react-semaphor 0.1.463 → 0.1.464

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.
Files changed (23) hide show
  1. package/dist/chunks/{dashboard-briefing-launcher-Dyf9-SMG.cjs → dashboard-briefing-launcher-BSMtcAgE.cjs} +1 -1
  2. package/dist/chunks/{dashboard-briefing-launcher-Dcfh50rg.js → dashboard-briefing-launcher-CTozRa6c.js} +2 -2
  3. package/dist/chunks/{dashboard-controls-Dk_4fD9Y.cjs → dashboard-controls-CmK7U1hI.cjs} +1 -1
  4. package/dist/chunks/{dashboard-controls-Cux9l7G3.js → dashboard-controls-wuo6PrDm.js} +3 -3
  5. package/dist/chunks/{dashboard-json-6vY_UIQ9.cjs → dashboard-json-7BQDKnHy.cjs} +1 -1
  6. package/dist/chunks/{dashboard-json-CLSh4K-P.js → dashboard-json-C9qvau-c.js} +1 -1
  7. package/dist/chunks/{edit-dashboard-visual-BNNbxMoA.cjs → edit-dashboard-visual-BSWdyT4u.cjs} +1 -1
  8. package/dist/chunks/{edit-dashboard-visual-WYIa0u5O.js → edit-dashboard-visual-CHlsiGOo.js} +2 -2
  9. package/dist/chunks/{editor-action-buttons-DfKOZoQs.js → editor-action-buttons-B0o-qU4l.js} +1 -1
  10. package/dist/chunks/{editor-action-buttons-B1QYcu9f.cjs → editor-action-buttons-DMnbVoBJ.cjs} +1 -1
  11. package/dist/chunks/{index-BxQ_lHnZ.js → index-DQvtZ1gG.js} +6 -4
  12. package/dist/chunks/{index-BnsIn34X.cjs → index-DqMJN4lZ.cjs} +2 -2
  13. package/dist/chunks/{report-preferences-dialog-jy8Ck1pK.js → report-preferences-dialog-BP4YC4D_.js} +1 -1
  14. package/dist/chunks/{report-preferences-dialog-Cd7yCULW.cjs → report-preferences-dialog-CkKbfjRg.cjs} +1 -1
  15. package/dist/dashboard/index.cjs +1 -1
  16. package/dist/dashboard/index.js +1 -1
  17. package/dist/data-app-builder/index.cjs +1 -1
  18. package/dist/data-app-builder/index.js +1 -1
  19. package/dist/index.cjs +1 -1
  20. package/dist/index.js +4 -4
  21. package/dist/surfboard/index.cjs +1 -1
  22. package/dist/surfboard/index.js +2 -2
  23. package/package.json +1 -1
@@ -958,7 +958,7 @@ ${(e*100).toLocaleString()}%`}}},scales:{_index_:{display:!1,padding:10,grid:{di
958
958
  * This source code is licensed under the MIT license found in the
959
959
  * LICENSE file in the root directory of this source tree.
960
960
  */var Eq;function _Ke(){return Eq||(Eq=1,process.env.NODE_ENV!=="production"&&function(){function e(c,u){return c===u&&(c!==0||1/c===1/u)||c!==c&&u!==u}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var t=v,n=typeof Object.is=="function"?Object.is:e,r=t.useSyncExternalStore,o=t.useRef,s=t.useEffect,i=t.useMemo,a=t.useDebugValue;pM.useSyncExternalStoreWithSelector=function(c,u,d,f,h){var m=o(null);if(m.current===null){var g={hasValue:!1,value:null};m.current=g}else g=m.current;m=i(function(){function b(S){if(!y){if(y=!0,w=S,S=f(S),h!==void 0&&g.hasValue){var j=g.value;if(h(j,S))return C=j}return C=S}if(j=C,n(w,S))return j;var I=f(S);return h!==void 0&&h(j,I)?(w=S,j):(w=S,C=I)}var y=!1,w,C,N=d===void 0?null:d;return[function(){return b(u())},N===null?void 0:function(){return b(N())}]},[u,d,f,h]);var x=r(c,m[0],m[1]);return s(function(){g.hasValue=!0,g.value=x},[x]),a(x),x},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),pM}process.env.NODE_ENV==="production"?GP.exports=IKe():GP.exports=_Ke();var TKe=GP.exports;function Uo(e,t,n=mce){return TKe.useSyncExternalStoreWithSelector($n(r=>e.subscribe(EKe,r)),$n(()=>e.state),$n(()=>e.state),$n(t),n)}function EKe(e){return e}function bce(e,t){let n=v.useId(),r=_$.get(t),[o,s]=Uo(r,v.useCallback(i=>[r.selectors.isTop(i,n),r.selectors.inStack(i,n)],[r,n]));return ko(()=>{if(e)return r.actions.push(n),()=>r.actions.pop(n)},[r,e,n]),e?s?o:!0:!1}let YP=new Map,u0=new Map;function Dq(e){var t;let n=(t=u0.get(e))!=null?t:0;return u0.set(e,n+1),n!==0?()=>Mq(e):(YP.set(e,{"aria-hidden":e.getAttribute("aria-hidden"),inert:e.inert}),e.setAttribute("aria-hidden","true"),e.inert=!0,()=>Mq(e))}function Mq(e){var t;let n=(t=u0.get(e))!=null?t:1;if(n===1?u0.delete(e):u0.set(e,n-1),n!==1)return;let r=YP.get(e);r&&(r["aria-hidden"]===null?e.removeAttribute("aria-hidden"):e.setAttribute("aria-hidden",r["aria-hidden"]),e.inert=r.inert,YP.delete(e))}function DKe(e,{allowed:t,disallowed:n}={}){let r=bce(e,"inert-others");ko(()=>{var o,s;if(!r)return;let i=Oa();for(let c of(o=n==null?void 0:n())!=null?o:[])c&&i.add(Dq(c));let a=(s=t==null?void 0:t())!=null?s:[];for(let c of a){if(!c)continue;let u=$w(c);if(!u)continue;let d=c.parentElement;for(;d&&d!==u.body;){for(let f of d.children)a.some(h=>f.contains(h))||i.add(Dq(f));d=d.parentElement}}return i.dispose},[r,t,n])}function MKe(e,t,n){let r=ip(o=>{let s=o.getBoundingClientRect();s.x===0&&s.y===0&&s.width===0&&s.height===0&&n()});v.useEffect(()=>{if(!e)return;let o=t===null?null:Ef(t)?t:t.current;if(!o)return;let s=Oa();if(typeof ResizeObserver<"u"){let i=new ResizeObserver(()=>r.current(o));i.observe(o),s.add(()=>i.disconnect())}if(typeof IntersectionObserver<"u"){let i=new IntersectionObserver(()=>r.current(o));i.observe(o),s.add(()=>i.disconnect())}return()=>s.dispose()},[t,r,e])}let ZP=["[contentEditable=true]","[tabindex]","a[href]","area[href]","button:not([disabled])","iframe","input:not([disabled])","select:not([disabled])","details>summary","textarea:not([disabled])"].map(e=>`${e}:not([tabindex='-1'])`).join(",");var RKe=(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))(RKe||{}),AKe=(e=>(e[e.Error=0]="Error",e[e.Overflow=1]="Overflow",e[e.Success=2]="Success",e[e.Underflow=3]="Underflow",e))(AKe||{}),PKe=(e=>(e[e.Previous=-1]="Previous",e[e.Next=1]="Next",e))(PKe||{}),xce=(e=>(e[e.Strict=0]="Strict",e[e.Loose=1]="Loose",e))(xce||{});function FKe(e,t=0){var n;return e===((n=$w(e))==null?void 0:n.body)?!1:hc(t,{0(){return e.matches(ZP)},1(){let r=e;for(;r!==null;){if(r.matches(ZP))return!0;r=r.parentElement}return!1}})}var OKe=(e=>(e[e.Keyboard=0]="Keyboard",e[e.Mouse=1]="Mouse",e))(OKe||{});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 LKe(e,t=n=>n){return e.slice().sort((n,r)=>{let o=t(n),s=t(r);if(o===null||s===null)return 0;let i=o.compareDocumentPosition(s);return i&Node.DOCUMENT_POSITION_FOLLOWING?-1:i&Node.DOCUMENT_POSITION_PRECEDING?1:0})}function yce(){return/iPhone/gi.test(window.navigator.platform)||/Mac/gi.test(window.navigator.platform)&&window.navigator.maxTouchPoints>0}function $Ke(){return/Android/gi.test(window.navigator.userAgent)}function XP(){return yce()||$Ke()}function rg(e,t,n,r){let o=ip(n);v.useEffect(()=>{if(!e)return;function s(i){o.current(i)}return document.addEventListener(t,s,r),()=>document.removeEventListener(t,s,r)},[e,t,r])}function zKe(e,t,n,r){let o=ip(n);v.useEffect(()=>{if(!e)return;function s(i){o.current(i)}return window.addEventListener(t,s,r),()=>window.removeEventListener(t,s,r)},[e,t,r])}const Rq=30;function BKe(e,t,n){let r=ip(n),o=v.useCallback(function(a,c){if(a.defaultPrevented)return;let u=c(a);if(u===null||!u.getRootNode().contains(u)||!u.isConnected)return;let d=function f(h){return typeof h=="function"?f(h()):Array.isArray(h)||h instanceof Set?h:[h]}(t);for(let f of d)if(f!==null&&(f.contains(u)||a.composed&&a.composedPath().includes(f)))return;return!FKe(u,xce.Loose)&&u.tabIndex!==-1&&a.preventDefault(),r.current(a,u)},[r,t]),s=v.useRef(null);rg(e,"pointerdown",a=>{var c,u;XP()||(s.current=((u=(c=a.composedPath)==null?void 0:c.call(a))==null?void 0:u[0])||a.target)},!0),rg(e,"pointerup",a=>{if(XP()||!s.current)return;let c=s.current;return s.current=null,o(a,()=>c)},!0);let i=v.useRef({x:0,y:0});rg(e,"touchstart",a=>{i.current.x=a.touches[0].clientX,i.current.y=a.touches[0].clientY},!0),rg(e,"touchend",a=>{let c={x:a.changedTouches[0].clientX,y:a.changedTouches[0].clientY};if(!(Math.abs(c.x-i.current.x)>=Rq||Math.abs(c.y-i.current.y)>=Rq))return o(a,()=>vh(a.target)?a.target:null)},!0),zKe(e,"blur",a=>o(a,()=>rKe(window.document.activeElement)?window.document.activeElement:null),!0)}function QP(...e){return v.useMemo(()=>$w(...e),[...e])}var VKe=(e=>(e[e.Ignore=0]="Ignore",e[e.Select=1]="Select",e[e.Close=2]="Close",e))(VKe||{});const Hx={Ignore:{kind:0},Select:e=>({kind:1,target:e}),Close:{kind:2}},HKe=200,Aq=5;function qKe(e,{trigger:t,action:n,close:r,select:o}){let s=v.useRef(null),i=v.useRef(null),a=v.useRef(null);rg(e&&t!==null,"pointerdown",c=>{ice(c==null?void 0:c.target)&&t!=null&&t.contains(c.target)&&(i.current=c.x,a.current=c.y,s.current=c.timeStamp)}),rg(e&&t!==null,"pointerup",c=>{var u,d;let f=s.current;if(f===null||(s.current=null,!vh(c.target))||Math.abs(c.x-((u=i.current)!=null?u:c.x))<Aq&&Math.abs(c.y-((d=a.current)!=null?d:c.y))<Aq)return;let h=n(c);switch(h.kind){case 0:return;case 1:{c.timeStamp-f>HKe&&(o(h.target),r());break}case 2:{r();break}}},{capture:!0})}function UKe(e,t,n,r){let o=ip(n);v.useEffect(()=>{e=e??window;function s(i){o.current(i)}return e.addEventListener(t,s,r),()=>e.removeEventListener(t,s,r)},[e,t,r])}function vce(e){let t=v.useRef({value:"",selectionStart:null,selectionEnd:null});return UKe(e,"blur",n=>{let r=n.target;zj(r)&&(t.current={value:r.value,selectionStart:r.selectionStart,selectionEnd:r.selectionEnd})}),$n(()=>{if(!Qle(e)&&zj(e)&&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 WKe(e,t){return v.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 KKe(e){return v.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getSnapshot)}function GKe(e,t){let n=e(),r=new Set;return{getSnapshot(){return n},subscribe(o){return r.add(o),()=>r.delete(o)},dispatch(o,...s){let i=t[o].call(n,...s);i&&(n=i,r.forEach(a=>a()))}}}function YKe(){let e;return{before({doc:t}){var n;let r=t.documentElement,o=(n=t.defaultView)!=null?n:window;e=Math.max(0,o.innerWidth-r.clientWidth)},after({doc:t,d:n}){let r=t.documentElement,o=Math.max(0,r.clientWidth-r.offsetWidth),s=Math.max(0,e-o);n.style(r,"paddingRight",`${s}px`)}}}function ZKe(){return yce()?{before({doc:e,d:t,meta:n}){function r(o){for(let s of n().containers)for(let i of s())if(i.contains(o))return!0;return!1}t.microTask(()=>{var o;if(window.getComputedStyle(e.documentElement).scrollBehavior!=="auto"){let a=Oa();a.style(e.documentElement,"scrollBehavior","auto"),t.add(()=>t.microTask(()=>a.dispose()))}let s=(o=window.scrollY)!=null?o:window.pageYOffset,i=null;t.addEventListener(e,"click",a=>{if(vh(a.target))try{let c=a.target.closest("a");if(!c)return;let{hash:u}=new URL(c.href),d=e.querySelector(u);vh(d)&&!r(d)&&(i=d)}catch{}},!0),t.group(a=>{t.addEventListener(e,"touchstart",c=>{if(a.dispose(),vh(c.target)&&nKe(c.target))if(r(c.target)){let u=c.target;for(;u.parentElement&&r(u.parentElement);)u=u.parentElement;a.style(u,"overscrollBehavior","contain")}else a.style(c.target,"touchAction","none")})}),t.addEventListener(e,"touchmove",a=>{if(vh(a.target)){if(zj(a.target))return;if(r(a.target)){let c=a.target;for(;c.parentElement&&c.dataset.headlessuiPortal!==""&&!(c.scrollHeight>c.clientHeight||c.scrollWidth>c.clientWidth);)c=c.parentElement;c.dataset.headlessuiPortal===""&&a.preventDefault()}else a.preventDefault()}},{passive:!1}),t.add(()=>{var a;let c=(a=window.scrollY)!=null?a:window.pageYOffset;s!==c&&window.scrollTo(0,s),i&&i.isConnected&&(i.scrollIntoView({block:"nearest"}),i=null)})})}}:{}}function XKe(){return{before({doc:e,d:t}){t.style(e.documentElement,"overflow","hidden")}}}function Pq(e){let t={};for(let n of e)Object.assign(t,n(t));return t}let wh=GKe(()=>new Map,{PUSH(e,t){var n;let r=(n=this.get(e))!=null?n:{doc:e,count:0,d:Oa(),meta:new Set,computedMeta:{}};return r.count++,r.meta.add(t),r.computedMeta=Pq(r.meta),this.set(e,r),this},POP(e,t){let n=this.get(e);return n&&(n.count--,n.meta.delete(t),n.computedMeta=Pq(n.meta)),this},SCROLL_PREVENT(e){let t={doc:e.doc,d:e.d,meta(){return e.computedMeta}},n=[ZKe(),YKe(),XKe()];n.forEach(({before:r})=>r==null?void 0:r(t)),n.forEach(({after:r})=>r==null?void 0:r(t))},SCROLL_ALLOW({d:e}){e.dispose()},TEARDOWN({doc:e}){this.delete(e)}});wh.subscribe(()=>{let e=wh.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",o=n.count!==0;(o&&!r||!o&&r)&&wh.dispatch(n.count>0?"SCROLL_PREVENT":"SCROLL_ALLOW",n),n.count===0&&wh.dispatch("TEARDOWN",n)}});function QKe(e,t,n=()=>({containers:[]})){let r=KKe(wh),o=t?r.get(t):void 0,s=o?o.count>0:!1;return ko(()=>{if(!(!t||!e))return wh.dispatch("PUSH",t,n),()=>wh.dispatch("POP",t,n)},[e,t]),s}function JKe(e,t,n=()=>[document.body]){let r=bce(e,"scroll-lock");QKe(r,t,o=>{var s;return{containers:[...(s=o.containers)!=null?s:[],n]}})}function Fq(e){return[e.screenX,e.screenY]}function eGe(){let e=v.useRef([-1,-1]);return{wasMoved(t){let n=Fq(t);return e.current[0]===n[0]&&e.current[1]===n[1]?!1:(e.current=n,!0)},update(t){e.current=Fq(t)}}}function tGe(e=0){let[t,n]=v.useState(e),r=v.useCallback(c=>n(c),[]),o=v.useCallback(c=>n(u=>u|c),[]),s=v.useCallback(c=>(t&c)===c,[t]),i=v.useCallback(c=>n(u=>u&~c),[]),a=v.useCallback(c=>n(u=>u^c),[]);return{flags:t,setFlag:r,addFlag:o,hasFlag:s,removeFlag:i,toggleFlag:a}}var Oq,Lq;typeof process<"u"&&typeof globalThis<"u"&&typeof Element<"u"&&((Oq=process==null?void 0:process.env)==null?void 0:Oq.NODE_ENV)==="test"&&typeof((Lq=Element==null?void 0:Element.prototype)==null?void 0:Lq.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(`
961
- `)),[]});var nGe=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(nGe||{});function rGe(e){let t={};for(let n in e)e[n]===!0&&(t[`data-${n}`]="");return t}function oGe(e,t,n,r){let[o,s]=v.useState(n),{hasFlag:i,addFlag:a,removeFlag:c}=tGe(e&&o?3:0),u=v.useRef(!1),d=v.useRef(!1),f=Qb();return ko(()=>{var h;if(e){if(n&&s(!0),!t){n&&a(3);return}return(h=void 0)==null||h.call(r,n),sGe(t,{inFlight:u,prepare(){d.current?d.current=!1:d.current=u.current,u.current=!0,!d.current&&(n?(a(3),c(4)):(a(4),c(2)))},run(){d.current?n?(c(3),a(4)):(c(4),a(3)):n?c(1):a(1)},done(){var m;d.current&&lGe(t)||(u.current=!1,c(7),n||s(!1),(m=void 0)==null||m.call(r,n))}})}},[e,n,t,f]),e?[o,{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 sGe(e,{prepare:t,run:n,done:r,inFlight:o}){let s=Oa();return aGe(e,{prepare:t,inFlight:o}),s.nextFrame(()=>{n(),s.requestAnimationFrame(()=>{s.add(iGe(e,r))})}),s.dispose}function iGe(e,t){var n,r;let o=Oa();if(!e)return o.dispose;let s=!1;o.add(()=>{s=!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(),o.dispose):(Promise.allSettled(i.map(a=>a.finished)).then(()=>{s||t()}),o.dispose)}function aGe(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 lGe(e){var t,n;return((n=(t=e.getAnimations)==null?void 0:t.call(e))!=null?n:[]).some(r=>r instanceof CSSTransition&&r.playState!=="finished")}function cGe(e,{container:t,accept:n,walk:r}){let o=v.useRef(n),s=v.useRef(r);v.useEffect(()=>{o.current=n,s.current=r},[n,r]),ko(()=>{if(!t||!e)return;let i=$w(t);if(!i)return;let a=o.current,c=s.current,u=Object.assign(f=>a(f),{acceptNode:a}),d=i.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,u,!1);for(;d.nextNode();)c(d.currentNode)},[t,e,o,s])}function $q(e,t){let n=v.useRef([]),r=$n(e);v.useEffect(()=>{let o=[...n.current];for(let[s,i]of t.entries())if(n.current[s]!==i){let a=r(t,o);return n.current=t,a}},[r,...t])}function uGe(){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 wce={...te},dGe=wce.useInsertionEffect,fGe=dGe||(e=>e());function Cce(e){const t=te.useRef(()=>{if(process.env.NODE_ENV!=="production")throw new Error("Cannot call an event handler while rendering.")});return fGe(()=>{t.current=e}),te.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}var JP=typeof document<"u"?v.useLayoutEffect:v.useEffect;let zq=!1,hGe=0;const Bq=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+hGe++;function mGe(){const[e,t]=te.useState(()=>zq?Bq():void 0);return JP(()=>{e==null&&t(Bq())},[]),te.useEffect(()=>{zq=!0},[]),e}const pGe=wce.useId,gGe=pGe||mGe;let iv;process.env.NODE_ENV!=="production"&&(iv=new Set);function bGe(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];const o="Floating UI: "+n.join(" ");if(!((e=iv)!=null&&e.has(o))){var s;(s=iv)==null||s.add(o),console.warn(o)}}function xGe(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];const o="Floating UI: "+n.join(" ");if(!((e=iv)!=null&&e.has(o))){var s;(s=iv)==null||s.add(o),console.error(o)}}function yGe(){const e=new Map;return{emit(t,n){var r;(r=e.get(t))==null||r.forEach(o=>o(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(o=>o!==n))||[])}}}const vGe=te.createContext(null),wGe=te.createContext(null),CGe=()=>{var e;return((e=te.useContext(vGe))==null?void 0:e.id)||null},SGe=()=>te.useContext(wGe),NGe="data-floating-ui-focusable";function jGe(e){const{open:t=!1,onOpenChange:n,elements:r}=e,o=gGe(),s=te.useRef({}),[i]=te.useState(()=>yGe()),a=CGe()!=null;if(process.env.NODE_ENV!=="production"){const m=r.reference;m&&!p.isElement(m)&&xGe("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[c,u]=te.useState(r.reference),d=Cce((m,g,x)=>{s.current.openEvent=m?g:void 0,i.emit("openchange",{open:m,event:g,reason:x,nested:a}),n==null||n(m,g,x)}),f=te.useMemo(()=>({setPositionReference:u}),[]),h=te.useMemo(()=>({reference:c||r.reference||null,floating:r.floating||null,domReference:r.reference}),[c,r.reference,r.floating]);return te.useMemo(()=>({dataRef:s,open:t,onOpenChange:d,elements:h,events:i,floatingId:o,refs:f}),[t,d,h,i,o,f])}function kGe(e){e===void 0&&(e={});const{nodeId:t}=e,n=jGe({...e,elements:{reference:null,floating:null,...e.elements}}),r=e.rootContext||n,o=r.elements,[s,i]=te.useState(null),[a,c]=te.useState(null),d=(o==null?void 0:o.domReference)||s,f=te.useRef(null),h=SGe();JP(()=>{d&&(f.current=d)},[d]);const m=p.useFloating({...e,elements:{...o,...a&&{reference:a}}}),g=te.useCallback(C=>{const N=p.isElement(C)?{getBoundingClientRect:()=>C.getBoundingClientRect(),contextElement:C}:C;c(N),m.refs.setReference(N)},[m.refs]),x=te.useCallback(C=>{(p.isElement(C)||C===null)&&(f.current=C,i(C)),(p.isElement(m.refs.reference.current)||m.refs.reference.current===null||C!==null&&!p.isElement(C))&&m.refs.setReference(C)},[m.refs]),b=te.useMemo(()=>({...m.refs,setReference:x,setPositionReference:g,domReference:f}),[m.refs,x,g]),y=te.useMemo(()=>({...m.elements,domReference:d}),[m.elements,d]),w=te.useMemo(()=>({...m,...r,refs:b,elements:y,nodeId:t}),[m,b,y,t,r]);return JP(()=>{r.dataRef.current.floatingContext=w;const C=h==null?void 0:h.nodesRef.current.find(N=>N.id===t);C&&(C.context=w)}),te.useMemo(()=>({...m,context:w,refs:b,elements:y}),[m,b,y,w])}const Vq="active",Hq="selected";function gM(e,t,n){const r=new Map,o=n==="item";let s=e;if(o&&e){const{[Vq]:i,[Hq]:a,...c}=e;s=c}return{...n==="floating"&&{tabIndex:-1,[NGe]:""},...s,...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(c=>{let[u,d]=c;if(!(o&&[Vq,Hq].includes(u)))if(u.indexOf("on")===0){if(r.has(u)||r.set(u,[]),typeof d=="function"){var f;(f=r.get(u))==null||f.push(d),i[u]=function(){for(var h,m=arguments.length,g=new Array(m),x=0;x<m;x++)g[x]=arguments[x];return(h=r.get(u))==null?void 0:h.map(b=>b(...g)).find(b=>b!==void 0)}}}else i[u]=d}),i),{})}}function IGe(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),o=te.useCallback(a=>gM(a,e,"reference"),t),s=te.useCallback(a=>gM(a,e,"floating"),n),i=te.useCallback(a=>gM(a,e,"item"),r);return te.useMemo(()=>({getReferenceProps:o,getFloatingProps:s,getItemProps:i}),[o,s,i])}function qq(e,t){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:t}}}}const _Ge=e=>({name:"inner",options:e,async fn(t){const{listRef:n,overflowRef:r,onFallbackChange:o,offset:s=0,index:i=0,minItemsVisible:a=4,referenceOverflowThreshold:c=0,scrollRef:u,...d}=p.evaluate(e,t),{rects:f,elements:{floating:h}}=t,m=n.current[i],g=(u==null?void 0:u.current)||h,x=h.clientTop||g.clientTop,b=h.clientTop!==0,y=g.clientTop!==0,w=h===g;if(process.env.NODE_ENV!=="production"&&(t.placement.startsWith("bottom")||bGe('`placement` side must be "bottom" when using the `inner`',"middleware.")),!m)return{};const C={...t,...await p.offset(-m.offsetTop-h.clientTop-f.reference.height/2-m.offsetHeight/2-s).fn(t)},N=await p.detectOverflow(qq(C,g.scrollHeight+x+h.clientTop),d),S=await p.detectOverflow(C,{...d,elementContext:"reference"}),j=p.max(0,N.top),I=C.y+j,_=(g.scrollHeight>g.clientHeight?E=>E:p.round)(p.max(0,g.scrollHeight+(b&&w||y?x*2:0)-j-p.max(0,N.bottom)));if(g.style.maxHeight=_+"px",g.scrollTop=j,o){const E=g.offsetHeight<m.offsetHeight*p.min(a,n.current.length)-1||S.top>=-c||S.bottom>=-c;Q2.flushSync(()=>o(E))}return r&&(r.current=await p.detectOverflow(qq({...C,y:I},g.offsetHeight+x+h.clientTop),d)),{y:I}}});function TGe(e,t){const{open:n,elements:r}=e,{enabled:o=!0,overflowRef:s,scrollRef:i,onChange:a}=t,c=Cce(a),u=te.useRef(!1),d=te.useRef(null),f=te.useRef(null);te.useEffect(()=>{if(!o)return;function m(x){if(x.ctrlKey||!g||s.current==null)return;const b=x.deltaY,y=s.current.top>=-.5,w=s.current.bottom>=-.5,C=g.scrollHeight-g.clientHeight,N=b<0?-1:1,S=b<0?"max":"min";g.scrollHeight<=g.clientHeight||(!y&&b>0||!w&&b<0?(x.preventDefault(),Q2.flushSync(()=>{c(j=>j+Math[S](b,C*N))})):/firefox/i.test(uGe())&&(g.scrollTop+=b))}const g=(i==null?void 0:i.current)||r.floating;if(n&&g)return g.addEventListener("wheel",m),requestAnimationFrame(()=>{d.current=g.scrollTop,s.current!=null&&(f.current={...s.current})}),()=>{d.current=null,f.current=null,g.removeEventListener("wheel",m)}},[o,n,r.floating,s,i,c]);const h=te.useMemo(()=>({onKeyDown(){u.current=!0},onWheel(){u.current=!1},onPointerMove(){u.current=!1},onScroll(){const m=(i==null?void 0:i.current)||r.floating;if(!(!s.current||!m||!u.current)){if(d.current!==null){const g=m.scrollTop-d.current;(s.current.bottom<-.5&&g<-1||s.current.top<-.5&&g>1)&&Q2.flushSync(()=>c(x=>x+g))}requestAnimationFrame(()=>{d.current=m.scrollTop})}}}),[r.floating,c,s,i]);return te.useMemo(()=>o?{floating:h}:{},[o,h])}let zw=v.createContext({styles:void 0,setReference:()=>{},setFloating:()=>{},getReferenceProps:()=>({}),getFloatingProps:()=>({}),slot:{}});zw.displayName="FloatingContext";let T$=v.createContext(null);T$.displayName="PlacementContext";function EGe(e){return v.useMemo(()=>e?typeof e=="string"?{to:e}:e:null,[e])}function DGe(){return v.useContext(zw).setReference}function MGe(){let{getFloatingProps:e,slot:t}=v.useContext(zw);return v.useCallback((...n)=>Object.assign({},e(...n),{"data-anchor":t.anchor}),[e,t])}function RGe(e=null){e===!1&&(e=null),typeof e=="string"&&(e={to:e});let t=v.useContext(T$),n=v.useMemo(()=>e,[JSON.stringify(e,(o,s)=>{var i;return(i=s==null?void 0:s.outerHTML)!=null?i:s})]);ko(()=>{t==null||t(n??null)},[t,n]);let r=v.useContext(zw);return v.useMemo(()=>[r.setFloating,e?r.styles:{}],[r.setFloating,e,r.styles])}let Uq=4;function AGe({children:e,enabled:t=!0}){let[n,r]=v.useState(null),[o,s]=v.useState(0),i=v.useRef(null),[a,c]=v.useState(null);PGe(a);let u=t&&n!==null&&a!==null,{to:d="bottom",gap:f=0,offset:h=0,padding:m=0,inner:g}=FGe(n,a),[x,b="center"]=d.split(" ");ko(()=>{u&&s(0)},[u]);let{refs:y,floatingStyles:w,context:C}=kGe({open:u,placement:x==="selection"?b==="center"?"bottom":`bottom-${b}`:b==="center"?`${x}`:`${x}-${b}`,strategy:"absolute",transform:!1,middleware:[p.offset({mainAxis:x==="selection"?0:f,crossAxis:h}),p.shift({padding:m}),x!=="selection"&&p.flip({padding:m}),x==="selection"&&g?_Ge({...g,padding:m,overflowRef:i,offset:o,minItemsVisible:Uq,referenceOverflowThreshold:m,onFallbackChange(E){var D,M;if(!E)return;let P=C.elements.floating;if(!P)return;let A=parseFloat(getComputedStyle(P).scrollPaddingBottom)||0,L=Math.min(Uq,P.childElementCount),O=0,B=0;for(let H of(M=(D=C.elements.floating)==null?void 0:D.childNodes)!=null?M:[])if(Ef(H)){let R=H.offsetTop,V=R+H.clientHeight+A,z=P.scrollTop,F=z+P.clientHeight;if(R>=z&&V<=F)L--;else{B=Math.max(0,Math.min(V,F)-Math.max(R,z)),O=H.clientHeight;break}}L>=1&&s(H=>{let R=O*L-B+A;return H>=R?H:R})}}):null,p.size({padding:m,apply({availableWidth:E,availableHeight:D,elements:M}){Object.assign(M.floating.style,{overflow:"auto",maxWidth:`${E}px`,maxHeight:`min(var(--anchor-max-height, 100vh), ${D}px)`})}})].filter(Boolean),whileElementsMounted:p.autoUpdate}),[N=x,S=b]=C.placement.split("-");x==="selection"&&(N="selection");let j=v.useMemo(()=>({anchor:[N,S].filter(Boolean).join(" ")}),[N,S]),I=TGe(C,{overflowRef:i,onChange:s}),{getReferenceProps:k,getFloatingProps:T}=IGe([I]),_=$n(E=>{c(E),y.setFloating(E)});return te.createElement(T$.Provider,{value:r},te.createElement(zw.Provider,{value:{setFloating:_,setReference:y.setReference,styles:w,getReferenceProps:k,getFloatingProps:T,slot:j}},e))}function PGe(e){ko(()=>{if(!e)return;let t=new MutationObserver(()=>{let n=window.getComputedStyle(e).maxHeight,r=parseFloat(n);if(isNaN(r))return;let o=parseInt(n);isNaN(o)||r!==o&&(e.style.maxHeight=`${Math.ceil(r)}px`)});return t.observe(e,{attributes:!0,attributeFilter:["style"]}),()=>{t.disconnect()}},[e])}function FGe(e,t){var n,r,o;let s=bM((n=e==null?void 0:e.gap)!=null?n:"var(--anchor-gap, 0)",t),i=bM((r=e==null?void 0:e.offset)!=null?r:"var(--anchor-offset, 0)",t),a=bM((o=e==null?void 0:e.padding)!=null?o:"var(--anchor-padding, 0)",t);return{...e,gap:s,offset:i,padding:a}}function bM(e,t,n=void 0){let r=Qb(),o=$n((c,u)=>{if(c==null)return[n,null];if(typeof c=="number")return[c,null];if(typeof c=="string"){if(!u)return[n,null];let d=Wq(c,u);return[d,f=>{let h=Sce(c);{let m=h.map(g=>window.getComputedStyle(u).getPropertyValue(g));r.requestAnimationFrame(function g(){r.nextFrame(g);let x=!1;for(let[y,w]of h.entries()){let C=window.getComputedStyle(u).getPropertyValue(w);if(m[y]!==C){m[y]=C,x=!0;break}}if(!x)return;let b=Wq(c,u);d!==b&&(f(b),d=b)})}return r.dispose}]}return[n,null]}),s=v.useMemo(()=>o(e,t)[0],[e,t]),[i=s,a]=v.useState();return ko(()=>{let[c,u]=o(e,t);if(a(c),!!u)return u(a)},[e,t]),i}function Sce(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(),o=t[1].slice(n+1).trim();return o?[r,...Sce(o)]:[r]}return[]}function Wq(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 OGe({children:e,freeze:t},n){let r=eF(t,e);return v.isValidElement(r)?v.cloneElement(r,{ref:n}):v.createElement(v.Fragment,null,r)}const LGe=v.forwardRef(OGe);function eF(e,t){let[n,r]=v.useState(t);return!e&&n!==t&&r(t),e?n:t}let E$=v.createContext(null);E$.displayName="OpenClosedContext";var av=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(av||{});function $Ge(){return v.useContext(E$)}function zGe({value:e,children:t}){return v.createElement(E$.Provider,{value:e},t)}function BGe(e){function t(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",t))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",t),t())}let lh=[];BGe(()=>{function e(t){if(!vh(t.target)||t.target===document.body||lh[0]===t.target)return;let n=t.target;n=n.closest(ZP),lh.unshift(n??t.target),lh=lh.filter(r=>r!=null&&r.isConnected),lh.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 VGe(e){throw new Error("Unexpected object: "+e)}var $o=(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))($o||{});function Kq(e,t){let n=t.resolveItems();if(n.length<=0)return null;let r=t.resolveActiveIndex(),o=r??-1;switch(e.focus){case 0:{for(let s=0;s<n.length;++s)if(!t.resolveDisabled(n[s],s,n))return s;return r}case 1:{o===-1&&(o=n.length);for(let s=o-1;s>=0;--s)if(!t.resolveDisabled(n[s],s,n))return s;return r}case 2:{for(let s=o+1;s<n.length;++s)if(!t.resolveDisabled(n[s],s,n))return s;return r}case 3:{for(let s=n.length-1;s>=0;--s)if(!t.resolveDisabled(n[s],s,n))return s;return r}case 4:{for(let s=0;s<n.length;++s)if(t.resolveId(n[s],s,n)===e.id)return s;return r}case 5:return null;default:VGe(e)}}function Nce(e){let t=$n(e),n=v.useRef(!1);v.useEffect(()=>(n.current=!1,()=>{n.current=!0,Jle(()=>{n.current&&t()})}),[t])}let HGe=v.createContext(!1);function qGe(){return v.useContext(HGe)}function UGe(e){let t=qGe(),n=v.useContext(kce),[r,o]=v.useState(()=>{var s;if(!t&&n!==null)return(s=n.current)!=null?s:null;if(Qh.isServer)return null;let i=e==null?void 0:e.getElementById("headlessui-portal-root");if(i)return i;if(e===null)return null;let a=e.createElement("div");return a.setAttribute("id","headlessui-portal-root"),e.body.appendChild(a)});return v.useEffect(()=>{r!==null&&(e!=null&&e.body.contains(r)||e==null||e.body.appendChild(r))},[r,e]),v.useEffect(()=>{t||n!==null&&o(n.current)},[n,o,t]),r}let jce=v.Fragment,WGe=Cl(function(e,t){let{ownerDocument:n=null,...r}=e,o=v.useRef(null),s=Ku(aKe(h=>{o.current=h}),t),i=QP(o.current),a=n??i,c=UGe(a),u=v.useContext(ZGe),d=Qb(),f=wl();return Nce(()=>{var h;c&&c.childNodes.length<=0&&((h=c.parentElement)==null||h.removeChild(c))}),c?vr.createPortal(v.createElement("div",{"data-headlessui-portal":"",ref:h=>{d.dispose(),u&&h&&d.add(u.register(h))}},f({ourProps:{ref:s},theirProps:r,slot:{},defaultTag:jce,name:"Portal"})),c):null});function KGe(e,t){let n=Ku(t),{enabled:r=!0,ownerDocument:o,...s}=e,i=wl();return r?v.createElement(WGe,{...s,ownerDocument:o,ref:n}):i({ourProps:{ref:n},theirProps:s,slot:{},defaultTag:jce,name:"Portal"})}let GGe=v.Fragment,kce=v.createContext(null);function YGe(e,t){let{target:n,...r}=e,o={ref:Ku(t)},s=wl();return v.createElement(kce.Provider,{value:n},s({ourProps:o,theirProps:r,defaultTag:GGe,name:"Popover.Group"}))}let ZGe=v.createContext(null),XGe=Cl(KGe),QGe=Cl(YGe),JGe=Object.assign(XGe,{Group:QGe});const ky={Idle:{kind:"Idle"},Tracked:e=>({kind:"Tracked",position:e}),Moved:{kind:"Moved"}};function Ice(e){let t=e.getBoundingClientRect();return`${t.x},${t.y}`}function eYe(e,t,n){let r=Oa();if(t.kind==="Tracked"){let o=function(){s!==Ice(e)&&(r.dispose(),n())},{position:s}=t,i=new ResizeObserver(o);i.observe(e),r.add(()=>i.disconnect()),r.addEventListener(window,"scroll",o,{passive:!0}),r.addEventListener(window,"resize",o)}return()=>r.dispose()}var tYe=Object.defineProperty,nYe=(e,t,n)=>t in e?tYe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Gq=(e,t,n)=>(nYe(e,typeof t!="symbol"?t+"":t,n),n),Dn=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(Dn||{}),Vi=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(Vi||{}),rc=(e=>(e[e.Pointer=0]="Pointer",e[e.Focus=1]="Focus",e[e.Other=2]="Other",e))(rc||{}),_ce=(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.DefaultToFirstOption=6]="DefaultToFirstOption",e[e.SetActivationTrigger=7]="SetActivationTrigger",e[e.UpdateVirtualConfiguration=8]="UpdateVirtualConfiguration",e[e.SetInputElement=9]="SetInputElement",e[e.SetButtonElement=10]="SetButtonElement",e[e.SetOptionsElement=11]="SetOptionsElement",e[e.MarkInputAsMoved=12]="MarkInputAsMoved",e))(_ce||{});function xM(e,t=n=>n){let n=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,r=t(e.options.slice()),o=r.length>0&&r[0].dataRef.current.order!==null?r.sort((i,a)=>i.dataRef.current.order-a.dataRef.current.order):LKe(r,i=>i.dataRef.current.domRef.current),s=n?o.indexOf(n):null;return s===-1&&(s=null),{options:o,activeOptionIndex:s}}let rYe={1(e){var t;if((t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===1)return e;let n=e.inputElement?ky.Tracked(Ice(e.inputElement)):e.inputPositionState;return{...e,activeOptionIndex:null,comboboxState:1,isTyping:!1,activationTrigger:2,inputPositionState:n,__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,inputPositionState:ky.Idle}}return{...e,comboboxState:0,inputPositionState:ky.Idle,__demoMode:!1}},3(e,t){return e.isTyping===t.isTyping?e:{...e,isTyping:t.isTyping}},2(e,t){var n,r,o,s;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:u,disabled:d}=e.virtual,f=t.focus===$o.Specific?t.idx:Kq(t,{resolveItems:()=>u,resolveActiveIndex:()=>{var m,g;return(g=(m=e.activeOptionIndex)!=null?m:u.findIndex(x=>!d(x)))!=null?g:null},resolveDisabled:d,resolveId(){throw new Error("Function not implemented.")}}),h=(o=t.trigger)!=null?o:2;return e.activeOptionIndex===f&&e.activationTrigger===h?e:{...e,activeOptionIndex:f,activationTrigger:h,isTyping:!1,__demoMode:!1}}let i=xM(e);if(i.activeOptionIndex===null){let u=i.options.findIndex(d=>!d.dataRef.current.disabled);u!==-1&&(i.activeOptionIndex=u)}let a=t.focus===$o.Specific?t.idx:Kq(t,{resolveItems:()=>i.options,resolveActiveIndex:()=>i.activeOptionIndex,resolveId:u=>u.id,resolveDisabled:u=>u.dataRef.current.disabled}),c=(s=t.trigger)!=null?s:2;return e.activeOptionIndex===a&&e.activationTrigger===c?e:{...e,...i,isTyping:!1,activeOptionIndex:a,activationTrigger:c,__demoMode:!1}},4:(e,t)=>{var n,r,o,s;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:[...e.options,t.payload]};let i=t.payload,a=xM(e,u=>(u.push(i),u));e.activeOptionIndex===null&&(o=(r=e.dataRef.current).isSelected)!=null&&o.call(r,t.payload.dataRef.current.value)&&(a.activeOptionIndex=a.options.indexOf(i));let c={...e,...a,activationTrigger:2};return(s=e.dataRef.current)!=null&&s.__demoMode&&e.dataRef.current.value===void 0&&(c.activeOptionIndex=0),c},5:(e,t)=>{var n;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:e.options.filter(o=>o.id!==t.id)};let r=xM(e,o=>{let s=o.findIndex(i=>i.id===t.id);return s!==-1&&o.splice(s,1),o});return{...e,...r,activationTrigger:2}},6:(e,t)=>e.defaultToFirstOption===t.value?e:{...e,defaultToFirstOption:t.value},7:(e,t)=>e.activationTrigger===t.trigger?e:{...e,activationTrigger:t.trigger},8:(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 o=e.activeOptionIndex;if(e.activeOptionIndex!==null){let s=t.options.indexOf(e.virtual.options[e.activeOptionIndex]);s!==-1?o=s:o=null}return{...e,activeOptionIndex:o,virtual:{options:t.options,disabled:(r=t.disabled)!=null?r:()=>!1}}},9:(e,t)=>e.inputElement===t.element?e:{...e,inputElement:t.element},10:(e,t)=>e.buttonElement===t.element?e:{...e,buttonElement:t.element},11:(e,t)=>e.optionsElement===t.element?e:{...e,optionsElement:t.element},12(e){return e.inputPositionState.kind!=="Tracked"?e:{...e,inputPositionState:ky.Moved}}};class D$ extends hce{constructor(t){super(t),Gq(this,"actions",{onChange:n=>{let{onChange:r,compare:o,mode:s,value:i}=this.state.dataRef.current;return hc(s,{0:()=>r==null?void 0:r(n),1:()=>{let a=i.slice(),c=a.findIndex(u=>o(u,n));return c===-1?a.push(n):a.splice(c,1),r==null?void 0:r(a)}})},registerOption:(n,r)=>(this.send({type:4,payload:{id:n,dataRef:r}}),()=>{this.state.activeOptionIndex===this.state.dataRef.current.calculateIndex(r.current.value)&&this.send({type:6,value:!0}),this.send({type:5,id:n})}),goToOption:(n,r)=>(this.send({type:6,value:!1}),this.send({type:2,...n,trigger:r})),setIsTyping:n=>{this.send({type:3,isTyping:n})},closeCombobox:()=>{var n,r;this.send({type:1}),this.send({type:6,value:!1}),(r=(n=this.state.dataRef.current).onClose)==null||r.call(n)},openCombobox:()=>{this.send({type:0}),this.send({type:6,value:!0})},setActivationTrigger:n=>{this.send({type:7,trigger:n})},selectActiveOption:()=>{let n=this.selectors.activeOptionIndex(this.state);if(n!==null){if(this.actions.setIsTyping(!1),this.state.virtual)this.actions.onChange(this.state.virtual.options[n]);else{let{dataRef:r}=this.state.options[n];this.actions.onChange(r.current.value)}this.actions.goToOption({focus:$o.Specific,idx:n})}},setInputElement:n=>{this.send({type:9,element:n})},setButtonElement:n=>{this.send({type:10,element:n})},setOptionsElement:n=>{this.send({type:11,element:n})}}),Gq(this,"selectors",{activeDescendantId:n=>{var r,o;let s=this.selectors.activeOptionIndex(n);if(s!==null)return n.virtual?(o=n.options.find(i=>!i.dataRef.current.disabled&&n.dataRef.current.compare(i.dataRef.current.value,n.virtual.options[s])))==null?void 0:o.id:(r=n.options[s])==null?void 0:r.id},activeOptionIndex:n=>{if(n.defaultToFirstOption&&n.activeOptionIndex===null&&(n.virtual?n.virtual.options.length>0:n.options.length>0)){if(n.virtual){let{options:o,disabled:s}=n.virtual,i=o.findIndex(a=>{var c;return!((c=s==null?void 0:s(a))!=null&&c)});if(i!==-1)return i}let r=n.options.findIndex(o=>!o.dataRef.current.disabled);if(r!==-1)return r}return n.activeOptionIndex},activeOption:n=>{var r,o;let s=this.selectors.activeOptionIndex(n);return s===null?null:n.virtual?n.virtual.options[s??0]:(o=(r=n.options[s])==null?void 0:r.dataRef.current.value)!=null?o:null},isActive:(n,r,o)=>{var s;let i=this.selectors.activeOptionIndex(n);return i===null?!1:n.virtual?i===n.dataRef.current.calculateIndex(r):((s=n.options[i])==null?void 0:s.id)===o},shouldScrollIntoView:(n,r,o)=>!(n.virtual||n.__demoMode||n.comboboxState!==0||n.activationTrigger===0||!this.selectors.isActive(n,r,o)),didInputMove(n){return n.inputPositionState.kind==="Moved"}});{let n=this.state.id,r=_$.get(null);this.disposables.add(r.on(pce.Push,o=>{!r.selectors.isTop(o,n)&&this.state.comboboxState===0&&this.actions.closeCombobox()})),this.on(0,()=>r.actions.push(n)),this.on(1,()=>r.actions.pop(n))}this.disposables.group(n=>{this.on(1,r=>{r.inputElement&&(n.dispose(),n.add(eYe(r.inputElement,r.inputPositionState,()=>{this.send({type:12})})))})})}static new({id:t,virtual:n=null,__demoMode:r=!1}){var o;return new D$({id:t,dataRef:{current:{}},comboboxState:r?0:1,isTyping:!1,options:[],virtual:n?{options:n.options,disabled:(o=n.disabled)!=null?o:()=>!1}:null,activeOptionIndex:null,activationTrigger:2,inputElement:null,buttonElement:null,optionsElement:null,__demoMode:r,inputPositionState:ky.Idle})}reduce(t,n){return hc(n.type,rYe,t,n)}}const Tce=v.createContext(null);function Bw(e){let t=v.useContext(Tce);if(t===null){let n=new Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,Ece),n}return t}function Ece({id:e,virtual:t=null,__demoMode:n=!1}){let r=v.useMemo(()=>D$.new({id:e,virtual:t,__demoMode:n}),[]);return Nce(()=>r.dispose()),r}let lv=v.createContext(null);lv.displayName="ComboboxDataContext";function Jb(e){let t=v.useContext(lv);if(t===null){let n=new Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,Jb),n}return t}let Dce=v.createContext(null);function oYe(e){let t=Bw("VirtualProvider"),n=Jb("VirtualProvider"),{options:r}=n.virtual,o=Uo(t,m=>m.optionsElement),[s,i]=v.useMemo(()=>{let m=o;if(!m)return[0,0];let g=window.getComputedStyle(m);return[parseFloat(g.paddingBlockStart||g.paddingTop),parseFloat(g.paddingBlockEnd||g.paddingBottom)]},[o]),a=v_({enabled:r.length!==0,scrollPaddingStart:s,scrollPaddingEnd:i,count:r.length,estimateSize(){return 40},getScrollElement(){return t.state.optionsElement},overscan:12}),[c,u]=v.useState(0);ko(()=>{u(m=>m+1)},[r]);let d=a.getVirtualItems(),f=Uo(t,m=>m.activationTrigger===rc.Pointer),h=Uo(t,t.selectors.activeOptionIndex);return d.length===0?null:v.createElement(Dce.Provider,{value:a},v.createElement("div",{style:{position:"relative",width:"100%",height:`${a.getTotalSize()}px`},ref:m=>{m&&(f||h!==null&&r.length>h&&a.scrollToIndex(h))}},d.map(m=>{var g;return v.createElement(v.Fragment,{key:m.key},v.cloneElement((g=e.children)==null?void 0:g.call(e,{...e.slot,option:r[m.index]}),{key:`${c}-${m.key}`,"data-index":m.index,"aria-setsize":r.length,"aria-posinset":m.index+1,style:{position:"absolute",top:0,left:0,transform:`translateY(${m.start}px)`,overflowAnchor:"none"}}))})))}let sYe=v.Fragment;function iYe(e,t){let n=v.useId(),r=S$(),{value:o,defaultValue:s,onChange:i,form:a,name:c,by:u,invalid:d=!1,disabled:f=r||!1,onClose:h,__demoMode:m=!1,multiple:g=!1,immediate:x=!1,virtual:b=null,nullable:y,...w}=e,C=KWe(s),[N=g?[]:void 0,S]=WWe(o,i,C),j=Ece({id:n,virtual:b,__demoMode:m}),I=v.useRef({static:!1,hold:!1}),k=xKe(u),T=$n($=>b?u===null?b.options.indexOf($):b.options.findIndex(X=>k(X,$)):j.state.options.findIndex(X=>k(X.dataRef.current.value,$))),_=v.useCallback($=>hc(M.mode,{[Vi.Multi]:()=>N.some(X=>k(X,$)),[Vi.Single]:()=>k(N,$)}),[N]),E=Uo(j,$=>$.virtual),D=$n(()=>h==null?void 0:h()),M=v.useMemo(()=>({__demoMode:m,immediate:x,optionsPropsRef:I,value:N,defaultValue:C,disabled:f,invalid:d,mode:g?Vi.Multi:Vi.Single,virtual:b?E:null,onChange:S,isSelected:_,calculateIndex:T,compare:k,onClose:D}),[m,x,I,N,C,f,d,g,b,E,S,_,T,k,D]);ko(()=>{var $;b&&j.send({type:_ce.UpdateVirtualConfiguration,options:b.options,disabled:($=b.disabled)!=null?$:null})},[b,b==null?void 0:b.options,b==null?void 0:b.disabled]),ko(()=>{j.state.dataRef.current=M},[M]);let[P,A,L,O]=Uo(j,$=>[$.comboboxState,$.buttonElement,$.inputElement,$.optionsElement]),B=_$.get(null),H=Uo(B,v.useCallback($=>B.selectors.isTop($,n),[B,n]));BKe(H,[A,L,O],()=>j.actions.closeCombobox());let R=Uo(j,j.selectors.activeOptionIndex),V=Uo(j,j.selectors.activeOption),z=ap({open:P===Dn.Open,disabled:f,invalid:d,activeIndex:R,activeOption:V,value:N}),[F,G]=fKe(),q=t===null?{}:{ref:t},Y=v.useCallback(()=>{if(C!==void 0)return S==null?void 0:S(C)},[S,C]),K=wl();return v.createElement(G,{value:F,props:{htmlFor:L==null?void 0:L.id},slot:{open:P===Dn.Open,disabled:f}},v.createElement(AGe,null,v.createElement(lv.Provider,{value:M},v.createElement(Tce.Provider,{value:j},v.createElement(zGe,{value:hc(P,{[Dn.Open]:av.Open,[Dn.Closed]:av.Closed})},c!=null&&v.createElement(JWe,{disabled:f,data:N!=null?{[c]:N}:{},form:a,onReset:Y}),K({ourProps:q,theirProps:w,slot:z,defaultTag:sYe,name:"Combobox"}))))))}let aYe="input";function lYe(e,t){var n,r;let o=Bw("Combobox.Input"),s=Jb("Combobox.Input"),i=v.useId(),a=sce(),{id:c=a||`headlessui-combobox-input-${i}`,onChange:u,displayValue:d,disabled:f=s.disabled||!1,autoFocus:h=!1,type:m="text",...g}=e,x=v.useRef(null),b=Ku(x,t,DGe(),o.actions.setInputElement),[y,w]=Uo(o,z=>[z.comboboxState,z.isTyping]),C=Qb(),N=$n(()=>{o.actions.onChange(null),o.state.optionsElement&&(o.state.optionsElement.scrollTop=0),o.actions.goToOption({focus:$o.Nothing})}),S=v.useMemo(()=>{var z;return typeof d=="function"&&s.value!==void 0?(z=d(s.value))!=null?z:"":typeof s.value=="string"?s.value:""},[s.value,d]);$q(([z,F],[G,q])=>{if(o.state.isTyping)return;let Y=x.current;Y&&((q===Dn.Open&&F===Dn.Closed||z!==G)&&(Y.value=z),requestAnimationFrame(()=>{if(o.state.isTyping||!Y||Qle(Y))return;let{selectionStart:K,selectionEnd:$}=Y;Math.abs(($??0)-(K??0))===0&&K===0&&Y.setSelectionRange(Y.value.length,Y.value.length)}))},[S,y,w]),$q(([z],[F])=>{if(z===Dn.Open&&F===Dn.Closed){if(o.state.isTyping)return;let G=x.current;if(!G)return;let q=G.value,{selectionStart:Y,selectionEnd:K,selectionDirection:$}=G;G.value="",G.value=q,$!==null?G.setSelectionRange(Y,K,$):G.setSelectionRange(Y,K)}},[y]);let j=v.useRef(!1),I=$n(()=>{j.current=!0}),k=$n(()=>{C.nextFrame(()=>{j.current=!1})}),T=$n(z=>{switch(o.actions.setIsTyping(!0),z.key){case Gs.Enter:if(o.state.comboboxState!==Dn.Open||j.current)return;if(z.preventDefault(),z.stopPropagation(),o.selectors.activeOptionIndex(o.state)===null){o.actions.closeCombobox();return}o.actions.selectActiveOption(),s.mode===Vi.Single&&o.actions.closeCombobox();break;case Gs.ArrowDown:return z.preventDefault(),z.stopPropagation(),hc(o.state.comboboxState,{[Dn.Open]:()=>o.actions.goToOption({focus:$o.Next}),[Dn.Closed]:()=>o.actions.openCombobox()});case Gs.ArrowUp:return z.preventDefault(),z.stopPropagation(),hc(o.state.comboboxState,{[Dn.Open]:()=>o.actions.goToOption({focus:$o.Previous}),[Dn.Closed]:()=>{vr.flushSync(()=>o.actions.openCombobox()),s.value||o.actions.goToOption({focus:$o.Last})}});case Gs.Home:if(o.state.comboboxState===Dn.Closed||z.shiftKey)break;return z.preventDefault(),z.stopPropagation(),o.actions.goToOption({focus:$o.First});case Gs.PageUp:return z.preventDefault(),z.stopPropagation(),o.actions.goToOption({focus:$o.First});case Gs.End:if(o.state.comboboxState===Dn.Closed||z.shiftKey)break;return z.preventDefault(),z.stopPropagation(),o.actions.goToOption({focus:$o.Last});case Gs.PageDown:return z.preventDefault(),z.stopPropagation(),o.actions.goToOption({focus:$o.Last});case Gs.Escape:return o.state.comboboxState!==Dn.Open?void 0:(z.preventDefault(),o.state.optionsElement&&!s.optionsPropsRef.current.static&&z.stopPropagation(),s.mode===Vi.Single&&s.value===null&&N(),o.actions.closeCombobox());case Gs.Tab:if(o.actions.setIsTyping(!1),o.state.comboboxState!==Dn.Open)return;s.mode===Vi.Single&&o.state.activationTrigger!==rc.Focus&&o.actions.selectActiveOption(),o.actions.closeCombobox();break}}),_=$n(z=>{u==null||u(z),s.mode===Vi.Single&&z.target.value===""&&N(),o.actions.openCombobox()}),E=$n(z=>{var F,G,q;let Y=(F=z.relatedTarget)!=null?F:lh.find(K=>K!==z.currentTarget);if(!((G=o.state.optionsElement)!=null&&G.contains(Y))&&!((q=o.state.buttonElement)!=null&&q.contains(Y))&&o.state.comboboxState===Dn.Open)return z.preventDefault(),s.mode===Vi.Single&&s.value===null&&N(),o.actions.closeCombobox()}),D=$n(z=>{var F,G,q;let Y=(F=z.relatedTarget)!=null?F:lh.find(K=>K!==z.currentTarget);(G=o.state.buttonElement)!=null&&G.contains(Y)||(q=o.state.optionsElement)!=null&&q.contains(Y)||s.disabled||s.immediate&&o.state.comboboxState!==Dn.Open&&C.microTask(()=>{vr.flushSync(()=>o.actions.openCombobox()),o.actions.setActivationTrigger(rc.Focus)})}),M=H_(),P=lKe(),{isFocused:A,focusProps:L}=Xle({autoFocus:h}),{isHovered:O,hoverProps:B}=Zle({isDisabled:f}),H=Uo(o,z=>z.optionsElement),R=ap({open:y===Dn.Open,disabled:f,invalid:s.invalid,hover:O,focus:A,autofocus:h}),V=N$({ref:b,id:c,role:"combobox",type:m,"aria-controls":H==null?void 0:H.id,"aria-expanded":y===Dn.Open,"aria-activedescendant":Uo(o,o.selectors.activeDescendantId),"aria-labelledby":M,"aria-describedby":P,"aria-autocomplete":"list",defaultValue:(r=(n=e.defaultValue)!=null?n:s.defaultValue!==void 0?d==null?void 0:d(s.defaultValue):null)!=null?r:s.defaultValue,disabled:f||void 0,autoFocus:h,onCompositionStart:I,onCompositionEnd:k,onKeyDown:T,onChange:_,onFocus:D,onBlur:E},L,B);return wl()({ourProps:V,theirProps:g,slot:R,defaultTag:aYe,name:"Combobox.Input"})}let cYe="button";function uYe(e,t){let n=Bw("Combobox.Button"),r=Jb("Combobox.Button"),[o,s]=v.useState(null),i=Ku(t,s,n.actions.setButtonElement),a=v.useId(),{id:c=`headlessui-combobox-button-${a}`,disabled:u=r.disabled||!1,autoFocus:d=!1,...f}=e,[h,m,g]=Uo(n,D=>[D.comboboxState,D.inputElement,D.optionsElement]),x=vce(m),b=h===Dn.Open;qKe(b,{trigger:o,action:v.useCallback(D=>{if(o!=null&&o.contains(D.target)||m!=null&&m.contains(D.target))return Hx.Ignore;let M=D.target.closest('[role="option"]:not([data-disabled])');return Ef(M)?Hx.Select(M):g!=null&&g.contains(D.target)?Hx.Ignore:Hx.Close},[o,m,g]),close:n.actions.closeCombobox,select:n.actions.selectActiveOption});let y=$n(D=>{switch(D.key){case Gs.Space:case Gs.Enter:D.preventDefault(),D.stopPropagation(),n.state.comboboxState===Dn.Closed&&vr.flushSync(()=>n.actions.openCombobox()),x();return;case Gs.ArrowDown:D.preventDefault(),D.stopPropagation(),n.state.comboboxState===Dn.Closed&&(vr.flushSync(()=>n.actions.openCombobox()),n.state.dataRef.current.value||n.actions.goToOption({focus:$o.First})),x();return;case Gs.ArrowUp:D.preventDefault(),D.stopPropagation(),n.state.comboboxState===Dn.Closed&&(vr.flushSync(()=>n.actions.openCombobox()),n.state.dataRef.current.value||n.actions.goToOption({focus:$o.Last})),x();return;case Gs.Escape:if(n.state.comboboxState!==Dn.Open)return;D.preventDefault(),n.state.optionsElement&&!r.optionsPropsRef.current.static&&D.stopPropagation(),vr.flushSync(()=>n.actions.closeCombobox()),x();return;default:return}}),w=yKe(()=>{n.state.comboboxState===Dn.Open?n.actions.closeCombobox():n.actions.openCombobox(),x()}),C=H_([c]),{isFocusVisible:N,focusProps:S}=Xle({autoFocus:d}),{isHovered:j,hoverProps:I}=Zle({isDisabled:u}),{pressed:k,pressProps:T}=LWe({disabled:u}),_=ap({open:h===Dn.Open,active:k||h===Dn.Open,disabled:u,invalid:r.invalid,value:r.value,hover:j,focus:N}),E=N$({ref:i,id:c,type:WKe(e,o),tabIndex:-1,"aria-haspopup":"listbox","aria-controls":g==null?void 0:g.id,"aria-expanded":h===Dn.Open,"aria-labelledby":C,disabled:u||void 0,autoFocus:d,onKeyDown:y},w,S,I,T);return wl()({ourProps:E,theirProps:f,slot:_,defaultTag:cYe,name:"Combobox.Button"})}let dYe="div",fYe=KP.RenderStrategy|KP.Static;function hYe(e,t){var n,r,o;let s=v.useId(),{id:i=`headlessui-combobox-options-${s}`,hold:a=!1,anchor:c,portal:u=!1,modal:d=!0,transition:f=!1,...h}=e,m=Bw("Combobox.Options"),g=Jb("Combobox.Options"),x=EGe(c);x&&(u=!0);let[b,y]=RGe(x),[w,C]=v.useState(null),N=MGe(),S=Ku(t,x?b:null,m.actions.setOptionsElement,C),[j,I,k,T,_]=Uo(m,U=>[U.comboboxState,U.inputElement,U.buttonElement,U.optionsElement,U.activationTrigger]),E=QP(I||k),D=QP(T),M=$Ge(),[P,A]=oGe(f,w,M!==null?(M&av.Open)===av.Open:j===Dn.Open);MKe(P,I,m.actions.closeCombobox);let L=g.__demoMode?!1:d&&j===Dn.Open;JKe(L,D);let O=g.__demoMode?!1:d&&j===Dn.Open;DKe(O,{allowed:v.useCallback(()=>[I,k,T],[I,k,T])});let B=Uo(m,m.selectors.didInputMove)?!1:P;ko(()=>{var U;g.optionsPropsRef.current.static=(U=e.static)!=null?U:!1},[g.optionsPropsRef,e.static]),ko(()=>{g.optionsPropsRef.current.hold=a},[g.optionsPropsRef,a]),cGe(j===Dn.Open,{container:T,accept(U){return U.getAttribute("role")==="option"?NodeFilter.FILTER_REJECT:U.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(U){U.setAttribute("role","none")}});let H=H_([k==null?void 0:k.id]),R=ap({open:j===Dn.Open,option:void 0}),V=$n(()=>{m.actions.setActivationTrigger(rc.Pointer)}),z=$n(U=>{U.preventDefault(),m.actions.setActivationTrigger(rc.Pointer)}),F=N$(x?N():{},{"aria-labelledby":H,role:"listbox","aria-multiselectable":g.mode===Vi.Multi?!0:void 0,id:i,ref:S,style:{...h.style,...y,"--input-width":jq(P,I,!0).width,"--button-width":jq(P,k,!0).width},onWheel:_===rc.Pointer?void 0:V,onMouseDown:z,...rGe(A)}),G=P&&j===Dn.Closed&&!e.static,q=eF(G,(n=g.virtual)==null?void 0:n.options),Y=eF(G,g.value),K=v.useCallback(U=>g.compare(Y,U),[g.compare,Y]),$=v.useMemo(()=>{if(!g.virtual)return g;if(q===void 0)throw new Error("Missing `options` in virtual mode");return q!==g.virtual.options?{...g,virtual:{...g.virtual,options:q}}:g},[g,q,(r=g.virtual)==null?void 0:r.options]);g.virtual&&Object.assign(h,{children:v.createElement(lv.Provider,{value:$},v.createElement(oYe,{slot:R},h.children))});let X=wl(),W=v.useMemo(()=>g.mode===Vi.Multi?g:{...g,isSelected:K},[g,K]);return v.createElement(JGe,{enabled:u?e.static||P:!1,ownerDocument:E},v.createElement(lv.Provider,{value:W},X({ourProps:F,theirProps:{...h,children:v.createElement(LGe,{freeze:G},typeof h.children=="function"?(o=h.children)==null?void 0:o.call(h,R):h.children)},slot:R,defaultTag:dYe,features:fYe,visible:B,name:"Combobox.Options"})))}let mYe="div";function pYe(e,t){var n,r,o;let s=Jb("Combobox.Option"),i=Bw("Combobox.Option"),a=v.useId(),{id:c=`headlessui-combobox-option-${a}`,value:u,disabled:d=(o=(r=(n=s.virtual)==null?void 0:n.disabled)==null?void 0:r.call(n,u))!=null?o:!1,order:f=null,...h}=e,[m]=Uo(i,A=>[A.inputElement]),g=vce(m),x=Uo(i,v.useCallback(A=>i.selectors.isActive(A,u,c),[u,c])),b=s.isSelected(u),y=v.useRef(null),w=ip({disabled:d,value:u,domRef:y,order:f}),C=v.useContext(Dce),N=Ku(t,y,C?C.measureElement:null),S=$n(()=>{i.actions.setIsTyping(!1),i.actions.onChange(u)});ko(()=>i.actions.registerOption(c,w),[w,c]);let j=Uo(i,v.useCallback(A=>i.selectors.shouldScrollIntoView(A,u,c),[u,c]));ko(()=>{if(j)return Oa().requestAnimationFrame(()=>{var A,L;(L=(A=y.current)==null?void 0:A.scrollIntoView)==null||L.call(A,{block:"nearest"})})},[j,y]);let I=$n(A=>{A.preventDefault(),A.button===I$.Left&&(d||(S(),XP()||requestAnimationFrame(()=>g()),s.mode===Vi.Single&&i.actions.closeCombobox()))}),k=$n(()=>{if(d)return i.actions.goToOption({focus:$o.Nothing});let A=s.calculateIndex(u);i.actions.goToOption({focus:$o.Specific,idx:A})}),T=eGe(),_=$n(A=>T.update(A)),E=$n(A=>{if(!T.wasMoved(A)||d||x&&i.state.activationTrigger===rc.Pointer)return;let L=s.calculateIndex(u);i.actions.goToOption({focus:$o.Specific,idx:L},rc.Pointer)}),D=$n(A=>{T.wasMoved(A)&&(d||x&&(s.optionsPropsRef.current.hold||i.state.activationTrigger===rc.Pointer&&i.actions.goToOption({focus:$o.Nothing})))}),M=ap({active:x,focus:x,selected:b,disabled:d}),P={id:c,ref:N,role:"option",tabIndex:d===!0?void 0:-1,"aria-disabled":d===!0?!0:void 0,"aria-selected":b,disabled:void 0,onMouseDown:I,onFocus:k,onPointerEnter:_,onMouseEnter:_,onPointerMove:E,onMouseMove:E,onPointerLeave:D,onMouseLeave:D};return wl()({ourProps:P,theirProps:h,slot:M,defaultTag:mYe,name:"Combobox.Option"})}let gYe=Cl(iYe),Mce=Cl(uYe),Rce=Cl(lYe),bYe=gKe,Ace=Cl(hYe),Pce=Cl(pYe),xYe=Object.assign(gYe,{Input:Rce,Button:Mce,Label:bYe,Options:Ace,Option:Pce});const yYe="var(--semaphor-control-radius, var(--radius, 0.3125rem))",tF="max(calc(var(--semaphor-control-radius, var(--radius, 0.3125rem)) - 2px), 0px)",vYe="var(--semaphor-radius, var(--semaphor-control-radius, var(--radius, 0.3125rem)))",wYe=v.memo(({option:e})=>l.jsxs(Pce,{style:{borderRadius:tF},value:e,className:p.cn("group mx-1 my-1 flex cursor-default select-none items-center gap-3 px-3 py-2.5","text-sm text-foreground transition-colors","data-[selected]:bg-primary/8 data-[focus]:bg-muted/80 data-[selected]:text-foreground"),children:[l.jsx("span",{className:p.cn("flex size-5 shrink-0 items-center justify-center rounded-full border border-border bg-background text-transparent transition-colors","group-data-[selected]:border-primary group-data-[selected]:bg-primary group-data-[selected]:text-primary-foreground","group-data-[focus]:border-muted-foreground/60"),children:l.jsx(p.Check,{className:"size-3.5"})}),l.jsx("span",{className:"min-w-0 flex-1 truncate",children:e.label??e.value})]},e.id),(e,t)=>e.option.id===t.option.id&&e.option.value===t.option.value&&e.option.label===t.option.label),Fce=v.forwardRef(({className:e,style:t,children:n,...r},o)=>{const{scopeProps:s}=oi.useAppearance();return l.jsx("div",{className:p.cn("semaphor-scope",s.className),"data-semaphor-theme":s["data-semaphor-theme"],"data-semaphor-appearance-instance":s["data-semaphor-appearance-instance"],style:s.style,children:l.jsx("div",{ref:o,className:e,style:t,...r,children:n})})});Fce.displayName="ScopedComboboxOptionsPanel";function CYe({options:e,onChange:t,selectedOptions:n,multiple:r=!0,externalFilteredOptions:o,selectAllChecked:s,onSelectAllCheckedChange:i,inputClassName:a,renderFilterModeButton:c,showNegativeIndicator:u,isSearching:d,isLoadingOptions:f=!1,resultSource:h="local",searchError:m,query:g,onQueryChange:x,filterDataType:b,onEnterKey:y,activeFilterValue:w,filterTitle:C,onClear:N,hasActiveFilter:S,placeholder:j,closedDisplayFallback:I,searchPlaceholder:k,selectedCount:T=0}){const[_,E]=v.useState(""),D=v.useRef(null),[M,P]=v.useState(null),A=g!==void 0?g:_,L=x||E,O=o||e;v.useLayoutEffect(()=>{const $=D.current;if(!$)return;const X=()=>{const U=Math.ceil($.getBoundingClientRect().width);P(Z=>Z===U?Z:U)};if(X(),typeof ResizeObserver>"u")return;const W=new ResizeObserver(()=>{X()});return W.observe($),()=>{W.disconnect()}},[]);function B($,X){if(X)return"";const W=[">","<",">=","<=","="];if((b?p.isNumberDataType(b):!1)&&w&&W.includes(w.operation))return`${w.operation}${w.values[0]}`;if(I)return I;const Z=Array.isArray($)?$:$?[$]:[];return Z.length?Z.map(Q=>Q.label??Q.value).join(", "):""}function H($){if($===null){t([]);return}Array.isArray($)||($=[$]),t($)}const R=r?n:n[0]??null;function V(){return d||f||O&&O.length>0?null:l.jsx("div",{className:"relative cursor-default select-none px-4 py-2",children:"No records found."})}function z(){return d&&(O==null?void 0:O.length)>0?l.jsxs("div",{className:"mx-1 mb-2 flex items-center gap-2 rounded-md bg-muted/40 px-3 py-2 text-xs text-muted-foreground",children:[l.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Searching..."]}):m&&A?l.jsx("div",{className:"mx-1 mb-2 rounded-md bg-amber-500/10 px-3 py-2 text-xs text-amber-600 dark:text-amber-400",children:"Search unavailable. Showing available results."}):null}function F(){return f?l.jsxs("div",{className:"px-3 py-3",children:[l.jsxs("div",{className:"mb-3 flex items-center gap-2 px-2 text-xs text-muted-foreground",children:[l.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Loading options..."]}),l.jsx("div",{className:"space-y-1",children:Array.from({length:4}).map(($,X)=>l.jsx("div",{style:{borderRadius:tF},className:"h-11 bg-muted/70","aria-hidden":"true"},X))})]}):!d||(O==null?void 0:O.length)>0?null:l.jsxs("div",{className:"px-3 py-3",children:[l.jsxs("div",{className:"mb-3 flex items-center gap-2 px-2 text-xs text-muted-foreground",children:[l.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Loading options..."]}),l.jsx("div",{className:"space-y-1",children:Array.from({length:4}).map(($,X)=>l.jsx("div",{style:{borderRadius:tF},className:"h-11 bg-muted/70","aria-hidden":"true"},X))})]})}function G(){return null}function q(){return!r||!(O!=null&&O.length)||f?null:l.jsxs("div",{className:"flex items-center justify-between gap-3 border-y border-border/80 px-5 py-3",children:[c==null?void 0:c(),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm text-muted-foreground",children:"All"}),l.jsx(An,{className:"size-5 rounded-control border-input text-primary data-[state=checked]:bg-primary",checked:s,onCheckedChange:i})]})]})}function Y(){return C?l.jsxs("div",{className:"flex items-center justify-between px-5 pb-3 pt-4",children:[l.jsx("span",{className:"text-[15px] font-semibold text-foreground",children:C}),S&&N&&l.jsx("button",{onClick:$=>{$.stopPropagation(),N()},className:"text-sm font-medium text-muted-foreground transition-colors hover:text-foreground","aria-label":"Clear filter",children:"Clear all"})]}):null}function K(){if(!r||f)return null;const $=Math.max(T,n.length);return l.jsx("div",{className:"border-t border-border/80 bg-muted/35 px-5 py-3 text-sm text-muted-foreground",children:`${$} selected`})}return l.jsx(xYe,{immediate:!0,multiple:r,value:R,onChange:H,onClose:()=>{L("")},by:($,X)=>Array.isArray($)||Array.isArray(X)?!1:!$||!X?$===X:$.id===X.id,children:({open:$})=>l.jsxs("div",{children:[l.jsxs("div",{ref:D,className:"relative flex items-center gap-0.5",children:[l.jsx(Mt.Search,{className:"pointer-events-none absolute left-3 size-4 text-muted-foreground"}),l.jsx(Rce,{className:p.cn("h-10 w-full cursor-default border border-input bg-background py-2 pl-10 pr-10 text-sm text-foreground shadow-sm transition-colors","hover:border-input/80 focus:border-ring",u&&"border-destructive/35 bg-destructive/[0.03] hover:border-destructive/45 focus:border-destructive/45","data-[focus]:outline-border-none focus:outline-none data-[focus]:outline-none data-[focus]:-outline-offset-2",a),style:{borderRadius:yYe},placeholder:$?k||"Search options...":j,displayValue:X=>B(X,$),onChange:X=>L(X.target.value),onKeyDown:X=>{if(X.key==="Enter"&&y){const W=/^(>=|<=|>|<|=)/.test(A.trim()),U=b?p.isNumberDataType(b):!1;W&&U&&(X.preventDefault(),y()&&X.target.blur())}}}),l.jsx(Mce,{className:"group absolute inset-y-0 right-0 px-2.5",children:l.jsx(Ie.ChevronDown,{className:"size-4 text-muted-foreground transition-colors group-hover:text-foreground"})})]}),l.jsxs(Ace,{as:Fce,anchor:"bottom",transition:!0,style:{borderRadius:vYe,width:M?`${M}px`:"16rem"},className:p.clsx$1("mt-2 overflow-hidden border border-border/80 bg-popover text-sm text-popover-foreground shadow-[0_20px_50px_-24px_rgba(15,23,42,0.35)] [--anchor-gap:var(--spacing-2)] empty:invisible dark:shadow-[0_20px_50px_-24px_rgba(0,0,0,0.6)]","transition duration-100 ease-in data-[leave]:data-[closed]:opacity-0"),children:[Y(),q(),l.jsxs("div",{className:"max-h-72 overflow-y-auto px-2 py-2",children:[z(),F(),G(),V(),!f&&(O==null?void 0:O.map(X=>l.jsx(wYe,{option:X},X.id)))]}),K()]})]})})}const Yq=[{value:"=",label:"Equal to",symbol:"="},{value:">",label:"Greater than",symbol:">"},{value:">=",label:"Greater than or equal",symbol:"≥"},{value:"<",label:"Less than",symbol:"<"},{value:"<=",label:"Less than or equal",symbol:"≤"},{value:"between",label:"Between",symbol:"⟷"},{value:"not between",label:"Not Between",symbol:"⇎"}],SYe=new Set(["=",">","<",">=","<=","between","not between"]);function NYe(e){return SYe.has(e)?e:">="}function jYe({filter:e,storageOptions:t}){var G;const{cardId:n,dashboardInput:r,inlineFilterValues:o,removeInlineFilterValue:s,sheetId:i,setInlineFilterValue:a,storageTarget:c}=t??{},u=c==="card",d=c==="dashboardInput",[f,h]=v.useState(">="),[m,g]=v.useState(""),[x,b]=v.useState(""),[y,w]=v.useState(""),[C,N]=v.useState(!0),S=v.useRef(null),j=v.useRef(!1),[,I]=v.useTransition(),k=l0(m,300),T=l0(x,300),_=l0(y,300),E=p.useDashboardStore(q=>q.filterValues),D=p.useDashboardStore(q=>q.dashboard),M=p.useDashboardStore(q=>q.dashboardInputValues);p.useDashboardStore(q=>q.themeStyle);const P=p.useDashboardStore(q=>q.actions.setDashboardInputSlot),A=p.useDashboardStore(q=>q.actions.clearDashboardInputSlot),L=p.useDashboardStore(q=>q.actions.setCardInlineFilterValue),O=p.useDashboardStore(q=>q.actions.removeCardInlineFilterValue),{addOrUpdateFilterValue:B,removeFilterValues:H}=p.useDashboardActions(),R=v.useMemo(()=>{if(!d||!r)return;const q=p.hydrateAuthoredDashboardInputSlot({dashboard:D,input:r,runtimeValues:M,target:{sheetId:i}});return(q==null?void 0:q.status)==="set"&&q.value.kind==="filter"?q.value.filterValue:void 0},[D,M,d,r,i]),V=v.useMemo(()=>d?R?[R]:[]:u?o:E,[E,R,o,u,d]),z=v.useCallback(q=>{if(d){if(!r)return;const Y=p.createFilterDashboardInputSlot(q);if(!Y)return;P(r,{sheetId:i},Y);return}if(u){if(a){a(q);return}L(n??"",q)}else B(q)},[d,r,i,P,u,a,L,n,B]),F=v.useCallback(()=>{if(d){if(!r)return;A(r,{sheetId:i});return}if(u){if(s){s(e.id);return}O(n??"",e.id)}else H(e.id)},[d,r,i,A,u,e.id,s,O,n,H]);return v.useEffect(()=>()=>{S.current=null,j.current=!1},[]),v.useEffect(()=>{const q=V==null?void 0:V.find(Y=>Y.filterId===e.id);if(q&&q.operation!=="in"){const Y=NYe(q.operation);if(S.current!==Y&&(h(Y),S.current=Y,j.current=!1),Y==="between"||Y==="not between"){const $=q.values[0],X=q.values[1];b($!=null?String($):""),w(X!=null?String(X):""),g("")}else{const $=q.values[0];g($!=null?String($):""),b(""),w("")}}else S.current!==null&&(g(""),b(""),w(""),!j.current&&S.current!==f&&(h(">="),j.current=!1),S.current=null),N(!1)},[V,e.id,f]),v.useEffect(()=>{C&&(f==="between"||f==="not between"?T===x&&_===y&&N(!1):k===m&&N(!1))},[C,f,m,k,x,y,T,_]),v.useEffect(()=>{if(!C)if(f==="between"||f==="not between"){const q=T&&T.trim()!=="",Y=_&&_.trim()!=="";if(!q||!Y){!q&&!Y&&(I(()=>{F()}),S.current=f);return}const K=Number(T),$=Number(_);if(isNaN(K)||isNaN($))return;const X={filterId:e.id,name:e.column,valueType:p.getFilterValueType(e),operation:f,values:[K,$],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};I(()=>{z(X)}),S.current=f}else{if(!k||k.trim()===""){I(()=>{F()}),S.current=null;return}const q=Number(k);if(isNaN(q))return;const Y={filterId:e.id,name:e.column,valueType:p.getFilterValueType(e),operation:f,values:[q],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};I(()=>{z(Y)}),S.current=f}},[f,k,T,_,e.id,e.column,e.database,C,z,F,e]),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsxs(p.Select,{value:f,onValueChange:q=>{j.current=!0,h(q)},children:[l.jsx(p.SelectTrigger,{className:"h-7 w-14 shrink-0 border-input bg-background text-[12px]",children:l.jsx("span",{className:"font-mono text-[13px]",children:(G=Yq.find(q=>q.value===f))==null?void 0:G.symbol})}),l.jsx(p.SelectContent,{children:Yq.map(q=>l.jsx(p.SelectItem,{value:q.value,children:l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"font-mono text-[12px]",children:q.symbol}),l.jsx("span",{className:"text-[12px]",children:q.label})]})},q.value))})]}),f==="between"||f==="not between"?l.jsxs(l.Fragment,{children:[l.jsx(p.Input,{type:"number",placeholder:"Min",value:x,onChange:q=>b(q.target.value),className:"h-7 flex-1 border-input bg-background text-[12px] tabular-nums"}),l.jsx("span",{className:"text-[11px] text-muted-foreground",children:"–"}),l.jsx(p.Input,{type:"number",placeholder:"Max",value:y,onChange:q=>w(q.target.value),className:"h-7 flex-1 border-input bg-background text-[12px] tabular-nums"})]}):l.jsx(p.Input,{type:"number",placeholder:"Value",value:m,onChange:q=>g(q.target.value),className:"h-7 flex-1 border-input bg-background text-[12px] tabular-nums"})]})}function M$({isCardStorage:e=!1,message:t="Error",className:n}){return l.jsx("div",{className:p.cn("flex w-full items-center bg-muted px-2 text-sm",e?"h-8":"h-9",n),children:t})}function Oce({filter:e,storageOptions:t}){var B,H;const n=e.searchMode==="numeric",r=(t==null?void 0:t.storageTarget)==="card",o=r?"h-8":"h-9",s=r?"h-[31px]":"h-[35px]",{removeFilterValues:i}=p.useDashboardActions(),a=p.useDashboardStore(R=>R.actions.removeCardInlineFilterValue),{filteredRecords:c,isSingleSelect:u,allSelected:d,handleChange:f,handleSelectAll:h,handleApplyOperatorExpression:m,query:g,setQuery:x,isLoading:b,isFetching:y,isPlaceholderData:w,isError:C,selectedRecords:N,isSearching:S,searchError:j,resultSource:I,activeFilterValue:k}=Xb(e,{enableServerSearch:!0,searchDebounceMs:300,minSearchLength:2,searchThreshold:5,...t}),_=b||y&&w,E=k&&(k.operation==="in"||k.operation==="not in")&&((B=k.values)!=null&&B.length)?k.values.map(R=>String(R)).join(", "):void 0,D=(k==null?void 0:k.operation)==="not in"||e.operation==="not in",P=`Search ${(e.title||e.column||"options").toLowerCase()}`,{clearDashboardInputSlot:A}=p.useDashboardActions(),L=v.useCallback(()=>{if((t==null?void 0:t.storageTarget)==="dashboardInput"&&t.dashboardInput){A(t.dashboardInput,{sheetId:t.sheetId});return}if((t==null?void 0:t.storageTarget)==="card"&&(t!=null&&t.cardId)){if(t.removeInlineFilterValue){t.removeInlineFilterValue(e.id);return}a(t.cardId,e.id)}else i(e.id)},[t,e.id,A,i,a]);return b&&!E?l.jsx(ei,{className:p.cn(s,"w-full rounded-control bg-foreground/10")}):C?l.jsx(M$,{isCardStorage:r}):n?l.jsx(jYe,{filter:e,storageOptions:t}):l.jsx(CYe,{showNegativeIndicator:D,renderFilterModeButton:()=>l.jsx(Lce,{filter:e,storageOptions:t}),inputClassName:o,options:c,selectedOptions:N,onChange:f,multiple:!u,selectAllChecked:d,onSelectAllCheckedChange:h,isSearching:S,isLoadingOptions:_,resultSource:I,searchError:j,query:g,onQueryChange:x,filterDataType:e.dataType,activeFilterValue:k,onEnterKey:m,filterTitle:e.title||e.column,onClear:L,hasActiveFilter:!!k,placeholder:e.showLabel===!1?e.title||e.column:void 0,closedDisplayFallback:N.length===0?E:void 0,searchPlaceholder:P,selectedCount:((H=k==null?void 0:k.values)==null?void 0:H.length)??N.length})}function Lce({filter:e,storageOptions:t,compact:n=!1}){const r={borderRadius:"max(calc(var(--semaphor-control-radius, var(--radius, 0.3125rem)) - 2px), 0px)"},o=(t==null?void 0:t.storageTarget)==="card",s=(t==null?void 0:t.storageTarget)==="dashboardInput",{setFilterMode:i}=p.useDashboardActions(),a=p.useDashboardStore(j=>j.dashboard),c=p.useDashboardStore(j=>j.dashboardInputValues),u=p.useDashboardStore(j=>j.isVisualEditing),d=p.useDashboardStore(j=>j.actions.setDashboardInputSlot),f=p.useDashboardStore(j=>j.actions.updateFilterDashboardInputDefinition),h=p.useDashboardStore(j=>j.actions.setCardInlineFilterMode),m=p.useDashboardStore(j=>j.actions.setCardInlineFilterValue),g=p.useEditorStore(j=>j.card),{setCard:x}=p.useEditorActions(),b=v.useMemo(()=>{if(!s||!(t!=null&&t.dashboardInput))return;const j=p.hydrateAuthoredDashboardInputSlot({dashboard:a,input:t.dashboardInput,runtimeValues:c,target:{sheetId:t.sheetId}});return(j==null?void 0:j.status)==="set"&&j.value.kind==="filter"?j.value.filterValue:void 0},[a,c,s,t==null?void 0:t.dashboardInput,t==null?void 0:t.sheetId]),w=(b&&(b.operation==="in"||b.operation==="not in")?b.operation:e.operation)==="not in"?"exclude":"include";function C(j){var k;if(j===w)return;const I=j==="exclude"?"not in":"in";if(s){if(!(t!=null&&t.dashboardInput)||t.dashboardInput.kind!=="filter"||!t.dashboardInput.filter)return;const T=t.dashboardInput;if(f(T.id,{...T.filter,operation:I}),(k=b==null?void 0:b.values)!=null&&k.length){const _={...b,operation:I},E=p.createFilterDashboardInputSlot(_);E&&d(T,{sheetId:t.sheetId},E)}return}if(o){if(t!=null&&t.setInlineFilterMode){t.setInlineFilterMode(e.id,j);return}if(u){const T=(g.inlineFilters||[]).map(E=>E.id===e.id?{...E,operation:I}:E);x({...g,inlineFilters:T});const _=N==null?void 0:N.find(E=>E.filterId===e.id);if(_&&(_.operation==="in"||_.operation==="not in")){const E={..._,operation:I};t!=null&&t.setInlineFilterValue?t.setInlineFilterValue(E):m((t==null?void 0:t.cardId)??"",E)}}else h((t==null?void 0:t.sheetId)??"",(t==null?void 0:t.cardId)??"",e.id,j)}else i(e.id,j)}const N=t==null?void 0:t.inlineFilterValues,S=n?"h-5 px-2 text-[11px]":"h-6 px-3 text-[12px]";return l.jsxs("div",{className:"inline-flex items-center gap-0.5 rounded-control bg-muted/80 p-0.5",children:[l.jsx(p.Button,{onClick:()=>C("include"),variant:"ghost",size:"sm",style:r,className:p.cn(S,"font-medium leading-none text-muted-foreground",w==="include"&&"bg-primary text-primary-foreground shadow-sm hover:bg-primary/90 hover:text-primary-foreground",w!=="include"&&"hover:bg-background/80 hover:text-foreground"),children:"Include"}),l.jsx(p.Button,{onClick:()=>C("exclude"),variant:"ghost",size:"sm",style:r,className:p.cn(S,"font-medium leading-none text-muted-foreground",w==="exclude"&&"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90 hover:text-destructive-foreground",w!=="exclude"&&"hover:bg-background/80 hover:text-foreground"),children:"Exclude"})]})}function $ce({filter:e,storageOptions:t}){var a;const{filteredRecords:n,handleChange:r,selectedRecords:o}=Xb(e,t),s=((a=o==null?void 0:o[0])==null?void 0:a.value)||"";function i(c){r([{value:c,id:c}])}return l.jsx(wu,{onValueChange:i,value:s,className:"flex flex-col gap-0.5",children:n==null?void 0:n.map(c=>{const u=`radio-${e.id}-${c.value}`,d=s===c.value;return l.jsxs(p.Label,{htmlFor:u,className:p.cn("flex w-full cursor-pointer items-center gap-2 rounded-control px-2 py-1.5 text-[13px] transition-colors",d?"bg-muted text-foreground hover:bg-foreground/[0.08]":"text-foreground hover:bg-muted"),children:[l.jsx(Qs,{value:c.value,id:u,className:"h-3.5 w-3.5"}),l.jsx("span",{className:"truncate",children:c.label??c.value})]},c.value)})})}function zce({filter:e,storageOptions:t}){var h;const n=(t==null?void 0:t.storageTarget)==="card",{filteredRecords:r,handleChange:o,selectedRecords:s,isLoading:i,isFetching:a,isError:c}=Xb(e,t),u=((h=s==null?void 0:s[0])==null?void 0:h.value)||"",d=r&&r.length>10;function f(m){o([{value:m,id:m}])}return i||a?l.jsx("div",{className:"space-y-1",children:Array.from({length:4}).map((m,g)=>l.jsx(ei,{className:"h-7 w-full rounded-control bg-foreground/[0.06]"},g))}):c?l.jsx(M$,{isCardStorage:n,message:"Error loading filter options"}):l.jsxs("div",{className:"flex flex-col gap-0.5",children:[d&&l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsxs("div",{className:"mb-1 inline-flex items-center gap-1 rounded-[4px] bg-amber-500/10 px-1.5 py-0.5 text-[11px] text-amber-700 dark:text-amber-300",children:[l.jsx(p.Info,{className:"h-3 w-3"}),l.jsxs("span",{children:["Many options (",r.length,")"]})]})}),l.jsx(p.TooltipContent,{side:"bottom",className:"max-w-xs",children:l.jsxs("p",{className:"text-xs",children:["This filter has ",r.length," options. Consider switching to a dropdown for better usability with many options."]})})]})}),l.jsx("div",{role:"radiogroup",className:"flex flex-col gap-0.5",children:r==null?void 0:r.map(m=>{const g=u===m.value;return l.jsx("button",{type:"button",role:"radio","aria-checked":g,onClick:()=>f(m.value),className:p.cn("flex w-full items-center rounded-control px-2 py-1.5 text-left text-[13px] transition-colors",g?"bg-muted text-foreground hover:bg-foreground/[0.08]":"text-foreground hover:bg-muted"),children:l.jsx("span",{className:"truncate",children:m.label??m.value})},m.value)})})]})}const kYe=v.createContext(null),yM={didCatch:!1,error:null};class _i extends v.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=yM}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var n,r,o=arguments.length,s=new Array(o),i=0;i<o;i++)s[i]=arguments[i];(n=(r=this.props).onReset)===null||n===void 0||n.call(r,{args:s,reason:"imperative-api"}),this.setState(yM)}}componentDidCatch(t,n){var r,o;(r=(o=this.props).onError)===null||r===void 0||r.call(o,t,n)}componentDidUpdate(t,n){const{didCatch:r}=this.state,{resetKeys:o}=this.props;if(r&&n.error!==null&&IYe(t.resetKeys,o)){var s,i;(s=(i=this.props).onReset)===null||s===void 0||s.call(i,{next:o,prev:t.resetKeys,reason:"keys"}),this.setState(yM)}}render(){const{children:t,fallbackRender:n,FallbackComponent:r,fallback:o}=this.props,{didCatch:s,error:i}=this.state;let a=t;if(s){const c={error:i,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")a=n(c);else if(r)a=v.createElement(r,c);else if(o!==void 0)a=o;else throw i}return v.createElement(kYe.Provider,{value:{didCatch:s,error:i,resetErrorBoundary:this.resetErrorBoundary}},a)}}function IYe(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((n,r)=>!Object.is(n,t[r]))}function _Ye(e,t){const[n,r]=v.useState(t),[o,s]=v.useState(),i=v.useMemo(()=>t,[t]);return v.useEffect(()=>{if(e&&(e==null?void 0:e.length)>0){const a=e[0];if(!a.min||!a.max)return;const c={from:new Date(a.min),to:new Date(a.max)};s(c),i||r(c)}},[e,i]),v.useEffect(()=>{i&&r(i)},[i]),{dateRange:n,setDateRange:r,initialDateRange:o,setInitialDateRange:s}}function TYe(e){const t=p.useDashboardStore(o=>{var s,i;return(i=(s=o.dashboard)==null?void 0:s.filters)==null?void 0:i.find(a=>a.id===e)}),{setDateRange:n,...r}=R$(t||{});return r}function R$(e,t){const{cardId:n,dashboardInput:r,filterQueryContext:o,inlineFilterValues:s,removeInlineFilterValue:i,setInlineFilterValue:a,sheetId:c,storageTarget:u}=t??{},d=u==="card",f=u==="dashboardInput",h=p.useDashboardStore($=>{var X;return((X=$.reportContext)==null?void 0:X.calendar)??null}),m=h==null?void 0:h.tz,g=p.useDashboardStore($=>$.filterValues),x=p.useDashboardStore($=>$.dashboard),b=p.useDashboardStore($=>$.dashboardInputValues),y=v.useMemo(()=>{if(!f||!r)return;const $={sheetId:c};return p.hydrateAuthoredDashboardInputSlot({dashboard:x,input:r,runtimeValues:b,target:$,timezone:m})},[x,b,f,r,c,m]),w=v.useMemo(()=>{if(!(!f||!r))return Ti({dashboard:x,sheetId:c,sheetKind:"dashboard",runtimeValues:{dashboardInputValues:b},timezone:m}).activeFilters},[x,b,f,r,c,m]),C=p.useDashboardStore($=>$.actions.addOrUpdateFilterValue),N=p.useDashboardStore($=>$.actions.setDashboardInputSlot),S=p.useDashboardStore($=>$.actions.clearDashboardInputSlot),j=p.useDashboardStore($=>$.actions.setCardInlineFilterValue),I=p.useDashboardStore($=>$.actions.removeCardInlineFilterValue),{removeFilterValues:k}=p.useDashboardActions(),T=(y==null?void 0:y.status)==="set"&&y.value.kind==="filter"?y.value.filterValue:void 0,_=v.useMemo(()=>f?T?[T]:[]:d?s:g,[T,g,s,d,f]),E=_==null?void 0:_.find($=>$.filterId===e.id),D=v.useMemo(()=>f?{...o,activeFilterValues:w}:o,[w,o,f]),{data:M,isLoading:P,isFetching:A,isError:L}=x$(e,{additionalFilterValues:d?s:void 0,filterQueryContext:D}),O=v.useCallback($=>{if(f){if(!r)return;const X=p.createFilterDashboardInputSlot($);if(!X)return;N(r,{sheetId:c},X);return}if(d){if(a){a($);return}if(!n)return;j(n,$)}else C($)},[f,r,c,N,d,a,j,n,C]),B=v.useCallback(()=>{if(f){if(!r)return;S(r,{sheetId:c});return}if(d){if(i){i(e.id);return}if(!n)return;I(n,e.id)}else k(e.id)},[f,r,c,S,d,e.id,i,I,n,k]),H=v.useMemo(()=>{const $=W=>{if(!W)return;const U=W instanceof Date?W:new Date(W);return isNaN(U.getTime())?void 0:U};if(!E||!Array.isArray(E.values))return;const X=E.operation;if((X==="between"||X==="not between")&&E.values.length===2){const[W,U]=E.values,Z=$(W),Q=$(U);return!Z&&!Q?void 0:{from:Z,to:Q}}if(["=","!=",">",">=","<","<="].includes(X)&&E.values.length===1){const[W]=E.values,U=$(W);return U?{from:U,to:U}:void 0}},[E]),{dateRange:R,setDateRange:V,initialDateRange:z}=_Ye((M==null?void 0:M.records)??[],H);function F(){B(),V(void 0)}function G(){V(z)}function q($,X="between",W={}){if(!$)return;if(X==="is null"||X==="is not null"){V(void 0),O({filterId:e.id,valueType:p.getFilterValueType(e),name:e.column,operation:X,values:[],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext});return}if(X==="between"||X==="not between"){const Z=p.normalizeDateFilterRange($,{temporalPrecision:W.temporalPrecision});V({from:Z.from,to:Z.to}),O({filterId:e.id,valueType:p.getFilterValueType(e),name:e.column,operation:X,values:Z.values,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext,...W.temporalPrecision?{temporalPrecision:W.temporalPrecision}:{}});return}const U=$.from||$.to;U&&(V({from:U,to:U}),O({filterId:e.id,valueType:p.getFilterValueType(e),name:e.column,operation:X,values:[U],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext,...W.temporalPrecision?{temporalPrecision:W.temporalPrecision}:{}}))}function Y($){V(void 0),O({filterId:e.id,valueType:p.getFilterValueType(e),name:e.column,operation:$,values:[],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext})}function K($,X,W={}){if(!$)return;const U=W.temporalPrecision??p.getTemporalPrecisionForRelativeMeta(X),Z=p.normalizeDateFilterRange($,{temporalPrecision:U});V({from:Z.from,to:Z.to});const Q={filterId:e.id,valueType:p.getFilterValueType(e),name:e.column,operation:"between",values:Z.values,relativeMeta:X,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext,...U?{temporalPrecision:U}:{}};O(Q)}return{records:M==null?void 0:M.records,isLoading:P,isFetching:A,isError:L,initialDateRange:z,dateRange:R,setDateRange:V,activeFilterValue:E,handleClear:F,handleChange:q,handleNullOperation:Y,handleRelativeChange:K,handleReset:G}}function Vw(e){var n;const t=e.scheme.tokens;return{colors:[...e.chartPalette],mode:e.mode,appearance:{version:Am.APPEARANCE_SPEC_VERSION,mode:e.mode,colors:Ys(e.colorValues),typography:Ys(t==null?void 0:t.typography),radius:Ys(t==null?void 0:t.radius),spacing:Ys(t==null?void 0:t.spacing),shadow:Ys(t==null?void 0:t.shadow),density:(n=t==null?void 0:t.typography)==null?void 0:n.density,chartPalette:[...e.chartPalette],table:Ys(e.table)}}}function EYe(e,t,n="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:e,timeZoneName:n}).format(t).split(/\s/g).slice(2).join(" ")}const vM={},Iy={};function Ch(e,t){try{const r=(vM[e]||(vM[e]=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).format))(t).split("GMT")[1];return r in Iy?Iy[r]:Zq(r,r.split(":"))}catch{if(e in Iy)return Iy[e];const n=e==null?void 0:e.match(DYe);return n?Zq(e,n.slice(1)):NaN}}const DYe=/([+-]\d\d):?(\d\d)?/;function Zq(e,t){const n=+(t[0]||0),r=+(t[1]||0),o=+(t[2]||0)/60;return Iy[e]=n*60+r>0?n*60+r+o:n*60-r-o}class Gl extends Date{constructor(...t){super(),t.length>1&&typeof t[t.length-1]=="string"&&(this.timeZone=t.pop()),this.internal=new Date,isNaN(Ch(this.timeZone,this))?this.setTime(NaN):t.length?typeof t[0]=="number"&&(t.length===1||t.length===2&&typeof t[1]!="number")?this.setTime(t[0]):typeof t[0]=="string"?this.setTime(+new Date(t[0])):t[0]instanceof Date?this.setTime(+t[0]):(this.setTime(+new Date(...t)),Bce(this),nF(this)):this.setTime(Date.now())}static tz(t,...n){return n.length?new Gl(...n,t):new Gl(Date.now(),t)}withTimeZone(t){return new Gl(+this,t)}getTimezoneOffset(){const t=-Ch(this.timeZone,this);return t>0?Math.floor(t):Math.ceil(t)}setTime(t){return Date.prototype.setTime.apply(this,arguments),nF(this),+this}[Symbol.for("constructDateFrom")](t){return new Gl(+new Date(t),this.timeZone)}}const Xq=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!Xq.test(e))return;const t=e.replace(Xq,"$1UTC");Gl.prototype[t]&&(e.startsWith("get")?Gl.prototype[e]=function(){return this.internal[t]()}:(Gl.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),MYe(this),+this},Gl.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),nF(this),+this}))});function nF(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-Ch(e.timeZone,e)*60))}function MYe(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),Bce(e)}function Bce(e){const t=Ch(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),r=new Date(+e);r.setUTCHours(r.getUTCHours()-1);const o=-new Date(+e).getTimezoneOffset(),s=-new Date(+r).getTimezoneOffset(),i=o-s,a=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();i&&a&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+i);const c=o-n;c&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+c);const u=new Date(+e);u.setUTCSeconds(0);const d=o>0?u.getSeconds():(u.getSeconds()-60)%60,f=Math.round(-(Ch(e.timeZone,e)*60))%60;(f||d)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+f),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+f+d));const h=Ch(e.timeZone,e),m=h>0?Math.floor(h):Math.ceil(h),x=-new Date(+e).getTimezoneOffset()-m,b=m!==n,y=x-c;if(b&&y){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+y);const w=Ch(e.timeZone,e),C=w>0?Math.floor(w):Math.ceil(w),N=m-C;N&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+N),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+N))}}class ru extends Gl{static tz(t,...n){return n.length?new ru(...n,t):new ru(Date.now(),t)}toISOString(){const[t,n,r]=this.tzComponents(),o=`${t}${n}:${r}`;return this.internal.toISOString().slice(0,-1)+o}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[t,n,r,o]=this.internal.toUTCString().split(" ");return`${t==null?void 0:t.slice(0,-1)} ${r} ${n} ${o}`}toTimeString(){const t=this.internal.toUTCString().split(" ")[4],[n,r,o]=this.tzComponents();return`${t} GMT${n}${r}${o} (${EYe(this.timeZone,this)})`}toLocaleString(t,n){return Date.prototype.toLocaleString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}toLocaleDateString(t,n){return Date.prototype.toLocaleDateString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}toLocaleTimeString(t,n){return Date.prototype.toLocaleTimeString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}tzComponents(){const t=this.getTimezoneOffset(),n=t>0?"-":"+",r=String(Math.floor(Math.abs(t)/60)).padStart(2,"0"),o=String(Math.abs(t)%60).padStart(2,"0");return[n,r,o]}withTimeZone(t){return new ru(+this,t)}[Symbol.for("constructDateFrom")](t){return new ru(+new Date(t),this.timeZone)}}const Vce=6048e5,RYe=864e5,Qq=Symbol.for("constructDateFrom");function Io(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&Qq in e?e[Qq](t):e instanceof Date?new e.constructor(t):new Date(t)}function gr(e,t){return Io(t||e,e)}function Hce(e,t,n){const r=gr(e,n==null?void 0:n.in);return isNaN(t)?Io(e,NaN):(t&&r.setDate(r.getDate()+t),r)}function qce(e,t,n){const r=gr(e,n==null?void 0:n.in);if(isNaN(t))return Io(e,NaN);if(!t)return r;const o=r.getDate(),s=Io(e,r.getTime());s.setMonth(r.getMonth()+t+1,0);const i=s.getDate();return o>=i?s:(r.setFullYear(s.getFullYear(),s.getMonth(),o),r)}let AYe={};function Hw(){return AYe}function cb(e,t){var a,c,u,d;const n=Hw(),r=(t==null?void 0:t.weekStartsOn)??((c=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:c.weekStartsOn)??n.weekStartsOn??((d=(u=n.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??0,o=gr(e,t==null?void 0:t.in),s=o.getDay(),i=(s<r?7:0)+s-r;return o.setDate(o.getDate()-i),o.setHours(0,0,0,0),o}function cv(e,t){return cb(e,{...t,weekStartsOn:1})}function Uce(e,t){const n=gr(e,t==null?void 0:t.in),r=n.getFullYear(),o=Io(n,0);o.setFullYear(r+1,0,4),o.setHours(0,0,0,0);const s=cv(o),i=Io(n,0);i.setFullYear(r,0,4),i.setHours(0,0,0,0);const a=cv(i);return n.getTime()>=s.getTime()?r+1:n.getTime()>=a.getTime()?r:r-1}function Jq(e){const t=gr(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function ex(e,...t){const n=Io.bind(null,t.find(r=>typeof r=="object"));return t.map(n)}function uv(e,t){const n=gr(e,t==null?void 0:t.in);return n.setHours(0,0,0,0),n}function Wce(e,t,n){const[r,o]=ex(n==null?void 0:n.in,e,t),s=uv(r),i=uv(o),a=+s-Jq(s),c=+i-Jq(i);return Math.round((a-c)/RYe)}function PYe(e,t){const n=Uce(e,t),r=Io(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),cv(r)}function FYe(e,t,n){return Hce(e,t*7,n)}function OYe(e,t,n){return qce(e,t*12,n)}function LYe(e,t){let n,r=t==null?void 0:t.in;return e.forEach(o=>{!r&&typeof o=="object"&&(r=Io.bind(null,o));const s=gr(o,r);(!n||n<s||isNaN(+s))&&(n=s)}),Io(r,n||NaN)}function $Ye(e,t){let n,r=t==null?void 0:t.in;return e.forEach(o=>{!r&&typeof o=="object"&&(r=Io.bind(null,o));const s=gr(o,r);(!n||n>s||isNaN(+s))&&(n=s)}),Io(r,n||NaN)}function zYe(e,t,n){const[r,o]=ex(n==null?void 0:n.in,e,t);return+uv(r)==+uv(o)}function Kce(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function BYe(e){return!(!Kce(e)&&typeof e!="number"||isNaN(+gr(e)))}function VYe(e,t,n){const[r,o]=ex(n==null?void 0:n.in,e,t),s=r.getFullYear()-o.getFullYear(),i=r.getMonth()-o.getMonth();return s*12+i}function HYe(e,t){const n=gr(e,t==null?void 0:t.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function Gce(e,t){const[n,r]=ex(e,t.start,t.end);return{start:n,end:r}}function qYe(e,t){const{start:n,end:r}=Gce(t==null?void 0:t.in,e);let o=+n>+r;const s=o?+n:+r,i=o?r:n;i.setHours(0,0,0,0),i.setDate(1);let a=1;const c=[];for(;+i<=s;)c.push(Io(n,i)),i.setMonth(i.getMonth()+a);return o?c.reverse():c}function UYe(e,t){const n=gr(e,t==null?void 0:t.in);return n.setDate(1),n.setHours(0,0,0,0),n}function WYe(e,t){const n=gr(e,t==null?void 0:t.in),r=n.getFullYear();return n.setFullYear(r+1,0,0),n.setHours(23,59,59,999),n}function Yce(e,t){const n=gr(e,t==null?void 0:t.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function KYe(e,t){const{start:n,end:r}=Gce(t==null?void 0:t.in,e);let o=+n>+r;const s=o?+n:+r,i=o?r:n;i.setHours(0,0,0,0),i.setMonth(0,1);let a=1;const c=[];for(;+i<=s;)c.push(Io(n,i)),i.setFullYear(i.getFullYear()+a);return o?c.reverse():c}function Zce(e,t){var a,c,u,d;const n=Hw(),r=(t==null?void 0:t.weekStartsOn)??((c=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:c.weekStartsOn)??n.weekStartsOn??((d=(u=n.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??0,o=gr(e,t==null?void 0:t.in),s=o.getDay(),i=(s<r?-7:0)+6-(s-r);return o.setDate(o.getDate()+i),o.setHours(23,59,59,999),o}function GYe(e,t){return Zce(e,{...t,weekStartsOn:1})}const YYe={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},ZYe=(e,t,n)=>{let r;const o=YYe[e];return typeof o=="string"?r=o:t===1?r=o.one:r=o.other.replace("{{count}}",t.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function wM(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const XYe={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},QYe={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},JYe={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},eZe={date:wM({formats:XYe,defaultWidth:"full"}),time:wM({formats:QYe,defaultWidth:"full"}),dateTime:wM({formats:JYe,defaultWidth:"full"})},tZe={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},nZe=(e,t,n,r)=>tZe[e];function qx(e){return(t,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let o;if(r==="formatting"&&e.formattingValues){const i=e.defaultFormattingWidth||e.defaultWidth,a=n!=null&&n.width?String(n.width):i;o=e.formattingValues[a]||e.formattingValues[i]}else{const i=e.defaultWidth,a=n!=null&&n.width?String(n.width):e.defaultWidth;o=e.values[a]||e.values[i]}const s=e.argumentCallback?e.argumentCallback(t):t;return o[s]}}const rZe={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},oZe={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},sZe={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},iZe={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},aZe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},lZe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},cZe=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},uZe={ordinalNumber:cZe,era:qx({values:rZe,defaultWidth:"wide"}),quarter:qx({values:oZe,defaultWidth:"wide",argumentCallback:e=>e-1}),month:qx({values:sZe,defaultWidth:"wide"}),day:qx({values:iZe,defaultWidth:"wide"}),dayPeriod:qx({values:aZe,defaultWidth:"wide",formattingValues:lZe,defaultFormattingWidth:"wide"})};function Ux(e){return(t,n={})=>{const r=n.width,o=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],s=t.match(o);if(!s)return null;const i=s[0],a=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(a)?fZe(a,f=>f.test(i)):dZe(a,f=>f.test(i));let u;u=e.valueCallback?e.valueCallback(c):c,u=n.valueCallback?n.valueCallback(u):u;const d=t.slice(i.length);return{value:u,rest:d}}}function dZe(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function fZe(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function hZe(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const o=r[0],s=t.match(e.parsePattern);if(!s)return null;let i=e.valueCallback?e.valueCallback(s[0]):s[0];i=n.valueCallback?n.valueCallback(i):i;const a=t.slice(o.length);return{value:i,rest:a}}}const mZe=/^(\d+)(th|st|nd|rd)?/i,pZe=/\d+/i,gZe={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},bZe={any:[/^b/i,/^(a|c)/i]},xZe={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},yZe={any:[/1/i,/2/i,/3/i,/4/i]},vZe={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},wZe={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},CZe={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},SZe={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},NZe={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},jZe={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},kZe={ordinalNumber:hZe({matchPattern:mZe,parsePattern:pZe,valueCallback:e=>parseInt(e,10)}),era:Ux({matchPatterns:gZe,defaultMatchWidth:"wide",parsePatterns:bZe,defaultParseWidth:"any"}),quarter:Ux({matchPatterns:xZe,defaultMatchWidth:"wide",parsePatterns:yZe,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Ux({matchPatterns:vZe,defaultMatchWidth:"wide",parsePatterns:wZe,defaultParseWidth:"any"}),day:Ux({matchPatterns:CZe,defaultMatchWidth:"wide",parsePatterns:SZe,defaultParseWidth:"any"}),dayPeriod:Ux({matchPatterns:NZe,defaultMatchWidth:"any",parsePatterns:jZe,defaultParseWidth:"any"})},A$={code:"en-US",formatDistance:ZYe,formatLong:eZe,formatRelative:nZe,localize:uZe,match:kZe,options:{weekStartsOn:0,firstWeekContainsDate:1}};function IZe(e,t){const n=gr(e,t==null?void 0:t.in);return Wce(n,Yce(n))+1}function Xce(e,t){const n=gr(e,t==null?void 0:t.in),r=+cv(n)-+PYe(n);return Math.round(r/Vce)+1}function Qce(e,t){var d,f,h,m;const n=gr(e,t==null?void 0:t.in),r=n.getFullYear(),o=Hw(),s=(t==null?void 0:t.firstWeekContainsDate)??((f=(d=t==null?void 0:t.locale)==null?void 0:d.options)==null?void 0:f.firstWeekContainsDate)??o.firstWeekContainsDate??((m=(h=o.locale)==null?void 0:h.options)==null?void 0:m.firstWeekContainsDate)??1,i=Io((t==null?void 0:t.in)||e,0);i.setFullYear(r+1,0,s),i.setHours(0,0,0,0);const a=cb(i,t),c=Io((t==null?void 0:t.in)||e,0);c.setFullYear(r,0,s),c.setHours(0,0,0,0);const u=cb(c,t);return+n>=+a?r+1:+n>=+u?r:r-1}function _Ze(e,t){var a,c,u,d;const n=Hw(),r=(t==null?void 0:t.firstWeekContainsDate)??((c=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:c.firstWeekContainsDate)??n.firstWeekContainsDate??((d=(u=n.locale)==null?void 0:u.options)==null?void 0:d.firstWeekContainsDate)??1,o=Qce(e,t),s=Io((t==null?void 0:t.in)||e,0);return s.setFullYear(o,0,r),s.setHours(0,0,0,0),cb(s,t)}function Jce(e,t){const n=gr(e,t==null?void 0:t.in),r=+cb(n,t)-+_Ze(n,t);return Math.round(r/Vce)+1}function lr(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const nd={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return lr(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):lr(n+1,2)},d(e,t){return lr(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return lr(e.getHours()%12||12,t.length)},H(e,t){return lr(e.getHours(),t.length)},m(e,t){return lr(e.getMinutes(),t.length)},s(e,t){return lr(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),o=Math.trunc(r*Math.pow(10,n-3));return lr(o,t.length)}},Tp={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},eU={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),o=r>0?r:1-r;return n.ordinalNumber(o,{unit:"year"})}return nd.y(e,t)},Y:function(e,t,n,r){const o=Qce(e,r),s=o>0?o:1-o;if(t==="YY"){const i=s%100;return lr(i,2)}return t==="Yo"?n.ordinalNumber(s,{unit:"year"}):lr(s,t.length)},R:function(e,t){const n=Uce(e);return lr(n,t.length)},u:function(e,t){const n=e.getFullYear();return lr(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return lr(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return lr(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return nd.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return lr(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const o=Jce(e,r);return t==="wo"?n.ordinalNumber(o,{unit:"week"}):lr(o,t.length)},I:function(e,t,n){const r=Xce(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):lr(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):nd.d(e,t)},D:function(e,t,n){const r=IZe(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):lr(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const o=e.getDay(),s=(o-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(s);case"ee":return lr(s,2);case"eo":return n.ordinalNumber(s,{unit:"day"});case"eee":return n.day(o,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(o,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(o,{width:"short",context:"formatting"});case"eeee":default:return n.day(o,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const o=e.getDay(),s=(o-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(s);case"cc":return lr(s,t.length);case"co":return n.ordinalNumber(s,{unit:"day"});case"ccc":return n.day(o,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(o,{width:"narrow",context:"standalone"});case"cccccc":return n.day(o,{width:"short",context:"standalone"});case"cccc":default:return n.day(o,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),o=r===0?7:r;switch(t){case"i":return String(o);case"ii":return lr(o,t.length);case"io":return n.ordinalNumber(o,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const o=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let o;switch(r===12?o=Tp.noon:r===0?o=Tp.midnight:o=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let o;switch(r>=17?o=Tp.evening:r>=12?o=Tp.afternoon:r>=4?o=Tp.morning:o=Tp.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return nd.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):nd.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):lr(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):lr(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):nd.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):nd.s(e,t)},S:function(e,t){return nd.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return nU(r);case"XXXX":case"XX":return th(r);case"XXXXX":case"XXX":default:return th(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return nU(r);case"xxxx":case"xx":return th(r);case"xxxxx":case"xxx":default:return th(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+tU(r,":");case"OOOO":default:return"GMT"+th(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+tU(r,":");case"zzzz":default:return"GMT"+th(r,":")}},t:function(e,t,n){const r=Math.trunc(+e/1e3);return lr(r,t.length)},T:function(e,t,n){return lr(+e,t.length)}};function tU(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),o=Math.trunc(r/60),s=r%60;return s===0?n+String(o):n+String(o)+t+lr(s,2)}function nU(e,t){return e%60===0?(e>0?"-":"+")+lr(Math.abs(e)/60,2):th(e,t)}function th(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),o=lr(Math.trunc(r/60),2),s=lr(r%60,2);return n+o+t+s}const rU=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},eue=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},TZe=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],o=n[2];if(!o)return rU(e,t);let s;switch(r){case"P":s=t.dateTime({width:"short"});break;case"PP":s=t.dateTime({width:"medium"});break;case"PPP":s=t.dateTime({width:"long"});break;case"PPPP":default:s=t.dateTime({width:"full"});break}return s.replace("{{date}}",rU(r,t)).replace("{{time}}",eue(o,t))},EZe={p:eue,P:TZe},DZe=/^D+$/,MZe=/^Y+$/,RZe=["D","DD","YY","YYYY"];function AZe(e){return DZe.test(e)}function PZe(e){return MZe.test(e)}function FZe(e,t,n){const r=OZe(e,t,n);if(console.warn(r),RZe.includes(e))throw new RangeError(r)}function OZe(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const LZe=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,$Ze=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,zZe=/^'([^]*?)'?$/,BZe=/''/g,VZe=/[a-zA-Z]/;function HZe(e,t,n){var d,f,h,m,g,x,b,y;const r=Hw(),o=(n==null?void 0:n.locale)??r.locale??A$,s=(n==null?void 0:n.firstWeekContainsDate)??((f=(d=n==null?void 0:n.locale)==null?void 0:d.options)==null?void 0:f.firstWeekContainsDate)??r.firstWeekContainsDate??((m=(h=r.locale)==null?void 0:h.options)==null?void 0:m.firstWeekContainsDate)??1,i=(n==null?void 0:n.weekStartsOn)??((x=(g=n==null?void 0:n.locale)==null?void 0:g.options)==null?void 0:x.weekStartsOn)??r.weekStartsOn??((y=(b=r.locale)==null?void 0:b.options)==null?void 0:y.weekStartsOn)??0,a=gr(e,n==null?void 0:n.in);if(!BYe(a))throw new RangeError("Invalid time value");let c=t.match($Ze).map(w=>{const C=w[0];if(C==="p"||C==="P"){const N=EZe[C];return N(w,o.formatLong)}return w}).join("").match(LZe).map(w=>{if(w==="''")return{isToken:!1,value:"'"};const C=w[0];if(C==="'")return{isToken:!1,value:qZe(w)};if(eU[C])return{isToken:!0,value:w};if(C.match(VZe))throw new RangeError("Format string contains an unescaped latin alphabet character `"+C+"`");return{isToken:!1,value:w}});o.localize.preprocessor&&(c=o.localize.preprocessor(a,c));const u={firstWeekContainsDate:s,weekStartsOn:i,locale:o};return c.map(w=>{if(!w.isToken)return w.value;const C=w.value;(!(n!=null&&n.useAdditionalWeekYearTokens)&&PZe(C)||!(n!=null&&n.useAdditionalDayOfYearTokens)&&AZe(C))&&FZe(C,t,String(e));const N=eU[C[0]];return N(a,C,o.localize,u)}).join("")}function qZe(e){const t=e.match(zZe);return t?t[1].replace(BZe,"'"):e}function UZe(e,t){const n=gr(e,t==null?void 0:t.in),r=n.getFullYear(),o=n.getMonth(),s=Io(n,0);return s.setFullYear(r,o+1,0),s.setHours(0,0,0,0),s.getDate()}function WZe(e,t){return gr(e,t==null?void 0:t.in).getMonth()}function KZe(e,t){return gr(e,t==null?void 0:t.in).getFullYear()}function GZe(e,t){return+gr(e)>+gr(t)}function YZe(e,t){return+gr(e)<+gr(t)}function ZZe(e,t,n){const[r,o]=ex(n==null?void 0:n.in,e,t);return r.getFullYear()===o.getFullYear()&&r.getMonth()===o.getMonth()}function XZe(e,t,n){const[r,o]=ex(n==null?void 0:n.in,e,t);return r.getFullYear()===o.getFullYear()}function QZe(e,t,n){const r=gr(e,n==null?void 0:n.in),o=r.getFullYear(),s=r.getDate(),i=Io(e,0);i.setFullYear(o,t,15),i.setHours(0,0,0,0);const a=UZe(i);return r.setMonth(t,Math.min(s,a)),r}function JZe(e,t,n){const r=gr(e,n==null?void 0:n.in);return isNaN(+r)?Io(e,NaN):(r.setFullYear(t),r)}const oU=5,eXe=4;function tXe(e,t){const n=t.startOfMonth(e),r=n.getDay()>0?n.getDay():7,o=t.addDays(e,-r+1),s=t.addDays(o,oU*7-1);return t.getMonth(e)===t.getMonth(s)?oU:eXe}function tue(e,t){const n=t.startOfMonth(e),r=n.getDay();return r===1?n:r===0?t.addDays(n,-1*6):t.addDays(n,-1*(r-1))}function nXe(e,t){const n=tue(e,t),r=tXe(e,t);return t.addDays(n,r*7-1)}class Qi{constructor(t,n){this.Date=Date,this.today=()=>{var r;return(r=this.overrides)!=null&&r.today?this.overrides.today():this.options.timeZone?ru.tz(this.options.timeZone):new this.Date},this.newDate=(r,o,s)=>{var i;return(i=this.overrides)!=null&&i.newDate?this.overrides.newDate(r,o,s):this.options.timeZone?new ru(r,o,s,this.options.timeZone):new Date(r,o,s)},this.addDays=(r,o)=>{var s;return(s=this.overrides)!=null&&s.addDays?this.overrides.addDays(r,o):Hce(r,o)},this.addMonths=(r,o)=>{var s;return(s=this.overrides)!=null&&s.addMonths?this.overrides.addMonths(r,o):qce(r,o)},this.addWeeks=(r,o)=>{var s;return(s=this.overrides)!=null&&s.addWeeks?this.overrides.addWeeks(r,o):FYe(r,o)},this.addYears=(r,o)=>{var s;return(s=this.overrides)!=null&&s.addYears?this.overrides.addYears(r,o):OYe(r,o)},this.differenceInCalendarDays=(r,o)=>{var s;return(s=this.overrides)!=null&&s.differenceInCalendarDays?this.overrides.differenceInCalendarDays(r,o):Wce(r,o)},this.differenceInCalendarMonths=(r,o)=>{var s;return(s=this.overrides)!=null&&s.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(r,o):VYe(r,o)},this.eachMonthOfInterval=r=>{var o;return(o=this.overrides)!=null&&o.eachMonthOfInterval?this.overrides.eachMonthOfInterval(r):qYe(r)},this.eachYearOfInterval=r=>{var a;const o=(a=this.overrides)!=null&&a.eachYearOfInterval?this.overrides.eachYearOfInterval(r):KYe(r),s=new Set(o.map(c=>this.getYear(c)));if(s.size===o.length)return o;const i=[];return s.forEach(c=>{i.push(new Date(c,0,1))}),i},this.endOfBroadcastWeek=r=>{var o;return(o=this.overrides)!=null&&o.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(r):nXe(r,this)},this.endOfISOWeek=r=>{var o;return(o=this.overrides)!=null&&o.endOfISOWeek?this.overrides.endOfISOWeek(r):GYe(r)},this.endOfMonth=r=>{var o;return(o=this.overrides)!=null&&o.endOfMonth?this.overrides.endOfMonth(r):HYe(r)},this.endOfWeek=(r,o)=>{var s;return(s=this.overrides)!=null&&s.endOfWeek?this.overrides.endOfWeek(r,o):Zce(r,this.options)},this.endOfYear=r=>{var o;return(o=this.overrides)!=null&&o.endOfYear?this.overrides.endOfYear(r):WYe(r)},this.format=(r,o,s)=>{var a;const i=(a=this.overrides)!=null&&a.format?this.overrides.format(r,o,this.options):HZe(r,o,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(i):i},this.getISOWeek=r=>{var o;return(o=this.overrides)!=null&&o.getISOWeek?this.overrides.getISOWeek(r):Xce(r)},this.getMonth=(r,o)=>{var s;return(s=this.overrides)!=null&&s.getMonth?this.overrides.getMonth(r,this.options):WZe(r,this.options)},this.getYear=(r,o)=>{var s;return(s=this.overrides)!=null&&s.getYear?this.overrides.getYear(r,this.options):KZe(r,this.options)},this.getWeek=(r,o)=>{var s;return(s=this.overrides)!=null&&s.getWeek?this.overrides.getWeek(r,this.options):Jce(r,this.options)},this.isAfter=(r,o)=>{var s;return(s=this.overrides)!=null&&s.isAfter?this.overrides.isAfter(r,o):GZe(r,o)},this.isBefore=(r,o)=>{var s;return(s=this.overrides)!=null&&s.isBefore?this.overrides.isBefore(r,o):YZe(r,o)},this.isDate=r=>{var o;return(o=this.overrides)!=null&&o.isDate?this.overrides.isDate(r):Kce(r)},this.isSameDay=(r,o)=>{var s;return(s=this.overrides)!=null&&s.isSameDay?this.overrides.isSameDay(r,o):zYe(r,o)},this.isSameMonth=(r,o)=>{var s;return(s=this.overrides)!=null&&s.isSameMonth?this.overrides.isSameMonth(r,o):ZZe(r,o)},this.isSameYear=(r,o)=>{var s;return(s=this.overrides)!=null&&s.isSameYear?this.overrides.isSameYear(r,o):XZe(r,o)},this.max=r=>{var o;return(o=this.overrides)!=null&&o.max?this.overrides.max(r):LYe(r)},this.min=r=>{var o;return(o=this.overrides)!=null&&o.min?this.overrides.min(r):$Ye(r)},this.setMonth=(r,o)=>{var s;return(s=this.overrides)!=null&&s.setMonth?this.overrides.setMonth(r,o):QZe(r,o)},this.setYear=(r,o)=>{var s;return(s=this.overrides)!=null&&s.setYear?this.overrides.setYear(r,o):JZe(r,o)},this.startOfBroadcastWeek=(r,o)=>{var s;return(s=this.overrides)!=null&&s.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(r,this):tue(r,this)},this.startOfDay=r=>{var o;return(o=this.overrides)!=null&&o.startOfDay?this.overrides.startOfDay(r):uv(r)},this.startOfISOWeek=r=>{var o;return(o=this.overrides)!=null&&o.startOfISOWeek?this.overrides.startOfISOWeek(r):cv(r)},this.startOfMonth=r=>{var o;return(o=this.overrides)!=null&&o.startOfMonth?this.overrides.startOfMonth(r):UYe(r)},this.startOfWeek=(r,o)=>{var s;return(s=this.overrides)!=null&&s.startOfWeek?this.overrides.startOfWeek(r,this.options):cb(r,this.options)},this.startOfYear=r=>{var o;return(o=this.overrides)!=null&&o.startOfYear?this.overrides.startOfYear(r):Yce(r)},this.options={locale:A$,...t},this.overrides=n}getDigitMap(){const{numerals:t="latn"}=this.options,n=new Intl.NumberFormat("en-US",{numberingSystem:t}),r={};for(let o=0;o<10;o++)r[o.toString()]=n.format(o);return r}replaceDigits(t){const n=this.getDigitMap();return t.replace(/\d/g,r=>n[r]||r)}formatNumber(t){return this.replaceDigits(t.toString())}getMonthYearOrder(){var n;const t=(n=this.options.locale)==null?void 0:n.code;return t&&Qi.yearFirstLocales.has(t)?"year-first":"month-first"}formatMonthYear(t){const{locale:n,timeZone:r,numerals:o}=this.options,s=n==null?void 0:n.code;if(s&&Qi.yearFirstLocales.has(s))try{return new Intl.DateTimeFormat(s,{month:"long",year:"numeric",timeZone:r,numberingSystem:o}).format(t)}catch{}const i=this.getMonthYearOrder()==="year-first"?"y LLLL":"LLLL y";return this.format(t,i)}}Qi.yearFirstLocales=new Set(["eu","hu","ja","ja-Hira","ja-JP","ko","ko-KR","lt","lt-LT","lv","lv-LV","mn","mn-MN","zh","zh-CN","zh-HK","zh-TW"]);const wc=new Qi;class nue{constructor(t,n,r=wc){this.date=t,this.displayMonth=n,this.outside=!!(n&&!r.isSameMonth(t,n)),this.dateLib=r,this.isoDate=r.format(t,"yyyy-MM-dd"),this.displayMonthId=r.format(n,"yyyy-MM"),this.dateMonthId=r.format(t,"yyyy-MM")}isEqualTo(t){return this.dateLib.isSameDay(t.date,this.date)&&this.dateLib.isSameMonth(t.displayMonth,this.displayMonth)}}class rXe{constructor(t,n){this.date=t,this.weeks=n}}class oXe{constructor(t,n){this.days=n,this.weekNumber=t}}function sXe(e){return v.createElement("button",{...e})}function iXe(e){return v.createElement("span",{...e})}function aXe(e){const{size:t=24,orientation:n="left",className:r}=e;return v.createElement("svg",{className:r,width:t,height:t,viewBox:"0 0 24 24"},n==="up"&&v.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),n==="down"&&v.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),n==="left"&&v.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),n==="right"&&v.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function lXe(e){const{day:t,modifiers:n,...r}=e;return v.createElement("td",{...r})}function cXe(e){const{day:t,modifiers:n,...r}=e,o=v.useRef(null);return v.useEffect(()=>{var s;n.focused&&((s=o.current)==null||s.focus())},[n.focused]),v.createElement("button",{ref:o,...r})}var qt;(function(e){e.Root="root",e.Chevron="chevron",e.Day="day",e.DayButton="day_button",e.CaptionLabel="caption_label",e.Dropdowns="dropdowns",e.Dropdown="dropdown",e.DropdownRoot="dropdown_root",e.Footer="footer",e.MonthGrid="month_grid",e.MonthCaption="month_caption",e.MonthsDropdown="months_dropdown",e.Month="month",e.Months="months",e.Nav="nav",e.NextMonthButton="button_next",e.PreviousMonthButton="button_previous",e.Week="week",e.Weeks="weeks",e.Weekday="weekday",e.Weekdays="weekdays",e.WeekNumber="week_number",e.WeekNumberHeader="week_number_header",e.YearsDropdown="years_dropdown"})(qt||(qt={}));var Gr;(function(e){e.disabled="disabled",e.hidden="hidden",e.outside="outside",e.focused="focused",e.today="today"})(Gr||(Gr={}));var Ya;(function(e){e.range_end="range_end",e.range_middle="range_middle",e.range_start="range_start",e.selected="selected"})(Ya||(Ya={}));var zi;(function(e){e.weeks_before_enter="weeks_before_enter",e.weeks_before_exit="weeks_before_exit",e.weeks_after_enter="weeks_after_enter",e.weeks_after_exit="weeks_after_exit",e.caption_after_enter="caption_after_enter",e.caption_after_exit="caption_after_exit",e.caption_before_enter="caption_before_enter",e.caption_before_exit="caption_before_exit"})(zi||(zi={}));function uXe(e){const{options:t,className:n,components:r,classNames:o,...s}=e,i=[o[qt.Dropdown],n].join(" "),a=t==null?void 0:t.find(({value:c})=>c===s.value);return v.createElement("span",{"data-disabled":s.disabled,className:o[qt.DropdownRoot]},v.createElement(r.Select,{className:i,...s},t==null?void 0:t.map(({value:c,label:u,disabled:d})=>v.createElement(r.Option,{key:c,value:c,disabled:d},u))),v.createElement("span",{className:o[qt.CaptionLabel],"aria-hidden":!0},a==null?void 0:a.label,v.createElement(r.Chevron,{orientation:"down",size:18,className:o[qt.Chevron]})))}function dXe(e){return v.createElement("div",{...e})}function fXe(e){return v.createElement("div",{...e})}function hXe(e){const{calendarMonth:t,displayIndex:n,...r}=e;return v.createElement("div",{...r},e.children)}function mXe(e){const{calendarMonth:t,displayIndex:n,...r}=e;return v.createElement("div",{...r})}function pXe(e){return v.createElement("table",{...e})}function gXe(e){return v.createElement("div",{...e})}const rue=v.createContext(void 0);function qw(){const e=v.useContext(rue);if(e===void 0)throw new Error("useDayPicker() must be used within a custom component.");return e}function bXe(e){const{components:t}=qw();return v.createElement(t.Dropdown,{...e})}function xXe(e){const{onPreviousClick:t,onNextClick:n,previousMonth:r,nextMonth:o,...s}=e,{components:i,classNames:a,labels:{labelPrevious:c,labelNext:u}}=qw(),d=v.useCallback(h=>{o&&(n==null||n(h))},[o,n]),f=v.useCallback(h=>{r&&(t==null||t(h))},[r,t]);return v.createElement("nav",{...s},v.createElement(i.PreviousMonthButton,{type:"button",className:a[qt.PreviousMonthButton],tabIndex:r?void 0:-1,"aria-disabled":r?void 0:!0,"aria-label":c(r),onClick:f},v.createElement(i.Chevron,{disabled:r?void 0:!0,className:a[qt.Chevron],orientation:"left"})),v.createElement(i.NextMonthButton,{type:"button",className:a[qt.NextMonthButton],tabIndex:o?void 0:-1,"aria-disabled":o?void 0:!0,"aria-label":u(o),onClick:d},v.createElement(i.Chevron,{disabled:o?void 0:!0,orientation:"right",className:a[qt.Chevron]})))}function yXe(e){const{components:t}=qw();return v.createElement(t.Button,{...e})}function vXe(e){return v.createElement("option",{...e})}function wXe(e){const{components:t}=qw();return v.createElement(t.Button,{...e})}function CXe(e){const{rootRef:t,...n}=e;return v.createElement("div",{...n,ref:t})}function SXe(e){return v.createElement("select",{...e})}function NXe(e){const{week:t,...n}=e;return v.createElement("tr",{...n})}function jXe(e){return v.createElement("th",{...e})}function kXe(e){return v.createElement("thead",{"aria-hidden":!0},v.createElement("tr",{...e}))}function IXe(e){const{week:t,...n}=e;return v.createElement("th",{...n})}function _Xe(e){return v.createElement("th",{...e})}function TXe(e){return v.createElement("tbody",{...e})}function EXe(e){const{components:t}=qw();return v.createElement(t.Dropdown,{...e})}const DXe=Object.freeze(Object.defineProperty({__proto__:null,Button:sXe,CaptionLabel:iXe,Chevron:aXe,Day:lXe,DayButton:cXe,Dropdown:uXe,DropdownNav:dXe,Footer:fXe,Month:hXe,MonthCaption:mXe,MonthGrid:pXe,Months:gXe,MonthsDropdown:bXe,Nav:xXe,NextMonthButton:yXe,Option:vXe,PreviousMonthButton:wXe,Root:CXe,Select:SXe,Week:NXe,WeekNumber:IXe,WeekNumberHeader:_Xe,Weekday:jXe,Weekdays:kXe,Weeks:TXe,YearsDropdown:EXe},Symbol.toStringTag,{value:"Module"}));function ou(e,t,n=!1,r=wc){let{from:o,to:s}=e;const{differenceInCalendarDays:i,isSameDay:a}=r;return o&&s?(i(s,o)<0&&([o,s]=[s,o]),i(t,o)>=(n?1:0)&&i(s,t)>=(n?1:0)):!n&&s?a(s,t):!n&&o?a(o,t):!1}function P$(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function q_(e){return!!(e&&typeof e=="object"&&"from"in e)}function F$(e){return!!(e&&typeof e=="object"&&"after"in e)}function O$(e){return!!(e&&typeof e=="object"&&"before"in e)}function oue(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function sue(e,t){return Array.isArray(e)&&e.every(t.isDate)}function su(e,t,n=wc){const r=Array.isArray(t)?t:[t],{isSameDay:o,differenceInCalendarDays:s,isAfter:i}=n;return r.some(a=>{if(typeof a=="boolean")return a;if(n.isDate(a))return o(e,a);if(sue(a,n))return a.includes(e);if(q_(a))return ou(a,e,!1,n);if(oue(a))return Array.isArray(a.dayOfWeek)?a.dayOfWeek.includes(e.getDay()):a.dayOfWeek===e.getDay();if(P$(a)){const c=s(a.before,e),u=s(a.after,e),d=c>0,f=u<0;return i(a.before,a.after)?f&&d:d||f}return F$(a)?s(e,a.after)>0:O$(a)?s(a.before,e)>0:typeof a=="function"?a(e):!1})}function MXe(e,t,n,r,o){const{disabled:s,hidden:i,modifiers:a,showOutsideDays:c,broadcastCalendar:u,today:d=o.today()}=t,{isSameDay:f,isSameMonth:h,startOfMonth:m,isBefore:g,endOfMonth:x,isAfter:b}=o,y=n&&m(n),w=r&&x(r),C={[Gr.focused]:[],[Gr.outside]:[],[Gr.disabled]:[],[Gr.hidden]:[],[Gr.today]:[]},N={};for(const S of e){const{date:j,displayMonth:I}=S,k=!!(I&&!h(j,I)),T=!!(y&&g(j,y)),_=!!(w&&b(j,w)),E=!!(s&&su(j,s,o)),D=!!(i&&su(j,i,o))||T||_||!u&&!c&&k||u&&c===!1&&k,M=f(j,d);k&&C.outside.push(S),E&&C.disabled.push(S),D&&C.hidden.push(S),M&&C.today.push(S),a&&Object.keys(a).forEach(P=>{const A=a==null?void 0:a[P];A&&su(j,A,o)&&(N[P]?N[P].push(S):N[P]=[S])})}return S=>{const j={[Gr.focused]:!1,[Gr.disabled]:!1,[Gr.hidden]:!1,[Gr.outside]:!1,[Gr.today]:!1},I={};for(const k in C){const T=C[k];j[k]=T.some(_=>_===S)}for(const k in N)I[k]=N[k].some(T=>T===S);return{...j,...I}}}function RXe(e,t,n={}){return Object.entries(e).filter(([,o])=>o===!0).reduce((o,[s])=>(n[s]?o.push(n[s]):t[Gr[s]]?o.push(t[Gr[s]]):t[Ya[s]]&&o.push(t[Ya[s]]),o),[t[qt.Day]])}function AXe(e){return{...DXe,...e}}function PXe(e){const t={"data-mode":e.mode??void 0,"data-required":"required"in e?e.required:void 0,"data-multiple-months":e.numberOfMonths&&e.numberOfMonths>1||void 0,"data-week-numbers":e.showWeekNumber||void 0,"data-broadcast-calendar":e.broadcastCalendar||void 0,"data-nav-layout":e.navLayout||void 0};return Object.entries(e).forEach(([n,r])=>{n.startsWith("data-")&&(t[n]=r)}),t}function L$(){const e={};for(const t in qt)e[qt[t]]=`rdp-${qt[t]}`;for(const t in Gr)e[Gr[t]]=`rdp-${Gr[t]}`;for(const t in Ya)e[Ya[t]]=`rdp-${Ya[t]}`;for(const t in zi)e[zi[t]]=`rdp-${zi[t]}`;return e}function iue(e,t,n){return(n??new Qi(t)).formatMonthYear(e)}const FXe=iue;function OXe(e,t,n){return(n??new Qi(t)).format(e,"d")}function LXe(e,t=wc){return t.format(e,"LLLL")}function $Xe(e,t,n){return(n??new Qi(t)).format(e,"cccccc")}function zXe(e,t=wc){return e<10?t.formatNumber(`0${e.toLocaleString()}`):t.formatNumber(`${e.toLocaleString()}`)}function BXe(){return""}function aue(e,t=wc){return t.format(e,"yyyy")}const VXe=aue,HXe=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:iue,formatDay:OXe,formatMonthCaption:FXe,formatMonthDropdown:LXe,formatWeekNumber:zXe,formatWeekNumberHeader:BXe,formatWeekdayName:$Xe,formatYearCaption:VXe,formatYearDropdown:aue},Symbol.toStringTag,{value:"Module"}));function qXe(e){return e!=null&&e.formatMonthCaption&&!e.formatCaption&&(e.formatCaption=e.formatMonthCaption),e!=null&&e.formatYearCaption&&!e.formatYearDropdown&&(e.formatYearDropdown=e.formatYearCaption),{...HXe,...e}}function UXe(e,t,n,r,o){const{startOfMonth:s,startOfYear:i,endOfYear:a,eachMonthOfInterval:c,getMonth:u}=o;return c({start:i(e),end:a(e)}).map(h=>{const m=r.formatMonthDropdown(h,o),g=u(h),x=t&&h<s(t)||n&&h>s(n)||!1;return{value:g,label:m,disabled:x}})}function WXe(e,t={},n={}){let r={...t==null?void 0:t[qt.Day]};return Object.entries(e).filter(([,o])=>o===!0).forEach(([o])=>{r={...r,...n==null?void 0:n[o]}}),r}function KXe(e,t,n,r){const o=r??e.today(),s=n?e.startOfBroadcastWeek(o,e):t?e.startOfISOWeek(o):e.startOfWeek(o),i=[];for(let a=0;a<7;a++){const c=e.addDays(s,a);i.push(c)}return i}function GXe(e,t,n,r,o=!1){if(!e||!t)return;const{startOfYear:s,endOfYear:i,eachYearOfInterval:a,getYear:c}=r,u=s(e),d=i(t),f=a({start:u,end:d});return o&&f.reverse(),f.map(h=>{const m=n.formatYearDropdown(h,r);return{value:c(h),label:m,disabled:!1}})}function lue(e,t,n,r){let o=(r??new Qi(n)).format(e,"PPPP");return t.today&&(o=`Today, ${o}`),t.selected&&(o=`${o}, selected`),o}const YXe=lue;function cue(e,t,n){return(n??new Qi(t)).formatMonthYear(e)}const ZXe=cue;function XXe(e,t,n,r){let o=(r??new Qi(n)).format(e,"PPPP");return t!=null&&t.today&&(o=`Today, ${o}`),o}function QXe(e){return"Choose the Month"}function JXe(){return""}function eQe(e){return"Go to the Next Month"}function tQe(e){return"Go to the Previous Month"}function nQe(e,t,n){return(n??new Qi(t)).format(e,"cccc")}function rQe(e,t){return`Week ${e}`}function oQe(e){return"Week Number"}function sQe(e){return"Choose the Year"}const iQe=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:ZXe,labelDay:YXe,labelDayButton:lue,labelGrid:cue,labelGridcell:XXe,labelMonthDropdown:QXe,labelNav:JXe,labelNext:eQe,labelPrevious:tQe,labelWeekNumber:rQe,labelWeekNumberHeader:oQe,labelWeekday:nQe,labelYearDropdown:sQe},Symbol.toStringTag,{value:"Module"})),Uw=e=>e instanceof HTMLElement?e:null,CM=e=>[...e.querySelectorAll("[data-animated-month]")??[]],aQe=e=>Uw(e.querySelector("[data-animated-month]")),SM=e=>Uw(e.querySelector("[data-animated-caption]")),NM=e=>Uw(e.querySelector("[data-animated-weeks]")),lQe=e=>Uw(e.querySelector("[data-animated-nav]")),cQe=e=>Uw(e.querySelector("[data-animated-weekdays]"));function uQe(e,t,{classNames:n,months:r,focused:o,dateLib:s}){const i=v.useRef(null),a=v.useRef(r),c=v.useRef(!1);v.useLayoutEffect(()=>{const u=a.current;if(a.current=r,!t||!e.current||!(e.current instanceof HTMLElement)||r.length===0||u.length===0||r.length!==u.length)return;const d=s.isSameMonth(r[0].date,u[0].date),f=s.isAfter(r[0].date,u[0].date),h=f?n[zi.caption_after_enter]:n[zi.caption_before_enter],m=f?n[zi.weeks_after_enter]:n[zi.weeks_before_enter],g=i.current,x=e.current.cloneNode(!0);if(x instanceof HTMLElement?(CM(x).forEach(C=>{if(!(C instanceof HTMLElement))return;const N=aQe(C);N&&C.contains(N)&&C.removeChild(N);const S=SM(C);S&&S.classList.remove(h);const j=NM(C);j&&j.classList.remove(m)}),i.current=x):i.current=null,c.current||d||o)return;const b=g instanceof HTMLElement?CM(g):[],y=CM(e.current);if(y!=null&&y.every(w=>w instanceof HTMLElement)&&b&&b.every(w=>w instanceof HTMLElement)){c.current=!0,e.current.style.isolation="isolate";const w=lQe(e.current);w&&(w.style.zIndex="1"),y.forEach((C,N)=>{const S=b[N];if(!S)return;C.style.position="relative",C.style.overflow="hidden";const j=SM(C);j&&j.classList.add(h);const I=NM(C);I&&I.classList.add(m);const k=()=>{c.current=!1,e.current&&(e.current.style.isolation=""),w&&(w.style.zIndex=""),j&&j.classList.remove(h),I&&I.classList.remove(m),C.style.position="",C.style.overflow="",C.contains(S)&&C.removeChild(S)};S.style.pointerEvents="none",S.style.position="absolute",S.style.overflow="hidden",S.setAttribute("aria-hidden","true");const T=cQe(S);T&&(T.style.opacity="0");const _=SM(S);_&&(_.classList.add(f?n[zi.caption_before_exit]:n[zi.caption_after_exit]),_.addEventListener("animationend",k));const E=NM(S);E&&E.classList.add(f?n[zi.weeks_before_exit]:n[zi.weeks_after_exit]),C.insertBefore(S,C.firstChild)})}})}function dQe(e,t,n,r){const o=e[0],s=e[e.length-1],{ISOWeek:i,fixedWeeks:a,broadcastCalendar:c}=n??{},{addDays:u,differenceInCalendarDays:d,differenceInCalendarMonths:f,endOfBroadcastWeek:h,endOfISOWeek:m,endOfMonth:g,endOfWeek:x,isAfter:b,startOfBroadcastWeek:y,startOfISOWeek:w,startOfWeek:C}=r,N=c?y(o,r):i?w(o):C(o),S=c?h(s):i?m(g(s)):x(g(s)),j=t&&(c?h(t):i?m(t):x(t)),I=j&&b(S,j)?j:S,k=d(I,N),T=f(s,o)+1,_=[];for(let M=0;M<=k;M++){const P=u(N,M);_.push(P)}const D=(c?35:42)*T;if(a&&_.length<D){const M=D-_.length;for(let P=0;P<M;P++){const A=u(_[_.length-1],1);_.push(A)}}return _}function fQe(e){const t=[];return e.reduce((n,r)=>{const o=r.weeks.reduce((s,i)=>s.concat(i.days.slice()),t.slice());return n.concat(o.slice())},t.slice())}function hQe(e,t,n,r){const{numberOfMonths:o=1}=n,s=[];for(let i=0;i<o;i++){const a=r.addMonths(e,i);if(t&&a>t)break;s.push(a)}return s}function sU(e,t,n,r){const{month:o,defaultMonth:s,today:i=r.today(),numberOfMonths:a=1}=e;let c=o||s||i;const{differenceInCalendarMonths:u,addMonths:d,startOfMonth:f}=r;if(n&&u(n,c)<a-1){const h=-1*(a-1);c=d(n,h)}return t&&u(c,t)<0&&(c=t),f(c)}function mQe(e,t,n,r){const{addDays:o,endOfBroadcastWeek:s,endOfISOWeek:i,endOfMonth:a,endOfWeek:c,getISOWeek:u,getWeek:d,startOfBroadcastWeek:f,startOfISOWeek:h,startOfWeek:m}=r,g=e.reduce((x,b)=>{const y=n.broadcastCalendar?f(b,r):n.ISOWeek?h(b):m(b),w=n.broadcastCalendar?s(b):n.ISOWeek?i(a(b)):c(a(b)),C=t.filter(I=>I>=y&&I<=w),N=n.broadcastCalendar?35:42;if(n.fixedWeeks&&C.length<N){const I=t.filter(k=>{const T=N-C.length;return k>w&&k<=o(w,T)});C.push(...I)}const S=C.reduce((I,k)=>{const T=n.ISOWeek?u(k):d(k),_=I.find(D=>D.weekNumber===T),E=new nue(k,b,r);return _?_.days.push(E):I.push(new oXe(T,[E])),I},[]),j=new rXe(b,S);return x.push(j),x},[]);return n.reverseMonths?g.reverse():g}function pQe(e,t){let{startMonth:n,endMonth:r}=e;const{startOfYear:o,startOfDay:s,startOfMonth:i,endOfMonth:a,addYears:c,endOfYear:u,newDate:d,today:f}=t,{fromYear:h,toYear:m,fromMonth:g,toMonth:x}=e;!n&&g&&(n=g),!n&&h&&(n=t.newDate(h,0,1)),!r&&x&&(r=x),!r&&m&&(r=d(m,11,31));const b=e.captionLayout==="dropdown"||e.captionLayout==="dropdown-years";return n?n=i(n):h?n=d(h,0,1):!n&&b&&(n=o(c(e.today??f(),-100))),r?r=a(r):m?r=d(m,11,31):!r&&b&&(r=u(e.today??f())),[n&&s(n),r&&s(r)]}function gQe(e,t,n,r){if(n.disableNavigation)return;const{pagedNavigation:o,numberOfMonths:s=1}=n,{startOfMonth:i,addMonths:a,differenceInCalendarMonths:c}=r,u=o?s:1,d=i(e);if(!t)return a(d,u);if(!(c(t,e)<s))return a(d,u)}function bQe(e,t,n,r){if(n.disableNavigation)return;const{pagedNavigation:o,numberOfMonths:s}=n,{startOfMonth:i,addMonths:a,differenceInCalendarMonths:c}=r,u=o?s??1:1,d=i(e);if(!t)return a(d,-u);if(!(c(d,t)<=0))return a(d,-u)}function xQe(e){const t=[];return e.reduce((n,r)=>n.concat(r.weeks.slice()),t.slice())}function U_(e,t){const[n,r]=v.useState(e);return[t===void 0?n:t,r]}function yQe(e,t){var N;const[n,r]=pQe(e,t),{startOfMonth:o,endOfMonth:s}=t,i=sU(e,n,r,t),[a,c]=U_(i,e.month?i:void 0);v.useEffect(()=>{const S=sU(e,n,r,t);c(S)},[e.timeZone]);const{months:u,weeks:d,days:f,previousMonth:h,nextMonth:m}=v.useMemo(()=>{const S=hQe(a,r,{numberOfMonths:e.numberOfMonths},t),j=dQe(S,e.endMonth?s(e.endMonth):void 0,{ISOWeek:e.ISOWeek,fixedWeeks:e.fixedWeeks,broadcastCalendar:e.broadcastCalendar},t),I=mQe(S,j,{broadcastCalendar:e.broadcastCalendar,fixedWeeks:e.fixedWeeks,ISOWeek:e.ISOWeek,reverseMonths:e.reverseMonths},t),k=xQe(I),T=fQe(I),_=bQe(a,n,e,t),E=gQe(a,r,e,t);return{months:I,weeks:k,days:T,previousMonth:_,nextMonth:E}},[t,a.getTime(),r==null?void 0:r.getTime(),n==null?void 0:n.getTime(),e.disableNavigation,e.broadcastCalendar,(N=e.endMonth)==null?void 0:N.getTime(),e.fixedWeeks,e.ISOWeek,e.numberOfMonths,e.pagedNavigation,e.reverseMonths]),{disableNavigation:g,onMonthChange:x}=e,b=S=>d.some(j=>j.days.some(I=>I.isEqualTo(S))),y=S=>{if(g)return;let j=o(S);n&&j<o(n)&&(j=o(n)),r&&j>o(r)&&(j=o(r)),c(j),x==null||x(j)};return{months:u,weeks:d,days:f,navStart:n,navEnd:r,previousMonth:h,nextMonth:m,goToMonth:y,goToDay:S=>{b(S)||y(S.date)}}}var Fl;(function(e){e[e.Today=0]="Today",e[e.Selected=1]="Selected",e[e.LastFocused=2]="LastFocused",e[e.FocusedModifier=3]="FocusedModifier"})(Fl||(Fl={}));function iU(e){return!e[Gr.disabled]&&!e[Gr.hidden]&&!e[Gr.outside]}function vQe(e,t,n,r){let o,s=-1;for(const i of e){const a=t(i);iU(a)&&(a[Gr.focused]&&s<Fl.FocusedModifier?(o=i,s=Fl.FocusedModifier):r!=null&&r.isEqualTo(i)&&s<Fl.LastFocused?(o=i,s=Fl.LastFocused):n(i.date)&&s<Fl.Selected?(o=i,s=Fl.Selected):a[Gr.today]&&s<Fl.Today&&(o=i,s=Fl.Today))}return o||(o=e.find(i=>iU(t(i)))),o}function wQe(e,t,n,r,o,s,i){const{ISOWeek:a,broadcastCalendar:c}=s,{addDays:u,addMonths:d,addWeeks:f,addYears:h,endOfBroadcastWeek:m,endOfISOWeek:g,endOfWeek:x,max:b,min:y,startOfBroadcastWeek:w,startOfISOWeek:C,startOfWeek:N}=i;let j={day:u,week:f,month:d,year:h,startOfWeek:I=>c?w(I,i):a?C(I):N(I),endOfWeek:I=>c?m(I):a?g(I):x(I)}[e](n,t==="after"?1:-1);return t==="before"&&r?j=b([r,j]):t==="after"&&o&&(j=y([o,j])),j}function uue(e,t,n,r,o,s,i,a=0){if(a>365)return;const c=wQe(e,t,n.date,r,o,s,i),u=!!(s.disabled&&su(c,s.disabled,i)),d=!!(s.hidden&&su(c,s.hidden,i)),f=c,h=new nue(c,f,i);return!u&&!d?h:uue(e,t,h,r,o,s,i,a+1)}function CQe(e,t,n,r,o){const{autoFocus:s}=e,[i,a]=v.useState(),c=vQe(t.days,n,r||(()=>!1),i),[u,d]=v.useState(s?c:void 0);return{isFocusTarget:x=>!!(c!=null&&c.isEqualTo(x)),setFocused:d,focused:u,blur:()=>{a(u),d(void 0)},moveFocus:(x,b)=>{if(!u)return;const y=uue(x,b,u,t.navStart,t.navEnd,e,o);y&&(e.disableNavigation&&!t.days.some(C=>C.isEqualTo(y))||(t.goToDay(y),d(y)))}}}function SQe(e,t){const{selected:n,required:r,onSelect:o}=e,[s,i]=U_(n,o?n:void 0),a=o?n:s,{isSameDay:c}=t,u=m=>(a==null?void 0:a.some(g=>c(g,m)))??!1,{min:d,max:f}=e;return{selected:a,select:(m,g,x)=>{let b=[...a??[]];if(u(m)){if((a==null?void 0:a.length)===d||r&&(a==null?void 0:a.length)===1)return;b=a==null?void 0:a.filter(y=>!c(y,m))}else(a==null?void 0:a.length)===f?b=[m]:b=[...b,m];return o||i(b),o==null||o(b,m,g,x),b},isSelected:u}}function NQe(e,t,n=0,r=0,o=!1,s=wc){const{from:i,to:a}=t||{},{isSameDay:c,isAfter:u,isBefore:d}=s;let f;if(!i&&!a)f={from:e,to:n>0?void 0:e};else if(i&&!a)c(i,e)?n===0?f={from:i,to:e}:o?f={from:i,to:void 0}:f=void 0:d(e,i)?f={from:e,to:i}:f={from:i,to:e};else if(i&&a)if(c(i,e)&&c(a,e))o?f={from:i,to:a}:f=void 0;else if(c(i,e))f={from:i,to:n>0?void 0:e};else if(c(a,e))f={from:e,to:n>0?void 0:e};else if(d(e,i))f={from:e,to:a};else if(u(e,i))f={from:i,to:e};else if(u(e,a))f={from:i,to:e};else throw new Error("Invalid range");if(f!=null&&f.from&&(f!=null&&f.to)){const h=s.differenceInCalendarDays(f.to,f.from);r>0&&h>r?f={from:e,to:void 0}:n>1&&h<n&&(f={from:e,to:void 0})}return f}function jQe(e,t,n=wc){const r=Array.isArray(t)?t:[t];let o=e.from;const s=n.differenceInCalendarDays(e.to,e.from),i=Math.min(s,6);for(let a=0;a<=i;a++){if(r.includes(o.getDay()))return!0;o=n.addDays(o,1)}return!1}function aU(e,t,n=wc){return ou(e,t.from,!1,n)||ou(e,t.to,!1,n)||ou(t,e.from,!1,n)||ou(t,e.to,!1,n)}function kQe(e,t,n=wc){const r=Array.isArray(t)?t:[t];if(r.filter(a=>typeof a!="function").some(a=>typeof a=="boolean"?a:n.isDate(a)?ou(e,a,!1,n):sue(a,n)?a.some(c=>ou(e,c,!1,n)):q_(a)?a.from&&a.to?aU(e,{from:a.from,to:a.to},n):!1:oue(a)?jQe(e,a.dayOfWeek,n):P$(a)?n.isAfter(a.before,a.after)?aU(e,{from:n.addDays(a.after,1),to:n.addDays(a.before,-1)},n):su(e.from,a,n)||su(e.to,a,n):F$(a)||O$(a)?su(e.from,a,n)||su(e.to,a,n):!1))return!0;const i=r.filter(a=>typeof a=="function");if(i.length){let a=e.from;const c=n.differenceInCalendarDays(e.to,e.from);for(let u=0;u<=c;u++){if(i.some(d=>d(a)))return!0;a=n.addDays(a,1)}}return!1}function IQe(e,t){const{disabled:n,excludeDisabled:r,selected:o,required:s,onSelect:i}=e,[a,c]=U_(o,i?o:void 0),u=i?o:a;return{selected:u,select:(h,m,g)=>{const{min:x,max:b}=e,y=h?NQe(h,u,x,b,s,t):void 0;return r&&n&&(y!=null&&y.from)&&y.to&&kQe({from:y.from,to:y.to},n,t)&&(y.from=h,y.to=void 0),i||c(y),i==null||i(y,h,m,g),y},isSelected:h=>u&&ou(u,h,!1,t)}}function _Qe(e,t){const{selected:n,required:r,onSelect:o}=e,[s,i]=U_(n,o?n:void 0),a=o?n:s,{isSameDay:c}=t;return{selected:a,select:(f,h,m)=>{let g=f;return!r&&a&&a&&c(f,a)&&(g=void 0),o||i(g),o==null||o(g,f,h,m),g},isSelected:f=>a?c(a,f):!1}}function TQe(e,t){const n=_Qe(e,t),r=SQe(e,t),o=IQe(e,t);switch(e.mode){case"single":return n;case"multiple":return r;case"range":return o;default:return}}function rs(e,t){return e instanceof ru&&e.timeZone===t?e:new ru(e,t)}function lU(e,t){return typeof e=="boolean"||typeof e=="function"?e:e instanceof Date?rs(e,t):Array.isArray(e)?e.map(n=>n instanceof Date?rs(n,t):n):q_(e)?{...e,from:e.from?rs(e.from,t):e.from,to:e.to?rs(e.to,t):e.to}:P$(e)?{before:rs(e.before,t),after:rs(e.after,t)}:F$(e)?{after:rs(e.after,t)}:O$(e)?{before:rs(e.before,t)}:e}function jM(e,t){return e&&(Array.isArray(e)?e.map(n=>lU(n,t)):lU(e,t))}function EQe(e){var et;let t=e;const n=t.timeZone;if(n&&(t={...e,timeZone:n},t.today&&(t.today=rs(t.today,n)),t.month&&(t.month=rs(t.month,n)),t.defaultMonth&&(t.defaultMonth=rs(t.defaultMonth,n)),t.startMonth&&(t.startMonth=rs(t.startMonth,n)),t.endMonth&&(t.endMonth=rs(t.endMonth,n)),t.mode==="single"&&t.selected?t.selected=rs(t.selected,n):t.mode==="multiple"&&t.selected?t.selected=(et=t.selected)==null?void 0:et.map(ye=>rs(ye,n)):t.mode==="range"&&t.selected&&(t.selected={from:t.selected.from?rs(t.selected.from,n):t.selected.from,to:t.selected.to?rs(t.selected.to,n):t.selected.to}),t.disabled!==void 0&&(t.disabled=jM(t.disabled,n)),t.hidden!==void 0&&(t.hidden=jM(t.hidden,n)),t.modifiers)){const ye={};Object.keys(t.modifiers).forEach(He=>{var Pe;ye[He]=jM((Pe=t.modifiers)==null?void 0:Pe[He],n)}),t.modifiers=ye}const{components:r,formatters:o,labels:s,dateLib:i,locale:a,classNames:c}=v.useMemo(()=>{const ye={...A$,...t.locale};return{dateLib:new Qi({locale:ye,weekStartsOn:t.broadcastCalendar?1:t.weekStartsOn,firstWeekContainsDate:t.firstWeekContainsDate,useAdditionalWeekYearTokens:t.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:t.useAdditionalDayOfYearTokens,timeZone:t.timeZone,numerals:t.numerals},t.dateLib),components:AXe(t.components),formatters:qXe(t.formatters),labels:{...iQe,...t.labels},locale:ye,classNames:{...L$(),...t.classNames}}},[t.locale,t.broadcastCalendar,t.weekStartsOn,t.firstWeekContainsDate,t.useAdditionalWeekYearTokens,t.useAdditionalDayOfYearTokens,t.timeZone,t.numerals,t.dateLib,t.components,t.formatters,t.labels,t.classNames]);t.today||(t={...t,today:i.today()});const{captionLayout:u,mode:d,navLayout:f,numberOfMonths:h=1,onDayBlur:m,onDayClick:g,onDayFocus:x,onDayKeyDown:b,onDayMouseEnter:y,onDayMouseLeave:w,onNextClick:C,onPrevClick:N,showWeekNumber:S,styles:j}=t,{formatCaption:I,formatDay:k,formatMonthDropdown:T,formatWeekNumber:_,formatWeekNumberHeader:E,formatWeekdayName:D,formatYearDropdown:M}=o,P=yQe(t,i),{days:A,months:L,navStart:O,navEnd:B,previousMonth:H,nextMonth:R,goToMonth:V}=P,z=MXe(A,t,O,B,i),{isSelected:F,select:G,selected:q}=TQe(t,i)??{},{blur:Y,focused:K,isFocusTarget:$,moveFocus:X,setFocused:W}=CQe(t,P,z,F??(()=>!1),i),{labelDayButton:U,labelGridcell:Z,labelGrid:Q,labelMonthDropdown:J,labelNav:re,labelPrevious:de,labelNext:le,labelWeekday:ce,labelWeekNumber:oe,labelWeekNumberHeader:fe,labelYearDropdown:we}=s,pe=v.useMemo(()=>KXe(i,t.ISOWeek,t.broadcastCalendar,t.today),[i,t.ISOWeek,t.broadcastCalendar,t.today]),ne=d!==void 0||g!==void 0,Se=v.useCallback(()=>{H&&(V(H),N==null||N(H))},[H,V,N]),ue=v.useCallback(()=>{R&&(V(R),C==null||C(R))},[V,R,C]),ie=v.useCallback((ye,He)=>Pe=>{Pe.preventDefault(),Pe.stopPropagation(),W(ye),!He.disabled&&(G==null||G(ye.date,He,Pe),g==null||g(ye.date,He,Pe))},[G,g,W]),ee=v.useCallback((ye,He)=>Pe=>{W(ye),x==null||x(ye.date,He,Pe)},[x,W]),ae=v.useCallback((ye,He)=>Pe=>{Y(),m==null||m(ye.date,He,Pe)},[Y,m]),se=v.useCallback((ye,He)=>Pe=>{const _e={ArrowLeft:[Pe.shiftKey?"month":"day",t.dir==="rtl"?"after":"before"],ArrowRight:[Pe.shiftKey?"month":"day",t.dir==="rtl"?"before":"after"],ArrowDown:[Pe.shiftKey?"year":"week","after"],ArrowUp:[Pe.shiftKey?"year":"week","before"],PageUp:[Pe.shiftKey?"year":"month","before"],PageDown:[Pe.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(_e[Pe.key]){Pe.preventDefault(),Pe.stopPropagation();const[ze,Ee]=_e[Pe.key];X(ze,Ee)}b==null||b(ye.date,He,Pe)},[X,b,t.dir]),he=v.useCallback((ye,He)=>Pe=>{y==null||y(ye.date,He,Pe)},[y]),ge=v.useCallback((ye,He)=>Pe=>{w==null||w(ye.date,He,Pe)},[w]),ke=v.useCallback(ye=>He=>{const Pe=Number(He.target.value),_e=i.setMonth(i.startOfMonth(ye),Pe);V(_e)},[i,V]),De=v.useCallback(ye=>He=>{const Pe=Number(He.target.value),_e=i.setYear(i.startOfMonth(ye),Pe);V(_e)},[i,V]),{className:Re,style:Ve}=v.useMemo(()=>({className:[c[qt.Root],t.className].filter(Boolean).join(" "),style:{...j==null?void 0:j[qt.Root],...t.style}}),[c,t.className,t.style,j]),ve=PXe(t),Ke=v.useRef(null);uQe(Ke,!!t.animate,{classNames:c,months:L,focused:K,dateLib:i});const qe={dayPickerProps:t,selected:q,select:G,isSelected:F,months:L,nextMonth:R,previousMonth:H,goToMonth:V,getModifiers:z,components:r,classNames:c,styles:j,labels:s,formatters:o};return v.createElement(rue.Provider,{value:qe},v.createElement(r.Root,{rootRef:t.animate?Ke:void 0,className:Re,style:Ve,dir:t.dir,id:t.id,lang:t.lang,nonce:t.nonce,title:t.title,role:t.role,"aria-label":t["aria-label"],"aria-labelledby":t["aria-labelledby"],...ve},v.createElement(r.Months,{className:c[qt.Months],style:j==null?void 0:j[qt.Months]},!t.hideNavigation&&!f&&v.createElement(r.Nav,{"data-animated-nav":t.animate?"true":void 0,className:c[qt.Nav],style:j==null?void 0:j[qt.Nav],"aria-label":re(),onPreviousClick:Se,onNextClick:ue,previousMonth:H,nextMonth:R}),L.map((ye,He)=>v.createElement(r.Month,{"data-animated-month":t.animate?"true":void 0,className:c[qt.Month],style:j==null?void 0:j[qt.Month],key:He,displayIndex:He,calendarMonth:ye},f==="around"&&!t.hideNavigation&&He===0&&v.createElement(r.PreviousMonthButton,{type:"button",className:c[qt.PreviousMonthButton],tabIndex:H?void 0:-1,"aria-disabled":H?void 0:!0,"aria-label":de(H),onClick:Se,"data-animated-button":t.animate?"true":void 0},v.createElement(r.Chevron,{disabled:H?void 0:!0,className:c[qt.Chevron],orientation:t.dir==="rtl"?"right":"left"})),v.createElement(r.MonthCaption,{"data-animated-caption":t.animate?"true":void 0,className:c[qt.MonthCaption],style:j==null?void 0:j[qt.MonthCaption],calendarMonth:ye,displayIndex:He},u!=null&&u.startsWith("dropdown")?v.createElement(r.DropdownNav,{className:c[qt.Dropdowns],style:j==null?void 0:j[qt.Dropdowns]},(()=>{const Pe=u==="dropdown"||u==="dropdown-months"?v.createElement(r.MonthsDropdown,{key:"month",className:c[qt.MonthsDropdown],"aria-label":J(),classNames:c,components:r,disabled:!!t.disableNavigation,onChange:ke(ye.date),options:UXe(ye.date,O,B,o,i),style:j==null?void 0:j[qt.Dropdown],value:i.getMonth(ye.date)}):v.createElement("span",{key:"month"},T(ye.date,i)),_e=u==="dropdown"||u==="dropdown-years"?v.createElement(r.YearsDropdown,{key:"year",className:c[qt.YearsDropdown],"aria-label":we(i.options),classNames:c,components:r,disabled:!!t.disableNavigation,onChange:De(ye.date),options:GXe(O,B,o,i,!!t.reverseYears),style:j==null?void 0:j[qt.Dropdown],value:i.getYear(ye.date)}):v.createElement("span",{key:"year"},M(ye.date,i));return i.getMonthYearOrder()==="year-first"?[_e,Pe]:[Pe,_e]})(),v.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},I(ye.date,i.options,i))):v.createElement(r.CaptionLabel,{className:c[qt.CaptionLabel],role:"status","aria-live":"polite"},I(ye.date,i.options,i))),f==="around"&&!t.hideNavigation&&He===h-1&&v.createElement(r.NextMonthButton,{type:"button",className:c[qt.NextMonthButton],tabIndex:R?void 0:-1,"aria-disabled":R?void 0:!0,"aria-label":le(R),onClick:ue,"data-animated-button":t.animate?"true":void 0},v.createElement(r.Chevron,{disabled:R?void 0:!0,className:c[qt.Chevron],orientation:t.dir==="rtl"?"left":"right"})),He===h-1&&f==="after"&&!t.hideNavigation&&v.createElement(r.Nav,{"data-animated-nav":t.animate?"true":void 0,className:c[qt.Nav],style:j==null?void 0:j[qt.Nav],"aria-label":re(),onPreviousClick:Se,onNextClick:ue,previousMonth:H,nextMonth:R}),v.createElement(r.MonthGrid,{role:"grid","aria-multiselectable":d==="multiple"||d==="range","aria-label":Q(ye.date,i.options,i)||void 0,className:c[qt.MonthGrid],style:j==null?void 0:j[qt.MonthGrid]},!t.hideWeekdays&&v.createElement(r.Weekdays,{"data-animated-weekdays":t.animate?"true":void 0,className:c[qt.Weekdays],style:j==null?void 0:j[qt.Weekdays]},S&&v.createElement(r.WeekNumberHeader,{"aria-label":fe(i.options),className:c[qt.WeekNumberHeader],style:j==null?void 0:j[qt.WeekNumberHeader],scope:"col"},E()),pe.map(Pe=>v.createElement(r.Weekday,{"aria-label":ce(Pe,i.options,i),className:c[qt.Weekday],key:String(Pe),style:j==null?void 0:j[qt.Weekday],scope:"col"},D(Pe,i.options,i)))),v.createElement(r.Weeks,{"data-animated-weeks":t.animate?"true":void 0,className:c[qt.Weeks],style:j==null?void 0:j[qt.Weeks]},ye.weeks.map(Pe=>v.createElement(r.Week,{className:c[qt.Week],key:Pe.weekNumber,style:j==null?void 0:j[qt.Week],week:Pe},S&&v.createElement(r.WeekNumber,{week:Pe,style:j==null?void 0:j[qt.WeekNumber],"aria-label":oe(Pe.weekNumber,{locale:a}),className:c[qt.WeekNumber],scope:"row",role:"rowheader"},_(Pe.weekNumber,i)),Pe.days.map(_e=>{const{date:ze}=_e,Ee=z(_e);if(Ee[Gr.focused]=!Ee.hidden&&!!(K!=null&&K.isEqualTo(_e)),Ee[Ya.selected]=(F==null?void 0:F(ze))||Ee.selected,q_(q)){const{from:rt,to:wt}=q;Ee[Ya.range_start]=!!(rt&&wt&&i.isSameDay(ze,rt)),Ee[Ya.range_end]=!!(rt&&wt&&i.isSameDay(ze,wt)),Ee[Ya.range_middle]=ou(q,ze,!0,i)}const Be=WXe(Ee,j,t.modifiersStyles),st=RXe(Ee,c,t.modifiersClassNames),lt=!ne&&!Ee.hidden?Z(ze,Ee,i.options,i):void 0;return v.createElement(r.Day,{key:`${_e.isoDate}_${_e.displayMonthId}`,day:_e,modifiers:Ee,className:st.join(" "),style:Be,role:"gridcell","aria-selected":Ee.selected||void 0,"aria-label":lt,"data-day":_e.isoDate,"data-month":_e.outside?_e.dateMonthId:void 0,"data-selected":Ee.selected||void 0,"data-disabled":Ee.disabled||void 0,"data-hidden":Ee.hidden||void 0,"data-outside":_e.outside||void 0,"data-focused":Ee.focused||void 0,"data-today":Ee.today||void 0},!Ee.hidden&&ne?v.createElement(r.DayButton,{className:c[qt.DayButton],style:j==null?void 0:j[qt.DayButton],type:"button",day:_e,modifiers:Ee,disabled:!Ee.focused&&Ee.disabled||void 0,"aria-disabled":Ee.focused&&Ee.disabled||void 0,tabIndex:$(_e)?0:-1,"aria-label":U(ze,Ee,i.options,i),onClick:ie(_e,Ee),onBlur:ae(_e,Ee),onFocus:ee(_e,Ee),onKeyDown:se(_e,Ee),onMouseEnter:he(_e,Ee),onMouseLeave:ge(_e,Ee)},k(ze,i.options,i)):!Ee.hidden&&k(_e.date,i.options,i))})))))))),t.footer&&v.createElement(r.Footer,{className:c[qt.Footer],style:j==null?void 0:j[qt.Footer],role:"status","aria-live":"polite"},t.footer)))}function Z1({className:e,classNames:t,showOutsideDays:n=!0,captionLayout:r="label",buttonVariant:o="ghost",formatters:s,components:i,...a}){const c=L$();return l.jsx(EQe,{showOutsideDays:n,className:p.cn("bg-background group/calendar p-2.5 [--cell-size:1.75rem] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,e),captionLayout:r,formatters:{formatMonthDropdown:u=>u.toLocaleString("default",{month:"short"}),...s},classNames:{root:p.cn("w-fit",c.root),months:p.cn("relative flex flex-col gap-3 md:flex-row",c.months),month:p.cn("flex w-full flex-col gap-3",c.month),nav:p.cn("absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",c.nav),button_previous:p.cn(p.buttonVariants({variant:o}),"h-[--cell-size] w-[--cell-size] select-none p-0 text-muted-foreground hover:text-foreground aria-disabled:opacity-50",c.button_previous),button_next:p.cn(p.buttonVariants({variant:o}),"h-[--cell-size] w-[--cell-size] select-none p-0 text-muted-foreground hover:text-foreground aria-disabled:opacity-50",c.button_next),month_caption:p.cn("flex h-[--cell-size] w-full items-center justify-center px-[--cell-size]",c.month_caption),dropdowns:p.cn("flex h-[--cell-size] w-full items-center justify-center gap-1.5 text-[13px] font-medium",c.dropdowns),dropdown_root:p.cn("has-focus:border-ring border-input has-focus:ring-ring/40 has-focus:ring-[2px] relative rounded-md border",c.dropdown_root),dropdown:p.cn("bg-popover absolute inset-0 opacity-0",c.dropdown),caption_label:p.cn("select-none font-medium text-foreground",r==="label"?"text-[13px]":"[&>svg]:text-muted-foreground flex h-7 items-center gap-1 rounded-md pl-2 pr-1 text-[13px] [&>svg]:size-3",c.caption_label),table:"w-full border-collapse",weekdays:p.cn("flex",c.weekdays),weekday:p.cn("text-muted-foreground flex-1 select-none text-[10px] font-medium uppercase tracking-[0.08em]",c.weekday),week:p.cn("mt-1 flex w-full",c.week),week_number_header:p.cn("w-[--cell-size] select-none",c.week_number_header),week_number:p.cn("text-muted-foreground select-none text-[10px]",c.week_number),day:p.cn("group/day relative aspect-square h-full w-full select-none p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md",c.day),range_start:p.cn("bg-accent rounded-l-md",c.range_start),range_middle:p.cn("rounded-none",c.range_middle),range_end:p.cn("bg-accent rounded-r-md",c.range_end),today:p.cn("rounded-md text-foreground font-medium [&>button]:ring-1 [&>button]:ring-inset [&>button]:ring-border",c.today),outside:p.cn("text-muted-foreground/60 aria-selected:text-muted-foreground/60",c.outside),disabled:p.cn("text-muted-foreground/50",c.disabled),hidden:p.cn("invisible",c.hidden),...t},components:{Root:({className:u,rootRef:d,...f})=>l.jsx("div",{"data-slot":"calendar",ref:d,className:p.cn(u),...f}),Chevron:({className:u,orientation:d,...f})=>d==="left"?l.jsx(Lm,{className:p.cn("size-4",u),...f}):d==="right"?l.jsx(Mt.ChevronRight,{className:p.cn("size-4",u),...f}):l.jsx(Ie.ChevronDown,{className:p.cn("size-4",u),...f}),DayButton:DQe,WeekNumber:({children:u,...d})=>l.jsx("td",{...d,children:l.jsx("div",{className:"flex size-[--cell-size] items-center justify-center text-center",children:u})}),...i},...a})}function DQe({className:e,day:t,modifiers:n,...r}){const o=L$(),s=te.useRef(null);return te.useEffect(()=>{var i;n.focused&&((i=s.current)==null||i.focus())},[n.focused]),l.jsx(p.Button,{ref:s,variant:"ghost",size:"icon","data-day":t.date.toLocaleDateString(),"data-selected-single":n.selected&&!n.range_start&&!n.range_end&&!n.range_middle,"data-range-start":n.range_start,"data-range-end":n.range_end,"data-range-middle":n.range_middle,className:p.cn("data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/40 flex aspect-square h-auto w-full min-w-[--cell-size] flex-col gap-0.5 rounded-md p-0 text-[12px] font-normal leading-none tabular-nums data-[range-end=true]:rounded-r-md data-[range-end=true]:rounded-l-none data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-l-md data-[range-start=true]:rounded-r-none group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[2px] [&>span]:text-[10px] [&>span]:opacity-70",o.day,e),...r})}const MQe={time:"Time",day:"Day",week:"Week",month:"Month",quarter:"Quarter",year:"Year"},cU=(e,t)=>!e||e.mode==="this"&&e.boundary?"day":e.unit==="minute"||e.unit==="hour"?t?"time":"day":e.unit,RQe=["Last 30 minutes","Last 1 hour","Last 4 hours","Last 12 hours","Last 24 hours"],AQe=(e=!1)=>{const t=[{label:"Today",value:n=>{const r=new Date;return{from:p.startOfDayInTimezone(r,n),to:p.endOfDayInTimezone(r,n)}},category:"day"},{label:"Yesterday",value:n=>{const r=new Date,o=p.shiftDateByDaysInTimezone(r,n,-1);return{from:p.startOfDayInTimezone(o,n),to:p.endOfDayInTimezone(o,n)}},category:"day"},{label:"First day of the month",value:n=>{const r=new Date,o=p.startOfMonthInTimezone(r,n);return{from:p.startOfDayInTimezone(o,n),to:p.endOfDayInTimezone(o,n)}},category:"day"},{label:"Last day of the month",value:n=>{const r=new Date,o=p.endOfMonthInTimezone(r,n);return{from:p.startOfDayInTimezone(o,n),to:p.endOfDayInTimezone(o,n)}},category:"day"},{label:"Last 7 days",value:n=>{const r=new Date,o=p.shiftDateByDaysInTimezone(r,n,-6);return{from:p.startOfDayInTimezone(o,n),to:p.endOfDayInTimezone(r,n)}},category:"day"},{label:"Last 30 days",value:n=>{const r=new Date,o=p.shiftDateByDaysInTimezone(r,n,-29);return{from:p.startOfDayInTimezone(o,n),to:p.endOfDayInTimezone(r,n)}},category:"day"},{label:"Last 90 days",value:n=>{const r=new Date,o=p.shiftDateByDaysInTimezone(r,n,-89);return{from:p.startOfDayInTimezone(o,n),to:p.endOfDayInTimezone(r,n)}},category:"day"},{label:"This week",value:n=>{const r=new Date,o=p.startOfWeekInTimezone(r,n),s=p.endOfWeekInTimezone(r,n);return{from:o,to:s}},category:"week"},{label:"Last week",value:n=>{const r=new Date,o=p.shiftDateByWeeksInTimezone(r,n,-1),s=p.startOfWeekInTimezone(o,n),i=p.endOfWeekInTimezone(o,n);return{from:s,to:i}},category:"week"},{label:"Last 2 weeks",value:n=>{const r=new Date,o=p.shiftDateByWeeksInTimezone(r,n,-2),s=p.shiftDateByWeeksInTimezone(r,n,-1);return{from:p.startOfWeekInTimezone(o,n),to:p.endOfWeekInTimezone(s,n)}},category:"week"},{label:"This month",value:n=>{const r=new Date,o=p.startOfMonthInTimezone(r,n),s=p.endOfMonthInTimezone(r,n);return{from:o,to:s}},category:"month"},{label:"Last month",value:n=>{const r=new Date,o=p.shiftDateByMonthsInTimezone(r,n,-1),s=p.startOfMonthInTimezone(o,n),i=p.endOfMonthInTimezone(o,n);return{from:s,to:i}},category:"month"},{label:"Last 3 months",value:n=>{const r=new Date,o=p.shiftDateByMonthsInTimezone(r,n,-3),s=p.shiftDateByMonthsInTimezone(r,n,-1);return{from:p.startOfMonthInTimezone(o,n),to:p.endOfMonthInTimezone(s,n)}},category:"month"},{label:"Last 6 months",value:n=>{const r=new Date,o=p.shiftDateByMonthsInTimezone(r,n,-6),s=p.shiftDateByMonthsInTimezone(r,n,-1);return{from:p.startOfMonthInTimezone(o,n),to:p.endOfMonthInTimezone(s,n)}},category:"month"},{label:"Last 9 months",value:n=>{const r=new Date,o=p.shiftDateByMonthsInTimezone(r,n,-9),s=p.shiftDateByMonthsInTimezone(r,n,-1);return{from:p.startOfMonthInTimezone(o,n),to:p.endOfMonthInTimezone(s,n)}},category:"month"},{label:"Last 12 months",value:n=>{const r=new Date,o=p.shiftDateByMonthsInTimezone(r,n,-12),s=p.shiftDateByMonthsInTimezone(r,n,-1);return{from:p.startOfMonthInTimezone(o,n),to:p.endOfMonthInTimezone(s,n)}},category:"month"},{label:"This quarter",value:n=>{const r=new Date,o=p.startOfQuarterInTimezone(r,n),s=p.endOfQuarterInTimezone(r,n);return{from:o,to:s}},category:"quarter"},{label:"Last quarter",value:n=>{const r=new Date,o=p.shiftDateByQuartersInTimezone(r,n,-1),s=p.startOfQuarterInTimezone(o,n),i=p.endOfQuarterInTimezone(o,n);return{from:s,to:i}},category:"quarter"},{label:"Last 4 quarters",value:n=>{const r=new Date,o=p.shiftDateByQuartersInTimezone(r,n,-4),s=p.shiftDateByQuartersInTimezone(r,n,-1);return{from:p.startOfQuarterInTimezone(o,n),to:p.endOfQuarterInTimezone(s,n)}},category:"quarter"},{label:"This year",value:n=>{const r=new Date,o=p.startOfYearInTimezone(r,n),s=p.endOfYearInTimezone(r,n);return{from:o,to:s}},category:"year"},{label:"Last year",value:n=>{const r=new Date,o=p.shiftDateByYearsInTimezone(r,n,-1),s=p.startOfYearInTimezone(o,n),i=p.endOfYearInTimezone(o,n);return{from:s,to:i}},category:"year"}];return e?[...RQe.map(n=>({label:n,value:()=>{const r=p.presetMetadata[n],o=p.resolveSubDayRelativeDateRange(r);return o?{from:o[0],to:o[1]}:{from:new Date,to:new Date}},category:"time"})),...t]:t},uU=[{label:"2 days ago",value:-2},{label:"Yesterday",value:-1},{label:"Today",value:0},{label:"Tomorrow",value:1},{label:"2 days ahead",value:2}],dU=[{label:"2 years ago",value:-2},{label:"Last year",value:-1},{label:"This year",value:0},{label:"Next year",value:1},{label:"2 years ahead",value:2}],fU=[{label:"2 quarters ago",value:-2},{label:"Last quarter",value:-1},{label:"This quarter",value:0},{label:"Next quarter",value:1},{label:"2 quarters ahead",value:2}],hU=[{label:"9 months ago",value:-9},{label:"6 months ago",value:-6},{label:"3 months ago",value:-3},{label:"2 months ago",value:-2},{label:"Last month",value:-1},{label:"This month",value:0},{label:"Next month",value:1},{label:"2 months ahead",value:2}],mU=[{label:"2 weeks ago",value:-2},{label:"Last week",value:-1},{label:"This week",value:0},{label:"Next week",value:1},{label:"2 weeks ahead",value:2}];function $$({value:e,onChange:t,selectionMode:n="range",singleValue:r,onSingleChange:o,comparisonOptions:s,comparisonValue:i,onComparisonChange:a,comparisonLabel:c="Condition",hideDateInputs:u=!1,onRelativeSelect:d,relativeValue:f,placeholder:h="All time",className:m,timezone:g,showRelativeTab:x=!0,hideCalendar:b=!1,disabled:y=!1,enableTimePrecision:w=!1,temporalPrecision:C,buttonClassName:N,buttonLabelSuffix:S,contentClassName:j,overlayContentClassName:I,targetColumns:k,selectedColumn:T,onColumnChange:_,inline:E=!1,onApplied:D,supplementalFooter:M,onOpenChange:P}){var St,At;const[A,L]=v.useState(!1),[O,B]=v.useState(n==="range"?"presets":"static"),[H,R]=v.useState(()=>cU(f,w)),[V,z]=v.useState(!1),[F,G]=v.useState(!1),[q,Y]=v.useState("Days"),[K,$]=v.useState("0"),[X,W]=v.useState("0"),[U,Z]=v.useState(w&&C==="minute"),[Q,J]=v.useState("00:00"),[re,de]=v.useState("23:59"),[le,ce]=v.useState("00:00"),[oe,fe]=v.useState(E?e:void 0),[we,pe]=v.useState(E?r:void 0),ne=ml("interactive"),Se=ne.controlStyle,ue=ne.contentStyle;v.useEffect(()=>{E&&fe(e)},[E,e]),v.useEffect(()=>{E&&pe(r)},[E,r]);const ie=p.getEffectiveTimezone(g),ee=w&&C==="minute",ae=v.useMemo(()=>AQe(w),[w]),se=v.useMemo(()=>[...w?["time"]:[],"day","week","month","quarter","year"],[w]),he=v.useMemo(()=>ae.filter(Fe=>Fe.category===H),[H,ae]),ge=cU(f,w),ke=x&&n==="range",De=n==="range";v.useEffect(()=>{R(ge)},[ge]),v.useEffect(()=>{const Fe=w&&C==="minute";Z(Fe),Fe?(e!=null&&e.from&&J(p.formatTimeInTimezone(e.from,ie)),e!=null&&e.to&&de(p.formatTimeInTimezone(e.to,ie)),r&&ce(p.formatTimeInTimezone(r,ie))):(J("00:00"),de("23:59"),ce("00:00"))},[ie,w,r,C,e==null?void 0:e.from,e==null?void 0:e.to]),v.useEffect(()=>{if(!De&&O!=="static"){B("static");return}!ke&&O==="relative"&&B("static")},[ke,De,O]);const Re=()=>{if(n==="single")return r?Vt.formatInTimeZone(r,ie,ee?"MMM dd, yyyy HH:mm":"MMM dd, yyyy"):h;if(e!=null&&e.from&&(e!=null&&e.to)){const Fe=Vt.formatInTimeZone(e.from,ie,ee?"MMM dd, yyyy HH:mm":"MMM dd, yyyy"),Je=Vt.formatInTimeZone(e.to,ie,ee?"MMM dd, yyyy HH:mm":"MMM dd, yyyy");return`${Fe} - ${Je}`}return h},Ve=n==="single"?!!r:!!(e!=null&&e.from||e!=null&&e.to),ve=!!(k&&k.length>1&&_),Ke=((St=k==null?void 0:k.find(Fe=>Fe.column===T))==null?void 0:St.label)||((At=k==null?void 0:k[0])==null?void 0:At.label)||"Date",qe=Fe=>{const Je=Fe.value(ie),Ct=p.presetMetadata[Fe.label],dt=w?p.getTemporalPrecisionForRelativeMeta(Ct):void 0,kt=dt?{temporalPrecision:dt}:void 0;t==null||t(Je,kt),ke&&(d==null||d(Je,Ct,kt)),rt(!1)},et=(Fe,Je)=>{var Rt,yt;const Ct=se.indexOf(Je);let dt;if(Fe.key==="ArrowRight"||Fe.key==="ArrowDown"?dt=(Ct+1)%se.length:Fe.key==="ArrowLeft"||Fe.key==="ArrowUp"?dt=(Ct-1+se.length)%se.length:Fe.key==="Home"?dt=0:Fe.key==="End"&&(dt=se.length-1),dt===void 0)return;Fe.preventDefault();const kt=se[dt];R(kt);const Ft=(Rt=Fe.currentTarget.parentElement)==null?void 0:Rt.querySelectorAll('[role="radio"]');(yt=Ft==null?void 0:Ft[dt])==null||yt.focus()},ye=()=>{n==="single"?o==null||o(void 0):t==null||t(void 0),rt(!1)},He=(Fe,Je)=>{if(!Je)return;const Ct=Fe==="from"?Je:oe==null?void 0:oe.from,dt=Fe==="to"?Je:oe==null?void 0:oe.to;fe({from:Ct,to:dt}),Fe==="from"?z(!1):G(!1)},Pe=Fe=>{const Je=Fe===!0;if(Z(Je),!Je){J("00:00"),de("23:59"),ce("00:00");return}oe!=null&&oe.from&&J(p.formatTimeInTimezone(oe.from,ie)),oe!=null&&oe.to&&de(p.formatTimeInTimezone(oe.to,ie)),we&&ce(p.formatTimeInTimezone(we,ie))},_e=()=>{if(oe!=null&&oe.from&&(oe!=null&&oe.to)){if(w&&U){const Ct=p.composeDateTimeInTimezone(oe.from,Q,ie),dt=p.composeDateTimeInTimezone(oe.to,re,ie,{boundary:"end"});if(!Ct||!dt||dt.getTime()<Ct.getTime())return;t==null||t({from:Ct,to:dt},{temporalPrecision:"minute"}),rt(!1);return}const Fe=p.startOfDayInTimezone(oe.from,ie),Je=p.endOfDayInTimezone(oe.to,ie);t==null||t({from:Fe,to:Je}),rt(!1)}},ze=()=>{fe(e)},Ee=()=>{if(we&&w&&U){const Fe=i==="<="?"end":"start",Je=p.composeDateTimeInTimezone(we,le,ie,{boundary:Fe});if(!Je)return;o==null||o(Je,{temporalPrecision:"minute"}),rt(!1);return}o==null||o(we),rt(!1)},Be=()=>{pe(r)},st=()=>{pe(p.startOfDayInTimezone(new Date,ie))},lt=()=>{const Fe=new Date,Je=parseInt(K,10),Ct=parseInt(X,10);let dt,kt;if(q==="Days"){const _t=p.shiftDateByDaysInTimezone(Fe,ie,Je),Lt=p.shiftDateByDaysInTimezone(Fe,ie,Ct);dt=p.startOfDayInTimezone(_t,ie),kt=p.endOfDayInTimezone(Lt,ie)}else if(q==="Weeks"){const _t=p.shiftDateByWeeksInTimezone(Fe,ie,Je),Lt=p.shiftDateByWeeksInTimezone(Fe,ie,Ct);dt=p.startOfWeekInTimezone(_t,ie),kt=p.endOfWeekInTimezone(Lt,ie)}else if(q==="Months"){const _t=p.shiftDateByMonthsInTimezone(Fe,ie,Je),Lt=p.shiftDateByMonthsInTimezone(Fe,ie,Ct);dt=p.startOfMonthInTimezone(_t,ie),kt=p.endOfMonthInTimezone(Lt,ie)}else if(q==="Quarters"){const _t=p.shiftDateByQuartersInTimezone(Fe,ie,Je),Lt=p.shiftDateByQuartersInTimezone(Fe,ie,Ct);dt=p.startOfQuarterInTimezone(_t,ie),kt=p.endOfQuarterInTimezone(Lt,ie)}else{const _t=p.shiftDateByYearsInTimezone(Fe,ie,Je),Lt=p.shiftDateByYearsInTimezone(Fe,ie,Ct);dt=p.startOfYearInTimezone(_t,ie),kt=p.endOfYearInTimezone(Lt,ie)}const Rt={mode:"between",unit:{Days:"day",Weeks:"week",Months:"month",Quarters:"quarter",Years:"year"}[q],from:Je,to:Ct},yt={from:dt,to:kt};t==null||t(yt),d==null||d(yt,Rt),rt(!1)};function rt(Fe){L(Fe),P==null||P(Fe)}const wt=Fe=>{rt(Fe),Fe&&(fe(e),pe(r),Z(w&&C==="minute"))},zt=l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"border-b border-border px-3 py-2",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx("div",{className:"min-w-0 flex-1",children:ve&&k?l.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[l.jsx(Wa,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsxs(p.Select,{value:T,onValueChange:_,children:[l.jsx(p.SelectTrigger,{className:"h-7 max-w-[210px] rounded-control border-border bg-background text-[12px]",style:Se,children:l.jsx(p.SelectValue,{})}),l.jsx(p.SelectContent,{className:p.cn(I??"z-[52]","rounded-control"),style:ue,children:k.map(Fe=>l.jsx(p.SelectItem,{value:Fe.column,children:Fe.label},Fe.column))})]})]}):l.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[l.jsx(Wa,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx("span",{className:"truncate text-[13px] font-medium",children:Ke})]})}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1 text-[11px] text-muted-foreground",title:`Using ${MN(ie)} timezone`,children:[l.jsx(SR,{className:"h-3 w-3"}),l.jsx("span",{children:hn.getTimezoneAbbreviation(ie)})]})]}),(e==null?void 0:e.from)&&(e==null?void 0:e.to)&&l.jsxs("p",{className:"mt-1 pl-[18px] font-mono text-[11px] tabular-nums text-muted-foreground",children:[Vt.formatInTimeZone(e.from,ie,ee?"MMM d, yyyy HH:mm":"MMM d, yyyy")," – ",Vt.formatInTimeZone(e.to,ie,ee?"MMM d, yyyy HH:mm":"MMM d, yyyy")]})]}),l.jsxs(p.Tabs,{value:O,onValueChange:Fe=>{B(Fe),Fe==="static"&&fe(e)},className:"w-full",children:[De&&l.jsx("div",{className:"px-2 pt-2",children:l.jsxs(p.TabsList,{style:Se,className:p.cn("inline-flex h-[30px] w-full items-center gap-0.5 rounded-control border border-border/60 bg-muted/60 p-0.5 text-muted-foreground"),children:[l.jsx(p.TabsTrigger,{value:"presets",className:"h-6 min-w-0 flex-1 rounded-control px-1.5 text-[11px] font-medium text-muted-foreground hover:text-foreground focus-visible:ring-ring/20 focus-visible:ring-offset-0 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm data-[state=active]:ring-1 data-[state=active]:ring-border",children:"Presets"}),l.jsx(p.TabsTrigger,{value:"static",className:"h-6 min-w-0 flex-1 rounded-control px-1.5 text-[11px] font-medium text-muted-foreground hover:text-foreground focus-visible:ring-ring/20 focus-visible:ring-offset-0 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm data-[state=active]:ring-1 data-[state=active]:ring-border",children:"Static"}),ke&&l.jsx(p.TabsTrigger,{value:"relative",className:"h-6 min-w-0 flex-1 rounded-control px-1.5 text-[11px] font-medium text-muted-foreground hover:text-foreground focus-visible:ring-ring/20 focus-visible:ring-offset-0 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm data-[state=active]:ring-1 data-[state=active]:ring-border",children:"Relative"})]})}),De&&l.jsx(p.TabsContent,{value:"presets",className:"mt-0",children:!u&&l.jsxs("div",{children:[l.jsx("div",{className:"border-b border-border px-2 py-1.5",children:l.jsx("div",{role:"radiogroup","aria-label":"Preset interval","aria-orientation":"horizontal",className:"flex items-center gap-0.5 rounded-control border border-border/60 bg-muted/60 p-0.5",children:se.map(Fe=>{const Je=Fe===H;return l.jsx("button",{type:"button",role:"radio","aria-checked":Je,tabIndex:Je?0:-1,onClick:()=>R(Fe),onKeyDown:Ct=>et(Ct,Fe),className:p.cn("h-6 min-w-0 flex-1 rounded-control px-1.5 text-[11px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/20",Je?"bg-background text-foreground shadow-sm ring-1 ring-border":"text-muted-foreground hover:text-foreground"),children:MQe[Fe]},Fe)})})}),l.jsx("div",{className:"space-y-0.5 p-2",children:he.map(Fe=>l.jsx("button",{type:"button",onClick:()=>{qe(Fe),E&&(D==null||D())},className:"w-full rounded-control px-2 py-1.5 text-left text-[13px] text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/30",children:Fe.label},Fe.label))})]})}),l.jsx(p.TabsContent,{value:"static",className:"mt-0",children:l.jsxs("div",{className:"space-y-2 p-2",children:[s&&s.length>0&&i&&l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:c}),l.jsxs(p.Select,{value:i,onValueChange:Fe=>a==null?void 0:a(Fe),children:[l.jsx(p.SelectTrigger,{className:"h-7 rounded-control border-border bg-background text-[12px]",style:Se,children:l.jsx(p.SelectValue,{})}),l.jsx(p.SelectContent,{className:p.cn(I??"z-[52]","rounded-control"),style:ue,children:s.map(Fe=>l.jsx(p.SelectItem,{value:Fe.value,children:Fe.label},Fe.value))})]})]}),!b&&!u&&(n==="single"?l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date"}),l.jsxs("div",{className:"flex items-center gap-2.5",children:[w&&l.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[l.jsx(An,{checked:U,onCheckedChange:Pe,className:"h-3.5 w-3.5"}),l.jsx("span",{children:"Include time"})]}),l.jsx("button",{type:"button",onClick:st,className:"rounded-control px-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:"Today"})]})]}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:"relative flex-1",children:l.jsxs(p.Popover,{open:V,onOpenChange:z,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs(p.Button,{variant:"outline",size:"xs",className:"h-7 w-full justify-start rounded-control border-border bg-background text-left text-[12px] font-normal",style:Se,children:[l.jsx(Wa,{className:"mr-1.5 h-3 w-3"}),we?Vt.formatInTimeZone(we,ie,"MM/dd/yyyy"):"Select date"]})}),l.jsx(p.PopoverContent,{style:ue,className:p.cn(I??"z-[52]","w-auto rounded-control p-0"),align:"start",children:l.jsx(Z1,{mode:"single",selected:we,defaultMonth:we,captionLayout:"dropdown",onSelect:Fe=>{pe(Fe),z(!1)},className:"p-2 [--cell-size:1.75rem]",classNames:{weekday:"text-muted-foreground flex-1 select-none text-[10px] font-medium uppercase tracking-[0.08em]",caption_label:"!inline-flex !flex-row !items-center !gap-1 select-none rounded-control !px-1.5 !h-7 text-[12px] font-medium whitespace-nowrap [&>svg]:!size-3 [&>svg]:text-muted-foreground",dropdown_root:"!inline-flex !flex-row !items-center has-focus:border-ring border-input has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-control border min-w-[3.5rem]",dropdowns:"flex h-[--cell-size] w-full items-center justify-center gap-1 text-[12px] font-medium",day:"group/day relative aspect-square h-full w-full select-none p-0 text-center [&_button]:!text-[11px] [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md"}})})]})}),U&&w&&l.jsx(p.Input,{size:"xs",value:le,onChange:Fe=>ce(Fe.target.value),placeholder:"HH:mm","aria-invalid":!p.isValidTimeInput(le),title:"Use 24-hour HH:mm time",className:"w-20 shrink-0 font-mono tabular-nums"})]})]}):l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Custom range"}),w&&l.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[l.jsx(An,{checked:U,onCheckedChange:Pe,className:"h-3.5 w-3.5"}),l.jsx("span",{children:"Include time"})]})]}),l.jsxs("div",{className:p.cn(U&&w?"space-y-1.5":"flex items-center gap-1.5"),children:[l.jsxs("div",{className:"flex flex-1 items-center gap-1.5",children:[l.jsx("div",{className:"relative flex-1",children:l.jsxs(p.Popover,{open:V,onOpenChange:z,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs(p.Button,{variant:"outline",size:"xs",className:"h-7 w-full justify-start rounded-control border-border bg-background text-left text-[12px] font-normal",style:Se,children:[l.jsx(Wa,{className:"mr-1.5 h-3 w-3"}),oe!=null&&oe.from?Vt.formatInTimeZone(oe.from,ie,"MM/dd/yyyy"):"From date"]})}),l.jsx(p.PopoverContent,{style:ue,className:p.cn(I??"z-[52]","w-auto rounded-control p-0"),align:"start",children:l.jsx(Z1,{mode:"single",selected:oe==null?void 0:oe.from,defaultMonth:oe==null?void 0:oe.from,captionLayout:"dropdown",onSelect:Fe=>He("from",Fe),className:"p-2 [--cell-size:1.75rem]",classNames:{weekday:"text-muted-foreground flex-1 select-none text-[10px] font-medium uppercase tracking-[0.08em]",caption_label:"!inline-flex !flex-row !items-center !gap-1 select-none rounded-control !px-1.5 !h-7 text-[12px] font-medium whitespace-nowrap [&>svg]:!size-3 [&>svg]:text-muted-foreground",dropdown_root:"!inline-flex !flex-row !items-center has-focus:border-ring border-input has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-control border min-w-[3.5rem]",dropdowns:"flex h-[--cell-size] w-full items-center justify-center gap-1 text-[12px] font-medium",day:"group/day relative aspect-square h-full w-full select-none p-0 text-center [&_button]:!text-[11px] [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md"}})})]})}),U&&w&&l.jsx(p.Input,{size:"xs",value:Q,onChange:Fe=>J(Fe.target.value),placeholder:"HH:mm","aria-invalid":!p.isValidTimeInput(Q),title:"Start time in 24-hour HH:mm",className:"w-20 shrink-0 font-mono tabular-nums"})]}),l.jsx("span",{className:p.cn("text-[12px] text-muted-foreground",U&&w&&"block text-center"),children:"–"}),l.jsxs("div",{className:"flex flex-1 items-center gap-1.5",children:[l.jsx("div",{className:"relative flex-1",children:l.jsxs(p.Popover,{open:F,onOpenChange:G,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs(p.Button,{variant:"outline",size:"xs",className:"h-7 w-full justify-start rounded-control border-border bg-background text-left text-[12px] font-normal",style:Se,children:[l.jsx(Wa,{className:"mr-1.5 h-3 w-3"}),oe!=null&&oe.to?Vt.formatInTimeZone(oe.to,ie,"MM/dd/yyyy"):"To date"]})}),l.jsx(p.PopoverContent,{style:ue,className:p.cn(I??"z-[52]","w-auto rounded-control p-0"),align:"start",children:l.jsx(Z1,{mode:"single",selected:oe==null?void 0:oe.to,defaultMonth:oe==null?void 0:oe.to,captionLayout:"dropdown",onSelect:Fe=>He("to",Fe),className:"p-2 [--cell-size:1.75rem]",classNames:{weekday:"text-muted-foreground flex-1 select-none text-[10px] font-medium uppercase tracking-[0.08em]",caption_label:"!inline-flex !flex-row !items-center !gap-1 select-none rounded-control !px-1.5 !h-7 text-[12px] font-medium whitespace-nowrap [&>svg]:!size-3 [&>svg]:text-muted-foreground",dropdown_root:"!inline-flex !flex-row !items-center has-focus:border-ring border-input has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-control border min-w-[3.5rem]",dropdowns:"flex h-[--cell-size] w-full items-center justify-center gap-1 text-[12px] font-medium",day:"group/day relative aspect-square h-full w-full select-none p-0 text-center [&_button]:!text-[11px] [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md"}})})]})}),U&&w&&l.jsx(p.Input,{size:"xs",value:re,onChange:Fe=>de(Fe.target.value),placeholder:"HH:mm","aria-invalid":!p.isValidTimeInput(re),title:"End time in 24-hour HH:mm",className:"w-20 shrink-0 font-mono tabular-nums"})]})]})]}))]})}),ke&&l.jsx(p.TabsContent,{value:"relative",className:"mt-0",children:l.jsxs("div",{className:"space-y-2 p-2",children:[l.jsx("div",{className:"inline-flex w-full items-center gap-0.5 rounded-control border border-border bg-background p-0.5",style:Se,children:["Days","Weeks","Months","Quarters","Years"].map(Fe=>l.jsx("button",{onClick:()=>Y(Fe),className:p.cn("flex-1 rounded-control px-2 py-1 text-[11px] font-medium transition-colors",q===Fe?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:Fe},Fe))}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:"flex-1",children:l.jsxs(p.Select,{value:K,onValueChange:$,children:[l.jsx(p.SelectTrigger,{className:"h-7 rounded-control border-border bg-background text-[12px]",style:Se,children:l.jsx(p.SelectValue,{placeholder:"From"})}),l.jsx(p.SelectContent,{className:p.cn(I??"z-[51]","rounded-control"),style:ue,children:(q==="Years"?dU:q==="Quarters"?fU:q==="Months"?hU:q==="Weeks"?mU:uU).map(Je=>l.jsx(p.SelectItem,{value:Je.value.toString(),children:Je.label},Je.value))})]})}),l.jsx("span",{className:"text-[12px] text-muted-foreground",children:"to"}),l.jsx("div",{className:"flex-1",children:l.jsxs(p.Select,{value:X,onValueChange:W,children:[l.jsx(p.SelectTrigger,{className:"h-7 rounded-control border-border bg-background text-[12px]",style:Se,children:l.jsx(p.SelectValue,{placeholder:"To"})}),l.jsx(p.SelectContent,{className:p.cn(I??"z-[51]","rounded-control"),style:ue,children:(q==="Years"?dU:q==="Quarters"?fU:q==="Months"?hU:q==="Weeks"?mU:uU).map(Je=>l.jsx(p.SelectItem,{value:Je.value.toString(),children:Je.label},Je.value))})]})})]})]})})]}),M,(()=>{const Fe=O==="static"&&n==="single",Je=O==="static"&&n==="range",Ct=O==="relative",dt=Fe&&!!we||Je&&!!(oe!=null&&oe.from)&&!!(oe!=null&&oe.to),kt=dt||Ct,Ft=dt,Rt=w&&U,yt=Rt&&(oe!=null&&oe.from)?p.composeDateTimeInTimezone(oe.from,Q,ie):null,_t=Rt&&(oe!=null&&oe.to)?p.composeDateTimeInTimezone(oe.to,re,ie,{boundary:"end"}):null,Lt=Je&&Rt&&(!p.isValidTimeInput(Q)||!p.isValidTimeInput(re)||!yt||!_t||_t.getTime()<yt.getTime()),ln=Fe&&Rt&&!p.isValidTimeInput(le);if(!Ve&&!kt)return null;const Ye=()=>{Fe?Ee():Je?_e():Ct&&lt(),E&&(D==null||D())},Ae=()=>{Fe?Be():Je&&ze()},Me=Fe&&!we||Je&&(!(oe!=null&&oe.from)||!(oe!=null&&oe.to))||Lt||ln;return l.jsxs("div",{className:"flex items-center justify-between gap-2 border-t border-border px-3 py-2",children:[Ve?l.jsx(p.Button,{type:"button",variant:"ghost",size:"xs",onClick:()=>{ye(),E&&(D==null||D())},children:"Clear"}):l.jsx("span",{}),l.jsxs("div",{className:"flex items-center gap-1",children:[Ft&&l.jsx(p.Button,{type:"button",variant:"ghost",size:"xs",onClick:Ae,children:"Cancel"}),kt&&l.jsx(p.Button,{type:"button",variant:"default",size:"xs",onClick:Ye,disabled:Me,children:"Apply"})]})]})})()]});return E?l.jsx("div",{className:p.cn("w-full overflow-hidden bg-popover text-popover-foreground",m),style:ue,children:zt}):l.jsx("div",{className:p.cn("w-full",m),children:l.jsxs(p.Popover,{open:A,onOpenChange:wt,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs(p.Button,{variant:"outline",className:p.cn("h-8 min-w-0 w-full justify-between gap-2 rounded-control border-border bg-background text-left text-[13px] font-normal text-foreground transition-colors hover:border-border/80 hover:bg-background",N),style:Se,title:`Timezone: ${MN(ie)} (${hn.getTimezoneAbbreviation(ie)})`,disabled:y,children:[l.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px]",children:S?`${Re()} · ${S}`:Re()}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[l.jsx(SR,{className:"h-3 w-3 opacity-50"}),l.jsx(Ie.ChevronDown,{className:"h-3 w-3 opacity-50"})]})]})}),l.jsx(p.PopoverContent,{style:ue,className:p.cn(j??"z-[51]","w-[320px] overflow-hidden rounded-control border border-border/80 bg-popover p-0 text-popover-foreground shadow-[0_20px_50px_-24px_rgba(15,23,42,0.35)] dark:shadow-[0_20px_50px_-24px_rgba(0,0,0,0.6)]"),align:"start",children:zt})]})})}function due(e,t){var o,s;const n=(o=t==null?void 0:t.find(i=>i.filterId===e.id))==null?void 0:o.name,r=new Set([e.column,...((s=e.targetColumns)==null?void 0:s.map(i=>i.column))??[]]);return n&&r.has(n)?n:e.column}function PQe(e,t){const n=v.useMemo(()=>{const h={column:e.column,label:e.title};return e.targetColumns&&e.targetColumns.length>0?[h,...e.targetColumns]:[h]},[e.targetColumns,e.column,e.title]),r=(t==null?void 0:t.storageTarget)==="card",o=p.useDashboardStore(h=>h.filterValues),s=r?t==null?void 0:t.inlineFilterValues:o,i=s==null?void 0:s.find(h=>h.filterId===e.id),a=!!i,c=v.useMemo(()=>due(e,s),[e,s]),[u,d]=v.useState(c);v.useEffect(()=>{const h=n.some(m=>m.column===u);(i!=null&&i.name&&c!==u||!h)&&d(c)},[c,i==null?void 0:i.name,n]);const f=v.useMemo(()=>u&&u!==e.column?{...e,column:u}:e,[e,u]);return{selectedColumn:u,setSelectedColumn:d,effectiveFilter:f,targetColumns:n,hasActiveFilter:a,storedFilterValue:i}}const FQe=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],OQe=["January","February","March","April","May","June","July","August","September","October","November","December"];function fue({value:e,onChange:t,onClear:n,placeholder:r="Select month",className:o,buttonClassName:s}){const[i,a]=v.useState(!1),[c,u]=v.useState((e==null?void 0:e.year)??new Date().getFullYear()),[d,f]=v.useState(e);v.useEffect(()=>{e?(f(e),u(e.year)):(f(void 0),u(new Date().getFullYear()))},[e]);const h=b=>{u(y=>y+b)},m=b=>{f({year:c,month:b}),t==null||t(c,b),a(!1)},g=()=>{f(void 0),n==null||n(),a(!1)},x=d?`${OQe[d.month]} ${d.year}`:r;return l.jsxs(p.Popover,{open:i,onOpenChange:a,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsx(p.Button,{variant:"outline",role:"combobox","aria-expanded":i,className:p.cn("min-w-0 w-full justify-between gap-2 px-3 text-sm font-normal",s??"h-9",!d&&"text-muted-foreground",o),children:l.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[l.jsx(N0,{className:"h-4 w-4 shrink-0 opacity-50"}),l.jsx("span",{className:"truncate",children:x})]})})}),l.jsx(p.PopoverContent,{className:"z-[52] w-80 p-0",align:"start",children:l.jsxs("div",{className:"p-3",children:[l.jsxs("div",{className:"mb-3 flex items-center justify-between border-b pb-3",children:[l.jsx(p.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>h(-1),"aria-label":"Previous year",children:l.jsx(Lm,{className:"h-4 w-4"})}),l.jsx("h2",{className:"text-sm font-semibold",children:c}),l.jsx(p.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>h(1),"aria-label":"Next year",children:l.jsx(Mt.ChevronRight,{className:"h-4 w-4"})})]}),l.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:FQe.map((b,y)=>{const w=(d==null?void 0:d.month)===y&&(d==null?void 0:d.year)===c;return l.jsx(p.Button,{variant:w?"outline":"ghost",className:p.cn("h-9 text-sm font-medium",!w&&"hover:bg-muted",w&&"border-foreground"),onClick:()=>m(y),children:b},b)})}),d&&l.jsx("div",{className:"mt-3 border-t pt-3",children:l.jsx(p.Button,{variant:"ghost",onClick:g,className:"h-9 w-full justify-center text-sm",children:"Clear selection"})})]})})]})}const hue=[{label:"Today",meta:{mode:"this",unit:"day"}},{label:"Yesterday",meta:{mode:"previous",unit:"day"}}];function mue(e,t){return!(!e||e.mode!==t.mode||e.unit!==t.unit||e.mode==="this"&&(e.boundary||e.toDate))}function pU({value:e,relativeValue:t,timezone:n,onSelect:r,onPresetSelect:o,onClear:s,onApplied:i,showPresets:a=!0}){const c=e?Vt.toZonedTime(e,n):void 0;return l.jsxs("div",{children:[a&&l.jsx("div",{className:"flex items-center gap-1 border-b border-border p-1.5",children:hue.map(u=>{const d=mue(t,u.meta);return l.jsx(p.Button,{variant:d?"outline":"ghost",size:"xs",className:p.cn("h-7 flex-1 text-[12px] font-normal",d&&"border-foreground"),onClick:()=>{o==null||o(u.meta),i==null||i()},children:u.label},u.label)})}),l.jsx(Z1,{mode:"single",selected:c,defaultMonth:c,captionLayout:"dropdown",onSelect:u=>{u&&(r==null||r(Vt.format(u,"yyyy-MM-dd")),i==null||i())},className:"mx-auto w-fit p-2 [--cell-size:1.75rem]",classNames:{weekday:"text-muted-foreground flex-1 select-none text-[10px] font-medium uppercase tracking-[0.08em]",caption_label:"!inline-flex !flex-row !items-center !gap-1 select-none rounded-control !px-1.5 !h-7 text-[12px] font-medium whitespace-nowrap [&>svg]:!size-3 [&>svg]:text-muted-foreground",dropdown_root:"!inline-flex !flex-row !items-center has-focus:border-ring border-input has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-control border min-w-[3.5rem]",dropdowns:"flex h-[--cell-size] w-full items-center justify-center gap-1 text-[12px] font-medium",day:"group/day relative aspect-square h-full w-full select-none p-0 text-center [&_button]:!text-[11px] [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md"}}),(e||t)&&s&&l.jsx("div",{className:"border-t border-border p-1.5",children:l.jsx(p.Button,{variant:"ghost",size:"xs",className:"h-7 w-full justify-center text-[12px]",onClick:()=>{s(),i==null||i()},children:"Clear selection"})})]})}function pue({value:e,relativeValue:t,timezone:n,onSelect:r,onPresetSelect:o,onClear:s,placeholder:i="Select date",className:a,buttonClassName:c,inline:u=!1,onApplied:d,showPresets:f=!0}){var w;const[h,m]=v.useState(!1),g=(w=hue.find(C=>mue(t,C.meta)))==null?void 0:w.label,x=g||(e?Vt.formatInTimeZone(e,n,"MMM d, yyyy"):i),b=!!(g||e);if(u)return l.jsx(pU,{value:e,relativeValue:t,timezone:n,onSelect:r,onPresetSelect:o,onClear:s,onApplied:d,showPresets:f});const y=C=>{C(),m(!1)};return l.jsxs(p.Popover,{open:h,onOpenChange:m,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsx(p.Button,{variant:"outline",role:"combobox","aria-expanded":h,className:p.cn("min-w-0 w-full justify-between gap-2 px-3 text-sm font-normal",c??"h-9",!b&&"text-muted-foreground",a),children:l.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[l.jsx(N0,{className:"h-4 w-4 shrink-0 opacity-50"}),l.jsx("span",{className:"truncate",children:x})]})})}),l.jsx(p.PopoverContent,{className:"z-[52] w-auto p-0",align:"start",children:l.jsx(pU,{value:e,relativeValue:t,timezone:n,onSelect:C=>y(()=>r==null?void 0:r(C)),onPresetSelect:C=>y(()=>o==null?void 0:o(C)),onClear:s?()=>y(s):void 0,showPresets:f})})]})}const X1=[{value:"between",label:"Is between"},{value:"<",label:"Is before"},{value:">",label:"Is after"},{value:"<=",label:"Is on or before"},{value:">=",label:"Is on or after"},{value:"=",label:"Is exactly"}],LQe=new Set(X1.map(e=>e.value)),$Qe=new Set(["between","not between","=","!=",">",">=","<","<="]),zQe={"not between":"Is not between","!=":"Is not exactly"},kM=e=>typeof e=="string"&&$Qe.has(e);function gue({filter:e,className:t,isCardStorage:n,timezone:r,selectedColumn:o,setSelectedColumn:s,targetColumns:i,hasActiveFilter:a,enableTimePrecision:c,storedFilterValue:u,activeFilterValue:d,dateRange:f,isLoading:h,isFetching:m,isError:g,hasData:x,setDateRange:b,handleChange:y,handleRelativeChange:w,handleClear:C,inline:N=!1,onApplied:S,supplementalFooter:j}){const I=n?"h-8":"h-9",k=n?"h-[31px]":"h-[35px]",T=e.dateSelectionMode==="months"||e.dateSelectionMode==="day"?e.dateSelectionMode:"range",_=a?f:void 0,E=kM(e.operation)?e.operation:"between",[D,M]=v.useState(o),[P,A]=v.useState(E);v.useEffect(()=>{if(d&&kM(d.operation)){A(d.operation);return}A(E)},[d,E]);const L=v.useMemo(()=>{if(LQe.has(P))return X1;const U=zQe[P];return U?[...X1,{value:P,label:U}]:X1},[P]);if(v.useEffect(()=>{if(o!==void 0&&s&&o!==D){if(M(o),!a)return;const U=kM(u==null?void 0:u.operation)?u.operation:P,Z=(u==null?void 0:u.temporalPrecision)==="minute"?{temporalPrecision:"minute"}:void 0,Q=u==null?void 0:u.relativeMeta;if(Q&&U==="between"&&f){w(f,Q,Z);return}if(U==="between"||U==="not between"){f&&y(f,U,Z);return}const J=(f==null?void 0:f.from)||(f==null?void 0:f.to);J&&y({from:J,to:J},U,Z)}},[o,D,f,y,w,s,u,a,P]),v.useEffect(()=>{if(T!=="day"||!a||!d)return;const U=d.values,Z=oe=>{if(!oe)return;const fe=oe instanceof Date?oe:new Date(oe);return Number.isNaN(fe.getTime())?void 0:fe},Q=Z(U==null?void 0:U[0]);if(!Q)return;const J=Z(U==null?void 0:U[1]),re=Vt.formatInTimeZone(Q,r,"yyyy-MM-dd");if(d.operation==="between"&&!!J&&Vt.formatInTimeZone(J,r,"yyyy-MM-dd")===re)return;const[le,ce]=p.resolveCalendarDayRange(re,r);y({from:le,to:ce},"between")},[d,T,y,a,r]),!N&&(h||m))return l.jsx("div",{children:l.jsx(ei,{className:p.cn(k,"w-full bg-foreground/10")})});if(g)return l.jsx(M$,{isCardStorage:n});if(!N&&!x)return l.jsx(p.Label,{className:p.cn("flex w-full items-center bg-muted px-2",I),children:"No Data"});const O=P==="between"||P==="not between",B=(c||p.getFilterTemporalCapability(e)==="datetime")&&p.supportsMinutePrecisionForOperation(P),H=d,R=B&&(H==null?void 0:H.temporalPrecision)==="minute"?"minute":B?p.getTemporalPrecisionForRelativeMeta(H==null?void 0:H.relativeMeta):void 0,V=e.showLabel===!1?e.title||e.column:void 0,z=U=>{if(!U)return;const Z=U instanceof Date?U:new Date(U);return isNaN(Z.getTime())?void 0:Z},F=()=>{const U=d==null?void 0:d.operation,Z=d==null?void 0:d.values;if(!U||!Array.isArray(Z)||Z.length<2||U!=="between"&&U!=="not between")return;const Q=z(Z[0]),J=z(Z[1]);if(!(!Q&&!J))return{from:Q,to:J}},G=()=>{const U=d==null?void 0:d.operation,Z=d==null?void 0:d.values;if(!(!U||!Array.isArray(Z)||Z.length<1||!["=","!=",">",">=","<","<="].includes(U)))return z(Z[0])},q=U=>{const Z=F();if(Z){if(U==="<"||U==="<=")return Z.to||Z.from;if(U===">"||U===">="||U==="=")return Z.from||Z.to}return G()},Y=(U,Z,Q={})=>Q.temporalPrecision==="minute"?U:Z==="<="||Z===">"?p.endOfDayInTimezone(U,r):p.startOfDayInTimezone(U,r),K=(U,Z)=>{if(!U){C();return}y(U,O?P:"between",Z)},$=(U,Z)=>{if(!U){C();return}const Q=Y(U,P,Z);b({from:Q,to:Q}),y({from:Q,to:Q},P,Z)},X=U=>{if(A(U),!a||!d)return;if(U==="between"||U==="not between"){const Q=F();if(Q!=null&&Q.from||Q!=null&&Q.to){y({from:Q.from,to:Q.to},U,R?{temporalPrecision:R}:{});return}const J=G();if(J){const re={from:p.startOfDayInTimezone(J,r),to:p.endOfDayInTimezone(J,r)};y(re,U)}return}const Z=q(U);if(Z){const Q=R&&p.supportsMinutePrecisionForOperation(U)?{temporalPrecision:R}:{},J=Y(Z,U,Q);b({from:J,to:J}),y({from:J,to:J},U,Q);return}},W=(U,Z,Q)=>{w(U,Z,Q)};if(T==="day"){const U=Q=>{const[J,re]=p.resolveCalendarDayRange(Q,r);b({from:J,to:re}),y({from:J,to:re},"between")},Z=Q=>{const[J,re]=p.resolveRelativeDateForDefaults(Q,r);w({from:J,to:re},Q)};return l.jsx(pue,{className:t,buttonClassName:I,timezone:r,value:_==null?void 0:_.from,relativeValue:a?H==null?void 0:H.relativeMeta:void 0,placeholder:V||"Select date",inline:N,onApplied:S,onClear:C,onSelect:U,onPresetSelect:Z})}if(T==="months"){const U=_!=null&&_.from?(()=>{const J=Vt.toZonedTime(_.from,r);return{year:yye(J),month:xye(J)}})():void 0,Z=J=>`${J}`.padStart(2,"0"),Q=(J,re)=>{const de=`${J}-${Z(re+1)}-01T00:00:00`,le=re===11?J+1:J,ce=(re+1)%12,oe=`${le}-${Z(ce+1)}-01T00:00:00`;return{from:X2.fromZonedTime(de,r),to:X2.fromZonedTime(oe,r)}};return l.jsx(fue,{className:t,buttonClassName:I,value:U,placeholder:V||"All months",onClear:C,onChange:(J,re)=>{const{from:de,to:le}=Q(J,re);y({from:de,to:le})}})}return l.jsx($$,{value:O?_:void 0,singleValue:O||_==null?void 0:_.from,selectionMode:O?"range":"single",buttonClassName:I,onChange:K,onSingleChange:$,onRelativeSelect:W,relativeValue:H==null?void 0:H.relativeMeta,comparisonOptions:L,comparisonValue:P,onComparisonChange:X,comparisonLabel:"Condition",timezone:r,enableTimePrecision:B,temporalPrecision:R,showRelativeTab:P==="between",className:t,placeholder:V||(O?"All time":"Select date"),targetColumns:i&&i.length>1?i:void 0,selectedColumn:o,onColumnChange:s,inline:N,onApplied:S,supplementalFooter:j})}function BQe({filter:e,className:t,storageOptions:n,inline:r,onApplied:o,supplementalFooter:s}){const i=bl(),{selectedColumn:a,setSelectedColumn:c,effectiveFilter:u,targetColumns:d,hasActiveFilter:f,storedFilterValue:h}=PQe(e,n),{records:m,dateRange:g,isLoading:x,isFetching:b,isError:y,setDateRange:w,activeFilterValue:C,handleChange:N,handleRelativeChange:S,handleClear:j}=R$(u,n);return l.jsx(gue,{filter:u,className:t,isCardStorage:(n==null?void 0:n.storageTarget)==="card",timezone:i,selectedColumn:a,setSelectedColumn:c,targetColumns:d,hasActiveFilter:f,storedFilterValue:h,activeFilterValue:C,dateRange:g,isLoading:x,isFetching:b,isError:y,hasData:!!m,setDateRange:w,handleChange:N,handleRelativeChange:S,handleClear:j,inline:r,onApplied:o,supplementalFooter:s})}function VQe({filter:e,className:t,storageOptions:n,managedState:r,inline:o,onApplied:s,supplementalFooter:i}){const a=bl();return l.jsx(gue,{filter:e,className:t,isCardStorage:(n==null?void 0:n.storageTarget)==="card",timezone:a,hasActiveFilter:r.hasActiveFilter??!!r.activeFilterValue,enableTimePrecision:r.enableTimePrecision,storedFilterValue:r.storedFilterValue??r.activeFilterValue,activeFilterValue:r.activeFilterValue,dateRange:r.dateRange,isLoading:r.isLoading??!1,isFetching:r.isFetching??!1,isError:r.isError??!1,hasData:r.hasData??!0,setDateRange:r.setDateRange??(()=>{}),handleChange:r.handleChange,handleRelativeChange:r.handleRelativeChange,handleClear:r.handleClear,inline:o,onApplied:s,supplementalFooter:i})}function z$(e){return"managedState"in e?l.jsx(VQe,{...e}):l.jsx(BQe,{...e})}function gU({filter:e,storageOptions:t}){return p.isDateDataType(e.dataType)?l.jsx(z$,{filter:e,storageOptions:t}):e.uiType==="radio"&&e.type==="single"?l.jsx($ce,{filter:e,storageOptions:t}):e.uiType==="tabs"&&e.type==="single"?l.jsx(zce,{filter:e,storageOptions:t}):l.jsx(Oce,{filter:e,storageOptions:t})}function HQe({filter:e,CustomFilterComponent:t,theme:n,storageOptions:r}){var N;const{filteredRecords:o,selectedRecords:s,handleChange:i,handleClear:a,handleSelectAll:c,query:u,setQuery:d,isLoading:f,isFetching:h,isError:m,isSearching:g,isSingleSelect:x,allSelected:b,activeFilterValue:y}=Xb(e,{enableServerSearch:!0,...r}),w={filter:e,options:o||[],selectedValues:s||[],onChange:i,onClear:a,onSelectAll:c,searchQuery:u,onSearchChange:d,isLoading:f,isFetching:h,isError:m,isSearching:g,isSingleSelect:x,allSelected:b,activeFilterValue:y,theme:n,settings:(N=e.customFilterPreferences)==null?void 0:N.settings},C=(r==null?void 0:r.storageTarget)==="card"?"h-[31px]":"h-[35px]";return l.jsx(v.Suspense,{fallback:l.jsx(ei,{className:`${C} w-full bg-foreground/10`}),children:l.jsx(t,{...w})})}function qQe({filter:e,CustomFilterComponent:t,theme:n,storageOptions:r}){var b;const{dateRange:o,initialDateRange:s,handleChange:i,handleRelativeChange:a,handleClear:c,handleReset:u,isLoading:d,isFetching:f,isError:h,activeFilterValue:m}=R$(e,r),g={filter:e,dateRange:o,initialDateRange:s,onDateChange:i,onRelativeDateChange:a,onClear:c,onReset:u,isLoading:d,isFetching:f,isError:h,activeFilterValue:m,theme:n,settings:(b=e.customFilterPreferences)==null?void 0:b.settings},x=(r==null?void 0:r.storageTarget)==="card"?"h-[31px]":"h-[35px]";return l.jsx(v.Suspense,{fallback:l.jsx(ei,{className:`${x} w-full bg-foreground/10`}),children:l.jsx(t,{...g})})}function UQe({filter:e,storageOptions:t}){var h,m,g;const{compiledAppearance:n}=oi.useAppearance(),r=(t==null?void 0:t.storageTarget)==="card"?"h-[31px]":"h-[35px]",o=v.useMemo(()=>Vw(n),[n]),{getFilter:s,isLoading:i,isError:a}=_f(((h=e.customFilterPreferences)==null?void 0:h.url)||""),c=(m=e.customFilterPreferences)==null?void 0:m.componentName,u=c?s(c):null;if(!c||!((g=e.customFilterPreferences)!=null&&g.url)||a||!i&&!u)return l.jsx(gU,{filter:e,storageOptions:t});if(i||!u)return l.jsx(ei,{className:`${r} w-full bg-foreground/10`});const f=p.isDateDataType(e.dataType);return l.jsx(_i,{fallback:l.jsx(gU,{filter:e,storageOptions:t}),onError:x=>console.error("Custom filter runtime error:",x),children:f?l.jsx(qQe,{filter:e,CustomFilterComponent:u,theme:o,storageOptions:t}):l.jsx(HQe,{filter:e,CustomFilterComponent:u,theme:o,storageOptions:t})})}const WQe=v.memo(UQe);function bue({selection:e,controlLabel:t,onChange:n}){const r=v.useId(),o=e.mode==="period"?e.spec:void 0,s=(o==null?void 0:o.kind)==="previous_year"?o.offsetYears||1:(o==null?void 0:o.kind)==="previous_period"&&o.offsetPeriods||1,i=(o==null?void 0:o.kind)||"off",a=`${r}-comparison`,c=d=>{o&&n({mode:"period",spec:{...o,...d}})},u=d=>{if(d==="off"){n({mode:"off"});return}n({mode:"period",spec:d==="previous_year"?{kind:"previous_year",toDate:!0}:{kind:"previous_period",toDate:!0}})};return l.jsxs("div",{className:"space-y-2",children:[l.jsx("div",{role:"radiogroup","aria-label":`${t} comparison`,className:"grid grid-cols-3 gap-0.5 rounded-control border border-border/60 bg-muted/60 p-0.5",children:[["off","Off"],["previous_period","Previous period"],["previous_year","Previous year"]].map(([d,f])=>{const h=i===d;return l.jsxs("label",{className:"cursor-pointer",children:[l.jsx("input",{type:"radio",name:a,value:d,checked:h,onChange:()=>u(d),className:"peer sr-only"}),l.jsx("span",{className:p.cn("flex h-6 items-center justify-center rounded-control px-1.5 text-center text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground peer-focus-visible:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-ring/20",h&&"bg-background text-foreground shadow-sm ring-1 ring-border"),children:f})]},d)})}),o?l.jsxs("div",{className:"space-y-2 rounded-control bg-muted/35 p-2",children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsx(p.Label,{htmlFor:r,className:"text-xs",children:"Offset"}),l.jsx(p.Input,{id:r,"aria-label":"Comparison offset",type:"number",min:1,step:1,className:"h-7 w-20 text-xs",value:s,onFocus:d=>d.currentTarget.select(),onChange:d=>{const f=Number.parseInt(d.target.value,10);!Number.isInteger(f)||f<1||c(o.kind==="previous_year"?{offsetYears:f}:{offsetPeriods:f})}})]}),l.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[l.jsx(An,{checked:o.toDate===!0,onCheckedChange:d=>c({toDate:d===!0})}),"To date"]}),l.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[l.jsx(An,{checked:o.alignment==="weekday",onCheckedChange:d=>c({alignment:d===!0?"weekday":"calendar"})}),"Match weekdays"]})]}):null]})}function xue({selection:e,controlLabel:t,scopeMessage:n,authorControlledCardCount:r,activeDateFilterValue:o,hasRuntimeOverride:s,onChange:i,onReset:a}){const c=e.mode==="period"?e.spec:void 0,u=p.hasFiniteDateComparisonRange(o);return l.jsxs("div",{className:"space-y-2 border-t border-border px-2 py-2.5",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Compare"}),s?l.jsx(p.Button,{type:"button",variant:"ghost",size:"xs",onClick:a,children:"Reset"}):null]}),l.jsx(bue,{selection:e,controlLabel:t,onChange:i}),l.jsxs("p",{className:"text-[11px] leading-4 text-muted-foreground",children:[u?n:c?`Choose a ${t} range to activate this comparison.`:`Choose a ${t} range to enable comparison.`,r>0?` ${r} visual${r===1?" contains":"s contain"} author-controlled comparison settings, which take precedence.`:""]})]})}function B$(e,t){const n=p.useDashboardStore(s=>s.dashboard),r=p.useDashboardStore(s=>s.selectedSheetId),o=p.useDashboardStore(s=>s.dashboardInputValues);return v.useMemo(()=>{var a;if((t==null?void 0:t.storageTarget)==="card")return t;const s=((a=t==null?void 0:t.dashboardInput)==null?void 0:a.kind)==="filter"?t.dashboardInput:ja(n,e.id);if(!s)return t;const i=p.getDashboardInputRuntimeSlot(o,s,{sheetId:(t==null?void 0:t.sheetId)||r});return(i==null?void 0:i.status)!=="set"&&(i==null?void 0:i.status)!=="cleared"?t:{...t,storageTarget:"dashboardInput",dashboardInput:s,sheetId:(t==null?void 0:t.sheetId)||r||void 0}},[n,o,e.id,r,t])}function IM(e){if(!e)return;const t=e instanceof Date?e:new Date(e);return isNaN(t.getTime())?void 0:t}function yue({filter:e,storageOptions:t,inline:n,onApplied:r}){var P;const o=B$(e,t),s=p.useDashboardStore(A=>A.filterValues),i=p.useDashboardStore(A=>A.dashboard),a=p.useDashboardStore(A=>A.dashboardInputValues),c=p.useDashboardStore(A=>A.selectedSheetId),u=p.useDashboardStore(A=>A.semanticExecutionPayload),{addOrUpdateFilterValue:d,removeFilterValues:f,setDashboardInputSlot:h,clearDashboardInputSlot:m,setDashboardInputComparisonSelection:g,resetDashboardInputComparisonSelection:x}=p.useDashboardActions(),b=v.useMemo(()=>p.getGlobalDateFilterCoverage(i,u,e),[i,e,u]),y=v.useMemo(()=>{const A=o==null?void 0:o.dashboardInput;return(A==null?void 0:A.kind)==="filter"?A:ja(i,e.id)},[i,e.id,o==null?void 0:o.dashboardInput]),w=v.useMemo(()=>({sheetId:(o==null?void 0:o.sheetId)||c}),[c,o==null?void 0:o.sheetId]),C=!!(y&&p.canAddressDashboardInputRuntimeSlot(y,w)),N=v.useMemo(()=>y&&C?p.hydrateAuthoredDashboardInputSlot({dashboard:i,input:y,runtimeValues:a,target:w}):void 0,[C,i,y,w,a]),S=(N==null?void 0:N.comparisonSelection)||{mode:"off"},j=(N==null?void 0:N.status)==="set"&&N.value.kind==="filter"?N.value.filterValue:void 0,I=(o==null?void 0:o.storageTarget)==="dashboardInput",k=I?j:s==null?void 0:s.find(A=>A.filterId===e.id),T=v.useCallback(A=>{if(I){if(!y)return;const L=p.createFilterDashboardInputSlot(A);L&&h(y,w,L);return}d(A)},[d,y,w,I,h]),_=v.useCallback(()=>{if(I){if(!y)return;m(y,w);return}f(e.id)},[m,y,w,e.id,I,f]),E=y?C&&((P=p.getDashboardInputRuntimeSlot(a,y,w))==null?void 0:P.comparisonSelection)!==void 0:!1,D=v.useMemo(()=>{const A=new Set(b.eligibleCardIds);return p.getDashboardCards(i).filter(L=>{var O,B;return A.has(L.id)?((O=L.preferences)==null?void 0:O.inheritGlobalComparison)===!1?!0:(((B=L.config)==null?void 0:B.metricColumns)||[]).some(H=>H.comparison!==void 0):!1}).length},[i,b.eligibleCardIds]),M=v.useMemo(()=>{var A;return{hasData:!0,hasActiveFilter:!!k,enableTimePrecision:b.allEligibleTargetsAreDateTime,activeFilterValue:k,storedFilterValue:k,dateRange:(A=k==null?void 0:k.values)!=null&&A.length?{from:IM(k.values[0]),to:k.values.length>1?IM(k.values[1]):IM(k.values[0])}:void 0,handleChange:(L,O="between",B={})=>{if(!L){_();return}let H;if(O==="between"||O==="not between")H={filterId:e.id,name:e.column,valueType:"date",operation:O,values:p.normalizeDateFilterRange(L,{temporalPrecision:B.temporalPrecision}).values,dataType:e.dataType,...B.temporalPrecision?{temporalPrecision:B.temporalPrecision}:{}};else{const R=L.from||L.to;if(!R){_();return}H={filterId:e.id,name:e.column,valueType:"date",operation:O,values:[R],dataType:e.dataType,...B.temporalPrecision?{temporalPrecision:B.temporalPrecision}:{}}}T(H)},handleRelativeChange:(L,O,B={})=>{if(!L)return;const H=B.temporalPrecision??p.getTemporalPrecisionForRelativeMeta(O),R={filterId:e.id,name:e.column,valueType:"date",operation:"between",values:p.normalizeDateFilterRange(L,{temporalPrecision:H}).values,dataType:e.dataType,relativeMeta:O,...H?{temporalPrecision:H}:{}};T(R)},handleClear:_}},[k,_,e,b.allEligibleTargetsAreDateTime,T]);return l.jsx(z$,{filter:e,managedState:M,inline:n,onApplied:r,supplementalFooter:y&&C?l.jsx(xue,{selection:S,controlLabel:"Global Date",scopeMessage:b.eligibleCardCount>0?`Comparison applies to ${b.eligibleCardCount} of ${b.totalCardCount} date-based visuals.`:"No visuals use Global Date for comparison.",authorControlledCardCount:D,activeDateFilterValue:k,hasRuntimeOverride:E,onChange:A=>g(y,w,A),onReset:()=>x(y,w)}):void 0})}function KQe(e){const t=p.getGlobalDateFilterCoverage(e.dashboard,e.semanticExecutionPayload),n=[];for(const{sheet:r,card:o}of p.getDashboardCardEntries(e.dashboard)){if(!p.dashboardInputRuntimeTargetsShareSlot(e.dashboardInput,e.dashboardInputTarget,{sheetId:r.id,cardId:o.id}))continue;const s=Ti({dashboard:e.dashboard,sheetId:r.id,card:o,runtimeValues:e.runtimeValues,mode:"interactive",timezone:e.timezone}),i=Cb({card:o,dashboard:e.dashboard,interactionStates:e.interactionStates,currentDashboardId:e.dashboard.id,filters:e.dashboard.filters,filterValues:e.runtimeValues.filterValues,selectedSheetId:r.id,inlineFilterValuesMap:e.runtimeValues.inlineFilterValuesMap,dashboardControls:e.dashboard.controls,dashboardControlValues:e.runtimeValues.controlValues,cardControlValuesMap:e.runtimeValues.cardControlValuesMap,dashboardInputContext:s}),a=aw({card:o,cardConfig:i.queryRelevantConfig,input:i.filterCompilationInput,semanticExecutionPayload:e.semanticExecutionPayload,timezone:e.timezone,allowMinutePrecision:t.allEligibleTargetsAreDateTime});a.status!=="blocked"&&n.push({card:o,plan:a.dateComparisonPlan})}return g_e({inputId:e.dashboardInput.id,targets:n})}function GQe(e){const t=[];return e.ownerCardCount>0&&t.push(`Comparison applies to ${e.ownerCardCount} of ${e.matchingCardCount} visuals using this date field.`),e.globalPrecedenceCardCount>0&&t.push(`Global Date controls comparison for ${e.globalPrecedenceCardCount} of those visual${e.globalPrecedenceCardCount===1?"":"s"}.`),e.ambiguousCardCount>0&&t.push(`Comparison is unavailable for ${e.ambiguousCardCount} visual${e.ambiguousCardCount===1?"":"s"} because more than one active filter uses this date field.`),t.length>0?t.join(" "):e.matchingCardCount>0?`Comparison is available for ${e.matchingCardCount} visual${e.matchingCardCount===1?"":"s"} using this date field.`:"No visuals use this date filter for comparison."}function vue({filter:e,storageOptions:t,inline:n,onApplied:r}){var E;const o=p.useDashboardStore(D=>D.dashboard),s=p.useDashboardStore(D=>D.filterValues),i=p.useDashboardStore(D=>D.controlValues),a=p.useDashboardStore(D=>D.dashboardInputValues),c=p.useDashboardStore(D=>D.inlineFilterValuesMap),u=p.useDashboardStore(D=>D.cardControlValuesMap),d=p.useDashboardStore(D=>D.selectedSheetId),f=p.useDashboardStore(D=>D.semanticExecutionPayload),h=p.useInteractionStore(D=>D.interactionStates),{setDashboardInputComparisonSelection:m,resetDashboardInputComparisonSelection:g}=p.useDashboardActions(),x=bl(),b=v.useMemo(()=>{const D=t==null?void 0:t.dashboardInput;return(D==null?void 0:D.kind)==="filter"?D:ja(o,e.id)},[o,e.id,t==null?void 0:t.dashboardInput]),y=v.useMemo(()=>({sheetId:(t==null?void 0:t.sheetId)||d}),[d,t==null?void 0:t.sheetId]),w=!!(b&&p.canAddressDashboardInputRuntimeSlot(b,y)),C=v.useMemo(()=>b&&w?p.hydrateAuthoredDashboardInputSlot({dashboard:o,input:b,runtimeValues:a,target:y,timezone:x}):void 0,[o,b,y,a,w,x]),N=(C==null?void 0:C.status)==="set"&&C.value.kind==="filter"?C.value.filterValue:void 0,S=(t==null?void 0:t.storageTarget)==="dashboardInput"?N:s==null?void 0:s.find(D=>D.filterId===e.id),j=(C==null?void 0:C.comparisonSelection)||{mode:"off"},I=b?w&&((E=p.getDashboardInputRuntimeSlot(a,b,y))==null?void 0:E.comparisonSelection)!==void 0:!1,k=!!(b&&w&&(t==null?void 0:t.storageTarget)!=="card"&&p.isComparisonCapableDashboardDateInput(b)),T=v.useMemo(()=>!b||!k?{ownerCardCount:0,matchingCardCount:0,globalPrecedenceCardCount:0,ambiguousCardCount:0,authorControlledCardCount:0}:KQe({dashboard:o,dashboardInput:b,dashboardInputTarget:y,interactionStates:h,semanticExecutionPayload:f,runtimeValues:{dashboardInputValues:a,filterValues:s,controlValues:i,inlineFilterValuesMap:c,cardControlValuesMap:u},timezone:x}),[u,i,o,b,y,a,s,c,h,k,f,x]),_=v.useMemo(()=>GQe(T),[T]);return l.jsx(z$,{filter:e,storageOptions:t,inline:n,onApplied:r,supplementalFooter:b&&k?l.jsx(xue,{selection:j,controlLabel:b.label||e.title||"date",scopeMessage:_,authorControlledCardCount:T.authorControlledCardCount,activeDateFilterValue:S,hasRuntimeOverride:I,onChange:D=>m(b,y,D),onReset:()=>g(b,y)}):void 0})}function W_({filter:e,storageOptions:t}){var r,o;const n=B$(e,t);return e.kind==="global-date"?l.jsx(yue,{filter:e,storageOptions:n}):(r=e.customFilterPreferences)!=null&&r.url&&((o=e.customFilterPreferences)!=null&&o.componentName)?l.jsx(WQe,{filter:e,storageOptions:n}):p.isDateDataType(e.dataType)?l.jsx(vue,{filter:e,storageOptions:n}):e.uiType==="radio"&&e.type==="single"?l.jsx($ce,{filter:e,storageOptions:n}):e.uiType==="tabs"&&e.type==="single"?l.jsx(zce,{filter:e,storageOptions:n}):l.jsx(Oce,{filter:e,storageOptions:n})}function wue({className:e,message:t="Failed to load options"}){return l.jsx("p",{className:p.cn("px-2 py-2 text-[12px] text-destructive",e),children:t})}function Cue({checked:e,className:t}){return l.jsx("span",{"aria-hidden":"true",className:p.cn("inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border bg-background transition-colors",e?"border-primary":"border-input",t),children:e?l.jsx("span",{className:"h-2 w-2 rounded-full bg-primary"}):null})}function YQe({filter:e,storageOptions:t,onApplied:n}){var H;const{filteredRecords:r,selectedRecords:o,handleChange:s,query:i,setQuery:a,isLoading:c,isFetching:u,isPlaceholderData:d,isError:f,isSearching:h,searchError:m,isSingleSelect:g,activeFilterValue:x}=Xb(e,{enableServerSearch:!0,searchDebounceMs:300,minSearchLength:2,searchThreshold:5,...t}),y=`Search ${(e.title||e.column||"options").toLowerCase()}`,[w,C]=v.useState(o),[N,S]=v.useState(!1);v.useEffect(()=>{N||C(o)},[o,N]);const j=v.useMemo(()=>new Set(w.map(R=>R.value)),[w]),I=(x==null?void 0:x.operation)==="is null"||(x==null?void 0:x.operation)==="is not null",k=(((H=x==null?void 0:x.values)==null?void 0:H.length)??0)>0||I,_=c||u&&d,E=R=>{if(g){C([R]),S(!0);return}S(!0),C(V=>V.some(F=>F.value===R.value)?V.filter(F=>F.value!==R.value):[...V,R])},D=(R,V)=>{R.key!=="Enter"&&R.key!==" "||(R.preventDefault(),E(V))},M=r.length>0&&r.every(R=>j.has(R.value)),P=!r.some(R=>j.has(R.value)),A=M?"checked":P?"unchecked":"indeterminate",L=()=>{if(S(!0),A==="checked"){const R=new Set(r.map(V=>V.value));C(V=>V.filter(z=>!R.has(z.value)))}else C(R=>{const V=new Map(R.map(z=>[z.value,z]));return r.forEach(z=>V.set(z.value,z)),Array.from(V.values())})},O=()=>{s(w),S(!1),n==null||n()},B=()=>{C([]),S(!0)};return f?l.jsx(wue,{}):l.jsxs("div",{className:"flex flex-col p-1.5",children:[l.jsxs("div",{className:"mb-1.5 flex h-7 shrink-0 items-center gap-1.5 rounded-control border border-input bg-background px-2 focus-within:border-ring",children:[h?l.jsx(p.LoaderCircle,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground","aria-label":"Searching","aria-live":"polite"}):l.jsx(Mt.Search,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx("input",{type:"text",value:i,onChange:R=>a(R.target.value),placeholder:y,"aria-label":y,className:"h-full w-full bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none"}),i&&l.jsx("button",{type:"button",onClick:()=>a(""),"aria-label":"Clear search",className:"inline-flex h-4 w-4 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx(Ie.X,{className:"h-3 w-3"})})]}),m&&l.jsxs("div",{className:"mb-2 flex items-start gap-1.5 rounded-[4px] border border-destructive/30 bg-destructive/5 px-2 py-1 text-[11px] text-destructive",children:[l.jsx(Ia,{className:"mt-0.5 h-3 w-3 shrink-0"}),l.jsx("span",{className:"min-w-0 flex-1 truncate",children:typeof m=="string"?m:"Search failed — showing local results"})]}),l.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2 px-0.5",children:[!g&&l.jsx(Lce,{filter:e,storageOptions:t,compact:!0}),!g&&r.length>0&&l.jsxs("label",{className:"ml-auto inline-flex cursor-pointer items-center gap-1.5 text-[11px] text-muted-foreground",children:[l.jsx("span",{children:"All"}),l.jsx(An,{checked:A==="checked"?!0:A==="indeterminate"?"indeterminate":!1,onCheckedChange:L,"aria-label":"Select all",className:"h-3.5 w-3.5"})]})]}),l.jsx("div",{className:"-mx-0.5 max-h-[260px] overflow-y-auto px-0.5",role:"listbox","aria-multiselectable":!g,children:_?l.jsx("div",{children:Array.from({length:6}).map((R,V)=>{const z=["w-32","w-24","w-40","w-28","w-36","w-20"];return l.jsxs("div",{className:"flex items-center gap-2 px-1.5 py-1","aria-hidden":"true",children:[l.jsx(ei,{className:"h-3.5 w-3.5 shrink-0 rounded-[3px] bg-foreground/[0.06]"}),l.jsx("span",{className:"flex h-5 items-center",children:l.jsx(ei,{className:p.cn("h-3 rounded-[3px] bg-foreground/[0.06]",z[V%z.length])})})]},V)})}):r.length===0?l.jsx("div",{className:"px-2 py-6 text-center text-[12px] text-muted-foreground",children:i?"No matches":"No options"}):r.map(R=>{var F;const V=j.has(R.value),z=((F=R.label)==null?void 0:F.toString())||String(R.value);return l.jsxs("div",{role:"option",tabIndex:0,"aria-selected":V,onClick:()=>E(R),onKeyDown:G=>D(G,R),className:p.cn("flex w-full cursor-pointer select-none items-center gap-2 rounded-[4px] px-1.5 py-1 text-left text-[13px] text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/20",V?"bg-muted hover:bg-foreground/[0.08]":"hover:bg-muted"),children:[g?l.jsx(Cue,{checked:V,className:"h-3.5 w-3.5"}):l.jsx(An,{checked:V,className:"pointer-events-none h-3.5 w-3.5",tabIndex:-1,"aria-hidden":"true"}),l.jsx("span",{className:"truncate",children:z})]},`${R.id}:${R.value}`)})}),l.jsxs("div",{className:"mt-1.5 flex items-center justify-between gap-2 border-t border-border pt-1.5",children:[l.jsxs("span",{className:"px-0.5 text-[11px] text-muted-foreground",children:[l.jsx("span",{className:"tabular-nums text-foreground",children:I&&!N&&w.length===0?1:w.length})," ","selected"]}),l.jsxs("div",{className:"flex items-center gap-1",children:[(N||k)&&l.jsx(p.Button,{type:"button",variant:"ghost",size:"xs",className:"h-6 px-2",onClick:B,children:"Clear"}),l.jsx(p.Button,{type:"button",variant:"default",size:"xs",className:"h-6 px-2",onClick:O,disabled:!N,children:"Apply"})]})]})]})}function ZQe({filter:e,onUpdate:t,cardScopeMode:n="editable"}){var E,D;const[r,o]=v.useState(""),s=p.useDashboardStore(M=>M.dashboard.sheets),i=v.useMemo(()=>p.getDashboardSheets(s??[]),[s]),a=p.useDashboardStore(M=>M.selectedSheetId),c=v.useMemo(()=>{const M=[];return i.forEach(P=>{var A;(A=P.frames)==null||A.forEach(L=>{var O;(O=L.cards)==null||O.forEach(B=>{M.push({...B,sheetId:P.id,sheetTitle:P.title||P.id})})})}),M},[i]),u=()=>e.applyToSheetIds!==void 0?"specific-sheets":e.excludeSheetIds!==void 0?"all-except-specific":"all-sheets",d=()=>e.applyToCardIds!==void 0?"specific-cards":e.excludeCardIds!==void 0?"all-except-specific":"all-cards",f=M=>{const P={};switch(M){case"all-sheets":P.applyToSheetIds=void 0,P.excludeSheetIds=void 0;break;case"specific-sheets":P.applyToSheetIds=[],P.excludeSheetIds=void 0;break;case"all-except-specific":P.applyToSheetIds=void 0,P.excludeSheetIds=[];break}t(P)},h=M=>{const P={};switch(M){case"all-cards":P.applyToCardIds=void 0,P.excludeCardIds=void 0;break;case"specific-cards":P.applyToCardIds=[],P.excludeCardIds=void 0;break;case"all-except-specific":P.applyToCardIds=void 0,P.excludeCardIds=[];break}t(P)},m=(M,P)=>{if(P==="specific-sheets"){const A=e.applyToSheetIds||[];t({applyToSheetIds:A.includes(M)?A.filter(L=>L!==M):[...A,M]})}else if(P==="all-except-specific"){const A=e.excludeSheetIds||[];t({excludeSheetIds:A.includes(M)?A.filter(L=>L!==M):[...A,M]})}},g=(M,P)=>{if(P==="specific-cards"){const A=e.applyToCardIds||[];t({applyToCardIds:A.includes(M)?A.filter(L=>L!==M):[...A,M]})}else if(P==="all-except-specific"){const A=e.excludeCardIds||[];t({excludeCardIds:A.includes(M)?A.filter(L=>L!==M):[...A,M]})}},x=v.useMemo(()=>e.applyToSheetIds!==void 0?e.applyToSheetIds:e.excludeSheetIds!==void 0?i.filter(M=>{var P;return!((P=e.excludeSheetIds)!=null&&P.includes(M.id))}).map(M=>M.id):i.map(M=>M.id),[i,e.applyToSheetIds,e.excludeSheetIds]),b=v.useMemo(()=>c.filter(M=>x.includes(M.sheetId)),[c,x]),y=v.useMemo(()=>{if(!r.trim())return b;const M=r.toLowerCase();return b.filter(P=>{var A;return(A=P==null?void 0:P.title)==null?void 0:A.toLowerCase().includes(M)})},[r,b]),w=u(),C=d(),N=(E=w==="specific-sheets"?e.applyToSheetIds:e.excludeSheetIds)==null?void 0:E.length,S=(D=C==="specific-cards"?e.applyToCardIds:e.excludeCardIds)==null?void 0:D.length,j=w==="all-sheets"?`Shows on every sheet (${i.length} total).`:w==="specific-sheets"?`Shows only on the checked sheets (${N??0} checked).`:`Shows everywhere except the checked sheets (${N??0} checked).`,I=C==="all-cards"?`Applies to every card in the sheets above (${b.length} total).`:C==="specific-cards"?`Applies only to the checked cards (${S??0} checked).`:`Applies to everything except the checked cards (${S??0} checked).`,k=(M,P,A)=>l.jsx(p.Tabs,{value:M,onValueChange:P,children:l.jsx(p.TabsList,{className:"grid h-8 w-full grid-cols-3 overflow-hidden rounded-control p-0.5",children:A.map(L=>l.jsx(p.TabsTrigger,{value:L.value,"aria-label":L.ariaLabel,className:"h-7 text-[12px] leading-none",children:L.label},L.value))})}),T=M=>{const P=(M==="specific-sheets"?e.applyToSheetIds:e.excludeSheetIds)||[];return l.jsx("div",{className:"max-h-44 overflow-y-auto rounded-control border border-border/60 p-1",children:i.map(A=>{const L=M==="specific-sheets"?`sheet-${A.id}`:`sheet-exclude-${A.id}`;return l.jsxs("label",{htmlFor:L,className:"flex cursor-pointer items-center gap-2 rounded-[4px] px-1.5 py-1 hover:bg-muted/50",children:[l.jsx(An,{id:L,checked:P.includes(A.id),onCheckedChange:()=>m(A.id,M),className:"h-3.5 w-3.5"}),l.jsx("span",{className:"truncate text-[13px] text-foreground",children:A.title||A.id}),A.id===a&&l.jsx("span",{className:"text-[11px] text-muted-foreground",children:"· current"})]},A.id)})})},_=M=>{const P=(M==="specific-cards"?e.applyToCardIds:e.excludeCardIds)||[];return l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Input,{size:"xs",placeholder:"Search cards…",value:r,onChange:A=>o(A.target.value)}),l.jsx("div",{className:"max-h-44 overflow-y-auto rounded-control border border-border/60 p-1",children:y.length>0?y.map(A=>{const L=M==="specific-cards"?`card-${A.id}`:`card-exclude-${A.id}`;return l.jsxs("label",{htmlFor:L,className:"flex cursor-pointer items-center gap-2 rounded-[4px] px-1.5 py-1 hover:bg-muted/50",children:[l.jsx(An,{id:L,checked:P.includes(A.id),onCheckedChange:()=>g(A.id,M),className:"h-3.5 w-3.5"}),l.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-foreground",children:A.title}),l.jsx("span",{className:"max-w-[40%] truncate text-[11px] text-muted-foreground",children:A.sheetTitle})]},A.id)}):l.jsxs("p",{className:"py-4 text-center text-[12px] text-muted-foreground",children:["No cards match “",r,"”."]})})]})};return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("section",{className:"space-y-1.5",children:[l.jsx("h4",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Sheet scope"}),k(w,M=>f(M),[{value:"all-sheets",label:"All sheets",ariaLabel:"All sheets"},{value:"specific-sheets",label:"Only specific",ariaLabel:"Only specific sheets"},{value:"all-except-specific",label:"All except",ariaLabel:"All except specific sheets"}]),l.jsx("p",{className:"text-[11px] leading-4 text-muted-foreground",children:j}),w!=="all-sheets"&&T(w)]}),l.jsxs("section",{className:"space-y-1.5 border-t border-border/60 pt-3",hidden:n==="mapping",children:[l.jsx("h4",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Card scope"}),k(C,M=>h(M),[{value:"all-cards",label:"All cards",ariaLabel:"All cards"},{value:"specific-cards",label:"Only specific",ariaLabel:"Only specific cards"},{value:"all-except-specific",label:"All except",ariaLabel:"All except specific cards"}]),l.jsxs("p",{className:"text-[11px] leading-4 text-muted-foreground",children:[I," Restricted to cards in the sheets selected above."]}),C!=="all-cards"&&_(C)]})]})}function K_(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,s;for(s=0;s<r.length;s++)o=r[s],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}var XQe=["color"],QQe=v.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=K_(e,XQe);return v.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o,{ref:t}),v.createElement("path",{d:"M7.5 2C7.77614 2 8 2.22386 8 2.5L8 11.2929L11.1464 8.14645C11.3417 7.95118 11.6583 7.95118 11.8536 8.14645C12.0488 8.34171 12.0488 8.65829 11.8536 8.85355L7.85355 12.8536C7.75979 12.9473 7.63261 13 7.5 13C7.36739 13 7.24021 12.9473 7.14645 12.8536L3.14645 8.85355C2.95118 8.65829 2.95118 8.34171 3.14645 8.14645C3.34171 7.95118 3.65829 7.95118 3.85355 8.14645L7 11.2929L7 2.5C7 2.22386 7.22386 2 7.5 2Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),JQe=["color"],eJe=v.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=K_(e,JQe);return v.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o,{ref:t}),v.createElement("path",{d:"M7.14645 2.14645C7.34171 1.95118 7.65829 1.95118 7.85355 2.14645L11.8536 6.14645C12.0488 6.34171 12.0488 6.65829 11.8536 6.85355C11.6583 7.04882 11.3417 7.04882 11.1464 6.85355L8 3.70711L8 12.5C8 12.7761 7.77614 13 7.5 13C7.22386 13 7 12.7761 7 12.5L7 3.70711L3.85355 6.85355C3.65829 7.04882 3.34171 7.04882 3.14645 6.85355C2.95118 6.65829 2.95118 6.34171 3.14645 6.14645L7.14645 2.14645Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),tJe=["color"],nJe=v.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=K_(e,tJe);return v.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o,{ref:t}),v.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"}))}),rJe=["color"],oJe=v.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=K_(e,rJe);return v.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o,{ref:t}),v.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 zd({text:e,className:t,ariaLabel:n,onCopy:r,disabled:o=!1,label:s,copiedLabel:i="Copied",showIcon:a=!0,variant:c="ghost",size:u}){const[d,f]=v.useState(!1),h=!!s,m=v.useRef(void 0);return v.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),l.jsxs(p.Button,{className:p.cn(!h&&"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70",t),variant:c,size:u??(h?"xs":"icon"),"aria-label":n,disabled:o,onClick:async()=>{try{let g=!1;if(r)g=await r();else if(typeof e=="string"){if(typeof navigator>"u"||!navigator.clipboard)return;await navigator.clipboard.writeText(e),g=!0}if(!g)return;f(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{f(!1),m.current=void 0},1e3)}catch(g){console.error("Failed to copy text",g)}},children:[a?d?l.jsx(nJe,{className:"size-3.5"}):l.jsx(rm,{className:"size-3.5"}):null,h?l.jsx("span",{children:d?i:s}):null]})}function Sue(){const{authToken:e,tokenProps:t}=It(),{data:n,isLoading:r,isFetching:o,isError:s}=qn({queryKey:["plugins",e==null?void 0:e.accessToken],queryFn:()=>p.getPlugins(t.apiServiceUrl,e==null?void 0:e.accessToken)});return{data:n,isLoading:r,isFetching:o,isError:s}}function V$(){const{data:e,isLoading:t,isError:n}=Sue(),r=Fm({queries:((e==null?void 0:e.plugins)||[]).map(c=>({queryKey:["manifest",c.value],queryFn:()=>Ale(c.value),enabled:!!c.value,staleTime:5*60*1e3,gcTime:10*60*1e3,retry:2,retryDelay:u=>Math.min(1e3*2**u,3e4)}))}),o=[],s=[];let i=t,a=n;return r.forEach((c,u)=>{var d;if(c.isLoading&&(i=!0),c.isError&&(a=!0),c.data&&((d=e==null?void 0:e.plugins)!=null&&d[u])){const f=e.plugins[u],h=c.data.visuals.map(m=>({name:m.name,pluginName:f.label,componentType:m.componentType,pluginType:f.type,icon:m.icon,chartType:m.chartType,visualType:m.visualType||(m.dataInputs&&m.dataInputs.length>1?"multiple":"single"),minInputs:m.minInputs,maxInputs:m.maxInputs,slots:m.slots,url:f.value}));if(o.push(...h),c.data.filters){const m=c.data.filters.map(g=>({name:g.name,component:g.component,pluginName:f.label,pluginType:f.type,icon:g.icon,filterType:g.filterType,supportedDataTypes:g.supportedDataTypes,url:f.value}));s.push(...m)}}}),{data:o,filters:s,isLoading:i,isError:a}}function sJe(e){const[t,n]=v.useState(null);return t}function iJe({pluginFilter:e}){const t=sJe(e.icon||""),n=e.name.charAt(0).toUpperCase();return l.jsxs("div",{className:"flex items-center gap-2",children:[t?l.jsx(t,{className:"h-4 w-4"}):l.jsx("div",{className:"flex h-4 w-4 items-center justify-center rounded bg-muted text-xs font-medium",children:n}),l.jsx("span",{children:e.name}),l.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",e.pluginName,")"]})]})}function aJe({filter:e,onSelect:t,onClear:n}){const{filters:r,isLoading:o}=V$(),s=p.getDataType(e.dataType),i=r==null?void 0:r.filter(u=>!u.supportedDataTypes||u.supportedDataTypes.length===0?!0:u.supportedDataTypes.some(d=>s.toLowerCase()===d.toLowerCase())),a=e.customFilterPreferences,c=a?`${a.url}::${a.componentName}`:"";return o?l.jsx("div",{className:"flex h-7 items-center rounded-control border border-input bg-background px-2 text-[12px] text-muted-foreground",children:"Checking available custom filters…"}):!i||i.length===0?l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"No custom filters available."}):l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(p.Select,{value:c,onValueChange:u=>{if(!u)return;const[d,f]=u.split("::"),h=i.find(m=>m.url===d&&m.component===f);h&&t({url:d,componentName:h.component,pluginFilterType:h.filterType,icon:h.icon})},children:[l.jsx(p.SelectTrigger,{className:"h-9 flex-1",children:l.jsx(p.SelectValue,{placeholder:"Use default UI"})}),l.jsx(p.SelectContent,{children:i.map(u=>l.jsx(p.SelectItem,{value:`${u.url}::${u.component}`,children:l.jsx(iJe,{pluginFilter:u})},`${u.url}::${u.component}`))})]}),a&&l.jsx(p.Button,{variant:"ghost",size:"sm",className:"h-9 w-9 p-0",onClick:n,title:"Clear custom filter selection",children:l.jsx(Ie.X,{className:"h-4 w-4"})})]})}function Nue(e){if((e==null?void 0:e.mode)!=="period")return;const t=e.spec;if(t.kind==="previous_year"){const r=t.offsetYears??1;return r===1?"vs previous year":`vs ${r} years ago`}const n=t.offsetPeriods??1;return n===1?"vs previous period":`vs ${n} periods ago`}function lJe(e){for(const[n,r]of Object.entries(p.presetMetadata))if(JSON.stringify(r)===JSON.stringify(e))return n;const t={minute:"minute",hour:"hour",day:"day",week:"week",month:"month",quarter:"quarter",year:"year"};switch(e.mode){case"last":{const n=e.complete?" (complete)":"",r=e.n>1?"s":"";return`Last ${e.n} ${t[e.unit]}${r}${n}`}case"this":{if(e.boundary==="first_day")return"First day of the month";if(e.boundary==="last_day")return"Last day of the month";const n=e.toDate?" to date":"";return`This ${t[e.unit]}${n}`}case"previous":return`Previous ${t[e.unit]}`;case"between":return`Between ${e.from} and ${e.to} ${t[e.unit]}s`}}const bU=["January","February","March","April","May","June","July","August","September","October","November","December"];function cJe(e){if(p.isFixedMonthDefaultDateFilter(e))return`${bU[e.month]} ${e.year}`;if(p.isFixedDayDefaultDateFilter(e)){const[t,n,r]=e.date.split("-").map(Number);return`${bU[n-1]} ${r}, ${t}`}return lJe(e)}function _M(e){return e&&p.isRelativeDateFilter(e)?"relative":"fixed"}function uJe(e){return`${typeof e}:${String(e)}`}function G_(e){return"kind"in e&&e.kind==="global-date"}function KS(e){return G_(e)?p.DEFAULT_GLOBAL_DATE_FILTER_TITLE:e.column}function dJe({selection:e,controlLabel:t,onChange:n}){return l.jsxs("div",{className:"space-y-2 border-t border-border px-2 py-2.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Compare"}),l.jsx(bue,{selection:e,controlLabel:t,onChange:n})]})}function fJe({filter:e,onUpdate:t,showFilterId:n=!0,filterOptionsData:r,optionLabelFieldName:o,timezone:s,variant:i="dashboard",defaultComparisonSelection:a,onDefaultComparisonChange:c,onDefaultDatePickerOpenChange:u,afterLabelSlot:d}){var G;const f=G_(e),[h,m]=v.useState(e.title===KS(e)?"":e.title||""),[g,x]=v.useState(e.defaultValues||[]),[b,y]=v.useState(e.defaultDateFilter),[w,C]=v.useState(_M(e.defaultDateFilter)),[N,S]=v.useState(e.targetColumns||[]),j=(G=e.column.split(".").pop())==null?void 0:G.replace(/"/g,""),I=((r==null?void 0:r.records)||[]).flatMap(q=>{const Y=j?q[j]:q.value;if(Y==null||!["string","number","boolean"].includes(typeof Y))return[];const K=o?q[o]:void 0;return[{key:`${typeof Y}:${String(Y)}`,value:Y,label:String(K??Y)}]}),k=v.useMemo(()=>p.getDataType(e.dataType)==="date",[e.dataType]),T=s||Intl.DateTimeFormat().resolvedOptions().timeZone,_=i==="inline"||i==="document"?"z-[80]":void 0,E=a&&c?l.jsx(dJe,{selection:a,controlLabel:e.title||"Date",onChange:c}):void 0,D=Nue(a),M=v.useMemo(()=>{if(!b)return;const q=p.resolveDefaultDateFilterForDefaults(b,T);if(!q)return;const[Y,K]=q;return{from:Y,to:K}},[b,T]),P=v.useMemo(()=>{if(b&&p.isFixedMonthDefaultDateFilter(b))return{year:b.year,month:b.month}},[b]),A=v.useMemo(()=>{if(!(!b||!p.isRelativeDateFilter(b)))return b},[b]),L=v.useMemo(()=>{if(!(!b||!p.isFixedDayDefaultDateFilter(b)))return X2.fromZonedTime(`${b.date}T00:00:00`,T)},[b,T]);v.useEffect(()=>{m(e.title===KS(e)?"":e.title||""),x(e.defaultValues||[]);const q=e.defaultDateFilter;y(q),C(_M(q)),S(e.targetColumns||[])},[e]);function O(){const q=h.trim();t({title:q||KS(e)})}function B(q){x(q),t({defaultValues:q.length?q:void 0})}function H(q){y(q),q&&C(_M(q)),t({defaultDateFilter:q})}function R(q){S(q),t({targetColumns:q.length>0?q:void 0})}function V(){R([...N,{column:"",label:""}])}function z(q){const Y=N.filter((K,$)=>$!==q);R(Y)}function F(q,Y,K){const $=N.map((X,W)=>W===q?{...X,[Y]:K}:X);R($)}return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Display Label"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsxs("div",{className:"space-y-2",children:[l.jsx("p",{className:"text-[12px]",children:"Leave empty to use the column name. Provide a custom label to override it."}),n&&l.jsxs("div",{className:"space-y-1 border-t pt-2",children:[l.jsx("p",{className:"text-[12px] font-medium",children:"Filter ID"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("p",{className:"break-all font-mono text-xs text-muted-foreground",children:e.id}),l.jsx(zd,{text:e.id})]})]})]})})]})})]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[l.jsx(An,{id:"hideLabel",checked:e.showLabel===!1,onCheckedChange:q=>{t({showLabel:!q})}}),l.jsx(p.Label,{htmlFor:"hideLabel",className:"cursor-pointer text-[11px] text-muted-foreground",children:"Hide label"})]})]}),l.jsx(p.Input,{size:"xs",value:h,onChange:q=>m(q.target.value),onBlur:O,placeholder:KS(e)})]}),d,k?l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Default Date Filter"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:"Sets the initial date selection on load and previews it immediately while editing. Relative defaults recalculate on each load and scheduled execution, while fixed month defaults stay unchanged."})})]})})]}),e.dateSelectionMode==="months"?l.jsxs(p.Tabs,{value:w,onValueChange:q=>C(q),className:"space-y-2",children:[l.jsxs(p.TabsList,{className:"grid h-8 w-full grid-cols-2 overflow-hidden rounded-control p-0.5",children:[l.jsx(p.TabsTrigger,{value:"fixed",className:"h-7 text-[12px] leading-none",children:"Fixed"}),l.jsx(p.TabsTrigger,{value:"relative",className:"h-7 text-[12px] leading-none",children:"Relative"})]}),l.jsx(p.TabsContent,{value:"fixed",className:"mt-0",children:l.jsx(fue,{value:P,placeholder:"Select default month...",className:"w-full",onClear:()=>H(void 0),onChange:(q,Y)=>H({mode:"fixed",unit:"month",year:q,month:Y})})}),l.jsx(p.TabsContent,{value:"relative",className:"mt-0",children:l.jsxs(p.Select,{value:A?JSON.stringify(A):"__none__",onValueChange:q=>{if(q==="__none__"){H(void 0);return}try{const Y=JSON.parse(q);H(Y)}catch(Y){console.error("Failed to parse relative date filter",Y)}},children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{placeholder:"Select default month range..."})}),l.jsxs(p.SelectContent,{className:_,children:[l.jsx(p.SelectItem,{value:"__none__",children:"None"}),l.jsx(p.SelectItem,{value:JSON.stringify({mode:"this",unit:"month"}),children:"This month"}),l.jsx(p.SelectItem,{value:JSON.stringify({mode:"previous",unit:"month"}),children:"Last month"})]})]})})]}):e.dateSelectionMode==="day"?l.jsxs(p.Tabs,{value:w,onValueChange:q=>C(q),className:"space-y-2",children:[l.jsxs(p.TabsList,{className:"grid h-8 w-full grid-cols-2 overflow-hidden rounded-control p-0.5",children:[l.jsx(p.TabsTrigger,{value:"fixed",className:"h-7 text-[12px] leading-none",children:"Fixed"}),l.jsx(p.TabsTrigger,{value:"relative",className:"h-7 text-[12px] leading-none",children:"Relative"})]}),l.jsx(p.TabsContent,{value:"fixed",className:"mt-0",children:l.jsx(pue,{value:L,timezone:T,placeholder:"Select default date...",className:"w-full",buttonClassName:"h-7 text-[12px]",showPresets:!1,onClear:()=>H(void 0),onSelect:q=>H({mode:"fixed",unit:"day",date:q})})}),l.jsx(p.TabsContent,{value:"relative",className:"mt-0",children:l.jsxs(p.Select,{value:A?JSON.stringify(A):"__none__",onValueChange:q=>{if(q==="__none__"){H(void 0);return}try{const Y=JSON.parse(q);H(Y)}catch(Y){console.error("Failed to parse relative date filter",Y)}},children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{placeholder:"Select default day..."})}),l.jsxs(p.SelectContent,{className:_,children:[l.jsx(p.SelectItem,{value:"__none__",children:"None"}),l.jsx(p.SelectItem,{value:JSON.stringify({mode:"this",unit:"day"}),children:"Today"}),l.jsx(p.SelectItem,{value:JSON.stringify({mode:"previous",unit:"day"}),children:"Yesterday"})]})]})})]}):l.jsx($$,{value:M,relativeValue:p.isRelativeDateFilter(b)?b:void 0,onRelativeSelect:(q,Y)=>{H(Y)},showRelativeTab:!0,hideCalendar:!0,timezone:T,placeholder:"Select default date range…",buttonClassName:"h-7 text-[12px]",buttonLabelSuffix:D,contentClassName:_,overlayContentClassName:_,supplementalFooter:E,onOpenChange:u}),b&&l.jsx("div",{className:"flex items-center gap-2",children:l.jsxs("span",{className:"inline-flex items-center gap-1 rounded-[4px] bg-muted px-1.5 py-0.5 text-[11px] text-foreground",children:[cJe(b),l.jsx("button",{type:"button",className:"-mr-px flex h-3 w-3 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground",onClick:()=>H(void 0),"aria-label":"Clear default date",children:l.jsx(Ie.X,{className:"h-3 w-3"})})]})}),e.dateSelectionMode==="months"||e.dateSelectionMode==="day"?E:null]}):l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Default Values"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:"Sets the initial selection on load and previews it immediately while editing. Works like a filter selection."})})]})})]}),I.length>0?l.jsxs(p.Select,{value:"",onValueChange:q=>{const Y=I.find(K=>K.key===q);Y&&!g.some(K=>Object.is(K,Y.value))&&B([...g,Y.value])},children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{placeholder:"Select values to add..."})}),l.jsxs(p.SelectContent,{className:_,children:[I.filter(q=>!g.some(Y=>Object.is(Y,q.value))).map(q=>l.jsx(p.SelectItem,{value:q.key,children:q.label},q.key)),I.every(q=>g.some(Y=>Object.is(Y,q.value)))&&l.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"All values selected"})]})]}):l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Loading filter options…"}),g.length>0&&l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:["Selected · ",g.length]}),l.jsx("div",{className:"flex flex-wrap gap-1",children:g.map(q=>{var Y,K;return l.jsxs("span",{className:"inline-flex items-center gap-1 rounded-[4px] bg-muted px-1.5 py-0.5 text-[11px] text-foreground",children:[((Y=I.find($=>Object.is($.value,q)))==null?void 0:Y.label)??String(q),l.jsx("button",{type:"button",className:"-mr-px flex h-3 w-3 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground",onClick:()=>{B(g.filter($=>!Object.is($,q)))},"aria-label":`Remove ${((K=I.find($=>Object.is($.value,q)))==null?void 0:K.label)??String(q)}`,children:l.jsx(Ie.X,{className:"h-3 w-3"})})]},uJe(q))})})]})]}),k&&!f&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Target Columns"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:"Add multiple date columns to let users choose which field to filter at runtime. Leave empty to use only the primary column above."})})]})})]}),N.length>0&&l.jsx("div",{className:"space-y-2",children:N.map((q,Y)=>l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Input,{size:"xs",placeholder:"Column name",value:q.column,onChange:K=>F(Y,"column",K.target.value),className:"flex-1 font-mono"}),l.jsx(p.Input,{size:"xs",placeholder:"Label",value:q.label,onChange:K=>F(Y,"label",K.target.value),className:"flex-1"}),l.jsx(p.Button,{variant:"ghost",size:"xs",className:"w-7 shrink-0 px-0 text-muted-foreground hover:text-foreground",onClick:()=>z(Y),"aria-label":"Remove target column",children:l.jsx(Ie.X,{className:"h-3.5 w-3.5"})})]},Y))}),l.jsxs(p.Button,{variant:"outline",size:"xs",onClick:V,children:[l.jsx(Mr,{className:"h-3.5 w-3.5"}),"Add column"]})]})]})}function hJe({variableName:e,reservedVariableNames:t=[],onUpdateInputMetadata:n}){const[r,o]=v.useState(e||""),[s,i]=v.useState(null);v.useEffect(()=>{o(e||""),i(null)},[e]);function a(){if(!n||e===void 0)return;const c=r.trim();if(!c){o(e),i(null);return}const u=p.normalizeDashboardInputVariableName(c);if(u!==e&&t.includes(u)){i(`"${u}" is already used by another input.`);return}i(null),o(u),u!==e&&n({variableName:u})}return e===void 0||!n?null:l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Variable name"}),l.jsx(p.Input,{size:"xs",value:r,onChange:c=>o(c.target.value),onBlur:a,"aria-invalid":!!s,placeholder:"input_name"}),s?l.jsx("p",{className:"text-[10px] leading-3 text-destructive",children:s}):null]})}function mJe({filter:e,onUpdate:t,variant:n="dashboard"}){const r=G_(e),{filters:o,isLoading:s}=V$(),i=v.useMemo(()=>p.getDataType(e.dataType)==="date",[e.dataType]),a=n==="inline"||n==="document"?"z-[80]":void 0,c=v.useMemo(()=>{const x=p.getDataType(e.dataType);return(o==null?void 0:o.filter(b=>!b.supportedDataTypes||b.supportedDataTypes.length===0?!0:b.supportedDataTypes.some(y=>x.toLowerCase()===y.toLowerCase())))??[]},[e.dataType,o]),u=!r&&(s||!!e.customFilterPreferences||c.length>0);function d(x){t({type:x})}function f(x){const b=e.defaultDateFilter;if(x==="day"&&b&&!p.isSingleDayDefaultDateFilter(b)){t({dateSelectionMode:x,defaultDateFilter:void 0});return}t({dateSelectionMode:x})}function h(x){t({uiType:x})}function m(x){t({customFilterPreferences:x})}function g(){t({customFilterPreferences:void 0})}return l.jsxs("div",{className:"space-y-4",children:[i?l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date Picker Type"}),l.jsxs(p.Select,{value:e.dateSelectionMode||"range",onValueChange:x=>f(x),children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{})}),l.jsxs(p.SelectContent,{className:a,children:[l.jsx(p.SelectItem,{value:"range",children:"Date Range Picker"}),l.jsx(p.SelectItem,{value:"months",children:"Month Picker"}),l.jsx(p.SelectItem,{value:"day",children:"Day Picker"})]})]})]}):l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Selection Type"}),l.jsx(p.Tabs,{value:e.type||"multiple",onValueChange:x=>d(x),children:l.jsxs(p.TabsList,{className:"grid h-8 w-full grid-cols-2 overflow-hidden rounded-control p-0.5",children:[l.jsx(p.TabsTrigger,{value:"multiple",className:"h-7 text-[12px] leading-none",children:"Multiple"}),l.jsx(p.TabsTrigger,{value:"single",className:"h-7 text-[12px] leading-none",children:"Single"})]})})]}),!i&&e.type==="single"&&l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"UI Component"}),l.jsxs(p.Select,{value:e.uiType||"dropdown",onValueChange:h,children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{})}),l.jsxs(p.SelectContent,{className:a,children:[l.jsx(p.SelectItem,{value:"dropdown",children:"Dropdown"}),l.jsx(p.SelectItem,{value:"radio",children:"Radio"}),l.jsx(p.SelectItem,{value:"tabs",children:"Tabs"})]})]})]}),u&&l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Custom Filter Component"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:"Select a custom filter component from an installed plugin to replace the default filter UI with a custom implementation."})})]})})]}),l.jsx(aJe,{filter:e,onSelect:m,onClear:g})]}),n==="dashboard"&&l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Display Mode"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:`Choose how this filter is displayed. "Inherit" uses the dashboard's default setting. Override with "Canvas Card" or "Toolbar" to always display this filter in a specific mode.`})})]})})]}),l.jsxs(p.Select,{value:e.displayMode||"inherit",onValueChange:x=>t({displayMode:x}),children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{})}),l.jsxs(p.SelectContent,{children:[l.jsx(p.SelectItem,{value:"inherit",children:"Inherit (use dashboard default)"}),l.jsx(p.SelectItem,{value:"canvas",children:"Canvas Card"}),l.jsx(p.SelectItem,{value:"toolbar",children:"Toolbar"})]})]})]}),n==="inline"&&l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Width (px)"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:"Set the width of this inline filter in pixels. Default is 250px."})})]})})]}),l.jsx(p.Input,{size:"xs",type:"number",min:100,max:500,value:e.width??250,onChange:x=>{const b=parseInt(x.target.value,10);isNaN(b)||t({width:b})},className:"w-24"})]})]})}function pJe({filter:e,onUpdate:t}){const[n,r]=v.useState(e.column);v.useEffect(()=>{r(e.column)},[e.column]);function o(){const s=n.trim();if(s&&s!==e.column){const i=!e.title||e.title===e.column;t(i?{column:s,title:s}:{column:s})}}return l.jsx(p.Input,{size:"xs",value:n,onChange:s=>r(s.target.value),onBlur:o,placeholder:"Enter column name",className:"font-mono"})}function gJe({filter:e,onUpdate:t,variant:n="dashboard"}){return G_(e)?l.jsx("div",{className:"rounded-control border border-border/60 bg-muted/30 p-3 text-[12px] text-muted-foreground",children:"Global date filters are not bound to a specific column. Configure the picker type, layout, and scope in the other tabs."}):l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Filter column name"}),l.jsx(pJe,{filter:e,onUpdate:t})]}),l.jsx(bJe,{filter:e,onUpdate:t,variant:n})]})}function bJe({filter:e,onUpdate:t,variant:n="dashboard"}){const[r,o]=v.useState(e.sql),[s,i]=v.useState(e.searchMode||"auto"),a=n==="inline"||n==="document"?"z-[80]":void 0;v.useEffect(()=>{o(e.sql),i(e.searchMode||"auto")},[e]);function c(){t({sql:r})}function u(d){i(d),t({searchMode:d})}return l.jsxs("div",{className:"space-y-4",children:[p.isNumberDataType(e.dataType)&&l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Search Mode"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsxs("div",{className:"space-y-2 text-xs",children:[l.jsxs("p",{children:[l.jsx("strong",{children:"Text Search:"}),' Treats numbers as text (e.g., ZIP codes, IDs). Search for "90210".']}),l.jsxs("p",{children:[l.jsx("strong",{children:"Numeric Operators:"})," Supports comparison operators (e.g., >100, <=50, =100) for quantities, prices."]}),l.jsxs("p",{children:[l.jsx("strong",{children:"Auto-detect:"})," Tries numeric first, falls back to text search."]})]})})]})})]}),l.jsxs(p.Select,{value:s,onValueChange:u,children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{})}),l.jsxs(p.SelectContent,{className:a,children:[l.jsx(p.SelectItem,{value:"text",children:"Text Search"}),l.jsx(p.SelectItem,{value:"numeric",children:"Numeric Operators"}),l.jsx(p.SelectItem,{value:"auto",children:"Auto-detect"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Filter values custom SQL"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:"This SQL will be used to fetch the filter values"})})]})})]}),l.jsx("div",{className:"h-36 w-full overflow-hidden rounded-control border border-input",onBlur:c,onKeyDown:d=>d.stopPropagation(),children:l.jsx(p.CodeEditor,{value:r,onValueChange:o,language:"sql-jinja",embedded:!0,hideLineNumbers:!0,dense:!0,ariaLabel:"Filter values custom SQL",placeholder:`SELECT ${e.column.split(".").pop()||"value"} FROM ... {{ filters | where }}`})})]})]})}function xU(e){return Object.fromEntries(Object.entries(e).filter(t=>typeof t[1]=="string"&&t[1].length>0))}function ju(e){return e.kind==="semantic"?[e.kind,e.domainId,e.datasetId||"",e.datasetName||"",e.connectionId||""].join(":"):[e.kind,e.connectionId,e.databaseName||"",e.schemaName||"",e.tableName].join(":")}function jue(e){return e.kind==="semantic"?xU({connection_id:e.connectionId,domain_id:e.domainId,dataset_id:e.datasetId,dataset_name:e.datasetName}):xU({connection_id:e.connectionId,datamodel_id:"",database_name:e.databaseName,schema_name:e.schemaName,table_name:e.tableName})}function xJe(e,t){const n=new Map;for(const{card:r,sheet:o}of p.getDashboardCardEntries(e)){if(o.kind==="document"||(t==null?void 0:t.kind)==="sheets"&&!t.sheetIds.includes(o.id))continue;const s=Zs.buildDashboardCardSourceIndex(r),i=s.kind==="config"?s.executableSources:s.kind==="sql"?s.pinnedCatalogSources.map(a=>a.source):[];for(const a of i){const c=ju(a);n.has(c)||n.set(c,{key:c,source:a,request:jue(a)})}}return Array.from(n.values())}function yJe(e,t){var o,s;const n=(o=t.column_name)==null?void 0:o.trim(),r=Or.normalizeAnalyticsCatalogDataType(t.data_type);if(!(!n||r==="unknown"))return{kind:"field",field:{name:n,source:{...e},dataType:r,...(s=t.sourceField)!=null&&s.trim()?{sourceField:t.sourceField.trim()}:{}}}}function vJe(e){var n;const t={};for(const{card:r,sheet:o}of p.getDashboardCardEntries(e.dashboard)){if(o.kind==="document"||((n=e.outerScope)==null?void 0:n.kind)==="sheets"&&!e.outerScope.sheetIds.includes(o.id))continue;const s=Zs.buildDashboardCardSourceIndex(r),i=s.kind==="config"?s.executableSources:s.kind==="sql"?s.pinnedCatalogSources.map(u=>u.source):[];if(!i.length)continue;const a=[];let c;for(const u of i){const d=e.metadataBySourceKey.get(ju(u));if(!d||d.status==="unavailable"){c=(d==null?void 0:d.status)==="unavailable"?d.message:"Field metadata is not available yet.";break}for(const f of d.columns){const h=yJe(u,f);h&&a.push(h)}}t[r.id]=c?{status:"metadataUnavailable",message:c}:{status:"ready",targets:a}}return t}const kue=7;function Bj(e){return[ju(e.field.source),e.field.name,e.field.sourceField||""].join("::")}function Q1(e){const t=e.field.source;return t.kind==="semantic"?t.label||t.datasetName||t.datasetId||"Dataset":[t.schemaName,t.tableName].filter(Boolean).join(".")}function wJe(e){switch(e.status){case"suggested":return{label:"Auto",className:"text-muted-foreground"};case"mapped":return{label:"Mapped",className:"text-muted-foreground"};case"excluded":return{label:"Not applied",className:"text-muted-foreground"};case"notApplicable":return{label:"Not applicable",className:"text-muted-foreground"};case"pendingSource":return{label:"Pending source",className:"text-muted-foreground"};case"metadataUnavailable":return{label:"Fields unavailable",className:"text-amber-700 dark:text-amber-400"};case"invalidMapping":return{label:"Invalid",className:"text-destructive"};case"needsMapping":return{label:"Needs mapping",className:"font-medium text-amber-700 dark:text-amber-400"}}}function CJe(e){if(typeof e!="string"||!e)return;const t=e.replace(/([A-Z])/g," $1").trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function SJe(e){var r;const t=(r=e.config)==null?void 0:r.queryBaseSource,n=[CJe(e.type),(t==null?void 0:t.datasetName)||(t==null?void 0:t.tableName)].filter(Boolean);return n.length?n.join(" · "):void 0}function NJe({target:e}){return l.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[11px]",children:[l.jsx(Go,{className:"h-3 w-3 shrink-0 text-muted-foreground/70"}),l.jsx("span",{className:"truncate text-muted-foreground",children:Q1(e)}),l.jsx("span",{className:"shrink-0 text-border",children:"·"}),l.jsx("span",{className:"truncate font-medium text-foreground",children:e.field.name})]})}function jJe({row:e,onPickTarget:t,onExclude:n}){const[r,o]=te.useState(""),s=e.candidates.length>kue,i=r.trim().toLowerCase(),a=e.candidates.filter(f=>!i||f.field.name.toLowerCase().includes(i)||Q1(f).toLowerCase().includes(i)),c=[];for(const f of a){const h=Q1(f);c.includes(h)||c.push(h)}const d=!(e.executionKind==="sql"&&e.status==="suggested")&&e.selectedTarget?Bj(e.selectedTarget):void 0;return l.jsxs("div",{role:"listbox","aria-label":"Field candidates",className:"flex flex-col",children:[s&&l.jsx("div",{className:"shrink-0 border-b border-border/60 p-1.5",children:l.jsxs("div",{className:"flex h-7 items-center gap-1.5 rounded-control border border-border px-2",children:[l.jsx(Mt.Search,{className:"h-3 w-3 shrink-0 text-muted-foreground/70"}),l.jsx("input",{autoFocus:!0,value:r,onChange:f=>o(f.target.value),placeholder:`Search ${e.candidates.length} fields`,className:"w-full bg-transparent text-[11px] text-foreground outline-none placeholder:text-[hsl(var(--semaphor-placeholder-foreground))]"})]})}),l.jsxs("div",{className:"max-h-[240px] overflow-y-auto p-1",children:[c.map(f=>{const h=a.filter(m=>Q1(m)===f);return l.jsxs("div",{children:[l.jsxs("p",{className:"px-2 pb-0.5 pt-1.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground/80",children:[f,s?` · ${h.length}`:""]}),h.map(m=>{const g=Bj(m);return l.jsxs("button",{type:"button",role:"option","aria-selected":d===g,onClick:()=>t(m),className:"flex w-full items-center gap-2 rounded-[4px] px-2 py-1.5 text-left text-[11px] hover:bg-muted/60",children:[l.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:m.field.name}),d===g&&l.jsx(p.Check,{className:"h-3 w-3 shrink-0 text-muted-foreground"})]},g)})]},f)}),a.length===0&&l.jsxs("p",{className:"px-2 py-3 text-center text-[11px] text-muted-foreground",children:["No fields match “",r,"”"]})]}),l.jsx("div",{className:"shrink-0 border-t border-border/60 p-1",children:l.jsxs("button",{type:"button",role:"option","aria-selected":e.status==="excluded",onClick:n,className:"flex w-full items-center gap-2 rounded-[4px] px-2 py-1.5 text-left text-[11px] text-muted-foreground hover:bg-muted/60",children:[l.jsx(Ie.X,{className:"h-3 w-3 shrink-0"})," Don't apply this filter",e.status==="excluded"&&l.jsx(p.Check,{className:"ml-auto h-3 w-3 shrink-0 text-muted-foreground"})]})})]})}function kJe({mode:e,row:t,cardTitle:n,cardMeta:r,onDecision:o,onRetry:s}){const[i,a]=te.useState(!1),c=wJe(t),u=t.executionKind!=="unconfigured"&&t.status!=="pendingSource"&&t.status!=="notApplicable"&&t.status!=="metadataUnavailable",d=t.status==="invalidMapping"?"border-destructive/60":t.status==="needsMapping"?"border-amber-400 dark:border-amber-700/60":t.status==="excluded"?"border-dashed border-border":"border-border hover:border-muted-foreground/40",f=u?l.jsxs(p.Popover,{open:i,onOpenChange:a,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs("button",{type:"button",role:"combobox","aria-expanded":i,"aria-label":`Mapping for ${n}`,className:p.cn("flex h-7 w-full items-center justify-between gap-1.5 rounded-control border bg-transparent px-2 text-left transition-colors",d,i&&"bg-muted/40"),children:[t.status==="excluded"?l.jsx("span",{className:"text-[11px] text-muted-foreground/80",children:"Not applied"}):t.executionKind==="sql"&&t.status==="suggested"&&t.automaticFieldName?l.jsxs("span",{className:"truncate text-[11px] text-muted-foreground",children:["Auto ·"," ",l.jsx("span",{className:"font-medium text-foreground",children:t.automaticFieldName})]}):t.selectedTarget?l.jsx(NJe,{target:t.selectedTarget}):l.jsx("span",{className:"text-[11px] font-medium text-amber-700 dark:text-amber-400",children:"Choose a field"}),l.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[t.status==="invalidMapping"&&l.jsx(Yo,{className:"h-3 w-3 text-destructive"}),l.jsx(Ie.ChevronDown,{className:"h-3 w-3 text-muted-foreground/70"})]})]})}),l.jsx(p.PopoverContent,{align:"end",sideOffset:4,className:p.cn("z-[80] rounded-control border-border/80 p-0 shadow-[0_10px_28px_rgba(0,0,0,0.14)] dark:shadow-[0_10px_28px_rgba(0,0,0,0.5)]",t.candidates.length>kue?"w-[300px]":"w-[270px]"),children:l.jsx(jJe,{row:t,onPickTarget:h=>{const m=t.status!=="excluded"&&!(t.executionKind==="sql"&&t.status==="suggested")&&t.selectedTarget?Bj(t.selectedTarget):void 0;Bj(h)!==m&&o({kind:"bound",target:h}),a(!1)},onExclude:()=>{t.status!=="excluded"&&o({kind:"excluded"}),a(!1)}})})]}):l.jsxs("div",{className:"flex h-7 items-center justify-between gap-2 rounded-control border border-dashed border-border px-2 text-[11px] text-muted-foreground",children:[l.jsx("span",{className:"truncate",children:t.guidanceMessage||(t.status==="pendingSource"?"Select a card data source first":t.status==="metadataUnavailable"?"Fields could not be loaded":t.status==="notApplicable"?"Not applicable":"No compatible field")}),t.status==="metadataUnavailable"&&l.jsxs("button",{type:"button",onClick:s,className:"inline-flex shrink-0 items-center gap-1 text-[11px] font-medium text-foreground/70 hover:text-foreground",children:[l.jsx(_a,{className:"h-3 w-3"})," Retry"]})]});return l.jsxs("div",{children:[l.jsxs("div",{className:p.cn("grid w-full items-center gap-3 px-4 py-2",e==="popover"?"grid-cols-[minmax(0,1fr)_238px]":"grid-cols-[minmax(180px,240px)_minmax(0,1fr)_90px]"),children:[l.jsxs("span",{className:"min-w-0",children:[l.jsx("span",{className:"block truncate text-[12px] font-medium text-foreground",children:n}),r&&l.jsx("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:r})]}),l.jsx("span",{className:"relative block min-w-0",children:f}),e==="table"&&l.jsx("span",{className:p.cn("text-[11px]",c.className),children:c.label})]}),t.status==="invalidMapping"&&l.jsxs("div",{className:"mx-4 mb-2 rounded-control border border-destructive/30 bg-destructive/5 p-2.5",children:[l.jsxs("p",{className:"flex items-start gap-1.5 text-[11px] font-medium leading-4 text-destructive",children:[l.jsx(Yo,{className:"mt-0.5 h-3 w-3 shrink-0"})," This mapping is no longer valid"]}),l.jsx("p",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:"The saved field no longer resolves for this card query. Choose a field from this card, or set it to Not applied."})]}),t.status==="metadataUnavailable"&&t.metadataMessage&&l.jsx("p",{className:"mx-4 mb-2 text-[10px] leading-4 text-muted-foreground",children:t.metadataMessage}),t.executionKind==="sql"&&t.status==="mapped"&&l.jsx("p",{className:"mx-4 mb-2 text-[10px] leading-4 text-muted-foreground",children:"Fields come from the card's pinned sources. Semaphor does not verify that your custom SQL references the selected field."})]})}function IJe({dashboard:e,filterTitle:t,isLoading:n,draftResult:r,onDecision:o,onRetry:s}){var S;const[i,a]=te.useState(""),[c,u]=te.useState(!1),d=p.getDashboardCardEntries(e),f=new Map(d.map(j=>[j.card.id,j])),h=r!=null&&r.ok?r.draft.rows:[],m=i.trim().toLowerCase(),x=(e.sheets||[]).map(j=>({sheet:j,rows:h.filter(I=>{var T;if(I.sheetId!==j.id)return!1;const k=((T=f.get(I.cardId))==null?void 0:T.card.title)||I.cardId;return!m||k.toLowerCase().includes(m)})})).filter(j=>j.rows.length>0),b=h.filter(j=>(j.status==="mapped"||j.status==="suggested")&&j.selectedTarget).length,y=h.filter(j=>j.status==="needsMapping"||j.status==="metadataUnavailable").length,w=h.filter(j=>j.status==="excluded"||j.status==="notApplicable").length,C=h.filter(j=>j.status==="invalidMapping").length,N=j=>x.map(({sheet:I,rows:k})=>l.jsxs("div",{children:[l.jsxs("p",{className:"flex items-center gap-1.5 border-y border-border/60 bg-muted/40 px-4 py-1 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground first:border-t-0",children:[I.title||I.id," · ",k.length," ",k.length===1?"card":"cards"]}),l.jsx("div",{className:"divide-y divide-border/60",children:k.map(T=>{const _=f.get(T.cardId);return l.jsx(kJe,{mode:j,row:T,cardTitle:(_==null?void 0:_.card.title)||T.cardId,cardMeta:_?SJe(_.card):void 0,onDecision:E=>o(T.cardId,E),onRetry:s},T.cardId)})})]},I.id));return n?l.jsxs("div",{className:"flex items-center justify-center gap-2 py-12 text-[12px] text-muted-foreground",children:[l.jsx(p.LoaderCircle,{className:"h-4 w-4 animate-spin"})," Loading card fields…"]}):l.jsxs("div",{children:[r&&!r.ok&&l.jsx("div",{className:"mx-4 my-3 rounded-control border border-destructive/40 bg-destructive/5 px-3 py-2 text-[11px] text-destructive",children:(S=r.issues[0])==null?void 0:S.message}),h.length>0&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5",children:[l.jsxs("div",{className:"flex h-7 min-w-0 flex-1 items-center gap-2 rounded-control border border-border px-2",children:[l.jsx(Mt.Search,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/70"}),l.jsx("input",{value:i,onChange:j=>a(j.target.value),placeholder:"Search cards","aria-label":"Search cards",className:"w-full bg-transparent text-[12px] text-foreground outline-none placeholder:text-[hsl(var(--semaphor-placeholder-foreground))]"})]}),l.jsxs(p.Button,{variant:"outline",size:"xs",onClick:()=>u(!0),className:"shrink-0 gap-1 text-[10px] font-medium text-muted-foreground hover:text-foreground",children:[l.jsx(Mt.Maximize2,{className:"h-3 w-3"})," Review as table"]})]}),N("popover"),x.length===0&&l.jsxs("p",{className:"py-8 text-center text-[12px] text-muted-foreground",children:["No cards match “",i,"”"]})]}),(r==null?void 0:r.ok)&&h.length===0&&l.jsx("p",{className:"py-8 text-center text-[12px] text-muted-foreground",children:"No cards are in this filter's current sheet scope."}),l.jsx(So,{open:c,onOpenChange:u,children:l.jsxs(po,{className:"z-[90] w-[min(880px,92vw)] max-w-none gap-0 overflow-hidden p-0",children:[l.jsx("div",{className:"border-b border-border/60 px-4 py-3",children:l.jsx(go,{className:"text-[13px] font-semibold text-foreground",children:t?`${t} · Card mapping`:"Card mapping"})}),l.jsxs("div",{className:"grid grid-cols-[minmax(180px,240px)_minmax(0,1fr)_90px] gap-3 border-b border-border/60 px-4 py-1.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:[l.jsx("span",{children:"Card"}),l.jsx("span",{children:"Binding"}),l.jsx("span",{children:"Status"})]}),l.jsx("div",{className:"max-h-[60vh] min-h-0 overflow-y-auto",children:N("table")}),l.jsxs("div",{className:"flex items-center justify-between border-t border-border/60 px-4 py-2.5",children:[l.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[b," covered · ",y," to review · ",w," ","not applied",C>0&&l.jsxs("span",{className:"text-destructive",children:[" ","· ",C," invalid"]})]}),l.jsx(p.Button,{size:"xs",onClick:()=>u(!1),children:"Done"})]})]})})]})}function _Je(e){var f;const t=p.useDashboardStore(h=>h.dashboard),n=p.useDashboardStore(h=>h.authToken),{tokenProps:r}=It(),o=v.useMemo(()=>xJe(t,e.outerScope),[t,e.outerScope]),s=!!(n!=null&&n.accessToken),i=Fm({queries:o.map(h=>({queryKey:["dashboard-filter-mapping-columns",h.key],queryFn:()=>p.getRequest(`${r.apiServiceUrl}/v1/columns`,(n==null?void 0:n.accessToken)||"",h.request),enabled:e.enabled&&s,staleTime:6e4}))}),a=e.enabled&&s&&i.some(h=>!h.data&&!h.error),c=v.useMemo(()=>{const h=new Map;return o.forEach((m,g)=>{const x=i[g];e.enabled&&(s?x!=null&&x.error?h.set(m.key,{status:"unavailable",message:x.error instanceof Error?x.error.message:"Field metadata could not be loaded."}):x!=null&&x.data&&h.set(m.key,{status:"ready",columns:Array.isArray(x.data.columns)?x.data.columns:[]}):h.set(m.key,{status:"unavailable",message:"Dashboard authentication is not ready for field metadata."}))}),h},[s,e.enabled,i,o]),u=v.useMemo(()=>vJe({dashboard:t,metadataBySourceKey:c,outerScope:e.outerScope}),[t,c,e.outerScope]),d=v.useMemo(()=>{const h=e.optionSource;if(h!=null&&h.valueField.name){const x=h.valueField;return{name:x.name,source:A5(x,h.source)}}const m=i_e(e.filter),g=P5(e.filter);return m&&g?{...m,source:g}:m},[e.filter,e.optionSource]);return{candidatesByCardId:u,selectionField:d,selectionDataType:((f=e.optionSource)==null?void 0:f.valueField.dataType)||e.filter.dataType,isLoading:a,retry:()=>{i.forEach(h=>{h.error&&h.refetch()})}}}function TJe(e){const t=e.hasPersistedApplication||e.hasDraftMappingChanges,n=e.optionSourceChanged&&!e.selectionIdentityChanged&&!e.hasDraftMappingChanges&&!e.scopeChanged;return t&&!n?"mapping":e.hasAuthoredOptionSource?"optionSource":"ordinary"}function EJe(e,t,n){if(!(!t.defaultSettingsChanged&&!t.defaultComparisonChanged&&!t.optionSourceChanged&&!t.selectionIdentityChanged))return{defaultValueChanged:t.defaultSettingsChanged,...t.defaultSettingsChanged?{defaultFilterValue:p.buildFilterValueFromDefaults(e,n)}:{},defaultComparisonChanged:t.defaultComparisonChanged,defaultComparisonSelection:t.defaultComparisonSelection,target:t.runtimeTarget,optionSourceChanged:t.optionSourceChanged,optionSource:t.optionSource,selectionIdentityChanged:t.selectionIdentityChanged}}function DJe(e){const t=p.useDashboardStore(k=>k.dashboard),[n,r]=v.useState(!1),[o,s]=v.useState({}),[i,a]=v.useState([]),{updateFilter:c,addOrUpdateFilterValue:u,removeFilterValues:d,acceptDashboardFilterOptionSource:f,acceptDashboardFilterMapping:h,setDefaultDashboardInputComparisonSelection:m}=p.useDashboardActions(),g=v.useMemo(()=>e.capable?p.findMappedDashboardFilterInput(t,e.filter.id):void 0,[t,e.capable,e.filter.id]),x=v.useMemo(()=>!e.scopeChanged&&g&&(g.scope.kind==="allSheets"||g.scope.kind==="sheets")?g.scope:p.buildDashboardFilterMappingOuterScope({filter:e.stagedFilter,dashboard:t}),[t,e.scopeChanged,e.stagedFilter,g]),b=_Je({filter:e.stagedFilter,enabled:!!(e.open&&e.capable),outerScope:x,optionSource:e.optionSource}),y=v.useMemo(()=>({filterId:e.filter.id,candidatesByCardId:b.candidatesByCardId,selectionField:b.selectionField,selectionDataType:b.selectionDataType,revalidatePersistedTargets:e.selectionIdentityChanged,decisionsByCardId:o,...e.scopeChanged?{outerScope:x}:{}}),[o,b.candidatesByCardId,b.selectionField,b.selectionDataType,x,e.filter.id,e.selectionIdentityChanged,e.scopeChanged]),w=v.useMemo(()=>({...t,filters:(t.filters||[]).map(k=>k.id===e.filter.id?e.stagedFilter:k)}),[t,e.filter.id,e.stagedFilter]),C=v.useMemo(()=>e.capable?p.buildDashboardFilterMappingDraft({dashboard:w,request:y}):void 0,[w,e.capable,y]),N=v.useCallback(()=>{r(!1),s({}),a([])},[]),S=v.useCallback((k,T)=>{s(_=>({..._,[k]:T})),r(!0),a([])},[]),j=v.useCallback(()=>a([]),[]),I=v.useCallback((k,T,_)=>{const E=EJe(k,T,e.dashboardTimezone),D=TJe({hasPersistedApplication:!!g,hasDraftMappingChanges:n,hasAuthoredOptionSource:!!e.optionSource,optionSourceChanged:!!T.optionSourceChanged,selectionIdentityChanged:!!T.selectionIdentityChanged,scopeChanged:e.scopeChanged});if(D==="mapping"){if(b.isLoading)return a([{code:"metadataUnavailable",filterId:e.filter.id,message:"Card field metadata is still loading."}]),!1;const M=h(y,k,E);if(!M.ok)return a(M.issues),!1}else if(D==="optionSource"){if(!T.optionSource)return a([{code:"invalidTarget",filterId:e.filter.id,message:"The Option Source is incomplete."}]),!1;const M=f(k,T.optionSource,E,_);if(!M.ok)return a(M.issues),!1}else c(k);if(D==="ordinary"&&T.defaultSettingsChanged){const M=p.buildFilterValueFromDefaults(k,e.dashboardTimezone);M?u(M):d(e.filter.id)}if(D==="ordinary"&&T.defaultComparisonChanged){const M=ja(p.useDashboardStore.getState().dashboard,e.filter.id);M&&p.isComparisonCapableDashboardDateInput(M)&&p.canAddressDashboardInputRuntimeSlot(M,T.runtimeTarget)&&m(M,T.runtimeTarget,T.defaultComparisonSelection)}return!0},[h,f,u,n,b.isLoading,e.dashboardTimezone,e.filter.id,e.optionSource,e.scopeChanged,g,d,y,m,c]);return{mappingActive:!!(g||n),hasDraftChanges:n,hasPersistedApplication:!!g,isLoading:b.isLoading,dashboardWithStagedFilter:w,draftResult:C,issues:i,retry:b.retry,decide:S,clearIssues:j,reset:N,acceptAuthoringChanges:I}}const MJe=7;function TM(e){return e.kind==="semantic"?e.datasetName||e.datasetId||e.domainId:[e.databaseName,e.schemaName,e.tableName].filter(Boolean).join(".")}function yU(e,t){var n,r;return((n=e.source)==null?void 0:n.kind)==="semantic"||((r=e.source)==null?void 0:r.kind)==="physical"?e.source:t}function Vj(e){return`${ju(e.source)}::${e.name}`}function vU({ariaLabel:e,value:t,fields:n,onPick:r,disabled:o=!1,isLoading:s=!1}){const[i,a]=v.useState(!1),[c,u]=v.useState(""),d=n.length>MJe,f=c.trim().toLowerCase(),h=n.filter(x=>!f||x.name.toLowerCase().includes(f)||TM(x.source).toLowerCase().includes(f)),m=new Map;for(const x of h){const b=ju(x.source),y=m.get(b)||{label:TM(x.source),fields:[]};y.fields.push(x),m.set(b,y)}const g=Vj(t);return l.jsxs(p.Popover,{open:i,onOpenChange:x=>{a(x),x||u("")},children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs("button",{type:"button",role:"combobox","aria-expanded":i,"aria-label":e,disabled:o,className:p.cn("flex h-7 w-full items-center justify-between gap-2 rounded-control border border-border bg-transparent px-2 text-left transition-colors hover:border-muted-foreground/40",i&&"bg-muted/40"),children:[l.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[12px]",children:[l.jsx("span",{className:"truncate text-muted-foreground",children:TM(t.source)}),l.jsx("span",{className:"shrink-0 text-border",children:"·"}),l.jsx("span",{className:"truncate font-medium text-foreground",children:t.name})]}),s?l.jsx(p.LoaderCircle,{role:"status","aria-label":"Loading fields",className:"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground/70"}):l.jsx(Ie.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/70"})]})}),l.jsx(p.PopoverContent,{align:"start",sideOffset:4,className:p.cn("z-[80] rounded-control border-border/80 p-0 shadow-[0_10px_28px_rgba(0,0,0,0.14)] dark:shadow-[0_10px_28px_rgba(0,0,0,0.5)]",d?"w-[300px]":"w-[270px]"),children:l.jsxs("div",{role:"listbox","aria-label":e,className:"flex flex-col",children:[d&&l.jsx("div",{className:"shrink-0 border-b border-border/60 p-1.5",children:l.jsxs("div",{className:"flex h-7 items-center gap-1.5 rounded-control border border-border px-2",children:[l.jsx(Mt.Search,{className:"h-3 w-3 shrink-0 text-muted-foreground/70"}),l.jsx("input",{autoFocus:!0,value:c,onChange:x=>u(x.target.value),placeholder:`Search ${n.length} fields`,className:"w-full bg-transparent text-[11px] text-foreground outline-none placeholder:text-[hsl(var(--semaphor-placeholder-foreground))]"})]})}),l.jsxs("div",{className:"max-h-[240px] overflow-y-auto p-1",children:[[...m.entries()].map(([x,b])=>l.jsxs("div",{children:[l.jsxs("p",{className:"px-2 pb-0.5 pt-1.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground/80",children:[b.label,d?` · ${b.fields.length}`:""]}),b.fields.map(y=>{const w=Vj(y);return l.jsxs("button",{type:"button",role:"option","aria-selected":w===g,onClick:()=>{r(y),a(!1),u("")},className:"flex w-full items-center gap-2 rounded-[4px] px-2 py-1.5 text-left text-[11px] hover:bg-muted/60",children:[l.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:y.name}),w===g&&l.jsx(p.Check,{className:"h-3 w-3 shrink-0 text-muted-foreground"})]},w)})]},x)),h.length===0&&l.jsx("p",{className:"px-2 py-3 text-center text-[11px] text-muted-foreground",children:n.length===0?"No fields available from the selected option source":`No fields match “${c}”`})]})]})})]})}function RJe({value:e,fieldChoices:t,isLoading:n=!1,error:r,onRetry:o,onChange:s}){const i={...e.labelField,source:yU(e.labelField,e.source)},a={...e.valueField,source:yU(e.valueField,e.source)},[c,u]=v.useState(Vj(i)!==Vj(a)),d=ju(e.source),f=t.filter(h=>ju(h.source)===d);return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Option Value Field"}),l.jsx(vU,{ariaLabel:"Option value field",value:a,fields:f,disabled:n||!!r,isLoading:n,onPick:h=>{s({source:e.source,valueField:{...h},labelField:c?e.labelField:{...h}},{changedValueField:h})}}),r?l.jsxs("div",{role:"alert",className:"flex items-center justify-between gap-2 text-[11px] text-destructive",children:[l.jsx("span",{children:"Fields could not be loaded."}),o?l.jsxs(p.Button,{type:"button",variant:"ghost",size:"xs",onClick:o,className:"h-6 gap-1 px-1.5",children:[l.jsx(_a,{className:"h-3 w-3"}),"Retry"]}):null]}):null]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(An,{id:"useOptionLabelField",checked:c,onCheckedChange:h=>{const m=h===!0;u(m),m||s({...e,labelField:{...e.valueField}})}}),l.jsx(p.Label,{htmlFor:"useOptionLabelField",className:"cursor-pointer text-[11px] text-muted-foreground",children:"Use a different field for the option label"})]}),c&&l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Option Label Field"}),l.jsx(vU,{ariaLabel:"Option label field",value:i,fields:f,disabled:n||!!r,isLoading:n,onPick:h=>s({...e,labelField:{...h}})})]})]})]})}function AJe(e){const t=p.useDashboardStore(s=>s.authToken),{tokenProps:n}=It(),r=qn({queryKey:["dashboard-filter-option-source-columns",e.optionSource?ju(e.optionSource.source):""],queryFn:()=>p.getRequest(`${n.apiServiceUrl}/v1/columns`,(t==null?void 0:t.accessToken)||"",jue(e.optionSource.source)),enabled:!!(e.enabled&&e.optionSource&&(t!=null&&t.accessToken)),staleTime:6e4});return{fields:v.useMemo(()=>{var i;const s=e.optionSource;return!s||!Array.isArray((i=r.data)==null?void 0:i.columns)?[]:r.data.columns.flatMap(a=>{var d;const c=(d=a.column_name)==null?void 0:d.trim(),u=Or.normalizeAnalyticsCatalogDataType(a.data_type);return!c||u==="unknown"?[]:[{name:c,dataType:u,source:{...s.source}}]})},[e.optionSource,r.data]),isLoading:r.isLoading,error:r.error,retry:r.refetch}}function wU(e){var n,r;const t=P5(e)||(()=>{const o=(e.qualifiedTableName||e.table||"options").split(".").filter(Boolean),s=o[o.length-1]||"options";return{kind:"physical",connectionId:e.connectionId,tableName:s,...o.length>=2?{schemaName:o[o.length-2]}:{},...o.length>=3?{databaseName:o[o.length-3]}:e.database?{databaseName:e.database}:{}}})();return{source:t,labelField:{name:((n=e.fieldMeta)==null?void 0:n.name)||e.column.split(".").pop()||e.column,dataType:"string",source:t},valueField:{name:((r=e.fieldMeta)==null?void 0:r.name)||e.column.split(".").pop()||e.column,dataType:p.getDataType(e.dataType),source:t}}}function og(e,t){const n=A5(e,t);return[ju(n),e.name,e.dataType||""].join("::")}function PJe(e,t){return og(e.valueField,e.source)===og(t.valueField,t.source)&&og(e.labelField,e.source)===og(t.labelField,t.source)}const FJe=[{id:"basic",label:"Basic"},{id:"scope",label:"Scope"},{id:"mapping",label:"Cards"},{id:"advanced",label:"Advanced"}];function H$({filter:e,variant:t="dashboard",onAccept:n,inputVariableName:r,reservedInputVariableNames:o,isDashboardFilterReference:s=!1,open:i,onOpenChange:a,trigger:c,isEditing:u=!1,filterQueryContext:d,onDelete:f}){var se,he;const h=ml("interactive");function m(ge){if(!ge)return"Unknown";const ke=p.getDataType(ge),De=ke==="date"?"Datetime":ke==="string"?"Text":ke==="number"?"Number":ke==="boolean"?"Boolean":ke==="json"?"JSON":"Geo";return/nullable/i.test(ge)?`${De} (nullable)`:De}const[g,x]=v.useState(!1),b=i??g,y=a??x,[w,C]=v.useState("basic"),N="kind"in e&&e.kind==="global-date",[S,j]=v.useState({}),[I,k]=v.useState({}),[T,_]=v.useState(),[E,D]=v.useState(!1),[M,P]=v.useState(!1),[A,L]=v.useState({mode:"off"}),[O,B]=v.useState(!1),[H,R]=v.useState(!1),V=p.useDashboardStore(ge=>ge.dashboard),z=p.useDashboardStore(ge=>ge.selectedSheetId),{updateFilter:F,addOrUpdateFilterValue:G,removeFilterValues:q,setDefaultDashboardInputComparisonSelection:Y}=p.useDashboardActions(),K=t==="dashboard"&&!N&&(!n||s),$=v.useMemo(()=>{if(t!=="dashboard")return;const ge=ja(V,e.id);if(!(!ge||!p.isComparisonCapableDashboardDateInput(ge)||!p.canAddressDashboardInputRuntimeSlot(ge,{sheetId:z})))return ge},[V,e.id,z,t]),X=v.useMemo(()=>ja(V,e.id),[V,e.id]),W=v.useMemo(()=>FJe.filter(ge=>!(t!=="dashboard"&&ge.id==="scope"||!K&&ge.id==="mapping"||N&&ge.id==="advanced"&&r===void 0)),[r,N,K,t]),{tokenProps:U}=It(),Z=bl()??void 0,Q={...e,...S},J=X!=null&&X.optionSource||E?T:void 0,{data:re}=x$(Q,{filterQueryContext:d,optionSource:J,currentSelectionPolicy:"exclude"}),de=["sheetId","applyToSheetIds","excludeSheetIds"].some(ge=>Object.prototype.hasOwnProperty.call(S,ge)),le=DJe({filter:e,stagedFilter:Q,dashboardTimezone:Z,open:b,capable:K,scopeChanged:de,optionSource:J,selectionIdentityChanged:M}),ce=AJe({optionSource:T,enabled:!!(b&&K)}),oe=le.reset,fe=K&&((se=le.draftResult)!=null&&se.ok)?le.draftResult.draft.rows:[],we=fe.filter(ge=>ge.status==="needsMapping"||ge.status==="metadataUnavailable").length,pe=fe.filter(ge=>ge.status==="invalidMapping").length;function ne(){let ge={...S};I.variableName&&K&&(ge={...ge,variableName:I.variableName});const ke=Object.prototype.hasOwnProperty.call(ge,"defaultValues")||Object.prototype.hasOwnProperty.call(ge,"defaultDateFilter");if(t==="inline"&&"width"in ge){const Re=ge.width;ge={...ge,width:Math.min(500,Math.max(100,Re))}}if(K){const Re={...e,...ge};if(!le.acceptAuthoringChanges(Re,{defaultSettingsChanged:ke,defaultComparisonChanged:O,defaultComparisonSelection:A.mode==="off"?void 0:A,runtimeTarget:{sheetId:z},optionSourceChanged:E,optionSource:T,selectionIdentityChanged:M},I)){C("mapping");return}}else if(n)n(ge,I);else{const Re={...e,...ge};if(F(Re),ke){const Ve=p.buildFilterValueFromDefaults(Re,Z);Ve?G(Ve):q(e.id)}}const De=K?ja(p.useDashboardStore.getState().dashboard,e.id):$;O&&!K&&De&&Y(De,{sheetId:z},A.mode==="off"?void 0:A),j({}),k({}),_(void 0),D(!1),P(!1),B(!1),y(!1)}function Se(ge){j(ke=>({...ke,...ge})),le.clearIssues()}function ue(ge){k(ke=>({...ke,...ge}))}v.useEffect(()=>{var ge;b&&(R(!1),j({}),k({}),_((X==null?void 0:X.optionSource)||wU(e)),D(!1),P(!1),L($?((ge=p.getDashboardInputRuntimeSlot(V.defaultInputValues,$,{sheetId:z}))==null?void 0:ge.comparisonSelection)||{mode:"off"}:{mode:"off"}),B(!1),oe(),C("basic"))},[V.defaultInputValues,$,e,X,b,oe,z]);const ie=N?e.title||p.DEFAULT_GLOBAL_DATE_FILTER_TITLE:e.column.split(".").pop()||e.column,ee=N?ie:e.column,ae=N?"Global date":m(e.dataType);return l.jsxs(p.Popover,{open:b,onOpenChange:y,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:c??l.jsx("button",{type:"button",className:p.cn("rounded p-0.5 hover:bg-muted focus:visible focus:outline-none focus:ring-1 focus:ring-ring",u?"visible":"invisible group-hover:visible"),"aria-label":"Filter settings",children:l.jsx(mf,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})}),l.jsxs(p.PopoverContent,{collisionPadding:12,onMouseDown:ge=>{H||ge.stopPropagation()},onDoubleClick:ge=>ge.stopPropagation(),style:h.controlStyle,className:p.cn("flex h-[440px] max-h-[85vh] flex-col overflow-hidden rounded-control border border-border/60 p-0 shadow-[0_10px_28px_rgba(0,0,0,0.14)] transition-[width] dark:shadow-[0_10px_28px_rgba(0,0,0,0.5)]",w==="mapping"?"w-[620px]":"w-[480px]",t==="inline"||t==="document"?"z-[70]":"z-50"),children:[l.jsxs("div",{className:"flex min-h-12 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3 py-1.5",children:[l.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[l.jsx(Hd,{"aria-hidden":!0,className:"mt-1 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[l.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",title:ie,children:ie}),l.jsx("span",{className:"shrink-0 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",title:e.dataType,children:ae})]}),l.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] leading-3 text-muted-foreground/70",title:ee,children:ee})]})]}),l.jsx("button",{type:"button",onClick:()=>y(!1),"aria-label":"Close",className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx("svg",{"aria-hidden":!0,viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:1.75,className:"h-3.5 w-3.5",children:l.jsx("path",{d:"M5 5l10 10M15 5L5 15",strokeLinecap:"round"})})})]}),l.jsx("nav",{role:"tablist","aria-label":"Filter settings sections",className:"flex h-9 shrink-0 items-stretch gap-4 border-b border-border/60 px-4",children:W.map(ge=>l.jsxs("button",{role:"tab","aria-selected":w===ge.id,onClick:()=>C(ge.id),className:p.cn("relative -mb-px inline-flex items-center text-[13px] transition-colors focus-visible:outline-none",w===ge.id?"font-medium text-foreground":"text-muted-foreground hover:text-foreground"),children:[ge.label,w===ge.id&&l.jsx("span",{"aria-hidden":!0,className:"absolute inset-x-0 -bottom-px h-[2px] bg-foreground"})]},ge.id))}),l.jsxs("div",{className:p.cn("min-h-0 flex-1 overflow-y-auto",w==="mapping"?"":"px-4 py-4"),children:[w==="basic"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx(fJe,{filter:Q,onUpdate:Se,showFilterId:!0,filterOptionsData:re,optionLabelFieldName:T==null?void 0:T.labelField.name,timezone:Z,variant:t,defaultComparisonSelection:$?A:void 0,onDefaultComparisonChange:$?ge=>{L(ge),B(!0)}:void 0,onDefaultDatePickerOpenChange:R,afterLabelSlot:K&&T?l.jsx(RJe,{value:T,fieldChoices:ce.fields,isLoading:ce.isLoading,error:ce.error,onRetry:()=>void ce.retry(),onChange:(ge,ke)=>{const De=(X==null?void 0:X.optionSource)||wU(e);_(ge),D(!PJe(ge,De)),P(og(ge.valueField,ge.source)!==og(De.valueField,De.source)),le.clearIssues();const Re=ke==null?void 0:ke.changedValueField;if(Re){const Ve=Re.source.kind==="semantic"?Re.source.datasetName||Re.source.datasetId:void 0,ve=Ve?`${Ve}.${Re.name}`:Re.name;Se({column:ve,dataType:Re.dataType,operation:p.getDataType(Re.dataType)==="date"?"between":"in",fieldMeta:{name:Re.name,qualifiedFieldName:ve,dataType:Re.dataType,...Re.source.kind==="semantic"?{entityName:Ve,entityId:Re.source.datasetId}:{entityName:Re.source.tableName}},defaultValues:void 0,defaultDateFilter:void 0})}}}):void 0}),l.jsx(mJe,{filter:Q,onUpdate:Se,variant:t})]}),w==="advanced"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx(hJe,{variableName:I.variableName??r,reservedVariableNames:o,onUpdateInputMetadata:r===void 0?void 0:ue}),l.jsx(gJe,{filter:Q,onUpdate:Se,variant:t})]}),w==="scope"&&t==="dashboard"&&l.jsx(ZQe,{filter:Q,onUpdate:Se,cardScopeMode:le.mappingActive?"mapping":"editable"}),w==="mapping"&&K&&l.jsx(IJe,{dashboard:le.dashboardWithStagedFilter,filterTitle:ie,isLoading:le.isLoading,draftResult:le.draftResult,onDecision:le.decide,onRetry:le.retry})]}),l.jsxs("div",{className:"shrink-0 border-t border-border/60 bg-background px-4 py-2.5",children:[K&&(le.issues.length>0||pe>0)&&l.jsxs("p",{className:"mb-2 flex items-start gap-1.5 text-[11px] leading-4 text-destructive",children:[l.jsx(Yo,{className:"mt-0.5 h-3 w-3 shrink-0"}),((he=le.issues[0])==null?void 0:he.message)||`${pe} ${pe===1?"mapping is":"mappings are"} no longer valid. Resolve to save.`]}),K&&le.issues.length===0&&pe===0&&we>0&&l.jsxs("p",{className:"mb-2 flex items-start gap-1.5 text-[11px] leading-4 text-muted-foreground",children:[l.jsx(p.Info,{className:"mt-0.5 h-3 w-3 shrink-0"}),we," ",we===1?"card":"cards"," will not receive this filter until mapped."]}),l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f?l.jsx(p.Button,{variant:"outline",size:"xs",onClick:()=>{f(),y(!1)},className:"text-destructive hover:border-destructive/40 hover:bg-destructive/10 hover:text-destructive",children:"Delete"}):l.jsx("span",{}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(p.Button,{variant:"outline",size:"xs",onClick:()=>y(!1),children:"Cancel"}),l.jsx(p.Button,{size:"xs",onClick:ne,children:"Accept"})]})]})]})]})]})}function OJe(e,t){const n=e?pb({dashboard:e}).allInputs.find(r=>r.id===Pg.getDashboardFilterCompatInputId(t.id)):void 0;return(n==null?void 0:n.variableName)||t.variableName||p.createDashboardInputVariableName(t.title||t.column||t.id)}function Iue(e,t){if(!e)return[];const n=LJe(t),r=new Set;for(const o of pb({dashboard:e}).allInputs)o.id!==n&&r.add(o.variableName);return Array.from(r)}function LJe(e){if(e)return e.source==="dashboardFilter"?Pg.getDashboardFilterCompatInputId(e.filterId):Pg.getDashboardControlCompatInputId(e.controlId)}function $Je(e,t={}){const{enabled:n=!0,eventType:r="mousedown"}=t,o=v.useRef(null),s=v.useRef(t.ignoreRefs);return s.current=t.ignoreRefs,v.useEffect(()=>{const i=a=>{var f;const c=a.target;o.current&&o.current.contains(c)||(f=s.current)!=null&&f.some(h=>{var m;return(m=h.current)==null?void 0:m.contains(c)})||c instanceof Element&&(c.closest("[data-radix-popper-content-wrapper]")||c.closest("[data-radix-select-content]")||c.closest("[data-radix-popover-content]")||c.closest("[data-radix-dropdown-menu-content]")||c.closest("[data-radix-tooltip-content]")||c.closest('[role="listbox"]')||c.closest('[role="option"]')||c.closest('[role="combobox"]'))||c instanceof Element&&c.hasAttribute("data-radix-")||e()};return n&&document.addEventListener(r,i),()=>{document.removeEventListener(r,i)}},[e,n,r]),o}function zJe(e,t,n,r=[]){const o=p.useDashboardStore(g=>g.dashboard),s=p.useDashboardStore(g=>g.selectedSheetId),i=p.useDashboardStore(g=>g.dashboardInputValues),a=p.useDashboardStore(g=>g.filterValues),c=p.useDashboardStore(g=>g.controlValues),u=v.useMemo(()=>{var g;return(g=ja(o,e.id))==null?void 0:g.optionSource},[o,e.id]),d=(t==null?void 0:t.sheetId)??s,f=v.useMemo(()=>!u||n!=null&&n.activeFilterValues?n==null?void 0:n.activeFilterValues:Ti({dashboard:o,sheetId:d,runtimeValues:{dashboardInputValues:i,filterValues:a,controlValues:c}}).activeFilters,[c,o,i,n==null?void 0:n.activeFilterValues,a,u,d]),h=v.useMemo(()=>u?{...n,selectedSheetId:d??void 0,activeFilterValues:f}:n,[f,n,u,d]),{searchRecords:m}=Lle(e,"",0,{enabled:!!(u&&r.length),debounceMs:0,searchThreshold:1,filterQueryContext:h,optionValueLookup:r});return v.useMemo(()=>{const g=new Map;for(const x of m)x.label!==void 0&&g.set(String(x.value),String(x.label));return g},[m])}const BJe=24;function Wx(e,t=BJe){return e.length<=t?e:`${e.slice(0,t-1)}…`}function VJe(e,t,n,r=new Map){if(!t)return null;if(t.operation==="is null")return"is empty";if(t.operation==="is not null")return"is not empty";const o=t.values;if(!o||o.length===0)return null;const s=p.getDataType(e.dataType),i=c=>{try{return Vt.formatInTimeZone(new Date(c),n,"MMM d")}catch{return String(c)}},a={"=":"=","!=":"≠","<":"<","<=":"≤",">":">",">=":"≥"};if(s==="date"){const c=t.relativeMeta,u=p.getRelativeDateLabel(c);if(u)return u;const d=o[0],f=o[1];if(!d)return null;if(f){const g=b=>{try{return Vt.formatInTimeZone(new Date(b),n,"yyyy-MM-dd")}catch{return String(b)}};if(g(d)===g(f)){const b=i(d);return t.operation==="not between"?`not ${b}`:b}const x=`${i(d)} – ${i(f)}`;return t.operation==="not between"?`not ${x}`:x}const h=a[t.operation],m=i(d);return h?`${h} ${m}`:m}if(s==="number"&&(t.operation==="between"||t.operation==="not between")&&o.length>=2){const c=`${String(o[0])} – ${String(o[1])}`;return t.operation==="not between"?`not ${c}`:c}if(s==="number"&&o.length===1&&t.operation!=="in"&&t.operation!=="not in"){const c=a[t.operation];if(c)return Wx(`${c} ${String(o[0])}`)}return t.operation==="not in"?o.length===1?Wx(`not ${r.get(String(o[0]))??String(o[0])}`):`${o.length} excluded`:t.operation==="not like"?Wx(`not ${String(o[0])}`):t.operation==="like"?Wx(`contains ${String(o[0])}`):o.length===1?Wx(r.get(String(o[0]))??String(o[0])):`${o.length} selected`}function HJe(e){return p.getDataType(e.dataType)==="date"||e.kind==="global-date"?N0:(e.searchMode==="numeric",null)}function qJe(e){const t=p.getDataType(e.dataType);return(t==="date"||e.kind==="global-date")&&e.dateSelectionMode==="day"?240:t==="date"||e.kind==="global-date"?360:e.uiType==="tabs"?320:e.uiType==="radio"?260:e.searchMode==="numeric"?240:300}function CU(e){var t;return!((t=e.customFilterPreferences)!=null&&t.url||e.kind==="global-date"||p.isDateDataType(e.dataType)||e.searchMode==="numeric"||e.type==="single"&&(e.uiType==="radio"||e.uiType==="tabs"))}function UJe(e,t){var o;const n=(t==null?void 0:t.name)||e.column;if(n===e.column)return e.title||e.column;const r=(o=e.targetColumns)==null?void 0:o.find(s=>s.column===n);return(r==null?void 0:r.label)||n}function q$({filter:e,isEditing:t=!1,dragListeners:n,storageOptions:r,settingsVariant:o="dashboard",filterQueryContext:s,inputVariableName:i,reservedInputVariableNames:a,isDashboardFilterReference:c=!1,onUpdateFilter:u,onRemoveFilter:d}){var U,Z,Q;const f=B$(e,r),h=ml("interactive"),m=p.useDashboardStore(J=>J.dashboard),g=p.useDashboardStore(J=>J.semanticExecutionPayload),{removeFilterValues:x,removeFilter:b,clearDashboardInputSlot:y}=p.useDashboardActions(),w=p.useDashboardStore(J=>J.actions.removeCardInlineFilterValue),C=(f==null?void 0:f.storageTarget)==="card",N=(f==null?void 0:f.storageTarget)==="dashboardInput",S=f==null?void 0:f.cardId,j=p.useDashboardStore(J=>J.dashboardInputValues),I=p.useDashboardStore(J=>J.selectedSheetId),k=bl(),T=v.useMemo(()=>{if(!N||!(f!=null&&f.dashboardInput))return;const J={sheetId:f.sheetId},re=p.hydrateAuthoredDashboardInputSlot({dashboard:m,input:f.dashboardInput,runtimeValues:j,target:J,timezone:k});return(re==null?void 0:re.status)==="set"&&re.value.kind==="filter"?re.value.filterValue:void 0},[m,j,N,f==null?void 0:f.dashboardInput,f==null?void 0:f.sheetId,k]),_=p.useDashboardStore(J=>{var re,de,le;return C?S?(de=(re=J.inlineFilterValuesMap)==null?void 0:re[S])==null?void 0:de.find(ce=>ce.filterId===e.id):void 0:(le=J.filterValues)==null?void 0:le.find(ce=>ce.filterId===e.id)}),D=C&&(f==null?void 0:f.inlineFilterValues)!==void 0?(U=f.inlineFilterValues)==null?void 0:U.find(J=>J.filterId===e.id):N?T:_,M=v.useMemo(()=>p.isGlobalDateFilter(e)?O5({globalDateFilter:e,globalDateFilterValue:D,timezone:k,allowMinutePrecision:p.getGlobalDateFilterCoverage(m,g).allEligibleTargetsAreDateTime}):D,[m,e,D,g,k]),[P,A]=v.useState(!1),L=v.useRef(null),O=$Je(()=>A(!1),{enabled:P,eventType:"pointerdown",ignoreRefs:[L]}),B=i??(o==="dashboard"?OJe(m,e):void 0),H=a??(o==="dashboard"?Iue(m,{source:"dashboardFilter",filterId:e.id}):void 0),R=zJe(e,f,s,M==null?void 0:M.values),V=VJe(e,M,k,R),z=p.isDateDataType(e.dataType)||e.kind==="global-date",F=v.useMemo(()=>{var le;if(!z)return null;const re=(((le=f==null?void 0:f.dashboardInput)==null?void 0:le.kind)==="filter"?f.dashboardInput:void 0)||ja(m,e.id);if(!re||!p.isComparisonCapableDashboardDateInput(re))return null;const de=p.hydrateAuthoredDashboardInputSlot({dashboard:m,input:re,runtimeValues:j,target:{sheetId:(f==null?void 0:f.sheetId)||I},timezone:k});return Nue(de==null?void 0:de.comparisonSelection)??null},[m,j,e,z,I,f==null?void 0:f.dashboardInput,f==null?void 0:f.sheetId,k]),G=V!==null,q=UJe(e,M),Y=HJe(e),K=!!((Z=e.customFilterPreferences)!=null&&Z.url&&((Q=e.customFilterPreferences)!=null&&Q.componentName)),$=z&&!K,X=J=>{if(J.preventDefault(),J.stopPropagation(),N&&(f!=null&&f.dashboardInput)){y(f.dashboardInput,{sheetId:f.sheetId});return}if(C&&e.id){if(f!=null&&f.removeInlineFilterValue){f.removeInlineFilterValue(e.id);return}S&&w(S,e.id);return}x(e.id)},W=()=>{if(d){d(e.id);return}x(e.id),b(e.id)};return l.jsxs("div",{className:"group/chip flex shrink-0 items-center gap-2",children:[t&&n&&l.jsx("span",{role:"button",tabIndex:-1,"aria-label":"Drag to reorder",className:"inline-flex h-7 cursor-grab items-center justify-center px-0.5 text-muted-foreground/50 transition-colors hover:text-muted-foreground active:cursor-grabbing",...n,children:l.jsx(Eu,{className:"size-3"})}),l.jsxs(p.Popover,{open:P,onOpenChange:A,children:[l.jsxs("div",{ref:L,className:p.cn("inline-flex h-7 items-stretch overflow-hidden rounded-control border border-border text-[12px] transition-colors",G?h.hasAppearance?"bg-accent/80 hover:bg-accent":"bg-muted/80 hover:bg-muted":h.hasAppearance?"bg-muted/40 hover:bg-accent/50":"bg-muted/40 hover:bg-muted/70"),style:h.chipStyle,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs("button",{type:"button",className:p.cn("inline-flex items-center gap-1.5 pl-2 focus:outline-none",G||t?"pr-1":"pr-2"),children:[Y&&l.jsx(Y,{className:p.cn("h-3 w-3 shrink-0",G?"text-muted-foreground":"text-muted-foreground/70")}),l.jsx("span",{className:"whitespace-nowrap text-muted-foreground",children:q}),G&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-border","aria-hidden":"true",children:"·"}),l.jsx("span",{className:"max-w-[160px] truncate whitespace-nowrap font-medium text-foreground",children:V})]}),F&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-border","aria-hidden":"true",children:"·"}),l.jsx("span",{className:"whitespace-nowrap text-[11px] font-medium text-muted-foreground",children:F})]}),l.jsx(Ie.ChevronDown,{className:"h-3 w-3 shrink-0 text-muted-foreground/60"})]})}),G&&l.jsx("button",{type:"button",onClick:X,"aria-label":`Clear ${e.title||e.column}`,className:"inline-flex w-6 shrink-0 items-center justify-center text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:l.jsx(Ie.X,{className:"h-3 w-3"})}),t&&l.jsx(H$,{filter:e,variant:o,isEditing:t,filterQueryContext:s,inputVariableName:B,reservedInputVariableNames:H,isDashboardFilterReference:c,onAccept:u?(J,re)=>u({...e,...J},re):void 0,onDelete:W,trigger:l.jsx("button",{type:"button","aria-label":`Settings for ${e.title||e.column}`,className:"inline-flex w-7 shrink-0 items-center justify-center text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:l.jsx(mf,{className:"h-3 w-3"})})})]}),l.jsx(p.PopoverContent,{ref:O,align:"start",sideOffset:4,style:{width:qJe(e),...h.contentStyle},className:p.cn($||CU(e)?"p-0":"p-3"),onMouseDown:J=>J.stopPropagation(),onClick:J=>J.stopPropagation(),children:(()=>{const J=()=>A(!1);return $?p.isGlobalDateFilter(e)?l.jsx(yue,{filter:e,storageOptions:f,inline:!0,onApplied:J}):l.jsx(vue,{filter:e,storageOptions:f,inline:!0,onApplied:J}):CU(e)?l.jsx(YQe,{filter:e,storageOptions:f,onApplied:J}):l.jsx(W_,{filter:e,storageOptions:f})})()})]})]})}function WJe(e){return{id:e.id,connectionId:e.connectionId,title:e.title,column:e.column,dataType:e.dataType,table:e.table,database:e.database,qualifiedTableName:e.qualifiedTableName,sql:e.sql,operation:e.operation,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext,type:e.type,uiType:e.uiType,dateSelectionMode:e.dateSelectionMode,defaultValues:e.defaultValues,defaultDateFilter:e.defaultDateFilter,searchMode:e.searchMode,customFilterPreferences:e.customFilterPreferences,showLabel:e.showLabel}}function _ue({inlineFilter:e,sheetId:t,cardId:n,inlineFilterValues:r,setInlineFilterValue:o,removeInlineFilterValue:s}){const i=WJe(e),a={storageTarget:"card",sheetId:t,cardId:n,inlineFilterValues:r,setInlineFilterValue:o,removeInlineFilterValue:s};return l.jsx(q$,{filter:i,isEditing:!1,storageOptions:a})}function U$({card:e,sheetId:t,inlineFilterValues:n,setInlineFilterValue:r,removeInlineFilterValue:o}){return!e.inlineFilters||e.inlineFilters.length===0?[]:e.inlineFilters.map(s=>l.jsx(_ue,{inlineFilter:s,sheetId:t,cardId:e.id,inlineFilterValues:n,setInlineFilterValue:r,removeInlineFilterValue:o},s.id))}function KJe(e){switch(e.type){case"kpi":return GJe(e);case"detailTable":case"table":return ZJe(e);case"aggregateTable":case"pivotTable":return XJe(e);default:return YJe(e)}}function Tue(e){return QJe(KJe(e))}function GJe(e){var i,a,c,u,d,f;const t=(i=e.preferences)==null?void 0:i.kpiVisualOptions,n=(a=e.preferences)==null?void 0:a.formatNumber,r=t==null?void 0:t.formatOptions,o=p.toTFormatOptions(p.fromSemanticFormat((d=(u=(c=e.config)==null?void 0:c.metricColumns)==null?void 0:u[0])==null?void 0:d.format));return{kpi:{primary:r?{...r,currency:r.currency||(r.type==="currency"?"USD":void 0)}:o?{...o,currency:o.currency||(o.type==="currency"?"USD":void 0)}:JJe(n),colorRanges:n==null?void 0:n.colorRanges},legacy:{formatNumber:n,numberAxisFormat:(f=e.preferences)==null?void 0:f.numberAxisFormat}}}function YJe(e){var n,r,o,s;const t=e.preferences;return{dataLabels:(n=t==null?void 0:t.dataLabelsConfig)==null?void 0:n.formatOptions,yAxis:(r=t==null?void 0:t.yAxisConfig)==null?void 0:r.formatOptions,xAxis:(o=t==null?void 0:t.xAxisConfig)==null?void 0:o.formatOptions,secondaryYAxis:(s=t==null?void 0:t.secondaryYAxisConfig)==null?void 0:s.formatOptions,legacy:{formatNumber:t==null?void 0:t.formatNumber,numberAxisFormat:t==null?void 0:t.numberAxisFormat}}}function ZJe(e){var n,r;return{tableColumnSettingsMap:(r=(n=e.preferences)==null?void 0:n.tablePrefs)==null?void 0:r.columnSettingsMap}}function XJe(e){var n;return{tableColumnSettings:(n=e.preferences)==null?void 0:n.columnSettings}}function QJe(e){const t=[],n={};return e.tableColumnSettingsMap&&Object.entries(e.tableColumnSettingsMap).forEach(([r,o])=>{const s=o==null?void 0:o.numberFormat;t.push({id:r,numberFormat:s}),n&&(n[r]={numberFormat:s})}),e.tableColumnSettings&&e.tableColumnSettings.forEach((r,o)=>{r.type==="number"&&t.push({position:r.columnIdx??o,numberFormat:eet(r)})}),{kpi:e.kpi,axes:{xAxis:e.xAxis,yAxis:e.yAxis,secondaryYAxis:e.secondaryYAxis},dataLabels:e.dataLabels,tables:t.length>0||Object.keys(n).length>0?{columns:t.length?t:void 0,columnMap:Object.keys(n).length>0?n:void 0}:void 0,legacy:e.legacy}}function JJe(e){const t=p.fromLegacyFormatNumber(e);return p.toTFormatOptions(t)}function eet(e){var n,r,o,s,i,a;if(e.type!=="number")return;const t=e.options;if(!(!t||typeof t!="object")&&"options"in t){const c=t,u=((n=c.options)==null?void 0:n.style)==="currency"||((r=c.options)==null?void 0:r.style)==="percent"?c.options.style:"decimal",d=p.fromColumnNumberFormat({style:u,currency:c.currency||"USD",locale:c.locale||"en-US",minimumFractionDigits:((o=c.options)==null?void 0:o.minimumFractionDigits)??0,maximumFractionDigits:((s=c.options)==null?void 0:s.maximumFractionDigits)??((i=c.options)==null?void 0:i.minimumFractionDigits)??2,useGrouping:typeof((a=c.options)==null?void 0:a.useGrouping)=="boolean"?c.options.useGrouping:!0,percentValueMode:u==="percent"?"whole":void 0});return p.toTFormatOptions(d)}}function Hj(e,t){if(!t)return e;const n=e?{...e}:{},r=n.title!==void 0,o=n.description!==void 0;return!r&&t.title!==void 0&&(n.title=t.title),!o&&t.description!==void 0&&(n.description=t.description),Object.keys(n).length>0?n:e}function tet({inputCard:e,slotType:t,slotIndex:n,multiInputData:r}){var s,i,a,c,u,d,f,h;if(!e)return{cardType:"unknown",title:`Tab ${n+1}`};const o=Tue(e);return{cardType:t??"unknown",title:e.tabTitle||e.title||`Tab ${n+1}`,description:e.description,formatConfig:o,kpiConfig:t==="kpi"?{comparisonMetadata:(i=(s=r==null?void 0:r[e.id])==null?void 0:s.metadata)==null?void 0:i.comparisonMetadata,options:{comparisonPolarity:p.getMetricComparisonPolarity((c=(a=e.config)==null?void 0:a.metricColumns)==null?void 0:c[0]),comparisonPresentation:(u=e.preferences)==null?void 0:u.comparisonPresentation,showComparison:((f=(d=e.preferences)==null?void 0:d.comparisonPresentation)==null?void 0:f.showComparison)!==!1},formatNumber:(h=e.preferences)==null?void 0:h.formatNumber}:void 0}}function Eue({card:e,dataMetadata:t}){var n,r,o,s,i,a;return{cardType:e.type||"unknown",title:e.tabTitle||e.title||"Tab 1",description:e.description,formatConfig:Tue(e),kpiConfig:e.type==="kpi"?{comparisonMetadata:t==null?void 0:t.comparisonMetadata,options:{comparisonPolarity:p.getMetricComparisonPolarity((r=(n=e.config)==null?void 0:n.metricColumns)==null?void 0:r[0]),comparisonPresentation:(o=e.preferences)==null?void 0:o.comparisonPresentation,showComparison:((i=(s=e.preferences)==null?void 0:s.comparisonPresentation)==null?void 0:i.showComparison)!==!1},formatNumber:(a=e.preferences)==null?void 0:a.formatNumber}:void 0}}function W$({configCard:e,slotOrderedCards:t,slotTypes:n,multiInputData:r,params:o,theme:s,chartSettings:i,filters:a,filterValues:c,inlineFilters:u,formatTemporalBucketValue:d}){var w;const f=n.map(C=>C??"unknown"),h=t.map(C=>{var N;return C?((N=r==null?void 0:r[C.id])==null?void 0:N.records)||[]:[]}),m=t.map(C=>{var N;return C?((N=r==null?void 0:r[C.id])==null?void 0:N.columns)||[]:[]}),g=Hj((w=e==null?void 0:e.customCardPreferences)==null?void 0:w.settings,e),x=t.map(C=>{var N;return Hj((N=C==null?void 0:C.customCardPreferences)==null?void 0:N.slotSettings,C)}),b={titles:t.map((C,N)=>C?C.tabTitle||C.title:`Tab ${N+1}`),cardTypes:f,cardIds:t.map((C,N)=>C?C.id:`missing-${N}`)},y=t.map((C,N)=>tet({inputCard:C,slotType:f[N],slotIndex:N,multiInputData:r}));return{data:h,columns:m,formatTemporalBucketValue:d,settings:g,slotSettings:x,tabMetadata:b,cardMetadata:y,params:o,theme:s,chartSettings:i,filters:a,filterValues:c,inlineFilters:u}}function K$(e){return e.slotOrderedCards.flatMap(t=>{if(!t)return[];const n=e.multiInputData[t.id];return[{card:t,cardConfig:n==null?void 0:n.effectiveCardConfig,columns:n==null?void 0:n.columns,columnKeyMap:n==null?void 0:n.columnKeyMap,executionSnapshot:e.executionSnapshot,dashboardId:e.dashboardId,attachmentIndex:e.attachmentIndex,valueFormatPreferences:e.valueFormatPreferences}]})}class net extends Error{constructor(n){super(`invalid_custom_visual_temporal_column: Column "${n}" is not an activated canonical temporal column from this custom-visual input. Pass the exact descriptor supplied in columns.`);je(this,"code","invalid_custom_visual_temporal_column");this.name="CustomVisualTemporalColumnError"}}function G$(e){const t=new Map;return e.forEach(n=>{const r=Sb({card:n.card,cardConfig:n.cardConfig,columns:n.columns,columnKeyMap:n.columnKeyMap,executionSnapshot:n.executionSnapshot,dashboardId:n.dashboardId,attachmentIndex:n.attachmentIndex,valueFormatPreferences:n.valueFormatPreferences});(n.columns||[]).forEach(o=>{const s=r.byColumnKey.get(o.key);s&&t.set(o,s)})}),(n,r)=>{const o=t.get(r);if(!o)throw new net(r.key);return at.formatGroupedTemporalValue({value:n,presentation:o})}}function ret({card:e,frame:t}){var q,Y,K,$,X,W;const n=e,r=xl(),[o,s]=v.useState({}),{authToken:i,presentationExecutionSnapshot:a}=It(),c=p.getTokenParams(i==null?void 0:i.accessToken),{compiledAppearance:u}=oi.useAppearance(),d=v.useMemo(()=>Vw(u),[u]),[f,h]=v.useState(()=>new Set),{getCard:m,manifest:g}=_f(((q=n.customCardPreferences)==null?void 0:q.url)||""),x=(Y=n.customCardPreferences)==null?void 0:Y.componentName,b=(K=g==null?void 0:g.visuals)==null?void 0:K.find(U=>U.name===x),y=at.resolveMultiInputType(n,b)??"single",w=v.useMemo(()=>y==="multiple"?{...e,connectionId:void 0,dataSource:void 0,sql:"",python:"",config:void 0,queryConfig:void 0}:e,[e,y]),{data:C,effectiveCardConfig:N}=vu(w),S=p.useInteractionStore(U=>U.interactionStates),j=p.useDashboardStore(U=>{var Z;return(Z=U.dashboard)==null?void 0:Z.id}),I=p.useDashboardStore(U=>U.dashboard.filters),k=p.useDashboardStore(U=>U.filterValues),T=p.useDashboardStore(U=>U.selectedSheetId),_=v.useMemo(()=>bb(a),[a]),E=v.useMemo(()=>Gv(),[]),D=p.useDashboardStore(U=>U.inlineFilterValuesMap[e.id]),M=v.useMemo(()=>U$({card:e,sheetId:T||"",inlineFilterValues:D}),[e,T,D]),{cardFilters:P,cardFilterValues:A}=v.useMemo(()=>bI({card:e,interactionStates:S,currentDashboardId:j,filters:I,filterValues:k,selectedSheetId:T}),[e,S,j,I,k,T]),L=v.useCallback((U,Z)=>{const Q=at.normalizeMultiInputPayload(Z);s(J=>({...J,[U]:Q}))},[]),O=x?m(x):null,B=v.useMemo(()=>at.getCustomVisualInputCards({frame:t,configCard:n,isMultiInputVisual:y==="multiple"}),[t,n,y]),H=v.useMemo(()=>at.buildSlotOrderedCards(B),[B]),R=v.useMemo(()=>H.map((U,Z)=>at.getEffectiveCardTypeForSlot(U,Z,b==null?void 0:b.slots)),[H,b==null?void 0:b.slots]),V=v.useMemo(()=>G$(y==="multiple"?K$({slotOrderedCards:H,multiInputData:o,executionSnapshot:_,dashboardId:j,attachmentIndex:E,valueFormatPreferences:r}):[{card:e,cardConfig:N,columns:C==null?void 0:C.columns,columnKeyMap:C==null?void 0:C.columnKeyMap,executionSnapshot:_,dashboardId:j,attachmentIndex:E,valueFormatPreferences:r}]),[e,j,C==null?void 0:C.columnKeyMap,C==null?void 0:C.columns,N,o,E,_,H,y,r]),z=v.useCallback((U,Z)=>{h(Q=>{const J=new Set(Q);return Z?J.add(U):J.delete(U),J})},[]),F=Hj(($=n.customCardPreferences)==null?void 0:$.settings,n);if(!x)return null;const G=((W=(X=e.preferences)==null?void 0:X.displayOptions)==null?void 0:W.allowScroll)??!0;return l.jsx("div",{className:p.cn("semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2",G?"overflow-y-auto":"h-full overflow-hidden"),children:l.jsxs(v.Suspense,{fallback:l.jsx(l.Fragment,{}),children:[O&&y==="single"&&l.jsx(O,{params:c,theme:d,chartSettings:F,settings:F,cardMetadata:Eue({card:e,dataMetadata:C==null?void 0:C.metadata}),onDataChange:L,data:(C==null?void 0:C.records)||[],columns:(C==null?void 0:C.columns)||[],formatTemporalBucketValue:V,filters:P,filterValues:[...A||[],...D||[]],inlineFilters:M}),O&&y==="multiple"&&l.jsxs(l.Fragment,{children:[B.map((U,Z)=>{if(!U)return null;const Q=at.getSlotIndexForCard(U,Z),J=at.getEffectiveCardTypeForSlot(U,Q,b==null?void 0:b.slots);return l.jsx(g$,{onLoadingStatus:z,onDataChange:L,card:U,effectiveCardType:J},`${U.id}-${Q}`)}),l.jsxs("div",{className:p.cn("relative flex h-full min-h-0 flex-1 flex-col gap-2"),children:[f.size>0&&l.jsx("div",{className:"pointer-events-none absolute inset-0 z-10 flex items-center justify-center",children:l.jsx(uc,{size:"md",color:"muted","aria-label":"Loading data"})}),l.jsx(O,{onDataChange:L,...W$({configCard:n,slotOrderedCards:H,slotTypes:R,multiInputData:o,params:c,theme:d,chartSettings:F,filters:P,filterValues:[...A||[],...D||[]],inlineFilters:M,formatTemporalBucketValue:V})})]})]})]},e.id)})}const qj=ret;function Uj({children:e,containerClassName:t,className:n,text:r,onSave:o,type:s="input",placeholder:i,enabled:a}){const[c,u]=v.useState(!1),[d,f]=v.useState(r),h=p.useDashboardStore(y=>y.isDashboardEditing);v.useEffect(()=>{f(y=>y!==r?r:y)},[r]);const m=y=>{y.stopPropagation(),h&&u(!0)};function g(y){if(y.stopPropagation(),y.key==="Escape"){u(!1);return}y.key==="Enter"&&y.shiftKey||(y.key==="Enter"||y.key==="Tab")&&(u(!1),o(d))}function x(){return s==="textarea"?l.jsx("textarea",{className:p.cn("resize rounded-sm bg-background px-2 py-1 text-sm outline-[0.5px] outline-muted",n),onChange:y=>f(y.target.value),value:d,autoFocus:!0,placeholder:i,onBlur:()=>u(!1),onKeyDown:g}):l.jsx("input",{onMouseDown:y=>y.stopPropagation(),type:"text",className:p.cn("rounded-sm bg-background outline-none",n),onChange:y=>f(y.target.value),value:d,autoFocus:!0,placeholder:i,onBlur:()=>u(!1),onKeyDown:g})}function b(){return a?l.jsx("div",{className:"flex grow items-center",children:l.jsx("div",{children:c?x():e})}):e}return l.jsx("div",{className:p.cn("flex",a&&!c&&"cursor-text",t),role:"editable",onDoubleClick:m,onMouseDown:y=>y.stopPropagation(),children:l.jsx("div",{className:"flex grow items-center",children:b()})})}function Y_(e,t){if(!t)return"";const n=t.find(r=>e>=r.start&&e<=r.end);return(n==null?void 0:n.color)||""}function Si(e){const t=e.isEditable!==!1&&e.isPending!==!0?"editable":"read-only";return l.jsx(oet,{...e},t)}function oet({value:e,displayTitle:t=!0,onSave:n,placeholder:r,inputClassName:o,displayClassName:s,isEditable:i=!0,isPending:a=!1,onEditingChange:c}){const[u,d]=v.useState(!1),[f,h]=v.useState(e||""),m=b=>{d(b),c==null||c(b)},g=()=>{m(!1),f!==e&&n(f)},x=b=>{b.key==="Enter"?(m(!1),n(f)):b.key==="Escape"&&(m(!1),h(e||""))};return u?l.jsx("div",{className:"flex",children:l.jsx("input",{type:"text",value:f,onChange:b=>h(b.target.value),onBlur:g,onKeyDown:x,onMouseDown:b=>b.stopPropagation(),className:p.cn("m-0 w-full border-0 bg-transparent p-0 outline-none focus:ring-1 focus:ring-ring/40 focus:ring-offset-2 focus:ring-offset-background",o),autoFocus:!0})}):l.jsxs("div",{className:p.cn("relative truncate transition-colors",s,{"cursor-default":!i,"cursor-text":i}),onClick:()=>{!i||a||(m(!0),h(e||""))},title:t?e||r:void 0,children:[l.jsx("div",{className:"flex items-center justify-between gap-2",children:l.jsx("span",{className:p.cn("truncate",{"text-muted-foreground":a}),children:e||l.jsx("span",{className:"text-muted-foreground",children:r})})}),a&&l.jsx("div",{className:"absolute inset-0 animate-pulse rounded bg-gradient-to-r from-transparent via-blue-100/30 to-transparent"})]})}function EM(e){if(typeof e!="string")return;const t=e.trim();if(!(!t||t.toLowerCase()==="none"))return t}function Due({card:e,preferences:t,boundCurrency:n}){var w,C,N,S,j,I;const r=t===void 0?qi.DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES:t,o=(w=e==null?void 0:e.preferences)==null?void 0:w.formatNumber,s=(N=(C=e==null?void 0:e.preferences)==null?void 0:C.kpiVisualOptions)==null?void 0:N.formatOptions,i=(e==null?void 0:e.type)==="kpi"?S0(e):void 0,a=e&&e.type!=="kpi"?p.fromSemanticFormat((I=(j=(S=e.config)==null?void 0:S.metricColumns)==null?void 0:j[0])==null?void 0:I.format,{preserveOmittedProperties:!0}):void 0,c=(e==null?void 0:e.type)==="kpi"?i==null?void 0:i.authoredFormat:p.fromPersistedKpiFormatOptions(s)||a||p.fromLegacyFormatNumber(o),u=c&&r&&Vt.isNumericCanonicalFormat(c)?$t.resolveNumericPresentation(c,r,n):c,d=(u==null?void 0:u.type)==="currency"?u.currency:void 0,f=EM(o==null?void 0:o.currency),h=d||f,m=u&&"locale"in u&&EM(u.locale),g=EM(o==null?void 0:o.locale),x=m||g||(r==null?void 0:r.locale)||qi.DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES.locale,b=o==null?void 0:o.enabled;return{currency:h,locale:x,canonicalPrimaryFormat:u,isFormattingDisabled:b===!1||b==="false"}}function Mue(e){var c,u,d;const{preferences:t,resolveBoundCurrency:n}=Pa(e),r=(d=(u=(c=e.config)==null?void 0:c.metricColumns)==null?void 0:u[0])==null?void 0:d.id,o=Due({card:e,preferences:t,boundCurrency:r?n({kind:"metric",metricId:r}):void 0});function s(){return o.currency}function i(){return o.locale}function a(){return o.canonicalPrimaryFormat}return{getCurrency:s,getLocale:i,getPrimaryFormat:a}}const set={"currentPeriod.start":"Current Start","currentPeriod.end":"Current End","comparisonPeriod.start":"Previous Start","comparisonPeriod.end":"Previous End"},iet=e=>e.filter(t=>t.segment==="meta"||t.Segment==="meta"),aet=e=>{switch(e){case"target":return"Target";case"previous_year":return"Last Year";case"previous_period":default:return"Previous"}};function DM({label:e,value:t,formatCurrency:n,emphasize:r=!1,signed:o=!1}){const s=n(o?Math.abs(t):t),i=o?t>0?`+${s}`:t<0?`−${s}`:s:s;return l.jsxs("div",{className:"flex items-center justify-between text-[12px]",children:[l.jsx("span",{className:"text-muted-foreground",children:e}),l.jsx("span",{className:r?"font-medium tabular-nums text-foreground":"tabular-nums text-foreground",children:i})]})}function cet({metaKey:e,value:t}){const n=set[e]??e;return l.jsxs("div",{className:"flex items-center justify-between gap-4 text-[12px]",children:[l.jsx("span",{className:"text-muted-foreground",children:n}),l.jsx("span",{className:"tabular-nums text-foreground",children:t})]})}function uet({currentValue:e,comparisonValue:t,formatCurrency:n,comparisonLabel:r="Previous"}){return l.jsxs("div",{className:"space-y-1",children:[l.jsx(DM,{label:"Current",value:e,formatCurrency:n,emphasize:!0}),l.jsx(DM,{label:r,value:t,formatCurrency:n}),l.jsx(DM,{label:"Change",value:e-t,formatCurrency:n,signed:!0})]})}function det({data:e,comparisonMetadata:t}){const n=t==null?void 0:t.output.currentWindow,r=t==null?void 0:t.output.comparisonWindow,o=t==null?void 0:t.output.windowGrain,s=n?GA({start:n.startInclusive,end:n.endExclusive},n.timezone,o):void 0,i=r?GA({start:r.startInclusive,end:r.endExclusive},r.timezone,o):void 0,a=s&&i?[{key:"currentPeriod.start",value:s.start},{key:"currentPeriod.end",value:s.end},{key:"comparisonPeriod.start",value:i.start},{key:"comparisonPeriod.end",value:i.end}]:iet(e);return a.length===0?null:l.jsxs("div",{className:"space-y-1 border-t border-border/60 px-3 py-2.5",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Period Details"}),l.jsx("div",{className:"space-y-1",children:a.map((c,u)=>l.jsx(cet,{metaKey:c.key??c.Key,value:c.value??c.Value},u))})]})}function fet({currentValue:e,comparisonValue:t,sentiment:n,data:r,comparisonMetadata:o,comparisonKind:s,formatCurrency:i,conditionalLabel:a}){const c=aet((o==null?void 0:o.type)??s);return l.jsxs(p.TooltipContent,{side:"right",sideOffset:8,className:"w-[260px] rounded-[6px] border border-border bg-popover p-0 text-popover-foreground shadow-md",children:[a&&l.jsx("div",{className:`border-b border-border/60 px-3 py-2 text-[12px] font-medium ${n==="favorable"?"text-emerald-600 dark:text-emerald-400":n==="unfavorable"?"text-rose-600 dark:text-rose-400":"text-muted-foreground"}`,children:a}),l.jsxs("div",{className:"space-y-1 px-3 py-2.5",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Key Metrics"}),l.jsx(uet,{currentValue:e,comparisonValue:t,formatCurrency:i,comparisonLabel:c})]}),l.jsx(det,{data:r,comparisonMetadata:o})]})}const het=[{id:"us",name:"United States",flag:"🇺🇸",code:"US",region:"North America"},{id:"ca",name:"Canada",flag:"🇨🇦",code:"CA",region:"North America"},{id:"mx",name:"Mexico",flag:"🇲🇽",code:"MX",region:"North America"},{id:"gb",name:"United Kingdom",flag:"🇬🇧",code:"GB",region:"Europe"},{id:"de",name:"Germany",flag:"🇩🇪",code:"DE",region:"Europe"},{id:"fr",name:"France",flag:"🇫🇷",code:"FR",region:"Europe"},{id:"it",name:"Italy",flag:"🇮🇹",code:"IT",region:"Europe"},{id:"es",name:"Spain",flag:"🇪🇸",code:"ES",region:"Europe"},{id:"nl",name:"Netherlands",flag:"🇳🇱",code:"NL",region:"Europe"},{id:"be",name:"Belgium",flag:"🇧🇪",code:"BE",region:"Europe"},{id:"ch",name:"Switzerland",flag:"🇨🇭",code:"CH",region:"Europe"},{id:"at",name:"Austria",flag:"🇦🇹",code:"AT",region:"Europe"},{id:"se",name:"Sweden",flag:"🇸🇪",code:"SE",region:"Europe"},{id:"no",name:"Norway",flag:"🇳🇴",code:"NO",region:"Europe"},{id:"dk",name:"Denmark",flag:"🇩🇰",code:"DK",region:"Europe"},{id:"fi",name:"Finland",flag:"🇫🇮",code:"FI",region:"Europe"},{id:"pl",name:"Poland",flag:"🇵🇱",code:"PL",region:"Europe"},{id:"cz",name:"Czech Republic",flag:"🇨🇿",code:"CZ",region:"Europe"},{id:"hu",name:"Hungary",flag:"🇭🇺",code:"HU",region:"Europe"},{id:"pt",name:"Portugal",flag:"🇵🇹",code:"PT",region:"Europe"},{id:"ie",name:"Ireland",flag:"🇮🇪",code:"IE",region:"Europe"},{id:"gr",name:"Greece",flag:"🇬🇷",code:"GR",region:"Europe"},{id:"jp",name:"Japan",flag:"🇯🇵",code:"JP",region:"Asia"},{id:"cn",name:"China",flag:"🇨🇳",code:"CN",region:"Asia"},{id:"in",name:"India",flag:"🇮🇳",code:"IN",region:"Asia"},{id:"kr",name:"South Korea",flag:"🇰🇷",code:"KR",region:"Asia"},{id:"sg",name:"Singapore",flag:"🇸🇬",code:"SG",region:"Asia"},{id:"hk",name:"Hong Kong",flag:"🇭🇰",code:"HK",region:"Asia"},{id:"tw",name:"Taiwan",flag:"🇹🇼",code:"TW",region:"Asia"},{id:"th",name:"Thailand",flag:"🇹🇭",code:"TH",region:"Asia"},{id:"my",name:"Malaysia",flag:"🇲🇾",code:"MY",region:"Asia"},{id:"id",name:"Indonesia",flag:"🇮🇩",code:"ID",region:"Asia"},{id:"ph",name:"Philippines",flag:"🇵🇭",code:"PH",region:"Asia"},{id:"vn",name:"Vietnam",flag:"🇻🇳",code:"VN",region:"Asia"},{id:"ae",name:"United Arab Emirates",flag:"🇦🇪",code:"AE",region:"Asia"},{id:"sa",name:"Saudi Arabia",flag:"🇸🇦",code:"SA",region:"Asia"},{id:"il",name:"Israel",flag:"🇮🇱",code:"IL",region:"Asia"},{id:"tr",name:"Turkey",flag:"🇹🇷",code:"TR",region:"Asia"},{id:"au",name:"Australia",flag:"🇦🇺",code:"AU",region:"Oceania"},{id:"nz",name:"New Zealand",flag:"🇳🇿",code:"NZ",region:"Oceania"},{id:"br",name:"Brazil",flag:"🇧🇷",code:"BR",region:"South America"},{id:"ar",name:"Argentina",flag:"🇦🇷",code:"AR",region:"South America"},{id:"cl",name:"Chile",flag:"🇨🇱",code:"CL",region:"South America"},{id:"co",name:"Colombia",flag:"🇨🇴",code:"CO",region:"South America"},{id:"pe",name:"Peru",flag:"🇵🇪",code:"PE",region:"South America"},{id:"uy",name:"Uruguay",flag:"🇺🇾",code:"UY",region:"South America"},{id:"ec",name:"Ecuador",flag:"🇪🇨",code:"EC",region:"South America"},{id:"ve",name:"Venezuela",flag:"🇻🇪",code:"VE",region:"South America"},{id:"za",name:"South Africa",flag:"🇿🇦",code:"ZA",region:"Africa"},{id:"ng",name:"Nigeria",flag:"🇳🇬",code:"NG",region:"Africa"},{id:"eg",name:"Egypt",flag:"🇪🇬",code:"EG",region:"Africa"},{id:"ma",name:"Morocco",flag:"🇲🇦",code:"MA",region:"Africa"},{id:"ke",name:"Kenya",flag:"🇰🇪",code:"KE",region:"Africa"},{id:"gh",name:"Ghana",flag:"🇬🇭",code:"GH",region:"Africa"},{id:"et",name:"Ethiopia",flag:"🇪🇹",code:"ET",region:"Africa"},{id:"tz",name:"Tanzania",flag:"🇹🇿",code:"TZ",region:"Africa"},{id:"ru",name:"Russia",flag:"🇷🇺",code:"RU",region:"Europe/Asia"},{id:"ua",name:"Ukraine",flag:"🇺🇦",code:"UA",region:"Europe"},{id:"by",name:"Belarus",flag:"🇧🇾",code:"BY",region:"Europe"},{id:"lt",name:"Lithuania",flag:"🇱🇹",code:"LT",region:"Europe"},{id:"lv",name:"Latvia",flag:"🇱🇻",code:"LV",region:"Europe"},{id:"ee",name:"Estonia",flag:"🇪🇪",code:"EE",region:"Europe"},{id:"ro",name:"Romania",flag:"🇷🇴",code:"RO",region:"Europe"},{id:"bg",name:"Bulgaria",flag:"🇧🇬",code:"BG",region:"Europe"},{id:"hr",name:"Croatia",flag:"🇭🇷",code:"HR",region:"Europe"},{id:"si",name:"Slovenia",flag:"🇸🇮",code:"SI",region:"Europe"},{id:"sk",name:"Slovakia",flag:"🇸🇰",code:"SK",region:"Europe"},{id:"rs",name:"Serbia",flag:"🇷🇸",code:"RS",region:"Europe"},{id:"ba",name:"Bosnia and Herzegovina",flag:"🇧🇦",code:"BA",region:"Europe"},{id:"me",name:"Montenegro",flag:"🇲🇪",code:"ME",region:"Europe"},{id:"mk",name:"North Macedonia",flag:"🇲🇰",code:"MK",region:"Europe"},{id:"al",name:"Albania",flag:"🇦🇱",code:"AL",region:"Europe"},{id:"xk",name:"Kosovo",flag:"🇽🇰",code:"XK",region:"Europe"},{id:"md",name:"Moldova",flag:"🇲🇩",code:"MD",region:"Europe"},{id:"is",name:"Iceland",flag:"🇮🇸",code:"IS",region:"Europe"},{id:"lu",name:"Luxembourg",flag:"🇱🇺",code:"LU",region:"Europe"},{id:"mt",name:"Malta",flag:"🇲🇹",code:"MT",region:"Europe"},{id:"cy",name:"Cyprus",flag:"🇨🇾",code:"CY",region:"Europe"},{id:"mc",name:"Monaco",flag:"🇲🇨",code:"MC",region:"Europe"},{id:"ad",name:"Andorra",flag:"🇦🇩",code:"AD",region:"Europe"},{id:"sm",name:"San Marino",flag:"🇸🇲",code:"SM",region:"Europe"},{id:"va",name:"Vatican City",flag:"🇻🇦",code:"VA",region:"Europe"},{id:"li",name:"Liechtenstein",flag:"🇱🇮",code:"LI",region:"Europe"},{id:"pk",name:"Pakistan",flag:"🇵🇰",code:"PK",region:"Asia"},{id:"bd",name:"Bangladesh",flag:"🇧🇩",code:"BD",region:"Asia"},{id:"lk",name:"Sri Lanka",flag:"🇱🇰",code:"LK",region:"Asia"},{id:"np",name:"Nepal",flag:"🇳🇵",code:"NP",region:"Asia"},{id:"bt",name:"Bhutan",flag:"🇧🇹",code:"BT",region:"Asia"},{id:"mv",name:"Maldives",flag:"🇲🇻",code:"MV",region:"Asia"},{id:"af",name:"Afghanistan",flag:"🇦🇫",code:"AF",region:"Asia"},{id:"ir",name:"Iran",flag:"🇮🇷",code:"IR",region:"Asia"},{id:"iq",name:"Iraq",flag:"🇮🇶",code:"IQ",region:"Asia"},{id:"sy",name:"Syria",flag:"🇸🇾",code:"SY",region:"Asia"},{id:"lb",name:"Lebanon",flag:"🇱🇧",code:"LB",region:"Asia"},{id:"jo",name:"Jordan",flag:"🇯🇴",code:"JO",region:"Asia"},{id:"kw",name:"Kuwait",flag:"🇰🇼",code:"KW",region:"Asia"},{id:"qa",name:"Qatar",flag:"🇶🇦",code:"QA",region:"Asia"},{id:"bh",name:"Bahrain",flag:"🇧🇭",code:"BH",region:"Asia"},{id:"om",name:"Oman",flag:"🇴🇲",code:"OM",region:"Asia"},{id:"ye",name:"Yemen",flag:"🇾🇪",code:"YE",region:"Asia"},{id:"ge",name:"Georgia",flag:"🇬🇪",code:"GE",region:"Asia"},{id:"am",name:"Armenia",flag:"🇦🇲",code:"AM",region:"Asia"},{id:"az",name:"Azerbaijan",flag:"🇦🇿",code:"AZ",region:"Asia"},{id:"kz",name:"Kazakhstan",flag:"🇰🇿",code:"KZ",region:"Asia"},{id:"kg",name:"Kyrgyzstan",flag:"🇰🇬",code:"KG",region:"Asia"},{id:"tj",name:"Tajikistan",flag:"🇹🇯",code:"TJ",region:"Asia"},{id:"tm",name:"Turkmenistan",flag:"🇹🇲",code:"TM",region:"Asia"},{id:"uz",name:"Uzbekistan",flag:"🇺🇿",code:"UZ",region:"Asia"},{id:"mn",name:"Mongolia",flag:"🇲🇳",code:"MN",region:"Asia"},{id:"kp",name:"North Korea",flag:"🇰🇵",code:"KP",region:"Asia"},{id:"mm",name:"Myanmar",flag:"🇲🇲",code:"MM",region:"Asia"},{id:"la",name:"Laos",flag:"🇱🇦",code:"LA",region:"Asia"},{id:"kh",name:"Cambodia",flag:"🇰🇭",code:"KH",region:"Asia"},{id:"bn",name:"Brunei",flag:"🇧🇳",code:"BN",region:"Asia"},{id:"tl",name:"East Timor",flag:"🇹🇱",code:"TL",region:"Asia"},{id:"dz",name:"Algeria",flag:"🇩🇿",code:"DZ",region:"Africa"},{id:"tn",name:"Tunisia",flag:"🇹🇳",code:"TN",region:"Africa"},{id:"ly",name:"Libya",flag:"🇱🇾",code:"LY",region:"Africa"},{id:"sd",name:"Sudan",flag:"🇸🇩",code:"SD",region:"Africa"},{id:"ss",name:"South Sudan",flag:"🇸🇸",code:"SS",region:"Africa"},{id:"td",name:"Chad",flag:"🇹🇩",code:"TD",region:"Africa"},{id:"ne",name:"Niger",flag:"🇳🇪",code:"NE",region:"Africa"},{id:"ml",name:"Mali",flag:"🇲🇱",code:"ML",region:"Africa"},{id:"bf",name:"Burkina Faso",flag:"🇧🇫",code:"BF",region:"Africa"},{id:"sn",name:"Senegal",flag:"🇸🇳",code:"SN",region:"Africa"},{id:"gm",name:"Gambia",flag:"🇬🇲",code:"GM",region:"Africa"},{id:"gw",name:"Guinea-Bissau",flag:"🇬🇼",code:"GW",region:"Africa"},{id:"gn",name:"Guinea",flag:"🇬🇳",code:"GN",region:"Africa"},{id:"sl",name:"Sierra Leone",flag:"🇸🇱",code:"SL",region:"Africa"},{id:"lr",name:"Liberia",flag:"🇱🇷",code:"LR",region:"Africa"},{id:"ci",name:"Ivory Coast",flag:"🇨🇮",code:"CI",region:"Africa"},{id:"tg",name:"Togo",flag:"🇹🇬",code:"TG",region:"Africa"},{id:"bj",name:"Benin",flag:"🇧🇯",code:"BJ",region:"Africa"},{id:"zw",name:"Zimbabwe",flag:"🇿🇼",code:"ZW",region:"Africa"},{id:"zm",name:"Zambia",flag:"🇿🇲",code:"ZM",region:"Africa"}];function Rue(e){const t=p.useDashboardStore(c=>c.isDashboardEditing),n=p.useDashboardStore(c=>c.isVisualEditing),{setCardTitle:r,setCountryLogo:o}=p.useEditorActions();return{setTitle:c=>{n&&r(c)},setCountryLogo:c=>{n&&o(c)},isEditable:n,isDashboardEditing:t,isVisualEditing:n}}function met(e,t){var r,o;if(!e)return e;const n=(o=(r=e.config)==null?void 0:r.metricColumns)==null?void 0:o[t];return{...e,config:{...e.config,metricColumns:n?[n]:[]},preferences:e.preferences}}function pet(e){var x,b,y,w,C,N;if(!e)return e;const t=(b=(x=e.config)==null?void 0:x.metricColumns)==null?void 0:b[0],n=(y=e.preferences)==null?void 0:y.formatNumber,r=(C=(w=e.preferences)==null?void 0:w.kpiVisualOptions)==null?void 0:C.formatOptions,o=p.fromTFormatOptions(r),s=(o==null?void 0:o.type)==="date"?SU(r==null?void 0:r.locale):void 0,i=o&&(Vt.isNumericCanonicalFormat(o)||o.type==="duration")?r:void 0,a=p.fromSemanticFormat(t==null?void 0:t.format),c=a&&(a.type==="date"||a.type==="string")&&"locale"in a?SU(a.locale):void 0,u=s||c,d=a&&(Vt.isNumericCanonicalFormat(a)||a.type==="duration")&&t?[u&&t.format&&typeof t.format=="object"?{...t,format:{...t.format,locale:u}}:t]:[],h=((o==null?void 0:o.type)==="date"||(o==null?void 0:o.type)==="string"||(o==null?void 0:o.type)==="temporal_bucket"||(a==null?void 0:a.type)==="date"||(a==null?void 0:a.type)==="string"||(a==null?void 0:a.type)==="temporal_bucket")&&!i&&d.length===0,m=!i&&u?{locale:u}:void 0,g=h?{...n,locale:u||(n==null?void 0:n.locale),currency:void 0,prefix:void 0,suffix:void 0,percentValueMode:void 0}:n;return{...e,config:{...e.config,metricColumns:d},preferences:{...e.preferences,formatNumber:g,kpiVisualOptions:{...(N=e.preferences)==null?void 0:N.kpiVisualOptions,formatOptions:i||m}}}}function get(e){return e!=="date"}function SU(e){if(typeof e!="string")return;const t=e.trim();if(!(!t||t.toLowerCase()==="none"))return t}function lp({card:e,preferences:t,boundCurrency:n}){const r=t===void 0?qi.DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES:t,{canonicalPrimaryFormat:o,isFormattingDisabled:s}=Due({card:e,preferences:t,boundCurrency:n}),i=o&&Vt.isNumericCanonicalFormat(o)?o:void 0,a=o&&(o.type==="date"||o.type==="duration")?p.toTFormatOptions(o):void 0,c={type:"number",locale:(r==null?void 0:r.locale)||qi.DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES.locale,minimumFractionDigits:0,maximumFractionDigits:0,useGrouping:!0},u=o==null?void 0:o.type,d=(g,{forceCompact:x=!1,forceSign:b=!1}={})=>{if(g==null)return"n/a";if(s){const w=String(g);return b&&g>0?`+${w}`:w}const y=a!=null&&a.type&&a.type!=="auto"?yr(g,a.type,a):$t.formatNumericCanonical(g,{...i||c,compact:x?!0:i==null?void 0:i.compact});return b&&g>0?`+${y}`:y};return{format:g=>d(g),formatCompact:g=>d(g,{forceCompact:!0}),formatSigned:g=>d(g,{forceSign:!0}),supportsComparisonDeltaInheritance:get(u)}}function NU({card:e,preferences:t,boundCurrency:n,metricIndex:r}){return lp({card:met(e,r),preferences:t,boundCurrency:n})}function Aue({card:e,preferences:t,boundCurrency:n}){return lp({card:pet(e),preferences:t,boundCurrency:n})}function bet({card:e,data:t,isPending:n,headerAction:r,headerTrailingAction:o}){var Y,K,$,X,W,U,Z,Q,J,re,de,le,ce,oe,fe,we,pe,ne,Se,ue,ie,ee;const s=e.config,{setTitle:i,isEditable:a,isVisualEditing:c}=Rue(),{setCardDescription:u}=p.useEditorActions(),{getLocale:d}=Mue(e),{preferences:f,boundCurrency:h,resolveBoundCurrency:m}=n_(e,t),g=($=(K=(Y=e.config)==null?void 0:Y.metricColumns)==null?void 0:K[1])==null?void 0:$.id,x=(U=(W=(X=e.config)==null?void 0:X.metricColumns)==null?void 0:W[2])==null?void 0:U.id,b=g?m({kind:"metric",metricId:g}):void 0,y=x?m({kind:"metric",metricId:x}):void 0,w=v.useMemo(()=>lp({card:e,preferences:f,boundCurrency:h}),[e,h,f]),C=v.useMemo(()=>NU({card:e,preferences:f,boundCurrency:b,metricIndex:1}),[e,b,f]),N=v.useMemo(()=>NU({card:e,preferences:f,boundCurrency:y,metricIndex:2}),[e,y,f]),S=(s==null?void 0:s.metricColumns)||[],j=((Z=e.preferences)==null?void 0:Z.metricPairComparisonEnabled)===!0,I=ae=>w.format(ae),k=ae=>w.formatCompact(ae),T=ae=>C.format(ae),_=ae=>N.format(ae),E=!!p.fromSemanticFormat((Q=S[1])==null?void 0:Q.format),D=ae=>E||b?T(ae):I(ae),M=ae=>{const se=t==null?void 0:t.find(he=>{var ge,ke;return he.segment===ae||he.Segment===ae||((ge=he.segment)==null?void 0:ge.toLowerCase())===ae.toLowerCase()||((ke=he.Segment)==null?void 0:ke.toLowerCase())===ae.toLowerCase()});return(se==null?void 0:se.value)??(se==null?void 0:se.Value)??0},P=M("current"),A=M("comparison"),L=M("tertiary"),O=p.getMetricComparisonPolarity(S[0]),B=(re=(J=e.preferences)==null?void 0:J.formatNumber)==null?void 0:re.colorRanges,H=Y_(P,B);function R(){return e.title?e.title:a?"Enter title":""}if(n)return l.jsxs("div",{className:"flex h-full grow flex-col",children:[l.jsx("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:l.jsx("div",{className:"h-3 w-24 rounded bg-foreground/[0.06]"})}),l.jsxs("div",{className:"flex flex-1 flex-col gap-2 px-4 py-3",children:[l.jsx("div",{className:"h-7 w-32 rounded bg-foreground/[0.06]"}),e.description&&l.jsx("div",{className:"h-3 w-24 rounded bg-foreground/[0.06]"})]})]});const V=j&&S.length===2,z=S.length>=2&&A!==void 0,F=S.length>2&&L!==void 0,q=((de=e==null?void 0:e.kpiPreferences)==null?void 0:de.format)==="compact"?k(P):I(P);return l.jsxs("div",{className:"flex h-full grow flex-col",children:[l.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:[l.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[l.jsx(Si,{displayClassName:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",inputClassName:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",value:R(),isEditable:a,onSave:i}),(e.description||c)&&l.jsx(Si,{isEditable:c,value:e.description||(c?"Enter description":""),placeholder:c?"Enter description":"",displayClassName:"min-w-0 truncate text-[11px] text-muted-foreground/80",inputClassName:"min-w-0 truncate text-[11px] text-muted-foreground/80",onSave:u})]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[r,V&&l.jsx("div",{className:"shrink-0",children:l.jsx(y3,{primaryValue:P,secondaryValue:A,presentation:(le=e.preferences)==null?void 0:le.comparisonPresentation,metricFormatOptions:(oe=(ce=e.preferences)==null?void 0:ce.kpiVisualOptions)==null?void 0:oe.formatOptions,locale:d()||"en-US",decimalPlaces:(we=(fe=e.preferences)==null?void 0:fe.formatNumber)==null?void 0:we.decimalPlaces,suffix:(ne=(pe=e.preferences)==null?void 0:pe.formatNumber)==null?void 0:ne.suffix,polarity:O,signedValueFormatter:w.formatSigned,allowSignedValueFormatter:w.supportsComparisonDeltaInheritance})}),o]})]}),l.jsxs("div",{className:"flex flex-1 flex-col gap-2 px-4 py-3",children:[l.jsx("p",{className:"text-[34px] font-semibold tabular-nums leading-none tracking-tight text-foreground",style:H?{color:H}:void 0,children:q}),z&&l.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[((Se=S[1])==null?void 0:Se.label)||((ue=S[1])==null?void 0:ue.name),l.jsx("span",{className:"mx-1.5 text-muted-foreground/60",children:"·"}),l.jsx("span",{className:"tabular-nums text-foreground/80",children:D(A)})]})]}),F&&l.jsxs("div",{className:"flex shrink-0 items-center justify-between border-t border-border/60 px-4 py-2",children:[l.jsx("span",{className:"truncate text-[11px] text-muted-foreground",children:((ie=S[2])==null?void 0:ie.label)||((ee=S[2])==null?void 0:ee.name)}),l.jsx("span",{className:"text-[12px] font-medium tabular-nums text-foreground",children:_(L)})]})]})}function xet(e){var t;return e.comparisonKind==="target"&&e.targetValue>0&&((t=e.presentation)==null?void 0:t.showComparison)!==!1}function yet(e){const{comparisonKind:t,comparisonValue:n,targetValue:r}=e;return t==="target"?typeof r=="number"&&!Number.isNaN(r)?r:null:n}function vet(e){return typeof e=="number"?"number":typeof e=="boolean"?"boolean":e instanceof Date?"date":"string"}function wet(e){const t=Array.isArray(e.payload.filters)?e.payload.filters:[];return t.length>0?t:[{field:e.payload.field,operator:e.payload.operator,value:e.payload.value}]}function Cet(e,t){return t?`summary:${e}:${t}`:`summary:${e}`}function Pue({addOrUpdateFilterValues:e,onEvent:t,refresh:n,selectedSheetId:r,cardId:o,onChangeComparison:s}){return async i=>{if(i.type==="apply_filter"){const a=wet(i),c=[];for(const u of a){const d=String(u.field||"").trim(),f=String(u.operator||"=").trim(),h=u.value,m=Array.isArray(h)?h[0]:h;if(!d||m==null)continue;const g={filterId:Cet(d,r),name:d,operation:f==="eq"?"=":f==="in"?"in":"=",valueType:vet(m),values:Array.isArray(h)?h:[m]};c.push(g)}c.length>0&&e(c),t==null||t({type:"info",message:{event:"summary_driver_chip_clicked",actionId:i.idempotencyKey,...o?{cardId:o}:{}}});return}if(i.type==="refresh"){await n(),t==null||t({type:"info",message:{event:"summary_retry_clicked",actionId:i.idempotencyKey,...o?{cardId:o}:{}}});return}i.type==="change_comparison"&&s&&await s(i)}}function Net(e){return e==="kpi"}function Fue(e){var t,n;return Net(e==null?void 0:e.type)&&((n=(t=e==null?void 0:e.config)==null?void 0:t.summary)==null?void 0:n.enabled)===!0}function Y$(e){var n;const t=(n=e==null?void 0:e.config)==null?void 0:n.summary;return Fue(e)&&((t==null?void 0:t.showOnCard)===!0||((t==null?void 0:t.breakdownDimensions)||[]).length>0)}function jU(e){var t,n;return Fue(e)&&((n=(t=e==null?void 0:e.config)==null?void 0:t.summary)==null?void 0:n.includeInDashboardSummary)===!0}function Z$(e,t){var R,V;const{authToken:n,tokenProps:r}=It(),o=p.useDashboardStore(z=>z.selectedSheetId),s=p.useDashboardStore(z=>z.dashboard),i=p.useDashboardStore(z=>z.selectedLensId),a=p.useDashboardStore(z=>z.dashboardInputReferenceTime),c=p.useDashboardStore(z=>z.onEvent),u=Zr(),{addOrUpdateFilterValues:d}=p.useDashboardActions(),f=l3(e),{finalConfig:h,finalFiltersKey:m,queryRelevantConfig:g}=f,x=v.useMemo(()=>p.getDashboardCards(s),[s]),b=v.useMemo(()=>x.length>0?x:[e],[e,x]),y=v.useMemo(()=>Object.fromEntries(b.map(z=>[z.id,z.id===e.id?g:z.config])),[e.id,g,b]),w=vI(b,{authority:"runtime",queryRelevantConfigsByCardId:y}).payload,C=p.useDashboardStore(z=>{var F;return((F=z.reportContext)==null?void 0:F.calendar)??null}),N=C==null?void 0:C.tz,S=v.useMemo(()=>p.getGlobalDateFilterCoverage(s,w),[s,w]),j=v.useMemo(()=>aw({card:e,cardConfig:f.queryRelevantConfig,input:f.filterCompilationInput,semanticExecutionPayload:w,timezone:N,allowMinutePrecision:S.allEligibleTargetsAreDateTime,comparisonReferenceTime:a}),[e,f,w,N,a,S.allEligibleTargetsAreDateTime]),I=j.status==="ready"?j.cardFilterValues:void 0,k=j.status==="ready"?j.globalDateComparison:void 0,T=j.status==="blocked",_=(t==null?void 0:t.enabled)??!0,E=v.useMemo(()=>({id:e.id,title:e.title,type:e.type,config:h,dataSource:e.dataSource,preferences:e.preferences}),[e.id,e.title,e.type,h,e.dataSource,e.preferences]),D=v.useMemo(()=>JSON.stringify({type:e.type,config:h,dataSource:e.dataSource}),[e.type,h,e.dataSource]),M=(s==null?void 0:s.id)||(r==null?void 0:r.dashboard_id),P=o||((V=(R=s==null?void 0:s.sheets)==null?void 0:R[0])==null?void 0:V.id)||null,A=!!(n!=null&&n.accessToken&&(r!=null&&r.apiServiceUrl)&&M&&P&&(e!=null&&e.id)&&C&&_&&Y$(e)&&j.status==="ready"),L=v.useMemo(()=>["card-summary",M,P,e.id,i,m,j.status,j.mappingDispositions,JSON.stringify(I||[]),D,k,C],[M,P,e.id,i,m,j.status,j.mappingDispositions,I,D,k,C]),O=qn({queryKey:L,enabled:A,staleTime:1e3,queryFn:async()=>{if(T)throw new Error("Resolve the dashboard filter mapping before generating this summary.");const z=`${r.apiServiceUrl}/v1/dashboard/${M}/cards/${e.id}/summary`;return p.postRequestRegular(z,(n==null?void 0:n.accessToken)||"",{selectedSheetId:P,activeFilters:I||[],lensId:i,cardOverride:E,globalDateComparison:k,calendarContext:C})}}),B=Ts({mutationFn:async()=>{if(j.status==="blocked")throw new Error("Resolve the dashboard filter mapping before refreshing this summary.");const z=`${r.apiServiceUrl}/v1/dashboard/${M}/cards/${e.id}/summary`;return p.postRequestRegular(z,(n==null?void 0:n.accessToken)||"",{selectedSheetId:P,activeFilters:I||[],lensId:i,cardOverride:E,globalDateComparison:k,calendarContext:C,refresh:!0})},onSuccess:z=>{u.setQueryData(L,z)}}),H=v.useMemo(()=>Pue({addOrUpdateFilterValues:d,onEvent:c,refresh:()=>B.mutateAsync(),selectedSheetId:P,cardId:e.id}),[d,c,B,P,e.id]);return{data:T?void 0:O.data,isLoading:O.isLoading,isFetching:O.isFetching,isError:O.isError,error:O.error,refresh:B.mutateAsync,isRefreshing:B.isPending,applyAction:H,enabled:A}}function jet(e,t){var r;if(!((r=e==null?void 0:e.sheets)!=null&&r.length)||!t)return[];const n=e.sheets.find(o=>o.id===t)||e.sheets[0];return n?[...n.cards||[],...(n.frames||[]).flatMap(o=>o.cards||[])]:[]}function Oue(){var B,H;const{authToken:e,tokenProps:t}=It(),n=p.useDashboardStore(R=>{var V;return((V=R.reportContext)==null?void 0:V.calendar)??null}),r=n==null?void 0:n.tz,o=p.useDashboardStore(R=>R.selectedSheetId),s=p.useDashboardStore(R=>R.dashboard),i=p.useDashboardStore(R=>R.dashboard.filters),a=p.useDashboardStore(R=>R.semanticExecutionPayload),c=v.useMemo(()=>p.getGlobalDateFilterCoverage(s,a),[s,a]),u=p.useDashboardStore(R=>R.filterValues),d=p.useDashboardStore(R=>R.inlineFilterValuesMap),f=p.useDashboardStore(R=>R.dashboardInputValues),h=p.useDashboardStore(R=>R.dashboardInputReferenceTime),m=p.useDashboardStore(R=>R.controlValues),g=p.useDashboardStore(R=>R.cardControlValuesMap),x=p.useDashboardStore(R=>R.selectedLensId),b=p.useDashboardStore(R=>R.onEvent),y=p.useInteractionStore(R=>R.interactionStates),w=Zr(),{addOrUpdateFilterValues:C}=p.useDashboardActions(),N=(s==null?void 0:s.id)||(t==null?void 0:t.dashboard_id),S=o||((H=(B=s==null?void 0:s.sheets)==null?void 0:B[0])==null?void 0:H.id)||null,j=v.useMemo(()=>jet(s,S),[s,S]),I=v.useMemo(()=>j.some(R=>jU(R)),[j]),k=v.useMemo(()=>{const R={},V=[];for(const z of j){if(!jU(z))continue;const F=Cb({card:z,dashboard:s,interactionStates:y,currentDashboardId:s==null?void 0:s.id,filters:i,filterValues:u,selectedSheetId:S,inlineFilterValuesMap:d,dashboardInputContext:Ti({dashboard:s,sheetId:S,card:z,runtimeValues:{dashboardInputValues:f,filterValues:u,controlValues:m,inlineFilterValuesMap:d,cardControlValuesMap:g}})}),G=aw({card:z,cardConfig:F.queryRelevantConfig,input:F.filterCompilationInput,semanticExecutionPayload:a,timezone:r,allowMinutePrecision:c.allEligibleTargetsAreDateTime,comparisonReferenceTime:h});if(G.status==="blocked"){V.push(z.id);continue}const{cardFilterValues:q,globalDateComparison:Y}=G;R[z.id]={activeFilters:q,cardOverride:{id:z.id,title:z.title,type:z.type,config:F.finalConfig,dataSource:z.dataSource,preferences:z.preferences},globalDateComparison:Y}}return{contexts:R,blockedCardIds:V}},[j,y,s,i,a,c.allEligibleTargetsAreDateTime,u,S,d,f,h,m,g,r]),T=k.contexts,_=k.blockedCardIds.length>0,E=!!(e!=null&&e.accessToken&&(t!=null&&t.apiServiceUrl)&&N&&S&&n&&I&&!_),D=v.useMemo(()=>bee({filters:i,filterValues:u||[],dashboard:s,semanticExecutionPayload:a,timezone:r,allowMinutePrecision:c.allEligibleTargetsAreDateTime}),[i,u,s,a,r,c.allEligibleTargetsAreDateTime]),M=v.useMemo(()=>JSON.stringify(k),[k]),P=v.useMemo(()=>["dashboard-summary",N,S,x,JSON.stringify(D),M,n],[N,S,x,D,M,n]),A=qn({queryKey:P,enabled:E,staleTime:1e3,queryFn:async()=>{if(_)throw new Error("Resolve dashboard filter mappings before generating a dashboard summary.");const R=`${t.apiServiceUrl}/v1/dashboard/${N}/summary`;return p.postRequestRegular(R,(e==null?void 0:e.accessToken)||"",{selectedSheetId:S,activeFilters:D,lensId:x,cardContexts:T,calendarContext:n})}}),L=Ts({mutationFn:async()=>{if(_)throw new Error("Resolve dashboard filter mappings before refreshing the dashboard summary.");const R=`${t.apiServiceUrl}/v1/dashboard/${N}/summary`;return p.postRequestRegular(R,(e==null?void 0:e.accessToken)||"",{selectedSheetId:S,activeFilters:D,lensId:x,refresh:!0,cardContexts:T,calendarContext:n})},onSuccess:R=>{w.setQueryData(P,R)}}),O=v.useMemo(()=>Pue({addOrUpdateFilterValues:C,onEvent:b,refresh:()=>L.mutateAsync(),selectedSheetId:S,onChangeComparison:R=>{b==null||b({type:"info",message:{event:"summary_action_clicked",actionType:"change_comparison",payload:R.payload}})}}),[C,b,L,S]);return{data:A.data,isLoading:A.isLoading,isFetching:A.isFetching,isError:A.isError,error:A.error,refetch:A.refetch,refresh:L.mutateAsync,isRefreshing:L.isPending,applyAction:O,enabled:E}}var Z_="Collapsible",[ket,Lue]=p.createContextScope(Z_),[Iet,X$]=ket(Z_),$ue=te.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[c,u]=p.useControllableState({prop:r,defaultProp:o??!1,onChange:i,caller:Z_});return l.jsx(Iet,{scope:n,disabled:s,contentId:p.useId(),open:c,onOpenToggle:te.useCallback(()=>u(d=>!d),[u]),children:l.jsx(p.Primitive.div,{"data-state":tz(c),"data-disabled":s?"":void 0,...a,ref:t})})});$ue.displayName=Z_;var zue="CollapsibleTrigger",Q$=te.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=X$(zue,n);return l.jsx(p.Primitive.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":tz(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:p.composeEventHandlers(e.onClick,o.onOpenToggle)})});Q$.displayName=zue;var J$="CollapsibleContent",ez=te.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=X$(J$,e.__scopeCollapsible);return l.jsx(p.Presence,{present:n||o.open,children:({present:s})=>l.jsx(_et,{...r,ref:t,present:s})})});ez.displayName=J$;var _et=te.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=X$(J$,n),[a,c]=te.useState(r),u=te.useRef(null),d=p.useComposedRefs(t,u),f=te.useRef(0),h=f.current,m=te.useRef(0),g=m.current,x=i.open||a,b=te.useRef(x),y=te.useRef(void 0);return te.useEffect(()=>{const w=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(w)},[]),p.useLayoutEffect2(()=>{const w=u.current;if(w){y.current=y.current||{transitionDuration:w.style.transitionDuration,animationName:w.style.animationName},w.style.transitionDuration="0s",w.style.animationName="none";const C=w.getBoundingClientRect();f.current=C.height,m.current=C.width,b.current||(w.style.transitionDuration=y.current.transitionDuration,w.style.animationName=y.current.animationName),c(r)}},[i.open,r]),l.jsx(p.Primitive.div,{"data-state":tz(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!x,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:x&&o})});function tz(e){return e?"open":"closed"}var Bue=$ue,Tet=Q$,Eet=ez;const ku=Bue,Iu=Q$,_u=ez;function Det(e){return e==null?"n/a":`${(e*100).toFixed(1)}%`}function nz({card:e,preferences:t,boundCurrency:n}){const r=lp({card:e,preferences:t,boundCurrency:n}),o=Aue({card:e,preferences:t,boundCurrency:n});return{formatValue:a=>r.format(a),formatSigned:a=>o.formatSigned(a),formatPct:Det}}const Met=new Set(["PARTIAL_TIMEOUT","DRIVER_DATA_INSUFFICIENT","UNSUPPORTED_CARD_EXCLUDED","CARD_QUERY_FAILED"]);function Ww(e){return e.filter(t=>Met.has(t))}function rz({partial:e,warnings:t}){return e?t.length===0?!0:Ww(t).length>0:!1}const Wj="Summary may be incomplete. Refresh to try again.",Ret={PARTIAL_TIMEOUT:"Summary is partial because generation exceeded the response time budget.",LLM_TIMEOUT_FALLBACK:"Using deterministic summary because narrative generation timed out.",DRIVER_DATA_INSUFFICIENT:"There is not enough breakdown data to compute reliable drivers.",UNSUPPORTED_CARD_EXCLUDED:"Some unsupported chart types were excluded from summary computation.",CARD_QUERY_FAILED:"One or more card summary queries failed; showing available summary results."};function Aet(e){return e==null?"n/a":`${(e*100).toFixed(1)}%`}function dv(e){return e.split("/").map(t=>t.trim()).filter(Boolean).join(", ")}function rF(e){return Ret[e]||e}function Pet(e){return e.kind==="value_contributor"}function oz({className:e,message:t=Wj,showLabel:n=!1}){return l.jsxs("span",{title:t,"aria-label":t,className:p.cn("inline-flex items-center gap-1 text-amber-600",n&&"rounded border border-amber-200 bg-amber-50 px-1.5 py-0.5 text-[11px] font-medium text-amber-700",e),children:[l.jsx(Yo,{className:"h-3.5 w-3.5"}),n&&l.jsx("span",{children:"Summary issue"})]})}function Fet(e){const t=Ww(e.metadata.warnings);return t.length===1?rF(t[0]):t.length>1?`Summary has ${t.length} warnings: ${t.map(rF).join(" ")}`:(rz(e.metadata),Wj)}function Vue(e,t){if(e==null)return null;const n=t.formatPct(e);return e>0?`+${n}`:n}function sz(e){return e==="up"?"text-emerald-600 dark:text-emerald-400":e==="down"?"text-rose-600 dark:text-rose-400":"text-foreground"}function Hue(e,t){if(e.length===0)return t;const n=e[0].dimension;return e.every(o=>o.dimension===n)&&n?`${t} by ${n}`:t}function que(e,t){return Pet(e)?`${t.formatValue(e.current)} · ${t.formatPct(e.contributionPct)}`:t.formatSigned(e.delta)}function Oet({data:e,formatter:t}){const n=e.keyChanges[0];if(!n)return e.narrative?l.jsxs("div",{className:"space-y-1 px-4 py-3",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"What changed"}),l.jsx("p",{className:"text-[13px] leading-[20px] text-foreground",children:e.narrative})]}):null;const r=n.direction==="up";n.direction;const o=sz(n.direction);if(n.comparison==null)return l.jsx("div",{className:"px-4 py-3",children:l.jsxs("p",{className:"text-[13px] leading-[20px] text-foreground",children:[n.label," is"," ",l.jsx("span",{className:"font-medium tabular-nums",children:t.formatValue(n.current)})," ","in the current view."]})});if(n.direction==="flat")return l.jsxs("div",{className:"space-y-1 px-4 py-3",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"What changed"}),l.jsxs("p",{className:"text-[13px] leading-[20px] text-foreground",children:[n.label," was unchanged at"," ",l.jsx("span",{className:"font-medium tabular-nums",children:t.formatValue(n.current)})," ","versus comparison."]})]});const s=r?"rose to":"fell to",i=r?"up":"down",a=n.delta!=null?t.formatSigned(n.delta):null,c=Vue(n.deltaPct,t);return l.jsxs("div",{className:"space-y-1 px-4 py-3",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"What changed"}),l.jsxs("p",{className:"text-[13px] leading-[20px] text-foreground",children:[n.label," ",s," ",l.jsx("span",{className:"font-medium tabular-nums",children:t.formatValue(n.current)}),a&&l.jsxs(l.Fragment,{children:[", ",i," ",l.jsx("span",{className:p.cn("font-medium tabular-nums",o),children:a}),c&&l.jsxs(l.Fragment,{children:[" (",l.jsx("span",{className:p.cn("tabular-nums",o),children:c}),")"]})]})," ","versus comparison."]})]})}function Let(e,t){if(e.comparison==null)return t.formatValue(e.current);if(e.direction==="flat")return`${t.formatValue(e.current)} · unchanged`;const n=t.formatSigned(e.delta),r=Vue(e.deltaPct,t);return r?`${t.formatValue(e.current)} · ${n} (${r})`:`${t.formatValue(e.current)} · ${n}`}function $et({changes:e,formatter:t}){return e.length<=1?null:l.jsxs("div",{className:"space-y-1 px-4 py-3",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Metrics"}),l.jsx("ul",{className:"space-y-1",children:e.map(n=>l.jsxs("li",{className:"flex items-baseline justify-between gap-3 text-[12px]",children:[l.jsx("span",{className:"min-w-0 truncate text-foreground",children:n.label}),l.jsx("span",{className:p.cn("shrink-0 font-medium tabular-nums",sz(n.direction)),children:Let(n,t)})]},n.metricId))})]})}function zet(e,t){if(e==="up")return"Where it grew";if(e==="down")return"Where it declined";const n=t.every(o=>(o.delta??0)>0),r=t.every(o=>(o.delta??0)<0);return n?"Where it grew":r?"Where it declined":"Where it changed"}function Bet({drivers:e,formatter:t,applyAction:n,headlineDirection:r}){const o=e.filter(a=>a.kind==="period_delta_driver"&&a.delta!=null&&Number.isFinite(a.delta)).slice(0,3);if(o.length===0)return null;const s=zet(r,o),i=Hue(o,s);return l.jsxs("div",{className:"space-y-1 px-4 py-3",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:i}),l.jsx("ul",{className:"space-y-1",children:o.map(a=>{const c=sz(a.direction),u=`${dv(a.key)} (${que(a,t)})`;return l.jsx("li",{children:l.jsxs("button",{type:"button",onClick:()=>n(a.action),"aria-label":u,className:"group/row flex w-full items-baseline justify-between gap-3 text-[12px] focus-visible:outline-none",children:[l.jsx("span",{className:"min-w-0 truncate text-left text-foreground underline-offset-2 group-hover/row:underline group-focus-visible/row:underline",children:dv(a.key)}),l.jsx("span",{className:p.cn("shrink-0 font-medium tabular-nums",c),"aria-hidden":"true",children:t.formatSigned(a.delta)})]})},`${a.metricId}-${a.key}`)})})]})}function Vet({drivers:e,formatter:t,applyAction:n}){const r=e.filter(s=>s.kind==="value_contributor").slice(0,3);if(r.length===0)return null;const o=Hue(r,"Top Contributors");return l.jsxs("div",{className:"space-y-1 px-4 py-3",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:o}),l.jsx("ul",{className:"space-y-1",children:r.map((s,i)=>{const a=`${dv(s.key)} (${que(s,t)})`;return l.jsx("li",{children:l.jsxs("button",{type:"button",onClick:()=>n(s.action),"aria-label":a,className:"group/row flex w-full items-center justify-between gap-3 text-[12px] focus-visible:outline-none",children:[l.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[l.jsx("span",{className:p.cn("flex size-4 shrink-0 items-center justify-center rounded-[3px] text-[9px] font-semibold tabular-nums",i===0?"bg-foreground text-background":"bg-muted text-muted-foreground"),"aria-hidden":"true",children:i+1}),l.jsx("span",{className:"truncate text-left text-foreground underline-offset-2 group-hover/row:underline group-focus-visible/row:underline",children:dv(s.key)})]}),l.jsxs("span",{className:"flex shrink-0 items-baseline gap-2 tabular-nums","aria-hidden":"true",children:[l.jsx("span",{className:"text-muted-foreground",children:t.formatValue(s.current)}),l.jsx("span",{className:"min-w-[3rem] text-right font-medium text-foreground",children:t.formatPct(s.contributionPct)})]})]})},`${s.metricId}-${s.key}`)})})]})}function Het(e){if(e.type!=="apply_filter")return e.label;const[t,n]=e.label.split(":");return n?`${t}: ${dv(n)}`:e.label}function Kj({data:e,applyAction:t,numberFormatter:n,audience:r="dashboard"}){var c;const o=n||{formatSigned:u=>u==null?"n/a":`${u>0?"+":""}${Math.round(u*100)/100}`,formatValue:u=>u==null?"n/a":`${Math.round(u*100)/100}`,formatPct:Aet},s=Ww(e.metadata.warnings),i=e.suggestedActions.filter(u=>u.type!=="refresh"&&u.type!=="apply_filter"),a=r==="author"&&s.length>0;return l.jsxs("div",{className:"divide-y divide-border/60",children:[l.jsx(Oet,{data:e,formatter:o}),l.jsx($et,{changes:e.keyChanges,formatter:o}),l.jsx(Bet,{drivers:e.drivers,formatter:o,applyAction:t,headlineDirection:(c=e.keyChanges[0])==null?void 0:c.direction}),l.jsx(Vet,{drivers:e.drivers,formatter:o,applyAction:t}),i.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 px-4 py-3",children:i.map(u=>l.jsx(p.Button,{size:"sm",variant:"secondary",className:"h-7 px-2 text-xs",onClick:()=>t(u),children:Het(u)},u.idempotencyKey))}),a&&l.jsx("div",{className:"px-4 py-3",children:l.jsx("div",{className:"rounded-[4px] bg-amber-50 px-2 py-1.5 text-[11px] text-amber-800 dark:bg-amber-950/30 dark:text-amber-300",children:s.map(u=>l.jsx("div",{children:rF(u)},u))})})]})}const qet=new Set(["up","rose","grew","gained","increased","climbed","surged","jumped","rising"]),Uet=new Set(["down","fell","declined","dipped","dropped","lost","decreased","slipped","falling"]),kU=/(\(([+−-])(\d[\d,]*(?:\.\d+)?[KkMmBb]?)(%?)\))|(([+−-])(\d[\d,]*(?:\.\d+)?[KkMmBb]?)(%?))|(\d[\d,]*(?:\.\d+)?[KkMmBb]?(?:%)?)/g;function Wet(e){const t=/^(\(?)([+−-]?)(\d[\d,]*)(\.\d+)?([KkMmBb]?)(%?)(\)?)$/.exec(e);if(!t)return e;const[,n,r,o,s,i,a,c]=t;if(i||o.includes(",")||o.length<4)return e;const u=Number(o);if(!Number.isFinite(u))return e;const d=u.toLocaleString("en-US");return`${n}${r}${d}${s??""}${i}${a}${c}`}function Ket(e){const t=[];let n=0,r;for(kU.lastIndex=0;(r=kU.exec(e))!==null;){r.index>n&&t.push({kind:"plain",text:e.slice(n,r.index)});const o=r[0],s=r[2]||r[6],i=Wet(o);s==="+"?t.push({kind:"pos",text:i}):s==="-"||s==="−"?t.push({kind:"neg",text:i}):t.push({kind:"num",text:i}),n=r.index+o.length}return n<e.length&&t.push({kind:"plain",text:e.slice(n)}),t}function Get(e){return e.map((t,n)=>{if(t.kind!=="num"||!t.text.endsWith("%"))return t;const r=e[n-1];if(!r||r.kind!=="plain")return t;const o=r.text.replace(/\s+$/,"").split(/[\s.,;:!?(]+/).pop();if(!o)return t;const s=o.toLowerCase();return qet.has(s)?{kind:"pos",text:t.text}:Uet.has(s)?{kind:"neg",text:t.text}:t})}function Yet({narrative:e}){const t=v.useMemo(()=>Get(Ket(e)),[e]);return l.jsx("div",{className:"px-4 py-3",children:l.jsx("p",{className:"text-[13px] leading-[20px] text-foreground",children:t.map((n,r)=>{if(n.kind==="plain")return l.jsx("span",{children:n.text},r);const o=n.kind==="pos"?"text-emerald-600 dark:text-emerald-400":n.kind==="neg"?"text-rose-600 dark:text-rose-400":"";return l.jsx("span",{className:p.cn("font-medium tabular-nums",o),children:n.text},r)})})})}function oF(){var w;const e=p.useDashboardStore(C=>C.dashboard),{preferences:t}=Pa(),n=p.useDashboardStore(C=>C.semanticExecutionPayload),r=p.useDashboardStore(C=>C.isDashboardEditing),o=((w=e==null?void 0:e.summary)==null?void 0:w.position)||"top",{setDashboard:s}=p.useDashboardActions(),{data:i,isLoading:a,isRefreshing:c,enabled:u,applyAction:d,refresh:f}=Oue(),[h,m]=v.useState(!0),g=v.useMemo(()=>nz({preferences:t}),[t]),x=i?rz(i.metadata)||Ww(i.metadata.warnings).length>0:!1,b=i?Fet(i):Wj,y=C=>{e&&o!==C&&s({...e,summary:{...e.summary,position:C}},{semanticExecutionPayload:n})};return u?a&&!i?l.jsx("div",{className:"mx-3 mt-3 overflow-hidden rounded-[6px] border bg-card",children:l.jsxs("div",{className:"space-y-2 px-4 py-3",children:[l.jsx("div",{className:"h-3 w-20 animate-pulse rounded bg-muted"}),l.jsx("div",{className:"h-4 w-4/5 animate-pulse rounded bg-muted"})]})}):i?l.jsx("div",{className:"mx-3 mb-3 mt-3 overflow-hidden rounded-[6px] border bg-card",children:l.jsxs(ku,{open:h,onOpenChange:m,children:[l.jsxs("div",{className:p.cn("flex items-center justify-between gap-2 px-4",h?"border-b border-border/60 py-2.5":"py-1.5"),children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Iu,{asChild:!0,children:l.jsx(p.Button,{size:"icon",variant:"ghost",className:"size-6","aria-label":h?"Collapse summary":"Expand summary",children:l.jsx(Ie.ChevronDown,{className:p.cn("h-3.5 w-3.5 transition-transform",!h&&"-rotate-90")})})}),l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Summary"}),x&&l.jsx(oz,{message:b,showLabel:!0})]}),l.jsxs("div",{className:"flex items-center gap-1",children:[r&&l.jsx("div",{className:"flex h-6 items-center overflow-hidden rounded-[4px] border border-border/60","aria-label":"Summary position",children:["top","bottom"].map(C=>l.jsx(p.Button,{size:"xs",variant:"ghost",className:p.cn("h-6 rounded-none px-2 text-[11px] capitalize text-muted-foreground hover:text-foreground",o===C&&"bg-muted text-foreground hover:bg-muted"),onClick:()=>y(C),"aria-pressed":o===C,children:C},C))}),l.jsx(p.Button,{size:"icon",variant:"ghost",className:"size-6 rounded-[4px] text-muted-foreground hover:text-foreground",onClick:()=>f(),disabled:c,"aria-label":"Refresh summary",children:l.jsx(_a,{className:p.cn("h-3 w-3",c&&"animate-spin")})})]})]}),l.jsx(_u,{children:i.narrative?l.jsx(Yet,{narrative:i.narrative}):l.jsx(Kj,{data:{narrative:i.narrative,generatedAt:i.generatedAt,keyChanges:i.keyChanges,drivers:i.drivers,suggestedActions:i.suggestedActions,metadata:i.metadata},applyAction:d,audience:"dashboard",numberFormatter:g})})]})}):null:null}function Uue({action:e,className:t,description:n,density:r="default",role:o="alert",title:s="This visual can’t be loaded"}){const i=v.useId();return l.jsx("div",{"aria-labelledby":i,className:p.cn("flex h-full min-h-0 w-full items-center justify-center text-center",r==="compact"?"px-0 py-1":"px-6 py-10",t),role:o,children:l.jsxs("div",{className:p.cn("flex flex-col items-center",r==="compact"?"max-w-[280px]":"max-w-[360px]"),children:[l.jsx(p.ChartColumn,{"aria-hidden":"true",className:p.cn("text-muted-foreground",r==="compact"?"mb-1.5 size-4":"mb-3 size-5"),strokeWidth:1.75}),l.jsx("h2",{id:i,className:p.cn("font-medium text-foreground",r==="compact"?"text-[12px]":"text-[14px]"),children:s}),n?l.jsx("p",{className:p.cn("text-muted-foreground",r==="compact"?"mt-0.5 text-[11px] leading-4":"mt-1 text-[12px] leading-5"),children:n}):null,e?l.jsx(p.Button,{className:r==="compact"?"mt-2":"mt-3",onClick:e.onClick,size:"xs",variant:"outline",children:e.label}):null]})})}function Kw(e){if(!e||typeof e!="object")return{};const t=e.code,n=e.message;return e.deliveryBlocking!==!0||typeof t!="string"||typeof n!="string"?{}:{"data-semaphor-render-error-code":t,"data-semaphor-render-error-message":n}}function Gw({onRetry:e,density:t="default",showOwnerGuidance:n=!0}){return l.jsx(Uue,{action:e?{label:"Try Again",onClick:e}:void 0,density:t,description:n?"Contact the dashboard owner for help resolving this issue.":void 0,role:"status"})}function IU({error:e,resetErrorBoundary:t}){return l.jsx("div",{...Kw(e),className:"contents",children:l.jsx(Gw,{onRetry:t})})}const Wue=4,Zet=.005,Xet="hsl(var(--semaphor-primary))",Qet="hsl(var(--semaphor-muted-foreground) / 0.35)",MM=[1,.65,.4,.25];function Kue(e){return e.split("/").map(t=>t.trim()).filter(Boolean).join(", ")}function Jet(e){return(e||[]).filter(t=>t.kind==="value_contributor"&&Number.isFinite(t.current)&&Number.isFinite(t.contributionPct)&&t.contributionPct>0)}function ett(e){return(e||[]).filter(t=>t.kind==="period_delta_driver"&&Number.isFinite(t.delta)&&Number.isFinite(t.contributionPct)&&t.contributionPct>0).slice(0,Wue).map(t=>({id:`${t.metricId}-${t.key}`,label:Kue(t.key),delta:t.delta,contributionPct:t.contributionPct,direction:t.direction,action:t.action}))}function ttt(e,t){const n=e.slice(0,Wue);if(n.length===0)return[];const r=t[0]||Xet,o=MM[MM.length-1]??.25,s=n.map((c,u)=>({id:`${c.metricId}-${c.key}`,label:Kue(c.key),current:c.current,contributionPct:c.contributionPct,color:r,opacity:MM[u]??o,action:c.action})),i=n.reduce((c,u)=>c+u.contributionPct,0),a=Math.max(0,1-i);return a>=Zet&&s.push({id:"other",label:"Other",current:null,contributionPct:a,color:Qet,opacity:1,action:null}),s}function ntt({card:e,data:t,isPending:n,isError:r,comparisonMetadata:o,headerAction:s,headerTrailingAction:i}){var ge,ke,De,Re,Ve,ve,Ke,qe,et,ye,He,Pe;const{setTitle:a,isEditable:c,isVisualEditing:u}=Rue(),{setCardDescription:d}=p.useEditorActions(),{getLocale:f}=Mue(e),{preferences:h,boundCurrency:m}=n_(e,t),{compiledAppearance:g}=oi.useAppearance(),x=(ke=(ge=e.preferences)==null?void 0:ge.kpiVisualOptions)==null?void 0:ke.countryLogoId;v.useMemo(()=>het.find(_e=>_e.id===x),[x]);const b=e.config,y=b==null?void 0:b.summary,w=((y==null?void 0:y.breakdownDimensions)||[]).length>0,C=(y==null?void 0:y.enabled)===!0&&((y==null?void 0:y.showOnCard)===!0||w),N=!u&&C,S=(b==null?void 0:b.groupByColumns)&&b.groupByColumns.length>0,j=(b==null?void 0:b.metricColumns)||[],I=j[0],k=(I==null?void 0:I.id)||(I==null?void 0:I.name),T=j.some(_e=>p.getMetricComparisonKind(_e)==="target"),_=!S&&j.length>1&&!T,E=C&&!_&&!r,{data:D,isLoading:M,isRefreshing:P,refresh:A,applyAction:L}=Z$(e,{enabled:E}),O=v.useMemo(()=>nz({card:e,preferences:h,boundCurrency:m}),[e,m,h]),B=v.useMemo(()=>Jet(D==null?void 0:D.drivers),[D==null?void 0:D.drivers]),H=v.useMemo(()=>ett(D==null?void 0:D.drivers),[D==null?void 0:D.drivers]),R=g.chartPalette,V=v.useMemo(()=>lp({card:e,preferences:h,boundCurrency:m}),[e,m,h]),z=v.useMemo(()=>Aue({card:e,preferences:h,boundCurrency:m}),[e,m,h]),F=v.useMemo(()=>{if(I)return eL(o,I)},[o,I]),G=F==null?void 0:F.metadata,q=_e=>V.format(_e),Y=_e=>V.formatCompact(_e),K=_e=>z.format(_e),$=_e=>{const ze=t==null?void 0:t.find(Be=>Be.segment===_e||Be.Segment===_e?k?Be.metricId===k||Be.metricId===void 0:!0:!1),Ee=(ze==null?void 0:ze.value)??(ze==null?void 0:ze.Value);if(typeof Ee=="number"&&Number.isFinite(Ee))return Ee;if(typeof Ee=="string"&&Ee.trim()){const Be=Number(Ee);return Number.isFinite(Be)?Be:null}return null},X=$("current")??0,W=$("comparison"),U=(F==null?void 0:F.comparisonKind)??p.getMetricComparisonKind(I),Z=p.getMetricComparisonPolarity(I),Q=(De=e.preferences)==null?void 0:De.comparisonPresentation,J=p.getMetricComparisonTarget(I),re=typeof X=="number"&&!isNaN(X)?X:0,de=v.useMemo(()=>ttt(B,R),[B,R]),le=typeof J=="number"&&!isNaN(J)?J:0,ce=le>0?Math.min(re/le,1):0,oe=le>0?Math.max(le-re,0):0,fe=le>0?Math.max(re-le,0):0,we=xet({comparisonKind:U,targetValue:le,presentation:Q}),pe=yet({comparisonKind:U,comparisonValue:W,targetValue:le}),ne=U==="target"?typeof J=="number"&&Number.isFinite(J):pe!==null,Se=U!=="none"&&ne&&(Q==null?void 0:Q.showComparison)!==!1,ue=(Ve=(Re=e.preferences)==null?void 0:Re.formatNumber)==null?void 0:Ve.colorRanges,ie=Y_(X,ue);function ee(){return e.title?e.title:c?"Enter title":""}const ae=e.description||(u?"Enter description":"");if(r)return l.jsx(p.TooltipProvider,{children:l.jsxs("div",{className:"group flex h-full grow flex-col",children:[l.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:[l.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[l.jsx(Si,{displayClassName:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",inputClassName:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",value:ee(),isEditable:c,onSave:a}),(e.description||u)&&l.jsx(Si,{displayClassName:"min-w-0 truncate text-[11px] text-muted-foreground/80",inputClassName:"min-w-0 truncate text-[11px] text-muted-foreground/80",value:ae,placeholder:u?"Enter description":"",isEditable:u,onSave:d})]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s,i]})]}),l.jsx("div",{className:"flex min-h-0 flex-1 px-4 py-3",children:l.jsx(Gw,{density:"compact",showOwnerGuidance:!1})})]})});if(_)return l.jsx(bet,{card:e,data:t,isPending:n,headerAction:s,headerTrailingAction:i});if(n)return l.jsxs("div",{className:"flex h-full grow flex-col",children:[l.jsx("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:l.jsx("div",{className:"h-3 w-24 rounded bg-foreground/[0.06]"})}),l.jsxs("div",{className:"flex flex-1 flex-col gap-2 px-4 py-3",children:[l.jsx("div",{className:"h-7 w-32 rounded bg-foreground/[0.06]"}),e.description&&l.jsx("div",{className:"h-3 w-24 rounded bg-foreground/[0.06]"})]})]});const he=((ve=e==null?void 0:e.kpiPreferences)==null?void 0:ve.format)==="compact"?Y(X):q(X);return l.jsx(p.TooltipProvider,{children:l.jsxs("div",{className:"group flex h-full grow flex-col",children:[l.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:[l.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[l.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[l.jsx(Si,{displayClassName:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",inputClassName:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",value:ee(),isEditable:c,onSave:a}),N&&l.jsxs(np,{openDelay:180,closeDelay:120,children:[l.jsx(Jd,{asChild:!0,children:l.jsx(p.Button,{size:"icon",variant:"ghost",className:"size-4 shrink-0 rounded-[3px] p-0 text-muted-foreground hover:text-foreground","aria-label":"Show summary",children:l.jsx(p.Info,{className:"h-3 w-3"})})}),l.jsxs(Su,{align:"start",className:"ml-2 w-[360px] overflow-hidden p-0",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Summary"}),D&&(D.metadata.partial||D.metadata.warnings.length>0)&&l.jsx(oz,{className:"text-amber-500"})]}),l.jsx(p.Button,{size:"icon",variant:"ghost",className:"size-6 rounded-[4px] text-muted-foreground hover:text-foreground",onClick:()=>A(),disabled:P,"aria-label":"Refresh summary",children:l.jsx(_a,{className:p.cn("h-3 w-3",P&&"animate-spin")})})]}),M&&!D?l.jsxs("div",{className:"space-y-2 px-4 py-3",children:[l.jsx("div",{className:"h-3 w-20 animate-pulse rounded bg-foreground/[0.06]"}),l.jsx("div",{className:"h-3 w-full animate-pulse rounded bg-foreground/[0.06]"}),l.jsx("div",{className:"h-3 w-5/6 animate-pulse rounded bg-foreground/[0.06]"})]}):D?l.jsx(Kj,{data:{narrative:D.narrative,generatedAt:D.generatedAt,keyChanges:D.keyChanges,drivers:D.drivers,suggestedActions:D.suggestedActions,metadata:D.metadata},applyAction:L,audience:"dashboard",numberFormatter:O}):l.jsx("div",{className:"px-4 py-3 text-xs text-muted-foreground",children:"Summary is unavailable for this card."})]})]})]}),(e.description||u)&&l.jsx(Si,{isEditable:u,value:ae,placeholder:u?"Enter description":"",displayClassName:"min-w-0 truncate text-[11px] text-muted-foreground/80",inputClassName:"min-w-0 truncate text-[11px] text-muted-foreground/80",onSave:d})]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s,Se&&pe!==null&&l.jsxs(p.Tooltip,{children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx("div",{className:"shrink-0 cursor-help [&_.inline-flex]:h-[18px] [&_.inline-flex]:gap-1 [&_.inline-flex]:px-1.5 [&_.inline-flex]:py-0 [&_.inline-flex]:text-[11px] [&_.inline-flex]:font-medium",children:l.jsx(y3,{primaryValue:X,secondaryValue:pe,presentation:Q,metricFormatOptions:(qe=(Ke=e.preferences)==null?void 0:Ke.kpiVisualOptions)==null?void 0:qe.formatOptions,locale:f()||"en-US",decimalPlaces:(ye=(et=e.preferences)==null?void 0:et.formatNumber)==null?void 0:ye.decimalPlaces,suffix:(Pe=(He=e.preferences)==null?void 0:He.formatNumber)==null?void 0:Pe.suffix,polarity:Z,signedValueFormatter:V.formatSigned,allowSignedValueFormatter:V.supportsComparisonDeltaInheritance})})}),l.jsx(fet,{currentValue:X,comparisonValue:pe,comparisonKind:U,sentiment:Vr.evaluateMetricComparison({currentValue:X,comparisonValue:pe,polarity:Z}).sentiment,data:t,comparisonMetadata:G,formatCurrency:q,conditionalLabel:(()=>{if(Q!=null&&Q.conditionalLabel){const{conditionalLabels:_e}=Q,ze=X-pe;return ze>0?(_e==null?void 0:_e.increase)||"Increase":ze<0?(_e==null?void 0:_e.decrease)||"Decrease":(_e==null?void 0:_e.neutral)||"No change"}})()})]}),i]})]}),l.jsxs("div",{className:"flex flex-1 flex-col gap-2 px-4 py-3",children:[l.jsx("p",{className:"text-[34px] font-semibold tabular-nums leading-none tracking-tight text-foreground",style:ie?{color:ie}:void 0,children:he}),Se&&pe!==null&&l.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[U==="target"?(Q==null?void 0:Q.labelName)||"Target":(Q==null?void 0:Q.labelName)||"Previous",l.jsx("span",{className:"mx-1.5 text-muted-foreground/60",children:"·"}),l.jsx("span",{className:"tabular-nums text-foreground/80",children:q(pe)})]})]}),we&&l.jsxs("div",{className:"space-y-1.5 border-t border-border/60 px-4 py-2.5",children:[l.jsx("div",{className:"h-1 w-full overflow-hidden rounded-full bg-muted",children:l.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Math.min(Math.round(ce*100),100)}%`,backgroundColor:ie||void 0}})}),l.jsxs("div",{className:"flex items-center justify-between text-[11px] text-muted-foreground",children:[l.jsx("span",{children:re>=le?fe>0?`${K(fe)} above target`:"Target reached":`${K(oe)} remaining`}),l.jsxs("span",{className:"tabular-nums",children:[Math.round(ce*100),"%"]})]})]}),C&&M&&!D&&l.jsxs("div",{className:"space-y-2 border-t border-border/60 px-4 py-2.5","data-testid":"kpi-composition-loading","aria-hidden":"true",children:[l.jsxs("div",{className:"flex h-1 w-full gap-px overflow-hidden rounded-[2px]",children:[l.jsx("div",{className:"h-full w-[40%] animate-pulse bg-foreground/[0.06]"}),l.jsx("div",{className:"h-full w-[26%] animate-pulse bg-foreground/[0.06]"}),l.jsx("div",{className:"h-full w-[16%] animate-pulse bg-foreground/[0.06]"}),l.jsx("div",{className:"h-full flex-1 animate-pulse bg-foreground/[0.06]"})]}),l.jsx("ul",{className:"space-y-1",children:["58%","44%","36%"].map((_e,ze)=>l.jsxs("li",{className:"flex items-center justify-between gap-3",children:[l.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[l.jsx("span",{className:"size-2 shrink-0 animate-pulse rounded-[2px] bg-foreground/[0.06]"}),l.jsx("span",{className:"h-2.5 animate-pulse rounded bg-foreground/[0.06]",style:{width:_e}})]}),l.jsxs("span",{className:"flex shrink-0 items-baseline gap-2",children:[l.jsx("span",{className:"h-2.5 w-7 animate-pulse rounded bg-foreground/[0.06]"}),l.jsx("span",{className:"h-2.5 w-10 animate-pulse rounded bg-foreground/[0.06]"})]})]},`composition-skeleton-${ze}`))})]}),C&&de.length>0&&l.jsxs("div",{className:"space-y-2 border-t border-border/60 px-4 py-3",children:[l.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-[2px]",children:de.map(_e=>l.jsx("div",{"data-testid":"kpi-composition-segment",className:"h-full",style:{width:`${Math.max(_e.contributionPct*100,2)}%`,backgroundColor:_e.color,opacity:_e.opacity}},_e.id))}),l.jsx("ul",{className:"space-y-1",children:de.map(_e=>{const ze=l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[l.jsx("span",{className:"size-2 shrink-0 rounded-[2px]",style:{backgroundColor:_e.color,opacity:_e.opacity}}),l.jsx("span",{className:p.cn("truncate text-muted-foreground decoration-muted-foreground/40 underline-offset-2",_e.action&&"group-hover/row:text-foreground group-hover/row:underline group-focus-visible/row:text-foreground group-focus-visible/row:underline"),children:_e.label})]}),l.jsxs("span",{className:"flex shrink-0 items-baseline gap-2 tabular-nums",children:[_e.current!=null&&l.jsx("span",{className:"text-muted-foreground",children:O.formatValue(_e.current)}),l.jsx("span",{className:"min-w-[3rem] text-right font-medium text-foreground",children:O.formatPct(_e.contributionPct)})]})]});return l.jsx("li",{children:_e.action?l.jsx("button",{type:"button",onClick:()=>L(_e.action),"aria-label":`Filter to ${_e.label}`,className:"group/row flex w-full items-center justify-between gap-3 text-[11px] focus-visible:outline-none",children:ze}):l.jsx("div",{className:"flex items-center justify-between gap-3 text-[11px]",children:ze})},`${_e.id}-legend`)})})]}),C&&de.length===0&&H.length>0&&l.jsx("div",{className:"border-t border-border/60 px-4 py-3",children:l.jsx("ul",{className:"space-y-1",children:H.map(_e=>{const ze=_e.direction==="up"?"text-emerald-600 dark:text-emerald-400":_e.direction==="down"?"text-rose-600 dark:text-rose-400":"text-foreground",Ee=l.jsxs(l.Fragment,{children:[l.jsx("span",{className:p.cn("min-w-0 truncate text-muted-foreground decoration-muted-foreground/40 underline-offset-2",_e.action&&"group-hover/row:text-foreground group-hover/row:underline group-focus-visible/row:text-foreground group-focus-visible/row:underline"),children:_e.label}),l.jsxs("span",{className:"flex shrink-0 items-baseline gap-2 tabular-nums",children:[l.jsx("span",{className:p.cn("font-medium",ze),children:O.formatSigned(_e.delta)}),l.jsx("span",{className:"min-w-[3rem] text-right font-medium text-foreground",children:O.formatPct(_e.contributionPct)})]})]});return l.jsx("li",{"data-testid":"kpi-period-driver-row",children:_e.action?l.jsx("button",{type:"button",onClick:()=>L(_e.action),"aria-label":`Filter to ${_e.label}`,className:"group/row flex w-full items-center justify-between gap-3 text-[11px] focus-visible:outline-none",children:Ee}):l.jsx("div",{className:"flex items-center justify-between gap-3 text-[11px]",children:Ee})},`${_e.id}-driver`)})})})]})})}function rtt({card:e,data:t,isPending:n,isError:r,headerAction:o,headerTrailingAction:s}){var P,A,L,O;const i=p.useDashboardStore(B=>B.isVisualEditing),a=p.useEditorStore(B=>B.card),c=p.useEditorStore(B=>B.actions.setCard);p.useEditorStore(B=>B.actions.setNumberFormat);const u=(A=(P=e.preferences)==null?void 0:P.formatNumber)==null?void 0:A.colorRanges,d=B=>{if(typeof B=="number")return Number.isFinite(B)?B:null;if(typeof B=="string"){const H=B.trim();if(!H)return null;const R=Number(H.replace(/,/g,""));return Number.isFinite(R)?R:null}return null},f=(t==null?void 0:t[0])??{},h=Cw(t),m=h[0],g=h[1],{preferences:x,boundCurrency:b}=n_(e,t),y=lp({card:e,preferences:x,boundCurrency:b}),w=m!==void 0?d(f[m]):null,C=g!==void 0?d(f[g]):null,N=Array.isArray(t)&&t.length>0,S=t==null?void 0:t.some(B=>Object.values(B).some(H=>H!=null)),j=N&&w!==null,I=N&&S?"KPI needs a numeric metric. Add a numeric field or aggregation.":"No data available for this KPI.";function k(B){i&&c({...a,title:B})}function T(B){i&&c({...a,description:B})}const _=w!==null&&C!==null&&C!==0?(w-C)/C:null,E=w!==null?y.format(w):"--";let D="";C!==null&&(D=y.format(C));const M=Y_(w??0,u);return l.jsx(ott,{isPending:n,isError:r,title:e.title,formattedCurrentValue:E,formattedPreviousValue:D,description:e.description,valueColor:M,onTitleChange:k,onDescriptionChange:T,percentDifference:_,polarity:((O=(L=e.preferences)==null?void 0:L.kpiVisualOptions)==null?void 0:O.queryComparisonPolarity)??Vr.DEFAULT_METRIC_COMPARISON_POLARITY,show:j,emptyStateMessage:I,headerAction:o,headerTrailingAction:s})}function sf({card:e,data:t,isPending:n,isError:r,comparisonMetadata:o,headerAction:s,headerTrailingAction:i}){return!uoe(e)&&ut.hasValidCardConfig(e.config)?l.jsx("div",{className:"flex h-full min-h-0 grow overflow-auto",children:l.jsx(ntt,{card:e,data:t||[],isPending:n,isError:r,comparisonMetadata:o,headerAction:s,headerTrailingAction:i})}):l.jsx(rtt,{card:e,data:t,isPending:n,isError:r,headerAction:s,headerTrailingAction:i})}function ott({title:e,formattedCurrentValue:t,formattedPreviousValue:n,description:r,valueColor:o,onTitleChange:s,onDescriptionChange:i,percentDifference:a,show:c,emptyStateMessage:u,isPending:d,isError:f,polarity:h,headerAction:m,headerTrailingAction:g}){const x=p.useDashboardStore(C=>C.isVisualEditing),b=p.useEditorStore(C=>C.card),y=r??"",w=y||(x?"Enter description":"");return l.jsxs("div",{className:"kpi-card flex h-full grow flex-col",children:[l.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:[l.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[l.jsx(Uj,{className:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",containerClassName:"min-w-0",enabled:x,text:x?b.title:e,onSave:s,children:l.jsx(xb,{className:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:e})}),(y||x)&&l.jsx(Uj,{className:"min-w-0 truncate text-[11px] text-muted-foreground/80",containerClassName:"min-w-0",enabled:x,text:w,placeholder:x?"Enter description":"",onSave:i,children:l.jsx("span",{className:"block min-w-0 truncate text-[11px] text-muted-foreground/80",children:w})})]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[m,a!=null&&a!==0&&!f&&!d&&l.jsx(Gue,{polarity:h,children:a}),g]})]}),l.jsx("div",{className:"flex flex-1 flex-col justify-between gap-2 px-4 py-3",children:f?l.jsx(Gw,{density:"compact",showOwnerGuidance:!1}):d?l.jsxs("div",{className:"space-y-2",children:[l.jsx(ei,{className:"h-7 w-32 bg-foreground/[0.06]"}),l.jsx(ei,{className:"h-3 w-24 bg-foreground/[0.06]"})]}):c?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-[34px] font-semibold tabular-nums leading-none tracking-tight text-foreground",style:o?{color:o}:void 0,children:t}),n&&l.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Previous",l.jsx("span",{className:"mx-1.5 text-muted-foreground/60",children:"·"}),l.jsx("span",{className:"tabular-nums text-foreground/80",children:n})]})]}):l.jsx("p",{className:"text-[12px] text-muted-foreground",children:u})})]})}function Gue({children:e,className:t,polarity:n}){const r=e>0,o=n==="lower_is_better"?!r:n==="higher_is_better"?r:null,s=r?ws:ss,i=`${Math.abs(e*100).toFixed(0)}%`;return l.jsxs("span",{className:p.cn("inline-flex h-5 shrink-0 items-center gap-0.5 rounded-[4px] px-1.5 text-[11px] font-medium tabular-nums",o===!0?"bg-emerald-50 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-300":o===!1?"bg-rose-50 text-rose-700 dark:bg-rose-950/40 dark:text-rose-300":"bg-gray-50 text-gray-700 dark:bg-gray-900 dark:text-gray-400",t),children:[l.jsx(s,{className:"h-3 w-3"}),i]})}const iz="A dashboard input is invalid or references a missing filter. Ask an editor to repair the dashboard configuration.";function az(e){return e instanceof Zs.DashboardFilterMappingContractError}function Yw({customerFacingMessage:e,error:t,resetErrorBoundary:n}){const r=az(t);return l.jsxs("div",{...Kw(t),className:"flex h-full w-full flex-col items-center justify-center rounded-lg border border-dashed border-muted-foreground/25 bg-muted/30 p-6 text-center",children:[l.jsx("div",{className:"mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:l.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),l.jsx("h3",{className:"mb-2 text-sm font-medium text-foreground",children:"Chart Unavailable"}),l.jsx("p",{className:"mb-4 text-xs text-muted-foreground",children:e||(r?iz:"Couldn't display this chart right now. Please try refreshing or check your data configuration.")}),l.jsxs("button",{onClick:n,className:"inline-flex items-center justify-center rounded-md bg-primary px-3 py-2 text-xs font-medium text-primary-foreground shadow-sm transition-colors hover:bg-primary/90 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[l.jsx("svg",{className:"mr-1.5 h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),"Try Again"]}),(!r||ut.isDevEnv)&&l.jsxs("details",{className:"mt-4 w-full text-left",children:[l.jsx("summary",{className:"cursor-pointer text-xs text-muted-foreground hover:text-foreground",children:"Show technical details"}),l.jsxs("div",{className:"mt-2 rounded border bg-background p-3",children:[l.jsx("p",{className:"mb-1 text-xs font-medium text-foreground",children:"Error Details:"}),l.jsx("pre",{className:"text-xs text-muted-foreground",children:t.message})]})]})]})}function X_({error:e}){const t=az(e);return l.jsx("div",{...Kw(e),className:"flex flex-col items-center justify-center",role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",width:"100%"},children:l.jsxs("div",{style:{backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",boxShadow:"0 2px 6px rgba(0, 0, 0, 0.08)",color:"#b91c1c",fontFamily:"sans-serif",padding:"16px",textAlign:"center",flexDirection:"column",whiteSpace:"pre-wrap",position:"relative"},className:"flex flex-col justify-center space-y-1 rounded-md bg-muted p-10",children:[l.jsx("p",{className:"text-sm",children:t?"Dashboard configuration needs attention":"Something went wrong:"}),t?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-xs",children:iz}),ut.isDevEnv]}):l.jsx("pre",{className:"text-xs",children:e.message})]})})}function stt({error:e,frame:t}){const n=az(e);return l.jsxs("div",{...Kw(e),className:"flex h-full flex-col items-center justify-center border",role:"alert",children:[l.jsx(iF,{frame:t,isHovered:!1}),l.jsx("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10"}),l.jsxs("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10",children:[l.jsx("p",{className:"text-lg font-semibold",children:n?"Dashboard configuration needs attention":"Oops! Looks like we tripped on a loose wire!"}),n?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-sm",children:iz}),ut.isDevEnv]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-sm",children:"Something went wrong:"}),l.jsx("pre",{className:"text-xs",children:e.message})]})]})]})}function itt(e={},t){const{displayPreferences:n,shouldShowElement:r}=pl(),o=xf(n.mode),s=e.enabled??!0,i=e.serverSide??!1,a=o?Number.MAX_SAFE_INTEGER:e.pageSize||50,c=e.currentPage!==void 0,[u,d]=v.useState(0),[f,h]=v.useState(a),m=c?(e.currentPage||1)-1:u,g=o?Number.MAX_SAFE_INTEGER:c?e.pageSize||a:f,x=v.useMemo(()=>s&&r("showPagination")&&!o,[s,r,o]),b=v.useMemo(()=>i?e.pageCount:Math.ceil(t/g),[i,e.pageCount,t,g]),y=v.useMemo(()=>i?e.totalCount||0:t,[i,e.totalCount,t]),w=v.useMemo(()=>i?(e.currentPage||1)>1:m>0,[i,e.currentPage,m]),C=v.useMemo(()=>i?(e.currentPage||1)<(e.pageCount||1):m<(b||1)-1,[i,e.currentPage,e.pageCount,m,b]);return{pageIndex:m,pageSize:g,isServerSidePagination:i,showPagination:x,paginationEnabled:s,isTablePrintDisplayMode:o,setPageIndex:k=>{var T;c?(T=e.onPageChange)==null||T.call(e,k+1,g):d(k)},setPageSize:k=>{var T;c?(T=e.onPageChange)==null||T.call(e,1,k):(d(0),h(k))},canPreviousPage:w,canNextPage:C,previousPage:()=>{var T;if(!w)return;const k=m-1;c?(T=e.onPageChange)==null||T.call(e,k+1,g):d(k)},nextPage:()=>{var T;if(!C)return;const k=m+1;c?(T=e.onPageChange)==null||T.call(e,k+1,g):d(k)},pageCount:b,totalCount:y}}function att(e,t){const n=e.subtotalLevel,r=r_(t.groupByColumns,n);if(r<0)throw new Error(`invalid_pivot_subtotal_identity: Subtotal level "${n||""}" does not match a configured row-axis field.`);return r}function ltt(e,t,n){var c;if(!t.length)return e;const r=t[0].id,o=t[0].desc?-1:1,s=((c=n.groupByColumns)==null?void 0:c.length)||0,i=r.startsWith("rowLevel"),a=i?parseInt(r.replace("rowLevel","")):-1;return i?ctt(e,a,o):utt(e,r,o,s,n)}function ctt(e,t,n){const r=[...e],o=new Map,s=[];r.forEach(c=>{if(c.isGrandTotal)return;const u=t>0?JSON.stringify((c.canonicalFieldValues||c.fieldValues).slice(0,t)):"root";o.has(u)||(o.set(u,[]),s.push(u)),o.get(u).push(c)});const i=[];s.forEach(c=>{const u=o.get(c),d=u.filter(h=>!h.isSubtotal),f=u.filter(h=>h.isSubtotal);d.sort((h,m)=>{const g=Ns(h,t),x=Ns(m,t);return g===x?0:g==null?1:x==null?-1:String(g).localeCompare(String(x))*n}),i.push(...d),i.push(...f)});const a=e.find(c=>c.isGrandTotal);return a&&i.push(a),i}function utt(e,t,n,r,o){const s={rows:[],children:new Map};let i;e.forEach(f=>{if(f.isGrandTotal){i=f;return}const h=f.isSubtotal?att(f,o)+1:r;let m=s;for(let g=0;g<h;g++){const x=JSON.stringify(Ns(f,g));m.children.has(x)||m.children.set(x,{rows:[],children:new Map}),m=m.children.get(x)}f.isSubtotal?m.subtotal=f:m.rows.push(f)});function a(f){var h;return t==="rowTotal"?o.columnHeaders.reduce((m,g)=>{var b;const x=(b=f.cells[g])==null?void 0:b.value;return m+(typeof x=="number"?x:0)},0):(h=f.cells[t])==null?void 0:h.value}function c(f){let h=0;return f.rows.forEach(m=>{const g=a(m);typeof g=="number"&&(h+=g)}),f.children.forEach(m=>{if(m.subtotal){const g=a(m.subtotal);typeof g=="number"&&(h+=g)}else h+=c(m)}),h}function u(f){const h=[],m=[...f.rows].sort((x,b)=>{const y=a(x),w=a(b);return y===w?0:y==null?1:w==null?-1:y>w?n:-n});return h.push(...m),Array.from(f.children.entries()).sort(([,x],[,b])=>{const y=x.subtotal?a(x.subtotal):c(x),w=b.subtotal?a(b.subtotal):c(b);return y===w?0:y==null?1:w==null?-1:y>w?n:-n}).forEach(([,x])=>{h.push(...u(x))}),f.subtotal&&h.push(f.subtotal),h}const d=u(s);return i&&d.push(i),d}function dtt(e,t){const[n,r]=v.useState([]),o=v.useMemo(()=>ltt(e,n,t),[e,n,t]),s=v.useCallback(c=>{r(u=>{const d=u.find(f=>f.id===c);return d?d.desc?[]:[{id:c,desc:!0}]:[{id:c,desc:!1}]})},[]),i=v.useCallback(()=>{r([])},[]),a=v.useCallback(c=>{const u=n.find(d=>d.id===c);return u?u.desc?"desc":"asc":!1},[n]);return{sorting:n,setSorting:r,sortedTableData:o,toggleColumnSort:s,clearSorting:i,getSortDirection:a}}function RM({columnName:e,groupByFields:t,pivotByFields:n,currentAggregation:r,onAggregationChange:o,onOpenChange:s}){const i=[{value:"SUM",label:"Sum"},{value:"MAX",label:"Max"},{value:"MIN",label:"Min"},{value:"AVG",label:"Avg"},{value:"MEDIAN",label:"Median"}],a=(u,d,f)=>{o({function:u,rowLevel:d,columnLevel:f})},c=(u,d,f)=>{if(!r)return!1;if(d!==void 0&&f===void 0){if(r.rowAggregates){const h=d==="all"?"ALL":d;return r.rowAggregates.some(m=>m.function===u&&m.groupLevel===h)}return!1}if(f!==void 0&&d===void 0){if(r.columnAggregates){const h=f==="all"?"ALL":f;return r.columnAggregates.some(m=>m.function===u&&m.pivotLevel===h)}return!1}return!1};return l.jsxs(Xo,{modal:!1,onOpenChange:s,children:[l.jsx(Qo,{asChild:!0,children:l.jsx(p.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 p-0 hover:bg-accent hover:text-accent-foreground",children:l.jsx($m,{className:"size-3"})})}),l.jsxs(Fo,{align:"start",className:"w-56",children:[l.jsx(Za,{className:"text-xs font-normal text-muted-foreground",children:"AGGREGATE"}),i.map(u=>{var m,g;const d=((m=r==null?void 0:r.rowAggregates)==null?void 0:m.some(x=>x.function===u.value))||!1,f=((g=r==null?void 0:r.columnAggregates)==null?void 0:g.some(x=>x.function===u.value))||!1,h=d||f;return l.jsxs(QO,{children:[l.jsx(Wk,{className:"text-xs",children:l.jsxs("div",{className:"flex w-full items-center justify-between",children:[l.jsx("span",{children:u.label}),h&&l.jsxs("div",{className:"ml-2 flex items-center gap-1 text-xs",children:[d&&l.jsx("span",{className:"rounded bg-blue-100 px-1 py-0.5 text-blue-700 dark:bg-blue-900 dark:text-blue-300",children:"R"}),f&&l.jsx("span",{className:"rounded bg-green-100 px-1 py-0.5 text-green-700 dark:bg-green-900 dark:text-green-300",children:"C"})]})]})}),l.jsxs(Kk,{className:"w-48",children:[l.jsx(Za,{className:"text-xs font-normal text-muted-foreground",children:"ROWS"}),l.jsx(In,{className:"text-xs",onClick:()=>a(u.value,"all"),children:l.jsxs("div",{className:"flex w-full items-center justify-between",children:[l.jsx("span",{children:"of all rows"}),c(u.value,"all")&&l.jsx(p.Check,{className:"h-4 w-4"})]})}),t.map(x=>l.jsx(In,{className:"text-xs",onClick:()=>a(u.value,x.id),children:l.jsxs("div",{className:"flex w-full items-center justify-between",children:[l.jsxs("span",{children:["within ",x.label||x.name]}),c(u.value,x.id)&&l.jsx(p.Check,{className:"h-4 w-4"})]})},x.id)),n.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Ta,{}),l.jsx(Za,{className:"text-xs font-normal text-muted-foreground",children:"COLUMNS"}),l.jsx(In,{className:"text-xs",onClick:()=>a(u.value,void 0,"all"),children:l.jsxs("div",{className:"flex w-full items-center justify-between",children:[l.jsx("span",{children:"of all columns"}),c(u.value,void 0,"all")&&l.jsx(p.Check,{className:"h-4 w-4"})]})}),n.map(x=>l.jsx(In,{className:"text-xs",onClick:()=>a(u.value,void 0,x.id),children:l.jsxs("div",{className:"flex w-full items-center justify-between",children:[l.jsxs("span",{children:["within ",x.label||x.name]}),c(u.value,void 0,x.id)&&l.jsx(p.Check,{className:"h-4 w-4"})]})},x.id))]})]})]},`${u.value}-${u.label}`)})]})]})}function Gj(e,t,n,r,o=!1){if(t){const s=VI(e,t,n,r,o),i=typeof e=="object"&&e!==null&&"value"in e?e.value:e,a=IDe(i,t);return s==="-"||s===0?l.jsx("div",{className:"flex justify-end",children:l.jsx(Uc,{className:"h-3 w-3 text-muted-foreground"})}):a?l.jsx("span",{style:{backgroundColor:a.backgroundColor,color:a.color,padding:"0.125rem 0.25rem",borderRadius:"0.25rem"},children:s}):s}return typeof e=="object"&&(e==null?void 0:e.formattedValue)!==void 0?e.formattedValue==="-"||e.formattedValue===0?l.jsx("div",{className:"flex justify-end",children:l.jsx(Uc,{className:"h-3 w-3 text-muted-foreground"})}):e.formattedValue:typeof e=="number"?e===0||e===null?l.jsx("div",{className:"flex justify-end",children:l.jsx(Uc,{className:"h-3 w-3 text-muted-foreground"})}):e.toLocaleString():e==null?l.jsx("div",{className:"flex justify-end",children:l.jsx(Uc,{className:"h-3 w-3 text-muted-foreground"})}):(e==null?void 0:e.toString())||l.jsx("div",{className:"flex justify-end",children:l.jsx(Uc,{className:"h-3 w-3 text-muted-foreground"})})}function ftt(e){return(e==null?void 0:e.includes("__subtotal__"))||(e==null?void 0:e.includes("_SUM_"))||(e==null?void 0:e.includes("_AVG_"))||(e==null?void 0:e.includes("_COUNT_"))||(e==null?void 0:e.includes("_MIN_"))||(e==null?void 0:e.includes("_MAX_"))}function htt(e,t){const n=(e==null?void 0:e.includes("__subtotal__"))&&(e==null?void 0:e.includes("__ALL__"))||(e==null?void 0:e.includes("_SUM_ALL"))||(e==null?void 0:e.includes("_AVG_ALL"))||(e==null?void 0:e.includes("_COUNT_ALL"))||(e==null?void 0:e.includes("_MIN_ALL"))||(e==null?void 0:e.includes("_MAX_ALL")),r=(t==null?void 0:t.some(o=>o.columnName===e&&(o.subtotalScope==="grand-total"||o.subtotalLevel==="grandTotal"||o.subtotalLevel==="ALL")))??!1;return n||r}function mtt({data:e,card:t,table:n,sorting:r,setSorting:o,showRowTotals:s,onAggregationChange:i,onOpenColumnSettings:a,suppressSortControls:c=!1,tableAppearance:u}){const[,d]=v.useState(null),f=p.useDashboardStore(g=>g.isVisualEditing),h=v.useCallback(g=>{var x;return(x=n.getHeaderGroups()[0])==null?void 0:x.headers.find(b=>b.column.id===g)},[n]);return{buildColumnHeaderRows:v.useCallback(()=>{var k,T;const g=((k=t.config)==null?void 0:k.pivotByColumns)||[],x=g.length,b=((T=e.groupByColumns)==null?void 0:T.length)||1,y=e.columnHeaders.length;function w(_,E,D,M=[]){_.forEach((P,A)=>{const L=P.level;if(L<x){const O=P.columnKey||`${L}-${M.join("-")}-${P.name}-${A}`,B=P.children?1:x-L;if(D[L].push(l.jsx(wo,{colSpan:P.colspan,rowSpan:B,style:u.headerCellStyle,className:p.cn("h-8 whitespace-nowrap border-b border-border/50 px-3 py-1.5 text-center text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName,L===0?"bg-muted/95":"bg-muted/90"),children:l.jsx("div",{className:"flex items-center justify-center",children:l.jsx("span",{className:"whitespace-nowrap",children:P.name})})},O)),P.children){const H=[...M,P.name];w(P.children,L+1,D,H)}}})}function C(_,E=[]){const D=[];return _.forEach((M,P)=>{var A,L,O,B,H,R,V,z;if(M.columnKey){const F=M.columnKey||`metric-${E.join("-")}-${M.name}-${P}`,G=ftt(M.columnKey),q=htt(M.columnKey,e.columnSubtotalMeta),Y=n.getColumn(M.columnKey),K=h(M.columnKey);D.push(l.jsx(wo,{"data-column-id":M.columnKey,className:p.cn("group/header h-8 whitespace-nowrap border-b border-border/50 bg-muted/85 px-3 py-1.5 text-right text-[10px] uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName,q?"bg-muted/95 font-semibold":G?"bg-muted/90 font-medium":""),style:{...u.headerCellStyle,width:K==null?void 0:K.getSize(),minWidth:K==null?void 0:K.getSize(),maxWidth:K==null?void 0:K.getSize(),position:"relative",transition:"none"},children:Y?l.jsxs("div",{className:"flex w-full items-center justify-end gap-1",children:[c?l.jsx("span",{className:p.cn("min-w-0 truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:((B=e.columnDisplayNames)==null?void 0:B[M.columnKey])||M.name||"Metric",children:((H=e.columnDisplayNames)==null?void 0:H[M.columnKey])||M.name||"Metric"}):l.jsxs(p.Button,{variant:"ghost",className:"h-auto min-w-0 shrink p-0 hover:bg-transparent",onClick:()=>{const $=Y.getIsSorted();o($?$==="asc"?[{id:Y.id,desc:!0}]:[]:[{id:Y.id,desc:!1}])},"aria-label":`Sort ${((A=e.columnDisplayNames)==null?void 0:A[M.columnKey])||M.name||"Metric"}`,children:[l.jsx("span",{className:p.cn("min-w-0 truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:((L=e.columnDisplayNames)==null?void 0:L[M.columnKey])||M.name||"Metric",children:((O=e.columnDisplayNames)==null?void 0:O[M.columnKey])||M.name||"Metric"}),l.jsx(ws,{className:p.cn("h-3 w-3",Y.getIsSorted()==="asc"?"block":"hidden")}),l.jsx(ss,{className:p.cn("h-3 w-3",Y.getIsSorted()==="desc"?"block":"hidden")})]}),f&&a&&!(K!=null&&K.column.getIsResizing())&&l.jsxs(Xo,{modal:!1,children:[l.jsx(Qo,{asChild:!0,children:l.jsx(p.Button,{variant:"ghost",size:"icon","aria-label":`Configure ${((R=e.columnDisplayNames)==null?void 0:R[M.columnKey])||M.name||"Metric"} column`,className:"h-5 w-5 shrink-0 p-0",onClick:$=>$.stopPropagation(),children:l.jsx(Ii,{className:"h-3 w-3"})})}),l.jsxs(Fo,{align:"end",className:"w-44",children:[!c&&l.jsxs(l.Fragment,{children:[l.jsxs(In,{className:"gap-2 text-xs",onSelect:()=>o([{id:Y.id,desc:!1}]),children:[l.jsx(ws,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Sort ascending"]}),l.jsxs(In,{className:"gap-2 text-xs",onSelect:()=>o([{id:Y.id,desc:!0}]),children:[l.jsx(ss,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Sort descending"]}),l.jsx(Ta,{})]}),l.jsxs(In,{className:"gap-2 text-xs",onSelect:()=>a(M.columnKey),children:[l.jsx(p.SlidersHorizontal,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Format column"]})]})]}),K&&f&&l.jsx(ih,{header:K,isResizing:K.column.getIsResizing()})]}):l.jsx("span",{className:"block truncate px-2",title:((V=e.columnDisplayNames)==null?void 0:V[M.columnKey])||M.name||"Metric",children:((z=e.columnDisplayNames)==null?void 0:z[M.columnKey])||M.name||"Metric"})},F))}else if(M.children){const F=[...E,M.name];D.push(...C(M.children,F))}}),D}const N=l.jsxs(Lr,{"data-header-type":"pivot-hierarchy","data-header-row-index":"0","data-repeat-header":"true",children:[e.groupByColumns&&e.groupByColumns.length>0?e.groupByColumns.map((_,E)=>{var A,L,O,B,H;const D=(A=n.getHeaderGroups()[0])==null?void 0:A.headers.find(R=>R.column.id===`rowLevel${E}`),M=D==null?void 0:D.getSize(),P=`row-header-${E}`;return l.jsx(wo,{rowSpan:x+2,"data-column-id":`rowLevel${E}`,className:p.cn("group/rowheader h-8 whitespace-nowrap border-b border-r border-border/40 bg-muted/95 px-3 py-1.5 text-left align-bottom text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),style:{...u.headerCellStyle,width:M,minWidth:M,maxWidth:M,position:"relative",transition:"none"},children:l.jsxs("div",{className:"flex h-full min-w-0 items-end justify-between",children:[l.jsxs("div",{className:"relative flex min-w-0 items-center",children:[i&&l.jsx("div",{className:p.cn("absolute left-0 top-1/2 -translate-y-1/2 overflow-hidden transition-all duration-200","h-6 w-6 opacity-100"),children:l.jsx(RM,{columnName:_.label||_.name,groupByFields:e.groupByColumns||[],pivotByFields:g,currentAggregation:{rowAggregates:(L=t.config)==null?void 0:L.rowAggregates,columnAggregates:(O=t.config)==null?void 0:O.columnAggregates},onAggregationChange:i,onOpenChange:R=>d(R?P:null)})}),c?l.jsx("div",{className:p.cn("flex h-auto min-w-0 items-center gap-1 p-0 transition-all duration-200",i&&"pl-7"),children:l.jsx("span",{className:p.cn("truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:_.label||_.name,children:_.label||_.name})}):l.jsxs(p.Button,{variant:"ghost",className:p.cn("flex h-auto min-w-0 items-center gap-1 p-0 transition-all duration-200 hover:bg-transparent",i&&"pl-7"),onClick:R=>{R.stopPropagation(),R.preventDefault(),o(V=>{const z=V.find(F=>F.id===`rowLevel${E}`);return z?z.desc?[]:[{id:`rowLevel${E}`,desc:!0}]:[{id:`rowLevel${E}`,desc:!1}]})},children:[l.jsx("span",{className:p.cn("truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:_.label||_.name,children:_.label||_.name}),l.jsx(ws,{className:p.cn("h-3 w-3 flex-shrink-0",((B=r.find(R=>R.id===`rowLevel${E}`))==null?void 0:B.desc)===!1?"block":"hidden")}),l.jsx(ss,{className:p.cn("h-3 w-3 flex-shrink-0",((H=r.find(R=>R.id===`rowLevel${E}`))==null?void 0:H.desc)===!0?"block":"hidden")})]})]}),D&&f&&l.jsx(ih,{header:D,isResizing:D.column.getIsResizing()})]})},`row-header-corner-${E}`)}):l.jsx(wo,{colSpan:b,rowSpan:x+2,style:u.headerCellStyle,className:p.cn("h-8 whitespace-nowrap border-b border-border/50 bg-muted/95 px-3 py-1.5 text-[10px] uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),children:""}),l.jsx(wo,{colSpan:y,style:u.headerCellStyle,className:p.cn("h-8 whitespace-nowrap border-b border-border/50 bg-muted/95 px-3 py-1.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),children:l.jsxs("div",{className:"group/pivot-main relative flex items-center",children:[i&&(()=>{var E,D;const _="pivot-main";return l.jsx("div",{className:p.cn("absolute left-0 top-1/2 -translate-y-1/2 overflow-hidden transition-all duration-200","h-6 w-6 opacity-100"),children:l.jsx(RM,{columnName:"Pivot Columns",groupByFields:e.groupByColumns||[],pivotByFields:g,currentAggregation:{rowAggregates:(E=t.config)==null?void 0:E.rowAggregates,columnAggregates:(D=t.config)==null?void 0:D.columnAggregates},onAggregationChange:i,onOpenChange:M=>d(M?_:null)})})})(),l.jsx("div",{className:p.cn("transition-all duration-200",i&&"pl-7"),children:g.map((_,E)=>l.jsxs("span",{className:"inline-flex items-center",children:[_.label,E<g.length-1&&l.jsx(Mt.ChevronRight,{className:"mx-1 inline-block h-4 w-4 text-muted-foreground"})]},_.id))})]})},"pivot-hierarchy"),s&&(()=>{var D;const _=(D=n.getHeaderGroups()[0])==null?void 0:D.headers.find(M=>M.column.id==="rowTotal"),E=_==null?void 0:_.getSize();return l.jsx(wo,{"data-column-id":"rowTotal",className:p.cn("group/total h-8 whitespace-nowrap border-b border-border/50 bg-muted/95 px-3 py-1.5 text-center text-[10px] uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),rowSpan:x+2,style:{...u.headerCellStyle,width:E,minWidth:E,maxWidth:E,position:"relative",transition:"none"},children:(()=>{const M=n.getColumn("rowTotal");return M?l.jsxs("div",{className:"flex w-full items-center justify-end",children:[c?l.jsx("span",{className:p.cn("truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:"Total",children:"Total"}):l.jsxs(p.Button,{variant:"ghost",className:"h-auto min-w-0 p-0 hover:bg-transparent",onClick:()=>{const P=M.getIsSorted();o(P?P==="asc"?[{id:M.id,desc:!0}]:[]:[{id:M.id,desc:!1}])},"aria-label":"Sort Total",children:[l.jsx("span",{className:p.cn("truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:"Total",children:"Total"}),l.jsx(ws,{className:p.cn("h-3 w-3",M.getIsSorted()==="asc"?"block":"hidden")}),l.jsx(ss,{className:p.cn("h-3 w-3",M.getIsSorted()==="desc"?"block":"hidden")})]}),_&&f&&l.jsx(ih,{header:_,isResizing:_.column.getIsResizing()})]}):"Total"})()},"pivot-hierarchy-total")})()]},"pivot-hierarchy"),S=[];if(e.columnGroups&&e.columnGroups.length>0){const _=Array.from({length:x},()=>[]);w(e.columnGroups,0,_,[]);for(let E=0;E<x;E++)S.push(l.jsx(Lr,{"data-header-type":"pivot-values","data-header-row-index":E+1,"data-repeat-header":"true",children:_[E]},`pivot-row-${E}`))}let j=[];e.columnGroups&&e.columnGroups.length>0?j=C(e.columnGroups,[]):e.columnHeaders.forEach(_=>{var M,P,A,L,O,B,H,R,V;const E=n.getColumn(_),D=(M=n.getHeaderGroups()[0])==null?void 0:M.headers.find(z=>z.column.id===_);j.push(l.jsx(wo,{"data-column-id":_,className:p.cn("group/colheader h-8 whitespace-nowrap border-b border-border/50 bg-muted/85 px-3 py-1.5 text-right text-[10px] uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),style:{...u.headerCellStyle,width:D==null?void 0:D.getSize(),minWidth:D==null?void 0:D.getSize(),maxWidth:D==null?void 0:D.getSize(),position:"relative",transition:"none"},children:E?l.jsxs("div",{className:"flex w-full items-center justify-end gap-1",children:[c?l.jsx("span",{className:p.cn("min-w-0 truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:((O=e.columnDisplayNames)==null?void 0:O[_])||_,children:((B=e.columnDisplayNames)==null?void 0:B[_])||_}):l.jsxs(p.Button,{variant:"ghost",className:"h-auto min-w-0 shrink p-0 hover:bg-transparent",onClick:()=>{const z=E.getIsSorted();o(z?z==="asc"?[{id:E.id,desc:!0}]:[]:[{id:E.id,desc:!1}])},"aria-label":`Sort ${((P=e.columnDisplayNames)==null?void 0:P[_])||_}`,children:[l.jsx("span",{className:p.cn("min-w-0 truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:((A=e.columnDisplayNames)==null?void 0:A[_])||_,children:((L=e.columnDisplayNames)==null?void 0:L[_])||_}),l.jsx(ws,{className:p.cn("h-3 w-3",E.getIsSorted()==="asc"?"block":"hidden")}),l.jsx(ss,{className:p.cn("h-3 w-3",E.getIsSorted()==="desc"?"block":"hidden")})]}),f&&a&&!(D!=null&&D.column.getIsResizing())&&l.jsxs(Xo,{modal:!1,children:[l.jsx(Qo,{asChild:!0,children:l.jsx(p.Button,{variant:"ghost",size:"icon","aria-label":`Configure ${((H=e.columnDisplayNames)==null?void 0:H[_])||_} column`,className:"h-5 w-5 shrink-0 p-0",onClick:z=>z.stopPropagation(),children:l.jsx(Ii,{className:"h-3 w-3"})})}),l.jsxs(Fo,{align:"end",className:"w-44",children:[!c&&l.jsxs(l.Fragment,{children:[l.jsxs(In,{className:"gap-2 text-xs",onSelect:()=>o([{id:E.id,desc:!1}]),children:[l.jsx(ws,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Sort ascending"]}),l.jsxs(In,{className:"gap-2 text-xs",onSelect:()=>o([{id:E.id,desc:!0}]),children:[l.jsx(ss,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Sort descending"]}),l.jsx(Ta,{})]}),l.jsxs(In,{className:"gap-2 text-xs",onSelect:()=>a(_),children:[l.jsx(p.SlidersHorizontal,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Format column"]})]})]}),D&&f&&l.jsx(ih,{header:D,isResizing:D.column.getIsResizing()})]}):l.jsx("span",{className:"block truncate px-2",title:((R=e.columnDisplayNames)==null?void 0:R[_])||_,children:((V=e.columnDisplayNames)==null?void 0:V[_])||_})},_))});const I=l.jsxs(Lr,{"data-header-type":"metrics","data-header-row-index":x>0?x+1:0,"data-repeat-header":"true",children:[x===0&&(e.groupByColumns&&e.groupByColumns.length>0?e.groupByColumns.map((_,E)=>{var A,L,O,B;const D=(A=n.getHeaderGroups()[0])==null?void 0:A.headers.find(H=>H.column.id===`rowLevel${E}`),M=D==null?void 0:D.getSize(),P=`metric-row-${E}`;return l.jsx(wo,{"data-column-id":`rowLevel${E}`,className:p.cn("group/metricrow h-8 whitespace-nowrap border-b border-border/50 bg-muted/85 px-3 py-1.5 text-left text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),style:{...u.headerCellStyle,width:M,minWidth:M,maxWidth:M,position:"relative",transition:"none"},children:l.jsxs("div",{className:"flex w-full items-center justify-between",children:[l.jsxs("div",{className:"relative flex min-w-0 items-center",children:[i&&l.jsx("div",{className:p.cn("absolute left-0 top-1/2 -translate-y-1/2 overflow-hidden transition-all duration-200","h-6 w-6 opacity-100"),children:l.jsx(RM,{columnName:_.label||_.name,groupByFields:e.groupByColumns||[],pivotByFields:((L=t.config)==null?void 0:L.pivotByColumns)||[],currentAggregation:{rowAggregates:(O=t.config)==null?void 0:O.rowAggregates,columnAggregates:(B=t.config)==null?void 0:B.columnAggregates},onAggregationChange:i,onOpenChange:H=>d(H?P:null)})}),c?l.jsx("div",{className:p.cn("flex h-auto min-w-0 items-center gap-1 p-0 transition-all duration-200",i&&"pl-7"),children:l.jsx("span",{className:p.cn("truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:_.label||_.name,children:_.label||_.name})}):l.jsxs(p.Button,{variant:"ghost",className:p.cn("flex h-auto min-w-0 items-center gap-1 p-0 transition-all duration-200 hover:bg-transparent",i&&"pl-7"),onClick:()=>{o(H=>{const R=H.find(V=>V.id===`rowLevel${E}`);return R?R.desc===!1?[{id:`rowLevel${E}`,desc:!0}]:[]:[{id:`rowLevel${E}`,desc:!1}]})},children:[l.jsx("span",{className:p.cn("truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:_.label||_.name,children:_.label||_.name}),(()=>{const H=r.find(R=>R.id===`rowLevel${E}`);return l.jsxs(l.Fragment,{children:[l.jsx(ss,{className:p.cn("h-3 w-3 flex-shrink-0",(H==null?void 0:H.desc)===!0?"block":"hidden")}),l.jsx(ws,{className:p.cn("h-3 w-3 flex-shrink-0",(H==null?void 0:H.desc)===!1?"block":"hidden")})]})})()]})]}),D&&f&&l.jsx(ih,{header:D,isResizing:D.column.getIsResizing()})]})},`row-header-title-${E}`)}):Array.from({length:b}).map((_,E)=>l.jsx(wo,{style:u.headerCellStyle,className:p.cn("h-8 whitespace-nowrap border-b border-border/50 bg-muted/85 py-1.5 text-left text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),children:`Level ${E+1}`},`empty-header-metric-${E}`))),j]},"metric-row");return x>0?[N,...S,I]:[I]},[e,t,n,r,o,s,i,h,d,f,a,c,u])}}function ptt(e,t,n){var k,T;const r=p.useDashboardStore(_=>_.isVisualEditing);p.useDashboardStore(_=>_.isDashboardEditing),p.useDashboardStore(_=>_.selectedSheetId);const{updateCurrentDashboardCard:o,updateFrame:s}=p.useDashboardActions(),i=p.useEditorStore(_=>{var E;return(E=_.actions)==null?void 0:E.setCardPreferences}),a=p.useEditorStore(_=>_.card),c=((T=(k=e==null?void 0:e.preferences)==null?void 0:k.tablePrefs)==null?void 0:T.columnSettingsMap)??p.EMPTY_COLUMN_SETTINGS,u=v.useMemo(()=>ac(c),[c]),[d,f]=v.useState(!1),[h,m]=v.useState(null),[g,x]=v.useState(Ao()),[b,y]=v.useState(!1),w=v.useRef(Ao()),C=v.useCallback(_=>{var D,M;m(_);let E=u[_];if(!E){const P=t==null?void 0:t.map(A=>{var L,O;return{[_]:(O=(L=A.cells)==null?void 0:L[_])==null?void 0:O.value}});E=P&&P.length>0?K0(_,P,n):Ao()}E=Ki({card:e,columnId:_,resolvedSettings:E,metricId:(D=n==null?void 0:n[_])==null?void 0:D.metricId,metricAlias:(M=n==null?void 0:n[_])==null?void 0:M.metricAlias,preserveOmittedProperties:!0})||E,w.current=E,x(E),y(!1),f(!0)},[e,u,t,n]),N=v.useCallback(()=>{var _,E;if(h&&g){const D=K5({persisted:c,columnId:h,baseline:w.current,next:g,reset:b});if(r&&i){const M={...a.preferences,tablePrefs:{...(_=a.preferences)==null?void 0:_.tablePrefs,columnSettingsMap:D}};i(M)}else if(o){const M={...e,preferences:{...e.preferences,tablePrefs:{...(E=e.preferences)==null?void 0:E.tablePrefs,columnSettingsMap:D}}};o(M)}}f(!1)},[h,g,b,c,r,i,a,o,e]),S=v.useCallback(()=>{h&&(x(Ao()),y(!0))},[h]),j=v.useCallback(_=>{y(!1),x(_)},[]),I=v.useCallback(()=>{var _,E;if(r&&i){const D={...a.preferences,tablePrefs:{...(_=a.preferences)==null?void 0:_.tablePrefs,columnSettingsMap:{}}};i(D)}else if(o){const D={...e,preferences:{...e.preferences,tablePrefs:{...(E=e.preferences)==null?void 0:E.tablePrefs,columnSettingsMap:{}}}};o(D)}f(!1)},[r,i,a,o,e]);return{columnSettings:u,columnSettingsOpen:d,activeColumnId:h,tempColumnSettings:g,isVisualEditing:r,openColumnSettings:C,applyColumnSettings:N,resetColumnSettings:S,resetAllColumnSettings:I,setColumnSettingsOpen:f,setTempColumnSettings:j}}function gtt({table:e,data:t,columns:n,subtotalColumnKeys:r,grandTotalColumnKeys:o,isTablePrintDisplayMode:s=!1,shouldVirtualizeRows:i=!1,virtualRows:a,paddingTop:c=0,paddingBottom:u=0,measureElement:d,disableRowTransitions:f=!1,suppressEmptyState:h=!1,tableAppearance:m}){var C;const g=e.getRowModel().rows,x=((C=t.groupByColumns)==null?void 0:C.length)||1,y=i&&a&&a.length>0?a:g,w=n.length||1;return g!=null&&g.length?l.jsxs(l.Fragment,{children:[i&&c>0&&l.jsx(Lr,{"aria-hidden":!0,className:"pointer-events-none border-none",children:l.jsx(Kn,{colSpan:w,style:{height:c,padding:0,border:"none"}})}),y.map((N,S)=>{const j=i?N.index:S,I=i?g[j]:N;if(!I)return null;const k=I.original,T=e.getRowModel().rows,_=j===T.length-1;return l.jsx(Lr,{ref:i&&d?E=>d(E):void 0,style:k.isSubtotal?m.subtotalRowStyle:m.getDataRowStyle(j),className:p.cn("border-border/40",(f||m.hasHoverRowStyle)&&"!transition-none",!f&&!m.hasHoverRowStyle&&"transition-colors duration-150",!k.isSubtotal&&m.dataRowClassName,k.isSubtotal?"border-t border-t-border/50 bg-muted/70 font-medium":"hover:bg-muted/40"),"data-row-type":k.isSubtotal?"subtotal":"data","data-row-index":j,...k.isSubtotal&&{"data-subtotal-level":k.subtotalLevel},children:I.getVisibleCells().map(E=>{const D=E.column.id;if(D.startsWith("rowLevel")){const A=parseInt(D.replace("rowLevel",""));if(k.isSubtotal&&k.subtotalLevel){const O=r_(t.groupByColumns,k.subtotalLevel);return A===O?l.jsx(Kn,{colSpan:s?1:x-A,...Id({tableAppearance:m,divider:"row",textFlow:"direct",className:p.cn("border-r border-border/40 px-4 font-medium text-foreground/90",!_&&"border-b border-b-border/35")}),children:wi(E.column.columnDef.cell,E.getContext())},E.id):A<O?l.jsx(Kn,{...Id({tableAppearance:m,divider:"row",textFlow:"direct",className:p.cn("border-r border-border/40 px-4 font-medium text-foreground/90",!_&&"border-b border-b-border/35")}),children:wi(E.column.columnDef.cell,E.getContext())},E.id):s?l.jsx(Kn,{...Id({tableAppearance:m,divider:"row",textFlow:"direct",className:p.cn("border-r border-border/40 px-4 text-foreground/90",!_&&"border-b border-b-border/35")})},E.id):null}if(!i&&!s&&j>0)for(let O=j-1;O>=0;O--){const B=T[O].original;if(B.isSubtotal||B.isGrandTotal)break;let H=!0;for(let R=0;R<=A;R++)if(Ns(k,R)!==Ns(B,R)){H=!1;break}if(H)return null}let L=1;if(!i&&!s)for(let O=j+1;O<T.length;O++){const B=T[O].original;if(B.isSubtotal||B.isGrandTotal)break;let H=!0;for(let R=0;R<=A;R++)if(Ns(k,R)!==Ns(B,R)){H=!1;break}if(H)L++;else break}return l.jsx(Kn,{rowSpan:i?void 0:L,...qh({tableAppearance:m,divider:"row",textFlow:"direct",className:p.cn("border-r border-border/40 px-4 text-foreground/90",!_&&"border-b border-b-border/35")}),children:wi(E.column.columnDef.cell,E.getContext())},E.id)}const M=o.has(D),P=r.has(D);return l.jsx(Kn,{"data-column-id":D,...k.isSubtotal?Id({tableAppearance:m,divider:"row",textFlow:"direct",style:{width:E.column.getSize(),minWidth:E.column.getSize(),maxWidth:E.column.getSize(),transition:"none"},className:p.cn("px-4 text-foreground/90",!_&&"border-b border-b-border/35",M?"bg-muted/50":P?"bg-muted/30":void 0)}):qh({tableAppearance:m,divider:"row",textFlow:"direct",style:{width:E.column.getSize(),minWidth:E.column.getSize(),maxWidth:E.column.getSize(),transition:"none"},className:p.cn("px-4 text-foreground/90",!_&&"border-b border-b-border/35",M?"bg-muted/50":P?"bg-muted/30":void 0)}),children:wi(E.column.columnDef.cell,E.getContext())},E.id)})},I.id)}),i&&u>0&&l.jsx(Lr,{"aria-hidden":!0,className:"pointer-events-none border-none",children:l.jsx(Kn,{colSpan:w,style:{height:u,padding:0,border:"none"}})})]}):h?null:l.jsx(Lr,{className:"h-8",children:l.jsx(Kn,{colSpan:n.length,className:"text-center",children:"No results."})})}function btt({grandTotalRows:e,data:t,card:n,table:r,showRowTotals:o,columnSettings:s,isSqlCard:i=!1,contextTimezone:a,browserTimezone:c,onAggregationLabelChange:u,tableAppearance:d,valueFormatPreferences:f,resolveBoundCurrency:h}){return e.length===0?null:l.jsx(l.Fragment,{children:e.map((m,g)=>{var x;return l.jsxs(Lr,{style:d.grandTotalRowStyle,className:"h-8 border-border/40 font-semibold","data-row-type":"grandtotal","data-grandtotal":"true","data-grandtotal-index":g,children:[l.jsx(Kn,{colSpan:((x=t.groupByColumns)==null?void 0:x.length)||1,...Jc({tableAppearance:d,overflow:"visible",className:"border-r border-t-2 border-border/40 border-t-border/60 px-4 font-semibold text-foreground/90"}),children:u?l.jsx(Si,{value:(()=>{var w,C,N;const b=m.aggregateFunction||"SUM";return((N=(C=(w=n.config)==null?void 0:w.rowAggregates)==null?void 0:C.find(S=>S.function===b&&S.groupLevel==="ALL"))==null?void 0:N.label)||m.fieldValues[0]})(),placeholder:m.fieldValues[0],onSave:b=>{const y=m.aggregateFunction||"SUM";u({type:"row",level:"ALL",function:y,label:b})},displayClassName:"text-right"}):m.fieldValues[0]}),t.columnHeaders.map(b=>{var j,I,k,T,_,E;const y=(I=(j=t.columnMetadata)==null?void 0:j[b])==null?void 0:I.metricId,w=ic({card:n,columnKey:b,metricId:y}),C=Ki({card:n,columnId:b,resolvedSettings:s==null?void 0:s[b],metricId:y,metricAlias:(T=(k=t.columnMetadata)==null?void 0:k[b])==null?void 0:T.metricAlias,valueFormatPreferences:f,boundCurrency:w?h(w):void 0}),N=(_=r.getHeaderGroups()[0])==null?void 0:_.headers.find(D=>D.column.id===b),S=Jc({tableAppearance:d,style:{width:N==null?void 0:N.getSize(),minWidth:N==null?void 0:N.getSize(),maxWidth:N==null?void 0:N.getSize(),transition:"none"},className:"numeric border-t-2 border-t-border/60 px-4 text-right font-semibold tabular-nums text-foreground/90"});return l.jsx(Kn,{"data-column-id":b,className:S.className,style:S.style,children:Gj((E=m.cells[b])==null?void 0:E.value,C,a,c,i)},b)}),o&&(()=>{var N;const b=vL({card:n,columnHeaders:t.columnHeaders,columnMetadata:t.columnMetadata,columnSettings:s,valueFormatPreferences:f,resolveBoundCurrency:h}),y=(N=r.getHeaderGroups()[0])==null?void 0:N.headers.find(S=>S.column.id==="rowTotal"),w=y==null?void 0:y.getSize(),C=Jc({tableAppearance:d,style:{width:w,minWidth:w,maxWidth:w,transition:"none"},className:"numeric border-t-2 border-t-border/60 px-4 text-right font-semibold tabular-nums text-foreground/90"});return l.jsx(Kn,{className:C.className,"data-column-id":"rowTotal",style:C.style,children:Gj(Hte(m,t.columnHeaders),b,a,c,i)})})()]},m.id)})})}function xtt({groupByColumns:e,numRowLevels:t,onAggregationLabelChange:n,isTablePrintDisplayMode:r=!1,isCellWrapping:o=!1,cellContentClassName:s,onCellClick:i}){const a=[];return e&&e.length>0?e.forEach((c,u)=>{a.push({id:`rowLevel${u}`,header:()=>l.jsx("div",{className:"group px-3 py-1 text-left text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:l.jsx("div",{className:"flex items-center gap-1",children:l.jsx("span",{className:"whitespace-nowrap",children:c.label||c.name})})}),accessorFn:d=>d.fieldValues[u],cell:({row:d,table:f})=>{const h=d.original;if(h.isSubtotal&&h.subtotalLevel){const b=r_(e,h.subtotalLevel);if(u===b){const y=h.fieldValues[u];return l.jsx("div",{className:p.cn("align-top font-medium",!o&&"whitespace-nowrap",s),style:{gridColumn:`span ${t-u}`},children:y.includes(" Total")&&n?l.jsx(Si,{value:y,placeholder:y,onSave:w=>{const C=h.aggregateFunction||"SUM";if(h.subtotalLevel&&e){const N=b$e(e,h.subtotalLevel);N&&n({type:"row",level:N.id,function:C,label:w})}},displayClassName:"text-left"}):y})}else if(u<b)return l.jsx("div",{className:p.cn("align-top font-medium",!o&&"whitespace-nowrap",s),children:h.fieldValues[u]});return r?l.jsx("div",{className:p.cn("align-top",!o&&"whitespace-nowrap",s)}):null}const m=f.getRowModel().rows,g=m.findIndex(b=>b.id===d.id);if(!r&&g>0)for(let b=g-1;b>=0;b--){const y=m[b].original;if(y.isSubtotal||y.isGrandTotal)break;let w=!0;for(let C=0;C<=u;C++)if(Ns(h,C)!==Ns(y,C)){w=!1;break}if(w)return null}let x=1;if(!r)for(let b=g+1;b<m.length;b++){const y=m[b].original;if(y.isSubtotal||y.isGrandTotal)break;let w=!0;for(let C=0;C<=u;C++)if(Ns(h,C)!==Ns(y,C)){w=!1;break}if(w)x++;else break}return l.jsx("div",{className:p.cn("align-top",!o&&"whitespace-nowrap",s),onClick:i&&!h.isGrandTotal?b=>i(b,h,`rowLevel${u}`):void 0,style:{gridRow:r?void 0:`span ${x}`},children:h.fieldValues[u]})}})}):a.push({id:"rowHeader",header:()=>l.jsx("div",{className:"px-3 py-1 text-left font-medium",children:"Row"}),accessorFn:c=>c.rowKey,cell:({getValue:c})=>l.jsx("div",{className:p.cn("min-w-[150px] max-w-[300px] border-x border-y border-border px-3 py-1",s),children:String(c())})}),a}function ytt({columnHeaders:e,columnDisplayNames:t,setSorting:n,columnSettings:r,card:o,columnMetadata:s,contextTimezone:i,browserTimezone:a,isSqlCard:c=!1,suppressSortControls:u=!1,valueFormatPreferences:d,resolveBoundCurrency:f,onCellClick:h}){return e.map(m=>({id:m,accessorFn:g=>{var x;return(x=g.cells[m])==null?void 0:x.value},header:({column:g})=>{const x=(t==null?void 0:t[m])||m;return l.jsx("div",{className:"flex w-full items-center justify-end",children:u?l.jsx("span",{className:"text-sm font-medium",children:x}):l.jsxs(p.Button,{variant:"ghost",className:"h-auto min-w-0 p-0 hover:bg-transparent",onClick:()=>{const b=g.getIsSorted();n(b?b==="asc"?[{id:g.id,desc:!0}]:[]:[{id:g.id,desc:!1}])},"aria-label":`Sort ${x}`,children:[l.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:x}),g.getIsSorted()==="asc"?l.jsx(ws,{className:"h-3 w-3"}):g.getIsSorted()==="desc"?l.jsx(ss,{className:"h-3 w-3"}):null]})})},cell:({getValue:g,row:x})=>{var S,j,I;const b=g(),y=o?ic({card:o,columnKey:m,metricId:(S=s==null?void 0:s[m])==null?void 0:S.metricId}):void 0,w=Ki({card:o,columnId:m,resolvedSettings:r==null?void 0:r[m],metricId:(j=s==null?void 0:s[m])==null?void 0:j.metricId,metricAlias:(I=s==null?void 0:s[m])==null?void 0:I.metricAlias,valueFormatPreferences:d,boundCurrency:y?f(y):void 0}),C=(w==null?void 0:w.textAlign)||"right",N=C==="left"?"text-left":C==="center"?"text-center":"text-right";return l.jsx("div",{className:N,onClick:h?k=>h(k,x.original,m):void 0,children:Gj(b,w,i,a,c)})}}))}function vtt({columnHeaders:e,setSorting:t,suppressSortControls:n=!1,settings:r}){return{id:"rowTotal",header:({column:o})=>l.jsx("div",{className:"flex w-full items-center justify-end",children:n?l.jsx("span",{className:"text-sm font-medium",children:"Total"}):l.jsxs(p.Button,{variant:"ghost",className:"h-auto min-w-0 p-0 hover:bg-transparent",onClick:()=>{const s=o.getIsSorted();t(s?s==="asc"?[{id:o.id,desc:!0}]:[]:[{id:o.id,desc:!1}])},"aria-label":"Sort Total",children:[l.jsx("span",{className:"text-sm font-medium",children:"Total"}),o.getIsSorted()==="asc"?l.jsx(ws,{className:"h-3 w-3"}):o.getIsSorted()==="desc"?l.jsx(ss,{className:"h-3 w-3"}):null]})}),cell:({row:o})=>{const s=o.original,i=Hte(s,e);return l.jsx("div",{className:"text-right text-sm font-medium",children:Gj(i,r)})}}}function _U(e){const t=at.resolveGroupedTemporalFieldPresentationByRole({presentation:e.presentation,fieldId:e.field.id,role:e.field.role});return e.value===null?{field:e.field,operator:"isNull",value:null,...t?{label:"(Blank)",temporalBucket:t.metadata}:{}}:{field:e.field,operator:"=",value:e.value,...t?{label:at.formatGroupedTemporalFieldValue({fieldId:e.field.id,role:e.field.role,value:e.value,presentation:e.presentation}),temporalBucket:t.metadata}:{}}}function wtt(e){var m,g,x;if(e.row.isSubtotal||e.row.isGrandTotal||!e.card.config)return;const t=e.card.config,n=e.row.canonicalFieldValues||e.row.fieldValues,r=(t.groupByColumns||[]).map((b,y)=>_U({field:b,value:n[y]??null,presentation:e.temporalPresentation})),o=(m=e.resultColumns)==null?void 0:m.find(b=>b.key===e.columnKey);if((((g=o==null?void 0:o.pivotIdentity)==null?void 0:g.members)??[]).forEach(b=>{const y=(t.pivotByColumns||[]).find(w=>w.id===b.fieldId);y&&r.push(_U({field:y,value:b.value,presentation:e.temporalPresentation}))}),r.length===0)return;const i=o==null?void 0:o.pivotIdentity,a=t.metricColumns||[],c=i?a.find(b=>Vr.resolveMetricResultAlias(b)===i.metricAlias):void 0,u=i?a.filter(b=>b.id===i.metricId):[],d=c||(u.length===1?u[0]:void 0),f=(x=e.row.cells[e.columnKey])==null?void 0:x.value,h=d&&typeof f=="number"?[{field:d,value:f}]:[];return{conditions:r,...h.length?{metrics:h}:{}}}function tx({data:e,card:t,options:n={},onAggregationChange:r,onAggregationLabelChange:o,suppressSortControls:s=!1,renderPlainWrapper:i=!1,frameId:a,sheetId:c,onMultipleInteractions:u}){var ee,ae,se,he,ge;const{preferences:d,resolveBoundCurrency:f}=Pa(t,e.columnHeaders),{displayPreferences:h,shouldShowElement:m}=pl(),g=v.useRef(null),x=v.useMemo(()=>w3(),[]),{updatePageSize:b}=p.useEditorActions(),y=v.useMemo(()=>typeof document<"u"&&"onscrollend"in document,[]),w=!!(t!=null&&t.sql),C=typeof window<"u"?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0,N=void 0,S=v.useMemo(()=>p.getInteractions(t.interactionConfig).some(p.isInteractionConfiguredForExecution),[t.interactionConfig]),{handlePointerInteraction:j}=p.useEventEngine(t,a||"",c||"",u),I=v.useCallback((ke,De,Re)=>{if(!S||!a||!c)return;const Ve=wtt({card:t,row:De,columnKey:Re,resultColumns:e.resultColumns,temporalPresentation:e.temporalPresentation});Ve&&(ke.stopPropagation(),j({context:Ve,gesture:"leftClick",modifierKeys:{shift:ke.shiftKey,ctrl:ke.ctrlKey,meta:ke.metaKey},position:{x:ke.clientX,y:ke.clientY}}))},[t,e.resultColumns,e.temporalPresentation,a,j,S,c]),k=n.showRowTotals??!1,{columnSizing:T,onColumnSizingChange:_}=v3({card:t}),{subtotalColumnKeys:E,grandTotalColumnKeys:D}=v.useMemo(()=>NDe(e.columnSubtotalMeta),[e.columnSubtotalMeta]),{tableData:M,grandTotalRows:P}=v.useMemo(()=>yL(e),[e]),{sorting:A,setSorting:L,sortedTableData:O}=dtt(M,e),{columnSettings:B,columnSettingsOpen:H,activeColumnId:R,tempColumnSettings:V,isVisualEditing:z,openColumnSettings:F,applyColumnSettings:G,resetColumnSettings:q,resetAllColumnSettings:Y,setColumnSettingsOpen:K,setTempColumnSettings:$}=ptt(t,O,e.columnMetadata),X=S3({displayMode:h.mode,isVisualEditing:z,printBehavior:"any-print",renderPlainWrapper:i}),W=X.isPrint,U=w_("pivotTable",(ae=(ee=t==null?void 0:t.preferences)==null?void 0:ee.tablePrefs)==null?void 0:ae.density,X.mode==="document-print"?"document":"appearance"),Z={...n.pagination},Q=itt(Z,O.length),J=v.useMemo(()=>{var ve;const ke=[],De=((ve=e.groupByColumns)==null?void 0:ve.length)||1,Re=xtt({groupByColumns:e.groupByColumns,numRowLevels:De,onAggregationLabelChange:o,isTablePrintDisplayMode:W,isCellWrapping:U.isCellWrapping,cellContentClassName:U.cellContentClassName,onCellClick:I});ke.push(...Re);const Ve=ytt({columnHeaders:e.columnHeaders,columnDisplayNames:e.columnDisplayNames,setSorting:L,suppressSortControls:s,columnSettings:B,card:t,columnMetadata:e.columnMetadata,contextTimezone:N,browserTimezone:C,isSqlCard:w,valueFormatPreferences:d,resolveBoundCurrency:f,onCellClick:I});if(ke.push(...Ve),k){const Ke=vtt({columnHeaders:e.columnHeaders,setSorting:L,suppressSortControls:s,settings:vL({card:t,columnHeaders:e.columnHeaders,columnMetadata:e.columnMetadata,columnSettings:B,valueFormatPreferences:d,resolveBoundCurrency:f})});ke.push(Ke)}return ke},[t,e,k,o,L,s,W,B,N,C,w,U.cellContentClassName,U.isCellWrapping,d,f,I]),re=f_({data:O,columns:J,state:{sorting:A,columnSizing:T,pagination:{pageIndex:Q.pageIndex,pageSize:Q.pageSize}},onSortingChange:L,onPaginationChange:void 0,getCoreRowModel:u_(),getPaginationRowModel:!Q.isServerSidePagination&&X.allowPagination?d_():void 0,manualPagination:Q.isServerSidePagination||!X.allowPagination,manualSorting:!0,pageCount:Q.pageCount,enableColumnResizing:!0,columnResizeMode:"onChange",onColumnSizingChange:_}),de=re.getRowModel().rows,ce=X.allowVirtualization&&de.length>75,oe=ce&&(!x||U.isCellWrapping),fe=v_({count:ce?de.length:0,getScrollElement:()=>g.current,estimateSize:()=>U.dataRowHeight??32,overscan:x?5:10,useScrollendEvent:x&&y,isScrollingResetDelay:x?240:150}),we=ce?fe.getVirtualItems():[],pe=ce&&we.length>0?we[0].start:0,ne=ce&&we.length>0?fe.getTotalSize()-we[we.length-1].end:0,{buildColumnHeaderRows:Se}=mtt({data:e,card:t,table:re,sorting:A,setSorting:L,showRowTotals:k,onAggregationChange:r,onOpenColumnSettings:F,suppressSortControls:s,tableAppearance:U}),ue=Se(),ie=l.jsxs("table",{className:"w-full border-separate border-spacing-0 text-sm [border-spacing:0]",onMouseDown:ke=>ke.stopPropagation(),"data-pivot-table":"true","data-row-levels":((se=e.groupByColumns)==null?void 0:se.length)||1,"data-pivot-levels":e.columnGroups&&((ge=(he=t.config)==null?void 0:he.pivotByColumns)==null?void 0:ge.length)||0,children:[l.jsx(tp,{style:U.headerStyle,className:p.cn("bg-muted/95 [&_tr]:border-b-0",X.allowStickyHeader&&U.isHeaderSticky&&"sticky top-0 z-20 supports-[backdrop-filter]:bg-muted/80 supports-[backdrop-filter]:backdrop-blur-sm"),children:ue}),l.jsx(Qd,{children:l.jsx(gtt,{table:re,data:e,columns:J,subtotalColumnKeys:E,grandTotalColumnKeys:D,isTablePrintDisplayMode:W,shouldVirtualizeRows:ce,virtualRows:we,paddingTop:pe,paddingBottom:ne,measureElement:oe?fe.measureElement:void 0,disableRowTransitions:x,suppressEmptyState:P.length>0,tableAppearance:U})}),P.length>0&&l.jsx("tfoot",{className:p.cn("border-t border-t-border/60 bg-muted/95",X.allowStickyHeader&&"sticky bottom-0 z-10"),"data-grandtotal":"true",style:U.grandTotalRowStyle,children:l.jsx(btt,{grandTotalRows:P,data:e,card:t,table:re,showRowTotals:k,columnSettings:B,isSqlCard:w,contextTimezone:N,browserTimezone:C,onAggregationLabelChange:o,tableAppearance:U,valueFormatPreferences:d,resolveBoundCurrency:f})})]});return l.jsxs("div",{className:"flex h-full w-full flex-col gap-2",children:[X.usePlainWrapper?l.jsx("div",{ref:g,style:U.containerStyle,className:"data-table-scroll-container relative h-full rounded-none border border-border/60 bg-muted/20",onMouseDown:ke=>ke.stopPropagation(),children:ie}):l.jsxs(yl,{ref:g,style:U.containerStyle,className:"data-table-scroll-container relative h-full rounded-none border border-border/60 bg-muted/20",onMouseDown:ke=>ke.stopPropagation(),children:[ie,l.jsx(p.ScrollBar,{orientation:"horizontal",className:"z-20"})]}),X.allowPagination&&Q.showPagination&&l.jsx(h_,{totalColumns:J.length,pageCount:Q.pageCount||re.getPageCount(),pageIndex:Q.pageIndex,pageSize:Q.pageSize,rowCount:Q.totalCount,selectedRowCount:0,setPageIndex:Q.setPageIndex,setPageSize:Q.setPageSize,canPreviousPage:Q.canPreviousPage,canNextPage:Q.canNextPage,previousPage:Q.previousPage,nextPage:Q.nextPage,onPageSizePreferenceChange:X.showEditorControls?b:void 0,onClearSelection:()=>{},appearance:U.pagination}),R&&l.jsx(b3,{column:re.getColumn(R)||null,settings:V,onSettingsChange:$,onApply:G,onReset:q,onResetAll:Y,open:H,onOpenChange:K,tableType:"pivot",isSqlCard:w})]})}const Ctt=420,Stt=360,Ntt="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.1/chart.umd.min.js";function jtt(e){return`<!DOCTYPE html>
961
+ `)),[]});var nGe=(e=>(e[e.None=0]="None",e[e.Closed=1]="Closed",e[e.Enter=2]="Enter",e[e.Leave=4]="Leave",e))(nGe||{});function rGe(e){let t={};for(let n in e)e[n]===!0&&(t[`data-${n}`]="");return t}function oGe(e,t,n,r){let[o,s]=v.useState(n),{hasFlag:i,addFlag:a,removeFlag:c}=tGe(e&&o?3:0),u=v.useRef(!1),d=v.useRef(!1),f=Qb();return ko(()=>{var h;if(e){if(n&&s(!0),!t){n&&a(3);return}return(h=void 0)==null||h.call(r,n),sGe(t,{inFlight:u,prepare(){d.current?d.current=!1:d.current=u.current,u.current=!0,!d.current&&(n?(a(3),c(4)):(a(4),c(2)))},run(){d.current?n?(c(3),a(4)):(c(4),a(3)):n?c(1):a(1)},done(){var m;d.current&&lGe(t)||(u.current=!1,c(7),n||s(!1),(m=void 0)==null||m.call(r,n))}})}},[e,n,t,f]),e?[o,{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 sGe(e,{prepare:t,run:n,done:r,inFlight:o}){let s=Oa();return aGe(e,{prepare:t,inFlight:o}),s.nextFrame(()=>{n(),s.requestAnimationFrame(()=>{s.add(iGe(e,r))})}),s.dispose}function iGe(e,t){var n,r;let o=Oa();if(!e)return o.dispose;let s=!1;o.add(()=>{s=!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(),o.dispose):(Promise.allSettled(i.map(a=>a.finished)).then(()=>{s||t()}),o.dispose)}function aGe(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 lGe(e){var t,n;return((n=(t=e.getAnimations)==null?void 0:t.call(e))!=null?n:[]).some(r=>r instanceof CSSTransition&&r.playState!=="finished")}function cGe(e,{container:t,accept:n,walk:r}){let o=v.useRef(n),s=v.useRef(r);v.useEffect(()=>{o.current=n,s.current=r},[n,r]),ko(()=>{if(!t||!e)return;let i=$w(t);if(!i)return;let a=o.current,c=s.current,u=Object.assign(f=>a(f),{acceptNode:a}),d=i.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,u,!1);for(;d.nextNode();)c(d.currentNode)},[t,e,o,s])}function $q(e,t){let n=v.useRef([]),r=$n(e);v.useEffect(()=>{let o=[...n.current];for(let[s,i]of t.entries())if(n.current[s]!==i){let a=r(t,o);return n.current=t,a}},[r,...t])}function uGe(){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 wce={...te},dGe=wce.useInsertionEffect,fGe=dGe||(e=>e());function Cce(e){const t=te.useRef(()=>{if(process.env.NODE_ENV!=="production")throw new Error("Cannot call an event handler while rendering.")});return fGe(()=>{t.current=e}),te.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return t.current==null?void 0:t.current(...r)},[])}var JP=typeof document<"u"?v.useLayoutEffect:v.useEffect;let zq=!1,hGe=0;const Bq=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+hGe++;function mGe(){const[e,t]=te.useState(()=>zq?Bq():void 0);return JP(()=>{e==null&&t(Bq())},[]),te.useEffect(()=>{zq=!0},[]),e}const pGe=wce.useId,gGe=pGe||mGe;let iv;process.env.NODE_ENV!=="production"&&(iv=new Set);function bGe(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];const o="Floating UI: "+n.join(" ");if(!((e=iv)!=null&&e.has(o))){var s;(s=iv)==null||s.add(o),console.warn(o)}}function xGe(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];const o="Floating UI: "+n.join(" ");if(!((e=iv)!=null&&e.has(o))){var s;(s=iv)==null||s.add(o),console.error(o)}}function yGe(){const e=new Map;return{emit(t,n){var r;(r=e.get(t))==null||r.forEach(o=>o(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(o=>o!==n))||[])}}}const vGe=te.createContext(null),wGe=te.createContext(null),CGe=()=>{var e;return((e=te.useContext(vGe))==null?void 0:e.id)||null},SGe=()=>te.useContext(wGe),NGe="data-floating-ui-focusable";function jGe(e){const{open:t=!1,onOpenChange:n,elements:r}=e,o=gGe(),s=te.useRef({}),[i]=te.useState(()=>yGe()),a=CGe()!=null;if(process.env.NODE_ENV!=="production"){const m=r.reference;m&&!p.isElement(m)&&xGe("Cannot pass a virtual element to the `elements.reference` option,","as it must be a real DOM element. Use `refs.setPositionReference()`","instead.")}const[c,u]=te.useState(r.reference),d=Cce((m,g,x)=>{s.current.openEvent=m?g:void 0,i.emit("openchange",{open:m,event:g,reason:x,nested:a}),n==null||n(m,g,x)}),f=te.useMemo(()=>({setPositionReference:u}),[]),h=te.useMemo(()=>({reference:c||r.reference||null,floating:r.floating||null,domReference:r.reference}),[c,r.reference,r.floating]);return te.useMemo(()=>({dataRef:s,open:t,onOpenChange:d,elements:h,events:i,floatingId:o,refs:f}),[t,d,h,i,o,f])}function kGe(e){e===void 0&&(e={});const{nodeId:t}=e,n=jGe({...e,elements:{reference:null,floating:null,...e.elements}}),r=e.rootContext||n,o=r.elements,[s,i]=te.useState(null),[a,c]=te.useState(null),d=(o==null?void 0:o.domReference)||s,f=te.useRef(null),h=SGe();JP(()=>{d&&(f.current=d)},[d]);const m=p.useFloating({...e,elements:{...o,...a&&{reference:a}}}),g=te.useCallback(C=>{const N=p.isElement(C)?{getBoundingClientRect:()=>C.getBoundingClientRect(),contextElement:C}:C;c(N),m.refs.setReference(N)},[m.refs]),x=te.useCallback(C=>{(p.isElement(C)||C===null)&&(f.current=C,i(C)),(p.isElement(m.refs.reference.current)||m.refs.reference.current===null||C!==null&&!p.isElement(C))&&m.refs.setReference(C)},[m.refs]),b=te.useMemo(()=>({...m.refs,setReference:x,setPositionReference:g,domReference:f}),[m.refs,x,g]),y=te.useMemo(()=>({...m.elements,domReference:d}),[m.elements,d]),w=te.useMemo(()=>({...m,...r,refs:b,elements:y,nodeId:t}),[m,b,y,t,r]);return JP(()=>{r.dataRef.current.floatingContext=w;const C=h==null?void 0:h.nodesRef.current.find(N=>N.id===t);C&&(C.context=w)}),te.useMemo(()=>({...m,context:w,refs:b,elements:y}),[m,b,y,w])}const Vq="active",Hq="selected";function gM(e,t,n){const r=new Map,o=n==="item";let s=e;if(o&&e){const{[Vq]:i,[Hq]:a,...c}=e;s=c}return{...n==="floating"&&{tabIndex:-1,[NGe]:""},...s,...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(c=>{let[u,d]=c;if(!(o&&[Vq,Hq].includes(u)))if(u.indexOf("on")===0){if(r.has(u)||r.set(u,[]),typeof d=="function"){var f;(f=r.get(u))==null||f.push(d),i[u]=function(){for(var h,m=arguments.length,g=new Array(m),x=0;x<m;x++)g[x]=arguments[x];return(h=r.get(u))==null?void 0:h.map(b=>b(...g)).find(b=>b!==void 0)}}}else i[u]=d}),i),{})}}function IGe(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),o=te.useCallback(a=>gM(a,e,"reference"),t),s=te.useCallback(a=>gM(a,e,"floating"),n),i=te.useCallback(a=>gM(a,e,"item"),r);return te.useMemo(()=>({getReferenceProps:o,getFloatingProps:s,getItemProps:i}),[o,s,i])}function qq(e,t){return{...e,rects:{...e.rects,floating:{...e.rects.floating,height:t}}}}const _Ge=e=>({name:"inner",options:e,async fn(t){const{listRef:n,overflowRef:r,onFallbackChange:o,offset:s=0,index:i=0,minItemsVisible:a=4,referenceOverflowThreshold:c=0,scrollRef:u,...d}=p.evaluate(e,t),{rects:f,elements:{floating:h}}=t,m=n.current[i],g=(u==null?void 0:u.current)||h,x=h.clientTop||g.clientTop,b=h.clientTop!==0,y=g.clientTop!==0,w=h===g;if(process.env.NODE_ENV!=="production"&&(t.placement.startsWith("bottom")||bGe('`placement` side must be "bottom" when using the `inner`',"middleware.")),!m)return{};const C={...t,...await p.offset(-m.offsetTop-h.clientTop-f.reference.height/2-m.offsetHeight/2-s).fn(t)},N=await p.detectOverflow(qq(C,g.scrollHeight+x+h.clientTop),d),S=await p.detectOverflow(C,{...d,elementContext:"reference"}),j=p.max(0,N.top),I=C.y+j,_=(g.scrollHeight>g.clientHeight?E=>E:p.round)(p.max(0,g.scrollHeight+(b&&w||y?x*2:0)-j-p.max(0,N.bottom)));if(g.style.maxHeight=_+"px",g.scrollTop=j,o){const E=g.offsetHeight<m.offsetHeight*p.min(a,n.current.length)-1||S.top>=-c||S.bottom>=-c;Q2.flushSync(()=>o(E))}return r&&(r.current=await p.detectOverflow(qq({...C,y:I},g.offsetHeight+x+h.clientTop),d)),{y:I}}});function TGe(e,t){const{open:n,elements:r}=e,{enabled:o=!0,overflowRef:s,scrollRef:i,onChange:a}=t,c=Cce(a),u=te.useRef(!1),d=te.useRef(null),f=te.useRef(null);te.useEffect(()=>{if(!o)return;function m(x){if(x.ctrlKey||!g||s.current==null)return;const b=x.deltaY,y=s.current.top>=-.5,w=s.current.bottom>=-.5,C=g.scrollHeight-g.clientHeight,N=b<0?-1:1,S=b<0?"max":"min";g.scrollHeight<=g.clientHeight||(!y&&b>0||!w&&b<0?(x.preventDefault(),Q2.flushSync(()=>{c(j=>j+Math[S](b,C*N))})):/firefox/i.test(uGe())&&(g.scrollTop+=b))}const g=(i==null?void 0:i.current)||r.floating;if(n&&g)return g.addEventListener("wheel",m),requestAnimationFrame(()=>{d.current=g.scrollTop,s.current!=null&&(f.current={...s.current})}),()=>{d.current=null,f.current=null,g.removeEventListener("wheel",m)}},[o,n,r.floating,s,i,c]);const h=te.useMemo(()=>({onKeyDown(){u.current=!0},onWheel(){u.current=!1},onPointerMove(){u.current=!1},onScroll(){const m=(i==null?void 0:i.current)||r.floating;if(!(!s.current||!m||!u.current)){if(d.current!==null){const g=m.scrollTop-d.current;(s.current.bottom<-.5&&g<-1||s.current.top<-.5&&g>1)&&Q2.flushSync(()=>c(x=>x+g))}requestAnimationFrame(()=>{d.current=m.scrollTop})}}}),[r.floating,c,s,i]);return te.useMemo(()=>o?{floating:h}:{},[o,h])}let zw=v.createContext({styles:void 0,setReference:()=>{},setFloating:()=>{},getReferenceProps:()=>({}),getFloatingProps:()=>({}),slot:{}});zw.displayName="FloatingContext";let T$=v.createContext(null);T$.displayName="PlacementContext";function EGe(e){return v.useMemo(()=>e?typeof e=="string"?{to:e}:e:null,[e])}function DGe(){return v.useContext(zw).setReference}function MGe(){let{getFloatingProps:e,slot:t}=v.useContext(zw);return v.useCallback((...n)=>Object.assign({},e(...n),{"data-anchor":t.anchor}),[e,t])}function RGe(e=null){e===!1&&(e=null),typeof e=="string"&&(e={to:e});let t=v.useContext(T$),n=v.useMemo(()=>e,[JSON.stringify(e,(o,s)=>{var i;return(i=s==null?void 0:s.outerHTML)!=null?i:s})]);ko(()=>{t==null||t(n??null)},[t,n]);let r=v.useContext(zw);return v.useMemo(()=>[r.setFloating,e?r.styles:{}],[r.setFloating,e,r.styles])}let Uq=4;function AGe({children:e,enabled:t=!0}){let[n,r]=v.useState(null),[o,s]=v.useState(0),i=v.useRef(null),[a,c]=v.useState(null);PGe(a);let u=t&&n!==null&&a!==null,{to:d="bottom",gap:f=0,offset:h=0,padding:m=0,inner:g}=FGe(n,a),[x,b="center"]=d.split(" ");ko(()=>{u&&s(0)},[u]);let{refs:y,floatingStyles:w,context:C}=kGe({open:u,placement:x==="selection"?b==="center"?"bottom":`bottom-${b}`:b==="center"?`${x}`:`${x}-${b}`,strategy:"absolute",transform:!1,middleware:[p.offset({mainAxis:x==="selection"?0:f,crossAxis:h}),p.shift({padding:m}),x!=="selection"&&p.flip({padding:m}),x==="selection"&&g?_Ge({...g,padding:m,overflowRef:i,offset:o,minItemsVisible:Uq,referenceOverflowThreshold:m,onFallbackChange(E){var D,M;if(!E)return;let P=C.elements.floating;if(!P)return;let A=parseFloat(getComputedStyle(P).scrollPaddingBottom)||0,L=Math.min(Uq,P.childElementCount),O=0,B=0;for(let H of(M=(D=C.elements.floating)==null?void 0:D.childNodes)!=null?M:[])if(Ef(H)){let R=H.offsetTop,V=R+H.clientHeight+A,z=P.scrollTop,F=z+P.clientHeight;if(R>=z&&V<=F)L--;else{B=Math.max(0,Math.min(V,F)-Math.max(R,z)),O=H.clientHeight;break}}L>=1&&s(H=>{let R=O*L-B+A;return H>=R?H:R})}}):null,p.size({padding:m,apply({availableWidth:E,availableHeight:D,elements:M}){Object.assign(M.floating.style,{overflow:"auto",maxWidth:`${E}px`,maxHeight:`min(var(--anchor-max-height, 100vh), ${D}px)`})}})].filter(Boolean),whileElementsMounted:p.autoUpdate}),[N=x,S=b]=C.placement.split("-");x==="selection"&&(N="selection");let j=v.useMemo(()=>({anchor:[N,S].filter(Boolean).join(" ")}),[N,S]),I=TGe(C,{overflowRef:i,onChange:s}),{getReferenceProps:k,getFloatingProps:T}=IGe([I]),_=$n(E=>{c(E),y.setFloating(E)});return te.createElement(T$.Provider,{value:r},te.createElement(zw.Provider,{value:{setFloating:_,setReference:y.setReference,styles:w,getReferenceProps:k,getFloatingProps:T,slot:j}},e))}function PGe(e){ko(()=>{if(!e)return;let t=new MutationObserver(()=>{let n=window.getComputedStyle(e).maxHeight,r=parseFloat(n);if(isNaN(r))return;let o=parseInt(n);isNaN(o)||r!==o&&(e.style.maxHeight=`${Math.ceil(r)}px`)});return t.observe(e,{attributes:!0,attributeFilter:["style"]}),()=>{t.disconnect()}},[e])}function FGe(e,t){var n,r,o;let s=bM((n=e==null?void 0:e.gap)!=null?n:"var(--anchor-gap, 0)",t),i=bM((r=e==null?void 0:e.offset)!=null?r:"var(--anchor-offset, 0)",t),a=bM((o=e==null?void 0:e.padding)!=null?o:"var(--anchor-padding, 0)",t);return{...e,gap:s,offset:i,padding:a}}function bM(e,t,n=void 0){let r=Qb(),o=$n((c,u)=>{if(c==null)return[n,null];if(typeof c=="number")return[c,null];if(typeof c=="string"){if(!u)return[n,null];let d=Wq(c,u);return[d,f=>{let h=Sce(c);{let m=h.map(g=>window.getComputedStyle(u).getPropertyValue(g));r.requestAnimationFrame(function g(){r.nextFrame(g);let x=!1;for(let[y,w]of h.entries()){let C=window.getComputedStyle(u).getPropertyValue(w);if(m[y]!==C){m[y]=C,x=!0;break}}if(!x)return;let b=Wq(c,u);d!==b&&(f(b),d=b)})}return r.dispose}]}return[n,null]}),s=v.useMemo(()=>o(e,t)[0],[e,t]),[i=s,a]=v.useState();return ko(()=>{let[c,u]=o(e,t);if(a(c),!!u)return u(a)},[e,t]),i}function Sce(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(),o=t[1].slice(n+1).trim();return o?[r,...Sce(o)]:[r]}return[]}function Wq(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 OGe({children:e,freeze:t},n){let r=eF(t,e);return v.isValidElement(r)?v.cloneElement(r,{ref:n}):v.createElement(v.Fragment,null,r)}const LGe=v.forwardRef(OGe);function eF(e,t){let[n,r]=v.useState(t);return!e&&n!==t&&r(t),e?n:t}let E$=v.createContext(null);E$.displayName="OpenClosedContext";var av=(e=>(e[e.Open=1]="Open",e[e.Closed=2]="Closed",e[e.Closing=4]="Closing",e[e.Opening=8]="Opening",e))(av||{});function $Ge(){return v.useContext(E$)}function zGe({value:e,children:t}){return v.createElement(E$.Provider,{value:e},t)}function BGe(e){function t(){document.readyState!=="loading"&&(e(),document.removeEventListener("DOMContentLoaded",t))}typeof window<"u"&&typeof document<"u"&&(document.addEventListener("DOMContentLoaded",t),t())}let lh=[];BGe(()=>{function e(t){if(!vh(t.target)||t.target===document.body||lh[0]===t.target)return;let n=t.target;n=n.closest(ZP),lh.unshift(n??t.target),lh=lh.filter(r=>r!=null&&r.isConnected),lh.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 VGe(e){throw new Error("Unexpected object: "+e)}var $o=(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))($o||{});function Kq(e,t){let n=t.resolveItems();if(n.length<=0)return null;let r=t.resolveActiveIndex(),o=r??-1;switch(e.focus){case 0:{for(let s=0;s<n.length;++s)if(!t.resolveDisabled(n[s],s,n))return s;return r}case 1:{o===-1&&(o=n.length);for(let s=o-1;s>=0;--s)if(!t.resolveDisabled(n[s],s,n))return s;return r}case 2:{for(let s=o+1;s<n.length;++s)if(!t.resolveDisabled(n[s],s,n))return s;return r}case 3:{for(let s=n.length-1;s>=0;--s)if(!t.resolveDisabled(n[s],s,n))return s;return r}case 4:{for(let s=0;s<n.length;++s)if(t.resolveId(n[s],s,n)===e.id)return s;return r}case 5:return null;default:VGe(e)}}function Nce(e){let t=$n(e),n=v.useRef(!1);v.useEffect(()=>(n.current=!1,()=>{n.current=!0,Jle(()=>{n.current&&t()})}),[t])}let HGe=v.createContext(!1);function qGe(){return v.useContext(HGe)}function UGe(e){let t=qGe(),n=v.useContext(kce),[r,o]=v.useState(()=>{var s;if(!t&&n!==null)return(s=n.current)!=null?s:null;if(Qh.isServer)return null;let i=e==null?void 0:e.getElementById("headlessui-portal-root");if(i)return i;if(e===null)return null;let a=e.createElement("div");return a.setAttribute("id","headlessui-portal-root"),e.body.appendChild(a)});return v.useEffect(()=>{r!==null&&(e!=null&&e.body.contains(r)||e==null||e.body.appendChild(r))},[r,e]),v.useEffect(()=>{t||n!==null&&o(n.current)},[n,o,t]),r}let jce=v.Fragment,WGe=Cl(function(e,t){let{ownerDocument:n=null,...r}=e,o=v.useRef(null),s=Ku(aKe(h=>{o.current=h}),t),i=QP(o.current),a=n??i,c=UGe(a),u=v.useContext(ZGe),d=Qb(),f=wl();return Nce(()=>{var h;c&&c.childNodes.length<=0&&((h=c.parentElement)==null||h.removeChild(c))}),c?vr.createPortal(v.createElement("div",{"data-headlessui-portal":"",ref:h=>{d.dispose(),u&&h&&d.add(u.register(h))}},f({ourProps:{ref:s},theirProps:r,slot:{},defaultTag:jce,name:"Portal"})),c):null});function KGe(e,t){let n=Ku(t),{enabled:r=!0,ownerDocument:o,...s}=e,i=wl();return r?v.createElement(WGe,{...s,ownerDocument:o,ref:n}):i({ourProps:{ref:n},theirProps:s,slot:{},defaultTag:jce,name:"Portal"})}let GGe=v.Fragment,kce=v.createContext(null);function YGe(e,t){let{target:n,...r}=e,o={ref:Ku(t)},s=wl();return v.createElement(kce.Provider,{value:n},s({ourProps:o,theirProps:r,defaultTag:GGe,name:"Popover.Group"}))}let ZGe=v.createContext(null),XGe=Cl(KGe),QGe=Cl(YGe),JGe=Object.assign(XGe,{Group:QGe});const ky={Idle:{kind:"Idle"},Tracked:e=>({kind:"Tracked",position:e}),Moved:{kind:"Moved"}};function Ice(e){let t=e.getBoundingClientRect();return`${t.x},${t.y}`}function eYe(e,t,n){let r=Oa();if(t.kind==="Tracked"){let o=function(){s!==Ice(e)&&(r.dispose(),n())},{position:s}=t,i=new ResizeObserver(o);i.observe(e),r.add(()=>i.disconnect()),r.addEventListener(window,"scroll",o,{passive:!0}),r.addEventListener(window,"resize",o)}return()=>r.dispose()}var tYe=Object.defineProperty,nYe=(e,t,n)=>t in e?tYe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Gq=(e,t,n)=>(nYe(e,typeof t!="symbol"?t+"":t,n),n),Dn=(e=>(e[e.Open=0]="Open",e[e.Closed=1]="Closed",e))(Dn||{}),Vi=(e=>(e[e.Single=0]="Single",e[e.Multi=1]="Multi",e))(Vi||{}),rc=(e=>(e[e.Pointer=0]="Pointer",e[e.Focus=1]="Focus",e[e.Other=2]="Other",e))(rc||{}),_ce=(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.DefaultToFirstOption=6]="DefaultToFirstOption",e[e.SetActivationTrigger=7]="SetActivationTrigger",e[e.UpdateVirtualConfiguration=8]="UpdateVirtualConfiguration",e[e.SetInputElement=9]="SetInputElement",e[e.SetButtonElement=10]="SetButtonElement",e[e.SetOptionsElement=11]="SetOptionsElement",e[e.MarkInputAsMoved=12]="MarkInputAsMoved",e))(_ce||{});function xM(e,t=n=>n){let n=e.activeOptionIndex!==null?e.options[e.activeOptionIndex]:null,r=t(e.options.slice()),o=r.length>0&&r[0].dataRef.current.order!==null?r.sort((i,a)=>i.dataRef.current.order-a.dataRef.current.order):LKe(r,i=>i.dataRef.current.domRef.current),s=n?o.indexOf(n):null;return s===-1&&(s=null),{options:o,activeOptionIndex:s}}let rYe={1(e){var t;if((t=e.dataRef.current)!=null&&t.disabled||e.comboboxState===1)return e;let n=e.inputElement?ky.Tracked(Ice(e.inputElement)):e.inputPositionState;return{...e,activeOptionIndex:null,comboboxState:1,isTyping:!1,activationTrigger:2,inputPositionState:n,__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,inputPositionState:ky.Idle}}return{...e,comboboxState:0,inputPositionState:ky.Idle,__demoMode:!1}},3(e,t){return e.isTyping===t.isTyping?e:{...e,isTyping:t.isTyping}},2(e,t){var n,r,o,s;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:u,disabled:d}=e.virtual,f=t.focus===$o.Specific?t.idx:Kq(t,{resolveItems:()=>u,resolveActiveIndex:()=>{var m,g;return(g=(m=e.activeOptionIndex)!=null?m:u.findIndex(x=>!d(x)))!=null?g:null},resolveDisabled:d,resolveId(){throw new Error("Function not implemented.")}}),h=(o=t.trigger)!=null?o:2;return e.activeOptionIndex===f&&e.activationTrigger===h?e:{...e,activeOptionIndex:f,activationTrigger:h,isTyping:!1,__demoMode:!1}}let i=xM(e);if(i.activeOptionIndex===null){let u=i.options.findIndex(d=>!d.dataRef.current.disabled);u!==-1&&(i.activeOptionIndex=u)}let a=t.focus===$o.Specific?t.idx:Kq(t,{resolveItems:()=>i.options,resolveActiveIndex:()=>i.activeOptionIndex,resolveId:u=>u.id,resolveDisabled:u=>u.dataRef.current.disabled}),c=(s=t.trigger)!=null?s:2;return e.activeOptionIndex===a&&e.activationTrigger===c?e:{...e,...i,isTyping:!1,activeOptionIndex:a,activationTrigger:c,__demoMode:!1}},4:(e,t)=>{var n,r,o,s;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:[...e.options,t.payload]};let i=t.payload,a=xM(e,u=>(u.push(i),u));e.activeOptionIndex===null&&(o=(r=e.dataRef.current).isSelected)!=null&&o.call(r,t.payload.dataRef.current.value)&&(a.activeOptionIndex=a.options.indexOf(i));let c={...e,...a,activationTrigger:2};return(s=e.dataRef.current)!=null&&s.__demoMode&&e.dataRef.current.value===void 0&&(c.activeOptionIndex=0),c},5:(e,t)=>{var n;if((n=e.dataRef.current)!=null&&n.virtual)return{...e,options:e.options.filter(o=>o.id!==t.id)};let r=xM(e,o=>{let s=o.findIndex(i=>i.id===t.id);return s!==-1&&o.splice(s,1),o});return{...e,...r,activationTrigger:2}},6:(e,t)=>e.defaultToFirstOption===t.value?e:{...e,defaultToFirstOption:t.value},7:(e,t)=>e.activationTrigger===t.trigger?e:{...e,activationTrigger:t.trigger},8:(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 o=e.activeOptionIndex;if(e.activeOptionIndex!==null){let s=t.options.indexOf(e.virtual.options[e.activeOptionIndex]);s!==-1?o=s:o=null}return{...e,activeOptionIndex:o,virtual:{options:t.options,disabled:(r=t.disabled)!=null?r:()=>!1}}},9:(e,t)=>e.inputElement===t.element?e:{...e,inputElement:t.element},10:(e,t)=>e.buttonElement===t.element?e:{...e,buttonElement:t.element},11:(e,t)=>e.optionsElement===t.element?e:{...e,optionsElement:t.element},12(e){return e.inputPositionState.kind!=="Tracked"?e:{...e,inputPositionState:ky.Moved}}};class D$ extends hce{constructor(t){super(t),Gq(this,"actions",{onChange:n=>{let{onChange:r,compare:o,mode:s,value:i}=this.state.dataRef.current;return hc(s,{0:()=>r==null?void 0:r(n),1:()=>{let a=i.slice(),c=a.findIndex(u=>o(u,n));return c===-1?a.push(n):a.splice(c,1),r==null?void 0:r(a)}})},registerOption:(n,r)=>(this.send({type:4,payload:{id:n,dataRef:r}}),()=>{this.state.activeOptionIndex===this.state.dataRef.current.calculateIndex(r.current.value)&&this.send({type:6,value:!0}),this.send({type:5,id:n})}),goToOption:(n,r)=>(this.send({type:6,value:!1}),this.send({type:2,...n,trigger:r})),setIsTyping:n=>{this.send({type:3,isTyping:n})},closeCombobox:()=>{var n,r;this.send({type:1}),this.send({type:6,value:!1}),(r=(n=this.state.dataRef.current).onClose)==null||r.call(n)},openCombobox:()=>{this.send({type:0}),this.send({type:6,value:!0})},setActivationTrigger:n=>{this.send({type:7,trigger:n})},selectActiveOption:()=>{let n=this.selectors.activeOptionIndex(this.state);if(n!==null){if(this.actions.setIsTyping(!1),this.state.virtual)this.actions.onChange(this.state.virtual.options[n]);else{let{dataRef:r}=this.state.options[n];this.actions.onChange(r.current.value)}this.actions.goToOption({focus:$o.Specific,idx:n})}},setInputElement:n=>{this.send({type:9,element:n})},setButtonElement:n=>{this.send({type:10,element:n})},setOptionsElement:n=>{this.send({type:11,element:n})}}),Gq(this,"selectors",{activeDescendantId:n=>{var r,o;let s=this.selectors.activeOptionIndex(n);if(s!==null)return n.virtual?(o=n.options.find(i=>!i.dataRef.current.disabled&&n.dataRef.current.compare(i.dataRef.current.value,n.virtual.options[s])))==null?void 0:o.id:(r=n.options[s])==null?void 0:r.id},activeOptionIndex:n=>{if(n.defaultToFirstOption&&n.activeOptionIndex===null&&(n.virtual?n.virtual.options.length>0:n.options.length>0)){if(n.virtual){let{options:o,disabled:s}=n.virtual,i=o.findIndex(a=>{var c;return!((c=s==null?void 0:s(a))!=null&&c)});if(i!==-1)return i}let r=n.options.findIndex(o=>!o.dataRef.current.disabled);if(r!==-1)return r}return n.activeOptionIndex},activeOption:n=>{var r,o;let s=this.selectors.activeOptionIndex(n);return s===null?null:n.virtual?n.virtual.options[s??0]:(o=(r=n.options[s])==null?void 0:r.dataRef.current.value)!=null?o:null},isActive:(n,r,o)=>{var s;let i=this.selectors.activeOptionIndex(n);return i===null?!1:n.virtual?i===n.dataRef.current.calculateIndex(r):((s=n.options[i])==null?void 0:s.id)===o},shouldScrollIntoView:(n,r,o)=>!(n.virtual||n.__demoMode||n.comboboxState!==0||n.activationTrigger===0||!this.selectors.isActive(n,r,o)),didInputMove(n){return n.inputPositionState.kind==="Moved"}});{let n=this.state.id,r=_$.get(null);this.disposables.add(r.on(pce.Push,o=>{!r.selectors.isTop(o,n)&&this.state.comboboxState===0&&this.actions.closeCombobox()})),this.on(0,()=>r.actions.push(n)),this.on(1,()=>r.actions.pop(n))}this.disposables.group(n=>{this.on(1,r=>{r.inputElement&&(n.dispose(),n.add(eYe(r.inputElement,r.inputPositionState,()=>{this.send({type:12})})))})})}static new({id:t,virtual:n=null,__demoMode:r=!1}){var o;return new D$({id:t,dataRef:{current:{}},comboboxState:r?0:1,isTyping:!1,options:[],virtual:n?{options:n.options,disabled:(o=n.disabled)!=null?o:()=>!1}:null,activeOptionIndex:null,activationTrigger:2,inputElement:null,buttonElement:null,optionsElement:null,__demoMode:r,inputPositionState:ky.Idle})}reduce(t,n){return hc(n.type,rYe,t,n)}}const Tce=v.createContext(null);function Bw(e){let t=v.useContext(Tce);if(t===null){let n=new Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,Ece),n}return t}function Ece({id:e,virtual:t=null,__demoMode:n=!1}){let r=v.useMemo(()=>D$.new({id:e,virtual:t,__demoMode:n}),[]);return Nce(()=>r.dispose()),r}let lv=v.createContext(null);lv.displayName="ComboboxDataContext";function Jb(e){let t=v.useContext(lv);if(t===null){let n=new Error(`<${e} /> is missing a parent <Combobox /> component.`);throw Error.captureStackTrace&&Error.captureStackTrace(n,Jb),n}return t}let Dce=v.createContext(null);function oYe(e){let t=Bw("VirtualProvider"),n=Jb("VirtualProvider"),{options:r}=n.virtual,o=Uo(t,m=>m.optionsElement),[s,i]=v.useMemo(()=>{let m=o;if(!m)return[0,0];let g=window.getComputedStyle(m);return[parseFloat(g.paddingBlockStart||g.paddingTop),parseFloat(g.paddingBlockEnd||g.paddingBottom)]},[o]),a=v_({enabled:r.length!==0,scrollPaddingStart:s,scrollPaddingEnd:i,count:r.length,estimateSize(){return 40},getScrollElement(){return t.state.optionsElement},overscan:12}),[c,u]=v.useState(0);ko(()=>{u(m=>m+1)},[r]);let d=a.getVirtualItems(),f=Uo(t,m=>m.activationTrigger===rc.Pointer),h=Uo(t,t.selectors.activeOptionIndex);return d.length===0?null:v.createElement(Dce.Provider,{value:a},v.createElement("div",{style:{position:"relative",width:"100%",height:`${a.getTotalSize()}px`},ref:m=>{m&&(f||h!==null&&r.length>h&&a.scrollToIndex(h))}},d.map(m=>{var g;return v.createElement(v.Fragment,{key:m.key},v.cloneElement((g=e.children)==null?void 0:g.call(e,{...e.slot,option:r[m.index]}),{key:`${c}-${m.key}`,"data-index":m.index,"aria-setsize":r.length,"aria-posinset":m.index+1,style:{position:"absolute",top:0,left:0,transform:`translateY(${m.start}px)`,overflowAnchor:"none"}}))})))}let sYe=v.Fragment;function iYe(e,t){let n=v.useId(),r=S$(),{value:o,defaultValue:s,onChange:i,form:a,name:c,by:u,invalid:d=!1,disabled:f=r||!1,onClose:h,__demoMode:m=!1,multiple:g=!1,immediate:x=!1,virtual:b=null,nullable:y,...w}=e,C=KWe(s),[N=g?[]:void 0,S]=WWe(o,i,C),j=Ece({id:n,virtual:b,__demoMode:m}),I=v.useRef({static:!1,hold:!1}),k=xKe(u),T=$n($=>b?u===null?b.options.indexOf($):b.options.findIndex(X=>k(X,$)):j.state.options.findIndex(X=>k(X.dataRef.current.value,$))),_=v.useCallback($=>hc(M.mode,{[Vi.Multi]:()=>N.some(X=>k(X,$)),[Vi.Single]:()=>k(N,$)}),[N]),E=Uo(j,$=>$.virtual),D=$n(()=>h==null?void 0:h()),M=v.useMemo(()=>({__demoMode:m,immediate:x,optionsPropsRef:I,value:N,defaultValue:C,disabled:f,invalid:d,mode:g?Vi.Multi:Vi.Single,virtual:b?E:null,onChange:S,isSelected:_,calculateIndex:T,compare:k,onClose:D}),[m,x,I,N,C,f,d,g,b,E,S,_,T,k,D]);ko(()=>{var $;b&&j.send({type:_ce.UpdateVirtualConfiguration,options:b.options,disabled:($=b.disabled)!=null?$:null})},[b,b==null?void 0:b.options,b==null?void 0:b.disabled]),ko(()=>{j.state.dataRef.current=M},[M]);let[P,A,L,O]=Uo(j,$=>[$.comboboxState,$.buttonElement,$.inputElement,$.optionsElement]),B=_$.get(null),H=Uo(B,v.useCallback($=>B.selectors.isTop($,n),[B,n]));BKe(H,[A,L,O],()=>j.actions.closeCombobox());let R=Uo(j,j.selectors.activeOptionIndex),V=Uo(j,j.selectors.activeOption),z=ap({open:P===Dn.Open,disabled:f,invalid:d,activeIndex:R,activeOption:V,value:N}),[F,G]=fKe(),q=t===null?{}:{ref:t},Y=v.useCallback(()=>{if(C!==void 0)return S==null?void 0:S(C)},[S,C]),K=wl();return v.createElement(G,{value:F,props:{htmlFor:L==null?void 0:L.id},slot:{open:P===Dn.Open,disabled:f}},v.createElement(AGe,null,v.createElement(lv.Provider,{value:M},v.createElement(Tce.Provider,{value:j},v.createElement(zGe,{value:hc(P,{[Dn.Open]:av.Open,[Dn.Closed]:av.Closed})},c!=null&&v.createElement(JWe,{disabled:f,data:N!=null?{[c]:N}:{},form:a,onReset:Y}),K({ourProps:q,theirProps:w,slot:z,defaultTag:sYe,name:"Combobox"}))))))}let aYe="input";function lYe(e,t){var n,r;let o=Bw("Combobox.Input"),s=Jb("Combobox.Input"),i=v.useId(),a=sce(),{id:c=a||`headlessui-combobox-input-${i}`,onChange:u,displayValue:d,disabled:f=s.disabled||!1,autoFocus:h=!1,type:m="text",...g}=e,x=v.useRef(null),b=Ku(x,t,DGe(),o.actions.setInputElement),[y,w]=Uo(o,z=>[z.comboboxState,z.isTyping]),C=Qb(),N=$n(()=>{o.actions.onChange(null),o.state.optionsElement&&(o.state.optionsElement.scrollTop=0),o.actions.goToOption({focus:$o.Nothing})}),S=v.useMemo(()=>{var z;return typeof d=="function"&&s.value!==void 0?(z=d(s.value))!=null?z:"":typeof s.value=="string"?s.value:""},[s.value,d]);$q(([z,F],[G,q])=>{if(o.state.isTyping)return;let Y=x.current;Y&&((q===Dn.Open&&F===Dn.Closed||z!==G)&&(Y.value=z),requestAnimationFrame(()=>{if(o.state.isTyping||!Y||Qle(Y))return;let{selectionStart:K,selectionEnd:$}=Y;Math.abs(($??0)-(K??0))===0&&K===0&&Y.setSelectionRange(Y.value.length,Y.value.length)}))},[S,y,w]),$q(([z],[F])=>{if(z===Dn.Open&&F===Dn.Closed){if(o.state.isTyping)return;let G=x.current;if(!G)return;let q=G.value,{selectionStart:Y,selectionEnd:K,selectionDirection:$}=G;G.value="",G.value=q,$!==null?G.setSelectionRange(Y,K,$):G.setSelectionRange(Y,K)}},[y]);let j=v.useRef(!1),I=$n(()=>{j.current=!0}),k=$n(()=>{C.nextFrame(()=>{j.current=!1})}),T=$n(z=>{switch(o.actions.setIsTyping(!0),z.key){case Gs.Enter:if(o.state.comboboxState!==Dn.Open||j.current)return;if(z.preventDefault(),z.stopPropagation(),o.selectors.activeOptionIndex(o.state)===null){o.actions.closeCombobox();return}o.actions.selectActiveOption(),s.mode===Vi.Single&&o.actions.closeCombobox();break;case Gs.ArrowDown:return z.preventDefault(),z.stopPropagation(),hc(o.state.comboboxState,{[Dn.Open]:()=>o.actions.goToOption({focus:$o.Next}),[Dn.Closed]:()=>o.actions.openCombobox()});case Gs.ArrowUp:return z.preventDefault(),z.stopPropagation(),hc(o.state.comboboxState,{[Dn.Open]:()=>o.actions.goToOption({focus:$o.Previous}),[Dn.Closed]:()=>{vr.flushSync(()=>o.actions.openCombobox()),s.value||o.actions.goToOption({focus:$o.Last})}});case Gs.Home:if(o.state.comboboxState===Dn.Closed||z.shiftKey)break;return z.preventDefault(),z.stopPropagation(),o.actions.goToOption({focus:$o.First});case Gs.PageUp:return z.preventDefault(),z.stopPropagation(),o.actions.goToOption({focus:$o.First});case Gs.End:if(o.state.comboboxState===Dn.Closed||z.shiftKey)break;return z.preventDefault(),z.stopPropagation(),o.actions.goToOption({focus:$o.Last});case Gs.PageDown:return z.preventDefault(),z.stopPropagation(),o.actions.goToOption({focus:$o.Last});case Gs.Escape:return o.state.comboboxState!==Dn.Open?void 0:(z.preventDefault(),o.state.optionsElement&&!s.optionsPropsRef.current.static&&z.stopPropagation(),s.mode===Vi.Single&&s.value===null&&N(),o.actions.closeCombobox());case Gs.Tab:if(o.actions.setIsTyping(!1),o.state.comboboxState!==Dn.Open)return;s.mode===Vi.Single&&o.state.activationTrigger!==rc.Focus&&o.actions.selectActiveOption(),o.actions.closeCombobox();break}}),_=$n(z=>{u==null||u(z),s.mode===Vi.Single&&z.target.value===""&&N(),o.actions.openCombobox()}),E=$n(z=>{var F,G,q;let Y=(F=z.relatedTarget)!=null?F:lh.find(K=>K!==z.currentTarget);if(!((G=o.state.optionsElement)!=null&&G.contains(Y))&&!((q=o.state.buttonElement)!=null&&q.contains(Y))&&o.state.comboboxState===Dn.Open)return z.preventDefault(),s.mode===Vi.Single&&s.value===null&&N(),o.actions.closeCombobox()}),D=$n(z=>{var F,G,q;let Y=(F=z.relatedTarget)!=null?F:lh.find(K=>K!==z.currentTarget);(G=o.state.buttonElement)!=null&&G.contains(Y)||(q=o.state.optionsElement)!=null&&q.contains(Y)||s.disabled||s.immediate&&o.state.comboboxState!==Dn.Open&&C.microTask(()=>{vr.flushSync(()=>o.actions.openCombobox()),o.actions.setActivationTrigger(rc.Focus)})}),M=H_(),P=lKe(),{isFocused:A,focusProps:L}=Xle({autoFocus:h}),{isHovered:O,hoverProps:B}=Zle({isDisabled:f}),H=Uo(o,z=>z.optionsElement),R=ap({open:y===Dn.Open,disabled:f,invalid:s.invalid,hover:O,focus:A,autofocus:h}),V=N$({ref:b,id:c,role:"combobox",type:m,"aria-controls":H==null?void 0:H.id,"aria-expanded":y===Dn.Open,"aria-activedescendant":Uo(o,o.selectors.activeDescendantId),"aria-labelledby":M,"aria-describedby":P,"aria-autocomplete":"list",defaultValue:(r=(n=e.defaultValue)!=null?n:s.defaultValue!==void 0?d==null?void 0:d(s.defaultValue):null)!=null?r:s.defaultValue,disabled:f||void 0,autoFocus:h,onCompositionStart:I,onCompositionEnd:k,onKeyDown:T,onChange:_,onFocus:D,onBlur:E},L,B);return wl()({ourProps:V,theirProps:g,slot:R,defaultTag:aYe,name:"Combobox.Input"})}let cYe="button";function uYe(e,t){let n=Bw("Combobox.Button"),r=Jb("Combobox.Button"),[o,s]=v.useState(null),i=Ku(t,s,n.actions.setButtonElement),a=v.useId(),{id:c=`headlessui-combobox-button-${a}`,disabled:u=r.disabled||!1,autoFocus:d=!1,...f}=e,[h,m,g]=Uo(n,D=>[D.comboboxState,D.inputElement,D.optionsElement]),x=vce(m),b=h===Dn.Open;qKe(b,{trigger:o,action:v.useCallback(D=>{if(o!=null&&o.contains(D.target)||m!=null&&m.contains(D.target))return Hx.Ignore;let M=D.target.closest('[role="option"]:not([data-disabled])');return Ef(M)?Hx.Select(M):g!=null&&g.contains(D.target)?Hx.Ignore:Hx.Close},[o,m,g]),close:n.actions.closeCombobox,select:n.actions.selectActiveOption});let y=$n(D=>{switch(D.key){case Gs.Space:case Gs.Enter:D.preventDefault(),D.stopPropagation(),n.state.comboboxState===Dn.Closed&&vr.flushSync(()=>n.actions.openCombobox()),x();return;case Gs.ArrowDown:D.preventDefault(),D.stopPropagation(),n.state.comboboxState===Dn.Closed&&(vr.flushSync(()=>n.actions.openCombobox()),n.state.dataRef.current.value||n.actions.goToOption({focus:$o.First})),x();return;case Gs.ArrowUp:D.preventDefault(),D.stopPropagation(),n.state.comboboxState===Dn.Closed&&(vr.flushSync(()=>n.actions.openCombobox()),n.state.dataRef.current.value||n.actions.goToOption({focus:$o.Last})),x();return;case Gs.Escape:if(n.state.comboboxState!==Dn.Open)return;D.preventDefault(),n.state.optionsElement&&!r.optionsPropsRef.current.static&&D.stopPropagation(),vr.flushSync(()=>n.actions.closeCombobox()),x();return;default:return}}),w=yKe(()=>{n.state.comboboxState===Dn.Open?n.actions.closeCombobox():n.actions.openCombobox(),x()}),C=H_([c]),{isFocusVisible:N,focusProps:S}=Xle({autoFocus:d}),{isHovered:j,hoverProps:I}=Zle({isDisabled:u}),{pressed:k,pressProps:T}=LWe({disabled:u}),_=ap({open:h===Dn.Open,active:k||h===Dn.Open,disabled:u,invalid:r.invalid,value:r.value,hover:j,focus:N}),E=N$({ref:i,id:c,type:WKe(e,o),tabIndex:-1,"aria-haspopup":"listbox","aria-controls":g==null?void 0:g.id,"aria-expanded":h===Dn.Open,"aria-labelledby":C,disabled:u||void 0,autoFocus:d,onKeyDown:y},w,S,I,T);return wl()({ourProps:E,theirProps:f,slot:_,defaultTag:cYe,name:"Combobox.Button"})}let dYe="div",fYe=KP.RenderStrategy|KP.Static;function hYe(e,t){var n,r,o;let s=v.useId(),{id:i=`headlessui-combobox-options-${s}`,hold:a=!1,anchor:c,portal:u=!1,modal:d=!0,transition:f=!1,...h}=e,m=Bw("Combobox.Options"),g=Jb("Combobox.Options"),x=EGe(c);x&&(u=!0);let[b,y]=RGe(x),[w,C]=v.useState(null),N=MGe(),S=Ku(t,x?b:null,m.actions.setOptionsElement,C),[j,I,k,T,_]=Uo(m,U=>[U.comboboxState,U.inputElement,U.buttonElement,U.optionsElement,U.activationTrigger]),E=QP(I||k),D=QP(T),M=$Ge(),[P,A]=oGe(f,w,M!==null?(M&av.Open)===av.Open:j===Dn.Open);MKe(P,I,m.actions.closeCombobox);let L=g.__demoMode?!1:d&&j===Dn.Open;JKe(L,D);let O=g.__demoMode?!1:d&&j===Dn.Open;DKe(O,{allowed:v.useCallback(()=>[I,k,T],[I,k,T])});let B=Uo(m,m.selectors.didInputMove)?!1:P;ko(()=>{var U;g.optionsPropsRef.current.static=(U=e.static)!=null?U:!1},[g.optionsPropsRef,e.static]),ko(()=>{g.optionsPropsRef.current.hold=a},[g.optionsPropsRef,a]),cGe(j===Dn.Open,{container:T,accept(U){return U.getAttribute("role")==="option"?NodeFilter.FILTER_REJECT:U.hasAttribute("role")?NodeFilter.FILTER_SKIP:NodeFilter.FILTER_ACCEPT},walk(U){U.setAttribute("role","none")}});let H=H_([k==null?void 0:k.id]),R=ap({open:j===Dn.Open,option:void 0}),V=$n(()=>{m.actions.setActivationTrigger(rc.Pointer)}),z=$n(U=>{U.preventDefault(),m.actions.setActivationTrigger(rc.Pointer)}),F=N$(x?N():{},{"aria-labelledby":H,role:"listbox","aria-multiselectable":g.mode===Vi.Multi?!0:void 0,id:i,ref:S,style:{...h.style,...y,"--input-width":jq(P,I,!0).width,"--button-width":jq(P,k,!0).width},onWheel:_===rc.Pointer?void 0:V,onMouseDown:z,...rGe(A)}),G=P&&j===Dn.Closed&&!e.static,q=eF(G,(n=g.virtual)==null?void 0:n.options),Y=eF(G,g.value),K=v.useCallback(U=>g.compare(Y,U),[g.compare,Y]),$=v.useMemo(()=>{if(!g.virtual)return g;if(q===void 0)throw new Error("Missing `options` in virtual mode");return q!==g.virtual.options?{...g,virtual:{...g.virtual,options:q}}:g},[g,q,(r=g.virtual)==null?void 0:r.options]);g.virtual&&Object.assign(h,{children:v.createElement(lv.Provider,{value:$},v.createElement(oYe,{slot:R},h.children))});let X=wl(),W=v.useMemo(()=>g.mode===Vi.Multi?g:{...g,isSelected:K},[g,K]);return v.createElement(JGe,{enabled:u?e.static||P:!1,ownerDocument:E},v.createElement(lv.Provider,{value:W},X({ourProps:F,theirProps:{...h,children:v.createElement(LGe,{freeze:G},typeof h.children=="function"?(o=h.children)==null?void 0:o.call(h,R):h.children)},slot:R,defaultTag:dYe,features:fYe,visible:B,name:"Combobox.Options"})))}let mYe="div";function pYe(e,t){var n,r,o;let s=Jb("Combobox.Option"),i=Bw("Combobox.Option"),a=v.useId(),{id:c=`headlessui-combobox-option-${a}`,value:u,disabled:d=(o=(r=(n=s.virtual)==null?void 0:n.disabled)==null?void 0:r.call(n,u))!=null?o:!1,order:f=null,...h}=e,[m]=Uo(i,A=>[A.inputElement]),g=vce(m),x=Uo(i,v.useCallback(A=>i.selectors.isActive(A,u,c),[u,c])),b=s.isSelected(u),y=v.useRef(null),w=ip({disabled:d,value:u,domRef:y,order:f}),C=v.useContext(Dce),N=Ku(t,y,C?C.measureElement:null),S=$n(()=>{i.actions.setIsTyping(!1),i.actions.onChange(u)});ko(()=>i.actions.registerOption(c,w),[w,c]);let j=Uo(i,v.useCallback(A=>i.selectors.shouldScrollIntoView(A,u,c),[u,c]));ko(()=>{if(j)return Oa().requestAnimationFrame(()=>{var A,L;(L=(A=y.current)==null?void 0:A.scrollIntoView)==null||L.call(A,{block:"nearest"})})},[j,y]);let I=$n(A=>{A.preventDefault(),A.button===I$.Left&&(d||(S(),XP()||requestAnimationFrame(()=>g()),s.mode===Vi.Single&&i.actions.closeCombobox()))}),k=$n(()=>{if(d)return i.actions.goToOption({focus:$o.Nothing});let A=s.calculateIndex(u);i.actions.goToOption({focus:$o.Specific,idx:A})}),T=eGe(),_=$n(A=>T.update(A)),E=$n(A=>{if(!T.wasMoved(A)||d||x&&i.state.activationTrigger===rc.Pointer)return;let L=s.calculateIndex(u);i.actions.goToOption({focus:$o.Specific,idx:L},rc.Pointer)}),D=$n(A=>{T.wasMoved(A)&&(d||x&&(s.optionsPropsRef.current.hold||i.state.activationTrigger===rc.Pointer&&i.actions.goToOption({focus:$o.Nothing})))}),M=ap({active:x,focus:x,selected:b,disabled:d}),P={id:c,ref:N,role:"option",tabIndex:d===!0?void 0:-1,"aria-disabled":d===!0?!0:void 0,"aria-selected":b,disabled:void 0,onMouseDown:I,onFocus:k,onPointerEnter:_,onMouseEnter:_,onPointerMove:E,onMouseMove:E,onPointerLeave:D,onMouseLeave:D};return wl()({ourProps:P,theirProps:h,slot:M,defaultTag:mYe,name:"Combobox.Option"})}let gYe=Cl(iYe),Mce=Cl(uYe),Rce=Cl(lYe),bYe=gKe,Ace=Cl(hYe),Pce=Cl(pYe),xYe=Object.assign(gYe,{Input:Rce,Button:Mce,Label:bYe,Options:Ace,Option:Pce});const yYe="var(--semaphor-control-radius, var(--radius, 0.3125rem))",tF="max(calc(var(--semaphor-control-radius, var(--radius, 0.3125rem)) - 2px), 0px)",vYe="var(--semaphor-radius, var(--semaphor-control-radius, var(--radius, 0.3125rem)))",wYe=v.memo(({option:e})=>l.jsxs(Pce,{style:{borderRadius:tF},value:e,className:p.cn("group mx-1 my-1 flex cursor-default select-none items-center gap-3 px-3 py-2.5","text-sm text-foreground transition-colors","data-[selected]:bg-primary/8 data-[focus]:bg-muted/80 data-[selected]:text-foreground"),children:[l.jsx("span",{className:p.cn("flex size-5 shrink-0 items-center justify-center rounded-full border border-border bg-background text-transparent transition-colors","group-data-[selected]:border-primary group-data-[selected]:bg-primary group-data-[selected]:text-primary-foreground","group-data-[focus]:border-muted-foreground/60"),children:l.jsx(p.Check,{className:"size-3.5"})}),l.jsx("span",{className:"min-w-0 flex-1 truncate",children:e.label??e.value})]},e.id),(e,t)=>e.option.id===t.option.id&&e.option.value===t.option.value&&e.option.label===t.option.label),Fce=v.forwardRef(({className:e,style:t,children:n,...r},o)=>{const{scopeProps:s}=oi.useAppearance();return l.jsx("div",{className:p.cn("semaphor-scope",s.className),"data-semaphor-theme":s["data-semaphor-theme"],"data-semaphor-appearance-instance":s["data-semaphor-appearance-instance"],style:s.style,children:l.jsx("div",{ref:o,className:e,style:t,...r,children:n})})});Fce.displayName="ScopedComboboxOptionsPanel";function CYe({options:e,onChange:t,selectedOptions:n,multiple:r=!0,externalFilteredOptions:o,selectAllChecked:s,onSelectAllCheckedChange:i,inputClassName:a,renderFilterModeButton:c,showNegativeIndicator:u,isSearching:d,isLoadingOptions:f=!1,resultSource:h="local",searchError:m,query:g,onQueryChange:x,filterDataType:b,onEnterKey:y,activeFilterValue:w,filterTitle:C,onClear:N,hasActiveFilter:S,placeholder:j,closedDisplayFallback:I,searchPlaceholder:k,selectedCount:T=0}){const[_,E]=v.useState(""),D=v.useRef(null),[M,P]=v.useState(null),A=g!==void 0?g:_,L=x||E,O=o||e;v.useLayoutEffect(()=>{const $=D.current;if(!$)return;const X=()=>{const U=Math.ceil($.getBoundingClientRect().width);P(Z=>Z===U?Z:U)};if(X(),typeof ResizeObserver>"u")return;const W=new ResizeObserver(()=>{X()});return W.observe($),()=>{W.disconnect()}},[]);function B($,X){if(X)return"";const W=[">","<",">=","<=","="];if((b?p.isNumberDataType(b):!1)&&w&&W.includes(w.operation))return`${w.operation}${w.values[0]}`;if(I)return I;const Z=Array.isArray($)?$:$?[$]:[];return Z.length?Z.map(Q=>Q.label??Q.value).join(", "):""}function H($){if($===null){t([]);return}Array.isArray($)||($=[$]),t($)}const R=r?n:n[0]??null;function V(){return d||f||O&&O.length>0?null:l.jsx("div",{className:"relative cursor-default select-none px-4 py-2",children:"No records found."})}function z(){return d&&(O==null?void 0:O.length)>0?l.jsxs("div",{className:"mx-1 mb-2 flex items-center gap-2 rounded-md bg-muted/40 px-3 py-2 text-xs text-muted-foreground",children:[l.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Searching..."]}):m&&A?l.jsx("div",{className:"mx-1 mb-2 rounded-md bg-amber-500/10 px-3 py-2 text-xs text-amber-600 dark:text-amber-400",children:"Search unavailable. Showing available results."}):null}function F(){return f?l.jsxs("div",{className:"px-3 py-3",children:[l.jsxs("div",{className:"mb-3 flex items-center gap-2 px-2 text-xs text-muted-foreground",children:[l.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Loading options..."]}),l.jsx("div",{className:"space-y-1",children:Array.from({length:4}).map(($,X)=>l.jsx("div",{style:{borderRadius:tF},className:"h-11 bg-muted/70","aria-hidden":"true"},X))})]}):!d||(O==null?void 0:O.length)>0?null:l.jsxs("div",{className:"px-3 py-3",children:[l.jsxs("div",{className:"mb-3 flex items-center gap-2 px-2 text-xs text-muted-foreground",children:[l.jsx("div",{className:"h-3 w-3 animate-spin rounded-full border-2 border-current border-t-transparent"}),"Loading options..."]}),l.jsx("div",{className:"space-y-1",children:Array.from({length:4}).map(($,X)=>l.jsx("div",{style:{borderRadius:tF},className:"h-11 bg-muted/70","aria-hidden":"true"},X))})]})}function G(){return null}function q(){return!r||!(O!=null&&O.length)||f?null:l.jsxs("div",{className:"flex items-center justify-between gap-3 border-y border-border/80 px-5 py-3",children:[c==null?void 0:c(),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-sm text-muted-foreground",children:"All"}),l.jsx(An,{className:"size-5 rounded-control border-input text-primary data-[state=checked]:bg-primary",checked:s,onCheckedChange:i})]})]})}function Y(){return C?l.jsxs("div",{className:"flex items-center justify-between px-5 pb-3 pt-4",children:[l.jsx("span",{className:"text-[15px] font-semibold text-foreground",children:C}),S&&N&&l.jsx("button",{onClick:$=>{$.stopPropagation(),N()},className:"text-sm font-medium text-muted-foreground transition-colors hover:text-foreground","aria-label":"Clear filter",children:"Clear all"})]}):null}function K(){if(!r||f)return null;const $=Math.max(T,n.length);return l.jsx("div",{className:"border-t border-border/80 bg-muted/35 px-5 py-3 text-sm text-muted-foreground",children:`${$} selected`})}return l.jsx(xYe,{immediate:!0,multiple:r,value:R,onChange:H,onClose:()=>{L("")},by:($,X)=>Array.isArray($)||Array.isArray(X)?!1:!$||!X?$===X:$.id===X.id,children:({open:$})=>l.jsxs("div",{children:[l.jsxs("div",{ref:D,className:"relative flex items-center gap-0.5",children:[l.jsx(Mt.Search,{className:"pointer-events-none absolute left-3 size-4 text-muted-foreground"}),l.jsx(Rce,{className:p.cn("h-10 w-full cursor-default border border-input bg-background py-2 pl-10 pr-10 text-sm text-foreground shadow-sm transition-colors","hover:border-input/80 focus:border-ring",u&&"border-destructive/35 bg-destructive/[0.03] hover:border-destructive/45 focus:border-destructive/45","data-[focus]:outline-border-none focus:outline-none data-[focus]:outline-none data-[focus]:-outline-offset-2",a),style:{borderRadius:yYe},placeholder:$?k||"Search options...":j,displayValue:X=>B(X,$),onChange:X=>L(X.target.value),onKeyDown:X=>{if(X.key==="Enter"&&y){const W=/^(>=|<=|>|<|=)/.test(A.trim()),U=b?p.isNumberDataType(b):!1;W&&U&&(X.preventDefault(),y()&&X.target.blur())}}}),l.jsx(Mce,{className:"group absolute inset-y-0 right-0 px-2.5",children:l.jsx(Ie.ChevronDown,{className:"size-4 text-muted-foreground transition-colors group-hover:text-foreground"})})]}),l.jsxs(Ace,{as:Fce,anchor:"bottom",transition:!0,style:{borderRadius:vYe,width:M?`${M}px`:"16rem"},className:p.clsx$1("mt-2 overflow-hidden border border-border/80 bg-popover text-sm text-popover-foreground shadow-[0_20px_50px_-24px_rgba(15,23,42,0.35)] [--anchor-gap:var(--spacing-2)] empty:invisible dark:shadow-[0_20px_50px_-24px_rgba(0,0,0,0.6)]","transition duration-100 ease-in data-[leave]:data-[closed]:opacity-0"),children:[Y(),q(),l.jsxs("div",{className:"max-h-72 overflow-y-auto px-2 py-2",children:[z(),F(),G(),V(),!f&&(O==null?void 0:O.map(X=>l.jsx(wYe,{option:X},X.id)))]}),K()]})]})})}const Yq=[{value:"=",label:"Equal to",symbol:"="},{value:">",label:"Greater than",symbol:">"},{value:">=",label:"Greater than or equal",symbol:"≥"},{value:"<",label:"Less than",symbol:"<"},{value:"<=",label:"Less than or equal",symbol:"≤"},{value:"between",label:"Between",symbol:"⟷"},{value:"not between",label:"Not Between",symbol:"⇎"}],SYe=new Set(["=",">","<",">=","<=","between","not between"]);function NYe(e){return SYe.has(e)?e:">="}function jYe({filter:e,storageOptions:t}){var G;const{cardId:n,dashboardInput:r,inlineFilterValues:o,removeInlineFilterValue:s,sheetId:i,setInlineFilterValue:a,storageTarget:c}=t??{},u=c==="card",d=c==="dashboardInput",[f,h]=v.useState(">="),[m,g]=v.useState(""),[x,b]=v.useState(""),[y,w]=v.useState(""),[C,N]=v.useState(!0),S=v.useRef(null),j=v.useRef(!1),[,I]=v.useTransition(),k=l0(m,300),T=l0(x,300),_=l0(y,300),E=p.useDashboardStore(q=>q.filterValues),D=p.useDashboardStore(q=>q.dashboard),M=p.useDashboardStore(q=>q.dashboardInputValues);p.useDashboardStore(q=>q.themeStyle);const P=p.useDashboardStore(q=>q.actions.setDashboardInputSlot),A=p.useDashboardStore(q=>q.actions.clearDashboardInputSlot),L=p.useDashboardStore(q=>q.actions.setCardInlineFilterValue),O=p.useDashboardStore(q=>q.actions.removeCardInlineFilterValue),{addOrUpdateFilterValue:B,removeFilterValues:H}=p.useDashboardActions(),R=v.useMemo(()=>{if(!d||!r)return;const q=p.hydrateAuthoredDashboardInputSlot({dashboard:D,input:r,runtimeValues:M,target:{sheetId:i}});return(q==null?void 0:q.status)==="set"&&q.value.kind==="filter"?q.value.filterValue:void 0},[D,M,d,r,i]),V=v.useMemo(()=>d?R?[R]:[]:u?o:E,[E,R,o,u,d]),z=v.useCallback(q=>{if(d){if(!r)return;const Y=p.createFilterDashboardInputSlot(q);if(!Y)return;P(r,{sheetId:i},Y);return}if(u){if(a){a(q);return}L(n??"",q)}else B(q)},[d,r,i,P,u,a,L,n,B]),F=v.useCallback(()=>{if(d){if(!r)return;A(r,{sheetId:i});return}if(u){if(s){s(e.id);return}O(n??"",e.id)}else H(e.id)},[d,r,i,A,u,e.id,s,O,n,H]);return v.useEffect(()=>()=>{S.current=null,j.current=!1},[]),v.useEffect(()=>{const q=V==null?void 0:V.find(Y=>Y.filterId===e.id);if(q&&q.operation!=="in"){const Y=NYe(q.operation);if(S.current!==Y&&(h(Y),S.current=Y,j.current=!1),Y==="between"||Y==="not between"){const $=q.values[0],X=q.values[1];b($!=null?String($):""),w(X!=null?String(X):""),g("")}else{const $=q.values[0];g($!=null?String($):""),b(""),w("")}}else S.current!==null&&(g(""),b(""),w(""),!j.current&&S.current!==f&&(h(">="),j.current=!1),S.current=null),N(!1)},[V,e.id,f]),v.useEffect(()=>{C&&(f==="between"||f==="not between"?T===x&&_===y&&N(!1):k===m&&N(!1))},[C,f,m,k,x,y,T,_]),v.useEffect(()=>{if(!C)if(f==="between"||f==="not between"){const q=T&&T.trim()!=="",Y=_&&_.trim()!=="";if(!q||!Y){!q&&!Y&&(I(()=>{F()}),S.current=f);return}const K=Number(T),$=Number(_);if(isNaN(K)||isNaN($))return;const X={filterId:e.id,name:e.column,valueType:p.getFilterValueType(e),operation:f,values:[K,$],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};I(()=>{z(X)}),S.current=f}else{if(!k||k.trim()===""){I(()=>{F()}),S.current=null;return}const q=Number(k);if(isNaN(q))return;const Y={filterId:e.id,name:e.column,valueType:p.getFilterValueType(e),operation:f,values:[q],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};I(()=>{z(Y)}),S.current=f}},[f,k,T,_,e.id,e.column,e.database,C,z,F,e]),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsxs(p.Select,{value:f,onValueChange:q=>{j.current=!0,h(q)},children:[l.jsx(p.SelectTrigger,{className:"h-7 w-14 shrink-0 border-input bg-background text-[12px]",children:l.jsx("span",{className:"font-mono text-[13px]",children:(G=Yq.find(q=>q.value===f))==null?void 0:G.symbol})}),l.jsx(p.SelectContent,{children:Yq.map(q=>l.jsx(p.SelectItem,{value:q.value,children:l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"font-mono text-[12px]",children:q.symbol}),l.jsx("span",{className:"text-[12px]",children:q.label})]})},q.value))})]}),f==="between"||f==="not between"?l.jsxs(l.Fragment,{children:[l.jsx(p.Input,{type:"number",placeholder:"Min",value:x,onChange:q=>b(q.target.value),className:"h-7 flex-1 border-input bg-background text-[12px] tabular-nums"}),l.jsx("span",{className:"text-[11px] text-muted-foreground",children:"–"}),l.jsx(p.Input,{type:"number",placeholder:"Max",value:y,onChange:q=>w(q.target.value),className:"h-7 flex-1 border-input bg-background text-[12px] tabular-nums"})]}):l.jsx(p.Input,{type:"number",placeholder:"Value",value:m,onChange:q=>g(q.target.value),className:"h-7 flex-1 border-input bg-background text-[12px] tabular-nums"})]})}function M$({isCardStorage:e=!1,message:t="Error",className:n}){return l.jsx("div",{className:p.cn("flex w-full items-center bg-muted px-2 text-sm",e?"h-8":"h-9",n),children:t})}function Oce({filter:e,storageOptions:t}){var B,H;const n=e.searchMode==="numeric",r=(t==null?void 0:t.storageTarget)==="card",o=r?"h-8":"h-9",s=r?"h-[31px]":"h-[35px]",{removeFilterValues:i}=p.useDashboardActions(),a=p.useDashboardStore(R=>R.actions.removeCardInlineFilterValue),{filteredRecords:c,isSingleSelect:u,allSelected:d,handleChange:f,handleSelectAll:h,handleApplyOperatorExpression:m,query:g,setQuery:x,isLoading:b,isFetching:y,isPlaceholderData:w,isError:C,selectedRecords:N,isSearching:S,searchError:j,resultSource:I,activeFilterValue:k}=Xb(e,{enableServerSearch:!0,searchDebounceMs:300,minSearchLength:2,searchThreshold:5,...t}),_=b||y&&w,E=k&&(k.operation==="in"||k.operation==="not in")&&((B=k.values)!=null&&B.length)?k.values.map(R=>String(R)).join(", "):void 0,D=(k==null?void 0:k.operation)==="not in"||e.operation==="not in",P=`Search ${(e.title||e.column||"options").toLowerCase()}`,{clearDashboardInputSlot:A}=p.useDashboardActions(),L=v.useCallback(()=>{if((t==null?void 0:t.storageTarget)==="dashboardInput"&&t.dashboardInput){A(t.dashboardInput,{sheetId:t.sheetId});return}if((t==null?void 0:t.storageTarget)==="card"&&(t!=null&&t.cardId)){if(t.removeInlineFilterValue){t.removeInlineFilterValue(e.id);return}a(t.cardId,e.id)}else i(e.id)},[t,e.id,A,i,a]);return b&&!E?l.jsx(ei,{className:p.cn(s,"w-full rounded-control bg-foreground/10")}):C?l.jsx(M$,{isCardStorage:r}):n?l.jsx(jYe,{filter:e,storageOptions:t}):l.jsx(CYe,{showNegativeIndicator:D,renderFilterModeButton:()=>l.jsx(Lce,{filter:e,storageOptions:t}),inputClassName:o,options:c,selectedOptions:N,onChange:f,multiple:!u,selectAllChecked:d,onSelectAllCheckedChange:h,isSearching:S,isLoadingOptions:_,resultSource:I,searchError:j,query:g,onQueryChange:x,filterDataType:e.dataType,activeFilterValue:k,onEnterKey:m,filterTitle:e.title||e.column,onClear:L,hasActiveFilter:!!k,placeholder:e.showLabel===!1?e.title||e.column:void 0,closedDisplayFallback:N.length===0?E:void 0,searchPlaceholder:P,selectedCount:((H=k==null?void 0:k.values)==null?void 0:H.length)??N.length})}function Lce({filter:e,storageOptions:t,compact:n=!1}){const r={borderRadius:"max(calc(var(--semaphor-control-radius, var(--radius, 0.3125rem)) - 2px), 0px)"},o=(t==null?void 0:t.storageTarget)==="card",s=(t==null?void 0:t.storageTarget)==="dashboardInput",{setFilterMode:i}=p.useDashboardActions(),a=p.useDashboardStore(j=>j.dashboard),c=p.useDashboardStore(j=>j.dashboardInputValues),u=p.useDashboardStore(j=>j.isVisualEditing),d=p.useDashboardStore(j=>j.actions.setDashboardInputSlot),f=p.useDashboardStore(j=>j.actions.updateFilterDashboardInputDefinition),h=p.useDashboardStore(j=>j.actions.setCardInlineFilterMode),m=p.useDashboardStore(j=>j.actions.setCardInlineFilterValue),g=p.useEditorStore(j=>j.card),{setCard:x}=p.useEditorActions(),b=v.useMemo(()=>{if(!s||!(t!=null&&t.dashboardInput))return;const j=p.hydrateAuthoredDashboardInputSlot({dashboard:a,input:t.dashboardInput,runtimeValues:c,target:{sheetId:t.sheetId}});return(j==null?void 0:j.status)==="set"&&j.value.kind==="filter"?j.value.filterValue:void 0},[a,c,s,t==null?void 0:t.dashboardInput,t==null?void 0:t.sheetId]),w=(b&&(b.operation==="in"||b.operation==="not in")?b.operation:e.operation)==="not in"?"exclude":"include";function C(j){var k;if(j===w)return;const I=j==="exclude"?"not in":"in";if(s){if(!(t!=null&&t.dashboardInput)||t.dashboardInput.kind!=="filter"||!t.dashboardInput.filter)return;const T=t.dashboardInput;if(f(T.id,{...T.filter,operation:I}),(k=b==null?void 0:b.values)!=null&&k.length){const _={...b,operation:I},E=p.createFilterDashboardInputSlot(_);E&&d(T,{sheetId:t.sheetId},E)}return}if(o){if(t!=null&&t.setInlineFilterMode){t.setInlineFilterMode(e.id,j);return}if(u){const T=(g.inlineFilters||[]).map(E=>E.id===e.id?{...E,operation:I}:E);x({...g,inlineFilters:T});const _=N==null?void 0:N.find(E=>E.filterId===e.id);if(_&&(_.operation==="in"||_.operation==="not in")){const E={..._,operation:I};t!=null&&t.setInlineFilterValue?t.setInlineFilterValue(E):m((t==null?void 0:t.cardId)??"",E)}}else h((t==null?void 0:t.sheetId)??"",(t==null?void 0:t.cardId)??"",e.id,j)}else i(e.id,j)}const N=t==null?void 0:t.inlineFilterValues,S=n?"h-5 px-2 text-[11px]":"h-6 px-3 text-[12px]";return l.jsxs("div",{className:"inline-flex items-center gap-0.5 rounded-control bg-muted/80 p-0.5",children:[l.jsx(p.Button,{onClick:()=>C("include"),variant:"ghost",size:"sm",style:r,className:p.cn(S,"font-medium leading-none text-muted-foreground",w==="include"&&"bg-primary text-primary-foreground shadow-sm hover:bg-primary/90 hover:text-primary-foreground",w!=="include"&&"hover:bg-background/80 hover:text-foreground"),children:"Include"}),l.jsx(p.Button,{onClick:()=>C("exclude"),variant:"ghost",size:"sm",style:r,className:p.cn(S,"font-medium leading-none text-muted-foreground",w==="exclude"&&"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90 hover:text-destructive-foreground",w!=="exclude"&&"hover:bg-background/80 hover:text-foreground"),children:"Exclude"})]})}function $ce({filter:e,storageOptions:t}){var a;const{filteredRecords:n,handleChange:r,selectedRecords:o}=Xb(e,t),s=((a=o==null?void 0:o[0])==null?void 0:a.value)||"";function i(c){r([{value:c,id:c}])}return l.jsx(wu,{onValueChange:i,value:s,className:"flex flex-col gap-0.5",children:n==null?void 0:n.map(c=>{const u=`radio-${e.id}-${c.value}`,d=s===c.value;return l.jsxs(p.Label,{htmlFor:u,className:p.cn("flex w-full cursor-pointer items-center gap-2 rounded-control px-2 py-1.5 text-[13px] transition-colors",d?"bg-muted text-foreground hover:bg-foreground/[0.08]":"text-foreground hover:bg-muted"),children:[l.jsx(Qs,{value:c.value,id:u,className:"h-3.5 w-3.5"}),l.jsx("span",{className:"truncate",children:c.label??c.value})]},c.value)})})}function zce({filter:e,storageOptions:t}){var h;const n=(t==null?void 0:t.storageTarget)==="card",{filteredRecords:r,handleChange:o,selectedRecords:s,isLoading:i,isFetching:a,isError:c}=Xb(e,t),u=((h=s==null?void 0:s[0])==null?void 0:h.value)||"",d=r&&r.length>10;function f(m){o([{value:m,id:m}])}return i||a?l.jsx("div",{className:"space-y-1",children:Array.from({length:4}).map((m,g)=>l.jsx(ei,{className:"h-7 w-full rounded-control bg-foreground/[0.06]"},g))}):c?l.jsx(M$,{isCardStorage:n,message:"Error loading filter options"}):l.jsxs("div",{className:"flex flex-col gap-0.5",children:[d&&l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsxs("div",{className:"mb-1 inline-flex items-center gap-1 rounded-[4px] bg-amber-500/10 px-1.5 py-0.5 text-[11px] text-amber-700 dark:text-amber-300",children:[l.jsx(p.Info,{className:"h-3 w-3"}),l.jsxs("span",{children:["Many options (",r.length,")"]})]})}),l.jsx(p.TooltipContent,{side:"bottom",className:"max-w-xs",children:l.jsxs("p",{className:"text-xs",children:["This filter has ",r.length," options. Consider switching to a dropdown for better usability with many options."]})})]})}),l.jsx("div",{role:"radiogroup",className:"flex flex-col gap-0.5",children:r==null?void 0:r.map(m=>{const g=u===m.value;return l.jsx("button",{type:"button",role:"radio","aria-checked":g,onClick:()=>f(m.value),className:p.cn("flex w-full items-center rounded-control px-2 py-1.5 text-left text-[13px] transition-colors",g?"bg-muted text-foreground hover:bg-foreground/[0.08]":"text-foreground hover:bg-muted"),children:l.jsx("span",{className:"truncate",children:m.label??m.value})},m.value)})})]})}const kYe=v.createContext(null),yM={didCatch:!1,error:null};class _i extends v.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=yM}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(){const{error:t}=this.state;if(t!==null){for(var n,r,o=arguments.length,s=new Array(o),i=0;i<o;i++)s[i]=arguments[i];(n=(r=this.props).onReset)===null||n===void 0||n.call(r,{args:s,reason:"imperative-api"}),this.setState(yM)}}componentDidCatch(t,n){var r,o;(r=(o=this.props).onError)===null||r===void 0||r.call(o,t,n)}componentDidUpdate(t,n){const{didCatch:r}=this.state,{resetKeys:o}=this.props;if(r&&n.error!==null&&IYe(t.resetKeys,o)){var s,i;(s=(i=this.props).onReset)===null||s===void 0||s.call(i,{next:o,prev:t.resetKeys,reason:"keys"}),this.setState(yM)}}render(){const{children:t,fallbackRender:n,FallbackComponent:r,fallback:o}=this.props,{didCatch:s,error:i}=this.state;let a=t;if(s){const c={error:i,resetErrorBoundary:this.resetErrorBoundary};if(typeof n=="function")a=n(c);else if(r)a=v.createElement(r,c);else if(o!==void 0)a=o;else throw i}return v.createElement(kYe.Provider,{value:{didCatch:s,error:i,resetErrorBoundary:this.resetErrorBoundary}},a)}}function IYe(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[];return e.length!==t.length||e.some((n,r)=>!Object.is(n,t[r]))}function _Ye(e,t){const[n,r]=v.useState(t),[o,s]=v.useState(),i=v.useMemo(()=>t,[t]);return v.useEffect(()=>{if(e&&(e==null?void 0:e.length)>0){const a=e[0];if(!a.min||!a.max)return;const c={from:new Date(a.min),to:new Date(a.max)};s(c),i||r(c)}},[e,i]),v.useEffect(()=>{i&&r(i)},[i]),{dateRange:n,setDateRange:r,initialDateRange:o,setInitialDateRange:s}}function TYe(e){const t=p.useDashboardStore(o=>{var s,i;return(i=(s=o.dashboard)==null?void 0:s.filters)==null?void 0:i.find(a=>a.id===e)}),{setDateRange:n,...r}=R$(t||{});return r}function R$(e,t){const{cardId:n,dashboardInput:r,filterQueryContext:o,inlineFilterValues:s,removeInlineFilterValue:i,setInlineFilterValue:a,sheetId:c,storageTarget:u}=t??{},d=u==="card",f=u==="dashboardInput",h=p.useDashboardStore($=>{var X;return((X=$.reportContext)==null?void 0:X.calendar)??null}),m=h==null?void 0:h.tz,g=p.useDashboardStore($=>$.filterValues),x=p.useDashboardStore($=>$.dashboard),b=p.useDashboardStore($=>$.dashboardInputValues),y=v.useMemo(()=>{if(!f||!r)return;const $={sheetId:c};return p.hydrateAuthoredDashboardInputSlot({dashboard:x,input:r,runtimeValues:b,target:$,timezone:m})},[x,b,f,r,c,m]),w=v.useMemo(()=>{if(!(!f||!r))return Ti({dashboard:x,sheetId:c,sheetKind:"dashboard",runtimeValues:{dashboardInputValues:b},timezone:m}).activeFilters},[x,b,f,r,c,m]),C=p.useDashboardStore($=>$.actions.addOrUpdateFilterValue),N=p.useDashboardStore($=>$.actions.setDashboardInputSlot),S=p.useDashboardStore($=>$.actions.clearDashboardInputSlot),j=p.useDashboardStore($=>$.actions.setCardInlineFilterValue),I=p.useDashboardStore($=>$.actions.removeCardInlineFilterValue),{removeFilterValues:k}=p.useDashboardActions(),T=(y==null?void 0:y.status)==="set"&&y.value.kind==="filter"?y.value.filterValue:void 0,_=v.useMemo(()=>f?T?[T]:[]:d?s:g,[T,g,s,d,f]),E=_==null?void 0:_.find($=>$.filterId===e.id),D=v.useMemo(()=>f?{...o,activeFilterValues:w}:o,[w,o,f]),{data:M,isLoading:P,isFetching:A,isError:L}=x$(e,{additionalFilterValues:d?s:void 0,filterQueryContext:D}),O=v.useCallback($=>{if(f){if(!r)return;const X=p.createFilterDashboardInputSlot($);if(!X)return;N(r,{sheetId:c},X);return}if(d){if(a){a($);return}if(!n)return;j(n,$)}else C($)},[f,r,c,N,d,a,j,n,C]),B=v.useCallback(()=>{if(f){if(!r)return;S(r,{sheetId:c});return}if(d){if(i){i(e.id);return}if(!n)return;I(n,e.id)}else k(e.id)},[f,r,c,S,d,e.id,i,I,n,k]),H=v.useMemo(()=>{const $=W=>{if(!W)return;const U=W instanceof Date?W:new Date(W);return isNaN(U.getTime())?void 0:U};if(!E||!Array.isArray(E.values))return;const X=E.operation;if((X==="between"||X==="not between")&&E.values.length===2){const[W,U]=E.values,Z=$(W),Q=$(U);return!Z&&!Q?void 0:{from:Z,to:Q}}if(["=","!=",">",">=","<","<="].includes(X)&&E.values.length===1){const[W]=E.values,U=$(W);return U?{from:U,to:U}:void 0}},[E]),{dateRange:R,setDateRange:V,initialDateRange:z}=_Ye((M==null?void 0:M.records)??[],H);function F(){B(),V(void 0)}function G(){V(z)}function q($,X="between",W={}){if(!$)return;if(X==="is null"||X==="is not null"){V(void 0),O({filterId:e.id,valueType:p.getFilterValueType(e),name:e.column,operation:X,values:[],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext});return}if(X==="between"||X==="not between"){const Z=p.normalizeDateFilterRange($,{temporalPrecision:W.temporalPrecision});V({from:Z.from,to:Z.to}),O({filterId:e.id,valueType:p.getFilterValueType(e),name:e.column,operation:X,values:Z.values,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext,...W.temporalPrecision?{temporalPrecision:W.temporalPrecision}:{}});return}const U=$.from||$.to;U&&(V({from:U,to:U}),O({filterId:e.id,valueType:p.getFilterValueType(e),name:e.column,operation:X,values:[U],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext,...W.temporalPrecision?{temporalPrecision:W.temporalPrecision}:{}}))}function Y($){V(void 0),O({filterId:e.id,valueType:p.getFilterValueType(e),name:e.column,operation:$,values:[],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext})}function K($,X,W={}){if(!$)return;const U=W.temporalPrecision??p.getTemporalPrecisionForRelativeMeta(X),Z=p.normalizeDateFilterRange($,{temporalPrecision:U});V({from:Z.from,to:Z.to});const Q={filterId:e.id,valueType:p.getFilterValueType(e),name:e.column,operation:"between",values:Z.values,relativeMeta:X,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext,...U?{temporalPrecision:U}:{}};O(Q)}return{records:M==null?void 0:M.records,isLoading:P,isFetching:A,isError:L,initialDateRange:z,dateRange:R,setDateRange:V,activeFilterValue:E,handleClear:F,handleChange:q,handleNullOperation:Y,handleRelativeChange:K,handleReset:G}}function Vw(e){var n;const t=e.scheme.tokens;return{colors:[...e.chartPalette],mode:e.mode,appearance:{version:Am.APPEARANCE_SPEC_VERSION,mode:e.mode,colors:Ys(e.colorValues),typography:Ys(t==null?void 0:t.typography),radius:Ys(t==null?void 0:t.radius),spacing:Ys(t==null?void 0:t.spacing),shadow:Ys(t==null?void 0:t.shadow),density:(n=t==null?void 0:t.typography)==null?void 0:n.density,chartPalette:[...e.chartPalette],table:Ys(e.table)}}}function EYe(e,t,n="long"){return new Intl.DateTimeFormat("en-US",{hour:"numeric",timeZone:e,timeZoneName:n}).format(t).split(/\s/g).slice(2).join(" ")}const vM={},Iy={};function Ch(e,t){try{const r=(vM[e]||(vM[e]=new Intl.DateTimeFormat("en-US",{timeZone:e,timeZoneName:"longOffset"}).format))(t).split("GMT")[1];return r in Iy?Iy[r]:Zq(r,r.split(":"))}catch{if(e in Iy)return Iy[e];const n=e==null?void 0:e.match(DYe);return n?Zq(e,n.slice(1)):NaN}}const DYe=/([+-]\d\d):?(\d\d)?/;function Zq(e,t){const n=+(t[0]||0),r=+(t[1]||0),o=+(t[2]||0)/60;return Iy[e]=n*60+r>0?n*60+r+o:n*60-r-o}class Gl extends Date{constructor(...t){super(),t.length>1&&typeof t[t.length-1]=="string"&&(this.timeZone=t.pop()),this.internal=new Date,isNaN(Ch(this.timeZone,this))?this.setTime(NaN):t.length?typeof t[0]=="number"&&(t.length===1||t.length===2&&typeof t[1]!="number")?this.setTime(t[0]):typeof t[0]=="string"?this.setTime(+new Date(t[0])):t[0]instanceof Date?this.setTime(+t[0]):(this.setTime(+new Date(...t)),Bce(this),nF(this)):this.setTime(Date.now())}static tz(t,...n){return n.length?new Gl(...n,t):new Gl(Date.now(),t)}withTimeZone(t){return new Gl(+this,t)}getTimezoneOffset(){const t=-Ch(this.timeZone,this);return t>0?Math.floor(t):Math.ceil(t)}setTime(t){return Date.prototype.setTime.apply(this,arguments),nF(this),+this}[Symbol.for("constructDateFrom")](t){return new Gl(+new Date(t),this.timeZone)}}const Xq=/^(get|set)(?!UTC)/;Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!Xq.test(e))return;const t=e.replace(Xq,"$1UTC");Gl.prototype[t]&&(e.startsWith("get")?Gl.prototype[e]=function(){return this.internal[t]()}:(Gl.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),MYe(this),+this},Gl.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),nF(this),+this}))});function nF(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-Ch(e.timeZone,e)*60))}function MYe(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),Bce(e)}function Bce(e){const t=Ch(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),r=new Date(+e);r.setUTCHours(r.getUTCHours()-1);const o=-new Date(+e).getTimezoneOffset(),s=-new Date(+r).getTimezoneOffset(),i=o-s,a=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();i&&a&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+i);const c=o-n;c&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+c);const u=new Date(+e);u.setUTCSeconds(0);const d=o>0?u.getSeconds():(u.getSeconds()-60)%60,f=Math.round(-(Ch(e.timeZone,e)*60))%60;(f||d)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+f),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+f+d));const h=Ch(e.timeZone,e),m=h>0?Math.floor(h):Math.ceil(h),x=-new Date(+e).getTimezoneOffset()-m,b=m!==n,y=x-c;if(b&&y){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+y);const w=Ch(e.timeZone,e),C=w>0?Math.floor(w):Math.ceil(w),N=m-C;N&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+N),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+N))}}class ru extends Gl{static tz(t,...n){return n.length?new ru(...n,t):new ru(Date.now(),t)}toISOString(){const[t,n,r]=this.tzComponents(),o=`${t}${n}:${r}`;return this.internal.toISOString().slice(0,-1)+o}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){const[t,n,r,o]=this.internal.toUTCString().split(" ");return`${t==null?void 0:t.slice(0,-1)} ${r} ${n} ${o}`}toTimeString(){const t=this.internal.toUTCString().split(" ")[4],[n,r,o]=this.tzComponents();return`${t} GMT${n}${r}${o} (${EYe(this.timeZone,this)})`}toLocaleString(t,n){return Date.prototype.toLocaleString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}toLocaleDateString(t,n){return Date.prototype.toLocaleDateString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}toLocaleTimeString(t,n){return Date.prototype.toLocaleTimeString.call(this,t,{...n,timeZone:(n==null?void 0:n.timeZone)||this.timeZone})}tzComponents(){const t=this.getTimezoneOffset(),n=t>0?"-":"+",r=String(Math.floor(Math.abs(t)/60)).padStart(2,"0"),o=String(Math.abs(t)%60).padStart(2,"0");return[n,r,o]}withTimeZone(t){return new ru(+this,t)}[Symbol.for("constructDateFrom")](t){return new ru(+new Date(t),this.timeZone)}}const Vce=6048e5,RYe=864e5,Qq=Symbol.for("constructDateFrom");function Io(e,t){return typeof e=="function"?e(t):e&&typeof e=="object"&&Qq in e?e[Qq](t):e instanceof Date?new e.constructor(t):new Date(t)}function gr(e,t){return Io(t||e,e)}function Hce(e,t,n){const r=gr(e,n==null?void 0:n.in);return isNaN(t)?Io(e,NaN):(t&&r.setDate(r.getDate()+t),r)}function qce(e,t,n){const r=gr(e,n==null?void 0:n.in);if(isNaN(t))return Io(e,NaN);if(!t)return r;const o=r.getDate(),s=Io(e,r.getTime());s.setMonth(r.getMonth()+t+1,0);const i=s.getDate();return o>=i?s:(r.setFullYear(s.getFullYear(),s.getMonth(),o),r)}let AYe={};function Hw(){return AYe}function cb(e,t){var a,c,u,d;const n=Hw(),r=(t==null?void 0:t.weekStartsOn)??((c=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:c.weekStartsOn)??n.weekStartsOn??((d=(u=n.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??0,o=gr(e,t==null?void 0:t.in),s=o.getDay(),i=(s<r?7:0)+s-r;return o.setDate(o.getDate()-i),o.setHours(0,0,0,0),o}function cv(e,t){return cb(e,{...t,weekStartsOn:1})}function Uce(e,t){const n=gr(e,t==null?void 0:t.in),r=n.getFullYear(),o=Io(n,0);o.setFullYear(r+1,0,4),o.setHours(0,0,0,0);const s=cv(o),i=Io(n,0);i.setFullYear(r,0,4),i.setHours(0,0,0,0);const a=cv(i);return n.getTime()>=s.getTime()?r+1:n.getTime()>=a.getTime()?r:r-1}function Jq(e){const t=gr(e),n=new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate(),t.getHours(),t.getMinutes(),t.getSeconds(),t.getMilliseconds()));return n.setUTCFullYear(t.getFullYear()),+e-+n}function ex(e,...t){const n=Io.bind(null,t.find(r=>typeof r=="object"));return t.map(n)}function uv(e,t){const n=gr(e,t==null?void 0:t.in);return n.setHours(0,0,0,0),n}function Wce(e,t,n){const[r,o]=ex(n==null?void 0:n.in,e,t),s=uv(r),i=uv(o),a=+s-Jq(s),c=+i-Jq(i);return Math.round((a-c)/RYe)}function PYe(e,t){const n=Uce(e,t),r=Io(e,0);return r.setFullYear(n,0,4),r.setHours(0,0,0,0),cv(r)}function FYe(e,t,n){return Hce(e,t*7,n)}function OYe(e,t,n){return qce(e,t*12,n)}function LYe(e,t){let n,r=t==null?void 0:t.in;return e.forEach(o=>{!r&&typeof o=="object"&&(r=Io.bind(null,o));const s=gr(o,r);(!n||n<s||isNaN(+s))&&(n=s)}),Io(r,n||NaN)}function $Ye(e,t){let n,r=t==null?void 0:t.in;return e.forEach(o=>{!r&&typeof o=="object"&&(r=Io.bind(null,o));const s=gr(o,r);(!n||n>s||isNaN(+s))&&(n=s)}),Io(r,n||NaN)}function zYe(e,t,n){const[r,o]=ex(n==null?void 0:n.in,e,t);return+uv(r)==+uv(o)}function Kce(e){return e instanceof Date||typeof e=="object"&&Object.prototype.toString.call(e)==="[object Date]"}function BYe(e){return!(!Kce(e)&&typeof e!="number"||isNaN(+gr(e)))}function VYe(e,t,n){const[r,o]=ex(n==null?void 0:n.in,e,t),s=r.getFullYear()-o.getFullYear(),i=r.getMonth()-o.getMonth();return s*12+i}function HYe(e,t){const n=gr(e,t==null?void 0:t.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}function Gce(e,t){const[n,r]=ex(e,t.start,t.end);return{start:n,end:r}}function qYe(e,t){const{start:n,end:r}=Gce(t==null?void 0:t.in,e);let o=+n>+r;const s=o?+n:+r,i=o?r:n;i.setHours(0,0,0,0),i.setDate(1);let a=1;const c=[];for(;+i<=s;)c.push(Io(n,i)),i.setMonth(i.getMonth()+a);return o?c.reverse():c}function UYe(e,t){const n=gr(e,t==null?void 0:t.in);return n.setDate(1),n.setHours(0,0,0,0),n}function WYe(e,t){const n=gr(e,t==null?void 0:t.in),r=n.getFullYear();return n.setFullYear(r+1,0,0),n.setHours(23,59,59,999),n}function Yce(e,t){const n=gr(e,t==null?void 0:t.in);return n.setFullYear(n.getFullYear(),0,1),n.setHours(0,0,0,0),n}function KYe(e,t){const{start:n,end:r}=Gce(t==null?void 0:t.in,e);let o=+n>+r;const s=o?+n:+r,i=o?r:n;i.setHours(0,0,0,0),i.setMonth(0,1);let a=1;const c=[];for(;+i<=s;)c.push(Io(n,i)),i.setFullYear(i.getFullYear()+a);return o?c.reverse():c}function Zce(e,t){var a,c,u,d;const n=Hw(),r=(t==null?void 0:t.weekStartsOn)??((c=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:c.weekStartsOn)??n.weekStartsOn??((d=(u=n.locale)==null?void 0:u.options)==null?void 0:d.weekStartsOn)??0,o=gr(e,t==null?void 0:t.in),s=o.getDay(),i=(s<r?-7:0)+6-(s-r);return o.setDate(o.getDate()+i),o.setHours(23,59,59,999),o}function GYe(e,t){return Zce(e,{...t,weekStartsOn:1})}const YYe={lessThanXSeconds:{one:"less than a second",other:"less than {{count}} seconds"},xSeconds:{one:"1 second",other:"{{count}} seconds"},halfAMinute:"half a minute",lessThanXMinutes:{one:"less than a minute",other:"less than {{count}} minutes"},xMinutes:{one:"1 minute",other:"{{count}} minutes"},aboutXHours:{one:"about 1 hour",other:"about {{count}} hours"},xHours:{one:"1 hour",other:"{{count}} hours"},xDays:{one:"1 day",other:"{{count}} days"},aboutXWeeks:{one:"about 1 week",other:"about {{count}} weeks"},xWeeks:{one:"1 week",other:"{{count}} weeks"},aboutXMonths:{one:"about 1 month",other:"about {{count}} months"},xMonths:{one:"1 month",other:"{{count}} months"},aboutXYears:{one:"about 1 year",other:"about {{count}} years"},xYears:{one:"1 year",other:"{{count}} years"},overXYears:{one:"over 1 year",other:"over {{count}} years"},almostXYears:{one:"almost 1 year",other:"almost {{count}} years"}},ZYe=(e,t,n)=>{let r;const o=YYe[e];return typeof o=="string"?r=o:t===1?r=o.one:r=o.other.replace("{{count}}",t.toString()),n!=null&&n.addSuffix?n.comparison&&n.comparison>0?"in "+r:r+" ago":r};function wM(e){return(t={})=>{const n=t.width?String(t.width):e.defaultWidth;return e.formats[n]||e.formats[e.defaultWidth]}}const XYe={full:"EEEE, MMMM do, y",long:"MMMM do, y",medium:"MMM d, y",short:"MM/dd/yyyy"},QYe={full:"h:mm:ss a zzzz",long:"h:mm:ss a z",medium:"h:mm:ss a",short:"h:mm a"},JYe={full:"{{date}} 'at' {{time}}",long:"{{date}} 'at' {{time}}",medium:"{{date}}, {{time}}",short:"{{date}}, {{time}}"},eZe={date:wM({formats:XYe,defaultWidth:"full"}),time:wM({formats:QYe,defaultWidth:"full"}),dateTime:wM({formats:JYe,defaultWidth:"full"})},tZe={lastWeek:"'last' eeee 'at' p",yesterday:"'yesterday at' p",today:"'today at' p",tomorrow:"'tomorrow at' p",nextWeek:"eeee 'at' p",other:"P"},nZe=(e,t,n,r)=>tZe[e];function qx(e){return(t,n)=>{const r=n!=null&&n.context?String(n.context):"standalone";let o;if(r==="formatting"&&e.formattingValues){const i=e.defaultFormattingWidth||e.defaultWidth,a=n!=null&&n.width?String(n.width):i;o=e.formattingValues[a]||e.formattingValues[i]}else{const i=e.defaultWidth,a=n!=null&&n.width?String(n.width):e.defaultWidth;o=e.values[a]||e.values[i]}const s=e.argumentCallback?e.argumentCallback(t):t;return o[s]}}const rZe={narrow:["B","A"],abbreviated:["BC","AD"],wide:["Before Christ","Anno Domini"]},oZe={narrow:["1","2","3","4"],abbreviated:["Q1","Q2","Q3","Q4"],wide:["1st quarter","2nd quarter","3rd quarter","4th quarter"]},sZe={narrow:["J","F","M","A","M","J","J","A","S","O","N","D"],abbreviated:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],wide:["January","February","March","April","May","June","July","August","September","October","November","December"]},iZe={narrow:["S","M","T","W","T","F","S"],short:["Su","Mo","Tu","We","Th","Fr","Sa"],abbreviated:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],wide:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]},aZe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"}},lZe={narrow:{am:"a",pm:"p",midnight:"mi",noon:"n",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},abbreviated:{am:"AM",pm:"PM",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"},wide:{am:"a.m.",pm:"p.m.",midnight:"midnight",noon:"noon",morning:"in the morning",afternoon:"in the afternoon",evening:"in the evening",night:"at night"}},cZe=(e,t)=>{const n=Number(e),r=n%100;if(r>20||r<10)switch(r%10){case 1:return n+"st";case 2:return n+"nd";case 3:return n+"rd"}return n+"th"},uZe={ordinalNumber:cZe,era:qx({values:rZe,defaultWidth:"wide"}),quarter:qx({values:oZe,defaultWidth:"wide",argumentCallback:e=>e-1}),month:qx({values:sZe,defaultWidth:"wide"}),day:qx({values:iZe,defaultWidth:"wide"}),dayPeriod:qx({values:aZe,defaultWidth:"wide",formattingValues:lZe,defaultFormattingWidth:"wide"})};function Ux(e){return(t,n={})=>{const r=n.width,o=r&&e.matchPatterns[r]||e.matchPatterns[e.defaultMatchWidth],s=t.match(o);if(!s)return null;const i=s[0],a=r&&e.parsePatterns[r]||e.parsePatterns[e.defaultParseWidth],c=Array.isArray(a)?fZe(a,f=>f.test(i)):dZe(a,f=>f.test(i));let u;u=e.valueCallback?e.valueCallback(c):c,u=n.valueCallback?n.valueCallback(u):u;const d=t.slice(i.length);return{value:u,rest:d}}}function dZe(e,t){for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&t(e[n]))return n}function fZe(e,t){for(let n=0;n<e.length;n++)if(t(e[n]))return n}function hZe(e){return(t,n={})=>{const r=t.match(e.matchPattern);if(!r)return null;const o=r[0],s=t.match(e.parsePattern);if(!s)return null;let i=e.valueCallback?e.valueCallback(s[0]):s[0];i=n.valueCallback?n.valueCallback(i):i;const a=t.slice(o.length);return{value:i,rest:a}}}const mZe=/^(\d+)(th|st|nd|rd)?/i,pZe=/\d+/i,gZe={narrow:/^(b|a)/i,abbreviated:/^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,wide:/^(before christ|before common era|anno domini|common era)/i},bZe={any:[/^b/i,/^(a|c)/i]},xZe={narrow:/^[1234]/i,abbreviated:/^q[1234]/i,wide:/^[1234](th|st|nd|rd)? quarter/i},yZe={any:[/1/i,/2/i,/3/i,/4/i]},vZe={narrow:/^[jfmasond]/i,abbreviated:/^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,wide:/^(january|february|march|april|may|june|july|august|september|october|november|december)/i},wZe={narrow:[/^j/i,/^f/i,/^m/i,/^a/i,/^m/i,/^j/i,/^j/i,/^a/i,/^s/i,/^o/i,/^n/i,/^d/i],any:[/^ja/i,/^f/i,/^mar/i,/^ap/i,/^may/i,/^jun/i,/^jul/i,/^au/i,/^s/i,/^o/i,/^n/i,/^d/i]},CZe={narrow:/^[smtwf]/i,short:/^(su|mo|tu|we|th|fr|sa)/i,abbreviated:/^(sun|mon|tue|wed|thu|fri|sat)/i,wide:/^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i},SZe={narrow:[/^s/i,/^m/i,/^t/i,/^w/i,/^t/i,/^f/i,/^s/i],any:[/^su/i,/^m/i,/^tu/i,/^w/i,/^th/i,/^f/i,/^sa/i]},NZe={narrow:/^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,any:/^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i},jZe={any:{am:/^a/i,pm:/^p/i,midnight:/^mi/i,noon:/^no/i,morning:/morning/i,afternoon:/afternoon/i,evening:/evening/i,night:/night/i}},kZe={ordinalNumber:hZe({matchPattern:mZe,parsePattern:pZe,valueCallback:e=>parseInt(e,10)}),era:Ux({matchPatterns:gZe,defaultMatchWidth:"wide",parsePatterns:bZe,defaultParseWidth:"any"}),quarter:Ux({matchPatterns:xZe,defaultMatchWidth:"wide",parsePatterns:yZe,defaultParseWidth:"any",valueCallback:e=>e+1}),month:Ux({matchPatterns:vZe,defaultMatchWidth:"wide",parsePatterns:wZe,defaultParseWidth:"any"}),day:Ux({matchPatterns:CZe,defaultMatchWidth:"wide",parsePatterns:SZe,defaultParseWidth:"any"}),dayPeriod:Ux({matchPatterns:NZe,defaultMatchWidth:"any",parsePatterns:jZe,defaultParseWidth:"any"})},A$={code:"en-US",formatDistance:ZYe,formatLong:eZe,formatRelative:nZe,localize:uZe,match:kZe,options:{weekStartsOn:0,firstWeekContainsDate:1}};function IZe(e,t){const n=gr(e,t==null?void 0:t.in);return Wce(n,Yce(n))+1}function Xce(e,t){const n=gr(e,t==null?void 0:t.in),r=+cv(n)-+PYe(n);return Math.round(r/Vce)+1}function Qce(e,t){var d,f,h,m;const n=gr(e,t==null?void 0:t.in),r=n.getFullYear(),o=Hw(),s=(t==null?void 0:t.firstWeekContainsDate)??((f=(d=t==null?void 0:t.locale)==null?void 0:d.options)==null?void 0:f.firstWeekContainsDate)??o.firstWeekContainsDate??((m=(h=o.locale)==null?void 0:h.options)==null?void 0:m.firstWeekContainsDate)??1,i=Io((t==null?void 0:t.in)||e,0);i.setFullYear(r+1,0,s),i.setHours(0,0,0,0);const a=cb(i,t),c=Io((t==null?void 0:t.in)||e,0);c.setFullYear(r,0,s),c.setHours(0,0,0,0);const u=cb(c,t);return+n>=+a?r+1:+n>=+u?r:r-1}function _Ze(e,t){var a,c,u,d;const n=Hw(),r=(t==null?void 0:t.firstWeekContainsDate)??((c=(a=t==null?void 0:t.locale)==null?void 0:a.options)==null?void 0:c.firstWeekContainsDate)??n.firstWeekContainsDate??((d=(u=n.locale)==null?void 0:u.options)==null?void 0:d.firstWeekContainsDate)??1,o=Qce(e,t),s=Io((t==null?void 0:t.in)||e,0);return s.setFullYear(o,0,r),s.setHours(0,0,0,0),cb(s,t)}function Jce(e,t){const n=gr(e,t==null?void 0:t.in),r=+cb(n,t)-+_Ze(n,t);return Math.round(r/Vce)+1}function lr(e,t){const n=e<0?"-":"",r=Math.abs(e).toString().padStart(t,"0");return n+r}const nd={y(e,t){const n=e.getFullYear(),r=n>0?n:1-n;return lr(t==="yy"?r%100:r,t.length)},M(e,t){const n=e.getMonth();return t==="M"?String(n+1):lr(n+1,2)},d(e,t){return lr(e.getDate(),t.length)},a(e,t){const n=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.toUpperCase();case"aaa":return n;case"aaaaa":return n[0];case"aaaa":default:return n==="am"?"a.m.":"p.m."}},h(e,t){return lr(e.getHours()%12||12,t.length)},H(e,t){return lr(e.getHours(),t.length)},m(e,t){return lr(e.getMinutes(),t.length)},s(e,t){return lr(e.getSeconds(),t.length)},S(e,t){const n=t.length,r=e.getMilliseconds(),o=Math.trunc(r*Math.pow(10,n-3));return lr(o,t.length)}},Tp={midnight:"midnight",noon:"noon",morning:"morning",afternoon:"afternoon",evening:"evening",night:"night"},eU={G:function(e,t,n){const r=e.getFullYear()>0?1:0;switch(t){case"G":case"GG":case"GGG":return n.era(r,{width:"abbreviated"});case"GGGGG":return n.era(r,{width:"narrow"});case"GGGG":default:return n.era(r,{width:"wide"})}},y:function(e,t,n){if(t==="yo"){const r=e.getFullYear(),o=r>0?r:1-r;return n.ordinalNumber(o,{unit:"year"})}return nd.y(e,t)},Y:function(e,t,n,r){const o=Qce(e,r),s=o>0?o:1-o;if(t==="YY"){const i=s%100;return lr(i,2)}return t==="Yo"?n.ordinalNumber(s,{unit:"year"}):lr(s,t.length)},R:function(e,t){const n=Uce(e);return lr(n,t.length)},u:function(e,t){const n=e.getFullYear();return lr(n,t.length)},Q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"Q":return String(r);case"QQ":return lr(r,2);case"Qo":return n.ordinalNumber(r,{unit:"quarter"});case"QQQ":return n.quarter(r,{width:"abbreviated",context:"formatting"});case"QQQQQ":return n.quarter(r,{width:"narrow",context:"formatting"});case"QQQQ":default:return n.quarter(r,{width:"wide",context:"formatting"})}},q:function(e,t,n){const r=Math.ceil((e.getMonth()+1)/3);switch(t){case"q":return String(r);case"qq":return lr(r,2);case"qo":return n.ordinalNumber(r,{unit:"quarter"});case"qqq":return n.quarter(r,{width:"abbreviated",context:"standalone"});case"qqqqq":return n.quarter(r,{width:"narrow",context:"standalone"});case"qqqq":default:return n.quarter(r,{width:"wide",context:"standalone"})}},M:function(e,t,n){const r=e.getMonth();switch(t){case"M":case"MM":return nd.M(e,t);case"Mo":return n.ordinalNumber(r+1,{unit:"month"});case"MMM":return n.month(r,{width:"abbreviated",context:"formatting"});case"MMMMM":return n.month(r,{width:"narrow",context:"formatting"});case"MMMM":default:return n.month(r,{width:"wide",context:"formatting"})}},L:function(e,t,n){const r=e.getMonth();switch(t){case"L":return String(r+1);case"LL":return lr(r+1,2);case"Lo":return n.ordinalNumber(r+1,{unit:"month"});case"LLL":return n.month(r,{width:"abbreviated",context:"standalone"});case"LLLLL":return n.month(r,{width:"narrow",context:"standalone"});case"LLLL":default:return n.month(r,{width:"wide",context:"standalone"})}},w:function(e,t,n,r){const o=Jce(e,r);return t==="wo"?n.ordinalNumber(o,{unit:"week"}):lr(o,t.length)},I:function(e,t,n){const r=Xce(e);return t==="Io"?n.ordinalNumber(r,{unit:"week"}):lr(r,t.length)},d:function(e,t,n){return t==="do"?n.ordinalNumber(e.getDate(),{unit:"date"}):nd.d(e,t)},D:function(e,t,n){const r=IZe(e);return t==="Do"?n.ordinalNumber(r,{unit:"dayOfYear"}):lr(r,t.length)},E:function(e,t,n){const r=e.getDay();switch(t){case"E":case"EE":case"EEE":return n.day(r,{width:"abbreviated",context:"formatting"});case"EEEEE":return n.day(r,{width:"narrow",context:"formatting"});case"EEEEEE":return n.day(r,{width:"short",context:"formatting"});case"EEEE":default:return n.day(r,{width:"wide",context:"formatting"})}},e:function(e,t,n,r){const o=e.getDay(),s=(o-r.weekStartsOn+8)%7||7;switch(t){case"e":return String(s);case"ee":return lr(s,2);case"eo":return n.ordinalNumber(s,{unit:"day"});case"eee":return n.day(o,{width:"abbreviated",context:"formatting"});case"eeeee":return n.day(o,{width:"narrow",context:"formatting"});case"eeeeee":return n.day(o,{width:"short",context:"formatting"});case"eeee":default:return n.day(o,{width:"wide",context:"formatting"})}},c:function(e,t,n,r){const o=e.getDay(),s=(o-r.weekStartsOn+8)%7||7;switch(t){case"c":return String(s);case"cc":return lr(s,t.length);case"co":return n.ordinalNumber(s,{unit:"day"});case"ccc":return n.day(o,{width:"abbreviated",context:"standalone"});case"ccccc":return n.day(o,{width:"narrow",context:"standalone"});case"cccccc":return n.day(o,{width:"short",context:"standalone"});case"cccc":default:return n.day(o,{width:"wide",context:"standalone"})}},i:function(e,t,n){const r=e.getDay(),o=r===0?7:r;switch(t){case"i":return String(o);case"ii":return lr(o,t.length);case"io":return n.ordinalNumber(o,{unit:"day"});case"iii":return n.day(r,{width:"abbreviated",context:"formatting"});case"iiiii":return n.day(r,{width:"narrow",context:"formatting"});case"iiiiii":return n.day(r,{width:"short",context:"formatting"});case"iiii":default:return n.day(r,{width:"wide",context:"formatting"})}},a:function(e,t,n){const o=e.getHours()/12>=1?"pm":"am";switch(t){case"a":case"aa":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"aaa":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"aaaaa":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"aaaa":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},b:function(e,t,n){const r=e.getHours();let o;switch(r===12?o=Tp.noon:r===0?o=Tp.midnight:o=r/12>=1?"pm":"am",t){case"b":case"bb":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"bbb":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"}).toLowerCase();case"bbbbb":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"bbbb":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},B:function(e,t,n){const r=e.getHours();let o;switch(r>=17?o=Tp.evening:r>=12?o=Tp.afternoon:r>=4?o=Tp.morning:o=Tp.night,t){case"B":case"BB":case"BBB":return n.dayPeriod(o,{width:"abbreviated",context:"formatting"});case"BBBBB":return n.dayPeriod(o,{width:"narrow",context:"formatting"});case"BBBB":default:return n.dayPeriod(o,{width:"wide",context:"formatting"})}},h:function(e,t,n){if(t==="ho"){let r=e.getHours()%12;return r===0&&(r=12),n.ordinalNumber(r,{unit:"hour"})}return nd.h(e,t)},H:function(e,t,n){return t==="Ho"?n.ordinalNumber(e.getHours(),{unit:"hour"}):nd.H(e,t)},K:function(e,t,n){const r=e.getHours()%12;return t==="Ko"?n.ordinalNumber(r,{unit:"hour"}):lr(r,t.length)},k:function(e,t,n){let r=e.getHours();return r===0&&(r=24),t==="ko"?n.ordinalNumber(r,{unit:"hour"}):lr(r,t.length)},m:function(e,t,n){return t==="mo"?n.ordinalNumber(e.getMinutes(),{unit:"minute"}):nd.m(e,t)},s:function(e,t,n){return t==="so"?n.ordinalNumber(e.getSeconds(),{unit:"second"}):nd.s(e,t)},S:function(e,t){return nd.S(e,t)},X:function(e,t,n){const r=e.getTimezoneOffset();if(r===0)return"Z";switch(t){case"X":return nU(r);case"XXXX":case"XX":return th(r);case"XXXXX":case"XXX":default:return th(r,":")}},x:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"x":return nU(r);case"xxxx":case"xx":return th(r);case"xxxxx":case"xxx":default:return th(r,":")}},O:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"O":case"OO":case"OOO":return"GMT"+tU(r,":");case"OOOO":default:return"GMT"+th(r,":")}},z:function(e,t,n){const r=e.getTimezoneOffset();switch(t){case"z":case"zz":case"zzz":return"GMT"+tU(r,":");case"zzzz":default:return"GMT"+th(r,":")}},t:function(e,t,n){const r=Math.trunc(+e/1e3);return lr(r,t.length)},T:function(e,t,n){return lr(+e,t.length)}};function tU(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),o=Math.trunc(r/60),s=r%60;return s===0?n+String(o):n+String(o)+t+lr(s,2)}function nU(e,t){return e%60===0?(e>0?"-":"+")+lr(Math.abs(e)/60,2):th(e,t)}function th(e,t=""){const n=e>0?"-":"+",r=Math.abs(e),o=lr(Math.trunc(r/60),2),s=lr(r%60,2);return n+o+t+s}const rU=(e,t)=>{switch(e){case"P":return t.date({width:"short"});case"PP":return t.date({width:"medium"});case"PPP":return t.date({width:"long"});case"PPPP":default:return t.date({width:"full"})}},eue=(e,t)=>{switch(e){case"p":return t.time({width:"short"});case"pp":return t.time({width:"medium"});case"ppp":return t.time({width:"long"});case"pppp":default:return t.time({width:"full"})}},TZe=(e,t)=>{const n=e.match(/(P+)(p+)?/)||[],r=n[1],o=n[2];if(!o)return rU(e,t);let s;switch(r){case"P":s=t.dateTime({width:"short"});break;case"PP":s=t.dateTime({width:"medium"});break;case"PPP":s=t.dateTime({width:"long"});break;case"PPPP":default:s=t.dateTime({width:"full"});break}return s.replace("{{date}}",rU(r,t)).replace("{{time}}",eue(o,t))},EZe={p:eue,P:TZe},DZe=/^D+$/,MZe=/^Y+$/,RZe=["D","DD","YY","YYYY"];function AZe(e){return DZe.test(e)}function PZe(e){return MZe.test(e)}function FZe(e,t,n){const r=OZe(e,t,n);if(console.warn(r),RZe.includes(e))throw new RangeError(r)}function OZe(e,t,n){const r=e[0]==="Y"?"years":"days of the month";return`Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`}const LZe=/[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g,$Ze=/P+p+|P+|p+|''|'(''|[^'])+('|$)|./g,zZe=/^'([^]*?)'?$/,BZe=/''/g,VZe=/[a-zA-Z]/;function HZe(e,t,n){var d,f,h,m,g,x,b,y;const r=Hw(),o=(n==null?void 0:n.locale)??r.locale??A$,s=(n==null?void 0:n.firstWeekContainsDate)??((f=(d=n==null?void 0:n.locale)==null?void 0:d.options)==null?void 0:f.firstWeekContainsDate)??r.firstWeekContainsDate??((m=(h=r.locale)==null?void 0:h.options)==null?void 0:m.firstWeekContainsDate)??1,i=(n==null?void 0:n.weekStartsOn)??((x=(g=n==null?void 0:n.locale)==null?void 0:g.options)==null?void 0:x.weekStartsOn)??r.weekStartsOn??((y=(b=r.locale)==null?void 0:b.options)==null?void 0:y.weekStartsOn)??0,a=gr(e,n==null?void 0:n.in);if(!BYe(a))throw new RangeError("Invalid time value");let c=t.match($Ze).map(w=>{const C=w[0];if(C==="p"||C==="P"){const N=EZe[C];return N(w,o.formatLong)}return w}).join("").match(LZe).map(w=>{if(w==="''")return{isToken:!1,value:"'"};const C=w[0];if(C==="'")return{isToken:!1,value:qZe(w)};if(eU[C])return{isToken:!0,value:w};if(C.match(VZe))throw new RangeError("Format string contains an unescaped latin alphabet character `"+C+"`");return{isToken:!1,value:w}});o.localize.preprocessor&&(c=o.localize.preprocessor(a,c));const u={firstWeekContainsDate:s,weekStartsOn:i,locale:o};return c.map(w=>{if(!w.isToken)return w.value;const C=w.value;(!(n!=null&&n.useAdditionalWeekYearTokens)&&PZe(C)||!(n!=null&&n.useAdditionalDayOfYearTokens)&&AZe(C))&&FZe(C,t,String(e));const N=eU[C[0]];return N(a,C,o.localize,u)}).join("")}function qZe(e){const t=e.match(zZe);return t?t[1].replace(BZe,"'"):e}function UZe(e,t){const n=gr(e,t==null?void 0:t.in),r=n.getFullYear(),o=n.getMonth(),s=Io(n,0);return s.setFullYear(r,o+1,0),s.setHours(0,0,0,0),s.getDate()}function WZe(e,t){return gr(e,t==null?void 0:t.in).getMonth()}function KZe(e,t){return gr(e,t==null?void 0:t.in).getFullYear()}function GZe(e,t){return+gr(e)>+gr(t)}function YZe(e,t){return+gr(e)<+gr(t)}function ZZe(e,t,n){const[r,o]=ex(n==null?void 0:n.in,e,t);return r.getFullYear()===o.getFullYear()&&r.getMonth()===o.getMonth()}function XZe(e,t,n){const[r,o]=ex(n==null?void 0:n.in,e,t);return r.getFullYear()===o.getFullYear()}function QZe(e,t,n){const r=gr(e,n==null?void 0:n.in),o=r.getFullYear(),s=r.getDate(),i=Io(e,0);i.setFullYear(o,t,15),i.setHours(0,0,0,0);const a=UZe(i);return r.setMonth(t,Math.min(s,a)),r}function JZe(e,t,n){const r=gr(e,n==null?void 0:n.in);return isNaN(+r)?Io(e,NaN):(r.setFullYear(t),r)}const oU=5,eXe=4;function tXe(e,t){const n=t.startOfMonth(e),r=n.getDay()>0?n.getDay():7,o=t.addDays(e,-r+1),s=t.addDays(o,oU*7-1);return t.getMonth(e)===t.getMonth(s)?oU:eXe}function tue(e,t){const n=t.startOfMonth(e),r=n.getDay();return r===1?n:r===0?t.addDays(n,-1*6):t.addDays(n,-1*(r-1))}function nXe(e,t){const n=tue(e,t),r=tXe(e,t);return t.addDays(n,r*7-1)}class Qi{constructor(t,n){this.Date=Date,this.today=()=>{var r;return(r=this.overrides)!=null&&r.today?this.overrides.today():this.options.timeZone?ru.tz(this.options.timeZone):new this.Date},this.newDate=(r,o,s)=>{var i;return(i=this.overrides)!=null&&i.newDate?this.overrides.newDate(r,o,s):this.options.timeZone?new ru(r,o,s,this.options.timeZone):new Date(r,o,s)},this.addDays=(r,o)=>{var s;return(s=this.overrides)!=null&&s.addDays?this.overrides.addDays(r,o):Hce(r,o)},this.addMonths=(r,o)=>{var s;return(s=this.overrides)!=null&&s.addMonths?this.overrides.addMonths(r,o):qce(r,o)},this.addWeeks=(r,o)=>{var s;return(s=this.overrides)!=null&&s.addWeeks?this.overrides.addWeeks(r,o):FYe(r,o)},this.addYears=(r,o)=>{var s;return(s=this.overrides)!=null&&s.addYears?this.overrides.addYears(r,o):OYe(r,o)},this.differenceInCalendarDays=(r,o)=>{var s;return(s=this.overrides)!=null&&s.differenceInCalendarDays?this.overrides.differenceInCalendarDays(r,o):Wce(r,o)},this.differenceInCalendarMonths=(r,o)=>{var s;return(s=this.overrides)!=null&&s.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(r,o):VYe(r,o)},this.eachMonthOfInterval=r=>{var o;return(o=this.overrides)!=null&&o.eachMonthOfInterval?this.overrides.eachMonthOfInterval(r):qYe(r)},this.eachYearOfInterval=r=>{var a;const o=(a=this.overrides)!=null&&a.eachYearOfInterval?this.overrides.eachYearOfInterval(r):KYe(r),s=new Set(o.map(c=>this.getYear(c)));if(s.size===o.length)return o;const i=[];return s.forEach(c=>{i.push(new Date(c,0,1))}),i},this.endOfBroadcastWeek=r=>{var o;return(o=this.overrides)!=null&&o.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(r):nXe(r,this)},this.endOfISOWeek=r=>{var o;return(o=this.overrides)!=null&&o.endOfISOWeek?this.overrides.endOfISOWeek(r):GYe(r)},this.endOfMonth=r=>{var o;return(o=this.overrides)!=null&&o.endOfMonth?this.overrides.endOfMonth(r):HYe(r)},this.endOfWeek=(r,o)=>{var s;return(s=this.overrides)!=null&&s.endOfWeek?this.overrides.endOfWeek(r,o):Zce(r,this.options)},this.endOfYear=r=>{var o;return(o=this.overrides)!=null&&o.endOfYear?this.overrides.endOfYear(r):WYe(r)},this.format=(r,o,s)=>{var a;const i=(a=this.overrides)!=null&&a.format?this.overrides.format(r,o,this.options):HZe(r,o,this.options);return this.options.numerals&&this.options.numerals!=="latn"?this.replaceDigits(i):i},this.getISOWeek=r=>{var o;return(o=this.overrides)!=null&&o.getISOWeek?this.overrides.getISOWeek(r):Xce(r)},this.getMonth=(r,o)=>{var s;return(s=this.overrides)!=null&&s.getMonth?this.overrides.getMonth(r,this.options):WZe(r,this.options)},this.getYear=(r,o)=>{var s;return(s=this.overrides)!=null&&s.getYear?this.overrides.getYear(r,this.options):KZe(r,this.options)},this.getWeek=(r,o)=>{var s;return(s=this.overrides)!=null&&s.getWeek?this.overrides.getWeek(r,this.options):Jce(r,this.options)},this.isAfter=(r,o)=>{var s;return(s=this.overrides)!=null&&s.isAfter?this.overrides.isAfter(r,o):GZe(r,o)},this.isBefore=(r,o)=>{var s;return(s=this.overrides)!=null&&s.isBefore?this.overrides.isBefore(r,o):YZe(r,o)},this.isDate=r=>{var o;return(o=this.overrides)!=null&&o.isDate?this.overrides.isDate(r):Kce(r)},this.isSameDay=(r,o)=>{var s;return(s=this.overrides)!=null&&s.isSameDay?this.overrides.isSameDay(r,o):zYe(r,o)},this.isSameMonth=(r,o)=>{var s;return(s=this.overrides)!=null&&s.isSameMonth?this.overrides.isSameMonth(r,o):ZZe(r,o)},this.isSameYear=(r,o)=>{var s;return(s=this.overrides)!=null&&s.isSameYear?this.overrides.isSameYear(r,o):XZe(r,o)},this.max=r=>{var o;return(o=this.overrides)!=null&&o.max?this.overrides.max(r):LYe(r)},this.min=r=>{var o;return(o=this.overrides)!=null&&o.min?this.overrides.min(r):$Ye(r)},this.setMonth=(r,o)=>{var s;return(s=this.overrides)!=null&&s.setMonth?this.overrides.setMonth(r,o):QZe(r,o)},this.setYear=(r,o)=>{var s;return(s=this.overrides)!=null&&s.setYear?this.overrides.setYear(r,o):JZe(r,o)},this.startOfBroadcastWeek=(r,o)=>{var s;return(s=this.overrides)!=null&&s.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(r,this):tue(r,this)},this.startOfDay=r=>{var o;return(o=this.overrides)!=null&&o.startOfDay?this.overrides.startOfDay(r):uv(r)},this.startOfISOWeek=r=>{var o;return(o=this.overrides)!=null&&o.startOfISOWeek?this.overrides.startOfISOWeek(r):cv(r)},this.startOfMonth=r=>{var o;return(o=this.overrides)!=null&&o.startOfMonth?this.overrides.startOfMonth(r):UYe(r)},this.startOfWeek=(r,o)=>{var s;return(s=this.overrides)!=null&&s.startOfWeek?this.overrides.startOfWeek(r,this.options):cb(r,this.options)},this.startOfYear=r=>{var o;return(o=this.overrides)!=null&&o.startOfYear?this.overrides.startOfYear(r):Yce(r)},this.options={locale:A$,...t},this.overrides=n}getDigitMap(){const{numerals:t="latn"}=this.options,n=new Intl.NumberFormat("en-US",{numberingSystem:t}),r={};for(let o=0;o<10;o++)r[o.toString()]=n.format(o);return r}replaceDigits(t){const n=this.getDigitMap();return t.replace(/\d/g,r=>n[r]||r)}formatNumber(t){return this.replaceDigits(t.toString())}getMonthYearOrder(){var n;const t=(n=this.options.locale)==null?void 0:n.code;return t&&Qi.yearFirstLocales.has(t)?"year-first":"month-first"}formatMonthYear(t){const{locale:n,timeZone:r,numerals:o}=this.options,s=n==null?void 0:n.code;if(s&&Qi.yearFirstLocales.has(s))try{return new Intl.DateTimeFormat(s,{month:"long",year:"numeric",timeZone:r,numberingSystem:o}).format(t)}catch{}const i=this.getMonthYearOrder()==="year-first"?"y LLLL":"LLLL y";return this.format(t,i)}}Qi.yearFirstLocales=new Set(["eu","hu","ja","ja-Hira","ja-JP","ko","ko-KR","lt","lt-LT","lv","lv-LV","mn","mn-MN","zh","zh-CN","zh-HK","zh-TW"]);const wc=new Qi;class nue{constructor(t,n,r=wc){this.date=t,this.displayMonth=n,this.outside=!!(n&&!r.isSameMonth(t,n)),this.dateLib=r,this.isoDate=r.format(t,"yyyy-MM-dd"),this.displayMonthId=r.format(n,"yyyy-MM"),this.dateMonthId=r.format(t,"yyyy-MM")}isEqualTo(t){return this.dateLib.isSameDay(t.date,this.date)&&this.dateLib.isSameMonth(t.displayMonth,this.displayMonth)}}class rXe{constructor(t,n){this.date=t,this.weeks=n}}class oXe{constructor(t,n){this.days=n,this.weekNumber=t}}function sXe(e){return v.createElement("button",{...e})}function iXe(e){return v.createElement("span",{...e})}function aXe(e){const{size:t=24,orientation:n="left",className:r}=e;return v.createElement("svg",{className:r,width:t,height:t,viewBox:"0 0 24 24"},n==="up"&&v.createElement("polygon",{points:"6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28"}),n==="down"&&v.createElement("polygon",{points:"6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72"}),n==="left"&&v.createElement("polygon",{points:"16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20"}),n==="right"&&v.createElement("polygon",{points:"8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20"}))}function lXe(e){const{day:t,modifiers:n,...r}=e;return v.createElement("td",{...r})}function cXe(e){const{day:t,modifiers:n,...r}=e,o=v.useRef(null);return v.useEffect(()=>{var s;n.focused&&((s=o.current)==null||s.focus())},[n.focused]),v.createElement("button",{ref:o,...r})}var qt;(function(e){e.Root="root",e.Chevron="chevron",e.Day="day",e.DayButton="day_button",e.CaptionLabel="caption_label",e.Dropdowns="dropdowns",e.Dropdown="dropdown",e.DropdownRoot="dropdown_root",e.Footer="footer",e.MonthGrid="month_grid",e.MonthCaption="month_caption",e.MonthsDropdown="months_dropdown",e.Month="month",e.Months="months",e.Nav="nav",e.NextMonthButton="button_next",e.PreviousMonthButton="button_previous",e.Week="week",e.Weeks="weeks",e.Weekday="weekday",e.Weekdays="weekdays",e.WeekNumber="week_number",e.WeekNumberHeader="week_number_header",e.YearsDropdown="years_dropdown"})(qt||(qt={}));var Gr;(function(e){e.disabled="disabled",e.hidden="hidden",e.outside="outside",e.focused="focused",e.today="today"})(Gr||(Gr={}));var Ya;(function(e){e.range_end="range_end",e.range_middle="range_middle",e.range_start="range_start",e.selected="selected"})(Ya||(Ya={}));var zi;(function(e){e.weeks_before_enter="weeks_before_enter",e.weeks_before_exit="weeks_before_exit",e.weeks_after_enter="weeks_after_enter",e.weeks_after_exit="weeks_after_exit",e.caption_after_enter="caption_after_enter",e.caption_after_exit="caption_after_exit",e.caption_before_enter="caption_before_enter",e.caption_before_exit="caption_before_exit"})(zi||(zi={}));function uXe(e){const{options:t,className:n,components:r,classNames:o,...s}=e,i=[o[qt.Dropdown],n].join(" "),a=t==null?void 0:t.find(({value:c})=>c===s.value);return v.createElement("span",{"data-disabled":s.disabled,className:o[qt.DropdownRoot]},v.createElement(r.Select,{className:i,...s},t==null?void 0:t.map(({value:c,label:u,disabled:d})=>v.createElement(r.Option,{key:c,value:c,disabled:d},u))),v.createElement("span",{className:o[qt.CaptionLabel],"aria-hidden":!0},a==null?void 0:a.label,v.createElement(r.Chevron,{orientation:"down",size:18,className:o[qt.Chevron]})))}function dXe(e){return v.createElement("div",{...e})}function fXe(e){return v.createElement("div",{...e})}function hXe(e){const{calendarMonth:t,displayIndex:n,...r}=e;return v.createElement("div",{...r},e.children)}function mXe(e){const{calendarMonth:t,displayIndex:n,...r}=e;return v.createElement("div",{...r})}function pXe(e){return v.createElement("table",{...e})}function gXe(e){return v.createElement("div",{...e})}const rue=v.createContext(void 0);function qw(){const e=v.useContext(rue);if(e===void 0)throw new Error("useDayPicker() must be used within a custom component.");return e}function bXe(e){const{components:t}=qw();return v.createElement(t.Dropdown,{...e})}function xXe(e){const{onPreviousClick:t,onNextClick:n,previousMonth:r,nextMonth:o,...s}=e,{components:i,classNames:a,labels:{labelPrevious:c,labelNext:u}}=qw(),d=v.useCallback(h=>{o&&(n==null||n(h))},[o,n]),f=v.useCallback(h=>{r&&(t==null||t(h))},[r,t]);return v.createElement("nav",{...s},v.createElement(i.PreviousMonthButton,{type:"button",className:a[qt.PreviousMonthButton],tabIndex:r?void 0:-1,"aria-disabled":r?void 0:!0,"aria-label":c(r),onClick:f},v.createElement(i.Chevron,{disabled:r?void 0:!0,className:a[qt.Chevron],orientation:"left"})),v.createElement(i.NextMonthButton,{type:"button",className:a[qt.NextMonthButton],tabIndex:o?void 0:-1,"aria-disabled":o?void 0:!0,"aria-label":u(o),onClick:d},v.createElement(i.Chevron,{disabled:o?void 0:!0,orientation:"right",className:a[qt.Chevron]})))}function yXe(e){const{components:t}=qw();return v.createElement(t.Button,{...e})}function vXe(e){return v.createElement("option",{...e})}function wXe(e){const{components:t}=qw();return v.createElement(t.Button,{...e})}function CXe(e){const{rootRef:t,...n}=e;return v.createElement("div",{...n,ref:t})}function SXe(e){return v.createElement("select",{...e})}function NXe(e){const{week:t,...n}=e;return v.createElement("tr",{...n})}function jXe(e){return v.createElement("th",{...e})}function kXe(e){return v.createElement("thead",{"aria-hidden":!0},v.createElement("tr",{...e}))}function IXe(e){const{week:t,...n}=e;return v.createElement("th",{...n})}function _Xe(e){return v.createElement("th",{...e})}function TXe(e){return v.createElement("tbody",{...e})}function EXe(e){const{components:t}=qw();return v.createElement(t.Dropdown,{...e})}const DXe=Object.freeze(Object.defineProperty({__proto__:null,Button:sXe,CaptionLabel:iXe,Chevron:aXe,Day:lXe,DayButton:cXe,Dropdown:uXe,DropdownNav:dXe,Footer:fXe,Month:hXe,MonthCaption:mXe,MonthGrid:pXe,Months:gXe,MonthsDropdown:bXe,Nav:xXe,NextMonthButton:yXe,Option:vXe,PreviousMonthButton:wXe,Root:CXe,Select:SXe,Week:NXe,WeekNumber:IXe,WeekNumberHeader:_Xe,Weekday:jXe,Weekdays:kXe,Weeks:TXe,YearsDropdown:EXe},Symbol.toStringTag,{value:"Module"}));function ou(e,t,n=!1,r=wc){let{from:o,to:s}=e;const{differenceInCalendarDays:i,isSameDay:a}=r;return o&&s?(i(s,o)<0&&([o,s]=[s,o]),i(t,o)>=(n?1:0)&&i(s,t)>=(n?1:0)):!n&&s?a(s,t):!n&&o?a(o,t):!1}function P$(e){return!!(e&&typeof e=="object"&&"before"in e&&"after"in e)}function q_(e){return!!(e&&typeof e=="object"&&"from"in e)}function F$(e){return!!(e&&typeof e=="object"&&"after"in e)}function O$(e){return!!(e&&typeof e=="object"&&"before"in e)}function oue(e){return!!(e&&typeof e=="object"&&"dayOfWeek"in e)}function sue(e,t){return Array.isArray(e)&&e.every(t.isDate)}function su(e,t,n=wc){const r=Array.isArray(t)?t:[t],{isSameDay:o,differenceInCalendarDays:s,isAfter:i}=n;return r.some(a=>{if(typeof a=="boolean")return a;if(n.isDate(a))return o(e,a);if(sue(a,n))return a.includes(e);if(q_(a))return ou(a,e,!1,n);if(oue(a))return Array.isArray(a.dayOfWeek)?a.dayOfWeek.includes(e.getDay()):a.dayOfWeek===e.getDay();if(P$(a)){const c=s(a.before,e),u=s(a.after,e),d=c>0,f=u<0;return i(a.before,a.after)?f&&d:d||f}return F$(a)?s(e,a.after)>0:O$(a)?s(a.before,e)>0:typeof a=="function"?a(e):!1})}function MXe(e,t,n,r,o){const{disabled:s,hidden:i,modifiers:a,showOutsideDays:c,broadcastCalendar:u,today:d=o.today()}=t,{isSameDay:f,isSameMonth:h,startOfMonth:m,isBefore:g,endOfMonth:x,isAfter:b}=o,y=n&&m(n),w=r&&x(r),C={[Gr.focused]:[],[Gr.outside]:[],[Gr.disabled]:[],[Gr.hidden]:[],[Gr.today]:[]},N={};for(const S of e){const{date:j,displayMonth:I}=S,k=!!(I&&!h(j,I)),T=!!(y&&g(j,y)),_=!!(w&&b(j,w)),E=!!(s&&su(j,s,o)),D=!!(i&&su(j,i,o))||T||_||!u&&!c&&k||u&&c===!1&&k,M=f(j,d);k&&C.outside.push(S),E&&C.disabled.push(S),D&&C.hidden.push(S),M&&C.today.push(S),a&&Object.keys(a).forEach(P=>{const A=a==null?void 0:a[P];A&&su(j,A,o)&&(N[P]?N[P].push(S):N[P]=[S])})}return S=>{const j={[Gr.focused]:!1,[Gr.disabled]:!1,[Gr.hidden]:!1,[Gr.outside]:!1,[Gr.today]:!1},I={};for(const k in C){const T=C[k];j[k]=T.some(_=>_===S)}for(const k in N)I[k]=N[k].some(T=>T===S);return{...j,...I}}}function RXe(e,t,n={}){return Object.entries(e).filter(([,o])=>o===!0).reduce((o,[s])=>(n[s]?o.push(n[s]):t[Gr[s]]?o.push(t[Gr[s]]):t[Ya[s]]&&o.push(t[Ya[s]]),o),[t[qt.Day]])}function AXe(e){return{...DXe,...e}}function PXe(e){const t={"data-mode":e.mode??void 0,"data-required":"required"in e?e.required:void 0,"data-multiple-months":e.numberOfMonths&&e.numberOfMonths>1||void 0,"data-week-numbers":e.showWeekNumber||void 0,"data-broadcast-calendar":e.broadcastCalendar||void 0,"data-nav-layout":e.navLayout||void 0};return Object.entries(e).forEach(([n,r])=>{n.startsWith("data-")&&(t[n]=r)}),t}function L$(){const e={};for(const t in qt)e[qt[t]]=`rdp-${qt[t]}`;for(const t in Gr)e[Gr[t]]=`rdp-${Gr[t]}`;for(const t in Ya)e[Ya[t]]=`rdp-${Ya[t]}`;for(const t in zi)e[zi[t]]=`rdp-${zi[t]}`;return e}function iue(e,t,n){return(n??new Qi(t)).formatMonthYear(e)}const FXe=iue;function OXe(e,t,n){return(n??new Qi(t)).format(e,"d")}function LXe(e,t=wc){return t.format(e,"LLLL")}function $Xe(e,t,n){return(n??new Qi(t)).format(e,"cccccc")}function zXe(e,t=wc){return e<10?t.formatNumber(`0${e.toLocaleString()}`):t.formatNumber(`${e.toLocaleString()}`)}function BXe(){return""}function aue(e,t=wc){return t.format(e,"yyyy")}const VXe=aue,HXe=Object.freeze(Object.defineProperty({__proto__:null,formatCaption:iue,formatDay:OXe,formatMonthCaption:FXe,formatMonthDropdown:LXe,formatWeekNumber:zXe,formatWeekNumberHeader:BXe,formatWeekdayName:$Xe,formatYearCaption:VXe,formatYearDropdown:aue},Symbol.toStringTag,{value:"Module"}));function qXe(e){return e!=null&&e.formatMonthCaption&&!e.formatCaption&&(e.formatCaption=e.formatMonthCaption),e!=null&&e.formatYearCaption&&!e.formatYearDropdown&&(e.formatYearDropdown=e.formatYearCaption),{...HXe,...e}}function UXe(e,t,n,r,o){const{startOfMonth:s,startOfYear:i,endOfYear:a,eachMonthOfInterval:c,getMonth:u}=o;return c({start:i(e),end:a(e)}).map(h=>{const m=r.formatMonthDropdown(h,o),g=u(h),x=t&&h<s(t)||n&&h>s(n)||!1;return{value:g,label:m,disabled:x}})}function WXe(e,t={},n={}){let r={...t==null?void 0:t[qt.Day]};return Object.entries(e).filter(([,o])=>o===!0).forEach(([o])=>{r={...r,...n==null?void 0:n[o]}}),r}function KXe(e,t,n,r){const o=r??e.today(),s=n?e.startOfBroadcastWeek(o,e):t?e.startOfISOWeek(o):e.startOfWeek(o),i=[];for(let a=0;a<7;a++){const c=e.addDays(s,a);i.push(c)}return i}function GXe(e,t,n,r,o=!1){if(!e||!t)return;const{startOfYear:s,endOfYear:i,eachYearOfInterval:a,getYear:c}=r,u=s(e),d=i(t),f=a({start:u,end:d});return o&&f.reverse(),f.map(h=>{const m=n.formatYearDropdown(h,r);return{value:c(h),label:m,disabled:!1}})}function lue(e,t,n,r){let o=(r??new Qi(n)).format(e,"PPPP");return t.today&&(o=`Today, ${o}`),t.selected&&(o=`${o}, selected`),o}const YXe=lue;function cue(e,t,n){return(n??new Qi(t)).formatMonthYear(e)}const ZXe=cue;function XXe(e,t,n,r){let o=(r??new Qi(n)).format(e,"PPPP");return t!=null&&t.today&&(o=`Today, ${o}`),o}function QXe(e){return"Choose the Month"}function JXe(){return""}function eQe(e){return"Go to the Next Month"}function tQe(e){return"Go to the Previous Month"}function nQe(e,t,n){return(n??new Qi(t)).format(e,"cccc")}function rQe(e,t){return`Week ${e}`}function oQe(e){return"Week Number"}function sQe(e){return"Choose the Year"}const iQe=Object.freeze(Object.defineProperty({__proto__:null,labelCaption:ZXe,labelDay:YXe,labelDayButton:lue,labelGrid:cue,labelGridcell:XXe,labelMonthDropdown:QXe,labelNav:JXe,labelNext:eQe,labelPrevious:tQe,labelWeekNumber:rQe,labelWeekNumberHeader:oQe,labelWeekday:nQe,labelYearDropdown:sQe},Symbol.toStringTag,{value:"Module"})),Uw=e=>e instanceof HTMLElement?e:null,CM=e=>[...e.querySelectorAll("[data-animated-month]")??[]],aQe=e=>Uw(e.querySelector("[data-animated-month]")),SM=e=>Uw(e.querySelector("[data-animated-caption]")),NM=e=>Uw(e.querySelector("[data-animated-weeks]")),lQe=e=>Uw(e.querySelector("[data-animated-nav]")),cQe=e=>Uw(e.querySelector("[data-animated-weekdays]"));function uQe(e,t,{classNames:n,months:r,focused:o,dateLib:s}){const i=v.useRef(null),a=v.useRef(r),c=v.useRef(!1);v.useLayoutEffect(()=>{const u=a.current;if(a.current=r,!t||!e.current||!(e.current instanceof HTMLElement)||r.length===0||u.length===0||r.length!==u.length)return;const d=s.isSameMonth(r[0].date,u[0].date),f=s.isAfter(r[0].date,u[0].date),h=f?n[zi.caption_after_enter]:n[zi.caption_before_enter],m=f?n[zi.weeks_after_enter]:n[zi.weeks_before_enter],g=i.current,x=e.current.cloneNode(!0);if(x instanceof HTMLElement?(CM(x).forEach(C=>{if(!(C instanceof HTMLElement))return;const N=aQe(C);N&&C.contains(N)&&C.removeChild(N);const S=SM(C);S&&S.classList.remove(h);const j=NM(C);j&&j.classList.remove(m)}),i.current=x):i.current=null,c.current||d||o)return;const b=g instanceof HTMLElement?CM(g):[],y=CM(e.current);if(y!=null&&y.every(w=>w instanceof HTMLElement)&&b&&b.every(w=>w instanceof HTMLElement)){c.current=!0,e.current.style.isolation="isolate";const w=lQe(e.current);w&&(w.style.zIndex="1"),y.forEach((C,N)=>{const S=b[N];if(!S)return;C.style.position="relative",C.style.overflow="hidden";const j=SM(C);j&&j.classList.add(h);const I=NM(C);I&&I.classList.add(m);const k=()=>{c.current=!1,e.current&&(e.current.style.isolation=""),w&&(w.style.zIndex=""),j&&j.classList.remove(h),I&&I.classList.remove(m),C.style.position="",C.style.overflow="",C.contains(S)&&C.removeChild(S)};S.style.pointerEvents="none",S.style.position="absolute",S.style.overflow="hidden",S.setAttribute("aria-hidden","true");const T=cQe(S);T&&(T.style.opacity="0");const _=SM(S);_&&(_.classList.add(f?n[zi.caption_before_exit]:n[zi.caption_after_exit]),_.addEventListener("animationend",k));const E=NM(S);E&&E.classList.add(f?n[zi.weeks_before_exit]:n[zi.weeks_after_exit]),C.insertBefore(S,C.firstChild)})}})}function dQe(e,t,n,r){const o=e[0],s=e[e.length-1],{ISOWeek:i,fixedWeeks:a,broadcastCalendar:c}=n??{},{addDays:u,differenceInCalendarDays:d,differenceInCalendarMonths:f,endOfBroadcastWeek:h,endOfISOWeek:m,endOfMonth:g,endOfWeek:x,isAfter:b,startOfBroadcastWeek:y,startOfISOWeek:w,startOfWeek:C}=r,N=c?y(o,r):i?w(o):C(o),S=c?h(s):i?m(g(s)):x(g(s)),j=t&&(c?h(t):i?m(t):x(t)),I=j&&b(S,j)?j:S,k=d(I,N),T=f(s,o)+1,_=[];for(let M=0;M<=k;M++){const P=u(N,M);_.push(P)}const D=(c?35:42)*T;if(a&&_.length<D){const M=D-_.length;for(let P=0;P<M;P++){const A=u(_[_.length-1],1);_.push(A)}}return _}function fQe(e){const t=[];return e.reduce((n,r)=>{const o=r.weeks.reduce((s,i)=>s.concat(i.days.slice()),t.slice());return n.concat(o.slice())},t.slice())}function hQe(e,t,n,r){const{numberOfMonths:o=1}=n,s=[];for(let i=0;i<o;i++){const a=r.addMonths(e,i);if(t&&a>t)break;s.push(a)}return s}function sU(e,t,n,r){const{month:o,defaultMonth:s,today:i=r.today(),numberOfMonths:a=1}=e;let c=o||s||i;const{differenceInCalendarMonths:u,addMonths:d,startOfMonth:f}=r;if(n&&u(n,c)<a-1){const h=-1*(a-1);c=d(n,h)}return t&&u(c,t)<0&&(c=t),f(c)}function mQe(e,t,n,r){const{addDays:o,endOfBroadcastWeek:s,endOfISOWeek:i,endOfMonth:a,endOfWeek:c,getISOWeek:u,getWeek:d,startOfBroadcastWeek:f,startOfISOWeek:h,startOfWeek:m}=r,g=e.reduce((x,b)=>{const y=n.broadcastCalendar?f(b,r):n.ISOWeek?h(b):m(b),w=n.broadcastCalendar?s(b):n.ISOWeek?i(a(b)):c(a(b)),C=t.filter(I=>I>=y&&I<=w),N=n.broadcastCalendar?35:42;if(n.fixedWeeks&&C.length<N){const I=t.filter(k=>{const T=N-C.length;return k>w&&k<=o(w,T)});C.push(...I)}const S=C.reduce((I,k)=>{const T=n.ISOWeek?u(k):d(k),_=I.find(D=>D.weekNumber===T),E=new nue(k,b,r);return _?_.days.push(E):I.push(new oXe(T,[E])),I},[]),j=new rXe(b,S);return x.push(j),x},[]);return n.reverseMonths?g.reverse():g}function pQe(e,t){let{startMonth:n,endMonth:r}=e;const{startOfYear:o,startOfDay:s,startOfMonth:i,endOfMonth:a,addYears:c,endOfYear:u,newDate:d,today:f}=t,{fromYear:h,toYear:m,fromMonth:g,toMonth:x}=e;!n&&g&&(n=g),!n&&h&&(n=t.newDate(h,0,1)),!r&&x&&(r=x),!r&&m&&(r=d(m,11,31));const b=e.captionLayout==="dropdown"||e.captionLayout==="dropdown-years";return n?n=i(n):h?n=d(h,0,1):!n&&b&&(n=o(c(e.today??f(),-100))),r?r=a(r):m?r=d(m,11,31):!r&&b&&(r=u(e.today??f())),[n&&s(n),r&&s(r)]}function gQe(e,t,n,r){if(n.disableNavigation)return;const{pagedNavigation:o,numberOfMonths:s=1}=n,{startOfMonth:i,addMonths:a,differenceInCalendarMonths:c}=r,u=o?s:1,d=i(e);if(!t)return a(d,u);if(!(c(t,e)<s))return a(d,u)}function bQe(e,t,n,r){if(n.disableNavigation)return;const{pagedNavigation:o,numberOfMonths:s}=n,{startOfMonth:i,addMonths:a,differenceInCalendarMonths:c}=r,u=o?s??1:1,d=i(e);if(!t)return a(d,-u);if(!(c(d,t)<=0))return a(d,-u)}function xQe(e){const t=[];return e.reduce((n,r)=>n.concat(r.weeks.slice()),t.slice())}function U_(e,t){const[n,r]=v.useState(e);return[t===void 0?n:t,r]}function yQe(e,t){var N;const[n,r]=pQe(e,t),{startOfMonth:o,endOfMonth:s}=t,i=sU(e,n,r,t),[a,c]=U_(i,e.month?i:void 0);v.useEffect(()=>{const S=sU(e,n,r,t);c(S)},[e.timeZone]);const{months:u,weeks:d,days:f,previousMonth:h,nextMonth:m}=v.useMemo(()=>{const S=hQe(a,r,{numberOfMonths:e.numberOfMonths},t),j=dQe(S,e.endMonth?s(e.endMonth):void 0,{ISOWeek:e.ISOWeek,fixedWeeks:e.fixedWeeks,broadcastCalendar:e.broadcastCalendar},t),I=mQe(S,j,{broadcastCalendar:e.broadcastCalendar,fixedWeeks:e.fixedWeeks,ISOWeek:e.ISOWeek,reverseMonths:e.reverseMonths},t),k=xQe(I),T=fQe(I),_=bQe(a,n,e,t),E=gQe(a,r,e,t);return{months:I,weeks:k,days:T,previousMonth:_,nextMonth:E}},[t,a.getTime(),r==null?void 0:r.getTime(),n==null?void 0:n.getTime(),e.disableNavigation,e.broadcastCalendar,(N=e.endMonth)==null?void 0:N.getTime(),e.fixedWeeks,e.ISOWeek,e.numberOfMonths,e.pagedNavigation,e.reverseMonths]),{disableNavigation:g,onMonthChange:x}=e,b=S=>d.some(j=>j.days.some(I=>I.isEqualTo(S))),y=S=>{if(g)return;let j=o(S);n&&j<o(n)&&(j=o(n)),r&&j>o(r)&&(j=o(r)),c(j),x==null||x(j)};return{months:u,weeks:d,days:f,navStart:n,navEnd:r,previousMonth:h,nextMonth:m,goToMonth:y,goToDay:S=>{b(S)||y(S.date)}}}var Fl;(function(e){e[e.Today=0]="Today",e[e.Selected=1]="Selected",e[e.LastFocused=2]="LastFocused",e[e.FocusedModifier=3]="FocusedModifier"})(Fl||(Fl={}));function iU(e){return!e[Gr.disabled]&&!e[Gr.hidden]&&!e[Gr.outside]}function vQe(e,t,n,r){let o,s=-1;for(const i of e){const a=t(i);iU(a)&&(a[Gr.focused]&&s<Fl.FocusedModifier?(o=i,s=Fl.FocusedModifier):r!=null&&r.isEqualTo(i)&&s<Fl.LastFocused?(o=i,s=Fl.LastFocused):n(i.date)&&s<Fl.Selected?(o=i,s=Fl.Selected):a[Gr.today]&&s<Fl.Today&&(o=i,s=Fl.Today))}return o||(o=e.find(i=>iU(t(i)))),o}function wQe(e,t,n,r,o,s,i){const{ISOWeek:a,broadcastCalendar:c}=s,{addDays:u,addMonths:d,addWeeks:f,addYears:h,endOfBroadcastWeek:m,endOfISOWeek:g,endOfWeek:x,max:b,min:y,startOfBroadcastWeek:w,startOfISOWeek:C,startOfWeek:N}=i;let j={day:u,week:f,month:d,year:h,startOfWeek:I=>c?w(I,i):a?C(I):N(I),endOfWeek:I=>c?m(I):a?g(I):x(I)}[e](n,t==="after"?1:-1);return t==="before"&&r?j=b([r,j]):t==="after"&&o&&(j=y([o,j])),j}function uue(e,t,n,r,o,s,i,a=0){if(a>365)return;const c=wQe(e,t,n.date,r,o,s,i),u=!!(s.disabled&&su(c,s.disabled,i)),d=!!(s.hidden&&su(c,s.hidden,i)),f=c,h=new nue(c,f,i);return!u&&!d?h:uue(e,t,h,r,o,s,i,a+1)}function CQe(e,t,n,r,o){const{autoFocus:s}=e,[i,a]=v.useState(),c=vQe(t.days,n,r||(()=>!1),i),[u,d]=v.useState(s?c:void 0);return{isFocusTarget:x=>!!(c!=null&&c.isEqualTo(x)),setFocused:d,focused:u,blur:()=>{a(u),d(void 0)},moveFocus:(x,b)=>{if(!u)return;const y=uue(x,b,u,t.navStart,t.navEnd,e,o);y&&(e.disableNavigation&&!t.days.some(C=>C.isEqualTo(y))||(t.goToDay(y),d(y)))}}}function SQe(e,t){const{selected:n,required:r,onSelect:o}=e,[s,i]=U_(n,o?n:void 0),a=o?n:s,{isSameDay:c}=t,u=m=>(a==null?void 0:a.some(g=>c(g,m)))??!1,{min:d,max:f}=e;return{selected:a,select:(m,g,x)=>{let b=[...a??[]];if(u(m)){if((a==null?void 0:a.length)===d||r&&(a==null?void 0:a.length)===1)return;b=a==null?void 0:a.filter(y=>!c(y,m))}else(a==null?void 0:a.length)===f?b=[m]:b=[...b,m];return o||i(b),o==null||o(b,m,g,x),b},isSelected:u}}function NQe(e,t,n=0,r=0,o=!1,s=wc){const{from:i,to:a}=t||{},{isSameDay:c,isAfter:u,isBefore:d}=s;let f;if(!i&&!a)f={from:e,to:n>0?void 0:e};else if(i&&!a)c(i,e)?n===0?f={from:i,to:e}:o?f={from:i,to:void 0}:f=void 0:d(e,i)?f={from:e,to:i}:f={from:i,to:e};else if(i&&a)if(c(i,e)&&c(a,e))o?f={from:i,to:a}:f=void 0;else if(c(i,e))f={from:i,to:n>0?void 0:e};else if(c(a,e))f={from:e,to:n>0?void 0:e};else if(d(e,i))f={from:e,to:a};else if(u(e,i))f={from:i,to:e};else if(u(e,a))f={from:i,to:e};else throw new Error("Invalid range");if(f!=null&&f.from&&(f!=null&&f.to)){const h=s.differenceInCalendarDays(f.to,f.from);r>0&&h>r?f={from:e,to:void 0}:n>1&&h<n&&(f={from:e,to:void 0})}return f}function jQe(e,t,n=wc){const r=Array.isArray(t)?t:[t];let o=e.from;const s=n.differenceInCalendarDays(e.to,e.from),i=Math.min(s,6);for(let a=0;a<=i;a++){if(r.includes(o.getDay()))return!0;o=n.addDays(o,1)}return!1}function aU(e,t,n=wc){return ou(e,t.from,!1,n)||ou(e,t.to,!1,n)||ou(t,e.from,!1,n)||ou(t,e.to,!1,n)}function kQe(e,t,n=wc){const r=Array.isArray(t)?t:[t];if(r.filter(a=>typeof a!="function").some(a=>typeof a=="boolean"?a:n.isDate(a)?ou(e,a,!1,n):sue(a,n)?a.some(c=>ou(e,c,!1,n)):q_(a)?a.from&&a.to?aU(e,{from:a.from,to:a.to},n):!1:oue(a)?jQe(e,a.dayOfWeek,n):P$(a)?n.isAfter(a.before,a.after)?aU(e,{from:n.addDays(a.after,1),to:n.addDays(a.before,-1)},n):su(e.from,a,n)||su(e.to,a,n):F$(a)||O$(a)?su(e.from,a,n)||su(e.to,a,n):!1))return!0;const i=r.filter(a=>typeof a=="function");if(i.length){let a=e.from;const c=n.differenceInCalendarDays(e.to,e.from);for(let u=0;u<=c;u++){if(i.some(d=>d(a)))return!0;a=n.addDays(a,1)}}return!1}function IQe(e,t){const{disabled:n,excludeDisabled:r,selected:o,required:s,onSelect:i}=e,[a,c]=U_(o,i?o:void 0),u=i?o:a;return{selected:u,select:(h,m,g)=>{const{min:x,max:b}=e,y=h?NQe(h,u,x,b,s,t):void 0;return r&&n&&(y!=null&&y.from)&&y.to&&kQe({from:y.from,to:y.to},n,t)&&(y.from=h,y.to=void 0),i||c(y),i==null||i(y,h,m,g),y},isSelected:h=>u&&ou(u,h,!1,t)}}function _Qe(e,t){const{selected:n,required:r,onSelect:o}=e,[s,i]=U_(n,o?n:void 0),a=o?n:s,{isSameDay:c}=t;return{selected:a,select:(f,h,m)=>{let g=f;return!r&&a&&a&&c(f,a)&&(g=void 0),o||i(g),o==null||o(g,f,h,m),g},isSelected:f=>a?c(a,f):!1}}function TQe(e,t){const n=_Qe(e,t),r=SQe(e,t),o=IQe(e,t);switch(e.mode){case"single":return n;case"multiple":return r;case"range":return o;default:return}}function rs(e,t){return e instanceof ru&&e.timeZone===t?e:new ru(e,t)}function lU(e,t){return typeof e=="boolean"||typeof e=="function"?e:e instanceof Date?rs(e,t):Array.isArray(e)?e.map(n=>n instanceof Date?rs(n,t):n):q_(e)?{...e,from:e.from?rs(e.from,t):e.from,to:e.to?rs(e.to,t):e.to}:P$(e)?{before:rs(e.before,t),after:rs(e.after,t)}:F$(e)?{after:rs(e.after,t)}:O$(e)?{before:rs(e.before,t)}:e}function jM(e,t){return e&&(Array.isArray(e)?e.map(n=>lU(n,t)):lU(e,t))}function EQe(e){var et;let t=e;const n=t.timeZone;if(n&&(t={...e,timeZone:n},t.today&&(t.today=rs(t.today,n)),t.month&&(t.month=rs(t.month,n)),t.defaultMonth&&(t.defaultMonth=rs(t.defaultMonth,n)),t.startMonth&&(t.startMonth=rs(t.startMonth,n)),t.endMonth&&(t.endMonth=rs(t.endMonth,n)),t.mode==="single"&&t.selected?t.selected=rs(t.selected,n):t.mode==="multiple"&&t.selected?t.selected=(et=t.selected)==null?void 0:et.map(ye=>rs(ye,n)):t.mode==="range"&&t.selected&&(t.selected={from:t.selected.from?rs(t.selected.from,n):t.selected.from,to:t.selected.to?rs(t.selected.to,n):t.selected.to}),t.disabled!==void 0&&(t.disabled=jM(t.disabled,n)),t.hidden!==void 0&&(t.hidden=jM(t.hidden,n)),t.modifiers)){const ye={};Object.keys(t.modifiers).forEach(He=>{var Pe;ye[He]=jM((Pe=t.modifiers)==null?void 0:Pe[He],n)}),t.modifiers=ye}const{components:r,formatters:o,labels:s,dateLib:i,locale:a,classNames:c}=v.useMemo(()=>{const ye={...A$,...t.locale};return{dateLib:new Qi({locale:ye,weekStartsOn:t.broadcastCalendar?1:t.weekStartsOn,firstWeekContainsDate:t.firstWeekContainsDate,useAdditionalWeekYearTokens:t.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:t.useAdditionalDayOfYearTokens,timeZone:t.timeZone,numerals:t.numerals},t.dateLib),components:AXe(t.components),formatters:qXe(t.formatters),labels:{...iQe,...t.labels},locale:ye,classNames:{...L$(),...t.classNames}}},[t.locale,t.broadcastCalendar,t.weekStartsOn,t.firstWeekContainsDate,t.useAdditionalWeekYearTokens,t.useAdditionalDayOfYearTokens,t.timeZone,t.numerals,t.dateLib,t.components,t.formatters,t.labels,t.classNames]);t.today||(t={...t,today:i.today()});const{captionLayout:u,mode:d,navLayout:f,numberOfMonths:h=1,onDayBlur:m,onDayClick:g,onDayFocus:x,onDayKeyDown:b,onDayMouseEnter:y,onDayMouseLeave:w,onNextClick:C,onPrevClick:N,showWeekNumber:S,styles:j}=t,{formatCaption:I,formatDay:k,formatMonthDropdown:T,formatWeekNumber:_,formatWeekNumberHeader:E,formatWeekdayName:D,formatYearDropdown:M}=o,P=yQe(t,i),{days:A,months:L,navStart:O,navEnd:B,previousMonth:H,nextMonth:R,goToMonth:V}=P,z=MXe(A,t,O,B,i),{isSelected:F,select:G,selected:q}=TQe(t,i)??{},{blur:Y,focused:K,isFocusTarget:$,moveFocus:X,setFocused:W}=CQe(t,P,z,F??(()=>!1),i),{labelDayButton:U,labelGridcell:Z,labelGrid:Q,labelMonthDropdown:J,labelNav:re,labelPrevious:de,labelNext:le,labelWeekday:ce,labelWeekNumber:oe,labelWeekNumberHeader:fe,labelYearDropdown:we}=s,pe=v.useMemo(()=>KXe(i,t.ISOWeek,t.broadcastCalendar,t.today),[i,t.ISOWeek,t.broadcastCalendar,t.today]),ne=d!==void 0||g!==void 0,Se=v.useCallback(()=>{H&&(V(H),N==null||N(H))},[H,V,N]),ue=v.useCallback(()=>{R&&(V(R),C==null||C(R))},[V,R,C]),ie=v.useCallback((ye,He)=>Pe=>{Pe.preventDefault(),Pe.stopPropagation(),W(ye),!He.disabled&&(G==null||G(ye.date,He,Pe),g==null||g(ye.date,He,Pe))},[G,g,W]),ee=v.useCallback((ye,He)=>Pe=>{W(ye),x==null||x(ye.date,He,Pe)},[x,W]),ae=v.useCallback((ye,He)=>Pe=>{Y(),m==null||m(ye.date,He,Pe)},[Y,m]),se=v.useCallback((ye,He)=>Pe=>{const _e={ArrowLeft:[Pe.shiftKey?"month":"day",t.dir==="rtl"?"after":"before"],ArrowRight:[Pe.shiftKey?"month":"day",t.dir==="rtl"?"before":"after"],ArrowDown:[Pe.shiftKey?"year":"week","after"],ArrowUp:[Pe.shiftKey?"year":"week","before"],PageUp:[Pe.shiftKey?"year":"month","before"],PageDown:[Pe.shiftKey?"year":"month","after"],Home:["startOfWeek","before"],End:["endOfWeek","after"]};if(_e[Pe.key]){Pe.preventDefault(),Pe.stopPropagation();const[ze,Ee]=_e[Pe.key];X(ze,Ee)}b==null||b(ye.date,He,Pe)},[X,b,t.dir]),he=v.useCallback((ye,He)=>Pe=>{y==null||y(ye.date,He,Pe)},[y]),ge=v.useCallback((ye,He)=>Pe=>{w==null||w(ye.date,He,Pe)},[w]),ke=v.useCallback(ye=>He=>{const Pe=Number(He.target.value),_e=i.setMonth(i.startOfMonth(ye),Pe);V(_e)},[i,V]),De=v.useCallback(ye=>He=>{const Pe=Number(He.target.value),_e=i.setYear(i.startOfMonth(ye),Pe);V(_e)},[i,V]),{className:Re,style:Ve}=v.useMemo(()=>({className:[c[qt.Root],t.className].filter(Boolean).join(" "),style:{...j==null?void 0:j[qt.Root],...t.style}}),[c,t.className,t.style,j]),ve=PXe(t),Ke=v.useRef(null);uQe(Ke,!!t.animate,{classNames:c,months:L,focused:K,dateLib:i});const qe={dayPickerProps:t,selected:q,select:G,isSelected:F,months:L,nextMonth:R,previousMonth:H,goToMonth:V,getModifiers:z,components:r,classNames:c,styles:j,labels:s,formatters:o};return v.createElement(rue.Provider,{value:qe},v.createElement(r.Root,{rootRef:t.animate?Ke:void 0,className:Re,style:Ve,dir:t.dir,id:t.id,lang:t.lang,nonce:t.nonce,title:t.title,role:t.role,"aria-label":t["aria-label"],"aria-labelledby":t["aria-labelledby"],...ve},v.createElement(r.Months,{className:c[qt.Months],style:j==null?void 0:j[qt.Months]},!t.hideNavigation&&!f&&v.createElement(r.Nav,{"data-animated-nav":t.animate?"true":void 0,className:c[qt.Nav],style:j==null?void 0:j[qt.Nav],"aria-label":re(),onPreviousClick:Se,onNextClick:ue,previousMonth:H,nextMonth:R}),L.map((ye,He)=>v.createElement(r.Month,{"data-animated-month":t.animate?"true":void 0,className:c[qt.Month],style:j==null?void 0:j[qt.Month],key:He,displayIndex:He,calendarMonth:ye},f==="around"&&!t.hideNavigation&&He===0&&v.createElement(r.PreviousMonthButton,{type:"button",className:c[qt.PreviousMonthButton],tabIndex:H?void 0:-1,"aria-disabled":H?void 0:!0,"aria-label":de(H),onClick:Se,"data-animated-button":t.animate?"true":void 0},v.createElement(r.Chevron,{disabled:H?void 0:!0,className:c[qt.Chevron],orientation:t.dir==="rtl"?"right":"left"})),v.createElement(r.MonthCaption,{"data-animated-caption":t.animate?"true":void 0,className:c[qt.MonthCaption],style:j==null?void 0:j[qt.MonthCaption],calendarMonth:ye,displayIndex:He},u!=null&&u.startsWith("dropdown")?v.createElement(r.DropdownNav,{className:c[qt.Dropdowns],style:j==null?void 0:j[qt.Dropdowns]},(()=>{const Pe=u==="dropdown"||u==="dropdown-months"?v.createElement(r.MonthsDropdown,{key:"month",className:c[qt.MonthsDropdown],"aria-label":J(),classNames:c,components:r,disabled:!!t.disableNavigation,onChange:ke(ye.date),options:UXe(ye.date,O,B,o,i),style:j==null?void 0:j[qt.Dropdown],value:i.getMonth(ye.date)}):v.createElement("span",{key:"month"},T(ye.date,i)),_e=u==="dropdown"||u==="dropdown-years"?v.createElement(r.YearsDropdown,{key:"year",className:c[qt.YearsDropdown],"aria-label":we(i.options),classNames:c,components:r,disabled:!!t.disableNavigation,onChange:De(ye.date),options:GXe(O,B,o,i,!!t.reverseYears),style:j==null?void 0:j[qt.Dropdown],value:i.getYear(ye.date)}):v.createElement("span",{key:"year"},M(ye.date,i));return i.getMonthYearOrder()==="year-first"?[_e,Pe]:[Pe,_e]})(),v.createElement("span",{role:"status","aria-live":"polite",style:{border:0,clip:"rect(0 0 0 0)",height:"1px",margin:"-1px",overflow:"hidden",padding:0,position:"absolute",width:"1px",whiteSpace:"nowrap",wordWrap:"normal"}},I(ye.date,i.options,i))):v.createElement(r.CaptionLabel,{className:c[qt.CaptionLabel],role:"status","aria-live":"polite"},I(ye.date,i.options,i))),f==="around"&&!t.hideNavigation&&He===h-1&&v.createElement(r.NextMonthButton,{type:"button",className:c[qt.NextMonthButton],tabIndex:R?void 0:-1,"aria-disabled":R?void 0:!0,"aria-label":le(R),onClick:ue,"data-animated-button":t.animate?"true":void 0},v.createElement(r.Chevron,{disabled:R?void 0:!0,className:c[qt.Chevron],orientation:t.dir==="rtl"?"left":"right"})),He===h-1&&f==="after"&&!t.hideNavigation&&v.createElement(r.Nav,{"data-animated-nav":t.animate?"true":void 0,className:c[qt.Nav],style:j==null?void 0:j[qt.Nav],"aria-label":re(),onPreviousClick:Se,onNextClick:ue,previousMonth:H,nextMonth:R}),v.createElement(r.MonthGrid,{role:"grid","aria-multiselectable":d==="multiple"||d==="range","aria-label":Q(ye.date,i.options,i)||void 0,className:c[qt.MonthGrid],style:j==null?void 0:j[qt.MonthGrid]},!t.hideWeekdays&&v.createElement(r.Weekdays,{"data-animated-weekdays":t.animate?"true":void 0,className:c[qt.Weekdays],style:j==null?void 0:j[qt.Weekdays]},S&&v.createElement(r.WeekNumberHeader,{"aria-label":fe(i.options),className:c[qt.WeekNumberHeader],style:j==null?void 0:j[qt.WeekNumberHeader],scope:"col"},E()),pe.map(Pe=>v.createElement(r.Weekday,{"aria-label":ce(Pe,i.options,i),className:c[qt.Weekday],key:String(Pe),style:j==null?void 0:j[qt.Weekday],scope:"col"},D(Pe,i.options,i)))),v.createElement(r.Weeks,{"data-animated-weeks":t.animate?"true":void 0,className:c[qt.Weeks],style:j==null?void 0:j[qt.Weeks]},ye.weeks.map(Pe=>v.createElement(r.Week,{className:c[qt.Week],key:Pe.weekNumber,style:j==null?void 0:j[qt.Week],week:Pe},S&&v.createElement(r.WeekNumber,{week:Pe,style:j==null?void 0:j[qt.WeekNumber],"aria-label":oe(Pe.weekNumber,{locale:a}),className:c[qt.WeekNumber],scope:"row",role:"rowheader"},_(Pe.weekNumber,i)),Pe.days.map(_e=>{const{date:ze}=_e,Ee=z(_e);if(Ee[Gr.focused]=!Ee.hidden&&!!(K!=null&&K.isEqualTo(_e)),Ee[Ya.selected]=(F==null?void 0:F(ze))||Ee.selected,q_(q)){const{from:rt,to:wt}=q;Ee[Ya.range_start]=!!(rt&&wt&&i.isSameDay(ze,rt)),Ee[Ya.range_end]=!!(rt&&wt&&i.isSameDay(ze,wt)),Ee[Ya.range_middle]=ou(q,ze,!0,i)}const Be=WXe(Ee,j,t.modifiersStyles),st=RXe(Ee,c,t.modifiersClassNames),lt=!ne&&!Ee.hidden?Z(ze,Ee,i.options,i):void 0;return v.createElement(r.Day,{key:`${_e.isoDate}_${_e.displayMonthId}`,day:_e,modifiers:Ee,className:st.join(" "),style:Be,role:"gridcell","aria-selected":Ee.selected||void 0,"aria-label":lt,"data-day":_e.isoDate,"data-month":_e.outside?_e.dateMonthId:void 0,"data-selected":Ee.selected||void 0,"data-disabled":Ee.disabled||void 0,"data-hidden":Ee.hidden||void 0,"data-outside":_e.outside||void 0,"data-focused":Ee.focused||void 0,"data-today":Ee.today||void 0},!Ee.hidden&&ne?v.createElement(r.DayButton,{className:c[qt.DayButton],style:j==null?void 0:j[qt.DayButton],type:"button",day:_e,modifiers:Ee,disabled:!Ee.focused&&Ee.disabled||void 0,"aria-disabled":Ee.focused&&Ee.disabled||void 0,tabIndex:$(_e)?0:-1,"aria-label":U(ze,Ee,i.options,i),onClick:ie(_e,Ee),onBlur:ae(_e,Ee),onFocus:ee(_e,Ee),onKeyDown:se(_e,Ee),onMouseEnter:he(_e,Ee),onMouseLeave:ge(_e,Ee)},k(ze,i.options,i)):!Ee.hidden&&k(_e.date,i.options,i))})))))))),t.footer&&v.createElement(r.Footer,{className:c[qt.Footer],style:j==null?void 0:j[qt.Footer],role:"status","aria-live":"polite"},t.footer)))}function Z1({className:e,classNames:t,showOutsideDays:n=!0,captionLayout:r="label",buttonVariant:o="ghost",formatters:s,components:i,...a}){const c=L$();return l.jsx(EQe,{showOutsideDays:n,className:p.cn("bg-background group/calendar p-2.5 [--cell-size:1.75rem] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent",String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,e),captionLayout:r,formatters:{formatMonthDropdown:u=>u.toLocaleString("default",{month:"short"}),...s},classNames:{root:p.cn("w-fit",c.root),months:p.cn("relative flex flex-col gap-3 md:flex-row",c.months),month:p.cn("flex w-full flex-col gap-3",c.month),nav:p.cn("absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1",c.nav),button_previous:p.cn(p.buttonVariants({variant:o}),"h-[--cell-size] w-[--cell-size] select-none p-0 text-muted-foreground hover:text-foreground aria-disabled:opacity-50",c.button_previous),button_next:p.cn(p.buttonVariants({variant:o}),"h-[--cell-size] w-[--cell-size] select-none p-0 text-muted-foreground hover:text-foreground aria-disabled:opacity-50",c.button_next),month_caption:p.cn("flex h-[--cell-size] w-full items-center justify-center px-[--cell-size]",c.month_caption),dropdowns:p.cn("flex h-[--cell-size] w-full items-center justify-center gap-1.5 text-[13px] font-medium",c.dropdowns),dropdown_root:p.cn("has-focus:border-ring border-input has-focus:ring-ring/40 has-focus:ring-[2px] relative rounded-md border",c.dropdown_root),dropdown:p.cn("bg-popover absolute inset-0 opacity-0",c.dropdown),caption_label:p.cn("select-none font-medium text-foreground",r==="label"?"text-[13px]":"[&>svg]:text-muted-foreground flex h-7 items-center gap-1 rounded-md pl-2 pr-1 text-[13px] [&>svg]:size-3",c.caption_label),table:"w-full border-collapse",weekdays:p.cn("flex",c.weekdays),weekday:p.cn("text-muted-foreground flex-1 select-none text-[10px] font-medium uppercase tracking-[0.08em]",c.weekday),week:p.cn("mt-1 flex w-full",c.week),week_number_header:p.cn("w-[--cell-size] select-none",c.week_number_header),week_number:p.cn("text-muted-foreground select-none text-[10px]",c.week_number),day:p.cn("group/day relative aspect-square h-full w-full select-none p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md",c.day),range_start:p.cn("bg-accent rounded-l-md",c.range_start),range_middle:p.cn("rounded-none",c.range_middle),range_end:p.cn("bg-accent rounded-r-md",c.range_end),today:p.cn("rounded-md text-foreground font-medium [&>button]:ring-1 [&>button]:ring-inset [&>button]:ring-border",c.today),outside:p.cn("text-muted-foreground/60 aria-selected:text-muted-foreground/60",c.outside),disabled:p.cn("text-muted-foreground/50",c.disabled),hidden:p.cn("invisible",c.hidden),...t},components:{Root:({className:u,rootRef:d,...f})=>l.jsx("div",{"data-slot":"calendar",ref:d,className:p.cn(u),...f}),Chevron:({className:u,orientation:d,...f})=>d==="left"?l.jsx(Lm,{className:p.cn("size-4",u),...f}):d==="right"?l.jsx(Mt.ChevronRight,{className:p.cn("size-4",u),...f}):l.jsx(Ie.ChevronDown,{className:p.cn("size-4",u),...f}),DayButton:DQe,WeekNumber:({children:u,...d})=>l.jsx("td",{...d,children:l.jsx("div",{className:"flex size-[--cell-size] items-center justify-center text-center",children:u})}),...i},...a})}function DQe({className:e,day:t,modifiers:n,...r}){const o=L$(),s=te.useRef(null);return te.useEffect(()=>{var i;n.focused&&((i=s.current)==null||i.focus())},[n.focused]),l.jsx(p.Button,{ref:s,variant:"ghost",size:"icon","data-day":t.date.toLocaleDateString(),"data-selected-single":n.selected&&!n.range_start&&!n.range_end&&!n.range_middle,"data-range-start":n.range_start,"data-range-end":n.range_end,"data-range-middle":n.range_middle,className:p.cn("data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/40 flex aspect-square h-auto w-full min-w-[--cell-size] flex-col gap-0.5 rounded-md p-0 text-[12px] font-normal leading-none tabular-nums data-[range-end=true]:rounded-r-md data-[range-end=true]:rounded-l-none data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-l-md data-[range-start=true]:rounded-r-none group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[2px] [&>span]:text-[10px] [&>span]:opacity-70",o.day,e),...r})}const MQe={time:"Time",day:"Day",week:"Week",month:"Month",quarter:"Quarter",year:"Year"},cU=(e,t)=>!e||e.mode==="this"&&e.boundary?"day":e.unit==="minute"||e.unit==="hour"?t?"time":"day":e.unit,RQe=["Last 30 minutes","Last 1 hour","Last 4 hours","Last 12 hours","Last 24 hours"],AQe=(e=!1)=>{const t=[{label:"Today",value:n=>{const r=new Date;return{from:p.startOfDayInTimezone(r,n),to:p.endOfDayInTimezone(r,n)}},category:"day"},{label:"Yesterday",value:n=>{const r=new Date,o=p.shiftDateByDaysInTimezone(r,n,-1);return{from:p.startOfDayInTimezone(o,n),to:p.endOfDayInTimezone(o,n)}},category:"day"},{label:"First day of the month",value:n=>{const r=new Date,o=p.startOfMonthInTimezone(r,n);return{from:p.startOfDayInTimezone(o,n),to:p.endOfDayInTimezone(o,n)}},category:"day"},{label:"Last day of the month",value:n=>{const r=new Date,o=p.endOfMonthInTimezone(r,n);return{from:p.startOfDayInTimezone(o,n),to:p.endOfDayInTimezone(o,n)}},category:"day"},{label:"Last 7 days",value:n=>{const r=new Date,o=p.shiftDateByDaysInTimezone(r,n,-6);return{from:p.startOfDayInTimezone(o,n),to:p.endOfDayInTimezone(r,n)}},category:"day"},{label:"Last 30 days",value:n=>{const r=new Date,o=p.shiftDateByDaysInTimezone(r,n,-29);return{from:p.startOfDayInTimezone(o,n),to:p.endOfDayInTimezone(r,n)}},category:"day"},{label:"Last 90 days",value:n=>{const r=new Date,o=p.shiftDateByDaysInTimezone(r,n,-89);return{from:p.startOfDayInTimezone(o,n),to:p.endOfDayInTimezone(r,n)}},category:"day"},{label:"This week",value:n=>{const r=new Date,o=p.startOfWeekInTimezone(r,n),s=p.endOfWeekInTimezone(r,n);return{from:o,to:s}},category:"week"},{label:"Last week",value:n=>{const r=new Date,o=p.shiftDateByWeeksInTimezone(r,n,-1),s=p.startOfWeekInTimezone(o,n),i=p.endOfWeekInTimezone(o,n);return{from:s,to:i}},category:"week"},{label:"Last 2 weeks",value:n=>{const r=new Date,o=p.shiftDateByWeeksInTimezone(r,n,-2),s=p.shiftDateByWeeksInTimezone(r,n,-1);return{from:p.startOfWeekInTimezone(o,n),to:p.endOfWeekInTimezone(s,n)}},category:"week"},{label:"This month",value:n=>{const r=new Date,o=p.startOfMonthInTimezone(r,n),s=p.endOfMonthInTimezone(r,n);return{from:o,to:s}},category:"month"},{label:"Last month",value:n=>{const r=new Date,o=p.shiftDateByMonthsInTimezone(r,n,-1),s=p.startOfMonthInTimezone(o,n),i=p.endOfMonthInTimezone(o,n);return{from:s,to:i}},category:"month"},{label:"Last 3 months",value:n=>{const r=new Date,o=p.shiftDateByMonthsInTimezone(r,n,-3),s=p.shiftDateByMonthsInTimezone(r,n,-1);return{from:p.startOfMonthInTimezone(o,n),to:p.endOfMonthInTimezone(s,n)}},category:"month"},{label:"Last 6 months",value:n=>{const r=new Date,o=p.shiftDateByMonthsInTimezone(r,n,-6),s=p.shiftDateByMonthsInTimezone(r,n,-1);return{from:p.startOfMonthInTimezone(o,n),to:p.endOfMonthInTimezone(s,n)}},category:"month"},{label:"Last 9 months",value:n=>{const r=new Date,o=p.shiftDateByMonthsInTimezone(r,n,-9),s=p.shiftDateByMonthsInTimezone(r,n,-1);return{from:p.startOfMonthInTimezone(o,n),to:p.endOfMonthInTimezone(s,n)}},category:"month"},{label:"Last 12 months",value:n=>{const r=new Date,o=p.shiftDateByMonthsInTimezone(r,n,-12),s=p.shiftDateByMonthsInTimezone(r,n,-1);return{from:p.startOfMonthInTimezone(o,n),to:p.endOfMonthInTimezone(s,n)}},category:"month"},{label:"This quarter",value:n=>{const r=new Date,o=p.startOfQuarterInTimezone(r,n),s=p.endOfQuarterInTimezone(r,n);return{from:o,to:s}},category:"quarter"},{label:"Last quarter",value:n=>{const r=new Date,o=p.shiftDateByQuartersInTimezone(r,n,-1),s=p.startOfQuarterInTimezone(o,n),i=p.endOfQuarterInTimezone(o,n);return{from:s,to:i}},category:"quarter"},{label:"Last 4 quarters",value:n=>{const r=new Date,o=p.shiftDateByQuartersInTimezone(r,n,-4),s=p.shiftDateByQuartersInTimezone(r,n,-1);return{from:p.startOfQuarterInTimezone(o,n),to:p.endOfQuarterInTimezone(s,n)}},category:"quarter"},{label:"This year",value:n=>{const r=new Date,o=p.startOfYearInTimezone(r,n),s=p.endOfYearInTimezone(r,n);return{from:o,to:s}},category:"year"},{label:"Last year",value:n=>{const r=new Date,o=p.shiftDateByYearsInTimezone(r,n,-1),s=p.startOfYearInTimezone(o,n),i=p.endOfYearInTimezone(o,n);return{from:s,to:i}},category:"year"}];return e?[...RQe.map(n=>({label:n,value:()=>{const r=p.presetMetadata[n],o=p.resolveSubDayRelativeDateRange(r);return o?{from:o[0],to:o[1]}:{from:new Date,to:new Date}},category:"time"})),...t]:t},uU=[{label:"2 days ago",value:-2},{label:"Yesterday",value:-1},{label:"Today",value:0},{label:"Tomorrow",value:1},{label:"2 days ahead",value:2}],dU=[{label:"2 years ago",value:-2},{label:"Last year",value:-1},{label:"This year",value:0},{label:"Next year",value:1},{label:"2 years ahead",value:2}],fU=[{label:"2 quarters ago",value:-2},{label:"Last quarter",value:-1},{label:"This quarter",value:0},{label:"Next quarter",value:1},{label:"2 quarters ahead",value:2}],hU=[{label:"9 months ago",value:-9},{label:"6 months ago",value:-6},{label:"3 months ago",value:-3},{label:"2 months ago",value:-2},{label:"Last month",value:-1},{label:"This month",value:0},{label:"Next month",value:1},{label:"2 months ahead",value:2}],mU=[{label:"2 weeks ago",value:-2},{label:"Last week",value:-1},{label:"This week",value:0},{label:"Next week",value:1},{label:"2 weeks ahead",value:2}];function $$({value:e,onChange:t,selectionMode:n="range",singleValue:r,onSingleChange:o,comparisonOptions:s,comparisonValue:i,onComparisonChange:a,comparisonLabel:c="Condition",hideDateInputs:u=!1,onRelativeSelect:d,relativeValue:f,placeholder:h="All time",className:m,timezone:g,showRelativeTab:x=!0,hideCalendar:b=!1,disabled:y=!1,enableTimePrecision:w=!1,temporalPrecision:C,buttonClassName:N,buttonLabelSuffix:S,contentClassName:j,overlayContentClassName:I,targetColumns:k,selectedColumn:T,onColumnChange:_,inline:E=!1,onApplied:D,supplementalFooter:M,onOpenChange:P}){var St,At;const[A,L]=v.useState(!1),[O,B]=v.useState(n==="range"?"presets":"static"),[H,R]=v.useState(()=>cU(f,w)),[V,z]=v.useState(!1),[F,G]=v.useState(!1),[q,Y]=v.useState("Days"),[K,$]=v.useState("0"),[X,W]=v.useState("0"),[U,Z]=v.useState(w&&C==="minute"),[Q,J]=v.useState("00:00"),[re,de]=v.useState("23:59"),[le,ce]=v.useState("00:00"),[oe,fe]=v.useState(E?e:void 0),[we,pe]=v.useState(E?r:void 0),ne=ml("interactive"),Se=ne.controlStyle,ue=ne.contentStyle;v.useEffect(()=>{E&&fe(e)},[E,e]),v.useEffect(()=>{E&&pe(r)},[E,r]);const ie=p.getEffectiveTimezone(g),ee=w&&C==="minute",ae=v.useMemo(()=>AQe(w),[w]),se=v.useMemo(()=>[...w?["time"]:[],"day","week","month","quarter","year"],[w]),he=v.useMemo(()=>ae.filter(Fe=>Fe.category===H),[H,ae]),ge=cU(f,w),ke=x&&n==="range",De=n==="range";v.useEffect(()=>{R(ge)},[ge]),v.useEffect(()=>{const Fe=w&&C==="minute";Z(Fe),Fe?(e!=null&&e.from&&J(p.formatTimeInTimezone(e.from,ie)),e!=null&&e.to&&de(p.formatTimeInTimezone(e.to,ie)),r&&ce(p.formatTimeInTimezone(r,ie))):(J("00:00"),de("23:59"),ce("00:00"))},[ie,w,r,C,e==null?void 0:e.from,e==null?void 0:e.to]),v.useEffect(()=>{if(!De&&O!=="static"){B("static");return}!ke&&O==="relative"&&B("static")},[ke,De,O]);const Re=()=>{if(n==="single")return r?Vt.formatInTimeZone(r,ie,ee?"MMM dd, yyyy HH:mm":"MMM dd, yyyy"):h;if(e!=null&&e.from&&(e!=null&&e.to)){const Fe=Vt.formatInTimeZone(e.from,ie,ee?"MMM dd, yyyy HH:mm":"MMM dd, yyyy"),Je=Vt.formatInTimeZone(e.to,ie,ee?"MMM dd, yyyy HH:mm":"MMM dd, yyyy");return`${Fe} - ${Je}`}return h},Ve=n==="single"?!!r:!!(e!=null&&e.from||e!=null&&e.to),ve=!!(k&&k.length>1&&_),Ke=((St=k==null?void 0:k.find(Fe=>Fe.column===T))==null?void 0:St.label)||((At=k==null?void 0:k[0])==null?void 0:At.label)||"Date",qe=Fe=>{const Je=Fe.value(ie),Ct=p.presetMetadata[Fe.label],dt=w?p.getTemporalPrecisionForRelativeMeta(Ct):void 0,kt=dt?{temporalPrecision:dt}:void 0;t==null||t(Je,kt),ke&&(d==null||d(Je,Ct,kt)),rt(!1)},et=(Fe,Je)=>{var Rt,yt;const Ct=se.indexOf(Je);let dt;if(Fe.key==="ArrowRight"||Fe.key==="ArrowDown"?dt=(Ct+1)%se.length:Fe.key==="ArrowLeft"||Fe.key==="ArrowUp"?dt=(Ct-1+se.length)%se.length:Fe.key==="Home"?dt=0:Fe.key==="End"&&(dt=se.length-1),dt===void 0)return;Fe.preventDefault();const kt=se[dt];R(kt);const Ft=(Rt=Fe.currentTarget.parentElement)==null?void 0:Rt.querySelectorAll('[role="radio"]');(yt=Ft==null?void 0:Ft[dt])==null||yt.focus()},ye=()=>{n==="single"?o==null||o(void 0):t==null||t(void 0),rt(!1)},He=(Fe,Je)=>{if(!Je)return;const Ct=Fe==="from"?Je:oe==null?void 0:oe.from,dt=Fe==="to"?Je:oe==null?void 0:oe.to;fe({from:Ct,to:dt}),Fe==="from"?z(!1):G(!1)},Pe=Fe=>{const Je=Fe===!0;if(Z(Je),!Je){J("00:00"),de("23:59"),ce("00:00");return}oe!=null&&oe.from&&J(p.formatTimeInTimezone(oe.from,ie)),oe!=null&&oe.to&&de(p.formatTimeInTimezone(oe.to,ie)),we&&ce(p.formatTimeInTimezone(we,ie))},_e=()=>{if(oe!=null&&oe.from&&(oe!=null&&oe.to)){if(w&&U){const Ct=p.composeDateTimeInTimezone(oe.from,Q,ie),dt=p.composeDateTimeInTimezone(oe.to,re,ie,{boundary:"end"});if(!Ct||!dt||dt.getTime()<Ct.getTime())return;t==null||t({from:Ct,to:dt},{temporalPrecision:"minute"}),rt(!1);return}const Fe=p.startOfDayInTimezone(oe.from,ie),Je=p.endOfDayInTimezone(oe.to,ie);t==null||t({from:Fe,to:Je}),rt(!1)}},ze=()=>{fe(e)},Ee=()=>{if(we&&w&&U){const Fe=i==="<="?"end":"start",Je=p.composeDateTimeInTimezone(we,le,ie,{boundary:Fe});if(!Je)return;o==null||o(Je,{temporalPrecision:"minute"}),rt(!1);return}o==null||o(we),rt(!1)},Be=()=>{pe(r)},st=()=>{pe(p.startOfDayInTimezone(new Date,ie))},lt=()=>{const Fe=new Date,Je=parseInt(K,10),Ct=parseInt(X,10);let dt,kt;if(q==="Days"){const _t=p.shiftDateByDaysInTimezone(Fe,ie,Je),Lt=p.shiftDateByDaysInTimezone(Fe,ie,Ct);dt=p.startOfDayInTimezone(_t,ie),kt=p.endOfDayInTimezone(Lt,ie)}else if(q==="Weeks"){const _t=p.shiftDateByWeeksInTimezone(Fe,ie,Je),Lt=p.shiftDateByWeeksInTimezone(Fe,ie,Ct);dt=p.startOfWeekInTimezone(_t,ie),kt=p.endOfWeekInTimezone(Lt,ie)}else if(q==="Months"){const _t=p.shiftDateByMonthsInTimezone(Fe,ie,Je),Lt=p.shiftDateByMonthsInTimezone(Fe,ie,Ct);dt=p.startOfMonthInTimezone(_t,ie),kt=p.endOfMonthInTimezone(Lt,ie)}else if(q==="Quarters"){const _t=p.shiftDateByQuartersInTimezone(Fe,ie,Je),Lt=p.shiftDateByQuartersInTimezone(Fe,ie,Ct);dt=p.startOfQuarterInTimezone(_t,ie),kt=p.endOfQuarterInTimezone(Lt,ie)}else{const _t=p.shiftDateByYearsInTimezone(Fe,ie,Je),Lt=p.shiftDateByYearsInTimezone(Fe,ie,Ct);dt=p.startOfYearInTimezone(_t,ie),kt=p.endOfYearInTimezone(Lt,ie)}const Rt={mode:"between",unit:{Days:"day",Weeks:"week",Months:"month",Quarters:"quarter",Years:"year"}[q],from:Je,to:Ct},yt={from:dt,to:kt};t==null||t(yt),d==null||d(yt,Rt),rt(!1)};function rt(Fe){L(Fe),P==null||P(Fe)}const wt=Fe=>{rt(Fe),Fe&&(fe(e),pe(r),Z(w&&C==="minute"))},zt=l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"border-b border-border px-3 py-2",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx("div",{className:"min-w-0 flex-1",children:ve&&k?l.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[l.jsx(Wa,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsxs(p.Select,{value:T,onValueChange:_,children:[l.jsx(p.SelectTrigger,{className:"h-7 max-w-[210px] rounded-control border-border bg-background text-[12px]",style:Se,children:l.jsx(p.SelectValue,{})}),l.jsx(p.SelectContent,{className:p.cn(I??"z-[52]","rounded-control"),style:ue,children:k.map(Fe=>l.jsx(p.SelectItem,{value:Fe.column,children:Fe.label},Fe.column))})]})]}):l.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[l.jsx(Wa,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx("span",{className:"truncate text-[13px] font-medium",children:Ke})]})}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1 text-[11px] text-muted-foreground",title:`Using ${MN(ie)} timezone`,children:[l.jsx(SR,{className:"h-3 w-3"}),l.jsx("span",{children:hn.getTimezoneAbbreviation(ie)})]})]}),(e==null?void 0:e.from)&&(e==null?void 0:e.to)&&l.jsxs("p",{className:"mt-1 pl-[18px] font-mono text-[11px] tabular-nums text-muted-foreground",children:[Vt.formatInTimeZone(e.from,ie,ee?"MMM d, yyyy HH:mm":"MMM d, yyyy")," – ",Vt.formatInTimeZone(e.to,ie,ee?"MMM d, yyyy HH:mm":"MMM d, yyyy")]})]}),l.jsxs(p.Tabs,{value:O,onValueChange:Fe=>{B(Fe),Fe==="static"&&fe(e)},className:"w-full",children:[De&&l.jsx("div",{className:"px-2 pt-2",children:l.jsxs(p.TabsList,{style:Se,className:p.cn("inline-flex h-[30px] w-full items-center gap-0.5 rounded-control border border-border/60 bg-muted/60 p-0.5 text-muted-foreground"),children:[l.jsx(p.TabsTrigger,{value:"presets",className:"h-6 min-w-0 flex-1 rounded-control px-1.5 text-[11px] font-medium text-muted-foreground hover:text-foreground focus-visible:ring-ring/20 focus-visible:ring-offset-0 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm data-[state=active]:ring-1 data-[state=active]:ring-border",children:"Presets"}),l.jsx(p.TabsTrigger,{value:"static",className:"h-6 min-w-0 flex-1 rounded-control px-1.5 text-[11px] font-medium text-muted-foreground hover:text-foreground focus-visible:ring-ring/20 focus-visible:ring-offset-0 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm data-[state=active]:ring-1 data-[state=active]:ring-border",children:"Static"}),ke&&l.jsx(p.TabsTrigger,{value:"relative",className:"h-6 min-w-0 flex-1 rounded-control px-1.5 text-[11px] font-medium text-muted-foreground hover:text-foreground focus-visible:ring-ring/20 focus-visible:ring-offset-0 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm data-[state=active]:ring-1 data-[state=active]:ring-border",children:"Relative"})]})}),De&&l.jsx(p.TabsContent,{value:"presets",className:"mt-0",children:!u&&l.jsxs("div",{children:[l.jsx("div",{className:"border-b border-border px-2 py-1.5",children:l.jsx("div",{role:"radiogroup","aria-label":"Preset interval","aria-orientation":"horizontal",className:"flex items-center gap-0.5 rounded-control border border-border/60 bg-muted/60 p-0.5",children:se.map(Fe=>{const Je=Fe===H;return l.jsx("button",{type:"button",role:"radio","aria-checked":Je,tabIndex:Je?0:-1,onClick:()=>R(Fe),onKeyDown:Ct=>et(Ct,Fe),className:p.cn("h-6 min-w-0 flex-1 rounded-control px-1.5 text-[11px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/20",Je?"bg-background text-foreground shadow-sm ring-1 ring-border":"text-muted-foreground hover:text-foreground"),children:MQe[Fe]},Fe)})})}),l.jsx("div",{className:"space-y-0.5 p-2",children:he.map(Fe=>l.jsx("button",{type:"button",onClick:()=>{qe(Fe),E&&(D==null||D())},className:"w-full rounded-control px-2 py-1.5 text-left text-[13px] text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/30",children:Fe.label},Fe.label))})]})}),l.jsx(p.TabsContent,{value:"static",className:"mt-0",children:l.jsxs("div",{className:"space-y-2 p-2",children:[s&&s.length>0&&i&&l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:c}),l.jsxs(p.Select,{value:i,onValueChange:Fe=>a==null?void 0:a(Fe),children:[l.jsx(p.SelectTrigger,{className:"h-7 rounded-control border-border bg-background text-[12px]",style:Se,children:l.jsx(p.SelectValue,{})}),l.jsx(p.SelectContent,{className:p.cn(I??"z-[52]","rounded-control"),style:ue,children:s.map(Fe=>l.jsx(p.SelectItem,{value:Fe.value,children:Fe.label},Fe.value))})]})]}),!b&&!u&&(n==="single"?l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date"}),l.jsxs("div",{className:"flex items-center gap-2.5",children:[w&&l.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[l.jsx(An,{checked:U,onCheckedChange:Pe,className:"h-3.5 w-3.5"}),l.jsx("span",{children:"Include time"})]}),l.jsx("button",{type:"button",onClick:st,className:"rounded-control px-1 text-[11px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:"Today"})]})]}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:"relative flex-1",children:l.jsxs(p.Popover,{open:V,onOpenChange:z,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs(p.Button,{variant:"outline",size:"xs",className:"h-7 w-full justify-start rounded-control border-border bg-background text-left text-[12px] font-normal",style:Se,children:[l.jsx(Wa,{className:"mr-1.5 h-3 w-3"}),we?Vt.formatInTimeZone(we,ie,"MM/dd/yyyy"):"Select date"]})}),l.jsx(p.PopoverContent,{style:ue,className:p.cn(I??"z-[52]","w-auto rounded-control p-0"),align:"start",children:l.jsx(Z1,{mode:"single",selected:we,defaultMonth:we,captionLayout:"dropdown",onSelect:Fe=>{pe(Fe),z(!1)},className:"p-2 [--cell-size:1.75rem]",classNames:{weekday:"text-muted-foreground flex-1 select-none text-[10px] font-medium uppercase tracking-[0.08em]",caption_label:"!inline-flex !flex-row !items-center !gap-1 select-none rounded-control !px-1.5 !h-7 text-[12px] font-medium whitespace-nowrap [&>svg]:!size-3 [&>svg]:text-muted-foreground",dropdown_root:"!inline-flex !flex-row !items-center has-focus:border-ring border-input has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-control border min-w-[3.5rem]",dropdowns:"flex h-[--cell-size] w-full items-center justify-center gap-1 text-[12px] font-medium",day:"group/day relative aspect-square h-full w-full select-none p-0 text-center [&_button]:!text-[11px] [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md"}})})]})}),U&&w&&l.jsx(p.Input,{size:"xs",value:le,onChange:Fe=>ce(Fe.target.value),placeholder:"HH:mm","aria-invalid":!p.isValidTimeInput(le),title:"Use 24-hour HH:mm time",className:"w-20 shrink-0 font-mono tabular-nums"})]})]}):l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Custom range"}),w&&l.jsxs("label",{className:"flex items-center gap-1.5 text-[11px] text-muted-foreground",children:[l.jsx(An,{checked:U,onCheckedChange:Pe,className:"h-3.5 w-3.5"}),l.jsx("span",{children:"Include time"})]})]}),l.jsxs("div",{className:p.cn(U&&w?"space-y-1.5":"flex items-center gap-1.5"),children:[l.jsxs("div",{className:"flex flex-1 items-center gap-1.5",children:[l.jsx("div",{className:"relative flex-1",children:l.jsxs(p.Popover,{open:V,onOpenChange:z,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs(p.Button,{variant:"outline",size:"xs",className:"h-7 w-full justify-start rounded-control border-border bg-background text-left text-[12px] font-normal",style:Se,children:[l.jsx(Wa,{className:"mr-1.5 h-3 w-3"}),oe!=null&&oe.from?Vt.formatInTimeZone(oe.from,ie,"MM/dd/yyyy"):"From date"]})}),l.jsx(p.PopoverContent,{style:ue,className:p.cn(I??"z-[52]","w-auto rounded-control p-0"),align:"start",children:l.jsx(Z1,{mode:"single",selected:oe==null?void 0:oe.from,defaultMonth:oe==null?void 0:oe.from,captionLayout:"dropdown",onSelect:Fe=>He("from",Fe),className:"p-2 [--cell-size:1.75rem]",classNames:{weekday:"text-muted-foreground flex-1 select-none text-[10px] font-medium uppercase tracking-[0.08em]",caption_label:"!inline-flex !flex-row !items-center !gap-1 select-none rounded-control !px-1.5 !h-7 text-[12px] font-medium whitespace-nowrap [&>svg]:!size-3 [&>svg]:text-muted-foreground",dropdown_root:"!inline-flex !flex-row !items-center has-focus:border-ring border-input has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-control border min-w-[3.5rem]",dropdowns:"flex h-[--cell-size] w-full items-center justify-center gap-1 text-[12px] font-medium",day:"group/day relative aspect-square h-full w-full select-none p-0 text-center [&_button]:!text-[11px] [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md"}})})]})}),U&&w&&l.jsx(p.Input,{size:"xs",value:Q,onChange:Fe=>J(Fe.target.value),placeholder:"HH:mm","aria-invalid":!p.isValidTimeInput(Q),title:"Start time in 24-hour HH:mm",className:"w-20 shrink-0 font-mono tabular-nums"})]}),l.jsx("span",{className:p.cn("text-[12px] text-muted-foreground",U&&w&&"block text-center"),children:"–"}),l.jsxs("div",{className:"flex flex-1 items-center gap-1.5",children:[l.jsx("div",{className:"relative flex-1",children:l.jsxs(p.Popover,{open:F,onOpenChange:G,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs(p.Button,{variant:"outline",size:"xs",className:"h-7 w-full justify-start rounded-control border-border bg-background text-left text-[12px] font-normal",style:Se,children:[l.jsx(Wa,{className:"mr-1.5 h-3 w-3"}),oe!=null&&oe.to?Vt.formatInTimeZone(oe.to,ie,"MM/dd/yyyy"):"To date"]})}),l.jsx(p.PopoverContent,{style:ue,className:p.cn(I??"z-[52]","w-auto rounded-control p-0"),align:"start",children:l.jsx(Z1,{mode:"single",selected:oe==null?void 0:oe.to,defaultMonth:oe==null?void 0:oe.to,captionLayout:"dropdown",onSelect:Fe=>He("to",Fe),className:"p-2 [--cell-size:1.75rem]",classNames:{weekday:"text-muted-foreground flex-1 select-none text-[10px] font-medium uppercase tracking-[0.08em]",caption_label:"!inline-flex !flex-row !items-center !gap-1 select-none rounded-control !px-1.5 !h-7 text-[12px] font-medium whitespace-nowrap [&>svg]:!size-3 [&>svg]:text-muted-foreground",dropdown_root:"!inline-flex !flex-row !items-center has-focus:border-ring border-input has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-control border min-w-[3.5rem]",dropdowns:"flex h-[--cell-size] w-full items-center justify-center gap-1 text-[12px] font-medium",day:"group/day relative aspect-square h-full w-full select-none p-0 text-center [&_button]:!text-[11px] [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md"}})})]})}),U&&w&&l.jsx(p.Input,{size:"xs",value:re,onChange:Fe=>de(Fe.target.value),placeholder:"HH:mm","aria-invalid":!p.isValidTimeInput(re),title:"End time in 24-hour HH:mm",className:"w-20 shrink-0 font-mono tabular-nums"})]})]})]}))]})}),ke&&l.jsx(p.TabsContent,{value:"relative",className:"mt-0",children:l.jsxs("div",{className:"space-y-2 p-2",children:[l.jsx("div",{className:"inline-flex w-full items-center gap-0.5 rounded-control border border-border bg-background p-0.5",style:Se,children:["Days","Weeks","Months","Quarters","Years"].map(Fe=>l.jsx("button",{onClick:()=>Y(Fe),className:p.cn("flex-1 rounded-control px-2 py-1 text-[11px] font-medium transition-colors",q===Fe?"bg-accent text-accent-foreground":"text-muted-foreground hover:bg-muted hover:text-foreground"),children:Fe},Fe))}),l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx("div",{className:"flex-1",children:l.jsxs(p.Select,{value:K,onValueChange:$,children:[l.jsx(p.SelectTrigger,{className:"h-7 rounded-control border-border bg-background text-[12px]",style:Se,children:l.jsx(p.SelectValue,{placeholder:"From"})}),l.jsx(p.SelectContent,{className:p.cn(I??"z-[51]","rounded-control"),style:ue,children:(q==="Years"?dU:q==="Quarters"?fU:q==="Months"?hU:q==="Weeks"?mU:uU).map(Je=>l.jsx(p.SelectItem,{value:Je.value.toString(),children:Je.label},Je.value))})]})}),l.jsx("span",{className:"text-[12px] text-muted-foreground",children:"to"}),l.jsx("div",{className:"flex-1",children:l.jsxs(p.Select,{value:X,onValueChange:W,children:[l.jsx(p.SelectTrigger,{className:"h-7 rounded-control border-border bg-background text-[12px]",style:Se,children:l.jsx(p.SelectValue,{placeholder:"To"})}),l.jsx(p.SelectContent,{className:p.cn(I??"z-[51]","rounded-control"),style:ue,children:(q==="Years"?dU:q==="Quarters"?fU:q==="Months"?hU:q==="Weeks"?mU:uU).map(Je=>l.jsx(p.SelectItem,{value:Je.value.toString(),children:Je.label},Je.value))})]})})]})]})})]}),M,(()=>{const Fe=O==="static"&&n==="single",Je=O==="static"&&n==="range",Ct=O==="relative",dt=Fe&&!!we||Je&&!!(oe!=null&&oe.from)&&!!(oe!=null&&oe.to),kt=dt||Ct,Ft=dt,Rt=w&&U,yt=Rt&&(oe!=null&&oe.from)?p.composeDateTimeInTimezone(oe.from,Q,ie):null,_t=Rt&&(oe!=null&&oe.to)?p.composeDateTimeInTimezone(oe.to,re,ie,{boundary:"end"}):null,Lt=Je&&Rt&&(!p.isValidTimeInput(Q)||!p.isValidTimeInput(re)||!yt||!_t||_t.getTime()<yt.getTime()),ln=Fe&&Rt&&!p.isValidTimeInput(le);if(!Ve&&!kt)return null;const Ye=()=>{Fe?Ee():Je?_e():Ct&&lt(),E&&(D==null||D())},Ae=()=>{Fe?Be():Je&&ze()},Me=Fe&&!we||Je&&(!(oe!=null&&oe.from)||!(oe!=null&&oe.to))||Lt||ln;return l.jsxs("div",{className:"flex items-center justify-between gap-2 border-t border-border px-3 py-2",children:[Ve?l.jsx(p.Button,{type:"button",variant:"ghost",size:"xs",onClick:()=>{ye(),E&&(D==null||D())},children:"Clear"}):l.jsx("span",{}),l.jsxs("div",{className:"flex items-center gap-1",children:[Ft&&l.jsx(p.Button,{type:"button",variant:"ghost",size:"xs",onClick:Ae,children:"Cancel"}),kt&&l.jsx(p.Button,{type:"button",variant:"default",size:"xs",onClick:Ye,disabled:Me,children:"Apply"})]})]})})()]});return E?l.jsx("div",{className:p.cn("w-full overflow-hidden bg-popover text-popover-foreground",m),style:ue,children:zt}):l.jsx("div",{className:p.cn("w-full",m),children:l.jsxs(p.Popover,{open:A,onOpenChange:wt,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs(p.Button,{variant:"outline",className:p.cn("h-8 min-w-0 w-full justify-between gap-2 rounded-control border-border bg-background text-left text-[13px] font-normal text-foreground transition-colors hover:border-border/80 hover:bg-background",N),style:Se,title:`Timezone: ${MN(ie)} (${hn.getTimezoneAbbreviation(ie)})`,disabled:y,children:[l.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px]",children:S?`${Re()} · ${S}`:Re()}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[l.jsx(SR,{className:"h-3 w-3 opacity-50"}),l.jsx(Ie.ChevronDown,{className:"h-3 w-3 opacity-50"})]})]})}),l.jsx(p.PopoverContent,{style:ue,className:p.cn(j??"z-[51]","w-[320px] overflow-hidden rounded-control border border-border/80 bg-popover p-0 text-popover-foreground shadow-[0_20px_50px_-24px_rgba(15,23,42,0.35)] dark:shadow-[0_20px_50px_-24px_rgba(0,0,0,0.6)]"),align:"start",children:zt})]})})}function due(e,t){var o,s;const n=(o=t==null?void 0:t.find(i=>i.filterId===e.id))==null?void 0:o.name,r=new Set([e.column,...((s=e.targetColumns)==null?void 0:s.map(i=>i.column))??[]]);return n&&r.has(n)?n:e.column}function PQe(e,t){const n=v.useMemo(()=>{const h={column:e.column,label:e.title};return e.targetColumns&&e.targetColumns.length>0?[h,...e.targetColumns]:[h]},[e.targetColumns,e.column,e.title]),r=(t==null?void 0:t.storageTarget)==="card",o=p.useDashboardStore(h=>h.filterValues),s=r?t==null?void 0:t.inlineFilterValues:o,i=s==null?void 0:s.find(h=>h.filterId===e.id),a=!!i,c=v.useMemo(()=>due(e,s),[e,s]),[u,d]=v.useState(c);v.useEffect(()=>{const h=n.some(m=>m.column===u);(i!=null&&i.name&&c!==u||!h)&&d(c)},[c,i==null?void 0:i.name,n]);const f=v.useMemo(()=>u&&u!==e.column?{...e,column:u}:e,[e,u]);return{selectedColumn:u,setSelectedColumn:d,effectiveFilter:f,targetColumns:n,hasActiveFilter:a,storedFilterValue:i}}const FQe=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],OQe=["January","February","March","April","May","June","July","August","September","October","November","December"];function fue({value:e,onChange:t,onClear:n,placeholder:r="Select month",className:o,buttonClassName:s}){const[i,a]=v.useState(!1),[c,u]=v.useState((e==null?void 0:e.year)??new Date().getFullYear()),[d,f]=v.useState(e);v.useEffect(()=>{e?(f(e),u(e.year)):(f(void 0),u(new Date().getFullYear()))},[e]);const h=b=>{u(y=>y+b)},m=b=>{f({year:c,month:b}),t==null||t(c,b),a(!1)},g=()=>{f(void 0),n==null||n(),a(!1)},x=d?`${OQe[d.month]} ${d.year}`:r;return l.jsxs(p.Popover,{open:i,onOpenChange:a,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsx(p.Button,{variant:"outline",role:"combobox","aria-expanded":i,className:p.cn("min-w-0 w-full justify-between gap-2 px-3 text-sm font-normal",s??"h-9",!d&&"text-muted-foreground",o),children:l.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[l.jsx(N0,{className:"h-4 w-4 shrink-0 opacity-50"}),l.jsx("span",{className:"truncate",children:x})]})})}),l.jsx(p.PopoverContent,{className:"z-[52] w-80 p-0",align:"start",children:l.jsxs("div",{className:"p-3",children:[l.jsxs("div",{className:"mb-3 flex items-center justify-between border-b pb-3",children:[l.jsx(p.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>h(-1),"aria-label":"Previous year",children:l.jsx(Lm,{className:"h-4 w-4"})}),l.jsx("h2",{className:"text-sm font-semibold",children:c}),l.jsx(p.Button,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>h(1),"aria-label":"Next year",children:l.jsx(Mt.ChevronRight,{className:"h-4 w-4"})})]}),l.jsx("div",{className:"grid grid-cols-3 gap-1.5",children:FQe.map((b,y)=>{const w=(d==null?void 0:d.month)===y&&(d==null?void 0:d.year)===c;return l.jsx(p.Button,{variant:w?"outline":"ghost",className:p.cn("h-9 text-sm font-medium",!w&&"hover:bg-muted",w&&"border-foreground"),onClick:()=>m(y),children:b},b)})}),d&&l.jsx("div",{className:"mt-3 border-t pt-3",children:l.jsx(p.Button,{variant:"ghost",onClick:g,className:"h-9 w-full justify-center text-sm",children:"Clear selection"})})]})})]})}const hue=[{label:"Today",meta:{mode:"this",unit:"day"}},{label:"Yesterday",meta:{mode:"previous",unit:"day"}}];function mue(e,t){return!(!e||e.mode!==t.mode||e.unit!==t.unit||e.mode==="this"&&(e.boundary||e.toDate))}function pU({value:e,relativeValue:t,timezone:n,onSelect:r,onPresetSelect:o,onClear:s,onApplied:i,showPresets:a=!0}){const c=e?Vt.toZonedTime(e,n):void 0;return l.jsxs("div",{children:[a&&l.jsx("div",{className:"flex items-center gap-1 border-b border-border p-1.5",children:hue.map(u=>{const d=mue(t,u.meta);return l.jsx(p.Button,{variant:d?"outline":"ghost",size:"xs",className:p.cn("h-7 flex-1 text-[12px] font-normal",d&&"border-foreground"),onClick:()=>{o==null||o(u.meta),i==null||i()},children:u.label},u.label)})}),l.jsx(Z1,{mode:"single",selected:c,defaultMonth:c,captionLayout:"dropdown",onSelect:u=>{u&&(r==null||r(Vt.format(u,"yyyy-MM-dd")),i==null||i())},className:"mx-auto w-fit p-2 [--cell-size:1.75rem]",classNames:{weekday:"text-muted-foreground flex-1 select-none text-[10px] font-medium uppercase tracking-[0.08em]",caption_label:"!inline-flex !flex-row !items-center !gap-1 select-none rounded-control !px-1.5 !h-7 text-[12px] font-medium whitespace-nowrap [&>svg]:!size-3 [&>svg]:text-muted-foreground",dropdown_root:"!inline-flex !flex-row !items-center has-focus:border-ring border-input has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-control border min-w-[3.5rem]",dropdowns:"flex h-[--cell-size] w-full items-center justify-center gap-1 text-[12px] font-medium",day:"group/day relative aspect-square h-full w-full select-none p-0 text-center [&_button]:!text-[11px] [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md"}}),(e||t)&&s&&l.jsx("div",{className:"border-t border-border p-1.5",children:l.jsx(p.Button,{variant:"ghost",size:"xs",className:"h-7 w-full justify-center text-[12px]",onClick:()=>{s(),i==null||i()},children:"Clear selection"})})]})}function pue({value:e,relativeValue:t,timezone:n,onSelect:r,onPresetSelect:o,onClear:s,placeholder:i="Select date",className:a,buttonClassName:c,inline:u=!1,onApplied:d,showPresets:f=!0}){var w;const[h,m]=v.useState(!1),g=(w=hue.find(C=>mue(t,C.meta)))==null?void 0:w.label,x=g||(e?Vt.formatInTimeZone(e,n,"MMM d, yyyy"):i),b=!!(g||e);if(u)return l.jsx(pU,{value:e,relativeValue:t,timezone:n,onSelect:r,onPresetSelect:o,onClear:s,onApplied:d,showPresets:f});const y=C=>{C(),m(!1)};return l.jsxs(p.Popover,{open:h,onOpenChange:m,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsx(p.Button,{variant:"outline",role:"combobox","aria-expanded":h,className:p.cn("min-w-0 w-full justify-between gap-2 px-3 text-sm font-normal",c??"h-9",!b&&"text-muted-foreground",a),children:l.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[l.jsx(N0,{className:"h-4 w-4 shrink-0 opacity-50"}),l.jsx("span",{className:"truncate",children:x})]})})}),l.jsx(p.PopoverContent,{className:"z-[52] w-auto p-0",align:"start",children:l.jsx(pU,{value:e,relativeValue:t,timezone:n,onSelect:C=>y(()=>r==null?void 0:r(C)),onPresetSelect:C=>y(()=>o==null?void 0:o(C)),onClear:s?()=>y(s):void 0,showPresets:f})})]})}const X1=[{value:"between",label:"Is between"},{value:"<",label:"Is before"},{value:">",label:"Is after"},{value:"<=",label:"Is on or before"},{value:">=",label:"Is on or after"},{value:"=",label:"Is exactly"}],LQe=new Set(X1.map(e=>e.value)),$Qe=new Set(["between","not between","=","!=",">",">=","<","<="]),zQe={"not between":"Is not between","!=":"Is not exactly"},kM=e=>typeof e=="string"&&$Qe.has(e);function gue({filter:e,className:t,isCardStorage:n,timezone:r,selectedColumn:o,setSelectedColumn:s,targetColumns:i,hasActiveFilter:a,enableTimePrecision:c,storedFilterValue:u,activeFilterValue:d,dateRange:f,isLoading:h,isFetching:m,isError:g,hasData:x,setDateRange:b,handleChange:y,handleRelativeChange:w,handleClear:C,inline:N=!1,onApplied:S,supplementalFooter:j}){const I=n?"h-8":"h-9",k=n?"h-[31px]":"h-[35px]",T=e.dateSelectionMode==="months"||e.dateSelectionMode==="day"?e.dateSelectionMode:"range",_=a?f:void 0,E=kM(e.operation)?e.operation:"between",[D,M]=v.useState(o),[P,A]=v.useState(E);v.useEffect(()=>{if(d&&kM(d.operation)){A(d.operation);return}A(E)},[d,E]);const L=v.useMemo(()=>{if(LQe.has(P))return X1;const U=zQe[P];return U?[...X1,{value:P,label:U}]:X1},[P]);if(v.useEffect(()=>{if(o!==void 0&&s&&o!==D){if(M(o),!a)return;const U=kM(u==null?void 0:u.operation)?u.operation:P,Z=(u==null?void 0:u.temporalPrecision)==="minute"?{temporalPrecision:"minute"}:void 0,Q=u==null?void 0:u.relativeMeta;if(Q&&U==="between"&&f){w(f,Q,Z);return}if(U==="between"||U==="not between"){f&&y(f,U,Z);return}const J=(f==null?void 0:f.from)||(f==null?void 0:f.to);J&&y({from:J,to:J},U,Z)}},[o,D,f,y,w,s,u,a,P]),v.useEffect(()=>{if(T!=="day"||!a||!d)return;const U=d.values,Z=oe=>{if(!oe)return;const fe=oe instanceof Date?oe:new Date(oe);return Number.isNaN(fe.getTime())?void 0:fe},Q=Z(U==null?void 0:U[0]);if(!Q)return;const J=Z(U==null?void 0:U[1]),re=Vt.formatInTimeZone(Q,r,"yyyy-MM-dd");if(d.operation==="between"&&!!J&&Vt.formatInTimeZone(J,r,"yyyy-MM-dd")===re)return;const[le,ce]=p.resolveCalendarDayRange(re,r);y({from:le,to:ce},"between")},[d,T,y,a,r]),!N&&(h||m))return l.jsx("div",{children:l.jsx(ei,{className:p.cn(k,"w-full bg-foreground/10")})});if(g)return l.jsx(M$,{isCardStorage:n});if(!N&&!x)return l.jsx(p.Label,{className:p.cn("flex w-full items-center bg-muted px-2",I),children:"No Data"});const O=P==="between"||P==="not between",B=(c||p.getFilterTemporalCapability(e)==="datetime")&&p.supportsMinutePrecisionForOperation(P),H=d,R=B&&(H==null?void 0:H.temporalPrecision)==="minute"?"minute":B?p.getTemporalPrecisionForRelativeMeta(H==null?void 0:H.relativeMeta):void 0,V=e.showLabel===!1?e.title||e.column:void 0,z=U=>{if(!U)return;const Z=U instanceof Date?U:new Date(U);return isNaN(Z.getTime())?void 0:Z},F=()=>{const U=d==null?void 0:d.operation,Z=d==null?void 0:d.values;if(!U||!Array.isArray(Z)||Z.length<2||U!=="between"&&U!=="not between")return;const Q=z(Z[0]),J=z(Z[1]);if(!(!Q&&!J))return{from:Q,to:J}},G=()=>{const U=d==null?void 0:d.operation,Z=d==null?void 0:d.values;if(!(!U||!Array.isArray(Z)||Z.length<1||!["=","!=",">",">=","<","<="].includes(U)))return z(Z[0])},q=U=>{const Z=F();if(Z){if(U==="<"||U==="<=")return Z.to||Z.from;if(U===">"||U===">="||U==="=")return Z.from||Z.to}return G()},Y=(U,Z,Q={})=>Q.temporalPrecision==="minute"?U:Z==="<="||Z===">"?p.endOfDayInTimezone(U,r):p.startOfDayInTimezone(U,r),K=(U,Z)=>{if(!U){C();return}y(U,O?P:"between",Z)},$=(U,Z)=>{if(!U){C();return}const Q=Y(U,P,Z);b({from:Q,to:Q}),y({from:Q,to:Q},P,Z)},X=U=>{if(A(U),!a||!d)return;if(U==="between"||U==="not between"){const Q=F();if(Q!=null&&Q.from||Q!=null&&Q.to){y({from:Q.from,to:Q.to},U,R?{temporalPrecision:R}:{});return}const J=G();if(J){const re={from:p.startOfDayInTimezone(J,r),to:p.endOfDayInTimezone(J,r)};y(re,U)}return}const Z=q(U);if(Z){const Q=R&&p.supportsMinutePrecisionForOperation(U)?{temporalPrecision:R}:{},J=Y(Z,U,Q);b({from:J,to:J}),y({from:J,to:J},U,Q);return}},W=(U,Z,Q)=>{w(U,Z,Q)};if(T==="day"){const U=Q=>{const[J,re]=p.resolveCalendarDayRange(Q,r);b({from:J,to:re}),y({from:J,to:re},"between")},Z=Q=>{const[J,re]=p.resolveRelativeDateForDefaults(Q,r);w({from:J,to:re},Q)};return l.jsx(pue,{className:t,buttonClassName:I,timezone:r,value:_==null?void 0:_.from,relativeValue:a?H==null?void 0:H.relativeMeta:void 0,placeholder:V||"Select date",inline:N,onApplied:S,onClear:C,onSelect:U,onPresetSelect:Z})}if(T==="months"){const U=_!=null&&_.from?(()=>{const J=Vt.toZonedTime(_.from,r);return{year:yye(J),month:xye(J)}})():void 0,Z=J=>`${J}`.padStart(2,"0"),Q=(J,re)=>{const de=`${J}-${Z(re+1)}-01T00:00:00`,le=re===11?J+1:J,ce=(re+1)%12,oe=`${le}-${Z(ce+1)}-01T00:00:00`;return{from:X2.fromZonedTime(de,r),to:X2.fromZonedTime(oe,r)}};return l.jsx(fue,{className:t,buttonClassName:I,value:U,placeholder:V||"All months",onClear:C,onChange:(J,re)=>{const{from:de,to:le}=Q(J,re);y({from:de,to:le})}})}return l.jsx($$,{value:O?_:void 0,singleValue:O||_==null?void 0:_.from,selectionMode:O?"range":"single",buttonClassName:I,onChange:K,onSingleChange:$,onRelativeSelect:W,relativeValue:H==null?void 0:H.relativeMeta,comparisonOptions:L,comparisonValue:P,onComparisonChange:X,comparisonLabel:"Condition",timezone:r,enableTimePrecision:B,temporalPrecision:R,showRelativeTab:P==="between",className:t,placeholder:V||(O?"All time":"Select date"),targetColumns:i&&i.length>1?i:void 0,selectedColumn:o,onColumnChange:s,inline:N,onApplied:S,supplementalFooter:j})}function BQe({filter:e,className:t,storageOptions:n,inline:r,onApplied:o,supplementalFooter:s}){const i=bl(),{selectedColumn:a,setSelectedColumn:c,effectiveFilter:u,targetColumns:d,hasActiveFilter:f,storedFilterValue:h}=PQe(e,n),{records:m,dateRange:g,isLoading:x,isFetching:b,isError:y,setDateRange:w,activeFilterValue:C,handleChange:N,handleRelativeChange:S,handleClear:j}=R$(u,n);return l.jsx(gue,{filter:u,className:t,isCardStorage:(n==null?void 0:n.storageTarget)==="card",timezone:i,selectedColumn:a,setSelectedColumn:c,targetColumns:d,hasActiveFilter:f,storedFilterValue:h,activeFilterValue:C,dateRange:g,isLoading:x,isFetching:b,isError:y,hasData:!!m,setDateRange:w,handleChange:N,handleRelativeChange:S,handleClear:j,inline:r,onApplied:o,supplementalFooter:s})}function VQe({filter:e,className:t,storageOptions:n,managedState:r,inline:o,onApplied:s,supplementalFooter:i}){const a=bl();return l.jsx(gue,{filter:e,className:t,isCardStorage:(n==null?void 0:n.storageTarget)==="card",timezone:a,hasActiveFilter:r.hasActiveFilter??!!r.activeFilterValue,enableTimePrecision:r.enableTimePrecision,storedFilterValue:r.storedFilterValue??r.activeFilterValue,activeFilterValue:r.activeFilterValue,dateRange:r.dateRange,isLoading:r.isLoading??!1,isFetching:r.isFetching??!1,isError:r.isError??!1,hasData:r.hasData??!0,setDateRange:r.setDateRange??(()=>{}),handleChange:r.handleChange,handleRelativeChange:r.handleRelativeChange,handleClear:r.handleClear,inline:o,onApplied:s,supplementalFooter:i})}function z$(e){return"managedState"in e?l.jsx(VQe,{...e}):l.jsx(BQe,{...e})}function gU({filter:e,storageOptions:t}){return p.isDateDataType(e.dataType)?l.jsx(z$,{filter:e,storageOptions:t}):e.uiType==="radio"&&e.type==="single"?l.jsx($ce,{filter:e,storageOptions:t}):e.uiType==="tabs"&&e.type==="single"?l.jsx(zce,{filter:e,storageOptions:t}):l.jsx(Oce,{filter:e,storageOptions:t})}function HQe({filter:e,CustomFilterComponent:t,theme:n,storageOptions:r}){var N;const{filteredRecords:o,selectedRecords:s,handleChange:i,handleClear:a,handleSelectAll:c,query:u,setQuery:d,isLoading:f,isFetching:h,isError:m,isSearching:g,isSingleSelect:x,allSelected:b,activeFilterValue:y}=Xb(e,{enableServerSearch:!0,...r}),w={filter:e,options:o||[],selectedValues:s||[],onChange:i,onClear:a,onSelectAll:c,searchQuery:u,onSearchChange:d,isLoading:f,isFetching:h,isError:m,isSearching:g,isSingleSelect:x,allSelected:b,activeFilterValue:y,theme:n,settings:(N=e.customFilterPreferences)==null?void 0:N.settings},C=(r==null?void 0:r.storageTarget)==="card"?"h-[31px]":"h-[35px]";return l.jsx(v.Suspense,{fallback:l.jsx(ei,{className:`${C} w-full bg-foreground/10`}),children:l.jsx(t,{...w})})}function qQe({filter:e,CustomFilterComponent:t,theme:n,storageOptions:r}){var b;const{dateRange:o,initialDateRange:s,handleChange:i,handleRelativeChange:a,handleClear:c,handleReset:u,isLoading:d,isFetching:f,isError:h,activeFilterValue:m}=R$(e,r),g={filter:e,dateRange:o,initialDateRange:s,onDateChange:i,onRelativeDateChange:a,onClear:c,onReset:u,isLoading:d,isFetching:f,isError:h,activeFilterValue:m,theme:n,settings:(b=e.customFilterPreferences)==null?void 0:b.settings},x=(r==null?void 0:r.storageTarget)==="card"?"h-[31px]":"h-[35px]";return l.jsx(v.Suspense,{fallback:l.jsx(ei,{className:`${x} w-full bg-foreground/10`}),children:l.jsx(t,{...g})})}function UQe({filter:e,storageOptions:t}){var h,m,g;const{compiledAppearance:n}=oi.useAppearance(),r=(t==null?void 0:t.storageTarget)==="card"?"h-[31px]":"h-[35px]",o=v.useMemo(()=>Vw(n),[n]),{getFilter:s,isLoading:i,isError:a}=_f(((h=e.customFilterPreferences)==null?void 0:h.url)||""),c=(m=e.customFilterPreferences)==null?void 0:m.componentName,u=c?s(c):null;if(!c||!((g=e.customFilterPreferences)!=null&&g.url)||a||!i&&!u)return l.jsx(gU,{filter:e,storageOptions:t});if(i||!u)return l.jsx(ei,{className:`${r} w-full bg-foreground/10`});const f=p.isDateDataType(e.dataType);return l.jsx(_i,{fallback:l.jsx(gU,{filter:e,storageOptions:t}),onError:x=>console.error("Custom filter runtime error:",x),children:f?l.jsx(qQe,{filter:e,CustomFilterComponent:u,theme:o,storageOptions:t}):l.jsx(HQe,{filter:e,CustomFilterComponent:u,theme:o,storageOptions:t})})}const WQe=v.memo(UQe);function bue({selection:e,controlLabel:t,onChange:n}){const r=v.useId(),o=e.mode==="period"?e.spec:void 0,s=(o==null?void 0:o.kind)==="previous_year"?o.offsetYears||1:(o==null?void 0:o.kind)==="previous_period"&&o.offsetPeriods||1,i=(o==null?void 0:o.kind)||"off",a=`${r}-comparison`,c=d=>{o&&n({mode:"period",spec:{...o,...d}})},u=d=>{if(d==="off"){n({mode:"off"});return}n({mode:"period",spec:d==="previous_year"?{kind:"previous_year",toDate:!0}:{kind:"previous_period",toDate:!0}})};return l.jsxs("div",{className:"space-y-2",children:[l.jsx("div",{role:"radiogroup","aria-label":`${t} comparison`,className:"grid grid-cols-3 gap-0.5 rounded-control border border-border/60 bg-muted/60 p-0.5",children:[["off","Off"],["previous_period","Previous period"],["previous_year","Previous year"]].map(([d,f])=>{const h=i===d;return l.jsxs("label",{className:"cursor-pointer",children:[l.jsx("input",{type:"radio",name:a,value:d,checked:h,onChange:()=>u(d),className:"peer sr-only"}),l.jsx("span",{className:p.cn("flex h-6 items-center justify-center rounded-control px-1.5 text-center text-[11px] font-medium text-muted-foreground transition-colors hover:text-foreground peer-focus-visible:outline-none peer-focus-visible:ring-2 peer-focus-visible:ring-ring/20",h&&"bg-background text-foreground shadow-sm ring-1 ring-border"),children:f})]},d)})}),o?l.jsxs("div",{className:"space-y-2 rounded-control bg-muted/35 p-2",children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsx(p.Label,{htmlFor:r,className:"text-xs",children:"Offset"}),l.jsx(p.Input,{id:r,"aria-label":"Comparison offset",type:"number",min:1,step:1,className:"h-7 w-20 text-xs",value:s,onFocus:d=>d.currentTarget.select(),onChange:d=>{const f=Number.parseInt(d.target.value,10);!Number.isInteger(f)||f<1||c(o.kind==="previous_year"?{offsetYears:f}:{offsetPeriods:f})}})]}),l.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[l.jsx(An,{checked:o.toDate===!0,onCheckedChange:d=>c({toDate:d===!0})}),"To date"]}),l.jsxs("label",{className:"flex items-center gap-2 text-xs",children:[l.jsx(An,{checked:o.alignment==="weekday",onCheckedChange:d=>c({alignment:d===!0?"weekday":"calendar"})}),"Match weekdays"]})]}):null]})}function xue({selection:e,controlLabel:t,scopeMessage:n,authorControlledCardCount:r,activeDateFilterValue:o,hasRuntimeOverride:s,onChange:i,onReset:a}){const c=e.mode==="period"?e.spec:void 0,u=p.hasFiniteDateComparisonRange(o);return l.jsxs("div",{className:"space-y-2 border-t border-border px-2 py-2.5",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Compare"}),s?l.jsx(p.Button,{type:"button",variant:"ghost",size:"xs",onClick:a,children:"Reset"}):null]}),l.jsx(bue,{selection:e,controlLabel:t,onChange:i}),l.jsxs("p",{className:"text-[11px] leading-4 text-muted-foreground",children:[u?n:c?`Choose a ${t} range to activate this comparison.`:`Choose a ${t} range to enable comparison.`,r>0?` ${r} visual${r===1?" contains":"s contain"} author-controlled comparison settings, which take precedence.`:""]})]})}function B$(e,t){const n=p.useDashboardStore(s=>s.dashboard),r=p.useDashboardStore(s=>s.selectedSheetId),o=p.useDashboardStore(s=>s.dashboardInputValues);return v.useMemo(()=>{var a;if((t==null?void 0:t.storageTarget)==="card")return t;const s=((a=t==null?void 0:t.dashboardInput)==null?void 0:a.kind)==="filter"?t.dashboardInput:ja(n,e.id);if(!s)return t;const i=p.getDashboardInputRuntimeSlot(o,s,{sheetId:(t==null?void 0:t.sheetId)||r});return(i==null?void 0:i.status)!=="set"&&(i==null?void 0:i.status)!=="cleared"?t:{...t,storageTarget:"dashboardInput",dashboardInput:s,sheetId:(t==null?void 0:t.sheetId)||r||void 0}},[n,o,e.id,r,t])}function IM(e){if(!e)return;const t=e instanceof Date?e:new Date(e);return isNaN(t.getTime())?void 0:t}function yue({filter:e,storageOptions:t,inline:n,onApplied:r}){var P;const o=B$(e,t),s=p.useDashboardStore(A=>A.filterValues),i=p.useDashboardStore(A=>A.dashboard),a=p.useDashboardStore(A=>A.dashboardInputValues),c=p.useDashboardStore(A=>A.selectedSheetId),u=p.useDashboardStore(A=>A.semanticExecutionPayload),{addOrUpdateFilterValue:d,removeFilterValues:f,setDashboardInputSlot:h,clearDashboardInputSlot:m,setDashboardInputComparisonSelection:g,resetDashboardInputComparisonSelection:x}=p.useDashboardActions(),b=v.useMemo(()=>p.getGlobalDateFilterCoverage(i,u,e),[i,e,u]),y=v.useMemo(()=>{const A=o==null?void 0:o.dashboardInput;return(A==null?void 0:A.kind)==="filter"?A:ja(i,e.id)},[i,e.id,o==null?void 0:o.dashboardInput]),w=v.useMemo(()=>({sheetId:(o==null?void 0:o.sheetId)||c}),[c,o==null?void 0:o.sheetId]),C=!!(y&&p.canAddressDashboardInputRuntimeSlot(y,w)),N=v.useMemo(()=>y&&C?p.hydrateAuthoredDashboardInputSlot({dashboard:i,input:y,runtimeValues:a,target:w}):void 0,[C,i,y,w,a]),S=(N==null?void 0:N.comparisonSelection)||{mode:"off"},j=(N==null?void 0:N.status)==="set"&&N.value.kind==="filter"?N.value.filterValue:void 0,I=(o==null?void 0:o.storageTarget)==="dashboardInput",k=I?j:s==null?void 0:s.find(A=>A.filterId===e.id),T=v.useCallback(A=>{if(I){if(!y)return;const L=p.createFilterDashboardInputSlot(A);L&&h(y,w,L);return}d(A)},[d,y,w,I,h]),_=v.useCallback(()=>{if(I){if(!y)return;m(y,w);return}f(e.id)},[m,y,w,e.id,I,f]),E=y?C&&((P=p.getDashboardInputRuntimeSlot(a,y,w))==null?void 0:P.comparisonSelection)!==void 0:!1,D=v.useMemo(()=>{const A=new Set(b.eligibleCardIds);return p.getDashboardCards(i).filter(L=>{var O,B;return A.has(L.id)?((O=L.preferences)==null?void 0:O.inheritGlobalComparison)===!1?!0:(((B=L.config)==null?void 0:B.metricColumns)||[]).some(H=>H.comparison!==void 0):!1}).length},[i,b.eligibleCardIds]),M=v.useMemo(()=>{var A;return{hasData:!0,hasActiveFilter:!!k,enableTimePrecision:b.allEligibleTargetsAreDateTime,activeFilterValue:k,storedFilterValue:k,dateRange:(A=k==null?void 0:k.values)!=null&&A.length?{from:IM(k.values[0]),to:k.values.length>1?IM(k.values[1]):IM(k.values[0])}:void 0,handleChange:(L,O="between",B={})=>{if(!L){_();return}let H;if(O==="between"||O==="not between")H={filterId:e.id,name:e.column,valueType:"date",operation:O,values:p.normalizeDateFilterRange(L,{temporalPrecision:B.temporalPrecision}).values,dataType:e.dataType,...B.temporalPrecision?{temporalPrecision:B.temporalPrecision}:{}};else{const R=L.from||L.to;if(!R){_();return}H={filterId:e.id,name:e.column,valueType:"date",operation:O,values:[R],dataType:e.dataType,...B.temporalPrecision?{temporalPrecision:B.temporalPrecision}:{}}}T(H)},handleRelativeChange:(L,O,B={})=>{if(!L)return;const H=B.temporalPrecision??p.getTemporalPrecisionForRelativeMeta(O),R={filterId:e.id,name:e.column,valueType:"date",operation:"between",values:p.normalizeDateFilterRange(L,{temporalPrecision:H}).values,dataType:e.dataType,relativeMeta:O,...H?{temporalPrecision:H}:{}};T(R)},handleClear:_}},[k,_,e,b.allEligibleTargetsAreDateTime,T]);return l.jsx(z$,{filter:e,managedState:M,inline:n,onApplied:r,supplementalFooter:y&&C?l.jsx(xue,{selection:S,controlLabel:"Global Date",scopeMessage:b.eligibleCardCount>0?`Comparison applies to ${b.eligibleCardCount} of ${b.totalCardCount} date-based visuals.`:"No visuals use Global Date for comparison.",authorControlledCardCount:D,activeDateFilterValue:k,hasRuntimeOverride:E,onChange:A=>g(y,w,A),onReset:()=>x(y,w)}):void 0})}function KQe(e){const t=p.getGlobalDateFilterCoverage(e.dashboard,e.semanticExecutionPayload),n=[];for(const{sheet:r,card:o}of p.getDashboardCardEntries(e.dashboard)){if(!p.dashboardInputRuntimeTargetsShareSlot(e.dashboardInput,e.dashboardInputTarget,{sheetId:r.id,cardId:o.id}))continue;const s=Ti({dashboard:e.dashboard,sheetId:r.id,card:o,runtimeValues:e.runtimeValues,mode:"interactive",timezone:e.timezone}),i=Cb({card:o,dashboard:e.dashboard,interactionStates:e.interactionStates,currentDashboardId:e.dashboard.id,filters:e.dashboard.filters,filterValues:e.runtimeValues.filterValues,selectedSheetId:r.id,inlineFilterValuesMap:e.runtimeValues.inlineFilterValuesMap,dashboardControls:e.dashboard.controls,dashboardControlValues:e.runtimeValues.controlValues,cardControlValuesMap:e.runtimeValues.cardControlValuesMap,dashboardInputContext:s}),a=aw({card:o,cardConfig:i.queryRelevantConfig,input:i.filterCompilationInput,semanticExecutionPayload:e.semanticExecutionPayload,timezone:e.timezone,allowMinutePrecision:t.allEligibleTargetsAreDateTime});a.status!=="blocked"&&n.push({card:o,plan:a.dateComparisonPlan})}return g_e({inputId:e.dashboardInput.id,targets:n})}function GQe(e){const t=[];return e.ownerCardCount>0&&t.push(`Comparison applies to ${e.ownerCardCount} of ${e.matchingCardCount} visuals using this date field.`),e.globalPrecedenceCardCount>0&&t.push(`Global Date controls comparison for ${e.globalPrecedenceCardCount} of those visual${e.globalPrecedenceCardCount===1?"":"s"}.`),e.ambiguousCardCount>0&&t.push(`Comparison is unavailable for ${e.ambiguousCardCount} visual${e.ambiguousCardCount===1?"":"s"} because more than one active filter uses this date field.`),t.length>0?t.join(" "):e.matchingCardCount>0?`Comparison is available for ${e.matchingCardCount} visual${e.matchingCardCount===1?"":"s"} using this date field.`:"No visuals use this date filter for comparison."}function vue({filter:e,storageOptions:t,inline:n,onApplied:r}){var E;const o=p.useDashboardStore(D=>D.dashboard),s=p.useDashboardStore(D=>D.filterValues),i=p.useDashboardStore(D=>D.controlValues),a=p.useDashboardStore(D=>D.dashboardInputValues),c=p.useDashboardStore(D=>D.inlineFilterValuesMap),u=p.useDashboardStore(D=>D.cardControlValuesMap),d=p.useDashboardStore(D=>D.selectedSheetId),f=p.useDashboardStore(D=>D.semanticExecutionPayload),h=p.useInteractionStore(D=>D.interactionStates),{setDashboardInputComparisonSelection:m,resetDashboardInputComparisonSelection:g}=p.useDashboardActions(),x=bl(),b=v.useMemo(()=>{const D=t==null?void 0:t.dashboardInput;return(D==null?void 0:D.kind)==="filter"?D:ja(o,e.id)},[o,e.id,t==null?void 0:t.dashboardInput]),y=v.useMemo(()=>({sheetId:(t==null?void 0:t.sheetId)||d}),[d,t==null?void 0:t.sheetId]),w=!!(b&&p.canAddressDashboardInputRuntimeSlot(b,y)),C=v.useMemo(()=>b&&w?p.hydrateAuthoredDashboardInputSlot({dashboard:o,input:b,runtimeValues:a,target:y,timezone:x}):void 0,[o,b,y,a,w,x]),N=(C==null?void 0:C.status)==="set"&&C.value.kind==="filter"?C.value.filterValue:void 0,S=(t==null?void 0:t.storageTarget)==="dashboardInput"?N:s==null?void 0:s.find(D=>D.filterId===e.id),j=(C==null?void 0:C.comparisonSelection)||{mode:"off"},I=b?w&&((E=p.getDashboardInputRuntimeSlot(a,b,y))==null?void 0:E.comparisonSelection)!==void 0:!1,k=!!(b&&w&&(t==null?void 0:t.storageTarget)!=="card"&&p.isComparisonCapableDashboardDateInput(b)),T=v.useMemo(()=>!b||!k?{ownerCardCount:0,matchingCardCount:0,globalPrecedenceCardCount:0,ambiguousCardCount:0,authorControlledCardCount:0}:KQe({dashboard:o,dashboardInput:b,dashboardInputTarget:y,interactionStates:h,semanticExecutionPayload:f,runtimeValues:{dashboardInputValues:a,filterValues:s,controlValues:i,inlineFilterValuesMap:c,cardControlValuesMap:u},timezone:x}),[u,i,o,b,y,a,s,c,h,k,f,x]),_=v.useMemo(()=>GQe(T),[T]);return l.jsx(z$,{filter:e,storageOptions:t,inline:n,onApplied:r,supplementalFooter:b&&k?l.jsx(xue,{selection:j,controlLabel:b.label||e.title||"date",scopeMessage:_,authorControlledCardCount:T.authorControlledCardCount,activeDateFilterValue:S,hasRuntimeOverride:I,onChange:D=>m(b,y,D),onReset:()=>g(b,y)}):void 0})}function W_({filter:e,storageOptions:t}){var r,o;const n=B$(e,t);return e.kind==="global-date"?l.jsx(yue,{filter:e,storageOptions:n}):(r=e.customFilterPreferences)!=null&&r.url&&((o=e.customFilterPreferences)!=null&&o.componentName)?l.jsx(WQe,{filter:e,storageOptions:n}):p.isDateDataType(e.dataType)?l.jsx(vue,{filter:e,storageOptions:n}):e.uiType==="radio"&&e.type==="single"?l.jsx($ce,{filter:e,storageOptions:n}):e.uiType==="tabs"&&e.type==="single"?l.jsx(zce,{filter:e,storageOptions:n}):l.jsx(Oce,{filter:e,storageOptions:n})}function wue({className:e,message:t="Failed to load options"}){return l.jsx("p",{className:p.cn("px-2 py-2 text-[12px] text-destructive",e),children:t})}function Cue({checked:e,className:t}){return l.jsx("span",{"aria-hidden":"true",className:p.cn("inline-flex h-4 w-4 shrink-0 items-center justify-center rounded-full border bg-background transition-colors",e?"border-primary":"border-input",t),children:e?l.jsx("span",{className:"h-2 w-2 rounded-full bg-primary"}):null})}function YQe({filter:e,storageOptions:t,onApplied:n}){var H;const{filteredRecords:r,selectedRecords:o,handleChange:s,query:i,setQuery:a,isLoading:c,isFetching:u,isPlaceholderData:d,isError:f,isSearching:h,searchError:m,isSingleSelect:g,activeFilterValue:x}=Xb(e,{enableServerSearch:!0,searchDebounceMs:300,minSearchLength:2,searchThreshold:5,...t}),y=`Search ${(e.title||e.column||"options").toLowerCase()}`,[w,C]=v.useState(o),[N,S]=v.useState(!1);v.useEffect(()=>{N||C(o)},[o,N]);const j=v.useMemo(()=>new Set(w.map(R=>R.value)),[w]),I=(x==null?void 0:x.operation)==="is null"||(x==null?void 0:x.operation)==="is not null",k=(((H=x==null?void 0:x.values)==null?void 0:H.length)??0)>0||I,_=c||u&&d,E=R=>{if(g){C([R]),S(!0);return}S(!0),C(V=>V.some(F=>F.value===R.value)?V.filter(F=>F.value!==R.value):[...V,R])},D=(R,V)=>{R.key!=="Enter"&&R.key!==" "||(R.preventDefault(),E(V))},M=r.length>0&&r.every(R=>j.has(R.value)),P=!r.some(R=>j.has(R.value)),A=M?"checked":P?"unchecked":"indeterminate",L=()=>{if(S(!0),A==="checked"){const R=new Set(r.map(V=>V.value));C(V=>V.filter(z=>!R.has(z.value)))}else C(R=>{const V=new Map(R.map(z=>[z.value,z]));return r.forEach(z=>V.set(z.value,z)),Array.from(V.values())})},O=()=>{s(w),S(!1),n==null||n()},B=()=>{C([]),S(!0)};return f?l.jsx(wue,{}):l.jsxs("div",{className:"flex flex-col p-1.5",children:[l.jsxs("div",{className:"mb-1.5 flex h-7 shrink-0 items-center gap-1.5 rounded-control border border-input bg-background px-2 focus-within:border-ring",children:[h?l.jsx(p.LoaderCircle,{className:"h-3 w-3 shrink-0 animate-spin text-muted-foreground","aria-label":"Searching","aria-live":"polite"}):l.jsx(Mt.Search,{className:"h-3 w-3 shrink-0 text-muted-foreground"}),l.jsx("input",{type:"text",value:i,onChange:R=>a(R.target.value),placeholder:y,"aria-label":y,className:"h-full w-full bg-transparent text-[12px] text-foreground placeholder:text-muted-foreground focus:outline-none"}),i&&l.jsx("button",{type:"button",onClick:()=>a(""),"aria-label":"Clear search",className:"inline-flex h-4 w-4 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx(Ie.X,{className:"h-3 w-3"})})]}),m&&l.jsxs("div",{className:"mb-2 flex items-start gap-1.5 rounded-[4px] border border-destructive/30 bg-destructive/5 px-2 py-1 text-[11px] text-destructive",children:[l.jsx(Ia,{className:"mt-0.5 h-3 w-3 shrink-0"}),l.jsx("span",{className:"min-w-0 flex-1 truncate",children:typeof m=="string"?m:"Search failed — showing local results"})]}),l.jsxs("div",{className:"mb-1 flex items-center justify-between gap-2 px-0.5",children:[!g&&l.jsx(Lce,{filter:e,storageOptions:t,compact:!0}),!g&&r.length>0&&l.jsxs("label",{className:"ml-auto inline-flex cursor-pointer items-center gap-1.5 text-[11px] text-muted-foreground",children:[l.jsx("span",{children:"All"}),l.jsx(An,{checked:A==="checked"?!0:A==="indeterminate"?"indeterminate":!1,onCheckedChange:L,"aria-label":"Select all",className:"h-3.5 w-3.5"})]})]}),l.jsx("div",{className:"-mx-0.5 max-h-[260px] overflow-y-auto px-0.5",role:"listbox","aria-multiselectable":!g,children:_?l.jsx("div",{children:Array.from({length:6}).map((R,V)=>{const z=["w-32","w-24","w-40","w-28","w-36","w-20"];return l.jsxs("div",{className:"flex items-center gap-2 px-1.5 py-1","aria-hidden":"true",children:[l.jsx(ei,{className:"h-3.5 w-3.5 shrink-0 rounded-[3px] bg-foreground/[0.06]"}),l.jsx("span",{className:"flex h-5 items-center",children:l.jsx(ei,{className:p.cn("h-3 rounded-[3px] bg-foreground/[0.06]",z[V%z.length])})})]},V)})}):r.length===0?l.jsx("div",{className:"px-2 py-6 text-center text-[12px] text-muted-foreground",children:i?"No matches":"No options"}):r.map(R=>{var F;const V=j.has(R.value),z=((F=R.label)==null?void 0:F.toString())||String(R.value);return l.jsxs("div",{role:"option",tabIndex:0,"aria-selected":V,onClick:()=>E(R),onKeyDown:G=>D(G,R),className:p.cn("flex w-full cursor-pointer select-none items-center gap-2 rounded-[4px] px-1.5 py-1 text-left text-[13px] text-foreground transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/20",V?"bg-muted hover:bg-foreground/[0.08]":"hover:bg-muted"),children:[g?l.jsx(Cue,{checked:V,className:"h-3.5 w-3.5"}):l.jsx(An,{checked:V,className:"pointer-events-none h-3.5 w-3.5",tabIndex:-1,"aria-hidden":"true"}),l.jsx("span",{className:"truncate",children:z})]},`${R.id}:${R.value}`)})}),l.jsxs("div",{className:"mt-1.5 flex items-center justify-between gap-2 border-t border-border pt-1.5",children:[l.jsxs("span",{className:"px-0.5 text-[11px] text-muted-foreground",children:[l.jsx("span",{className:"tabular-nums text-foreground",children:I&&!N&&w.length===0?1:w.length})," ","selected"]}),l.jsxs("div",{className:"flex items-center gap-1",children:[(N||k)&&l.jsx(p.Button,{type:"button",variant:"ghost",size:"xs",className:"h-6 px-2",onClick:B,children:"Clear"}),l.jsx(p.Button,{type:"button",variant:"default",size:"xs",className:"h-6 px-2",onClick:O,disabled:!N,children:"Apply"})]})]})]})}function ZQe({filter:e,onUpdate:t,cardScopeMode:n="editable"}){var E,D;const[r,o]=v.useState(""),s=p.useDashboardStore(M=>M.dashboard.sheets),i=v.useMemo(()=>p.getDashboardSheets(s??[]),[s]),a=p.useDashboardStore(M=>M.selectedSheetId),c=v.useMemo(()=>{const M=[];return i.forEach(P=>{var A;(A=P.frames)==null||A.forEach(L=>{var O;(O=L.cards)==null||O.forEach(B=>{M.push({...B,sheetId:P.id,sheetTitle:P.title||P.id})})})}),M},[i]),u=()=>e.applyToSheetIds!==void 0?"specific-sheets":e.excludeSheetIds!==void 0?"all-except-specific":"all-sheets",d=()=>e.applyToCardIds!==void 0?"specific-cards":e.excludeCardIds!==void 0?"all-except-specific":"all-cards",f=M=>{const P={};switch(M){case"all-sheets":P.applyToSheetIds=void 0,P.excludeSheetIds=void 0;break;case"specific-sheets":P.applyToSheetIds=[],P.excludeSheetIds=void 0;break;case"all-except-specific":P.applyToSheetIds=void 0,P.excludeSheetIds=[];break}t(P)},h=M=>{const P={};switch(M){case"all-cards":P.applyToCardIds=void 0,P.excludeCardIds=void 0;break;case"specific-cards":P.applyToCardIds=[],P.excludeCardIds=void 0;break;case"all-except-specific":P.applyToCardIds=void 0,P.excludeCardIds=[];break}t(P)},m=(M,P)=>{if(P==="specific-sheets"){const A=e.applyToSheetIds||[];t({applyToSheetIds:A.includes(M)?A.filter(L=>L!==M):[...A,M]})}else if(P==="all-except-specific"){const A=e.excludeSheetIds||[];t({excludeSheetIds:A.includes(M)?A.filter(L=>L!==M):[...A,M]})}},g=(M,P)=>{if(P==="specific-cards"){const A=e.applyToCardIds||[];t({applyToCardIds:A.includes(M)?A.filter(L=>L!==M):[...A,M]})}else if(P==="all-except-specific"){const A=e.excludeCardIds||[];t({excludeCardIds:A.includes(M)?A.filter(L=>L!==M):[...A,M]})}},x=v.useMemo(()=>e.applyToSheetIds!==void 0?e.applyToSheetIds:e.excludeSheetIds!==void 0?i.filter(M=>{var P;return!((P=e.excludeSheetIds)!=null&&P.includes(M.id))}).map(M=>M.id):i.map(M=>M.id),[i,e.applyToSheetIds,e.excludeSheetIds]),b=v.useMemo(()=>c.filter(M=>x.includes(M.sheetId)),[c,x]),y=v.useMemo(()=>{if(!r.trim())return b;const M=r.toLowerCase();return b.filter(P=>{var A;return(A=P==null?void 0:P.title)==null?void 0:A.toLowerCase().includes(M)})},[r,b]),w=u(),C=d(),N=(E=w==="specific-sheets"?e.applyToSheetIds:e.excludeSheetIds)==null?void 0:E.length,S=(D=C==="specific-cards"?e.applyToCardIds:e.excludeCardIds)==null?void 0:D.length,j=w==="all-sheets"?`Shows on every sheet (${i.length} total).`:w==="specific-sheets"?`Shows only on the checked sheets (${N??0} checked).`:`Shows everywhere except the checked sheets (${N??0} checked).`,I=C==="all-cards"?`Applies to every card in the sheets above (${b.length} total).`:C==="specific-cards"?`Applies only to the checked cards (${S??0} checked).`:`Applies to everything except the checked cards (${S??0} checked).`,k=(M,P,A)=>l.jsx(p.Tabs,{value:M,onValueChange:P,children:l.jsx(p.TabsList,{className:"grid h-8 w-full grid-cols-3 overflow-hidden rounded-control p-0.5",children:A.map(L=>l.jsx(p.TabsTrigger,{value:L.value,"aria-label":L.ariaLabel,className:"h-7 text-[12px] leading-none",children:L.label},L.value))})}),T=M=>{const P=(M==="specific-sheets"?e.applyToSheetIds:e.excludeSheetIds)||[];return l.jsx("div",{className:"max-h-44 overflow-y-auto rounded-control border border-border/60 p-1",children:i.map(A=>{const L=M==="specific-sheets"?`sheet-${A.id}`:`sheet-exclude-${A.id}`;return l.jsxs("label",{htmlFor:L,className:"flex cursor-pointer items-center gap-2 rounded-[4px] px-1.5 py-1 hover:bg-muted/50",children:[l.jsx(An,{id:L,checked:P.includes(A.id),onCheckedChange:()=>m(A.id,M),className:"h-3.5 w-3.5"}),l.jsx("span",{className:"truncate text-[13px] text-foreground",children:A.title||A.id}),A.id===a&&l.jsx("span",{className:"text-[11px] text-muted-foreground",children:"· current"})]},A.id)})})},_=M=>{const P=(M==="specific-cards"?e.applyToCardIds:e.excludeCardIds)||[];return l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Input,{size:"xs",placeholder:"Search cards…",value:r,onChange:A=>o(A.target.value)}),l.jsx("div",{className:"max-h-44 overflow-y-auto rounded-control border border-border/60 p-1",children:y.length>0?y.map(A=>{const L=M==="specific-cards"?`card-${A.id}`:`card-exclude-${A.id}`;return l.jsxs("label",{htmlFor:L,className:"flex cursor-pointer items-center gap-2 rounded-[4px] px-1.5 py-1 hover:bg-muted/50",children:[l.jsx(An,{id:L,checked:P.includes(A.id),onCheckedChange:()=>g(A.id,M),className:"h-3.5 w-3.5"}),l.jsx("span",{className:"min-w-0 flex-1 truncate text-[13px] text-foreground",children:A.title}),l.jsx("span",{className:"max-w-[40%] truncate text-[11px] text-muted-foreground",children:A.sheetTitle})]},A.id)}):l.jsxs("p",{className:"py-4 text-center text-[12px] text-muted-foreground",children:["No cards match “",r,"”."]})})]})};return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("section",{className:"space-y-1.5",children:[l.jsx("h4",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Sheet scope"}),k(w,M=>f(M),[{value:"all-sheets",label:"All sheets",ariaLabel:"All sheets"},{value:"specific-sheets",label:"Only specific",ariaLabel:"Only specific sheets"},{value:"all-except-specific",label:"All except",ariaLabel:"All except specific sheets"}]),l.jsx("p",{className:"text-[11px] leading-4 text-muted-foreground",children:j}),w!=="all-sheets"&&T(w)]}),l.jsxs("section",{className:"space-y-1.5 border-t border-border/60 pt-3",hidden:n==="mapping",children:[l.jsx("h4",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Card scope"}),k(C,M=>h(M),[{value:"all-cards",label:"All cards",ariaLabel:"All cards"},{value:"specific-cards",label:"Only specific",ariaLabel:"Only specific cards"},{value:"all-except-specific",label:"All except",ariaLabel:"All except specific cards"}]),l.jsxs("p",{className:"text-[11px] leading-4 text-muted-foreground",children:[I," Restricted to cards in the sheets selected above."]}),C!=="all-cards"&&_(C)]})]})}function K_(e,t){if(e==null)return{};var n={},r=Object.keys(e),o,s;for(s=0;s<r.length;s++)o=r[s],!(t.indexOf(o)>=0)&&(n[o]=e[o]);return n}var XQe=["color"],QQe=v.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=K_(e,XQe);return v.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o,{ref:t}),v.createElement("path",{d:"M7.5 2C7.77614 2 8 2.22386 8 2.5L8 11.2929L11.1464 8.14645C11.3417 7.95118 11.6583 7.95118 11.8536 8.14645C12.0488 8.34171 12.0488 8.65829 11.8536 8.85355L7.85355 12.8536C7.75979 12.9473 7.63261 13 7.5 13C7.36739 13 7.24021 12.9473 7.14645 12.8536L3.14645 8.85355C2.95118 8.65829 2.95118 8.34171 3.14645 8.14645C3.34171 7.95118 3.65829 7.95118 3.85355 8.14645L7 11.2929L7 2.5C7 2.22386 7.22386 2 7.5 2Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),JQe=["color"],eJe=v.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=K_(e,JQe);return v.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o,{ref:t}),v.createElement("path",{d:"M7.14645 2.14645C7.34171 1.95118 7.65829 1.95118 7.85355 2.14645L11.8536 6.14645C12.0488 6.34171 12.0488 6.65829 11.8536 6.85355C11.6583 7.04882 11.3417 7.04882 11.1464 6.85355L8 3.70711L8 12.5C8 12.7761 7.77614 13 7.5 13C7.22386 13 7 12.7761 7 12.5L7 3.70711L3.85355 6.85355C3.65829 7.04882 3.34171 7.04882 3.14645 6.85355C2.95118 6.65829 2.95118 6.34171 3.14645 6.14645L7.14645 2.14645Z",fill:r,fillRule:"evenodd",clipRule:"evenodd"}))}),tJe=["color"],nJe=v.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=K_(e,tJe);return v.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o,{ref:t}),v.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"}))}),rJe=["color"],oJe=v.forwardRef(function(e,t){var n=e.color,r=n===void 0?"currentColor":n,o=K_(e,rJe);return v.createElement("svg",Object.assign({width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg"},o,{ref:t}),v.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 zd({text:e,className:t,ariaLabel:n,onCopy:r,disabled:o=!1,label:s,copiedLabel:i="Copied",showIcon:a=!0,variant:c="ghost",size:u}){const[d,f]=v.useState(!1),h=!!s,m=v.useRef(void 0);return v.useEffect(()=>()=>{m.current&&clearTimeout(m.current)},[]),l.jsxs(p.Button,{className:p.cn(!h&&"h-7 w-fit px-1 font-mono text-xs text-muted-foreground/70",t),variant:c,size:u??(h?"xs":"icon"),"aria-label":n,disabled:o,onClick:async()=>{try{let g=!1;if(r)g=await r();else if(typeof e=="string"){if(typeof navigator>"u"||!navigator.clipboard)return;await navigator.clipboard.writeText(e),g=!0}if(!g)return;f(!0),m.current&&clearTimeout(m.current),m.current=setTimeout(()=>{f(!1),m.current=void 0},1e3)}catch(g){console.error("Failed to copy text",g)}},children:[a?d?l.jsx(nJe,{className:"size-3.5"}):l.jsx(rm,{className:"size-3.5"}):null,h?l.jsx("span",{children:d?i:s}):null]})}function Sue(){const{authToken:e,tokenProps:t}=It(),{data:n,isLoading:r,isFetching:o,isError:s}=qn({queryKey:["plugins",e==null?void 0:e.accessToken],queryFn:()=>p.getPlugins(t.apiServiceUrl,e==null?void 0:e.accessToken)});return{data:n,isLoading:r,isFetching:o,isError:s}}function V$(){const{data:e,isLoading:t,isError:n}=Sue(),r=Fm({queries:((e==null?void 0:e.plugins)||[]).map(c=>({queryKey:["manifest",c.value],queryFn:()=>Ale(c.value),enabled:!!c.value,staleTime:5*60*1e3,gcTime:10*60*1e3,retry:2,retryDelay:u=>Math.min(1e3*2**u,3e4)}))}),o=[],s=[];let i=t,a=n;return r.forEach((c,u)=>{var d;if(c.isLoading&&(i=!0),c.isError&&(a=!0),c.data&&((d=e==null?void 0:e.plugins)!=null&&d[u])){const f=e.plugins[u],h=c.data.visuals.map(m=>({name:m.name,pluginName:f.label,componentType:m.componentType,pluginType:f.type,icon:m.icon,chartType:m.chartType,visualType:m.visualType||(m.dataInputs&&m.dataInputs.length>1?"multiple":"single"),minInputs:m.minInputs,maxInputs:m.maxInputs,slots:m.slots,url:f.value}));if(o.push(...h),c.data.filters){const m=c.data.filters.map(g=>({name:g.name,component:g.component,pluginName:f.label,pluginType:f.type,icon:g.icon,filterType:g.filterType,supportedDataTypes:g.supportedDataTypes,url:f.value}));s.push(...m)}}}),{data:o,filters:s,isLoading:i,isError:a}}function sJe(e){const[t,n]=v.useState(null);return t}function iJe({pluginFilter:e}){const t=sJe(e.icon||""),n=e.name.charAt(0).toUpperCase();return l.jsxs("div",{className:"flex items-center gap-2",children:[t?l.jsx(t,{className:"h-4 w-4"}):l.jsx("div",{className:"flex h-4 w-4 items-center justify-center rounded bg-muted text-xs font-medium",children:n}),l.jsx("span",{children:e.name}),l.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",e.pluginName,")"]})]})}function aJe({filter:e,onSelect:t,onClear:n}){const{filters:r,isLoading:o}=V$(),s=p.getDataType(e.dataType),i=r==null?void 0:r.filter(u=>!u.supportedDataTypes||u.supportedDataTypes.length===0?!0:u.supportedDataTypes.some(d=>s.toLowerCase()===d.toLowerCase())),a=e.customFilterPreferences,c=a?`${a.url}::${a.componentName}`:"";return o?l.jsx("div",{className:"flex h-7 items-center rounded-control border border-input bg-background px-2 text-[12px] text-muted-foreground",children:"Checking available custom filters…"}):!i||i.length===0?l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"No custom filters available."}):l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsxs(p.Select,{value:c,onValueChange:u=>{if(!u)return;const[d,f]=u.split("::"),h=i.find(m=>m.url===d&&m.component===f);h&&t({url:d,componentName:h.component,pluginFilterType:h.filterType,icon:h.icon})},children:[l.jsx(p.SelectTrigger,{className:"h-9 flex-1",children:l.jsx(p.SelectValue,{placeholder:"Use default UI"})}),l.jsx(p.SelectContent,{children:i.map(u=>l.jsx(p.SelectItem,{value:`${u.url}::${u.component}`,children:l.jsx(iJe,{pluginFilter:u})},`${u.url}::${u.component}`))})]}),a&&l.jsx(p.Button,{variant:"ghost",size:"sm",className:"h-9 w-9 p-0",onClick:n,title:"Clear custom filter selection",children:l.jsx(Ie.X,{className:"h-4 w-4"})})]})}function Nue(e){if((e==null?void 0:e.mode)!=="period")return;const t=e.spec;if(t.kind==="previous_year"){const r=t.offsetYears??1;return r===1?"vs previous year":`vs ${r} years ago`}const n=t.offsetPeriods??1;return n===1?"vs previous period":`vs ${n} periods ago`}function lJe(e){for(const[n,r]of Object.entries(p.presetMetadata))if(JSON.stringify(r)===JSON.stringify(e))return n;const t={minute:"minute",hour:"hour",day:"day",week:"week",month:"month",quarter:"quarter",year:"year"};switch(e.mode){case"last":{const n=e.complete?" (complete)":"",r=e.n>1?"s":"";return`Last ${e.n} ${t[e.unit]}${r}${n}`}case"this":{if(e.boundary==="first_day")return"First day of the month";if(e.boundary==="last_day")return"Last day of the month";const n=e.toDate?" to date":"";return`This ${t[e.unit]}${n}`}case"previous":return`Previous ${t[e.unit]}`;case"between":return`Between ${e.from} and ${e.to} ${t[e.unit]}s`}}const bU=["January","February","March","April","May","June","July","August","September","October","November","December"];function cJe(e){if(p.isFixedMonthDefaultDateFilter(e))return`${bU[e.month]} ${e.year}`;if(p.isFixedDayDefaultDateFilter(e)){const[t,n,r]=e.date.split("-").map(Number);return`${bU[n-1]} ${r}, ${t}`}return lJe(e)}function _M(e){return e&&p.isRelativeDateFilter(e)?"relative":"fixed"}function uJe(e){return`${typeof e}:${String(e)}`}function G_(e){return"kind"in e&&e.kind==="global-date"}function KS(e){return G_(e)?p.DEFAULT_GLOBAL_DATE_FILTER_TITLE:e.column}function dJe({selection:e,controlLabel:t,onChange:n}){return l.jsxs("div",{className:"space-y-2 border-t border-border px-2 py-2.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Compare"}),l.jsx(bue,{selection:e,controlLabel:t,onChange:n})]})}function fJe({filter:e,onUpdate:t,showFilterId:n=!0,filterOptionsData:r,optionLabelFieldName:o,timezone:s,variant:i="dashboard",defaultComparisonSelection:a,onDefaultComparisonChange:c,onDefaultDatePickerOpenChange:u,afterLabelSlot:d}){var G;const f=G_(e),[h,m]=v.useState(e.title===KS(e)?"":e.title||""),[g,x]=v.useState(e.defaultValues||[]),[b,y]=v.useState(e.defaultDateFilter),[w,C]=v.useState(_M(e.defaultDateFilter)),[N,S]=v.useState(e.targetColumns||[]),j=(G=e.column.split(".").pop())==null?void 0:G.replace(/"/g,""),I=((r==null?void 0:r.records)||[]).flatMap(q=>{const Y=j?q[j]:q.value;if(Y==null||!["string","number","boolean"].includes(typeof Y))return[];const K=o?q[o]:void 0;return[{key:`${typeof Y}:${String(Y)}`,value:Y,label:String(K??Y)}]}),k=v.useMemo(()=>p.getDataType(e.dataType)==="date",[e.dataType]),T=s||Intl.DateTimeFormat().resolvedOptions().timeZone,_=i==="inline"||i==="document"?"z-[80]":void 0,E=a&&c?l.jsx(dJe,{selection:a,controlLabel:e.title||"Date",onChange:c}):void 0,D=Nue(a),M=v.useMemo(()=>{if(!b)return;const q=p.resolveDefaultDateFilterForDefaults(b,T);if(!q)return;const[Y,K]=q;return{from:Y,to:K}},[b,T]),P=v.useMemo(()=>{if(b&&p.isFixedMonthDefaultDateFilter(b))return{year:b.year,month:b.month}},[b]),A=v.useMemo(()=>{if(!(!b||!p.isRelativeDateFilter(b)))return b},[b]),L=v.useMemo(()=>{if(!(!b||!p.isFixedDayDefaultDateFilter(b)))return X2.fromZonedTime(`${b.date}T00:00:00`,T)},[b,T]);v.useEffect(()=>{m(e.title===KS(e)?"":e.title||""),x(e.defaultValues||[]);const q=e.defaultDateFilter;y(q),C(_M(q)),S(e.targetColumns||[])},[e]);function O(){const q=h.trim();t({title:q||KS(e)})}function B(q){x(q),t({defaultValues:q.length?q:void 0})}function H(q){y(q),q&&C(_M(q)),t({defaultDateFilter:q})}function R(q){S(q),t({targetColumns:q.length>0?q:void 0})}function V(){R([...N,{column:"",label:""}])}function z(q){const Y=N.filter((K,$)=>$!==q);R(Y)}function F(q,Y,K){const $=N.map((X,W)=>W===q?{...X,[Y]:K}:X);R($)}return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center justify-between gap-3",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Display Label"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsxs("div",{className:"space-y-2",children:[l.jsx("p",{className:"text-[12px]",children:"Leave empty to use the column name. Provide a custom label to override it."}),n&&l.jsxs("div",{className:"space-y-1 border-t pt-2",children:[l.jsx("p",{className:"text-[12px] font-medium",children:"Filter ID"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("p",{className:"break-all font-mono text-xs text-muted-foreground",children:e.id}),l.jsx(zd,{text:e.id})]})]})]})})]})})]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[l.jsx(An,{id:"hideLabel",checked:e.showLabel===!1,onCheckedChange:q=>{t({showLabel:!q})}}),l.jsx(p.Label,{htmlFor:"hideLabel",className:"cursor-pointer text-[11px] text-muted-foreground",children:"Hide label"})]})]}),l.jsx(p.Input,{size:"xs",value:h,onChange:q=>m(q.target.value),onBlur:O,placeholder:KS(e)})]}),d,k?l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Default Date Filter"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:"Sets the initial date selection on load and previews it immediately while editing. Relative defaults recalculate on each load and scheduled execution, while fixed month defaults stay unchanged."})})]})})]}),e.dateSelectionMode==="months"?l.jsxs(p.Tabs,{value:w,onValueChange:q=>C(q),className:"space-y-2",children:[l.jsxs(p.TabsList,{className:"grid h-8 w-full grid-cols-2 overflow-hidden rounded-control p-0.5",children:[l.jsx(p.TabsTrigger,{value:"fixed",className:"h-7 text-[12px] leading-none",children:"Fixed"}),l.jsx(p.TabsTrigger,{value:"relative",className:"h-7 text-[12px] leading-none",children:"Relative"})]}),l.jsx(p.TabsContent,{value:"fixed",className:"mt-0",children:l.jsx(fue,{value:P,placeholder:"Select default month...",className:"w-full",onClear:()=>H(void 0),onChange:(q,Y)=>H({mode:"fixed",unit:"month",year:q,month:Y})})}),l.jsx(p.TabsContent,{value:"relative",className:"mt-0",children:l.jsxs(p.Select,{value:A?JSON.stringify(A):"__none__",onValueChange:q=>{if(q==="__none__"){H(void 0);return}try{const Y=JSON.parse(q);H(Y)}catch(Y){console.error("Failed to parse relative date filter",Y)}},children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{placeholder:"Select default month range..."})}),l.jsxs(p.SelectContent,{className:_,children:[l.jsx(p.SelectItem,{value:"__none__",children:"None"}),l.jsx(p.SelectItem,{value:JSON.stringify({mode:"this",unit:"month"}),children:"This month"}),l.jsx(p.SelectItem,{value:JSON.stringify({mode:"previous",unit:"month"}),children:"Last month"})]})]})})]}):e.dateSelectionMode==="day"?l.jsxs(p.Tabs,{value:w,onValueChange:q=>C(q),className:"space-y-2",children:[l.jsxs(p.TabsList,{className:"grid h-8 w-full grid-cols-2 overflow-hidden rounded-control p-0.5",children:[l.jsx(p.TabsTrigger,{value:"fixed",className:"h-7 text-[12px] leading-none",children:"Fixed"}),l.jsx(p.TabsTrigger,{value:"relative",className:"h-7 text-[12px] leading-none",children:"Relative"})]}),l.jsx(p.TabsContent,{value:"fixed",className:"mt-0",children:l.jsx(pue,{value:L,timezone:T,placeholder:"Select default date...",className:"w-full",buttonClassName:"h-7 text-[12px]",showPresets:!1,onClear:()=>H(void 0),onSelect:q=>H({mode:"fixed",unit:"day",date:q})})}),l.jsx(p.TabsContent,{value:"relative",className:"mt-0",children:l.jsxs(p.Select,{value:A?JSON.stringify(A):"__none__",onValueChange:q=>{if(q==="__none__"){H(void 0);return}try{const Y=JSON.parse(q);H(Y)}catch(Y){console.error("Failed to parse relative date filter",Y)}},children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{placeholder:"Select default day..."})}),l.jsxs(p.SelectContent,{className:_,children:[l.jsx(p.SelectItem,{value:"__none__",children:"None"}),l.jsx(p.SelectItem,{value:JSON.stringify({mode:"this",unit:"day"}),children:"Today"}),l.jsx(p.SelectItem,{value:JSON.stringify({mode:"previous",unit:"day"}),children:"Yesterday"})]})]})})]}):l.jsx($$,{value:M,relativeValue:p.isRelativeDateFilter(b)?b:void 0,onRelativeSelect:(q,Y)=>{H(Y)},showRelativeTab:!0,hideCalendar:!0,timezone:T,placeholder:"Select default date range…",buttonClassName:"h-7 text-[12px]",buttonLabelSuffix:D,contentClassName:_,overlayContentClassName:_,supplementalFooter:E,onOpenChange:u}),b&&l.jsx("div",{className:"flex items-center gap-2",children:l.jsxs("span",{className:"inline-flex items-center gap-1 rounded-[4px] bg-muted px-1.5 py-0.5 text-[11px] text-foreground",children:[cJe(b),l.jsx("button",{type:"button",className:"-mr-px flex h-3 w-3 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground",onClick:()=>H(void 0),"aria-label":"Clear default date",children:l.jsx(Ie.X,{className:"h-3 w-3"})})]})}),e.dateSelectionMode==="months"||e.dateSelectionMode==="day"?E:null]}):l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Default Values"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:"Sets the initial selection on load and previews it immediately while editing. Works like a filter selection."})})]})})]}),I.length>0?l.jsxs(p.Select,{value:"",onValueChange:q=>{const Y=I.find(K=>K.key===q);Y&&!g.some(K=>Object.is(K,Y.value))&&B([...g,Y.value])},children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{placeholder:"Select values to add..."})}),l.jsxs(p.SelectContent,{className:_,children:[I.filter(q=>!g.some(Y=>Object.is(Y,q.value))).map(q=>l.jsx(p.SelectItem,{value:q.key,children:q.label},q.key)),I.every(q=>g.some(Y=>Object.is(Y,q.value)))&&l.jsx("div",{className:"px-2 py-1.5 text-xs text-muted-foreground",children:"All values selected"})]})]}):l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Loading filter options…"}),g.length>0&&l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:["Selected · ",g.length]}),l.jsx("div",{className:"flex flex-wrap gap-1",children:g.map(q=>{var Y,K;return l.jsxs("span",{className:"inline-flex items-center gap-1 rounded-[4px] bg-muted px-1.5 py-0.5 text-[11px] text-foreground",children:[((Y=I.find($=>Object.is($.value,q)))==null?void 0:Y.label)??String(q),l.jsx("button",{type:"button",className:"-mr-px flex h-3 w-3 items-center justify-center rounded-sm text-muted-foreground hover:text-foreground",onClick:()=>{B(g.filter($=>!Object.is($,q)))},"aria-label":`Remove ${((K=I.find($=>Object.is($.value,q)))==null?void 0:K.label)??String(q)}`,children:l.jsx(Ie.X,{className:"h-3 w-3"})})]},uJe(q))})})]})]}),k&&!f&&l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Target Columns"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:"Add multiple date columns to let users choose which field to filter at runtime. Leave empty to use only the primary column above."})})]})})]}),N.length>0&&l.jsx("div",{className:"space-y-2",children:N.map((q,Y)=>l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Input,{size:"xs",placeholder:"Column name",value:q.column,onChange:K=>F(Y,"column",K.target.value),className:"flex-1 font-mono"}),l.jsx(p.Input,{size:"xs",placeholder:"Label",value:q.label,onChange:K=>F(Y,"label",K.target.value),className:"flex-1"}),l.jsx(p.Button,{variant:"ghost",size:"xs",className:"w-7 shrink-0 px-0 text-muted-foreground hover:text-foreground",onClick:()=>z(Y),"aria-label":"Remove target column",children:l.jsx(Ie.X,{className:"h-3.5 w-3.5"})})]},Y))}),l.jsxs(p.Button,{variant:"outline",size:"xs",onClick:V,children:[l.jsx(Mr,{className:"h-3.5 w-3.5"}),"Add column"]})]})]})}function hJe({variableName:e,reservedVariableNames:t=[],onUpdateInputMetadata:n}){const[r,o]=v.useState(e||""),[s,i]=v.useState(null);v.useEffect(()=>{o(e||""),i(null)},[e]);function a(){if(!n||e===void 0)return;const c=r.trim();if(!c){o(e),i(null);return}const u=p.normalizeDashboardInputVariableName(c);if(u!==e&&t.includes(u)){i(`"${u}" is already used by another input.`);return}i(null),o(u),u!==e&&n({variableName:u})}return e===void 0||!n?null:l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Variable name"}),l.jsx(p.Input,{size:"xs",value:r,onChange:c=>o(c.target.value),onBlur:a,"aria-invalid":!!s,placeholder:"input_name"}),s?l.jsx("p",{className:"text-[10px] leading-3 text-destructive",children:s}):null]})}function mJe({filter:e,onUpdate:t,variant:n="dashboard"}){const r=G_(e),{filters:o,isLoading:s}=V$(),i=v.useMemo(()=>p.getDataType(e.dataType)==="date",[e.dataType]),a=n==="inline"||n==="document"?"z-[80]":void 0,c=v.useMemo(()=>{const x=p.getDataType(e.dataType);return(o==null?void 0:o.filter(b=>!b.supportedDataTypes||b.supportedDataTypes.length===0?!0:b.supportedDataTypes.some(y=>x.toLowerCase()===y.toLowerCase())))??[]},[e.dataType,o]),u=!r&&(s||!!e.customFilterPreferences||c.length>0);function d(x){t({type:x})}function f(x){const b=e.defaultDateFilter;if(x==="day"&&b&&!p.isSingleDayDefaultDateFilter(b)){t({dateSelectionMode:x,defaultDateFilter:void 0});return}t({dateSelectionMode:x})}function h(x){t({uiType:x})}function m(x){t({customFilterPreferences:x})}function g(){t({customFilterPreferences:void 0})}return l.jsxs("div",{className:"space-y-4",children:[i?l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date Picker Type"}),l.jsxs(p.Select,{value:e.dateSelectionMode||"range",onValueChange:x=>f(x),children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{})}),l.jsxs(p.SelectContent,{className:a,children:[l.jsx(p.SelectItem,{value:"range",children:"Date Range Picker"}),l.jsx(p.SelectItem,{value:"months",children:"Month Picker"}),l.jsx(p.SelectItem,{value:"day",children:"Day Picker"})]})]})]}):l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Selection Type"}),l.jsx(p.Tabs,{value:e.type||"multiple",onValueChange:x=>d(x),children:l.jsxs(p.TabsList,{className:"grid h-8 w-full grid-cols-2 overflow-hidden rounded-control p-0.5",children:[l.jsx(p.TabsTrigger,{value:"multiple",className:"h-7 text-[12px] leading-none",children:"Multiple"}),l.jsx(p.TabsTrigger,{value:"single",className:"h-7 text-[12px] leading-none",children:"Single"})]})})]}),!i&&e.type==="single"&&l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"UI Component"}),l.jsxs(p.Select,{value:e.uiType||"dropdown",onValueChange:h,children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{})}),l.jsxs(p.SelectContent,{className:a,children:[l.jsx(p.SelectItem,{value:"dropdown",children:"Dropdown"}),l.jsx(p.SelectItem,{value:"radio",children:"Radio"}),l.jsx(p.SelectItem,{value:"tabs",children:"Tabs"})]})]})]}),u&&l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Custom Filter Component"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:"Select a custom filter component from an installed plugin to replace the default filter UI with a custom implementation."})})]})})]}),l.jsx(aJe,{filter:e,onSelect:m,onClear:g})]}),n==="dashboard"&&l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Display Mode"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:`Choose how this filter is displayed. "Inherit" uses the dashboard's default setting. Override with "Canvas Card" or "Toolbar" to always display this filter in a specific mode.`})})]})})]}),l.jsxs(p.Select,{value:e.displayMode||"inherit",onValueChange:x=>t({displayMode:x}),children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{})}),l.jsxs(p.SelectContent,{children:[l.jsx(p.SelectItem,{value:"inherit",children:"Inherit (use dashboard default)"}),l.jsx(p.SelectItem,{value:"canvas",children:"Canvas Card"}),l.jsx(p.SelectItem,{value:"toolbar",children:"Toolbar"})]})]})]}),n==="inline"&&l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Width (px)"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:"Set the width of this inline filter in pixels. Default is 250px."})})]})})]}),l.jsx(p.Input,{size:"xs",type:"number",min:100,max:500,value:e.width??250,onChange:x=>{const b=parseInt(x.target.value,10);isNaN(b)||t({width:b})},className:"w-24"})]})]})}function pJe({filter:e,onUpdate:t}){const[n,r]=v.useState(e.column);v.useEffect(()=>{r(e.column)},[e.column]);function o(){const s=n.trim();if(s&&s!==e.column){const i=!e.title||e.title===e.column;t(i?{column:s,title:s}:{column:s})}}return l.jsx(p.Input,{size:"xs",value:n,onChange:s=>r(s.target.value),onBlur:o,placeholder:"Enter column name",className:"font-mono"})}function gJe({filter:e,onUpdate:t,variant:n="dashboard"}){return G_(e)?l.jsx("div",{className:"rounded-control border border-border/60 bg-muted/30 p-3 text-[12px] text-muted-foreground",children:"Global date filters are not bound to a specific column. Configure the picker type, layout, and scope in the other tabs."}):l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Filter column name"}),l.jsx(pJe,{filter:e,onUpdate:t})]}),l.jsx(bJe,{filter:e,onUpdate:t,variant:n})]})}function bJe({filter:e,onUpdate:t,variant:n="dashboard"}){const[r,o]=v.useState(e.sql),[s,i]=v.useState(e.searchMode||"auto"),a=n==="inline"||n==="document"?"z-[80]":void 0;v.useEffect(()=>{o(e.sql),i(e.searchMode||"auto")},[e]);function c(){t({sql:r})}function u(d){i(d),t({searchMode:d})}return l.jsxs("div",{className:"space-y-4",children:[p.isNumberDataType(e.dataType)&&l.jsxs("div",{className:"space-y-1",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Search Mode"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsxs("div",{className:"space-y-2 text-xs",children:[l.jsxs("p",{children:[l.jsx("strong",{children:"Text Search:"}),' Treats numbers as text (e.g., ZIP codes, IDs). Search for "90210".']}),l.jsxs("p",{children:[l.jsx("strong",{children:"Numeric Operators:"})," Supports comparison operators (e.g., >100, <=50, =100) for quantities, prices."]}),l.jsxs("p",{children:[l.jsx("strong",{children:"Auto-detect:"})," Tries numeric first, falls back to text search."]})]})})]})})]}),l.jsxs(p.Select,{value:s,onValueChange:u,children:[l.jsx(p.SelectTrigger,{size:"xs",children:l.jsx(p.SelectValue,{})}),l.jsxs(p.SelectContent,{className:a,children:[l.jsx(p.SelectItem,{value:"text",children:"Text Search"}),l.jsx(p.SelectItem,{value:"numeric",children:"Numeric Operators"}),l.jsx(p.SelectItem,{value:"auto",children:"Auto-detect"})]})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-1.5",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Filter values custom SQL"}),l.jsx(p.TooltipProvider,{children:l.jsxs(p.Tooltip,{delayDuration:0,children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Info,{className:"h-3.5 w-3.5 cursor-help text-muted-foreground"})}),l.jsx(p.TooltipContent,{side:"right",className:"max-w-xs",children:l.jsx("p",{className:"text-[12px]",children:"This SQL will be used to fetch the filter values"})})]})})]}),l.jsx("div",{className:"h-36 w-full overflow-hidden rounded-control border border-input",onBlur:c,onKeyDown:d=>d.stopPropagation(),children:l.jsx(p.CodeEditor,{value:r,onValueChange:o,language:"sql-jinja",embedded:!0,hideLineNumbers:!0,dense:!0,ariaLabel:"Filter values custom SQL",placeholder:`SELECT ${e.column.split(".").pop()||"value"} FROM ... {{ filters | where }}`})})]})]})}function xU(e){return Object.fromEntries(Object.entries(e).filter(t=>typeof t[1]=="string"&&t[1].length>0))}function ju(e){return e.kind==="semantic"?[e.kind,e.domainId,e.datasetId||"",e.datasetName||"",e.connectionId||""].join(":"):[e.kind,e.connectionId,e.databaseName||"",e.schemaName||"",e.tableName].join(":")}function jue(e){return e.kind==="semantic"?xU({connection_id:e.connectionId,domain_id:e.domainId,dataset_id:e.datasetId,dataset_name:e.datasetName}):xU({connection_id:e.connectionId,datamodel_id:"",database_name:e.databaseName,schema_name:e.schemaName,table_name:e.tableName})}function xJe(e,t){const n=new Map;for(const{card:r,sheet:o}of p.getDashboardCardEntries(e)){if(o.kind==="document"||(t==null?void 0:t.kind)==="sheets"&&!t.sheetIds.includes(o.id))continue;const s=Zs.buildDashboardCardSourceIndex(r),i=s.kind==="config"?s.executableSources:s.kind==="sql"?s.pinnedCatalogSources.map(a=>a.source):[];for(const a of i){const c=ju(a);n.has(c)||n.set(c,{key:c,source:a,request:jue(a)})}}return Array.from(n.values())}function yJe(e,t){var o,s;const n=(o=t.column_name)==null?void 0:o.trim(),r=Or.normalizeAnalyticsCatalogDataType(t.data_type);if(!(!n||r==="unknown"))return{kind:"field",field:{name:n,source:{...e},dataType:r,...(s=t.sourceField)!=null&&s.trim()?{sourceField:t.sourceField.trim()}:{}}}}function vJe(e){var n;const t={};for(const{card:r,sheet:o}of p.getDashboardCardEntries(e.dashboard)){if(o.kind==="document"||((n=e.outerScope)==null?void 0:n.kind)==="sheets"&&!e.outerScope.sheetIds.includes(o.id))continue;const s=Zs.buildDashboardCardSourceIndex(r),i=s.kind==="config"?s.executableSources:s.kind==="sql"?s.pinnedCatalogSources.map(u=>u.source):[];if(!i.length)continue;const a=[];let c;for(const u of i){const d=e.metadataBySourceKey.get(ju(u));if(!d||d.status==="unavailable"){c=(d==null?void 0:d.status)==="unavailable"?d.message:"Field metadata is not available yet.";break}for(const f of d.columns){const h=yJe(u,f);h&&a.push(h)}}t[r.id]=c?{status:"metadataUnavailable",message:c}:{status:"ready",targets:a}}return t}const kue=7;function Bj(e){return[ju(e.field.source),e.field.name,e.field.sourceField||""].join("::")}function Q1(e){const t=e.field.source;return t.kind==="semantic"?t.label||t.datasetName||t.datasetId||"Dataset":[t.schemaName,t.tableName].filter(Boolean).join(".")}function wJe(e){switch(e.status){case"suggested":return{label:"Auto",className:"text-muted-foreground"};case"mapped":return{label:"Mapped",className:"text-muted-foreground"};case"excluded":return{label:"Not applied",className:"text-muted-foreground"};case"notApplicable":return{label:"Not applicable",className:"text-muted-foreground"};case"pendingSource":return{label:"Pending source",className:"text-muted-foreground"};case"metadataUnavailable":return{label:"Fields unavailable",className:"text-amber-700 dark:text-amber-400"};case"invalidMapping":return{label:"Invalid",className:"text-destructive"};case"needsMapping":return{label:"Needs mapping",className:"font-medium text-amber-700 dark:text-amber-400"}}}function CJe(e){if(typeof e!="string"||!e)return;const t=e.replace(/([A-Z])/g," $1").trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function SJe(e){var r;const t=(r=e.config)==null?void 0:r.queryBaseSource,n=[CJe(e.type),(t==null?void 0:t.datasetName)||(t==null?void 0:t.tableName)].filter(Boolean);return n.length?n.join(" · "):void 0}function NJe({target:e}){return l.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[11px]",children:[l.jsx(Go,{className:"h-3 w-3 shrink-0 text-muted-foreground/70"}),l.jsx("span",{className:"truncate text-muted-foreground",children:Q1(e)}),l.jsx("span",{className:"shrink-0 text-border",children:"·"}),l.jsx("span",{className:"truncate font-medium text-foreground",children:e.field.name})]})}function jJe({row:e,onPickTarget:t,onExclude:n}){const[r,o]=te.useState(""),s=e.candidates.length>kue,i=r.trim().toLowerCase(),a=e.candidates.filter(f=>!i||f.field.name.toLowerCase().includes(i)||Q1(f).toLowerCase().includes(i)),c=[];for(const f of a){const h=Q1(f);c.includes(h)||c.push(h)}const d=!(e.executionKind==="sql"&&e.status==="suggested")&&e.selectedTarget?Bj(e.selectedTarget):void 0;return l.jsxs("div",{role:"listbox","aria-label":"Field candidates",className:"flex flex-col",children:[s&&l.jsx("div",{className:"shrink-0 border-b border-border/60 p-1.5",children:l.jsxs("div",{className:"flex h-7 items-center gap-1.5 rounded-control border border-border px-2",children:[l.jsx(Mt.Search,{className:"h-3 w-3 shrink-0 text-muted-foreground/70"}),l.jsx("input",{autoFocus:!0,value:r,onChange:f=>o(f.target.value),placeholder:`Search ${e.candidates.length} fields`,className:"w-full bg-transparent text-[11px] text-foreground outline-none placeholder:text-[hsl(var(--semaphor-placeholder-foreground))]"})]})}),l.jsxs("div",{className:"max-h-[240px] overflow-y-auto p-1",children:[c.map(f=>{const h=a.filter(m=>Q1(m)===f);return l.jsxs("div",{children:[l.jsxs("p",{className:"px-2 pb-0.5 pt-1.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground/80",children:[f,s?` · ${h.length}`:""]}),h.map(m=>{const g=Bj(m);return l.jsxs("button",{type:"button",role:"option","aria-selected":d===g,onClick:()=>t(m),className:"flex w-full items-center gap-2 rounded-[4px] px-2 py-1.5 text-left text-[11px] hover:bg-muted/60",children:[l.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:m.field.name}),d===g&&l.jsx(p.Check,{className:"h-3 w-3 shrink-0 text-muted-foreground"})]},g)})]},f)}),a.length===0&&l.jsxs("p",{className:"px-2 py-3 text-center text-[11px] text-muted-foreground",children:["No fields match “",r,"”"]})]}),l.jsx("div",{className:"shrink-0 border-t border-border/60 p-1",children:l.jsxs("button",{type:"button",role:"option","aria-selected":e.status==="excluded",onClick:n,className:"flex w-full items-center gap-2 rounded-[4px] px-2 py-1.5 text-left text-[11px] text-muted-foreground hover:bg-muted/60",children:[l.jsx(Ie.X,{className:"h-3 w-3 shrink-0"})," Don't apply this filter",e.status==="excluded"&&l.jsx(p.Check,{className:"ml-auto h-3 w-3 shrink-0 text-muted-foreground"})]})})]})}function kJe({mode:e,row:t,cardTitle:n,cardMeta:r,onDecision:o,onRetry:s}){const[i,a]=te.useState(!1),c=wJe(t),u=t.executionKind!=="unconfigured"&&t.status!=="pendingSource"&&t.status!=="notApplicable"&&t.status!=="metadataUnavailable",d=t.status==="invalidMapping"?"border-destructive/60":t.status==="needsMapping"?"border-amber-400 dark:border-amber-700/60":t.status==="excluded"?"border-dashed border-border":"border-border hover:border-muted-foreground/40",f=u?l.jsxs(p.Popover,{open:i,onOpenChange:a,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs("button",{type:"button",role:"combobox","aria-expanded":i,"aria-label":`Mapping for ${n}`,className:p.cn("flex h-7 w-full items-center justify-between gap-1.5 rounded-control border bg-transparent px-2 text-left transition-colors",d,i&&"bg-muted/40"),children:[t.status==="excluded"?l.jsx("span",{className:"text-[11px] text-muted-foreground/80",children:"Not applied"}):t.executionKind==="sql"&&t.status==="suggested"&&t.automaticFieldName?l.jsxs("span",{className:"truncate text-[11px] text-muted-foreground",children:["Auto ·"," ",l.jsx("span",{className:"font-medium text-foreground",children:t.automaticFieldName})]}):t.selectedTarget?l.jsx(NJe,{target:t.selectedTarget}):l.jsx("span",{className:"text-[11px] font-medium text-amber-700 dark:text-amber-400",children:"Choose a field"}),l.jsxs("span",{className:"flex shrink-0 items-center gap-1",children:[t.status==="invalidMapping"&&l.jsx(Yo,{className:"h-3 w-3 text-destructive"}),l.jsx(Ie.ChevronDown,{className:"h-3 w-3 text-muted-foreground/70"})]})]})}),l.jsx(p.PopoverContent,{align:"end",sideOffset:4,className:p.cn("z-[100] rounded-control border-border/80 p-0 shadow-[0_10px_28px_rgba(0,0,0,0.14)] dark:shadow-[0_10px_28px_rgba(0,0,0,0.5)]",t.candidates.length>kue?"w-[300px]":"w-[270px]"),children:l.jsx(jJe,{row:t,onPickTarget:h=>{const m=t.status!=="excluded"&&!(t.executionKind==="sql"&&t.status==="suggested")&&t.selectedTarget?Bj(t.selectedTarget):void 0;Bj(h)!==m&&o({kind:"bound",target:h}),a(!1)},onExclude:()=>{t.status!=="excluded"&&o({kind:"excluded"}),a(!1)}})})]}):l.jsxs("div",{className:"flex h-7 items-center justify-between gap-2 rounded-control border border-dashed border-border px-2 text-[11px] text-muted-foreground",children:[l.jsx("span",{className:"truncate",children:t.guidanceMessage||(t.status==="pendingSource"?"Select a card data source first":t.status==="metadataUnavailable"?"Fields could not be loaded":t.status==="notApplicable"?"Not applicable":"No compatible field")}),t.status==="metadataUnavailable"&&l.jsxs("button",{type:"button",onClick:s,className:"inline-flex shrink-0 items-center gap-1 text-[11px] font-medium text-foreground/70 hover:text-foreground",children:[l.jsx(_a,{className:"h-3 w-3"})," Retry"]})]});return l.jsxs("div",{children:[l.jsxs("div",{className:p.cn("grid w-full items-center gap-3 px-4 py-2",e==="popover"?"grid-cols-[minmax(0,1fr)_238px]":"grid-cols-[minmax(180px,240px)_minmax(0,1fr)_90px]"),children:[l.jsxs("span",{className:"min-w-0",children:[l.jsx("span",{className:"block truncate text-[12px] font-medium text-foreground",children:n}),r&&l.jsx("span",{className:"mt-0.5 block truncate text-[10px] text-muted-foreground",children:r})]}),l.jsx("span",{className:"relative block min-w-0",children:f}),e==="table"&&l.jsx("span",{className:p.cn("text-[11px]",c.className),children:c.label})]}),t.status==="invalidMapping"&&l.jsxs("div",{className:"mx-4 mb-2 rounded-control border border-destructive/30 bg-destructive/5 p-2.5",children:[l.jsxs("p",{className:"flex items-start gap-1.5 text-[11px] font-medium leading-4 text-destructive",children:[l.jsx(Yo,{className:"mt-0.5 h-3 w-3 shrink-0"})," This mapping is no longer valid"]}),l.jsx("p",{className:"mt-1 text-[11px] leading-4 text-muted-foreground",children:"The saved field no longer resolves for this card query. Choose a field from this card, or set it to Not applied."})]}),t.status==="metadataUnavailable"&&t.metadataMessage&&l.jsx("p",{className:"mx-4 mb-2 text-[10px] leading-4 text-muted-foreground",children:t.metadataMessage}),t.executionKind==="sql"&&t.status==="mapped"&&l.jsx("p",{className:"mx-4 mb-2 text-[10px] leading-4 text-muted-foreground",children:"Fields come from the card's pinned sources. Semaphor does not verify that your custom SQL references the selected field."})]})}function IJe({dashboard:e,filterTitle:t,isLoading:n,draftResult:r,onDecision:o,onRetry:s}){var S;const[i,a]=te.useState(""),[c,u]=te.useState(!1),d=p.getDashboardCardEntries(e),f=new Map(d.map(j=>[j.card.id,j])),h=r!=null&&r.ok?r.draft.rows:[],m=i.trim().toLowerCase(),x=(e.sheets||[]).map(j=>({sheet:j,rows:h.filter(I=>{var T;if(I.sheetId!==j.id)return!1;const k=((T=f.get(I.cardId))==null?void 0:T.card.title)||I.cardId;return!m||k.toLowerCase().includes(m)})})).filter(j=>j.rows.length>0),b=h.filter(j=>(j.status==="mapped"||j.status==="suggested")&&j.selectedTarget).length,y=h.filter(j=>j.status==="needsMapping"||j.status==="metadataUnavailable").length,w=h.filter(j=>j.status==="excluded"||j.status==="notApplicable").length,C=h.filter(j=>j.status==="invalidMapping").length,N=j=>x.map(({sheet:I,rows:k})=>l.jsxs("div",{children:[l.jsxs("p",{className:"flex items-center gap-1.5 border-y border-border/60 bg-muted/40 px-4 py-1 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground first:border-t-0",children:[I.title||I.id," · ",k.length," ",k.length===1?"card":"cards"]}),l.jsx("div",{className:"divide-y divide-border/60",children:k.map(T=>{const _=f.get(T.cardId);return l.jsx(kJe,{mode:j,row:T,cardTitle:(_==null?void 0:_.card.title)||T.cardId,cardMeta:_?SJe(_.card):void 0,onDecision:E=>o(T.cardId,E),onRetry:s},T.cardId)})})]},I.id));return n?l.jsxs("div",{className:"flex items-center justify-center gap-2 py-12 text-[12px] text-muted-foreground",children:[l.jsx(p.LoaderCircle,{className:"h-4 w-4 animate-spin"})," Loading card fields…"]}):l.jsxs("div",{children:[r&&!r.ok&&l.jsx("div",{className:"mx-4 my-3 rounded-control border border-destructive/40 bg-destructive/5 px-3 py-2 text-[11px] text-destructive",children:(S=r.issues[0])==null?void 0:S.message}),h.length>0&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"flex items-center gap-2 px-4 py-2.5",children:[l.jsxs("div",{className:"flex h-7 min-w-0 flex-1 items-center gap-2 rounded-control border border-border px-2",children:[l.jsx(Mt.Search,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/70"}),l.jsx("input",{value:i,onChange:j=>a(j.target.value),placeholder:"Search cards","aria-label":"Search cards",className:"w-full bg-transparent text-[12px] text-foreground outline-none placeholder:text-[hsl(var(--semaphor-placeholder-foreground))]"})]}),l.jsxs(p.Button,{variant:"outline",size:"xs",onClick:()=>u(!0),className:"shrink-0 gap-1 text-[10px] font-medium text-muted-foreground hover:text-foreground",children:[l.jsx(Mt.Maximize2,{className:"h-3 w-3"})," Review as table"]})]}),N("popover"),x.length===0&&l.jsxs("p",{className:"py-8 text-center text-[12px] text-muted-foreground",children:["No cards match “",i,"”"]})]}),(r==null?void 0:r.ok)&&h.length===0&&l.jsx("p",{className:"py-8 text-center text-[12px] text-muted-foreground",children:"No cards are in this filter's current sheet scope."}),l.jsx(So,{open:c,onOpenChange:u,children:l.jsxs(po,{className:"z-[90] w-[min(880px,92vw)] max-w-none gap-0 overflow-hidden p-0",children:[l.jsx("div",{className:"border-b border-border/60 px-4 py-3",children:l.jsx(go,{className:"text-[13px] font-semibold text-foreground",children:t?`${t} · Card mapping`:"Card mapping"})}),l.jsxs("div",{className:"grid grid-cols-[minmax(180px,240px)_minmax(0,1fr)_90px] gap-3 border-b border-border/60 px-4 py-1.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:[l.jsx("span",{children:"Card"}),l.jsx("span",{children:"Binding"}),l.jsx("span",{children:"Status"})]}),l.jsx("div",{className:"max-h-[60vh] min-h-0 overflow-y-auto",children:N("table")}),l.jsxs("div",{className:"flex items-center justify-between border-t border-border/60 px-4 py-2.5",children:[l.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[b," covered · ",y," to review · ",w," ","not applied",C>0&&l.jsxs("span",{className:"text-destructive",children:[" ","· ",C," invalid"]})]}),l.jsx(p.Button,{size:"xs",onClick:()=>u(!1),children:"Done"})]})]})})]})}function _Je(e){var f;const t=p.useDashboardStore(h=>h.dashboard),n=p.useDashboardStore(h=>h.authToken),{tokenProps:r}=It(),o=v.useMemo(()=>xJe(t,e.outerScope),[t,e.outerScope]),s=!!(n!=null&&n.accessToken),i=Fm({queries:o.map(h=>({queryKey:["dashboard-filter-mapping-columns",h.key],queryFn:()=>p.getRequest(`${r.apiServiceUrl}/v1/columns`,(n==null?void 0:n.accessToken)||"",h.request),enabled:e.enabled&&s,staleTime:6e4}))}),a=e.enabled&&s&&i.some(h=>!h.data&&!h.error),c=v.useMemo(()=>{const h=new Map;return o.forEach((m,g)=>{const x=i[g];e.enabled&&(s?x!=null&&x.error?h.set(m.key,{status:"unavailable",message:x.error instanceof Error?x.error.message:"Field metadata could not be loaded."}):x!=null&&x.data&&h.set(m.key,{status:"ready",columns:Array.isArray(x.data.columns)?x.data.columns:[]}):h.set(m.key,{status:"unavailable",message:"Dashboard authentication is not ready for field metadata."}))}),h},[s,e.enabled,i,o]),u=v.useMemo(()=>vJe({dashboard:t,metadataBySourceKey:c,outerScope:e.outerScope}),[t,c,e.outerScope]),d=v.useMemo(()=>{const h=e.optionSource;if(h!=null&&h.valueField.name){const x=h.valueField;return{name:x.name,source:A5(x,h.source)}}const m=i_e(e.filter),g=P5(e.filter);return m&&g?{...m,source:g}:m},[e.filter,e.optionSource]);return{candidatesByCardId:u,selectionField:d,selectionDataType:((f=e.optionSource)==null?void 0:f.valueField.dataType)||e.filter.dataType,isLoading:a,retry:()=>{i.forEach(h=>{h.error&&h.refetch()})}}}function TJe(e){const t=e.hasPersistedApplication||e.hasDraftMappingChanges,n=e.optionSourceChanged&&!e.selectionIdentityChanged&&!e.hasDraftMappingChanges&&!e.scopeChanged;return t&&!n?"mapping":e.hasAuthoredOptionSource?"optionSource":"ordinary"}function EJe(e,t,n){if(!(!t.defaultSettingsChanged&&!t.defaultComparisonChanged&&!t.optionSourceChanged&&!t.selectionIdentityChanged))return{defaultValueChanged:t.defaultSettingsChanged,...t.defaultSettingsChanged?{defaultFilterValue:p.buildFilterValueFromDefaults(e,n)}:{},defaultComparisonChanged:t.defaultComparisonChanged,defaultComparisonSelection:t.defaultComparisonSelection,target:t.runtimeTarget,optionSourceChanged:t.optionSourceChanged,optionSource:t.optionSource,selectionIdentityChanged:t.selectionIdentityChanged}}function DJe(e){const t=p.useDashboardStore(k=>k.dashboard),[n,r]=v.useState(!1),[o,s]=v.useState({}),[i,a]=v.useState([]),{updateFilter:c,addOrUpdateFilterValue:u,removeFilterValues:d,acceptDashboardFilterOptionSource:f,acceptDashboardFilterMapping:h,setDefaultDashboardInputComparisonSelection:m}=p.useDashboardActions(),g=v.useMemo(()=>e.capable?p.findMappedDashboardFilterInput(t,e.filter.id):void 0,[t,e.capable,e.filter.id]),x=v.useMemo(()=>!e.scopeChanged&&g&&(g.scope.kind==="allSheets"||g.scope.kind==="sheets")?g.scope:p.buildDashboardFilterMappingOuterScope({filter:e.stagedFilter,dashboard:t}),[t,e.scopeChanged,e.stagedFilter,g]),b=_Je({filter:e.stagedFilter,enabled:!!(e.open&&e.capable),outerScope:x,optionSource:e.optionSource}),y=v.useMemo(()=>({filterId:e.filter.id,candidatesByCardId:b.candidatesByCardId,selectionField:b.selectionField,selectionDataType:b.selectionDataType,revalidatePersistedTargets:e.selectionIdentityChanged,decisionsByCardId:o,...e.scopeChanged?{outerScope:x}:{}}),[o,b.candidatesByCardId,b.selectionField,b.selectionDataType,x,e.filter.id,e.selectionIdentityChanged,e.scopeChanged]),w=v.useMemo(()=>({...t,filters:(t.filters||[]).map(k=>k.id===e.filter.id?e.stagedFilter:k)}),[t,e.filter.id,e.stagedFilter]),C=v.useMemo(()=>e.capable?p.buildDashboardFilterMappingDraft({dashboard:w,request:y}):void 0,[w,e.capable,y]),N=v.useCallback(()=>{r(!1),s({}),a([])},[]),S=v.useCallback((k,T)=>{s(_=>({..._,[k]:T})),r(!0),a([])},[]),j=v.useCallback(()=>a([]),[]),I=v.useCallback((k,T,_)=>{const E=EJe(k,T,e.dashboardTimezone),D=TJe({hasPersistedApplication:!!g,hasDraftMappingChanges:n,hasAuthoredOptionSource:!!e.optionSource,optionSourceChanged:!!T.optionSourceChanged,selectionIdentityChanged:!!T.selectionIdentityChanged,scopeChanged:e.scopeChanged});if(D==="mapping"){if(b.isLoading)return a([{code:"metadataUnavailable",filterId:e.filter.id,message:"Card field metadata is still loading."}]),!1;const M=h(y,k,E);if(!M.ok)return a(M.issues),!1}else if(D==="optionSource"){if(!T.optionSource)return a([{code:"invalidTarget",filterId:e.filter.id,message:"The Option Source is incomplete."}]),!1;const M=f(k,T.optionSource,E,_);if(!M.ok)return a(M.issues),!1}else c(k);if(D==="ordinary"&&T.defaultSettingsChanged){const M=p.buildFilterValueFromDefaults(k,e.dashboardTimezone);M?u(M):d(e.filter.id)}if(D==="ordinary"&&T.defaultComparisonChanged){const M=ja(p.useDashboardStore.getState().dashboard,e.filter.id);M&&p.isComparisonCapableDashboardDateInput(M)&&p.canAddressDashboardInputRuntimeSlot(M,T.runtimeTarget)&&m(M,T.runtimeTarget,T.defaultComparisonSelection)}return!0},[h,f,u,n,b.isLoading,e.dashboardTimezone,e.filter.id,e.optionSource,e.scopeChanged,g,d,y,m,c]);return{mappingActive:!!(g||n),hasDraftChanges:n,hasPersistedApplication:!!g,isLoading:b.isLoading,dashboardWithStagedFilter:w,draftResult:C,issues:i,retry:b.retry,decide:S,clearIssues:j,reset:N,acceptAuthoringChanges:I}}const MJe=7;function TM(e){return e.kind==="semantic"?e.datasetName||e.datasetId||e.domainId:[e.databaseName,e.schemaName,e.tableName].filter(Boolean).join(".")}function yU(e,t){var n,r;return((n=e.source)==null?void 0:n.kind)==="semantic"||((r=e.source)==null?void 0:r.kind)==="physical"?e.source:t}function Vj(e){return`${ju(e.source)}::${e.name}`}function vU({ariaLabel:e,value:t,fields:n,onPick:r,disabled:o=!1,isLoading:s=!1}){const[i,a]=v.useState(!1),[c,u]=v.useState(""),d=n.length>MJe,f=c.trim().toLowerCase(),h=n.filter(x=>!f||x.name.toLowerCase().includes(f)||TM(x.source).toLowerCase().includes(f)),m=new Map;for(const x of h){const b=ju(x.source),y=m.get(b)||{label:TM(x.source),fields:[]};y.fields.push(x),m.set(b,y)}const g=Vj(t);return l.jsxs(p.Popover,{open:i,onOpenChange:x=>{a(x),x||u("")},children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs("button",{type:"button",role:"combobox","aria-expanded":i,"aria-label":e,disabled:o,className:p.cn("flex h-7 w-full items-center justify-between gap-2 rounded-control border border-border bg-transparent px-2 text-left transition-colors hover:border-muted-foreground/40",i&&"bg-muted/40"),children:[l.jsxs("span",{className:"flex min-w-0 items-center gap-1.5 text-[12px]",children:[l.jsx("span",{className:"truncate text-muted-foreground",children:TM(t.source)}),l.jsx("span",{className:"shrink-0 text-border",children:"·"}),l.jsx("span",{className:"truncate font-medium text-foreground",children:t.name})]}),s?l.jsx(p.LoaderCircle,{role:"status","aria-label":"Loading fields",className:"h-3.5 w-3.5 shrink-0 animate-spin text-muted-foreground/70"}):l.jsx(Ie.ChevronDown,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground/70"})]})}),l.jsx(p.PopoverContent,{align:"start",sideOffset:4,className:p.cn("z-[80] rounded-control border-border/80 p-0 shadow-[0_10px_28px_rgba(0,0,0,0.14)] dark:shadow-[0_10px_28px_rgba(0,0,0,0.5)]",d?"w-[300px]":"w-[270px]"),children:l.jsxs("div",{role:"listbox","aria-label":e,className:"flex flex-col",children:[d&&l.jsx("div",{className:"shrink-0 border-b border-border/60 p-1.5",children:l.jsxs("div",{className:"flex h-7 items-center gap-1.5 rounded-control border border-border px-2",children:[l.jsx(Mt.Search,{className:"h-3 w-3 shrink-0 text-muted-foreground/70"}),l.jsx("input",{autoFocus:!0,value:c,onChange:x=>u(x.target.value),placeholder:`Search ${n.length} fields`,className:"w-full bg-transparent text-[11px] text-foreground outline-none placeholder:text-[hsl(var(--semaphor-placeholder-foreground))]"})]})}),l.jsxs("div",{className:"max-h-[240px] overflow-y-auto p-1",children:[[...m.entries()].map(([x,b])=>l.jsxs("div",{children:[l.jsxs("p",{className:"px-2 pb-0.5 pt-1.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground/80",children:[b.label,d?` · ${b.fields.length}`:""]}),b.fields.map(y=>{const w=Vj(y);return l.jsxs("button",{type:"button",role:"option","aria-selected":w===g,onClick:()=>{r(y),a(!1),u("")},className:"flex w-full items-center gap-2 rounded-[4px] px-2 py-1.5 text-left text-[11px] hover:bg-muted/60",children:[l.jsx("span",{className:"min-w-0 flex-1 truncate font-medium text-foreground",children:y.name}),w===g&&l.jsx(p.Check,{className:"h-3 w-3 shrink-0 text-muted-foreground"})]},w)})]},x)),h.length===0&&l.jsx("p",{className:"px-2 py-3 text-center text-[11px] text-muted-foreground",children:n.length===0?"No fields available from the selected option source":`No fields match “${c}”`})]})]})})]})}function RJe({value:e,fieldChoices:t,isLoading:n=!1,error:r,onRetry:o,onChange:s}){const i={...e.labelField,source:yU(e.labelField,e.source)},a={...e.valueField,source:yU(e.valueField,e.source)},[c,u]=v.useState(Vj(i)!==Vj(a)),d=ju(e.source),f=t.filter(h=>ju(h.source)===d);return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Option Value Field"}),l.jsx(vU,{ariaLabel:"Option value field",value:a,fields:f,disabled:n||!!r,isLoading:n,onPick:h=>{s({source:e.source,valueField:{...h},labelField:c?e.labelField:{...h}},{changedValueField:h})}}),r?l.jsxs("div",{role:"alert",className:"flex items-center justify-between gap-2 text-[11px] text-destructive",children:[l.jsx("span",{children:"Fields could not be loaded."}),o?l.jsxs(p.Button,{type:"button",variant:"ghost",size:"xs",onClick:o,className:"h-6 gap-1 px-1.5",children:[l.jsx(_a,{className:"h-3 w-3"}),"Retry"]}):null]}):null]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(An,{id:"useOptionLabelField",checked:c,onCheckedChange:h=>{const m=h===!0;u(m),m||s({...e,labelField:{...e.valueField}})}}),l.jsx(p.Label,{htmlFor:"useOptionLabelField",className:"cursor-pointer text-[11px] text-muted-foreground",children:"Use a different field for the option label"})]}),c&&l.jsxs("div",{className:"space-y-1",children:[l.jsx(p.Label,{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Option Label Field"}),l.jsx(vU,{ariaLabel:"Option label field",value:i,fields:f,disabled:n||!!r,isLoading:n,onPick:h=>s({...e,labelField:{...h}})})]})]})]})}function AJe(e){const t=p.useDashboardStore(s=>s.authToken),{tokenProps:n}=It(),r=qn({queryKey:["dashboard-filter-option-source-columns",e.optionSource?ju(e.optionSource.source):""],queryFn:()=>p.getRequest(`${n.apiServiceUrl}/v1/columns`,(t==null?void 0:t.accessToken)||"",jue(e.optionSource.source)),enabled:!!(e.enabled&&e.optionSource&&(t!=null&&t.accessToken)),staleTime:6e4});return{fields:v.useMemo(()=>{var i;const s=e.optionSource;return!s||!Array.isArray((i=r.data)==null?void 0:i.columns)?[]:r.data.columns.flatMap(a=>{var d;const c=(d=a.column_name)==null?void 0:d.trim(),u=Or.normalizeAnalyticsCatalogDataType(a.data_type);return!c||u==="unknown"?[]:[{name:c,dataType:u,source:{...s.source}}]})},[e.optionSource,r.data]),isLoading:r.isLoading,error:r.error,retry:r.refetch}}function wU(e){var n,r;const t=P5(e)||(()=>{const o=(e.qualifiedTableName||e.table||"options").split(".").filter(Boolean),s=o[o.length-1]||"options";return{kind:"physical",connectionId:e.connectionId,tableName:s,...o.length>=2?{schemaName:o[o.length-2]}:{},...o.length>=3?{databaseName:o[o.length-3]}:e.database?{databaseName:e.database}:{}}})();return{source:t,labelField:{name:((n=e.fieldMeta)==null?void 0:n.name)||e.column.split(".").pop()||e.column,dataType:"string",source:t},valueField:{name:((r=e.fieldMeta)==null?void 0:r.name)||e.column.split(".").pop()||e.column,dataType:p.getDataType(e.dataType),source:t}}}function og(e,t){const n=A5(e,t);return[ju(n),e.name,e.dataType||""].join("::")}function PJe(e,t){return og(e.valueField,e.source)===og(t.valueField,t.source)&&og(e.labelField,e.source)===og(t.labelField,t.source)}const FJe=[{id:"basic",label:"Basic"},{id:"scope",label:"Scope"},{id:"mapping",label:"Cards"},{id:"advanced",label:"Advanced"}];function H$({filter:e,variant:t="dashboard",onAccept:n,inputVariableName:r,reservedInputVariableNames:o,isDashboardFilterReference:s=!1,open:i,onOpenChange:a,trigger:c,isEditing:u=!1,filterQueryContext:d,onDelete:f}){var se,he;const h=ml("interactive");function m(ge){if(!ge)return"Unknown";const ke=p.getDataType(ge),De=ke==="date"?"Datetime":ke==="string"?"Text":ke==="number"?"Number":ke==="boolean"?"Boolean":ke==="json"?"JSON":"Geo";return/nullable/i.test(ge)?`${De} (nullable)`:De}const[g,x]=v.useState(!1),b=i??g,y=a??x,[w,C]=v.useState("basic"),N="kind"in e&&e.kind==="global-date",[S,j]=v.useState({}),[I,k]=v.useState({}),[T,_]=v.useState(),[E,D]=v.useState(!1),[M,P]=v.useState(!1),[A,L]=v.useState({mode:"off"}),[O,B]=v.useState(!1),[H,R]=v.useState(!1),V=p.useDashboardStore(ge=>ge.dashboard),z=p.useDashboardStore(ge=>ge.selectedSheetId),{updateFilter:F,addOrUpdateFilterValue:G,removeFilterValues:q,setDefaultDashboardInputComparisonSelection:Y}=p.useDashboardActions(),K=t==="dashboard"&&!N&&(!n||s),$=v.useMemo(()=>{if(t!=="dashboard")return;const ge=ja(V,e.id);if(!(!ge||!p.isComparisonCapableDashboardDateInput(ge)||!p.canAddressDashboardInputRuntimeSlot(ge,{sheetId:z})))return ge},[V,e.id,z,t]),X=v.useMemo(()=>ja(V,e.id),[V,e.id]),W=v.useMemo(()=>FJe.filter(ge=>!(t!=="dashboard"&&ge.id==="scope"||!K&&ge.id==="mapping"||N&&ge.id==="advanced"&&r===void 0)),[r,N,K,t]),{tokenProps:U}=It(),Z=bl()??void 0,Q={...e,...S},J=X!=null&&X.optionSource||E?T:void 0,{data:re}=x$(Q,{filterQueryContext:d,optionSource:J,currentSelectionPolicy:"exclude"}),de=["sheetId","applyToSheetIds","excludeSheetIds"].some(ge=>Object.prototype.hasOwnProperty.call(S,ge)),le=DJe({filter:e,stagedFilter:Q,dashboardTimezone:Z,open:b,capable:K,scopeChanged:de,optionSource:J,selectionIdentityChanged:M}),ce=AJe({optionSource:T,enabled:!!(b&&K)}),oe=le.reset,fe=K&&((se=le.draftResult)!=null&&se.ok)?le.draftResult.draft.rows:[],we=fe.filter(ge=>ge.status==="needsMapping"||ge.status==="metadataUnavailable").length,pe=fe.filter(ge=>ge.status==="invalidMapping").length;function ne(){let ge={...S};I.variableName&&K&&(ge={...ge,variableName:I.variableName});const ke=Object.prototype.hasOwnProperty.call(ge,"defaultValues")||Object.prototype.hasOwnProperty.call(ge,"defaultDateFilter");if(t==="inline"&&"width"in ge){const Re=ge.width;ge={...ge,width:Math.min(500,Math.max(100,Re))}}if(K){const Re={...e,...ge};if(!le.acceptAuthoringChanges(Re,{defaultSettingsChanged:ke,defaultComparisonChanged:O,defaultComparisonSelection:A.mode==="off"?void 0:A,runtimeTarget:{sheetId:z},optionSourceChanged:E,optionSource:T,selectionIdentityChanged:M},I)){C("mapping");return}}else if(n)n(ge,I);else{const Re={...e,...ge};if(F(Re),ke){const Ve=p.buildFilterValueFromDefaults(Re,Z);Ve?G(Ve):q(e.id)}}const De=K?ja(p.useDashboardStore.getState().dashboard,e.id):$;O&&!K&&De&&Y(De,{sheetId:z},A.mode==="off"?void 0:A),j({}),k({}),_(void 0),D(!1),P(!1),B(!1),y(!1)}function Se(ge){j(ke=>({...ke,...ge})),le.clearIssues()}function ue(ge){k(ke=>({...ke,...ge}))}v.useEffect(()=>{var ge;b&&(R(!1),j({}),k({}),_((X==null?void 0:X.optionSource)||wU(e)),D(!1),P(!1),L($?((ge=p.getDashboardInputRuntimeSlot(V.defaultInputValues,$,{sheetId:z}))==null?void 0:ge.comparisonSelection)||{mode:"off"}:{mode:"off"}),B(!1),oe(),C("basic"))},[V.defaultInputValues,$,e,X,b,oe,z]);const ie=N?e.title||p.DEFAULT_GLOBAL_DATE_FILTER_TITLE:e.column.split(".").pop()||e.column,ee=N?ie:e.column,ae=N?"Global date":m(e.dataType);return l.jsxs(p.Popover,{open:b,onOpenChange:y,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:c??l.jsx("button",{type:"button",className:p.cn("rounded p-0.5 hover:bg-muted focus:visible focus:outline-none focus:ring-1 focus:ring-ring",u?"visible":"invisible group-hover:visible"),"aria-label":"Filter settings",children:l.jsx(mf,{className:"h-3 w-3 text-muted-foreground hover:text-foreground"})})}),l.jsxs(p.PopoverContent,{collisionPadding:12,onMouseDown:ge=>{H||ge.stopPropagation()},onDoubleClick:ge=>ge.stopPropagation(),style:h.controlStyle,className:p.cn("flex h-[440px] max-h-[85vh] flex-col overflow-hidden rounded-control border border-border/60 p-0 shadow-[0_10px_28px_rgba(0,0,0,0.14)] transition-[width] dark:shadow-[0_10px_28px_rgba(0,0,0,0.5)]",w==="mapping"?"w-[620px]":"w-[480px]",t==="inline"||t==="document"?"z-[70]":"z-50"),children:[l.jsxs("div",{className:"flex min-h-12 shrink-0 items-center justify-between gap-2 border-b border-border/60 px-3 py-1.5",children:[l.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[l.jsx(Hd,{"aria-hidden":!0,className:"mt-1 h-3.5 w-3.5 shrink-0 text-muted-foreground"}),l.jsxs("div",{className:"min-w-0",children:[l.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[l.jsx("span",{className:"truncate text-[13px] font-medium text-foreground",title:ie,children:ie}),l.jsx("span",{className:"shrink-0 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",title:e.dataType,children:ae})]}),l.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] leading-3 text-muted-foreground/70",title:ee,children:ee})]})]}),l.jsx("button",{type:"button",onClick:()=>y(!1),"aria-label":"Close",className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",children:l.jsx("svg",{"aria-hidden":!0,viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:1.75,className:"h-3.5 w-3.5",children:l.jsx("path",{d:"M5 5l10 10M15 5L5 15",strokeLinecap:"round"})})})]}),l.jsx("nav",{role:"tablist","aria-label":"Filter settings sections",className:"flex h-9 shrink-0 items-stretch gap-4 border-b border-border/60 px-4",children:W.map(ge=>l.jsxs("button",{role:"tab","aria-selected":w===ge.id,onClick:()=>C(ge.id),className:p.cn("relative -mb-px inline-flex items-center text-[13px] transition-colors focus-visible:outline-none",w===ge.id?"font-medium text-foreground":"text-muted-foreground hover:text-foreground"),children:[ge.label,w===ge.id&&l.jsx("span",{"aria-hidden":!0,className:"absolute inset-x-0 -bottom-px h-[2px] bg-foreground"})]},ge.id))}),l.jsxs("div",{className:p.cn("min-h-0 flex-1 overflow-y-auto",w==="mapping"?"":"px-4 py-4"),children:[w==="basic"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx(fJe,{filter:Q,onUpdate:Se,showFilterId:!0,filterOptionsData:re,optionLabelFieldName:T==null?void 0:T.labelField.name,timezone:Z,variant:t,defaultComparisonSelection:$?A:void 0,onDefaultComparisonChange:$?ge=>{L(ge),B(!0)}:void 0,onDefaultDatePickerOpenChange:R,afterLabelSlot:K&&T?l.jsx(RJe,{value:T,fieldChoices:ce.fields,isLoading:ce.isLoading,error:ce.error,onRetry:()=>void ce.retry(),onChange:(ge,ke)=>{const De=(X==null?void 0:X.optionSource)||wU(e);_(ge),D(!PJe(ge,De)),P(og(ge.valueField,ge.source)!==og(De.valueField,De.source)),le.clearIssues();const Re=ke==null?void 0:ke.changedValueField;if(Re){const Ve=Re.source.kind==="semantic"?Re.source.datasetName||Re.source.datasetId:void 0,ve=Ve?`${Ve}.${Re.name}`:Re.name;Se({column:ve,dataType:Re.dataType,operation:p.getDataType(Re.dataType)==="date"?"between":"in",fieldMeta:{name:Re.name,qualifiedFieldName:ve,dataType:Re.dataType,...Re.source.kind==="semantic"?{entityName:Ve,entityId:Re.source.datasetId}:{entityName:Re.source.tableName}},defaultValues:void 0,defaultDateFilter:void 0})}}}):void 0}),l.jsx(mJe,{filter:Q,onUpdate:Se,variant:t})]}),w==="advanced"&&l.jsxs("div",{className:"space-y-4",children:[l.jsx(hJe,{variableName:I.variableName??r,reservedVariableNames:o,onUpdateInputMetadata:r===void 0?void 0:ue}),l.jsx(gJe,{filter:Q,onUpdate:Se,variant:t})]}),w==="scope"&&t==="dashboard"&&l.jsx(ZQe,{filter:Q,onUpdate:Se,cardScopeMode:le.mappingActive?"mapping":"editable"}),w==="mapping"&&K&&l.jsx(IJe,{dashboard:le.dashboardWithStagedFilter,filterTitle:ie,isLoading:le.isLoading,draftResult:le.draftResult,onDecision:le.decide,onRetry:le.retry})]}),l.jsxs("div",{className:"shrink-0 border-t border-border/60 bg-background px-4 py-2.5",children:[K&&(le.issues.length>0||pe>0)&&l.jsxs("p",{className:"mb-2 flex items-start gap-1.5 text-[11px] leading-4 text-destructive",children:[l.jsx(Yo,{className:"mt-0.5 h-3 w-3 shrink-0"}),((he=le.issues[0])==null?void 0:he.message)||`${pe} ${pe===1?"mapping is":"mappings are"} no longer valid. Resolve to save.`]}),K&&le.issues.length===0&&pe===0&&we>0&&l.jsxs("p",{className:"mb-2 flex items-start gap-1.5 text-[11px] leading-4 text-muted-foreground",children:[l.jsx(p.Info,{className:"mt-0.5 h-3 w-3 shrink-0"}),we," ",we===1?"card":"cards"," will not receive this filter until mapped."]}),l.jsxs("div",{className:"flex items-center justify-between gap-2",children:[f?l.jsx(p.Button,{variant:"outline",size:"xs",onClick:()=>{f(),y(!1)},className:"text-destructive hover:border-destructive/40 hover:bg-destructive/10 hover:text-destructive",children:"Delete"}):l.jsx("span",{}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(p.Button,{variant:"outline",size:"xs",onClick:()=>y(!1),children:"Cancel"}),l.jsx(p.Button,{size:"xs",onClick:ne,children:"Accept"})]})]})]})]})]})}function OJe(e,t){const n=e?pb({dashboard:e}).allInputs.find(r=>r.id===Pg.getDashboardFilterCompatInputId(t.id)):void 0;return(n==null?void 0:n.variableName)||t.variableName||p.createDashboardInputVariableName(t.title||t.column||t.id)}function Iue(e,t){if(!e)return[];const n=LJe(t),r=new Set;for(const o of pb({dashboard:e}).allInputs)o.id!==n&&r.add(o.variableName);return Array.from(r)}function LJe(e){if(e)return e.source==="dashboardFilter"?Pg.getDashboardFilterCompatInputId(e.filterId):Pg.getDashboardControlCompatInputId(e.controlId)}function $Je(e,t={}){const{enabled:n=!0,eventType:r="mousedown"}=t,o=v.useRef(null),s=v.useRef(t.ignoreRefs);return s.current=t.ignoreRefs,v.useEffect(()=>{const i=a=>{var f;const c=a.target;o.current&&o.current.contains(c)||(f=s.current)!=null&&f.some(h=>{var m;return(m=h.current)==null?void 0:m.contains(c)})||c instanceof Element&&(c.closest("[data-radix-popper-content-wrapper]")||c.closest("[data-radix-select-content]")||c.closest("[data-radix-popover-content]")||c.closest("[data-radix-dropdown-menu-content]")||c.closest("[data-radix-tooltip-content]")||c.closest('[role="listbox"]')||c.closest('[role="option"]')||c.closest('[role="combobox"]'))||c instanceof Element&&c.hasAttribute("data-radix-")||e()};return n&&document.addEventListener(r,i),()=>{document.removeEventListener(r,i)}},[e,n,r]),o}function zJe(e,t,n,r=[]){const o=p.useDashboardStore(g=>g.dashboard),s=p.useDashboardStore(g=>g.selectedSheetId),i=p.useDashboardStore(g=>g.dashboardInputValues),a=p.useDashboardStore(g=>g.filterValues),c=p.useDashboardStore(g=>g.controlValues),u=v.useMemo(()=>{var g;return(g=ja(o,e.id))==null?void 0:g.optionSource},[o,e.id]),d=(t==null?void 0:t.sheetId)??s,f=v.useMemo(()=>!u||n!=null&&n.activeFilterValues?n==null?void 0:n.activeFilterValues:Ti({dashboard:o,sheetId:d,runtimeValues:{dashboardInputValues:i,filterValues:a,controlValues:c}}).activeFilters,[c,o,i,n==null?void 0:n.activeFilterValues,a,u,d]),h=v.useMemo(()=>u?{...n,selectedSheetId:d??void 0,activeFilterValues:f}:n,[f,n,u,d]),{searchRecords:m}=Lle(e,"",0,{enabled:!!(u&&r.length),debounceMs:0,searchThreshold:1,filterQueryContext:h,optionValueLookup:r});return v.useMemo(()=>{const g=new Map;for(const x of m)x.label!==void 0&&g.set(String(x.value),String(x.label));return g},[m])}const BJe=24;function Wx(e,t=BJe){return e.length<=t?e:`${e.slice(0,t-1)}…`}function VJe(e,t,n,r=new Map){if(!t)return null;if(t.operation==="is null")return"is empty";if(t.operation==="is not null")return"is not empty";const o=t.values;if(!o||o.length===0)return null;const s=p.getDataType(e.dataType),i=c=>{try{return Vt.formatInTimeZone(new Date(c),n,"MMM d")}catch{return String(c)}},a={"=":"=","!=":"≠","<":"<","<=":"≤",">":">",">=":"≥"};if(s==="date"){const c=t.relativeMeta,u=p.getRelativeDateLabel(c);if(u)return u;const d=o[0],f=o[1];if(!d)return null;if(f){const g=b=>{try{return Vt.formatInTimeZone(new Date(b),n,"yyyy-MM-dd")}catch{return String(b)}};if(g(d)===g(f)){const b=i(d);return t.operation==="not between"?`not ${b}`:b}const x=`${i(d)} – ${i(f)}`;return t.operation==="not between"?`not ${x}`:x}const h=a[t.operation],m=i(d);return h?`${h} ${m}`:m}if(s==="number"&&(t.operation==="between"||t.operation==="not between")&&o.length>=2){const c=`${String(o[0])} – ${String(o[1])}`;return t.operation==="not between"?`not ${c}`:c}if(s==="number"&&o.length===1&&t.operation!=="in"&&t.operation!=="not in"){const c=a[t.operation];if(c)return Wx(`${c} ${String(o[0])}`)}return t.operation==="not in"?o.length===1?Wx(`not ${r.get(String(o[0]))??String(o[0])}`):`${o.length} excluded`:t.operation==="not like"?Wx(`not ${String(o[0])}`):t.operation==="like"?Wx(`contains ${String(o[0])}`):o.length===1?Wx(r.get(String(o[0]))??String(o[0])):`${o.length} selected`}function HJe(e){return p.getDataType(e.dataType)==="date"||e.kind==="global-date"?N0:(e.searchMode==="numeric",null)}function qJe(e){const t=p.getDataType(e.dataType);return(t==="date"||e.kind==="global-date")&&e.dateSelectionMode==="day"?240:t==="date"||e.kind==="global-date"?360:e.uiType==="tabs"?320:e.uiType==="radio"?260:e.searchMode==="numeric"?240:300}function CU(e){var t;return!((t=e.customFilterPreferences)!=null&&t.url||e.kind==="global-date"||p.isDateDataType(e.dataType)||e.searchMode==="numeric"||e.type==="single"&&(e.uiType==="radio"||e.uiType==="tabs"))}function UJe(e,t){var o;const n=(t==null?void 0:t.name)||e.column;if(n===e.column)return e.title||e.column;const r=(o=e.targetColumns)==null?void 0:o.find(s=>s.column===n);return(r==null?void 0:r.label)||n}function q$({filter:e,isEditing:t=!1,dragListeners:n,storageOptions:r,settingsVariant:o="dashboard",filterQueryContext:s,inputVariableName:i,reservedInputVariableNames:a,isDashboardFilterReference:c=!1,onUpdateFilter:u,onRemoveFilter:d}){var U,Z,Q;const f=B$(e,r),h=ml("interactive"),m=p.useDashboardStore(J=>J.dashboard),g=p.useDashboardStore(J=>J.semanticExecutionPayload),{removeFilterValues:x,removeFilter:b,clearDashboardInputSlot:y}=p.useDashboardActions(),w=p.useDashboardStore(J=>J.actions.removeCardInlineFilterValue),C=(f==null?void 0:f.storageTarget)==="card",N=(f==null?void 0:f.storageTarget)==="dashboardInput",S=f==null?void 0:f.cardId,j=p.useDashboardStore(J=>J.dashboardInputValues),I=p.useDashboardStore(J=>J.selectedSheetId),k=bl(),T=v.useMemo(()=>{if(!N||!(f!=null&&f.dashboardInput))return;const J={sheetId:f.sheetId},re=p.hydrateAuthoredDashboardInputSlot({dashboard:m,input:f.dashboardInput,runtimeValues:j,target:J,timezone:k});return(re==null?void 0:re.status)==="set"&&re.value.kind==="filter"?re.value.filterValue:void 0},[m,j,N,f==null?void 0:f.dashboardInput,f==null?void 0:f.sheetId,k]),_=p.useDashboardStore(J=>{var re,de,le;return C?S?(de=(re=J.inlineFilterValuesMap)==null?void 0:re[S])==null?void 0:de.find(ce=>ce.filterId===e.id):void 0:(le=J.filterValues)==null?void 0:le.find(ce=>ce.filterId===e.id)}),D=C&&(f==null?void 0:f.inlineFilterValues)!==void 0?(U=f.inlineFilterValues)==null?void 0:U.find(J=>J.filterId===e.id):N?T:_,M=v.useMemo(()=>p.isGlobalDateFilter(e)?O5({globalDateFilter:e,globalDateFilterValue:D,timezone:k,allowMinutePrecision:p.getGlobalDateFilterCoverage(m,g).allEligibleTargetsAreDateTime}):D,[m,e,D,g,k]),[P,A]=v.useState(!1),L=v.useRef(null),O=$Je(()=>A(!1),{enabled:P,eventType:"pointerdown",ignoreRefs:[L]}),B=i??(o==="dashboard"?OJe(m,e):void 0),H=a??(o==="dashboard"?Iue(m,{source:"dashboardFilter",filterId:e.id}):void 0),R=zJe(e,f,s,M==null?void 0:M.values),V=VJe(e,M,k,R),z=p.isDateDataType(e.dataType)||e.kind==="global-date",F=v.useMemo(()=>{var le;if(!z)return null;const re=(((le=f==null?void 0:f.dashboardInput)==null?void 0:le.kind)==="filter"?f.dashboardInput:void 0)||ja(m,e.id);if(!re||!p.isComparisonCapableDashboardDateInput(re))return null;const de=p.hydrateAuthoredDashboardInputSlot({dashboard:m,input:re,runtimeValues:j,target:{sheetId:(f==null?void 0:f.sheetId)||I},timezone:k});return Nue(de==null?void 0:de.comparisonSelection)??null},[m,j,e,z,I,f==null?void 0:f.dashboardInput,f==null?void 0:f.sheetId,k]),G=V!==null,q=UJe(e,M),Y=HJe(e),K=!!((Z=e.customFilterPreferences)!=null&&Z.url&&((Q=e.customFilterPreferences)!=null&&Q.componentName)),$=z&&!K,X=J=>{if(J.preventDefault(),J.stopPropagation(),N&&(f!=null&&f.dashboardInput)){y(f.dashboardInput,{sheetId:f.sheetId});return}if(C&&e.id){if(f!=null&&f.removeInlineFilterValue){f.removeInlineFilterValue(e.id);return}S&&w(S,e.id);return}x(e.id)},W=()=>{if(d){d(e.id);return}x(e.id),b(e.id)};return l.jsxs("div",{className:"group/chip flex shrink-0 items-center gap-2",children:[t&&n&&l.jsx("span",{role:"button",tabIndex:-1,"aria-label":"Drag to reorder",className:"inline-flex h-7 cursor-grab items-center justify-center px-0.5 text-muted-foreground/50 transition-colors hover:text-muted-foreground active:cursor-grabbing",...n,children:l.jsx(Eu,{className:"size-3"})}),l.jsxs(p.Popover,{open:P,onOpenChange:A,children:[l.jsxs("div",{ref:L,className:p.cn("inline-flex h-7 items-stretch overflow-hidden rounded-control border border-border text-[12px] transition-colors",G?h.hasAppearance?"bg-accent/80 hover:bg-accent":"bg-muted/80 hover:bg-muted":h.hasAppearance?"bg-muted/40 hover:bg-accent/50":"bg-muted/40 hover:bg-muted/70"),style:h.chipStyle,children:[l.jsx(p.PopoverTrigger,{asChild:!0,children:l.jsxs("button",{type:"button",className:p.cn("inline-flex items-center gap-1.5 pl-2 focus:outline-none",G||t?"pr-1":"pr-2"),children:[Y&&l.jsx(Y,{className:p.cn("h-3 w-3 shrink-0",G?"text-muted-foreground":"text-muted-foreground/70")}),l.jsx("span",{className:"whitespace-nowrap text-muted-foreground",children:q}),G&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-border","aria-hidden":"true",children:"·"}),l.jsx("span",{className:"max-w-[160px] truncate whitespace-nowrap font-medium text-foreground",children:V})]}),F&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"text-border","aria-hidden":"true",children:"·"}),l.jsx("span",{className:"whitespace-nowrap text-[11px] font-medium text-muted-foreground",children:F})]}),l.jsx(Ie.ChevronDown,{className:"h-3 w-3 shrink-0 text-muted-foreground/60"})]})}),G&&l.jsx("button",{type:"button",onClick:X,"aria-label":`Clear ${e.title||e.column}`,className:"inline-flex w-6 shrink-0 items-center justify-center text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:l.jsx(Ie.X,{className:"h-3 w-3"})}),t&&l.jsx(H$,{filter:e,variant:o,isEditing:t,filterQueryContext:s,inputVariableName:B,reservedInputVariableNames:H,isDashboardFilterReference:c,onAccept:u?(J,re)=>u({...e,...J},re):void 0,onDelete:W,trigger:l.jsx("button",{type:"button","aria-label":`Settings for ${e.title||e.column}`,className:"inline-flex w-7 shrink-0 items-center justify-center text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:l.jsx(mf,{className:"h-3 w-3"})})})]}),l.jsx(p.PopoverContent,{ref:O,align:"start",sideOffset:4,style:{width:qJe(e),...h.contentStyle},className:p.cn($||CU(e)?"p-0":"p-3"),onMouseDown:J=>J.stopPropagation(),onClick:J=>J.stopPropagation(),children:(()=>{const J=()=>A(!1);return $?p.isGlobalDateFilter(e)?l.jsx(yue,{filter:e,storageOptions:f,inline:!0,onApplied:J}):l.jsx(vue,{filter:e,storageOptions:f,inline:!0,onApplied:J}):CU(e)?l.jsx(YQe,{filter:e,storageOptions:f,onApplied:J}):l.jsx(W_,{filter:e,storageOptions:f})})()})]})]})}function WJe(e){return{id:e.id,connectionId:e.connectionId,title:e.title,column:e.column,dataType:e.dataType,table:e.table,database:e.database,qualifiedTableName:e.qualifiedTableName,sql:e.sql,operation:e.operation,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext,type:e.type,uiType:e.uiType,dateSelectionMode:e.dateSelectionMode,defaultValues:e.defaultValues,defaultDateFilter:e.defaultDateFilter,searchMode:e.searchMode,customFilterPreferences:e.customFilterPreferences,showLabel:e.showLabel}}function _ue({inlineFilter:e,sheetId:t,cardId:n,inlineFilterValues:r,setInlineFilterValue:o,removeInlineFilterValue:s}){const i=WJe(e),a={storageTarget:"card",sheetId:t,cardId:n,inlineFilterValues:r,setInlineFilterValue:o,removeInlineFilterValue:s};return l.jsx(q$,{filter:i,isEditing:!1,storageOptions:a})}function U$({card:e,sheetId:t,inlineFilterValues:n,setInlineFilterValue:r,removeInlineFilterValue:o}){return!e.inlineFilters||e.inlineFilters.length===0?[]:e.inlineFilters.map(s=>l.jsx(_ue,{inlineFilter:s,sheetId:t,cardId:e.id,inlineFilterValues:n,setInlineFilterValue:r,removeInlineFilterValue:o},s.id))}function KJe(e){switch(e.type){case"kpi":return GJe(e);case"detailTable":case"table":return ZJe(e);case"aggregateTable":case"pivotTable":return XJe(e);default:return YJe(e)}}function Tue(e){return QJe(KJe(e))}function GJe(e){var i,a,c,u,d,f;const t=(i=e.preferences)==null?void 0:i.kpiVisualOptions,n=(a=e.preferences)==null?void 0:a.formatNumber,r=t==null?void 0:t.formatOptions,o=p.toTFormatOptions(p.fromSemanticFormat((d=(u=(c=e.config)==null?void 0:c.metricColumns)==null?void 0:u[0])==null?void 0:d.format));return{kpi:{primary:r?{...r,currency:r.currency||(r.type==="currency"?"USD":void 0)}:o?{...o,currency:o.currency||(o.type==="currency"?"USD":void 0)}:JJe(n),colorRanges:n==null?void 0:n.colorRanges},legacy:{formatNumber:n,numberAxisFormat:(f=e.preferences)==null?void 0:f.numberAxisFormat}}}function YJe(e){var n,r,o,s;const t=e.preferences;return{dataLabels:(n=t==null?void 0:t.dataLabelsConfig)==null?void 0:n.formatOptions,yAxis:(r=t==null?void 0:t.yAxisConfig)==null?void 0:r.formatOptions,xAxis:(o=t==null?void 0:t.xAxisConfig)==null?void 0:o.formatOptions,secondaryYAxis:(s=t==null?void 0:t.secondaryYAxisConfig)==null?void 0:s.formatOptions,legacy:{formatNumber:t==null?void 0:t.formatNumber,numberAxisFormat:t==null?void 0:t.numberAxisFormat}}}function ZJe(e){var n,r;return{tableColumnSettingsMap:(r=(n=e.preferences)==null?void 0:n.tablePrefs)==null?void 0:r.columnSettingsMap}}function XJe(e){var n;return{tableColumnSettings:(n=e.preferences)==null?void 0:n.columnSettings}}function QJe(e){const t=[],n={};return e.tableColumnSettingsMap&&Object.entries(e.tableColumnSettingsMap).forEach(([r,o])=>{const s=o==null?void 0:o.numberFormat;t.push({id:r,numberFormat:s}),n&&(n[r]={numberFormat:s})}),e.tableColumnSettings&&e.tableColumnSettings.forEach((r,o)=>{r.type==="number"&&t.push({position:r.columnIdx??o,numberFormat:eet(r)})}),{kpi:e.kpi,axes:{xAxis:e.xAxis,yAxis:e.yAxis,secondaryYAxis:e.secondaryYAxis},dataLabels:e.dataLabels,tables:t.length>0||Object.keys(n).length>0?{columns:t.length?t:void 0,columnMap:Object.keys(n).length>0?n:void 0}:void 0,legacy:e.legacy}}function JJe(e){const t=p.fromLegacyFormatNumber(e);return p.toTFormatOptions(t)}function eet(e){var n,r,o,s,i,a;if(e.type!=="number")return;const t=e.options;if(!(!t||typeof t!="object")&&"options"in t){const c=t,u=((n=c.options)==null?void 0:n.style)==="currency"||((r=c.options)==null?void 0:r.style)==="percent"?c.options.style:"decimal",d=p.fromColumnNumberFormat({style:u,currency:c.currency||"USD",locale:c.locale||"en-US",minimumFractionDigits:((o=c.options)==null?void 0:o.minimumFractionDigits)??0,maximumFractionDigits:((s=c.options)==null?void 0:s.maximumFractionDigits)??((i=c.options)==null?void 0:i.minimumFractionDigits)??2,useGrouping:typeof((a=c.options)==null?void 0:a.useGrouping)=="boolean"?c.options.useGrouping:!0,percentValueMode:u==="percent"?"whole":void 0});return p.toTFormatOptions(d)}}function Hj(e,t){if(!t)return e;const n=e?{...e}:{},r=n.title!==void 0,o=n.description!==void 0;return!r&&t.title!==void 0&&(n.title=t.title),!o&&t.description!==void 0&&(n.description=t.description),Object.keys(n).length>0?n:e}function tet({inputCard:e,slotType:t,slotIndex:n,multiInputData:r}){var s,i,a,c,u,d,f,h;if(!e)return{cardType:"unknown",title:`Tab ${n+1}`};const o=Tue(e);return{cardType:t??"unknown",title:e.tabTitle||e.title||`Tab ${n+1}`,description:e.description,formatConfig:o,kpiConfig:t==="kpi"?{comparisonMetadata:(i=(s=r==null?void 0:r[e.id])==null?void 0:s.metadata)==null?void 0:i.comparisonMetadata,options:{comparisonPolarity:p.getMetricComparisonPolarity((c=(a=e.config)==null?void 0:a.metricColumns)==null?void 0:c[0]),comparisonPresentation:(u=e.preferences)==null?void 0:u.comparisonPresentation,showComparison:((f=(d=e.preferences)==null?void 0:d.comparisonPresentation)==null?void 0:f.showComparison)!==!1},formatNumber:(h=e.preferences)==null?void 0:h.formatNumber}:void 0}}function Eue({card:e,dataMetadata:t}){var n,r,o,s,i,a;return{cardType:e.type||"unknown",title:e.tabTitle||e.title||"Tab 1",description:e.description,formatConfig:Tue(e),kpiConfig:e.type==="kpi"?{comparisonMetadata:t==null?void 0:t.comparisonMetadata,options:{comparisonPolarity:p.getMetricComparisonPolarity((r=(n=e.config)==null?void 0:n.metricColumns)==null?void 0:r[0]),comparisonPresentation:(o=e.preferences)==null?void 0:o.comparisonPresentation,showComparison:((i=(s=e.preferences)==null?void 0:s.comparisonPresentation)==null?void 0:i.showComparison)!==!1},formatNumber:(a=e.preferences)==null?void 0:a.formatNumber}:void 0}}function W$({configCard:e,slotOrderedCards:t,slotTypes:n,multiInputData:r,params:o,theme:s,chartSettings:i,filters:a,filterValues:c,inlineFilters:u,formatTemporalBucketValue:d}){var w;const f=n.map(C=>C??"unknown"),h=t.map(C=>{var N;return C?((N=r==null?void 0:r[C.id])==null?void 0:N.records)||[]:[]}),m=t.map(C=>{var N;return C?((N=r==null?void 0:r[C.id])==null?void 0:N.columns)||[]:[]}),g=Hj((w=e==null?void 0:e.customCardPreferences)==null?void 0:w.settings,e),x=t.map(C=>{var N;return Hj((N=C==null?void 0:C.customCardPreferences)==null?void 0:N.slotSettings,C)}),b={titles:t.map((C,N)=>C?C.tabTitle||C.title:`Tab ${N+1}`),cardTypes:f,cardIds:t.map((C,N)=>C?C.id:`missing-${N}`)},y=t.map((C,N)=>tet({inputCard:C,slotType:f[N],slotIndex:N,multiInputData:r}));return{data:h,columns:m,formatTemporalBucketValue:d,settings:g,slotSettings:x,tabMetadata:b,cardMetadata:y,params:o,theme:s,chartSettings:i,filters:a,filterValues:c,inlineFilters:u}}function K$(e){return e.slotOrderedCards.flatMap(t=>{if(!t)return[];const n=e.multiInputData[t.id];return[{card:t,cardConfig:n==null?void 0:n.effectiveCardConfig,columns:n==null?void 0:n.columns,columnKeyMap:n==null?void 0:n.columnKeyMap,executionSnapshot:e.executionSnapshot,dashboardId:e.dashboardId,attachmentIndex:e.attachmentIndex,valueFormatPreferences:e.valueFormatPreferences}]})}class net extends Error{constructor(n){super(`invalid_custom_visual_temporal_column: Column "${n}" is not an activated canonical temporal column from this custom-visual input. Pass the exact descriptor supplied in columns.`);je(this,"code","invalid_custom_visual_temporal_column");this.name="CustomVisualTemporalColumnError"}}function G$(e){const t=new Map;return e.forEach(n=>{const r=Sb({card:n.card,cardConfig:n.cardConfig,columns:n.columns,columnKeyMap:n.columnKeyMap,executionSnapshot:n.executionSnapshot,dashboardId:n.dashboardId,attachmentIndex:n.attachmentIndex,valueFormatPreferences:n.valueFormatPreferences});(n.columns||[]).forEach(o=>{const s=r.byColumnKey.get(o.key);s&&t.set(o,s)})}),(n,r)=>{const o=t.get(r);if(!o)throw new net(r.key);return at.formatGroupedTemporalValue({value:n,presentation:o})}}function ret({card:e,frame:t}){var q,Y,K,$,X,W;const n=e,r=xl(),[o,s]=v.useState({}),{authToken:i,presentationExecutionSnapshot:a}=It(),c=p.getTokenParams(i==null?void 0:i.accessToken),{compiledAppearance:u}=oi.useAppearance(),d=v.useMemo(()=>Vw(u),[u]),[f,h]=v.useState(()=>new Set),{getCard:m,manifest:g}=_f(((q=n.customCardPreferences)==null?void 0:q.url)||""),x=(Y=n.customCardPreferences)==null?void 0:Y.componentName,b=(K=g==null?void 0:g.visuals)==null?void 0:K.find(U=>U.name===x),y=at.resolveMultiInputType(n,b)??"single",w=v.useMemo(()=>y==="multiple"?{...e,connectionId:void 0,dataSource:void 0,sql:"",python:"",config:void 0,queryConfig:void 0}:e,[e,y]),{data:C,effectiveCardConfig:N}=vu(w),S=p.useInteractionStore(U=>U.interactionStates),j=p.useDashboardStore(U=>{var Z;return(Z=U.dashboard)==null?void 0:Z.id}),I=p.useDashboardStore(U=>U.dashboard.filters),k=p.useDashboardStore(U=>U.filterValues),T=p.useDashboardStore(U=>U.selectedSheetId),_=v.useMemo(()=>bb(a),[a]),E=v.useMemo(()=>Gv(),[]),D=p.useDashboardStore(U=>U.inlineFilterValuesMap[e.id]),M=v.useMemo(()=>U$({card:e,sheetId:T||"",inlineFilterValues:D}),[e,T,D]),{cardFilters:P,cardFilterValues:A}=v.useMemo(()=>bI({card:e,interactionStates:S,currentDashboardId:j,filters:I,filterValues:k,selectedSheetId:T}),[e,S,j,I,k,T]),L=v.useCallback((U,Z)=>{const Q=at.normalizeMultiInputPayload(Z);s(J=>({...J,[U]:Q}))},[]),O=x?m(x):null,B=v.useMemo(()=>at.getCustomVisualInputCards({frame:t,configCard:n,isMultiInputVisual:y==="multiple"}),[t,n,y]),H=v.useMemo(()=>at.buildSlotOrderedCards(B),[B]),R=v.useMemo(()=>H.map((U,Z)=>at.getEffectiveCardTypeForSlot(U,Z,b==null?void 0:b.slots)),[H,b==null?void 0:b.slots]),V=v.useMemo(()=>G$(y==="multiple"?K$({slotOrderedCards:H,multiInputData:o,executionSnapshot:_,dashboardId:j,attachmentIndex:E,valueFormatPreferences:r}):[{card:e,cardConfig:N,columns:C==null?void 0:C.columns,columnKeyMap:C==null?void 0:C.columnKeyMap,executionSnapshot:_,dashboardId:j,attachmentIndex:E,valueFormatPreferences:r}]),[e,j,C==null?void 0:C.columnKeyMap,C==null?void 0:C.columns,N,o,E,_,H,y,r]),z=v.useCallback((U,Z)=>{h(Q=>{const J=new Set(Q);return Z?J.add(U):J.delete(U),J})},[]),F=Hj(($=n.customCardPreferences)==null?void 0:$.settings,n);if(!x)return null;const G=((W=(X=e.preferences)==null?void 0:X.displayOptions)==null?void 0:W.allowScroll)??!0;return l.jsx("div",{className:p.cn("semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2",G?"overflow-y-auto":"h-full overflow-hidden"),children:l.jsxs(v.Suspense,{fallback:l.jsx(l.Fragment,{}),children:[O&&y==="single"&&l.jsx(O,{params:c,theme:d,chartSettings:F,settings:F,cardMetadata:Eue({card:e,dataMetadata:C==null?void 0:C.metadata}),onDataChange:L,data:(C==null?void 0:C.records)||[],columns:(C==null?void 0:C.columns)||[],formatTemporalBucketValue:V,filters:P,filterValues:[...A||[],...D||[]],inlineFilters:M}),O&&y==="multiple"&&l.jsxs(l.Fragment,{children:[B.map((U,Z)=>{if(!U)return null;const Q=at.getSlotIndexForCard(U,Z),J=at.getEffectiveCardTypeForSlot(U,Q,b==null?void 0:b.slots);return l.jsx(g$,{onLoadingStatus:z,onDataChange:L,card:U,effectiveCardType:J},`${U.id}-${Q}`)}),l.jsxs("div",{className:p.cn("relative flex h-full min-h-0 flex-1 flex-col gap-2"),children:[f.size>0&&l.jsx("div",{className:"pointer-events-none absolute inset-0 z-10 flex items-center justify-center",children:l.jsx(uc,{size:"md",color:"muted","aria-label":"Loading data"})}),l.jsx(O,{onDataChange:L,...W$({configCard:n,slotOrderedCards:H,slotTypes:R,multiInputData:o,params:c,theme:d,chartSettings:F,filters:P,filterValues:[...A||[],...D||[]],inlineFilters:M,formatTemporalBucketValue:V})})]})]})]},e.id)})}const qj=ret;function Uj({children:e,containerClassName:t,className:n,text:r,onSave:o,type:s="input",placeholder:i,enabled:a}){const[c,u]=v.useState(!1),[d,f]=v.useState(r),h=p.useDashboardStore(y=>y.isDashboardEditing);v.useEffect(()=>{f(y=>y!==r?r:y)},[r]);const m=y=>{y.stopPropagation(),h&&u(!0)};function g(y){if(y.stopPropagation(),y.key==="Escape"){u(!1);return}y.key==="Enter"&&y.shiftKey||(y.key==="Enter"||y.key==="Tab")&&(u(!1),o(d))}function x(){return s==="textarea"?l.jsx("textarea",{className:p.cn("resize rounded-sm bg-background px-2 py-1 text-sm outline-[0.5px] outline-muted",n),onChange:y=>f(y.target.value),value:d,autoFocus:!0,placeholder:i,onBlur:()=>u(!1),onKeyDown:g}):l.jsx("input",{onMouseDown:y=>y.stopPropagation(),type:"text",className:p.cn("rounded-sm bg-background outline-none",n),onChange:y=>f(y.target.value),value:d,autoFocus:!0,placeholder:i,onBlur:()=>u(!1),onKeyDown:g})}function b(){return a?l.jsx("div",{className:"flex grow items-center",children:l.jsx("div",{children:c?x():e})}):e}return l.jsx("div",{className:p.cn("flex",a&&!c&&"cursor-text",t),role:"editable",onDoubleClick:m,onMouseDown:y=>y.stopPropagation(),children:l.jsx("div",{className:"flex grow items-center",children:b()})})}function Y_(e,t){if(!t)return"";const n=t.find(r=>e>=r.start&&e<=r.end);return(n==null?void 0:n.color)||""}function Si(e){const t=e.isEditable!==!1&&e.isPending!==!0?"editable":"read-only";return l.jsx(oet,{...e},t)}function oet({value:e,displayTitle:t=!0,onSave:n,placeholder:r,inputClassName:o,displayClassName:s,isEditable:i=!0,isPending:a=!1,onEditingChange:c}){const[u,d]=v.useState(!1),[f,h]=v.useState(e||""),m=b=>{d(b),c==null||c(b)},g=()=>{m(!1),f!==e&&n(f)},x=b=>{b.key==="Enter"?(m(!1),n(f)):b.key==="Escape"&&(m(!1),h(e||""))};return u?l.jsx("div",{className:"flex",children:l.jsx("input",{type:"text",value:f,onChange:b=>h(b.target.value),onBlur:g,onKeyDown:x,onMouseDown:b=>b.stopPropagation(),className:p.cn("m-0 w-full border-0 bg-transparent p-0 outline-none focus:ring-1 focus:ring-ring/40 focus:ring-offset-2 focus:ring-offset-background",o),autoFocus:!0})}):l.jsxs("div",{className:p.cn("relative truncate transition-colors",s,{"cursor-default":!i,"cursor-text":i}),onClick:()=>{!i||a||(m(!0),h(e||""))},title:t?e||r:void 0,children:[l.jsx("div",{className:"flex items-center justify-between gap-2",children:l.jsx("span",{className:p.cn("truncate",{"text-muted-foreground":a}),children:e||l.jsx("span",{className:"text-muted-foreground",children:r})})}),a&&l.jsx("div",{className:"absolute inset-0 animate-pulse rounded bg-gradient-to-r from-transparent via-blue-100/30 to-transparent"})]})}function EM(e){if(typeof e!="string")return;const t=e.trim();if(!(!t||t.toLowerCase()==="none"))return t}function Due({card:e,preferences:t,boundCurrency:n}){var w,C,N,S,j,I;const r=t===void 0?qi.DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES:t,o=(w=e==null?void 0:e.preferences)==null?void 0:w.formatNumber,s=(N=(C=e==null?void 0:e.preferences)==null?void 0:C.kpiVisualOptions)==null?void 0:N.formatOptions,i=(e==null?void 0:e.type)==="kpi"?S0(e):void 0,a=e&&e.type!=="kpi"?p.fromSemanticFormat((I=(j=(S=e.config)==null?void 0:S.metricColumns)==null?void 0:j[0])==null?void 0:I.format,{preserveOmittedProperties:!0}):void 0,c=(e==null?void 0:e.type)==="kpi"?i==null?void 0:i.authoredFormat:p.fromPersistedKpiFormatOptions(s)||a||p.fromLegacyFormatNumber(o),u=c&&r&&Vt.isNumericCanonicalFormat(c)?$t.resolveNumericPresentation(c,r,n):c,d=(u==null?void 0:u.type)==="currency"?u.currency:void 0,f=EM(o==null?void 0:o.currency),h=d||f,m=u&&"locale"in u&&EM(u.locale),g=EM(o==null?void 0:o.locale),x=m||g||(r==null?void 0:r.locale)||qi.DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES.locale,b=o==null?void 0:o.enabled;return{currency:h,locale:x,canonicalPrimaryFormat:u,isFormattingDisabled:b===!1||b==="false"}}function Mue(e){var c,u,d;const{preferences:t,resolveBoundCurrency:n}=Pa(e),r=(d=(u=(c=e.config)==null?void 0:c.metricColumns)==null?void 0:u[0])==null?void 0:d.id,o=Due({card:e,preferences:t,boundCurrency:r?n({kind:"metric",metricId:r}):void 0});function s(){return o.currency}function i(){return o.locale}function a(){return o.canonicalPrimaryFormat}return{getCurrency:s,getLocale:i,getPrimaryFormat:a}}const set={"currentPeriod.start":"Current Start","currentPeriod.end":"Current End","comparisonPeriod.start":"Previous Start","comparisonPeriod.end":"Previous End"},iet=e=>e.filter(t=>t.segment==="meta"||t.Segment==="meta"),aet=e=>{switch(e){case"target":return"Target";case"previous_year":return"Last Year";case"previous_period":default:return"Previous"}};function DM({label:e,value:t,formatCurrency:n,emphasize:r=!1,signed:o=!1}){const s=n(o?Math.abs(t):t),i=o?t>0?`+${s}`:t<0?`−${s}`:s:s;return l.jsxs("div",{className:"flex items-center justify-between text-[12px]",children:[l.jsx("span",{className:"text-muted-foreground",children:e}),l.jsx("span",{className:r?"font-medium tabular-nums text-foreground":"tabular-nums text-foreground",children:i})]})}function cet({metaKey:e,value:t}){const n=set[e]??e;return l.jsxs("div",{className:"flex items-center justify-between gap-4 text-[12px]",children:[l.jsx("span",{className:"text-muted-foreground",children:n}),l.jsx("span",{className:"tabular-nums text-foreground",children:t})]})}function uet({currentValue:e,comparisonValue:t,formatCurrency:n,comparisonLabel:r="Previous"}){return l.jsxs("div",{className:"space-y-1",children:[l.jsx(DM,{label:"Current",value:e,formatCurrency:n,emphasize:!0}),l.jsx(DM,{label:r,value:t,formatCurrency:n}),l.jsx(DM,{label:"Change",value:e-t,formatCurrency:n,signed:!0})]})}function det({data:e,comparisonMetadata:t}){const n=t==null?void 0:t.output.currentWindow,r=t==null?void 0:t.output.comparisonWindow,o=t==null?void 0:t.output.windowGrain,s=n?GA({start:n.startInclusive,end:n.endExclusive},n.timezone,o):void 0,i=r?GA({start:r.startInclusive,end:r.endExclusive},r.timezone,o):void 0,a=s&&i?[{key:"currentPeriod.start",value:s.start},{key:"currentPeriod.end",value:s.end},{key:"comparisonPeriod.start",value:i.start},{key:"comparisonPeriod.end",value:i.end}]:iet(e);return a.length===0?null:l.jsxs("div",{className:"space-y-1 border-t border-border/60 px-3 py-2.5",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Period Details"}),l.jsx("div",{className:"space-y-1",children:a.map((c,u)=>l.jsx(cet,{metaKey:c.key??c.Key,value:c.value??c.Value},u))})]})}function fet({currentValue:e,comparisonValue:t,sentiment:n,data:r,comparisonMetadata:o,comparisonKind:s,formatCurrency:i,conditionalLabel:a}){const c=aet((o==null?void 0:o.type)??s);return l.jsxs(p.TooltipContent,{side:"right",sideOffset:8,className:"w-[260px] rounded-[6px] border border-border bg-popover p-0 text-popover-foreground shadow-md",children:[a&&l.jsx("div",{className:`border-b border-border/60 px-3 py-2 text-[12px] font-medium ${n==="favorable"?"text-emerald-600 dark:text-emerald-400":n==="unfavorable"?"text-rose-600 dark:text-rose-400":"text-muted-foreground"}`,children:a}),l.jsxs("div",{className:"space-y-1 px-3 py-2.5",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Key Metrics"}),l.jsx(uet,{currentValue:e,comparisonValue:t,formatCurrency:i,comparisonLabel:c})]}),l.jsx(det,{data:r,comparisonMetadata:o})]})}const het=[{id:"us",name:"United States",flag:"🇺🇸",code:"US",region:"North America"},{id:"ca",name:"Canada",flag:"🇨🇦",code:"CA",region:"North America"},{id:"mx",name:"Mexico",flag:"🇲🇽",code:"MX",region:"North America"},{id:"gb",name:"United Kingdom",flag:"🇬🇧",code:"GB",region:"Europe"},{id:"de",name:"Germany",flag:"🇩🇪",code:"DE",region:"Europe"},{id:"fr",name:"France",flag:"🇫🇷",code:"FR",region:"Europe"},{id:"it",name:"Italy",flag:"🇮🇹",code:"IT",region:"Europe"},{id:"es",name:"Spain",flag:"🇪🇸",code:"ES",region:"Europe"},{id:"nl",name:"Netherlands",flag:"🇳🇱",code:"NL",region:"Europe"},{id:"be",name:"Belgium",flag:"🇧🇪",code:"BE",region:"Europe"},{id:"ch",name:"Switzerland",flag:"🇨🇭",code:"CH",region:"Europe"},{id:"at",name:"Austria",flag:"🇦🇹",code:"AT",region:"Europe"},{id:"se",name:"Sweden",flag:"🇸🇪",code:"SE",region:"Europe"},{id:"no",name:"Norway",flag:"🇳🇴",code:"NO",region:"Europe"},{id:"dk",name:"Denmark",flag:"🇩🇰",code:"DK",region:"Europe"},{id:"fi",name:"Finland",flag:"🇫🇮",code:"FI",region:"Europe"},{id:"pl",name:"Poland",flag:"🇵🇱",code:"PL",region:"Europe"},{id:"cz",name:"Czech Republic",flag:"🇨🇿",code:"CZ",region:"Europe"},{id:"hu",name:"Hungary",flag:"🇭🇺",code:"HU",region:"Europe"},{id:"pt",name:"Portugal",flag:"🇵🇹",code:"PT",region:"Europe"},{id:"ie",name:"Ireland",flag:"🇮🇪",code:"IE",region:"Europe"},{id:"gr",name:"Greece",flag:"🇬🇷",code:"GR",region:"Europe"},{id:"jp",name:"Japan",flag:"🇯🇵",code:"JP",region:"Asia"},{id:"cn",name:"China",flag:"🇨🇳",code:"CN",region:"Asia"},{id:"in",name:"India",flag:"🇮🇳",code:"IN",region:"Asia"},{id:"kr",name:"South Korea",flag:"🇰🇷",code:"KR",region:"Asia"},{id:"sg",name:"Singapore",flag:"🇸🇬",code:"SG",region:"Asia"},{id:"hk",name:"Hong Kong",flag:"🇭🇰",code:"HK",region:"Asia"},{id:"tw",name:"Taiwan",flag:"🇹🇼",code:"TW",region:"Asia"},{id:"th",name:"Thailand",flag:"🇹🇭",code:"TH",region:"Asia"},{id:"my",name:"Malaysia",flag:"🇲🇾",code:"MY",region:"Asia"},{id:"id",name:"Indonesia",flag:"🇮🇩",code:"ID",region:"Asia"},{id:"ph",name:"Philippines",flag:"🇵🇭",code:"PH",region:"Asia"},{id:"vn",name:"Vietnam",flag:"🇻🇳",code:"VN",region:"Asia"},{id:"ae",name:"United Arab Emirates",flag:"🇦🇪",code:"AE",region:"Asia"},{id:"sa",name:"Saudi Arabia",flag:"🇸🇦",code:"SA",region:"Asia"},{id:"il",name:"Israel",flag:"🇮🇱",code:"IL",region:"Asia"},{id:"tr",name:"Turkey",flag:"🇹🇷",code:"TR",region:"Asia"},{id:"au",name:"Australia",flag:"🇦🇺",code:"AU",region:"Oceania"},{id:"nz",name:"New Zealand",flag:"🇳🇿",code:"NZ",region:"Oceania"},{id:"br",name:"Brazil",flag:"🇧🇷",code:"BR",region:"South America"},{id:"ar",name:"Argentina",flag:"🇦🇷",code:"AR",region:"South America"},{id:"cl",name:"Chile",flag:"🇨🇱",code:"CL",region:"South America"},{id:"co",name:"Colombia",flag:"🇨🇴",code:"CO",region:"South America"},{id:"pe",name:"Peru",flag:"🇵🇪",code:"PE",region:"South America"},{id:"uy",name:"Uruguay",flag:"🇺🇾",code:"UY",region:"South America"},{id:"ec",name:"Ecuador",flag:"🇪🇨",code:"EC",region:"South America"},{id:"ve",name:"Venezuela",flag:"🇻🇪",code:"VE",region:"South America"},{id:"za",name:"South Africa",flag:"🇿🇦",code:"ZA",region:"Africa"},{id:"ng",name:"Nigeria",flag:"🇳🇬",code:"NG",region:"Africa"},{id:"eg",name:"Egypt",flag:"🇪🇬",code:"EG",region:"Africa"},{id:"ma",name:"Morocco",flag:"🇲🇦",code:"MA",region:"Africa"},{id:"ke",name:"Kenya",flag:"🇰🇪",code:"KE",region:"Africa"},{id:"gh",name:"Ghana",flag:"🇬🇭",code:"GH",region:"Africa"},{id:"et",name:"Ethiopia",flag:"🇪🇹",code:"ET",region:"Africa"},{id:"tz",name:"Tanzania",flag:"🇹🇿",code:"TZ",region:"Africa"},{id:"ru",name:"Russia",flag:"🇷🇺",code:"RU",region:"Europe/Asia"},{id:"ua",name:"Ukraine",flag:"🇺🇦",code:"UA",region:"Europe"},{id:"by",name:"Belarus",flag:"🇧🇾",code:"BY",region:"Europe"},{id:"lt",name:"Lithuania",flag:"🇱🇹",code:"LT",region:"Europe"},{id:"lv",name:"Latvia",flag:"🇱🇻",code:"LV",region:"Europe"},{id:"ee",name:"Estonia",flag:"🇪🇪",code:"EE",region:"Europe"},{id:"ro",name:"Romania",flag:"🇷🇴",code:"RO",region:"Europe"},{id:"bg",name:"Bulgaria",flag:"🇧🇬",code:"BG",region:"Europe"},{id:"hr",name:"Croatia",flag:"🇭🇷",code:"HR",region:"Europe"},{id:"si",name:"Slovenia",flag:"🇸🇮",code:"SI",region:"Europe"},{id:"sk",name:"Slovakia",flag:"🇸🇰",code:"SK",region:"Europe"},{id:"rs",name:"Serbia",flag:"🇷🇸",code:"RS",region:"Europe"},{id:"ba",name:"Bosnia and Herzegovina",flag:"🇧🇦",code:"BA",region:"Europe"},{id:"me",name:"Montenegro",flag:"🇲🇪",code:"ME",region:"Europe"},{id:"mk",name:"North Macedonia",flag:"🇲🇰",code:"MK",region:"Europe"},{id:"al",name:"Albania",flag:"🇦🇱",code:"AL",region:"Europe"},{id:"xk",name:"Kosovo",flag:"🇽🇰",code:"XK",region:"Europe"},{id:"md",name:"Moldova",flag:"🇲🇩",code:"MD",region:"Europe"},{id:"is",name:"Iceland",flag:"🇮🇸",code:"IS",region:"Europe"},{id:"lu",name:"Luxembourg",flag:"🇱🇺",code:"LU",region:"Europe"},{id:"mt",name:"Malta",flag:"🇲🇹",code:"MT",region:"Europe"},{id:"cy",name:"Cyprus",flag:"🇨🇾",code:"CY",region:"Europe"},{id:"mc",name:"Monaco",flag:"🇲🇨",code:"MC",region:"Europe"},{id:"ad",name:"Andorra",flag:"🇦🇩",code:"AD",region:"Europe"},{id:"sm",name:"San Marino",flag:"🇸🇲",code:"SM",region:"Europe"},{id:"va",name:"Vatican City",flag:"🇻🇦",code:"VA",region:"Europe"},{id:"li",name:"Liechtenstein",flag:"🇱🇮",code:"LI",region:"Europe"},{id:"pk",name:"Pakistan",flag:"🇵🇰",code:"PK",region:"Asia"},{id:"bd",name:"Bangladesh",flag:"🇧🇩",code:"BD",region:"Asia"},{id:"lk",name:"Sri Lanka",flag:"🇱🇰",code:"LK",region:"Asia"},{id:"np",name:"Nepal",flag:"🇳🇵",code:"NP",region:"Asia"},{id:"bt",name:"Bhutan",flag:"🇧🇹",code:"BT",region:"Asia"},{id:"mv",name:"Maldives",flag:"🇲🇻",code:"MV",region:"Asia"},{id:"af",name:"Afghanistan",flag:"🇦🇫",code:"AF",region:"Asia"},{id:"ir",name:"Iran",flag:"🇮🇷",code:"IR",region:"Asia"},{id:"iq",name:"Iraq",flag:"🇮🇶",code:"IQ",region:"Asia"},{id:"sy",name:"Syria",flag:"🇸🇾",code:"SY",region:"Asia"},{id:"lb",name:"Lebanon",flag:"🇱🇧",code:"LB",region:"Asia"},{id:"jo",name:"Jordan",flag:"🇯🇴",code:"JO",region:"Asia"},{id:"kw",name:"Kuwait",flag:"🇰🇼",code:"KW",region:"Asia"},{id:"qa",name:"Qatar",flag:"🇶🇦",code:"QA",region:"Asia"},{id:"bh",name:"Bahrain",flag:"🇧🇭",code:"BH",region:"Asia"},{id:"om",name:"Oman",flag:"🇴🇲",code:"OM",region:"Asia"},{id:"ye",name:"Yemen",flag:"🇾🇪",code:"YE",region:"Asia"},{id:"ge",name:"Georgia",flag:"🇬🇪",code:"GE",region:"Asia"},{id:"am",name:"Armenia",flag:"🇦🇲",code:"AM",region:"Asia"},{id:"az",name:"Azerbaijan",flag:"🇦🇿",code:"AZ",region:"Asia"},{id:"kz",name:"Kazakhstan",flag:"🇰🇿",code:"KZ",region:"Asia"},{id:"kg",name:"Kyrgyzstan",flag:"🇰🇬",code:"KG",region:"Asia"},{id:"tj",name:"Tajikistan",flag:"🇹🇯",code:"TJ",region:"Asia"},{id:"tm",name:"Turkmenistan",flag:"🇹🇲",code:"TM",region:"Asia"},{id:"uz",name:"Uzbekistan",flag:"🇺🇿",code:"UZ",region:"Asia"},{id:"mn",name:"Mongolia",flag:"🇲🇳",code:"MN",region:"Asia"},{id:"kp",name:"North Korea",flag:"🇰🇵",code:"KP",region:"Asia"},{id:"mm",name:"Myanmar",flag:"🇲🇲",code:"MM",region:"Asia"},{id:"la",name:"Laos",flag:"🇱🇦",code:"LA",region:"Asia"},{id:"kh",name:"Cambodia",flag:"🇰🇭",code:"KH",region:"Asia"},{id:"bn",name:"Brunei",flag:"🇧🇳",code:"BN",region:"Asia"},{id:"tl",name:"East Timor",flag:"🇹🇱",code:"TL",region:"Asia"},{id:"dz",name:"Algeria",flag:"🇩🇿",code:"DZ",region:"Africa"},{id:"tn",name:"Tunisia",flag:"🇹🇳",code:"TN",region:"Africa"},{id:"ly",name:"Libya",flag:"🇱🇾",code:"LY",region:"Africa"},{id:"sd",name:"Sudan",flag:"🇸🇩",code:"SD",region:"Africa"},{id:"ss",name:"South Sudan",flag:"🇸🇸",code:"SS",region:"Africa"},{id:"td",name:"Chad",flag:"🇹🇩",code:"TD",region:"Africa"},{id:"ne",name:"Niger",flag:"🇳🇪",code:"NE",region:"Africa"},{id:"ml",name:"Mali",flag:"🇲🇱",code:"ML",region:"Africa"},{id:"bf",name:"Burkina Faso",flag:"🇧🇫",code:"BF",region:"Africa"},{id:"sn",name:"Senegal",flag:"🇸🇳",code:"SN",region:"Africa"},{id:"gm",name:"Gambia",flag:"🇬🇲",code:"GM",region:"Africa"},{id:"gw",name:"Guinea-Bissau",flag:"🇬🇼",code:"GW",region:"Africa"},{id:"gn",name:"Guinea",flag:"🇬🇳",code:"GN",region:"Africa"},{id:"sl",name:"Sierra Leone",flag:"🇸🇱",code:"SL",region:"Africa"},{id:"lr",name:"Liberia",flag:"🇱🇷",code:"LR",region:"Africa"},{id:"ci",name:"Ivory Coast",flag:"🇨🇮",code:"CI",region:"Africa"},{id:"tg",name:"Togo",flag:"🇹🇬",code:"TG",region:"Africa"},{id:"bj",name:"Benin",flag:"🇧🇯",code:"BJ",region:"Africa"},{id:"zw",name:"Zimbabwe",flag:"🇿🇼",code:"ZW",region:"Africa"},{id:"zm",name:"Zambia",flag:"🇿🇲",code:"ZM",region:"Africa"}];function Rue(e){const t=p.useDashboardStore(c=>c.isDashboardEditing),n=p.useDashboardStore(c=>c.isVisualEditing),{setCardTitle:r,setCountryLogo:o}=p.useEditorActions();return{setTitle:c=>{n&&r(c)},setCountryLogo:c=>{n&&o(c)},isEditable:n,isDashboardEditing:t,isVisualEditing:n}}function met(e,t){var r,o;if(!e)return e;const n=(o=(r=e.config)==null?void 0:r.metricColumns)==null?void 0:o[t];return{...e,config:{...e.config,metricColumns:n?[n]:[]},preferences:e.preferences}}function pet(e){var x,b,y,w,C,N;if(!e)return e;const t=(b=(x=e.config)==null?void 0:x.metricColumns)==null?void 0:b[0],n=(y=e.preferences)==null?void 0:y.formatNumber,r=(C=(w=e.preferences)==null?void 0:w.kpiVisualOptions)==null?void 0:C.formatOptions,o=p.fromTFormatOptions(r),s=(o==null?void 0:o.type)==="date"?SU(r==null?void 0:r.locale):void 0,i=o&&(Vt.isNumericCanonicalFormat(o)||o.type==="duration")?r:void 0,a=p.fromSemanticFormat(t==null?void 0:t.format),c=a&&(a.type==="date"||a.type==="string")&&"locale"in a?SU(a.locale):void 0,u=s||c,d=a&&(Vt.isNumericCanonicalFormat(a)||a.type==="duration")&&t?[u&&t.format&&typeof t.format=="object"?{...t,format:{...t.format,locale:u}}:t]:[],h=((o==null?void 0:o.type)==="date"||(o==null?void 0:o.type)==="string"||(o==null?void 0:o.type)==="temporal_bucket"||(a==null?void 0:a.type)==="date"||(a==null?void 0:a.type)==="string"||(a==null?void 0:a.type)==="temporal_bucket")&&!i&&d.length===0,m=!i&&u?{locale:u}:void 0,g=h?{...n,locale:u||(n==null?void 0:n.locale),currency:void 0,prefix:void 0,suffix:void 0,percentValueMode:void 0}:n;return{...e,config:{...e.config,metricColumns:d},preferences:{...e.preferences,formatNumber:g,kpiVisualOptions:{...(N=e.preferences)==null?void 0:N.kpiVisualOptions,formatOptions:i||m}}}}function get(e){return e!=="date"}function SU(e){if(typeof e!="string")return;const t=e.trim();if(!(!t||t.toLowerCase()==="none"))return t}function lp({card:e,preferences:t,boundCurrency:n}){const r=t===void 0?qi.DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES:t,{canonicalPrimaryFormat:o,isFormattingDisabled:s}=Due({card:e,preferences:t,boundCurrency:n}),i=o&&Vt.isNumericCanonicalFormat(o)?o:void 0,a=o&&(o.type==="date"||o.type==="duration")?p.toTFormatOptions(o):void 0,c={type:"number",locale:(r==null?void 0:r.locale)||qi.DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES.locale,minimumFractionDigits:0,maximumFractionDigits:0,useGrouping:!0},u=o==null?void 0:o.type,d=(g,{forceCompact:x=!1,forceSign:b=!1}={})=>{if(g==null)return"n/a";if(s){const w=String(g);return b&&g>0?`+${w}`:w}const y=a!=null&&a.type&&a.type!=="auto"?yr(g,a.type,a):$t.formatNumericCanonical(g,{...i||c,compact:x?!0:i==null?void 0:i.compact});return b&&g>0?`+${y}`:y};return{format:g=>d(g),formatCompact:g=>d(g,{forceCompact:!0}),formatSigned:g=>d(g,{forceSign:!0}),supportsComparisonDeltaInheritance:get(u)}}function NU({card:e,preferences:t,boundCurrency:n,metricIndex:r}){return lp({card:met(e,r),preferences:t,boundCurrency:n})}function Aue({card:e,preferences:t,boundCurrency:n}){return lp({card:pet(e),preferences:t,boundCurrency:n})}function bet({card:e,data:t,isPending:n,headerAction:r,headerTrailingAction:o}){var Y,K,$,X,W,U,Z,Q,J,re,de,le,ce,oe,fe,we,pe,ne,Se,ue,ie,ee;const s=e.config,{setTitle:i,isEditable:a,isVisualEditing:c}=Rue(),{setCardDescription:u}=p.useEditorActions(),{getLocale:d}=Mue(e),{preferences:f,boundCurrency:h,resolveBoundCurrency:m}=n_(e,t),g=($=(K=(Y=e.config)==null?void 0:Y.metricColumns)==null?void 0:K[1])==null?void 0:$.id,x=(U=(W=(X=e.config)==null?void 0:X.metricColumns)==null?void 0:W[2])==null?void 0:U.id,b=g?m({kind:"metric",metricId:g}):void 0,y=x?m({kind:"metric",metricId:x}):void 0,w=v.useMemo(()=>lp({card:e,preferences:f,boundCurrency:h}),[e,h,f]),C=v.useMemo(()=>NU({card:e,preferences:f,boundCurrency:b,metricIndex:1}),[e,b,f]),N=v.useMemo(()=>NU({card:e,preferences:f,boundCurrency:y,metricIndex:2}),[e,y,f]),S=(s==null?void 0:s.metricColumns)||[],j=((Z=e.preferences)==null?void 0:Z.metricPairComparisonEnabled)===!0,I=ae=>w.format(ae),k=ae=>w.formatCompact(ae),T=ae=>C.format(ae),_=ae=>N.format(ae),E=!!p.fromSemanticFormat((Q=S[1])==null?void 0:Q.format),D=ae=>E||b?T(ae):I(ae),M=ae=>{const se=t==null?void 0:t.find(he=>{var ge,ke;return he.segment===ae||he.Segment===ae||((ge=he.segment)==null?void 0:ge.toLowerCase())===ae.toLowerCase()||((ke=he.Segment)==null?void 0:ke.toLowerCase())===ae.toLowerCase()});return(se==null?void 0:se.value)??(se==null?void 0:se.Value)??0},P=M("current"),A=M("comparison"),L=M("tertiary"),O=p.getMetricComparisonPolarity(S[0]),B=(re=(J=e.preferences)==null?void 0:J.formatNumber)==null?void 0:re.colorRanges,H=Y_(P,B);function R(){return e.title?e.title:a?"Enter title":""}if(n)return l.jsxs("div",{className:"flex h-full grow flex-col",children:[l.jsx("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:l.jsx("div",{className:"h-3 w-24 rounded bg-foreground/[0.06]"})}),l.jsxs("div",{className:"flex flex-1 flex-col gap-2 px-4 py-3",children:[l.jsx("div",{className:"h-7 w-32 rounded bg-foreground/[0.06]"}),e.description&&l.jsx("div",{className:"h-3 w-24 rounded bg-foreground/[0.06]"})]})]});const V=j&&S.length===2,z=S.length>=2&&A!==void 0,F=S.length>2&&L!==void 0,q=((de=e==null?void 0:e.kpiPreferences)==null?void 0:de.format)==="compact"?k(P):I(P);return l.jsxs("div",{className:"flex h-full grow flex-col",children:[l.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:[l.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[l.jsx(Si,{displayClassName:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",inputClassName:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",value:R(),isEditable:a,onSave:i}),(e.description||c)&&l.jsx(Si,{isEditable:c,value:e.description||(c?"Enter description":""),placeholder:c?"Enter description":"",displayClassName:"min-w-0 truncate text-[11px] text-muted-foreground/80",inputClassName:"min-w-0 truncate text-[11px] text-muted-foreground/80",onSave:u})]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[r,V&&l.jsx("div",{className:"shrink-0",children:l.jsx(y3,{primaryValue:P,secondaryValue:A,presentation:(le=e.preferences)==null?void 0:le.comparisonPresentation,metricFormatOptions:(oe=(ce=e.preferences)==null?void 0:ce.kpiVisualOptions)==null?void 0:oe.formatOptions,locale:d()||"en-US",decimalPlaces:(we=(fe=e.preferences)==null?void 0:fe.formatNumber)==null?void 0:we.decimalPlaces,suffix:(ne=(pe=e.preferences)==null?void 0:pe.formatNumber)==null?void 0:ne.suffix,polarity:O,signedValueFormatter:w.formatSigned,allowSignedValueFormatter:w.supportsComparisonDeltaInheritance})}),o]})]}),l.jsxs("div",{className:"flex flex-1 flex-col gap-2 px-4 py-3",children:[l.jsx("p",{className:"text-[34px] font-semibold tabular-nums leading-none tracking-tight text-foreground",style:H?{color:H}:void 0,children:q}),z&&l.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[((Se=S[1])==null?void 0:Se.label)||((ue=S[1])==null?void 0:ue.name),l.jsx("span",{className:"mx-1.5 text-muted-foreground/60",children:"·"}),l.jsx("span",{className:"tabular-nums text-foreground/80",children:D(A)})]})]}),F&&l.jsxs("div",{className:"flex shrink-0 items-center justify-between border-t border-border/60 px-4 py-2",children:[l.jsx("span",{className:"truncate text-[11px] text-muted-foreground",children:((ie=S[2])==null?void 0:ie.label)||((ee=S[2])==null?void 0:ee.name)}),l.jsx("span",{className:"text-[12px] font-medium tabular-nums text-foreground",children:_(L)})]})]})}function xet(e){var t;return e.comparisonKind==="target"&&e.targetValue>0&&((t=e.presentation)==null?void 0:t.showComparison)!==!1}function yet(e){const{comparisonKind:t,comparisonValue:n,targetValue:r}=e;return t==="target"?typeof r=="number"&&!Number.isNaN(r)?r:null:n}function vet(e){return typeof e=="number"?"number":typeof e=="boolean"?"boolean":e instanceof Date?"date":"string"}function wet(e){const t=Array.isArray(e.payload.filters)?e.payload.filters:[];return t.length>0?t:[{field:e.payload.field,operator:e.payload.operator,value:e.payload.value}]}function Cet(e,t){return t?`summary:${e}:${t}`:`summary:${e}`}function Pue({addOrUpdateFilterValues:e,onEvent:t,refresh:n,selectedSheetId:r,cardId:o,onChangeComparison:s}){return async i=>{if(i.type==="apply_filter"){const a=wet(i),c=[];for(const u of a){const d=String(u.field||"").trim(),f=String(u.operator||"=").trim(),h=u.value,m=Array.isArray(h)?h[0]:h;if(!d||m==null)continue;const g={filterId:Cet(d,r),name:d,operation:f==="eq"?"=":f==="in"?"in":"=",valueType:vet(m),values:Array.isArray(h)?h:[m]};c.push(g)}c.length>0&&e(c),t==null||t({type:"info",message:{event:"summary_driver_chip_clicked",actionId:i.idempotencyKey,...o?{cardId:o}:{}}});return}if(i.type==="refresh"){await n(),t==null||t({type:"info",message:{event:"summary_retry_clicked",actionId:i.idempotencyKey,...o?{cardId:o}:{}}});return}i.type==="change_comparison"&&s&&await s(i)}}function Net(e){return e==="kpi"}function Fue(e){var t,n;return Net(e==null?void 0:e.type)&&((n=(t=e==null?void 0:e.config)==null?void 0:t.summary)==null?void 0:n.enabled)===!0}function Y$(e){var n;const t=(n=e==null?void 0:e.config)==null?void 0:n.summary;return Fue(e)&&((t==null?void 0:t.showOnCard)===!0||((t==null?void 0:t.breakdownDimensions)||[]).length>0)}function jU(e){var t,n;return Fue(e)&&((n=(t=e==null?void 0:e.config)==null?void 0:t.summary)==null?void 0:n.includeInDashboardSummary)===!0}function Z$(e,t){var R,V;const{authToken:n,tokenProps:r}=It(),o=p.useDashboardStore(z=>z.selectedSheetId),s=p.useDashboardStore(z=>z.dashboard),i=p.useDashboardStore(z=>z.selectedLensId),a=p.useDashboardStore(z=>z.dashboardInputReferenceTime),c=p.useDashboardStore(z=>z.onEvent),u=Zr(),{addOrUpdateFilterValues:d}=p.useDashboardActions(),f=l3(e),{finalConfig:h,finalFiltersKey:m,queryRelevantConfig:g}=f,x=v.useMemo(()=>p.getDashboardCards(s),[s]),b=v.useMemo(()=>x.length>0?x:[e],[e,x]),y=v.useMemo(()=>Object.fromEntries(b.map(z=>[z.id,z.id===e.id?g:z.config])),[e.id,g,b]),w=vI(b,{authority:"runtime",queryRelevantConfigsByCardId:y}).payload,C=p.useDashboardStore(z=>{var F;return((F=z.reportContext)==null?void 0:F.calendar)??null}),N=C==null?void 0:C.tz,S=v.useMemo(()=>p.getGlobalDateFilterCoverage(s,w),[s,w]),j=v.useMemo(()=>aw({card:e,cardConfig:f.queryRelevantConfig,input:f.filterCompilationInput,semanticExecutionPayload:w,timezone:N,allowMinutePrecision:S.allEligibleTargetsAreDateTime,comparisonReferenceTime:a}),[e,f,w,N,a,S.allEligibleTargetsAreDateTime]),I=j.status==="ready"?j.cardFilterValues:void 0,k=j.status==="ready"?j.globalDateComparison:void 0,T=j.status==="blocked",_=(t==null?void 0:t.enabled)??!0,E=v.useMemo(()=>({id:e.id,title:e.title,type:e.type,config:h,dataSource:e.dataSource,preferences:e.preferences}),[e.id,e.title,e.type,h,e.dataSource,e.preferences]),D=v.useMemo(()=>JSON.stringify({type:e.type,config:h,dataSource:e.dataSource}),[e.type,h,e.dataSource]),M=(s==null?void 0:s.id)||(r==null?void 0:r.dashboard_id),P=o||((V=(R=s==null?void 0:s.sheets)==null?void 0:R[0])==null?void 0:V.id)||null,A=!!(n!=null&&n.accessToken&&(r!=null&&r.apiServiceUrl)&&M&&P&&(e!=null&&e.id)&&C&&_&&Y$(e)&&j.status==="ready"),L=v.useMemo(()=>["card-summary",M,P,e.id,i,m,j.status,j.mappingDispositions,JSON.stringify(I||[]),D,k,C],[M,P,e.id,i,m,j.status,j.mappingDispositions,I,D,k,C]),O=qn({queryKey:L,enabled:A,staleTime:1e3,queryFn:async()=>{if(T)throw new Error("Resolve the dashboard filter mapping before generating this summary.");const z=`${r.apiServiceUrl}/v1/dashboard/${M}/cards/${e.id}/summary`;return p.postRequestRegular(z,(n==null?void 0:n.accessToken)||"",{selectedSheetId:P,activeFilters:I||[],lensId:i,cardOverride:E,globalDateComparison:k,calendarContext:C})}}),B=Ts({mutationFn:async()=>{if(j.status==="blocked")throw new Error("Resolve the dashboard filter mapping before refreshing this summary.");const z=`${r.apiServiceUrl}/v1/dashboard/${M}/cards/${e.id}/summary`;return p.postRequestRegular(z,(n==null?void 0:n.accessToken)||"",{selectedSheetId:P,activeFilters:I||[],lensId:i,cardOverride:E,globalDateComparison:k,calendarContext:C,refresh:!0})},onSuccess:z=>{u.setQueryData(L,z)}}),H=v.useMemo(()=>Pue({addOrUpdateFilterValues:d,onEvent:c,refresh:()=>B.mutateAsync(),selectedSheetId:P,cardId:e.id}),[d,c,B,P,e.id]);return{data:T?void 0:O.data,isLoading:O.isLoading,isFetching:O.isFetching,isError:O.isError,error:O.error,refresh:B.mutateAsync,isRefreshing:B.isPending,applyAction:H,enabled:A}}function jet(e,t){var r;if(!((r=e==null?void 0:e.sheets)!=null&&r.length)||!t)return[];const n=e.sheets.find(o=>o.id===t)||e.sheets[0];return n?[...n.cards||[],...(n.frames||[]).flatMap(o=>o.cards||[])]:[]}function Oue(){var B,H;const{authToken:e,tokenProps:t}=It(),n=p.useDashboardStore(R=>{var V;return((V=R.reportContext)==null?void 0:V.calendar)??null}),r=n==null?void 0:n.tz,o=p.useDashboardStore(R=>R.selectedSheetId),s=p.useDashboardStore(R=>R.dashboard),i=p.useDashboardStore(R=>R.dashboard.filters),a=p.useDashboardStore(R=>R.semanticExecutionPayload),c=v.useMemo(()=>p.getGlobalDateFilterCoverage(s,a),[s,a]),u=p.useDashboardStore(R=>R.filterValues),d=p.useDashboardStore(R=>R.inlineFilterValuesMap),f=p.useDashboardStore(R=>R.dashboardInputValues),h=p.useDashboardStore(R=>R.dashboardInputReferenceTime),m=p.useDashboardStore(R=>R.controlValues),g=p.useDashboardStore(R=>R.cardControlValuesMap),x=p.useDashboardStore(R=>R.selectedLensId),b=p.useDashboardStore(R=>R.onEvent),y=p.useInteractionStore(R=>R.interactionStates),w=Zr(),{addOrUpdateFilterValues:C}=p.useDashboardActions(),N=(s==null?void 0:s.id)||(t==null?void 0:t.dashboard_id),S=o||((H=(B=s==null?void 0:s.sheets)==null?void 0:B[0])==null?void 0:H.id)||null,j=v.useMemo(()=>jet(s,S),[s,S]),I=v.useMemo(()=>j.some(R=>jU(R)),[j]),k=v.useMemo(()=>{const R={},V=[];for(const z of j){if(!jU(z))continue;const F=Cb({card:z,dashboard:s,interactionStates:y,currentDashboardId:s==null?void 0:s.id,filters:i,filterValues:u,selectedSheetId:S,inlineFilterValuesMap:d,dashboardInputContext:Ti({dashboard:s,sheetId:S,card:z,runtimeValues:{dashboardInputValues:f,filterValues:u,controlValues:m,inlineFilterValuesMap:d,cardControlValuesMap:g}})}),G=aw({card:z,cardConfig:F.queryRelevantConfig,input:F.filterCompilationInput,semanticExecutionPayload:a,timezone:r,allowMinutePrecision:c.allEligibleTargetsAreDateTime,comparisonReferenceTime:h});if(G.status==="blocked"){V.push(z.id);continue}const{cardFilterValues:q,globalDateComparison:Y}=G;R[z.id]={activeFilters:q,cardOverride:{id:z.id,title:z.title,type:z.type,config:F.finalConfig,dataSource:z.dataSource,preferences:z.preferences},globalDateComparison:Y}}return{contexts:R,blockedCardIds:V}},[j,y,s,i,a,c.allEligibleTargetsAreDateTime,u,S,d,f,h,m,g,r]),T=k.contexts,_=k.blockedCardIds.length>0,E=!!(e!=null&&e.accessToken&&(t!=null&&t.apiServiceUrl)&&N&&S&&n&&I&&!_),D=v.useMemo(()=>bee({filters:i,filterValues:u||[],dashboard:s,semanticExecutionPayload:a,timezone:r,allowMinutePrecision:c.allEligibleTargetsAreDateTime}),[i,u,s,a,r,c.allEligibleTargetsAreDateTime]),M=v.useMemo(()=>JSON.stringify(k),[k]),P=v.useMemo(()=>["dashboard-summary",N,S,x,JSON.stringify(D),M,n],[N,S,x,D,M,n]),A=qn({queryKey:P,enabled:E,staleTime:1e3,queryFn:async()=>{if(_)throw new Error("Resolve dashboard filter mappings before generating a dashboard summary.");const R=`${t.apiServiceUrl}/v1/dashboard/${N}/summary`;return p.postRequestRegular(R,(e==null?void 0:e.accessToken)||"",{selectedSheetId:S,activeFilters:D,lensId:x,cardContexts:T,calendarContext:n})}}),L=Ts({mutationFn:async()=>{if(_)throw new Error("Resolve dashboard filter mappings before refreshing the dashboard summary.");const R=`${t.apiServiceUrl}/v1/dashboard/${N}/summary`;return p.postRequestRegular(R,(e==null?void 0:e.accessToken)||"",{selectedSheetId:S,activeFilters:D,lensId:x,refresh:!0,cardContexts:T,calendarContext:n})},onSuccess:R=>{w.setQueryData(P,R)}}),O=v.useMemo(()=>Pue({addOrUpdateFilterValues:C,onEvent:b,refresh:()=>L.mutateAsync(),selectedSheetId:S,onChangeComparison:R=>{b==null||b({type:"info",message:{event:"summary_action_clicked",actionType:"change_comparison",payload:R.payload}})}}),[C,b,L,S]);return{data:A.data,isLoading:A.isLoading,isFetching:A.isFetching,isError:A.isError,error:A.error,refetch:A.refetch,refresh:L.mutateAsync,isRefreshing:L.isPending,applyAction:O,enabled:E}}var Z_="Collapsible",[ket,Lue]=p.createContextScope(Z_),[Iet,X$]=ket(Z_),$ue=te.forwardRef((e,t)=>{const{__scopeCollapsible:n,open:r,defaultOpen:o,disabled:s,onOpenChange:i,...a}=e,[c,u]=p.useControllableState({prop:r,defaultProp:o??!1,onChange:i,caller:Z_});return l.jsx(Iet,{scope:n,disabled:s,contentId:p.useId(),open:c,onOpenToggle:te.useCallback(()=>u(d=>!d),[u]),children:l.jsx(p.Primitive.div,{"data-state":tz(c),"data-disabled":s?"":void 0,...a,ref:t})})});$ue.displayName=Z_;var zue="CollapsibleTrigger",Q$=te.forwardRef((e,t)=>{const{__scopeCollapsible:n,...r}=e,o=X$(zue,n);return l.jsx(p.Primitive.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":tz(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...r,ref:t,onClick:p.composeEventHandlers(e.onClick,o.onOpenToggle)})});Q$.displayName=zue;var J$="CollapsibleContent",ez=te.forwardRef((e,t)=>{const{forceMount:n,...r}=e,o=X$(J$,e.__scopeCollapsible);return l.jsx(p.Presence,{present:n||o.open,children:({present:s})=>l.jsx(_et,{...r,ref:t,present:s})})});ez.displayName=J$;var _et=te.forwardRef((e,t)=>{const{__scopeCollapsible:n,present:r,children:o,...s}=e,i=X$(J$,n),[a,c]=te.useState(r),u=te.useRef(null),d=p.useComposedRefs(t,u),f=te.useRef(0),h=f.current,m=te.useRef(0),g=m.current,x=i.open||a,b=te.useRef(x),y=te.useRef(void 0);return te.useEffect(()=>{const w=requestAnimationFrame(()=>b.current=!1);return()=>cancelAnimationFrame(w)},[]),p.useLayoutEffect2(()=>{const w=u.current;if(w){y.current=y.current||{transitionDuration:w.style.transitionDuration,animationName:w.style.animationName},w.style.transitionDuration="0s",w.style.animationName="none";const C=w.getBoundingClientRect();f.current=C.height,m.current=C.width,b.current||(w.style.transitionDuration=y.current.transitionDuration,w.style.animationName=y.current.animationName),c(r)}},[i.open,r]),l.jsx(p.Primitive.div,{"data-state":tz(i.open),"data-disabled":i.disabled?"":void 0,id:i.contentId,hidden:!x,...s,ref:d,style:{"--radix-collapsible-content-height":h?`${h}px`:void 0,"--radix-collapsible-content-width":g?`${g}px`:void 0,...e.style},children:x&&o})});function tz(e){return e?"open":"closed"}var Bue=$ue,Tet=Q$,Eet=ez;const ku=Bue,Iu=Q$,_u=ez;function Det(e){return e==null?"n/a":`${(e*100).toFixed(1)}%`}function nz({card:e,preferences:t,boundCurrency:n}){const r=lp({card:e,preferences:t,boundCurrency:n}),o=Aue({card:e,preferences:t,boundCurrency:n});return{formatValue:a=>r.format(a),formatSigned:a=>o.formatSigned(a),formatPct:Det}}const Met=new Set(["PARTIAL_TIMEOUT","DRIVER_DATA_INSUFFICIENT","UNSUPPORTED_CARD_EXCLUDED","CARD_QUERY_FAILED"]);function Ww(e){return e.filter(t=>Met.has(t))}function rz({partial:e,warnings:t}){return e?t.length===0?!0:Ww(t).length>0:!1}const Wj="Summary may be incomplete. Refresh to try again.",Ret={PARTIAL_TIMEOUT:"Summary is partial because generation exceeded the response time budget.",LLM_TIMEOUT_FALLBACK:"Using deterministic summary because narrative generation timed out.",DRIVER_DATA_INSUFFICIENT:"There is not enough breakdown data to compute reliable drivers.",UNSUPPORTED_CARD_EXCLUDED:"Some unsupported chart types were excluded from summary computation.",CARD_QUERY_FAILED:"One or more card summary queries failed; showing available summary results."};function Aet(e){return e==null?"n/a":`${(e*100).toFixed(1)}%`}function dv(e){return e.split("/").map(t=>t.trim()).filter(Boolean).join(", ")}function rF(e){return Ret[e]||e}function Pet(e){return e.kind==="value_contributor"}function oz({className:e,message:t=Wj,showLabel:n=!1}){return l.jsxs("span",{title:t,"aria-label":t,className:p.cn("inline-flex items-center gap-1 text-amber-600",n&&"rounded border border-amber-200 bg-amber-50 px-1.5 py-0.5 text-[11px] font-medium text-amber-700",e),children:[l.jsx(Yo,{className:"h-3.5 w-3.5"}),n&&l.jsx("span",{children:"Summary issue"})]})}function Fet(e){const t=Ww(e.metadata.warnings);return t.length===1?rF(t[0]):t.length>1?`Summary has ${t.length} warnings: ${t.map(rF).join(" ")}`:(rz(e.metadata),Wj)}function Vue(e,t){if(e==null)return null;const n=t.formatPct(e);return e>0?`+${n}`:n}function sz(e){return e==="up"?"text-emerald-600 dark:text-emerald-400":e==="down"?"text-rose-600 dark:text-rose-400":"text-foreground"}function Hue(e,t){if(e.length===0)return t;const n=e[0].dimension;return e.every(o=>o.dimension===n)&&n?`${t} by ${n}`:t}function que(e,t){return Pet(e)?`${t.formatValue(e.current)} · ${t.formatPct(e.contributionPct)}`:t.formatSigned(e.delta)}function Oet({data:e,formatter:t}){const n=e.keyChanges[0];if(!n)return e.narrative?l.jsxs("div",{className:"space-y-1 px-4 py-3",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"What changed"}),l.jsx("p",{className:"text-[13px] leading-[20px] text-foreground",children:e.narrative})]}):null;const r=n.direction==="up";n.direction;const o=sz(n.direction);if(n.comparison==null)return l.jsx("div",{className:"px-4 py-3",children:l.jsxs("p",{className:"text-[13px] leading-[20px] text-foreground",children:[n.label," is"," ",l.jsx("span",{className:"font-medium tabular-nums",children:t.formatValue(n.current)})," ","in the current view."]})});if(n.direction==="flat")return l.jsxs("div",{className:"space-y-1 px-4 py-3",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"What changed"}),l.jsxs("p",{className:"text-[13px] leading-[20px] text-foreground",children:[n.label," was unchanged at"," ",l.jsx("span",{className:"font-medium tabular-nums",children:t.formatValue(n.current)})," ","versus comparison."]})]});const s=r?"rose to":"fell to",i=r?"up":"down",a=n.delta!=null?t.formatSigned(n.delta):null,c=Vue(n.deltaPct,t);return l.jsxs("div",{className:"space-y-1 px-4 py-3",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"What changed"}),l.jsxs("p",{className:"text-[13px] leading-[20px] text-foreground",children:[n.label," ",s," ",l.jsx("span",{className:"font-medium tabular-nums",children:t.formatValue(n.current)}),a&&l.jsxs(l.Fragment,{children:[", ",i," ",l.jsx("span",{className:p.cn("font-medium tabular-nums",o),children:a}),c&&l.jsxs(l.Fragment,{children:[" (",l.jsx("span",{className:p.cn("tabular-nums",o),children:c}),")"]})]})," ","versus comparison."]})]})}function Let(e,t){if(e.comparison==null)return t.formatValue(e.current);if(e.direction==="flat")return`${t.formatValue(e.current)} · unchanged`;const n=t.formatSigned(e.delta),r=Vue(e.deltaPct,t);return r?`${t.formatValue(e.current)} · ${n} (${r})`:`${t.formatValue(e.current)} · ${n}`}function $et({changes:e,formatter:t}){return e.length<=1?null:l.jsxs("div",{className:"space-y-1 px-4 py-3",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Metrics"}),l.jsx("ul",{className:"space-y-1",children:e.map(n=>l.jsxs("li",{className:"flex items-baseline justify-between gap-3 text-[12px]",children:[l.jsx("span",{className:"min-w-0 truncate text-foreground",children:n.label}),l.jsx("span",{className:p.cn("shrink-0 font-medium tabular-nums",sz(n.direction)),children:Let(n,t)})]},n.metricId))})]})}function zet(e,t){if(e==="up")return"Where it grew";if(e==="down")return"Where it declined";const n=t.every(o=>(o.delta??0)>0),r=t.every(o=>(o.delta??0)<0);return n?"Where it grew":r?"Where it declined":"Where it changed"}function Bet({drivers:e,formatter:t,applyAction:n,headlineDirection:r}){const o=e.filter(a=>a.kind==="period_delta_driver"&&a.delta!=null&&Number.isFinite(a.delta)).slice(0,3);if(o.length===0)return null;const s=zet(r,o),i=Hue(o,s);return l.jsxs("div",{className:"space-y-1 px-4 py-3",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:i}),l.jsx("ul",{className:"space-y-1",children:o.map(a=>{const c=sz(a.direction),u=`${dv(a.key)} (${que(a,t)})`;return l.jsx("li",{children:l.jsxs("button",{type:"button",onClick:()=>n(a.action),"aria-label":u,className:"group/row flex w-full items-baseline justify-between gap-3 text-[12px] focus-visible:outline-none",children:[l.jsx("span",{className:"min-w-0 truncate text-left text-foreground underline-offset-2 group-hover/row:underline group-focus-visible/row:underline",children:dv(a.key)}),l.jsx("span",{className:p.cn("shrink-0 font-medium tabular-nums",c),"aria-hidden":"true",children:t.formatSigned(a.delta)})]})},`${a.metricId}-${a.key}`)})})]})}function Vet({drivers:e,formatter:t,applyAction:n}){const r=e.filter(s=>s.kind==="value_contributor").slice(0,3);if(r.length===0)return null;const o=Hue(r,"Top Contributors");return l.jsxs("div",{className:"space-y-1 px-4 py-3",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:o}),l.jsx("ul",{className:"space-y-1",children:r.map((s,i)=>{const a=`${dv(s.key)} (${que(s,t)})`;return l.jsx("li",{children:l.jsxs("button",{type:"button",onClick:()=>n(s.action),"aria-label":a,className:"group/row flex w-full items-center justify-between gap-3 text-[12px] focus-visible:outline-none",children:[l.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[l.jsx("span",{className:p.cn("flex size-4 shrink-0 items-center justify-center rounded-[3px] text-[9px] font-semibold tabular-nums",i===0?"bg-foreground text-background":"bg-muted text-muted-foreground"),"aria-hidden":"true",children:i+1}),l.jsx("span",{className:"truncate text-left text-foreground underline-offset-2 group-hover/row:underline group-focus-visible/row:underline",children:dv(s.key)})]}),l.jsxs("span",{className:"flex shrink-0 items-baseline gap-2 tabular-nums","aria-hidden":"true",children:[l.jsx("span",{className:"text-muted-foreground",children:t.formatValue(s.current)}),l.jsx("span",{className:"min-w-[3rem] text-right font-medium text-foreground",children:t.formatPct(s.contributionPct)})]})]})},`${s.metricId}-${s.key}`)})})]})}function Het(e){if(e.type!=="apply_filter")return e.label;const[t,n]=e.label.split(":");return n?`${t}: ${dv(n)}`:e.label}function Kj({data:e,applyAction:t,numberFormatter:n,audience:r="dashboard"}){var c;const o=n||{formatSigned:u=>u==null?"n/a":`${u>0?"+":""}${Math.round(u*100)/100}`,formatValue:u=>u==null?"n/a":`${Math.round(u*100)/100}`,formatPct:Aet},s=Ww(e.metadata.warnings),i=e.suggestedActions.filter(u=>u.type!=="refresh"&&u.type!=="apply_filter"),a=r==="author"&&s.length>0;return l.jsxs("div",{className:"divide-y divide-border/60",children:[l.jsx(Oet,{data:e,formatter:o}),l.jsx($et,{changes:e.keyChanges,formatter:o}),l.jsx(Bet,{drivers:e.drivers,formatter:o,applyAction:t,headlineDirection:(c=e.keyChanges[0])==null?void 0:c.direction}),l.jsx(Vet,{drivers:e.drivers,formatter:o,applyAction:t}),i.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 px-4 py-3",children:i.map(u=>l.jsx(p.Button,{size:"sm",variant:"secondary",className:"h-7 px-2 text-xs",onClick:()=>t(u),children:Het(u)},u.idempotencyKey))}),a&&l.jsx("div",{className:"px-4 py-3",children:l.jsx("div",{className:"rounded-[4px] bg-amber-50 px-2 py-1.5 text-[11px] text-amber-800 dark:bg-amber-950/30 dark:text-amber-300",children:s.map(u=>l.jsx("div",{children:rF(u)},u))})})]})}const qet=new Set(["up","rose","grew","gained","increased","climbed","surged","jumped","rising"]),Uet=new Set(["down","fell","declined","dipped","dropped","lost","decreased","slipped","falling"]),kU=/(\(([+−-])(\d[\d,]*(?:\.\d+)?[KkMmBb]?)(%?)\))|(([+−-])(\d[\d,]*(?:\.\d+)?[KkMmBb]?)(%?))|(\d[\d,]*(?:\.\d+)?[KkMmBb]?(?:%)?)/g;function Wet(e){const t=/^(\(?)([+−-]?)(\d[\d,]*)(\.\d+)?([KkMmBb]?)(%?)(\)?)$/.exec(e);if(!t)return e;const[,n,r,o,s,i,a,c]=t;if(i||o.includes(",")||o.length<4)return e;const u=Number(o);if(!Number.isFinite(u))return e;const d=u.toLocaleString("en-US");return`${n}${r}${d}${s??""}${i}${a}${c}`}function Ket(e){const t=[];let n=0,r;for(kU.lastIndex=0;(r=kU.exec(e))!==null;){r.index>n&&t.push({kind:"plain",text:e.slice(n,r.index)});const o=r[0],s=r[2]||r[6],i=Wet(o);s==="+"?t.push({kind:"pos",text:i}):s==="-"||s==="−"?t.push({kind:"neg",text:i}):t.push({kind:"num",text:i}),n=r.index+o.length}return n<e.length&&t.push({kind:"plain",text:e.slice(n)}),t}function Get(e){return e.map((t,n)=>{if(t.kind!=="num"||!t.text.endsWith("%"))return t;const r=e[n-1];if(!r||r.kind!=="plain")return t;const o=r.text.replace(/\s+$/,"").split(/[\s.,;:!?(]+/).pop();if(!o)return t;const s=o.toLowerCase();return qet.has(s)?{kind:"pos",text:t.text}:Uet.has(s)?{kind:"neg",text:t.text}:t})}function Yet({narrative:e}){const t=v.useMemo(()=>Get(Ket(e)),[e]);return l.jsx("div",{className:"px-4 py-3",children:l.jsx("p",{className:"text-[13px] leading-[20px] text-foreground",children:t.map((n,r)=>{if(n.kind==="plain")return l.jsx("span",{children:n.text},r);const o=n.kind==="pos"?"text-emerald-600 dark:text-emerald-400":n.kind==="neg"?"text-rose-600 dark:text-rose-400":"";return l.jsx("span",{className:p.cn("font-medium tabular-nums",o),children:n.text},r)})})})}function oF(){var w;const e=p.useDashboardStore(C=>C.dashboard),{preferences:t}=Pa(),n=p.useDashboardStore(C=>C.semanticExecutionPayload),r=p.useDashboardStore(C=>C.isDashboardEditing),o=((w=e==null?void 0:e.summary)==null?void 0:w.position)||"top",{setDashboard:s}=p.useDashboardActions(),{data:i,isLoading:a,isRefreshing:c,enabled:u,applyAction:d,refresh:f}=Oue(),[h,m]=v.useState(!0),g=v.useMemo(()=>nz({preferences:t}),[t]),x=i?rz(i.metadata)||Ww(i.metadata.warnings).length>0:!1,b=i?Fet(i):Wj,y=C=>{e&&o!==C&&s({...e,summary:{...e.summary,position:C}},{semanticExecutionPayload:n})};return u?a&&!i?l.jsx("div",{className:"mx-3 mt-3 overflow-hidden rounded-[6px] border bg-card",children:l.jsxs("div",{className:"space-y-2 px-4 py-3",children:[l.jsx("div",{className:"h-3 w-20 animate-pulse rounded bg-muted"}),l.jsx("div",{className:"h-4 w-4/5 animate-pulse rounded bg-muted"})]})}):i?l.jsx("div",{className:"mx-3 mb-3 mt-3 overflow-hidden rounded-[6px] border bg-card",children:l.jsxs(ku,{open:h,onOpenChange:m,children:[l.jsxs("div",{className:p.cn("flex items-center justify-between gap-2 px-4",h?"border-b border-border/60 py-2.5":"py-1.5"),children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Iu,{asChild:!0,children:l.jsx(p.Button,{size:"icon",variant:"ghost",className:"size-6","aria-label":h?"Collapse summary":"Expand summary",children:l.jsx(Ie.ChevronDown,{className:p.cn("h-3.5 w-3.5 transition-transform",!h&&"-rotate-90")})})}),l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Summary"}),x&&l.jsx(oz,{message:b,showLabel:!0})]}),l.jsxs("div",{className:"flex items-center gap-1",children:[r&&l.jsx("div",{className:"flex h-6 items-center overflow-hidden rounded-[4px] border border-border/60","aria-label":"Summary position",children:["top","bottom"].map(C=>l.jsx(p.Button,{size:"xs",variant:"ghost",className:p.cn("h-6 rounded-none px-2 text-[11px] capitalize text-muted-foreground hover:text-foreground",o===C&&"bg-muted text-foreground hover:bg-muted"),onClick:()=>y(C),"aria-pressed":o===C,children:C},C))}),l.jsx(p.Button,{size:"icon",variant:"ghost",className:"size-6 rounded-[4px] text-muted-foreground hover:text-foreground",onClick:()=>f(),disabled:c,"aria-label":"Refresh summary",children:l.jsx(_a,{className:p.cn("h-3 w-3",c&&"animate-spin")})})]})]}),l.jsx(_u,{children:i.narrative?l.jsx(Yet,{narrative:i.narrative}):l.jsx(Kj,{data:{narrative:i.narrative,generatedAt:i.generatedAt,keyChanges:i.keyChanges,drivers:i.drivers,suggestedActions:i.suggestedActions,metadata:i.metadata},applyAction:d,audience:"dashboard",numberFormatter:g})})]})}):null:null}function Uue({action:e,className:t,description:n,density:r="default",role:o="alert",title:s="This visual can’t be loaded"}){const i=v.useId();return l.jsx("div",{"aria-labelledby":i,className:p.cn("flex h-full min-h-0 w-full items-center justify-center text-center",r==="compact"?"px-0 py-1":"px-6 py-10",t),role:o,children:l.jsxs("div",{className:p.cn("flex flex-col items-center",r==="compact"?"max-w-[280px]":"max-w-[360px]"),children:[l.jsx(p.ChartColumn,{"aria-hidden":"true",className:p.cn("text-muted-foreground",r==="compact"?"mb-1.5 size-4":"mb-3 size-5"),strokeWidth:1.75}),l.jsx("h2",{id:i,className:p.cn("font-medium text-foreground",r==="compact"?"text-[12px]":"text-[14px]"),children:s}),n?l.jsx("p",{className:p.cn("text-muted-foreground",r==="compact"?"mt-0.5 text-[11px] leading-4":"mt-1 text-[12px] leading-5"),children:n}):null,e?l.jsx(p.Button,{className:r==="compact"?"mt-2":"mt-3",onClick:e.onClick,size:"xs",variant:"outline",children:e.label}):null]})})}function Kw(e){if(!e||typeof e!="object")return{};const t=e.code,n=e.message;return e.deliveryBlocking!==!0||typeof t!="string"||typeof n!="string"?{}:{"data-semaphor-render-error-code":t,"data-semaphor-render-error-message":n}}function Gw({onRetry:e,density:t="default",showOwnerGuidance:n=!0}){return l.jsx(Uue,{action:e?{label:"Try Again",onClick:e}:void 0,density:t,description:n?"Contact the dashboard owner for help resolving this issue.":void 0,role:"status"})}function IU({error:e,resetErrorBoundary:t}){return l.jsx("div",{...Kw(e),className:"contents",children:l.jsx(Gw,{onRetry:t})})}const Wue=4,Zet=.005,Xet="hsl(var(--semaphor-primary))",Qet="hsl(var(--semaphor-muted-foreground) / 0.35)",MM=[1,.65,.4,.25];function Kue(e){return e.split("/").map(t=>t.trim()).filter(Boolean).join(", ")}function Jet(e){return(e||[]).filter(t=>t.kind==="value_contributor"&&Number.isFinite(t.current)&&Number.isFinite(t.contributionPct)&&t.contributionPct>0)}function ett(e){return(e||[]).filter(t=>t.kind==="period_delta_driver"&&Number.isFinite(t.delta)&&Number.isFinite(t.contributionPct)&&t.contributionPct>0).slice(0,Wue).map(t=>({id:`${t.metricId}-${t.key}`,label:Kue(t.key),delta:t.delta,contributionPct:t.contributionPct,direction:t.direction,action:t.action}))}function ttt(e,t){const n=e.slice(0,Wue);if(n.length===0)return[];const r=t[0]||Xet,o=MM[MM.length-1]??.25,s=n.map((c,u)=>({id:`${c.metricId}-${c.key}`,label:Kue(c.key),current:c.current,contributionPct:c.contributionPct,color:r,opacity:MM[u]??o,action:c.action})),i=n.reduce((c,u)=>c+u.contributionPct,0),a=Math.max(0,1-i);return a>=Zet&&s.push({id:"other",label:"Other",current:null,contributionPct:a,color:Qet,opacity:1,action:null}),s}function ntt({card:e,data:t,isPending:n,isError:r,comparisonMetadata:o,headerAction:s,headerTrailingAction:i}){var ge,ke,De,Re,Ve,ve,Ke,qe,et,ye,He,Pe;const{setTitle:a,isEditable:c,isVisualEditing:u}=Rue(),{setCardDescription:d}=p.useEditorActions(),{getLocale:f}=Mue(e),{preferences:h,boundCurrency:m}=n_(e,t),{compiledAppearance:g}=oi.useAppearance(),x=(ke=(ge=e.preferences)==null?void 0:ge.kpiVisualOptions)==null?void 0:ke.countryLogoId;v.useMemo(()=>het.find(_e=>_e.id===x),[x]);const b=e.config,y=b==null?void 0:b.summary,w=((y==null?void 0:y.breakdownDimensions)||[]).length>0,C=(y==null?void 0:y.enabled)===!0&&((y==null?void 0:y.showOnCard)===!0||w),N=!u&&C,S=(b==null?void 0:b.groupByColumns)&&b.groupByColumns.length>0,j=(b==null?void 0:b.metricColumns)||[],I=j[0],k=(I==null?void 0:I.id)||(I==null?void 0:I.name),T=j.some(_e=>p.getMetricComparisonKind(_e)==="target"),_=!S&&j.length>1&&!T,E=C&&!_&&!r,{data:D,isLoading:M,isRefreshing:P,refresh:A,applyAction:L}=Z$(e,{enabled:E}),O=v.useMemo(()=>nz({card:e,preferences:h,boundCurrency:m}),[e,m,h]),B=v.useMemo(()=>Jet(D==null?void 0:D.drivers),[D==null?void 0:D.drivers]),H=v.useMemo(()=>ett(D==null?void 0:D.drivers),[D==null?void 0:D.drivers]),R=g.chartPalette,V=v.useMemo(()=>lp({card:e,preferences:h,boundCurrency:m}),[e,m,h]),z=v.useMemo(()=>Aue({card:e,preferences:h,boundCurrency:m}),[e,m,h]),F=v.useMemo(()=>{if(I)return eL(o,I)},[o,I]),G=F==null?void 0:F.metadata,q=_e=>V.format(_e),Y=_e=>V.formatCompact(_e),K=_e=>z.format(_e),$=_e=>{const ze=t==null?void 0:t.find(Be=>Be.segment===_e||Be.Segment===_e?k?Be.metricId===k||Be.metricId===void 0:!0:!1),Ee=(ze==null?void 0:ze.value)??(ze==null?void 0:ze.Value);if(typeof Ee=="number"&&Number.isFinite(Ee))return Ee;if(typeof Ee=="string"&&Ee.trim()){const Be=Number(Ee);return Number.isFinite(Be)?Be:null}return null},X=$("current")??0,W=$("comparison"),U=(F==null?void 0:F.comparisonKind)??p.getMetricComparisonKind(I),Z=p.getMetricComparisonPolarity(I),Q=(De=e.preferences)==null?void 0:De.comparisonPresentation,J=p.getMetricComparisonTarget(I),re=typeof X=="number"&&!isNaN(X)?X:0,de=v.useMemo(()=>ttt(B,R),[B,R]),le=typeof J=="number"&&!isNaN(J)?J:0,ce=le>0?Math.min(re/le,1):0,oe=le>0?Math.max(le-re,0):0,fe=le>0?Math.max(re-le,0):0,we=xet({comparisonKind:U,targetValue:le,presentation:Q}),pe=yet({comparisonKind:U,comparisonValue:W,targetValue:le}),ne=U==="target"?typeof J=="number"&&Number.isFinite(J):pe!==null,Se=U!=="none"&&ne&&(Q==null?void 0:Q.showComparison)!==!1,ue=(Ve=(Re=e.preferences)==null?void 0:Re.formatNumber)==null?void 0:Ve.colorRanges,ie=Y_(X,ue);function ee(){return e.title?e.title:c?"Enter title":""}const ae=e.description||(u?"Enter description":"");if(r)return l.jsx(p.TooltipProvider,{children:l.jsxs("div",{className:"group flex h-full grow flex-col",children:[l.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:[l.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[l.jsx(Si,{displayClassName:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",inputClassName:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",value:ee(),isEditable:c,onSave:a}),(e.description||u)&&l.jsx(Si,{displayClassName:"min-w-0 truncate text-[11px] text-muted-foreground/80",inputClassName:"min-w-0 truncate text-[11px] text-muted-foreground/80",value:ae,placeholder:u?"Enter description":"",isEditable:u,onSave:d})]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s,i]})]}),l.jsx("div",{className:"flex min-h-0 flex-1 px-4 py-3",children:l.jsx(Gw,{density:"compact",showOwnerGuidance:!1})})]})});if(_)return l.jsx(bet,{card:e,data:t,isPending:n,headerAction:s,headerTrailingAction:i});if(n)return l.jsxs("div",{className:"flex h-full grow flex-col",children:[l.jsx("div",{className:"flex shrink-0 items-center justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:l.jsx("div",{className:"h-3 w-24 rounded bg-foreground/[0.06]"})}),l.jsxs("div",{className:"flex flex-1 flex-col gap-2 px-4 py-3",children:[l.jsx("div",{className:"h-7 w-32 rounded bg-foreground/[0.06]"}),e.description&&l.jsx("div",{className:"h-3 w-24 rounded bg-foreground/[0.06]"})]})]});const he=((ve=e==null?void 0:e.kpiPreferences)==null?void 0:ve.format)==="compact"?Y(X):q(X);return l.jsx(p.TooltipProvider,{children:l.jsxs("div",{className:"group flex h-full grow flex-col",children:[l.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:[l.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[l.jsxs("div",{className:"flex min-w-0 items-center gap-1",children:[l.jsx(Si,{displayClassName:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",inputClassName:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",value:ee(),isEditable:c,onSave:a}),N&&l.jsxs(np,{openDelay:180,closeDelay:120,children:[l.jsx(Jd,{asChild:!0,children:l.jsx(p.Button,{size:"icon",variant:"ghost",className:"size-4 shrink-0 rounded-[3px] p-0 text-muted-foreground hover:text-foreground","aria-label":"Show summary",children:l.jsx(p.Info,{className:"h-3 w-3"})})}),l.jsxs(Su,{align:"start",className:"ml-2 w-[360px] overflow-hidden p-0",children:[l.jsxs("div",{className:"flex items-center justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Summary"}),D&&(D.metadata.partial||D.metadata.warnings.length>0)&&l.jsx(oz,{className:"text-amber-500"})]}),l.jsx(p.Button,{size:"icon",variant:"ghost",className:"size-6 rounded-[4px] text-muted-foreground hover:text-foreground",onClick:()=>A(),disabled:P,"aria-label":"Refresh summary",children:l.jsx(_a,{className:p.cn("h-3 w-3",P&&"animate-spin")})})]}),M&&!D?l.jsxs("div",{className:"space-y-2 px-4 py-3",children:[l.jsx("div",{className:"h-3 w-20 animate-pulse rounded bg-foreground/[0.06]"}),l.jsx("div",{className:"h-3 w-full animate-pulse rounded bg-foreground/[0.06]"}),l.jsx("div",{className:"h-3 w-5/6 animate-pulse rounded bg-foreground/[0.06]"})]}):D?l.jsx(Kj,{data:{narrative:D.narrative,generatedAt:D.generatedAt,keyChanges:D.keyChanges,drivers:D.drivers,suggestedActions:D.suggestedActions,metadata:D.metadata},applyAction:L,audience:"dashboard",numberFormatter:O}):l.jsx("div",{className:"px-4 py-3 text-xs text-muted-foreground",children:"Summary is unavailable for this card."})]})]})]}),(e.description||u)&&l.jsx(Si,{isEditable:u,value:ae,placeholder:u?"Enter description":"",displayClassName:"min-w-0 truncate text-[11px] text-muted-foreground/80",inputClassName:"min-w-0 truncate text-[11px] text-muted-foreground/80",onSave:d})]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[s,Se&&pe!==null&&l.jsxs(p.Tooltip,{children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx("div",{className:"shrink-0 cursor-help [&_.inline-flex]:h-[18px] [&_.inline-flex]:gap-1 [&_.inline-flex]:px-1.5 [&_.inline-flex]:py-0 [&_.inline-flex]:text-[11px] [&_.inline-flex]:font-medium",children:l.jsx(y3,{primaryValue:X,secondaryValue:pe,presentation:Q,metricFormatOptions:(qe=(Ke=e.preferences)==null?void 0:Ke.kpiVisualOptions)==null?void 0:qe.formatOptions,locale:f()||"en-US",decimalPlaces:(ye=(et=e.preferences)==null?void 0:et.formatNumber)==null?void 0:ye.decimalPlaces,suffix:(Pe=(He=e.preferences)==null?void 0:He.formatNumber)==null?void 0:Pe.suffix,polarity:Z,signedValueFormatter:V.formatSigned,allowSignedValueFormatter:V.supportsComparisonDeltaInheritance})})}),l.jsx(fet,{currentValue:X,comparisonValue:pe,comparisonKind:U,sentiment:Vr.evaluateMetricComparison({currentValue:X,comparisonValue:pe,polarity:Z}).sentiment,data:t,comparisonMetadata:G,formatCurrency:q,conditionalLabel:(()=>{if(Q!=null&&Q.conditionalLabel){const{conditionalLabels:_e}=Q,ze=X-pe;return ze>0?(_e==null?void 0:_e.increase)||"Increase":ze<0?(_e==null?void 0:_e.decrease)||"Decrease":(_e==null?void 0:_e.neutral)||"No change"}})()})]}),i]})]}),l.jsxs("div",{className:"flex flex-1 flex-col gap-2 px-4 py-3",children:[l.jsx("p",{className:"text-[34px] font-semibold tabular-nums leading-none tracking-tight text-foreground",style:ie?{color:ie}:void 0,children:he}),Se&&pe!==null&&l.jsxs("p",{className:"text-[11px] text-muted-foreground",children:[U==="target"?(Q==null?void 0:Q.labelName)||"Target":(Q==null?void 0:Q.labelName)||"Previous",l.jsx("span",{className:"mx-1.5 text-muted-foreground/60",children:"·"}),l.jsx("span",{className:"tabular-nums text-foreground/80",children:q(pe)})]})]}),we&&l.jsxs("div",{className:"space-y-1.5 border-t border-border/60 px-4 py-2.5",children:[l.jsx("div",{className:"h-1 w-full overflow-hidden rounded-full bg-muted",children:l.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${Math.min(Math.round(ce*100),100)}%`,backgroundColor:ie||void 0}})}),l.jsxs("div",{className:"flex items-center justify-between text-[11px] text-muted-foreground",children:[l.jsx("span",{children:re>=le?fe>0?`${K(fe)} above target`:"Target reached":`${K(oe)} remaining`}),l.jsxs("span",{className:"tabular-nums",children:[Math.round(ce*100),"%"]})]})]}),C&&M&&!D&&l.jsxs("div",{className:"space-y-2 border-t border-border/60 px-4 py-2.5","data-testid":"kpi-composition-loading","aria-hidden":"true",children:[l.jsxs("div",{className:"flex h-1 w-full gap-px overflow-hidden rounded-[2px]",children:[l.jsx("div",{className:"h-full w-[40%] animate-pulse bg-foreground/[0.06]"}),l.jsx("div",{className:"h-full w-[26%] animate-pulse bg-foreground/[0.06]"}),l.jsx("div",{className:"h-full w-[16%] animate-pulse bg-foreground/[0.06]"}),l.jsx("div",{className:"h-full flex-1 animate-pulse bg-foreground/[0.06]"})]}),l.jsx("ul",{className:"space-y-1",children:["58%","44%","36%"].map((_e,ze)=>l.jsxs("li",{className:"flex items-center justify-between gap-3",children:[l.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[l.jsx("span",{className:"size-2 shrink-0 animate-pulse rounded-[2px] bg-foreground/[0.06]"}),l.jsx("span",{className:"h-2.5 animate-pulse rounded bg-foreground/[0.06]",style:{width:_e}})]}),l.jsxs("span",{className:"flex shrink-0 items-baseline gap-2",children:[l.jsx("span",{className:"h-2.5 w-7 animate-pulse rounded bg-foreground/[0.06]"}),l.jsx("span",{className:"h-2.5 w-10 animate-pulse rounded bg-foreground/[0.06]"})]})]},`composition-skeleton-${ze}`))})]}),C&&de.length>0&&l.jsxs("div",{className:"space-y-2 border-t border-border/60 px-4 py-3",children:[l.jsx("div",{className:"flex h-1 w-full overflow-hidden rounded-[2px]",children:de.map(_e=>l.jsx("div",{"data-testid":"kpi-composition-segment",className:"h-full",style:{width:`${Math.max(_e.contributionPct*100,2)}%`,backgroundColor:_e.color,opacity:_e.opacity}},_e.id))}),l.jsx("ul",{className:"space-y-1",children:de.map(_e=>{const ze=l.jsxs(l.Fragment,{children:[l.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[l.jsx("span",{className:"size-2 shrink-0 rounded-[2px]",style:{backgroundColor:_e.color,opacity:_e.opacity}}),l.jsx("span",{className:p.cn("truncate text-muted-foreground decoration-muted-foreground/40 underline-offset-2",_e.action&&"group-hover/row:text-foreground group-hover/row:underline group-focus-visible/row:text-foreground group-focus-visible/row:underline"),children:_e.label})]}),l.jsxs("span",{className:"flex shrink-0 items-baseline gap-2 tabular-nums",children:[_e.current!=null&&l.jsx("span",{className:"text-muted-foreground",children:O.formatValue(_e.current)}),l.jsx("span",{className:"min-w-[3rem] text-right font-medium text-foreground",children:O.formatPct(_e.contributionPct)})]})]});return l.jsx("li",{children:_e.action?l.jsx("button",{type:"button",onClick:()=>L(_e.action),"aria-label":`Filter to ${_e.label}`,className:"group/row flex w-full items-center justify-between gap-3 text-[11px] focus-visible:outline-none",children:ze}):l.jsx("div",{className:"flex items-center justify-between gap-3 text-[11px]",children:ze})},`${_e.id}-legend`)})})]}),C&&de.length===0&&H.length>0&&l.jsx("div",{className:"border-t border-border/60 px-4 py-3",children:l.jsx("ul",{className:"space-y-1",children:H.map(_e=>{const ze=_e.direction==="up"?"text-emerald-600 dark:text-emerald-400":_e.direction==="down"?"text-rose-600 dark:text-rose-400":"text-foreground",Ee=l.jsxs(l.Fragment,{children:[l.jsx("span",{className:p.cn("min-w-0 truncate text-muted-foreground decoration-muted-foreground/40 underline-offset-2",_e.action&&"group-hover/row:text-foreground group-hover/row:underline group-focus-visible/row:text-foreground group-focus-visible/row:underline"),children:_e.label}),l.jsxs("span",{className:"flex shrink-0 items-baseline gap-2 tabular-nums",children:[l.jsx("span",{className:p.cn("font-medium",ze),children:O.formatSigned(_e.delta)}),l.jsx("span",{className:"min-w-[3rem] text-right font-medium text-foreground",children:O.formatPct(_e.contributionPct)})]})]});return l.jsx("li",{"data-testid":"kpi-period-driver-row",children:_e.action?l.jsx("button",{type:"button",onClick:()=>L(_e.action),"aria-label":`Filter to ${_e.label}`,className:"group/row flex w-full items-center justify-between gap-3 text-[11px] focus-visible:outline-none",children:Ee}):l.jsx("div",{className:"flex items-center justify-between gap-3 text-[11px]",children:Ee})},`${_e.id}-driver`)})})})]})})}function rtt({card:e,data:t,isPending:n,isError:r,headerAction:o,headerTrailingAction:s}){var P,A,L,O;const i=p.useDashboardStore(B=>B.isVisualEditing),a=p.useEditorStore(B=>B.card),c=p.useEditorStore(B=>B.actions.setCard);p.useEditorStore(B=>B.actions.setNumberFormat);const u=(A=(P=e.preferences)==null?void 0:P.formatNumber)==null?void 0:A.colorRanges,d=B=>{if(typeof B=="number")return Number.isFinite(B)?B:null;if(typeof B=="string"){const H=B.trim();if(!H)return null;const R=Number(H.replace(/,/g,""));return Number.isFinite(R)?R:null}return null},f=(t==null?void 0:t[0])??{},h=Cw(t),m=h[0],g=h[1],{preferences:x,boundCurrency:b}=n_(e,t),y=lp({card:e,preferences:x,boundCurrency:b}),w=m!==void 0?d(f[m]):null,C=g!==void 0?d(f[g]):null,N=Array.isArray(t)&&t.length>0,S=t==null?void 0:t.some(B=>Object.values(B).some(H=>H!=null)),j=N&&w!==null,I=N&&S?"KPI needs a numeric metric. Add a numeric field or aggregation.":"No data available for this KPI.";function k(B){i&&c({...a,title:B})}function T(B){i&&c({...a,description:B})}const _=w!==null&&C!==null&&C!==0?(w-C)/C:null,E=w!==null?y.format(w):"--";let D="";C!==null&&(D=y.format(C));const M=Y_(w??0,u);return l.jsx(ott,{isPending:n,isError:r,title:e.title,formattedCurrentValue:E,formattedPreviousValue:D,description:e.description,valueColor:M,onTitleChange:k,onDescriptionChange:T,percentDifference:_,polarity:((O=(L=e.preferences)==null?void 0:L.kpiVisualOptions)==null?void 0:O.queryComparisonPolarity)??Vr.DEFAULT_METRIC_COMPARISON_POLARITY,show:j,emptyStateMessage:I,headerAction:o,headerTrailingAction:s})}function sf({card:e,data:t,isPending:n,isError:r,comparisonMetadata:o,headerAction:s,headerTrailingAction:i}){return!uoe(e)&&ut.hasValidCardConfig(e.config)?l.jsx("div",{className:"flex h-full min-h-0 grow overflow-auto",children:l.jsx(ntt,{card:e,data:t||[],isPending:n,isError:r,comparisonMetadata:o,headerAction:s,headerTrailingAction:i})}):l.jsx(rtt,{card:e,data:t,isPending:n,isError:r,headerAction:s,headerTrailingAction:i})}function ott({title:e,formattedCurrentValue:t,formattedPreviousValue:n,description:r,valueColor:o,onTitleChange:s,onDescriptionChange:i,percentDifference:a,show:c,emptyStateMessage:u,isPending:d,isError:f,polarity:h,headerAction:m,headerTrailingAction:g}){const x=p.useDashboardStore(C=>C.isVisualEditing),b=p.useEditorStore(C=>C.card),y=r??"",w=y||(x?"Enter description":"");return l.jsxs("div",{className:"kpi-card flex h-full grow flex-col",children:[l.jsxs("div",{className:"flex shrink-0 items-start justify-between gap-2 border-b border-border/60 px-4 py-2.5",children:[l.jsxs("div",{className:"flex min-w-0 flex-col gap-0.5",children:[l.jsx(Uj,{className:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",containerClassName:"min-w-0",enabled:x,text:x?b.title:e,onSave:s,children:l.jsx(xb,{className:"min-w-0 truncate text-[11px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:e})}),(y||x)&&l.jsx(Uj,{className:"min-w-0 truncate text-[11px] text-muted-foreground/80",containerClassName:"min-w-0",enabled:x,text:w,placeholder:x?"Enter description":"",onSave:i,children:l.jsx("span",{className:"block min-w-0 truncate text-[11px] text-muted-foreground/80",children:w})})]}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[m,a!=null&&a!==0&&!f&&!d&&l.jsx(Gue,{polarity:h,children:a}),g]})]}),l.jsx("div",{className:"flex flex-1 flex-col justify-between gap-2 px-4 py-3",children:f?l.jsx(Gw,{density:"compact",showOwnerGuidance:!1}):d?l.jsxs("div",{className:"space-y-2",children:[l.jsx(ei,{className:"h-7 w-32 bg-foreground/[0.06]"}),l.jsx(ei,{className:"h-3 w-24 bg-foreground/[0.06]"})]}):c?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-[34px] font-semibold tabular-nums leading-none tracking-tight text-foreground",style:o?{color:o}:void 0,children:t}),n&&l.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Previous",l.jsx("span",{className:"mx-1.5 text-muted-foreground/60",children:"·"}),l.jsx("span",{className:"tabular-nums text-foreground/80",children:n})]})]}):l.jsx("p",{className:"text-[12px] text-muted-foreground",children:u})})]})}function Gue({children:e,className:t,polarity:n}){const r=e>0,o=n==="lower_is_better"?!r:n==="higher_is_better"?r:null,s=r?ws:ss,i=`${Math.abs(e*100).toFixed(0)}%`;return l.jsxs("span",{className:p.cn("inline-flex h-5 shrink-0 items-center gap-0.5 rounded-[4px] px-1.5 text-[11px] font-medium tabular-nums",o===!0?"bg-emerald-50 text-emerald-700 dark:bg-emerald-950/40 dark:text-emerald-300":o===!1?"bg-rose-50 text-rose-700 dark:bg-rose-950/40 dark:text-rose-300":"bg-gray-50 text-gray-700 dark:bg-gray-900 dark:text-gray-400",t),children:[l.jsx(s,{className:"h-3 w-3"}),i]})}const iz="A dashboard input is invalid or references a missing filter. Ask an editor to repair the dashboard configuration.";function az(e){return e instanceof Zs.DashboardFilterMappingContractError}function Yw({customerFacingMessage:e,error:t,resetErrorBoundary:n}){const r=az(t);return l.jsxs("div",{...Kw(t),className:"flex h-full w-full flex-col items-center justify-center rounded-lg border border-dashed border-muted-foreground/25 bg-muted/30 p-6 text-center",children:[l.jsx("div",{className:"mb-4 flex h-12 w-12 items-center justify-center rounded-full bg-muted",children:l.jsx("svg",{className:"h-6 w-6 text-muted-foreground",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),l.jsx("h3",{className:"mb-2 text-sm font-medium text-foreground",children:"Chart Unavailable"}),l.jsx("p",{className:"mb-4 text-xs text-muted-foreground",children:e||(r?iz:"Couldn't display this chart right now. Please try refreshing or check your data configuration.")}),l.jsxs("button",{onClick:n,className:"inline-flex items-center justify-center rounded-md bg-primary px-3 py-2 text-xs font-medium text-primary-foreground shadow-sm transition-colors hover:bg-primary/90 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",children:[l.jsx("svg",{className:"mr-1.5 h-3 w-3",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:l.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"})}),"Try Again"]}),(!r||ut.isDevEnv)&&l.jsxs("details",{className:"mt-4 w-full text-left",children:[l.jsx("summary",{className:"cursor-pointer text-xs text-muted-foreground hover:text-foreground",children:"Show technical details"}),l.jsxs("div",{className:"mt-2 rounded border bg-background p-3",children:[l.jsx("p",{className:"mb-1 text-xs font-medium text-foreground",children:"Error Details:"}),l.jsx("pre",{className:"text-xs text-muted-foreground",children:t.message})]})]})]})}function X_({error:e}){const t=az(e);return l.jsx("div",{...Kw(e),className:"flex flex-col items-center justify-center",role:"alert",style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",width:"100%"},children:l.jsxs("div",{style:{backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",boxShadow:"0 2px 6px rgba(0, 0, 0, 0.08)",color:"#b91c1c",fontFamily:"sans-serif",padding:"16px",textAlign:"center",flexDirection:"column",whiteSpace:"pre-wrap",position:"relative"},className:"flex flex-col justify-center space-y-1 rounded-md bg-muted p-10",children:[l.jsx("p",{className:"text-sm",children:t?"Dashboard configuration needs attention":"Something went wrong:"}),t?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-xs",children:iz}),ut.isDevEnv]}):l.jsx("pre",{className:"text-xs",children:e.message})]})})}function stt({error:e,frame:t}){const n=az(e);return l.jsxs("div",{...Kw(e),className:"flex h-full flex-col items-center justify-center border",role:"alert",children:[l.jsx(iF,{frame:t,isHovered:!1}),l.jsx("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10"}),l.jsxs("div",{className:"flex flex-col justify-center space-y-2 rounded-md p-10",children:[l.jsx("p",{className:"text-lg font-semibold",children:n?"Dashboard configuration needs attention":"Oops! Looks like we tripped on a loose wire!"}),n?l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-sm",children:iz}),ut.isDevEnv]}):l.jsxs(l.Fragment,{children:[l.jsx("p",{className:"text-sm",children:"Something went wrong:"}),l.jsx("pre",{className:"text-xs",children:e.message})]})]})]})}function itt(e={},t){const{displayPreferences:n,shouldShowElement:r}=pl(),o=xf(n.mode),s=e.enabled??!0,i=e.serverSide??!1,a=o?Number.MAX_SAFE_INTEGER:e.pageSize||50,c=e.currentPage!==void 0,[u,d]=v.useState(0),[f,h]=v.useState(a),m=c?(e.currentPage||1)-1:u,g=o?Number.MAX_SAFE_INTEGER:c?e.pageSize||a:f,x=v.useMemo(()=>s&&r("showPagination")&&!o,[s,r,o]),b=v.useMemo(()=>i?e.pageCount:Math.ceil(t/g),[i,e.pageCount,t,g]),y=v.useMemo(()=>i?e.totalCount||0:t,[i,e.totalCount,t]),w=v.useMemo(()=>i?(e.currentPage||1)>1:m>0,[i,e.currentPage,m]),C=v.useMemo(()=>i?(e.currentPage||1)<(e.pageCount||1):m<(b||1)-1,[i,e.currentPage,e.pageCount,m,b]);return{pageIndex:m,pageSize:g,isServerSidePagination:i,showPagination:x,paginationEnabled:s,isTablePrintDisplayMode:o,setPageIndex:k=>{var T;c?(T=e.onPageChange)==null||T.call(e,k+1,g):d(k)},setPageSize:k=>{var T;c?(T=e.onPageChange)==null||T.call(e,1,k):(d(0),h(k))},canPreviousPage:w,canNextPage:C,previousPage:()=>{var T;if(!w)return;const k=m-1;c?(T=e.onPageChange)==null||T.call(e,k+1,g):d(k)},nextPage:()=>{var T;if(!C)return;const k=m+1;c?(T=e.onPageChange)==null||T.call(e,k+1,g):d(k)},pageCount:b,totalCount:y}}function att(e,t){const n=e.subtotalLevel,r=r_(t.groupByColumns,n);if(r<0)throw new Error(`invalid_pivot_subtotal_identity: Subtotal level "${n||""}" does not match a configured row-axis field.`);return r}function ltt(e,t,n){var c;if(!t.length)return e;const r=t[0].id,o=t[0].desc?-1:1,s=((c=n.groupByColumns)==null?void 0:c.length)||0,i=r.startsWith("rowLevel"),a=i?parseInt(r.replace("rowLevel","")):-1;return i?ctt(e,a,o):utt(e,r,o,s,n)}function ctt(e,t,n){const r=[...e],o=new Map,s=[];r.forEach(c=>{if(c.isGrandTotal)return;const u=t>0?JSON.stringify((c.canonicalFieldValues||c.fieldValues).slice(0,t)):"root";o.has(u)||(o.set(u,[]),s.push(u)),o.get(u).push(c)});const i=[];s.forEach(c=>{const u=o.get(c),d=u.filter(h=>!h.isSubtotal),f=u.filter(h=>h.isSubtotal);d.sort((h,m)=>{const g=Ns(h,t),x=Ns(m,t);return g===x?0:g==null?1:x==null?-1:String(g).localeCompare(String(x))*n}),i.push(...d),i.push(...f)});const a=e.find(c=>c.isGrandTotal);return a&&i.push(a),i}function utt(e,t,n,r,o){const s={rows:[],children:new Map};let i;e.forEach(f=>{if(f.isGrandTotal){i=f;return}const h=f.isSubtotal?att(f,o)+1:r;let m=s;for(let g=0;g<h;g++){const x=JSON.stringify(Ns(f,g));m.children.has(x)||m.children.set(x,{rows:[],children:new Map}),m=m.children.get(x)}f.isSubtotal?m.subtotal=f:m.rows.push(f)});function a(f){var h;return t==="rowTotal"?o.columnHeaders.reduce((m,g)=>{var b;const x=(b=f.cells[g])==null?void 0:b.value;return m+(typeof x=="number"?x:0)},0):(h=f.cells[t])==null?void 0:h.value}function c(f){let h=0;return f.rows.forEach(m=>{const g=a(m);typeof g=="number"&&(h+=g)}),f.children.forEach(m=>{if(m.subtotal){const g=a(m.subtotal);typeof g=="number"&&(h+=g)}else h+=c(m)}),h}function u(f){const h=[],m=[...f.rows].sort((x,b)=>{const y=a(x),w=a(b);return y===w?0:y==null?1:w==null?-1:y>w?n:-n});return h.push(...m),Array.from(f.children.entries()).sort(([,x],[,b])=>{const y=x.subtotal?a(x.subtotal):c(x),w=b.subtotal?a(b.subtotal):c(b);return y===w?0:y==null?1:w==null?-1:y>w?n:-n}).forEach(([,x])=>{h.push(...u(x))}),f.subtotal&&h.push(f.subtotal),h}const d=u(s);return i&&d.push(i),d}function dtt(e,t){const[n,r]=v.useState([]),o=v.useMemo(()=>ltt(e,n,t),[e,n,t]),s=v.useCallback(c=>{r(u=>{const d=u.find(f=>f.id===c);return d?d.desc?[]:[{id:c,desc:!0}]:[{id:c,desc:!1}]})},[]),i=v.useCallback(()=>{r([])},[]),a=v.useCallback(c=>{const u=n.find(d=>d.id===c);return u?u.desc?"desc":"asc":!1},[n]);return{sorting:n,setSorting:r,sortedTableData:o,toggleColumnSort:s,clearSorting:i,getSortDirection:a}}function RM({columnName:e,groupByFields:t,pivotByFields:n,currentAggregation:r,onAggregationChange:o,onOpenChange:s}){const i=[{value:"SUM",label:"Sum"},{value:"MAX",label:"Max"},{value:"MIN",label:"Min"},{value:"AVG",label:"Avg"},{value:"MEDIAN",label:"Median"}],a=(u,d,f)=>{o({function:u,rowLevel:d,columnLevel:f})},c=(u,d,f)=>{if(!r)return!1;if(d!==void 0&&f===void 0){if(r.rowAggregates){const h=d==="all"?"ALL":d;return r.rowAggregates.some(m=>m.function===u&&m.groupLevel===h)}return!1}if(f!==void 0&&d===void 0){if(r.columnAggregates){const h=f==="all"?"ALL":f;return r.columnAggregates.some(m=>m.function===u&&m.pivotLevel===h)}return!1}return!1};return l.jsxs(Xo,{modal:!1,onOpenChange:s,children:[l.jsx(Qo,{asChild:!0,children:l.jsx(p.Button,{variant:"ghost",size:"icon",className:"h-6 w-6 p-0 hover:bg-accent hover:text-accent-foreground",children:l.jsx($m,{className:"size-3"})})}),l.jsxs(Fo,{align:"start",className:"w-56",children:[l.jsx(Za,{className:"text-xs font-normal text-muted-foreground",children:"AGGREGATE"}),i.map(u=>{var m,g;const d=((m=r==null?void 0:r.rowAggregates)==null?void 0:m.some(x=>x.function===u.value))||!1,f=((g=r==null?void 0:r.columnAggregates)==null?void 0:g.some(x=>x.function===u.value))||!1,h=d||f;return l.jsxs(QO,{children:[l.jsx(Wk,{className:"text-xs",children:l.jsxs("div",{className:"flex w-full items-center justify-between",children:[l.jsx("span",{children:u.label}),h&&l.jsxs("div",{className:"ml-2 flex items-center gap-1 text-xs",children:[d&&l.jsx("span",{className:"rounded bg-blue-100 px-1 py-0.5 text-blue-700 dark:bg-blue-900 dark:text-blue-300",children:"R"}),f&&l.jsx("span",{className:"rounded bg-green-100 px-1 py-0.5 text-green-700 dark:bg-green-900 dark:text-green-300",children:"C"})]})]})}),l.jsxs(Kk,{className:"w-48",children:[l.jsx(Za,{className:"text-xs font-normal text-muted-foreground",children:"ROWS"}),l.jsx(In,{className:"text-xs",onClick:()=>a(u.value,"all"),children:l.jsxs("div",{className:"flex w-full items-center justify-between",children:[l.jsx("span",{children:"of all rows"}),c(u.value,"all")&&l.jsx(p.Check,{className:"h-4 w-4"})]})}),t.map(x=>l.jsx(In,{className:"text-xs",onClick:()=>a(u.value,x.id),children:l.jsxs("div",{className:"flex w-full items-center justify-between",children:[l.jsxs("span",{children:["within ",x.label||x.name]}),c(u.value,x.id)&&l.jsx(p.Check,{className:"h-4 w-4"})]})},x.id)),n.length>0&&l.jsxs(l.Fragment,{children:[l.jsx(Ta,{}),l.jsx(Za,{className:"text-xs font-normal text-muted-foreground",children:"COLUMNS"}),l.jsx(In,{className:"text-xs",onClick:()=>a(u.value,void 0,"all"),children:l.jsxs("div",{className:"flex w-full items-center justify-between",children:[l.jsx("span",{children:"of all columns"}),c(u.value,void 0,"all")&&l.jsx(p.Check,{className:"h-4 w-4"})]})}),n.map(x=>l.jsx(In,{className:"text-xs",onClick:()=>a(u.value,void 0,x.id),children:l.jsxs("div",{className:"flex w-full items-center justify-between",children:[l.jsxs("span",{children:["within ",x.label||x.name]}),c(u.value,void 0,x.id)&&l.jsx(p.Check,{className:"h-4 w-4"})]})},x.id))]})]})]},`${u.value}-${u.label}`)})]})]})}function Gj(e,t,n,r,o=!1){if(t){const s=VI(e,t,n,r,o),i=typeof e=="object"&&e!==null&&"value"in e?e.value:e,a=IDe(i,t);return s==="-"||s===0?l.jsx("div",{className:"flex justify-end",children:l.jsx(Uc,{className:"h-3 w-3 text-muted-foreground"})}):a?l.jsx("span",{style:{backgroundColor:a.backgroundColor,color:a.color,padding:"0.125rem 0.25rem",borderRadius:"0.25rem"},children:s}):s}return typeof e=="object"&&(e==null?void 0:e.formattedValue)!==void 0?e.formattedValue==="-"||e.formattedValue===0?l.jsx("div",{className:"flex justify-end",children:l.jsx(Uc,{className:"h-3 w-3 text-muted-foreground"})}):e.formattedValue:typeof e=="number"?e===0||e===null?l.jsx("div",{className:"flex justify-end",children:l.jsx(Uc,{className:"h-3 w-3 text-muted-foreground"})}):e.toLocaleString():e==null?l.jsx("div",{className:"flex justify-end",children:l.jsx(Uc,{className:"h-3 w-3 text-muted-foreground"})}):(e==null?void 0:e.toString())||l.jsx("div",{className:"flex justify-end",children:l.jsx(Uc,{className:"h-3 w-3 text-muted-foreground"})})}function ftt(e){return(e==null?void 0:e.includes("__subtotal__"))||(e==null?void 0:e.includes("_SUM_"))||(e==null?void 0:e.includes("_AVG_"))||(e==null?void 0:e.includes("_COUNT_"))||(e==null?void 0:e.includes("_MIN_"))||(e==null?void 0:e.includes("_MAX_"))}function htt(e,t){const n=(e==null?void 0:e.includes("__subtotal__"))&&(e==null?void 0:e.includes("__ALL__"))||(e==null?void 0:e.includes("_SUM_ALL"))||(e==null?void 0:e.includes("_AVG_ALL"))||(e==null?void 0:e.includes("_COUNT_ALL"))||(e==null?void 0:e.includes("_MIN_ALL"))||(e==null?void 0:e.includes("_MAX_ALL")),r=(t==null?void 0:t.some(o=>o.columnName===e&&(o.subtotalScope==="grand-total"||o.subtotalLevel==="grandTotal"||o.subtotalLevel==="ALL")))??!1;return n||r}function mtt({data:e,card:t,table:n,sorting:r,setSorting:o,showRowTotals:s,onAggregationChange:i,onOpenColumnSettings:a,suppressSortControls:c=!1,tableAppearance:u}){const[,d]=v.useState(null),f=p.useDashboardStore(g=>g.isVisualEditing),h=v.useCallback(g=>{var x;return(x=n.getHeaderGroups()[0])==null?void 0:x.headers.find(b=>b.column.id===g)},[n]);return{buildColumnHeaderRows:v.useCallback(()=>{var k,T;const g=((k=t.config)==null?void 0:k.pivotByColumns)||[],x=g.length,b=((T=e.groupByColumns)==null?void 0:T.length)||1,y=e.columnHeaders.length;function w(_,E,D,M=[]){_.forEach((P,A)=>{const L=P.level;if(L<x){const O=P.columnKey||`${L}-${M.join("-")}-${P.name}-${A}`,B=P.children?1:x-L;if(D[L].push(l.jsx(wo,{colSpan:P.colspan,rowSpan:B,style:u.headerCellStyle,className:p.cn("h-8 whitespace-nowrap border-b border-border/50 px-3 py-1.5 text-center text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName,L===0?"bg-muted/95":"bg-muted/90"),children:l.jsx("div",{className:"flex items-center justify-center",children:l.jsx("span",{className:"whitespace-nowrap",children:P.name})})},O)),P.children){const H=[...M,P.name];w(P.children,L+1,D,H)}}})}function C(_,E=[]){const D=[];return _.forEach((M,P)=>{var A,L,O,B,H,R,V,z;if(M.columnKey){const F=M.columnKey||`metric-${E.join("-")}-${M.name}-${P}`,G=ftt(M.columnKey),q=htt(M.columnKey,e.columnSubtotalMeta),Y=n.getColumn(M.columnKey),K=h(M.columnKey);D.push(l.jsx(wo,{"data-column-id":M.columnKey,className:p.cn("group/header h-8 whitespace-nowrap border-b border-border/50 bg-muted/85 px-3 py-1.5 text-right text-[10px] uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName,q?"bg-muted/95 font-semibold":G?"bg-muted/90 font-medium":""),style:{...u.headerCellStyle,width:K==null?void 0:K.getSize(),minWidth:K==null?void 0:K.getSize(),maxWidth:K==null?void 0:K.getSize(),position:"relative",transition:"none"},children:Y?l.jsxs("div",{className:"flex w-full items-center justify-end gap-1",children:[c?l.jsx("span",{className:p.cn("min-w-0 truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:((B=e.columnDisplayNames)==null?void 0:B[M.columnKey])||M.name||"Metric",children:((H=e.columnDisplayNames)==null?void 0:H[M.columnKey])||M.name||"Metric"}):l.jsxs(p.Button,{variant:"ghost",className:"h-auto min-w-0 shrink p-0 hover:bg-transparent",onClick:()=>{const $=Y.getIsSorted();o($?$==="asc"?[{id:Y.id,desc:!0}]:[]:[{id:Y.id,desc:!1}])},"aria-label":`Sort ${((A=e.columnDisplayNames)==null?void 0:A[M.columnKey])||M.name||"Metric"}`,children:[l.jsx("span",{className:p.cn("min-w-0 truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:((L=e.columnDisplayNames)==null?void 0:L[M.columnKey])||M.name||"Metric",children:((O=e.columnDisplayNames)==null?void 0:O[M.columnKey])||M.name||"Metric"}),l.jsx(ws,{className:p.cn("h-3 w-3",Y.getIsSorted()==="asc"?"block":"hidden")}),l.jsx(ss,{className:p.cn("h-3 w-3",Y.getIsSorted()==="desc"?"block":"hidden")})]}),f&&a&&!(K!=null&&K.column.getIsResizing())&&l.jsxs(Xo,{modal:!1,children:[l.jsx(Qo,{asChild:!0,children:l.jsx(p.Button,{variant:"ghost",size:"icon","aria-label":`Configure ${((R=e.columnDisplayNames)==null?void 0:R[M.columnKey])||M.name||"Metric"} column`,className:"h-5 w-5 shrink-0 p-0",onClick:$=>$.stopPropagation(),children:l.jsx(Ii,{className:"h-3 w-3"})})}),l.jsxs(Fo,{align:"end",className:"w-44",children:[!c&&l.jsxs(l.Fragment,{children:[l.jsxs(In,{className:"gap-2 text-xs",onSelect:()=>o([{id:Y.id,desc:!1}]),children:[l.jsx(ws,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Sort ascending"]}),l.jsxs(In,{className:"gap-2 text-xs",onSelect:()=>o([{id:Y.id,desc:!0}]),children:[l.jsx(ss,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Sort descending"]}),l.jsx(Ta,{})]}),l.jsxs(In,{className:"gap-2 text-xs",onSelect:()=>a(M.columnKey),children:[l.jsx(p.SlidersHorizontal,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Format column"]})]})]}),K&&f&&l.jsx(ih,{header:K,isResizing:K.column.getIsResizing()})]}):l.jsx("span",{className:"block truncate px-2",title:((V=e.columnDisplayNames)==null?void 0:V[M.columnKey])||M.name||"Metric",children:((z=e.columnDisplayNames)==null?void 0:z[M.columnKey])||M.name||"Metric"})},F))}else if(M.children){const F=[...E,M.name];D.push(...C(M.children,F))}}),D}const N=l.jsxs(Lr,{"data-header-type":"pivot-hierarchy","data-header-row-index":"0","data-repeat-header":"true",children:[e.groupByColumns&&e.groupByColumns.length>0?e.groupByColumns.map((_,E)=>{var A,L,O,B,H;const D=(A=n.getHeaderGroups()[0])==null?void 0:A.headers.find(R=>R.column.id===`rowLevel${E}`),M=D==null?void 0:D.getSize(),P=`row-header-${E}`;return l.jsx(wo,{rowSpan:x+2,"data-column-id":`rowLevel${E}`,className:p.cn("group/rowheader h-8 whitespace-nowrap border-b border-r border-border/40 bg-muted/95 px-3 py-1.5 text-left align-bottom text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),style:{...u.headerCellStyle,width:M,minWidth:M,maxWidth:M,position:"relative",transition:"none"},children:l.jsxs("div",{className:"flex h-full min-w-0 items-end justify-between",children:[l.jsxs("div",{className:"relative flex min-w-0 items-center",children:[i&&l.jsx("div",{className:p.cn("absolute left-0 top-1/2 -translate-y-1/2 overflow-hidden transition-all duration-200","h-6 w-6 opacity-100"),children:l.jsx(RM,{columnName:_.label||_.name,groupByFields:e.groupByColumns||[],pivotByFields:g,currentAggregation:{rowAggregates:(L=t.config)==null?void 0:L.rowAggregates,columnAggregates:(O=t.config)==null?void 0:O.columnAggregates},onAggregationChange:i,onOpenChange:R=>d(R?P:null)})}),c?l.jsx("div",{className:p.cn("flex h-auto min-w-0 items-center gap-1 p-0 transition-all duration-200",i&&"pl-7"),children:l.jsx("span",{className:p.cn("truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:_.label||_.name,children:_.label||_.name})}):l.jsxs(p.Button,{variant:"ghost",className:p.cn("flex h-auto min-w-0 items-center gap-1 p-0 transition-all duration-200 hover:bg-transparent",i&&"pl-7"),onClick:R=>{R.stopPropagation(),R.preventDefault(),o(V=>{const z=V.find(F=>F.id===`rowLevel${E}`);return z?z.desc?[]:[{id:`rowLevel${E}`,desc:!0}]:[{id:`rowLevel${E}`,desc:!1}]})},children:[l.jsx("span",{className:p.cn("truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:_.label||_.name,children:_.label||_.name}),l.jsx(ws,{className:p.cn("h-3 w-3 flex-shrink-0",((B=r.find(R=>R.id===`rowLevel${E}`))==null?void 0:B.desc)===!1?"block":"hidden")}),l.jsx(ss,{className:p.cn("h-3 w-3 flex-shrink-0",((H=r.find(R=>R.id===`rowLevel${E}`))==null?void 0:H.desc)===!0?"block":"hidden")})]})]}),D&&f&&l.jsx(ih,{header:D,isResizing:D.column.getIsResizing()})]})},`row-header-corner-${E}`)}):l.jsx(wo,{colSpan:b,rowSpan:x+2,style:u.headerCellStyle,className:p.cn("h-8 whitespace-nowrap border-b border-border/50 bg-muted/95 px-3 py-1.5 text-[10px] uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),children:""}),l.jsx(wo,{colSpan:y,style:u.headerCellStyle,className:p.cn("h-8 whitespace-nowrap border-b border-border/50 bg-muted/95 px-3 py-1.5 text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),children:l.jsxs("div",{className:"group/pivot-main relative flex items-center",children:[i&&(()=>{var E,D;const _="pivot-main";return l.jsx("div",{className:p.cn("absolute left-0 top-1/2 -translate-y-1/2 overflow-hidden transition-all duration-200","h-6 w-6 opacity-100"),children:l.jsx(RM,{columnName:"Pivot Columns",groupByFields:e.groupByColumns||[],pivotByFields:g,currentAggregation:{rowAggregates:(E=t.config)==null?void 0:E.rowAggregates,columnAggregates:(D=t.config)==null?void 0:D.columnAggregates},onAggregationChange:i,onOpenChange:M=>d(M?_:null)})})})(),l.jsx("div",{className:p.cn("transition-all duration-200",i&&"pl-7"),children:g.map((_,E)=>l.jsxs("span",{className:"inline-flex items-center",children:[_.label,E<g.length-1&&l.jsx(Mt.ChevronRight,{className:"mx-1 inline-block h-4 w-4 text-muted-foreground"})]},_.id))})]})},"pivot-hierarchy"),s&&(()=>{var D;const _=(D=n.getHeaderGroups()[0])==null?void 0:D.headers.find(M=>M.column.id==="rowTotal"),E=_==null?void 0:_.getSize();return l.jsx(wo,{"data-column-id":"rowTotal",className:p.cn("group/total h-8 whitespace-nowrap border-b border-border/50 bg-muted/95 px-3 py-1.5 text-center text-[10px] uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),rowSpan:x+2,style:{...u.headerCellStyle,width:E,minWidth:E,maxWidth:E,position:"relative",transition:"none"},children:(()=>{const M=n.getColumn("rowTotal");return M?l.jsxs("div",{className:"flex w-full items-center justify-end",children:[c?l.jsx("span",{className:p.cn("truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:"Total",children:"Total"}):l.jsxs(p.Button,{variant:"ghost",className:"h-auto min-w-0 p-0 hover:bg-transparent",onClick:()=>{const P=M.getIsSorted();o(P?P==="asc"?[{id:M.id,desc:!0}]:[]:[{id:M.id,desc:!1}])},"aria-label":"Sort Total",children:[l.jsx("span",{className:p.cn("truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:"Total",children:"Total"}),l.jsx(ws,{className:p.cn("h-3 w-3",M.getIsSorted()==="asc"?"block":"hidden")}),l.jsx(ss,{className:p.cn("h-3 w-3",M.getIsSorted()==="desc"?"block":"hidden")})]}),_&&f&&l.jsx(ih,{header:_,isResizing:_.column.getIsResizing()})]}):"Total"})()},"pivot-hierarchy-total")})()]},"pivot-hierarchy"),S=[];if(e.columnGroups&&e.columnGroups.length>0){const _=Array.from({length:x},()=>[]);w(e.columnGroups,0,_,[]);for(let E=0;E<x;E++)S.push(l.jsx(Lr,{"data-header-type":"pivot-values","data-header-row-index":E+1,"data-repeat-header":"true",children:_[E]},`pivot-row-${E}`))}let j=[];e.columnGroups&&e.columnGroups.length>0?j=C(e.columnGroups,[]):e.columnHeaders.forEach(_=>{var M,P,A,L,O,B,H,R,V;const E=n.getColumn(_),D=(M=n.getHeaderGroups()[0])==null?void 0:M.headers.find(z=>z.column.id===_);j.push(l.jsx(wo,{"data-column-id":_,className:p.cn("group/colheader h-8 whitespace-nowrap border-b border-border/50 bg-muted/85 px-3 py-1.5 text-right text-[10px] uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),style:{...u.headerCellStyle,width:D==null?void 0:D.getSize(),minWidth:D==null?void 0:D.getSize(),maxWidth:D==null?void 0:D.getSize(),position:"relative",transition:"none"},children:E?l.jsxs("div",{className:"flex w-full items-center justify-end gap-1",children:[c?l.jsx("span",{className:p.cn("min-w-0 truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:((O=e.columnDisplayNames)==null?void 0:O[_])||_,children:((B=e.columnDisplayNames)==null?void 0:B[_])||_}):l.jsxs(p.Button,{variant:"ghost",className:"h-auto min-w-0 shrink p-0 hover:bg-transparent",onClick:()=>{const z=E.getIsSorted();o(z?z==="asc"?[{id:E.id,desc:!0}]:[]:[{id:E.id,desc:!1}])},"aria-label":`Sort ${((P=e.columnDisplayNames)==null?void 0:P[_])||_}`,children:[l.jsx("span",{className:p.cn("min-w-0 truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:((A=e.columnDisplayNames)==null?void 0:A[_])||_,children:((L=e.columnDisplayNames)==null?void 0:L[_])||_}),l.jsx(ws,{className:p.cn("h-3 w-3",E.getIsSorted()==="asc"?"block":"hidden")}),l.jsx(ss,{className:p.cn("h-3 w-3",E.getIsSorted()==="desc"?"block":"hidden")})]}),f&&a&&!(D!=null&&D.column.getIsResizing())&&l.jsxs(Xo,{modal:!1,children:[l.jsx(Qo,{asChild:!0,children:l.jsx(p.Button,{variant:"ghost",size:"icon","aria-label":`Configure ${((H=e.columnDisplayNames)==null?void 0:H[_])||_} column`,className:"h-5 w-5 shrink-0 p-0",onClick:z=>z.stopPropagation(),children:l.jsx(Ii,{className:"h-3 w-3"})})}),l.jsxs(Fo,{align:"end",className:"w-44",children:[!c&&l.jsxs(l.Fragment,{children:[l.jsxs(In,{className:"gap-2 text-xs",onSelect:()=>o([{id:E.id,desc:!1}]),children:[l.jsx(ws,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Sort ascending"]}),l.jsxs(In,{className:"gap-2 text-xs",onSelect:()=>o([{id:E.id,desc:!0}]),children:[l.jsx(ss,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Sort descending"]}),l.jsx(Ta,{})]}),l.jsxs(In,{className:"gap-2 text-xs",onSelect:()=>a(_),children:[l.jsx(p.SlidersHorizontal,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Format column"]})]})]}),D&&f&&l.jsx(ih,{header:D,isResizing:D.column.getIsResizing()})]}):l.jsx("span",{className:"block truncate px-2",title:((R=e.columnDisplayNames)==null?void 0:R[_])||_,children:((V=e.columnDisplayNames)==null?void 0:V[_])||_})},_))});const I=l.jsxs(Lr,{"data-header-type":"metrics","data-header-row-index":x>0?x+1:0,"data-repeat-header":"true",children:[x===0&&(e.groupByColumns&&e.groupByColumns.length>0?e.groupByColumns.map((_,E)=>{var A,L,O,B;const D=(A=n.getHeaderGroups()[0])==null?void 0:A.headers.find(H=>H.column.id===`rowLevel${E}`),M=D==null?void 0:D.getSize(),P=`metric-row-${E}`;return l.jsx(wo,{"data-column-id":`rowLevel${E}`,className:p.cn("group/metricrow h-8 whitespace-nowrap border-b border-border/50 bg-muted/85 px-3 py-1.5 text-left text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),style:{...u.headerCellStyle,width:M,minWidth:M,maxWidth:M,position:"relative",transition:"none"},children:l.jsxs("div",{className:"flex w-full items-center justify-between",children:[l.jsxs("div",{className:"relative flex min-w-0 items-center",children:[i&&l.jsx("div",{className:p.cn("absolute left-0 top-1/2 -translate-y-1/2 overflow-hidden transition-all duration-200","h-6 w-6 opacity-100"),children:l.jsx(RM,{columnName:_.label||_.name,groupByFields:e.groupByColumns||[],pivotByFields:((L=t.config)==null?void 0:L.pivotByColumns)||[],currentAggregation:{rowAggregates:(O=t.config)==null?void 0:O.rowAggregates,columnAggregates:(B=t.config)==null?void 0:B.columnAggregates},onAggregationChange:i,onOpenChange:H=>d(H?P:null)})}),c?l.jsx("div",{className:p.cn("flex h-auto min-w-0 items-center gap-1 p-0 transition-all duration-200",i&&"pl-7"),children:l.jsx("span",{className:p.cn("truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:_.label||_.name,children:_.label||_.name})}):l.jsxs(p.Button,{variant:"ghost",className:p.cn("flex h-auto min-w-0 items-center gap-1 p-0 transition-all duration-200 hover:bg-transparent",i&&"pl-7"),onClick:()=>{o(H=>{const R=H.find(V=>V.id===`rowLevel${E}`);return R?R.desc===!1?[{id:`rowLevel${E}`,desc:!0}]:[]:[{id:`rowLevel${E}`,desc:!1}]})},children:[l.jsx("span",{className:p.cn("truncate text-[10px] font-medium uppercase tracking-[0.08em]",u.densitySpec.header,u.headerTextClassName),title:_.label||_.name,children:_.label||_.name}),(()=>{const H=r.find(R=>R.id===`rowLevel${E}`);return l.jsxs(l.Fragment,{children:[l.jsx(ss,{className:p.cn("h-3 w-3 flex-shrink-0",(H==null?void 0:H.desc)===!0?"block":"hidden")}),l.jsx(ws,{className:p.cn("h-3 w-3 flex-shrink-0",(H==null?void 0:H.desc)===!1?"block":"hidden")})]})})()]})]}),D&&f&&l.jsx(ih,{header:D,isResizing:D.column.getIsResizing()})]})},`row-header-title-${E}`)}):Array.from({length:b}).map((_,E)=>l.jsx(wo,{style:u.headerCellStyle,className:p.cn("h-8 whitespace-nowrap border-b border-border/50 bg-muted/85 py-1.5 text-left text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",u.densitySpec.header,u.headerTextClassName),children:`Level ${E+1}`},`empty-header-metric-${E}`))),j]},"metric-row");return x>0?[N,...S,I]:[I]},[e,t,n,r,o,s,i,h,d,f,a,c,u])}}function ptt(e,t,n){var k,T;const r=p.useDashboardStore(_=>_.isVisualEditing);p.useDashboardStore(_=>_.isDashboardEditing),p.useDashboardStore(_=>_.selectedSheetId);const{updateCurrentDashboardCard:o,updateFrame:s}=p.useDashboardActions(),i=p.useEditorStore(_=>{var E;return(E=_.actions)==null?void 0:E.setCardPreferences}),a=p.useEditorStore(_=>_.card),c=((T=(k=e==null?void 0:e.preferences)==null?void 0:k.tablePrefs)==null?void 0:T.columnSettingsMap)??p.EMPTY_COLUMN_SETTINGS,u=v.useMemo(()=>ac(c),[c]),[d,f]=v.useState(!1),[h,m]=v.useState(null),[g,x]=v.useState(Ao()),[b,y]=v.useState(!1),w=v.useRef(Ao()),C=v.useCallback(_=>{var D,M;m(_);let E=u[_];if(!E){const P=t==null?void 0:t.map(A=>{var L,O;return{[_]:(O=(L=A.cells)==null?void 0:L[_])==null?void 0:O.value}});E=P&&P.length>0?K0(_,P,n):Ao()}E=Ki({card:e,columnId:_,resolvedSettings:E,metricId:(D=n==null?void 0:n[_])==null?void 0:D.metricId,metricAlias:(M=n==null?void 0:n[_])==null?void 0:M.metricAlias,preserveOmittedProperties:!0})||E,w.current=E,x(E),y(!1),f(!0)},[e,u,t,n]),N=v.useCallback(()=>{var _,E;if(h&&g){const D=K5({persisted:c,columnId:h,baseline:w.current,next:g,reset:b});if(r&&i){const M={...a.preferences,tablePrefs:{...(_=a.preferences)==null?void 0:_.tablePrefs,columnSettingsMap:D}};i(M)}else if(o){const M={...e,preferences:{...e.preferences,tablePrefs:{...(E=e.preferences)==null?void 0:E.tablePrefs,columnSettingsMap:D}}};o(M)}}f(!1)},[h,g,b,c,r,i,a,o,e]),S=v.useCallback(()=>{h&&(x(Ao()),y(!0))},[h]),j=v.useCallback(_=>{y(!1),x(_)},[]),I=v.useCallback(()=>{var _,E;if(r&&i){const D={...a.preferences,tablePrefs:{...(_=a.preferences)==null?void 0:_.tablePrefs,columnSettingsMap:{}}};i(D)}else if(o){const D={...e,preferences:{...e.preferences,tablePrefs:{...(E=e.preferences)==null?void 0:E.tablePrefs,columnSettingsMap:{}}}};o(D)}f(!1)},[r,i,a,o,e]);return{columnSettings:u,columnSettingsOpen:d,activeColumnId:h,tempColumnSettings:g,isVisualEditing:r,openColumnSettings:C,applyColumnSettings:N,resetColumnSettings:S,resetAllColumnSettings:I,setColumnSettingsOpen:f,setTempColumnSettings:j}}function gtt({table:e,data:t,columns:n,subtotalColumnKeys:r,grandTotalColumnKeys:o,isTablePrintDisplayMode:s=!1,shouldVirtualizeRows:i=!1,virtualRows:a,paddingTop:c=0,paddingBottom:u=0,measureElement:d,disableRowTransitions:f=!1,suppressEmptyState:h=!1,tableAppearance:m}){var C;const g=e.getRowModel().rows,x=((C=t.groupByColumns)==null?void 0:C.length)||1,y=i&&a&&a.length>0?a:g,w=n.length||1;return g!=null&&g.length?l.jsxs(l.Fragment,{children:[i&&c>0&&l.jsx(Lr,{"aria-hidden":!0,className:"pointer-events-none border-none",children:l.jsx(Kn,{colSpan:w,style:{height:c,padding:0,border:"none"}})}),y.map((N,S)=>{const j=i?N.index:S,I=i?g[j]:N;if(!I)return null;const k=I.original,T=e.getRowModel().rows,_=j===T.length-1;return l.jsx(Lr,{ref:i&&d?E=>d(E):void 0,style:k.isSubtotal?m.subtotalRowStyle:m.getDataRowStyle(j),className:p.cn("border-border/40",(f||m.hasHoverRowStyle)&&"!transition-none",!f&&!m.hasHoverRowStyle&&"transition-colors duration-150",!k.isSubtotal&&m.dataRowClassName,k.isSubtotal?"border-t border-t-border/50 bg-muted/70 font-medium":"hover:bg-muted/40"),"data-row-type":k.isSubtotal?"subtotal":"data","data-row-index":j,...k.isSubtotal&&{"data-subtotal-level":k.subtotalLevel},children:I.getVisibleCells().map(E=>{const D=E.column.id;if(D.startsWith("rowLevel")){const A=parseInt(D.replace("rowLevel",""));if(k.isSubtotal&&k.subtotalLevel){const O=r_(t.groupByColumns,k.subtotalLevel);return A===O?l.jsx(Kn,{colSpan:s?1:x-A,...Id({tableAppearance:m,divider:"row",textFlow:"direct",className:p.cn("border-r border-border/40 px-4 font-medium text-foreground/90",!_&&"border-b border-b-border/35")}),children:wi(E.column.columnDef.cell,E.getContext())},E.id):A<O?l.jsx(Kn,{...Id({tableAppearance:m,divider:"row",textFlow:"direct",className:p.cn("border-r border-border/40 px-4 font-medium text-foreground/90",!_&&"border-b border-b-border/35")}),children:wi(E.column.columnDef.cell,E.getContext())},E.id):s?l.jsx(Kn,{...Id({tableAppearance:m,divider:"row",textFlow:"direct",className:p.cn("border-r border-border/40 px-4 text-foreground/90",!_&&"border-b border-b-border/35")})},E.id):null}if(!i&&!s&&j>0)for(let O=j-1;O>=0;O--){const B=T[O].original;if(B.isSubtotal||B.isGrandTotal)break;let H=!0;for(let R=0;R<=A;R++)if(Ns(k,R)!==Ns(B,R)){H=!1;break}if(H)return null}let L=1;if(!i&&!s)for(let O=j+1;O<T.length;O++){const B=T[O].original;if(B.isSubtotal||B.isGrandTotal)break;let H=!0;for(let R=0;R<=A;R++)if(Ns(k,R)!==Ns(B,R)){H=!1;break}if(H)L++;else break}return l.jsx(Kn,{rowSpan:i?void 0:L,...qh({tableAppearance:m,divider:"row",textFlow:"direct",className:p.cn("border-r border-border/40 px-4 text-foreground/90",!_&&"border-b border-b-border/35")}),children:wi(E.column.columnDef.cell,E.getContext())},E.id)}const M=o.has(D),P=r.has(D);return l.jsx(Kn,{"data-column-id":D,...k.isSubtotal?Id({tableAppearance:m,divider:"row",textFlow:"direct",style:{width:E.column.getSize(),minWidth:E.column.getSize(),maxWidth:E.column.getSize(),transition:"none"},className:p.cn("px-4 text-foreground/90",!_&&"border-b border-b-border/35",M?"bg-muted/50":P?"bg-muted/30":void 0)}):qh({tableAppearance:m,divider:"row",textFlow:"direct",style:{width:E.column.getSize(),minWidth:E.column.getSize(),maxWidth:E.column.getSize(),transition:"none"},className:p.cn("px-4 text-foreground/90",!_&&"border-b border-b-border/35",M?"bg-muted/50":P?"bg-muted/30":void 0)}),children:wi(E.column.columnDef.cell,E.getContext())},E.id)})},I.id)}),i&&u>0&&l.jsx(Lr,{"aria-hidden":!0,className:"pointer-events-none border-none",children:l.jsx(Kn,{colSpan:w,style:{height:u,padding:0,border:"none"}})})]}):h?null:l.jsx(Lr,{className:"h-8",children:l.jsx(Kn,{colSpan:n.length,className:"text-center",children:"No results."})})}function btt({grandTotalRows:e,data:t,card:n,table:r,showRowTotals:o,columnSettings:s,isSqlCard:i=!1,contextTimezone:a,browserTimezone:c,onAggregationLabelChange:u,tableAppearance:d,valueFormatPreferences:f,resolveBoundCurrency:h}){return e.length===0?null:l.jsx(l.Fragment,{children:e.map((m,g)=>{var x;return l.jsxs(Lr,{style:d.grandTotalRowStyle,className:"h-8 border-border/40 font-semibold","data-row-type":"grandtotal","data-grandtotal":"true","data-grandtotal-index":g,children:[l.jsx(Kn,{colSpan:((x=t.groupByColumns)==null?void 0:x.length)||1,...Jc({tableAppearance:d,overflow:"visible",className:"border-r border-t-2 border-border/40 border-t-border/60 px-4 font-semibold text-foreground/90"}),children:u?l.jsx(Si,{value:(()=>{var w,C,N;const b=m.aggregateFunction||"SUM";return((N=(C=(w=n.config)==null?void 0:w.rowAggregates)==null?void 0:C.find(S=>S.function===b&&S.groupLevel==="ALL"))==null?void 0:N.label)||m.fieldValues[0]})(),placeholder:m.fieldValues[0],onSave:b=>{const y=m.aggregateFunction||"SUM";u({type:"row",level:"ALL",function:y,label:b})},displayClassName:"text-right"}):m.fieldValues[0]}),t.columnHeaders.map(b=>{var j,I,k,T,_,E;const y=(I=(j=t.columnMetadata)==null?void 0:j[b])==null?void 0:I.metricId,w=ic({card:n,columnKey:b,metricId:y}),C=Ki({card:n,columnId:b,resolvedSettings:s==null?void 0:s[b],metricId:y,metricAlias:(T=(k=t.columnMetadata)==null?void 0:k[b])==null?void 0:T.metricAlias,valueFormatPreferences:f,boundCurrency:w?h(w):void 0}),N=(_=r.getHeaderGroups()[0])==null?void 0:_.headers.find(D=>D.column.id===b),S=Jc({tableAppearance:d,style:{width:N==null?void 0:N.getSize(),minWidth:N==null?void 0:N.getSize(),maxWidth:N==null?void 0:N.getSize(),transition:"none"},className:"numeric border-t-2 border-t-border/60 px-4 text-right font-semibold tabular-nums text-foreground/90"});return l.jsx(Kn,{"data-column-id":b,className:S.className,style:S.style,children:Gj((E=m.cells[b])==null?void 0:E.value,C,a,c,i)},b)}),o&&(()=>{var N;const b=vL({card:n,columnHeaders:t.columnHeaders,columnMetadata:t.columnMetadata,columnSettings:s,valueFormatPreferences:f,resolveBoundCurrency:h}),y=(N=r.getHeaderGroups()[0])==null?void 0:N.headers.find(S=>S.column.id==="rowTotal"),w=y==null?void 0:y.getSize(),C=Jc({tableAppearance:d,style:{width:w,minWidth:w,maxWidth:w,transition:"none"},className:"numeric border-t-2 border-t-border/60 px-4 text-right font-semibold tabular-nums text-foreground/90"});return l.jsx(Kn,{className:C.className,"data-column-id":"rowTotal",style:C.style,children:Gj(Hte(m,t.columnHeaders),b,a,c,i)})})()]},m.id)})})}function xtt({groupByColumns:e,numRowLevels:t,onAggregationLabelChange:n,isTablePrintDisplayMode:r=!1,isCellWrapping:o=!1,cellContentClassName:s,onCellClick:i}){const a=[];return e&&e.length>0?e.forEach((c,u)=>{a.push({id:`rowLevel${u}`,header:()=>l.jsx("div",{className:"group px-3 py-1 text-left text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:l.jsx("div",{className:"flex items-center gap-1",children:l.jsx("span",{className:"whitespace-nowrap",children:c.label||c.name})})}),accessorFn:d=>d.fieldValues[u],cell:({row:d,table:f})=>{const h=d.original;if(h.isSubtotal&&h.subtotalLevel){const b=r_(e,h.subtotalLevel);if(u===b){const y=h.fieldValues[u];return l.jsx("div",{className:p.cn("align-top font-medium",!o&&"whitespace-nowrap",s),style:{gridColumn:`span ${t-u}`},children:y.includes(" Total")&&n?l.jsx(Si,{value:y,placeholder:y,onSave:w=>{const C=h.aggregateFunction||"SUM";if(h.subtotalLevel&&e){const N=b$e(e,h.subtotalLevel);N&&n({type:"row",level:N.id,function:C,label:w})}},displayClassName:"text-left"}):y})}else if(u<b)return l.jsx("div",{className:p.cn("align-top font-medium",!o&&"whitespace-nowrap",s),children:h.fieldValues[u]});return r?l.jsx("div",{className:p.cn("align-top",!o&&"whitespace-nowrap",s)}):null}const m=f.getRowModel().rows,g=m.findIndex(b=>b.id===d.id);if(!r&&g>0)for(let b=g-1;b>=0;b--){const y=m[b].original;if(y.isSubtotal||y.isGrandTotal)break;let w=!0;for(let C=0;C<=u;C++)if(Ns(h,C)!==Ns(y,C)){w=!1;break}if(w)return null}let x=1;if(!r)for(let b=g+1;b<m.length;b++){const y=m[b].original;if(y.isSubtotal||y.isGrandTotal)break;let w=!0;for(let C=0;C<=u;C++)if(Ns(h,C)!==Ns(y,C)){w=!1;break}if(w)x++;else break}return l.jsx("div",{className:p.cn("align-top",!o&&"whitespace-nowrap",s),onClick:i&&!h.isGrandTotal?b=>i(b,h,`rowLevel${u}`):void 0,style:{gridRow:r?void 0:`span ${x}`},children:h.fieldValues[u]})}})}):a.push({id:"rowHeader",header:()=>l.jsx("div",{className:"px-3 py-1 text-left font-medium",children:"Row"}),accessorFn:c=>c.rowKey,cell:({getValue:c})=>l.jsx("div",{className:p.cn("min-w-[150px] max-w-[300px] border-x border-y border-border px-3 py-1",s),children:String(c())})}),a}function ytt({columnHeaders:e,columnDisplayNames:t,setSorting:n,columnSettings:r,card:o,columnMetadata:s,contextTimezone:i,browserTimezone:a,isSqlCard:c=!1,suppressSortControls:u=!1,valueFormatPreferences:d,resolveBoundCurrency:f,onCellClick:h}){return e.map(m=>({id:m,accessorFn:g=>{var x;return(x=g.cells[m])==null?void 0:x.value},header:({column:g})=>{const x=(t==null?void 0:t[m])||m;return l.jsx("div",{className:"flex w-full items-center justify-end",children:u?l.jsx("span",{className:"text-sm font-medium",children:x}):l.jsxs(p.Button,{variant:"ghost",className:"h-auto min-w-0 p-0 hover:bg-transparent",onClick:()=>{const b=g.getIsSorted();n(b?b==="asc"?[{id:g.id,desc:!0}]:[]:[{id:g.id,desc:!1}])},"aria-label":`Sort ${x}`,children:[l.jsx("span",{className:"min-w-0 truncate text-sm font-medium",children:x}),g.getIsSorted()==="asc"?l.jsx(ws,{className:"h-3 w-3"}):g.getIsSorted()==="desc"?l.jsx(ss,{className:"h-3 w-3"}):null]})})},cell:({getValue:g,row:x})=>{var S,j,I;const b=g(),y=o?ic({card:o,columnKey:m,metricId:(S=s==null?void 0:s[m])==null?void 0:S.metricId}):void 0,w=Ki({card:o,columnId:m,resolvedSettings:r==null?void 0:r[m],metricId:(j=s==null?void 0:s[m])==null?void 0:j.metricId,metricAlias:(I=s==null?void 0:s[m])==null?void 0:I.metricAlias,valueFormatPreferences:d,boundCurrency:y?f(y):void 0}),C=(w==null?void 0:w.textAlign)||"right",N=C==="left"?"text-left":C==="center"?"text-center":"text-right";return l.jsx("div",{className:N,onClick:h?k=>h(k,x.original,m):void 0,children:Gj(b,w,i,a,c)})}}))}function vtt({columnHeaders:e,setSorting:t,suppressSortControls:n=!1,settings:r}){return{id:"rowTotal",header:({column:o})=>l.jsx("div",{className:"flex w-full items-center justify-end",children:n?l.jsx("span",{className:"text-sm font-medium",children:"Total"}):l.jsxs(p.Button,{variant:"ghost",className:"h-auto min-w-0 p-0 hover:bg-transparent",onClick:()=>{const s=o.getIsSorted();t(s?s==="asc"?[{id:o.id,desc:!0}]:[]:[{id:o.id,desc:!1}])},"aria-label":"Sort Total",children:[l.jsx("span",{className:"text-sm font-medium",children:"Total"}),o.getIsSorted()==="asc"?l.jsx(ws,{className:"h-3 w-3"}):o.getIsSorted()==="desc"?l.jsx(ss,{className:"h-3 w-3"}):null]})}),cell:({row:o})=>{const s=o.original,i=Hte(s,e);return l.jsx("div",{className:"text-right text-sm font-medium",children:Gj(i,r)})}}}function _U(e){const t=at.resolveGroupedTemporalFieldPresentationByRole({presentation:e.presentation,fieldId:e.field.id,role:e.field.role});return e.value===null?{field:e.field,operator:"isNull",value:null,...t?{label:"(Blank)",temporalBucket:t.metadata}:{}}:{field:e.field,operator:"=",value:e.value,...t?{label:at.formatGroupedTemporalFieldValue({fieldId:e.field.id,role:e.field.role,value:e.value,presentation:e.presentation}),temporalBucket:t.metadata}:{}}}function wtt(e){var m,g,x;if(e.row.isSubtotal||e.row.isGrandTotal||!e.card.config)return;const t=e.card.config,n=e.row.canonicalFieldValues||e.row.fieldValues,r=(t.groupByColumns||[]).map((b,y)=>_U({field:b,value:n[y]??null,presentation:e.temporalPresentation})),o=(m=e.resultColumns)==null?void 0:m.find(b=>b.key===e.columnKey);if((((g=o==null?void 0:o.pivotIdentity)==null?void 0:g.members)??[]).forEach(b=>{const y=(t.pivotByColumns||[]).find(w=>w.id===b.fieldId);y&&r.push(_U({field:y,value:b.value,presentation:e.temporalPresentation}))}),r.length===0)return;const i=o==null?void 0:o.pivotIdentity,a=t.metricColumns||[],c=i?a.find(b=>Vr.resolveMetricResultAlias(b)===i.metricAlias):void 0,u=i?a.filter(b=>b.id===i.metricId):[],d=c||(u.length===1?u[0]:void 0),f=(x=e.row.cells[e.columnKey])==null?void 0:x.value,h=d&&typeof f=="number"?[{field:d,value:f}]:[];return{conditions:r,...h.length?{metrics:h}:{}}}function tx({data:e,card:t,options:n={},onAggregationChange:r,onAggregationLabelChange:o,suppressSortControls:s=!1,renderPlainWrapper:i=!1,frameId:a,sheetId:c,onMultipleInteractions:u}){var ee,ae,se,he,ge;const{preferences:d,resolveBoundCurrency:f}=Pa(t,e.columnHeaders),{displayPreferences:h,shouldShowElement:m}=pl(),g=v.useRef(null),x=v.useMemo(()=>w3(),[]),{updatePageSize:b}=p.useEditorActions(),y=v.useMemo(()=>typeof document<"u"&&"onscrollend"in document,[]),w=!!(t!=null&&t.sql),C=typeof window<"u"?Intl.DateTimeFormat().resolvedOptions().timeZone:void 0,N=void 0,S=v.useMemo(()=>p.getInteractions(t.interactionConfig).some(p.isInteractionConfiguredForExecution),[t.interactionConfig]),{handlePointerInteraction:j}=p.useEventEngine(t,a||"",c||"",u),I=v.useCallback((ke,De,Re)=>{if(!S||!a||!c)return;const Ve=wtt({card:t,row:De,columnKey:Re,resultColumns:e.resultColumns,temporalPresentation:e.temporalPresentation});Ve&&(ke.stopPropagation(),j({context:Ve,gesture:"leftClick",modifierKeys:{shift:ke.shiftKey,ctrl:ke.ctrlKey,meta:ke.metaKey},position:{x:ke.clientX,y:ke.clientY}}))},[t,e.resultColumns,e.temporalPresentation,a,j,S,c]),k=n.showRowTotals??!1,{columnSizing:T,onColumnSizingChange:_}=v3({card:t}),{subtotalColumnKeys:E,grandTotalColumnKeys:D}=v.useMemo(()=>NDe(e.columnSubtotalMeta),[e.columnSubtotalMeta]),{tableData:M,grandTotalRows:P}=v.useMemo(()=>yL(e),[e]),{sorting:A,setSorting:L,sortedTableData:O}=dtt(M,e),{columnSettings:B,columnSettingsOpen:H,activeColumnId:R,tempColumnSettings:V,isVisualEditing:z,openColumnSettings:F,applyColumnSettings:G,resetColumnSettings:q,resetAllColumnSettings:Y,setColumnSettingsOpen:K,setTempColumnSettings:$}=ptt(t,O,e.columnMetadata),X=S3({displayMode:h.mode,isVisualEditing:z,printBehavior:"any-print",renderPlainWrapper:i}),W=X.isPrint,U=w_("pivotTable",(ae=(ee=t==null?void 0:t.preferences)==null?void 0:ee.tablePrefs)==null?void 0:ae.density,X.mode==="document-print"?"document":"appearance"),Z={...n.pagination},Q=itt(Z,O.length),J=v.useMemo(()=>{var ve;const ke=[],De=((ve=e.groupByColumns)==null?void 0:ve.length)||1,Re=xtt({groupByColumns:e.groupByColumns,numRowLevels:De,onAggregationLabelChange:o,isTablePrintDisplayMode:W,isCellWrapping:U.isCellWrapping,cellContentClassName:U.cellContentClassName,onCellClick:I});ke.push(...Re);const Ve=ytt({columnHeaders:e.columnHeaders,columnDisplayNames:e.columnDisplayNames,setSorting:L,suppressSortControls:s,columnSettings:B,card:t,columnMetadata:e.columnMetadata,contextTimezone:N,browserTimezone:C,isSqlCard:w,valueFormatPreferences:d,resolveBoundCurrency:f,onCellClick:I});if(ke.push(...Ve),k){const Ke=vtt({columnHeaders:e.columnHeaders,setSorting:L,suppressSortControls:s,settings:vL({card:t,columnHeaders:e.columnHeaders,columnMetadata:e.columnMetadata,columnSettings:B,valueFormatPreferences:d,resolveBoundCurrency:f})});ke.push(Ke)}return ke},[t,e,k,o,L,s,W,B,N,C,w,U.cellContentClassName,U.isCellWrapping,d,f,I]),re=f_({data:O,columns:J,state:{sorting:A,columnSizing:T,pagination:{pageIndex:Q.pageIndex,pageSize:Q.pageSize}},onSortingChange:L,onPaginationChange:void 0,getCoreRowModel:u_(),getPaginationRowModel:!Q.isServerSidePagination&&X.allowPagination?d_():void 0,manualPagination:Q.isServerSidePagination||!X.allowPagination,manualSorting:!0,pageCount:Q.pageCount,enableColumnResizing:!0,columnResizeMode:"onChange",onColumnSizingChange:_}),de=re.getRowModel().rows,ce=X.allowVirtualization&&de.length>75,oe=ce&&(!x||U.isCellWrapping),fe=v_({count:ce?de.length:0,getScrollElement:()=>g.current,estimateSize:()=>U.dataRowHeight??32,overscan:x?5:10,useScrollendEvent:x&&y,isScrollingResetDelay:x?240:150}),we=ce?fe.getVirtualItems():[],pe=ce&&we.length>0?we[0].start:0,ne=ce&&we.length>0?fe.getTotalSize()-we[we.length-1].end:0,{buildColumnHeaderRows:Se}=mtt({data:e,card:t,table:re,sorting:A,setSorting:L,showRowTotals:k,onAggregationChange:r,onOpenColumnSettings:F,suppressSortControls:s,tableAppearance:U}),ue=Se(),ie=l.jsxs("table",{className:"w-full border-separate border-spacing-0 text-sm [border-spacing:0]",onMouseDown:ke=>ke.stopPropagation(),"data-pivot-table":"true","data-row-levels":((se=e.groupByColumns)==null?void 0:se.length)||1,"data-pivot-levels":e.columnGroups&&((ge=(he=t.config)==null?void 0:he.pivotByColumns)==null?void 0:ge.length)||0,children:[l.jsx(tp,{style:U.headerStyle,className:p.cn("bg-muted/95 [&_tr]:border-b-0",X.allowStickyHeader&&U.isHeaderSticky&&"sticky top-0 z-20 supports-[backdrop-filter]:bg-muted/80 supports-[backdrop-filter]:backdrop-blur-sm"),children:ue}),l.jsx(Qd,{children:l.jsx(gtt,{table:re,data:e,columns:J,subtotalColumnKeys:E,grandTotalColumnKeys:D,isTablePrintDisplayMode:W,shouldVirtualizeRows:ce,virtualRows:we,paddingTop:pe,paddingBottom:ne,measureElement:oe?fe.measureElement:void 0,disableRowTransitions:x,suppressEmptyState:P.length>0,tableAppearance:U})}),P.length>0&&l.jsx("tfoot",{className:p.cn("border-t border-t-border/60 bg-muted/95",X.allowStickyHeader&&"sticky bottom-0 z-10"),"data-grandtotal":"true",style:U.grandTotalRowStyle,children:l.jsx(btt,{grandTotalRows:P,data:e,card:t,table:re,showRowTotals:k,columnSettings:B,isSqlCard:w,contextTimezone:N,browserTimezone:C,onAggregationLabelChange:o,tableAppearance:U,valueFormatPreferences:d,resolveBoundCurrency:f})})]});return l.jsxs("div",{className:"flex h-full w-full flex-col gap-2",children:[X.usePlainWrapper?l.jsx("div",{ref:g,style:U.containerStyle,className:"data-table-scroll-container relative h-full rounded-none border border-border/60 bg-muted/20",onMouseDown:ke=>ke.stopPropagation(),children:ie}):l.jsxs(yl,{ref:g,style:U.containerStyle,className:"data-table-scroll-container relative h-full rounded-none border border-border/60 bg-muted/20",onMouseDown:ke=>ke.stopPropagation(),children:[ie,l.jsx(p.ScrollBar,{orientation:"horizontal",className:"z-20"})]}),X.allowPagination&&Q.showPagination&&l.jsx(h_,{totalColumns:J.length,pageCount:Q.pageCount||re.getPageCount(),pageIndex:Q.pageIndex,pageSize:Q.pageSize,rowCount:Q.totalCount,selectedRowCount:0,setPageIndex:Q.setPageIndex,setPageSize:Q.setPageSize,canPreviousPage:Q.canPreviousPage,canNextPage:Q.canNextPage,previousPage:Q.previousPage,nextPage:Q.nextPage,onPageSizePreferenceChange:X.showEditorControls?b:void 0,onClearSelection:()=>{},appearance:U.pagination}),R&&l.jsx(b3,{column:re.getColumn(R)||null,settings:V,onSettingsChange:$,onApply:G,onReset:q,onResetAll:Y,open:H,onOpenChange:K,tableType:"pivot",isSqlCard:w})]})}const Ctt=420,Stt=360,Ntt="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.4.1/chart.umd.min.js";function jtt(e){return`<!DOCTYPE html>
962
962
  <html lang="en">
963
963
  <head>
964
964
  <meta charset="utf-8" />
@@ -1389,4 +1389,4 @@ Defaulting to \`null\`.`}var oxe=exe,fkt=nxe;const Z4=te.forwardRef(({className:
1389
1389
  More info: ${o.docs}`:"",a=typeof o.message=="string"&&o.message.trim()?o.message.trim():typeof o.error=="string"&&o.error.trim()?o.error.trim():null;if(a){const c=s?` (code: ${s})`:"",u=s==="insufficient_quota"||a.toLowerCase().includes("quota")?`
1390
1390
 
1391
1391
  Semaphor supports bring-your-own OpenAI API keys. Add yours in Settings or drop a note to support@semaphor.cloud and we’ll help you get set up.`:"";return`${a}${c}${i}${u}`}return null};if(typeof e=="string"){const r=e.trim();if(!r)return"Something went wrong.";try{const o=JSON.parse(r),s=t(o);if(s)return s}catch{}return r}const n=t(e);if(n)return n;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function nB({errorMessage:e}){return l.jsxs("div",{className:"flex items-start gap-2 rounded-control border border-red-300 bg-red-50/60 p-2 text-[12px] text-red-700 dark:border-red-900/60 dark:bg-red-950/20 dark:text-red-300",children:[l.jsx(Yo,{className:"mt-0.5 h-3.5 w-3.5 shrink-0"}),l.jsx("span",{className:"whitespace-pre-wrap break-words leading-[1.55]",children:TIt(e)})]})}function EIt({error:e,resetErrorBoundary:t}){return l.jsxs("div",{className:"my-3 space-y-2 rounded-control border border-border/60 bg-muted/20 p-2.5",children:[l.jsx(nB,{errorMessage:e==null?void 0:e.message}),l.jsx("button",{type:"button",className:"text-[11px] font-medium text-muted-foreground underline underline-offset-2 hover:text-foreground",onClick:t,children:"Try again"})]})}function DIt({text:e,files:t}){return l.jsxs(Ixe,{who:"You",children:[e&&l.jsx("div",{className:"whitespace-pre-line text-[13px] leading-[1.55] text-foreground",children:e}),t&&t.length>0&&l.jsx("div",{className:"flex flex-wrap gap-2 pt-0.5",children:t.map(n=>l.jsx(mkt,{file:n},n.id))})]})}function MIt({text:e}){const t=e.split("|"),n=t[0],r=t[1]||"{}",o=JSON.parse(r);return l.jsxs("div",{className:"space-y-1 text-xs",children:[l.jsxs("div",{children:[l.jsx("span",{className:"font-bold",children:"System Message:"})," ",n]}),l.jsxs("div",{className:"space-y-1",children:[l.jsx("span",{className:"font-mono text-xs",children:"Scope:"}),l.jsx(Akt,{children:JSON.stringify(o,null,2)})]})]})}function _xe(e,t){return!e||e.role!=="assistant"?!1:(e.parts??[]).some(r=>{if(!r)return!1;switch(r.type){case"text":return typeof r.text=="string"&&r.text.trim().length>0;case"reasoning":return typeof r.text=="string"&&r.text.trim().length>0||r.state==="streaming";case"error":return!0;default:return typeof r.type=="string"&&(r.type.startsWith("tool-")||r.type==="dynamic-tool")?tB(r,t):!1}})}function tY(){return l.jsx("span",{className:"relative grid h-2 w-2 shrink-0 place-items-center",children:l.jsx("span",{className:"absolute inset-0 animate-pulse rounded-full bg-muted-foreground/70"})})}function RIt({status:e,errorMessage:t,activeToolText:n}){return n?l.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-muted-foreground",children:[l.jsx(tY,{}),l.jsx("span",{children:n})]}):e==="submitted"||e==="streaming"?l.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-muted-foreground",children:[l.jsx(tY,{}),l.jsx("span",{children:e==="submitted"?"Thinking":"Generating"})]}):e==="error"?l.jsx(nB,{errorMessage:t}):null}function AIt(e){var t;return e?(t=[...e].reverse().find(n=>{var r;return n.role==="assistant"&&((r=n.parts)==null?void 0:r.some(o=>o.type==="text"&&typeof o.text=="string"&&o.text.trim().length>0))}))==null?void 0:t.id:void 0}function PIt({message:e,messageIndex:t,messages:n,showTools:r=!1,onAddToDashboard:o,showSystemMessage:s=!1,handleRun:i,onQuickReply:a,disableQuickReplies:c=!1}){var y,w,C,N;const u=AIt(n),d=e.id===u;if(e.role==="user"){const S=((y=e.parts)==null?void 0:y.filter(T=>T.type==="text"))||[],j=((w=e.parts)==null?void 0:w.filter(T=>T.type==="file"))||[],I=S.map(T=>T.text).join(`
1392
- `).trim(),k=j.map((T,_)=>{var M,P;let E="",D;if((M=T.url)!=null&&M.startsWith("data:")){const A=T.url.match(/data:[^;]+;base64,(.+)/);A&&(E=A[1],(P=T.mediaType)!=null&&P.startsWith("image/")&&(D=T.url))}return{id:`${e.id||t}-file-${_}`,name:T.filename||`File ${_+1}`,size:0,type:T.mediaType||"application/octet-stream",data:E,preview:D}});return l.jsx(DIt,{text:I||void 0,files:k.length>0?k:void 0})}const f=((C=e.parts)==null?void 0:C.filter(S=>S.type==="reasoning"))||[],h=f.length>0,m=f.some(S=>S.state==="streaming"),g=f.filter(S=>S.text&&S.text.trim().length>0),x=h&&(g.length>0||m)?l.jsxs(ku,{className:"space-y-2",defaultOpen:!1,children:[l.jsx(Iu,{asChild:!0,children:l.jsxs("button",{type:"button",className:"group inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground",children:[l.jsx(Mt.ChevronRight,{className:"h-3 w-3 transition-transform duration-200 group-data-[state=open]:rotate-90"}),l.jsx("span",{className:m?"animate-pulse":"",children:m?"Reasoning":"Show reasoning"}),g.length>1&&l.jsxs("span",{className:"font-mono tabular-nums text-muted-foreground/70",children:["(",g.length," steps)"]})]})}),l.jsx(_u,{children:l.jsx("ol",{className:"space-y-2 border-l border-border/60 pl-3",children:g.map((S,j)=>l.jsxs("li",{className:"relative",children:[l.jsx("span",{className:"absolute -left-[15px] top-[3px] grid h-4 w-4 place-items-center rounded-full bg-muted font-mono text-[9px] text-muted-foreground",children:j+1}),l.jsx(KG,{className:"text-[12px] leading-[1.55] text-muted-foreground",text:S.text})]},`${e.id||t}-reasoning-${j}`))})})]},`${e.id||t}-reasoning`):null,b=(N=e.parts)==null?void 0:N.map((S,j)=>{var k;const I=`${e.id||t}-${j}`;switch(S.type){case"text":{const T=typeof S.text=="string"?S.text:JSON.stringify(S.text??"",null,2);if(e.role==="assistant"){const{cleanedText:_,quickReplies:E}=IIt(T),D=_.trim().length>0;return l.jsxs("div",{className:"space-y-2.5",children:[D&&l.jsx(KG,{text:_,handleRun:i,onAddToDashboard:o,messageId:e.id,messages:n}),E.length>0&&a&&d&&l.jsxs("div",{className:"space-y-1.5",children:[E.length>=3&&l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Suggested next steps"}),l.jsx("div",{className:"flex flex-wrap gap-1",children:E.map(({label:M,value:P},A)=>l.jsxs(p.Tooltip,{children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Button,{size:"sm",variant:"outline",className:"h-6 max-w-[220px] rounded-control border-border/60 bg-background px-2 text-[11px] font-normal text-foreground/85 transition-colors hover:border-border hover:bg-muted/40 hover:text-foreground disabled:opacity-50",disabled:c,onClick:()=>a(P),children:l.jsx("span",{className:"truncate",children:M})})}),l.jsx(p.TooltipContent,{side:"top",align:"center",children:l.jsx("p",{className:"max-w-xs text-xs",children:P})})]},`${I}-qr-${A}`))})]})]},I)}return e.role==="system"&&s?l.jsx(MIt,{text:T},I):null}case"error":{const T=S,_=T.errorText??T.error??T.message;return l.jsx("div",{className:"my-4",children:l.jsx(nB,{errorMessage:_})},I)}case"reasoning":return null;default:return((k=S.type)!=null&&k.startsWith("tool-")||S.type==="dynamic-tool")&&tB(S,r)?l.jsx(_i,{FallbackComponent:({error:T,resetErrorBoundary:_})=>l.jsx(EIt,{error:T,resetErrorBoundary:_}),children:l.jsx(CIt,{part:S,idx:I,messageId:e.id,showTools:r,onAddToDashboard:o,messages:n})},I):null}});return e.role==="assistant"?_xe(e,r)?l.jsxs(Ixe,{who:"Assistant",className:"space-y-2",children:[x,b]}):null:l.jsxs("div",{className:"space-y-2",children:[x,b]})}const FIt=8,OIt=24,LIt=20;function $It(e,t,n,r){return e==="error"&&t?!0:r?!1:!!(n||e==="submitted"||e==="streaming")}function Txe({messages:e,showTools:t=!1,showSystemMessage:n=!1,handleRun:r,onAddToDashboard:o,onQuickReply:s,disableQuickReplies:i=!1,status:a,errorMessage:c,activeToolText:u,className:d,rowContentClassName:f,statusClassName:h,latestButtonClassName:m,scrollToEndSignal:g=0}){const x=v.useRef(null),b=v.useRef(null),y=v.useRef(e.length),w=v.useRef(!1),C=v.useRef(null),N=v.useRef(!1),S=v.useRef(g),[j,I]=v.useState(!0),[k,T]=v.useState(0),[_,E]=v.useState(OIt);S.current!==g&&(S.current=g,N.current=!0);const D=e[e.length-1],M=_xe(D,t),P=$It(a,c,u,M),A=v_({count:e.length,getScrollElement:()=>x.current,estimateSize:H=>{const R=e[H];return(R==null?void 0:R.role)==="user"?88:180},getItemKey:H=>{const R=e[H];return(R==null?void 0:R.id)||`message-${H}`},anchorTo:"end",followOnAppend:!0,scrollEndThreshold:FIt,overscan:6,gap:20,paddingEnd:P?_+LIt:0,useAnimationFrameWithResizeObserver:!0,onChange:H=>{const R=H.isAtEnd();I(V=>V===R?V:R),R&&T(0)}}),L=v.useCallback((H="smooth")=>{C.current!==null&&cancelAnimationFrame(C.current),C.current=requestAnimationFrame(()=>{C.current=null,A.scrollToEnd({behavior:H})}),T(0),I(!0)},[A]);v.useLayoutEffect(()=>{w.current||(w.current=!0,L("auto"))},[L]),v.useLayoutEffect(()=>{N.current&&(N.current=!1,L("auto"))},[e.length,g,L]),v.useEffect(()=>{const H=y.current;y.current=e.length,e.length>H&&!A.isAtEnd()&&T(R=>R+e.length-H),e.length===0&&(T(0),I(!0),w.current=!1,N.current=!1)},[e.length,A]);const O=A.getVirtualItems(),B=A.getTotalSize();return v.useEffect(()=>()=>{C.current!==null&&cancelAnimationFrame(C.current)},[]),v.useLayoutEffect(()=>{const H=b.current;if(!H||!P)return;const R=()=>{const z=Math.ceil(H.getBoundingClientRect().height);z>0&&E(F=>F===z?F:z)};if(R(),typeof ResizeObserver>"u")return;const V=new ResizeObserver(R);return V.observe(H),()=>V.disconnect()},[P,a,c,u]),l.jsxs(l.Fragment,{children:[l.jsx(yl,{"data-role":"assistant-virtualized-scroll-area",ref:x,className:p.cn("min-h-0 min-w-0 flex-1 basis-0",d),children:l.jsxs("div",{className:"relative w-full",style:{height:B},children:[O.map(H=>{const R=e[H.index];return R?l.jsx("div",{ref:A.measureElement,"data-index":H.index,className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${H.start}px)`},children:l.jsx("div",{className:p.cn("min-w-0",f),children:l.jsx(PIt,{message:R,messageIndex:H.index,messages:e,showTools:t,showSystemMessage:n,handleRun:r,onAddToDashboard:o,onQuickReply:s,disableQuickReplies:i})})},H.key):null}),P&&l.jsx("div",{ref:b,className:p.cn("absolute left-0 top-0 w-full",h),style:{transform:`translateY(${Math.max(B-_,0)}px)`},children:l.jsx("div",{className:p.cn("min-w-0",f),children:l.jsx(RIt,{status:a,errorMessage:c,activeToolText:u})})})]})}),!j&&l.jsxs("button",{type:"button",onClick:()=>L("smooth"),"aria-label":"Scroll to latest",className:p.cn("absolute right-4 z-10 inline-flex h-7 items-center gap-1.5 rounded-full border border-border bg-background px-2.5 text-[11px] text-foreground shadow-[0_1px_2px_rgba(0,0,0,0.08)] transition-colors hover:bg-muted/40",m),children:[l.jsx(ss,{className:"h-3 w-3"}),"Latest",k>0&&l.jsx("span",{className:"grid h-4 min-w-[16px] place-items-center rounded-full bg-foreground px-1 font-mono text-[9px] tabular-nums text-background",children:k>9?"9+":k})]})]})}function zIt(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return"";const t=e;return(typeof t.userSql=="string"?t.userSql:"")||(typeof t.sourceSql=="string"?t.sourceSql:"")||(typeof t.sql=="string"?t.sql:"")}const BIt=[{title:"Show top 3 insights",subtitle:"from this dataset"},{title:"Create a bar chart for",subtitle:"sales by product category"}];function VIt({open:e,setOpen:t,isFullscreen:n,onFullscreenChange:r,fullscreenContainer:o}){const[s,i]=v.useState(!1),[a,c]=v.useState(ut.isDevEnv),[u,d]=v.useState(!1),[f,h]=v.useState("auto"),[m,g]=v.useState(!1),[x,b]=v.useState(!1),[y,w]=v.useState(0),C=n??x,{isLocalDev:N,isConsoleMode:S}=Hm(),j=N||S||a,I=v.useRef(null);p.useDashboardStore(se=>se.dashboard.aiScopeTables),p.useDashboardStore(se=>se.isDashboardEditing);const k=p.useDashboardStore(se=>se.selectedSheetId),{setDataSource:T}=p.useEditorActions(),{setSelectedFrameId:_,setIsDashboardEditing:E}=p.useDashboardActions(),D=cz(),{clearAssistantMessageContexts:M}=p.useAIActions(),{clearQueue:P}=p.useQueueActions(),{clearFileAttachments:A,getFileAttachments:L}=p.useFileActions(),O=p.useFileAttachments("dashboard"),B=p.useEditorStore(se=>se.card.dataSource),{assistantProfile:H}=Kbe(),R=p.useDashboardStore(se=>se.handleOpenAssistantProfile),{selectedEntities:V,applyDashboardDefaultEntities:z}=uT("dashboard"),{sendMessage:F,isLoading:G,messages:q,setMessages:Y,status:K,stop:$,errorMessage:X,clearError:W}=Kjt({dynamicVisualMode:f}),U=v.useCallback(()=>{w(se=>se+1)},[]),Z=v.useCallback(se=>{r==null||r(se),n===void 0&&b(se)},[n,r]),Q=v.useCallback(()=>{Z(!C)},[C,Z]);v.useEffect(()=>{if(!C)return;function se(he){he.key==="Escape"&&Z(!1)}return window.addEventListener("keydown",se),()=>{window.removeEventListener("keydown",se)}},[C,Z]);const[J,re]=v.useState(""),de=se=>{re(se.target.value)};async function le({sql:se,cardTitle:he,connectionId:ge,cardType:ke,python:De,cardConfig:Re,dataSource:Ve,customVisualPreferences:ve,visualizationMode:Ke,dynamicCardPreferences:qe}){if(!k)return;const et=Ke==="dynamic",ye=ut.hasValidCardConfig(Re),He=ge||(Ve==null?void 0:Ve.connectionId)||"",Pe=Ve?{...Ve,connectionId:He||Ve.connectionId,connectionType:Ve.connectionType||"",mode:Ve.mode||"database",selectedEntities:Ve.selectedEntities||[]}:He?{connectionId:He,connectionType:"",mode:"database",selectedEntities:[]}:mb,ze=!(ye&&(!et||(qe==null?void 0:qe.provenance)==="card-config"||(qe==null?void 0:qe.provenance)==="query_spec")),Ee=ze?zIt(se):"",Be=ze?De:"",st={id:ut.v4(),title:he||"Title",preferences:{onClickFilter:[{columnIndex:0,expression:""}],chartOptions:{indexAxis:ke==="horizontalBar"?"y":"x"},...et&&{displayOptions:{showChrome:!1,allowScroll:!1}}},type:ke,sql:Ee,python:Be,dataSource:Pe,config:Re,connectionId:He,visualizationMode:Ke,dynamicCardPreferences:qe,customCardPreferences:ve?{url:ve.url,componentName:ve.componentName,pluginChartType:ve.pluginChartType,settings:ve.settings,type:"component"}:void 0},lt={id:ut.v4(),cards:[st],activeCardId:st.id};try{await D(k,lt,"end"),E(!0),_(lt.id)}catch(rt){console.error("Failed to add assistant visual to dashboard:",rt),it.error(rt instanceof Error?rt.message:"Failed to prepare semantic metadata for the new visual")}}const ce=se=>{se.preventDefault();const he=J.trim();if(!he&&O.length===0)return;const ge=[];he&&ge.push({type:"text",text:he}),O.forEach(ke=>{ke.data&&ge.push({type:"file",mediaType:ke.type,filename:ke.name,url:`data:${ke.type};base64,${ke.data}`})}),F({role:"user",parts:ge}),re(""),A("dashboard"),U()};v.useEffect(()=>{var se;e&&((se=I.current)==null||se.focus())},[e]),uxe({assistantType:"dashboard",status:K,isLoading:G,sendMessage:F});const{hasActiveTools:oe,activeToolText:fe}=dxe(q);function we(se){const he={role:"user",parts:[{type:"text",text:se.title+" "+se.subtitle}]};F(he),U()}function pe(se){F({role:"user",parts:[{type:"text",text:se}]}),U()}function ne(se){F({role:"user",parts:[{type:"text",text:se}]}),U()}const Se=v.useCallback(async()=>{const se=JSON.stringify(q??[],null,2);try{if(typeof navigator>"u"||!navigator.clipboard)throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(se),it.success("Conversation copied")}catch(he){console.error("Failed to copy conversation",he),it.error("Unable to copy conversation")}},[q]),ue=(J==null?void 0:J.length)===0&&(q==null?void 0:q.filter(se=>se.role==="user").length)===0;function ie(){return l.jsx("div",{"data-role":"header",className:"flex items-center gap-2",children:l.jsx("span",{className:"text-[13px] font-medium text-foreground",children:"Assistant"})})}function ee(){return l.jsxs(Xo,{children:[l.jsx(Qo,{asChild:!0,children:l.jsx(au,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",children:l.jsx($m,{className:"size-3.5"})})}),l.jsxs(Fo,{align:"end",children:[l.jsx(Za,{children:"Options"}),l.jsx(Ta,{}),l.jsx(ad,{checked:s,onCheckedChange:i,children:"Token Usage"}),l.jsx(ad,{checked:a,onCheckedChange:c,children:"Tool Invocations"}),l.jsx(ad,{checked:u,onCheckedChange:d,children:"System Message"}),(N||S)&&l.jsxs(l.Fragment,{children:[l.jsx(Ta,{}),l.jsx(Za,{children:"Dynamic Visuals"}),l.jsx(ad,{checked:f==="auto",onCheckedChange:()=>h("auto"),children:"Auto"}),l.jsx(ad,{checked:f==="force",onCheckedChange:()=>h("force"),children:"Force Dynamic"}),l.jsx(ad,{checked:f==="off",onCheckedChange:()=>h("off"),children:"Disable Dynamic"})]})]})]})}const ae=l.jsxs("div",{"data-role":"dashboard-assistant",className:p.cn("relative flex h-full grow flex-col break-words bg-background",C&&"rounded-card border border-border/60 shadow-xl"),children:[l.jsxs("header",{"data-role":"header-section",className:"flex h-10 shrink-0 items-center gap-2 border-b border-border/60 px-3",children:[ie(),R&&l.jsxs("button",{type:"button",onClick:R,className:"inline-flex h-6 items-center gap-1 rounded-[4px] border border-border/60 bg-muted/40 px-1.5 text-[11px] text-muted-foreground transition-colors hover:border-border hover:text-foreground",title:"Edit assistant profile",children:[l.jsx("span",{className:"h-1 w-1 rounded-full bg-muted-foreground/60"}),l.jsx("span",{className:"max-w-[180px] truncate",children:(H==null?void 0:H.name)||"Default profile"})]}),l.jsxs("div",{"data-role":"header-actions",className:"ml-auto flex items-center gap-0.5",children:[S&&ee(),j&&l.jsx(p.Button,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-[11px] text-muted-foreground hover:text-foreground",onClick:Se,children:"Copy Conversation"}),l.jsx(au,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:C?"Exit fullscreen":"Expand",onClick:Q,children:C?l.jsx(Mt.Minimize2,{className:"h-3.5 w-3.5"}):l.jsx(Mt.Maximize2,{className:"h-3.5 w-3.5"})}),l.jsx(au,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:"New chat",onClick:()=>{const se=q.filter(he=>he.role==="assistant").map(he=>he.id).filter(he=>!!he);Y([]),P("dashboard"),W(),M(se)},children:l.jsx($O,{className:"h-3.5 w-3.5"})}),l.jsx(au,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:"Close",onClick:()=>{t(!1)},children:l.jsx(Ie.X,{className:"h-3.5 w-3.5"})})]})]}),l.jsx(Txe,{messages:q,showTools:a,showSystemMessage:u,onAddToDashboard:le,onQuickReply:ne,disableQuickReplies:G,status:K,errorMessage:X,activeToolText:G&&oe?fe:void 0,className:p.cn(C?"px-6 py-5":"px-3 py-3"),rowContentClassName:p.cn(C&&"mx-auto w-full max-w-[680px]"),latestButtonClassName:e?"bottom-[148px]":"hidden",scrollToEndSignal:y}),l.jsxs("div",{className:"shrink-0 space-y-2 border-t border-border/60 px-3 pb-3 pt-2",children:[!H&&ue&&l.jsx(Nge,{onClick:we,placeholders:BIt}),ue&&H&&l.jsx(Gbe,{seedQuestions:H.seedQuestions||[],handleSeedQuestionClick:pe}),l.jsx(cxe,{assistantType:"dashboard"}),l.jsx(eB,{ref:I,setInput:re,stop:$,input:J,handleInputChange:de,handleSubmit:se=>{ce(se)},isLoading:G,status:K,assistantType:"dashboard",onFocus:()=>{}})]}),l.jsx(J4,{incomingSelectedEntities:V,open:m,onOpenChange:g,dataSource:B||mb,dialogMode:"aiContext",saveAsDashboardDefault:!0,onSaveSelectedEntities:se=>z()})]});return C&&o?vr.createPortal(l.jsx(nx,{className:"pointer-events-auto absolute inset-0 z-50 flex bg-background/95 px-4 pb-4 pt-[calc(var(--app-header-height,15px)+0.5rem)] backdrop-blur-sm",children:l.jsx("div",{className:"flex h-full w-full",children:ae})}),o):ae}function HIt(e){const t=e.current,{getSelectedFrame:n,setSelectedFrameId:r}=p.useDashboardActions(),o=Jue(),s=p.useDashboardStore(d=>d.dashboard.sheets),a=p.useDashboardStore(d=>d.selectedSheetId)??(s==null?void 0:s[0].id),c=p.useDashboardStore(d=>d.isDashboardEditing),u=p.useDashboardStore(d=>d.isVisualEditing);v.useEffect(()=>{if(!c||u)return;async function d(m){if(qIt(m.target))return;const g=m.ctrlKey||m.metaKey;g&&m.key==="c"?(await f(),it.success("Card copied to clipboard"),m.preventDefault()):g&&m.key==="v"&&(await h(),m.preventDefault())}async function f(){try{const m=n();m&&await navigator.clipboard.writeText(JSON.stringify(m))}catch(m){console.error("Failed to copy text:",m)}}async function h(){if(!a)return null;try{const m=await navigator.clipboard.readText(),g=UIt(m);if(g!=null&&g.id){const x=Zue(g),b=x.cards.findIndex(y=>y.id===x.activeCardId);b!==-1&&(x.cards[b].title=`${x.cards[b].title} (Copy)`),await o(a,x),r(x.id),it.success("Card pasted from clipboard")}return m}catch(m){return console.error("Failed to paste text:",m),null}}return t==null||t.addEventListener("keydown",d),()=>t==null?void 0:t.removeEventListener("keydown",d)},[o,n,r,a,c,u,t])}function qIt(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.closest("[contenteditable]");return t&&t.getAttribute("contenteditable")!=="false"?!0:!!e.closest('input, textarea, select, [role="textbox"]')}function UIt(e){try{const t=JSON.parse(e);return t&&typeof t=="object"&&typeof t.id=="string"&&Array.isArray(t.cards)?t:null}catch{return null}}function WIt(e,t){switch(e.interactionMode){case"drillToDetail":KIt(e,t);break;case"drillThrough":GIt(e,t);break;case"drillToURL":YIt(e);break;case"inlineDrill":console.warn("Inline drill execution not yet implemented");break;case"clickFilter":case"drillDown":case"dynamicDrill":break;default:console.warn("Unknown interaction mode:",e.interactionMode)}}function KIt(e,t){var c;const{targetInsightId:n,contextMode:r,displayMode:o,filterGroups:s}=e;if(!n){console.warn("drillToDetail event missing targetInsightId");return}const i=r||"full";let a=[];switch(i){case"interactionFilters":a=s.flatMap(u=>u.filters);break;case"full":{const u=((c=t.getCurrentFilters)==null?void 0:c.call(t))||[],d=s.flatMap(f=>f.filters);a=[...u,...d];break}case"none":default:a=[];break}o==="replace-card"?t.replaceCardContent({cardId:e.sourceCardId,insightId:n,filters:a,contextMode:r}):t.openInsightModal({insightId:n,filters:a,contextMode:r})}function GIt(e,t){var u,d;const{targetDashboardId:n,contextMode:r="interactionFilters",filterGroups:o,sourceCardId:s}=e;if(!n){console.warn("[DrillThrough] Event missing targetDashboardId. This interaction needs to be reconfigured with a target dashboard.",e);return}const i=o.flatMap(f=>f.filters),a=((u=t.getCurrentDashboardId)==null?void 0:u.call(t))||"",c=(d=t.getCurrentDashboardTitle)==null?void 0:d.call(t);t.setGlobalDrillContext&&t.setGlobalDrillContext({filters:i,contextMode:r,sourceDashboardId:a,sourceDashboardTitle:c,targetDashboardId:n}),t.setPendingDrillThrough&&t.setPendingDrillThrough({targetDashboardId:n,sourceDashboardId:a,sourceDashboardTitle:c,filters:i,contextMode:r})}function YIt(e){const{url:t}=e;if(!t){console.warn("drillToURL event missing url");return}try{new URL(t)}catch(n){console.error("Invalid URL:",t,n);return}window.open(t,"_blank","noopener,noreferrer")}function ZIt({open:e,onOpenChange:t,insightId:n,filters:r,filterDefinitions:o,contextMode:s,cardTitle:i,cardDescription:a}){return l.jsx(So,{open:e,onOpenChange:t,children:l.jsxs(po,{className:"flex max-h-[90vh] max-w-[90vw] flex-col gap-0 overflow-hidden p-0",children:[l.jsxs(Ds,{className:"space-y-1 border-b border-border px-5 pb-3.5 pt-4 text-left",children:[l.jsx(go,{className:"text-[15px] font-semibold tracking-tight",children:i||"Insight detail"}),l.jsx(Oo,{className:"text-[12px] leading-[1.5] text-muted-foreground",children:a||"View detailed insight data with applied filters"})]}),l.jsx(ode,{filters:r,filterDefinitions:o,contextMode:s}),l.jsx("div",{className:"h-[400px] min-h-0 flex-1 overflow-auto px-5 py-4",children:n?l.jsx(mhe,{insightId:n,filters:r,contextMode:s}):l.jsx("div",{className:"flex items-center justify-center p-12 text-[13px] text-muted-foreground",children:"No insight selected"})})]})})}function XIt(){const e=p.useInteractionStore(N=>N.interactionStates),t=p.useInteractionStore(N=>N.setInteractionState),n=p.useInteractionStore(N=>N.clearLastInteractionEvent),r=p.useInteractionStore(N=>N.replaceCardWithInsight),o=p.useInteractionStore(N=>N.setPendingDrillThrough),s=p.useInteractionStore(N=>N.pendingDrillThrough),i=p.useInteractionStore(N=>N.clearPendingDrillThrough),{setSelectedSheetId:a,navigateWithDrill:c}=p.useDashboardActions(),{selectDashboard:u}=Om(),d=p.useDashboardStore(N=>N.dashboard),f=p.useDashboardStore(N=>N.filterValues),{data:h,isLoading:m}=lQ((s==null?void 0:s.targetDashboardId)||"",{enabled:!!(s!=null&&s.targetDashboardId)}),[g,x]=v.useState({open:!1,insightId:""}),b=phe(g.insightId,{enabled:g.open&&!!g.insightId}),y=v.useRef(new Set),w=v.useMemo(()=>({setSelectedSheetId:a,openInsightModal:({insightId:N,filters:S,contextMode:j})=>{x({open:!0,insightId:N,filters:S,filterDefinitions:(d==null?void 0:d.filters)||[],contextMode:j})},replaceCardContent:({cardId:N,insightId:S,filters:j,contextMode:I})=>{r(N,S,j,I)},getCurrentFilters:()=>f||[],navigateWithDrill:c,getCurrentDashboardId:()=>(d==null?void 0:d.id)||"",getCurrentDashboardTitle:()=>d==null?void 0:d.title,setPendingDrillThrough:o,setGlobalDrillContext:({filters:N,contextMode:S,sourceDashboardId:j,sourceDashboardTitle:I,targetDashboardId:k})=>{const T={filters:N},_={sourceCardId:p.DRILL_CONTEXT_CARD_ID,interactionMode:"clickFilter",filterGroups:[T]},E={...p.createInitialInteractionState(),appliedClickFilters:[_],contextMode:S,sourceDashboardId:j,sourceDashboardTitle:I,targetDashboardId:k};t(p.DRILL_CONTEXT_CARD_ID,E)}}),[a,r,f,c,d,o,t]);v.useEffect(()=>{Object.entries(e).forEach(([N,S])=>{if(S!=null&&S.lastInteractionEvent){const j=S.lastInteractionEvent,I=`${N}-${j.interactionMode}-${j.sourceCardId}-${Date.now()}`;if(y.current.has(I))return;y.current.add(I);try{WIt(j,w)}catch(k){console.error("Error executing interaction event:",k)}finally{n(N),setTimeout(()=>{y.current.delete(I)},5e3)}}})},[e,n,w]),v.useEffect(()=>{if(!(!s||!h||m))try{u(h),c(s.targetDashboardId,s.sourceDashboardId,s.sourceDashboardTitle,s.filters,s.contextMode),i()}catch(N){console.error("[DrillThrough] Error during automatic navigation:",N),i()}},[s,h,m,u,c,i]);const C=()=>{x({open:!1,insightId:""})};return l.jsxs(l.Fragment,{children:[l.jsx(ZIt,{open:g.open,onOpenChange:C,insightId:g.insightId,filters:g.filters,filterDefinitions:g.filterDefinitions,contextMode:g.contextMode,cardTitle:b.title,cardDescription:b.description}),s&&m&&l.jsx("div",{className:"fixed inset-0 z-[51] flex items-center justify-center bg-background/80 backdrop-blur-sm",children:l.jsxs("div",{className:"flex flex-col items-center gap-2.5 rounded-[6px] border border-border/60 bg-background px-4 py-3 shadow-sm",children:[l.jsx(p.LoaderCircle,{className:"h-5 w-5 animate-spin text-muted-foreground/60"}),l.jsx("div",{className:"text-[12px] text-muted-foreground",children:"Loading dashboard..."})]})})]})}function QIt(e){return e.length===0?"":e.map(t=>{const n=t.field.label||t.field.name,r=t.operator,o=JIt(dz(t));return r==="="?`${n} = ${o}`:`${n} ${r} ${o}`}).join(", ")}function JIt(e){return e==null?"null":Array.isArray(e)?e.join(", "):typeof e=="object"&&e.toString?e.toString():String(e)}function e_t(e){return e?`Back to ${e}`:"Back"}function t_t(){var y,w,C,N,S;const e=p.useInteractionStore(j=>j.interactionStates[p.DRILL_CONTEXT_CARD_ID]),t=p.useDashboardStore(j=>j.actions.goBackFromDrill),n=p.useDashboardStore(j=>j.actions.clearDrillContext),{selectDashboard:r}=Om(),[o,s]=v.useState({x:16,y:16}),[i,a]=v.useState(!1),c=v.useRef({x:0,y:0});v.useEffect(()=>{if(!i)return;const j=k=>{s({x:k.clientX-c.current.x,y:k.clientY-c.current.y})},I=()=>{a(!1)};return document.addEventListener("mousemove",j),document.addEventListener("mouseup",I),()=>{document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",I)}},[i]);const u=e==null?void 0:e.sourceDashboardId,d=e==null?void 0:e.sourceDashboardTitle,f=((N=(C=(w=(y=e==null?void 0:e.appliedClickFilters)==null?void 0:y[0])==null?void 0:w.filterGroups)==null?void 0:C[0])==null?void 0:N.filters)||[],h=u?{id:u,title:d||"Previous Dashboard",description:"",isPrivate:!1,isPublic:!1,version:"",createdBy:null,createdByTenantUser:"",tenantId:"",projectId:"",createdAt:"",updatedAt:"",lastModified:"",lastModifiedBy:"",createdByUser:null,createdByTenantUserRel:{name:"",email:""},permissions:{canEdit:!0,canShare:!0,canDelete:!0},ownership:{status:"private",isOwner:!0,sharedCount:0,createdBy:{type:"user",userId:"",name:"",email:""}}}:null;if(!e||!((S=e.appliedClickFilters)!=null&&S.length))return null;const m=()=>{if(!h){console.warn("[DrillBack] No source dashboard in context");return}try{t(),r(h)}catch(j){console.error("[DrillBack] Error during back navigation:",j)}},g=()=>{n()},x=j=>{j.target.closest("button")||(a(!0),c.current={x:j.clientX-o.x,y:j.clientY-o.y})};QIt(f);const b=e_t(d);return l.jsx("div",{className:"fixed z-50 max-w-md",style:{left:0,top:0,transform:`translate(${o.x}px, ${o.y}px)`,transition:i?"none":void 0},children:l.jsxs("div",{className:"select-none rounded-lg border bg-background/95 p-3 shadow-lg backdrop-blur-sm",onMouseDown:x,style:{cursor:i?"grabbing":"grab"},children:[l.jsxs("div",{className:"mb-3 flex items-start justify-between gap-2",children:[l.jsxs("div",{className:"flex flex-col gap-2",children:[l.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Viewing:"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:f.map((j,I)=>{const k=j.field.label||j.field.name,T=String(j.value);return l.jsxs(yi,{variant:"secondary",className:"pointer-events-none text-xs",children:[k," = ",T]},I)})})]}),l.jsx(p.Button,{variant:"ghost",size:"sm",onClick:g,className:"h-6 w-6 cursor-pointer p-0",title:"Clear drill context",children:l.jsx(Ie.X,{className:"h-3 w-3"})})]}),l.jsx("div",{className:"flex items-center gap-2 border-t pt-2",children:l.jsxs(p.Button,{variant:"secondary",size:"sm",onClick:m,disabled:!h,className:"w-full cursor-pointer",children:[l.jsx(Yv,{className:"mr-2 h-4 w-4"}),b]})})]})})}function n_t(e,t){return typeof e=="boolean"?e:typeof t=="boolean"?t:!1}function r_t({filter:e,isEditing:t=!1,disabled:n=!1,storageOptions:r,settingsVariant:o,filterQueryContext:s,inputVariableName:i,reservedInputVariableNames:a,isDashboardFilterReference:c,onUpdateFilter:u,onRemoveFilter:d}){const{attributes:f,listeners:h,setNodeRef:m,transform:g,transition:x,isDragging:b}=ux({id:`filter:${e.id}`,disabled:n||!t}),y={transform:Ji.Translate.toString(g),transition:x,opacity:b?.5:1,zIndex:b?10:void 0};return l.jsx("div",{ref:m,style:y,...f,children:l.jsx(q$,{filter:e,isEditing:t,dragListeners:t?h:void 0,storageOptions:r,settingsVariant:o,filterQueryContext:s,inputVariableName:i,reservedInputVariableNames:a,isDashboardFilterReference:c,onUpdateFilter:u,onRemoveFilter:d})})}const nY="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",o_t=[];function Exe({open:e,onOpenChange:t}){const[n,r]=v.useState(!1),[o,s]=v.useState(!1),[i,a]=v.useState({sheetSelection:"current",protectPdf:!1,password:""}),c=p.useDashboardStore(Y=>{var K;return(K=Y.dashboard)==null?void 0:K.sheets}),u=p.useDashboardStore(Y=>Y.dashboard),d=p.useDashboardStore(Y=>Y.dashboardInputValues),f=p.useDashboardStore(Y=>Y.filterValues),h=p.useDashboardStore(Y=>Y.controlValues),m=p.useDashboardStore(Y=>Y.inlineFilterValuesMap),g=p.useDashboardStore(Y=>Y.cardControlValuesMap),x=p.useDashboardStore(Y=>Y.selectedSheetId),b=p.useDashboardStore(Y=>Y.selectedSheetId?Y.documentInputRuntimeBySheetId[Y.selectedSheetId]:void 0),y=p.useDashboardStore(Y=>Y.isDownloadingPdf),w=p.useDashboardStore(Y=>Y.reportContext),{authToken:C,tokenProps:N}=It(),S=c==null?void 0:c.find(Y=>Y.id===x),j=v.useMemo(()=>p.getDashboardExportSheets(c),[c]),I=p.isDocumentSheet(S),k=I&&S?S.document:void 0,T=v.useMemo(()=>I&&S?fx(u,S.id):[],[S,I,u]),_=T.length>0,E=v.useMemo(()=>I&&S?Jpe(u,S.id):!1,[S,I,u]),D=v.useMemo(()=>_?T.map(pC):(k==null?void 0:k.inputs)||o_t,[k,T,_]),M=w==null?void 0:w.calendar.tz,P=v.useMemo(()=>Xme(D),[D]),A=v.useMemo(()=>Yme(D,M),[D,M]),L=v.useMemo(()=>Zme(D),[D]),O=b?b.filterValuesByInputId:A,B=b?b.controlValuesByInputId:L,H=v.useMemo(()=>I?E&&S&&k?fZ({dashboard:u,sheetId:S.id,sheetKind:"document",sectionIds:k.sections.map(Y=>Y.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:m,cardControlValuesMap:g},timezone:M}):epe(D,O,B,P,P):[],[k,D,S,I,u,g,h,f,m,d,B,O,P,M,E]),R=!!S,V=j.length>0,z=((c==null?void 0:c.length)||0)>1||I,F=i.sheetSelection==="current"&&(!R||I&&H.length>0)||i.sheetSelection==="all"&&!V;v.useEffect(()=>{e&&i.sheetSelection==="all"&&!V&&a(Y=>({...Y,sheetSelection:"current"}))},[V,e,i.sheetSelection]);const G=()=>{a({sheetSelection:"current",protectPdf:!1,password:""}),r(!1),t(!1)};async function q(){if(y){it.error("A PDF export is already in progress");return}if(i.protectPdf&&!i.password){it.error("Please enter a password to protect the PDF");return}if(i.sheetSelection==="current"&&!R){it.error("No sheet is selected to export");return}if(i.sheetSelection==="all"&&!V){it.error("No dashboard sheets are available to export");return}s(!0);const Y=i.sheetSelection==="current"&&I,K=Y?i.protectPdf?"Generating protected document PDF... may take up to 60 seconds":"Generating document PDF... may take up to 60 seconds":i.sheetSelection==="all"?"Generating PDF for all dashboard sheets... This may take a while.":i.protectPdf?"Generating protected PDF... may take up to 60 seconds":"Generating PDF... may take up to 60 seconds",$=it.loading(K);try{if(Y){if(!k||!S)throw new Error("Selected document sheet is missing document data");if(H.length>0){it.dismiss($),it.error(`Set ${H.join(", ")} before exporting`);return}const W=new Date().toISOString(),U=E?hZ({dashboard:u,sheetId:S.id,sheetKind:"document",sectionIds:k.sections.map(Z=>Z.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:m,cardControlValuesMap:g},generatedAt:W,timezone:M}).snapshot:void 0;await aL(N.apiServiceUrl,C,{sheetId:S.id,title:S.title||"Document",pageSize:k.page.size,orientation:k.page.orientation,timezone:M,password:i.protectPdf?i.password:void 0,inputSnapshot:U,...U?{}:{inputValues:{sheetId:S.id,filterValuesByInputId:O,controlValuesByInputId:B,generatedAt:W}}})}else{const W=xoe();await cte(N.apiServiceUrl,C,i.protectPdf?i.password:void 0,i.sheetSelection,W)}it.dismiss($);const X=Y?i.protectPdf?"Protected document PDF downloaded successfully!":"Document PDF downloaded successfully!":i.sheetSelection==="all"?"Dashboard sheets PDF downloaded successfully!":i.protectPdf?"Protected PDF downloaded successfully!":"PDF downloaded successfully!";it.success(X,{duration:2e3}),G()}catch(X){it.dismiss($),it.error("Failed to download PDF",{description:PI(X,"Please try again or contact support."),descriptionClassName:AI,closeButton:!0,duration:1/0,richColors:!0}),console.error("PDF download error:",X)}finally{s(!1)}}return l.jsx(So,{open:e,onOpenChange:Y=>{if(!Y){G();return}t(!0)},children:l.jsxs(po,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[l.jsxs(Ds,{children:[l.jsx(go,{className:"text-[15px]",children:I?"Export document":"Export dashboard"}),l.jsx(Oo,{className:"text-[13px] leading-5",children:I?"Export this document sheet as a PDF document.":"Export this dashboard as a PDF document."})]}),l.jsxs("div",{className:"space-y-4 py-1",children:[z&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(p.Label,{className:nY,children:"Export scope"}),l.jsxs(wu,{value:i.sheetSelection,onValueChange:Y=>a({...i,sheetSelection:Y}),className:"gap-1.5",children:[l.jsxs(p.Label,{htmlFor:"scope-current",className:p.cn("flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 text-[13px] font-normal hover:bg-muted/50",!R&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(Qs,{value:"current",id:"scope-current",disabled:!R}),I?"This document":"This sheet"," (",(S==null?void 0:S.title)||"Current",")"]}),l.jsxs(p.Label,{htmlFor:"scope-all",className:p.cn("flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 text-[13px] font-normal hover:bg-muted/50",!V&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(Qs,{value:"all",id:"scope-all",disabled:!V}),"Dashboard sheets (",j.length," ",j.length===1?"sheet":"sheets",")"]})]}),I&&l.jsx("p",{className:"text-[12px] leading-5 text-muted-foreground",children:H.length>0?`Set ${H.join(", ")} before exporting this document.`:'"Dashboard sheets" includes dashboard sheets only. Choose "This document" to export the selected document.'})]}),l.jsx(p.Separator,{className:"bg-border/60"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs(p.Label,{htmlFor:"protect-pdf",className:"flex cursor-pointer items-center gap-2 text-[13px] font-normal",children:[l.jsx(An,{id:"protect-pdf",checked:i.protectPdf,onCheckedChange:Y=>{a({...i,protectPdf:Y,password:Y?i.password:""}),Y||r(!1)}}),l.jsx(Xv,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Password protect PDF"]}),i.protectPdf&&l.jsxs("div",{className:"ml-6 space-y-1.5",children:[l.jsx(p.Label,{htmlFor:"pdf-password",className:nY,children:"Password"}),l.jsxs("div",{className:"relative",children:[l.jsx(p.Input,{id:"pdf-password",size:"xs",type:n?"text":"password",value:i.password,onChange:Y=>a({...i,password:Y.target.value}),placeholder:"Enter password",className:"pr-8",onKeyDown:Y=>{Y.key==="Enter"&&i.password&&q()}}),l.jsx("button",{type:"button",className:"absolute right-1 top-1/2 flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>r(!n),"aria-label":n?"Hide password":"Show password",children:n?l.jsx(Vk,{className:"h-3.5 w-3.5"}):l.jsx(Mt.Eye,{className:"h-3.5 w-3.5"})})]}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Recipients will need this password to open the PDF."})]})]})]}),l.jsxs(al,{children:[l.jsx(p.Button,{variant:"outline",size:"xs",onClick:G,disabled:o,children:"Cancel"}),l.jsx(p.Button,{size:"xs",onClick:q,disabled:o||y||F,children:o?l.jsxs(l.Fragment,{children:[l.jsx(p.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Exporting…"]}):l.jsxs(l.Fragment,{children:[l.jsx(Tu,{className:"h-3.5 w-3.5"}),"Export"]})})]})]})})}function Dxe({iconClassName:e,open:t,onOpenChange:n}){const[r,o]=v.useState(!1),s=t!==void 0,i=s?t:r,a=u=>{s||o(u),n==null||n(u)},c=p.useDashboardStore(u=>u.isDownloadingPdf);return l.jsxs(l.Fragment,{children:[s?null:l.jsx(p.Button,{variant:"ghost",size:"sm",className:"h-7 p-2",disabled:c,onClick:()=>a(!0),children:l.jsx(Tu,{className:p.cn("size-4",e)})}),l.jsx(Exe,{open:i,onOpenChange:a})]})}function rY(e,t,n){const r=new Set(t),o=[...n];return e.map(s=>r.has(s.id)?o.shift()??s.id:s.id)}function s_t({control:e,value:t,isEditing:n=!1,onChange:r}){const{attributes:o,listeners:s,setNodeRef:i,transform:a,transition:c,isDragging:u}=ux({id:`control:${e.id}`,disabled:!n}),d={transform:Ji.Translate.toString(a),transition:c,opacity:u?.5:1,zIndex:u?10:void 0};return l.jsx("div",{ref:i,style:d,...o,children:l.jsx(bpe,{control:e,value:t,isEditing:n,dragListeners:n?s:void 0,onChange:r})})}function oY(e){var t;return(((t=e.values)==null?void 0:t.length)??0)>0||e.operation==="is null"||e.operation==="is not null"}function sY(e,t){return[...e.map(n=>`filter:${n.id}`),...t.map(n=>`control:${n.id}`)]}function i_t(e,t,n){const r=new Set([...t.map(a=>`filter:${a.id}`),...n.map(a=>`control:${a.id}`)]);if(!(e!=null&&e.length))return sY(t,n);const o=e.filter(a=>r.has(a)),s=new Set(o),i=sY(t,n).filter(a=>!s.has(a));return[...o,...i]}function a_t(e,t){return p.getDashboardCardEntries({sheets:e.sheets||[]}).filter(n=>n.sheet.id===t).map(n=>n.card.id)}function l_t(e){return nm(e.dashboardInput,{sheetId:e.selectedSheetId,sheetKind:"dashboard"})?!0:e.dashboardInput.scope.kind!=="cards"?!1:e.selectedSheetCardIds.some(t=>nm(e.dashboardInput,{sheetId:e.selectedSheetId,cardId:t,sheetKind:"dashboard"}))}function U2(e){var t;return((t=e.compatibility)==null?void 0:t.source)!=="dashboardFilter"}function c_t(e){return Mxe(e).filter(t=>{var n,r;return t.filter.hide||t.filter.location==="frame"?!1:((n=t.compatibility)==null?void 0:n.source)==="dashboardFilter"?!0:(((r=t.presentation)==null?void 0:r.placement)||"toolbar")==="toolbar"})}function Mxe(e){if(!e.selectedSheetId)return[];const t=e.selectedSheetId,n=a_t(e.dashboard,t);return Bk(pb({dashboard:e.dashboard}).allInputs).filter(r=>!(r.kind!=="filter"||!l_t({dashboardInput:r,selectedSheetId:t,selectedSheetCardIds:n})))}function u_t(e,t){return"toolbar"}function d_t(){const e=ml("interactive"),t=p.useDashboardStore(W=>W.selectedSheetId),n=p.useDashboardStore(W=>W.dashboard.filters),r=p.useDashboardStore(W=>W.dashboard.filterLayout),o=p.useDashboardStore(W=>W.isDashboardEditing),s=p.useDashboardStore(W=>W.controlValues),i=p.useDashboardStore(W=>W.filterValues);p.useDashboardStore(W=>W.filteringCards);const a=p.useDashboardStore(W=>W.inlineFilterValuesMap),c=p.useDashboardStore(W=>W.dashboardInputValues),u=p.useInteractionStore(W=>W.clearAllClickFilters),d=p.useInteractionStore(W=>Object.entries(W.interactionStates).reduce((U,[Z,Q])=>{var J;return Z===p.DRILL_CONTEXT_CARD_ID?U:U+(((J=Q.appliedClickFilters)==null?void 0:J.length)??0)},0)),f=p.useDashboardStore(W=>W.actions.removeCardInlineFilterValue),{reorderFilters:h,clearDashboardInputSlot:m,reorderDashboardControls:g,removeDashboardInput:x,removeFilter:b,setControlValue:y,setFilterLayout:w,setFilterValues:C,setFilteringCards:N,updateFilterDashboardInputDefinition:S}=p.useDashboardActions(),j=mT(db(lx,{activationConstraint:{distance:5}})),I=p.useDashboardStore(W=>W.dashboard),k=c_t({dashboard:I,selectedSheetId:t}).filter(W=>u_t(W.filter)==="toolbar"),T=Mxe({dashboard:I,selectedSheetId:t}),_=k.map(W=>W.filter),E=new Map(k.map(W=>[`filter:${W.filter.id}`,W])),D=fnt(I),M=D.filter(W=>!W.hidden&&fv(W)==="toolbar"),P=D.filter(W=>!W.hidden&&fv(W)==="advanced"),A=i_t(r==null?void 0:r.toolbarItemOrder,_,M),L=new Map(_.map(W=>[`filter:${W.id}`,W])),O=new Map(M.map(W=>[`control:${W.id}`,W]));function B(W){const{active:U,over:Z}=W;if(!Z||U.id===Z.id)return;const Q=String(U.id),J=String(Z.id),re=A.findIndex(ne=>ne===Q),de=A.findIndex(ne=>ne===J);if(re===-1||de===-1)return;const le=cx(A,re,de);w({toolbarItemOrder:le});const ce=new Set((n||[]).map(ne=>ne.id)),oe=A.filter(ne=>ne.startsWith("filter:")).map(ne=>ne.replace("filter:","")).filter(ne=>ce.has(ne)),fe=le.filter(ne=>ne.startsWith("filter:")).map(ne=>ne.replace("filter:","")).filter(ne=>ce.has(ne)),we=A.filter(ne=>ne.startsWith("control:")).map(ne=>ne.replace("control:","")),pe=le.filter(ne=>ne.startsWith("control:")).map(ne=>ne.replace("control:",""));h(rY(n||[],oe,fe)),g(rY(I.controls||[],we,pe))}const H=(r==null?void 0:r.toolbarWrap)??!1,R=(r==null?void 0:r.showDownloadButton)??!1,V=T.filter(U2),z=T.filter(W=>{if(U2(W))return!1;const U=p.getDashboardInputRuntimeSlot(c,W,{sheetId:t});return(U==null?void 0:U.status)==="set"||(U==null?void 0:U.status)==="cleared"}),F=new Set([...V,...z].map(W=>W.filter.id)),G=(i==null?void 0:i.filter(W=>!F.has(W.filterId)&&oY(W)).length)??0,q=[...V,...z],Y=q.filter(W=>{const U=p.hydrateAuthoredDashboardInputSlot({dashboard:I,input:W,runtimeValues:c,target:{sheetId:t}});return(U==null?void 0:U.status)==="set"&&U.value.kind==="filter"&&oY(U.value.filterValue)}).length,K=a?Object.values(a).reduce((W,U)=>W+((U==null?void 0:U.length)??0),0):0,$=G+Y+K+d,X=()=>{C([]),q.forEach(W=>{m(W,{sheetId:t})}),N([]),u(),a&&Object.entries(a).forEach(([W,U])=>{U==null||U.forEach(Z=>{f(W,Z.filterId)})})};return!_.length&&!M.length&&!P.length&&!R&&$===0?null:l.jsx("div",{className:"z-20 border-b border-border/60 bg-background/95 px-3 py-2 backdrop-blur supports-[backdrop-filter]:bg-background/85",style:e.containerStyle,role:"toolbar","aria-label":"Dashboard filters and controls",children:l.jsx(cC,{sensors:j,collisionDetection:iC,onDragEnd:B,children:l.jsxs("div",{className:p.cn("flex items-center",H?"flex-wrap":"w-0 min-w-full overflow-x-auto"),children:[l.jsx(uC,{items:A,strategy:Gz,children:l.jsx(HF,{className:"gap-3 pr-0",wrap:H,children:A.map(W=>{const U=L.get(W);if(U){const Q=E.get(W),J=Q&&U2(Q),re=J&&Q.definitionOrigin==="dashboardFilter";return l.jsx(r_t,{filter:U,isEditing:o,storageOptions:J?{storageTarget:"dashboardInput",dashboardInput:Q,sheetId:t??void 0}:void 0,inputVariableName:J?Q.variableName:void 0,isDashboardFilterReference:re,onUpdateFilter:J?(de,le)=>{S(Q.id,de,le)}:void 0,onRemoveFilter:J?()=>{if(Q.definitionOrigin==="dashboardFilter"){b(U.id);return}C((i||[]).filter(de=>de.filterId!==U.id)),x(Q.id)}:void 0},W)}const Z=O.get(W);return Z?l.jsx(s_t,{control:Z,value:s==null?void 0:s[Z.id],isEditing:o,onChange:Q=>y(Z.id,Q)},W):null})})}),P.length>0&&l.jsx(fde,{title:"",controls:P,values:s,onChange:(W,U)=>y(W.id,U),immediatePlacement:"toolbar",advancedLabel:"More controls"}),$>0&&l.jsxs("button",{type:"button",onClick:X,"aria-label":"Clear all filters",className:"ml-auto inline-flex h-7 shrink-0 items-center gap-1 rounded-control px-2 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:[l.jsx(Ie.X,{className:"h-3 w-3"}),"Clear all",l.jsx("span",{className:"rounded-[3px] bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:$})]}),R&&l.jsx("div",{className:p.cn($>0?"ml-1.5":"ml-auto"),children:l.jsx(Dxe,{})})]})})})}function Rxe(){var ne,Se;const{showAssistant:e,tokenProps:t,renderMode:n}=It(),r=n_t((ne=t.config)==null?void 0:ne.showDashboardAssistant,e),{preferences:o}=Hm(),s=(Se=o==null?void 0:o.cardDisplay)==null?void 0:Se.mode,i=xf(s),a=xee({displayMode:s,renderMode:n}),c=v.useRef(null),u=v.useRef(null),[d,f]=v.useState(!1),{handleDragStart:h,isDraggingRef:m,getStyle:g,getPositionClasses:x}=Pvt({initialPosition:"bottom-right"}),b=Fh(ue=>ue.setFullscreen),y=Fh(ue=>ue.setPanelOpen),w=Fh(ue=>ue.setContainer),C=dJ("dashboard"),N=fJ(),S=hJ("dashboard"),j=C.isOpen,I=N==="dashboard",k=p.useDashboardStore(ue=>ue.isVisualEditing),T=p.useDashboardStore(ue=>ue.themeStyle),_=$u(),E=p.useDashboardStore(ue=>{var ie;return(ie=ue.dashboard)==null?void 0:ie.sheets}),D=p.useDashboardStore(ue=>ue.showFilters),M=p.useDashboardStore(ue=>ue.isDashboardEditing),P=p.useDashboardStore(ue=>ue.selectedSheetId),A=E==null?void 0:E.find(ue=>ue.id===P),L=p.useDashboardStore(ue=>{var ie,ee,ae;return(ae=(ee=(ie=ue.dashboard)==null?void 0:ie.sheets)==null?void 0:ee.find(se=>se.id===ue.selectedSheetId))==null?void 0:ae.kind}),O=p.useDashboardStore(ue=>{var ie,ee;return((ee=(ie=ue.dashboard)==null?void 0:ie.summary)==null?void 0:ee.position)||"top"}),B=L==="document",H=p.useDashboardStore(ue=>{var ie;return(ie=ue.dashboard)==null?void 0:ie.id}),{getDefaultSheetId:R,setDefaultSheetId:V,clearDefaultSheetId:z}=WY(H),[F,G]=v.useState(null),{setSelectedSheetId:q,setSheetTitle:Y,addSheet:K,setSheets:$}=p.useDashboardActions();HIt(u);const{setActiveAssistantType:X}=p.useAIActions();v.useEffect(()=>{if(H){const ue=R();G(ue)}},[H,R]),v.useEffect(()=>{j?X("dashboard"):N==="dashboard"&&b(null)},[j,X,N,b]),v.useEffect(()=>{var ue;j||(ue=c.current)==null||ue.resize(0)},[j]);function W(ue){var ie,ee;ue?((ie=c.current)==null||ie.resize(40),y("dashboard",!0),b("dashboard"),X("dashboard")):(y("dashboard",!1),b(null),(ee=c.current)==null||ee.resize(0),X(null))}function U(ue="dashboard"){const ie={id:ut.v4(),title:ue==="document"?"New Document":"New Sheet",...ue==="document"?{kind:ue,document:p.createDefaultDocumentDefinition()}:{}};K(ie),q(ie.id)}function Z(ue,ie){if(!H)return;F===ue?(z(),G(null),it.success("Default sheet cleared")):(V(ue),G(ue),it.success(`"${ie}" set as default sheet`))}function Q(ue){var ie;ue<1?(y("dashboard",!1),b(null),X(null),(ie=c.current)==null||ie.resize(0)):(j||y("dashboard",!0),X("dashboard"))}function J(){return(T==null?void 0:T.canvasTheme)==="muted"||!(T!=null&&T.canvasTheme)?"hsl(var(--semaphor-muted))":(T==null?void 0:T.canvasTheme)==="clear"?"":T==null?void 0:T.canvasTheme}const re=(ue,ie)=>{ue.dataTransfer.setData("tabIndex",ie.toString())},de=ue=>{ue.preventDefault()},le=(ue,ie)=>{const ee=ue.dataTransfer.getData("tabIndex");if(ee===ie.toString())return;const ae=Array.from(E||[]),[se]=ae.splice(parseInt(ee),1);ae.splice(ie,0,se),$(ae)},ce=r===!0&&!i&&!j&&!k&&!D;function oe(){if(E&&E.length>1||M)return l.jsx("div",{className:"relative flex w-full items-stretch border-b border-border",children:l.jsxs("div",{className:"relative min-w-0 flex-1",children:[l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-10 w-4 bg-gradient-to-r from-background to-transparent"}),l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 right-0 z-10 w-4 bg-gradient-to-l from-background to-transparent"}),l.jsxs(p.TabsList,{role:"tab-list",className:"flex w-0 min-w-full items-stretch justify-start overflow-x-auto rounded-none bg-transparent p-0 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[E==null?void 0:E.map((ue,ie)=>{const ee=P===ue.id,ae=F===ue.id;return l.jsxs(p.TabsTrigger,{draggable:!0,onDragStart:se=>re(se,ie),onDragOver:de,onDrop:se=>le(se,ie),onClick:()=>q(ue.id),className:p.cn("group relative inline-flex h-9 shrink-0 items-center gap-1.5 rounded-none bg-transparent px-3 py-0 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-transparent hover:text-foreground data-[state=active]:bg-transparent data-[state=active]:text-foreground data-[state=active]:shadow-none","after:pointer-events-none after:absolute after:inset-x-2 after:-bottom-px after:h-0.5 after:bg-transparent data-[state=active]:after:bg-foreground"),value:ue.id,children:[ue.kind==="document"&&l.jsx(ti,{className:"h-3 w-3 text-muted-foreground"}),l.jsx(Uj,{enabled:M&&ee,text:ue.title,onSave:se=>Y(ue.id,se),children:ue.title},ue.id),l.jsx("span",{role:"button",tabIndex:0,"aria-label":ae?"Clear default sheet":"Set as default sheet",title:ae?"Clear default sheet":"Set as default sheet",onClick:se=>{se.stopPropagation(),Z(ue.id,ue.title||"Sheet")},onKeyDown:se=>{(se.key==="Enter"||se.key===" ")&&(se.preventDefault(),se.stopPropagation(),Z(ue.id,ue.title||"Sheet"))},className:p.cn("inline-flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-[3px] transition-opacity hover:bg-muted focus:outline-none focus-visible:ring-1 focus-visible:ring-foreground",ee||ae?"opacity-100":"opacity-0 group-hover:opacity-100"),children:l.jsx(JZ,{className:p.cn("h-3 w-3 transition-colors",ae?"fill-current text-amber-500":"text-muted-foreground")})}),M&&ee&&E.length>1&&l.jsx("span",{role:"button",tabIndex:0,"aria-label":"Delete sheet",className:"inline-flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-[3px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-foreground",onClick:se=>{se.stopPropagation(),f(!0)},onKeyDown:se=>{(se.key==="Enter"||se.key===" ")&&(se.preventDefault(),se.stopPropagation(),f(!0))},children:l.jsx(Ie.X,{className:"h-3 w-3"})})]},ue.id)}),M&&l.jsxs(Xo,{children:[l.jsx(Qo,{asChild:!0,children:l.jsxs("button",{type:"button","aria-label":"Add sheet",className:"ml-1 inline-flex h-9 shrink-0 items-center gap-1 px-3 text-[12px] font-medium text-muted-foreground transition-colors hover:text-foreground",children:[l.jsx(Mr,{className:"h-3 w-3"}),"Sheet"]})}),l.jsxs(Fo,{align:"start",className:"w-48",children:[l.jsxs(In,{onSelect:()=>U("dashboard"),children:[l.jsx(om,{className:"h-4 w-4 text-muted-foreground"}),"Dashboard sheet"]}),l.jsxs(In,{onSelect:()=>U("document"),children:[l.jsx(ti,{className:"h-4 w-4 text-muted-foreground"}),"Document"]})]})]})]})]})})}function fe(){return l.jsx("div",{ref:u,style:{},className:"h-full min-h-0 grow",children:E==null?void 0:E.map(ue=>l.jsx(p.TabsContent,{style:{backgroundColor:J(),..._.dashboardCanvasStyle},className:p.cn("mt-0 h-full min-h-0",{}),value:ue.id,children:l.jsx(QK,{sheet:ue})},ue.id))})}function we(){return l.jsxs(p.Tabs,{"data-role":"dashboard-tabs-container",className:p.cn("relative flex h-full flex-col",T==null?void 0:T.dashboardTabsContainer),onValueChange:ue=>{q(ue)},value:P||void 0,children:[oe(),O==="top"&&!B&&l.jsx(oF,{}),P&&!B&&l.jsx(d_t,{}),B?l.jsx("div",{"data-role":"dashboard-tabs-content",className:"min-h-0 flex-1 grow basis-0 overflow-hidden",children:fe()}):l.jsx(yl,{"data-role":"dashboard-tabs-content",className:"flex-1 grow basis-0 overflow-y-auto",children:fe()}),O==="bottom"&&!B&&l.jsx(oF,{}),l.jsx(Fvt,{open:d,setOpen:f})]})}const pe=v.useCallback(ue=>{w("dashboard",ue)},[w]);return E?a&&P&&!B?l.jsxs("div",{"data-document-render-error":"true",className:"bg-white p-8 text-sm text-zinc-700",children:['Requested document sheet "',P,'" was not found or is not a document sheet in the loaded dashboard.']}):a&&B&&A?l.jsx("div",{"data-role":"dashboard-document-print-content",className:"min-h-0 overflow-visible bg-white",children:l.jsx(QK,{sheet:A})}):l.jsxs(l.Fragment,{children:[l.jsx(XIt,{}),l.jsx(t_t,{}),l.jsxs("div",{className:"relative flex-1 basis-0 overflow-hidden",children:[l.jsxs(Sge,{className:p.cn("flex-1 basis-0 overflow-y-auto transition-opacity",I&&"pointer-events-none opacity-0"),direction:"horizontal",children:[l.jsx(GF,{children:we()}),r===!0&&l.jsxs(l.Fragment,{children:[l.jsx(Avt,{open:j,onTabClick:W,withHandle:!0,disabled:!j}),l.jsx(GF,{className:"flex grow","data-role":"dashboard-assistant-panel",onResize:Q,defaultSize:j?40:0,ref:c,children:l.jsx("div",{className:"grow overflow-y-auto",children:l.jsx(VIt,{open:j,setOpen:W,isFullscreen:I,onFullscreenChange:ue=>b(ue?"dashboard":null),fullscreenContainer:S})})})]})]}),l.jsx("div",{ref:pe,className:p.cn("absolute inset-0",!I&&"pointer-events-none")}),ce&&l.jsx("div",{className:p.cn("absolute z-50 transition-all duration-300 ease-in-out",x().horizontal,x().vertical),style:g(),children:l.jsx(p.Button,{size:"sm",variant:"outline",className:"h-12 w-12 cursor-grab rounded-full border-border bg-background p-0 shadow-lg hover:bg-muted active:cursor-grabbing",onClick:()=>{m.current||W(!0)},onMouseDown:h,onTouchStart:h,title:"Open Assistant (drag to move)",children:l.jsx(Xve,{className:"h-5 w-5"})})})]})]}):null}const Axe=v.forwardRef(({appearance:e,organizationAppearance:t,tokenAppearance:n,reactAppearance:r,resolvedAppearance:o,systemMode:s,children:i,className:a,style:c,...u},d)=>l.jsx(ag.InternalAppearanceRuntimeProvider,{appearance:e,organizationAppearance:t,tokenAppearance:n,reactAppearance:r,resolvedAppearance:o,systemMode:s,children:l.jsx(nx,{...u,ref:d,className:a,style:c,children:i})}));Axe.displayName="AppearanceProvider";const Pxe=v.createContext({openBrandStudioPreview:()=>{}}),f_t=Pxe.Provider;function h_t(){return v.useContext(Pxe)}function m_t({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const o=ag.normalizeTheme(t),[s,i]=v.useState(()=>p_t(n)||o),a=v.useCallback(u=>{const d=ag.normalizeTheme(u);g_t(n,d),i(d)},[n]),c=v.useMemo(()=>({theme:s,setTheme:a}),[s,a]);return l.jsx(ag.ThemeProviderContext.Provider,{...r,value:c,children:e})}function p_t(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const n=ag.normalizeTheme(t,"system");return n===t?n:null}catch{return null}}function g_t(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}const b_t=v.lazy(()=>Promise.resolve().then(()=>require("../brand-studio/index.cjs")).then(e=>({default:e.BrandStudioEditor})));function rB({appearance:e,children:t}){var E,D;const{authToken:n,id:r,tokenProps:o}=It(),s=Uv(),i=(E=s.data)==null?void 0:E.organizationAppearance,a=(D=o.config)==null?void 0:D.appearance,[c,u]=v.useState(!1),[d,f]=v.useState(null),[h,m]=v.useState(null),[g,x]=v.useState(null),[b,y]=v.useState(null),w=`${o.apiServiceUrl??""}:${(n==null?void 0:n.accessToken)??""}`,C=qn({queryKey:rQ({resourceType:mo.DASHBOARD,apiServiceUrl:o.apiServiceUrl,accessToken:n==null?void 0:n.accessToken}),queryFn:async()=>p.getRequest(`${o.apiServiceUrl}/management/v1/dashboards`,(n==null?void 0:n.accessToken)||""),select:M=>(M==null?void 0:M.organizationAppearance)??null,enabled:!s.dashboardIdToFetch&&i===void 0&&!!(n!=null&&n.accessToken)});v.useEffect(()=>{i!==void 0&&y({scopeKey:w,appearance:i})},[i,w]),v.useEffect(()=>{C.data!==void 0&&y({scopeKey:w,appearance:C.data})},[C.data,w]);const N=(b==null?void 0:b.scopeKey)===w?b.appearance:null,S=i!==void 0?i:C.data!==void 0?C.data:N,j=v.useMemo(()=>Am.resolveAppearance({organizationAppearance:S,tokenAppearance:a,reactAppearance:e}),[e,S,a]),I=v.useCallback(()=>{f(g??h??j),u(!0)},[g,h,j]),k=v.useCallback(()=>{u(!1)},[]);v.useEffect(()=>{f(null),m(null),x(null),u(!1)},[r]);const T=v.useMemo(()=>({openBrandStudioPreview:I}),[I]),_=g??h??e;return l.jsx(m_t,{defaultTheme:"system",storageKey:"vite-ui-theme",children:l.jsx(f_t,{value:T,children:l.jsx(Axe,{organizationAppearance:S,tokenAppearance:a,reactAppearance:_,style:{height:"100%",width:"100%"},children:l.jsxs(p.TooltipProvider,{delayDuration:0,children:[t,c&&l.jsx("aside",{"aria-label":"Brand Studio","aria-modal":"false",role:"dialog",className:"fixed bottom-0 right-0 top-0 z-50 flex w-[min(520px,100vw)] flex-col border-l border-border bg-background text-foreground shadow-sm",children:l.jsx(v.Suspense,{fallback:l.jsx("div",{className:"flex h-full items-center justify-center text-[12px] text-muted-foreground",children:"Loading Brand Studio..."}),children:l.jsx(b_t,{appearance:d,onDraftChange:x,onSave:M=>{m(M),x(M),f(M)},onCancel:k})})})]})})})})}function Fxe({children:e,preferences:t}){const{currentUser:n}=si(),r=v.useMemo(()=>{var o,s;return{preferences:t||{},isLocalDev:((o=t==null?void 0:t.uiMode)==null?void 0:o.developer)||!1,isConsoleMode:((s=t==null?void 0:t.uiMode)==null?void 0:s.console)||!1}},[t]);return l.jsx(eQ.Provider,{value:r,children:l.jsx(J_,{displayPreferences:t==null?void 0:t.cardDisplay,currentUser:n,children:e})})}function x_t(e=2e3,t=500){const n=N0e(),[r,o]=v.useState(!1),[s,i]=v.useState(!1),a=v.useRef(null);return v.useEffect(()=>{const c=setTimeout(()=>o(!0),e);return()=>clearTimeout(c)},[e]),v.useEffect(()=>{if(r){if(n>0){i(!1),a.current&&(clearTimeout(a.current),a.current=null);return}return a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{i(!0)},t),()=>{a.current&&clearTimeout(a.current)}}},[r,n,t]),s}function oB({delayMs:e=2e3,quietMs:t=500,componentType:n,componentId:r}){const o=x_t(e,t);return v.useEffect(()=>(o&&(window.__SEMAPHOR_READY__={ready:!0,type:n,componentId:r||null,timestamp:Date.now()}),()=>{window.__SEMAPHOR_READY__={ready:!1,type:n,componentId:r||null,timestamp:Date.now()}}),[o,n,r]),l.jsx("div",{id:"idle-check","aria-hidden":"true",style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0},children:o?"ready":""})}function Oxe(e){if(typeof window>"u")return null;const{preferences:t}=e;return l.jsx(_i,{FallbackComponent:X_,children:l.jsx(vO,{dashboardProps:e,children:l.jsxs(cT,{children:[l.jsx(oB,{componentType:"dashboard",componentId:e.id}),l.jsx(rB,{appearance:e.appearance,children:l.jsx(Fxe,{preferences:t,children:l.jsx("main",{className:"flex h-full flex-col",children:l.jsx(a5,{...e,type:"dashboard",children:l.jsx(Rxe,{})})})})})]})})})}function y_t(e=[]){const t=v.useRef(null),n=v.useRef(null),r=v.useRef(null),[o,s]=v.useState(),i=v.useCallback(()=>{var m,g,x;const a=((m=t.current)==null?void 0:m.clientWidth)??0,c=((g=r.current)==null?void 0:g.offsetWidth)??0,u=((x=n.current)==null?void 0:x.offsetWidth)??0,f=a-c-u-8,h=Math.max(f,0);s(b=>b===h?b:h)},[]);return v.useEffect(()=>{const a=t.current;if(!a||typeof ResizeObserver>"u")return;const c=new ResizeObserver(()=>i());return c.observe(a),i(),()=>c.disconnect()},[i,...e]),{headerRef:t,leftActionsRef:n,rightActionsRef:r,titleMaxWidth:o,updateAvailableWidth:i}}function v_t({filter:e}){var g;const t=p.useDashboardStore(x=>x.isDashboardEditing),{preferences:n}=Hm(),r=xf((g=n==null?void 0:n.cardDisplay)==null?void 0:g.mode),o=p.useDashboardStore(x=>x.filterValues),s=o==null?void 0:o.some(x=>x.filterId===e.id),{removeFilterValues:i,removeFilter:a,updateFilter:c}=p.useDashboardActions(),{headerRef:u,leftActionsRef:d,rightActionsRef:f,titleMaxWidth:h,updateAvailableWidth:m}=y_t([t,s,r]);return v.useEffect(()=>{m()},[e.title,m]),l.jsxs("div",{ref:u,className:"group mb-1 flex h-5 items-center justify-between",children:[l.jsxs("div",{className:"flex grow items-center gap-2 min-w-0",children:[l.jsx("div",{className:"min-w-0 flex-1",style:h!==void 0?{maxWidth:h}:void 0,children:l.jsx(p.Label,{className:"my-1 block w-full text-sm",children:l.jsx(Si,{value:e.title||e.column,onSave:x=>c({...e,title:x}),isEditable:t,placeholder:"Filter",displayClassName:"text-sm truncate",inputClassName:"text-sm"})})}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",ref:d,children:[t&&l.jsx(H$,{filter:e,isEditing:t}),t&&l.jsx("button",{onClick:()=>{i(e.id),a(e.id)},className:"text-muted-foreground hover:text-foreground",children:l.jsx(Ie.X,{className:"size-3.5"})})]})]}),l.jsx("div",{className:"hidden",ref:f})]})}function w_t(){const e=p.useDashboardStore(r=>r.dashboard.filters),t=p.useDashboardStore(r=>r.theme),n=e==null?void 0:e.filter(r=>r.hide);return n!=null&&n.length?l.jsx("div",{className:p.cn("mb-1 flex items-center gap-2 border-y px-0.5 pb-0.5",{"bg-[repeating-linear-gradient(45deg,_#ffffff_0_3px,_#f3f3f3_3px_6px)]":t==="light","bg-[repeating-linear-gradient(45deg,_#18171d_0_3px,_#272729_3px_6px)]":t==="dark"}),children:n==null?void 0:n.map(r=>l.jsxs("div",{className:"flex min-w-[250px] max-w-fit flex-col gap-1 p-2",children:[l.jsx(v_t,{filter:r}),l.jsx(W_,{filter:r})]},r.id))}):null}function C_t(){var s;const e=p.useDashboardStore(i=>i.dashboard),t=p.useDashboardStore(i=>i.selectedSheetId),n=p.useDashboardStore(i=>i.isDashboardEditing),r=(s=e.sheets)==null?void 0:s.find(i=>i.id===t),o=p.isDocumentSheet(r);return l.jsx("div",{role:"dashboard-plus-main",className:"flex min-h-0 grow basis-0 overflow-hidden",children:l.jsxs("section",{className:"flex min-h-0 grow basis-0 flex-col overflow-hidden",children:[n&&!o&&l.jsx(w_t,{}),l.jsx(Rxe,{})]})})}const S_t=v.lazy(()=>Promise.resolve().then(()=>require("./dashboard-controls-Dk_4fD9Y.cjs"))),N_t=v.lazy(()=>Promise.resolve().then(()=>require("./edit-dashboard-visual-BNNbxMoA.cjs"))),j_t=v.lazy(()=>Promise.resolve().then(()=>require("./dashboard-json-6vY_UIQ9.cjs")));function k_t({showControls:e=!1,showFooter:t=!0,...n}){const r=p.useDashboardStore(a=>a.isVisualEditing),o=p.useDashboardStore(a=>a.showDashboardJSON),{appearance:s,preferences:i}=n;return l.jsx(_i,{FallbackComponent:X_,children:l.jsx(vO,{dashboardProps:n,children:l.jsxs(cT,{children:[l.jsx(oB,{componentType:"surfboard",componentId:n.id}),l.jsxs(rB,{appearance:s,children:[l.jsx(rSe,{toastOptions:{classNames:{toast:"max-w-[calc(100vw-2rem)] overflow-x-hidden !items-start [--toast-close-button-end:0.5rem] [--toast-close-button-start:auto] [--toast-close-button-transform:translate(0,0)] sm:max-w-[44rem]",content:"min-w-0 flex-1",icon:"mt-0.5 shrink-0",title:"max-w-full break-words pr-8",description:"max-w-full break-words",closeButton:"!top-2 h-6 w-6 rounded-md border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground"}}}),l.jsxs(Fxe,{preferences:i,children:[o&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(j_t,{})}),l.jsxs("main",{className:"relative flex h-full w-full flex-col overflow-hidden",children:[e&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(S_t,{})}),l.jsx("div",{className:"flex grow overflow-hidden",children:l.jsx("div",{className:"flex min-w-0 flex-1",children:l.jsxs(a5,{...n,type:"dashboard",children:[r&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(N_t,{})}),l.jsx(v.Activity,{mode:r?"hidden":"visible",children:l.jsx(C_t,{})})]})})})]})]})]})]})})})}const lO=[{value:"en-US",label:"English (United States)"},{value:"en-GB",label:"English (United Kingdom)"},{value:"de-DE",label:"German (Germany)"},{value:"fr-FR",label:"French (France)"},{value:"es-ES",label:"Spanish (Spain)"},{value:"it-IT",label:"Italian (Italy)"},{value:"nl-NL",label:"Dutch (Netherlands)"},{value:"pt-BR",label:"Portuguese (Brazil)"},{value:"ja-JP",label:"Japanese (Japan)"},{value:"en-IN",label:"English (India)"},{value:"en-NZ",label:"English (New Zealand)"},{value:"mi-NZ",label:"Māori (New Zealand)"}],Lxe=new Set(["USD","EUR","GBP","CAD","AUD","JPY","CHF","INR","BRL","KWD"]),I_t=qi.getSupportedCurrencyCodes(),__t=I_t.filter(e=>!Lxe.has(e)),$xe=[{value:"short",label:"Short"},{value:"medium",label:"Medium"},{value:"long",label:"Long"}],iY="2026-07-31",W2="2026-07-31T14:30:45";function cO(e){switch(e){case"viewer_user":return"user";case"viewer_tenant_user":return"tenant user";case"viewer_tenant":return"tenant";case"viewer_organization":return"organization";case"session_initial":return"embedded session";case"system_default":return"system";default:return"another preference level"}}function K2(e){var t;return((t=$xe.find(n=>n.value===e))==null?void 0:t.label)??e}function T_t(e){const t=lO.find(n=>n.value===e);return t?`${t.label} — ${t.value}`:e}function G2(e){return{short:e("short"),medium:e("medium"),long:e("long")}}function Y2({id:e,label:t,value:n,inherited:r,inheritedSource:o,examples:s,disabled:i,onValueChange:a}){const c=n===void 0?`Inherited · ${K2(r)}`:K2(n);return l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(p.Label,{htmlFor:e,className:"text-[11px] text-muted-foreground",children:t}),l.jsxs(p.Select,{value:n??"inherit",disabled:i,onValueChange:a,children:[l.jsx(p.SelectTrigger,{id:e,size:"xs",children:l.jsx(p.SelectValue,{children:c})}),l.jsxs(p.SelectContent,{children:[l.jsx(p.SelectItem,{value:"inherit",className:"[&>span:last-child]:w-full",children:l.jsxs("span",{className:"flex w-full min-w-0 items-center justify-between gap-4",children:[l.jsxs("span",{children:["Inherited from ",cO(o)," ·"," ",K2(r)]}),l.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:s[r]})]})}),$xe.map(u=>l.jsx(p.SelectItem,{value:u.value,className:"[&>span:last-child]:w-full",children:l.jsxs("span",{className:"flex w-full min-w-0 items-center justify-between gap-4",children:[l.jsx("span",{children:u.label}),l.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:s[u.value]})]})},u.value))]})]})]})}function E_t({value:e,inherited:t,inheritedSources:n,onChange:r,disabled:o}){var j,I,k,T;const s=v.useId(),i=v.useId(),a=v.useId(),c=v.useId(),u=v.useId(),f=(e.locale===void 0?void 0:qi.canonicalizeSupportedLocale(e.locale))??t.locale,h=e.defaultCurrency??t.defaultCurrency,m={locale:f,dateStyle:e.dateStyle??t.dateStyle,dateTime:{dateStyle:((j=e.dateTime)==null?void 0:j.dateStyle)??t.dateTime.dateStyle,timeStyle:((I=e.dateTime)==null?void 0:I.timeStyle)??t.dateTime.timeStyle},defaultCurrency:h},g=new Intl.NumberFormat(f,{style:"currency",currency:h}).format(1e3),x=$t.resolveRawTemporalFormat({preferences:m,calendar:{tz:"UTC"}}),b=$t.formatRawTemporalValue({value:iY,metadata:{kind:"raw_temporal",valueKind:"date"},format:x}).text,y=$t.formatRawTemporalValue({value:W2,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:x}).text,w=G2(_=>$t.formatRawTemporalValue({value:iY,metadata:{kind:"raw_temporal",valueKind:"date"},format:$t.resolveRawTemporalFormat({preferences:{...m,dateStyle:_},calendar:{tz:"UTC"}})}).text),C=G2(_=>$t.formatRawTemporalValue({value:W2,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:$t.resolveRawTemporalFormat({preferences:{...m,dateTime:{...m.dateTime,dateStyle:_}},calendar:{tz:"UTC"}})}).text),N=G2(_=>$t.formatRawTemporalValue({value:W2,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:$t.resolveRawTemporalFormat({preferences:{...m,dateTime:{...m.dateTime,timeStyle:_}},calendar:{tz:"UTC"}})}).text),S=(_,E)=>{const D={...e.dateTime,[_]:E==="inherit"?void 0:E};r({...e,dateTime:D.dateStyle===void 0&&D.timeStyle===void 0?void 0:D})};return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(p.Label,{htmlFor:s,className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Locale"}),l.jsxs(p.Select,{value:e.locale??"inherit",disabled:o,onValueChange:_=>r({...e,locale:_==="inherit"?void 0:_}),children:[l.jsx(p.SelectTrigger,{id:s,size:"xs",children:l.jsx(p.SelectValue,{children:e.locale===void 0?`Inherited · ${t.locale}`:T_t(e.locale)})}),l.jsxs(p.SelectContent,{children:[l.jsxs(p.SelectItem,{value:"inherit",children:["Inherited from ",cO(n.locale)," ·"," ",t.locale]}),e.locale&&!lO.some(_=>_.value===e.locale)&&l.jsx(p.SelectItem,{value:e.locale,children:e.locale}),lO.map(_=>l.jsxs(p.SelectItem,{value:_.value,children:[_.label," — ",_.value]},_.value))]})]})]}),l.jsxs("fieldset",{className:"space-y-2",children:[l.jsx("legend",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date values"}),l.jsx(Y2,{id:a,label:"Format",value:e.dateStyle,inherited:t.dateStyle,inheritedSource:n.dateStyle,examples:w,disabled:o,onValueChange:_=>r({...e,dateStyle:_==="inherit"?void 0:_})})]}),l.jsxs("fieldset",{className:"space-y-2",children:[l.jsx("legend",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date & time values"}),l.jsx(Y2,{id:c,label:"Date",value:(k=e.dateTime)==null?void 0:k.dateStyle,inherited:t.dateTime.dateStyle,inheritedSource:n.dateTime.dateStyle,examples:C,disabled:o,onValueChange:_=>S("dateStyle",_)}),l.jsx(Y2,{id:u,label:"Time",value:(T=e.dateTime)==null?void 0:T.timeStyle,inherited:t.dateTime.timeStyle,inheritedSource:n.dateTime.timeStyle,examples:N,disabled:o,onValueChange:_=>S("timeStyle",_)})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(p.Label,{htmlFor:i,className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Default currency"}),l.jsxs(p.Select,{value:e.defaultCurrency??"inherit",disabled:o,onValueChange:_=>r({...e,defaultCurrency:_==="inherit"?void 0:_}),children:[l.jsx(p.SelectTrigger,{id:i,size:"xs",children:l.jsx(p.SelectValue,{children:e.defaultCurrency===void 0?`Inherited · ${t.defaultCurrency}`:e.defaultCurrency})}),l.jsxs(p.SelectContent,{children:[l.jsxs(p.SelectItem,{value:"inherit",children:["Inherited from ",cO(n.defaultCurrency)," ·"," ",t.defaultCurrency]}),[...Lxe].map(_=>l.jsx(p.SelectItem,{value:_,children:_},_)),__t.map(_=>l.jsx(p.SelectItem,{value:_,children:_},_))]})]})]}),l.jsxs("div",{className:"rounded-control border border-border/60 bg-muted/30 px-3 py-2",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Preview"}),l.jsxs("dl",{className:"mt-1.5 space-y-1 text-[12px]",children:[l.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[l.jsx("dt",{className:"text-muted-foreground",children:"Date"}),l.jsx("dd",{className:"text-right font-medium text-foreground",children:b})]}),l.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[l.jsx("dt",{className:"text-muted-foreground",children:"Date & time"}),l.jsx("dd",{className:"text-right font-medium text-foreground",children:y})]}),l.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[l.jsx("dt",{className:"text-muted-foreground",children:"Currency"}),l.jsx("dd",{className:"text-right font-medium text-foreground",children:g})]})]})]}),l.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Currency values are not converted. Date examples use a fixed reference value and the Gregorian calendar."})]})}const uO=new Set;function zxe(e){return uO.add(e),()=>{uO.delete(e)}}function sB(){uO.forEach(e=>{e()})}var D_t=Object.defineProperty,M_t=(e,t,n)=>t in e?D_t(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g1=(e,t,n)=>M_t(e,typeof t!="symbol"?t+"":t,n);const R_t={stringify:e=>e?"true":"false",parse:e=>/^[ty1-9]/i.test(e)},A_t={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{if(typeof window<"u"&&e in window)return window[e];if(typeof global<"u"&&e in global)return global[e]})();return typeof r=="function"?r.bind(n):void 0}},P_t={stringify:e=>JSON.stringify(e),parse:e=>JSON.parse(e)};function F_t(e){return e.replace(/([a-z0-9])([A-Z])/g,(t,n,r)=>`${n}-${r.toLowerCase()}`)}function Bxe(e){return e.replace(/[-:]([a-z])/g,(t,n)=>`${n.toUpperCase()}`)}const O_t={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{const o=Bxe(t);if(typeof n<"u"&&o in n.container)return n.container[o]})();return typeof r=="function"?r.bind(n):void 0}},L_t={stringify:e=>`${e}`,parse:e=>parseFloat(e)},$_t={stringify:e=>e,parse:e=>e},Z2={string:$_t,number:L_t,boolean:R_t,function:A_t,method:O_t,json:P_t},sy=Symbol.for("r2wc.render"),b1=Symbol.for("r2wc.connected"),Gf=Symbol.for("r2wc.context"),Ai=Symbol.for("r2wc.props");function z_t(e,t,n){var r,o,s;t.props||(t.props=e.propTypes?Object.keys(e.propTypes):[]),t.events||(t.events=[]);const i=Array.isArray(t.props)?t.props.slice():Object.keys(t.props),a=Array.isArray(t.events)?t.events.slice():Object.keys(t.events),c={},u={},d={},f={};for(const m of i){c[m]=Array.isArray(t.props)?"string":t.props[m];const g=F_t(m);d[m]=g,f[g]=m}for(const m of a)u[m]=Array.isArray(t.events)?{}:t.events[m];class h extends HTMLElement{constructor(){super(),g1(this,s,!0),g1(this,o),g1(this,r,{}),g1(this,"container"),t.shadow?this.container=this.attachShadow({mode:t.shadow}):this.container=this,this[Ai].container=this.container;for(const g of i){const x=d[g],b=this.getAttribute(x),y=c[g],w=y?Z2[y]:null;if(y==="method"){const C=Bxe(x);Object.defineProperty(this[Ai].container,C,{enumerable:!0,configurable:!0,get(){return this[Ai][C]},set(N){this[Ai][C]=N,this[sy]()}}),this[Ai][g]=w.parse(b,x,this)}w!=null&&w.parse&&b&&(this[Ai][g]=w.parse(b,x,this))}for(const g of a)this[Ai][g]=x=>{const b=g.replace(/^on/,"").toLowerCase();this.dispatchEvent(new CustomEvent(b,{detail:x,...u[g]}))}}static get observedAttributes(){return Object.keys(f)}connectedCallback(){this[b1]=!0,this[sy]()}disconnectedCallback(){this[b1]=!1,this[Gf]&&n.unmount(this[Gf]),delete this[Gf]}attributeChangedCallback(g,x,b){const y=f[g],w=c[y],C=w?Z2[w]:null;y in c&&C!=null&&C.parse&&b&&(this[Ai][y]=C.parse(b,g,this),this[sy]())}[(s=b1,o=Gf,r=Ai,sy)](){this[b1]&&(this[Gf]?n.update(this[Gf],this[Ai]):this[Gf]=n.mount(this.container,e,this[Ai]))}}for(const m of i){const g=d[m],x=c[m];Object.defineProperty(h.prototype,m,{enumerable:!0,configurable:!0,get(){return this[Ai][m]},set(b){this[Ai][m]=b;const y=x?Z2[x]:null;if(y!=null&&y.stringify){const w=y.stringify(b,g,this);this.getAttribute(g)!==w&&this.setAttribute(g,w)}else this[sy]()}})}return h}function B_t(e,t,n){const r=hye.createRoot(e),o=v.createElement(t,n);return r.render(o),{root:r,ReactComponent:t}}function V_t({root:e,ReactComponent:t},n){const r=v.createElement(t,n);e.render(r)}function H_t({root:e}){e.unmount()}function q_t(e,t={}){return z_t(e,t,{mount:B_t,update:V_t,unmount:H_t})}const U_t={id:"string",version:"string",authToken:"json",placeholders:"json",defaultFilterValues:"json",defaultControlValues:"json",controlContractOverrides:"json",documentInputValues:"json",dashboardInputExecutionSnapshot:"json",interactionExecutionSnapshot:"json",presentationExecutionSnapshot:"json",renderMode:"string",currentTheme:"string",customCards:"json",customStyle:"json",appearance:"json",onChartElementClicked:"function",onFilterValuesChange:"function",onEvent:"function",onSave:"function",LoadingComponent:"function",ErrorComponent:"function",showAssistant:"boolean",showBriefings:"boolean",selectedSheetId:"string",eventHandlers:"json",preferences:"json"},W_t=q_t(Oxe,{props:U_t}),K_t=v.memo(function({context:t="editor"}={}){return l.jsxs("div",{"data-content":"fields-section",className:"flex h-full grow flex-col items-center overflow-hidden",children:[" ",l.jsx(y4,{context:t})," "]})});var Vxe="Toggle",Hxe=te.forwardRef((e,t)=>{const{pressed:n,defaultPressed:r,onPressedChange:o,...s}=e,[i,a]=p.useControllableState({prop:n,onChange:o,defaultProp:r??!1,caller:Vxe});return l.jsx(p.Primitive.button,{type:"button","aria-pressed":i,"data-state":i?"on":"off","data-disabled":e.disabled?"":void 0,...s,ref:t,onClick:p.composeEventHandlers(e.onClick,()=>{e.disabled||a(!i)})})});Hxe.displayName=Vxe;var qxe=Hxe;const G_t=p.cva("inline-flex items-center justify-center rounded-control text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),Uxe=te.forwardRef(({className:e,variant:t,size:n,...r},o)=>l.jsx(qxe,{ref:o,className:p.cn(G_t({variant:t,size:n,className:e})),...r}));Uxe.displayName=qxe.displayName;function iB(){var c,u;const e=p.useEditorStore(d=>d.card),t=p.useEditorStore(d=>d.frame),n=v.useMemo(()=>at.findCustomVisualConfigCard(t,e),[t,e]),{manifest:r}=_f(((c=n==null?void 0:n.customCardPreferences)==null?void 0:c.url)||""),o=v.useMemo(()=>{var d;return(d=r==null?void 0:r.visuals)==null?void 0:d.find(f=>{var h;return f.name===((h=n==null?void 0:n.customCardPreferences)==null?void 0:h.componentName)})},[r,(u=n==null?void 0:n.customCardPreferences)==null?void 0:u.componentName]),s=at.resolveMultiInputType(n,o),i=v.useMemo(()=>at.getCustomVisualInputCards({frame:t,configCard:n,isMultiInputVisual:s==="multiple"}),[t,n,s]),a=v.useMemo(()=>{const d=i.findIndex(f=>(f==null?void 0:f.id)===e.id);return d<0?-1:at.getSlotIndexForCard(e,d)},[i,e]);return v.useMemo(()=>!n||s!=="multiple"||a<0?e.type:at.getEffectiveCardTypeForSlot(e,a,o==null?void 0:o.slots)??e.type,[n,s,a,e,o==null?void 0:o.slots])}function Wxe({storeValue:e,defaultValue:t="",onStoreUpdate:n,delay:r=300}){const[o,s]=v.useState(e??t),i=v.useRef(null),a=v.useRef(o),c=v.useRef(e),u=v.useRef(!1),d=v.useCallback(()=>{i.current&&(clearTimeout(i.current),i.current=null),u.current&&a.current!==(c.current??t)&&(n(a.current),c.current=a.current)},[t,n]);v.useEffect(()=>{if(e!==c.current){i.current&&(clearTimeout(i.current),i.current=null);const h=e??t;s(h),a.current=h,c.current=e,u.current=!1}},[e,t]),v.useEffect(()=>{if(u.current)return i.current=setTimeout(()=>{d()},r),()=>{i.current&&(clearTimeout(i.current),i.current=null)}},[r,d,o]),v.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]);const f=v.useCallback(h=>{const m=h??t;u.current=!0,a.current=m,s(m)},[t]);return{value:o,onChange:f,flush:d}}const Y_t=300;function Z_t({onExpand:e},t){const n=p.useEditorStore(C=>C.card.sql),r=p.useEditorStore(C=>C.sqlGen),o=p.useEditorStore(C=>C.card),s=iB(),{setCardSql:i,setSqlGen:a,setRunSql:c}=p.useEditorActions(),u=v.useMemo(()=>s!==o.type?{...o,type:s}:o,[o,s]),{queryKey:d}=Nb(u),f=Zr(),h=v.useRef(d);h.current=d;const m=v.useRef(r);m.current=r;const g=v.useCallback(C=>{i(C)},[i]),{value:x,onChange:b,flush:y}=Wxe({storeValue:n,defaultValue:"",onStoreUpdate:g,delay:Y_t});v.useEffect(()=>zxe(y),[y]);function w(C){b(C),p.isObjectEmpty(m.current)||a({})}return l.jsxs("div",{className:"relative h-full w-full",children:[l.jsx(p.CodeEditor,{ref:t,value:x??"",onValueChange:w,language:"sql-jinja",embedded:!0,hideLineNumbers:!0,wrapLines:!0,placeholder:"Write your SQL here",onKeyDown:C=>{C.key==="Enter"&&C.shiftKey&&(C.preventDefault(),sB(),setTimeout(()=>{f.removeQueries({queryKey:h.current,exact:!0}),c(!0)},0))}}),e?l.jsx(p.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-2.5 top-2 z-20 h-7 w-7 bg-background/80 p-0 text-muted-foreground backdrop-blur-sm transition-colors hover:bg-accent hover:text-foreground focus-visible:text-foreground",onClick:e,"aria-label":"Expand SQL editor",title:"Expand SQL editor",children:l.jsx(Mt.Maximize2,{className:"h-3.5 w-3.5",strokeWidth:1.75})}):null]})}const X_t=v.forwardRef(Z_t),Q_t=300;function J_t(e,t){const n=p.useEditorStore(g=>g.card.python),r=p.useEditorStore(g=>g.card),o=iB(),{setCardPython:s,setRunSql:i}=p.useEditorActions(),a=v.useMemo(()=>o!==r.type?{...r,type:o}:r,[r,o]),{queryKey:c}=Nb(a),u=Zr(),d=v.useRef(c);d.current=c;const{value:f,onChange:h,flush:m}=Wxe({storeValue:n,defaultValue:at.PYTHON_DEFAULT_CODE,onStoreUpdate:s,delay:Q_t});return v.useEffect(()=>zxe(m),[m]),l.jsx(p.CodeEditor,{ref:t,value:f??"",onValueChange:h,language:"python",embedded:!0,hideLineNumbers:!0,wrapLines:!0,className:"[&_.code-editor-pre]:!pt-2 [&_.code-editor-textarea]:!pt-2",onKeyDown:g=>{g.key==="Enter"&&g.shiftKey&&(g.preventDefault(),sB(),setTimeout(()=>{u.removeQueries({queryKey:d.current,exact:!0}),i(!0)},0))}})}const eTt=v.forwardRef(J_t),Kxe=new Set(["askForMoreInfo","getAvailableChartTypes","getChartSQLSyntax","getDomainRelationships","getTableColumns","getUserSql","validateCardConfigFormat"]),tTt=new Set(["createChartFromSql","createForecast","generateQueryConfig","getChartDataFromCardConfig","getChartDataFromSqlAndPython","getForecastDataFromSqlAndPython"]),nTt=Array.from(Kxe).join(", "),rTt=3,oTt="Self-heal",sTt=new Set(["SQL_PARSE_ERROR","SQL_EXPLAIN_ERROR"]);function iTt({card:e}){var z,F,G,q,Y;const t=xl(),[n,r]=v.useState({}),{authToken:o}=It(),s=p.getTokenParams(o==null?void 0:o.accessToken),{compiledAppearance:i}=oi.useAppearance(),a=v.useMemo(()=>Vw(i),[i]),c=p.useEditorStore(K=>K.frame),u=p.useEditorStore(K=>K.inlineFilterValuesMap[e.id]),d=p.useEditorStore(K=>K.actions.setCardInlineFilterValue),f=p.useEditorStore(K=>K.actions.removeCardInlineFilterValue),h=e,{getCard:m,manifest:g}=_f(((z=h.customCardPreferences)==null?void 0:z.url)||""),x=(F=g==null?void 0:g.visuals)==null?void 0:F.find(K=>{var $;return K.name===(($=h.customCardPreferences)==null?void 0:$.componentName)}),b=at.resolveMultiInputType(h,x)??"single",y=v.useMemo(()=>at.getCustomVisualInputCards({frame:c,configCard:h,isMultiInputVisual:b==="multiple"}),[c,h,b]),w=v.useMemo(()=>{const K=y.findIndex($=>($==null?void 0:$.id)===e.id);return K<0?-1:at.getSlotIndexForCard(e,K)},[y,e]),C=v.useMemo(()=>b!=="multiple"||w<0?e.type:at.getEffectiveCardTypeForSlot(e,w,x==null?void 0:x.slots)??e.type,[b,w,e,x==null?void 0:x.slots]),N=v.useMemo(()=>b==="multiple"?{...e,connectionId:void 0,dataSource:void 0,sql:"",python:"",config:void 0,queryConfig:void 0}:C!==e.type?{...e,type:C}:e,[e,C,b]),{data:S,effectiveCardConfig:j}=Nb(N),I=p.useInteractionStore(K=>K.interactionStates),k=p.useDashboardStore(K=>{var $;return($=K.dashboard)==null?void 0:$.id}),T=p.useDashboardStore(K=>K.dashboard.filters),_=p.useDashboardStore(K=>K.filterValues),E=p.useDashboardStore(K=>K.selectedSheetId),D=v.useMemo(()=>U$({card:e,sheetId:E||"",inlineFilterValues:u,setInlineFilterValue:K=>d(e.id,K),removeInlineFilterValue:K=>f(e.id,K)}),[e,E,u,d,f]),{cardFilters:M,cardFilterValues:P}=v.useMemo(()=>bI({card:e,interactionStates:I,currentDashboardId:k,filters:T,filterValues:_,selectedSheetId:E}),[e,I,k,T,_,E]),A=v.useCallback((K,$)=>{const X=at.normalizeMultiInputPayload($);r(W=>({...W,[K]:X}))},[]),L=(G=h.customCardPreferences)==null?void 0:G.componentName,O=L?m(L):null,B=Hj((q=h.customCardPreferences)==null?void 0:q.settings,h),H=v.useMemo(()=>at.buildSlotOrderedCards(y),[y]),R=v.useMemo(()=>H.map((K,$)=>at.getEffectiveCardTypeForSlot(K,$,x==null?void 0:x.slots)),[H,x==null?void 0:x.slots]),V=v.useMemo(()=>G$(b==="multiple"?K$({slotOrderedCards:H,multiInputData:n,valueFormatPreferences:t}):[{card:e,cardConfig:j,columns:S==null?void 0:S.columns,columnKeyMap:S==null?void 0:S.columnKeyMap,valueFormatPreferences:t}]),[e,S==null?void 0:S.columnKeyMap,S==null?void 0:S.columns,j,n,H,b,t]);return L?l.jsx("div",{className:"semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2 overflow-y-auto",children:l.jsxs(v.Suspense,{fallback:l.jsx(l.Fragment,{}),children:[O&&b==="single"&&l.jsx(O,{editing:!0,params:s,theme:a,settings:B,cardMetadata:Eue({card:e,dataMetadata:S==null?void 0:S.metadata}),onDataChange:A,data:(S==null?void 0:S.records)||[],columns:(S==null?void 0:S.columns)||[],formatTemporalBucketValue:V,filters:M,filterValues:[...P||[],...u||[]],inlineFilters:D}),O&&b==="multiple"&&l.jsxs(l.Fragment,{children:[y.map((K,$)=>{if(!K)return null;const X=at.getSlotIndexForCard(K,$),W=at.getEffectiveCardTypeForSlot(K,X,x==null?void 0:x.slots);return l.jsx(g$,{onDataChange:A,card:K,effectiveCardType:W},`${K.id}-${X}`)}),l.jsx("div",{className:"flex flex-col gap-2",children:l.jsx(O,{editing:!0,onDataChange:A,...W$({configCard:h,slotOrderedCards:H,slotTypes:R,multiInputData:n,params:s,theme:a,chartSettings:B,filters:M,filterValues:[...P||[],...u||[]],inlineFilters:D,formatTemporalBucketValue:V})})})]})]},(Y=h.customCardPreferences)==null?void 0:Y.componentName)}):null}const aTt=v.memo(iTt),lTt=p.create()(p.persist((e,t)=>({starredCharts:[],isStarred:(n,r)=>t().starredCharts.some(o=>o.type===n&&o.id===r),toggleStar:n=>{e(r=>{const o=r.starredCharts.findIndex(s=>s.type===n.type&&s.id===n.id);return o>=0?{starredCharts:r.starredCharts.filter((s,i)=>i!==o)}:{starredCharts:[...r.starredCharts,n]}})},getStarredChart:(n,r)=>t().starredCharts.find(o=>o.type===n&&o.id===r)}),{name:"semaphor-starred-charts"}));var Gxe=["PageUp","PageDown"],Yxe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Zxe={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},gx="Slider",[dO,cTt,uTt]=p.createCollection(gx),[Xxe]=p.createContextScope(gx,[uTt]),[dTt,GT]=Xxe(gx),Qxe=te.forwardRef((e,t)=>{const{name:n,min:r=0,max:o=100,step:s=1,orientation:i="horizontal",disabled:a=!1,minStepsBetweenThumbs:c=0,defaultValue:u=[r],value:d,onValueChange:f=()=>{},onValueCommit:h=()=>{},inverted:m=!1,form:g,...x}=e,b=te.useRef(new Set),y=te.useRef(0),C=i==="horizontal"?fTt:hTt,[N=[],S]=p.useControllableState({prop:d,defaultProp:u,onChange:E=>{var M;(M=[...b.current][y.current])==null||M.focus(),f(E)}}),j=te.useRef(N);function I(E){const D=xTt(N,E);_(E,D)}function k(E){_(E,y.current)}function T(){const E=j.current[y.current];N[y.current]!==E&&h(N)}function _(E,D,{commit:M}={commit:!1}){const P=CTt(s),A=STt(Math.round((E-r)/s)*s+r,P),L=p.clamp(A,[r,o]);S((O=[])=>{const B=gTt(O,L,D);if(wTt(B,c*s)){y.current=B.indexOf(L);const H=String(B)!==String(O);return H&&M&&h(B),H?B:O}else return O})}return l.jsx(dTt,{scope:e.__scopeSlider,name:n,disabled:a,min:r,max:o,valueIndexToChangeRef:y,thumbs:b.current,values:N,orientation:i,form:g,children:l.jsx(dO.Provider,{scope:e.__scopeSlider,children:l.jsx(dO.Slot,{scope:e.__scopeSlider,children:l.jsx(C,{"aria-disabled":a,"data-disabled":a?"":void 0,...x,ref:t,onPointerDown:p.composeEventHandlers(x.onPointerDown,()=>{a||(j.current=N)}),min:r,max:o,inverted:m,onSlideStart:a?void 0:I,onSlideMove:a?void 0:k,onSlideEnd:a?void 0:T,onHomeKeyDown:()=>!a&&_(r,0,{commit:!0}),onEndKeyDown:()=>!a&&_(o,N.length-1,{commit:!0}),onStepKeyDown:({event:E,direction:D})=>{if(!a){const A=Gxe.includes(E.key)||E.shiftKey&&Yxe.includes(E.key)?10:1,L=y.current,O=N[L],B=s*A*D;_(O+B,L,{commit:!0})}}})})})})});Qxe.displayName=gx;var[Jxe,eye]=Xxe(gx,{startEdge:"left",endEdge:"right",size:"width",direction:1}),fTt=te.forwardRef((e,t)=>{const{min:n,max:r,dir:o,inverted:s,onSlideStart:i,onSlideMove:a,onSlideEnd:c,onStepKeyDown:u,...d}=e,[f,h]=te.useState(null),m=p.useComposedRefs(t,C=>h(C)),g=te.useRef(void 0),x=p.useDirection(o),b=x==="ltr",y=b&&!s||!b&&s;function w(C){const N=g.current||f.getBoundingClientRect(),S=[0,N.width],I=aB(S,y?[n,r]:[r,n]);return g.current=N,I(C-N.left)}return l.jsx(Jxe,{scope:e.__scopeSlider,startEdge:y?"left":"right",endEdge:y?"right":"left",direction:y?1:-1,size:"width",children:l.jsx(tye,{dir:x,"data-orientation":"horizontal",...d,ref:m,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:C=>{const N=w(C.clientX);i==null||i(N)},onSlideMove:C=>{const N=w(C.clientX);a==null||a(N)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:C=>{const S=Zxe[y?"from-left":"from-right"].includes(C.key);u==null||u({event:C,direction:S?-1:1})}})})}),hTt=te.forwardRef((e,t)=>{const{min:n,max:r,inverted:o,onSlideStart:s,onSlideMove:i,onSlideEnd:a,onStepKeyDown:c,...u}=e,d=te.useRef(null),f=p.useComposedRefs(t,d),h=te.useRef(void 0),m=!o;function g(x){const b=h.current||d.current.getBoundingClientRect(),y=[0,b.height],C=aB(y,m?[r,n]:[n,r]);return h.current=b,C(x-b.top)}return l.jsx(Jxe,{scope:e.__scopeSlider,startEdge:m?"bottom":"top",endEdge:m?"top":"bottom",size:"height",direction:m?1:-1,children:l.jsx(tye,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:x=>{const b=g(x.clientY);s==null||s(b)},onSlideMove:x=>{const b=g(x.clientY);i==null||i(b)},onSlideEnd:()=>{h.current=void 0,a==null||a()},onStepKeyDown:x=>{const y=Zxe[m?"from-bottom":"from-top"].includes(x.key);c==null||c({event:x,direction:y?-1:1})}})})}),tye=te.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:o,onSlideEnd:s,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:c,...u}=e,d=GT(gx,n);return l.jsx(p.Primitive.span,{...u,ref:t,onKeyDown:p.composeEventHandlers(e.onKeyDown,f=>{f.key==="Home"?(i(f),f.preventDefault()):f.key==="End"?(a(f),f.preventDefault()):Gxe.concat(Yxe).includes(f.key)&&(c(f),f.preventDefault())}),onPointerDown:p.composeEventHandlers(e.onPointerDown,f=>{const h=f.target;h.setPointerCapture(f.pointerId),f.preventDefault(),d.thumbs.has(h)?h.focus():r(f)}),onPointerMove:p.composeEventHandlers(e.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&o(f)}),onPointerUp:p.composeEventHandlers(e.onPointerUp,f=>{const h=f.target;h.hasPointerCapture(f.pointerId)&&(h.releasePointerCapture(f.pointerId),s(f))})})}),nye="SliderTrack",rye=te.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=GT(nye,n);return l.jsx(p.Primitive.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...r,ref:t})});rye.displayName=nye;var fO="SliderRange",oye=te.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=GT(fO,n),s=eye(fO,n),i=te.useRef(null),a=p.useComposedRefs(t,i),c=o.values.length,u=o.values.map(h=>aye(h,o.min,o.max)),d=c>1?Math.min(...u):0,f=100-Math.max(...u);return l.jsx(p.Primitive.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...r,ref:a,style:{...e.style,[s.startEdge]:d+"%",[s.endEdge]:f+"%"}})});oye.displayName=fO;var hO="SliderThumb",sye=te.forwardRef((e,t)=>{const n=cTt(e.__scopeSlider),[r,o]=te.useState(null),s=p.useComposedRefs(t,a=>o(a)),i=te.useMemo(()=>r?n().findIndex(a=>a.ref.current===r):-1,[n,r]);return l.jsx(mTt,{...e,ref:s,index:i})}),mTt=te.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:o,...s}=e,i=GT(hO,n),a=eye(hO,n),[c,u]=te.useState(null),d=p.useComposedRefs(t,w=>u(w)),f=c?i.form||!!c.closest("form"):!0,h=p.useSize(c),m=i.values[r],g=m===void 0?0:aye(m,i.min,i.max),x=bTt(r,i.values.length),b=h==null?void 0:h[a.size],y=b?yTt(b,g,a.direction):0;return te.useEffect(()=>{if(c)return i.thumbs.add(c),()=>{i.thumbs.delete(c)}},[c,i.thumbs]),l.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${g}% + ${y}px)`},children:[l.jsx(dO.ItemSlot,{scope:e.__scopeSlider,children:l.jsx(p.Primitive.span,{role:"slider","aria-label":e["aria-label"]||x,"aria-valuemin":i.min,"aria-valuenow":m,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...s,ref:d,style:m===void 0?{display:"none"}:e.style,onFocus:p.composeEventHandlers(e.onFocus,()=>{i.valueIndexToChangeRef.current=r})})}),f&&l.jsx(iye,{name:o??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:m},r)]})});sye.displayName=hO;var pTt="RadioBubbleInput",iye=te.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const o=te.useRef(null),s=p.useComposedRefs(o,r),i=p.usePrevious(t);return te.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const f=new Event("input",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),l.jsx(p.Primitive.input,{style:{display:"none"},...n,ref:s,defaultValue:t})});iye.displayName=pTt;function gTt(e=[],t,n){const r=[...e];return r[n]=t,r.sort((o,s)=>o-s)}function aye(e,t,n){const s=100/(n-t)*(e-t);return p.clamp(s,[0,100])}function bTt(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function xTt(e,t){if(e.length===1)return 0;const n=e.map(o=>Math.abs(o-t)),r=Math.min(...n);return n.indexOf(r)}function yTt(e,t,n){const r=e/2,s=aB([0,50],[0,r]);return(r-s(t)*n)*n}function vTt(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function wTt(e,t){if(t>0){const n=vTt(e);return Math.min(...n)>=t}return!0}function aB(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function CTt(e){return(String(e).split(".")[1]||"").length}function STt(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var lye=Qxe,NTt=rye,jTt=oye,kTt=sye;const cye=te.forwardRef(({className:e,...t},n)=>l.jsxs(lye,{ref:n,className:p.cn("relative flex w-full touch-none select-none items-center",e),...t,children:[l.jsx(NTt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:l.jsx(jTt,{className:"absolute h-full bg-primary"})}),l.jsx(kTt,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));cye.displayName=lye.displayName;exports.Accordion=u4;exports.AccordionContent=Nv;exports.AccordionItem=Cv;exports.AccordionTrigger=Sv;exports.AddDataPicker=J4;exports.AggregateTable=S_;exports.Alert=fL;exports.AlertDescription=hL;exports.AlertDialog=gf;exports.AlertDialogAction=Ou;exports.AlertDialogCancel=Lu;exports.AlertDialogContent=Mu;exports.AlertDialogDescription=Fu;exports.AlertDialogFooter=Au;exports.AlertDialogHeader=Ru;exports.AlertDialogTitle=Pu;exports.AlertDialogTrigger=S1e;exports.AlertTitle=Mte;exports.ArrowDown=ss;exports.ArrowDownIcon=QQe;exports.ArrowLeft=Yv;exports.ArrowRight=Zv;exports.ArrowUp=ws;exports.ArrowUpIcon=eJe;exports.AssistantContextEntityControls=iO;exports.AssistantVirtualizedMessages=Txe;exports.AxisConfigurator=Xm;exports.BackgroundRunPill=Rut;exports.Badge=yi;exports.Bell=w1;exports.BookType=wZ;exports.BriefingAuthor=lhe;exports.BriefingAuthorDialog=che;exports.BriefingUiCapabilitiesBoundary=tdt;exports.BriefingUiCapabilitiesProvider=cT;exports.BriefingsApiError=Qw;exports.BulletChartIcon=wxe;exports.CSS=Ji;exports.CalculatedFieldEditor=$me;exports.Calculator=SZ;exports.Calendar=Wa;exports.CalendarClock=DO;exports.Card=CN;exports.CardContent=EO;exports.CardHeader=TO;exports.CardSummary=dF;exports.CardTitle=xb;exports.ChartArea=CR;exports.ChartColumnIncreasing=jZ;exports.ChartColumnStacked=kZ;exports.ChartJsVisual=Ow;exports.ChartLine=IZ;exports.ChartNoAxesGantt=TZ;exports.ChartPie=EZ;exports.ChartScatter=DZ;exports.ChatInputWithContext=eB;exports.Checkbox=An;exports.ChevronLeft=Lm;exports.ChevronsUpDown=AZ;exports.Circle=MO;exports.CircleAlert=Ia;exports.CircleCheck=PZ;exports.CircleHelp=FZ;exports.Clock=OZ;exports.CodeHighlighter=Bd;exports.CodeXml=C1;exports.Collapsible=ku;exports.CollapsibleContent=_u;exports.CollapsibleTrigger=Iu;exports.ColorField=ga;exports.Command=yT;exports.CommandEmpty=wT;exports.CommandGroup=CT;exports.CommandInput=Qz;exports.CommandItem=ST;exports.CommandList=vT;exports.CommandSeparator=ome;exports.ComparisonMetadataBadge=ese;exports.Container=a5;exports.ControlDefaultValueEditor=lpe;exports.ControlDefinitionOptionsEditor=ape;exports.ControlIdInput=rpe;exports.ControlVisibilitySettings=ybt;exports.Copy=rm;exports.CopyButton=zd;exports.CopyPlus=NR;exports.Cross2Icon=oJe;exports.CustomFilterPopover=H$;exports.CustomScrollArea=yl;exports.DEFAULT_HEATMAP_CUSTOM_RANGE=Qre;exports.Dashboard=Oxe;exports.DashboardCard=hhe;exports.DashboardCreateDialogBase=EQ;exports.DashboardExportDialog=Exe;exports.DashboardPlus=k_t;exports.DashboardWC=W_t;exports.DataTableConditionalFormattingSettings=Xpe;exports.DataTablePagination=h_;exports.Database=Go;exports.DateRangePicker=$$;exports.DefaultChatTransport=q4;exports.Dialog=So;exports.DialogContent=po;exports.DialogDescription=Oo;exports.DialogFooter=al;exports.DialogHeader=Ds;exports.DialogTitle=go;exports.DialogTrigger=IQ;exports.DisplayFormatPreferencesFields=E_t;exports.DisplayPreferencesProvider=J_;exports.DndContext=cC;exports.Donut=LZ;exports.Download=Tu;exports.DownloadPdf=Dxe;exports.DragOverlay=qhe;exports.DropdownMenu=Xo;exports.DropdownMenuCheckboxItem=ad;exports.DropdownMenuContent=Fo;exports.DropdownMenuItem=In;exports.DropdownMenuLabel=Za;exports.DropdownMenuRadioGroup=ECe;exports.DropdownMenuRadioItem=JX;exports.DropdownMenuSeparator=Ta;exports.DropdownMenuSub=QO;exports.DropdownMenuSubContent=Kk;exports.DropdownMenuSubTrigger=Wk;exports.DropdownMenuTrigger=Qo;exports.EMPTY_DATA_SOURCE=mb;exports.Editable=Uj;exports.EditableText=Si;exports.EditorCustomVisual=aTt;exports.Ellipsis=Ii;exports.EllipsisVertical=$m;exports.ErrorBoundary=_i;exports.ExportError=Pb;exports.ExternalLink=Vd;exports.EyeOff=Vk;exports.Fallback=X_;exports.FallbackVisual=Yw;exports.FeedbackCategory=ff;exports.FeedbackDialog=Pv;exports.FieldsList=y4;exports.FieldsSection=K_t;exports.FileCode=$Z;exports.FileText=ti;exports.Filter=Hd;exports.FilterComponent=W_;exports.FilterInfo=aF;exports.FilterableFieldsPanel=Bme;exports.Grid3x3=jR;exports.GripVertical=Eu;exports.HEATMAP_PRESET_PALETTES=OA;exports.Hash=yb;exports.House=zZ;exports.HoverCard=np;exports.HoverCardContent=Su;exports.HoverCardTrigger=Jd;exports.INLINE_ALLOWED_READ_ONLY_TOOLS=Kxe;exports.INLINE_ALLOWED_TOOL_LIST=nTt;exports.INLINE_BLOCKED_MUTATING_TOOLS=tTt;exports.IconButton=au;exports.IconForFieldType=cN;exports.Inbox=AO;exports.InfoHover=uz;exports.InlineFilterBar=sde;exports.KPICard=sf;exports.KeyboardSensor=aC;exports.Layers=Bm;exports.Link=PO;exports.LoadingDots=uc;exports.MAX_SELF_HEAL_ATTEMPTS=rTt;exports.Map=qZ;exports.Markdown=Az;exports.MatrixTableVisual=C_;exports.MdStackedLineChart=yxe;exports.MultiInputEmptyRenderer=g$;exports.PanelResizeHandle=zT;exports.Pause=UZ;exports.PenLine=_R;exports.Pencil=TR;exports.PendingMessagesDisplay=cxe;exports.PersistedDynamicVisual=Q_;exports.PiChartPolar=pxe;exports.Pin=KZ;exports.PinOff=WZ;exports.PivotTableTanstack=tx;exports.Placeholders=Nge;exports.Play=GZ;exports.Plus=Mr;exports.PointerSensor=lx;exports.Progress=Z4;exports.PythonEditor=eTt;exports.RECOVERABLE_SQL_ERROR_CODES=sTt;exports.Radar=YZ;exports.RadioGroup=wu;exports.RadioGroupItem=Qs;exports.RefreshCw=_a;exports.ResizableHandle=Rvt;exports.ResizablePanel=GF;exports.ResizablePanelGroup=Sge;exports.ResourceEditDialog=aJ;exports.ResourceType=mo;exports.Rows3=ZZ;exports.RunCompletionBanner=Aut;exports.SELF_HEAL_TIMELINE_STEP=oTt;exports.SeedQuestions=Gbe;exports.SemaphorContext=qv;exports.SemaphorContextProvider=vO;exports.SemaphorQueryClient=UY;exports.SemaphorReadyIndicator=oB;exports.SemaphorStyleWrapper=nx;exports.Send=OO;exports.SendHorizontal=XZ;exports.Settings=LO;exports.Settings2=mf;exports.Share2=QZ;exports.ShareDialog=iJ;exports.Sheet=g3;exports.SheetContent=m_;exports.SheetDescription=g_;exports.SheetHeader=qoe;exports.SheetTitle=p_;exports.SheetTrigger=_4e;exports.Slider=cye;exports.SortableContext=uC;exports.Sparkles=j0;exports.SqlEditor=X_t;exports.Square=zO;exports.SquarePen=$O;exports.Star=JZ;exports.StructuralParticipantSelector=ope;exports.SummaryCard=oF;exports.TABLE_PRESENTATION_DEFAULT_STYLE=Ld;exports.TABLE_PRESENTATION_DEFAULT_TOTALS_STYLE=xa;exports.TableBody=Qd;exports.TableCell=Kn;exports.TableColumnVisibilitySettings=$pe;exports.TableHead=wo;exports.TableHeader=tp;exports.TablePresentationSettings=Bpe;exports.TableRow=Lr;exports.TableSkeleton=fz;exports.TableVisual=ef;exports.Tag=eX;exports.TbChartBubble=gxe;exports.TbChartFunnel=bxe;exports.TbChartTreemap=xxe;exports.TextCard=ib;exports.Textarea=Um;exports.TiSortNumerically=vxe;exports.Toggle=Uxe;exports.Tornado=tX;exports.Trash2=il;exports.TriangleAlert=Yo;exports.TypeGlyph=nC;exports.UXProvider=rB;exports.Undo2=nX;exports.User=VO;exports.Users=Hk;exports.UsersRound=HO;exports.VisualErrorState=Uue;exports.Zap=ER;exports.applyBriefingFormPatch=hv;exports.areContextEntitiesEqual=cr;exports.areEntitiesJoined=noe;exports.arrayMove=cx;exports.briefingFormDraftToCreateRequest=mF;exports.briefingFormDraftToUpdateRequest=Vde;exports.briefingToFormDraft=sg;exports.briefingTone=Er;exports.buildCardControlUsageById=wbt;exports.buildCustomCardTheme=Vw;exports.buildDashboardControlUsageById=vbt;exports.buildDashboardSheetsInputExecutionSnapshot=_O;exports.buildDashboardStructuralParticipantIdsByControlId=dpe;exports.buildFilterFieldMeta=o4;exports.buildFilterSemanticContext=s4;exports.buildInlineFilterNodes=U$;exports.buildMultiInputCustomVisualProps=W$;exports.buildMultiInputTemporalPresentationInputs=K$;exports.calculateCardFilterValues=gI;exports.calculateContextAwareFilters=bI;exports.calculateFieldState=r3;exports.canEditLocalCalculatedFields=p4;exports.canUserAccessVisuals=TNe;exports.canUserCreateDashboards=cJ;exports.canUserEdit=kNe;exports.canUserManageDashboards=_Ne;exports.canUserManageGroups=ENe;exports.canUserUseFilters=INe;exports.cancelBriefingPreviewRun=Ede;exports.cancelBriefingRun=Mde;exports.cancelExport=$$e;exports.chartSupportsDataLabels=Yne;exports.chartSupportsLegend=Kne;exports.chartTypes=KT;exports.cleanupKpiMetricComparisonMode=hme;exports.cloneDeep=Ys;exports.cloneLinkedFrameWithSourceMapping=Ptt;exports.closestCenter=iC;exports.commitSharedCalculatedFields=rh;exports.createAssistantConversationId=Gp;exports.createAssistantRequestId=Wbe;exports.createBriefing=Cde;exports.createBriefingFormDraft=hF;exports.createChartConfig=Rb;exports.createCustomVisualTemporalBucketFormatter=G$;exports.createDashboardControlInputFromControl=v0t;exports.createExport=yoe;exports.currencyPresentationTargetKey=Ca;exports.dedup=_jt;exports.dedupeContextEntities=Vz;exports.deleteBriefing=jde;exports.deleteBriefingRun=Rde;exports.diagnoseCurrencyPresentationBindings=q0e;exports.doesStoredFilterMatchField=fb;exports.downloadDocumentPdf=aL;exports.downloadPdf=cte;exports.extractSqlParamReferences=KY;exports.extractTableMetadata=r4;exports.fieldAlreadyExists=ooe;exports.flexRender=wi;exports.flushPendingEditorDrafts=sB;exports.formatDisplayFormula=gpt;exports.formatFileSize=V$e;exports.getAutoDetectedChartIcon=oIt;exports.getBriefing=wde;exports.getBriefingArtifact=Fnt;exports.getBriefingEvidence=Ont;exports.getBriefingPreviewRun=Tde;exports.getBriefingRun=Dde;exports.getCardCurrencyPresentationFields=jO;exports.getCardCurrencyPresentationTargets=kO;exports.getChartGridStyle=FDe;exports.getChartIconByType=sIt;exports.getColorForValue=XR;exports.getCoreRowModel=u_;exports.getDefaultAxisConfig=nA;exports.getDefaultChartColors=Zm;exports.getDefaultDataLabelsConfig=yw;exports.getDefaultLegendConfig=$L;exports.getDefaultRunningTotalPartitionByFieldIds=b0;exports.getDisplayedKpiResultColumnKeys=Cw;exports.getDocumentSectionEditorCard=Jgt;exports.getDocumentSheetDashboardInputs=fx;exports.getDownloadUrl=L$e;exports.getEntityIcon=Rk;exports.getErrorMessage=Mbe;exports.getExportStatus=O$e;exports.getExports=F$e;exports.getExpressionFieldKind=lf;exports.getFieldExpressionAnnotation=i4;exports.getFilterCount=Zj;exports.getGranularityOptionsForFieldType=npe;exports.getKeys=Cr;exports.getMatrixVisualLoadingState=a_;exports.getMetricDisplayLabel=Q3e;exports.getNewField=coe;exports.getObjectDiff=jY;exports.getPaginationRowModel=d_;exports.getRoleBasedDisplayOverrides=lJ;exports.getRunningTotalOrderByCandidates=$mt;exports.getSelectedDateFilterColumn=due;exports.getSortedRowModel=Boe;exports.getTableConditionalFormattingColumnOptions=Upe;exports.getTableOutputColumnOptions=Wpe;exports.getTablePageSizeOptions=boe;exports.handleAggregationChange=lF;exports.handleAggregationLabelChange=rde;exports.hasFlatTableTotalsBehavior=Ym;exports.hasMatrixResultData=Nw;exports.horizontalListSortingStrategy=Gz;exports.inferSemanticDomainIdFromSelectedEntities=Mk;exports.isActiveBriefingRunStatus=tk;exports.isCardSummaryVisibleOnCard=Y$;exports.isCurrencyPresentationControl=V0e;exports.isDefaultColor=eEe;exports.isEligibleFlatTableTotalsCard=dw;exports.isExportComplete=B$e;exports.isExportInProgress=z$e;exports.isInAiScopeArray=Ijt;exports.isManagedCalculatedExpressionField=ol;exports.isMetricTransformEnabled=Omt;exports.isPresentationCurrencyBinding=Kv;exports.isPromiseLike=sO;exports.isSqlBackedKpi=uoe;exports.isStructuralControlBinding=B0e;exports.isSubtotalEnabledAggregateTable=n4;exports.isSupportedDocumentTableCardType=ebt;exports.isTableType=CDe;exports.isTerminalBriefingRunStatus=ek;exports.lastAssistantMessageIsCompleteWithToolCalls=_be;exports.listBriefingRuns=Pnt;exports.listBriefingTenantSummaries=Ant;exports.listBriefings=Rnt;exports.merge=sc;exports.mergeAxisConfig=rA;exports.normalizeConditionalFormatting=H5;exports.normalizeContextFormatMode=Oee;exports.pauseBriefing=Sde;exports.pivotData=hw;exports.polishBriefingText=Ade;exports.prepareFeedbackData=WT;exports.previewBriefingPlan=Ide;exports.remarkGfm=Lz;exports.removeFromScopeArray=Tjt;exports.requiresDashboardInputResolution=hf;exports.resolveCurrencyPresentationTargetFormat=Bee;exports.resolveDashboardBriefingsVisibility=uhe;exports.resolveDashboardControlsVisibility=ANe;exports.resolveDashboardInputContext=Ti;exports.resolveDashboardTitleEditability=RNe;exports.resolveDomainCalculatedFieldForEdit=dgt;exports.resolveMatrixCardMeasureInstances=zk;exports.resolvePendingPivotTableResultState=k$e;exports.resolveTablePageSize=o_;exports.resolveTablePresentationStyle=N3;exports.resumeBriefing=Nde;exports.runBriefingNow=kde;exports.runBriefingPreview=_de;exports.sanitizeAIScope=Dbe;exports.saveCalculatedFieldToCardScope=$F;exports.saveCalculatedFieldToSharedScope=zme;exports.saveCalculatedFieldToSheetScope=zF;exports.seedSemanticMetricFormatDefaults=pme;exports.setTableColumnVisibility=Coe;exports.setupEditorWithCard=RI;exports.showAllTableColumns=Q$e;exports.showJoinRequiredNotification=roe;exports.sortByColumnsToSortState=use;exports.sortStateToSortByColumns=dse;exports.sortableKeyboardCoordinates=Zz;exports.supportsLiveNumericPresentation=Wv;exports.supportsMetricTransformForMetric=mme;exports.supportsTableConditionalFormatting=Vpe;exports.toEntityArray=rl;exports.ue=it;exports.updateBriefing=tT;exports.useActiveExports=zNe;exports.useActiveToolStatus=dxe;exports.useAddFrameWithFreshSemanticExecutionPayload=cz;exports.useAddNewFrame=vhe;exports.useAssistantContainer=hJ;exports.useAssistantContextEntities=uT;exports.useAssistantLayoutStore=Fh;exports.useAssistantPanel=dJ;exports.useAssistantProfile=Kbe;exports.useAutoSubmitQueue=uxe;exports.useBrandStudioPreview=h_t;exports.useBriefingRunPolling=gF;exports.useBriefingUiCapabilities=dhe;exports.useCalendarContext=c$e;exports.useCard=g$e;exports.useCardNumericPresentation=Pa;exports.useCardSummary=Z$;exports.useChartNumericPresentation=Ab;exports.useChat=Ebe;exports.useColumns=Jz;exports.useCreateVisualWithFrame=kSe;exports.useCurrentUserInfo=si;exports.useCustomVisual=_f;exports.useCustomVisualsQuery=V$;exports.useDashboardAppearance=$u;exports.useDashboardById=lQ;exports.useDashboardInteractionMode=ede;exports.useDashboardPreferences=Hm;exports.useDashboardQuery=Uv;exports.useDashboardStructuralParticipants=fpe;exports.useDashboardSummary=Oue;exports.useDataColumns=bme;exports.useDateFilterHook=TYe;exports.useDefaultDashboardMutation=tQ;exports.useDisplayPreferences=pl;exports.useDroppable=Hhe;exports.useEditorAside=NT;exports.useEditorCardQuery=Nb;exports.useEffectiveEditorCardType=iB;exports.useEnsureReactGlobals=Ple;exports.useExportActions=mJ;exports.useExportStore=nI;exports.useFieldManagement=gme;exports.useFilterableFields=ume;exports.useFullscreenAssistant=fJ;exports.useGroupMembers=_1e;exports.useGroups=s5;exports.useHasDashboardId=pJ;exports.useInProgressExportsCount=BNe;exports.useJoinabilityMap=t4;exports.useManagementActions=Om;exports.useManagementStore=Es;exports.useMutation=Ts;exports.usePivotTableConfig=Jm;exports.usePluginQuery=Sue;exports.useQuery=qn;exports.useQueryClient=Zr;exports.useReactTable=f_;exports.useResolveExistingFrameSemanticExecutionPayload=$tt;exports.useResolvedDefaultCurrency=i3;exports.useResolvedTemporalStylePreferences=xl;exports.useResolvedValueFormatLocale=s3;exports.useResourceManagement=e5;exports.useResourceUpdateState=cQ;exports.useScopedFields=cme;exports.useSelectedVisual=I0e;exports.useSemaphorContext=It;exports.useSensor=db;exports.useSensors=mT;exports.useSortable=ux;exports.useStarredChartsStore=lTt;exports.useSurfaceAppearance=ml;exports.useTableQueryState=tse;exports.useTextFilterHook=sWe;exports.useTheme=NY;exports.useTimezone=bl;exports.useTopoJson=ww;exports.useUnifiedUsers=eI;exports.useUpdateResource=oQ;exports.useUpdateVisualMutation=ISe;exports.useUserPreferences=DQ;exports.useVisualById=Yk;exports.useVisualManagement=jSe;exports.validateBriefingFormDraft=pF;exports.validateFieldForChartType=fme;exports.verticalListSortingStrategy=Yz;
1392
+ `).trim(),k=j.map((T,_)=>{var M,P;let E="",D;if((M=T.url)!=null&&M.startsWith("data:")){const A=T.url.match(/data:[^;]+;base64,(.+)/);A&&(E=A[1],(P=T.mediaType)!=null&&P.startsWith("image/")&&(D=T.url))}return{id:`${e.id||t}-file-${_}`,name:T.filename||`File ${_+1}`,size:0,type:T.mediaType||"application/octet-stream",data:E,preview:D}});return l.jsx(DIt,{text:I||void 0,files:k.length>0?k:void 0})}const f=((C=e.parts)==null?void 0:C.filter(S=>S.type==="reasoning"))||[],h=f.length>0,m=f.some(S=>S.state==="streaming"),g=f.filter(S=>S.text&&S.text.trim().length>0),x=h&&(g.length>0||m)?l.jsxs(ku,{className:"space-y-2",defaultOpen:!1,children:[l.jsx(Iu,{asChild:!0,children:l.jsxs("button",{type:"button",className:"group inline-flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground",children:[l.jsx(Mt.ChevronRight,{className:"h-3 w-3 transition-transform duration-200 group-data-[state=open]:rotate-90"}),l.jsx("span",{className:m?"animate-pulse":"",children:m?"Reasoning":"Show reasoning"}),g.length>1&&l.jsxs("span",{className:"font-mono tabular-nums text-muted-foreground/70",children:["(",g.length," steps)"]})]})}),l.jsx(_u,{children:l.jsx("ol",{className:"space-y-2 border-l border-border/60 pl-3",children:g.map((S,j)=>l.jsxs("li",{className:"relative",children:[l.jsx("span",{className:"absolute -left-[15px] top-[3px] grid h-4 w-4 place-items-center rounded-full bg-muted font-mono text-[9px] text-muted-foreground",children:j+1}),l.jsx(KG,{className:"text-[12px] leading-[1.55] text-muted-foreground",text:S.text})]},`${e.id||t}-reasoning-${j}`))})})]},`${e.id||t}-reasoning`):null,b=(N=e.parts)==null?void 0:N.map((S,j)=>{var k;const I=`${e.id||t}-${j}`;switch(S.type){case"text":{const T=typeof S.text=="string"?S.text:JSON.stringify(S.text??"",null,2);if(e.role==="assistant"){const{cleanedText:_,quickReplies:E}=IIt(T),D=_.trim().length>0;return l.jsxs("div",{className:"space-y-2.5",children:[D&&l.jsx(KG,{text:_,handleRun:i,onAddToDashboard:o,messageId:e.id,messages:n}),E.length>0&&a&&d&&l.jsxs("div",{className:"space-y-1.5",children:[E.length>=3&&l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Suggested next steps"}),l.jsx("div",{className:"flex flex-wrap gap-1",children:E.map(({label:M,value:P},A)=>l.jsxs(p.Tooltip,{children:[l.jsx(p.TooltipTrigger,{asChild:!0,children:l.jsx(p.Button,{size:"sm",variant:"outline",className:"h-6 max-w-[220px] rounded-control border-border/60 bg-background px-2 text-[11px] font-normal text-foreground/85 transition-colors hover:border-border hover:bg-muted/40 hover:text-foreground disabled:opacity-50",disabled:c,onClick:()=>a(P),children:l.jsx("span",{className:"truncate",children:M})})}),l.jsx(p.TooltipContent,{side:"top",align:"center",children:l.jsx("p",{className:"max-w-xs text-xs",children:P})})]},`${I}-qr-${A}`))})]})]},I)}return e.role==="system"&&s?l.jsx(MIt,{text:T},I):null}case"error":{const T=S,_=T.errorText??T.error??T.message;return l.jsx("div",{className:"my-4",children:l.jsx(nB,{errorMessage:_})},I)}case"reasoning":return null;default:return((k=S.type)!=null&&k.startsWith("tool-")||S.type==="dynamic-tool")&&tB(S,r)?l.jsx(_i,{FallbackComponent:({error:T,resetErrorBoundary:_})=>l.jsx(EIt,{error:T,resetErrorBoundary:_}),children:l.jsx(CIt,{part:S,idx:I,messageId:e.id,showTools:r,onAddToDashboard:o,messages:n})},I):null}});return e.role==="assistant"?_xe(e,r)?l.jsxs(Ixe,{who:"Assistant",className:"space-y-2",children:[x,b]}):null:l.jsxs("div",{className:"space-y-2",children:[x,b]})}const FIt=8,OIt=24,LIt=20;function $It(e,t,n,r){return e==="error"&&t?!0:r?!1:!!(n||e==="submitted"||e==="streaming")}function Txe({messages:e,showTools:t=!1,showSystemMessage:n=!1,handleRun:r,onAddToDashboard:o,onQuickReply:s,disableQuickReplies:i=!1,status:a,errorMessage:c,activeToolText:u,className:d,rowContentClassName:f,statusClassName:h,latestButtonClassName:m,scrollToEndSignal:g=0}){const x=v.useRef(null),b=v.useRef(null),y=v.useRef(e.length),w=v.useRef(!1),C=v.useRef(null),N=v.useRef(!1),S=v.useRef(g),[j,I]=v.useState(!0),[k,T]=v.useState(0),[_,E]=v.useState(OIt);S.current!==g&&(S.current=g,N.current=!0);const D=e[e.length-1],M=_xe(D,t),P=$It(a,c,u,M),A=v_({count:e.length,getScrollElement:()=>x.current,estimateSize:H=>{const R=e[H];return(R==null?void 0:R.role)==="user"?88:180},getItemKey:H=>{const R=e[H];return(R==null?void 0:R.id)||`message-${H}`},anchorTo:"end",followOnAppend:!0,scrollEndThreshold:FIt,overscan:6,gap:20,paddingEnd:P?_+LIt:0,useAnimationFrameWithResizeObserver:!0,onChange:H=>{const R=H.isAtEnd();I(V=>V===R?V:R),R&&T(0)}}),L=v.useCallback((H="smooth")=>{C.current!==null&&cancelAnimationFrame(C.current),C.current=requestAnimationFrame(()=>{C.current=null,A.scrollToEnd({behavior:H})}),T(0),I(!0)},[A]);v.useLayoutEffect(()=>{w.current||(w.current=!0,L("auto"))},[L]),v.useLayoutEffect(()=>{N.current&&(N.current=!1,L("auto"))},[e.length,g,L]),v.useEffect(()=>{const H=y.current;y.current=e.length,e.length>H&&!A.isAtEnd()&&T(R=>R+e.length-H),e.length===0&&(T(0),I(!0),w.current=!1,N.current=!1)},[e.length,A]);const O=A.getVirtualItems(),B=A.getTotalSize();return v.useEffect(()=>()=>{C.current!==null&&cancelAnimationFrame(C.current)},[]),v.useLayoutEffect(()=>{const H=b.current;if(!H||!P)return;const R=()=>{const z=Math.ceil(H.getBoundingClientRect().height);z>0&&E(F=>F===z?F:z)};if(R(),typeof ResizeObserver>"u")return;const V=new ResizeObserver(R);return V.observe(H),()=>V.disconnect()},[P,a,c,u]),l.jsxs(l.Fragment,{children:[l.jsx(yl,{"data-role":"assistant-virtualized-scroll-area",ref:x,className:p.cn("min-h-0 min-w-0 flex-1 basis-0",d),children:l.jsxs("div",{className:"relative w-full",style:{height:B},children:[O.map(H=>{const R=e[H.index];return R?l.jsx("div",{ref:A.measureElement,"data-index":H.index,className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${H.start}px)`},children:l.jsx("div",{className:p.cn("min-w-0",f),children:l.jsx(PIt,{message:R,messageIndex:H.index,messages:e,showTools:t,showSystemMessage:n,handleRun:r,onAddToDashboard:o,onQuickReply:s,disableQuickReplies:i})})},H.key):null}),P&&l.jsx("div",{ref:b,className:p.cn("absolute left-0 top-0 w-full",h),style:{transform:`translateY(${Math.max(B-_,0)}px)`},children:l.jsx("div",{className:p.cn("min-w-0",f),children:l.jsx(RIt,{status:a,errorMessage:c,activeToolText:u})})})]})}),!j&&l.jsxs("button",{type:"button",onClick:()=>L("smooth"),"aria-label":"Scroll to latest",className:p.cn("absolute right-4 z-10 inline-flex h-7 items-center gap-1.5 rounded-full border border-border bg-background px-2.5 text-[11px] text-foreground shadow-[0_1px_2px_rgba(0,0,0,0.08)] transition-colors hover:bg-muted/40",m),children:[l.jsx(ss,{className:"h-3 w-3"}),"Latest",k>0&&l.jsx("span",{className:"grid h-4 min-w-[16px] place-items-center rounded-full bg-foreground px-1 font-mono text-[9px] tabular-nums text-background",children:k>9?"9+":k})]})]})}function zIt(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return"";const t=e;return(typeof t.userSql=="string"?t.userSql:"")||(typeof t.sourceSql=="string"?t.sourceSql:"")||(typeof t.sql=="string"?t.sql:"")}const BIt=[{title:"Show top 3 insights",subtitle:"from this dataset"},{title:"Create a bar chart for",subtitle:"sales by product category"}];function VIt({open:e,setOpen:t,isFullscreen:n,onFullscreenChange:r,fullscreenContainer:o}){const[s,i]=v.useState(!1),[a,c]=v.useState(ut.isDevEnv),[u,d]=v.useState(!1),[f,h]=v.useState("auto"),[m,g]=v.useState(!1),[x,b]=v.useState(!1),[y,w]=v.useState(0),C=n??x,{isLocalDev:N,isConsoleMode:S}=Hm(),j=N||S||a,I=v.useRef(null);p.useDashboardStore(se=>se.dashboard.aiScopeTables),p.useDashboardStore(se=>se.isDashboardEditing);const k=p.useDashboardStore(se=>se.selectedSheetId),{setDataSource:T}=p.useEditorActions(),{setSelectedFrameId:_,setIsDashboardEditing:E}=p.useDashboardActions(),D=cz(),{clearAssistantMessageContexts:M}=p.useAIActions(),{clearQueue:P}=p.useQueueActions(),{clearFileAttachments:A,getFileAttachments:L}=p.useFileActions(),O=p.useFileAttachments("dashboard"),B=p.useEditorStore(se=>se.card.dataSource),{assistantProfile:H}=Kbe(),R=p.useDashboardStore(se=>se.handleOpenAssistantProfile),{selectedEntities:V,applyDashboardDefaultEntities:z}=uT("dashboard"),{sendMessage:F,isLoading:G,messages:q,setMessages:Y,status:K,stop:$,errorMessage:X,clearError:W}=Kjt({dynamicVisualMode:f}),U=v.useCallback(()=>{w(se=>se+1)},[]),Z=v.useCallback(se=>{r==null||r(se),n===void 0&&b(se)},[n,r]),Q=v.useCallback(()=>{Z(!C)},[C,Z]);v.useEffect(()=>{if(!C)return;function se(he){he.key==="Escape"&&Z(!1)}return window.addEventListener("keydown",se),()=>{window.removeEventListener("keydown",se)}},[C,Z]);const[J,re]=v.useState(""),de=se=>{re(se.target.value)};async function le({sql:se,cardTitle:he,connectionId:ge,cardType:ke,python:De,cardConfig:Re,dataSource:Ve,customVisualPreferences:ve,visualizationMode:Ke,dynamicCardPreferences:qe}){if(!k)return;const et=Ke==="dynamic",ye=ut.hasValidCardConfig(Re),He=ge||(Ve==null?void 0:Ve.connectionId)||"",Pe=Ve?{...Ve,connectionId:He||Ve.connectionId,connectionType:Ve.connectionType||"",mode:Ve.mode||"database",selectedEntities:Ve.selectedEntities||[]}:He?{connectionId:He,connectionType:"",mode:"database",selectedEntities:[]}:mb,ze=!(ye&&(!et||(qe==null?void 0:qe.provenance)==="card-config"||(qe==null?void 0:qe.provenance)==="query_spec")),Ee=ze?zIt(se):"",Be=ze?De:"",st={id:ut.v4(),title:he||"Title",preferences:{onClickFilter:[{columnIndex:0,expression:""}],chartOptions:{indexAxis:ke==="horizontalBar"?"y":"x"},...et&&{displayOptions:{showChrome:!1,allowScroll:!1}}},type:ke,sql:Ee,python:Be,dataSource:Pe,config:Re,connectionId:He,visualizationMode:Ke,dynamicCardPreferences:qe,customCardPreferences:ve?{url:ve.url,componentName:ve.componentName,pluginChartType:ve.pluginChartType,settings:ve.settings,type:"component"}:void 0},lt={id:ut.v4(),cards:[st],activeCardId:st.id};try{await D(k,lt,"end"),E(!0),_(lt.id)}catch(rt){console.error("Failed to add assistant visual to dashboard:",rt),it.error(rt instanceof Error?rt.message:"Failed to prepare semantic metadata for the new visual")}}const ce=se=>{se.preventDefault();const he=J.trim();if(!he&&O.length===0)return;const ge=[];he&&ge.push({type:"text",text:he}),O.forEach(ke=>{ke.data&&ge.push({type:"file",mediaType:ke.type,filename:ke.name,url:`data:${ke.type};base64,${ke.data}`})}),F({role:"user",parts:ge}),re(""),A("dashboard"),U()};v.useEffect(()=>{var se;e&&((se=I.current)==null||se.focus())},[e]),uxe({assistantType:"dashboard",status:K,isLoading:G,sendMessage:F});const{hasActiveTools:oe,activeToolText:fe}=dxe(q);function we(se){const he={role:"user",parts:[{type:"text",text:se.title+" "+se.subtitle}]};F(he),U()}function pe(se){F({role:"user",parts:[{type:"text",text:se}]}),U()}function ne(se){F({role:"user",parts:[{type:"text",text:se}]}),U()}const Se=v.useCallback(async()=>{const se=JSON.stringify(q??[],null,2);try{if(typeof navigator>"u"||!navigator.clipboard)throw new Error("Clipboard API unavailable");await navigator.clipboard.writeText(se),it.success("Conversation copied")}catch(he){console.error("Failed to copy conversation",he),it.error("Unable to copy conversation")}},[q]),ue=(J==null?void 0:J.length)===0&&(q==null?void 0:q.filter(se=>se.role==="user").length)===0;function ie(){return l.jsx("div",{"data-role":"header",className:"flex items-center gap-2",children:l.jsx("span",{className:"text-[13px] font-medium text-foreground",children:"Assistant"})})}function ee(){return l.jsxs(Xo,{children:[l.jsx(Qo,{asChild:!0,children:l.jsx(au,{className:"h-7 p-2 text-muted-foreground hover:text-foreground",children:l.jsx($m,{className:"size-3.5"})})}),l.jsxs(Fo,{align:"end",children:[l.jsx(Za,{children:"Options"}),l.jsx(Ta,{}),l.jsx(ad,{checked:s,onCheckedChange:i,children:"Token Usage"}),l.jsx(ad,{checked:a,onCheckedChange:c,children:"Tool Invocations"}),l.jsx(ad,{checked:u,onCheckedChange:d,children:"System Message"}),(N||S)&&l.jsxs(l.Fragment,{children:[l.jsx(Ta,{}),l.jsx(Za,{children:"Dynamic Visuals"}),l.jsx(ad,{checked:f==="auto",onCheckedChange:()=>h("auto"),children:"Auto"}),l.jsx(ad,{checked:f==="force",onCheckedChange:()=>h("force"),children:"Force Dynamic"}),l.jsx(ad,{checked:f==="off",onCheckedChange:()=>h("off"),children:"Disable Dynamic"})]})]})]})}const ae=l.jsxs("div",{"data-role":"dashboard-assistant",className:p.cn("relative flex h-full grow flex-col break-words bg-background",C&&"rounded-card border border-border/60 shadow-xl"),children:[l.jsxs("header",{"data-role":"header-section",className:"flex h-10 shrink-0 items-center gap-2 border-b border-border/60 px-3",children:[ie(),R&&l.jsxs("button",{type:"button",onClick:R,className:"inline-flex h-6 items-center gap-1 rounded-[4px] border border-border/60 bg-muted/40 px-1.5 text-[11px] text-muted-foreground transition-colors hover:border-border hover:text-foreground",title:"Edit assistant profile",children:[l.jsx("span",{className:"h-1 w-1 rounded-full bg-muted-foreground/60"}),l.jsx("span",{className:"max-w-[180px] truncate",children:(H==null?void 0:H.name)||"Default profile"})]}),l.jsxs("div",{"data-role":"header-actions",className:"ml-auto flex items-center gap-0.5",children:[S&&ee(),j&&l.jsx(p.Button,{variant:"ghost",size:"sm",className:"h-6 px-1.5 text-[11px] text-muted-foreground hover:text-foreground",onClick:Se,children:"Copy Conversation"}),l.jsx(au,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:C?"Exit fullscreen":"Expand",onClick:Q,children:C?l.jsx(Mt.Minimize2,{className:"h-3.5 w-3.5"}):l.jsx(Mt.Maximize2,{className:"h-3.5 w-3.5"})}),l.jsx(au,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:"New chat",onClick:()=>{const se=q.filter(he=>he.role==="assistant").map(he=>he.id).filter(he=>!!he);Y([]),P("dashboard"),W(),M(se)},children:l.jsx($O,{className:"h-3.5 w-3.5"})}),l.jsx(au,{className:"grid h-6 w-6 place-items-center rounded-[4px] p-0 text-muted-foreground hover:bg-muted hover:text-foreground",tooltip:"Close",onClick:()=>{t(!1)},children:l.jsx(Ie.X,{className:"h-3.5 w-3.5"})})]})]}),l.jsx(Txe,{messages:q,showTools:a,showSystemMessage:u,onAddToDashboard:le,onQuickReply:ne,disableQuickReplies:G,status:K,errorMessage:X,activeToolText:G&&oe?fe:void 0,className:p.cn(C?"px-6 py-5":"px-3 py-3"),rowContentClassName:p.cn(C&&"mx-auto w-full max-w-[680px]"),latestButtonClassName:e?"bottom-[148px]":"hidden",scrollToEndSignal:y}),l.jsxs("div",{className:"shrink-0 space-y-2 border-t border-border/60 px-3 pb-3 pt-2",children:[!H&&ue&&l.jsx(Nge,{onClick:we,placeholders:BIt}),ue&&H&&l.jsx(Gbe,{seedQuestions:H.seedQuestions||[],handleSeedQuestionClick:pe}),l.jsx(cxe,{assistantType:"dashboard"}),l.jsx(eB,{ref:I,setInput:re,stop:$,input:J,handleInputChange:de,handleSubmit:se=>{ce(se)},isLoading:G,status:K,assistantType:"dashboard",onFocus:()=>{}})]}),l.jsx(J4,{incomingSelectedEntities:V,open:m,onOpenChange:g,dataSource:B||mb,dialogMode:"aiContext",saveAsDashboardDefault:!0,onSaveSelectedEntities:se=>z()})]});return C&&o?vr.createPortal(l.jsx(nx,{className:"pointer-events-auto absolute inset-0 z-50 flex bg-background/95 px-4 pb-4 pt-[calc(var(--app-header-height,15px)+0.5rem)] backdrop-blur-sm",children:l.jsx("div",{className:"flex h-full w-full",children:ae})}),o):ae}function HIt(e){const t=e.current,{getSelectedFrame:n,setSelectedFrameId:r}=p.useDashboardActions(),o=Jue(),s=p.useDashboardStore(d=>d.dashboard.sheets),a=p.useDashboardStore(d=>d.selectedSheetId)??(s==null?void 0:s[0].id),c=p.useDashboardStore(d=>d.isDashboardEditing),u=p.useDashboardStore(d=>d.isVisualEditing);v.useEffect(()=>{if(!c||u)return;async function d(m){if(qIt(m.target))return;const g=m.ctrlKey||m.metaKey;g&&m.key==="c"?(await f(),it.success("Card copied to clipboard"),m.preventDefault()):g&&m.key==="v"&&(await h(),m.preventDefault())}async function f(){try{const m=n();m&&await navigator.clipboard.writeText(JSON.stringify(m))}catch(m){console.error("Failed to copy text:",m)}}async function h(){if(!a)return null;try{const m=await navigator.clipboard.readText(),g=UIt(m);if(g!=null&&g.id){const x=Zue(g),b=x.cards.findIndex(y=>y.id===x.activeCardId);b!==-1&&(x.cards[b].title=`${x.cards[b].title} (Copy)`),await o(a,x),r(x.id),it.success("Card pasted from clipboard")}return m}catch(m){return console.error("Failed to paste text:",m),null}}return t==null||t.addEventListener("keydown",d),()=>t==null?void 0:t.removeEventListener("keydown",d)},[o,n,r,a,c,u,t])}function qIt(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;const t=e.closest("[contenteditable]");return t&&t.getAttribute("contenteditable")!=="false"?!0:!!e.closest('input, textarea, select, [role="textbox"]')}function UIt(e){try{const t=JSON.parse(e);return t&&typeof t=="object"&&typeof t.id=="string"&&Array.isArray(t.cards)?t:null}catch{return null}}function WIt(e,t){switch(e.interactionMode){case"drillToDetail":KIt(e,t);break;case"drillThrough":GIt(e,t);break;case"drillToURL":YIt(e);break;case"inlineDrill":console.warn("Inline drill execution not yet implemented");break;case"clickFilter":case"drillDown":case"dynamicDrill":break;default:console.warn("Unknown interaction mode:",e.interactionMode)}}function KIt(e,t){var c;const{targetInsightId:n,contextMode:r,displayMode:o,filterGroups:s}=e;if(!n){console.warn("drillToDetail event missing targetInsightId");return}const i=r||"full";let a=[];switch(i){case"interactionFilters":a=s.flatMap(u=>u.filters);break;case"full":{const u=((c=t.getCurrentFilters)==null?void 0:c.call(t))||[],d=s.flatMap(f=>f.filters);a=[...u,...d];break}case"none":default:a=[];break}o==="replace-card"?t.replaceCardContent({cardId:e.sourceCardId,insightId:n,filters:a,contextMode:r}):t.openInsightModal({insightId:n,filters:a,contextMode:r})}function GIt(e,t){var u,d;const{targetDashboardId:n,contextMode:r="interactionFilters",filterGroups:o,sourceCardId:s}=e;if(!n){console.warn("[DrillThrough] Event missing targetDashboardId. This interaction needs to be reconfigured with a target dashboard.",e);return}const i=o.flatMap(f=>f.filters),a=((u=t.getCurrentDashboardId)==null?void 0:u.call(t))||"",c=(d=t.getCurrentDashboardTitle)==null?void 0:d.call(t);t.setGlobalDrillContext&&t.setGlobalDrillContext({filters:i,contextMode:r,sourceDashboardId:a,sourceDashboardTitle:c,targetDashboardId:n}),t.setPendingDrillThrough&&t.setPendingDrillThrough({targetDashboardId:n,sourceDashboardId:a,sourceDashboardTitle:c,filters:i,contextMode:r})}function YIt(e){const{url:t}=e;if(!t){console.warn("drillToURL event missing url");return}try{new URL(t)}catch(n){console.error("Invalid URL:",t,n);return}window.open(t,"_blank","noopener,noreferrer")}function ZIt({open:e,onOpenChange:t,insightId:n,filters:r,filterDefinitions:o,contextMode:s,cardTitle:i,cardDescription:a}){return l.jsx(So,{open:e,onOpenChange:t,children:l.jsxs(po,{className:"flex max-h-[90vh] max-w-[90vw] flex-col gap-0 overflow-hidden p-0",children:[l.jsxs(Ds,{className:"space-y-1 border-b border-border px-5 pb-3.5 pt-4 text-left",children:[l.jsx(go,{className:"text-[15px] font-semibold tracking-tight",children:i||"Insight detail"}),l.jsx(Oo,{className:"text-[12px] leading-[1.5] text-muted-foreground",children:a||"View detailed insight data with applied filters"})]}),l.jsx(ode,{filters:r,filterDefinitions:o,contextMode:s}),l.jsx("div",{className:"h-[400px] min-h-0 flex-1 overflow-auto px-5 py-4",children:n?l.jsx(mhe,{insightId:n,filters:r,contextMode:s}):l.jsx("div",{className:"flex items-center justify-center p-12 text-[13px] text-muted-foreground",children:"No insight selected"})})]})})}function XIt(){const e=p.useInteractionStore(N=>N.interactionStates),t=p.useInteractionStore(N=>N.setInteractionState),n=p.useInteractionStore(N=>N.clearLastInteractionEvent),r=p.useInteractionStore(N=>N.replaceCardWithInsight),o=p.useInteractionStore(N=>N.setPendingDrillThrough),s=p.useInteractionStore(N=>N.pendingDrillThrough),i=p.useInteractionStore(N=>N.clearPendingDrillThrough),{setSelectedSheetId:a,navigateWithDrill:c}=p.useDashboardActions(),{selectDashboard:u}=Om(),d=p.useDashboardStore(N=>N.dashboard),f=p.useDashboardStore(N=>N.filterValues),{data:h,isLoading:m}=lQ((s==null?void 0:s.targetDashboardId)||"",{enabled:!!(s!=null&&s.targetDashboardId)}),[g,x]=v.useState({open:!1,insightId:""}),b=phe(g.insightId,{enabled:g.open&&!!g.insightId}),y=v.useRef(new Set),w=v.useMemo(()=>({setSelectedSheetId:a,openInsightModal:({insightId:N,filters:S,contextMode:j})=>{x({open:!0,insightId:N,filters:S,filterDefinitions:(d==null?void 0:d.filters)||[],contextMode:j})},replaceCardContent:({cardId:N,insightId:S,filters:j,contextMode:I})=>{r(N,S,j,I)},getCurrentFilters:()=>f||[],navigateWithDrill:c,getCurrentDashboardId:()=>(d==null?void 0:d.id)||"",getCurrentDashboardTitle:()=>d==null?void 0:d.title,setPendingDrillThrough:o,setGlobalDrillContext:({filters:N,contextMode:S,sourceDashboardId:j,sourceDashboardTitle:I,targetDashboardId:k})=>{const T={filters:N},_={sourceCardId:p.DRILL_CONTEXT_CARD_ID,interactionMode:"clickFilter",filterGroups:[T]},E={...p.createInitialInteractionState(),appliedClickFilters:[_],contextMode:S,sourceDashboardId:j,sourceDashboardTitle:I,targetDashboardId:k};t(p.DRILL_CONTEXT_CARD_ID,E)}}),[a,r,f,c,d,o,t]);v.useEffect(()=>{Object.entries(e).forEach(([N,S])=>{if(S!=null&&S.lastInteractionEvent){const j=S.lastInteractionEvent,I=`${N}-${j.interactionMode}-${j.sourceCardId}-${Date.now()}`;if(y.current.has(I))return;y.current.add(I);try{WIt(j,w)}catch(k){console.error("Error executing interaction event:",k)}finally{n(N),setTimeout(()=>{y.current.delete(I)},5e3)}}})},[e,n,w]),v.useEffect(()=>{if(!(!s||!h||m))try{u(h),c(s.targetDashboardId,s.sourceDashboardId,s.sourceDashboardTitle,s.filters,s.contextMode),i()}catch(N){console.error("[DrillThrough] Error during automatic navigation:",N),i()}},[s,h,m,u,c,i]);const C=()=>{x({open:!1,insightId:""})};return l.jsxs(l.Fragment,{children:[l.jsx(ZIt,{open:g.open,onOpenChange:C,insightId:g.insightId,filters:g.filters,filterDefinitions:g.filterDefinitions,contextMode:g.contextMode,cardTitle:b.title,cardDescription:b.description}),s&&m&&l.jsx("div",{className:"fixed inset-0 z-[51] flex items-center justify-center bg-background/80 backdrop-blur-sm",children:l.jsxs("div",{className:"flex flex-col items-center gap-2.5 rounded-[6px] border border-border/60 bg-background px-4 py-3 shadow-sm",children:[l.jsx(p.LoaderCircle,{className:"h-5 w-5 animate-spin text-muted-foreground/60"}),l.jsx("div",{className:"text-[12px] text-muted-foreground",children:"Loading dashboard..."})]})})]})}function QIt(e){return e.length===0?"":e.map(t=>{const n=t.field.label||t.field.name,r=t.operator,o=JIt(dz(t));return r==="="?`${n} = ${o}`:`${n} ${r} ${o}`}).join(", ")}function JIt(e){return e==null?"null":Array.isArray(e)?e.join(", "):typeof e=="object"&&e.toString?e.toString():String(e)}function e_t(e){return e?`Back to ${e}`:"Back"}function t_t(){var y,w,C,N,S;const e=p.useInteractionStore(j=>j.interactionStates[p.DRILL_CONTEXT_CARD_ID]),t=p.useDashboardStore(j=>j.actions.goBackFromDrill),n=p.useDashboardStore(j=>j.actions.clearDrillContext),{selectDashboard:r}=Om(),[o,s]=v.useState({x:16,y:16}),[i,a]=v.useState(!1),c=v.useRef({x:0,y:0});v.useEffect(()=>{if(!i)return;const j=k=>{s({x:k.clientX-c.current.x,y:k.clientY-c.current.y})},I=()=>{a(!1)};return document.addEventListener("mousemove",j),document.addEventListener("mouseup",I),()=>{document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",I)}},[i]);const u=e==null?void 0:e.sourceDashboardId,d=e==null?void 0:e.sourceDashboardTitle,f=((N=(C=(w=(y=e==null?void 0:e.appliedClickFilters)==null?void 0:y[0])==null?void 0:w.filterGroups)==null?void 0:C[0])==null?void 0:N.filters)||[],h=u?{id:u,title:d||"Previous Dashboard",description:"",isPrivate:!1,isPublic:!1,version:"",createdBy:null,createdByTenantUser:"",tenantId:"",projectId:"",createdAt:"",updatedAt:"",lastModified:"",lastModifiedBy:"",createdByUser:null,createdByTenantUserRel:{name:"",email:""},permissions:{canEdit:!0,canShare:!0,canDelete:!0},ownership:{status:"private",isOwner:!0,sharedCount:0,createdBy:{type:"user",userId:"",name:"",email:""}}}:null;if(!e||!((S=e.appliedClickFilters)!=null&&S.length))return null;const m=()=>{if(!h){console.warn("[DrillBack] No source dashboard in context");return}try{t(),r(h)}catch(j){console.error("[DrillBack] Error during back navigation:",j)}},g=()=>{n()},x=j=>{j.target.closest("button")||(a(!0),c.current={x:j.clientX-o.x,y:j.clientY-o.y})};QIt(f);const b=e_t(d);return l.jsx("div",{className:"fixed z-50 max-w-md",style:{left:0,top:0,transform:`translate(${o.x}px, ${o.y}px)`,transition:i?"none":void 0},children:l.jsxs("div",{className:"select-none rounded-lg border bg-background/95 p-3 shadow-lg backdrop-blur-sm",onMouseDown:x,style:{cursor:i?"grabbing":"grab"},children:[l.jsxs("div",{className:"mb-3 flex items-start justify-between gap-2",children:[l.jsxs("div",{className:"flex flex-col gap-2",children:[l.jsx("span",{className:"text-xs font-medium text-muted-foreground",children:"Viewing:"}),l.jsx("div",{className:"flex flex-wrap gap-2",children:f.map((j,I)=>{const k=j.field.label||j.field.name,T=String(j.value);return l.jsxs(yi,{variant:"secondary",className:"pointer-events-none text-xs",children:[k," = ",T]},I)})})]}),l.jsx(p.Button,{variant:"ghost",size:"sm",onClick:g,className:"h-6 w-6 cursor-pointer p-0",title:"Clear drill context",children:l.jsx(Ie.X,{className:"h-3 w-3"})})]}),l.jsx("div",{className:"flex items-center gap-2 border-t pt-2",children:l.jsxs(p.Button,{variant:"secondary",size:"sm",onClick:m,disabled:!h,className:"w-full cursor-pointer",children:[l.jsx(Yv,{className:"mr-2 h-4 w-4"}),b]})})]})})}function n_t(e,t){return typeof e=="boolean"?e:typeof t=="boolean"?t:!1}function r_t({filter:e,isEditing:t=!1,disabled:n=!1,storageOptions:r,settingsVariant:o,filterQueryContext:s,inputVariableName:i,reservedInputVariableNames:a,isDashboardFilterReference:c,onUpdateFilter:u,onRemoveFilter:d}){const{attributes:f,listeners:h,setNodeRef:m,transform:g,transition:x,isDragging:b}=ux({id:`filter:${e.id}`,disabled:n||!t}),y={transform:Ji.Translate.toString(g),transition:x,opacity:b?.5:1,zIndex:b?10:void 0};return l.jsx("div",{ref:m,style:y,...f,children:l.jsx(q$,{filter:e,isEditing:t,dragListeners:t?h:void 0,storageOptions:r,settingsVariant:o,filterQueryContext:s,inputVariableName:i,reservedInputVariableNames:a,isDashboardFilterReference:c,onUpdateFilter:u,onRemoveFilter:d})})}const nY="text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",o_t=[];function Exe({open:e,onOpenChange:t}){const[n,r]=v.useState(!1),[o,s]=v.useState(!1),[i,a]=v.useState({sheetSelection:"current",protectPdf:!1,password:""}),c=p.useDashboardStore(Y=>{var K;return(K=Y.dashboard)==null?void 0:K.sheets}),u=p.useDashboardStore(Y=>Y.dashboard),d=p.useDashboardStore(Y=>Y.dashboardInputValues),f=p.useDashboardStore(Y=>Y.filterValues),h=p.useDashboardStore(Y=>Y.controlValues),m=p.useDashboardStore(Y=>Y.inlineFilterValuesMap),g=p.useDashboardStore(Y=>Y.cardControlValuesMap),x=p.useDashboardStore(Y=>Y.selectedSheetId),b=p.useDashboardStore(Y=>Y.selectedSheetId?Y.documentInputRuntimeBySheetId[Y.selectedSheetId]:void 0),y=p.useDashboardStore(Y=>Y.isDownloadingPdf),w=p.useDashboardStore(Y=>Y.reportContext),{authToken:C,tokenProps:N}=It(),S=c==null?void 0:c.find(Y=>Y.id===x),j=v.useMemo(()=>p.getDashboardExportSheets(c),[c]),I=p.isDocumentSheet(S),k=I&&S?S.document:void 0,T=v.useMemo(()=>I&&S?fx(u,S.id):[],[S,I,u]),_=T.length>0,E=v.useMemo(()=>I&&S?Jpe(u,S.id):!1,[S,I,u]),D=v.useMemo(()=>_?T.map(pC):(k==null?void 0:k.inputs)||o_t,[k,T,_]),M=w==null?void 0:w.calendar.tz,P=v.useMemo(()=>Xme(D),[D]),A=v.useMemo(()=>Yme(D,M),[D,M]),L=v.useMemo(()=>Zme(D),[D]),O=b?b.filterValuesByInputId:A,B=b?b.controlValuesByInputId:L,H=v.useMemo(()=>I?E&&S&&k?fZ({dashboard:u,sheetId:S.id,sheetKind:"document",sectionIds:k.sections.map(Y=>Y.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:m,cardControlValuesMap:g},timezone:M}):epe(D,O,B,P,P):[],[k,D,S,I,u,g,h,f,m,d,B,O,P,M,E]),R=!!S,V=j.length>0,z=((c==null?void 0:c.length)||0)>1||I,F=i.sheetSelection==="current"&&(!R||I&&H.length>0)||i.sheetSelection==="all"&&!V;v.useEffect(()=>{e&&i.sheetSelection==="all"&&!V&&a(Y=>({...Y,sheetSelection:"current"}))},[V,e,i.sheetSelection]);const G=()=>{a({sheetSelection:"current",protectPdf:!1,password:""}),r(!1),t(!1)};async function q(){if(y){it.error("A PDF export is already in progress");return}if(i.protectPdf&&!i.password){it.error("Please enter a password to protect the PDF");return}if(i.sheetSelection==="current"&&!R){it.error("No sheet is selected to export");return}if(i.sheetSelection==="all"&&!V){it.error("No dashboard sheets are available to export");return}s(!0);const Y=i.sheetSelection==="current"&&I,K=Y?i.protectPdf?"Generating protected document PDF... may take up to 60 seconds":"Generating document PDF... may take up to 60 seconds":i.sheetSelection==="all"?"Generating PDF for all dashboard sheets... This may take a while.":i.protectPdf?"Generating protected PDF... may take up to 60 seconds":"Generating PDF... may take up to 60 seconds",$=it.loading(K);try{if(Y){if(!k||!S)throw new Error("Selected document sheet is missing document data");if(H.length>0){it.dismiss($),it.error(`Set ${H.join(", ")} before exporting`);return}const W=new Date().toISOString(),U=E?hZ({dashboard:u,sheetId:S.id,sheetKind:"document",sectionIds:k.sections.map(Z=>Z.id),mode:"document",runtimeValues:{dashboardInputValues:d,filterValues:f,controlValues:h,inlineFilterValuesMap:m,cardControlValuesMap:g},generatedAt:W,timezone:M}).snapshot:void 0;await aL(N.apiServiceUrl,C,{sheetId:S.id,title:S.title||"Document",pageSize:k.page.size,orientation:k.page.orientation,timezone:M,password:i.protectPdf?i.password:void 0,inputSnapshot:U,...U?{}:{inputValues:{sheetId:S.id,filterValuesByInputId:O,controlValuesByInputId:B,generatedAt:W}}})}else{const W=xoe();await cte(N.apiServiceUrl,C,i.protectPdf?i.password:void 0,i.sheetSelection,W)}it.dismiss($);const X=Y?i.protectPdf?"Protected document PDF downloaded successfully!":"Document PDF downloaded successfully!":i.sheetSelection==="all"?"Dashboard sheets PDF downloaded successfully!":i.protectPdf?"Protected PDF downloaded successfully!":"PDF downloaded successfully!";it.success(X,{duration:2e3}),G()}catch(X){it.dismiss($),it.error("Failed to download PDF",{description:PI(X,"Please try again or contact support."),descriptionClassName:AI,closeButton:!0,duration:1/0,richColors:!0}),console.error("PDF download error:",X)}finally{s(!1)}}return l.jsx(So,{open:e,onOpenChange:Y=>{if(!Y){G();return}t(!0)},children:l.jsxs(po,{className:"rounded-control border-border/60 sm:max-w-[440px] sm:rounded-control",children:[l.jsxs(Ds,{children:[l.jsx(go,{className:"text-[15px]",children:I?"Export document":"Export dashboard"}),l.jsx(Oo,{className:"text-[13px] leading-5",children:I?"Export this document sheet as a PDF document.":"Export this dashboard as a PDF document."})]}),l.jsxs("div",{className:"space-y-4 py-1",children:[z&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(p.Label,{className:nY,children:"Export scope"}),l.jsxs(wu,{value:i.sheetSelection,onValueChange:Y=>a({...i,sheetSelection:Y}),className:"gap-1.5",children:[l.jsxs(p.Label,{htmlFor:"scope-current",className:p.cn("flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 text-[13px] font-normal hover:bg-muted/50",!R&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(Qs,{value:"current",id:"scope-current",disabled:!R}),I?"This document":"This sheet"," (",(S==null?void 0:S.title)||"Current",")"]}),l.jsxs(p.Label,{htmlFor:"scope-all",className:p.cn("flex cursor-pointer items-center gap-2 rounded-control px-1 py-1 text-[13px] font-normal hover:bg-muted/50",!V&&"cursor-not-allowed opacity-50 hover:bg-transparent"),children:[l.jsx(Qs,{value:"all",id:"scope-all",disabled:!V}),"Dashboard sheets (",j.length," ",j.length===1?"sheet":"sheets",")"]})]}),I&&l.jsx("p",{className:"text-[12px] leading-5 text-muted-foreground",children:H.length>0?`Set ${H.join(", ")} before exporting this document.`:'"Dashboard sheets" includes dashboard sheets only. Choose "This document" to export the selected document.'})]}),l.jsx(p.Separator,{className:"bg-border/60"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsxs(p.Label,{htmlFor:"protect-pdf",className:"flex cursor-pointer items-center gap-2 text-[13px] font-normal",children:[l.jsx(An,{id:"protect-pdf",checked:i.protectPdf,onCheckedChange:Y=>{a({...i,protectPdf:Y,password:Y?i.password:""}),Y||r(!1)}}),l.jsx(Xv,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Password protect PDF"]}),i.protectPdf&&l.jsxs("div",{className:"ml-6 space-y-1.5",children:[l.jsx(p.Label,{htmlFor:"pdf-password",className:nY,children:"Password"}),l.jsxs("div",{className:"relative",children:[l.jsx(p.Input,{id:"pdf-password",size:"xs",type:n?"text":"password",value:i.password,onChange:Y=>a({...i,password:Y.target.value}),placeholder:"Enter password",className:"pr-8",onKeyDown:Y=>{Y.key==="Enter"&&i.password&&q()}}),l.jsx("button",{type:"button",className:"absolute right-1 top-1/2 flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-control text-muted-foreground hover:bg-muted hover:text-foreground",onClick:()=>r(!n),"aria-label":n?"Hide password":"Show password",children:n?l.jsx(Vk,{className:"h-3.5 w-3.5"}):l.jsx(Mt.Eye,{className:"h-3.5 w-3.5"})})]}),l.jsx("p",{className:"text-[12px] text-muted-foreground",children:"Recipients will need this password to open the PDF."})]})]})]}),l.jsxs(al,{children:[l.jsx(p.Button,{variant:"outline",size:"xs",onClick:G,disabled:o,children:"Cancel"}),l.jsx(p.Button,{size:"xs",onClick:q,disabled:o||y||F,children:o?l.jsxs(l.Fragment,{children:[l.jsx(p.LoaderCircle,{className:"h-3.5 w-3.5 animate-spin"}),"Exporting…"]}):l.jsxs(l.Fragment,{children:[l.jsx(Tu,{className:"h-3.5 w-3.5"}),"Export"]})})]})]})})}function Dxe({iconClassName:e,open:t,onOpenChange:n}){const[r,o]=v.useState(!1),s=t!==void 0,i=s?t:r,a=u=>{s||o(u),n==null||n(u)},c=p.useDashboardStore(u=>u.isDownloadingPdf);return l.jsxs(l.Fragment,{children:[s?null:l.jsx(p.Button,{variant:"ghost",size:"sm",className:"h-7 p-2",disabled:c,onClick:()=>a(!0),children:l.jsx(Tu,{className:p.cn("size-4",e)})}),l.jsx(Exe,{open:i,onOpenChange:a})]})}function rY(e,t,n){const r=new Set(t),o=[...n];return e.map(s=>r.has(s.id)?o.shift()??s.id:s.id)}function s_t({control:e,value:t,isEditing:n=!1,onChange:r}){const{attributes:o,listeners:s,setNodeRef:i,transform:a,transition:c,isDragging:u}=ux({id:`control:${e.id}`,disabled:!n}),d={transform:Ji.Translate.toString(a),transition:c,opacity:u?.5:1,zIndex:u?10:void 0};return l.jsx("div",{ref:i,style:d,...o,children:l.jsx(bpe,{control:e,value:t,isEditing:n,dragListeners:n?s:void 0,onChange:r})})}function oY(e){var t;return(((t=e.values)==null?void 0:t.length)??0)>0||e.operation==="is null"||e.operation==="is not null"}function sY(e,t){return[...e.map(n=>`filter:${n.id}`),...t.map(n=>`control:${n.id}`)]}function i_t(e,t,n){const r=new Set([...t.map(a=>`filter:${a.id}`),...n.map(a=>`control:${a.id}`)]);if(!(e!=null&&e.length))return sY(t,n);const o=e.filter(a=>r.has(a)),s=new Set(o),i=sY(t,n).filter(a=>!s.has(a));return[...o,...i]}function a_t(e,t){return p.getDashboardCardEntries({sheets:e.sheets||[]}).filter(n=>n.sheet.id===t).map(n=>n.card.id)}function l_t(e){return nm(e.dashboardInput,{sheetId:e.selectedSheetId,sheetKind:"dashboard"})?!0:e.dashboardInput.scope.kind!=="cards"?!1:e.selectedSheetCardIds.some(t=>nm(e.dashboardInput,{sheetId:e.selectedSheetId,cardId:t,sheetKind:"dashboard"}))}function U2(e){var t;return((t=e.compatibility)==null?void 0:t.source)!=="dashboardFilter"}function c_t(e){return Mxe(e).filter(t=>{var n,r;return t.filter.hide||t.filter.location==="frame"?!1:((n=t.compatibility)==null?void 0:n.source)==="dashboardFilter"?!0:(((r=t.presentation)==null?void 0:r.placement)||"toolbar")==="toolbar"})}function Mxe(e){if(!e.selectedSheetId)return[];const t=e.selectedSheetId,n=a_t(e.dashboard,t);return Bk(pb({dashboard:e.dashboard}).allInputs).filter(r=>!(r.kind!=="filter"||!l_t({dashboardInput:r,selectedSheetId:t,selectedSheetCardIds:n})))}function u_t(e,t){return"toolbar"}function d_t(){const e=ml("interactive"),t=p.useDashboardStore(W=>W.selectedSheetId),n=p.useDashboardStore(W=>W.dashboard.filters),r=p.useDashboardStore(W=>W.dashboard.filterLayout),o=p.useDashboardStore(W=>W.isDashboardEditing),s=p.useDashboardStore(W=>W.controlValues),i=p.useDashboardStore(W=>W.filterValues);p.useDashboardStore(W=>W.filteringCards);const a=p.useDashboardStore(W=>W.inlineFilterValuesMap),c=p.useDashboardStore(W=>W.dashboardInputValues),u=p.useInteractionStore(W=>W.clearAllClickFilters),d=p.useInteractionStore(W=>Object.entries(W.interactionStates).reduce((U,[Z,Q])=>{var J;return Z===p.DRILL_CONTEXT_CARD_ID?U:U+(((J=Q.appliedClickFilters)==null?void 0:J.length)??0)},0)),f=p.useDashboardStore(W=>W.actions.removeCardInlineFilterValue),{reorderFilters:h,clearDashboardInputSlot:m,reorderDashboardControls:g,removeDashboardInput:x,removeFilter:b,setControlValue:y,setFilterLayout:w,setFilterValues:C,setFilteringCards:N,updateFilterDashboardInputDefinition:S}=p.useDashboardActions(),j=mT(db(lx,{activationConstraint:{distance:5}})),I=p.useDashboardStore(W=>W.dashboard),k=c_t({dashboard:I,selectedSheetId:t}).filter(W=>u_t(W.filter)==="toolbar"),T=Mxe({dashboard:I,selectedSheetId:t}),_=k.map(W=>W.filter),E=new Map(k.map(W=>[`filter:${W.filter.id}`,W])),D=fnt(I),M=D.filter(W=>!W.hidden&&fv(W)==="toolbar"),P=D.filter(W=>!W.hidden&&fv(W)==="advanced"),A=i_t(r==null?void 0:r.toolbarItemOrder,_,M),L=new Map(_.map(W=>[`filter:${W.id}`,W])),O=new Map(M.map(W=>[`control:${W.id}`,W]));function B(W){const{active:U,over:Z}=W;if(!Z||U.id===Z.id)return;const Q=String(U.id),J=String(Z.id),re=A.findIndex(ne=>ne===Q),de=A.findIndex(ne=>ne===J);if(re===-1||de===-1)return;const le=cx(A,re,de);w({toolbarItemOrder:le});const ce=new Set((n||[]).map(ne=>ne.id)),oe=A.filter(ne=>ne.startsWith("filter:")).map(ne=>ne.replace("filter:","")).filter(ne=>ce.has(ne)),fe=le.filter(ne=>ne.startsWith("filter:")).map(ne=>ne.replace("filter:","")).filter(ne=>ce.has(ne)),we=A.filter(ne=>ne.startsWith("control:")).map(ne=>ne.replace("control:","")),pe=le.filter(ne=>ne.startsWith("control:")).map(ne=>ne.replace("control:",""));h(rY(n||[],oe,fe)),g(rY(I.controls||[],we,pe))}const H=(r==null?void 0:r.toolbarWrap)??!1,R=(r==null?void 0:r.showDownloadButton)??!1,V=T.filter(U2),z=T.filter(W=>{if(U2(W))return!1;const U=p.getDashboardInputRuntimeSlot(c,W,{sheetId:t});return(U==null?void 0:U.status)==="set"||(U==null?void 0:U.status)==="cleared"}),F=new Set([...V,...z].map(W=>W.filter.id)),G=(i==null?void 0:i.filter(W=>!F.has(W.filterId)&&oY(W)).length)??0,q=[...V,...z],Y=q.filter(W=>{const U=p.hydrateAuthoredDashboardInputSlot({dashboard:I,input:W,runtimeValues:c,target:{sheetId:t}});return(U==null?void 0:U.status)==="set"&&U.value.kind==="filter"&&oY(U.value.filterValue)}).length,K=a?Object.values(a).reduce((W,U)=>W+((U==null?void 0:U.length)??0),0):0,$=G+Y+K+d,X=()=>{C([]),q.forEach(W=>{m(W,{sheetId:t})}),N([]),u(),a&&Object.entries(a).forEach(([W,U])=>{U==null||U.forEach(Z=>{f(W,Z.filterId)})})};return!_.length&&!M.length&&!P.length&&!R&&$===0?null:l.jsx("div",{className:"z-20 border-b border-border/60 bg-background/95 px-3 py-2 backdrop-blur supports-[backdrop-filter]:bg-background/85",style:e.containerStyle,role:"toolbar","aria-label":"Dashboard filters and controls",children:l.jsx(cC,{sensors:j,collisionDetection:iC,onDragEnd:B,children:l.jsxs("div",{className:p.cn("flex items-center",H?"flex-wrap":"w-0 min-w-full overflow-x-auto"),children:[l.jsx(uC,{items:A,strategy:Gz,children:l.jsx(HF,{className:"gap-3 pr-0",wrap:H,children:A.map(W=>{const U=L.get(W);if(U){const Q=E.get(W),J=Q&&U2(Q),re=J&&Q.definitionOrigin==="dashboardFilter";return l.jsx(r_t,{filter:U,isEditing:o,storageOptions:J?{storageTarget:"dashboardInput",dashboardInput:Q,sheetId:t??void 0}:void 0,inputVariableName:J?Q.variableName:void 0,isDashboardFilterReference:re,onUpdateFilter:J?(de,le)=>{S(Q.id,de,le)}:void 0,onRemoveFilter:J?()=>{if(Q.definitionOrigin==="dashboardFilter"){b(U.id);return}C((i||[]).filter(de=>de.filterId!==U.id)),x(Q.id)}:void 0},W)}const Z=O.get(W);return Z?l.jsx(s_t,{control:Z,value:s==null?void 0:s[Z.id],isEditing:o,onChange:Q=>y(Z.id,Q)},W):null})})}),P.length>0&&l.jsx(fde,{title:"",controls:P,values:s,onChange:(W,U)=>y(W.id,U),immediatePlacement:"toolbar",advancedLabel:"More controls"}),$>0&&l.jsxs("button",{type:"button",onClick:X,"aria-label":"Clear all filters",className:"ml-auto inline-flex h-7 shrink-0 items-center gap-1 rounded-control px-2 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:[l.jsx(Ie.X,{className:"h-3 w-3"}),"Clear all",l.jsx("span",{className:"rounded-[3px] bg-muted px-1 text-[10px] tabular-nums text-muted-foreground",children:$})]}),R&&l.jsx("div",{className:p.cn($>0?"ml-1.5":"ml-auto"),children:l.jsx(Dxe,{})})]})})})}function Rxe(){var ne,Se;const{showAssistant:e,tokenProps:t,renderMode:n}=It(),r=n_t((ne=t.config)==null?void 0:ne.showDashboardAssistant,e),{preferences:o}=Hm(),s=(Se=o==null?void 0:o.cardDisplay)==null?void 0:Se.mode,i=xf(s),a=xee({displayMode:s,renderMode:n}),c=v.useRef(null),u=v.useRef(null),[d,f]=v.useState(!1),{handleDragStart:h,isDraggingRef:m,getStyle:g,getPositionClasses:x}=Pvt({initialPosition:"bottom-right"}),b=Fh(ue=>ue.setFullscreen),y=Fh(ue=>ue.setPanelOpen),w=Fh(ue=>ue.setContainer),C=dJ("dashboard"),N=fJ(),S=hJ("dashboard"),j=C.isOpen,I=N==="dashboard",k=p.useDashboardStore(ue=>ue.isVisualEditing),T=p.useDashboardStore(ue=>ue.themeStyle),_=$u(),E=p.useDashboardStore(ue=>{var ie;return(ie=ue.dashboard)==null?void 0:ie.sheets}),D=p.useDashboardStore(ue=>ue.showFilters),M=p.useDashboardStore(ue=>ue.isDashboardEditing),P=p.useDashboardStore(ue=>ue.selectedSheetId),A=E==null?void 0:E.find(ue=>ue.id===P),L=p.useDashboardStore(ue=>{var ie,ee,ae;return(ae=(ee=(ie=ue.dashboard)==null?void 0:ie.sheets)==null?void 0:ee.find(se=>se.id===ue.selectedSheetId))==null?void 0:ae.kind}),O=p.useDashboardStore(ue=>{var ie,ee;return((ee=(ie=ue.dashboard)==null?void 0:ie.summary)==null?void 0:ee.position)||"top"}),B=L==="document",H=p.useDashboardStore(ue=>{var ie;return(ie=ue.dashboard)==null?void 0:ie.id}),{getDefaultSheetId:R,setDefaultSheetId:V,clearDefaultSheetId:z}=WY(H),[F,G]=v.useState(null),{setSelectedSheetId:q,setSheetTitle:Y,addSheet:K,setSheets:$}=p.useDashboardActions();HIt(u);const{setActiveAssistantType:X}=p.useAIActions();v.useEffect(()=>{if(H){const ue=R();G(ue)}},[H,R]),v.useEffect(()=>{j?X("dashboard"):N==="dashboard"&&b(null)},[j,X,N,b]),v.useEffect(()=>{var ue;j||(ue=c.current)==null||ue.resize(0)},[j]);function W(ue){var ie,ee;ue?((ie=c.current)==null||ie.resize(40),y("dashboard",!0),b("dashboard"),X("dashboard")):(y("dashboard",!1),b(null),(ee=c.current)==null||ee.resize(0),X(null))}function U(ue="dashboard"){const ie={id:ut.v4(),title:ue==="document"?"New Document":"New Sheet",...ue==="document"?{kind:ue,document:p.createDefaultDocumentDefinition()}:{}};K(ie),q(ie.id)}function Z(ue,ie){if(!H)return;F===ue?(z(),G(null),it.success("Default sheet cleared")):(V(ue),G(ue),it.success(`"${ie}" set as default sheet`))}function Q(ue){var ie;ue<1?(y("dashboard",!1),b(null),X(null),(ie=c.current)==null||ie.resize(0)):(j||y("dashboard",!0),X("dashboard"))}function J(){return(T==null?void 0:T.canvasTheme)==="muted"||!(T!=null&&T.canvasTheme)?"hsl(var(--semaphor-muted))":(T==null?void 0:T.canvasTheme)==="clear"?"":T==null?void 0:T.canvasTheme}const re=(ue,ie)=>{ue.dataTransfer.setData("tabIndex",ie.toString())},de=ue=>{ue.preventDefault()},le=(ue,ie)=>{const ee=ue.dataTransfer.getData("tabIndex");if(ee===ie.toString())return;const ae=Array.from(E||[]),[se]=ae.splice(parseInt(ee),1);ae.splice(ie,0,se),$(ae)},ce=r===!0&&!i&&!j&&!k&&!D;function oe(){if(E&&E.length>1||M)return l.jsx("div",{className:"relative flex w-full items-stretch border-b border-border",children:l.jsxs("div",{className:"relative min-w-0 flex-1",children:[l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 left-0 z-10 w-4 bg-gradient-to-r from-background to-transparent"}),l.jsx("span",{"aria-hidden":"true",className:"pointer-events-none absolute inset-y-0 right-0 z-10 w-4 bg-gradient-to-l from-background to-transparent"}),l.jsxs(p.TabsList,{role:"tab-list",className:"flex w-0 min-w-full items-stretch justify-start overflow-x-auto rounded-none bg-transparent p-0 [scrollbar-width:none] [&::-webkit-scrollbar]:hidden",children:[E==null?void 0:E.map((ue,ie)=>{const ee=P===ue.id,ae=F===ue.id;return l.jsxs(p.TabsTrigger,{draggable:!0,onDragStart:se=>re(se,ie),onDragOver:de,onDrop:se=>le(se,ie),onClick:()=>q(ue.id),className:p.cn("group relative inline-flex h-9 shrink-0 items-center gap-1.5 rounded-none bg-transparent px-3 py-0 text-[12px] font-medium text-muted-foreground transition-colors hover:bg-transparent hover:text-foreground data-[state=active]:bg-transparent data-[state=active]:text-foreground data-[state=active]:shadow-none","after:pointer-events-none after:absolute after:inset-x-2 after:-bottom-px after:h-0.5 after:bg-transparent data-[state=active]:after:bg-foreground"),value:ue.id,children:[ue.kind==="document"&&l.jsx(ti,{className:"h-3 w-3 text-muted-foreground"}),l.jsx(Uj,{enabled:M&&ee,text:ue.title,onSave:se=>Y(ue.id,se),children:ue.title},ue.id),l.jsx("span",{role:"button",tabIndex:0,"aria-label":ae?"Clear default sheet":"Set as default sheet",title:ae?"Clear default sheet":"Set as default sheet",onClick:se=>{se.stopPropagation(),Z(ue.id,ue.title||"Sheet")},onKeyDown:se=>{(se.key==="Enter"||se.key===" ")&&(se.preventDefault(),se.stopPropagation(),Z(ue.id,ue.title||"Sheet"))},className:p.cn("inline-flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-[3px] transition-opacity hover:bg-muted focus:outline-none focus-visible:ring-1 focus-visible:ring-foreground",ee||ae?"opacity-100":"opacity-0 group-hover:opacity-100"),children:l.jsx(JZ,{className:p.cn("h-3 w-3 transition-colors",ae?"fill-current text-amber-500":"text-muted-foreground")})}),M&&ee&&E.length>1&&l.jsx("span",{role:"button",tabIndex:0,"aria-label":"Delete sheet",className:"inline-flex h-4 w-4 shrink-0 cursor-pointer items-center justify-center rounded-[3px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-1 focus-visible:ring-foreground",onClick:se=>{se.stopPropagation(),f(!0)},onKeyDown:se=>{(se.key==="Enter"||se.key===" ")&&(se.preventDefault(),se.stopPropagation(),f(!0))},children:l.jsx(Ie.X,{className:"h-3 w-3"})})]},ue.id)}),M&&l.jsxs(Xo,{children:[l.jsx(Qo,{asChild:!0,children:l.jsxs("button",{type:"button","aria-label":"Add sheet",className:"ml-1 inline-flex h-9 shrink-0 items-center gap-1 px-3 text-[12px] font-medium text-muted-foreground transition-colors hover:text-foreground",children:[l.jsx(Mr,{className:"h-3 w-3"}),"Sheet"]})}),l.jsxs(Fo,{align:"start",className:"w-48",children:[l.jsxs(In,{onSelect:()=>U("dashboard"),children:[l.jsx(om,{className:"h-4 w-4 text-muted-foreground"}),"Dashboard sheet"]}),l.jsxs(In,{onSelect:()=>U("document"),children:[l.jsx(ti,{className:"h-4 w-4 text-muted-foreground"}),"Document"]})]})]})]})]})})}function fe(){return l.jsx("div",{ref:u,style:{},className:"h-full min-h-0 grow",children:E==null?void 0:E.map(ue=>l.jsx(p.TabsContent,{style:{backgroundColor:J(),..._.dashboardCanvasStyle},className:p.cn("mt-0 h-full min-h-0",{}),value:ue.id,children:l.jsx(QK,{sheet:ue})},ue.id))})}function we(){return l.jsxs(p.Tabs,{"data-role":"dashboard-tabs-container",className:p.cn("relative flex h-full flex-col",T==null?void 0:T.dashboardTabsContainer),onValueChange:ue=>{q(ue)},value:P||void 0,children:[oe(),O==="top"&&!B&&l.jsx(oF,{}),P&&!B&&l.jsx(d_t,{}),B?l.jsx("div",{"data-role":"dashboard-tabs-content",className:"min-h-0 flex-1 grow basis-0 overflow-hidden",children:fe()}):l.jsx(yl,{"data-role":"dashboard-tabs-content",className:"flex-1 grow basis-0 overflow-y-auto",children:fe()}),O==="bottom"&&!B&&l.jsx(oF,{}),l.jsx(Fvt,{open:d,setOpen:f})]})}const pe=v.useCallback(ue=>{w("dashboard",ue)},[w]);return E?a&&P&&!B?l.jsxs("div",{"data-document-render-error":"true",className:"bg-white p-8 text-sm text-zinc-700",children:['Requested document sheet "',P,'" was not found or is not a document sheet in the loaded dashboard.']}):a&&B&&A?l.jsx("div",{"data-role":"dashboard-document-print-content",className:"min-h-0 overflow-visible bg-white",children:l.jsx(QK,{sheet:A})}):l.jsxs(l.Fragment,{children:[l.jsx(XIt,{}),l.jsx(t_t,{}),l.jsxs("div",{className:"relative flex-1 basis-0 overflow-hidden",children:[l.jsxs(Sge,{className:p.cn("flex-1 basis-0 overflow-y-auto transition-opacity",I&&"pointer-events-none opacity-0"),direction:"horizontal",children:[l.jsx(GF,{children:we()}),r===!0&&l.jsxs(l.Fragment,{children:[l.jsx(Avt,{open:j,onTabClick:W,withHandle:!0,disabled:!j}),l.jsx(GF,{className:"flex grow","data-role":"dashboard-assistant-panel",onResize:Q,defaultSize:j?40:0,ref:c,children:l.jsx("div",{className:"grow overflow-y-auto",children:l.jsx(VIt,{open:j,setOpen:W,isFullscreen:I,onFullscreenChange:ue=>b(ue?"dashboard":null),fullscreenContainer:S})})})]})]}),l.jsx("div",{ref:pe,className:p.cn("absolute inset-0",!I&&"pointer-events-none")}),ce&&l.jsx("div",{className:p.cn("absolute z-50 transition-all duration-300 ease-in-out",x().horizontal,x().vertical),style:g(),children:l.jsx(p.Button,{size:"sm",variant:"outline",className:"h-12 w-12 cursor-grab rounded-full border-border bg-background p-0 shadow-lg hover:bg-muted active:cursor-grabbing",onClick:()=>{m.current||W(!0)},onMouseDown:h,onTouchStart:h,title:"Open Assistant (drag to move)",children:l.jsx(Xve,{className:"h-5 w-5"})})})]})]}):null}const Axe=v.forwardRef(({appearance:e,organizationAppearance:t,tokenAppearance:n,reactAppearance:r,resolvedAppearance:o,systemMode:s,children:i,className:a,style:c,...u},d)=>l.jsx(ag.InternalAppearanceRuntimeProvider,{appearance:e,organizationAppearance:t,tokenAppearance:n,reactAppearance:r,resolvedAppearance:o,systemMode:s,children:l.jsx(nx,{...u,ref:d,className:a,style:c,children:i})}));Axe.displayName="AppearanceProvider";const Pxe=v.createContext({openBrandStudioPreview:()=>{}}),f_t=Pxe.Provider;function h_t(){return v.useContext(Pxe)}function m_t({children:e,defaultTheme:t="system",storageKey:n="vite-ui-theme",...r}){const o=ag.normalizeTheme(t),[s,i]=v.useState(()=>p_t(n)||o),a=v.useCallback(u=>{const d=ag.normalizeTheme(u);g_t(n,d),i(d)},[n]),c=v.useMemo(()=>({theme:s,setTheme:a}),[s,a]);return l.jsx(ag.ThemeProviderContext.Provider,{...r,value:c,children:e})}function p_t(e){if(typeof window>"u")return null;try{const t=window.localStorage.getItem(e);if(!t)return null;const n=ag.normalizeTheme(t,"system");return n===t?n:null}catch{return null}}function g_t(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}const b_t=v.lazy(()=>Promise.resolve().then(()=>require("../brand-studio/index.cjs")).then(e=>({default:e.BrandStudioEditor})));function rB({appearance:e,children:t}){var E,D;const{authToken:n,id:r,tokenProps:o}=It(),s=Uv(),i=(E=s.data)==null?void 0:E.organizationAppearance,a=(D=o.config)==null?void 0:D.appearance,[c,u]=v.useState(!1),[d,f]=v.useState(null),[h,m]=v.useState(null),[g,x]=v.useState(null),[b,y]=v.useState(null),w=`${o.apiServiceUrl??""}:${(n==null?void 0:n.accessToken)??""}`,C=qn({queryKey:rQ({resourceType:mo.DASHBOARD,apiServiceUrl:o.apiServiceUrl,accessToken:n==null?void 0:n.accessToken}),queryFn:async()=>p.getRequest(`${o.apiServiceUrl}/management/v1/dashboards`,(n==null?void 0:n.accessToken)||""),select:M=>(M==null?void 0:M.organizationAppearance)??null,enabled:!s.dashboardIdToFetch&&i===void 0&&!!(n!=null&&n.accessToken)});v.useEffect(()=>{i!==void 0&&y({scopeKey:w,appearance:i})},[i,w]),v.useEffect(()=>{C.data!==void 0&&y({scopeKey:w,appearance:C.data})},[C.data,w]);const N=(b==null?void 0:b.scopeKey)===w?b.appearance:null,S=i!==void 0?i:C.data!==void 0?C.data:N,j=v.useMemo(()=>Am.resolveAppearance({organizationAppearance:S,tokenAppearance:a,reactAppearance:e}),[e,S,a]),I=v.useCallback(()=>{f(g??h??j),u(!0)},[g,h,j]),k=v.useCallback(()=>{u(!1)},[]);v.useEffect(()=>{f(null),m(null),x(null),u(!1)},[r]);const T=v.useMemo(()=>({openBrandStudioPreview:I}),[I]),_=g??h??e;return l.jsx(m_t,{defaultTheme:"system",storageKey:"vite-ui-theme",children:l.jsx(f_t,{value:T,children:l.jsx(Axe,{organizationAppearance:S,tokenAppearance:a,reactAppearance:_,style:{height:"100%",width:"100%"},children:l.jsxs(p.TooltipProvider,{delayDuration:0,children:[t,c&&l.jsx("aside",{"aria-label":"Brand Studio","aria-modal":"false",role:"dialog",className:"fixed bottom-0 right-0 top-0 z-50 flex w-[min(520px,100vw)] flex-col border-l border-border bg-background text-foreground shadow-sm",children:l.jsx(v.Suspense,{fallback:l.jsx("div",{className:"flex h-full items-center justify-center text-[12px] text-muted-foreground",children:"Loading Brand Studio..."}),children:l.jsx(b_t,{appearance:d,onDraftChange:x,onSave:M=>{m(M),x(M),f(M)},onCancel:k})})})]})})})})}function Fxe({children:e,preferences:t}){const{currentUser:n}=si(),r=v.useMemo(()=>{var o,s;return{preferences:t||{},isLocalDev:((o=t==null?void 0:t.uiMode)==null?void 0:o.developer)||!1,isConsoleMode:((s=t==null?void 0:t.uiMode)==null?void 0:s.console)||!1}},[t]);return l.jsx(eQ.Provider,{value:r,children:l.jsx(J_,{displayPreferences:t==null?void 0:t.cardDisplay,currentUser:n,children:e})})}function x_t(e=2e3,t=500){const n=N0e(),[r,o]=v.useState(!1),[s,i]=v.useState(!1),a=v.useRef(null);return v.useEffect(()=>{const c=setTimeout(()=>o(!0),e);return()=>clearTimeout(c)},[e]),v.useEffect(()=>{if(r){if(n>0){i(!1),a.current&&(clearTimeout(a.current),a.current=null);return}return a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{i(!0)},t),()=>{a.current&&clearTimeout(a.current)}}},[r,n,t]),s}function oB({delayMs:e=2e3,quietMs:t=500,componentType:n,componentId:r}){const o=x_t(e,t);return v.useEffect(()=>(o&&(window.__SEMAPHOR_READY__={ready:!0,type:n,componentId:r||null,timestamp:Date.now()}),()=>{window.__SEMAPHOR_READY__={ready:!1,type:n,componentId:r||null,timestamp:Date.now()}}),[o,n,r]),l.jsx("div",{id:"idle-check","aria-hidden":"true",style:{position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:0},children:o?"ready":""})}function Oxe(e){if(typeof window>"u")return null;const{preferences:t}=e;return l.jsx(_i,{FallbackComponent:X_,children:l.jsx(vO,{dashboardProps:e,children:l.jsxs(cT,{children:[l.jsx(oB,{componentType:"dashboard",componentId:e.id}),l.jsx(rB,{appearance:e.appearance,children:l.jsx(Fxe,{preferences:t,children:l.jsx("main",{className:"flex h-full flex-col",children:l.jsx(a5,{...e,type:"dashboard",children:l.jsx(Rxe,{})})})})})]})})})}function y_t(e=[]){const t=v.useRef(null),n=v.useRef(null),r=v.useRef(null),[o,s]=v.useState(),i=v.useCallback(()=>{var m,g,x;const a=((m=t.current)==null?void 0:m.clientWidth)??0,c=((g=r.current)==null?void 0:g.offsetWidth)??0,u=((x=n.current)==null?void 0:x.offsetWidth)??0,f=a-c-u-8,h=Math.max(f,0);s(b=>b===h?b:h)},[]);return v.useEffect(()=>{const a=t.current;if(!a||typeof ResizeObserver>"u")return;const c=new ResizeObserver(()=>i());return c.observe(a),i(),()=>c.disconnect()},[i,...e]),{headerRef:t,leftActionsRef:n,rightActionsRef:r,titleMaxWidth:o,updateAvailableWidth:i}}function v_t({filter:e}){var g;const t=p.useDashboardStore(x=>x.isDashboardEditing),{preferences:n}=Hm(),r=xf((g=n==null?void 0:n.cardDisplay)==null?void 0:g.mode),o=p.useDashboardStore(x=>x.filterValues),s=o==null?void 0:o.some(x=>x.filterId===e.id),{removeFilterValues:i,removeFilter:a,updateFilter:c}=p.useDashboardActions(),{headerRef:u,leftActionsRef:d,rightActionsRef:f,titleMaxWidth:h,updateAvailableWidth:m}=y_t([t,s,r]);return v.useEffect(()=>{m()},[e.title,m]),l.jsxs("div",{ref:u,className:"group mb-1 flex h-5 items-center justify-between",children:[l.jsxs("div",{className:"flex grow items-center gap-2 min-w-0",children:[l.jsx("div",{className:"min-w-0 flex-1",style:h!==void 0?{maxWidth:h}:void 0,children:l.jsx(p.Label,{className:"my-1 block w-full text-sm",children:l.jsx(Si,{value:e.title||e.column,onSave:x=>c({...e,title:x}),isEditable:t,placeholder:"Filter",displayClassName:"text-sm truncate",inputClassName:"text-sm"})})}),l.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",ref:d,children:[t&&l.jsx(H$,{filter:e,isEditing:t}),t&&l.jsx("button",{onClick:()=>{i(e.id),a(e.id)},className:"text-muted-foreground hover:text-foreground",children:l.jsx(Ie.X,{className:"size-3.5"})})]})]}),l.jsx("div",{className:"hidden",ref:f})]})}function w_t(){const e=p.useDashboardStore(r=>r.dashboard.filters),t=p.useDashboardStore(r=>r.theme),n=e==null?void 0:e.filter(r=>r.hide);return n!=null&&n.length?l.jsx("div",{className:p.cn("mb-1 flex items-center gap-2 border-y px-0.5 pb-0.5",{"bg-[repeating-linear-gradient(45deg,_#ffffff_0_3px,_#f3f3f3_3px_6px)]":t==="light","bg-[repeating-linear-gradient(45deg,_#18171d_0_3px,_#272729_3px_6px)]":t==="dark"}),children:n==null?void 0:n.map(r=>l.jsxs("div",{className:"flex min-w-[250px] max-w-fit flex-col gap-1 p-2",children:[l.jsx(v_t,{filter:r}),l.jsx(W_,{filter:r})]},r.id))}):null}function C_t(){var s;const e=p.useDashboardStore(i=>i.dashboard),t=p.useDashboardStore(i=>i.selectedSheetId),n=p.useDashboardStore(i=>i.isDashboardEditing),r=(s=e.sheets)==null?void 0:s.find(i=>i.id===t),o=p.isDocumentSheet(r);return l.jsx("div",{role:"dashboard-plus-main",className:"flex min-h-0 grow basis-0 overflow-hidden",children:l.jsxs("section",{className:"flex min-h-0 grow basis-0 flex-col overflow-hidden",children:[n&&!o&&l.jsx(w_t,{}),l.jsx(Rxe,{})]})})}const S_t=v.lazy(()=>Promise.resolve().then(()=>require("./dashboard-controls-CmK7U1hI.cjs"))),N_t=v.lazy(()=>Promise.resolve().then(()=>require("./edit-dashboard-visual-BSWdyT4u.cjs"))),j_t=v.lazy(()=>Promise.resolve().then(()=>require("./dashboard-json-7BQDKnHy.cjs")));function k_t({showControls:e=!1,showFooter:t=!0,...n}){const r=p.useDashboardStore(a=>a.isVisualEditing),o=p.useDashboardStore(a=>a.showDashboardJSON),{appearance:s,preferences:i}=n;return l.jsx(_i,{FallbackComponent:X_,children:l.jsx(vO,{dashboardProps:n,children:l.jsxs(cT,{children:[l.jsx(oB,{componentType:"surfboard",componentId:n.id}),l.jsxs(rB,{appearance:s,children:[l.jsx(rSe,{toastOptions:{classNames:{toast:"max-w-[calc(100vw-2rem)] overflow-x-hidden !items-start [--toast-close-button-end:0.5rem] [--toast-close-button-start:auto] [--toast-close-button-transform:translate(0,0)] sm:max-w-[44rem]",content:"min-w-0 flex-1",icon:"mt-0.5 shrink-0",title:"max-w-full break-words pr-8",description:"max-w-full break-words",closeButton:"!top-2 h-6 w-6 rounded-md border-border bg-background text-muted-foreground hover:bg-muted hover:text-foreground"}}}),l.jsxs(Fxe,{preferences:i,children:[o&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(j_t,{})}),l.jsxs("main",{className:"relative flex h-full w-full flex-col overflow-hidden",children:[e&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(S_t,{})}),l.jsx("div",{className:"flex grow overflow-hidden",children:l.jsx("div",{className:"flex min-w-0 flex-1",children:l.jsxs(a5,{...n,type:"dashboard",children:[r&&l.jsx(v.Suspense,{fallback:null,children:l.jsx(N_t,{})}),l.jsx(v.Activity,{mode:r?"hidden":"visible",children:l.jsx(C_t,{})})]})})})]})]})]})]})})})}const lO=[{value:"en-US",label:"English (United States)"},{value:"en-GB",label:"English (United Kingdom)"},{value:"de-DE",label:"German (Germany)"},{value:"fr-FR",label:"French (France)"},{value:"es-ES",label:"Spanish (Spain)"},{value:"it-IT",label:"Italian (Italy)"},{value:"nl-NL",label:"Dutch (Netherlands)"},{value:"pt-BR",label:"Portuguese (Brazil)"},{value:"ja-JP",label:"Japanese (Japan)"},{value:"en-IN",label:"English (India)"},{value:"en-NZ",label:"English (New Zealand)"},{value:"mi-NZ",label:"Māori (New Zealand)"}],Lxe=new Set(["USD","EUR","GBP","CAD","AUD","JPY","CHF","INR","BRL","KWD"]),I_t=qi.getSupportedCurrencyCodes(),__t=I_t.filter(e=>!Lxe.has(e)),$xe=[{value:"short",label:"Short"},{value:"medium",label:"Medium"},{value:"long",label:"Long"}],iY="2026-07-31",W2="2026-07-31T14:30:45";function cO(e){switch(e){case"viewer_user":return"user";case"viewer_tenant_user":return"tenant user";case"viewer_tenant":return"tenant";case"viewer_organization":return"organization";case"session_initial":return"embedded session";case"system_default":return"system";default:return"another preference level"}}function K2(e){var t;return((t=$xe.find(n=>n.value===e))==null?void 0:t.label)??e}function T_t(e){const t=lO.find(n=>n.value===e);return t?`${t.label} — ${t.value}`:e}function G2(e){return{short:e("short"),medium:e("medium"),long:e("long")}}function Y2({id:e,label:t,value:n,inherited:r,inheritedSource:o,examples:s,disabled:i,onValueChange:a}){const c=n===void 0?`Inherited · ${K2(r)}`:K2(n);return l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(p.Label,{htmlFor:e,className:"text-[11px] text-muted-foreground",children:t}),l.jsxs(p.Select,{value:n??"inherit",disabled:i,onValueChange:a,children:[l.jsx(p.SelectTrigger,{id:e,size:"xs",children:l.jsx(p.SelectValue,{children:c})}),l.jsxs(p.SelectContent,{children:[l.jsx(p.SelectItem,{value:"inherit",className:"[&>span:last-child]:w-full",children:l.jsxs("span",{className:"flex w-full min-w-0 items-center justify-between gap-4",children:[l.jsxs("span",{children:["Inherited from ",cO(o)," ·"," ",K2(r)]}),l.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:s[r]})]})}),$xe.map(u=>l.jsx(p.SelectItem,{value:u.value,className:"[&>span:last-child]:w-full",children:l.jsxs("span",{className:"flex w-full min-w-0 items-center justify-between gap-4",children:[l.jsx("span",{children:u.label}),l.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:s[u.value]})]})},u.value))]})]})]})}function E_t({value:e,inherited:t,inheritedSources:n,onChange:r,disabled:o}){var j,I,k,T;const s=v.useId(),i=v.useId(),a=v.useId(),c=v.useId(),u=v.useId(),f=(e.locale===void 0?void 0:qi.canonicalizeSupportedLocale(e.locale))??t.locale,h=e.defaultCurrency??t.defaultCurrency,m={locale:f,dateStyle:e.dateStyle??t.dateStyle,dateTime:{dateStyle:((j=e.dateTime)==null?void 0:j.dateStyle)??t.dateTime.dateStyle,timeStyle:((I=e.dateTime)==null?void 0:I.timeStyle)??t.dateTime.timeStyle},defaultCurrency:h},g=new Intl.NumberFormat(f,{style:"currency",currency:h}).format(1e3),x=$t.resolveRawTemporalFormat({preferences:m,calendar:{tz:"UTC"}}),b=$t.formatRawTemporalValue({value:iY,metadata:{kind:"raw_temporal",valueKind:"date"},format:x}).text,y=$t.formatRawTemporalValue({value:W2,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:x}).text,w=G2(_=>$t.formatRawTemporalValue({value:iY,metadata:{kind:"raw_temporal",valueKind:"date"},format:$t.resolveRawTemporalFormat({preferences:{...m,dateStyle:_},calendar:{tz:"UTC"}})}).text),C=G2(_=>$t.formatRawTemporalValue({value:W2,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:$t.resolveRawTemporalFormat({preferences:{...m,dateTime:{...m.dateTime,dateStyle:_}},calendar:{tz:"UTC"}})}).text),N=G2(_=>$t.formatRawTemporalValue({value:W2,metadata:{kind:"raw_temporal",valueKind:"wall_datetime"},format:$t.resolveRawTemporalFormat({preferences:{...m,dateTime:{...m.dateTime,timeStyle:_}},calendar:{tz:"UTC"}})}).text),S=(_,E)=>{const D={...e.dateTime,[_]:E==="inherit"?void 0:E};r({...e,dateTime:D.dateStyle===void 0&&D.timeStyle===void 0?void 0:D})};return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(p.Label,{htmlFor:s,className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Locale"}),l.jsxs(p.Select,{value:e.locale??"inherit",disabled:o,onValueChange:_=>r({...e,locale:_==="inherit"?void 0:_}),children:[l.jsx(p.SelectTrigger,{id:s,size:"xs",children:l.jsx(p.SelectValue,{children:e.locale===void 0?`Inherited · ${t.locale}`:T_t(e.locale)})}),l.jsxs(p.SelectContent,{children:[l.jsxs(p.SelectItem,{value:"inherit",children:["Inherited from ",cO(n.locale)," ·"," ",t.locale]}),e.locale&&!lO.some(_=>_.value===e.locale)&&l.jsx(p.SelectItem,{value:e.locale,children:e.locale}),lO.map(_=>l.jsxs(p.SelectItem,{value:_.value,children:[_.label," — ",_.value]},_.value))]})]})]}),l.jsxs("fieldset",{className:"space-y-2",children:[l.jsx("legend",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date values"}),l.jsx(Y2,{id:a,label:"Format",value:e.dateStyle,inherited:t.dateStyle,inheritedSource:n.dateStyle,examples:w,disabled:o,onValueChange:_=>r({...e,dateStyle:_==="inherit"?void 0:_})})]}),l.jsxs("fieldset",{className:"space-y-2",children:[l.jsx("legend",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Date & time values"}),l.jsx(Y2,{id:c,label:"Date",value:(k=e.dateTime)==null?void 0:k.dateStyle,inherited:t.dateTime.dateStyle,inheritedSource:n.dateTime.dateStyle,examples:C,disabled:o,onValueChange:_=>S("dateStyle",_)}),l.jsx(Y2,{id:u,label:"Time",value:(T=e.dateTime)==null?void 0:T.timeStyle,inherited:t.dateTime.timeStyle,inheritedSource:n.dateTime.timeStyle,examples:N,disabled:o,onValueChange:_=>S("timeStyle",_)})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(p.Label,{htmlFor:i,className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Default currency"}),l.jsxs(p.Select,{value:e.defaultCurrency??"inherit",disabled:o,onValueChange:_=>r({...e,defaultCurrency:_==="inherit"?void 0:_}),children:[l.jsx(p.SelectTrigger,{id:i,size:"xs",children:l.jsx(p.SelectValue,{children:e.defaultCurrency===void 0?`Inherited · ${t.defaultCurrency}`:e.defaultCurrency})}),l.jsxs(p.SelectContent,{children:[l.jsxs(p.SelectItem,{value:"inherit",children:["Inherited from ",cO(n.defaultCurrency)," ·"," ",t.defaultCurrency]}),[...Lxe].map(_=>l.jsx(p.SelectItem,{value:_,children:_},_)),__t.map(_=>l.jsx(p.SelectItem,{value:_,children:_},_))]})]})]}),l.jsxs("div",{className:"rounded-control border border-border/60 bg-muted/30 px-3 py-2",children:[l.jsx("p",{className:"text-[10px] font-medium uppercase tracking-[0.08em] text-muted-foreground",children:"Preview"}),l.jsxs("dl",{className:"mt-1.5 space-y-1 text-[12px]",children:[l.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[l.jsx("dt",{className:"text-muted-foreground",children:"Date"}),l.jsx("dd",{className:"text-right font-medium text-foreground",children:b})]}),l.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[l.jsx("dt",{className:"text-muted-foreground",children:"Date & time"}),l.jsx("dd",{className:"text-right font-medium text-foreground",children:y})]}),l.jsxs("div",{className:"flex items-baseline justify-between gap-4",children:[l.jsx("dt",{className:"text-muted-foreground",children:"Currency"}),l.jsx("dd",{className:"text-right font-medium text-foreground",children:g})]})]})]}),l.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Currency values are not converted. Date examples use a fixed reference value and the Gregorian calendar."})]})}const uO=new Set;function zxe(e){return uO.add(e),()=>{uO.delete(e)}}function sB(){uO.forEach(e=>{e()})}var D_t=Object.defineProperty,M_t=(e,t,n)=>t in e?D_t(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,g1=(e,t,n)=>M_t(e,typeof t!="symbol"?t+"":t,n);const R_t={stringify:e=>e?"true":"false",parse:e=>/^[ty1-9]/i.test(e)},A_t={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{if(typeof window<"u"&&e in window)return window[e];if(typeof global<"u"&&e in global)return global[e]})();return typeof r=="function"?r.bind(n):void 0}},P_t={stringify:e=>JSON.stringify(e),parse:e=>JSON.parse(e)};function F_t(e){return e.replace(/([a-z0-9])([A-Z])/g,(t,n,r)=>`${n}-${r.toLowerCase()}`)}function Bxe(e){return e.replace(/[-:]([a-z])/g,(t,n)=>`${n.toUpperCase()}`)}const O_t={stringify:e=>e.name,parse:(e,t,n)=>{const r=(()=>{const o=Bxe(t);if(typeof n<"u"&&o in n.container)return n.container[o]})();return typeof r=="function"?r.bind(n):void 0}},L_t={stringify:e=>`${e}`,parse:e=>parseFloat(e)},$_t={stringify:e=>e,parse:e=>e},Z2={string:$_t,number:L_t,boolean:R_t,function:A_t,method:O_t,json:P_t},sy=Symbol.for("r2wc.render"),b1=Symbol.for("r2wc.connected"),Gf=Symbol.for("r2wc.context"),Ai=Symbol.for("r2wc.props");function z_t(e,t,n){var r,o,s;t.props||(t.props=e.propTypes?Object.keys(e.propTypes):[]),t.events||(t.events=[]);const i=Array.isArray(t.props)?t.props.slice():Object.keys(t.props),a=Array.isArray(t.events)?t.events.slice():Object.keys(t.events),c={},u={},d={},f={};for(const m of i){c[m]=Array.isArray(t.props)?"string":t.props[m];const g=F_t(m);d[m]=g,f[g]=m}for(const m of a)u[m]=Array.isArray(t.events)?{}:t.events[m];class h extends HTMLElement{constructor(){super(),g1(this,s,!0),g1(this,o),g1(this,r,{}),g1(this,"container"),t.shadow?this.container=this.attachShadow({mode:t.shadow}):this.container=this,this[Ai].container=this.container;for(const g of i){const x=d[g],b=this.getAttribute(x),y=c[g],w=y?Z2[y]:null;if(y==="method"){const C=Bxe(x);Object.defineProperty(this[Ai].container,C,{enumerable:!0,configurable:!0,get(){return this[Ai][C]},set(N){this[Ai][C]=N,this[sy]()}}),this[Ai][g]=w.parse(b,x,this)}w!=null&&w.parse&&b&&(this[Ai][g]=w.parse(b,x,this))}for(const g of a)this[Ai][g]=x=>{const b=g.replace(/^on/,"").toLowerCase();this.dispatchEvent(new CustomEvent(b,{detail:x,...u[g]}))}}static get observedAttributes(){return Object.keys(f)}connectedCallback(){this[b1]=!0,this[sy]()}disconnectedCallback(){this[b1]=!1,this[Gf]&&n.unmount(this[Gf]),delete this[Gf]}attributeChangedCallback(g,x,b){const y=f[g],w=c[y],C=w?Z2[w]:null;y in c&&C!=null&&C.parse&&b&&(this[Ai][y]=C.parse(b,g,this),this[sy]())}[(s=b1,o=Gf,r=Ai,sy)](){this[b1]&&(this[Gf]?n.update(this[Gf],this[Ai]):this[Gf]=n.mount(this.container,e,this[Ai]))}}for(const m of i){const g=d[m],x=c[m];Object.defineProperty(h.prototype,m,{enumerable:!0,configurable:!0,get(){return this[Ai][m]},set(b){this[Ai][m]=b;const y=x?Z2[x]:null;if(y!=null&&y.stringify){const w=y.stringify(b,g,this);this.getAttribute(g)!==w&&this.setAttribute(g,w)}else this[sy]()}})}return h}function B_t(e,t,n){const r=hye.createRoot(e),o=v.createElement(t,n);return r.render(o),{root:r,ReactComponent:t}}function V_t({root:e,ReactComponent:t},n){const r=v.createElement(t,n);e.render(r)}function H_t({root:e}){e.unmount()}function q_t(e,t={}){return z_t(e,t,{mount:B_t,update:V_t,unmount:H_t})}const U_t={id:"string",version:"string",authToken:"json",placeholders:"json",defaultFilterValues:"json",defaultControlValues:"json",controlContractOverrides:"json",documentInputValues:"json",dashboardInputExecutionSnapshot:"json",interactionExecutionSnapshot:"json",presentationExecutionSnapshot:"json",renderMode:"string",currentTheme:"string",customCards:"json",customStyle:"json",appearance:"json",onChartElementClicked:"function",onFilterValuesChange:"function",onEvent:"function",onSave:"function",LoadingComponent:"function",ErrorComponent:"function",showAssistant:"boolean",showBriefings:"boolean",selectedSheetId:"string",eventHandlers:"json",preferences:"json"},W_t=q_t(Oxe,{props:U_t}),K_t=v.memo(function({context:t="editor"}={}){return l.jsxs("div",{"data-content":"fields-section",className:"flex h-full grow flex-col items-center overflow-hidden",children:[" ",l.jsx(y4,{context:t})," "]})});var Vxe="Toggle",Hxe=te.forwardRef((e,t)=>{const{pressed:n,defaultPressed:r,onPressedChange:o,...s}=e,[i,a]=p.useControllableState({prop:n,onChange:o,defaultProp:r??!1,caller:Vxe});return l.jsx(p.Primitive.button,{type:"button","aria-pressed":i,"data-state":i?"on":"off","data-disabled":e.disabled?"":void 0,...s,ref:t,onClick:p.composeEventHandlers(e.onClick,()=>{e.disabled||a(!i)})})});Hxe.displayName=Vxe;var qxe=Hxe;const G_t=p.cva("inline-flex items-center justify-center rounded-control text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2.5",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),Uxe=te.forwardRef(({className:e,variant:t,size:n,...r},o)=>l.jsx(qxe,{ref:o,className:p.cn(G_t({variant:t,size:n,className:e})),...r}));Uxe.displayName=qxe.displayName;function iB(){var c,u;const e=p.useEditorStore(d=>d.card),t=p.useEditorStore(d=>d.frame),n=v.useMemo(()=>at.findCustomVisualConfigCard(t,e),[t,e]),{manifest:r}=_f(((c=n==null?void 0:n.customCardPreferences)==null?void 0:c.url)||""),o=v.useMemo(()=>{var d;return(d=r==null?void 0:r.visuals)==null?void 0:d.find(f=>{var h;return f.name===((h=n==null?void 0:n.customCardPreferences)==null?void 0:h.componentName)})},[r,(u=n==null?void 0:n.customCardPreferences)==null?void 0:u.componentName]),s=at.resolveMultiInputType(n,o),i=v.useMemo(()=>at.getCustomVisualInputCards({frame:t,configCard:n,isMultiInputVisual:s==="multiple"}),[t,n,s]),a=v.useMemo(()=>{const d=i.findIndex(f=>(f==null?void 0:f.id)===e.id);return d<0?-1:at.getSlotIndexForCard(e,d)},[i,e]);return v.useMemo(()=>!n||s!=="multiple"||a<0?e.type:at.getEffectiveCardTypeForSlot(e,a,o==null?void 0:o.slots)??e.type,[n,s,a,e,o==null?void 0:o.slots])}function Wxe({storeValue:e,defaultValue:t="",onStoreUpdate:n,delay:r=300}){const[o,s]=v.useState(e??t),i=v.useRef(null),a=v.useRef(o),c=v.useRef(e),u=v.useRef(!1),d=v.useCallback(()=>{i.current&&(clearTimeout(i.current),i.current=null),u.current&&a.current!==(c.current??t)&&(n(a.current),c.current=a.current)},[t,n]);v.useEffect(()=>{if(e!==c.current){i.current&&(clearTimeout(i.current),i.current=null);const h=e??t;s(h),a.current=h,c.current=e,u.current=!1}},[e,t]),v.useEffect(()=>{if(u.current)return i.current=setTimeout(()=>{d()},r),()=>{i.current&&(clearTimeout(i.current),i.current=null)}},[r,d,o]),v.useEffect(()=>()=>{i.current&&clearTimeout(i.current)},[]);const f=v.useCallback(h=>{const m=h??t;u.current=!0,a.current=m,s(m)},[t]);return{value:o,onChange:f,flush:d}}const Y_t=300;function Z_t({onExpand:e},t){const n=p.useEditorStore(C=>C.card.sql),r=p.useEditorStore(C=>C.sqlGen),o=p.useEditorStore(C=>C.card),s=iB(),{setCardSql:i,setSqlGen:a,setRunSql:c}=p.useEditorActions(),u=v.useMemo(()=>s!==o.type?{...o,type:s}:o,[o,s]),{queryKey:d}=Nb(u),f=Zr(),h=v.useRef(d);h.current=d;const m=v.useRef(r);m.current=r;const g=v.useCallback(C=>{i(C)},[i]),{value:x,onChange:b,flush:y}=Wxe({storeValue:n,defaultValue:"",onStoreUpdate:g,delay:Y_t});v.useEffect(()=>zxe(y),[y]);function w(C){b(C),p.isObjectEmpty(m.current)||a({})}return l.jsxs("div",{className:"relative h-full w-full",children:[l.jsx(p.CodeEditor,{ref:t,value:x??"",onValueChange:w,language:"sql-jinja",embedded:!0,hideLineNumbers:!0,wrapLines:!0,placeholder:"Write your SQL here",onKeyDown:C=>{C.key==="Enter"&&C.shiftKey&&(C.preventDefault(),sB(),setTimeout(()=>{f.removeQueries({queryKey:h.current,exact:!0}),c(!0)},0))}}),e?l.jsx(p.Button,{type:"button",variant:"ghost",size:"icon",className:"absolute right-2.5 top-2 z-20 h-7 w-7 bg-background/80 p-0 text-muted-foreground backdrop-blur-sm transition-colors hover:bg-accent hover:text-foreground focus-visible:text-foreground",onClick:e,"aria-label":"Expand SQL editor",title:"Expand SQL editor",children:l.jsx(Mt.Maximize2,{className:"h-3.5 w-3.5",strokeWidth:1.75})}):null]})}const X_t=v.forwardRef(Z_t),Q_t=300;function J_t(e,t){const n=p.useEditorStore(g=>g.card.python),r=p.useEditorStore(g=>g.card),o=iB(),{setCardPython:s,setRunSql:i}=p.useEditorActions(),a=v.useMemo(()=>o!==r.type?{...r,type:o}:r,[r,o]),{queryKey:c}=Nb(a),u=Zr(),d=v.useRef(c);d.current=c;const{value:f,onChange:h,flush:m}=Wxe({storeValue:n,defaultValue:at.PYTHON_DEFAULT_CODE,onStoreUpdate:s,delay:Q_t});return v.useEffect(()=>zxe(m),[m]),l.jsx(p.CodeEditor,{ref:t,value:f??"",onValueChange:h,language:"python",embedded:!0,hideLineNumbers:!0,wrapLines:!0,className:"[&_.code-editor-pre]:!pt-2 [&_.code-editor-textarea]:!pt-2",onKeyDown:g=>{g.key==="Enter"&&g.shiftKey&&(g.preventDefault(),sB(),setTimeout(()=>{u.removeQueries({queryKey:d.current,exact:!0}),i(!0)},0))}})}const eTt=v.forwardRef(J_t),Kxe=new Set(["askForMoreInfo","getAvailableChartTypes","getChartSQLSyntax","getDomainRelationships","getTableColumns","getUserSql","validateCardConfigFormat"]),tTt=new Set(["createChartFromSql","createForecast","generateQueryConfig","getChartDataFromCardConfig","getChartDataFromSqlAndPython","getForecastDataFromSqlAndPython"]),nTt=Array.from(Kxe).join(", "),rTt=3,oTt="Self-heal",sTt=new Set(["SQL_PARSE_ERROR","SQL_EXPLAIN_ERROR"]);function iTt({card:e}){var z,F,G,q,Y;const t=xl(),[n,r]=v.useState({}),{authToken:o}=It(),s=p.getTokenParams(o==null?void 0:o.accessToken),{compiledAppearance:i}=oi.useAppearance(),a=v.useMemo(()=>Vw(i),[i]),c=p.useEditorStore(K=>K.frame),u=p.useEditorStore(K=>K.inlineFilterValuesMap[e.id]),d=p.useEditorStore(K=>K.actions.setCardInlineFilterValue),f=p.useEditorStore(K=>K.actions.removeCardInlineFilterValue),h=e,{getCard:m,manifest:g}=_f(((z=h.customCardPreferences)==null?void 0:z.url)||""),x=(F=g==null?void 0:g.visuals)==null?void 0:F.find(K=>{var $;return K.name===(($=h.customCardPreferences)==null?void 0:$.componentName)}),b=at.resolveMultiInputType(h,x)??"single",y=v.useMemo(()=>at.getCustomVisualInputCards({frame:c,configCard:h,isMultiInputVisual:b==="multiple"}),[c,h,b]),w=v.useMemo(()=>{const K=y.findIndex($=>($==null?void 0:$.id)===e.id);return K<0?-1:at.getSlotIndexForCard(e,K)},[y,e]),C=v.useMemo(()=>b!=="multiple"||w<0?e.type:at.getEffectiveCardTypeForSlot(e,w,x==null?void 0:x.slots)??e.type,[b,w,e,x==null?void 0:x.slots]),N=v.useMemo(()=>b==="multiple"?{...e,connectionId:void 0,dataSource:void 0,sql:"",python:"",config:void 0,queryConfig:void 0}:C!==e.type?{...e,type:C}:e,[e,C,b]),{data:S,effectiveCardConfig:j}=Nb(N),I=p.useInteractionStore(K=>K.interactionStates),k=p.useDashboardStore(K=>{var $;return($=K.dashboard)==null?void 0:$.id}),T=p.useDashboardStore(K=>K.dashboard.filters),_=p.useDashboardStore(K=>K.filterValues),E=p.useDashboardStore(K=>K.selectedSheetId),D=v.useMemo(()=>U$({card:e,sheetId:E||"",inlineFilterValues:u,setInlineFilterValue:K=>d(e.id,K),removeInlineFilterValue:K=>f(e.id,K)}),[e,E,u,d,f]),{cardFilters:M,cardFilterValues:P}=v.useMemo(()=>bI({card:e,interactionStates:I,currentDashboardId:k,filters:T,filterValues:_,selectedSheetId:E}),[e,I,k,T,_,E]),A=v.useCallback((K,$)=>{const X=at.normalizeMultiInputPayload($);r(W=>({...W,[K]:X}))},[]),L=(G=h.customCardPreferences)==null?void 0:G.componentName,O=L?m(L):null,B=Hj((q=h.customCardPreferences)==null?void 0:q.settings,h),H=v.useMemo(()=>at.buildSlotOrderedCards(y),[y]),R=v.useMemo(()=>H.map((K,$)=>at.getEffectiveCardTypeForSlot(K,$,x==null?void 0:x.slots)),[H,x==null?void 0:x.slots]),V=v.useMemo(()=>G$(b==="multiple"?K$({slotOrderedCards:H,multiInputData:n,valueFormatPreferences:t}):[{card:e,cardConfig:j,columns:S==null?void 0:S.columns,columnKeyMap:S==null?void 0:S.columnKeyMap,valueFormatPreferences:t}]),[e,S==null?void 0:S.columnKeyMap,S==null?void 0:S.columns,j,n,H,b,t]);return L?l.jsx("div",{className:"semaphor-custom mb-3 flex grow basis-0 flex-col space-y-2 overflow-y-auto",children:l.jsxs(v.Suspense,{fallback:l.jsx(l.Fragment,{}),children:[O&&b==="single"&&l.jsx(O,{editing:!0,params:s,theme:a,settings:B,cardMetadata:Eue({card:e,dataMetadata:S==null?void 0:S.metadata}),onDataChange:A,data:(S==null?void 0:S.records)||[],columns:(S==null?void 0:S.columns)||[],formatTemporalBucketValue:V,filters:M,filterValues:[...P||[],...u||[]],inlineFilters:D}),O&&b==="multiple"&&l.jsxs(l.Fragment,{children:[y.map((K,$)=>{if(!K)return null;const X=at.getSlotIndexForCard(K,$),W=at.getEffectiveCardTypeForSlot(K,X,x==null?void 0:x.slots);return l.jsx(g$,{onDataChange:A,card:K,effectiveCardType:W},`${K.id}-${X}`)}),l.jsx("div",{className:"flex flex-col gap-2",children:l.jsx(O,{editing:!0,onDataChange:A,...W$({configCard:h,slotOrderedCards:H,slotTypes:R,multiInputData:n,params:s,theme:a,chartSettings:B,filters:M,filterValues:[...P||[],...u||[]],inlineFilters:D,formatTemporalBucketValue:V})})})]})]},(Y=h.customCardPreferences)==null?void 0:Y.componentName)}):null}const aTt=v.memo(iTt),lTt=p.create()(p.persist((e,t)=>({starredCharts:[],isStarred:(n,r)=>t().starredCharts.some(o=>o.type===n&&o.id===r),toggleStar:n=>{e(r=>{const o=r.starredCharts.findIndex(s=>s.type===n.type&&s.id===n.id);return o>=0?{starredCharts:r.starredCharts.filter((s,i)=>i!==o)}:{starredCharts:[...r.starredCharts,n]}})},getStarredChart:(n,r)=>t().starredCharts.find(o=>o.type===n&&o.id===r)}),{name:"semaphor-starred-charts"}));var Gxe=["PageUp","PageDown"],Yxe=["ArrowUp","ArrowDown","ArrowLeft","ArrowRight"],Zxe={"from-left":["Home","PageDown","ArrowDown","ArrowLeft"],"from-right":["Home","PageDown","ArrowDown","ArrowRight"],"from-bottom":["Home","PageDown","ArrowDown","ArrowLeft"],"from-top":["Home","PageDown","ArrowUp","ArrowLeft"]},gx="Slider",[dO,cTt,uTt]=p.createCollection(gx),[Xxe]=p.createContextScope(gx,[uTt]),[dTt,GT]=Xxe(gx),Qxe=te.forwardRef((e,t)=>{const{name:n,min:r=0,max:o=100,step:s=1,orientation:i="horizontal",disabled:a=!1,minStepsBetweenThumbs:c=0,defaultValue:u=[r],value:d,onValueChange:f=()=>{},onValueCommit:h=()=>{},inverted:m=!1,form:g,...x}=e,b=te.useRef(new Set),y=te.useRef(0),C=i==="horizontal"?fTt:hTt,[N=[],S]=p.useControllableState({prop:d,defaultProp:u,onChange:E=>{var M;(M=[...b.current][y.current])==null||M.focus(),f(E)}}),j=te.useRef(N);function I(E){const D=xTt(N,E);_(E,D)}function k(E){_(E,y.current)}function T(){const E=j.current[y.current];N[y.current]!==E&&h(N)}function _(E,D,{commit:M}={commit:!1}){const P=CTt(s),A=STt(Math.round((E-r)/s)*s+r,P),L=p.clamp(A,[r,o]);S((O=[])=>{const B=gTt(O,L,D);if(wTt(B,c*s)){y.current=B.indexOf(L);const H=String(B)!==String(O);return H&&M&&h(B),H?B:O}else return O})}return l.jsx(dTt,{scope:e.__scopeSlider,name:n,disabled:a,min:r,max:o,valueIndexToChangeRef:y,thumbs:b.current,values:N,orientation:i,form:g,children:l.jsx(dO.Provider,{scope:e.__scopeSlider,children:l.jsx(dO.Slot,{scope:e.__scopeSlider,children:l.jsx(C,{"aria-disabled":a,"data-disabled":a?"":void 0,...x,ref:t,onPointerDown:p.composeEventHandlers(x.onPointerDown,()=>{a||(j.current=N)}),min:r,max:o,inverted:m,onSlideStart:a?void 0:I,onSlideMove:a?void 0:k,onSlideEnd:a?void 0:T,onHomeKeyDown:()=>!a&&_(r,0,{commit:!0}),onEndKeyDown:()=>!a&&_(o,N.length-1,{commit:!0}),onStepKeyDown:({event:E,direction:D})=>{if(!a){const A=Gxe.includes(E.key)||E.shiftKey&&Yxe.includes(E.key)?10:1,L=y.current,O=N[L],B=s*A*D;_(O+B,L,{commit:!0})}}})})})})});Qxe.displayName=gx;var[Jxe,eye]=Xxe(gx,{startEdge:"left",endEdge:"right",size:"width",direction:1}),fTt=te.forwardRef((e,t)=>{const{min:n,max:r,dir:o,inverted:s,onSlideStart:i,onSlideMove:a,onSlideEnd:c,onStepKeyDown:u,...d}=e,[f,h]=te.useState(null),m=p.useComposedRefs(t,C=>h(C)),g=te.useRef(void 0),x=p.useDirection(o),b=x==="ltr",y=b&&!s||!b&&s;function w(C){const N=g.current||f.getBoundingClientRect(),S=[0,N.width],I=aB(S,y?[n,r]:[r,n]);return g.current=N,I(C-N.left)}return l.jsx(Jxe,{scope:e.__scopeSlider,startEdge:y?"left":"right",endEdge:y?"right":"left",direction:y?1:-1,size:"width",children:l.jsx(tye,{dir:x,"data-orientation":"horizontal",...d,ref:m,style:{...d.style,"--radix-slider-thumb-transform":"translateX(-50%)"},onSlideStart:C=>{const N=w(C.clientX);i==null||i(N)},onSlideMove:C=>{const N=w(C.clientX);a==null||a(N)},onSlideEnd:()=>{g.current=void 0,c==null||c()},onStepKeyDown:C=>{const S=Zxe[y?"from-left":"from-right"].includes(C.key);u==null||u({event:C,direction:S?-1:1})}})})}),hTt=te.forwardRef((e,t)=>{const{min:n,max:r,inverted:o,onSlideStart:s,onSlideMove:i,onSlideEnd:a,onStepKeyDown:c,...u}=e,d=te.useRef(null),f=p.useComposedRefs(t,d),h=te.useRef(void 0),m=!o;function g(x){const b=h.current||d.current.getBoundingClientRect(),y=[0,b.height],C=aB(y,m?[r,n]:[n,r]);return h.current=b,C(x-b.top)}return l.jsx(Jxe,{scope:e.__scopeSlider,startEdge:m?"bottom":"top",endEdge:m?"top":"bottom",size:"height",direction:m?1:-1,children:l.jsx(tye,{"data-orientation":"vertical",...u,ref:f,style:{...u.style,"--radix-slider-thumb-transform":"translateY(50%)"},onSlideStart:x=>{const b=g(x.clientY);s==null||s(b)},onSlideMove:x=>{const b=g(x.clientY);i==null||i(b)},onSlideEnd:()=>{h.current=void 0,a==null||a()},onStepKeyDown:x=>{const y=Zxe[m?"from-bottom":"from-top"].includes(x.key);c==null||c({event:x,direction:y?-1:1})}})})}),tye=te.forwardRef((e,t)=>{const{__scopeSlider:n,onSlideStart:r,onSlideMove:o,onSlideEnd:s,onHomeKeyDown:i,onEndKeyDown:a,onStepKeyDown:c,...u}=e,d=GT(gx,n);return l.jsx(p.Primitive.span,{...u,ref:t,onKeyDown:p.composeEventHandlers(e.onKeyDown,f=>{f.key==="Home"?(i(f),f.preventDefault()):f.key==="End"?(a(f),f.preventDefault()):Gxe.concat(Yxe).includes(f.key)&&(c(f),f.preventDefault())}),onPointerDown:p.composeEventHandlers(e.onPointerDown,f=>{const h=f.target;h.setPointerCapture(f.pointerId),f.preventDefault(),d.thumbs.has(h)?h.focus():r(f)}),onPointerMove:p.composeEventHandlers(e.onPointerMove,f=>{f.target.hasPointerCapture(f.pointerId)&&o(f)}),onPointerUp:p.composeEventHandlers(e.onPointerUp,f=>{const h=f.target;h.hasPointerCapture(f.pointerId)&&(h.releasePointerCapture(f.pointerId),s(f))})})}),nye="SliderTrack",rye=te.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=GT(nye,n);return l.jsx(p.Primitive.span,{"data-disabled":o.disabled?"":void 0,"data-orientation":o.orientation,...r,ref:t})});rye.displayName=nye;var fO="SliderRange",oye=te.forwardRef((e,t)=>{const{__scopeSlider:n,...r}=e,o=GT(fO,n),s=eye(fO,n),i=te.useRef(null),a=p.useComposedRefs(t,i),c=o.values.length,u=o.values.map(h=>aye(h,o.min,o.max)),d=c>1?Math.min(...u):0,f=100-Math.max(...u);return l.jsx(p.Primitive.span,{"data-orientation":o.orientation,"data-disabled":o.disabled?"":void 0,...r,ref:a,style:{...e.style,[s.startEdge]:d+"%",[s.endEdge]:f+"%"}})});oye.displayName=fO;var hO="SliderThumb",sye=te.forwardRef((e,t)=>{const n=cTt(e.__scopeSlider),[r,o]=te.useState(null),s=p.useComposedRefs(t,a=>o(a)),i=te.useMemo(()=>r?n().findIndex(a=>a.ref.current===r):-1,[n,r]);return l.jsx(mTt,{...e,ref:s,index:i})}),mTt=te.forwardRef((e,t)=>{const{__scopeSlider:n,index:r,name:o,...s}=e,i=GT(hO,n),a=eye(hO,n),[c,u]=te.useState(null),d=p.useComposedRefs(t,w=>u(w)),f=c?i.form||!!c.closest("form"):!0,h=p.useSize(c),m=i.values[r],g=m===void 0?0:aye(m,i.min,i.max),x=bTt(r,i.values.length),b=h==null?void 0:h[a.size],y=b?yTt(b,g,a.direction):0;return te.useEffect(()=>{if(c)return i.thumbs.add(c),()=>{i.thumbs.delete(c)}},[c,i.thumbs]),l.jsxs("span",{style:{transform:"var(--radix-slider-thumb-transform)",position:"absolute",[a.startEdge]:`calc(${g}% + ${y}px)`},children:[l.jsx(dO.ItemSlot,{scope:e.__scopeSlider,children:l.jsx(p.Primitive.span,{role:"slider","aria-label":e["aria-label"]||x,"aria-valuemin":i.min,"aria-valuenow":m,"aria-valuemax":i.max,"aria-orientation":i.orientation,"data-orientation":i.orientation,"data-disabled":i.disabled?"":void 0,tabIndex:i.disabled?void 0:0,...s,ref:d,style:m===void 0?{display:"none"}:e.style,onFocus:p.composeEventHandlers(e.onFocus,()=>{i.valueIndexToChangeRef.current=r})})}),f&&l.jsx(iye,{name:o??(i.name?i.name+(i.values.length>1?"[]":""):void 0),form:i.form,value:m},r)]})});sye.displayName=hO;var pTt="RadioBubbleInput",iye=te.forwardRef(({__scopeSlider:e,value:t,...n},r)=>{const o=te.useRef(null),s=p.useComposedRefs(o,r),i=p.usePrevious(t);return te.useEffect(()=>{const a=o.current;if(!a)return;const c=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(c,"value").set;if(i!==t&&d){const f=new Event("input",{bubbles:!0});d.call(a,t),a.dispatchEvent(f)}},[i,t]),l.jsx(p.Primitive.input,{style:{display:"none"},...n,ref:s,defaultValue:t})});iye.displayName=pTt;function gTt(e=[],t,n){const r=[...e];return r[n]=t,r.sort((o,s)=>o-s)}function aye(e,t,n){const s=100/(n-t)*(e-t);return p.clamp(s,[0,100])}function bTt(e,t){return t>2?`Value ${e+1} of ${t}`:t===2?["Minimum","Maximum"][e]:void 0}function xTt(e,t){if(e.length===1)return 0;const n=e.map(o=>Math.abs(o-t)),r=Math.min(...n);return n.indexOf(r)}function yTt(e,t,n){const r=e/2,s=aB([0,50],[0,r]);return(r-s(t)*n)*n}function vTt(e){return e.slice(0,-1).map((t,n)=>e[n+1]-t)}function wTt(e,t){if(t>0){const n=vTt(e);return Math.min(...n)>=t}return!0}function aB(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function CTt(e){return(String(e).split(".")[1]||"").length}function STt(e,t){const n=Math.pow(10,t);return Math.round(e*n)/n}var lye=Qxe,NTt=rye,jTt=oye,kTt=sye;const cye=te.forwardRef(({className:e,...t},n)=>l.jsxs(lye,{ref:n,className:p.cn("relative flex w-full touch-none select-none items-center",e),...t,children:[l.jsx(NTt,{className:"relative h-2 w-full grow overflow-hidden rounded-full bg-secondary",children:l.jsx(jTt,{className:"absolute h-full bg-primary"})}),l.jsx(kTt,{className:"block h-5 w-5 rounded-full border-2 border-primary bg-background ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50"})]}));cye.displayName=lye.displayName;exports.Accordion=u4;exports.AccordionContent=Nv;exports.AccordionItem=Cv;exports.AccordionTrigger=Sv;exports.AddDataPicker=J4;exports.AggregateTable=S_;exports.Alert=fL;exports.AlertDescription=hL;exports.AlertDialog=gf;exports.AlertDialogAction=Ou;exports.AlertDialogCancel=Lu;exports.AlertDialogContent=Mu;exports.AlertDialogDescription=Fu;exports.AlertDialogFooter=Au;exports.AlertDialogHeader=Ru;exports.AlertDialogTitle=Pu;exports.AlertDialogTrigger=S1e;exports.AlertTitle=Mte;exports.ArrowDown=ss;exports.ArrowDownIcon=QQe;exports.ArrowLeft=Yv;exports.ArrowRight=Zv;exports.ArrowUp=ws;exports.ArrowUpIcon=eJe;exports.AssistantContextEntityControls=iO;exports.AssistantVirtualizedMessages=Txe;exports.AxisConfigurator=Xm;exports.BackgroundRunPill=Rut;exports.Badge=yi;exports.Bell=w1;exports.BookType=wZ;exports.BriefingAuthor=lhe;exports.BriefingAuthorDialog=che;exports.BriefingUiCapabilitiesBoundary=tdt;exports.BriefingUiCapabilitiesProvider=cT;exports.BriefingsApiError=Qw;exports.BulletChartIcon=wxe;exports.CSS=Ji;exports.CalculatedFieldEditor=$me;exports.Calculator=SZ;exports.Calendar=Wa;exports.CalendarClock=DO;exports.Card=CN;exports.CardContent=EO;exports.CardHeader=TO;exports.CardSummary=dF;exports.CardTitle=xb;exports.ChartArea=CR;exports.ChartColumnIncreasing=jZ;exports.ChartColumnStacked=kZ;exports.ChartJsVisual=Ow;exports.ChartLine=IZ;exports.ChartNoAxesGantt=TZ;exports.ChartPie=EZ;exports.ChartScatter=DZ;exports.ChatInputWithContext=eB;exports.Checkbox=An;exports.ChevronLeft=Lm;exports.ChevronsUpDown=AZ;exports.Circle=MO;exports.CircleAlert=Ia;exports.CircleCheck=PZ;exports.CircleHelp=FZ;exports.Clock=OZ;exports.CodeHighlighter=Bd;exports.CodeXml=C1;exports.Collapsible=ku;exports.CollapsibleContent=_u;exports.CollapsibleTrigger=Iu;exports.ColorField=ga;exports.Command=yT;exports.CommandEmpty=wT;exports.CommandGroup=CT;exports.CommandInput=Qz;exports.CommandItem=ST;exports.CommandList=vT;exports.CommandSeparator=ome;exports.ComparisonMetadataBadge=ese;exports.Container=a5;exports.ControlDefaultValueEditor=lpe;exports.ControlDefinitionOptionsEditor=ape;exports.ControlIdInput=rpe;exports.ControlVisibilitySettings=ybt;exports.Copy=rm;exports.CopyButton=zd;exports.CopyPlus=NR;exports.Cross2Icon=oJe;exports.CustomFilterPopover=H$;exports.CustomScrollArea=yl;exports.DEFAULT_HEATMAP_CUSTOM_RANGE=Qre;exports.Dashboard=Oxe;exports.DashboardCard=hhe;exports.DashboardCreateDialogBase=EQ;exports.DashboardExportDialog=Exe;exports.DashboardPlus=k_t;exports.DashboardWC=W_t;exports.DataTableConditionalFormattingSettings=Xpe;exports.DataTablePagination=h_;exports.Database=Go;exports.DateRangePicker=$$;exports.DefaultChatTransport=q4;exports.Dialog=So;exports.DialogContent=po;exports.DialogDescription=Oo;exports.DialogFooter=al;exports.DialogHeader=Ds;exports.DialogTitle=go;exports.DialogTrigger=IQ;exports.DisplayFormatPreferencesFields=E_t;exports.DisplayPreferencesProvider=J_;exports.DndContext=cC;exports.Donut=LZ;exports.Download=Tu;exports.DownloadPdf=Dxe;exports.DragOverlay=qhe;exports.DropdownMenu=Xo;exports.DropdownMenuCheckboxItem=ad;exports.DropdownMenuContent=Fo;exports.DropdownMenuItem=In;exports.DropdownMenuLabel=Za;exports.DropdownMenuRadioGroup=ECe;exports.DropdownMenuRadioItem=JX;exports.DropdownMenuSeparator=Ta;exports.DropdownMenuSub=QO;exports.DropdownMenuSubContent=Kk;exports.DropdownMenuSubTrigger=Wk;exports.DropdownMenuTrigger=Qo;exports.EMPTY_DATA_SOURCE=mb;exports.Editable=Uj;exports.EditableText=Si;exports.EditorCustomVisual=aTt;exports.Ellipsis=Ii;exports.EllipsisVertical=$m;exports.ErrorBoundary=_i;exports.ExportError=Pb;exports.ExternalLink=Vd;exports.EyeOff=Vk;exports.Fallback=X_;exports.FallbackVisual=Yw;exports.FeedbackCategory=ff;exports.FeedbackDialog=Pv;exports.FieldsList=y4;exports.FieldsSection=K_t;exports.FileCode=$Z;exports.FileText=ti;exports.Filter=Hd;exports.FilterComponent=W_;exports.FilterInfo=aF;exports.FilterableFieldsPanel=Bme;exports.Grid3x3=jR;exports.GripVertical=Eu;exports.HEATMAP_PRESET_PALETTES=OA;exports.Hash=yb;exports.House=zZ;exports.HoverCard=np;exports.HoverCardContent=Su;exports.HoverCardTrigger=Jd;exports.INLINE_ALLOWED_READ_ONLY_TOOLS=Kxe;exports.INLINE_ALLOWED_TOOL_LIST=nTt;exports.INLINE_BLOCKED_MUTATING_TOOLS=tTt;exports.IconButton=au;exports.IconForFieldType=cN;exports.Inbox=AO;exports.InfoHover=uz;exports.InlineFilterBar=sde;exports.KPICard=sf;exports.KeyboardSensor=aC;exports.Layers=Bm;exports.Link=PO;exports.LoadingDots=uc;exports.MAX_SELF_HEAL_ATTEMPTS=rTt;exports.Map=qZ;exports.Markdown=Az;exports.MatrixTableVisual=C_;exports.MdStackedLineChart=yxe;exports.MultiInputEmptyRenderer=g$;exports.PanelResizeHandle=zT;exports.Pause=UZ;exports.PenLine=_R;exports.Pencil=TR;exports.PendingMessagesDisplay=cxe;exports.PersistedDynamicVisual=Q_;exports.PiChartPolar=pxe;exports.Pin=KZ;exports.PinOff=WZ;exports.PivotTableTanstack=tx;exports.Placeholders=Nge;exports.Play=GZ;exports.Plus=Mr;exports.PointerSensor=lx;exports.Progress=Z4;exports.PythonEditor=eTt;exports.RECOVERABLE_SQL_ERROR_CODES=sTt;exports.Radar=YZ;exports.RadioGroup=wu;exports.RadioGroupItem=Qs;exports.RefreshCw=_a;exports.ResizableHandle=Rvt;exports.ResizablePanel=GF;exports.ResizablePanelGroup=Sge;exports.ResourceEditDialog=aJ;exports.ResourceType=mo;exports.Rows3=ZZ;exports.RunCompletionBanner=Aut;exports.SELF_HEAL_TIMELINE_STEP=oTt;exports.SeedQuestions=Gbe;exports.SemaphorContext=qv;exports.SemaphorContextProvider=vO;exports.SemaphorQueryClient=UY;exports.SemaphorReadyIndicator=oB;exports.SemaphorStyleWrapper=nx;exports.Send=OO;exports.SendHorizontal=XZ;exports.Settings=LO;exports.Settings2=mf;exports.Share2=QZ;exports.ShareDialog=iJ;exports.Sheet=g3;exports.SheetContent=m_;exports.SheetDescription=g_;exports.SheetHeader=qoe;exports.SheetTitle=p_;exports.SheetTrigger=_4e;exports.Slider=cye;exports.SortableContext=uC;exports.Sparkles=j0;exports.SqlEditor=X_t;exports.Square=zO;exports.SquarePen=$O;exports.Star=JZ;exports.StructuralParticipantSelector=ope;exports.SummaryCard=oF;exports.TABLE_PRESENTATION_DEFAULT_STYLE=Ld;exports.TABLE_PRESENTATION_DEFAULT_TOTALS_STYLE=xa;exports.TableBody=Qd;exports.TableCell=Kn;exports.TableColumnVisibilitySettings=$pe;exports.TableHead=wo;exports.TableHeader=tp;exports.TablePresentationSettings=Bpe;exports.TableRow=Lr;exports.TableSkeleton=fz;exports.TableVisual=ef;exports.Tag=eX;exports.TbChartBubble=gxe;exports.TbChartFunnel=bxe;exports.TbChartTreemap=xxe;exports.TextCard=ib;exports.Textarea=Um;exports.TiSortNumerically=vxe;exports.Toggle=Uxe;exports.Tornado=tX;exports.Trash2=il;exports.TriangleAlert=Yo;exports.TypeGlyph=nC;exports.UXProvider=rB;exports.Undo2=nX;exports.User=VO;exports.Users=Hk;exports.UsersRound=HO;exports.VisualErrorState=Uue;exports.Zap=ER;exports.applyBriefingFormPatch=hv;exports.areContextEntitiesEqual=cr;exports.areEntitiesJoined=noe;exports.arrayMove=cx;exports.briefingFormDraftToCreateRequest=mF;exports.briefingFormDraftToUpdateRequest=Vde;exports.briefingToFormDraft=sg;exports.briefingTone=Er;exports.buildCardControlUsageById=wbt;exports.buildCustomCardTheme=Vw;exports.buildDashboardControlUsageById=vbt;exports.buildDashboardSheetsInputExecutionSnapshot=_O;exports.buildDashboardStructuralParticipantIdsByControlId=dpe;exports.buildFilterFieldMeta=o4;exports.buildFilterSemanticContext=s4;exports.buildInlineFilterNodes=U$;exports.buildMultiInputCustomVisualProps=W$;exports.buildMultiInputTemporalPresentationInputs=K$;exports.calculateCardFilterValues=gI;exports.calculateContextAwareFilters=bI;exports.calculateFieldState=r3;exports.canEditLocalCalculatedFields=p4;exports.canUserAccessVisuals=TNe;exports.canUserCreateDashboards=cJ;exports.canUserEdit=kNe;exports.canUserManageDashboards=_Ne;exports.canUserManageGroups=ENe;exports.canUserUseFilters=INe;exports.cancelBriefingPreviewRun=Ede;exports.cancelBriefingRun=Mde;exports.cancelExport=$$e;exports.chartSupportsDataLabels=Yne;exports.chartSupportsLegend=Kne;exports.chartTypes=KT;exports.cleanupKpiMetricComparisonMode=hme;exports.cloneDeep=Ys;exports.cloneLinkedFrameWithSourceMapping=Ptt;exports.closestCenter=iC;exports.commitSharedCalculatedFields=rh;exports.createAssistantConversationId=Gp;exports.createAssistantRequestId=Wbe;exports.createBriefing=Cde;exports.createBriefingFormDraft=hF;exports.createChartConfig=Rb;exports.createCustomVisualTemporalBucketFormatter=G$;exports.createDashboardControlInputFromControl=v0t;exports.createExport=yoe;exports.currencyPresentationTargetKey=Ca;exports.dedup=_jt;exports.dedupeContextEntities=Vz;exports.deleteBriefing=jde;exports.deleteBriefingRun=Rde;exports.diagnoseCurrencyPresentationBindings=q0e;exports.doesStoredFilterMatchField=fb;exports.downloadDocumentPdf=aL;exports.downloadPdf=cte;exports.extractSqlParamReferences=KY;exports.extractTableMetadata=r4;exports.fieldAlreadyExists=ooe;exports.flexRender=wi;exports.flushPendingEditorDrafts=sB;exports.formatDisplayFormula=gpt;exports.formatFileSize=V$e;exports.getAutoDetectedChartIcon=oIt;exports.getBriefing=wde;exports.getBriefingArtifact=Fnt;exports.getBriefingEvidence=Ont;exports.getBriefingPreviewRun=Tde;exports.getBriefingRun=Dde;exports.getCardCurrencyPresentationFields=jO;exports.getCardCurrencyPresentationTargets=kO;exports.getChartGridStyle=FDe;exports.getChartIconByType=sIt;exports.getColorForValue=XR;exports.getCoreRowModel=u_;exports.getDefaultAxisConfig=nA;exports.getDefaultChartColors=Zm;exports.getDefaultDataLabelsConfig=yw;exports.getDefaultLegendConfig=$L;exports.getDefaultRunningTotalPartitionByFieldIds=b0;exports.getDisplayedKpiResultColumnKeys=Cw;exports.getDocumentSectionEditorCard=Jgt;exports.getDocumentSheetDashboardInputs=fx;exports.getDownloadUrl=L$e;exports.getEntityIcon=Rk;exports.getErrorMessage=Mbe;exports.getExportStatus=O$e;exports.getExports=F$e;exports.getExpressionFieldKind=lf;exports.getFieldExpressionAnnotation=i4;exports.getFilterCount=Zj;exports.getGranularityOptionsForFieldType=npe;exports.getKeys=Cr;exports.getMatrixVisualLoadingState=a_;exports.getMetricDisplayLabel=Q3e;exports.getNewField=coe;exports.getObjectDiff=jY;exports.getPaginationRowModel=d_;exports.getRoleBasedDisplayOverrides=lJ;exports.getRunningTotalOrderByCandidates=$mt;exports.getSelectedDateFilterColumn=due;exports.getSortedRowModel=Boe;exports.getTableConditionalFormattingColumnOptions=Upe;exports.getTableOutputColumnOptions=Wpe;exports.getTablePageSizeOptions=boe;exports.handleAggregationChange=lF;exports.handleAggregationLabelChange=rde;exports.hasFlatTableTotalsBehavior=Ym;exports.hasMatrixResultData=Nw;exports.horizontalListSortingStrategy=Gz;exports.inferSemanticDomainIdFromSelectedEntities=Mk;exports.isActiveBriefingRunStatus=tk;exports.isCardSummaryVisibleOnCard=Y$;exports.isCurrencyPresentationControl=V0e;exports.isDefaultColor=eEe;exports.isEligibleFlatTableTotalsCard=dw;exports.isExportComplete=B$e;exports.isExportInProgress=z$e;exports.isInAiScopeArray=Ijt;exports.isManagedCalculatedExpressionField=ol;exports.isMetricTransformEnabled=Omt;exports.isPresentationCurrencyBinding=Kv;exports.isPromiseLike=sO;exports.isSqlBackedKpi=uoe;exports.isStructuralControlBinding=B0e;exports.isSubtotalEnabledAggregateTable=n4;exports.isSupportedDocumentTableCardType=ebt;exports.isTableType=CDe;exports.isTerminalBriefingRunStatus=ek;exports.lastAssistantMessageIsCompleteWithToolCalls=_be;exports.listBriefingRuns=Pnt;exports.listBriefingTenantSummaries=Ant;exports.listBriefings=Rnt;exports.merge=sc;exports.mergeAxisConfig=rA;exports.normalizeConditionalFormatting=H5;exports.normalizeContextFormatMode=Oee;exports.pauseBriefing=Sde;exports.pivotData=hw;exports.polishBriefingText=Ade;exports.prepareFeedbackData=WT;exports.previewBriefingPlan=Ide;exports.remarkGfm=Lz;exports.removeFromScopeArray=Tjt;exports.requiresDashboardInputResolution=hf;exports.resolveCurrencyPresentationTargetFormat=Bee;exports.resolveDashboardBriefingsVisibility=uhe;exports.resolveDashboardControlsVisibility=ANe;exports.resolveDashboardInputContext=Ti;exports.resolveDashboardTitleEditability=RNe;exports.resolveDomainCalculatedFieldForEdit=dgt;exports.resolveMatrixCardMeasureInstances=zk;exports.resolvePendingPivotTableResultState=k$e;exports.resolveTablePageSize=o_;exports.resolveTablePresentationStyle=N3;exports.resumeBriefing=Nde;exports.runBriefingNow=kde;exports.runBriefingPreview=_de;exports.sanitizeAIScope=Dbe;exports.saveCalculatedFieldToCardScope=$F;exports.saveCalculatedFieldToSharedScope=zme;exports.saveCalculatedFieldToSheetScope=zF;exports.seedSemanticMetricFormatDefaults=pme;exports.setTableColumnVisibility=Coe;exports.setupEditorWithCard=RI;exports.showAllTableColumns=Q$e;exports.showJoinRequiredNotification=roe;exports.sortByColumnsToSortState=use;exports.sortStateToSortByColumns=dse;exports.sortableKeyboardCoordinates=Zz;exports.supportsLiveNumericPresentation=Wv;exports.supportsMetricTransformForMetric=mme;exports.supportsTableConditionalFormatting=Vpe;exports.toEntityArray=rl;exports.ue=it;exports.updateBriefing=tT;exports.useActiveExports=zNe;exports.useActiveToolStatus=dxe;exports.useAddFrameWithFreshSemanticExecutionPayload=cz;exports.useAddNewFrame=vhe;exports.useAssistantContainer=hJ;exports.useAssistantContextEntities=uT;exports.useAssistantLayoutStore=Fh;exports.useAssistantPanel=dJ;exports.useAssistantProfile=Kbe;exports.useAutoSubmitQueue=uxe;exports.useBrandStudioPreview=h_t;exports.useBriefingRunPolling=gF;exports.useBriefingUiCapabilities=dhe;exports.useCalendarContext=c$e;exports.useCard=g$e;exports.useCardNumericPresentation=Pa;exports.useCardSummary=Z$;exports.useChartNumericPresentation=Ab;exports.useChat=Ebe;exports.useColumns=Jz;exports.useCreateVisualWithFrame=kSe;exports.useCurrentUserInfo=si;exports.useCustomVisual=_f;exports.useCustomVisualsQuery=V$;exports.useDashboardAppearance=$u;exports.useDashboardById=lQ;exports.useDashboardInteractionMode=ede;exports.useDashboardPreferences=Hm;exports.useDashboardQuery=Uv;exports.useDashboardStructuralParticipants=fpe;exports.useDashboardSummary=Oue;exports.useDataColumns=bme;exports.useDateFilterHook=TYe;exports.useDefaultDashboardMutation=tQ;exports.useDisplayPreferences=pl;exports.useDroppable=Hhe;exports.useEditorAside=NT;exports.useEditorCardQuery=Nb;exports.useEffectiveEditorCardType=iB;exports.useEnsureReactGlobals=Ple;exports.useExportActions=mJ;exports.useExportStore=nI;exports.useFieldManagement=gme;exports.useFilterableFields=ume;exports.useFullscreenAssistant=fJ;exports.useGroupMembers=_1e;exports.useGroups=s5;exports.useHasDashboardId=pJ;exports.useInProgressExportsCount=BNe;exports.useJoinabilityMap=t4;exports.useManagementActions=Om;exports.useManagementStore=Es;exports.useMutation=Ts;exports.usePivotTableConfig=Jm;exports.usePluginQuery=Sue;exports.useQuery=qn;exports.useQueryClient=Zr;exports.useReactTable=f_;exports.useResolveExistingFrameSemanticExecutionPayload=$tt;exports.useResolvedDefaultCurrency=i3;exports.useResolvedTemporalStylePreferences=xl;exports.useResolvedValueFormatLocale=s3;exports.useResourceManagement=e5;exports.useResourceUpdateState=cQ;exports.useScopedFields=cme;exports.useSelectedVisual=I0e;exports.useSemaphorContext=It;exports.useSensor=db;exports.useSensors=mT;exports.useSortable=ux;exports.useStarredChartsStore=lTt;exports.useSurfaceAppearance=ml;exports.useTableQueryState=tse;exports.useTextFilterHook=sWe;exports.useTheme=NY;exports.useTimezone=bl;exports.useTopoJson=ww;exports.useUnifiedUsers=eI;exports.useUpdateResource=oQ;exports.useUpdateVisualMutation=ISe;exports.useUserPreferences=DQ;exports.useVisualById=Yk;exports.useVisualManagement=jSe;exports.validateBriefingFormDraft=pF;exports.validateFieldForChartType=fme;exports.verticalListSortingStrategy=Yz;