@texturehq/edges 5.23.0 → 5.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{colors-DSr9KkYH.d.ts → colors-BbvlWkbj.d.ts} +8 -8
- package/dist/{colors-Bwk-3pEe.d.cts → colors-Dy4u9vTC.d.cts} +8 -8
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/server.cjs +1 -1
- package/dist/server.cjs.map +1 -1
- package/dist/server.d.cts +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -165,7 +165,7 @@ import {TooltipTrigger,Tooltip,OverlayArrow,composeRenderProps,DialogTrigger,Men
|
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
167
|
`}})]})}function Dn(e,t=300){let[r,o]=useState(e);return useEffect(()=>{let n=setTimeout(()=>o(e),t);return ()=>clearTimeout(n)},[e,t]),r}function jl(e,t=300){let[r,o]=useState(false);return useEffect(()=>{if(e){let n=setTimeout(()=>{o(true);},t);return ()=>clearTimeout(n)}o(false);},[e,t]),r}var $N=({isEntering:e,isExiting:t,className:r})=>["max-w-xs group bg-background-surface border border-border-default text-text-primary text-sm leading-relaxed rounded-lg shadow-lg will-change-transform px-3 py-2",e?"animate-in fade-in placement-bottom:slide-in-from-top-0.5 placement-top:slide-in-from-bottom-0.5 placement-left:slide-in-from-right-0.5 placement-right:slide-in-from-left-0.5 ease-out duration-200":"",t?"animate-out fade-out placement-bottom:slide-out-to-top-0.5 placement-top:slide-out-to-bottom-0.5 placement-left:slide-out-to-right-0.5 placement-right:slide-out-to-left-0.5 ease-in duration-150":"",r].filter(Boolean).join(" ");function Zh({content:e,tooltipRef:t,...r}){return jsxs(Tooltip,{...r,ref:t,offset:r.offset??8,className:composeRenderProps(r.className,(o,n)=>$N({...n,className:o})),children:[jsx(OverlayArrow,{children:jsx("svg",{width:8,height:8,viewBox:"0 0 8 8",className:"fill-background-surface stroke-border-default group-placement-left:-rotate-90 group-placement-right:rotate-90 group-placement-bottom:rotate-180 forced-colors:fill-[Canvas] forced-colors:stroke-[ButtonBorder]",children:jsx("path",{d:"M0 0 L4 4 L8 0"})})}),e]})}function ek({children:e,content:t,delay:r=200,closeDelay:o,...n}){let[a,i]=useState(false),s=useRef(false),l=useRef(null),d=useRef(null),c=useId();if(useEffect(()=>{if(!a)return;let m=()=>{s.current=false,i(false);},p=f=>{f.key==="Escape"&&m();},g=f=>{!(f.target instanceof Node)||document.querySelector(`[data-tooltip-trigger="${c}"]`)?.contains(f.target)||d.current?.contains(f.target)||m();};return document.addEventListener("keydown",p,true),document.addEventListener("pointerdown",g),()=>{document.removeEventListener("keydown",p,true),document.removeEventListener("pointerdown",g);}},[a,c]),useEffect(()=>()=>{l.current&&clearTimeout(l.current);},[]),!isValidElement(e))throw new Error("Tooltip with openOnPress requires a single pressable child");let u=ot__default.cloneElement(e,{"data-tooltip-trigger":c,onHoverStart:m=>{e.props.onHoverStart?.(m),l.current=setTimeout(()=>i(true),r);},onHoverEnd:m=>{e.props.onHoverEnd?.(m),l.current&&clearTimeout(l.current),s.current||i(false);},onPress:m=>{e.props.onPress?.(m),l.current&&clearTimeout(l.current),s.current=!s.current,i(s.current);}});return jsxs(TooltipTrigger,{delay:r,closeDelay:o,shouldCloseOnPress:false,isOpen:a,onOpenChange:m=>{!m&&s.current||i(m);},children:[u,jsx(Zh,{...n,content:t,tooltipRef:d})]})}function tr({children:e,content:t,openOnPress:r=false,delay:o=200,closeDelay:n,...a}){return r?jsx(ek,{...a,content:t,delay:o,closeDelay:n,children:e}):jsxs(TooltipTrigger,{delay:o,closeDelay:n,children:[e,jsx(Zh,{...a,content:t})]})}function Ar(){let[e,t]=ot__default.useState(false),r=ot__default.useCallback((n,a)=>{t(true),a?.(n);},[]),o=ot__default.useCallback((n,a)=>{t(false),a?.(n);},[]);return {isFocused:e,handleFocus:r,handleBlur:o}}var Dt=ot__default.forwardRef(({children:e,className:t},r)=>jsx("div",{ref:r,className:twMerge("relative w-full",t),children:e}));Dt.displayName="InputWrapper";function ms({onClick:e,size:t="md",className:r}){return jsx("button",{type:"button",onClick:o=>{o.preventDefault(),o.stopPropagation(),e();},className:twMerge("absolute right-2 top-[48%] -translate-y-1/2 transform text-text-secondary hover:text-text-primary cursor-pointer",r),"aria-label":"Clear input",onMouseDown:o=>{o.preventDefault(),o.stopPropagation();},children:jsx(G,{name:"X",size:t==="sm"?16:20})})}function An(e){let{isInvalid:t,isDisabled:r,isFocused:o}=e,n="border rounded-[var(--control-border-radius)] !outline-none ";return r?`${n} border-border-muted`:t&&o?`${n} border-feedback-error-border shadow-[inset_0_0_0_1px_var(--color-feedback-error-border)]`:t?`${n} border-feedback-error-border`:o?`${n} border-border-focus shadow-[inset_0_0_0_1px_var(--color-border-focus)]`:`${n} border-border-input`}function Qh(e){return e.isDisabled?"bg-background-muted":e.transparent?"bg-transparent":"bg-background-input"}function tk(e){return e==="sm"?"!text-base md:!text-[length:var(--control-text-sm)]":e==="md"?"!text-base md:!text-[length:var(--control-text-md)]":""}function rr(e){let{isInvalid:t,isDisabled:r,isFocused:o,transparent:n,size:a="md",className:i}=e;return twMerge("w-full",An({isInvalid:t,isDisabled:r,isFocused:o}),Qh({transparent:n,isDisabled:r}),_e[a].text,_e[a].height,_e[a].padding,tk(a),i)}function rk(e){let{size:t="md",isFocusWithin:r,isInvalid:o,isDisabled:n,transparent:a,className:i}=e;return twMerge("group flex items-center rounded-[var(--control-border-radius)] overflow-hidden",Qh({transparent:a,isDisabled:n}),_e[t].height,An({isFocused:r,isInvalid:o,isDisabled:n}),i)}function et({children:e,size:t="md",tooltip:r,description:o,descriptionPlacement:n="below",isRequired:a,className:i,htmlFor:s}){let l=r||o&&n==="tooltip",d=r||o,c=o&&n==="inline",u=jsxs("label",{htmlFor:s,className:twMerge(_e[t].text,"!text-text-label font-semibold flex items-center gap-1",i),children:[e,a&&jsx("span",{children:"*"}),l&&jsx("span",{className:"inline-flex items-center text-text-secondary",children:jsx(G,{name:"Info",size:t==="sm"?16:20})}),c&&jsx("span",{className:"text-text-secondary font-normal ml-1",children:o})]});return l&&d?jsx(tr,{content:d,children:u}):u}function Ee({size:e="md",className:t,children:r,...o}){return jsx("div",{...o,className:twMerge("leading-[2.25] text-text-secondary",_e[e].text,t),children:r})}function ye({children:e,size:t="md",className:r}){return jsx("div",{role:"alert",className:twMerge(_e[t].text,"text-feedback-error-text",r),children:e})}function Zl({size:e="md",isInvalid:t,isDisabled:r,isFocused:o,transparent:n,className:a,...i}){let s=r??i.disabled;return jsx("input",{className:rr({isInvalid:t,isDisabled:r,isFocused:o,transparent:n,size:e,className:a}),...i,disabled:s,"aria-disabled":s||void 0})}function _h(e){let{children:t,...r}=e;return jsx("div",{...r,className:rk(e),children:typeof t=="function"?t(e):t})}var Ip=createContext("md");function ob(){return useContext(Ip)}function Lp(e="md"){let t=e==="sm"?"!text-base md:!text-[length:var(--control-text-sm)]":e==="md"?"!text-base md:!text-[length:var(--control-text-md)]":"";return `flex-1 text-start data-[placeholder]:text-text-disabled overflow-hidden text-ellipsis whitespace-nowrap ${_e[e].text} ${t}`}function lk(){let e=ot__default.useCallback((r,o)=>{o?.(r);},[]),t=ot__default.useCallback((r,o)=>{o?.(r);},[]);return {handleFocus:e,handleBlur:t}}function on({label:e,description:t,errorMessage:r,children:o,items:n,renderItem:a,renderSelectedValue:i,size:s="md",selectedKey:l,defaultSelectedKey:d,onSelectionChange:c,placeholder:u,showErrors:m=false,tooltip:p,isRequired:g,transparent:f,reserveErrorSpace:b=false,placement:h="bottom start",shouldFlip:v=true,menuWidth:x="match",descriptionPlacement:C="below",useMobileTray:S=true,...w}){let[T,N]=useState(null),[k,R]=useState(null),[A,M]=useState(false),B=l??T??d,{handleFocus:D,handleBlur:W}=lk(),{isMobile:X}=Rr(),H=S&&X,I=ot__default.useMemo(()=>!i||!B||!n?null:Array.from(n).find(V=>V.id===B)??null,[i,B,n]),F=O=>{c&&O!==null&&c(O),c||N(O);},z=useRef(null),U=useRef(null),K=()=>{H&&M(!A);};return jsxs(Fragment,{children:[jsx(Select,{...w,selectedKey:B,defaultSelectedKey:d,onSelectionChange:F,placeholder:u,className:Fe(w.className,"group flex w-full flex-col"),ref:z,onOpenChange:O=>{H||(O&&U.current?R(U.current.offsetWidth):O||z.current?.blur());},children:({isDisabled:O,isInvalid:V,isOpen:L})=>jsxs("div",{className:"flex flex-col",children:[e&&jsx(et,{size:s,tooltip:p,description:C==="tooltip"||C==="inline"?t:void 0,descriptionPlacement:C,isRequired:g,children:e}),jsx(Dt,{children:jsx("div",{ref:U,children:jsxs(te,{variant:"unstyled",className:twMerge(rr({isInvalid:V||m&&!!r,isDisabled:O,isFocused:H?A:L,transparent:f,size:s}),"flex items-center text-start gap-4 cursor-pointer pl-[var(--control-padding-sm)]"),onFocus:y=>D(y,w.onFocus),onBlur:y=>W(y,w.onBlur),onPress:H?K:void 0,"data-open":H?A:L,children:[i&&I?jsx("div",{className:Lp(s),children:i(I)}):H&&B?jsx("div",{className:Lp(s),children:n?Array.from(n).find(P=>P.id===B)?.label:String(B)}):jsx(SelectValue,{className:Lp(s)}),jsx(G,{name:"CaretDown","aria-hidden":true,className:twMerge("h-4 w-4 text-text-primary group-disabled:text-text-disabled forced-colors:text-[ButtonText] transition-transform",(H?A:L)&&"rotate-180")})]})})}),b?jsx("div",{className:"mt-1 min-h-[20px]",children:m?jsx(ye,{size:s,className:"text-feedback-error-text",children:typeof r=="function"&&w.validationResult?r(w.validationResult):typeof r=="string"?r:null}):t&&C==="below"?jsx(Ee,{size:s,children:t}):null}):jsx(Fragment,{children:m?jsx(ye,{size:s,className:"mt-1 text-feedback-error-text",children:typeof r=="function"&&w.validationResult?r(w.validationResult):typeof r=="string"?r:null}):t&&C==="below"?jsx(Ee,{size:s,className:"mt-1",children:t}):null}),H?null:jsx(Et,{className:"bg-background-input shadow-xl border border-border-input/20 backdrop-blur-sm rounded-[var(--control-border-radius)]",style:{width:x==="match"&&k?`${k}px`:void 0,minWidth:x==="auto"&&k?`${k}px`:void 0,maxWidth:x==="auto"?"min(600px, 90vw)":void 0},placement:h,shouldFlip:v,children:jsx(Ip.Provider,{value:"md",children:jsx(ListBox,{items:n,className:"w-full max-h-[300px] overflow-auto bg-background-input p-0 outline-0",children:a&&n?y=>jsx(Ir,{id:y.id,textValue:y.label,children:jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap min-w-0 flex-1",children:a(y)})},y.id):o})})})]})}),H&&jsx(Lt,{isOpen:A,onClose:()=>M(false),title:e??"Select an option",contentPadding:false,children:jsx(Ip.Provider,{value:"md",children:jsx(ListBox,{items:n,className:"w-full bg-background-surface p-0 outline-0 [&_[role=option]]:border-b [&_[role=option]]:border-border-default [&_[role=option]:last-child]:border-0 [&_[role=option]]:!px-6 [&_[role=option]]:!py-4 [&_[role=option]]:rounded-none",selectionMode:"single",selectedKeys:B!=null?[B]:[],onSelectionChange:O=>{let V=Array.from(O)[0];V!=null&&(F(V),M(false));},children:a&&n?O=>jsx(Ir,{id:O.id,textValue:O.label,children:jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap min-w-0 flex-1",children:a(O)})},O.id):o})})})]})}function Ir({size:e,className:t,...r}){let o=ob(),n=e??o;return jsx(ListBoxItem,{...r,className:twMerge("flex cursor-default items-center gap-2 rounded-sm px-3 outline-none text-text-primary data-[focused]:bg-background-hover data-[focus-visible]:ring-2 data-[focus-visible]:ring-action-default data-[focus-visible]:ring-inset data-[selected]:bg-background-selected data-[selected]:font-medium overflow-hidden",_e[n].paddingY,_e[n].text,t)})}var vk=[],Ck={sm:"h-4 w-4",md:"h-5 w-5",lg:"h-6 w-6",xl:"h-7 w-7"},Sk={sm:"pl-8",md:"pl-10",lg:"pl-11",xl:"pl-13"},ab={sm:"py-1",md:"py-2",lg:"py-3",xl:"py-4"},Bp=(e,t,r)=>{if(e==null||e==="")return "";let n=(r?r.flatMap(a=>a.items):t||[]).find(a=>a.id===e);return n?n.name:""};async function wk(e,t,r){try{let o=e.url.replace("{q}",t),n=new URLSearchParams;e.extraParams&&Object.entries(e.extraParams).forEach(([l,d])=>{n.append(l,d.toString());});let a=`${o}${n.toString()?"?"+n.toString():""}`,i=await fetch(a,{method:"GET",headers:e.headers,signal:r});if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);let s=await i.json();return {items:e.transformResponse(s)}}catch(o){if(o instanceof Error&&o.name==="AbortError")return {items:[]};console.error("Error in REST request:",o);let n=o instanceof Error?o.message:"Unknown error occurred";return {items:[],error:n}}}async function Tk(e,t,r){try{let o=e.graphqlQuery.replace(`$${e.variableKey||"filter"}`,`"${t}"`),n=await fetch(e.url,{method:"POST",headers:{"Content-Type":"application/json",...e.headers},body:JSON.stringify({query:o}),signal:r});if(!n.ok)throw new Error(`HTTP error! status: ${n.status}`);let a=await n.json();if(a.errors)throw new Error(a.errors[0]?.message||"GraphQL error occurred");return e.responsePath&&(a=e.responsePath.split(".").reduce((i,s)=>i?.[s],a)),{items:e.transformResponse(a)}}catch(o){if(o instanceof Error&&o.name==="AbortError")return {items:[]};console.error("Error in GraphQL request:",o);let n=o instanceof Error?o.message:"Unknown error occurred";return {items:[],error:n}}}function $l({label:e,staticItems:t=vk,sections:r,selectedKey:o,defaultSelectedKey:n,onSelectionChange:a,requestConfig:i,defaultFilter:s,placeholder:l,errorMessage:d,description:c,size:u="md",tooltip:m,isRequired:p,isDisabled:g,isInvalid:f,validationResult:b,showErrors:h=true,renderItem:v,renderLeftIcon:x,renderSection:C,autoFocus:S=false,reserveErrorSpace:w=false,hideChevron:T=false,useMobileTray:N=true,className:k}){let R=ot__default.useRef(null),A=ot__default.useRef(null),[M,B]=ot__default.useState(),[D,W]=useState(()=>Bp(o||n,t,r)),[X,H]=useState(false),[I,F]=useState(false),z=Dn(D),{contains:U}=useFilter({sensitivity:"base"}),[K,O]=useState(),{isMobile:V}=Rr(),L=N&&V,y=_e[u].text,E=useAsyncList({async load({signal:me,filterText:ue=""}){if(!i)return {items:[]};if(!i.url||i.shouldLoad&&!i.shouldLoad(ue))return {items:[]};try{let ie;return i.requestType==="GraphQL"?ie=await Tk(i,ue,me):ie=await wk(i,ue,me),O(ie.error),{items:ie.items}}catch(ie){return ie instanceof Error&&ie.name==="AbortError"?{items:[]}:(console.error("Error loading items:",ie),O(ie instanceof Error?ie.message:"Unknown error occurred"),{items:[]})}},initialFilterText:""}),P=i&&z!==""?E:null,Y=false,$=useRef("");useEffect(()=>{S&&H(true);},[S]),useEffect(()=>{let me=Bp(o,t,r);me!==D&&W(me);},[o,t,r]),useEffect(()=>{let me=()=>{R.current&&B(R.current.offsetWidth);};return me(),window.addEventListener("resize",me),()=>window.removeEventListener("resize",me)},[]),useEffect(()=>{z===""?$.current="":P&&z!==$.current&&($.current=z,P.setFilterText(z));},[z,P]),Y=jl(!!P?.isLoading,300);let oe=ot__default.useMemo(()=>{if(!L||!D)return P?P.items:t;let me=P?P.items:t,ue=s??(i?()=>true:U);return me.filter(ie=>ue(ie.name,D))},[L,D,P,t,s,U]),re=me=>{let ue=Bp(me,t,r);W(ue),a&&a(me);},_=me=>{W(me);},he=()=>{L&&F(true);};return jsxs(Fragment,{children:[jsx(ComboBox,{onSelectionChange:re,selectedKey:o||void 0,defaultSelectedKey:n||void 0,items:P?P.items:r?r.flatMap(me=>me.items):t,className:Fe(k,"group flex flex-col w-full"),menuTrigger:L?"manual":i?"input":"focus",allowsEmptyCollection:!!i,isDisabled:g,isInvalid:f||!!d,inputValue:D,onInputChange:_,autoFocus:S&&!L,defaultFilter:s??(i?()=>true:U),"aria-label":e||l||"Autocomplete",children:me=>jsxs("div",{className:"flex flex-col",children:[e&&jsx(et,{size:u,tooltip:m,isRequired:p,children:e}),jsxs(Dt,{ref:R,children:[x?jsx("div",{className:"pointer-events-none absolute left-3 top-[45%] -translate-y-1/2 z-10",children:x(Y)}):jsx("div",{className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 z-10 flex items-center",children:Y?jsx(ao,{size:16,color:"text-text-secondary"}):jsx(G,{name:"MagnifyingGlass",className:`${Ck[u]} text-text-secondary`})}),jsx(Input,{className:rr({isInvalid:f||!!d,isDisabled:g,isFocused:X||(L?I:me.isOpen),size:u,className:twMerge(Sk[u],D&&!g||!T&&!D?"pr-10":"pr-3",L&&"cursor-pointer",k)}),placeholder:l,disabled:g,onFocus:ue=>{H(true),L&&(ue.currentTarget.blur(),he());},onBlur:()=>{H(false);},onClick:L?he:void 0,readOnly:L,"aria-label":e||l||"Autocomplete"}),D&&!g&&jsx(ms,{onClick:()=>{W(""),a?.(null);},size:u}),!T&&!D&&jsx(Button,{className:"absolute right-3 top-[46%] -translate-y-1/2 transform text-text-secondary hover:text-text-primary","aria-label":"Toggle menu",isDisabled:g,children:({isPressed:ue})=>jsx(G,{name:ue?"CaretUp":"CaretDown",className:"h-4 w-4"})})]}),w?jsx("div",{className:"mt-1 min-h-[20px]",children:h&&K?jsx(ye,{size:u,className:"text-feedback-error-text",children:K}):h&&typeof d=="string"?jsx(ye,{size:u,className:"text-feedback-error-text",children:d}):h&&typeof d=="function"&&b?jsx(ye,{size:u,className:"text-feedback-error-text",children:d(b)}):c?jsx(Ee,{size:u,children:c}):null}):jsxs(Fragment,{children:[c&&jsx(Ee,{size:u,className:"mt-1",children:c}),h&&K&&jsx(ye,{size:u,className:"text-feedback-error-text mt-1",children:K}),h&&typeof d=="string"&&jsx(ye,{size:u,className:"text-feedback-error-text mt-1",children:d}),h&&typeof d=="function"&&b&&jsx(ye,{size:u,className:"text-feedback-error-text mt-1",children:d(b)})]}),!L&&jsx(Et,{className:"bg-background-input shadow-xl border border-border-input/20 backdrop-blur-sm ring-1 ring-black/5 rounded-[var(--control-border-radius)]",style:{minWidth:M?`${M}px`:void 0,zIndex:9999},children:jsx(ListBox,{"aria-label":e||l||"Suggestions",className:`max-h-[300px] overflow-auto bg-background-input outline-none ${y}`,children:r?r.map(ue=>{let ie=ue.items.map(fe=>jsx(Ir,{id:fe.id,textValue:fe.name,size:u,className:`flex cursor-default items-center gap-2 px-3 ${ab[u]} text-text-primary outline-none data-[focused]:bg-background-hover data-[selected]:bg-background-selected data-[selected]:font-medium data-[focus-visible]:ring-0`,children:v?v(fe):fe.name},fe.id));if(C){let fe=C(ue,ie);return ot__default.isValidElement(fe)&&fe.type===ListBoxSection?fe:jsx(ListBoxSection,{children:fe},ue.name)}return jsxs(ListBoxSection,{children:[jsx(Header,{className:"px-3 py-1 text-sm font-bold text-text-secondary",children:ue.name}),ie]},ue.name)}):ue=>jsx(Ir,{id:ue.id,textValue:ue.name,size:u,className:`flex cursor-default items-center gap-2 px-3 ${ab[u]} text-text-primary outline-none data-[focused]:bg-background-hover data-[selected]:bg-background-selected data-[selected]:font-medium data-[focus-visible]:ring-0`,children:v?v(ue):ue.name},ue.id)})})]})}),L&&jsx(Lt,{isOpen:I,onClose:()=>F(false),title:e??l??"Search",contentPadding:false,height:"80vh",children:jsxs("div",{className:"flex flex-col h-full",children:[jsx("div",{className:"p-4 border-b border-border-default",children:jsxs(Dt,{children:[jsx("div",{className:"pointer-events-none absolute left-3 top-[45%] -translate-y-1/2 z-10 flex items-center",children:Y?jsx(ao,{size:16,color:"text-text-secondary"}):jsx(G,{name:"MagnifyingGlass",className:"h-4 w-4 text-text-secondary"})}),jsx("input",{ref:A,type:"text",value:D,onChange:me=>_(me.target.value),placeholder:l,autoFocus:true,className:rr({isInvalid:false,isDisabled:false,isFocused:true,size:"md",className:"pl-10 pr-10"})}),D&&jsx(ms,{onClick:()=>{W(""),a?.(null);},size:"md"})]})}),jsx("div",{className:"flex-1 overflow-auto",children:jsx(ListBox,{"aria-label":e||l||"Suggestions",items:oe,selectedKeys:o?[o]:[],selectionMode:"single",onSelectionChange:me=>{let ue=Array.from(me)[0];ue&&(re(ue),F(false));},className:"bg-background-input outline-none",children:me=>jsx(Ir,{id:me.id,textValue:me.name,size:"md",className:"flex cursor-default items-center gap-2 px-4 py-3 text-text-primary outline-none data-[focused]:bg-background-hover data-[selected]:bg-background-selected data-[selected]:font-medium data-[focus-visible]:ring-0",children:v?v(me):me.name},me.id)})})]})})]})}function nn({src:e,alt:t,firstName:r,lastName:o,fullName:n,onClick:a,size:i="md",shape:s="circle",variant:l="user",className:d,status:c,bordered:u=false,piiEntity:m}){let[p,g]=useState(false),f=useCallback(()=>g(true),[]);useEffect(()=>{g(false);},[e]);let b={xs:"h-6 w-6 text-xs",sm:"h-8 w-8 text-sm",md:"h-10 w-10 text-base",lg:"h-12 w-12 text-lg",xl:"h-16 w-16 text-xl"},h={xs:"h-1.5 w-1.5",sm:"h-2 w-2",md:"h-2.5 w-2.5",lg:"h-3 w-3",xl:"h-4 w-4"},v={xs:"bottom-0 right-0",sm:"bottom-0 right-0",md:"bottom-0 right-0",lg:"bottom-0.5 right-0.5",xl:"bottom-1 right-1"},x={online:"bg-feedback-success-background border-feedback-success-border",offline:"bg-text-secondary border-border-muted",away:"bg-feedback-warning-background border-feedback-warning-border",busy:"bg-feedback-error-background border-feedback-error-border"},C={user:"bg-feedback-info-background text-feedback-info-text",team:"bg-feedback-info-background text-feedback-info-text",organization:"bg-feedback-success-background text-feedback-success-text"},S=s==="circle"?"rounded-full":"rounded-md",w=twMerge("relative inline-flex items-center justify-center overflow-hidden transition-opacity outline-none",b[i],S,a&&"cursor-pointer hover:opacity-80",u&&"ring-2 ring-background-surface",d),N=(()=>{if(r||o){let M=r?.[0]||"",B=o?.[0]||"";return (M+B).toUpperCase()}if(n){let M=n.split(" "),B=M[0]?.[0]||"",D=M[M.length-1]?.[0]||"";return B===D?B.toUpperCase():(B+D).toUpperCase()}return ""})(),k=()=>{let M={xs:14,sm:16,md:20,lg:24,xl:32}[i];switch(l){case "team":return jsx(Users,{size:M});case "organization":return jsx(Building2,{size:M});default:return jsx(User,{size:M})}},R=M=>{if(m)return l==="organization"?M?"organization-logo":"initials":M?"avatar":"initials"},A=()=>e&&!p?jsx("img",{src:e,alt:t||n||"Avatar",className:"h-full w-full object-cover",onError:f,"data-pii-type":R(true),"data-pii-entity":m}):N?jsx("span",{className:"font-semibold","data-pii-type":R(false),"data-pii-entity":m,children:N}):k();return jsxs("div",{className:"relative inline-block",children:[jsx("div",{"data-avatar":true,className:twMerge(w,!e||p?C[l]:""),onClick:a,role:a?"button":void 0,tabIndex:a?0:void 0,children:A()}),c&&jsx("span",{className:twMerge("absolute border-2 border-background-surface",S,h[i],v[i],x[c]),"aria-label":`Status: ${c}`})]})}var Dk={default:"bg-feedback-info-background text-feedback-info-text",success:"bg-feedback-success-background text-feedback-success-text",error:"bg-feedback-error-background text-feedback-error-text",warning:"bg-feedback-warning-background text-feedback-warning-text",info:"bg-feedback-info-background text-feedback-info-text",primary:"bg-action-primary/10 text-action-primary border border-action-primary/20",brand:"bg-action-primary/10 text-action-primary border border-action-primary/20",secondary:"bg-action-secondary text-[color:var(--color-action-secondary-text)] border border-border-muted",neutral:"bg-background-muted text-text-secondary",charging:"bg-state-charging text-state-charging-text",discharging:"bg-state-discharging text-state-discharging-text",heat:"bg-state-heat text-state-heat-text",cool:"bg-state-cool text-state-cool-text",eco:"bg-state-eco text-state-eco-text",auto:"bg-state-auto text-state-auto-text",on:"bg-state-on text-state-on-text",off:"bg-state-off text-state-off-text",idle:"bg-state-idle text-state-idle-text",circulate:"bg-state-circulate text-state-circulate-text",unknown:"bg-state-unknown text-state-unknown-text",connected:"bg-feedback-success-background text-feedback-success-text",disconnected:"bg-feedback-error-background text-feedback-error-text",importing:"bg-state-importing text-state-importing-text",exporting:"bg-state-exporting text-state-exporting-text"},Ak={xs:"px-1.5 py-0.5 text-xs",sm:"px-2.5 py-1.5 text-xs",md:"px-3.5 py-2 text-sm",lg:"px-4 py-2.5 text-base"},Ik={pill:"rounded-full",rounded:"rounded-lg",square:"rounded-sm"},Fk={xs:"w-1 h-1",sm:"w-1.5 h-1.5",md:"w-2 h-2",lg:"w-2.5 h-2.5"};function kt({children:e,variant:t="default",size:r="sm",shape:o="square",dot:n=false,dotPosition:a="left",dotPulse:i=false,title:s,className:l}){let d=n&&jsx("span",{className:twMerge("rounded-full bg-current opacity-75",Fk[r],i&&"animate-pulse"),"aria-hidden":"true"});return jsxs("span",{title:s,className:twMerge("inline-flex items-center gap-1.5 font-medium",Ak[r],Ik[o],Dk[t],l),children:[n&&a==="left"&&d,e,n&&a==="right"&&d]})}var St=({href:e,children:t,className:r="",external:o=false,title:n,variant:a="secondary",onClick:i,asButton:s=false,onPress:l,showArrow:d=false,alwaysUnderlined:c=false,LinkComponent:u,"data-pii-type":m,"data-pii-entity":p})=>{let g={...m&&{"data-pii-type":m},...p&&{"data-pii-entity":p}},f=o?{target:"_blank",rel:"noopener noreferrer"}:{},C=`${`${c?"underline decoration-1 underline-offset-4 decoration-current":"hover:underline hover:decoration-1 hover:underline-offset-4 hover:decoration-current"} cursor-pointer`} ${{primary:"text-action-primary hover:text-action-primary-hover visited:text-action-primary",secondary:"text-text-link-default hover:text-text-link-hover visited:text-text-link-default",muted:"text-text-secondary hover:text-text-secondary visited:text-text-secondary",unstyled:""}[a==="brand"?"primary":a==="default"?"secondary":a]} ${r}`,S=jsxs(Fragment,{children:[t,d&&jsxs("span",{children:["\xA0","\u2192"]})]});return s?jsx("button",{type:"button",className:C,onClick:l,title:n,...g,children:S}):u&&e?jsx(u,{href:e,className:C,title:n,onClick:i,...f,...g,children:S}):jsx("a",{href:e||"#",className:C,...f,...g,title:n,onClick:i,children:S})};var Yk={info:{subtle:{container:"bg-feedback-info-background border-l-4 border-l-feedback-info-border",iconColor:"text-feedback-info-border",titleColor:"text-text-primary",bodyColor:"text-text-primary"},bold:{container:"bg-feedback-info-border border-feedback-info-border",iconColor:"text-text-inverse",titleColor:"text-text-inverse",bodyColor:"text-text-inverse/90"},icon:Info},success:{subtle:{container:"bg-feedback-success-background border-l-4 border-l-feedback-success-border",iconColor:"text-feedback-success-border",titleColor:"text-text-primary",bodyColor:"text-text-primary"},bold:{container:"bg-feedback-success-border border-feedback-success-border",iconColor:"text-text-inverse",titleColor:"text-text-inverse",bodyColor:"text-text-inverse/90"},icon:CheckCircle},warning:{subtle:{container:"bg-feedback-warning-background border-l-4 border-l-feedback-warning-border",iconColor:"text-feedback-warning-border",titleColor:"text-text-primary",bodyColor:"text-text-primary"},bold:{container:"bg-feedback-warning-border border-feedback-warning-border",iconColor:"text-text-inverse",titleColor:"text-text-inverse",bodyColor:"text-text-inverse/90"},icon:AlertCircle},error:{subtle:{container:"bg-feedback-error-background border-l-4 border-l-feedback-error-border",iconColor:"text-feedback-error-border",titleColor:"text-text-primary",bodyColor:"text-text-primary"},bold:{container:"bg-feedback-error-border border-feedback-error-border",iconColor:"text-text-inverse",titleColor:"text-text-inverse",bodyColor:"text-text-inverse/90"},icon:XCircle},discovery:{subtle:{container:"bg-background-muted border-l-4 border-l-action-brand",iconColor:"text-action-brand",titleColor:"text-text-primary",bodyColor:"text-text-primary"},bold:{container:"bg-action-brand border-action-brand",iconColor:"text-text-inverse",titleColor:"text-text-inverse",bodyColor:"text-text-inverse/90"},icon:Lightbulb}};function tc({variant:e="info",appearance:t="subtle",title:r,children:o,dismissible:n=false,onDismiss:a,primaryAction:i,secondaryAction:s,icon:l,hideIcon:d=false,className:c,testId:u}){let m=Yk[e],p=m[t],g=m.icon,f=!!(i||s),b=!!(r||o);return jsxs("div",{className:twMerge("flex gap-3 rounded-sm border p-4",p.container,c),role:"region","aria-live":"polite","data-testid":u,children:[!d&&jsx("div",{className:twMerge("flex-shrink-0",p.iconColor),"aria-hidden":"true",children:l||jsx(g,{className:"h-5 w-5"})}),jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-3",children:[b&&jsxs("div",{className:"flex-1",children:[r&&jsx("div",{className:Er(zt("headingSm"),p.titleColor),children:r}),o&&jsx("div",{className:Er(zt("bodySm"),r?"mt-1":"",p.bodyColor),children:o})]}),f&&jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[i&&(i.asLink?jsx(St,{asButton:true,onPress:i.onPress,variant:t==="bold"?"unstyled":"default",className:t==="bold"?"text-text-inverse hover:text-text-inverse/80":"",children:i.label}):jsx(te,{size:"sm",variant:"primary",onPress:i.onPress,className:t==="bold"?"bg-background-surface text-text-primary hover:bg-background-surface/90":"",children:i.label})),s&&(s.asLink?jsx(St,{asButton:true,onPress:s.onPress,variant:t==="bold"?"unstyled":"default",className:t==="bold"?"text-text-inverse hover:text-text-inverse/80":"",children:s.label}):jsx(te,{size:"sm",variant:"secondary",onPress:s.onPress,className:t==="bold"?"border-text-inverse/30 text-text-inverse hover:bg-text-inverse/10":"",children:s.label}))]})]}),n&&jsx("button",{type:"button",onClick:a,className:twMerge("flex h-8 w-8 flex-shrink-0 items-center justify-center self-start rounded-md transition-colors hover:bg-background-modal/10",p.iconColor,pt()),"aria-label":"Dismiss banner",children:jsx(X,{className:"h-4 w-4"})})]})}function cb({isOpen:e=true,position:t="sticky",className:r,...o}){let n=t==="fixed"?"fixed top-0 left-0 right-0 z-50":"sticky top-0 z-50",a=r?`${r} !rounded-none`:"!rounded-none";return jsx(AnimatePresence,{children:e&&jsx(motion.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.2,ease:"easeInOut"},className:n,children:jsx(tc,{...o,className:a})})})}function bi(){let[e,t]=useState({width:0,height:0}),r=useRef(null),o=useRef(void 0),n=useCallback(a=>{if(r.current&&(r.current.disconnect(),r.current=null),o.current&&(cancelAnimationFrame(o.current),o.current=void 0),!a){t({width:0,height:0});return}let i=a.getBoundingClientRect();t({width:i.width,height:i.height}),r.current=new ResizeObserver(s=>{o.current&&cancelAnimationFrame(o.current),o.current=requestAnimationFrame(l=>{for(let d of s){let{width:c,height:u}=d.contentRect;t(m=>m.width!==c||m.height!==u?{width:c,height:u}:m);}});}),r.current.observe(a);},[]);return useEffect(()=>()=>{o.current&&cancelAnimationFrame(o.current),r.current&&r.current.disconnect();},[]),{ref:n,width:e.width,height:e.height}}function In({value:e,children:t,className:r,size:o="sm",iconPosition:n="right"}){let[a,i]=useState(false),d=jsx(te,{variant:"icon",size:o,onPress:()=>{let u=e||(typeof t=="string"?t:"");navigator.clipboard.writeText(u),i(true),setTimeout(()=>{i(false);},2e3);},className:"!px-2 relative",style:{top:"0.5px"},children:jsx(G,{name:"Copy",size:o==="sm"?14:16})}),c=a?jsx(tr,{content:"Copied!",children:d}):d;return jsxs("div",{className:twMerge("inline-flex items-center gap-0.5",r),children:[n==="left"&&c,t,n==="right"&&c]})}function rc(e){let{children:t,maxWidth:r=600,className:o,...n}=e,{ref:a,width:i}=bi(),[s,l]=ot__default.useState(false),[d,c]=ot__default.useState(false),u=ot__default.useRef(false),m=ot__default.useMemo(()=>t&&!e.items&&typeof t!="function"?ot__default.Children.toArray(t):null,[t,e.items]);if(ot__default.useEffect(()=>{m&&m.length>=4&&i>0&&!u.current?(u.current=true,l(i>r),c(true)):(!m||m&&m.length<4)&&c(true);let p=setTimeout(()=>{d||c(true);},100);return ()=>clearTimeout(p)},[i,r,m,d]),m&&s&&m.length>=4){let p=m[0],g=m.slice(1,-2),f=m.slice(-2),b=g.map(h=>{if(ot__default.isValidElement(h)){let v=h.props;if(typeof v.children=="string")return {label:v.children,href:v.href}}return {label:"..."}});return jsxs(Breadcrumbs,{...n,ref:a,className:twMerge("flex gap-2",d?"opacity-100":"opacity-0",o),children:[p,jsx(eP,{items:b}),f]})}return jsx(Breadcrumbs,{...n,ref:a,className:twMerge("flex gap-2",d?"opacity-100":"opacity-0",o),children:t})}function eP({items:e}){let t=e.map((r,o)=>({id:`breadcrumb-${o}`,name:r.label,href:r.href}));return jsx(Breadcrumb,{className:"flex items-center gap-2",children:jsxs("span",{className:"flex items-center gap-2",children:[jsx(pi,{items:t,align:"left",size:"sm",children:jsx(te,{variant:"icon",size:"sm",icon:"DotsThree","aria-label":"Show hidden breadcrumbs",className:"px-0.5"})}),jsx(ChevronRight,{className:"h-4 w-4 text-text-secondary"})]})})}function oc(e){let{className:t,children:r,href:o,copyable:n,copyValue:a,...i}=e;return jsx(Breadcrumb,{className:Fe(t,"flex items-center gap-2"),...i,children:s=>{let l=s.isCurrent,d=typeof r=="function"?r(s):r;return jsx(Fragment,{children:l?n?jsx(In,{value:a||(typeof d=="string"?d:void 0),size:"sm",iconPosition:"right",children:jsx("span",{className:"max-w-[200px] truncate font-semibold text-text-primary sm:max-w-none",children:d})}):jsx("span",{className:"max-w-[200px] truncate font-semibold text-text-primary sm:max-w-none",children:d}):jsxs(Fragment,{children:[jsx(St,{variant:"muted",href:o,className:"max-w-[150px] truncate sm:max-w-[300px] md:max-w-none",children:d}),jsx(ChevronRight,{className:"h-4 w-4 shrink-0 text-text-secondary"})]})})}})}function dP({isSelected:e,isDisabled:t}){let r=[pt,"w-9 h-9 text-sm cursor-default rounded-sm flex items-center justify-center forced-color-adjust-none font-semibold"];return t?r.push("text-text-disabled forced-colors:text-[GrayText]"):e?r.push("bg-action-default text-text-inverse invalid:bg-feedback-error-border forced-colors:bg-[Highlight] forced-colors:invalid:bg-[Mark] forced-colors:text-[HighlightText]"):r.push("text-text-primary hover:bg-background-hover pressed:bg-background-selected"),r.join(" ")}function xi({errorMessage:e,...t}){return jsxs(Calendar,{...t,children:[jsx(nc,{}),jsxs(CalendarGrid,{className:"border-separate [border-spacing:0] [&_td]:p-0 [&_td]:!border-0",children:[jsx(ac,{}),jsx(CalendarGridBody,{children:r=>jsx(CalendarCell,{date:r,className:({isSelected:o,isDisabled:n})=>`${dP({isSelected:o,isDisabled:n})} border-0`})})]}),e&&jsx(Text,{slot:"errorMessage",className:"text-sm text-feedback-error-text",children:e})]})}function nc(){let{direction:e}=useLocale(),t=18;return jsxs("header",{className:"flex w-full items-center gap-1 px-1 pb-4",children:[jsx(te,{variant:"icon",slot:"previous",className:"pl-0",children:e==="rtl"?jsx(G,{name:"CaretRight","aria-hidden":true,size:t}):jsx(G,{name:"CaretLeft","aria-hidden":true,size:t})}),jsx(Heading,{className:"text-md mx-2 flex-1 text-center font-semibold text-text-primary"}),jsx(te,{variant:"icon",slot:"next",className:"pr-0",children:e==="rtl"?jsx(G,{name:"CaretLeft","aria-hidden":true,size:t}):jsx(G,{name:"CaretRight","aria-hidden":true,size:t})})]})}function ac(){return jsx(CalendarGridHeader,{children:e=>jsx(CalendarHeaderCell,{className:"text-xs font-semibold text-text-secondary",children:e})})}var hb=ot.createContext(null);function Fn(){let e=ot.useContext(hb);if(!e)throw new Error("Carousel components must be used within a CarouselRoot");return e}function bb({page:e,defaultPage:t=0,onPageChange:r,orientation:o="horizontal",loop:n=false,autoplay:a=false,autoplayDelay:i=4e3,allowMouseDrag:s=false,spacing:l="1rem",slidesPerView:d=1,slidesPerMove:c=1,className:u,children:m,...p}){let g=e!==void 0,[f,b]=ot.useState(t),h=g?e:f,v=ot.useRef(null),[x,C]=ot.useState(0),[S,w]=ot.useState(typeof a=="boolean"?a:!!a),[T,N]=ot.useState(false),k=ot.useRef(null),R=ot.useRef(null),A=typeof a=="object"&&a!==null&&a.delay?a.delay:i;ot.useEffect(()=>{if(v.current){let y=Math.max(1,Math.floor(Number(d)||1)),E=v.current.children;if(E.length===0){C(0);return}let P=Math.ceil(E.length/y);C(P);}},[m,d]);let M=ot.useRef(-1);ot.useEffect(()=>{if(h!==M.current&&v.current){let y=Array.from(v.current.children);if(y.length===0)return;let E=h*d,P=Math.min(E,y.length-1),Y=y[P];Y&&typeof Y.scrollIntoView=="function"&&(Y.scrollIntoView({behavior:"smooth",block:o==="vertical"?"start":"nearest",inline:o==="horizontal"?"start":"nearest"}),M.current=h);}},[h,d,o]);let B=ot.useCallback(y=>{let E=y;n?E<0?E=x-1:E>=x&&(E=0):E=Math.max(0,Math.min(y,x-1)),g||b(E),r?.(E);},[g,n,r,x]),D=ot.useCallback(()=>{B(h+c);},[h,B,c]),W=ot.useCallback(()=>{B(h-c);},[h,B,c]),X=ot.useRef(D);ot.useEffect(()=>{X.current=D;},[D]);let H=x>0&&(n||h<x-1),I=x>0&&(n||h>0),F=ot.useCallback(()=>{w(y=>!y);},[]);ot.useEffect(()=>{if(S&&x>1)return k.current=setInterval(()=>{X.current();},A),()=>{k.current&&(clearInterval(k.current),k.current=null);}},[S,x,A]);let z=ot.useCallback(()=>{k.current&&(clearInterval(k.current),k.current=null);},[]),U=ot.useCallback(()=>{S&&x>1&&(k.current=setInterval(()=>{X.current();},A));},[S,x,A]),K=ot.useCallback(y=>{if(!s)return;N(true);let E="touches"in y&&y.touches&&y.touches.length>0?y.touches[0].clientX:"clientX"in y?y.clientX:0,P="touches"in y&&y.touches&&y.touches.length>0?y.touches[0].clientY:"clientY"in y?y.clientY:0;R.current={x:E,y:P};},[s]),O=ot.useCallback(y=>{if(!T||!R.current)return;let E="touches"in y&&y.touches&&y.touches.length>0?y.touches[0].clientX:"clientX"in y?y.clientX:0,P="touches"in y&&y.touches&&y.touches.length>0?y.touches[0].clientY:"clientY"in y?y.clientY:0,Y=E-R.current.x,$=P-R.current.y,oe=50;o==="horizontal"&&Math.abs(Y)>oe?(Y>0?W():D(),N(false),R.current=null):o==="vertical"&&Math.abs($)>oe&&($>0?W():D(),N(false),R.current=null);},[T,o,D,W]),V=ot.useCallback(()=>{N(false),R.current=null;},[]),L={currentPage:h,totalPages:x,orientation:o,loop:n,spacing:l,slidesPerView:d,goToPage:B,goToNext:D,goToPrev:W,canGoNext:H,canGoPrev:I,isAutoplayActive:S,toggleAutoplay:F,itemsRef:v,isDragging:T,allowMouseDrag:s,handleDragStart:K,handleDragMove:O,handleDragEnd:V};return jsx(hb.Provider,{value:L,children:jsx("div",{...p,className:twMerge("relative w-full",o==="vertical"?"h-full":"",u),onMouseEnter:z,onMouseLeave:U,children:m})})}function xb({className:e,children:t,...r}){let{itemsRef:o,orientation:n,spacing:a,isDragging:i,allowMouseDrag:s,handleDragStart:l,handleDragMove:d,handleDragEnd:c}=Fn();return jsx("div",{ref:o,...r,className:twMerge("flex overflow-x-auto overflow-y-hidden snap-x snap-mandatory scrollbar-hide scroll-smooth",n==="vertical"&&"flex-col overflow-y-auto overflow-x-hidden snap-y",s&&i&&"cursor-grabbing select-none",s&&!i&&"cursor-grab",e),style:{gap:a,"--carousel-spacing":a,...r.style},onMouseDown:l,onMouseMove:d,onMouseUp:c,onMouseLeave:c,onTouchStart:l,onTouchMove:d,onTouchEnd:c,children:t})}function yb({index:e,className:t,children:r,...o}){let{orientation:n,slidesPerView:a}=Fn();return jsx("div",{...o,"data-index":e,className:twMerge("shrink-0 snap-start",n==="horizontal"?"h-full":"w-full",t),style:{width:n==="horizontal"?`calc((100% - (${a-1} * var(--carousel-spacing, 1rem))) / ${a})`:void 0,height:n==="vertical"?`calc((100% - (${a-1} * var(--carousel-spacing, 1rem))) / ${a})`:void 0,...o.style},children:r})}function vb({className:e,children:t,...r}){return jsx("div",{...r,className:twMerge("flex items-center justify-center gap-4 mt-4",e),children:t})}function Cb({className:e,children:t,...r}){let{goToPrev:o,canGoPrev:n}=Fn();return jsx("button",{type:"button",...r,onClick:a=>{o(),r.onClick?.(a);},disabled:!n||r.disabled,"aria-label":"Previous slide",className:twMerge("inline-flex items-center justify-center rounded-md","h-10 w-10","bg-background-input border border-border-input","text-text-primary hover:bg-background-muted","transition-colors duration-200","disabled:opacity-40 disabled:cursor-not-allowed","focus-visible:outline focus-visible:outline-2 focus-visible:outline-action-default",e),children:t||jsx(G,{name:"CaretLeft",size:"sm"})})}function Sb({className:e,children:t,...r}){let{goToNext:o,canGoNext:n}=Fn();return jsx("button",{type:"button",...r,onClick:a=>{o(),r.onClick?.(a);},disabled:!n||r.disabled,"aria-label":"Next slide",className:twMerge("inline-flex items-center justify-center rounded-md","h-10 w-10","bg-background-input border border-border-input","text-text-primary hover:bg-background-muted","transition-colors duration-200","disabled:opacity-40 disabled:cursor-not-allowed","focus-visible:outline focus-visible:outline-2 focus-visible:outline-action-default",e),children:t||jsx(G,{name:"CaretRight",size:"sm"})})}function Kp({index:e,className:t,children:r,...o}){let{currentPage:n,goToPage:a}=Fn(),i=n===e;return jsx("button",{type:"button",...o,onClick:s=>{a(e),o.onClick?.(s);},"aria-label":`Go to slide ${e+1}`,"aria-current":i,className:twMerge("h-2 rounded-full transition-all duration-200",i?"w-6 bg-action-brand":"w-2 bg-border-muted hover:bg-border-input","focus-visible:outline focus-visible:outline-2 focus-visible:outline-action-default",t),children:r})}function wb({className:e,...t}){let{totalPages:r}=Fn();return jsx("div",{...t,className:twMerge("flex items-center gap-2",e),role:"group","aria-label":"Carousel indicators",children:Array.from({length:r},(o,n)=>jsx(Kp,{index:n},n))})}function Tb({className:e,children:t,...r}){let{isAutoplayActive:o,toggleAutoplay:n}=Fn();return jsx("button",{type:"button",...r,onClick:a=>{n(),r.onClick?.(a);},"aria-label":o?"Pause autoplay":"Start autoplay",className:twMerge("inline-flex items-center justify-center rounded-md","h-10 w-10","bg-background-input border border-border-input","text-text-primary hover:bg-background-muted","transition-colors duration-200","focus-visible:outline focus-visible:outline-2 focus-visible:outline-action-default",e),children:t||jsx(G,{name:o?"Pause":"Play",size:"sm"})})}function Nb({className:e,...t}){let{currentPage:r,totalPages:o}=Fn();return jsxs("div",{...t,className:twMerge("text-sm text-text-secondary tabular-nums",e),"aria-live":"polite","aria-atomic":"true",children:[r+1," / ",o]})}var bP="focus:ring-action-primary",xP="bg-action-primary border-action-primary text-[color:var(--color-action-primary-text)] hover:bg-action-primary-hover hover:border-action-primary-hover";function Yp(e){return jsxs(CheckboxGroup,{...e,className:Fe(e.className,"flex flex-col gap-2"),children:[jsx(et,{children:e.label}),e.children,e.description&&jsx(Ee,{children:e.description}),jsx(ye,{children:typeof e.errorMessage=="function"?void 0:e.errorMessage})]})}function yP({isDisabled:e}){return `relative flex gap-2 items-center group text-sm transition ${e?"text-text-disabled":"text-text-secondary"}`}function vP({isSelected:e,isInvalid:t,isDisabled:r,isIndeterminate:o}){let n="w-5 h-5 flex-shrink-0 rounded-[var(--control-border-radius)] flex items-center justify-center border-2 transition ring-offset-2 focus:ring-2",a=bP,i="";return r?i="border-border-muted bg-background-muted":t?i="border-feedback-error-border bg-feedback-error-background":e||o?i=xP:i="bg-background-input border-border-input hover:border-border-focus",`${n} ${a} ${i}`}var kb="w-4 h-4 text-current group-disabled:text-text-disabled";function Xp({className:e,...t}){return jsx("div",{"aria-hidden":"true",className:`${vP(t)} ${e||""}`,children:t.isIndeterminate?jsx(Minus,{"aria-hidden":true,className:kb}):t.isSelected?jsx(Check,{"aria-hidden":true,className:kb}):null})}function So(e){let{children:t,variant:r,...o}=e;return jsx(Checkbox,{...o,className:composeRenderProps(e.className,(n,a)=>`${yP(a)} ${n||""}`),children:n=>{let{isSelected:a,isIndeterminate:i,isDisabled:s,isInvalid:l}=n;return jsxs(Fragment,{children:[jsx(Xp,{isSelected:a,isIndeterminate:i,isDisabled:s,isInvalid:l}),typeof t=="function"?t(n):t]})}})}var wP={primary:"bg-action-primary/10 text-action-primary border border-action-primary/20 hover:bg-action-primary/15",secondary:"bg-action-secondary text-[color:var(--color-action-secondary-text)] border border-border-muted hover:bg-action-secondary-hover",info:"bg-feedback-info-background text-feedback-info-text border border-feedback-info-border hover:bg-feedback-info-background/80"};function Rb(e){return !e||e==="default"?"secondary":e==="brand"?"primary":e}var TP={xs:"px-1.5 py-[2px] gap-0.5",sm:"px-2 py-1 gap-1",md:"px-3 py-1.5 gap-1.5",lg:"px-3 py-2 gap-2",xl:"px-4 py-2.5 gap-2"},NP="opacity-75 cursor-not-allowed pointer-events-none";function Mb(e){let{variant:t,size:r,isDisabled:o,isClickable:n,className:a}=e,i=r==="xs"?"text-xs":_e[r].text;return twMerge("inline-flex items-center justify-center rounded-full font-medium transition-colors","whitespace-nowrap select-none",TP[r],i,wP[t],n&&!o&&"cursor-pointer",o&&NP,a)}function lo({children:e,onRemove:t,removeLabel:r="Remove",size:o="md",variant:n="secondary",isRemovable:a=true,isDisabled:i=false,className:s,onClick:l}){let d=!!l&&!i,c=a&&t&&!i,u=b=>{b.stopPropagation(),b.preventDefault(),t&&!i&&t();},m=()=>{l&&!i&&l();},p=o==="xs"?10:o==="sm"?12:o==="md"?14:16,f=jsxs(Fragment,{children:[jsx("span",{className:"truncate",children:e}),c?d?jsx("span",{onClick:u,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),u(b));},role:"button",tabIndex:0,className:"flex-shrink-0 rounded-full p-0.5 hover:bg-text-primary/10 transition-colors cursor-pointer","aria-label":r,title:r,children:jsx(G,{name:"X",size:p,className:"text-current opacity-70 hover:opacity-100"})}):jsx("button",{type:"button",onClick:u,className:"flex-shrink-0 rounded-full p-0.5 hover:bg-text-primary/10 transition-colors cursor-pointer","aria-label":r,title:r,tabIndex:-1,children:jsx(G,{name:"X",size:p,className:"text-current opacity-70 hover:opacity-100"})}):null]});return d?jsx("button",{type:"button",onClick:m,className:Mb({variant:Rb(n),size:o,isDisabled:i,isClickable:d,className:s}),disabled:i,children:f}):jsx("span",{className:Mb({variant:Rb(n),size:o,isDisabled:i,isClickable:d,className:s}),children:f})}function Db({label:e,description:t,errorMessage:r,size:o="md",tooltip:n,isRequired:a=false,isDisabled:i=false,isInvalid:s=false,validationResult:l,placeholder:d="Add items...",selectedItems:c=[],onItemsChange:u,staticItems:m,fetchSuggestions:p,chipVariant:g="secondary",showErrors:f=true,className:b}){let[h,v]=useState(""),[x,C]=useState([]),[S,w]=useState(false),[T,N]=useState(false),[k,R]=useState(-1),A=Dn(h,300),M=useRef(null),B=useRef(null),{isFocused:D,handleFocus:W,handleBlur:X}=Ar(),H=useId(),I=useCallback(L=>{if(!u||!L.trim())return;let y=L.trim();if(c.includes(y)){v(""),N(false),C([]),R(-1);return}u([...c,y]),v(""),N(false),C([]),R(-1),M.current?.focus();},[c,u]),F=useCallback(L=>{u&&u(c.filter(y=>y!==L));},[c,u]);useEffect(()=>{if(!p)return;let L=true;return (async()=>{let E=A.trim();if(!E){L&&(w(false),C([]),N(false));return}w(true);try{let P=await p(E);if(!L)return;C(P),N(!0);}catch(P){if(!L)return;console.error("Error fetching suggestions:",P),C([]),N(false);}finally{L&&w(false);}})(),()=>{L=false;}},[A,p]),useEffect(()=>{if(p||!m)return;if(!A.trim()){C([]),N(false);return}let L=m.filter(y=>y.name.toLowerCase().includes(A.toLowerCase())).map(y=>y.id);C(L),N(L.length>0||A.trim().length>0);},[A,m,p]);let z=useMemo(()=>{let L=x.filter(y=>!c.includes(y));return h.trim()&&!L.includes(h.trim())&&!c.includes(h.trim())?[...L,`Create tag: "${h.trim()}"`]:L},[x,h,c]),U=useCallback(L=>{v(L.target.value),R(-1),L.target.value&&N(true);},[]),K=useCallback(L=>{i||(L.startsWith("Create tag:")?I(h):I(L));},[I,h,i]),O=useCallback(L=>{if(!i)switch(L.key){case "Enter":case ",":if(L.preventDefault(),k>=0&&k<z.length){let y=z[k];y.startsWith("Create tag:")?I(h):I(y);}else h.trim()&&I(h.trim());break;case "Backspace":!h&&c.length>0&&(L.preventDefault(),F(c[c.length-1]));break;case "ArrowDown":L.preventDefault(),T&&R(y=>y<z.length-1?y+1:y);break;case "ArrowUp":L.preventDefault(),T&&R(y=>y>0?y-1:-1);break;case "Escape":N(false),R(-1);break}},[i,h,c,z,k,T,I,F]);useEffect(()=>{let L=y=>{B.current&&y.target instanceof Node&&!B.current.contains(y.target)&&N(false);};return document.addEventListener("mousedown",L),()=>document.removeEventListener("mousedown",L)},[]);let V=()=>twMerge("flex items-center gap-1.5 rounded-md overflow-x-auto overflow-y-hidden","[&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]",An({isInvalid:s,isDisabled:i,isFocused:D}),"bg-background-input",o==="sm"&&"px-2 py-1 h-[32px]",o==="md"&&"px-2.5 py-1.5 h-[40px]",o==="lg"&&"px-3 py-2 h-[44px]",o==="xl"&&"px-3.5 py-2.5 h-[48px]",i&&"opacity-50 cursor-not-allowed bg-background-muted");return jsxs("div",{ref:B,className:twMerge("relative flex flex-col gap-1",b),children:[e&&jsx(et,{size:o,tooltip:n,isRequired:a,children:e}),jsx(Dt,{children:jsxs("div",{className:V(),onClick:()=>!i&&M.current?.focus(),children:[c.map(L=>jsx(lo,{variant:g,size:"xs",onRemove:()=>F(L),isDisabled:i,className:"shrink-0 max-h-full",children:L},L)),jsx("input",{ref:M,type:"text",role:"combobox","aria-expanded":T,"aria-haspopup":"listbox","aria-controls":H,"aria-autocomplete":"list",value:h,onChange:U,onKeyDown:O,onFocus:L=>W(L),onBlur:L=>X(L),placeholder:c.length===0?d:"",disabled:i,className:"flex-1 min-w-[120px] h-full !border-0 !outline-none !ring-0 bg-transparent text-text-primary text-sm placeholder:text-text-disabled disabled:cursor-not-allowed focus:!ring-0 focus:!outline-none focus:!border-0 focus-visible:!ring-0 focus-visible:!outline-none focus-visible:!border-0",style:{boxShadow:"none",WebkitAppearance:"none",appearance:"none",border:"none",outline:"none"}})]})}),T&&(h||z.length>0)&&jsx("div",{id:H,role:"listbox",className:twMerge("absolute z-50 mt-1 rounded-lg border border-border-default","max-h-60 overflow-auto bg-background-surface shadow-lg","left-0 right-0 top-full"),children:S?jsx("div",{className:"px-3 py-2 text-sm text-text-secondary",children:"Loading..."}):z.length>0?z.map((L,y)=>jsx("div",{role:"option","aria-selected":y===k,className:twMerge("cursor-pointer px-3 py-2 text-sm transition-colors","hover:bg-background-hover",y===k&&"bg-background-selected",L.startsWith("Create tag:")&&"italic text-text-secondary"),onClick:()=>K(L),children:L},L)):h&&jsx("div",{className:"px-3 py-2 text-sm text-text-secondary",children:"No suggestions found"})}),t&&jsx(Ee,{size:o,className:"mt-1",children:t}),f&&typeof r=="string"&&jsx(ye,{size:o,className:"text-feedback-error-text mt-1",children:r}),f&&typeof r=="function"&&l&&jsx(ye,{size:o,className:"text-feedback-error-text mt-1",children:r(l)})]})}var FP={json:()=>import('ace-builds/src-noconflict/mode-json'),javascript:()=>import('ace-builds/src-noconflict/mode-javascript'),typescript:()=>import('ace-builds/src-noconflict/mode-typescript'),html:()=>import('ace-builds/src-noconflict/mode-html'),css:()=>import('ace-builds/src-noconflict/mode-css'),markdown:()=>import('ace-builds/src-noconflict/mode-markdown'),yaml:()=>import('ace-builds/src-noconflict/mode-yaml'),xml:()=>import('ace-builds/src-noconflict/mode-xml'),python:()=>import('ace-builds/src-noconflict/mode-python'),sql:()=>import('ace-builds/src-noconflict/mode-sql')},BP={github:()=>import('ace-builds/src-noconflict/theme-github'),github_dark:()=>import('ace-builds/src-noconflict/theme-github_dark')},VP={"ext-language-tools":()=>import('ace-builds/src-noconflict/ext-language_tools')},bs=new Set;async function jp(e,t){bs.has(e)||(await t(),bs.add(e));}async function OP(e,t,r){await Promise.all([jp(`language:${e}`,FP[e]),jp(`theme:${t}`,BP[t]),r?jp("extension:language-tools",VP["ext-language-tools"]):void 0]);}function Ib(e,t,r){let o=bs.has(`language:${e}`)&&bs.has(`theme:${t}`);return r?o&&bs.has("extension:language-tools"):o}function Fb({value:e,readOnly:t=false,onChange:r,language:o="json",theme:n="github_dark",height:a,width:i="100%",className:s,lineHeight:l=19,minLines:d=3,maxLines:c=50,showLineNumbers:u=true,showGutter:m=true,fontSize:p=14,wrapEnabled:g=false}){let f=useRef(null),[b,h]=useState(()=>Ib(o,n,!t)),v=useMemo(()=>{if(a)return a;let x=(e.match(/\n/g)||[]).length+1;return `${Math.max(d,Math.min(x,c))*l+10}px`},[e,a,l,d,c]);return useEffect(()=>{let x=false,C=!t;return Ib(o,n,C)?(h(true),()=>{x=true;}):(h(false),OP(o,n,C).then(()=>{x||h(true);}).catch(S=>{x||h(true),console.error("Failed to load Ace editor resources",S);}),()=>{x=true;})},[o,t,n]),useEffect(()=>{b&&f.current?.editor&&f.current.editor.resize();},[v,b]),jsx("div",{className:twMerge("overflow-hidden rounded-md border border-border-input",s),style:{width:i,height:v},children:b?jsx(AP,{ref:f,mode:o,theme:n,value:e,onChange:r,readOnly:t,width:"100%",height:"100%",fontSize:p,showPrintMargin:false,showGutter:m,highlightActiveLine:!t,setOptions:{useWorker:true,showLineNumbers:u,tabSize:2,enableBasicAutocompletion:!t,enableLiveAutocompletion:!t,enableSnippets:!t,showFoldWidgets:true,wrap:g},editorProps:{$blockScrolling:true}}):jsx("div",{className:"flex h-full w-full items-center justify-center bg-surface-muted text-foreground-muted",children:"Loading editor\u2026"})})}var Vb=ot.createContext({variant:"contained",density:"comfortable",showDividers:true}),Ob=ot.createContext(null),UP={contained:"rounded-lg border border-border-default bg-background-surface overflow-hidden",bordered:"rounded-lg border border-border-default bg-background-surface",plain:"bg-transparent"},Bb={true:"divide-y divide-border-default",false:"gap-3"},KP={comfortable:"px-5 py-3",compact:"px-4 py-2.5"},YP={comfortable:"px-5 pt-0",compact:"px-4 pt-0"},XP={comfortable:"h-4 w-4",compact:"h-3.5 w-3.5"};function _p(){return ot.useContext(Vb)}function JP(e){let t=ot.useContext(Ob);if(!t)throw new Error(`${e} must be used within a <CollapseItem>`);return t}function jP({variant:e,showDividers:t,className:r}){let o="group/collapse-item w-full transition-colors",n={contained:"bg-background-surface",bordered:"bg-background-surface",plain:"bg-transparent"},a=t?"":"rounded-lg border border-border-default bg-background-surface overflow-hidden";return twMerge(o,n[e],a,r)}function qP({isDisabled:e,isPressed:t,density:r,variant:o,showDividers:n,className:a}){let i="group/collapse-header flex w-full items-start gap-4 text-left transition-colors duration-150",s=e?"cursor-not-allowed text-text-disabled":"cursor-pointer text-text-primary",l=t&&!e?"bg-background-hover":"",d=KP[r];return twMerge(i,pt(),d,s,l,o==="plain"&&n?"px-0":"",a)}function ZP({density:e,variant:t,showDividers:r,className:o}){let n="text-text-primary",a=YP[e];return twMerge(n,a,r?"":"rounded-b-lg",t==="plain"&&r?"px-0":"",o)}function yi({variant:e="contained",density:t="comfortable",showDividers:r=true,className:o,...n}){let a=ot.useMemo(()=>({variant:e,density:t,showDividers:r}),[e,t,r]),i=twMerge("flex w-full flex-col",UP[e],r?Bb.true:Bb.false,e==="plain"&&r?"border-y border-border-default/60":"");return jsx(Vb.Provider,{value:a,children:jsx(DisclosureGroup,{...n,className:Fe(o,i)})})}function On({className:e,children:t,...r}){let{variant:o,showDividers:n}=_p();return jsx(Disclosure,{...r,className:composeRenderProps(e,a=>jP({variant:o,showDividers:n,className:a})),children:a=>jsx(Ob.Provider,{value:a,children:t})})}On.displayName="CollapseItem";function zn({title:e,description:t,startContent:r,endContent:o,indicator:n,indicatorPosition:a="end",showIndicator:i=true,keepIndicatorSpace:s=false,children:l,className:d,...c}){let u=JP("CollapseHeader"),{density:m,variant:p,showDividers:g}=_p(),f=XP[m];return jsx(Button,{...c,slot:"trigger","data-expanded":u.isExpanded?"true":void 0,className:composeRenderProps(d,(b,h)=>qP({isDisabled:h.isDisabled??false,isPressed:h.isPressed??false,density:m,variant:p,showDividers:g,className:b})),children:b=>{let h=b.isDisabled??false,v=i?typeof n=="function"?n({isExpanded:u.isExpanded,isDisabled:h}):n??jsx(G,{name:"CaretDown",size:m==="compact"?"xs":"sm",weight:"bold","aria-hidden":"true",className:twMerge("text-text-secondary transition-transform duration-200",u.isExpanded?"rotate-180":"rotate-0")}):null,x=v?jsx("span",{className:twMerge("flex flex-shrink-0 items-center justify-center text-text-secondary",f),"aria-hidden":"true",children:v}):s?jsx("span",{className:twMerge("flex flex-shrink-0 items-center justify-center",f),"aria-hidden":"true"}):null;return jsxs("div",{className:"flex w-full items-center gap-4",children:[a==="start"&&x,r&&jsx("div",{className:"flex flex-shrink-0 items-center text-text-secondary",children:r}),jsxs("div",{className:"flex min-w-0 flex-1 items-start gap-3",children:[l??jsxs("div",{className:"flex min-w-0 flex-1 flex-col gap-1 text-left",children:[e&&jsx("span",{className:"truncate font-medium text-text-primary",children:e}),t&&jsx("span",{className:"text-sm text-text-secondary",children:t})]}),o&&jsx("div",{className:"flex flex-shrink-0 items-center text-sm text-text-secondary",children:o})]}),a==="end"&&x]})}})}zn.displayName="CollapseHeader";function Hn({className:e,children:t,...r}){let{density:o,variant:n,showDividers:a}=_p();return jsx(DisclosurePanel,{...r,className:composeRenderProps(e,i=>ZP({density:o,variant:n,showDividers:a,className:i})),children:jsx(Mn,{children:t})})}Hn.displayName="CollapseContent";function vi(e){if(!e)return false;let t=e.startsWith("#")?e.slice(1):e;return /^[0-9A-Fa-f]{3}$|^[0-9A-Fa-f]{6}$/.test(t)}function em(e){if(!e)return "";let t=e.startsWith("#")?e.slice(1):e;return t.length===3&&(t=t.split("").map(r=>r+r).join("")),`#${t.toUpperCase()}`}function e1({label:e,description:t,errorMessage:r,size:o="md",tooltip:n,isRequired:a,transparent:i,className:s,validationResult:l,value:d,defaultValue:c,onChange:u,placeholder:m="#000000",showColorSwatch:p=true,reserveErrorSpace:g=true,...f}){let[b,h]=useState(c||""),[v,x]=useState(d||c||""),[C,S]=useState(false),[w,T]=useState(null),{isFocused:N,handleFocus:k,handleBlur:R}=Ar(),A=d!==void 0?d:b;useEffect(()=>{d!==void 0&&x(d);},[d]);let M=A?!vi(A):false,B=useCallback(X=>{if(x(X),vi(X)){let H=em(X);u?u(H):h(H);}else X===""&&(u?u(""):h(""));},[u]),D=useCallback(X=>{let H=em(X);x(H),u?u(H):h(H);},[u]),W=useCallback(X=>{if(vi(v)){let H=em(v);x(H),u&&H!==A?u(H):!u&&H!==b&&h(H);}R(X,f.onBlur);},[v,A,b,u,R,f.onBlur]);return jsx(TextField,{...f,isRequired:a,className:Fe(s,"group flex flex-col"),children:({isDisabled:X})=>jsxs("div",{className:"flex flex-col",children:[e&&jsx(et,{size:o,tooltip:n,isRequired:a,children:e}),jsx(Dt,{children:jsxs("div",{className:"flex gap-2",children:[jsxs("div",{className:"flex-1 relative",children:[jsx(Zl,{size:o,disabled:X,type:"text",value:v,placeholder:m,onFocus:H=>k(H,f.onFocus),onBlur:W,onChange:H=>B(H.target.value),className:twMerge(rr({isInvalid:M,isDisabled:X,isFocused:N,size:o,transparent:i}),p?"pr-12":"pr-3","pl-3")}),p&&jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none",style:{width:_e[o].height},children:jsx("div",{className:twMerge("w-6 h-6 rounded border shadow-sm",vi(A)?"border-border-default":"border-border-default bg-background-muted"),style:vi(A)?{backgroundColor:A}:void 0,"aria-hidden":"true",children:!vi(A)&&jsx("div",{className:"w-full h-full flex items-center justify-center",children:jsx("div",{className:"w-3 h-3 rounded-full border-2 border-border-muted"})})})})]}),jsx("div",{ref:T,children:jsx(te,{variant:"secondary",size:o,icon:"Palette",onPress:()=>S(!C),isDisabled:X,className:"flex-shrink-0",children:"Pick"})})]})}),g?jsx("div",{className:"mt-1 min-h-[20px]",children:typeof r=="string"?jsx(ye,{size:o,children:r}):typeof r=="function"&&l?jsx(ye,{size:o,children:r(l)}):t?jsx(Ee,{size:o,children:t}):null}):jsx(Fragment,{children:typeof r=="string"?jsx(ye,{size:o,className:"mt-1",children:r}):typeof r=="function"&&l?jsx(ye,{size:o,className:"mt-1",children:r(l)}):t?jsx(Ee,{size:o,className:"mt-1",children:t}):null}),C&&w&&jsx(Et,{triggerRef:{current:w},isOpen:C,onOpenChange:S,placement:"bottom end",className:"bg-background-input shadow-xl border border-border-input/20 backdrop-blur-sm rounded-lg p-4",children:jsxs("div",{className:"flex flex-col gap-4",children:[jsx(HexColorPicker,{color:A||"#000000",onChange:D,style:{width:"200px",height:"200px"}}),jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:"w-10 h-10 rounded border border-border-default shadow-sm flex-shrink-0",style:{backgroundColor:A||"#000000"}}),jsx("div",{className:"flex-1 text-text-primary text-[length:var(--control-text-sm)] font-mono",children:A||"#000000"})]})]})})]})})}function Gb({isOpen:e,onClose:t,onConfirm:r,title:o,message:n,confirmLabel:a="Confirm",cancelLabel:i="Cancel",confirmVariant:s,isDestructive:l=false,isLoading:d=false,maxWidth:c="500px",minWidth:u="400px"}){return jsx(Dr,{isOpen:e,onClose:t,title:o,maxWidth:c,minWidth:u,primaryAction:{label:a,onPress:()=>{r();},variant:s??(l?"destructive":"primary"),isLoading:d},secondaryAction:{label:i,onPress:t,variant:"secondary",isDisabled:d},children:jsx("div",{className:"text-text-primary",children:n})})}function Wb({isConnected:e,connectedAt:t,disconnectedAt:r,showTimestamp:o=false,isLoading:n,size:a="sm",shape:i="pill",...s}){if(n)return jsx(q,{className:"inline-flex h-6 w-24"});let l=e?"Connected":"Disconnected",d=e?"success":"neutral",c=null;if(o){if(e&&t)c=Pl(t);else if(!e&&r){let u=Pl(r);c=u?`Offline ${u}`:null;}}return jsxs("div",{className:"inline-flex flex-col gap-1",children:[jsx(kt,{variant:d,size:a,shape:i,dot:e,dotPulse:e,...s,children:l}),c&&jsx("span",{className:"text-xs text-text-secondary",children:c})]})}function Ub({firstName:e,lastName:t,email:r,phone:o,avatarUrl:n,href:a,LinkComponent:i,variant:s="outlined",layout:l="horizontal",showEmail:d=true,showPhone:c=false,isLoading:u=false,className:m,contentClassName:p,piiEntity:g}){let f=`${e} ${t}`.trim(),b=({children:v,className:x})=>a?i?jsx(i,{href:a,className:x,children:v}):jsx(St,{href:a,variant:"unstyled",className:twMerge("hover:underline",x),asButton:false,children:v}):jsx("span",{className:x,children:v}),h=l==="vertical";return u?jsx(at,{variant:s,className:twMerge("flex flex-col",m),children:jsx(at.Content,{className:"flex items-center flex-1",children:jsxs("div",{className:twMerge("w-full",h?"flex flex-col items-center gap-4":"flex items-center gap-4"),children:[jsx(q,{width:56,height:56,className:"rounded flex-shrink-0"}),jsxs("div",{className:twMerge(h?"w-full text-center":"flex-1","space-y-2"),children:[jsx(q,{width:"70%",height:20,className:twMerge(h&&"mx-auto")}),jsx(q,{width:"100%",height:16,className:twMerge(h&&"mx-auto")})]})]})})}):jsx(at,{variant:s,className:twMerge("group/card flex flex-col",m),children:jsx(at.Content,{className:twMerge("flex items-center flex-1",a&&"cursor-pointer",p),children:jsxs("div",{className:twMerge("relative w-full",h?"flex flex-col items-center gap-4 text-center":"flex items-center gap-4"),children:[jsx(nn,{firstName:e,lastName:t,src:n,size:"xl",variant:"user",shape:"square",className:"flex-shrink-0",piiEntity:g}),jsxs("div",{className:twMerge(h?"w-full":"flex-1 min-w-0"),children:[a&&jsx(b,{className:"after:absolute after:inset-0",children:jsx("span",{className:"sr-only",children:f})}),jsx("span",{className:"text-lg font-semibold leading-tight text-text-primary block mb-1.5 group-hover/card:text-text-brand transition-colors","data-pii-type":g?"full-name":void 0,"data-pii-entity":g,children:f}),jsxs("div",{className:twMerge("space-y-0.5",h&&"flex flex-col items-center"),children:[d&&r&&jsxs("div",{className:"flex items-center gap-2.5 text-text-primary",children:[jsx(G,{name:"Envelope",size:16,className:"text-text-secondary flex-shrink-0"}),jsx(St,{href:`mailto:${r}`,variant:"unstyled",className:twMerge("text-sm leading-relaxed text-text-primary relative z-20",h?"":"truncate"),"data-pii-type":g?"email":void 0,"data-pii-entity":g,children:r})]}),c&&o&&jsxs("div",{className:"flex items-center gap-2.5 text-text-primary",children:[jsx(G,{name:"Phone",size:16,className:"text-text-secondary flex-shrink-0"}),jsx(St,{href:`tel:${o}`,variant:"unstyled",className:twMerge("text-sm leading-relaxed text-text-primary relative z-20",h?"":"truncate"),"data-pii-type":g?"phone":void 0,"data-pii-entity":g,children:ai(o)})]})]})]})]})})})}function lc({firstName:e,lastName:t,email:r,avatarUrl:o,layout:n="stacked",size:a="md",href:i,LinkComponent:s,linkVariant:l="unstyled",emphasis:d="normal",showEmail:c=false,badge:u,avatarShape:m,isLoading:p=false,className:g,piiEntity:f,piiPrimaryTextType:b="full-name"}){let h=m??(n==="inline"?"circle":"square"),x={xs:{avatarSize:"xs",gap:"gap-1.5",textSize:"text-xs",secondaryTextSize:"text-xs",skeletonAvatar:24,skeletonText:80,skeletonSecondary:60},sm:{avatarSize:"sm",gap:"gap-2",textSize:"text-sm",secondaryTextSize:"text-xs",skeletonAvatar:32,skeletonText:96,skeletonSecondary:72},md:{avatarSize:"md",gap:"gap-3",textSize:"text-base",secondaryTextSize:"text-sm",skeletonAvatar:40,skeletonText:128,skeletonSecondary:96},lg:{avatarSize:"lg",gap:"gap-3",textSize:"text-lg",secondaryTextSize:"text-base",skeletonAvatar:48,skeletonText:160,skeletonSecondary:120}}[a],C=`${e} ${t}`.trim(),w={strong:"font-semibold text-text-primary",high:"font-semibold text-text-primary",normal:"text-text-primary",low:"text-text-secondary"}[d],T=({children:N,className:k})=>i?s?jsx(s,{href:i,className:k,children:N}):jsx(St,{href:i,variant:l,className:twMerge("hover:underline",k),asButton:false,children:N}):jsx("span",{className:k,children:N});return p?n==="inline"?jsxs("div",{className:twMerge("flex items-center",x.gap,g),children:[jsx(q,{width:x.skeletonAvatar,height:x.skeletonAvatar,className:"flex-shrink-0 rounded-full"}),jsx(q,{width:x.skeletonText,height:x.skeletonAvatar*.5})]}):jsxs("div",{className:twMerge("flex items-center",x.gap,g),children:[jsx(q,{width:x.skeletonAvatar,height:x.skeletonAvatar,className:"flex-shrink-0 rounded-full"}),jsxs("div",{className:"flex flex-col gap-1",children:[jsx(q,{width:x.skeletonText,height:16}),c&&jsx(q,{width:x.skeletonSecondary,height:12})]})]}):n==="inline"?jsxs("div",{className:twMerge("flex items-center",x.gap,g),children:[jsxs(T,{className:twMerge("flex items-center",x.gap),children:[jsx(nn,{firstName:e,lastName:t,src:o,size:x.avatarSize,variant:"user",shape:h,className:"flex-shrink-0",piiEntity:f}),jsx("span",{className:twMerge("leading-normal truncate hover:text-text-primary",w,x.textSize,i&&"hover:underline hover:decoration-1 hover:underline-offset-4"),"data-pii-type":f?b:void 0,"data-pii-entity":f,children:C})]}),u]}):jsxs("div",{className:twMerge("flex items-center justify-start",x.gap,g),children:[jsx(nn,{firstName:e,lastName:t,src:o,size:x.avatarSize,variant:"user",shape:h,className:"flex-shrink-0",piiEntity:f}),jsxs("div",{className:"flex flex-col items-start min-w-0",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx(T,{className:twMerge("leading-normal truncate hover:text-text-primary",w,x.textSize,i&&"hover:underline hover:decoration-1 hover:underline-offset-4"),children:jsx("span",{"data-pii-type":f?b:void 0,"data-pii-entity":f,children:C})}),u]}),c&&r&&jsx("div",{className:twMerge("text-text-secondary leading-normal truncate",x.secondaryTextSize),"data-pii-type":f?"email":void 0,"data-pii-entity":f,children:r})]})]})}var rm=createContext(null);function Kb(e){let t=useContext(rm),r=useRef(null),o=e??r,[n,a]=useState(()=>t||{current:"xl",isSm:true,isMd:true,isLg:true,isXl:true,is2Xl:false,isMobile:false,isDesktop:true});return useEffect(()=>{if(t){a(t);return}let i=o.current;if(!i||typeof ResizeObserver>"u")return;let s=()=>{let d=i.offsetWidth,c=d>=640,u=d>=768,m=d>=1024,p=d>=1280,g=d>=1536,f="base";g?f="2xl":p?f="xl":m?f="lg":u?f="md":c&&(f="sm"),a({current:f,isSm:c,isMd:u,isLg:m,isXl:p,is2Xl:g,isMobile:!u,isDesktop:u});};s();let l=new ResizeObserver(s);return l.observe(i),()=>l.disconnect()},[t,o]),n}function Xb({children:e,className:t}){let r=useRef(null),[o,n]=useState({current:"base",isSm:false,isMd:false,isLg:false,isXl:false,is2Xl:false,isMobile:true,isDesktop:false});return useEffect(()=>{let a=r.current;if(!a||typeof ResizeObserver>"u")return;let i=()=>{let l=a.offsetWidth,d=l>=640,c=l>=768,u=l>=1024,m=l>=1280,p=l>=1536,g="base";p?g="2xl":m?g="xl":u?g="lg":c?g="md":d&&(g="sm"),n({current:g,isSm:d,isMd:c,isLg:u,isXl:m,is2Xl:p,isMobile:!c,isDesktop:c});};i();let s=new ResizeObserver(i);return s.observe(a),()=>s.disconnect()},[]),jsx(rm.Provider,{value:o,children:jsx("div",{ref:r,className:t,style:{width:"100%"},children:e})})}var cc={duration:.5,ease:"easeInOut"},co=createContext(null);function dc(){let e=useRef({played:false});return useEffect(()=>{e.current.played=true;},[]),e.current}var ba=()=>{let e=useContext(co);if(!e)throw new Error("useChartContext must be used within a ChartContextProvider");return e};function uc(e,t){if(t<=0||e.length<2)return e;let r=[e[0]];for(let o=1;o<e.length;o++)e[o].xValue.getTime()-e[o-1].xValue.getTime()>t&&r.push(null),r.push(e[o]);return r}var Wn=({data:e,color:t="var(--color-viz-default)",baseline:r,fillOpacity:o=.1,showLine:n=true,maxGapMs:a,animate:i=true})=>{let s=useId(),l=useId(),{xScale:d,yScale:c,animationSettings:u,entrance:m}=ba(),[p]=ot__default.useState(()=>m?.played!==true),g=i&&p,f=d.range(),b=c.range(),h=(N,k)=>typeof r=="function"?r(N,k):r??0,v=N=>N.chartYValue??N.yValue,x=e??[],C=a!=null?uc(x,a):x,S=i?void 0:"non-scaling-stroke",w={transformOrigin:`0 ${b[0]}px`,transformBox:"fill-box",isolation:"isolate"},T=jsxs(Fragment,{children:[r===void 0?jsx(AreaClosed,{data:C,x:N=>N?d(N.xValue):0,y:N=>N?c(v(N)):0,yScale:c,defined:N=>N!=null,fill:`url(#${s})`,curve:curveLinear}):jsx(Area,{data:C,x:N=>N?d(N.xValue):0,y0:(N,k)=>N?c(h(N,k)):0,y1:N=>N?c(v(N)):0,defined:N=>N!=null,fill:t,fillOpacity:o,curve:curveLinear}),n?jsx(LinePath,{data:C,x:N=>N?d(N.xValue):0,y:N=>N?c(v(N)):0,defined:N=>N!=null,stroke:t,strokeWidth:3,vectorEffect:S,curve:curveLinear}):null]});return jsxs(Fragment,{children:[jsxs("defs",{children:[jsxs("linearGradient",{id:s,x1:"0%",y1:"0%",x2:"0%",y2:"100%",children:[jsx("stop",{offset:"50%",stopColor:t,stopOpacity:o}),jsx("stop",{offset:"100%",stopColor:t,stopOpacity:0})]}),g&&jsx("clipPath",{id:l,children:jsx("rect",{x:f[0],y:b[1],width:f[1]-f[0],height:b[0]-b[1]})})]}),g?jsx("g",{clipPath:`url(#${l})`,children:jsx(motion.g,{initial:{scaleY:0},animate:{scaleY:1},transition:{duration:u.duration,ease:u.ease},style:w,children:T})}):jsx("g",{style:w,children:T})]})};var mc=({data:e,color:t="var(--color-viz-default)",opacity:r=1,categoryColors:o={}})=>{let{xScale:n,yScale:a,animationSettings:i}=ba(),s=useId(),l=n.range(),d=a.range(),c=[...e??[]].sort((p,g)=>p.xValue.getTime()-g.xValue.getTime());if(c.length===0)return null;let u=c.length>1?c[1].xValue.getTime()-c[0].xValue.getTime():15*6e4,m=Math.abs(n(new Date(c[0].xValue.getTime()+u))-n(c[0].xValue));return jsxs(Fragment,{children:[jsx("defs",{children:jsx("clipPath",{id:s,children:jsx("rect",{x:l[0],y:d[1],width:l[1]-l[0],height:d[0]-d[1]})})}),jsx("g",{clipPath:`url(#${s})`,children:jsx(motion.g,{initial:{scaleY:0},animate:{scaleY:1},transition:{duration:i.duration,ease:i.ease},style:{transformOrigin:`0 ${a(0)}px`,isolation:"isolate"},children:c.map((p,g)=>{let f=n(p.xValue),b=p.chartYValue??p.yValue,h=p.baselineValue??0,v=a(b),x=a(h),C=Math.min(v,x),S=Math.abs(v-x),w=c[g+1],T=w?Math.abs(n(w.xValue)-f):m,N=p.category&&o[p.category]?o[p.category]:t;return jsx(Bar,{x:f-T/2,y:C,width:T,height:S,fill:N,opacity:r,rx:1},p.xValue.getTime())})})})]})};function N1(e,t){return e.length*(t*.6)}var xa;function k1(){if(xa!==void 0)return xa;if(typeof window>"u"||typeof document>"u")return xa=null,xa;try{xa=document.createElement("canvas").getContext("2d");}catch{xa=null;}return xa}function fc(e,t=12,r="system-ui"){let o=k1();return o?(o.font=`${t}px ${r}`,o.measureText(e).width):N1(e,t)}function sn(e,t=12,r="system-ui"){return e.length===0?0:Math.max(...e.map(o=>fc(o,t,r)))}function qb(e,t,r=12,o="system-ui"){if(t<=0)return "";if(fc(e,r,o)<=t)return e;let n="\u2026";if(fc(n,r,o)>t)return "";let a=0,i=e.length;for(;a<i;){let s=Math.ceil((a+i)/2);fc(e.slice(0,s)+n,r,o)<=t?a=s:i=s-1;}return e.slice(0,a)+n}var gc=(e,t,r)=>{if(!e.tooltipRange||e.baseline===void 0)return;let o=typeof e.baseline=="function"?e.baseline(t,r):e.baseline;return typeof o=="number"&&Number.isFinite(o)&&o!==t.yValue?o:void 0};function L1(e){return e>=1e9?"GW":e>=1e6?"MW":e>=1e3?"kW":"W"}function D1(e){return e>=1e3?"kA":e<1?"mA":"A"}function A1(e){return e>=1e3?"kV":e<1?"mV":"V"}function I1(e){return e>=1e6?"M\u03A9":e>=1e3?"k\u03A9":e<1?"m\u03A9":"\u03A9"}function Si(e,t){if(typeof e!="object"||e===null)return e;switch(e.type){case "energy":{if(e.unit||e.autoScale===false)return e;let r=e.sourceUnit?Xu[e.sourceUnit]:1;return {...e,unit:Yu(t*r)}}case "power":return e.unit||e.autoScale===false?e:{...e,unit:L1(t)};case "current":return e.unit||e.autoScale===false?e:{...e,unit:D1(t)};case "voltage":return e.unit||e.autoScale===false?e:{...e,unit:A1(t)};case "resistance":return e.unit||e.autoScale===false?e:{...e,unit:I1(t)};default:return e}}var F1=e=>e.baselineValue??0,je={top:8,right:0,bottom:50,left:60};function zr(e={type:"number"}){let t=i=>{if(i==null)return "-";let s=Ao({value:i,formatter:e});if(s===null)return "-";if(typeof s=="string")return s;if(typeof s=="number")return s.toString();if(typeof s=="object"&&s!==null&&"props"in s){let l=c=>{if(c==null)return "";if(typeof c=="string")return c;if(typeof c=="number")return c.toString();if(typeof c=="object"&&"props"in c){let u=c.props;if(u?.children)return Array.isArray(u.children)?u.children.map(l).join(""):l(u.children)}return ""};return l(s)||i.toString()}return i.toString()},r=i=>{if(i==null)return "-";if(typeof e=="string"){let s=Ao({value:i,formatter:e});return s===null?"-":String(s)}if(typeof e=="object"&&e.type)switch(e.type){case "energy":case "power":case "voltage":case "current":case "resistance":case "temperature":case "distance":return t(i);case "currency":return t(i);default:return t(i)}return t(i)},o,n,a;return typeof e=="object"&&e.type&&e.type==="number"&&("min"in e&&(o=e.min),"max"in e&&(n=e.max)),{format:t,tickFormat:r,min:o,max:n,tickInterval:a}}var nm=(e,t)=>{let r=extent(e,o=>o.xValue);return scaleTime({range:[je.left,t-je.right],domain:r,nice:true})},ys=(e,t,r,o)=>{let n=zr(r);if(o)return scaleLinear({range:[t-je.bottom,je.top],domain:o,nice:true});let a=min(e,d=>Math.min(d.yValue,d.chartYValue??d.yValue,d.baselineValue??d.yValue))||0,i=max(e,d=>Math.max(d.yValue,d.chartYValue??d.yValue,d.baselineValue??d.yValue))||0,s=n.min!==void 0?n.min:a>=0?0:a*1.1,l=n.max!==void 0?n.max:i<=0?0:i*1.1;return scaleLinear({range:[t-je.bottom,je.top],domain:[s,l],nice:true})};function vs(e){return e instanceof Date&&!Number.isNaN(e.getTime())}var Cs=12;function B1(e,t,r=12,o=false){if(!vs(t[0])||!vs(t[1]))return console.warn("ChartAxis: Invalid date in domain, skipping tick calculation"),[];let n=t[0].getTime(),a=t[1].getTime(),i=a-n;if(i===0||i<1e3)return [t[0]];let s=ap({start:t[0],end:t[1]},{compact:o}),d=[t[0],new Date((t[0].getTime()+t[1].getTime())/2),t[1]].map(v=>s(v)),c=sn(d,r),m=c+c,p=Math.floor(e/m),g=Math.max(2,Math.min(8,p));if(g<=2)return [t[0],t[1]];let f=[t[0]],b=i/36e5,h;b<=1?h=6e4:b<=6?h=5*6e4:b<=48?h=60*6e4:b<=168?h=360*6e4:h=1440*6e4;for(let v=1;v<g-1;v++){let x=v/(g-1),C=n+i*x,S=Math.round(C/h)*h,w=f[f.length-1].getTime(),T=S>w?S:w+h;if(T>=a)break;f.push(new Date(T));}return f.push(t[1]),f}var V1=({top:e,scale:t,width:r})=>{let o=t.domain(),n=[o[0],o[o.length-1]],a=vs(n[0])&&vs(n[1]),i=r<400,s=a?n[0].getTime():0,l=a?n[1].getTime():0,d=useMemo(()=>a?ap({start:n[0],end:n[1]},{compact:i}):()=>"",[s,l,i,a]),c=useMemo(()=>B1(r,n,12,i),[r,s,l,i]);return c.length===0?null:jsx(Axis,{orientation:"bottom",top:e,scale:t,tickValues:c,tickFormat:u=>{let m=u;return vs(m)?d(m):""},stroke:"var(--color-border-muted)",tickStroke:"var(--color-border-muted)",tickLabelProps:(u,m,p)=>({fill:"var(--color-text-secondary)",fontSize:12,textAnchor:m===0?"start":m===p.length-1?"end":"middle"}),rangePadding:0})};function ya(e,t=12){let r=t*2.5,o=Math.floor(e/r);return Math.max(2,Math.min(6,o))}var hc=12;function Qb(e,t,r){let o=zr(t),n=o.tickFormat||o.format,a=e.ticks(r?ya(r):5).map(i=>String(n(i)));return Math.ceil(sn(a,hc,"system-ui"))+12}var O1=({left:e,scale:t,yFormatter:r,height:o,labelLeft:n})=>{let a=zr(r),i=useMemo(()=>!o||o<=0?5:ya(o),[o]);return jsx(Axis,{orientation:"left",left:e,scale:t,numTicks:i,tickFormat:s=>(a.tickFormat||a.format)(s),stroke:"var(--color-border-muted)",tickStroke:"var(--color-border-muted)",tickLabelProps:s=>{let l={fill:"var(--color-text-secondary)",fontSize:hc,textAnchor:n===void 0?"end":"start",...n===void 0?{}:{x:n}},d=t(s),[c,u]=t.range(),m=Math.min(c,u),p=Math.max(c,u);return d-m<hc/2?{...l,verticalAnchor:"start"}:p-d<hc/2?{...l,verticalAnchor:"end"}:{...l,dy:"0.33em"}}})},z1=({top:e,scale:t})=>jsx(Axis,{orientation:"bottom",top:e,scale:t,stroke:"var(--color-border-muted)",tickStroke:"var(--color-border-muted)",tickLabelProps:()=>({fill:"var(--color-text-secondary)",fontSize:12,textAnchor:"middle",dy:"0.25em"})}),H1=({left:e,scale:t,availableWidth:r,labelLeft:o})=>jsx(Axis,{orientation:"left",left:e,scale:t,stroke:"var(--color-border-muted)",tickStroke:"var(--color-border-muted)",tickFormat:r===void 0?void 0:n=>qb(String(n),r,Cs),tickLabelProps:()=>({fill:"var(--color-text-secondary)",fontSize:Cs,textAnchor:o===void 0?"end":"start",...o===void 0?{}:{x:o},dx:o===void 0?"-0.25em":0,dy:"0.33em"})}),G1=({top:e,scale:t,yFormatter:r,width:o})=>{let n=zr(r),a=useMemo(()=>{if(!o||o<=0)return 5;let s=Math.floor(o/60);return Math.max(2,Math.min(8,s))},[o]);return jsx(Axis,{orientation:"bottom",top:e,scale:t,numTicks:a,tickFormat:i=>(n.tickFormat||n.format)(i),stroke:"var(--color-border-muted)",tickStroke:"var(--color-border-muted)",tickLabelProps:()=>({fill:"var(--color-text-secondary)",fontSize:12,textAnchor:"middle",dy:"0.25em"})})},uo={Bottom:V1,Left:O1,CategoryBottom:z1,CategoryLeft:H1,NumericBottom:G1};var Ho=({data:e,formatter:t,label:r,categoryLabels:o})=>{let n=ot__default.useContext(co),a=o??n?.categoryLabels,i=n?.xScale,s=n?.width,l=n?.height,d=zr(t),c=v=>{if(v.baselineValue===void 0)return d.format(v.value);let x=Math.min(v.baselineValue,v.value),C=Math.max(v.baselineValue,v.value);return `${d.format(x)} \u2013 ${d.format(C)}`},u=ot__default.useRef(null),[m,p]=ot__default.useState({x:0,y:0,translate:"translate(-50%, -100%)"});if(ot__default.useEffect(()=>{if(!e||!u.current)return;let x=u.current.getBoundingClientRect(),C=s??window.innerWidth,S=l??window.innerHeight,w=e.x,T=e.y,N=16,k=e.x+x.width+N<=C,R=e.x-x.width-N>=0,A;e.position==="left"?A=R||!k:A=!k&&R;let M=A?"translate(calc(-100% - 16px), -50%)":"translate(16px, -50%)";if(!k&&!R){let B=C-e.x,D=e.x;B<=D?(w=C,M="translate(-100%, -50%)"):(w=0,M="translate(0, -50%)");}T-x.height/2<0?T=x.height/2:T+x.height/2>S&&(T=S-x.height/2),p({x:w,y:T,translate:M});},[e?.x,e?.y,e?.position,s,l]),!e)return null;let g=i?.domain(),b=g&&g.length===2&&g.every(v=>v instanceof Date)?lh({start:g[0],end:g[1]}):null,h=r||(b&&e.xValue instanceof Date?b(e.xValue):String(e.xValue));return jsx(AnimatePresence,{children:jsxs(motion.div,{ref:u,role:"tooltip","aria-live":"polite",initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},"data-testid":"tooltip",className:"pointer-events-none absolute z-50 rounded-lg bg-background-surface p-4 text-sm shadow-xl ring-1 ring-border-default whitespace-nowrap",style:{left:m.x,top:m.y,transform:m.translate},children:[jsx("div",{className:"mb-1 font-medium text-text-primary",children:h}),e.isEvent?jsxs("div",{className:"space-y-2",children:[e.series.length>1&&jsx("ul",{className:"list-none p-0 border-b border-border-default pb-2",children:e.series.slice(0,-1).map(v=>jsxs("li",{className:"py-0.5",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsxs("span",{className:"font-medium text-text-primary",children:[v.label,":"]}),jsx("span",{className:"text-text-secondary",children:c(v)})]}),v.category&&jsxs("div",{className:"mt-0.5 flex items-center gap-2",children:[jsx("div",{className:"h-3 w-3",style:{backgroundColor:v.categoryColor||v.color,borderRadius:"1px"}}),jsx("span",{className:"text-sm text-text-secondary",children:a?.[v.category]||v.category})]}),v.extraTooltipRows&&v.extraTooltipRows.length>0&&jsx("div",{className:"mt-0.5 space-y-0.5",children:v.extraTooltipRows.map(x=>jsxs("div",{className:"flex items-center gap-2 text-sm text-text-secondary",children:[jsxs("span",{children:[x.label,":"]}),jsx("span",{className:"font-medium text-text-primary",children:x.value})]},x.label))})]},v.label))}),(()=>{let v=e.series[e.series.length-1],x=e.eventItems?.length?e.eventItems:[{label:v.label,color:v.color,metadata:e.eventMetadata}];return jsx("div",{className:"space-y-2",children:x.map((C,S)=>jsxs("div",{children:[jsxs("div",{className:"flex items-center gap-2",children:[jsx("div",{className:"h-2 w-2 rounded-full",style:{backgroundColor:C.color}}),jsx("span",{className:"font-medium text-text-primary",children:C.label})]}),C.metadata&&Object.keys(C.metadata).length>0&&jsx("div",{className:"ml-4 mt-1 space-y-0.5 text-xs text-text-secondary",children:Object.entries(C.metadata).map(([w,T])=>jsxs("div",{className:"flex items-center gap-2",children:[jsxs("span",{className:"capitalize",children:[w,":"]}),jsx("span",{className:"font-medium",children:T})]},w))})]},`${C.label}-${S}`))})})()]}):jsx("ul",{className:"list-none p-0",children:e.series.map(v=>jsxs("li",{className:"py-0.5",children:[jsxs("div",{className:"flex items-center gap-2",children:[jsxs("span",{className:"font-medium text-text-primary",children:[v.label,":"]}),jsx("span",{className:"text-text-secondary",children:c(v)})]}),v.category&&jsxs("div",{className:"mt-0.5 flex items-center gap-2",children:[jsx("div",{className:"h-3 w-3",style:{backgroundColor:v.categoryColor||v.color,borderRadius:"1px"}}),jsx("span",{className:"text-sm text-text-secondary",children:a?.[v.category]||v.category})]}),v.extraTooltipRows&&v.extraTooltipRows.length>0&&jsx("div",{className:"mt-0.5 space-y-0.5",children:v.extraTooltipRows.map(x=>jsxs("div",{className:"flex items-center gap-2 text-sm text-text-secondary",children:[jsxs("span",{children:[x.label,":"]}),jsx("span",{className:"font-medium text-text-primary",children:x.value})]},x.label))})]},v.label))})]})})};var ox={top:20,right:20,bottom:50,left:60},sx=12,q1=.4,nx=60;function Z1({margin:e,orientation:t,labelsKey:r,width:o}){return useMemo(()=>{if(e)return e;if(t!=="horizontal")return ox;let n=sn(r.split("\0"),Cs,"system-ui"),a=Math.max(nx,Math.floor(o*q1)),i=Math.ceil(n)+sx;return {...ox,left:Math.min(Math.max(i,nx),a)}},[e,t,r,o])}var lx=({data:e,width:t,height:r,margin:o,scaleToFit:n=false,color:a,yFormatter:i={type:"number"},showGrid:s=true,showAxes:l=true,animate:d=true,barRadius:c=4,barPadding:u=.3,onBarClick:m,onBarHover:p,activeIndex:g,className:f,style:b,"aria-label":h,orientation:v="horizontal",showTooltip:x=true})=>{let[C,S]=useState(null),[w,T]=useState(null),[N,k]=useState(null),R=n&&t!==void 0&&r!==void 0,[A,M]=useState(t??600),[B,D]=useState(r??300),W=useRef(null),X=g??C,H=useId(),I=a||"var(--color-viz-default)";useEffect(()=>{if(t!==void 0&&r!==void 0){M(t),D(r);return}if(!W.current)return;let E=new ResizeObserver(P=>{for(let Y of P)t===void 0&&M(Y.contentRect.width),r===void 0&&D(Y.contentRect.height);});return E.observe(W.current),t===void 0&&M(W.current.offsetWidth),r===void 0&&D(W.current.offsetHeight||300),()=>{E.disconnect();}},[t,r]);let F=e.map(E=>E.label).join("\0"),z=Z1({margin:o,orientation:v,labelsKey:F,width:A}),U=Math.max(0,z.left-sx),{xScale:K,yScale:O,innerWidth:V,innerHeight:L}=useMemo(()=>{let E=A-z.left-z.right,P=B-z.top-z.bottom;if(v==="horizontal"){let $=max(e,oe=>oe.value)||0;return {xScale:scaleLinear({range:[0,E],domain:[0,$*1.1],nice:true}),yScale:scaleBand({range:[0,P],domain:e.map(oe=>oe.label),padding:u}),innerWidth:E,innerHeight:P}}let Y=max(e,$=>$.value)||0;return {xScale:scaleBand({range:[0,E],domain:e.map($=>$.label),padding:u}),yScale:scaleLinear({range:[P,0],domain:[0,Y*1.1],nice:true}),innerWidth:E,innerHeight:P}},[e,A,B,z,u,v]);if(e.length===0)return jsx("div",{ref:W,className:twMerge("flex h-full min-h-[200px] w-full items-center justify-center rounded-lg border border-dashed border-border-default bg-background-surface text-sm font-medium text-text-secondary",f),style:r!==void 0?{height:r,...b}:b,children:"No data available"});let y=(E,P)=>{if(S(E),p?.(P,E),E!==null&&P){let Y,$;if(v==="horizontal"){let re=K(P.value),_=O(P.label)||0,he=O.bandwidth();Y=z.left+re,$=z.top+_+he/2;}else {let re=K,_=O,he=re(P.label)??0,me=re.bandwidth(),ue=_(P.value);Y=z.left+he+me/2,$=z.top+ue;}let oe=Y>A/2;k(P.label),T({xValue:new Date,series:[{label:"Value",value:P.value,color:P.color||I}],x:Y,y:$,position:oe?"left":"right"});}else T(null),k(null);};return jsxs("div",{ref:W,className:twMerge("relative w-full overflow-hidden rounded-lg bg-background-surface",!R&&"h-full",f),style:!R&&r!==void 0?{height:r,...b}:b,"aria-label":h,role:"img",children:[jsxs("svg",{width:A,height:B,viewBox:R?`0 0 ${A} ${B}`:void 0,style:R?{display:"block",width:"100%",height:"auto"}:void 0,children:[jsx("defs",{children:jsx(LinearGradient,{id:`${H}-bar`,from:I,to:I,toOpacity:.85})}),jsxs(Group,{left:z.left,top:z.top,children:[s&&jsx("g",{className:"grid-lines",children:(v==="horizontal"?K.ticks(5):O.ticks(5)).map(E=>{let P=v==="horizontal"?0:O(E),Y=v==="horizontal"?K(E):0;return jsx("line",{x1:v==="horizontal"?Y:0,y1:v==="horizontal"?0:P,x2:v==="horizontal"?Y:V,y2:v==="horizontal"?L:P,stroke:"var(--color-border-default)",strokeOpacity:.5,strokeDasharray:"2,3"},E)})}),e.map((E,P)=>{let Y=X===P||X==null,$=E.color||`url(#${H}-bar)`;if(v==="horizontal"){let ie=K(E.value),fe=O.bandwidth(),Te=O(E.label)||0;return jsx(motion.rect,{x:0,y:Te,width:ie,height:fe,fill:$,rx:c,ry:c,initial:d?{width:0,opacity:.5}:void 0,animate:{width:ie,opacity:Y?1:.5},transition:{duration:.5,delay:P*.05,ease:"easeOut",opacity:{duration:.15,delay:0}},style:{cursor:m||p?"pointer":"default"},onMouseEnter:()=>y(P,E),onMouseLeave:()=>y(null,null),onClick:()=>m?.(E,P)},E.label)}let oe=K,re=O,_=oe.bandwidth(),he=oe(E.label)??0,me=re(E.value),ue=Math.max(0,L-me);return d?jsx(motion.rect,{x:he,width:_,fill:$,rx:c,ry:c,initial:{y:L,height:0,opacity:.5},animate:{y:me,height:ue,opacity:Y?1:.5},transition:{duration:.5,delay:P*.05,ease:"easeOut",opacity:{duration:.15,delay:0}},style:{cursor:m||p?"pointer":"default"},onMouseEnter:()=>y(P,E),onMouseLeave:()=>y(null,null),onClick:()=>m?.(E,P)},E.label):jsx("rect",{x:he,y:me,width:_,height:ue,fill:$,rx:c,ry:c,opacity:Y?1:.5,style:{cursor:m||p?"pointer":"default",transition:"opacity 150ms ease-out"},onMouseEnter:()=>y(P,E),onMouseLeave:()=>y(null,null),onClick:()=>m?.(E,P)},E.label)}),l&&v==="vertical"&&jsxs(Fragment,{children:[jsx(uo.CategoryBottom,{top:L,scale:K}),jsx(uo.Left,{left:0,scale:O,yFormatter:i,height:L})]}),l&&v==="horizontal"&&jsxs(Fragment,{children:[jsx(uo.NumericBottom,{top:L,scale:K,yFormatter:i,width:V}),jsx(uo.CategoryLeft,{left:0,labelLeft:-z.left,scale:O,availableWidth:U})]})]})]}),x&&!R&&jsx(Ho,{data:w,formatter:i,label:N??void 0})]})};var cx=({item:e,onToggle:t})=>{let r=jsxs(Fragment,{children:[jsx("div",{className:"h-3 w-3 shrink-0",style:{backgroundColor:e.fill,borderRadius:"1px",opacity:e.isHidden?.35:1}}),jsx("span",{className:`text-sm whitespace-nowrap ${e.isHidden?"text-text-disabled line-through":"text-text-secondary"}`,children:e.category})]});return t?jsx("button",{type:"button",className:"flex items-center gap-2 shrink-0 rounded-sm focus:outline-none focus:ring-2 focus:ring-border-focus disabled:cursor-not-allowed disabled:opacity-60","aria-pressed":!e.isHidden,"aria-label":`${e.isHidden?"Show":"Hide"} ${e.category}`,disabled:e.isDisabled,onClick:()=>t(e.id??e.category),children:r}):jsx("div",{className:"flex items-center gap-2 shrink-0",children:r})},$1=({items:e,onToggle:t})=>e.length===0?null:jsx("div",{className:"flex items-center gap-3 flex-wrap",children:e.map((r,o)=>jsx(cx,{item:r,onToggle:t},`${r.category}:${o}`))}),Ti=({items:e,onExport:t,marginLeft:r=0,marginRight:o=0,hideExport:n=false,isZoomed:a=false,onResetZoom:i,onLegendItemToggle:s})=>{let[l,d]=ot__default.useState(false),[c,u]=ot__default.useState(null),[m,p]=ot__default.useState(false),[g,f]=ot__default.useState(false),b=ot__default.useCallback(async v=>{d(true),u(v),f(false);try{await t(v);}catch(x){console.error("Export failed:",x);}finally{d(false),u(null);}},[t]),h=ot__default.useCallback(async v=>{await b(v);},[b]);return jsxs("div",{className:"mt-2 flex items-center justify-between gap-3 min-h-[32px]",style:{marginLeft:r,marginRight:o},children:[jsx("div",{className:"hidden sm:block flex-1 min-w-0",children:jsx($1,{items:e,onToggle:s})}),jsx("div",{className:"sm:hidden flex items-center gap-3",children:e.length>0&&jsxs(Fragment,{children:[jsx("button",{onClick:()=>p(true),className:"text-sm text-text-secondary hover:text-text-primary transition-colors underline decoration-dotted underline-offset-4",children:"Legend"}),jsx(Lt,{isOpen:m,onClose:()=>p(false),title:"Legend",children:jsx("div",{className:"grid grid-cols-1 gap-3 p-4",children:e.map((v,x)=>jsx(cx,{item:v,onToggle:s},`${v.category}:${x}`))})})]})}),jsxs("div",{className:"sm:hidden flex items-center gap-2 shrink-0",children:[a&&i&&jsx(te,{variant:"secondary",size:"sm",onPress:i,"aria-label":"Reset Zoom",children:jsx(G,{name:"ArrowsOut",size:16})}),!n&&jsxs(Fragment,{children:[jsx(te,{variant:"secondary",size:"sm",onPress:()=>f(true),isDisabled:l,"aria-label":"Export chart",children:jsx(G,{name:"Export",size:16})}),jsx(Lt,{isOpen:g,onClose:()=>f(false),title:"Export Chart",contentPadding:false,children:jsxs("div",{className:"flex flex-col",children:[jsxs("button",{onClick:()=>b("csv"),disabled:l,className:"flex items-center gap-3 px-6 py-4 text-left hover:bg-background-hover active:bg-background-muted transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[jsx(G,{name:"List",size:20,className:"text-text-secondary"}),jsx("span",{className:"text-sm text-text-primary",children:c==="csv"?"Exporting...":"Export as CSV"})]}),jsxs("button",{onClick:()=>b("svg"),disabled:l,className:"flex items-center gap-3 px-6 py-4 text-left hover:bg-background-hover active:bg-background-muted transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[jsx(G,{name:"Code",size:20,className:"text-text-secondary"}),jsx("span",{className:"text-sm text-text-primary",children:c==="svg"?"Exporting...":"Export as SVG"})]}),jsxs("button",{onClick:()=>b("png"),disabled:l,className:"flex items-center gap-3 px-6 py-4 text-left hover:bg-background-hover active:bg-background-muted transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[jsx(G,{name:"DownloadSimple",size:20,className:"text-text-secondary"}),jsx("span",{className:"text-sm text-text-primary",children:c==="png"?"Exporting...":"Export as PNG"})]})]})})]})]}),jsxs("div",{className:"hidden sm:flex items-center gap-2 shrink-0",children:[a&&i&&jsxs(te,{variant:"secondary",size:"sm",onPress:i,children:[jsx(G,{name:"ArrowsOut",size:16}),jsx("span",{className:"hidden sm:inline",children:"Reset Zoom"})]}),!n&&jsxs(DialogTrigger,{children:[jsxs(te,{variant:"secondary",size:"sm",isDisabled:l,children:[jsx(G,{name:"Export",size:16}),l?"Exporting...":"Export"]}),jsx(Et,{placement:"top end",className:"min-w-48 p-1 bg-background-surface rounded-lg shadow-xl ring-1 ring-border-default",children:jsxs(Menu,{onAction:h,className:"outline-none",children:[jsx(MenuItem,{id:"csv",className:"flex items-center gap-2 px-3 py-2 text-sm text-text-primary rounded cursor-pointer hover:bg-background-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus focus-visible:ring-offset-1 focus-visible:ring-offset-background-surface data-[focused]:bg-background-hover data-[focused]:ring-2 data-[focused]:ring-border-focus data-[focused]:ring-offset-1 data-[focused]:ring-offset-background-surface",isDisabled:l,children:jsxs("span",{className:"flex items-center gap-2",children:[jsx(G,{name:"List",size:14}),c==="csv"?"Exporting...":"Export as CSV"]})}),jsx(MenuItem,{id:"svg",className:"flex items-center gap-2 px-3 py-2 text-sm text-text-primary rounded cursor-pointer hover:bg-background-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus focus-visible:ring-offset-1 focus-visible:ring-offset-background-surface data-[focused]:bg-background-hover data-[focused]:ring-2 data-[focused]:ring-border-focus data-[focused]:ring-offset-1 data-[focused]:ring-offset-background-surface",isDisabled:l,children:jsxs("span",{className:"flex items-center gap-2",children:[jsx(G,{name:"Code",size:14}),c==="svg"?"Exporting...":"Export as SVG"]})}),jsx(MenuItem,{id:"png",className:"flex items-center gap-2 px-3 py-2 text-sm text-text-primary rounded cursor-pointer hover:bg-background-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus focus-visible:ring-offset-1 focus-visible:ring-offset-background-surface data-[focused]:bg-background-hover data-[focused]:ring-2 data-[focused]:ring-border-focus data-[focused]:ring-offset-1 data-[focused]:ring-offset-background-surface",isDisabled:l,children:jsxs("span",{className:"flex items-center gap-2",children:[jsx(G,{name:"DownloadSimple",size:14}),c==="png"?"Exporting...":"Export as PNG"]})})]})})]})]})]})};var yc=lg(cm());var dx=["stroke","fill","color","stop-color","flood-color","lighting-color"],ux=/var\s*\(/;function px(e,t){let r=[e,...Array.from(e.querySelectorAll("*"))],o=[t,...Array.from(t.querySelectorAll("*"))],n=Math.min(r.length,o.length);for(let a=0;a<n;a++){let i=r[a],s=o[a];if(!(i instanceof Element)||!(s instanceof Element))continue;let l=window.getComputedStyle(i);for(let d of dx){let c=s.getAttribute(d);if(c&&ux.test(c)){let u=l.getPropertyValue(d);u&&s.setAttribute(d,u.trim());}}if(s instanceof HTMLElement||s instanceof SVGElement)for(let d of dx){let c=d,u=s.style.getPropertyValue(c);if(u&&ux.test(u)){let m=l.getPropertyValue(c);m&&s.style.setProperty(c,m.trim());}}}}function dm(e,t,r=true){let o=e||"chart";if(r){let n=new Date().toISOString().replace(/[:.]/g,"-").slice(0,-5);return `${o}-${n}.${t}`}return `${o}.${t}`}async function um(e,t,r={},o){let n=Array.isArray(t[0])?t:[t];try{switch(e){case "csv":await tR(n,r);break;case "svg":await rR(o,r);break;case "png":await oR(o,r);break;default:throw new Error(`Unsupported export type: ${e}`)}}catch(a){throw console.error("Export failed:",a),new Error(`Failed to export chart as ${e}: ${a instanceof Error?a.message:"Unknown error"}`)}}async function tR(e,t){try{let r=t.yFormat?np(t.yFormat):null,o=t.yFormat,n=m=>{if(m==null||m==="")return "";if(!o)return typeof m=="number"?m:String(m);let p=sh(m,o);return p===null?typeof m=="number"?m:String(m):p},a=new Map;e.forEach(m=>{m.forEach(p=>{let g=p.xValue.getTime();a.has(g)||a.set(g,p.xValue);});});let i=Array.from(a.values()).sort((m,p)=>m.getTime()-p.getTime()),s=e.map((m,p)=>{let g=t.seriesLabels?.[p]||`Series ${p+1}`;return r&&!g.includes(`(${r})`)?`${g} (${r})`:g}),l=i.map(m=>{let p={[t.xLabel||"Date"]:m.toLocaleString("en-US",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})};return e.forEach((g,f)=>{let b=s[f],h=g.find(v=>v.xValue.getTime()===m.getTime());p[b]=h?n(h.yValue):"",h?.category&&(p[`${b} Category`]=h.category);}),p}),d=eR.unparse(l,{header:!0,skipEmptyLines:!0}),c=new Blob([d],{type:"text/csv;charset=utf-8;"}),u=dm(t.filename||"chart-data","csv",t.timestamp!==!1);(0,yc.saveAs)(c,u);}catch(r){throw new Error(`CSV export failed: ${r instanceof Error?r.message:"Unknown error"}`)}}async function rR(e,t){if(!e.current)throw new Error("SVG element not found");try{let r=e.current,o=r.cloneNode(!0);if(px(r,o),!o.querySelector("rect[data-background]")){let d=document.createElementNS("http://www.w3.org/2000/svg","rect");d.setAttribute("width",o.getAttribute("width")||"100%"),d.setAttribute("height",o.getAttribute("height")||"100%"),d.setAttribute("fill","white"),d.setAttribute("data-background","true"),o.insertBefore(d,o.firstChild);}let i=new XMLSerializer().serializeToString(o);i.includes("<?xml")||(i=`<?xml version="1.0" encoding="UTF-8"?>
|
|
168
|
-
`+i),i.includes("xmlns=")||(i=i.replace("<svg",'<svg xmlns="http://www.w3.org/2000/svg"'));let s=new Blob([i],{type:"image/svg+xml;charset=utf-8"}),l=dm(t.filename||"chart","svg",t.timestamp!==!1);(0,yc.saveAs)(s,l);}catch(r){throw new Error(`SVG export failed: ${r instanceof Error?r.message:"Unknown error"}`)}}async function oR(e,t,r=2){if(!e.current)throw new Error("SVG element not found");let o="";try{let n=e.current,a=n.getBoundingClientRect(),i=n.cloneNode(!0);px(n,i),i.setAttribute("width",String(a.width)),i.setAttribute("height",String(a.height)),i.removeAttribute("transform");let s=i.getElementsByTagName("text");Array.from(s).forEach(m=>{m.style.fontFamily||(m.style.fontFamily="system-ui, -apple-system, sans-serif"),m.style.fontSize||(m.style.fontSize="12px");});let l=document.createElementNS("http://www.w3.org/2000/svg","rect");l.setAttribute("width",String(a.width)),l.setAttribute("height",String(a.height)),l.setAttribute("fill","white"),i.insertBefore(l,i.firstChild);let c=new XMLSerializer().serializeToString(i);c.includes("xmlns=")||(c=c.replace("<svg",'<svg xmlns="http://www.w3.org/2000/svg"'));let u=new Blob([c],{type:"image/svg+xml;charset=utf-8"});return o=URL.createObjectURL(u),new Promise((m,p)=>{let g=new Image,f=setTimeout(()=>{o&&URL.revokeObjectURL(o),p(new Error("Image loading timeout"));},1e4);g.onload=()=>{clearTimeout(f);try{let b=document.createElement("canvas");b.width=a.width*r,b.height=a.height*r;let h=b.getContext("2d");if(!h)throw new Error("Canvas context not available");h.imageSmoothingEnabled=!0,h.imageSmoothingQuality="high",h.scale(r,r),h.fillStyle="white",h.fillRect(0,0,a.width,a.height),h.drawImage(g,0,0,a.width,a.height),b.toBlob(v=>{if(v){let x=dm(t.filename||"chart","png",t.timestamp!==!1);(0,yc.saveAs)(v,x),m();}else p(new Error("Failed to create PNG blob"));o&&URL.revokeObjectURL(o);},"image/png",1);}catch(b){o&&URL.revokeObjectURL(o),p(b);}},g.onerror=()=>{clearTimeout(f),o&&URL.revokeObjectURL(o),p(new Error("Failed to load SVG as image"));},g.src=o;})}catch(n){throw o&&URL.revokeObjectURL(o),new Error(`PNG export failed: ${n instanceof Error?n.message:"Unknown error"}`)}}function nR(e){if(typeof window>"u")return false;switch(e){case "csv":return true;case "svg":return typeof XMLSerializer<"u";case "png":return typeof HTMLCanvasElement<"u"&&typeof HTMLCanvasElement.prototype.toBlob=="function";default:return false}}function aR(e){return {csv:"CSV Spreadsheet",svg:"SVG Vector Image",png:"PNG Image"}[e]||"Unknown Format"}function vc({datasets:e,metadata:t,svgRef:r}){return useCallback(async o=>{try{await um(o,e,t,r);}catch(n){throw console.error("Chart export failed:",n),n}},[e,t,r])}var pm=({data:e,seriesMetadata:t,width:r,height:o,onBrushChange:n,brushRegion:a,margin:i=je,yDomain:s})=>{let l=useRef(null),d=useRef(false),c=useMemo(()=>e.flat(),[e]),u=useMemo(()=>({top:10,bottom:15,left:i.left,right:i.right}),[i]),m=r-u.left-u.right,p=useMemo(()=>{if(c.length===0)return scaleTime({domain:[new Date,new Date],range:[0,m]});let v=new Date(Math.min(...c.map(C=>C.xValue.getTime()))),x=new Date(Math.max(...c.map(C=>C.xValue.getTime())));return scaleTime({domain:[v,x],range:[0,m]})},[c,m]),g=useMemo(()=>{let v=c.length>0?Math.max(0,...c.map(x=>x.yValue)):1;return scaleLinear({domain:s??[0,v],range:[o-u.bottom,u.top]})},[c,o,s,u.top,u.bottom]),f=v=>{if(d.current)return;if(!v){n(null);return}let{x0:x,x1:C}=v;if(x===C)return;let S=new Date(x),w=new Date(C);if(!(Number.isNaN(S.getTime())||Number.isNaN(w.getTime()))){if(c.length>0){let T=Math.min(...c.map(M=>M.xValue.getTime())),N=Math.max(...c.map(M=>M.xValue.getTime())),R=(N-T)*.05;if(Math.abs(S.getTime()-T)<R&&Math.abs(w.getTime()-N)<R){n(null);return}}n([S,w]);}},b=useMemo(()=>{if(c.length!==0)return {start:{x:0,y:u.top},end:{x:m,y:o-u.bottom}}},[m,o,c]);useEffect(()=>{if(!l.current||c.length===0)return;let v=l.current.state;if(v?.isBrushing||v?.activeHandle)return;let x=Math.min(...c.map(k=>k.xValue.getTime())),C=Math.max(...c.map(k=>k.xValue.getTime())),S=a?a[0]:new Date(x),w=a?a[1]:new Date(C),T=l.current.state?.extent;if(T){let k=p.invert(T.x0),R=p.invert(T.x1),A=Math.abs(k.getTime()-S.getTime()),M=Math.abs(R.getTime()-w.getTime());if(A<1e3&&M<1e3)return}d.current=true;let N=k=>{let R=l.current.getExtent({x:p(S),y:u.top},{x:p(w),y:o-u.bottom});return {...k,start:{y:R.y0,x:R.x0},end:{y:R.y1,x:R.x1},extent:R}};l.current.updateBrush(N),setTimeout(()=>{d.current=false;},50);},[a,p,o,c]);let h={fill:"url(#brush_pattern)",fillOpacity:.15,stroke:"var(--color-border-focus)",strokeWidth:1.5,strokeOpacity:.3};return jsx("div",{className:"mt-2",children:jsxs("svg",{width:r,height:o,children:[jsx(PatternLines,{id:"brush_pattern",height:8,width:8,stroke:"var(--color-text-secondary)",strokeWidth:1,orientation:["diagonal"]}),jsxs("g",{transform:`translate(${u.left}, 0)`,children:[e.map((v,x)=>jsx(LinePath,{data:v,x:C=>p(C.xValue),y:C=>g(C.yValue),stroke:t[x]?.color||"var(--color-gray-500)",strokeWidth:1.5,opacity:.8},`brush-series-${x}`)),jsx(Brush,{xScale:p,yScale:g,width:m,height:o-u.top-u.bottom,margin:{top:u.top,bottom:u.bottom,left:0,right:0},handleSize:8,innerRef:l,resizeTriggerAreas:["left","right"],brushDirection:"horizontal",initialBrushPosition:b,onChange:f,onClick:()=>n(null),selectedBoxStyle:h,useWindowMoveEvents:true})]})]})})};function ln(e){switch(e){case "command":return _t("--color-action-brand","#111111");case "success":return _t("--color-feedback-success-border","#278a4a");case "warning":return _t("--color-feedback-warning-border","#c88420");case "error":return _t("--color-feedback-error-border","#c42d2d");case "alert":return _t("--color-feedback-warning-border","#c88420");default:return _t("--color-text-secondary","#525250")}}function Sc({events:e,color:t,showLabels:r=false}){let o=useContext(co),[n,a]=useState(null);if(!o)return console.warn("ChartEventMarkers must be used within a ChartContainer"),null;let{xScale:i,yScale:s,height:l,tooltip:d,datasets:c,seriesMetadata:u,seriesTypes:m,categoryColors:p}=o,g=e.filter(h=>{let v=i(h.timestamp);return v>=je.left&&v<=i.range()[1]}),f=useCallback((h,v)=>{a(v);let x=i(h.timestamp),C=x>(i.range()[1]-je.right-je.left)/2+je.left,S=[];c&&u&&c.forEach((N,k)=>{if(N.length===0)return;let R=bisector(W=>W.xValue).left,A=R(N,h.timestamp),M=N[A-1],B=N[A],D;if(!M)D=B;else if(!B)D=M;else {let W=Math.abs(h.timestamp.getTime()-M.xValue.getTime()),X=Math.abs(h.timestamp.getTime()-B.xValue.getTime());D=W<X?M:B;}D&&u[k]&&S.push({label:u[k].label,value:D.yValue,color:u[k].color,type:m?.[k]||"line",...D.category&&{category:D.category,categoryColor:p?.[D.category]}});});let T=g.filter(N=>Math.abs(i(N.timestamp)-x)<=10).map(N=>({label:N.label,color:N.color??t??ln(N.type),metadata:N.metadata}));S.push({label:T.length>1?`${T.length} events`:h.label,value:0,color:h.color??t??ln(h.type),type:"event"}),d.show({xValue:h.timestamp,series:S,x,y:S.length>1&&typeof S[0].value=="number"?s(S[0].value):l/2,position:C?"left":"right",isEvent:true,eventMetadata:h.metadata,eventItems:T});},[i,s,l,d,t,c,u,m,p,g]),b=useCallback(()=>{a(null),d.hide();},[d]);return g.length===0?null:jsx("g",{className:"chart-event-markers","data-testid":"chart-event-markers",children:g.map((h,v)=>{let x=i(h.timestamp),C=h.color??t??ln(h.type),S=n===v;return jsxs("g",{children:[jsx("line",{x1:x,y1:je.top,x2:x,y2:l-je.bottom,stroke:C,strokeWidth:S?3:2,strokeDasharray:"4 4",strokeOpacity:S?.9:.6,pointerEvents:"none"}),jsx("circle",{cx:x,cy:je.top,r:S?5:4,fill:C,stroke:"var(--color-background-surface)",strokeWidth:2,pointerEvents:"none"}),jsx("circle",{cx:x,cy:l-je.bottom,r:S?5:4,fill:C,stroke:"var(--color-background-surface)",strokeWidth:2,pointerEvents:"none"}),r&&jsx("text",{x,y:je.top-8,textAnchor:"middle",fill:"var(--color-text-secondary)",fontSize:11,fontWeight:500,pointerEvents:"none",children:h.label}),jsx("rect",{x:x-10,y:je.top,width:20,height:l-je.top-je.bottom,fill:"transparent",style:{cursor:"pointer"},onMouseEnter:()=>f(h,v),onMouseLeave:b})]},`${h.timestamp.getTime()}-${v}`)})})}var vR=bisector(e=>e.xValue).left;function CR(e,t){if(e.length===0)return;let r=vR(e,t),o=e[r-1],n=e[r];return o?n?Math.abs(t.getTime()-o.xValue.getTime())<Math.abs(t.getTime()-n.xValue.getTime())?{point:o,index:r-1}:{point:n,index:r}:{point:o,index:r-1}:n?{point:n,index:r}:void 0}function wc({spans:e,opacity:t=.25,color:r}){let o=useContext(co),[n,a]=useState(null),i=useRef(Number.NEGATIVE_INFINITY),s=o?.xScale,l=o?.yScale,d=o?.height,c=o?.tooltip,u=o?.datasets,m=o?.seriesMetadata,p=o?.seriesTypes,g=o?.categoryColors,[f,b]=s?.domain()??[new Date(0),new Date(0)],[h,v]=s?.range()??[0,0],x=useCallback((A,M,B)=>{if(!s||!c||(a(B),A.timeStamp-i.current<16))return;i.current=A.timeStamp;let{left:D}=A.currentTarget.ownerSVGElement?.getBoundingClientRect()??{left:0},W=A.clientX-D,X=s.invert(W),H=[];u&&m&&u.forEach((K,O)=>{let V=m[O],L=CR(K,X);if(!L||!V)return;let{point:y,index:E}=L,P=gc(V,y,E);H.push({label:V.label,value:y.yValue,...P!==void 0?{baselineValue:P}:{},chartY:y.chartYValue??y.yValue,showMarker:y.showTooltipMarker??true,color:V.color,type:p?.[O]??"line",...y.category?{category:y.category,categoryColor:g?.[y.category]}:{},...y.extraTooltipRows&&y.extraTooltipRows.length>0?{extraTooltipRows:y.extraTooltipRows}:{}});});let I=W>(v-h)/2+h,z=e.filter(K=>K.end>K.start&&K.start<M.end&&K.end>M.start).map(K=>({label:K.label,color:K.color??r??ln(K.type),metadata:K.metadata}));H.push({label:z.length>1?`${z.length} scheduled commands`:M.label,value:0,color:M.color??r??ln(M.type),type:"event"});let U=H.length>1?H[0]?.chartY??H[0]?.value:void 0;c.show({xValue:X,series:H,x:W,y:typeof U=="number"&&l?l(U):(d??0)/2,position:I?"left":"right",isEvent:true,eventMetadata:M.metadata,eventItems:z});},[s,l,d,c,u,m,p,g,r,h,v,e]),C=useCallback(()=>{a(null),c?.hide();},[c]);if(!o)return console.warn("ChartEventSpans must be used within a ChartContainer"),null;let{xScale:S,height:w}=o,T=je.top,k=w-je.bottom-T,R=e.filter(A=>A.end>A.start);return R.length===0?null:jsx("g",{className:"chart-event-spans","data-testid":"chart-event-spans",children:R.map((A,M)=>{let B=A.start<f?f:A.start,D=A.end>b?b:A.end;if(B>=b||D<=f)return null;let W=S(B),H=S(D)-W;if(H<=0)return null;let I=A.color??r??ln(A.type);return jsx("rect",{x:W,y:T,width:H,height:k,fill:I,fillOpacity:n===M?Math.min((t??.25)*1.8,1):t??.25,pointerEvents:"all",style:{cursor:"pointer"},onMouseMove:z=>x(z,A,M),onMouseLeave:C},`${A.start.getTime()}-${A.end.getTime()}-${M}`)})})}var vx=createContext(false);function fm({children:e}){return jsx(vx.Provider,{value:true,children:e})}function va(e){let t=useContext(vx),[r,o]=useState(false),[n,a]=useState(null),i=useRef(null),s=useCallback(u=>{if(i.current?.disconnect(),i.current=null,!u||typeof ResizeObserver>"u")return;let m=new ResizeObserver(([p])=>{if(!p)return;let{width:g,height:f}=p.contentRect;a(b=>b&&b.width===g&&b.height===f?b:{width:g,height:f});});m.observe(u),i.current=m;},[]);useEffect(()=>()=>i.current?.disconnect(),[]);let l=useCallback(()=>{o(false),a(null);},[]),d=t?null:jsx(te,{variant:"icon",size:"sm",icon:"ArrowsOutSimple","aria-label":`Expand ${e} chart`,onPress:()=>o(true)}),c=useCallback(u=>r&&!t?jsx(Dr,{isOpen:true,onClose:l,title:e,contentPadding:false,maxWidth:"min(1200px, 100vw)",minWidth:"min(360px, 100vw)",height:"82vh",mobileHeight:"82vh",children:jsx("div",{ref:s,className:"h-full w-full p-4",children:u})}):u,[r,t,l,e,s]);return {isExpanded:r,action:d,expandedSize:n,present:c}}function Nc(e){return e?.kind==="streaming"}function kc(e){if(typeof e!="string")return null;let t=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d{1,3})?(Z|[+-]\d{2}:\d{2})$/.exec(e);if(!t)return null;let r=Date.parse(e);if(!Number.isFinite(r))return null;let o=new Date(r),[,n,a,i]=t,s=new Date(`${n}-${a}-${i}T00:00:00Z`);return s.getUTCFullYear()!==Number(n)||s.getUTCMonth()+1!==Number(a)||s.getUTCDate()!==Number(i)?null:o}var kR={sm:"gap-4 px-6 py-8",md:"gap-5 px-8 py-12",lg:"gap-6 px-10 py-16"},PR={sm:"xs",md:"sm",lg:"md"},RR={sm:zt("bodySm"),md:zt("bodySm"),lg:zt("bodyMd")},MR={sm:"h-10 w-10",md:"h-12 w-12",lg:"h-16 w-16"},ER={sm:20,md:24,lg:32},LR={center:"items-center text-center [&_.empty-state-actions]:justify-center [&_.empty-state-actions]:text-center",start:"items-start text-left [&_.empty-state-actions]:justify-start [&_.empty-state-actions]:text-left"},DR={mesh:"radial-gradient(at 20% 20%, rgba(68, 74, 225, 0.06) 0px, transparent 45%), radial-gradient(at 80% 80%, rgba(68, 74, 225, 0.045) 0px, transparent 45%), radial-gradient(at 50% 50%, rgba(68, 74, 225, 0.03) 0px, transparent 50%)","top-fade":"linear-gradient(to bottom, rgba(68, 74, 225, 0.06) 0%, rgba(68, 74, 225, 0.02) 60%, transparent 100%)",center:"radial-gradient(ellipse 600px 400px at center, rgba(68, 74, 225, 0.06) 0px, transparent 60%)",corners:"radial-gradient(at 0% 0%, rgba(68, 74, 225, 0.06) 0px, transparent 40%), radial-gradient(at 100% 100%, rgba(68, 74, 225, 0.045) 0px, transparent 40%)",bottom:"radial-gradient(ellipse 700px 300px at 50% 100%, rgba(68, 74, 225, 0.06) 0px, transparent 60%)",asymmetric:"radial-gradient(at 15% 30%, rgba(68, 74, 225, 0.06) 0px, transparent 45%), radial-gradient(at 85% 70%, rgba(68, 74, 225, 0.04) 0px, transparent 50%)"};function ki({icon:e,title:t,description:r,primaryAction:o,secondaryAction:n,actions:a,size:i="md",alignment:s="center",variant:l="default",spotlightPattern:d="mesh",fullHeight:c=false,className:u}){let m=i==="sm"?"sm":"md",p=l==="spotlight",g=p?{background:DR[d]}:void 0,f=()=>a?jsx("div",{className:"empty-state-actions mt-2 flex flex-wrap items-center gap-3",children:a}):o||n?jsxs("div",{className:"empty-state-actions mt-2 flex flex-col gap-3",children:[o&&(o.href?jsx(te,{variant:"secondary",size:m,onPress:o.onPress,isDisabled:o.isDisabled,isLoading:o.isLoading,href:o.href,children:o.label}):jsx(te,{variant:"secondary",size:m,onPress:o.onPress,isDisabled:o.isDisabled,isLoading:o.isLoading,children:o.label})),n&&jsx(St,{href:n.href||"#",variant:"muted",onPress:n.onPress,className:zt("labelMd"),children:n.label})]}):null;return jsxs("section",{"data-testid":"empty-state",role:"status","aria-live":"polite",className:twMerge("flex w-full flex-col rounded-xl text-text-primary",kR[i],LR[s],c?"h-full justify-center":"",p?"relative overflow-hidden":"",u),style:g,children:[e&&jsx("div",{className:twMerge("flex items-center justify-center rounded-full border border-border-muted bg-background-muted text-text-secondary",MR[i]),children:jsx(G,{name:e,size:ER[i]})}),jsx(vr,{size:PR[i],tag:"h2",className:"text-text-secondary",children:t}),r&&jsx("p",{className:twMerge("max-w-xs text-text-secondary whitespace-pre-line",RR[i]),children:r}),f()]})}function cn(e,t=""){return Children.toArray(e).flatMap(r=>isValidElement(r)&&r.type===Fragment$1?cn(r.props.children,`${t}${String(r.key)}`):t&&isValidElement(r)?[cloneElement(r,{key:`${t}${String(r.key)}`})]:[r])}function Pc(e,t,r,o){if(r.length===0)throw new Error("tierForViewport: resolution ladder is empty");let n=[...r].sort((s,l)=>s.bucketMs-l.bucketMs),a=e/Math.max(1,t*o.targetPointsPerPx),i=Math.max(o.nativeMs,a);return n.find(s=>s.bucketMs>=i)??n[n.length-1]}function BR(e,t){return Math.floor(e/t.tileSpanMs)}function dn(e,t,r){let o=BR(e.startMs,t)-r,n=Math.ceil(e.endMs/t.tileSpanMs)-1+r,a=[];for(let i=o;i<=n;i++)a.push({tierId:t.id,index:i,startMs:i*t.tileSpanMs,endMs:(i+1)*t.tileSpanMs});return a}var br=(e,t)=>`${e}:${t}`,Ca=e=>!!e&&(e.line.length>0||(e.band?.length??0)>0||Object.values(e.lines??{}).some(t=>t.length>0));var wx={erroredTiles:0};function hm(e,t){let r=new Map,o=new Map,n=new Map,a=0;for(let m of e){let p=t.get(br(m.tierId,m.index));if(p&&(p.error&&(a+=1),!!p.data)){for(let g of p.data.line)r.set(g.xValue.getTime(),g);for(let g of p.data.band??[])o.set(g.xValue.getTime(),g);for(let[g,f]of Object.entries(p.data.lines??{})){let b=n.get(g);b||(b=new Map,n.set(g,b));for(let h of f)b.set(h.xValue.getTime(),h);}}}let i=(m,p)=>m.xValue.getTime()-p.xValue.getTime(),s=[...r.values()].sort(i),l=[...o.values()].sort(i),d=Object.fromEntries([...n.entries()].map(([m,p])=>[m,[...p.values()].sort(i)])),c,u;for(let m of [s,l,...Object.values(d)]){if(!m.length)continue;let p=m[0].xValue.getTime(),g=m[m.length-1].xValue.getTime();c=Math.min(c??p,p),u=Math.max(u??g,g);}return {line:s,band:l,lines:d,coverage:{earliestMs:c,latestMs:u,erroredTiles:a}}}function VR(e,t,r,o){let n=dn(e,t,0).filter(a=>o==null||a.startMs<o);return n.length===0?false:n.every(a=>{let i=r.get(br(a.tierId,a.index));return i!=null&&(i.status==="loaded"||i.status==="empty")})}function Tx(e,t,r){return dn(e,t,0).some(n=>{let a=r.get(br(n.tierId,n.index));return a?.status==="loaded"&&Ca(a.data)})}function OR(e,t){if(!Ca(e))return false;let r=e.coverage.earliestMs,o=e.coverage.latestMs;return r==null||o==null?false:r<t.endMs&&o>t.startMs}function Nx({viewport:e,targetTier:t,ladder:r,store:o,overscanTiles:n,prev:a,prevViewport:i,maxFutureMs:s}){let l=VR(e,t,o,s),d=dn(e,t,0).filter(p=>s==null||p.startMs<s).map(p=>o.get(br(p.tierId,p.index))),c=d.every(p=>p?.revalidated&&!p.refreshing&&!p.error),u=Tx(e,t,o);if(l&&(!u||a?.isFallback)&&d.some(p=>p?.refreshing||p?.error||p?.revalidated===false)&&a&&a.targetTier.id===t.id&&i?.startMs===e.startMs&&i?.endMs===e.endMs)return a;if(l&&(c||u)){let p=dn(e,t,n),{line:g,band:f,lines:b,coverage:h}=hm(p,o);return {line:g,band:f,lines:b,renderTier:t,targetTier:t,isFallback:false,isStale:false,coverage:h}}let m=r.findIndex(p=>p.id===t.id);for(let p=m+1;p<r.length;p++){let g=r[p];if(Tx(e,g,o)){let f=dn(e,g,n),{line:b,band:h,lines:v,coverage:x}=hm(f,o);return {line:b,band:h,lines:v,renderTier:g,targetTier:t,isFallback:true,isStale:false,coverage:x}}}if(l){let p=dn(e,t,n),{line:g,band:f,lines:b,coverage:h}=hm(p,o);return {line:g,band:f,lines:b,renderTier:t,targetTier:t,isFallback:false,isStale:false,coverage:h}}return a?OR(a,e)?{...a,targetTier:t,isFallback:true,isStale:false}:{line:a.line,band:a.band,lines:a.lines,renderTier:null,targetTier:t,isFallback:true,isStale:true,coverage:wx}:{line:[],band:[],lines:{},renderTier:null,targetTier:t,isFallback:false,isStale:false,coverage:wx}}var bm=new Map;function kx(e,t){switch(t.type){case "reset":return new Map;case "request":{let r=new Map(e);for(let o of t.ids){let n=r.get(o);t.refresh&&n?.data?r.set(o,{...n,refreshing:true,error:void 0,revalidated:false}):(!n||n.status==="error")&&r.set(o,{status:"loading",refreshing:!!t.refresh});}return r}case "cancel":{let r=new Map(e);for(let o of t.ids){let n=r.get(o);n&&r.set(o,{...n,refreshing:false,status:n.data?n.status:"error"});}return r}case "fulfilled":{let r=new Map(e);return r.set(t.id,{status:Ca(t.data)?"loaded":"empty",data:t.data,revision:(e.get(t.id)?.revision??0)+1,revalidated:t.refresh||e.get(t.id)?.revalidated}),r}case "failed":{let r=new Map(e),o=e.get(t.id);return r.set(t.id,o?.data?{...o,refreshing:false,error:t.error}:{status:"error",error:t.error}),r}default:return e}}function Rx({refs:e,refsKey:t,store:r,tier:o,viewport:n,fetchTile:a,dispatch:i,concurrency:s,maxFutureMs:l,resetKey:d,refreshKey:c,refreshEnabled:u=true,automaticLoads:m=false}){let p=useRef({resetKey:d,refreshKey:c,refreshEnabled:u});useLayoutEffect(()=>{p.current={resetKey:d,refreshKey:c,refreshEnabled:u};},[d,c,u]);let g=useRef(new Map),f=useRef(new Map),b=useRef(0),h=useRef(false),v=useRef(null),x=useRef(new Map),C=useRef({resetKey:d,refreshKey:c,refreshEnabled:u}),S=useRef(`${o.id}:${n.startMs}:${n.endMs}`),[w,T]=useReducer(k=>k+1,0),N=useCallback(()=>{for(let k of g.current.values())k.ac.abort();g.current.clear(),f.current.clear(),v.current=null,h.current=false,x.current.clear();},[]);return useEffect(()=>{let k=`${o.id}:${n.startMs}:${n.endMs}`,R=C.current.resetKey!==d,A=C.current.refreshKey!==c,M=C.current.refreshEnabled&&!u;if(R&&N(),u)(A||h.current)&&!R&&(h.current=false,b.current+=1,v.current={generation:b.current,seen:new Set});else {h.current||(h.current=f.current.size>0||[...g.current.values()].some(F=>F.refresh));let I=[...f.current.keys()];for(let F of I)x.current.set(F,S.current);f.current.clear(),v.current=null;for(let[F,z]of g.current)!z.refresh&&!(M&&z.automatic)||(z.ac.abort(),g.current.delete(F),I.push(F),x.current.set(F,M&&S.current===k?k:z.viewportKey));I.length&&i({type:"cancel",ids:I});}C.current={resetKey:d,refreshKey:u||R?c:C.current.refreshKey,refreshEnabled:u},S.current=k;let B=v.current;if(B){let I=[];for(let F of e){let z=br(F.tierId,F.index);B.seen.has(z)||l!=null&&F.startMs>=l||(B.seen.add(z),f.current.set(z,B.generation),I.push(z));}I.length&&i({type:"request",ids:I,refresh:true});}let D=new Set(e.map(I=>br(I.tierId,I.index)));for(let I of f.current.keys())D.has(I)||(f.current.delete(I),x.current.set(I,k),i({type:"cancel",ids:[I]}));for(let[I,F]of g.current)(F.tierId!==o.id||F.refresh&&!D.has(I))&&(F.ac.abort(),g.current.delete(I),x.current.set(I,k),i({type:"cancel",ids:[I]}));let W=e.filter(I=>{if(l!=null&&I.startMs>=l)return false;let F=br(I.tierId,I.index);if(g.current.has(F))return false;let z=r.get(F),U=x.current.get(F);return U===k&&!f.current.has(F)?false:f.current.has(F)||U!=null||!z||z.status==="loading"}),X=(n.startMs+n.endMs)/2;W.sort((I,F)=>Math.abs((I.startMs+I.endMs)/2-X)-Math.abs((F.startMs+F.endMs)/2-X));let H=W.slice(0,Math.max(0,s-g.current.size));for(let I of H){let F=br(I.tierId,I.index),z=f.current.get(F),U=z!==void 0,K={ac:new AbortController,tierId:I.tierId,generation:z??b.current,refresh:U,automatic:m&&u,viewportKey:k};x.current.delete(F),g.current.set(F,K),i({type:"request",ids:[F],refresh:U});let O=l!=null?Math.min(I.endMs,l):I.endMs,V=()=>!K.ac.signal.aborted&&p.current.resetKey===d&&g.current.get(F)===K&&(!K.automatic||p.current.refreshEnabled)&&(!U||p.current.refreshEnabled&&p.current.refreshKey===c)&&(f.current.get(F)??K.generation)===K.generation;Promise.resolve().then(()=>{if(K.ac.signal.aborted)throw new DOMException("Aborted","AbortError");return a(o,I.startMs,O,K.ac.signal,{reason:U?"refresh":"load",isCurrent:V})}).then(L=>{V()&&i({type:"fulfilled",id:F,data:L,refresh:U});}).catch(L=>{if(!V())return;let y=L instanceof Error?L.message:String(L);i({type:"failed",id:F,error:new Error(`tile fetch failed (tile ${F}, tier ${o.id}): ${y}`)});}).finally(()=>{g.current.get(F)===K&&(g.current.delete(F),f.current.get(F)===K.generation&&f.current.delete(F),!f.current.size&&![...g.current.values()].some(L=>L.refresh)&&(v.current=null),T());});}},[e,t,r,a,o,n,i,s,l,d,c,u,m,N,w]),useEffect(()=>N,[N]),{abortAll:N}}var Ex=1.3,KR=25e4,YR=3;function XR(e,t,r){let o=t.tileSpanMs/t.bucketMs,n=Math.max(1,Math.floor(KR/o/r));return Math.min(Math.max(1,Math.ceil(.5*e/t.tileSpanMs)),n)}function Rc(e){let{fetchTile:t,ladder:r,nativeMs:o,viewport:n,widthPx:a,maxFutureMs:i,targetPointsPerPx:s=1,concurrency:l=3,tileCostSeriesCount:d=YR,resetKey:c,refreshKey:u,refreshEnabled:m,automaticLoads:p}=e,g=useMemo(()=>({targetPointsPerPx:s,nativeMs:o}),[s,o]),[f,b]=useState(()=>Pc(n.endMs-n.startMs,Math.max(1,a),r,g)),[h,v]=useReducer(kx,bm),[x,C]=useState(c),S=x===c?h:bm,w=useRef(null),T=useRef(null);x!==c&&(C(c),w.current=null,T.current=null,v({type:"reset"}));let N=useRef(n.endMs-n.startMs),k=useRef(g);useEffect(()=>{let V=n.endMs-n.startMs,L=Pc(V,Math.max(1,a),r,g);if(L.id===f.id){k.current=g;return}let E=Pc(V,Math.max(1,a),r,k.current).id!==L.id,P=V/N.current;(E||P>Ex||P<1/Ex)&&(N.current=V,k.current=g,b(L));},[n,a,r,f.id,g]);let R=n.endMs-n.startMs,A=useMemo(()=>XR(R,f,d),[R,f,d]),M=useMemo(()=>dn(n,f,A),[n,f,A]),B=useMemo(()=>M.map(V=>br(V.tierId,V.index)).join(","),[M]),D=useRef(M);D.current=M;let W=useRef(n);W.current=n;let X=useRef(S);X.current=S,Rx({refs:M,refsKey:B,store:S,tier:f,viewport:n,fetchTile:t,dispatch:v,concurrency:l,resetKey:c,refreshKey:u,refreshEnabled:m,automaticLoads:p,...i!=null?{maxFutureMs:i}:{}});let H=useMemo(()=>D.current.map(V=>{let L=br(V.tierId,V.index),y=S.get(L);return `${L}:${y?.status??"\u2205"}:${y?.revision??0}:${!!y?.error}`}).join("|"),[B,S]),I=useMemo(()=>{let V=Nx({viewport:W.current,targetTier:f,ladder:r,store:X.current,overscanTiles:A,prev:w.current,prevViewport:T.current,maxFutureMs:i});return w.current=V,T.current=W.current,V},[H,f,r,A,n.startMs,n.endMs,i,c]),F=useMemo(()=>D.current.some(V=>X.current.get(br(V.tierId,V.index))?.status==="loading"),[H]),z=useMemo(()=>{let V=D.current[0];return V?X.current.get(br(V.tierId,V.index))?.status==="empty":false},[H]),U=M.map(V=>S.get(br(V.tierId,V.index))),K=U.some(V=>V?.refreshing),O=U.find(V=>V?.error)?.error;return {tier:f,series:I,loading:F,refreshing:K,refreshError:O,atDataStart:z}}function ym(e){let{initialViewport:t,...r}=e,[o,n]=useState(t),a=Rc({...r,viewport:o}),i=useCallback(l=>n(l),[]),s=useCallback(l=>n(l),[]);return {viewport:o,onViewportChange:i,jumpTo:s,...a}}var jR=1440*60*1e3,qR=[{id:"5y",label:"5 years",days:5*365},{id:"year",label:"Year",days:365},{id:"month",label:"Month",days:30},{id:"week",label:"Week",days:7},{id:"day",label:"24h",days:1}],ZR=[{id:"day",days:1},{id:"week",days:7},{id:"month",days:30}];function Lx(e,t=Date.now){return ZR.map(({id:r,days:o})=>({id:r,label:e[r],getRange:()=>{let n=new Date(t());return {after:subDays(n,o),before:n}}}))}function Mc(e=Date.now){return qR.map(({id:t,label:r,days:o})=>({id:t,label:r,getRange:()=>{let n=e();return {after:new Date(n-o*jR),before:new Date(n)}}}))}function r2({selectionState:e,isDisabled:t}){let r=`${pt} w-full h-full flex items-center justify-center rounded-sm forced-color-adjust-none font-semibold`,o={none:"text-text-primary group-hover:bg-background-muted group-pressed:bg-background-muted",middle:["bg-background-selected group-hover:bg-background-muted forced-colors:group-hover:bg-[Highlight]","group-invalid:group-hover:bg-feedback-error-background forced-colors:group-invalid:group-hover:bg-[Mark]","group-pressed:bg-background-muted forced-colors:group-pressed:bg-[Highlight] forced-colors:text-[HighlightText]","group-invalid:group-pressed:bg-feedback-error-background forced-colors:group-invalid:group-pressed:bg-[Mark]"].join(" "),cap:"bg-action-default text-[color:var(--color-action-default-text)] group-invalid:bg-feedback-error-border forced-colors:bg-[Highlight] forced-colors:group-invalid:bg-[Mark] forced-colors:text-[HighlightText]"},n=t?"text-text-disabled forced-colors:text-text-disabled font-light":"";return [r,o[e],n].filter(Boolean).join(" ")}function Ri({errorMessage:e,...t}){return jsxs(RangeCalendar,{...t,children:[jsx(nc,{}),jsxs(CalendarGrid,{className:"w-full border-separate [border-spacing:0] [&_td]:p-0 [&_td]:!border-0",children:[jsx(ac,{}),jsx(CalendarGridBody,{children:r=>jsx(CalendarCell,{date:r,className:"selection-start:rounded-s-full selection-end:rounded-e-full [td:last-child_&]:rounded-e-end group h-9 w-9 cursor-default text-sm border-0 outside-month:text-text-disabled invalid:selected:bg-feedback-error-background forced-colors:selected:bg-[Highlight] forced-colors:selected:text-[HighlightText] forced-colors:invalid:selected:bg-[Mark] [td:first-child_&]:rounded-s-full [&]:border-0",children:({formattedDate:o,isSelected:n,isSelectionStart:a,isSelectionEnd:i,isFocusVisible:s,isDisabled:l})=>jsx("span",{className:r2({selectionState:n&&(a||i)?"cap":n?"middle":"none",isDisabled:l}),children:o})})})]}),e&&jsx(Text,{slot:"errorMessage",className:"text-sm text-feedback-error-text",children:e})]})}function Ax(e){return e==="brand"?"primary":e==="default"||e==="secondary"||!e?"subtle":e}var n2={sm:"h-[var(--control-sm-height)] text-xs",md:"h-[var(--control-md-height)] text-sm",lg:"h-[var(--control-lg-height)] text-base",xl:"h-[var(--control-xl-height)] text-lg"},a2={sm:14,md:16,lg:18,xl:20},i2=({isSelected:e,isFirst:t,isLast:r,isDisabled:o,variant:n="subtle"})=>{let a=Ax(n),i=a==="primary"?"focus-visible:outline-action-primary":"focus-visible:outline-[color:var(--color-action-secondary-text)]";return a==="subtle"?twMerge(pt(),"focus-visible:outline-[color:var(--color-action-secondary-text)]","px-3 text-center transition cursor-pointer forced-color-adjust-none -ml-px first:ml-0 flex items-center justify-center h-full gap-2",e?"bg-background-muted text-text-primary font-medium forced-colors:!bg-[Highlight] forced-colors:!text-[HighlightText]":"text-text-secondary hover:bg-background-hover pressed:bg-background-hover forced-colors:!bg-[ButtonFace] forced-colors:!text-[ButtonText]",!r&&"border-r border-border-muted",o&&"bg-background-muted text-text-disabled forced-colors:!bg-[ButtonFace] forced-colors:!text-[GrayText] border-border-muted forced-colors:border-[GrayText] cursor-not-allowed"):twMerge(pt(),i,"px-3 text-center transition cursor-pointer forced-color-adjust-none -ml-px first:ml-0 flex items-center justify-center h-full gap-2",e?"bg-action-primary text-[color:var(--color-action-primary-text)] font-semibold forced-colors:!bg-[Highlight] forced-colors:!text-[HighlightText]":"text-text-secondary hover:bg-background-hover pressed:bg-background-hover forced-colors:!bg-[ButtonFace] forced-colors:!text-[ButtonText] hover:font-semibold",!r&&"border-r border-border-muted",o&&"bg-background-muted text-text-disabled forced-colors:!bg-[ButtonFace] forced-colors:!text-[GrayText] border-border-muted forced-colors:border-[GrayText] cursor-not-allowed")};function Lc({options:e,value:t,onChange:r,size:o="md",className:n,isDisabled:a,variant:i="subtle",iconOnly:s=false,"aria-label":l}){return jsx("div",{className:twMerge("inline-flex overflow-hidden rounded-[var(--control-border-radius)]",Ax(i)==="subtle"?"border border-border-muted":"border-2 border-border-muted",n2[o],n),role:"group","aria-label":l,children:e.map((d,c)=>{let u=s&&!!d.icon;return jsxs(ToggleButton,{isSelected:t===d.id,onChange:()=>r(d.id),className:i2({isSelected:t===d.id,isFirst:c===0,isLast:c===e.length-1,isDisabled:a,variant:i}),isDisabled:a,"aria-label":d.label,children:[d.icon&&jsx(G,{name:d.icon,size:a2[o]}),u?jsx("span",{className:"sr-only",children:d.label}):jsx("span",{className:"inline-flex flex-col items-center after:content-[attr(data-label)] after:font-semibold after:h-0 after:overflow-hidden after:invisible","data-label":d.label,children:d.label})]},d.id)})})}function d2(e){return e instanceof Date&&!Number.isNaN(e.getTime())}function Sm(e){return d2(e)?e:(console.warn("Invalid date detected in TimeControls, using fallback:",e),new Date)}var zx=120*1e3,u2=.02,Hx={ONE_MINUTE:0,FIVE_MINUTES:1,FIFTEEN_MINUTES:2,HOUR:3,DAY:4,WEEK:5,MONTH:6,YEAR:7},p2=[{id:"FIFTEEN_MINUTES",label:"15m"},{id:"HOUR",label:"1h"},{id:"DAY",label:"1d"},{id:"WEEK",label:"1w"}];function Dc({dateRange:e,onDateRangeChange:t,windowSize:r,onWindowSizeChange:o,showWindowSize:n=true,showRangeSelector:a=true,allowDatePicker:i=false,lockWindowSize:s=false,showReset:l=true,restrictToSingleDay:d=false,presetRanges:c=[],windowSizeOptions:u=p2,autoAdjustWindowSize:m=false,size:p="md",className:g}){let[f,b]=useState(0),h=useRef(null),[v,x]=useState(false),[C,S]=useState(null),w=y=>{let P=(y.before.getTime()-y.after.getTime())/(1e3*60*60);return P<=24?"FIFTEEN_MINUTES":P<=72||P<=168?"HOUR":("DAY")};useEffect(()=>{if(m&&!v&&o){let y=w(e);o(y);}},[e,m,v,o]);let T=y=>{let E;for(let P of c){let Y=P.getRange(),$=(Y.before.getTime()-Y.after.getTime())*u2,oe=Math.abs(Y.after.getTime()-y.after.getTime()),re=Math.abs(Y.before.getTime()-y.before.getTime());if(oe>$||re>$)continue;let _=oe+re;(!E||_<E.distance)&&(E={id:P.id,distance:_});}return E?.id},N=C&&c.some(y=>y.id===C.id)&&Math.abs(C.after-e.after.getTime())<=zx&&Math.abs(C.before-e.before.getTime())<=zx?C.id:T(e),k=Sm(e.after),R=Sm(e.before),A=new Date(R.getTime()-1),M={start:fromDate(k,getLocalTimeZone()),end:fromDate(A,getLocalTimeZone())};useEffect(()=>{let y=new ResizeObserver(E=>{for(let P of E)b(P.contentRect.width);});return h.current&&y.observe(h.current),()=>{h.current&&y.unobserve(h.current);}},[]);let B=[...u].sort((y,E)=>Hx[y.id]-Hx[E.id]),D=y=>{let E=y.toString(),P=c.find(Y=>Y.id===E);if(P){let Y=P.getRange();S({id:E,after:Y.after.getTime(),before:Y.before.getTime()}),x(false),t(Y,{presetId:E});}},W=y=>{if(y?.start&&y?.end){S(null);let E=new Date(y.start.year,y.start.month-1,y.start.day,0,0,0,0),P=new Date(y.end.year,y.end.month-1,y.end.day+1,0,0,0,0);t({after:E,before:P});}},X=y=>{if(y){S(null);let E=new Date(y.year,y.month-1,y.day,0,0,0,0),P=new Date(y.year,y.month-1,y.day+1,0,0,0,0);t({after:E,before:P});}},H=y=>{o&&(x(true),o(y.toString()));},I=()=>{c.length>0&&D(c[0].id);},F=y=>Sm(y).toLocaleDateString("en-US"),z=B.map(y=>({id:y.id,label:y.label,value:y.id})),U=c.map(y=>({id:y.id,label:y.label,value:y.id})),K=s?jsx("div",{className:"flex items-center rounded-md border border-border-muted bg-background-muted px-3 py-2 text-sm text-text-secondary",children:B.find(y=>y.id===r)?.label||r}):jsx(on,{className:"w-full md:w-auto",selectedKey:r,onSelectionChange:H,items:z,size:p,"aria-label":"Select Window Size",children:y=>jsx(Ir,{id:y.id,"aria-label":y.label,size:p,children:y.label},y.id)}),O=l&&!N&&c.length>0,V=d?jsx("div",{className:"flex items-center",children:jsxs(DialogTrigger,{children:[jsxs(te,{className:"border-l pl-2 pr-2 hover:border-border-default hover:bg-background-muted hover:text-text-link-hover",variant:"secondary",size:p,children:[jsx(G,{name:"CalendarBlank",size:18}),jsx("span",{className:"ml-2 hidden md:block",children:F(e.after)})]}),jsx(Et,{className:"z-50 w-auto p-3",disableGroup:true,children:jsx(xi,{"aria-label":"Select date",value:parseDate(k.toISOString().split("T")[0]),onChange:X})})]})}):jsxs("div",{className:"flex items-center",children:[jsxs(DialogTrigger,{children:[jsxs(te,{className:twMerge("border-l pl-2 pr-2 hover:border-border-default hover:bg-background-muted hover:text-text-link-hover",O&&"rounded-r-none"),variant:"secondary",size:p,children:[jsx(G,{name:"CalendarBlank",size:18}),!N&&jsx("span",{className:"ml-2 hidden md:block",children:`${F(e.after)} - ${F(A)}`})]}),jsx(Et,{className:"z-50 w-auto p-3",disableGroup:true,children:jsx(Ri,{"aria-label":"Date range calendar",value:M,onChange:W})})]}),O&&jsx(te,{variant:"ghost",size:p,onPress:I,children:"Reset"})]}),L=f<600;return jsx("div",{ref:h,className:twMerge("flex w-full flex-wrap items-center justify-between gap-4",g),children:L?jsxs("div",{className:"flex w-full justify-between",children:[jsxs("div",{className:"flex items-center",children:[i&&V,a&&c.length>0&&jsx(on,{selectedKey:N??"",onSelectionChange:D,items:U,size:p,"aria-label":"Select Date Range",children:y=>jsx(Ir,{id:y.id,size:p,children:y.label},y.id)})]}),jsx("div",{className:"flex items-center",children:n&&r&&K})]}):jsxs(Fragment,{children:[jsxs("div",{className:"flex items-center gap-4",children:[i&&V,a&&c.length>0&&jsx(Lc,{options:c.map(y=>({id:y.id,label:y.label})),value:N??"",onChange:D,size:"sm",variant:"secondary","aria-label":"Select Date Range"})]}),jsx("div",{className:"flex items-center",children:n&&r&&K})]})})}function Ac({children:e,label:t="About this chart"}){return jsx(tr,{content:e,placement:"bottom end",openOnPress:true,children:jsx(te,{variant:"ghost",size:"sm","aria-label":t,className:"px-1.5",children:jsx(G,{name:"Info",size:16})})})}function Ic(){let e=new Map;return {publish(t,r){for(let[o,n]of e)o!==t&&n(r);},subscribe(t,r){return e.set(t,r),()=>{e.delete(t);}}}}var g2=bisector(e=>e.xValue).left,h2=(e,t,r)=>{if(!e.tooltipRange||e.baseline===void 0)return;let o=typeof e.baseline=="function"?e.baseline(t,r):e.baseline;return typeof o=="number"&&Number.isFinite(o)&&o!==t.yValue?o:void 0};function Gx(e){let{mouseX:t,datasets:r,seriesMetadata:o,seriesTypes:n,xScale:a,yScale:i,plotLeft:s,plotRight:l}=e,d=a.invert(t),c=r.map((p,g)=>{if(!p||p.length===0)return null;let f=g2(p,d,1);if(f===0)return {point:p[0],index:0,datasetIndex:g};if(f>=p.length)return {point:p[p.length-1],index:p.length-1,datasetIndex:g};let b=p[f-1],h=p[f];if(!b||!h)return null;let v=Math.abs(b.xValue.getTime()-d.getTime()),x=Math.abs(h.xValue.getTime()-d.getTime()),C=v<x;return {point:C?b:h,index:C?f-1:f,datasetIndex:g}}).filter(p=>p!==null&&o[p.datasetIndex]!==void 0).map(({point:p,index:g,datasetIndex:f})=>({label:o[f].label,value:p.yValue,baselineValue:h2(o[f],p,g),color:o[f].color,point:p,type:n[f]}));if(c.length===0)return null;let u=a(c[0].point.xValue),m=u>(s+l)/2;return {xValue:c[0].point.xValue,series:c.map(({label:p,value:g,baselineValue:f,color:b,point:h,type:v})=>({label:p,value:g,...f!==void 0?{baselineValue:f}:{},chartY:h.chartYValue??g,showMarker:h.showTooltipMarker??true,color:b,type:v,...h.category!==void 0?{category:h.category}:{},...h.extraTooltipRows&&h.extraTooltipRows.length>0?{extraTooltipRows:h.extraTooltipRows}:{}})),x:u,y:i(c[0].point.chartYValue??c[0].value),position:m?"left":"right"}}var Kx=e=>e instanceof Date&&!Number.isNaN(e.getTime()),v2=160;function Fc(e,t,r){let[o,n]=useState(null);useImperativeHandle(r,()=>({setPreview:n}),[]);let[a,i]=e.range(),s=useMemo(()=>o?scaleTime$1().domain([new Date(o[0]),new Date(o[1])]).range([a,i]):e,[o,e,a,i]),l=s.domain(),d=l[0],c=l[l.length-1],u=Kx(d)&&Kx(c),m=t<400,p=Math.max(2,Math.min(8,Math.floor(t/(m?70:110)))),g=useMemo(()=>{if(!u)return [];let f=i-a;if(f<=0)return s.ticks(p);let[b,h]=s.domain(),v=b.getTime(),x=h.getTime(),C=(x-v)/f,S=Math.min(v2,f),w=S*C,T=scaleTime$1().domain([new Date(v-w),new Date(x+w)]).range([a-S,i+S]),N=timeTickInterval(b,h,p);if(N)return T.ticks(N);let k=Math.max(2,Math.round(p*(f+2*S)/f));return T.ticks(k)},[s,p,u,a,i]);return {activeScale:s,ticks:g,start:d,end:c,valid:u,compact:m,rangeStart:a,rangeEnd:i}}var T2=6,Yx=20,Nm=forwardRef(({top:e,scale:t,width:r},o)=>{let{activeScale:n,ticks:a,start:i,end:s,valid:l,compact:d,rangeStart:c,rangeEnd:u}=Fc(t,r,o),m=a.length>=2?a[1].getTime()-a[0].getTime():s.getTime()-i.getTime(),p=useMemo(()=>l?ch(m,{compact:d}):()=>"",[m,d,l]),g=useId(),f=Math.min(c,u),b=Math.abs(u-c);return jsxs("g",{children:[jsx("line",{x1:c,x2:u,y1:e,y2:e,stroke:"var(--color-border-muted)",strokeWidth:1}),a.length>0&&jsxs(Fragment,{children:[jsx("defs",{children:jsx("clipPath",{id:g,children:jsx("rect",{x:f,y:e-4,width:b,height:Yx+16})})}),jsx("g",{clipPath:`url(#${g})`,children:a.map(h=>jsxs("g",{transform:`translate(${n(h)},${e})`,children:[jsx("line",{x1:0,x2:0,y1:0,y2:T2,stroke:"var(--color-border-muted)",strokeWidth:1}),jsx("text",{x:0,y:Yx,textAnchor:"middle",fontSize:12,fill:"var(--color-text-secondary)",children:p(h)})]},h.getTime()))})]})]})});Nm.displayName="LiveTimeAxisBottom";var km=forwardRef(({scale:e,width:t,top:r,bottom:o},n)=>{let{activeScale:a,ticks:i,rangeStart:s,rangeEnd:l}=Fc(e,t,n),d=useId(),c=Math.min(s,l),u=Math.abs(l-s);return jsxs("g",{"aria-hidden":"true",children:[jsx("defs",{children:jsx("clipPath",{id:d,children:jsx("rect",{x:c,y:r,width:u,height:o-r})})}),jsx("g",{clipPath:`url(#${d})`,children:i.map(m=>{let p=a(m);return jsx("line",{x1:p,x2:p,y1:r,y2:o,stroke:"var(--color-border-muted)",strokeWidth:1},m.getTime())})})]})});km.displayName="LiveTimeGridlines";function Bc(e,t,r){let o=e[1]-e[0],n=t/Math.max(1,r)*o;return [e[0]-n,e[1]-n]}function Xx(e,t,r){let o=e[1]-e[0],n=e[0]+t*o,a=o/r,i=n-t*a;return [i,i+a]}function Pm(e,t,r=16,o=800){return t===1?e*r:t===2?e*o:e}var Jx=(e,t,r,o,n)=>{let a=t!==1?Xx(e,r,t):e;return o!==0&&(a=Bc(a,o,n)),a},Rm=(e,t)=>{if(!t)return e;let r=e[1]-e[0];if(r>=t[1]-t[0])return [t[0],t[1]];let[o,n]=e;return n>t[1]&&(n=t[1],o=n-r),o<t[0]&&(o=t[0],n=o+r),[o,n]},E2=e=>typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(()=>e(0),0),L2=e=>{typeof cancelAnimationFrame=="function"?cancelAnimationFrame(e):clearTimeout(e);};function jx(e){let{groupRef:t,overlayRef:r}=e,o=useRef({xDomain:e.xDomain,plotWidthPx:e.plotWidthPx,plotLeftPx:e.plotLeftPx??0});o.current={xDomain:e.xDomain,plotWidthPx:e.plotWidthPx,plotLeftPx:e.plotLeftPx??0};let n=useRef(e.onCommit);n.current=e.onCommit;let a=useRef(e.panBoundsMs);a.current=e.panBoundsMs;let i=useRef(e.getPanBoundsMs);i.current=e.getPanBoundsMs;let s=useRef(e.settleMs??140);s.current=e.settleMs??140;let l=useRef(e.zoomIntent??(F=>F.ctrlKey));l.current=e.zoomIntent??(F=>F.ctrlKey);let d=useRef(e.onGestureStart);d.current=e.onGestureStart;let c=useRef(e.onFramePreview);c.current=e.onFramePreview;let u=F=>F.button===0&&(F.shiftKey||F.ctrlKey||F.metaKey),m=useRef(e.selectIntent??u);m.current=e.selectIntent??u;let p=useRef(e.onSelectPreview);p.current=e.onSelectPreview;let g=useRef(null),f=useRef(null),b=useRef({scale:1,cursorFrac:.5,panDxPx:0,timer:null}),h=useRef(null),v=useRef(null),x=useRef(false),C=useCallback((F,z,U)=>{v.current={translateX:F,scaleX:z,preview:U},h.current==null&&(h.current=E2(()=>{h.current=null;let K=v.current;if(K!=null){let O=`translate(${K.translateX},0) scale(${K.scaleX},1)`;t.current?.setAttribute("transform",O),r?.current?.setAttribute("transform",O),c.current?.(K.preview);}}));},[t,r]),S=useCallback(()=>{h.current!=null&&(L2(h.current),h.current=null),v.current=null,t.current?.removeAttribute("transform"),r?.current?.removeAttribute("transform"),c.current?.(null);},[t,r]),w=useCallback(()=>{x.current||(x.current=true,d.current?.());},[]),T=useCallback(()=>{x.current=false;},[]),N=useCallback(()=>{b.current.timer!=null&&(clearTimeout(b.current.timer),b.current.timer=null);},[]),k=useCallback(()=>{b.current={scale:1,cursorFrac:.5,panDxPx:0,timer:null};},[]),R=useCallback(()=>{let{xDomain:F,plotWidthPx:z}=o.current,{scale:U,cursorFrac:K,panDxPx:O}=b.current;U===1&&O===0||n.current(Rm(Jx(F,U,K,O,z),i.current?.()??a.current));},[]),A=useCallback(()=>{b.current.timer!=null&&(N(),R(),k(),S());},[N,R,k,S]),M=useCallback(F=>{if(A(),F.currentTarget.setPointerCapture?.(F.pointerId),p.current&&m.current(F)){let z=F.currentTarget.getBoundingClientRect().left,U=F.clientX-z;f.current={startX:U,currentX:U,leftPx:z},p.current?.([0,0]),w();return}g.current={startX:F.clientX,dxPx:0},w();},[A,w]),B=useCallback(F=>{if(f.current){f.current.currentX=F.clientX-f.current.leftPx;let K=Math.max(1,o.current.plotWidthPx),O=Math.min(1,Math.max(0,f.current.startX/K)),V=Math.min(1,Math.max(0,f.current.currentX/K));p.current?.(O<=V?[O,V]:[V,O]);return}if(!g.current)return;g.current.dxPx=F.clientX-g.current.startX;let{xDomain:z,plotWidthPx:U}=o.current;C(g.current.dxPx,1,Bc(z,g.current.dxPx,U));},[C]),D=8,W=useCallback(F=>{if(f.current){let{startX:U,currentX:K}=f.current;if(f.current=null,p.current?.(null),T(),Math.abs(K-U)<D)return;let{xDomain:O,plotWidthPx:V}=o.current,L=Math.max(1,V),y=O[1]-O[0],E=$=>O[0]+Math.min(1,Math.max(0,$/L))*y,P=E(Math.min(U,K)),Y=E(Math.max(U,K));n.current(Rm([P,Y],i.current?.()??a.current));return}if(!g.current)return;let{dxPx:z}=g.current;g.current=null,S(),T(),z!==0&&n.current(Rm(Bc(o.current.xDomain,z,o.current.plotWidthPx),i.current?.()??a.current));},[S,T]),X=useCallback(()=>{if(f.current){f.current=null,p.current?.(null),T();return}g.current&&(g.current=null,S(),T());},[S,T]),H=useRef(null),I=useCallback(F=>{if(H.current?.(),H.current=null,!F)return;let z=U=>{if(g.current)return;let{plotWidthPx:K,plotLeftPx:O}=o.current,V=Pm(U.deltaY,U.deltaMode),L=Pm(U.deltaX,U.deltaMode),y=l.current(U);if(!y&&L===0)return;if(U.preventDefault(),w(),y){let $=Math.min(1,Math.max(0,(U.clientX-F.getBoundingClientRect().left)/Math.max(1,K)));b.current.scale*=Math.exp(-V/200),b.current.cursorFrac=$;}else b.current.panDxPx-=L;let{scale:E,cursorFrac:P,panDxPx:Y}=b.current;C((O+P*K)*(1-E)+Y,E,Jx(o.current.xDomain,E,P,Y,K)),N(),b.current.timer=setTimeout(()=>{R(),k(),S(),T();},s.current);};F.addEventListener("wheel",z,{passive:false}),H.current=()=>F.removeEventListener("wheel",z);},[C,S,N,R,k,w,T]);return useEffect(()=>()=>{H.current?.(),H.current=null,S(),b.current.timer!=null&&clearTimeout(b.current.timer);},[S]),{onPointerDown:M,onPointerMove:B,onPointerUp:W,onPointerCancel:X,wheelTargetRef:I,gestureActiveRef:x}}var Ta=({data:e,color:t="var(--color-viz-default)",strokeWidth:r=3,strokeDasharray:o,categoryColors:n={},maxGapMs:a,animate:i=true})=>{let{xScale:s,yScale:l,animationSettings:d,entrance:c}=ba(),[u]=ot__default.useState(()=>c?.played!==true),m=i&&u,p=l.range(),g=Object.keys(n).length>0,f=T=>T.category?n[T.category]??t:t,b=T=>T.chartYValue??T.yValue,h=e??[],v=h.length===1?h[0]:void 0,x=a!=null?uc(h,a):h,C=i?void 0:"non-scaling-stroke",S=v?jsx("circle",{cx:s(v.xValue),cy:l(b(v)),r,fill:g?f(v):t}):g?h.slice(0,-1).map((T,N)=>{let k=h[N+1];return a!=null&&a>0&&k.xValue.getTime()-T.xValue.getTime()>a?null:jsx(LinePath,{data:[T,k],x:R=>s(R.xValue),y:R=>l(b(R)),stroke:f(T),strokeWidth:r,strokeDasharray:o,strokeLinecap:"round",vectorEffect:C,curve:curveLinear},`${T.xValue.getTime()}-${k.xValue.getTime()}`)}):jsx(LinePath,{data:x,x:T=>T?s(T.xValue):0,y:T=>T?l(b(T)):0,defined:T=>T!=null,stroke:t,strokeWidth:r,strokeDasharray:o,strokeLinecap:"round",vectorEffect:C,curve:curveLinear}),w={transformOrigin:`0 ${p[0]}px`,transformBox:"fill-box",isolation:"isolate"};return m?jsx(motion.g,{initial:{scaleY:0},animate:{scaleY:1},transition:{duration:d.duration,ease:d.ease},style:w,children:S}):jsx("g",{style:w,children:S})};var _x=forwardRef(function({leftPx:t,topPx:r,widthPx:o,heightPx:n},a){let i=useRef(null),s=useRef(null),l=useRef(null),d=useRef(null);return useImperativeHandle(a,()=>({setRange:c=>{let u=i.current;if(!u)return;if(!c||c[1]-c[0]<=0){u.setAttribute("opacity","0");return}u.setAttribute("opacity","1");let m=t+c[0]*o,p=t+c[1]*o;s.current?.setAttribute("x",String(m)),s.current?.setAttribute("width",String(p-m)),l.current?.setAttribute("x1",String(m)),l.current?.setAttribute("x2",String(m)),d.current?.setAttribute("x1",String(p)),d.current?.setAttribute("x2",String(p));}})),jsxs("g",{ref:i,opacity:0,pointerEvents:"none",children:[jsx("rect",{ref:s,x:t,y:r,width:0,height:n,fill:"var(--color-viz-categorical-1)",fillOpacity:.12}),[l,d].map((c,u)=>jsx("line",{ref:c,x1:t,x2:t,y1:r,y2:r+n,stroke:"var(--color-viz-categorical-1)",strokeOpacity:.9,strokeWidth:1,strokeDasharray:"4 3"},u))]})});var ty=e=>e.type===Wn||e.type===Ta,W2=({children:e,title:t,hideExport:r=false,hiddenSeriesLabels:o,onLegendItemToggle:n,legend:a,xMarkers:i,headerActions:s,headerControls:l,viewport:d,panBounds:c,getPanBounds:u,onViewportChange:m,onPlotWidthChange:p,yFormatter:g={type:"number"},yDomain:f,referenceLines:b,cameraSync:h,parentWidth:v=0,parentHeight:x=0})=>{let[C,S]=useState(null),w=useRef(null),T=useRef(0),N=useId(),k=useRef(null),R=useRef(null),A=useRef(null),{colorMode:M}=hr(),B=useMemo(()=>tn(),[M]),D=useMemo(()=>$i(),[M]),{datasets:W,seriesMetadata:X,seriesTypes:H}=useMemo(()=>{let Z=cn(e).filter(Tt=>isValidElement(Tt)&&ty(Tt)),le=Z.filter(Tt=>Tt.props.data).length,Ae=[],Oe=[],it=[];return Z.forEach((Tt,Ot)=>{let tt=Tt.props;if(!tt.data)return;let xr="label"in tt&&tt.label||`Series ${Ae.length+1}`;Ae.push(o?.has(xr)?[]:tt.data);let xo=("color"in tt&&tt.color?tt.color:void 0)||(le===1?D:B[Ot%B.length]),ne=Tt.type===Wn;Oe.push({label:xr,color:xo,maxGapMs:tt.maxGapMs,...ne&&"baseline"in tt&&tt.baseline!==void 0?{baseline:tt.baseline,tooltipRange:"tooltipRange"in tt&&tt.tooltipRange||false}:{}}),it.push(ne?"area":"line");}),{datasets:Ae,seriesMetadata:Oe,seriesTypes:it}},[e,D,B,o]),I=va(t),F=I.expandedSize?.width??v,z=s||I.action?jsxs(Fragment,{children:[s,I.action]}):void 0,{headerRef:U,headerHeight:K}=ci(!!z,!!l),{ref:O,height:V}=Bl(),L=Math.max(100,(I.expandedSize?.height??x)-K-(V||50)),y=useMemo(()=>[new Date(d.startMs),new Date(d.endMs)],[d.startMs,d.endMs]),E=useMemo(()=>{let Z=W.flat(),le=W.flatMap((Ae,Oe)=>Ae.filter((it,Tt)=>{let Ot=it.xValue.getTime();if(Ot>=d.startMs&&Ot<=d.endMs)return true;if(typeof f!="function")return false;let tt=Ot<d.startMs?Ae[Tt+1]:Ae[Tt-1];if(!tt)return false;let xr=tt.xValue.getTime(),gr=X[Oe].maxGapMs;return gr!=null&&gr>0&&Math.abs(xr-Ot)>gr?false:Ot<d.startMs?xr>d.startMs:xr<d.endMs}));return le.length>0?le:Z},[W,X,d.startMs,d.endMs,f]),P=useMemo(()=>{let Z=typeof f=="function"?f(E):f,le=ys(E,L,g,Z);if(!f){let[Ae,Oe]=le.domain();Oe>Ae&&le.domain([Ae,Oe+(Oe-Ae)*.05]);}return le},[E,L,g,f]),Y=useRef(JSON.stringify(g)),$=useRef(null),oe=useMemo(()=>{let[Z,le]=P.domain(),Ae=Math.max(Math.abs(Z),Math.abs(le)),Oe=JSON.stringify(g);if(Oe!==Y.current&&(Y.current=Oe,$.current=null),$.current!==null)return $.current;if(Ae===0)return Si(g,0);let it=Si(g,Ae);return $.current=it,it},[P,g]),re=useMemo(()=>{let Z=L-je.top-je.bottom;return ya(Z)},[L]),_=useMemo(()=>{let Z=zr(oe),le=Z.tickFormat||Z.format,Oe=P.ticks(re).map(Ot=>le(Ot)),it=sn(Oe,12,"system-ui"),Tt=Math.ceil(it)+12;return {...je,left:Math.max(Tt,30),bottom:30}},[P,oe,re]),he=useMemo(()=>scaleTime({domain:y,range:[_.left,F-_.right]}),[y,F,_]),me=useMemo(()=>[d.startMs,d.endMs],[d.startMs,d.endMs]),ue=useMemo(()=>c?[c.startMs,c.endMs]:void 0,[c]),ie=useCallback(Z=>{m({startMs:Z[0],endMs:Z[1]});},[m]),fe=F-_.left-_.right,Te=useCallback(()=>S(null),[]),Ye=useRef({}),yt=useRef(h);yt.current=h;let Qt=useCallback(Z=>{R.current?.setPreview(Z),A.current?.setPreview(Z),yt.current?.publish(Ye.current,Z);},[]),Ze=useRef(null),fr=useRef(null),lr=useCallback(Z=>{fr.current?.setRange(Z);},[]),{onPointerDown:Ce,onPointerMove:Vt,onPointerUp:ee,onPointerCancel:Be,wheelTargetRef:Ve,gestureActiveRef:nt}=jx({onSelectPreview:lr,overlayRef:Ze,xDomain:me,plotWidthPx:fe,plotLeftPx:_.left,groupRef:k,onCommit:ie,onGestureStart:Te,onFramePreview:Qt,...ue?{panBoundsMs:ue}:{},...u?{getPanBoundsMs:()=>{let Z=u();return [Z.startMs,Z.endMs]}}:{}}),wt=useRef({startMs:d.startMs,endMs:d.endMs,left:0,width:0});wt.current={startMs:d.startMs,endMs:d.endMs,left:_.left,width:fe},useEffect(()=>{if(!h)return;let Z=()=>{k.current?.removeAttribute("transform"),R.current?.setPreview(null),A.current?.setPreview(null);},le=Oe=>{if(nt.current)return;if(Oe==null){Z();return}let{startMs:it,endMs:Tt,left:Ot,width:tt}=wt.current,xr=Tt-it,gr=Oe[1]-Oe[0];if(xr<=0||gr<=0||tt<=0)return;let xo=xr/gr,ne=Ot*(1-xo)+(it-Oe[0])*tt/gr;k.current?.setAttribute("transform",`translate(${ne},0) scale(${xo},1)`),R.current?.setPreview(Oe),A.current?.setPreview(Oe);},Ae=h.subscribe(Ye.current,le);return ()=>{Ae(),nt.current||Z();}},[h,nt]),useEffect(()=>{p?.(Math.max(0,F-_.left-_.right));},[F,_,p]);let Xt=useCallback(Z=>{if(nt.current)return;let{left:le}=w.current?.getBoundingClientRect()||{left:0},Ae=Z.clientX-le;Z.timeStamp-(T.current||0)<16||(T.current=Z.timeStamp,S(Gx({mouseX:Ae,datasets:W,seriesMetadata:X,seriesTypes:H,xScale:he,yScale:P,plotLeft:_.left,plotRight:F-_.right})));},[W,X,H,he,P,F,_,nt]),Q=useCallback(()=>S(null),[]),j=dc(),pe={width:F,height:L,xScale:he,yScale:P,yFormatter:oe,animationSettings:cc,entrance:j,tooltip:{data:C,show:S,hide:()=>S(null)},datasets:W,seriesMetadata:X,seriesTypes:H},ae=0,Ne=[];cn(e).forEach(Z=>{if(!isValidElement(Z)){Ne.push(Z);return}if(ty(Z)){let le=ae;ae++;let Ae=Z.props;Ne.push(ot__default.cloneElement(Z,{...Ae,...X[le]&&o?.has(X[le].label)?{data:[]}:{},color:X[le]?.color,animate:false}));}else Ne.push(Z);});let Qe=a??X.map(Z=>({category:Z.label,fill:Z.color,isHidden:o?.has(Z.label)??false})),Ue=vc({datasets:W,metadata:{xLabel:"Date",yLabel:"Value",seriesLabels:X.map(Z=>Z.label),timestamp:true},svgRef:w}),cr=jsxs(Fragment,{children:[jsx("title",{children:t}),jsx("g",{children:P.ticks(re).map(Z=>{let le=Math.abs(Z)<Number.EPSILON;return jsx(Line,{from:{x:_.left,y:P(Z)},to:{x:F-_.right,y:P(Z)},stroke:le?"var(--color-border-default)":"var(--color-border-muted)",strokeWidth:le?1.5:1},`grid-line-${Z}`)})}),jsx(km,{ref:A,scale:he,width:F-_.left-_.right,top:P.range()[1],bottom:P.range()[0]}),jsx("defs",{children:jsx("clipPath",{id:N,children:jsx("rect",{x:he.range()[0],y:P.range()[1],width:he.range()[1]-he.range()[0],height:P.range()[0]-P.range()[1]})})}),jsx("g",{clipPath:`url(#${N})`,children:jsx("g",{"data-camera-plot-group":"",ref:k,children:Ne})}),b&&b.length>0&&jsx("g",{children:b.map((Z,le)=>{let Ae=P(Z.value),Oe=Z.color??"var(--color-error-base)";return jsxs("g",{children:[jsx(Line,{from:{x:_.left,y:Ae},to:{x:F-_.right,y:Ae},stroke:Oe,strokeWidth:1.5,strokeDasharray:"6 4"}),Z.label&&jsx("text",{x:F-_.right-4,y:Ae-4,textAnchor:"end",fontSize:11,fill:Oe,children:Z.label})]},`ref-line-${le}`)})}),jsx(Nm,{ref:R,top:L-_.bottom,scale:he,width:F-_.left-_.right}),jsx(uo.Left,{left:_.left,scale:P,yFormatter:oe,height:L-_.top-_.bottom}),C&&!C.isEvent&&jsxs(Fragment,{children:[jsx(Line,{"data-testid":"chart-hover-crosshair",from:{x:he(C.xValue),y:P.range()[1]},to:{x:he(C.xValue),y:P.range()[0]},stroke:"var(--color-text-secondary)",strokeWidth:1,strokeDasharray:"3 3",opacity:.7}),C.series.filter(Z=>Z.type!=="bar"&&Z.showMarker!==false).map(Z=>jsxs("g",{children:[jsx("circle",{cx:he(C.xValue),cy:P(Z.chartY??Z.value),r:8,fill:"white",stroke:Z.color,strokeWidth:2,style:{transition:"all 100ms ease-out"}}),jsx("circle",{cx:he(C.xValue),cy:P(Z.chartY??Z.value),r:4,fill:Z.color,style:{transition:"all 100ms ease-out"}})]},`highlight-${Z.label}`))]}),jsx("rect",{"data-camera-surface":"",x:_.left,y:_.top,width:F-_.left-_.right,height:L-_.top-_.bottom,fill:"transparent",style:{cursor:"grab",touchAction:"none"},onMouseMove:Xt,onMouseLeave:Q,onPointerDown:Ce,onPointerMove:Vt,onPointerUp:ee,onPointerCancel:Be,onContextMenu:Z=>{(Z.ctrlKey||Z.metaKey)&&Z.preventDefault();},ref:Ve}),jsx("g",{ref:Ze,children:i?.map(Z=>{let le=he(new Date(Z.timeMs));if(!Number.isFinite(le)||le<_.left||le>F-_.right)return null;let Ae=Z.color??"var(--color-error-base)",Oe=()=>{Z.point&&S({xValue:new Date(Z.timeMs),series:[{label:Z.point.label,value:Z.point.value,color:Ae,showMarker:false}],x:le,y:P(Z.point.value),position:le>(_.left+(F-_.right))/2?"left":"right"});};return jsxs("g",{children:[jsx("line",{x1:le,x2:le,y1:_.top,y2:L-_.bottom,stroke:"transparent",strokeWidth:7,onMouseMove:Z.point?Oe:Xt,onMouseLeave:Q}),jsx("line",{x1:le,x2:le,y1:_.top,y2:L-_.bottom,stroke:Ae,strokeWidth:1,strokeOpacity:.75,vectorEffect:"non-scaling-stroke",pointerEvents:"none"})]},`${Z.timeMs}:${Z.label}`)})}),jsx(_x,{ref:fr,leftPx:_.left,topPx:_.top,widthPx:F-_.left-_.right,heightPx:L-_.top-_.bottom})]});return I.present(jsx("div",{className:"relative flex h-full flex-col",children:jsxs(co.Provider,{value:pe,children:[jsx(di,{title:t,controls:l,actions:z,containerRef:U}),jsx("svg",{width:F,height:L,className:"overflow-visible",ref:w,role:"img","aria-label":t,children:cr}),jsx(Ho,{data:C,formatter:oe}),jsx("div",{ref:O,children:jsx(Ti,{onExport:Ue,items:Qe,hideExport:r,marginLeft:12,marginRight:12,...n&&{onLegendItemToggle:n}})})]})}))},Ms=withParentSize(W2);var K2={single:[],band:["net"],pair:["import","export"]};function Y2({kind:e,series:t,seriesKeys:r}){let o=r??K2[e];return e==="single"?[t.line]:e==="band"?[...o.map(n=>t.lines[n]??[]),t.band.filter(n=>Number.isFinite(n.baselineValue))]:o.map(n=>t.lines[n]??[])}function X2(e){let{viewport:t,maxDataTimeMs:r}=e,o=null;for(let n of Y2(e))for(let a of n){let i=a.xValue.getTime();Number.isFinite(i)&&Number.isFinite(a.yValue)&&i>=t.startMs&&i<t.endMs&&i<=r&&(o===null||i>o)&&(o=i);}return o}function ry(e){let t=useId(),r=X2(e),o=r===null?null:new Date(r);return jsxs("span",{className:"inline-flex max-w-full flex-wrap items-baseline gap-x-1","aria-describedby":t,title:"Time marks the start of the latest interval with data plotted in this view.",children:[jsx("span",{children:"Latest data in view:"}),o?jsx("time",{dateTime:o.toISOString(),className:"font-medium text-text-primary",children:o.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"})}):jsx("span",{className:"font-medium text-text-primary",children:"Unavailable"}),jsx("span",{id:t,className:"sr-only",children:"Time marks the start of the latest interval with data plotted in this view."})]})}var q2={live:"Receiving updates",connecting:"Waiting for next update",reconnecting:"Reconnecting\u2026",stale:"No recent updates",delayed:"Measurements delayed","refresh-failed":"Update delayed"};function ny({label:e,checked:t,onChange:r,status:o,disabledReason:n,waitingDescription:a}){let i=useId(),s=t&&o==="live",l=n||(t?q2[o]:void 0);return jsxs("div",{className:"flex max-w-full shrink-0 flex-col items-end gap-1",children:[jsxs(te,{variant:"ghost",size:"sm","aria-label":e,"aria-pressed":t,...l&&{"aria-describedby":i},isDisabled:!!n,onPress:()=>r(!t),className:t?"text-text-primary":"text-text-secondary",children:[jsx("span",{"aria-hidden":"true","data-live-indicator":s?"live":"neutral",className:`size-1.5 shrink-0 rounded-full ${s?"bg-error-base":"bg-text-secondary"}`}),jsx("span",{children:t?"Live":"Static"})]}),jsxs("span",{id:i,role:"status","aria-atomic":"true",className:"max-w-64 text-right text-xs text-text-secondary",children:[l,!n&&t&&o==="connecting"&&a&&jsxs(Fragment,{children:[". ",a]})]})]})}var $2=1440*60*1e3,Dm=6e4,ay=(e,t)=>({startMs:t-e*$2,endMs:t}),eM=e=>({after:new Date(e.startMs),before:new Date(e.endMs)});function Gc({source:e,hideExport:t=false,hideWindowSummary:r=false,leadingControls:o,trailingControls:n,xMarkers:a,legend:i,hiddenSeriesLabels:s,onLegendItemToggle:l,title:d,liveControl:c,initialRange:u,viewportEnd:m,yFormatter:p,yDomain:g,referenceLines:f,emptyState:b,presetRanges:h,tierToWindow:v,windowSizeOptions:x,height:C=360,fitParent:S=false,hint:w,dataBounds:T,onViewChange:N,followLatest:k=false,followLatestKey:R,children:A,latestDataReadout:M,latestDataSeriesKeys:B,renderMetadata:D,panels:W}){let X=W!==void 0&&W.length>0,H=useMemo(()=>X?Ic():void 0,[X]),[I,F]=useState(900),z=e.refreshEnabled!==false,U=T?.endMs,[K,O]=useState(()=>U??Date.now()),V=m?.getTime()??U,L=k&&m===void 0&&T===void 0,[y,E]=useState(true),[P,Y]=useState(null),$=L&&y,[oe,re]=useState({resetKey:e.resetKey,automatic:false}),_=m===void 0&&T===void 0&&y,he=u?.days??30,me=useMemo(()=>ay(he,V??Date.now()),[he,V]),ue=useRef({resetKey:e.resetKey,refreshKey:e.refreshKey,refreshEnabled:z,followLatestKey:R}),ie=z&&(ue.current.resetKey!==e.resetKey||ue.current.refreshKey!==e.refreshKey||ue.current.refreshEnabled===false),fe=ue.current.resetKey===e.resetKey,Te=L&&ue.current.followLatestKey!==R,Ye=U??(ie||Te?Date.now():K);useEffect(()=>{ue.current={resetKey:e.resetKey,refreshKey:e.refreshKey,refreshEnabled:z,followLatestKey:R},(ie||Te)&&(fe&&re({resetKey:e.resetKey,automatic:true}),O(Ye));},[e.resetKey,e.refreshKey,z,R,ie,Te,Ye,fe]);let[yt,Qt]=useState(null),[Ze,fr]=useState(null),lr=yt??me,Ce=ym({fetchTile:e.fetchTile,ladder:e.ladder,nativeMs:e.nativeMs,initialViewport:me,widthPx:I,maxFutureMs:Ye,tileCostSeriesCount:e.tileCostSeriesCount,resetKey:e.resetKey,...e.refreshKey!==void 0&&{refreshKey:e.refreshKey},refreshEnabled:z&&P===null,automaticLoads:($||Te)&&(oe.resetKey===e.resetKey&&oe.automatic||fe&&(ie||Te))}),Vt=Ce.series.targetTier.bucketMs,ee=L?(Math.floor(Ye/Vt)+1)*Vt:Ye,Be=V==null?Math.max(ee,Ce.viewport.endMs):ee,Ve=useMemo(()=>({startMs:T?.startMs??0,endMs:Be}),[T?.startMs,Be]),nt=Le=>{let J=V==null?Math.max(Ve.endMs,Date.now()):Ve.endMs,se=Math.min(Le.endMs-Le.startMs,J-Ve.startMs),Pe=Math.max(Math.min(Le.endMs,J),Ve.startMs+se);return {startMs:Pe-se,endMs:Pe}},wt=(Le,J=true)=>{re({resetKey:e.resetKey,automatic:false});let se=Math.abs(Ve.endMs-Le)<=Dm||Math.abs(Date.now()-Le)<=Dm,Pe=J&&se;z&&Y(""),E(Pe),U==null&&O(Date.now());};useEffect(()=>{if(U!=null){O(U);return}if(!z)return;let Le,J=(Pe=true)=>{let Re=Date.now();Pe&&$&&re({resetKey:e.resetKey,automatic:true}),O(Re);let He=Vt-Re%Vt;Le=setTimeout(J,Math.min(Dm,He));},se=()=>{document.visibilityState==="visible"&&(clearTimeout(Le),J());};return J(false),document.addEventListener("visibilitychange",se),()=>{clearTimeout(Le),document.removeEventListener("visibilitychange",se);}},[U,Vt,z,$,e.resetKey]);let Xt=useRef(R);useEffect(()=>{let Le=Xt.current!==R;Xt.current=R,!(!Le||!L)&&(E(true),O(Date.now()));},[L,R]),useEffect(()=>{$&&z&&O(Date.now());},[$,z,e.resetKey,e.refreshKey]);let Q=Ce.jumpTo,{startMs:j,endMs:pe}=Ce.viewport;useEffect(()=>{if(!$)return;let Le=Math.max(pe-j,Vt);ee===pe&&Le===pe-j||(re({resetKey:e.resetKey,automatic:true}),Q({startMs:ee-Le,endMs:ee}));},[$,ee,j,pe,Vt,Q,e.resetKey]);let ae=useMemo(()=>Mc(()=>V??Date.now()),[V]),Ne=h??ae,Qe=()=>{if(Ze&&"presetId"in Ze){let Le=Ne.find(J=>J.id===Ze.presetId);if(Le){let J=Le.getRange();return {startMs:J.after.getTime(),endMs:J.before.getTime()}}}return Ze&&"range"in Ze?Ze.range:ay(he,V??Date.now())},{coverage:Ue,renderTier:cr,targetTier:Z,isFallback:le,isStale:Ae}=Ce.series,Oe=Z.id,it=cr?.id??null,{startMs:Tt,endMs:Ot}=Ce.viewport,tt=useRef(N);useEffect(()=>{tt.current=N;},[N]),useEffect(()=>{tt.current?.({targetTierId:Oe,renderedTierId:it,viewport:{startMs:Tt,endMs:Ot},followingLatest:$,atLiveEdge:_});},[Oe,it,Tt,Ot,$,_]),useEffect(()=>{if(P===null)return;let Le=`${Oe}:${Tt}:${Ot}`;Y(P===Le?null:Le);},[P,Oe,Tt,Ot]);let xr=cr?cr.bucketMs*1.5:0,gr=Le=>Le==null?"\u2014":new Date(Le).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),xo=(Le,J)=>{let se=J-Le<1728e5?{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}:{month:"short",day:"numeric",year:"numeric"},Pe=new Intl.DateTimeFormat("en-US",se);return `${Pe.format(new Date(Le))} \u2013 ${Pe.format(new Date(J))}`},ne=$?Ce.viewport.endMs-Ce.viewport.startMs!==lr.endMs-lr.startMs:Ce.viewport.startMs!==lr.startMs||Ce.viewport.endMs!==lr.endMs,Se=Ae||Ce.loading&&Ue.earliestMs==null,ce=(Ce.viewport.endMs-Ce.viewport.startMs)*.03,ct=!Se&&Ue.earliestMs!=null&&Ue.earliestMs>Ce.viewport.startMs+ce,yr=!Ce.loading&&Ue.earliestMs==null&&Ue.latestMs==null&&!Ca(Ce.series)&&!Ae,yo=va(d),vo=Fl(),yl=typeof a=="function"?a(Ce.series):a,Nu=sy(A({series:Ce.series,gapMs:xr})),Zi=jsxs("div",{className:`flex flex-col gap-3${yo.isExpanded||S?" h-full":""}`,children:[o&&jsx("div",{className:"flex flex-wrap items-center gap-3",children:o}),jsxs("div",{className:"flex flex-wrap items-start gap-2",children:[jsx("div",{className:"min-w-0 flex-[1_1_16rem]",children:jsx(Dc,{dateRange:eM(Ce.viewport),onDateRangeChange:(Le,J)=>{let se=nt({startMs:Le.after.getTime(),endMs:Le.before.getTime()});wt(se.endMs,!!J?.presetId),fr(J?.presetId?{presetId:J.presetId}:{range:se}),Qt(se),Ce.jumpTo(se);},windowSize:v[Z.id],windowSizeOptions:x,lockWindowSize:true,presetRanges:Ne,allowDatePicker:true,showReset:false})}),jsxs("div",{className:"ml-auto flex max-w-full flex-wrap items-start gap-2",children:[c&&jsx(ny,{...c,status:Ce.refreshError?"refresh-failed":c.status}),w&&!yr&&jsx(Ac,{label:`About ${d}`,children:w}),!yo.isExpanded&&!yr&&yo.action]})]}),jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-text-secondary",children:[!r&&jsxs(Fragment,{children:[jsxs("span",{children:["Window"," ",jsx("span",{className:"font-medium text-text-primary",children:xo(Ce.viewport.startMs,Ce.viewport.endMs)})]}),jsx("span",{className:"text-text-tertiary",children:"\u2022"}),jsxs("span",{children:["Resolution ",jsx("span",{className:"font-medium text-text-primary",children:cr?.id??Z.id}),le&&jsxs("span",{className:"text-text-tertiary",children:[" \xB7 loading ",Z.id]})]})]}),M&&jsx(ry,{kind:M,series:Ce.series,viewport:Ce.viewport,maxDataTimeMs:Ye,...B!==void 0?{seriesKeys:B}:{}}),D?.({series:Ce.series,viewport:Ce.viewport,maxDataTimeMs:Ye}),Ce.loading&&jsx("span",{className:"text-text-tertiary",children:"loading\u2026"}),Ce.refreshError&&jsx("span",{role:"status",className:"text-text-tertiary",children:Ue.earliestMs==null?"Unable to load telemetry":"Refresh failed \xB7 showing previous data"}),ct&&jsxs("span",{className:"text-text-tertiary",children:["showing available history from ",gr(Ue.earliestMs)]}),!r&&!ct&&!Se&&Ce.atDataStart&&jsx("span",{className:"text-text-tertiary",children:"no earlier data loaded"})]}),X&&!vo&&jsx("span",{className:"text-[11px] font-medium text-text-secondary",children:d}),jsxs("div",{className:`relative overflow-hidden rounded-md border border-border-subtle${yo.isExpanded||S?" min-h-0 flex-1":""}`,style:yo.isExpanded||S?void 0:{height:C},children:[ne&&!yr&&jsx("div",{className:"absolute top-2 right-2 z-10",children:jsx(te,{variant:"secondary",size:"sm",onPress:()=>{let Le=nt(Qe());wt(Le.endMs,!(Ze&&"range"in Ze)),Qt(Le),Ce.jumpTo(Le);},children:"\u27F2 Reset"})}),yr?jsx(ki,{title:b.title,description:b.description}):jsxs(Fragment,{children:[jsx(Ms,{title:d,hideExport:t,viewport:Ce.viewport,panBounds:Ve,getPanBounds:()=>({startMs:Ve.startMs,endMs:U??Math.max(Ve.endMs,Date.now())}),onViewportChange:Le=>{wt(Le.endMs),Ce.onViewportChange(Le);},onPlotWidthChange:F,...H&&{cameraSync:H},...p&&{yFormatter:p},...g&&{yDomain:g},...f&&{referenceLines:f},...yl?.length&&{xMarkers:yl},...i&&{legend:i},...s&&{hiddenSeriesLabels:s},...l&&{onLegendItemToggle:l},children:Nu}),Ce.loading&&jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 animate-pulse bg-[var(--color-viz-categorical-1)] opacity-60"})]})]}),X&&W.map(Le=>jsx(tM,{panel:Le,hideExport:Le.hideExport??t,viewport:Ce.viewport,panBounds:Ve,staticEndMs:U,maxFutureMs:Ye,widthPx:I,onViewportChange:J=>{wt(J.endMs),Ce.onViewportChange(J);},...H&&{cameraSync:H}},Le.key)),n&&jsx("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-1",children:jsx("div",{className:"ml-auto flex flex-wrap items-center gap-x-4 gap-y-1",children:n})})]});return jsx(fm,{children:yo.present(Zi)})}function sy(e){return isValidElement(e)&&e.type===Fragment$1?e.props.children:e}function tM({panel:e,hideExport:t,viewport:r,panBounds:o,staticEndMs:n,maxFutureMs:a,widthPx:i,onViewportChange:s,cameraSync:l}){let d=Rc({fetchTile:e.source.fetchTile,ladder:e.source.ladder,nativeMs:e.source.nativeMs,viewport:r,widthPx:i,maxFutureMs:a,resetKey:e.source.resetKey,tileCostSeriesCount:e.source.tileCostSeriesCount,...e.source.refreshKey!==void 0?{refreshKey:e.source.refreshKey}:{},...e.source.refreshEnabled!==void 0?{refreshEnabled:e.source.refreshEnabled}:{}}),c=d.series.renderTier?d.series.renderTier.bucketMs*1.5:0;return jsxs("div",{className:"flex flex-col gap-1",children:[jsx("span",{className:"text-[11px] font-medium text-text-secondary",children:e.title}),jsxs("div",{className:"relative overflow-hidden rounded-md border border-border-subtle",style:{height:e.height??220},children:[jsx(Ms,{title:e.title,hideExport:t,viewport:r,panBounds:o,getPanBounds:()=>({startMs:o.startMs,endMs:n??Math.max(o.endMs,Date.now())}),onViewportChange:s,...l&&{cameraSync:l},...e.yFormatter&&{yFormatter:e.yFormatter},...e.yDomain&&{yDomain:e.yDomain},...e.referenceLines&&{referenceLines:e.referenceLines},...e.legend&&{legend:e.legend},...e.hiddenSeriesLabels&&{hiddenSeriesLabels:e.hiddenSeriesLabels},...e.onLegendItemToggle&&{onLegendItemToggle:e.onLegendItemToggle},children:sy(e.children({series:d.series,gapMs:c}))}),d.loading&&jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 animate-pulse bg-[var(--color-viz-categorical-1)] opacity-60"})]})]})}var aM=12;function ly(e){let t=Number.isFinite(e)?Math.max(1,Math.floor(e)):1,r=0,o=[],n=()=>{for(;o.length>0;){let i=o[0];if(r+i.permits>t)return;o.shift(),r+=i.permits,i.grant();}},a=i=>()=>{r=Math.max(0,r-i),n();};return {acquire(i=1){let s=Math.min(t,Number.isFinite(i)?Math.max(1,Math.floor(i)):1);return o.length===0&&r+s<=t?(r+=s,Promise.resolve(dy(a(s)))):new Promise(l=>{o.push({permits:s,grant:()=>l(dy(a(s)))});})},get stats(){return {active:r,waiting:o.length}}}}function cy(){let e=new Error("The operation was aborted.");return e.name="AbortError",e}function dy(e){let t=false;return ()=>{t||(t=true,e());}}var iM=()=>{},sM={acquire:()=>Promise.resolve(iM),stats:{active:0,waiting:0}},Am=createContext(null);function py({maxConcurrent:e,children:t}){let r=useContext(Am),o=useMemo(()=>e!==void 0?ly(e):r??ly(aM),[e,r]);return createElement(Am.Provider,{value:o},t)}function Im(){return useContext(Am)??sM}function Fm(e,t,r=1){return async(...o)=>{let n=o[3],a=()=>n instanceof AbortSignal&&n.aborted;if(a())throw cy();let i=await e.acquire(r);try{if(a())throw cy();return await t(...o)}finally{i();}}}var gy=createContext(null),hy=createContext(null);function by({resolve:e,host:t,maxConcurrentFetches:r,children:o}){return jsx(gy.Provider,{value:e??null,children:jsx(hy.Provider,{value:t??null,children:jsx(py,{...r!==void 0?{maxConcurrent:r}:{},children:o})})})}function Es(){return useContext(gy)}function Ls(){return useContext(hy)}var Cy="line";function dM(e,t){return t===Cy?e.line:t==="band"?e.band:e.lines[t]??[]}function Sy(e){let t=0;for(let r of e)typeof r?.bucketMs=="number"&&Number.isFinite(r.bucketMs)&&r.bucketMs>0&&(t=t===0?r.bucketMs:Math.min(t,r.bucketMs));return t}function Wc(e){let t=Ls();return t?jsx(t,{source:e.source,children:r=>r?jsx(wy,{...e,resolved:r}):jsx(xy,{...e})}):jsx(xy,{...e})}function wy(e){let t=e.panels;return !t||t.length===0?jsx(yy,{...e}):jsx(Ty,{panels:t,index:0,acc:[],render:r=>jsx(yy,{...e,resolvedPanels:r})})}function xy(e){let t=Es(),r=useMemo(()=>t?.(e.source)??null,[t,e.source]);return r?jsx(wy,{...e,resolved:r}):jsx(ki,{icon:"ChartLine",title:e.emptyState?.title??"No data source",description:e.emptyState?.description??"This chart's data source is unavailable."})}function yy({source:e,title:t,children:r,yFormatter:o,yDomain:n,referenceLines:a,headerActions:i,height:s,hint:l,emptyState:d,tierToWindow:c,windowSizeOptions:u,presetRanges:m,latestDataReadout:p,latestDataSeriesKeys:g,resolved:f,resolvedPanels:b=[]}){let h=kc(e.viewportEnd),v=Im(),C={fetchTile:useMemo(()=>Fm(v,f.fetchSlice,f.fetchesPerSlice??1),[v,f.fetchSlice,f.fetchesPerSlice]),ladder:e.ladder,...f.refreshEnabled!==void 0?{refreshEnabled:f.refreshEnabled}:{},nativeMs:f.nativeMs??e.nativeMs??Sy(e.ladder),resetKey:e.resetKey??"",...f.refreshKey!==void 0?{refreshKey:f.refreshKey}:e.refreshKey!==void 0?{refreshKey:e.refreshKey}:{},tileCostSeriesCount:f.costSeriesCount??1};return jsx(Gc,{title:t,source:C,yFormatter:o,...n!==void 0?{yDomain:n}:{},...a!==void 0?{referenceLines:a}:{},...i!==void 0?{headerActions:i}:{},...s!==void 0?{height:s}:{fitParent:true},...f.liveControl!==void 0?{liveControl:f.liveControl}:{},...f.onViewChange!==void 0?{onViewChange:f.onViewChange}:{},...f.followLatest!==void 0?{followLatest:f.followLatest}:{},...f.followLatestKey!==void 0?{followLatestKey:f.followLatestKey}:{},...l!==void 0?{hint:l}:{},...e.initialRange!==void 0?{initialRange:e.initialRange}:{},...h!==null?{viewportEnd:h}:{},...m!==void 0?{presetRanges:m}:{},...p!==void 0?{latestDataReadout:p}:{},...g!==void 0?{latestDataSeriesKeys:g}:{},emptyState:d??{title:"No data",description:"No readings in this window."},tierToWindow:c??{},windowSizeOptions:u??[],...b.length>0?{panels:b}:{},children:({series:S,gapMs:w})=>ky(r,S,w)})}function Ty({panels:e,index:t,acc:r,render:o}){if(t>=e.length)return jsx(Fragment,{children:o(r)});let n=e[t];return jsx(uM,{panel:n,children:a=>jsx(Ty,{panels:e,index:t+1,acc:a?[...r,a]:r,render:o})})}function uM({panel:e,children:t}){let r=Ls();return r?jsx(r,{source:e.source,children:o=>o?jsx(Ny,{panel:e,resolved:o,children:t}):jsx(vy,{panel:e,children:t})}):jsx(vy,{panel:e,children:t})}function vy({panel:e,children:t}){let r=Es(),o=useMemo(()=>r?.(e.source)??null,[r,e.source]);return o?jsx(Ny,{panel:e,resolved:o,children:t}):jsx(Fragment,{children:t(null)})}function Ny({panel:e,resolved:t,children:r}){let o=Im(),n=useMemo(()=>Fm(o,t.fetchSlice,t.fetchesPerSlice??1),[o,t.fetchSlice,t.fetchesPerSlice]),a=useMemo(()=>({key:e.key,title:e.title,source:{fetchTile:n,ladder:e.source.ladder,nativeMs:t.nativeMs??e.source.nativeMs??Sy(e.source.ladder),resetKey:e.source.resetKey??"",tileCostSeriesCount:t.costSeriesCount??1,...t.refreshEnabled!==void 0?{refreshEnabled:t.refreshEnabled}:{},...t.refreshKey!==void 0?{refreshKey:t.refreshKey}:e.source.refreshKey!==void 0?{refreshKey:e.source.refreshKey}:{}},...e.yFormatter!==void 0?{yFormatter:e.yFormatter}:{},...e.yDomain!==void 0?{yDomain:e.yDomain}:{},...e.referenceLines!==void 0?{referenceLines:e.referenceLines}:{},...e.height!==void 0?{height:e.height}:{},children:({series:i,gapMs:s})=>ky(e.children,i,s)}),[e,n,t.nativeMs,t.costSeriesCount,t.refreshEnabled,t.refreshKey]);return jsx(Fragment,{children:r(a)})}function ky(e,t,r){return cn(e).map(o=>{if(!isValidElement(o))return o;let n=o.props;if(n.data)return o;let a=dM(t,n.seriesKey??Cy);return cloneElement(o,{data:a,maxGapMs:r,...n.labelFromData?{label:n.labelFromData(a,t)}:{}})})}var My=e=>e.type===Wn||e.type===Ta||e.type===mc,xM=e=>e.type===Sc||e.type===wc,Ey=280,yM=bisector(e=>e.xValue).left,vM=()=>jsx("div",{className:"flex h-full items-center justify-center",children:jsx("p",{className:"text-text-secondary",children:"No data available"})}),CM=()=>jsxs("div",{className:"flex h-full flex-col gap-4 p-4",children:[jsx(q,{className:"h-full w-full"}),jsxs("div",{className:"flex gap-4",children:[jsx(q,{className:"h-4 w-24"}),jsx(q,{className:"h-4 w-24"})]})]}),SM=({parentWidth:e,parentHeight:t,yFormatter:r={type:"number"},yDomain:o,referenceLines:n,isLoading:a=false,enableZoom:i=false,enableBrush:s=false,brushHeight:l=60,onZoomChange:d,zoomDomain:c,hiddenSeriesLabels:u,onHiddenSeriesChange:m,hideBottomBar:p=false,headerActions:g,headerControls:f,title:b,children:h})=>{let v=u!==void 0,x=c!==void 0,[C,S]=useState(null),[w,T]=useState(null),N=x?c:w,[k,R]=useState(()=>new Set),A=v?u:k,M=useRef(null),B=useId(),D=useRef(0),W=useRef(""),X=useRef(null),{colorMode:H}=hr(),I=useMemo(()=>tn(),[H]),F=useMemo(()=>$i(),[H]),{datasets:z,seriesMetadata:U,categoryInfo:K,categoryColors:O,categoryLabels:V,seriesTypes:L}=useMemo(()=>{let se=cn(h).filter(Ge=>isValidElement(Ge)&&My(Ge)),Pe=se.filter(Ge=>Ge.props.data).length,Re=[],He=[],ut=[],Nt=null,ze=null;se.forEach((Ge,Mt)=>{let Ie=Ge.props;if(!Ie.data)return;Re.push(Ie.data);let $o=("color"in Ie&&Ie.color?Ie.color:void 0)||(Pe===1?F:I[Mt%I.length]),en=Ge.type===Wn;He.push({label:"label"in Ie&&Ie.label||`Series ${Re.length}`,color:$o,...en&&"baseline"in Ie&&Ie.baseline!==void 0?{baseline:Ie.baseline,tooltipRange:"tooltipRange"in Ie&&Ie.tooltipRange||false}:{}});let ra=en?"area":Ge.type===Ta?"line":"bar";ut.push(ra),"categoryColors"in Ie&&Ie.categoryColors&&(Nt=Ie.categoryColors),"categoryLabels"in Ie&&Ie.categoryLabels&&(ze=Ie.categoryLabels);});let vt=null;if(Nt){let Ge=new Set;Re.forEach(Mt=>{Mt.forEach(Ie=>{Ie.category&&Ge.add(Ie.category);});}),vt=Array.from(Ge).map(Mt=>({label:ze?.[Mt]||Mt,color:Nt[Mt]||"#6b7280"}));}return {datasets:Re,seriesMetadata:He,categoryInfo:vt,categoryColors:Nt,categoryLabels:ze,seriesTypes:ut}},[h,F,I,H]),y=va(b),E=y.expandedSize?.width??e,P=y.expandedSize?.height??t,$=!p?y.action:null,oe=g||$?jsxs(Fragment,{children:[g,$]}):void 0,{headerRef:re,headerHeight:_}=ci(!!oe,!!f),he=p?0:60,me=s?l+8:0,ue=P-_-he-me,ie=Math.max(100,ue),fe=useCallback(J=>J?A.has(J):false,[A]),Te=useMemo(()=>U.map((J,se)=>fe(J.label)?null:se).filter(J=>J!==null),[U,fe]),Ye=useMemo(()=>Te.map(J=>z[J]).filter(J=>!!J),[z,Te]),yt=useMemo(()=>Te.map(J=>U[J]).filter(J=>!!J),[U,Te]),Qt=useMemo(()=>Te.map(J=>L[J]).filter(J=>!!J),[L,Te]),Ze=Qt.findIndex(J=>J==="bar"),fr=Ze!==-1,lr=useCallback((J,se)=>{let Pe=J.has(se);if(!Pe&&U.reduce((ut,Nt)=>J.has(Nt.label)||Nt.label===se?ut:ut+1,0)<1)return J;let Re=new Set(J);return Pe?Re.delete(se):Re.add(se),Re},[U]),Ce=useCallback(J=>{if(v){let se=u;if(!se.has(J)&&U.reduce((He,ut)=>se.has(ut.label)||ut.label===J?He:He+1,0)<1){S(null);return}m?.(Re=>lr(Re,J));}else R(se=>lr(se,J));S(null);},[v,u,m,U,lr]),Vt=useMemo(()=>U.map(J=>J.label).join(""),[U]),ee=useRef(Vt);useEffect(()=>{ee.current!==Vt&&(ee.current=Vt,v||R(J=>J.size===0?J:new Set));},[Vt,v]);let Be=useMemo(()=>Ye.flat(),[Ye]),Ve=useMemo(()=>{if(Be.length===0)return null;let J=[...Be].sort((se,Pe)=>se.xValue.getTime()-Pe.xValue.getTime());return [J[0].xValue,J[J.length-1].xValue]},[Be]),wt=N||Ve,Xt=useCallback(J=>{x?d?.(J):T(J);},[x,d]),Q=useMemo(()=>wt?z.map(se=>se.filter(Pe=>Pe.xValue>=wt[0]&&Pe.xValue<=wt[1])):z,[z,wt]),j=useMemo(()=>Te.map(J=>Q[J]??[]),[Te,Q]);useEffect(()=>{d&&d(N);},[N,d]);let pe=useMemo(()=>Te.flatMap(J=>Q[J]??[]),[Q,Te]),ae=useMemo(()=>ys(pe,ie,r,o),[pe,ie,r,o]),Ne=useRef(JSON.stringify(r)),Qe=useRef(null),Ue=useMemo(()=>{let[J,se]=ae.domain(),Pe=Math.max(Math.abs(J),Math.abs(se)),Re=JSON.stringify(r);if(Re!==Ne.current&&(Ne.current=Re,Qe.current=null),Qe.current!==null)return Qe.current;if(Pe===0)return Si(r,0);let He=Si(r,Pe);return Qe.current=He,He},[ae,r]),cr=useMemo(()=>{let J=ie-je.top-je.bottom;return ya(J)},[ie]),Z=useMemo(()=>{let J=zr(Ue),se=J.tickFormat||J.format,Re=ae.ticks(cr).map(Nt=>se(Nt)),He=sn(Re,12,"system-ui"),ut=Math.ceil(He)+12;return {...je,left:Math.max(ut,30),right:8}},[ae,Ue,cr]),le=useMemo(()=>wt?scaleTime({domain:wt,range:[Z.left,E-Z.right]}):nm(Be,E),[wt,Be,E,Z]),Ae=useCallback(J=>{if(!Ve)return;let{scaleX:se,translateX:Pe}=J,Re=E-Z.left-Z.right,[He,ut]=Ve,Nt=ut.getTime()-He.getTime();if(Nt<=0){Xt(null);return}let ze=-Pe,vt=ze+Re,Ge=Re*se/Nt,Mt=ze/Ge,Ie=vt/Ge,_o=new Date(He.getTime()+Mt),$o=new Date(He.getTime()+Ie),en=Math.abs(_o.getTime()-He.getTime()),ra=Math.abs($o.getTime()-ut.getTime()),vl=Nt*.02;en<vl&&ra<vl?Xt(null):Xt([_o,$o]);},[Ve,E,Z,Xt]),Oe=useCallback(J=>{let{left:se}=M.current?.getBoundingClientRect()||{left:0},Pe=J.clientX-se;if(J.timeStamp-(D.current||0)<16)return;D.current=J.timeStamp;let Re=le.invert(Pe),He=j.map((ze,vt)=>{if(!ze||ze.length===0)return null;let Ge=yM(ze,Re,1);if(Ge===0)return {point:ze[0],index:0,datasetIndex:vt};if(Ge>=ze.length)return {point:ze[ze.length-1],index:ze.length-1,datasetIndex:vt};let Mt=ze[Ge-1],Ie=ze[Ge];if(!Mt||!Ie)return null;let _o=Math.abs(Mt.xValue.getTime()-Re.getTime()),$o=Math.abs(Ie.xValue.getTime()-Re.getTime()),en=_o<$o;return {point:en?Mt:Ie,index:en?Ge-1:Ge,datasetIndex:vt}}).filter(ze=>ze!==null&&yt[ze.datasetIndex]!==void 0).map(({point:ze,index:vt,datasetIndex:Ge})=>({label:yt[Ge].label,value:ze.yValue,baselineValue:gc(yt[Ge],ze,vt),color:yt[Ge].color,point:ze,type:Qt[Ge]}));if(He.length===0){S(null);return}let ut=le(He[0].point.xValue),Nt=ut>(E-Z.right-Z.left)/2+Z.left;S({xValue:He[0].point.xValue,series:He.map(({label:ze,value:vt,baselineValue:Ge,color:Mt,point:Ie,type:_o})=>({label:ze,value:vt,...Ge!==void 0?{baselineValue:Ge}:{},chartY:Ie.chartYValue??vt,showMarker:Ie.showTooltipMarker??true,color:Mt,type:_o,category:Ie.category,categoryColor:Ie.category&&O?O[Ie.category]:void 0,...Ie.extraTooltipRows&&Ie.extraTooltipRows.length>0?{extraTooltipRows:Ie.extraTooltipRows}:{}})),x:ut,y:ae(He[0].point.chartYValue??He[0].value),position:Nt?"left":"right"});},[j,yt,Qt,le,ae,E,O,Z]),it=()=>{S(null);},Tt=useCallback(()=>{Xt(null),X.current&&X.current.reset();},[Xt]),Ot=useCallback(J=>{let se={scaleX:1,scaleY:1,translateX:0,translateY:0,skewX:0,skewY:0};if(!J||!Ve)return se;let[Pe,Re]=Ve,He=Re.getTime()-Pe.getTime();if(He<=0)return se;let[ut,Nt]=J,ze=Nt.getTime()-ut.getTime();if(ze<=0)return se;let vt=He/ze,Ge=E-Z.left-Z.right,Mt=ut.getTime()-Pe.getTime();return {scaleX:vt,scaleY:1,translateX:-(Mt/He)*Ge*vt,translateY:0,skewX:0,skewY:0}},[Ve,E,Z]),tt=useCallback(J=>{if(!(X.current&&Ve))return;let[se,Pe]=Ve,Re=Pe.getTime()-se.getTime();if(Re<=0){X.current.reset();return}if(!J){X.current.reset();return}let[He,ut]=J,Nt=ut.getTime()-He.getTime();if(Nt<=0){X.current.reset();return}let ze=Re/Nt,vt=E-Z.left-Z.right,Mt=-((He.getTime()-se.getTime())/Re)*vt*ze;X.current.setTransformMatrix({scaleX:ze,scaleY:1,translateX:Mt,translateY:0,skewX:0,skewY:0});},[Ve,E,Z]),xr=useCallback(J=>{Xt(J),tt(J);},[Xt,tt]);useEffect(()=>{x&&tt(c??null);},[x,c,tt]);let gr=dc(),xo={width:E,height:ie,xScale:le,yScale:ae,yFormatter:Ue,animationSettings:cc,entrance:gr,tooltip:{data:C,show:S,hide:()=>S(null)},datasets:j,seriesMetadata:yt,seriesTypes:Qt,categoryColors:O||void 0,categoryLabels:V||void 0},ne=cn(h),Se=0,ce=[],ct=[],yr=[];ne.forEach(J=>{if(!isValidElement(J)){yr.push(J);return}if(xM(J))ct.push(J);else if(My(J)){let se=Se;Se++;let Pe=J.props,Re=U[se]?.label;if(fe(Re))return;ce.push(ot__default.cloneElement(J,{...Pe,data:Q[se]||Pe.data,color:U[se]?.color}));}else yr.push(J);});let yo=Te.length,vo=(K||U).map(J=>{let se=!K&&fe(J.label);return {category:J.label,fill:J.color,isHidden:se,isDisabled:!K&&!se&&yo<=1}}),yl=typeof r=="object"&&r!==null&&typeof r.type=="string",Nu=vc({datasets:Ye,metadata:{xLabel:"Date",yLabel:"Value",seriesLabels:yt.map(J=>J.label),timestamp:true,...yl?{yFormat:r}:{}},svgRef:M}),Zi=jsx(di,{title:b,controls:f,actions:oe,containerRef:re});if(a)return y.present(jsxs("div",{className:"relative flex h-full flex-col",children:[Zi,jsx(CM,{})]}));if(z.length===0)return y.present(jsxs("div",{className:"relative flex h-full flex-col",children:[Zi,jsx(vM,{})]}));let Le=jsxs(Fragment,{children:[jsx("title",{children:b}),jsx("g",{children:ae.ticks(cr).map(J=>{let se=Math.abs(J)<Number.EPSILON;return jsx(Line,{from:{x:Z.left,y:ae(J)},to:{x:E-Z.right,y:ae(J)},stroke:se?"var(--color-border-default)":"var(--color-border-muted)",strokeWidth:se?1.5:1},`grid-line-${J}`)})}),jsx("defs",{children:jsx("clipPath",{id:B,children:jsx("rect",{x:le.range()[0],y:ae.range()[1],width:le.range()[1]-le.range()[0],height:ae.range()[0]-ae.range()[1]})})}),jsx("g",{clipPath:`url(#${B})`,children:ce}),yr,n&&n.length>0&&jsx("g",{children:n.map((J,se)=>{let Pe=ae(J.value),Re=J.color??"var(--color-error-base)";return jsxs("g",{children:[jsx(Line,{from:{x:Z.left,y:Pe},to:{x:E-Z.right,y:Pe},stroke:Re,strokeWidth:1.5,strokeDasharray:"6 4"}),J.label&&jsx("text",{x:E-Z.right-4,y:Pe-4,textAnchor:"end",fontSize:11,fill:Re,children:J.label})]},`ref-line-${se}`)})}),jsx(uo.Bottom,{top:ie-Z.bottom,scale:le,width:E-Z.left-Z.right}),jsx(uo.Left,{left:Z.left,scale:ae,yFormatter:Ue,height:ie-Z.top-Z.bottom}),C&&!C.isEvent&&jsxs(Fragment,{children:[fr?(()=>{let J=Ye[Ze]??[];if(J.length===0)return null;let se=[...J].sort((ra,vl)=>ra.xValue.getTime()-vl.xValue.getTime()),Pe=se.findIndex(ra=>ra.xValue.getTime()===C.xValue.getTime()),Re=se[Pe+1],He=se.length>1&&Re?Re.xValue.getTime()-C.xValue.getTime():15*6e4,ut=Math.abs(le(new Date(C.xValue.getTime()+He))-le(C.xValue)),ze=le(C.xValue)-ut/2,vt=ae.range(),[Ge,Mt]=le.range(),Ie=Math.min(Ge,Mt),_o=Math.max(Ge,Mt),$o=Math.max(ze,Ie),en=Math.max(0,Math.min(ze+ut,_o)-$o);return jsx("rect",{x:$o,y:vt[1],width:en,height:vt[0]-vt[1],className:"fill-background-muted",opacity:.5,pointerEvents:"none",style:{transition:"all 100ms ease-out"}})})():null,C.series.filter(J=>J.type!=="bar"&&J.showMarker!==false).map(J=>jsxs("g",{children:[jsx("circle",{cx:le(C.xValue),cy:ae(J.chartY??J.value),r:8,fill:"white",stroke:J.color,strokeWidth:2,style:{transition:"all 100ms ease-out"}}),jsx("circle",{cx:le(C.xValue),cy:ae(J.chartY??J.value),r:4,fill:J.color,style:{transition:"all 100ms ease-out"}})]},`highlight-${J.label}`))]}),jsx("rect",{x:Z.left,y:Z.top,width:E-Z.left-Z.right,height:ie-Z.top-Z.bottom,fill:"transparent",style:{cursor:i?"grab":"crosshair",touchAction:"none"},onMouseMove:Oe,onMouseLeave:it}),ct]});return y.present(jsx("div",{className:"relative flex h-full flex-col",children:jsxs(co.Provider,{value:xo,children:[Zi,i?jsx(Zoom,{initialTransformMatrix:Ot(N),width:E,height:ie,scaleXMin:1,scaleXMax:20,scaleYMin:1,scaleYMax:1,constrain:J=>{let{scaleX:se,translateX:Pe}=J,Re=Math.max(1,Math.min(20,se)),He=1,ut=E-Z.left-Z.right,Nt=0,ze=ut*(1-Re),vt=Math.max(ze,Math.min(Nt,Pe));return {...J,scaleX:Re,scaleY:He,translateX:vt,translateY:0}},children:J=>{if(X.current=J,J.transformMatrix){let{scaleX:se,translateX:Pe}=J.transformMatrix,Re=`${se.toFixed(4)}-${Pe.toFixed(2)}`;Re!==W.current&&(W.current=Re,setTimeout(()=>{Ae(J.transformMatrix);},0));}return jsx("svg",{width:E,height:ie,className:"overflow-visible",ref:se=>{M.current=se,J.containerRef.current!==se&&(J.containerRef.current=se);},role:"img","aria-label":b,style:{cursor:J.isDragging?"grabbing":"grab",touchAction:"none"},onMouseDown:J.dragStart,onMouseMove:J.dragMove,onMouseUp:J.dragEnd,onMouseLeave:()=>{J.isDragging&&J.dragEnd();},onTouchStart:J.dragStart,onTouchMove:J.dragMove,onTouchEnd:J.dragEnd,children:Le})}},`zoom-${Math.round(E)}x${Math.round(ie)}`):jsx("svg",{width:E,height:ie,className:"overflow-visible",ref:M,role:"img","aria-label":b,children:Le}),jsx(Ho,{data:C,formatter:Ue}),s&&Ve&&jsx(pm,{data:Ye,seriesMetadata:yt,width:E,height:l,onBrushChange:xr,brushRegion:N,margin:Z,...o?{yDomain:o}:{}}),!p&&jsx(Ti,{onExport:Nu,items:vo,isZoomed:N!==null,onResetZoom:Tt,onLegendItemToggle:K?void 0:Ce,marginLeft:Z.left,marginRight:Z.right})]})}))},wM=withParentSize(SM),Gm=({source:e,streaming:t,...r})=>{if(Nc(e))return jsx(Wc,{source:e,title:r.title??"Chart",...r.yFormatter!==void 0?{yFormatter:r.yFormatter}:{},...r.yDomain!==void 0?{yDomain:r.yDomain}:{},...r.referenceLines!==void 0?{referenceLines:r.referenceLines}:{},...r.headerActions!==void 0?{headerActions:r.headerActions}:{},...t?.tierToWindow!==void 0?{tierToWindow:t.tierToWindow}:{},...t?.windowSizeOptions!==void 0?{windowSizeOptions:t.windowSizeOptions}:{},...t?.presetRanges!==void 0?{presetRanges:t.presetRanges}:{},...t?.hint!==void 0?{hint:t.hint}:{},...t?.emptyState!==void 0?{emptyState:t.emptyState}:{},...t?.height!==void 0?{height:t.height}:{},...t?.latestDataReadout!==void 0?{latestDataReadout:t.latestDataReadout}:{},...t?.latestDataSeriesKeys!==void 0?{latestDataSeriesKeys:t.latestDataSeriesKeys}:{},...t?.panels!==void 0?{panels:t.panels}:{},children:r.children});let{yDomain:o,...n}=r;return jsx(wM,{...n,...typeof o=="function"?{}:{yDomain:o}})};Gm.displayName="ChartContainer";var MM=e=>e.toLocaleString(),EM=e=>`${Math.round(e*100)}%`,Iy=({data:e,width:t=800,height:r=400,padding:o=0,barGap:n=30,formatValue:a=MM,formatPercentage:i=EM,color:s,showScale:l=true,showOverallConversion:d=true,overallConversionLabel:c="Overall Conversion:",activeStageId:u,onStageClick:m,onStageHover:p,className:g,style:f,"aria-label":b="Funnel chart"})=>{let[h,v]=useState(null),[x,C]=useState(t),S=useRef(null),w=u??h,T=useId(),N=s||"var(--color-viz-default)";useEffect(()=>{if(!S.current)return;let D=new ResizeObserver(W=>{for(let X of W)C(X.contentRect.width);});return D.observe(S.current),()=>{D.disconnect();}},[]);let{layout:k,overallConversion:R}=useMemo(()=>{if(e.length===0)return {layout:[],overallConversion:0};let D=e[0].value,W=d?60:0,X=r-o*2-W,H=(e.length-1)*n,I=(X-H)/e.length,F=e.map((U,K)=>{let O=o+W+K*(I+n),V=D===0?0:U.value/D,L=V,y=K===0?null:e[K-1].value,E=y==null||y===0?0:1-U.value/y;return {stage:U,index:K,y:O,barHeight:I,widthPercent:V,conversionRate:L,dropOff:E}}),z=D===0?0:e[e.length-1].value/D;return {layout:F,overallConversion:z,maxValue:D}},[e,x,r,o,n,l,d]);if(e.length===0)return jsx("div",{className:twMerge("flex h-full min-h-[280px] w-full items-center justify-center rounded-lg border border-dashed border-border-default bg-background-surface text-sm font-medium text-text-secondary",g),style:{width:t,height:r,...f},children:"No funnel data available"});let A=l?60:0,M=o+A,B=x-o*2-A;return jsx("div",{ref:S,className:twMerge("relative w-full overflow-hidden rounded-lg bg-background-surface",g),style:{height:r,...f},"aria-label":b,role:"img",children:jsxs("svg",{width:"100%",height:r,className:"relative",children:[jsxs("defs",{children:[jsx(LinearGradient,{id:`${T}-bar`,from:N,to:N,toOpacity:.85}),jsx(LinearGradient,{id:`${T}-bg`,from:N,to:N,fromOpacity:.01,toOpacity:.15,x1:"0",y1:"0",x2:"1",y2:"0"})]}),d&&jsxs("text",{x:M,y:o+20,className:"fill-text-primary text-sm font-medium",children:[jsx("tspan",{className:"fill-text-secondary",children:c})," ",i(R)]}),l&&jsx("g",{children:k.map(D=>{let W=D.y+D.barHeight/2;return jsx("text",{x:o+A-12,y:W,textAnchor:"end",dominantBaseline:"middle",className:"fill-text-secondary text-xs",children:i(D.conversionRate)},D.stage.id)})}),k.map(D=>{let W=w===D.stage.id,X=B*D.widthPercent;return jsxs("g",{children:[jsx("rect",{x:M,y:D.y,width:B,height:D.barHeight,fill:`url(#${T}-bg)`,rx:4}),jsx(motion.rect,{x:M,y:D.y,width:X,height:D.barHeight,fill:`url(#${T}-bar)`,rx:4,initial:{width:0},animate:{width:X},transition:{duration:.6,delay:D.index*.1,ease:"easeOut"},opacity:W||w==null?1:.5,style:{cursor:m||p?"pointer":"default",transition:"opacity 150ms ease"},onMouseEnter:()=>{v(D.stage.id),p?.(D.stage);},onMouseLeave:()=>{v(null),p?.(null);},onClick:()=>m?.(D.stage)}),jsx("rect",{x:M+10,y:D.y+D.barHeight/2-10,width:70,height:20,className:"fill-background-surface stroke-border-default",strokeWidth:1,rx:4,style:{pointerEvents:"none"}}),jsx("text",{x:M+16,y:D.y+D.barHeight/2+4,className:"fill-text-primary text-xs font-semibold",style:{pointerEvents:"none"},children:a(D.stage.value)}),jsxs("text",{x:M,y:D.y-8,className:"fill-text-secondary text-xs",style:{pointerEvents:"none"},children:[jsx("tspan",{children:D.index+1})," ",D.stage.label]}),D.stage.secondaryValue&&jsx("text",{x:M+16,y:D.y-24,className:"fill-text-secondary text-xs",style:{pointerEvents:"none"},children:D.stage.secondaryValue}),D.index>0&&D.dropOff>0&&jsxs("text",{x:M+B,y:D.y-8,textAnchor:"end",className:"fill-text-secondary text-xs",children:[i(D.dropOff)," drop"]}),D.stage.annotation&&jsxs("g",{children:[jsx("rect",{x:M+X+8,y:D.y+8,width:60,height:24,rx:3,className:"fill-background-muted"}),jsx("text",{x:M+X+16,y:D.y+20,className:"fill-text-secondary text-xs font-medium",children:D.stage.annotation})]})]},D.stage.id)})]})})};var FM=.005,Vy=320;function Uc(e){return e>0?e:0}function BM(e,t,r){let o=t===0?0:Uc(e.value)/t*100;return `${e.label}: ${r(e.value)}, ${o.toFixed(1)}%`}var Oy=({data:e,width:t,height:r,innerRadiusRatio:o=0,yFormatter:n={type:"number"},showLegend:a=true,showTooltip:i=true,onSliceClick:s,onSliceHover:l,className:d,style:c,"aria-label":u})=>{let[m,p]=useState(null),[g,f]=useState(null),[b,h]=useState(null),[v,x]=useState(t??600),[C,S]=useState(r??300),w=useRef(null);useEffect(()=>{if(t!==void 0&&r!==void 0){x(t),S(r);return}if(!w.current)return;let H=new ResizeObserver(I=>{for(let F of I)t===void 0&&x(F.contentRect.width),r===void 0&&S(F.contentRect.height);});return H.observe(w.current),t===void 0&&x(w.current.offsetWidth),r===void 0&&S(w.current.offsetHeight||300),()=>{H.disconnect();}},[t,r]);let T=useMemo(()=>e.reduce((H,I)=>H+Uc(I.value),0),[e]),N=useMemo(()=>{let H=es(e.map(I=>I.label));return e.map(I=>({...I,color:I.color||H[I.label]||"var(--color-viz-default)"}))},[e]),k=zr(n),R=s!==void 0,A=a&&v>=Vy,M=A?Math.max(v*.45,Vy*.45):v,D=Math.max(0,Math.min(M,C)-8)/2,W=D*Math.min(Math.max(o,0),.95);if(e.length===0||T===0)return jsx("div",{ref:w,className:twMerge("flex h-full min-h-[200px] w-full items-center justify-center rounded-lg border border-dashed border-border-default bg-background-surface text-sm font-medium text-text-secondary",d),style:r!==void 0?{height:r,...c}:c,children:"No data available"});let X=(H,I,F)=>{if(p(H),l?.(I,H),H!==null&&I&&F){let z=M/2+F[0],U=C/2+F[1];h(I.label),f({xValue:new Date,series:[{label:"Value",value:I.value,color:I.color||"var(--color-viz-default)"}],x:z,y:U,position:z>v/2?"left":"right"});}else f(null),h(null);};return jsxs("div",{ref:w,className:twMerge("relative flex h-full w-full items-center gap-4 rounded-lg bg-background-surface",d),style:r!==void 0?{height:r,...c}:c,children:[jsx("svg",{width:M,height:C,className:"flex-shrink-0",role:R?"group":"img","aria-label":u,children:jsx(Group,{top:C/2,left:M/2,children:jsx(Pie,{data:N,pieValue:H=>Uc(H.value),pieSort:null,pieSortValues:null,outerRadius:D,innerRadius:W,padAngle:FM,children:H=>H.arcs.map((I,F)=>{let z=m===F||m===null,U=H.path.centroid(I);return jsx("path",{d:H.path(I)??void 0,fill:I.data.color,opacity:z?1:.5,style:{cursor:s||l?"pointer":"default",transition:"opacity 150ms ease-out"},onMouseEnter:()=>X(F,I.data,U),onMouseLeave:()=>X(null,null),onClick:()=>s?.(I.data,F),...R?{role:"button",tabIndex:0,"aria-label":BM(I.data,T,k.format),onFocus:()=>X(F,I.data,U),onBlur:()=>X(null,null),onKeyDown:K=>{K.key!=="Enter"&&K.key!==" "||(K.preventDefault(),s?.(I.data,F));}}:{}},I.data.label)})})})}),A?jsx("ul",{className:"flex min-w-0 flex-col gap-1 overflow-y-auto py-2 text-xs",children:N.map((H,I)=>jsxs("li",{className:"flex items-center gap-2",style:{opacity:m===I||m===null?1:.5},onMouseEnter:()=>X(I,H),onMouseLeave:()=>X(null,null),children:[jsx("span",{className:"h-3 w-3 flex-shrink-0 rounded-sm",style:{backgroundColor:H.color}}),jsx("span",{className:"truncate text-text-primary",title:H.label,children:H.label}),jsxs("span",{className:"ml-auto flex-shrink-0 tabular-nums text-text-secondary",children:[k.format(H.value)," (",(Uc(H.value)/T*100).toFixed(1),"%)"]})]},H.label))}):null,i&&jsx(Ho,{data:g,formatter:n,label:b??void 0})]})};function Is({count:e,label:t="results",suffix:r,unknownLabel:o="\u2014",isLoading:n=false,className:a="",testId:i}){if(n)return jsx("div",{className:`flex items-center ${a}`,children:jsx(q,{width:80,height:16})});if(e===null)return jsx("div",{"data-testid":i,className:`text-sm text-text-secondary whitespace-nowrap ${a}`,children:o});let s=t.endsWith("s")?t.slice(0,-1):t,l=e===1&&!r?s:t,d=`${e.toLocaleString()}${r??""}${l?` ${l}`:""}`;return jsx("div",{"data-testid":i,className:`text-sm text-text-secondary whitespace-nowrap ${a}`,children:d})}var HM=e=>{let t=rr({isInvalid:e.isInvalid,isDisabled:e.isDisabled,isFocused:e.isFocused,transparent:e.transparent,size:e.size}),r=[e.showSearchIcon?"":"pl-3",e.isClearable&&e.hasValue||e.isPassword?"pr-8":"pr-3"].join(" ");return twMerge(t,r,e.className)};function fo({label:e,description:t,errorMessage:r,size:o="md",tooltip:n,isRequired:a,transparent:i,showSearchIcon:s,isClearable:l,onClear:d,type:c,validationResult:u,reserveErrorSpace:m=true,isLoading:p=false,descriptionPlacement:g="below",...f}){let[b,h]=ot__default.useState(false),{isFocused:v,handleFocus:x,handleBlur:C}=Ar(),S=c==="password",w=jl(p,300);return jsx(TextField,{...f,isRequired:a,className:Fe(f.className,"group flex flex-col"),children:({isDisabled:T,isInvalid:N})=>jsxs("div",{className:"flex flex-col",children:[e&&jsx(et,{size:o,tooltip:n,description:g==="tooltip"||g==="inline"?t:void 0,descriptionPlacement:g,isRequired:a,children:e}),jsxs(Dt,{children:[s&&jsx("div",{className:"pointer-events-none absolute top-1/2 -translate-y-1/2 transform flex items-center z-10",style:{left:9},children:(()=>{let k={sm:14,md:16,lg:18,xl:20}[o];return w?jsx(ao,{size:k,color:"text-text-secondary"}):jsx(G,{name:"MagnifyingGlass",size:k,className:`transition-colors ${v?"text-action-brand":"text-text-secondary"}`})})()}),jsx(Zl,{size:o,disabled:T,type:S?b?"text":"password":c,name:f.name,autoComplete:f.autoComplete,value:f.value,defaultValue:f.defaultValue,placeholder:f.placeholder,onFocus:k=>x(k,f.onFocus),onBlur:k=>C(k,f.onBlur),onChange:k=>f.onChange?.(k.target.value),style:s?{paddingLeft:{sm:28,md:32,lg:36,xl:37}[o]}:void 0,className:HM({isInvalid:N,isDisabled:T,isFocused:v,size:o,transparent:i,showSearchIcon:s,isClearable:l,hasValue:!!f.value,isPassword:S,className:typeof f.className=="string"?f.className:void 0})}),l&&f.value&&!T&&jsx(ms,{onClick:()=>{d?d():f.onChange&&f.onChange("");},size:o}),S&&!T&&jsx("button",{type:"button",onClick:()=>h(!b),className:"absolute right-3 top-1/2 -translate-y-1/2 transform text-text-secondary hover:text-text-primary","aria-label":b?"Hide password":"Show password",onMouseDown:k=>{k.preventDefault(),k.stopPropagation();},children:jsx(G,{name:b?"EyeSlash":"Eye",size:o==="sm"?16:20,className:"text-text-primary"})})]}),m?jsx("div",{className:"mt-1 min-h-[20px]",children:typeof r=="string"?jsx(ye,{size:o,children:r}):typeof r=="function"&&u?jsx(ye,{size:o,children:r(u)}):t&&g==="below"?jsx(Ee,{size:o,children:t}):null}):jsx(Fragment,{children:typeof r=="string"?jsx(ye,{size:o,className:"mt-1",children:r}):typeof r=="function"&&u?jsx(ye,{size:o,className:"mt-1",children:r(u)}):t&&g==="below"?jsx(Ee,{size:o,className:"mt-1",children:t}):null})]})})}function Ma({value:e,onChange:t,onClear:r,placeholder:o="Search...",size:n="sm",className:a="",isLoading:i=false}){return jsx("div",{className:`flex-1 min-w-0 sm:max-w-sm ${a}`,children:jsx(fo,{value:e,onChange:t,placeholder:o,showSearchIcon:true,isClearable:!!e&&!!r,onClear:r,size:n,"aria-label":o,reserveErrorSpace:false,isLoading:i})})}function Fs({value:e,options:t,onChange:r,direction:o,onDirectionChange:n,showLabel:a=true,size:i="sm",className:s="",compact:l=false}){let[d,c]=useState(false),u=o!==void 0&&n!==void 0,m=t.find(p=>p.value===e);return l?jsxs("div",{className:`flex items-center gap-2 ${s}`,children:[jsx(te,{variant:"secondary",size:i,icon:"ArrowsDownUp","aria-label":`Sort by: ${m?.label||"Select"}`,onPress:()=>c(true)}),jsx(Lt,{isOpen:d,onClose:()=>c(false),title:"Sort by",contentPadding:false,children:jsx(ListBox,{items:t.map(p=>({id:p.value,label:p.label,value:p.value})),className:"w-full bg-background-surface p-0 outline-0 [&_[role=option]]:border-b [&_[role=option]]:border-border-default [&_[role=option]:last-child]:border-0 [&_[role=option]]:!px-6 [&_[role=option]]:!py-4 [&_[role=option]]:rounded-none",selectionMode:"single",selectedKeys:e?[e]:[],onSelectionChange:p=>{let g=Array.from(p)[0];g!=null&&(r(g),c(false));},children:p=>jsx(Ir,{id:p.id,textValue:p.label,children:jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap min-w-0 flex-1",children:p.label})},p.id)})})]}):jsxs("div",{className:`flex items-center gap-2 ${s}`,children:[a&&jsx("span",{className:"text-sm text-text-secondary whitespace-nowrap",children:"Sort by:"}),jsx(on,{selectedKey:e,onSelectionChange:p=>r(p),size:i,className:"min-w-32",items:t.map(p=>({id:p.value,label:p.label,value:p.value})),renderItem:p=>p.label,"aria-label":"Sort by",reserveErrorSpace:false}),u&&jsx(te,{variant:"ghost",size:i,onClick:()=>n(o==="asc"?"desc":"asc"),"aria-label":`Sort ${o==="asc"?"descending":"ascending"}`,className:"p-1.5",children:o==="asc"?jsx(ArrowUp,{className:"w-4 h-4"}):jsx(ArrowDown,{className:"w-4 h-4"})})]})}function Wy({search:e,searchMobileMode:t="expanded",filters:r=[],onRemoveFilter:o,onClearAllFilters:n,onManageFilters:a,exportControl:i,maxVisibleFilterChips:s=3,sort:l,resultsCount:d,leftControls:c,onManageColumns:u,columnPicker:m,customControls:p,actions:g,interactionMode:f="auto",sticky:b,stickyTop:h="0",zIndex:v=10,className:x="",style:C}){let S=r.length>0;if(!(e||S||a||l||d||c||u||m||p||g||i))return null;let T=b?"sticky bg-background-surface":"",N=b?{top:h,zIndex:v}:{};return jsxs("div",{className:`@container flex flex-col gap-3 bg-background-surface py-3 border-b border-border-default ${T} ${x}`,style:{...C,...N},children:[jsxs("div",{className:"hidden @[640px]:flex @[640px]:items-center @[640px]:justify-between @[640px]:gap-4",children:[jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[c,c&&d&&jsx("div",{className:"h-4 w-px bg-border-default"}),d&&jsx(Is,{count:d.count,label:d.label,suffix:d.suffix,unknownLabel:d.unknownLabel,isLoading:d.isLoading,testId:d.testId}),d&&l&&jsx("div",{className:"h-4 w-px bg-border-default"}),l&&jsx(Fs,{value:l.value,options:l.options,onChange:l.onChange,showLabel:l.showLabel,direction:l.direction,onDirectionChange:l.onDirectionChange}),u?jsx(te,{variant:"secondary",size:"sm",icon:"Columns",onClick:u,children:"Columns"}):m,S&&o&&jsxs(Fragment,{children:[r.slice(0,s).map(k=>jsxs(lo,{variant:"primary",size:"sm",onRemove:()=>o(k.id),isRemovable:true,children:[k.label,": ",k.value]},k.id)),r.length>s&&a&&jsxs(te,{variant:"ghost",size:"sm",onClick:a,className:"text-text-secondary hover:text-text-primary whitespace-nowrap",children:["+",r.length-s," more"]}),n&&jsx(te,{variant:"ghost",size:"sm",onClick:n,className:"text-text-secondary hover:text-text-primary whitespace-nowrap",children:"Clear all"})]})]}),jsx("div",{className:"flex items-center gap-3 flex-shrink-0",children:p||jsxs(Fragment,{children:[g&&g.items.length>0&&jsx(Fragment,{children:g.items.map(k=>jsx(te,{variant:k.variant||"secondary",size:"sm",icon:k.icon,onPress:k.onClick,isDisabled:k.disabled,children:k.label},k.id))}),e&&jsx("div",{className:"w-64",children:jsx(Ma,{value:e.value,onChange:e.onChange,onClear:e.onClear,placeholder:e.placeholder,isLoading:e.isLoading})}),a&&jsx(te,{variant:"secondary",size:"sm",icon:"Sliders",badgeNumber:r.length>0?r.length:void 0,onClick:a,children:"Filters"}),i&&jsx(te,{variant:"secondary",size:"sm",icon:i.icon??"Upload",onClick:i.onClick,isDisabled:i.isDisabled,isLoading:i.isLoading,children:i.label})]})})]}),jsxs("div",{className:"@[640px]:hidden",children:[jsx("div",{className:"flex flex-col gap-3 mb-3",children:jsx("div",{className:"flex items-center gap-3",children:p?jsx("div",{className:"flex-1",children:p}):jsxs(Fragment,{children:[g&&g.items.length>0&&jsx(pi,{items:g.items.map(k=>({id:k.id,name:k.label,iconName:k.icon,variant:k.variant==="destructive"?"destructive":"primary",disabled:k.disabled,onAction:k.onClick})),align:"left",size:"sm",children:jsx(te,{variant:"secondary",size:"sm",icon:"DotsThreeVertical","aria-label":g.menuLabel||"Actions"})}),e&&jsx("div",{className:"flex-1",children:jsx(Ma,{value:e.value,onChange:e.onChange,onClear:e.onClear,placeholder:e.placeholder,isLoading:e.isLoading})}),a&&jsx(te,{variant:"secondary",size:"sm",icon:"Sliders",badgeNumber:r.length>0?r.length:void 0,onClick:a,"aria-label":`Filters${r.length>0?` (${r.length} active)`:""}`}),i&&jsx(te,{variant:"secondary",size:"sm",icon:i.icon??"Upload",onClick:i.onClick,isDisabled:i.isDisabled,isLoading:i.isLoading,children:i.label})]})})}),jsxs("div",{className:"flex items-center justify-between gap-3",children:[jsxs("div",{className:"flex items-center gap-3",children:[c,d&&jsx(Is,{count:d.count,label:d.label,suffix:d.suffix,unknownLabel:d.unknownLabel,isLoading:d.isLoading})]}),jsx("div",{className:"flex items-center gap-2",children:l&&jsx(Fs,{value:l.value,options:l.options,onChange:l.onChange,showLabel:false,direction:l.direction,onDirectionChange:l.onDirectionChange,compact:f!=="desktop"})})]})]})]})}function Uy({filters:e,onRemove:t,onClearAll:r,onManageFilters:o,maxVisibleChips:n=3,mode:a="chips",showManageButton:i=true,size:s="sm",className:l=""}){let d=e.length>0,c=e.slice(0,n),u=Math.max(0,e.length-n),m=u>0,p=a==="button"&&!!o,g=a==="chips"&&i&&!!o;if(!d&&!p&&!g)return null;let f=p&&jsxs(te,{variant:"secondary",size:s,onClick:o,className:"whitespace-nowrap",children:[e.length," ",e.length===1?"filter":"filters"]}),b=jsxs(Fragment,{children:[g&&jsx(te,{variant:"secondary",size:s,icon:"Sliders",onClick:o,className:"whitespace-nowrap",children:"Filters"}),d&&c.map(v=>jsxs(lo,{variant:"secondary",size:s,onRemove:()=>t(v.id),isRemovable:true,children:[v.label,": ",v.value]},v.id)),d&&m&&o&&jsxs(te,{variant:"ghost",size:s,onClick:o,className:"text-text-secondary hover:text-text-primary whitespace-nowrap",children:["+",u," more"]}),d&&r&&jsx(te,{variant:"ghost",size:s,onClick:r,className:"text-text-secondary hover:text-text-primary whitespace-nowrap",children:"Clear all"})]}),h=a==="button"?f:b;return jsx("div",{className:`flex flex-wrap items-center gap-2 ${l}`,children:h})}var Ky=["isEmpty","isNotEmpty"];function Yy(e){return Ky.includes(e)}var Xy={isEmpty:"is empty",isNotEmpty:"is not empty"};function JM(e,t,r){return {field:e,operator:t,value:r}}function jM(e,t="AND"){return {logic:t,conditions:e}}function Bs(){return {logic:"AND",conditions:[]}}function Jc(e){return !e||e.conditions.length===0?true:e.conditions.every(t=>"conditions"in t?Jc(t):false)}function qM(e,t){if(!e)return [];let r=new Map(t?.map(i=>[i.field,i])),o=new Map;function n(i){if("conditions"in i)i.conditions.forEach(s=>n(s));else {let s=o.get(i.field)||[];s.push(i),o.set(i.field,s);}}e.conditions.forEach(i=>n(i));let a=[];for(let[i,s]of o.entries()){let l=r.get(i),d=l?.label||i,c=[],u=[],m=[];for(let p of s)p.operator==="in"&&Array.isArray(p.value)?c.push(...p.value):p.operator==="eq"?p.value!==void 0&&typeof p.value!="boolean"&&!Array.isArray(p.value)?c.push(p.value):m.push(p):["gte","gt","lte","lt"].includes(p.operator)&&p.value!==void 0?u.push({operator:p.operator,value:typeof p.value=="boolean"||Array.isArray(p.value)?String(p.value):p.value}):m.push(p);if(c.length>0){let g=Array.from(new Set(c)).map(f=>l?.values?.find(h=>String(h.value)===String(f))?.label??f);a.push({id:`${i}-in`,label:d,value:g.join(", ")});}if(u.length>0){let p=u.find(f=>f.operator==="gte"||f.operator==="gt"),g=u.find(f=>f.operator==="lte"||f.operator==="lt");if(p&&g){let f=p.operator==="gte"?"\u2265":">",b=g.operator==="lte"?"\u2264":"<";a.push({id:`${i}-range`,label:d,value:`${f} ${p.value} and ${b} ${g.value}`});}else for(let f of u){let b;f.operator==="gte"?b="\u2265":f.operator==="gt"?b=">":f.operator==="lte"?b="\u2264":b="<",a.push({id:`${i}-${f.operator}`,label:d,value:`${b} ${f.value}`});}}for(let p of m){let g;p.operator==="neq"?g=`\u2260 ${p.value}`:p.operator==="contains"?g=`contains "${p.value}"`:p.operator==="startsWith"?g=`starts with "${p.value}"`:p.operator==="endsWith"?g=`ends with "${p.value}"`:Yy(p.operator)?g=Xy[p.operator]:g=String(p.value),a.push({id:`${i}-${p.operator}`,label:d,value:g});}}return a}function Xn(e,t){let r=e||Bs();return {...r,conditions:[...r.conditions,t]}}function Ea(e,t){if(!e)return Bs();let r=e.conditions.filter(o=>"conditions"in o?Ea(o,t).conditions.length>0:o.field!==t);return {...e,conditions:r}}function La(e){if(!e)return [];let t=new Set;function r(o){"conditions"in o?o.conditions.forEach(r):t.add(o.field);}return e.conditions.forEach(r),Array.from(t)}function jy({label:e,description:t,errorMessage:r,size:o="md",tooltip:n,isRequired:a,isDisabled:i,isInvalid:s,showCalendar:l=true,reserveErrorSpace:d=true,validationResult:c,className:u,...m}){let[p,g]=useState(false),f=b=>{m.onChange&&b&&m.onChange(b),g(false);};return jsxs(DateField,{...m,isDisabled:i,isRequired:a,isInvalid:s,className:Fe(u,"flex flex-col gap-1"),children:[e&&jsx(et,{size:o,tooltip:n,isRequired:a,children:e}),jsx(Dt,{children:jsxs("div",{className:"relative w-full",children:[jsx(Vs,{size:o,isDisabled:i,isInvalid:s,hasCalendar:l}),l&&!i&&jsxs(DialogTrigger,{isOpen:p,onOpenChange:g,children:[jsx(te,{variant:"unstyled",className:"absolute right-2 top-1/2 -translate-y-1/2 flex h-8 w-8 items-center justify-center rounded hover:bg-background-hover text-text-secondary hover:text-text-primary transition-colors","aria-label":"Open calendar",children:jsx(G,{name:"Calendar",size:18})}),jsx(Popover,{className:"bg-background-surface rounded-lg border border-border-default shadow-xl",children:jsx(Dialog,{className:"p-4 outline-none",children:jsx(xi,{value:m.value,onChange:f,minValue:m.minValue,maxValue:m.maxValue,isDisabled:i,isReadOnly:m.isReadOnly,isDateUnavailable:m.isDateUnavailable})})})]})]})}),d?jsx("div",{className:"mt-1 min-h-[20px]",children:typeof r=="string"?jsx(ye,{size:o,children:r}):typeof r=="function"&&c?jsx(ye,{size:o,children:r(c)}):t?jsx(Ee,{size:o,children:t}):null}):jsx(Fragment,{children:typeof r=="string"?jsx(ye,{size:o,className:"mt-1",children:r}):typeof r=="function"&&c?jsx(ye,{size:o,className:"mt-1",children:r(c)}):t?jsx(Ee,{size:o,className:"mt-1",children:t}):null})]})}function oE({isPlaceholder:e,isDisabled:t,size:r="md"}){return twMerge("inline-block box-content px-0.5 rounded outline-none tabular-nums text-center transition-colors",{sm:"text-base md:text-xs",md:"text-base md:text-sm",lg:"text-base",xl:"text-lg"}[r],e?"text-text-disabled italic":"text-text-primary",t?"text-text-disabled cursor-not-allowed":"cursor-text",!t&&"hover:bg-background-hover","data-[focused]:bg-background-selected data-[focused]:text-text-primary")}function Vs({size:e="md",isDisabled:t,isInvalid:r,hasCalendar:o,className:n,...a}){return jsx(DateInput,{className:twMerge(An({isInvalid:r,isDisabled:t}),"px-3 py-2 flex items-center gap-0.5 w-full",o&&"pr-10",n),...a,children:i=>jsx(DateSegment,{segment:i,className:oE({isPlaceholder:i.isPlaceholder,isDisabled:!i.isEditable||t,size:e})})})}function jc({label:e,description:t,errorMessage:r,...o}){return jsxs(DateRangePicker,{...o,className:Fe(o.className,"group flex flex-col gap-1"),children:[e&&jsx(et,{children:e}),jsxs(_h,{className:"w-auto min-w-[208px]",children:[jsx(Vs,{slot:"start",className:"px-2 py-1.5 text-sm"}),jsx("span",{"aria-hidden":"true",className:"text-text-primary group-disabled:text-text-disabled forced-colors:text-[ButtonText] group-disabled:forced-colors:text-[GrayText]",children:"\u2013"}),jsx(Vs,{slot:"end",className:"flex-1 px-2 py-1.5 text-sm"}),jsx(te,{variant:"icon",className:"mr-1 w-6 rounded outline-offset-0",children:jsx(CalendarIcon,{"aria-hidden":true,className:"h-4 w-4"})})]}),t&&jsx(Ee,{children:t}),typeof r=="string"?jsx(ye,{children:r}):null,jsx(Et,{children:jsx(Ri,{})})]})}var pE=e=>{let t=rr({isInvalid:e.isInvalid,isDisabled:e.isDisabled,isFocused:e.isFocused,transparent:e.transparent,size:e.size});return twMerge(t,"pr-9","[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none",e.className)};function Os({label:e,description:t,errorMessage:r,size:o="md",tooltip:n,isRequired:a,transparent:i,validationResult:s,reserveErrorSpace:l=true,descriptionPlacement:d="below",...c}){let u=useId(),{isFocused:m,handleFocus:p,handleBlur:g}=Ar();return jsx(NumberField,{...c,id:u,isRequired:a,className:Fe(c.className,"group flex flex-col gap-1"),step:c.step??1,onChange:f=>{typeof f=="number"&&(c.maxValue!=null&&f>c.maxValue?c.onChange?.(c.maxValue):c.minValue!=null&&f<c.minValue?c.onChange?.(c.minValue):c.onChange?.(f));},isInvalid:!!r||typeof c.value=="number"&&(c.maxValue!=null&&c.value>c.maxValue||c.minValue!=null&&c.value<c.minValue),children:({isDisabled:f,isInvalid:b})=>jsxs("div",{className:"flex flex-col gap-1",children:[e&&jsx(et,{size:o,tooltip:n,description:d==="tooltip"||d==="inline"?t:void 0,descriptionPlacement:d,isRequired:a,htmlFor:u,children:e}),jsx("div",{className:"relative",children:jsxs(Group$1,{className:"relative",children:[jsx(Input,{onFocus:v=>p(v,c.onFocus),onBlur:v=>g(v,c.onBlur),className:pE({isInvalid:b||!!r,isDisabled:f,isFocused:m,transparent:i,size:o,className:typeof c.className=="string"?c.className:void 0})}),jsxs("div",{className:"absolute inset-y-[2px] right-[2px] flex flex-col divide-y divide-border-default border-l border-border-default overflow-hidden rounded-r-[calc(var(--control-border-radius)-2px)]",children:[jsx(Button,{slot:"increment",isDisabled:f,className:"flex h-1/2 w-7 items-center justify-center bg-background-input hover:bg-background-input-hover active:bg-background-input-active disabled:cursor-not-allowed disabled:opacity-50",children:jsx(G,{name:"CaretUp",size:14})}),jsx(Button,{slot:"decrement",isDisabled:f,className:"flex h-1/2 w-7 items-center justify-center bg-background-input hover:bg-background-input-hover active:bg-background-input-active disabled:cursor-not-allowed disabled:opacity-50",children:jsx(G,{name:"CaretDown",size:14})})]})]})}),l?jsx("div",{className:"mt-1 min-h-[20px]",children:r?jsx(ye,{size:o,children:typeof r=="function"?r(s):r}):t&&d==="below"?jsx(Ee,{size:o,children:t}):null}):jsx(Fragment,{children:r?jsx(ye,{size:o,className:"mt-1",children:typeof r=="function"?r(s):r}):t&&d==="below"?jsx(Ee,{size:o,className:"mt-1",children:t}):null})]})})}var Jm={sm:{track:"h-4 w-7",handle:"h-3.5 w-3.5",text:"text-xs"},md:{track:"h-5 w-9",handle:"h-4 w-4",text:"text-sm"},lg:{track:"h-6 w-11",handle:"h-5 w-5",text:"text-base"},xl:{track:"h-7 w-14",handle:"h-6 w-6",text:"text-lg"}};function gE({isSelected:e,isDisabled:t,size:r="md"}){let o="flex px-px items-center shrink-0 cursor-default rounded-full transition duration-200 ease-in-out shadow-inner border border-transparent",n=Jm[r].track,a=pt,i="focus-visible:outline-action-primary",s="";return e?s="bg-action-primary forced-colors:!bg-[Highlight] group-pressed:bg-action-primary-hover":s="bg-border-input group-pressed:bg-border-focus",[o,n,a,i,s,t?"bg-background-muted forced-colors:group-selected:!bg-[GrayText] forced-colors:border-[GrayText]":""].filter(Boolean).join(" ")}function hE({isSelected:e,isDisabled:t,size:r="md"}){let o="transform rounded-full bg-background-surface outline-none shadow transition duration-200 ease-in-out",n=Jm[r].handle;return [o,n,e?"translate-x-[100%]":"translate-x-0",t?"forced-colors:outline-[GrayText]":""].filter(Boolean).join(" ")}function qc({children:e,variant:t="primary",size:r="md",...o}){return jsx(Switch,{...o,className:Fe(o.className,`relative group flex items-center gap-2 ${Jm[r].text} text-text-primary transition disabled:text-text-disabled forced-colors:disabled:text-[GrayText]`),children:n=>jsxs(Fragment,{children:[jsx("div",{className:gE({...n,size:r}),children:jsx("span",{className:hE({...n,size:r})})}),e]})})}function Qy(e){return new Intl.NumberFormat("en-US").format(e)}function _y({isOpen:e,onClose:t,facetConfigs:r,facetCounts:o={},currentFilters:n,onApply:a,onClear:i,title:s="Filters",resultCount:l}){let[d,c]=useState(n),[u,m]=useState({}),[p,g]=useState({}),[f,b]=useState(null),{isMobile:h}=Rr(),v=useMemo(()=>r.some(y=>y.group),[r]),{groups:x,ungroupedFacets:C,facetsByGroup:S}=useMemo(()=>{let y=new Set,E=[],P={};for(let Y of r)Y.group?(y.has(Y.group)||(y.add(Y.group),P[Y.group]=[]),P[Y.group].push(Y)):E.push(Y);return {groups:Array.from(y),ungroupedFacets:E,facetsByGroup:P}},[r]);useEffect(()=>{e&&(c(n),m({}),g({}),b(!h&&x.length>0?x[0]:null));},[e,n,x,h]);let w=useMemo(()=>!d||Jc(d)?0:La(d).length,[d]),T=()=>{a(d),t();},N=()=>{let y=Bs();c(y),i?i():a(y),t();},k=y=>{if(!d)return [];if(!La(d).includes(y))return [];let P=[];function Y($){if($)for(let oe of $.conditions)"conditions"in oe?Y(oe):oe.field===y&&oe.operator==="in"&&Array.isArray(oe.value)&&P.push(...oe.value.map(String));}return Y(d),P},R=(y,E,P)=>{let Y=Ea(d,y);E!==void 0&&(Y=Xn(Y,{field:y,operator:"gte",value:E})),P!==void 0&&(Y=Xn(Y,{field:y,operator:"lte",value:P})),c(Y);},A=y=>{if(!d)return;let E;function P(Y){if(Y)for(let $ of Y.conditions)"conditions"in $?P($):$.field===y&&$.operator==="eq"&&typeof $.value=="boolean"&&(E=$.value);}return P(d),E},M=(y,E)=>{let P=Ea(d,y);E!==void 0&&(P=Xn(P,{field:y,operator:"eq",value:E})),c(P);},B=(y,E,P)=>{let Y=Ea(d,y);E&&(Y=Xn(Y,{field:y,operator:"gte",value:E.toString()})),P&&(Y=Xn(Y,{field:y,operator:"lte",value:P.toString()})),c(Y);},D=y=>{let E=S[y]||[],P=d?La(d):[];return E.filter(Y=>P.includes(Y.field)).length},W="pr-9 bg-background-muted/50",X="border-t border-border-muted",H="text-sm font-medium text-text-link-default",I=y=>jsx("span",{className:H,children:y}),F=y=>{let E=o[y.field]||{},P=u[y.field]||"",Y=[];y.values?Y=y.values.map(re=>({value:String(re.value),label:re.label,count:E[String(re.value)]})):Y=Object.entries(E).map(([re,_])=>({value:re,label:re,count:_}));let $=Y.length;if(P){let re=P.toLowerCase();Y=Y.filter(_=>_.label.toLowerCase().includes(re));}Y.sort((re,_)=>re.count!==void 0&&_.count!==void 0&&_.count!==re.count?_.count-re.count:re.label.localeCompare(_.label));let oe=y.type||"string";if(oe==="string"||!y.type){let re=k(y.field),_=y.searchThreshold??10,he=y.maxVisibleOptions??50,me=p[y.field]??false,ue=me||Y.length<=he?Y:Y.slice(0,he),ie=Y.length>he&&!me;return jsxs(On,{id:y.field,children:[jsx(zn,{title:y.label,description:y.description,className:W,endContent:re.length>0?I(`${re.length} selected`):void 0}),jsx(Hn,{className:X,children:jsxs("div",{className:"space-y-4 pt-4 pb-4",children:[$>_&&jsx(Ma,{value:P,onChange:fe=>m(Te=>({...Te,[y.field]:fe})),onClear:()=>m(fe=>({...fe,[y.field]:""})),placeholder:`Search ${y.label.toLowerCase()}...`,size:"sm",className:"w-full !max-w-none pr-4"}),jsx(Yp,{value:re,onChange:fe=>{let Te=Ea(d,y.field);fe.length>0&&(Te=Xn(Te,{field:y.field,operator:"in",value:fe})),c(Te);},children:jsx("div",{className:"space-y-1.5",children:ue.map(fe=>jsx("div",{className:"rounded-md py-2 pr-4 transition-colors hover:bg-background-hover",children:jsx(So,{value:fe.value,children:jsxs("div",{className:"flex items-center justify-between gap-3 flex-1",children:[y.renderLabel?y.renderLabel(fe.value,fe.label):jsx("span",{className:"text-sm font-medium text-text-primary",children:fe.label}),fe.count!==void 0&&jsx("span",{className:"text-xs font-medium text-text-secondary tabular-nums",children:Qy(fe.count)})]})})},fe.value))})}),ie&&jsx("div",{className:"pt-2 border-t border-border-muted",children:jsxs(te,{variant:"ghost",size:"sm",onPress:()=>g(fe=>({...fe,[y.field]:true})),className:"w-full",children:["Show all ",Y.length," options"]})}),me&&Y.length>he&&jsx("div",{className:"pt-2 border-t border-border-muted",children:jsx(te,{variant:"ghost",size:"sm",onPress:()=>g(fe=>({...fe,[y.field]:false})),className:"w-full",children:"Show less"})})]})})]},y.field)}if(oe==="number"){let re,_,he=ue=>{if(ue)for(let ie of ue.conditions)"conditions"in ie?he(ie):ie.field===y.field&&(ie.operator==="gte"&&typeof ie.value=="number"&&(re=ie.value),ie.operator==="lte"&&typeof ie.value=="number"&&(_=ie.value));};he(d);let me=re!==void 0||_!==void 0;return jsxs(On,{id:y.field,children:[jsx(zn,{title:y.label,description:y.description,className:W,endContent:me?I(re!==void 0&&_!==void 0?`${re} - ${_}`:re!==void 0?`\u2265 ${re}`:`\u2264 ${_}`):void 0}),jsx(Hn,{className:X,children:jsxs("div",{className:"grid grid-cols-2 gap-4 pt-4 pb-4",children:[jsx(Os,{label:"Min",value:re,onChange:ue=>R(y.field,ue,_)},`${y.field}-min`),jsx(Os,{label:"Max",value:_,onChange:ue=>R(y.field,re,ue)},`${y.field}-max`)]})})]},y.field)}if(oe==="boolean"){let re=A(y.field);return jsxs(On,{id:y.field,children:[jsx(zn,{title:y.label,description:y.description,className:W,endContent:re!==void 0?I(re?"Yes":"No"):void 0}),jsx(Hn,{className:X,children:jsxs("div",{className:"flex items-center justify-between pt-4 pb-4",children:[jsx("span",{className:"text-sm font-medium text-text-primary",children:re!==void 0?re?"Enabled":"Disabled":"No filter applied"}),jsx(qc,{size:"lg",isSelected:re??false,onChange:_=>M(y.field,_?true:void 0),children:re?"Yes":"No"})]})})]},y.field)}if(oe==="date"){let re,_,he=Te=>{if(Te)for(let Ye of Te.conditions)"conditions"in Ye?he(Ye):Ye.field===y.field&&(Ye.operator==="gte"&&(re=String(Ye.value)),Ye.operator==="lte"&&(_=String(Ye.value)));};he(d);let me=re!==void 0||_!==void 0,ue=Te=>{if(Te)try{return /^\d{4}-\d{2}-\d{2}$/.test(Te)?parseDate(Te):void 0}catch{return}},ie=ue(re),fe=ue(_);return jsxs(On,{id:y.field,children:[jsx(zn,{title:y.label,description:y.description,className:W,endContent:me?I("Date range selected"):void 0}),jsx(Hn,{className:X,children:jsx("div",{className:"pt-4 pb-4",children:jsx(jc,{label:"Date Range",value:ie&&fe?{start:ie,end:fe}:void 0,onChange:Te=>{Te?B(y.field,Te.start,Te.end):B(y.field,void 0,void 0);}})})})]},y.field)}return null},z=()=>jsxs("div",{className:"flex flex-col",children:[C.map(y=>{let P=(d?La(d):[]).includes(y.field);return jsxs("button",{type:"button",onClick:()=>b(`__ungrouped__${y.field}`),className:"flex items-center justify-between px-6 py-3 text-left hover:bg-background-hover border-b border-border-muted transition-colors",children:[jsx("span",{className:"text-sm font-medium text-text-primary",children:y.label}),jsxs("div",{className:"flex items-center gap-2",children:[P&&jsx("span",{className:H,children:"1 active"}),jsx(G,{name:"CaretRight",size:"sm",className:"text-text-secondary"})]})]},y.field)}),x.map(y=>{let E=D(y);return jsxs("button",{type:"button",onClick:()=>b(y),className:"flex items-center justify-between px-6 py-3 text-left hover:bg-background-hover border-b border-border-muted transition-colors",children:[jsx("span",{className:"text-sm font-medium text-text-primary",children:y}),jsxs("div",{className:"flex items-center gap-2",children:[E>0&&jsxs("span",{className:H,children:[E," active"]}),jsx(G,{name:"CaretRight",size:"sm",className:"text-text-secondary"})]})]},y)})]}),U=y=>{if(y.startsWith("__ungrouped__")){let P=y.replace("__ungrouped__",""),Y=C.find($=>$.field===P);return Y?jsx(yi,{variant:"contained",density:"comfortable",showDividers:true,defaultExpandedKeys:[Y.field],children:F(Y)}):null}let E=S[y]||[];return E.length===0?null:jsx(yi,{variant:"contained",density:"comfortable",showDividers:true,defaultExpandedKeys:[E[0].field],children:E.map(P=>F(P))})},K=()=>{if(f){let y=f.startsWith("__ungrouped__")&&C.find(E=>E.field===f.replace("__ungrouped__",""))?.label||f;return jsxs("div",{className:"flex flex-col h-full",children:[jsxs("button",{type:"button",onClick:()=>b(null),className:"flex items-center gap-2 px-4 py-3 border-b border-border-muted hover:bg-background-hover transition-colors",children:[jsx(G,{name:"CaretLeft",size:"sm",className:"text-text-secondary"}),jsx("span",{className:"text-sm font-medium text-text-primary",children:y})]}),jsx("div",{className:"flex-1 overflow-y-auto",children:U(f)})]})}return z()},O=()=>jsxs("div",{className:"flex h-full",children:[jsxs("div",{className:"w-48 flex-shrink-0 border-r border-border-muted overflow-y-auto bg-background-muted/30",children:[C.map(y=>{let P=(d?La(d):[]).includes(y.field),Y=f===`__ungrouped__${y.field}`;return jsxs("button",{type:"button",onClick:()=>b(`__ungrouped__${y.field}`),className:`flex items-center justify-between w-full px-4 py-3 text-left border-b border-border-muted transition-colors ${Y?"bg-background-selected":"hover:bg-background-hover"}`,children:[jsx("span",{className:`text-sm truncate ${Y?"font-semibold text-text-primary":"font-medium text-text-primary"}`,children:y.label}),P&&jsx("span",{className:"w-2 h-2 rounded-full bg-action-primary flex-shrink-0 ml-2"})]},y.field)}),x.map(y=>{let E=D(y),P=f===y;return jsxs("button",{type:"button",onClick:()=>b(y),className:`flex items-center justify-between w-full px-4 py-3 text-left border-b border-border-muted transition-colors ${P?"bg-background-selected":"hover:bg-background-hover"}`,children:[jsx("span",{className:`text-sm truncate ${P?"font-semibold text-text-primary":"font-medium text-text-primary"}`,children:y}),E>0&&jsx("span",{className:"w-2 h-2 rounded-full bg-action-primary flex-shrink-0 ml-2"})]},y)})]}),jsx("div",{className:"flex-1 overflow-y-auto",children:f?U(f):jsx("div",{className:"flex items-center justify-center h-full text-text-secondary text-sm",children:"Select a category to view filters"})})]}),V=()=>jsx(yi,{variant:"contained",density:"comfortable",showDividers:true,defaultExpandedKeys:[r[0].field],children:r.map(y=>F(y))});return jsx(Dr,{isOpen:e,onClose:t,title:v&&h&&f?f.startsWith("__ungrouped__")?C.find(y=>y.field===f.replace("__ungrouped__",""))?.label||s:f:w>0?`${s} (${w} active)`:s,hideCloseIcon:false,primaryAction:{label:"Apply filters",onPress:T,variant:"primary"},secondaryAction:{label:"Clear all",onPress:N},maxWidth:v?"800px":"700px",height:"600px",mobileHeight:"85vh",contentPadding:false,footerContent:l!==void 0?jsxs("div",{className:"text-sm text-text-secondary text-center",children:[jsx("span",{className:"font-semibold text-text-primary",children:Qy(l)})," ",l===1?"result":"results"," with current filters"]}):void 0,children:r.length===0?jsx("div",{className:"py-12 text-center",children:jsx("div",{className:"text-sm font-medium text-text-secondary",children:"No filters available"})}):v?h?K():O():V()})}function qm(e="left"){switch(e){case "center":return "justify-center text-center";case "right":return "justify-end text-right";default:return "justify-start text-left"}}function Gr(e="normal",t){return twMerge({strong:"font-semibold text-text-primary",high:"font-semibold text-text-primary",normal:"text-text-primary",low:"text-text-secondary"}[e],t&&"hover:text-action-primary cursor-pointer transition-colors")}function ke(e="left",t){return twMerge("flex items-center gap-1 min-w-0 overflow-hidden",qm(e),t)}function _c(e,t="\u2014"){return e==null||e===""?t:String(e)}var Jn={xs:"h-4 w-12",sm:"h-4 w-20",md:"h-4 w-24",lg:"h-4 w-32",xl:"h-4 w-40"};function Ft(e="normal"){return {strong:Jn.lg,high:Jn.lg,normal:Jn.md,low:Jn.sm}[e]}function ge(e,...t){return typeof e=="function"?e(...t):e}function $y(e="neutral",t="sm"){return twMerge("inline-flex items-center rounded-full font-medium",t==="sm"?"px-2 py-0.5 text-xs":"px-2.5 py-1 text-sm",{success:"bg-feedback-success-background text-feedback-success-text",error:"bg-feedback-error-background text-feedback-error-text",warning:"bg-feedback-warning-background text-feedback-warning-text",info:"bg-feedback-info-background text-feedback-info-text",neutral:"bg-background-muted text-text-secondary"}[e])}function ev(e){return e?"success":"neutral"}function $c(e,t=false){return t?e>0?"text-feedback-success-text":e<0?"text-feedback-error-text":"text-text-primary":"text-text-primary"}function Zm(e="hover",t="secondary"){let r={primary:"text-action-primary hover:text-action-primary-hover visited:text-action-primary",secondary:"text-text-link-default hover:text-text-link-hover visited:text-text-link-default",default:"text-text-link-default hover:text-text-link-hover visited:text-text-link-default",brand:"text-action-primary hover:text-action-primary-hover visited:text-action-primary",muted:"text-text-secondary hover:text-text-secondary visited:text-text-secondary",unstyled:""},o={visible:"underline underline-offset-4 decoration-1 cursor-pointer",hover:"hover:underline hover:underline-offset-4 hover:decoration-1 cursor-pointer transition-colors",none:"cursor-pointer"},n=r[t],a=o[e]||"";return `${n} ${a}`.trim()}function Yo(e,t,r,o="hover",n="secondary",a,i){if(!t)return e;let s=typeof t=="function"&&r?t(r):t,l=Zm(o,n);return jsx("a",{href:s,className:twMerge(l,a==="strong"||a==="high"?"font-semibold":"",i),onClick:c=>{c.metaKey||c.ctrlKey;},children:e})}function tv({row:e,context:t,actions:r,align:o="right",size:n="sm"}){let{isLoading:a}=t;if(a)return jsx(q,{className:Jn.sm});let s=(typeof r=="function"?r(e):r).filter(d=>!ge(d.hidden,e));if(s.length===0)return null;let l=ke(o);return jsx("div",{className:l,children:s.map(d=>{let c=ge(d.disabled,e);return d.variant==="icon"||!d.label?jsx(te,{variant:"icon",size:n,onPress:()=>{d.onClick(e);},isDisabled:c,"aria-label":d.label||d.id,children:jsx(G,{name:d.icon||"DotsThree",size:n==="sm"?16:20})},d.id):jsxs(te,{variant:d.variant||"secondary",size:n,onPress:()=>{d.onClick(e);},isDisabled:c,children:[d.icon&&jsx(G,{name:d.icon,size:n==="sm"?14:16}),d.label]},d.id)})})}function ov({value:e,row:t,context:r,variant:o="default",label:n,size:a="sm",shape:i="square",dot:s,dotPosition:l="left",dotPulse:d,align:c="left",emptyText:u="\u2014",className:m,maxVisible:p=2,maxLabelLength:g}){let{isLoading:f}=r,b=(w,T)=>{if(!g||w.length<=g)return jsx(Fragment,{children:w});let N=w.slice(0,g-1)+"\u2026";return jsx(tr,{content:T,children:jsx("span",{children:N})})};if(f)return jsx(q,{className:Ft("normal")});if(e==null||e==="")return jsx("div",{className:ke(c,"text-text-secondary"),children:u});if(Array.isArray(e)&&e.length===0)return jsx("div",{className:ke(c,"text-text-secondary"),children:u});let h=ke(c,m);if(Array.isArray(e)){let w=e.slice(0,p),T=e.slice(p),N=T.length>0;return jsx("div",{className:h,children:jsxs("div",{className:"flex items-center gap-1",children:[w.map((k,R)=>{let A=ge(o,k,t),M=n!==void 0?ge(n,k,t):String(k),B=ge(s,k,t),D=ge(d,k,t);return jsx("span",{className:"flex-shrink-0 whitespace-nowrap",children:jsx(kt,{variant:A,size:a,shape:i,dot:B,dotPosition:l,dotPulse:D,children:b(M,M)})},R)}),N&&jsx(tr,{content:T.join(", "),children:jsx("span",{className:"flex-shrink-0 whitespace-nowrap",children:jsxs(kt,{variant:"neutral",size:a,shape:i,children:["+",T.length]})})})]})})}let v=ge(o,e,t),x=n!==void 0?ge(n,e,t):String(e),C=ge(s,e,t),S=ge(d,e,t);return jsx("div",{className:h,children:jsx(kt,{variant:v,size:a,shape:i,dot:C,dotPosition:l,dotPulse:S,children:b(x,x)})})}function nv({value:e,context:t,format:r="icon",trueText:o="Yes",falseText:n="No",trueIcon:a="Check",falseIcon:i="X",showFalse:s=true,align:l="center",emphasis:d="normal",className:c}){let{isLoading:u}=t;if(u)return jsx(q,{className:Ft(d)});let m=!!e;if(!m&&!s)return jsx("div",{className:ke(l,c)});let p=ke(l,c);switch(r){case "icon":return jsx("div",{className:p,children:jsx(G,{name:m?a:i,size:16,className:m?"text-feedback-success-text":"text-text-disabled"})});case "text":return jsx("div",{className:p,children:jsx("span",{className:Gr(d),children:m?o:n})});case "badge":return jsx("div",{className:p,children:jsx(kt,{variant:m?"success":"neutral",size:"sm",children:m?o:n})});default:return null}}var ed="var(--color-text-subtle)",av=Tl().map((e,t)=>`var(--color-viz-categorical-${t+1})`);function sv({value:e,row:t,context:r,color:o,swatch:n="dot",emptyText:a="\u2014",align:i="left",className:s}){let{isLoading:l}=r;if(l)return jsx(q,{className:Ft("normal")});let d=ge(e,t),c=d==null?"":String(d);return c.length===0?jsx("div",{className:ke(i,"text-text-secondary"),children:a}):jsxs("div",{className:ke(i,twMerge("gap-2",s)),children:[jsx("span",{"aria-hidden":"true",className:twMerge("h-2 w-2 flex-shrink-0",n==="dot"?"rounded-full":"rounded-sm"),style:{backgroundColor:o??ed}}),jsx("span",{className:"truncate",children:c})]})}function cv({row:e,context:t,firstName:r,lastName:o,email:n,avatarUrl:a,layout:i="stacked",size:s="sm",href:l,LinkComponent:d,linkVariant:c="secondary",showEmail:u=false,badge:m,emphasis:p="normal",align:g="left",className:f,piiEntity:b}){let{isLoading:h}=t,v=ge(r,e),x=ge(o,e),C=ge(n,e),S=ge(a,e),w=ge(l,e),T=ge(m,e),N=ge(b,e),k=ke(g,f);return jsx("div",{className:k,children:jsx(lc,{firstName:v,lastName:x,email:C,avatarUrl:S,layout:i,size:s,href:w,LinkComponent:d,linkVariant:c,showEmail:u,badge:T,emphasis:p,isLoading:h,piiEntity:N})})}function dv({value:e,row:t,context:r,render:o,className:n}){let a=o(e,t,r);return jsx("div",{className:twMerge("h-full w-full",n),children:a})}function uv({value:e,row:t,context:r,format:o="date",customFormat:n,emptyText:a="\u2014",align:i="left",emphasis:s="normal",href:l,linkBehavior:d="hover",className:c}){let{isLoading:u}=r;if(u)return jsx(q,{className:Ft(s)});if(!e)return jsx("div",{className:ke(i,"text-text-secondary"),children:a});let m=e instanceof Date?e:new Date(e);if(isNaN(m.getTime()))return jsx("div",{className:ke(i,"text-text-secondary"),children:a});let p;switch(o){case "date":p=m.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});break;case "time":p=m.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"});break;case "datetime":p=m.toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});break;case "relative":p=RE(m);break;case "custom":p=n?m.toLocaleString("en-US",n):m.toISOString();break;default:p=m.toLocaleDateString();}let g=ke(i,twMerge(Gr(s),c)),f=ge(l,t);return f?jsx("div",{className:g,children:Yo(p,f,t,d)}):jsx("div",{className:g,children:p})}function RE(e){let r=new Date().getTime()-e.getTime(),o=Math.floor(r/1e3),n=Math.floor(o/60),a=Math.floor(n/60),i=Math.floor(a/24);return o<60?"just now":n<60?`${n} minute${n!==1?"s":""} ago`:a<24?`${a} hour${a!==1?"s":""} ago`:i<7?`${i} day${i!==1?"s":""} ago`:e.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}var EE={up:"ArrowUp",down:"ArrowDown",flat:"Minus"},LE={positive:"text-feedback-success-text",negative:"text-feedback-error-text",neutral:"text-text-secondary"};function Qm(e){return e>0?"up":e<0?"down":"flat"}function DE(e,t,r){switch(e){case "percent":return {type:"percentage",decimals:t};case "currency":return {type:"currency",currency:r,minimumFractionDigits:t,maximumFractionDigits:t};case "compact":return {type:"number",notation:"compact",decimals:t,thousandsSeparator:true};default:return {type:"number",decimals:t,thousandsSeparator:true}}}function pv({value:e,row:t,context:r,direction:o,tone:n="neutral",format:a="number",decimals:i=0,currency:s="USD",showIcon:l=true,align:d="right",emphasis:c="normal",emptyText:u="\u2014",className:m}){let{isLoading:p}=r;if(p)return jsx(q,{className:Ft(c)});let g=typeof e=="number"?e:Number(e);if(e==null||e===""||!Number.isFinite(g))return jsx("div",{className:ke(d,"text-text-secondary"),children:u});let f=ge(o,t)??Qm(g),b=ge(n,t)??"neutral",h=Xr(g,DE(a,i,s))??u,v=g>0?"+":"",C=ke(d,twMerge(c==="strong"||c==="high"?"font-semibold":void 0,m,LE[b]));return jsxs("div",{className:C,children:[l&&jsx(G,{name:EE[f],size:"xs","aria-hidden":true}),jsx("span",{children:`${v}${h}`})]})}var IE={open:{className:"text-feedback-success-border",token:"--color-feedback-success-border",label:"Open"},closed:{className:"text-feedback-error-border",token:"--color-feedback-error-border",label:"Closed"}},FE={platform:{label:"Platform",description:"Core product objects that structure the Texture workspace.",icon:"Stack",order:0},grid:{label:"Grid Elements",description:"Physical utility-grid infrastructure imported from a customer's GIS export.",icon:"TreeStructure",order:1},device:{label:"Devices",description:"Behind-the-meter connected energy devices.",icon:"Lightning",order:2}},BE=["energized","customerName","gs_max_continuous_current"],VE=["MOTOR.voltage"],OE=[{key:"total_kvar",label:"Rated kvar",format:{type:"power",unit:"kvar",decimals:1}}],zE=[{key:"kvar_a",label:"kvar A",format:{type:"power",unit:"kvar",decimals:1}},{key:"kvar_b",label:"kvar B",format:{type:"power",unit:"kvar",decimals:1}},{key:"kvar_c",label:"kvar C",format:{type:"power",unit:"kvar",decimals:1}}],xt={TRANSFORMER:[{key:"capacityKva",label:"kVA Rating",format:{type:"power",unit:"kVA",decimals:0}},{key:"phase",label:"Phase",format:{type:"text"}},{key:"primaryVoltageKv",label:"Primary Voltage",format:{type:"voltage",unit:"kV",decimals:1}},{key:"outputVoltageKv",label:"Output Voltage",format:{type:"voltage",unit:"kV",decimals:2}},{key:"manufacturer",label:"Manufacturer",format:{type:"text"}},{key:"xfmr_conductor_description",label:"Conductor",format:{type:"text"}}],CONSUMER:[{key:"service_address",label:"Service address",format:{type:"text"}},{key:"name",label:"Customer",format:{type:"text"}},{key:"account_number",label:"Account #",format:{type:"text"}},{key:"meterNumber",label:"Meter Number",format:{type:"text"}},{key:"service_type",label:"Service type",format:{type:"text"}}],SOURCE:[{key:"voltageKv",label:"Nominal Voltage",format:{type:"voltage",unit:"kV",decimals:1}},{key:"substationNumber",label:"Substation Number",format:{type:"text"}},{key:"trf_capacity",label:"Rated Capacity",format:{type:"text"}},{key:"connection_code",label:"Connection",format:{type:"text"}}],SWITCH:[{key:"switchId",label:"Switch ID",format:{type:"text"}},{key:"phase",label:"Phase",format:{type:"text"}},{key:"max_continuous_current",label:"Max Continuous Current",format:{type:"number",unit:"A",decimals:0}},{key:"switchIsOpen",label:"Position",format:{type:"text"}},{key:"switch_status",label:"Status",format:{type:"text"}},{key:"partnerIdentifier",label:"Partner ID",format:{type:"text"}}],CAPACITOR:[{key:"phase",label:"Phase",format:{type:"text"}},{key:"nominalVoltageV",label:"Nominal Voltage",format:{type:"voltage",unit:"V",decimals:0}}],OVERCURRENT_DEVICE:[{key:"size_value",label:"Size",format:{type:"text"}},{key:"phase",label:"Phase",format:{type:"text"}}],REGULATOR:[{key:"rated_kva",label:"Rated kVA",format:{type:"power",unit:"kVA",decimals:0}},{key:"phase",label:"Phase",format:{type:"text"}},{key:"manufacturer",label:"Manufacturer",format:{type:"text"}},{key:"high_side_configuration",label:"High Side",format:{type:"text"}},{key:"forwardSetVoltageV",label:"Forward Set Voltage",format:{type:"voltage",unit:"V",decimals:1}}],OVERHEAD_LINE:[{key:"impedanceLength",label:"Length",format:{type:"distance",unit:"ft",decimals:0}},{key:"conductorDescPhA",label:"Conductor Phase A",format:{type:"text"}},{key:"conductorDescPhB",label:"Conductor Phase B",format:{type:"text"}},{key:"conductorDescPhC",label:"Conductor Phase C",format:{type:"text"}},{key:"conductorDescNeutral",label:"Conductor Neutral",format:{type:"text"}},{key:"phase",label:"Phase",format:{type:"text"}},{key:"subtype_cd",label:"Subtype",format:{type:"text"}}],UNDERGROUND_LINE:[{key:"impedanceLength",label:"Length",format:{type:"distance",unit:"ft",decimals:0}},{key:"conductorDescPhA",label:"Conductor Phase A",format:{type:"text"}},{key:"conductorDescPhB",label:"Conductor Phase B",format:{type:"text"}},{key:"conductorDescPhC",label:"Conductor Phase C",format:{type:"text"}},{key:"phase",label:"Phase",format:{type:"text"}},{key:"subtype_cd",label:"Subtype",format:{type:"text"}}],NODE:[],SUPPORT_STRUCTURE:[{key:"height",label:"Height",format:{type:"distance",unit:"ft",decimals:0}},{key:"class",label:"Class",format:{type:"text"}},{key:"species",label:"Material",format:{type:"text"}},{key:"phase",label:"Phase",format:{type:"text"}},{key:"substation",label:"Substation",format:{type:"text"}}],GENERATOR:[{key:"phase",label:"Phase",format:{type:"text"}},{key:"generator_system_size",label:"System Size",format:{type:"number",decimals:1}}],MOTOR:[{key:"ratedPower",label:"Rated Power",format:{type:"power",unit:"kW",decimals:1}},{key:"voltage",label:"Voltage",format:{type:"voltage",unit:"V",decimals:0}}],DEVICE_LEADER:[],TRANSFORMER_BANK:[]},fn={app:{icon:"AppWindow",category:"platform",archetype:"platform",detailPage:false,label:{singular:"App",plural:"Apps"},description:"Workspace tools and third-party integrations"},site:{icon:"MapPin",category:"platform",archetype:"platform",detailPage:true,label:{singular:"Site",plural:"Sites"},description:"Physical location housing energy systems"},device:{icon:"ShareNetwork",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Device",plural:"Devices"},description:"Connected, controllable energy device"},customer:{icon:"Users",category:"platform",archetype:"platform",detailPage:true,label:{singular:"Customer",plural:"Customers"},description:"End customer or owner of one or more sites"},contact:{icon:"Users",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Contact",plural:"Contacts"},description:"Person associated with a customer or site"},program:{icon:"ClipboardText",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Program",plural:"Programs"},description:"Demand-response or virtual power plant program"},workflow:{icon:"FlowArrow",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Workflow",plural:"Workflows"},description:"Automated rule that runs in response to events"},collection:{icon:"Stack",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Collection",plural:"Collections"},description:"Named group of related entities or records"},board:{icon:"TextureBoards",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Board",plural:"Boards"},description:"Dashboard for monitoring metrics and devices"},report:{icon:"ChartLine",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Report",plural:"Reports"},description:"Saved analytics view or generated report"},event:{icon:"ClockCounterClockwise",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Event",plural:"Events"},description:"Recorded system event or logged activity"},alert:{icon:"Warning",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Alert",plural:"Alerts"},description:"Notification raised when attention is needed"},monitor:{icon:"TextureMonitors",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Monitor",plural:"Monitors"},description:"Rule that watches a metric against a threshold"},insight:{icon:"LightbulbFilament",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Insight",plural:"Insights"},description:"Derived finding surfaced from platform data"},command:{icon:"Play",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Command",plural:"Commands"},description:"Control action issued to a connected device"},explore:{icon:"TextureExplore",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Explore",plural:"Explore"},description:"The BEAM map surface for exploring the connected grid."},boards:{icon:"TextureBoards",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Boards",plural:"Boards"},description:"The BEAM surface for building and viewing grid dashboards."},monitors:{icon:"TextureMonitors",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Monitors",plural:"Monitors"},description:"The BEAM surface for watching conditions across the grid."},askTexture:{icon:"Sparkle",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Ask Texture",plural:"Ask Texture"},description:"The BEAM conversational surface for investigating grid data and creating views and monitors."},survey:{icon:"TextureSurvey",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Survey",plural:"Survey"},description:"The onboarding engagement that maps a utility's systems to the Terrain schema."},seismic:{icon:"TextureSeismic",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Seismic",plural:"Seismic"},description:"AI-powered interpretation of raw data, automatically mapped into the grid model."},waypoint:{icon:"TextureWaypoint",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Waypoint",plural:"Waypoint"},description:"Flexible customer data collection and authorization for consumer devices."},terrain:{icon:"TextureTerrain",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Terrain",plural:"Terrain"},description:"The shared schema for grid assets, locations, and relationships. An AI-ready data model standard."},magma:{icon:"TextureMagma",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Magma",plural:"Magma"},description:"The execution engine for streaming, monitoring, automation, insights, and simulations, using data in the Terrain schema."},ground:{icon:"TextureGround",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Ground",plural:"Ground"},description:"On-premises hardware Stations for local control, AI processing, and continuity when cloud connectivity drops."},source:{icon:"TextureSource",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.SOURCE},label:{singular:"Source",plural:"Sources"},description:"Upstream feed where the network originates"},substation:{icon:"TextureSource",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.SOURCE},label:{singular:"Substation",plural:"Substations"},description:"Facility that steps down transmission voltage"},capacitor:{icon:"TextureCapacitor",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.CAPACITOR},label:{singular:"Capacitor",plural:"Capacitors"},description:"Capacitor bank for power-factor and voltage support"},switch:{icon:"TextureSwitchClosed",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.SWITCH},label:{singular:"Switch",plural:"Switches"},description:"Sectionalizing or disconnect switch on the line",states:{open:{icon:"TextureSwitch",color:"open"},closed:{icon:"TextureSwitchClosed",color:"closed"}}},sectionalizer:{icon:"TextureSectionalizerClosed",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.SWITCH},label:{singular:"Sectionalizer",plural:"Sectionalizers"},description:"Counts upstream recloser trips and opens to isolate a faulted section",states:{open:{icon:"TextureSectionalizerOpen",color:"open"},closed:{icon:"TextureSectionalizerClosed",color:"closed"}}},relay:{icon:"Cpu",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.NODE},label:{singular:"Relay",plural:"Relays"},description:"Microprocessor relay that senses faults and trips devices"},transformer:{icon:"TextureTransformer",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.TRANSFORMER},label:{singular:"Transformer",plural:"Transformers"},description:"Transformer that steps voltage up or down"},meter:{icon:"Gauge",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.CONSUMER},label:{singular:"Meter",plural:"Meters"},description:"Revenue meter at the point of consumption"},consumer:{icon:"Gauge",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.CONSUMER},label:{singular:"Consumer",plural:"Consumers"},description:"Service point or customer premise on the grid"},singlePhaseOverheadLine:{icon:"TextureSinglePhaseOverheadLine",category:"grid",archetype:"grid-line",detailPage:true,properties:{statList:xt.OVERHEAD_LINE},label:{singular:"Single-Phase Overhead Line",plural:"Single-Phase Overhead Lines"},description:"Overhead line carrying one phase conductor"},twoPhaseOverheadLine:{icon:"TextureTwoPhaseOverheadLine",category:"grid",archetype:"grid-line",detailPage:true,properties:{statList:xt.OVERHEAD_LINE},label:{singular:"Two-Phase Overhead Line",plural:"Two-Phase Overhead Lines"},description:"Overhead line carrying two phase conductors"},threePhaseOverheadLine:{icon:"TextureThreePhaseOverheadLine",category:"grid",archetype:"grid-line",detailPage:true,properties:{statList:xt.OVERHEAD_LINE},label:{singular:"Three-Phase Overhead Line",plural:"Three-Phase Overhead Lines"},description:"Overhead line carrying three phase conductors"},singlePhaseUndergroundLine:{icon:"TextureSinglePhaseUndergroundLine",category:"grid",archetype:"grid-line",detailPage:true,properties:{statList:xt.UNDERGROUND_LINE},label:{singular:"Single-Phase Underground Line",plural:"Single-Phase Underground Lines"},description:"Buried line carrying one phase conductor"},twoPhaseUndergroundLine:{icon:"TextureTwoPhaseUndergroundLine",category:"grid",archetype:"grid-line",detailPage:true,properties:{statList:xt.UNDERGROUND_LINE},label:{singular:"Two-Phase Underground Line",plural:"Two-Phase Underground Lines"},description:"Buried line carrying two phase conductors"},threePhaseUndergroundLine:{icon:"TextureThreePhaseUndergroundLine",category:"grid",archetype:"grid-line",detailPage:true,properties:{statList:xt.UNDERGROUND_LINE},label:{singular:"Three-Phase Underground Line",plural:"Three-Phase Underground Lines"},description:"Buried line carrying three phase conductors"},motorSwitch:{icon:"Diamond",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.MOTOR},label:{singular:"Motor Switch",plural:"Motor Switches"},description:"Motor-operated switch or motor load element"},recloser:{icon:"TextureRecloser",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.OVERCURRENT_DEVICE},label:{singular:"Recloser",plural:"Reclosers"},description:"Auto-reclosing device that clears transient faults",states:{open:{color:"open"},closed:{color:"closed"}}},fuse:{icon:"TextureFuse",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.OVERCURRENT_DEVICE},label:{singular:"Fuse",plural:"Fuses"},description:"Fusible element providing overcurrent protection"},breaker:{icon:"TextureBreaker",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.OVERCURRENT_DEVICE},label:{singular:"Breaker",plural:"Breakers"},description:"Circuit breaker that interrupts fault current",states:{open:{color:"open"},closed:{color:"closed"}}},generator:{icon:"Wind",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.GENERATOR},label:{singular:"Generator",plural:"Generators"},description:"Distributed generation unit feeding the grid"},regulator:{icon:"TextureRegulator",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.REGULATOR},label:{singular:"Regulator",plural:"Regulators"},description:"Voltage regulator that holds line voltage in range"},supportStructure:{icon:"TextureSupportStructure",category:"grid",archetype:"grid-line",detailPage:true,properties:{statList:xt.SUPPORT_STRUCTURE},label:{singular:"Support Structure",plural:"Support Structures"},description:"Structure carrying overhead line equipment"},deviceLeader:{icon:"FlowArrow",category:"grid",archetype:"grid-line",detailPage:true,properties:{statList:xt.DEVICE_LEADER},label:{singular:"Device Leader",plural:"Device Leaders"},description:"Cartographic leader line pointing an offset device symbol to its true location"},transformerBank:{icon:"TextureTransformer",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.TRANSFORMER_BANK},label:{singular:"Transformer Bank",plural:"Transformer Banks"},description:"Grouping of single-phase transformer units sharing a bank id"},battery:{icon:"BatteryHigh",category:"device",archetype:"device",detailPage:true,label:{singular:"Battery",plural:"Batteries"},description:"Behind-the-meter battery or storage system",fusedMetricId:"soc",fields:{headlineMetrics:[{id:"power",label:"device.battery.fields.gridPower",source:{kind:"state",path:"state.gridPower"},format:{type:"power",decimals:1},icon:"Lightning"},{id:"soc",label:"device.battery.fields.soc",source:{kind:"state",path:"state.chargePercentage"},format:{type:"percentage",decimals:0},icon:"BatteryCharging"},{id:"batteryPower",label:"device.battery.fields.batteryPower",source:{kind:"state",path:"state.chargeRate"},format:{type:"power",decimals:1},icon:"TrendUp"},{id:"backupReserve",label:"device.battery.fields.backupReserve",source:{kind:"state",path:"state.backupReserve"},format:{type:"percentage",decimals:0},icon:"BatteryCharging"}]},stateRules:{primaryState:{label:"device.battery.fields.status",fieldPath:"state.chargingState",mapping:{charging:"charging",discharging:"discharging",idle:"idle",unknown:"unknown"},fallback:"unknown"},secondaryState:{label:"device.battery.fields.gridState",fieldPath:"state.gridStatus",mapping:{importing:"importing",exporting:"exporting",idle:"idle",unknown:"unknown"},fallback:"unknown"}}},evCharger:{icon:"ChargingStation",category:"device",archetype:"device",detailPage:true,label:{singular:"EV Charger",plural:"EV Chargers"},description:"Electric-vehicle charging station or port",fusedMetricId:"power",fields:{headlineMetrics:[{id:"power",label:"device.evCharger.fields.power",source:{kind:"state",path:"state.chargerWattage"},format:{type:"power",decimals:1},icon:"Lightning"},{id:"isPluggedIn",label:"device.evCharger.fields.isPluggedIn",source:{kind:"state",path:"state.isPluggedIn"},format:{type:"boolean",trueText:"Yes",falseText:"No"},icon:"Plug"},{id:"voltage",label:"device.evCharger.fields.voltage",source:{kind:"state",path:"state.chargerVoltage"},format:{type:"voltage",decimals:1},icon:"Lightning"},{id:"current",label:"device.evCharger.fields.current",source:{kind:"state",path:"state.chargerCurrent"},format:{type:"current",decimals:1},icon:"Lightning"}]},stateRules:{primaryState:{label:"device.evCharger.fields.status",fieldPath:"state.chargingState",mapping:{charging:"charging",discharging:"discharging",idle:"idle",unknown:"unknown"},fallback:"unknown"}}},inverter:{icon:"Sun",category:"device",archetype:"device",detailPage:true,label:{singular:"Solar / Inverter",plural:"Solar / Inverters"},description:"Solar PV inverter and its connected array",fusedMetricId:"power",fields:{headlineMetrics:[{id:"power",label:"device.inverter.fields.power",source:{kind:"state",path:"state.power"},format:{type:"power",decimals:0},icon:"Lightning"},{id:"gridPower",label:"device.inverter.fields.gridPower",source:{kind:"state",path:"state.gridPower"},format:{type:"power",decimals:0},icon:"GridFour"},{id:"generatedEnergy",label:"device.inverter.fields.generatedEnergy",source:{kind:"state",path:"state.generatedEnergy"},format:{type:"energy",decimals:1},icon:"Lightning"},{id:"lifetimeEnergyGenerated",label:"device.inverter.fields.lifetimeEnergyGenerated",source:{kind:"state",path:"state.lifetimeEnergyGenerated"},format:{type:"energy",decimals:0},icon:"Lightning"}]},stateRules:{primaryState:{label:"device.inverter.fields.gridStatus",fieldPath:"state.gridStatus",mapping:{exporting:"exporting",importing:"importing",idle:"idle"},fallback:"unknown"}}},sensor:{icon:"TextureSensor",category:"device",archetype:"device",detailPage:true,label:{singular:"Sensor",plural:"Sensors"},description:"Connected grid and power-quality sensor"},thermostat:{icon:"Thermometer",category:"device",archetype:"device",detailPage:true,label:{singular:"Thermostat",plural:"Thermostats"},description:"Smart thermostat or connected HVAC control",fusedMetricId:"ambientTemperature",fields:{headlineMetrics:[{id:"ambientTemperature",label:"device.thermostat.fields.ambientTemperature",source:{kind:"state",path:"state.ambientTemperature"},format:{type:"temperature",decimals:0},icon:"Thermometer"},{id:"heatTarget",label:"device.thermostat.fields.heatTarget",source:{kind:"state",path:"state.heatTarget"},format:{type:"temperature",decimals:0},icon:"Flame"},{id:"coolTarget",label:"device.thermostat.fields.coolTarget",source:{kind:"state",path:"state.coolTarget"},format:{type:"temperature",decimals:0},icon:"Snowflake"},{id:"fanMode",label:"device.thermostat.fields.fanMode",source:{kind:"state",path:"state.fanMode"},format:{type:"text"}}]},stateRules:{primaryState:{label:"device.thermostat.fields.operatingMode",fieldPath:"state.operatingMode",mapping:{heat:"heat",cool:"cool",auto:"auto",off:"off",eco:"eco",unknown:"unknown"},fallback:"unknown"}}},vehicle:{icon:"Car",category:"device",archetype:"device",detailPage:true,label:{singular:"EV",plural:"EVs"},description:"Electric vehicle managed as a flexible load",fusedMetricId:"chargePercentage",fields:{headlineMetrics:[{id:"chargePercentage",label:"device.vehicle.fields.chargePercentage",source:{kind:"state",path:"state.chargePercentage"},format:{type:"percentage",decimals:0},icon:"BatteryCharging"},{id:"range",label:"device.vehicle.fields.range",source:{kind:"state",path:"state.range"},format:{type:"distance",unit:"mi",decimals:0},icon:"GasPump"},{id:"chargeLimit",label:"device.vehicle.fields.chargeLimit",source:{kind:"state",path:"state.chargeLimit"},format:{type:"percentage",decimals:0},icon:"BatteryCharging"},{id:"isPluggedIn",label:"device.vehicle.fields.isPluggedIn",source:{kind:"state",path:"state.isPluggedIn"},format:{type:"boolean",trueText:"Yes",falseText:"No"},icon:"Plug"}]},stateRules:{primaryState:{label:"device.vehicle.fields.status",fieldPath:"state.chargingState",mapping:{charging:"charging",discharging:"discharging",idle:"idle",unknown:"unknown"},fallback:"unknown"}}},waterHeater:{icon:"Drop",category:"device",archetype:"device",detailPage:true,label:{singular:"Water Heater",plural:"Water Heaters"},description:"Connected or smart electric water heater"}},mv=Object.freeze(Object.keys(fn).filter(e=>fn[e].category==="grid")),HE=new Set(mv);function GE(e){return typeof e=="string"&&HE.has(e)}var WE={source:"SOURCE",substation:"SOURCE",capacitor:"CAPACITOR",switch:"SWITCH",sectionalizer:"SWITCH",relay:"NODE",transformer:"TRANSFORMER",meter:"CONSUMER",consumer:"CONSUMER",singlePhaseOverheadLine:"OVERHEAD_LINE",twoPhaseOverheadLine:"OVERHEAD_LINE",threePhaseOverheadLine:"OVERHEAD_LINE",singlePhaseUndergroundLine:"UNDERGROUND_LINE",twoPhaseUndergroundLine:"UNDERGROUND_LINE",threePhaseUndergroundLine:"UNDERGROUND_LINE",motorSwitch:"MOTOR",recloser:"OVERCURRENT_DEVICE",fuse:"OVERCURRENT_DEVICE",breaker:"OVERCURRENT_DEVICE",generator:"GENERATOR",regulator:"REGULATOR",supportStructure:"SUPPORT_STRUCTURE",deviceLeader:"DEVICE_LEADER",transformerBank:"TRANSFORMER_BANK"};function od(e){return fn[e]}function Gs(e){return fn[e].icon}function UE(e,t=false){return t?fn[e].label.plural:fn[e].label.singular}function KE(e){return fn[e].category}var YE={min:2,max:4};function XE(e){let t=fn[e];if(!t)throw new Error(`archetypeFor: unknown entity type "${String(e)}"`);return t.archetype}function JE(e){return od(e).detailPage}function jE(e){return (od(e).fields?.headlineMetrics.length??0)>0}function fv(e){return od(e).properties?.statList??[]}function qE(e){return fv(e).length>0}function nd({manufacturer:e,model:t,deviceType:r,deviceTypeIconName:o,logoUrl:n,layout:a="stacked",size:i="md",href:s,LinkComponent:l,linkVariant:d="unstyled",showDeviceTypeIcon:c=true,showLogo:u=true,emphasis:m="normal",isLoading:p=false,className:g,piiEntity:f}){let[b,h]=useState(false),v=o||(r?QE(r):"DeviceMobile"),C={xs:{iconSize:28,logoSize:"w-7 h-7",gap:"gap-1.5",textSize:"text-xs",secondaryTextSize:"text-xs",iconInTextSize:12,skeletonIcon:28,skeletonText:80,skeletonSecondary:60},sm:{iconSize:32,logoSize:"w-8 h-8",gap:"gap-2",textSize:"text-sm",secondaryTextSize:"text-xs",iconInTextSize:14,skeletonIcon:32,skeletonText:96,skeletonSecondary:72},md:{iconSize:32,logoSize:"w-9 h-9",gap:"gap-3",textSize:"text-base",secondaryTextSize:"text-sm",iconInTextSize:16,skeletonIcon:36,skeletonText:128,skeletonSecondary:96},lg:{iconSize:40,logoSize:"w-10 h-10",gap:"gap-3",textSize:"text-lg",secondaryTextSize:"text-base",iconInTextSize:18,skeletonIcon:40,skeletonText:160,skeletonSecondary:120}}[i],S=n&&!b&&u,T={strong:"font-semibold text-text-primary",high:"font-semibold text-text-primary",normal:"text-text-primary",low:"text-text-secondary"}[m],N=({children:k,className:R})=>s?l?jsx(l,{href:s,className:R,children:k}):jsx(St,{href:s,variant:d,className:twMerge("hover:underline",R),asButton:false,children:k}):jsx("span",{className:R,children:k});if(p)return a==="inline"?jsxs("div",{className:twMerge("flex items-center",C.gap,g),children:[jsx(q,{width:C.skeletonIcon,height:C.skeletonIcon,className:"flex-shrink-0 rounded"}),jsx(q,{width:C.skeletonText,height:C.skeletonIcon*.6})]}):jsxs("div",{className:twMerge("flex items-center",C.gap,g),children:[jsx(q,{width:C.skeletonIcon,height:C.skeletonIcon,className:"flex-shrink-0"}),jsxs("div",{className:"flex flex-col gap-1",children:[jsx(q,{width:C.skeletonText,height:16}),jsx(q,{width:C.skeletonSecondary,height:12})]})]});if(a==="inline"){let k=`${e} ${t}`;return jsxs("div",{className:twMerge("flex items-center",C.gap,g),children:[jsx("div",{className:twMerge("flex-shrink-0 flex items-center justify-center rounded border border-border-muted",C.logoSize),children:S?jsx("img",{src:n,alt:`${e} logo`,className:"w-full h-full object-contain",onError:()=>h(true)}):jsx(G,{name:v,size:C.iconSize*.6,className:"text-text-secondary"})}),jsx(N,{className:twMerge("truncate leading-normal hover:text-text-primary",T,C.textSize,s&&"hover:underline hover:decoration-1 hover:underline-offset-4"),children:jsx("span",{"data-pii-type":f?"device-name":void 0,"data-pii-entity":f,children:k})})]})}return jsxs("div",{className:twMerge("flex items-center justify-start",C.gap,g),children:[u&&jsx("div",{className:twMerge("flex-shrink-0 flex items-center justify-center rounded border border-border-muted",C.logoSize),children:S?jsx("img",{src:n,alt:`${e} logo`,className:"w-full h-full object-contain",onError:()=>h(true)}):jsx(G,{name:v,size:C.iconSize*.6,className:"text-text-secondary"})}),jsxs("div",{className:"flex flex-col items-start min-w-0",children:[jsx(N,{className:twMerge("truncate leading-normal hover:text-text-primary",T,C.textSize,s&&"hover:underline hover:decoration-1 hover:underline-offset-4"),children:jsx("span",{"data-pii-type":f?"device-name":void 0,"data-pii-entity":f,children:e})}),jsxs("div",{className:twMerge("flex items-center gap-1.5 text-text-secondary leading-normal",C.secondaryTextSize),children:[c&&jsx(G,{name:v,size:C.iconInTextSize,className:"flex-shrink-0"}),jsx("span",{className:"truncate","data-pii-type":f?"device-name":void 0,"data-pii-entity":f,children:t})]})]})]})}function QE(e){switch(e){case "battery":return "BatteryHigh";case "charger":return "ChargingStation";case "inverter":return "Power";case "thermostat":return "ThermometerSimple";case "vehicle":return "CarSimple";case "water_heater":return "DropHalfBottom";case "meter":return "Gauge";case "sensor":return Gs("sensor");default:return "DeviceMobile"}}function hv({row:e,context:t,manufacturer:r,model:o,deviceType:n,logoUrl:a,layout:i="stacked",size:s="sm",href:l,LinkComponent:d,linkVariant:c="secondary",showDeviceTypeIcon:u=true,showLogo:m=true,emphasis:p="normal",align:g="left",className:f,piiEntity:b}){let{isLoading:h}=t,v=ge(r,e),x=ge(o,e),C=ge(n,e),S=ge(a,e),w=ge(l,e),T=ge(b,e),N=ke(g,f);return jsx("div",{className:N,children:jsx(nd,{manufacturer:v,model:x,deviceType:C,logoUrl:S,layout:i,size:s,href:w,LinkComponent:d,linkVariant:c,showDeviceTypeIcon:u,showLogo:m,emphasis:p,isLoading:h,piiEntity:T})})}var MZ={charging:"percentage",discharging:"percentage",on:"kW",idle:void 0,off:void 0,heat:"temperature",cool:"temperature",auto:"temperature",eco:"temperature",circulate:void 0,unknown:void 0,connected:void 0,disconnected:void 0},_E=["charging","discharging","heat","cool","on","circulate","connected"],$E={unknown:"Unknown",on:"On",off:"Off",idle:"Idle",charging:"Charging",discharging:"Discharging",heat:"Heating",eco:"Eco Mode",cool:"Cooling",auto:"Auto",circulate:"Circulating",connected:"Connected",disconnected:"Disconnected"};function _m(e){return _E.includes(e)}function $m(e){return $E[e]}function Aa({state:e,label:t,icon:r,isLoading:o,size:n="sm",shape:a="pill",dot:i,dotPulse:s,fixedWidth:l,className:d,...c}){if(o)return jsx(q,{className:"inline-flex h-6 w-20"});let u=t??$m(e),m=_m(e);return jsxs(kt,{variant:e,size:n,shape:a,dot:i??m,dotPulse:s??m,className:l?`w-28 justify-center ${d||""}`:d,...c,children:[r&&jsx(G,{name:r,size:n==="sm"?12:n==="md"?14:16}),u]})}var tL={importing:"Importing",exporting:"Exporting",idle:"Idle",unknown:"Unknown"};function xv(e){return tL[e]}var rL={importing:"ArrowDown",exporting:"ArrowUp"};function id({state:e,label:t,showIcon:r=false,isLoading:o,size:n="sm",shape:a="pill",fixedWidth:i,className:s,...l}){if(o)return jsx(q,{className:"inline-flex h-6 w-24"});let d=t??xv(e),c=rL[e],u=n==="sm"?12:n==="md"?14:16;return r&&c?jsx(kt,{variant:e,size:n,shape:a,className:`w-6 justify-center ${s||""}`,...l,children:jsx(G,{name:c,size:u})}):jsx(kt,{variant:e,size:n,shape:a,className:i?`w-28 justify-center ${s||""}`:s,...l,children:d})}function sd({state:e,stateLabel:t,metric:r,metricFormatter:o,secondaryState:n,layout:a="horizontal",isLoading:i,size:s="sm",shape:l="pill",icon:d,fixedWidth:c,secondaryStateIconOnly:u=false,className:m}){if(i)return jsx(q,{className:twMerge("inline-flex h-6 w-32",m)});let p=r!=null&&o?Xr(r,o):null,g=a==="horizontal",f=o&&!p;return jsxs("div",{className:twMerge("inline-flex items-center",g?"gap-2":"flex-col gap-1",m),children:[(p||f)&&jsx("span",{className:twMerge("font-medium inline-block",p?"text-text-primary":"text-text-secondary",s==="sm"&&"text-xs min-w-12",s==="md"&&"text-sm min-w-14",s==="lg"&&"text-base min-w-16"),children:p||"\u2014"}),jsx(Aa,{state:e,label:t,icon:d,size:s,shape:l,fixedWidth:c}),n&&jsx(Fragment,{children:n==="importing"||n==="exporting"?jsx(id,{state:n,size:s,shape:l,fixedWidth:c,showIcon:u}):jsx(Aa,{state:n,size:s,shape:l,fixedWidth:c})})]})}function yv({value:e,row:t,context:r,metric:o,metricFormatter:n,secondaryState:a,size:i="sm",shape:s="pill",label:l,icon:d,fixedWidth:c=true,align:u="left",compact:m=false,className:p}){let{isLoading:g}=r;if(g){let C={pill:"rounded-full",rounded:"rounded-lg",square:"rounded-sm"}[s],S=o!=null||n!=null;return jsx("div",{className:"flex items-center gap-2",children:S?jsxs(Fragment,{children:[jsx(q,{className:"h-4 w-12"}),jsx(q,{className:`h-6 w-24 ${C}`}),jsx(q,{className:`h-6 w-20 ${C}`})]}):jsx(q,{className:`h-6 w-24 ${C}`})})}if(!e)return jsx("div",{className:ke(u,p),children:jsx("span",{className:"text-text-secondary",children:"\u2014"})});let f=ge(o,t),b=ge(a,t),h=typeof l=="function"?l(e,t):l,v=ke(u,p);return f!=null||n?jsx("div",{className:twMerge(v),children:jsx(sd,{state:e,stateLabel:h,metric:f,metricFormatter:n,secondaryState:b||void 0,size:i,shape:s,icon:d,fixedWidth:c,secondaryStateIconOnly:m,layout:"horizontal"})}):jsx("div",{className:v,children:jsx(Aa,{state:e,label:h,icon:d,size:i,shape:s,fixedWidth:c})})}function Cv({value:e,row:t,context:r,formatter:o,align:n="left",emphasis:a="normal",href:i,linkBehavior:s="hover",className:l,emptyText:d="\u2014",emptyClassName:c="text-text-secondary"}){let{isLoading:u}=r;if(u)return jsx(q,{className:Ft(a)});let m=Ao({value:e,formatter:o,emptyText:d,emptyClassName:c}),p=Gr(a),g=ke(n,twMerge(p,l)),f=jsx("div",{className:g,children:m}),b=ge(i,t);return b?Yo(f,b,t,s):f}var tf=ot__default.memo(({value:e,min:t,max:r,color:o="var(--color-viz-default)",backgroundColor:n="var(--color-background-muted)",colorScale:a,showLabel:i=true,formatLabel:s,height:l=20,minWidth:d=4,segments:c,segmentGap:u=2,barWidth:m,context:p})=>{let g=useMemo(()=>r===t?100:Math.max(0,Math.min(100,(e-t)/(r-t)*100)),[e,t,r]),f=useMemo(()=>o==="auto"&&a?a.type==="diverging"&&a.center!==void 0?ns(e,t,r,a.center,a.scheme):os(e,t,r,a.scheme):o,[o,a,e,t,r]);if(p.isLoading)return jsx("div",{className:"flex items-center gap-2 w-full",style:{height:l},children:jsx("div",{className:"h-full flex-1 animate-pulse bg-border-default rounded"})});if(c&&c>0){let v=`calc((100% - ${u*(c-1)}px) / ${c})`,x=Math.ceil(g/100*c),C={height:l,...m&&{width:typeof m=="number"?`${m}px`:m,flexShrink:0}};return jsxs("div",{className:"flex items-center gap-2 w-full",children:[jsx("div",{className:`flex gap-0.5 ${m?"":"flex-1"}`,style:C,children:Array.from({length:c}).map((S,w)=>{let T=w<x;return jsx("div",{className:"rounded-sm",style:{width:v,backgroundColor:T?f:n==="none"?"transparent":n,marginRight:w<c-1?`${u}px`:0}},w)})}),i&&jsx("span",{className:"text-sm text-text-primary whitespace-nowrap",children:s?s(e):e.toLocaleString()})]})}let b={height:l,backgroundColor:n==="none"?"transparent":n,...m&&{width:typeof m=="number"?`${m}px`:m,flexShrink:0}};return jsxs("div",{className:"flex items-center gap-2 w-full",children:[jsx("div",{className:`relative rounded-sm ${m?"":"flex-1"}`,style:b,children:jsx("div",{className:"absolute left-0 top-0 h-full rounded-sm",style:{width:`${g}%`,minWidth:g>0?d:0,backgroundColor:f}})}),i&&jsx("span",{className:"text-sm text-text-primary whitespace-nowrap",children:s?s(e):e.toLocaleString()})]})});tf.displayName="HorizontalBarCell";function uL(e){return Math.max(1,String(Math.max(1,Math.trunc(e))).length)}function Tv({context:e,startAt:t=1,padTo:r,rowCount:o,align:n="right",className:a}){let{isLoading:i,rowIndex:s}=e;if(i)return jsx(q,{className:Ft("normal")});if(typeof s!="number"||!Number.isFinite(s))return jsx("div",{className:ke(n,"text-text-muted"),children:"\u2014"});let l=s+t,d=r??(o===void 0?void 0:uL(o+t-1)),c=d===void 0?String(l):String(l).padStart(d,"0");return jsx("div",{className:ke(n,twMerge("font-mono text-text-muted tabular-nums",a)),children:jsx("span",{children:c})})}var rf=ot__default.memo(({value:e,data:t,color:r="var(--color-viz-default)",categoryColors:o,context:n,width:a,height:i=40})=>{let s=e||t||[],l=b=>"xValue"in b?b.xValue:b.x,d=b=>"yValue"in b?b.yValue:b.y,c=a||100,u=i,{xScale:m,yScale:p,barWidth:g}=useMemo(()=>{if(s.length===0)return {xScale:scaleTime({range:[0,c],domain:[new Date,new Date]}),yScale:scaleLinear({range:[u,0],domain:[0,1]}),barWidth:2};let b=extent(s,T=>l(T)),h=min(s,T=>d(T))??0,v=max(s,T=>d(T))??0,x=h<0?h:0,C=scaleTime({range:[0,c],domain:b}),S=scaleLinear({range:[u,0],domain:[x,v*1.05]}),w=s.length>1?c/s.length*.8:8;return {xScale:C,yScale:S,barWidth:Math.max(2,w)}},[s,c,u]);if(n.isLoading)return jsx("div",{className:"flex items-center gap-0.5",style:{width:c,height:u},children:Array.from({length:5}).map((b,h)=>jsx("div",{className:"flex-1 animate-pulse bg-border-default rounded"},h))});if(!s||s.length===0)return jsx("div",{className:"flex items-center justify-center text-text-secondary text-xs",style:{width:c,height:u},children:"No data"});let f=p(0);return jsx("svg",{width:c,height:u,children:s.map((b,h)=>{let v=d(b),x=m(l(b)),C=p(v),S=Math.abs(f-C),w=b.category&&o?.[b.category]?o[b.category]:r;return jsx(Bar,{x:x-g/2,y:v>=0?C:f,width:g,height:S,fill:w,rx:1},`bar-${h}`)})})});rf.displayName="MiniBarCell";function Pv({value:e,row:t,context:r,format:o="number",decimals:n=0,prefix:a,suffix:i,emptyText:s="\u2014",align:l="right",emphasis:d="normal",href:c,linkBehavior:u="hover",showPositiveSign:m=false,colorCode:p=false,className:g}){let{isLoading:f}=r;if(f)return jsx(q,{className:Ft(d)});if(e==null||isNaN(Number(e)))return jsx("div",{className:ke(l,"text-text-secondary"),children:s});let b=Number(e),h;switch(o){case "currency":h=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:n,maximumFractionDigits:n}).format(b);break;case "percent":h=new Intl.NumberFormat("en-US",{style:"percent",minimumFractionDigits:n,maximumFractionDigits:n}).format(b/100);break;case "compact":h=new Intl.NumberFormat("en-US",{notation:"compact",minimumFractionDigits:n>0?1:0,maximumFractionDigits:n}).format(b);break;default:h=new Intl.NumberFormat("en-US",{minimumFractionDigits:n,maximumFractionDigits:n}).format(b);}let x=`${m&&b>0?"+":""}${h}`,C=p?$c(b,true):Gr(d),S=ke(l,twMerge(C,g)),w=jsxs(Fragment,{children:[a&&jsx("span",{className:"text-text-secondary",children:a}),jsx("span",{children:x}),i&&jsx("span",{className:"text-text-secondary",children:i})]}),T=ge(c,t);return T?jsx("div",{className:S,children:Yo(w,T,t,u)}):jsx("div",{className:S,children:w})}var SL={low:"var(--color-feedback-warning-text)",critical:"var(--color-feedback-error-text)"};function nf(e,t){if(t){if(t.critical!==void 0&&e<=t.critical)return "critical";if(t.low!==void 0&&e<=t.low)return "low"}}var af=ot__default.memo(({value:e,showLabel:t=true,color:r="var(--color-viz-categorical-1)",backgroundColor:o="var(--color-background-muted)",height:n=20,segments:a,segmentGap:i=2,colorScale:s,thresholds:l,context:d})=>{let c=useMemo(()=>Math.max(0,Math.min(100,e)),[e]),u=useMemo(()=>nf(c,l),[c,l]),m=useMemo(()=>u?SL[u]:r==="auto"&&s?s.type==="diverging"&&s.center!==void 0?ns(e,0,100,s.center,s.scheme):os(e,0,100,s.scheme):r,[r,s,u,e]);if(d.isLoading)return jsx("div",{className:"flex items-center gap-2",style:{height:n},children:jsx("div",{className:"h-full w-full animate-pulse bg-border-default rounded"})});if(a&&a>0){let g=`calc((100% - ${i*(a-1)}px) / ${a})`,f=Math.ceil(c/100*a);return jsxs("div",{className:"flex items-center gap-2 w-full","data-threshold":u,children:[jsx("div",{className:"flex gap-0.5 flex-1",style:{height:n},children:Array.from({length:a}).map((b,h)=>{let v=h<f,x=m;if(!u&&r==="auto"&&s&&v){let C=(h+1)/a*100;s.type==="diverging"&&s.center!==void 0?x=ns(C,0,100,s.center,s.scheme):x=os(C,0,100,s.scheme);}return jsx("div",{className:"rounded-sm",style:{width:g,backgroundColor:v?x:o==="none"?"transparent":o,marginRight:h<a-1?`${i}px`:0}},h)})}),t&&jsxs("span",{className:"text-sm text-text-primary whitespace-nowrap",children:[c.toFixed(0),"%"]})]})}return jsxs("div",{className:"flex items-center gap-2 w-full","data-threshold":u,children:[jsx("div",{className:"relative flex-1 rounded-sm",style:{height:n,backgroundColor:o==="none"?"transparent":o},children:jsx("div",{className:"absolute left-0 top-0 h-full rounded-sm transition-all duration-300",style:{width:`${c}%`,backgroundColor:m}})}),t&&jsxs("span",{className:"text-sm text-text-primary whitespace-nowrap",children:[c.toFixed(0),"%"]})]})});af.displayName="PercentBarCell";var TL="\u2013",Rv="\u200A";function Mv(e){if(e==null||e==="")return;let t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:void 0}function Ev({row:e,context:t,min:r,max:o,decimals:n=0,unit:a,emptyText:i="\u2014",align:s="right",emphasis:l="normal",className:d}){let{isLoading:c}=t;if(c)return jsx(q,{className:Ft(l)});let u=Mv(ge(r,e)),m=Mv(ge(o,e));if(u===void 0&&m===void 0)return jsx("div",{className:ke(s,"text-text-secondary"),children:i});let p=b=>new Intl.NumberFormat("en-US",{minimumFractionDigits:n,maximumFractionDigits:n}).format(b),g=u!==void 0&&m!==void 0?`${p(u)}${Rv}${TL}${Rv}${p(m)}`:p(u!==void 0?u:m),f=ke(s,twMerge("tabular-nums",Gr(l),d));return jsxs("div",{className:f,children:[jsx("span",{children:g}),a&&jsx("span",{className:"text-text-secondary",children:a})]})}function pd({row:e,context:t,isSelected:r=false,onSelect:o,isDisabled:n=false,align:a="center"}){let{isLoading:i}=t;if(i)return jsx("div",{className:ke(a),children:jsx(q,{className:"h-4 w-4 rounded"})});let s=ge(n,e),l=ke(a);return jsx("div",{className:l,children:jsx(So,{isSelected:r,onChange:d=>{o?.(e,d);},isDisabled:s,"aria-label":"Select row"})})}function md({streetAddress:e,city:t,state:r,postalCode:o,layout:n="stacked",size:a="md",href:i,LinkComponent:s,linkVariant:l="unstyled",emphasis:d="normal",isLoading:c=false,showIcon:u=true,className:m,piiEntity:p}){let f={xs:{iconSize:16,iconContainerSize:"w-7 h-7",gap:"gap-1.5",textSize:"text-xs",secondaryTextSize:"text-xs",skeletonIconStacked:28,skeletonIconInline:16,skeletonText:80,skeletonSecondary:60},sm:{iconSize:20,iconContainerSize:"w-8 h-8",gap:"gap-2",textSize:"text-sm",secondaryTextSize:"text-xs",skeletonIconStacked:32,skeletonIconInline:20,skeletonText:96,skeletonSecondary:72},md:{iconSize:24,iconContainerSize:"w-9 h-9",gap:"gap-3",textSize:"text-base",secondaryTextSize:"text-sm",skeletonIconStacked:36,skeletonIconInline:24,skeletonText:128,skeletonSecondary:96},lg:{iconSize:28,iconContainerSize:"w-10 h-10",gap:"gap-3",textSize:"text-lg",secondaryTextSize:"text-base",skeletonIconStacked:40,skeletonIconInline:28,skeletonText:160,skeletonSecondary:120}}[a],h={strong:"font-semibold text-text-primary",high:"font-semibold text-text-primary",normal:"text-text-primary",low:"text-text-secondary"}[d],v=[];t&&v.push(t),r&&o?v.push(`${r} ${o}`):r?v.push(r):o&&v.push(o);let x=v.join(", "),C=({children:w,className:T})=>i?s?jsx(s,{href:i,className:T,children:w}):jsx(St,{href:i,variant:l,className:twMerge("hover:underline",T),asButton:false,children:w}):jsx("span",{className:T,children:w});if(c)return n==="inline"?jsxs("div",{className:twMerge("flex items-center",f.gap,m),children:[u&&jsx(q,{width:f.skeletonIconInline,height:f.skeletonIconInline,className:"flex-shrink-0 rounded"}),jsx(q,{width:f.skeletonText,height:f.skeletonIconInline*.8})]}):jsxs("div",{className:twMerge("flex items-center",f.gap,m),children:[u&&jsx(q,{width:f.skeletonIconStacked,height:f.skeletonIconStacked,className:"flex-shrink-0 rounded"}),jsxs("div",{className:"flex flex-col gap-1",children:[jsx(q,{width:f.skeletonText,height:16}),jsx(q,{width:f.skeletonSecondary,height:12})]})]});if(n==="inline")return jsxs(C,{className:twMerge("flex items-center",f.gap,i&&"hover:bg-background-hover transition-colors",m),children:[u&&jsx(G,{name:"MapPin",size:f.iconSize,className:"text-text-secondary flex-shrink-0"}),jsx("span",{className:twMerge("leading-normal truncate hover:text-text-primary",h,f.textSize,i&&"hover:underline hover:decoration-1 hover:underline-offset-4"),"data-pii-type":p?"address":void 0,"data-pii-entity":p,children:e})]});let S=()=>{if(p){if(t&&r&&o)return "city-state-zip";if(t&&r)return "city-state";if(t)return "city";if(r)return "state";if(o)return "postal-code"}};return jsxs("div",{className:twMerge("flex items-center justify-start",f.gap,m),children:[u&&jsx("div",{className:twMerge("flex-shrink-0 flex items-center justify-center rounded border border-border-muted",f.iconContainerSize),children:jsx(G,{name:"MapPin",size:f.iconSize,className:"text-text-secondary"})}),jsxs("div",{className:"flex flex-col items-start min-w-0",children:[jsx(C,{className:twMerge("leading-normal truncate hover:text-text-primary",h,f.textSize,i&&"hover:underline hover:decoration-1 hover:underline-offset-4"),children:jsx("span",{"data-pii-type":p?"address":void 0,"data-pii-entity":p,children:e})}),x&&jsx("div",{className:twMerge("text-text-secondary leading-normal truncate",f.secondaryTextSize),"data-pii-type":S(),"data-pii-entity":p,children:x})]})]})}function Dv({row:e,context:t,streetAddress:r,city:o,state:n,postalCode:a,layout:i="stacked",size:s="sm",href:l,LinkComponent:d,linkVariant:c="secondary",emphasis:u="normal",align:m="left",className:p,piiEntity:g}){let{isLoading:f}=t,b=ge(r,e),h=ge(o,e),v=ge(n,e),x=ge(a,e),C=ge(l,e),S=ge(g,e),w=ke(m,p);return jsx("div",{className:w,children:jsx(md,{streetAddress:b,city:h,state:v,postalCode:x,layout:i,size:s,href:C,LinkComponent:d,linkVariant:c,emphasis:u,isLoading:f,piiEntity:S})})}var sf=ot__default.memo(({value:e,data:t,type:r="line",color:o="var(--color-viz-default)",strokeWidth:n=2,categoryColors:a,context:i,width:s,height:l=40})=>{let d=e||t||[],c=s||100,u=l,{xScale:m,yScale:p}=useMemo(()=>{if(d.length===0)return {xScale:scaleTime({range:[0,c],domain:[new Date,new Date]}),yScale:scaleLinear({range:[u,0],domain:[0,1]})};let f=extent(d,x=>x.xValue),b=min(d,x=>x.yValue)||0,h=max(d,x=>x.yValue)||0,v=(h-b)*.1||1;return {xScale:scaleTime({range:[0,c],domain:f}),yScale:scaleLinear({range:[u,0],domain:[b-v,h+v]})}},[d,c,u]);if(i.isLoading)return jsx("div",{className:"flex items-center",style:{width:c,height:u},children:jsx("div",{className:"h-1 w-full animate-pulse bg-border-default rounded"})});if(!d||d.length===0)return jsx("div",{className:"flex items-center justify-center text-text-secondary text-xs",style:{width:c,height:u},children:"No data"});let g=a&&d[0]?.category&&a[d[0].category]?a[d[0].category]:o;return jsxs("svg",{width:c,height:u,className:"overflow-visible",children:[(r==="area"||r==="both")&&jsx(AreaClosed,{data:d,x:f=>m(f.xValue),y:f=>p(f.yValue),yScale:p,fill:g,fillOpacity:.15,curve:curveLinear}),(r==="line"||r==="both")&&jsx(LinePath,{data:d,x:f=>m(f.xValue),y:f=>p(f.yValue),stroke:g,strokeWidth:n,strokeLinecap:"round",curve:curveLinear})]})});sf.displayName="SparklineCell";function Bv({value:e,row:t,context:r,prefix:o,suffix:n,emptyText:a="\u2014",href:i,linkBehavior:s="hover",linkVariant:l="secondary",emphasis:d="normal",truncate:c=true,copyable:u=false,align:m="left",className:p,piiType:g,piiEntity:f}){let{isLoading:b}=r;if(b)return jsx(q,{className:Ft(d)});let h=_c(e,a),v=ge(i,t),x=ge(f,t),C=h,S=false,w=false;if(c&&h&&typeof h=="string")if(typeof c=="boolean")w=true;else {let{position:D="end",length:W=16,ellipsis:X="...",tooltip:H=true}=c;if(h.length>W){switch(D){case "start":C=Ll(h,W);break;case "middle":C=ii(h,W);break;case "end":C=Dl(h,W,X);break}S=H;}}let T=g&&x?{"data-pii-type":g,"data-pii-entity":x}:{},N=Object.keys(T).length>0,k=jsx("span",{className:w?"truncate":"",...T,children:C}),R=S?jsx(tr,{content:N?jsx("span",{...T,children:String(h)}):String(h),children:k}):k,A=jsxs(Fragment,{children:[o&&jsx("span",{className:"text-text-secondary",children:o}),R,n&&jsx("span",{className:"text-text-secondary",children:n})]}),M=A;if(u&&h&&h!==a){let D=typeof u=="function"?u(t):String(h);M=jsx(In,{value:D,size:"sm",children:A});}if(v){let D=ke(m,p);return jsx("div",{className:D,children:Yo(M,v,t,s,l,d)})}let B=ke(m,twMerge(Gr(d),p));return jsx("div",{className:B,children:M})}var VL={sm:"sm:hidden",md:"md:hidden",lg:"lg:hidden",xl:"xl:hidden"},OL={sm:"hidden sm:grid",md:"hidden md:grid",lg:"hidden lg:grid",xl:"hidden xl:grid"};function fd(e,t){return t.accessor?typeof t.accessor=="function"?t.accessor(e):e[t.accessor]:null}function gd(e,t,r,o){if(r.cell){let n=r.cell,a=typeof r.cellProps=="function"?r.cellProps(e,t):r.cellProps;return jsx(n,{value:e,row:t,context:o,...a})}return r.render?r.render(e,t,o):e?.toString()??"\u2014"}function bd({row:e,columns:t,density:r,isLoading:o,onClick:n}){let a=t.filter(u=>u.mobile!==false).map(u=>{let m=u.mobile===false?null:u.mobile;return {...u,mobilePriority:m?.priority??2,mobileFormat:m?.format??"secondary",showLabel:m?.label??m?.format==="secondary",icon:m?.icon}}).sort((u,m)=>u.mobilePriority-m.mobilePriority),i=a.filter(u=>u.mobilePriority===1||u.mobileFormat==="primary"),s=a.filter(u=>u.mobilePriority===2&&u.mobileFormat!=="primary"),l=a.filter(u=>u.mobileFormat==="badge"),d={isLoading:!!o,rowIndex:0,columnIndex:0,density:r};return jsxs("div",{className:twMerge("border-b border-border-default bg-background-surface transition-colors",n&&"cursor-pointer hover:bg-background-hover active:bg-background-pressed",{compact:"px-3 py-2",default:"px-4 py-3",relaxed:"px-4 py-4"}[r]),onClick:n,role:n?"button":void 0,tabIndex:n?0:void 0,children:[i.length>0&&jsxs("div",{className:"mb-2 flex items-start justify-between",children:[jsx("div",{className:"flex-1",children:i.map(u=>{let m=fd(e,u);return jsx("div",{className:"font-medium text-text-primary [&>*]:!justify-start [&>*]:!text-left",children:gd(m,e,u,d)},u.id)})}),l.length>0&&jsx("div",{className:"ml-2 flex flex-wrap gap-1",children:l.map(u=>{let m=fd(e,u);return jsx("div",{className:"inline-flex",children:gd(m,e,u,d)},u.id)})})]}),s.length>0&&jsx("div",{className:"space-y-1",children:s.map(u=>{let m=fd(e,u),p=u.showLabel&&u.label;return jsxs("div",{className:"flex items-center text-sm text-text-secondary",children:[u.icon&&jsx(G,{name:u.icon,className:"mr-1.5 h-4 w-4 flex-shrink-0"}),p&&jsxs("span",{className:"mr-1 font-medium",children:[u.label,":"]}),jsx("span",{className:"truncate [&>*]:!justify-start [&>*]:!text-left",children:gd(m,e,u,d)})]},u.id)})})]})}function xd({row:e,columns:t,density:r,isLoading:o,onClick:n}){let a=t.filter(l=>l.mobile!==false),i={isLoading:!!o,rowIndex:0,columnIndex:0,density:r};return jsx("div",{className:twMerge("border-b border-border-default bg-background-surface transition-colors",n&&"cursor-pointer hover:bg-background-hover active:bg-background-pressed",{compact:"px-3 py-2",default:"px-4 py-3",relaxed:"px-4 py-4"}[r]),onClick:n,role:n?"button":void 0,tabIndex:n?0:void 0,children:jsx("div",{className:"space-y-2",children:a.map((l,d)=>{let c=fd(e,l),u=d===0;return jsxs("div",{children:[!u&&jsx("div",{className:"text-xs text-text-secondary",children:l.label}),jsx("div",{className:twMerge(u?"font-medium text-text-primary":"text-sm text-text-primary","[&>*]:!justify-start [&>*]:!text-left"),children:gd(c,e,l,i)})]},l.id)})})})}function Vv(e="md"){return {mobile:VL[e],desktop:OL[e]}}function Ov({density:e}){return jsxs("div",{className:twMerge("border-b border-border-default bg-background-surface",{compact:"px-3 py-2",default:"px-4 py-3",relaxed:"px-4 py-4"}[e]),children:[jsx("div",{className:"mb-2 h-5 w-3/4 animate-pulse rounded bg-background-muted"}),jsxs("div",{className:"space-y-1",children:[jsx("div",{className:"h-4 w-1/2 animate-pulse rounded bg-background-muted"}),jsx("div",{className:"h-4 w-2/3 animate-pulse rounded bg-background-muted"})]})]})}var yd=10,lf=200;function zL(e){return e===void 0||!Number.isInteger(e)||e<=0?yd:Math.min(e,lf)}function vd(e,t,r){let o=typeof e=="boolean"?{}:e??{},n=zL(o.pageSize),a=o.totalRows??t,i=Math.max(1,Math.ceil(a/n)),s=Math.min(Math.max(Math.trunc(r)||0,0),i-1),l=s*n,d=Math.min(l+n,o.totalRows!==void 0?t:a),c=Math.max(0,d-(o.totalRows!==void 0?0:l));return {page:s,pageCount:i,start:l,end:d,from:a===0?0:l+1,to:a===0?0:l+c,total:a}}var HL={compact:"px-3 py-1.5",default:"px-3 py-2",relaxed:"px-4 py-3"};function Cd({page:e,pageCount:t,from:r,to:o,total:n,density:a,onPageChange:i,label:s="Pagination"}){let l=e<=0,d=e>=t-1;return jsxs("nav",{"data-testid":"data-table-pagination","aria-label":s,className:twMerge("flex items-center gap-3 border-t border-border-default","justify-between @sm:justify-start",HL[a]),children:[jsx(te,{size:"sm",variant:"ghost",icon:"CaretLeft",isDisabled:l,onPress:()=>i(e-1),"aria-label":"Previous page",className:"order-1 @sm:order-2",children:jsx("span",{className:"@sm:hidden",children:"Previous"})}),jsx("p",{className:twMerge("m-0 flex min-w-0 items-baseline gap-2 text-body-sm text-text-secondary","order-2 @sm:order-1 @sm:grow"),children:jsx("span",{className:"truncate tabular-nums",children:n===0?"No rows":`Showing ${r}\u2013${o} of ${n.toLocaleString()}`})}),jsx(te,{size:"sm",variant:"ghost",icon:"CaretRight",iconPosition:"right",isDisabled:d,onPress:()=>i(e+1),"aria-label":"Next page",className:"order-3",children:jsx("span",{className:"@sm:hidden",children:"Next"})}),jsx("span",{"aria-live":"polite","aria-atomic":"true",className:"sr-only",children:n===0?"No rows":`Page ${e+1} of ${t}, showing rows ${r} to ${o} of ${n}`})]})}var $L={compact:"py-1.5 px-3 text-sm",default:"py-3 px-4 text-sm",relaxed:"py-4 px-4 text-base"},eD={left:"text-left justify-start",center:"text-center justify-center",right:"text-right justify-end"};function tD(e){let t={};return e.width!==void 0&&(t.width=typeof e.width=="number"?`${e.width}px`:e.width),e.minWidth!==void 0&&(t.minWidth=typeof e.minWidth=="number"?`${e.minWidth}px`:e.minWidth),e.maxWidth!==void 0&&(t.maxWidth=typeof e.maxWidth=="number"?`${e.maxWidth}px`:e.maxWidth),e.flex!==void 0&&(t.flex=`${e.flex} 1 0`),t}function rD({column:e,sortConfig:t,onSort:r,stickyHeader:o,stickyFirstColumn:n,isFirstColumn:a,density:i="default",isLoading:s=false,headerContent:l,sortNote:d}){let c=e.reorderable!==false,{attributes:u,listeners:m,setNodeRef:p,transform:g,transition:f,isDragging:b}=useSortable({id:e.id,disabled:!c||s}),{role:h,"aria-pressed":v,...x}=u,C=t?.columnId===e.id,S=C?t.direction:null,w=n&&a,T=C?d:void 0,N={...tD(e),transform:CSS.Transform.toString(g),transition:f,opacity:b?.8:1,zIndex:b?50:void 0};return jsx("div",{ref:p,className:twMerge("flex items-center border-b border-border-default bg-background-surface",e.sortable?"gap-2":"gap-1",$L[i],eD[e.align||"left"],o&&"sticky top-0 z-10",w&&"sticky left-0 z-20 shadow-[2px_0_4px_-2px_rgba(0,0,0,0.1)]",o&&w&&"z-30",e.sortable&&!s&&"hover:bg-background-hover",s&&"cursor-not-allowed opacity-60",C?"font-bold text-text-primary":"font-medium text-text-secondary",b&&"bg-background-hover"),style:N,...x,...m,role:"columnheader","aria-sort":C?S==="asc"?"ascending":"descending":"none","aria-disabled":s,title:T,"data-sort-note":T,children:s?jsx(q,{className:"h-4 w-24"}):jsxs(Fragment,{children:[l??jsx("span",{className:twMerge("flex-1 truncate",e.sortable&&"cursor-pointer"),onClick:()=>!s&&e.sortable&&r(e.id),children:e.label}),T&&jsx("span",{className:"sr-only",children:T}),e.sortable?jsx("button",{type:"button",className:"flex flex-shrink-0 cursor-pointer",onClick:()=>!s&&r(e.id),"aria-label":`Sort by ${e.label}`,children:C?jsx(G,{name:S==="asc"?"CaretUp":"CaretDown",size:14,weight:T?"regular":"bold",className:T?"text-text-secondary opacity-40":"text-text-primary"}):jsx(G,{name:"CaretUpDown",size:12,className:"text-text-secondary opacity-40"})}):C?jsx("span",{className:"flex flex-shrink-0",children:jsx(G,{name:S==="asc"?"CaretUp":"CaretDown",size:14,weight:T?"regular":"bold",className:T?"text-text-secondary opacity-40":"text-text-primary"})}):null]})})}function Wv({columns:e,columnOrder:t,onColumnOrderChange:r,sortConfig:o,onSort:n,stickyHeader:a,stickyFirstColumn:i,density:s="default",isLoading:l=false,renderHeaderContent:d,sortNote:c}){let u=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:5}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates})),m=new Map(e.map(f=>[f.id,f])),p=f=>{let{active:b,over:h}=f;if(h&&b.id!==h.id){let v=t.indexOf(b.id),x=t.indexOf(h.id);if(m.get(h.id)?.reorderable===false)return;let S=0;for(let k=0;k<t.length&&m.get(t[k])?.reorderable===false;k++)S=k+1;if(x<S)return;let w=Math.min(v,x),T=Math.max(v,x);for(let k=w;k<=T;k++){if(k===v)continue;if(m.get(t[k])?.reorderable===false)return}let N=arrayMove(t,v,x);r(N);}},g=t.map(f=>m.get(f)).filter(f=>f!==void 0);return jsx(DndContext,{sensors:u,collisionDetection:closestCenter,onDragEnd:p,children:jsx(SortableContext,{items:t,strategy:horizontalListSortingStrategy,children:jsx("div",{className:"contents",role:"rowgroup",children:g.map((f,b)=>jsx(rD,{column:f,sortConfig:o,onSort:n,stickyHeader:a,stickyFirstColumn:i,isFirstColumn:b===0,density:s,isLoading:l,headerContent:d?.(f),sortNote:c},f.id))})})})}var Sd="__select",sD=new Set,cf={compact:"py-1.5 px-3 text-sm",default:"py-3 px-4 text-sm",relaxed:"py-4 px-4 text-base"},df={left:"text-left justify-start",center:"text-center justify-center",right:"text-right justify-end"},lD={full:"w-full",auto:"w-auto inline-block",contained:"w-full max-w-6xl mx-auto"},cD={auto:"table-auto",fixed:"table-fixed",responsive:"table-auto"};function Kv(e){if(typeof e=="number")return e;let t=/^(\d+(?:\.\d+)?)px$/.exec(e.trim());return t?Number(t[1]):0}function uf(e){let t={};return e.width!==void 0&&(t.width=typeof e.width=="number"?`${e.width}px`:e.width),e.minWidth!==void 0&&(t.minWidth=typeof e.minWidth=="number"?`${e.minWidth}px`:e.minWidth),e.maxWidth!==void 0&&(t.maxWidth=typeof e.maxWidth=="number"?`${e.maxWidth}px`:e.maxWidth),e.flex!==void 0&&(t.flex=`${e.flex} 1 0`),t}function dD(e,t){return t.accessor?typeof t.accessor=="function"?t.accessor(e):e[t.accessor]:null}function uD({column:e,sortConfig:t,onSort:r,stickyHeader:o,stickyFirstColumn:n,isFirstColumn:a,density:i="default",isLoading:s=false,headerContent:l,sortNote:d}){let c=t?.columnId===e.id,u=c?t.direction:null,m=n&&a,p=c?d:void 0;return jsx("div",{className:twMerge("flex items-center border-b border-border-default bg-background-surface",e.sortable?"gap-2":"gap-1",cf[i],df[e.align||"left"],o&&"sticky top-0 z-10",m&&"sticky left-0 z-20 shadow-[2px_0_4px_-2px_rgba(0,0,0,0.1)]",o&&m&&"z-30",e.sortable&&!s&&"cursor-pointer hover:bg-background-hover",s&&"cursor-not-allowed opacity-60",c?"font-bold text-text-primary":"font-medium text-text-secondary"),onClick:()=>!s&&e.sortable&&r(e.id),role:"columnheader","aria-sort":c?u==="asc"?"ascending":"descending":"none","aria-disabled":s,title:p,"data-sort-note":p,style:uf(e),children:s?jsx(q,{className:"h-4 w-24"}):jsxs(Fragment,{children:[l??jsx("span",{className:"truncate",children:e.label}),e.headerTooltip&&jsx(tr,{content:e.headerTooltip,children:jsx(te,{variant:"ghost","aria-label":`About ${e.label}`,onClick:g=>g.stopPropagation(),className:"h-auto min-h-0 flex-shrink-0 p-0 text-text-tertiary hover:text-text-secondary",children:jsx(G,{name:"Info",size:12,"aria-hidden":true})})}),p&&jsx("span",{className:"sr-only",children:p}),(e.sortable||c)&&jsx("div",{className:"flex flex-shrink-0",children:c?jsx(G,{name:u==="asc"?"CaretUp":"CaretDown",size:14,weight:p?"regular":"bold",className:p?"text-text-secondary opacity-40":"text-text-primary"}):jsx(G,{name:"CaretUpDown",size:12,className:"text-text-secondary opacity-40"})})]})})}function pD({column:e,row:t,rowIndex:r,columnIndex:o,isHovered:n,isSelected:a,density:i="default",className:s,stickyFirstColumn:l}){let d=l&&o===0,c=dD(t,e),u={isLoading:false,isHovered:n,...a===void 0?{}:{isSelected:a},rowIndex:r,columnIndex:o,density:i},m;if(e.cell){let p=e.cell,g=typeof e.cellProps=="function"?e.cellProps(c,t):e.cellProps;m=jsx(p,{value:c,row:t,context:u,...g});}else e.render?m=e.render(c,t,u):m=jsx("span",{className:"truncate",children:c?.toString()??""});if(e.popover){let p=e.popover,g,f="top",b=false,h="hover";typeof p=="string"?g=p:typeof p=="function"?g=p(c,t):(g=typeof p.content=="function"?p.content(c,t):p.content,f=p.placement||"top",b=p.showArrow??false,h=p.trigger||"hover"),m=jsxs(DialogTrigger,{...h==="hover"?{trigger:"longPress"}:{},children:[jsx("div",{className:"cursor-help",children:m}),jsx(Et,{placement:f,showArrow:b,children:jsx("div",{className:"p-2",children:g})})]});}return jsx("div",{className:twMerge("flex items-center border-b border-border-default bg-background-surface",e.noCellPadding?"":cf[i],df[e.align||"left"],d&&"sticky left-0 z-10 shadow-[2px_0_4px_-2px_rgba(0,0,0,0.1)]",s),role:"cell",style:uf(e),children:m})}function mD({column:e,rowIndex:t,columnIndex:r,density:o="default",stickyFirstColumn:n}){let a=n&&r===0,i={isLoading:true,rowIndex:t,columnIndex:r,density:o},s;if(e.cell){let l=e.cell,d=typeof e.cellProps=="function"?e.cellProps(null,{}):e.cellProps;s=jsx(l,{value:null,row:{},context:i,...d});}else e.render?s=e.render(null,{},i):s=jsx(q,{className:"h-4 w-full max-w-[200px]"});return jsx("div",{className:twMerge("flex items-center border-b border-border-default bg-background-surface",e.noCellPadding?"":cf[o],df[e.align||"left"],a&&"sticky left-0 z-10 shadow-[2px_0_4px_-2px_rgba(0,0,0,0.1)]"),role:"cell",style:uf(e),children:s})}function fD(e,t){let r=new Set(["BUTTON","A","INPUT","SELECT","TEXTAREA"]),o=new Set(["button","link","checkbox","switch","menuitem","option"]),n=e;for(;n&&n!==t;){if(r.has(n.tagName))return true;let a=n.getAttribute("role");if(a&&o.has(a))return true;n=n.parentElement;}return false}function Yv({columns:e,row:t,rowIndex:r,density:o="default",onClick:n,stickyFirstColumn:a,isSelected:i}){let[s,l]=useState(false),d=useCallback(c=>{if(!n)return;let u=c.target,m=c.currentTarget;fD(u,m)||n(t);},[n,t]);return jsx("div",{className:twMerge("contents group",n&&"cursor-pointer"),role:"row","aria-selected":i===void 0?void 0:i,onClick:d,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),children:e.map((c,u)=>jsx(pD,{column:c,row:t,rowIndex:r,columnIndex:u,isHovered:s,isSelected:i,density:o,className:twMerge(n?"group-hover:bg-background-hover":"",i&&"bg-background-selected"),stickyFirstColumn:a},c.id))})}function gD({columns:e,rowIndex:t,density:r="default",stickyFirstColumn:o}){return jsx("div",{className:"contents",role:"row",children:e.map((n,a)=>jsx(mD,{column:n,rowIndex:t,columnIndex:a,density:r,stickyFirstColumn:o},n.id))})}function Xv({columns:e,data:t,className:r,density:o="default",width:n="full",height:a,maxHeight:i,layout:s="auto",mobileRenderer:l="auto",customMobileRowRender:d,mobileBreakpoint:c="md",isLoading:u=false,loadingState:m,loadingRowCount:p=5,onLoadMore:g,hasMore:f=false,enableVirtualization:b,estimatedRowHeight:h,loadingIndicator:v,stickyHeader:x=false,stickyFirstColumn:C=false,onRowClick:S,getRowId:w,selectedRowIds:T,onSelectionChange:N,selectionMode:k="multi",hideHeader:R=false,sortConfig:A,onSort:M,sortNote:B,"aria-label":D,enableColumnReorder:W=false,columnOrder:X,onColumnOrderChange:H,pagination:I}){let F=I!==void 0&&I!==false,z=typeof I=="object"?I:void 0,U=z?.page,K=U!==void 0,[O,V]=useState(0),L=vd(I,t.length,K?U:O),y=useCallback(ne=>{let Se=Math.min(Math.max(ne,0),L.pageCount-1);K||V(Se),z?.onPageChange?.(Se);},[K,z,L.pageCount]),E=useMemo(()=>!F||z?.totalRows!==void 0?t:t.slice(L.start,L.end),[t,F,z?.totalRows,L.start,L.end]);useEffect(()=>{K||!F||O!==L.page&&V(L.page);},[K,F,O,L.page]);let P=N!==void 0,Y=T??sD,$=useCallback((ne,Se)=>{if(w)return w(ne);let ce=ne.id;return typeof ce=="string"&&ce.length>0?ce:typeof ce=="number"&&Number.isFinite(ce)?String(ce):`row-${Se}`},[w]),oe=useMemo(()=>E.map((ne,Se)=>$(ne,Se)),[E,$]),re=useCallback((ne,Se)=>{if(!N)return;if(k==="single"){N(Se?new Set([ne]):new Set);return}let ce=new Set(Y);Se?ce.add(ne):ce.delete(ne),N(ce);},[N,Y,k]),_=oe.filter(ne=>Y.has(ne)).length,he=oe.length>0&&_===oe.length,me=_>0&&!he,ue=useCallback(ne=>{if(!N)return;let Se=new Set(Y);for(let ce of oe)ne?Se.add(ce):Se.delete(ce);N(Se);},[N,oe,Y]),ie=useMemo(()=>P?[{id:Sd,label:"",width:44,align:"center",sortable:false,reorderable:false,exportable:false,mobile:false,render:(Se,ce,ct)=>{let yr=$(ce,ct.rowIndex);return jsx(pd,{value:void 0,row:ce,context:ct,isSelected:Y.has(yr),onSelect:(yo,vo)=>re(yr,vo)})}},...e]:e,[e,P,Y,$,re]),fe=P&&k==="multi"?jsx(So,{isSelected:he,isIndeterminate:me,onChange:ne=>ue(ne),isDisabled:oe.length===0,"aria-label":he?"Deselect all rows on this page":"Select all rows on this page"}):void 0,Te=useCallback(ne=>ne.id===Sd?fe:void 0,[fe]),[Ye,yt]=useState(null),Qt=A!==void 0,Ze=Qt?A:Ye,fr=useRef(null),lr=useMemo(()=>ie.map(ne=>ne.id),[ie]),[Ce,Vt]=useState(lr),ee=X!==void 0,Be=ee?X:Ce;useEffect(()=>{ee||Vt(ne=>{let Se=ie.map(vo=>vo.id),ce=new Set(Se),ct=new Set(ne),yr=ne.filter(vo=>ce.has(vo)),yo=Se.filter(vo=>!ct.has(vo));return [...yr,...yo]});},[ie,ee]);let Ve=useCallback(ne=>{ee||Vt(ne),H?.(ne);},[ee,H]),nt=useMemo(()=>{if(!W&&!X)return ie;let ne=new Map(ie.map(ct=>[ct.id,ct])),Se=Be.map(ct=>ne.get(ct)).filter(ct=>ct!==void 0),ce=ne.get(Sd);return ce&&!Se.some(ct=>ct.id===Sd)?[ce,...Se]:Se},[ie,Be,W,X]),wt=En({items:E,onLoadMore:g,hasMore:f,isLoading:u,loadingState:m,enableVirtualization:b,estimatedItemSize:h||(o==="compact"?40:o==="relaxed"?60:48),overscan:5}),Xt=g||b?wt:null,Q=Xt?.scrollRef??fr,{loadMoreRef:j,virtualizer:pe,virtualItems:ae,isLoadingMore:Ne,computedLoadingState:Qe}=Xt||{},{gridTemplateColumns:Ue,totalMinWidth:cr}=useMemo(()=>{let ne=0;return {gridTemplateColumns:nt.map(ce=>{if(ce.minWidth?ne+=Kv(ce.minWidth):ce.width&&(ne+=Kv(ce.width)),ce.width)return typeof ce.width=="number"?`${ce.width}px`:ce.width;if(ce.flex)return `${ce.flex}fr`;if(ce.minWidth&&ce.maxWidth){let ct=typeof ce.minWidth=="number"?`${ce.minWidth}px`:ce.minWidth,yr=typeof ce.maxWidth=="number"?`${ce.maxWidth}px`:ce.maxWidth;return `minmax(${ct}, ${yr})`}return ce.minWidth?`minmax(${typeof ce.minWidth=="number"?`${ce.minWidth}px`:ce.minWidth}, 1fr)`:ce.maxWidth?`minmax(0, ${typeof ce.maxWidth=="number"?`${ce.maxWidth}px`:ce.maxWidth})`:"1fr"}).join(" "),totalMinWidth:ne}},[nt]),Z=useCallback(ne=>{if(!ie.find(ct=>ct.id===ne)?.sortable)return;let ce;Ze?.columnId===ne?ce={columnId:ne,direction:Ze.direction==="asc"?"desc":"asc"}:ce={columnId:ne,direction:"asc"},Qt||yt(ce),M?.(ce);},[ie,Ze,M,Qt]),le=Qe==="loading"||u&&E.length===0,Ae=F&&(z?.alwaysShow||L.pageCount>1)&&!u&&!le,Oe=Ae&&a!==void 0,it={};a?(Oe?(it.flex="1 1 auto",it.minHeight=0):it.height=typeof a=="number"?`${a}px`:a,it.overflowY="auto"):i?(it.maxHeight=typeof i=="number"?`${i}px`:i,it.overflowY="auto"):g&&(it.height="600px",it.overflowY="auto"),g&&(it.overflowX="auto");let Tt=twMerge(lD[n],!g&&(s==="responsive"?"overflow-x-auto scrollbar-visible":"overflow-auto scrollbar-visible"),r),Ot=Vv(c),tt=l!=="none",xr=(ne,Se)=>tt?l==="custom"&&d?d(ne,Se):jsx(l==="cards"?xd:bd,{row:ne,columns:nt,density:o,isLoading:u,onClick:S?()=>S(ne):void 0}):null,gr=pe?ae?.map(ne=>({virtualItem:ne,row:E[ne.index],index:ne.index}))||[]:E.map((ne,Se)=>({row:ne,index:Se,virtualItem:null})),xo=jsxs("div",{ref:Q,className:Tt,style:{...it,position:pe?"relative":void 0},children:[jsxs("div",{className:twMerge("grid border-separate border-spacing-0",cD[s],n==="auto"?"inline-grid w-auto":"w-full",tt&&Ot.desktop),role:"table","aria-label":D,style:{gridTemplateColumns:Ue,minWidth:cr>0?`${cr}px`:void 0},children:[!R&&(W?jsx(Wv,{columns:ie,columnOrder:Be,onColumnOrderChange:Ve,sortConfig:Ze,onSort:Z,stickyHeader:x,stickyFirstColumn:C,density:o,isLoading:le,renderHeaderContent:Te,sortNote:B}):jsx("div",{className:"contents",role:"rowgroup",children:nt.map((ne,Se)=>jsx(uD,{column:ne,sortConfig:Ze,onSort:Z,stickyHeader:x,stickyFirstColumn:C,isFirstColumn:Se===0,density:o,isLoading:le,headerContent:Te(ne),sortNote:B},ne.id))})),pe&&!le?jsx("div",{className:"col-span-full",style:{gridColumn:"1 / -1",height:`${pe.getTotalSize()}px`,position:"relative"},role:"rowgroup",children:E.length>0?jsxs(Fragment,{children:[gr.map(({row:ne,index:Se,virtualItem:ce})=>{if(!ne||!ce)return null;let ct=w?w(ne):`row-${Se}`;return jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",display:"grid",gridTemplateColumns:Ue,transform:`translateY(${ce.start}px)`},"data-index":ce.index,ref:pe.measureElement,children:jsx(Yv,{columns:nt,row:ne,rowIndex:Se,density:o,onClick:S,stickyFirstColumn:C,isSelected:P?Y.has($(ne,Se)):void 0})},ct)}),Ne&&jsx("div",{style:{position:"absolute",top:`${pe.getTotalSize()}px`,left:0,width:"100%"},children:v||jsx(io,{state:"loading-more"})})]}):jsx("div",{className:"py-12 text-center text-text-secondary",children:"No data available"})}):jsx("div",{className:"contents",role:"rowgroup",children:le?Array.from({length:p}).map((ne,Se)=>jsx(gD,{columns:nt,rowIndex:Se,density:o,stickyFirstColumn:C},`loading-${Se}`)):E.length>0?jsxs(Fragment,{children:[gr.map(({row:ne,index:Se})=>{if(!ne)return null;let ce=w?w(ne):`row-${Se}`;return jsx(Yv,{columns:nt,row:ne,rowIndex:Se,density:o,onClick:S,stickyFirstColumn:C,isSelected:P?Y.has($(ne,Se)):void 0},ce)}),Ne&&jsx("div",{className:"col-span-full",style:{gridColumn:"1 / -1"},children:v||jsx(io,{state:"loading-more"})})]}):jsx("div",{className:"col-span-full py-12 text-center text-text-secondary",role:"row",children:jsx("div",{role:"cell",children:"No data available"})})})]}),tt&&jsx("div",{className:Ot.mobile,children:le?Array.from({length:p}).map((ne,Se)=>jsx(Ov,{density:o},`mobile-loading-${Se}`)):E.length>0?jsxs(Fragment,{children:[gr.map(({row:ne,index:Se})=>{if(!ne)return null;let ce=w?w(ne):`mobile-row-${Se}`;return jsx("div",{className:"border-b border-border-default last:border-b-0",children:xr(ne,Se)},ce)}),Ne&&(v||jsx(io,{state:"loading-more"}))]}):jsx("div",{className:"py-12 text-center text-text-secondary",children:"No data available"})}),g&&f&&!le&&(pe?jsx("div",{ref:j,style:{position:"absolute",top:`${pe.getTotalSize()}px`,left:0,width:"100%",height:1}}):jsx("div",{ref:j,className:"h-px w-full"}))]});return Ae?jsxs("div",{className:"@container flex flex-col",style:Oe?{height:typeof a=="number"?`${a}px`:a,minHeight:0}:void 0,children:[xo,jsx(Cd,{...L,density:o,onPageChange:y,...D?{label:`${D} pagination`}:{}})]}):xo}function jv({status:e,alertCount:t,showCount:r=false,isLoading:o,size:n="sm",shape:a="pill",...i}){if(o)return jsx(q,{className:"inline-flex h-6 w-20"});let s={healthy:"success",warning:"warning",error:"error",unknown:"neutral"},l={healthy:"Healthy",warning:"Warning",error:"Error",unknown:"Unknown"},d=e==="warning"||e==="error",c=r&&t?`${l[e]} (${t})`:l[e];return jsx(kt,{variant:s[e],size:n,shape:a,dot:d,dotPulse:d,...i,children:c})}var bD={battery:"BatteryHigh",charger:"ChargingStation",thermostat:"ThermometerSimple",inverter:"Power",vehicle:"Car",water_heater:"DropHalfBottom",meter:"Gauge",sensor:Gs("sensor"),gateway:"WifiHigh",other:"Cube",unknown:"Question"},xD={battery:"Battery",charger:"Charger",thermostat:"Thermostat",inverter:"Inverter",vehicle:"Vehicle",water_heater:"Water Heater",meter:"Meter",sensor:"Sensor",gateway:"Gateway",other:"Other",unknown:"Unknown"};function Zv({deviceType:e,iconName:t,size:r="md",showLabel:o=false,className:n}){let a=t||(e?bD[e]:"Question"),i=e?xD[e]:void 0;return jsxs("div",{className:twMerge("inline-flex items-center",o?"flex-col gap-1":"gap-0",n),children:[jsx(G,{name:a,size:r}),o&&i&&jsx("span",{className:"text-xs text-text-secondary",children:i})]})}function Ks({children:e,title:t,headerContent:r,titleAlign:o="left",hideCloseIcon:n=false,hasBackArrow:a=false,onBack:i,isOpen:s,slideInFrom:l="right",transparentOverlay:d=false,onClose:c,className:u,primaryAction:m,secondaryAction:p,tertiaryAction:g,footerContent:f,contentPadding:b=true,maxWidth:h="400px"}){if(!s)return null;let v=t||r,x=m||p||g||f;return jsx(Co,{children:jsx(Yr,{isOpen:s,onOpenChange:C=>!C&&c?.(),isDismissable:true,transparent:d,children:jsx(Modal,{className:"outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0 focus-visible:ring-0",children:jsxs(Dialog,{className:twMerge("fixed top-0 bottom-0 flex flex-col bg-background-surface shadow-xl overflow-hidden",l==="right"?"right-0":"left-0",l==="right"?"animate-in slide-in-from-right duration-300 ease-out":"animate-in slide-in-from-left duration-300 ease-out","data-[exiting]:animate-out",l==="right"?"data-[exiting]:slide-out-to-right":"data-[exiting]:slide-out-to-left","data-[exiting]:duration-200 data-[exiting]:ease-in","outline-none focus-visible:outline focus-visible:outline-2 focus-visible:outline-action-default focus-visible:outline-offset-0",u),style:{maxWidth:h,width:"100%"},children:[v&&(a&&i?jsx(Cr,{title:t,headerContent:r,titleAlign:o,hideCloseIcon:n,hasBackArrow:true,onBack:i,onClose:c}):jsx(Cr,{title:t,headerContent:r,titleAlign:o,hideCloseIcon:n,onClose:c})),jsx("div",{className:twMerge("flex-1 overflow-y-auto overscroll-contain",b?"px-6 py-6":"p-0"),children:e}),x&&jsx(Pn,{primaryAction:m,secondaryAction:p,tertiaryAction:g,footerContent:f})]})})})})}Ks.displayName="Drawer";function _v({status:e,programName:t,isLoading:r,size:o="sm",shape:n="pill",...a}){if(r)return jsx(q,{className:"inline-flex h-6 w-20"});let i={enrolled:"success",eligible:"info",pending:"warning",not_eligible:"neutral",opted_out:"neutral"},s={enrolled:"Enrolled",eligible:"Eligible",pending:"Pending",not_eligible:"Not Eligible",opted_out:"Opted Out"},l=jsx(kt,{variant:i[e],size:o,shape:n,...a,children:s[e]});return t?jsx(tr,{content:t,children:l}):l}function eC({value:e,onChange:t,onUrlChange:r,accept:o="image/*",maxSize:n,isDisabled:a=false,onUpload:i,className:s,showPreview:l=true,placeholder:d="Drop files here or click to browse"}){let[c,u]=useState(false),[m,p]=useState(false),[g,f]=useState(null),[b,h]=useState(e),v=useRef(null),x=async w=>{if(f(null),n&&w.size>n){f(`File size must be less than ${(n/1024/1024).toFixed(2)}MB`);return}if(l&&w.type.startsWith("image/")){let T=new FileReader;T.onloadend=()=>{h(T.result);},T.readAsDataURL(w);}if(i){p(true);try{let T=await i(w);h(T),r?.(T);}catch(T){f("Failed to upload file"),console.error("Upload error:",T);}finally{p(false);}}t?.(w,b);},C=async w=>{try{let T=w.items;if(T.length>0){let N=T[0];if(N.kind==="file"){let k=await N.getFile();k&&x(k);}}}catch(T){f("Failed to upload file"),console.error("Upload error:",T);}finally{u(false);}},S=()=>{h(void 0),f(null),t?.(null),r?.(""),v.current&&(v.current.value="");};return jsxs("div",{className:twMerge("w-full",s),children:[jsxs(DropZone,{className:twMerge("relative flex min-h-[200px] w-full flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",c?"border-action-brand bg-action-brand/5":"border-border-muted hover:border-border-default",a&&"pointer-events-none opacity-50",g&&"border-feedback-error-border bg-feedback-error-background/50"),onDrop:C,onDropEnter:()=>u(true),onDropExit:()=>u(false),children:[b?jsxs("div",{className:"relative flex h-full w-full items-center justify-center p-4",children:[l&&(b.startsWith("data:image")||b.startsWith("http"))?jsx("img",{src:b,alt:"Preview",className:"max-h-48 max-w-full rounded-md object-contain"}):jsxs("div",{className:"flex flex-col items-center gap-2",children:[jsx(Image$1,{className:"h-12 w-12 text-text-secondary"}),jsx("span",{className:"text-sm text-text-secondary",children:"File uploaded"})]}),!a&&jsx(te,{variant:"icon",size:"sm",onPress:S,className:"absolute right-2 top-2 bg-background-surface shadow-md",children:jsx(X,{className:"h-4 w-4"})})]}):jsxs("div",{className:"flex flex-col items-center gap-4 p-6",children:[jsx(Upload,{className:"h-12 w-12 text-text-secondary"}),jsxs("div",{className:"text-center",children:[jsx("p",{className:"text-sm text-text-primary",children:d}),jsx("p",{className:"mt-1 text-xs text-text-secondary",children:o==="image/*"?"PNG, JPG, GIF up to 10MB":`Accepts ${o}`})]}),jsx(FileTrigger,{acceptedFileTypes:o.split(","),onSelect:w=>{let T=Array.from(w||[]);T.length>0&&x(T[0]);},children:jsx(te,{variant:"secondary",size:"sm",isDisabled:a,children:"Choose File"})})]}),m&&jsx("div",{className:"absolute inset-0 flex items-center justify-center rounded-lg bg-background-surface/80",children:jsxs("div",{className:"flex flex-col items-center gap-2",children:[jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-action-brand border-t-transparent"}),jsx("span",{className:"text-sm text-text-secondary",children:"Uploading..."})]})})]}),g&&jsx("p",{className:"mt-2 text-sm text-feedback-error-text",children:g})]})}function rC({version:e,isLatest:t,updateAvailable:r,isLoading:o,size:n="sm",shape:a="rounded",...i}){if(o)return jsx(q,{className:"inline-flex h-6 w-16"});let s="neutral",l=e;return t?s="success":r&&(s="warning",l=`${e} (Update)`),jsx(kt,{variant:s,size:n,shape:a,...i,children:l})}function Ii(e){return jsx(Form,{validationBehavior:"aria",...e,className:twMerge("flex flex-col gap-6",e.className)})}function nC({placeholder:e="Search...",value:t,onChange:r,isOpen:o,onOpenChange:n,trigger:a,children:i,showShortcutHint:s=true,showInput:l=true,className:d}){let[c,u]=useState(false),m=Pr("(max-width: 767px)"),p=o!==void 0?o:c,g=useCallback(v=>{n?n(v):u(v);},[n]);useEffect(()=>{let v=x=>{(x.metaKey||x.ctrlKey)&&x.key==="k"&&(x.preventDefault(),g(!p)),x.key==="Escape"&&p&&g(false);};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[p,g]);let f=useCallback(v=>{r?.(v);},[r]),b=jsxs("button",{type:"button",className:"flex items-center gap-2 px-3 py-2 text-sm text-text-secondary hover:text-text-primary hover:bg-background-hover rounded-md transition-colors","aria-label":"Open search",children:[jsx(G,{name:"MagnifyingGlass",size:18}),!m&&s&&jsxs("span",{className:"hidden md:flex items-center gap-1 text-xs",children:[jsx("kbd",{className:"px-1.5 py-0.5 bg-background-muted border border-border-muted rounded text-xs",children:navigator.platform.includes("Mac")?"\u2318":"Ctrl"}),jsx("kbd",{className:"px-1.5 py-0.5 bg-background-muted border border-border-muted rounded text-xs",children:"K"})]})]}),h=a===null||isValidElement(a)&&a.type===Fragment$1&&!a.props.children;return m?jsxs(Fragment,{children:[!h&&(a?jsx("button",{type:"button",onClick:()=>g(true),className:"appearance-none bg-transparent border-none p-0 cursor-pointer",children:a}):jsx("button",{type:"button",onClick:()=>g(true),className:"appearance-none bg-transparent border-none p-0 cursor-pointer",children:b})),jsx(Lt,{isOpen:p,onClose:()=>g(false),hideCloseIcon:false,contentPadding:false,maxHeight:"90vh",children:jsxs("div",{className:"flex flex-col h-full",children:[l&&jsx("div",{className:"p-4 border-b border-border-muted flex-shrink-0",children:jsx(fo,{value:t,onChange:f,placeholder:e,showSearchIcon:true,isClearable:!!t,onClear:()=>r?.(""),reserveErrorSpace:false,className:d,autoFocus:true})}),jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:i})]})})]}):h?null:jsxs(DialogTrigger,{isOpen:p,onOpenChange:g,children:[a||b,jsx(Et,{placement:"bottom",className:"w-[600px] max-w-[90vw] bg-background-surface shadow-xl border border-border-default rounded-lg overflow-hidden",children:jsxs("div",{className:"flex flex-col",children:[l&&jsx("div",{className:"p-4 border-b border-border-muted",children:jsx(fo,{value:t,onChange:f,placeholder:e,showSearchIcon:true,isClearable:!!t,onClear:()=>r?.(""),reserveErrorSpace:false,className:d,autoFocus:true})}),jsx("div",{className:"max-h-[500px] overflow-hidden",children:i})]})})]})}function sC({placeholder:e="Search...",value:t,onChange:r,isOpen:o,onOpenChange:n,children:a,maxHeight:i="400px",variant:s="default",className:l}){let[d,c]=useState(false),u=Pr("(max-width: 767px)"),m=useRef(null),p=useRef(null),g=o!==void 0?o:d,f=useCallback(R=>{n?n(R):c(R);},[n]);useEffect(()=>{let R=A=>{(A.metaKey||A.ctrlKey)&&A.key==="k"&&(A.preventDefault(),f(!g)),A.key==="Escape"&&g&&f(false);};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[g,f]),useEffect(()=>{g&&!u&&m.current&&setTimeout(()=>{m.current?.querySelector("input")?.focus();},0);},[g,u]),useEffect(()=>{if(!g||u)return;let R=A=>{let M=A.target,B=m.current?.contains(M),D=p.current?.contains(M);!B&&!D&&f(false);};return document.addEventListener("mousedown",R,true),()=>document.removeEventListener("mousedown",R,true)},[g,u,f]);let b=R=>{r?.(R);},h=useCallback(()=>{f(false);},[f]),v=useCallback(()=>{r?.("");},[r]),[x,C]=useState(null);useEffect(()=>{if(g&&!u&&m.current){let R=null,A=()=>{let B=m.current?.getBoundingClientRect();B&&C({top:B.bottom+8,left:B.left,width:B.width});},M=()=>{R===null&&(R=requestAnimationFrame(()=>{A(),R=null;}));};return A(),window.addEventListener("resize",M),window.addEventListener("scroll",M,true),()=>{window.removeEventListener("resize",M),window.removeEventListener("scroll",M,true),R!==null&&cancelAnimationFrame(R);}}},[g,u]);let S=useCallback(()=>{f(true);},[f]);if(u)return jsxs("div",{className:l,children:[jsx("button",{type:"button",onClick:S,className:"flex items-center justify-center w-10 h-10 rounded-lg hover:bg-background-hover transition-colors","aria-label":"Open search",children:jsx(G,{name:"MagnifyingGlass",size:"md"})}),jsxs(Lt,{isOpen:g,onClose:h,contentPadding:false,height:"80vh",children:[jsxs("div",{className:"flex items-center gap-2 px-4 pt-4",children:[jsx("div",{className:"flex-1",children:jsx(fo,{value:t,onChange:b,placeholder:e,showSearchIcon:true,isClearable:!!t,onClear:v,reserveErrorSpace:false,autoFocus:true})}),jsx(te,{variant:"icon",onPress:h,"aria-label":"Close search",className:"flex-shrink-0",children:jsx(G,{name:"X",size:"md"})})]}),jsx("div",{className:"mt-4",children:a})]})]},"mobile");let w=R=>{let M=R.target.tagName==="INPUT";if(R.key==="ArrowDown"&&g&&M){R.preventDefault();let B=p.current?.querySelector("[data-search-result]");B&&B.focus();}},T=R=>{let A=R.target;if(!A.hasAttribute("data-search-result"))return;let B=Array.from(p.current?.querySelectorAll("[data-search-result]")||[]),D=B.indexOf(A);if(R.key==="ArrowDown"){R.preventDefault(),R.stopPropagation();let W=Math.min(D+1,B.length-1);B[W]?.focus();}else if(R.key==="ArrowUp")if(R.preventDefault(),R.stopPropagation(),D===0)m.current?.querySelector("input")?.focus();else {let W=Math.max(D-1,0);B[W]?.focus();}else R.key==="Escape"&&(R.preventDefault(),R.stopPropagation(),f(false),m.current?.querySelector("input")?.focus());},N=g&&x&&typeof document<"u"?createPortal(jsx("div",{ref:p,style:{position:"fixed",top:`${x.top}px`,left:`${x.left}px`,width:`${x.width}px`,zIndex:9999},role:"listbox",onKeyDown:T,children:jsx("div",{className:"bg-background-surface shadow-2xl border border-border-default rounded-lg overflow-hidden animate-in fade-in zoom-in-95 duration-200",children:jsx("div",{className:"overflow-y-auto",style:{maxHeight:i},children:a})})}),document.body):null,k=s==="elevated"?"bg-background-muted/50 border-border-subtle/50 focus-within:bg-background-body focus-within:border-border-focus focus-within:shadow-md backdrop-blur-sm transition-all duration-200":"";return jsxs("div",{ref:m,className:`relative w-full ${l||""}`,onKeyDown:w,children:[jsx(fo,{value:t,onChange:b,placeholder:e,showSearchIcon:true,isClearable:!!t,onClear:()=>r?.(""),reserveErrorSpace:false,className:k,onFocus:()=>f(true)}),N]},"desktop")}function lC({message:e="No results found",suggestion:t,icon:r="MagnifyingGlass",className:o=""}){return jsxs("div",{className:`flex flex-col items-center justify-center py-12 px-4 text-center ${o}`,children:[jsx("div",{className:"text-text-secondary mb-3",children:jsx(G,{name:r,size:48})}),jsx("p",{className:"text-base font-medium text-text-primary mb-1",children:e}),t&&jsx("p",{className:"text-sm text-text-secondary max-w-xs",children:t})]})}function dC({count:e=3,className:t=""}){return jsx("div",{className:`flex flex-col ${t}`,children:Array.from({length:e}).map((r,o)=>jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[jsx(q,{width:20,height:20,variant:"circle"}),jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[jsx(q,{width:"60%",height:16}),jsx(q,{width:"40%",height:12})]}),jsx(q,{width:16,height:16})]},o))})}function pC({title:e,count:t,isLoading:r,footer:o,children:n,className:a}){return jsxs("div",{className:twMerge("flex flex-col",a),children:[jsxs("div",{className:"flex items-baseline gap-1.5 px-4 pt-4 pb-2 border-t border-border-muted first:border-t-0",children:[jsx("h3",{className:"text-sm font-semibold text-text-primary",children:e}),!r&&t!==void 0&&jsx("span",{className:"text-xs text-text-secondary",children:t}),r&&jsx("span",{className:"text-xs text-text-secondary animate-pulse",children:"Loading..."})]}),jsx("div",{className:"flex flex-col",children:n}),o&&jsx("div",{className:"px-4 py-2 border-t border-border-subtle",children:o})]})}function mC({id:e,title:t,subtitle:r,metadata:o,icon:n,customIcon:a,onSelect:i,isFocused:s=false,className:l,testId:d}){return jsxs("div",{role:"option",tabIndex:0,onClick:()=>{i?.(e);},onKeyDown:m=>{let p=m.currentTarget;switch(m.key){case "Enter":case " ":{m.preventDefault(),i?.(e);break}case "ArrowDown":{m.preventDefault();let g=Array.from(document.querySelectorAll("[data-search-result]")),f=g.indexOf(p);f!==-1&&f<g.length-1&&g[f+1].focus();break}case "ArrowUp":{m.preventDefault();let g=Array.from(document.querySelectorAll("[data-search-result]")),f=g.indexOf(p);if(f>0)g[f-1].focus();else {let b=document.querySelector('input[type="text"][placeholder*="Search"]');b&&b.focus();}break}case "Escape":{m.preventDefault();let g=document.querySelector('input[type="text"][placeholder*="Search"]');g&&g.focus();break}}},"data-testid":d,"data-search-result":true,className:twMerge("group flex items-center gap-3 px-4 py-3 cursor-pointer outline-none transition-colors","text-text-primary hover:bg-background-hover","focus-visible:bg-background-muted focus-visible:outline-none","data-[focused]:bg-background-hover",s&&"bg-background-hover",l),"data-focused":s||void 0,children:[a?jsx("div",{className:"flex-shrink-0",children:a}):n?jsx("div",{className:"flex-shrink-0 text-text-secondary",children:jsx(G,{name:n,size:20})}):null,jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"flex items-baseline gap-2",children:[jsx("span",{className:"font-medium text-text-primary truncate",children:t}),o&&jsx("span",{className:"text-xs text-text-secondary flex-shrink-0",children:o})]}),r&&jsx("div",{className:"text-sm text-text-secondary truncate mt-0.5",children:r})]}),jsx("div",{className:"flex-shrink-0 opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100 group-data-[focused]:opacity-100 transition-opacity",children:jsx(G,{name:"ArrowRight",size:16,className:"text-text-secondary"})})]})}function fC({children:e,maxHeight:t="400px",className:r}){return jsx("div",{className:twMerge("overflow-y-auto overscroll-contain","divide-y divide-border-muted",r),style:{maxHeight:t},children:e})}function hC({placeholder:e="Search...",onClick:t,showShortcut:r=true,variant:o="default",className:n=""}){let a=typeof navigator<"u"&&navigator.platform.includes("Mac");return jsxs("button",{type:"button",onClick:t,className:`
|
|
168
|
+
`+i),i.includes("xmlns=")||(i=i.replace("<svg",'<svg xmlns="http://www.w3.org/2000/svg"'));let s=new Blob([i],{type:"image/svg+xml;charset=utf-8"}),l=dm(t.filename||"chart","svg",t.timestamp!==!1);(0,yc.saveAs)(s,l);}catch(r){throw new Error(`SVG export failed: ${r instanceof Error?r.message:"Unknown error"}`)}}async function oR(e,t,r=2){if(!e.current)throw new Error("SVG element not found");let o="";try{let n=e.current,a=n.getBoundingClientRect(),i=n.cloneNode(!0);px(n,i),i.setAttribute("width",String(a.width)),i.setAttribute("height",String(a.height)),i.removeAttribute("transform");let s=i.getElementsByTagName("text");Array.from(s).forEach(m=>{m.style.fontFamily||(m.style.fontFamily="system-ui, -apple-system, sans-serif"),m.style.fontSize||(m.style.fontSize="12px");});let l=document.createElementNS("http://www.w3.org/2000/svg","rect");l.setAttribute("width",String(a.width)),l.setAttribute("height",String(a.height)),l.setAttribute("fill","white"),i.insertBefore(l,i.firstChild);let c=new XMLSerializer().serializeToString(i);c.includes("xmlns=")||(c=c.replace("<svg",'<svg xmlns="http://www.w3.org/2000/svg"'));let u=new Blob([c],{type:"image/svg+xml;charset=utf-8"});return o=URL.createObjectURL(u),new Promise((m,p)=>{let g=new Image,f=setTimeout(()=>{o&&URL.revokeObjectURL(o),p(new Error("Image loading timeout"));},1e4);g.onload=()=>{clearTimeout(f);try{let b=document.createElement("canvas");b.width=a.width*r,b.height=a.height*r;let h=b.getContext("2d");if(!h)throw new Error("Canvas context not available");h.imageSmoothingEnabled=!0,h.imageSmoothingQuality="high",h.scale(r,r),h.fillStyle="white",h.fillRect(0,0,a.width,a.height),h.drawImage(g,0,0,a.width,a.height),b.toBlob(v=>{if(v){let x=dm(t.filename||"chart","png",t.timestamp!==!1);(0,yc.saveAs)(v,x),m();}else p(new Error("Failed to create PNG blob"));o&&URL.revokeObjectURL(o);},"image/png",1);}catch(b){o&&URL.revokeObjectURL(o),p(b);}},g.onerror=()=>{clearTimeout(f),o&&URL.revokeObjectURL(o),p(new Error("Failed to load SVG as image"));},g.src=o;})}catch(n){throw o&&URL.revokeObjectURL(o),new Error(`PNG export failed: ${n instanceof Error?n.message:"Unknown error"}`)}}function nR(e){if(typeof window>"u")return false;switch(e){case "csv":return true;case "svg":return typeof XMLSerializer<"u";case "png":return typeof HTMLCanvasElement<"u"&&typeof HTMLCanvasElement.prototype.toBlob=="function";default:return false}}function aR(e){return {csv:"CSV Spreadsheet",svg:"SVG Vector Image",png:"PNG Image"}[e]||"Unknown Format"}function vc({datasets:e,metadata:t,svgRef:r}){return useCallback(async o=>{try{await um(o,e,t,r);}catch(n){throw console.error("Chart export failed:",n),n}},[e,t,r])}var pm=({data:e,seriesMetadata:t,width:r,height:o,onBrushChange:n,brushRegion:a,margin:i=je,yDomain:s})=>{let l=useRef(null),d=useRef(false),c=useMemo(()=>e.flat(),[e]),u=useMemo(()=>({top:10,bottom:15,left:i.left,right:i.right}),[i]),m=r-u.left-u.right,p=useMemo(()=>{if(c.length===0)return scaleTime({domain:[new Date,new Date],range:[0,m]});let v=new Date(Math.min(...c.map(C=>C.xValue.getTime()))),x=new Date(Math.max(...c.map(C=>C.xValue.getTime())));return scaleTime({domain:[v,x],range:[0,m]})},[c,m]),g=useMemo(()=>{let v=c.length>0?Math.max(0,...c.map(x=>x.yValue)):1;return scaleLinear({domain:s??[0,v],range:[o-u.bottom,u.top]})},[c,o,s,u.top,u.bottom]),f=v=>{if(d.current)return;if(!v){n(null);return}let{x0:x,x1:C}=v;if(x===C)return;let S=new Date(x),w=new Date(C);if(!(Number.isNaN(S.getTime())||Number.isNaN(w.getTime()))){if(c.length>0){let T=Math.min(...c.map(M=>M.xValue.getTime())),N=Math.max(...c.map(M=>M.xValue.getTime())),R=(N-T)*.05;if(Math.abs(S.getTime()-T)<R&&Math.abs(w.getTime()-N)<R){n(null);return}}n([S,w]);}},b=useMemo(()=>{if(c.length!==0)return {start:{x:0,y:u.top},end:{x:m,y:o-u.bottom}}},[m,o,c]);useEffect(()=>{if(!l.current||c.length===0)return;let v=l.current.state;if(v?.isBrushing||v?.activeHandle)return;let x=Math.min(...c.map(k=>k.xValue.getTime())),C=Math.max(...c.map(k=>k.xValue.getTime())),S=a?a[0]:new Date(x),w=a?a[1]:new Date(C),T=l.current.state?.extent;if(T){let k=p.invert(T.x0),R=p.invert(T.x1),A=Math.abs(k.getTime()-S.getTime()),M=Math.abs(R.getTime()-w.getTime());if(A<1e3&&M<1e3)return}d.current=true;let N=k=>{let R=l.current.getExtent({x:p(S),y:u.top},{x:p(w),y:o-u.bottom});return {...k,start:{y:R.y0,x:R.x0},end:{y:R.y1,x:R.x1},extent:R}};l.current.updateBrush(N),setTimeout(()=>{d.current=false;},50);},[a,p,o,c]);let h={fill:"url(#brush_pattern)",fillOpacity:.15,stroke:"var(--color-border-focus)",strokeWidth:1.5,strokeOpacity:.3};return jsx("div",{className:"mt-2",children:jsxs("svg",{width:r,height:o,children:[jsx(PatternLines,{id:"brush_pattern",height:8,width:8,stroke:"var(--color-text-secondary)",strokeWidth:1,orientation:["diagonal"]}),jsxs("g",{transform:`translate(${u.left}, 0)`,children:[e.map((v,x)=>jsx(LinePath,{data:v,x:C=>p(C.xValue),y:C=>g(C.yValue),stroke:t[x]?.color||"var(--color-gray-500)",strokeWidth:1.5,opacity:.8},`brush-series-${x}`)),jsx(Brush,{xScale:p,yScale:g,width:m,height:o-u.top-u.bottom,margin:{top:u.top,bottom:u.bottom,left:0,right:0},handleSize:8,innerRef:l,resizeTriggerAreas:["left","right"],brushDirection:"horizontal",initialBrushPosition:b,onChange:f,onClick:()=>n(null),selectedBoxStyle:h,useWindowMoveEvents:true})]})]})})};function ln(e){switch(e){case "command":return _t("--color-action-brand","#111111");case "success":return _t("--color-feedback-success-border","#278a4a");case "warning":return _t("--color-feedback-warning-border","#c88420");case "error":return _t("--color-feedback-error-border","#c42d2d");case "alert":return _t("--color-feedback-warning-border","#c88420");default:return _t("--color-text-secondary","#525250")}}function Sc({events:e,color:t,showLabels:r=false}){let o=useContext(co),[n,a]=useState(null);if(!o)return console.warn("ChartEventMarkers must be used within a ChartContainer"),null;let{xScale:i,yScale:s,height:l,tooltip:d,datasets:c,seriesMetadata:u,seriesTypes:m,categoryColors:p}=o,g=e.filter(h=>{let v=i(h.timestamp);return v>=je.left&&v<=i.range()[1]}),f=useCallback((h,v)=>{a(v);let x=i(h.timestamp),C=x>(i.range()[1]-je.right-je.left)/2+je.left,S=[];c&&u&&c.forEach((N,k)=>{if(N.length===0)return;let R=bisector(W=>W.xValue).left,A=R(N,h.timestamp),M=N[A-1],B=N[A],D;if(!M)D=B;else if(!B)D=M;else {let W=Math.abs(h.timestamp.getTime()-M.xValue.getTime()),X=Math.abs(h.timestamp.getTime()-B.xValue.getTime());D=W<X?M:B;}D&&u[k]&&S.push({label:u[k].label,value:D.yValue,color:u[k].color,type:m?.[k]||"line",...D.category&&{category:D.category,categoryColor:p?.[D.category]}});});let T=g.filter(N=>Math.abs(i(N.timestamp)-x)<=10).map(N=>({label:N.label,color:N.color??t??ln(N.type),metadata:N.metadata}));S.push({label:T.length>1?`${T.length} events`:h.label,value:0,color:h.color??t??ln(h.type),type:"event"}),d.show({xValue:h.timestamp,series:S,x,y:S.length>1&&typeof S[0].value=="number"?s(S[0].value):l/2,position:C?"left":"right",isEvent:true,eventMetadata:h.metadata,eventItems:T});},[i,s,l,d,t,c,u,m,p,g]),b=useCallback(()=>{a(null),d.hide();},[d]);return g.length===0?null:jsx("g",{className:"chart-event-markers","data-testid":"chart-event-markers",children:g.map((h,v)=>{let x=i(h.timestamp),C=h.color??t??ln(h.type),S=n===v;return jsxs("g",{children:[jsx("line",{x1:x,y1:je.top,x2:x,y2:l-je.bottom,stroke:C,strokeWidth:S?3:2,strokeDasharray:"4 4",strokeOpacity:S?.9:.6,pointerEvents:"none"}),jsx("circle",{cx:x,cy:je.top,r:S?5:4,fill:C,stroke:"var(--color-background-surface)",strokeWidth:2,pointerEvents:"none"}),jsx("circle",{cx:x,cy:l-je.bottom,r:S?5:4,fill:C,stroke:"var(--color-background-surface)",strokeWidth:2,pointerEvents:"none"}),r&&jsx("text",{x,y:je.top-8,textAnchor:"middle",fill:"var(--color-text-secondary)",fontSize:11,fontWeight:500,pointerEvents:"none",children:h.label}),jsx("rect",{x:x-10,y:je.top,width:20,height:l-je.top-je.bottom,fill:"transparent",style:{cursor:"pointer"},onMouseEnter:()=>f(h,v),onMouseLeave:b})]},`${h.timestamp.getTime()}-${v}`)})})}var vR=bisector(e=>e.xValue).left;function CR(e,t){if(e.length===0)return;let r=vR(e,t),o=e[r-1],n=e[r];return o?n?Math.abs(t.getTime()-o.xValue.getTime())<Math.abs(t.getTime()-n.xValue.getTime())?{point:o,index:r-1}:{point:n,index:r}:{point:o,index:r-1}:n?{point:n,index:r}:void 0}function wc({spans:e,opacity:t=.25,color:r}){let o=useContext(co),[n,a]=useState(null),i=useRef(Number.NEGATIVE_INFINITY),s=o?.xScale,l=o?.yScale,d=o?.height,c=o?.tooltip,u=o?.datasets,m=o?.seriesMetadata,p=o?.seriesTypes,g=o?.categoryColors,[f,b]=s?.domain()??[new Date(0),new Date(0)],[h,v]=s?.range()??[0,0],x=useCallback((A,M,B)=>{if(!s||!c||(a(B),A.timeStamp-i.current<16))return;i.current=A.timeStamp;let{left:D}=A.currentTarget.ownerSVGElement?.getBoundingClientRect()??{left:0},W=A.clientX-D,X=s.invert(W),H=[];u&&m&&u.forEach((K,O)=>{let V=m[O],L=CR(K,X);if(!L||!V)return;let{point:y,index:E}=L,P=gc(V,y,E);H.push({label:V.label,value:y.yValue,...P!==void 0?{baselineValue:P}:{},chartY:y.chartYValue??y.yValue,showMarker:y.showTooltipMarker??true,color:V.color,type:p?.[O]??"line",...y.category?{category:y.category,categoryColor:g?.[y.category]}:{},...y.extraTooltipRows&&y.extraTooltipRows.length>0?{extraTooltipRows:y.extraTooltipRows}:{}});});let I=W>(v-h)/2+h,z=e.filter(K=>K.end>K.start&&K.start<M.end&&K.end>M.start).map(K=>({label:K.label,color:K.color??r??ln(K.type),metadata:K.metadata}));H.push({label:z.length>1?`${z.length} scheduled commands`:M.label,value:0,color:M.color??r??ln(M.type),type:"event"});let U=H.length>1?H[0]?.chartY??H[0]?.value:void 0;c.show({xValue:X,series:H,x:W,y:typeof U=="number"&&l?l(U):(d??0)/2,position:I?"left":"right",isEvent:true,eventMetadata:M.metadata,eventItems:z});},[s,l,d,c,u,m,p,g,r,h,v,e]),C=useCallback(()=>{a(null),c?.hide();},[c]);if(!o)return console.warn("ChartEventSpans must be used within a ChartContainer"),null;let{xScale:S,height:w}=o,T=je.top,k=w-je.bottom-T,R=e.filter(A=>A.end>A.start);return R.length===0?null:jsx("g",{className:"chart-event-spans","data-testid":"chart-event-spans",children:R.map((A,M)=>{let B=A.start<f?f:A.start,D=A.end>b?b:A.end;if(B>=b||D<=f)return null;let W=S(B),H=S(D)-W;if(H<=0)return null;let I=A.color??r??ln(A.type);return jsx("rect",{x:W,y:T,width:H,height:k,fill:I,fillOpacity:n===M?Math.min((t??.25)*1.8,1):t??.25,pointerEvents:"all",style:{cursor:"pointer"},onMouseMove:z=>x(z,A,M),onMouseLeave:C},`${A.start.getTime()}-${A.end.getTime()}-${M}`)})})}var vx=createContext(false);function fm({children:e}){return jsx(vx.Provider,{value:true,children:e})}function va(e){let t=useContext(vx),[r,o]=useState(false),[n,a]=useState(null),i=useRef(null),s=useCallback(u=>{if(i.current?.disconnect(),i.current=null,!u||typeof ResizeObserver>"u")return;let m=new ResizeObserver(([p])=>{if(!p)return;let{width:g,height:f}=p.contentRect;a(b=>b&&b.width===g&&b.height===f?b:{width:g,height:f});});m.observe(u),i.current=m;},[]);useEffect(()=>()=>i.current?.disconnect(),[]);let l=useCallback(()=>{o(false),a(null);},[]),d=t?null:jsx(te,{variant:"icon",size:"sm",icon:"ArrowsOutSimple","aria-label":`Expand ${e} chart`,onPress:()=>o(true)}),c=useCallback(u=>r&&!t?jsx(Dr,{isOpen:true,onClose:l,title:e,contentPadding:false,maxWidth:"min(1200px, 100vw)",minWidth:"min(360px, 100vw)",height:"82vh",mobileHeight:"82vh",children:jsx("div",{ref:s,className:"h-full w-full p-4",children:u})}):u,[r,t,l,e,s]);return {isExpanded:r,action:d,expandedSize:n,present:c}}function Nc(e){return e?.kind==="streaming"}function kc(e){if(typeof e!="string")return null;let t=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.\d{1,3})?(Z|[+-]\d{2}:\d{2})$/.exec(e);if(!t)return null;let r=Date.parse(e);if(!Number.isFinite(r))return null;let o=new Date(r),[,n,a,i]=t,s=new Date(`${n}-${a}-${i}T00:00:00Z`);return s.getUTCFullYear()!==Number(n)||s.getUTCMonth()+1!==Number(a)||s.getUTCDate()!==Number(i)?null:o}var kR={sm:"gap-4 px-6 py-8",md:"gap-5 px-8 py-12",lg:"gap-6 px-10 py-16"},PR={sm:"xs",md:"sm",lg:"md"},RR={sm:zt("bodySm"),md:zt("bodySm"),lg:zt("bodyMd")},MR={sm:"h-10 w-10",md:"h-12 w-12",lg:"h-16 w-16"},ER={sm:20,md:24,lg:32},LR={center:"items-center text-center [&_.empty-state-actions]:justify-center [&_.empty-state-actions]:text-center",start:"items-start text-left [&_.empty-state-actions]:justify-start [&_.empty-state-actions]:text-left"},DR={mesh:"radial-gradient(at 20% 20%, rgba(68, 74, 225, 0.06) 0px, transparent 45%), radial-gradient(at 80% 80%, rgba(68, 74, 225, 0.045) 0px, transparent 45%), radial-gradient(at 50% 50%, rgba(68, 74, 225, 0.03) 0px, transparent 50%)","top-fade":"linear-gradient(to bottom, rgba(68, 74, 225, 0.06) 0%, rgba(68, 74, 225, 0.02) 60%, transparent 100%)",center:"radial-gradient(ellipse 600px 400px at center, rgba(68, 74, 225, 0.06) 0px, transparent 60%)",corners:"radial-gradient(at 0% 0%, rgba(68, 74, 225, 0.06) 0px, transparent 40%), radial-gradient(at 100% 100%, rgba(68, 74, 225, 0.045) 0px, transparent 40%)",bottom:"radial-gradient(ellipse 700px 300px at 50% 100%, rgba(68, 74, 225, 0.06) 0px, transparent 60%)",asymmetric:"radial-gradient(at 15% 30%, rgba(68, 74, 225, 0.06) 0px, transparent 45%), radial-gradient(at 85% 70%, rgba(68, 74, 225, 0.04) 0px, transparent 50%)"};function ki({icon:e,title:t,description:r,primaryAction:o,secondaryAction:n,actions:a,size:i="md",alignment:s="center",variant:l="default",spotlightPattern:d="mesh",fullHeight:c=false,className:u}){let m=i==="sm"?"sm":"md",p=l==="spotlight",g=p?{background:DR[d]}:void 0,f=()=>a?jsx("div",{className:"empty-state-actions mt-2 flex flex-wrap items-center gap-3",children:a}):o||n?jsxs("div",{className:"empty-state-actions mt-2 flex flex-col gap-3",children:[o&&(o.href?jsx(te,{variant:"secondary",size:m,onPress:o.onPress,isDisabled:o.isDisabled,isLoading:o.isLoading,href:o.href,children:o.label}):jsx(te,{variant:"secondary",size:m,onPress:o.onPress,isDisabled:o.isDisabled,isLoading:o.isLoading,children:o.label})),n&&jsx(St,{href:n.href||"#",variant:"muted",onPress:n.onPress,className:zt("labelMd"),children:n.label})]}):null;return jsxs("section",{"data-testid":"empty-state",role:"status","aria-live":"polite",className:twMerge("flex w-full flex-col rounded-xl text-text-primary",kR[i],LR[s],c?"h-full justify-center":"",p?"relative overflow-hidden":"",u),style:g,children:[e&&jsx("div",{className:twMerge("flex items-center justify-center rounded-full border border-border-muted bg-background-muted text-text-secondary",MR[i]),children:jsx(G,{name:e,size:ER[i]})}),jsx(vr,{size:PR[i],tag:"h2",className:"text-text-secondary",children:t}),r&&jsx("p",{className:twMerge("max-w-xs text-text-secondary whitespace-pre-line",RR[i]),children:r}),f()]})}function cn(e,t=""){return Children.toArray(e).flatMap(r=>isValidElement(r)&&r.type===Fragment$1?cn(r.props.children,`${t}${String(r.key)}`):t&&isValidElement(r)?[cloneElement(r,{key:`${t}${String(r.key)}`})]:[r])}function Pc(e,t,r,o){if(r.length===0)throw new Error("tierForViewport: resolution ladder is empty");let n=[...r].sort((s,l)=>s.bucketMs-l.bucketMs),a=e/Math.max(1,t*o.targetPointsPerPx),i=Math.max(o.nativeMs,a);return n.find(s=>s.bucketMs>=i)??n[n.length-1]}function BR(e,t){return Math.floor(e/t.tileSpanMs)}function dn(e,t,r){let o=BR(e.startMs,t)-r,n=Math.ceil(e.endMs/t.tileSpanMs)-1+r,a=[];for(let i=o;i<=n;i++)a.push({tierId:t.id,index:i,startMs:i*t.tileSpanMs,endMs:(i+1)*t.tileSpanMs});return a}var br=(e,t)=>`${e}:${t}`,Ca=e=>!!e&&(e.line.length>0||(e.band?.length??0)>0||Object.values(e.lines??{}).some(t=>t.length>0));var wx={erroredTiles:0};function hm(e,t){let r=new Map,o=new Map,n=new Map,a=0;for(let m of e){let p=t.get(br(m.tierId,m.index));if(p&&(p.error&&(a+=1),!!p.data)){for(let g of p.data.line)r.set(g.xValue.getTime(),g);for(let g of p.data.band??[])o.set(g.xValue.getTime(),g);for(let[g,f]of Object.entries(p.data.lines??{})){let b=n.get(g);b||(b=new Map,n.set(g,b));for(let h of f)b.set(h.xValue.getTime(),h);}}}let i=(m,p)=>m.xValue.getTime()-p.xValue.getTime(),s=[...r.values()].sort(i),l=[...o.values()].sort(i),d=Object.fromEntries([...n.entries()].map(([m,p])=>[m,[...p.values()].sort(i)])),c,u;for(let m of [s,l,...Object.values(d)]){if(!m.length)continue;let p=m[0].xValue.getTime(),g=m[m.length-1].xValue.getTime();c=Math.min(c??p,p),u=Math.max(u??g,g);}return {line:s,band:l,lines:d,coverage:{earliestMs:c,latestMs:u,erroredTiles:a}}}function VR(e,t,r,o){let n=dn(e,t,0).filter(a=>o==null||a.startMs<o);return n.length===0?false:n.every(a=>{let i=r.get(br(a.tierId,a.index));return i!=null&&(i.status==="loaded"||i.status==="empty")})}function Tx(e,t,r){return dn(e,t,0).some(n=>{let a=r.get(br(n.tierId,n.index));return a?.status==="loaded"&&Ca(a.data)})}function OR(e,t){if(!Ca(e))return false;let r=e.coverage.earliestMs,o=e.coverage.latestMs;return r==null||o==null?false:r<t.endMs&&o>t.startMs}function Nx({viewport:e,targetTier:t,ladder:r,store:o,overscanTiles:n,prev:a,prevViewport:i,maxFutureMs:s}){let l=VR(e,t,o,s),d=dn(e,t,0).filter(p=>s==null||p.startMs<s).map(p=>o.get(br(p.tierId,p.index))),c=d.every(p=>p?.revalidated&&!p.refreshing&&!p.error),u=Tx(e,t,o);if(l&&(!u||a?.isFallback)&&d.some(p=>p?.refreshing||p?.error||p?.revalidated===false)&&a&&a.targetTier.id===t.id&&i?.startMs===e.startMs&&i?.endMs===e.endMs)return a;if(l&&(c||u)){let p=dn(e,t,n),{line:g,band:f,lines:b,coverage:h}=hm(p,o);return {line:g,band:f,lines:b,renderTier:t,targetTier:t,isFallback:false,isStale:false,coverage:h}}let m=r.findIndex(p=>p.id===t.id);for(let p=m+1;p<r.length;p++){let g=r[p];if(Tx(e,g,o)){let f=dn(e,g,n),{line:b,band:h,lines:v,coverage:x}=hm(f,o);return {line:b,band:h,lines:v,renderTier:g,targetTier:t,isFallback:true,isStale:false,coverage:x}}}if(l){let p=dn(e,t,n),{line:g,band:f,lines:b,coverage:h}=hm(p,o);return {line:g,band:f,lines:b,renderTier:t,targetTier:t,isFallback:false,isStale:false,coverage:h}}return a?OR(a,e)?{...a,targetTier:t,isFallback:true,isStale:false}:{line:a.line,band:a.band,lines:a.lines,renderTier:null,targetTier:t,isFallback:true,isStale:true,coverage:wx}:{line:[],band:[],lines:{},renderTier:null,targetTier:t,isFallback:false,isStale:false,coverage:wx}}var bm=new Map;function kx(e,t){switch(t.type){case "reset":return new Map;case "request":{let r=new Map(e);for(let o of t.ids){let n=r.get(o);t.refresh&&n?.data?r.set(o,{...n,refreshing:true,error:void 0,revalidated:false}):(!n||n.status==="error")&&r.set(o,{status:"loading",refreshing:!!t.refresh});}return r}case "cancel":{let r=new Map(e);for(let o of t.ids){let n=r.get(o);n&&r.set(o,{...n,refreshing:false,status:n.data?n.status:"error"});}return r}case "fulfilled":{let r=new Map(e);return r.set(t.id,{status:Ca(t.data)?"loaded":"empty",data:t.data,revision:(e.get(t.id)?.revision??0)+1,revalidated:t.refresh||e.get(t.id)?.revalidated}),r}case "failed":{let r=new Map(e),o=e.get(t.id);return r.set(t.id,o?.data?{...o,refreshing:false,error:t.error}:{status:"error",error:t.error}),r}default:return e}}function Rx({refs:e,refsKey:t,store:r,tier:o,viewport:n,fetchTile:a,dispatch:i,concurrency:s,maxFutureMs:l,resetKey:d,refreshKey:c,refreshEnabled:u=true,automaticLoads:m=false}){let p=useRef({resetKey:d,refreshKey:c,refreshEnabled:u});useLayoutEffect(()=>{p.current={resetKey:d,refreshKey:c,refreshEnabled:u};},[d,c,u]);let g=useRef(new Map),f=useRef(new Map),b=useRef(0),h=useRef(false),v=useRef(null),x=useRef(new Map),C=useRef({resetKey:d,refreshKey:c,refreshEnabled:u}),S=useRef(`${o.id}:${n.startMs}:${n.endMs}`),[w,T]=useReducer(k=>k+1,0),N=useCallback(()=>{for(let k of g.current.values())k.ac.abort();g.current.clear(),f.current.clear(),v.current=null,h.current=false,x.current.clear();},[]);return useEffect(()=>{let k=`${o.id}:${n.startMs}:${n.endMs}`,R=C.current.resetKey!==d,A=C.current.refreshKey!==c,M=C.current.refreshEnabled&&!u;if(R&&N(),u)(A||h.current)&&!R&&(h.current=false,b.current+=1,v.current={generation:b.current,seen:new Set});else {h.current||(h.current=f.current.size>0||[...g.current.values()].some(F=>F.refresh));let I=[...f.current.keys()];for(let F of I)x.current.set(F,S.current);f.current.clear(),v.current=null;for(let[F,z]of g.current)!z.refresh&&!(M&&z.automatic)||(z.ac.abort(),g.current.delete(F),I.push(F),x.current.set(F,M&&S.current===k?k:z.viewportKey));I.length&&i({type:"cancel",ids:I});}C.current={resetKey:d,refreshKey:u||R?c:C.current.refreshKey,refreshEnabled:u},S.current=k;let B=v.current;if(B){let I=[];for(let F of e){let z=br(F.tierId,F.index);B.seen.has(z)||l!=null&&F.startMs>=l||(B.seen.add(z),f.current.set(z,B.generation),I.push(z));}I.length&&i({type:"request",ids:I,refresh:true});}let D=new Set(e.map(I=>br(I.tierId,I.index)));for(let I of f.current.keys())D.has(I)||(f.current.delete(I),x.current.set(I,k),i({type:"cancel",ids:[I]}));for(let[I,F]of g.current)(F.tierId!==o.id||F.refresh&&!D.has(I))&&(F.ac.abort(),g.current.delete(I),x.current.set(I,k),i({type:"cancel",ids:[I]}));let W=e.filter(I=>{if(l!=null&&I.startMs>=l)return false;let F=br(I.tierId,I.index);if(g.current.has(F))return false;let z=r.get(F),U=x.current.get(F);return U===k&&!f.current.has(F)?false:f.current.has(F)||U!=null||!z||z.status==="loading"}),X=(n.startMs+n.endMs)/2;W.sort((I,F)=>Math.abs((I.startMs+I.endMs)/2-X)-Math.abs((F.startMs+F.endMs)/2-X));let H=W.slice(0,Math.max(0,s-g.current.size));for(let I of H){let F=br(I.tierId,I.index),z=f.current.get(F),U=z!==void 0,K={ac:new AbortController,tierId:I.tierId,generation:z??b.current,refresh:U,automatic:m&&u,viewportKey:k};x.current.delete(F),g.current.set(F,K),i({type:"request",ids:[F],refresh:U});let O=l!=null?Math.min(I.endMs,l):I.endMs,V=()=>!K.ac.signal.aborted&&p.current.resetKey===d&&g.current.get(F)===K&&(!K.automatic||p.current.refreshEnabled)&&(!U||p.current.refreshEnabled&&p.current.refreshKey===c)&&(f.current.get(F)??K.generation)===K.generation;Promise.resolve().then(()=>{if(K.ac.signal.aborted)throw new DOMException("Aborted","AbortError");return a(o,I.startMs,O,K.ac.signal,{reason:U?"refresh":"load",isCurrent:V})}).then(L=>{V()&&i({type:"fulfilled",id:F,data:L,refresh:U});}).catch(L=>{if(!V())return;let y=L instanceof Error?L.message:String(L);i({type:"failed",id:F,error:new Error(`tile fetch failed (tile ${F}, tier ${o.id}): ${y}`)});}).finally(()=>{g.current.get(F)===K&&(g.current.delete(F),f.current.get(F)===K.generation&&f.current.delete(F),!f.current.size&&![...g.current.values()].some(L=>L.refresh)&&(v.current=null),T());});}},[e,t,r,a,o,n,i,s,l,d,c,u,m,N,w]),useEffect(()=>N,[N]),{abortAll:N}}var Ex=1.3,KR=25e4,YR=3;function XR(e,t,r){let o=t.tileSpanMs/t.bucketMs,n=Math.max(1,Math.floor(KR/o/r));return Math.min(Math.max(1,Math.ceil(.5*e/t.tileSpanMs)),n)}function Rc(e){let{fetchTile:t,ladder:r,nativeMs:o,viewport:n,widthPx:a,maxFutureMs:i,targetPointsPerPx:s=1,concurrency:l=3,tileCostSeriesCount:d=YR,resetKey:c,refreshKey:u,refreshEnabled:m,automaticLoads:p}=e,g=useMemo(()=>({targetPointsPerPx:s,nativeMs:o}),[s,o]),[f,b]=useState(()=>Pc(n.endMs-n.startMs,Math.max(1,a),r,g)),[h,v]=useReducer(kx,bm),[x,C]=useState(c),S=x===c?h:bm,w=useRef(null),T=useRef(null);x!==c&&(C(c),w.current=null,T.current=null,v({type:"reset"}));let N=useRef(n.endMs-n.startMs),k=useRef(g);useEffect(()=>{let V=n.endMs-n.startMs,L=Pc(V,Math.max(1,a),r,g);if(L.id===f.id){k.current=g;return}let E=Pc(V,Math.max(1,a),r,k.current).id!==L.id,P=V/N.current;(E||P>Ex||P<1/Ex)&&(N.current=V,k.current=g,b(L));},[n,a,r,f.id,g]);let R=n.endMs-n.startMs,A=useMemo(()=>XR(R,f,d),[R,f,d]),M=useMemo(()=>dn(n,f,A),[n,f,A]),B=useMemo(()=>M.map(V=>br(V.tierId,V.index)).join(","),[M]),D=useRef(M);D.current=M;let W=useRef(n);W.current=n;let X=useRef(S);X.current=S,Rx({refs:M,refsKey:B,store:S,tier:f,viewport:n,fetchTile:t,dispatch:v,concurrency:l,resetKey:c,refreshKey:u,refreshEnabled:m,automaticLoads:p,...i!=null?{maxFutureMs:i}:{}});let H=useMemo(()=>D.current.map(V=>{let L=br(V.tierId,V.index),y=S.get(L);return `${L}:${y?.status??"\u2205"}:${y?.revision??0}:${!!y?.error}`}).join("|"),[B,S]),I=useMemo(()=>{let V=Nx({viewport:W.current,targetTier:f,ladder:r,store:X.current,overscanTiles:A,prev:w.current,prevViewport:T.current,maxFutureMs:i});return w.current=V,T.current=W.current,V},[H,f,r,A,n.startMs,n.endMs,i,c]),F=useMemo(()=>D.current.some(V=>X.current.get(br(V.tierId,V.index))?.status==="loading"),[H]),z=useMemo(()=>{let V=D.current[0];return V?X.current.get(br(V.tierId,V.index))?.status==="empty":false},[H]),U=M.map(V=>S.get(br(V.tierId,V.index))),K=U.some(V=>V?.refreshing),O=U.find(V=>V?.error)?.error;return {tier:f,series:I,loading:F,refreshing:K,refreshError:O,atDataStart:z}}function ym(e){let{initialViewport:t,...r}=e,[o,n]=useState(t),a=Rc({...r,viewport:o}),i=useCallback(l=>n(l),[]),s=useCallback(l=>n(l),[]);return {viewport:o,onViewportChange:i,jumpTo:s,...a}}var jR=1440*60*1e3,qR=[{id:"5y",label:"5 years",days:5*365},{id:"year",label:"Year",days:365},{id:"month",label:"Month",days:30},{id:"week",label:"Week",days:7},{id:"day",label:"24h",days:1}],ZR=[{id:"day",days:1},{id:"week",days:7},{id:"month",days:30}];function Lx(e,t=Date.now){return ZR.map(({id:r,days:o})=>({id:r,label:e[r],getRange:()=>{let n=new Date(t());return {after:subDays(n,o),before:n}}}))}function Mc(e=Date.now){return qR.map(({id:t,label:r,days:o})=>({id:t,label:r,getRange:()=>{let n=e();return {after:new Date(n-o*jR),before:new Date(n)}}}))}function r2({selectionState:e,isDisabled:t}){let r=`${pt} w-full h-full flex items-center justify-center rounded-sm forced-color-adjust-none font-semibold`,o={none:"text-text-primary group-hover:bg-background-muted group-pressed:bg-background-muted",middle:["bg-background-selected group-hover:bg-background-muted forced-colors:group-hover:bg-[Highlight]","group-invalid:group-hover:bg-feedback-error-background forced-colors:group-invalid:group-hover:bg-[Mark]","group-pressed:bg-background-muted forced-colors:group-pressed:bg-[Highlight] forced-colors:text-[HighlightText]","group-invalid:group-pressed:bg-feedback-error-background forced-colors:group-invalid:group-pressed:bg-[Mark]"].join(" "),cap:"bg-action-default text-[color:var(--color-action-default-text)] group-invalid:bg-feedback-error-border forced-colors:bg-[Highlight] forced-colors:group-invalid:bg-[Mark] forced-colors:text-[HighlightText]"},n=t?"text-text-disabled forced-colors:text-text-disabled font-light":"";return [r,o[e],n].filter(Boolean).join(" ")}function Ri({errorMessage:e,...t}){return jsxs(RangeCalendar,{...t,children:[jsx(nc,{}),jsxs(CalendarGrid,{className:"w-full border-separate [border-spacing:0] [&_td]:p-0 [&_td]:!border-0",children:[jsx(ac,{}),jsx(CalendarGridBody,{children:r=>jsx(CalendarCell,{date:r,className:"selection-start:rounded-s-full selection-end:rounded-e-full [td:last-child_&]:rounded-e-end group h-9 w-9 cursor-default text-sm border-0 outside-month:text-text-disabled invalid:selected:bg-feedback-error-background forced-colors:selected:bg-[Highlight] forced-colors:selected:text-[HighlightText] forced-colors:invalid:selected:bg-[Mark] [td:first-child_&]:rounded-s-full [&]:border-0",children:({formattedDate:o,isSelected:n,isSelectionStart:a,isSelectionEnd:i,isFocusVisible:s,isDisabled:l})=>jsx("span",{className:r2({selectionState:n&&(a||i)?"cap":n?"middle":"none",isDisabled:l}),children:o})})})]}),e&&jsx(Text,{slot:"errorMessage",className:"text-sm text-feedback-error-text",children:e})]})}function Ax(e){return e==="brand"?"primary":e==="default"||e==="secondary"||!e?"subtle":e}var n2={sm:"h-[var(--control-sm-height)] text-xs",md:"h-[var(--control-md-height)] text-sm",lg:"h-[var(--control-lg-height)] text-base",xl:"h-[var(--control-xl-height)] text-lg"},a2={sm:14,md:16,lg:18,xl:20},i2=({isSelected:e,isFirst:t,isLast:r,isDisabled:o,variant:n="subtle"})=>{let a=Ax(n),i=a==="primary"?"focus-visible:outline-action-primary":"focus-visible:outline-[color:var(--color-action-secondary-text)]";return a==="subtle"?twMerge(pt(),"focus-visible:outline-[color:var(--color-action-secondary-text)]","px-3 text-center transition cursor-pointer forced-color-adjust-none -ml-px first:ml-0 flex items-center justify-center h-full gap-2",e?"bg-background-muted text-text-primary font-medium forced-colors:!bg-[Highlight] forced-colors:!text-[HighlightText]":"text-text-secondary hover:bg-background-hover pressed:bg-background-hover forced-colors:!bg-[ButtonFace] forced-colors:!text-[ButtonText]",!r&&"border-r border-border-muted",o&&"bg-background-muted text-text-disabled forced-colors:!bg-[ButtonFace] forced-colors:!text-[GrayText] border-border-muted forced-colors:border-[GrayText] cursor-not-allowed"):twMerge(pt(),i,"px-3 text-center transition cursor-pointer forced-color-adjust-none -ml-px first:ml-0 flex items-center justify-center h-full gap-2",e?"bg-action-primary text-[color:var(--color-action-primary-text)] font-semibold forced-colors:!bg-[Highlight] forced-colors:!text-[HighlightText]":"text-text-secondary hover:bg-background-hover pressed:bg-background-hover forced-colors:!bg-[ButtonFace] forced-colors:!text-[ButtonText] hover:font-semibold",!r&&"border-r border-border-muted",o&&"bg-background-muted text-text-disabled forced-colors:!bg-[ButtonFace] forced-colors:!text-[GrayText] border-border-muted forced-colors:border-[GrayText] cursor-not-allowed")};function Lc({options:e,value:t,onChange:r,size:o="md",className:n,isDisabled:a,variant:i="subtle",iconOnly:s=false,"aria-label":l}){return jsx("div",{className:twMerge("inline-flex overflow-hidden rounded-[var(--control-border-radius)]",Ax(i)==="subtle"?"border border-border-muted":"border-2 border-border-muted",n2[o],n),role:"group","aria-label":l,children:e.map((d,c)=>{let u=s&&!!d.icon;return jsxs(ToggleButton,{isSelected:t===d.id,onChange:()=>r(d.id),className:i2({isSelected:t===d.id,isFirst:c===0,isLast:c===e.length-1,isDisabled:a,variant:i}),isDisabled:a,"aria-label":d.label,children:[d.icon&&jsx(G,{name:d.icon,size:a2[o]}),u?jsx("span",{className:"sr-only",children:d.label}):jsx("span",{className:"inline-flex flex-col items-center after:content-[attr(data-label)] after:font-semibold after:h-0 after:overflow-hidden after:invisible","data-label":d.label,children:d.label})]},d.id)})})}function d2(e){return e instanceof Date&&!Number.isNaN(e.getTime())}function Sm(e){return d2(e)?e:(console.warn("Invalid date detected in TimeControls, using fallback:",e),new Date)}var zx=120*1e3,u2=.02,Hx={ONE_MINUTE:0,FIVE_MINUTES:1,FIFTEEN_MINUTES:2,HOUR:3,DAY:4,WEEK:5,MONTH:6,YEAR:7},p2=[{id:"FIFTEEN_MINUTES",label:"15m"},{id:"HOUR",label:"1h"},{id:"DAY",label:"1d"},{id:"WEEK",label:"1w"}];function Dc({dateRange:e,onDateRangeChange:t,windowSize:r,onWindowSizeChange:o,showWindowSize:n=true,showRangeSelector:a=true,allowDatePicker:i=false,lockWindowSize:s=false,showReset:l=true,restrictToSingleDay:d=false,presetRanges:c=[],windowSizeOptions:u=p2,autoAdjustWindowSize:m=false,size:p="md",className:g}){let[f,b]=useState(0),h=useRef(null),[v,x]=useState(false),[C,S]=useState(null),w=y=>{let P=(y.before.getTime()-y.after.getTime())/(1e3*60*60);return P<=24?"FIFTEEN_MINUTES":P<=72||P<=168?"HOUR":("DAY")};useEffect(()=>{if(m&&!v&&o){let y=w(e);o(y);}},[e,m,v,o]);let T=y=>{let E;for(let P of c){let Y=P.getRange(),$=(Y.before.getTime()-Y.after.getTime())*u2,oe=Math.abs(Y.after.getTime()-y.after.getTime()),re=Math.abs(Y.before.getTime()-y.before.getTime());if(oe>$||re>$)continue;let _=oe+re;(!E||_<E.distance)&&(E={id:P.id,distance:_});}return E?.id},N=C&&c.some(y=>y.id===C.id)&&Math.abs(C.after-e.after.getTime())<=zx&&Math.abs(C.before-e.before.getTime())<=zx?C.id:T(e),k=Sm(e.after),R=Sm(e.before),A=new Date(R.getTime()-1),M={start:fromDate(k,getLocalTimeZone()),end:fromDate(A,getLocalTimeZone())};useEffect(()=>{let y=new ResizeObserver(E=>{for(let P of E)b(P.contentRect.width);});return h.current&&y.observe(h.current),()=>{h.current&&y.unobserve(h.current);}},[]);let B=[...u].sort((y,E)=>Hx[y.id]-Hx[E.id]),D=y=>{let E=y.toString(),P=c.find(Y=>Y.id===E);if(P){let Y=P.getRange();S({id:E,after:Y.after.getTime(),before:Y.before.getTime()}),x(false),t(Y,{presetId:E});}},W=y=>{if(y?.start&&y?.end){S(null);let E=new Date(y.start.year,y.start.month-1,y.start.day,0,0,0,0),P=new Date(y.end.year,y.end.month-1,y.end.day+1,0,0,0,0);t({after:E,before:P});}},X=y=>{if(y){S(null);let E=new Date(y.year,y.month-1,y.day,0,0,0,0),P=new Date(y.year,y.month-1,y.day+1,0,0,0,0);t({after:E,before:P});}},H=y=>{o&&(x(true),o(y.toString()));},I=()=>{c.length>0&&D(c[0].id);},F=y=>Sm(y).toLocaleDateString("en-US"),z=B.map(y=>({id:y.id,label:y.label,value:y.id})),U=c.map(y=>({id:y.id,label:y.label,value:y.id})),K=s?jsx("div",{className:"flex items-center rounded-md border border-border-muted bg-background-muted px-3 py-2 text-sm text-text-secondary",children:B.find(y=>y.id===r)?.label||r}):jsx(on,{className:"w-full md:w-auto",selectedKey:r,onSelectionChange:H,items:z,size:p,"aria-label":"Select Window Size",children:y=>jsx(Ir,{id:y.id,"aria-label":y.label,size:p,children:y.label},y.id)}),O=l&&!N&&c.length>0,V=d?jsx("div",{className:"flex items-center",children:jsxs(DialogTrigger,{children:[jsxs(te,{className:"border-l pl-2 pr-2 hover:border-border-default hover:bg-background-muted hover:text-text-link-hover",variant:"secondary",size:p,children:[jsx(G,{name:"CalendarBlank",size:18}),jsx("span",{className:"ml-2 hidden md:block",children:F(e.after)})]}),jsx(Et,{className:"z-50 w-auto p-3",disableGroup:true,children:jsx(xi,{"aria-label":"Select date",value:parseDate(k.toISOString().split("T")[0]),onChange:X})})]})}):jsxs("div",{className:"flex items-center",children:[jsxs(DialogTrigger,{children:[jsxs(te,{className:twMerge("border-l pl-2 pr-2 hover:border-border-default hover:bg-background-muted hover:text-text-link-hover",O&&"rounded-r-none"),variant:"secondary",size:p,children:[jsx(G,{name:"CalendarBlank",size:18}),!N&&jsx("span",{className:"ml-2 hidden md:block",children:`${F(e.after)} - ${F(A)}`})]}),jsx(Et,{className:"z-50 w-auto p-3",disableGroup:true,children:jsx(Ri,{"aria-label":"Date range calendar",value:M,onChange:W})})]}),O&&jsx(te,{variant:"ghost",size:p,onPress:I,children:"Reset"})]}),L=f<600;return jsx("div",{ref:h,className:twMerge("flex w-full flex-wrap items-center justify-between gap-4",g),children:L?jsxs("div",{className:"flex w-full justify-between",children:[jsxs("div",{className:"flex items-center",children:[i&&V,a&&c.length>0&&jsx(on,{selectedKey:N??"",onSelectionChange:D,items:U,size:p,"aria-label":"Select Date Range",children:y=>jsx(Ir,{id:y.id,size:p,children:y.label},y.id)})]}),jsx("div",{className:"flex items-center",children:n&&r&&K})]}):jsxs(Fragment,{children:[jsxs("div",{className:"flex items-center gap-4",children:[i&&V,a&&c.length>0&&jsx(Lc,{options:c.map(y=>({id:y.id,label:y.label})),value:N??"",onChange:D,size:"sm",variant:"secondary","aria-label":"Select Date Range"})]}),jsx("div",{className:"flex items-center",children:n&&r&&K})]})})}function Ac({children:e,label:t="About this chart"}){return jsx(tr,{content:e,placement:"bottom end",openOnPress:true,children:jsx(te,{variant:"ghost",size:"sm","aria-label":t,className:"px-1.5",children:jsx(G,{name:"Info",size:16})})})}function Ic(){let e=new Map;return {publish(t,r){for(let[o,n]of e)o!==t&&n(r);},subscribe(t,r){return e.set(t,r),()=>{e.delete(t);}}}}var g2=bisector(e=>e.xValue).left,h2=(e,t,r)=>{if(!e.tooltipRange||e.baseline===void 0)return;let o=typeof e.baseline=="function"?e.baseline(t,r):e.baseline;return typeof o=="number"&&Number.isFinite(o)&&o!==t.yValue?o:void 0};function Gx(e){let{mouseX:t,datasets:r,seriesMetadata:o,seriesTypes:n,xScale:a,yScale:i,plotLeft:s,plotRight:l}=e,d=a.invert(t),c=r.map((p,g)=>{if(!p||p.length===0)return null;let f=g2(p,d,1);if(f===0)return {point:p[0],index:0,datasetIndex:g};if(f>=p.length)return {point:p[p.length-1],index:p.length-1,datasetIndex:g};let b=p[f-1],h=p[f];if(!b||!h)return null;let v=Math.abs(b.xValue.getTime()-d.getTime()),x=Math.abs(h.xValue.getTime()-d.getTime()),C=v<x;return {point:C?b:h,index:C?f-1:f,datasetIndex:g}}).filter(p=>p!==null&&o[p.datasetIndex]!==void 0).map(({point:p,index:g,datasetIndex:f})=>({label:o[f].label,value:p.yValue,baselineValue:h2(o[f],p,g),color:o[f].color,point:p,type:n[f]}));if(c.length===0)return null;let u=a(c[0].point.xValue),m=u>(s+l)/2;return {xValue:c[0].point.xValue,series:c.map(({label:p,value:g,baselineValue:f,color:b,point:h,type:v})=>({label:p,value:g,...f!==void 0?{baselineValue:f}:{},chartY:h.chartYValue??g,showMarker:h.showTooltipMarker??true,color:b,type:v,...h.category!==void 0?{category:h.category}:{},...h.extraTooltipRows&&h.extraTooltipRows.length>0?{extraTooltipRows:h.extraTooltipRows}:{}})),x:u,y:i(c[0].point.chartYValue??c[0].value),position:m?"left":"right"}}var Kx=e=>e instanceof Date&&!Number.isNaN(e.getTime()),v2=160;function Fc(e,t,r){let[o,n]=useState(null);useImperativeHandle(r,()=>({setPreview:n}),[]);let[a,i]=e.range(),s=useMemo(()=>o?scaleTime$1().domain([new Date(o[0]),new Date(o[1])]).range([a,i]):e,[o,e,a,i]),l=s.domain(),d=l[0],c=l[l.length-1],u=Kx(d)&&Kx(c),m=t<400,p=Math.max(2,Math.min(8,Math.floor(t/(m?70:110)))),g=useMemo(()=>{if(!u)return [];let f=i-a;if(f<=0)return s.ticks(p);let[b,h]=s.domain(),v=b.getTime(),x=h.getTime(),C=(x-v)/f,S=Math.min(v2,f),w=S*C,T=scaleTime$1().domain([new Date(v-w),new Date(x+w)]).range([a-S,i+S]),N=timeTickInterval(b,h,p);if(N)return T.ticks(N);let k=Math.max(2,Math.round(p*(f+2*S)/f));return T.ticks(k)},[s,p,u,a,i]);return {activeScale:s,ticks:g,start:d,end:c,valid:u,compact:m,rangeStart:a,rangeEnd:i}}var T2=6,Yx=20,Nm=forwardRef(({top:e,scale:t,width:r},o)=>{let{activeScale:n,ticks:a,start:i,end:s,valid:l,compact:d,rangeStart:c,rangeEnd:u}=Fc(t,r,o),m=a.length>=2?a[1].getTime()-a[0].getTime():s.getTime()-i.getTime(),p=useMemo(()=>l?ch(m,{compact:d}):()=>"",[m,d,l]),g=useId(),f=Math.min(c,u),b=Math.abs(u-c);return jsxs("g",{children:[jsx("line",{x1:c,x2:u,y1:e,y2:e,stroke:"var(--color-border-muted)",strokeWidth:1}),a.length>0&&jsxs(Fragment,{children:[jsx("defs",{children:jsx("clipPath",{id:g,children:jsx("rect",{x:f,y:e-4,width:b,height:Yx+16})})}),jsx("g",{clipPath:`url(#${g})`,children:a.map(h=>jsxs("g",{transform:`translate(${n(h)},${e})`,children:[jsx("line",{x1:0,x2:0,y1:0,y2:T2,stroke:"var(--color-border-muted)",strokeWidth:1}),jsx("text",{x:0,y:Yx,textAnchor:"middle",fontSize:12,fill:"var(--color-text-secondary)",children:p(h)})]},h.getTime()))})]})]})});Nm.displayName="LiveTimeAxisBottom";var km=forwardRef(({scale:e,width:t,top:r,bottom:o},n)=>{let{activeScale:a,ticks:i,rangeStart:s,rangeEnd:l}=Fc(e,t,n),d=useId(),c=Math.min(s,l),u=Math.abs(l-s);return jsxs("g",{"aria-hidden":"true",children:[jsx("defs",{children:jsx("clipPath",{id:d,children:jsx("rect",{x:c,y:r,width:u,height:o-r})})}),jsx("g",{clipPath:`url(#${d})`,children:i.map(m=>{let p=a(m);return jsx("line",{x1:p,x2:p,y1:r,y2:o,stroke:"var(--color-border-muted)",strokeWidth:1},m.getTime())})})]})});km.displayName="LiveTimeGridlines";function Bc(e,t,r){let o=e[1]-e[0],n=t/Math.max(1,r)*o;return [e[0]-n,e[1]-n]}function Xx(e,t,r){let o=e[1]-e[0],n=e[0]+t*o,a=o/r,i=n-t*a;return [i,i+a]}function Pm(e,t,r=16,o=800){return t===1?e*r:t===2?e*o:e}var Jx=(e,t,r,o,n)=>{let a=t!==1?Xx(e,r,t):e;return o!==0&&(a=Bc(a,o,n)),a},Rm=(e,t)=>{if(!t)return e;let r=e[1]-e[0];if(r>=t[1]-t[0])return [t[0],t[1]];let[o,n]=e;return n>t[1]&&(n=t[1],o=n-r),o<t[0]&&(o=t[0],n=o+r),[o,n]},E2=e=>typeof requestAnimationFrame=="function"?requestAnimationFrame(e):setTimeout(()=>e(0),0),L2=e=>{typeof cancelAnimationFrame=="function"?cancelAnimationFrame(e):clearTimeout(e);};function jx(e){let{groupRef:t,overlayRef:r}=e,o=useRef({xDomain:e.xDomain,plotWidthPx:e.plotWidthPx,plotLeftPx:e.plotLeftPx??0});o.current={xDomain:e.xDomain,plotWidthPx:e.plotWidthPx,plotLeftPx:e.plotLeftPx??0};let n=useRef(e.onCommit);n.current=e.onCommit;let a=useRef(e.panBoundsMs);a.current=e.panBoundsMs;let i=useRef(e.getPanBoundsMs);i.current=e.getPanBoundsMs;let s=useRef(e.settleMs??140);s.current=e.settleMs??140;let l=useRef(e.zoomIntent??(F=>F.ctrlKey));l.current=e.zoomIntent??(F=>F.ctrlKey);let d=useRef(e.onGestureStart);d.current=e.onGestureStart;let c=useRef(e.onFramePreview);c.current=e.onFramePreview;let u=F=>F.button===0&&(F.shiftKey||F.ctrlKey||F.metaKey),m=useRef(e.selectIntent??u);m.current=e.selectIntent??u;let p=useRef(e.onSelectPreview);p.current=e.onSelectPreview;let g=useRef(null),f=useRef(null),b=useRef({scale:1,cursorFrac:.5,panDxPx:0,timer:null}),h=useRef(null),v=useRef(null),x=useRef(false),C=useCallback((F,z,U)=>{v.current={translateX:F,scaleX:z,preview:U},h.current==null&&(h.current=E2(()=>{h.current=null;let K=v.current;if(K!=null){let O=`translate(${K.translateX},0) scale(${K.scaleX},1)`;t.current?.setAttribute("transform",O),r?.current?.setAttribute("transform",O),c.current?.(K.preview);}}));},[t,r]),S=useCallback(()=>{h.current!=null&&(L2(h.current),h.current=null),v.current=null,t.current?.removeAttribute("transform"),r?.current?.removeAttribute("transform"),c.current?.(null);},[t,r]),w=useCallback(()=>{x.current||(x.current=true,d.current?.());},[]),T=useCallback(()=>{x.current=false;},[]),N=useCallback(()=>{b.current.timer!=null&&(clearTimeout(b.current.timer),b.current.timer=null);},[]),k=useCallback(()=>{b.current={scale:1,cursorFrac:.5,panDxPx:0,timer:null};},[]),R=useCallback(()=>{let{xDomain:F,plotWidthPx:z}=o.current,{scale:U,cursorFrac:K,panDxPx:O}=b.current;U===1&&O===0||n.current(Rm(Jx(F,U,K,O,z),i.current?.()??a.current));},[]),A=useCallback(()=>{b.current.timer!=null&&(N(),R(),k(),S());},[N,R,k,S]),M=useCallback(F=>{if(A(),F.currentTarget.setPointerCapture?.(F.pointerId),p.current&&m.current(F)){let z=F.currentTarget.getBoundingClientRect().left,U=F.clientX-z;f.current={startX:U,currentX:U,leftPx:z},p.current?.([0,0]),w();return}g.current={startX:F.clientX,dxPx:0},w();},[A,w]),B=useCallback(F=>{if(f.current){f.current.currentX=F.clientX-f.current.leftPx;let K=Math.max(1,o.current.plotWidthPx),O=Math.min(1,Math.max(0,f.current.startX/K)),V=Math.min(1,Math.max(0,f.current.currentX/K));p.current?.(O<=V?[O,V]:[V,O]);return}if(!g.current)return;g.current.dxPx=F.clientX-g.current.startX;let{xDomain:z,plotWidthPx:U}=o.current;C(g.current.dxPx,1,Bc(z,g.current.dxPx,U));},[C]),D=8,W=useCallback(F=>{if(f.current){let{startX:U,currentX:K}=f.current;if(f.current=null,p.current?.(null),T(),Math.abs(K-U)<D)return;let{xDomain:O,plotWidthPx:V}=o.current,L=Math.max(1,V),y=O[1]-O[0],E=$=>O[0]+Math.min(1,Math.max(0,$/L))*y,P=E(Math.min(U,K)),Y=E(Math.max(U,K));n.current(Rm([P,Y],i.current?.()??a.current));return}if(!g.current)return;let{dxPx:z}=g.current;g.current=null,S(),T(),z!==0&&n.current(Rm(Bc(o.current.xDomain,z,o.current.plotWidthPx),i.current?.()??a.current));},[S,T]),X=useCallback(()=>{if(f.current){f.current=null,p.current?.(null),T();return}g.current&&(g.current=null,S(),T());},[S,T]),H=useRef(null),I=useCallback(F=>{if(H.current?.(),H.current=null,!F)return;let z=U=>{if(g.current)return;let{plotWidthPx:K,plotLeftPx:O}=o.current,V=Pm(U.deltaY,U.deltaMode),L=Pm(U.deltaX,U.deltaMode),y=l.current(U);if(!y&&L===0)return;if(U.preventDefault(),w(),y){let $=Math.min(1,Math.max(0,(U.clientX-F.getBoundingClientRect().left)/Math.max(1,K)));b.current.scale*=Math.exp(-V/200),b.current.cursorFrac=$;}else b.current.panDxPx-=L;let{scale:E,cursorFrac:P,panDxPx:Y}=b.current;C((O+P*K)*(1-E)+Y,E,Jx(o.current.xDomain,E,P,Y,K)),N(),b.current.timer=setTimeout(()=>{R(),k(),S(),T();},s.current);};F.addEventListener("wheel",z,{passive:false}),H.current=()=>F.removeEventListener("wheel",z);},[C,S,N,R,k,w,T]);return useEffect(()=>()=>{H.current?.(),H.current=null,S(),b.current.timer!=null&&clearTimeout(b.current.timer);},[S]),{onPointerDown:M,onPointerMove:B,onPointerUp:W,onPointerCancel:X,wheelTargetRef:I,gestureActiveRef:x}}var Ta=({data:e,color:t="var(--color-viz-default)",strokeWidth:r=3,strokeDasharray:o,categoryColors:n={},maxGapMs:a,animate:i=true})=>{let{xScale:s,yScale:l,animationSettings:d,entrance:c}=ba(),[u]=ot__default.useState(()=>c?.played!==true),m=i&&u,p=l.range(),g=Object.keys(n).length>0,f=T=>T.category?n[T.category]??t:t,b=T=>T.chartYValue??T.yValue,h=e??[],v=h.length===1?h[0]:void 0,x=a!=null?uc(h,a):h,C=i?void 0:"non-scaling-stroke",S=v?jsx("circle",{cx:s(v.xValue),cy:l(b(v)),r,fill:g?f(v):t}):g?h.slice(0,-1).map((T,N)=>{let k=h[N+1];return a!=null&&a>0&&k.xValue.getTime()-T.xValue.getTime()>a?null:jsx(LinePath,{data:[T,k],x:R=>s(R.xValue),y:R=>l(b(R)),stroke:f(T),strokeWidth:r,strokeDasharray:o,strokeLinecap:"round",vectorEffect:C,curve:curveLinear},`${T.xValue.getTime()}-${k.xValue.getTime()}`)}):jsx(LinePath,{data:x,x:T=>T?s(T.xValue):0,y:T=>T?l(b(T)):0,defined:T=>T!=null,stroke:t,strokeWidth:r,strokeDasharray:o,strokeLinecap:"round",vectorEffect:C,curve:curveLinear}),w={transformOrigin:`0 ${p[0]}px`,transformBox:"fill-box",isolation:"isolate"};return m?jsx(motion.g,{initial:{scaleY:0},animate:{scaleY:1},transition:{duration:d.duration,ease:d.ease},style:w,children:S}):jsx("g",{style:w,children:S})};var _x=forwardRef(function({leftPx:t,topPx:r,widthPx:o,heightPx:n},a){let i=useRef(null),s=useRef(null),l=useRef(null),d=useRef(null);return useImperativeHandle(a,()=>({setRange:c=>{let u=i.current;if(!u)return;if(!c||c[1]-c[0]<=0){u.setAttribute("opacity","0");return}u.setAttribute("opacity","1");let m=t+c[0]*o,p=t+c[1]*o;s.current?.setAttribute("x",String(m)),s.current?.setAttribute("width",String(p-m)),l.current?.setAttribute("x1",String(m)),l.current?.setAttribute("x2",String(m)),d.current?.setAttribute("x1",String(p)),d.current?.setAttribute("x2",String(p));}})),jsxs("g",{ref:i,opacity:0,pointerEvents:"none",children:[jsx("rect",{ref:s,x:t,y:r,width:0,height:n,fill:"var(--color-viz-categorical-1)",fillOpacity:.12}),[l,d].map((c,u)=>jsx("line",{ref:c,x1:t,x2:t,y1:r,y2:r+n,stroke:"var(--color-viz-categorical-1)",strokeOpacity:.9,strokeWidth:1,strokeDasharray:"4 3"},u))]})});var ty=e=>e.type===Wn||e.type===Ta,W2=({children:e,title:t,hideExport:r=false,hiddenSeriesLabels:o,onLegendItemToggle:n,legend:a,xMarkers:i,headerActions:s,headerControls:l,viewport:d,panBounds:c,getPanBounds:u,onViewportChange:m,onPlotWidthChange:p,yFormatter:g={type:"number"},yDomain:f,referenceLines:b,cameraSync:h,parentWidth:v=0,parentHeight:x=0})=>{let[C,S]=useState(null),w=useRef(null),T=useRef(0),N=useId(),k=useRef(null),R=useRef(null),A=useRef(null),{colorMode:M}=hr(),B=useMemo(()=>tn(),[M]),D=useMemo(()=>$i(),[M]),{datasets:W,seriesMetadata:X,seriesTypes:H}=useMemo(()=>{let Z=cn(e).filter(Tt=>isValidElement(Tt)&&ty(Tt)),le=Z.filter(Tt=>Tt.props.data).length,Ae=[],Oe=[],it=[];return Z.forEach((Tt,Ot)=>{let tt=Tt.props;if(!tt.data)return;let xr="label"in tt&&tt.label||`Series ${Ae.length+1}`;Ae.push(o?.has(xr)?[]:tt.data);let xo=("color"in tt&&tt.color?tt.color:void 0)||(le===1?D:B[Ot%B.length]),ne=Tt.type===Wn;Oe.push({label:xr,color:xo,maxGapMs:tt.maxGapMs,...ne&&"baseline"in tt&&tt.baseline!==void 0?{baseline:tt.baseline,tooltipRange:"tooltipRange"in tt&&tt.tooltipRange||false}:{}}),it.push(ne?"area":"line");}),{datasets:Ae,seriesMetadata:Oe,seriesTypes:it}},[e,D,B,o]),I=va(t),F=I.expandedSize?.width??v,z=s||I.action?jsxs(Fragment,{children:[s,I.action]}):void 0,{headerRef:U,headerHeight:K}=ci(!!z,!!l),{ref:O,height:V}=Bl(),L=Math.max(100,(I.expandedSize?.height??x)-K-(V||50)),y=useMemo(()=>[new Date(d.startMs),new Date(d.endMs)],[d.startMs,d.endMs]),E=useMemo(()=>{let Z=W.flat(),le=W.flatMap((Ae,Oe)=>Ae.filter((it,Tt)=>{let Ot=it.xValue.getTime();if(Ot>=d.startMs&&Ot<=d.endMs)return true;if(typeof f!="function")return false;let tt=Ot<d.startMs?Ae[Tt+1]:Ae[Tt-1];if(!tt)return false;let xr=tt.xValue.getTime(),gr=X[Oe].maxGapMs;return gr!=null&&gr>0&&Math.abs(xr-Ot)>gr?false:Ot<d.startMs?xr>d.startMs:xr<d.endMs}));return le.length>0?le:Z},[W,X,d.startMs,d.endMs,f]),P=useMemo(()=>{let Z=typeof f=="function"?f(E):f,le=ys(E,L,g,Z);if(!f){let[Ae,Oe]=le.domain();Oe>Ae&&le.domain([Ae,Oe+(Oe-Ae)*.05]);}return le},[E,L,g,f]),Y=useRef(JSON.stringify(g)),$=useRef(null),oe=useMemo(()=>{let[Z,le]=P.domain(),Ae=Math.max(Math.abs(Z),Math.abs(le)),Oe=JSON.stringify(g);if(Oe!==Y.current&&(Y.current=Oe,$.current=null),$.current!==null)return $.current;if(Ae===0)return Si(g,0);let it=Si(g,Ae);return $.current=it,it},[P,g]),re=useMemo(()=>{let Z=L-je.top-je.bottom;return ya(Z)},[L]),_=useMemo(()=>{let Z=zr(oe),le=Z.tickFormat||Z.format,Oe=P.ticks(re).map(Ot=>le(Ot)),it=sn(Oe,12,"system-ui"),Tt=Math.ceil(it)+12;return {...je,left:Math.max(Tt,30),bottom:30}},[P,oe,re]),he=useMemo(()=>scaleTime({domain:y,range:[_.left,F-_.right]}),[y,F,_]),me=useMemo(()=>[d.startMs,d.endMs],[d.startMs,d.endMs]),ue=useMemo(()=>c?[c.startMs,c.endMs]:void 0,[c]),ie=useCallback(Z=>{m({startMs:Z[0],endMs:Z[1]});},[m]),fe=F-_.left-_.right,Te=useCallback(()=>S(null),[]),Ye=useRef({}),yt=useRef(h);yt.current=h;let Qt=useCallback(Z=>{R.current?.setPreview(Z),A.current?.setPreview(Z),yt.current?.publish(Ye.current,Z);},[]),Ze=useRef(null),fr=useRef(null),lr=useCallback(Z=>{fr.current?.setRange(Z);},[]),{onPointerDown:Ce,onPointerMove:Vt,onPointerUp:ee,onPointerCancel:Be,wheelTargetRef:Ve,gestureActiveRef:nt}=jx({onSelectPreview:lr,overlayRef:Ze,xDomain:me,plotWidthPx:fe,plotLeftPx:_.left,groupRef:k,onCommit:ie,onGestureStart:Te,onFramePreview:Qt,...ue?{panBoundsMs:ue}:{},...u?{getPanBoundsMs:()=>{let Z=u();return [Z.startMs,Z.endMs]}}:{}}),wt=useRef({startMs:d.startMs,endMs:d.endMs,left:0,width:0});wt.current={startMs:d.startMs,endMs:d.endMs,left:_.left,width:fe},useEffect(()=>{if(!h)return;let Z=()=>{k.current?.removeAttribute("transform"),R.current?.setPreview(null),A.current?.setPreview(null);},le=Oe=>{if(nt.current)return;if(Oe==null){Z();return}let{startMs:it,endMs:Tt,left:Ot,width:tt}=wt.current,xr=Tt-it,gr=Oe[1]-Oe[0];if(xr<=0||gr<=0||tt<=0)return;let xo=xr/gr,ne=Ot*(1-xo)+(it-Oe[0])*tt/gr;k.current?.setAttribute("transform",`translate(${ne},0) scale(${xo},1)`),R.current?.setPreview(Oe),A.current?.setPreview(Oe);},Ae=h.subscribe(Ye.current,le);return ()=>{Ae(),nt.current||Z();}},[h,nt]),useEffect(()=>{p?.(Math.max(0,F-_.left-_.right));},[F,_,p]);let Xt=useCallback(Z=>{if(nt.current)return;let{left:le}=w.current?.getBoundingClientRect()||{left:0},Ae=Z.clientX-le;Z.timeStamp-(T.current||0)<16||(T.current=Z.timeStamp,S(Gx({mouseX:Ae,datasets:W,seriesMetadata:X,seriesTypes:H,xScale:he,yScale:P,plotLeft:_.left,plotRight:F-_.right})));},[W,X,H,he,P,F,_,nt]),Q=useCallback(()=>S(null),[]),j=dc(),pe={width:F,height:L,xScale:he,yScale:P,yFormatter:oe,animationSettings:cc,entrance:j,tooltip:{data:C,show:S,hide:()=>S(null)},datasets:W,seriesMetadata:X,seriesTypes:H},ae=0,Ne=[];cn(e).forEach(Z=>{if(!isValidElement(Z)){Ne.push(Z);return}if(ty(Z)){let le=ae;ae++;let Ae=Z.props;Ne.push(ot__default.cloneElement(Z,{...Ae,...X[le]&&o?.has(X[le].label)?{data:[]}:{},color:X[le]?.color,animate:false}));}else Ne.push(Z);});let Qe=a??X.map(Z=>({category:Z.label,fill:Z.color,isHidden:o?.has(Z.label)??false})),Ue=vc({datasets:W,metadata:{xLabel:"Date",yLabel:"Value",seriesLabels:X.map(Z=>Z.label),timestamp:true},svgRef:w}),cr=jsxs(Fragment,{children:[jsx("title",{children:t}),jsx("g",{children:P.ticks(re).map(Z=>{let le=Math.abs(Z)<Number.EPSILON;return jsx(Line,{from:{x:_.left,y:P(Z)},to:{x:F-_.right,y:P(Z)},stroke:le?"var(--color-border-default)":"var(--color-border-muted)",strokeWidth:le?1.5:1},`grid-line-${Z}`)})}),jsx(km,{ref:A,scale:he,width:F-_.left-_.right,top:P.range()[1],bottom:P.range()[0]}),jsx("defs",{children:jsx("clipPath",{id:N,children:jsx("rect",{x:he.range()[0],y:P.range()[1],width:he.range()[1]-he.range()[0],height:P.range()[0]-P.range()[1]})})}),jsx("g",{clipPath:`url(#${N})`,children:jsx("g",{"data-camera-plot-group":"",ref:k,children:Ne})}),b&&b.length>0&&jsx("g",{children:b.map((Z,le)=>{let Ae=P(Z.value),Oe=Z.color??"var(--color-error-base)";return jsxs("g",{children:[jsx(Line,{from:{x:_.left,y:Ae},to:{x:F-_.right,y:Ae},stroke:Oe,strokeWidth:1.5,strokeDasharray:"6 4"}),Z.label&&jsx("text",{x:F-_.right-4,y:Ae-4,textAnchor:"end",fontSize:11,fill:Oe,children:Z.label})]},`ref-line-${le}`)})}),jsx(Nm,{ref:R,top:L-_.bottom,scale:he,width:F-_.left-_.right}),jsx(uo.Left,{left:_.left,scale:P,yFormatter:oe,height:L-_.top-_.bottom}),C&&!C.isEvent&&jsxs(Fragment,{children:[jsx(Line,{"data-testid":"chart-hover-crosshair",from:{x:he(C.xValue),y:P.range()[1]},to:{x:he(C.xValue),y:P.range()[0]},stroke:"var(--color-text-secondary)",strokeWidth:1,strokeDasharray:"3 3",opacity:.7}),C.series.filter(Z=>Z.type!=="bar"&&Z.showMarker!==false).map(Z=>jsxs("g",{children:[jsx("circle",{cx:he(C.xValue),cy:P(Z.chartY??Z.value),r:8,fill:"white",stroke:Z.color,strokeWidth:2,style:{transition:"all 100ms ease-out"}}),jsx("circle",{cx:he(C.xValue),cy:P(Z.chartY??Z.value),r:4,fill:Z.color,style:{transition:"all 100ms ease-out"}})]},`highlight-${Z.label}`))]}),jsx("rect",{"data-camera-surface":"",x:_.left,y:_.top,width:F-_.left-_.right,height:L-_.top-_.bottom,fill:"transparent",style:{cursor:"grab",touchAction:"none"},onMouseMove:Xt,onMouseLeave:Q,onPointerDown:Ce,onPointerMove:Vt,onPointerUp:ee,onPointerCancel:Be,onContextMenu:Z=>{(Z.ctrlKey||Z.metaKey)&&Z.preventDefault();},ref:Ve}),jsx("g",{ref:Ze,children:i?.map(Z=>{let le=he(new Date(Z.timeMs));if(!Number.isFinite(le)||le<_.left||le>F-_.right)return null;let Ae=Z.color??"var(--color-error-base)",Oe=()=>{Z.point&&S({xValue:new Date(Z.timeMs),series:[{label:Z.point.label,value:Z.point.value,color:Ae,showMarker:false}],x:le,y:P(Z.point.value),position:le>(_.left+(F-_.right))/2?"left":"right"});};return jsxs("g",{children:[jsx("line",{x1:le,x2:le,y1:_.top,y2:L-_.bottom,stroke:"transparent",strokeWidth:7,onMouseMove:Z.point?Oe:Xt,onMouseLeave:Q}),jsx("line",{x1:le,x2:le,y1:_.top,y2:L-_.bottom,stroke:Ae,strokeWidth:1,strokeOpacity:.75,vectorEffect:"non-scaling-stroke",pointerEvents:"none"})]},`${Z.timeMs}:${Z.label}`)})}),jsx(_x,{ref:fr,leftPx:_.left,topPx:_.top,widthPx:F-_.left-_.right,heightPx:L-_.top-_.bottom})]});return I.present(jsx("div",{className:"relative flex h-full flex-col",children:jsxs(co.Provider,{value:pe,children:[jsx(di,{title:t,controls:l,actions:z,containerRef:U}),jsx("svg",{width:F,height:L,className:"overflow-visible",ref:w,role:"img","aria-label":t,children:cr}),jsx(Ho,{data:C,formatter:oe}),jsx("div",{ref:O,children:jsx(Ti,{onExport:Ue,items:Qe,hideExport:r,marginLeft:12,marginRight:12,...n&&{onLegendItemToggle:n}})})]})}))},Ms=withParentSize(W2);var K2={single:[],band:["net"],pair:["import","export"]};function Y2({kind:e,series:t,seriesKeys:r}){let o=r??K2[e];return e==="single"?[t.line]:e==="band"?[...o.map(n=>t.lines[n]??[]),t.band.filter(n=>Number.isFinite(n.baselineValue))]:o.map(n=>t.lines[n]??[])}function X2(e){let{viewport:t,maxDataTimeMs:r}=e,o=null;for(let n of Y2(e))for(let a of n){let i=a.xValue.getTime();Number.isFinite(i)&&Number.isFinite(a.yValue)&&i>=t.startMs&&i<t.endMs&&i<=r&&(o===null||i>o)&&(o=i);}return o}function ry(e){let t=useId(),r=X2(e),o=r===null?null:new Date(r);return jsxs("span",{className:"inline-flex max-w-full flex-wrap items-baseline gap-x-1","aria-describedby":t,title:"Time marks the start of the latest interval with data plotted in this view.",children:[jsx("span",{children:"Latest data in view:"}),o?jsx("time",{dateTime:o.toISOString(),className:"font-medium text-text-primary",children:o.toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit",timeZoneName:"short"})}):jsx("span",{className:"font-medium text-text-primary",children:"Unavailable"}),jsx("span",{id:t,className:"sr-only",children:"Time marks the start of the latest interval with data plotted in this view."})]})}var q2={live:"Receiving updates",connecting:"Waiting for next update",reconnecting:"Reconnecting\u2026",stale:"No recent updates",delayed:"Measurements delayed","refresh-failed":"Update delayed"};function ny({label:e,checked:t,onChange:r,status:o,disabledReason:n,waitingDescription:a}){let i=useId(),s=t&&o==="live",l=n||(t?q2[o]:void 0);return jsxs("div",{className:"flex max-w-full shrink-0 flex-col items-end gap-1",children:[jsxs(te,{variant:"ghost",size:"sm","aria-label":e,"aria-pressed":t,...l&&{"aria-describedby":i},isDisabled:!!n,onPress:()=>r(!t),className:t?"text-text-primary":"text-text-secondary",children:[jsx("span",{"aria-hidden":"true","data-live-indicator":s?"live":"neutral",className:`size-1.5 shrink-0 rounded-full ${s?"bg-error-base":"bg-text-secondary"}`}),jsx("span",{children:t?"Live":"Static"})]}),jsxs("span",{id:i,role:"status","aria-atomic":"true",className:"max-w-64 text-right text-xs text-text-secondary",children:[l,!n&&t&&o==="connecting"&&a&&jsxs(Fragment,{children:[". ",a]})]})]})}var $2=1440*60*1e3,Dm=6e4,ay=(e,t)=>({startMs:t-e*$2,endMs:t}),eM=e=>({after:new Date(e.startMs),before:new Date(e.endMs)});function Gc({source:e,hideExport:t=false,hideWindowSummary:r=false,leadingControls:o,trailingControls:n,xMarkers:a,legend:i,hiddenSeriesLabels:s,onLegendItemToggle:l,title:d,liveControl:c,initialRange:u,viewportEnd:m,yFormatter:p,yDomain:g,referenceLines:f,emptyState:b,presetRanges:h,tierToWindow:v,windowSizeOptions:x,height:C=360,fitParent:S=false,hint:w,dataBounds:T,onViewChange:N,followLatest:k=false,followLatestKey:R,children:A,latestDataReadout:M,latestDataSeriesKeys:B,renderMetadata:D,panels:W}){let X=W!==void 0&&W.length>0,H=useMemo(()=>X?Ic():void 0,[X]),[I,F]=useState(900),z=e.refreshEnabled!==false,U=T?.endMs,[K,O]=useState(()=>U??Date.now()),V=m?.getTime()??U,L=k&&m===void 0&&T===void 0,[y,E]=useState(true),[P,Y]=useState(null),$=L&&y,[oe,re]=useState({resetKey:e.resetKey,automatic:false}),_=m===void 0&&T===void 0&&y,he=u?.days??30,me=useMemo(()=>ay(he,V??Date.now()),[he,V]),ue=useRef({resetKey:e.resetKey,refreshKey:e.refreshKey,refreshEnabled:z,followLatestKey:R}),ie=z&&(ue.current.resetKey!==e.resetKey||ue.current.refreshKey!==e.refreshKey||ue.current.refreshEnabled===false),fe=ue.current.resetKey===e.resetKey,Te=L&&ue.current.followLatestKey!==R,Ye=U??(ie||Te?Date.now():K);useEffect(()=>{ue.current={resetKey:e.resetKey,refreshKey:e.refreshKey,refreshEnabled:z,followLatestKey:R},(ie||Te)&&(fe&&re({resetKey:e.resetKey,automatic:true}),O(Ye));},[e.resetKey,e.refreshKey,z,R,ie,Te,Ye,fe]);let[yt,Qt]=useState(null),[Ze,fr]=useState(null),lr=yt??me,Ce=ym({fetchTile:e.fetchTile,ladder:e.ladder,nativeMs:e.nativeMs,initialViewport:me,widthPx:I,maxFutureMs:Ye,tileCostSeriesCount:e.tileCostSeriesCount,resetKey:e.resetKey,...e.refreshKey!==void 0&&{refreshKey:e.refreshKey},refreshEnabled:z&&P===null,automaticLoads:($||Te)&&(oe.resetKey===e.resetKey&&oe.automatic||fe&&(ie||Te))}),Vt=Ce.series.targetTier.bucketMs,ee=L?(Math.floor(Ye/Vt)+1)*Vt:Ye,Be=V==null?Math.max(ee,Ce.viewport.endMs):ee,Ve=useMemo(()=>({startMs:T?.startMs??0,endMs:Be}),[T?.startMs,Be]),nt=Le=>{let J=V==null?Math.max(Ve.endMs,Date.now()):Ve.endMs,se=Math.min(Le.endMs-Le.startMs,J-Ve.startMs),Pe=Math.max(Math.min(Le.endMs,J),Ve.startMs+se);return {startMs:Pe-se,endMs:Pe}},wt=(Le,J=true)=>{re({resetKey:e.resetKey,automatic:false});let se=Math.abs(Ve.endMs-Le)<=Dm||Math.abs(Date.now()-Le)<=Dm,Pe=J&&se;z&&Y(""),E(Pe),U==null&&O(Date.now());};useEffect(()=>{if(U!=null){O(U);return}if(!z)return;let Le,J=(Pe=true)=>{let Re=Date.now();Pe&&$&&re({resetKey:e.resetKey,automatic:true}),O(Re);let He=Vt-Re%Vt;Le=setTimeout(J,Math.min(Dm,He));},se=()=>{document.visibilityState==="visible"&&(clearTimeout(Le),J());};return J(false),document.addEventListener("visibilitychange",se),()=>{clearTimeout(Le),document.removeEventListener("visibilitychange",se);}},[U,Vt,z,$,e.resetKey]);let Xt=useRef(R);useEffect(()=>{let Le=Xt.current!==R;Xt.current=R,!(!Le||!L)&&(E(true),O(Date.now()));},[L,R]),useEffect(()=>{$&&z&&O(Date.now());},[$,z,e.resetKey,e.refreshKey]);let Q=Ce.jumpTo,{startMs:j,endMs:pe}=Ce.viewport;useEffect(()=>{if(!$)return;let Le=Math.max(pe-j,Vt);ee===pe&&Le===pe-j||(re({resetKey:e.resetKey,automatic:true}),Q({startMs:ee-Le,endMs:ee}));},[$,ee,j,pe,Vt,Q,e.resetKey]);let ae=useMemo(()=>Mc(()=>V??Date.now()),[V]),Ne=h??ae,Qe=()=>{if(Ze&&"presetId"in Ze){let Le=Ne.find(J=>J.id===Ze.presetId);if(Le){let J=Le.getRange();return {startMs:J.after.getTime(),endMs:J.before.getTime()}}}return Ze&&"range"in Ze?Ze.range:ay(he,V??Date.now())},{coverage:Ue,renderTier:cr,targetTier:Z,isFallback:le,isStale:Ae}=Ce.series,Oe=Z.id,it=cr?.id??null,{startMs:Tt,endMs:Ot}=Ce.viewport,tt=useRef(N);useEffect(()=>{tt.current=N;},[N]),useEffect(()=>{tt.current?.({targetTierId:Oe,renderedTierId:it,viewport:{startMs:Tt,endMs:Ot},followingLatest:$,atLiveEdge:_});},[Oe,it,Tt,Ot,$,_]),useEffect(()=>{if(P===null)return;let Le=`${Oe}:${Tt}:${Ot}`;Y(P===Le?null:Le);},[P,Oe,Tt,Ot]);let xr=cr?cr.bucketMs*1.5:0,gr=Le=>Le==null?"\u2014":new Date(Le).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),xo=(Le,J)=>{let se=J-Le<1728e5?{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}:{month:"short",day:"numeric",year:"numeric"},Pe=new Intl.DateTimeFormat("en-US",se);return `${Pe.format(new Date(Le))} \u2013 ${Pe.format(new Date(J))}`},ne=$?Ce.viewport.endMs-Ce.viewport.startMs!==lr.endMs-lr.startMs:Ce.viewport.startMs!==lr.startMs||Ce.viewport.endMs!==lr.endMs,Se=Ae||Ce.loading&&Ue.earliestMs==null,ce=(Ce.viewport.endMs-Ce.viewport.startMs)*.03,ct=!Se&&Ue.earliestMs!=null&&Ue.earliestMs>Ce.viewport.startMs+ce,yr=!Ce.loading&&Ue.earliestMs==null&&Ue.latestMs==null&&!Ca(Ce.series)&&!Ae,yo=va(d),vo=Fl(),yl=typeof a=="function"?a(Ce.series):a,Nu=sy(A({series:Ce.series,gapMs:xr})),Zi=jsxs("div",{className:`flex flex-col gap-3${yo.isExpanded||S?" h-full":""}`,children:[o&&jsx("div",{className:"flex flex-wrap items-center gap-3",children:o}),jsxs("div",{className:"flex flex-wrap items-start gap-2",children:[jsx("div",{className:"min-w-0 flex-[1_1_16rem]",children:jsx(Dc,{dateRange:eM(Ce.viewport),onDateRangeChange:(Le,J)=>{let se=nt({startMs:Le.after.getTime(),endMs:Le.before.getTime()});wt(se.endMs,!!J?.presetId),fr(J?.presetId?{presetId:J.presetId}:{range:se}),Qt(se),Ce.jumpTo(se);},windowSize:v[Z.id],windowSizeOptions:x,lockWindowSize:true,presetRanges:Ne,allowDatePicker:true,showReset:false})}),jsxs("div",{className:"ml-auto flex max-w-full flex-wrap items-start gap-2",children:[c&&jsx(ny,{...c,status:Ce.refreshError?"refresh-failed":c.status}),w&&!yr&&jsx(Ac,{label:`About ${d}`,children:w}),!yo.isExpanded&&!yr&&yo.action]})]}),jsxs("div",{className:"flex flex-wrap items-center gap-3 text-xs text-text-secondary",children:[!r&&jsxs(Fragment,{children:[jsxs("span",{children:["Window"," ",jsx("span",{className:"font-medium text-text-primary",children:xo(Ce.viewport.startMs,Ce.viewport.endMs)})]}),jsx("span",{className:"text-text-tertiary",children:"\u2022"}),jsxs("span",{children:["Resolution ",jsx("span",{className:"font-medium text-text-primary",children:cr?.id??Z.id}),le&&jsxs("span",{className:"text-text-tertiary",children:[" \xB7 loading ",Z.id]})]})]}),M&&jsx(ry,{kind:M,series:Ce.series,viewport:Ce.viewport,maxDataTimeMs:Ye,...B!==void 0?{seriesKeys:B}:{}}),D?.({series:Ce.series,viewport:Ce.viewport,maxDataTimeMs:Ye}),Ce.loading&&jsx("span",{className:"text-text-tertiary",children:"loading\u2026"}),Ce.refreshError&&jsx("span",{role:"status",className:"text-text-tertiary",children:Ue.earliestMs==null?"Unable to load telemetry":"Refresh failed \xB7 showing previous data"}),ct&&jsxs("span",{className:"text-text-tertiary",children:["showing available history from ",gr(Ue.earliestMs)]}),!r&&!ct&&!Se&&Ce.atDataStart&&jsx("span",{className:"text-text-tertiary",children:"no earlier data loaded"})]}),X&&!vo&&jsx("span",{className:"text-[11px] font-medium text-text-secondary",children:d}),jsxs("div",{className:`relative overflow-hidden rounded-md border border-border-subtle${yo.isExpanded||S?" min-h-0 flex-1":""}`,style:yo.isExpanded||S?void 0:{height:C},children:[ne&&!yr&&jsx("div",{className:"absolute top-2 right-2 z-10",children:jsx(te,{variant:"secondary",size:"sm",onPress:()=>{let Le=nt(Qe());wt(Le.endMs,!(Ze&&"range"in Ze)),Qt(Le),Ce.jumpTo(Le);},children:"\u27F2 Reset"})}),yr?jsx(ki,{title:b.title,description:b.description}):jsxs(Fragment,{children:[jsx(Ms,{title:d,hideExport:t,viewport:Ce.viewport,panBounds:Ve,getPanBounds:()=>({startMs:Ve.startMs,endMs:U??Math.max(Ve.endMs,Date.now())}),onViewportChange:Le=>{wt(Le.endMs),Ce.onViewportChange(Le);},onPlotWidthChange:F,...H&&{cameraSync:H},...p&&{yFormatter:p},...g&&{yDomain:g},...f&&{referenceLines:f},...yl?.length&&{xMarkers:yl},...i&&{legend:i},...s&&{hiddenSeriesLabels:s},...l&&{onLegendItemToggle:l},children:Nu}),Ce.loading&&jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 animate-pulse bg-[var(--color-viz-categorical-1)] opacity-60"})]})]}),X&&W.map(Le=>jsx(tM,{panel:Le,hideExport:Le.hideExport??t,viewport:Ce.viewport,panBounds:Ve,staticEndMs:U,maxFutureMs:Ye,widthPx:I,onViewportChange:J=>{wt(J.endMs),Ce.onViewportChange(J);},...H&&{cameraSync:H}},Le.key)),n&&jsx("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-1",children:jsx("div",{className:"ml-auto flex flex-wrap items-center gap-x-4 gap-y-1",children:n})})]});return jsx(fm,{children:yo.present(Zi)})}function sy(e){return isValidElement(e)&&e.type===Fragment$1?e.props.children:e}function tM({panel:e,hideExport:t,viewport:r,panBounds:o,staticEndMs:n,maxFutureMs:a,widthPx:i,onViewportChange:s,cameraSync:l}){let d=Rc({fetchTile:e.source.fetchTile,ladder:e.source.ladder,nativeMs:e.source.nativeMs,viewport:r,widthPx:i,maxFutureMs:a,resetKey:e.source.resetKey,tileCostSeriesCount:e.source.tileCostSeriesCount,...e.source.refreshKey!==void 0?{refreshKey:e.source.refreshKey}:{},...e.source.refreshEnabled!==void 0?{refreshEnabled:e.source.refreshEnabled}:{}}),c=d.series.renderTier?d.series.renderTier.bucketMs*1.5:0;return jsxs("div",{className:"flex flex-col gap-1",children:[jsx("span",{className:"text-[11px] font-medium text-text-secondary",children:e.title}),jsxs("div",{className:"relative overflow-hidden rounded-md border border-border-subtle",style:{height:e.height??220},children:[jsx(Ms,{title:e.title,hideExport:t,viewport:r,panBounds:o,getPanBounds:()=>({startMs:o.startMs,endMs:n??Math.max(o.endMs,Date.now())}),onViewportChange:s,...l&&{cameraSync:l},...e.yFormatter&&{yFormatter:e.yFormatter},...e.yDomain&&{yDomain:e.yDomain},...e.referenceLines&&{referenceLines:e.referenceLines},...e.legend&&{legend:e.legend},...e.hiddenSeriesLabels&&{hiddenSeriesLabels:e.hiddenSeriesLabels},...e.onLegendItemToggle&&{onLegendItemToggle:e.onLegendItemToggle},children:sy(e.children({series:d.series,gapMs:c}))}),d.loading&&jsx("div",{className:"pointer-events-none absolute inset-x-0 top-0 h-0.5 animate-pulse bg-[var(--color-viz-categorical-1)] opacity-60"})]})]})}var aM=12;function ly(e){let t=Number.isFinite(e)?Math.max(1,Math.floor(e)):1,r=0,o=[],n=()=>{for(;o.length>0;){let i=o[0];if(r+i.permits>t)return;o.shift(),r+=i.permits,i.grant();}},a=i=>()=>{r=Math.max(0,r-i),n();};return {acquire(i=1){let s=Math.min(t,Number.isFinite(i)?Math.max(1,Math.floor(i)):1);return o.length===0&&r+s<=t?(r+=s,Promise.resolve(dy(a(s)))):new Promise(l=>{o.push({permits:s,grant:()=>l(dy(a(s)))});})},get stats(){return {active:r,waiting:o.length}}}}function cy(){let e=new Error("The operation was aborted.");return e.name="AbortError",e}function dy(e){let t=false;return ()=>{t||(t=true,e());}}var iM=()=>{},sM={acquire:()=>Promise.resolve(iM),stats:{active:0,waiting:0}},Am=createContext(null);function py({maxConcurrent:e,children:t}){let r=useContext(Am),o=useMemo(()=>e!==void 0?ly(e):r??ly(aM),[e,r]);return createElement(Am.Provider,{value:o},t)}function Im(){return useContext(Am)??sM}function Fm(e,t,r=1){return async(...o)=>{let n=o[3],a=()=>n instanceof AbortSignal&&n.aborted;if(a())throw cy();let i=await e.acquire(r);try{if(a())throw cy();return await t(...o)}finally{i();}}}var gy=createContext(null),hy=createContext(null);function by({resolve:e,host:t,maxConcurrentFetches:r,children:o}){return jsx(gy.Provider,{value:e??null,children:jsx(hy.Provider,{value:t??null,children:jsx(py,{...r!==void 0?{maxConcurrent:r}:{},children:o})})})}function Es(){return useContext(gy)}function Ls(){return useContext(hy)}var Cy="line";function dM(e,t){return t===Cy?e.line:t==="band"?e.band:e.lines[t]??[]}function Sy(e){let t=0;for(let r of e)typeof r?.bucketMs=="number"&&Number.isFinite(r.bucketMs)&&r.bucketMs>0&&(t=t===0?r.bucketMs:Math.min(t,r.bucketMs));return t}function Wc(e){let t=Ls();return t?jsx(t,{source:e.source,children:r=>r?jsx(wy,{...e,resolved:r}):jsx(xy,{...e})}):jsx(xy,{...e})}function wy(e){let t=e.panels;return !t||t.length===0?jsx(yy,{...e}):jsx(Ty,{panels:t,index:0,acc:[],render:r=>jsx(yy,{...e,resolvedPanels:r})})}function xy(e){let t=Es(),r=useMemo(()=>t?.(e.source)??null,[t,e.source]);return r?jsx(wy,{...e,resolved:r}):jsx(ki,{icon:"ChartLine",title:e.emptyState?.title??"No data source",description:e.emptyState?.description??"This chart's data source is unavailable."})}function yy({source:e,title:t,children:r,yFormatter:o,yDomain:n,referenceLines:a,headerActions:i,height:s,hint:l,emptyState:d,tierToWindow:c,windowSizeOptions:u,presetRanges:m,latestDataReadout:p,latestDataSeriesKeys:g,resolved:f,resolvedPanels:b=[]}){let h=kc(e.viewportEnd),v=Im(),C={fetchTile:useMemo(()=>Fm(v,f.fetchSlice,f.fetchesPerSlice??1),[v,f.fetchSlice,f.fetchesPerSlice]),ladder:e.ladder,...f.refreshEnabled!==void 0?{refreshEnabled:f.refreshEnabled}:{},nativeMs:f.nativeMs??e.nativeMs??Sy(e.ladder),resetKey:e.resetKey??"",...f.refreshKey!==void 0?{refreshKey:f.refreshKey}:e.refreshKey!==void 0?{refreshKey:e.refreshKey}:{},tileCostSeriesCount:f.costSeriesCount??1};return jsx(Gc,{title:t,source:C,yFormatter:o,...n!==void 0?{yDomain:n}:{},...a!==void 0?{referenceLines:a}:{},...i!==void 0?{headerActions:i}:{},...s!==void 0?{height:s}:{fitParent:true},...f.liveControl!==void 0?{liveControl:f.liveControl}:{},...f.onViewChange!==void 0?{onViewChange:f.onViewChange}:{},...f.followLatest!==void 0?{followLatest:f.followLatest}:{},...f.followLatestKey!==void 0?{followLatestKey:f.followLatestKey}:{},...l!==void 0?{hint:l}:{},...e.initialRange!==void 0?{initialRange:e.initialRange}:{},...h!==null?{viewportEnd:h}:{},...m!==void 0?{presetRanges:m}:{},...p!==void 0?{latestDataReadout:p}:{},...g!==void 0?{latestDataSeriesKeys:g}:{},emptyState:d??{title:"No data",description:"No readings in this window."},tierToWindow:c??{},windowSizeOptions:u??[],...b.length>0?{panels:b}:{},children:({series:S,gapMs:w})=>ky(r,S,w)})}function Ty({panels:e,index:t,acc:r,render:o}){if(t>=e.length)return jsx(Fragment,{children:o(r)});let n=e[t];return jsx(uM,{panel:n,children:a=>jsx(Ty,{panels:e,index:t+1,acc:a?[...r,a]:r,render:o})})}function uM({panel:e,children:t}){let r=Ls();return r?jsx(r,{source:e.source,children:o=>o?jsx(Ny,{panel:e,resolved:o,children:t}):jsx(vy,{panel:e,children:t})}):jsx(vy,{panel:e,children:t})}function vy({panel:e,children:t}){let r=Es(),o=useMemo(()=>r?.(e.source)??null,[r,e.source]);return o?jsx(Ny,{panel:e,resolved:o,children:t}):jsx(Fragment,{children:t(null)})}function Ny({panel:e,resolved:t,children:r}){let o=Im(),n=useMemo(()=>Fm(o,t.fetchSlice,t.fetchesPerSlice??1),[o,t.fetchSlice,t.fetchesPerSlice]),a=useMemo(()=>({key:e.key,title:e.title,source:{fetchTile:n,ladder:e.source.ladder,nativeMs:t.nativeMs??e.source.nativeMs??Sy(e.source.ladder),resetKey:e.source.resetKey??"",tileCostSeriesCount:t.costSeriesCount??1,...t.refreshEnabled!==void 0?{refreshEnabled:t.refreshEnabled}:{},...t.refreshKey!==void 0?{refreshKey:t.refreshKey}:e.source.refreshKey!==void 0?{refreshKey:e.source.refreshKey}:{}},...e.yFormatter!==void 0?{yFormatter:e.yFormatter}:{},...e.yDomain!==void 0?{yDomain:e.yDomain}:{},...e.referenceLines!==void 0?{referenceLines:e.referenceLines}:{},...e.height!==void 0?{height:e.height}:{},children:({series:i,gapMs:s})=>ky(e.children,i,s)}),[e,n,t.nativeMs,t.costSeriesCount,t.refreshEnabled,t.refreshKey]);return jsx(Fragment,{children:r(a)})}function ky(e,t,r){return cn(e).map(o=>{if(!isValidElement(o))return o;let n=o.props;if(n.data)return o;let a=dM(t,n.seriesKey??Cy);return cloneElement(o,{data:a,maxGapMs:r,...n.labelFromData?{label:n.labelFromData(a,t)}:{}})})}var My=e=>e.type===Wn||e.type===Ta||e.type===mc,xM=e=>e.type===Sc||e.type===wc,Ey=280,yM=bisector(e=>e.xValue).left,vM=()=>jsx("div",{className:"flex h-full items-center justify-center",children:jsx("p",{className:"text-text-secondary",children:"No data available"})}),CM=()=>jsxs("div",{className:"flex h-full flex-col gap-4 p-4",children:[jsx(q,{className:"h-full w-full"}),jsxs("div",{className:"flex gap-4",children:[jsx(q,{className:"h-4 w-24"}),jsx(q,{className:"h-4 w-24"})]})]}),SM=({parentWidth:e,parentHeight:t,yFormatter:r={type:"number"},yDomain:o,referenceLines:n,isLoading:a=false,enableZoom:i=false,enableBrush:s=false,brushHeight:l=60,onZoomChange:d,zoomDomain:c,hiddenSeriesLabels:u,onHiddenSeriesChange:m,hideBottomBar:p=false,headerActions:g,headerControls:f,title:b,children:h})=>{let v=u!==void 0,x=c!==void 0,[C,S]=useState(null),[w,T]=useState(null),N=x?c:w,[k,R]=useState(()=>new Set),A=v?u:k,M=useRef(null),B=useId(),D=useRef(0),W=useRef(""),X=useRef(null),{colorMode:H}=hr(),I=useMemo(()=>tn(),[H]),F=useMemo(()=>$i(),[H]),{datasets:z,seriesMetadata:U,categoryInfo:K,categoryColors:O,categoryLabels:V,seriesTypes:L}=useMemo(()=>{let se=cn(h).filter(Ge=>isValidElement(Ge)&&My(Ge)),Pe=se.filter(Ge=>Ge.props.data).length,Re=[],He=[],ut=[],Nt=null,ze=null;se.forEach((Ge,Mt)=>{let Ie=Ge.props;if(!Ie.data)return;Re.push(Ie.data);let $o=("color"in Ie&&Ie.color?Ie.color:void 0)||(Pe===1?F:I[Mt%I.length]),en=Ge.type===Wn;He.push({label:"label"in Ie&&Ie.label||`Series ${Re.length}`,color:$o,...en&&"baseline"in Ie&&Ie.baseline!==void 0?{baseline:Ie.baseline,tooltipRange:"tooltipRange"in Ie&&Ie.tooltipRange||false}:{}});let ra=en?"area":Ge.type===Ta?"line":"bar";ut.push(ra),"categoryColors"in Ie&&Ie.categoryColors&&(Nt=Ie.categoryColors),"categoryLabels"in Ie&&Ie.categoryLabels&&(ze=Ie.categoryLabels);});let vt=null;if(Nt){let Ge=new Set;Re.forEach(Mt=>{Mt.forEach(Ie=>{Ie.category&&Ge.add(Ie.category);});}),vt=Array.from(Ge).map(Mt=>({label:ze?.[Mt]||Mt,color:Nt[Mt]||"#6b7280"}));}return {datasets:Re,seriesMetadata:He,categoryInfo:vt,categoryColors:Nt,categoryLabels:ze,seriesTypes:ut}},[h,F,I,H]),y=va(b),E=y.expandedSize?.width??e,P=y.expandedSize?.height??t,$=!p?y.action:null,oe=g||$?jsxs(Fragment,{children:[g,$]}):void 0,{headerRef:re,headerHeight:_}=ci(!!oe,!!f),he=p?0:60,me=s?l+8:0,ue=P-_-he-me,ie=Math.max(100,ue),fe=useCallback(J=>J?A.has(J):false,[A]),Te=useMemo(()=>U.map((J,se)=>fe(J.label)?null:se).filter(J=>J!==null),[U,fe]),Ye=useMemo(()=>Te.map(J=>z[J]).filter(J=>!!J),[z,Te]),yt=useMemo(()=>Te.map(J=>U[J]).filter(J=>!!J),[U,Te]),Qt=useMemo(()=>Te.map(J=>L[J]).filter(J=>!!J),[L,Te]),Ze=Qt.findIndex(J=>J==="bar"),fr=Ze!==-1,lr=useCallback((J,se)=>{let Pe=J.has(se);if(!Pe&&U.reduce((ut,Nt)=>J.has(Nt.label)||Nt.label===se?ut:ut+1,0)<1)return J;let Re=new Set(J);return Pe?Re.delete(se):Re.add(se),Re},[U]),Ce=useCallback(J=>{if(v){let se=u;if(!se.has(J)&&U.reduce((He,ut)=>se.has(ut.label)||ut.label===J?He:He+1,0)<1){S(null);return}m?.(Re=>lr(Re,J));}else R(se=>lr(se,J));S(null);},[v,u,m,U,lr]),Vt=useMemo(()=>U.map(J=>J.label).join(""),[U]),ee=useRef(Vt);useEffect(()=>{ee.current!==Vt&&(ee.current=Vt,v||R(J=>J.size===0?J:new Set));},[Vt,v]);let Be=useMemo(()=>Ye.flat(),[Ye]),Ve=useMemo(()=>{if(Be.length===0)return null;let J=[...Be].sort((se,Pe)=>se.xValue.getTime()-Pe.xValue.getTime());return [J[0].xValue,J[J.length-1].xValue]},[Be]),wt=N||Ve,Xt=useCallback(J=>{x?d?.(J):T(J);},[x,d]),Q=useMemo(()=>wt?z.map(se=>se.filter(Pe=>Pe.xValue>=wt[0]&&Pe.xValue<=wt[1])):z,[z,wt]),j=useMemo(()=>Te.map(J=>Q[J]??[]),[Te,Q]);useEffect(()=>{d&&d(N);},[N,d]);let pe=useMemo(()=>Te.flatMap(J=>Q[J]??[]),[Q,Te]),ae=useMemo(()=>ys(pe,ie,r,o),[pe,ie,r,o]),Ne=useRef(JSON.stringify(r)),Qe=useRef(null),Ue=useMemo(()=>{let[J,se]=ae.domain(),Pe=Math.max(Math.abs(J),Math.abs(se)),Re=JSON.stringify(r);if(Re!==Ne.current&&(Ne.current=Re,Qe.current=null),Qe.current!==null)return Qe.current;if(Pe===0)return Si(r,0);let He=Si(r,Pe);return Qe.current=He,He},[ae,r]),cr=useMemo(()=>{let J=ie-je.top-je.bottom;return ya(J)},[ie]),Z=useMemo(()=>{let J=zr(Ue),se=J.tickFormat||J.format,Re=ae.ticks(cr).map(Nt=>se(Nt)),He=sn(Re,12,"system-ui"),ut=Math.ceil(He)+12;return {...je,left:Math.max(ut,30),right:8}},[ae,Ue,cr]),le=useMemo(()=>wt?scaleTime({domain:wt,range:[Z.left,E-Z.right]}):nm(Be,E),[wt,Be,E,Z]),Ae=useCallback(J=>{if(!Ve)return;let{scaleX:se,translateX:Pe}=J,Re=E-Z.left-Z.right,[He,ut]=Ve,Nt=ut.getTime()-He.getTime();if(Nt<=0){Xt(null);return}let ze=-Pe,vt=ze+Re,Ge=Re*se/Nt,Mt=ze/Ge,Ie=vt/Ge,_o=new Date(He.getTime()+Mt),$o=new Date(He.getTime()+Ie),en=Math.abs(_o.getTime()-He.getTime()),ra=Math.abs($o.getTime()-ut.getTime()),vl=Nt*.02;en<vl&&ra<vl?Xt(null):Xt([_o,$o]);},[Ve,E,Z,Xt]),Oe=useCallback(J=>{let{left:se}=M.current?.getBoundingClientRect()||{left:0},Pe=J.clientX-se;if(J.timeStamp-(D.current||0)<16)return;D.current=J.timeStamp;let Re=le.invert(Pe),He=j.map((ze,vt)=>{if(!ze||ze.length===0)return null;let Ge=yM(ze,Re,1);if(Ge===0)return {point:ze[0],index:0,datasetIndex:vt};if(Ge>=ze.length)return {point:ze[ze.length-1],index:ze.length-1,datasetIndex:vt};let Mt=ze[Ge-1],Ie=ze[Ge];if(!Mt||!Ie)return null;let _o=Math.abs(Mt.xValue.getTime()-Re.getTime()),$o=Math.abs(Ie.xValue.getTime()-Re.getTime()),en=_o<$o;return {point:en?Mt:Ie,index:en?Ge-1:Ge,datasetIndex:vt}}).filter(ze=>ze!==null&&yt[ze.datasetIndex]!==void 0).map(({point:ze,index:vt,datasetIndex:Ge})=>({label:yt[Ge].label,value:ze.yValue,baselineValue:gc(yt[Ge],ze,vt),color:yt[Ge].color,point:ze,type:Qt[Ge]}));if(He.length===0){S(null);return}let ut=le(He[0].point.xValue),Nt=ut>(E-Z.right-Z.left)/2+Z.left;S({xValue:He[0].point.xValue,series:He.map(({label:ze,value:vt,baselineValue:Ge,color:Mt,point:Ie,type:_o})=>({label:ze,value:vt,...Ge!==void 0?{baselineValue:Ge}:{},chartY:Ie.chartYValue??vt,showMarker:Ie.showTooltipMarker??true,color:Mt,type:_o,category:Ie.category,categoryColor:Ie.category&&O?O[Ie.category]:void 0,...Ie.extraTooltipRows&&Ie.extraTooltipRows.length>0?{extraTooltipRows:Ie.extraTooltipRows}:{}})),x:ut,y:ae(He[0].point.chartYValue??He[0].value),position:Nt?"left":"right"});},[j,yt,Qt,le,ae,E,O,Z]),it=()=>{S(null);},Tt=useCallback(()=>{Xt(null),X.current&&X.current.reset();},[Xt]),Ot=useCallback(J=>{let se={scaleX:1,scaleY:1,translateX:0,translateY:0,skewX:0,skewY:0};if(!J||!Ve)return se;let[Pe,Re]=Ve,He=Re.getTime()-Pe.getTime();if(He<=0)return se;let[ut,Nt]=J,ze=Nt.getTime()-ut.getTime();if(ze<=0)return se;let vt=He/ze,Ge=E-Z.left-Z.right,Mt=ut.getTime()-Pe.getTime();return {scaleX:vt,scaleY:1,translateX:-(Mt/He)*Ge*vt,translateY:0,skewX:0,skewY:0}},[Ve,E,Z]),tt=useCallback(J=>{if(!(X.current&&Ve))return;let[se,Pe]=Ve,Re=Pe.getTime()-se.getTime();if(Re<=0){X.current.reset();return}if(!J){X.current.reset();return}let[He,ut]=J,Nt=ut.getTime()-He.getTime();if(Nt<=0){X.current.reset();return}let ze=Re/Nt,vt=E-Z.left-Z.right,Mt=-((He.getTime()-se.getTime())/Re)*vt*ze;X.current.setTransformMatrix({scaleX:ze,scaleY:1,translateX:Mt,translateY:0,skewX:0,skewY:0});},[Ve,E,Z]),xr=useCallback(J=>{Xt(J),tt(J);},[Xt,tt]);useEffect(()=>{x&&tt(c??null);},[x,c,tt]);let gr=dc(),xo={width:E,height:ie,xScale:le,yScale:ae,yFormatter:Ue,animationSettings:cc,entrance:gr,tooltip:{data:C,show:S,hide:()=>S(null)},datasets:j,seriesMetadata:yt,seriesTypes:Qt,categoryColors:O||void 0,categoryLabels:V||void 0},ne=cn(h),Se=0,ce=[],ct=[],yr=[];ne.forEach(J=>{if(!isValidElement(J)){yr.push(J);return}if(xM(J))ct.push(J);else if(My(J)){let se=Se;Se++;let Pe=J.props,Re=U[se]?.label;if(fe(Re))return;ce.push(ot__default.cloneElement(J,{...Pe,data:Q[se]||Pe.data,color:U[se]?.color}));}else yr.push(J);});let yo=Te.length,vo=(K||U).map(J=>{let se=!K&&fe(J.label);return {category:J.label,fill:J.color,isHidden:se,isDisabled:!K&&!se&&yo<=1}}),yl=typeof r=="object"&&r!==null&&typeof r.type=="string",Nu=vc({datasets:Ye,metadata:{xLabel:"Date",yLabel:"Value",seriesLabels:yt.map(J=>J.label),timestamp:true,...yl?{yFormat:r}:{}},svgRef:M}),Zi=jsx(di,{title:b,controls:f,actions:oe,containerRef:re});if(a)return y.present(jsxs("div",{className:"relative flex h-full flex-col",children:[Zi,jsx(CM,{})]}));if(z.length===0)return y.present(jsxs("div",{className:"relative flex h-full flex-col",children:[Zi,jsx(vM,{})]}));let Le=jsxs(Fragment,{children:[jsx("title",{children:b}),jsx("g",{children:ae.ticks(cr).map(J=>{let se=Math.abs(J)<Number.EPSILON;return jsx(Line,{from:{x:Z.left,y:ae(J)},to:{x:E-Z.right,y:ae(J)},stroke:se?"var(--color-border-default)":"var(--color-border-muted)",strokeWidth:se?1.5:1},`grid-line-${J}`)})}),jsx("defs",{children:jsx("clipPath",{id:B,children:jsx("rect",{x:le.range()[0],y:ae.range()[1],width:le.range()[1]-le.range()[0],height:ae.range()[0]-ae.range()[1]})})}),jsx("g",{clipPath:`url(#${B})`,children:ce}),yr,n&&n.length>0&&jsx("g",{children:n.map((J,se)=>{let Pe=ae(J.value),Re=J.color??"var(--color-error-base)";return jsxs("g",{children:[jsx(Line,{from:{x:Z.left,y:Pe},to:{x:E-Z.right,y:Pe},stroke:Re,strokeWidth:1.5,strokeDasharray:"6 4"}),J.label&&jsx("text",{x:E-Z.right-4,y:Pe-4,textAnchor:"end",fontSize:11,fill:Re,children:J.label})]},`ref-line-${se}`)})}),jsx(uo.Bottom,{top:ie-Z.bottom,scale:le,width:E-Z.left-Z.right}),jsx(uo.Left,{left:Z.left,scale:ae,yFormatter:Ue,height:ie-Z.top-Z.bottom}),C&&!C.isEvent&&jsxs(Fragment,{children:[fr?(()=>{let J=Ye[Ze]??[];if(J.length===0)return null;let se=[...J].sort((ra,vl)=>ra.xValue.getTime()-vl.xValue.getTime()),Pe=se.findIndex(ra=>ra.xValue.getTime()===C.xValue.getTime()),Re=se[Pe+1],He=se.length>1&&Re?Re.xValue.getTime()-C.xValue.getTime():15*6e4,ut=Math.abs(le(new Date(C.xValue.getTime()+He))-le(C.xValue)),ze=le(C.xValue)-ut/2,vt=ae.range(),[Ge,Mt]=le.range(),Ie=Math.min(Ge,Mt),_o=Math.max(Ge,Mt),$o=Math.max(ze,Ie),en=Math.max(0,Math.min(ze+ut,_o)-$o);return jsx("rect",{x:$o,y:vt[1],width:en,height:vt[0]-vt[1],className:"fill-background-muted",opacity:.5,pointerEvents:"none",style:{transition:"all 100ms ease-out"}})})():null,C.series.filter(J=>J.type!=="bar"&&J.showMarker!==false).map(J=>jsxs("g",{children:[jsx("circle",{cx:le(C.xValue),cy:ae(J.chartY??J.value),r:8,fill:"white",stroke:J.color,strokeWidth:2,style:{transition:"all 100ms ease-out"}}),jsx("circle",{cx:le(C.xValue),cy:ae(J.chartY??J.value),r:4,fill:J.color,style:{transition:"all 100ms ease-out"}})]},`highlight-${J.label}`))]}),jsx("rect",{x:Z.left,y:Z.top,width:E-Z.left-Z.right,height:ie-Z.top-Z.bottom,fill:"transparent",style:{cursor:i?"grab":"crosshair",touchAction:"none"},onMouseMove:Oe,onMouseLeave:it}),ct]});return y.present(jsx("div",{className:"relative flex h-full flex-col",children:jsxs(co.Provider,{value:xo,children:[Zi,i?jsx(Zoom,{initialTransformMatrix:Ot(N),width:E,height:ie,scaleXMin:1,scaleXMax:20,scaleYMin:1,scaleYMax:1,constrain:J=>{let{scaleX:se,translateX:Pe}=J,Re=Math.max(1,Math.min(20,se)),He=1,ut=E-Z.left-Z.right,Nt=0,ze=ut*(1-Re),vt=Math.max(ze,Math.min(Nt,Pe));return {...J,scaleX:Re,scaleY:He,translateX:vt,translateY:0}},children:J=>{if(X.current=J,J.transformMatrix){let{scaleX:se,translateX:Pe}=J.transformMatrix,Re=`${se.toFixed(4)}-${Pe.toFixed(2)}`;Re!==W.current&&(W.current=Re,setTimeout(()=>{Ae(J.transformMatrix);},0));}return jsx("svg",{width:E,height:ie,className:"overflow-visible",ref:se=>{M.current=se,J.containerRef.current!==se&&(J.containerRef.current=se);},role:"img","aria-label":b,style:{cursor:J.isDragging?"grabbing":"grab",touchAction:"none"},onMouseDown:J.dragStart,onMouseMove:J.dragMove,onMouseUp:J.dragEnd,onMouseLeave:()=>{J.isDragging&&J.dragEnd();},onTouchStart:J.dragStart,onTouchMove:J.dragMove,onTouchEnd:J.dragEnd,children:Le})}},`zoom-${Math.round(E)}x${Math.round(ie)}`):jsx("svg",{width:E,height:ie,className:"overflow-visible",ref:M,role:"img","aria-label":b,children:Le}),jsx(Ho,{data:C,formatter:Ue}),s&&Ve&&jsx(pm,{data:Ye,seriesMetadata:yt,width:E,height:l,onBrushChange:xr,brushRegion:N,margin:Z,...o?{yDomain:o}:{}}),!p&&jsx(Ti,{onExport:Nu,items:vo,isZoomed:N!==null,onResetZoom:Tt,onLegendItemToggle:K?void 0:Ce,marginLeft:Z.left,marginRight:Z.right})]})}))},wM=withParentSize(SM),Gm=({source:e,streaming:t,...r})=>{if(Nc(e))return jsx(Wc,{source:e,title:r.title??"Chart",...r.yFormatter!==void 0?{yFormatter:r.yFormatter}:{},...r.yDomain!==void 0?{yDomain:r.yDomain}:{},...r.referenceLines!==void 0?{referenceLines:r.referenceLines}:{},...r.headerActions!==void 0?{headerActions:r.headerActions}:{},...t?.tierToWindow!==void 0?{tierToWindow:t.tierToWindow}:{},...t?.windowSizeOptions!==void 0?{windowSizeOptions:t.windowSizeOptions}:{},...t?.presetRanges!==void 0?{presetRanges:t.presetRanges}:{},...t?.hint!==void 0?{hint:t.hint}:{},...t?.emptyState!==void 0?{emptyState:t.emptyState}:{},...t?.height!==void 0?{height:t.height}:{},...t?.latestDataReadout!==void 0?{latestDataReadout:t.latestDataReadout}:{},...t?.latestDataSeriesKeys!==void 0?{latestDataSeriesKeys:t.latestDataSeriesKeys}:{},...t?.panels!==void 0?{panels:t.panels}:{},children:r.children});let{yDomain:o,...n}=r;return jsx(wM,{...n,...typeof o=="function"?{}:{yDomain:o}})};Gm.displayName="ChartContainer";var MM=e=>e.toLocaleString(),EM=e=>`${Math.round(e*100)}%`,Iy=({data:e,width:t=800,height:r=400,padding:o=0,barGap:n=30,formatValue:a=MM,formatPercentage:i=EM,color:s,showScale:l=true,showOverallConversion:d=true,overallConversionLabel:c="Overall Conversion:",activeStageId:u,onStageClick:m,onStageHover:p,className:g,style:f,"aria-label":b="Funnel chart"})=>{let[h,v]=useState(null),[x,C]=useState(t),S=useRef(null),w=u??h,T=useId(),N=s||"var(--color-viz-default)";useEffect(()=>{if(!S.current)return;let D=new ResizeObserver(W=>{for(let X of W)C(X.contentRect.width);});return D.observe(S.current),()=>{D.disconnect();}},[]);let{layout:k,overallConversion:R}=useMemo(()=>{if(e.length===0)return {layout:[],overallConversion:0};let D=e[0].value,W=d?60:0,X=r-o*2-W,H=(e.length-1)*n,I=(X-H)/e.length,F=e.map((U,K)=>{let O=o+W+K*(I+n),V=D===0?0:U.value/D,L=V,y=K===0?null:e[K-1].value,E=y==null||y===0?0:1-U.value/y;return {stage:U,index:K,y:O,barHeight:I,widthPercent:V,conversionRate:L,dropOff:E}}),z=D===0?0:e[e.length-1].value/D;return {layout:F,overallConversion:z,maxValue:D}},[e,x,r,o,n,l,d]);if(e.length===0)return jsx("div",{className:twMerge("flex h-full min-h-[280px] w-full items-center justify-center rounded-lg border border-dashed border-border-default bg-background-surface text-sm font-medium text-text-secondary",g),style:{width:t,height:r,...f},children:"No funnel data available"});let A=l?60:0,M=o+A,B=x-o*2-A;return jsx("div",{ref:S,className:twMerge("relative w-full overflow-hidden rounded-lg bg-background-surface",g),style:{height:r,...f},"aria-label":b,role:"img",children:jsxs("svg",{width:"100%",height:r,className:"relative",children:[jsxs("defs",{children:[jsx(LinearGradient,{id:`${T}-bar`,from:N,to:N,toOpacity:.85}),jsx(LinearGradient,{id:`${T}-bg`,from:N,to:N,fromOpacity:.01,toOpacity:.15,x1:"0",y1:"0",x2:"1",y2:"0"})]}),d&&jsxs("text",{x:M,y:o+20,className:"fill-text-primary text-sm font-medium",children:[jsx("tspan",{className:"fill-text-secondary",children:c})," ",i(R)]}),l&&jsx("g",{children:k.map(D=>{let W=D.y+D.barHeight/2;return jsx("text",{x:o+A-12,y:W,textAnchor:"end",dominantBaseline:"middle",className:"fill-text-secondary text-xs",children:i(D.conversionRate)},D.stage.id)})}),k.map(D=>{let W=w===D.stage.id,X=B*D.widthPercent;return jsxs("g",{children:[jsx("rect",{x:M,y:D.y,width:B,height:D.barHeight,fill:`url(#${T}-bg)`,rx:4}),jsx(motion.rect,{x:M,y:D.y,width:X,height:D.barHeight,fill:`url(#${T}-bar)`,rx:4,initial:{width:0},animate:{width:X},transition:{duration:.6,delay:D.index*.1,ease:"easeOut"},opacity:W||w==null?1:.5,style:{cursor:m||p?"pointer":"default",transition:"opacity 150ms ease"},onMouseEnter:()=>{v(D.stage.id),p?.(D.stage);},onMouseLeave:()=>{v(null),p?.(null);},onClick:()=>m?.(D.stage)}),jsx("rect",{x:M+10,y:D.y+D.barHeight/2-10,width:70,height:20,className:"fill-background-surface stroke-border-default",strokeWidth:1,rx:4,style:{pointerEvents:"none"}}),jsx("text",{x:M+16,y:D.y+D.barHeight/2+4,className:"fill-text-primary text-xs font-semibold",style:{pointerEvents:"none"},children:a(D.stage.value)}),jsxs("text",{x:M,y:D.y-8,className:"fill-text-secondary text-xs",style:{pointerEvents:"none"},children:[jsx("tspan",{children:D.index+1})," ",D.stage.label]}),D.stage.secondaryValue&&jsx("text",{x:M+16,y:D.y-24,className:"fill-text-secondary text-xs",style:{pointerEvents:"none"},children:D.stage.secondaryValue}),D.index>0&&D.dropOff>0&&jsxs("text",{x:M+B,y:D.y-8,textAnchor:"end",className:"fill-text-secondary text-xs",children:[i(D.dropOff)," drop"]}),D.stage.annotation&&jsxs("g",{children:[jsx("rect",{x:M+X+8,y:D.y+8,width:60,height:24,rx:3,className:"fill-background-muted"}),jsx("text",{x:M+X+16,y:D.y+20,className:"fill-text-secondary text-xs font-medium",children:D.stage.annotation})]})]},D.stage.id)})]})})};var FM=.005,Vy=320;function Uc(e){return e>0?e:0}function BM(e,t,r){let o=t===0?0:Uc(e.value)/t*100;return `${e.label}: ${r(e.value)}, ${o.toFixed(1)}%`}var Oy=({data:e,width:t,height:r,innerRadiusRatio:o=0,yFormatter:n={type:"number"},showLegend:a=true,showTooltip:i=true,onSliceClick:s,onSliceHover:l,className:d,style:c,"aria-label":u})=>{let[m,p]=useState(null),[g,f]=useState(null),[b,h]=useState(null),[v,x]=useState(t??600),[C,S]=useState(r??300),w=useRef(null);useEffect(()=>{if(t!==void 0&&r!==void 0){x(t),S(r);return}if(!w.current)return;let H=new ResizeObserver(I=>{for(let F of I)t===void 0&&x(F.contentRect.width),r===void 0&&S(F.contentRect.height);});return H.observe(w.current),t===void 0&&x(w.current.offsetWidth),r===void 0&&S(w.current.offsetHeight||300),()=>{H.disconnect();}},[t,r]);let T=useMemo(()=>e.reduce((H,I)=>H+Uc(I.value),0),[e]),N=useMemo(()=>{let H=es(e.map(I=>I.label));return e.map(I=>({...I,color:I.color||H[I.label]||"var(--color-viz-default)"}))},[e]),k=zr(n),R=s!==void 0,A=a&&v>=Vy,M=A?Math.max(v*.45,Vy*.45):v,D=Math.max(0,Math.min(M,C)-8)/2,W=D*Math.min(Math.max(o,0),.95);if(e.length===0||T===0)return jsx("div",{ref:w,className:twMerge("flex h-full min-h-[200px] w-full items-center justify-center rounded-lg border border-dashed border-border-default bg-background-surface text-sm font-medium text-text-secondary",d),style:r!==void 0?{height:r,...c}:c,children:"No data available"});let X=(H,I,F)=>{if(p(H),l?.(I,H),H!==null&&I&&F){let z=M/2+F[0],U=C/2+F[1];h(I.label),f({xValue:new Date,series:[{label:"Value",value:I.value,color:I.color||"var(--color-viz-default)"}],x:z,y:U,position:z>v/2?"left":"right"});}else f(null),h(null);};return jsxs("div",{ref:w,className:twMerge("relative flex h-full w-full items-center gap-4 rounded-lg bg-background-surface",d),style:r!==void 0?{height:r,...c}:c,children:[jsx("svg",{width:M,height:C,className:"flex-shrink-0",role:R?"group":"img","aria-label":u,children:jsx(Group,{top:C/2,left:M/2,children:jsx(Pie,{data:N,pieValue:H=>Uc(H.value),pieSort:null,pieSortValues:null,outerRadius:D,innerRadius:W,padAngle:FM,children:H=>H.arcs.map((I,F)=>{let z=m===F||m===null,U=H.path.centroid(I);return jsx("path",{d:H.path(I)??void 0,fill:I.data.color,opacity:z?1:.5,style:{cursor:s||l?"pointer":"default",transition:"opacity 150ms ease-out"},onMouseEnter:()=>X(F,I.data,U),onMouseLeave:()=>X(null,null),onClick:()=>s?.(I.data,F),...R?{role:"button",tabIndex:0,"aria-label":BM(I.data,T,k.format),onFocus:()=>X(F,I.data,U),onBlur:()=>X(null,null),onKeyDown:K=>{K.key!=="Enter"&&K.key!==" "||(K.preventDefault(),s?.(I.data,F));}}:{}},I.data.label)})})})}),A?jsx("ul",{className:"flex min-w-0 flex-col gap-1 overflow-y-auto py-2 text-xs",children:N.map((H,I)=>jsxs("li",{className:"flex items-center gap-2",style:{opacity:m===I||m===null?1:.5},onMouseEnter:()=>X(I,H),onMouseLeave:()=>X(null,null),children:[jsx("span",{className:"h-3 w-3 flex-shrink-0 rounded-sm",style:{backgroundColor:H.color}}),jsx("span",{className:"truncate text-text-primary",title:H.label,children:H.label}),jsxs("span",{className:"ml-auto flex-shrink-0 tabular-nums text-text-secondary",children:[k.format(H.value)," (",(Uc(H.value)/T*100).toFixed(1),"%)"]})]},H.label))}):null,i&&jsx(Ho,{data:g,formatter:n,label:b??void 0})]})};function Is({count:e,label:t="results",suffix:r,unknownLabel:o="\u2014",isLoading:n=false,className:a="",testId:i}){if(n)return jsx("div",{className:`flex items-center ${a}`,children:jsx(q,{width:80,height:16})});if(e===null)return jsx("div",{"data-testid":i,className:`text-sm text-text-secondary whitespace-nowrap ${a}`,children:o});let s=t.endsWith("s")?t.slice(0,-1):t,l=e===1&&!r?s:t,d=`${e.toLocaleString()}${r??""}${l?` ${l}`:""}`;return jsx("div",{"data-testid":i,className:`text-sm text-text-secondary whitespace-nowrap ${a}`,children:d})}var HM=e=>{let t=rr({isInvalid:e.isInvalid,isDisabled:e.isDisabled,isFocused:e.isFocused,transparent:e.transparent,size:e.size}),r=[e.showSearchIcon?"":"pl-3",e.isClearable&&e.hasValue||e.isPassword?"pr-8":"pr-3"].join(" ");return twMerge(t,r,e.className)};function fo({label:e,description:t,errorMessage:r,size:o="md",tooltip:n,isRequired:a,transparent:i,showSearchIcon:s,isClearable:l,onClear:d,type:c,validationResult:u,reserveErrorSpace:m=true,isLoading:p=false,descriptionPlacement:g="below",...f}){let[b,h]=ot__default.useState(false),{isFocused:v,handleFocus:x,handleBlur:C}=Ar(),S=c==="password",w=jl(p,300);return jsx(TextField,{...f,isRequired:a,className:Fe(f.className,"group flex flex-col"),children:({isDisabled:T,isInvalid:N})=>jsxs("div",{className:"flex flex-col",children:[e&&jsx(et,{size:o,tooltip:n,description:g==="tooltip"||g==="inline"?t:void 0,descriptionPlacement:g,isRequired:a,children:e}),jsxs(Dt,{children:[s&&jsx("div",{className:"pointer-events-none absolute top-1/2 -translate-y-1/2 transform flex items-center z-10",style:{left:9},children:(()=>{let k={sm:14,md:16,lg:18,xl:20}[o];return w?jsx(ao,{size:k,color:"text-text-secondary"}):jsx(G,{name:"MagnifyingGlass",size:k,className:`transition-colors ${v?"text-action-brand":"text-text-secondary"}`})})()}),jsx(Zl,{size:o,disabled:T,type:S?b?"text":"password":c,name:f.name,autoComplete:f.autoComplete,value:f.value,defaultValue:f.defaultValue,placeholder:f.placeholder,onFocus:k=>x(k,f.onFocus),onBlur:k=>C(k,f.onBlur),onChange:k=>f.onChange?.(k.target.value),style:s?{paddingLeft:{sm:28,md:32,lg:36,xl:37}[o]}:void 0,className:HM({isInvalid:N,isDisabled:T,isFocused:v,size:o,transparent:i,showSearchIcon:s,isClearable:l,hasValue:!!f.value,isPassword:S,className:typeof f.className=="string"?f.className:void 0})}),l&&f.value&&!T&&jsx(ms,{onClick:()=>{d?d():f.onChange&&f.onChange("");},size:o}),S&&!T&&jsx("button",{type:"button",onClick:()=>h(!b),className:"absolute right-3 top-1/2 -translate-y-1/2 transform text-text-secondary hover:text-text-primary","aria-label":b?"Hide password":"Show password",onMouseDown:k=>{k.preventDefault(),k.stopPropagation();},children:jsx(G,{name:b?"EyeSlash":"Eye",size:o==="sm"?16:20,className:"text-text-primary"})})]}),m?jsx("div",{className:"mt-1 min-h-[20px]",children:typeof r=="string"?jsx(ye,{size:o,children:r}):typeof r=="function"&&u?jsx(ye,{size:o,children:r(u)}):t&&g==="below"?jsx(Ee,{size:o,children:t}):null}):jsx(Fragment,{children:typeof r=="string"?jsx(ye,{size:o,className:"mt-1",children:r}):typeof r=="function"&&u?jsx(ye,{size:o,className:"mt-1",children:r(u)}):t&&g==="below"?jsx(Ee,{size:o,className:"mt-1",children:t}):null})]})})}function Ma({value:e,onChange:t,onClear:r,placeholder:o="Search...",size:n="sm",className:a="",isLoading:i=false}){return jsx("div",{className:`flex-1 min-w-0 sm:max-w-sm ${a}`,children:jsx(fo,{value:e,onChange:t,placeholder:o,showSearchIcon:true,isClearable:!!e&&!!r,onClear:r,size:n,"aria-label":o,reserveErrorSpace:false,isLoading:i})})}function Fs({value:e,options:t,onChange:r,direction:o,onDirectionChange:n,showLabel:a=true,size:i="sm",className:s="",compact:l=false}){let[d,c]=useState(false),u=o!==void 0&&n!==void 0,m=t.find(p=>p.value===e);return l?jsxs("div",{className:`flex items-center gap-2 ${s}`,children:[jsx(te,{variant:"secondary",size:i,icon:"ArrowsDownUp","aria-label":`Sort by: ${m?.label||"Select"}`,onPress:()=>c(true)}),jsx(Lt,{isOpen:d,onClose:()=>c(false),title:"Sort by",contentPadding:false,children:jsx(ListBox,{items:t.map(p=>({id:p.value,label:p.label,value:p.value})),className:"w-full bg-background-surface p-0 outline-0 [&_[role=option]]:border-b [&_[role=option]]:border-border-default [&_[role=option]:last-child]:border-0 [&_[role=option]]:!px-6 [&_[role=option]]:!py-4 [&_[role=option]]:rounded-none",selectionMode:"single",selectedKeys:e?[e]:[],onSelectionChange:p=>{let g=Array.from(p)[0];g!=null&&(r(g),c(false));},children:p=>jsx(Ir,{id:p.id,textValue:p.label,children:jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap min-w-0 flex-1",children:p.label})},p.id)})})]}):jsxs("div",{className:`flex items-center gap-2 ${s}`,children:[a&&jsx("span",{className:"text-sm text-text-secondary whitespace-nowrap",children:"Sort by:"}),jsx(on,{selectedKey:e,onSelectionChange:p=>r(p),size:i,className:"min-w-32",items:t.map(p=>({id:p.value,label:p.label,value:p.value})),renderItem:p=>p.label,"aria-label":"Sort by",reserveErrorSpace:false}),u&&jsx(te,{variant:"ghost",size:i,onClick:()=>n(o==="asc"?"desc":"asc"),"aria-label":`Sort ${o==="asc"?"descending":"ascending"}`,className:"p-1.5",children:o==="asc"?jsx(ArrowUp,{className:"w-4 h-4"}):jsx(ArrowDown,{className:"w-4 h-4"})})]})}function Wy({search:e,searchMobileMode:t="expanded",filters:r=[],onRemoveFilter:o,onClearAllFilters:n,onManageFilters:a,exportControl:i,maxVisibleFilterChips:s=3,sort:l,resultsCount:d,leftControls:c,onManageColumns:u,columnPicker:m,customControls:p,actions:g,interactionMode:f="auto",sticky:b,stickyTop:h="0",zIndex:v=10,className:x="",style:C}){let S=r.length>0;if(!(e||S||a||l||d||c||u||m||p||g||i))return null;let T=b?"sticky bg-background-surface":"",N=b?{top:h,zIndex:v}:{};return jsxs("div",{className:`@container flex flex-col gap-3 bg-background-surface py-3 border-b border-border-default ${T} ${x}`,style:{...C,...N},children:[jsxs("div",{className:"hidden @[640px]:flex @[640px]:items-center @[640px]:justify-between @[640px]:gap-4",children:[jsxs("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:[c,c&&d&&jsx("div",{className:"h-4 w-px bg-border-default"}),d&&jsx(Is,{count:d.count,label:d.label,suffix:d.suffix,unknownLabel:d.unknownLabel,isLoading:d.isLoading,testId:d.testId}),d&&l&&jsx("div",{className:"h-4 w-px bg-border-default"}),l&&jsx(Fs,{value:l.value,options:l.options,onChange:l.onChange,showLabel:l.showLabel,direction:l.direction,onDirectionChange:l.onDirectionChange}),u?jsx(te,{variant:"secondary",size:"sm",icon:"Columns",onClick:u,children:"Columns"}):m,S&&o&&jsxs(Fragment,{children:[r.slice(0,s).map(k=>jsxs(lo,{variant:"primary",size:"sm",onRemove:()=>o(k.id),isRemovable:true,children:[k.label,": ",k.value]},k.id)),r.length>s&&a&&jsxs(te,{variant:"ghost",size:"sm",onClick:a,className:"text-text-secondary hover:text-text-primary whitespace-nowrap",children:["+",r.length-s," more"]}),n&&jsx(te,{variant:"ghost",size:"sm",onClick:n,className:"text-text-secondary hover:text-text-primary whitespace-nowrap",children:"Clear all"})]})]}),jsx("div",{className:"flex items-center gap-3 flex-shrink-0",children:p||jsxs(Fragment,{children:[g&&g.items.length>0&&jsx(Fragment,{children:g.items.map(k=>jsx(te,{variant:k.variant||"secondary",size:"sm",icon:k.icon,onPress:k.onClick,isDisabled:k.disabled,children:k.label},k.id))}),e&&jsx("div",{className:"w-64",children:jsx(Ma,{value:e.value,onChange:e.onChange,onClear:e.onClear,placeholder:e.placeholder,isLoading:e.isLoading})}),a&&jsx(te,{variant:"secondary",size:"sm",icon:"Sliders",badgeNumber:r.length>0?r.length:void 0,onClick:a,children:"Filters"}),i&&jsx(te,{variant:"secondary",size:"sm",icon:i.icon??"Upload",onClick:i.onClick,isDisabled:i.isDisabled,isLoading:i.isLoading,children:i.label})]})})]}),jsxs("div",{className:"@[640px]:hidden",children:[jsx("div",{className:"flex flex-col gap-3 mb-3",children:jsx("div",{className:"flex items-center gap-3",children:p?jsx("div",{className:"flex-1",children:p}):jsxs(Fragment,{children:[g&&g.items.length>0&&jsx(pi,{items:g.items.map(k=>({id:k.id,name:k.label,iconName:k.icon,variant:k.variant==="destructive"?"destructive":"primary",disabled:k.disabled,onAction:k.onClick})),align:"left",size:"sm",children:jsx(te,{variant:"secondary",size:"sm",icon:"DotsThreeVertical","aria-label":g.menuLabel||"Actions"})}),e&&jsx("div",{className:"flex-1",children:jsx(Ma,{value:e.value,onChange:e.onChange,onClear:e.onClear,placeholder:e.placeholder,isLoading:e.isLoading})}),a&&jsx(te,{variant:"secondary",size:"sm",icon:"Sliders",badgeNumber:r.length>0?r.length:void 0,onClick:a,"aria-label":`Filters${r.length>0?` (${r.length} active)`:""}`}),i&&jsx(te,{variant:"secondary",size:"sm",icon:i.icon??"Upload",onClick:i.onClick,isDisabled:i.isDisabled,isLoading:i.isLoading,children:i.label})]})})}),jsxs("div",{className:"flex items-center justify-between gap-3",children:[jsxs("div",{className:"flex items-center gap-3",children:[c,d&&jsx(Is,{count:d.count,label:d.label,suffix:d.suffix,unknownLabel:d.unknownLabel,isLoading:d.isLoading})]}),jsx("div",{className:"flex items-center gap-2",children:l&&jsx(Fs,{value:l.value,options:l.options,onChange:l.onChange,showLabel:false,direction:l.direction,onDirectionChange:l.onDirectionChange,compact:f!=="desktop"})})]})]})]})}function Uy({filters:e,onRemove:t,onClearAll:r,onManageFilters:o,maxVisibleChips:n=3,mode:a="chips",showManageButton:i=true,size:s="sm",className:l=""}){let d=e.length>0,c=e.slice(0,n),u=Math.max(0,e.length-n),m=u>0,p=a==="button"&&!!o,g=a==="chips"&&i&&!!o;if(!d&&!p&&!g)return null;let f=p&&jsxs(te,{variant:"secondary",size:s,onClick:o,className:"whitespace-nowrap",children:[e.length," ",e.length===1?"filter":"filters"]}),b=jsxs(Fragment,{children:[g&&jsx(te,{variant:"secondary",size:s,icon:"Sliders",onClick:o,className:"whitespace-nowrap",children:"Filters"}),d&&c.map(v=>jsxs(lo,{variant:"secondary",size:s,onRemove:()=>t(v.id),isRemovable:true,children:[v.label,": ",v.value]},v.id)),d&&m&&o&&jsxs(te,{variant:"ghost",size:s,onClick:o,className:"text-text-secondary hover:text-text-primary whitespace-nowrap",children:["+",u," more"]}),d&&r&&jsx(te,{variant:"ghost",size:s,onClick:r,className:"text-text-secondary hover:text-text-primary whitespace-nowrap",children:"Clear all"})]}),h=a==="button"?f:b;return jsx("div",{className:`flex flex-wrap items-center gap-2 ${l}`,children:h})}var Ky=["isEmpty","isNotEmpty"];function Yy(e){return Ky.includes(e)}var Xy={isEmpty:"is empty",isNotEmpty:"is not empty"};function JM(e,t,r){return {field:e,operator:t,value:r}}function jM(e,t="AND"){return {logic:t,conditions:e}}function Bs(){return {logic:"AND",conditions:[]}}function Jc(e){return !e||e.conditions.length===0?true:e.conditions.every(t=>"conditions"in t?Jc(t):false)}function qM(e,t){if(!e)return [];let r=new Map(t?.map(i=>[i.field,i])),o=new Map;function n(i){if("conditions"in i)i.conditions.forEach(s=>n(s));else {let s=o.get(i.field)||[];s.push(i),o.set(i.field,s);}}e.conditions.forEach(i=>n(i));let a=[];for(let[i,s]of o.entries()){let l=r.get(i),d=l?.label||i,c=[],u=[],m=[];for(let p of s)p.operator==="in"&&Array.isArray(p.value)?c.push(...p.value):p.operator==="eq"?p.value!==void 0&&typeof p.value!="boolean"&&!Array.isArray(p.value)?c.push(p.value):m.push(p):["gte","gt","lte","lt"].includes(p.operator)&&p.value!==void 0?u.push({operator:p.operator,value:typeof p.value=="boolean"||Array.isArray(p.value)?String(p.value):p.value}):m.push(p);if(c.length>0){let g=Array.from(new Set(c)).map(f=>l?.values?.find(h=>String(h.value)===String(f))?.label??f);a.push({id:`${i}-in`,label:d,value:g.join(", ")});}if(u.length>0){let p=u.find(f=>f.operator==="gte"||f.operator==="gt"),g=u.find(f=>f.operator==="lte"||f.operator==="lt");if(p&&g){let f=p.operator==="gte"?"\u2265":">",b=g.operator==="lte"?"\u2264":"<";a.push({id:`${i}-range`,label:d,value:`${f} ${p.value} and ${b} ${g.value}`});}else for(let f of u){let b;f.operator==="gte"?b="\u2265":f.operator==="gt"?b=">":f.operator==="lte"?b="\u2264":b="<",a.push({id:`${i}-${f.operator}`,label:d,value:`${b} ${f.value}`});}}for(let p of m){let g;p.operator==="neq"?g=`\u2260 ${p.value}`:p.operator==="contains"?g=`contains "${p.value}"`:p.operator==="startsWith"?g=`starts with "${p.value}"`:p.operator==="endsWith"?g=`ends with "${p.value}"`:Yy(p.operator)?g=Xy[p.operator]:g=String(p.value),a.push({id:`${i}-${p.operator}`,label:d,value:g});}}return a}function Xn(e,t){let r=e||Bs();return {...r,conditions:[...r.conditions,t]}}function Ea(e,t){if(!e)return Bs();let r=e.conditions.filter(o=>"conditions"in o?Ea(o,t).conditions.length>0:o.field!==t);return {...e,conditions:r}}function La(e){if(!e)return [];let t=new Set;function r(o){"conditions"in o?o.conditions.forEach(r):t.add(o.field);}return e.conditions.forEach(r),Array.from(t)}function jy({label:e,description:t,errorMessage:r,size:o="md",tooltip:n,isRequired:a,isDisabled:i,isInvalid:s,showCalendar:l=true,reserveErrorSpace:d=true,validationResult:c,className:u,...m}){let[p,g]=useState(false),f=b=>{m.onChange&&b&&m.onChange(b),g(false);};return jsxs(DateField,{...m,isDisabled:i,isRequired:a,isInvalid:s,className:Fe(u,"flex flex-col gap-1"),children:[e&&jsx(et,{size:o,tooltip:n,isRequired:a,children:e}),jsx(Dt,{children:jsxs("div",{className:"relative w-full",children:[jsx(Vs,{size:o,isDisabled:i,isInvalid:s,hasCalendar:l}),l&&!i&&jsxs(DialogTrigger,{isOpen:p,onOpenChange:g,children:[jsx(te,{variant:"unstyled",className:"absolute right-2 top-1/2 -translate-y-1/2 flex h-8 w-8 items-center justify-center rounded hover:bg-background-hover text-text-secondary hover:text-text-primary transition-colors","aria-label":"Open calendar",children:jsx(G,{name:"Calendar",size:18})}),jsx(Popover,{className:"bg-background-surface rounded-lg border border-border-default shadow-xl",children:jsx(Dialog,{className:"p-4 outline-none",children:jsx(xi,{value:m.value,onChange:f,minValue:m.minValue,maxValue:m.maxValue,isDisabled:i,isReadOnly:m.isReadOnly,isDateUnavailable:m.isDateUnavailable})})})]})]})}),d?jsx("div",{className:"mt-1 min-h-[20px]",children:typeof r=="string"?jsx(ye,{size:o,children:r}):typeof r=="function"&&c?jsx(ye,{size:o,children:r(c)}):t?jsx(Ee,{size:o,children:t}):null}):jsx(Fragment,{children:typeof r=="string"?jsx(ye,{size:o,className:"mt-1",children:r}):typeof r=="function"&&c?jsx(ye,{size:o,className:"mt-1",children:r(c)}):t?jsx(Ee,{size:o,className:"mt-1",children:t}):null})]})}function oE({isPlaceholder:e,isDisabled:t,size:r="md"}){return twMerge("inline-block box-content px-0.5 rounded outline-none tabular-nums text-center transition-colors",{sm:"text-base md:text-xs",md:"text-base md:text-sm",lg:"text-base",xl:"text-lg"}[r],e?"text-text-disabled italic":"text-text-primary",t?"text-text-disabled cursor-not-allowed":"cursor-text",!t&&"hover:bg-background-hover","data-[focused]:bg-background-selected data-[focused]:text-text-primary")}function Vs({size:e="md",isDisabled:t,isInvalid:r,hasCalendar:o,className:n,...a}){return jsx(DateInput,{className:twMerge(An({isInvalid:r,isDisabled:t}),"px-3 py-2 flex items-center gap-0.5 w-full",o&&"pr-10",n),...a,children:i=>jsx(DateSegment,{segment:i,className:oE({isPlaceholder:i.isPlaceholder,isDisabled:!i.isEditable||t,size:e})})})}function jc({label:e,description:t,errorMessage:r,...o}){return jsxs(DateRangePicker,{...o,className:Fe(o.className,"group flex flex-col gap-1"),children:[e&&jsx(et,{children:e}),jsxs(_h,{className:"w-auto min-w-[208px]",children:[jsx(Vs,{slot:"start",className:"px-2 py-1.5 text-sm"}),jsx("span",{"aria-hidden":"true",className:"text-text-primary group-disabled:text-text-disabled forced-colors:text-[ButtonText] group-disabled:forced-colors:text-[GrayText]",children:"\u2013"}),jsx(Vs,{slot:"end",className:"flex-1 px-2 py-1.5 text-sm"}),jsx(te,{variant:"icon",className:"mr-1 w-6 rounded outline-offset-0",children:jsx(CalendarIcon,{"aria-hidden":true,className:"h-4 w-4"})})]}),t&&jsx(Ee,{children:t}),typeof r=="string"?jsx(ye,{children:r}):null,jsx(Et,{children:jsx(Ri,{})})]})}var pE=e=>{let t=rr({isInvalid:e.isInvalid,isDisabled:e.isDisabled,isFocused:e.isFocused,transparent:e.transparent,size:e.size});return twMerge(t,"pr-9","[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none",e.className)};function Os({label:e,description:t,errorMessage:r,size:o="md",tooltip:n,isRequired:a,transparent:i,validationResult:s,reserveErrorSpace:l=true,descriptionPlacement:d="below",...c}){let u=useId(),{isFocused:m,handleFocus:p,handleBlur:g}=Ar();return jsx(NumberField,{...c,id:u,isRequired:a,className:Fe(c.className,"group flex flex-col gap-1"),step:c.step??1,onChange:f=>{typeof f=="number"&&(c.maxValue!=null&&f>c.maxValue?c.onChange?.(c.maxValue):c.minValue!=null&&f<c.minValue?c.onChange?.(c.minValue):c.onChange?.(f));},isInvalid:!!r||typeof c.value=="number"&&(c.maxValue!=null&&c.value>c.maxValue||c.minValue!=null&&c.value<c.minValue),children:({isDisabled:f,isInvalid:b})=>jsxs("div",{className:"flex flex-col gap-1",children:[e&&jsx(et,{size:o,tooltip:n,description:d==="tooltip"||d==="inline"?t:void 0,descriptionPlacement:d,isRequired:a,htmlFor:u,children:e}),jsx("div",{className:"relative",children:jsxs(Group$1,{className:"relative",children:[jsx(Input,{onFocus:v=>p(v,c.onFocus),onBlur:v=>g(v,c.onBlur),className:pE({isInvalid:b||!!r,isDisabled:f,isFocused:m,transparent:i,size:o,className:typeof c.className=="string"?c.className:void 0})}),jsxs("div",{className:"absolute inset-y-[2px] right-[2px] flex flex-col divide-y divide-border-default border-l border-border-default overflow-hidden rounded-r-[calc(var(--control-border-radius)-2px)]",children:[jsx(Button,{slot:"increment",isDisabled:f,className:"flex h-1/2 w-7 items-center justify-center bg-background-input hover:bg-background-input-hover active:bg-background-input-active disabled:cursor-not-allowed disabled:opacity-50",children:jsx(G,{name:"CaretUp",size:14})}),jsx(Button,{slot:"decrement",isDisabled:f,className:"flex h-1/2 w-7 items-center justify-center bg-background-input hover:bg-background-input-hover active:bg-background-input-active disabled:cursor-not-allowed disabled:opacity-50",children:jsx(G,{name:"CaretDown",size:14})})]})]})}),l?jsx("div",{className:"mt-1 min-h-[20px]",children:r?jsx(ye,{size:o,children:typeof r=="function"?r(s):r}):t&&d==="below"?jsx(Ee,{size:o,children:t}):null}):jsx(Fragment,{children:r?jsx(ye,{size:o,className:"mt-1",children:typeof r=="function"?r(s):r}):t&&d==="below"?jsx(Ee,{size:o,className:"mt-1",children:t}):null})]})})}var Jm={sm:{track:"h-4 w-7",handle:"h-3.5 w-3.5",text:"text-xs"},md:{track:"h-5 w-9",handle:"h-4 w-4",text:"text-sm"},lg:{track:"h-6 w-11",handle:"h-5 w-5",text:"text-base"},xl:{track:"h-7 w-14",handle:"h-6 w-6",text:"text-lg"}};function gE({isSelected:e,isDisabled:t,size:r="md"}){let o="flex px-px items-center shrink-0 cursor-default rounded-full transition duration-200 ease-in-out shadow-inner border border-transparent",n=Jm[r].track,a=pt,i="focus-visible:outline-action-primary",s="";return e?s="bg-action-primary forced-colors:!bg-[Highlight] group-pressed:bg-action-primary-hover":s="bg-border-input group-pressed:bg-border-focus",[o,n,a,i,s,t?"bg-background-muted forced-colors:group-selected:!bg-[GrayText] forced-colors:border-[GrayText]":""].filter(Boolean).join(" ")}function hE({isSelected:e,isDisabled:t,size:r="md"}){let o="transform rounded-full bg-background-surface outline-none shadow transition duration-200 ease-in-out",n=Jm[r].handle;return [o,n,e?"translate-x-[100%]":"translate-x-0",t?"forced-colors:outline-[GrayText]":""].filter(Boolean).join(" ")}function qc({children:e,variant:t="primary",size:r="md",...o}){return jsx(Switch,{...o,className:Fe(o.className,`relative group flex items-center gap-2 ${Jm[r].text} text-text-primary transition disabled:text-text-disabled forced-colors:disabled:text-[GrayText]`),children:n=>jsxs(Fragment,{children:[jsx("div",{className:gE({...n,size:r}),children:jsx("span",{className:hE({...n,size:r})})}),e]})})}function Qy(e){return new Intl.NumberFormat("en-US").format(e)}function _y({isOpen:e,onClose:t,facetConfigs:r,facetCounts:o={},currentFilters:n,onApply:a,onClear:i,title:s="Filters",resultCount:l}){let[d,c]=useState(n),[u,m]=useState({}),[p,g]=useState({}),[f,b]=useState(null),{isMobile:h}=Rr(),v=useMemo(()=>r.some(y=>y.group),[r]),{groups:x,ungroupedFacets:C,facetsByGroup:S}=useMemo(()=>{let y=new Set,E=[],P={};for(let Y of r)Y.group?(y.has(Y.group)||(y.add(Y.group),P[Y.group]=[]),P[Y.group].push(Y)):E.push(Y);return {groups:Array.from(y),ungroupedFacets:E,facetsByGroup:P}},[r]);useEffect(()=>{e&&(c(n),m({}),g({}),b(!h&&x.length>0?x[0]:null));},[e,n,x,h]);let w=useMemo(()=>!d||Jc(d)?0:La(d).length,[d]),T=()=>{a(d),t();},N=()=>{let y=Bs();c(y),i?i():a(y),t();},k=y=>{if(!d)return [];if(!La(d).includes(y))return [];let P=[];function Y($){if($)for(let oe of $.conditions)"conditions"in oe?Y(oe):oe.field===y&&oe.operator==="in"&&Array.isArray(oe.value)&&P.push(...oe.value.map(String));}return Y(d),P},R=(y,E,P)=>{let Y=Ea(d,y);E!==void 0&&(Y=Xn(Y,{field:y,operator:"gte",value:E})),P!==void 0&&(Y=Xn(Y,{field:y,operator:"lte",value:P})),c(Y);},A=y=>{if(!d)return;let E;function P(Y){if(Y)for(let $ of Y.conditions)"conditions"in $?P($):$.field===y&&$.operator==="eq"&&typeof $.value=="boolean"&&(E=$.value);}return P(d),E},M=(y,E)=>{let P=Ea(d,y);E!==void 0&&(P=Xn(P,{field:y,operator:"eq",value:E})),c(P);},B=(y,E,P)=>{let Y=Ea(d,y);E&&(Y=Xn(Y,{field:y,operator:"gte",value:E.toString()})),P&&(Y=Xn(Y,{field:y,operator:"lte",value:P.toString()})),c(Y);},D=y=>{let E=S[y]||[],P=d?La(d):[];return E.filter(Y=>P.includes(Y.field)).length},W="pr-9 bg-background-muted/50",X="border-t border-border-muted",H="text-sm font-medium text-text-link-default",I=y=>jsx("span",{className:H,children:y}),F=y=>{let E=o[y.field]||{},P=u[y.field]||"",Y=[];y.values?Y=y.values.map(re=>({value:String(re.value),label:re.label,count:E[String(re.value)]})):Y=Object.entries(E).map(([re,_])=>({value:re,label:re,count:_}));let $=Y.length;if(P){let re=P.toLowerCase();Y=Y.filter(_=>_.label.toLowerCase().includes(re));}Y.sort((re,_)=>re.count!==void 0&&_.count!==void 0&&_.count!==re.count?_.count-re.count:re.label.localeCompare(_.label));let oe=y.type||"string";if(oe==="string"||!y.type){let re=k(y.field),_=y.searchThreshold??10,he=y.maxVisibleOptions??50,me=p[y.field]??false,ue=me||Y.length<=he?Y:Y.slice(0,he),ie=Y.length>he&&!me;return jsxs(On,{id:y.field,children:[jsx(zn,{title:y.label,description:y.description,className:W,endContent:re.length>0?I(`${re.length} selected`):void 0}),jsx(Hn,{className:X,children:jsxs("div",{className:"space-y-4 pt-4 pb-4",children:[$>_&&jsx(Ma,{value:P,onChange:fe=>m(Te=>({...Te,[y.field]:fe})),onClear:()=>m(fe=>({...fe,[y.field]:""})),placeholder:`Search ${y.label.toLowerCase()}...`,size:"sm",className:"w-full !max-w-none pr-4"}),jsx(Yp,{value:re,onChange:fe=>{let Te=Ea(d,y.field);fe.length>0&&(Te=Xn(Te,{field:y.field,operator:"in",value:fe})),c(Te);},children:jsx("div",{className:"space-y-1.5",children:ue.map(fe=>jsx("div",{className:"rounded-md py-2 pr-4 transition-colors hover:bg-background-hover",children:jsx(So,{value:fe.value,children:jsxs("div",{className:"flex items-center justify-between gap-3 flex-1",children:[y.renderLabel?y.renderLabel(fe.value,fe.label):jsx("span",{className:"text-sm font-medium text-text-primary",children:fe.label}),fe.count!==void 0&&jsx("span",{className:"text-xs font-medium text-text-secondary tabular-nums",children:Qy(fe.count)})]})})},fe.value))})}),ie&&jsx("div",{className:"pt-2 border-t border-border-muted",children:jsxs(te,{variant:"ghost",size:"sm",onPress:()=>g(fe=>({...fe,[y.field]:true})),className:"w-full",children:["Show all ",Y.length," options"]})}),me&&Y.length>he&&jsx("div",{className:"pt-2 border-t border-border-muted",children:jsx(te,{variant:"ghost",size:"sm",onPress:()=>g(fe=>({...fe,[y.field]:false})),className:"w-full",children:"Show less"})})]})})]},y.field)}if(oe==="number"){let re,_,he=ue=>{if(ue)for(let ie of ue.conditions)"conditions"in ie?he(ie):ie.field===y.field&&(ie.operator==="gte"&&typeof ie.value=="number"&&(re=ie.value),ie.operator==="lte"&&typeof ie.value=="number"&&(_=ie.value));};he(d);let me=re!==void 0||_!==void 0;return jsxs(On,{id:y.field,children:[jsx(zn,{title:y.label,description:y.description,className:W,endContent:me?I(re!==void 0&&_!==void 0?`${re} - ${_}`:re!==void 0?`\u2265 ${re}`:`\u2264 ${_}`):void 0}),jsx(Hn,{className:X,children:jsxs("div",{className:"grid grid-cols-2 gap-4 pt-4 pb-4",children:[jsx(Os,{label:"Min",value:re,onChange:ue=>R(y.field,ue,_)},`${y.field}-min`),jsx(Os,{label:"Max",value:_,onChange:ue=>R(y.field,re,ue)},`${y.field}-max`)]})})]},y.field)}if(oe==="boolean"){let re=A(y.field);return jsxs(On,{id:y.field,children:[jsx(zn,{title:y.label,description:y.description,className:W,endContent:re!==void 0?I(re?"Yes":"No"):void 0}),jsx(Hn,{className:X,children:jsxs("div",{className:"flex items-center justify-between pt-4 pb-4",children:[jsx("span",{className:"text-sm font-medium text-text-primary",children:re!==void 0?re?"Enabled":"Disabled":"No filter applied"}),jsx(qc,{size:"lg",isSelected:re??false,onChange:_=>M(y.field,_?true:void 0),children:re?"Yes":"No"})]})})]},y.field)}if(oe==="date"){let re,_,he=Te=>{if(Te)for(let Ye of Te.conditions)"conditions"in Ye?he(Ye):Ye.field===y.field&&(Ye.operator==="gte"&&(re=String(Ye.value)),Ye.operator==="lte"&&(_=String(Ye.value)));};he(d);let me=re!==void 0||_!==void 0,ue=Te=>{if(Te)try{return /^\d{4}-\d{2}-\d{2}$/.test(Te)?parseDate(Te):void 0}catch{return}},ie=ue(re),fe=ue(_);return jsxs(On,{id:y.field,children:[jsx(zn,{title:y.label,description:y.description,className:W,endContent:me?I("Date range selected"):void 0}),jsx(Hn,{className:X,children:jsx("div",{className:"pt-4 pb-4",children:jsx(jc,{label:"Date Range",value:ie&&fe?{start:ie,end:fe}:void 0,onChange:Te=>{Te?B(y.field,Te.start,Te.end):B(y.field,void 0,void 0);}})})})]},y.field)}return null},z=()=>jsxs("div",{className:"flex flex-col",children:[C.map(y=>{let P=(d?La(d):[]).includes(y.field);return jsxs("button",{type:"button",onClick:()=>b(`__ungrouped__${y.field}`),className:"flex items-center justify-between px-6 py-3 text-left hover:bg-background-hover border-b border-border-muted transition-colors",children:[jsx("span",{className:"text-sm font-medium text-text-primary",children:y.label}),jsxs("div",{className:"flex items-center gap-2",children:[P&&jsx("span",{className:H,children:"1 active"}),jsx(G,{name:"CaretRight",size:"sm",className:"text-text-secondary"})]})]},y.field)}),x.map(y=>{let E=D(y);return jsxs("button",{type:"button",onClick:()=>b(y),className:"flex items-center justify-between px-6 py-3 text-left hover:bg-background-hover border-b border-border-muted transition-colors",children:[jsx("span",{className:"text-sm font-medium text-text-primary",children:y}),jsxs("div",{className:"flex items-center gap-2",children:[E>0&&jsxs("span",{className:H,children:[E," active"]}),jsx(G,{name:"CaretRight",size:"sm",className:"text-text-secondary"})]})]},y)})]}),U=y=>{if(y.startsWith("__ungrouped__")){let P=y.replace("__ungrouped__",""),Y=C.find($=>$.field===P);return Y?jsx(yi,{variant:"contained",density:"comfortable",showDividers:true,defaultExpandedKeys:[Y.field],children:F(Y)}):null}let E=S[y]||[];return E.length===0?null:jsx(yi,{variant:"contained",density:"comfortable",showDividers:true,defaultExpandedKeys:[E[0].field],children:E.map(P=>F(P))})},K=()=>{if(f){let y=f.startsWith("__ungrouped__")&&C.find(E=>E.field===f.replace("__ungrouped__",""))?.label||f;return jsxs("div",{className:"flex flex-col h-full",children:[jsxs("button",{type:"button",onClick:()=>b(null),className:"flex items-center gap-2 px-4 py-3 border-b border-border-muted hover:bg-background-hover transition-colors",children:[jsx(G,{name:"CaretLeft",size:"sm",className:"text-text-secondary"}),jsx("span",{className:"text-sm font-medium text-text-primary",children:y})]}),jsx("div",{className:"flex-1 overflow-y-auto",children:U(f)})]})}return z()},O=()=>jsxs("div",{className:"flex h-full",children:[jsxs("div",{className:"w-48 flex-shrink-0 border-r border-border-muted overflow-y-auto bg-background-muted/30",children:[C.map(y=>{let P=(d?La(d):[]).includes(y.field),Y=f===`__ungrouped__${y.field}`;return jsxs("button",{type:"button",onClick:()=>b(`__ungrouped__${y.field}`),className:`flex items-center justify-between w-full px-4 py-3 text-left border-b border-border-muted transition-colors ${Y?"bg-background-selected":"hover:bg-background-hover"}`,children:[jsx("span",{className:`text-sm truncate ${Y?"font-semibold text-text-primary":"font-medium text-text-primary"}`,children:y.label}),P&&jsx("span",{className:"w-2 h-2 rounded-full bg-action-primary flex-shrink-0 ml-2"})]},y.field)}),x.map(y=>{let E=D(y),P=f===y;return jsxs("button",{type:"button",onClick:()=>b(y),className:`flex items-center justify-between w-full px-4 py-3 text-left border-b border-border-muted transition-colors ${P?"bg-background-selected":"hover:bg-background-hover"}`,children:[jsx("span",{className:`text-sm truncate ${P?"font-semibold text-text-primary":"font-medium text-text-primary"}`,children:y}),E>0&&jsx("span",{className:"w-2 h-2 rounded-full bg-action-primary flex-shrink-0 ml-2"})]},y)})]}),jsx("div",{className:"flex-1 overflow-y-auto",children:f?U(f):jsx("div",{className:"flex items-center justify-center h-full text-text-secondary text-sm",children:"Select a category to view filters"})})]}),V=()=>jsx(yi,{variant:"contained",density:"comfortable",showDividers:true,defaultExpandedKeys:[r[0].field],children:r.map(y=>F(y))});return jsx(Dr,{isOpen:e,onClose:t,title:v&&h&&f?f.startsWith("__ungrouped__")?C.find(y=>y.field===f.replace("__ungrouped__",""))?.label||s:f:w>0?`${s} (${w} active)`:s,hideCloseIcon:false,primaryAction:{label:"Apply filters",onPress:T,variant:"primary"},secondaryAction:{label:"Clear all",onPress:N},maxWidth:v?"800px":"700px",height:"600px",mobileHeight:"85vh",contentPadding:false,footerContent:l!==void 0?jsxs("div",{className:"text-sm text-text-secondary text-center",children:[jsx("span",{className:"font-semibold text-text-primary",children:Qy(l)})," ",l===1?"result":"results"," with current filters"]}):void 0,children:r.length===0?jsx("div",{className:"py-12 text-center",children:jsx("div",{className:"text-sm font-medium text-text-secondary",children:"No filters available"})}):v?h?K():O():V()})}function qm(e="left"){switch(e){case "center":return "justify-center text-center";case "right":return "justify-end text-right";default:return "justify-start text-left"}}function Gr(e="normal",t){return twMerge({strong:"font-semibold text-text-primary",high:"font-semibold text-text-primary",normal:"text-text-primary",low:"text-text-secondary"}[e],t&&"hover:text-action-primary cursor-pointer transition-colors")}function ke(e="left",t){return twMerge("flex items-center gap-1 min-w-0 overflow-hidden",qm(e),t)}function _c(e,t="\u2014"){return e==null||e===""?t:String(e)}var Jn={xs:"h-4 w-12",sm:"h-4 w-20",md:"h-4 w-24",lg:"h-4 w-32",xl:"h-4 w-40"};function Ft(e="normal"){return {strong:Jn.lg,high:Jn.lg,normal:Jn.md,low:Jn.sm}[e]}function ge(e,...t){return typeof e=="function"?e(...t):e}function $y(e="neutral",t="sm"){return twMerge("inline-flex items-center rounded-full font-medium",t==="sm"?"px-2 py-0.5 text-xs":"px-2.5 py-1 text-sm",{success:"bg-feedback-success-background text-feedback-success-text",error:"bg-feedback-error-background text-feedback-error-text",warning:"bg-feedback-warning-background text-feedback-warning-text",info:"bg-feedback-info-background text-feedback-info-text",neutral:"bg-background-muted text-text-secondary"}[e])}function ev(e){return e?"success":"neutral"}function $c(e,t=false){return t?e>0?"text-feedback-success-text":e<0?"text-feedback-error-text":"text-text-primary":"text-text-primary"}function Zm(e="hover",t="secondary"){let r={primary:"text-action-primary hover:text-action-primary-hover visited:text-action-primary",secondary:"text-text-link-default hover:text-text-link-hover visited:text-text-link-default",default:"text-text-link-default hover:text-text-link-hover visited:text-text-link-default",brand:"text-action-primary hover:text-action-primary-hover visited:text-action-primary",muted:"text-text-secondary hover:text-text-secondary visited:text-text-secondary",unstyled:""},o={visible:"underline underline-offset-4 decoration-1 cursor-pointer",hover:"hover:underline hover:underline-offset-4 hover:decoration-1 cursor-pointer transition-colors",none:"cursor-pointer"},n=r[t],a=o[e]||"";return `${n} ${a}`.trim()}function Yo(e,t,r,o="hover",n="secondary",a,i){if(!t)return e;let s=typeof t=="function"&&r?t(r):t,l=Zm(o,n);return jsx("a",{href:s,className:twMerge(l,a==="strong"||a==="high"?"font-semibold":"",i),onClick:c=>{c.metaKey||c.ctrlKey;},children:e})}function tv({row:e,context:t,actions:r,align:o="right",size:n="sm"}){let{isLoading:a}=t;if(a)return jsx(q,{className:Jn.sm});let s=(typeof r=="function"?r(e):r).filter(d=>!ge(d.hidden,e));if(s.length===0)return null;let l=ke(o);return jsx("div",{className:l,children:s.map(d=>{let c=ge(d.disabled,e);return d.variant==="icon"||!d.label?jsx(te,{variant:"icon",size:n,onPress:()=>{d.onClick(e);},isDisabled:c,"aria-label":d.label||d.id,children:jsx(G,{name:d.icon||"DotsThree",size:n==="sm"?16:20})},d.id):jsxs(te,{variant:d.variant||"secondary",size:n,onPress:()=>{d.onClick(e);},isDisabled:c,children:[d.icon&&jsx(G,{name:d.icon,size:n==="sm"?14:16}),d.label]},d.id)})})}function ov({value:e,row:t,context:r,variant:o="default",label:n,size:a="sm",shape:i="square",dot:s,dotPosition:l="left",dotPulse:d,align:c="left",emptyText:u="\u2014",className:m,maxVisible:p=2,maxLabelLength:g}){let{isLoading:f}=r,b=(w,T)=>{if(!g||w.length<=g)return jsx(Fragment,{children:w});let N=w.slice(0,g-1)+"\u2026";return jsx(tr,{content:T,children:jsx("span",{children:N})})};if(f)return jsx(q,{className:Ft("normal")});if(e==null||e==="")return jsx("div",{className:ke(c,"text-text-secondary"),children:u});if(Array.isArray(e)&&e.length===0)return jsx("div",{className:ke(c,"text-text-secondary"),children:u});let h=ke(c,m);if(Array.isArray(e)){let w=e.slice(0,p),T=e.slice(p),N=T.length>0;return jsx("div",{className:h,children:jsxs("div",{className:"flex items-center gap-1",children:[w.map((k,R)=>{let A=ge(o,k,t),M=n!==void 0?ge(n,k,t):String(k),B=ge(s,k,t),D=ge(d,k,t);return jsx("span",{className:"flex-shrink-0 whitespace-nowrap",children:jsx(kt,{variant:A,size:a,shape:i,dot:B,dotPosition:l,dotPulse:D,children:b(M,M)})},R)}),N&&jsx(tr,{content:T.join(", "),children:jsx("span",{className:"flex-shrink-0 whitespace-nowrap",children:jsxs(kt,{variant:"neutral",size:a,shape:i,children:["+",T.length]})})})]})})}let v=ge(o,e,t),x=n!==void 0?ge(n,e,t):String(e),C=ge(s,e,t),S=ge(d,e,t);return jsx("div",{className:h,children:jsx(kt,{variant:v,size:a,shape:i,dot:C,dotPosition:l,dotPulse:S,children:b(x,x)})})}function nv({value:e,context:t,format:r="icon",trueText:o="Yes",falseText:n="No",trueIcon:a="Check",falseIcon:i="X",showFalse:s=true,align:l="center",emphasis:d="normal",className:c}){let{isLoading:u}=t;if(u)return jsx(q,{className:Ft(d)});let m=!!e;if(!m&&!s)return jsx("div",{className:ke(l,c)});let p=ke(l,c);switch(r){case "icon":return jsx("div",{className:p,children:jsx(G,{name:m?a:i,size:16,className:m?"text-feedback-success-text":"text-text-disabled"})});case "text":return jsx("div",{className:p,children:jsx("span",{className:Gr(d),children:m?o:n})});case "badge":return jsx("div",{className:p,children:jsx(kt,{variant:m?"success":"neutral",size:"sm",children:m?o:n})});default:return null}}var ed="var(--color-text-subtle)",av=Tl().map((e,t)=>`var(--color-viz-categorical-${t+1})`);function sv({value:e,row:t,context:r,color:o,swatch:n="dot",emptyText:a="\u2014",align:i="left",className:s}){let{isLoading:l}=r;if(l)return jsx(q,{className:Ft("normal")});let d=ge(e,t),c=d==null?"":String(d);return c.length===0?jsx("div",{className:ke(i,"text-text-secondary"),children:a}):jsxs("div",{className:ke(i,twMerge("gap-2",s)),children:[jsx("span",{"aria-hidden":"true",className:twMerge("h-2 w-2 flex-shrink-0",n==="dot"?"rounded-full":"rounded-sm"),style:{backgroundColor:o??ed}}),jsx("span",{className:"truncate",children:c})]})}function cv({row:e,context:t,firstName:r,lastName:o,email:n,avatarUrl:a,layout:i="stacked",size:s="sm",href:l,LinkComponent:d,linkVariant:c="secondary",showEmail:u=false,badge:m,emphasis:p="normal",align:g="left",className:f,piiEntity:b}){let{isLoading:h}=t,v=ge(r,e),x=ge(o,e),C=ge(n,e),S=ge(a,e),w=ge(l,e),T=ge(m,e),N=ge(b,e),k=ke(g,f);return jsx("div",{className:k,children:jsx(lc,{firstName:v,lastName:x,email:C,avatarUrl:S,layout:i,size:s,href:w,LinkComponent:d,linkVariant:c,showEmail:u,badge:T,emphasis:p,isLoading:h,piiEntity:N})})}function dv({value:e,row:t,context:r,render:o,className:n}){let a=o(e,t,r);return jsx("div",{className:twMerge("h-full w-full",n),children:a})}function uv({value:e,row:t,context:r,format:o="date",customFormat:n,emptyText:a="\u2014",align:i="left",emphasis:s="normal",href:l,linkBehavior:d="hover",className:c}){let{isLoading:u}=r;if(u)return jsx(q,{className:Ft(s)});if(!e)return jsx("div",{className:ke(i,"text-text-secondary"),children:a});let m=e instanceof Date?e:new Date(e);if(isNaN(m.getTime()))return jsx("div",{className:ke(i,"text-text-secondary"),children:a});let p;switch(o){case "date":p=m.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"});break;case "time":p=m.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"});break;case "datetime":p=m.toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});break;case "relative":p=RE(m);break;case "custom":p=n?m.toLocaleString("en-US",n):m.toISOString();break;default:p=m.toLocaleDateString();}let g=ke(i,twMerge(Gr(s),c)),f=ge(l,t);return f?jsx("div",{className:g,children:Yo(p,f,t,d)}):jsx("div",{className:g,children:p})}function RE(e){let r=new Date().getTime()-e.getTime(),o=Math.floor(r/1e3),n=Math.floor(o/60),a=Math.floor(n/60),i=Math.floor(a/24);return o<60?"just now":n<60?`${n} minute${n!==1?"s":""} ago`:a<24?`${a} hour${a!==1?"s":""} ago`:i<7?`${i} day${i!==1?"s":""} ago`:e.toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}var EE={up:"ArrowUp",down:"ArrowDown",flat:"Minus"},LE={positive:"text-feedback-success-text",negative:"text-feedback-error-text",neutral:"text-text-secondary"};function Qm(e){return e>0?"up":e<0?"down":"flat"}function DE(e,t,r){switch(e){case "percent":return {type:"percentage",decimals:t};case "currency":return {type:"currency",currency:r,minimumFractionDigits:t,maximumFractionDigits:t};case "compact":return {type:"number",notation:"compact",decimals:t,thousandsSeparator:true};default:return {type:"number",decimals:t,thousandsSeparator:true}}}function pv({value:e,row:t,context:r,direction:o,tone:n="neutral",format:a="number",decimals:i=0,currency:s="USD",showIcon:l=true,align:d="right",emphasis:c="normal",emptyText:u="\u2014",className:m}){let{isLoading:p}=r;if(p)return jsx(q,{className:Ft(c)});let g=typeof e=="number"?e:Number(e);if(e==null||e===""||!Number.isFinite(g))return jsx("div",{className:ke(d,"text-text-secondary"),children:u});let f=ge(o,t)??Qm(g),b=ge(n,t)??"neutral",h=Xr(g,DE(a,i,s))??u,v=g>0?"+":"",C=ke(d,twMerge(c==="strong"||c==="high"?"font-semibold":void 0,m,LE[b]));return jsxs("div",{className:C,children:[l&&jsx(G,{name:EE[f],size:"xs","aria-hidden":true}),jsx("span",{children:`${v}${h}`})]})}var IE={open:{className:"text-feedback-success-border",token:"--color-feedback-success-border",label:"Open"},closed:{className:"text-feedback-error-border",token:"--color-feedback-error-border",label:"Closed"}},FE={platform:{label:"Platform",description:"Core product objects that structure the Texture workspace.",icon:"Stack",order:0},grid:{label:"Grid Elements",description:"Physical utility-grid infrastructure imported from a customer's GIS export.",icon:"TreeStructure",order:1},device:{label:"Devices",description:"Behind-the-meter connected energy devices.",icon:"Lightning",order:2}},BE=["energized","customerName","gs_max_continuous_current"],VE=["MOTOR.voltage"],OE=[{key:"total_kvar",label:"Rated kvar",format:{type:"power",unit:"kvar",decimals:1}}],zE=[{key:"kvar_a",label:"kvar A",format:{type:"power",unit:"kvar",decimals:1}},{key:"kvar_b",label:"kvar B",format:{type:"power",unit:"kvar",decimals:1}},{key:"kvar_c",label:"kvar C",format:{type:"power",unit:"kvar",decimals:1}}],xt={TRANSFORMER:[{key:"capacityKva",label:"kVA Rating",format:{type:"power",unit:"kVA",decimals:0}},{key:"phase",label:"Phase",format:{type:"text"}},{key:"primaryVoltageKv",label:"Primary Voltage",format:{type:"voltage",unit:"kV",decimals:1}},{key:"outputVoltageKv",label:"Output Voltage",format:{type:"voltage",unit:"kV",decimals:2}},{key:"manufacturer",label:"Manufacturer",format:{type:"text"}},{key:"xfmr_conductor_description",label:"Conductor",format:{type:"text"}}],CONSUMER:[{key:"service_address",label:"Service address",format:{type:"text"}},{key:"name",label:"Customer",format:{type:"text"}},{key:"account_number",label:"Account #",format:{type:"text"}},{key:"meterNumber",label:"Meter Number",format:{type:"text"}},{key:"service_type",label:"Service type",format:{type:"text"}}],SOURCE:[{key:"voltageKv",label:"Nominal Voltage",format:{type:"voltage",unit:"kV",decimals:1}},{key:"substationNumber",label:"Substation Number",format:{type:"text"}},{key:"trf_capacity",label:"Rated Capacity",format:{type:"text"}},{key:"connection_code",label:"Connection",format:{type:"text"}}],SWITCH:[{key:"switchId",label:"Switch ID",format:{type:"text"}},{key:"phase",label:"Phase",format:{type:"text"}},{key:"max_continuous_current",label:"Max Continuous Current",format:{type:"number",unit:"A",decimals:0}},{key:"switchIsOpen",label:"Position",format:{type:"text"}},{key:"switch_status",label:"Status",format:{type:"text"}},{key:"partnerIdentifier",label:"Partner ID",format:{type:"text"}}],CAPACITOR:[{key:"phase",label:"Phase",format:{type:"text"}},{key:"nominalVoltageV",label:"Nominal Voltage",format:{type:"voltage",unit:"V",decimals:0}}],OVERCURRENT_DEVICE:[{key:"size_value",label:"Size",format:{type:"text"}},{key:"phase",label:"Phase",format:{type:"text"}}],REGULATOR:[{key:"rated_kva",label:"Rated kVA",format:{type:"power",unit:"kVA",decimals:0}},{key:"phase",label:"Phase",format:{type:"text"}},{key:"manufacturer",label:"Manufacturer",format:{type:"text"}},{key:"high_side_configuration",label:"High Side",format:{type:"text"}},{key:"forwardSetVoltageV",label:"Forward Set Voltage",format:{type:"voltage",unit:"V",decimals:1}}],OVERHEAD_LINE:[{key:"impedanceLength",label:"Length",format:{type:"distance",unit:"ft",decimals:2}},{key:"conductorDescPhA",label:"Conductor Phase A",format:{type:"text"}},{key:"conductorDescPhB",label:"Conductor Phase B",format:{type:"text"}},{key:"conductorDescPhC",label:"Conductor Phase C",format:{type:"text"}},{key:"conductorDescNeutral",label:"Conductor Neutral",format:{type:"text"}},{key:"phase",label:"Phase",format:{type:"text"}},{key:"subtype_cd",label:"Subtype",format:{type:"text"}}],UNDERGROUND_LINE:[{key:"impedanceLength",label:"Length",format:{type:"distance",unit:"ft",decimals:2}},{key:"conductorDescPhA",label:"Conductor Phase A",format:{type:"text"}},{key:"conductorDescPhB",label:"Conductor Phase B",format:{type:"text"}},{key:"conductorDescPhC",label:"Conductor Phase C",format:{type:"text"}},{key:"phase",label:"Phase",format:{type:"text"}},{key:"subtype_cd",label:"Subtype",format:{type:"text"}}],NODE:[],SUPPORT_STRUCTURE:[{key:"height",label:"Height",format:{type:"distance",unit:"ft",decimals:0}},{key:"class",label:"Class",format:{type:"text"}},{key:"species",label:"Material",format:{type:"text"}},{key:"phase",label:"Phase",format:{type:"text"}},{key:"substation",label:"Substation",format:{type:"text"}}],GENERATOR:[{key:"phase",label:"Phase",format:{type:"text"}},{key:"generator_system_size",label:"System Size",format:{type:"number",decimals:1}}],MOTOR:[{key:"ratedPower",label:"Rated Power",format:{type:"power",unit:"kW",decimals:1}},{key:"voltage",label:"Voltage",format:{type:"voltage",unit:"V",decimals:0}}],DEVICE_LEADER:[],TRANSFORMER_BANK:[]},fn={app:{icon:"AppWindow",category:"platform",archetype:"platform",detailPage:false,label:{singular:"App",plural:"Apps"},description:"Workspace tools and third-party integrations"},site:{icon:"MapPin",category:"platform",archetype:"platform",detailPage:true,label:{singular:"Site",plural:"Sites"},description:"Physical location housing energy systems"},device:{icon:"ShareNetwork",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Device",plural:"Devices"},description:"Connected, controllable energy device"},customer:{icon:"Users",category:"platform",archetype:"platform",detailPage:true,label:{singular:"Customer",plural:"Customers"},description:"End customer or owner of one or more sites"},contact:{icon:"Users",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Contact",plural:"Contacts"},description:"Person associated with a customer or site"},program:{icon:"ClipboardText",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Program",plural:"Programs"},description:"Demand-response or virtual power plant program"},workflow:{icon:"FlowArrow",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Workflow",plural:"Workflows"},description:"Automated rule that runs in response to events"},collection:{icon:"Stack",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Collection",plural:"Collections"},description:"Named group of related entities or records"},board:{icon:"TextureBoards",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Board",plural:"Boards"},description:"Dashboard for monitoring metrics and devices"},report:{icon:"ChartLine",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Report",plural:"Reports"},description:"Saved analytics view or generated report"},event:{icon:"ClockCounterClockwise",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Event",plural:"Events"},description:"Recorded system event or logged activity"},alert:{icon:"Warning",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Alert",plural:"Alerts"},description:"Notification raised when attention is needed"},monitor:{icon:"TextureMonitors",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Monitor",plural:"Monitors"},description:"Rule that watches a metric against a threshold"},insight:{icon:"LightbulbFilament",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Insight",plural:"Insights"},description:"Derived finding surfaced from platform data"},command:{icon:"Play",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Command",plural:"Commands"},description:"Control action issued to a connected device"},explore:{icon:"TextureExplore",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Explore",plural:"Explore"},description:"The BEAM map surface for exploring the connected grid."},boards:{icon:"TextureBoards",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Boards",plural:"Boards"},description:"The BEAM surface for building and viewing grid dashboards."},monitors:{icon:"TextureMonitors",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Monitors",plural:"Monitors"},description:"The BEAM surface for watching conditions across the grid."},askTexture:{icon:"Sparkle",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Ask Texture",plural:"Ask Texture"},description:"The BEAM conversational surface for investigating grid data and creating views and monitors."},survey:{icon:"TextureSurvey",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Survey",plural:"Survey"},description:"The onboarding engagement that maps a utility's systems to the Terrain schema."},seismic:{icon:"TextureSeismic",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Seismic",plural:"Seismic"},description:"AI-powered interpretation of raw data, automatically mapped into the grid model."},waypoint:{icon:"TextureWaypoint",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Waypoint",plural:"Waypoint"},description:"Flexible customer data collection and authorization for consumer devices."},terrain:{icon:"TextureTerrain",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Terrain",plural:"Terrain"},description:"The shared schema for grid assets, locations, and relationships. An AI-ready data model standard."},magma:{icon:"TextureMagma",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Magma",plural:"Magma"},description:"The execution engine for streaming, monitoring, automation, insights, and simulations, using data in the Terrain schema."},ground:{icon:"TextureGround",category:"platform",archetype:"platform",detailPage:false,label:{singular:"Ground",plural:"Ground"},description:"On-premises hardware Stations for local control, AI processing, and continuity when cloud connectivity drops."},source:{icon:"TextureSource",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.SOURCE},label:{singular:"Source",plural:"Sources"},description:"Upstream feed where the network originates"},substation:{icon:"TextureSource",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.SOURCE},label:{singular:"Substation",plural:"Substations"},description:"Facility that steps down transmission voltage"},capacitor:{icon:"TextureCapacitor",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.CAPACITOR},label:{singular:"Capacitor",plural:"Capacitors"},description:"Capacitor bank for power-factor and voltage support"},switch:{icon:"TextureSwitchClosed",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.SWITCH},label:{singular:"Switch",plural:"Switches"},description:"Sectionalizing or disconnect switch on the line",states:{open:{icon:"TextureSwitch",color:"open"},closed:{icon:"TextureSwitchClosed",color:"closed"}}},sectionalizer:{icon:"TextureSectionalizerClosed",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.SWITCH},label:{singular:"Sectionalizer",plural:"Sectionalizers"},description:"Counts upstream recloser trips and opens to isolate a faulted section",states:{open:{icon:"TextureSectionalizerOpen",color:"open"},closed:{icon:"TextureSectionalizerClosed",color:"closed"}}},relay:{icon:"Cpu",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.NODE},label:{singular:"Relay",plural:"Relays"},description:"Microprocessor relay that senses faults and trips devices"},transformer:{icon:"TextureTransformer",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.TRANSFORMER},label:{singular:"Transformer",plural:"Transformers"},description:"Transformer that steps voltage up or down"},meter:{icon:"Gauge",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.CONSUMER},label:{singular:"Meter",plural:"Meters"},description:"Revenue meter at the point of consumption"},consumer:{icon:"Gauge",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.CONSUMER},label:{singular:"Consumer",plural:"Consumers"},description:"Service point or customer premise on the grid"},singlePhaseOverheadLine:{icon:"TextureSinglePhaseOverheadLine",category:"grid",archetype:"grid-line",detailPage:true,properties:{statList:xt.OVERHEAD_LINE},label:{singular:"Single-Phase Overhead Line",plural:"Single-Phase Overhead Lines"},description:"Overhead line carrying one phase conductor"},twoPhaseOverheadLine:{icon:"TextureTwoPhaseOverheadLine",category:"grid",archetype:"grid-line",detailPage:true,properties:{statList:xt.OVERHEAD_LINE},label:{singular:"Two-Phase Overhead Line",plural:"Two-Phase Overhead Lines"},description:"Overhead line carrying two phase conductors"},threePhaseOverheadLine:{icon:"TextureThreePhaseOverheadLine",category:"grid",archetype:"grid-line",detailPage:true,properties:{statList:xt.OVERHEAD_LINE},label:{singular:"Three-Phase Overhead Line",plural:"Three-Phase Overhead Lines"},description:"Overhead line carrying three phase conductors"},singlePhaseUndergroundLine:{icon:"TextureSinglePhaseUndergroundLine",category:"grid",archetype:"grid-line",detailPage:true,properties:{statList:xt.UNDERGROUND_LINE},label:{singular:"Single-Phase Underground Line",plural:"Single-Phase Underground Lines"},description:"Buried line carrying one phase conductor"},twoPhaseUndergroundLine:{icon:"TextureTwoPhaseUndergroundLine",category:"grid",archetype:"grid-line",detailPage:true,properties:{statList:xt.UNDERGROUND_LINE},label:{singular:"Two-Phase Underground Line",plural:"Two-Phase Underground Lines"},description:"Buried line carrying two phase conductors"},threePhaseUndergroundLine:{icon:"TextureThreePhaseUndergroundLine",category:"grid",archetype:"grid-line",detailPage:true,properties:{statList:xt.UNDERGROUND_LINE},label:{singular:"Three-Phase Underground Line",plural:"Three-Phase Underground Lines"},description:"Buried line carrying three phase conductors"},motorSwitch:{icon:"Diamond",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.MOTOR},label:{singular:"Motor Switch",plural:"Motor Switches"},description:"Motor-operated switch or motor load element"},recloser:{icon:"TextureRecloser",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.OVERCURRENT_DEVICE},label:{singular:"Recloser",plural:"Reclosers"},description:"Auto-reclosing device that clears transient faults",states:{open:{color:"open"},closed:{color:"closed"}}},fuse:{icon:"TextureFuse",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.OVERCURRENT_DEVICE},label:{singular:"Fuse",plural:"Fuses"},description:"Fusible element providing overcurrent protection"},breaker:{icon:"TextureBreaker",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.OVERCURRENT_DEVICE},label:{singular:"Breaker",plural:"Breakers"},description:"Circuit breaker that interrupts fault current",states:{open:{color:"open"},closed:{color:"closed"}}},generator:{icon:"Wind",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.GENERATOR},label:{singular:"Generator",plural:"Generators"},description:"Distributed generation unit feeding the grid"},regulator:{icon:"TextureRegulator",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.REGULATOR},label:{singular:"Regulator",plural:"Regulators"},description:"Voltage regulator that holds line voltage in range"},supportStructure:{icon:"TextureSupportStructure",category:"grid",archetype:"grid-line",detailPage:true,properties:{statList:xt.SUPPORT_STRUCTURE},label:{singular:"Support Structure",plural:"Support Structures"},description:"Structure carrying overhead line equipment"},deviceLeader:{icon:"FlowArrow",category:"grid",archetype:"grid-line",detailPage:true,properties:{statList:xt.DEVICE_LEADER},label:{singular:"Device Leader",plural:"Device Leaders"},description:"Cartographic leader line pointing an offset device symbol to its true location"},transformerBank:{icon:"TextureTransformer",category:"grid",archetype:"grid-energized",detailPage:true,properties:{statList:xt.TRANSFORMER_BANK},label:{singular:"Transformer Bank",plural:"Transformer Banks"},description:"Grouping of single-phase transformer units sharing a bank id"},battery:{icon:"BatteryHigh",category:"device",archetype:"device",detailPage:true,label:{singular:"Battery",plural:"Batteries"},description:"Behind-the-meter battery or storage system",fusedMetricId:"soc",fields:{headlineMetrics:[{id:"power",label:"device.battery.fields.gridPower",source:{kind:"state",path:"state.gridPower"},format:{type:"power",decimals:1},icon:"Lightning"},{id:"soc",label:"device.battery.fields.soc",source:{kind:"state",path:"state.chargePercentage"},format:{type:"percentage",decimals:0},icon:"BatteryCharging"},{id:"batteryPower",label:"device.battery.fields.batteryPower",source:{kind:"state",path:"state.chargeRate"},format:{type:"power",decimals:1},icon:"TrendUp"},{id:"backupReserve",label:"device.battery.fields.backupReserve",source:{kind:"state",path:"state.backupReserve"},format:{type:"percentage",decimals:0},icon:"BatteryCharging"}]},stateRules:{primaryState:{label:"device.battery.fields.status",fieldPath:"state.chargingState",mapping:{charging:"charging",discharging:"discharging",idle:"idle",unknown:"unknown"},fallback:"unknown"},secondaryState:{label:"device.battery.fields.gridState",fieldPath:"state.gridStatus",mapping:{importing:"importing",exporting:"exporting",idle:"idle",unknown:"unknown"},fallback:"unknown"}}},evCharger:{icon:"ChargingStation",category:"device",archetype:"device",detailPage:true,label:{singular:"EV Charger",plural:"EV Chargers"},description:"Electric-vehicle charging station or port",fusedMetricId:"power",fields:{headlineMetrics:[{id:"power",label:"device.evCharger.fields.power",source:{kind:"state",path:"state.chargerWattage"},format:{type:"power",decimals:1},icon:"Lightning"},{id:"isPluggedIn",label:"device.evCharger.fields.isPluggedIn",source:{kind:"state",path:"state.isPluggedIn"},format:{type:"boolean",trueText:"Yes",falseText:"No"},icon:"Plug"},{id:"voltage",label:"device.evCharger.fields.voltage",source:{kind:"state",path:"state.chargerVoltage"},format:{type:"voltage",decimals:1},icon:"Lightning"},{id:"current",label:"device.evCharger.fields.current",source:{kind:"state",path:"state.chargerCurrent"},format:{type:"current",decimals:1},icon:"Lightning"}]},stateRules:{primaryState:{label:"device.evCharger.fields.status",fieldPath:"state.chargingState",mapping:{charging:"charging",discharging:"discharging",idle:"idle",unknown:"unknown"},fallback:"unknown"}}},inverter:{icon:"Sun",category:"device",archetype:"device",detailPage:true,label:{singular:"Solar / Inverter",plural:"Solar / Inverters"},description:"Solar PV inverter and its connected array",fusedMetricId:"power",fields:{headlineMetrics:[{id:"power",label:"device.inverter.fields.power",source:{kind:"state",path:"state.power"},format:{type:"power",decimals:0},icon:"Lightning"},{id:"gridPower",label:"device.inverter.fields.gridPower",source:{kind:"state",path:"state.gridPower"},format:{type:"power",decimals:0},icon:"GridFour"},{id:"generatedEnergy",label:"device.inverter.fields.generatedEnergy",source:{kind:"state",path:"state.generatedEnergy"},format:{type:"energy",decimals:1},icon:"Lightning"},{id:"lifetimeEnergyGenerated",label:"device.inverter.fields.lifetimeEnergyGenerated",source:{kind:"state",path:"state.lifetimeEnergyGenerated"},format:{type:"energy",decimals:0},icon:"Lightning"}]},stateRules:{primaryState:{label:"device.inverter.fields.gridStatus",fieldPath:"state.gridStatus",mapping:{exporting:"exporting",importing:"importing",idle:"idle"},fallback:"unknown"}}},sensor:{icon:"TextureSensor",category:"device",archetype:"device",detailPage:true,label:{singular:"Sensor",plural:"Sensors"},description:"Connected grid and power-quality sensor"},thermostat:{icon:"Thermometer",category:"device",archetype:"device",detailPage:true,label:{singular:"Thermostat",plural:"Thermostats"},description:"Smart thermostat or connected HVAC control",fusedMetricId:"ambientTemperature",fields:{headlineMetrics:[{id:"ambientTemperature",label:"device.thermostat.fields.ambientTemperature",source:{kind:"state",path:"state.ambientTemperature"},format:{type:"temperature",decimals:0},icon:"Thermometer"},{id:"heatTarget",label:"device.thermostat.fields.heatTarget",source:{kind:"state",path:"state.heatTarget"},format:{type:"temperature",decimals:0},icon:"Flame"},{id:"coolTarget",label:"device.thermostat.fields.coolTarget",source:{kind:"state",path:"state.coolTarget"},format:{type:"temperature",decimals:0},icon:"Snowflake"},{id:"fanMode",label:"device.thermostat.fields.fanMode",source:{kind:"state",path:"state.fanMode"},format:{type:"text"}}]},stateRules:{primaryState:{label:"device.thermostat.fields.operatingMode",fieldPath:"state.operatingMode",mapping:{heat:"heat",cool:"cool",auto:"auto",off:"off",eco:"eco",unknown:"unknown"},fallback:"unknown"}}},vehicle:{icon:"Car",category:"device",archetype:"device",detailPage:true,label:{singular:"EV",plural:"EVs"},description:"Electric vehicle managed as a flexible load",fusedMetricId:"chargePercentage",fields:{headlineMetrics:[{id:"chargePercentage",label:"device.vehicle.fields.chargePercentage",source:{kind:"state",path:"state.chargePercentage"},format:{type:"percentage",decimals:0},icon:"BatteryCharging"},{id:"range",label:"device.vehicle.fields.range",source:{kind:"state",path:"state.range"},format:{type:"distance",unit:"mi",decimals:0},icon:"GasPump"},{id:"chargeLimit",label:"device.vehicle.fields.chargeLimit",source:{kind:"state",path:"state.chargeLimit"},format:{type:"percentage",decimals:0},icon:"BatteryCharging"},{id:"isPluggedIn",label:"device.vehicle.fields.isPluggedIn",source:{kind:"state",path:"state.isPluggedIn"},format:{type:"boolean",trueText:"Yes",falseText:"No"},icon:"Plug"}]},stateRules:{primaryState:{label:"device.vehicle.fields.status",fieldPath:"state.chargingState",mapping:{charging:"charging",discharging:"discharging",idle:"idle",unknown:"unknown"},fallback:"unknown"}}},waterHeater:{icon:"Drop",category:"device",archetype:"device",detailPage:true,label:{singular:"Water Heater",plural:"Water Heaters"},description:"Connected or smart electric water heater"}},mv=Object.freeze(Object.keys(fn).filter(e=>fn[e].category==="grid")),HE=new Set(mv);function GE(e){return typeof e=="string"&&HE.has(e)}var WE={source:"SOURCE",substation:"SOURCE",capacitor:"CAPACITOR",switch:"SWITCH",sectionalizer:"SWITCH",relay:"NODE",transformer:"TRANSFORMER",meter:"CONSUMER",consumer:"CONSUMER",singlePhaseOverheadLine:"OVERHEAD_LINE",twoPhaseOverheadLine:"OVERHEAD_LINE",threePhaseOverheadLine:"OVERHEAD_LINE",singlePhaseUndergroundLine:"UNDERGROUND_LINE",twoPhaseUndergroundLine:"UNDERGROUND_LINE",threePhaseUndergroundLine:"UNDERGROUND_LINE",motorSwitch:"MOTOR",recloser:"OVERCURRENT_DEVICE",fuse:"OVERCURRENT_DEVICE",breaker:"OVERCURRENT_DEVICE",generator:"GENERATOR",regulator:"REGULATOR",supportStructure:"SUPPORT_STRUCTURE",deviceLeader:"DEVICE_LEADER",transformerBank:"TRANSFORMER_BANK"};function od(e){return fn[e]}function Gs(e){return fn[e].icon}function UE(e,t=false){return t?fn[e].label.plural:fn[e].label.singular}function KE(e){return fn[e].category}var YE={min:2,max:4};function XE(e){let t=fn[e];if(!t)throw new Error(`archetypeFor: unknown entity type "${String(e)}"`);return t.archetype}function JE(e){return od(e).detailPage}function jE(e){return (od(e).fields?.headlineMetrics.length??0)>0}function fv(e){return od(e).properties?.statList??[]}function qE(e){return fv(e).length>0}function nd({manufacturer:e,model:t,deviceType:r,deviceTypeIconName:o,logoUrl:n,layout:a="stacked",size:i="md",href:s,LinkComponent:l,linkVariant:d="unstyled",showDeviceTypeIcon:c=true,showLogo:u=true,emphasis:m="normal",isLoading:p=false,className:g,piiEntity:f}){let[b,h]=useState(false),v=o||(r?QE(r):"DeviceMobile"),C={xs:{iconSize:28,logoSize:"w-7 h-7",gap:"gap-1.5",textSize:"text-xs",secondaryTextSize:"text-xs",iconInTextSize:12,skeletonIcon:28,skeletonText:80,skeletonSecondary:60},sm:{iconSize:32,logoSize:"w-8 h-8",gap:"gap-2",textSize:"text-sm",secondaryTextSize:"text-xs",iconInTextSize:14,skeletonIcon:32,skeletonText:96,skeletonSecondary:72},md:{iconSize:32,logoSize:"w-9 h-9",gap:"gap-3",textSize:"text-base",secondaryTextSize:"text-sm",iconInTextSize:16,skeletonIcon:36,skeletonText:128,skeletonSecondary:96},lg:{iconSize:40,logoSize:"w-10 h-10",gap:"gap-3",textSize:"text-lg",secondaryTextSize:"text-base",iconInTextSize:18,skeletonIcon:40,skeletonText:160,skeletonSecondary:120}}[i],S=n&&!b&&u,T={strong:"font-semibold text-text-primary",high:"font-semibold text-text-primary",normal:"text-text-primary",low:"text-text-secondary"}[m],N=({children:k,className:R})=>s?l?jsx(l,{href:s,className:R,children:k}):jsx(St,{href:s,variant:d,className:twMerge("hover:underline",R),asButton:false,children:k}):jsx("span",{className:R,children:k});if(p)return a==="inline"?jsxs("div",{className:twMerge("flex items-center",C.gap,g),children:[jsx(q,{width:C.skeletonIcon,height:C.skeletonIcon,className:"flex-shrink-0 rounded"}),jsx(q,{width:C.skeletonText,height:C.skeletonIcon*.6})]}):jsxs("div",{className:twMerge("flex items-center",C.gap,g),children:[jsx(q,{width:C.skeletonIcon,height:C.skeletonIcon,className:"flex-shrink-0"}),jsxs("div",{className:"flex flex-col gap-1",children:[jsx(q,{width:C.skeletonText,height:16}),jsx(q,{width:C.skeletonSecondary,height:12})]})]});if(a==="inline"){let k=`${e} ${t}`;return jsxs("div",{className:twMerge("flex items-center",C.gap,g),children:[jsx("div",{className:twMerge("flex-shrink-0 flex items-center justify-center rounded border border-border-muted",C.logoSize),children:S?jsx("img",{src:n,alt:`${e} logo`,className:"w-full h-full object-contain",onError:()=>h(true)}):jsx(G,{name:v,size:C.iconSize*.6,className:"text-text-secondary"})}),jsx(N,{className:twMerge("truncate leading-normal hover:text-text-primary",T,C.textSize,s&&"hover:underline hover:decoration-1 hover:underline-offset-4"),children:jsx("span",{"data-pii-type":f?"device-name":void 0,"data-pii-entity":f,children:k})})]})}return jsxs("div",{className:twMerge("flex items-center justify-start",C.gap,g),children:[u&&jsx("div",{className:twMerge("flex-shrink-0 flex items-center justify-center rounded border border-border-muted",C.logoSize),children:S?jsx("img",{src:n,alt:`${e} logo`,className:"w-full h-full object-contain",onError:()=>h(true)}):jsx(G,{name:v,size:C.iconSize*.6,className:"text-text-secondary"})}),jsxs("div",{className:"flex flex-col items-start min-w-0",children:[jsx(N,{className:twMerge("truncate leading-normal hover:text-text-primary",T,C.textSize,s&&"hover:underline hover:decoration-1 hover:underline-offset-4"),children:jsx("span",{"data-pii-type":f?"device-name":void 0,"data-pii-entity":f,children:e})}),jsxs("div",{className:twMerge("flex items-center gap-1.5 text-text-secondary leading-normal",C.secondaryTextSize),children:[c&&jsx(G,{name:v,size:C.iconInTextSize,className:"flex-shrink-0"}),jsx("span",{className:"truncate","data-pii-type":f?"device-name":void 0,"data-pii-entity":f,children:t})]})]})]})}function QE(e){switch(e){case "battery":return "BatteryHigh";case "charger":return "ChargingStation";case "inverter":return "Power";case "thermostat":return "ThermometerSimple";case "vehicle":return "CarSimple";case "water_heater":return "DropHalfBottom";case "meter":return "Gauge";case "sensor":return Gs("sensor");default:return "DeviceMobile"}}function hv({row:e,context:t,manufacturer:r,model:o,deviceType:n,logoUrl:a,layout:i="stacked",size:s="sm",href:l,LinkComponent:d,linkVariant:c="secondary",showDeviceTypeIcon:u=true,showLogo:m=true,emphasis:p="normal",align:g="left",className:f,piiEntity:b}){let{isLoading:h}=t,v=ge(r,e),x=ge(o,e),C=ge(n,e),S=ge(a,e),w=ge(l,e),T=ge(b,e),N=ke(g,f);return jsx("div",{className:N,children:jsx(nd,{manufacturer:v,model:x,deviceType:C,logoUrl:S,layout:i,size:s,href:w,LinkComponent:d,linkVariant:c,showDeviceTypeIcon:u,showLogo:m,emphasis:p,isLoading:h,piiEntity:T})})}var MZ={charging:"percentage",discharging:"percentage",on:"kW",idle:void 0,off:void 0,heat:"temperature",cool:"temperature",auto:"temperature",eco:"temperature",circulate:void 0,unknown:void 0,connected:void 0,disconnected:void 0},_E=["charging","discharging","heat","cool","on","circulate","connected"],$E={unknown:"Unknown",on:"On",off:"Off",idle:"Idle",charging:"Charging",discharging:"Discharging",heat:"Heating",eco:"Eco Mode",cool:"Cooling",auto:"Auto",circulate:"Circulating",connected:"Connected",disconnected:"Disconnected"};function _m(e){return _E.includes(e)}function $m(e){return $E[e]}function Aa({state:e,label:t,icon:r,isLoading:o,size:n="sm",shape:a="pill",dot:i,dotPulse:s,fixedWidth:l,className:d,...c}){if(o)return jsx(q,{className:"inline-flex h-6 w-20"});let u=t??$m(e),m=_m(e);return jsxs(kt,{variant:e,size:n,shape:a,dot:i??m,dotPulse:s??m,className:l?`w-28 justify-center ${d||""}`:d,...c,children:[r&&jsx(G,{name:r,size:n==="sm"?12:n==="md"?14:16}),u]})}var tL={importing:"Importing",exporting:"Exporting",idle:"Idle",unknown:"Unknown"};function xv(e){return tL[e]}var rL={importing:"ArrowDown",exporting:"ArrowUp"};function id({state:e,label:t,showIcon:r=false,isLoading:o,size:n="sm",shape:a="pill",fixedWidth:i,className:s,...l}){if(o)return jsx(q,{className:"inline-flex h-6 w-24"});let d=t??xv(e),c=rL[e],u=n==="sm"?12:n==="md"?14:16;return r&&c?jsx(kt,{variant:e,size:n,shape:a,className:`w-6 justify-center ${s||""}`,...l,children:jsx(G,{name:c,size:u})}):jsx(kt,{variant:e,size:n,shape:a,className:i?`w-28 justify-center ${s||""}`:s,...l,children:d})}function sd({state:e,stateLabel:t,metric:r,metricFormatter:o,secondaryState:n,layout:a="horizontal",isLoading:i,size:s="sm",shape:l="pill",icon:d,fixedWidth:c,secondaryStateIconOnly:u=false,className:m}){if(i)return jsx(q,{className:twMerge("inline-flex h-6 w-32",m)});let p=r!=null&&o?Xr(r,o):null,g=a==="horizontal",f=o&&!p;return jsxs("div",{className:twMerge("inline-flex items-center",g?"gap-2":"flex-col gap-1",m),children:[(p||f)&&jsx("span",{className:twMerge("font-medium inline-block",p?"text-text-primary":"text-text-secondary",s==="sm"&&"text-xs min-w-12",s==="md"&&"text-sm min-w-14",s==="lg"&&"text-base min-w-16"),children:p||"\u2014"}),jsx(Aa,{state:e,label:t,icon:d,size:s,shape:l,fixedWidth:c}),n&&jsx(Fragment,{children:n==="importing"||n==="exporting"?jsx(id,{state:n,size:s,shape:l,fixedWidth:c,showIcon:u}):jsx(Aa,{state:n,size:s,shape:l,fixedWidth:c})})]})}function yv({value:e,row:t,context:r,metric:o,metricFormatter:n,secondaryState:a,size:i="sm",shape:s="pill",label:l,icon:d,fixedWidth:c=true,align:u="left",compact:m=false,className:p}){let{isLoading:g}=r;if(g){let C={pill:"rounded-full",rounded:"rounded-lg",square:"rounded-sm"}[s],S=o!=null||n!=null;return jsx("div",{className:"flex items-center gap-2",children:S?jsxs(Fragment,{children:[jsx(q,{className:"h-4 w-12"}),jsx(q,{className:`h-6 w-24 ${C}`}),jsx(q,{className:`h-6 w-20 ${C}`})]}):jsx(q,{className:`h-6 w-24 ${C}`})})}if(!e)return jsx("div",{className:ke(u,p),children:jsx("span",{className:"text-text-secondary",children:"\u2014"})});let f=ge(o,t),b=ge(a,t),h=typeof l=="function"?l(e,t):l,v=ke(u,p);return f!=null||n?jsx("div",{className:twMerge(v),children:jsx(sd,{state:e,stateLabel:h,metric:f,metricFormatter:n,secondaryState:b||void 0,size:i,shape:s,icon:d,fixedWidth:c,secondaryStateIconOnly:m,layout:"horizontal"})}):jsx("div",{className:v,children:jsx(Aa,{state:e,label:h,icon:d,size:i,shape:s,fixedWidth:c})})}function Cv({value:e,row:t,context:r,formatter:o,align:n="left",emphasis:a="normal",href:i,linkBehavior:s="hover",className:l,emptyText:d="\u2014",emptyClassName:c="text-text-secondary"}){let{isLoading:u}=r;if(u)return jsx(q,{className:Ft(a)});let m=Ao({value:e,formatter:o,emptyText:d,emptyClassName:c}),p=Gr(a),g=ke(n,twMerge(p,l)),f=jsx("div",{className:g,children:m}),b=ge(i,t);return b?Yo(f,b,t,s):f}var tf=ot__default.memo(({value:e,min:t,max:r,color:o="var(--color-viz-default)",backgroundColor:n="var(--color-background-muted)",colorScale:a,showLabel:i=true,formatLabel:s,height:l=20,minWidth:d=4,segments:c,segmentGap:u=2,barWidth:m,context:p})=>{let g=useMemo(()=>r===t?100:Math.max(0,Math.min(100,(e-t)/(r-t)*100)),[e,t,r]),f=useMemo(()=>o==="auto"&&a?a.type==="diverging"&&a.center!==void 0?ns(e,t,r,a.center,a.scheme):os(e,t,r,a.scheme):o,[o,a,e,t,r]);if(p.isLoading)return jsx("div",{className:"flex items-center gap-2 w-full",style:{height:l},children:jsx("div",{className:"h-full flex-1 animate-pulse bg-border-default rounded"})});if(c&&c>0){let v=`calc((100% - ${u*(c-1)}px) / ${c})`,x=Math.ceil(g/100*c),C={height:l,...m&&{width:typeof m=="number"?`${m}px`:m,flexShrink:0}};return jsxs("div",{className:"flex items-center gap-2 w-full",children:[jsx("div",{className:`flex gap-0.5 ${m?"":"flex-1"}`,style:C,children:Array.from({length:c}).map((S,w)=>{let T=w<x;return jsx("div",{className:"rounded-sm",style:{width:v,backgroundColor:T?f:n==="none"?"transparent":n,marginRight:w<c-1?`${u}px`:0}},w)})}),i&&jsx("span",{className:"text-sm text-text-primary whitespace-nowrap",children:s?s(e):e.toLocaleString()})]})}let b={height:l,backgroundColor:n==="none"?"transparent":n,...m&&{width:typeof m=="number"?`${m}px`:m,flexShrink:0}};return jsxs("div",{className:"flex items-center gap-2 w-full",children:[jsx("div",{className:`relative rounded-sm ${m?"":"flex-1"}`,style:b,children:jsx("div",{className:"absolute left-0 top-0 h-full rounded-sm",style:{width:`${g}%`,minWidth:g>0?d:0,backgroundColor:f}})}),i&&jsx("span",{className:"text-sm text-text-primary whitespace-nowrap",children:s?s(e):e.toLocaleString()})]})});tf.displayName="HorizontalBarCell";function uL(e){return Math.max(1,String(Math.max(1,Math.trunc(e))).length)}function Tv({context:e,startAt:t=1,padTo:r,rowCount:o,align:n="right",className:a}){let{isLoading:i,rowIndex:s}=e;if(i)return jsx(q,{className:Ft("normal")});if(typeof s!="number"||!Number.isFinite(s))return jsx("div",{className:ke(n,"text-text-muted"),children:"\u2014"});let l=s+t,d=r??(o===void 0?void 0:uL(o+t-1)),c=d===void 0?String(l):String(l).padStart(d,"0");return jsx("div",{className:ke(n,twMerge("font-mono text-text-muted tabular-nums",a)),children:jsx("span",{children:c})})}var rf=ot__default.memo(({value:e,data:t,color:r="var(--color-viz-default)",categoryColors:o,context:n,width:a,height:i=40})=>{let s=e||t||[],l=b=>"xValue"in b?b.xValue:b.x,d=b=>"yValue"in b?b.yValue:b.y,c=a||100,u=i,{xScale:m,yScale:p,barWidth:g}=useMemo(()=>{if(s.length===0)return {xScale:scaleTime({range:[0,c],domain:[new Date,new Date]}),yScale:scaleLinear({range:[u,0],domain:[0,1]}),barWidth:2};let b=extent(s,T=>l(T)),h=min(s,T=>d(T))??0,v=max(s,T=>d(T))??0,x=h<0?h:0,C=scaleTime({range:[0,c],domain:b}),S=scaleLinear({range:[u,0],domain:[x,v*1.05]}),w=s.length>1?c/s.length*.8:8;return {xScale:C,yScale:S,barWidth:Math.max(2,w)}},[s,c,u]);if(n.isLoading)return jsx("div",{className:"flex items-center gap-0.5",style:{width:c,height:u},children:Array.from({length:5}).map((b,h)=>jsx("div",{className:"flex-1 animate-pulse bg-border-default rounded"},h))});if(!s||s.length===0)return jsx("div",{className:"flex items-center justify-center text-text-secondary text-xs",style:{width:c,height:u},children:"No data"});let f=p(0);return jsx("svg",{width:c,height:u,children:s.map((b,h)=>{let v=d(b),x=m(l(b)),C=p(v),S=Math.abs(f-C),w=b.category&&o?.[b.category]?o[b.category]:r;return jsx(Bar,{x:x-g/2,y:v>=0?C:f,width:g,height:S,fill:w,rx:1},`bar-${h}`)})})});rf.displayName="MiniBarCell";function Pv({value:e,row:t,context:r,format:o="number",decimals:n=0,prefix:a,suffix:i,emptyText:s="\u2014",align:l="right",emphasis:d="normal",href:c,linkBehavior:u="hover",showPositiveSign:m=false,colorCode:p=false,className:g}){let{isLoading:f}=r;if(f)return jsx(q,{className:Ft(d)});if(e==null||isNaN(Number(e)))return jsx("div",{className:ke(l,"text-text-secondary"),children:s});let b=Number(e),h;switch(o){case "currency":h=new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:n,maximumFractionDigits:n}).format(b);break;case "percent":h=new Intl.NumberFormat("en-US",{style:"percent",minimumFractionDigits:n,maximumFractionDigits:n}).format(b/100);break;case "compact":h=new Intl.NumberFormat("en-US",{notation:"compact",minimumFractionDigits:n>0?1:0,maximumFractionDigits:n}).format(b);break;default:h=new Intl.NumberFormat("en-US",{minimumFractionDigits:n,maximumFractionDigits:n}).format(b);}let x=`${m&&b>0?"+":""}${h}`,C=p?$c(b,true):Gr(d),S=ke(l,twMerge(C,g)),w=jsxs(Fragment,{children:[a&&jsx("span",{className:"text-text-secondary",children:a}),jsx("span",{children:x}),i&&jsx("span",{className:"text-text-secondary",children:i})]}),T=ge(c,t);return T?jsx("div",{className:S,children:Yo(w,T,t,u)}):jsx("div",{className:S,children:w})}var SL={low:"var(--color-feedback-warning-text)",critical:"var(--color-feedback-error-text)"};function nf(e,t){if(t){if(t.critical!==void 0&&e<=t.critical)return "critical";if(t.low!==void 0&&e<=t.low)return "low"}}var af=ot__default.memo(({value:e,showLabel:t=true,color:r="var(--color-viz-categorical-1)",backgroundColor:o="var(--color-background-muted)",height:n=20,segments:a,segmentGap:i=2,colorScale:s,thresholds:l,context:d})=>{let c=useMemo(()=>Math.max(0,Math.min(100,e)),[e]),u=useMemo(()=>nf(c,l),[c,l]),m=useMemo(()=>u?SL[u]:r==="auto"&&s?s.type==="diverging"&&s.center!==void 0?ns(e,0,100,s.center,s.scheme):os(e,0,100,s.scheme):r,[r,s,u,e]);if(d.isLoading)return jsx("div",{className:"flex items-center gap-2",style:{height:n},children:jsx("div",{className:"h-full w-full animate-pulse bg-border-default rounded"})});if(a&&a>0){let g=`calc((100% - ${i*(a-1)}px) / ${a})`,f=Math.ceil(c/100*a);return jsxs("div",{className:"flex items-center gap-2 w-full","data-threshold":u,children:[jsx("div",{className:"flex gap-0.5 flex-1",style:{height:n},children:Array.from({length:a}).map((b,h)=>{let v=h<f,x=m;if(!u&&r==="auto"&&s&&v){let C=(h+1)/a*100;s.type==="diverging"&&s.center!==void 0?x=ns(C,0,100,s.center,s.scheme):x=os(C,0,100,s.scheme);}return jsx("div",{className:"rounded-sm",style:{width:g,backgroundColor:v?x:o==="none"?"transparent":o,marginRight:h<a-1?`${i}px`:0}},h)})}),t&&jsxs("span",{className:"text-sm text-text-primary whitespace-nowrap",children:[c.toFixed(0),"%"]})]})}return jsxs("div",{className:"flex items-center gap-2 w-full","data-threshold":u,children:[jsx("div",{className:"relative flex-1 rounded-sm",style:{height:n,backgroundColor:o==="none"?"transparent":o},children:jsx("div",{className:"absolute left-0 top-0 h-full rounded-sm transition-all duration-300",style:{width:`${c}%`,backgroundColor:m}})}),t&&jsxs("span",{className:"text-sm text-text-primary whitespace-nowrap",children:[c.toFixed(0),"%"]})]})});af.displayName="PercentBarCell";var TL="\u2013",Rv="\u200A";function Mv(e){if(e==null||e==="")return;let t=typeof e=="number"?e:Number(e);return Number.isFinite(t)?t:void 0}function Ev({row:e,context:t,min:r,max:o,decimals:n=0,unit:a,emptyText:i="\u2014",align:s="right",emphasis:l="normal",className:d}){let{isLoading:c}=t;if(c)return jsx(q,{className:Ft(l)});let u=Mv(ge(r,e)),m=Mv(ge(o,e));if(u===void 0&&m===void 0)return jsx("div",{className:ke(s,"text-text-secondary"),children:i});let p=b=>new Intl.NumberFormat("en-US",{minimumFractionDigits:n,maximumFractionDigits:n}).format(b),g=u!==void 0&&m!==void 0?`${p(u)}${Rv}${TL}${Rv}${p(m)}`:p(u!==void 0?u:m),f=ke(s,twMerge("tabular-nums",Gr(l),d));return jsxs("div",{className:f,children:[jsx("span",{children:g}),a&&jsx("span",{className:"text-text-secondary",children:a})]})}function pd({row:e,context:t,isSelected:r=false,onSelect:o,isDisabled:n=false,align:a="center"}){let{isLoading:i}=t;if(i)return jsx("div",{className:ke(a),children:jsx(q,{className:"h-4 w-4 rounded"})});let s=ge(n,e),l=ke(a);return jsx("div",{className:l,children:jsx(So,{isSelected:r,onChange:d=>{o?.(e,d);},isDisabled:s,"aria-label":"Select row"})})}function md({streetAddress:e,city:t,state:r,postalCode:o,layout:n="stacked",size:a="md",href:i,LinkComponent:s,linkVariant:l="unstyled",emphasis:d="normal",isLoading:c=false,showIcon:u=true,className:m,piiEntity:p}){let f={xs:{iconSize:16,iconContainerSize:"w-7 h-7",gap:"gap-1.5",textSize:"text-xs",secondaryTextSize:"text-xs",skeletonIconStacked:28,skeletonIconInline:16,skeletonText:80,skeletonSecondary:60},sm:{iconSize:20,iconContainerSize:"w-8 h-8",gap:"gap-2",textSize:"text-sm",secondaryTextSize:"text-xs",skeletonIconStacked:32,skeletonIconInline:20,skeletonText:96,skeletonSecondary:72},md:{iconSize:24,iconContainerSize:"w-9 h-9",gap:"gap-3",textSize:"text-base",secondaryTextSize:"text-sm",skeletonIconStacked:36,skeletonIconInline:24,skeletonText:128,skeletonSecondary:96},lg:{iconSize:28,iconContainerSize:"w-10 h-10",gap:"gap-3",textSize:"text-lg",secondaryTextSize:"text-base",skeletonIconStacked:40,skeletonIconInline:28,skeletonText:160,skeletonSecondary:120}}[a],h={strong:"font-semibold text-text-primary",high:"font-semibold text-text-primary",normal:"text-text-primary",low:"text-text-secondary"}[d],v=[];t&&v.push(t),r&&o?v.push(`${r} ${o}`):r?v.push(r):o&&v.push(o);let x=v.join(", "),C=({children:w,className:T})=>i?s?jsx(s,{href:i,className:T,children:w}):jsx(St,{href:i,variant:l,className:twMerge("hover:underline",T),asButton:false,children:w}):jsx("span",{className:T,children:w});if(c)return n==="inline"?jsxs("div",{className:twMerge("flex items-center",f.gap,m),children:[u&&jsx(q,{width:f.skeletonIconInline,height:f.skeletonIconInline,className:"flex-shrink-0 rounded"}),jsx(q,{width:f.skeletonText,height:f.skeletonIconInline*.8})]}):jsxs("div",{className:twMerge("flex items-center",f.gap,m),children:[u&&jsx(q,{width:f.skeletonIconStacked,height:f.skeletonIconStacked,className:"flex-shrink-0 rounded"}),jsxs("div",{className:"flex flex-col gap-1",children:[jsx(q,{width:f.skeletonText,height:16}),jsx(q,{width:f.skeletonSecondary,height:12})]})]});if(n==="inline")return jsxs(C,{className:twMerge("flex items-center",f.gap,i&&"hover:bg-background-hover transition-colors",m),children:[u&&jsx(G,{name:"MapPin",size:f.iconSize,className:"text-text-secondary flex-shrink-0"}),jsx("span",{className:twMerge("leading-normal truncate hover:text-text-primary",h,f.textSize,i&&"hover:underline hover:decoration-1 hover:underline-offset-4"),"data-pii-type":p?"address":void 0,"data-pii-entity":p,children:e})]});let S=()=>{if(p){if(t&&r&&o)return "city-state-zip";if(t&&r)return "city-state";if(t)return "city";if(r)return "state";if(o)return "postal-code"}};return jsxs("div",{className:twMerge("flex items-center justify-start",f.gap,m),children:[u&&jsx("div",{className:twMerge("flex-shrink-0 flex items-center justify-center rounded border border-border-muted",f.iconContainerSize),children:jsx(G,{name:"MapPin",size:f.iconSize,className:"text-text-secondary"})}),jsxs("div",{className:"flex flex-col items-start min-w-0",children:[jsx(C,{className:twMerge("leading-normal truncate hover:text-text-primary",h,f.textSize,i&&"hover:underline hover:decoration-1 hover:underline-offset-4"),children:jsx("span",{"data-pii-type":p?"address":void 0,"data-pii-entity":p,children:e})}),x&&jsx("div",{className:twMerge("text-text-secondary leading-normal truncate",f.secondaryTextSize),"data-pii-type":S(),"data-pii-entity":p,children:x})]})]})}function Dv({row:e,context:t,streetAddress:r,city:o,state:n,postalCode:a,layout:i="stacked",size:s="sm",href:l,LinkComponent:d,linkVariant:c="secondary",emphasis:u="normal",align:m="left",className:p,piiEntity:g}){let{isLoading:f}=t,b=ge(r,e),h=ge(o,e),v=ge(n,e),x=ge(a,e),C=ge(l,e),S=ge(g,e),w=ke(m,p);return jsx("div",{className:w,children:jsx(md,{streetAddress:b,city:h,state:v,postalCode:x,layout:i,size:s,href:C,LinkComponent:d,linkVariant:c,emphasis:u,isLoading:f,piiEntity:S})})}var sf=ot__default.memo(({value:e,data:t,type:r="line",color:o="var(--color-viz-default)",strokeWidth:n=2,categoryColors:a,context:i,width:s,height:l=40})=>{let d=e||t||[],c=s||100,u=l,{xScale:m,yScale:p}=useMemo(()=>{if(d.length===0)return {xScale:scaleTime({range:[0,c],domain:[new Date,new Date]}),yScale:scaleLinear({range:[u,0],domain:[0,1]})};let f=extent(d,x=>x.xValue),b=min(d,x=>x.yValue)||0,h=max(d,x=>x.yValue)||0,v=(h-b)*.1||1;return {xScale:scaleTime({range:[0,c],domain:f}),yScale:scaleLinear({range:[u,0],domain:[b-v,h+v]})}},[d,c,u]);if(i.isLoading)return jsx("div",{className:"flex items-center",style:{width:c,height:u},children:jsx("div",{className:"h-1 w-full animate-pulse bg-border-default rounded"})});if(!d||d.length===0)return jsx("div",{className:"flex items-center justify-center text-text-secondary text-xs",style:{width:c,height:u},children:"No data"});let g=a&&d[0]?.category&&a[d[0].category]?a[d[0].category]:o;return jsxs("svg",{width:c,height:u,className:"overflow-visible",children:[(r==="area"||r==="both")&&jsx(AreaClosed,{data:d,x:f=>m(f.xValue),y:f=>p(f.yValue),yScale:p,fill:g,fillOpacity:.15,curve:curveLinear}),(r==="line"||r==="both")&&jsx(LinePath,{data:d,x:f=>m(f.xValue),y:f=>p(f.yValue),stroke:g,strokeWidth:n,strokeLinecap:"round",curve:curveLinear})]})});sf.displayName="SparklineCell";function Bv({value:e,row:t,context:r,prefix:o,suffix:n,emptyText:a="\u2014",href:i,linkBehavior:s="hover",linkVariant:l="secondary",emphasis:d="normal",truncate:c=true,copyable:u=false,align:m="left",className:p,piiType:g,piiEntity:f}){let{isLoading:b}=r;if(b)return jsx(q,{className:Ft(d)});let h=_c(e,a),v=ge(i,t),x=ge(f,t),C=h,S=false,w=false;if(c&&h&&typeof h=="string")if(typeof c=="boolean")w=true;else {let{position:D="end",length:W=16,ellipsis:X="...",tooltip:H=true}=c;if(h.length>W){switch(D){case "start":C=Ll(h,W);break;case "middle":C=ii(h,W);break;case "end":C=Dl(h,W,X);break}S=H;}}let T=g&&x?{"data-pii-type":g,"data-pii-entity":x}:{},N=Object.keys(T).length>0,k=jsx("span",{className:w?"truncate":"",...T,children:C}),R=S?jsx(tr,{content:N?jsx("span",{...T,children:String(h)}):String(h),children:k}):k,A=jsxs(Fragment,{children:[o&&jsx("span",{className:"text-text-secondary",children:o}),R,n&&jsx("span",{className:"text-text-secondary",children:n})]}),M=A;if(u&&h&&h!==a){let D=typeof u=="function"?u(t):String(h);M=jsx(In,{value:D,size:"sm",children:A});}if(v){let D=ke(m,p);return jsx("div",{className:D,children:Yo(M,v,t,s,l,d)})}let B=ke(m,twMerge(Gr(d),p));return jsx("div",{className:B,children:M})}var VL={sm:"sm:hidden",md:"md:hidden",lg:"lg:hidden",xl:"xl:hidden"},OL={sm:"hidden sm:grid",md:"hidden md:grid",lg:"hidden lg:grid",xl:"hidden xl:grid"};function fd(e,t){return t.accessor?typeof t.accessor=="function"?t.accessor(e):e[t.accessor]:null}function gd(e,t,r,o){if(r.cell){let n=r.cell,a=typeof r.cellProps=="function"?r.cellProps(e,t):r.cellProps;return jsx(n,{value:e,row:t,context:o,...a})}return r.render?r.render(e,t,o):e?.toString()??"\u2014"}function bd({row:e,columns:t,density:r,isLoading:o,onClick:n}){let a=t.filter(u=>u.mobile!==false).map(u=>{let m=u.mobile===false?null:u.mobile;return {...u,mobilePriority:m?.priority??2,mobileFormat:m?.format??"secondary",showLabel:m?.label??m?.format==="secondary",icon:m?.icon}}).sort((u,m)=>u.mobilePriority-m.mobilePriority),i=a.filter(u=>u.mobilePriority===1||u.mobileFormat==="primary"),s=a.filter(u=>u.mobilePriority===2&&u.mobileFormat!=="primary"),l=a.filter(u=>u.mobileFormat==="badge"),d={isLoading:!!o,rowIndex:0,columnIndex:0,density:r};return jsxs("div",{className:twMerge("border-b border-border-default bg-background-surface transition-colors",n&&"cursor-pointer hover:bg-background-hover active:bg-background-pressed",{compact:"px-3 py-2",default:"px-4 py-3",relaxed:"px-4 py-4"}[r]),onClick:n,role:n?"button":void 0,tabIndex:n?0:void 0,children:[i.length>0&&jsxs("div",{className:"mb-2 flex items-start justify-between",children:[jsx("div",{className:"flex-1",children:i.map(u=>{let m=fd(e,u);return jsx("div",{className:"font-medium text-text-primary [&>*]:!justify-start [&>*]:!text-left",children:gd(m,e,u,d)},u.id)})}),l.length>0&&jsx("div",{className:"ml-2 flex flex-wrap gap-1",children:l.map(u=>{let m=fd(e,u);return jsx("div",{className:"inline-flex",children:gd(m,e,u,d)},u.id)})})]}),s.length>0&&jsx("div",{className:"space-y-1",children:s.map(u=>{let m=fd(e,u),p=u.showLabel&&u.label;return jsxs("div",{className:"flex items-center text-sm text-text-secondary",children:[u.icon&&jsx(G,{name:u.icon,className:"mr-1.5 h-4 w-4 flex-shrink-0"}),p&&jsxs("span",{className:"mr-1 font-medium",children:[u.label,":"]}),jsx("span",{className:"truncate [&>*]:!justify-start [&>*]:!text-left",children:gd(m,e,u,d)})]},u.id)})})]})}function xd({row:e,columns:t,density:r,isLoading:o,onClick:n}){let a=t.filter(l=>l.mobile!==false),i={isLoading:!!o,rowIndex:0,columnIndex:0,density:r};return jsx("div",{className:twMerge("border-b border-border-default bg-background-surface transition-colors",n&&"cursor-pointer hover:bg-background-hover active:bg-background-pressed",{compact:"px-3 py-2",default:"px-4 py-3",relaxed:"px-4 py-4"}[r]),onClick:n,role:n?"button":void 0,tabIndex:n?0:void 0,children:jsx("div",{className:"space-y-2",children:a.map((l,d)=>{let c=fd(e,l),u=d===0;return jsxs("div",{children:[!u&&jsx("div",{className:"text-xs text-text-secondary",children:l.label}),jsx("div",{className:twMerge(u?"font-medium text-text-primary":"text-sm text-text-primary","[&>*]:!justify-start [&>*]:!text-left"),children:gd(c,e,l,i)})]},l.id)})})})}function Vv(e="md"){return {mobile:VL[e],desktop:OL[e]}}function Ov({density:e}){return jsxs("div",{className:twMerge("border-b border-border-default bg-background-surface",{compact:"px-3 py-2",default:"px-4 py-3",relaxed:"px-4 py-4"}[e]),children:[jsx("div",{className:"mb-2 h-5 w-3/4 animate-pulse rounded bg-background-muted"}),jsxs("div",{className:"space-y-1",children:[jsx("div",{className:"h-4 w-1/2 animate-pulse rounded bg-background-muted"}),jsx("div",{className:"h-4 w-2/3 animate-pulse rounded bg-background-muted"})]})]})}var yd=10,lf=200;function zL(e){return e===void 0||!Number.isInteger(e)||e<=0?yd:Math.min(e,lf)}function vd(e,t,r){let o=typeof e=="boolean"?{}:e??{},n=zL(o.pageSize),a=o.totalRows??t,i=Math.max(1,Math.ceil(a/n)),s=Math.min(Math.max(Math.trunc(r)||0,0),i-1),l=s*n,d=Math.min(l+n,o.totalRows!==void 0?t:a),c=Math.max(0,d-(o.totalRows!==void 0?0:l));return {page:s,pageCount:i,start:l,end:d,from:a===0?0:l+1,to:a===0?0:l+c,total:a}}var HL={compact:"px-3 py-1.5",default:"px-3 py-2",relaxed:"px-4 py-3"};function Cd({page:e,pageCount:t,from:r,to:o,total:n,density:a,onPageChange:i,label:s="Pagination"}){let l=e<=0,d=e>=t-1;return jsxs("nav",{"data-testid":"data-table-pagination","aria-label":s,className:twMerge("flex items-center gap-3 border-t border-border-default","justify-between @sm:justify-start",HL[a]),children:[jsx(te,{size:"sm",variant:"ghost",icon:"CaretLeft",isDisabled:l,onPress:()=>i(e-1),"aria-label":"Previous page",className:"order-1 @sm:order-2",children:jsx("span",{className:"@sm:hidden",children:"Previous"})}),jsx("p",{className:twMerge("m-0 flex min-w-0 items-baseline gap-2 text-body-sm text-text-secondary","order-2 @sm:order-1 @sm:grow"),children:jsx("span",{className:"truncate tabular-nums",children:n===0?"No rows":`Showing ${r}\u2013${o} of ${n.toLocaleString()}`})}),jsx(te,{size:"sm",variant:"ghost",icon:"CaretRight",iconPosition:"right",isDisabled:d,onPress:()=>i(e+1),"aria-label":"Next page",className:"order-3",children:jsx("span",{className:"@sm:hidden",children:"Next"})}),jsx("span",{"aria-live":"polite","aria-atomic":"true",className:"sr-only",children:n===0?"No rows":`Page ${e+1} of ${t}, showing rows ${r} to ${o} of ${n}`})]})}var $L={compact:"py-1.5 px-3 text-sm",default:"py-3 px-4 text-sm",relaxed:"py-4 px-4 text-base"},eD={left:"text-left justify-start",center:"text-center justify-center",right:"text-right justify-end"};function tD(e){let t={};return e.width!==void 0&&(t.width=typeof e.width=="number"?`${e.width}px`:e.width),e.minWidth!==void 0&&(t.minWidth=typeof e.minWidth=="number"?`${e.minWidth}px`:e.minWidth),e.maxWidth!==void 0&&(t.maxWidth=typeof e.maxWidth=="number"?`${e.maxWidth}px`:e.maxWidth),e.flex!==void 0&&(t.flex=`${e.flex} 1 0`),t}function rD({column:e,sortConfig:t,onSort:r,stickyHeader:o,stickyFirstColumn:n,isFirstColumn:a,density:i="default",isLoading:s=false,headerContent:l,sortNote:d}){let c=e.reorderable!==false,{attributes:u,listeners:m,setNodeRef:p,transform:g,transition:f,isDragging:b}=useSortable({id:e.id,disabled:!c||s}),{role:h,"aria-pressed":v,...x}=u,C=t?.columnId===e.id,S=C?t.direction:null,w=n&&a,T=C?d:void 0,N={...tD(e),transform:CSS.Transform.toString(g),transition:f,opacity:b?.8:1,zIndex:b?50:void 0};return jsx("div",{ref:p,className:twMerge("flex items-center border-b border-border-default bg-background-surface",e.sortable?"gap-2":"gap-1",$L[i],eD[e.align||"left"],o&&"sticky top-0 z-10",w&&"sticky left-0 z-20 shadow-[2px_0_4px_-2px_rgba(0,0,0,0.1)]",o&&w&&"z-30",e.sortable&&!s&&"hover:bg-background-hover",s&&"cursor-not-allowed opacity-60",C?"font-bold text-text-primary":"font-medium text-text-secondary",b&&"bg-background-hover"),style:N,...x,...m,role:"columnheader","aria-sort":C?S==="asc"?"ascending":"descending":"none","aria-disabled":s,title:T,"data-sort-note":T,children:s?jsx(q,{className:"h-4 w-24"}):jsxs(Fragment,{children:[l??jsx("span",{className:twMerge("flex-1 truncate",e.sortable&&"cursor-pointer"),onClick:()=>!s&&e.sortable&&r(e.id),children:e.label}),T&&jsx("span",{className:"sr-only",children:T}),e.sortable?jsx("button",{type:"button",className:"flex flex-shrink-0 cursor-pointer",onClick:()=>!s&&r(e.id),"aria-label":`Sort by ${e.label}`,children:C?jsx(G,{name:S==="asc"?"CaretUp":"CaretDown",size:14,weight:T?"regular":"bold",className:T?"text-text-secondary opacity-40":"text-text-primary"}):jsx(G,{name:"CaretUpDown",size:12,className:"text-text-secondary opacity-40"})}):C?jsx("span",{className:"flex flex-shrink-0",children:jsx(G,{name:S==="asc"?"CaretUp":"CaretDown",size:14,weight:T?"regular":"bold",className:T?"text-text-secondary opacity-40":"text-text-primary"})}):null]})})}function Wv({columns:e,columnOrder:t,onColumnOrderChange:r,sortConfig:o,onSort:n,stickyHeader:a,stickyFirstColumn:i,density:s="default",isLoading:l=false,renderHeaderContent:d,sortNote:c}){let u=useSensors(useSensor(PointerSensor,{activationConstraint:{distance:5}}),useSensor(KeyboardSensor,{coordinateGetter:sortableKeyboardCoordinates})),m=new Map(e.map(f=>[f.id,f])),p=f=>{let{active:b,over:h}=f;if(h&&b.id!==h.id){let v=t.indexOf(b.id),x=t.indexOf(h.id);if(m.get(h.id)?.reorderable===false)return;let S=0;for(let k=0;k<t.length&&m.get(t[k])?.reorderable===false;k++)S=k+1;if(x<S)return;let w=Math.min(v,x),T=Math.max(v,x);for(let k=w;k<=T;k++){if(k===v)continue;if(m.get(t[k])?.reorderable===false)return}let N=arrayMove(t,v,x);r(N);}},g=t.map(f=>m.get(f)).filter(f=>f!==void 0);return jsx(DndContext,{sensors:u,collisionDetection:closestCenter,onDragEnd:p,children:jsx(SortableContext,{items:t,strategy:horizontalListSortingStrategy,children:jsx("div",{className:"contents",role:"rowgroup",children:g.map((f,b)=>jsx(rD,{column:f,sortConfig:o,onSort:n,stickyHeader:a,stickyFirstColumn:i,isFirstColumn:b===0,density:s,isLoading:l,headerContent:d?.(f),sortNote:c},f.id))})})})}var Sd="__select",sD=new Set,cf={compact:"py-1.5 px-3 text-sm",default:"py-3 px-4 text-sm",relaxed:"py-4 px-4 text-base"},df={left:"text-left justify-start",center:"text-center justify-center",right:"text-right justify-end"},lD={full:"w-full",auto:"w-auto inline-block",contained:"w-full max-w-6xl mx-auto"},cD={auto:"table-auto",fixed:"table-fixed",responsive:"table-auto"};function Kv(e){if(typeof e=="number")return e;let t=/^(\d+(?:\.\d+)?)px$/.exec(e.trim());return t?Number(t[1]):0}function uf(e){let t={};return e.width!==void 0&&(t.width=typeof e.width=="number"?`${e.width}px`:e.width),e.minWidth!==void 0&&(t.minWidth=typeof e.minWidth=="number"?`${e.minWidth}px`:e.minWidth),e.maxWidth!==void 0&&(t.maxWidth=typeof e.maxWidth=="number"?`${e.maxWidth}px`:e.maxWidth),e.flex!==void 0&&(t.flex=`${e.flex} 1 0`),t}function dD(e,t){return t.accessor?typeof t.accessor=="function"?t.accessor(e):e[t.accessor]:null}function uD({column:e,sortConfig:t,onSort:r,stickyHeader:o,stickyFirstColumn:n,isFirstColumn:a,density:i="default",isLoading:s=false,headerContent:l,sortNote:d}){let c=t?.columnId===e.id,u=c?t.direction:null,m=n&&a,p=c?d:void 0;return jsx("div",{className:twMerge("flex items-center border-b border-border-default bg-background-surface",e.sortable?"gap-2":"gap-1",cf[i],df[e.align||"left"],o&&"sticky top-0 z-10",m&&"sticky left-0 z-20 shadow-[2px_0_4px_-2px_rgba(0,0,0,0.1)]",o&&m&&"z-30",e.sortable&&!s&&"cursor-pointer hover:bg-background-hover",s&&"cursor-not-allowed opacity-60",c?"font-bold text-text-primary":"font-medium text-text-secondary"),onClick:()=>!s&&e.sortable&&r(e.id),role:"columnheader","aria-sort":c?u==="asc"?"ascending":"descending":"none","aria-disabled":s,title:p,"data-sort-note":p,style:uf(e),children:s?jsx(q,{className:"h-4 w-24"}):jsxs(Fragment,{children:[l??jsx("span",{className:"truncate",children:e.label}),e.headerTooltip&&jsx(tr,{content:e.headerTooltip,children:jsx(te,{variant:"ghost","aria-label":`About ${e.label}`,onClick:g=>g.stopPropagation(),className:"h-auto min-h-0 flex-shrink-0 p-0 text-text-tertiary hover:text-text-secondary",children:jsx(G,{name:"Info",size:12,"aria-hidden":true})})}),p&&jsx("span",{className:"sr-only",children:p}),(e.sortable||c)&&jsx("div",{className:"flex flex-shrink-0",children:c?jsx(G,{name:u==="asc"?"CaretUp":"CaretDown",size:14,weight:p?"regular":"bold",className:p?"text-text-secondary opacity-40":"text-text-primary"}):jsx(G,{name:"CaretUpDown",size:12,className:"text-text-secondary opacity-40"})})]})})}function pD({column:e,row:t,rowIndex:r,columnIndex:o,isHovered:n,isSelected:a,density:i="default",className:s,stickyFirstColumn:l}){let d=l&&o===0,c=dD(t,e),u={isLoading:false,isHovered:n,...a===void 0?{}:{isSelected:a},rowIndex:r,columnIndex:o,density:i},m;if(e.cell){let p=e.cell,g=typeof e.cellProps=="function"?e.cellProps(c,t):e.cellProps;m=jsx(p,{value:c,row:t,context:u,...g});}else e.render?m=e.render(c,t,u):m=jsx("span",{className:"truncate",children:c?.toString()??""});if(e.popover){let p=e.popover,g,f="top",b=false,h="hover";typeof p=="string"?g=p:typeof p=="function"?g=p(c,t):(g=typeof p.content=="function"?p.content(c,t):p.content,f=p.placement||"top",b=p.showArrow??false,h=p.trigger||"hover"),m=jsxs(DialogTrigger,{...h==="hover"?{trigger:"longPress"}:{},children:[jsx("div",{className:"cursor-help",children:m}),jsx(Et,{placement:f,showArrow:b,children:jsx("div",{className:"p-2",children:g})})]});}return jsx("div",{className:twMerge("flex items-center border-b border-border-default bg-background-surface",e.noCellPadding?"":cf[i],df[e.align||"left"],d&&"sticky left-0 z-10 shadow-[2px_0_4px_-2px_rgba(0,0,0,0.1)]",s),role:"cell",style:uf(e),children:m})}function mD({column:e,rowIndex:t,columnIndex:r,density:o="default",stickyFirstColumn:n}){let a=n&&r===0,i={isLoading:true,rowIndex:t,columnIndex:r,density:o},s;if(e.cell){let l=e.cell,d=typeof e.cellProps=="function"?e.cellProps(null,{}):e.cellProps;s=jsx(l,{value:null,row:{},context:i,...d});}else e.render?s=e.render(null,{},i):s=jsx(q,{className:"h-4 w-full max-w-[200px]"});return jsx("div",{className:twMerge("flex items-center border-b border-border-default bg-background-surface",e.noCellPadding?"":cf[o],df[e.align||"left"],a&&"sticky left-0 z-10 shadow-[2px_0_4px_-2px_rgba(0,0,0,0.1)]"),role:"cell",style:uf(e),children:s})}function fD(e,t){let r=new Set(["BUTTON","A","INPUT","SELECT","TEXTAREA"]),o=new Set(["button","link","checkbox","switch","menuitem","option"]),n=e;for(;n&&n!==t;){if(r.has(n.tagName))return true;let a=n.getAttribute("role");if(a&&o.has(a))return true;n=n.parentElement;}return false}function Yv({columns:e,row:t,rowIndex:r,density:o="default",onClick:n,stickyFirstColumn:a,isSelected:i}){let[s,l]=useState(false),d=useCallback(c=>{if(!n)return;let u=c.target,m=c.currentTarget;fD(u,m)||n(t);},[n,t]);return jsx("div",{className:twMerge("contents group",n&&"cursor-pointer"),role:"row","aria-selected":i===void 0?void 0:i,onClick:d,onMouseEnter:()=>l(true),onMouseLeave:()=>l(false),children:e.map((c,u)=>jsx(pD,{column:c,row:t,rowIndex:r,columnIndex:u,isHovered:s,isSelected:i,density:o,className:twMerge(n?"group-hover:bg-background-hover":"",i&&"bg-background-selected"),stickyFirstColumn:a},c.id))})}function gD({columns:e,rowIndex:t,density:r="default",stickyFirstColumn:o}){return jsx("div",{className:"contents",role:"row",children:e.map((n,a)=>jsx(mD,{column:n,rowIndex:t,columnIndex:a,density:r,stickyFirstColumn:o},n.id))})}function Xv({columns:e,data:t,className:r,density:o="default",width:n="full",height:a,maxHeight:i,layout:s="auto",mobileRenderer:l="auto",customMobileRowRender:d,mobileBreakpoint:c="md",isLoading:u=false,loadingState:m,loadingRowCount:p=5,onLoadMore:g,hasMore:f=false,enableVirtualization:b,estimatedRowHeight:h,loadingIndicator:v,stickyHeader:x=false,stickyFirstColumn:C=false,onRowClick:S,getRowId:w,selectedRowIds:T,onSelectionChange:N,selectionMode:k="multi",hideHeader:R=false,sortConfig:A,onSort:M,sortNote:B,"aria-label":D,enableColumnReorder:W=false,columnOrder:X,onColumnOrderChange:H,pagination:I}){let F=I!==void 0&&I!==false,z=typeof I=="object"?I:void 0,U=z?.page,K=U!==void 0,[O,V]=useState(0),L=vd(I,t.length,K?U:O),y=useCallback(ne=>{let Se=Math.min(Math.max(ne,0),L.pageCount-1);K||V(Se),z?.onPageChange?.(Se);},[K,z,L.pageCount]),E=useMemo(()=>!F||z?.totalRows!==void 0?t:t.slice(L.start,L.end),[t,F,z?.totalRows,L.start,L.end]);useEffect(()=>{K||!F||O!==L.page&&V(L.page);},[K,F,O,L.page]);let P=N!==void 0,Y=T??sD,$=useCallback((ne,Se)=>{if(w)return w(ne);let ce=ne.id;return typeof ce=="string"&&ce.length>0?ce:typeof ce=="number"&&Number.isFinite(ce)?String(ce):`row-${Se}`},[w]),oe=useMemo(()=>E.map((ne,Se)=>$(ne,Se)),[E,$]),re=useCallback((ne,Se)=>{if(!N)return;if(k==="single"){N(Se?new Set([ne]):new Set);return}let ce=new Set(Y);Se?ce.add(ne):ce.delete(ne),N(ce);},[N,Y,k]),_=oe.filter(ne=>Y.has(ne)).length,he=oe.length>0&&_===oe.length,me=_>0&&!he,ue=useCallback(ne=>{if(!N)return;let Se=new Set(Y);for(let ce of oe)ne?Se.add(ce):Se.delete(ce);N(Se);},[N,oe,Y]),ie=useMemo(()=>P?[{id:Sd,label:"",width:44,align:"center",sortable:false,reorderable:false,exportable:false,mobile:false,render:(Se,ce,ct)=>{let yr=$(ce,ct.rowIndex);return jsx(pd,{value:void 0,row:ce,context:ct,isSelected:Y.has(yr),onSelect:(yo,vo)=>re(yr,vo)})}},...e]:e,[e,P,Y,$,re]),fe=P&&k==="multi"?jsx(So,{isSelected:he,isIndeterminate:me,onChange:ne=>ue(ne),isDisabled:oe.length===0,"aria-label":he?"Deselect all rows on this page":"Select all rows on this page"}):void 0,Te=useCallback(ne=>ne.id===Sd?fe:void 0,[fe]),[Ye,yt]=useState(null),Qt=A!==void 0,Ze=Qt?A:Ye,fr=useRef(null),lr=useMemo(()=>ie.map(ne=>ne.id),[ie]),[Ce,Vt]=useState(lr),ee=X!==void 0,Be=ee?X:Ce;useEffect(()=>{ee||Vt(ne=>{let Se=ie.map(vo=>vo.id),ce=new Set(Se),ct=new Set(ne),yr=ne.filter(vo=>ce.has(vo)),yo=Se.filter(vo=>!ct.has(vo));return [...yr,...yo]});},[ie,ee]);let Ve=useCallback(ne=>{ee||Vt(ne),H?.(ne);},[ee,H]),nt=useMemo(()=>{if(!W&&!X)return ie;let ne=new Map(ie.map(ct=>[ct.id,ct])),Se=Be.map(ct=>ne.get(ct)).filter(ct=>ct!==void 0),ce=ne.get(Sd);return ce&&!Se.some(ct=>ct.id===Sd)?[ce,...Se]:Se},[ie,Be,W,X]),wt=En({items:E,onLoadMore:g,hasMore:f,isLoading:u,loadingState:m,enableVirtualization:b,estimatedItemSize:h||(o==="compact"?40:o==="relaxed"?60:48),overscan:5}),Xt=g||b?wt:null,Q=Xt?.scrollRef??fr,{loadMoreRef:j,virtualizer:pe,virtualItems:ae,isLoadingMore:Ne,computedLoadingState:Qe}=Xt||{},{gridTemplateColumns:Ue,totalMinWidth:cr}=useMemo(()=>{let ne=0;return {gridTemplateColumns:nt.map(ce=>{if(ce.minWidth?ne+=Kv(ce.minWidth):ce.width&&(ne+=Kv(ce.width)),ce.width)return typeof ce.width=="number"?`${ce.width}px`:ce.width;if(ce.flex)return `${ce.flex}fr`;if(ce.minWidth&&ce.maxWidth){let ct=typeof ce.minWidth=="number"?`${ce.minWidth}px`:ce.minWidth,yr=typeof ce.maxWidth=="number"?`${ce.maxWidth}px`:ce.maxWidth;return `minmax(${ct}, ${yr})`}return ce.minWidth?`minmax(${typeof ce.minWidth=="number"?`${ce.minWidth}px`:ce.minWidth}, 1fr)`:ce.maxWidth?`minmax(0, ${typeof ce.maxWidth=="number"?`${ce.maxWidth}px`:ce.maxWidth})`:"1fr"}).join(" "),totalMinWidth:ne}},[nt]),Z=useCallback(ne=>{if(!ie.find(ct=>ct.id===ne)?.sortable)return;let ce;Ze?.columnId===ne?ce={columnId:ne,direction:Ze.direction==="asc"?"desc":"asc"}:ce={columnId:ne,direction:"asc"},Qt||yt(ce),M?.(ce);},[ie,Ze,M,Qt]),le=Qe==="loading"||u&&E.length===0,Ae=F&&(z?.alwaysShow||L.pageCount>1)&&!u&&!le,Oe=Ae&&a!==void 0,it={};a?(Oe?(it.flex="1 1 auto",it.minHeight=0):it.height=typeof a=="number"?`${a}px`:a,it.overflowY="auto"):i?(it.maxHeight=typeof i=="number"?`${i}px`:i,it.overflowY="auto"):g&&(it.height="600px",it.overflowY="auto"),g&&(it.overflowX="auto");let Tt=twMerge(lD[n],!g&&(s==="responsive"?"overflow-x-auto scrollbar-visible":"overflow-auto scrollbar-visible"),r),Ot=Vv(c),tt=l!=="none",xr=(ne,Se)=>tt?l==="custom"&&d?d(ne,Se):jsx(l==="cards"?xd:bd,{row:ne,columns:nt,density:o,isLoading:u,onClick:S?()=>S(ne):void 0}):null,gr=pe?ae?.map(ne=>({virtualItem:ne,row:E[ne.index],index:ne.index}))||[]:E.map((ne,Se)=>({row:ne,index:Se,virtualItem:null})),xo=jsxs("div",{ref:Q,className:Tt,style:{...it,position:pe?"relative":void 0},children:[jsxs("div",{className:twMerge("grid border-separate border-spacing-0",cD[s],n==="auto"?"inline-grid w-auto":"w-full",tt&&Ot.desktop),role:"table","aria-label":D,style:{gridTemplateColumns:Ue,minWidth:cr>0?`${cr}px`:void 0},children:[!R&&(W?jsx(Wv,{columns:ie,columnOrder:Be,onColumnOrderChange:Ve,sortConfig:Ze,onSort:Z,stickyHeader:x,stickyFirstColumn:C,density:o,isLoading:le,renderHeaderContent:Te,sortNote:B}):jsx("div",{className:"contents",role:"rowgroup",children:nt.map((ne,Se)=>jsx(uD,{column:ne,sortConfig:Ze,onSort:Z,stickyHeader:x,stickyFirstColumn:C,isFirstColumn:Se===0,density:o,isLoading:le,headerContent:Te(ne),sortNote:B},ne.id))})),pe&&!le?jsx("div",{className:"col-span-full",style:{gridColumn:"1 / -1",height:`${pe.getTotalSize()}px`,position:"relative"},role:"rowgroup",children:E.length>0?jsxs(Fragment,{children:[gr.map(({row:ne,index:Se,virtualItem:ce})=>{if(!ne||!ce)return null;let ct=w?w(ne):`row-${Se}`;return jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",display:"grid",gridTemplateColumns:Ue,transform:`translateY(${ce.start}px)`},"data-index":ce.index,ref:pe.measureElement,children:jsx(Yv,{columns:nt,row:ne,rowIndex:Se,density:o,onClick:S,stickyFirstColumn:C,isSelected:P?Y.has($(ne,Se)):void 0})},ct)}),Ne&&jsx("div",{style:{position:"absolute",top:`${pe.getTotalSize()}px`,left:0,width:"100%"},children:v||jsx(io,{state:"loading-more"})})]}):jsx("div",{className:"py-12 text-center text-text-secondary",children:"No data available"})}):jsx("div",{className:"contents",role:"rowgroup",children:le?Array.from({length:p}).map((ne,Se)=>jsx(gD,{columns:nt,rowIndex:Se,density:o,stickyFirstColumn:C},`loading-${Se}`)):E.length>0?jsxs(Fragment,{children:[gr.map(({row:ne,index:Se})=>{if(!ne)return null;let ce=w?w(ne):`row-${Se}`;return jsx(Yv,{columns:nt,row:ne,rowIndex:Se,density:o,onClick:S,stickyFirstColumn:C,isSelected:P?Y.has($(ne,Se)):void 0},ce)}),Ne&&jsx("div",{className:"col-span-full",style:{gridColumn:"1 / -1"},children:v||jsx(io,{state:"loading-more"})})]}):jsx("div",{className:"col-span-full py-12 text-center text-text-secondary",role:"row",children:jsx("div",{role:"cell",children:"No data available"})})})]}),tt&&jsx("div",{className:Ot.mobile,children:le?Array.from({length:p}).map((ne,Se)=>jsx(Ov,{density:o},`mobile-loading-${Se}`)):E.length>0?jsxs(Fragment,{children:[gr.map(({row:ne,index:Se})=>{if(!ne)return null;let ce=w?w(ne):`mobile-row-${Se}`;return jsx("div",{className:"border-b border-border-default last:border-b-0",children:xr(ne,Se)},ce)}),Ne&&(v||jsx(io,{state:"loading-more"}))]}):jsx("div",{className:"py-12 text-center text-text-secondary",children:"No data available"})}),g&&f&&!le&&(pe?jsx("div",{ref:j,style:{position:"absolute",top:`${pe.getTotalSize()}px`,left:0,width:"100%",height:1}}):jsx("div",{ref:j,className:"h-px w-full"}))]});return Ae?jsxs("div",{className:"@container flex flex-col",style:Oe?{height:typeof a=="number"?`${a}px`:a,minHeight:0}:void 0,children:[xo,jsx(Cd,{...L,density:o,onPageChange:y,...D?{label:`${D} pagination`}:{}})]}):xo}function jv({status:e,alertCount:t,showCount:r=false,isLoading:o,size:n="sm",shape:a="pill",...i}){if(o)return jsx(q,{className:"inline-flex h-6 w-20"});let s={healthy:"success",warning:"warning",error:"error",unknown:"neutral"},l={healthy:"Healthy",warning:"Warning",error:"Error",unknown:"Unknown"},d=e==="warning"||e==="error",c=r&&t?`${l[e]} (${t})`:l[e];return jsx(kt,{variant:s[e],size:n,shape:a,dot:d,dotPulse:d,...i,children:c})}var bD={battery:"BatteryHigh",charger:"ChargingStation",thermostat:"ThermometerSimple",inverter:"Power",vehicle:"Car",water_heater:"DropHalfBottom",meter:"Gauge",sensor:Gs("sensor"),gateway:"WifiHigh",other:"Cube",unknown:"Question"},xD={battery:"Battery",charger:"Charger",thermostat:"Thermostat",inverter:"Inverter",vehicle:"Vehicle",water_heater:"Water Heater",meter:"Meter",sensor:"Sensor",gateway:"Gateway",other:"Other",unknown:"Unknown"};function Zv({deviceType:e,iconName:t,size:r="md",showLabel:o=false,className:n}){let a=t||(e?bD[e]:"Question"),i=e?xD[e]:void 0;return jsxs("div",{className:twMerge("inline-flex items-center",o?"flex-col gap-1":"gap-0",n),children:[jsx(G,{name:a,size:r}),o&&i&&jsx("span",{className:"text-xs text-text-secondary",children:i})]})}function Ks({children:e,title:t,headerContent:r,titleAlign:o="left",hideCloseIcon:n=false,hasBackArrow:a=false,onBack:i,isOpen:s,slideInFrom:l="right",transparentOverlay:d=false,onClose:c,className:u,primaryAction:m,secondaryAction:p,tertiaryAction:g,footerContent:f,contentPadding:b=true,maxWidth:h="400px"}){if(!s)return null;let v=t||r,x=m||p||g||f;return jsx(Co,{children:jsx(Yr,{isOpen:s,onOpenChange:C=>!C&&c?.(),isDismissable:true,transparent:d,children:jsx(Modal,{className:"outline-none focus:outline-none focus-visible:outline-none ring-0 focus:ring-0 focus-visible:ring-0",children:jsxs(Dialog,{className:twMerge("fixed top-0 bottom-0 flex flex-col bg-background-surface shadow-xl overflow-hidden",l==="right"?"right-0":"left-0",l==="right"?"animate-in slide-in-from-right duration-300 ease-out":"animate-in slide-in-from-left duration-300 ease-out","data-[exiting]:animate-out",l==="right"?"data-[exiting]:slide-out-to-right":"data-[exiting]:slide-out-to-left","data-[exiting]:duration-200 data-[exiting]:ease-in","outline-none focus-visible:outline focus-visible:outline-2 focus-visible:outline-action-default focus-visible:outline-offset-0",u),style:{maxWidth:h,width:"100%"},children:[v&&(a&&i?jsx(Cr,{title:t,headerContent:r,titleAlign:o,hideCloseIcon:n,hasBackArrow:true,onBack:i,onClose:c}):jsx(Cr,{title:t,headerContent:r,titleAlign:o,hideCloseIcon:n,onClose:c})),jsx("div",{className:twMerge("flex-1 overflow-y-auto overscroll-contain",b?"px-6 py-6":"p-0"),children:e}),x&&jsx(Pn,{primaryAction:m,secondaryAction:p,tertiaryAction:g,footerContent:f})]})})})})}Ks.displayName="Drawer";function _v({status:e,programName:t,isLoading:r,size:o="sm",shape:n="pill",...a}){if(r)return jsx(q,{className:"inline-flex h-6 w-20"});let i={enrolled:"success",eligible:"info",pending:"warning",not_eligible:"neutral",opted_out:"neutral"},s={enrolled:"Enrolled",eligible:"Eligible",pending:"Pending",not_eligible:"Not Eligible",opted_out:"Opted Out"},l=jsx(kt,{variant:i[e],size:o,shape:n,...a,children:s[e]});return t?jsx(tr,{content:t,children:l}):l}function eC({value:e,onChange:t,onUrlChange:r,accept:o="image/*",maxSize:n,isDisabled:a=false,onUpload:i,className:s,showPreview:l=true,placeholder:d="Drop files here or click to browse"}){let[c,u]=useState(false),[m,p]=useState(false),[g,f]=useState(null),[b,h]=useState(e),v=useRef(null),x=async w=>{if(f(null),n&&w.size>n){f(`File size must be less than ${(n/1024/1024).toFixed(2)}MB`);return}if(l&&w.type.startsWith("image/")){let T=new FileReader;T.onloadend=()=>{h(T.result);},T.readAsDataURL(w);}if(i){p(true);try{let T=await i(w);h(T),r?.(T);}catch(T){f("Failed to upload file"),console.error("Upload error:",T);}finally{p(false);}}t?.(w,b);},C=async w=>{try{let T=w.items;if(T.length>0){let N=T[0];if(N.kind==="file"){let k=await N.getFile();k&&x(k);}}}catch(T){f("Failed to upload file"),console.error("Upload error:",T);}finally{u(false);}},S=()=>{h(void 0),f(null),t?.(null),r?.(""),v.current&&(v.current.value="");};return jsxs("div",{className:twMerge("w-full",s),children:[jsxs(DropZone,{className:twMerge("relative flex min-h-[200px] w-full flex-col items-center justify-center rounded-lg border-2 border-dashed transition-colors",c?"border-action-brand bg-action-brand/5":"border-border-muted hover:border-border-default",a&&"pointer-events-none opacity-50",g&&"border-feedback-error-border bg-feedback-error-background/50"),onDrop:C,onDropEnter:()=>u(true),onDropExit:()=>u(false),children:[b?jsxs("div",{className:"relative flex h-full w-full items-center justify-center p-4",children:[l&&(b.startsWith("data:image")||b.startsWith("http"))?jsx("img",{src:b,alt:"Preview",className:"max-h-48 max-w-full rounded-md object-contain"}):jsxs("div",{className:"flex flex-col items-center gap-2",children:[jsx(Image$1,{className:"h-12 w-12 text-text-secondary"}),jsx("span",{className:"text-sm text-text-secondary",children:"File uploaded"})]}),!a&&jsx(te,{variant:"icon",size:"sm",onPress:S,className:"absolute right-2 top-2 bg-background-surface shadow-md",children:jsx(X,{className:"h-4 w-4"})})]}):jsxs("div",{className:"flex flex-col items-center gap-4 p-6",children:[jsx(Upload,{className:"h-12 w-12 text-text-secondary"}),jsxs("div",{className:"text-center",children:[jsx("p",{className:"text-sm text-text-primary",children:d}),jsx("p",{className:"mt-1 text-xs text-text-secondary",children:o==="image/*"?"PNG, JPG, GIF up to 10MB":`Accepts ${o}`})]}),jsx(FileTrigger,{acceptedFileTypes:o.split(","),onSelect:w=>{let T=Array.from(w||[]);T.length>0&&x(T[0]);},children:jsx(te,{variant:"secondary",size:"sm",isDisabled:a,children:"Choose File"})})]}),m&&jsx("div",{className:"absolute inset-0 flex items-center justify-center rounded-lg bg-background-surface/80",children:jsxs("div",{className:"flex flex-col items-center gap-2",children:[jsx("div",{className:"h-8 w-8 animate-spin rounded-full border-2 border-action-brand border-t-transparent"}),jsx("span",{className:"text-sm text-text-secondary",children:"Uploading..."})]})})]}),g&&jsx("p",{className:"mt-2 text-sm text-feedback-error-text",children:g})]})}function rC({version:e,isLatest:t,updateAvailable:r,isLoading:o,size:n="sm",shape:a="rounded",...i}){if(o)return jsx(q,{className:"inline-flex h-6 w-16"});let s="neutral",l=e;return t?s="success":r&&(s="warning",l=`${e} (Update)`),jsx(kt,{variant:s,size:n,shape:a,...i,children:l})}function Ii(e){return jsx(Form,{validationBehavior:"aria",...e,className:twMerge("flex flex-col gap-6",e.className)})}function nC({placeholder:e="Search...",value:t,onChange:r,isOpen:o,onOpenChange:n,trigger:a,children:i,showShortcutHint:s=true,showInput:l=true,className:d}){let[c,u]=useState(false),m=Pr("(max-width: 767px)"),p=o!==void 0?o:c,g=useCallback(v=>{n?n(v):u(v);},[n]);useEffect(()=>{let v=x=>{(x.metaKey||x.ctrlKey)&&x.key==="k"&&(x.preventDefault(),g(!p)),x.key==="Escape"&&p&&g(false);};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[p,g]);let f=useCallback(v=>{r?.(v);},[r]),b=jsxs("button",{type:"button",className:"flex items-center gap-2 px-3 py-2 text-sm text-text-secondary hover:text-text-primary hover:bg-background-hover rounded-md transition-colors","aria-label":"Open search",children:[jsx(G,{name:"MagnifyingGlass",size:18}),!m&&s&&jsxs("span",{className:"hidden md:flex items-center gap-1 text-xs",children:[jsx("kbd",{className:"px-1.5 py-0.5 bg-background-muted border border-border-muted rounded text-xs",children:navigator.platform.includes("Mac")?"\u2318":"Ctrl"}),jsx("kbd",{className:"px-1.5 py-0.5 bg-background-muted border border-border-muted rounded text-xs",children:"K"})]})]}),h=a===null||isValidElement(a)&&a.type===Fragment$1&&!a.props.children;return m?jsxs(Fragment,{children:[!h&&(a?jsx("button",{type:"button",onClick:()=>g(true),className:"appearance-none bg-transparent border-none p-0 cursor-pointer",children:a}):jsx("button",{type:"button",onClick:()=>g(true),className:"appearance-none bg-transparent border-none p-0 cursor-pointer",children:b})),jsx(Lt,{isOpen:p,onClose:()=>g(false),hideCloseIcon:false,contentPadding:false,maxHeight:"90vh",children:jsxs("div",{className:"flex flex-col h-full",children:[l&&jsx("div",{className:"p-4 border-b border-border-muted flex-shrink-0",children:jsx(fo,{value:t,onChange:f,placeholder:e,showSearchIcon:true,isClearable:!!t,onClear:()=>r?.(""),reserveErrorSpace:false,className:d,autoFocus:true})}),jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:i})]})})]}):h?null:jsxs(DialogTrigger,{isOpen:p,onOpenChange:g,children:[a||b,jsx(Et,{placement:"bottom",className:"w-[600px] max-w-[90vw] bg-background-surface shadow-xl border border-border-default rounded-lg overflow-hidden",children:jsxs("div",{className:"flex flex-col",children:[l&&jsx("div",{className:"p-4 border-b border-border-muted",children:jsx(fo,{value:t,onChange:f,placeholder:e,showSearchIcon:true,isClearable:!!t,onClear:()=>r?.(""),reserveErrorSpace:false,className:d,autoFocus:true})}),jsx("div",{className:"max-h-[500px] overflow-hidden",children:i})]})})]})}function sC({placeholder:e="Search...",value:t,onChange:r,isOpen:o,onOpenChange:n,children:a,maxHeight:i="400px",variant:s="default",className:l}){let[d,c]=useState(false),u=Pr("(max-width: 767px)"),m=useRef(null),p=useRef(null),g=o!==void 0?o:d,f=useCallback(R=>{n?n(R):c(R);},[n]);useEffect(()=>{let R=A=>{(A.metaKey||A.ctrlKey)&&A.key==="k"&&(A.preventDefault(),f(!g)),A.key==="Escape"&&g&&f(false);};return window.addEventListener("keydown",R),()=>window.removeEventListener("keydown",R)},[g,f]),useEffect(()=>{g&&!u&&m.current&&setTimeout(()=>{m.current?.querySelector("input")?.focus();},0);},[g,u]),useEffect(()=>{if(!g||u)return;let R=A=>{let M=A.target,B=m.current?.contains(M),D=p.current?.contains(M);!B&&!D&&f(false);};return document.addEventListener("mousedown",R,true),()=>document.removeEventListener("mousedown",R,true)},[g,u,f]);let b=R=>{r?.(R);},h=useCallback(()=>{f(false);},[f]),v=useCallback(()=>{r?.("");},[r]),[x,C]=useState(null);useEffect(()=>{if(g&&!u&&m.current){let R=null,A=()=>{let B=m.current?.getBoundingClientRect();B&&C({top:B.bottom+8,left:B.left,width:B.width});},M=()=>{R===null&&(R=requestAnimationFrame(()=>{A(),R=null;}));};return A(),window.addEventListener("resize",M),window.addEventListener("scroll",M,true),()=>{window.removeEventListener("resize",M),window.removeEventListener("scroll",M,true),R!==null&&cancelAnimationFrame(R);}}},[g,u]);let S=useCallback(()=>{f(true);},[f]);if(u)return jsxs("div",{className:l,children:[jsx("button",{type:"button",onClick:S,className:"flex items-center justify-center w-10 h-10 rounded-lg hover:bg-background-hover transition-colors","aria-label":"Open search",children:jsx(G,{name:"MagnifyingGlass",size:"md"})}),jsxs(Lt,{isOpen:g,onClose:h,contentPadding:false,height:"80vh",children:[jsxs("div",{className:"flex items-center gap-2 px-4 pt-4",children:[jsx("div",{className:"flex-1",children:jsx(fo,{value:t,onChange:b,placeholder:e,showSearchIcon:true,isClearable:!!t,onClear:v,reserveErrorSpace:false,autoFocus:true})}),jsx(te,{variant:"icon",onPress:h,"aria-label":"Close search",className:"flex-shrink-0",children:jsx(G,{name:"X",size:"md"})})]}),jsx("div",{className:"mt-4",children:a})]})]},"mobile");let w=R=>{let M=R.target.tagName==="INPUT";if(R.key==="ArrowDown"&&g&&M){R.preventDefault();let B=p.current?.querySelector("[data-search-result]");B&&B.focus();}},T=R=>{let A=R.target;if(!A.hasAttribute("data-search-result"))return;let B=Array.from(p.current?.querySelectorAll("[data-search-result]")||[]),D=B.indexOf(A);if(R.key==="ArrowDown"){R.preventDefault(),R.stopPropagation();let W=Math.min(D+1,B.length-1);B[W]?.focus();}else if(R.key==="ArrowUp")if(R.preventDefault(),R.stopPropagation(),D===0)m.current?.querySelector("input")?.focus();else {let W=Math.max(D-1,0);B[W]?.focus();}else R.key==="Escape"&&(R.preventDefault(),R.stopPropagation(),f(false),m.current?.querySelector("input")?.focus());},N=g&&x&&typeof document<"u"?createPortal(jsx("div",{ref:p,style:{position:"fixed",top:`${x.top}px`,left:`${x.left}px`,width:`${x.width}px`,zIndex:9999},role:"listbox",onKeyDown:T,children:jsx("div",{className:"bg-background-surface shadow-2xl border border-border-default rounded-lg overflow-hidden animate-in fade-in zoom-in-95 duration-200",children:jsx("div",{className:"overflow-y-auto",style:{maxHeight:i},children:a})})}),document.body):null,k=s==="elevated"?"bg-background-muted/50 border-border-subtle/50 focus-within:bg-background-body focus-within:border-border-focus focus-within:shadow-md backdrop-blur-sm transition-all duration-200":"";return jsxs("div",{ref:m,className:`relative w-full ${l||""}`,onKeyDown:w,children:[jsx(fo,{value:t,onChange:b,placeholder:e,showSearchIcon:true,isClearable:!!t,onClear:()=>r?.(""),reserveErrorSpace:false,className:k,onFocus:()=>f(true)}),N]},"desktop")}function lC({message:e="No results found",suggestion:t,icon:r="MagnifyingGlass",className:o=""}){return jsxs("div",{className:`flex flex-col items-center justify-center py-12 px-4 text-center ${o}`,children:[jsx("div",{className:"text-text-secondary mb-3",children:jsx(G,{name:r,size:48})}),jsx("p",{className:"text-base font-medium text-text-primary mb-1",children:e}),t&&jsx("p",{className:"text-sm text-text-secondary max-w-xs",children:t})]})}function dC({count:e=3,className:t=""}){return jsx("div",{className:`flex flex-col ${t}`,children:Array.from({length:e}).map((r,o)=>jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5",children:[jsx(q,{width:20,height:20,variant:"circle"}),jsxs("div",{className:"flex-1 min-w-0 space-y-2",children:[jsx(q,{width:"60%",height:16}),jsx(q,{width:"40%",height:12})]}),jsx(q,{width:16,height:16})]},o))})}function pC({title:e,count:t,isLoading:r,footer:o,children:n,className:a}){return jsxs("div",{className:twMerge("flex flex-col",a),children:[jsxs("div",{className:"flex items-baseline gap-1.5 px-4 pt-4 pb-2 border-t border-border-muted first:border-t-0",children:[jsx("h3",{className:"text-sm font-semibold text-text-primary",children:e}),!r&&t!==void 0&&jsx("span",{className:"text-xs text-text-secondary",children:t}),r&&jsx("span",{className:"text-xs text-text-secondary animate-pulse",children:"Loading..."})]}),jsx("div",{className:"flex flex-col",children:n}),o&&jsx("div",{className:"px-4 py-2 border-t border-border-subtle",children:o})]})}function mC({id:e,title:t,subtitle:r,metadata:o,icon:n,customIcon:a,onSelect:i,isFocused:s=false,className:l,testId:d}){return jsxs("div",{role:"option",tabIndex:0,onClick:()=>{i?.(e);},onKeyDown:m=>{let p=m.currentTarget;switch(m.key){case "Enter":case " ":{m.preventDefault(),i?.(e);break}case "ArrowDown":{m.preventDefault();let g=Array.from(document.querySelectorAll("[data-search-result]")),f=g.indexOf(p);f!==-1&&f<g.length-1&&g[f+1].focus();break}case "ArrowUp":{m.preventDefault();let g=Array.from(document.querySelectorAll("[data-search-result]")),f=g.indexOf(p);if(f>0)g[f-1].focus();else {let b=document.querySelector('input[type="text"][placeholder*="Search"]');b&&b.focus();}break}case "Escape":{m.preventDefault();let g=document.querySelector('input[type="text"][placeholder*="Search"]');g&&g.focus();break}}},"data-testid":d,"data-search-result":true,className:twMerge("group flex items-center gap-3 px-4 py-3 cursor-pointer outline-none transition-colors","text-text-primary hover:bg-background-hover","focus-visible:bg-background-muted focus-visible:outline-none","data-[focused]:bg-background-hover",s&&"bg-background-hover",l),"data-focused":s||void 0,children:[a?jsx("div",{className:"flex-shrink-0",children:a}):n?jsx("div",{className:"flex-shrink-0 text-text-secondary",children:jsx(G,{name:n,size:20})}):null,jsxs("div",{className:"flex-1 min-w-0",children:[jsxs("div",{className:"flex items-baseline gap-2",children:[jsx("span",{className:"font-medium text-text-primary truncate",children:t}),o&&jsx("span",{className:"text-xs text-text-secondary flex-shrink-0",children:o})]}),r&&jsx("div",{className:"text-sm text-text-secondary truncate mt-0.5",children:r})]}),jsx("div",{className:"flex-shrink-0 opacity-0 group-hover:opacity-100 group-focus-visible:opacity-100 group-data-[focused]:opacity-100 transition-opacity",children:jsx(G,{name:"ArrowRight",size:16,className:"text-text-secondary"})})]})}function fC({children:e,maxHeight:t="400px",className:r}){return jsx("div",{className:twMerge("overflow-y-auto overscroll-contain","divide-y divide-border-muted",r),style:{maxHeight:t},children:e})}function hC({placeholder:e="Search...",onClick:t,showShortcut:r=true,variant:o="default",className:n=""}){let a=typeof navigator<"u"&&navigator.platform.includes("Mac");return jsxs("button",{type:"button",onClick:t,className:`
|
|
169
169
|
flex items-center gap-3 w-full px-4 py-2.5 rounded-lg
|
|
170
170
|
transition-all duration-200 cursor-text
|
|
171
171
|
${{default:`
|