@elaraai/e3-ui-cli 1.0.57 → 1.0.58
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.
|
@@ -669,7 +669,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
669
669
|
*/function eX(e,t){return e?cNn(e)?C.createElement(e,t):e:null}function cNn(e){return uNn(e)||typeof e=="function"||dNn(e)}function uNn(e){return typeof e=="function"&&(()=>{const t=Object.getPrototypeOf(e);return t.prototype&&t.prototype.isReactComponent})()}function dNn(e){return typeof e=="object"&&typeof e.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(e.$$typeof.description)}function yI(e){const t={state:{},onStateChange:()=>{},renderFallbackValue:null,...e},[n]=C.useState(()=>({current:lNn(t)})),[r,a]=C.useState(()=>n.current.initialState);return n.current.setOptions(o=>({...o,...e,state:{...r,...e.state},onStateChange:i=>{a(i),e.onStateChange==null||e.onStateChange(i)}})),n.current}function Hh(e,t,n){let r=n.initialDeps??[],a,o=!0;function i(){var s,l,c;let u;n.key&&((s=n.debug)!=null&&s.call(n))&&(u=Date.now());const d=e();if(!(d.length!==r.length||d.some((g,v)=>r[v]!==g)))return a;r=d;let h;if(n.key&&((l=n.debug)!=null&&l.call(n))&&(h=Date.now()),a=t(...d),n.key&&((c=n.debug)!=null&&c.call(n))){const g=Math.round((Date.now()-u)*100)/100,v=Math.round((Date.now()-h)*100)/100,b=v/16,y=(x,S)=>{for(x=String(x);x.length<S;)x=" "+x;return x};console.info(`%c⏱ ${y(v,5)} /${y(g,5)} ms`,`
|
|
670
670
|
font-size: .6rem;
|
|
671
671
|
font-weight: bold;
|
|
672
|
-
color: hsl(${Math.max(0,Math.min(120-120*b,120))}deg 100% 31%);`,n==null?void 0:n.key)}return n!=null&&n.onChange&&!(o&&n.skipInitialOnChange)&&n.onChange(a),o=!1,a}return i.updateDeps=s=>{r=s},i}function W5e(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const fNn=(e,t)=>Math.abs(e-t)<1.01,pNn=(e,t,n)=>{let r;return function(...a){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,a),n)}},U5e=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},hNn=e=>e,gNn=e=>{const t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let a=t;a<=n;a++)r.push(a);return r},mNn=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const a=i=>{const{width:s,height:l}=i;t({width:Math.round(s),height:Math.round(l)})};if(a(U5e(n)),!r.ResizeObserver)return()=>{};const o=new r.ResizeObserver(i=>{const s=()=>{const l=i[0];if(l!=null&&l.borderBoxSize){const c=l.borderBoxSize[0];if(c){a({width:c.inlineSize,height:c.blockSize});return}}a(U5e(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(s):s()});return o.observe(n,{box:"border-box"}),()=>{o.unobserve(n)}},q5e={passive:!0},G5e=typeof window>"u"?!0:"onscrollend"in window,vNn=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;let a=0;const o=e.options.useScrollendEvent&&G5e?()=>{}:pNn(r,()=>{t(a,!1)},e.options.isScrollingResetDelay),i=u=>()=>{const{horizontal:d,isRtl:f}=e.options;a=d?n.scrollLeft*(f&&-1||1):n.scrollTop,o(),t(a,u)},s=i(!0),l=i(!1);n.addEventListener("scroll",s,q5e);const c=e.options.useScrollendEvent&&G5e;return c&&n.addEventListener("scrollend",l,q5e),()=>{n.removeEventListener("scroll",s),c&&n.removeEventListener("scrollend",l)}},yNn=(e,t,n)=>{if(t!=null&&t.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},bNn=(e,{adjustments:t=0,behavior:n},r)=>{var a,o;const i=e+t;(o=(a=r.scrollElement)==null?void 0:a.scrollTo)==null||o.call(a,{[r.options.horizontal?"left":"top"]:i,behavior:n})};let xNn=class{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var n,r,a;return((a=(r=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:r.now)==null?void 0:a.call(r))??Date.now()},this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(a=>{a.forEach(o=>{const i=()=>{const s=o.target,l=this.indexFromElement(s);if(!s.isConnected){this.observer.unobserve(s);return}this.shouldMeasureDuringScroll(l)&&this.resizeItem(l,this.options.measureElement(s,o,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()})}));return{disconnect:()=>{var a;(a=r())==null||a.disconnect(),n=null},observe:a=>{var o;return(o=r())==null?void 0:o.observe(a,{box:"border-box"})},unobserve:a=>{var o;return(o=r())==null?void 0:o.unobserve(a)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([r,a])=>{typeof a>"u"&&delete n[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:hNn,rangeExtractor:gNn,onChange:()=>{},measureElement:yNn,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...n}},this.notify=n=>{var r,a;(a=(r=this.options).onChange)==null||a.call(r,this,n)},this.maybeNotify=Hh(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(a=>{this.observer.observe(a)}),this.unsubs.push(this.options.observeElementRect(this,a=>{this.scrollRect=a,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(a,o)=>{this.scrollAdjustments=0,this.scrollDirection=o?this.getScrollOffset()<a?"forward":"backward":null,this.scrollOffset=a,this.isScrolling=o,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,r)=>{const a=new Map,o=new Map;for(let i=r-1;i>=0;i--){const s=n[i];if(a.has(s.lane))continue;const l=o.get(s.lane);if(l==null||s.end>l.end?o.set(s.lane,s):s.end<l.end&&a.set(s.lane,!0),a.size===this.options.lanes)break}return o.size===this.options.lanes?Array.from(o.values()).sort((i,s)=>i.end===s.end?i.index-s.index:i.end-s.end)[0]:void 0},this.getMeasurementOptions=Hh(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(n,r,a,o,i,s)=>(this.prevLanes!==void 0&&this.prevLanes!==s&&(this.lanesChangedFlag=!0),this.prevLanes=s,this.pendingMeasuredCacheIndexes=[],{count:n,paddingStart:r,scrollMargin:a,getItemKey:o,enabled:i,lanes:s}),{key:!1}),this.getMeasurements=Hh(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:n,paddingStart:r,scrollMargin:a,getItemKey:o,enabled:i,lanes:s},l)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const f of this.laneAssignments.keys())f>=n&&this.laneAssignments.delete(f);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(f=>{this.itemSizeCache.set(f.key,f.size)}));const c=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1);const u=this.measurementsCache.slice(0,c),d=new Array(s).fill(void 0);for(let f=0;f<c;f++){const h=u[f];h&&(d[h.lane]=f)}for(let f=c;f<n;f++){const h=o(f),g=this.laneAssignments.get(f);let v,b;if(g!==void 0&&this.options.lanes>1){v=g;const z=d[v],M=z!==void 0?u[z]:void 0;b=M?M.end+this.options.gap:r+a}else{const z=this.options.lanes===1?u[f-1]:this.getFurthestMeasurement(u,f);b=z?z.end+this.options.gap:r+a,v=z?z.lane:f%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(f,v)}const y=l.get(h),x=typeof y=="number"?y:this.options.estimateSize(f),S=b+x;u[f]={index:f,start:b,size:x,end:S,key:h,lane:v},d[v]=f}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Hh(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,a,o)=>this.range=n.length>0&&r>0?wNn({measurements:n,outerSize:r,scrollOffset:a,lanes:o}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Hh(()=>{let n=null,r=null;const a=this.calculateRange();return a&&(n=a.startIndex,r=a.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,a,o,i)=>o===null||i===null?[]:n({startIndex:o,endIndex:i,overscan:r,count:a}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,a=n.getAttribute(r);return a?parseInt(a,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var r;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const a=this.scrollState.index??((r=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:r.index);if(a!==void 0&&this.range){const o=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),i=Math.max(0,a-o),s=Math.min(this.options.count-1,a+o);return n>=i&&n<=s}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((i,s)=>{i.isConnected||(this.observer.unobserve(i),this.elementsCache.delete(s))});return}const r=this.indexFromElement(n),a=this.options.getItemKey(r),o=this.elementsCache.get(a);o!==n&&(o&&this.observer.unobserve(o),this.observer.observe(n),this.elementsCache.set(a,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(r)&&this.resizeItem(r,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,r)=>{var a;const o=this.measurementsCache[n];if(!o)return;const i=this.itemSizeCache.get(o.key)??o.size,s=r-i;s!==0&&(((a=this.scrollState)==null?void 0:a.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(o,s,this):o.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=s,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(o.index),this.itemSizeCache=new Map(this.itemSizeCache.set(o.key,r)),this.notify(!1))},this.getVirtualItems=Hh(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const a=[];for(let o=0,i=n.length;o<i;o++){const s=n[o],l=r[s];a.push(l)}return a},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length!==0)return W5e(r[fXe(0,r.length-1,a=>W5e(r[a]).start,n)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(n,r,a=0)=>{if(!this.scrollElement)return 0;const o=this.getSize(),i=this.getScrollOffset();r==="auto"&&(r=n>=i+o?"end":"start"),r==="center"?n+=(a-o)/2:r==="end"&&(n-=o);const s=this.getMaxScrollOffset();return Math.max(Math.min(s,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const a=this.getSize(),o=this.getScrollOffset(),i=this.measurementsCache[n];if(!i)return;if(r==="auto")if(i.end>=o+a-this.options.scrollPaddingEnd)r="end";else if(i.start<=o+this.options.scrollPaddingStart)r="start";else return[o,r];if(r==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),r];const s=r==="end"?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(s,r,i.size),r]},this.scrollToOffset=(n,{align:r="start",behavior:a="auto"}={})=>{const o=this.getOffsetForAlignment(n,r),i=this.now();this.scrollState={index:null,align:r,behavior:a,startedAt:i,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:a}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:r="auto",behavior:a="auto"}={})=>{n=Math.max(0,Math.min(n,this.options.count-1));const o=this.getOffsetForIndex(n,r);if(!o)return;const[i,s]=o,l=this.now();this.scrollState={index:n,align:s,behavior:a,startedAt:l,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:a}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:r="auto"}={})=>{const a=this.getScrollOffset()+n,o=this.now();this.scrollState={index:null,align:"start",behavior:r,startedAt:o,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let a;if(r.length===0)a=this.options.paddingStart;else if(this.options.lanes===1)a=((n=r[r.length-1])==null?void 0:n.end)??0;else{const o=Array(this.options.lanes).fill(null);let i=r.length-1;for(;i>=0&&o.some(s=>s===null);){const s=r[i];o[s.lane]===null&&(o[s.lane]=s.end),i--}a=Math.max(...o.filter(s=>s!==null))}return Math.max(a-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(n,{adjustments:r,behavior:a})=>{this.options.scrollToFn(n,{behavior:a,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(t)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const r=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,a=r?r[0]:this.scrollState.lastTargetOffset,o=1,i=a!==this.scrollState.lastTargetOffset;if(!i&&fNn(a,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=o){this.scrollState=null;return}}else this.scrollState.stableFrames=0,i&&(this.scrollState.lastTargetOffset=a,this.scrollState.behavior="auto",this._scrollToOffset(a,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}};const fXe=(e,t,n,r)=>{for(;e<=t;){const a=(e+t)/2|0,o=n(a);if(o<r)e=a+1;else if(o>r)t=a-1;else return a}return e>0?e-1:0};function wNn({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){const a=e.length-1,o=l=>e[l].start;if(e.length<=r)return{startIndex:0,endIndex:a};let i=fXe(0,a,o,n),s=i;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){const l=Array(r).fill(0);for(;s<a&&l.some(u=>u<n+t);){const u=e[s];l[u.lane]=u.end,s++}const c=Array(r).fill(n+t);for(;i>=0&&c.some(u=>u>=n);){const u=e[i];c[u.lane]=u.start,i--}i=Math.max(0,i-i%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:i,endIndex:s}}const K5e=typeof document<"u"?C.useLayoutEffect:C.useEffect;function SNn({useFlushSync:e=!0,...t}){const n=C.useReducer(()=>({}),{})[1],r={...t,onChange:(o,i)=>{var s;e&&i?J0.flushSync(n):n(),(s=t.onChange)==null||s.call(t,o,i)}},[a]=C.useState(()=>new xNn(r));return a.setOptions(r),K5e(()=>a._didMount(),[]),K5e(()=>a._willUpdate()),a}function bI(e){return SNn({observeElementRect:mNn,observeElementOffset:vNn,scrollToFn:bNn,...e})}const xI={scrollbarGutter:"stable","@supports (-moz-appearance: none)":{scrollbarWidth:"thin",scrollbarColor:"var(--chakra-colors-overlay-scroll-thumb) var(--chakra-colors-overlay-scroll-track)"},"&::-webkit-scrollbar":{width:"12px",height:"12px"},"&::-webkit-scrollbar-track":{background:"var(--chakra-colors-overlay-scroll-track)"},"&::-webkit-scrollbar-thumb":{background:"var(--chakra-colors-overlay-scroll-thumb)",borderRadius:"6px",border:"3px solid transparent",backgroundClip:"padding-box"},"&::-webkit-scrollbar-corner":{background:"transparent"}},CNn={"&::-webkit-scrollbar":{width:"12px",height:"12px"},"&::-webkit-scrollbar:vertical":{display:"none"},"&::-webkit-scrollbar-track":{background:"var(--chakra-colors-overlay-scroll-track)"},"&::-webkit-scrollbar-thumb":{background:"var(--chakra-colors-overlay-scroll-thumb)",borderRadius:"6px",border:"3px solid transparent",backgroundClip:"padding-box"},"&::-webkit-scrollbar-corner":{background:"transparent"}};function Dv(e){const{header:t,footer:n,count:r,estimateSize:a,renderRow:o,overscan:i=4,minWidth:s,headerZIndex:l=3,onScroll:c,rootCss:u,fillParent:d,scrollElRef:f}=e,h=Tt(e.height),g=Tt(e.maxHeight),v=h!==void 0||g!==void 0||d===!0,b=C.useRef(null),y=C.useRef(null),[x,S]=C.useState(0);C.useLayoutEffect(()=>{var L;S(((L=y.current)==null?void 0:L.offsetTop)??0)},[r]);const z=bI({count:r,getScrollElement:()=>b.current,estimateSize:a,overscan:i,scrollMargin:x,measureElement:L=>L==null?void 0:L.getBoundingClientRect().height});if(!v)return p.jsxs(V,{css:u,children:[t,Array.from({length:r},(L,R)=>p.jsx(C.Fragment,{children:o(R)},R)),n]});const M=z.getVirtualItems();return p.jsxs(V,{ref:L=>{b.current=L,f!==void 0&&(f.current=L)},css:{...u,display:"block",overflowY:"auto",minHeight:"0",...d===!0?{flex:"1 1 auto"}:{},...xI},height:d===!0?void 0:h,maxHeight:d===!0?void 0:g,onScroll:c,children:[t!==void 0&&p.jsx(V,{position:"sticky",top:"0",zIndex:l,minWidth:s,background:"bg.surface",children:t}),p.jsx(V,{ref:y,position:"relative",height:`${z.getTotalSize()}px`,minWidth:s,children:M.map(L=>p.jsx(V,{"data-index":L.index,ref:z.measureElement,position:"absolute",top:"0",left:"0",width:"100%",style:{transform:`translateY(${L.start-x}px)`},children:o(L.index)},L.key))}),n]})}const Y5e=ji({position:!0,size:36});function pXe(e){const t=e.getIsPinned();return{borderRight:t==="left"&&e.getIsLastColumn("left")?"2px solid var(--chakra-colors-border, #e2e8f0)":void 0,left:t==="left"?`${e.getStart("left")}px`:void 0,right:t==="right"?`${e.getAfter("right")}px`:void 0,position:t?"sticky":"relative",width:e.getSize(),zIndex:t?1:0,backgroundColor:t?"var(--chakra-colors-bg-panel, white)":void 0}}function kNn({frozenFromValue:e,persistedPinnedColumns:t,setPersistedPinnedColumns:n}){const r=C.useMemo(()=>t??[...e],[t,e]),a=C.useMemo(()=>({left:r,right:[]}),[r]),o=r.length>0,i=C.useCallback(s=>{n(l=>l.includes(s)?l.filter(u=>u!==s):[...l,s])},[n]);return{pinnedColumns:r,columnPinning:a,hasFrozen:o,toggleColumnPin:i}}function zNn({header:e,toggleColumnPin:t,getSortIndex:n,enableMultiSort:r,enableColumnResizing:a}){const o=n(e.id),i=e.column.getIsSorted(),l=i?(i||null)==="asc"?x$:au:k$,c=e.column.getIsPinned();return p.jsxs(p.Fragment,{children:[p.jsxs(Xr,{justify:"space-between",width:"100%",pr:a?"4px":"0",children:[p.jsx(V,{as:"span",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"1",children:e.isPlaceholder?null:eX(e.column.columnDef.header,e.getContext())}),p.jsxs(Xr,{className:"col-controls",gap:0,flexShrink:0,alignItems:"center",css:{opacity:c||i?1:0,"@media (hover: none)":{opacity:c||i?1:.6}},transition:"opacity 0.15s",children:[p.jsx(V,{as:"button","aria-label":c?`Unpin ${e.id}`:`Pin ${e.id}`,onClick:u=>{u.stopPropagation(),t(e.id)},color:c?"fg.default":"fg.muted",_hover:{color:"fg.default",bg:"bg.emphasized"},transition:"color 0.15s",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",w:"24px",h:"24px",css:Y5e,borderRadius:"sm",children:p.jsx(Ut,{icon:WC,style:{width:"10px",height:"10px",transform:c?void 0:"rotate(45deg)"}})}),e.column.getCanSort()&&p.jsxs(V,{as:"button","aria-label":`Sort by ${e.id}`,onClick:u=>{u.stopPropagation(),e.column.toggleSorting(void 0,r)},color:i?"fg.default":"fg.muted",_hover:{color:"fg.default",bg:"bg.emphasized"},cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",w:"24px",h:"24px",css:Y5e,borderRadius:"sm",position:"relative",children:[p.jsx(Ut,{icon:l,style:{width:"10px",height:"10px"}}),i&&o&&r&&p.jsx(Ie,{fontSize:"7px",fontWeight:"bold",color:"fg.muted",lineHeight:"1",position:"absolute",top:"4px",right:"4px",children:o})]})]})]}),a&&p.jsx(Eie,{header:e})]})}const hXe={position:"absolute",right:"0",top:"50%",transform:"translateY(-50%)",width:"2px",height:"16px",bg:"gray.300",borderRadius:"1px"};function gXe(){return p.jsx(V,{css:{...hXe,opacity:.4},pointerEvents:"none"})}function Eie({header:e}){return e.column.getCanResize()?p.jsx(V,{position:"absolute",right:"0",top:"0",bottom:"0",width:"8px",cursor:"col-resize",bg:"transparent",_hover:{_before:{opacity:1,bg:"fg.muted"}},transition:"all 0.2s",zIndex:10,onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),_before:{content:'""',...hXe,opacity:.4,transition:"opacity 0.2s"}}):null}function _ie(e,t,n,r){var a;const o=t?pXe(e.column):{},i=e.column.getIsPinned();return{display:"flex",alignItems:"center",...r?{minWidth:`var(--header-${e.id}-size)`,flex:1}:{width:`var(--header-${e.id}-size)`,flex:t||n[e.id]||(a=e.column.columnDef.meta)!=null&&a.width?"none":1},...o,zIndex:i?3:void 0,position:i?"sticky":"relative"}}function Lie(e,t,n,r){const a=e.column.columnDef.meta,o=t?pXe(e.column):{};return{...r?{minWidth:`var(--col-${e.column.id}-size)`,flex:1}:{width:`var(--col-${e.column.id}-size)`,flex:t||n[e.column.id]||a!=null&&a.width?"none":1},...o}}function MNn(e){return t=>{const n=e.findIndex(r=>r.id===t);return n>=0?n+1:void 0}}function Rie(e){return C.useMemo(()=>{const t={};for(const n of e.getFlatHeaders())t[`--header-${n.id}-size`]=`${n.getSize()}px`,t[`--col-${n.column.id}-size`]=`${n.column.getSize()}px`;return t},[e.getState().columnSizingInfo,e.getState().columnSizing])}function TNn(e){return C.useMemo(()=>{const t=e.getFlatHeaders();for(let n=t.length-1;n>=0;n--)if(!t[n].column.getIsPinned())return t[n].id;return null},[e,e.getState().columnPinning])}function wI(e){const[t,n]=M7("sizes",[`density.header.${e}`,`density.row.${e}`]);return{header:parseInt(t??"",10)||36,row:parseInt(n??"",10)||36}}function X5e(e){return e==="start"?"flex-start":e==="end"?"flex-end":"center"}function ENn(e){if(e==="success")return"var(--chakra-colors-status-pos-subtle)";if(e==="warning")return"var(--chakra-colors-status-warn-subtle)";if(e==="danger")return"var(--chakra-colors-status-neg-subtle)";if(e==="info")return"var(--chakra-colors-status-info-subtle)";if(e==="neutral")return"var(--chakra-colors-bg-subtle)"}function mXe(e){const t=C.useMemo(()=>e,[e]);return C.useCallback(n=>{if(t)try{const r=t(BigInt(n));return ENn(r==null?void 0:r.type)}catch{return}},[t])}const _Nn=it(N8.Types.Root),LNn=["brand","success","warning","danger","info","neutral","slack","free"],RNn=["success","warning","danger","info","neutral"],AV=["horizontal","vertical"],PNn={success:A$,warning:Tv,danger:VC,info:Ev,neutral:Lae};function ANn(e){var t;const n=(t=_(e.density))==null?void 0:t.type;return n==="compact"?"sm":n==="comfortable"?"lg":"md"}function vXe(e){const t=_(e);return t?t.value:void 0}function NNn({segments:e,orientation:t,barStyle:n,segByFill:r,segLabelStyle:a,resizeHandleStyle:o,minLabelSizePx:i,onResize:s}){const l=C.useRef(null),[c,u]=C.useState(0);C.useLayoutEffect(()=>{const f=l.current;if(!f||typeof ResizeObserver>"u")return;const h=new ResizeObserver(()=>{const g=f.getBoundingClientRect();u(t==="vertical"?g.height:g.width)});return h.observe(f),()=>h.disconnect()},[t]);const d=e.reduce((f,h)=>f+h.weight,0)||1;return p.jsx(V,{ref:l,css:n,"data-slot":"bar",children:e.map((f,h)=>{const g=f.weight/d*100,v=c*g/100,b=f.fill.type,y=_(f.color),x=vXe(f.label),S=x!==void 0&&(i<=0||v===0||v>=i),z=s!==void 0&&h<e.length-1,M={...r[b],flexGrow:0,flexShrink:0,flexBasis:`${g}%`,...y!==void 0?{background:y}:{}};return p.jsxs(V,{css:M,"data-slot":"seg","data-fill":b,children:[S&&p.jsx(V,{as:"span",css:a,"data-slot":"segLabel",children:x}),z&&p.jsx(V,{css:o,"data-slot":"resizeHandle",onPointerDown:L=>s(L,h,d,c)})]},h)})})}function $Nn(e,t){return{top:e==="tl"||e==="tr"?t:"auto",bottom:e==="bl"||e==="br"?t:"auto",left:e==="tl"||e==="bl"?t:"auto",right:e==="tr"||e==="br"?t:"auto"}}function INn({cell:e,rowKey:t,columnKey:n,rootOrientation:r,storageKey:a,minLabelSizePx:o,barStyles:i,segStyles:s,segLabelStyle:l,resizeHandleStyle:c,statusStyles:u,markerInset:d,onCellClick:f,onSegmentClick:h,onSegmentChange:g}){var v;const b=((v=_(e.orientation))==null?void 0:v.type)==="vertical"?"vertical":r,y=_(e.slot),x=_(e.popover),S=e.segments,z=e.markers,M=C.useCallback((H,K,U,Z)=>{if(!g||Z<=0)return;H.stopPropagation(),H.preventDefault();const G=S[K];if(!G)return;const W=G.weight,J=_(G.min)??0,ae=_(G.max)??U,ne=_(G.step)??0,Y=b==="vertical"?H.clientY:H.clientX,te=ue=>{const oe=b==="vertical"?ue.clientY:ue.clientX,ve=b==="vertical"?Y-oe:oe-Y;let se=W+ve/Z*U;se=Math.max(J,Math.min(ae,se)),ne>0&&(se=Math.round(se/ne)*ne),queueMicrotask(()=>g({row:t,column:n,segmentIndex:BigInt(K),weight:se}))},ie=()=>{window.removeEventListener("pointermove",te),window.removeEventListener("pointerup",ie)};window.addEventListener("pointermove",te),window.addEventListener("pointerup",ie)},[g,S,b,t,n]),L=h!==void 0,R=y!==void 0?p.jsx(mn,{value:y,storageKey:`${a}.slot`}):p.jsx(NNn,{segments:S,orientation:b,barStyle:i[b],segByFill:s[b],segLabelStyle:l,resizeHandleStyle:c,minLabelSizePx:o,onResize:g?M:void 0}),N=x===void 0&&(f!==void 0||L),O=p.jsx(V,{flex:"1",minW:0,display:"flex",alignItems:"center",width:"100%",height:"100%",cursor:N?"pointer":void 0,onClick:N?()=>{f&&f({row:t,column:n}),h&&S.length>0&&h({row:t,column:n,segmentIndex:0n,fill:S[0].fill})}:void 0,children:R}),j=z.length>0?z[0].status.type:void 0,B=j?(u[j]??u.info).markerRing:void 0;return p.jsxs(p.Fragment,{children:[x!==void 0?p.jsxs(nu,{positioning:{placement:"top"},children:[p.jsx(R6,{asChild:!0,children:p.jsx(V,{flex:"1",minW:0,display:"flex",alignItems:"center",width:"100%",height:"100%",cursor:"pointer",children:R})}),p.jsx(go,{children:p.jsx(M4,{children:p.jsx(T4,{padding:"14px 16px",minW:"240px",maxW:"360px",fontSize:"13px",children:p.jsx($C,{padding:0,children:p.jsx(mn,{value:x,storageKey:`${a}.popover`})})})})})]}):O,B&&p.jsx(V,{css:B,"data-slot":"markerRing"}),z.map((H,K)=>{const U=u[H.status.type]??u.info,Z=_(H.label),G={...U.markerIcon,...$Nn(H.at.type,d)};return p.jsxs(s$,{openDelay:150,children:[p.jsx(l$,{asChild:!0,children:p.jsx(V,{css:G,"data-slot":"markerIcon",children:Z!==void 0?Z:p.jsx(Ut,{icon:PNn[H.status.type]??Ev})})}),p.jsx(go,{children:p.jsx(c$,{children:p.jsx(u$,{children:H.message})})})]},K)})]})}const Z5e=180,DNn=C.memo(function({value:t,storageKey:n}){var r,a,o,i,s,l,c;const u=(r=_(t.density))==null?void 0:r.type,d=ANn(t),f=en({key:"matrix"}),h=en({key:"table"}),g=en({key:"sliceFrame"}),v=C.useMemo(()=>f({size:d}),[f,d]),b=C.useMemo(()=>h({size:d}).columnHeader??{},[h,d]),y=C.useMemo(()=>g(),[g]),{header:x,row:S}=wI(d),z=t.orientation.type==="vertical"?"vertical":"horizontal",M=C.useMemo(()=>t.columns.map(Pe=>({key:Pe.key,label:vXe(Pe.label)??Pe.key})),[t.columns]),L=Math.max(M.length,1),R=C.useMemo(()=>{const Pe={};for(const ot of AV)Pe[ot]=f({size:d,orientation:ot}).bar??{};return Pe},[f,d]),N=C.useMemo(()=>{const Pe={};for(const ot of AV)Pe[ot]=f({size:d,orientation:ot}).cell??{};return Pe},[f,d]),O=C.useMemo(()=>{const Pe={};for(const ot of AV){const kt={};for(const Mt of LNn)kt[Mt]=f({size:d,orientation:ot,fill:Mt}).seg??{};Pe[ot]=kt}return Pe},[f,d]),j=C.useMemo(()=>{const Pe={};for(const ot of RNn)Pe[ot]=f({size:d,status:ot});return Pe},[f,d]),B=((a=v.markerIcon)==null?void 0:a.top)??"3px",H=C.useMemo(()=>t.rows.some(Pe=>_(Pe.sublabel)!==void 0),[t.rows]),K=parseInt(((o=v.cell)==null?void 0:o.padding)??"8",10)||8,U=parseInt(((i=R[z])==null?void 0:i.height)??"24",10)||24,Z=Math.round((parseInt(((s=v.rowHeaderSub)==null?void 0:s.fontSize)??"10",10)||10)*1.4)+(parseInt(((l=v.rowHeaderSub)==null?void 0:l.marginTop)??"2",10)||2),G=Math.max(S,U+2*K)+(H?Z:0),W=C.useMemo(()=>{const Pe=_(t.minLabelSize);return Pe===void 0?0:Math.round(Pe)},[t.minLabelSize]),J=C.useMemo(()=>_(t.onCellClick),[t.onCellClick]),ae=C.useMemo(()=>_(t.onSegmentClick),[t.onSegmentClick]),ne=C.useMemo(()=>_(t.onSegmentChange),[t.onSegmentChange]),Y=C.useMemo(()=>gI(),[]),te=!1,ie=_(t.rowHeader)??"",ue=C.useMemo(()=>[Y.accessor(Pe=>Pe.value,{id:"__rowheader__",header:ie,enableSorting:!1,size:Z5e,minSize:80,meta:{columnKey:"__rowheader__",width:`${Z5e}px`}})],[Y,ie]),{state:oe,setState:ve}=Pl(n,{columnSizing:{}}),se=oe.columnSizing,pe=C.useCallback(Pe=>{ve(ot=>({...ot,columnSizing:typeof Pe=="function"?Pe(ot.columnSizing):Pe}))},[ve]),de=yI({data:t.rows,columns:ue,state:{columnSizing:se},onColumnSizingChange:pe,getCoreRowModel:vI(),enableSorting:!1,enableColumnResizing:!0,columnResizeMode:"onChange"}),ge=Rie(de),ye=((c=de.getHeaderGroups()[0])==null?void 0:c.headers)??[],me=`${de.getTotalSize()}px`,Me="90px",Te=90,Be=`repeat(${L}, minmax(${Me}, 1fr))`,ht=`calc(${me} + ${L*Te}px)`,De={position:"sticky",left:0,zIndex:1,background:"bg.surface"},Qe={...De,zIndex:2,background:"bg.panel"},bt=N7(),Ve=C.useMemo(()=>_(t.plotGutter),[t.plotGutter]),ut=(Ve?_(Ve.left):void 0)??(bt==null?void 0:bt.left),_t=(Ve?_(Ve.right):void 0)??(bt==null?void 0:bt.right),Ft=ut!==void 0||_t!==void 0,wt=_t??"0px",Lt=ut??me,Jt=ut!==void 0?{...ge,"--col-__rowheader__-size":ut,"--header-__rowheader__-size":ut}:ge,Dt=Ft?`${Lt} 1fr ${wt}`:`${me} 1fr`,Et=Ft?`repeat(${L}, minmax(0, 1fr))`:Be,Gt=Ft?void 0:ht,Ke=_(t.legend),Se=C.useMemo(()=>{const Pe=[];return t.rows.forEach((ot,kt)=>{const Mt=_(ot.group),At=Pe[Pe.length-1];At&&At.label===Mt?At.rows.push({row:ot,index:kt}):Pe.push({label:Mt,rows:[{row:ot,index:kt}]})}),Pe},[t.rows]),Re=p.jsxs(V,{css:v.header,"data-slot":"header",display:"grid",gridTemplateColumns:Dt,minWidth:Gt,height:`${x}px`,children:[p.jsx(V,{css:Qe,display:"flex",width:"100%",style:Jt,children:ye.map(Pe=>p.jsxs(V,{css:b,"data-slot":"colHeader",position:"relative",display:"flex",alignItems:"center",style:_ie(Pe,te,se,!1),children:[p.jsx(V,{as:"span",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minW:0,children:Pe.column.columnDef.header}),p.jsx(Eie,{header:Pe})]},Pe.id))}),p.jsx(V,{display:"grid",gridTemplateColumns:Et,children:M.map((Pe,ot)=>p.jsxs(V,{css:{...b,position:"relative",display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"},"data-slot":"headerCell",children:[Pe.label,ot<M.length-1&&p.jsx(gXe,{})]},Pe.key))}),Ft&&p.jsx(V,{"data-slot":"headerGutter","aria-hidden":"true",background:"bg.surface"})]}),qe=[];for(const Pe of Se){Pe.label!==void 0&&qe.push({kind:"groupHead",label:Pe.label});for(const ot of Pe.rows)qe.push({kind:"row",row:ot.row,index:ot.index})}const Ye=Pe=>{const ot=qe[Pe];if(ot===void 0)return null;if(ot.kind==="groupHead")return p.jsx(V,{css:v.groupHead,"data-slot":"groupHead",minWidth:Gt,display:"grid",gridTemplateColumns:Dt,children:p.jsx(V,{css:{...De,...v.groupHeadCell,background:"bg.panel"},"data-slot":"groupHeadCell",children:ot.label})});const{row:kt,index:Mt}=ot;return p.jsxs(V,{css:v.row,position:"relative",display:"grid",gridTemplateColumns:Dt,minWidth:Gt,children:[Ft&&p.jsx(V,{position:"absolute",top:"0",bottom:"-1px",right:"0",width:wt,background:"bg.surface",pointerEvents:"none",zIndex:3,"aria-hidden":"true"}),p.jsx(V,{css:De,display:"flex",width:"100%",style:Jt,children:de.getVisibleLeafColumns().map(At=>{const fn=_(kt.sublabel);return p.jsxs(V,{css:v.rowHeader,"data-slot":"rowHeader",style:Lie({column:At},te,se,!1),children:[p.jsx(V,{css:v.rowHeaderName,"data-slot":"rowHeaderName",children:kt.value}),fn!==void 0&&p.jsx(V,{css:v.rowHeaderSub,"data-slot":"rowHeaderSub",children:fn})]},At.id)})}),p.jsx(V,{display:"grid",gridTemplateColumns:Et,children:M.map((At,fn)=>{var rt;const ln=kt.cells.get(At.key),Mn=ln&&((rt=_(ln.orientation))==null?void 0:rt.type)==="vertical"?"vertical":z;let Jn={...N[Mn],height:`${G}px`};return fn===M.length-1&&(Jn={...Jn,borderRightWidth:"0"}),p.jsx(V,{"data-slot":"cell",css:Jn,children:ln&&p.jsx(INn,{cell:ln,rowKey:kt.key,columnKey:At.key,rootOrientation:z,storageKey:`${n}.${kt.key}.${At.key}`,minLabelSizePx:W,barStyles:R,segStyles:O,segLabelStyle:v.segLabel??{},resizeHandleStyle:v.resizeHandle??{},statusStyles:j,markerInset:B,onCellClick:J,onSegmentClick:ae,onSegmentChange:ne})},At.key)})})]},Mt)},$e=Ke&&Ke.length>0?p.jsx(V,{css:y.legendRail,"data-slot":"legend",borderTopWidth:"1px",borderTopColor:"border.subtle",children:Ke.map((Pe,ot)=>{const kt=Pe.fill.type,Mt=O.horizontal[kt]["@layer recipes"]??O.horizontal[kt]??{};return p.jsxs(V,{as:"span",css:y.legendItem,cursor:"default","data-slot":"legendItem",children:[p.jsx(V,{as:"span",css:y.legendSwatch,"data-slot":"legendSwatch",...Mt.background?{background:Mt.background}:{},...Mt.backgroundImage?{backgroundImage:Mt.backgroundImage}:{},...kt==="free"?{borderWidth:"1px",borderStyle:"solid",borderColor:"border.subtle"}:{}}),p.jsx(V,{as:"span",css:y.legendLabel,"data-slot":"legendLabel",children:Pe.label})]},ot)})}):void 0,lt=p.jsx(Dv,{height:_(t.height),maxHeight:_(t.maxHeight),header:Re,footer:$e,count:qe.length,estimateSize:Pe=>{var ot;return((ot=qe[Pe])==null?void 0:ot.kind)==="groupHead"?x:G},renderRow:Ye,minWidth:Gt,rootCss:{...v.root,...Ft?{width:"100%"}:{}}});return u!==void 0?p.jsx(hu,{value:u,children:lt}):lt},(e,t)=>_Nn(e.value,t.value)&&e.storageKey===t.storageKey),ONn=it(Vq.Types.Pagination),jNn=C.memo(function({value:t,storageKey:n}){const r=C.useMemo(()=>_(t.style),[t.style]),a=r?_(r.color):void 0,o=r?_(r.background):void 0,i=r?_(r.activeBackground):void 0,s=r?_(r.activeColor):void 0,l=r?_(r.siblings):void 0,c=t.onPageChange,u=Number(t.page),d=Number(t.pageSize),f=Number(t.count),h=C.useCallback(M=>{queueMicrotask(()=>c(BigInt(M.page-1)))},[c]),v=en({key:"pagination"})(),b=C.useRef(null),y=Rv(b,360),x=Math.max(1,Math.ceil(f/Math.max(1,d))),S=C.useMemo(()=>({...a!==void 0?{color:a}:{}}),[a]),z=C.useMemo(()=>{const M=v.item,L={...i!==void 0?{background:i}:{},...s!==void 0?{color:s}:{}},R=Object.keys(L).length>0;return{...M,...a!==void 0?{color:a}:{},...o!==void 0?{background:o}:{},...R?{_selected:{...M._selected,...L},"&[data-selected]":{...M["&[data-selected]"],...L}}:{}}},[v,a,o,i,s]);return p.jsx(z$t,{count:f,pageSize:d,page:u+1,siblingCount:l!==void 0?Number(l):void 0,onPageChange:h,children:p.jsxs(V,{ref:b,css:v.root,children:[p.jsx(_$t,{asChild:!0,children:p.jsx(V,{as:"button","aria-label":"Previous page",css:{...v.prevTrigger,...S},children:p.jsx(Ut,{icon:kd})})}),y?p.jsxs(V,{as:"span","aria-live":"polite",css:{...v.ellipsis,...S},children:[u+1," / ",x]}):p.jsx(L$t,{render:M=>p.jsx(V,{as:"button","aria-label":`Page ${M.value}`,css:z,children:M.value})}),p.jsx(E$t,{asChild:!0,children:p.jsx(V,{as:"button","aria-label":"Next page",css:{...v.nextTrigger,...S},children:p.jsx(Ut,{icon:r2})})})]})})},(e,t)=>ONn(e.value,t.value)&&e.storageKey===t.storageKey);class yXe{constructor(t=1e3){Lg(this,"rowStates"),Lg(this,"loadedRows"),Lg(this,"loadingTimeouts"),Lg(this,"maxCacheSize"),Lg(this,"listeners",new Set),this.rowStates=new Map,this.loadedRows=new Set,this.loadingTimeouts=new Map,this.maxCacheSize=t}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}notifyListeners(){this.listeners.forEach(t=>t())}getRowState(t){return this.rowStates.get(t)||{status:"unloaded"}}isRowLoaded(t){return this.loadedRows.has(t)}markRowsLoading(t){const n=Date.now();t.forEach(r=>{this.clearTimeout(r),this.rowStates.set(r,{status:"loading",loadStartTime:n})}),this.cleanup(),this.notifyListeners()}clearTimeout(t){const n=this.loadingTimeouts.get(t);n&&(clearTimeout(n),this.loadingTimeouts.delete(t))}markRowsLoaded(t){t.forEach(n=>{this.clearTimeout(n),this.rowStates.set(n,{status:"loaded"}),this.loadedRows.add(n)}),this.notifyListeners()}markRowsError(t,n){t.forEach(r=>{this.clearTimeout(r),this.rowStates.set(r,{status:"error",error:n})}),this.notifyListeners()}markRowsUnloaded(t){t.forEach(n=>{this.clearTimeout(n),this.rowStates.delete(n),this.loadedRows.delete(n)}),this.notifyListeners()}scheduleLoaded(t,n=300){this.clearTimeout(t);const r=setTimeout(()=>{this.markRowsLoaded([t])},n);this.loadingTimeouts.set(t,r)}cleanup(){if(this.rowStates.size>this.maxCacheSize){const t=this.rowStates.size-this.maxCacheSize,n=this.rowStates.keys();for(let r=0;r<t;r++){const a=n.next().value;a!==void 0&&(this.rowStates.delete(a),this.loadedRows.delete(a))}}}clear(){this.loadingTimeouts.forEach(t=>clearTimeout(t)),this.loadingTimeouts.clear(),this.rowStates.clear(),this.loadedRows.clear(),this.notifyListeners()}getStates(){return new Map(this.rowStates)}}const m6="168px";function Q5e(e){const t={};return e.forEach((n,r)=>{if(n===void 0)return;const a=_(n);a!==void 0&&(t[r]=a.type)}),t}function ok(e,t){const n=C.useMemo(()=>e&&_(e.onApprove),[e]),r=C.useMemo(()=>e&&_(e.onReject),[e]),a=C.useMemo(()=>e&&_(e.onApproveAll),[e]),o=C.useMemo(()=>e&&_(e.onRejectAll),[e]),i=C.useMemo(()=>e&&_(e.onRerun),[e]),s=C.useMemo(()=>e&&_(e.summary),[e]),[l,c]=C.useState(()=>Q5e(t));C.useEffect(()=>{c(Q5e(t))},[t]);const u=C.useCallback(b=>{c(y=>({...y,[b]:"approved"})),n&&queueMicrotask(()=>n({rowIndex:BigInt(b)}))},[n]),d=C.useCallback(b=>{c(y=>({...y,[b]:"rejected"})),r&&queueMicrotask(()=>r({rowIndex:BigInt(b)}))},[r]),f=C.useCallback(()=>{c(()=>{const b={};return t.forEach((y,x)=>{b[x]="approved"}),b}),a&&queueMicrotask(()=>a())},[a,t]),h=C.useCallback(()=>{c(()=>{const b={};return t.forEach((y,x)=>{b[x]="rejected"}),b}),o&&queueMicrotask(()=>o())},[o,t]),g=C.useCallback(()=>{i&&queueMicrotask(()=>i())},[i]),v=C.useCallback(b=>l[b]??"pending",[l]);return C.useMemo(()=>{if(e!==void 0)return{review:e,decisions:l,tagFor:v,approveRow:u,rejectRow:d,approveAll:f,rejectAll:h,rerun:g,summary:s,showFoot:s!==void 0||a!==void 0||o!==void 0||i!==void 0,hasApproveAll:a!==void 0,hasRejectAll:o!==void 0,hasRerun:i!==void 0}},[e,l,v,u,d,f,h,g,s,a,o,i])}function SI({rowIndex:e,controller:t}){const n=ga({key:"button"}),r=t.tagFor(e),a=r==="approved"?"solid":r==="rejected"?"ghost":"outline",o=r==="rejected"?"danger":"ghost";return p.jsxs(p.Fragment,{children:[p.jsx(V,{as:"button",css:n({variant:a,size:"xs"}),"aria-pressed":r==="approved",onClick:i=>{i.stopPropagation(),t.approveRow(e)},children:"Approve"}),p.jsx(V,{as:"button",css:n({variant:o,size:"xs"}),"aria-pressed":r==="rejected",onClick:i=>{i.stopPropagation(),t.rejectRow(e)},children:"Reject"})]})}function ik({controller:e,storageKey:t}){const n=en({key:"commitBar"}),r=C.useMemo(()=>n({}),[n]);return e.showFoot?p.jsxs(V,{css:r.root,"data-slot":"reviewFoot",children:[p.jsx(V,{css:r.draft,children:e.summary!==void 0&&p.jsx(mn,{value:e.summary,storageKey:`${t}.review.summary`})}),p.jsxs(V,{css:r.btnRow,children:[e.hasRejectAll&&p.jsx(V,{as:"button",css:r.btnDanger,onClick:e.rejectAll,children:"Reject all"}),e.hasRerun&&p.jsx(V,{as:"button",css:r.btn,onClick:e.rerun,children:e.review.rerunLabel}),e.hasApproveAll&&p.jsx(V,{as:"button",css:r.btnPrimary,onClick:e.approveAll,children:"Approve all"})]})]}):null}const NV=ji({position:!0,size:36}),FNn=it(xte.Types.Root),$V=(e,t)=>{if(!e)return t;const n=parseInt(e,10);return isNaN(n)?t:n};function BNn(e){var t,n,r;const a=_(e.style);return{variant:a?(t=_(a.variant))==null?void 0:t.type:void 0,size:a?(n=_(a.size))==null?void 0:n.type:void 0,striped:a?_(a.striped):void 0,interactive:_(e.interactive),stickyHeader:a?_(a.stickyHeader):void 0,showColumnBorder:a?_(a.showColumnBorder):void 0,colorPalette:a?(r=_(a.colorPalette))==null?void 0:r.type:void 0}}const l8="__review__";function VNn(e,t){if(e==="count")return $("Integer",BigInt(t.length));if(t.length===0)return $("Null",null);const n=t[0].type;if(e==="sum"||e==="mean"){const a=t.map(i=>typeof i.value=="bigint"?Number(i.value):i.value),o=a.reduce((i,s)=>i+s,0);return e==="mean"?$("Float",o/a.length):n==="Integer"?$("Integer",t.reduce((i,s)=>i+s.value,0n)):$("Float",o)}let r=t[0];for(const a of t){const o=a.value,i=r.value;(e==="min"?o<i:o>i)&&(r=a)}return r}function HNn(e){switch(e.type){case"Integer":return e.value.toLocaleString("en-US");case"Float":return e.value.toLocaleString("en-US",{maximumFractionDigits:2});case"DateTime":return e.value.toISOString().slice(0,10);case"Boolean":return String(e.value);case"String":return e.value;default:return"—"}}const J5e=function({value:t,height:n="100%",rowHeight:r=36,overscan:a=8,onSortChange:o,enableMultiSort:i=!0,maxSortColumns:s=5,loadingDelay:l=0,enableColumnResizing:c,storageKey:u,hidePaginationBand:d}){var f,h,g;const v=C.useMemo(()=>BNn(t),[t]),b=C.useRef(null),y=_(t.style),x=_(t.onCellClick),S=_(t.onCellDoubleClick),z=_(t.onRowClick),M=_(t.onRowDoubleClick),L=_(t.onSortChange),R=_(t.onRowSelectionChange),N=_(t.columnResize),O=N!==void 0?N:c??!0,j=_(t.virtualization)!==!1,B=y?_(y.headerBackground):void 0,H=y?_(y.headerColor)??"gray.500":"gray.500",K=y?_(y.borderColor):void 0,U=y?_(y.zebraBackground):void 0,Z=y?_(y.hoverBackground):void 0,G=y?_(y.selectedBackground):void 0,W=y?_(y.selectedBorderColor):void 0,J=y?_(y.footerBackground):void 0,ae=(f=_(t.density))==null?void 0:f.type,ne=ae==="compact"||ae==="condensed"?"sm":ae==="comfortable"?"lg":v.size??"md",Y=ne==="sm"?6:ne==="lg"?12:10,te=wI(ne).row,ie=y?_(y.rowHeight):void 0,ue=ie!==void 0?Number(ie):void 0,oe=ne==="sm"?"8px":ne==="lg"?"16px":"14px",ve=`${Y}px`,se=en({key:"table"})({size:ne}),pe=se,de=_(t.expandedContent),[ge,ye]=C.useState(()=>new Set),me=C.useCallback(ft=>{ye(Nt=>{const sn=new Set(Nt);return sn.has(ft)?sn.delete(ft):sn.add(ft),sn})},[]),Me=mXe(_(t.rowStatus)),[Te]=C.useState(()=>new yXe),[Be,ht]=C.useState(new Map);C.useEffect(()=>Te.subscribe(()=>{ht(new Map(Te.getStates()))}),[Te]),C.useEffect(()=>()=>{Te.clear()},[Te]);const De=C.useMemo(()=>_(t.review),[t.review]),Qe=De!==void 0,bt=C.useMemo(()=>_(t.reviewStatus),[t.reviewStatus]),Ve=C.useMemo(()=>_(t.reviewApproval),[t.reviewApproval]),ut=C.useMemo(()=>t.rows.map((ft,Nt)=>Ve==null?void 0:Ve(BigInt(Nt))),[t,Ve]),_t=ok(De,ut),Ft=en({key:"reviewChrome"}),wt=C.useMemo(()=>Ft({}),[Ft]),Lt=C.useMemo(()=>{const ft={};for(const Nt of["success","warning","danger","info","neutral"])ft[Nt]=Ft({status:Nt}).statusDot??{};return ft},[Ft]),Jt=gI(),Dt=C.useMemo(()=>t.columns.map(ft=>{const Nt=zr(ft.valueType),sn=Tn(ft.valueType),Fn=_(ft.width),xn=_(ft.minWidth),Pa=_(ft.maxWidth),Qr=ft.render;return Jt.accessor(cr=>cr.get(ft.key),{id:ft.key,header:_(ft.header)??ft.key,enableSorting:!0,sortingFn:(cr,Ar,Cr)=>{const Aa=cr.original.get(Cr),qo=Ar.original.get(Cr),bo=Aa==null?void 0:Aa.value,qr=qo==null?void 0:qo.value;return bo===void 0||qr===void 0?0:sn(bo,qr)},minSize:$V(xn,80),size:$V(Fn,150),maxSize:$V(Pa,400),meta:{print:Nt,columnKey:ft.key,width:Fn,minWidth:xn,maxWidth:Pa,renderFn:Qr}})}),[t.columns,Jt]),Et=C.useMemo(()=>!Qe||De===void 0?Dt:[...Dt,Jt.display({id:l8,header:De.columnLabel,enableSorting:!1,enableResizing:!1,enablePinning:!0,size:parseInt(m6,10),meta:{columnKey:l8,width:m6}})],[Dt,Jt,Qe,De]),{state:Gt,setState:Ke}=Pl(u,{sorting:[],columnSizing:{},pinnedColumns:[...t.frozen],scrollIndex:0}),Se=Gt.sorting,Re=C.useCallback(ft=>{Ke(Nt=>({...Nt,sorting:typeof ft=="function"?ft(Nt.sorting):ft}))},[Ke]),qe=_(t.selection),Ye=(h=qe==null?void 0:qe.mode)==null?void 0:h.type,$e=qe==null?void 0:qe.selected,lt=qe==null?void 0:qe.onChange,Pe=$e!==void 0,[ot,kt]=C.useState({}),Mt=C.useMemo(()=>{if($e){const ft={};for(const Nt of $e)ft[String(Nt)]=!0;return ft}return ot},[$e,ot]),At=C.useRef(null),fn=C.useCallback(ft=>{const Nt=Mt,sn=typeof ft=="function"?ft(Nt):ft,Fn=Object.keys(sn).filter(xn=>sn[xn]).map(xn=>BigInt(parseInt(xn,10)));if(R){const xn=new Set(Object.keys(Nt).filter(Qr=>Nt[Qr])),Pa=new Set(Object.keys(sn).filter(Qr=>sn[Qr]));for(const Qr of Pa)if(!xn.has(Qr)){const cr=BigInt(parseInt(Qr,10));queueMicrotask(()=>R({rowIndex:cr,selected:!0,selectedRowsIndices:Fn}))}for(const Qr of xn)if(!Pa.has(Qr)){const cr=BigInt(parseInt(Qr,10));queueMicrotask(()=>R({rowIndex:cr,selected:!1,selectedRowsIndices:Fn}))}}lt&&queueMicrotask(()=>lt(Fn)),Pe||kt(sn)},[Mt,Pe,R,lt]),rt=C.useCallback((ft,Nt)=>{const sn=Mt;let Fn;const xn=!!sn[String(ft)];if(Ye==="single")Fn=xn?{}:{[String(ft)]:!0};else if(Ye==="range"&&Nt&&At.current!==null){const Pa=Math.min(At.current,ft),Qr=Math.max(At.current,ft);Fn={...sn};for(let cr=Pa;cr<=Qr;cr++)Fn[String(cr)]=!0}else Fn={...sn},xn?delete Fn[String(ft)]:Fn[String(ft)]=!0;fn(Fn),At.current=ft},[Mt,Ye,fn]),ln=C.useCallback(ft=>{Re(Nt=>{const sn=typeof ft=="function"?ft(Nt):ft,Fn=sn.map(xn=>({columnKey:xn.id,direction:xn.desc?"desc":"asc"}));return o==null||o(Fn),L&&sn.forEach((xn,Pa)=>{queueMicrotask(()=>L({columnKey:xn.id,sortIndex:BigInt(Pa),sortDirection:xn.desc?$("desc",null):$("asc",null)}))}),sn})},[o,L,Re]),Mn=C.useCallback((ft,Nt,sn)=>{x&&sn!==void 0&&queueMicrotask(()=>x({rowIndex:ft,columnKey:Nt,cellValue:sn}))},[x]),Jn=C.useCallback((ft,Nt,sn)=>{S&&sn!==void 0&&queueMicrotask(()=>S({rowIndex:ft,columnKey:Nt,cellValue:sn}))},[S]),Er=C.useCallback(ft=>{z&&queueMicrotask(()=>z({rowIndex:ft}))},[z]),_r=C.useCallback(ft=>{M&&queueMicrotask(()=>M({rowIndex:ft}))},[M]),fr=Gt.columnSizing,Vr=C.useCallback(ft=>{Ke(Nt=>({...Nt,columnSizing:typeof ft=="function"?ft(Nt.columnSizing):ft}))},[Ke]),wr=C.useMemo(()=>Gt.pinnedColumns??[...t.frozen],[Gt.pinnedColumns,t.frozen]),pa=C.useMemo(()=>({left:wr,right:Qe?[l8]:[]}),[wr,Qe]),ar=wr.length>0,On=C.useCallback(ft=>{Ke(Nt=>{const sn=Nt.pinnedColumns??[...t.frozen],Fn=sn.includes(ft);return{...Nt,pinnedColumns:Fn?sn.filter(xn=>xn!==ft):[...sn,ft]}})},[Ke,t.frozen]),st=_(t.pagination),dn=st?Number(st.pageSize):void 0,Pn=st?Number(st.page):0,Hn=st==null?void 0:st.onPageChange,pr=dn?Math.max(1,Math.ceil(t.rows.length/dn)):1,Hr=C.useMemo(()=>{if(!dn)return t.rows;const ft=Pn*dn;return t.rows.slice(ft,ft+dn)},[t.rows,dn,Pn]),lr=yI({data:Hr,columns:Et,state:{sorting:Se,columnSizing:fr,rowSelection:Mt,columnPinning:pa},onSortingChange:ln,onColumnSizingChange:Vr,onRowSelectionChange:fn,getCoreRowModel:vI(),getSortedRowModel:dXe(),enableMultiSort:i,isMultiSortEvent:()=>i,maxMultiSortColCount:s,enableColumnResizing:O,columnResizeMode:"onChange",enableRowSelection:!0,enableColumnPinning:!0}),{rows:vr}=lr.getRowModel(),mo=C.useMemo(()=>_(t.groupBy),[t.groupBy]),Fe=C.useMemo(()=>{const ft=new Map;for(const Nt of t.columns){const sn=_(Nt.aggregate);sn!==void 0&&ft.set(Nt.key,{tag:sn.type,renderFn:_(Nt.aggregateRender)})}return ft},[t.columns]),Qt=Gt.groupCollapse,tt=C.useMemo(()=>{if(mo===void 0||mo.length===0)return;const ft=dn?Pn*dn:0,Nt=new Map;vr.forEach((Ar,Cr)=>Nt.set(Ar.index,Cr));const sn=new Map(vr.map(Ar=>[Ar.index,Ar])),Fn={path:"",children:new Map,order:[],members:[]},xn=vr.length;for(let Ar=0;Ar<xn;Ar++){if(sn.get(Ar)===void 0)continue;let Aa=Fn;for(let qo=0;qo<mo.length;qo++){const bo=mo[qo].keys[ft+Ar]??"";let qr=Aa.children.get(bo);qr===void 0&&(qr={path:`${Aa.path}\0${bo}`,depth:qo,label:bo,children:new Map,order:[],members:[]},Aa.children.set(bo,qr),Aa.order.push(qr)),Aa=qr}Aa.members.push(Ar)}const Pa=Ar=>Ar.children.size===0?Ar.members:Ar.order.flatMap(Pa),Qr=[],cr=Ar=>{for(const Cr of Ar.order){const Aa=Pa(Cr),qo=new Map;for(const[qr,{tag:Gs}]of Fe){const yr=Aa.map(Jr=>{var ja,ta;return(ta=(ja=sn.get(Jr))==null?void 0:ja.original)==null?void 0:ta.get(qr)}).filter(Jr=>Jr!==void 0);qo.set(qr,VNn(Gs,yr))}const bo=(Qt==null?void 0:Qt[Cr.path])??mo[Cr.depth].collapsed;Qr.push({kind:"group",path:Cr.path,depth:Cr.depth,label:Cr.label,count:Aa.length,collapsed:bo,aggregates:qo}),!bo&&(Cr.depth===mo.length-1?[...Cr.members].sort((qr,Gs)=>(Nt.get(qr)??0)-(Nt.get(Gs)??0)).forEach(qr=>Qr.push({kind:"leaf",row:sn.get(qr)})):cr(Cr))}};return cr(Fn),Qr},[mo,vr,Fe,Qt,Pn,dn]),gt=C.useCallback((ft,Nt)=>{Ke(sn=>({...sn,groupCollapse:{...sn.groupCollapse??{},[ft]:!Nt}}))},[Ke]),Ot=tt!==void 0?tt.length:vr.length,yn=C.useMemo(()=>{const ft=lr.getFlatHeaders(),Nt={};return ft.forEach(sn=>{Nt[`--header-${sn.id}-size`]=`${sn.getSize()}px`,Nt[`--col-${sn.column.id}-size`]=`${sn.column.getSize()}px`}),Nt},[lr.getState().columnSizingInfo,lr.getState().columnSizing]),Bt=ue??(ae?te:r),vn=bI({count:Ot,getScrollElement:()=>b.current,estimateSize:()=>Bt,overscan:a,measureElement:ft=>ft==null?void 0:ft.getBoundingClientRect().height}),wn=C.useMemo(()=>j?vn.getVirtualItems():Array.from({length:Ot},(ft,Nt)=>({index:Nt,start:Nt*Bt,end:(Nt+1)*Bt,size:Bt,key:Nt,lane:0})),[j,vn,Ot,Bt,vn.getVirtualItems()]),Or=C.useRef(void 0),Zr=C.useCallback(()=>{Or.current&&clearTimeout(Or.current),Or.current=setTimeout(()=>{var ft,Nt;const sn=j?((ft=vn.getVirtualItems()[0])==null?void 0:ft.index)??0:Math.round((((Nt=b.current)==null?void 0:Nt.scrollTop)??0)/Bt);Ke(Fn=>Fn.scrollIndex===sn?Fn:{...Fn,scrollIndex:sn})},150)},[j,vn,Bt,Ke]),qn=C.useRef(!1);C.useEffect(()=>{if(qn.current||vr.length===0)return;qn.current=!0;const ft=Gt.scrollIndex??0;if(ft<=0)return;const Nt=Math.min(ft,vr.length-1);requestAnimationFrame(()=>{j?vn.scrollToIndex(Nt,{align:"start"}):b.current&&(b.current.scrollTop=Nt*Bt)})},[vr.length]),C.useEffect(()=>{const ft=new Set;wn.forEach(sn=>{ft.add(sn.index)});const Nt=[];ft.forEach(sn=>{Te.getRowState(sn).status==="unloaded"&&Nt.push(sn)}),Nt.length>0&&(l>0?(Te.markRowsLoading(Nt),Nt.forEach(sn=>Te.scheduleLoaded(sn,l))):Te.markRowsLoaded(Nt))},[wn,Te,l]);const ca=C.useCallback(ft=>{const Nt=Se.findIndex(sn=>sn.id===ft);return Nt>=0?Nt+1:void 0},[Se]),sa=C.useMemo(()=>ar?lr.getLeftLeafColumns().reduce((ft,Nt)=>ft+Nt.getSize(),0):0,[ar,lr.getState().columnSizing,lr.getState().columnSizingInfo]),vo=N7(),Ya=y?_(y.plotGutter):void 0,Ha=(Ya?_(Ya.left):void 0)??(vo==null?void 0:vo.left),fi=(Ya?_(Ya.right):void 0)??(vo==null?void 0:vo.right),Ma=Ha!==void 0||fi!==void 0,Wa=fi??"0px",Sa=w9(Ha),Oa=Ma&&Sa!==void 0&&sa>0?Sa/sa:1,Nl=Ma&&Sa!==void 0&&sa===0?Ha:void 0,$l=ft=>Ma&&!ft.getIsPinned()?{flex:"1 1 0",width:"auto",minWidth:0,position:"relative",left:void 0,justifyContent:"center",textAlign:"center"}:{},Il=ft=>{const Nt=ft.getIsPinned();return{borderRight:Nt==="left"&&ft.getIsLastColumn("left")?"2px solid var(--chakra-colors-border, #e2e8f0)":void 0,left:Nt==="left"?`${ft.getStart("left")}px`:void 0,right:Nt==="right"?`${ft.getAfter("right")}px`:void 0,position:Nt?"sticky":"relative",width:ft.getSize()*Oa,zIndex:Nt?1:0,backgroundColor:Nt?"var(--chakra-colors-bg-canvas, #fafafa)":void 0}},M1=Tt(y?_(y.height):void 0),Sc=Tt(y?_(y.maxHeight):void 0),yo=!ar&&!Ma?(g=lr.getVisibleLeafColumns().filter(ft=>ft.id!==l8&&!ft.getIsPinned()).at(-1))==null?void 0:g.id:void 0,il=p.jsxs(V,{ref:b,onScroll:Zr,height:M1??n,maxHeight:Sc,overflowY:"auto",overflowX:Ma?"hidden":"auto",overscrollBehaviorX:"contain",css:M1!==void 0||Sc!==void 0?xI:void 0,position:"relative",...Ma?{width:"100%"}:{},children:[p.jsxs(CK,{...v,size:ne,style:{...yn,width:Ma?"100%":ar?lr.getCenterTotalSize()+sa:"100%",minWidth:Ma?0:ar?lr.getCenterTotalSize()+sa:lr.getCenterTotalSize(),tableLayout:"fixed"},children:[p.jsxs(lNe,{style:{display:"block"},position:"sticky",top:0,zIndex:2,bg:"bg.canvas",children:[(()=>{const ft=_(t.columnGroups);return!ft||ft.length===0?null:p.jsx($f,{style:{display:"flex",width:"100%"},children:(()=>{const Nt=!ar&&Object.keys(fr).length===0&&t.columns.every(sn=>_(sn.width)===void 0);return ft.map((sn,Fn)=>{const xn=Array.from(sn.columnKeys);if(xn.length===0)return null;const Pa=xn.map(cr=>`var(--col-${cr}-size)`).join(" + "),Qr=yo!==void 0&&xn.includes(yo);return p.jsx(xf,{bg:B,color:H,style:{width:`calc(${Pa})`,minWidth:`calc(${Pa})`,flex:Nt?`${xn.length} 1 0%`:Qr?"1 0 auto":"none",borderColor:K,paddingLeft:oe,paddingRight:oe,paddingTop:ve,paddingBottom:ve,textAlign:"center",fontWeight:600,borderBottomWidth:0},children:sn.label},`group-${Fn}`)})})()},"column-groups")})(),lr.getHeaderGroups().map(ft=>p.jsxs($f,{style:{display:"flex",width:"100%"},children:[de&&p.jsx(xf,{bg:B,color:H,style:{width:"32px",flex:"none",borderColor:K,paddingLeft:0,paddingRight:0}},"expand-toggle-col-header"),Ye&&p.jsx(xf,{bg:B,color:H,style:{width:"40px",flex:"none",borderColor:K,paddingLeft:0,paddingRight:0,textAlign:"center"},children:Ye==="multiple"&&p.jsx("input",{type:"checkbox","aria-label":"Select all rows",checked:vr.length>0&&Object.values(Mt).filter(Boolean).length===vr.length,ref:Nt=>{if(Nt){const sn=Object.values(Mt).some(Boolean),Fn=vr.length>0&&Object.values(Mt).filter(Boolean).length===vr.length;Nt.indeterminate=sn&&!Fn}},onChange:()=>{const Nt=vr.length>0&&Object.values(Mt).filter(Boolean).length===vr.length,sn={};if(!Nt)for(let Fn=0;Fn<vr.length;Fn++)sn[String(Fn)]=!0;fn(sn)}})},"selection-col-header"),Nl!==void 0&&p.jsx(xf,{"aria-hidden":"true",bg:B,style:{flex:"none",width:Nl,padding:0,borderColor:K,height:`${Bt}px`}}),ft.headers.map(Nt=>{var sn;if(Nt.column.id===l8)return p.jsx(xf,{css:wt.decisionHeader,"data-slot":"decisionHeader",style:{width:`var(--header-${Nt.id}-size)`,flex:"none",height:`${Bt}px`,...Il(Nt.column),zIndex:3,borderColor:K},position:"sticky",children:eX(Nt.column.columnDef.header,Nt.getContext())},Nt.id);const Fn=ca(Nt.id),xn=Nt.column.getIsSorted(),Qr=xn?(xn||null)==="asc"?x$:au:k$,cr=ar?Il(Nt.column):{},Ar=Nt.column.getIsPinned(),Cr=Ma&&!Ar;return p.jsxs(xf,{css:se.columnHeader,bg:B,color:H,_hover:{bg:B??"bg.muted","& .col-controls":{opacity:1},"& .col-resizer::before":{opacity:1}},transition:"background 0.2s",style:{width:`var(--header-${Nt.id}-size)`,flex:ar?"none":fr[Nt.id]||(sn=Nt.column.columnDef.meta)!=null&&sn.width?Nt.column.id===yo?"1 0 auto":"none":1,...cr,zIndex:Ar?3:void 0,borderColor:K,height:`${Bt}px`,display:"flex",alignItems:"center",...$l(Nt.column)},position:Ar&&!Ma?"sticky":"relative",children:[p.jsxs(Xr,{justify:"space-between",align:"center",width:"100%",pr:Cr?"0":O?"4px":"0",children:[p.jsx(V,{as:"span",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"1",textAlign:Cr?"center":void 0,children:Nt.isPlaceholder?null:eX(Nt.column.columnDef.header,Nt.getContext())}),p.jsxs(Xr,{className:"col-controls",gap:0,flexShrink:0,alignItems:"center",display:Cr?"none":void 0,css:{opacity:Ar||xn?1:0,"@media (hover: none)":{opacity:Ar||xn?1:.6}},transition:"opacity 0.15s",children:[p.jsx(V,{as:"button","aria-label":Ar?`Unpin ${Nt.id}`:`Pin ${Nt.id}`,onClick:Aa=>{Aa.stopPropagation(),On(Nt.id)},color:Ar?"fg.default":"fg.muted",_hover:{color:"fg.default",bg:"bg.emphasized"},transition:"color 0.15s",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",w:"24px",h:"24px",css:NV,borderRadius:"sm",children:p.jsx(Ut,{icon:WC,style:{width:"10px",height:"10px",transform:Ar?void 0:"rotate(45deg)"}})}),Nt.column.getCanSort()&&p.jsxs(V,{as:"button","aria-label":`Sort by ${Nt.id}`,onClick:Aa=>{Aa.stopPropagation(),Nt.column.toggleSorting(void 0,i)},color:xn?"fg.default":"fg.muted",_hover:{color:"fg.default",bg:"bg.emphasized"},cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",w:"24px",h:"24px",css:NV,borderRadius:"sm",position:"relative",children:[p.jsx(Ut,{icon:Qr,style:{width:"10px",height:"10px"}}),xn&&Fn&&i&&p.jsx(Ie,{fontSize:"7px",fontWeight:"bold",color:"fg.muted",lineHeight:"1",position:"absolute",top:"4px",right:"4px",children:Fn})]})]})]}),O&&Nt.column.getCanResize()&&p.jsx(V,{className:"col-resizer",position:"absolute",right:"0",top:"0",bottom:"0",width:"6px",cursor:"ew-resize",bg:"transparent",_hover:{_before:{opacity:1,bg:"fg.muted"}},transition:"all 0.2s",zIndex:10,onMouseDown:Nt.getResizeHandler(),onTouchStart:Nt.getResizeHandler(),_before:{content:'""',position:"absolute",right:"2px",top:"30%",bottom:"30%",width:"1px",bg:"gray.300",opacity:0,transition:"opacity 0.2s"}})]},Nt.id)}),Ma&&p.jsx(xf,{"aria-hidden":"true",bg:"bg.surface",style:{flex:"none",width:Wa,padding:0,border:"none",height:`${Bt}px`}})]},ft.id))]}),p.jsx(kK,{style:{display:"block",position:"relative",height:`${vn.getTotalSize()}px`},children:wn.map(ft=>{var Nt;const sn=tt!==void 0?tt[ft.index]:void 0;if(sn!==void 0&&sn.kind==="group"){const yr=sn;return p.jsx("div",{"data-index":ft.index,ref:vn.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${ft.start}px)`},children:p.jsx($f,{css:pe.groupHead,"data-slot":"groupHead","data-depth":yr.depth,display:"flex",width:"100%",onClick:()=>gt(yr.path,yr.collapsed),children:lr.getVisibleLeafColumns().map((Jr,ja)=>{var ta;const Io=ar?"none":fr[Jr.id]||(ta=Jr.columnDef.meta)!=null&&ta.width?Jr.id===yo?"1 0 auto":"none":1,xi={width:`var(--col-${Jr.id}-size)`,flex:Io,display:"flex",alignItems:"center",minHeight:`${Bt}px`};if(Jr.id===l8)return p.jsx(ds,{css:pe.groupHeadCell,style:{...xi,flex:"none"}},Jr.id);if(ja===0)return p.jsxs(ds,{css:pe.groupHeadCell,"data-slot":"groupHeadLabel",style:{...xi,cursor:"pointer",paddingLeft:`${12+yr.depth*18}px`,gap:"8px",overflow:"visible",whiteSpace:"nowrap"},children:[p.jsx(Ut,{icon:yr.collapsed?r2:au,style:{width:9,height:9}}),yr.label===""?"—":yr.label]},Jr.id);const wi=yr.aggregates.get(Jr.id),pi=Fe.get(Jr.id);return wi===void 0||pi===void 0?p.jsx(ds,{css:pe.groupHeadCell,style:xi},Jr.id):p.jsx(ds,{css:pe.groupHeadAggregate,"data-slot":"groupHeadAggregate",style:xi,children:pi.renderFn!==void 0?p.jsx(mn,{value:pi.renderFn(wi),storageKey:`${u??"table"}.group.${yr.path}.${Jr.id}`}):HNn(wi)},Jr.id)})})},`group:${yr.path}`)}const Fn=sn!==void 0?sn.row:vr[ft.index];if(!Fn)return null;const xn=ft.index,Pa=Be.get(xn)||{status:"unloaded"},Qr=!Te.isRowLoaded(xn)||Pa.status==="loading",cr=BigInt(Fn.index),Ar=!!((Nt=Fn.getIsSelected)!=null&&Nt.call(Fn)),Cr=ft.index%2===1,Aa=Me(ft.index),qo=v.striped&&Cr?U??"var(--chakra-colors-bg-subtle, color-mix(in srgb, currentColor 12%, transparent))":void 0,bo=Aa??(Ar?G:void 0)??qo,qr=ge.has(ft.index),Gs=ue!==void 0&&!qr?{height:`${Bt}px`,overflow:"hidden"}:{minHeight:`${Bt}px`};return p.jsxs("div",{"data-index":ft.index,ref:vn.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${ft.start}px)`,background:bo},children:[p.jsxs($f,{"data-selected":Ar?"true":void 0,style:{display:"flex",width:"100%",...Gs,cursor:z||M?"pointer":void 0,background:"transparent",boxShadow:Ar&&W?`inset 0 0 0 2px ${W}`:void 0},...Z?{_hover:{bg:Z}}:{},onClick:z?()=>Er(cr):void 0,onDoubleClick:M?()=>_r(cr):void 0,children:[Ye&&p.jsx(ds,{style:{width:"40px",flex:"none",display:"flex",alignItems:"center",justifyContent:"center",padding:0,borderColor:K,background:"transparent"},onClick:yr=>yr.stopPropagation(),children:p.jsx("input",{type:Ye==="single"?"radio":"checkbox",checked:Ar,"aria-label":`Select row ${ft.index+1}`,onChange:()=>rt(ft.index,!1),onClick:yr=>{yr.shiftKey&&(yr.preventDefault(),rt(ft.index,!0))}})},"selection"),de&&p.jsx(ds,{style:{width:"32px",flex:"none",display:"flex",alignItems:"center",justifyContent:"center",padding:0,background:"transparent",borderColor:K},onClick:yr=>{yr.stopPropagation(),me(ft.index)},children:p.jsx(V,{as:"button","aria-label":qr?"Collapse row":"Expand row","aria-expanded":qr,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",w:"24px",h:"24px",css:NV,borderRadius:"sm",color:"fg.muted",_hover:{color:"fg.default",bg:"bg.emphasized"},transition:"transform 0.15s",transform:qr?"rotate(90deg)":"none",children:p.jsx(Ut,{icon:r2,style:{width:10,height:10}})})},"expand-toggle"),Nl!==void 0&&p.jsx(ds,{"aria-hidden":"true",style:{flex:"none",width:Nl,padding:0,borderColor:K}}),Fn.getVisibleCells().map(yr=>{var Jr;if(yr.column.id===l8&&_t!==void 0){const Xe=(dn?Pn*dn:0)+Fn.index,Rt=bt==null?void 0:bt(BigInt(Xe)),an=(Rt==null?void 0:Rt.type)==="some"?Rt.value.type:void 0;return p.jsxs(ds,{css:wt.decisionCol,"data-slot":"decisionCol","data-status":an,onClick:Rn=>Rn.stopPropagation(),style:{width:`var(--col-${yr.column.id}-size)`,flex:"none",display:"flex",alignItems:"center",borderColor:K,...Il(yr.column),position:"sticky",zIndex:2},children:[an!==void 0&&p.jsx(V,{as:"span",css:Lt[an],"data-slot":"statusDot",position:"absolute",left:"12px"}),p.jsx(SI,{rowIndex:Xe,controller:_t})]},yr.id)}const ja=yr.getValue(),ta=yr.column.columnDef.meta,Io=(ta==null?void 0:ta.columnKey)??yr.column.id,xi=ar?Il(yr.column):{},wi={width:`var(--col-${yr.column.id}-size)`,flex:ar?"none":fr[yr.column.id]||ta!=null&&ta.width?yr.column.id===yo?"1 0 auto":"none":1,display:"flex",alignItems:"center",overflow:"hidden",borderColor:K,background:xi.backgroundColor??"transparent",...xi,...$l(yr.column)},pi=x?Xe=>{Xe.stopPropagation(),Mn(cr,Io,ja)}:void 0,Dl=S?Xe=>{Xe.stopPropagation(),Jn(cr,Io,ja)}:void 0;if(Qr)return p.jsx(ds,{css:se.cell,style:wi,children:p.jsx(d4,{height:"20px",width:"80%"})},yr.id);if(ja==null)return p.jsx(ds,{css:se.cell,style:wi,onClick:pi,onDoubleClick:Dl},yr.id);if(ta!=null&&ta.renderFn){const Xe=ta.renderFn({rowIndex:cr,columnKey:Io,cellValue:ja});return p.jsx(ds,{css:se.cell,style:wi,onClick:pi,onDoubleClick:Dl,children:p.jsx(mn,{value:Xe,storageKey:`${u}.render.${yr.column.id}`})},yr.id)}return p.jsx(ds,{css:se.cell,style:wi,onClick:pi,onDoubleClick:Dl,children:p.jsx(Ie,{children:((Jr=ta==null?void 0:ta.print)==null?void 0:Jr.call(ta,ja.value))??null})},yr.id)}),Ma&&p.jsx(ds,{"aria-hidden":"true",bg:"bg.surface",style:{flex:"none",width:Wa,padding:0,border:"none"}})]}),de&&qr&&(()=>{const yr=de(cr);return p.jsx(V,{bg:"bg.subtle",borderTop:"1px solid",borderBottom:"1px solid",borderColor:K??"border.subtle",padding:"3",children:p.jsx(mn,{value:yr,storageKey:`${u}.expand.${ft.index}`})})})()]},Fn.id)})}),(()=>{const ft=_(t.footer),Nt=_(t.footerRows),sn=[];if(ft&&sn.push(ft),Nt)for(const Fn of Nt)sn.push(Fn);return sn.length===0?null:p.jsx(VIt,{style:{display:"block"},children:sn.map((Fn,xn)=>{var Pa;const Qr=[];let cr=0;for(let Ar=0;Ar<t.columns.length;Ar++){if(cr>0){cr--;continue}const Cr=t.columns[Ar].key,Aa=(Pa=Fn.get)==null?void 0:Pa.call(Fn,Cr),qo=Aa?Number(_(Aa.colSpan)??1n):1;cr=qo-1;const bo=Array.from({length:qo},(ta,Io)=>`var(--col-${t.columns[Ar+Io].key}-size)`).join(" + "),qr=!ar&&Object.keys(fr).length===0&&t.columns.every(ta=>_(ta.width)===void 0),Gs=qo>1?`calc(${bo})`:`var(--col-${Cr}-size)`,yr=yo!==void 0&&Array.from({length:qo},(ta,Io)=>t.columns[Ar+Io].key).includes(yo),Jr={width:Gs,minWidth:Gs,flex:qr?`${qo} 1 0%`:yr?"1 0 auto":"none",display:"flex",alignItems:"center",overflow:"hidden",paddingLeft:oe,paddingRight:oe,paddingTop:ve,paddingBottom:ve,background:J,borderColor:K,fontWeight:600},ja=Aa==null?void 0:Aa.content;Qr.push(p.jsx(ds,{css:se.cell,style:Jr,children:ja?p.jsx(mn,{value:ja,storageKey:`${u}.footer.${xn}.${Cr}`}):null},`${xn}-${Cr}`))}return p.jsx($f,{style:{display:"flex",width:"100%"},children:Qr},`footer-${xn}`)})})})()]}),st&&!d&&p.jsxs(Xr,{gap:"2",justify:"flex-end",px:"3",py:"2",borderTop:"1px solid",borderColor:"border.subtle",children:[p.jsxs(Ie,{fontSize:"sm",color:"fg.muted",children:["Page ",Pn+1," of ",pr," (",t.rows.length," total)"]}),p.jsx("button",{type:"button","aria-label":"Previous page",disabled:Pn<=0,style:{cursor:Pn<=0?"not-allowed":"pointer",opacity:Pn<=0?.4:1,padding:"4px 8px",borderRadius:"4px",border:"none",background:"transparent"},onClick:()=>{Pn<=0||Hn&&queueMicrotask(()=>Hn(BigInt(Pn-1)))},children:p.jsx(Ut,{icon:kd,style:{width:10,height:10}})}),p.jsx("button",{type:"button","aria-label":"Next page",disabled:Pn>=pr-1,style:{cursor:Pn>=pr-1?"not-allowed":"pointer",opacity:Pn>=pr-1?.4:1,padding:"4px 8px",borderRadius:"4px",border:"none",background:"transparent"},onClick:()=>{Pn>=pr-1||Hn&&queueMicrotask(()=>Hn(BigInt(Pn+1)))},children:p.jsx(Ut,{icon:r2,style:{width:10,height:10}})})]}),_t!==void 0&&_t.showFoot&&p.jsx(ik,{controller:_t,storageKey:u??"table"})]});return ae!==void 0?p.jsx(hu,{value:ae,children:il}):il},WNn=C.memo(function(t){const n=_(t.value.slice),r=n==null?void 0:n.slice;rl(r==null?void 0:r.key);const a=en({key:"sliceFrame"})();if(n===void 0||r===void 0)return p.jsx(J5e,{...t});const o=r.read(),i=n.affordances.map(b=>b.type),s=Lv(i,o),l=Number(r.totalCount()),c=Number(r.resultCount()),u=l>0?Math.round((1-c/l)*100):0,d=_(t.value.pagination),f=d?Number(d.pageSize):0,h=d?Number(d.page):0,g=d?Math.max(1,Math.ceil(t.value.rows.length/f)):1,v=d==null?void 0:d.onPageChange;return p.jsxs(V,{css:{...a.root,height:"100%",minHeight:0,display:"flex",flexDirection:"column"},children:[p.jsx(V,{css:{...a.frameEyebrow,flexShrink:0},children:p.jsx(zd,{slice:r,affordanceKinds:s})}),p.jsx(V,{css:{...a.frameBody,flex:"1 1 0%",minHeight:0,overflow:"hidden"},children:p.jsx(J5e,{...t,hidePaginationBand:!0})}),p.jsxs(V,{css:{...a.frameFooter,flexShrink:0},children:[p.jsx(V,{as:"span",css:a.frameFooterStat,children:c.toLocaleString()}),p.jsx(V,{as:"span",children:`rows · of ${l.toLocaleString()}`}),u>0&&p.jsx(V,{as:"span",css:a.frameFooterDelta,children:`· −${u}%`}),d&&p.jsxs(V,{display:"inline-flex",alignItems:"center",gap:"{spacing.1.5}",marginLeft:"auto",children:[p.jsx(V,{as:"span",children:`page ${h+1} of ${g}`}),p.jsx(Ht.button,{type:"button","aria-label":"Previous page",disabled:h<=0,cursor:h<=0?"not-allowed":"pointer",opacity:h<=0?.4:1,onClick:()=>{h<=0||!v||queueMicrotask(()=>v(BigInt(h-1)))},children:p.jsx(Ut,{icon:kd,style:{width:9,height:9}})}),p.jsx(Ht.button,{type:"button","aria-label":"Next page",disabled:h>=g-1,cursor:h>=g-1?"not-allowed":"pointer",opacity:h>=g-1?.4:1,onClick:()=>{h>=g-1||!v||queueMicrotask(()=>v(BigInt(h+1)))},children:p.jsx(Ut,{icon:r2,style:{width:9,height:9}})})]})]})]})},(e,t)=>FNn(e.value,t.value));zv.add(_v,Eoe,Loe);const UNn=it(Dq.Types.Icon),qNn={xs:"xs",sm:"sm",md:void 0,lg:"lg",xl:"xl","2xl":"2xl"};function GNn(e){var t,n;const r=_(e.style),a=_(e.label),o=r?(t=_(r.size))==null?void 0:t.type:void 0,i=r?_(r.color):void 0,s=r?(n=_(r.colorPalette))==null?void 0:n.type:void 0,l=o?qNn[o]:void 0;return{icon:[e.prefix,e.name],size:l,color:i??(s?`var(--chakra-colors-${s}-500)`:void 0),...a!==void 0?{title:a}:{"aria-hidden":!0}}}function KNn(e){var t,n,r;const a=_(e.style);if(!a)return;const o=_(a.padding),i=_(a.margin),s=_(a.opacity),l=_(a.background),c=_(a.borderRadius),u=(t=_(a.overflow))==null?void 0:t.type,d=(n=_(a.overflowX))==null?void 0:n.type,f=(r=_(a.overflowY))==null?void 0:r.type,h=_(a.width),g=_(a.height),v=_(a.minWidth),b=_(a.minHeight),y=_(a.maxWidth),x=_(a.maxHeight);if(!(s===void 0&&l===void 0&&c===void 0&&u===void 0&&d===void 0&&f===void 0&&h===void 0&&g===void 0&&v===void 0&&b===void 0&&y===void 0&&x===void 0&&!o&&!i))return{display:"inline-block",opacity:s,background:l,borderRadius:c,overflow:u,overflowX:d,overflowY:f,width:h,height:g,minWidth:v,minHeight:b,maxWidth:y,maxHeight:x,pt:o?_(o.top):void 0,pr:o?_(o.right):void 0,pb:o?_(o.bottom):void 0,pl:o?_(o.left):void 0,mt:i?_(i.top):void 0,mr:i?_(i.right):void 0,mb:i?_(i.bottom):void 0,ml:i?_(i.left):void 0}}const bXe=C.memo(function({value:t}){const n=C.useMemo(()=>GNn(t),[t]),r=C.useMemo(()=>KNn(t),[t]);return r?p.jsx(V,{...r,children:p.jsx(Ut,{...n})}):p.jsx(Ut,{...n})},(e,t)=>UNn(e.value,t.value)),YNn=it(Xb.Types.Root);function xXe(e){return e.map(t=>Sr(t,{Item:n=>({value:n.value,label:n.label,indicator:n.indicator,children:[]}),Branch:n=>({value:n.value,label:n.label,indicator:n.indicator,disabled:_(n.disabled)??!1,children:xXe(n.children)})}))}const XNn=C.memo(function({value:t,storageKey:n}){var r,a;const o=_(t.style),i=_(t.label),s=_(t.defaultExpandedValue),l=_(t.defaultSelectedValue),c=_(t.selectionMode),u=o?_(o.itemColor):void 0,d=o?_(o.itemHoverBackground):void 0,f=o?_(o.selectedBackground):void 0,h=o?_(o.selectedColor):void 0,g=o?_(o.caretColor):void 0,v=o?_(o.connectorColor):void 0,{state:b,setState:y}=Pl(n,{expandedValues:s??[],selectedValues:l??[]}),x=C.useMemo(()=>_(t.onExpandedChange),[t.onExpandedChange]),S=C.useMemo(()=>_(t.onSelectionChange),[t.onSelectionChange]),z=C.useMemo(()=>_(t.onFocusChange),[t.onFocusChange]),M=C.useCallback(j=>{y(B=>({...B,expandedValues:j.expandedValue})),x&&queueMicrotask(()=>x(j.expandedValue))},[x,y]),L=C.useCallback(j=>{y(B=>({...B,selectedValues:j.selectedValue})),S&&queueMicrotask(()=>S(j.selectedValue))},[S,y]),R=C.useCallback(j=>{if(z){const B=j.focusedValue!==null?P(j.focusedValue):A;queueMicrotask(()=>z(B))}},[z]),N=C.useMemo(()=>xXe(t.nodes),[t.nodes]),O=C.useMemo(()=>aCt({nodeToValue:j=>j.value,nodeToString:j=>j.label,rootNode:{value:"ROOT",label:"ROOT",children:N}}),[N]);return p.jsx(cDt,{collection:O,size:o?(r=_(o.size))==null?void 0:r.type:void 0,variant:o?(a=_(o.variant))==null?void 0:a.type:void 0,selectionMode:c==null?void 0:c.type,expandedValue:b.expandedValues,selectedValue:b.selectedValues,"aria-label":i,onExpandedChange:M,onSelectionChange:L,onFocusChange:z?R:void 0,color:u,css:{"& [data-part='item']:hover":d?{background:d}:void 0,"& [data-part='item'][data-selected]":f||h?{...f?{background:f}:{},...h?{color:h}:{}}:void 0,"& [data-part='branch-indicator']":g?{color:g}:void 0,"& [data-part='branch-content']":v?{borderColor:v}:void 0},children:p.jsx(vDt,{children:O.rootNode.children.map((j,B)=>p.jsx(wXe,{node:j,indexPath:[B]},j.value))})})},(e,t)=>YNn(e.value,t.value)&&e.storageKey===t.storageKey);function e8e({indicator:e}){const t=_(e);return t?p.jsx(bXe,{value:t}):null}function wXe({node:e,indexPath:t}){return e.children.length>0?p.jsx(T4e,{node:e,indexPath:t,children:p.jsxs(uDt,{children:[p.jsxs(fDt,{children:[p.jsx(pDt,{}),e.indicator&&p.jsx(e8e,{indicator:e.indicator}),p.jsx(hDt,{children:e.label})]}),p.jsx(dDt,{children:e.children.map((r,a)=>p.jsx(wXe,{node:r,indexPath:[...t,a]},r.value))})]})}):p.jsx(T4e,{node:e,indexPath:t,children:p.jsxs(gDt,{children:[e.indicator&&p.jsx(e8e,{indicator:e.indicator}),p.jsx(mDt,{children:e.label})]})})}const SXe=C.createContext(null);function Ov(){return C.useContext(SXe)}function yb(e){return{surface:e.surface,row:e.row,slot:e.slot,event:e.event!==void 0?P(e.event):A}}function ZNn(e){return{library:e.library,key:e.key}}function QNn({children:e}){var t;const n=C.useRef(new Map),r=C.useRef(new Map),a=C.useRef(new Map),[o,i]=C.useState(null),s=C.useRef(null),l=C.useRef(null),c=C.useRef(null),u=C.useCallback(j=>(n.current.set(j.id,j),()=>{n.current.delete(j.id)}),[]),d=C.useCallback((j,B)=>(r.current.set(j,B),j.setAttribute("data-drag-cell",""),()=>{r.current.delete(j)}),[]),f=C.useCallback((j,B)=>(a.current.set(j,B),j.setAttribute("data-drag-sink",""),()=>{a.current.delete(j)}),[]),h=C.useCallback((j,B)=>{if(j.disabled)return!1;const H=n.current.get(j.coord.surface);return H?B.kind==="item"?(H.kinds.add??!1)&&H.sources.includes(B.from.library):B.kind==="edge"?(H.kinds.resize??!1)&&B.from.surface===j.coord.surface&&B.from.row===j.coord.row:(H.kinds.move??!1)&&B.from.surface===j.coord.surface:!1},[]),g=C.useCallback((j,B,H,K)=>{var U;return h(j,B)&&(((U=j.canDrop)==null?void 0:U.call(j,B,H,K))??!0)},[h]),v=C.useCallback((j,B,H,K)=>{var U;return h(j,B)&&((U=j.canDrop)==null?void 0:U.call(j,B,H,K))===!1},[h]),b=C.useCallback((j,B)=>{if(B.kind!=="event")return!1;const H=n.current.get(B.from.surface);return!H||!(H.kinds.remove??!1)?!1:j.kind==="library"?j.library!==void 0&&H.sources.includes(j.library):!0},[]),y=C.useCallback(()=>{for(const j of r.current.keys())j.removeAttribute("data-drop-valid"),j.removeAttribute("data-drop-active"),j.removeAttribute("data-drop-invalid");for(const j of a.current.keys())j.removeAttribute("data-drop-valid"),j.removeAttribute("data-drop-active");c.current=null},[]),x=C.useCallback(j=>{var B,H,K;const U=s.current,Z=c.current;if(y(),(B=l.current)==null||B.removeAttribute("data-dragging"),l.current=null,s.current=null,i(null),!j||!U||!Z)return;const{payload:G,altKey:W,x:J,y:ae}=U,ne=r.current.get(Z),Y=a.current.get(Z);if(ne&&g(ne,G,J,ae)){const te=n.current.get(ne.coord.surface);if(!(te!=null&&te.onDrag))return;const ie=((H=ne.resolveCoord)==null?void 0:H.call(ne,J,ae))??ne.coord;G.kind==="item"?te.onDrag($("add",{from:ZNn(G.from),into:yb(ie),duplicate:W}),G.label!==void 0?{label:G.label}:void 0):G.kind==="edge"?te.onDrag($("resize",{event:yb({...G.from,slot:ie.slot}),edge:$(G.edge,null)})):te.onDrag($("move",{from:yb(G.from),to:yb(ie)}))}else if(Y&&b(Y,G)&&G.kind==="event"){const te=n.current.get(G.from.surface);(K=te==null?void 0:te.onDrag)==null||K.call(te,$("remove",{from:yb(G.from),to:$(Y.kind==="trash"?"trash":"source",null)}))}},[g,b,y]),S=j=>{for(let B=j;B&&B!==document.body;B=B.parentElement){const H=getComputedStyle(B);if(/(auto|scroll)/.test(H.overflowX)&&B.scrollWidth>B.clientWidth||/(auto|scroll)/.test(H.overflowY)&&B.scrollHeight>B.clientHeight)return B}return null},z=C.useCallback((j,B,H,K,U,Z)=>{j.setAttribute("data-dragging",""),l.current=j;for(const[ie,ue]of r.current)g(ue,B)&&ie.setAttribute("data-drop-valid","");for(const[ie,ue]of a.current)b(ue,B)&&ie.setAttribute("data-drop-valid","");const G={payload:B,x:H,y:K,altKey:U};s.current=G,i(G);const W=ie=>{const ue=s.current;if(!ue)return;const oe={...ue,x:ie.clientX,y:ie.clientY,altKey:ie.altKey};s.current=oe,i(oe);const ve=document.elementFromPoint(ie.clientX,ie.clientY),se=(ve==null?void 0:ve.closest("[data-drag-cell], [data-drag-sink]"))??null,pe=se!==null&&se.hasAttribute("data-drop-valid");if(c.current&&c.current!==se&&(c.current.removeAttribute("data-drop-active"),c.current.removeAttribute("data-drop-invalid"),c.current=null),se&&pe){const de=r.current.get(se);de&&v(de,ue.payload,ie.clientX,ie.clientY)?(se.removeAttribute("data-drop-active"),se.setAttribute("data-drop-invalid",""),c.current=se):(se.removeAttribute("data-drop-invalid"),se.setAttribute("data-drop-active",""),c.current=se)}else if(se){const de=r.current.get(se);de&&v(de,ue.payload,ie.clientX,ie.clientY)&&(se.setAttribute("data-drop-invalid",""),c.current=se)}if(Z){const de=S(ve);if(de){const ge=de.getBoundingClientRect(),ye=48,me=12;ie.clientX>ge.right-ye?de.scrollLeft+=me:ie.clientX<ge.left+ye&&(de.scrollLeft-=me),ie.clientY>ge.bottom-ye?de.scrollTop+=me:ie.clientY<ge.top+ye&&(de.scrollTop-=me)}}},J=ie=>{ie.preventDefault()},ae=()=>{document.removeEventListener("pointermove",W),document.removeEventListener("pointerup",ne),document.removeEventListener("pointercancel",Y),document.removeEventListener("keydown",te,!0),Z&&document.removeEventListener("touchmove",J)},ne=()=>{ae(),x(!0)},Y=()=>{ae(),x(!1)},te=ie=>{ie.key==="Escape"&&(ae(),x(!1))};document.addEventListener("pointermove",W),document.addEventListener("pointerup",ne),document.addEventListener("pointercancel",Y),document.addEventListener("keydown",te,!0),Z&&document.addEventListener("touchmove",J,{passive:!1})},[g,v,b,x]),M=C.useCallback((j,B)=>{var H,K;if(s.current)return;const U=j.currentTarget,Z=j.pointerType==="touch"&&((K=(H=j.target).closest)==null?void 0:K.call(H,"[data-drag-grip]"))!==null;if(j.pointerType==="touch"&&!Z){const G=j.clientX,W=j.clientY,J=j.altKey,ae=()=>{clearTimeout(Y),document.removeEventListener("pointermove",ne),document.removeEventListener("pointerup",ae),document.removeEventListener("pointercancel",ae)},ne=te=>{Math.hypot(te.clientX-G,te.clientY-W)>8&&ae()},Y=setTimeout(()=>{ae(),s.current||z(U,B,G,W,J,!0)},300);document.addEventListener("pointermove",ne),document.addEventListener("pointerup",ae),document.addEventListener("pointercancel",ae);return}j.preventDefault(),z(U,B,j.clientX,j.clientY,j.altKey,j.pointerType==="touch")},[z]),L=C.useMemo(()=>({registerTarget:u,registerCell:d,registerSink:f,beginDrag:M,active:o!==null}),[u,d,f,M,o]),R=o!==null&&o.payload.kind==="event"&&(((t=n.current.get(o.payload.from.surface))==null?void 0:t.kinds.remove)??!1),N=C.useRef(null),O=C.useCallback(j=>{var B;if((B=N.current)==null||B.call(N),N.current=null,j){N.current=f(j,{kind:"trash"});const H=s.current;H&&b({kind:"trash"},H.payload)&&j.setAttribute("data-drop-valid","")}},[f,b]);return p.jsxs(SXe.Provider,{value:L,children:[e,R&&J0.createPortal(p.jsx("div",{ref:O,"data-drag-trash":"","aria-label":"Remove (drop to trash)",children:"⌫"}),document.body),o!==null&&J0.createPortal(p.jsx("div",{"data-drag-ghost":"",style:{position:"fixed",left:0,top:0,transform:`translate(${o.x+12}px, ${o.y+8}px)`,pointerEvents:"none",zIndex:1700},children:o.payload.ghost}),document.body)]})}function sk(e){const t=Ov();C.useEffect(()=>{if(!(!t||!e))return t.registerTarget(e)},[t,e])}function lk(e,t=!1,n,r){const a=Ov(),o=C.useRef(null);return C.useCallback(i=>{var s;(s=o.current)==null||s.call(o),o.current=null,a&&i&&e&&(o.current=a.registerCell(i,{coord:e,disabled:t,canDrop:n,resolveCoord:r}))},[a,e,t,n,r])}function JNn(e,t){const n=Ov(),r=C.useRef(null);return C.useCallback(a=>{var o;(o=r.current)==null||o.call(r),r.current=null,n&&a&&(r.current=n.registerSink(a,t!==void 0?{kind:e,library:t}:{kind:e}))},[n,e,t])}function e$n(e,t,n=!1){const r=Ov();return C.useMemo(()=>{if(!(!r||!e||n))return a=>r.beginDrag(a,{kind:"item",from:{library:e.library,key:e.key},...e.label!==void 0?{label:e.label}:{},ghost:t})},[r,e,t,n])}function CI(e,t,n=!1){const r=Ov();return C.useMemo(()=>{if(!(!r||!e||n))return a=>r.beginDrag(a,{kind:"event",from:e,ghost:t})},[r,e,t,n])}function t8e(e,t,n,r=!1){const a=Ov();return C.useMemo(()=>{if(!(!a||!e||r))return o=>a.beginDrag(o,{kind:"edge",from:e,edge:t,ghost:n})},[a,e,t,n,r])}function lT(e){return{surface:e.surface,row:e.row,slot:e.slot,event:e.event!==void 0?P(e.event):A}}function CXe(e,t){if(e.kind==="item")return $("add",{from:{library:e.from.library,key:e.from.key},into:lT(t),duplicate:!1});if(e.kind==="event")return $("move",{from:lT(e.from),to:lT(t)});if(e.kind==="edge")return $("resize",{event:lT({...e.from,slot:t.slot}),edge:$(e.edge,null)})}function t$n(e,t){return`${e.kind==="item"?`i\0${e.from.library}\0${e.from.key}`:`e\0${e.from.surface}\0${e.from.row}\0${e.from.slot}\0${e.from.event}`}${t.row}\0${t.slot}\0${t.event??""}`}function t7(e,t){if(e===void 0||t===void 0)return!0;try{return e(t)===!0}catch(n){return console.error("[DnD] canDrop validator failed (allowing):",n),!0}}function kI(e){const t=C.useRef(new Map),n=C.useRef(e);n.current!==e&&(n.current=e,t.current=new Map);const r=C.useCallback(a=>o=>{const i=n.current;if(i===void 0)return!0;const s=t$n(o,a),l=t.current.get(s);if(l!==void 0)return l;const c=t7(i,CXe(o,a));return t.current.set(s,c),c},[]);return C.useMemo(()=>e===void 0?void 0:r,[e,r])}const n$n=864e5;function r$n(e,t){const n=(t.getTime()-e.getTime())/n$n;return n<=35?"week":n<=1100?"month":"quarter"}function kXe(e,t,n){return e==="auto"?r$n(t,n):e}function zXe(e){switch(e){case"day":return $v;case"week":return ek;case"month":return g6;case"quarter":return g6.every(3)??g6;case"year":return p4}}function a$n(e,t,n){return zXe(kXe(e,t,n))}function o$n(e,t){return e==="year"?"YYYY":e==="week"||e==="day"?"MMM DD":t?"MMM YYYY":"MMM"}let Wh=null;function i$n(e){const t=e.toUpperCase(),n=1.6,r=28;return typeof document<"u"&&(Wh||(Wh=document.createElement("canvas").getContext("2d"),Wh&&(Wh.font="600 10px ui-monospace, SFMono-Regular, Menlo, monospace")),Wh)?Wh.measureText(t).width+n*Math.max(0,t.length-1)+r:t.length*8+r}const s$n=({startDate:e,endDate:t,width:n,height:r,columnHeaderStyles:a,tier:o="auto",format:i})=>{const s=C.useMemo(()=>{const l=cie({domain:[e,t],range:[0,n]}),c=kXe(o,e,t),d=l.ticks(zXe(c)).filter(x=>x.getTime()>e.getTime()&&x.getTime()<t.getTime()),f=[e,...d],h=e.getUTCFullYear()!==t.getUTCFullYear(),g=i??o$n(c,h),v=[];let b=-1/0,y=0;for(const x of f){const S=l(x);if(S-b>=y){const z=km(g,x);v.push({x:S,text:z}),b=S,y=i$n(z)}}return v.map((x,S)=>{var z;return{label:x.text,x0:x.x,x1:((z=v[S+1])==null?void 0:z.x)??n}})},[e,t,n,o,i]);return p.jsx(V,{position:"relative",width:"100%",height:`${r}px`,children:s.map((l,c)=>p.jsx(V,{position:"absolute",left:`${l.x0}px`,width:`${Math.max(l.x1-l.x0,0)}px`,height:"100%",color:"gray.500",css:a,children:l.label},`band-${c}`))})};function l$n(e,t,n){return Math.max(t,Math.min(e,n))}const Y1={toVector(e,t){return e===void 0&&(e=t),Array.isArray(e)?e:[e,e]},add(e,t){return[e[0]+t[0],e[1]+t[1]]},sub(e,t){return[e[0]-t[0],e[1]-t[1]]},addTo(e,t){e[0]+=t[0],e[1]+=t[1]},subTo(e,t){e[0]-=t[0],e[1]-=t[1]}};function n8e(e,t,n){return t===0||Math.abs(t)===1/0?Math.pow(e,n*5):e*t*n/(t+n*e)}function r8e(e,t,n,r=.15){return r===0?l$n(e,t,n):e<t?-n8e(t-e,n-t,r)+t:e>n?+n8e(e-n,n-t,r)+n:e}function c$n(e,[t,n],[r,a]){const[[o,i],[s,l]]=e;return[r8e(t,o,i,r),r8e(n,s,l,a)]}function u$n(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function d$n(e){var t=u$n(e,"string");return typeof t=="symbol"?t:String(t)}function nc(e,t,n){return t=d$n(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a8e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),n.push.apply(n,r)}return n}function mi(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?a8e(Object(n),!0).forEach(function(r){nc(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a8e(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}const MXe={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function o8e(e){return e?e[0].toUpperCase()+e.slice(1):""}const f$n=["enter","leave"];function p$n(e=!1,t){return e&&!f$n.includes(t)}function h$n(e,t="",n=!1){const r=MXe[e],a=r&&r[t]||t;return"on"+o8e(e)+o8e(a)+(p$n(n,a)?"Capture":"")}const g$n=["gotpointercapture","lostpointercapture"];function m$n(e){let t=e.substring(2).toLowerCase();const n=!!~t.indexOf("passive");n&&(t=t.replace("passive",""));const r=g$n.includes(t)?"capturecapture":"capture",a=!!~t.indexOf(r);return a&&(t=t.replace("capture","")),{device:t,capture:a,passive:n}}function v$n(e,t=""){const n=MXe[e],r=n&&n[t]||t;return e+r}function zI(e){return"touches"in e}function TXe(e){return zI(e)?"touch":"pointerType"in e?e.pointerType:"mouse"}function y$n(e){return Array.from(e.touches).filter(t=>{var n,r;return t.target===e.currentTarget||((n=e.currentTarget)===null||n===void 0||(r=n.contains)===null||r===void 0?void 0:r.call(n,t.target))})}function b$n(e){return e.type==="touchend"||e.type==="touchcancel"?e.changedTouches:e.targetTouches}function EXe(e){return zI(e)?b$n(e)[0]:e}function x$n(e){return y$n(e).map(t=>t.identifier)}function IV(e){const t=EXe(e);return zI(e)?t.identifier:t.pointerId}function i8e(e){const t=EXe(e);return[t.clientX,t.clientY]}function w$n(e){const t={};if("buttons"in e&&(t.buttons=e.buttons),"shiftKey"in e){const{shiftKey:n,altKey:r,metaKey:a,ctrlKey:o}=e;Object.assign(t,{shiftKey:n,altKey:r,metaKey:a,ctrlKey:o})}return t}function hR(e,...t){return typeof e=="function"?e(...t):e}function S$n(){}function C$n(...e){return e.length===0?S$n:e.length===1?e[0]:function(){let t;for(const n of e)t=n.apply(this,arguments)||t;return t}}function s8e(e,t){return Object.assign({},t,e||{})}const k$n=32;class z$n{constructor(t,n,r){this.ctrl=t,this.args=n,this.key=r,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(t){this.ctrl.state[this.key]=t}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:t,shared:n,ingKey:r,args:a}=this;n[r]=t._active=t.active=t._blocked=t._force=!1,t._step=[!1,!1],t.intentional=!1,t._movement=[0,0],t._distance=[0,0],t._direction=[0,0],t._delta=[0,0],t._bounds=[[-1/0,1/0],[-1/0,1/0]],t.args=a,t.axis=void 0,t.memo=void 0,t.elapsedTime=t.timeDelta=0,t.direction=[0,0],t.distance=[0,0],t.overflow=[0,0],t._movementBound=[!1,!1],t.velocity=[0,0],t.movement=[0,0],t.delta=[0,0],t.timeStamp=0}start(t){const n=this.state,r=this.config;n._active||(this.reset(),this.computeInitial(),n._active=!0,n.target=t.target,n.currentTarget=t.currentTarget,n.lastOffset=r.from?hR(r.from,n):n.offset,n.offset=n.lastOffset,n.startTime=n.timeStamp=t.timeStamp)}computeValues(t){const n=this.state;n._values=t,n.values=this.config.transform(t)}computeInitial(){const t=this.state;t._initial=t._values,t.initial=t.values}compute(t){const{state:n,config:r,shared:a}=this;n.args=this.args;let o=0;if(t&&(n.event=t,r.preventDefault&&t.cancelable&&n.event.preventDefault(),n.type=t.type,a.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,a.locked=!!document.pointerLockElement,Object.assign(a,w$n(t)),a.down=a.pressed=a.buttons%2===1||a.touches>0,o=t.timeStamp-n.timeStamp,n.timeStamp=t.timeStamp,n.elapsedTime=n.timeStamp-n.startTime),n._active){const L=n._delta.map(Math.abs);Y1.addTo(n._distance,L)}this.axisIntent&&this.axisIntent(t);const[i,s]=n._movement,[l,c]=r.threshold,{_step:u,values:d}=n;if(r.hasCustomTransform?(u[0]===!1&&(u[0]=Math.abs(i)>=l&&d[0]),u[1]===!1&&(u[1]=Math.abs(s)>=c&&d[1])):(u[0]===!1&&(u[0]=Math.abs(i)>=l&&Math.sign(i)*l),u[1]===!1&&(u[1]=Math.abs(s)>=c&&Math.sign(s)*c)),n.intentional=u[0]!==!1||u[1]!==!1,!n.intentional)return;const f=[0,0];if(r.hasCustomTransform){const[L,R]=d;f[0]=u[0]!==!1?L-u[0]:0,f[1]=u[1]!==!1?R-u[1]:0}else f[0]=u[0]!==!1?i-u[0]:0,f[1]=u[1]!==!1?s-u[1]:0;this.restrictToAxis&&!n._blocked&&this.restrictToAxis(f);const h=n.offset,g=n._active&&!n._blocked||n.active;g&&(n.first=n._active&&!n.active,n.last=!n._active&&n.active,n.active=a[this.ingKey]=n._active,t&&(n.first&&("bounds"in r&&(n._bounds=hR(r.bounds,n)),this.setup&&this.setup()),n.movement=f,this.computeOffset()));const[v,b]=n.offset,[[y,x],[S,z]]=n._bounds;n.overflow=[v<y?-1:v>x?1:0,b<S?-1:b>z?1:0],n._movementBound[0]=n.overflow[0]?n._movementBound[0]===!1?n._movement[0]:n._movementBound[0]:!1,n._movementBound[1]=n.overflow[1]?n._movementBound[1]===!1?n._movement[1]:n._movementBound[1]:!1;const M=n._active?r.rubberband||[0,0]:[0,0];if(n.offset=c$n(n._bounds,n.offset,M),n.delta=Y1.sub(n.offset,h),this.computeMovement(),g&&(!n.last||o>k$n)){n.delta=Y1.sub(n.offset,h);const L=n.delta.map(Math.abs);Y1.addTo(n.distance,L),n.direction=n.delta.map(Math.sign),n._direction=n._delta.map(Math.sign),!n.first&&o>0&&(n.velocity=[L[0]/o,L[1]/o],n.timeDelta=o)}}emit(){const t=this.state,n=this.shared,r=this.config;if(t._active||this.clean(),(t._blocked||!t.intentional)&&!t._force&&!r.triggerAllEvents)return;const a=this.handler(mi(mi(mi({},n),t),{},{[this.aliasKey]:t.values}));a!==void 0&&(t.memo=a)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function M$n([e,t],n){const r=Math.abs(e),a=Math.abs(t);if(r>a&&r>n)return"x";if(a>r&&a>n)return"y"}class T$n extends z$n{constructor(...t){super(...t),nc(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=Y1.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=Y1.sub(this.state.offset,this.state.lastOffset)}axisIntent(t){const n=this.state,r=this.config;if(!n.axis&&t){const a=typeof r.axisThreshold=="object"?r.axisThreshold[TXe(t)]:r.axisThreshold;n.axis=M$n(n._movement,a)}n._blocked=(r.lockDirection||!!r.axis)&&!n.axis||!!r.axis&&r.axis!==n.axis}restrictToAxis(t){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":t[1]=0;break;case"y":t[0]=0;break}}}const E$n=e=>e,l8e=.15,_Xe={enabled(e=!0){return e},eventOptions(e,t,n){return mi(mi({},n.shared.eventOptions),e)},preventDefault(e=!1){return e},triggerAllEvents(e=!1){return e},rubberband(e=0){switch(e){case!0:return[l8e,l8e];case!1:return[0,0];default:return Y1.toVector(e)}},from(e){if(typeof e=="function")return e;if(e!=null)return Y1.toVector(e)},transform(e,t,n){const r=e||n.shared.transform;return this.hasCustomTransform=!!r,r||E$n},threshold(e){return Y1.toVector(e,0)}},_$n=0,ck=mi(mi({},_Xe),{},{axis(e,t,{axis:n}){if(this.lockDirection=n==="lock",!this.lockDirection)return n},axisThreshold(e=_$n){return e},bounds(e={}){if(typeof e=="function")return o=>ck.bounds(e(o));if("current"in e)return()=>e.current;if(typeof HTMLElement=="function"&&e instanceof HTMLElement)return e;const{left:t=-1/0,right:n=1/0,top:r=-1/0,bottom:a=1/0}=e;return[[t,n],[r,a]]}}),c8e={ArrowRight:(e,t=1)=>[e*t,0],ArrowLeft:(e,t=1)=>[-1*e*t,0],ArrowUp:(e,t=1)=>[0,-1*e*t],ArrowDown:(e,t=1)=>[0,e*t]};class L$n extends T$n{constructor(...t){super(...t),nc(this,"ingKey","dragging")}reset(){super.reset();const t=this.state;t._pointerId=void 0,t._pointerActive=!1,t._keyboardActive=!1,t._preventScroll=!1,t._delayed=!1,t.swipe=[0,0],t.tap=!1,t.canceled=!1,t.cancel=this.cancel.bind(this)}setup(){const t=this.state;if(t._bounds instanceof HTMLElement){const n=t._bounds.getBoundingClientRect(),r=t.currentTarget.getBoundingClientRect(),a={left:n.left-r.left+t.offset[0],right:n.right-r.right+t.offset[0],top:n.top-r.top+t.offset[1],bottom:n.bottom-r.bottom+t.offset[1]};t._bounds=ck.bounds(a)}}cancel(){const t=this.state;t.canceled||(t.canceled=!0,t._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(t){const n=this.config,r=this.state;if(t.buttons!=null&&(Array.isArray(n.pointerButtons)?!n.pointerButtons.includes(t.buttons):n.pointerButtons!==-1&&n.pointerButtons!==t.buttons))return;const a=this.ctrl.setEventIds(t);n.pointerCapture&&t.target.setPointerCapture(t.pointerId),!(a&&a.size>1&&r._pointerActive)&&(this.start(t),this.setupPointer(t),r._pointerId=IV(t),r._pointerActive=!0,this.computeValues(i8e(t)),this.computeInitial(),n.preventScrollAxis&&TXe(t)!=="mouse"?(r._active=!1,this.setupScrollPrevention(t)):n.delay>0?(this.setupDelayTrigger(t),n.triggerAllEvents&&(this.compute(t),this.emit())):this.startPointerDrag(t))}startPointerDrag(t){const n=this.state;n._active=!0,n._preventScroll=!0,n._delayed=!1,this.compute(t),this.emit()}pointerMove(t){const n=this.state,r=this.config;if(!n._pointerActive)return;const a=IV(t);if(n._pointerId!==void 0&&a!==n._pointerId)return;const o=i8e(t);if(document.pointerLockElement===t.target?n._delta=[t.movementX,t.movementY]:(n._delta=Y1.sub(o,n._values),this.computeValues(o)),Y1.addTo(n._movement,n._delta),this.compute(t),n._delayed&&n.intentional){this.timeoutStore.remove("dragDelay"),n.active=!1,this.startPointerDrag(t);return}if(r.preventScrollAxis&&!n._preventScroll)if(n.axis)if(n.axis===r.preventScrollAxis||r.preventScrollAxis==="xy"){n._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(t);return}else return;this.emit()}pointerUp(t){this.ctrl.setEventIds(t);try{this.config.pointerCapture&&t.target.hasPointerCapture(t.pointerId)&&t.target.releasePointerCapture(t.pointerId)}catch{}const n=this.state,r=this.config;if(!n._active||!n._pointerActive)return;const a=IV(t);if(n._pointerId!==void 0&&a!==n._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(t);const[o,i]=n._distance;if(n.tap=o<=r.tapsThreshold&&i<=r.tapsThreshold,n.tap&&r.filterTaps)n._force=!0;else{const[s,l]=n._delta,[c,u]=n._movement,[d,f]=r.swipe.velocity,[h,g]=r.swipe.distance,v=r.swipe.duration;if(n.elapsedTime<v){const b=Math.abs(s/n.timeDelta),y=Math.abs(l/n.timeDelta);b>d&&Math.abs(c)>h&&(n.swipe[0]=Math.sign(s)),y>f&&Math.abs(u)>g&&(n.swipe[1]=Math.sign(l))}}this.emit()}pointerClick(t){!this.state.tap&&t.detail>0&&(t.preventDefault(),t.stopPropagation())}setupPointer(t){const n=this.config,r=n.device;n.pointerLock&&t.currentTarget.requestPointerLock(),n.pointerCapture||(this.eventStore.add(this.sharedConfig.window,r,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,r,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,r,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(t){this.state._preventScroll&&t.cancelable&&t.preventDefault()}setupScrollPrevention(t){this.state._preventScroll=!1,R$n(t);const n=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",n),this.eventStore.add(this.sharedConfig.window,"touch","cancel",n),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,t)}setupDelayTrigger(t){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(t)},this.config.delay)}keyDown(t){const n=c8e[t.key];if(n){const r=this.state,a=t.shiftKey?10:t.altKey?.1:1;this.start(t),r._delta=n(this.config.keyboardDisplacement,a),r._keyboardActive=!0,Y1.addTo(r._movement,r._delta),this.compute(t),this.emit()}}keyUp(t){t.key in c8e&&(this.state._keyboardActive=!1,this.setActive(),this.compute(t),this.emit())}bind(t){const n=this.config.device;t(n,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(t(n,"change",this.pointerMove.bind(this)),t(n,"end",this.pointerUp.bind(this)),t(n,"cancel",this.pointerUp.bind(this)),t("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(t("key","down",this.keyDown.bind(this)),t("key","up",this.keyUp.bind(this))),this.config.filterTaps&&t("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function R$n(e){"persist"in e&&typeof e.persist=="function"&&e.persist()}const uk=typeof window<"u"&&window.document&&window.document.createElement;function LXe(){return uk&&"ontouchstart"in window}function P$n(){return LXe()||uk&&window.navigator.maxTouchPoints>1}function A$n(){return uk&&"onpointerdown"in window}function N$n(){return uk&&"exitPointerLock"in window.document}function $$n(){try{return"constructor"in GestureEvent}catch{return!1}}const U2={isBrowser:uk,gesture:$$n(),touch:LXe(),touchscreen:P$n(),pointer:A$n(),pointerLock:N$n()},I$n=250,D$n=180,O$n=.5,j$n=50,F$n=250,B$n=10,u8e={mouse:0,touch:0,pen:8},V$n=mi(mi({},ck),{},{device(e,t,{pointer:{touch:n=!1,lock:r=!1,mouse:a=!1}={}}){return this.pointerLock=r&&U2.pointerLock,U2.touch&&n?"touch":this.pointerLock?"mouse":U2.pointer&&!a?"pointer":U2.touch?"touch":"mouse"},preventScrollAxis(e,t,{preventScroll:n}){if(this.preventScrollDelay=typeof n=="number"?n:n||n===void 0&&e?I$n:void 0,!(!U2.touchscreen||n===!1))return e||(n!==void 0?"y":void 0)},pointerCapture(e,t,{pointer:{capture:n=!0,buttons:r=1,keys:a=!0}={}}){return this.pointerButtons=r,this.keys=a,!this.pointerLock&&this.device==="pointer"&&n},threshold(e,t,{filterTaps:n=!1,tapsThreshold:r=3,axis:a=void 0}){const o=Y1.toVector(e,n?r:a?1:0);return this.filterTaps=n,this.tapsThreshold=r,o},swipe({velocity:e=O$n,distance:t=j$n,duration:n=F$n}={}){return{velocity:this.transform(Y1.toVector(e)),distance:this.transform(Y1.toVector(t)),duration:n}},delay(e=0){switch(e){case!0:return D$n;case!1:return 0;default:return e}},axisThreshold(e){return e?mi(mi({},u8e),e):u8e},keyboardDisplacement(e=B$n){return e}});mi(mi({},_Xe),{},{device(e,t,{shared:n,pointer:{touch:r=!1}={}}){if(n.target&&!U2.touch&&U2.gesture)return"gesture";if(U2.touch&&r)return"touch";if(U2.touchscreen){if(U2.pointer)return"pointer";if(U2.touch)return"touch"}},bounds(e,t,{scaleBounds:n={},angleBounds:r={}}){const a=i=>{const s=s8e(hR(n,i),{min:-1/0,max:1/0});return[s.min,s.max]},o=i=>{const s=s8e(hR(r,i),{min:-1/0,max:1/0});return[s.min,s.max]};return typeof n!="function"&&typeof r!="function"?[a(),o()]:i=>[a(i),o(i)]},threshold(e,t,n){return this.lockDirection=n.axis==="lock",Y1.toVector(e,this.lockDirection?[.1,3]:0)},modifierKey(e){return e===void 0?"ctrlKey":e},pinchOnWheel(e=!0){return e}});mi(mi({},ck),{},{mouseOnly:(e=!0)=>e});mi(mi({},ck),{},{mouseOnly:(e=!0)=>e});const RXe=new Map,tX=new Map;function H$n(e){RXe.set(e.key,e.engine),tX.set(e.key,e.resolver)}const W$n={key:"drag",engine:L$n,resolver:V$n};function U$n(e,t){if(e==null)return{};var n={},r=Object.keys(e),a,o;for(o=0;o<r.length;o++)a=r[o],!(t.indexOf(a)>=0)&&(n[a]=e[a]);return n}function q$n(e,t){if(e==null)return{};var n=U$n(e,t),r,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a<o.length;a++)r=o[a],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}const G$n={target(e){if(e)return()=>"current"in e?e.current:e},enabled(e=!0){return e},window(e=U2.isBrowser?window:void 0){return e},eventOptions({passive:e=!0,capture:t=!1}={}){return{passive:e,capture:t}},transform(e){return e}},K$n=["target","eventOptions","window","enabled","transform"];function qE(e={},t){const n={};for(const[r,a]of Object.entries(t))switch(typeof a){case"function":n[r]=a.call(n,e[r],r,e);break;case"object":n[r]=qE(e[r],a);break;case"boolean":a&&(n[r]=e[r]);break}return n}function Y$n(e,t,n={}){const r=e,{target:a,eventOptions:o,window:i,enabled:s,transform:l}=r,c=q$n(r,K$n);if(n.shared=qE({target:a,eventOptions:o,window:i,enabled:s,transform:l},G$n),t){const u=tX.get(t);n[t]=qE(mi({shared:n.shared},c),u)}else for(const u in c){const d=tX.get(u);d&&(n[u]=qE(mi({shared:n.shared},c[u]),d))}return n}class PXe{constructor(t,n){nc(this,"_listeners",new Set),this._ctrl=t,this._gestureKey=n}add(t,n,r,a,o){const i=this._listeners,s=v$n(n,r),l=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},c=mi(mi({},l),o);t.addEventListener(s,a,c);const u=()=>{t.removeEventListener(s,a,c),i.delete(u)};return i.add(u),u}clean(){this._listeners.forEach(t=>t()),this._listeners.clear()}}class X$n{constructor(){nc(this,"_timeouts",new Map)}add(t,n,r=140,...a){this.remove(t),this._timeouts.set(t,window.setTimeout(n,r,...a))}remove(t){const n=this._timeouts.get(t);n&&window.clearTimeout(n)}clean(){this._timeouts.forEach(t=>void window.clearTimeout(t)),this._timeouts.clear()}}class Z$n{constructor(t){nc(this,"gestures",new Set),nc(this,"_targetEventStore",new PXe(this)),nc(this,"gestureEventStores",{}),nc(this,"gestureTimeoutStores",{}),nc(this,"handlers",{}),nc(this,"config",{}),nc(this,"pointerIds",new Set),nc(this,"touchIds",new Set),nc(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),Q$n(this,t)}setEventIds(t){if(zI(t))return this.touchIds=new Set(x$n(t)),this.touchIds;if("pointerId"in t)return t.type==="pointerup"||t.type==="pointercancel"?this.pointerIds.delete(t.pointerId):t.type==="pointerdown"&&this.pointerIds.add(t.pointerId),this.pointerIds}applyHandlers(t,n){this.handlers=t,this.nativeHandlers=n}applyConfig(t,n){this.config=Y$n(t,n,this.config)}clean(){this._targetEventStore.clean();for(const t of this.gestures)this.gestureEventStores[t].clean(),this.gestureTimeoutStores[t].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...t){const n=this.config.shared,r={};let a;if(!(n.target&&(a=n.target(),!a))){if(n.enabled){for(const i of this.gestures){const s=this.config[i],l=d8e(r,s.eventOptions,!!a);if(s.enabled){const c=RXe.get(i);new c(this,t,i).bind(l)}}const o=d8e(r,n.eventOptions,!!a);for(const i in this.nativeHandlers)o(i,"",s=>this.nativeHandlers[i](mi(mi({},this.state.shared),{},{event:s,args:t})),void 0,!0)}for(const o in r)r[o]=C$n(...r[o]);if(!a)return r;for(const o in r){const{device:i,capture:s,passive:l}=m$n(o);this._targetEventStore.add(a,i,"",r[o],{capture:s,passive:l})}}}}function Uh(e,t){e.gestures.add(t),e.gestureEventStores[t]=new PXe(e,t),e.gestureTimeoutStores[t]=new X$n}function Q$n(e,t){t.drag&&Uh(e,"drag"),t.wheel&&Uh(e,"wheel"),t.scroll&&Uh(e,"scroll"),t.move&&Uh(e,"move"),t.pinch&&Uh(e,"pinch"),t.hover&&Uh(e,"hover")}const d8e=(e,t,n)=>(r,a,o,i={},s=!1)=>{var l,c;const u=(l=i.capture)!==null&&l!==void 0?l:t.capture,d=(c=i.passive)!==null&&c!==void 0?c:t.passive;let f=s?r:h$n(r,a,u);n&&d&&(f+="Passive"),e[f]=e[f]||[],e[f].push(o)};function J$n(e,t={},n,r){const a=C.useMemo(()=>new Z$n(e),[]);if(a.applyHandlers(e,r),a.applyConfig(t,n),C.useEffect(a.effect.bind(a)),C.useEffect(()=>a.clean.bind(a),[]),t.target===void 0)return a.bind.bind(a)}function GE(e,t){return H$n(W$n),J$n({drag:e},t||{},"drag")}function eIn(e){return Sr(e,{committed:()=>"committed",rejected:()=>"rejected",proposed:t=>Sr(t,{added:()=>"proposedAdded",model:()=>"proposedModel",removed:()=>"proposedRemoved"},"proposedAdded")},"committed")}const tIn={committed:"fg.success",proposedAdded:"fg.info",proposedModel:"fg.info",proposedRemoved:"fg.info",rejected:"fg.subtle"},nIn={success:"fg.success",warning:"fg.warning",danger:"fg.danger",info:"fg.info",neutral:"fg.subtle"},rIn={committed:void 0,proposedAdded:"5 3",proposedModel:"3 3",proposedRemoved:"3 3",rejected:void 0},aIn={committed:1,proposedAdded:1,proposedModel:.75,proposedRemoved:.6,rejected:.55},oIn={committed:!1,proposedAdded:!1,proposedModel:!1,proposedRemoved:!0,rejected:!0},iIn={interim:"fg.warning",release:"fg.info"},AXe=e=>{switch(e.type){case"minutes":return e.value*60*1e3;case"hours":return e.value*60*60*1e3;case"days":return e.value*24*60*60*1e3;case"weeks":return e.value*7*24*60*60*1e3;case"months":return e.value*30*24*60*60*1e3}},dx=(e,t)=>{if(!t)return e;const n=AXe(t),r=Math.round(e.getTime()/n)*n;return new Date(r)},sIn=({x:e,y:t,width:n,height:r,value:a,storageKey:o="task",onClick:i,onDoubleClick:s,onDrag:l,onDurationChange:c,onProgressChange:u,timelineStartDate:d,timelineEndDate:f,timelineWidth:h,dragStep:g,durationStep:v})=>{var b,y,x,S,z,M;const L=yUe(),[R,N]=C.useState(!1),[O,j]=C.useState(null),[B,H]=C.useState(null),[K,U]=C.useState(null),[Z,G]=C.useState({x:e,width:n}),[W,J]=C.useState(!1),ae=C.useRef(null),ne=_(a.label),Y=ne?{value:ne.value,align:((b=_(ne.align))==null?void 0:b.type)??"start",verticalAlign:((y=_(ne.verticalAlign))==null?void 0:y.type)??"center",color:_(ne.color),fontWeight:(x=_(ne.fontWeight))==null?void 0:x.type,fontStyle:(S=_(ne.fontStyle))==null?void 0:S.type,fontSize:(z=_(ne.fontSize))==null?void 0:z.type}:null,te=eIn(a.state),ie=(M=_(a.status))==null?void 0:M.type,ue=_(a.progress),oe=_(a.popover),ve=oe!==void 0,[se,pe]=C.useState(ue??0);C.useEffect(()=>{G({x:e,width:n})},[e,n]),C.useEffect(()=>{pe(ue??0)},[ue]);const[de,ge,ye]=M7("colors",[(ie!==void 0?nIn[ie]:void 0)??tIn[te]??"fg.success","bg.canvas","border.strong"]),me=rIn[te],Me=aIn[te],Te=oIn[te],Be=Z.x+(O??0),ht=Math.max(Z.width+(B??0),4),De=Math.max(ht,4),Qe=(Y==null?void 0:Y.fontSize)??"11px",bt=2,Ve=K??se,ut=De*(Ve/100),_t=C.useCallback(()=>N(!0),[]),Ft=C.useCallback(()=>{O===null&&B===null&&K===null&&N(!1)},[O,B,K]),wt=C.useCallback(ot=>{if(!d||!f||!h)return 0;const kt=f.getTime()-d.getTime();return ot/h*kt},[d,f,h]),Lt=C.useCallback(ot=>{if(!d||!f||!h)return 0;const kt=f.getTime()-d.getTime();return ot/kt*h},[d,f,h]),Jt=te==="proposedAdded"||te==="proposedModel"||te==="proposedRemoved",Dt=Jt&&l&&d&&f&&h,Et=Jt&&c&&d&&f&&h,Gt=Jt&&u&&ue!==void 0,Ke=C.useCallback((ot,kt,Mt)=>{if(!Mt||!h||!d||!f)return ot;const At=wt(ot),fn=dx(new Date(kt.getTime()+At),Mt);return Lt(fn.getTime()-kt.getTime())},[h,d,f,wt,Lt]),Se=GE(({active:ot,movement:[kt],tap:Mt,last:At,first:fn})=>{if(fn&&N(!0),Mt){i&&i(),ve&&J(rt=>!rt),j(null),N(!1);return}if(At){if(Dt&&h){const rt=Ke(kt,a.start,g),ln=dx(new Date(a.start.getTime()+wt(rt)),g),Mn=dx(new Date(a.end.getTime()+wt(rt)),g);G(Jn=>({...Jn,x:Jn.x+rt})),l&&l(a.start,a.end,ln,Mn)}j(null),N(!1);return}ot&&Dt&&j(Ke(kt,a.start,g))},{filterTaps:!0,preventDefault:!0}),Re=GE(({active:ot,movement:[kt],last:Mt})=>{if(Mt){if(Et&&h){const At=Ke(kt,a.end,v),fn=dx(new Date(a.end.getTime()+wt(At)),v);G(rt=>({...rt,width:rt.width+At})),c&&c(a.end,fn)}H(null),N(!1);return}ot&&Et&&H(Ke(kt,a.end,v))},{preventDefault:!0}),qe=GE(({active:ot,movement:[kt],last:Mt})=>{if(Mt){if(Gt){const At=kt/De*100,fn=Math.max(0,Math.min(100,se+At));pe(fn),u&&u(se,fn)}U(null),N(!1);return}if(ot&&Gt){const At=kt/De*100;U(Math.max(0,Math.min(100,se+At)))}},{preventDefault:!0}),Ye=C.useCallback(()=>{s&&O===null&&B===null&&s()},[s,O,B]),$e=O!==null?"grabbing":Dt?"grab":i||s||ve?"pointer":"default",lt=R||O!==null||B!==null||K!==null,Pe=C.useCallback(()=>ae.current?ae.current.getBoundingClientRect():{x:0,y:0,width:0,height:0},[]);return p.jsxs("g",{children:[p.jsx("rect",{ref:ae,x:Be,y:t,width:De,height:r,fill:te==="proposedModel"?"transparent":ge,stroke:de,strokeWidth:1,strokeDasharray:me,opacity:(lt?1:.9)*Me,rx:bt,ry:bt,onDoubleClick:Ye,onMouseEnter:_t,onMouseLeave:Ft,...Se(),style:{cursor:$e,touchAction:"none"}}),ue!==void 0&&p.jsx("rect",{x:Be,y:t,width:ut,height:r,fill:de,opacity:Me,rx:bt,ry:bt,style:{pointerEvents:"none"}}),Te&&p.jsx("line",{x1:Be+2,x2:Be+De-2,y1:t+r/2,y2:t+r/2,stroke:de,strokeWidth:1.5,opacity:.9,style:{pointerEvents:"none"}}),Dt&&p.jsx("foreignObject",{x:Be+4,y:t+r/2-6,width:12,height:12,style:{pointerEvents:"none",overflow:"visible"},children:p.jsx(V,{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:ut>=14?"white":"gray.500",opacity:lt?1:0,transition:"opacity 0.2s",children:p.jsx(Ut,{icon:g5,style:{width:9,height:9}})})}),Y&&p.jsx("foreignObject",{x:Be+(Dt?22:8),y:t,width:Math.max(De-(Dt?30:16),0),height:r,style:{pointerEvents:"none"},children:p.jsx(V,{display:"flex",alignItems:X5e(Y.verticalAlign),justifyContent:X5e(Y.align),height:"100%",opacity:lt?1:.9,children:p.jsx(Ie,{fontFamily:"mono",fontSize:typeof Qe=="number"?`${Qe}px`:Qe,color:Y.color??(Ve>=50?"white":"fg.default"),fontWeight:Y.fontWeight??600,fontStyle:Y.fontStyle??(te==="proposedModel"?"italic":void 0),whiteSpace:"nowrap",cursor:$e,userSelect:"none",lineHeight:"1",overflow:"hidden",textOverflow:"ellipsis",m:0,p:0,children:Y.value})})}),Et&&p.jsxs(p.Fragment,{children:[p.jsx("line",{x1:Be+De,x2:Be+De,y1:t+r*.3,y2:t+r*.7,stroke:ye,strokeWidth:1,opacity:lt?1:0,style:{transition:"opacity 0.2s",pointerEvents:"none"}}),p.jsx("rect",{x:Be+De-(L?12:3),y:t,width:L?24:6,height:r,fill:"transparent",onMouseEnter:_t,onMouseLeave:Ft,...Re(),style:{cursor:"ew-resize",touchAction:"none"}})]}),Gt&&ut>8&&p.jsx("rect",{x:Be+ut-(L?12:6),y:t,width:L?24:12,height:r,fill:"transparent",onMouseEnter:_t,onMouseLeave:Ft,...qe(),style:{cursor:"ew-resize",touchAction:"none"}}),ve&&p.jsx(nu,{open:W,onOpenChange:ot=>J(ot.open),positioning:{placement:"top",getAnchorRect:Pe},children:p.jsx(go,{children:p.jsx(M4,{children:p.jsx(T4,{padding:"14px 16px",minW:"240px",maxW:"360px",fontSize:"13px",children:p.jsx($C,{children:p.jsx(mn,{value:oe,storageKey:`${o}.popover`})})})})})})]})},lIn=(e,t,n)=>{const r=n/2;return`${e},${t-r} ${e+r},${t} ${e},${t+r} ${e-r},${t}`},cIn=({x:e,y:t,height:n,value:r,storageKey:a="milestone",onClick:o,onDoubleClick:i,onDrag:s,timelineStartDate:l,timelineEndDate:c,timelineWidth:u})=>{var d,f,h,g,v,b;const[y,x]=C.useState(!1),[S,z]=C.useState(null),[M,L]=C.useState({x:e}),[R,N]=C.useState(!1),O=C.useRef(null);C.useEffect(()=>{L({x:e})},[e]);const j=_(r.label),B=j?{value:j.value,align:((d=_(j.align))==null?void 0:d.type)??"start",verticalAlign:((f=_(j.verticalAlign))==null?void 0:f.type)??"center",color:_(j.color),fontWeight:(h=_(j.fontWeight))==null?void 0:h.type,fontStyle:(g=_(j.fontStyle))==null?void 0:g.type,fontSize:(v=_(j.fontSize))==null?void 0:v.type}:null,H=((b=_(r.kind))==null?void 0:b.type)??"release",K=_(r.popover),U=K!==void 0,[Z,G]=M7("colors",[iIn[H]??"fg.info","white"]),W=M.x+(S??0),J=(B==null?void 0:B.fontSize)??"10px",ae=14,ne=t+n/2,Y=lIn(W,ne,ae),te=C.useCallback(()=>x(!0),[]),ie=C.useCallback(()=>{S===null&&x(!1)},[S]),ue=C.useCallback(ge=>{if(!l||!c||!u)return r.date;const ye=c.getTime()-l.getTime(),me=Math.max(0,Math.min(1,ge/u));return new Date(l.getTime()+me*ye)},[l,c,u,r.date]),oe=s&&l&&c&&u,ve=GE(({active:ge,movement:[ye],tap:me,last:Me,first:Te})=>{if(Te&&x(!0),me){o&&o(),U&&N(Be=>!Be),z(null),x(!1);return}if(Me){if(oe&&u&&(L(Be=>({x:Be.x+ye})),s)){const Be=ue(M.x+ye);s(r.date,Be)}z(null),x(!1);return}ge&&oe&&z(ye)},{filterTaps:!0,preventDefault:!0}),se=C.useCallback(()=>{i&&S===null&&i()},[i,S]),pe=S!==null?"grabbing":oe?"grab":o||i||U?"pointer":"default",de=C.useCallback(()=>O.current?O.current.getBoundingClientRect():{x:0,y:0,width:0,height:0},[]);return p.jsxs("g",{children:[p.jsx("polygon",{ref:O,points:Y,fill:Z,stroke:G,strokeWidth:4,paintOrder:"stroke",strokeLinejoin:"miter",opacity:y||S!==null?1:.9,onDoubleClick:se,onMouseEnter:te,onMouseLeave:ie,...ve(),style:{cursor:pe,touchAction:"none"}}),B&&p.jsx("foreignObject",{x:W-100,y:ne+ae/2+4,width:200,height:14,style:{pointerEvents:"none",overflow:"visible"},children:p.jsx(V,{display:"flex",alignItems:"flex-start",justifyContent:"center",height:"100%",opacity:y||S!==null?1:.9,children:p.jsx(Ie,{fontFamily:"mono",fontSize:typeof J=="number"?`${J}px`:J,color:B.color??Z,fontWeight:B.fontWeight??600,fontStyle:B.fontStyle,whiteSpace:"nowrap",cursor:pe,userSelect:"none",lineHeight:"1",m:0,p:0,children:B.value})})}),U&&p.jsx(nu,{open:R,onOpenChange:ge=>N(ge.open),positioning:{placement:"top",getAnchorRect:de},children:p.jsx(go,{children:p.jsx(M4,{children:p.jsx(T4,{padding:"14px 16px",minW:"240px",maxW:"360px",fontSize:"13px",children:p.jsx($C,{children:p.jsx(mn,{value:K,storageKey:`${a}.popover`})})})})})})]})},uIn=(e,t,n,r)=>{const a=n.getTime()-t.getTime(),o=e.start,i=e.end,s=Math.max(o.getTime(),t.getTime()),l=Math.min(i.getTime(),n.getTime()),c=(s-t.getTime())/a,u=(l-s)/a;return{x:c*r,width:Math.max(u*r,2)}},dIn=(e,t,n,r)=>{const a=n.getTime()-t.getTime(),i=e.date.getTime();return i<t.getTime()||i>n.getTime()?null:{x:(i-t.getTime())/a*r}},fIn=({tasks:e,milestones:t,rowIndex:n,y:r,width:a,height:o,startDate:i,endDate:s,onTaskClick:l,onTaskDoubleClick:c,onMilestoneClick:u,onMilestoneDoubleClick:d,onTaskDrag:f,onTaskDurationChange:h,onTaskProgressChange:g,onMilestoneDrag:v,dragStep:b,durationStep:y,storageKey:x="gantt"})=>{const S=C.useMemo(()=>{const z=Math.min(26,Math.max(16,o-12)),M=r+(o-z)/2,L=e.map((N,O)=>{const j=uIn(N,i,s,a);return j.x<0||j.x>a?null:p.jsx(sIn,{x:j.x,y:M,width:j.width,height:z,value:N,storageKey:`${x}.${n}.task.${O}`,onClick:l?()=>l(N,n,O):void 0,onDoubleClick:c?()=>c(N,n,O):void 0,onDrag:f?(B,H,K,U)=>f(n,O,B,H,K,U):void 0,onDurationChange:h?(B,H)=>h(n,O,B,H):void 0,onProgressChange:g?(B,H)=>g(n,O,B,H):void 0,timelineStartDate:i,timelineEndDate:s,timelineWidth:a,dragStep:b,durationStep:y},`task-${n}-${O}`)}),R=t.map((N,O)=>{const j=dIn(N,i,s,a);return j===null?null:p.jsx(cIn,{x:j.x,y:M,height:z,value:N,storageKey:`${x}.${n}.milestone.${O}`,onClick:u?()=>u(N,n,O):void 0,onDoubleClick:d?()=>d(N,n,O):void 0,onDrag:v?(B,H)=>v(n,O,B,H):void 0,timelineStartDate:i,timelineEndDate:s,timelineWidth:a},`milestone-${n}-${O}`)});return[...L,...R].filter(Boolean)},[e,t,n,r,a,o,i,s,l,c,u,d,f,h,g,v,b,y,x]);return p.jsx("g",{children:S})},pIn=it($x.Types.Root),qh=e=>e.toISOString().slice(0,-1),DV=(e,t)=>{if(!e)return t;const n=parseInt(e,10);return isNaN(n)?t:n};function hIn(e){var t,n;const r=_(e.style);return{variant:r?(t=_(r.variant))==null?void 0:t.type:void 0,size:r?(n=_(r.size))==null?void 0:n.type:void 0,striped:r?_(r.striped):void 0,interactive:!0,stickyHeader:r?_(r.stickyHeader):void 0,showColumnBorder:r?_(r.showColumnBorder):void 0}}const f8e=function({value:t,height:n="100%",rowHeight:r=36,overscan:a=8,onSortChange:o,enableMultiSort:i=!0,maxSortColumns:s=5,loadingDelay:l=200,enableColumnResizing:c=!0,onTaskClick:u,onMilestoneClick:d,tablePanelSize:f,storageKey:h,timelineBrush:g,timelineWindow:v}){var b;const y=C.useMemo(()=>hIn(t),[t]),x=C.useRef(null),[S,z]=C.useState(0);C.useEffect(()=>{const Xe=x.current;if(!Xe)return;const Rt=new ResizeObserver(([an])=>{an&&z(an.contentRect.width)});return Rt.observe(Xe),()=>Rt.disconnect()},[]);const M=_(t.style),L=N7(),R=M?_(M.plotGutter):void 0,N=(R?_(R.left):void 0)??(L==null?void 0:L.left),O=(R?_(R.right):void 0)??(L==null?void 0:L.right),j=N!==void 0||O!==void 0,B=w9(N),H=w9(O)??0,K=_(t.onCellClick),U=_(t.onCellDoubleClick),Z=_(t.onRowClick),G=_(t.onRowDoubleClick),W=_(t.onSortChange),J=_(t.onTaskClick),ae=_(t.onTaskDoubleClick),ne=_(t.onDrag),Y=C.useMemo(()=>_(t.canDrop),[t.canDrop]),te=t.id,ie=_(t.onTaskProgressChange),ue=_(t.onMilestoneClick),oe=_(t.onMilestoneDoubleClick),ve=_(t.dragStep),se=_(t.durationStep),pe=(b=M?_(M.density):void 0)==null?void 0:b.type,de=pe==="compact"?"sm":pe==="comfortable"?"lg":"md",{header:ge,row:ye}=wI(de),me=M?_(M.rowHeight):void 0,Te=(me!==void 0?Number(me):void 0)??(pe?ye:r),Be=en({key:"gantt"})({size:de}),ht=en({key:"table"})({size:de}),De=mXe(_(t.rowStatus)),Qe=C.useMemo(()=>_(t.review),[t.review]),bt=C.useMemo(()=>t.rows.map(Xe=>Xe.approval),[t]),Ve=ok(Qe,bt),ut=en({key:"reviewChrome"}),_t=C.useMemo(()=>ut({size:de}),[ut,de]),Ft=C.useMemo(()=>{const Xe={};for(const Rt of["success","warning","danger","info","neutral"])Xe[Rt]=ut({size:de,status:Rt}).statusDot??{};return Xe},[ut,de]),wt=C.useRef(null),[Lt,Jt]=M7("colors",["gray.300","fg.info"]),Dt=M?_(M.showToday)??!1:!1,Et=C.useRef(null),Gt=C.useRef(null),[Ke,Se]=C.useState(400),[Re,qe]=C.useState(null),Ye=en({key:"sliceFrame"})(),[$e]=C.useState(()=>new yXe),[lt,Pe]=C.useState(new Map),ot=C.useRef(new Set),kt=C.useMemo(()=>_(t.axis),[t.axis]),Mt=C.useMemo(()=>kt?_(kt.range):void 0,[kt]),At=C.useMemo(()=>kt?_(kt.format):void 0,[kt]),fn=C.useMemo(()=>{var Xe;return kt?(Xe=_(kt.tier))==null?void 0:Xe.type:void 0},[kt]),rt=C.useMemo(()=>{if(Mt)return{start:Mt.min,end:Mt.max};let Xe=null,Rt=null;t.rows.forEach(Rn=>{Rn.tasks.forEach(hr=>{const kr=hr.start,to=hr.end;(Xe===null||kr<Xe)&&(Xe=kr),(Rt===null||to>Rt)&&(Rt=to)}),Rn.milestones.forEach(hr=>{const kr=hr.date;(Xe===null||kr<Xe)&&(Xe=kr),(Rt===null||kr>Rt)&&(Rt=kr)})}),Xe===null&&(Xe=new Date),Rt===null&&(Rt=new Date),Xe.getTime()===Rt.getTime()&&(Xe=new Date(Xe.getTime()-864e5),Rt=new Date(Rt.getTime()+864e5));const an=a$n(fn??"auto",Xe,Rt);return{start:an.floor(Xe),end:an.ceil(Rt)}},[t.rows,Mt,fn]),ln=j?Math.max(0,Ke-H):Ke,Mn=C.useMemo(()=>cie({domain:[rt.start,rt.end],range:[0,ln]}),[rt.start,rt.end,ln]),Jn=C.useMemo(()=>Mn.ticks(Math.max(2,Math.floor(Ke/100))).map(Xe=>Mn(Xe)).filter(Xe=>Xe>=0&&Xe<=Ke),[Mn,Ke]);C.useEffect(()=>{const Xe=Gt.current;if(!Xe)return;const Rt=()=>{const Rn=Xe.offsetWidth;Se(Math.max(200,Rn))};Rt();const an=new ResizeObserver(Rt);return an.observe(Xe),()=>an.disconnect()},[]),C.useEffect(()=>$e.subscribe(()=>{Pe(new Map($e.getStates()))}),[$e]),C.useEffect(()=>()=>{$e.clear()},[$e]);const Er=gI(),_r=C.useMemo(()=>t.columns.map(Xe=>{const Rt=zr(Xe.valueType),an=Tn(Xe.valueType),Rn=_(Xe.width),hr=_(Xe.minWidth),kr=_(Xe.maxWidth),to=Xe.render;return Er.accessor(Na=>Na.cells.get(Xe.key),{id:Xe.key,header:_(Xe.header)??Xe.key,enableSorting:!0,sortingFn:(Na,Go,Si)=>{const ri=Na.original.cells.get(Si),Nr=Go.original.cells.get(Si),no=ri==null?void 0:ri.value,y2=Nr==null?void 0:Nr.value;return no===void 0||y2===void 0?0:an(no,y2)},minSize:DV(hr,80),size:DV(Rn,150),maxSize:DV(kr,400),meta:{print:Rt,columnKey:Xe.key,width:Rn,minWidth:hr,maxWidth:kr,renderFn:to}})}),[t.columns,Er]),{state:fr,setState:Vr}=Pl(h,{sorting:[],columnSizing:{},pinnedColumns:[...t.frozen],tablePanelSize:null}),wr=fr.sorting,{columnPinning:pa,hasFrozen:ar,toggleColumnPin:On}=kNn({frozenFromValue:t.frozen,persistedPinnedColumns:fr.pinnedColumns,setPersistedPinnedColumns:Xe=>Vr(Rt=>({...Rt,pinnedColumns:Xe(Rt.pinnedColumns??[...t.frozen])}))}),st=MNn(wr),dn=C.useCallback(Xe=>{Vr(Rt=>({...Rt,sorting:typeof Xe=="function"?Xe(Rt.sorting):Xe}))},[Vr]),Pn=C.useCallback(Xe=>{dn(Rt=>{const an=typeof Xe=="function"?Xe(Rt):Xe,Rn=an.map(hr=>({columnKey:hr.id,direction:hr.desc?"desc":"asc"}));return o==null||o(Rn),W&&an.forEach((hr,kr)=>{queueMicrotask(()=>W({columnKey:hr.id,sortIndex:BigInt(kr),sortDirection:hr.desc?$("desc",null):$("asc",null)}))}),an})},[o,W,dn]),Hn=C.useCallback((Xe,Rt,an)=>{K&&an!==void 0&&queueMicrotask(()=>K({rowIndex:Xe,columnKey:Rt,cellValue:an}))},[K]),pr=C.useCallback((Xe,Rt,an)=>{U&&an!==void 0&&queueMicrotask(()=>U({rowIndex:Xe,columnKey:Rt,cellValue:an}))},[U]),Hr=C.useCallback(Xe=>{Z&&queueMicrotask(()=>Z({rowIndex:Xe}))},[Z]),lr=C.useCallback(Xe=>{G&&queueMicrotask(()=>G({rowIndex:Xe}))},[G]),vr=C.useCallback((Xe,Rt,an,Rn)=>{J&&queueMicrotask(()=>J({rowIndex:Xe,taskIndex:Rt,taskStart:an,taskEnd:Rn}))},[J]),mo=C.useCallback((Xe,Rt,an)=>{ue&&queueMicrotask(()=>ue({rowIndex:Xe,milestoneIndex:Rt,milestoneDate:an}))},[ue]),Fe=C.useCallback((Xe,Rt,an,Rn)=>{ae&&queueMicrotask(()=>ae({rowIndex:Xe,taskIndex:Rt,taskStart:an,taskEnd:Rn}))},[ae]),Qt=C.useCallback((Xe,Rt,an)=>{oe&&queueMicrotask(()=>oe({rowIndex:Xe,milestoneIndex:Rt,milestoneDate:an}))},[oe]),tt=C.useCallback(Xe=>{(Xe.type==="move"||Xe.type==="resize")&&!t7(Y,Xe)||ne&&queueMicrotask(()=>ne(Xe))},[ne,Y]),gt=C.useCallback((Xe,Rt,an,Rn,hr,kr)=>{tt($("move",{from:{surface:te,row:String(Xe),slot:qh(an),event:P(`t${Rt}`)},to:{surface:te,row:String(Xe),slot:qh(hr),event:A}}))},[tt,te]),Ot=C.useCallback((Xe,Rt,an,Rn)=>{ie&&queueMicrotask(()=>ie({rowIndex:Xe,taskIndex:Rt,previousProgress:an,newProgress:Rn}))},[ie]),yn=C.useCallback((Xe,Rt,an,Rn)=>{tt($("move",{from:{surface:te,row:String(Xe),slot:qh(an),event:P(`m${Rt}`)},to:{surface:te,row:String(Xe),slot:qh(Rn),event:A}}))},[tt,te]),Bt=C.useCallback((Xe,Rt,an,Rn)=>{tt($("resize",{event:{surface:te,row:String(Xe),slot:qh(Rn),event:P(`t${Rt}`)},edge:$("end",null)}))},[tt,te]),vn=C.useCallback((Xe,Rt,an)=>{J&&vr(BigInt(Rt),BigInt(an),Xe.start,Xe.end)},[J,vr]),wn=C.useCallback((Xe,Rt,an)=>{ae&&Fe(BigInt(Rt),BigInt(an),Xe.start,Xe.end)},[ae,Fe]),Or=C.useCallback((Xe,Rt,an)=>{ue&&mo(BigInt(Rt),BigInt(an),Xe.date)},[ue,mo]),Zr=C.useCallback((Xe,Rt,an)=>{oe&&Qt(BigInt(Rt),BigInt(an),Xe.date)},[oe,Qt]),qn=C.useCallback((Xe,Rt,an,Rn)=>{Ot(BigInt(Xe),BigInt(Rt),an,Rn)},[Ot]),ca=ve?{type:ve.type,value:ve.value}:void 0,sa=se?{type:se.type,value:se.value}:void 0,vo=fr.columnSizing,Ya=C.useCallback(Xe=>{Vr(Rt=>({...Rt,columnSizing:typeof Xe=="function"?Xe(Rt.columnSizing):Xe}))},[Vr]),[Ha,fi]=C.useState(null),Ma=C.useCallback(Xe=>{Xe.size[0]!==void 0&&fi(Xe.size[0])},[]),Wa=C.useCallback(Xe=>{Xe.size[0]!==void 0&&Vr(Rt=>({...Rt,tablePanelSize:Xe.size[0]})),fi(null)},[Vr]),Sa=yI({data:t.rows,columns:_r,state:{sorting:wr,columnSizing:vo,columnPinning:pa},onSortingChange:Pn,onColumnSizingChange:Ya,getCoreRowModel:vI(),getSortedRowModel:dXe(),enableMultiSort:i,isMultiSortEvent:()=>i,maxMultiSortColCount:s,enableColumnResizing:c,columnResizeMode:"onChange",enableColumnPinning:!0}),{rows:Oa}=Sa.getRowModel(),Nl=C.useCallback((Xe,Rt,an,Rn,hr,kr)=>{var to;const Na=((to=Oa[Xe])==null?void 0:to.index)??Xe;gt(BigInt(Na),BigInt(Rt),an,Rn,hr,kr)},[gt,Oa]),$l=C.useCallback((Xe,Rt,an,Rn)=>{var hr;const kr=((hr=Oa[Xe])==null?void 0:hr.index)??Xe;yn(BigInt(kr),BigInt(Rt),an,Rn)},[yn,Oa]),Il=C.useCallback((Xe,Rt,an,Rn)=>{var hr;const kr=((hr=Oa[Xe])==null?void 0:hr.index)??Xe;Bt(BigInt(kr),BigInt(Rt),an,Rn)},[Bt,Oa]),M1=Rie(Sa),Sc=Sa.getCenterTotalSize(),yo=C.useMemo(()=>f??(S<=0?50:Math.min(Math.max(Sc/S*100,15),75)),[f,Sc,S]),il=j&&B!==void 0&&S>0?Math.min(Math.max(B/S*100,1),99):void 0,ft=S>0&&S<480,Nt=ft?0:il??Ha??fr.tablePanelSize??yo,sn=TNn(Sa),Fn=bI({count:Oa.length,getScrollElement:()=>Et.current,estimateSize:()=>Te,overscan:a}),xn=Fn.getVirtualItems();C.useEffect(()=>{const Xe=new Set;xn.forEach(hr=>{Xe.add(hr.index)});const Rt=ot.current,an=[];Xe.forEach(hr=>{$e.getRowState(hr).status==="unloaded"&&an.push(hr)});const Rn=[];Rt.forEach(hr=>{Xe.has(hr)||Rn.push(hr)}),an.length>0&&($e.markRowsLoading(an),an.forEach(hr=>$e.scheduleLoaded(hr,l))),Rn.length>0&&$e.markRowsUnloaded(Rn),ot.current=Xe},[xn,$e,l]);const Pa=C.useCallback(()=>{Et.current&&Gt.current&&(Gt.current.scrollTop=Et.current.scrollTop),Et.current&&wt.current&&(wt.current.scrollTop=Et.current.scrollTop)},[]),Qr=C.useCallback(()=>{Et.current&&Gt.current&&(Et.current.scrollTop=Gt.current.scrollTop),Gt.current&&wt.current&&(wt.current.scrollTop=Gt.current.scrollTop)},[]),cr=C.useCallback(()=>{wt.current&&Et.current&&(Et.current.scrollTop=wt.current.scrollTop),wt.current&&Gt.current&&(Gt.current.scrollTop=wt.current.scrollTop)},[]),Ar=C.useMemo(()=>ft?[{id:"table",minSize:0},{id:"timeline",minSize:20}]:[{id:"table",minSize:20},{id:"timeline",minSize:20}],[ft]),Cr=ne!==void 0,[Aa,qo]=C.useState(()=>new Map);C.useEffect(()=>{qo(new Map)},[t]);const bo=C.useCallback((Xe,Rt)=>{var an;const Rn=Gt.current,hr=Rn==null?void 0:Rn.getBoundingClientRect(),kr=hr?Math.max(0,Math.min(ln,Xe-hr.left)):0,to=Mn.invert(kr),Na=ca?dx(to,ca):to,Go=hr?Rt-hr.top+((Rn==null?void 0:Rn.scrollTop)??0)-ge:0,Si=xn.find(Nr=>Go>=Nr.start&&Go<Nr.end),ri=Si!==void 0?((an=Oa[Si.index])==null?void 0:an.index)??Si.index:0;return{surface:te,row:String(ri),slot:qh(Na)}},[ln,Mn,ca,xn,Oa,te,ge]),qr=C.useCallback((Xe,Rt,an)=>Y===void 0||Rt===void 0||an===void 0?!0:t7(Y,CXe(Xe,bo(Rt,an))),[Y,bo]),Gs=C.useMemo(()=>Cr?{surface:te,row:"",slot:""}:null,[Cr,te]),yr=lk(Gs,!1,qr,bo),Jr=C.useCallback((Xe,Rt)=>{if(Xe.type==="add"){const an=Number(Xe.value.into.row),Rn=new Date(Xe.value.into.slot);if(Number.isFinite(an)&&!Number.isNaN(Rn.getTime())){const hr=ca?AXe(ca):864e5,kr={start:Rn,end:new Date(Rn.getTime()+hr),label:(Rt==null?void 0:Rt.label)!==void 0?P({value:Rt.label,align:A,verticalAlign:A,color:A,fontWeight:A,fontStyle:A,fontSize:A}):A,progress:A,state:$("proposed",$("added",null)),status:A,popover:A};qo(to=>{const Na=new Map(to);return Na.set(an,[...Na.get(an)??[],kr]),Na})}}ne&&queueMicrotask(()=>ne(Xe))},[ne,ca]),ja=C.useMemo(()=>ne!==void 0?{id:te,sources:[...t.sources],kinds:{add:!0,move:!0,resize:!0},onDrag:Jr}:null,[ne,te,t.sources,Jr]);sk(ja);const ta=Tt(M?_(M.height):void 0)??n,Io=Tt(M?_(M.maxHeight):void 0),xi=Ve!==void 0&&Ve.showFoot,wi=Ve!==void 0&&Qe!==void 0?p.jsxs(V,{width:m6,flexShrink:0,display:"flex",flexDirection:"column",height:"100%",background:"bg.surface",children:[p.jsx(V,{css:_t.decisionHeader,"data-slot":"decisionHeader",height:`${ge}px`,flexShrink:0,children:Qe.columnLabel}),p.jsx(V,{ref:wt,flex:"1",overflowY:"auto",onScroll:cr,css:{scrollbarWidth:"none"},children:p.jsx(V,{position:"relative",height:`${Fn.getTotalSize()}px`,children:xn.map(Xe=>{var Rt;const an=Oa[Xe.index];if(!an)return null;const Rn=(Rt=_(an.original.status))==null?void 0:Rt.type;return p.jsxs(V,{css:_t.decisionCol,"data-slot":"decisionCol","data-status":Rn,position:"absolute",top:0,left:0,right:0,transform:`translateY(${Xe.start}px)`,height:`${Xe.size}px`,children:[Rn!==void 0&&p.jsx(V,{as:"span",css:Ft[Rn],"data-slot":"statusDot",position:"absolute",left:"12px"}),p.jsx(SI,{rowIndex:an.index,controller:Ve})]},an.id)})})})]}):null,pi=p.jsxs(V,{ref:x,width:"100%",...xi?{flex:"1",minHeight:0}:{height:ta},...Io!==void 0?{maxHeight:Io,minHeight:0}:{},overflow:"hidden",display:"flex",children:[p.jsx(V,{flex:"1",minWidth:0,height:"100%",children:p.jsxs(oNe,{size:[Nt,100-Nt],panels:Ar,width:"100%",height:"100%",onResize:Ma,onResizeEnd:Wa,children:[p.jsx(SK,{id:"table",children:p.jsx(V,{ref:Et,height:"100%",overflowY:"auto",position:"relative",onScroll:Pa,css:CNn,children:p.jsxs(CK,{...y,style:{...M1,width:"100%",minWidth:j?0:Sa.getCenterTotalSize(),tableLayout:"fixed"},children:[p.jsx(lNe,{style:{display:"block"},position:"sticky",top:0,zIndex:1,css:Be.header,children:Sa.getHeaderGroups().map(Xe=>p.jsx($f,{style:{display:"flex",width:"100%",height:`${ge}px`},children:Xe.headers.map(Rt=>p.jsx(xf,{css:ht.columnHeader,color:"gray.500",_hover:{bg:"bg.muted","& .col-controls":{opacity:1}},transition:"background 0.2s",style:_ie(Rt,ar,vo,Rt.id===sn),children:p.jsx(zNn,{header:Rt,toggleColumnPin:On,getSortIndex:st,enableMultiSort:i,enableColumnResizing:c})},Rt.id))},Xe.id))}),p.jsx(kK,{style:{display:"block",position:"relative",height:`${Fn.getTotalSize()}px`},children:xn.map(Xe=>{const Rt=Oa[Xe.index];if(!Rt)return null;const an=Xe.index,Rn=lt.get(an)||{status:"unloaded"},hr=!$e.isRowLoaded(an)||Rn.status==="loading",kr=BigInt(Xe.index),to=De(Xe.index);return p.jsx($f,{style:{display:"flex",position:"absolute",top:0,left:0,width:"100%",height:`${Xe.size}px`,transform:`translateY(${Xe.start}px)`,cursor:Z||G?"pointer":void 0,background:to},onClick:Z?()=>Hr(kr):void 0,onDoubleClick:G?()=>lr(kr):void 0,children:Rt.getVisibleCells().map(Na=>{var Go;const Si=Na.getValue(),ri=Na.column.columnDef.meta,Nr=(ri==null?void 0:ri.columnKey)??Na.column.id,no=Lie(Na,ar,vo,Na.column.id===sn),y2=K?T1=>{T1.stopPropagation(),Hn(kr,Nr,Si)}:void 0,P4=U?T1=>{T1.stopPropagation(),pr(kr,Nr,Si)}:void 0;if(hr)return p.jsx(ds,{style:no,children:p.jsx(d4,{height:"20px",width:"80%"})},Na.id);if(Si==null)return p.jsx(ds,{style:no,onClick:y2,onDoubleClick:P4},Na.id);if(ri!=null&&ri.renderFn){const T1=ri.renderFn({rowIndex:kr,columnKey:Nr,cellValue:Si});return p.jsx(ds,{style:no,onClick:y2,onDoubleClick:P4,children:p.jsx(mn,{value:T1,storageKey:`${h}.render.${Na.column.id}`})},Na.id)}return p.jsx(ds,{style:no,onClick:y2,onDoubleClick:P4,children:p.jsx(Ie,{children:((Go=ri==null?void 0:ri.print)==null?void 0:Go.call(ri,Si.value))??null})},Na.id)})},Rt.id)})})]})})}),!j&&p.jsx(iNe,{id:"table:timeline",css:{_after:{top:`calc(50% + ${ge/2}px)`}}}),p.jsx(SK,{id:"timeline",children:p.jsxs(V,{ref:Gt,width:"100%",height:"100%",overflowY:"auto",overflowX:"hidden",position:"relative",onScroll:Qr,css:xI,children:[p.jsxs(V,{position:"sticky",top:0,zIndex:1,css:Be.header,children:[p.jsx(s$n,{startDate:rt.start,endDate:rt.end,width:Ke,height:ge,columnHeaderStyles:ht.columnHeader,tier:fn,format:At}),j&&H>0&&p.jsx(V,{position:"absolute",top:0,right:0,width:`${H}px`,height:`${ge}px`,background:"bg.surface",pointerEvents:"none",zIndex:1}),g&&(()=>{const Xe=v!==void 0?{lo:Math.max(0,Math.min(ln,Mn(v.from))),hi:Math.max(0,Math.min(ln,Mn(v.to)))}:void 0,Rt=Xe!==void 0&&Number.isFinite(Xe.lo)&&Number.isFinite(Xe.hi)&&Xe.hi>Xe.lo,an=Re!==null?Roe(Re):void 0;return p.jsxs(V,{position:"absolute",inset:0,cursor:Re!==null?fUe(Re.mode):"crosshair","data-brush-track":!0,onPointerDown:Rn=>{const hr=Rn.currentTarget;try{hr.setPointerCapture(Rn.pointerId)}catch{}const kr=hr.getBoundingClientRect(),to=Rn.clientX-kr.left,Na=Rt?Xe:void 0;qe({mode:uUe(to,Na),start:to,current:to,width:ln,win:Na})},onPointerMove:Rn=>{if(!Re)return;const hr=Rn.currentTarget.getBoundingClientRect().left;qe({...Re,current:Rn.clientX-hr})},onPointerUp:()=>{if(!Re)return;qe(null);const Rn=dUe(Re);Rn.kind==="clear"?g(null):Rn.kind==="commit"&&g({from:Mn.invert(Rn.lo),to:Mn.invert(Rn.hi)})},children:[Re===null&&Rt&&p.jsxs(p.Fragment,{children:[p.jsx(V,{"data-brush-window":!0,css:Ye.brushWindow,left:`${Xe.lo}px`,width:`${Xe.hi-Xe.lo}px`,opacity:.18}),p.jsx(V,{"data-brush-handle":"lo",css:Ye.brushHandle,left:`${Xe.lo}px`}),p.jsx(V,{"data-brush-handle":"hi",css:Ye.brushHandle,left:`${Xe.hi}px`})]}),an!==void 0&&p.jsx(V,{position:"absolute",top:0,bottom:0,left:`${an.lo}px`,width:`${an.hi-an.lo}px`,bg:"accent.brand",opacity:.18,borderXWidth:"1px",borderColor:"accent.brand",pointerEvents:"none"})]})})()]}),p.jsxs(V,{position:"relative",ref:yr,children:[p.jsx(CK,{...y,style:{width:"100%",tableLayout:"fixed",position:"relative"},children:p.jsx(kK,{style:{display:"block",position:"relative",height:`${Fn.getTotalSize()}px`},children:xn.map(Xe=>{const Rt=Oa[Xe.index];if(!Rt)return null;const an=De(Xe.index);return p.jsxs($f,{style:{display:"flex",position:"absolute",top:0,left:0,width:"100%",height:`${Xe.size}px`,transform:`translateY(${Xe.start}px)`,background:an},children:[j&&H>0&&p.jsx(V,{position:"absolute",top:0,right:0,bottom:"-1px",width:`${H}px`,background:"bg.surface",pointerEvents:"none",zIndex:2,"aria-hidden":"true"}),p.jsx(ds,{style:{width:"100%",padding:0},children:p.jsx("svg",{width:"100%",height:Xe.size,children:p.jsx(fIn,{tasks:[...Rt.original.tasks,...Aa.get(Rt.index)??[]],milestones:Rt.original.milestones,rowIndex:Xe.index,y:0,width:Ke,height:Xe.size,startDate:rt.start,endDate:rt.end,storageKey:`${h}.gantt`,onTaskClick:vn,onTaskDoubleClick:wn,onMilestoneClick:Or,onMilestoneDoubleClick:Zr,onTaskDrag:ne?Nl:void 0,onTaskDurationChange:ne?Il:void 0,onTaskProgressChange:ie?qn:void 0,onMilestoneDrag:ne?$l:void 0,dragStep:ca,durationStep:sa})})})]},Rt.id)})})}),p.jsxs("svg",{width:Ke,height:Fn.getTotalSize(),style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:1},children:[Jn.map((Xe,Rt)=>p.jsx("line",{x1:Xe,y1:0,x2:Xe,y2:Fn.getTotalSize(),stroke:Lt,strokeWidth:1,strokeDasharray:"4 4",opacity:.6},`grid-${Rt}`)),Dt&&(()=>{const Xe=Mn(new Date);return Xe<0||Xe>Ke?null:p.jsx("line",{x1:Xe,y1:0,x2:Xe,y2:Fn.getTotalSize(),stroke:Jt,strokeWidth:1})})()]})]})]})})]})}),wi]}),Dl=xi&&Ve!==void 0?p.jsxs(V,{display:"flex",flexDirection:"column",width:"100%",height:ta,...Io!==void 0?{maxHeight:Io}:{},children:[pi,p.jsx(ik,{controller:Ve,storageKey:h??"gantt"})]}):pi;return pe!==void 0?p.jsx(hu,{value:pe,children:Dl}):Dl},gIn=C.memo(function(t){const n=_(t.value.slice),r=n==null?void 0:n.slice;rl(r==null?void 0:r.key);const a=en({key:"sliceFrame"})();if(n===void 0||r===void 0)return p.jsx(f8e,{...t});const o=r.read(),i=n.affordances.map(v=>v.type),s=Lv(i,o).filter(v=>v!=="brush"),l=Number(r.totalCount()),c=Number(r.resultCount()),u=l>0?Math.round((1-c/l)*100):0,d=i.includes("brush"),f=d?v=>{if(v===null){r.setRange(A);return}r.setRange(P($("datetime",{from:v.from,to:v.to})))}:void 0,h=d?_(o.range):void 0,g=(h==null?void 0:h.type)==="datetime"?h.value:void 0;return p.jsxs(V,{css:a.root,children:[p.jsx(V,{css:a.frameEyebrow,children:p.jsx(zd,{slice:r,affordanceKinds:s})}),p.jsx(V,{css:a.frameBody,children:p.jsx(f8e,{...t,...f!==void 0?{timelineBrush:f}:{},...g!==void 0?{timelineWindow:g}:{}})}),p.jsxs(V,{css:a.frameFooter,children:[p.jsx(V,{as:"span",css:a.frameFooterStat,children:c.toLocaleString()}),p.jsx(V,{as:"span",children:`rows · of ${l.toLocaleString()}`}),u>0&&p.jsx(V,{as:"span",css:a.frameFooterDelta,children:`· −${u}%`})]})]})},(e,t)=>pIn(e.value,t.value)),mIn=it(Uft.Types.Root),vIn={success:A$,warning:Tv,danger:VC,info:Ev,neutral:Lae};function yIn(e){var t;const n=(t=_(e.density))==null?void 0:t.type;return n==="compact"?"sm":n==="comfortable"?"lg":"md"}function bIn(e){const t=[];for(const n of e.rows)for(const r of n.events){t.push(r.slot);const a=_(r.endSlot);a!==void 0&&t.push(a)}return t}const xIn=864e5,p8e=500;function NXe(e){switch(e){case"hour":return lie;case"day":return $v;case"week":return ek;case"month":return g6;case"quarter":return g6.every(3)??g6;case"year":return p4}}function wIn(e){const t=_(e.axis.range);if(t!==void 0)return Sr(t,{time:n=>n,number:()=>{},ordinal:()=>{}},void 0)}function SIn(e){var t;const n=(t=_(e.axis.resolution))==null?void 0:t.type;if(n!==void 0&&n!=="auto")return n;const r=wIn(e);return r!==void 0&&r.max.getTime()-r.min.getTime()<=14*xIn?"day":"month"}function CIn(e,t){switch(e){case"hour":return"HH:mm";case"day":return"ddd DD";case"week":return"MMM DD";case"year":return"YYYY";default:return t?"MMM YYYY":"MMM"}}function kIn(e,t){return`t:${NXe(t).floor(e).toISOString()}`}function zIn(e,t){const n=e.axis.scale.type,r=_(e.axis.range),a=bIn(e);if(n==="number"){let f=1,h=1;const g=r!==void 0?Sr(r,{number:b=>b,time:()=>{},ordinal:()=>{}},void 0):void 0;if(g)f=g.min,h=g.max;else{const b=a.map(y=>Sr(y,{number:x=>x,time:()=>0,ordinal:()=>0},0));f=b.length?Math.floor(Math.min(...b)):1,h=b.length?Math.ceil(Math.max(...b)):1}const v=[];for(let b=f;b<=h;b++)v.push({key:`n:${b}`,label:String(b)});return v}if(n==="ordinal"){let f=[];if(r!==void 0)f=Sr(r,{ordinal:h=>h,number:()=>[],time:()=>[]},[]);else{const h=new Set;for(const g of a){const v=Sr(g,{ordinal:b=>b,number:()=>"",time:()=>""},"");v&&!h.has(v)&&(h.add(v),f.push(v))}}return f.map(h=>({key:`o:${h}`,label:h}))}let o,i;const s=r!==void 0?Sr(r,{time:f=>f,number:()=>{},ordinal:()=>{}},void 0):void 0,l=s!==void 0;if(s)o=s.min,i=s.max;else{const f=a.map(h=>Sr(h,{time:g=>g.getTime(),number:()=>0,ordinal:()=>0},0)).filter(h=>h>0);o=f.length?new Date(Math.min(...f)):new Date(0),i=f.length?new Date(Math.max(...f)):new Date(0)}const c=NXe(t),u=_(e.axis.format)??CIn(t,o.getFullYear()!==i.getFullYear()),d=[];for(let f=c.floor(o);l?f.getTime()<i.getTime():f.getTime()<=i.getTime();f=c.offset(f,1)){if(d.length>=p8e){console.warn(`[Planner] time axis truncated at ${p8e} ${t} columns — narrow the range or use a coarser resolution.`);break}d.push({key:`t:${f.toISOString()}`,label:km(u,f)})}return d.length?d:[{key:"t:0",label:""}]}function s3(e,t,n){const r=Sr(e,{number:a=>`n:${Math.round(a)}`,ordinal:a=>`o:${a}`,time:a=>kIn(a,n)},"");return t.findIndex(a=>a.key===r)}function Gh(e){return e.key.slice(2)}function h8e(e,t){return t!==void 0?`${e}:${t}`:e}function $Xe(e){return Sr(e,{committed:()=>"committed",rejected:()=>"rejected",proposed:t=>Sr(t,{added:()=>"proposedAdded",model:()=>"proposedModel",removed:()=>"proposedRemoved"},"proposedAdded")},"committed")}function MIn(e,t){return Sr(e,{number:n=>String(n),ordinal:n=>n,time:n=>km(t==="hour"?"MMM DD HH:mm":"MMM DD",n)},"")}const OV={start:"flex-start",center:"center",end:"flex-end"},g8e={success:{background:"bg.success.subtle",color:"{colors.status.pos}",borderColor:"{colors.status.pos}"},warning:{background:"bg.warning.subtle",color:"{colors.status.warn}",borderColor:"{colors.status.warn}"},danger:{background:"bg.danger.subtle",color:"{colors.status.neg}",borderColor:"{colors.status.neg}"},info:{background:"bg.info.subtle",color:"{colors.status.info}",borderColor:"{colors.status.info}"},neutral:{background:"transparent",color:"fg.default",borderColor:"border.strong"}};function TIn(e,t,n){var r,a,o;const i=(r=_(e.stretch))==null?void 0:r.type,s=_(e.content),l=s?(a=_(s.horizontal))==null?void 0:a.type:void 0,c=s?(o=_(s.vertical))==null?void 0:o.type:void 0,u={};return(i==="horizontal"||i==="both")&&(u.width="100%"),(i==="vertical"||i==="both")&&(u.height="100%"),l&&(u.justifyContent=OV[l]),c&&(u.alignItems=OV[c]),t==="point"&&(c?u.alignSelf=OV[c]:n||(u.alignSelf="flex-start")),u}function jV({surface:e,row:t,slot:n,vetoFor:r,children:a,...o}){const i=C.useMemo(()=>e!==void 0&&t!==void 0&&n!==void 0?{surface:e,row:t,slot:n}:null,[e,t,n]),s=C.useMemo(()=>i!==null&&r!==void 0?r(i):void 0,[i,r]),l=lk(i,!1,s);return p.jsx(V,{ref:l,...o,children:a})}function FV({event:e,eventStyle:t,gripStyle:n,shape:r,inLane:a=!1,dnd:o}){const i=_(e.popover),s=_(e.hovercard),l=$Xe(e.state),c=l==="proposedAdded"||l==="proposedModel"||l==="proposedRemoved",u=C.useMemo(()=>o&&c?{surface:o.surface,row:o.row,slot:o.slot,event:o.event}:null,[o,c]),d=C.useMemo(()=>p.jsx("span",{children:e.label}),[e.label]),f=CI(u,d,u===null),h=t8e(u,"start",d,u===null||r!=="span"),g=C.useMemo(()=>u&&(o==null?void 0:o.endSlot)!==void 0?{...u,slot:o.endSlot}:u,[u,o]),v=t8e(g,"end",d,g===null||r!=="span"),b={...t,...TIn(e,r,a),...c?{paddingInlineStart:"3px"}:{},...u?{position:"relative"}:{}},y=p.jsxs(V,{css:b,"data-slot":"event","data-state":l,onPointerDown:f,...u&&f?{"data-draggable":""}:{},children:[c&&p.jsx(V,{as:"span",css:n,"data-slot":"grip","data-drag-grip":"",children:p.jsx(Ut,{icon:g5})}),p.jsx(V,{as:"span",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minW:0,children:e.label}),r==="span"&&h&&p.jsx(V,{as:"span",position:"absolute",left:"-3px",top:"0",bottom:"0",width:"6px",cursor:"ew-resize",onPointerDown:z=>{z.stopPropagation(),h(z)},"data-resize-edge":"start"}),r==="span"&&v&&p.jsx(V,{as:"span",position:"absolute",right:"-3px",top:"0",bottom:"0",width:"6px",cursor:"ew-resize",onPointerDown:z=>{z.stopPropagation(),v(z)},"data-resize-edge":"end"})]});if(i===void 0&&s===void 0)return y;const x=s!==void 0?p.jsx(go,{children:p.jsx(Nre,{children:p.jsx($re,{padding:"14px 16px",minW:"240px",maxW:"360px",fontSize:"13px",children:p.jsx(mn,{value:s,storageKey:"planner.hovercard"})})})}):null,S=i!==void 0?p.jsx(go,{children:p.jsx(M4,{children:p.jsx(T4,{padding:"14px 16px",minW:"240px",maxW:"360px",fontSize:"13px",children:p.jsx($C,{padding:0,children:p.jsx(mn,{value:i,storageKey:"planner.popover"})})})})}):null;return i!==void 0&&s!==void 0?p.jsxs(nu,{positioning:{placement:"top"},children:[p.jsxs(kL,{openDelay:150,positioning:{placement:"top"},children:[p.jsx(R6,{asChild:!0,children:p.jsx(zL,{asChild:!0,children:y})}),x]}),S]}):s!==void 0?p.jsxs(kL,{openDelay:150,positioning:{placement:"top"},children:[p.jsx(zL,{asChild:!0,children:y}),x]}):p.jsxs(nu,{positioning:{placement:"top"},children:[p.jsx(R6,{asChild:!0,children:y}),S]})}const EIn=C.memo(function({value:t,storageKey:n}){var r,a;const o=(r=_(t.density))==null?void 0:r.type,i=yIn(t),s=en({key:"planner"}),l=en({key:"table"}),c=_(t.rowHover)===!0,u=Tt(_(t.maxHeight)),d=Tt(_(t.height)),f=C.useMemo(()=>s({size:i,rowHover:c,scroll:!1}),[s,i,c]),h=C.useMemo(()=>l({size:i}).columnHeader??{},[l,i]),{header:g,row:v}=wI(i),b=t.variant.type==="span"?"span":"point",y=C.useMemo(()=>SIn(t),[t]),x=C.useMemo(()=>zIn(t,y),[t,y]),S=t.axis.buckets,z=Math.max(x.length,1),M=C.useMemo(()=>{const tt=["committed","proposedAdded","proposedModel","proposedRemoved","rejected"],gt={};for(const Ot of tt)gt[Ot]=s({size:i,shape:b,state:Ot}).event??{};return gt},[s,i,b]),L=C.useMemo(()=>{const tt={};for(const gt of["success","warning","danger","info","neutral"])tt[gt]=s({size:i,status:gt});return tt},[s,i]),R=C.useMemo(()=>({animation:(s({size:i,shape:b,animation:"pulse"}).event??{}).animation,"@media (prefers-reduced-motion: reduce)":{animation:"none"}}),[s,i,b]),N=C.useMemo(()=>_(t.onSelectRow),[t.onSelectRow]),[O,j]=C.useState(void 0);C.useEffect(()=>{j(void 0)},[t]);const B=C.useCallback(tt=>{j(tt),N&&queueMicrotask(()=>N({rowIndex:BigInt(tt)}))},[N]),H=C.useMemo(()=>_(t.onDrag),[t.onDrag]),K=C.useMemo(()=>_(t.canDrop),[t.canDrop]),U=t.id,Z=t.axis.scale.type,G=H!==void 0,[W,J]=C.useState(()=>new Map);C.useEffect(()=>{J(new Map)},[t]);const ae=C.useCallback(tt=>{let gt=tt,Ot;const yn=tt.lastIndexOf(":");if(yn>0&&!tt.endsWith("Z")){const vn=tt.slice(yn+1);S.some(wn=>wn.key===vn)&&(gt=tt.slice(0,yn),Ot=vn)}if(Z==="number"){const vn=Number(gt);return Number.isFinite(vn)?{slot:$("number",vn),bucket:Ot}:void 0}if(Z==="ordinal")return{slot:$("ordinal",gt),bucket:Ot};const Bt=new Date(gt);return Number.isNaN(Bt.getTime())?void 0:{slot:$("time",Bt),bucket:Ot}},[Z,S]),ne=kI(K),Y=C.useCallback((tt,gt)=>{if(!((tt.type==="add"||tt.type==="move"||tt.type==="resize")&&!t7(K,tt))){if(tt.type==="add"){const Ot=Number(tt.value.into.row),yn=ae(tt.value.into.slot);if(Number.isFinite(Ot)&&yn!==void 0){const Bt={key:P(`local:${tt.value.from.library}:${tt.value.from.key}:${tt.value.into.slot}`),slot:yn.slot,endSlot:A,bucket:yn.bucket!==void 0?P(yn.bucket):A,label:(gt==null?void 0:gt.label)??tt.value.from.key,state:$("proposed",$("added",null)),popover:A,stretch:A,content:A,tone:A,color:A,colorPalette:A,animation:A,hovercard:A};J(vn=>{const wn=new Map(vn);return wn.set(Ot,[...wn.get(Ot)??[],Bt]),wn})}}H&&queueMicrotask(()=>H(tt))}},[H,K,ae]),te=C.useMemo(()=>G?{id:U,sources:[...t.sources],kinds:{add:!0,move:!0,remove:!0,resize:b==="span"},onDrag:Y}:null,[G,U,t.sources,Y,b]);sk(te);const ie=C.useMemo(()=>_(t.review),[t.review]),ue=C.useMemo(()=>t.rows.map(tt=>tt.approval),[t]),oe=ok(ie,ue),ve=oe!==void 0,se=en({key:"reviewChrome"}),pe=C.useMemo(()=>se({size:i}),[se,i]),de=C.useMemo(()=>{const tt={};for(const gt of["success","warning","danger","info","neutral"])tt[gt]=se({size:i,status:gt}).statusDot??{};return tt},[se,i]),ge=C.useMemo(()=>gI(),[]),ye=!1,me=C.useMemo(()=>t.columns.map((tt,gt)=>{var Ot;const yn=_(tt.width),Bt=((Ot=_(tt.align))==null?void 0:Ot.type)==="end",vn=yn?parseInt(yn,10)||150:gt===0?150:110;return ge.accessor(wn=>{var Or;return((Or=wn.cells.get(tt.key))==null?void 0:Or.value)??""},{id:tt.key,header:tt.header,enableSorting:!1,size:vn,minSize:60,meta:{columnKey:tt.key,width:yn??`${vn}px`,alignEnd:Bt}})}),[t.columns,ge]),{state:Me,setState:Te}=Pl(n,{columnSizing:{}}),Be=Me.columnSizing,ht=C.useCallback(tt=>{Te(gt=>({...gt,columnSizing:typeof tt=="function"?tt(gt.columnSizing):tt}))},[Te]),De=yI({data:t.rows,columns:me,state:{columnSizing:Be},onColumnSizingChange:ht,getCoreRowModel:vI(),enableSorting:!1,enableColumnResizing:!0,columnResizeMode:"onChange"}),Qe=Rie(De),bt=De.getVisibleLeafColumns(),Ve=((a=De.getHeaderGroups()[0])==null?void 0:a.headers)??[],ut=`${De.getTotalSize()}px`,_t=_(t.slotMinWidth)??"56px",Ft=parseInt(_t,10)||56,wt=`repeat(${z}, minmax(${_t}, 1fr))`,Lt={position:"sticky",left:0,zIndex:1,background:"bg.surface"},Jt={...Lt,zIndex:2,background:"bg.panel"},Dt=ve?`${ut} 1fr ${m6}`:`${ut} 1fr`,Et=ve?`calc(${ut} + ${z*Ft}px + ${m6})`:`calc(${ut} + ${z*Ft}px)`,Gt={position:"sticky",right:0,zIndex:1,background:"bg.surface"},Ke={...Gt,zIndex:2,background:"bg.panel"},Se=N7(),Re=_(t.plotGutter),qe=(Re?_(Re.left):void 0)??(Se==null?void 0:Se.left),Ye=(Re?_(Re.right):void 0)??(Se==null?void 0:Se.right),$e=qe!==void 0||Ye!==void 0,lt=Ye??"0px",Pe=w9(qe),ot=De.getTotalSize(),kt=$e&&Pe!==void 0&&ot>0?Pe/ot:1,Mt=kt!==1?Object.fromEntries(Object.entries(Qe).map(([tt,gt])=>[tt,typeof gt=="string"&>.endsWith("px")?`${parseFloat(gt)*kt}px`:gt])):Qe,At=qe??ut,fn=$e?ve?`${At} 1fr ${m6} ${lt}`:`${At} 1fr ${lt}`:Dt,rt=$e?`repeat(${z}, minmax(0, 1fr))`:wt,ln=$e?void 0:Et,Mn=_(t.now),Jn=Mn!==void 0?s3(Mn,x,y):-1,Er=tt=>{var gt,Ot,yn;let Bt=M[$Xe(tt.state)];const vn=(gt=_(tt.tone))==null?void 0:gt.type;vn!==void 0&&g8e[vn]!==void 0&&(Bt={...Bt,...g8e[vn]});const wn=_(tt.color),Or=(Ot=_(tt.colorPalette))==null?void 0:Ot.type;return wn!==void 0?Bt={...Bt,background:"transparent",color:wn,borderColor:wn}:Or!==void 0&&(Bt={...Bt,colorPalette:Or,background:"colorPalette.subtle",color:"colorPalette.fg",borderColor:"colorPalette.solid"}),((yn=_(tt.animation))==null?void 0:yn.type)==="pulse"&&(Bt={...Bt,...R}),Bt},_r=(tt,gt,Ot)=>tt.events.filter(yn=>{if(s3(yn.slot,x,y)!==gt)return!1;const Bt=_(yn.bucket);return Ot===void 0?Bt===void 0:Bt===Ot}),fr=(tt,gt)=>tt.events.filter(Ot=>s3(Ot.slot,x,y)===gt),Vr=(tt,gt)=>{for(const Ot of tt.markers)if(s3(Ot.slot,x,y)===gt)return Ot},wr=C.useMemo(()=>{const tt=[];return t.rows.forEach((gt,Ot)=>{const yn=_(gt.group),Bt=tt[tt.length-1];Bt&&Bt.label===yn?Bt.rows.push({row:gt,index:Ot}):tt.push({label:yn,rows:[{row:gt,index:Ot}]})}),tt},[t.rows]),pa=C.useMemo(()=>{const tt=new Set;return S.length>0&&t.rows.forEach((gt,Ot)=>{x.some((Bt,vn)=>gt.events.some(wn=>s3(wn.slot,x,y)===vn&&_(wn.bucket)!==void 0)&>.events.some(wn=>s3(wn.slot,x,y)===vn&&_(wn.bucket)===void 0))&&tt.add(Ot)}),tt},[t.rows,x,S,y]);C.useEffect(()=>{pa.size>0&&console.warn(`[Planner] ${pa.size} row(s) have a bucketless event sharing a bucketed cell — rendered in an "N/A" lane. Give the event a bucket, or move it to its own column.`)},[pa]);const ar=tt=>S.length>0&&tt.events.some(gt=>_(gt.bucket)!==void 0),On=(tt,gt)=>{if(!ar(tt))return!1;const Ot=fr(tt,gt);return Ot.length===0?!0:Ot.some(yn=>_(yn.bucket)!==void 0)},st={key:"__na__",label:"N/A"},dn=(tt,gt,Ot,yn)=>{if(!G)return;const Bt=_(tt.key);if(Bt===void 0)return;const vn=x[Ot];if(vn===void 0)return;const wn=_(tt.endSlot),Or=wn!==void 0?x[s3(wn,x,y)]:void 0;return{surface:U,row:String(gt),slot:h8e(Gh(vn),yn),event:Bt,endSlot:Or!==void 0?Gh(Or):void 0}},Pn=(tt,gt,Ot,yn)=>On(tt,Ot)?(yn?[...S,st]:S).map(vn=>{const wn=vn.key===st.key,Or=wn?_r(tt,Ot,void 0):_r(tt,Ot,vn.key),Zr=!wn&&x[Ot]!==void 0?h8e(Gh(x[Ot]),vn.key):void 0;return p.jsxs(jV,{css:f.bucket,"data-slot":"bucket","data-na":wn?"":void 0,height:`${v}px`,surface:U,row:String(gt),slot:G?Zr:void 0,vetoFor:ne,...G&&Zr!==void 0?{"data-drop-row":String(gt),"data-drop-slot":Zr}:{},children:[p.jsx(V,{css:f.bucketLabel,"data-slot":"bucketLabel",children:vn.label}),Or.map((qn,ca)=>p.jsx(FV,{event:qn,eventStyle:Er(qn),gripStyle:f.grip,shape:"point",inLane:!0,dnd:dn(qn,gt,Ot,wn?void 0:vn.key)},ca))]},vn.key)}):_r(tt,Ot).map((vn,wn)=>p.jsx(FV,{event:vn,eventStyle:Er(vn),gripStyle:f.grip,shape:"point",dnd:dn(vn,gt,Ot)},wn)),Hn=p.jsxs(V,{css:f.header,"data-slot":"header",display:"grid",gridTemplateColumns:fn,minWidth:ln,height:`${g}px`,children:[p.jsx(V,{css:Jt,display:"flex",width:"100%",style:Mt,children:Ve.map(tt=>{var gt;return p.jsxs(V,{css:h,"data-slot":"colHeader",position:"relative",display:"flex",alignItems:"center",justifyContent:(gt=tt.column.columnDef.meta)!=null&>.alignEnd?"flex-end":"flex-start",style:_ie(tt,ye,Be,!1),children:[p.jsx(V,{as:"span",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minW:0,children:tt.column.columnDef.header}),p.jsx(Eie,{header:tt})]},tt.id)})}),p.jsxs(V,{position:"relative",display:"grid",gridTemplateColumns:rt,children:[x.map((tt,gt)=>p.jsxs(V,{css:{...h,position:"relative",display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"},"data-slot":"headerCell",children:[tt.label,gt<x.length-1&&p.jsx(gXe,{})]},tt.key)),Jn>=0&&p.jsx(V,{css:f.nowLine,left:`calc(${Jn} * (100% / ${z}))`})]}),ve&&ie&&p.jsx(V,{css:{...pe.decisionHeader,...Ke},"data-slot":"decisionHeader",children:ie.columnLabel}),$e&&p.jsx(V,{"data-slot":"headerGutter","aria-hidden":"true",background:"bg.surface"})]}),pr=[];for(const tt of wr){tt.label!==void 0&&pr.push({kind:"groupHead",label:tt.label});for(const gt of tt.rows)pr.push({kind:"row",rowBase:gt.row,index:gt.index})}const Hr=tt=>{var gt;const Ot=pr[tt];if(Ot===void 0)return null;if(Ot.kind==="groupHead")return p.jsx(V,{css:f.groupHead,"data-slot":"groupHead",minWidth:ln,display:"grid",gridTemplateColumns:fn,children:p.jsx(V,{css:{...Lt,...f.groupHeadCell,background:"bg.panel"},"data-slot":"groupHeadCell",children:Ot.label})});const{rowBase:yn,index:Bt}=Ot,vn=W.get(Bt),wn=vn!==void 0&&vn.length>0?{...yn,events:[...yn.events,...vn]}:yn,Or=ve?(gt=_(wn.status))==null?void 0:gt.type:void 0,Zr=pa.has(Bt);return p.jsxs(V,{css:f.row,position:"relative",display:"grid",gridTemplateColumns:fn,minWidth:ln,onClick:N?()=>B(Bt):void 0,cursor:N?"pointer":void 0,children:[O===Bt&&p.jsx(V,{position:"absolute",inset:"0",pointerEvents:"none",zIndex:4,borderWidth:"2px",borderColor:"{colors.brand.600}",borderRadius:"2px"}),$e&&p.jsx(V,{position:"absolute",top:"0",bottom:"-1px",right:"0",width:lt,background:"bg.surface",pointerEvents:"none",zIndex:3,"aria-hidden":"true"}),p.jsx(V,{css:Lt,display:"flex",width:"100%",style:Mt,children:bt.map((qn,ca)=>{var sa,vo;const Ya=((sa=qn.columnDef.meta)==null?void 0:sa.columnKey)??qn.id,Ha=wn.cells.get(Ya),fi=Ha?_(Ha.sublabel):void 0,Ma=((vo=qn.columnDef.meta)==null?void 0:vo.alignEnd)===!0,Wa=ca===0&&Or!==void 0;return p.jsxs(V,{css:f.rowHeader,"data-slot":"rowHeader",style:Lie({column:qn},ye,Be,!1),children:[p.jsxs(V,{css:f.rowHeaderName,"data-slot":"rowHeaderName",display:"flex",justifyContent:Ma?"flex-end":"flex-start",children:[Wa&&Or!==void 0&&p.jsx(V,{as:"span",css:de[Or],"data-slot":"statusDot"}),p.jsx(V,{as:"span",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minW:0,children:(Ha==null?void 0:Ha.value)??""})]}),fi!==void 0&&p.jsx(V,{css:f.rowHeaderSub,"data-slot":"rowHeaderSub",textAlign:Ma?"right":"left",children:fi})]},qn.id)})}),p.jsxs(V,{position:"relative",display:"grid",gridTemplateColumns:rt,children:[b==="point"&&x.map((qn,ca)=>{const sa=Vr(wn,ca),vo=sa?L[sa.status.type]??L.info:void 0,Ya=Jn>0&&ca<Jn;let Ha={...f.cell};On(wn,ca)?Ha={...Ha,...f.bucketedCell}:Ha={...Ha,minHeight:`${v}px`},ca===x.length-1&&(Ha={...Ha,borderRightWidth:"0"}),Ha={...Ha,position:"relative"};const fi=Gh(qn),Ma=G&&!On(wn,ca);return p.jsxs(jV,{"data-slot":"cell","data-past":Ya?"":void 0,css:Ha,surface:U,row:String(Bt),slot:Ma?fi:void 0,vetoFor:ne,...Ma?{"data-drop-row":String(Bt),"data-drop-slot":fi}:{},children:[Pn(wn,Bt,ca,Zr),sa&&vo&&p.jsx(V,{css:vo.markerRing,"data-slot":"markerRing"}),sa&&vo&&p.jsxs(s$,{openDelay:150,children:[p.jsx(l$,{asChild:!0,children:p.jsx(V,{css:vo.markerIcon,"data-slot":"markerIcon",children:p.jsx(Ut,{icon:vIn[sa.status.type]??Ev})})}),p.jsx(go,{children:p.jsx(c$,{children:p.jsx(u$,{children:sa.message})})})]})]},qn.key)}),b==="span"&&p.jsxs(p.Fragment,{children:[x.map(qn=>p.jsx(jV,{css:f.cell,height:`${v}px`,surface:U,row:String(Bt),slot:G?Gh(qn):void 0,vetoFor:ne,...G?{"data-drop-row":String(Bt),"data-drop-slot":Gh(qn)}:{}},qn.key)),wn.events.map((qn,ca)=>{const sa=s3(qn.slot,x,y);if(sa<0)return null;const vo=_(qn.endSlot),Ya=vo!==void 0?s3(vo,x,y):sa,Ha=Math.max(Ya,sa)-sa+1;return p.jsx(V,{position:"absolute",top:"0",bottom:"0",display:"flex",alignItems:"center",left:`calc(${sa} * (100% / ${z}))`,width:`calc(${Ha} * (100% / ${z}))`,pointerEvents:G?void 0:"none",children:p.jsx(FV,{event:qn,eventStyle:Er(qn),gripStyle:f.grip,shape:"span",dnd:dn(qn,Bt,sa)})},ca)})]}),Jn>=0&&p.jsxs(p.Fragment,{children:[p.jsx(V,{css:f.nowLine,"data-slot":"nowLine",left:`calc(${Jn} * (100% / ${z}))`}),p.jsx(V,{css:f.nowHint,left:`calc(${Jn} * (100% / ${z}))`,title:`now · ${Mn?MIn(Mn,y):""}`})]})]}),oe!==void 0&&p.jsx(V,{css:{...pe.decisionCol,...Gt},"data-slot":"decisionCol","data-status":Or,onClick:qn=>qn.stopPropagation(),children:p.jsx(SI,{rowIndex:Bt,controller:oe})})]},Bt)},lr=oe!==void 0&&oe.showFoot,vr=lr&&(d!==void 0||u!==void 0),mo=p.jsx(Dv,{height:vr?void 0:d,maxHeight:vr?void 0:u,fillParent:vr,header:Hn,count:pr.length,estimateSize:tt=>{var gt;return((gt=pr[tt])==null?void 0:gt.kind)==="groupHead"?g:v},renderRow:Hr,minWidth:ln,headerZIndex:5,rootCss:{...f.root,...$e?{width:"100%"}:{}}}),Fe=lr&&oe!==void 0?p.jsx(ik,{controller:oe,storageKey:n}):null,Qt=Fe!==null?p.jsxs(V,{display:"flex",flexDirection:"column",width:"100%",height:d,maxHeight:u,minHeight:"0",children:[mo,Fe]}):mo;return o!==void 0?p.jsx(hu,{value:o,children:Qt}):Qt},(e,t)=>mIn(e.value,t.value)&&e.storageKey===t.storageKey),_In=it(_w.Types.Root),LIn=it(_w.Types.Item),RIn=C.memo(function({value:t}){const n=C.useMemo(()=>_(t.current)??!1,[t]),r=C.useMemo(()=>_(t.onClick),[t]),a=C.useCallback(()=>{r&&queueMicrotask(()=>r())},[r]);return n?p.jsx(I3e,{children:p.jsx(sNt,{children:t.label})}):p.jsx(I3e,{children:p.jsx(iNt,{onClick:r?a:void 0,cursor:r?"pointer":void 0,children:t.label})})},(e,t)=>LIn(e.value,t.value)),PIn=C.memo(function({value:t}){const n=C.useMemo(()=>_(t.style),[t.style]),r=C.useMemo(()=>n?_(n.runAnchor):void 0,[n]),a=n?_(n.leadingSeparator)??!1:!1;return p.jsx(aNt,{children:p.jsxs(oNt,{children:[t.items.map((o,i)=>p.jsxs(C.Fragment,{children:[(i>0||a)&&p.jsx(lNt,{children:"/"}),p.jsx(RIn,{value:o})]},i)),r!==void 0&&p.jsxs(V,{as:"span",fontFamily:"mono",fontSize:"11px",letterSpacing:"0.06em",color:"gray.500",marginInlineStart:"12px",paddingInlineStart:"12px",borderInlineStartWidth:"1px",borderInlineStartStyle:"solid",borderInlineStartColor:"gray.200",children:["run ",p.jsx(V,{as:"span",color:"brand.900",fontWeight:"600",children:r.replace(/^run\s+/i,"")})]})]})})},(e,t)=>_In(e.value,t.value));zv.add(_v,Eoe,Loe);const AIn=it(q_.Types.NavList),IXe=C.memo(function({value:t,collapsed:n=!1}){var r;const a=((r=_(t.surface))==null?void 0:r.type)??"card",o=_(t.background),s=en({key:"navList"})({surface:a,collapsed:n}),l=C.useMemo(()=>_(t.onSelect),[t.onSelect]),c=C.useCallback(d=>{l&&queueMicrotask(()=>l(d))},[l]),u=d=>{const f=_(d.active)??!1,h=_(d.icon),g=_(d.badge);return p.jsxs(Vo,{as:"button",role:"button",onClick:()=>c(d.key),css:s.item,title:d.label,"aria-label":n?d.label:void 0,"aria-current":f?"page":void 0,children:[h&&p.jsx(V,{as:"span",css:s.itemIcon,children:p.jsx(Ut,{icon:[h.prefix,h.name]})}),p.jsx(Ie,{as:"span",css:s.itemText,children:d.label}),g&&p.jsx(V,{as:"span",css:s.badge,children:g})]},d.key)};return p.jsx(V,{css:o?{...s.root,background:o}:s.root,role:"navigation",children:t.sections.map((d,f)=>{const h=_(d.label);return p.jsxs(V,{css:s.group,children:[h&&p.jsx(Ie,{as:"div",css:s.groupLabel,children:h}),d.items.map(u)]},`${h??"_"}-${f}`)})})},(e,t)=>AIn(e.value,t.value)&&e.collapsed===t.collapsed),NIn=it(Sg.Types.Image),$In={png:"image/png",svg:"image/svg+xml",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif"},IIn={contain:"contain",cover:"cover",fill:"fill",none:"none",scaleDown:"scale-down"},DXe=C.memo(function({value:t}){const n=t.source,r=C.useMemo(()=>n.type==="url"||n.type==="dataUri"?n.value:void 0,[n]),[a,o]=C.useState(void 0);C.useEffect(()=>{if(n.type!=="blob"){o(void 0);return}const u=URL.createObjectURL(new Blob([n.value.bytes],{type:$In[n.value.format.type]??"application/octet-stream"}));return o(u),()=>URL.revokeObjectURL(u)},[n]);const i=C.useMemo(()=>_(t.style),[t.style]),s=C.useMemo(()=>{var u;if(i===void 0)return{};const d=_(i.padding),f=_(i.margin),h=(u=_(i.fit))==null?void 0:u.type;return{objectFit:h?IIn[h]:void 0,aspectRatio:_(i.aspectRatio),width:Tt(_(i.width)),height:Tt(_(i.height)),minWidth:Tt(_(i.minWidth)),minHeight:Tt(_(i.minHeight)),maxWidth:Tt(_(i.maxWidth)),maxHeight:Tt(_(i.maxHeight)),opacity:_(i.opacity),borderRadius:_(i.borderRadius),background:_(i.background),pt:d?_(d.top):void 0,pr:d?_(d.right):void 0,pb:d?_(d.bottom):void 0,pl:d?_(d.left):void 0,mt:f?_(f.top):void 0,mr:f?_(f.right):void 0,mb:f?_(f.bottom):void 0,ml:f?_(f.left):void 0}},[i]),l=i?_(i.alt):void 0,c=r??a;return p.jsx(Ht.img,{src:c,alt:l??"",...s})},(e,t)=>NIn(e.value,t.value)),DIn="east-ui.color-mode";function BV(){return typeof document>"u"?"light":document.documentElement.classList.contains("dark")?"dark":"light"}function OIn(e){if(!(typeof document>"u")){document.documentElement.classList.toggle("dark",e==="dark"),document.documentElement.style.colorScheme=e;try{localStorage.setItem(DIn,e)}catch{}}}function jIn(){const[e,t]=C.useState(BV),n=C.useCallback(()=>{const r=BV()==="dark"?"light":"dark";OIn(r),t(r)},[]);return C.useEffect(()=>{if(typeof document>"u")return;const r=document.documentElement,a=new MutationObserver(()=>t(BV()));return a.observe(r,{attributes:!0,attributeFilter:["class"]}),()=>a.disconnect()},[]),[e,n]}const FIn=C.createContext({});function BIn(){return C.useContext(FIn)}const VIn=it(But),HIn=C.memo(function({value:t,storageKey:n}){var r;const a=en({key:"app"}),o=BIn(),{state:i,setState:s}=Pl(`${n}.app.collapsed`,!1),l=t.collapsible&&i,c=C.useCallback(()=>s(z=>!z),[s]),[u,d]=jIn();C.useEffect(()=>{if(!t.collapsible)return;function z(M){if(M.key!=="[")return;const L=M.target;L&&(L.tagName==="INPUT"||L.tagName==="TEXTAREA"||L.isContentEditable)||s(R=>!R)}return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[t.collapsible,s]);const f=al(),h=((r=_(t.density))==null?void 0:r.type)??f??"comfortable",g=h==="condensed",v=a({collapsed:l,density:h}),b=_(t.title),y=l?_(t.logoCollapsed)??_(t.logo):_(t.logo),x=o.logo??(y!==void 0?p.jsx(V,{css:v.logo,children:p.jsx(DXe,{value:{source:y,style:A}})}):null),S=t.barStart.length>0||o.barStart!=null;return p.jsxs(V,{css:v.root,children:[p.jsxs(V,{as:"aside",css:v.rail,children:[p.jsx(V,{css:v.railHeader,children:x}),t.collapsible&&p.jsx(V,{css:v.collapseToggleRow,children:p.jsx(Ht.button,{type:"button",css:v.collapseToggle,onClick:c,"aria-label":l?"Expand sidebar":"Collapse sidebar",children:p.jsx(Ut,{icon:l?r2:kd})})}),p.jsx(V,{css:v.railBody,children:p.jsx(IXe,{value:t.rail.value,collapsed:l})}),o.railFooter!=null&&p.jsx(V,{css:v.railFooter,children:o.railFooter})]}),p.jsxs(V,{css:v.content,children:[o.bannerTop!=null&&p.jsx(V,{css:v.bannerTop,children:o.bannerTop}),p.jsxs(V,{as:"header",css:v.header,children:[p.jsxs(Vo,{css:v.headerRow,children:[p.jsx(V,{css:v.breadcrumb,children:p.jsx(mn,{value:t.breadcrumb,storageKey:`${n}.breadcrumb`})}),g&&b!==void 0&&p.jsxs(p.Fragment,{children:[p.jsx(V,{css:v.titleDivider}),p.jsx(V,{css:v.titleInline,children:b})]}),S&&p.jsxs(V,{css:v.barStart,children:[t.barStart.map((z,M)=>p.jsx(mn,{value:z,storageKey:`${n}.barStart.${M}`},M)),o.barStart]}),p.jsx(V,{css:v.barCenter,children:o.barCenter}),p.jsxs(V,{css:v.barEnd,children:[t.barEnd.map((z,M)=>p.jsx(mn,{value:z,storageKey:`${n}.barEnd.${M}`},M)),o.barEnd,t.themeToggle&&p.jsx(Ht.button,{type:"button",css:v.themeToggle,onClick:d,"aria-label":u==="dark"?"Switch to light mode":"Switch to dark mode",children:p.jsx(Ut,{icon:u==="dark"?YDe:Xje})})]})]}),!g&&b!==void 0&&p.jsx(V,{css:v.title,children:b})]}),p.jsx(V,{as:"main",css:v.main,children:p.jsx(mn,{value:t.body,storageKey:`${n}.body`})})]})]})},(e,t)=>e.storageKey===t.storageKey&&VIn(e.value,t.value)),WIn=it(Tq.Types.Badge);function UIn(e){var t,n,r,a,o,i,s,l,c,u;const d=_(e.style);if(d===void 0)return{display:"flex"};const f=_(d.padding),h=_(d.margin);return{display:"flex",variant:(t=_(d.variant))==null?void 0:t.type,colorPalette:(n=_(d.colorPalette))==null?void 0:n.type,size:(r=_(d.size))==null?void 0:r.type,opacity:_(d.opacity),color:_(d.color),background:_(d.background),borderRadius:_(d.borderRadius),borderWidth:(a=_(d.borderWidth))==null?void 0:a.type,borderStyle:(o=_(d.borderStyle))==null?void 0:o.type,borderColor:_(d.borderColor),overflow:(i=_(d.overflow))==null?void 0:i.type,overflowX:(s=_(d.overflowX))==null?void 0:s.type,overflowY:(l=_(d.overflowY))==null?void 0:l.type,justifyContent:(c=_(d.justifyContent))==null?void 0:c.type,alignItems:(u=_(d.alignItems))==null?void 0:u.type,width:Tt(_(d.width)),height:Tt(_(d.height)),minWidth:Tt(_(d.minWidth)),minHeight:Tt(_(d.minHeight)),maxWidth:Tt(_(d.maxWidth)),maxHeight:Tt(_(d.maxHeight)),pt:f?_(f.top):void 0,pr:f?_(f.right):void 0,pb:f?_(f.bottom):void 0,pl:f?_(f.left):void 0,mt:h?_(h.top):void 0,mr:h?_(h.right):void 0,mb:h?_(h.bottom):void 0,ml:h?_(h.left):void 0}}const qIn=C.memo(function({value:t}){const n=C.useMemo(()=>UIn(t),[t]),r=al(),o=C.useMemo(()=>{var i;return(i=_(t.density))==null?void 0:i.type},[t.density])??r;return p.jsx(_re,{...n,...o!==void 0?{density:o}:{},children:t.value})},(e,t)=>WIn(e.value,t.value)),GIn=it(Eq.Types.Tag);function KIn(e){var t,n,r,a,o,i,s,l;const c=_(e.style);if(c===void 0)return{};const u=_(c.padding),d=_(c.margin);return{variant:(t=_(c.variant))==null?void 0:t.type,colorPalette:(n=_(c.colorPalette))==null?void 0:n.type,size:(r=_(c.size))==null?void 0:r.type,opacity:_(c.opacity),color:_(c.color),background:_(c.background),borderRadius:_(c.borderRadius),borderWidth:(a=_(c.borderWidth))==null?void 0:a.type,borderStyle:(o=_(c.borderStyle))==null?void 0:o.type,borderColor:_(c.borderColor),overflow:(i=_(c.overflow))==null?void 0:i.type,overflowX:(s=_(c.overflowX))==null?void 0:s.type,overflowY:(l=_(c.overflowY))==null?void 0:l.type,width:Tt(_(c.width)),height:Tt(_(c.height)),minWidth:Tt(_(c.minWidth)),minHeight:Tt(_(c.minHeight)),maxWidth:Tt(_(c.maxWidth)),maxHeight:Tt(_(c.maxHeight)),pt:u?_(u.top):void 0,pr:u?_(u.right):void 0,pb:u?_(u.bottom):void 0,pl:u?_(u.left):void 0,mt:d?_(d.top):void 0,mr:d?_(d.right):void 0,mb:d?_(d.bottom):void 0,ml:d?_(d.left):void 0}}const YIn=C.memo(function({value:t}){const n=C.useMemo(()=>KIn(t),[t]),r=C.useMemo(()=>_(t.closable),[t.closable]),a=C.useMemo(()=>_(t.onClose),[t.onClose]),o=al(),s=C.useMemo(()=>{var c;return(c=_(t.density))==null?void 0:c.type},[t.density])??o,l=C.useCallback(()=>{a&&queueMicrotask(()=>a())},[a]);return p.jsxs(KIt,{...n,...s!==void 0?{density:s}:{},children:[p.jsx(YIt,{children:t.label}),r&&p.jsx(XIt,{onClick:a?l:void 0})]})},(e,t)=>GIn(e.value,t.value)),XIn=it(Aq.Types.Avatar);function OXe(e){var t,n,r,a,o,i;const s=_(e.style);if(s===void 0)return{};const l=_(s.padding),c=_(s.margin);return{size:(t=_(s.size))==null?void 0:t.type,variant:(n=_(s.variant))==null?void 0:n.type,colorPalette:(r=_(s.colorPalette))==null?void 0:r.type,opacity:_(s.opacity),borderRadius:_(s.borderRadius),overflow:(a=_(s.overflow))==null?void 0:a.type,overflowX:(o=_(s.overflowX))==null?void 0:o.type,overflowY:(i=_(s.overflowY))==null?void 0:i.type,width:Tt(_(s.width)),height:Tt(_(s.height)),minWidth:Tt(_(s.minWidth)),minHeight:Tt(_(s.minHeight)),maxWidth:Tt(_(s.maxWidth)),maxHeight:Tt(_(s.maxHeight)),color:_(s.color),background:_(s.background),borderColor:_(s.borderColor),pt:l?_(l.top):void 0,pr:l?_(l.right):void 0,pb:l?_(l.bottom):void 0,pl:l?_(l.left):void 0,mt:c?_(c.top):void 0,mr:c?_(c.right):void 0,mb:c?_(c.bottom):void 0,ml:c?_(c.left):void 0}}const ZIn=C.memo(function({value:t}){const n=C.useMemo(()=>OXe(t),[t]),r=C.useMemo(()=>_(t.src),[t.src]),a=C.useMemo(()=>_(t.name),[t.name]),o=al(),s=C.useMemo(()=>{var l;return(l=_(t.density))==null?void 0:l.type},[t.density])??o;return p.jsxs(cK,{...n,...s!==void 0?{density:s}:{},children:[p.jsx(uK,{name:a}),r&&p.jsx(YPe,{src:r})]})},(e,t)=>XIn(e.value,t.value)),QIn=it(Oq.Types.Stat),JIn={sm:"sm",md:"md",lg:"lg"},m8e={positive:"fg.success",negative:"fg.danger",neutral:"fg.muted"},eDn=C.memo(function({value:t,storageKey:n}){var r,a;const o=C.useMemo(()=>_(t.helpText),[t.helpText]),i=C.useMemo(()=>_(t.baseline),[t.baseline]),s=C.useMemo(()=>_(t.delta),[t.delta]),l=C.useMemo(()=>_(t.info),[t.info]),c=C.useMemo(()=>_(t.indicator),[t.indicator]),u=C.useMemo(()=>_(t.style),[t.style]),d=al(),h=C.useMemo(()=>{var N;return(N=_(t.density))==null?void 0:N.type},[t.density])??d,g=C.useMemo(()=>{const N=t.value,O=_(t.format);switch(N.type){case"Float":case"Integer":return Yp(Number(N.value),O);case"DateTime":return Yp(new Date(N.value).getTime(),O);case"String":return N.value;default:return String(N.value)}},[t.value,t.format]),v=c?c.direction.type:void 0,b=c?(r=_(c.sentiment))==null?void 0:r.type:void 0,y=c?_(c.icon):void 0,x=u?(a=_(u.size))==null?void 0:a.type:void 0,S=x?JIn[x]:void 0,z=u?_(u.valueColor):void 0,M=u?_(u.labelColor):void 0,L=u?_(u.helpTextColor):void 0,R=u?_(u.indicatorColor)??(b?m8e[b]:void 0):b?m8e[b]:void 0;return p.jsxs(TIt,{size:S,...h!==void 0?{density:h}:{},children:[p.jsxs(Xr,{gap:"1",align:"baseline",children:[p.jsx(EIt,{color:M,children:t.label}),l&&p.jsx(V,{children:p.jsx(mn,{value:l,storageKey:`${n}.info`})})]}),p.jsx(_It,{color:z,children:g}),i&&p.jsx(V,{mt:"0.5",children:p.jsx(mn,{value:i,storageKey:`${n}.baseline`})}),(o||v||s)&&p.jsx(LIt,{color:L,children:p.jsxs(Xr,{gap:"1",align:"center",children:[v!==void 0&&y===void 0&&p.jsxs(V,{color:R,children:[v==="up"&&p.jsx(RIt,{}),v==="down"&&p.jsx(PIt,{})]}),y!==void 0&&p.jsx(V,{color:R,children:p.jsx(Ut,{icon:[y.prefix,y.name],"aria-hidden":!0})}),o&&p.jsx("span",{children:o}),s&&p.jsx(V,{ml:"auto",children:p.jsx(mn,{value:s,storageKey:`${n}.delta`})})]})})]})},(e,t)=>QIn(e.value,t.value)&&e.storageKey===t.storageKey),tDn=it(Pq.Types.MetricChip),v8e={positive:{bg:"success.subtle",fg:"fg.success",border:"fg.success",solidBg:"fg.success",solidFg:"white"},negative:{bg:"danger.subtle",fg:"fg.danger",border:"fg.danger",solidBg:"fg.danger",solidFg:"white"},neutral:{bg:"bg.subtle",fg:"fg.muted",border:"border.strong",solidBg:"fg.muted",solidFg:"white"},info:{bg:"info.subtle",fg:"fg.info",border:"fg.info",solidBg:"fg.info",solidFg:"white"}},y8e={xs:{px:"1.5",py:"0",fontSize:"xs"},sm:{px:"2",py:"0.5",fontSize:"sm"},md:{px:"2.5",py:"1",fontSize:"sm"},lg:{px:"3",py:"1.5",fontSize:"md"},xl:{px:"3.5",py:"2",fontSize:"md"}},nDn={positive:"up",negative:"down",neutral:"flat",info:"brand"},rDn=C.memo(function({value:t,storageKey:n}){var r,a;const o=en({key:"metricChip"}),i=t.tone.type,s=nDn[i]??"flat",l=al(),u=C.useMemo(()=>{var R;return(R=_(t.density))==null?void 0:R.type},[t.density])??l,d=o({sentiment:s,density:u}),f=C.useMemo(()=>_(t.unit),[t.unit]),h=C.useMemo(()=>_(t.icon),[t.icon]),g=C.useMemo(()=>_(t.style),[t.style]),v=g?((r=_(g.emphasis))==null?void 0:r.type)??"subtle":"subtle",b=g?((a=_(g.size))==null?void 0:a.type)??"sm":"sm",y=y8e[b]??y8e.sm,x=v8e[i]??v8e.neutral,S=(g&&_(g.color))??(v==="solid"?x.solidFg:void 0),z=(g&&_(g.background))??(v==="solid"?x.solidBg:v==="outline"?"transparent":void 0),M=(g&&_(g.borderColor))??(v==="outline"?x.border:void 0),L=(g&&_(g.iconColor))??S??x.fg;return p.jsx(V,{css:d.root,px:y.px,py:y.py,fontSize:y.fontSize,...S!==void 0?{color:S}:{},...z!==void 0?{bg:z}:{},...M!==void 0?{borderColor:M}:{},...v==="solid"?{borderColor:"transparent"}:{},children:p.jsxs(Xr,{gap:"1",align:"center",children:[h&&p.jsx(V,{color:L,children:p.jsx(Ut,{icon:[h.prefix,h.name],"aria-hidden":!0})}),p.jsx(V,{css:d.value,children:p.jsx(mn,{value:t.value,storageKey:`${n}.value`})}),f&&p.jsx(Ie,{as:"span",opacity:.75,children:f})]})})},(e,t)=>tDn(e.value,t.value)&&e.storageKey===t.storageKey),aDn=C.memo(function({value:t}){const{slice:n}=t;rl(n.key);const r=Number(n.activeCount()),a=n.resultCount(),o=Number(n.totalCount()),i=en({key:"sliceFrame"})();return p.jsxs(V,{css:i.frameFooter,children:[a!==void 0&&p.jsxs(p.Fragment,{children:[p.jsx(V,{as:"span",css:i.frameFooterStat,children:Number(a).toLocaleString()}),o>0&&p.jsx(V,{as:"span",children:`of ${o.toLocaleString()}`}),p.jsx(V,{as:"span",children:Number(a)===1?"result":"results"}),p.jsx(V,{as:"span",children:"·"})]}),p.jsx(V,{as:"span",css:i.frameFooterStat,children:r}),p.jsx(V,{as:"span",children:r===1?"narrowing":"narrowings"}),r>0&&p.jsxs(p.Fragment,{children:[p.jsx(V,{as:"span",children:"·"}),p.jsx(Ht.button,{type:"button",color:"link",fontWeight:"medium",cursor:"pointer",_hover:{textDecoration:"underline",textUnderlineOffset:"2px"},onClick:()=>{n.clearFilters()},children:"clear all"})]})]})},()=>!1),oDn=it(Rq.Types.EditableChip),iDn=C.memo(function({value:t,storageKey:n}){var r;const a=C.useMemo(()=>_(t.trigger),[t.trigger]),o=C.useMemo(()=>_(t.disabled),[t.disabled]),i=C.useMemo(()=>_(t.onClick),[t.onClick]),s=C.useMemo(()=>_(t.style),[t.style]),l=C.useCallback(()=>{i&&!o&&queueMicrotask(()=>i())},[i,o]),c=s?((r=_(s.size))==null?void 0:r.type)??"sm":"sm",u=al(),f=C.useMemo(()=>{var z;return(z=_(t.density))==null?void 0:z.type},[t.density])??u,g=en({key:"editableChip"})({size:c,density:f}),v=C.useMemo(()=>{const z=s?_(s.borderRadius):void 0,M=s?_(s.color):void 0,L=s?_(s.background):void 0,R=s?_(s.borderColor):void 0;return{...g.root,...z!==void 0?{borderRadius:z}:{},...M!==void 0?{color:M}:{},...L!==void 0?{background:L}:{},...R!==void 0?{borderColor:R}:{}}},[g,s]),b=C.useMemo(()=>{const z=s?_(s.triggerIconColor):void 0;return{...g.trigger,...z!==void 0?{color:z}:{}}},[g,s]),y=a?[a.prefix,a.name]:Wae,x=!!i&&!o,S=p.jsxs(p.Fragment,{children:[p.jsx(mn,{value:t.label,storageKey:`${n}.label`}),p.jsx(V,{as:"span",css:b,children:p.jsx(Ut,{icon:y,"aria-hidden":!0})})]});return x?p.jsx(fu,{unstyled:!0,css:v,onClick:l,children:S}):p.jsx(V,{css:v,cursor:o?"not-allowed":"default",opacity:o?.5:void 0,children:S})},(e,t)=>oDn(e.value,t.value)&&e.storageKey===t.storageKey),sDn=it(Lq.Types.Kbd),lDn=C.memo(function({value:t}){var n,r,a;const o=C.useMemo(()=>_(t.style),[t.style]),i=al(),l=C.useMemo(()=>{var b;return(b=_(t.density))==null?void 0:b.type},[t.density])??i,c=o?(n=_(o.variant))==null?void 0:n.type:void 0,u=o?(r=_(o.size))==null?void 0:r.type:void 0,d=o?(a=_(o.colorPalette))==null?void 0:a.type:void 0,f=o?_(o.color):void 0,h=o?_(o.background):void 0,g=o?_(o.borderColor):void 0,v=t.keys;return p.jsx(Xr,{gap:"1",align:"center",display:"inline-flex",children:v.map((b,y)=>p.jsxs(C.Fragment,{children:[y>0&&p.jsx(Ie,{as:"span",color:"fg.muted",children:"+"}),p.jsx(Dre,{variant:c??"flat",size:u==="xs"||u==="xl"||u==="2xl"?"sm":u,colorPalette:d,color:f,background:h,borderColor:g,...l!==void 0?{density:l}:{},children:b})]},y))})},(e,t)=>sDn(e.value,t.value)),cDn=it(_q.Types.Meter),uDn=C.memo(function({value:t,storageKey:n}){var r;const a=C.useMemo(()=>_(t.label),[t.label]),o=C.useMemo(()=>_(t.max)??100,[t.max]),i=C.useMemo(()=>{var M;return(M=_(t.tone))==null?void 0:M.type},[t.tone]),s=C.useMemo(()=>_(t.style),[t.style]),l=al(),u=C.useMemo(()=>{var M;return(M=_(t.density))==null?void 0:M.type},[t.density])??l,d=s?(r=_(s.thickness))==null?void 0:r.type:void 0,f=s?_(s.fillColor):void 0,h=s?_(s.trackColor):void 0,g=s?_(s.labelColor):void 0,v=s?_(s.borderRadius):void 0,b=(s?_(s.showValue):void 0)??!0,y=en({key:"meter"})({thickness:d,tone:i,density:u}),x=Math.max(0,Math.min(Number(t.value)/Number(o),1)),S=`${(x*100).toFixed(2)}%`,z=`${Math.round(x*100)}%`;return p.jsxs(V,{css:y.root,children:[a&&p.jsx(V,{css:y.label,color:g,children:p.jsx(mn,{value:a,storageKey:`${n}.label`})}),p.jsx(V,{css:y.track,bg:h,borderRadius:v,children:p.jsx(V,{css:y.fill,width:S,bg:f,borderRadius:v})}),b&&p.jsx(V,{as:"span",css:y.value,children:z})]})},(e,t)=>cDn(e.value,t.value)&&e.storageKey===t.storageKey),dDn=it(Iq.Types.SegmentedMeter),fDn={xs:"4px",sm:"6px",md:"10px",lg:"14px"},pDn={success:"fg.success",warning:"fg.warning",danger:"fg.danger",info:"fg.info",neutral:"fg.muted"},hDn=C.memo(function({value:t,storageKey:n}){var r,a,o;const i=C.useMemo(()=>_(t.caption),[t.caption]),s=C.useMemo(()=>_(t.style),[t.style]),l=al(),u=C.useMemo(()=>{var B;return(B=_(t.density))==null?void 0:B.type},[t.density])??l,d=en({key:"segmentedMeter"})({density:u}),f=s?((r=_(s.thickness))==null?void 0:r.type)??"sm":"sm",g=(u!==void 0?(a=d.track)==null?void 0:a.height:void 0)??fDn[f]??"6px",v=s?((o=_(s.labels))==null?void 0:o.type)??"none":"none",b=(s&&_(s.borderRadius))??"sm",y=(s&&_(s.trackColor))??"gray.100",x=s?_(s.captionColor):void 0,S=(s&&_(s.labelColor))??"white",z=t.segments,M=z.reduce((B,H)=>B+Number(H.value),0),L=_(t.max),N=(L!==void 0?Math.max(Number(L),M):M)-M,O=p.jsxs(Vo,{width:"full",height:g,borderRadius:b,overflow:"hidden",children:[z.map((B,H)=>{var K;const U=(K=_(B.tone))==null?void 0:K.type,Z=_(B.color)??(U?pDn[U]:"fg.info"),G=_(B.label);return p.jsx(V,{flex:Number(B.value),bg:Z,display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",children:v==="inside"&&G&&p.jsx(Ie,{fontSize:"xs",color:S,truncate:!0,children:G})},H)}),N>0&&p.jsx(V,{flex:N,bg:y})]}),j=v==="outside"?p.jsxs(Vo,{width:"full",mt:"1",children:[z.map((B,H)=>{const K=_(B.label);return p.jsx(V,{flex:Number(B.value),textAlign:"center",children:K&&p.jsx(Ie,{fontSize:"xs",color:"fg.muted",truncate:!0,children:K})},H)}),N>0&&p.jsx(V,{flex:N})]}):null;return i?p.jsxs(V,{width:"full",children:[p.jsxs(Xr,{gap:"3",align:"center",mb:"1",children:[p.jsx(V,{color:x,flexShrink:0,children:p.jsx(mn,{value:i,storageKey:`${n}.caption`})}),p.jsx(V,{flex:"1",children:O})]}),j]}):p.jsxs(V,{width:"full",children:[O,j]})},(e,t)=>dDn(e.value,t.value)&&e.storageKey===t.storageKey),gDn=it($q.Types.BarStrip),mDn={success:"fg.success",warning:"fg.warning",danger:"fg.danger",info:"fg.info",neutral:"fg.muted"},vDn=C.memo(function({value:t,storageKey:n}){var r;const a=C.useMemo(()=>_(t.style),[t.style]),o=C.useMemo(()=>_(t.showValues)??!0,[t.showValues]),i=C.useMemo(()=>{var S;return((S=_(t.sort))==null?void 0:S.type)??"none"},[t.sort]),s=C.useMemo(()=>_(t.maxItems),[t.maxItems]),l=al(),u=C.useMemo(()=>{var S;return(S=_(t.density))==null?void 0:S.type},[t.density])??l,d=a?(r=_(a.thickness))==null?void 0:r.type:void 0,f=a?_(a.trackColor):void 0,h=a?_(a.labelColor):void 0,g=a?_(a.valueColor):void 0,v=a?_(a.borderRadius):void 0,b=en({key:"barStrip"})({thickness:d,density:u}),y=C.useMemo(()=>{let S=[...t.items];return i==="asc"?S.sort((z,M)=>Number(z.value)-Number(M.value)):i==="desc"&&S.sort((z,M)=>Number(M.value)-Number(z.value)),s!==void 0&&(S=S.slice(0,Number(s))),S},[t,i,s]),x=C.useMemo(()=>{let S=0;for(const z of y){const M=Number(z.value);M>S&&(S=M)}return S===0?1:S},[y]);return p.jsx(V,{css:b.root,children:y.map((S,z)=>{var M;const L=(M=_(S.tone))==null?void 0:M.type,R=_(S.color)??(L?mDn[L]:void 0),N=_(S.trailing),O=`${(Number(S.value)/x*100).toFixed(2)}%`;return p.jsxs(V,{css:b.row,children:[p.jsx(V,{css:b.label,color:h,children:p.jsx(mn,{value:S.label,storageKey:`${n}.${z}.label`})}),p.jsx(V,{css:b.track,bg:f,borderRadius:v,children:p.jsx(V,{css:b.fill,width:O,bg:R,borderRadius:v})}),o&&p.jsx(V,{as:"span",css:b.value,color:g,children:Number(S.value).toLocaleString()}),N&&p.jsx(V,{css:b.trailing,children:p.jsx(mn,{value:N,storageKey:`${n}.${z}.trailing`})})]},z)})})},(e,t)=>gDn(e.value,t.value)&&e.storageKey===t.storageKey),yDn=it(jq.Types.Trace),b8e=["var(--chakra-colors-brand-600)","var(--chakra-colors-orange-500)","var(--chakra-colors-purple-500)","var(--chakra-colors-cyan-600)","var(--chakra-colors-pink-500)"],bDn="var(--chakra-colors-orange-500)",x8e="var(--chakra-colors-bg-muted)",w8e="var(--chakra-colors-bg-surface)";function S8e(e){return Number.isInteger(e)?String(e):e.toFixed(1)}function xDn(e,t,n,r,a,o,i){if(a==="diverge"){const u=Math.max(n-r,r-t)||1,d=(e-r)/u,f=d>=0?bDn:o,h=Math.min(Math.abs(d),1),g=i?w8e:x8e,v=i?h*34:h*80;return{fill:`color-mix(in srgb, ${f} ${v.toFixed(0)}%, ${g})`,edge:f,hot:!i&&h>.62}}const s=n>t?(e-t)/(n-t):.5,l=i?w8e:x8e,c=i?s*42:s*100;return{fill:`color-mix(in srgb, ${o} ${c.toFixed(0)}%, ${l})`,edge:o,hot:!i&&s>.6}}const wDn=C.memo(function({value:t,storageKey:n}){const r=en({key:"trace"}),a=al(),i=C.useMemo(()=>{var Z;return(Z=_(t.density))==null?void 0:Z.type},[t.density])??a??"comfortable",s=r({density:i}),l=C.useMemo(()=>{var Z;return((Z=_(t.scale))==null?void 0:Z.type)??"brand"},[t.scale]),c=C.useMemo(()=>{var Z;return((Z=_(t.future))==null?void 0:Z.type)??"ghost"},[t.future]),u=C.useMemo(()=>_(t.axis),[t.axis]),d=C.useMemo(()=>_(t.style),[t.style]),f=(d?_(d.brandColor):void 0)??"var(--chakra-colors-brand-600)",h=d?_(d.nowLineColor):void 0,g=d?_(d.labelWidth):void 0,v=N7(),b=C.useMemo(()=>d?_(d.plotGutter):void 0,[d]),y=(b?_(b.left):void 0)??(v==null?void 0:v.left),x=(b?_(b.right):void 0)??(v==null?void 0:v.right),S=y!==void 0||x!==void 0,z=y??g??"var(--t-stub-w)",M=x??"0px",L=C.useMemo(()=>_(t.now),[t.now]),R=L!==void 0?Number(L):void 0,N=t.tracks,O=N.reduce((Z,G)=>Math.max(Z,G.values.length),0),j=S?`${z} repeat(${O}, minmax(0, 1fr)) ${M}`:`var(--t-stub-w) repeat(${O}, var(--t-step-w))`,B=S?{columnGap:"0px"}:void 0;C.useEffect(()=>{if(N.length<2)return;const Z=N.map(G=>G.values.length);Z.some(G=>G!==Z[0])&&console.warn(`<Trace>: tracks have unequal value lengths [${Z.join(", ")}]; short tracks padded to ${O} steps — tracks are expected to share one step grid.`)},[N,O]);const H=R!==void 0&&R>0&&R<O,K=S?`calc(${z} + (100% - ${z} - ${M}) * ${R} / ${O})`:`calc(var(--t-stub-w) + var(--t-gap) + ${R} * (var(--t-step-w) + var(--t-gap)) - var(--t-gap) / 2)`,U=i==="comfortable"&&u!==void 0&&u.length>0;return p.jsxs(V,{css:s.root,"data-future":c,...S?{display:"block",width:"100%"}:{},...g!==void 0?{style:{"--t-stub-w":g}}:{},children:[U&&p.jsxs(V,{css:s.axis,style:{gridTemplateColumns:j,...B},children:[p.jsx("span",{}),Array.from({length:O},(Z,G)=>p.jsx(V,{css:s.axisCell,children:u[G]??""},`ax.${G}`)),S&&p.jsx("span",{})]}),p.jsxs(V,{css:s.grid,style:{gridTemplateColumns:j,...B},position:"relative",children:[N.map((Z,G)=>{const W=Z.values,J=Math.min(...W),ae=Math.max(...W),ne=(J+ae)/2,Y=l==="categorical"?b8e[G%b8e.length]:f;return p.jsxs(C.Fragment,{children:[p.jsx(V,{css:s.stub,title:Z.name,children:Z.name}),W.map((te,ie)=>{const ue=R!==void 0&&ie>=R,{fill:oe,edge:ve,hot:se}=xDn(te,J,ae,ne,l,Y,ue),pe={background:oe};S&&(pe.marginInline="calc(var(--t-gap) / 2)"),ue?(pe.color=ve,pe.fontStyle="italic",c==="fade"?pe.opacity="0.7":(pe.borderColor=ve,pe.borderStyle="dashed"),c==="hatch"&&(pe.backgroundImage=`repeating-linear-gradient(-45deg, transparent 0 5px, color-mix(in srgb, ${ve} 12%, transparent) 5px 6px)`)):se&&(pe.color="var(--chakra-colors-bg-surface)");const de=`${u!=null&&u[ie]?`${u[ie]} · `:""}${Z.name} ${S8e(te)} · ${ue?"predicted":"measured"}`;return p.jsx(V,{css:s.step,style:pe,title:de,children:p.jsx(V,{as:"span",css:s.value,children:S8e(te)})},`step.${G}.${ie}`)}),Array.from({length:O-W.length},(te,ie)=>p.jsx("span",{"aria-hidden":"true"},`pad.${G}.${ie}`)),S&&p.jsx("span",{"aria-hidden":"true"},`rpad.${G}`)]},`${n}.track.${G}`)}),H&&p.jsx(V,{css:s.now,style:{left:K,...h?{background:h}:{}}})]})]})},(e,t)=>yDn(e.value,t.value)&&e.storageKey===t.storageKey),SDn=it(X_.Types.Library);function CDn(e){return(_(e.search)??e.label).toLowerCase()}const kDn=220,C8e=12,zDn=16;function MDn(e){const t=e-2*zDn;return Math.max(1,Math.floor((t+C8e)/(kDn+C8e)))}function TDn(e,t){const n=Math.max(1,t),r=[];for(const a of e){a.label!==""&&r.push({kind:"groupHead",label:a.label,summary:a.summary,count:a.items.length});for(let o=0;o<a.items.length;o+=n)r.push({kind:"cardRow",items:a.items.slice(o,o+n)})}return r}function k8e({libraryId:e,item:t,dimOrder:n,activeDims:r,filtered:a,styles:o}){const i=_(t.status),s=_(t.sublabel),l=_(t.icon),c=t.draggable&&!a,u=n.filter(v=>r.includes(v)&&t.dims.get(v)!==void 0),d=s===void 0&&u.length===0,f=C.useMemo(()=>({library:e,key:t.key,label:t.label}),[e,t.key,t.label]),h=C.useMemo(()=>p.jsx(V,{css:o.ghost,children:t.label}),[o.ghost,t.label]),g=e$n(f,h,!c);return p.jsxs(V,{css:o.card,onPointerDown:g,...a?{"data-filtered":""}:{},...c&&g?{"data-draggable":""}:{},...d?{"data-compact":""}:{},children:[c&&g&&p.jsx(V,{as:"span",css:o.grip,"data-drag-grip":"",children:p.jsx(Ut,{icon:g5})}),l&&p.jsx(V,{css:o.iconTile,children:p.jsx(Ut,{icon:["fas",l]})}),p.jsxs(V,{css:o.cardBody,children:[p.jsxs(V,{css:o.cardHead,children:[p.jsx(V,{as:"span",css:o.cardLabel,children:t.label}),i&&p.jsx(V,{as:"span",css:o.statusPill,"data-tone":i.tone.type,children:i.label})]}),s&&p.jsx(V,{css:o.cardSublabel,children:s}),u.map(v=>{const b=t.dims.get(v);return Sr(b,{meter:y=>p.jsxs(V,{css:o.meter,children:[p.jsx(V,{css:o.meterTrack,children:p.jsx(V,{css:o.meterFill,width:`${Math.max(0,Math.min(100,y.max>0?y.value/y.max*100:0))}%`})}),_(y.text)!==void 0&&p.jsx(V,{as:"span",css:o.meterText,children:_(y.text)})]},v),chips:y=>p.jsx(V,{css:o.chips,children:y.map((x,S)=>p.jsx(V,{as:"span",css:o.chip,children:x},S))},v),text:y=>p.jsx(V,{css:o.dimText,children:y},v)})})]})]})}function z8e({label:e,count:t,summary:n,styles:r}){return p.jsxs(V,{css:r.groupHead,children:[p.jsxs(V,{as:"span",css:r.groupLabel,children:[e," · ",t]}),n!==void 0&&p.jsx(V,{as:"span",css:r.groupSummary,children:n})]})}function M8e({value:e,storageKey:t,suppressSearch:n}){var r;const a=en({key:"library"})(),o=ga({key:"chip"}),i=en({key:"sliceFrame"})(),s=e.groupOptions,l=e.dimOptions,c=C.useMemo(()=>l.map(ue=>ue.key),[l]),{state:u,setState:d}=Pl(`${t}.toolbar`,{groupKey:((r=s[0])==null?void 0:r.key)??null,activeDims:[...e.defaultDimensions]}),[f,h]=C.useState(""),g=JNn("library",e.id),v=C.useCallback(ue=>{d(oe=>({...oe,groupKey:ue}))},[d]),b=C.useCallback(ue=>{d(oe=>({...oe,activeDims:oe.activeDims.includes(ue)?oe.activeDims.filter(ve=>ve!==ue):[...oe.activeDims,ue]}))},[d]),y=f.trim().toLowerCase(),x=C.useCallback(ue=>y!==""&&!CDn(ue).includes(y),[y]),S=C.useMemo(()=>{const ue=u.groupKey,oe=ue!==null?e.groupSummaries.get(ue):void 0,ve=new Map;for(const se of e.items){if(x(se))continue;const pe=(ue!==null?se.groups.get(ue):void 0)??"";let de=ve.get(pe);de===void 0&&(de={label:pe,summary:oe==null?void 0:oe.get(pe),items:[]},ve.set(pe,de)),de.items.push(se)}return[...ve.values()]},[e.items,e.groupSummaries,u.groupKey,x]),z=C.useMemo(()=>e.items.filter(x).length,[e.items,x]),M=_(e.hint),L=_(e.addLabel),R=C.useMemo(()=>_(e.onAdd),[e.onAdd]),N=C.useCallback(()=>{R&&queueMicrotask(()=>R())},[R]),O=C.useMemo(()=>_(e.style),[e.style]),j=Tt(O?_(O.height):void 0),B=Tt(O?_(O.maxHeight):void 0),H=j!==void 0||B!==void 0,K=H&&(O?_(O.virtualization):void 0)!==!1,U=C.useRef(null),[Z,G]=C.useState(1);C.useEffect(()=>{if(!H)return;const ue=U.current;if(ue===null)return;const oe=()=>G(MDn(ue.clientWidth));oe();const ve=new ResizeObserver(oe);return ve.observe(ue),()=>ve.disconnect()},[H]);const W=C.useMemo(()=>K?TDn(S,Z):[],[K,S,Z]),J=bI({count:W.length,getScrollElement:()=>U.current,estimateSize:ue=>{var oe;return((oe=W[ue])==null?void 0:oe.kind)==="groupHead"?33:104},overscan:4,measureElement:ue=>ue==null?void 0:ue.getBoundingClientRect().height}),ae=C.useRef(void 0),ne=C.useCallback(()=>{K&&(ae.current&&clearTimeout(ae.current),ae.current=setTimeout(()=>{var ue;const oe=((ue=J.getVirtualItems()[0])==null?void 0:ue.index)??0;d(ve=>ve.scrollIndex===oe?ve:{...ve,scrollIndex:oe})},150))},[K,J,d]),Y=C.useRef(!1);C.useEffect(()=>{if(!K||Y.current||W.length===0)return;Y.current=!0;const ue=u.scrollIndex??0;if(ue<=0)return;const oe=Math.min(ue,W.length-1);requestAnimationFrame(()=>J.scrollToIndex(oe,{align:"start"}))},[K,W.length]);const te=e.searchable&&n!==!0,ie=K?p.jsx(V,{css:a.canvas,style:{height:`${J.getTotalSize()}px`},children:J.getVirtualItems().map(ue=>{const oe=W[ue.index];return p.jsx(V,{ref:J.measureElement,"data-index":ue.index,css:a.row,style:{transform:`translateY(${ue.start}px)`},children:oe.kind==="groupHead"?p.jsx(z8e,{label:oe.label,count:oe.count,summary:oe.summary,styles:a}):p.jsx(V,{css:a.rowGrid,style:{gridTemplateColumns:`repeat(${Z}, minmax(0, 1fr))`},children:oe.items.map(ve=>p.jsx(k8e,{libraryId:e.id,item:ve,dimOrder:c,activeDims:u.activeDims,filtered:ve.filtered,styles:a},ve.key))})},ue.key)})}):S.map(ue=>p.jsxs(V,{css:a.group,children:[ue.label!==""&&p.jsx(z8e,{label:ue.label,count:ue.items.length,summary:ue.summary,styles:a}),p.jsx(V,{css:a.grid,children:ue.items.map(oe=>p.jsx(k8e,{libraryId:e.id,item:oe,dimOrder:c,activeDims:u.activeDims,filtered:oe.filtered,styles:a},oe.key))})]},ue.label||"_flat"));return p.jsxs(V,{css:a.root,ref:g,"data-library":e.id,...H?{"data-scrollable":""}:{},style:H?{height:j,maxHeight:B}:void 0,children:[M!==void 0&&p.jsx(V,{css:a.header,children:p.jsx(V,{as:"span",css:a.hint,children:M})}),(te||s.length>0||l.length>0)&&p.jsxs(V,{css:a.toolbar,children:[te&&p.jsxs(V,{css:[i.searchPill,a.search],children:[p.jsx(Ut,{icon:b$,style:{width:10,height:10}}),p.jsx(V,{as:"input",placeholder:"Search…","aria-label":"Search library",value:f,onChange:ue=>h(ue.target.value)}),f!==""&&p.jsx(V,{as:"button",css:i.searchClear,"aria-label":"Clear search",onClick:()=>h(""),children:p.jsx(Ut,{icon:c0,style:{width:9,height:9}})})]}),s.length>0&&p.jsxs(V,{css:a.segGroup,children:[p.jsx(V,{as:"span",css:a.segLabel,children:"Group by"}),s.map(ue=>p.jsx(V,{as:"button",css:{...o({tone:u.groupKey===ue.key?"brand":"neutral",size:"sm"}),cursor:"pointer"},"aria-pressed":u.groupKey===ue.key,onClick:()=>v(ue.key),children:ue.label},ue.key)),p.jsx(V,{as:"button",css:{...o({tone:u.groupKey===null?"brand":"neutral",size:"sm"}),cursor:"pointer"},"aria-pressed":u.groupKey===null,onClick:()=>v(null),children:"None"})]}),l.length>0&&p.jsxs(V,{css:a.segGroup,marginLeft:"auto",children:[p.jsx(V,{as:"span",css:a.segLabel,children:"Secondary"}),l.map(ue=>p.jsx(V,{as:"button",css:{...o({tone:u.activeDims.includes(ue.key)?"brand":"neutral",size:"sm"}),cursor:"pointer"},"aria-pressed":u.activeDims.includes(ue.key),onClick:()=>b(ue.key),children:ue.label},ue.key))]})]}),p.jsx(V,{ref:U,css:H?{...a.body,...xI}:a.body,...H?{"data-scrollable":""}:{},onScroll:ne,children:ie}),(z>0||L!==void 0)&&p.jsxs(V,{css:a.footer,children:[z>0&&p.jsxs(V,{as:"span",css:a.hiddenNote,children:[z," hidden by filter ·"," ",p.jsx(V,{as:"button",css:a.showAll,onClick:()=>h(""),children:"Show all"})]}),L!==void 0&&p.jsxs(V,{as:"button",css:a.addAction,marginLeft:"auto",onClick:N,children:["+ ",L]})]})]})}const EDn=C.memo(function(t){const n=_(t.value.slice),r=n==null?void 0:n.slice;rl(r==null?void 0:r.key);const a=en({key:"sliceFrame"})();if(n===void 0||r===void 0)return p.jsx(M8e,{...t});const o=r.read(),i=n.affordances.map(d=>d.type),s=Lv(i,o),l=Number(r.totalCount()),c=Number(r.resultCount()),u=l>0?Math.round((1-c/l)*100):0;return p.jsxs(V,{css:{...a.root,height:"100%",minHeight:0,display:"flex",flexDirection:"column"},children:[p.jsx(V,{css:{...a.frameEyebrow,flexShrink:0},children:p.jsx(zd,{slice:r,affordanceKinds:s})}),p.jsx(V,{css:{...a.frameBody,flex:"1 1 0%",minHeight:0,overflow:"hidden"},children:p.jsx(M8e,{...t,suppressSearch:s.includes("search")})}),p.jsxs(V,{css:{...a.frameFooter,flexShrink:0},children:[p.jsx(V,{as:"span",css:a.frameFooterStat,children:c.toLocaleString()}),p.jsx(V,{as:"span",children:`items · of ${l.toLocaleString()}`}),u>0&&p.jsx(V,{as:"span",css:a.frameFooterDelta,children:`· −${u}%`})]})]})},(e,t)=>SDn(e.value,t.value)&&e.storageKey===t.storageKey),_Dn=it(sv.Types.Deck),LDn=it(sv.Types.Readout),RDn=it(sv.Types.Rows),PDn=it(sv.Types.Note),ADn=300,T8e={success:"var(--chakra-colors-status-pos)",warning:"var(--chakra-colors-status-warn)",danger:"var(--chakra-colors-status-neg)",info:"var(--chakra-colors-brand-600)",neutral:"var(--chakra-colors-fg-subtle)"};function VV(e,t){if(t===void 0)return;const n=e.get(t);if(n===void 0)return;const r=n.color.type==="token"?T8e[n.color.value.type]??T8e.neutral:n.color.value;return{label:n.label,color:r,tint:`color-mix(in srgb, ${r} 8%, var(--chakra-colors-bg-surface))`,pulse:n.pulse,hint:_(n.hint)}}function jXe(e){return e!==void 0?{"--dc":e.color,"--dt":e.tint}:void 0}function FXe(e){return e===void 0?void 0:x$e({prefix:"fas",iconName:e})??void 0}function BXe(e,t,n){if(e===void 0)return"—";const r=_(n);if(r!==void 0)return r;const a=_(t);return a!==void 0?Iv(a,"linear")(e):new Intl.NumberFormat().format(e)}function VXe({st:e,styles:t}){return p.jsxs(V,{as:"span",css:t.stag,"data-pulse":e.pulse?"":void 0,children:[p.jsx(V,{as:"span",css:t.sdot,"data-part":"sdot"}),e.label]})}function NDn({item:e,st:t,styles:n,libStyles:r,open:a,activatable:o,registerEl:i,onActivate:s,onHoverStart:l,onHoverEnd:c,storageKey:u}){const d=FXe(_(e.icon)),f=_(e.sublabel),h=_(e.face),g=_(e.fill),v=g!==void 0&&g.max>0?Math.min(100,Math.max(0,g.value/g.max*100)):0;return p.jsxs(V,{css:n.card,ref:b=>i(e.key,b),"data-clickable":o?"":void 0,"data-filtered":e.filtered?"":void 0,"data-status":t!==void 0?"":void 0,"data-open":a?"":void 0,style:jXe(t),onMouseEnter:()=>l(e),onMouseLeave:c,...o?{role:"button",tabIndex:0,onClick:()=>s(e),onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),s(e))}}:{},children:[d!==void 0&&p.jsx(V,{css:n.cardIcon,children:p.jsx(Ut,{icon:d})}),p.jsxs(V,{css:n.cardBody,children:[p.jsxs(V,{css:n.cardHead,children:[p.jsxs(V,{css:n.cardId,children:[p.jsx(V,{as:"span",css:n.cardName,children:e.title}),f!==void 0&&p.jsx(V,{as:"span",css:n.cardSub,children:f})]}),t!==void 0&&p.jsx(VXe,{st:t,styles:n})]}),e.metrics.length>0&&p.jsx(V,{css:n.metricsRow,children:e.metrics.map((b,y)=>{const x=_(b.value);return p.jsxs(V,{css:n.metricCell,children:[p.jsx(V,{as:"span",css:n.metricK,children:b.label}),p.jsx(V,{as:"span",css:n.metricV,"data-warn":b.warn?"":void 0,"data-muted":x===void 0?"":void 0,children:BXe(x,b.format,b.text)})]},y)})}),e.facts.map((b,y)=>{const x=b.value;if(x.type==="meter"){const S=x.value.max>0?Math.min(100,Math.max(0,x.value.value/x.value.max*100)):0,z=_(x.value.text);return p.jsxs(V,{css:r.meter,children:[p.jsx(V,{css:r.meterTrack,children:p.jsx(V,{css:r.meterFill,style:{width:`${S}%`}})}),z!==void 0&&p.jsx(V,{as:"span",css:r.meterText,children:z})]},y)}return x.type==="chips"?p.jsx(V,{css:r.chips,children:x.value.map((S,z)=>p.jsx(V,{as:"span",css:r.chip,children:S},z))},y):p.jsx(V,{as:"span",css:r.dimText,children:x.value},y)}),h!==void 0&&p.jsx(V,{css:n.face,children:p.jsx(mn,{value:h,storageKey:`${u}.face.${e.key}`})}),g!==void 0&&p.jsxs(V,{css:n.fillRow,children:[p.jsx(V,{css:n.fillTrack,children:p.jsx(V,{css:n.fillBar,style:{width:`${v}%`}})}),p.jsx(V,{as:"span",css:n.fillPct,children:_(g.text)??(_(g.format)!==void 0?Iv(_(g.format),"linear")(g.value):`${Math.round(v)}%`)})]})]})]})}function E8e({item:e,st:t,body:n,mode:r,getAnchorRect:a,onDismiss:o,contentRef:i,styles:s,storageKey:l}){const c=FXe(_(e.icon)),u=_(e.sublabel);return p.jsx(nu,{open:!0,onOpenChange:d=>{d.open||o()},positioning:{placement:"right-start",getAnchorRect:a},autoFocus:r==="click",modal:!1,children:p.jsx(go,{children:p.jsx(M4,{children:p.jsxs(T4,{css:s.pop,"data-mode":r,"data-status":t!==void 0?"":void 0,"aria-label":e.title,style:jXe(t),...i!==void 0?{ref:i}:{},onKeyDown:d=>{r==="click"&&d.key==="Escape"&&(d.preventDefault(),o())},children:[p.jsxs(V,{css:s.popHead,children:[c!==void 0&&p.jsx(V,{css:s.cardIcon,children:p.jsx(Ut,{icon:c})}),p.jsxs(V,{css:s.cardId,children:[p.jsx(V,{as:"span",css:s.cardName,children:e.title}),u!==void 0&&p.jsx(V,{as:"span",css:s.cardSub,children:u})]}),t!==void 0&&p.jsx(VXe,{st:t,styles:s}),r==="click"&&p.jsx(Ht.button,{type:"button",css:s.popClose,"aria-label":"Close",onClick:o,children:p.jsx(Ut,{icon:c0})})]}),p.jsx(V,{css:s.popBody,children:p.jsx(mn,{value:n,storageKey:`${l}.${r}.${e.key}`})})]})})})})}const $Dn=C.memo(function({value:t}){const n=en({key:"deck"})();return p.jsx(V,{css:n.readout,children:t.cells.map((r,a)=>{const o=_(r.value),i=_(r.unit);return p.jsxs(V,{css:n.readoutCell,children:[p.jsx(V,{css:n.readoutK,children:r.label}),p.jsxs(V,{css:n.readoutV,"data-warn":r.warn?"":void 0,"data-muted":o===void 0?"":void 0,children:[BXe(o,r.format,r.text),i!==void 0&&p.jsx(V,{as:"span",css:n.readoutU,children:i})]})]},a)})})},(e,t)=>LDn(e.value,t.value)),IDn=C.memo(function({value:t}){const n=en({key:"deck"})();return p.jsx(V,{css:n.drows,children:t.rows.map((r,a)=>p.jsxs(V,{css:n.drow,children:[p.jsx(V,{as:"span",css:n.drowK,children:r.label}),p.jsx(V,{as:"span",css:n.drowV,children:r.value})]},a))})},(e,t)=>RDn(e.value,t.value)),DDn=C.memo(function({value:t}){const n=en({key:"deck"})();return p.jsx(V,{css:n.note,children:t.text})},(e,t)=>PDn(e.value,t.value));function _8e({value:e,storageKey:t}){var n,r;const a=en({key:"deck"})(),o=en({key:"library"})(),i=ga({key:"chip"}),s=e.groupOptions,{state:l,setState:c}=Pl(`${t}.toolbar`,{groupKey:((n=s[0])==null?void 0:n.key)??null,collapsed:[]}),u=C.useCallback(oe=>{c(ve=>({...ve,groupKey:oe,collapsed:[]}))},[c]),d=C.useCallback(oe=>{c(ve=>({...ve,collapsed:ve.collapsed.includes(oe)?ve.collapsed.filter(se=>se!==oe):[...ve.collapsed,oe]}))},[c]),f=C.useMemo(()=>{const oe=l.groupKey,ve=oe!==null?e.groupSummaries.get(oe):void 0,se=new Map;for(const pe of e.items){const de=(oe!==null?pe.groups.get(oe):void 0)??"";let ge=se.get(de);ge===void 0&&(ge={label:de,summary:ve==null?void 0:ve.get(de),items:[]},se.set(de,ge)),ge.items.push(pe)}return[...se.values()]},[e.items,e.groupSummaries,l.groupKey]),h=C.useMemo(()=>_(e.onCardClick),[e.onCardClick]),g=C.useMemo(()=>_(e.onOpen),[e.onOpen]),v=C.useMemo(()=>_(e.onClose),[e.onClose]),b=C.useCallback(oe=>VV(e.statuses,_(oe.status)),[e.statuses]),y=C.useRef(new Map),x=C.useCallback((oe,ve)=>{ve===null?y.current.delete(oe):y.current.set(oe,ve)},[]),S=C.useCallback(oe=>()=>{const ve=y.current.get(oe);return ve!==void 0?ve.getBoundingClientRect():null},[]),[z,M]=C.useState(null),L=C.useMemo(()=>z!==null?e.items.find(oe=>oe.key===z):void 0,[e.items,z]),R=L!==void 0?_(L.detail):void 0,N=C.useCallback(()=>{z!==null&&(M(null),v&&queueMicrotask(()=>{v()}))},[z,v]),O=C.useCallback(oe=>{_(oe.detail)!==void 0&&(M(oe.key),g&&queueMicrotask(()=>{g(oe.key)})),h&&queueMicrotask(()=>h(oe.key))},[g,h]),j=C.useRef(null);C.useEffect(()=>{if(z===null)return;const oe=ve=>{const se=j.current;se!==null&&!se.contains(ve.target)&&N()};return document.addEventListener("pointerdown",oe),()=>document.removeEventListener("pointerdown",oe)},[z,N]);const B=Poe(),[H,K]=C.useState(null),U=C.useRef(null),Z=C.useCallback(oe=>{!B||_(oe.hover)===void 0||(U.current!==null&&clearTimeout(U.current),U.current=setTimeout(()=>{K(oe.key)},ADn))},[B]),G=C.useCallback(()=>{U.current!==null&&clearTimeout(U.current),U.current=null,K(null)},[]);C.useEffect(()=>()=>{U.current!==null&&clearTimeout(U.current)},[]);const W=C.useMemo(()=>H!==null?e.items.find(oe=>oe.key===H):void 0,[e.items,H]),J=W!==void 0?_(W.hover):void 0,ae=((r=_(e.layout))==null?void 0:r.type)??"grid",ne=C.useMemo(()=>_(e.style),[e.style]),Y=Tt(ne?_(ne.height):void 0),te=Tt(ne?_(ne.maxHeight):void 0),ie=Tt(ne?_(ne.minCardWidth):void 0)??"240px",ue=Y!==void 0||te!==void 0;return p.jsxs(V,{css:a.root,"data-scrollable":ue?"":void 0,style:{...Y!==void 0?{height:Y}:{},...te!==void 0?{maxHeight:te}:{}},children:[s.length>0&&p.jsx(V,{css:a.toolbar,children:p.jsxs(V,{css:a.segGroup,children:[p.jsx(V,{as:"span",css:a.segLabel,children:"Group by"}),[...s,{key:null,label:"None"}].map(oe=>p.jsx(V,{as:"button",css:{...i({tone:l.groupKey===oe.key?"brand":"neutral",size:"sm"}),cursor:"pointer"},onClick:()=>u(oe.key),children:oe.label},oe.key??"∅"))]})}),p.jsx(V,{css:a.body,"data-scrollable":ue?"":void 0,children:f.map(oe=>{const ve=l.collapsed.includes(oe.label),se=VV(e.statuses,oe.label!==""?oe.label:void 0);return p.jsxs(V,{css:a.group,children:[oe.label!==""&&p.jsxs(V,{as:"button",css:a.groupHead,"aria-expanded":!ve,onClick:()=>d(oe.label),children:[p.jsx(V,{as:"span",css:a.groupChevron,children:p.jsx(Ut,{icon:ve?r2:au})}),se!==void 0&&p.jsx(V,{as:"span",css:a.groupSwatch,style:{background:se.color}}),p.jsx(V,{as:"span",css:a.groupLabel,children:(se==null?void 0:se.label)??oe.label}),p.jsx(V,{as:"span",css:a.groupCount,children:oe.items.length}),(oe.summary??(se==null?void 0:se.hint))!==void 0&&p.jsx(V,{as:"span",css:a.groupSummary,children:oe.summary??(se==null?void 0:se.hint)})]}),!ve&&p.jsx(V,{css:ae==="list"?a.list:a.grid,style:ae==="grid"?{gridTemplateColumns:`repeat(auto-fill, minmax(min(${ie}, 100%), 1fr))`}:void 0,children:oe.items.map(pe=>p.jsx(NDn,{item:pe,st:b(pe),styles:a,libStyles:o,open:z===pe.key,activatable:h!==void 0||_(pe.detail)!==void 0,registerEl:x,onActivate:O,onHoverStart:Z,onHoverEnd:G,storageKey:t},pe.key))})]},oe.label||"∅")})}),e.footer.length>0&&p.jsx(V,{css:a.footRow,children:e.footer.map((oe,ve)=>p.jsxs(C.Fragment,{children:[ve>0&&p.jsx(V,{as:"span",css:a.footSep,children:"·"}),p.jsx(V,{as:"span",css:a.footK,children:oe.label}),p.jsx(V,{as:"span",css:a.footV,children:oe.value})]},ve))}),e.legend&&e.statuses.size>0&&p.jsx(V,{css:a.legend,children:[...e.statuses.keys()].map(oe=>{const ve=VV(e.statuses,oe);return ve===void 0?null:p.jsxs(V,{css:a.legendItem,children:[p.jsx(V,{as:"span",css:a.legendSw,style:{background:ve.color}}),p.jsx(V,{as:"span",css:a.legendLb,children:ve.label}),ve.hint!==void 0&&p.jsx(V,{as:"span",css:a.legendDs,children:ve.hint})]},oe)})}),W!==void 0&&J!==void 0&&H!==null&&z===null&&p.jsx(E8e,{item:W,st:b(W),body:J,mode:"hover",getAnchorRect:S(W.key),onDismiss:G,contentRef:void 0,styles:a,storageKey:t}),L!==void 0&&R!==void 0&&z!==null&&p.jsx(E8e,{item:L,st:b(L),body:R,mode:"click",getAnchorRect:S(L.key),onDismiss:N,contentRef:j,styles:a,storageKey:t})]})}const ODn=C.memo(function(t){const n=_(t.value.slice),r=n==null?void 0:n.slice;rl(r==null?void 0:r.key);const a=en({key:"sliceFrame"})();if(n===void 0||r===void 0)return p.jsx(_8e,{...t});const o=r.read(),i=n.affordances.map(d=>d.type),s=Lv(i,o),l=Number(r.totalCount()),c=Number(r.resultCount()),u=l>0?Math.round((1-c/l)*100):0;return p.jsxs(V,{css:{...a.root,height:"100%",minHeight:0,display:"flex",flexDirection:"column"},children:[p.jsx(V,{css:{...a.frameEyebrow,flexShrink:0},children:p.jsx(zd,{slice:r,affordanceKinds:s})}),p.jsx(V,{css:{...a.frameBody,flex:"1 1 0%",minHeight:0,overflow:"hidden"},children:p.jsx(_8e,{...t})}),p.jsxs(V,{css:{...a.frameFooter,flexShrink:0},children:[p.jsx(V,{as:"span",css:a.frameFooterStat,children:c.toLocaleString()}),p.jsx(V,{as:"span",children:`cards · of ${l.toLocaleString()}`}),u>0&&p.jsx(V,{as:"span",css:a.frameFooterDelta,children:`· −${u}%`})]})]})},(e,t)=>_Dn(e.value,t.value)&&e.storageKey===t.storageKey),jDn=it(fq.Types.Checkbox);function L8e(e){var t,n;const r=_(e.indeterminate),a=_(e.style),o=a?(t=_(a.colorPalette))==null?void 0:t.type:void 0,i=a?(n=_(a.size))==null?void 0:n.type:void 0;return{checked:r?"indeterminate":e.checked,disabled:_(e.disabled),colorPalette:o??"brand",size:i}}const HXe=C.memo(function({value:t}){const[n,r]=C.useState(L8e(t)),a=C.useMemo(()=>_(t.label),[t.label]),o=C.useMemo(()=>_(t.onChange),[t.onChange]);C.useEffect(()=>{r(()=>L8e(t))},[t]);const i=C.useCallback(s=>{r(l=>({...l,checked:s.checked})),o&&queueMicrotask(()=>o(s.checked===!0))},[o]);return p.jsxs(kNt,{...n,onCheckedChange:i,children:[p.jsx(ENt,{}),p.jsx(TNt,{}),a&&p.jsx(zNt,{children:a})]})},(e,t)=>jDn(e.value,t.value)),FDn=it(Ste.Types.Root),bb=32,BDn=1,R8e=18,VDn=3;function HDn(e){let t="";for(const n of e)n.type==="field"?t+=`.${n.value}`:n.type==="index"?t+=`[${n.value}]`:n.type==="key"?t+=`{${n.value}}`:n.type==="some"?t+="?":t+="!";return t===""?"$":t}function MI(e){const t=e.replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim();return t===""?e:t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}function WDn(e,t){let n=e,r=t,a,o;for(;;){if(n.type==="option"){const s=_(n.value.value);if(o===void 0&&(o={path:r,isSome:s!==void 0}),s===void 0)return{kind:"emptyOption",leaf:void 0,opaque:void 0,node:n,path:r,variantCtl:a,optionCtl:o};r=[...r,$("some",null)],n=s;continue}if(n.type==="variant"){a===void 0&&(a={path:r,tag:n.value.tag,tags:[...n.value.tags]}),r=[...r,$("tag",null)],n=n.value.value;continue}break}return{kind:n.type==="leaf"?"leaf":n.type==="opaque"?"opaque":n.type==="struct"?"struct":n.type==="array"?"array":"dict",leaf:n.type==="leaf"?n.value:void 0,opaque:n.type==="opaque"?n.value:void 0,node:n,path:r,variantCtl:a,optionCtl:o}}function P8e(e){for(;;){if(e.type==="option"){const t=_(e.value.value);if(t===void 0)return e;e=t;continue}if(e.type==="variant"){e=e.value.value;continue}return e}}function WXe(e){switch(e.type){case"string":return e.value;case"integer":return String(e.value);case"float":return String(e.value);case"boolean":return e.value?"true":"false";case"datetime":return e.value.toISOString().replace("T"," ").slice(0,19);default:return"—"}}function UDn(e){for(;;){if(e.type==="option"){const t=_(e.value.value);if(t===void 0)return;e=t;continue}break}if(e.type==="variant")return MI(e.value.tag);if(e.type==="leaf"){if(e.value.type==="null")return;const t=WXe(e.value);return t===""?void 0:t}}function qDn(e){if(e.type==="struct"){const t=[];for(const r of e.value.fields){const a=UDn(r.node);if(a!==void 0&&t.push(a),t.length>=VDn)break}if(t.length>0)return t.join(" · ");const n=e.value.fields.length;return n===0?"Empty":n===1?"1 field":`${n} fields`}if(e.type==="array"){const t=e.value.items.length;return t===0?"Empty":t===1?"1 item":`${t} items`}if(e.type==="dict"){const t=e.value.entries.length;return t===0?"Empty":t===1?"1 entry":`${t} entries`}return""}function UXe(e,t){const n=P8e(e);if(n.type==="struct")for(const r of n.value.fields){const a=P8e(r.node);if(a.type==="leaf"&&a.value.type==="string"&&a.value.value!=="")return a.value.value}return`Item ${t+1}`}function qXe(e){return e.type==="struct"?e.value.fields.map(t=>({label:MI(t.name),node:t.node,step:$("field",t.name)})):e.type==="array"?e.value.items.map((t,n)=>({label:UXe(t,n),node:t,step:$("index",BigInt(n))})):e.type==="dict"?e.value.entries.map(t=>({label:t.key,node:t.node,step:$("key",t.key)})):[]}function GXe(e,t,n,r,a,o){return{id:`${e??"$"}/$append`,parentId:e,depth:r,label:n==="appendArray"?"Add item":"Add entry",kind:n,leaf:void 0,opaque:void 0,summary:void 0,path:t,ownPath:t,variantCtl:void 0,optionCtl:void 0,removable:!1,expandable:!1,expanded:!1,posinset:a,setsize:o}}function Pie(e,t,n,r,a,o,i,s,l){const c=WDn(n,r),u=HDn(r),d=qXe(c.node),f=e.canInsert&&(c.kind==="array"||c.kind==="dict"&&c.node.type==="dict"&&c.node.value.editable),h=d.length>0||f,g=h&&(e.open[u]??o<e.openDepth);let v=c.kind==="emptyOption"?"Not set":c.kind==="struct"||c.kind==="array"||c.kind==="dict"?qDn(c.node):void 0;if(v!==void 0&&v!==t&&v.startsWith(`${t} · `)?v=v.slice(t.length+3):v===t&&(v=void 0),e.rows.push({id:u,parentId:a,depth:o,label:t,kind:c.kind,leaf:c.leaf,opaque:c.opaque,summary:v,path:c.path,ownPath:r,variantCtl:c.variantCtl,optionCtl:c.optionCtl,removable:i,expandable:h,expanded:g,posinset:s,setsize:l}),g){const b=e.canRemove&&(c.kind==="array"||c.kind==="dict"&&c.node.type==="dict"&&c.node.value.editable),y=d.length+(f?1:0);d.forEach((x,S)=>{Pie(e,x.label,x.node,[...c.path,x.step],u,o+1,b,S+1,y)}),f&&e.rows.push(GXe(u,c.path,c.kind==="array"?"appendArray":"appendDict",o+1,y,y))}}function GDn(e,t,n,r,a){const o={open:t,openDepth:n,canRemove:r,canInsert:a,rows:[]},i=(c,u,d,f,h,g,v,b)=>Pie(o,c,u,d,f,h,g,v,b),s=o.rows,l=(c,u,d,f,h,g)=>GXe(c,u,d,f,h,g);if(e.type==="struct"||e.type==="array"||e.type==="dict"){const c=a&&(e.type==="array"||e.type==="dict"&&e.value.editable),u=r&&(e.type==="array"||e.type==="dict"&&e.value.editable),d=qXe(e),f=d.length+(c?1:0);d.forEach((h,g)=>{i(h.label,h.node,[h.step],void 0,0,u,g+1,f)}),c&&s.push(l(void 0,[],e.type==="array"?"appendArray":"appendDict",0,f,f))}else i("Value",e,[],void 0,0,!1,1,1);return s}function A8e(...e){try{if(typeof localStorage>"u")return;const t=localStorage.getItem("e3-paging-debug");if(t===null||t==="off")return}catch{return}console.info("[e3-paging:tree]",...e)}function KDn(e,t,n){const{totalRows:r,pageSize:a,pages:o}=e,i=Math.max(0,Math.ceil(r/a)),s=d=>Math.max(0,Math.min(a,r-d*a)),l=new Map,c=[],u=new Array(i+1);u[0]=0;for(let d=0;d<i;d++){const f=o.get(d);if(f===void 0){u[d+1]=u[d]+s(d);continue}const h={open:t,openDepth:n,canRemove:!1,canInsert:!1,rows:[]};f.forEach((g,v)=>{const b=d*a+v,y=g.label??UXe(g.node,b);Pie(h,y,g.node,[g.step],void 0,0,!1,b+1,r)}),l.set(d,h.rows),c.push(...h.rows),u[d+1]=u[d]+h.rows.length}return{totalFlat:u[i]??0,prefix:u,pageModels:l,loadedRows:c,pageCount:i,rootRowsInPage:s}}function nX(e,t){let n=0,r=e.length-2;for(;n<r;){const a=n+r>>1;e[a+1]<=t?n=a+1:r=a}return n}function YDn(e,t,n){const r=nX(e.prefix,n),a=n-e.prefix[r],o=e.pageModels.get(r);return o!==void 0?{kind:"model",row:o[a]}:{kind:"placeholder",globalRow:r*t.pageSize+a}}const fx=P({size:P($("xs",null))});function XDn(e,t,n){return{value:P(e),items:t.map(r=>({value:r,label:MI(r),disabled:A})),placeholder:A,multiple:A,disabled:A,onChange:P(n),onChangeMultiple:A,onOpenChange:A,style:fx}}function ZDn({leaf:e,path:t,onEdit:n}){switch(e.type){case"string":return p.jsx(Y$,{value:{value:e.value,onChange:P(r=>{n(t,$("string",r))}),style:fx}});case"integer":return p.jsx(X$,{value:{value:e.value,onChange:P(r=>{n(t,$("integer",r))}),style:fx}});case"float":return p.jsx(Z$,{value:{value:e.value,onChange:P(r=>{n(t,$("float",r))}),style:fx}});case"datetime":return p.jsx(m9,{value:{value:e.value,onChange:P(r=>{n(t,$("datetime",r))}),style:fx}});case"boolean":return p.jsx(HXe,{value:{checked:e.value,onChange:P(r=>{n(t,$("boolean",r))})}});default:return null}}function QDn({path:e,styles:t,onInsert:n}){const[r,a]=C.useState(void 0);return r===void 0?p.jsxs(Ht.button,{type:"button",css:t.append,"aria-label":"Add entry",onClick:()=>a(""),children:[p.jsx(Ut,{icon:m5})," Add entry"]}):p.jsx(Ht.input,{css:t.keyInput,autoFocus:!0,value:r,placeholder:"name","aria-label":"New entry key",onChange:o=>a(o.target.value),onBlur:()=>a(void 0),onKeyDown:o=>{o.key==="Enter"&&r!==""?(n([...e,$("key",r)]),a(void 0)):o.key==="Escape"&&a(void 0)}})}function JDn({row:e,styles:t,cbs:n,tabbable:r,onToggle:a,onKeyNav:o,onFocusRow:i}){var s;const{onEdit:l,onInsert:c,onRemove:u,onTag:d}=n,f=b=>{b.target===b.currentTarget&&o(e.id,b.key)&&b.preventDefault()};if((e.kind==="appendArray"||e.kind==="appendDict")&&c!==void 0)return p.jsxs(V,{css:t.row,"data-part":"row","data-row-id":e.id,role:"treeitem","aria-level":e.depth+1,tabIndex:r?0:-1,onKeyDown:f,onFocus:b=>{b.target===b.currentTarget&&i(e.id)},style:{paddingLeft:`${12+e.depth*R8e}px`},children:[p.jsx(V,{css:t.twist,visibility:"hidden","aria-hidden":"true"}),e.kind==="appendArray"?p.jsxs(Ht.button,{type:"button",css:t.append,"aria-label":e.label,onClick:()=>{c([...e.path,$("append",null)])},children:[p.jsx(Ut,{icon:m5})," ",e.label]}):p.jsx(QDn,{path:e.path,styles:t,onInsert:c})]});const h=e.variantCtl!==void 0&&d===void 0?p.jsx(V,{as:"span",css:t.summary,children:MI(e.variantCtl.tag)}):null,g=e.variantCtl!==void 0&&d!==void 0?(()=>{const b=e.variantCtl;return p.jsx(V,{css:t.tagWrap,children:p.jsx(h6,{ariaLabel:"Variant tag",value:XDn(b.tag,b.tags,y=>{y!==b.tag&&d(b.path,y)})})})})():null;let v;return e.kind==="leaf"&&e.leaf!==void 0?v=l!==void 0&&e.leaf.type!=="null"?p.jsx(ZDn,{leaf:e.leaf,path:e.path,onEdit:l}):(h!==null||g!==null)&&e.leaf.type==="null"?null:p.jsx(V,{as:"span",css:t.valueText,children:WXe(e.leaf)}):e.kind==="opaque"?v=p.jsx(V,{as:"span",css:t.opaque,title:e.opaque,children:e.opaque}):v=e.summary!==void 0&&e.summary!==""?p.jsx(V,{as:"span",css:t.summary,children:e.summary}):null,p.jsxs(V,{css:t.row,"data-part":"row","data-row-id":e.id,role:"treeitem","aria-level":e.depth+1,"aria-posinset":e.posinset,"aria-setsize":e.setsize,"aria-expanded":e.expandable?e.expanded:void 0,tabIndex:r?0:-1,onKeyDown:f,onFocus:b=>{b.target===b.currentTarget&&i(e.id)},style:{paddingLeft:`${12+e.depth*R8e}px`},children:[e.expandable?p.jsx(Ht.button,{type:"button",css:t.twist,tabIndex:-1,"aria-label":e.expanded?"Collapse":"Expand",title:e.expanded?"Collapse (Alt: entire subtree)":"Expand",onClick:b=>a(e.id,!e.expanded,b.altKey),children:p.jsx(Ut,{icon:e.expanded?au:r2})}):p.jsx(V,{css:t.twist,visibility:"hidden","aria-hidden":"true"}),p.jsx(V,{as:"span",css:t.label,title:e.label,children:e.label}),p.jsxs(V,{css:t.value,"data-leaf":(s=e.leaf)==null?void 0:s.type,children:[h,g,v]}),p.jsxs(V,{css:t.controls,children:[e.optionCtl!==void 0&&d!==void 0&&(()=>{const b=e.optionCtl;return b.isSome?p.jsx(Ht.button,{type:"button",css:t.ctl,"aria-label":"Clear value",onClick:()=>{d(b.path,"none")},children:p.jsx(Ut,{icon:m$})}):p.jsx(Ht.button,{type:"button",css:t.setBtn,"aria-label":"Set value",onClick:()=>{d(b.path,"some")},children:"Set"})})(),e.removable&&u!==void 0&&p.jsx(Ht.button,{type:"button",css:t.ctl,"aria-label":"Remove",onClick:()=>{u(e.ownPath)},children:p.jsx(Ut,{icon:c0})})]})]})}const Aie=C.memo(function({value:t,storageKey:n,paging:r}){var a;const i=en({key:"valueTree"})(),s=C.useMemo(()=>({onEdit:_(t.onEdit),onInsert:_(t.onInsert),onRemove:_(t.onRemove),onTag:_(t.onTag)}),[t.onEdit,t.onInsert,t.onRemove,t.onTag]),{state:l,setState:c}=Pl(n,{open:{},topRow:0}),u=_(t.style),d=u!==void 0&&u.openDepth!==void 0?_(u.openDepth):void 0,f=(u!==void 0&&u.toolbar!==void 0?_(u.toolbar):void 0)===!0,h=l.baseDepth??(d!==void 0?Number(d):BDn),g=C.useMemo(()=>{if(r===void 0)return;const Y=KDn(r,l.open,h);return A8e(`flatten: totalRows=${r.totalRows} pageSize=${r.pageSize} totalFlat=${Y.totalFlat} loaded=[${[...Y.pageModels.entries()].map(([te,ie])=>`p${te}:${ie.length}`).join(" ")}]`),Y},[r,l.open,h]),v=C.useMemo(()=>g!==void 0?g.loadedRows:GDn(t.root,l.open,h,s.onRemove!==void 0,s.onInsert!==void 0),[g,t.root,l.open,h,s.onRemove,s.onInsert]),b=g!==void 0?g.totalFlat:v.length,y=C.useCallback((Y,te,ie=!1)=>{c(ue=>{if(!ie||te)return{...ue,open:{...ue.open,[Y]:te}};const oe={...ue.open,[Y]:!1},ve=v.findIndex(se=>se.id===Y);if(ve>=0){const se=v[ve].depth;for(let pe=ve+1;pe<v.length&&v[pe].depth>se;pe++)v[pe].expandable&&(oe[v[pe].id]=!1)}return{...ue,open:oe}})},[c,v]),x=C.useCallback(()=>{c(Y=>({...Y,open:{},baseDepth:0}))},[c]),S=C.useCallback(()=>{c(Y=>({...Y,open:{},baseDepth:Number.MAX_SAFE_INTEGER}))},[c]),z=C.useRef(null),[M,L]=C.useState(void 0),R=C.useCallback(Y=>{L(Y)},[]),N=C.useCallback(Y=>{var te;L(Y);const ie=Y.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),ue=(te=z.current)==null?void 0:te.querySelector(`[data-row-id="${ie}"]`);ue==null||ue.focus()},[]),O=C.useCallback((Y,te)=>{const ie=v.findIndex(oe=>oe.id===Y);if(ie<0)return!1;const ue=v[ie];switch(te){case"ArrowDown":{const oe=v[ie+1];return oe!==void 0&&N(oe.id),!0}case"ArrowUp":{const oe=v[ie-1];return oe!==void 0&&N(oe.id),!0}case"ArrowRight":{if(ue.expandable&&!ue.expanded)y(ue.id,!0);else{const oe=v[ie+1];oe!==void 0&&N(oe.id)}return!0}case"ArrowLeft":return ue.expandable&&ue.expanded?y(ue.id,!1):ue.parentId!==void 0&&N(ue.parentId),!0;case"Enter":case" ":return ue.expandable&&y(ue.id,!ue.expanded),!0;default:return!1}},[v,N,y]),j=C.useRef(null),B=C.useRef(!1);C.useLayoutEffect(()=>{if(B.current)return;B.current=!0;const Y=j.current;Y!==null&&l.topRow>0&&(Y.scrollTop=l.topRow*bb)},[l.topRow]);const H=C.useCallback(()=>{if(r===void 0||g===void 0||r.totalRows===0)return;const Y=j.current,te=Y===null?0:Math.max(0,Math.floor(Y.scrollTop/bb)),ie=Y===null?60:Math.ceil(Y.clientHeight/bb)+1,ue=Math.min(g.totalFlat-1,te+ie),oe=Math.max(0,nX(g.prefix,te)-1),ve=Math.min(g.pageCount-1,nX(g.prefix,ue)+1);A8e(`visible: scrollTop=${(Y==null?void 0:Y.scrollTop)??"null"} clientH=${(Y==null?void 0:Y.clientHeight)??"null"} flat[${te},${ue}] → pages ${oe}..${ve} → rows [${oe*r.pageSize}, ${Math.min(r.totalRows,(ve+1)*r.pageSize)})`),r.onNeedRows(oe*r.pageSize,Math.min(r.totalRows,(ve+1)*r.pageSize))},[r,g]);C.useLayoutEffect(()=>{H()},[H]);const K=C.useCallback(()=>{const Y=j.current;if(Y===null)return;const te=Math.round(Y.scrollTop/bb);c(ie=>ie.topRow===te?ie:{...ie,topRow:te}),H()},[c,H]),U=u!==void 0?_(u.height):void 0,Z=u!==void 0?_(u.maxHeight):void 0;if(b===0)return p.jsx(V,{css:i.root,role:"tree",children:p.jsx(V,{css:i.empty,children:"No values"})});const G=M!==void 0&&v.some(Y=>Y.id===M)?M:(a=v[0])==null?void 0:a.id,W=Tt(U),J=Tt(Z),ae=W!==void 0||J!==void 0,ne=f?p.jsxs(V,{css:i.toolbar,children:[p.jsx(Ht.button,{type:"button",css:i.toolbarBtn,onClick:x,children:"Collapse all"}),p.jsx(Ht.button,{type:"button",css:i.toolbarBtn,onClick:S,children:"Expand all"})]}):void 0;return p.jsx(V,{role:"tree","aria-label":"Value tree",ref:z,...ae&&{display:"flex",flexDirection:"column",minHeight:0,height:W,maxHeight:J},children:p.jsx(Dv,{height:ae?void 0:U,maxHeight:ae?void 0:Z,fillParent:ae,header:ne,count:b,estimateSize:()=>bb,overscan:8,rootCss:i.root,scrollElRef:j,onScroll:K,renderRow:Y=>{let te;if(g!==void 0&&r!==void 0){const ie=YDn(g,r,Y);if(ie.kind==="placeholder")return p.jsxs(V,{css:i.row,"data-part":"row","data-placeholder-row":ie.globalRow,role:"treeitem","aria-level":1,"aria-posinset":ie.globalRow+1,"aria-setsize":r.totalRows,"aria-busy":"true",style:{paddingLeft:"12px"},children:[p.jsx(V,{css:i.twist,visibility:"hidden","aria-hidden":"true"}),p.jsx(d4,{height:"14px",flex:"0 1 160px"}),p.jsx(d4,{height:"14px",flex:"0 1 90px",opacity:.6})]});te=ie.row}else te=v[Y];return te===void 0?null:p.jsx(JDn,{row:te,styles:i,cbs:s,tabbable:te.id===G,onToggle:y,onKeyNav:O,onFocusRow:R},te.id)}})})},(e,t)=>FDn(e.value,t.value)&&e.storageKey===t.storageKey&&e.paging===t.paging),eOn=it(Cte.Types.Roster),KXe=84,tOn=`${KXe}px`;function N8e(e,t){return`${e}\0${t}`}function KE(e,t,n,r){return{surface:e,row:t,slot:n,event:r!==void 0?P(r):A}}function nOn(e){return Sr(e.state,{committed:()=>e.label,rejected:()=>e.label,proposed:t=>Sr(t,{added:()=>`+${e.label}`,removed:()=>e.label,model:()=>e.label})})}function rOn(e){return Sr(e.state,{committed:()=>"committed",rejected:()=>"rejected",proposed:t=>Sr(t,{added:()=>"added",removed:()=>"removed",model:()=>"model"})})}function aOn({surface:e,person:t,day:n,shift:r,edit:a,styles:o,onSelect:i,onAccept:s,onRemove:l}){const c=rOn(r),u=c==="model",d=a&&(c==="added"||c==="removed"||c==="model"),f=C.useMemo(()=>({surface:e,row:t,slot:n,event:r.key}),[e,t,n,r.key]),h=C.useMemo(()=>p.jsx(V,{css:o.dragGhost,children:r.label}),[o.dragGhost,r.label]),g=CI(f,h,!d),v=C.useCallback(b=>{b.stopPropagation();const y=KE(e,t,n,r.key);u&&s?s(y):i&&i(y)},[e,t,n,r.key,u,s,i]);return p.jsxs(V,{css:o.chip,"data-state":c,onPointerDown:g,onClick:v,...d&&g?{"data-draggable":""}:{},children:[d&&g&&p.jsx(V,{as:"span",css:o.chipGrip,children:p.jsx(Ut,{icon:g5})}),p.jsx(V,{as:"span",css:o.chipLabel,children:nOn(r)}),(u&&s||d&&l)&&p.jsxs(V,{css:o.chipActions,children:[u&&s&&p.jsx(V,{as:"button",css:o.chipAction,"aria-label":"Accept ghost shift",onPointerDown:b=>b.stopPropagation(),onClick:b=>{b.stopPropagation(),s(KE(e,t,n,r.key))},children:p.jsx(Ut,{icon:_$})}),d&&l&&p.jsx(V,{as:"button",css:o.chipAction,"data-danger":"","aria-label":"Remove shift",onPointerDown:b=>b.stopPropagation(),onClick:b=>{b.stopPropagation(),l(KE(e,t,n,r.key))},children:p.jsx(Ut,{icon:UC})})]})]})}function oOn({surface:e,person:t,day:n,shifts:r,edit:a,styles:o,vetoFor:i,onSelect:s,onAccept:l,onRemove:c,onAddAt:u}){const d=C.useMemo(()=>({surface:e,row:t,slot:n}),[e,t,n]),f=C.useMemo(()=>i==null?void 0:i(d),[i,d]),h=lk(a?d:null,!1,f),g=C.useCallback(()=>{a&&r.length===0&&u&&u(KE(e,t,n))},[a,r.length,u,e,t,n]);return p.jsx(V,{ref:h,css:o.cell,onClick:g,...a&&r.length===0&&u?{"data-addable":""}:{},children:r.map(v=>p.jsx(aOn,{surface:e,person:t,day:n,shift:v,edit:a,styles:o,onSelect:s,onAccept:l,onRemove:c},v.key))})}const iOn=C.memo(function({value:t,storageKey:n}){const r=en({key:"roster"})(),a=t.mode.type==="edit",[o,i]=C.useState(()=>[...t.shifts]);C.useEffect(()=>{i([...t.shifts])},[t.shifts]);const s=C.useMemo(()=>_(t.onDrag),[t.onDrag]),l=C.useMemo(()=>_(t.canDrop),[t.canDrop]),c=kI(l),u=C.useMemo(()=>_(t.review),[t.review]),d=C.useMemo(()=>t.people.map(ue=>ue.approval),[t]),f=ok(u,d),h=en({key:"reviewChrome"}),g=C.useMemo(()=>h({}),[h]),v=C.useMemo(()=>{const ue={};for(const oe of["success","warning","danger","info","neutral"])ue[oe]=h({status:oe}).statusDot??{};return ue},[h]),b=C.useMemo(()=>_(t.onSelect),[t.onSelect]),y=C.useMemo(()=>_(t.onAccept),[t.onAccept]),x=C.useMemo(()=>_(t.onAddAt),[t.onAddAt]),S=C.useCallback((ue,oe)=>{if((ue.type==="add"||ue.type==="move")&&!t7(l,ue))return;let ve=o;if(ue.type==="add"){const{from:se,into:pe}=ue.value;ve=[...o,{key:`local:${se.library}:${se.key}:${pe.row}:${pe.slot}:${o.length}`,person:pe.row,day:pe.slot,label:(oe==null?void 0:oe.label)??se.key,state:$("proposed",$("added",null))}]}else if(ue.type==="move"){const{from:se,to:pe}=ue.value,de=se.event.type==="some"?se.event.value:void 0;ve=o.map(ge=>ge.key===de?{...ge,person:pe.row,day:pe.slot}:ge)}else if(ue.type==="remove"){const se=ue.value.from.event.type==="some"?ue.value.from.event.value:void 0;ve=o.filter(pe=>pe.key!==se)}i(ve),s&&queueMicrotask(()=>s(ue))},[o,s,l]),z=C.useMemo(()=>b?ue=>queueMicrotask(()=>b(ue)):void 0,[b]),M=C.useCallback(ue=>{const oe=ue.event.type==="some"?ue.event.value:void 0,ve=o.map(se=>se.key===oe&&se.state.type==="proposed"&&se.state.value.type==="model"?{...se,state:$("proposed",$("added",null))}:se);i(ve),y&&queueMicrotask(()=>y(ue))},[o,y]),L=C.useCallback(ue=>{const oe=ue.event.type==="some"?ue.event.value:void 0;if(i(o.filter(ve=>ve.key!==oe)),s){const ve=$("remove",{from:ue,to:$("trash",null)});queueMicrotask(()=>s(ve))}},[o,s]),R=C.useMemo(()=>x?ue=>queueMicrotask(()=>x(ue)):void 0,[x]),N=C.useMemo(()=>a?{id:t.id,sources:[...t.sources],kinds:{add:!0,move:!0,remove:!0},onDrag:S}:null,[a,t.id,t.sources,S]);sk(N);const O=C.useMemo(()=>{const ue=new Map;for(const oe of o){if(!a&&oe.state.type!=="committed")continue;const ve=N8e(oe.person,oe.day);ue.has(ve)||ue.set(ve,[]),ue.get(ve).push(oe)}return ue},[o,a]),j=_(t.summary),B=_(t.personWidth)??"150px",H=f!==void 0?` ${m6}`:"",K=`${B} repeat(${t.days.length}, minmax(${tOn}, 1fr))${H}`,U=`calc(${B} + ${t.days.length*KXe}px${H?` + ${m6}`:""})`,Z={gridTemplateColumns:K,minWidth:U},G=p.jsxs(V,{css:r.grid,style:Z,children:[p.jsx(V,{css:r.headerCell,children:t.personHeader}),t.days.map(ue=>p.jsx(V,{css:r.headerCell,children:ue},ue)),f!==void 0&&u!==void 0&&p.jsx(V,{css:g.decisionHeader,"data-slot":"decisionHeader",children:u.columnLabel})]}),W=ue=>{var oe;const ve=t.people[ue];if(ve===void 0)return null;const se=_(ve.sublabel),pe=f!==void 0?(oe=_(ve.status))==null?void 0:oe.type:void 0;return p.jsxs(V,{css:r.grid,style:Z,children:[p.jsxs(V,{css:r.personCell,children:[p.jsxs(V,{as:"span",css:r.personLabel,children:[pe!==void 0&&p.jsx(V,{as:"span",css:v[pe],"data-slot":"statusDot"}),ve.label]}),se&&p.jsx(V,{as:"span",css:r.personSublabel,children:se})]}),t.days.map(de=>p.jsx(oOn,{surface:t.id,person:ve.key,day:de,shifts:O.get(N8e(ve.key,de))??[],edit:a,styles:r,vetoFor:c,onSelect:z,onAccept:a?M:void 0,onRemove:a?L:void 0,onAddAt:R},`${ve.key}-${de}`)),f!==void 0&&p.jsx(V,{css:g.decisionCol,"data-slot":"decisionCol","data-status":pe,onClick:de=>de.stopPropagation(),children:p.jsx(SI,{rowIndex:ue,controller:f})})]})},J=j!==void 0||a?p.jsxs(V,{css:r.strip,children:[j!==void 0&&p.jsx(V,{as:"span",css:r.stripSummary,children:j}),a&&p.jsx(V,{as:"span",css:r.stripHint,children:"drag handles ⠿ · click empty cell to add · ✓ accept ghost · ⌫ remove"})]}):void 0,ae=Tt(_(t.height)),ne=Tt(_(t.maxHeight)),Y=f!==void 0&&f.showFoot,te=Y&&(ae!==void 0||ne!==void 0),ie=p.jsx(Dv,{height:te?void 0:ae,maxHeight:te?void 0:ne,fillParent:te,header:G,footer:J,count:t.people.length,estimateSize:()=>72,renderRow:W,rootCss:{...r.root}});return f!==void 0&&Y?p.jsxs(V,{display:"flex",flexDirection:"column",width:"100%",height:ae,maxHeight:ne,minHeight:"0",children:[ie,p.jsx(ik,{controller:f,storageKey:n})]}):ie},(e,t)=>eOn(e.value,t.value)&&e.storageKey===t.storageKey),sOn=it(kte.Types.Board),YXe=180,lOn=`${YXe}px`;function Jx(e,t,n,r){return{surface:e,row:t,slot:n,event:r!==void 0?P(r):A}}function cOn(e,t){return Sr(t.state,{committed:()=>e,rejected:()=>e,proposed:n=>Sr(n,{added:()=>`+${e}`,removed:()=>e,model:()=>`+${e}`})})}function Nie(e){return Sr(e.state,{committed:()=>"committed",rejected:()=>"rejected",proposed:t=>Sr(t,{added:()=>"added",removed:()=>"removed",model:()=>"model"})})}function uOn(e){const t=Nie(e);return t==="committed"||t==="added"}function dOn({surface:e,area:t,shift:n,assignment:r,label:a,edit:o,dragDisabled:i,styles:s,onSelect:l,onAccept:c,onRemove:u}){const d=Nie(r),f=d==="model",h=o&&!i&&(d==="added"||d==="removed"||d==="model"),g=C.useMemo(()=>({surface:e,row:t,slot:n,event:r.key}),[e,t,n,r.key]),v=C.useMemo(()=>p.jsx(V,{css:s.dragGhost,children:a}),[s.dragGhost,a]),b=CI(g,v,!h),y=C.useCallback(x=>{x.stopPropagation();const S=Jx(e,t,n,r.key);f&&c?c(S):l&&l(S)},[e,t,n,r.key,f,c,l]);return p.jsxs(V,{css:s.chip,"data-state":d,onPointerDown:b,onClick:y,...h&&b?{"data-draggable":""}:{},children:[h&&b&&p.jsx(V,{as:"span",css:s.chipGrip,"data-drag-grip":"",children:p.jsx(Ut,{icon:g5})}),cOn(a,r),f&&c&&p.jsx(V,{as:"button",css:s.chipAction,"aria-label":"Accept ghost assignment",onPointerDown:x=>x.stopPropagation(),onClick:x=>{x.stopPropagation(),c(Jx(e,t,n,r.key))},children:p.jsx(Ut,{icon:_$})}),h&&u&&p.jsx(V,{as:"button",css:s.chipAction,"data-danger":"","aria-label":"Remove assignment",onPointerDown:x=>x.stopPropagation(),onClick:x=>{x.stopPropagation(),u(Jx(e,t,n,r.key))},children:p.jsx(Ut,{icon:UC})})]})}function fOn({surface:e,area:t,shift:n,chips:r,required:a,maxVisible:o,edit:i,canDrop:s,styles:l,onSelect:c,onAccept:u,onRemove:d,onAddAt:f}){const h=C.useMemo(()=>({surface:e,row:t,slot:n}),[e,t,n]),g=lk(i?h:null,!1,s),[v,b]=C.useState(!1),y=r.filter(B=>uOn(B.assignment)).length,x=r.filter(B=>Nie(B.assignment)==="model").length,S=a!==void 0&&i?Math.max(0,a-y-x):0,z=a===void 0?void 0:y>a?"over":y===a?"ok":"under",M=o!==void 0&&r.length>o,L=M?r.slice(0,o):r,R=M?r.slice(o):[],N=C.useCallback(B=>{B.stopPropagation(),f&&f(Jx(e,t,n))},[f,e,t,n]),O=C.useCallback(()=>{i&&r.length===0&&S===0&&f&&f(Jx(e,t,n))},[i,r.length,S,f,e,t,n]),j=(B,H)=>p.jsx(dOn,{surface:e,area:t,shift:n,assignment:B.assignment,label:B.label,edit:i,...H!==void 0?{dragDisabled:H}:{},styles:l,onSelect:c,onAccept:u,onRemove:d},B.assignment.key);return p.jsxs(V,{ref:g,css:l.cell,onClick:O,...i&&r.length===0&&S===0&&f?{"data-addable":""}:{},children:[a!==void 0&&p.jsx(V,{css:l.coverage,children:p.jsxs(V,{as:"span",css:l.coverageCount,"data-tone":z,children:[y,"/",a]})}),L.map(B=>j(B)),M&&p.jsxs(nu,{open:v,onOpenChange:B=>b(B.open),positioning:{placement:"bottom-start"},lazyMount:!0,unmountOnExit:!0,children:[p.jsx(R6,{asChild:!0,children:p.jsxs(V,{as:"button",css:l.overflowChip,"aria-label":`${R.length} more assignments`,onClick:B=>B.stopPropagation(),children:["+",R.length]})}),p.jsx(go,{children:p.jsx(M4,{children:p.jsx(T4,{css:l.overflowContent,children:R.map(B=>j(B,!0))})})})]}),Array.from({length:S},(B,H)=>p.jsx(V,{as:"button",css:l.openSlot,"aria-label":"Open slot",onClick:N,children:"⊕"},`open-${H}`))]})}const pOn=C.memo(function({value:t,storageKey:n}){const r=en({key:"board"})(),a=t.mode.type==="edit",[o,i]=C.useState(()=>[...t.assignments]);C.useEffect(()=>{i([...t.assignments])},[t.assignments]);const[s,l]=C.useState(()=>new Map),c=C.useMemo(()=>_(t.onDrag),[t.onDrag]),u=C.useMemo(()=>_(t.canDrop),[t.canDrop]),d=kI(u),f=C.useMemo(()=>_(t.review),[t.review]),h=C.useMemo(()=>[],[]),g=ok(f,h),v=C.useMemo(()=>_(t.onSelect),[t.onSelect]),b=C.useMemo(()=>_(t.onAccept),[t.onAccept]),y=C.useMemo(()=>_(t.onAddAt),[t.onAddAt]),x=C.useMemo(()=>{const ye=new Map;for(const me of t.people)ye.set(me.key,me.label);return ye},[t.people]),S=C.useCallback(ye=>x.get(ye)??s.get(ye)??ye,[x,s]),z=C.useCallback((ye,me,Me,Te)=>o.some(Be=>Be.area===ye&&Be.shift===me&&Be.person===Me&&Be.key!==Te),[o]),M=C.useCallback(ye=>{if(ye.kind==="item")return{person:ye.from.key};const me=o.find(Me=>Me.key===ye.from.event);return me!==void 0?{person:me.person,excludeKey:me.key}:void 0},[o]),L=C.useCallback((ye,me)=>{const Me=d==null?void 0:d({surface:t.id,row:ye,slot:me});return Te=>{const Be=M(Te);return Be!==void 0&&z(ye,me,Be.person,Be.excludeKey)?!1:(Me==null?void 0:Me(Te))??!0}},[M,z,d,t.id]),R=C.useCallback((ye,me)=>{if(!((ye.type==="add"||ye.type==="move")&&!t7(u,ye))){if(ye.type==="add"){const{from:Me,into:Te}=ye.value;if(z(Te.row,Te.slot,Me.key))return;i([...o,{key:`local:${Me.library}:${Me.key}:${Te.row}:${Te.slot}:${o.length}`,person:Me.key,area:Te.row,shift:Te.slot,state:$("proposed",$("added",null))}]),(me==null?void 0:me.label)!==void 0&&!x.has(Me.key)&&l(Be=>new Map(Be).set(Me.key,me.label))}else if(ye.type==="move"){const{from:Me,to:Te}=ye.value,Be=Me.event.type==="some"?Me.event.value:void 0,ht=o.find(De=>De.key===Be);if(ht===void 0||z(Te.row,Te.slot,ht.person,ht.key))return;i(o.map(De=>De.key===Be?{...De,area:Te.row,shift:Te.slot}:De))}else if(ye.type==="remove"){const Me=ye.value.from.event.type==="some"?ye.value.from.event.value:void 0;i(o.filter(Te=>Te.key!==Me))}c&&queueMicrotask(()=>c(ye))}},[o,x,z,u,c]),N=C.useMemo(()=>v?ye=>queueMicrotask(()=>v(ye)):void 0,[v]),O=C.useCallback(ye=>{const me=ye.event.type==="some"?ye.event.value:void 0,Me=o.map(Te=>Te.key===me&&Te.state.type==="proposed"&&Te.state.value.type==="model"?{...Te,state:$("proposed",$("added",null))}:Te);i(Me),b&&queueMicrotask(()=>b(ye))},[o,b]),j=C.useCallback(ye=>{const me=ye.event.type==="some"?ye.event.value:void 0;if(i(o.filter(Me=>Me.key!==me)),c){const Me=$("remove",{from:ye,to:$("trash",null)});queueMicrotask(()=>c(Me))}},[o,c]),B=C.useMemo(()=>y?ye=>queueMicrotask(()=>y(ye)):void 0,[y]),H=C.useMemo(()=>a?{id:t.id,sources:[...t.sources],kinds:{add:!0,move:!0,remove:!0},onDrag:R}:null,[a,t.id,t.sources,R]);sk(H);const K=C.useMemo(()=>{const ye=new Map;for(const me of o){if(!a&&me.state.type!=="committed")continue;const Me=`${me.area} ${me.shift}`;ye.has(Me)||ye.set(Me,[]),ye.get(Me).push({assignment:me,label:S(me.person)})}return ye},[o,a,S]),U=C.useMemo(()=>{const ye=new Map,me=_(t.requirements);if(me!==void 0)for(const Me of me)ye.set(`${Me.area} ${Me.shift}`,Number(Me.required));return ye},[t.requirements]),Z=_(t.maxVisible),G=Z!==void 0?Number(Z):void 0,W=_(t.areaHeader),J=_(t.areaWidth)??"150px",ae=_(t.summary),ne=`${J} repeat(${t.shifts.length}, minmax(${lOn}, 1fr))`,Y=`calc(${J} + ${t.shifts.length*YXe}px)`,te={gridTemplateColumns:ne,minWidth:Y},ie=p.jsxs(V,{css:r.grid,style:te,children:[p.jsx(V,{css:r.headerCell,children:W}),t.shifts.map(ye=>{const me=_(ye.sublabel);return p.jsxs(V,{css:r.headerCell,children:[ye.label,me!==void 0&&p.jsx(V,{as:"span",css:r.headerSublabel,children:me})]},ye.key)})]}),ue=ye=>{const me=t.areas[ye];if(me===void 0)return null;const Me=_(me.sublabel);return p.jsxs(V,{css:r.grid,style:te,children:[p.jsxs(V,{css:r.areaCell,children:[p.jsx(V,{as:"span",css:r.areaLabel,children:me.label}),Me!==void 0&&p.jsx(V,{as:"span",css:r.areaSublabel,children:Me})]}),t.shifts.map(Te=>p.jsx(fOn,{surface:t.id,area:me.key,shift:Te.key,chips:K.get(`${me.key} ${Te.key}`)??[],required:U.get(`${me.key} ${Te.key}`),maxVisible:G,edit:a,canDrop:L(me.key,Te.key),styles:r,onSelect:N,onAccept:a?O:void 0,onRemove:a?j:void 0,onAddAt:B},`${me.key}-${Te.key}`))]})},oe=ae!==void 0?p.jsx(V,{css:r.strip,children:p.jsx(V,{as:"span",css:r.stripSummary,children:ae})}):void 0,ve=Tt(_(t.height)),se=Tt(_(t.maxHeight)),pe=g!==void 0&&g.showFoot,de=pe&&(ve!==void 0||se!==void 0),ge=p.jsx(Dv,{height:de?void 0:ve,maxHeight:de?void 0:se,fillParent:de,header:ie,footer:oe,count:t.areas.length,estimateSize:()=>80,renderRow:ue,rootCss:{...r.root}});return g!==void 0&&pe?p.jsxs(V,{display:"flex",flexDirection:"column",width:"100%",height:ve,maxHeight:se,minHeight:"0",children:[ge,p.jsx(ik,{controller:g,storageKey:n})]}):ge},(e,t)=>sOn(e.value,t.value)&&e.storageKey===t.storageKey),hOn=it($8.Types.Calendar),c8=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],$8e=8,I8e={comfortable:{H:46,gap:3,colLabel:54,colDay:"minmax(62px,1fr)",colTot:82,padX:18,padTop:18,padBottom:20},compact:{H:30,gap:2,colLabel:54,colDay:"minmax(46px,1fr)",colTot:78,padX:16,padTop:14,padBottom:16},condensed:{H:20,gap:2,colLabel:40,colDay:"34px",colTot:60,padX:16,padTop:12,padBottom:12}};function D8e(e,t){if(e.length===0)return null;switch(t){case"sum":return e.reduce((n,r)=>n+r,0);case"mean":return e.reduce((n,r)=>n+r,0)/e.length;case"min":return Math.min(...e);case"max":return Math.max(...e);case"count":return e.length;default:return null}}function HV(e){return Math.round(e).toLocaleString("en-US")}const gOn=C.memo(function({value:t}){var n;const r=al(),a=((n=_(t.density))==null?void 0:n.type)??r??"comfortable",o=I8e[a]??I8e.comfortable,i=en({key:"calendar"})({density:a}),s=N7(),l=C.useMemo(()=>_(t.plotGutter),[t.plotGutter]),c=(l?_(l.left):void 0)??(s==null?void 0:s.left),u=(l?_(l.right):void 0)??(s==null?void 0:s.right),d=c!==void 0||u!==void 0,f=t.values,h=d?void 0:_(t.totals),g=d?void 0:_(t.aggregateRow),v=d?void 0:_(t.footer),b=_(t.scale),y=b?_(b.ramp):void 0,x=b?Math.max(1,Number(b.steps)):$8e,S=y?y.length:$8e,z=C.useMemo(()=>_(t.onSelect),[t.onSelect]),M=C.useMemo(()=>_(t.onAction),[t.onAction]),L=d?void 0:_(t.actionLabel),R=_(t.domain),[N,O]=C.useState(null),[j,B]=C.useState(null),{weeks:H,cells:K,min:U,max:Z}=C.useMemo(()=>{const Dt=[],Et=new Map;let Gt=Number.POSITIVE_INFINITY,Ke=Number.NEGATIVE_INFINITY;for(const Se of t.cells)Dt.includes(Se.week)||Dt.push(Se.week),Et.set(`${Se.week} ${Se.day}`,Se),Se.value<Gt&&(Gt=Se.value),Se.value>Ke&&(Ke=Se.value);return R!==void 0&&(Gt=R.min,Ke=R.max),{weeks:Dt,cells:Et,min:Gt,max:Ke}},[t.cells,R]),G=C.useCallback(Dt=>{const Et=Z<=U?0:Math.max(0,Math.min(1,(Dt-U)/(Z-U))),Gt=x<=1?0:Math.max(0,Math.min(x-1,Math.round(Et*(x-1)))),Ke=x<=1?0:Math.max(0,Math.min(S-1,Math.round(Gt/(x-1)*(S-1)))),Se=y?y[Ke]:`var(--cal-r${Ke})`,Re=Ke>=Math.ceil(S/2)?"var(--cal-ink-hi)":"var(--cal-ink-lo)";return{bg:Se,fg:Re}},[U,Z,x,S,y]),W=v!==void 0||z!==void 0,J=C.useCallback((Dt,Et)=>{O({week:Dt,day:Et}),z&&queueMicrotask(()=>z({week:Dt,day:Et}))},[z]),ae=C.useCallback(()=>{N&&M&&queueMicrotask(()=>M(N))},[N,M]),ne=j??N,Y=Dt=>(ne==null?void 0:ne.day)===Dt,te=Dt=>(ne==null?void 0:ne.week)===Dt,ie=h?h.aggregate.type:void 0,ue=C.useMemo(()=>{if(ie===void 0)return{map:new Map,max:0};const Dt=new Map;let Et=0;for(const Gt of H){const Ke=[];for(const Re of c8){const qe=K.get(`${Gt} ${Re}`);qe&&Ke.push(qe.value)}const Se=D8e(Ke,ie);Dt.set(Gt,Se),Se!==null&&Se>Et&&(Et=Se)}return{map:Dt,max:Et}},[ie,H,K]),oe=g?g.aggregate.type:void 0,ve=C.useMemo(()=>{if(oe===void 0)return new Map;const Dt=new Map;for(const Et of c8){const Gt=[];for(const Ke of H){const Se=K.get(`${Ke} ${Et}`);Se&&Gt.push(Se.value)}Dt.set(Et,D8e(Gt,oe))}return Dt},[oe,H,K]),se=c??`${o.colLabel}px`,pe=u??"0px",de=d?`${se} repeat(${c8.length}, minmax(0, 1fr)) ${pe}`:`${o.colLabel}px repeat(${c8.length}, ${o.colDay})${h?` ${o.colTot}px`:""}`,ge=`${o.gap}px`,ye={display:"grid",gap:d?"0px":ge,...d?{paddingLeft:"0",paddingRight:"0"}:{paddingLeft:`${o.padX}px`,paddingRight:`${o.padX}px`}},me={...ye,paddingTop:ge},Me=d?{...i.cell,marginInline:`${o.gap/2}px`}:{...i.cell},Te=p.jsxs(V,{css:{...ye,paddingTop:`${o.padTop}px`},style:{gridTemplateColumns:de},children:[p.jsx(V,{}),c8.map(Dt=>p.jsx(V,{css:i.dayHeader,...Y(Dt)?{"data-active":""}:{},children:Dt.toUpperCase()},Dt)),h&&p.jsx(V,{css:i.totalsHeader,children:h.label}),d&&p.jsx(V,{"aria-hidden":"true"},"hdr-rpad")]}),Be=Dt=>{const Et=H[Dt];if(Et===void 0)return null;const Gt=h?ue.map.get(Et)??null:null,Ke=h&&Gt!==null&&ue.max>0?`${Math.max(10,Math.round(Gt/ue.max*100))}%`:"0%";return p.jsxs(V,{css:me,style:{gridTemplateColumns:de},children:[p.jsx(V,{css:i.weekLabel,...te(Et)?{"data-active":""}:{},children:Et}),c8.map(Se=>{const Re=K.get(`${Et} ${Se}`),qe=W&&(N==null?void 0:N.week)===Et&&N.day===Se,Ye=W&&(j==null?void 0:j.week)===Et&&j.day===Se,$e=Re!==void 0?G(Re.value):void 0;return p.jsx(V,{css:Me,height:`${o.H}px`,...Re===void 0?{"data-empty":""}:{},...!W&&Re!==void 0?{"data-static":""}:{},...qe?{"data-selected":""}:{},...Ye?{"data-hover":""}:{},...$e?{style:{background:$e.bg,color:$e.fg}}:{},onClick:W&&Re!==void 0?()=>J(Et,Se):void 0,onMouseEnter:W&&Re!==void 0?()=>B({week:Et,day:Se}):void 0,onMouseLeave:W&&Re!==void 0?()=>B(null):void 0,children:f?Re!==void 0?Re.text:"–":""},`${Et}-${Se}`)}),h&&p.jsxs(V,{css:i.totalsCell,children:[p.jsx(V,{as:"span",css:i.totalsValue,children:Gt!==null?HV(Gt):"·"}),h.bar&&p.jsx(V,{as:"span",css:i.totalsBar,children:p.jsx(V,{as:"span",css:i.totalsBarFill,style:{width:Ke}})})]}),d&&p.jsx(V,{"aria-hidden":"true"},`${Et}-rpad`)]})},ht=g?p.jsxs(V,{css:me,style:{gridTemplateColumns:de},children:[p.jsx(V,{css:i.meanLabel,children:g.label}),c8.map(Dt=>{const Et=ve.get(Dt)??null;return p.jsx(V,{css:i.meanCell,...Y(Dt)?{"data-active":""}:{},children:Et!==null?HV(Et):"·"},`mean-${Dt}`)}),h&&p.jsx(V,{css:i.meanPad})]}):null,De=N?K.get(`${N.week} ${N.day}`):void 0,Qe=De?_(De.compare):void 0,bt=De?_(De.summary):void 0,Ve=De!==void 0&&Qe!==void 0&&Qe!==0?Math.round((De.value/Qe-1)*100):void 0,ut=Ve===void 0?"flat":Ve>0?"up":Ve<0?"down":"flat",_t=Ve===void 0?"":`${Ve>0?"▲ +":Ve<0?"▼ ":"– "}${Math.abs(Ve)}%`,Ft=v!==void 0||L!==void 0,wt=v?_(v.legend):void 0,Lt=Ft?p.jsxs(V,{css:i.footer,paddingTop:"13px",paddingX:"2px",paddingBottom:"2px",children:[De!==void 0&&v!==void 0?p.jsxs(p.Fragment,{children:[p.jsx(V,{as:"span",css:i.footerLead,children:"Selected ·"}),p.jsxs(V,{as:"span",css:i.footerSel,children:[N.day," ",N.week]}),p.jsx(V,{as:"span",color:"border.strong",children:"·"}),p.jsxs(V,{as:"span",children:[v.valueLabel," ",p.jsx(V,{as:"span",css:i.footerValue,children:De.text})]}),Qe!==void 0&&p.jsxs(p.Fragment,{children:[p.jsx(V,{as:"span",color:"border.strong",children:"·"}),p.jsxs(V,{as:"span",children:[v.compareLabel," ",p.jsx(V,{as:"span",css:i.footerValue,children:HV(Qe)})]})]}),bt!==void 0&&p.jsxs(p.Fragment,{children:[p.jsx(V,{as:"span",color:"border.strong",children:"·"}),p.jsx(V,{as:"span",children:bt})]}),Ve!==void 0&&p.jsx(V,{as:"span",css:i.deltaChip,"data-dir":ut,children:_t})]}):p.jsx(V,{as:"span",css:i.footerLead,children:"Selected · none — pick a day"}),L!==void 0&&p.jsxs(V,{as:"button",css:i.action,marginLeft:wt!==void 0?void 0:"auto",onClick:ae,...N===null?{"data-disabled":""}:{},children:[L," →"]}),wt!==void 0&&p.jsxs(V,{as:"span",css:i.legend,children:[p.jsx(V,{as:"span",css:i.legendCap,children:wt.low}),p.jsx(V,{as:"span",css:i.legendGradient}),p.jsx(V,{as:"span",css:i.legendCap,children:wt.high})]})]}):void 0,Jt=ht!==null||Lt!==void 0?p.jsxs(p.Fragment,{children:[ht,Lt]}):void 0;return p.jsx(Dv,{height:Tt(_(t.height)),maxHeight:Tt(_(t.maxHeight)),header:Te,footer:Jt,count:H.length,estimateSize:()=>o.H+o.gap,renderRow:Be,rootCss:{...i.root,paddingBottom:`${o.padBottom}px`,...d?{display:"block",width:"100%"}:{}}})},(e,t)=>hOn(e.value,t.value)&&e.storageKey===t.storageKey);function XXe(e,t,n=0,r=e.length-1,a=mOn){for(;r>n;){if(r-n>600){const l=r-n+1,c=t-n+1,u=Math.log(l),d=.5*Math.exp(2*u/3),f=.5*Math.sqrt(u*d*(l-d)/l)*(c-l/2<0?-1:1),h=Math.max(n,Math.floor(t-c*d/l+f)),g=Math.min(r,Math.floor(t+(l-c)*d/l+f));XXe(e,t,h,g,a)}const o=e[t];let i=n,s=r;for(xb(e,n,t),a(e[r],o)>0&&xb(e,n,r);i<s;){for(xb(e,i,s),i++,s--;a(e[i],o)<0;)i++;for(;a(e[s],o)>0;)s--}a(e[n],o)===0?xb(e,n,s):(s++,xb(e,s,r)),s<=t&&(n=s+1),t<=s&&(r=s-1)}}function xb(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function mOn(e,t){return e<t?-1:e>t?1:0}class ZXe{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let n=this.data;const r=[];if(!uT(t,n))return r;const a=this.toBBox,o=[];for(;n;){for(let i=0;i<n.children.length;i++){const s=n.children[i],l=n.leaf?a(s):s;uT(t,l)&&(n.leaf?r.push(s):UV(t,l)?this._all(s,r):o.push(s))}n=o.pop()}return r}collides(t){let n=this.data;if(!uT(t,n))return!1;const r=[];for(;n;){for(let a=0;a<n.children.length;a++){const o=n.children[a],i=n.leaf?this.toBBox(o):o;if(uT(t,i)){if(n.leaf||UV(t,i))return!0;r.push(o)}}n=r.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let r=0;r<t.length;r++)this.insert(t[r]);return this}let n=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=n;else if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){const r=this.data;this.data=n,n=r}this._insert(n,this.data.height-n.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=Rg([]),this}remove(t,n){if(!t)return this;let r=this.data;const a=this.toBBox(t),o=[],i=[];let s,l,c;for(;r||o.length;){if(r||(r=o.pop(),l=o[o.length-1],s=i.pop(),c=!0),r.leaf){const u=vOn(t,r.children,n);if(u!==-1)return r.children.splice(u,1),o.push(r),this._condense(o),this}!c&&!r.leaf&&UV(r,a)?(o.push(r),i.push(s),s=0,l=r,r=r.children[0]):l?(s++,r=l.children[s],c=!1):r=null}return this}toBBox(t){return t}compareMinX(t,n){return t.minX-n.minX}compareMinY(t,n){return t.minY-n.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,n){const r=[];for(;t;)t.leaf?n.push(...t.children):r.push(...t.children),t=r.pop();return n}_build(t,n,r,a){const o=r-n+1;let i=this._maxEntries,s;if(o<=i)return s=Rg(t.slice(n,r+1)),Kh(s,this.toBBox),s;a||(a=Math.ceil(Math.log(o)/Math.log(i)),i=Math.ceil(o/Math.pow(i,a-1))),s=Rg([]),s.leaf=!1,s.height=a;const l=Math.ceil(o/i),c=l*Math.ceil(Math.sqrt(i));O8e(t,n,r,c,this.compareMinX);for(let u=n;u<=r;u+=c){const d=Math.min(u+c-1,r);O8e(t,u,d,l,this.compareMinY);for(let f=u;f<=d;f+=l){const h=Math.min(f+l-1,d);s.children.push(this._build(t,f,h,a-1))}}return Kh(s,this.toBBox),s}_chooseSubtree(t,n,r,a){for(;a.push(n),!(n.leaf||a.length-1===r);){let o=1/0,i=1/0,s;for(let l=0;l<n.children.length;l++){const c=n.children[l],u=WV(c),d=xOn(t,c)-u;d<i?(i=d,o=u<o?u:o,s=c):d===i&&u<o&&(o=u,s=c)}n=s||n.children[0]}return n}_insert(t,n,r){const a=r?t:this.toBBox(t),o=[],i=this._chooseSubtree(a,this.data,n,o);for(i.children.push(t),hx(i,a);n>=0&&o[n].children.length>this._maxEntries;)this._split(o,n),n--;this._adjustParentBBoxes(a,o,n)}_split(t,n){const r=t[n],a=r.children.length,o=this._minEntries;this._chooseSplitAxis(r,o,a);const i=this._chooseSplitIndex(r,o,a),s=Rg(r.children.splice(i,r.children.length-i));s.height=r.height,s.leaf=r.leaf,Kh(r,this.toBBox),Kh(s,this.toBBox),n?t[n-1].children.push(s):this._splitRoot(r,s)}_splitRoot(t,n){this.data=Rg([t,n]),this.data.height=t.height+1,this.data.leaf=!1,Kh(this.data,this.toBBox)}_chooseSplitIndex(t,n,r){let a,o=1/0,i=1/0;for(let s=n;s<=r-n;s++){const l=px(t,0,s,this.toBBox),c=px(t,s,r,this.toBBox),u=wOn(l,c),d=WV(l)+WV(c);u<o?(o=u,a=s,i=d<i?d:i):u===o&&d<i&&(i=d,a=s)}return a||r-n}_chooseSplitAxis(t,n,r){const a=t.leaf?this.compareMinX:yOn,o=t.leaf?this.compareMinY:bOn,i=this._allDistMargin(t,n,r,a),s=this._allDistMargin(t,n,r,o);i<s&&t.children.sort(a)}_allDistMargin(t,n,r,a){t.children.sort(a);const o=this.toBBox,i=px(t,0,n,o),s=px(t,r-n,r,o);let l=cT(i)+cT(s);for(let c=n;c<r-n;c++){const u=t.children[c];hx(i,t.leaf?o(u):u),l+=cT(i)}for(let c=r-n-1;c>=n;c--){const u=t.children[c];hx(s,t.leaf?o(u):u),l+=cT(s)}return l}_adjustParentBBoxes(t,n,r){for(let a=r;a>=0;a--)hx(n[a],t)}_condense(t){for(let n=t.length-1,r;n>=0;n--)t[n].children.length===0?n>0?(r=t[n-1].children,r.splice(r.indexOf(t[n]),1)):this.clear():Kh(t[n],this.toBBox)}}function vOn(e,t,n){if(!n)return t.indexOf(e);for(let r=0;r<t.length;r++)if(n(e,t[r]))return r;return-1}function Kh(e,t){px(e,0,e.children.length,t,e)}function px(e,t,n,r,a){a||(a=Rg(null)),a.minX=1/0,a.minY=1/0,a.maxX=-1/0,a.maxY=-1/0;for(let o=t;o<n;o++){const i=e.children[o];hx(a,e.leaf?r(i):i)}return a}function hx(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function yOn(e,t){return e.minX-t.minX}function bOn(e,t){return e.minY-t.minY}function WV(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function cT(e){return e.maxX-e.minX+(e.maxY-e.minY)}function xOn(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function wOn(e,t){const n=Math.max(e.minX,t.minX),r=Math.max(e.minY,t.minY),a=Math.min(e.maxX,t.maxX),o=Math.min(e.maxY,t.maxY);return Math.max(0,a-n)*Math.max(0,o-r)}function UV(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function uT(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function Rg(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function O8e(e,t,n,r,a){const o=[t,n];for(;o.length;){if(n=o.pop(),t=o.pop(),n-t<=r)continue;const i=t+Math.ceil((n-t)/r/2)*r;XXe(e,i,t,n,a),o.push(t,i,i,n)}}const YE={zoom:1,tx:0,ty:0};function SOn(e,t,n){return{sx:e*n.ppu+n.tx,sy:t*n.ppu+n.ty}}function COn(e,t){return`translate(calc(var(--cam-ppu) * ${e} * 1px + var(--cam-tx)), calc(var(--cam-ppu) * ${t} * 1px + var(--cam-ty)))`}function kOn(e){return`calc(var(--cam-ppu) * ${e} * 1px)`}function QXe(e,t,n){return{minX:-e.tx/e.ppu,minY:-e.ty/e.ppu,maxX:(t-e.tx)/e.ppu,maxY:(n-e.ty)/e.ppu}}function qV(e,t){return e.maxX>=t.minX&&e.minX<=t.maxX&&e.maxY>=t.minY&&e.minY<=t.maxY}function rX(e){if(e.length===0)return null;let t=1/0,n=1/0,r=-1/0,a=-1/0;for(const o of e)o.x<t&&(t=o.x),o.y<n&&(n=o.y),o.x>r&&(r=o.x),o.y>a&&(a=o.y);return{minX:t,minY:n,maxX:r,maxY:a}}function GV(e,t,n,r,a,o){const i=Math.max(a,Math.min(o,e.zoom*t));if(i===1)return YE;const s=i/e.zoom;return{zoom:i,tx:n-s*(n-e.tx),ty:r-s*(r-e.ty)}}function zOn(e,t){switch(t){case"pointerDown":return"panning";case"wheel":return"wheeling";case"zoom":return"wheeling";case"flyStart":return"flying";case"pointerUp":return e==="panning"?"idle":e;case"flyEnd":return e==="flying"?"idle":e;case"cancel":return"idle"}}function MOn(e,t){return e==="flying"&&(t==="pointerDown"||t==="wheel"||t==="zoom"||t==="cancel")}function TOn(e,t){let n=null;return{request(r){n===null&&(n=e(()=>{n=null,r()}))},cancel(){n!==null&&(t(n),n=null)}}}const ba=(e,t=1)=>t>=1?`rgb(${e[0]},${e[1]},${e[2]})`:`rgba(${e[0]},${e[1]},${e[2]},${t})`;function XE(e,t,n){switch(t){case"brand":return e.brand600;case"ink":return e.fg;case"muted":return n==="zone"?e.borderStrong:e.fgMuted;case"success":return e.statusOk;case"warning":return e.statusWarn;case"danger":return e.statusBad;default:return e.fgMuted}}function j8e(e,t){switch(t){case"success":return e.statusOk;case"warning":return e.statusWarn;case"danger":return e.statusBad;case"info":return e.brand500;default:return e.fgMuted}}function F8e(e){return e.type==="some"?e.value.type:void 0}function KV(e,t,n,r,a){return t!==void 0?t:ba(n!==void 0?XE(e,n,a):r)}function O8(e){const t=[];for(const n of e){const r=t[t.length-1];r!==void 0&&r.x!==n.x&&r.y!==n.y&&t.push(Math.abs(n.y-r.y)>=Math.abs(n.x-r.x)?{x:r.x,y:n.y}:{x:n.x,y:r.y}),(r===void 0||r.x!==n.x||r.y!==n.y)&&t.push(n)}return t}function Yl(e,t,n){if(t.length===0)return;e.moveTo(t[0].x,t[0].y);for(let a=1;a<t.length-1;a++){const o=t[a],i=t[a-1],s=t[a+1],l=Math.hypot(o.x-i.x,o.y-i.y),c=Math.hypot(s.x-o.x,s.y-o.y),u=Math.min(n,l/2,c/2);if(u<.5){e.lineTo(o.x,o.y);continue}const d={x:(o.x-i.x)/l,y:(o.y-i.y)/l};e.lineTo(o.x-d.x*u,o.y-d.y*u),e.quadraticCurveTo(o.x,o.y,o.x+(s.x-o.x)/c*u,o.y+(s.y-o.y)/c*u)}const r=t[t.length-1];t.length>1&&e.lineTo(r.x,r.y)}function EOn(e,t,n){const r=t.x-e.x,a=t.y-e.y,o=Math.hypot(r,a);if(Math.abs(n)<1e-4||o<1e-9)return null;const i=4*Math.atan(n),s=Math.abs(o/(2*Math.sin(i/2))),l=(e.x+t.x)/2,c=(e.y+t.y)/2,u=o/2/Math.tan(i/2),d=l-a/o*u,f=c+r/o*u;return!Number.isFinite(s)||!Number.isFinite(u)||!Number.isFinite(d)||!Number.isFinite(f)?null:{cx:d,cy:f,radius:s,startAngle:Math.atan2(e.y-f,e.x-d),endAngle:Math.atan2(t.y-f,t.x-d),anticlockwise:i<0}}function B8e(e,t,n,r){const a=EOn(t,n,r);if(a===null){e.lineTo(n.x,n.y);return}e.arc(a.cx,a.cy,a.radius,a.startAngle,a.endAngle,a.anticlockwise)}function wb(e,t,n){if(t.length!==0){e.moveTo(t[0].x,t[0].y);for(let r=1;r<t.length;r++)B8e(e,t[r-1],t[r],t[r-1].bulge);if(n){const r=t[t.length-1];B8e(e,r,t[0],r.bulge),e.closePath()}}}const $ie='600 10px ui-monospace, "SF Mono", Menlo, monospace',_On=5,LOn=10,gR=6,ZE=7,JXe=4,V8e=16;function eZe(e,t,n,r){const{sx:a,sy:o}=SOn(e.x,e.y,n);if(t==="dot")return{kind:"circle",cx:a,cy:o,r:LOn};const i=r(e.label),s=gR+ZE+JXe+i+gR;return{kind:"rect",left:a-s/2,top:o-V8e/2,w:s,h:V8e}}function ROn(e,t,n){return e.kind==="circle"?Math.hypot(t-e.cx,n-e.cy)<=e.r:t>=e.left&&t<=e.left+e.w&&n>=e.top&&n<=e.top+e.h}const YV=5;function XV(e,t,n){let r=1/0;for(let a=1;a<e.length;a++){const o=e[a-1],i=e[a],s=i.x-o.x,l=i.y-o.y,c=s*s+l*l,u=c>0?Math.max(0,Math.min(1,((t-o.x)*s+(n-o.y)*l)/c)):0,d=Math.hypot(t-(o.x+u*s),n-(o.y+u*l));d<r&&(r=d)}return r}const H8e=16,tZe=7;function POn(e){if(e.length===0)return{x:0,y:0};let t=0;for(let a=1;a<e.length;a++)t+=Math.hypot(e[a].x-e[a-1].x,e[a].y-e[a-1].y);if(t<=1e-9)return e[0];let n=0;const r=t/2;for(let a=1;a<e.length;a++){const o=Math.hypot(e[a].x-e[a-1].x,e[a].y-e[a-1].y);if(n+o>=r){const i=o>0?(r-n)/o:0;return{x:e[a-1].x+(e[a].x-e[a-1].x)*i,y:e[a-1].y+(e[a].y-e[a-1].y)*i}}n+=o}return e[e.length-1]}function nZe(e,t){const n=new Map;for(const a of e){if(!t(a))continue;const o=a.from<a.to?`${a.from}\0${a.to}`:`${a.to}\0${a.from}`,i=n.get(o);i!==void 0?i.push(a.key):n.set(o,[a.key])}const r=new Map;for(const a of n.values())a.length<2||(a.sort(),a.forEach((o,i)=>r.set(o,{i,n:a.length})));return r}function AOn(e){return Number.isFinite(e)?Math.max(1,e):1}function NOn(e,t,n,r,a,o,i,s,l,c){const u=-s,d=i;if(Math.abs(u)<=1e-6)return{oStart:-l,oEnd:l};const f=Math.max(e,0),h=Math.max(t,0),g=Math.min(e+n,a),v=Math.min(t+r,o),b=[f*u+h*d,g*u+h*d,f*u+v*d,g*u+v*d],y=z=>(z-e*u-(t-l*s)*d)/u,x=y(Math.min(...b)),S=y(Math.max(...b));return{oStart:Math.max(-l,-l+Math.floor((Math.min(x,S)+l)/c)*c-c),oEnd:Math.min(l,Math.max(x,S)+c)}}function $On(e,t){const n={minX:e.x,minY:e.y,maxX:e.x+e.width,maxY:e.y+e.height};if(t!==void 0&&t.type==="circle"){const r=e.x+e.width/2,a=e.y+e.height/2,o=t.value.radius;n.minX=Math.min(n.minX,r-o),n.minY=Math.min(n.minY,a-o),n.maxX=Math.max(n.maxX,r+o),n.maxY=Math.max(n.maxY,a+o)}else if(t!==void 0&&t.type!=="rect"){const r=rX(t.value.vertices);r!==null&&(n.minX=Math.min(n.minX,r.minX),n.minY=Math.min(n.minY,r.minY),n.maxX=Math.max(n.maxX,r.maxX),n.maxY=Math.max(n.maxY,r.maxY))}return n}function W8e(e,t){const n={x:e.reduce((L,R)=>L+R.x,0)/e.length,y:e.reduce((L,R)=>L+R.y,0)/e.length};if(e.length===1)return{anchor:e[0],stubs:[],taps:[]};const r=Math.min(...e.map(L=>L.x)),a=Math.max(...e.map(L=>L.x)),o=Math.min(...e.map(L=>L.y)),i=Math.max(...e.map(L=>L.y)),s=i-o>=a-r,l=L=>s?L.y:L.x,c=L=>s?L.x:L.y,u=(L,R)=>s?{x:R,y:L}:{x:L,y:R},d=s?o:r,f=s?i:a;if(f-d<1e-6)return{anchor:n,stubs:[],taps:[]};const h=Math.sign(c(t)-c(n))||1,g=h>0?Math.max(...e.map(c)):Math.min(...e.map(c)),v=Math.abs(c(t)-g),b=g+h*Math.min(Math.max(v*.3,.9),3),y=u(Math.min(Math.max(l(t),d),f),b),x=e.map(L=>[L,u(l(L),b)]),S=L=>L-d<1e-6||f-L<1e-6,z=[],M=L=>{S(l(L))||z.some(R=>Math.abs(R.x-L.x)<1e-6&&Math.abs(R.y-L.y)<1e-6)||z.push(L)};for(const L of x)M(L[1]);return M(y),{anchor:y,bar:[u(d,b),u(f,b)],stubs:x,taps:z}}function aX(e,t,n){const r=c=>({x:c.reduce((u,d)=>u+d.x,0)/c.length,y:c.reduce((u,d)=>u+d.y,0)/c.length}),a=n.length>0?n[0]:r(t),o=n.length>0?n[n.length-1]:r(e),i=W8e(e,a),s=W8e(t,o),l=[];return i.bar&&l.push(i.bar),s.bar&&l.push(s.bar),{trunk:[i.anchor,...n,s.anchor],bars:l,stubs:[...i.stubs,...s.stubs],taps:[...i.taps,...s.taps]}}function U8e(e,t,n,r,a){var o;if(r===void 0&&a===void 0)return;const i=POn(n);e.save(),e.font=$ie;const s=r??"",l=a!==void 0?r!==void 0?` · ${a}`:a:"",c=s!==""?e.measureText(s).width:0,u=l!==""?e.measureText(l).width:0,d=c+u+12,f=16,h=i.x-d/2,g=i.y-f/2;e.beginPath(),(o=e.roundRect)==null||o.call(e,h,g,d,f,f/2),e.roundRect||e.rect(h,g,d,f),e.fillStyle=ba(t.bgSurface),e.fill(),e.lineWidth=1,e.strokeStyle=ba(t.borderSubtle),e.stroke(),e.textBaseline="middle",s!==""&&(e.fillStyle=ba(t.fg),e.fillText(s,h+6,i.y)),l!==""&&(e.fillStyle=ba(t.fgMuted),e.fillText(l,h+6+c,i.y)),e.restore()}function IOn(e){var t,n,r,a;const{ctx:o,value:i,cam:s,width:l,height:c,visibleItems:u,tiers:d,selected:f,selectedZones:h,centers:g,palette:v,effect:b,layerHiddenKeys:y,layerAlpha:x,draftLink:S,session:z,connectFlash:M,selectedLink:L}=e,R=W=>W*s.ppu+s.tx,N=W=>W*s.ppu+s.ty,O=s.ppu,j=W=>(b==null?void 0:b.excluded.has(W))??!1,B=W=>(y==null?void 0:y.has(W))??!1,H=W=>(b!==void 0&&j(W)?b.excludedOpacity:1)*((x==null?void 0:x.get(W))??1),K=W=>b!==void 0&&j(W)&&b.excludedDesaturate,U=QXe(s,l,c);o.save(),o.setTransform(1,0,0,1,0,0),o.clearRect(0,0,o.canvas.width,o.canvas.height),o.restore(),o.lineJoin="round";for(const W of i.zones){if(B(W.key))continue;const J=_(W.geometry);if(!qV($On(W,J),U))continue;const ae=W.pattern,ne=(ae.value.tone.type==="some"?ae.value.tone.value.type:void 0)??"muted",Y=KV(v,_(W.color),(t=_(W.tone))==null?void 0:t.type,XE(v,ne,"zone"),"zone"),te=_(W.bg),ie=_(W.fillOpacity)??.15,ue=_(W.weight),oe=R(W.x),ve=N(W.y),se=W.width*O,pe=W.height*O,de=()=>{te!==void 0&&(o.save(),o.globalAlpha=ie,o.fillStyle=te,o.fill(),o.restore())};if(J!==void 0&&J.type!=="rect")if(J.type==="circle")o.beginPath(),o.arc(oe+se/2,ve+pe/2,J.value.radius*O,0,Math.PI*2),de(),o.setLineDash([4,3]),o.lineWidth=ue??1,o.strokeStyle=Y,o.stroke(),o.setLineDash([]);else{const ge=J.value.vertices.map(ye=>({x:R(ye.x),y:N(ye.y),bulge:ye.bulge}));if(ge.length>0)if(o.beginPath(),J.type==="polygon")wb(o,ge,!0),de(),o.setLineDash([4,3]),o.lineWidth=ue??1,o.strokeStyle=Y,o.stroke(),o.setLineDash([]);else{wb(o,ge,!1);const ye=J.value.width.type==="some"?J.value.width.value*O:void 0;o.setLineDash([]),o.lineCap="round",o.lineWidth=ue??ye??1.5,o.save(),o.globalAlpha=.55,o.strokeStyle=Y,o.stroke(),o.restore(),o.lineCap="butt"}}else if(ae.type==="hatch"){const ge=AOn(_(ae.value.spacing)??8),ye=(_(ae.value.angle)??45)*Math.PI/180;o.save(),o.beginPath(),o.rect(oe,ve,se,pe),o.clip(),te!==void 0&&(o.save(),o.globalAlpha=ie,o.fillStyle=te,o.fillRect(oe,ve,se,pe),o.restore()),o.globalAlpha=.3,o.strokeStyle=Y,o.lineWidth=ue??1;const me=Math.cos(ye),Me=Math.sin(ye),Te=Math.hypot(se,pe),{oStart:Be,oEnd:ht}=NOn(oe,ve,se,pe,l,c,me,Me,Te,ge);o.beginPath();for(let De=Be;De<ht;De+=ge)o.moveTo(oe+De,ve-Te*Me),o.lineTo(oe+De+me*2*Te,ve-Te*Me+Me*2*Te);o.stroke(),o.restore()}else te!==void 0&&(o.save(),o.globalAlpha=ie,o.fillStyle=te,o.fillRect(oe,ve,se,pe),o.restore()),o.setLineDash([5,4]),o.lineWidth=ue??1,o.strokeStyle=Y,o.strokeRect(oe,ve,se,pe),o.setLineDash([]);if(((h==null?void 0:h.has(W.key))??!1)&&(o.save(),o.beginPath(),J!==void 0&&J.type==="circle"?o.arc(oe+se/2,ve+pe/2,J.value.radius*O,0,Math.PI*2):J!==void 0&&J.type==="polygon"?wb(o,J.value.vertices.map(ge=>({x:R(ge.x),y:N(ge.y),bulge:ge.bulge})),!0):o.rect(oe,ve,se,pe),o.globalAlpha=.06,o.fillStyle=ba(v.brand500),o.fill(),o.globalAlpha=1,o.setLineDash([]),o.lineWidth=2,o.strokeStyle=ba(v.brand600),o.stroke(),o.restore()),se>=W.label.length*6.2+24){o.font='600 9px ui-monospace, "SF Mono", Menlo, monospace';const ge=W.label.toUpperCase(),ye=o.measureText(ge).width;o.fillStyle=ba(v.bgPanel),o.fillRect(oe+6,ve-7,ye+6,12),o.fillStyle=ba(v.fgMuted),o.textBaseline="middle",o.fillText(ge,oe+9,ve)}}const Z=nZe(i.links,W=>!B(W.key)&&g.has(W.from)&&g.has(W.to)&&W.via.length===0);for(const W of i.links){if(B(W.key))continue;const J=g.get(W.from),ae=g.get(W.to);if(!J||!ae)continue;const ne=rX([J,...W.via,ae]);if(ne!==null&&!qV(ne,U))continue;const Y=[J,...W.via,ae].map(de=>({x:R(de.x),y:N(de.y)})),te=Z.get(W.key);if(te!==void 0){const de=Y[0],ge=Y[Y.length-1],ye=Math.hypot(ge.x-de.x,ge.y-de.y);if(ye>1e-6){const me=(te.i-(te.n-1)/2)*tZe,Me=-(ge.y-de.y)/ye*me,Te=(ge.x-de.x)/ye*me;for(const Be of Y)Be.x+=Me,Be.y+=Te}}const ie=W.route.type==="orthogonal"?W.route.value.corner.type==="some"?W.route.value.corner.value:8:0,ue=W.route.type==="orthogonal"?O8(Y):Y,oe=W.style,ve=(oe.value.tone.type==="some"?oe.value.tone.value.type:void 0)??(oe.type==="solid"?"brand":"muted"),se=oe.value.weight.type==="some"?oe.value.weight.value:oe.type==="solid"?2.5:1.5,pe=XE(v,ve,"link");if(o.lineCap="round",o.strokeStyle=ba(pe),o.lineWidth=se,o.setLineDash(oe.type==="dashed"?[6,5]:[]),o.beginPath(),Yl(o,ue,ie),o.stroke(),o.setLineDash([]),L!==void 0&&L.key===W.key){if(o.save(),o.lineWidth=se+4,o.strokeStyle=ba(v.brand600,.25),o.beginPath(),Yl(o,ue,ie),o.stroke(),L.editable)for(const de of[ue[0],ue[ue.length-1]])o.beginPath(),o.arc(de.x,de.y,5,0,Math.PI*2),o.fillStyle=ba(v.bgSurface),o.fill(),o.lineWidth=2,o.strokeStyle=ba(v.brand600),o.stroke();o.restore()}o.fillStyle=ba(pe);for(const de of[Y[0],Y[Y.length-1]])o.beginPath(),o.arc(de.x,de.y,se+1.5,0,Math.PI*2),o.fill();O>=H8e&&U8e(o,v,ue,_(W.label),_(W.metric)),o.lineCap="butt"}for(const W of i.nets){if(B(W.key))continue;const J=W.sources.filter(Te=>g.has(Te)),ae=W.destinations.filter(Te=>g.has(Te)),ne=J.map(Te=>g.get(Te)),Y=ae.map(Te=>g.get(Te));if(ne.length===0||Y.length===0)continue;const te=rX([...ne,...W.via,...Y]);if(te!==null&&!qV(te,U))continue;const ie=W.style,ue=(ie.value.tone.type==="some"?ie.value.tone.value.type:void 0)??(ie.type==="solid"?"brand":"muted"),oe=ie.value.weight.type==="some"?ie.value.weight.value:ie.type==="solid"?2.5:1.5,ve=W.route.type==="orthogonal"?W.route.value.corner.type==="some"?W.route.value.corner.value:8:0,se=XE(v,ue,"link"),pe=Te=>({x:R(Te.x),y:N(Te.y)}),de=Te=>{const Be=Te.map(pe);return W.route.type==="orthogonal"?O8(Be):Be},ge=L!==void 0&&L.key===W.key,ye=aX(ne,Y,W.via);o.save(),o.lineCap="round",o.setLineDash(ie.type==="dashed"?[6,5]:[]);const me=de(ye.trunk);o.strokeStyle=ba(se),o.lineWidth=oe+1,o.beginPath(),Yl(o,me,ve),o.stroke();for(const Te of ye.bars)o.beginPath(),Yl(o,Te.map(pe),0),o.stroke();o.lineWidth=oe;for(const Te of ye.stubs)o.beginPath(),Yl(o,Te.map(pe),ve),o.stroke();o.setLineDash([]),o.fillStyle=ba(se);for(const Te of ye.taps.map(pe))o.beginPath(),o.arc(Te.x,Te.y,oe+1.5,0,Math.PI*2),o.fill();const Me=ge?L==null?void 0:L.leg:void 0;if(ge&&Me===void 0){o.lineWidth=oe+5,o.strokeStyle=ba(v.brand600,.25),o.beginPath(),Yl(o,me,ve),o.stroke();for(const Te of ye.bars)o.beginPath(),Yl(o,Te.map(pe),0),o.stroke()}else if(Me!==void 0){const Te=Me.end==="source"?J.indexOf(Me.item):ae.indexOf(Me.item),Be=Te>=0?ye.stubs[Me.end==="source"?Te:J.length+Te]:void 0;Be!==void 0&&(o.lineWidth=oe+5,o.strokeStyle=ba(v.brand600,.35),o.beginPath(),Yl(o,Be.map(pe),ve),o.stroke())}O>=H8e&&U8e(o,v,me,_(W.label),_(W.metric)),o.lineCap="butt",o.restore()}const G=(W,J)=>O8([{x:R(W.x),y:N(W.y)},{x:R(J.x),y:N(J.y)}]);if(z!==void 0){if(o.save(),o.lineCap="round",o.setLineDash([6,5]),o.lineWidth=2,o.strokeStyle=ba(v.brand500,.75),z.kind==="edge")o.beginPath(),Yl(o,G(z.from,z.to),8),o.stroke();else{const W=aX(z.sources,z.destinations,[]),J=ae=>({x:R(ae.x),y:N(ae.y)});o.beginPath(),Yl(o,O8(W.trunk.map(J)),8),o.stroke();for(const ae of W.bars)o.beginPath(),Yl(o,ae.map(J),0),o.stroke();for(const ae of W.stubs)o.beginPath(),Yl(o,O8(ae.map(J)),8),o.stroke()}o.restore()}if(S!==void 0){const W=S.forbiddenKey!==void 0,J=W?v.statusBad:v.brand600,ae=G(S.from,S.to);o.save(),o.lineCap="round",o.setLineDash([6,5]),o.lineWidth=2.5,o.strokeStyle=ba(J,S.snapped?1:W?.85:.65),o.beginPath(),Yl(o,ae,8),o.stroke();const ne=ae[0],Y=ae[ae.length-1];if(o.setLineDash([]),o.beginPath(),o.arc(ne.x,ne.y,4,0,Math.PI*2),o.fillStyle=ba(J),o.fill(),o.beginPath(),o.arc(Y.x,Y.y,S.snapped?9:6,0,Math.PI*2),o.lineWidth=2,o.strokeStyle=ba(J,S.snapped?1:W?.85:.5),o.stroke(),W){const te=g.get(S.forbiddenKey),ie=d.get(S.forbiddenKey)??"dot";if(te!==void 0&&ie!=="card"){const ue=(ie==="label"?18:11)+4;o.beginPath(),o.arc(R(te.x),N(te.y),ue,0,Math.PI*2),o.lineWidth=2,o.strokeStyle=ba(v.statusBad,.75),o.stroke()}}o.restore()}if(M!==void 0&&M.from!==void 0&&M.to!==void 0){const W=M.phase,J=G(M.from,M.to);o.save(),o.lineCap="round",o.setLineDash([10,6]),o.lineDashOffset=-W*32,o.lineWidth=3,o.strokeStyle=ba(v.brand600,.9*(1-W)),o.beginPath(),Yl(o,J,8),o.stroke(),o.setLineDash([]);for(const ae of[J[0],J[J.length-1]])o.beginPath(),o.arc(ae.x,ae.y,6+W*12,0,Math.PI*2),o.lineWidth=2,o.strokeStyle=ba(v.brand500,.8*(1-W)),o.stroke();o.restore()}if(b!==void 0){if(b.frame!==void 0){const J=R(b.frame.minX)-10,ae=N(b.frame.minY)-10,ne=(b.frame.maxX-b.frame.minX)*O+20,Y=(b.frame.maxY-b.frame.minY)*O+20;o.save(),o.beginPath(),o.rect(J,ae,ne,Y),o.globalAlpha=.07,o.fillStyle=ba(v.brand500),o.fill(),o.restore(),o.save(),o.setLineDash([7,5]),o.lineWidth=1.5,o.strokeStyle=ba(v.brand600),o.strokeRect(J,ae,ne,Y),o.setLineDash([]),o.restore()}if(b.emphasis!==void 0){const W=b.emphasis==="pulse",J=W?Math.sin(b.pulsePhase*Math.PI*2)*.5+.5:1;for(const ae of u){if(j(ae.key))continue;const ne=d.get(ae.key)??"dot";if(ne==="card")continue;const te=(ne==="label"?18:11)+(W?J*7:4),ie=W?.14+.3*(1-J):.34;o.save(),o.beginPath(),o.arc(R(ae.x),N(ae.y),te,0,Math.PI*2),o.lineWidth=2,o.strokeStyle=ba(v.brand500,ie),o.stroke(),o.restore()}}}for(const W of u){const J=_(W.footprint);if(J===void 0||J.type==="rect"||(d.get(W.key)??"dot")!=="card")continue;const ae=f.has(W.key);let ne=KV(v,_(W.color),(n=_(W.tone))==null?void 0:n.type,j8e(v,F8e(W.status)),"link");K(W.key)&&(ne=ba(v.fgMuted));const Y=H(W.key),te=_(W.bg),ie=_(W.fillOpacity)??(ae?.24:.12),ue=_(W.weight)??(ae?2.5:1.5),oe=()=>{o.save(),o.globalAlpha=ie*Y,o.fillStyle=K(W.key)?ne:te??ne,o.fill(),o.restore()};if(o.save(),o.globalAlpha=Y,J.type==="circle")o.beginPath(),o.arc(R(W.x),N(W.y),J.value.radius*O,0,Math.PI*2),oe(),o.lineWidth=ue,o.strokeStyle=ne,o.stroke();else{const ve=J.value.vertices.map(se=>({x:R(se.x),y:N(se.y),bulge:se.bulge}));if(ve.length>0){if(o.beginPath(),J.type==="polygon")wb(o,ve,!0),oe(),o.lineWidth=ue;else{wb(o,ve,!1);const se=J.value.width.type==="some"?J.value.width.value*O:void 0;o.lineCap="round",o.lineWidth=_(W.weight)??se??(ae?2.5:1.5)}o.strokeStyle=ne,o.stroke(),o.lineCap="butt"}}o.restore()}for(const W of u){const J=d.get(W.key)??"dot";if(J==="card")continue;let ae=KV(v,_(W.color),(r=_(W.tone))==null?void 0:r.type,j8e(v,F8e(W.status)),"link");K(W.key)&&(ae=ba(v.fgMuted));const ne=f.has(W.key),Y=R(W.x),te=N(W.y);if(o.save(),o.globalAlpha=H(W.key),J==="dot")o.beginPath(),o.arc(Y,te,_On,0,Math.PI*2),o.fillStyle=ae,o.fill(),o.lineWidth=1.5,o.strokeStyle=ba(v.white),o.stroke(),ne&&(o.beginPath(),o.arc(Y,te,7.5,0,Math.PI*2),o.lineWidth=2,o.strokeStyle=ba(v.fg),o.stroke());else{o.font=$ie;const ie=eZe(W,"label",s,ue=>o.measureText(ue).width);if(ie.kind==="rect"){const{left:ue,top:oe,w:ve,h:se}=ie;o.beginPath(),(a=o.roundRect)==null||a.call(o,ue,oe,ve,se,se/2),o.roundRect||o.rect(ue,oe,ve,se),o.fillStyle=ba(v.bgSurface),o.fill(),o.lineWidth=1,o.strokeStyle=ba(ne?v.fg:v.borderStrong),o.stroke(),o.beginPath(),o.arc(ue+gR+ZE/2,te,ZE/2,0,Math.PI*2),o.fillStyle=ae,o.fill(),o.fillStyle=ba(v.fg),o.textBaseline="middle",o.fillText(W.label,ue+gR+ZE+JXe,te)}}o.restore()}}const w3=new Set;function rZe(e,t){return e.type==="string"&&e.value.fieldId===t&&e.value.op.type==="in"}function DOn(e,t){for(const n of e)if(rZe(n,t))return n.value.op.value;return w3}function OOn(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function jOn(e,t,n){const r=e.filters.findIndex(o=>rZe(o,t));let a;if(n.length===0)a=r<0?[...e.filters]:e.filters.filter((o,i)=>i!==r);else{const o=$("string",{fieldId:t,op:$("in",new Set(n))});r<0?a=[...e.filters,o]:(a=[...e.filters],a[r]=o)}return{...e,filters:a}}function FOn(e,t,n,r){const a=new Set;for(const o of e.search(t)){const i=o.item.key;n.has(i)||r.has(i)||o.item.x<t.minX||o.item.x>t.maxX||o.item.y<t.minY||o.item.y>t.maxY||a.add(i)}return a}function BOn(e,t){const n=new Map,r=[...e].sort((u,d)=>u.width*u.height-d.width*d.height),a=(u,d,f)=>d>=u.x&&d<=u.x+u.width&&f>=u.y&&f<=u.y+u.height;for(const u of e)n.set(u.key,{zone:u,children:[],items:[]});const o=[],i=new Map;for(const u of e){const d=r.find(f=>f.key!==u.key&&f.width*f.height>u.width*u.height&&a(f,u.x+u.width/2,u.y+u.height/2));d!==void 0?(n.get(d.key).children.push(n.get(u.key)),i.set(u.key,d.key)):o.push(n.get(u.key))}const s=r.filter(u=>u.pattern.type==="outline"),l=[],c=new Map;for(const u of t){const d=s.find(f=>a(f,u.x,u.y));d!==void 0?(n.get(d.key).items.push(u),c.set(u.key,d.key)):l.push(u)}return{roots:o,floor:l,zoneOf:c,parentOf:i}}function Zg(e,t,n){if(t==="label")return{w:e.label.length*6+28,h:22};const r=e.sublabel.type==="some"?e.sublabel.value:void 0,o=(e.width.type==="some"?e.width.value*n:void 0)??Math.max(88,e.label.length*6.6+(e.icon.type==="some"?16:0)+(e.status.type==="some"?13:0)+20,((r==null?void 0:r.length)??0)*5.4+20),i=24+(r!==void 0?13:0)+(e.meter.type==="some"?8:0)+(e.metric.type==="some"?15:0);return{w:o,h:i}}function VOn(e){const t=new ZXe;return t.load(e.map(n=>({minX:n.x,minY:n.y,maxX:n.x,maxY:n.y,item:n}))),t}function HOn(e,t,n,r,a){const o=new Map;if(n==="dot"){for(const d of e)o.set(d.key,"dot");return o}const i=6;let s=0,l=0;const c=new Map;for(const d of e){const f=Zg(d,"card",r),h=Zg(d,"label",r);c.set(d.key,{card:f,label:h}),s=Math.max(s,f.w),l=Math.max(l,f.h)}const u=(d,f)=>{const h=c.get(d.key)[f],g=((h.w+s)/2+i)/r,v=((h.h+l)/2+i)/r;for(const b of t.search({minX:d.x-g,minY:d.y-v,maxX:d.x+g,maxY:d.y+v})){if(b.item.key===d.key)continue;const y=o.get(b.item.key);if(y==="dot")continue;const S=(c.get(b.item.key)??{card:Zg(b.item,"card",r),label:Zg(b.item,"label",r)})[y==="label"?"label":f];if(Math.abs(b.item.x-d.x)*r<(h.w+S.w)/2+i&&Math.abs(b.item.y-d.y)*r<(h.h+S.h)/2+i)return!1}return!0};if(n==="card")for(const d of e)u(d,"card")&&o.set(d.key,"card");for(const d of e)o.has(d.key)||o.set(d.key,u(d,"label")?"label":"dot");for(const d of a)o.has(d)&&o.set(d,n);return o}const aZe={brand600:"brand.600",brand500:"brand.500",fg:"fg",fgMuted:"fg.muted",fgSubtle:"fg.subtle",borderStrong:"border.strong",borderSubtle:"border.subtle",bgSurface:"bg.surface",bgPanel:"bg.panel",statusOk:"status.pos",statusWarn:"status.warn",statusBad:"status.neg",white:"white"},q8e=Object.keys(aZe);function WOn(e){const t=e.match(/[\d.]+/g);return t===null||t.length<3?[0,0,0]:[Math.round(+t[0]),Math.round(+t[1]),Math.round(+t[2])]}const UOn=C.memo(function({onResolve:t}){const n=C.useRef(null);return C.useLayoutEffect(()=>{const r=()=>{const o=n.current;if(o===null)return;const i=o.children,s={};q8e.forEach((l,c)=>{const u=i[c];u!==void 0&&(s[l]=WOn(getComputedStyle(u).color))}),t(s)};r();const a=new MutationObserver(r);return a.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","style"]}),()=>a.disconnect()},[t]),p.jsx(V,{ref:n,"aria-hidden":"true",css:{position:"absolute",width:"0",height:"0",overflow:"hidden",pointerEvents:"none"},children:q8e.map(r=>p.jsx(V,{color:aZe[r]},r))})});zv.add(_v);const qOn=it(S0.Types.Schematic);function G8e(e){let t=[],n=[];for(const r of e){const a=o=>t.includes(o)||n.includes(o);t.length===0&&n.length===0?(t=[r.from],n=[r.to]):a(r.from)&&!a(r.to)?n=[...n,r.to]:!a(r.from)&&a(r.to)?t=[...t,r.from]:!a(r.from)&&!a(r.to)&&(t=[...t,r.from],n=[...n,r.to])}return{sources:t,destinations:n}}const dT=40,GOn=30,KOn=16,YOn=25,K8e={},Y8e=1600,XOn=300,ZOn=250,X8e=10;function P1(e,t){queueMicrotask(()=>{try{const n=t();n instanceof Promise&&n.catch(r=>console.error(`[Schematic] ${e} callback failed:`,r))}catch(n){console.error(`[Schematic] ${e} callback failed:`,n)}})}function QOn(e,t,n){return{key:e,sources:[...t],destinations:[...n],label:A,metric:A,style:$("solid",{tone:A,weight:A}),route:$("orthogonal",{corner:A}),via:[],layer:A}}function JOn(e,t,n){return{key:e,from:t,to:n,label:A,metric:A,style:$("solid",{tone:A,weight:A}),route:$("orthogonal",{corner:A}),via:[],layer:A}}function ZV(e){return e.type==="some"?e.value.type:void 0}function Z8e(e,t){const n=t/e,r=Math.pow(10,Math.floor(Math.log10(n)));for(const a of[5,2,1])if(a*r<=n)return a*r;return r}function Q8e(e,t,n){let r=!1;for(let a=0,o=n.length-1;a<n.length;o=a++){const i=n[a].x,s=n[a].y,l=n[o].x,c=n[o].y;s>t!=c>t&&e<(l-i)*(t-s)/(c-s)+i&&(r=!r)}return r}const ejn=C.memo(function({value:t,storageKey:n}){var r,a,o;const i=en({key:"schematic"})(),{width:s,height:l}=t.extent,c=C.useMemo(()=>_(t.onSelect),[t.onSelect]),u=C.useMemo(()=>_(t.onSelectionChange),[t.onSelectionChange]),d=((r=_(t.selectionMode))==null?void 0:r.type)??"single",f=d==="multiple",h=_(t.selectZoomFocus)??!1,g=C.useMemo(()=>_(t.onViewportChange),[t.onViewportChange]),v=C.useMemo(()=>_(t.onItemOpen),[t.onItemOpen]),b=C.useMemo(()=>_(t.onSelectZone),[t.onSelectZone]),y=C.useMemo(()=>_(t.onZoneSelectionChange),[t.onZoneSelectionChange]),[x,S]=C.useState(w3),z=C.useMemo(()=>_(t.onCreateLink),[t.onCreateLink]),M=((a=_(t.linkMode))==null?void 0:a.type)??"draw",L=_(t.readOnly)??!1,R=!L&&!(_(t.readOnlyLinks)??!1),N=C.useMemo(()=>_(t.onMoveItem),[t.onMoveItem]),O=C.useMemo(()=>_(t.itemHover),[t.itemHover]),j=C.useMemo(()=>_(t.zoneHover),[t.zoneHover]),B=C.useMemo(()=>_(t.linkHover),[t.linkHover]),H=O!==void 0||j!==void 0||B!==void 0,[K,U]=C.useState(null),Z=C.useRef(null);C.useEffect(()=>{Z.current=K},[K]);const G=C.useRef(null),W=C.useRef(null),J=C.useCallback(()=>{G.current!==null&&(window.clearTimeout(G.current.timer),G.current=null)},[]),ae=C.useCallback(()=>{W.current!==null&&(window.clearTimeout(W.current),W.current=null)},[]),ne=C.useCallback(()=>{J(),ae(),U(fe=>fe===null?fe:null)},[J,ae]),Y=C.useCallback(()=>{J(),!(Z.current===null||W.current!==null)&&(W.current=window.setTimeout(()=>{W.current=null,U(null)},ZOn))},[J]);C.useEffect(()=>()=>{G.current!==null&&window.clearTimeout(G.current.timer),W.current!==null&&window.clearTimeout(W.current)},[]);const te=C.useMemo(()=>{if(K===null)return null;const fe=K.kind==="item"?O:K.kind==="zone"?j:B;if(fe===void 0)return null;try{return fe(K.key)}catch(Ee){return console.error("[Schematic] hover content builder failed:",Ee),null}},[K,O,j,B]),ie=!L&&!(_(t.readOnlyItems)??!1),ue=C.useMemo(()=>_(t.onSelectLink),[t.onSelectLink]),oe=C.useMemo(()=>_(t.onEditLink),[t.onEditLink]),ve=C.useMemo(()=>_(t.onDeleteLink),[t.onDeleteLink]),se=C.useMemo(()=>_(t.onEditNet),[t.onEditNet]),pe=C.useMemo(()=>_(t.canConnect),[t.canConnect]),de=C.useRef(new Map);C.useEffect(()=>{de.current=new Map},[pe]);const ge=C.useCallback((fe,Ee)=>{if(pe===void 0)return!0;const Le=`${fe}\0${Ee}`,He=de.current.get(Le);if(He!==void 0)return He;let Je=!0;try{Je=pe(fe,Ee)===!0}catch(at){console.error("[Schematic] canConnect validator failed (allowing):",at)}return de.current.set(Le,Je),Je},[pe]),[ye,me]=C.useState(null),Me=_(t.scaleUnit),Te=_(t.grid)??!0,Be=_(t.navigator)??t.zones.length>0,ht=_(t.minimap)??t.items.length>=YOn,De=_(t.slice),Qe=De==null?void 0:De.slice,bt=rl(Qe==null?void 0:Qe.key),Ve=en({key:"sliceFrame"})(),ut=De!==void 0&&Qe!==void 0,_t=C.useMemo(()=>(De==null?void 0:De.affordances.map(fe=>fe.type))??[],[De]),Ft=C.useMemo(()=>ut?p.jsx(zd,{slice:Qe,affordanceKinds:_t}):null,[ut,Qe,_t,bt]),wt=Tt(_(t.height)),Lt=Tt(_(t.maxHeight)),Jt=_(t.sliceEffect),Dt=Jt!==void 0,Et=Jt!==void 0&&(_(Jt.hidden)??!1)?"hide":"keep",Gt=Jt!==void 0?_(Jt.opacity)??1:1,Ke=Jt!==void 0?_(Jt.desaturate)??!1:!1,Se=Jt!==void 0?_(Jt.dot)??!1:!1,Re=Jt!==void 0?(o=_(Jt.emphasis))==null?void 0:o.type:void 0,qe=Jt!==void 0?_(Jt.frame)??!1:!1,Ye=Jt!==void 0?_(Jt.frameFit)??!1:!1,$e=C.useMemo(()=>{const fe=new Set;if(Dt)for(const Ee of t.items)_(Ee.excluded)===!0&&fe.add(Ee.key);return fe},[t.items,Dt]),lt=Dt&&$e.size>0,[Pe,ot]=C.useState({created:[],createdNets:[],retarget:new Map,deleted:new Set,netEdits:new Map});C.useEffect(()=>{ot({created:[],createdNets:[],retarget:new Map,deleted:new Set,netEdits:new Map})},[t.links,t.nets]);const kt=Pe.created.length>0||Pe.createdNets.length>0||Pe.retarget.size>0||Pe.deleted.size>0||Pe.netEdits.size>0,Mt=C.useMemo(()=>kt?[...t.links.filter(Ee=>!Pe.deleted.has(Ee.key)).map(Ee=>{const Le=Pe.retarget.get(Ee.key);return Le!==void 0?{...Ee,from:Le.from,to:Le.to}:Ee}),...Pe.created]:t.links,[t.links,Pe,kt]),At=C.useMemo(()=>kt?[...t.nets.filter(fe=>!Pe.deleted.has(fe.key)),...Pe.createdNets].map(fe=>{const Ee=Pe.netEdits.get(fe.key);return Ee!==void 0?{...fe,sources:[...Ee.sources],destinations:[...Ee.destinations]}:fe}):t.nets,[t.nets,Pe,kt]),[fn,rt]=C.useState(new Map);C.useEffect(()=>{rt(new Map)},[t.items]);const ln=C.useMemo(()=>fn.size===0?t.items:t.items.map(fe=>{const Ee=fn.get(fe.key);return Ee!==void 0?{...fe,x:Ee.x,y:Ee.y}:fe}),[t.items,fn]),Mn=C.useMemo(()=>kt||fn.size>0?{...t,items:ln,links:Mt,nets:At}:t,[t,ln,fn,Mt,At,kt]);C.useEffect(()=>{me(fe=>{if(fe===null)return fe;const Ee=At.find(Le=>Le.key===fe.key);return Ee===void 0&&!Mt.some(Le=>Le.key===fe.key)?null:fe.leg!==null&&Ee!==void 0&&!(fe.leg.end==="source"?Ee.sources:Ee.destinations).includes(fe.leg.item)?{key:fe.key,leg:null}:fe})},[Mt,At]);const[Jn,Er]=C.useState({selected:w3,anchor:null}),_r=Jn.selected,fr=_(t.sliceSelectField),Vr={onSelectionChange:u,sliceSelectField:fr,sliceHandle:Qe,selectZoomFocus:h},wr=C.useRef(Vr),pa=C.useRef(!1),ar=C.useCallback((fe,Ee)=>{Er(Je=>({selected:fe,anchor:fe.size===0?null:Ee.anchor!==void 0?Ee.anchor:Je.anchor}));const Le=wr.current,He=Le.onSelectionChange;if(He&&P1("onSelectionChange",()=>He({key:Ee.key!==void 0?P(Ee.key):A,selected:Ee.key!==void 0?fe.has(Ee.key):fe.size>0,selectedKeys:[...fe],additive:Ee.additive,region:Ee.region!==void 0?P(Ee.region):A})),Le.sliceSelectField!==void 0&&Le.sliceHandle!==void 0){const Je=Le.sliceHandle.read();OOn(DOn(Je.filters,Le.sliceSelectField),fe)||(Le.selectZoomFocus&&(pa.current=!0),Le.sliceHandle.write(jOn(Je,Le.sliceSelectField,[...fe].sort())))}},[]),On=C.useCallback(()=>ar(w3,{additive:!1}),[ar]),[st,dn]=C.useState(null),{state:Pn,setState:Hn}=Pl(n,{navCollapsed:!1,layerVis:{},layerLocks:{}}),pr=Pn.navCollapsed,Hr=C.useCallback(fe=>Hn(Ee=>({...Ee,navCollapsed:fe})),[Hn]),lr=C.useMemo(()=>_(t.layers)??[],[t.layers]),vr=lr.length>0,mo=Pn.layerVis??K8e,Fe=Pn.layerLocks??K8e,[Qt,tt]=C.useState(null),[gt,Ot]=C.useState(!1),yn=C.useMemo(()=>new Map(lr.map(fe=>[fe.key,fe])),[lr]),Bt=C.useCallback(fe=>{var Ee;return _((Ee=yn.get(fe))==null?void 0:Ee.visible)??!0},[yn]),vn=C.useCallback(fe=>{var Ee;return _((Ee=yn.get(fe))==null?void 0:Ee.locked)??!1},[yn]),wn=C.useCallback(fe=>{var Ee;return _((Ee=yn.get(fe))==null?void 0:Ee.opacity)??1},[yn]),Or=C.useCallback(fe=>Qt!==null?yn.has(fe)&&fe!==Qt:(mo[fe]??Bt(fe))===!1,[Qt,yn,mo,Bt]),{layerHiddenKeys:Zr,lockedKeys:qn,layerAlpha:ca,layerHiddenLayers:sa}=C.useMemo(()=>{const fe=St=>Fe[St]??vn(St),Ee=new Set;for(const St of lr)Or(St.key)&&Ee.add(St.key);const Le=new Set,He=new Set,Je=new Map,at=(St,$t)=>{if($t===void 0)return;if(Or($t)){Le.add(St);return}fe($t)&&He.add(St);const Yt=wn($t);Yt<1&&Je.set(St,Yt)};for(const St of t.items)at(St.key,_(St.layer));for(const St of t.zones)at(St.key,_(St.layer));for(const St of t.links)at(St.key,_(St.layer));return{layerHiddenKeys:Le,lockedKeys:He,layerAlpha:Je,layerHiddenLayers:Ee}},[lr,t.items,t.zones,t.links,Fe,Or,vn,wn]),vo=sa.size>0||Qt!==null,Ya=C.useMemo(()=>{const fe=new Map,Ee=Le=>{Le!==void 0&&fe.set(Le,(fe.get(Le)??0)+1)};for(const Le of t.items)Ee(_(Le.layer));for(const Le of t.zones)Ee(_(Le.layer));for(const Le of t.links)Ee(_(Le.layer));return fe},[t.items,t.zones,t.links]),Ha=C.useCallback(fe=>{const Ee=!sa.has(fe);tt(null),Hn(Le=>({...Le,layerVis:{...Le.layerVis??{},[fe]:!Ee}}))},[Hn,sa]),fi=C.useCallback(fe=>{Hn(Ee=>{const Le=Ee.layerLocks??{},He=Le[fe]??vn(fe);return{...Ee,layerLocks:{...Le,[fe]:!He}}})},[Hn,vn]),Ma=C.useCallback(fe=>tt(Ee=>Ee===fe?null:fe),[]),Wa=C.useCallback(()=>{tt(null),Hn(fe=>({...fe,layerVis:{},layerLocks:{}}))},[Hn]),Sa=C.useMemo(()=>{const fe=lt&&Et==="hide";return!fe&&Zr.size===0?ln:ln.filter(Ee=>!Zr.has(Ee.key)&&!(fe&&$e.has(Ee.key)))},[ln,lt,Et,$e,Zr]),Oa=C.useMemo(()=>Zr.size===0?t.zones:t.zones.filter(fe=>!Zr.has(fe.key)),[t.zones,Zr]),[Nl,$l]=C.useState(null);C.useEffect(()=>{if(_r.size===0)return;const fe=new Set(Sa.map(He=>He.key));let Ee=!1;const Le=new Set;for(const He of _r)fe.has(He)?Le.add(He):Ee=!0;Ee&&ar(Le,{additive:!1}),Er(He=>He.anchor!==null&&!fe.has(He.anchor)?{...He,anchor:null}:He)},[Sa,_r,ar]);const Il=C.useRef(null),M1=C.useRef(null),Sc=C.useRef(null),yo=C.useRef(null),il=C.useRef(null),[ft,Nt]=C.useState(null);C.useLayoutEffect(()=>{const fe=M1.current;if(!fe)return;const Ee=()=>Nt({w:fe.clientWidth,h:fe.clientHeight});Ee();const Le=new ResizeObserver(Ee);return Le.observe(fe),()=>Le.disconnect()},[]);const[sn,Fn]=C.useState(()=>typeof window<"u"&&window.devicePixelRatio||1);C.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;let fe=()=>{};const Ee=()=>{const Le=window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),He=()=>{fe(),Fn(window.devicePixelRatio||1),Ee()};Le.addEventListener("change",He),fe=()=>Le.removeEventListener("change",He)};return Ee(),()=>fe()},[]);const xn=C.useRef(YE),Pa=C.useRef("idle"),Qr=C.useRef(null),[cr,Ar]=C.useState(YE),[Cr,Aa]=C.useState("grab"),[qo,bo]=C.useState(null),qr=qo??Cr,Gs=qr==="zoom"||qr==="marquee",yr=C.useRef(!1),Jr=C.useRef(null),ja=C.useRef(null),[ta,Io]=C.useState(null),xi=C.useRef(null),[wi,pi]=C.useState([]),Dl=C.useRef(0),Xe=C.useRef(null),Rt=C.useRef(null),an=C.useRef(null),Rn=C.useRef(null),hr=C.useRef(null);C.useEffect(()=>()=>{Rn.current!==null&&cancelAnimationFrame(Rn.current)},[]);const[kr,to]=C.useState(null),Na=(kr==null?void 0:kr.rect)??null,Go=kr!==null&&kr.mode==="marquee"?kr.hits.size:0,Si=C.useMemo(()=>kr===null||kr.mode!=="marquee"?null:kr.additive?new Set([..._r,...kr.hits]):kr.hits,[kr,_r]),ri=ft!==null?Math.min(ft.w/s,ft.h/l):0,Nr=ri*cr.zoom,no=C.useMemo(()=>{const fe=new Map;for(const Ee of Sa)fe.set(Ee.key,{x:Ee.x,y:Ee.y});return fe},[Sa]),y2=C.useMemo(()=>{if(ta===null)return;const fe=no.get(ta.from);if(fe===void 0)return;const Ee=ta.target!==void 0?no.get(ta.target)??ta.toWorld:ta.toWorld;return{from:fe,to:Ee,snapped:ta.target!==void 0,...ta.forbidden!==void 0?{forbiddenKey:ta.forbidden}:{}}},[ta,no]),P4=C.useMemo(()=>{if(wi.length===0)return null;if(wi.length===1){const Je=wi[0],at=no.get(Je.from),St=no.get(Je.to);return at!==void 0&&St!==void 0?{kind:"edge",from:at,to:St}:null}const{sources:fe,destinations:Ee}=G8e(wi),Le=fe.map(Je=>no.get(Je)).filter(Je=>Je!==void 0),He=Ee.map(Je=>no.get(Je)).filter(Je=>Je!==void 0);return Le.length===0||He.length===0?null:{kind:"net",sources:Le,destinations:He}},[wi,no]),T1=C.useMemo(()=>{const fe=new ZXe;return fe.load(Sa.map(Ee=>{const Le=(_(Ee.width)??0)/2+2.4;let He=Ee.x-Le,Je=Ee.y-2,at=Ee.x+Le,St=Ee.y+2;const $t=_(Ee.footprint);if($t!==void 0&&$t.type==="circle"){const Yt=$t.value.radius;He=Math.min(He,Ee.x-Yt),Je=Math.min(Je,Ee.y-Yt),at=Math.max(at,Ee.x+Yt),St=Math.max(St,Ee.y+Yt)}else if($t!==void 0&&$t.type!=="rect")for(const Yt of $t.value.vertices)He=Math.min(He,Yt.x),Je=Math.min(Je,Yt.y),at=Math.max(at,Yt.x),St=Math.max(St,Yt.y);return{minX:He,minY:Je,maxX:at,maxY:St,item:Ee}})),fe},[Sa]),Ol=C.useMemo(()=>ft===null||Nr===0?[]:T1.search({minX:-cr.tx/Nr,minY:-cr.ty/Nr,maxX:(ft.w-cr.tx)/Nr,maxY:(ft.h-cr.ty)/Nr}).map(fe=>fe.item),[T1,ft,Nr,cr]),Ks=C.useMemo(()=>BOn(Oa,Sa),[Oa,Sa]),Fk=C.useCallback(fe=>{if(fe.size===0)return[];const Ee=[];for(const[Le,He]of Ks.zoneOf){let Je=He;for(;Je!==void 0;){if(fe.has(Je)){Ee.push(Le);break}Je=Ks.parentOf.get(Je)}}return Ee},[Ks]),Pd=C.useCallback((fe,Ee)=>{S(fe);const Le=y;Le&&P1("onZoneSelectionChange",()=>Le({key:Ee.key!==void 0?P(Ee.key):A,selected:Ee.key!==void 0?fe.has(Ee.key):fe.size>0,selectedKeys:[...fe],childItemKeys:Fk(fe),additive:Ee.additive}))},[y,Fk]),T5=C.useCallback(()=>{$r.current.zoneSelection.size>0&&Pd(w3,{additive:!1})},[Pd]),A4=C.useCallback((fe,Ee,Le)=>{const He=$r.current;if(He.size===null)return;const Je=xn.current,at=He.fit*Je.zoom;if(at===0)return;const St=fe.getBoundingClientRect(),$t=(Ee-St.left-Je.tx)/at,Yt=(Le-St.top-Je.ty)/at;let _n,Bn=1/0;for(const qt of Oa){if(qt.pattern.type!=="outline"||qn.has(qt.key))continue;const tn=_(qt.geometry);let er;if(tn!==void 0&&tn.type==="circle")er=Math.hypot($t-(qt.x+qt.width/2),Yt-(qt.y+qt.height/2))<=tn.value.radius;else if(tn!==void 0&&tn.type==="polygon")er=Q8e($t,Yt,tn.value.vertices);else{if(tn!==void 0&&tn.type==="polyline")continue;er=$t>=qt.x&&$t<=qt.x+qt.width&&Yt>=qt.y&&Yt<=qt.y+qt.height}if(!er)continue;const gr=qt.width*qt.height;gr<Bn&&(_n=qt,Bn=gr)}return _n==null?void 0:_n.key},[Oa,qn]),E5=C.useCallback((fe,Ee,Le)=>{const He=$r.current;if(He.size===null)return;const Je=xn.current,at=He.fit*Je.zoom;if(at===0)return;const St=fe.getBoundingClientRect(),$t=Ee-St.left,Yt=Le-St.top,_n=nZe(Mt,tn=>!Zr.has(tn.key)&&no.has(tn.from)&&no.has(tn.to)&&tn.via.length===0);let Bn,qt=1/0;for(const tn of Mt){if(Zr.has(tn.key)||qn.has(tn.key))continue;const er=no.get(tn.from),gr=no.get(tn.to);if(er===void 0||gr===void 0)continue;const br=[er,...tn.via,gr].map(Do=>({x:Do.x*at+Je.tx,y:Do.y*at+Je.ty})),ma=_n.get(tn.key);if(ma!==void 0){const Do=br[0],Ys=br[br.length-1],x2=Math.hypot(Ys.x-Do.x,Ys.y-Do.y);if(x2>1e-6){const j4=(ma.i-(ma.n-1)/2)*tZe,ro=-(Ys.y-Do.y)/x2*j4,p0=(Ys.x-Do.x)/x2*j4;for(const Fl of br)Fl.x+=ro,Fl.y+=p0}}const Eo=tn.route.type==="orthogonal"?O8(br):br,Ir=tn.style.value.weight.type==="some"?tn.style.value.weight.value:tn.style.type==="solid"?2.5:1.5,ai=XV(Eo,$t,Yt);ai<=Ir/2+YV&&ai<qt&&(Bn={key:tn.key,leg:null},qt=ai)}for(const tn of At){if(Zr.has(tn.key)||qn.has(tn.key))continue;const er=tn.sources.filter(ro=>no.has(ro)),gr=tn.destinations.filter(ro=>no.has(ro)),br=er.map(ro=>no.get(ro)),ma=gr.map(ro=>no.get(ro));if(br.length===0||ma.length===0)continue;const Eo=aX(br,ma,tn.via),Ir=ro=>({x:ro.x*at+Je.tx,y:ro.y*at+Je.ty}),ai=tn.route.type==="orthogonal",Do=ro=>ai?O8(ro.map(Ir)):ro.map(Ir),Ys=tn.style.value.weight.type==="some"?tn.style.value.weight.value:tn.style.type==="solid"?2.5:1.5,x2=ro=>ro<er.length?{end:"source",item:er[ro]}:{end:"destination",item:gr[ro-er.length]},j4=[Do(Eo.trunk),...Eo.bars.map(ro=>ro.map(Ir))];for(const ro of j4){const p0=XV(ro,$t,Yt);p0<=(Ys+1)/2+YV&&p0<qt&&(Bn={key:tn.key,leg:null},qt=p0)}for(const[ro,p0]of Eo.stubs.entries()){const Fl=XV(Do(p0),$t,Yt);Fl<=(Ys+1)/2+YV&&Fl<qt&&(Bn={key:tn.key,leg:x2(ro)},qt=Fl)}}return Bn},[Mt,At,no,Zr,qn]),Xv=C.useCallback((fe,Ee=null)=>{if(me({key:fe,leg:Ee}),ue){const Le=ue;P1("onSelectLink",()=>Le(fe))}},[ue]),MD=C.useMemo(()=>{const fe=new Map,Ee=new Map;for(const Le of Oa){const He=(fe.get(Le.label)??0)+1;fe.set(Le.label,He),Ee.set(Le.key,He>1?`${Le.label} · ${He}`:Le.label)}return Ee},[Oa]),Bk=C.useMemo(()=>{const fe=(Je,at)=>Je.label.localeCompare(at.label,void 0,{numeric:!0}),Ee=[],Le=Je=>{for(const at of[...Je].sort((St,$t)=>fe(St.zone,$t.zone)))Ee.push(...[...at.items].sort(fe)),Le(at.children)};Le(Ks.roots),Ee.push(...[...Ks.floor].sort(fe));const He=new Map(Ee.map((Je,at)=>[Je.key,at]));return{ordered:Ee,indexOf:He}},[Ks]),[_5,Zv]=C.useState(void 0);C.useEffect(()=>{if(ft===null||Nr===0||cr.zoom<=1.05){Zv(void 0);return}const He=-cr.tx/Nr,Je=-cr.ty/Nr,at=(ft.w-cr.tx)/Nr,St=(ft.h-cr.ty)/Nr,$t=(at-He)*(St-Je),Yt=qt=>{const tn=Math.max(0,Math.min(at,qt.x+qt.width)-Math.max(He,qt.x)),er=Math.max(0,Math.min(St,qt.y+qt.height)-Math.max(Je,qt.y));return tn*er/Math.min($t,qt.width*qt.height)};let _n,Bn=0;for(const qt of Oa){const tn=Yt(qt);tn>Bn&&(_n=qt.key,Bn=tn)}Zv(qt=>{if(qt!==void 0){const tn=Oa.find(gr=>gr.key===qt),er=tn!==void 0?Yt(tn):0;if(er>=.18&&(_n===qt||Bn<er+.15))return qt}return Bn>=.3?_n:void 0})},[ft,Nr,cr,Oa]);const Vk=C.useRef(null);C.useEffect(()=>{if(g===void 0||ft===null||ri===0)return;const fe=setTimeout(()=>{const Ee=ri*cr.zoom;if(Ee<=0)return;const Le=QXe({ppu:Ee,tx:cr.tx,ty:cr.ty},ft.w,ft.h),He={zoom:cr.zoom,minX:Le.minX,minY:Le.minY,maxX:Le.maxX,maxY:Le.maxY},Je=Vk.current;if(Je!==null&&Je.zoom===He.zoom&&Je.minX===He.minX&&Je.minY===He.minY&&Je.maxX===He.maxX&&Je.maxY===He.maxY)return;Vk.current=He;const at=g;P1("onViewportChange",()=>at(He))},150);return()=>clearTimeout(fe)},[g,ft,ri,cr]);const Cc=Nr>=GOn?"card":Nr>=KOn?"label":"dot",Hk=C.useMemo(()=>VOn(Ol),[Ol]),L5=C.useMemo(()=>{const fe=HOn(Ol,Hk,Cc,Nr,_r);if(lt&&Et==="keep"&&Se)for(const Ee of $e)fe.has(Ee)&&fe.set(Ee,"dot");return fe},[Ol,Hk,Cc,Nr,_r,lt,Et,Se,$e]),R5=Nr>0?Z8e(Nr,100):0,Qv=C.useMemo(()=>{if(!(lt&&qe))return;let fe=1/0,Ee=1/0,Le=-1/0,He=-1/0,Je=0;for(const at of ln){if($e.has(at.key)||Zr.has(at.key))continue;Je++;const St=Cc==="dot"?X8e:Zg(at,Cc,Nr).w/2+2,$t=Cc==="dot"?X8e:Zg(at,Cc,Nr).h/2+2,Yt=Nr>0?St/Nr:0,_n=Nr>0?$t/Nr:0;let Bn=at.x-Yt,qt=at.y-_n,tn=at.x+Yt,er=at.y+_n;const gr=_(at.footprint);if(gr!==void 0&&gr.type==="circle"){const br=gr.value.radius;Bn=Math.min(Bn,at.x-br),qt=Math.min(qt,at.y-br),tn=Math.max(tn,at.x+br),er=Math.max(er,at.y+br)}else if(gr!==void 0&&gr.type!=="rect")for(const br of gr.value.vertices)Bn=Math.min(Bn,br.x),qt=Math.min(qt,br.y),tn=Math.max(tn,br.x),er=Math.max(er,br.y);Bn<fe&&(fe=Bn),qt<Ee&&(Ee=qt),tn>Le&&(Le=tn),er>He&&(He=er)}return Je>=2&&Number.isFinite(fe)?{minX:fe,minY:Ee,maxX:Le,maxY:He}:void 0},[ln,$e,Zr,lt,qe,Cc,Nr]),TD=C.useMemo(()=>{if(lt)return{excluded:Et==="keep"?$e:w3,excludedOpacity:Gt,excludedDesaturate:Ke,emphasis:Re,frame:Qv}},[lt,Et,$e,Gt,Ke,Re,Qv]),Wk=Si??_r,Jv={value:Mn,size:ft,fit:ri,dpr:sn,palette:Nl,visibleItems:Ol,tiers:L5,selection:Jn,zoneSelection:x,renderSelected:Wk,centers:no,openZone:st,paintEffect:TD,frameRect:Qv,layerHiddenKeys:Zr,layerAlpha:ca,effectiveTool:qr,isBoxTool:Gs,connectDraftWorld:y2,sessionWorld:P4,selectedLink:ye,linkEditEnabled:R},$r=C.useRef(Jv),P5=C.useRef(0),Uk=C.useRef(null),kc=C.useCallback(()=>{const fe=$r.current,Ee=fe.size;if(Ee===null)return;const Le=xn.current,He=fe.fit*Le.zoom,Je=fe.dpr,at=yo.current;at!==null&&(at.style.setProperty("--cam-ppu",String(He)),at.style.setProperty("--cam-tx",`${Le.tx}px`),at.style.setProperty("--cam-ty",`${Le.ty}px`));const St=il.current;if(St!==null){const ma=He>0?Z8e(He,100):0;if(ma>0){const Eo=ma*He,Ir=Eo/5;St.style.backgroundSize=`${Eo}px ${Eo}px, ${Eo}px ${Eo}px, ${Ir}px ${Ir}px, ${Ir}px ${Ir}px`,St.style.backgroundPosition=`${Le.tx}px 0, 0 ${Le.ty}px, ${Le.tx}px 0, 0 ${Le.ty}px`}}const $t=Sc.current,Yt=fe.palette;if($t===null||Yt===null)return;const _n=Xe.current,Bn=_n!==null?Math.min(1,(performance.now()-_n.t0)/450):-1,qt=Uk.current;if(qt!==null&&qt.zoom===Le.zoom&&qt.tx===Le.tx&&qt.ty===Le.ty&&qt.vis===fe.visibleItems&&qt.tiers===fe.tiers&&qt.sel===fe.renderSelected&&qt.zsel===fe.zoneSelection&&qt.pal===Yt&&qt.w===Ee.w&&qt.h===Ee.h&&qt.dpr===Je&&qt.val===fe.value&&qt.eff===fe.paintEffect&&qt.phase===P5.current&&qt.lay===fe.layerHiddenKeys&&qt.alp===fe.layerAlpha&&qt.dl===fe.connectDraftWorld&&qt.sw===fe.sessionWorld&&qt.cf===Bn&&qt.slk===fe.selectedLink&&qt.sle===fe.linkEditEnabled)return;Uk.current={zoom:Le.zoom,tx:Le.tx,ty:Le.ty,vis:fe.visibleItems,tiers:fe.tiers,sel:fe.renderSelected,zsel:fe.zoneSelection,pal:Yt,w:Ee.w,h:Ee.h,dpr:Je,val:fe.value,eff:fe.paintEffect,phase:P5.current,lay:fe.layerHiddenKeys,alp:fe.layerAlpha,dl:fe.connectDraftWorld,sw:fe.sessionWorld,cf:Bn,slk:fe.selectedLink,sle:fe.linkEditEnabled};const tn=Math.round(Ee.w*Je),er=Math.round(Ee.h*Je);($t.width!==tn||$t.height!==er)&&($t.width=tn,$t.height=er);const gr=$t.getContext("2d");if(gr===null)return;gr.setTransform(Je,0,0,Je,0,0);const br=fe.paintEffect;try{IOn({ctx:gr,value:fe.value,cam:{ppu:He,tx:Le.tx,ty:Le.ty},width:Ee.w,height:Ee.h,visibleItems:fe.visibleItems,tiers:fe.tiers,selected:fe.renderSelected,selectedZones:fe.zoneSelection,centers:fe.centers,palette:Yt,layerHiddenKeys:fe.layerHiddenKeys,layerAlpha:fe.layerAlpha,...fe.connectDraftWorld!==void 0?{draftLink:fe.connectDraftWorld}:{},...fe.sessionWorld!==null?{session:fe.sessionWorld}:{},..._n!==null?{connectFlash:{from:fe.centers.get(_n.from),to:fe.centers.get(_n.to),phase:Bn}}:{},...fe.selectedLink!==null?{selectedLink:{key:fe.selectedLink.key,editable:fe.linkEditEnabled,...fe.selectedLink.leg!==null?{leg:fe.selectedLink.leg}:{}}}:{},...br!==void 0?{effect:{...br,pulsePhase:P5.current}}:{}})}catch(ma){console.error("[Schematic] paint failed (frame skipped):",ma)}},[]);C.useLayoutEffect(()=>{$r.current=Jv,wr.current=Vr,kc()});const V7=C.useRef(null);V7.current===null&&typeof requestAnimationFrame<"u"&&(V7.current=TOn(requestAnimationFrame,cancelAnimationFrame));const zc=C.useCallback(()=>{const fe=()=>{kc();const Le=xn.current;Ar(He=>He.zoom===Le.zoom&&He.tx===Le.tx&&He.ty===Le.ty?He:{zoom:Le.zoom,tx:Le.tx,ty:Le.ty})},Ee=V7.current;Ee!==null?Ee.request(fe):fe()},[kc]),qk=C.useCallback(()=>{Qr.current!==null&&(cancelAnimationFrame(Qr.current),Qr.current=null)},[]),Ci=C.useCallback(fe=>{MOn(Pa.current,fe)&&qk(),Pa.current=zOn(Pa.current,fe)},[qk]),jl=C.useCallback(fe=>{if($r.current.size===null||$r.current.fit===0)return;ne();const Ee=1.18,Le=()=>{const St=$r.current.size,$t=$r.current.fit;if(St===null||$t===0)return null;const Yt=Math.min(dT,Math.min(St.w/(fe.w*Ee*$t),St.h/(fe.h*Ee*$t)));return{zoom:Yt,tx:St.w/2-(fe.x+fe.w/2)*$t*Yt,ty:St.h/2-(fe.y+fe.h/2)*$t*Yt}},He={...xn.current},Je=performance.now();Qr.current!==null&&cancelAnimationFrame(Qr.current),Ci("flyStart");const at=St=>{const $t=Math.min(1,(St-Je)/350),Yt=1-Math.pow(1-$t,3),_n=Le();if(_n!==null){xn.current={zoom:He.zoom+(_n.zoom-He.zoom)*Yt,tx:He.tx+(_n.tx-He.tx)*Yt,ty:He.ty+(_n.ty-He.ty)*Yt},kc();const Bn=xn.current;Ar({zoom:Bn.zoom,tx:Bn.tx,ty:Bn.ty})}$t<1?Qr.current=requestAnimationFrame(at):(Qr.current=null,Ci("flyEnd"))};Qr.current=requestAnimationFrame(at)},[kc,Ci,ne]),Ad=C.useCallback(fe=>{if(fe.size===0)return;let Ee=1/0,Le=1/0,He=-1/0,Je=-1/0;for(const $t of fe){const Yt=$r.current.centers.get($t);Yt!==void 0&&(Ee=Math.min(Ee,Yt.x),Le=Math.min(Le,Yt.y),He=Math.max(He,Yt.x),Je=Math.max(Je,Yt.y))}if(Ee>He)return;const at=Math.max(4,(He-Ee)*.15),St=Math.max(3,(Je-Le)*.15);jl({x:Ee-at,y:Le-St,w:He-Ee+2*at,h:Je-Le+2*St})},[jl]),Nd=C.useCallback(fe=>{let Ee=1/0,Le=1/0,He=-1/0,Je=-1/0;for(const at of Oa)fe.has(at.key)&&(Ee=Math.min(Ee,at.x),Le=Math.min(Le,at.y),He=Math.max(He,at.x+at.width),Je=Math.max(Je,at.y+at.height));Ee<=He&&jl({x:Ee,y:Le,w:He-Ee,h:Je-Le})},[Oa,jl]),ey=C.useCallback((fe,Ee)=>{const Le=Ee&&d==="multiple";let He;if(Le?(He=new Set($r.current.zoneSelection),He.has(fe)?He.delete(fe):He.add(fe)):He=new Set([fe]),h&&Nd(He),Pd(He,{additive:Le,key:fe}),b){const Je=b;P1("onSelectZone",()=>Je(fe))}},[d,h,Nd,Pd,b]),b2=C.useCallback(()=>{xi.current=null,pi(fe=>fe.length===0?fe:[])},[]),N4=C.useCallback(()=>{Rt.current!==null&&cancelAnimationFrame(Rt.current);const fe=()=>{const Ee=Xe.current;if(Ee===null){Rt.current=null;return}if(kc(),performance.now()-Ee.t0>=450){Xe.current=null,Rt.current=null,kc();return}Rt.current=requestAnimationFrame(fe)};Rt.current=requestAnimationFrame(fe)},[kc]);C.useEffect(()=>()=>{Rt.current!==null&&cancelAnimationFrame(Rt.current)},[]);const ty=C.useCallback((fe,Ee,Le)=>{var He;const Je=`connect-${fe}-${Ee}-${++Dl.current}`,at={key:Je,from:fe,to:Ee},St=Le?xi.current:null,$t=St!==null?[...St.links,at]:[at],Yt=St!==null?St.seeded:[],_n=St!==null?St.key:`net-${++Dl.current}`,Bn=St!==null,{sources:qt,destinations:tn}=G8e($t),er=Mt.filter(br=>br.from===fe&&br.to===Ee||br.from===Ee&&br.to===fe).map(br=>br.key);let gr="none";if(M==="draw")if(!Bn)gr="link",ot({...Pe,created:[...Pe.created,JOn(Je,fe,Ee)]});else{gr="net";const br=QOn(_n,qt,tn),ma=St!==null&&St.drawn==="link"?(He=St.links[0])==null?void 0:He.key:void 0,Eo=new Set(Yt),Ir=Yt.length>0?new Set([...Pe.deleted,...Yt]):Pe.deleted;ot({...Pe,created:Pe.created.filter(ai=>ai.key!==ma&&!Eo.has(ai.key)),createdNets:[...Pe.createdNets.filter(ai=>ai.key!==_n),br],deleted:Ir})}else pi($t);if(xi.current={key:_n,links:$t,drawn:gr,seeded:Yt},Xe.current={from:fe,to:Ee,t0:performance.now()},N4(),z){const br=z;P1("onCreateLink",()=>br({link:at,links:[...$t],net:{key:_n,sources:qt,destinations:tn},additive:Bn,existing:er,absorbed:[...Yt]}))}},[Mt,M,Pe,z,N4]),ny=C.useCallback((fe,Ee,Le)=>{const He=Mt.find($t=>$t.key===fe);if(He===void 0)return;const Je=Ee==="from"?Le:He.from,at=Ee==="to"?Le:He.to;if(Je===at)return;const St=Pe.created.findIndex($t=>$t.key===fe);if(St>=0){const $t=[...Pe.created];$t[St]={...$t[St],from:Je,to:at},ot({...Pe,created:$t})}else{const $t=new Map(Pe.retarget);$t.set(fe,{from:Je,to:at}),ot({...Pe,retarget:$t})}if(Xe.current={from:Je,to:at,t0:performance.now()},N4(),oe){const $t=oe;P1("onEditLink",()=>$t({key:fe,from:Je,to:at}))}},[Mt,Pe,oe,N4]),ry=C.useCallback((fe,Ee,Le)=>{const He=At.find(Yt=>Yt.key===fe);if(He===void 0||He.sources.includes(Le)||He.destinations.includes(Le)||!(He.sources.includes(Ee)||He.destinations.includes(Ee)))return;const at=[...He.sources],St=[...He.destinations,Le],$t=new Map(Pe.netEdits);if($t.set(fe,{sources:at,destinations:St}),ot({...Pe,netEdits:$t}),Xe.current={from:Ee,to:Le,t0:performance.now()},N4(),se){const Yt=se;P1("onEditNet",()=>Yt({key:fe,sources:at,destinations:St}))}},[At,Pe,se,N4]),$4=C.useCallback(()=>{const fe=$r.current.selectedLink;if(fe===null||!$r.current.linkEditEnabled)return;const Ee=fe.key;if(fe.leg!==null){const Le=At.find(He=>He.key===Ee);if(Le!==void 0){const He=fe.leg,Je=He.end==="source"?Le.sources.filter(St=>St!==He.item):[...Le.sources],at=He.end==="destination"?Le.destinations.filter(St=>St!==He.item):[...Le.destinations];if(Je.length>0&&at.length>0){const St=new Map(Pe.netEdits);if(St.set(Ee,{sources:Je,destinations:at}),ot({...Pe,netEdits:St}),me({key:Ee,leg:null}),se){const $t=se;P1("onEditNet",()=>$t({key:Ee,sources:Je,destinations:at}))}return}}}if(Pe.created.some(Le=>Le.key===Ee))ot({...Pe,created:Pe.created.filter(Le=>Le.key!==Ee)});else if(Pe.createdNets.some(Le=>Le.key===Ee))ot({...Pe,createdNets:Pe.createdNets.filter(Le=>Le.key!==Ee)});else{const Le=new Set(Pe.deleted);Le.add(Ee),ot({...Pe,deleted:Le})}if(me(null),ve){const Le=ve;P1("onDeleteLink",()=>Le(Ee))}},[Pe,ve,At,se]),Gk=C.useCallback((fe,Ee,Le)=>{if(N===void 0)return;const He=fe.orig.get(fe.key);if(He===void 0)return;const Je=N,at={key:fe.key,x:Math.min(Math.max(He.x+Ee,0),s),y:Math.min(Math.max(He.y+Le,0),l),keys:[...fe.keys],dx:Ee,dy:Le};P1("onMoveItem",()=>Je(at))},[N,s,l]),$d=C.useRef(null),H7=C.useCallback(fe=>{if(jl({x:fe.x-4,y:fe.y-3,w:8,h:6}),ar(new Set([fe.key]),{additive:!1,key:fe.key,anchor:fe.key}),$d.current=null,dn(Ks.zoneOf.get(fe.key)??null),c){const Ee=c;P1("onSelect",()=>Ee(fe.key))}},[jl,Ks.zoneOf,c,ar]),Id=C.useCallback(fe=>{const{ordered:Ee,indexOf:Le}=Bk;if(Ee.length===0)return;const He=Jn.anchor,Je=He!==null?Le.get(He)??-1:-1;H7(Ee[(Je+fe+Ee.length)%Ee.length])},[Bk,H7,Jn.anchor]),Kk=C.useCallback(fe=>{if(fe.key==="ArrowRight"||fe.key==="ArrowDown")fe.preventDefault(),Id(1);else if(fe.key==="ArrowLeft"||fe.key==="ArrowUp")fe.preventDefault(),Id(-1);else if(fe.key==="Enter"){const Ee=$r.current.selection.anchor;if(Ee!==null&&v){const Le=v;P1("onItemOpen",()=>Le(Ee))}}},[Id,v]),A5=C.useCallback(fe=>{if(jl({x:fe.x,y:fe.y,w:fe.width,h:fe.height}),$d.current=null,dn(fe.key),Pd(new Set([fe.key]),{additive:!1,key:fe.key}),b){const Ee=b;P1("onSelectZone",()=>Ee(fe.key))}},[jl,Pd,b]);C.useEffect(()=>{const fe=M1.current;if(!fe)return;const Ee=Le=>{Le.preventDefault(),ne();const He=fe.getBoundingClientRect(),Je=Le.clientX-He.left,at=Le.clientY-He.top;Ci("wheel"),xn.current=GV(xn.current,Math.exp(-Le.deltaY*.0015),Je,at,1,dT),zc()};return fe.addEventListener("wheel",Ee,{passive:!1}),()=>fe.removeEventListener("wheel",Ee)},[Ci,zc,ne]);const d0=C.useRef(null),f0=C.useRef(new Map),Dd=C.useRef(null),I4=C.useRef(!1),E1=C.useCallback((fe,Ee,Le)=>{var He,Je,at;if($r.current.size===null)return;const $t=xn.current,Yt=$r.current.fit*$t.zoom;if(Yt===0)return;const _n=fe.getBoundingClientRect(),Bn=Ee-_n.left,qt=Le-_n.top,tn=(Bn-$t.tx)/Yt,er=(qt-$t.ty)/Yt;for(const Ir of Ol){if(qn.has(Ir.key)||(L5.get(Ir.key)??Cc)!=="card")continue;const ai=_(Ir.footprint);if(ai===void 0||ai.type==="rect")continue;if(ai.type==="circle"?Math.hypot(tn-Ir.x,er-Ir.y)<=ai.value.radius:Q8e(tn,er,ai.value.vertices))return Ir.key}if(typeof document<"u"){const Ir=(Je=(He=document.elementFromPoint(Ee,Le))==null?void 0:He.closest("[data-card-key]"))==null?void 0:Je.getAttribute("data-card-key");if(Ir!=null&&!qn.has(Ir))return Ir}const gr=((at=Sc.current)==null?void 0:at.getContext("2d"))??null;gr!==null&&(gr.save(),gr.font=$ie);const br={ppu:Yt,tx:$t.tx,ty:$t.ty};let ma=null,Eo=1/0;for(const Ir of Ol){if(qn.has(Ir.key))continue;const ai=L5.get(Ir.key)??Cc;if(ai==="card")continue;const Do=eZe(Ir,ai,br,x2=>gr!==null?gr.measureText(x2).width:x2.length*6);if(!ROn(Do,Bn,qt))continue;const Ys=Math.hypot(Ir.x*Yt+$t.tx-Bn,Ir.y*Yt+$t.ty-qt);Ys<Eo&&(ma=Ir,Eo=Ys)}return gr!==null&&gr.restore(),ma==null?void 0:ma.key},[L5,Cc,Ol,qn]),Od=C.useCallback((fe,Ee,Le,He)=>{const Je=E1(fe,Ee,Le);if(Je===void 0)return!1;const at=He&&d==="multiple";let St;if(at?(St=new Set($r.current.selection.selected),St.has(Je)?St.delete(Je):St.add(Je)):St=new Set([Je]),h&&Ad(St),ar(St,{additive:at,key:Je,anchor:Je}),c){const $t=c;P1("onSelect",()=>$t(Je))}return!0},[E1,c,Ad,d,ar,h]),jd=C.useCallback(fe=>FOn(T1,fe,qn,$e),[T1,qn,$e]),Yk=C.useCallback(fe=>{if(fe.button===0){if(fe.pointerType==="touch"&&(f0.current.set(fe.pointerId,{x:fe.clientX,y:fe.clientY}),f0.current.size===2)){const[Ee,Le]=[...f0.current.values()];Dd.current={dist:Math.hypot(Ee.x-Le.x,Ee.y-Le.y)},d0.current=null,ja.current=null,I4.current=!0;return}if(ne(),fe.target.closest("button")===null){if(fe.currentTarget.setPointerCapture(fe.pointerId),I4.current=!1,$r.current.effectiveTool==="move"){const Ee=E1(fe.currentTarget,fe.clientX,fe.clientY);if(Ee!==void 0){Ci("cancel");const Le=$r.current,He=xn.current,Je=Le.fit*He.zoom,at=fe.currentTarget.getBoundingClientRect(),St=Je>0?(fe.clientX-at.left-He.tx)/Je:0,$t=Je>0?(fe.clientY-at.top-He.ty)/Je:0,Yt=Le.selection.selected.has(Ee)?[...Le.selection.selected]:[Ee],_n=new Map;for(const Bn of Yt){const qt=Le.centers.get(Bn);qt!==void 0&&_n.set(Bn,{x:qt.x,y:qt.y})}ja.current={key:Ee,keys:[..._n.keys()],orig:_n,startWorld:{x:St,y:$t}};return}}if(!fe.shiftKey&&$r.current.linkEditEnabled&&$r.current.selectedLink!==null){const Ee=$r.current,Le=Mt.find(at=>{var St;return at.key===((St=Ee.selectedLink)==null?void 0:St.key)}),He=xn.current,Je=Ee.fit*He.zoom;if(Le!==void 0&&Je>0){const at=fe.currentTarget.getBoundingClientRect(),St=fe.clientX-at.left,$t=fe.clientY-at.top,Yt=Ee.centers.get(Le.from),_n=Ee.centers.get(Le.to),Bn=tn=>tn!==void 0&&Math.hypot(tn.x*Je+He.tx-St,tn.y*Je+He.ty-$t)<=10,qt=Bn(Yt)?"from":Bn(_n)?"to":void 0;if(qt!==void 0){Ci("cancel");const tn=qt==="from"?Le.to:Le.from;Jr.current={from:tn,additive:!1,retarget:{key:Le.key,movingEnd:qt}},Io({from:tn,toWorld:{x:(St-He.tx)/Je,y:($t-He.ty)/Je},target:void 0});return}}}if($r.current.effectiveTool==="connect"){const Ee=E1(fe.currentTarget,fe.clientX,fe.clientY);if(Ee!==void 0){!fe.shiftKey&&xi.current!==null&&b2(),Ci("cancel");const Le=fe.currentTarget.getBoundingClientRect(),He=xn.current,Je=$r.current.fit*He.zoom,at=Je>0?(fe.clientX-Le.left-He.tx)/Je:0,St=Je>0?(fe.clientY-Le.top-He.ty)/Je:0;if(Jr.current={from:Ee,additive:fe.shiftKey},fe.shiftKey&&xi.current===null){const $t=$r.current.selectedLink;if($t!==null&&$t.leg===null){const Yt=At.find(_n=>_n.key===$t.key);if(Yt!==void 0&&(Yt.sources.includes(Ee)||Yt.destinations.includes(Ee)))Jr.current={from:Ee,additive:!0,netExtend:Yt.key};else{const _n=Mt.find(Bn=>Bn.key===$t.key);_n!==void 0&&(_n.from===Ee||_n.to===Ee)&&(xi.current={key:`net-${++Dl.current}`,links:[{key:_n.key,from:_n.from,to:_n.to}],drawn:"none",seeded:[_n.key]})}}}Io({from:Ee,toWorld:{x:at,y:St},target:void 0});return}}if($r.current.isBoxTool){Ci("cancel");const Ee=fe.currentTarget.getBoundingClientRect(),Le=fe.clientX-Ee.left,He=fe.clientY-Ee.top,Je=$r.current.effectiveTool==="marquee"?"marquee":"zoom";an.current={sx:Le,sy:He,mode:Je,additive:fe.shiftKey},to({rect:{x:Le,y:He,w:0,h:0},mode:Je,additive:fe.shiftKey,hits:w3});return}xi.current!==null&&b2(),Ci("pointerDown"),d0.current={x:fe.clientX,y:fe.clientY,tx:xn.current.tx,ty:xn.current.ty}}}},[Ci,E1,Mt,At,ne,b2]),ay=C.useCallback(fe=>{var Ee;const Le=fe.currentTarget;let He=null,Je;if(O!==void 0&&(Je=E1(Le,fe.clientX,fe.clientY),Je!==void 0&&(He="item")),He===null&&j!==void 0&&(Je=A4(Le,fe.clientX,fe.clientY),Je!==void 0&&(He="zone")),He===null&&B!==void 0&&(Je=(Ee=E5(Le,fe.clientX,fe.clientY))==null?void 0:Ee.key,Je!==void 0&&(He="link")),He===null||Je===void 0){Y();return}const at=Z.current;if(at!==null&&at.kind===He&&at.key===Je){ae();return}const St=`${He}:${Je}`;if(G.current!==null&&G.current.target===St)return;J();const $t=Le.getBoundingClientRect();let Yt=fe.clientX-$t.left,_n=fe.clientY-$t.top;if(He==="item"){const br=xn.current,ma=$r.current.fit*br.zoom,Eo=no.get(Je);Eo!==void 0&&ma>0&&(Yt=Eo.x*ma+br.tx,_n=Eo.y*ma+br.ty)}const Bn=He,qt=Je,tn=Yt,er=_n,gr=window.setTimeout(()=>{G.current=null,ae(),U({kind:Bn,key:qt,ax:tn,ay:er})},XOn);G.current={timer:gr,target:St}},[O,j,B,E1,A4,E5,no,Y,J,ae]),Xk=C.useCallback(fe=>{if(fe.pointerType==="touch"&&f0.current.has(fe.pointerId)){f0.current.set(fe.pointerId,{x:fe.clientX,y:fe.clientY});const at=Dd.current;if(at&&f0.current.size>=2){const[St,$t]=[...f0.current.values()],Yt=Math.hypot(St.x-$t.x,St.y-$t.y);if(Yt>0&&at.dist>0){const _n=fe.currentTarget.getBoundingClientRect(),Bn=(St.x+$t.x)/2-_n.left,qt=(St.y+$t.y)/2-_n.top;Ci("wheel"),xn.current=GV(xn.current,Yt/at.dist,Bn,qt,1,dT),zc()}at.dist=Yt;return}}const Ee=ja.current;if(Ee!==null){const St=fe.currentTarget.getBoundingClientRect(),$t=xn.current,Yt=$r.current.fit*$t.zoom;if(Yt>0){const _n=(fe.clientX-St.left-$t.tx)/Yt-Ee.startWorld.x,Bn=(fe.clientY-St.top-$t.ty)/Yt-Ee.startWorld.y;rt(qt=>{const tn=new Map(qt);for(const[er,gr]of Ee.orig)tn.set(er,{x:Math.min(Math.max(gr.x+_n,0),s),y:Math.min(Math.max(gr.y+Bn,0),l)});return tn})}return}const Le=Jr.current;if(Le!==null){const at=fe.currentTarget,St=at.getBoundingClientRect(),$t=xn.current,Yt=$r.current.fit*$t.zoom;if(Yt>0){const _n=(fe.clientX-St.left-$t.tx)/Yt,Bn=(fe.clientY-St.top-$t.ty)/Yt,qt=E1(at,fe.clientX,fe.clientY),tn=qt!==void 0&&qt!==Le.from&&(Le.retarget!==void 0&&Le.retarget.movingEnd==="from"?ge(qt,Le.from):ge(Le.from,qt)),er=tn?qt:void 0,gr=qt!==void 0&&qt!==Le.from&&!tn?qt:void 0;Io({from:Le.from,toWorld:{x:_n,y:Bn},target:er,...gr!==void 0?{forbidden:gr}:{}})}return}const He=an.current;if(He!==null){const at=fe.currentTarget.getBoundingClientRect(),St=fe.clientX-at.left,$t=fe.clientY-at.top;(Math.abs(St-He.sx)>4||Math.abs($t-He.sy)>4)&&(I4.current=!0);const Yt=Math.min(He.sx,St),_n=Math.min(He.sy,$t),Bn=Math.abs(St-He.sx),qt=Math.abs($t-He.sy);to(tn=>({rect:{x:Yt,y:_n,w:Bn,h:qt},mode:He.mode,additive:He.additive,hits:tn!==null?tn.hits:w3})),He.mode==="marquee"&&(hr.current={x0:Yt,y0:_n,sw:Bn,sh:qt},Rn.current===null&&(Rn.current=requestAnimationFrame(()=>{Rn.current=null;const tn=hr.current;if(tn===null||an.current===null)return;const er=xn.current,gr=$r.current.fit*er.zoom,br=tn.sw>6&&tn.sh>6&&gr>0?jd({minX:(tn.x0-er.tx)/gr,minY:(tn.y0-er.ty)/gr,maxX:(tn.x0+tn.sw-er.tx)/gr,maxY:(tn.y0+tn.sh-er.ty)/gr}):w3;to(ma=>ma===null?ma:{...ma,hits:br})})));return}const Je=d0.current;if(!Je){H&&ay(fe);return}(Math.abs(fe.clientX-Je.x)>4||Math.abs(fe.clientY-Je.y)>4)&&(I4.current=!0),xn.current={...xn.current,tx:Je.tx+fe.clientX-Je.x,ty:Je.ty+fe.clientY-Je.y},zc()},[zc,jd,E1,H,ay,s,l,ge,Ci]),W7=C.useCallback(()=>d0.current===null?!1:(d0.current=null,Ci("pointerUp"),!0),[Ci]),ED=C.useCallback(fe=>{fe.pointerType==="touch"&&(f0.current.delete(fe.pointerId),f0.current.size<2&&(Dd.current=null));const Ee=ja.current;if(Ee!==null){ja.current=null;const at=fe.currentTarget.getBoundingClientRect(),St=xn.current,$t=$r.current.fit*St.zoom;if($t>0){const Yt=(fe.clientX-at.left-St.tx)/$t-Ee.startWorld.x,_n=(fe.clientY-at.top-St.ty)/$t-Ee.startWorld.y;Gk(Ee,Yt,_n)}return}const Le=Jr.current;if(Le!==null){Jr.current=null,Io(null);const at=E1(fe.currentTarget,fe.clientX,fe.clientY);at!==void 0&&at!==Le.from&&(Le.retarget!==void 0&&Le.retarget.movingEnd==="from"?ge(at,Le.from):ge(Le.from,at))&&(Le.retarget!==void 0?ny(Le.retarget.key,Le.retarget.movingEnd,at):Le.netExtend!==void 0?ry(Le.netExtend,Le.from,at):ty(Le.from,at,Le.additive));return}const He=an.current;if(He!==null){an.current=null;const at=fe.currentTarget.getBoundingClientRect(),St=fe.clientX-at.left,$t=fe.clientY-at.top,Yt=Math.min(He.sx,St),_n=Math.min(He.sy,$t),Bn=Math.abs(St-He.sx),qt=Math.abs($t-He.sy);to(null);const tn=xn.current,er=$r.current.fit*tn.zoom,gr=Bn>6&&qt>6&&er>0;if(He.mode==="zoom"){gr?jl({x:(Yt-tn.tx)/er,y:(_n-tn.ty)/er,w:Bn/er,h:qt/er}):!Od(fe.currentTarget,fe.clientX,fe.clientY,fe.shiftKey)&&!fe.shiftKey&&On();return}if(gr){const br={minX:(Yt-tn.tx)/er,minY:(_n-tn.ty)/er,maxX:(Yt+Bn-tn.tx)/er,maxY:(_n+qt-tn.ty)/er},ma=jd(br),Eo=He.additive,Ir=Eo?new Set([...$r.current.selection.selected,...ma]):ma;h&&Ad(Ir),ar(Ir,{additive:Eo,region:br,...ma.size>0?{anchor:[...ma][ma.size-1]}:{}})}else if(!Od(fe.currentTarget,fe.clientX,fe.clientY,He.additive)){const br=E5(fe.currentTarget,fe.clientX,fe.clientY);if(br!==void 0)Xv(br.key,br.leg);else{const ma=A4(fe.currentTarget,fe.clientX,fe.clientY);ma!==void 0?ey(ma,He.additive):He.additive||(On(),T5(),me(null))}}return}if(!(!W7()||I4.current)&&!Od(fe.currentTarget,fe.clientX,fe.clientY,fe.shiftKey)){const at=E5(fe.currentTarget,fe.clientX,fe.clientY);if(at!==void 0)Xv(at.key,at.leg);else{const St=A4(fe.currentTarget,fe.clientX,fe.clientY);St!==void 0?ey(St,fe.shiftKey):fe.shiftKey||(On(),T5(),me(null))}}},[W7,Od,jl,Ad,jd,ar,On,h,A4,ey,T5,E1,ty,ny,E5,Xv,Gk,ge,ry]),Zk=C.useCallback(()=>{I4.current=!1;const fe=ja.current;fe!==null&&(ja.current=null,rt(Ee=>{const Le=new Map(Ee);for(const[He,Je]of fe.orig)Le.set(He,Je);return Le})),Jr.current=null,Io(null),an.current=null,to(null),W7()},[W7]),oy=C.useCallback(()=>{Ci("cancel"),xn.current=YE,zc()},[Ci,zc]),_D=C.useCallback(fe=>{if(v!==void 0){const Ee=E1(fe.currentTarget,fe.clientX,fe.clientY);if(Ee!==void 0){const Le=v;P1("onItemOpen",()=>Le(Ee));return}}oy()},[v,E1,oy]),_1=C.useCallback(fe=>{const Ee=$r.current.size;Ee!==null&&(Ci("zoom"),xn.current=GV(xn.current,fe,Ee.w/2,Ee.h/2,1,dT),zc())},[Ci,zc]);C.useEffect(()=>{b2()},[M,b2]),C.useEffect(()=>{Cr!=="connect"&&(Jr.current=null,Io(null),b2()),(Cr==="connect"&&!R||Cr==="move"&&!ie)&&Aa("grab")},[Cr,b2,R,ie]),C.useEffect(()=>{const fe=He=>{if(yr.current){if(He.code==="Space")He.preventDefault(),He.repeat||bo("grab");else if(He.key==="Control"&&!He.repeat)bo("zoom");else if((He.key==="Delete"||He.key==="Backspace")&&$r.current.selectedLink!==null)He.preventDefault(),$4();else if(He.key==="Escape")if(Z.current!==null)ne();else if(ja.current!==null){const Je=ja.current;ja.current=null,rt(at=>{const St=new Map(at);for(const[$t,Yt]of Je.orig)St.set($t,Yt);return St})}else Jr.current!==null?(Jr.current=null,Io(null)):an.current!==null?(an.current=null,to(null)):xi.current!==null?b2():($r.current.selection.selected.size>0||$r.current.zoneSelection.size>0||$r.current.selectedLink!==null)&&(On(),T5(),me(null))}},Ee=He=>{(He.code==="Space"||He.key==="Control")&&bo(null)},Le=()=>bo(null);return window.addEventListener("keydown",fe),window.addEventListener("keyup",Ee),window.addEventListener("blur",Le),()=>{window.removeEventListener("keydown",fe),window.removeEventListener("keyup",Ee),window.removeEventListener("blur",Le)}},[On,T5,b2,$4,ne]);const D4=C.useRef(!1),iy=C.useCallback((fe,Ee,Le)=>{const He=$r.current.size;if(He===null)return;const Je=fe.getBoundingClientRect(),at=(Ee-Je.left)/Je.width*s,St=(Le-Je.top)/Je.height*l,$t=xn.current;xn.current={...$t,tx:He.w/2-at*$r.current.fit*$t.zoom,ty:He.h/2-St*$r.current.fit*$t.zoom},zc()},[s,l,zc]);C.useEffect(()=>()=>{var fe;(fe=V7.current)==null||fe.cancel(),Qr.current!==null&&cancelAnimationFrame(Qr.current)},[Qr]),C.useEffect(()=>{if(!(lt&&Re==="pulse"))return;let fe=0;const Ee=performance.now(),Le=He=>{var Je;const at=(He-Ee)%Y8e/Y8e;P5.current=at,(Je=yo.current)==null||Je.style.setProperty("--pulse",String(Math.sin(at*Math.PI*2)*.5+.5)),kc(),fe=requestAnimationFrame(Le)};return fe=requestAnimationFrame(Le),()=>{var He;cancelAnimationFrame(fe),P5.current=0,(He=yo.current)==null||He.style.setProperty("--pulse","0"),kc()}},[lt,Re,kc]);const Qk=C.useMemo(()=>{if(!(lt&&Ye))return null;const fe=[];for(const Ee of t.items)!$e.has(Ee.key)&&!Zr.has(Ee.key)&&fe.push(Ee.key);return fe.sort(),fe.join("|")},[t.items,$e,Zr,lt,Ye]),sy=ft!==null;C.useEffect(()=>{const fe=pa.current;pa.current=!1;const Ee=$r.current.frameRect;!(lt&&Ye)||Ee===void 0||!sy||fe||jl({x:Ee.minX,y:Ee.minY,w:Math.max(.001,Ee.maxX-Ee.minX),h:Math.max(.001,Ee.maxY-Ee.minY)})},[Qk,lt,Ye,jl,sy]);const Jk=C.useCallback(fe=>{const Ee=$r.current.openZone===fe;$d.current=Ee?fe:null,dn(Ee?Ks.parentOf.get(fe)??null:fe)},[Ks.parentOf]);C.useEffect(()=>{if(_5!==void 0){if($d.current!==null){if($d.current===_5)return;$d.current=null}dn(_5)}},[_5]);const U7=C.useMemo(()=>{const fe=new Set;let Ee=st??void 0;for(;Ee!==void 0;)fe.add(Ee),Ee=Ks.parentOf.get(Ee);return fe},[st,Ks.parentOf]);C.useEffect(()=>{var fe,Ee;const Le=Jn.anchor;Le!==null&&((Ee=(fe=Il.current)==null?void 0:fe.querySelector(`[data-nav-key="${CSS.escape(Le)}"]`))==null||Ee.scrollIntoView({block:"nearest"}))},[Jn,U7]);const ez=(fe,Ee)=>{const Le=U7.has(fe.zone.key),He=fe.items.length+fe.children.reduce((at,St)=>at+St.items.length,0),Je=fe.items.length>0||fe.children.length>0;return p.jsxs(V,{children:[p.jsxs(V,{css:i.navZone,style:{paddingLeft:`${8+Ee*14}px`,top:`calc(var(--nav-row-h) * ${Ee})`,zIndex:30-Ee},...fe.zone.key===_5?{"data-current":""}:{},children:[Je?p.jsx(V,{as:"button",css:i.navCaret,"aria-label":Le?"Collapse zone":"Expand zone","data-open":Le?"":void 0,onClick:()=>Jk(fe.zone.key),children:p.jsx(Ut,{icon:BK})}):p.jsx(V,{css:i.navCaret,"aria-hidden":"true",style:{visibility:"hidden"},children:p.jsx(Ut,{icon:BK})}),p.jsx(V,{as:"button",css:i.navZoneLabel,onClick:()=>A5(fe.zone),children:MD.get(fe.zone.key)??fe.zone.label}),He>0&&p.jsx(V,{as:"span",css:i.navCount,children:He})]}),Le&&fe.children.map(at=>ez(at,Ee+1)),Le&&fe.items.map(at=>p.jsxs(V,{as:"button",css:i.navItem,"data-nav-key":at.key,style:{paddingLeft:`${30+Ee*14}px`},..._r.has(at.key)?{"data-selected":""}:{},onClick:()=>H7(at),children:[p.jsx(V,{as:"span",css:i.statusDot,"data-tone":ZV(at.status)??"neutral"}),at.label,at.metric.type==="some"&&p.jsx(V,{as:"span",css:i.navMetric,children:at.metric.value})]},at.key))]},fe.zone.key)},O4=p.jsxs(V,{css:i.root,...wt!==void 0?{style:{height:wt,maxHeight:Lt??wt}}:Lt!==void 0?{style:{maxHeight:Lt}}:{},children:[p.jsx(UOn,{onResolve:$l}),Be&&pr&&p.jsx(V,{css:i.navCollapsed,children:p.jsx(V,{as:"button",css:i.navToggle,"aria-label":"Expand index",title:"Show index",onClick:()=>Hr(!1),children:p.jsx(Ut,{icon:uoe})})}),Be&&!pr&&p.jsxs(V,{css:i.nav,children:[p.jsxs(V,{css:i.navHeader,children:[p.jsx(V,{as:"span",css:i.navTitle,children:"Index"}),p.jsx(V,{as:"button",css:i.navToggle,"aria-label":"Collapse index",title:"Hide index",onClick:()=>Hr(!0),children:p.jsx(Ut,{icon:foe})})]}),p.jsxs(V,{ref:Il,css:i.navTree,children:[Ks.roots.map(fe=>ez(fe,0)),Ks.floor.map(fe=>p.jsxs(V,{as:"button",css:i.navItem,"data-nav-key":fe.key,style:{paddingLeft:"8px"},..._r.has(fe.key)?{"data-selected":""}:{},onClick:()=>H7(fe),children:[p.jsx(V,{as:"span",css:i.statusDot,"data-tone":ZV(fe.status)??"neutral"}),fe.label]},fe.key))]})]}),p.jsxs(V,{ref:M1,css:i.canvas,"data-schematic-canvas":"",tabIndex:0,role:"application","aria-label":"Schematic canvas — arrow keys traverse items, Enter opens the selected item",onKeyDown:Kk,style:{...wt!==void 0?{minHeight:0}:{aspectRatio:`${s} / ${l}`},...(ta==null?void 0:ta.forbidden)!==void 0?{cursor:"not-allowed"}:Gs||qr==="connect"?{cursor:"crosshair"}:qr==="move"?{cursor:"move"}:{}},onPointerEnter:()=>{yr.current=!0},onPointerLeave:()=>{yr.current=!1,bo(null),Y()},onPointerDown:Yk,onPointerMove:Xk,onPointerUp:ED,onPointerCancel:Zk,onLostPointerCapture:Zk,onDoubleClick:_D,children:[Te&&ft!==null&&p.jsx(V,{ref:il,css:i.grid}),ft!==null&&p.jsxs(p.Fragment,{children:[p.jsx("canvas",{ref:Sc,style:{position:"absolute",inset:0,width:"100%",height:"100%"}}),p.jsx(V,{ref:yo,css:i.cardLayer,children:Ol.map(fe=>{if((L5.get(fe.key)??Cc)!=="card")return null;const Ee=ZV(fe.status),Le=Wk.has(fe.key),He=lt&&Et==="keep"&&$e.has(fe.key),Je=lt&&Re!==void 0&&!$e.has(fe.key),at=qn.has(fe.key),St=(He?Gt:1)*(ca.get(fe.key)??1),$t=_(fe.sublabel),Yt=_(fe.icon),_n=_(fe.meter),Bn=_(fe.metric),qt=_(fe.width),tn=Yt!==void 0?x$e({prefix:"fas",iconName:Yt}):void 0;return p.jsxs(V,{css:i.item,"data-card-key":fe.key,...Le?{"data-selected":""}:{},...Je?{"data-emphasis":Re}:{},...He?{"data-excluded":""}:{},...(ta==null?void 0:ta.forbidden)===fe.key?{"data-forbidden":""}:{},style:{left:0,top:0,transform:`${COn(fe.x,fe.y)} translate(-50%, -50%)`,...typeof qt=="number"?{width:kOn(qt)}:{},...St<1?{opacity:St}:{},...He&&Ke?{filter:"grayscale(1)"}:{},...at?{pointerEvents:"none"}:{}},children:[p.jsxs(V,{css:i.itemHead,children:[tn!==void 0&&p.jsx(V,{as:"span",css:i.itemIcon,children:p.jsx(Ut,{icon:tn})}),p.jsx(V,{as:"span",css:i.itemLabel,children:fe.label}),Ee!==void 0&&p.jsx(V,{as:"span",css:i.statusDot,"data-tone":Ee})]}),$t!==void 0&&p.jsx(V,{css:i.itemSublabel,children:$t}),_n!==void 0&&p.jsx(V,{css:i.meterTrack,children:p.jsx(V,{css:i.meterFill,style:{width:`${_n.max>0?Math.min(100,_n.value/_n.max*100):0}%`}})}),Bn!==void 0&&p.jsx(V,{css:i.itemMetric,children:Bn})]},fe.key)})}),Na!==null&&p.jsx(V,{css:i.selectBox,"data-mode":qr==="marquee"?"marquee":"zoom",style:{left:Na.x,top:Na.y,width:Na.w,height:Na.h},"aria-hidden":"true",children:qr==="marquee"&&Go>0&&p.jsx(V,{as:"span",css:i.selectBoxCount,children:Go})}),K!==null&&te!==null&&p.jsx(V,{css:i.hoverCard,style:{left:Math.round(K.ax),top:Math.round(K.ay),transform:`translate(${K.ax>ft.w*.6?"calc(-100% - 12px)":"12px"}, ${K.ay>ft.h*.6?"calc(-100% - 12px)":"12px"})`},onPointerEnter:ae,onPointerLeave:Y,onPointerMove:fe=>fe.stopPropagation(),onPointerDown:fe=>fe.stopPropagation(),children:p.jsx(mn,{value:te,storageKey:`${n}.hover.${K.kind}`})}),p.jsxs(V,{css:i.controls,children:[p.jsxs(V,{css:i.controlGroup,children:[p.jsx(V,{as:"button",css:i.controlButton,...Cr==="grab"?{"data-active":""}:{},"aria-label":"Grab / pan tool","aria-pressed":Cr==="grab",title:"Grab — drag to pan (hold Space)",onClick:()=>Aa("grab"),children:p.jsx(Ut,{icon:Pae})}),p.jsx(V,{as:"button",css:i.controlButton,...Cr==="zoom"?{"data-active":""}:{},"aria-label":"Zoom-region tool","aria-pressed":Cr==="zoom",title:"Zoom — drag a box to zoom in (hold Ctrl)",onClick:()=>Aa("zoom"),children:p.jsx(Ut,{icon:xVe})})]}),f&&p.jsxs(V,{css:i.controlGroup,children:[p.jsx(V,{as:"button",css:i.controlButton,...Cr==="marquee"?{"data-active":""}:{},"aria-label":"Select-region tool","aria-pressed":Cr==="marquee",title:"Select region — drag a box (Shift adds)",onClick:()=>Aa("marquee"),children:p.jsx(Ut,{icon:wDe})}),_r.size>0&&p.jsx(V,{as:"button",css:i.controlButton,"aria-label":"Clear selection",title:"Clear selection (Esc)",onClick:On,children:p.jsx(Ut,{icon:c0})})]}),(R||ie)&&p.jsxs(V,{css:i.controlGroup,children:[R&&p.jsx(V,{as:"button",css:i.controlButton,...Cr==="connect"?{"data-active":""}:{},"aria-label":"Connect tool","aria-pressed":Cr==="connect",title:"Connect — drag from item to item (Shift adds to the session)",onClick:()=>Aa("connect"),children:p.jsx(Ut,{icon:Rae})}),ie&&p.jsx(V,{as:"button",css:i.controlButton,...Cr==="move"?{"data-active":""}:{},"aria-label":"Move tool","aria-pressed":Cr==="move",title:"Move — drag an item (a selected item moves the whole selection)",onClick:()=>Aa("move"),children:p.jsx(Ut,{icon:Nae})})]}),p.jsx(V,{as:"button",css:i.controlButton,"aria-label":"Zoom in",title:"Zoom in (scroll)",onClick:()=>_1(1.5),children:p.jsx(Ut,{icon:m5})}),p.jsx(V,{as:"button",css:i.controlButton,"aria-label":"Zoom out",title:"Zoom out (scroll)",onClick:()=>_1(1/1.5),children:p.jsx(Ut,{icon:m$})}),p.jsx(V,{as:"button",css:i.controlButton,"aria-label":"Fit view",title:"Fit view (double-click)",onClick:oy,children:p.jsx(Ut,{icon:w$})}),vr&&p.jsx(V,{as:"button",css:i.controlButton,...vo?{"data-active":""}:{},"aria-label":"Layers","aria-expanded":gt,title:"Layers",onClick:()=>Ot(fe=>!fe),children:p.jsx(Ut,{icon:j$})}),_r.size>0&&p.jsxs(V,{css:i.controlGroup,children:[p.jsx(V,{as:"button",css:i.controlButton,"aria-label":"Previous item",title:"Previous item",onClick:()=>Id(-1),children:p.jsx(Ut,{icon:kd})}),p.jsx(V,{as:"button",css:i.controlButton,"aria-label":"Next item",title:"Next item",onClick:()=>Id(1),children:p.jsx(Ut,{icon:r2})})]})]}),vr&>&&p.jsxs(V,{css:i.layerPanel,onPointerDown:fe=>fe.stopPropagation(),children:[p.jsxs(V,{css:i.layerHeader,children:[p.jsx(V,{as:"span",css:i.layerTitle,children:"Layers"}),p.jsx(V,{as:"button",css:i.layerReset,onClick:Wa,children:"Show all"})]}),lr.map(fe=>{var Ee;const Le=sa.has(fe.key),He=Qt===fe.key,Je=Fe[fe.key]??vn(fe.key),at=((Ee=_(fe.tone))==null?void 0:Ee.type)??"muted";return p.jsxs(V,{css:i.layerRow,...Le?{"data-hidden":""}:{},children:[p.jsx(V,{as:"span",css:i.layerSwatch,"data-tone":at}),p.jsx(V,{as:"span",css:i.layerLabel,children:fe.label}),p.jsx(V,{as:"span",css:i.layerCount,children:Ya.get(fe.key)??0}),p.jsx(V,{as:"button",css:i.layerToggle,...He?{"data-active":""}:{},"aria-label":"Isolate layer",title:"Isolate",onClick:()=>Ma(fe.key),children:p.jsx(Ut,{icon:EOe})}),p.jsx(V,{as:"button",css:i.layerToggle,...Je?{"data-active":""}:{},"aria-label":Je?"Unlock layer":"Lock layer",title:Je?"Locked (click to unlock)":"Lock (non-selectable on canvas)",onClick:()=>fi(fe.key),children:p.jsx(Ut,{icon:Je?Jae:Wje})}),p.jsx(V,{as:"button",css:i.layerToggle,"aria-label":Le?"Show layer":"Hide layer",title:Le?"Show":"Hide",onClick:()=>Ha(fe.key),children:p.jsx(Ut,{icon:Le?loe:yae})})]},fe.key)})]}),Me!==void 0&&R5>0&&(()=>{const fe=R5*Nr,Ee=(Le,He)=>`M ${fe*Le/4} 6.5 V ${He}`;return p.jsxs(V,{css:i.scaleBar,children:[p.jsxs(V,{as:"span",css:i.scaleLabel,children:[R5," ",Me]}),p.jsx(V,{as:"svg",css:i.scaleRuler,width:fe,height:7,viewBox:`0 0 ${fe} 7`,children:p.jsx("path",{d:`M 0.5 0 V 6.5 H ${fe-.5} V 0 ${Ee(1,3)} ${Ee(2,1.5)} ${Ee(3,3)}`,fill:"none"})})]})})(),ht&&p.jsxs(V,{css:i.minimap,title:"Jump to a location",style:{width:150,height:150*l/s},onPointerDown:fe=>{fe.stopPropagation();const Ee=fe.currentTarget;Ee.setPointerCapture(fe.pointerId),Ci("cancel"),D4.current=!0,iy(Ee,fe.clientX,fe.clientY)},onPointerMove:fe=>{D4.current&&(fe.stopPropagation(),iy(fe.currentTarget,fe.clientX,fe.clientY))},onPointerUp:fe=>{D4.current=!1,fe.currentTarget.releasePointerCapture(fe.pointerId)},children:[Oa.map(fe=>p.jsx(V,{css:i.minimapZone,style:{left:`${fe.x/s*100}%`,top:`${fe.y/l*100}%`,width:`${fe.width/s*100}%`,height:`${fe.height/l*100}%`}},fe.key)),ft!==null&&p.jsx(V,{css:i.minimapViewport,style:{left:`${Math.max(0,-cr.tx/Nr/s*100)}%`,top:`${Math.max(0,-cr.ty/Nr/l*100)}%`,width:`${Math.min(100,ft.w/Nr/s*100)}%`,height:`${Math.min(100,ft.h/Nr/l*100)}%`}})]})]})]})]});return ut?p.jsxs(V,{css:{...Ve.root,display:"flex",flexDirection:"column",minHeight:0,...wt!==void 0?{height:wt,maxHeight:Lt??wt}:Lt!==void 0?{maxHeight:Lt}:{}},children:[p.jsx(V,{css:{...Ve.frameEyebrow,flexShrink:0},children:Ft}),p.jsx(V,{css:{...Ve.frameBody,flex:"1 1 0%",minHeight:0,position:"relative"},children:O4})]}):O4},(e,t)=>qOn(e.value,t.value)&&e.storageKey===t.storageKey),Es=e=>e.type==="some"?e.value:void 0;function tjn(e,t,n){if(e===void 0||e<=0||n<=0)return 1.4;if(n<=t)return 2;const r=(Math.log1p(e)-Math.log1p(t))/(Math.log1p(n)-Math.log1p(t));return r>=.8?2.5:r>=.4?2:1.6}function njn(e){return e>=1e3?e.toLocaleString(void 0,{maximumFractionDigits:0}):e.toLocaleString(void 0,{maximumFractionDigits:1})}function rjn(e){return Number(e).toLocaleString()}function J8e(e,t,n){return`${e}→${t}#${n}`}function ajn(e){const t=e.lanes.map(b=>({key:b.key,label:Es(b.label)??b.key.toUpperCase()})),n=new Map(t.map((b,y)=>[b.key,y])),r=new Array(Math.max(t.length,1)).fill(0),a=[],o=new Map,i=b=>{const y=r[b]??0;return r[b]=y+1,y};for(const b of e.states){const y=n.get(b.lane)??Math.max(t.length-1,0),x={key:b.key,label:Es(b.label),laneIndex:y,laneOrder:i(y),members:Es(b.members),notes:Es(b.notes),inPlaceKeys:[],ghost:!1};a.push(x),o.set(x.key,x)}const s=[],l=e.links.map(b=>{const y=Es(b.evidence);return y?Es(y.volume):void 0}).filter(b=>b!==void 0&&b>0),c=l.length>0?Math.max(...l):0,u=l.length>0?Math.min(...l):0,d=(b,y)=>{if(o.has(b))return;const x=Math.min(Math.max(y,0),Math.max(t.length-1,0)),S={key:b,label:"No state row",laneIndex:x,laneOrder:i(x),members:void 0,notes:void 0,inPlaceKeys:[],ghost:!0};a.push(S),o.set(b,S)};let f=0,h=0,g=0;e.links.forEach((b,y)=>{var x;if(b.from===b.to){const j=o.get(b.from);j&&j.inPlaceKeys.push(Es(b.key)??J8e(b.from,b.to,y));return}const S=!o.has(b.from)||!o.has(b.to);if(S){const j=o.get(b.from)??o.get(b.to),B=j?j.laneIndex+1:0;d(b.from,B),d(b.to,B)}const z=((x=Es(b.kind))==null?void 0:x.type)??"planned",M=S?"unresolved":z;M==="planned"?f+=1:M==="observed"?h+=1:g+=1;const L=Es(b.evidence),R=L?Es(L.volume):void 0,N=L?Es(L.count):void 0,O=L?Es(L.unit):void 0;s.push({key:Es(b.key)??J8e(b.from,b.to,y),from:b.from,to:b.to,cls:M,trigger:Es(b.trigger),evidence:L,weight:M==="unresolved"?1.4:tjn(R,u,c),badgeText:R!==void 0?`${njn(R)}${O!==void 0?` ${O}`:""}${N!==void 0?` · ${rjn(N)}`:""}`:void 0})});const v=new Map;for(const b of e.triggers)v.set(b.key,{key:b.key,label:b.label,letter:Es(b.letter)??(b.label.length>0?b.label.charAt(0).toUpperCase():"?"),owner:Es(b.owner),queue:Es(b.queue)??[],outcomes:Es(b.outcomes),governs:s.filter(y=>y.trigger===b.key).map(y=>y.key)});return{lanes:t.length>0?t:[{key:"",label:""}],nodes:a,nodesByKey:o,links:s,triggers:v,counts:{total:s.length,planned:f,observed:h,unresolved:g}}}const fT=116,pT=40,ojn=8,ijn=4,epe=16,sjn=166,Sb=40,ljn=96,tpe=48,QV=78,op=3.5,M3=18,Tu=e=>Math.round(e*2)/2;function npe(e,t,n,r,a){const o=e+n/2,i=t+r/2;return{key:a,x:e,y:t,w:n,h:r,cx:o,cy:i,left:{x:e,y:i},right:{x:e+n,y:i},top:{x:o,y:t},bottom:{x:o,y:t+r}}}function Iie(e){if(e.length<2)return{d:"",segs:[]};const t=[];for(let a=0;a<e.length-1;a++){const o=e[a],i=e[a+1];t.push({a:o,b:i})}const n=e[0];let r=`M${Tu(n.x)} ${Tu(n.y)}`;for(let a=1;a<e.length;a++){const o=e[a-1],i=e[a],s=e[a+1];if(s===void 0){r+=`L${Tu(i.x)} ${Tu(i.y)}`;break}const l=Math.abs(i.x-o.x)+Math.abs(i.y-o.y),c=Math.abs(s.x-i.x)+Math.abs(s.y-i.y),u=Math.max(ijn,Math.min(ojn,l/2,c/2)),d=Math.sign(i.x-o.x),f=Math.sign(i.y-o.y),h=Math.sign(s.x-i.x),g=Math.sign(s.y-i.y);r+=`L${Tu(i.x-d*u)} ${Tu(i.y-f*u)}`,r+=`Q${Tu(i.x)} ${Tu(i.y)} ${Tu(i.x+h*u)} ${Tu(i.y+g*u)}`}return{d:r,segs:t}}function oZe(e){if(e.length<2)return e;const t=e.map(i=>({...i})),n=t[0],r=t[1];n.x+=Math.sign(r.x-n.x)*op,n.y+=Math.sign(r.y-n.y)*op;const a=t[t.length-1],o=t[t.length-2];return a.x+=Math.sign(o.x-a.x)*op,a.y+=Math.sign(o.y-a.y)*op,t}function cjn(e){let t,n=-1;for(const r of e){const a=Math.abs(r.b.x-r.a.x)+Math.abs(r.b.y-r.a.y);a>n&&(n=a,t=r)}return t?{x:(t.a.x+t.b.x)/2,y:(t.a.y+t.b.y)/2}:{x:0,y:0}}const oS={left:{x:-1,y:0},right:{x:1,y:0},top:{x:0,y:-1},bottom:{x:0,y:1}},rpe=["left","right","top","bottom"];function iZe(e){const t=[];for(const n of e){const r=t.length;if(!(r>0&&t[r-1].x===n.x&&t[r-1].y===n.y)){if(r>1){const a=t[r-2],o=t[r-1];if(a.x===o.x&&o.x===n.x||a.y===o.y&&o.y===n.y){t[r-1]=n;continue}}t.push(n)}}return t}function sZe(e,t){let n;for(const r of rpe)for(const a of rpe){const o=e[r],i=t[a],s=oS[r],l=oS[a],c=s.x*(t.cx-o.x)+s.y*(t.cy-o.y)>0,u=l.x*(e.cx-i.x)+l.y*(e.cy-i.y)>0;if(!c||!u)continue;const d=Math.abs(o.x-i.x)+Math.abs(o.y-i.y);(n===void 0||d<n.d)&&(n={sa:r,sb:a,d})}return n??{sa:"right",sb:"left"}}function lZe(e,t,n,r,a){const o=e[n],i=t[r],s=oS[n],l=oS[r];let c;if(s.x!==0&&l.x!==0){const u=a??(o.x+i.x)/2;c=o.y===i.y?[o,i]:[o,{x:u,y:o.y},{x:u,y:i.y},i]}else if(s.y!==0&&l.y!==0){const u=(o.y+i.y)/2;c=o.x===i.x?[o,i]:[o,{x:o.x,y:u},{x:i.x,y:u},i]}else s.x!==0?c=[o,{x:i.x,y:o.y},i]:c=[o,{x:o.x,y:i.y},i];return iZe(c)}function ujn(e,t){const{sa:n,sb:r}=sZe(e,t);return Iie(oZe(lZe(e,t,n,r))).d}function djn(e,t,n){const r=e[t],a=oS[t];let o;if(a.x!==0){const i=(r.x+n.x)/2;o=Math.abs(n.y-r.y)<2?[r,n]:[r,{x:i,y:r.y},{x:i,y:n.y},n]}else{const i=(r.y+n.y)/2;o=Math.abs(n.x-r.x)<2?[r,n]:[r,{x:r.x,y:i},{x:n.x,y:i},n]}if(o=iZe(o),o.length>=2){const i=o[0],s=o[1];o[0]={x:i.x+Math.sign(s.x-i.x)*op,y:i.y+Math.sign(s.y-i.y)*op}}return Iie(o).d}function fjn(e,t){const n=new Map,r=new Map;for(const a of e){const o=t(a.from),i=t(a.to);if(!o||!i||o.laneIndex===i.laneIndex)continue;const s=o.laneIndex<i.laneIndex?i.laneIndex:i.laneIndex+1;let l=n.get(s);l===void 0&&(l=new Map,n.set(s,l)),l.set(a.key,l.size),r.set(s,l.size)}return{order:n,count:r}}const ape=(e,t,n)=>e.x-n<t.x+t.w&&e.x+e.w+n>t.x&&e.y-n<t.y+t.h&&e.y+e.h+n>t.y;function pjn(e,t){var n;const r=t.orientation==="TD",a=r?pT:fT,o=r?fT:pT,i=r?112:sjn,s=J=>r?{x:J.y,y:J.x}:J,l=Math.max(e.lanes.length,1),c=Math.max(1,...e.nodes.map(J=>J.laneOrder+1));let u=r?168:ljn;if(r){const J=t.width-Sb-16-tpe;J>c*u&&(u=Math.min(260,Math.floor(J/c)))}const d=r?Number.POSITIVE_INFINITY:t.width-QV,f=Math.max(i,Number.isFinite(d)?Math.floor(d/l):i);let h=Sb+16+c*u+tpe;!r&&t.minHeight!==void 0&&(h=Math.max(h,t.minHeight-(t.legendPad??0))),r&&(h=Math.max(h,t.width));const g=l*f+QV,v=h+(r?0:t.legendPad??0),b=e.lanes.map((J,ae)=>{const ne=s({x:ae*f,y:0}),Y=s({x:(ae+1)*f,y:v});return{key:J.key,label:J.label,x:Math.min(ne.x,Y.x),y:Math.min(ne.y,Y.y),w:Math.abs(Y.x-ne.x),h:Math.abs(Y.y-ne.y),tinted:ae%2===1,cx:ae*f+f/2}}),y=new Map,x=new Map;for(const J of e.nodes){const ne=Math.min(J.laneIndex,l-1)*f+f/2-a/2,Y=Sb+16+J.laneOrder*u;x.set(J.key,npe(ne,Y,a,o,J.key));const te=s({x:ne,y:Y});y.set(J.key,npe(te.x,te.y,fT,pT,J.key))}const S=r?g:h,z=new Map;for(let J=0;J<e.lanes.length;J++){const ae=e.nodes.reduce((ue,oe)=>oe.laneIndex===J?Math.max(ue,oe.laneOrder+1):ue,0),Y=J*f+f/2-a/2,te=Sb+16+ae*u,ie=s({x:Y,y:te});z.set(e.lanes[J].key,{x:ie.x,y:ie.y,w:fT,h:pT})}const M=fjn(e.links,J=>e.nodesByKey.get(J)),L=(J,ae)=>{const ne=(J-1)*f+f/2+a/2,Y=J*f+f/2-a/2,ie=((M.count.get(J)??1)-1)*epe;return(ne+Y)/2-ie/2+ae*epe},R=J=>r?J==="left"?"top":J==="right"?"bottom":J==="top"?"left":"right":J,N=new Map,O=(J,ae,ne)=>{let Y=N.get(J);Y===void 0&&(Y=new Map,N.set(J,Y));const te=R(ae),ie=Y.get(te)??[];ie.push(ne),Y.set(te,ie)},j=[];for(const J of e.links){const ae=x.get(J.from),ne=x.get(J.to);if(!ae||!ne)continue;const Y=e.nodesByKey.get(J.from),te=e.nodesByKey.get(J.to),ie=sZe(ae,ne),ue=ie.sa,oe=ie.sb,ve=ae[ue],se=ne[oe];let pe;if(ue!==oe&&(ue==="left"||ue==="right")&&(oe==="left"||oe==="right")&&Y.laneIndex!==te.laneIndex){const Te=Y.laneIndex<te.laneIndex?te.laneIndex:te.laneIndex+1,Be=(n=M.order.get(Te))==null?void 0:n.get(J.key);Be!==void 0&&(pe=L(Te,Be))}const de=lZe(ae,ne,ue,oe,pe);O(J.from,ue,J.key),O(J.to,oe,J.key);const ge=oZe(de.map(s)),{d:ye}=Iie(ge),me=[],Me=de.map(s);for(let Te=0;Te<Me.length-1;Te++)me.push({a:Me[Te],b:Me[Te+1]});j.push({key:J.key,d:ye,end:s(se),segs:me,mid:cjn(me),ports:[s(ve),s(se)]})}const B=new Map;for(const[J,ae]of N){const ne=y.get(J);if(!ne)continue;const Y=[];for(const[te,ie]of ae)Y.push({side:te,pt:ne[te],links:ie});B.set(J,Y)}const H=J=>J.length*5.8+14,K=[...y.values()].map(J=>({x:J.x,y:J.y,w:J.w,h:J.h}));r?K.push({x:0,y:0,w:108,h:S}):K.push({x:0,y:0,w:g,h:Sb});for(const J of B.values())for(const ae of J)K.push({x:ae.pt.x-6,y:ae.pt.y-6,w:12,h:12});for(const J of e.links){if(J.trigger===void 0)continue;const ae=j.find(ne=>ne.key===J.key);ae&&K.push({x:ae.mid.x-14,y:ae.mid.y-14,w:28,h:28})}for(const J of e.links){if(J.badgeText===void 0)continue;const ae=j.find(ie=>ie.key===J.key);if(!ae)continue;const ne=H(J.badgeText),Y=[...ae.segs].sort((ie,ue)=>Math.abs(ue.b.x-ue.a.x)+Math.abs(ue.b.y-ue.a.y)-(Math.abs(ie.b.x-ie.a.x)+Math.abs(ie.b.y-ie.a.y)));let te;e:for(const ie of Y){const ue=Math.abs(ie.b.x-ie.a.x)<Math.abs(ie.b.y-ie.a.y);for(const oe of[.5,.32,.68]){const ve=ie.a.x+(ie.b.x-ie.a.x)*oe,se=ie.a.y+(ie.b.y-ie.a.y)*oe,pe=ue?{x:ve,y:se}:{x:ve,y:se-M3/2-4},de={x:pe.x-ne/2,y:pe.y-M3/2,w:ne,h:M3};if(!K.some(ge=>ape(de,ge,4))){te=pe;break e}}}if(te===void 0){const ie=Y[0],ue=Math.abs(ie.b.x-ie.a.x)<Math.abs(ie.b.y-ie.a.y);e:for(const oe of[22,-22,40,-40,58,-58,76,-76,94,-94,112,-112]){const ve=ue?{x:ae.mid.x+oe,y:ae.mid.y}:{x:ae.mid.x,y:ae.mid.y+oe},se={x:ve.x-ne/2,y:ve.y-M3/2,w:ne,h:M3};if(!K.some(pe=>ape(se,pe,4))){te=ve;break e}}te??(te={x:ae.mid.x,y:ae.mid.y+26})}ae.badge=te,K.push({x:te.x-ne/2,y:te.y-M3/2,w:ne,h:M3})}const U=s({x:l*f+8,y:14}),Z=s({x:l*f+QV-8,y:v-14}),G=r?h:g,W=(r?g:h)+(t.legendPad??0);return{width:G,height:W,orientation:t.orientation,lanes:b,nodes:y,routes:j,handles:B,laneGhosts:z,laneTail:{x:Math.min(U.x,Z.x),y:Math.min(U.y,Z.y),w:Math.abs(Z.x-U.x),h:Math.abs(Z.y-U.y)}}}const hT=14;function hjn(e,t,n){let r=null;for(const[a,o]of e.nodes)a!==n&&t.x>=o.x-hT&&t.x<=o.x+o.w+hT&&t.y>=o.y-hT&&t.y<=o.y+o.h+hT&&(r=a);return r}function gjn(e,t,n){var r;return(r=e.links.find(a=>a.from===t&&a.to===n))==null?void 0:r.key}function mjn(e,t){for(const n of e.lanes)if(t.x>=n.x&&t.x<=n.x+n.w&&t.y>=n.y&&t.y<=n.y+n.h)return n.key;return null}const vjn=it(zte.Types.Flowchart);function P2(e,t){queueMicrotask(()=>{try{const n=t();n instanceof Promise&&n.catch(r=>console.error(`[Flowchart] ${e} callback failed:`,r))}catch(n){console.error(`[Flowchart] ${e} callback failed:`,n)}})}const zm="var(--fc-ink)",yjn="var(--fc-ink3)",Yh="var(--fc-ink4)",Cb="var(--fc-paper)",bjn="var(--fc-lane)",cZe="var(--fc-rule-strong)",C9="var(--fc-info)",JV="var(--fc-brand)",T3="var(--fc-brand-d)",xjn="var(--fc-brand-dd)",k9="var(--fc-neg)",wjn={planned:zm,observed:C9,unresolved:k9},Sjn={planned:void 0,observed:"5 4",unresolved:"4 4"},Cjn={planned:"ink",observed:"info",unresolved:"neg"},kb="var(--chakra-fonts-mono)",kjn=400,zjn=250,gT=1,oX=.45,Mjn=.15,Tjn={active:!1,restLevel:oX,nodes:new Set,links:new Set};function Ejn(e,t){if(t===null)return Tjn;const n=new Set,r=new Set;if(t.kind==="state"){n.add(t.key);for(const o of e.links)(o.from===t.key||o.to===t.key)&&(r.add(o.key),n.add(o.from),n.add(o.to));return{active:!0,restLevel:oX,nodes:n,links:r}}if(t.kind==="link"){const o=e.links.find(i=>i.key===t.key);return o&&(r.add(o.key),n.add(o.from),n.add(o.to)),{active:!0,restLevel:oX,nodes:n,links:r}}const a=e.triggers.get(t.key);if(a){for(const o of a.governs){r.add(o);const i=e.links.find(s=>s.key===o);i&&(n.add(i.from),n.add(i.to))}for(const o of a.queue)n.add(o)}return{active:!0,restLevel:Mjn,nodes:n,links:r}}function _jn(e,t){return e.some(n=>n.key===t)?T3:e.length>0&&e.every(n=>n.cls==="observed")?C9:e.length>0&&e.every(n=>n.cls==="unresolved")?k9:zm}function Ljn(e,t){return t?{stroke:T3,dash:void 0,text:xjn}:e==="observed"?{stroke:C9,dash:"4 3",text:C9}:e==="unresolved"?{stroke:k9,dash:"4 3",text:k9}:{stroke:cZe,dash:void 0,text:zm}}const Rjn=C.memo(function({value:t,storageKey:n}){var r,a,o;const i=en({key:"flowchart"})(),s=C.useMemo(()=>ajn(t),[t]),l=((r=_(t.orientation))==null?void 0:r.type)??"LR",c=_(t.freshness),u=_(t.legend)??!0,d=_(t.minimap),f=(a=_(t.density))==null?void 0:a.type,h=Tt(_(t.height)),g=Tt(_(t.maxHeight)),v=(o=_(t.linkMode))==null?void 0:o.type,b=_(t.readOnly)??!1,y=C.useMemo(()=>_(t.onSelectState),[t.onSelectState]),x=C.useMemo(()=>_(t.onSelectLink),[t.onSelectLink]),S=C.useMemo(()=>_(t.onSelectTrigger),[t.onSelectTrigger]),z=C.useMemo(()=>_(t.onTracePath),[t.onTracePath]),M=C.useMemo(()=>_(t.onAddLane),[t.onAddLane]),L=C.useMemo(()=>_(t.onRenameLane),[t.onRenameLane]),R=C.useMemo(()=>_(t.onDeleteLane),[t.onDeleteLane]),N=C.useMemo(()=>_(t.onAddState),[t.onAddState]),O=C.useMemo(()=>_(t.onEditState),[t.onEditState]),j=C.useMemo(()=>_(t.onMoveState),[t.onMoveState]),B=N!==void 0&&!b,H=O!==void 0&&!b,K=j!==void 0&&!b,U=C.useMemo(()=>_(t.onCreateLink),[t.onCreateLink]),Z=C.useMemo(()=>_(t.onDeleteLink),[t.onDeleteLink]),G=C.useMemo(()=>_(t.canConnect),[t.canConnect]),W=C.useMemo(()=>_(t.stateHover),[t.stateHover]),J=C.useMemo(()=>_(t.linkHover),[t.linkHover]),ae=C.useMemo(()=>_(t.triggerHover),[t.triggerHover]),ne=_(t.slice),Y=ne==null?void 0:ne.slice,te=rl(Y==null?void 0:Y.key),ie=C.useMemo(()=>(ne==null?void 0:ne.affordances.map(Fe=>Fe.type))??[],[ne]),ue=C.useMemo(()=>Y!==void 0?p.jsx(AL.Provider,{value:"compact",children:p.jsx(zd,{slice:Y,affordanceKinds:ie})}):null,[Y,ie,te]),oe=Y!==void 0?Number(Y.totalCount()):void 0,ve=Y!==void 0?Number(Y.resultCount()??Y.totalCount()):void 0,[se,pe]=C.useState(l);C.useEffect(()=>{pe(l)},[l]);const[de,ge]=C.useState(null),ye=C.useRef(null);ye.current=de;const me=C.useRef(!1);me.current=b;const[Me,Te]=C.useState(null),[Be,ht]=C.useState(null),De=C.useRef(null),Qe=C.useRef(null),bt=C.useCallback(()=>{De.current!==null&&(clearTimeout(De.current),De.current=null),Qe.current!==null&&(clearTimeout(Qe.current),Qe.current=null)},[]);C.useEffect(()=>bt,[bt]);const Ve=C.useCallback(Fe=>Fe==="state"?W:Fe==="link"?J:ae,[W,J,ae]),ut=C.useCallback((Fe,Qt,tt,gt)=>{Ve(Fe)!==void 0&&(bt(),De.current=setTimeout(()=>{De.current=null,ht({kind:Fe,key:Qt,ax:tt,ay:gt})},kjn))},[bt,Ve]),_t=C.useCallback(()=>{De.current!==null&&(clearTimeout(De.current),De.current=null),Qe.current===null&&(Qe.current=setTimeout(()=>{Qe.current=null,ht(null)},zjn))},[]),Ft=C.useCallback(()=>{Qe.current!==null&&(clearTimeout(Qe.current),Qe.current=null)},[]),wt=C.useMemo(()=>{if(Be===null)return null;const Fe=Ve(Be.kind);if(Fe===void 0)return null;try{return Fe(Be.key)}catch(Qt){return console.error("[Flowchart] hover content builder failed:",Qt),null}},[Be,Ve]),[Lt,Jt]=C.useState(null),Dt=C.useRef(null);Dt.current=Lt;const[Et,Gt]=C.useState(null),[Ke,Se]=C.useState(null),[Re,qe]=C.useState(null),[Ye,$e]=C.useState(null),[lt,Pe]=C.useState(null),ot=C.useRef(null);ot.current=lt;const kt=C.useRef(!1);C.useEffect(()=>{if(Et===null)return;const Fe=setTimeout(()=>Gt(null),1100);return()=>clearTimeout(Fe)},[Et]);const Mt=C.useRef(null),[At,fn]=C.useState(null);C.useLayoutEffect(()=>{const Fe=Mt.current;if(!Fe)return;const Qt=()=>fn({w:Fe.clientWidth,h:Fe.clientHeight});Qt();const tt=new ResizeObserver(Qt);return tt.observe(Fe),()=>tt.disconnect()},[]);const rt=C.useMemo(()=>At===null?null:pjn(s,{width:At.w,orientation:se,legendPad:u?122:0,minHeight:h!==void 0&&At.h>0?At.h:void 0}),[s,At,se,u,h]),ln=C.useMemo(()=>Ejn(s,Me),[s,Me]),Mn=Fe=>ln.active?ln.nodes.has(Fe)?gT:ln.restLevel:gT,Jn=Fe=>ln.active?ln.links.has(Fe)?gT:ln.restLevel:gT,Er=(de==null?void 0:de.kind)==="link"?de.key:null,_r=Fe=>Fe?"opacity 150ms ease":void 0,fr=C.useCallback(Fe=>{ge(Fe),Fe!==null&&(Fe.kind==="state"&&y&&P2("onSelectState",()=>y(Fe.key)),Fe.kind==="link"&&x&&P2("onSelectLink",()=>x(Fe.key)),Fe.kind==="trigger"&&S&&P2("onSelectTrigger",()=>S(Fe.key)))},[y,x,S]);C.useEffect(()=>{const Fe=Qt=>{var tt;if(Qt.key==="Escape")ge(null),Te(null),ht(null),Jt(null);else if((Qt.key==="Delete"||Qt.key==="Backspace")&&((tt=ye.current)==null?void 0:tt.kind)==="link"&&Z&&!me.current){const gt=ye.current.key;P2("onDeleteLink",()=>Z(gt))}};return window.addEventListener("keydown",Fe),()=>window.removeEventListener("keydown",Fe)},[Z]);const Vr=C.useCallback((Fe,Qt)=>{if(!G)return!0;try{return G(Fe,Qt)!==!1}catch(tt){return console.error("[Flowchart] canConnect failed (allowing):",tt),!0}},[G]),wr=C.useCallback(Fe=>{var Qt;const tt=(Qt=Mt.current)==null?void 0:Qt.querySelector("[data-flowchart-canvas]"),gt=tt==null?void 0:tt.getBoundingClientRect();return gt?{x:Fe.clientX-gt.left,y:Fe.clientY-gt.top}:{x:0,y:0}},[]),pa=C.useCallback((Fe,Qt,tt)=>{if(v===void 0||b)return;tt.preventDefault(),tt.stopPropagation();const gt=wr(tt);Jt({from:Fe,side:Qt,x:gt.x,y:gt.y,over:null,allowed:!1,dup:void 0});const Ot=Bt=>{var vn;const wn=wr(Bt),Or=((vn=Dt.current)==null?void 0:vn.from)??Fe,Zr=rt?hjn(rt,wn):null,qn=Zr!==null?gjn(s,Or,Zr):void 0,ca=Zr!==null&&qn===void 0&&Vr(Or,Zr);Jt(sa=>sa===null?sa:{...sa,x:wn.x,y:wn.y,over:Zr,allowed:ca,dup:qn})},yn=()=>{window.removeEventListener("pointermove",Ot),window.removeEventListener("pointerup",yn);const Bt=Dt.current;if(Jt(null),!(!Bt||Bt.over===null)){if(Bt.dup!==void 0){Gt(vn=>({from:Bt.from,to:Bt.over,seq:((vn==null?void 0:vn.seq)??0)+1}));return}if(Bt.allowed&&U){const vn={from:Bt.from,to:Bt.over};P2("onCreateLink",()=>U(vn)),Gt(wn=>({from:Bt.from,to:Bt.over,seq:((wn==null?void 0:wn.seq)??0)+1}))}}};window.addEventListener("pointermove",Ot),window.addEventListener("pointerup",yn)},[v,b,wr,rt,s,Vr,U]),ar=C.useCallback((Fe,Qt)=>{if(!K)return;const tt=wr(Qt);let gt=!1;kt.current=!1;const Ot=Bt=>{const vn=wr(Bt);if(!gt){if(Math.abs(vn.x-tt.x)+Math.abs(vn.y-tt.y)<5)return;gt=!0,kt.current=!0,bt(),ht(null)}const wn=rt?mjn(rt,vn):null;Pe({key:Fe,x:vn.x,y:vn.y,overLane:wn})},yn=()=>{var Bt;window.removeEventListener("pointermove",Ot),window.removeEventListener("pointerup",yn);const vn=ot.current;if(Pe(null),!gt||vn===null||vn.overLane===null)return;const wn=s.nodesByKey.get(Fe),Or=wn!==void 0?(Bt=s.lanes[wn.laneIndex])==null?void 0:Bt.key:void 0;if(vn.overLane!==Or&&j){const Zr={key:Fe,lane:vn.overLane};P2("onMoveState",()=>j(Zr))}};window.addEventListener("pointermove",Ot),window.addEventListener("pointerup",yn)},[K,wr,rt,s,j,bt]),On=C.useMemo(()=>new Map(s.links.map(Fe=>[Fe.key,Fe])),[s]),st=d??s.nodes.length>=25,dn=C.useMemo(()=>{if(!rt)return[];const Fe=[],Qt=[],tt=[];for(const gt of rt.routes){const Ot=On.get(gt.key);Ot&&(gt.key===Er?tt.push(gt):Ot.cls==="planned"?Fe.push(gt):Qt.push(gt))}return[...Fe,...Qt,...tt]},[rt,On,Er]);if(s.nodes.length===0&&s.links.length===0)return p.jsx(V,{css:i.root,"data-flowchart-root":!0,style:{height:h,maxHeight:g}});const Pn=p.jsxs(V,{css:i.eyebrow,"data-flowchart-eyebrow":!0,children:[p.jsx(V,{css:i.eyebrowLeft,children:ue}),p.jsxs(V,{css:i.eyebrowRight,children:[p.jsxs(V,{css:i.orientationSegment,role:"group","aria-label":"Orientation",children:[p.jsxs("button",{type:"button","data-active":se==="LR"||void 0,onClick:()=>pe("LR"),children:[p.jsx(Ut,{icon:Nje,style:{fontSize:"9px"}})," LR"]}),p.jsxs("button",{type:"button","data-active":se==="TD"||void 0,onClick:()=>pe("TD"),children:[p.jsx(Ut,{icon:nVe,style:{fontSize:"9px"}})," TD"]})]}),c!==void 0&&p.jsxs(V,{css:i.freshnessChip,children:[p.jsx(V,{as:"span",css:i.freshnessDot}),p.jsx(V,{as:"span",children:c.label}),_(c.date)!==void 0&&p.jsx(V,{as:"span",css:i.freshnessDate,children:_(c.date).toLocaleDateString(void 0,{day:"2-digit",month:"short",timeZone:"UTC"})})]})]})]}),Hn=t.links.length,pr=oe!==void 0&&ve!==void 0&&ve<oe,Hr=pr?Math.round((1-ve/oe)*100):void 0,lr=p.jsxs(V,{css:i.footer,"data-flowchart-footer":!0,children:[p.jsx(V,{as:"span",css:i.footerStrong,children:Hn}),p.jsx(V,{as:"span",children:Hn===1?"link":"links"}),pr&&p.jsxs(p.Fragment,{children:[p.jsxs(V,{as:"span",children:["· narrowed from ",oe.toLocaleString()," ·"]}),p.jsxs(V,{as:"span",css:i.footerNeg,children:["−",Hr,"%"]})]}),p.jsxs(V,{css:i.footerSplit,children:[s.counts.planned," planned · ",s.counts.observed," observed",s.counts.unresolved>0?` · ${s.counts.unresolved} unresolved`:""]})]}),vr=h===void 0&&rt!==null?rt.height:void 0,mo=p.jsxs(V,{ref:Mt,css:i.body,"data-flowchart-body":!0,style:vr!==void 0?{height:vr,flex:"0 0 auto"}:void 0,children:[rt!==null&&p.jsx(V,{css:i.scroll,children:p.jsxs(V,{css:i.canvasWrap,style:{width:rt.width,height:rt.height},children:[p.jsxs("svg",{"data-flowchart-canvas":!0,width:rt.width,height:rt.height,viewBox:`0 0 ${rt.width} ${rt.height}`,style:{position:"absolute",inset:0,display:"block"},children:[p.jsx("defs",{children:[["ink",zm],["info",C9],["neg",k9],["brand",T3]].map(([Fe,Qt])=>p.jsx("marker",{id:`fc-mk-${Fe}-${n}`,viewBox:"0 0 10 10",refX:10,refY:5,markerWidth:12,markerHeight:12,markerUnits:"userSpaceOnUse",orient:"auto",children:p.jsx("path",{d:"M0 0L10 5L0 10z",fill:Qt})},Fe))}),rt.lanes.map(Fe=>Fe.tinted&&p.jsx("rect",{x:Fe.x,y:Fe.y,width:Fe.w,height:Fe.h,fill:bjn},Fe.key)),B&&rt.lanes.map(Fe=>p.jsx("rect",{x:Fe.x,y:Fe.y,width:Fe.w,height:Fe.h,fill:"transparent",onPointerEnter:()=>qe(Fe.key),onPointerLeave:()=>qe(Qt=>Qt===Fe.key?null:Qt)},`bandhit-${Fe.key}`)),lt!==null&<.overLane!==null&&(()=>{const Fe=rt.lanes.find(Qt=>Qt.key===lt.overLane);return Fe?p.jsxs("g",{style:{pointerEvents:"none"},children:[p.jsx("rect",{x:Fe.x,y:Fe.y,width:Fe.w,height:Fe.h,fill:JV,opacity:.07}),p.jsx("rect",{x:Fe.x+2,y:Fe.y+2,width:Fe.w-4,height:Fe.h-4,fill:"none",stroke:T3,strokeDasharray:"6 4",strokeWidth:1.5})]}):null})(),rt.lanes.map(Fe=>{const Qt=rt.orientation==="TD",tt=Qt?12:Fe.cx,gt=Qt?Fe.y+24:26,Ot=L!==void 0&&!b,yn=R!==void 0&&!b,Bt=Fe.label.length*8.2,vn=Qt?tt+Bt+12:tt+Bt/2+14;return p.jsxs("g",{children:[p.jsx("text",{x:tt,y:gt,textAnchor:Qt?"start":"middle",style:{fontFamily:kb,fontSize:10,fontWeight:600,letterSpacing:"2.2px",fill:Yh,cursor:Ot?"text":void 0},"data-flowchart-lane":Fe.key,onClick:Ot?()=>Se({key:Fe.key,label:Fe.label}):void 0,children:Fe.label.toUpperCase()}),yn&&p.jsx("text",{x:vn,y:gt,textAnchor:"start","data-flowchart-lane-delete":Fe.key,style:{fontSize:11,fill:Yh,cursor:"pointer"},onClick:()=>P2("onDeleteLane",()=>R(Fe.key)),children:"×"})]},Fe.key)}),M!==void 0&&!b&&p.jsxs("g",{"data-flowchart-addlane":!0,style:{cursor:"pointer"},onClick:()=>P2("onAddLane",()=>M()),children:[p.jsx("rect",{x:rt.laneTail.x,y:rt.laneTail.y,width:rt.laneTail.w,height:rt.laneTail.h,rx:6,fill:"transparent",stroke:cZe,strokeDasharray:"4 4"}),rt.orientation==="TD"?p.jsxs(p.Fragment,{children:[p.jsx("text",{x:rt.laneTail.x+rt.laneTail.w/2-8,y:rt.laneTail.y+rt.laneTail.h/2+5,textAnchor:"end",style:{fontSize:14,fill:Yh},children:"+"}),p.jsx("text",{x:rt.laneTail.x+rt.laneTail.w/2,y:rt.laneTail.y+rt.laneTail.h/2+4,textAnchor:"start",style:{fontFamily:kb,fontSize:9,letterSpacing:"2px",fill:Yh},children:"LANE"})]}):p.jsxs(p.Fragment,{children:[p.jsx("text",{x:rt.laneTail.x+rt.laneTail.w/2,y:rt.laneTail.y+30,textAnchor:"middle",style:{fontSize:14,fill:Yh},children:"+"}),p.jsx("text",{x:rt.laneTail.x+rt.laneTail.w/2,y:rt.laneTail.y+52,textAnchor:"middle",style:{fontFamily:kb,fontSize:9,letterSpacing:"2px",fill:Yh},children:"LANE"})]})]}),p.jsx("g",{"data-flowchart-links":!0,children:dn.map(Fe=>{const Qt=On.get(Fe.key),tt=Fe.key===Er,gt=Jn(Fe.key);return p.jsxs("g",{style:{opacity:gt,transition:_r(ln.active)},children:[tt&&p.jsx("path",{d:Fe.d,fill:"none",stroke:JV,strokeWidth:9,opacity:.16,strokeLinecap:"round"}),p.jsx("path",{d:Fe.d,fill:"none",stroke:tt?T3:wjn[Qt.cls],strokeWidth:tt?3:Qt.weight,strokeDasharray:Sjn[Qt.cls],markerEnd:`url(#fc-mk-${tt?"brand":Cjn[Qt.cls]}-${n})`}),p.jsx("path",{d:Fe.d,"data-flowchart-link":Fe.key,fill:"none",stroke:"transparent",strokeWidth:12,style:{cursor:"pointer"},onPointerEnter:Ot=>{Te({kind:"link",key:Fe.key});const yn=wr(Ot);ut("link",Fe.key,yn.x,yn.y)},onPointerLeave:()=>{Te(null),_t()},onClick:Ot=>{if(Ot.altKey&&z){P2("onTracePath",()=>z(Fe.key));return}fr({kind:"link",key:Fe.key})}})]},Fe.key)})}),dn.map(Fe=>{const Qt=On.get(Fe.key),tt=Qt.trigger!==void 0?s.triggers.get(Qt.trigger):void 0;return tt===void 0?null:p.jsx("g",{style:{opacity:Jn(Fe.key),transition:_r(ln.active)},children:p.jsxs("g",{"data-flowchart-trigger":tt.key,transform:`translate(${Fe.mid.x},${Fe.mid.y}) rotate(45)`,style:{cursor:"pointer"},onPointerEnter:gt=>{Te({kind:"trigger",key:tt.key});const Ot=wr(gt);ut("trigger",tt.key,Ot.x,Ot.y)},onPointerLeave:()=>{Te(null),_t()},onClick:()=>fr({kind:"trigger",key:tt.key}),children:[p.jsx("rect",{x:-8,y:-8,width:16,height:16,rx:3,fill:Cb,stroke:T3,strokeWidth:1.4}),p.jsx("text",{transform:"rotate(-45)",y:3.5,textAnchor:"middle",style:{fontFamily:kb,fontSize:8.5,fontWeight:700,fill:T3},children:tt.letter})]})},`dia-${Fe.key}`)}),dn.map(Fe=>{const Qt=On.get(Fe.key);if(Qt.badgeText===void 0||Fe.badge===void 0)return null;const tt=Qt.badgeText.length*5.8+14,gt=Ljn(Qt.cls,Fe.key===Er);return p.jsxs("g",{style:{opacity:Jn(Fe.key),transition:_r(ln.active),pointerEvents:"none"},transform:`translate(${Fe.badge.x},${Fe.badge.y})`,children:[p.jsx("rect",{x:-tt/2,y:-M3/2,width:tt,height:M3,rx:4,fill:Cb,stroke:gt.stroke,strokeWidth:1,strokeDasharray:gt.dash}),p.jsx("text",{y:3.5,textAnchor:"middle",style:{fontFamily:kb,fontSize:10,fontWeight:600,fill:gt.text,fontVariantNumeric:"tabular-nums"},children:Qt.badgeText})]},`bdg-${Fe.key}`)})]}),[...rt.nodes.values()].map(Fe=>{const Qt=s.nodesByKey.get(Fe.key);if(!Qt)return null;const tt=(de==null?void 0:de.kind)==="state"&&de.key===Fe.key;return p.jsxs(V,{"data-flowchart-node":Fe.key,css:Qt.ghost?i.ghostNode:i.node,"data-selected":tt||void 0,style:{left:Fe.x,top:Fe.y,width:Fe.w,height:Fe.h,opacity:(lt==null?void 0:lt.key)===Fe.key?.3:Mn(Fe.key),transition:_r(ln.active)},onPointerEnter:gt=>{Te({kind:"state",key:Fe.key});const Ot=wr(gt);ut("state",Fe.key,Ot.x,Ot.y)},onPointerLeave:()=>{Te(null),_t()},onPointerDown:K?gt=>ar(Fe.key,gt):void 0,onClick:()=>{if(kt.current){kt.current=!1;return}fr({kind:"state",key:Fe.key})},onDoubleClick:H&&!Qt.ghost?()=>{$e({mode:"edit",key:Fe.key,code:Fe.key,label:Qt.label??""})}:void 0,children:[p.jsxs(V,{css:i.nodeCode,children:[Fe.key,Qt.members!==void 0&&p.jsxs(V,{as:"span",css:i.nodeBadge,children:["×",String(Qt.members)]}),Qt.inPlaceKeys.length>0&&(()=>{const gt=(de==null?void 0:de.kind)==="link"?Qt.inPlaceKeys.indexOf(de.key):-1,Ot=gt>=0?Qt.inPlaceKeys[gt]:Qt.inPlaceKeys[0];return p.jsxs(V,{as:"span",css:i.nodeBadge,"data-flowchart-inplace":Fe.key,"data-selected":gt>=0||void 0,onPointerDown:yn=>yn.stopPropagation(),onDoubleClick:yn=>yn.stopPropagation(),onClick:yn=>{yn.stopPropagation(),fr({kind:"link",key:Qt.inPlaceKeys[(gt+1)%Qt.inPlaceKeys.length]})},onPointerEnter:yn=>{const Bt=wr(yn);ut("link",Ot,Bt.x,Bt.y)},onPointerLeave:yn=>{const Bt=wr(yn);ut("state",Fe.key,Bt.x,Bt.y)},children:[p.jsx(Ut,{icon:mm,style:{fontSize:"8px"}})," ",Qt.inPlaceKeys.length]})})()]}),Qt.label!==void 0&&p.jsx(V,{css:i.nodeLabel,children:Qt.label})]},Fe.key)}),p.jsxs("svg",{width:rt.width,height:rt.height,viewBox:`0 0 ${rt.width} ${rt.height}`,style:{position:"absolute",inset:0,display:"block",pointerEvents:"none"},children:[[...rt.nodes.values()].map(Fe=>{const Qt=(Me==null?void 0:Me.kind)==="state"&&Me.key===Fe.key||(de==null?void 0:de.kind)==="state"&&de.key===Fe.key||Lt!==null,tt=rt.handles.get(Fe.key)??[],gt=new Set(tt.map(Bt=>Bt.side)),yn=Qt&&(v!==void 0&&!b)?["left","right","top","bottom"].filter(Bt=>!gt.has(Bt)):[];return p.jsxs("g",{style:{opacity:Mn(Fe.key),transition:_r(ln.active)},children:[v!==void 0&&!b&&["left","right","top","bottom"].map(Bt=>p.jsx("circle",{cx:Fe[Bt].x,cy:Fe[Bt].y,r:8,fill:"transparent",style:{pointerEvents:"all",cursor:"crosshair"},onPointerEnter:()=>Te({kind:"state",key:Fe.key}),onPointerDown:vn=>pa(Fe.key,Bt,vn)},`hit-${Bt}`)),tt.map(Bt=>{const vn=Bt.links.map(Or=>On.get(Or)).filter(Or=>Or!==void 0),wn=Qt?4.5:op;return p.jsx("circle",{cx:Bt.pt.x,cy:Bt.pt.y,r:wn,fill:Cb,stroke:_jn(vn,Er),strokeWidth:1.4},Bt.side)}),yn.map(Bt=>p.jsx("circle",{cx:Fe[Bt].x,cy:Fe[Bt].y,r:4.5,fill:Cb,stroke:zm,strokeWidth:1.4},Bt))]},`ports-${Fe.key}`)}),Lt!==null&&(()=>{const Fe=rt.nodes.get(Lt.from);if(!Fe)return null;const Qt=Lt.over!==null?rt.nodes.get(Lt.over):void 0,tt=Lt.allowed||Lt.dup!==void 0,Ot=Lt.over===Lt.from&&tt?void 0:Qt!==void 0&&tt?ujn(Fe,Qt):djn(Fe,Lt.side,{x:Lt.x,y:Lt.y});return p.jsx("g",{children:Ot!==void 0&&p.jsx("path",{d:Ot,fill:"none",stroke:Lt.over!==null&&!tt?k9:T3,strokeWidth:1.6,strokeDasharray:"5 4"})})})(),Et!==null&&dn.map(Fe=>{const Qt=On.get(Fe.key);return!Qt||Qt.from!==Et.from||Qt.to!==Et.to?null:p.jsx("path",{d:Fe.d,fill:"none",stroke:JV,strokeWidth:11,strokeLinecap:"round",opacity:0,style:{pointerEvents:"none",animation:"fc-connect-pulse 0.9s ease-out forwards"}},`pulse-${Et.seq}-${Fe.key}`)})]}),B&&Ye===null&&Re!==null&<===null&&(()=>{const Fe=rt.laneGhosts.get(Re);return Fe?p.jsx(V,{"data-flowchart-ghoststate":Re,css:i.stateGhost,style:{left:Fe.x,top:Fe.y,width:Fe.w,height:Fe.h},onPointerEnter:()=>qe(Re),onClick:()=>$e({mode:"add",lane:Re,code:"",label:""}),children:"+ state"}):null})(),Ye!==null&&(()=>{const Fe=Ye.mode==="add"?rt.laneGhosts.get(Ye.lane):rt.nodes.get(Ye.key);if(!Fe)return null;const Qt=()=>{const gt=Ye;if($e(null),!(gt===null||gt.code.trim()==="")){if(gt.mode==="add"&&N){const Ot={lane:gt.lane,key:gt.code.trim(),label:gt.label.trim()};P2("onAddState",()=>N(Ot))}else if(gt.mode==="edit"&&O){const Ot={key:gt.key,code:gt.code.trim(),label:gt.label.trim()};P2("onEditState",()=>O(Ot))}}},tt=gt=>{gt.key==="Enter"?Qt():gt.key==="Escape"&&(gt.stopPropagation(),$e(null))};return p.jsxs(V,{"data-flowchart-stateeditor":!0,css:i.stateEditor,style:{left:Fe.x,top:Fe.y,width:Fe.w,minHeight:Fe.h},onBlur:gt=>{gt.currentTarget.contains(gt.relatedTarget)||Qt()},children:[p.jsx("input",{autoFocus:!0,placeholder:"CODE",value:Ye.code,onChange:gt=>$e(Ot=>Ot===null?Ot:{...Ot,code:gt.target.value}),onKeyDown:tt}),p.jsx("input",{placeholder:"Name state…",value:Ye.label,onChange:gt=>$e(Ot=>Ot===null?Ot:{...Ot,label:gt.target.value}),onKeyDown:tt})]})})(),lt!==null&&(()=>{const Fe=s.nodesByKey.get(lt.key);return Fe?p.jsxs(V,{css:i.moveClone,style:{left:lt.x+10,top:lt.y+10},children:[p.jsx(V,{css:i.nodeCode,children:lt.key}),Fe.label!==void 0&&p.jsx(V,{css:i.nodeLabel,children:Fe.label})]}):null})(),Lt!==null&&Lt.over!==null&&(()=>{const Fe=Lt.allowed||Lt.dup!==void 0,Qt=Lt.over===Lt.from&&Fe;return!Qt&&Fe?null:p.jsx(V,{style:{position:"absolute",left:Lt.x+12,top:Lt.y-18,pointerEvents:"none",fontSize:13,color:Qt?"var(--fc-brand-d)":"var(--fc-neg)"},children:p.jsx(Ut,{icon:Qt?mm:vae})})})(),Et!==null&&Et.from===Et.to&&(()=>{const Fe=rt.nodes.get(Et.from);return Fe?p.jsx(V,{style:{position:"absolute",left:Fe.x,top:Fe.y,width:Fe.w,height:Fe.h,borderRadius:6,pointerEvents:"none",animation:"fc-node-pulse 0.9s ease-out forwards"}},`nodepulse-${Et.seq}`):null})(),Ke!==null&&(()=>{const Fe=rt.lanes.find(Ot=>Ot.key===Ke.key);if(!Fe)return null;const tt=rt.orientation==="TD"?{left:8,top:Fe.y+8,width:148}:{left:Fe.cx-74,top:8,width:148},gt=()=>{const Ot=Ke;Se(null),Ot!==null&&Ot.label.trim()!==""&&L&&P2("onRenameLane",()=>L({key:Ot.key,label:Ot.label.trim()}))};return p.jsx("input",{"data-flowchart-lane-edit":!0,autoFocus:!0,value:Ke.label,onChange:Ot=>Se(yn=>yn===null?yn:{...yn,label:Ot.target.value}),onBlur:gt,onKeyDown:Ot=>{Ot.key==="Enter"?gt():Ot.key==="Escape"&&(Ot.stopPropagation(),Se(null))},style:{position:"absolute",...tt,zIndex:11,fontFamily:"var(--chakra-fonts-mono)",fontSize:11,fontWeight:600,padding:"3px 8px",borderRadius:4,border:"1px solid var(--fc-brand-d)",background:"var(--fc-paper)",color:"inherit",outline:"none"}})})(),u&&p.jsxs(V,{css:i.legend,"data-flowchart-legend":!0,children:[p.jsx(V,{css:i.legendTitle,children:"Legend"}),p.jsxs(V,{css:i.legendRow,children:[p.jsx("svg",{width:28,height:8,children:p.jsx("line",{x1:1,y1:4,x2:27,y2:4,stroke:zm,strokeWidth:2})}),p.jsx("span",{children:"Planned"})]}),p.jsxs(V,{css:i.legendRow,children:[p.jsx("svg",{width:28,height:8,children:p.jsx("line",{x1:1,y1:4,x2:27,y2:4,stroke:C9,strokeWidth:1.6,strokeDasharray:"5 4"})}),p.jsx("span",{children:"Observed"})]}),p.jsxs(V,{css:i.legendRow,children:[p.jsx("svg",{width:28,height:16,children:p.jsx("rect",{x:9,y:3,width:10,height:10,rx:2,transform:"rotate(45 14 8)",fill:Cb,stroke:T3,strokeWidth:1.2})}),p.jsx("span",{children:"Decision trigger"})]}),p.jsxs(V,{css:i.legendRow,children:[p.jsxs(V,{as:"span",css:i.nodeBadge,children:[p.jsx(Ut,{icon:mm,style:{fontSize:"8px"}})," n"]}),p.jsx("span",{children:"In-place transition"})]})]}),st&&p.jsx(V,{css:i.minimap,"data-flowchart-minimap":!0,children:p.jsx("svg",{width:96,height:64,viewBox:`0 0 ${rt.width} ${rt.height}`,preserveAspectRatio:"xMidYMid meet",children:[...rt.nodes.values()].map(Fe=>p.jsx("rect",{x:Fe.x,y:Fe.y,width:Fe.w,height:Fe.h,rx:8,fill:"none",stroke:yjn,strokeWidth:6},Fe.key))})})]})}),Be!==null&&wt!==null&&rt!==null&&p.jsx(V,{css:i.hoverCard,"data-flowchart-hovercard":!0,style:{left:Math.min(Be.ax+14,Math.max(0,((At==null?void 0:At.w)??320)-300)),top:Be.ay+14},onPointerEnter:Ft,onPointerLeave:_t,children:p.jsx(mn,{value:wt,storageKey:`${n}.hover.${Be.kind}`})})]});return p.jsxs(V,{css:i.root,"data-flowchart-root":!0,"data-density":f,style:{height:h,maxHeight:g??h},children:[Pn,mo,lr]})},(e,t)=>vjn(e.value,t.value)&&e.storageKey===t.storageKey),Pjn=["a","b","c","d"],Ajn='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors © <a href="https://carto.com/attributions">CARTO</a>',Njn='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',$jn={positron:"light_all",darkMatter:"dark_all",voyager:"voyager"};function k4r(e){if(e.type==="carto")return{url:`https://{s}.basemaps.cartocdn.com/rastertiles/${$jn[e.value.style.type]??"light_all"}/{z}/{x}/{y}{r}.png`,attribution:Ajn,subdomains:Pjn,maxZoom:20,detectRetina:!0};if(e.type==="osm")return{url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",attribution:Njn,subdomains:["a","b","c"],maxZoom:19,detectRetina:!0};const t=e.value;return{url:t.url,attribution:t.attribution,subdomains:t.subdomains.type==="some"?t.subdomains.value:[],maxZoom:t.maxZoom.type==="some"?Number(t.maxZoom.value):19,detectRetina:t.detectRetina.type==="some"?t.detectRetina.value:!1}}const uZe={success:"success",danger:"danger",warning:"warning",info:"brand",neutral:"muted"};function dZe(e){return e.tone.type==="some"?e.tone.value.type:e.status.type==="some"?uZe[e.status.value.type]??"muted":"muted"}function Ijn(e){const t=e.status.type==="some"?e.status.value.type:void 0,n=t==="danger"?"danger":t==="warning"?"warning":t==="success"||t==="info"?"success":void 0;if(e.pulse.type==="some"){if(!e.pulse.value)return;if(n!==void 0)return n;const r=dZe(e);return r==="danger"?"danger":r==="warning"?"warning":"success"}return n}function z4r(e){const t=Ijn(e);return["elara-map-area",e.color.type==="some"?"":`elara-map-area--${dZe(e)}`,t!==void 0?`elara-map-area--pulse-${t}`:""].filter(Boolean).join(" ")}function M4r(e){return e!==void 0?`elara-map-hex-cell elara-map-area--${uZe[e]??"muted"}`:"elara-map-hex-cell elara-map-area--muted"}function fZe(e){return e.style.value.tone.type==="some"?e.style.value.tone.value.type:"brand"}function T4r(e){const t=e.flow.type==="some"&&e.flow.value;return["elara-map-line",`elara-map-line--${fZe(e)}`,t?"elara-map-line--flow":""].filter(Boolean).join(" ")}function E4r(e){return`elara-map-arrowhead elara-map-arrowhead--${fZe(e)}`}function _4r(e){return e.tone.type==="some"?`--${e.tone.value.type}`:"--brand"}function ope(e){return e==="start"?"flex-start":e==="end"?"flex-end":"center"}function Djn({compact:e,interactive:t,styles:n,children:r}){const[a,o]=C.useState(!1);return e&&t&&!a?p.jsx(Ht.button,{type:"button",css:n.overlayToggle,"aria-label":"Show map panel","aria-expanded":!1,onClick:()=>o(!0),children:p.jsx(Ut,{icon:j$})}):p.jsxs(V,{css:n.overlayItem,style:{pointerEvents:t?"auto":"none"},children:[e&&t&&p.jsx(Ht.button,{type:"button",css:n.overlayToggle,"data-dismiss":"","aria-label":"Hide map panel","aria-expanded":!0,onClick:()=>o(!1),children:p.jsx(Ut,{icon:c0})}),r]})}const Ojn=C.lazy(()=>wDt(()=>import("./engine-CkVTyL0W-BmlCdSLd.js"),[],import.meta.url)),jjn=it(cs.Types.Map),Fjn=C.memo(function({value:t,storageKey:n}){const r=en({key:"map"})(),a=_(t.height),o=a===void 0?void 0:a==="fill"?{height:"100%",maxHeight:"100%"}:{height:a,maxHeight:a},i=C.useMemo(()=>_(t.onAreaClick),[t.onAreaClick]),s=C.useMemo(()=>_(t.onMarkerClick),[t.onMarkerClick]),l=C.useMemo(()=>_(t.onZoom),[t.onZoom]),c=C.useMemo(()=>_(t.onSelect),[t.onSelect]),u=C.useMemo(()=>i?y=>{queueMicrotask(()=>i(y))}:void 0,[i]),d=C.useMemo(()=>s?y=>{queueMicrotask(()=>s(y))}:void 0,[s]),f=C.useMemo(()=>l?y=>{queueMicrotask(()=>l(y))}:void 0,[l]),h=C.useMemo(()=>c?y=>{queueMicrotask(()=>c(y))}:void 0,[c]),g=C.useRef(null),v=Rv(g,480),b=C.useMemo(()=>{const y=t.tiles.type==="carto"?`carto:${t.tiles.value.style.type}`:t.tiles.type==="custom"?`custom:${t.tiles.value.url}`:"osm",x=_(t.fitBounds);return[y,String(_(t.minZoom)??""),String(_(t.maxZoom)??""),String(_(t.scrollWheelZoom)??!0),String(_(t.attributionPrefix)??!1),x!==void 0?x.type:""].join("|")},[t.tiles,t.minZoom,t.maxZoom,t.scrollWheelZoom,t.attributionPrefix,t.fitBounds]);return p.jsxs(V,{ref:g,css:r.root,...o!==void 0?{style:o}:{},children:[p.jsx(C.Suspense,{fallback:p.jsx(V,{css:r.fallback}),children:p.jsx(Ojn,{value:t,containerClassName:"elara-map-canvas",onAreaClickFn:u,onMarkerClickFn:d,onZoomFn:f,onSelectFn:h},b)}),t.overlays.map((y,x)=>{const S=_(y.key)??String(x),z=_(y.interactive)??!0;return p.jsx(V,{css:r.overlay,style:{justifyContent:ope(y.align.type),alignItems:ope(y.verticalAlign.type)},children:p.jsx(Djn,{compact:v,interactive:z,styles:r,children:p.jsx(mn,{value:y.content,storageKey:`${n}.overlay.${S}`})})},S)})]})},(e,t)=>jjn(e.value,t.value)&&e.storageKey===t.storageKey);function Bjn({children:e}){const t=ga({key:"dropHint"});return p.jsx(V,{css:t({}),"data-drop-hint":"",children:e})}const Vjn=it(Ix.Types.Blend);function pZe(e){return e.type!=="proposed"?e.type:e.value.type}function gx(e){return Math.abs(e)>=1e3?`${Math.round(e/1e3)}k`:`${Math.round(e)}`}function Hjn({surface:e,targetKey:t,alloc:n,unit:r,capacity:a,styles:o,onAmount:i,onRemove:s}){const l=pZe(n.state),c=n.state.type==="proposed",u=c&&!n.pinned,[d,f]=C.useState(String(n.amount));C.useEffect(()=>{f(String(n.amount))},[n.amount]);const h=C.useMemo(()=>({surface:e,row:t,slot:"alloc",event:n.source}),[e,t,n.source]),g=C.useMemo(()=>p.jsx(V,{css:o.dragGhost,children:n.label}),[o.dragGhost,n.label]),v=CI(h,g,!u),b=C.useCallback(()=>{const S=Number(d);Number.isFinite(S)&&S>=0&&S!==n.amount&&i?i(n.source,S):f(String(n.amount))},[d,n.amount,n.source,i]),y=a>0?Math.round(n.amount/a*100):0,x=_(n.sublabel);return p.jsxs(V,{css:o.allocRow,"data-state":l,onPointerDown:v,...u&&v?{"data-draggable":""}:{},children:[u&&v&&p.jsx(V,{as:"span",css:o.allocGrip,"data-drag-grip":"",children:p.jsx(Ut,{icon:g5})}),p.jsxs(V,{css:o.allocBody,children:[p.jsx(V,{as:"span",css:o.allocLabel,children:n.label}),x!==void 0&&p.jsx(V,{as:"span",css:o.allocSublabel,children:x})]}),n.pinned&&p.jsx(V,{as:"span",css:o.pinBadge,title:"Pinned — held fixed",children:p.jsx(Ut,{icon:WC})}),c&&i?p.jsx(V,{as:"input",css:o.amountInput,value:d,inputMode:"decimal",onPointerDown:S=>S.stopPropagation(),onChange:S=>f(S.target.value),onBlur:b,onKeyDown:S=>{S.key==="Enter"&&S.target.blur()}}):p.jsx(V,{as:"span",css:o.amountText,children:gx(n.amount)}),p.jsxs(V,{as:"span",css:o.share,children:[r," · ",y,"%"]}),u&&s&&p.jsx(V,{as:"button",css:o.allocAction,"aria-label":"Remove allocation",title:"Remove allocation",onPointerDown:S=>S.stopPropagation(),onClick:()=>s(n.source),children:p.jsx(Ut,{icon:UC})})]})}function Wjn({surface:e,target:t,mode:n,badge:r,styles:a,vetoFor:o,onAmount:i,onRemove:s,onAction:l,compactActive:c}){const u=en({key:"commitBar"}),d=C.useMemo(()=>u({}),[u]),f=C.useMemo(()=>({surface:e,row:t.key,slot:"alloc"}),[e,t.key]),h=C.useMemo(()=>o==null?void 0:o(f),[o,f]),g=lk(f,!1,h),v=t.allocations.reduce((S,z)=>S+z.amount,0),b=Math.max(0,t.capacity-v),y=[0,.25,.5,.75,1].map(S=>S*t.capacity),x=_(t.objective);return p.jsxs(V,{ref:g,css:a.panel,"data-mode":n,...c?{"data-compact-active":""}:{},children:[p.jsxs(V,{css:a.panelHead,children:[r!==void 0&&p.jsx(V,{as:"span",css:a.panelBadge,children:r}),p.jsx(V,{as:"span",css:a.panelTitle,children:t.label}),p.jsxs(V,{as:"span",css:a.panelCap,children:["cap ",gx(t.capacity)," ",t.unit," · ",gx(b)," headroom"]})]}),p.jsxs(V,{css:a.compositionBar,children:[t.allocations.map(S=>p.jsx(V,{css:a.segment,"data-state":pZe(S.state),style:{width:`${t.capacity>0?S.amount/t.capacity*100:0}%`},title:`${S.label} · ${gx(S.amount)} ${t.unit}`},S.source)),p.jsx(V,{css:a.headroom,style:{width:`${t.capacity>0?b/t.capacity*100:100}%`}})]}),p.jsx(V,{css:a.axis,children:y.map(S=>p.jsx(V,{as:"span",css:a.axisTick,children:gx(S)},S))}),p.jsxs(V,{css:a.allocList,children:[t.allocations.map(S=>p.jsx(Hjn,{surface:e,targetKey:t.key,alloc:S,unit:t.unit,capacity:t.capacity,styles:a,onAmount:i,onRemove:s},S.source)),p.jsx(Bjn,{children:"drop a source here"})]}),t.metrics.length>0&&p.jsx(V,{css:a.metricList,children:t.metrics.map(S=>{const z=_(S.model),M=_(S.band);return p.jsxs(V,{css:a.metricRow,children:[p.jsx(V,{as:"span",css:a.metricLabel,children:S.label}),p.jsx(V,{as:"span",css:a.metricValue,children:S.value}),z!==void 0&&p.jsx(V,{as:"span",css:a.trustChip,children:z}),M!==void 0&&p.jsxs(V,{as:"span",css:a.bandText,children:["band ",M.min,"–",M.max]})]},S.key)})}),p.jsx(V,{css:a.panelFoot,children:p.jsxs(V,{css:d.root,"data-slot":"panelFoot",children:[p.jsx(V,{css:d.draft,children:x!==void 0&&p.jsxs(V,{as:"span",css:a.objective,children:["objective ",x]})}),l&&p.jsxs(V,{css:d.btnRow,children:[p.jsx(V,{as:"button",css:d.btn,onClick:()=>l("reset"),children:"Reset"}),n==="compare"&&p.jsx(V,{as:"button",css:d.btnDanger,onClick:()=>l("discard"),children:"Discard"}),p.jsx(V,{as:"button",css:d.btnPrimary,onClick:()=>l("apply"),children:"Apply blend"})]})]})})]})}const Ujn=C.memo(function({value:t}){var n;const r=en({key:"blend"})(),a=t.targets.length<=1?"single":t.targets.length===2?"compare":"portfolio",o=C.useMemo(()=>_(t.onDrag),[t.onDrag]),i=C.useMemo(()=>_(t.canDrop),[t.canDrop]),s=kI(i),l=C.useMemo(()=>_(t.onAmountChange),[t.onAmountChange]),c=C.useMemo(()=>_(t.onAction),[t.onAction]),u=_(t.verdict),[d,f]=C.useState(()=>[...t.targets]);C.useEffect(()=>{f([...t.targets])},[t.targets]);const h=C.useCallback((O,j)=>{if(O.type==="add"&&!t7(i,O))return;let B=d;if(O.type==="add"){const{from:H,into:K}=O.value;B=d.map(U=>U.key!==K.row?U:{...U,allocations:[...U.allocations,{source:H.key,label:(j==null?void 0:j.label)??H.key,sublabel:A,amount:0,pinned:!1,state:$("proposed",$("added",null))}]})}else if(O.type==="remove"){const{from:H}=O.value,K=H.event.type==="some"?H.event.value:void 0;B=d.map(U=>U.key!==H.row?U:{...U,allocations:U.allocations.filter(Z=>Z.source!==K)})}f(B),o&&queueMicrotask(()=>o(O))},[d,o,i]),g=C.useMemo(()=>({id:t.id,sources:[...t.sources],kinds:{add:!0,remove:!0},onDrag:h}),[t.id,t.sources,h]);sk(g);const v=C.useCallback(O=>(j,B)=>{f(H=>H.map(K=>K.key!==O?K:{...K,allocations:K.allocations.map(U=>U.source===j?{...U,amount:B}:U)})),l&&queueMicrotask(()=>l({target:O,source:j,amount:B}))},[l]),b=C.useCallback(O=>j=>{const B=$("remove",{from:{surface:t.id,row:O,slot:"alloc",event:P(j)},to:$("trash",null)});h(B)},[t.id,h]),y=C.useCallback(O=>j=>{c&&queueMicrotask(()=>c({target:P(O),action:$(j,null)}))},[c]),x=C.useRef(null),S=Rv(x,480),[z,M]=C.useState(null),L=S&&d.length>1,R=L?z!==null&&d.some(O=>O.key===z)?z:(n=d[0])==null?void 0:n.key:void 0,N=C.useMemo(()=>{if(a!=="compare")return[];const[O,j]=d;return O===void 0||j===void 0?[]:(t.diff.length>0?[...t.diff]:O.metrics.map(H=>H.key)).flatMap(H=>{const K=O.metrics.find(J=>J.key===H),U=j.metrics.find(J=>J.key===H);if(K===void 0&&U===void 0)return[];const Z=K!==void 0?_(K.numeric):void 0,G=U!==void 0?_(U.numeric):void 0,W=typeof Z=="number"&&typeof G=="number"?`${G-Z>=0?"+":""}${Number((G-Z).toFixed(3))}`:"—";return[{key:H,label:(K==null?void 0:K.label)??(U==null?void 0:U.label)??H,a:(K==null?void 0:K.value)??"—",b:(U==null?void 0:U.value)??"—",delta:W}]})},[a,d,t.diff]);return p.jsxs(V,{ref:x,css:r.root,"data-mode":a,children:[p.jsx(V,{css:r.targets,"data-mode":a,children:d.map((O,j)=>{const B=a==="compare"?j===0?"A":"B":void 0;return L&&O.key!==R?p.jsxs(Ht.button,{type:"button",css:r.panelRail,"aria-label":`Show ${O.label}`,onClick:()=>M(O.key),children:[B!==void 0&&p.jsx(V,{as:"span",css:r.panelBadge,children:B}),p.jsx(V,{as:"span",css:r.panelRailLabel,children:O.label})]},O.key):p.jsx(Wjn,{surface:t.id,target:O,mode:a,badge:B,styles:r,vetoFor:s,onAmount:v(O.key),onRemove:b(O.key),onAction:c?y(O.key):void 0,compactActive:L},O.key)})}),a==="compare"&&N.length>0&&p.jsxs(V,{css:r.diff,children:[p.jsxs(V,{css:r.diffRow,"data-head":"",children:[p.jsx(V,{as:"span",children:"metric"}),p.jsx(V,{as:"span",children:"target A"}),p.jsx(V,{as:"span",children:"target B"}),p.jsx(V,{as:"span",children:"Δ (B−A)"})]}),N.map(O=>p.jsxs(V,{css:r.diffRow,children:[p.jsx(V,{as:"span",children:O.label}),p.jsx(V,{as:"span",children:O.a}),p.jsx(V,{as:"span",children:O.b}),p.jsx(V,{as:"span","data-delta":"",children:O.delta})]},O.key)),u!==void 0&&p.jsx(V,{css:r.verdict,children:u})]})]})},(e,t)=>Vjn(e.value,t.value)&&e.storageKey===t.storageKey),qjn=it(Nq.Types.AvatarGroup),Gjn=C.memo(function({value:t}){var n;const r=C.useMemo(()=>_(t.style),[t.style]),a=r?(n=_(r.size))==null?void 0:n.type:void 0,o=r?_(r.borderColor):void 0,i=C.useMemo(()=>_(t.max),[t.max]),s=al(),c=C.useMemo(()=>{var h;return(h=_(t.density))==null?void 0:h.type},[t.density])??s,u=t.avatars,d=i!==void 0?Math.min(Number(i),u.length):u.length,f=u.length-d;return p.jsxs(tNt,{size:a??"xs",spaceX:"-1.5",borderColor:o??"bg.surface",children:[u.slice(0,d).map((h,g)=>{var v;const b=OXe(h),y=_(h.src),x=_(h.name),S=((v=_(h.density))==null?void 0:v.type)??c;return p.jsxs(cK,{...b,...S!==void 0?{density:S}:{},children:[p.jsx(uK,{name:x}),y&&p.jsx(YPe,{src:y})]},g)}),f>0&&p.jsx(cK,{...c!==void 0?{density:c}:{},children:p.jsxs(uK,{children:["+",f]})})]})},(e,t)=>qjn(e.value,t.value)),Kjn=it(xq.Types.Root),Yjn=C.memo(function({value:t}){var n,r,a;const o=_(t.style),i=o?(n=_(o.colorPalette))==null?void 0:n.type:void 0,s=o?(r=_(o.size))==null?void 0:r.type:void 0,c=(o?(a=_(o.orientation))==null?void 0:a.type:void 0)==="horizontal"?"horizontal":"vertical",u=o?_(o.color):void 0,d=o?_(o.fillColor):void 0,f=o?_(o.borderColor):void 0,h=_(t.onChange),g=_(t.disabled),v=_(t.required),b=_(t.name),[y,x]=C.useState(t.value);C.useEffect(()=>{x(t.value)},[t.value]);const S=C.useCallback(M=>{const L=M.value??"";x(L),h&&queueMicrotask(()=>h(L))},[h]),z=c==="horizontal"?Xr:W1;return p.jsx(K$t,{value:y,onValueChange:S,colorPalette:i??"brand",size:s,disabled:g,required:v,name:b,orientation:c,children:p.jsx(z,{gap:"3",align:c==="vertical"?"start":void 0,children:t.items.map(M=>{const L=_(M.disabled)??!1,R=_(M.label)??M.value;return p.jsxs(Y$t,{value:M.value,disabled:L||g,color:u,children:[p.jsx(Q$t,{}),p.jsx(Z$t,{borderColor:f,...d?{_checked:{color:d,borderColor:d}}:{}}),p.jsx(X$t,{children:R})]},M.value)})})})},(e,t)=>Kjn(e.value,t.value)),Xjn=it(wq.Types.Root),Zjn=C.memo(function({value:t}){var n,r,a;const o=_(t.style),i=o?(n=_(o.colorPalette))==null?void 0:n.type:void 0,s=o?(r=_(o.size))==null?void 0:r.type:void 0,l=s==="xs"?"sm":s,u=(o?(a=_(o.orientation))==null?void 0:a.type:void 0)==="horizontal"?"horizontal":"vertical",d=o?_(o.color):void 0,f=o?_(o.descriptionColor):void 0,h=o?_(o.cardBackground):void 0,g=o?_(o.selectedCardBackground):void 0,v=o?_(o.selectedBorderColor):void 0,b=_(t.onChange),y=_(t.disabled),x=_(t.required),S=_(t.name),[z,M]=C.useState(t.value);C.useEffect(()=>{M(t.value)},[t.value]);const L=C.useCallback(N=>{const O=N.value??"";M(O),b&&queueMicrotask(()=>b(O))},[b]),R=u==="horizontal"?Xr:W1;return p.jsx(j$t,{value:z,onValueChange:L,colorPalette:i??"brand",size:l,disabled:y,required:x,name:S,orientation:u,children:p.jsx(R,{gap:"3",align:u==="vertical"?"stretch":void 0,flexWrap:u==="horizontal"?"wrap":void 0,children:t.items.map(N=>{const O=_(N.disabled)??!1,j=_(N.description),B=N.value===z;return p.jsxs(F$t,{value:N.value,disabled:O||y,bg:B?g:h,borderColor:B?v:void 0,children:[p.jsx(q$t,{}),p.jsxs(H$t,{children:[p.jsxs(W$t,{children:[p.jsx(B$t,{color:d,children:N.label}),j&&p.jsx(V$t,{color:f,children:j})]}),p.jsx(U$t,{})]})]},N.value)})})})},(e,t)=>Xjn(e.value,t.value)),Qjn=it(bq.Types.Root);function Xh(e){const n=((typeof e=="bigint"?Number(e):e)%1440+1440)%1440;return new _7(Math.floor(n/60),n%60,0)}function mT(e){return BigInt(e.hour*60+e.minute)}const Jjn=C.memo(function({value:t}){var n;const r=_(t.style),a=r?_(r.color):void 0,o=r?_(r.background):void 0,i=r?_(r.borderColor):void 0,s=r?_(r.focusBorderColor):void 0,l=r?(n=_(r.size))==null?void 0:n.type:void 0,c=C.useMemo(()=>_(t.onChange),[t.onChange]),u=_(t.disabled)??!1,d=_(t.presets),[f,h]=C.useState(Xh(t.startValue)),[g,v]=C.useState(Xh(t.endValue));C.useEffect(()=>{h(Xh(t.startValue))},[t.startValue]),C.useEffect(()=>{v(Xh(t.endValue))},[t.endValue]);const b=C.useCallback(L=>{L&&(h(L),c&&queueMicrotask(()=>c(mT(L),mT(g))))},[c,g]),y=C.useCallback(L=>{L&&(v(L),c&&queueMicrotask(()=>c(mT(f),mT(L))))},[c,f]),x=C.useCallback((L,R)=>{const N=Xh(L),O=Xh(R);h(N),v(O),c&&queueMicrotask(()=>c(L,R))},[c]),S=l==="sm"||l==="xs"?"sm":l==="lg"?"lg":"md",z={...h5,display:"inline-flex",alignItems:"center",_coarse:{minHeight:"44px"},...o!==void 0?{background:o}:{},...a!==void 0?{color:a}:{},...i!==void 0?{borderColor:i}:{},opacity:u?.6:1,_focusWithin:s?{borderColor:s}:P6},M=p.jsxs(Xr,{gap:"2",align:"center",flexWrap:"wrap",children:[p.jsx(V,{css:z,children:p.jsx(p9,{value:f,onChange:b,isReadOnly:u,"aria-label":"Start time",children:p.jsx(h9,{children:({segment:L})=>p.jsx(g9,{segment:L})})})}),p.jsx(Ie,{color:"fg.muted",fontSize:S,children:"–"}),p.jsx(V,{css:z,children:p.jsx(p9,{value:g,onChange:y,isReadOnly:u,"aria-label":"End time",children:p.jsx(h9,{children:({segment:L})=>p.jsx(g9,{segment:L})})})})]});return!d||d.length===0?M:p.jsxs(W1,{gap:"2",align:"flex-start",children:[M,p.jsx(Xre,{gap:"2",children:d.map((L,R)=>p.jsx(fu,{size:"xs",variant:"subtle",disabled:u,onClick:()=>x(L.start,L.end),children:L.label},`${L.label}-${R}`))})]})},(e,t)=>Qjn(e.value,t.value)),eFn=it(yq.Types.Root);function Zh(e){return{calendar:new yi(e.getUTCFullYear(),e.getUTCMonth()+1,e.getUTCDate()),time:new _7(e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds())}}function ipe(e){return new Date(Date.UTC(e.calendar.year,e.calendar.month-1,e.calendar.day,e.time.hour,e.time.minute,e.time.second))}const tFn=C.memo(function({value:t}){var n,r;const a=_(t.style),o=a?_(a.color):void 0,i=a?_(a.background):void 0,s=a?_(a.borderColor):void 0,l=a?_(a.focusBorderColor):void 0,c=a?(n=_(a.size))==null?void 0:n.type:void 0,u=C.useMemo(()=>_(t.onChange),[t.onChange]),d=_(t.disabled)??!1,f=((r=_(t.precision))==null?void 0:r.type)??"date",h=_(t.presets),g=C.useMemo(()=>t.startValue instanceof Date?t.startValue:new Date(t.startValue),[t.startValue]),v=C.useMemo(()=>t.endValue instanceof Date?t.endValue:new Date(t.endValue),[t.endValue]),[b,y]=C.useState(()=>Zh(g)),[x,S]=C.useState(()=>Zh(v));C.useEffect(()=>{y(Zh(g))},[g]),C.useEffect(()=>{S(Zh(v))},[v]);const z=C.useRef(b),M=C.useRef(x);z.current=b,M.current=x;const L=C.useCallback(G=>{u&&queueMicrotask(()=>u(ipe(G.start),ipe(G.end)))},[u]),R=C.useCallback(G=>{if(!G)return;const W=G,J={...z.current,calendar:W};y(J),L({start:J,end:M.current})},[L]),N=C.useCallback(G=>{if(!G)return;const W={...z.current,time:G};y(W),L({start:W,end:M.current})},[L]),O=C.useCallback(G=>{if(!G)return;const W=G,J={...M.current,calendar:W};S(J),L({start:z.current,end:J})},[L]),j=C.useCallback(G=>{if(!G)return;const W={...M.current,time:G};S(W),L({start:z.current,end:W})},[L]),B=C.useCallback((G,W)=>{const J=Zh(G),ae=Zh(W);y(J),S(ae),u&&queueMicrotask(()=>u(G,W))},[u]),H=c==="sm"||c==="xs"?"sm":c==="lg"?"lg":"md",K={...h5,display:"inline-flex",alignItems:"center",gap:"{spacing.2}",_coarse:{minHeight:"44px"},...i!==void 0?{background:i}:{},...o!==void 0?{color:o}:{},...s!==void 0?{borderColor:s}:{},opacity:d?.6:1,_focusWithin:l?{borderColor:l}:P6},U=(G,W,J,ae)=>f==="time"?p.jsx(V,{css:K,children:p.jsx(p9,{value:G.time,onChange:J,isReadOnly:d,"aria-label":`${ae} time`,children:p.jsx(h9,{children:({segment:ne})=>p.jsx(g9,{segment:ne})})})}):f==="date"?p.jsx(V,{css:K,children:p.jsx(VL,{value:G.calendar,onChange:W,isReadOnly:d,"aria-label":`${ae} date`,children:p.jsx(HL,{children:({segment:ne})=>p.jsx(WL,{segment:ne})})})}):p.jsxs(V,{css:K,children:[p.jsx(VL,{value:G.calendar,onChange:W,isReadOnly:d,"aria-label":`${ae} date`,children:p.jsx(HL,{children:({segment:ne})=>p.jsx(WL,{segment:ne})})}),p.jsx(p9,{value:G.time,onChange:J,isReadOnly:d,"aria-label":`${ae} time`,children:p.jsx(h9,{children:({segment:ne})=>p.jsx(g9,{segment:ne})})})]}),Z=p.jsxs(Xr,{gap:"2",align:"center",flexWrap:"wrap",children:[U(b,R,N,"Start"),p.jsx(Ie,{color:"fg.muted",fontSize:H,children:"–"}),U(x,O,j,"End")]});return!h||h.length===0?Z:p.jsxs(W1,{gap:"2",align:"flex-start",children:[Z,p.jsx(Xre,{gap:"2",children:h.map((G,W)=>p.jsx(fu,{size:"xs",variant:"subtle",disabled:d,onClick:()=>B(G.start instanceof Date?G.start:new Date(G.start),G.end instanceof Date?G.end:new Date(G.end)),children:G.label},`${G.label}-${W}`))})]})},(e,t)=>eFn(e.value,t.value)),nFn=it(pq.Types.Switch);function spe(e){var t,n;const r=_(e.style),a=r?(t=_(r.colorPalette))==null?void 0:t.type:void 0,o=r?(n=_(r.size))==null?void 0:n.type:void 0;return{checked:e.checked,disabled:_(e.disabled),colorPalette:a??"brand",size:o}}const rFn=C.memo(function({value:t}){const[n,r]=C.useState(spe(t)),a=C.useMemo(()=>_(t.label),[t.label]),o=C.useMemo(()=>_(t.onChange),[t.onChange]);C.useEffect(()=>{r(()=>spe(t))},[t]);const i=C.useCallback(s=>{r(l=>({...l,checked:s.checked})),o&&queueMicrotask(()=>o(s.checked))},[o]);return p.jsxs(NIt,{...n,onCheckedChange:i,children:[p.jsx(OIt,{}),p.jsx(DIt,{}),a&&p.jsx($It,{children:a})]})},(e,t)=>nFn(e.value,t.value)),aFn=it(uE.Types.Root);function lpe(e){var t;const n=_(e.value),r=_(e.style),a=r?(t=_(r.size))==null?void 0:t.type:void 0,o=r?_(r.color):void 0,i=r?_(r.background):void 0,s=r?_(r.borderColor):void 0;return{value:n?[n]:[],multiple:_(e.multiple),disabled:_(e.disabled),size:a,allowCustomValue:_(e.allowCustomValue),color:o,bg:i,borderColor:s}}const oFn=C.memo(function({value:t}){const[n,r]=C.useState(lpe(t)),a=C.useMemo(()=>_(t.placeholder),[t.placeholder]),o=C.useMemo(()=>_(t.onChange),[t.onChange]),i=C.useMemo(()=>_(t.onChangeMultiple),[t.onChangeMultiple]),s=C.useMemo(()=>_(t.onInputValueChange),[t.onInputValueChange]),l=C.useMemo(()=>_(t.onOpenChange),[t.onOpenChange]),c=C.useMemo(()=>_(t.multiple),[t.multiple]),[u,d]=C.useState("");C.useEffect(()=>{r(()=>lpe(t))},[t]);const f=C.useMemo(()=>t.items.map(y=>({value:y.value,label:y.label,disabled:_(y.disabled)??!1})),[t.items]),h=C.useMemo(()=>{const y=f.filter(x=>x.label.toLowerCase().includes(u.toLowerCase()));return Xne({items:y})},[f,u]),g=C.useCallback(y=>{r(x=>({...x,value:y.value})),c&&i?queueMicrotask(()=>i(y.value)):!c&&o&&y.value.length>0&&queueMicrotask(()=>o(y.value[0]))},[c,o,i]),v=C.useCallback(y=>{d(y.inputValue),s&&queueMicrotask(()=>s(y.inputValue))},[s]),b=C.useCallback(y=>{l&&queueMicrotask(()=>l(y.open))},[l]);return p.jsxs(pK,{...n,collection:h,inputValue:u,onValueChange:g,onInputValueChange:v,onOpenChange:b,children:[p.jsxs(gK,{children:[p.jsx(hK,{placeholder:a??"Search..."}),p.jsxs(cAe,{children:[p.jsx($Nt,{}),p.jsx(iAe,{})]})]}),p.jsx(go,{children:p.jsx(sAe,{children:p.jsxs(lAe,{children:[p.jsx(fAe,{children:"No results found"}),h.items.map(y=>p.jsxs(uAe,{item:y,children:[y.label,p.jsx(dAe,{})]},y.value))]})})})]})},(e,t)=>aFn(e.value,t.value)),iFn=it(hq.Types.Slider);function cpe(e){var t,n,r,a;const o=_(e.style),i=o?(t=_(o.orientation))==null?void 0:t.type:void 0,s=o?(n=_(o.colorPalette))==null?void 0:n.type:void 0,l=o?(r=_(o.size))==null?void 0:r.type:void 0,c=o?(a=_(o.variant))==null?void 0:a.type:void 0;return{value:[e.value],min:_(e.min),max:_(e.max),step:_(e.step),orientation:i,colorPalette:s??"brand",size:l,variant:c,disabled:_(e.disabled)}}const sFn=C.memo(function({value:t}){const[n,r]=C.useState(cpe(t)),a=C.useMemo(()=>_(t.onChange),[t.onChange]),o=C.useMemo(()=>_(t.onChangeEnd),[t.onChangeEnd]);C.useEffect(()=>{r(()=>cpe(t))},[t]);const i=C.useCallback(l=>{r(c=>({...c,value:l.value})),a&&l.value.length>0&&queueMicrotask(()=>a(l.value[0]))},[a]),s=C.useCallback(l=>{r(c=>({...c,value:l.value})),o&&l.value.length>0&&queueMicrotask(()=>o(l.value[0]))},[o]);return p.jsx(fIt,{...n,width:"100%",thumbAlignment:"center",onValueChange:i,onValueChangeEnd:s,children:p.jsxs(wIt,{children:[p.jsx(pIt,{children:p.jsx(hIt,{})}),p.jsx(xIt,{})]})})},(e,t)=>iFn(e.value,t.value)),lFn=it(B3t.Types.Field);function cFn(e){return{required:_(e.required),disabled:_(e.disabled),invalid:_(e.invalid),readOnly:_(e.readOnly)}}const uFn=C.memo(function({value:t,storageKey:n}){const r=C.useMemo(()=>cFn(t),[t]),a=C.useMemo(()=>_(t.helperText),[t.helperText]),o=C.useMemo(()=>_(t.errorText),[t.errorText]),i=C.useMemo(()=>_(t.style),[t.style]),s=C.useMemo(()=>i?_(i.schemaKey):void 0,[i]);return p.jsxs(PE,{...r,children:[p.jsxs(AE,{children:[t.label,s&&p.jsx(V,{as:"span",ml:"2",fontFamily:"mono",fontSize:"11px",fontWeight:"500",letterSpacing:"0",textTransform:"none",color:"fg.muted",children:s})]}),p.jsx(mn,{value:t.control,storageKey:`${n}.control`}),a&&p.jsx(e$t,{children:a}),o&&p.jsx(t$t,{children:o})]})},(e,t)=>lFn(e.value,t.value)&&e.storageKey===t.storageKey),dFn=it(mq.Types.Textarea);function upe(e){var t,n,r;const a=_(e.rows),o=_(e.maxLength),i=_(e.style),s=i?(t=_(i.variant))==null?void 0:t.type:void 0,l=i?(n=_(i.size))==null?void 0:n.type:void 0,c=i?(r=_(i.resize))==null?void 0:r.type:void 0,u=i?_(i.color):void 0,d=i?_(i.background):void 0,f=i?_(i.borderColor):void 0,h=i?_(i.focusBorderColor):void 0;return{value:e.value,placeholder:_(e.placeholder),variant:s,size:l,resize:c,rows:a!==void 0?Number(a):void 0,disabled:_(e.disabled),readOnly:_(e.readOnly),required:_(e.required),..._(e.invalid)?{"aria-invalid":!0}:{},maxLength:o!==void 0?Number(o):void 0,autoresize:_(e.autoresize),color:u,bg:d,borderColor:f,...h?{_focus:{borderColor:h,boxShadow:`0 0 0 1px ${h}`}}:{}}}const fFn=C.memo(function({value:t}){const[n,r]=C.useState(upe(t)),a=C.useMemo(()=>_(t.onChange),[t.onChange]),o=C.useMemo(()=>_(t.onBlur),[t.onBlur]),i=C.useMemo(()=>_(t.onFocus),[t.onFocus]);C.useEffect(()=>{r(()=>upe(t))},[t]);const s=C.useCallback(u=>{const d=u.target.value;r(f=>({...f,value:d})),a&&queueMicrotask(()=>a(d))},[a]),l=C.useCallback(()=>{o&&queueMicrotask(()=>o())},[o]),c=C.useCallback(()=>{i&&queueMicrotask(()=>i())},[i]);return p.jsx(Yre,{...n,onChange:s,onBlur:l,onFocus:c})},(e,t)=>dFn(e.value,t.value)),pFn=it(vq.Types.FileUpload);function hFn(e){var t;const n=_(e.maxFiles),r=_(e.maxFileSize),a=_(e.minFileSize);return{accept:_(e.accept),maxFiles:n!==void 0?Number(n):void 0,maxFileSize:r!==void 0?Number(r):void 0,minFileSize:a!==void 0?Number(a):void 0,directory:_(e.directory),disabled:_(e.disabled),required:_(e.required),allowDrop:_(e.allowDrop),capture:(t=_(e.capture))==null?void 0:t.type,name:_(e.name)}}const gFn=C.memo(function({value:t}){const n=C.useMemo(()=>hFn(t),[t]),r=C.useMemo(()=>_(t.label),[t.label]),a=C.useMemo(()=>_(t.dropzoneText),[t.dropzoneText]),o=C.useMemo(()=>_(t.triggerText),[t.triggerText]),i=C.useMemo(()=>{var d;return(d=_(t.orientation))==null?void 0:d.type},[t.orientation]),s=C.useMemo(()=>_(t.onFileAccept),[t.onFileAccept]),l=C.useMemo(()=>_(t.onFileReject),[t.onFileReject]),c=C.useCallback(d=>{if(s){const f=d.files.map(h=>({name:h.name,size:BigInt(h.size),type:h.type}));queueMicrotask(()=>s(f))}},[s]),u=C.useCallback(d=>{if(l){const f=d.files.map(h=>({file:{name:h.file.name,size:BigInt(h.file.size),type:h.file.type},errors:h.errors.map(g=>String(g))}));queueMicrotask(()=>l(f))}},[l]);return p.jsxs(r$t,{...n,onFileAccept:s?c:void 0,onFileReject:l?u:void 0,children:[r&&p.jsx(s$t,{children:r}),p.jsx(a$t,{py:i==="horizontal"?"4":"6",children:p.jsxs(Vo,{direction:i==="horizontal"?"row":"column",align:"center",justify:"center",gap:"2",textAlign:"center",children:[p.jsx(V,{color:"fg.muted",fontSize:"20px",lineHeight:"1","aria-hidden":!0,children:p.jsx(Ut,{icon:fOe})}),p.jsxs(V,{fontSize:"sm",color:"fg",children:[p.jsx(l$t,{asChild:!0,children:p.jsx(V,{as:"span",color:"link",cursor:"pointer",textDecoration:"underline",textUnderlineOffset:"2px",children:o??"Choose files"})}),a&&p.jsx(V,{as:"span",ml:"2",children:a})]})]})}),p.jsx(_Ae,{children:p.jsx(u$t,{children:({acceptedFiles:d})=>d.map(f=>p.jsxs(TAe,{file:f,children:[p.jsx(wK,{}),p.jsx(LAe,{}),p.jsx(EAe,{})]},f.name))})}),p.jsx(d$t,{})]})},(e,t)=>pFn(e.value,t.value)),mFn=it(Sq.Types.Progress);function vFn(e){var t,n,r;const a=_(e.style),o=_(e.indeterminate)??!1,i=a?(t=_(a.tone))==null?void 0:t.type:void 0,s=a?(n=_(a.size))==null?void 0:n.type:void 0,l=s==="xs"||s==="sm"||s==="md"?s:void 0;return{value:o?null:e.value,min:_(e.min),max:_(e.max),size:l,variant:a?(r=_(a.variant))==null?void 0:r.type:void 0,striped:a?_(a.striped):void 0,animated:a?_(a.animated):void 0,...i!==void 0?{sentiment:i}:{}}}function yFn(e,t,n){if(!e||t===void 0)return;const r=n-e.getTime(),o=Number(t)*1e3-r;if(o<=0)return;const i=Math.max(0,Math.round(o/1e3));if(i<60)return`~${i}s remaining`;const s=Math.floor(i/60),l=i%60;return l===0?`~${s}m remaining`:`~${s}m ${l}s remaining`}const bFn=C.memo(function({value:t}){const n=C.useMemo(()=>vFn(t),[t]),r=C.useMemo(()=>_(t.label),[t.label]),a=C.useMemo(()=>_(t.valueText),[t.valueText]),o=_(t.showValue)??!1,i=_(t.estimatedDuration),s=_(t.startedAt),[l,c]=C.useState(()=>Date.now());C.useEffect(()=>{if(!s||i===void 0)return;const y=window.setInterval(()=>c(Date.now()),1e3);return()=>window.clearInterval(y)},[s,i]);const u=C.useMemo(()=>yFn(s,i,l),[s,i,l]),d=o&&!_(t.indeterminate)?`${Math.round(t.value)}%`:void 0,f=u??a??d,h=_(t.style),g=h?_(h.trackColor):void 0,v=h?_(h.fillColor):void 0,b=h?_(h.labelColor):void 0;return p.jsxs(N$t,{...n,children:[r||f?p.jsxs($$t,{...b!==void 0?{color:b}:{},children:[r,f?p.jsx(O$t,{children:f}):null]}):null,p.jsx(I$t,{...g!==void 0?{style:{background:g}}:{},children:p.jsx(D$t,{...v!==void 0?{style:{background:v}}:{}})})]})},(e,t)=>mFn(e.value,t.value)),xFn=it(kq.Types.EmptyState),wFn=C.memo(function({value:t,storageKey:n}){var r;const a=C.useMemo(()=>_(t.style),[t.style]),o=C.useMemo(()=>_(t.icon),[t.icon]),i=C.useMemo(()=>_(t.glyph),[t.glyph]),s=C.useMemo(()=>_(t.description),[t.description]),l=C.useMemo(()=>_(t.actions),[t.actions]),c=a?(r=_(a.size))==null?void 0:r.type:void 0,u=a?_(a.color):void 0,d=a?_(a.background):void 0,f=a?_(a.borderColor):void 0,h=a?_(a.iconColor):void 0;return p.jsx(mK,{...c!==void 0?{size:c}:{},...u!==void 0?{color:u}:{},...d!==void 0?{bg:d}:{},...f!==void 0?{borderColor:f,borderWidth:"1px"}:{},colorPalette:"brand",paddingInline:"28px",paddingBlock:"36px",children:p.jsxs(vK,{children:[i!==void 0?p.jsx(V,{fontFamily:"mono",fontSize:"36px",letterSpacing:"0.1em",color:h??"border.strong",mb:"3",lineHeight:"1",children:i}):o?p.jsx(yK,{...h!==void 0?{color:h}:{},children:p.jsx(Ut,{icon:[o.prefix,o.name]})}):null,p.jsxs(V,{children:[p.jsx(bK,{fontSize:"15px",fontWeight:"semibold",children:p.jsx(mn,{value:t.title,storageKey:`${n??""}.title`})}),s?p.jsx(xK,{fontSize:"13.5px",color:"fg.subtle",children:p.jsx(mn,{value:s,storageKey:`${n??""}.description`})}):null]}),l?p.jsx(V,{mt:"4",children:p.jsx(mn,{value:l,storageKey:`${n??""}.actions`})}):null]})})},(e,t)=>xFn(e.value,t.value)&&e.storageKey===t.storageKey),SFn=it(zq.Types.Skeleton),CFn=C.memo(function({value:t}){const n=C.useMemo(()=>_(t.style),[t.style]),r=n?_(n.width):void 0,a=n?_(n.height):void 0,o=n?_(n.fontSize):void 0,i=n?_(n.background):void 0,s=n?_(n.shimmerColor):void 0,l=_(t.count),c=l!==void 0?Number(l):1,u={};i!==void 0&&(u["--chakra-colors-bg-emphasized"]=i),s!==void 0&&(u["--chakra-colors-bg"]=s);const d=t.shape.type,f=h=>{if(d==="text"){const g=_(t.lines);return p.jsx(Gre,{noOfLines:g!==void 0?Number(g):3,...o!==void 0?{fontSize:o}:{},...r!==void 0?{width:r}:{},css:u},h)}return d==="circle"?p.jsx(nNe,{size:r??a??"10",css:u},h):p.jsx(d4,{...r!==void 0?{width:r}:{},...a!==void 0?{height:a}:{height:"20px"},css:u},h)};return c<=1?f(0):p.jsx(W1,{align:"stretch",gap:"2",children:Array.from({length:c},(h,g)=>f(g))})},(e,t)=>SFn(e.value,t.value)),kFn=it(Mq.Types.Status),zFn={success:"fg.success",warning:"fg.warning",danger:"fg.danger",info:"fg.info",neutral:"fg.muted"},MFn=C.memo(function({value:t,storageKey:n}){var r;const a=en({key:"status"}),o=C.useMemo(()=>_(t.style),[t.style]),i=C.useMemo(()=>_(t.icon),[t.icon]),s=_(t.pulsing)??!1,[l,c]=C.useState(!1);C.useEffect(()=>{if(typeof window>"u")return;const b=window.matchMedia("(prefers-reduced-motion: reduce)");c(b.matches);const y=x=>c(x.matches);return b.addEventListener("change",y),()=>b.removeEventListener("change",y)},[]);const u=t.value.type,d=o?(r=_(o.size))==null?void 0:r.type:void 0,f=o?_(o.color):void 0,h=o?_(o.dotColor):void 0,v=a({status:u,size:d??"md",pulsing:s&&!l});return p.jsxs(Xr,{css:v.root,...f!==void 0?{color:f}:{},children:[p.jsx(V,{as:"span",css:v.indicator,...h!==void 0?{bg:h}:{}}),i?p.jsx(V,{as:"span",display:"inline-flex",alignItems:"center",color:h??zFn[u],children:p.jsx(Ut,{icon:[i.prefix,i.name]})}):null,p.jsx(V,{css:v.label,children:p.jsx(mn,{value:t.label,storageKey:`${n??""}.label`})})]})},(e,t)=>kFn(e.value,t.value)&&e.storageKey===t.storageKey),TFn=it(Cq.Types.Banner),EFn={info:"banner.partial",success:"banner.ok",warning:"banner.guard",error:"banner.error",neutral:"banner.partial",change:"banner.change",guard:"banner.guard",stale:"banner.dashed.stale"},_Fn={info:"fg.info",success:"fg.success",warning:"fg.warning",error:"fg.danger",neutral:"fg.muted",change:"border.brand",guard:"fg.warning",stale:"fg.muted"},LFn=C.memo(function({value:t,storageKey:n}){var r;const a=C.useMemo(()=>_(t.style),[t.style]),o=C.useMemo(()=>_(t.icon),[t.icon]),i=C.useMemo(()=>_(t.description),[t.description]),s=C.useMemo(()=>_(t.actions),[t.actions]),l=_(t.dismissible)??!1,c=C.useMemo(()=>_(t.onDismiss),[t.onDismiss]),u=t.status.type,d=EFn[u],f=_Fn[u],h=a?(r=_(a.variant))==null?void 0:r.type:void 0,g=a?_(a.background):void 0,v=a?_(a.color):void 0,b=a?_(a.borderColor):void 0,y=(a?_(a.iconColor):void 0)??f,x=C.useCallback(()=>{c&&queueMicrotask(()=>c())},[c]),S=u==="warning"||u==="error"?"alert":"status",z=h==="solid";return p.jsxs(V,{role:S,width:"100%",display:"flex",alignItems:"flex-start",gap:"3",flexWrap:"wrap",...z?{bg:g??f,color:v??"white",paddingX:"4",paddingY:"3",borderRadius:"2px"}:{layerStyle:d,...g!==void 0?{bg:g}:{},...v!==void 0?{color:v}:{}},...b!==void 0?{borderColor:b}:{},children:[o?p.jsx(V,{as:"span",display:"inline-flex",alignItems:"center",color:z?"currentcolor":y,fontSize:"md",flexShrink:0,pt:"0.5",children:p.jsx(Ut,{icon:[o.prefix,o.name],size:"lg"})}):null,p.jsxs(V,{flex:"1",minWidth:0,children:[p.jsx(V,{fontWeight:"semibold",fontSize:"sm",lineHeight:"1.4",children:p.jsx(mn,{value:t.title,storageKey:`${n??""}.title`})}),i?p.jsx(V,{fontSize:"13px",color:"fg.muted",lineHeight:"1.5",mt:"1",children:p.jsx(mn,{value:i,storageKey:`${n??""}.description`})}):null]}),p.jsxs(Xr,{gap:"2",flexShrink:0,children:[s?p.jsx(V,{colorPalette:"brand",children:p.jsx(mn,{value:s,storageKey:`${n??""}.actions`})}):null,l?p.jsx(Lre,{size:"sm",onClick:x}):null]})]})},(e,t)=>TFn(e.value,t.value)&&e.storageKey===t.storageKey),RFn=it(Yb.Types.Card);function PFn(e){var t;const n=_(e.style);return{height:Tt(n?_(n.height):void 0),minHeight:Tt(n?_(n.minHeight):void 0),maxHeight:Tt(n?_(n.maxHeight):void 0),width:Tt(n?_(n.width):void 0),minWidth:Tt(n?_(n.minWidth):void 0),maxWidth:Tt(n?_(n.maxWidth):void 0),flex:n?_(n.flex):void 0,overflow:n?(t=_(n.overflow))==null?void 0:t.type:void 0}}function AFn(e){switch(e){case"loading":return p.jsxs(V,{p:"3",children:[p.jsx(d4,{height:"24px",width:"60%",mb:"3"}),p.jsx(Gre,{noOfLines:3})]});case"empty":return p.jsx(mK,{size:"sm",children:p.jsxs(vK,{children:[p.jsx(yK,{children:p.jsx(Ut,{icon:MFe})}),p.jsxs(V,{children:[p.jsx(bK,{children:"No data"}),p.jsx(xK,{children:"There's nothing to show here yet."})]})]})});case"error":return p.jsxs(WPe,{status:"error",variant:"subtle",m:"3",children:[p.jsx(GPe,{children:p.jsx(Ut,{icon:Tv})}),p.jsxs(WAt,{children:[p.jsx(UPe,{children:"Something went wrong"}),p.jsx(qPe,{children:"This content failed to load."})]})]});case"permission-denied":return p.jsx(mK,{size:"sm",children:p.jsxs(vK,{children:[p.jsx(yK,{children:p.jsx(Ut,{icon:Jae})}),p.jsxs(V,{children:[p.jsx(bK,{children:"Access denied"}),p.jsx(xK,{children:"You don't have permission to view this content."})]})]})});default:return null}}const NFn=C.memo(function({value:t,storageKey:n}){const r=C.useMemo(()=>PFn(t),[t]),a=C.useMemo(()=>_(t.header),[t.header]),o=C.useMemo(()=>_(t.footer),[t.footer]),i=_(t.state),s=(i==null?void 0:i.type)??"ready",l=C.useMemo(()=>{var R;return(R=_(t.density))==null?void 0:R.type},[t.density]),c=_(t.style),u=c?_(c.background):void 0,d=c?_(c.borderColor):void 0,f=c?_(c.headerBackground):void 0,h=c?_(c.footerBackground):void 0,g=c?_(c.accentColor):void 0,v=c?_(c.bodyPadding):void 0,b=(c?_(c.flush):void 0)===!0,y=r.height!==void 0||r.maxHeight!==void 0,x=s==="disabled",S=s==="stale",z=s==="loading"||s==="empty"||s==="error"||s==="permission-denied",M=d??"border.subtle",L=p.jsxs(pNt,{...r,borderRadius:"10px",borderColor:M,borderWidth:"1px",overflow:r.overflow??"hidden",...y?{display:"flex",flexDirection:"column"}:{},...u!==void 0?{bg:u}:{},...g!==void 0?{borderLeftWidth:"3px",borderLeftColor:g}:{},"aria-disabled":x||void 0,opacity:x?.5:void 0,position:S?"relative":void 0,children:[a&&p.jsx(gNt,{paddingY:"12px",paddingX:"18px",borderBottomWidth:"1px",borderBottomColor:M,bg:f??"bg.canvas",display:"flex",flexDirection:"column",gap:"1",fontFamily:"mono",fontSize:"11px",children:p.jsx(mn,{value:a,storageKey:`${n}.header`})}),S&&p.jsxs(V,{layerStyle:"banner.stale",borderRadius:"0",display:"flex",alignItems:"center",gap:"2",children:[p.jsx(V,{as:"span",color:"fg.warning",children:p.jsx(Ut,{icon:xae})}),p.jsx(V,{fontWeight:"semibold",fontSize:"sm",children:"Stale data"})]}),p.jsx(hNt,{padding:b?"0":v??"18px 20px",display:"flex",flexDirection:"column",gap:b?"0":"3",...y?{flex:"1",minHeight:"0"}:{},opacity:S?.6:void 0,children:z?AFn(s):t.body.map((R,N)=>p.jsx(mn,{value:R,storageKey:`${n}.${N}`},N))}),o&&p.jsx(mNt,{paddingY:"10px",paddingX:"18px",borderTopWidth:"1px",borderTopColor:M,bg:h??"bg.canvas",display:"flex",alignItems:"center",gap:"3",children:p.jsx(mn,{value:o,storageKey:`${n}.footer`})})]});return l!==void 0?p.jsx(hu,{value:l,children:L}):L},(e,t)=>RFn(e.value,t.value)&&e.storageKey===t.storageKey),$Fn=it(lG.Types.Tooltip),IFn=500,DFn=C.memo(function({value:t,storageKey:n}){const r=C.useMemo(()=>_(t.style),[t.style]),a=C.useMemo(()=>{var g;return r?(g=_(r.placement))==null?void 0:g.type:void 0},[r]),o=C.useMemo(()=>r?_(r.hasArrow):void 0,[r]),i=Poe(),[s,l]=C.useState(!1),c=C.useRef(void 0);C.useEffect(()=>()=>clearTimeout(c.current),[]);const u=C.useCallback(g=>{g.pointerType!=="touch"&&g.pointerType!=="pen"||(clearTimeout(c.current),c.current=setTimeout(()=>l(!0),IFn))},[]),d=C.useCallback(()=>{clearTimeout(c.current),l(!1)},[]),f=C.useCallback(g=>{g.preventDefault()},[]),h=en({key:"tooltip"})();return i?p.jsxs(s$,{positioning:a?{placement:a}:void 0,children:[p.jsx(l$,{asChild:!0,children:p.jsx("span",{style:{display:"inline-flex"},children:p.jsx(mn,{value:t.trigger,storageKey:`${n}.trigger`})})}),p.jsx(c$,{children:p.jsxs(u$,{children:[o&&p.jsx(lDt,{children:p.jsx(pNe,{})}),t.content]})})]}):p.jsxs(nu,{open:s,positioning:a?{placement:a}:void 0,children:[p.jsx(R6,{asChild:!0,children:p.jsx("span",{style:{display:"inline-flex"},onPointerDown:u,onPointerUp:d,onPointerLeave:d,onPointerCancel:d,onContextMenu:f,children:p.jsx(mn,{value:t.trigger,storageKey:`${n}.trigger`})})}),p.jsx(go,{children:p.jsx(M4,{children:p.jsxs(T4,{css:h.content,width:"auto",children:[o&&p.jsx(n$,{css:h.arrow}),t.content]})})})]})},(e,t)=>$Fn(e.value,t.value)&&e.storageKey===t.storageKey),OFn=it(zg.Types.Menu),jFn=C.memo(function({value:t,storageKey:n}){const r=C.useMemo(()=>_(t.style),[t.style]),a=C.useMemo(()=>{var i;return r?(i=_(r.placement))==null?void 0:i.type:void 0},[r]),o=en({key:"menu"})();return p.jsxs(fm,{positioning:a?{placement:a}:void 0,children:[p.jsx(Ore,{asChild:!0,children:p.jsx("span",{style:{display:"inline-flex"},children:p.jsx(mn,{value:t.trigger,storageKey:`${n}.trigger`})})}),p.jsx(go,{children:p.jsx(pm,{children:p.jsx(hm,{children:t.items.map((i,s)=>Sr(i,{Item:l=>{const c=_(l.icon),u=_(l.command),d=_(l.destructive);return p.jsxs(ep,{value:l.value,disabled:_(l.disabled),...d?{"data-destructive":""}:{},children:[c&&p.jsx(V,{as:"span",css:o.itemIndicator,children:p.jsx(Ut,{icon:["fas",c]})}),l.label,u&&p.jsx(V,{as:"span",css:o.itemCommand,children:u})]},s)},GroupLabel:l=>p.jsx(V,{css:o.itemGroupLabel,children:l.label},s),Separator:()=>p.jsx(OAe,{},s)}))})})})]})},(e,t)=>OFn(e.value,t.value)&&e.storageKey===t.storageKey),FFn=it(uG.Types.Popover),BFn=C.memo(function({value:t,storageKey:n}){const r=C.useMemo(()=>_(t.style),[t.style]),a=C.useMemo(()=>{var d;return r?(d=_(r.placement))==null?void 0:d.type:void 0},[r]),o=C.useMemo(()=>{var d;return r?(d=_(r.size))==null?void 0:d.type:void 0},[r]),i=C.useMemo(()=>r?_(r.hasArrow):void 0,[r]),s=C.useMemo(()=>_(t.title),[t.title]),l=C.useMemo(()=>_(t.description),[t.description]),c=C.useMemo(()=>r?_(r.onOpenChange):void 0,[r]),u=C.useCallback(d=>{c&&queueMicrotask(()=>c(d.open))},[c]);return p.jsxs(nu,{positioning:a?{placement:a}:void 0,size:o,onOpenChange:c?u:void 0,children:[p.jsx(R6,{asChild:!0,children:p.jsx("span",{style:{display:"inline-flex"},children:p.jsx(mn,{value:t.trigger,storageKey:`${n}.trigger`})})}),p.jsx(go,{children:p.jsx(M4,{children:p.jsxs(T4,{children:[i!==!1&&p.jsx(n$,{children:p.jsx(Bre,{})}),p.jsxs($C,{children:[s&&p.jsx(P$t,{children:s}),l&&p.jsx(A$t,{children:l}),t.body.map((d,f)=>p.jsx(mn,{value:d,storageKey:`${n}.${f}`},f))]})]})})})]})},(e,t)=>FFn(e.value,t.value)&&e.storageKey===t.storageKey),VFn=it(dG.Types.HoverCard),HFn=C.memo(function({value:t,storageKey:n}){const r=C.useMemo(()=>_(t.style),[t.style]),a=C.useMemo(()=>_(t.title),[t.title]),o=C.useMemo(()=>_(t.description),[t.description]),i=en({key:"hoverCard"})(),s=C.useMemo(()=>{var x;return r?(x=_(r.placement))==null?void 0:x.type:void 0},[r]),l=C.useMemo(()=>{var x;return r?(x=_(r.size))==null?void 0:x.type:void 0},[r]),c=C.useMemo(()=>r?_(r.hasArrow):void 0,[r]),u=C.useMemo(()=>{const x=r?_(r.openDelay):void 0;return x!==void 0?Number(x):void 0},[r]),d=C.useMemo(()=>{const x=r?_(r.closeDelay):void 0;return x!==void 0?Number(x):void 0},[r]),f=C.useMemo(()=>r?_(r.onOpenChange):void 0,[r]),h=Poe(),[g,v]=C.useState(!1),b=C.useCallback(x=>{h||v(x.open),f&&queueMicrotask(()=>f(x.open))},[h,f]),y=C.useCallback(()=>{const x=!g;v(x),f&&queueMicrotask(()=>f(x))},[g,f]);return p.jsxs(kL,{positioning:s?{placement:s}:void 0,size:l,openDelay:u,closeDelay:d,...h?{}:{open:g},onOpenChange:!h||f?b:void 0,children:[p.jsx(zL,{asChild:!0,children:p.jsx("span",{style:{display:"inline-flex"},...h?{}:{onClick:y},children:p.jsx(mn,{value:t.trigger,storageKey:`${n}.trigger`})})}),p.jsx(go,{children:p.jsx(Nre,{children:p.jsxs($re,{children:[c!==!1&&p.jsx(NAe,{children:p.jsx(Ire,{})}),a&&p.jsx(V,{css:i.title,children:a}),o&&p.jsx(V,{css:i.description,children:o}),t.body.map((x,S)=>p.jsx(mn,{value:x,storageKey:`${n}.${S}`},S))]})})})]})},(e,t)=>VFn(e.value,t.value)&&e.storageKey===t.storageKey),WFn=it(pE.Types.Dialog),UFn={xs:"320px",sm:"400px",md:"480px",lg:"640px",xl:"800px",cover:"calc(100vw - 32px)",full:"100vw"};function qFn(e){var t,n,r,a,o;const i=_(e.style);return{size:i?(t=_(i.size))==null?void 0:t.type:void 0,placement:i?(n=_(i.placement))==null?void 0:n.type:void 0,scrollBehavior:i?(r=_(i.scrollBehavior))==null?void 0:r.type:void 0,motionPreset:i?(a=_(i.motionPreset))==null?void 0:a.type:void 0,role:i?(o=_(i.role))==null?void 0:o.type:void 0}}function hZe({value:e,storageKey:t,trigger:n,open:r,onClose:a,onExitComplete:o}){const i=C.useMemo(()=>qFn(e),[e]),s=en({key:"dialog"})(),l=C.useMemo(()=>_(e.eyebrow),[e.eyebrow]),c=C.useMemo(()=>_(e.title),[e.title]),u=C.useMemo(()=>_(e.description),[e.description]),d=C.useMemo(()=>_(e.style),[e.style]),f=C.useMemo(()=>d?_(d.onOpenChange):void 0,[d]),h=C.useMemo(()=>d?_(d.onExitComplete):void 0,[d]),g=C.useMemo(()=>d?_(d.onEscapeKeyDown):void 0,[d]),v=C.useMemo(()=>d?_(d.onInteractOutside):void 0,[d]),b=C.useCallback(z=>{!z.open&&a&&a(),f&&queueMicrotask(()=>f(z.open))},[f,a]),y=C.useCallback(()=>{h&&queueMicrotask(()=>h()),o&&o()},[h,o]),x=C.useCallback(()=>{g&&queueMicrotask(()=>g())},[g]),S=C.useCallback(()=>{v&&queueMicrotask(()=>v())},[v]);return p.jsxs(hAe,{open:r,size:i.size,placement:i.placement,scrollBehavior:i.scrollBehavior,motionPreset:i.motionPreset,role:i.role,onOpenChange:f||a?b:void 0,onExitComplete:h||o?y:void 0,onEscapeKeyDown:g?x:void 0,onInteractOutside:v?S:void 0,children:[n&&p.jsx(BNt,{asChild:!0,children:p.jsx("span",{children:n})}),p.jsxs(go,{children:[p.jsx(vAe,{}),p.jsx(gAe,{children:p.jsxs(mAe,{maxW:UFn[i.size??"md"]??"480px",children:[l&&p.jsx(V,{css:s.eyebrow,children:l}),c&&p.jsx(HNt,{children:c}),u&&p.jsx(VNt,{children:u}),p.jsx(WNt,{children:e.body.map((z,M)=>p.jsx(mn,{value:z,storageKey:`${t}.${M}`},M))})]})})]})]})}const GFn=C.memo(function({value:t,storageKey:n}){const r=C.useMemo(()=>({body:t.body,eyebrow:t.eyebrow,title:t.title,description:t.description,style:t.style}),[t.body,t.eyebrow,t.title,t.description,t.style]);return p.jsx(hZe,{value:r,storageKey:n,trigger:p.jsx(mn,{value:t.trigger,storageKey:`${n}.trigger`})})},(e,t)=>WFn(e.value,t.value)&&e.storageKey===t.storageKey),KFn=it(hE.Types.Drawer);function YFn(e){var t,n;const r=_(e.style);return{size:r?(t=_(r.size))==null?void 0:t.type:void 0,placement:r?(n=_(r.placement))==null?void 0:n.type:void 0,contained:r?_(r.contained):void 0}}function gZe({value:e,storageKey:t,trigger:n,open:r,onClose:a,onExitComplete:o,railsSlot:i,fullscreen:s,onToggleFullscreen:l}){const c=C.useMemo(()=>YFn(e),[e]),[u,d]=C.useState(!1),f=s??u,h=C.useMemo(()=>_(e.eyebrow),[e.eyebrow]),g=C.useMemo(()=>_(e.title),[e.title]),v=C.useMemo(()=>_(e.description),[e.description]),b=en({key:"drawer"})(),y=C.useMemo(()=>_(e.style),[e.style]),x=C.useMemo(()=>y?_(y.onOpenChange):void 0,[y]),S=C.useMemo(()=>y?_(y.onExitComplete):void 0,[y]),z=C.useMemo(()=>y?_(y.bodyPadding):void 0,[y]),M=C.useMemo(()=>(y?_(y.flush):void 0)===!0,[y]),L=C.useMemo(()=>(y?_(y.fillBody):void 0)===!0,[y]),R=C.useCallback(B=>{!B.open&&a&&a(),x&&queueMicrotask(()=>x(B.open))},[x,a]),N=C.useCallback(()=>{S&&queueMicrotask(()=>S()),o&&o()},[S,o]),O=C.useCallback(()=>{l?l():d(B=>!B)},[l]),j=f?"full":c.size;return p.jsxs(bAe,{open:r,size:j,placement:c.placement,contained:c.contained,onOpenChange:R,onExitComplete:S||o?N:void 0,children:[n&&p.jsx(UNt,{asChild:!0,children:p.jsx("span",{children:n})}),p.jsxs(go,{children:[p.jsx(SAe,{}),p.jsxs(xAe,{children:[i,p.jsxs(wAe,{children:[p.jsxs(kAe,{children:[p.jsxs(V,{flex:"1",minWidth:"0",children:[h&&p.jsx(V,{css:b.eyebrow,children:h}),g&&p.jsx(GNt,{children:g}),v&&p.jsx(qNt,{children:v})]}),p.jsx(fc,{"aria-label":f?"Exit fullscreen":"Enter fullscreen",onClick:O,variant:"ghost",size:"sm",children:p.jsx(Ut,{icon:f?ioe:w$})})]}),p.jsx(CAe,{padding:M?"0":z??"16px 20px",...L?{display:"flex",flexDirection:"column",minHeight:0,overflow:"hidden"}:{},children:e.body.map((B,H)=>p.jsx(mn,{value:B,storageKey:`${t}.${H}`},H))})]})]})]})]})}const XFn=C.memo(function({value:t,storageKey:n}){const r=C.useMemo(()=>({body:t.body,eyebrow:t.eyebrow,title:t.title,description:t.description,style:t.style}),[t.body,t.eyebrow,t.title,t.description,t.style]);return p.jsx(gZe,{value:r,storageKey:n,trigger:p.jsx(mn,{value:t.trigger,storageKey:`${n}.trigger`})})},(e,t)=>KFn(e.value,t.value)&&e.storageKey===t.storageKey),ZFn=it(pG.Types.ActionBar),QFn=C.memo(function({value:t}){const n=C.useMemo(()=>_(t.selectionCount),[t.selectionCount]),r=C.useMemo(()=>_(t.selectionLabel),[t.selectionLabel]),a=C.useMemo(()=>_(t.style),[t.style]),o=n!==void 0&&n>0,i=C.useMemo(()=>a?_(a.onSelect):void 0,[a]),s=C.useMemo(()=>a?_(a.onOpenChange):void 0,[a]),l=C.useCallback(u=>{s&&queueMicrotask(()=>s(u.open))},[s]),c=C.useCallback(u=>()=>{i&&queueMicrotask(()=>i(u))},[i]);return p.jsx(IAt,{open:o,onOpenChange:s?l:void 0,children:p.jsx(go,{children:p.jsx(DAt,{children:p.jsxs(OAt,{children:[p.jsxs(jAt,{children:[n," ",r??"selected"]}),p.jsx($3e,{}),t.items.map((u,d)=>Sr(u,{Action:f=>p.jsx(fu,{variant:"outline",size:"sm",disabled:_(f.disabled),onClick:i?c(f.value):void 0,children:f.label},d),Separator:()=>p.jsx($3e,{},d)}))]})})})})},(e,t)=>ZFn(e.value,t.value)),JFn=it(cG.Types.ToggleTip),eBn=C.memo(function({value:t,storageKey:n}){const r=C.useMemo(()=>_(t.style),[t.style]),a=C.useMemo(()=>{var c;return r?(c=_(r.placement))==null?void 0:c.type:void 0},[r]),o=C.useMemo(()=>r?_(r.hasArrow):void 0,[r]),i=C.useMemo(()=>r?_(r.onOpenChange):void 0,[r]),s=C.useCallback(c=>{i&&queueMicrotask(()=>i(c.open))},[i]),l=en({key:"tooltip"})();return p.jsxs(nu,{positioning:a?{placement:a}:void 0,onOpenChange:i?s:void 0,children:[p.jsx(R6,{asChild:!0,children:p.jsx("span",{style:{display:"inline-flex"},children:p.jsx(mn,{value:t.trigger,storageKey:`${n}.trigger`})})}),p.jsx(go,{children:p.jsx(M4,{children:p.jsxs(T4,{css:l.content,width:"auto",children:[o&&p.jsx(n$,{css:l.arrow}),t.content]})})})]})},(e,t)=>JFn(e.value,t.value)&&e.storageKey===t.storageKey),tBn=it(fG.Types.CommandPalette);function nBn(e,t){if(!t.trim())return e;const n=t.toLowerCase();return e.filter(r=>r.label.toLowerCase().includes(n)||r.keywords.some(a=>a.toLowerCase().includes(n)))}const rBn=C.memo(function({value:t}){const n=_(t.placeholder)??"Type a command…",r=_(t.triggerKey)??"mod+k",a=C.useMemo(()=>_(t.onOpenChange),[t.onOpenChange]),o=_(t.open),i=_(t.style),s=i?_(i.background):void 0,l=i?_(i.borderColor):void 0,c=i?_(i.inputBackground):void 0,u=i?_(i.inputColor):void 0,d=i?_(i.itemColor):void 0,f=i?_(i.selectedBackground):void 0,h=i?_(i.selectedColor):void 0,g=i?_(i.groupLabelColor):void 0,v=C.useMemo(()=>t.commands.map(W=>({id:W.id,label:W.label,shortcut:_(W.shortcut),group:_(W.group),keywords:_(W.keywords)??[],action:W.action})),[t.commands]),[b,y]=C.useState(o??!1);C.useEffect(()=>{o!==void 0&&y(o)},[o]);const[x,S]=C.useState(""),[z,M]=C.useState(0),L=C.useRef(null),R=C.useMemo(()=>nBn(v,x),[v,x]),N=C.useMemo(()=>{const W=new Map;for(const J of R){const ae=J.group??"";W.has(ae)||W.set(ae,[]),W.get(ae).push(J)}return W},[R]),O=C.useCallback(W=>{y(W),W&&(S(""),M(0)),a&&queueMicrotask(()=>a(W))},[a]);C.useEffect(()=>{b&&queueMicrotask(()=>{var W;return(W=L.current)==null?void 0:W.focus()})},[b]);const j=C.useCallback(()=>{const W=R[z];W&&(O(!1),queueMicrotask(()=>W.action()))},[R,z,O]),B=W=>{S(W.target.value),M(0)},H=W=>{W.key==="ArrowDown"?(W.preventDefault(),M(J=>Math.min(J+1,R.length-1))):W.key==="ArrowUp"?(W.preventDefault(),M(J=>Math.max(J-1,0))):W.key==="Enter"&&(W.preventDefault(),j())};let K=0;const U=en({key:"commandPalette"})(),Z="Open command palette",G=r.toLowerCase().split("+").map(W=>W.trim());return p.jsxs(C.Fragment,{children:[p.jsxs(fu,{variant:"outline",size:"sm",onClick:()=>O(!0),"aria-haspopup":"dialog","aria-expanded":b,children:[p.jsx(Ie,{children:Z}),p.jsx(V,{as:"span",ml:"2",display:"inline-flex",gap:"1",children:G.map(W=>p.jsx(Dre,{fontSize:"xs",children:W==="mod"?"⌘":W},W))})]}),p.jsx(hAe,{open:b,onOpenChange:W=>O(W.open),size:"md",placement:"center",children:p.jsxs(go,{children:[p.jsx(vAe,{css:U.backdrop}),p.jsx(gAe,{children:p.jsxs(mAe,{css:U.content,bg:s,borderColor:l,"aria-label":"Command palette",children:[p.jsx(Ht.input,{ref:L,css:U.input,placeholder:n,value:x,onChange:B,onKeyDown:H,bg:c,color:u}),p.jsx(V,{css:U.list,children:R.length===0?p.jsx(V,{css:U.empty,children:"No commands found"}):Array.from(N.entries()).map(([W,J])=>p.jsxs(V,{children:[W&&p.jsx(Ie,{css:U.groupLabel,color:g,children:W}),J.map(ae=>{const ne=K++,Y=ne===z;return p.jsxs(V,{css:U.item,onMouseEnter:()=>M(ne),onClick:j,...Y?{"data-highlighted":""}:{},bg:Y?f:void 0,color:Y?h??d:d,children:[p.jsx(Ie,{css:U.itemText,children:ae.label}),ae.shortcut&&p.jsx(Ie,{css:U.itemKbd,children:ae.shortcut})]},ae.id)})]},W||"_default"))})]})})]})})]})},(e,t)=>tBn(e.value,t.value));zv.add(_v);const aBn=C.createContext(null);let iS=null;function eH(e){var t;const n=_(e.title),r=_(e.style),a=r?_(r.stacked)??!1:!1,o=r?_(r.stackIcon):void 0,i=(r?(t=_(r.placement))==null?void 0:t.type:void 0)??"end";return{title:n,icon:o,stacked:a,placement:i}}const oBn=C.memo(function({meta:t,onClick:n}){const r=en({key:"drawerStackRail"})(),a=t.title??"Back",o=t.placement==="start"?kd:r2;return p.jsxs(Ht.button,{css:r.rail,"aria-label":`Back to ${a}`,onClick:n,children:[p.jsx(Ut,{icon:t.icon?t.icon:o}),p.jsx(Ht.span,{css:r.label,children:a})]})});function iBn({ancestors:e,placement:t,onPopTo:n}){const r=en({key:"drawerStackRail"})(),a=t==="start"||t==="top"?1:-1;return p.jsx(Ht.div,{css:r.railGroup,order:a,children:e.map(({id:o,meta:i})=>p.jsx(oBn,{meta:i,onClick:()=>n(o)},o))})}let sBn=0,lBn=0;function cBn({children:e}){const[t,n]=C.useState([]),[r,a]=C.useState([]),[o,i]=C.useState(new Set),s=C.useCallback(g=>{i(v=>{const b=new Set(v);return b.has(g)?b.delete(g):b.add(g),b})},[]);C.useEffect(()=>{i(g=>{if(g.size===0)return g;const v=new Set(r.map(x=>x.id));let b=!1;const y=new Set;for(const x of g)v.has(x)?y.add(x):b=!0;return b?y:g})},[r]);const l=C.useCallback(g=>{const v=`dialog-${++sBn}`;n(b=>[...b,{id:v,value:g}])},[]),c=C.useCallback(g=>{n(v=>v.filter(b=>b.id!==g))},[]),u=C.useCallback(g=>{const v=`drawer-${++lBn}`;a(b=>[...b,{id:v,value:g}])},[]),d=C.useCallback(g=>{a(v=>v.filter(b=>b.id!==g))},[]),f=C.useCallback(g=>{a(v=>{const b=v.findIndex(y=>y.id===g);return b===-1?v:v.slice(0,b+1)})},[]),h={openDialog:l,openDrawer:u};return iS=h,p.jsxs(aBn.Provider,{value:h,children:[e,t.map(({id:g,value:v})=>p.jsx(uBn,{value:v,onClose:()=>c(g)},g)),(()=>{const g=r.slice(0,-1).map(y=>({id:y.id,meta:eH(y.value)})).filter(({meta:y})=>y.stacked),v=r.length>0?eH(r[r.length-1].value).placement:"end",b=g.length>0?p.jsx(iBn,{ancestors:g,placement:v,onPopTo:f}):void 0;return r.map(({id:y,value:x},S)=>{const z=S===r.length-1;return!z&&eH(x).stacked?null:p.jsx(dBn,{value:x,onClose:()=>d(y),railsSlot:z?b:void 0,fullscreen:o.has(y),onToggleFullscreen:()=>s(y)},y)})})()]})}function uBn({value:e,onClose:t}){const[n,r]=C.useState(!1);C.useEffect(()=>{r(!0)},[]);const a=C.useCallback(()=>r(!1),[]),o=C.useCallback(()=>t(),[t]);return p.jsx(hZe,{value:e,storageKey:"programmatic-dialog",open:n,onClose:a,onExitComplete:o})}function dBn({value:e,onClose:t,railsSlot:n,fullscreen:r,onToggleFullscreen:a}){const[o,i]=C.useState(!1);C.useEffect(()=>{i(!0)},[]);const s=C.useCallback(()=>i(!1),[]),l=C.useCallback(()=>t(),[t]);return p.jsx(gZe,{value:e,storageKey:"programmatic-drawer",open:o,onClose:s,onExitComplete:l,railsSlot:n,fullscreen:r,onToggleFullscreen:a})}const fBn=ECe.implement(e=>{if(!iS){console.warn("Dialog.open called but OverlayManagerProvider is not mounted. Wrap your app in <OverlayManagerProvider>.");return}iS.openDialog(e)}),pBn=LCe.implement(e=>{if(!iS){console.warn("Drawer.open called but OverlayManagerProvider is not mounted. Wrap your app in <OverlayManagerProvider>.");return}iS.openDrawer(e)}),Die=[fBn,pBn];s0(Die);const hBn=it($te.Types.Hotkey);function gBn(e,t){const n=t.toLowerCase().split("+").map(s=>s.trim()),r=n.includes("mod")||n.includes("ctrl")||n.includes("cmd"),a=n.includes("shift"),o=n.includes("alt")||n.includes("option"),i=n[n.length-1];return r&&!(e.metaKey||e.ctrlKey)||!r&&(e.metaKey||e.ctrlKey)||a!==e.shiftKey||o!==e.altKey?!1:e.key.toLowerCase()===i}const mBn=C.memo(function({value:t}){const{chord:n,onTrigger:r}=t;return C.useEffect(()=>{if(typeof document>"u")return;const a=o=>{const i=o.target;!(n.toLowerCase().includes("mod")||n.toLowerCase().includes("ctrl")||n.toLowerCase().includes("cmd"))&&i&&(i.tagName==="INPUT"||i.tagName==="TEXTAREA"||i.isContentEditable)||gBn(o,n)&&(o.preventDefault(),queueMicrotask(()=>r()))};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[n,r]),null},(e,t)=>hBn(e.value,t.value));function vBn(e){if(e.includes("no IR attached"))return"A raw JavaScript function reached the value serializer where an East function (one carrying compiled IR) was expected — typically a plain arrow passed to a prop that must be an East function. The Region below identifies the rendering subtree."}function dk({title:e,message:t,stack:n,context:r}){const a=vBn(t);return p.jsxs(WPe,{status:"error","data-east-error":"true",children:[p.jsx(GPe,{}),p.jsxs(qp,{gap:"2",flex:"1",children:[p.jsx(UPe,{children:e}),p.jsx(qPe,{children:p.jsxs(V,{children:[p.jsxs(qp,{gap:"1",children:[p.jsx(Ie,{fontWeight:"medium",children:t}),a&&p.jsx(Ie,{children:a}),r&&p.jsxs(Ie,{children:["Region: ",r]})]}),n&&p.jsx(qw,{display:"block",whiteSpace:"pre-wrap",fontSize:"xs",mt:"2",p:"2",layerStyle:"banner.error",borderRadius:"sm",maxHeight:"200px",overflow:"auto",children:n})]})})]})]})}function fk(e){const t=e instanceof Error?e.message:String(e),n=e instanceof Error?e.stack:void 0;return{message:t,stack:n}}class mZe extends C.Component{constructor(){super(...arguments),Lg(this,"state",{error:null})}static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){t.resetKey!==this.props.resetKey&&this.state.error!==null&&this.setState({error:null})}componentDidCatch(t,n){console.error("[EastErrorBoundary]",t,n)}render(){if(this.state.error!==null){const{message:t,stack:n}=fk(this.state.error);return p.jsx(dk,{title:this.props.title,message:t,stack:n,context:this.props.context})}return this.props.children}}function vZe(e){const t=C.useSyncExternalStore(iht,lht),n=sht(),r=C.useRef(new Map),a=C.useCallback(()=>{for(const c of n)c.enableTracking();try{const c=e(),u=new Map;for(const d of n)u.set(d.id,d.disableTracking());return r.current=u,{ok:!0,value:c}}catch(c){const u=new Map;for(const d of n)u.set(d.id,d.disableTracking());return r.current=u,{ok:!1,error:c}}},[e,n]),o=C.useCallback(c=>{const u=[];for(const d of n){const f=d.getStore();if(!f)continue;const h=r.current.get(d.id)??[];for(const g of h)u.push(f.subscribe(g,c))}return()=>u.forEach(d=>d())},[n]),i=C.useCallback(()=>{const c=[];for(const u of n){const d=u.getStore();if(!d)continue;const f=r.current.get(u.id)??[];c.push(f.map(h=>`${u.id}:${h}:${d.getKeyVersion(h)}`).join(","))}return c.join("|")},[n]),s=C.useSyncExternalStore(o,i);return{result:C.useMemo(()=>a(),[a,s,t]),snapshot:s}}function Oie({value:e,storageKey:t}){const n=C.useCallback(()=>e.render(),[e]),{result:r,snapshot:a}=vZe(n);if(!r.ok){const o=fk(r.error);return p.jsx(dk,{title:"East Render Error",message:o.message,stack:o.stack,context:t})}return r.value===void 0||r.value===null?null:p.jsx(mZe,{title:"East Render Error",resetKey:a,context:t,children:p.jsx(mn,{value:r.value,storageKey:t})})}const yBn=C.memo(function({value:t,storageKey:n}){const r=C.useCallback(()=>t.tag(),[t]),{result:a}=vZe(r);if(!a.ok){const o=fk(a.error);return p.jsx(dk,{title:"East Render Error",message:o.message,stack:o.stack,context:n})}return p.jsx(Oie,{value:t,storageKey:n},`case:${a.value}`)},(e,t)=>e.storageKey===t.storageKey),dpe=C.memo(function({value:t,storageKey:n}){const r=t.navKey,a=C.useCallback(s=>ns().subscribe(r,s),[r]),o=C.useCallback(()=>ns().getKeyVersion(r),[r]),i=C.useSyncExternalStore(a,o);return p.jsx(Oie,{value:t,storageKey:n},`route:${i}`)},(e,t)=>e.value.navKey===t.value.navKey&&e.storageKey===t.storageKey),yZe=new Map;function pk(e,t){yZe.set(e.name,{schema:e.schema,renderer:t,decode:n=>Ra(e.schema,{platform:lv()})(n)})}function bBn(e){return yZe.get(e)}const xBn=C.memo(function({value:t,storageKey:n}){const r=bBn(t.kind),a=C.useMemo(()=>r?r.decode(t.payload):null,[r,t.payload]);if(!r)return p.jsxs(V,{layerStyle:"banner.error",fontFamily:"mono",fontSize:"xs",children:[p.jsx(Ie,{fontWeight:"semibold",children:"Extension renderer missing"}),p.jsxs(Ie,{children:["kind: ",t.kind]})]});const o=r.renderer;return p.jsx(o,{value:a,storageKey:n})}),wBn=it(je);function Vn(e,t){return e?`${e}.${t}`:t}const mn=C.memo(function({value:t,storageKey:n}){const r=C.useMemo(()=>Sr(t,{Text:a=>p.jsx(wjt,{value:a}),Code:a=>p.jsx(kjt,{value:a}),Heading:a=>p.jsx(Tjt,{value:a}),Link:a=>p.jsx(Ljt,{value:a}),Highlight:a=>p.jsx(Ajt,{value:a}),Mark:a=>p.jsx(Ijt,{value:a}),List:a=>p.jsx(rfn,{value:a,storageKey:Vn(n,"List")}),CodeBlock:a=>p.jsx(ifn,{value:a}),Numeric:a=>p.jsx(cfn,{value:a}),Note:a=>p.jsx(pfn,{value:a,storageKey:Vn(n,"Note")}),Button:a=>p.jsx(WVe,{value:a,storageKey:Vn(n,"Button")}),IconButton:a=>p.jsx(QWe,{value:a}),CopyButton:a=>p.jsx(JWe,{value:a}),CloseButton:a=>p.jsx(eUe,{value:a}),Toggle:a=>p.jsx(tUe,{value:a,storageKey:Vn(n,"Toggle")}),ButtonGroup:a=>p.jsx(Jxn,{value:a,storageKey:Vn(n,"ButtonGroup")}),Box:a=>p.jsx(_Rn,{value:a,storageKey:n}),Flex:a=>p.jsx(PRn,{value:a,storageKey:n}),Stack:a=>p.jsx($Rn,{value:a,storageKey:n}),AlignedStack:a=>p.jsx(DRn,{value:a,storageKey:Vn(n,"AlignedStack")}),Separator:a=>p.jsx(FRn,{value:a,storageKey:n}),Grid:a=>p.jsx(HRn,{value:a,storageKey:n}),Splitter:a=>p.jsx(YRn,{value:a,storageKey:Vn(n,"Splitter")}),Sticky:a=>p.jsx(ZRn,{value:a,storageKey:Vn(n,"Sticky")}),ScrollArea:a=>p.jsx(EPn,{value:a,storageKey:Vn(n,"ScrollArea")}),Expandable:a=>p.jsx(RPn,{value:a,storageKey:Vn(n,"Expandable")}),Dock:a=>p.jsx(APn,{value:a,storageKey:Vn(n,"Dock")}),ChipRail:a=>p.jsx($Pn,{value:a,storageKey:Vn(n,"ChipRail")}),StringInput:a=>p.jsx(Y$,{value:a}),IntegerInput:a=>p.jsx(X$,{value:a}),FloatInput:a=>p.jsx(Z$,{value:a}),DateTimeInput:a=>p.jsx(m9,{value:a}),Checkbox:a=>p.jsx(HXe,{value:a}),RadioGroup:a=>p.jsx(Yjn,{value:a}),RadioCardGroup:a=>p.jsx(Zjn,{value:a}),TimeRangeInput:a=>p.jsx(Jjn,{value:a}),DateRangeInput:a=>p.jsx(tFn,{value:a}),Switch:a=>p.jsx(rFn,{value:a}),Select:a=>p.jsx(h6,{value:a}),Combobox:a=>p.jsx(oFn,{value:a}),Slider:a=>p.jsx(sFn,{value:a}),FileUpload:a=>p.jsx(gFn,{value:a}),Field:a=>p.jsx(uFn,{value:a,storageKey:Vn(n,"Field")}),Textarea:a=>p.jsx(fFn,{value:a}),TagsInput:a=>p.jsx(EKe,{value:a}),Progress:a=>p.jsx(bFn,{value:a}),Banner:a=>p.jsx(LFn,{value:a,storageKey:Vn(n,"Banner")}),EmptyState:a=>p.jsx(wFn,{value:a,storageKey:Vn(n,"EmptyState")}),Skeleton:a=>p.jsx(CFn,{value:a}),Status:a=>p.jsx(MFn,{value:a,storageKey:Vn(n,"Status")}),Breadcrumb:a=>p.jsx(PIn,{value:a}),NavList:a=>p.jsx(IXe,{value:a}),Pages:a=>p.jsx(dpe,{value:a,storageKey:Vn(n,"Pages")}),Route:a=>p.jsx(dpe,{value:a,storageKey:Vn(n,"Route")}),App:a=>p.jsx(HIn,{value:a,storageKey:Vn(n,"App")}),Icon:a=>p.jsx(bXe,{value:a}),Badge:a=>p.jsx(qIn,{value:a}),Tag:a=>p.jsx(YIn,{value:a}),Avatar:a=>p.jsx(ZIn,{value:a}),Image:a=>p.jsx(DXe,{value:a}),Stat:a=>p.jsx(eDn,{value:a,storageKey:Vn(n,"Stat")}),MetricChip:a=>p.jsx(rDn,{value:a,storageKey:Vn(n,"MetricChip")}),EditableChip:a=>p.jsx(iDn,{value:a,storageKey:Vn(n,"EditableChip")}),Kbd:a=>p.jsx(lDn,{value:a}),Meter:a=>p.jsx(uDn,{value:a,storageKey:Vn(n,"Meter")}),SegmentedMeter:a=>p.jsx(hDn,{value:a,storageKey:Vn(n,"SegmentedMeter")}),BarStrip:a=>p.jsx(vDn,{value:a,storageKey:Vn(n,"BarStrip")}),AvatarGroup:a=>p.jsx(Gjn,{value:a}),Trace:a=>p.jsx(wDn,{value:a,storageKey:Vn(n,"Trace")}),SliceSummary:a=>p.jsx(aDn,{value:a}),SliceRange:a=>p.jsx(DKe,{value:a}),SliceFilter:a=>p.jsx(PKe,{value:a}),SliceLegend:a=>p.jsx(Qoe,{value:a}),SliceBreakdown:a=>p.jsx($Ke,{value:a}),SliceSearch:a=>p.jsx(AKe,{value:a}),SliceCohort:a=>p.jsx(sY,{value:a}),SliceRail:a=>p.jsx(uzn,{value:a}),Card:a=>p.jsx(NFn,{value:a,storageKey:n}),DataList:a=>p.jsx(SAn,{value:a,storageKey:Vn(n,"DataList")}),Matrix:a=>p.jsx(DNn,{value:a,storageKey:Vn(n,"Matrix")}),Pagination:a=>p.jsx(jNn,{value:a,storageKey:Vn(n,"Pagination")}),Table:a=>p.jsx(WNn,{value:a,storageKey:Vn(n,"Table")}),Gantt:a=>p.jsx(gIn,{value:a,storageKey:Vn(n,"Gantt")}),Planner:a=>p.jsx(EIn,{value:a,storageKey:Vn(n,"Planner")}),Library:a=>p.jsx(EDn,{value:a,storageKey:Vn(n,"Library")}),Deck:a=>p.jsx(ODn,{value:a,storageKey:Vn(n,"Deck")}),DeckReadout:a=>p.jsx($Dn,{value:a}),DeckRows:a=>p.jsx(IDn,{value:a}),DeckNote:a=>p.jsx(DDn,{value:a}),ValueTree:a=>p.jsx(Aie,{value:a,storageKey:Vn(n,"ValueTree")}),Roster:a=>p.jsx(iOn,{value:a,storageKey:Vn(n,"Roster")}),Board:a=>p.jsx(pOn,{value:a,storageKey:Vn(n,"Board")}),Calendar:a=>p.jsx(gOn,{value:a,storageKey:Vn(n,"Calendar")}),Schematic:a=>p.jsx(ejn,{value:a,storageKey:Vn(n,"Schematic")}),Flowchart:a=>p.jsx(Rjn,{value:a,storageKey:Vn(n,"Flowchart")}),Map:a=>p.jsx(Fjn,{value:a,storageKey:Vn(n,"Map")}),Blend:a=>p.jsx(Ujn,{value:a,storageKey:Vn(n,"Blend")}),Sparkline:a=>p.jsx(rwn,{value:a}),VisxChart:a=>p.jsx(yRn,{value:a}),TreeView:a=>p.jsx(XNn,{value:a,storageKey:Vn(n,"TreeView")}),Accordion:a=>p.jsx(BPn,{value:a,storageKey:Vn(n,"Accordion")}),Carousel:a=>p.jsx(WPn,{value:a,storageKey:Vn(n,"Carousel")}),Tabs:a=>p.jsx(ZPn,{value:a,storageKey:Vn(n,"Tabs")}),Story:a=>p.jsx(lAn,{value:a,storageKey:Vn(n,"Story")}),StoryStep:a=>p.jsx(cAn,{value:a,storageKey:Vn(n,"StoryStep")}),StoryProgress:a=>p.jsx(uAn,{value:a,storageKey:Vn(n,"StoryProgress")}),SegmentGroup:a=>p.jsx(pAn,{value:a,storageKey:Vn(n,"SegmentGroup")}),Collapsible:a=>p.jsx(gAn,{value:a,storageKey:Vn(n,"Collapsible")}),Disclosure:a=>p.jsx(vAn,{value:a,storageKey:Vn(n,"Disclosure")}),OptionList:a=>p.jsx(bAn,{value:a,storageKey:Vn(n,"OptionList")}),Tooltip:a=>p.jsx(DFn,{value:a,storageKey:Vn(n,"Tooltip")}),Menu:a=>p.jsx(jFn,{value:a,storageKey:Vn(n,"Menu")}),Popover:a=>p.jsx(BFn,{value:a,storageKey:Vn(n,"Popover")}),HoverCard:a=>p.jsx(HFn,{value:a,storageKey:Vn(n,"HoverCard")}),Dialog:a=>p.jsx(GFn,{value:a,storageKey:Vn(n,"Dialog")}),Drawer:a=>p.jsx(XFn,{value:a,storageKey:Vn(n,"Drawer")}),ActionBar:a=>p.jsx(QFn,{value:a}),ToggleTip:a=>p.jsx(eBn,{value:a,storageKey:Vn(n,"ToggleTip")}),CommandPalette:a=>p.jsx(rBn,{value:a}),Hotkey:a=>p.jsx(mBn,{value:a}),ReactiveComponent:a=>p.jsx(Oie,{value:a,storageKey:Vn(n,"ReactiveComponent")}),Match:a=>p.jsx(yBn,{value:a,storageKey:Vn(n,"Match")}),Extension:a=>p.jsx(xBn,{value:a,storageKey:Vn(n,`Extension:${a.kind}`)})}),[t,n]);return p.jsx(p.Fragment,{children:r})},(e,t)=>wBn(e.value,t.value)&&e.storageKey===t.storageKey);class hk{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}hk.prototype.normal={};hk.prototype.property={};hk.prototype.space=void 0;function bZe(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new hk(n,r,t)}function fpe(e){return e.toLowerCase()}class g2{constructor(t,n){this.attribute=n,this.property=t}}g2.prototype.attribute="";g2.prototype.booleanish=!1;g2.prototype.boolean=!1;g2.prototype.commaOrSpaceSeparated=!1;g2.prototype.commaSeparated=!1;g2.prototype.defined=!1;g2.prototype.mustUseProperty=!1;g2.prototype.number=!1;g2.prototype.overloadedBoolean=!1;g2.prototype.property="";g2.prototype.spaceSeparated=!1;g2.prototype.space=void 0;let SBn=0;const aa=D7(),Gi=D7(),iX=D7(),pn=D7(),Fo=D7(),Mm=D7(),Oc=D7();function D7(){return 2**++SBn}const sX=Object.freeze(Object.defineProperty({__proto__:null,boolean:aa,booleanish:Gi,commaOrSpaceSeparated:Oc,commaSeparated:Mm,number:pn,overloadedBoolean:iX,spaceSeparated:Fo},Symbol.toStringTag,{value:"Module"})),tH=Object.keys(sX);class xZe extends g2{constructor(t,n,r,a){let o=-1;if(super(t,n),ppe(this,"space",a),typeof r=="number")for(;++o<tH.length;){const i=tH[o];ppe(this,tH[o],(r&sX[i])===sX[i])}}}xZe.prototype.defined=!0;function ppe(e,t,n){n&&(e[t]=n)}function jv(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const o=new xZe(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[fpe(r)]=r,n[fpe(o.attribute)]=r}return new hk(t,n,e.space)}const wZe=jv({properties:{ariaActiveDescendant:null,ariaAtomic:Gi,ariaAutoComplete:null,ariaBusy:Gi,ariaChecked:Gi,ariaColCount:pn,ariaColIndex:pn,ariaColSpan:pn,ariaControls:Fo,ariaCurrent:null,ariaDescribedBy:Fo,ariaDetails:null,ariaDisabled:Gi,ariaDropEffect:Fo,ariaErrorMessage:null,ariaExpanded:Gi,ariaFlowTo:Fo,ariaGrabbed:Gi,ariaHasPopup:null,ariaHidden:Gi,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Fo,ariaLevel:pn,ariaLive:null,ariaModal:Gi,ariaMultiLine:Gi,ariaMultiSelectable:Gi,ariaOrientation:null,ariaOwns:Fo,ariaPlaceholder:null,ariaPosInSet:pn,ariaPressed:Gi,ariaReadOnly:Gi,ariaRelevant:null,ariaRequired:Gi,ariaRoleDescription:Fo,ariaRowCount:pn,ariaRowIndex:pn,ariaRowSpan:pn,ariaSelected:Gi,ariaSetSize:pn,ariaSort:null,ariaValueMax:pn,ariaValueMin:pn,ariaValueNow:pn,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function SZe(e,t){return t in e?e[t]:t}function CZe(e,t){return SZe(e,t.toLowerCase())}const CBn=jv({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Mm,acceptCharset:Fo,accessKey:Fo,action:null,allow:null,allowFullScreen:aa,allowPaymentRequest:aa,allowUserMedia:aa,alt:null,as:null,async:aa,autoCapitalize:null,autoComplete:Fo,autoFocus:aa,autoPlay:aa,blocking:Fo,capture:null,charSet:null,checked:aa,cite:null,className:Fo,cols:pn,colSpan:null,content:null,contentEditable:Gi,controls:aa,controlsList:Fo,coords:pn|Mm,crossOrigin:null,data:null,dateTime:null,decoding:null,default:aa,defer:aa,dir:null,dirName:null,disabled:aa,download:iX,draggable:Gi,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:aa,formTarget:null,headers:Fo,height:pn,hidden:iX,high:pn,href:null,hrefLang:null,htmlFor:Fo,httpEquiv:Fo,id:null,imageSizes:null,imageSrcSet:null,inert:aa,inputMode:null,integrity:null,is:null,isMap:aa,itemId:null,itemProp:Fo,itemRef:Fo,itemScope:aa,itemType:Fo,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:aa,low:pn,manifest:null,max:null,maxLength:pn,media:null,method:null,min:null,minLength:pn,multiple:aa,muted:aa,name:null,nonce:null,noModule:aa,noValidate:aa,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:aa,optimum:pn,pattern:null,ping:Fo,placeholder:null,playsInline:aa,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:aa,referrerPolicy:null,rel:Fo,required:aa,reversed:aa,rows:pn,rowSpan:pn,sandbox:Fo,scope:null,scoped:aa,seamless:aa,selected:aa,shadowRootClonable:aa,shadowRootDelegatesFocus:aa,shadowRootMode:null,shape:null,size:pn,sizes:null,slot:null,span:pn,spellCheck:Gi,src:null,srcDoc:null,srcLang:null,srcSet:null,start:pn,step:null,style:null,tabIndex:pn,target:null,title:null,translate:null,type:null,typeMustMatch:aa,useMap:null,value:Gi,width:pn,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Fo,axis:null,background:null,bgColor:null,border:pn,borderColor:null,bottomMargin:pn,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:aa,declare:aa,event:null,face:null,frame:null,frameBorder:null,hSpace:pn,leftMargin:pn,link:null,longDesc:null,lowSrc:null,marginHeight:pn,marginWidth:pn,noResize:aa,noHref:aa,noShade:aa,noWrap:aa,object:null,profile:null,prompt:null,rev:null,rightMargin:pn,rules:null,scheme:null,scrolling:Gi,standby:null,summary:null,text:null,topMargin:pn,valueType:null,version:null,vAlign:null,vLink:null,vSpace:pn,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:aa,disableRemotePlayback:aa,prefix:null,property:null,results:pn,security:null,unselectable:null},space:"html",transform:CZe}),kBn=jv({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Oc,accentHeight:pn,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:pn,amplitude:pn,arabicForm:null,ascent:pn,attributeName:null,attributeType:null,azimuth:pn,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:pn,by:null,calcMode:null,capHeight:pn,className:Fo,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:pn,diffuseConstant:pn,direction:null,display:null,dur:null,divisor:pn,dominantBaseline:null,download:aa,dx:null,dy:null,edgeMode:null,editable:null,elevation:pn,enableBackground:null,end:null,event:null,exponent:pn,externalResourcesRequired:null,fill:null,fillOpacity:pn,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Mm,g2:Mm,glyphName:Mm,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:pn,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:pn,horizOriginX:pn,horizOriginY:pn,id:null,ideographic:pn,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:pn,k:pn,k1:pn,k2:pn,k3:pn,k4:pn,kernelMatrix:Oc,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:pn,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:pn,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:pn,overlineThickness:pn,paintOrder:null,panose1:null,path:null,pathLength:pn,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Fo,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:pn,pointsAtY:pn,pointsAtZ:pn,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Oc,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Oc,rev:Oc,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Oc,requiredFeatures:Oc,requiredFonts:Oc,requiredFormats:Oc,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:pn,specularExponent:pn,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:pn,strikethroughThickness:pn,string:null,stroke:null,strokeDashArray:Oc,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:pn,strokeOpacity:pn,strokeWidth:null,style:null,surfaceScale:pn,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Oc,tabIndex:pn,tableValues:null,target:null,targetX:pn,targetY:pn,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Oc,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:pn,underlineThickness:pn,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:pn,values:null,vAlphabetic:pn,vMathematical:pn,vectorEffect:null,vHanging:pn,vIdeographic:pn,version:null,vertAdvY:pn,vertOriginX:pn,vertOriginY:pn,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:pn,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:SZe}),kZe=jv({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),zZe=jv({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:CZe}),MZe=jv({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});bZe([wZe,CBn,kZe,zZe,MZe],"html");bZe([wZe,kBn,kZe,zZe,MZe],"svg");var Qh={},nH,hpe;function zBn(){if(hpe)return nH;hpe=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,i=/^[;\s]*/,s=/^\s+|\s+$/g,l=`
|
|
672
|
+
color: hsl(${Math.max(0,Math.min(120-120*b,120))}deg 100% 31%);`,n==null?void 0:n.key)}return n!=null&&n.onChange&&!(o&&n.skipInitialOnChange)&&n.onChange(a),o=!1,a}return i.updateDeps=s=>{r=s},i}function W5e(e,t){if(e===void 0)throw new Error("Unexpected undefined");return e}const fNn=(e,t)=>Math.abs(e-t)<1.01,pNn=(e,t,n)=>{let r;return function(...a){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,a),n)}},U5e=e=>{const{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},hNn=e=>e,gNn=e=>{const t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let a=t;a<=n;a++)r.push(a);return r},mNn=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;const a=i=>{const{width:s,height:l}=i;t({width:Math.round(s),height:Math.round(l)})};if(a(U5e(n)),!r.ResizeObserver)return()=>{};const o=new r.ResizeObserver(i=>{const s=()=>{const l=i[0];if(l!=null&&l.borderBoxSize){const c=l.borderBoxSize[0];if(c){a({width:c.inlineSize,height:c.blockSize});return}}a(U5e(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(s):s()});return o.observe(n,{box:"border-box"}),()=>{o.unobserve(n)}},q5e={passive:!0},G5e=typeof window>"u"?!0:"onscrollend"in window,vNn=(e,t)=>{const n=e.scrollElement;if(!n)return;const r=e.targetWindow;if(!r)return;let a=0;const o=e.options.useScrollendEvent&&G5e?()=>{}:pNn(r,()=>{t(a,!1)},e.options.isScrollingResetDelay),i=u=>()=>{const{horizontal:d,isRtl:f}=e.options;a=d?n.scrollLeft*(f&&-1||1):n.scrollTop,o(),t(a,u)},s=i(!0),l=i(!1);n.addEventListener("scroll",s,q5e);const c=e.options.useScrollendEvent&&G5e;return c&&n.addEventListener("scrollend",l,q5e),()=>{n.removeEventListener("scroll",s),c&&n.removeEventListener("scrollend",l)}},yNn=(e,t,n)=>{if(t!=null&&t.borderBoxSize){const r=t.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return e[n.options.horizontal?"offsetWidth":"offsetHeight"]},bNn=(e,{adjustments:t=0,behavior:n},r)=>{var a,o;const i=e+t;(o=(a=r.scrollElement)==null?void 0:a.scrollTo)==null||o.call(a,{[r.options.horizontal?"left":"top"]:i,behavior:n})};let xNn=class{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var n,r,a;return((a=(r=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:r.now)==null?void 0:a.call(r))??Date.now()},this.observer=(()=>{let n=null;const r=()=>n||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:n=new this.targetWindow.ResizeObserver(a=>{a.forEach(o=>{const i=()=>{const s=o.target,l=this.indexFromElement(s);if(!s.isConnected){this.observer.unobserve(s);return}this.shouldMeasureDuringScroll(l)&&this.resizeItem(l,this.options.measureElement(s,o,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()})}));return{disconnect:()=>{var a;(a=r())==null||a.disconnect(),n=null},observe:a=>{var o;return(o=r())==null?void 0:o.observe(a,{box:"border-box"})},unobserve:a=>{var o;return(o=r())==null?void 0:o.unobserve(a)}}})(),this.range=null,this.setOptions=n=>{Object.entries(n).forEach(([r,a])=>{typeof a>"u"&&delete n[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:hNn,rangeExtractor:gNn,onChange:()=>{},measureElement:yNn,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...n}},this.notify=n=>{var r,a;(a=(r=this.options).onChange)==null||a.call(r,this,n)},this.maybeNotify=Hh(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),n=>{this.notify(n)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(n=>n()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(a=>{this.observer.observe(a)}),this.unsubs.push(this.options.observeElementRect(this,a=>{this.scrollRect=a,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(a,o)=>{this.scrollAdjustments=0,this.scrollDirection=o?this.getScrollOffset()<a?"forward":"backward":null,this.scrollOffset=a,this.isScrolling=o,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(n,r)=>{const a=new Map,o=new Map;for(let i=r-1;i>=0;i--){const s=n[i];if(a.has(s.lane))continue;const l=o.get(s.lane);if(l==null||s.end>l.end?o.set(s.lane,s):s.end<l.end&&a.set(s.lane,!0),a.size===this.options.lanes)break}return o.size===this.options.lanes?Array.from(o.values()).sort((i,s)=>i.end===s.end?i.index-s.index:i.end-s.end)[0]:void 0},this.getMeasurementOptions=Hh(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(n,r,a,o,i,s)=>(this.prevLanes!==void 0&&this.prevLanes!==s&&(this.lanesChangedFlag=!0),this.prevLanes=s,this.pendingMeasuredCacheIndexes=[],{count:n,paddingStart:r,scrollMargin:a,getItemKey:o,enabled:i,lanes:s}),{key:!1}),this.getMeasurements=Hh(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:n,paddingStart:r,scrollMargin:a,getItemKey:o,enabled:i,lanes:s},l)=>{if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>n)for(const f of this.laneAssignments.keys())f>=n&&this.laneAssignments.delete(f);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(f=>{this.itemSizeCache.set(f.key,f.size)}));const c=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===n&&(this.lanesSettling=!1);const u=this.measurementsCache.slice(0,c),d=new Array(s).fill(void 0);for(let f=0;f<c;f++){const h=u[f];h&&(d[h.lane]=f)}for(let f=c;f<n;f++){const h=o(f),g=this.laneAssignments.get(f);let v,b;if(g!==void 0&&this.options.lanes>1){v=g;const z=d[v],M=z!==void 0?u[z]:void 0;b=M?M.end+this.options.gap:r+a}else{const z=this.options.lanes===1?u[f-1]:this.getFurthestMeasurement(u,f);b=z?z.end+this.options.gap:r+a,v=z?z.lane:f%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(f,v)}const y=l.get(h),x=typeof y=="number"?y:this.options.estimateSize(f),S=b+x;u[f]={index:f,start:b,size:x,end:S,key:h,lane:v},d[v]=f}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Hh(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(n,r,a,o)=>this.range=n.length>0&&r>0?wNn({measurements:n,outerSize:r,scrollOffset:a,lanes:o}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Hh(()=>{let n=null,r=null;const a=this.calculateRange();return a&&(n=a.startIndex,r=a.endIndex),this.maybeNotify.updateDeps([this.isScrolling,n,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,n,r]},(n,r,a,o,i)=>o===null||i===null?[]:n({startIndex:o,endIndex:i,overscan:r,count:a}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=n=>{const r=this.options.indexAttribute,a=n.getAttribute(r);return a?parseInt(a,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=n=>{var r;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;const a=this.scrollState.index??((r=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:r.index);if(a!==void 0&&this.range){const o=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),i=Math.max(0,a-o),s=Math.min(this.options.count-1,a+o);return n>=i&&n<=s}return!0},this.measureElement=n=>{if(!n){this.elementsCache.forEach((i,s)=>{i.isConnected||(this.observer.unobserve(i),this.elementsCache.delete(s))});return}const r=this.indexFromElement(n),a=this.options.getItemKey(r),o=this.elementsCache.get(a);o!==n&&(o&&this.observer.unobserve(o),this.observer.observe(n),this.elementsCache.set(a,n)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(r)&&this.resizeItem(r,this.options.measureElement(n,void 0,this))},this.resizeItem=(n,r)=>{var a;const o=this.measurementsCache[n];if(!o)return;const i=this.itemSizeCache.get(o.key)??o.size,s=r-i;s!==0&&(((a=this.scrollState)==null?void 0:a.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(o,s,this):o.start<this.getScrollOffset()+this.scrollAdjustments)&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=s,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(o.index),this.itemSizeCache=new Map(this.itemSizeCache.set(o.key,r)),this.notify(!1))},this.getVirtualItems=Hh(()=>[this.getVirtualIndexes(),this.getMeasurements()],(n,r)=>{const a=[];for(let o=0,i=n.length;o<i;o++){const s=n[o],l=r[s];a.push(l)}return a},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=n=>{const r=this.getMeasurements();if(r.length!==0)return W5e(r[fXe(0,r.length-1,a=>W5e(r[a]).start,n)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const n=this.scrollElement.document.documentElement;return this.options.horizontal?n.scrollWidth-this.scrollElement.innerWidth:n.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(n,r,a=0)=>{if(!this.scrollElement)return 0;const o=this.getSize(),i=this.getScrollOffset();r==="auto"&&(r=n>=i+o?"end":"start"),r==="center"?n+=(a-o)/2:r==="end"&&(n-=o);const s=this.getMaxScrollOffset();return Math.max(Math.min(s,n),0)},this.getOffsetForIndex=(n,r="auto")=>{n=Math.max(0,Math.min(n,this.options.count-1));const a=this.getSize(),o=this.getScrollOffset(),i=this.measurementsCache[n];if(!i)return;if(r==="auto")if(i.end>=o+a-this.options.scrollPaddingEnd)r="end";else if(i.start<=o+this.options.scrollPaddingStart)r="start";else return[o,r];if(r==="end"&&n===this.options.count-1)return[this.getMaxScrollOffset(),r];const s=r==="end"?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(s,r,i.size),r]},this.scrollToOffset=(n,{align:r="start",behavior:a="auto"}={})=>{const o=this.getOffsetForAlignment(n,r),i=this.now();this.scrollState={index:null,align:r,behavior:a,startedAt:i,lastTargetOffset:o,stableFrames:0},this._scrollToOffset(o,{adjustments:void 0,behavior:a}),this.scheduleScrollReconcile()},this.scrollToIndex=(n,{align:r="auto",behavior:a="auto"}={})=>{n=Math.max(0,Math.min(n,this.options.count-1));const o=this.getOffsetForIndex(n,r);if(!o)return;const[i,s]=o,l=this.now();this.scrollState={index:n,align:s,behavior:a,startedAt:l,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:a}),this.scheduleScrollReconcile()},this.scrollBy=(n,{behavior:r="auto"}={})=>{const a=this.getScrollOffset()+n,o=this.now();this.scrollState={index:null,align:"start",behavior:r,startedAt:o,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var n;const r=this.getMeasurements();let a;if(r.length===0)a=this.options.paddingStart;else if(this.options.lanes===1)a=((n=r[r.length-1])==null?void 0:n.end)??0;else{const o=Array(this.options.lanes).fill(null);let i=r.length-1;for(;i>=0&&o.some(s=>s===null);){const s=r[i];o[s.lane]===null&&(o[s.lane]=s.end),i--}a=Math.max(...o.filter(s=>s!==null))}return Math.max(a-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(n,{adjustments:r,behavior:a})=>{this.options.scrollToFn(n,{behavior:a,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(t)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId==null&&(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}const r=this.scrollState.index!=null?this.getOffsetForIndex(this.scrollState.index,this.scrollState.align):void 0,a=r?r[0]:this.scrollState.lastTargetOffset,o=1,i=a!==this.scrollState.lastTargetOffset;if(!i&&fNn(a,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=o){this.scrollState=null;return}}else this.scrollState.stableFrames=0,i&&(this.scrollState.lastTargetOffset=a,this.scrollState.behavior="auto",this._scrollToOffset(a,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}};const fXe=(e,t,n,r)=>{for(;e<=t;){const a=(e+t)/2|0,o=n(a);if(o<r)e=a+1;else if(o>r)t=a-1;else return a}return e>0?e-1:0};function wNn({measurements:e,outerSize:t,scrollOffset:n,lanes:r}){const a=e.length-1,o=l=>e[l].start;if(e.length<=r)return{startIndex:0,endIndex:a};let i=fXe(0,a,o,n),s=i;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){const l=Array(r).fill(0);for(;s<a&&l.some(u=>u<n+t);){const u=e[s];l[u.lane]=u.end,s++}const c=Array(r).fill(n+t);for(;i>=0&&c.some(u=>u>=n);){const u=e[i];c[u.lane]=u.start,i--}i=Math.max(0,i-i%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:i,endIndex:s}}const K5e=typeof document<"u"?C.useLayoutEffect:C.useEffect;function SNn({useFlushSync:e=!0,...t}){const n=C.useReducer(()=>({}),{})[1],r={...t,onChange:(o,i)=>{var s;e&&i?J0.flushSync(n):n(),(s=t.onChange)==null||s.call(t,o,i)}},[a]=C.useState(()=>new xNn(r));return a.setOptions(r),K5e(()=>a._didMount(),[]),K5e(()=>a._willUpdate()),a}function bI(e){return SNn({observeElementRect:mNn,observeElementOffset:vNn,scrollToFn:bNn,...e})}const xI={scrollbarGutter:"stable","@supports (-moz-appearance: none)":{scrollbarWidth:"thin",scrollbarColor:"var(--chakra-colors-overlay-scroll-thumb) var(--chakra-colors-overlay-scroll-track)"},"&::-webkit-scrollbar":{width:"12px",height:"12px"},"&::-webkit-scrollbar-track":{background:"var(--chakra-colors-overlay-scroll-track)"},"&::-webkit-scrollbar-thumb":{background:"var(--chakra-colors-overlay-scroll-thumb)",borderRadius:"6px",border:"3px solid transparent",backgroundClip:"padding-box"},"&::-webkit-scrollbar-corner":{background:"transparent"}},CNn={"&::-webkit-scrollbar":{width:"12px",height:"12px"},"&::-webkit-scrollbar:vertical":{display:"none"},"&::-webkit-scrollbar-track":{background:"var(--chakra-colors-overlay-scroll-track)"},"&::-webkit-scrollbar-thumb":{background:"var(--chakra-colors-overlay-scroll-thumb)",borderRadius:"6px",border:"3px solid transparent",backgroundClip:"padding-box"},"&::-webkit-scrollbar-corner":{background:"transparent"}};function Dv(e){const{header:t,footer:n,count:r,estimateSize:a,renderRow:o,overscan:i=4,minWidth:s,headerZIndex:l=3,onScroll:c,rootCss:u,fillParent:d,scrollElRef:f}=e,h=Tt(e.height),g=Tt(e.maxHeight),v=h!==void 0||g!==void 0||d===!0,b=C.useRef(null),y=C.useRef(null),[x,S]=C.useState(0);C.useLayoutEffect(()=>{var L;S(((L=y.current)==null?void 0:L.offsetTop)??0)},[r]);const z=bI({count:r,getScrollElement:()=>b.current,estimateSize:a,overscan:i,scrollMargin:x,measureElement:L=>L==null?void 0:L.getBoundingClientRect().height});if(!v)return p.jsxs(V,{css:u,children:[t,Array.from({length:r},(L,R)=>p.jsx(C.Fragment,{children:o(R)},R)),n]});const M=z.getVirtualItems();return p.jsxs(V,{ref:L=>{b.current=L,f!==void 0&&(f.current=L)},css:{...u,display:"block",overflowY:"auto",minHeight:"0",...d===!0?{flex:"1 1 auto"}:{},...xI},height:d===!0?void 0:h,maxHeight:d===!0?void 0:g,onScroll:c,children:[t!==void 0&&p.jsx(V,{position:"sticky",top:"0",zIndex:l,minWidth:s,background:"bg.surface",children:t}),p.jsx(V,{ref:y,position:"relative",height:`${z.getTotalSize()}px`,minWidth:s,children:M.map(L=>p.jsx(V,{"data-index":L.index,ref:z.measureElement,position:"absolute",top:"0",left:"0",width:"100%",style:{transform:`translateY(${L.start-x}px)`},children:o(L.index)},L.key))}),n]})}const Y5e=ji({position:!0,size:36});function pXe(e){const t=e.getIsPinned();return{borderRight:t==="left"&&e.getIsLastColumn("left")?"2px solid var(--chakra-colors-border, #e2e8f0)":void 0,left:t==="left"?`${e.getStart("left")}px`:void 0,right:t==="right"?`${e.getAfter("right")}px`:void 0,position:t?"sticky":"relative",width:e.getSize(),zIndex:t?1:0,backgroundColor:t?"var(--chakra-colors-bg-panel, white)":void 0}}function kNn({frozenFromValue:e,persistedPinnedColumns:t,setPersistedPinnedColumns:n}){const r=C.useMemo(()=>t??[...e],[t,e]),a=C.useMemo(()=>({left:r,right:[]}),[r]),o=r.length>0,i=C.useCallback(s=>{n(l=>l.includes(s)?l.filter(u=>u!==s):[...l,s])},[n]);return{pinnedColumns:r,columnPinning:a,hasFrozen:o,toggleColumnPin:i}}function zNn({header:e,toggleColumnPin:t,getSortIndex:n,enableMultiSort:r,enableColumnResizing:a}){const o=n(e.id),i=e.column.getIsSorted(),l=i?(i||null)==="asc"?x$:au:k$,c=e.column.getIsPinned();return p.jsxs(p.Fragment,{children:[p.jsxs(Xr,{justify:"space-between",width:"100%",pr:a?"4px":"0",children:[p.jsx(V,{as:"span",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"1",children:e.isPlaceholder?null:eX(e.column.columnDef.header,e.getContext())}),p.jsxs(Xr,{className:"col-controls",gap:0,flexShrink:0,alignItems:"center",css:{opacity:c||i?1:0,"@media (hover: none)":{opacity:c||i?1:.6}},transition:"opacity 0.15s",children:[p.jsx(V,{as:"button","aria-label":c?`Unpin ${e.id}`:`Pin ${e.id}`,onClick:u=>{u.stopPropagation(),t(e.id)},color:c?"fg.default":"fg.muted",_hover:{color:"fg.default",bg:"bg.emphasized"},transition:"color 0.15s",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",w:"24px",h:"24px",css:Y5e,borderRadius:"sm",children:p.jsx(Ut,{icon:WC,style:{width:"10px",height:"10px",transform:c?void 0:"rotate(45deg)"}})}),e.column.getCanSort()&&p.jsxs(V,{as:"button","aria-label":`Sort by ${e.id}`,onClick:u=>{u.stopPropagation(),e.column.toggleSorting(void 0,r)},color:i?"fg.default":"fg.muted",_hover:{color:"fg.default",bg:"bg.emphasized"},cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",w:"24px",h:"24px",css:Y5e,borderRadius:"sm",position:"relative",children:[p.jsx(Ut,{icon:l,style:{width:"10px",height:"10px"}}),i&&o&&r&&p.jsx(Ie,{fontSize:"7px",fontWeight:"bold",color:"fg.muted",lineHeight:"1",position:"absolute",top:"4px",right:"4px",children:o})]})]})]}),a&&p.jsx(Eie,{header:e})]})}const hXe={position:"absolute",right:"0",top:"50%",transform:"translateY(-50%)",width:"2px",height:"16px",bg:"gray.300",borderRadius:"1px"};function gXe(){return p.jsx(V,{css:{...hXe,opacity:.4},pointerEvents:"none"})}function Eie({header:e}){return e.column.getCanResize()?p.jsx(V,{position:"absolute",right:"0",top:"0",bottom:"0",width:"8px",cursor:"col-resize",bg:"transparent",_hover:{_before:{opacity:1,bg:"fg.muted"}},transition:"all 0.2s",zIndex:10,onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler(),_before:{content:'""',...hXe,opacity:.4,transition:"opacity 0.2s"}}):null}function _ie(e,t,n,r){var a;const o=t?pXe(e.column):{},i=e.column.getIsPinned();return{display:"flex",alignItems:"center",...r?{minWidth:`var(--header-${e.id}-size)`,flex:1}:{width:`var(--header-${e.id}-size)`,flex:t||n[e.id]||(a=e.column.columnDef.meta)!=null&&a.width?"none":1},...o,zIndex:i?3:void 0,position:i?"sticky":"relative"}}function Lie(e,t,n,r){const a=e.column.columnDef.meta,o=t?pXe(e.column):{};return{...r?{minWidth:`var(--col-${e.column.id}-size)`,flex:1}:{width:`var(--col-${e.column.id}-size)`,flex:t||n[e.column.id]||a!=null&&a.width?"none":1},...o}}function MNn(e){return t=>{const n=e.findIndex(r=>r.id===t);return n>=0?n+1:void 0}}function Rie(e){return C.useMemo(()=>{const t={};for(const n of e.getFlatHeaders())t[`--header-${n.id}-size`]=`${n.getSize()}px`,t[`--col-${n.column.id}-size`]=`${n.column.getSize()}px`;return t},[e.getState().columnSizingInfo,e.getState().columnSizing])}function TNn(e){return C.useMemo(()=>{const t=e.getFlatHeaders();for(let n=t.length-1;n>=0;n--)if(!t[n].column.getIsPinned())return t[n].id;return null},[e,e.getState().columnPinning])}function wI(e){const[t,n]=M7("sizes",[`density.header.${e}`,`density.row.${e}`]);return{header:parseInt(t??"",10)||36,row:parseInt(n??"",10)||36}}function X5e(e){return e==="start"?"flex-start":e==="end"?"flex-end":"center"}function ENn(e){if(e==="success")return"var(--chakra-colors-status-pos-subtle)";if(e==="warning")return"var(--chakra-colors-status-warn-subtle)";if(e==="danger")return"var(--chakra-colors-status-neg-subtle)";if(e==="info")return"var(--chakra-colors-status-info-subtle)";if(e==="neutral")return"var(--chakra-colors-bg-subtle)"}function mXe(e){const t=C.useMemo(()=>e,[e]);return C.useCallback(n=>{if(t)try{const r=t(BigInt(n));return ENn(r==null?void 0:r.type)}catch{return}},[t])}const _Nn=it(N8.Types.Root),LNn=["brand","success","warning","danger","info","neutral","slack","free"],RNn=["success","warning","danger","info","neutral"],AV=["horizontal","vertical"],PNn={success:A$,warning:Tv,danger:VC,info:Ev,neutral:Lae};function ANn(e){var t;const n=(t=_(e.density))==null?void 0:t.type;return n==="compact"?"sm":n==="comfortable"?"lg":"md"}function vXe(e){const t=_(e);return t?t.value:void 0}function NNn({segments:e,orientation:t,barStyle:n,segByFill:r,segLabelStyle:a,resizeHandleStyle:o,minLabelSizePx:i,onResize:s}){const l=C.useRef(null),[c,u]=C.useState(0);C.useLayoutEffect(()=>{const f=l.current;if(!f||typeof ResizeObserver>"u")return;const h=new ResizeObserver(()=>{const g=f.getBoundingClientRect();u(t==="vertical"?g.height:g.width)});return h.observe(f),()=>h.disconnect()},[t]);const d=e.reduce((f,h)=>f+h.weight,0)||1;return p.jsx(V,{ref:l,css:n,"data-slot":"bar",children:e.map((f,h)=>{const g=f.weight/d*100,v=c*g/100,b=f.fill.type,y=_(f.color),x=vXe(f.label),S=x!==void 0&&(i<=0||v===0||v>=i),z=s!==void 0&&h<e.length-1,M={...r[b],flexGrow:0,flexShrink:0,flexBasis:`${g}%`,...y!==void 0?{background:y}:{}};return p.jsxs(V,{css:M,"data-slot":"seg","data-fill":b,children:[S&&p.jsx(V,{as:"span",css:a,"data-slot":"segLabel",children:x}),z&&p.jsx(V,{css:o,"data-slot":"resizeHandle",onPointerDown:L=>s(L,h,d,c)})]},h)})})}function $Nn(e,t){return{top:e==="tl"||e==="tr"?t:"auto",bottom:e==="bl"||e==="br"?t:"auto",left:e==="tl"||e==="bl"?t:"auto",right:e==="tr"||e==="br"?t:"auto"}}function INn({cell:e,rowKey:t,columnKey:n,rootOrientation:r,storageKey:a,minLabelSizePx:o,barStyles:i,segStyles:s,segLabelStyle:l,resizeHandleStyle:c,statusStyles:u,markerInset:d,onCellClick:f,onSegmentClick:h,onSegmentChange:g}){var v;const b=((v=_(e.orientation))==null?void 0:v.type)==="vertical"?"vertical":r,y=_(e.slot),x=_(e.popover),S=e.segments,z=e.markers,M=C.useCallback((H,K,U,Z)=>{if(!g||Z<=0)return;H.stopPropagation(),H.preventDefault();const G=S[K];if(!G)return;const W=G.weight,J=_(G.min)??0,ae=_(G.max)??U,ne=_(G.step)??0,Y=b==="vertical"?H.clientY:H.clientX,te=ue=>{const oe=b==="vertical"?ue.clientY:ue.clientX,ve=b==="vertical"?Y-oe:oe-Y;let se=W+ve/Z*U;se=Math.max(J,Math.min(ae,se)),ne>0&&(se=Math.round(se/ne)*ne),queueMicrotask(()=>g({row:t,column:n,segmentIndex:BigInt(K),weight:se}))},ie=()=>{window.removeEventListener("pointermove",te),window.removeEventListener("pointerup",ie)};window.addEventListener("pointermove",te),window.addEventListener("pointerup",ie)},[g,S,b,t,n]),L=h!==void 0,R=y!==void 0?p.jsx(mn,{value:y,storageKey:`${a}.slot`}):p.jsx(NNn,{segments:S,orientation:b,barStyle:i[b],segByFill:s[b],segLabelStyle:l,resizeHandleStyle:c,minLabelSizePx:o,onResize:g?M:void 0}),N=x===void 0&&(f!==void 0||L),O=p.jsx(V,{flex:"1",minW:0,display:"flex",alignItems:"center",width:"100%",height:"100%",cursor:N?"pointer":void 0,onClick:N?()=>{f&&f({row:t,column:n}),h&&S.length>0&&h({row:t,column:n,segmentIndex:0n,fill:S[0].fill})}:void 0,children:R}),j=z.length>0?z[0].status.type:void 0,B=j?(u[j]??u.info).markerRing:void 0;return p.jsxs(p.Fragment,{children:[x!==void 0?p.jsxs(nu,{positioning:{placement:"top"},children:[p.jsx(R6,{asChild:!0,children:p.jsx(V,{flex:"1",minW:0,display:"flex",alignItems:"center",width:"100%",height:"100%",cursor:"pointer",children:R})}),p.jsx(go,{children:p.jsx(M4,{children:p.jsx(T4,{padding:"14px 16px",minW:"240px",maxW:"360px",fontSize:"13px",children:p.jsx($C,{padding:0,children:p.jsx(mn,{value:x,storageKey:`${a}.popover`})})})})})]}):O,B&&p.jsx(V,{css:B,"data-slot":"markerRing"}),z.map((H,K)=>{const U=u[H.status.type]??u.info,Z=_(H.label),G={...U.markerIcon,...$Nn(H.at.type,d)};return p.jsxs(s$,{openDelay:150,children:[p.jsx(l$,{asChild:!0,children:p.jsx(V,{css:G,"data-slot":"markerIcon",children:Z!==void 0?Z:p.jsx(Ut,{icon:PNn[H.status.type]??Ev})})}),p.jsx(go,{children:p.jsx(c$,{children:p.jsx(u$,{children:H.message})})})]},K)})]})}const Z5e=180,DNn=C.memo(function({value:t,storageKey:n}){var r,a,o,i,s,l,c;const u=(r=_(t.density))==null?void 0:r.type,d=ANn(t),f=en({key:"matrix"}),h=en({key:"table"}),g=en({key:"sliceFrame"}),v=C.useMemo(()=>f({size:d}),[f,d]),b=C.useMemo(()=>h({size:d}).columnHeader??{},[h,d]),y=C.useMemo(()=>g(),[g]),{header:x,row:S}=wI(d),z=t.orientation.type==="vertical"?"vertical":"horizontal",M=C.useMemo(()=>t.columns.map(Pe=>({key:Pe.key,label:vXe(Pe.label)??Pe.key})),[t.columns]),L=Math.max(M.length,1),R=C.useMemo(()=>{const Pe={};for(const ot of AV)Pe[ot]=f({size:d,orientation:ot}).bar??{};return Pe},[f,d]),N=C.useMemo(()=>{const Pe={};for(const ot of AV)Pe[ot]=f({size:d,orientation:ot}).cell??{};return Pe},[f,d]),O=C.useMemo(()=>{const Pe={};for(const ot of AV){const kt={};for(const Mt of LNn)kt[Mt]=f({size:d,orientation:ot,fill:Mt}).seg??{};Pe[ot]=kt}return Pe},[f,d]),j=C.useMemo(()=>{const Pe={};for(const ot of RNn)Pe[ot]=f({size:d,status:ot});return Pe},[f,d]),B=((a=v.markerIcon)==null?void 0:a.top)??"3px",H=C.useMemo(()=>t.rows.some(Pe=>_(Pe.sublabel)!==void 0),[t.rows]),K=parseInt(((o=v.cell)==null?void 0:o.padding)??"8",10)||8,U=parseInt(((i=R[z])==null?void 0:i.height)??"24",10)||24,Z=Math.round((parseInt(((s=v.rowHeaderSub)==null?void 0:s.fontSize)??"10",10)||10)*1.4)+(parseInt(((l=v.rowHeaderSub)==null?void 0:l.marginTop)??"2",10)||2),G=Math.max(S,U+2*K)+(H?Z:0),W=C.useMemo(()=>{const Pe=_(t.minLabelSize);return Pe===void 0?0:Math.round(Pe)},[t.minLabelSize]),J=C.useMemo(()=>_(t.onCellClick),[t.onCellClick]),ae=C.useMemo(()=>_(t.onSegmentClick),[t.onSegmentClick]),ne=C.useMemo(()=>_(t.onSegmentChange),[t.onSegmentChange]),Y=C.useMemo(()=>gI(),[]),te=!1,ie=_(t.rowHeader)??"",ue=C.useMemo(()=>[Y.accessor(Pe=>Pe.value,{id:"__rowheader__",header:ie,enableSorting:!1,size:Z5e,minSize:80,meta:{columnKey:"__rowheader__",width:`${Z5e}px`}})],[Y,ie]),{state:oe,setState:ve}=Pl(n,{columnSizing:{}}),se=oe.columnSizing,pe=C.useCallback(Pe=>{ve(ot=>({...ot,columnSizing:typeof Pe=="function"?Pe(ot.columnSizing):Pe}))},[ve]),de=yI({data:t.rows,columns:ue,state:{columnSizing:se},onColumnSizingChange:pe,getCoreRowModel:vI(),enableSorting:!1,enableColumnResizing:!0,columnResizeMode:"onChange"}),ge=Rie(de),ye=((c=de.getHeaderGroups()[0])==null?void 0:c.headers)??[],me=`${de.getTotalSize()}px`,Me="90px",Te=90,Be=`repeat(${L}, minmax(${Me}, 1fr))`,ht=`calc(${me} + ${L*Te}px)`,De={position:"sticky",left:0,zIndex:1,background:"bg.surface"},Qe={...De,zIndex:2,background:"bg.panel"},bt=N7(),Ve=C.useMemo(()=>_(t.plotGutter),[t.plotGutter]),ut=(Ve?_(Ve.left):void 0)??(bt==null?void 0:bt.left),_t=(Ve?_(Ve.right):void 0)??(bt==null?void 0:bt.right),Ft=ut!==void 0||_t!==void 0,wt=_t??"0px",Lt=ut??me,Jt=ut!==void 0?{...ge,"--col-__rowheader__-size":ut,"--header-__rowheader__-size":ut}:ge,Dt=Ft?`${Lt} 1fr ${wt}`:`${me} 1fr`,Et=Ft?`repeat(${L}, minmax(0, 1fr))`:Be,Gt=Ft?void 0:ht,Ke=_(t.legend),Se=C.useMemo(()=>{const Pe=[];return t.rows.forEach((ot,kt)=>{const Mt=_(ot.group),At=Pe[Pe.length-1];At&&At.label===Mt?At.rows.push({row:ot,index:kt}):Pe.push({label:Mt,rows:[{row:ot,index:kt}]})}),Pe},[t.rows]),Re=p.jsxs(V,{css:v.header,"data-slot":"header",display:"grid",gridTemplateColumns:Dt,minWidth:Gt,height:`${x}px`,children:[p.jsx(V,{css:Qe,display:"flex",width:"100%",style:Jt,children:ye.map(Pe=>p.jsxs(V,{css:b,"data-slot":"colHeader",position:"relative",display:"flex",alignItems:"center",style:_ie(Pe,te,se,!1),children:[p.jsx(V,{as:"span",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minW:0,children:Pe.column.columnDef.header}),p.jsx(Eie,{header:Pe})]},Pe.id))}),p.jsx(V,{display:"grid",gridTemplateColumns:Et,children:M.map((Pe,ot)=>p.jsxs(V,{css:{...b,position:"relative",display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"},"data-slot":"headerCell",children:[Pe.label,ot<M.length-1&&p.jsx(gXe,{})]},Pe.key))}),Ft&&p.jsx(V,{"data-slot":"headerGutter","aria-hidden":"true",background:"bg.surface"})]}),qe=[];for(const Pe of Se){Pe.label!==void 0&&qe.push({kind:"groupHead",label:Pe.label});for(const ot of Pe.rows)qe.push({kind:"row",row:ot.row,index:ot.index})}const Ye=Pe=>{const ot=qe[Pe];if(ot===void 0)return null;if(ot.kind==="groupHead")return p.jsx(V,{css:v.groupHead,"data-slot":"groupHead",minWidth:Gt,display:"grid",gridTemplateColumns:Dt,children:p.jsx(V,{css:{...De,...v.groupHeadCell,background:"bg.panel"},"data-slot":"groupHeadCell",children:ot.label})});const{row:kt,index:Mt}=ot;return p.jsxs(V,{css:v.row,position:"relative",display:"grid",gridTemplateColumns:Dt,minWidth:Gt,children:[Ft&&p.jsx(V,{position:"absolute",top:"0",bottom:"-1px",right:"0",width:wt,background:"bg.surface",pointerEvents:"none",zIndex:3,"aria-hidden":"true"}),p.jsx(V,{css:De,display:"flex",width:"100%",style:Jt,children:de.getVisibleLeafColumns().map(At=>{const fn=_(kt.sublabel);return p.jsxs(V,{css:v.rowHeader,"data-slot":"rowHeader",style:Lie({column:At},te,se,!1),children:[p.jsx(V,{css:v.rowHeaderName,"data-slot":"rowHeaderName",children:kt.value}),fn!==void 0&&p.jsx(V,{css:v.rowHeaderSub,"data-slot":"rowHeaderSub",children:fn})]},At.id)})}),p.jsx(V,{display:"grid",gridTemplateColumns:Et,children:M.map((At,fn)=>{var rt;const ln=kt.cells.get(At.key),Mn=ln&&((rt=_(ln.orientation))==null?void 0:rt.type)==="vertical"?"vertical":z;let Jn={...N[Mn],height:`${G}px`};return fn===M.length-1&&(Jn={...Jn,borderRightWidth:"0"}),p.jsx(V,{"data-slot":"cell",css:Jn,children:ln&&p.jsx(INn,{cell:ln,rowKey:kt.key,columnKey:At.key,rootOrientation:z,storageKey:`${n}.${kt.key}.${At.key}`,minLabelSizePx:W,barStyles:R,segStyles:O,segLabelStyle:v.segLabel??{},resizeHandleStyle:v.resizeHandle??{},statusStyles:j,markerInset:B,onCellClick:J,onSegmentClick:ae,onSegmentChange:ne})},At.key)})})]},Mt)},$e=Ke&&Ke.length>0?p.jsx(V,{css:y.legendRail,"data-slot":"legend",borderTopWidth:"1px",borderTopColor:"border.subtle",children:Ke.map((Pe,ot)=>{const kt=Pe.fill.type,Mt=O.horizontal[kt]["@layer recipes"]??O.horizontal[kt]??{};return p.jsxs(V,{as:"span",css:y.legendItem,cursor:"default","data-slot":"legendItem",children:[p.jsx(V,{as:"span",css:y.legendSwatch,"data-slot":"legendSwatch",...Mt.background?{background:Mt.background}:{},...Mt.backgroundImage?{backgroundImage:Mt.backgroundImage}:{},...kt==="free"?{borderWidth:"1px",borderStyle:"solid",borderColor:"border.subtle"}:{}}),p.jsx(V,{as:"span",css:y.legendLabel,"data-slot":"legendLabel",children:Pe.label})]},ot)})}):void 0,lt=p.jsx(Dv,{height:_(t.height),maxHeight:_(t.maxHeight),header:Re,footer:$e,count:qe.length,estimateSize:Pe=>{var ot;return((ot=qe[Pe])==null?void 0:ot.kind)==="groupHead"?x:G},renderRow:Ye,minWidth:Gt,rootCss:{...v.root,...Ft?{width:"100%"}:{}}});return u!==void 0?p.jsx(hu,{value:u,children:lt}):lt},(e,t)=>_Nn(e.value,t.value)&&e.storageKey===t.storageKey),ONn=it(Vq.Types.Pagination),jNn=C.memo(function({value:t,storageKey:n}){const r=C.useMemo(()=>_(t.style),[t.style]),a=r?_(r.color):void 0,o=r?_(r.background):void 0,i=r?_(r.activeBackground):void 0,s=r?_(r.activeColor):void 0,l=r?_(r.siblings):void 0,c=t.onPageChange,u=Number(t.page),d=Number(t.pageSize),f=Number(t.count),h=C.useCallback(M=>{queueMicrotask(()=>c(BigInt(M.page-1)))},[c]),v=en({key:"pagination"})(),b=C.useRef(null),y=Rv(b,360),x=Math.max(1,Math.ceil(f/Math.max(1,d))),S=C.useMemo(()=>({...a!==void 0?{color:a}:{}}),[a]),z=C.useMemo(()=>{const M=v.item,L={...i!==void 0?{background:i}:{},...s!==void 0?{color:s}:{}},R=Object.keys(L).length>0;return{...M,...a!==void 0?{color:a}:{},...o!==void 0?{background:o}:{},...R?{_selected:{...M._selected,...L},"&[data-selected]":{...M["&[data-selected]"],...L}}:{}}},[v,a,o,i,s]);return p.jsx(z$t,{count:f,pageSize:d,page:u+1,siblingCount:l!==void 0?Number(l):void 0,onPageChange:h,children:p.jsxs(V,{ref:b,css:v.root,children:[p.jsx(_$t,{asChild:!0,children:p.jsx(V,{as:"button","aria-label":"Previous page",css:{...v.prevTrigger,...S},children:p.jsx(Ut,{icon:kd})})}),y?p.jsxs(V,{as:"span","aria-live":"polite",css:{...v.ellipsis,...S},children:[u+1," / ",x]}):p.jsx(L$t,{render:M=>p.jsx(V,{as:"button","aria-label":`Page ${M.value}`,css:z,children:M.value})}),p.jsx(E$t,{asChild:!0,children:p.jsx(V,{as:"button","aria-label":"Next page",css:{...v.nextTrigger,...S},children:p.jsx(Ut,{icon:r2})})})]})})},(e,t)=>ONn(e.value,t.value)&&e.storageKey===t.storageKey);class yXe{constructor(t=1e3){Lg(this,"rowStates"),Lg(this,"loadedRows"),Lg(this,"loadingTimeouts"),Lg(this,"maxCacheSize"),Lg(this,"listeners",new Set),this.rowStates=new Map,this.loadedRows=new Set,this.loadingTimeouts=new Map,this.maxCacheSize=t}subscribe(t){return this.listeners.add(t),()=>this.listeners.delete(t)}notifyListeners(){this.listeners.forEach(t=>t())}getRowState(t){return this.rowStates.get(t)||{status:"unloaded"}}isRowLoaded(t){return this.loadedRows.has(t)}markRowsLoading(t){const n=Date.now();t.forEach(r=>{this.clearTimeout(r),this.rowStates.set(r,{status:"loading",loadStartTime:n})}),this.cleanup(),this.notifyListeners()}clearTimeout(t){const n=this.loadingTimeouts.get(t);n&&(clearTimeout(n),this.loadingTimeouts.delete(t))}markRowsLoaded(t){t.forEach(n=>{this.clearTimeout(n),this.rowStates.set(n,{status:"loaded"}),this.loadedRows.add(n)}),this.notifyListeners()}markRowsError(t,n){t.forEach(r=>{this.clearTimeout(r),this.rowStates.set(r,{status:"error",error:n})}),this.notifyListeners()}markRowsUnloaded(t){t.forEach(n=>{this.clearTimeout(n),this.rowStates.delete(n),this.loadedRows.delete(n)}),this.notifyListeners()}scheduleLoaded(t,n=300){this.clearTimeout(t);const r=setTimeout(()=>{this.markRowsLoaded([t])},n);this.loadingTimeouts.set(t,r)}cleanup(){if(this.rowStates.size>this.maxCacheSize){const t=this.rowStates.size-this.maxCacheSize,n=this.rowStates.keys();for(let r=0;r<t;r++){const a=n.next().value;a!==void 0&&(this.rowStates.delete(a),this.loadedRows.delete(a))}}}clear(){this.loadingTimeouts.forEach(t=>clearTimeout(t)),this.loadingTimeouts.clear(),this.rowStates.clear(),this.loadedRows.clear(),this.notifyListeners()}getStates(){return new Map(this.rowStates)}}const m6="168px";function Q5e(e){const t={};return e.forEach((n,r)=>{if(n===void 0)return;const a=_(n);a!==void 0&&(t[r]=a.type)}),t}function ok(e,t){const n=C.useMemo(()=>e&&_(e.onApprove),[e]),r=C.useMemo(()=>e&&_(e.onReject),[e]),a=C.useMemo(()=>e&&_(e.onApproveAll),[e]),o=C.useMemo(()=>e&&_(e.onRejectAll),[e]),i=C.useMemo(()=>e&&_(e.onRerun),[e]),s=C.useMemo(()=>e&&_(e.summary),[e]),[l,c]=C.useState(()=>Q5e(t));C.useEffect(()=>{c(Q5e(t))},[t]);const u=C.useCallback(b=>{c(y=>({...y,[b]:"approved"})),n&&queueMicrotask(()=>n({rowIndex:BigInt(b)}))},[n]),d=C.useCallback(b=>{c(y=>({...y,[b]:"rejected"})),r&&queueMicrotask(()=>r({rowIndex:BigInt(b)}))},[r]),f=C.useCallback(()=>{c(()=>{const b={};return t.forEach((y,x)=>{b[x]="approved"}),b}),a&&queueMicrotask(()=>a())},[a,t]),h=C.useCallback(()=>{c(()=>{const b={};return t.forEach((y,x)=>{b[x]="rejected"}),b}),o&&queueMicrotask(()=>o())},[o,t]),g=C.useCallback(()=>{i&&queueMicrotask(()=>i())},[i]),v=C.useCallback(b=>l[b]??"pending",[l]);return C.useMemo(()=>{if(e!==void 0)return{review:e,decisions:l,tagFor:v,approveRow:u,rejectRow:d,approveAll:f,rejectAll:h,rerun:g,summary:s,showFoot:s!==void 0||a!==void 0||o!==void 0||i!==void 0,hasApproveAll:a!==void 0,hasRejectAll:o!==void 0,hasRerun:i!==void 0}},[e,l,v,u,d,f,h,g,s,a,o,i])}function SI({rowIndex:e,controller:t}){const n=ga({key:"button"}),r=t.tagFor(e),a=r==="approved"?"solid":r==="rejected"?"ghost":"outline",o=r==="rejected"?"danger":"ghost";return p.jsxs(p.Fragment,{children:[p.jsx(V,{as:"button",css:n({variant:a,size:"xs"}),"aria-pressed":r==="approved",onClick:i=>{i.stopPropagation(),t.approveRow(e)},children:"Approve"}),p.jsx(V,{as:"button",css:n({variant:o,size:"xs"}),"aria-pressed":r==="rejected",onClick:i=>{i.stopPropagation(),t.rejectRow(e)},children:"Reject"})]})}function ik({controller:e,storageKey:t}){const n=en({key:"commitBar"}),r=C.useMemo(()=>n({}),[n]);return e.showFoot?p.jsxs(V,{css:r.root,"data-slot":"reviewFoot",children:[p.jsx(V,{css:r.draft,children:e.summary!==void 0&&p.jsx(mn,{value:e.summary,storageKey:`${t}.review.summary`})}),p.jsxs(V,{css:r.btnRow,children:[e.hasRejectAll&&p.jsx(V,{as:"button",css:r.btnDanger,onClick:e.rejectAll,children:"Reject all"}),e.hasRerun&&p.jsx(V,{as:"button",css:r.btn,onClick:e.rerun,children:e.review.rerunLabel}),e.hasApproveAll&&p.jsx(V,{as:"button",css:r.btnPrimary,onClick:e.approveAll,children:"Approve all"})]})]}):null}const NV=ji({position:!0,size:36}),FNn=it(xte.Types.Root),$V=(e,t)=>{if(!e)return t;const n=parseInt(e,10);return isNaN(n)?t:n};function BNn(e){var t,n,r;const a=_(e.style);return{variant:a?(t=_(a.variant))==null?void 0:t.type:void 0,size:a?(n=_(a.size))==null?void 0:n.type:void 0,striped:a?_(a.striped):void 0,interactive:_(e.interactive),stickyHeader:a?_(a.stickyHeader):void 0,showColumnBorder:a?_(a.showColumnBorder):void 0,colorPalette:a?(r=_(a.colorPalette))==null?void 0:r.type:void 0}}const l8="__review__";function VNn(e,t){if(e==="count")return $("Integer",BigInt(t.length));if(t.length===0)return $("Null",null);const n=t[0].type;if(e==="sum"||e==="mean"){const a=t.map(i=>typeof i.value=="bigint"?Number(i.value):i.value),o=a.reduce((i,s)=>i+s,0);return e==="mean"?$("Float",o/a.length):n==="Integer"?$("Integer",t.reduce((i,s)=>i+s.value,0n)):$("Float",o)}let r=t[0];for(const a of t){const o=a.value,i=r.value;(e==="min"?o<i:o>i)&&(r=a)}return r}function HNn(e){switch(e.type){case"Integer":return e.value.toLocaleString("en-US");case"Float":return e.value.toLocaleString("en-US",{maximumFractionDigits:2});case"DateTime":return e.value.toISOString().slice(0,10);case"Boolean":return String(e.value);case"String":return e.value;default:return"—"}}const J5e=function({value:t,height:n="100%",rowHeight:r=36,overscan:a=8,onSortChange:o,enableMultiSort:i=!0,maxSortColumns:s=5,loadingDelay:l=0,enableColumnResizing:c,storageKey:u,hidePaginationBand:d}){var f,h,g;const v=C.useMemo(()=>BNn(t),[t]),b=C.useRef(null),y=_(t.style),x=_(t.onCellClick),S=_(t.onCellDoubleClick),z=_(t.onRowClick),M=_(t.onRowDoubleClick),L=_(t.onSortChange),R=_(t.onRowSelectionChange),N=_(t.columnResize),O=N!==void 0?N:c??!0,j=_(t.virtualization)!==!1,B=y?_(y.headerBackground):void 0,H=y?_(y.headerColor)??"gray.500":"gray.500",K=y?_(y.borderColor):void 0,U=y?_(y.zebraBackground):void 0,Z=y?_(y.hoverBackground):void 0,G=y?_(y.selectedBackground):void 0,W=y?_(y.selectedBorderColor):void 0,J=y?_(y.footerBackground):void 0,ae=(f=_(t.density))==null?void 0:f.type,ne=ae==="compact"||ae==="condensed"?"sm":ae==="comfortable"?"lg":v.size??"md",Y=ne==="sm"?6:ne==="lg"?12:10,te=wI(ne).row,ie=y?_(y.rowHeight):void 0,ue=ie!==void 0?Number(ie):void 0,oe=ne==="sm"?"8px":ne==="lg"?"16px":"14px",ve=`${Y}px`,se=en({key:"table"})({size:ne}),pe=se,de=_(t.expandedContent),[ge,ye]=C.useState(()=>new Set),me=C.useCallback(ft=>{ye(Nt=>{const sn=new Set(Nt);return sn.has(ft)?sn.delete(ft):sn.add(ft),sn})},[]),Me=mXe(_(t.rowStatus)),[Te]=C.useState(()=>new yXe),[Be,ht]=C.useState(new Map);C.useEffect(()=>Te.subscribe(()=>{ht(new Map(Te.getStates()))}),[Te]),C.useEffect(()=>()=>{Te.clear()},[Te]);const De=C.useMemo(()=>_(t.review),[t.review]),Qe=De!==void 0,bt=C.useMemo(()=>_(t.reviewStatus),[t.reviewStatus]),Ve=C.useMemo(()=>_(t.reviewApproval),[t.reviewApproval]),ut=C.useMemo(()=>t.rows.map((ft,Nt)=>Ve==null?void 0:Ve(BigInt(Nt))),[t,Ve]),_t=ok(De,ut),Ft=en({key:"reviewChrome"}),wt=C.useMemo(()=>Ft({}),[Ft]),Lt=C.useMemo(()=>{const ft={};for(const Nt of["success","warning","danger","info","neutral"])ft[Nt]=Ft({status:Nt}).statusDot??{};return ft},[Ft]),Jt=gI(),Dt=C.useMemo(()=>t.columns.map(ft=>{const Nt=zr(ft.valueType),sn=Tn(ft.valueType),Fn=_(ft.width),xn=_(ft.minWidth),Pa=_(ft.maxWidth),Qr=ft.render;return Jt.accessor(cr=>cr.get(ft.key),{id:ft.key,header:_(ft.header)??ft.key,enableSorting:!0,sortingFn:(cr,Ar,Cr)=>{const Aa=cr.original.get(Cr),qo=Ar.original.get(Cr),bo=Aa==null?void 0:Aa.value,qr=qo==null?void 0:qo.value;return bo===void 0||qr===void 0?0:sn(bo,qr)},minSize:$V(xn,80),size:$V(Fn,150),maxSize:$V(Pa,400),meta:{print:Nt,columnKey:ft.key,width:Fn,minWidth:xn,maxWidth:Pa,renderFn:Qr}})}),[t.columns,Jt]),Et=C.useMemo(()=>!Qe||De===void 0?Dt:[...Dt,Jt.display({id:l8,header:De.columnLabel,enableSorting:!1,enableResizing:!1,enablePinning:!0,size:parseInt(m6,10),meta:{columnKey:l8,width:m6}})],[Dt,Jt,Qe,De]),{state:Gt,setState:Ke}=Pl(u,{sorting:[],columnSizing:{},pinnedColumns:[...t.frozen],scrollIndex:0}),Se=Gt.sorting,Re=C.useCallback(ft=>{Ke(Nt=>({...Nt,sorting:typeof ft=="function"?ft(Nt.sorting):ft}))},[Ke]),qe=_(t.selection),Ye=(h=qe==null?void 0:qe.mode)==null?void 0:h.type,$e=qe==null?void 0:qe.selected,lt=qe==null?void 0:qe.onChange,Pe=$e!==void 0,[ot,kt]=C.useState({}),Mt=C.useMemo(()=>{if($e){const ft={};for(const Nt of $e)ft[String(Nt)]=!0;return ft}return ot},[$e,ot]),At=C.useRef(null),fn=C.useCallback(ft=>{const Nt=Mt,sn=typeof ft=="function"?ft(Nt):ft,Fn=Object.keys(sn).filter(xn=>sn[xn]).map(xn=>BigInt(parseInt(xn,10)));if(R){const xn=new Set(Object.keys(Nt).filter(Qr=>Nt[Qr])),Pa=new Set(Object.keys(sn).filter(Qr=>sn[Qr]));for(const Qr of Pa)if(!xn.has(Qr)){const cr=BigInt(parseInt(Qr,10));queueMicrotask(()=>R({rowIndex:cr,selected:!0,selectedRowsIndices:Fn}))}for(const Qr of xn)if(!Pa.has(Qr)){const cr=BigInt(parseInt(Qr,10));queueMicrotask(()=>R({rowIndex:cr,selected:!1,selectedRowsIndices:Fn}))}}lt&&queueMicrotask(()=>lt(Fn)),Pe||kt(sn)},[Mt,Pe,R,lt]),rt=C.useCallback((ft,Nt)=>{const sn=Mt;let Fn;const xn=!!sn[String(ft)];if(Ye==="single")Fn=xn?{}:{[String(ft)]:!0};else if(Ye==="range"&&Nt&&At.current!==null){const Pa=Math.min(At.current,ft),Qr=Math.max(At.current,ft);Fn={...sn};for(let cr=Pa;cr<=Qr;cr++)Fn[String(cr)]=!0}else Fn={...sn},xn?delete Fn[String(ft)]:Fn[String(ft)]=!0;fn(Fn),At.current=ft},[Mt,Ye,fn]),ln=C.useCallback(ft=>{Re(Nt=>{const sn=typeof ft=="function"?ft(Nt):ft,Fn=sn.map(xn=>({columnKey:xn.id,direction:xn.desc?"desc":"asc"}));return o==null||o(Fn),L&&sn.forEach((xn,Pa)=>{queueMicrotask(()=>L({columnKey:xn.id,sortIndex:BigInt(Pa),sortDirection:xn.desc?$("desc",null):$("asc",null)}))}),sn})},[o,L,Re]),Mn=C.useCallback((ft,Nt,sn)=>{x&&sn!==void 0&&queueMicrotask(()=>x({rowIndex:ft,columnKey:Nt,cellValue:sn}))},[x]),Jn=C.useCallback((ft,Nt,sn)=>{S&&sn!==void 0&&queueMicrotask(()=>S({rowIndex:ft,columnKey:Nt,cellValue:sn}))},[S]),Er=C.useCallback(ft=>{z&&queueMicrotask(()=>z({rowIndex:ft}))},[z]),_r=C.useCallback(ft=>{M&&queueMicrotask(()=>M({rowIndex:ft}))},[M]),fr=Gt.columnSizing,Vr=C.useCallback(ft=>{Ke(Nt=>({...Nt,columnSizing:typeof ft=="function"?ft(Nt.columnSizing):ft}))},[Ke]),wr=C.useMemo(()=>Gt.pinnedColumns??[...t.frozen],[Gt.pinnedColumns,t.frozen]),pa=C.useMemo(()=>({left:wr,right:Qe?[l8]:[]}),[wr,Qe]),ar=wr.length>0,On=C.useCallback(ft=>{Ke(Nt=>{const sn=Nt.pinnedColumns??[...t.frozen],Fn=sn.includes(ft);return{...Nt,pinnedColumns:Fn?sn.filter(xn=>xn!==ft):[...sn,ft]}})},[Ke,t.frozen]),st=_(t.pagination),dn=st?Number(st.pageSize):void 0,Pn=st?Number(st.page):0,Hn=st==null?void 0:st.onPageChange,pr=dn?Math.max(1,Math.ceil(t.rows.length/dn)):1,Hr=C.useMemo(()=>{if(!dn)return t.rows;const ft=Pn*dn;return t.rows.slice(ft,ft+dn)},[t.rows,dn,Pn]),lr=yI({data:Hr,columns:Et,state:{sorting:Se,columnSizing:fr,rowSelection:Mt,columnPinning:pa},onSortingChange:ln,onColumnSizingChange:Vr,onRowSelectionChange:fn,getCoreRowModel:vI(),getSortedRowModel:dXe(),enableMultiSort:i,isMultiSortEvent:()=>i,maxMultiSortColCount:s,enableColumnResizing:O,columnResizeMode:"onChange",enableRowSelection:!0,enableColumnPinning:!0}),{rows:vr}=lr.getRowModel(),mo=C.useMemo(()=>_(t.groupBy),[t.groupBy]),Fe=C.useMemo(()=>{const ft=new Map;for(const Nt of t.columns){const sn=_(Nt.aggregate);sn!==void 0&&ft.set(Nt.key,{tag:sn.type,renderFn:_(Nt.aggregateRender)})}return ft},[t.columns]),Qt=Gt.groupCollapse,tt=C.useMemo(()=>{if(mo===void 0||mo.length===0)return;const ft=dn?Pn*dn:0,Nt=new Map;vr.forEach((Ar,Cr)=>Nt.set(Ar.index,Cr));const sn=new Map(vr.map(Ar=>[Ar.index,Ar])),Fn={path:"",children:new Map,order:[],members:[]},xn=vr.length;for(let Ar=0;Ar<xn;Ar++){if(sn.get(Ar)===void 0)continue;let Aa=Fn;for(let qo=0;qo<mo.length;qo++){const bo=mo[qo].keys[ft+Ar]??"";let qr=Aa.children.get(bo);qr===void 0&&(qr={path:`${Aa.path}\0${bo}`,depth:qo,label:bo,children:new Map,order:[],members:[]},Aa.children.set(bo,qr),Aa.order.push(qr)),Aa=qr}Aa.members.push(Ar)}const Pa=Ar=>Ar.children.size===0?Ar.members:Ar.order.flatMap(Pa),Qr=[],cr=Ar=>{for(const Cr of Ar.order){const Aa=Pa(Cr),qo=new Map;for(const[qr,{tag:Gs}]of Fe){const yr=Aa.map(Jr=>{var ja,ta;return(ta=(ja=sn.get(Jr))==null?void 0:ja.original)==null?void 0:ta.get(qr)}).filter(Jr=>Jr!==void 0);qo.set(qr,VNn(Gs,yr))}const bo=(Qt==null?void 0:Qt[Cr.path])??mo[Cr.depth].collapsed;Qr.push({kind:"group",path:Cr.path,depth:Cr.depth,label:Cr.label,count:Aa.length,collapsed:bo,aggregates:qo}),!bo&&(Cr.depth===mo.length-1?[...Cr.members].sort((qr,Gs)=>(Nt.get(qr)??0)-(Nt.get(Gs)??0)).forEach(qr=>Qr.push({kind:"leaf",row:sn.get(qr)})):cr(Cr))}};return cr(Fn),Qr},[mo,vr,Fe,Qt,Pn,dn]),gt=C.useCallback((ft,Nt)=>{Ke(sn=>({...sn,groupCollapse:{...sn.groupCollapse??{},[ft]:!Nt}}))},[Ke]),Ot=tt!==void 0?tt.length:vr.length,yn=C.useMemo(()=>{const ft=lr.getFlatHeaders(),Nt={};return ft.forEach(sn=>{Nt[`--header-${sn.id}-size`]=`${sn.getSize()}px`,Nt[`--col-${sn.column.id}-size`]=`${sn.column.getSize()}px`}),Nt},[lr.getState().columnSizingInfo,lr.getState().columnSizing]),Bt=ue??(ae?te:r),vn=bI({count:Ot,getScrollElement:()=>b.current,estimateSize:()=>Bt,overscan:a,measureElement:ft=>ft==null?void 0:ft.getBoundingClientRect().height}),wn=C.useMemo(()=>j?vn.getVirtualItems():Array.from({length:Ot},(ft,Nt)=>({index:Nt,start:Nt*Bt,end:(Nt+1)*Bt,size:Bt,key:Nt,lane:0})),[j,vn,Ot,Bt,vn.getVirtualItems()]),Or=C.useRef(void 0),Zr=C.useCallback(()=>{Or.current&&clearTimeout(Or.current),Or.current=setTimeout(()=>{var ft,Nt;const sn=j?((ft=vn.getVirtualItems()[0])==null?void 0:ft.index)??0:Math.round((((Nt=b.current)==null?void 0:Nt.scrollTop)??0)/Bt);Ke(Fn=>Fn.scrollIndex===sn?Fn:{...Fn,scrollIndex:sn})},150)},[j,vn,Bt,Ke]),qn=C.useRef(!1);C.useEffect(()=>{if(qn.current||vr.length===0)return;qn.current=!0;const ft=Gt.scrollIndex??0;if(ft<=0)return;const Nt=Math.min(ft,vr.length-1);requestAnimationFrame(()=>{j?vn.scrollToIndex(Nt,{align:"start"}):b.current&&(b.current.scrollTop=Nt*Bt)})},[vr.length]),C.useEffect(()=>{const ft=new Set;wn.forEach(sn=>{ft.add(sn.index)});const Nt=[];ft.forEach(sn=>{Te.getRowState(sn).status==="unloaded"&&Nt.push(sn)}),Nt.length>0&&(l>0?(Te.markRowsLoading(Nt),Nt.forEach(sn=>Te.scheduleLoaded(sn,l))):Te.markRowsLoaded(Nt))},[wn,Te,l]);const ca=C.useCallback(ft=>{const Nt=Se.findIndex(sn=>sn.id===ft);return Nt>=0?Nt+1:void 0},[Se]),sa=C.useMemo(()=>ar?lr.getLeftLeafColumns().reduce((ft,Nt)=>ft+Nt.getSize(),0):0,[ar,lr.getState().columnSizing,lr.getState().columnSizingInfo]),vo=N7(),Ya=y?_(y.plotGutter):void 0,Ha=(Ya?_(Ya.left):void 0)??(vo==null?void 0:vo.left),fi=(Ya?_(Ya.right):void 0)??(vo==null?void 0:vo.right),Ma=Ha!==void 0||fi!==void 0,Wa=fi??"0px",Sa=w9(Ha),Oa=Ma&&Sa!==void 0&&sa>0?Sa/sa:1,Nl=Ma&&Sa!==void 0&&sa===0?Ha:void 0,$l=ft=>Ma&&!ft.getIsPinned()?{flex:"1 1 0",width:"auto",minWidth:0,position:"relative",left:void 0,justifyContent:"center",textAlign:"center"}:{},Il=ft=>{const Nt=ft.getIsPinned();return{borderRight:Nt==="left"&&ft.getIsLastColumn("left")?"2px solid var(--chakra-colors-border, #e2e8f0)":void 0,left:Nt==="left"?`${ft.getStart("left")}px`:void 0,right:Nt==="right"?`${ft.getAfter("right")}px`:void 0,position:Nt?"sticky":"relative",width:ft.getSize()*Oa,zIndex:Nt?1:0,backgroundColor:Nt?"var(--chakra-colors-bg-canvas, #fafafa)":void 0}},M1=Tt(y?_(y.height):void 0),Sc=Tt(y?_(y.maxHeight):void 0),yo=!ar&&!Ma?(g=lr.getVisibleLeafColumns().filter(ft=>ft.id!==l8&&!ft.getIsPinned()).at(-1))==null?void 0:g.id:void 0,il=p.jsxs(V,{ref:b,onScroll:Zr,height:M1??n,maxHeight:Sc,overflowY:"auto",overflowX:Ma?"hidden":"auto",overscrollBehaviorX:"contain",css:M1!==void 0||Sc!==void 0?xI:void 0,position:"relative",...Ma?{width:"100%"}:{},children:[p.jsxs(CK,{...v,size:ne,style:{...yn,width:Ma?"100%":ar?lr.getCenterTotalSize()+sa:"100%",minWidth:Ma?0:ar?lr.getCenterTotalSize()+sa:lr.getCenterTotalSize(),tableLayout:"fixed"},children:[p.jsxs(lNe,{style:{display:"block"},position:"sticky",top:0,zIndex:2,bg:"bg.canvas",children:[(()=>{const ft=_(t.columnGroups);return!ft||ft.length===0?null:p.jsx($f,{style:{display:"flex",width:"100%"},children:(()=>{const Nt=!ar&&Object.keys(fr).length===0&&t.columns.every(sn=>_(sn.width)===void 0);return ft.map((sn,Fn)=>{const xn=Array.from(sn.columnKeys);if(xn.length===0)return null;const Pa=xn.map(cr=>`var(--col-${cr}-size)`).join(" + "),Qr=yo!==void 0&&xn.includes(yo);return p.jsx(xf,{bg:B,color:H,style:{width:`calc(${Pa})`,minWidth:`calc(${Pa})`,flex:Nt?`${xn.length} 1 0%`:Qr?"1 0 auto":"none",borderColor:K,paddingLeft:oe,paddingRight:oe,paddingTop:ve,paddingBottom:ve,textAlign:"center",fontWeight:600,borderBottomWidth:0},children:sn.label},`group-${Fn}`)})})()},"column-groups")})(),lr.getHeaderGroups().map(ft=>p.jsxs($f,{style:{display:"flex",width:"100%"},children:[de&&p.jsx(xf,{bg:B,color:H,style:{width:"32px",flex:"none",borderColor:K,paddingLeft:0,paddingRight:0}},"expand-toggle-col-header"),Ye&&p.jsx(xf,{bg:B,color:H,style:{width:"40px",flex:"none",borderColor:K,paddingLeft:0,paddingRight:0,textAlign:"center"},children:Ye==="multiple"&&p.jsx("input",{type:"checkbox","aria-label":"Select all rows",checked:vr.length>0&&Object.values(Mt).filter(Boolean).length===vr.length,ref:Nt=>{if(Nt){const sn=Object.values(Mt).some(Boolean),Fn=vr.length>0&&Object.values(Mt).filter(Boolean).length===vr.length;Nt.indeterminate=sn&&!Fn}},onChange:()=>{const Nt=vr.length>0&&Object.values(Mt).filter(Boolean).length===vr.length,sn={};if(!Nt)for(let Fn=0;Fn<vr.length;Fn++)sn[String(Fn)]=!0;fn(sn)}})},"selection-col-header"),Nl!==void 0&&p.jsx(xf,{"aria-hidden":"true",bg:B,style:{flex:"none",width:Nl,padding:0,borderColor:K,height:`${Bt}px`}}),ft.headers.map(Nt=>{var sn;if(Nt.column.id===l8)return p.jsx(xf,{css:wt.decisionHeader,"data-slot":"decisionHeader",style:{width:`var(--header-${Nt.id}-size)`,flex:"none",height:`${Bt}px`,...Il(Nt.column),zIndex:3,borderColor:K},position:"sticky",children:eX(Nt.column.columnDef.header,Nt.getContext())},Nt.id);const Fn=ca(Nt.id),xn=Nt.column.getIsSorted(),Qr=xn?(xn||null)==="asc"?x$:au:k$,cr=ar?Il(Nt.column):{},Ar=Nt.column.getIsPinned(),Cr=Ma&&!Ar;return p.jsxs(xf,{css:se.columnHeader,bg:B,color:H,_hover:{bg:B??"bg.muted","& .col-controls":{opacity:1},"& .col-resizer::before":{opacity:1}},transition:"background 0.2s",style:{width:`var(--header-${Nt.id}-size)`,flex:ar?"none":fr[Nt.id]||(sn=Nt.column.columnDef.meta)!=null&&sn.width?Nt.column.id===yo?"1 0 auto":"none":1,...cr,zIndex:Ar?3:void 0,borderColor:K,height:`${Bt}px`,display:"flex",alignItems:"center",...$l(Nt.column)},position:Ar&&!Ma?"sticky":"relative",children:[p.jsxs(Xr,{justify:"space-between",align:"center",width:"100%",pr:Cr?"0":O?"4px":"0",children:[p.jsx(V,{as:"span",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:"1",textAlign:Cr?"center":void 0,children:Nt.isPlaceholder?null:eX(Nt.column.columnDef.header,Nt.getContext())}),p.jsxs(Xr,{className:"col-controls",gap:0,flexShrink:0,alignItems:"center",display:Cr?"none":void 0,css:{opacity:Ar||xn?1:0,"@media (hover: none)":{opacity:Ar||xn?1:.6}},transition:"opacity 0.15s",children:[p.jsx(V,{as:"button","aria-label":Ar?`Unpin ${Nt.id}`:`Pin ${Nt.id}`,onClick:Aa=>{Aa.stopPropagation(),On(Nt.id)},color:Ar?"fg.default":"fg.muted",_hover:{color:"fg.default",bg:"bg.emphasized"},transition:"color 0.15s",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",w:"24px",h:"24px",css:NV,borderRadius:"sm",children:p.jsx(Ut,{icon:WC,style:{width:"10px",height:"10px",transform:Ar?void 0:"rotate(45deg)"}})}),Nt.column.getCanSort()&&p.jsxs(V,{as:"button","aria-label":`Sort by ${Nt.id}`,onClick:Aa=>{Aa.stopPropagation(),Nt.column.toggleSorting(void 0,i)},color:xn?"fg.default":"fg.muted",_hover:{color:"fg.default",bg:"bg.emphasized"},cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",w:"24px",h:"24px",css:NV,borderRadius:"sm",position:"relative",children:[p.jsx(Ut,{icon:Qr,style:{width:"10px",height:"10px"}}),xn&&Fn&&i&&p.jsx(Ie,{fontSize:"7px",fontWeight:"bold",color:"fg.muted",lineHeight:"1",position:"absolute",top:"4px",right:"4px",children:Fn})]})]})]}),O&&Nt.column.getCanResize()&&p.jsx(V,{className:"col-resizer",position:"absolute",right:"0",top:"0",bottom:"0",width:"6px",cursor:"ew-resize",bg:"transparent",_hover:{_before:{opacity:1,bg:"fg.muted"}},transition:"all 0.2s",zIndex:10,onMouseDown:Nt.getResizeHandler(),onTouchStart:Nt.getResizeHandler(),_before:{content:'""',position:"absolute",right:"2px",top:"30%",bottom:"30%",width:"1px",bg:"gray.300",opacity:0,transition:"opacity 0.2s"}})]},Nt.id)}),Ma&&p.jsx(xf,{"aria-hidden":"true",bg:"bg.surface",style:{flex:"none",width:Wa,padding:0,border:"none",height:`${Bt}px`}})]},ft.id))]}),p.jsx(kK,{style:{display:"block",position:"relative",height:`${vn.getTotalSize()}px`},children:wn.map(ft=>{var Nt;const sn=tt!==void 0?tt[ft.index]:void 0;if(sn!==void 0&&sn.kind==="group"){const yr=sn;return p.jsx("div",{"data-index":ft.index,ref:vn.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${ft.start}px)`},children:p.jsx($f,{css:pe.groupHead,"data-slot":"groupHead","data-depth":yr.depth,display:"flex",width:"100%",onClick:()=>gt(yr.path,yr.collapsed),children:lr.getVisibleLeafColumns().map((Jr,ja)=>{var ta;const Io=ar?"none":fr[Jr.id]||(ta=Jr.columnDef.meta)!=null&&ta.width?Jr.id===yo?"1 0 auto":"none":1,xi={width:`var(--col-${Jr.id}-size)`,flex:Io,display:"flex",alignItems:"center",minHeight:`${Bt}px`};if(Jr.id===l8)return p.jsx(ds,{css:pe.groupHeadCell,style:{...xi,flex:"none"}},Jr.id);if(ja===0)return p.jsxs(ds,{css:pe.groupHeadCell,"data-slot":"groupHeadLabel",style:{...xi,cursor:"pointer",paddingLeft:`${12+yr.depth*18}px`,gap:"8px",overflow:"visible",whiteSpace:"nowrap"},children:[p.jsx(Ut,{icon:yr.collapsed?r2:au,style:{width:9,height:9}}),yr.label===""?"—":yr.label]},Jr.id);const wi=yr.aggregates.get(Jr.id),pi=Fe.get(Jr.id);return wi===void 0||pi===void 0?p.jsx(ds,{css:pe.groupHeadCell,style:xi},Jr.id):p.jsx(ds,{css:pe.groupHeadAggregate,"data-slot":"groupHeadAggregate",style:xi,children:pi.renderFn!==void 0?p.jsx(mn,{value:pi.renderFn(wi),storageKey:`${u??"table"}.group.${yr.path}.${Jr.id}`}):HNn(wi)},Jr.id)})})},`group:${yr.path}`)}const Fn=sn!==void 0?sn.row:vr[ft.index];if(!Fn)return null;const xn=ft.index,Pa=Be.get(xn)||{status:"unloaded"},Qr=!Te.isRowLoaded(xn)||Pa.status==="loading",cr=BigInt(Fn.index),Ar=!!((Nt=Fn.getIsSelected)!=null&&Nt.call(Fn)),Cr=ft.index%2===1,Aa=Me(ft.index),qo=v.striped&&Cr?U??"var(--chakra-colors-bg-subtle, color-mix(in srgb, currentColor 12%, transparent))":void 0,bo=Aa??(Ar?G:void 0)??qo,qr=ge.has(ft.index),Gs=ue!==void 0&&!qr?{height:`${Bt}px`,overflow:"hidden"}:{minHeight:`${Bt}px`};return p.jsxs("div",{"data-index":ft.index,ref:vn.measureElement,style:{position:"absolute",top:0,left:0,width:"100%",transform:`translateY(${ft.start}px)`,background:bo},children:[p.jsxs($f,{"data-selected":Ar?"true":void 0,style:{display:"flex",width:"100%",...Gs,cursor:z||M?"pointer":void 0,background:"transparent",boxShadow:Ar&&W?`inset 0 0 0 2px ${W}`:void 0},...Z?{_hover:{bg:Z}}:{},onClick:z?()=>Er(cr):void 0,onDoubleClick:M?()=>_r(cr):void 0,children:[Ye&&p.jsx(ds,{style:{width:"40px",flex:"none",display:"flex",alignItems:"center",justifyContent:"center",padding:0,borderColor:K,background:"transparent"},onClick:yr=>yr.stopPropagation(),children:p.jsx("input",{type:Ye==="single"?"radio":"checkbox",checked:Ar,"aria-label":`Select row ${ft.index+1}`,onChange:()=>rt(ft.index,!1),onClick:yr=>{yr.shiftKey&&(yr.preventDefault(),rt(ft.index,!0))}})},"selection"),de&&p.jsx(ds,{style:{width:"32px",flex:"none",display:"flex",alignItems:"center",justifyContent:"center",padding:0,background:"transparent",borderColor:K},onClick:yr=>{yr.stopPropagation(),me(ft.index)},children:p.jsx(V,{as:"button","aria-label":qr?"Collapse row":"Expand row","aria-expanded":qr,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",w:"24px",h:"24px",css:NV,borderRadius:"sm",color:"fg.muted",_hover:{color:"fg.default",bg:"bg.emphasized"},transition:"transform 0.15s",transform:qr?"rotate(90deg)":"none",children:p.jsx(Ut,{icon:r2,style:{width:10,height:10}})})},"expand-toggle"),Nl!==void 0&&p.jsx(ds,{"aria-hidden":"true",style:{flex:"none",width:Nl,padding:0,borderColor:K}}),Fn.getVisibleCells().map(yr=>{var Jr;if(yr.column.id===l8&&_t!==void 0){const Xe=(dn?Pn*dn:0)+Fn.index,Rt=bt==null?void 0:bt(BigInt(Xe)),an=(Rt==null?void 0:Rt.type)==="some"?Rt.value.type:void 0;return p.jsxs(ds,{css:wt.decisionCol,"data-slot":"decisionCol","data-status":an,onClick:Rn=>Rn.stopPropagation(),style:{width:`var(--col-${yr.column.id}-size)`,flex:"none",display:"flex",alignItems:"center",borderColor:K,...Il(yr.column),position:"sticky",zIndex:2},children:[an!==void 0&&p.jsx(V,{as:"span",css:Lt[an],"data-slot":"statusDot",position:"absolute",left:"12px"}),p.jsx(SI,{rowIndex:Xe,controller:_t})]},yr.id)}const ja=yr.getValue(),ta=yr.column.columnDef.meta,Io=(ta==null?void 0:ta.columnKey)??yr.column.id,xi=ar?Il(yr.column):{},wi={width:`var(--col-${yr.column.id}-size)`,flex:ar?"none":fr[yr.column.id]||ta!=null&&ta.width?yr.column.id===yo?"1 0 auto":"none":1,display:"flex",alignItems:"center",overflow:"hidden",borderColor:K,background:xi.backgroundColor??"transparent",...xi,...$l(yr.column)},pi=x?Xe=>{Xe.stopPropagation(),Mn(cr,Io,ja)}:void 0,Dl=S?Xe=>{Xe.stopPropagation(),Jn(cr,Io,ja)}:void 0;if(Qr)return p.jsx(ds,{css:se.cell,style:wi,children:p.jsx(d4,{height:"20px",width:"80%"})},yr.id);if(ja==null)return p.jsx(ds,{css:se.cell,style:wi,onClick:pi,onDoubleClick:Dl},yr.id);if(ta!=null&&ta.renderFn){const Xe=ta.renderFn({rowIndex:cr,columnKey:Io,cellValue:ja});return p.jsx(ds,{css:se.cell,style:wi,onClick:pi,onDoubleClick:Dl,children:p.jsx(mn,{value:Xe,storageKey:`${u}.render.${yr.column.id}`})},yr.id)}return p.jsx(ds,{css:se.cell,style:wi,onClick:pi,onDoubleClick:Dl,children:p.jsx(Ie,{children:((Jr=ta==null?void 0:ta.print)==null?void 0:Jr.call(ta,ja.value))??null})},yr.id)}),Ma&&p.jsx(ds,{"aria-hidden":"true",bg:"bg.surface",style:{flex:"none",width:Wa,padding:0,border:"none"}})]}),de&&qr&&(()=>{const yr=de(cr);return p.jsx(V,{bg:"bg.subtle",borderTop:"1px solid",borderBottom:"1px solid",borderColor:K??"border.subtle",padding:"3",children:p.jsx(mn,{value:yr,storageKey:`${u}.expand.${ft.index}`})})})()]},Fn.id)})}),(()=>{const ft=_(t.footer),Nt=_(t.footerRows),sn=[];if(ft&&sn.push(ft),Nt)for(const Fn of Nt)sn.push(Fn);return sn.length===0?null:p.jsx(VIt,{style:{display:"block"},children:sn.map((Fn,xn)=>{var Pa;const Qr=[];let cr=0;for(let Ar=0;Ar<t.columns.length;Ar++){if(cr>0){cr--;continue}const Cr=t.columns[Ar].key,Aa=(Pa=Fn.get)==null?void 0:Pa.call(Fn,Cr),qo=Aa?Number(_(Aa.colSpan)??1n):1;cr=qo-1;const bo=Array.from({length:qo},(ta,Io)=>`var(--col-${t.columns[Ar+Io].key}-size)`).join(" + "),qr=!ar&&Object.keys(fr).length===0&&t.columns.every(ta=>_(ta.width)===void 0),Gs=qo>1?`calc(${bo})`:`var(--col-${Cr}-size)`,yr=yo!==void 0&&Array.from({length:qo},(ta,Io)=>t.columns[Ar+Io].key).includes(yo),Jr={width:Gs,minWidth:Gs,flex:qr?`${qo} 1 0%`:yr?"1 0 auto":"none",display:"flex",alignItems:"center",overflow:"hidden",paddingLeft:oe,paddingRight:oe,paddingTop:ve,paddingBottom:ve,background:J,borderColor:K,fontWeight:600},ja=Aa==null?void 0:Aa.content;Qr.push(p.jsx(ds,{css:se.cell,style:Jr,children:ja?p.jsx(mn,{value:ja,storageKey:`${u}.footer.${xn}.${Cr}`}):null},`${xn}-${Cr}`))}return p.jsx($f,{style:{display:"flex",width:"100%"},children:Qr},`footer-${xn}`)})})})()]}),st&&!d&&p.jsxs(Xr,{gap:"2",justify:"flex-end",px:"3",py:"2",borderTop:"1px solid",borderColor:"border.subtle",children:[p.jsxs(Ie,{fontSize:"sm",color:"fg.muted",children:["Page ",Pn+1," of ",pr," (",t.rows.length," total)"]}),p.jsx("button",{type:"button","aria-label":"Previous page",disabled:Pn<=0,style:{cursor:Pn<=0?"not-allowed":"pointer",opacity:Pn<=0?.4:1,padding:"4px 8px",borderRadius:"4px",border:"none",background:"transparent"},onClick:()=>{Pn<=0||Hn&&queueMicrotask(()=>Hn(BigInt(Pn-1)))},children:p.jsx(Ut,{icon:kd,style:{width:10,height:10}})}),p.jsx("button",{type:"button","aria-label":"Next page",disabled:Pn>=pr-1,style:{cursor:Pn>=pr-1?"not-allowed":"pointer",opacity:Pn>=pr-1?.4:1,padding:"4px 8px",borderRadius:"4px",border:"none",background:"transparent"},onClick:()=>{Pn>=pr-1||Hn&&queueMicrotask(()=>Hn(BigInt(Pn+1)))},children:p.jsx(Ut,{icon:r2,style:{width:10,height:10}})})]}),_t!==void 0&&_t.showFoot&&p.jsx(ik,{controller:_t,storageKey:u??"table"})]});return ae!==void 0?p.jsx(hu,{value:ae,children:il}):il},WNn=C.memo(function(t){const n=_(t.value.slice),r=n==null?void 0:n.slice;rl(r==null?void 0:r.key);const a=en({key:"sliceFrame"})();if(n===void 0||r===void 0)return p.jsx(J5e,{...t});const o=r.read(),i=n.affordances.map(b=>b.type),s=Lv(i,o),l=Number(r.totalCount()),c=Number(r.resultCount()),u=l>0?Math.round((1-c/l)*100):0,d=_(t.value.pagination),f=d?Number(d.pageSize):0,h=d?Number(d.page):0,g=d?Math.max(1,Math.ceil(t.value.rows.length/f)):1,v=d==null?void 0:d.onPageChange;return p.jsxs(V,{css:{...a.root,height:"100%",minHeight:0,display:"flex",flexDirection:"column"},children:[p.jsx(V,{css:{...a.frameEyebrow,flexShrink:0},children:p.jsx(zd,{slice:r,affordanceKinds:s})}),p.jsx(V,{css:{...a.frameBody,flex:"1 1 0%",minHeight:0,overflow:"hidden"},children:p.jsx(J5e,{...t,hidePaginationBand:!0})}),p.jsxs(V,{css:{...a.frameFooter,flexShrink:0},children:[p.jsx(V,{as:"span",css:a.frameFooterStat,children:c.toLocaleString()}),p.jsx(V,{as:"span",children:`rows · of ${l.toLocaleString()}`}),u>0&&p.jsx(V,{as:"span",css:a.frameFooterDelta,children:`· −${u}%`}),d&&p.jsxs(V,{display:"inline-flex",alignItems:"center",gap:"{spacing.1.5}",marginLeft:"auto",children:[p.jsx(V,{as:"span",children:`page ${h+1} of ${g}`}),p.jsx(Ht.button,{type:"button","aria-label":"Previous page",disabled:h<=0,cursor:h<=0?"not-allowed":"pointer",opacity:h<=0?.4:1,onClick:()=>{h<=0||!v||queueMicrotask(()=>v(BigInt(h-1)))},children:p.jsx(Ut,{icon:kd,style:{width:9,height:9}})}),p.jsx(Ht.button,{type:"button","aria-label":"Next page",disabled:h>=g-1,cursor:h>=g-1?"not-allowed":"pointer",opacity:h>=g-1?.4:1,onClick:()=>{h>=g-1||!v||queueMicrotask(()=>v(BigInt(h+1)))},children:p.jsx(Ut,{icon:r2,style:{width:9,height:9}})})]})]})]})},(e,t)=>FNn(e.value,t.value));zv.add(_v,Eoe,Loe);const UNn=it(Dq.Types.Icon),qNn={xs:"xs",sm:"sm",md:void 0,lg:"lg",xl:"xl","2xl":"2xl"};function GNn(e){var t,n;const r=_(e.style),a=_(e.label),o=r?(t=_(r.size))==null?void 0:t.type:void 0,i=r?_(r.color):void 0,s=r?(n=_(r.colorPalette))==null?void 0:n.type:void 0,l=o?qNn[o]:void 0;return{icon:[e.prefix,e.name],size:l,color:i??(s?`var(--chakra-colors-${s}-500)`:void 0),...a!==void 0?{title:a}:{"aria-hidden":!0}}}function KNn(e){var t,n,r;const a=_(e.style);if(!a)return;const o=_(a.padding),i=_(a.margin),s=_(a.opacity),l=_(a.background),c=_(a.borderRadius),u=(t=_(a.overflow))==null?void 0:t.type,d=(n=_(a.overflowX))==null?void 0:n.type,f=(r=_(a.overflowY))==null?void 0:r.type,h=_(a.width),g=_(a.height),v=_(a.minWidth),b=_(a.minHeight),y=_(a.maxWidth),x=_(a.maxHeight);if(!(s===void 0&&l===void 0&&c===void 0&&u===void 0&&d===void 0&&f===void 0&&h===void 0&&g===void 0&&v===void 0&&b===void 0&&y===void 0&&x===void 0&&!o&&!i))return{display:"inline-block",opacity:s,background:l,borderRadius:c,overflow:u,overflowX:d,overflowY:f,width:h,height:g,minWidth:v,minHeight:b,maxWidth:y,maxHeight:x,pt:o?_(o.top):void 0,pr:o?_(o.right):void 0,pb:o?_(o.bottom):void 0,pl:o?_(o.left):void 0,mt:i?_(i.top):void 0,mr:i?_(i.right):void 0,mb:i?_(i.bottom):void 0,ml:i?_(i.left):void 0}}const bXe=C.memo(function({value:t}){const n=C.useMemo(()=>GNn(t),[t]),r=C.useMemo(()=>KNn(t),[t]);return r?p.jsx(V,{...r,children:p.jsx(Ut,{...n})}):p.jsx(Ut,{...n})},(e,t)=>UNn(e.value,t.value)),YNn=it(Xb.Types.Root);function xXe(e){return e.map(t=>Sr(t,{Item:n=>({value:n.value,label:n.label,indicator:n.indicator,children:[]}),Branch:n=>({value:n.value,label:n.label,indicator:n.indicator,disabled:_(n.disabled)??!1,children:xXe(n.children)})}))}const XNn=C.memo(function({value:t,storageKey:n}){var r,a;const o=_(t.style),i=_(t.label),s=_(t.defaultExpandedValue),l=_(t.defaultSelectedValue),c=_(t.selectionMode),u=o?_(o.itemColor):void 0,d=o?_(o.itemHoverBackground):void 0,f=o?_(o.selectedBackground):void 0,h=o?_(o.selectedColor):void 0,g=o?_(o.caretColor):void 0,v=o?_(o.connectorColor):void 0,{state:b,setState:y}=Pl(n,{expandedValues:s??[],selectedValues:l??[]}),x=C.useMemo(()=>_(t.onExpandedChange),[t.onExpandedChange]),S=C.useMemo(()=>_(t.onSelectionChange),[t.onSelectionChange]),z=C.useMemo(()=>_(t.onFocusChange),[t.onFocusChange]),M=C.useCallback(j=>{y(B=>({...B,expandedValues:j.expandedValue})),x&&queueMicrotask(()=>x(j.expandedValue))},[x,y]),L=C.useCallback(j=>{y(B=>({...B,selectedValues:j.selectedValue})),S&&queueMicrotask(()=>S(j.selectedValue))},[S,y]),R=C.useCallback(j=>{if(z){const B=j.focusedValue!==null?P(j.focusedValue):A;queueMicrotask(()=>z(B))}},[z]),N=C.useMemo(()=>xXe(t.nodes),[t.nodes]),O=C.useMemo(()=>aCt({nodeToValue:j=>j.value,nodeToString:j=>j.label,rootNode:{value:"ROOT",label:"ROOT",children:N}}),[N]);return p.jsx(cDt,{collection:O,size:o?(r=_(o.size))==null?void 0:r.type:void 0,variant:o?(a=_(o.variant))==null?void 0:a.type:void 0,selectionMode:c==null?void 0:c.type,expandedValue:b.expandedValues,selectedValue:b.selectedValues,"aria-label":i,onExpandedChange:M,onSelectionChange:L,onFocusChange:z?R:void 0,color:u,css:{"& [data-part='item']:hover":d?{background:d}:void 0,"& [data-part='item'][data-selected]":f||h?{...f?{background:f}:{},...h?{color:h}:{}}:void 0,"& [data-part='branch-indicator']":g?{color:g}:void 0,"& [data-part='branch-content']":v?{borderColor:v}:void 0},children:p.jsx(vDt,{children:O.rootNode.children.map((j,B)=>p.jsx(wXe,{node:j,indexPath:[B]},j.value))})})},(e,t)=>YNn(e.value,t.value)&&e.storageKey===t.storageKey);function e8e({indicator:e}){const t=_(e);return t?p.jsx(bXe,{value:t}):null}function wXe({node:e,indexPath:t}){return e.children.length>0?p.jsx(T4e,{node:e,indexPath:t,children:p.jsxs(uDt,{children:[p.jsxs(fDt,{children:[p.jsx(pDt,{}),e.indicator&&p.jsx(e8e,{indicator:e.indicator}),p.jsx(hDt,{children:e.label})]}),p.jsx(dDt,{children:e.children.map((r,a)=>p.jsx(wXe,{node:r,indexPath:[...t,a]},r.value))})]})}):p.jsx(T4e,{node:e,indexPath:t,children:p.jsxs(gDt,{children:[e.indicator&&p.jsx(e8e,{indicator:e.indicator}),p.jsx(mDt,{children:e.label})]})})}const SXe=C.createContext(null);function Ov(){return C.useContext(SXe)}function yb(e){return{surface:e.surface,row:e.row,slot:e.slot,event:e.event!==void 0?P(e.event):A}}function ZNn(e){return{library:e.library,key:e.key}}function QNn({children:e}){var t;const n=C.useRef(new Map),r=C.useRef(new Map),a=C.useRef(new Map),[o,i]=C.useState(null),s=C.useRef(null),l=C.useRef(null),c=C.useRef(null),u=C.useCallback(j=>(n.current.set(j.id,j),()=>{n.current.delete(j.id)}),[]),d=C.useCallback((j,B)=>(r.current.set(j,B),j.setAttribute("data-drag-cell",""),()=>{r.current.delete(j)}),[]),f=C.useCallback((j,B)=>(a.current.set(j,B),j.setAttribute("data-drag-sink",""),()=>{a.current.delete(j)}),[]),h=C.useCallback((j,B)=>{if(j.disabled)return!1;const H=n.current.get(j.coord.surface);return H?B.kind==="item"?(H.kinds.add??!1)&&H.sources.includes(B.from.library):B.kind==="edge"?(H.kinds.resize??!1)&&B.from.surface===j.coord.surface&&B.from.row===j.coord.row:(H.kinds.move??!1)&&B.from.surface===j.coord.surface:!1},[]),g=C.useCallback((j,B,H,K)=>{var U;return h(j,B)&&(((U=j.canDrop)==null?void 0:U.call(j,B,H,K))??!0)},[h]),v=C.useCallback((j,B,H,K)=>{var U;return h(j,B)&&((U=j.canDrop)==null?void 0:U.call(j,B,H,K))===!1},[h]),b=C.useCallback((j,B)=>{if(B.kind!=="event")return!1;const H=n.current.get(B.from.surface);return!H||!(H.kinds.remove??!1)?!1:j.kind==="library"?j.library!==void 0&&H.sources.includes(j.library):!0},[]),y=C.useCallback(()=>{for(const j of r.current.keys())j.removeAttribute("data-drop-valid"),j.removeAttribute("data-drop-active"),j.removeAttribute("data-drop-invalid");for(const j of a.current.keys())j.removeAttribute("data-drop-valid"),j.removeAttribute("data-drop-active");c.current=null},[]),x=C.useCallback(j=>{var B,H,K;const U=s.current,Z=c.current;if(y(),(B=l.current)==null||B.removeAttribute("data-dragging"),l.current=null,s.current=null,i(null),!j||!U||!Z)return;const{payload:G,altKey:W,x:J,y:ae}=U,ne=r.current.get(Z),Y=a.current.get(Z);if(ne&&g(ne,G,J,ae)){const te=n.current.get(ne.coord.surface);if(!(te!=null&&te.onDrag))return;const ie=((H=ne.resolveCoord)==null?void 0:H.call(ne,J,ae))??ne.coord;G.kind==="item"?te.onDrag($("add",{from:ZNn(G.from),into:yb(ie),duplicate:W}),G.label!==void 0?{label:G.label}:void 0):G.kind==="edge"?te.onDrag($("resize",{event:yb({...G.from,slot:ie.slot}),edge:$(G.edge,null)})):te.onDrag($("move",{from:yb(G.from),to:yb(ie)}))}else if(Y&&b(Y,G)&&G.kind==="event"){const te=n.current.get(G.from.surface);(K=te==null?void 0:te.onDrag)==null||K.call(te,$("remove",{from:yb(G.from),to:$(Y.kind==="trash"?"trash":"source",null)}))}},[g,b,y]),S=j=>{for(let B=j;B&&B!==document.body;B=B.parentElement){const H=getComputedStyle(B);if(/(auto|scroll)/.test(H.overflowX)&&B.scrollWidth>B.clientWidth||/(auto|scroll)/.test(H.overflowY)&&B.scrollHeight>B.clientHeight)return B}return null},z=C.useCallback((j,B,H,K,U,Z)=>{j.setAttribute("data-dragging",""),l.current=j;for(const[ie,ue]of r.current)g(ue,B)&&ie.setAttribute("data-drop-valid","");for(const[ie,ue]of a.current)b(ue,B)&&ie.setAttribute("data-drop-valid","");const G={payload:B,x:H,y:K,altKey:U};s.current=G,i(G);const W=ie=>{const ue=s.current;if(!ue)return;const oe={...ue,x:ie.clientX,y:ie.clientY,altKey:ie.altKey};s.current=oe,i(oe);const ve=document.elementFromPoint(ie.clientX,ie.clientY),se=(ve==null?void 0:ve.closest("[data-drag-cell], [data-drag-sink]"))??null,pe=se!==null&&se.hasAttribute("data-drop-valid");if(c.current&&c.current!==se&&(c.current.removeAttribute("data-drop-active"),c.current.removeAttribute("data-drop-invalid"),c.current=null),se&&pe){const de=r.current.get(se);de&&v(de,ue.payload,ie.clientX,ie.clientY)?(se.removeAttribute("data-drop-active"),se.setAttribute("data-drop-invalid",""),c.current=se):(se.removeAttribute("data-drop-invalid"),se.setAttribute("data-drop-active",""),c.current=se)}else if(se){const de=r.current.get(se);de&&v(de,ue.payload,ie.clientX,ie.clientY)&&(se.setAttribute("data-drop-invalid",""),c.current=se)}if(Z){const de=S(ve);if(de){const ge=de.getBoundingClientRect(),ye=48,me=12;ie.clientX>ge.right-ye?de.scrollLeft+=me:ie.clientX<ge.left+ye&&(de.scrollLeft-=me),ie.clientY>ge.bottom-ye?de.scrollTop+=me:ie.clientY<ge.top+ye&&(de.scrollTop-=me)}}},J=ie=>{ie.preventDefault()},ae=()=>{document.removeEventListener("pointermove",W),document.removeEventListener("pointerup",ne),document.removeEventListener("pointercancel",Y),document.removeEventListener("keydown",te,!0),Z&&document.removeEventListener("touchmove",J)},ne=()=>{ae(),x(!0)},Y=()=>{ae(),x(!1)},te=ie=>{ie.key==="Escape"&&(ae(),x(!1))};document.addEventListener("pointermove",W),document.addEventListener("pointerup",ne),document.addEventListener("pointercancel",Y),document.addEventListener("keydown",te,!0),Z&&document.addEventListener("touchmove",J,{passive:!1})},[g,v,b,x]),M=C.useCallback((j,B)=>{var H,K;if(s.current)return;const U=j.currentTarget,Z=j.pointerType==="touch"&&((K=(H=j.target).closest)==null?void 0:K.call(H,"[data-drag-grip]"))!==null;if(j.pointerType==="touch"&&!Z){const G=j.clientX,W=j.clientY,J=j.altKey,ae=()=>{clearTimeout(Y),document.removeEventListener("pointermove",ne),document.removeEventListener("pointerup",ae),document.removeEventListener("pointercancel",ae)},ne=te=>{Math.hypot(te.clientX-G,te.clientY-W)>8&&ae()},Y=setTimeout(()=>{ae(),s.current||z(U,B,G,W,J,!0)},300);document.addEventListener("pointermove",ne),document.addEventListener("pointerup",ae),document.addEventListener("pointercancel",ae);return}j.preventDefault(),z(U,B,j.clientX,j.clientY,j.altKey,j.pointerType==="touch")},[z]),L=C.useMemo(()=>({registerTarget:u,registerCell:d,registerSink:f,beginDrag:M,active:o!==null}),[u,d,f,M,o]),R=o!==null&&o.payload.kind==="event"&&(((t=n.current.get(o.payload.from.surface))==null?void 0:t.kinds.remove)??!1),N=C.useRef(null),O=C.useCallback(j=>{var B;if((B=N.current)==null||B.call(N),N.current=null,j){N.current=f(j,{kind:"trash"});const H=s.current;H&&b({kind:"trash"},H.payload)&&j.setAttribute("data-drop-valid","")}},[f,b]);return p.jsxs(SXe.Provider,{value:L,children:[e,R&&J0.createPortal(p.jsx("div",{ref:O,"data-drag-trash":"","aria-label":"Remove (drop to trash)",children:"⌫"}),document.body),o!==null&&J0.createPortal(p.jsx("div",{"data-drag-ghost":"",style:{position:"fixed",left:0,top:0,transform:`translate(${o.x+12}px, ${o.y+8}px)`,pointerEvents:"none",zIndex:1700},children:o.payload.ghost}),document.body)]})}function sk(e){const t=Ov();C.useEffect(()=>{if(!(!t||!e))return t.registerTarget(e)},[t,e])}function lk(e,t=!1,n,r){const a=Ov(),o=C.useRef(null);return C.useCallback(i=>{var s;(s=o.current)==null||s.call(o),o.current=null,a&&i&&e&&(o.current=a.registerCell(i,{coord:e,disabled:t,canDrop:n,resolveCoord:r}))},[a,e,t,n,r])}function JNn(e,t){const n=Ov(),r=C.useRef(null);return C.useCallback(a=>{var o;(o=r.current)==null||o.call(r),r.current=null,n&&a&&(r.current=n.registerSink(a,t!==void 0?{kind:e,library:t}:{kind:e}))},[n,e,t])}function e$n(e,t,n=!1){const r=Ov();return C.useMemo(()=>{if(!(!r||!e||n))return a=>r.beginDrag(a,{kind:"item",from:{library:e.library,key:e.key},...e.label!==void 0?{label:e.label}:{},ghost:t})},[r,e,t,n])}function CI(e,t,n=!1){const r=Ov();return C.useMemo(()=>{if(!(!r||!e||n))return a=>r.beginDrag(a,{kind:"event",from:e,ghost:t})},[r,e,t,n])}function t8e(e,t,n,r=!1){const a=Ov();return C.useMemo(()=>{if(!(!a||!e||r))return o=>a.beginDrag(o,{kind:"edge",from:e,edge:t,ghost:n})},[a,e,t,n,r])}function lT(e){return{surface:e.surface,row:e.row,slot:e.slot,event:e.event!==void 0?P(e.event):A}}function CXe(e,t){if(e.kind==="item")return $("add",{from:{library:e.from.library,key:e.from.key},into:lT(t),duplicate:!1});if(e.kind==="event")return $("move",{from:lT(e.from),to:lT(t)});if(e.kind==="edge")return $("resize",{event:lT({...e.from,slot:t.slot}),edge:$(e.edge,null)})}function t$n(e,t){return`${e.kind==="item"?`i\0${e.from.library}\0${e.from.key}`:`e\0${e.from.surface}\0${e.from.row}\0${e.from.slot}\0${e.from.event}`}${t.row}\0${t.slot}\0${t.event??""}`}function t7(e,t){if(e===void 0||t===void 0)return!0;try{return e(t)===!0}catch(n){return console.error("[DnD] canDrop validator failed (allowing):",n),!0}}function kI(e){const t=C.useRef(new Map),n=C.useRef(e);n.current!==e&&(n.current=e,t.current=new Map);const r=C.useCallback(a=>o=>{const i=n.current;if(i===void 0)return!0;const s=t$n(o,a),l=t.current.get(s);if(l!==void 0)return l;const c=t7(i,CXe(o,a));return t.current.set(s,c),c},[]);return C.useMemo(()=>e===void 0?void 0:r,[e,r])}const n$n=864e5;function r$n(e,t){const n=(t.getTime()-e.getTime())/n$n;return n<=35?"week":n<=1100?"month":"quarter"}function kXe(e,t,n){return e==="auto"?r$n(t,n):e}function zXe(e){switch(e){case"day":return $v;case"week":return ek;case"month":return g6;case"quarter":return g6.every(3)??g6;case"year":return p4}}function a$n(e,t,n){return zXe(kXe(e,t,n))}function o$n(e,t){return e==="year"?"YYYY":e==="week"||e==="day"?"MMM DD":t?"MMM YYYY":"MMM"}let Wh=null;function i$n(e){const t=e.toUpperCase(),n=1.6,r=28;return typeof document<"u"&&(Wh||(Wh=document.createElement("canvas").getContext("2d"),Wh&&(Wh.font="600 10px ui-monospace, SFMono-Regular, Menlo, monospace")),Wh)?Wh.measureText(t).width+n*Math.max(0,t.length-1)+r:t.length*8+r}const s$n=({startDate:e,endDate:t,width:n,height:r,columnHeaderStyles:a,tier:o="auto",format:i})=>{const s=C.useMemo(()=>{const l=cie({domain:[e,t],range:[0,n]}),c=kXe(o,e,t),d=l.ticks(zXe(c)).filter(x=>x.getTime()>e.getTime()&&x.getTime()<t.getTime()),f=[e,...d],h=e.getUTCFullYear()!==t.getUTCFullYear(),g=i??o$n(c,h),v=[];let b=-1/0,y=0;for(const x of f){const S=l(x);if(S-b>=y){const z=km(g,x);v.push({x:S,text:z}),b=S,y=i$n(z)}}return v.map((x,S)=>{var z;return{label:x.text,x0:x.x,x1:((z=v[S+1])==null?void 0:z.x)??n}})},[e,t,n,o,i]);return p.jsx(V,{position:"relative",width:"100%",height:`${r}px`,children:s.map((l,c)=>p.jsx(V,{position:"absolute",left:`${l.x0}px`,width:`${Math.max(l.x1-l.x0,0)}px`,height:"100%",color:"gray.500",css:a,children:l.label},`band-${c}`))})};function l$n(e,t,n){return Math.max(t,Math.min(e,n))}const Y1={toVector(e,t){return e===void 0&&(e=t),Array.isArray(e)?e:[e,e]},add(e,t){return[e[0]+t[0],e[1]+t[1]]},sub(e,t){return[e[0]-t[0],e[1]-t[1]]},addTo(e,t){e[0]+=t[0],e[1]+=t[1]},subTo(e,t){e[0]-=t[0],e[1]-=t[1]}};function n8e(e,t,n){return t===0||Math.abs(t)===1/0?Math.pow(e,n*5):e*t*n/(t+n*e)}function r8e(e,t,n,r=.15){return r===0?l$n(e,t,n):e<t?-n8e(t-e,n-t,r)+t:e>n?+n8e(e-n,n-t,r)+n:e}function c$n(e,[t,n],[r,a]){const[[o,i],[s,l]]=e;return[r8e(t,o,i,r),r8e(n,s,l,a)]}function u$n(e,t){if(typeof e!="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function d$n(e){var t=u$n(e,"string");return typeof t=="symbol"?t:String(t)}function nc(e,t,n){return t=d$n(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function a8e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),n.push.apply(n,r)}return n}function mi(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?a8e(Object(n),!0).forEach(function(r){nc(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a8e(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}const MXe={pointer:{start:"down",change:"move",end:"up"},mouse:{start:"down",change:"move",end:"up"},touch:{start:"start",change:"move",end:"end"},gesture:{start:"start",change:"change",end:"end"}};function o8e(e){return e?e[0].toUpperCase()+e.slice(1):""}const f$n=["enter","leave"];function p$n(e=!1,t){return e&&!f$n.includes(t)}function h$n(e,t="",n=!1){const r=MXe[e],a=r&&r[t]||t;return"on"+o8e(e)+o8e(a)+(p$n(n,a)?"Capture":"")}const g$n=["gotpointercapture","lostpointercapture"];function m$n(e){let t=e.substring(2).toLowerCase();const n=!!~t.indexOf("passive");n&&(t=t.replace("passive",""));const r=g$n.includes(t)?"capturecapture":"capture",a=!!~t.indexOf(r);return a&&(t=t.replace("capture","")),{device:t,capture:a,passive:n}}function v$n(e,t=""){const n=MXe[e],r=n&&n[t]||t;return e+r}function zI(e){return"touches"in e}function TXe(e){return zI(e)?"touch":"pointerType"in e?e.pointerType:"mouse"}function y$n(e){return Array.from(e.touches).filter(t=>{var n,r;return t.target===e.currentTarget||((n=e.currentTarget)===null||n===void 0||(r=n.contains)===null||r===void 0?void 0:r.call(n,t.target))})}function b$n(e){return e.type==="touchend"||e.type==="touchcancel"?e.changedTouches:e.targetTouches}function EXe(e){return zI(e)?b$n(e)[0]:e}function x$n(e){return y$n(e).map(t=>t.identifier)}function IV(e){const t=EXe(e);return zI(e)?t.identifier:t.pointerId}function i8e(e){const t=EXe(e);return[t.clientX,t.clientY]}function w$n(e){const t={};if("buttons"in e&&(t.buttons=e.buttons),"shiftKey"in e){const{shiftKey:n,altKey:r,metaKey:a,ctrlKey:o}=e;Object.assign(t,{shiftKey:n,altKey:r,metaKey:a,ctrlKey:o})}return t}function hR(e,...t){return typeof e=="function"?e(...t):e}function S$n(){}function C$n(...e){return e.length===0?S$n:e.length===1?e[0]:function(){let t;for(const n of e)t=n.apply(this,arguments)||t;return t}}function s8e(e,t){return Object.assign({},t,e||{})}const k$n=32;class z$n{constructor(t,n,r){this.ctrl=t,this.args=n,this.key=r,this.state||(this.state={},this.computeValues([0,0]),this.computeInitial(),this.init&&this.init(),this.reset())}get state(){return this.ctrl.state[this.key]}set state(t){this.ctrl.state[this.key]=t}get shared(){return this.ctrl.state.shared}get eventStore(){return this.ctrl.gestureEventStores[this.key]}get timeoutStore(){return this.ctrl.gestureTimeoutStores[this.key]}get config(){return this.ctrl.config[this.key]}get sharedConfig(){return this.ctrl.config.shared}get handler(){return this.ctrl.handlers[this.key]}reset(){const{state:t,shared:n,ingKey:r,args:a}=this;n[r]=t._active=t.active=t._blocked=t._force=!1,t._step=[!1,!1],t.intentional=!1,t._movement=[0,0],t._distance=[0,0],t._direction=[0,0],t._delta=[0,0],t._bounds=[[-1/0,1/0],[-1/0,1/0]],t.args=a,t.axis=void 0,t.memo=void 0,t.elapsedTime=t.timeDelta=0,t.direction=[0,0],t.distance=[0,0],t.overflow=[0,0],t._movementBound=[!1,!1],t.velocity=[0,0],t.movement=[0,0],t.delta=[0,0],t.timeStamp=0}start(t){const n=this.state,r=this.config;n._active||(this.reset(),this.computeInitial(),n._active=!0,n.target=t.target,n.currentTarget=t.currentTarget,n.lastOffset=r.from?hR(r.from,n):n.offset,n.offset=n.lastOffset,n.startTime=n.timeStamp=t.timeStamp)}computeValues(t){const n=this.state;n._values=t,n.values=this.config.transform(t)}computeInitial(){const t=this.state;t._initial=t._values,t.initial=t.values}compute(t){const{state:n,config:r,shared:a}=this;n.args=this.args;let o=0;if(t&&(n.event=t,r.preventDefault&&t.cancelable&&n.event.preventDefault(),n.type=t.type,a.touches=this.ctrl.pointerIds.size||this.ctrl.touchIds.size,a.locked=!!document.pointerLockElement,Object.assign(a,w$n(t)),a.down=a.pressed=a.buttons%2===1||a.touches>0,o=t.timeStamp-n.timeStamp,n.timeStamp=t.timeStamp,n.elapsedTime=n.timeStamp-n.startTime),n._active){const L=n._delta.map(Math.abs);Y1.addTo(n._distance,L)}this.axisIntent&&this.axisIntent(t);const[i,s]=n._movement,[l,c]=r.threshold,{_step:u,values:d}=n;if(r.hasCustomTransform?(u[0]===!1&&(u[0]=Math.abs(i)>=l&&d[0]),u[1]===!1&&(u[1]=Math.abs(s)>=c&&d[1])):(u[0]===!1&&(u[0]=Math.abs(i)>=l&&Math.sign(i)*l),u[1]===!1&&(u[1]=Math.abs(s)>=c&&Math.sign(s)*c)),n.intentional=u[0]!==!1||u[1]!==!1,!n.intentional)return;const f=[0,0];if(r.hasCustomTransform){const[L,R]=d;f[0]=u[0]!==!1?L-u[0]:0,f[1]=u[1]!==!1?R-u[1]:0}else f[0]=u[0]!==!1?i-u[0]:0,f[1]=u[1]!==!1?s-u[1]:0;this.restrictToAxis&&!n._blocked&&this.restrictToAxis(f);const h=n.offset,g=n._active&&!n._blocked||n.active;g&&(n.first=n._active&&!n.active,n.last=!n._active&&n.active,n.active=a[this.ingKey]=n._active,t&&(n.first&&("bounds"in r&&(n._bounds=hR(r.bounds,n)),this.setup&&this.setup()),n.movement=f,this.computeOffset()));const[v,b]=n.offset,[[y,x],[S,z]]=n._bounds;n.overflow=[v<y?-1:v>x?1:0,b<S?-1:b>z?1:0],n._movementBound[0]=n.overflow[0]?n._movementBound[0]===!1?n._movement[0]:n._movementBound[0]:!1,n._movementBound[1]=n.overflow[1]?n._movementBound[1]===!1?n._movement[1]:n._movementBound[1]:!1;const M=n._active?r.rubberband||[0,0]:[0,0];if(n.offset=c$n(n._bounds,n.offset,M),n.delta=Y1.sub(n.offset,h),this.computeMovement(),g&&(!n.last||o>k$n)){n.delta=Y1.sub(n.offset,h);const L=n.delta.map(Math.abs);Y1.addTo(n.distance,L),n.direction=n.delta.map(Math.sign),n._direction=n._delta.map(Math.sign),!n.first&&o>0&&(n.velocity=[L[0]/o,L[1]/o],n.timeDelta=o)}}emit(){const t=this.state,n=this.shared,r=this.config;if(t._active||this.clean(),(t._blocked||!t.intentional)&&!t._force&&!r.triggerAllEvents)return;const a=this.handler(mi(mi(mi({},n),t),{},{[this.aliasKey]:t.values}));a!==void 0&&(t.memo=a)}clean(){this.eventStore.clean(),this.timeoutStore.clean()}}function M$n([e,t],n){const r=Math.abs(e),a=Math.abs(t);if(r>a&&r>n)return"x";if(a>r&&a>n)return"y"}class T$n extends z$n{constructor(...t){super(...t),nc(this,"aliasKey","xy")}reset(){super.reset(),this.state.axis=void 0}init(){this.state.offset=[0,0],this.state.lastOffset=[0,0]}computeOffset(){this.state.offset=Y1.add(this.state.lastOffset,this.state.movement)}computeMovement(){this.state.movement=Y1.sub(this.state.offset,this.state.lastOffset)}axisIntent(t){const n=this.state,r=this.config;if(!n.axis&&t){const a=typeof r.axisThreshold=="object"?r.axisThreshold[TXe(t)]:r.axisThreshold;n.axis=M$n(n._movement,a)}n._blocked=(r.lockDirection||!!r.axis)&&!n.axis||!!r.axis&&r.axis!==n.axis}restrictToAxis(t){if(this.config.axis||this.config.lockDirection)switch(this.state.axis){case"x":t[1]=0;break;case"y":t[0]=0;break}}}const E$n=e=>e,l8e=.15,_Xe={enabled(e=!0){return e},eventOptions(e,t,n){return mi(mi({},n.shared.eventOptions),e)},preventDefault(e=!1){return e},triggerAllEvents(e=!1){return e},rubberband(e=0){switch(e){case!0:return[l8e,l8e];case!1:return[0,0];default:return Y1.toVector(e)}},from(e){if(typeof e=="function")return e;if(e!=null)return Y1.toVector(e)},transform(e,t,n){const r=e||n.shared.transform;return this.hasCustomTransform=!!r,r||E$n},threshold(e){return Y1.toVector(e,0)}},_$n=0,ck=mi(mi({},_Xe),{},{axis(e,t,{axis:n}){if(this.lockDirection=n==="lock",!this.lockDirection)return n},axisThreshold(e=_$n){return e},bounds(e={}){if(typeof e=="function")return o=>ck.bounds(e(o));if("current"in e)return()=>e.current;if(typeof HTMLElement=="function"&&e instanceof HTMLElement)return e;const{left:t=-1/0,right:n=1/0,top:r=-1/0,bottom:a=1/0}=e;return[[t,n],[r,a]]}}),c8e={ArrowRight:(e,t=1)=>[e*t,0],ArrowLeft:(e,t=1)=>[-1*e*t,0],ArrowUp:(e,t=1)=>[0,-1*e*t],ArrowDown:(e,t=1)=>[0,e*t]};class L$n extends T$n{constructor(...t){super(...t),nc(this,"ingKey","dragging")}reset(){super.reset();const t=this.state;t._pointerId=void 0,t._pointerActive=!1,t._keyboardActive=!1,t._preventScroll=!1,t._delayed=!1,t.swipe=[0,0],t.tap=!1,t.canceled=!1,t.cancel=this.cancel.bind(this)}setup(){const t=this.state;if(t._bounds instanceof HTMLElement){const n=t._bounds.getBoundingClientRect(),r=t.currentTarget.getBoundingClientRect(),a={left:n.left-r.left+t.offset[0],right:n.right-r.right+t.offset[0],top:n.top-r.top+t.offset[1],bottom:n.bottom-r.bottom+t.offset[1]};t._bounds=ck.bounds(a)}}cancel(){const t=this.state;t.canceled||(t.canceled=!0,t._active=!1,setTimeout(()=>{this.compute(),this.emit()},0))}setActive(){this.state._active=this.state._pointerActive||this.state._keyboardActive}clean(){this.pointerClean(),this.state._pointerActive=!1,this.state._keyboardActive=!1,super.clean()}pointerDown(t){const n=this.config,r=this.state;if(t.buttons!=null&&(Array.isArray(n.pointerButtons)?!n.pointerButtons.includes(t.buttons):n.pointerButtons!==-1&&n.pointerButtons!==t.buttons))return;const a=this.ctrl.setEventIds(t);n.pointerCapture&&t.target.setPointerCapture(t.pointerId),!(a&&a.size>1&&r._pointerActive)&&(this.start(t),this.setupPointer(t),r._pointerId=IV(t),r._pointerActive=!0,this.computeValues(i8e(t)),this.computeInitial(),n.preventScrollAxis&&TXe(t)!=="mouse"?(r._active=!1,this.setupScrollPrevention(t)):n.delay>0?(this.setupDelayTrigger(t),n.triggerAllEvents&&(this.compute(t),this.emit())):this.startPointerDrag(t))}startPointerDrag(t){const n=this.state;n._active=!0,n._preventScroll=!0,n._delayed=!1,this.compute(t),this.emit()}pointerMove(t){const n=this.state,r=this.config;if(!n._pointerActive)return;const a=IV(t);if(n._pointerId!==void 0&&a!==n._pointerId)return;const o=i8e(t);if(document.pointerLockElement===t.target?n._delta=[t.movementX,t.movementY]:(n._delta=Y1.sub(o,n._values),this.computeValues(o)),Y1.addTo(n._movement,n._delta),this.compute(t),n._delayed&&n.intentional){this.timeoutStore.remove("dragDelay"),n.active=!1,this.startPointerDrag(t);return}if(r.preventScrollAxis&&!n._preventScroll)if(n.axis)if(n.axis===r.preventScrollAxis||r.preventScrollAxis==="xy"){n._active=!1,this.clean();return}else{this.timeoutStore.remove("startPointerDrag"),this.startPointerDrag(t);return}else return;this.emit()}pointerUp(t){this.ctrl.setEventIds(t);try{this.config.pointerCapture&&t.target.hasPointerCapture(t.pointerId)&&t.target.releasePointerCapture(t.pointerId)}catch{}const n=this.state,r=this.config;if(!n._active||!n._pointerActive)return;const a=IV(t);if(n._pointerId!==void 0&&a!==n._pointerId)return;this.state._pointerActive=!1,this.setActive(),this.compute(t);const[o,i]=n._distance;if(n.tap=o<=r.tapsThreshold&&i<=r.tapsThreshold,n.tap&&r.filterTaps)n._force=!0;else{const[s,l]=n._delta,[c,u]=n._movement,[d,f]=r.swipe.velocity,[h,g]=r.swipe.distance,v=r.swipe.duration;if(n.elapsedTime<v){const b=Math.abs(s/n.timeDelta),y=Math.abs(l/n.timeDelta);b>d&&Math.abs(c)>h&&(n.swipe[0]=Math.sign(s)),y>f&&Math.abs(u)>g&&(n.swipe[1]=Math.sign(l))}}this.emit()}pointerClick(t){!this.state.tap&&t.detail>0&&(t.preventDefault(),t.stopPropagation())}setupPointer(t){const n=this.config,r=n.device;n.pointerLock&&t.currentTarget.requestPointerLock(),n.pointerCapture||(this.eventStore.add(this.sharedConfig.window,r,"change",this.pointerMove.bind(this)),this.eventStore.add(this.sharedConfig.window,r,"end",this.pointerUp.bind(this)),this.eventStore.add(this.sharedConfig.window,r,"cancel",this.pointerUp.bind(this)))}pointerClean(){this.config.pointerLock&&document.pointerLockElement===this.state.currentTarget&&document.exitPointerLock()}preventScroll(t){this.state._preventScroll&&t.cancelable&&t.preventDefault()}setupScrollPrevention(t){this.state._preventScroll=!1,R$n(t);const n=this.eventStore.add(this.sharedConfig.window,"touch","change",this.preventScroll.bind(this),{passive:!1});this.eventStore.add(this.sharedConfig.window,"touch","end",n),this.eventStore.add(this.sharedConfig.window,"touch","cancel",n),this.timeoutStore.add("startPointerDrag",this.startPointerDrag.bind(this),this.config.preventScrollDelay,t)}setupDelayTrigger(t){this.state._delayed=!0,this.timeoutStore.add("dragDelay",()=>{this.state._step=[0,0],this.startPointerDrag(t)},this.config.delay)}keyDown(t){const n=c8e[t.key];if(n){const r=this.state,a=t.shiftKey?10:t.altKey?.1:1;this.start(t),r._delta=n(this.config.keyboardDisplacement,a),r._keyboardActive=!0,Y1.addTo(r._movement,r._delta),this.compute(t),this.emit()}}keyUp(t){t.key in c8e&&(this.state._keyboardActive=!1,this.setActive(),this.compute(t),this.emit())}bind(t){const n=this.config.device;t(n,"start",this.pointerDown.bind(this)),this.config.pointerCapture&&(t(n,"change",this.pointerMove.bind(this)),t(n,"end",this.pointerUp.bind(this)),t(n,"cancel",this.pointerUp.bind(this)),t("lostPointerCapture","",this.pointerUp.bind(this))),this.config.keys&&(t("key","down",this.keyDown.bind(this)),t("key","up",this.keyUp.bind(this))),this.config.filterTaps&&t("click","",this.pointerClick.bind(this),{capture:!0,passive:!1})}}function R$n(e){"persist"in e&&typeof e.persist=="function"&&e.persist()}const uk=typeof window<"u"&&window.document&&window.document.createElement;function LXe(){return uk&&"ontouchstart"in window}function P$n(){return LXe()||uk&&window.navigator.maxTouchPoints>1}function A$n(){return uk&&"onpointerdown"in window}function N$n(){return uk&&"exitPointerLock"in window.document}function $$n(){try{return"constructor"in GestureEvent}catch{return!1}}const U2={isBrowser:uk,gesture:$$n(),touch:LXe(),touchscreen:P$n(),pointer:A$n(),pointerLock:N$n()},I$n=250,D$n=180,O$n=.5,j$n=50,F$n=250,B$n=10,u8e={mouse:0,touch:0,pen:8},V$n=mi(mi({},ck),{},{device(e,t,{pointer:{touch:n=!1,lock:r=!1,mouse:a=!1}={}}){return this.pointerLock=r&&U2.pointerLock,U2.touch&&n?"touch":this.pointerLock?"mouse":U2.pointer&&!a?"pointer":U2.touch?"touch":"mouse"},preventScrollAxis(e,t,{preventScroll:n}){if(this.preventScrollDelay=typeof n=="number"?n:n||n===void 0&&e?I$n:void 0,!(!U2.touchscreen||n===!1))return e||(n!==void 0?"y":void 0)},pointerCapture(e,t,{pointer:{capture:n=!0,buttons:r=1,keys:a=!0}={}}){return this.pointerButtons=r,this.keys=a,!this.pointerLock&&this.device==="pointer"&&n},threshold(e,t,{filterTaps:n=!1,tapsThreshold:r=3,axis:a=void 0}){const o=Y1.toVector(e,n?r:a?1:0);return this.filterTaps=n,this.tapsThreshold=r,o},swipe({velocity:e=O$n,distance:t=j$n,duration:n=F$n}={}){return{velocity:this.transform(Y1.toVector(e)),distance:this.transform(Y1.toVector(t)),duration:n}},delay(e=0){switch(e){case!0:return D$n;case!1:return 0;default:return e}},axisThreshold(e){return e?mi(mi({},u8e),e):u8e},keyboardDisplacement(e=B$n){return e}});mi(mi({},_Xe),{},{device(e,t,{shared:n,pointer:{touch:r=!1}={}}){if(n.target&&!U2.touch&&U2.gesture)return"gesture";if(U2.touch&&r)return"touch";if(U2.touchscreen){if(U2.pointer)return"pointer";if(U2.touch)return"touch"}},bounds(e,t,{scaleBounds:n={},angleBounds:r={}}){const a=i=>{const s=s8e(hR(n,i),{min:-1/0,max:1/0});return[s.min,s.max]},o=i=>{const s=s8e(hR(r,i),{min:-1/0,max:1/0});return[s.min,s.max]};return typeof n!="function"&&typeof r!="function"?[a(),o()]:i=>[a(i),o(i)]},threshold(e,t,n){return this.lockDirection=n.axis==="lock",Y1.toVector(e,this.lockDirection?[.1,3]:0)},modifierKey(e){return e===void 0?"ctrlKey":e},pinchOnWheel(e=!0){return e}});mi(mi({},ck),{},{mouseOnly:(e=!0)=>e});mi(mi({},ck),{},{mouseOnly:(e=!0)=>e});const RXe=new Map,tX=new Map;function H$n(e){RXe.set(e.key,e.engine),tX.set(e.key,e.resolver)}const W$n={key:"drag",engine:L$n,resolver:V$n};function U$n(e,t){if(e==null)return{};var n={},r=Object.keys(e),a,o;for(o=0;o<r.length;o++)a=r[o],!(t.indexOf(a)>=0)&&(n[a]=e[a]);return n}function q$n(e,t){if(e==null)return{};var n=U$n(e,t),r,a;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(a=0;a<o.length;a++)r=o[a],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}const G$n={target(e){if(e)return()=>"current"in e?e.current:e},enabled(e=!0){return e},window(e=U2.isBrowser?window:void 0){return e},eventOptions({passive:e=!0,capture:t=!1}={}){return{passive:e,capture:t}},transform(e){return e}},K$n=["target","eventOptions","window","enabled","transform"];function qE(e={},t){const n={};for(const[r,a]of Object.entries(t))switch(typeof a){case"function":n[r]=a.call(n,e[r],r,e);break;case"object":n[r]=qE(e[r],a);break;case"boolean":a&&(n[r]=e[r]);break}return n}function Y$n(e,t,n={}){const r=e,{target:a,eventOptions:o,window:i,enabled:s,transform:l}=r,c=q$n(r,K$n);if(n.shared=qE({target:a,eventOptions:o,window:i,enabled:s,transform:l},G$n),t){const u=tX.get(t);n[t]=qE(mi({shared:n.shared},c),u)}else for(const u in c){const d=tX.get(u);d&&(n[u]=qE(mi({shared:n.shared},c[u]),d))}return n}class PXe{constructor(t,n){nc(this,"_listeners",new Set),this._ctrl=t,this._gestureKey=n}add(t,n,r,a,o){const i=this._listeners,s=v$n(n,r),l=this._gestureKey?this._ctrl.config[this._gestureKey].eventOptions:{},c=mi(mi({},l),o);t.addEventListener(s,a,c);const u=()=>{t.removeEventListener(s,a,c),i.delete(u)};return i.add(u),u}clean(){this._listeners.forEach(t=>t()),this._listeners.clear()}}class X$n{constructor(){nc(this,"_timeouts",new Map)}add(t,n,r=140,...a){this.remove(t),this._timeouts.set(t,window.setTimeout(n,r,...a))}remove(t){const n=this._timeouts.get(t);n&&window.clearTimeout(n)}clean(){this._timeouts.forEach(t=>void window.clearTimeout(t)),this._timeouts.clear()}}class Z$n{constructor(t){nc(this,"gestures",new Set),nc(this,"_targetEventStore",new PXe(this)),nc(this,"gestureEventStores",{}),nc(this,"gestureTimeoutStores",{}),nc(this,"handlers",{}),nc(this,"config",{}),nc(this,"pointerIds",new Set),nc(this,"touchIds",new Set),nc(this,"state",{shared:{shiftKey:!1,metaKey:!1,ctrlKey:!1,altKey:!1}}),Q$n(this,t)}setEventIds(t){if(zI(t))return this.touchIds=new Set(x$n(t)),this.touchIds;if("pointerId"in t)return t.type==="pointerup"||t.type==="pointercancel"?this.pointerIds.delete(t.pointerId):t.type==="pointerdown"&&this.pointerIds.add(t.pointerId),this.pointerIds}applyHandlers(t,n){this.handlers=t,this.nativeHandlers=n}applyConfig(t,n){this.config=Y$n(t,n,this.config)}clean(){this._targetEventStore.clean();for(const t of this.gestures)this.gestureEventStores[t].clean(),this.gestureTimeoutStores[t].clean()}effect(){return this.config.shared.target&&this.bind(),()=>this._targetEventStore.clean()}bind(...t){const n=this.config.shared,r={};let a;if(!(n.target&&(a=n.target(),!a))){if(n.enabled){for(const i of this.gestures){const s=this.config[i],l=d8e(r,s.eventOptions,!!a);if(s.enabled){const c=RXe.get(i);new c(this,t,i).bind(l)}}const o=d8e(r,n.eventOptions,!!a);for(const i in this.nativeHandlers)o(i,"",s=>this.nativeHandlers[i](mi(mi({},this.state.shared),{},{event:s,args:t})),void 0,!0)}for(const o in r)r[o]=C$n(...r[o]);if(!a)return r;for(const o in r){const{device:i,capture:s,passive:l}=m$n(o);this._targetEventStore.add(a,i,"",r[o],{capture:s,passive:l})}}}}function Uh(e,t){e.gestures.add(t),e.gestureEventStores[t]=new PXe(e,t),e.gestureTimeoutStores[t]=new X$n}function Q$n(e,t){t.drag&&Uh(e,"drag"),t.wheel&&Uh(e,"wheel"),t.scroll&&Uh(e,"scroll"),t.move&&Uh(e,"move"),t.pinch&&Uh(e,"pinch"),t.hover&&Uh(e,"hover")}const d8e=(e,t,n)=>(r,a,o,i={},s=!1)=>{var l,c;const u=(l=i.capture)!==null&&l!==void 0?l:t.capture,d=(c=i.passive)!==null&&c!==void 0?c:t.passive;let f=s?r:h$n(r,a,u);n&&d&&(f+="Passive"),e[f]=e[f]||[],e[f].push(o)};function J$n(e,t={},n,r){const a=C.useMemo(()=>new Z$n(e),[]);if(a.applyHandlers(e,r),a.applyConfig(t,n),C.useEffect(a.effect.bind(a)),C.useEffect(()=>a.clean.bind(a),[]),t.target===void 0)return a.bind.bind(a)}function GE(e,t){return H$n(W$n),J$n({drag:e},t||{},"drag")}function eIn(e){return Sr(e,{committed:()=>"committed",rejected:()=>"rejected",proposed:t=>Sr(t,{added:()=>"proposedAdded",model:()=>"proposedModel",removed:()=>"proposedRemoved"},"proposedAdded")},"committed")}const tIn={committed:"fg.success",proposedAdded:"fg.info",proposedModel:"fg.info",proposedRemoved:"fg.info",rejected:"fg.subtle"},nIn={success:"fg.success",warning:"fg.warning",danger:"fg.danger",info:"fg.info",neutral:"fg.subtle"},rIn={committed:void 0,proposedAdded:"5 3",proposedModel:"3 3",proposedRemoved:"3 3",rejected:void 0},aIn={committed:1,proposedAdded:1,proposedModel:.75,proposedRemoved:.6,rejected:.55},oIn={committed:!1,proposedAdded:!1,proposedModel:!1,proposedRemoved:!0,rejected:!0},iIn={interim:"fg.warning",release:"fg.info"},AXe=e=>{switch(e.type){case"minutes":return e.value*60*1e3;case"hours":return e.value*60*60*1e3;case"days":return e.value*24*60*60*1e3;case"weeks":return e.value*7*24*60*60*1e3;case"months":return e.value*30*24*60*60*1e3}},dx=(e,t)=>{if(!t)return e;const n=AXe(t),r=Math.round(e.getTime()/n)*n;return new Date(r)},sIn=({x:e,y:t,width:n,height:r,value:a,storageKey:o="task",onClick:i,onDoubleClick:s,onDrag:l,onDurationChange:c,onProgressChange:u,timelineStartDate:d,timelineEndDate:f,timelineWidth:h,dragStep:g,durationStep:v})=>{var b,y,x,S,z,M;const L=yUe(),[R,N]=C.useState(!1),[O,j]=C.useState(null),[B,H]=C.useState(null),[K,U]=C.useState(null),[Z,G]=C.useState({x:e,width:n}),[W,J]=C.useState(!1),ae=C.useRef(null),ne=_(a.label),Y=ne?{value:ne.value,align:((b=_(ne.align))==null?void 0:b.type)??"start",verticalAlign:((y=_(ne.verticalAlign))==null?void 0:y.type)??"center",color:_(ne.color),fontWeight:(x=_(ne.fontWeight))==null?void 0:x.type,fontStyle:(S=_(ne.fontStyle))==null?void 0:S.type,fontSize:(z=_(ne.fontSize))==null?void 0:z.type}:null,te=eIn(a.state),ie=(M=_(a.status))==null?void 0:M.type,ue=_(a.progress),oe=_(a.popover),ve=oe!==void 0,[se,pe]=C.useState(ue??0);C.useEffect(()=>{G({x:e,width:n})},[e,n]),C.useEffect(()=>{pe(ue??0)},[ue]);const[de,ge,ye]=M7("colors",[(ie!==void 0?nIn[ie]:void 0)??tIn[te]??"fg.success","bg.canvas","border.strong"]),me=rIn[te],Me=aIn[te],Te=oIn[te],Be=Z.x+(O??0),ht=Math.max(Z.width+(B??0),4),De=Math.max(ht,4),Qe=(Y==null?void 0:Y.fontSize)??"11px",bt=2,Ve=K??se,ut=De*(Ve/100),_t=C.useCallback(()=>N(!0),[]),Ft=C.useCallback(()=>{O===null&&B===null&&K===null&&N(!1)},[O,B,K]),wt=C.useCallback(ot=>{if(!d||!f||!h)return 0;const kt=f.getTime()-d.getTime();return ot/h*kt},[d,f,h]),Lt=C.useCallback(ot=>{if(!d||!f||!h)return 0;const kt=f.getTime()-d.getTime();return ot/kt*h},[d,f,h]),Jt=te==="proposedAdded"||te==="proposedModel"||te==="proposedRemoved",Dt=Jt&&l&&d&&f&&h,Et=Jt&&c&&d&&f&&h,Gt=Jt&&u&&ue!==void 0,Ke=C.useCallback((ot,kt,Mt)=>{if(!Mt||!h||!d||!f)return ot;const At=wt(ot),fn=dx(new Date(kt.getTime()+At),Mt);return Lt(fn.getTime()-kt.getTime())},[h,d,f,wt,Lt]),Se=GE(({active:ot,movement:[kt],tap:Mt,last:At,first:fn})=>{if(fn&&N(!0),Mt){i&&i(),ve&&J(rt=>!rt),j(null),N(!1);return}if(At){if(Dt&&h){const rt=Ke(kt,a.start,g),ln=dx(new Date(a.start.getTime()+wt(rt)),g),Mn=dx(new Date(a.end.getTime()+wt(rt)),g);G(Jn=>({...Jn,x:Jn.x+rt})),l&&l(a.start,a.end,ln,Mn)}j(null),N(!1);return}ot&&Dt&&j(Ke(kt,a.start,g))},{filterTaps:!0,preventDefault:!0}),Re=GE(({active:ot,movement:[kt],last:Mt})=>{if(Mt){if(Et&&h){const At=Ke(kt,a.end,v),fn=dx(new Date(a.end.getTime()+wt(At)),v);G(rt=>({...rt,width:rt.width+At})),c&&c(a.end,fn)}H(null),N(!1);return}ot&&Et&&H(Ke(kt,a.end,v))},{preventDefault:!0}),qe=GE(({active:ot,movement:[kt],last:Mt})=>{if(Mt){if(Gt){const At=kt/De*100,fn=Math.max(0,Math.min(100,se+At));pe(fn),u&&u(se,fn)}U(null),N(!1);return}if(ot&&Gt){const At=kt/De*100;U(Math.max(0,Math.min(100,se+At)))}},{preventDefault:!0}),Ye=C.useCallback(()=>{s&&O===null&&B===null&&s()},[s,O,B]),$e=O!==null?"grabbing":Dt?"grab":i||s||ve?"pointer":"default",lt=R||O!==null||B!==null||K!==null,Pe=C.useCallback(()=>ae.current?ae.current.getBoundingClientRect():{x:0,y:0,width:0,height:0},[]);return p.jsxs("g",{children:[p.jsx("rect",{ref:ae,x:Be,y:t,width:De,height:r,fill:te==="proposedModel"?"transparent":ge,stroke:de,strokeWidth:1,strokeDasharray:me,opacity:(lt?1:.9)*Me,rx:bt,ry:bt,onDoubleClick:Ye,onMouseEnter:_t,onMouseLeave:Ft,...Se(),style:{cursor:$e,touchAction:"none"}}),ue!==void 0&&p.jsx("rect",{x:Be,y:t,width:ut,height:r,fill:de,opacity:Me,rx:bt,ry:bt,style:{pointerEvents:"none"}}),Te&&p.jsx("line",{x1:Be+2,x2:Be+De-2,y1:t+r/2,y2:t+r/2,stroke:de,strokeWidth:1.5,opacity:.9,style:{pointerEvents:"none"}}),Dt&&p.jsx("foreignObject",{x:Be+4,y:t+r/2-6,width:12,height:12,style:{pointerEvents:"none",overflow:"visible"},children:p.jsx(V,{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:ut>=14?"white":"gray.500",opacity:lt?1:0,transition:"opacity 0.2s",children:p.jsx(Ut,{icon:g5,style:{width:9,height:9}})})}),Y&&p.jsx("foreignObject",{x:Be+(Dt?22:8),y:t,width:Math.max(De-(Dt?30:16),0),height:r,style:{pointerEvents:"none"},children:p.jsx(V,{display:"flex",alignItems:X5e(Y.verticalAlign),justifyContent:X5e(Y.align),height:"100%",opacity:lt?1:.9,children:p.jsx(Ie,{fontFamily:"mono",fontSize:typeof Qe=="number"?`${Qe}px`:Qe,color:Y.color??(Ve>=50?"white":"fg.default"),fontWeight:Y.fontWeight??600,fontStyle:Y.fontStyle??(te==="proposedModel"?"italic":void 0),whiteSpace:"nowrap",cursor:$e,userSelect:"none",lineHeight:"1",overflow:"hidden",textOverflow:"ellipsis",m:0,p:0,children:Y.value})})}),Et&&p.jsxs(p.Fragment,{children:[p.jsx("line",{x1:Be+De,x2:Be+De,y1:t+r*.3,y2:t+r*.7,stroke:ye,strokeWidth:1,opacity:lt?1:0,style:{transition:"opacity 0.2s",pointerEvents:"none"}}),p.jsx("rect",{x:Be+De-(L?12:3),y:t,width:L?24:6,height:r,fill:"transparent",onMouseEnter:_t,onMouseLeave:Ft,...Re(),style:{cursor:"ew-resize",touchAction:"none"}})]}),Gt&&ut>8&&p.jsx("rect",{x:Be+ut-(L?12:6),y:t,width:L?24:12,height:r,fill:"transparent",onMouseEnter:_t,onMouseLeave:Ft,...qe(),style:{cursor:"ew-resize",touchAction:"none"}}),ve&&p.jsx(nu,{open:W,onOpenChange:ot=>J(ot.open),positioning:{placement:"top",getAnchorRect:Pe},children:p.jsx(go,{children:p.jsx(M4,{children:p.jsx(T4,{padding:"14px 16px",minW:"240px",maxW:"360px",fontSize:"13px",children:p.jsx($C,{children:p.jsx(mn,{value:oe,storageKey:`${o}.popover`})})})})})})]})},lIn=(e,t,n)=>{const r=n/2;return`${e},${t-r} ${e+r},${t} ${e},${t+r} ${e-r},${t}`},cIn=({x:e,y:t,height:n,value:r,storageKey:a="milestone",onClick:o,onDoubleClick:i,onDrag:s,timelineStartDate:l,timelineEndDate:c,timelineWidth:u})=>{var d,f,h,g,v,b;const[y,x]=C.useState(!1),[S,z]=C.useState(null),[M,L]=C.useState({x:e}),[R,N]=C.useState(!1),O=C.useRef(null);C.useEffect(()=>{L({x:e})},[e]);const j=_(r.label),B=j?{value:j.value,align:((d=_(j.align))==null?void 0:d.type)??"start",verticalAlign:((f=_(j.verticalAlign))==null?void 0:f.type)??"center",color:_(j.color),fontWeight:(h=_(j.fontWeight))==null?void 0:h.type,fontStyle:(g=_(j.fontStyle))==null?void 0:g.type,fontSize:(v=_(j.fontSize))==null?void 0:v.type}:null,H=((b=_(r.kind))==null?void 0:b.type)??"release",K=_(r.popover),U=K!==void 0,[Z,G]=M7("colors",[iIn[H]??"fg.info","white"]),W=M.x+(S??0),J=(B==null?void 0:B.fontSize)??"10px",ae=14,ne=t+n/2,Y=lIn(W,ne,ae),te=C.useCallback(()=>x(!0),[]),ie=C.useCallback(()=>{S===null&&x(!1)},[S]),ue=C.useCallback(ge=>{if(!l||!c||!u)return r.date;const ye=c.getTime()-l.getTime(),me=Math.max(0,Math.min(1,ge/u));return new Date(l.getTime()+me*ye)},[l,c,u,r.date]),oe=s&&l&&c&&u,ve=GE(({active:ge,movement:[ye],tap:me,last:Me,first:Te})=>{if(Te&&x(!0),me){o&&o(),U&&N(Be=>!Be),z(null),x(!1);return}if(Me){if(oe&&u&&(L(Be=>({x:Be.x+ye})),s)){const Be=ue(M.x+ye);s(r.date,Be)}z(null),x(!1);return}ge&&oe&&z(ye)},{filterTaps:!0,preventDefault:!0}),se=C.useCallback(()=>{i&&S===null&&i()},[i,S]),pe=S!==null?"grabbing":oe?"grab":o||i||U?"pointer":"default",de=C.useCallback(()=>O.current?O.current.getBoundingClientRect():{x:0,y:0,width:0,height:0},[]);return p.jsxs("g",{children:[p.jsx("polygon",{ref:O,points:Y,fill:Z,stroke:G,strokeWidth:4,paintOrder:"stroke",strokeLinejoin:"miter",opacity:y||S!==null?1:.9,onDoubleClick:se,onMouseEnter:te,onMouseLeave:ie,...ve(),style:{cursor:pe,touchAction:"none"}}),B&&p.jsx("foreignObject",{x:W-100,y:ne+ae/2+4,width:200,height:14,style:{pointerEvents:"none",overflow:"visible"},children:p.jsx(V,{display:"flex",alignItems:"flex-start",justifyContent:"center",height:"100%",opacity:y||S!==null?1:.9,children:p.jsx(Ie,{fontFamily:"mono",fontSize:typeof J=="number"?`${J}px`:J,color:B.color??Z,fontWeight:B.fontWeight??600,fontStyle:B.fontStyle,whiteSpace:"nowrap",cursor:pe,userSelect:"none",lineHeight:"1",m:0,p:0,children:B.value})})}),U&&p.jsx(nu,{open:R,onOpenChange:ge=>N(ge.open),positioning:{placement:"top",getAnchorRect:de},children:p.jsx(go,{children:p.jsx(M4,{children:p.jsx(T4,{padding:"14px 16px",minW:"240px",maxW:"360px",fontSize:"13px",children:p.jsx($C,{children:p.jsx(mn,{value:K,storageKey:`${a}.popover`})})})})})})]})},uIn=(e,t,n,r)=>{const a=n.getTime()-t.getTime(),o=e.start,i=e.end,s=Math.max(o.getTime(),t.getTime()),l=Math.min(i.getTime(),n.getTime()),c=(s-t.getTime())/a,u=(l-s)/a;return{x:c*r,width:Math.max(u*r,2)}},dIn=(e,t,n,r)=>{const a=n.getTime()-t.getTime(),i=e.date.getTime();return i<t.getTime()||i>n.getTime()?null:{x:(i-t.getTime())/a*r}},fIn=({tasks:e,milestones:t,rowIndex:n,y:r,width:a,height:o,startDate:i,endDate:s,onTaskClick:l,onTaskDoubleClick:c,onMilestoneClick:u,onMilestoneDoubleClick:d,onTaskDrag:f,onTaskDurationChange:h,onTaskProgressChange:g,onMilestoneDrag:v,dragStep:b,durationStep:y,storageKey:x="gantt"})=>{const S=C.useMemo(()=>{const z=Math.min(26,Math.max(16,o-12)),M=r+(o-z)/2,L=e.map((N,O)=>{const j=uIn(N,i,s,a);return j.x<0||j.x>a?null:p.jsx(sIn,{x:j.x,y:M,width:j.width,height:z,value:N,storageKey:`${x}.${n}.task.${O}`,onClick:l?()=>l(N,n,O):void 0,onDoubleClick:c?()=>c(N,n,O):void 0,onDrag:f?(B,H,K,U)=>f(n,O,B,H,K,U):void 0,onDurationChange:h?(B,H)=>h(n,O,B,H):void 0,onProgressChange:g?(B,H)=>g(n,O,B,H):void 0,timelineStartDate:i,timelineEndDate:s,timelineWidth:a,dragStep:b,durationStep:y},`task-${n}-${O}`)}),R=t.map((N,O)=>{const j=dIn(N,i,s,a);return j===null?null:p.jsx(cIn,{x:j.x,y:M,height:z,value:N,storageKey:`${x}.${n}.milestone.${O}`,onClick:u?()=>u(N,n,O):void 0,onDoubleClick:d?()=>d(N,n,O):void 0,onDrag:v?(B,H)=>v(n,O,B,H):void 0,timelineStartDate:i,timelineEndDate:s,timelineWidth:a},`milestone-${n}-${O}`)});return[...L,...R].filter(Boolean)},[e,t,n,r,a,o,i,s,l,c,u,d,f,h,g,v,b,y,x]);return p.jsx("g",{children:S})},pIn=it($x.Types.Root),qh=e=>e.toISOString().slice(0,-1),DV=(e,t)=>{if(!e)return t;const n=parseInt(e,10);return isNaN(n)?t:n};function hIn(e){var t,n;const r=_(e.style);return{variant:r?(t=_(r.variant))==null?void 0:t.type:void 0,size:r?(n=_(r.size))==null?void 0:n.type:void 0,striped:r?_(r.striped):void 0,interactive:!0,stickyHeader:r?_(r.stickyHeader):void 0,showColumnBorder:r?_(r.showColumnBorder):void 0}}const f8e=function({value:t,height:n="100%",rowHeight:r=36,overscan:a=8,onSortChange:o,enableMultiSort:i=!0,maxSortColumns:s=5,loadingDelay:l=200,enableColumnResizing:c=!0,onTaskClick:u,onMilestoneClick:d,tablePanelSize:f,storageKey:h,timelineBrush:g,timelineWindow:v}){var b;const y=C.useMemo(()=>hIn(t),[t]),x=C.useRef(null),[S,z]=C.useState(0);C.useEffect(()=>{const Xe=x.current;if(!Xe)return;const Rt=new ResizeObserver(([an])=>{an&&z(an.contentRect.width)});return Rt.observe(Xe),()=>Rt.disconnect()},[]);const M=_(t.style),L=N7(),R=M?_(M.plotGutter):void 0,N=(R?_(R.left):void 0)??(L==null?void 0:L.left),O=(R?_(R.right):void 0)??(L==null?void 0:L.right),j=N!==void 0||O!==void 0,B=w9(N),H=w9(O)??0,K=_(t.onCellClick),U=_(t.onCellDoubleClick),Z=_(t.onRowClick),G=_(t.onRowDoubleClick),W=_(t.onSortChange),J=_(t.onTaskClick),ae=_(t.onTaskDoubleClick),ne=_(t.onDrag),Y=C.useMemo(()=>_(t.canDrop),[t.canDrop]),te=t.id,ie=_(t.onTaskProgressChange),ue=_(t.onMilestoneClick),oe=_(t.onMilestoneDoubleClick),ve=_(t.dragStep),se=_(t.durationStep),pe=(b=M?_(M.density):void 0)==null?void 0:b.type,de=pe==="compact"?"sm":pe==="comfortable"?"lg":"md",{header:ge,row:ye}=wI(de),me=M?_(M.rowHeight):void 0,Te=(me!==void 0?Number(me):void 0)??(pe?ye:r),Be=en({key:"gantt"})({size:de}),ht=en({key:"table"})({size:de}),De=mXe(_(t.rowStatus)),Qe=C.useMemo(()=>_(t.review),[t.review]),bt=C.useMemo(()=>t.rows.map(Xe=>Xe.approval),[t]),Ve=ok(Qe,bt),ut=en({key:"reviewChrome"}),_t=C.useMemo(()=>ut({size:de}),[ut,de]),Ft=C.useMemo(()=>{const Xe={};for(const Rt of["success","warning","danger","info","neutral"])Xe[Rt]=ut({size:de,status:Rt}).statusDot??{};return Xe},[ut,de]),wt=C.useRef(null),[Lt,Jt]=M7("colors",["gray.300","fg.info"]),Dt=M?_(M.showToday)??!1:!1,Et=C.useRef(null),Gt=C.useRef(null),[Ke,Se]=C.useState(400),[Re,qe]=C.useState(null),Ye=en({key:"sliceFrame"})(),[$e]=C.useState(()=>new yXe),[lt,Pe]=C.useState(new Map),ot=C.useRef(new Set),kt=C.useMemo(()=>_(t.axis),[t.axis]),Mt=C.useMemo(()=>kt?_(kt.range):void 0,[kt]),At=C.useMemo(()=>kt?_(kt.format):void 0,[kt]),fn=C.useMemo(()=>{var Xe;return kt?(Xe=_(kt.tier))==null?void 0:Xe.type:void 0},[kt]),rt=C.useMemo(()=>{if(Mt)return{start:Mt.min,end:Mt.max};let Xe=null,Rt=null;t.rows.forEach(Rn=>{Rn.tasks.forEach(hr=>{const kr=hr.start,to=hr.end;(Xe===null||kr<Xe)&&(Xe=kr),(Rt===null||to>Rt)&&(Rt=to)}),Rn.milestones.forEach(hr=>{const kr=hr.date;(Xe===null||kr<Xe)&&(Xe=kr),(Rt===null||kr>Rt)&&(Rt=kr)})}),Xe===null&&(Xe=new Date),Rt===null&&(Rt=new Date),Xe.getTime()===Rt.getTime()&&(Xe=new Date(Xe.getTime()-864e5),Rt=new Date(Rt.getTime()+864e5));const an=a$n(fn??"auto",Xe,Rt);return{start:an.floor(Xe),end:an.ceil(Rt)}},[t.rows,Mt,fn]),ln=j?Math.max(0,Ke-H):Ke,Mn=C.useMemo(()=>cie({domain:[rt.start,rt.end],range:[0,ln]}),[rt.start,rt.end,ln]),Jn=C.useMemo(()=>Mn.ticks(Math.max(2,Math.floor(Ke/100))).map(Xe=>Mn(Xe)).filter(Xe=>Xe>=0&&Xe<=Ke),[Mn,Ke]);C.useEffect(()=>{const Xe=Gt.current;if(!Xe)return;const Rt=()=>{const Rn=Xe.offsetWidth;Se(Math.max(200,Rn))};Rt();const an=new ResizeObserver(Rt);return an.observe(Xe),()=>an.disconnect()},[]),C.useEffect(()=>$e.subscribe(()=>{Pe(new Map($e.getStates()))}),[$e]),C.useEffect(()=>()=>{$e.clear()},[$e]);const Er=gI(),_r=C.useMemo(()=>t.columns.map(Xe=>{const Rt=zr(Xe.valueType),an=Tn(Xe.valueType),Rn=_(Xe.width),hr=_(Xe.minWidth),kr=_(Xe.maxWidth),to=Xe.render;return Er.accessor(Na=>Na.cells.get(Xe.key),{id:Xe.key,header:_(Xe.header)??Xe.key,enableSorting:!0,sortingFn:(Na,Go,Si)=>{const ri=Na.original.cells.get(Si),Nr=Go.original.cells.get(Si),no=ri==null?void 0:ri.value,y2=Nr==null?void 0:Nr.value;return no===void 0||y2===void 0?0:an(no,y2)},minSize:DV(hr,80),size:DV(Rn,150),maxSize:DV(kr,400),meta:{print:Rt,columnKey:Xe.key,width:Rn,minWidth:hr,maxWidth:kr,renderFn:to}})}),[t.columns,Er]),{state:fr,setState:Vr}=Pl(h,{sorting:[],columnSizing:{},pinnedColumns:[...t.frozen],tablePanelSize:null}),wr=fr.sorting,{columnPinning:pa,hasFrozen:ar,toggleColumnPin:On}=kNn({frozenFromValue:t.frozen,persistedPinnedColumns:fr.pinnedColumns,setPersistedPinnedColumns:Xe=>Vr(Rt=>({...Rt,pinnedColumns:Xe(Rt.pinnedColumns??[...t.frozen])}))}),st=MNn(wr),dn=C.useCallback(Xe=>{Vr(Rt=>({...Rt,sorting:typeof Xe=="function"?Xe(Rt.sorting):Xe}))},[Vr]),Pn=C.useCallback(Xe=>{dn(Rt=>{const an=typeof Xe=="function"?Xe(Rt):Xe,Rn=an.map(hr=>({columnKey:hr.id,direction:hr.desc?"desc":"asc"}));return o==null||o(Rn),W&&an.forEach((hr,kr)=>{queueMicrotask(()=>W({columnKey:hr.id,sortIndex:BigInt(kr),sortDirection:hr.desc?$("desc",null):$("asc",null)}))}),an})},[o,W,dn]),Hn=C.useCallback((Xe,Rt,an)=>{K&&an!==void 0&&queueMicrotask(()=>K({rowIndex:Xe,columnKey:Rt,cellValue:an}))},[K]),pr=C.useCallback((Xe,Rt,an)=>{U&&an!==void 0&&queueMicrotask(()=>U({rowIndex:Xe,columnKey:Rt,cellValue:an}))},[U]),Hr=C.useCallback(Xe=>{Z&&queueMicrotask(()=>Z({rowIndex:Xe}))},[Z]),lr=C.useCallback(Xe=>{G&&queueMicrotask(()=>G({rowIndex:Xe}))},[G]),vr=C.useCallback((Xe,Rt,an,Rn)=>{J&&queueMicrotask(()=>J({rowIndex:Xe,taskIndex:Rt,taskStart:an,taskEnd:Rn}))},[J]),mo=C.useCallback((Xe,Rt,an)=>{ue&&queueMicrotask(()=>ue({rowIndex:Xe,milestoneIndex:Rt,milestoneDate:an}))},[ue]),Fe=C.useCallback((Xe,Rt,an,Rn)=>{ae&&queueMicrotask(()=>ae({rowIndex:Xe,taskIndex:Rt,taskStart:an,taskEnd:Rn}))},[ae]),Qt=C.useCallback((Xe,Rt,an)=>{oe&&queueMicrotask(()=>oe({rowIndex:Xe,milestoneIndex:Rt,milestoneDate:an}))},[oe]),tt=C.useCallback(Xe=>{(Xe.type==="move"||Xe.type==="resize")&&!t7(Y,Xe)||ne&&queueMicrotask(()=>ne(Xe))},[ne,Y]),gt=C.useCallback((Xe,Rt,an,Rn,hr,kr)=>{tt($("move",{from:{surface:te,row:String(Xe),slot:qh(an),event:P(`t${Rt}`)},to:{surface:te,row:String(Xe),slot:qh(hr),event:A}}))},[tt,te]),Ot=C.useCallback((Xe,Rt,an,Rn)=>{ie&&queueMicrotask(()=>ie({rowIndex:Xe,taskIndex:Rt,previousProgress:an,newProgress:Rn}))},[ie]),yn=C.useCallback((Xe,Rt,an,Rn)=>{tt($("move",{from:{surface:te,row:String(Xe),slot:qh(an),event:P(`m${Rt}`)},to:{surface:te,row:String(Xe),slot:qh(Rn),event:A}}))},[tt,te]),Bt=C.useCallback((Xe,Rt,an,Rn)=>{tt($("resize",{event:{surface:te,row:String(Xe),slot:qh(Rn),event:P(`t${Rt}`)},edge:$("end",null)}))},[tt,te]),vn=C.useCallback((Xe,Rt,an)=>{J&&vr(BigInt(Rt),BigInt(an),Xe.start,Xe.end)},[J,vr]),wn=C.useCallback((Xe,Rt,an)=>{ae&&Fe(BigInt(Rt),BigInt(an),Xe.start,Xe.end)},[ae,Fe]),Or=C.useCallback((Xe,Rt,an)=>{ue&&mo(BigInt(Rt),BigInt(an),Xe.date)},[ue,mo]),Zr=C.useCallback((Xe,Rt,an)=>{oe&&Qt(BigInt(Rt),BigInt(an),Xe.date)},[oe,Qt]),qn=C.useCallback((Xe,Rt,an,Rn)=>{Ot(BigInt(Xe),BigInt(Rt),an,Rn)},[Ot]),ca=ve?{type:ve.type,value:ve.value}:void 0,sa=se?{type:se.type,value:se.value}:void 0,vo=fr.columnSizing,Ya=C.useCallback(Xe=>{Vr(Rt=>({...Rt,columnSizing:typeof Xe=="function"?Xe(Rt.columnSizing):Xe}))},[Vr]),[Ha,fi]=C.useState(null),Ma=C.useCallback(Xe=>{Xe.size[0]!==void 0&&fi(Xe.size[0])},[]),Wa=C.useCallback(Xe=>{Xe.size[0]!==void 0&&Vr(Rt=>({...Rt,tablePanelSize:Xe.size[0]})),fi(null)},[Vr]),Sa=yI({data:t.rows,columns:_r,state:{sorting:wr,columnSizing:vo,columnPinning:pa},onSortingChange:Pn,onColumnSizingChange:Ya,getCoreRowModel:vI(),getSortedRowModel:dXe(),enableMultiSort:i,isMultiSortEvent:()=>i,maxMultiSortColCount:s,enableColumnResizing:c,columnResizeMode:"onChange",enableColumnPinning:!0}),{rows:Oa}=Sa.getRowModel(),Nl=C.useCallback((Xe,Rt,an,Rn,hr,kr)=>{var to;const Na=((to=Oa[Xe])==null?void 0:to.index)??Xe;gt(BigInt(Na),BigInt(Rt),an,Rn,hr,kr)},[gt,Oa]),$l=C.useCallback((Xe,Rt,an,Rn)=>{var hr;const kr=((hr=Oa[Xe])==null?void 0:hr.index)??Xe;yn(BigInt(kr),BigInt(Rt),an,Rn)},[yn,Oa]),Il=C.useCallback((Xe,Rt,an,Rn)=>{var hr;const kr=((hr=Oa[Xe])==null?void 0:hr.index)??Xe;Bt(BigInt(kr),BigInt(Rt),an,Rn)},[Bt,Oa]),M1=Rie(Sa),Sc=Sa.getCenterTotalSize(),yo=C.useMemo(()=>f??(S<=0?50:Math.min(Math.max(Sc/S*100,15),75)),[f,Sc,S]),il=j&&B!==void 0&&S>0?Math.min(Math.max(B/S*100,1),99):void 0,ft=S>0&&S<480,Nt=ft?0:il??Ha??fr.tablePanelSize??yo,sn=TNn(Sa),Fn=bI({count:Oa.length,getScrollElement:()=>Et.current,estimateSize:()=>Te,overscan:a}),xn=Fn.getVirtualItems();C.useEffect(()=>{const Xe=new Set;xn.forEach(hr=>{Xe.add(hr.index)});const Rt=ot.current,an=[];Xe.forEach(hr=>{$e.getRowState(hr).status==="unloaded"&&an.push(hr)});const Rn=[];Rt.forEach(hr=>{Xe.has(hr)||Rn.push(hr)}),an.length>0&&($e.markRowsLoading(an),an.forEach(hr=>$e.scheduleLoaded(hr,l))),Rn.length>0&&$e.markRowsUnloaded(Rn),ot.current=Xe},[xn,$e,l]);const Pa=C.useCallback(()=>{Et.current&&Gt.current&&(Gt.current.scrollTop=Et.current.scrollTop),Et.current&&wt.current&&(wt.current.scrollTop=Et.current.scrollTop)},[]),Qr=C.useCallback(()=>{Et.current&&Gt.current&&(Et.current.scrollTop=Gt.current.scrollTop),Gt.current&&wt.current&&(wt.current.scrollTop=Gt.current.scrollTop)},[]),cr=C.useCallback(()=>{wt.current&&Et.current&&(Et.current.scrollTop=wt.current.scrollTop),wt.current&&Gt.current&&(Gt.current.scrollTop=wt.current.scrollTop)},[]),Ar=C.useMemo(()=>ft?[{id:"table",minSize:0},{id:"timeline",minSize:20}]:[{id:"table",minSize:20},{id:"timeline",minSize:20}],[ft]),Cr=ne!==void 0,[Aa,qo]=C.useState(()=>new Map);C.useEffect(()=>{qo(new Map)},[t]);const bo=C.useCallback((Xe,Rt)=>{var an;const Rn=Gt.current,hr=Rn==null?void 0:Rn.getBoundingClientRect(),kr=hr?Math.max(0,Math.min(ln,Xe-hr.left)):0,to=Mn.invert(kr),Na=ca?dx(to,ca):to,Go=hr?Rt-hr.top+((Rn==null?void 0:Rn.scrollTop)??0)-ge:0,Si=xn.find(Nr=>Go>=Nr.start&&Go<Nr.end),ri=Si!==void 0?((an=Oa[Si.index])==null?void 0:an.index)??Si.index:0;return{surface:te,row:String(ri),slot:qh(Na)}},[ln,Mn,ca,xn,Oa,te,ge]),qr=C.useCallback((Xe,Rt,an)=>Y===void 0||Rt===void 0||an===void 0?!0:t7(Y,CXe(Xe,bo(Rt,an))),[Y,bo]),Gs=C.useMemo(()=>Cr?{surface:te,row:"",slot:""}:null,[Cr,te]),yr=lk(Gs,!1,qr,bo),Jr=C.useCallback((Xe,Rt)=>{if(Xe.type==="add"){const an=Number(Xe.value.into.row),Rn=new Date(Xe.value.into.slot);if(Number.isFinite(an)&&!Number.isNaN(Rn.getTime())){const hr=ca?AXe(ca):864e5,kr={start:Rn,end:new Date(Rn.getTime()+hr),label:(Rt==null?void 0:Rt.label)!==void 0?P({value:Rt.label,align:A,verticalAlign:A,color:A,fontWeight:A,fontStyle:A,fontSize:A}):A,progress:A,state:$("proposed",$("added",null)),status:A,popover:A};qo(to=>{const Na=new Map(to);return Na.set(an,[...Na.get(an)??[],kr]),Na})}}ne&&queueMicrotask(()=>ne(Xe))},[ne,ca]),ja=C.useMemo(()=>ne!==void 0?{id:te,sources:[...t.sources],kinds:{add:!0,move:!0,resize:!0},onDrag:Jr}:null,[ne,te,t.sources,Jr]);sk(ja);const ta=Tt(M?_(M.height):void 0)??n,Io=Tt(M?_(M.maxHeight):void 0),xi=Ve!==void 0&&Ve.showFoot,wi=Ve!==void 0&&Qe!==void 0?p.jsxs(V,{width:m6,flexShrink:0,display:"flex",flexDirection:"column",height:"100%",background:"bg.surface",children:[p.jsx(V,{css:_t.decisionHeader,"data-slot":"decisionHeader",height:`${ge}px`,flexShrink:0,children:Qe.columnLabel}),p.jsx(V,{ref:wt,flex:"1",overflowY:"auto",onScroll:cr,css:{scrollbarWidth:"none"},children:p.jsx(V,{position:"relative",height:`${Fn.getTotalSize()}px`,children:xn.map(Xe=>{var Rt;const an=Oa[Xe.index];if(!an)return null;const Rn=(Rt=_(an.original.status))==null?void 0:Rt.type;return p.jsxs(V,{css:_t.decisionCol,"data-slot":"decisionCol","data-status":Rn,position:"absolute",top:0,left:0,right:0,transform:`translateY(${Xe.start}px)`,height:`${Xe.size}px`,children:[Rn!==void 0&&p.jsx(V,{as:"span",css:Ft[Rn],"data-slot":"statusDot",position:"absolute",left:"12px"}),p.jsx(SI,{rowIndex:an.index,controller:Ve})]},an.id)})})})]}):null,pi=p.jsxs(V,{ref:x,width:"100%",...xi?{flex:"1",minHeight:0}:{height:ta},...Io!==void 0?{maxHeight:Io,minHeight:0}:{},overflow:"hidden",display:"flex",children:[p.jsx(V,{flex:"1",minWidth:0,height:"100%",children:p.jsxs(oNe,{size:[Nt,100-Nt],panels:Ar,width:"100%",height:"100%",onResize:Ma,onResizeEnd:Wa,children:[p.jsx(SK,{id:"table",children:p.jsx(V,{ref:Et,height:"100%",overflowY:"auto",position:"relative",onScroll:Pa,css:CNn,children:p.jsxs(CK,{...y,style:{...M1,width:"100%",minWidth:j?0:Sa.getCenterTotalSize(),tableLayout:"fixed"},children:[p.jsx(lNe,{style:{display:"block"},position:"sticky",top:0,zIndex:1,css:Be.header,children:Sa.getHeaderGroups().map(Xe=>p.jsx($f,{style:{display:"flex",width:"100%",height:`${ge}px`},children:Xe.headers.map(Rt=>p.jsx(xf,{css:ht.columnHeader,color:"gray.500",_hover:{bg:"bg.muted","& .col-controls":{opacity:1}},transition:"background 0.2s",style:_ie(Rt,ar,vo,Rt.id===sn),children:p.jsx(zNn,{header:Rt,toggleColumnPin:On,getSortIndex:st,enableMultiSort:i,enableColumnResizing:c})},Rt.id))},Xe.id))}),p.jsx(kK,{style:{display:"block",position:"relative",height:`${Fn.getTotalSize()}px`},children:xn.map(Xe=>{const Rt=Oa[Xe.index];if(!Rt)return null;const an=Xe.index,Rn=lt.get(an)||{status:"unloaded"},hr=!$e.isRowLoaded(an)||Rn.status==="loading",kr=BigInt(Xe.index),to=De(Xe.index);return p.jsx($f,{style:{display:"flex",position:"absolute",top:0,left:0,width:"100%",height:`${Xe.size}px`,transform:`translateY(${Xe.start}px)`,cursor:Z||G?"pointer":void 0,background:to},onClick:Z?()=>Hr(kr):void 0,onDoubleClick:G?()=>lr(kr):void 0,children:Rt.getVisibleCells().map(Na=>{var Go;const Si=Na.getValue(),ri=Na.column.columnDef.meta,Nr=(ri==null?void 0:ri.columnKey)??Na.column.id,no=Lie(Na,ar,vo,Na.column.id===sn),y2=K?T1=>{T1.stopPropagation(),Hn(kr,Nr,Si)}:void 0,P4=U?T1=>{T1.stopPropagation(),pr(kr,Nr,Si)}:void 0;if(hr)return p.jsx(ds,{style:no,children:p.jsx(d4,{height:"20px",width:"80%"})},Na.id);if(Si==null)return p.jsx(ds,{style:no,onClick:y2,onDoubleClick:P4},Na.id);if(ri!=null&&ri.renderFn){const T1=ri.renderFn({rowIndex:kr,columnKey:Nr,cellValue:Si});return p.jsx(ds,{style:no,onClick:y2,onDoubleClick:P4,children:p.jsx(mn,{value:T1,storageKey:`${h}.render.${Na.column.id}`})},Na.id)}return p.jsx(ds,{style:no,onClick:y2,onDoubleClick:P4,children:p.jsx(Ie,{children:((Go=ri==null?void 0:ri.print)==null?void 0:Go.call(ri,Si.value))??null})},Na.id)})},Rt.id)})})]})})}),!j&&p.jsx(iNe,{id:"table:timeline",css:{_after:{top:`calc(50% + ${ge/2}px)`}}}),p.jsx(SK,{id:"timeline",children:p.jsxs(V,{ref:Gt,width:"100%",height:"100%",overflowY:"auto",overflowX:"hidden",position:"relative",onScroll:Qr,css:xI,children:[p.jsxs(V,{position:"sticky",top:0,zIndex:1,css:Be.header,children:[p.jsx(s$n,{startDate:rt.start,endDate:rt.end,width:Ke,height:ge,columnHeaderStyles:ht.columnHeader,tier:fn,format:At}),j&&H>0&&p.jsx(V,{position:"absolute",top:0,right:0,width:`${H}px`,height:`${ge}px`,background:"bg.surface",pointerEvents:"none",zIndex:1}),g&&(()=>{const Xe=v!==void 0?{lo:Math.max(0,Math.min(ln,Mn(v.from))),hi:Math.max(0,Math.min(ln,Mn(v.to)))}:void 0,Rt=Xe!==void 0&&Number.isFinite(Xe.lo)&&Number.isFinite(Xe.hi)&&Xe.hi>Xe.lo,an=Re!==null?Roe(Re):void 0;return p.jsxs(V,{position:"absolute",inset:0,cursor:Re!==null?fUe(Re.mode):"crosshair","data-brush-track":!0,onPointerDown:Rn=>{const hr=Rn.currentTarget;try{hr.setPointerCapture(Rn.pointerId)}catch{}const kr=hr.getBoundingClientRect(),to=Rn.clientX-kr.left,Na=Rt?Xe:void 0;qe({mode:uUe(to,Na),start:to,current:to,width:ln,win:Na})},onPointerMove:Rn=>{if(!Re)return;const hr=Rn.currentTarget.getBoundingClientRect().left;qe({...Re,current:Rn.clientX-hr})},onPointerUp:()=>{if(!Re)return;qe(null);const Rn=dUe(Re);Rn.kind==="clear"?g(null):Rn.kind==="commit"&&g({from:Mn.invert(Rn.lo),to:Mn.invert(Rn.hi)})},children:[Re===null&&Rt&&p.jsxs(p.Fragment,{children:[p.jsx(V,{"data-brush-window":!0,css:Ye.brushWindow,left:`${Xe.lo}px`,width:`${Xe.hi-Xe.lo}px`,opacity:.18}),p.jsx(V,{"data-brush-handle":"lo",css:Ye.brushHandle,left:`${Xe.lo}px`}),p.jsx(V,{"data-brush-handle":"hi",css:Ye.brushHandle,left:`${Xe.hi}px`})]}),an!==void 0&&p.jsx(V,{position:"absolute",top:0,bottom:0,left:`${an.lo}px`,width:`${an.hi-an.lo}px`,bg:"accent.brand",opacity:.18,borderXWidth:"1px",borderColor:"accent.brand",pointerEvents:"none"})]})})()]}),p.jsxs(V,{position:"relative",ref:yr,children:[p.jsx(CK,{...y,style:{width:"100%",tableLayout:"fixed",position:"relative"},children:p.jsx(kK,{style:{display:"block",position:"relative",height:`${Fn.getTotalSize()}px`},children:xn.map(Xe=>{const Rt=Oa[Xe.index];if(!Rt)return null;const an=De(Xe.index);return p.jsxs($f,{style:{display:"flex",position:"absolute",top:0,left:0,width:"100%",height:`${Xe.size}px`,transform:`translateY(${Xe.start}px)`,background:an},children:[j&&H>0&&p.jsx(V,{position:"absolute",top:0,right:0,bottom:"-1px",width:`${H}px`,background:"bg.surface",pointerEvents:"none",zIndex:2,"aria-hidden":"true"}),p.jsx(ds,{style:{width:"100%",padding:0},children:p.jsx("svg",{width:"100%",height:Xe.size,children:p.jsx(fIn,{tasks:[...Rt.original.tasks,...Aa.get(Rt.index)??[]],milestones:Rt.original.milestones,rowIndex:Xe.index,y:0,width:Ke,height:Xe.size,startDate:rt.start,endDate:rt.end,storageKey:`${h}.gantt`,onTaskClick:vn,onTaskDoubleClick:wn,onMilestoneClick:Or,onMilestoneDoubleClick:Zr,onTaskDrag:ne?Nl:void 0,onTaskDurationChange:ne?Il:void 0,onTaskProgressChange:ie?qn:void 0,onMilestoneDrag:ne?$l:void 0,dragStep:ca,durationStep:sa})})})]},Rt.id)})})}),p.jsxs("svg",{width:Ke,height:Fn.getTotalSize(),style:{position:"absolute",top:0,left:0,pointerEvents:"none",zIndex:1},children:[Jn.map((Xe,Rt)=>p.jsx("line",{x1:Xe,y1:0,x2:Xe,y2:Fn.getTotalSize(),stroke:Lt,strokeWidth:1,strokeDasharray:"4 4",opacity:.6},`grid-${Rt}`)),Dt&&(()=>{const Xe=Mn(new Date);return Xe<0||Xe>Ke?null:p.jsx("line",{x1:Xe,y1:0,x2:Xe,y2:Fn.getTotalSize(),stroke:Jt,strokeWidth:1})})()]})]})]})})]})}),wi]}),Dl=xi&&Ve!==void 0?p.jsxs(V,{display:"flex",flexDirection:"column",width:"100%",height:ta,...Io!==void 0?{maxHeight:Io}:{},children:[pi,p.jsx(ik,{controller:Ve,storageKey:h??"gantt"})]}):pi;return pe!==void 0?p.jsx(hu,{value:pe,children:Dl}):Dl},gIn=C.memo(function(t){const n=_(t.value.slice),r=n==null?void 0:n.slice;rl(r==null?void 0:r.key);const a=en({key:"sliceFrame"})();if(n===void 0||r===void 0)return p.jsx(f8e,{...t});const o=r.read(),i=n.affordances.map(v=>v.type),s=Lv(i,o).filter(v=>v!=="brush"),l=Number(r.totalCount()),c=Number(r.resultCount()),u=l>0?Math.round((1-c/l)*100):0,d=i.includes("brush"),f=d?v=>{if(v===null){r.setRange(A);return}r.setRange(P($("datetime",{from:v.from,to:v.to})))}:void 0,h=d?_(o.range):void 0,g=(h==null?void 0:h.type)==="datetime"?h.value:void 0;return p.jsxs(V,{css:a.root,children:[p.jsx(V,{css:a.frameEyebrow,children:p.jsx(zd,{slice:r,affordanceKinds:s})}),p.jsx(V,{css:a.frameBody,children:p.jsx(f8e,{...t,...f!==void 0?{timelineBrush:f}:{},...g!==void 0?{timelineWindow:g}:{}})}),p.jsxs(V,{css:a.frameFooter,children:[p.jsx(V,{as:"span",css:a.frameFooterStat,children:c.toLocaleString()}),p.jsx(V,{as:"span",children:`rows · of ${l.toLocaleString()}`}),u>0&&p.jsx(V,{as:"span",css:a.frameFooterDelta,children:`· −${u}%`})]})]})},(e,t)=>pIn(e.value,t.value)),mIn=it(Uft.Types.Root),vIn={success:A$,warning:Tv,danger:VC,info:Ev,neutral:Lae};function yIn(e){var t;const n=(t=_(e.density))==null?void 0:t.type;return n==="compact"?"sm":n==="comfortable"?"lg":"md"}function bIn(e){const t=[];for(const n of e.rows)for(const r of n.events){t.push(r.slot);const a=_(r.endSlot);a!==void 0&&t.push(a)}return t}const xIn=864e5,p8e=500;function NXe(e){switch(e){case"hour":return lie;case"day":return $v;case"week":return ek;case"month":return g6;case"quarter":return g6.every(3)??g6;case"year":return p4}}function wIn(e){const t=_(e.axis.range);if(t!==void 0)return Sr(t,{time:n=>n,number:()=>{},ordinal:()=>{}},void 0)}function SIn(e){var t;const n=(t=_(e.axis.resolution))==null?void 0:t.type;if(n!==void 0&&n!=="auto")return n;const r=wIn(e);return r!==void 0&&r.max.getTime()-r.min.getTime()<=14*xIn?"day":"month"}function CIn(e,t){switch(e){case"hour":return"HH:mm";case"day":return"ddd DD";case"week":return"MMM DD";case"year":return"YYYY";default:return t?"MMM YYYY":"MMM"}}function kIn(e,t){return`t:${NXe(t).floor(e).toISOString()}`}function zIn(e,t){const n=e.axis.scale.type,r=_(e.axis.range),a=bIn(e);if(n==="number"){let f=1,h=1;const g=r!==void 0?Sr(r,{number:b=>b,time:()=>{},ordinal:()=>{}},void 0):void 0;if(g)f=g.min,h=g.max;else{const b=a.map(y=>Sr(y,{number:x=>x,time:()=>0,ordinal:()=>0},0));f=b.length?Math.floor(Math.min(...b)):1,h=b.length?Math.ceil(Math.max(...b)):1}const v=[];for(let b=f;b<=h;b++)v.push({key:`n:${b}`,label:String(b)});return v}if(n==="ordinal"){let f=[];if(r!==void 0)f=Sr(r,{ordinal:h=>h,number:()=>[],time:()=>[]},[]);else{const h=new Set;for(const g of a){const v=Sr(g,{ordinal:b=>b,number:()=>"",time:()=>""},"");v&&!h.has(v)&&(h.add(v),f.push(v))}}return f.map(h=>({key:`o:${h}`,label:h}))}let o,i;const s=r!==void 0?Sr(r,{time:f=>f,number:()=>{},ordinal:()=>{}},void 0):void 0,l=s!==void 0;if(s)o=s.min,i=s.max;else{const f=a.map(h=>Sr(h,{time:g=>g.getTime(),number:()=>0,ordinal:()=>0},0)).filter(h=>h>0);o=f.length?new Date(Math.min(...f)):new Date(0),i=f.length?new Date(Math.max(...f)):new Date(0)}const c=NXe(t),u=_(e.axis.format)??CIn(t,o.getFullYear()!==i.getFullYear()),d=[];for(let f=c.floor(o);l?f.getTime()<i.getTime():f.getTime()<=i.getTime();f=c.offset(f,1)){if(d.length>=p8e){console.warn(`[Planner] time axis truncated at ${p8e} ${t} columns — narrow the range or use a coarser resolution.`);break}d.push({key:`t:${f.toISOString()}`,label:km(u,f)})}return d.length?d:[{key:"t:0",label:""}]}function s3(e,t,n){const r=Sr(e,{number:a=>`n:${Math.round(a)}`,ordinal:a=>`o:${a}`,time:a=>kIn(a,n)},"");return t.findIndex(a=>a.key===r)}function Gh(e){return e.key.slice(2)}function h8e(e,t){return t!==void 0?`${e}:${t}`:e}function $Xe(e){return Sr(e,{committed:()=>"committed",rejected:()=>"rejected",proposed:t=>Sr(t,{added:()=>"proposedAdded",model:()=>"proposedModel",removed:()=>"proposedRemoved"},"proposedAdded")},"committed")}function MIn(e,t){return Sr(e,{number:n=>String(n),ordinal:n=>n,time:n=>km(t==="hour"?"MMM DD HH:mm":"MMM DD",n)},"")}const OV={start:"flex-start",center:"center",end:"flex-end"},g8e={success:{background:"bg.success.subtle",color:"{colors.status.pos}",borderColor:"{colors.status.pos}"},warning:{background:"bg.warning.subtle",color:"{colors.status.warn}",borderColor:"{colors.status.warn}"},danger:{background:"bg.danger.subtle",color:"{colors.status.neg}",borderColor:"{colors.status.neg}"},info:{background:"bg.info.subtle",color:"{colors.status.info}",borderColor:"{colors.status.info}"},neutral:{background:"transparent",color:"fg.default",borderColor:"border.strong"}};function TIn(e,t,n){var r,a,o;const i=(r=_(e.stretch))==null?void 0:r.type,s=_(e.content),l=s?(a=_(s.horizontal))==null?void 0:a.type:void 0,c=s?(o=_(s.vertical))==null?void 0:o.type:void 0,u={};return(i==="horizontal"||i==="both")&&(u.width="100%"),(i==="vertical"||i==="both")&&(u.height="100%"),l&&(u.justifyContent=OV[l]),c&&(u.alignItems=OV[c]),t==="point"&&(c?u.alignSelf=OV[c]:n||(u.alignSelf="flex-start")),u}function jV({surface:e,row:t,slot:n,vetoFor:r,children:a,...o}){const i=C.useMemo(()=>e!==void 0&&t!==void 0&&n!==void 0?{surface:e,row:t,slot:n}:null,[e,t,n]),s=C.useMemo(()=>i!==null&&r!==void 0?r(i):void 0,[i,r]),l=lk(i,!1,s);return p.jsx(V,{ref:l,...o,children:a})}function FV({event:e,eventStyle:t,gripStyle:n,shape:r,inLane:a=!1,dnd:o}){const i=_(e.popover),s=_(e.hovercard),l=$Xe(e.state),c=l==="proposedAdded"||l==="proposedModel"||l==="proposedRemoved",u=C.useMemo(()=>o&&c?{surface:o.surface,row:o.row,slot:o.slot,event:o.event}:null,[o,c]),d=C.useMemo(()=>p.jsx("span",{children:e.label}),[e.label]),f=CI(u,d,u===null),h=t8e(u,"start",d,u===null||r!=="span"),g=C.useMemo(()=>u&&(o==null?void 0:o.endSlot)!==void 0?{...u,slot:o.endSlot}:u,[u,o]),v=t8e(g,"end",d,g===null||r!=="span"),b={...t,...TIn(e,r,a),...c?{paddingInlineStart:"3px"}:{},...u?{position:"relative"}:{}},y=p.jsxs(V,{css:b,"data-slot":"event","data-state":l,onPointerDown:f,...u&&f?{"data-draggable":""}:{},children:[c&&p.jsx(V,{as:"span",css:n,"data-slot":"grip","data-drag-grip":"",children:p.jsx(Ut,{icon:g5})}),p.jsx(V,{as:"span",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minW:0,children:e.label}),r==="span"&&h&&p.jsx(V,{as:"span",position:"absolute",left:"-3px",top:"0",bottom:"0",width:"6px",cursor:"ew-resize",onPointerDown:z=>{z.stopPropagation(),h(z)},"data-resize-edge":"start"}),r==="span"&&v&&p.jsx(V,{as:"span",position:"absolute",right:"-3px",top:"0",bottom:"0",width:"6px",cursor:"ew-resize",onPointerDown:z=>{z.stopPropagation(),v(z)},"data-resize-edge":"end"})]});if(i===void 0&&s===void 0)return y;const x=s!==void 0?p.jsx(go,{children:p.jsx(Nre,{children:p.jsx($re,{padding:"14px 16px",minW:"240px",maxW:"360px",fontSize:"13px",children:p.jsx(mn,{value:s,storageKey:"planner.hovercard"})})})}):null,S=i!==void 0?p.jsx(go,{children:p.jsx(M4,{children:p.jsx(T4,{padding:"14px 16px",minW:"240px",maxW:"360px",fontSize:"13px",children:p.jsx($C,{padding:0,children:p.jsx(mn,{value:i,storageKey:"planner.popover"})})})})}):null;return i!==void 0&&s!==void 0?p.jsxs(nu,{positioning:{placement:"top"},children:[p.jsxs(kL,{openDelay:150,positioning:{placement:"top"},children:[p.jsx(R6,{asChild:!0,children:p.jsx(zL,{asChild:!0,children:y})}),x]}),S]}):s!==void 0?p.jsxs(kL,{openDelay:150,positioning:{placement:"top"},children:[p.jsx(zL,{asChild:!0,children:y}),x]}):p.jsxs(nu,{positioning:{placement:"top"},children:[p.jsx(R6,{asChild:!0,children:y}),S]})}const EIn=C.memo(function({value:t,storageKey:n}){var r,a;const o=(r=_(t.density))==null?void 0:r.type,i=yIn(t),s=en({key:"planner"}),l=en({key:"table"}),c=_(t.rowHover)===!0,u=Tt(_(t.maxHeight)),d=Tt(_(t.height)),f=C.useMemo(()=>s({size:i,rowHover:c,scroll:!1}),[s,i,c]),h=C.useMemo(()=>l({size:i}).columnHeader??{},[l,i]),{header:g,row:v}=wI(i),b=t.variant.type==="span"?"span":"point",y=C.useMemo(()=>SIn(t),[t]),x=C.useMemo(()=>zIn(t,y),[t,y]),S=t.axis.buckets,z=Math.max(x.length,1),M=C.useMemo(()=>{const tt=["committed","proposedAdded","proposedModel","proposedRemoved","rejected"],gt={};for(const Ot of tt)gt[Ot]=s({size:i,shape:b,state:Ot}).event??{};return gt},[s,i,b]),L=C.useMemo(()=>{const tt={};for(const gt of["success","warning","danger","info","neutral"])tt[gt]=s({size:i,status:gt});return tt},[s,i]),R=C.useMemo(()=>({animation:(s({size:i,shape:b,animation:"pulse"}).event??{}).animation,"@media (prefers-reduced-motion: reduce)":{animation:"none"}}),[s,i,b]),N=C.useMemo(()=>_(t.onSelectRow),[t.onSelectRow]),[O,j]=C.useState(void 0);C.useEffect(()=>{j(void 0)},[t]);const B=C.useCallback(tt=>{j(tt),N&&queueMicrotask(()=>N({rowIndex:BigInt(tt)}))},[N]),H=C.useMemo(()=>_(t.onDrag),[t.onDrag]),K=C.useMemo(()=>_(t.canDrop),[t.canDrop]),U=t.id,Z=t.axis.scale.type,G=H!==void 0,[W,J]=C.useState(()=>new Map);C.useEffect(()=>{J(new Map)},[t]);const ae=C.useCallback(tt=>{let gt=tt,Ot;const yn=tt.lastIndexOf(":");if(yn>0&&!tt.endsWith("Z")){const vn=tt.slice(yn+1);S.some(wn=>wn.key===vn)&&(gt=tt.slice(0,yn),Ot=vn)}if(Z==="number"){const vn=Number(gt);return Number.isFinite(vn)?{slot:$("number",vn),bucket:Ot}:void 0}if(Z==="ordinal")return{slot:$("ordinal",gt),bucket:Ot};const Bt=new Date(gt);return Number.isNaN(Bt.getTime())?void 0:{slot:$("time",Bt),bucket:Ot}},[Z,S]),ne=kI(K),Y=C.useCallback((tt,gt)=>{if(!((tt.type==="add"||tt.type==="move"||tt.type==="resize")&&!t7(K,tt))){if(tt.type==="add"){const Ot=Number(tt.value.into.row),yn=ae(tt.value.into.slot);if(Number.isFinite(Ot)&&yn!==void 0){const Bt={key:P(`local:${tt.value.from.library}:${tt.value.from.key}:${tt.value.into.slot}`),slot:yn.slot,endSlot:A,bucket:yn.bucket!==void 0?P(yn.bucket):A,label:(gt==null?void 0:gt.label)??tt.value.from.key,state:$("proposed",$("added",null)),popover:A,stretch:A,content:A,tone:A,color:A,colorPalette:A,animation:A,hovercard:A};J(vn=>{const wn=new Map(vn);return wn.set(Ot,[...wn.get(Ot)??[],Bt]),wn})}}H&&queueMicrotask(()=>H(tt))}},[H,K,ae]),te=C.useMemo(()=>G?{id:U,sources:[...t.sources],kinds:{add:!0,move:!0,remove:!0,resize:b==="span"},onDrag:Y}:null,[G,U,t.sources,Y,b]);sk(te);const ie=C.useMemo(()=>_(t.review),[t.review]),ue=C.useMemo(()=>t.rows.map(tt=>tt.approval),[t]),oe=ok(ie,ue),ve=oe!==void 0,se=en({key:"reviewChrome"}),pe=C.useMemo(()=>se({size:i}),[se,i]),de=C.useMemo(()=>{const tt={};for(const gt of["success","warning","danger","info","neutral"])tt[gt]=se({size:i,status:gt}).statusDot??{};return tt},[se,i]),ge=C.useMemo(()=>gI(),[]),ye=!1,me=C.useMemo(()=>t.columns.map((tt,gt)=>{var Ot;const yn=_(tt.width),Bt=((Ot=_(tt.align))==null?void 0:Ot.type)==="end",vn=yn?parseInt(yn,10)||150:gt===0?150:110;return ge.accessor(wn=>{var Or;return((Or=wn.cells.get(tt.key))==null?void 0:Or.value)??""},{id:tt.key,header:tt.header,enableSorting:!1,size:vn,minSize:60,meta:{columnKey:tt.key,width:yn??`${vn}px`,alignEnd:Bt}})}),[t.columns,ge]),{state:Me,setState:Te}=Pl(n,{columnSizing:{}}),Be=Me.columnSizing,ht=C.useCallback(tt=>{Te(gt=>({...gt,columnSizing:typeof tt=="function"?tt(gt.columnSizing):tt}))},[Te]),De=yI({data:t.rows,columns:me,state:{columnSizing:Be},onColumnSizingChange:ht,getCoreRowModel:vI(),enableSorting:!1,enableColumnResizing:!0,columnResizeMode:"onChange"}),Qe=Rie(De),bt=De.getVisibleLeafColumns(),Ve=((a=De.getHeaderGroups()[0])==null?void 0:a.headers)??[],ut=`${De.getTotalSize()}px`,_t=_(t.slotMinWidth)??"56px",Ft=parseInt(_t,10)||56,wt=`repeat(${z}, minmax(${_t}, 1fr))`,Lt={position:"sticky",left:0,zIndex:1,background:"bg.surface"},Jt={...Lt,zIndex:2,background:"bg.panel"},Dt=ve?`${ut} 1fr ${m6}`:`${ut} 1fr`,Et=ve?`calc(${ut} + ${z*Ft}px + ${m6})`:`calc(${ut} + ${z*Ft}px)`,Gt={position:"sticky",right:0,zIndex:1,background:"bg.surface"},Ke={...Gt,zIndex:2,background:"bg.panel"},Se=N7(),Re=_(t.plotGutter),qe=(Re?_(Re.left):void 0)??(Se==null?void 0:Se.left),Ye=(Re?_(Re.right):void 0)??(Se==null?void 0:Se.right),$e=qe!==void 0||Ye!==void 0,lt=Ye??"0px",Pe=w9(qe),ot=De.getTotalSize(),kt=$e&&Pe!==void 0&&ot>0?Pe/ot:1,Mt=kt!==1?Object.fromEntries(Object.entries(Qe).map(([tt,gt])=>[tt,typeof gt=="string"&>.endsWith("px")?`${parseFloat(gt)*kt}px`:gt])):Qe,At=qe??ut,fn=$e?ve?`${At} 1fr ${m6} ${lt}`:`${At} 1fr ${lt}`:Dt,rt=$e?`repeat(${z}, minmax(0, 1fr))`:wt,ln=$e?void 0:Et,Mn=_(t.now),Jn=Mn!==void 0?s3(Mn,x,y):-1,Er=tt=>{var gt,Ot,yn;let Bt=M[$Xe(tt.state)];const vn=(gt=_(tt.tone))==null?void 0:gt.type;vn!==void 0&&g8e[vn]!==void 0&&(Bt={...Bt,...g8e[vn]});const wn=_(tt.color),Or=(Ot=_(tt.colorPalette))==null?void 0:Ot.type;return wn!==void 0?Bt={...Bt,background:"transparent",color:wn,borderColor:wn}:Or!==void 0&&(Bt={...Bt,colorPalette:Or,background:"colorPalette.subtle",color:"colorPalette.fg",borderColor:"colorPalette.solid"}),((yn=_(tt.animation))==null?void 0:yn.type)==="pulse"&&(Bt={...Bt,...R}),Bt},_r=(tt,gt,Ot)=>tt.events.filter(yn=>{if(s3(yn.slot,x,y)!==gt)return!1;const Bt=_(yn.bucket);return Ot===void 0?Bt===void 0:Bt===Ot}),fr=(tt,gt)=>tt.events.filter(Ot=>s3(Ot.slot,x,y)===gt),Vr=(tt,gt)=>{for(const Ot of tt.markers)if(s3(Ot.slot,x,y)===gt)return Ot},wr=C.useMemo(()=>{const tt=[];return t.rows.forEach((gt,Ot)=>{const yn=_(gt.group),Bt=tt[tt.length-1];Bt&&Bt.label===yn?Bt.rows.push({row:gt,index:Ot}):tt.push({label:yn,rows:[{row:gt,index:Ot}]})}),tt},[t.rows]),pa=C.useMemo(()=>{const tt=new Set;return S.length>0&&t.rows.forEach((gt,Ot)=>{x.some((Bt,vn)=>gt.events.some(wn=>s3(wn.slot,x,y)===vn&&_(wn.bucket)!==void 0)&>.events.some(wn=>s3(wn.slot,x,y)===vn&&_(wn.bucket)===void 0))&&tt.add(Ot)}),tt},[t.rows,x,S,y]);C.useEffect(()=>{pa.size>0&&console.warn(`[Planner] ${pa.size} row(s) have a bucketless event sharing a bucketed cell — rendered in an "N/A" lane. Give the event a bucket, or move it to its own column.`)},[pa]);const ar=tt=>S.length>0&&tt.events.some(gt=>_(gt.bucket)!==void 0),On=(tt,gt)=>{if(!ar(tt))return!1;const Ot=fr(tt,gt);return Ot.length===0?!0:Ot.some(yn=>_(yn.bucket)!==void 0)},st={key:"__na__",label:"N/A"},dn=(tt,gt,Ot,yn)=>{if(!G)return;const Bt=_(tt.key);if(Bt===void 0)return;const vn=x[Ot];if(vn===void 0)return;const wn=_(tt.endSlot),Or=wn!==void 0?x[s3(wn,x,y)]:void 0;return{surface:U,row:String(gt),slot:h8e(Gh(vn),yn),event:Bt,endSlot:Or!==void 0?Gh(Or):void 0}},Pn=(tt,gt,Ot,yn)=>On(tt,Ot)?(yn?[...S,st]:S).map(vn=>{const wn=vn.key===st.key,Or=wn?_r(tt,Ot,void 0):_r(tt,Ot,vn.key),Zr=!wn&&x[Ot]!==void 0?h8e(Gh(x[Ot]),vn.key):void 0;return p.jsxs(jV,{css:f.bucket,"data-slot":"bucket","data-na":wn?"":void 0,height:`${v}px`,surface:U,row:String(gt),slot:G?Zr:void 0,vetoFor:ne,...G&&Zr!==void 0?{"data-drop-row":String(gt),"data-drop-slot":Zr}:{},children:[p.jsx(V,{css:f.bucketLabel,"data-slot":"bucketLabel",children:vn.label}),Or.map((qn,ca)=>p.jsx(FV,{event:qn,eventStyle:Er(qn),gripStyle:f.grip,shape:"point",inLane:!0,dnd:dn(qn,gt,Ot,wn?void 0:vn.key)},ca))]},vn.key)}):_r(tt,Ot).map((vn,wn)=>p.jsx(FV,{event:vn,eventStyle:Er(vn),gripStyle:f.grip,shape:"point",dnd:dn(vn,gt,Ot)},wn)),Hn=p.jsxs(V,{css:f.header,"data-slot":"header",display:"grid",gridTemplateColumns:fn,minWidth:ln,height:`${g}px`,children:[p.jsx(V,{css:Jt,display:"flex",width:"100%",style:Mt,children:Ve.map(tt=>{var gt;return p.jsxs(V,{css:h,"data-slot":"colHeader",position:"relative",display:"flex",alignItems:"center",justifyContent:(gt=tt.column.columnDef.meta)!=null&>.alignEnd?"flex-end":"flex-start",style:_ie(tt,ye,Be,!1),children:[p.jsx(V,{as:"span",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minW:0,children:tt.column.columnDef.header}),p.jsx(Eie,{header:tt})]},tt.id)})}),p.jsxs(V,{position:"relative",display:"grid",gridTemplateColumns:rt,children:[x.map((tt,gt)=>p.jsxs(V,{css:{...h,position:"relative",display:"flex",alignItems:"center",justifyContent:"center",textAlign:"center"},"data-slot":"headerCell",children:[tt.label,gt<x.length-1&&p.jsx(gXe,{})]},tt.key)),Jn>=0&&p.jsx(V,{css:f.nowLine,left:`calc(${Jn} * (100% / ${z}))`})]}),ve&&ie&&p.jsx(V,{css:{...pe.decisionHeader,...Ke},"data-slot":"decisionHeader",children:ie.columnLabel}),$e&&p.jsx(V,{"data-slot":"headerGutter","aria-hidden":"true",background:"bg.surface"})]}),pr=[];for(const tt of wr){tt.label!==void 0&&pr.push({kind:"groupHead",label:tt.label});for(const gt of tt.rows)pr.push({kind:"row",rowBase:gt.row,index:gt.index})}const Hr=tt=>{var gt;const Ot=pr[tt];if(Ot===void 0)return null;if(Ot.kind==="groupHead")return p.jsx(V,{css:f.groupHead,"data-slot":"groupHead",minWidth:ln,display:"grid",gridTemplateColumns:fn,children:p.jsx(V,{css:{...Lt,...f.groupHeadCell,background:"bg.panel"},"data-slot":"groupHeadCell",children:Ot.label})});const{rowBase:yn,index:Bt}=Ot,vn=W.get(Bt),wn=vn!==void 0&&vn.length>0?{...yn,events:[...yn.events,...vn]}:yn,Or=ve?(gt=_(wn.status))==null?void 0:gt.type:void 0,Zr=pa.has(Bt);return p.jsxs(V,{css:f.row,position:"relative",display:"grid",gridTemplateColumns:fn,minWidth:ln,onClick:N?()=>B(Bt):void 0,cursor:N?"pointer":void 0,children:[O===Bt&&p.jsx(V,{position:"absolute",inset:"0",pointerEvents:"none",zIndex:4,borderWidth:"2px",borderColor:"{colors.brand.600}",borderRadius:"2px"}),$e&&p.jsx(V,{position:"absolute",top:"0",bottom:"-1px",right:"0",width:lt,background:"bg.surface",pointerEvents:"none",zIndex:3,"aria-hidden":"true"}),p.jsx(V,{css:Lt,display:"flex",width:"100%",style:Mt,children:bt.map((qn,ca)=>{var sa,vo;const Ya=((sa=qn.columnDef.meta)==null?void 0:sa.columnKey)??qn.id,Ha=wn.cells.get(Ya),fi=Ha?_(Ha.sublabel):void 0,Ma=((vo=qn.columnDef.meta)==null?void 0:vo.alignEnd)===!0,Wa=ca===0&&Or!==void 0;return p.jsxs(V,{css:f.rowHeader,"data-slot":"rowHeader",style:Lie({column:qn},ye,Be,!1),children:[p.jsxs(V,{css:f.rowHeaderName,"data-slot":"rowHeaderName",display:"flex",justifyContent:Ma?"flex-end":"flex-start",children:[Wa&&Or!==void 0&&p.jsx(V,{as:"span",css:de[Or],"data-slot":"statusDot"}),p.jsx(V,{as:"span",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minW:0,children:(Ha==null?void 0:Ha.value)??""})]}),fi!==void 0&&p.jsx(V,{css:f.rowHeaderSub,"data-slot":"rowHeaderSub",textAlign:Ma?"right":"left",children:fi})]},qn.id)})}),p.jsxs(V,{position:"relative",display:"grid",gridTemplateColumns:rt,children:[b==="point"&&x.map((qn,ca)=>{const sa=Vr(wn,ca),vo=sa?L[sa.status.type]??L.info:void 0,Ya=Jn>0&&ca<Jn;let Ha={...f.cell};On(wn,ca)?Ha={...Ha,...f.bucketedCell}:Ha={...Ha,minHeight:`${v}px`},ca===x.length-1&&(Ha={...Ha,borderRightWidth:"0"}),Ha={...Ha,position:"relative"};const fi=Gh(qn),Ma=G&&!On(wn,ca);return p.jsxs(jV,{"data-slot":"cell","data-past":Ya?"":void 0,css:Ha,surface:U,row:String(Bt),slot:Ma?fi:void 0,vetoFor:ne,...Ma?{"data-drop-row":String(Bt),"data-drop-slot":fi}:{},children:[Pn(wn,Bt,ca,Zr),sa&&vo&&p.jsx(V,{css:vo.markerRing,"data-slot":"markerRing"}),sa&&vo&&p.jsxs(s$,{openDelay:150,children:[p.jsx(l$,{asChild:!0,children:p.jsx(V,{css:vo.markerIcon,"data-slot":"markerIcon",children:p.jsx(Ut,{icon:vIn[sa.status.type]??Ev})})}),p.jsx(go,{children:p.jsx(c$,{children:p.jsx(u$,{children:sa.message})})})]})]},qn.key)}),b==="span"&&p.jsxs(p.Fragment,{children:[x.map(qn=>p.jsx(jV,{css:f.cell,height:`${v}px`,surface:U,row:String(Bt),slot:G?Gh(qn):void 0,vetoFor:ne,...G?{"data-drop-row":String(Bt),"data-drop-slot":Gh(qn)}:{}},qn.key)),wn.events.map((qn,ca)=>{const sa=s3(qn.slot,x,y);if(sa<0)return null;const vo=_(qn.endSlot),Ya=vo!==void 0?s3(vo,x,y):sa,Ha=Math.max(Ya,sa)-sa+1;return p.jsx(V,{position:"absolute",top:"0",bottom:"0",display:"flex",alignItems:"center",left:`calc(${sa} * (100% / ${z}))`,width:`calc(${Ha} * (100% / ${z}))`,pointerEvents:G?void 0:"none",children:p.jsx(FV,{event:qn,eventStyle:Er(qn),gripStyle:f.grip,shape:"span",dnd:dn(qn,Bt,sa)})},ca)})]}),Jn>=0&&p.jsxs(p.Fragment,{children:[p.jsx(V,{css:f.nowLine,"data-slot":"nowLine",left:`calc(${Jn} * (100% / ${z}))`}),p.jsx(V,{css:f.nowHint,left:`calc(${Jn} * (100% / ${z}))`,title:`now · ${Mn?MIn(Mn,y):""}`})]})]}),oe!==void 0&&p.jsx(V,{css:{...pe.decisionCol,...Gt},"data-slot":"decisionCol","data-status":Or,onClick:qn=>qn.stopPropagation(),children:p.jsx(SI,{rowIndex:Bt,controller:oe})})]},Bt)},lr=oe!==void 0&&oe.showFoot,vr=lr&&(d!==void 0||u!==void 0),mo=p.jsx(Dv,{height:vr?void 0:d,maxHeight:vr?void 0:u,fillParent:vr,header:Hn,count:pr.length,estimateSize:tt=>{var gt;return((gt=pr[tt])==null?void 0:gt.kind)==="groupHead"?g:v},renderRow:Hr,minWidth:ln,headerZIndex:5,rootCss:{...f.root,...$e?{width:"100%"}:{}}}),Fe=lr&&oe!==void 0?p.jsx(ik,{controller:oe,storageKey:n}):null,Qt=Fe!==null?p.jsxs(V,{display:"flex",flexDirection:"column",width:"100%",height:d,maxHeight:u,minHeight:"0",children:[mo,Fe]}):mo;return o!==void 0?p.jsx(hu,{value:o,children:Qt}):Qt},(e,t)=>mIn(e.value,t.value)&&e.storageKey===t.storageKey),_In=it(_w.Types.Root),LIn=it(_w.Types.Item),RIn=C.memo(function({value:t}){const n=C.useMemo(()=>_(t.current)??!1,[t]),r=C.useMemo(()=>_(t.onClick),[t]),a=C.useCallback(()=>{r&&queueMicrotask(()=>r())},[r]);return n?p.jsx(I3e,{children:p.jsx(sNt,{children:t.label})}):p.jsx(I3e,{children:p.jsx(iNt,{onClick:r?a:void 0,cursor:r?"pointer":void 0,children:t.label})})},(e,t)=>LIn(e.value,t.value)),PIn=C.memo(function({value:t}){const n=C.useMemo(()=>_(t.style),[t.style]),r=C.useMemo(()=>n?_(n.runAnchor):void 0,[n]),a=n?_(n.leadingSeparator)??!1:!1;return p.jsx(aNt,{children:p.jsxs(oNt,{children:[t.items.map((o,i)=>p.jsxs(C.Fragment,{children:[(i>0||a)&&p.jsx(lNt,{children:"/"}),p.jsx(RIn,{value:o})]},i)),r!==void 0&&p.jsxs(V,{as:"span",fontFamily:"mono",fontSize:"11px",letterSpacing:"0.06em",color:"gray.500",marginInlineStart:"12px",paddingInlineStart:"12px",borderInlineStartWidth:"1px",borderInlineStartStyle:"solid",borderInlineStartColor:"gray.200",children:["run ",p.jsx(V,{as:"span",color:"brand.900",fontWeight:"600",children:r.replace(/^run\s+/i,"")})]})]})})},(e,t)=>_In(e.value,t.value));zv.add(_v,Eoe,Loe);const AIn=it(q_.Types.NavList),IXe=C.memo(function({value:t,collapsed:n=!1}){var r;const a=((r=_(t.surface))==null?void 0:r.type)??"card",o=_(t.background),s=en({key:"navList"})({surface:a,collapsed:n}),l=C.useMemo(()=>_(t.onSelect),[t.onSelect]),c=C.useCallback(d=>{l&&queueMicrotask(()=>l(d))},[l]),u=d=>{const f=_(d.active)??!1,h=_(d.icon),g=_(d.badge);return p.jsxs(Vo,{as:"button",role:"button",onClick:()=>c(d.key),css:s.item,title:d.label,"aria-label":n?d.label:void 0,"aria-current":f?"page":void 0,children:[h&&p.jsx(V,{as:"span",css:s.itemIcon,children:p.jsx(Ut,{icon:[h.prefix,h.name]})}),p.jsx(Ie,{as:"span",css:s.itemText,children:d.label}),g&&p.jsx(V,{as:"span",css:s.badge,children:g})]},d.key)};return p.jsx(V,{css:o?{...s.root,background:o}:s.root,role:"navigation",children:t.sections.map((d,f)=>{const h=_(d.label);return p.jsxs(V,{css:s.group,children:[h&&p.jsx(Ie,{as:"div",css:s.groupLabel,children:h}),d.items.map(u)]},`${h??"_"}-${f}`)})})},(e,t)=>AIn(e.value,t.value)&&e.collapsed===t.collapsed),NIn=it(Sg.Types.Image),$In={png:"image/png",svg:"image/svg+xml",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif"},IIn={contain:"contain",cover:"cover",fill:"fill",none:"none",scaleDown:"scale-down"},DXe=C.memo(function({value:t}){const n=t.source,r=C.useMemo(()=>n.type==="url"||n.type==="dataUri"?n.value:void 0,[n]),[a,o]=C.useState(void 0);C.useEffect(()=>{if(n.type!=="blob"){o(void 0);return}const u=URL.createObjectURL(new Blob([n.value.bytes],{type:$In[n.value.format.type]??"application/octet-stream"}));return o(u),()=>URL.revokeObjectURL(u)},[n]);const i=C.useMemo(()=>_(t.style),[t.style]),s=C.useMemo(()=>{var u;if(i===void 0)return{};const d=_(i.padding),f=_(i.margin),h=(u=_(i.fit))==null?void 0:u.type;return{objectFit:h?IIn[h]:void 0,aspectRatio:_(i.aspectRatio),width:Tt(_(i.width)),height:Tt(_(i.height)),minWidth:Tt(_(i.minWidth)),minHeight:Tt(_(i.minHeight)),maxWidth:Tt(_(i.maxWidth)),maxHeight:Tt(_(i.maxHeight)),opacity:_(i.opacity),borderRadius:_(i.borderRadius),background:_(i.background),pt:d?_(d.top):void 0,pr:d?_(d.right):void 0,pb:d?_(d.bottom):void 0,pl:d?_(d.left):void 0,mt:f?_(f.top):void 0,mr:f?_(f.right):void 0,mb:f?_(f.bottom):void 0,ml:f?_(f.left):void 0}},[i]),l=i?_(i.alt):void 0,c=r??a;return p.jsx(Ht.img,{src:c,alt:l??"",...s})},(e,t)=>NIn(e.value,t.value)),DIn="east-ui.color-mode";function BV(){return typeof document>"u"?"light":document.documentElement.classList.contains("dark")?"dark":"light"}function OIn(e){if(!(typeof document>"u")){document.documentElement.classList.toggle("dark",e==="dark"),document.documentElement.style.colorScheme=e;try{localStorage.setItem(DIn,e)}catch{}}}function jIn(){const[e,t]=C.useState(BV),n=C.useCallback(()=>{const r=BV()==="dark"?"light":"dark";OIn(r),t(r)},[]);return C.useEffect(()=>{if(typeof document>"u")return;const r=document.documentElement,a=new MutationObserver(()=>t(BV()));return a.observe(r,{attributes:!0,attributeFilter:["class"]}),()=>a.disconnect()},[]),[e,n]}const FIn=C.createContext({});function BIn(){return C.useContext(FIn)}const VIn=it(But),HIn=C.memo(function({value:t,storageKey:n}){var r;const a=en({key:"app"}),o=BIn(),{state:i,setState:s}=Pl(`${n}.app.collapsed`,!1),l=t.collapsible&&i,c=C.useCallback(()=>s(z=>!z),[s]),[u,d]=jIn();C.useEffect(()=>{if(!t.collapsible)return;function z(M){if(M.key!=="[")return;const L=M.target;L&&(L.tagName==="INPUT"||L.tagName==="TEXTAREA"||L.isContentEditable)||s(R=>!R)}return window.addEventListener("keydown",z),()=>window.removeEventListener("keydown",z)},[t.collapsible,s]);const f=al(),h=((r=_(t.density))==null?void 0:r.type)??f??"comfortable",g=h==="condensed",v=a({collapsed:l,density:h}),b=_(t.title),y=l?_(t.logoCollapsed)??_(t.logo):_(t.logo),x=o.logo??(y!==void 0?p.jsx(V,{css:v.logo,children:p.jsx(DXe,{value:{source:y,style:A}})}):null),S=t.barStart.length>0||o.barStart!=null;return p.jsxs(V,{css:v.root,children:[p.jsxs(V,{as:"aside",css:v.rail,children:[p.jsx(V,{css:v.railHeader,children:x}),t.collapsible&&p.jsx(V,{css:v.collapseToggleRow,children:p.jsx(Ht.button,{type:"button",css:v.collapseToggle,onClick:c,"aria-label":l?"Expand sidebar":"Collapse sidebar",children:p.jsx(Ut,{icon:l?r2:kd})})}),p.jsx(V,{css:v.railBody,children:p.jsx(IXe,{value:t.rail.value,collapsed:l})}),o.railFooter!=null&&p.jsx(V,{css:v.railFooter,children:o.railFooter})]}),p.jsxs(V,{css:v.content,children:[o.bannerTop!=null&&p.jsx(V,{css:v.bannerTop,children:o.bannerTop}),p.jsxs(V,{as:"header",css:v.header,children:[p.jsxs(Vo,{css:v.headerRow,children:[p.jsx(V,{css:v.breadcrumb,children:p.jsx(mn,{value:t.breadcrumb,storageKey:`${n}.breadcrumb`})}),g&&b!==void 0&&p.jsxs(p.Fragment,{children:[p.jsx(V,{css:v.titleDivider}),p.jsx(V,{css:v.titleInline,children:b})]}),S&&p.jsxs(V,{css:v.barStart,children:[t.barStart.map((z,M)=>p.jsx(mn,{value:z,storageKey:`${n}.barStart.${M}`},M)),o.barStart]}),p.jsx(V,{css:v.barCenter,children:o.barCenter}),p.jsxs(V,{css:v.barEnd,children:[t.barEnd.map((z,M)=>p.jsx(mn,{value:z,storageKey:`${n}.barEnd.${M}`},M)),o.barEnd,t.themeToggle&&p.jsx(Ht.button,{type:"button",css:v.themeToggle,onClick:d,"aria-label":u==="dark"?"Switch to light mode":"Switch to dark mode",children:p.jsx(Ut,{icon:u==="dark"?YDe:Xje})})]})]}),!g&&b!==void 0&&p.jsx(V,{css:v.title,children:b})]}),p.jsx(V,{as:"main",css:v.main,children:p.jsx(mn,{value:t.body,storageKey:`${n}.body`})})]})]})},(e,t)=>e.storageKey===t.storageKey&&VIn(e.value,t.value)),WIn=it(Tq.Types.Badge);function UIn(e){var t,n,r,a,o,i,s,l,c,u;const d=_(e.style);if(d===void 0)return{display:"flex"};const f=_(d.padding),h=_(d.margin);return{display:"flex",variant:(t=_(d.variant))==null?void 0:t.type,colorPalette:(n=_(d.colorPalette))==null?void 0:n.type,size:(r=_(d.size))==null?void 0:r.type,opacity:_(d.opacity),color:_(d.color),background:_(d.background),borderRadius:_(d.borderRadius),borderWidth:(a=_(d.borderWidth))==null?void 0:a.type,borderStyle:(o=_(d.borderStyle))==null?void 0:o.type,borderColor:_(d.borderColor),overflow:(i=_(d.overflow))==null?void 0:i.type,overflowX:(s=_(d.overflowX))==null?void 0:s.type,overflowY:(l=_(d.overflowY))==null?void 0:l.type,justifyContent:(c=_(d.justifyContent))==null?void 0:c.type,alignItems:(u=_(d.alignItems))==null?void 0:u.type,width:Tt(_(d.width)),height:Tt(_(d.height)),minWidth:Tt(_(d.minWidth)),minHeight:Tt(_(d.minHeight)),maxWidth:Tt(_(d.maxWidth)),maxHeight:Tt(_(d.maxHeight)),pt:f?_(f.top):void 0,pr:f?_(f.right):void 0,pb:f?_(f.bottom):void 0,pl:f?_(f.left):void 0,mt:h?_(h.top):void 0,mr:h?_(h.right):void 0,mb:h?_(h.bottom):void 0,ml:h?_(h.left):void 0}}const qIn=C.memo(function({value:t}){const n=C.useMemo(()=>UIn(t),[t]),r=al(),o=C.useMemo(()=>{var i;return(i=_(t.density))==null?void 0:i.type},[t.density])??r;return p.jsx(_re,{...n,...o!==void 0?{density:o}:{},children:t.value})},(e,t)=>WIn(e.value,t.value)),GIn=it(Eq.Types.Tag);function KIn(e){var t,n,r,a,o,i,s,l;const c=_(e.style);if(c===void 0)return{};const u=_(c.padding),d=_(c.margin);return{variant:(t=_(c.variant))==null?void 0:t.type,colorPalette:(n=_(c.colorPalette))==null?void 0:n.type,size:(r=_(c.size))==null?void 0:r.type,opacity:_(c.opacity),color:_(c.color),background:_(c.background),borderRadius:_(c.borderRadius),borderWidth:(a=_(c.borderWidth))==null?void 0:a.type,borderStyle:(o=_(c.borderStyle))==null?void 0:o.type,borderColor:_(c.borderColor),overflow:(i=_(c.overflow))==null?void 0:i.type,overflowX:(s=_(c.overflowX))==null?void 0:s.type,overflowY:(l=_(c.overflowY))==null?void 0:l.type,width:Tt(_(c.width)),height:Tt(_(c.height)),minWidth:Tt(_(c.minWidth)),minHeight:Tt(_(c.minHeight)),maxWidth:Tt(_(c.maxWidth)),maxHeight:Tt(_(c.maxHeight)),pt:u?_(u.top):void 0,pr:u?_(u.right):void 0,pb:u?_(u.bottom):void 0,pl:u?_(u.left):void 0,mt:d?_(d.top):void 0,mr:d?_(d.right):void 0,mb:d?_(d.bottom):void 0,ml:d?_(d.left):void 0}}const YIn=C.memo(function({value:t}){const n=C.useMemo(()=>KIn(t),[t]),r=C.useMemo(()=>_(t.closable),[t.closable]),a=C.useMemo(()=>_(t.onClose),[t.onClose]),o=al(),s=C.useMemo(()=>{var c;return(c=_(t.density))==null?void 0:c.type},[t.density])??o,l=C.useCallback(()=>{a&&queueMicrotask(()=>a())},[a]);return p.jsxs(KIt,{...n,...s!==void 0?{density:s}:{},children:[p.jsx(YIt,{children:t.label}),r&&p.jsx(XIt,{onClick:a?l:void 0})]})},(e,t)=>GIn(e.value,t.value)),XIn=it(Aq.Types.Avatar);function OXe(e){var t,n,r,a,o,i;const s=_(e.style);if(s===void 0)return{};const l=_(s.padding),c=_(s.margin);return{size:(t=_(s.size))==null?void 0:t.type,variant:(n=_(s.variant))==null?void 0:n.type,colorPalette:(r=_(s.colorPalette))==null?void 0:r.type,opacity:_(s.opacity),borderRadius:_(s.borderRadius),overflow:(a=_(s.overflow))==null?void 0:a.type,overflowX:(o=_(s.overflowX))==null?void 0:o.type,overflowY:(i=_(s.overflowY))==null?void 0:i.type,width:Tt(_(s.width)),height:Tt(_(s.height)),minWidth:Tt(_(s.minWidth)),minHeight:Tt(_(s.minHeight)),maxWidth:Tt(_(s.maxWidth)),maxHeight:Tt(_(s.maxHeight)),color:_(s.color),background:_(s.background),borderColor:_(s.borderColor),pt:l?_(l.top):void 0,pr:l?_(l.right):void 0,pb:l?_(l.bottom):void 0,pl:l?_(l.left):void 0,mt:c?_(c.top):void 0,mr:c?_(c.right):void 0,mb:c?_(c.bottom):void 0,ml:c?_(c.left):void 0}}const ZIn=C.memo(function({value:t}){const n=C.useMemo(()=>OXe(t),[t]),r=C.useMemo(()=>_(t.src),[t.src]),a=C.useMemo(()=>_(t.name),[t.name]),o=al(),s=C.useMemo(()=>{var l;return(l=_(t.density))==null?void 0:l.type},[t.density])??o;return p.jsxs(cK,{...n,...s!==void 0?{density:s}:{},children:[p.jsx(uK,{name:a}),r&&p.jsx(YPe,{src:r})]})},(e,t)=>XIn(e.value,t.value)),QIn=it(Oq.Types.Stat),JIn={sm:"sm",md:"md",lg:"lg"},m8e={positive:"fg.success",negative:"fg.danger",neutral:"fg.muted"},eDn=C.memo(function({value:t,storageKey:n}){var r,a;const o=C.useMemo(()=>_(t.helpText),[t.helpText]),i=C.useMemo(()=>_(t.baseline),[t.baseline]),s=C.useMemo(()=>_(t.delta),[t.delta]),l=C.useMemo(()=>_(t.info),[t.info]),c=C.useMemo(()=>_(t.indicator),[t.indicator]),u=C.useMemo(()=>_(t.style),[t.style]),d=al(),h=C.useMemo(()=>{var N;return(N=_(t.density))==null?void 0:N.type},[t.density])??d,g=C.useMemo(()=>{const N=t.value,O=_(t.format);switch(N.type){case"Float":case"Integer":return Yp(Number(N.value),O);case"DateTime":return Yp(new Date(N.value).getTime(),O);case"String":return N.value;default:return String(N.value)}},[t.value,t.format]),v=c?c.direction.type:void 0,b=c?(r=_(c.sentiment))==null?void 0:r.type:void 0,y=c?_(c.icon):void 0,x=u?(a=_(u.size))==null?void 0:a.type:void 0,S=x?JIn[x]:void 0,z=u?_(u.valueColor):void 0,M=u?_(u.labelColor):void 0,L=u?_(u.helpTextColor):void 0,R=u?_(u.indicatorColor)??(b?m8e[b]:void 0):b?m8e[b]:void 0;return p.jsxs(TIt,{size:S,...h!==void 0?{density:h}:{},children:[p.jsxs(Xr,{gap:"1",align:"baseline",children:[p.jsx(EIt,{color:M,children:t.label}),l&&p.jsx(V,{children:p.jsx(mn,{value:l,storageKey:`${n}.info`})})]}),p.jsx(_It,{color:z,children:g}),i&&p.jsx(V,{mt:"0.5",children:p.jsx(mn,{value:i,storageKey:`${n}.baseline`})}),(o||v||s)&&p.jsx(LIt,{color:L,children:p.jsxs(Xr,{gap:"1",align:"center",children:[v!==void 0&&y===void 0&&p.jsxs(V,{color:R,children:[v==="up"&&p.jsx(RIt,{}),v==="down"&&p.jsx(PIt,{})]}),y!==void 0&&p.jsx(V,{color:R,children:p.jsx(Ut,{icon:[y.prefix,y.name],"aria-hidden":!0})}),o&&p.jsx("span",{children:o}),s&&p.jsx(V,{ml:"auto",children:p.jsx(mn,{value:s,storageKey:`${n}.delta`})})]})})]})},(e,t)=>QIn(e.value,t.value)&&e.storageKey===t.storageKey),tDn=it(Pq.Types.MetricChip),v8e={positive:{bg:"success.subtle",fg:"fg.success",border:"fg.success",solidBg:"fg.success",solidFg:"white"},negative:{bg:"danger.subtle",fg:"fg.danger",border:"fg.danger",solidBg:"fg.danger",solidFg:"white"},neutral:{bg:"bg.subtle",fg:"fg.muted",border:"border.strong",solidBg:"fg.muted",solidFg:"white"},info:{bg:"info.subtle",fg:"fg.info",border:"fg.info",solidBg:"fg.info",solidFg:"white"}},y8e={xs:{px:"1.5",py:"0",fontSize:"xs"},sm:{px:"2",py:"0.5",fontSize:"sm"},md:{px:"2.5",py:"1",fontSize:"sm"},lg:{px:"3",py:"1.5",fontSize:"md"},xl:{px:"3.5",py:"2",fontSize:"md"}},nDn={positive:"up",negative:"down",neutral:"flat",info:"brand"},rDn=C.memo(function({value:t,storageKey:n}){var r,a;const o=en({key:"metricChip"}),i=t.tone.type,s=nDn[i]??"flat",l=al(),u=C.useMemo(()=>{var R;return(R=_(t.density))==null?void 0:R.type},[t.density])??l,d=o({sentiment:s,density:u}),f=C.useMemo(()=>_(t.unit),[t.unit]),h=C.useMemo(()=>_(t.icon),[t.icon]),g=C.useMemo(()=>_(t.style),[t.style]),v=g?((r=_(g.emphasis))==null?void 0:r.type)??"subtle":"subtle",b=g?((a=_(g.size))==null?void 0:a.type)??"sm":"sm",y=y8e[b]??y8e.sm,x=v8e[i]??v8e.neutral,S=(g&&_(g.color))??(v==="solid"?x.solidFg:void 0),z=(g&&_(g.background))??(v==="solid"?x.solidBg:v==="outline"?"transparent":void 0),M=(g&&_(g.borderColor))??(v==="outline"?x.border:void 0),L=(g&&_(g.iconColor))??S??x.fg;return p.jsx(V,{css:d.root,px:y.px,py:y.py,fontSize:y.fontSize,...S!==void 0?{color:S}:{},...z!==void 0?{bg:z}:{},...M!==void 0?{borderColor:M}:{},...v==="solid"?{borderColor:"transparent"}:{},children:p.jsxs(Xr,{gap:"1",align:"center",children:[h&&p.jsx(V,{color:L,children:p.jsx(Ut,{icon:[h.prefix,h.name],"aria-hidden":!0})}),p.jsx(V,{css:d.value,children:p.jsx(mn,{value:t.value,storageKey:`${n}.value`})}),f&&p.jsx(Ie,{as:"span",opacity:.75,children:f})]})})},(e,t)=>tDn(e.value,t.value)&&e.storageKey===t.storageKey),aDn=C.memo(function({value:t}){const{slice:n}=t;rl(n.key);const r=Number(n.activeCount()),a=n.resultCount(),o=Number(n.totalCount()),i=en({key:"sliceFrame"})();return p.jsxs(V,{css:i.frameFooter,children:[a!==void 0&&p.jsxs(p.Fragment,{children:[p.jsx(V,{as:"span",css:i.frameFooterStat,children:Number(a).toLocaleString()}),o>0&&p.jsx(V,{as:"span",children:`of ${o.toLocaleString()}`}),p.jsx(V,{as:"span",children:Number(a)===1?"result":"results"}),p.jsx(V,{as:"span",children:"·"})]}),p.jsx(V,{as:"span",css:i.frameFooterStat,children:r}),p.jsx(V,{as:"span",children:r===1?"narrowing":"narrowings"}),r>0&&p.jsxs(p.Fragment,{children:[p.jsx(V,{as:"span",children:"·"}),p.jsx(Ht.button,{type:"button",color:"link",fontWeight:"medium",cursor:"pointer",_hover:{textDecoration:"underline",textUnderlineOffset:"2px"},onClick:()=>{n.clearFilters()},children:"clear all"})]})]})},()=>!1),oDn=it(Rq.Types.EditableChip),iDn=C.memo(function({value:t,storageKey:n}){var r;const a=C.useMemo(()=>_(t.trigger),[t.trigger]),o=C.useMemo(()=>_(t.disabled),[t.disabled]),i=C.useMemo(()=>_(t.onClick),[t.onClick]),s=C.useMemo(()=>_(t.style),[t.style]),l=C.useCallback(()=>{i&&!o&&queueMicrotask(()=>i())},[i,o]),c=s?((r=_(s.size))==null?void 0:r.type)??"sm":"sm",u=al(),f=C.useMemo(()=>{var z;return(z=_(t.density))==null?void 0:z.type},[t.density])??u,g=en({key:"editableChip"})({size:c,density:f}),v=C.useMemo(()=>{const z=s?_(s.borderRadius):void 0,M=s?_(s.color):void 0,L=s?_(s.background):void 0,R=s?_(s.borderColor):void 0;return{...g.root,...z!==void 0?{borderRadius:z}:{},...M!==void 0?{color:M}:{},...L!==void 0?{background:L}:{},...R!==void 0?{borderColor:R}:{}}},[g,s]),b=C.useMemo(()=>{const z=s?_(s.triggerIconColor):void 0;return{...g.trigger,...z!==void 0?{color:z}:{}}},[g,s]),y=a?[a.prefix,a.name]:Wae,x=!!i&&!o,S=p.jsxs(p.Fragment,{children:[p.jsx(mn,{value:t.label,storageKey:`${n}.label`}),p.jsx(V,{as:"span",css:b,children:p.jsx(Ut,{icon:y,"aria-hidden":!0})})]});return x?p.jsx(fu,{unstyled:!0,css:v,onClick:l,children:S}):p.jsx(V,{css:v,cursor:o?"not-allowed":"default",opacity:o?.5:void 0,children:S})},(e,t)=>oDn(e.value,t.value)&&e.storageKey===t.storageKey),sDn=it(Lq.Types.Kbd),lDn=C.memo(function({value:t}){var n,r,a;const o=C.useMemo(()=>_(t.style),[t.style]),i=al(),l=C.useMemo(()=>{var b;return(b=_(t.density))==null?void 0:b.type},[t.density])??i,c=o?(n=_(o.variant))==null?void 0:n.type:void 0,u=o?(r=_(o.size))==null?void 0:r.type:void 0,d=o?(a=_(o.colorPalette))==null?void 0:a.type:void 0,f=o?_(o.color):void 0,h=o?_(o.background):void 0,g=o?_(o.borderColor):void 0,v=t.keys;return p.jsx(Xr,{gap:"1",align:"center",display:"inline-flex",children:v.map((b,y)=>p.jsxs(C.Fragment,{children:[y>0&&p.jsx(Ie,{as:"span",color:"fg.muted",children:"+"}),p.jsx(Dre,{variant:c??"flat",size:u==="xs"||u==="xl"||u==="2xl"?"sm":u,colorPalette:d,color:f,background:h,borderColor:g,...l!==void 0?{density:l}:{},children:b})]},y))})},(e,t)=>sDn(e.value,t.value)),cDn=it(_q.Types.Meter),uDn=C.memo(function({value:t,storageKey:n}){var r;const a=C.useMemo(()=>_(t.label),[t.label]),o=C.useMemo(()=>_(t.max)??100,[t.max]),i=C.useMemo(()=>{var M;return(M=_(t.tone))==null?void 0:M.type},[t.tone]),s=C.useMemo(()=>_(t.style),[t.style]),l=al(),u=C.useMemo(()=>{var M;return(M=_(t.density))==null?void 0:M.type},[t.density])??l,d=s?(r=_(s.thickness))==null?void 0:r.type:void 0,f=s?_(s.fillColor):void 0,h=s?_(s.trackColor):void 0,g=s?_(s.labelColor):void 0,v=s?_(s.borderRadius):void 0,b=(s?_(s.showValue):void 0)??!0,y=en({key:"meter"})({thickness:d,tone:i,density:u}),x=Math.max(0,Math.min(Number(t.value)/Number(o),1)),S=`${(x*100).toFixed(2)}%`,z=`${Math.round(x*100)}%`;return p.jsxs(V,{css:y.root,children:[a&&p.jsx(V,{css:y.label,color:g,children:p.jsx(mn,{value:a,storageKey:`${n}.label`})}),p.jsx(V,{css:y.track,bg:h,borderRadius:v,children:p.jsx(V,{css:y.fill,width:S,bg:f,borderRadius:v})}),b&&p.jsx(V,{as:"span",css:y.value,children:z})]})},(e,t)=>cDn(e.value,t.value)&&e.storageKey===t.storageKey),dDn=it(Iq.Types.SegmentedMeter),fDn={xs:"4px",sm:"6px",md:"10px",lg:"14px"},pDn={success:"fg.success",warning:"fg.warning",danger:"fg.danger",info:"fg.info",neutral:"fg.muted"},hDn=C.memo(function({value:t,storageKey:n}){var r,a,o;const i=C.useMemo(()=>_(t.caption),[t.caption]),s=C.useMemo(()=>_(t.style),[t.style]),l=al(),u=C.useMemo(()=>{var B;return(B=_(t.density))==null?void 0:B.type},[t.density])??l,d=en({key:"segmentedMeter"})({density:u}),f=s?((r=_(s.thickness))==null?void 0:r.type)??"sm":"sm",g=(u!==void 0?(a=d.track)==null?void 0:a.height:void 0)??fDn[f]??"6px",v=s?((o=_(s.labels))==null?void 0:o.type)??"none":"none",b=(s&&_(s.borderRadius))??"sm",y=(s&&_(s.trackColor))??"gray.100",x=s?_(s.captionColor):void 0,S=(s&&_(s.labelColor))??"white",z=t.segments,M=z.reduce((B,H)=>B+Number(H.value),0),L=_(t.max),N=(L!==void 0?Math.max(Number(L),M):M)-M,O=p.jsxs(Vo,{width:"full",height:g,borderRadius:b,overflow:"hidden",children:[z.map((B,H)=>{var K;const U=(K=_(B.tone))==null?void 0:K.type,Z=_(B.color)??(U?pDn[U]:"fg.info"),G=_(B.label);return p.jsx(V,{flex:Number(B.value),bg:Z,display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",children:v==="inside"&&G&&p.jsx(Ie,{fontSize:"xs",color:S,truncate:!0,children:G})},H)}),N>0&&p.jsx(V,{flex:N,bg:y})]}),j=v==="outside"?p.jsxs(Vo,{width:"full",mt:"1",children:[z.map((B,H)=>{const K=_(B.label);return p.jsx(V,{flex:Number(B.value),textAlign:"center",children:K&&p.jsx(Ie,{fontSize:"xs",color:"fg.muted",truncate:!0,children:K})},H)}),N>0&&p.jsx(V,{flex:N})]}):null;return i?p.jsxs(V,{width:"full",children:[p.jsxs(Xr,{gap:"3",align:"center",mb:"1",children:[p.jsx(V,{color:x,flexShrink:0,children:p.jsx(mn,{value:i,storageKey:`${n}.caption`})}),p.jsx(V,{flex:"1",children:O})]}),j]}):p.jsxs(V,{width:"full",children:[O,j]})},(e,t)=>dDn(e.value,t.value)&&e.storageKey===t.storageKey),gDn=it($q.Types.BarStrip),mDn={success:"fg.success",warning:"fg.warning",danger:"fg.danger",info:"fg.info",neutral:"fg.muted"},vDn=C.memo(function({value:t,storageKey:n}){var r;const a=C.useMemo(()=>_(t.style),[t.style]),o=C.useMemo(()=>_(t.showValues)??!0,[t.showValues]),i=C.useMemo(()=>{var S;return((S=_(t.sort))==null?void 0:S.type)??"none"},[t.sort]),s=C.useMemo(()=>_(t.maxItems),[t.maxItems]),l=al(),u=C.useMemo(()=>{var S;return(S=_(t.density))==null?void 0:S.type},[t.density])??l,d=a?(r=_(a.thickness))==null?void 0:r.type:void 0,f=a?_(a.trackColor):void 0,h=a?_(a.labelColor):void 0,g=a?_(a.valueColor):void 0,v=a?_(a.borderRadius):void 0,b=en({key:"barStrip"})({thickness:d,density:u}),y=C.useMemo(()=>{let S=[...t.items];return i==="asc"?S.sort((z,M)=>Number(z.value)-Number(M.value)):i==="desc"&&S.sort((z,M)=>Number(M.value)-Number(z.value)),s!==void 0&&(S=S.slice(0,Number(s))),S},[t,i,s]),x=C.useMemo(()=>{let S=0;for(const z of y){const M=Number(z.value);M>S&&(S=M)}return S===0?1:S},[y]);return p.jsx(V,{css:b.root,children:y.map((S,z)=>{var M;const L=(M=_(S.tone))==null?void 0:M.type,R=_(S.color)??(L?mDn[L]:void 0),N=_(S.trailing),O=`${(Number(S.value)/x*100).toFixed(2)}%`;return p.jsxs(V,{css:b.row,children:[p.jsx(V,{css:b.label,color:h,children:p.jsx(mn,{value:S.label,storageKey:`${n}.${z}.label`})}),p.jsx(V,{css:b.track,bg:f,borderRadius:v,children:p.jsx(V,{css:b.fill,width:O,bg:R,borderRadius:v})}),o&&p.jsx(V,{as:"span",css:b.value,color:g,children:Number(S.value).toLocaleString()}),N&&p.jsx(V,{css:b.trailing,children:p.jsx(mn,{value:N,storageKey:`${n}.${z}.trailing`})})]},z)})})},(e,t)=>gDn(e.value,t.value)&&e.storageKey===t.storageKey),yDn=it(jq.Types.Trace),b8e=["var(--chakra-colors-brand-600)","var(--chakra-colors-orange-500)","var(--chakra-colors-purple-500)","var(--chakra-colors-cyan-600)","var(--chakra-colors-pink-500)"],bDn="var(--chakra-colors-orange-500)",x8e="var(--chakra-colors-bg-muted)",w8e="var(--chakra-colors-bg-surface)";function S8e(e){return Number.isInteger(e)?String(e):e.toFixed(1)}function xDn(e,t,n,r,a,o,i){if(a==="diverge"){const u=Math.max(n-r,r-t)||1,d=(e-r)/u,f=d>=0?bDn:o,h=Math.min(Math.abs(d),1),g=i?w8e:x8e,v=i?h*34:h*80;return{fill:`color-mix(in srgb, ${f} ${v.toFixed(0)}%, ${g})`,edge:f,hot:!i&&h>.62}}const s=n>t?(e-t)/(n-t):.5,l=i?w8e:x8e,c=i?s*42:s*100;return{fill:`color-mix(in srgb, ${o} ${c.toFixed(0)}%, ${l})`,edge:o,hot:!i&&s>.6}}const wDn=C.memo(function({value:t,storageKey:n}){const r=en({key:"trace"}),a=al(),i=C.useMemo(()=>{var Z;return(Z=_(t.density))==null?void 0:Z.type},[t.density])??a??"comfortable",s=r({density:i}),l=C.useMemo(()=>{var Z;return((Z=_(t.scale))==null?void 0:Z.type)??"brand"},[t.scale]),c=C.useMemo(()=>{var Z;return((Z=_(t.future))==null?void 0:Z.type)??"ghost"},[t.future]),u=C.useMemo(()=>_(t.axis),[t.axis]),d=C.useMemo(()=>_(t.style),[t.style]),f=(d?_(d.brandColor):void 0)??"var(--chakra-colors-brand-600)",h=d?_(d.nowLineColor):void 0,g=d?_(d.labelWidth):void 0,v=N7(),b=C.useMemo(()=>d?_(d.plotGutter):void 0,[d]),y=(b?_(b.left):void 0)??(v==null?void 0:v.left),x=(b?_(b.right):void 0)??(v==null?void 0:v.right),S=y!==void 0||x!==void 0,z=y??g??"var(--t-stub-w)",M=x??"0px",L=C.useMemo(()=>_(t.now),[t.now]),R=L!==void 0?Number(L):void 0,N=t.tracks,O=N.reduce((Z,G)=>Math.max(Z,G.values.length),0),j=S?`${z} repeat(${O}, minmax(0, 1fr)) ${M}`:`var(--t-stub-w) repeat(${O}, var(--t-step-w))`,B=S?{columnGap:"0px"}:void 0;C.useEffect(()=>{if(N.length<2)return;const Z=N.map(G=>G.values.length);Z.some(G=>G!==Z[0])&&console.warn(`<Trace>: tracks have unequal value lengths [${Z.join(", ")}]; short tracks padded to ${O} steps — tracks are expected to share one step grid.`)},[N,O]);const H=R!==void 0&&R>0&&R<O,K=S?`calc(${z} + (100% - ${z} - ${M}) * ${R} / ${O})`:`calc(var(--t-stub-w) + var(--t-gap) + ${R} * (var(--t-step-w) + var(--t-gap)) - var(--t-gap) / 2)`,U=i==="comfortable"&&u!==void 0&&u.length>0;return p.jsxs(V,{css:s.root,"data-future":c,...S?{display:"block",width:"100%"}:{},...g!==void 0?{style:{"--t-stub-w":g}}:{},children:[U&&p.jsxs(V,{css:s.axis,style:{gridTemplateColumns:j,...B},children:[p.jsx("span",{}),Array.from({length:O},(Z,G)=>p.jsx(V,{css:s.axisCell,children:u[G]??""},`ax.${G}`)),S&&p.jsx("span",{})]}),p.jsxs(V,{css:s.grid,style:{gridTemplateColumns:j,...B},position:"relative",children:[N.map((Z,G)=>{const W=Z.values,J=Math.min(...W),ae=Math.max(...W),ne=(J+ae)/2,Y=l==="categorical"?b8e[G%b8e.length]:f;return p.jsxs(C.Fragment,{children:[p.jsx(V,{css:s.stub,title:Z.name,children:Z.name}),W.map((te,ie)=>{const ue=R!==void 0&&ie>=R,{fill:oe,edge:ve,hot:se}=xDn(te,J,ae,ne,l,Y,ue),pe={background:oe};S&&(pe.marginInline="calc(var(--t-gap) / 2)"),ue?(pe.color=ve,pe.fontStyle="italic",c==="fade"?pe.opacity="0.7":(pe.borderColor=ve,pe.borderStyle="dashed"),c==="hatch"&&(pe.backgroundImage=`repeating-linear-gradient(-45deg, transparent 0 5px, color-mix(in srgb, ${ve} 12%, transparent) 5px 6px)`)):se&&(pe.color="var(--chakra-colors-bg-surface)");const de=`${u!=null&&u[ie]?`${u[ie]} · `:""}${Z.name} ${S8e(te)} · ${ue?"predicted":"measured"}`;return p.jsx(V,{css:s.step,style:pe,title:de,children:p.jsx(V,{as:"span",css:s.value,children:S8e(te)})},`step.${G}.${ie}`)}),Array.from({length:O-W.length},(te,ie)=>p.jsx("span",{"aria-hidden":"true"},`pad.${G}.${ie}`)),S&&p.jsx("span",{"aria-hidden":"true"},`rpad.${G}`)]},`${n}.track.${G}`)}),H&&p.jsx(V,{css:s.now,style:{left:K,...h?{background:h}:{}}})]})]})},(e,t)=>yDn(e.value,t.value)&&e.storageKey===t.storageKey),SDn=it(X_.Types.Library);function CDn(e){return(_(e.search)??e.label).toLowerCase()}const kDn=220,C8e=12,zDn=16;function MDn(e){const t=e-2*zDn;return Math.max(1,Math.floor((t+C8e)/(kDn+C8e)))}function TDn(e,t){const n=Math.max(1,t),r=[];for(const a of e){a.label!==""&&r.push({kind:"groupHead",label:a.label,summary:a.summary,count:a.items.length});for(let o=0;o<a.items.length;o+=n)r.push({kind:"cardRow",items:a.items.slice(o,o+n)})}return r}function k8e({libraryId:e,item:t,dimOrder:n,activeDims:r,filtered:a,styles:o}){const i=_(t.status),s=_(t.sublabel),l=_(t.icon),c=t.draggable&&!a,u=n.filter(v=>r.includes(v)&&t.dims.get(v)!==void 0),d=s===void 0&&u.length===0,f=C.useMemo(()=>({library:e,key:t.key,label:t.label}),[e,t.key,t.label]),h=C.useMemo(()=>p.jsx(V,{css:o.ghost,children:t.label}),[o.ghost,t.label]),g=e$n(f,h,!c);return p.jsxs(V,{css:o.card,onPointerDown:g,...a?{"data-filtered":""}:{},...c&&g?{"data-draggable":""}:{},...d?{"data-compact":""}:{},children:[c&&g&&p.jsx(V,{as:"span",css:o.grip,"data-drag-grip":"",children:p.jsx(Ut,{icon:g5})}),l&&p.jsx(V,{css:o.iconTile,children:p.jsx(Ut,{icon:["fas",l]})}),p.jsxs(V,{css:o.cardBody,children:[p.jsxs(V,{css:o.cardHead,children:[p.jsx(V,{as:"span",css:o.cardLabel,children:t.label}),i&&p.jsx(V,{as:"span",css:o.statusPill,"data-tone":i.tone.type,children:i.label})]}),s&&p.jsx(V,{css:o.cardSublabel,children:s}),u.map(v=>{const b=t.dims.get(v);return Sr(b,{meter:y=>p.jsxs(V,{css:o.meter,children:[p.jsx(V,{css:o.meterTrack,children:p.jsx(V,{css:o.meterFill,width:`${Math.max(0,Math.min(100,y.max>0?y.value/y.max*100:0))}%`})}),_(y.text)!==void 0&&p.jsx(V,{as:"span",css:o.meterText,children:_(y.text)})]},v),chips:y=>p.jsx(V,{css:o.chips,children:y.map((x,S)=>p.jsx(V,{as:"span",css:o.chip,children:x},S))},v),text:y=>p.jsx(V,{css:o.dimText,children:y},v)})})]})]})}function z8e({label:e,count:t,summary:n,styles:r}){return p.jsxs(V,{css:r.groupHead,children:[p.jsxs(V,{as:"span",css:r.groupLabel,children:[e," · ",t]}),n!==void 0&&p.jsx(V,{as:"span",css:r.groupSummary,children:n})]})}function M8e({value:e,storageKey:t,suppressSearch:n}){var r;const a=en({key:"library"})(),o=ga({key:"chip"}),i=en({key:"sliceFrame"})(),s=e.groupOptions,l=e.dimOptions,c=C.useMemo(()=>l.map(ue=>ue.key),[l]),{state:u,setState:d}=Pl(`${t}.toolbar`,{groupKey:((r=s[0])==null?void 0:r.key)??null,activeDims:[...e.defaultDimensions]}),[f,h]=C.useState(""),g=JNn("library",e.id),v=C.useCallback(ue=>{d(oe=>({...oe,groupKey:ue}))},[d]),b=C.useCallback(ue=>{d(oe=>({...oe,activeDims:oe.activeDims.includes(ue)?oe.activeDims.filter(ve=>ve!==ue):[...oe.activeDims,ue]}))},[d]),y=f.trim().toLowerCase(),x=C.useCallback(ue=>y!==""&&!CDn(ue).includes(y),[y]),S=C.useMemo(()=>{const ue=u.groupKey,oe=ue!==null?e.groupSummaries.get(ue):void 0,ve=new Map;for(const se of e.items){if(x(se))continue;const pe=(ue!==null?se.groups.get(ue):void 0)??"";let de=ve.get(pe);de===void 0&&(de={label:pe,summary:oe==null?void 0:oe.get(pe),items:[]},ve.set(pe,de)),de.items.push(se)}return[...ve.values()]},[e.items,e.groupSummaries,u.groupKey,x]),z=C.useMemo(()=>e.items.filter(x).length,[e.items,x]),M=_(e.hint),L=_(e.addLabel),R=C.useMemo(()=>_(e.onAdd),[e.onAdd]),N=C.useCallback(()=>{R&&queueMicrotask(()=>R())},[R]),O=C.useMemo(()=>_(e.style),[e.style]),j=Tt(O?_(O.height):void 0),B=Tt(O?_(O.maxHeight):void 0),H=j!==void 0||B!==void 0,K=H&&(O?_(O.virtualization):void 0)!==!1,U=C.useRef(null),[Z,G]=C.useState(1);C.useEffect(()=>{if(!H)return;const ue=U.current;if(ue===null)return;const oe=()=>G(MDn(ue.clientWidth));oe();const ve=new ResizeObserver(oe);return ve.observe(ue),()=>ve.disconnect()},[H]);const W=C.useMemo(()=>K?TDn(S,Z):[],[K,S,Z]),J=bI({count:W.length,getScrollElement:()=>U.current,estimateSize:ue=>{var oe;return((oe=W[ue])==null?void 0:oe.kind)==="groupHead"?33:104},overscan:4,measureElement:ue=>ue==null?void 0:ue.getBoundingClientRect().height}),ae=C.useRef(void 0),ne=C.useCallback(()=>{K&&(ae.current&&clearTimeout(ae.current),ae.current=setTimeout(()=>{var ue;const oe=((ue=J.getVirtualItems()[0])==null?void 0:ue.index)??0;d(ve=>ve.scrollIndex===oe?ve:{...ve,scrollIndex:oe})},150))},[K,J,d]),Y=C.useRef(!1);C.useEffect(()=>{if(!K||Y.current||W.length===0)return;Y.current=!0;const ue=u.scrollIndex??0;if(ue<=0)return;const oe=Math.min(ue,W.length-1);requestAnimationFrame(()=>J.scrollToIndex(oe,{align:"start"}))},[K,W.length]);const te=e.searchable&&n!==!0,ie=K?p.jsx(V,{css:a.canvas,style:{height:`${J.getTotalSize()}px`},children:J.getVirtualItems().map(ue=>{const oe=W[ue.index];return p.jsx(V,{ref:J.measureElement,"data-index":ue.index,css:a.row,style:{transform:`translateY(${ue.start}px)`},children:oe.kind==="groupHead"?p.jsx(z8e,{label:oe.label,count:oe.count,summary:oe.summary,styles:a}):p.jsx(V,{css:a.rowGrid,style:{gridTemplateColumns:`repeat(${Z}, minmax(0, 1fr))`},children:oe.items.map(ve=>p.jsx(k8e,{libraryId:e.id,item:ve,dimOrder:c,activeDims:u.activeDims,filtered:ve.filtered,styles:a},ve.key))})},ue.key)})}):S.map(ue=>p.jsxs(V,{css:a.group,children:[ue.label!==""&&p.jsx(z8e,{label:ue.label,count:ue.items.length,summary:ue.summary,styles:a}),p.jsx(V,{css:a.grid,children:ue.items.map(oe=>p.jsx(k8e,{libraryId:e.id,item:oe,dimOrder:c,activeDims:u.activeDims,filtered:oe.filtered,styles:a},oe.key))})]},ue.label||"_flat"));return p.jsxs(V,{css:a.root,ref:g,"data-library":e.id,...H?{"data-scrollable":""}:{},style:H?{height:j,maxHeight:B}:void 0,children:[M!==void 0&&p.jsx(V,{css:a.header,children:p.jsx(V,{as:"span",css:a.hint,children:M})}),(te||s.length>0||l.length>0)&&p.jsxs(V,{css:a.toolbar,children:[te&&p.jsxs(V,{css:[i.searchPill,a.search],children:[p.jsx(Ut,{icon:b$,style:{width:10,height:10}}),p.jsx(V,{as:"input",placeholder:"Search…","aria-label":"Search library",value:f,onChange:ue=>h(ue.target.value)}),f!==""&&p.jsx(V,{as:"button",css:i.searchClear,"aria-label":"Clear search",onClick:()=>h(""),children:p.jsx(Ut,{icon:c0,style:{width:9,height:9}})})]}),s.length>0&&p.jsxs(V,{css:a.segGroup,children:[p.jsx(V,{as:"span",css:a.segLabel,children:"Group by"}),s.map(ue=>p.jsx(V,{as:"button",css:{...o({tone:u.groupKey===ue.key?"brand":"neutral",size:"sm"}),cursor:"pointer"},"aria-pressed":u.groupKey===ue.key,onClick:()=>v(ue.key),children:ue.label},ue.key)),p.jsx(V,{as:"button",css:{...o({tone:u.groupKey===null?"brand":"neutral",size:"sm"}),cursor:"pointer"},"aria-pressed":u.groupKey===null,onClick:()=>v(null),children:"None"})]}),l.length>0&&p.jsxs(V,{css:a.segGroup,marginLeft:"auto",children:[p.jsx(V,{as:"span",css:a.segLabel,children:"Secondary"}),l.map(ue=>p.jsx(V,{as:"button",css:{...o({tone:u.activeDims.includes(ue.key)?"brand":"neutral",size:"sm"}),cursor:"pointer"},"aria-pressed":u.activeDims.includes(ue.key),onClick:()=>b(ue.key),children:ue.label},ue.key))]})]}),p.jsx(V,{ref:U,css:H?{...a.body,...xI}:a.body,...H?{"data-scrollable":""}:{},onScroll:ne,children:ie}),(z>0||L!==void 0)&&p.jsxs(V,{css:a.footer,children:[z>0&&p.jsxs(V,{as:"span",css:a.hiddenNote,children:[z," hidden by filter ·"," ",p.jsx(V,{as:"button",css:a.showAll,onClick:()=>h(""),children:"Show all"})]}),L!==void 0&&p.jsxs(V,{as:"button",css:a.addAction,marginLeft:"auto",onClick:N,children:["+ ",L]})]})]})}const EDn=C.memo(function(t){const n=_(t.value.slice),r=n==null?void 0:n.slice;rl(r==null?void 0:r.key);const a=en({key:"sliceFrame"})();if(n===void 0||r===void 0)return p.jsx(M8e,{...t});const o=r.read(),i=n.affordances.map(d=>d.type),s=Lv(i,o),l=Number(r.totalCount()),c=Number(r.resultCount()),u=l>0?Math.round((1-c/l)*100):0;return p.jsxs(V,{css:{...a.root,height:"100%",minHeight:0,display:"flex",flexDirection:"column"},children:[p.jsx(V,{css:{...a.frameEyebrow,flexShrink:0},children:p.jsx(zd,{slice:r,affordanceKinds:s})}),p.jsx(V,{css:{...a.frameBody,flex:"1 1 0%",minHeight:0,overflow:"hidden"},children:p.jsx(M8e,{...t,suppressSearch:s.includes("search")})}),p.jsxs(V,{css:{...a.frameFooter,flexShrink:0},children:[p.jsx(V,{as:"span",css:a.frameFooterStat,children:c.toLocaleString()}),p.jsx(V,{as:"span",children:`items · of ${l.toLocaleString()}`}),u>0&&p.jsx(V,{as:"span",css:a.frameFooterDelta,children:`· −${u}%`})]})]})},(e,t)=>SDn(e.value,t.value)&&e.storageKey===t.storageKey),_Dn=it(sv.Types.Deck),LDn=it(sv.Types.Readout),RDn=it(sv.Types.Rows),PDn=it(sv.Types.Note),ADn=300,T8e={success:"var(--chakra-colors-status-pos)",warning:"var(--chakra-colors-status-warn)",danger:"var(--chakra-colors-status-neg)",info:"var(--chakra-colors-brand-600)",neutral:"var(--chakra-colors-fg-subtle)"};function VV(e,t){if(t===void 0)return;const n=e.get(t);if(n===void 0)return;const r=n.color.type==="token"?T8e[n.color.value.type]??T8e.neutral:n.color.value;return{label:n.label,color:r,tint:`color-mix(in srgb, ${r} 8%, var(--chakra-colors-bg-surface))`,pulse:n.pulse,hint:_(n.hint)}}function jXe(e){return e!==void 0?{"--dc":e.color,"--dt":e.tint}:void 0}function FXe(e){return e===void 0?void 0:x$e({prefix:"fas",iconName:e})??void 0}function BXe(e,t,n){if(e===void 0)return"—";const r=_(n);if(r!==void 0)return r;const a=_(t);return a!==void 0?Iv(a,"linear")(e):new Intl.NumberFormat().format(e)}function VXe({st:e,styles:t}){return p.jsxs(V,{as:"span",css:t.stag,"data-pulse":e.pulse?"":void 0,children:[p.jsx(V,{as:"span",css:t.sdot,"data-part":"sdot"}),e.label]})}function NDn({item:e,st:t,styles:n,libStyles:r,open:a,activatable:o,registerEl:i,onActivate:s,onHoverStart:l,onHoverEnd:c,storageKey:u}){const d=FXe(_(e.icon)),f=_(e.sublabel),h=_(e.face),g=_(e.fill),v=g!==void 0&&g.max>0?Math.min(100,Math.max(0,g.value/g.max*100)):0;return p.jsxs(V,{css:n.card,ref:b=>i(e.key,b),"data-clickable":o?"":void 0,"data-filtered":e.filtered?"":void 0,"data-status":t!==void 0?"":void 0,"data-open":a?"":void 0,style:jXe(t),onMouseEnter:()=>l(e),onMouseLeave:c,...o?{role:"button",tabIndex:0,onClick:()=>s(e),onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&(b.preventDefault(),s(e))}}:{},children:[d!==void 0&&p.jsx(V,{css:n.cardIcon,children:p.jsx(Ut,{icon:d})}),p.jsxs(V,{css:n.cardBody,children:[p.jsxs(V,{css:n.cardHead,children:[p.jsxs(V,{css:n.cardId,children:[p.jsx(V,{as:"span",css:n.cardName,children:e.title}),f!==void 0&&p.jsx(V,{as:"span",css:n.cardSub,children:f})]}),t!==void 0&&p.jsx(VXe,{st:t,styles:n})]}),e.metrics.length>0&&p.jsx(V,{css:n.metricsRow,children:e.metrics.map((b,y)=>{const x=_(b.value);return p.jsxs(V,{css:n.metricCell,children:[p.jsx(V,{as:"span",css:n.metricK,children:b.label}),p.jsx(V,{as:"span",css:n.metricV,"data-warn":b.warn?"":void 0,"data-muted":x===void 0?"":void 0,children:BXe(x,b.format,b.text)})]},y)})}),e.facts.map((b,y)=>{const x=b.value;if(x.type==="meter"){const S=x.value.max>0?Math.min(100,Math.max(0,x.value.value/x.value.max*100)):0,z=_(x.value.text);return p.jsxs(V,{css:r.meter,children:[p.jsx(V,{css:r.meterTrack,children:p.jsx(V,{css:r.meterFill,style:{width:`${S}%`}})}),z!==void 0&&p.jsx(V,{as:"span",css:r.meterText,children:z})]},y)}return x.type==="chips"?p.jsx(V,{css:r.chips,children:x.value.map((S,z)=>p.jsx(V,{as:"span",css:r.chip,children:S},z))},y):p.jsx(V,{as:"span",css:r.dimText,children:x.value},y)}),h!==void 0&&p.jsx(V,{css:n.face,children:p.jsx(mn,{value:h,storageKey:`${u}.face.${e.key}`})}),g!==void 0&&p.jsxs(V,{css:n.fillRow,children:[p.jsx(V,{css:n.fillTrack,children:p.jsx(V,{css:n.fillBar,style:{width:`${v}%`}})}),p.jsx(V,{as:"span",css:n.fillPct,children:_(g.text)??(_(g.format)!==void 0?Iv(_(g.format),"linear")(g.value):`${Math.round(v)}%`)})]})]})]})}function E8e({item:e,st:t,body:n,mode:r,getAnchorRect:a,onDismiss:o,contentRef:i,styles:s,storageKey:l}){const c=FXe(_(e.icon)),u=_(e.sublabel);return p.jsx(nu,{open:!0,onOpenChange:d=>{d.open||o()},positioning:{placement:"right-start",getAnchorRect:a},autoFocus:r==="click",modal:!1,children:p.jsx(go,{children:p.jsx(M4,{children:p.jsxs(T4,{css:s.pop,"data-mode":r,"data-status":t!==void 0?"":void 0,"aria-label":e.title,style:jXe(t),...i!==void 0?{ref:i}:{},onKeyDown:d=>{r==="click"&&d.key==="Escape"&&(d.preventDefault(),o())},children:[p.jsxs(V,{css:s.popHead,children:[c!==void 0&&p.jsx(V,{css:s.cardIcon,children:p.jsx(Ut,{icon:c})}),p.jsxs(V,{css:s.cardId,children:[p.jsx(V,{as:"span",css:s.cardName,children:e.title}),u!==void 0&&p.jsx(V,{as:"span",css:s.cardSub,children:u})]}),t!==void 0&&p.jsx(VXe,{st:t,styles:s}),r==="click"&&p.jsx(Ht.button,{type:"button",css:s.popClose,"aria-label":"Close",onClick:o,children:p.jsx(Ut,{icon:c0})})]}),p.jsx(V,{css:s.popBody,children:p.jsx(mn,{value:n,storageKey:`${l}.${r}.${e.key}`})})]})})})})}const $Dn=C.memo(function({value:t}){const n=en({key:"deck"})();return p.jsx(V,{css:n.readout,children:t.cells.map((r,a)=>{const o=_(r.value),i=_(r.unit);return p.jsxs(V,{css:n.readoutCell,children:[p.jsx(V,{css:n.readoutK,children:r.label}),p.jsxs(V,{css:n.readoutV,"data-warn":r.warn?"":void 0,"data-muted":o===void 0?"":void 0,children:[BXe(o,r.format,r.text),i!==void 0&&p.jsx(V,{as:"span",css:n.readoutU,children:i})]})]},a)})})},(e,t)=>LDn(e.value,t.value)),IDn=C.memo(function({value:t}){const n=en({key:"deck"})();return p.jsx(V,{css:n.drows,children:t.rows.map((r,a)=>p.jsxs(V,{css:n.drow,children:[p.jsx(V,{as:"span",css:n.drowK,children:r.label}),p.jsx(V,{as:"span",css:n.drowV,children:r.value})]},a))})},(e,t)=>RDn(e.value,t.value)),DDn=C.memo(function({value:t}){const n=en({key:"deck"})();return p.jsx(V,{css:n.note,children:t.text})},(e,t)=>PDn(e.value,t.value));function _8e({value:e,storageKey:t}){var n,r;const a=en({key:"deck"})(),o=en({key:"library"})(),i=ga({key:"chip"}),s=e.groupOptions,{state:l,setState:c}=Pl(`${t}.toolbar`,{groupKey:((n=s[0])==null?void 0:n.key)??null,collapsed:[]}),u=C.useCallback(oe=>{c(ve=>({...ve,groupKey:oe,collapsed:[]}))},[c]),d=C.useCallback(oe=>{c(ve=>({...ve,collapsed:ve.collapsed.includes(oe)?ve.collapsed.filter(se=>se!==oe):[...ve.collapsed,oe]}))},[c]),f=C.useMemo(()=>{const oe=l.groupKey,ve=oe!==null?e.groupSummaries.get(oe):void 0,se=new Map;for(const pe of e.items){const de=(oe!==null?pe.groups.get(oe):void 0)??"";let ge=se.get(de);ge===void 0&&(ge={label:de,summary:ve==null?void 0:ve.get(de),items:[]},se.set(de,ge)),ge.items.push(pe)}return[...se.values()]},[e.items,e.groupSummaries,l.groupKey]),h=C.useMemo(()=>_(e.onCardClick),[e.onCardClick]),g=C.useMemo(()=>_(e.onOpen),[e.onOpen]),v=C.useMemo(()=>_(e.onClose),[e.onClose]),b=C.useCallback(oe=>VV(e.statuses,_(oe.status)),[e.statuses]),y=C.useRef(new Map),x=C.useCallback((oe,ve)=>{ve===null?y.current.delete(oe):y.current.set(oe,ve)},[]),S=C.useCallback(oe=>()=>{const ve=y.current.get(oe);return ve!==void 0?ve.getBoundingClientRect():null},[]),[z,M]=C.useState(null),L=C.useMemo(()=>z!==null?e.items.find(oe=>oe.key===z):void 0,[e.items,z]),R=L!==void 0?_(L.detail):void 0,N=C.useCallback(()=>{z!==null&&(M(null),v&&queueMicrotask(()=>{v()}))},[z,v]),O=C.useCallback(oe=>{_(oe.detail)!==void 0&&(M(oe.key),g&&queueMicrotask(()=>{g(oe.key)})),h&&queueMicrotask(()=>h(oe.key))},[g,h]),j=C.useRef(null);C.useEffect(()=>{if(z===null)return;const oe=ve=>{const se=j.current;se!==null&&!se.contains(ve.target)&&N()};return document.addEventListener("pointerdown",oe),()=>document.removeEventListener("pointerdown",oe)},[z,N]);const B=Poe(),[H,K]=C.useState(null),U=C.useRef(null),Z=C.useCallback(oe=>{!B||_(oe.hover)===void 0||(U.current!==null&&clearTimeout(U.current),U.current=setTimeout(()=>{K(oe.key)},ADn))},[B]),G=C.useCallback(()=>{U.current!==null&&clearTimeout(U.current),U.current=null,K(null)},[]);C.useEffect(()=>()=>{U.current!==null&&clearTimeout(U.current)},[]);const W=C.useMemo(()=>H!==null?e.items.find(oe=>oe.key===H):void 0,[e.items,H]),J=W!==void 0?_(W.hover):void 0,ae=((r=_(e.layout))==null?void 0:r.type)??"grid",ne=C.useMemo(()=>_(e.style),[e.style]),Y=Tt(ne?_(ne.height):void 0),te=Tt(ne?_(ne.maxHeight):void 0),ie=Tt(ne?_(ne.minCardWidth):void 0)??"240px",ue=Y!==void 0||te!==void 0;return p.jsxs(V,{css:a.root,"data-scrollable":ue?"":void 0,style:{...Y!==void 0?{height:Y}:{},...te!==void 0?{maxHeight:te}:{}},children:[s.length>0&&p.jsx(V,{css:a.toolbar,children:p.jsxs(V,{css:a.segGroup,children:[p.jsx(V,{as:"span",css:a.segLabel,children:"Group by"}),[...s,{key:null,label:"None"}].map(oe=>p.jsx(V,{as:"button",css:{...i({tone:l.groupKey===oe.key?"brand":"neutral",size:"sm"}),cursor:"pointer"},onClick:()=>u(oe.key),children:oe.label},oe.key??"∅"))]})}),p.jsx(V,{css:a.body,"data-scrollable":ue?"":void 0,children:f.map(oe=>{const ve=l.collapsed.includes(oe.label),se=VV(e.statuses,oe.label!==""?oe.label:void 0);return p.jsxs(V,{css:a.group,children:[oe.label!==""&&p.jsxs(V,{as:"button",css:a.groupHead,"aria-expanded":!ve,onClick:()=>d(oe.label),children:[p.jsx(V,{as:"span",css:a.groupChevron,children:p.jsx(Ut,{icon:ve?r2:au})}),se!==void 0&&p.jsx(V,{as:"span",css:a.groupSwatch,style:{background:se.color}}),p.jsx(V,{as:"span",css:a.groupLabel,children:(se==null?void 0:se.label)??oe.label}),p.jsx(V,{as:"span",css:a.groupCount,children:oe.items.length}),(oe.summary??(se==null?void 0:se.hint))!==void 0&&p.jsx(V,{as:"span",css:a.groupSummary,children:oe.summary??(se==null?void 0:se.hint)})]}),!ve&&p.jsx(V,{css:ae==="list"?a.list:a.grid,style:ae==="grid"?{gridTemplateColumns:`repeat(auto-fill, minmax(min(${ie}, 100%), 1fr))`}:void 0,children:oe.items.map(pe=>p.jsx(NDn,{item:pe,st:b(pe),styles:a,libStyles:o,open:z===pe.key,activatable:h!==void 0||_(pe.detail)!==void 0,registerEl:x,onActivate:O,onHoverStart:Z,onHoverEnd:G,storageKey:t},pe.key))})]},oe.label||"∅")})}),e.footer.length>0&&p.jsx(V,{css:a.footRow,children:e.footer.map((oe,ve)=>p.jsxs(C.Fragment,{children:[ve>0&&p.jsx(V,{as:"span",css:a.footSep,children:"·"}),p.jsx(V,{as:"span",css:a.footK,children:oe.label}),p.jsx(V,{as:"span",css:a.footV,children:oe.value})]},ve))}),e.legend&&e.statuses.size>0&&p.jsx(V,{css:a.legend,children:[...e.statuses.keys()].map(oe=>{const ve=VV(e.statuses,oe);return ve===void 0?null:p.jsxs(V,{css:a.legendItem,children:[p.jsx(V,{as:"span",css:a.legendSw,style:{background:ve.color}}),p.jsx(V,{as:"span",css:a.legendLb,children:ve.label}),ve.hint!==void 0&&p.jsx(V,{as:"span",css:a.legendDs,children:ve.hint})]},oe)})}),W!==void 0&&J!==void 0&&H!==null&&z===null&&p.jsx(E8e,{item:W,st:b(W),body:J,mode:"hover",getAnchorRect:S(W.key),onDismiss:G,contentRef:void 0,styles:a,storageKey:t}),L!==void 0&&R!==void 0&&z!==null&&p.jsx(E8e,{item:L,st:b(L),body:R,mode:"click",getAnchorRect:S(L.key),onDismiss:N,contentRef:j,styles:a,storageKey:t})]})}const ODn=C.memo(function(t){const n=_(t.value.slice),r=n==null?void 0:n.slice;rl(r==null?void 0:r.key);const a=en({key:"sliceFrame"})();if(n===void 0||r===void 0)return p.jsx(_8e,{...t});const o=r.read(),i=n.affordances.map(d=>d.type),s=Lv(i,o),l=Number(r.totalCount()),c=Number(r.resultCount()),u=l>0?Math.round((1-c/l)*100):0;return p.jsxs(V,{css:{...a.root,height:"100%",minHeight:0,display:"flex",flexDirection:"column"},children:[p.jsx(V,{css:{...a.frameEyebrow,flexShrink:0},children:p.jsx(zd,{slice:r,affordanceKinds:s})}),p.jsx(V,{css:{...a.frameBody,flex:"1 1 0%",minHeight:0,overflow:"hidden"},children:p.jsx(_8e,{...t})}),p.jsxs(V,{css:{...a.frameFooter,flexShrink:0},children:[p.jsx(V,{as:"span",css:a.frameFooterStat,children:c.toLocaleString()}),p.jsx(V,{as:"span",children:`cards · of ${l.toLocaleString()}`}),u>0&&p.jsx(V,{as:"span",css:a.frameFooterDelta,children:`· −${u}%`})]})]})},(e,t)=>_Dn(e.value,t.value)&&e.storageKey===t.storageKey),jDn=it(fq.Types.Checkbox);function L8e(e){var t,n;const r=_(e.indeterminate),a=_(e.style),o=a?(t=_(a.colorPalette))==null?void 0:t.type:void 0,i=a?(n=_(a.size))==null?void 0:n.type:void 0;return{checked:r?"indeterminate":e.checked,disabled:_(e.disabled),colorPalette:o??"brand",size:i}}const HXe=C.memo(function({value:t}){const[n,r]=C.useState(L8e(t)),a=C.useMemo(()=>_(t.label),[t.label]),o=C.useMemo(()=>_(t.onChange),[t.onChange]);C.useEffect(()=>{r(()=>L8e(t))},[t]);const i=C.useCallback(s=>{r(l=>({...l,checked:s.checked})),o&&queueMicrotask(()=>o(s.checked===!0))},[o]);return p.jsxs(kNt,{...n,onCheckedChange:i,children:[p.jsx(ENt,{}),p.jsx(TNt,{}),a&&p.jsx(zNt,{children:a})]})},(e,t)=>jDn(e.value,t.value)),FDn=it(Ste.Types.Root),bb=32,BDn=1,R8e=18,VDn=3;function HDn(e){let t="";for(const n of e)n.type==="field"?t+=`.${n.value}`:n.type==="index"?t+=`[${n.value}]`:n.type==="key"?t+=`{${n.value}}`:n.type==="some"?t+="?":t+="!";return t===""?"$":t}function MI(e){const t=e.replace(/[_-]+/g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").trim();return t===""?e:t.charAt(0).toUpperCase()+t.slice(1).toLowerCase()}function WDn(e,t){let n=e,r=t,a,o;for(;;){if(n.type==="option"){const s=_(n.value.value);if(o===void 0&&(o={path:r,isSome:s!==void 0}),s===void 0)return{kind:"emptyOption",leaf:void 0,opaque:void 0,node:n,path:r,variantCtl:a,optionCtl:o};r=[...r,$("some",null)],n=s;continue}if(n.type==="variant"){a===void 0&&(a={path:r,tag:n.value.tag,tags:[...n.value.tags]}),r=[...r,$("tag",null)],n=n.value.value;continue}break}return{kind:n.type==="leaf"?"leaf":n.type==="opaque"?"opaque":n.type==="struct"?"struct":n.type==="array"?"array":"dict",leaf:n.type==="leaf"?n.value:void 0,opaque:n.type==="opaque"?n.value:void 0,node:n,path:r,variantCtl:a,optionCtl:o}}function P8e(e){for(;;){if(e.type==="option"){const t=_(e.value.value);if(t===void 0)return e;e=t;continue}if(e.type==="variant"){e=e.value.value;continue}return e}}function WXe(e){switch(e.type){case"string":return e.value;case"integer":return String(e.value);case"float":return String(e.value);case"boolean":return e.value?"true":"false";case"datetime":return e.value.toISOString().replace("T"," ").slice(0,19);default:return"—"}}function UDn(e){for(;;){if(e.type==="option"){const t=_(e.value.value);if(t===void 0)return;e=t;continue}break}if(e.type==="variant")return MI(e.value.tag);if(e.type==="leaf"){if(e.value.type==="null")return;const t=WXe(e.value);return t===""?void 0:t}}function qDn(e){if(e.type==="struct"){const t=[];for(const r of e.value.fields){const a=UDn(r.node);if(a!==void 0&&t.push(a),t.length>=VDn)break}if(t.length>0)return t.join(" · ");const n=e.value.fields.length;return n===0?"Empty":n===1?"1 field":`${n} fields`}if(e.type==="array"){const t=e.value.items.length;return t===0?"Empty":t===1?"1 item":`${t} items`}if(e.type==="dict"){const t=e.value.entries.length;return t===0?"Empty":t===1?"1 entry":`${t} entries`}return""}function UXe(e,t){const n=P8e(e);if(n.type==="struct")for(const r of n.value.fields){const a=P8e(r.node);if(a.type==="leaf"&&a.value.type==="string"&&a.value.value!=="")return a.value.value}return`Item ${t+1}`}function qXe(e){return e.type==="struct"?e.value.fields.map(t=>({label:MI(t.name),node:t.node,step:$("field",t.name)})):e.type==="array"?e.value.items.map((t,n)=>({label:UXe(t,n),node:t,step:$("index",BigInt(n))})):e.type==="dict"?e.value.entries.map(t=>({label:t.key,node:t.node,step:$("key",t.key)})):[]}function GXe(e,t,n,r,a,o){return{id:`${e??"$"}/$append`,parentId:e,depth:r,label:n==="appendArray"?"Add item":"Add entry",kind:n,leaf:void 0,opaque:void 0,summary:void 0,path:t,ownPath:t,variantCtl:void 0,optionCtl:void 0,removable:!1,expandable:!1,expanded:!1,posinset:a,setsize:o}}function Pie(e,t,n,r,a,o,i,s,l){const c=WDn(n,r),u=HDn(r),d=qXe(c.node),f=e.canInsert&&(c.kind==="array"||c.kind==="dict"&&c.node.type==="dict"&&c.node.value.editable),h=d.length>0||f,g=h&&(e.open[u]??o<e.openDepth);let v=c.kind==="emptyOption"?"Not set":c.kind==="struct"||c.kind==="array"||c.kind==="dict"?qDn(c.node):void 0;if(v!==void 0&&v!==t&&v.startsWith(`${t} · `)?v=v.slice(t.length+3):v===t&&(v=void 0),e.rows.push({id:u,parentId:a,depth:o,label:t,kind:c.kind,leaf:c.leaf,opaque:c.opaque,summary:v,path:c.path,ownPath:r,variantCtl:c.variantCtl,optionCtl:c.optionCtl,removable:i,expandable:h,expanded:g,posinset:s,setsize:l}),g){const b=e.canRemove&&(c.kind==="array"||c.kind==="dict"&&c.node.type==="dict"&&c.node.value.editable),y=d.length+(f?1:0);d.forEach((x,S)=>{Pie(e,x.label,x.node,[...c.path,x.step],u,o+1,b,S+1,y)}),f&&e.rows.push(GXe(u,c.path,c.kind==="array"?"appendArray":"appendDict",o+1,y,y))}}function GDn(e,t,n,r,a){const o={open:t,openDepth:n,canRemove:r,canInsert:a,rows:[]},i=(c,u,d,f,h,g,v,b)=>Pie(o,c,u,d,f,h,g,v,b),s=o.rows,l=(c,u,d,f,h,g)=>GXe(c,u,d,f,h,g);if(e.type==="struct"||e.type==="array"||e.type==="dict"){const c=a&&(e.type==="array"||e.type==="dict"&&e.value.editable),u=r&&(e.type==="array"||e.type==="dict"&&e.value.editable),d=qXe(e),f=d.length+(c?1:0);d.forEach((h,g)=>{i(h.label,h.node,[h.step],void 0,0,u,g+1,f)}),c&&s.push(l(void 0,[],e.type==="array"?"appendArray":"appendDict",0,f,f))}else i("Value",e,[],void 0,0,!1,1,1);return s}function A8e(...e){try{if(typeof localStorage>"u")return;const t=localStorage.getItem("e3-paging-debug");if(t===null||t==="off")return}catch{return}console.info("[e3-paging:tree]",...e)}function KDn(e,t,n){const{totalRows:r,pageSize:a,pages:o}=e,i=Math.max(0,Math.ceil(r/a)),s=d=>Math.max(0,Math.min(a,r-d*a)),l=new Map,c=[],u=new Array(i+1);u[0]=0;for(let d=0;d<i;d++){const f=o.get(d);if(f===void 0){u[d+1]=u[d]+s(d);continue}const h={open:t,openDepth:n,canRemove:!1,canInsert:!1,rows:[]};f.forEach((g,v)=>{const b=d*a+v,y=g.label??UXe(g.node,b);Pie(h,y,g.node,[g.step],void 0,0,!1,b+1,r)}),l.set(d,h.rows),c.push(...h.rows),u[d+1]=u[d]+h.rows.length}return{totalFlat:u[i]??0,prefix:u,pageModels:l,loadedRows:c,pageCount:i,rootRowsInPage:s}}function nX(e,t){let n=0,r=e.length-2;for(;n<r;){const a=n+r>>1;e[a+1]<=t?n=a+1:r=a}return n}function YDn(e,t,n){const r=nX(e.prefix,n),a=n-e.prefix[r],o=e.pageModels.get(r);return o!==void 0?{kind:"model",row:o[a]}:{kind:"placeholder",globalRow:r*t.pageSize+a}}const fx=P({size:P($("xs",null))});function XDn(e,t,n){return{value:P(e),items:t.map(r=>({value:r,label:MI(r),disabled:A})),placeholder:A,multiple:A,disabled:A,onChange:P(n),onChangeMultiple:A,onOpenChange:A,style:fx}}function ZDn({leaf:e,path:t,onEdit:n}){switch(e.type){case"string":return p.jsx(Y$,{value:{value:e.value,onChange:P(r=>{n(t,$("string",r))}),style:fx}});case"integer":return p.jsx(X$,{value:{value:e.value,onChange:P(r=>{n(t,$("integer",r))}),style:fx}});case"float":return p.jsx(Z$,{value:{value:e.value,onChange:P(r=>{n(t,$("float",r))}),style:fx}});case"datetime":return p.jsx(m9,{value:{value:e.value,onChange:P(r=>{n(t,$("datetime",r))}),style:fx}});case"boolean":return p.jsx(HXe,{value:{checked:e.value,onChange:P(r=>{n(t,$("boolean",r))})}});default:return null}}function QDn({path:e,styles:t,onInsert:n}){const[r,a]=C.useState(void 0);return r===void 0?p.jsxs(Ht.button,{type:"button",css:t.append,"aria-label":"Add entry",onClick:()=>a(""),children:[p.jsx(Ut,{icon:m5})," Add entry"]}):p.jsx(Ht.input,{css:t.keyInput,autoFocus:!0,value:r,placeholder:"name","aria-label":"New entry key",onChange:o=>a(o.target.value),onBlur:()=>a(void 0),onKeyDown:o=>{o.key==="Enter"&&r!==""?(n([...e,$("key",r)]),a(void 0)):o.key==="Escape"&&a(void 0)}})}function JDn({row:e,styles:t,cbs:n,tabbable:r,onToggle:a,onKeyNav:o,onFocusRow:i}){var s;const{onEdit:l,onInsert:c,onRemove:u,onTag:d}=n,f=b=>{b.target===b.currentTarget&&o(e.id,b.key)&&b.preventDefault()};if((e.kind==="appendArray"||e.kind==="appendDict")&&c!==void 0)return p.jsxs(V,{css:t.row,"data-part":"row","data-row-id":e.id,role:"treeitem","aria-level":e.depth+1,tabIndex:r?0:-1,onKeyDown:f,onFocus:b=>{b.target===b.currentTarget&&i(e.id)},style:{paddingLeft:`${12+e.depth*R8e}px`},children:[p.jsx(V,{css:t.twist,visibility:"hidden","aria-hidden":"true"}),e.kind==="appendArray"?p.jsxs(Ht.button,{type:"button",css:t.append,"aria-label":e.label,onClick:()=>{c([...e.path,$("append",null)])},children:[p.jsx(Ut,{icon:m5})," ",e.label]}):p.jsx(QDn,{path:e.path,styles:t,onInsert:c})]});const h=e.variantCtl!==void 0&&d===void 0?p.jsx(V,{as:"span",css:t.summary,children:MI(e.variantCtl.tag)}):null,g=e.variantCtl!==void 0&&d!==void 0?(()=>{const b=e.variantCtl;return p.jsx(V,{css:t.tagWrap,children:p.jsx(h6,{ariaLabel:"Variant tag",value:XDn(b.tag,b.tags,y=>{y!==b.tag&&d(b.path,y)})})})})():null;let v;return e.kind==="leaf"&&e.leaf!==void 0?v=l!==void 0&&e.leaf.type!=="null"?p.jsx(ZDn,{leaf:e.leaf,path:e.path,onEdit:l}):(h!==null||g!==null)&&e.leaf.type==="null"?null:p.jsx(V,{as:"span",css:t.valueText,children:WXe(e.leaf)}):e.kind==="opaque"?v=p.jsx(V,{as:"span",css:t.opaque,title:e.opaque,children:e.opaque}):v=e.summary!==void 0&&e.summary!==""?p.jsx(V,{as:"span",css:t.summary,children:e.summary}):null,p.jsxs(V,{css:t.row,"data-part":"row","data-row-id":e.id,role:"treeitem","aria-level":e.depth+1,"aria-posinset":e.posinset,"aria-setsize":e.setsize,"aria-expanded":e.expandable?e.expanded:void 0,tabIndex:r?0:-1,onKeyDown:f,onFocus:b=>{b.target===b.currentTarget&&i(e.id)},style:{paddingLeft:`${12+e.depth*R8e}px`},children:[e.expandable?p.jsx(Ht.button,{type:"button",css:t.twist,tabIndex:-1,"aria-label":e.expanded?"Collapse":"Expand",title:e.expanded?"Collapse (Alt: entire subtree)":"Expand",onClick:b=>a(e.id,!e.expanded,b.altKey),children:p.jsx(Ut,{icon:e.expanded?au:r2})}):p.jsx(V,{css:t.twist,visibility:"hidden","aria-hidden":"true"}),p.jsx(V,{as:"span",css:t.label,title:e.label,children:e.label}),p.jsxs(V,{css:t.value,"data-leaf":(s=e.leaf)==null?void 0:s.type,children:[h,g,v]}),p.jsxs(V,{css:t.controls,children:[e.optionCtl!==void 0&&d!==void 0&&(()=>{const b=e.optionCtl;return b.isSome?p.jsx(Ht.button,{type:"button",css:t.ctl,"aria-label":"Clear value",onClick:()=>{d(b.path,"none")},children:p.jsx(Ut,{icon:m$})}):p.jsx(Ht.button,{type:"button",css:t.setBtn,"aria-label":"Set value",onClick:()=>{d(b.path,"some")},children:"Set"})})(),e.removable&&u!==void 0&&p.jsx(Ht.button,{type:"button",css:t.ctl,"aria-label":"Remove",onClick:()=>{u(e.ownPath)},children:p.jsx(Ut,{icon:c0})})]})]})}const Aie=C.memo(function({value:t,storageKey:n,paging:r}){var a;const i=en({key:"valueTree"})(),s=C.useMemo(()=>({onEdit:_(t.onEdit),onInsert:_(t.onInsert),onRemove:_(t.onRemove),onTag:_(t.onTag)}),[t.onEdit,t.onInsert,t.onRemove,t.onTag]),{state:l,setState:c}=Pl(n,{open:{},topRow:0}),u=_(t.style),d=u!==void 0&&u.openDepth!==void 0?_(u.openDepth):void 0,f=(u!==void 0&&u.toolbar!==void 0?_(u.toolbar):void 0)===!0,h=l.baseDepth??(d!==void 0?Number(d):BDn),g=C.useMemo(()=>{if(r===void 0)return;const Y=KDn(r,l.open,h);return A8e(`flatten: totalRows=${r.totalRows} pageSize=${r.pageSize} totalFlat=${Y.totalFlat} loaded=[${[...Y.pageModels.entries()].map(([te,ie])=>`p${te}:${ie.length}`).join(" ")}]`),Y},[r,l.open,h]),v=C.useMemo(()=>g!==void 0?g.loadedRows:GDn(t.root,l.open,h,s.onRemove!==void 0,s.onInsert!==void 0),[g,t.root,l.open,h,s.onRemove,s.onInsert]),b=g!==void 0?g.totalFlat:v.length,y=C.useCallback((Y,te,ie=!1)=>{c(ue=>{if(!ie||te)return{...ue,open:{...ue.open,[Y]:te}};const oe={...ue.open,[Y]:!1},ve=v.findIndex(se=>se.id===Y);if(ve>=0){const se=v[ve].depth;for(let pe=ve+1;pe<v.length&&v[pe].depth>se;pe++)v[pe].expandable&&(oe[v[pe].id]=!1)}return{...ue,open:oe}})},[c,v]),x=C.useCallback(()=>{c(Y=>({...Y,open:{},baseDepth:0}))},[c]),S=C.useCallback(()=>{c(Y=>({...Y,open:{},baseDepth:Number.MAX_SAFE_INTEGER}))},[c]),z=C.useRef(null),[M,L]=C.useState(void 0),R=C.useCallback(Y=>{L(Y)},[]),N=C.useCallback(Y=>{var te;L(Y);const ie=Y.replace(/\\/g,"\\\\").replace(/"/g,'\\"'),ue=(te=z.current)==null?void 0:te.querySelector(`[data-row-id="${ie}"]`);ue==null||ue.focus()},[]),O=C.useCallback((Y,te)=>{const ie=v.findIndex(oe=>oe.id===Y);if(ie<0)return!1;const ue=v[ie];switch(te){case"ArrowDown":{const oe=v[ie+1];return oe!==void 0&&N(oe.id),!0}case"ArrowUp":{const oe=v[ie-1];return oe!==void 0&&N(oe.id),!0}case"ArrowRight":{if(ue.expandable&&!ue.expanded)y(ue.id,!0);else{const oe=v[ie+1];oe!==void 0&&N(oe.id)}return!0}case"ArrowLeft":return ue.expandable&&ue.expanded?y(ue.id,!1):ue.parentId!==void 0&&N(ue.parentId),!0;case"Enter":case" ":return ue.expandable&&y(ue.id,!ue.expanded),!0;default:return!1}},[v,N,y]),j=C.useRef(null),B=C.useRef(!1);C.useLayoutEffect(()=>{if(B.current)return;B.current=!0;const Y=j.current;Y!==null&&l.topRow>0&&(Y.scrollTop=l.topRow*bb)},[l.topRow]);const H=C.useCallback(()=>{if(r===void 0||g===void 0||r.totalRows===0)return;const Y=j.current,te=Y===null?0:Math.max(0,Math.floor(Y.scrollTop/bb)),ie=Y===null?60:Math.ceil(Y.clientHeight/bb)+1,ue=Math.min(g.totalFlat-1,te+ie),oe=Math.max(0,nX(g.prefix,te)-1),ve=Math.min(g.pageCount-1,nX(g.prefix,ue)+1);A8e(`visible: scrollTop=${(Y==null?void 0:Y.scrollTop)??"null"} clientH=${(Y==null?void 0:Y.clientHeight)??"null"} flat[${te},${ue}] → pages ${oe}..${ve} → rows [${oe*r.pageSize}, ${Math.min(r.totalRows,(ve+1)*r.pageSize)})`),r.onNeedRows(oe*r.pageSize,Math.min(r.totalRows,(ve+1)*r.pageSize))},[r,g]);C.useLayoutEffect(()=>{H()},[H]);const K=C.useCallback(()=>{const Y=j.current;if(Y===null)return;const te=Math.round(Y.scrollTop/bb);c(ie=>ie.topRow===te?ie:{...ie,topRow:te}),H()},[c,H]),U=u!==void 0?_(u.height):void 0,Z=u!==void 0?_(u.maxHeight):void 0;if(b===0)return p.jsx(V,{css:i.root,role:"tree",children:p.jsx(V,{css:i.empty,children:"No values"})});const G=M!==void 0&&v.some(Y=>Y.id===M)?M:(a=v[0])==null?void 0:a.id,W=Tt(U),J=Tt(Z),ae=W!==void 0||J!==void 0,ne=f?p.jsxs(V,{css:i.toolbar,children:[p.jsx(Ht.button,{type:"button",css:i.toolbarBtn,onClick:x,children:"Collapse all"}),p.jsx(Ht.button,{type:"button",css:i.toolbarBtn,onClick:S,children:"Expand all"})]}):void 0;return p.jsx(V,{role:"tree","aria-label":"Value tree",ref:z,...ae&&{display:"flex",flexDirection:"column",minHeight:0,height:W,maxHeight:J},children:p.jsx(Dv,{height:ae?void 0:U,maxHeight:ae?void 0:Z,fillParent:ae,header:ne,count:b,estimateSize:()=>bb,overscan:8,rootCss:i.root,scrollElRef:j,onScroll:K,renderRow:Y=>{let te;if(g!==void 0&&r!==void 0){const ie=YDn(g,r,Y);if(ie.kind==="placeholder")return p.jsxs(V,{css:i.row,"data-part":"row","data-placeholder-row":ie.globalRow,role:"treeitem","aria-level":1,"aria-posinset":ie.globalRow+1,"aria-setsize":r.totalRows,"aria-busy":"true",style:{paddingLeft:"12px"},children:[p.jsx(V,{css:i.twist,visibility:"hidden","aria-hidden":"true"}),p.jsx(d4,{height:"14px",flex:"0 1 160px"}),p.jsx(d4,{height:"14px",flex:"0 1 90px",opacity:.6})]});te=ie.row}else te=v[Y];return te===void 0?null:p.jsx(JDn,{row:te,styles:i,cbs:s,tabbable:te.id===G,onToggle:y,onKeyNav:O,onFocusRow:R},te.id)}})})},(e,t)=>FDn(e.value,t.value)&&e.storageKey===t.storageKey&&e.paging===t.paging),eOn=it(Cte.Types.Roster),KXe=84,tOn=`${KXe}px`;function N8e(e,t){return`${e}\0${t}`}function KE(e,t,n,r){return{surface:e,row:t,slot:n,event:r!==void 0?P(r):A}}function nOn(e){return Sr(e.state,{committed:()=>e.label,rejected:()=>e.label,proposed:t=>Sr(t,{added:()=>`+${e.label}`,removed:()=>e.label,model:()=>e.label})})}function rOn(e){return Sr(e.state,{committed:()=>"committed",rejected:()=>"rejected",proposed:t=>Sr(t,{added:()=>"added",removed:()=>"removed",model:()=>"model"})})}function aOn({surface:e,person:t,day:n,shift:r,edit:a,styles:o,onSelect:i,onAccept:s,onRemove:l}){const c=rOn(r),u=c==="model",d=a&&(c==="added"||c==="removed"||c==="model"),f=C.useMemo(()=>({surface:e,row:t,slot:n,event:r.key}),[e,t,n,r.key]),h=C.useMemo(()=>p.jsx(V,{css:o.dragGhost,children:r.label}),[o.dragGhost,r.label]),g=CI(f,h,!d),v=C.useCallback(b=>{b.stopPropagation();const y=KE(e,t,n,r.key);u&&s?s(y):i&&i(y)},[e,t,n,r.key,u,s,i]);return p.jsxs(V,{css:o.chip,"data-state":c,onPointerDown:g,onClick:v,...d&&g?{"data-draggable":""}:{},children:[d&&g&&p.jsx(V,{as:"span",css:o.chipGrip,children:p.jsx(Ut,{icon:g5})}),p.jsx(V,{as:"span",css:o.chipLabel,children:nOn(r)}),(u&&s||d&&l)&&p.jsxs(V,{css:o.chipActions,children:[u&&s&&p.jsx(V,{as:"button",css:o.chipAction,"aria-label":"Accept ghost shift",onPointerDown:b=>b.stopPropagation(),onClick:b=>{b.stopPropagation(),s(KE(e,t,n,r.key))},children:p.jsx(Ut,{icon:_$})}),d&&l&&p.jsx(V,{as:"button",css:o.chipAction,"data-danger":"","aria-label":"Remove shift",onPointerDown:b=>b.stopPropagation(),onClick:b=>{b.stopPropagation(),l(KE(e,t,n,r.key))},children:p.jsx(Ut,{icon:UC})})]})]})}function oOn({surface:e,person:t,day:n,shifts:r,edit:a,styles:o,vetoFor:i,onSelect:s,onAccept:l,onRemove:c,onAddAt:u}){const d=C.useMemo(()=>({surface:e,row:t,slot:n}),[e,t,n]),f=C.useMemo(()=>i==null?void 0:i(d),[i,d]),h=lk(a?d:null,!1,f),g=C.useCallback(()=>{a&&r.length===0&&u&&u(KE(e,t,n))},[a,r.length,u,e,t,n]);return p.jsx(V,{ref:h,css:o.cell,onClick:g,...a&&r.length===0&&u?{"data-addable":""}:{},children:r.map(v=>p.jsx(aOn,{surface:e,person:t,day:n,shift:v,edit:a,styles:o,onSelect:s,onAccept:l,onRemove:c},v.key))})}const iOn=C.memo(function({value:t,storageKey:n}){const r=en({key:"roster"})(),a=t.mode.type==="edit",[o,i]=C.useState(()=>[...t.shifts]);C.useEffect(()=>{i([...t.shifts])},[t.shifts]);const s=C.useMemo(()=>_(t.onDrag),[t.onDrag]),l=C.useMemo(()=>_(t.canDrop),[t.canDrop]),c=kI(l),u=C.useMemo(()=>_(t.review),[t.review]),d=C.useMemo(()=>t.people.map(ue=>ue.approval),[t]),f=ok(u,d),h=en({key:"reviewChrome"}),g=C.useMemo(()=>h({}),[h]),v=C.useMemo(()=>{const ue={};for(const oe of["success","warning","danger","info","neutral"])ue[oe]=h({status:oe}).statusDot??{};return ue},[h]),b=C.useMemo(()=>_(t.onSelect),[t.onSelect]),y=C.useMemo(()=>_(t.onAccept),[t.onAccept]),x=C.useMemo(()=>_(t.onAddAt),[t.onAddAt]),S=C.useCallback((ue,oe)=>{if((ue.type==="add"||ue.type==="move")&&!t7(l,ue))return;let ve=o;if(ue.type==="add"){const{from:se,into:pe}=ue.value;ve=[...o,{key:`local:${se.library}:${se.key}:${pe.row}:${pe.slot}:${o.length}`,person:pe.row,day:pe.slot,label:(oe==null?void 0:oe.label)??se.key,state:$("proposed",$("added",null))}]}else if(ue.type==="move"){const{from:se,to:pe}=ue.value,de=se.event.type==="some"?se.event.value:void 0;ve=o.map(ge=>ge.key===de?{...ge,person:pe.row,day:pe.slot}:ge)}else if(ue.type==="remove"){const se=ue.value.from.event.type==="some"?ue.value.from.event.value:void 0;ve=o.filter(pe=>pe.key!==se)}i(ve),s&&queueMicrotask(()=>s(ue))},[o,s,l]),z=C.useMemo(()=>b?ue=>queueMicrotask(()=>b(ue)):void 0,[b]),M=C.useCallback(ue=>{const oe=ue.event.type==="some"?ue.event.value:void 0,ve=o.map(se=>se.key===oe&&se.state.type==="proposed"&&se.state.value.type==="model"?{...se,state:$("proposed",$("added",null))}:se);i(ve),y&&queueMicrotask(()=>y(ue))},[o,y]),L=C.useCallback(ue=>{const oe=ue.event.type==="some"?ue.event.value:void 0;if(i(o.filter(ve=>ve.key!==oe)),s){const ve=$("remove",{from:ue,to:$("trash",null)});queueMicrotask(()=>s(ve))}},[o,s]),R=C.useMemo(()=>x?ue=>queueMicrotask(()=>x(ue)):void 0,[x]),N=C.useMemo(()=>a?{id:t.id,sources:[...t.sources],kinds:{add:!0,move:!0,remove:!0},onDrag:S}:null,[a,t.id,t.sources,S]);sk(N);const O=C.useMemo(()=>{const ue=new Map;for(const oe of o){if(!a&&oe.state.type!=="committed")continue;const ve=N8e(oe.person,oe.day);ue.has(ve)||ue.set(ve,[]),ue.get(ve).push(oe)}return ue},[o,a]),j=_(t.summary),B=_(t.personWidth)??"150px",H=f!==void 0?` ${m6}`:"",K=`${B} repeat(${t.days.length}, minmax(${tOn}, 1fr))${H}`,U=`calc(${B} + ${t.days.length*KXe}px${H?` + ${m6}`:""})`,Z={gridTemplateColumns:K,minWidth:U},G=p.jsxs(V,{css:r.grid,style:Z,children:[p.jsx(V,{css:r.headerCell,children:t.personHeader}),t.days.map(ue=>p.jsx(V,{css:r.headerCell,children:ue},ue)),f!==void 0&&u!==void 0&&p.jsx(V,{css:g.decisionHeader,"data-slot":"decisionHeader",children:u.columnLabel})]}),W=ue=>{var oe;const ve=t.people[ue];if(ve===void 0)return null;const se=_(ve.sublabel),pe=f!==void 0?(oe=_(ve.status))==null?void 0:oe.type:void 0;return p.jsxs(V,{css:r.grid,style:Z,children:[p.jsxs(V,{css:r.personCell,children:[p.jsxs(V,{as:"span",css:r.personLabel,children:[pe!==void 0&&p.jsx(V,{as:"span",css:v[pe],"data-slot":"statusDot"}),ve.label]}),se&&p.jsx(V,{as:"span",css:r.personSublabel,children:se})]}),t.days.map(de=>p.jsx(oOn,{surface:t.id,person:ve.key,day:de,shifts:O.get(N8e(ve.key,de))??[],edit:a,styles:r,vetoFor:c,onSelect:z,onAccept:a?M:void 0,onRemove:a?L:void 0,onAddAt:R},`${ve.key}-${de}`)),f!==void 0&&p.jsx(V,{css:g.decisionCol,"data-slot":"decisionCol","data-status":pe,onClick:de=>de.stopPropagation(),children:p.jsx(SI,{rowIndex:ue,controller:f})})]})},J=j!==void 0||a?p.jsxs(V,{css:r.strip,children:[j!==void 0&&p.jsx(V,{as:"span",css:r.stripSummary,children:j}),a&&p.jsx(V,{as:"span",css:r.stripHint,children:"drag handles ⠿ · click empty cell to add · ✓ accept ghost · ⌫ remove"})]}):void 0,ae=Tt(_(t.height)),ne=Tt(_(t.maxHeight)),Y=f!==void 0&&f.showFoot,te=Y&&(ae!==void 0||ne!==void 0),ie=p.jsx(Dv,{height:te?void 0:ae,maxHeight:te?void 0:ne,fillParent:te,header:G,footer:J,count:t.people.length,estimateSize:()=>72,renderRow:W,rootCss:{...r.root}});return f!==void 0&&Y?p.jsxs(V,{display:"flex",flexDirection:"column",width:"100%",height:ae,maxHeight:ne,minHeight:"0",children:[ie,p.jsx(ik,{controller:f,storageKey:n})]}):ie},(e,t)=>eOn(e.value,t.value)&&e.storageKey===t.storageKey),sOn=it(kte.Types.Board),YXe=180,lOn=`${YXe}px`;function Jx(e,t,n,r){return{surface:e,row:t,slot:n,event:r!==void 0?P(r):A}}function cOn(e,t){return Sr(t.state,{committed:()=>e,rejected:()=>e,proposed:n=>Sr(n,{added:()=>`+${e}`,removed:()=>e,model:()=>`+${e}`})})}function Nie(e){return Sr(e.state,{committed:()=>"committed",rejected:()=>"rejected",proposed:t=>Sr(t,{added:()=>"added",removed:()=>"removed",model:()=>"model"})})}function uOn(e){const t=Nie(e);return t==="committed"||t==="added"}function dOn({surface:e,area:t,shift:n,assignment:r,label:a,edit:o,dragDisabled:i,styles:s,onSelect:l,onAccept:c,onRemove:u}){const d=Nie(r),f=d==="model",h=o&&!i&&(d==="added"||d==="removed"||d==="model"),g=C.useMemo(()=>({surface:e,row:t,slot:n,event:r.key}),[e,t,n,r.key]),v=C.useMemo(()=>p.jsx(V,{css:s.dragGhost,children:a}),[s.dragGhost,a]),b=CI(g,v,!h),y=C.useCallback(x=>{x.stopPropagation();const S=Jx(e,t,n,r.key);f&&c?c(S):l&&l(S)},[e,t,n,r.key,f,c,l]);return p.jsxs(V,{css:s.chip,"data-state":d,onPointerDown:b,onClick:y,...h&&b?{"data-draggable":""}:{},children:[h&&b&&p.jsx(V,{as:"span",css:s.chipGrip,"data-drag-grip":"",children:p.jsx(Ut,{icon:g5})}),cOn(a,r),f&&c&&p.jsx(V,{as:"button",css:s.chipAction,"aria-label":"Accept ghost assignment",onPointerDown:x=>x.stopPropagation(),onClick:x=>{x.stopPropagation(),c(Jx(e,t,n,r.key))},children:p.jsx(Ut,{icon:_$})}),h&&u&&p.jsx(V,{as:"button",css:s.chipAction,"data-danger":"","aria-label":"Remove assignment",onPointerDown:x=>x.stopPropagation(),onClick:x=>{x.stopPropagation(),u(Jx(e,t,n,r.key))},children:p.jsx(Ut,{icon:UC})})]})}function fOn({surface:e,area:t,shift:n,chips:r,required:a,maxVisible:o,edit:i,canDrop:s,styles:l,onSelect:c,onAccept:u,onRemove:d,onAddAt:f}){const h=C.useMemo(()=>({surface:e,row:t,slot:n}),[e,t,n]),g=lk(i?h:null,!1,s),[v,b]=C.useState(!1),y=r.filter(B=>uOn(B.assignment)).length,x=r.filter(B=>Nie(B.assignment)==="model").length,S=a!==void 0&&i?Math.max(0,a-y-x):0,z=a===void 0?void 0:y>a?"over":y===a?"ok":"under",M=o!==void 0&&r.length>o,L=M?r.slice(0,o):r,R=M?r.slice(o):[],N=C.useCallback(B=>{B.stopPropagation(),f&&f(Jx(e,t,n))},[f,e,t,n]),O=C.useCallback(()=>{i&&r.length===0&&S===0&&f&&f(Jx(e,t,n))},[i,r.length,S,f,e,t,n]),j=(B,H)=>p.jsx(dOn,{surface:e,area:t,shift:n,assignment:B.assignment,label:B.label,edit:i,...H!==void 0?{dragDisabled:H}:{},styles:l,onSelect:c,onAccept:u,onRemove:d},B.assignment.key);return p.jsxs(V,{ref:g,css:l.cell,onClick:O,...i&&r.length===0&&S===0&&f?{"data-addable":""}:{},children:[a!==void 0&&p.jsx(V,{css:l.coverage,children:p.jsxs(V,{as:"span",css:l.coverageCount,"data-tone":z,children:[y,"/",a]})}),L.map(B=>j(B)),M&&p.jsxs(nu,{open:v,onOpenChange:B=>b(B.open),positioning:{placement:"bottom-start"},lazyMount:!0,unmountOnExit:!0,children:[p.jsx(R6,{asChild:!0,children:p.jsxs(V,{as:"button",css:l.overflowChip,"aria-label":`${R.length} more assignments`,onClick:B=>B.stopPropagation(),children:["+",R.length]})}),p.jsx(go,{children:p.jsx(M4,{children:p.jsx(T4,{css:l.overflowContent,children:R.map(B=>j(B,!0))})})})]}),Array.from({length:S},(B,H)=>p.jsx(V,{as:"button",css:l.openSlot,"aria-label":"Open slot",onClick:N,children:"⊕"},`open-${H}`))]})}const pOn=C.memo(function({value:t,storageKey:n}){const r=en({key:"board"})(),a=t.mode.type==="edit",[o,i]=C.useState(()=>[...t.assignments]);C.useEffect(()=>{i([...t.assignments])},[t.assignments]);const[s,l]=C.useState(()=>new Map),c=C.useMemo(()=>_(t.onDrag),[t.onDrag]),u=C.useMemo(()=>_(t.canDrop),[t.canDrop]),d=kI(u),f=C.useMemo(()=>_(t.review),[t.review]),h=C.useMemo(()=>[],[]),g=ok(f,h),v=C.useMemo(()=>_(t.onSelect),[t.onSelect]),b=C.useMemo(()=>_(t.onAccept),[t.onAccept]),y=C.useMemo(()=>_(t.onAddAt),[t.onAddAt]),x=C.useMemo(()=>{const ye=new Map;for(const me of t.people)ye.set(me.key,me.label);return ye},[t.people]),S=C.useCallback(ye=>x.get(ye)??s.get(ye)??ye,[x,s]),z=C.useCallback((ye,me,Me,Te)=>o.some(Be=>Be.area===ye&&Be.shift===me&&Be.person===Me&&Be.key!==Te),[o]),M=C.useCallback(ye=>{if(ye.kind==="item")return{person:ye.from.key};const me=o.find(Me=>Me.key===ye.from.event);return me!==void 0?{person:me.person,excludeKey:me.key}:void 0},[o]),L=C.useCallback((ye,me)=>{const Me=d==null?void 0:d({surface:t.id,row:ye,slot:me});return Te=>{const Be=M(Te);return Be!==void 0&&z(ye,me,Be.person,Be.excludeKey)?!1:(Me==null?void 0:Me(Te))??!0}},[M,z,d,t.id]),R=C.useCallback((ye,me)=>{if(!((ye.type==="add"||ye.type==="move")&&!t7(u,ye))){if(ye.type==="add"){const{from:Me,into:Te}=ye.value;if(z(Te.row,Te.slot,Me.key))return;i([...o,{key:`local:${Me.library}:${Me.key}:${Te.row}:${Te.slot}:${o.length}`,person:Me.key,area:Te.row,shift:Te.slot,state:$("proposed",$("added",null))}]),(me==null?void 0:me.label)!==void 0&&!x.has(Me.key)&&l(Be=>new Map(Be).set(Me.key,me.label))}else if(ye.type==="move"){const{from:Me,to:Te}=ye.value,Be=Me.event.type==="some"?Me.event.value:void 0,ht=o.find(De=>De.key===Be);if(ht===void 0||z(Te.row,Te.slot,ht.person,ht.key))return;i(o.map(De=>De.key===Be?{...De,area:Te.row,shift:Te.slot}:De))}else if(ye.type==="remove"){const Me=ye.value.from.event.type==="some"?ye.value.from.event.value:void 0;i(o.filter(Te=>Te.key!==Me))}c&&queueMicrotask(()=>c(ye))}},[o,x,z,u,c]),N=C.useMemo(()=>v?ye=>queueMicrotask(()=>v(ye)):void 0,[v]),O=C.useCallback(ye=>{const me=ye.event.type==="some"?ye.event.value:void 0,Me=o.map(Te=>Te.key===me&&Te.state.type==="proposed"&&Te.state.value.type==="model"?{...Te,state:$("proposed",$("added",null))}:Te);i(Me),b&&queueMicrotask(()=>b(ye))},[o,b]),j=C.useCallback(ye=>{const me=ye.event.type==="some"?ye.event.value:void 0;if(i(o.filter(Me=>Me.key!==me)),c){const Me=$("remove",{from:ye,to:$("trash",null)});queueMicrotask(()=>c(Me))}},[o,c]),B=C.useMemo(()=>y?ye=>queueMicrotask(()=>y(ye)):void 0,[y]),H=C.useMemo(()=>a?{id:t.id,sources:[...t.sources],kinds:{add:!0,move:!0,remove:!0},onDrag:R}:null,[a,t.id,t.sources,R]);sk(H);const K=C.useMemo(()=>{const ye=new Map;for(const me of o){if(!a&&me.state.type!=="committed")continue;const Me=`${me.area} ${me.shift}`;ye.has(Me)||ye.set(Me,[]),ye.get(Me).push({assignment:me,label:S(me.person)})}return ye},[o,a,S]),U=C.useMemo(()=>{const ye=new Map,me=_(t.requirements);if(me!==void 0)for(const Me of me)ye.set(`${Me.area} ${Me.shift}`,Number(Me.required));return ye},[t.requirements]),Z=_(t.maxVisible),G=Z!==void 0?Number(Z):void 0,W=_(t.areaHeader),J=_(t.areaWidth)??"150px",ae=_(t.summary),ne=`${J} repeat(${t.shifts.length}, minmax(${lOn}, 1fr))`,Y=`calc(${J} + ${t.shifts.length*YXe}px)`,te={gridTemplateColumns:ne,minWidth:Y},ie=p.jsxs(V,{css:r.grid,style:te,children:[p.jsx(V,{css:r.headerCell,children:W}),t.shifts.map(ye=>{const me=_(ye.sublabel);return p.jsxs(V,{css:r.headerCell,children:[ye.label,me!==void 0&&p.jsx(V,{as:"span",css:r.headerSublabel,children:me})]},ye.key)})]}),ue=ye=>{const me=t.areas[ye];if(me===void 0)return null;const Me=_(me.sublabel);return p.jsxs(V,{css:r.grid,style:te,children:[p.jsxs(V,{css:r.areaCell,children:[p.jsx(V,{as:"span",css:r.areaLabel,children:me.label}),Me!==void 0&&p.jsx(V,{as:"span",css:r.areaSublabel,children:Me})]}),t.shifts.map(Te=>p.jsx(fOn,{surface:t.id,area:me.key,shift:Te.key,chips:K.get(`${me.key} ${Te.key}`)??[],required:U.get(`${me.key} ${Te.key}`),maxVisible:G,edit:a,canDrop:L(me.key,Te.key),styles:r,onSelect:N,onAccept:a?O:void 0,onRemove:a?j:void 0,onAddAt:B},`${me.key}-${Te.key}`))]})},oe=ae!==void 0?p.jsx(V,{css:r.strip,children:p.jsx(V,{as:"span",css:r.stripSummary,children:ae})}):void 0,ve=Tt(_(t.height)),se=Tt(_(t.maxHeight)),pe=g!==void 0&&g.showFoot,de=pe&&(ve!==void 0||se!==void 0),ge=p.jsx(Dv,{height:de?void 0:ve,maxHeight:de?void 0:se,fillParent:de,header:ie,footer:oe,count:t.areas.length,estimateSize:()=>80,renderRow:ue,rootCss:{...r.root}});return g!==void 0&&pe?p.jsxs(V,{display:"flex",flexDirection:"column",width:"100%",height:ve,maxHeight:se,minHeight:"0",children:[ge,p.jsx(ik,{controller:g,storageKey:n})]}):ge},(e,t)=>sOn(e.value,t.value)&&e.storageKey===t.storageKey),hOn=it($8.Types.Calendar),c8=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],$8e=8,I8e={comfortable:{H:46,gap:3,colLabel:54,colDay:"minmax(62px,1fr)",colTot:82,padX:18,padTop:18,padBottom:20},compact:{H:30,gap:2,colLabel:54,colDay:"minmax(46px,1fr)",colTot:78,padX:16,padTop:14,padBottom:16},condensed:{H:20,gap:2,colLabel:40,colDay:"34px",colTot:60,padX:16,padTop:12,padBottom:12}};function D8e(e,t){if(e.length===0)return null;switch(t){case"sum":return e.reduce((n,r)=>n+r,0);case"mean":return e.reduce((n,r)=>n+r,0)/e.length;case"min":return Math.min(...e);case"max":return Math.max(...e);case"count":return e.length;default:return null}}function HV(e){return Math.round(e).toLocaleString("en-US")}const gOn=C.memo(function({value:t}){var n;const r=al(),a=((n=_(t.density))==null?void 0:n.type)??r??"comfortable",o=I8e[a]??I8e.comfortable,i=en({key:"calendar"})({density:a}),s=N7(),l=C.useMemo(()=>_(t.plotGutter),[t.plotGutter]),c=(l?_(l.left):void 0)??(s==null?void 0:s.left),u=(l?_(l.right):void 0)??(s==null?void 0:s.right),d=c!==void 0||u!==void 0,f=t.values,h=d?void 0:_(t.totals),g=d?void 0:_(t.aggregateRow),v=d?void 0:_(t.footer),b=_(t.scale),y=b?_(b.ramp):void 0,x=b?Math.max(1,Number(b.steps)):$8e,S=y?y.length:$8e,z=C.useMemo(()=>_(t.onSelect),[t.onSelect]),M=C.useMemo(()=>_(t.onAction),[t.onAction]),L=d?void 0:_(t.actionLabel),R=_(t.domain),[N,O]=C.useState(null),[j,B]=C.useState(null),{weeks:H,cells:K,min:U,max:Z}=C.useMemo(()=>{const Dt=[],Et=new Map;let Gt=Number.POSITIVE_INFINITY,Ke=Number.NEGATIVE_INFINITY;for(const Se of t.cells)Dt.includes(Se.week)||Dt.push(Se.week),Et.set(`${Se.week} ${Se.day}`,Se),Se.value<Gt&&(Gt=Se.value),Se.value>Ke&&(Ke=Se.value);return R!==void 0&&(Gt=R.min,Ke=R.max),{weeks:Dt,cells:Et,min:Gt,max:Ke}},[t.cells,R]),G=C.useCallback(Dt=>{const Et=Z<=U?0:Math.max(0,Math.min(1,(Dt-U)/(Z-U))),Gt=x<=1?0:Math.max(0,Math.min(x-1,Math.round(Et*(x-1)))),Ke=x<=1?0:Math.max(0,Math.min(S-1,Math.round(Gt/(x-1)*(S-1)))),Se=y?y[Ke]:`var(--cal-r${Ke})`,Re=Ke>=Math.ceil(S/2)?"var(--cal-ink-hi)":"var(--cal-ink-lo)";return{bg:Se,fg:Re}},[U,Z,x,S,y]),W=v!==void 0||z!==void 0,J=C.useCallback((Dt,Et)=>{O({week:Dt,day:Et}),z&&queueMicrotask(()=>z({week:Dt,day:Et}))},[z]),ae=C.useCallback(()=>{N&&M&&queueMicrotask(()=>M(N))},[N,M]),ne=j??N,Y=Dt=>(ne==null?void 0:ne.day)===Dt,te=Dt=>(ne==null?void 0:ne.week)===Dt,ie=h?h.aggregate.type:void 0,ue=C.useMemo(()=>{if(ie===void 0)return{map:new Map,max:0};const Dt=new Map;let Et=0;for(const Gt of H){const Ke=[];for(const Re of c8){const qe=K.get(`${Gt} ${Re}`);qe&&Ke.push(qe.value)}const Se=D8e(Ke,ie);Dt.set(Gt,Se),Se!==null&&Se>Et&&(Et=Se)}return{map:Dt,max:Et}},[ie,H,K]),oe=g?g.aggregate.type:void 0,ve=C.useMemo(()=>{if(oe===void 0)return new Map;const Dt=new Map;for(const Et of c8){const Gt=[];for(const Ke of H){const Se=K.get(`${Ke} ${Et}`);Se&&Gt.push(Se.value)}Dt.set(Et,D8e(Gt,oe))}return Dt},[oe,H,K]),se=c??`${o.colLabel}px`,pe=u??"0px",de=d?`${se} repeat(${c8.length}, minmax(0, 1fr)) ${pe}`:`${o.colLabel}px repeat(${c8.length}, ${o.colDay})${h?` ${o.colTot}px`:""}`,ge=`${o.gap}px`,ye={display:"grid",gap:d?"0px":ge,...d?{paddingLeft:"0",paddingRight:"0"}:{paddingLeft:`${o.padX}px`,paddingRight:`${o.padX}px`}},me={...ye,paddingTop:ge},Me=d?{...i.cell,marginInline:`${o.gap/2}px`}:{...i.cell},Te=p.jsxs(V,{css:{...ye,paddingTop:`${o.padTop}px`},style:{gridTemplateColumns:de},children:[p.jsx(V,{}),c8.map(Dt=>p.jsx(V,{css:i.dayHeader,...Y(Dt)?{"data-active":""}:{},children:Dt.toUpperCase()},Dt)),h&&p.jsx(V,{css:i.totalsHeader,children:h.label}),d&&p.jsx(V,{"aria-hidden":"true"},"hdr-rpad")]}),Be=Dt=>{const Et=H[Dt];if(Et===void 0)return null;const Gt=h?ue.map.get(Et)??null:null,Ke=h&&Gt!==null&&ue.max>0?`${Math.max(10,Math.round(Gt/ue.max*100))}%`:"0%";return p.jsxs(V,{css:me,style:{gridTemplateColumns:de},children:[p.jsx(V,{css:i.weekLabel,...te(Et)?{"data-active":""}:{},children:Et}),c8.map(Se=>{const Re=K.get(`${Et} ${Se}`),qe=W&&(N==null?void 0:N.week)===Et&&N.day===Se,Ye=W&&(j==null?void 0:j.week)===Et&&j.day===Se,$e=Re!==void 0?G(Re.value):void 0;return p.jsx(V,{css:Me,height:`${o.H}px`,...Re===void 0?{"data-empty":""}:{},...!W&&Re!==void 0?{"data-static":""}:{},...qe?{"data-selected":""}:{},...Ye?{"data-hover":""}:{},...$e?{style:{background:$e.bg,color:$e.fg}}:{},onClick:W&&Re!==void 0?()=>J(Et,Se):void 0,onMouseEnter:W&&Re!==void 0?()=>B({week:Et,day:Se}):void 0,onMouseLeave:W&&Re!==void 0?()=>B(null):void 0,children:f?Re!==void 0?Re.text:"–":""},`${Et}-${Se}`)}),h&&p.jsxs(V,{css:i.totalsCell,children:[p.jsx(V,{as:"span",css:i.totalsValue,children:Gt!==null?HV(Gt):"·"}),h.bar&&p.jsx(V,{as:"span",css:i.totalsBar,children:p.jsx(V,{as:"span",css:i.totalsBarFill,style:{width:Ke}})})]}),d&&p.jsx(V,{"aria-hidden":"true"},`${Et}-rpad`)]})},ht=g?p.jsxs(V,{css:me,style:{gridTemplateColumns:de},children:[p.jsx(V,{css:i.meanLabel,children:g.label}),c8.map(Dt=>{const Et=ve.get(Dt)??null;return p.jsx(V,{css:i.meanCell,...Y(Dt)?{"data-active":""}:{},children:Et!==null?HV(Et):"·"},`mean-${Dt}`)}),h&&p.jsx(V,{css:i.meanPad})]}):null,De=N?K.get(`${N.week} ${N.day}`):void 0,Qe=De?_(De.compare):void 0,bt=De?_(De.summary):void 0,Ve=De!==void 0&&Qe!==void 0&&Qe!==0?Math.round((De.value/Qe-1)*100):void 0,ut=Ve===void 0?"flat":Ve>0?"up":Ve<0?"down":"flat",_t=Ve===void 0?"":`${Ve>0?"▲ +":Ve<0?"▼ ":"– "}${Math.abs(Ve)}%`,Ft=v!==void 0||L!==void 0,wt=v?_(v.legend):void 0,Lt=Ft?p.jsxs(V,{css:i.footer,paddingTop:"13px",paddingX:"2px",paddingBottom:"2px",children:[De!==void 0&&v!==void 0?p.jsxs(p.Fragment,{children:[p.jsx(V,{as:"span",css:i.footerLead,children:"Selected ·"}),p.jsxs(V,{as:"span",css:i.footerSel,children:[N.day," ",N.week]}),p.jsx(V,{as:"span",color:"border.strong",children:"·"}),p.jsxs(V,{as:"span",children:[v.valueLabel," ",p.jsx(V,{as:"span",css:i.footerValue,children:De.text})]}),Qe!==void 0&&p.jsxs(p.Fragment,{children:[p.jsx(V,{as:"span",color:"border.strong",children:"·"}),p.jsxs(V,{as:"span",children:[v.compareLabel," ",p.jsx(V,{as:"span",css:i.footerValue,children:HV(Qe)})]})]}),bt!==void 0&&p.jsxs(p.Fragment,{children:[p.jsx(V,{as:"span",color:"border.strong",children:"·"}),p.jsx(V,{as:"span",children:bt})]}),Ve!==void 0&&p.jsx(V,{as:"span",css:i.deltaChip,"data-dir":ut,children:_t})]}):p.jsx(V,{as:"span",css:i.footerLead,children:"Selected · none — pick a day"}),L!==void 0&&p.jsxs(V,{as:"button",css:i.action,marginLeft:wt!==void 0?void 0:"auto",onClick:ae,...N===null?{"data-disabled":""}:{},children:[L," →"]}),wt!==void 0&&p.jsxs(V,{as:"span",css:i.legend,children:[p.jsx(V,{as:"span",css:i.legendCap,children:wt.low}),p.jsx(V,{as:"span",css:i.legendGradient}),p.jsx(V,{as:"span",css:i.legendCap,children:wt.high})]})]}):void 0,Jt=ht!==null||Lt!==void 0?p.jsxs(p.Fragment,{children:[ht,Lt]}):void 0;return p.jsx(Dv,{height:Tt(_(t.height)),maxHeight:Tt(_(t.maxHeight)),header:Te,footer:Jt,count:H.length,estimateSize:()=>o.H+o.gap,renderRow:Be,rootCss:{...i.root,paddingBottom:`${o.padBottom}px`,...d?{display:"block",width:"100%"}:{}}})},(e,t)=>hOn(e.value,t.value)&&e.storageKey===t.storageKey);function XXe(e,t,n=0,r=e.length-1,a=mOn){for(;r>n;){if(r-n>600){const l=r-n+1,c=t-n+1,u=Math.log(l),d=.5*Math.exp(2*u/3),f=.5*Math.sqrt(u*d*(l-d)/l)*(c-l/2<0?-1:1),h=Math.max(n,Math.floor(t-c*d/l+f)),g=Math.min(r,Math.floor(t+(l-c)*d/l+f));XXe(e,t,h,g,a)}const o=e[t];let i=n,s=r;for(xb(e,n,t),a(e[r],o)>0&&xb(e,n,r);i<s;){for(xb(e,i,s),i++,s--;a(e[i],o)<0;)i++;for(;a(e[s],o)>0;)s--}a(e[n],o)===0?xb(e,n,s):(s++,xb(e,s,r)),s<=t&&(n=s+1),t<=s&&(r=s-1)}}function xb(e,t,n){const r=e[t];e[t]=e[n],e[n]=r}function mOn(e,t){return e<t?-1:e>t?1:0}class ZXe{constructor(t=9){this._maxEntries=Math.max(4,t),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(t){let n=this.data;const r=[];if(!uT(t,n))return r;const a=this.toBBox,o=[];for(;n;){for(let i=0;i<n.children.length;i++){const s=n.children[i],l=n.leaf?a(s):s;uT(t,l)&&(n.leaf?r.push(s):UV(t,l)?this._all(s,r):o.push(s))}n=o.pop()}return r}collides(t){let n=this.data;if(!uT(t,n))return!1;const r=[];for(;n;){for(let a=0;a<n.children.length;a++){const o=n.children[a],i=n.leaf?this.toBBox(o):o;if(uT(t,i)){if(n.leaf||UV(t,i))return!0;r.push(o)}}n=r.pop()}return!1}load(t){if(!(t&&t.length))return this;if(t.length<this._minEntries){for(let r=0;r<t.length;r++)this.insert(t[r]);return this}let n=this._build(t.slice(),0,t.length-1,0);if(!this.data.children.length)this.data=n;else if(this.data.height===n.height)this._splitRoot(this.data,n);else{if(this.data.height<n.height){const r=this.data;this.data=n,n=r}this._insert(n,this.data.height-n.height-1,!0)}return this}insert(t){return t&&this._insert(t,this.data.height-1),this}clear(){return this.data=Rg([]),this}remove(t,n){if(!t)return this;let r=this.data;const a=this.toBBox(t),o=[],i=[];let s,l,c;for(;r||o.length;){if(r||(r=o.pop(),l=o[o.length-1],s=i.pop(),c=!0),r.leaf){const u=vOn(t,r.children,n);if(u!==-1)return r.children.splice(u,1),o.push(r),this._condense(o),this}!c&&!r.leaf&&UV(r,a)?(o.push(r),i.push(s),s=0,l=r,r=r.children[0]):l?(s++,r=l.children[s],c=!1):r=null}return this}toBBox(t){return t}compareMinX(t,n){return t.minX-n.minX}compareMinY(t,n){return t.minY-n.minY}toJSON(){return this.data}fromJSON(t){return this.data=t,this}_all(t,n){const r=[];for(;t;)t.leaf?n.push(...t.children):r.push(...t.children),t=r.pop();return n}_build(t,n,r,a){const o=r-n+1;let i=this._maxEntries,s;if(o<=i)return s=Rg(t.slice(n,r+1)),Kh(s,this.toBBox),s;a||(a=Math.ceil(Math.log(o)/Math.log(i)),i=Math.ceil(o/Math.pow(i,a-1))),s=Rg([]),s.leaf=!1,s.height=a;const l=Math.ceil(o/i),c=l*Math.ceil(Math.sqrt(i));O8e(t,n,r,c,this.compareMinX);for(let u=n;u<=r;u+=c){const d=Math.min(u+c-1,r);O8e(t,u,d,l,this.compareMinY);for(let f=u;f<=d;f+=l){const h=Math.min(f+l-1,d);s.children.push(this._build(t,f,h,a-1))}}return Kh(s,this.toBBox),s}_chooseSubtree(t,n,r,a){for(;a.push(n),!(n.leaf||a.length-1===r);){let o=1/0,i=1/0,s;for(let l=0;l<n.children.length;l++){const c=n.children[l],u=WV(c),d=xOn(t,c)-u;d<i?(i=d,o=u<o?u:o,s=c):d===i&&u<o&&(o=u,s=c)}n=s||n.children[0]}return n}_insert(t,n,r){const a=r?t:this.toBBox(t),o=[],i=this._chooseSubtree(a,this.data,n,o);for(i.children.push(t),hx(i,a);n>=0&&o[n].children.length>this._maxEntries;)this._split(o,n),n--;this._adjustParentBBoxes(a,o,n)}_split(t,n){const r=t[n],a=r.children.length,o=this._minEntries;this._chooseSplitAxis(r,o,a);const i=this._chooseSplitIndex(r,o,a),s=Rg(r.children.splice(i,r.children.length-i));s.height=r.height,s.leaf=r.leaf,Kh(r,this.toBBox),Kh(s,this.toBBox),n?t[n-1].children.push(s):this._splitRoot(r,s)}_splitRoot(t,n){this.data=Rg([t,n]),this.data.height=t.height+1,this.data.leaf=!1,Kh(this.data,this.toBBox)}_chooseSplitIndex(t,n,r){let a,o=1/0,i=1/0;for(let s=n;s<=r-n;s++){const l=px(t,0,s,this.toBBox),c=px(t,s,r,this.toBBox),u=wOn(l,c),d=WV(l)+WV(c);u<o?(o=u,a=s,i=d<i?d:i):u===o&&d<i&&(i=d,a=s)}return a||r-n}_chooseSplitAxis(t,n,r){const a=t.leaf?this.compareMinX:yOn,o=t.leaf?this.compareMinY:bOn,i=this._allDistMargin(t,n,r,a),s=this._allDistMargin(t,n,r,o);i<s&&t.children.sort(a)}_allDistMargin(t,n,r,a){t.children.sort(a);const o=this.toBBox,i=px(t,0,n,o),s=px(t,r-n,r,o);let l=cT(i)+cT(s);for(let c=n;c<r-n;c++){const u=t.children[c];hx(i,t.leaf?o(u):u),l+=cT(i)}for(let c=r-n-1;c>=n;c--){const u=t.children[c];hx(s,t.leaf?o(u):u),l+=cT(s)}return l}_adjustParentBBoxes(t,n,r){for(let a=r;a>=0;a--)hx(n[a],t)}_condense(t){for(let n=t.length-1,r;n>=0;n--)t[n].children.length===0?n>0?(r=t[n-1].children,r.splice(r.indexOf(t[n]),1)):this.clear():Kh(t[n],this.toBBox)}}function vOn(e,t,n){if(!n)return t.indexOf(e);for(let r=0;r<t.length;r++)if(n(e,t[r]))return r;return-1}function Kh(e,t){px(e,0,e.children.length,t,e)}function px(e,t,n,r,a){a||(a=Rg(null)),a.minX=1/0,a.minY=1/0,a.maxX=-1/0,a.maxY=-1/0;for(let o=t;o<n;o++){const i=e.children[o];hx(a,e.leaf?r(i):i)}return a}function hx(e,t){return e.minX=Math.min(e.minX,t.minX),e.minY=Math.min(e.minY,t.minY),e.maxX=Math.max(e.maxX,t.maxX),e.maxY=Math.max(e.maxY,t.maxY),e}function yOn(e,t){return e.minX-t.minX}function bOn(e,t){return e.minY-t.minY}function WV(e){return(e.maxX-e.minX)*(e.maxY-e.minY)}function cT(e){return e.maxX-e.minX+(e.maxY-e.minY)}function xOn(e,t){return(Math.max(t.maxX,e.maxX)-Math.min(t.minX,e.minX))*(Math.max(t.maxY,e.maxY)-Math.min(t.minY,e.minY))}function wOn(e,t){const n=Math.max(e.minX,t.minX),r=Math.max(e.minY,t.minY),a=Math.min(e.maxX,t.maxX),o=Math.min(e.maxY,t.maxY);return Math.max(0,a-n)*Math.max(0,o-r)}function UV(e,t){return e.minX<=t.minX&&e.minY<=t.minY&&t.maxX<=e.maxX&&t.maxY<=e.maxY}function uT(e,t){return t.minX<=e.maxX&&t.minY<=e.maxY&&t.maxX>=e.minX&&t.maxY>=e.minY}function Rg(e){return{children:e,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function O8e(e,t,n,r,a){const o=[t,n];for(;o.length;){if(n=o.pop(),t=o.pop(),n-t<=r)continue;const i=t+Math.ceil((n-t)/r/2)*r;XXe(e,i,t,n,a),o.push(t,i,i,n)}}const YE={zoom:1,tx:0,ty:0};function SOn(e,t,n){return{sx:e*n.ppu+n.tx,sy:t*n.ppu+n.ty}}function COn(e,t){return`translate(calc(var(--cam-ppu) * ${e} * 1px + var(--cam-tx)), calc(var(--cam-ppu) * ${t} * 1px + var(--cam-ty)))`}function kOn(e){return`calc(var(--cam-ppu) * ${e} * 1px)`}function QXe(e,t,n){return{minX:-e.tx/e.ppu,minY:-e.ty/e.ppu,maxX:(t-e.tx)/e.ppu,maxY:(n-e.ty)/e.ppu}}function qV(e,t){return e.maxX>=t.minX&&e.minX<=t.maxX&&e.maxY>=t.minY&&e.minY<=t.maxY}function rX(e){if(e.length===0)return null;let t=1/0,n=1/0,r=-1/0,a=-1/0;for(const o of e)o.x<t&&(t=o.x),o.y<n&&(n=o.y),o.x>r&&(r=o.x),o.y>a&&(a=o.y);return{minX:t,minY:n,maxX:r,maxY:a}}function GV(e,t,n,r,a,o){const i=Math.max(a,Math.min(o,e.zoom*t));if(i===1)return YE;const s=i/e.zoom;return{zoom:i,tx:n-s*(n-e.tx),ty:r-s*(r-e.ty)}}function zOn(e,t){switch(t){case"pointerDown":return"panning";case"wheel":return"wheeling";case"zoom":return"wheeling";case"flyStart":return"flying";case"pointerUp":return e==="panning"?"idle":e;case"flyEnd":return e==="flying"?"idle":e;case"cancel":return"idle"}}function MOn(e,t){return e==="flying"&&(t==="pointerDown"||t==="wheel"||t==="zoom"||t==="cancel")}function TOn(e,t){let n=null;return{request(r){n===null&&(n=e(()=>{n=null,r()}))},cancel(){n!==null&&(t(n),n=null)}}}const ba=(e,t=1)=>t>=1?`rgb(${e[0]},${e[1]},${e[2]})`:`rgba(${e[0]},${e[1]},${e[2]},${t})`;function XE(e,t,n){switch(t){case"brand":return e.brand600;case"ink":return e.fg;case"muted":return n==="zone"?e.borderStrong:e.fgMuted;case"success":return e.statusOk;case"warning":return e.statusWarn;case"danger":return e.statusBad;default:return e.fgMuted}}function j8e(e,t){switch(t){case"success":return e.statusOk;case"warning":return e.statusWarn;case"danger":return e.statusBad;case"info":return e.brand500;default:return e.fgMuted}}function F8e(e){return e.type==="some"?e.value.type:void 0}function KV(e,t,n,r,a){return t!==void 0?t:ba(n!==void 0?XE(e,n,a):r)}function O8(e){const t=[];for(const n of e){const r=t[t.length-1];r!==void 0&&r.x!==n.x&&r.y!==n.y&&t.push(Math.abs(n.y-r.y)>=Math.abs(n.x-r.x)?{x:r.x,y:n.y}:{x:n.x,y:r.y}),(r===void 0||r.x!==n.x||r.y!==n.y)&&t.push(n)}return t}function Yl(e,t,n){if(t.length===0)return;e.moveTo(t[0].x,t[0].y);for(let a=1;a<t.length-1;a++){const o=t[a],i=t[a-1],s=t[a+1],l=Math.hypot(o.x-i.x,o.y-i.y),c=Math.hypot(s.x-o.x,s.y-o.y),u=Math.min(n,l/2,c/2);if(u<.5){e.lineTo(o.x,o.y);continue}const d={x:(o.x-i.x)/l,y:(o.y-i.y)/l};e.lineTo(o.x-d.x*u,o.y-d.y*u),e.quadraticCurveTo(o.x,o.y,o.x+(s.x-o.x)/c*u,o.y+(s.y-o.y)/c*u)}const r=t[t.length-1];t.length>1&&e.lineTo(r.x,r.y)}function EOn(e,t,n){const r=t.x-e.x,a=t.y-e.y,o=Math.hypot(r,a);if(Math.abs(n)<1e-4||o<1e-9)return null;const i=4*Math.atan(n),s=Math.abs(o/(2*Math.sin(i/2))),l=(e.x+t.x)/2,c=(e.y+t.y)/2,u=o/2/Math.tan(i/2),d=l-a/o*u,f=c+r/o*u;return!Number.isFinite(s)||!Number.isFinite(u)||!Number.isFinite(d)||!Number.isFinite(f)?null:{cx:d,cy:f,radius:s,startAngle:Math.atan2(e.y-f,e.x-d),endAngle:Math.atan2(t.y-f,t.x-d),anticlockwise:i<0}}function B8e(e,t,n,r){const a=EOn(t,n,r);if(a===null){e.lineTo(n.x,n.y);return}e.arc(a.cx,a.cy,a.radius,a.startAngle,a.endAngle,a.anticlockwise)}function wb(e,t,n){if(t.length!==0){e.moveTo(t[0].x,t[0].y);for(let r=1;r<t.length;r++)B8e(e,t[r-1],t[r],t[r-1].bulge);if(n){const r=t[t.length-1];B8e(e,r,t[0],r.bulge),e.closePath()}}}const $ie='600 10px ui-monospace, "SF Mono", Menlo, monospace',_On=5,LOn=10,gR=6,ZE=7,JXe=4,V8e=16;function eZe(e,t,n,r){const{sx:a,sy:o}=SOn(e.x,e.y,n);if(t==="dot")return{kind:"circle",cx:a,cy:o,r:LOn};const i=r(e.label),s=gR+ZE+JXe+i+gR;return{kind:"rect",left:a-s/2,top:o-V8e/2,w:s,h:V8e}}function ROn(e,t,n){return e.kind==="circle"?Math.hypot(t-e.cx,n-e.cy)<=e.r:t>=e.left&&t<=e.left+e.w&&n>=e.top&&n<=e.top+e.h}const YV=5;function XV(e,t,n){let r=1/0;for(let a=1;a<e.length;a++){const o=e[a-1],i=e[a],s=i.x-o.x,l=i.y-o.y,c=s*s+l*l,u=c>0?Math.max(0,Math.min(1,((t-o.x)*s+(n-o.y)*l)/c)):0,d=Math.hypot(t-(o.x+u*s),n-(o.y+u*l));d<r&&(r=d)}return r}const H8e=16,tZe=7;function POn(e){if(e.length===0)return{x:0,y:0};let t=0;for(let a=1;a<e.length;a++)t+=Math.hypot(e[a].x-e[a-1].x,e[a].y-e[a-1].y);if(t<=1e-9)return e[0];let n=0;const r=t/2;for(let a=1;a<e.length;a++){const o=Math.hypot(e[a].x-e[a-1].x,e[a].y-e[a-1].y);if(n+o>=r){const i=o>0?(r-n)/o:0;return{x:e[a-1].x+(e[a].x-e[a-1].x)*i,y:e[a-1].y+(e[a].y-e[a-1].y)*i}}n+=o}return e[e.length-1]}function nZe(e,t){const n=new Map;for(const a of e){if(!t(a))continue;const o=a.from<a.to?`${a.from}\0${a.to}`:`${a.to}\0${a.from}`,i=n.get(o);i!==void 0?i.push(a.key):n.set(o,[a.key])}const r=new Map;for(const a of n.values())a.length<2||(a.sort(),a.forEach((o,i)=>r.set(o,{i,n:a.length})));return r}function AOn(e){return Number.isFinite(e)?Math.max(1,e):1}function NOn(e,t,n,r,a,o,i,s,l,c){const u=-s,d=i;if(Math.abs(u)<=1e-6)return{oStart:-l,oEnd:l};const f=Math.max(e,0),h=Math.max(t,0),g=Math.min(e+n,a),v=Math.min(t+r,o),b=[f*u+h*d,g*u+h*d,f*u+v*d,g*u+v*d],y=z=>(z-e*u-(t-l*s)*d)/u,x=y(Math.min(...b)),S=y(Math.max(...b));return{oStart:Math.max(-l,-l+Math.floor((Math.min(x,S)+l)/c)*c-c),oEnd:Math.min(l,Math.max(x,S)+c)}}function $On(e,t){const n={minX:e.x,minY:e.y,maxX:e.x+e.width,maxY:e.y+e.height};if(t!==void 0&&t.type==="circle"){const r=e.x+e.width/2,a=e.y+e.height/2,o=t.value.radius;n.minX=Math.min(n.minX,r-o),n.minY=Math.min(n.minY,a-o),n.maxX=Math.max(n.maxX,r+o),n.maxY=Math.max(n.maxY,a+o)}else if(t!==void 0&&t.type!=="rect"){const r=rX(t.value.vertices);r!==null&&(n.minX=Math.min(n.minX,r.minX),n.minY=Math.min(n.minY,r.minY),n.maxX=Math.max(n.maxX,r.maxX),n.maxY=Math.max(n.maxY,r.maxY))}return n}function W8e(e,t){const n={x:e.reduce((L,R)=>L+R.x,0)/e.length,y:e.reduce((L,R)=>L+R.y,0)/e.length};if(e.length===1)return{anchor:e[0],stubs:[],taps:[]};const r=Math.min(...e.map(L=>L.x)),a=Math.max(...e.map(L=>L.x)),o=Math.min(...e.map(L=>L.y)),i=Math.max(...e.map(L=>L.y)),s=i-o>=a-r,l=L=>s?L.y:L.x,c=L=>s?L.x:L.y,u=(L,R)=>s?{x:R,y:L}:{x:L,y:R},d=s?o:r,f=s?i:a;if(f-d<1e-6)return{anchor:n,stubs:[],taps:[]};const h=Math.sign(c(t)-c(n))||1,g=h>0?Math.max(...e.map(c)):Math.min(...e.map(c)),v=Math.abs(c(t)-g),b=g+h*Math.min(Math.max(v*.3,.9),3),y=u(Math.min(Math.max(l(t),d),f),b),x=e.map(L=>[L,u(l(L),b)]),S=L=>L-d<1e-6||f-L<1e-6,z=[],M=L=>{S(l(L))||z.some(R=>Math.abs(R.x-L.x)<1e-6&&Math.abs(R.y-L.y)<1e-6)||z.push(L)};for(const L of x)M(L[1]);return M(y),{anchor:y,bar:[u(d,b),u(f,b)],stubs:x,taps:z}}function aX(e,t,n){const r=c=>({x:c.reduce((u,d)=>u+d.x,0)/c.length,y:c.reduce((u,d)=>u+d.y,0)/c.length}),a=n.length>0?n[0]:r(t),o=n.length>0?n[n.length-1]:r(e),i=W8e(e,a),s=W8e(t,o),l=[];return i.bar&&l.push(i.bar),s.bar&&l.push(s.bar),{trunk:[i.anchor,...n,s.anchor],bars:l,stubs:[...i.stubs,...s.stubs],taps:[...i.taps,...s.taps]}}function U8e(e,t,n,r,a){var o;if(r===void 0&&a===void 0)return;const i=POn(n);e.save(),e.font=$ie;const s=r??"",l=a!==void 0?r!==void 0?` · ${a}`:a:"",c=s!==""?e.measureText(s).width:0,u=l!==""?e.measureText(l).width:0,d=c+u+12,f=16,h=i.x-d/2,g=i.y-f/2;e.beginPath(),(o=e.roundRect)==null||o.call(e,h,g,d,f,f/2),e.roundRect||e.rect(h,g,d,f),e.fillStyle=ba(t.bgSurface),e.fill(),e.lineWidth=1,e.strokeStyle=ba(t.borderSubtle),e.stroke(),e.textBaseline="middle",s!==""&&(e.fillStyle=ba(t.fg),e.fillText(s,h+6,i.y)),l!==""&&(e.fillStyle=ba(t.fgMuted),e.fillText(l,h+6+c,i.y)),e.restore()}function IOn(e){var t,n,r,a;const{ctx:o,value:i,cam:s,width:l,height:c,visibleItems:u,tiers:d,selected:f,selectedZones:h,centers:g,palette:v,effect:b,layerHiddenKeys:y,layerAlpha:x,draftLink:S,session:z,connectFlash:M,selectedLink:L}=e,R=W=>W*s.ppu+s.tx,N=W=>W*s.ppu+s.ty,O=s.ppu,j=W=>(b==null?void 0:b.excluded.has(W))??!1,B=W=>(y==null?void 0:y.has(W))??!1,H=W=>(b!==void 0&&j(W)?b.excludedOpacity:1)*((x==null?void 0:x.get(W))??1),K=W=>b!==void 0&&j(W)&&b.excludedDesaturate,U=QXe(s,l,c);o.save(),o.setTransform(1,0,0,1,0,0),o.clearRect(0,0,o.canvas.width,o.canvas.height),o.restore(),o.lineJoin="round";for(const W of i.zones){if(B(W.key))continue;const J=_(W.geometry);if(!qV($On(W,J),U))continue;const ae=W.pattern,ne=(ae.value.tone.type==="some"?ae.value.tone.value.type:void 0)??"muted",Y=KV(v,_(W.color),(t=_(W.tone))==null?void 0:t.type,XE(v,ne,"zone"),"zone"),te=_(W.bg),ie=_(W.fillOpacity)??.15,ue=_(W.weight),oe=R(W.x),ve=N(W.y),se=W.width*O,pe=W.height*O,de=()=>{te!==void 0&&(o.save(),o.globalAlpha=ie,o.fillStyle=te,o.fill(),o.restore())};if(J!==void 0&&J.type!=="rect")if(J.type==="circle")o.beginPath(),o.arc(oe+se/2,ve+pe/2,J.value.radius*O,0,Math.PI*2),de(),o.setLineDash([4,3]),o.lineWidth=ue??1,o.strokeStyle=Y,o.stroke(),o.setLineDash([]);else{const ge=J.value.vertices.map(ye=>({x:R(ye.x),y:N(ye.y),bulge:ye.bulge}));if(ge.length>0)if(o.beginPath(),J.type==="polygon")wb(o,ge,!0),de(),o.setLineDash([4,3]),o.lineWidth=ue??1,o.strokeStyle=Y,o.stroke(),o.setLineDash([]);else{wb(o,ge,!1);const ye=J.value.width.type==="some"?J.value.width.value*O:void 0;o.setLineDash([]),o.lineCap="round",o.lineWidth=ue??ye??1.5,o.save(),o.globalAlpha=.55,o.strokeStyle=Y,o.stroke(),o.restore(),o.lineCap="butt"}}else if(ae.type==="hatch"){const ge=AOn(_(ae.value.spacing)??8),ye=(_(ae.value.angle)??45)*Math.PI/180;o.save(),o.beginPath(),o.rect(oe,ve,se,pe),o.clip(),te!==void 0&&(o.save(),o.globalAlpha=ie,o.fillStyle=te,o.fillRect(oe,ve,se,pe),o.restore()),o.globalAlpha=.3,o.strokeStyle=Y,o.lineWidth=ue??1;const me=Math.cos(ye),Me=Math.sin(ye),Te=Math.hypot(se,pe),{oStart:Be,oEnd:ht}=NOn(oe,ve,se,pe,l,c,me,Me,Te,ge);o.beginPath();for(let De=Be;De<ht;De+=ge)o.moveTo(oe+De,ve-Te*Me),o.lineTo(oe+De+me*2*Te,ve-Te*Me+Me*2*Te);o.stroke(),o.restore()}else te!==void 0&&(o.save(),o.globalAlpha=ie,o.fillStyle=te,o.fillRect(oe,ve,se,pe),o.restore()),o.setLineDash([5,4]),o.lineWidth=ue??1,o.strokeStyle=Y,o.strokeRect(oe,ve,se,pe),o.setLineDash([]);if(((h==null?void 0:h.has(W.key))??!1)&&(o.save(),o.beginPath(),J!==void 0&&J.type==="circle"?o.arc(oe+se/2,ve+pe/2,J.value.radius*O,0,Math.PI*2):J!==void 0&&J.type==="polygon"?wb(o,J.value.vertices.map(ge=>({x:R(ge.x),y:N(ge.y),bulge:ge.bulge})),!0):o.rect(oe,ve,se,pe),o.globalAlpha=.06,o.fillStyle=ba(v.brand500),o.fill(),o.globalAlpha=1,o.setLineDash([]),o.lineWidth=2,o.strokeStyle=ba(v.brand600),o.stroke(),o.restore()),se>=W.label.length*6.2+24){o.font='600 9px ui-monospace, "SF Mono", Menlo, monospace';const ge=W.label.toUpperCase(),ye=o.measureText(ge).width;o.fillStyle=ba(v.bgPanel),o.fillRect(oe+6,ve-7,ye+6,12),o.fillStyle=ba(v.fgMuted),o.textBaseline="middle",o.fillText(ge,oe+9,ve)}}const Z=nZe(i.links,W=>!B(W.key)&&g.has(W.from)&&g.has(W.to)&&W.via.length===0);for(const W of i.links){if(B(W.key))continue;const J=g.get(W.from),ae=g.get(W.to);if(!J||!ae)continue;const ne=rX([J,...W.via,ae]);if(ne!==null&&!qV(ne,U))continue;const Y=[J,...W.via,ae].map(de=>({x:R(de.x),y:N(de.y)})),te=Z.get(W.key);if(te!==void 0){const de=Y[0],ge=Y[Y.length-1],ye=Math.hypot(ge.x-de.x,ge.y-de.y);if(ye>1e-6){const me=(te.i-(te.n-1)/2)*tZe,Me=-(ge.y-de.y)/ye*me,Te=(ge.x-de.x)/ye*me;for(const Be of Y)Be.x+=Me,Be.y+=Te}}const ie=W.route.type==="orthogonal"?W.route.value.corner.type==="some"?W.route.value.corner.value:8:0,ue=W.route.type==="orthogonal"?O8(Y):Y,oe=W.style,ve=(oe.value.tone.type==="some"?oe.value.tone.value.type:void 0)??(oe.type==="solid"?"brand":"muted"),se=oe.value.weight.type==="some"?oe.value.weight.value:oe.type==="solid"?2.5:1.5,pe=XE(v,ve,"link");if(o.lineCap="round",o.strokeStyle=ba(pe),o.lineWidth=se,o.setLineDash(oe.type==="dashed"?[6,5]:[]),o.beginPath(),Yl(o,ue,ie),o.stroke(),o.setLineDash([]),L!==void 0&&L.key===W.key){if(o.save(),o.lineWidth=se+4,o.strokeStyle=ba(v.brand600,.25),o.beginPath(),Yl(o,ue,ie),o.stroke(),L.editable)for(const de of[ue[0],ue[ue.length-1]])o.beginPath(),o.arc(de.x,de.y,5,0,Math.PI*2),o.fillStyle=ba(v.bgSurface),o.fill(),o.lineWidth=2,o.strokeStyle=ba(v.brand600),o.stroke();o.restore()}o.fillStyle=ba(pe);for(const de of[Y[0],Y[Y.length-1]])o.beginPath(),o.arc(de.x,de.y,se+1.5,0,Math.PI*2),o.fill();O>=H8e&&U8e(o,v,ue,_(W.label),_(W.metric)),o.lineCap="butt"}for(const W of i.nets){if(B(W.key))continue;const J=W.sources.filter(Te=>g.has(Te)),ae=W.destinations.filter(Te=>g.has(Te)),ne=J.map(Te=>g.get(Te)),Y=ae.map(Te=>g.get(Te));if(ne.length===0||Y.length===0)continue;const te=rX([...ne,...W.via,...Y]);if(te!==null&&!qV(te,U))continue;const ie=W.style,ue=(ie.value.tone.type==="some"?ie.value.tone.value.type:void 0)??(ie.type==="solid"?"brand":"muted"),oe=ie.value.weight.type==="some"?ie.value.weight.value:ie.type==="solid"?2.5:1.5,ve=W.route.type==="orthogonal"?W.route.value.corner.type==="some"?W.route.value.corner.value:8:0,se=XE(v,ue,"link"),pe=Te=>({x:R(Te.x),y:N(Te.y)}),de=Te=>{const Be=Te.map(pe);return W.route.type==="orthogonal"?O8(Be):Be},ge=L!==void 0&&L.key===W.key,ye=aX(ne,Y,W.via);o.save(),o.lineCap="round",o.setLineDash(ie.type==="dashed"?[6,5]:[]);const me=de(ye.trunk);o.strokeStyle=ba(se),o.lineWidth=oe+1,o.beginPath(),Yl(o,me,ve),o.stroke();for(const Te of ye.bars)o.beginPath(),Yl(o,Te.map(pe),0),o.stroke();o.lineWidth=oe;for(const Te of ye.stubs)o.beginPath(),Yl(o,Te.map(pe),ve),o.stroke();o.setLineDash([]),o.fillStyle=ba(se);for(const Te of ye.taps.map(pe))o.beginPath(),o.arc(Te.x,Te.y,oe+1.5,0,Math.PI*2),o.fill();const Me=ge?L==null?void 0:L.leg:void 0;if(ge&&Me===void 0){o.lineWidth=oe+5,o.strokeStyle=ba(v.brand600,.25),o.beginPath(),Yl(o,me,ve),o.stroke();for(const Te of ye.bars)o.beginPath(),Yl(o,Te.map(pe),0),o.stroke()}else if(Me!==void 0){const Te=Me.end==="source"?J.indexOf(Me.item):ae.indexOf(Me.item),Be=Te>=0?ye.stubs[Me.end==="source"?Te:J.length+Te]:void 0;Be!==void 0&&(o.lineWidth=oe+5,o.strokeStyle=ba(v.brand600,.35),o.beginPath(),Yl(o,Be.map(pe),ve),o.stroke())}O>=H8e&&U8e(o,v,me,_(W.label),_(W.metric)),o.lineCap="butt",o.restore()}const G=(W,J)=>O8([{x:R(W.x),y:N(W.y)},{x:R(J.x),y:N(J.y)}]);if(z!==void 0){if(o.save(),o.lineCap="round",o.setLineDash([6,5]),o.lineWidth=2,o.strokeStyle=ba(v.brand500,.75),z.kind==="edge")o.beginPath(),Yl(o,G(z.from,z.to),8),o.stroke();else{const W=aX(z.sources,z.destinations,[]),J=ae=>({x:R(ae.x),y:N(ae.y)});o.beginPath(),Yl(o,O8(W.trunk.map(J)),8),o.stroke();for(const ae of W.bars)o.beginPath(),Yl(o,ae.map(J),0),o.stroke();for(const ae of W.stubs)o.beginPath(),Yl(o,O8(ae.map(J)),8),o.stroke()}o.restore()}if(S!==void 0){const W=S.forbiddenKey!==void 0,J=W?v.statusBad:v.brand600,ae=G(S.from,S.to);o.save(),o.lineCap="round",o.setLineDash([6,5]),o.lineWidth=2.5,o.strokeStyle=ba(J,S.snapped?1:W?.85:.65),o.beginPath(),Yl(o,ae,8),o.stroke();const ne=ae[0],Y=ae[ae.length-1];if(o.setLineDash([]),o.beginPath(),o.arc(ne.x,ne.y,4,0,Math.PI*2),o.fillStyle=ba(J),o.fill(),o.beginPath(),o.arc(Y.x,Y.y,S.snapped?9:6,0,Math.PI*2),o.lineWidth=2,o.strokeStyle=ba(J,S.snapped?1:W?.85:.5),o.stroke(),W){const te=g.get(S.forbiddenKey),ie=d.get(S.forbiddenKey)??"dot";if(te!==void 0&&ie!=="card"){const ue=(ie==="label"?18:11)+4;o.beginPath(),o.arc(R(te.x),N(te.y),ue,0,Math.PI*2),o.lineWidth=2,o.strokeStyle=ba(v.statusBad,.75),o.stroke()}}o.restore()}if(M!==void 0&&M.from!==void 0&&M.to!==void 0){const W=M.phase,J=G(M.from,M.to);o.save(),o.lineCap="round",o.setLineDash([10,6]),o.lineDashOffset=-W*32,o.lineWidth=3,o.strokeStyle=ba(v.brand600,.9*(1-W)),o.beginPath(),Yl(o,J,8),o.stroke(),o.setLineDash([]);for(const ae of[J[0],J[J.length-1]])o.beginPath(),o.arc(ae.x,ae.y,6+W*12,0,Math.PI*2),o.lineWidth=2,o.strokeStyle=ba(v.brand500,.8*(1-W)),o.stroke();o.restore()}if(b!==void 0){if(b.frame!==void 0){const J=R(b.frame.minX)-10,ae=N(b.frame.minY)-10,ne=(b.frame.maxX-b.frame.minX)*O+20,Y=(b.frame.maxY-b.frame.minY)*O+20;o.save(),o.beginPath(),o.rect(J,ae,ne,Y),o.globalAlpha=.07,o.fillStyle=ba(v.brand500),o.fill(),o.restore(),o.save(),o.setLineDash([7,5]),o.lineWidth=1.5,o.strokeStyle=ba(v.brand600),o.strokeRect(J,ae,ne,Y),o.setLineDash([]),o.restore()}if(b.emphasis!==void 0){const W=b.emphasis==="pulse",J=W?Math.sin(b.pulsePhase*Math.PI*2)*.5+.5:1;for(const ae of u){if(j(ae.key))continue;const ne=d.get(ae.key)??"dot";if(ne==="card")continue;const te=(ne==="label"?18:11)+(W?J*7:4),ie=W?.14+.3*(1-J):.34;o.save(),o.beginPath(),o.arc(R(ae.x),N(ae.y),te,0,Math.PI*2),o.lineWidth=2,o.strokeStyle=ba(v.brand500,ie),o.stroke(),o.restore()}}}for(const W of u){const J=_(W.footprint);if(J===void 0||J.type==="rect"||(d.get(W.key)??"dot")!=="card")continue;const ae=f.has(W.key);let ne=KV(v,_(W.color),(n=_(W.tone))==null?void 0:n.type,j8e(v,F8e(W.status)),"link");K(W.key)&&(ne=ba(v.fgMuted));const Y=H(W.key),te=_(W.bg),ie=_(W.fillOpacity)??(ae?.24:.12),ue=_(W.weight)??(ae?2.5:1.5),oe=()=>{o.save(),o.globalAlpha=ie*Y,o.fillStyle=K(W.key)?ne:te??ne,o.fill(),o.restore()};if(o.save(),o.globalAlpha=Y,J.type==="circle")o.beginPath(),o.arc(R(W.x),N(W.y),J.value.radius*O,0,Math.PI*2),oe(),o.lineWidth=ue,o.strokeStyle=ne,o.stroke();else{const ve=J.value.vertices.map(se=>({x:R(se.x),y:N(se.y),bulge:se.bulge}));if(ve.length>0){if(o.beginPath(),J.type==="polygon")wb(o,ve,!0),oe(),o.lineWidth=ue;else{wb(o,ve,!1);const se=J.value.width.type==="some"?J.value.width.value*O:void 0;o.lineCap="round",o.lineWidth=_(W.weight)??se??(ae?2.5:1.5)}o.strokeStyle=ne,o.stroke(),o.lineCap="butt"}}o.restore()}for(const W of u){const J=d.get(W.key)??"dot";if(J==="card")continue;let ae=KV(v,_(W.color),(r=_(W.tone))==null?void 0:r.type,j8e(v,F8e(W.status)),"link");K(W.key)&&(ae=ba(v.fgMuted));const ne=f.has(W.key),Y=R(W.x),te=N(W.y);if(o.save(),o.globalAlpha=H(W.key),J==="dot")o.beginPath(),o.arc(Y,te,_On,0,Math.PI*2),o.fillStyle=ae,o.fill(),o.lineWidth=1.5,o.strokeStyle=ba(v.white),o.stroke(),ne&&(o.beginPath(),o.arc(Y,te,7.5,0,Math.PI*2),o.lineWidth=2,o.strokeStyle=ba(v.fg),o.stroke());else{o.font=$ie;const ie=eZe(W,"label",s,ue=>o.measureText(ue).width);if(ie.kind==="rect"){const{left:ue,top:oe,w:ve,h:se}=ie;o.beginPath(),(a=o.roundRect)==null||a.call(o,ue,oe,ve,se,se/2),o.roundRect||o.rect(ue,oe,ve,se),o.fillStyle=ba(v.bgSurface),o.fill(),o.lineWidth=1,o.strokeStyle=ba(ne?v.fg:v.borderStrong),o.stroke(),o.beginPath(),o.arc(ue+gR+ZE/2,te,ZE/2,0,Math.PI*2),o.fillStyle=ae,o.fill(),o.fillStyle=ba(v.fg),o.textBaseline="middle",o.fillText(W.label,ue+gR+ZE+JXe,te)}}o.restore()}}const w3=new Set;function rZe(e,t){return e.type==="string"&&e.value.fieldId===t&&e.value.op.type==="in"}function DOn(e,t){for(const n of e)if(rZe(n,t))return n.value.op.value;return w3}function OOn(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function jOn(e,t,n){const r=e.filters.findIndex(o=>rZe(o,t));let a;if(n.length===0)a=r<0?[...e.filters]:e.filters.filter((o,i)=>i!==r);else{const o=$("string",{fieldId:t,op:$("in",new Set(n))});r<0?a=[...e.filters,o]:(a=[...e.filters],a[r]=o)}return{...e,filters:a}}function FOn(e,t,n,r){const a=new Set;for(const o of e.search(t)){const i=o.item.key;n.has(i)||r.has(i)||o.item.x<t.minX||o.item.x>t.maxX||o.item.y<t.minY||o.item.y>t.maxY||a.add(i)}return a}function BOn(e,t){const n=new Map,r=[...e].sort((u,d)=>u.width*u.height-d.width*d.height),a=(u,d,f)=>d>=u.x&&d<=u.x+u.width&&f>=u.y&&f<=u.y+u.height;for(const u of e)n.set(u.key,{zone:u,children:[],items:[]});const o=[],i=new Map;for(const u of e){const d=r.find(f=>f.key!==u.key&&f.width*f.height>u.width*u.height&&a(f,u.x+u.width/2,u.y+u.height/2));d!==void 0?(n.get(d.key).children.push(n.get(u.key)),i.set(u.key,d.key)):o.push(n.get(u.key))}const s=r.filter(u=>u.pattern.type==="outline"),l=[],c=new Map;for(const u of t){const d=s.find(f=>a(f,u.x,u.y));d!==void 0?(n.get(d.key).items.push(u),c.set(u.key,d.key)):l.push(u)}return{roots:o,floor:l,zoneOf:c,parentOf:i}}function Zg(e,t,n){if(t==="label")return{w:e.label.length*6+28,h:22};const r=e.sublabel.type==="some"?e.sublabel.value:void 0,o=(e.width.type==="some"?e.width.value*n:void 0)??Math.max(88,e.label.length*6.6+(e.icon.type==="some"?16:0)+(e.status.type==="some"?13:0)+20,((r==null?void 0:r.length)??0)*5.4+20),i=24+(r!==void 0?13:0)+(e.meter.type==="some"?8:0)+(e.metric.type==="some"?15:0);return{w:o,h:i}}function VOn(e){const t=new ZXe;return t.load(e.map(n=>({minX:n.x,minY:n.y,maxX:n.x,maxY:n.y,item:n}))),t}function HOn(e,t,n,r,a){const o=new Map;if(n==="dot"){for(const d of e)o.set(d.key,"dot");return o}const i=6;let s=0,l=0;const c=new Map;for(const d of e){const f=Zg(d,"card",r),h=Zg(d,"label",r);c.set(d.key,{card:f,label:h}),s=Math.max(s,f.w),l=Math.max(l,f.h)}const u=(d,f)=>{const h=c.get(d.key)[f],g=((h.w+s)/2+i)/r,v=((h.h+l)/2+i)/r;for(const b of t.search({minX:d.x-g,minY:d.y-v,maxX:d.x+g,maxY:d.y+v})){if(b.item.key===d.key)continue;const y=o.get(b.item.key);if(y==="dot")continue;const S=(c.get(b.item.key)??{card:Zg(b.item,"card",r),label:Zg(b.item,"label",r)})[y==="label"?"label":f];if(Math.abs(b.item.x-d.x)*r<(h.w+S.w)/2+i&&Math.abs(b.item.y-d.y)*r<(h.h+S.h)/2+i)return!1}return!0};if(n==="card")for(const d of e)u(d,"card")&&o.set(d.key,"card");for(const d of e)o.has(d.key)||o.set(d.key,u(d,"label")?"label":"dot");for(const d of a)o.has(d)&&o.set(d,n);return o}const aZe={brand600:"brand.600",brand500:"brand.500",fg:"fg",fgMuted:"fg.muted",fgSubtle:"fg.subtle",borderStrong:"border.strong",borderSubtle:"border.subtle",bgSurface:"bg.surface",bgPanel:"bg.panel",statusOk:"status.pos",statusWarn:"status.warn",statusBad:"status.neg",white:"white"},q8e=Object.keys(aZe);function WOn(e){const t=e.match(/[\d.]+/g);return t===null||t.length<3?[0,0,0]:[Math.round(+t[0]),Math.round(+t[1]),Math.round(+t[2])]}const UOn=C.memo(function({onResolve:t}){const n=C.useRef(null);return C.useLayoutEffect(()=>{const r=()=>{const o=n.current;if(o===null)return;const i=o.children,s={};q8e.forEach((l,c)=>{const u=i[c];u!==void 0&&(s[l]=WOn(getComputedStyle(u).color))}),t(s)};r();const a=new MutationObserver(r);return a.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme","style"]}),()=>a.disconnect()},[t]),p.jsx(V,{ref:n,"aria-hidden":"true",css:{position:"absolute",width:"0",height:"0",overflow:"hidden",pointerEvents:"none"},children:q8e.map(r=>p.jsx(V,{color:aZe[r]},r))})});zv.add(_v);const qOn=it(S0.Types.Schematic);function G8e(e){let t=[],n=[];for(const r of e){const a=o=>t.includes(o)||n.includes(o);t.length===0&&n.length===0?(t=[r.from],n=[r.to]):a(r.from)&&!a(r.to)?n=[...n,r.to]:!a(r.from)&&a(r.to)?t=[...t,r.from]:!a(r.from)&&!a(r.to)&&(t=[...t,r.from],n=[...n,r.to])}return{sources:t,destinations:n}}const dT=40,GOn=30,KOn=16,YOn=25,K8e={},Y8e=1600,XOn=300,ZOn=250,X8e=10;function P1(e,t){queueMicrotask(()=>{try{const n=t();n instanceof Promise&&n.catch(r=>console.error(`[Schematic] ${e} callback failed:`,r))}catch(n){console.error(`[Schematic] ${e} callback failed:`,n)}})}function QOn(e,t,n){return{key:e,sources:[...t],destinations:[...n],label:A,metric:A,style:$("solid",{tone:A,weight:A}),route:$("orthogonal",{corner:A}),via:[],layer:A}}function JOn(e,t,n){return{key:e,from:t,to:n,label:A,metric:A,style:$("solid",{tone:A,weight:A}),route:$("orthogonal",{corner:A}),via:[],layer:A}}function ZV(e){return e.type==="some"?e.value.type:void 0}function Z8e(e,t){const n=t/e,r=Math.pow(10,Math.floor(Math.log10(n)));for(const a of[5,2,1])if(a*r<=n)return a*r;return r}function Q8e(e,t,n){let r=!1;for(let a=0,o=n.length-1;a<n.length;o=a++){const i=n[a].x,s=n[a].y,l=n[o].x,c=n[o].y;s>t!=c>t&&e<(l-i)*(t-s)/(c-s)+i&&(r=!r)}return r}const ejn=C.memo(function({value:t,storageKey:n}){var r,a,o;const i=en({key:"schematic"})(),{width:s,height:l}=t.extent,c=C.useMemo(()=>_(t.onSelect),[t.onSelect]),u=C.useMemo(()=>_(t.onSelectionChange),[t.onSelectionChange]),d=((r=_(t.selectionMode))==null?void 0:r.type)??"single",f=d==="multiple",h=_(t.selectZoomFocus)??!1,g=C.useMemo(()=>_(t.onViewportChange),[t.onViewportChange]),v=C.useMemo(()=>_(t.onItemOpen),[t.onItemOpen]),b=C.useMemo(()=>_(t.onSelectZone),[t.onSelectZone]),y=C.useMemo(()=>_(t.onZoneSelectionChange),[t.onZoneSelectionChange]),[x,S]=C.useState(w3),z=C.useMemo(()=>_(t.onCreateLink),[t.onCreateLink]),M=((a=_(t.linkMode))==null?void 0:a.type)??"draw",L=_(t.readOnly)??!1,R=!L&&!(_(t.readOnlyLinks)??!1),N=C.useMemo(()=>_(t.onMoveItem),[t.onMoveItem]),O=C.useMemo(()=>_(t.itemHover),[t.itemHover]),j=C.useMemo(()=>_(t.zoneHover),[t.zoneHover]),B=C.useMemo(()=>_(t.linkHover),[t.linkHover]),H=O!==void 0||j!==void 0||B!==void 0,[K,U]=C.useState(null),Z=C.useRef(null);C.useEffect(()=>{Z.current=K},[K]);const G=C.useRef(null),W=C.useRef(null),J=C.useCallback(()=>{G.current!==null&&(window.clearTimeout(G.current.timer),G.current=null)},[]),ae=C.useCallback(()=>{W.current!==null&&(window.clearTimeout(W.current),W.current=null)},[]),ne=C.useCallback(()=>{J(),ae(),U(fe=>fe===null?fe:null)},[J,ae]),Y=C.useCallback(()=>{J(),!(Z.current===null||W.current!==null)&&(W.current=window.setTimeout(()=>{W.current=null,U(null)},ZOn))},[J]);C.useEffect(()=>()=>{G.current!==null&&window.clearTimeout(G.current.timer),W.current!==null&&window.clearTimeout(W.current)},[]);const te=C.useMemo(()=>{if(K===null)return null;const fe=K.kind==="item"?O:K.kind==="zone"?j:B;if(fe===void 0)return null;try{return fe(K.key)}catch(Ee){return console.error("[Schematic] hover content builder failed:",Ee),null}},[K,O,j,B]),ie=!L&&!(_(t.readOnlyItems)??!1),ue=C.useMemo(()=>_(t.onSelectLink),[t.onSelectLink]),oe=C.useMemo(()=>_(t.onEditLink),[t.onEditLink]),ve=C.useMemo(()=>_(t.onDeleteLink),[t.onDeleteLink]),se=C.useMemo(()=>_(t.onEditNet),[t.onEditNet]),pe=C.useMemo(()=>_(t.canConnect),[t.canConnect]),de=C.useRef(new Map);C.useEffect(()=>{de.current=new Map},[pe]);const ge=C.useCallback((fe,Ee)=>{if(pe===void 0)return!0;const Le=`${fe}\0${Ee}`,He=de.current.get(Le);if(He!==void 0)return He;let Je=!0;try{Je=pe(fe,Ee)===!0}catch(at){console.error("[Schematic] canConnect validator failed (allowing):",at)}return de.current.set(Le,Je),Je},[pe]),[ye,me]=C.useState(null),Me=_(t.scaleUnit),Te=_(t.grid)??!0,Be=_(t.navigator)??t.zones.length>0,ht=_(t.minimap)??t.items.length>=YOn,De=_(t.slice),Qe=De==null?void 0:De.slice,bt=rl(Qe==null?void 0:Qe.key),Ve=en({key:"sliceFrame"})(),ut=De!==void 0&&Qe!==void 0,_t=C.useMemo(()=>(De==null?void 0:De.affordances.map(fe=>fe.type))??[],[De]),Ft=C.useMemo(()=>ut?p.jsx(zd,{slice:Qe,affordanceKinds:_t}):null,[ut,Qe,_t,bt]),wt=Tt(_(t.height)),Lt=Tt(_(t.maxHeight)),Jt=_(t.sliceEffect),Dt=Jt!==void 0,Et=Jt!==void 0&&(_(Jt.hidden)??!1)?"hide":"keep",Gt=Jt!==void 0?_(Jt.opacity)??1:1,Ke=Jt!==void 0?_(Jt.desaturate)??!1:!1,Se=Jt!==void 0?_(Jt.dot)??!1:!1,Re=Jt!==void 0?(o=_(Jt.emphasis))==null?void 0:o.type:void 0,qe=Jt!==void 0?_(Jt.frame)??!1:!1,Ye=Jt!==void 0?_(Jt.frameFit)??!1:!1,$e=C.useMemo(()=>{const fe=new Set;if(Dt)for(const Ee of t.items)_(Ee.excluded)===!0&&fe.add(Ee.key);return fe},[t.items,Dt]),lt=Dt&&$e.size>0,[Pe,ot]=C.useState({created:[],createdNets:[],retarget:new Map,deleted:new Set,netEdits:new Map});C.useEffect(()=>{ot({created:[],createdNets:[],retarget:new Map,deleted:new Set,netEdits:new Map})},[t.links,t.nets]);const kt=Pe.created.length>0||Pe.createdNets.length>0||Pe.retarget.size>0||Pe.deleted.size>0||Pe.netEdits.size>0,Mt=C.useMemo(()=>kt?[...t.links.filter(Ee=>!Pe.deleted.has(Ee.key)).map(Ee=>{const Le=Pe.retarget.get(Ee.key);return Le!==void 0?{...Ee,from:Le.from,to:Le.to}:Ee}),...Pe.created]:t.links,[t.links,Pe,kt]),At=C.useMemo(()=>kt?[...t.nets.filter(fe=>!Pe.deleted.has(fe.key)),...Pe.createdNets].map(fe=>{const Ee=Pe.netEdits.get(fe.key);return Ee!==void 0?{...fe,sources:[...Ee.sources],destinations:[...Ee.destinations]}:fe}):t.nets,[t.nets,Pe,kt]),[fn,rt]=C.useState(new Map);C.useEffect(()=>{rt(new Map)},[t.items]);const ln=C.useMemo(()=>fn.size===0?t.items:t.items.map(fe=>{const Ee=fn.get(fe.key);return Ee!==void 0?{...fe,x:Ee.x,y:Ee.y}:fe}),[t.items,fn]),Mn=C.useMemo(()=>kt||fn.size>0?{...t,items:ln,links:Mt,nets:At}:t,[t,ln,fn,Mt,At,kt]);C.useEffect(()=>{me(fe=>{if(fe===null)return fe;const Ee=At.find(Le=>Le.key===fe.key);return Ee===void 0&&!Mt.some(Le=>Le.key===fe.key)?null:fe.leg!==null&&Ee!==void 0&&!(fe.leg.end==="source"?Ee.sources:Ee.destinations).includes(fe.leg.item)?{key:fe.key,leg:null}:fe})},[Mt,At]);const[Jn,Er]=C.useState({selected:w3,anchor:null}),_r=Jn.selected,fr=_(t.sliceSelectField),Vr={onSelectionChange:u,sliceSelectField:fr,sliceHandle:Qe,selectZoomFocus:h},wr=C.useRef(Vr),pa=C.useRef(!1),ar=C.useCallback((fe,Ee)=>{Er(Je=>({selected:fe,anchor:fe.size===0?null:Ee.anchor!==void 0?Ee.anchor:Je.anchor}));const Le=wr.current,He=Le.onSelectionChange;if(He&&P1("onSelectionChange",()=>He({key:Ee.key!==void 0?P(Ee.key):A,selected:Ee.key!==void 0?fe.has(Ee.key):fe.size>0,selectedKeys:[...fe],additive:Ee.additive,region:Ee.region!==void 0?P(Ee.region):A})),Le.sliceSelectField!==void 0&&Le.sliceHandle!==void 0){const Je=Le.sliceHandle.read();OOn(DOn(Je.filters,Le.sliceSelectField),fe)||(Le.selectZoomFocus&&(pa.current=!0),Le.sliceHandle.write(jOn(Je,Le.sliceSelectField,[...fe].sort())))}},[]),On=C.useCallback(()=>ar(w3,{additive:!1}),[ar]),[st,dn]=C.useState(null),{state:Pn,setState:Hn}=Pl(n,{navCollapsed:!1,layerVis:{},layerLocks:{}}),pr=Pn.navCollapsed,Hr=C.useCallback(fe=>Hn(Ee=>({...Ee,navCollapsed:fe})),[Hn]),lr=C.useMemo(()=>_(t.layers)??[],[t.layers]),vr=lr.length>0,mo=Pn.layerVis??K8e,Fe=Pn.layerLocks??K8e,[Qt,tt]=C.useState(null),[gt,Ot]=C.useState(!1),yn=C.useMemo(()=>new Map(lr.map(fe=>[fe.key,fe])),[lr]),Bt=C.useCallback(fe=>{var Ee;return _((Ee=yn.get(fe))==null?void 0:Ee.visible)??!0},[yn]),vn=C.useCallback(fe=>{var Ee;return _((Ee=yn.get(fe))==null?void 0:Ee.locked)??!1},[yn]),wn=C.useCallback(fe=>{var Ee;return _((Ee=yn.get(fe))==null?void 0:Ee.opacity)??1},[yn]),Or=C.useCallback(fe=>Qt!==null?yn.has(fe)&&fe!==Qt:(mo[fe]??Bt(fe))===!1,[Qt,yn,mo,Bt]),{layerHiddenKeys:Zr,lockedKeys:qn,layerAlpha:ca,layerHiddenLayers:sa}=C.useMemo(()=>{const fe=St=>Fe[St]??vn(St),Ee=new Set;for(const St of lr)Or(St.key)&&Ee.add(St.key);const Le=new Set,He=new Set,Je=new Map,at=(St,$t)=>{if($t===void 0)return;if(Or($t)){Le.add(St);return}fe($t)&&He.add(St);const Yt=wn($t);Yt<1&&Je.set(St,Yt)};for(const St of t.items)at(St.key,_(St.layer));for(const St of t.zones)at(St.key,_(St.layer));for(const St of t.links)at(St.key,_(St.layer));return{layerHiddenKeys:Le,lockedKeys:He,layerAlpha:Je,layerHiddenLayers:Ee}},[lr,t.items,t.zones,t.links,Fe,Or,vn,wn]),vo=sa.size>0||Qt!==null,Ya=C.useMemo(()=>{const fe=new Map,Ee=Le=>{Le!==void 0&&fe.set(Le,(fe.get(Le)??0)+1)};for(const Le of t.items)Ee(_(Le.layer));for(const Le of t.zones)Ee(_(Le.layer));for(const Le of t.links)Ee(_(Le.layer));return fe},[t.items,t.zones,t.links]),Ha=C.useCallback(fe=>{const Ee=!sa.has(fe);tt(null),Hn(Le=>({...Le,layerVis:{...Le.layerVis??{},[fe]:!Ee}}))},[Hn,sa]),fi=C.useCallback(fe=>{Hn(Ee=>{const Le=Ee.layerLocks??{},He=Le[fe]??vn(fe);return{...Ee,layerLocks:{...Le,[fe]:!He}}})},[Hn,vn]),Ma=C.useCallback(fe=>tt(Ee=>Ee===fe?null:fe),[]),Wa=C.useCallback(()=>{tt(null),Hn(fe=>({...fe,layerVis:{},layerLocks:{}}))},[Hn]),Sa=C.useMemo(()=>{const fe=lt&&Et==="hide";return!fe&&Zr.size===0?ln:ln.filter(Ee=>!Zr.has(Ee.key)&&!(fe&&$e.has(Ee.key)))},[ln,lt,Et,$e,Zr]),Oa=C.useMemo(()=>Zr.size===0?t.zones:t.zones.filter(fe=>!Zr.has(fe.key)),[t.zones,Zr]),[Nl,$l]=C.useState(null);C.useEffect(()=>{if(_r.size===0)return;const fe=new Set(Sa.map(He=>He.key));let Ee=!1;const Le=new Set;for(const He of _r)fe.has(He)?Le.add(He):Ee=!0;Ee&&ar(Le,{additive:!1}),Er(He=>He.anchor!==null&&!fe.has(He.anchor)?{...He,anchor:null}:He)},[Sa,_r,ar]);const Il=C.useRef(null),M1=C.useRef(null),Sc=C.useRef(null),yo=C.useRef(null),il=C.useRef(null),[ft,Nt]=C.useState(null);C.useLayoutEffect(()=>{const fe=M1.current;if(!fe)return;const Ee=()=>Nt({w:fe.clientWidth,h:fe.clientHeight});Ee();const Le=new ResizeObserver(Ee);return Le.observe(fe),()=>Le.disconnect()},[]);const[sn,Fn]=C.useState(()=>typeof window<"u"&&window.devicePixelRatio||1);C.useEffect(()=>{if(typeof window>"u"||typeof window.matchMedia!="function")return;let fe=()=>{};const Ee=()=>{const Le=window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`),He=()=>{fe(),Fn(window.devicePixelRatio||1),Ee()};Le.addEventListener("change",He),fe=()=>Le.removeEventListener("change",He)};return Ee(),()=>fe()},[]);const xn=C.useRef(YE),Pa=C.useRef("idle"),Qr=C.useRef(null),[cr,Ar]=C.useState(YE),[Cr,Aa]=C.useState("grab"),[qo,bo]=C.useState(null),qr=qo??Cr,Gs=qr==="zoom"||qr==="marquee",yr=C.useRef(!1),Jr=C.useRef(null),ja=C.useRef(null),[ta,Io]=C.useState(null),xi=C.useRef(null),[wi,pi]=C.useState([]),Dl=C.useRef(0),Xe=C.useRef(null),Rt=C.useRef(null),an=C.useRef(null),Rn=C.useRef(null),hr=C.useRef(null);C.useEffect(()=>()=>{Rn.current!==null&&cancelAnimationFrame(Rn.current)},[]);const[kr,to]=C.useState(null),Na=(kr==null?void 0:kr.rect)??null,Go=kr!==null&&kr.mode==="marquee"?kr.hits.size:0,Si=C.useMemo(()=>kr===null||kr.mode!=="marquee"?null:kr.additive?new Set([..._r,...kr.hits]):kr.hits,[kr,_r]),ri=ft!==null?Math.min(ft.w/s,ft.h/l):0,Nr=ri*cr.zoom,no=C.useMemo(()=>{const fe=new Map;for(const Ee of Sa)fe.set(Ee.key,{x:Ee.x,y:Ee.y});return fe},[Sa]),y2=C.useMemo(()=>{if(ta===null)return;const fe=no.get(ta.from);if(fe===void 0)return;const Ee=ta.target!==void 0?no.get(ta.target)??ta.toWorld:ta.toWorld;return{from:fe,to:Ee,snapped:ta.target!==void 0,...ta.forbidden!==void 0?{forbiddenKey:ta.forbidden}:{}}},[ta,no]),P4=C.useMemo(()=>{if(wi.length===0)return null;if(wi.length===1){const Je=wi[0],at=no.get(Je.from),St=no.get(Je.to);return at!==void 0&&St!==void 0?{kind:"edge",from:at,to:St}:null}const{sources:fe,destinations:Ee}=G8e(wi),Le=fe.map(Je=>no.get(Je)).filter(Je=>Je!==void 0),He=Ee.map(Je=>no.get(Je)).filter(Je=>Je!==void 0);return Le.length===0||He.length===0?null:{kind:"net",sources:Le,destinations:He}},[wi,no]),T1=C.useMemo(()=>{const fe=new ZXe;return fe.load(Sa.map(Ee=>{const Le=(_(Ee.width)??0)/2+2.4;let He=Ee.x-Le,Je=Ee.y-2,at=Ee.x+Le,St=Ee.y+2;const $t=_(Ee.footprint);if($t!==void 0&&$t.type==="circle"){const Yt=$t.value.radius;He=Math.min(He,Ee.x-Yt),Je=Math.min(Je,Ee.y-Yt),at=Math.max(at,Ee.x+Yt),St=Math.max(St,Ee.y+Yt)}else if($t!==void 0&&$t.type!=="rect")for(const Yt of $t.value.vertices)He=Math.min(He,Yt.x),Je=Math.min(Je,Yt.y),at=Math.max(at,Yt.x),St=Math.max(St,Yt.y);return{minX:He,minY:Je,maxX:at,maxY:St,item:Ee}})),fe},[Sa]),Ol=C.useMemo(()=>ft===null||Nr===0?[]:T1.search({minX:-cr.tx/Nr,minY:-cr.ty/Nr,maxX:(ft.w-cr.tx)/Nr,maxY:(ft.h-cr.ty)/Nr}).map(fe=>fe.item),[T1,ft,Nr,cr]),Ks=C.useMemo(()=>BOn(Oa,Sa),[Oa,Sa]),Fk=C.useCallback(fe=>{if(fe.size===0)return[];const Ee=[];for(const[Le,He]of Ks.zoneOf){let Je=He;for(;Je!==void 0;){if(fe.has(Je)){Ee.push(Le);break}Je=Ks.parentOf.get(Je)}}return Ee},[Ks]),Pd=C.useCallback((fe,Ee)=>{S(fe);const Le=y;Le&&P1("onZoneSelectionChange",()=>Le({key:Ee.key!==void 0?P(Ee.key):A,selected:Ee.key!==void 0?fe.has(Ee.key):fe.size>0,selectedKeys:[...fe],childItemKeys:Fk(fe),additive:Ee.additive}))},[y,Fk]),T5=C.useCallback(()=>{$r.current.zoneSelection.size>0&&Pd(w3,{additive:!1})},[Pd]),A4=C.useCallback((fe,Ee,Le)=>{const He=$r.current;if(He.size===null)return;const Je=xn.current,at=He.fit*Je.zoom;if(at===0)return;const St=fe.getBoundingClientRect(),$t=(Ee-St.left-Je.tx)/at,Yt=(Le-St.top-Je.ty)/at;let _n,Bn=1/0;for(const qt of Oa){if(qt.pattern.type!=="outline"||qn.has(qt.key))continue;const tn=_(qt.geometry);let er;if(tn!==void 0&&tn.type==="circle")er=Math.hypot($t-(qt.x+qt.width/2),Yt-(qt.y+qt.height/2))<=tn.value.radius;else if(tn!==void 0&&tn.type==="polygon")er=Q8e($t,Yt,tn.value.vertices);else{if(tn!==void 0&&tn.type==="polyline")continue;er=$t>=qt.x&&$t<=qt.x+qt.width&&Yt>=qt.y&&Yt<=qt.y+qt.height}if(!er)continue;const gr=qt.width*qt.height;gr<Bn&&(_n=qt,Bn=gr)}return _n==null?void 0:_n.key},[Oa,qn]),E5=C.useCallback((fe,Ee,Le)=>{const He=$r.current;if(He.size===null)return;const Je=xn.current,at=He.fit*Je.zoom;if(at===0)return;const St=fe.getBoundingClientRect(),$t=Ee-St.left,Yt=Le-St.top,_n=nZe(Mt,tn=>!Zr.has(tn.key)&&no.has(tn.from)&&no.has(tn.to)&&tn.via.length===0);let Bn,qt=1/0;for(const tn of Mt){if(Zr.has(tn.key)||qn.has(tn.key))continue;const er=no.get(tn.from),gr=no.get(tn.to);if(er===void 0||gr===void 0)continue;const br=[er,...tn.via,gr].map(Do=>({x:Do.x*at+Je.tx,y:Do.y*at+Je.ty})),ma=_n.get(tn.key);if(ma!==void 0){const Do=br[0],Ys=br[br.length-1],x2=Math.hypot(Ys.x-Do.x,Ys.y-Do.y);if(x2>1e-6){const j4=(ma.i-(ma.n-1)/2)*tZe,ro=-(Ys.y-Do.y)/x2*j4,p0=(Ys.x-Do.x)/x2*j4;for(const Fl of br)Fl.x+=ro,Fl.y+=p0}}const Eo=tn.route.type==="orthogonal"?O8(br):br,Ir=tn.style.value.weight.type==="some"?tn.style.value.weight.value:tn.style.type==="solid"?2.5:1.5,ai=XV(Eo,$t,Yt);ai<=Ir/2+YV&&ai<qt&&(Bn={key:tn.key,leg:null},qt=ai)}for(const tn of At){if(Zr.has(tn.key)||qn.has(tn.key))continue;const er=tn.sources.filter(ro=>no.has(ro)),gr=tn.destinations.filter(ro=>no.has(ro)),br=er.map(ro=>no.get(ro)),ma=gr.map(ro=>no.get(ro));if(br.length===0||ma.length===0)continue;const Eo=aX(br,ma,tn.via),Ir=ro=>({x:ro.x*at+Je.tx,y:ro.y*at+Je.ty}),ai=tn.route.type==="orthogonal",Do=ro=>ai?O8(ro.map(Ir)):ro.map(Ir),Ys=tn.style.value.weight.type==="some"?tn.style.value.weight.value:tn.style.type==="solid"?2.5:1.5,x2=ro=>ro<er.length?{end:"source",item:er[ro]}:{end:"destination",item:gr[ro-er.length]},j4=[Do(Eo.trunk),...Eo.bars.map(ro=>ro.map(Ir))];for(const ro of j4){const p0=XV(ro,$t,Yt);p0<=(Ys+1)/2+YV&&p0<qt&&(Bn={key:tn.key,leg:null},qt=p0)}for(const[ro,p0]of Eo.stubs.entries()){const Fl=XV(Do(p0),$t,Yt);Fl<=(Ys+1)/2+YV&&Fl<qt&&(Bn={key:tn.key,leg:x2(ro)},qt=Fl)}}return Bn},[Mt,At,no,Zr,qn]),Xv=C.useCallback((fe,Ee=null)=>{if(me({key:fe,leg:Ee}),ue){const Le=ue;P1("onSelectLink",()=>Le(fe))}},[ue]),MD=C.useMemo(()=>{const fe=new Map,Ee=new Map;for(const Le of Oa){const He=(fe.get(Le.label)??0)+1;fe.set(Le.label,He),Ee.set(Le.key,He>1?`${Le.label} · ${He}`:Le.label)}return Ee},[Oa]),Bk=C.useMemo(()=>{const fe=(Je,at)=>Je.label.localeCompare(at.label,void 0,{numeric:!0}),Ee=[],Le=Je=>{for(const at of[...Je].sort((St,$t)=>fe(St.zone,$t.zone)))Ee.push(...[...at.items].sort(fe)),Le(at.children)};Le(Ks.roots),Ee.push(...[...Ks.floor].sort(fe));const He=new Map(Ee.map((Je,at)=>[Je.key,at]));return{ordered:Ee,indexOf:He}},[Ks]),[_5,Zv]=C.useState(void 0);C.useEffect(()=>{if(ft===null||Nr===0||cr.zoom<=1.05){Zv(void 0);return}const He=-cr.tx/Nr,Je=-cr.ty/Nr,at=(ft.w-cr.tx)/Nr,St=(ft.h-cr.ty)/Nr,$t=(at-He)*(St-Je),Yt=qt=>{const tn=Math.max(0,Math.min(at,qt.x+qt.width)-Math.max(He,qt.x)),er=Math.max(0,Math.min(St,qt.y+qt.height)-Math.max(Je,qt.y));return tn*er/Math.min($t,qt.width*qt.height)};let _n,Bn=0;for(const qt of Oa){const tn=Yt(qt);tn>Bn&&(_n=qt.key,Bn=tn)}Zv(qt=>{if(qt!==void 0){const tn=Oa.find(gr=>gr.key===qt),er=tn!==void 0?Yt(tn):0;if(er>=.18&&(_n===qt||Bn<er+.15))return qt}return Bn>=.3?_n:void 0})},[ft,Nr,cr,Oa]);const Vk=C.useRef(null);C.useEffect(()=>{if(g===void 0||ft===null||ri===0)return;const fe=setTimeout(()=>{const Ee=ri*cr.zoom;if(Ee<=0)return;const Le=QXe({ppu:Ee,tx:cr.tx,ty:cr.ty},ft.w,ft.h),He={zoom:cr.zoom,minX:Le.minX,minY:Le.minY,maxX:Le.maxX,maxY:Le.maxY},Je=Vk.current;if(Je!==null&&Je.zoom===He.zoom&&Je.minX===He.minX&&Je.minY===He.minY&&Je.maxX===He.maxX&&Je.maxY===He.maxY)return;Vk.current=He;const at=g;P1("onViewportChange",()=>at(He))},150);return()=>clearTimeout(fe)},[g,ft,ri,cr]);const Cc=Nr>=GOn?"card":Nr>=KOn?"label":"dot",Hk=C.useMemo(()=>VOn(Ol),[Ol]),L5=C.useMemo(()=>{const fe=HOn(Ol,Hk,Cc,Nr,_r);if(lt&&Et==="keep"&&Se)for(const Ee of $e)fe.has(Ee)&&fe.set(Ee,"dot");return fe},[Ol,Hk,Cc,Nr,_r,lt,Et,Se,$e]),R5=Nr>0?Z8e(Nr,100):0,Qv=C.useMemo(()=>{if(!(lt&&qe))return;let fe=1/0,Ee=1/0,Le=-1/0,He=-1/0,Je=0;for(const at of ln){if($e.has(at.key)||Zr.has(at.key))continue;Je++;const St=Cc==="dot"?X8e:Zg(at,Cc,Nr).w/2+2,$t=Cc==="dot"?X8e:Zg(at,Cc,Nr).h/2+2,Yt=Nr>0?St/Nr:0,_n=Nr>0?$t/Nr:0;let Bn=at.x-Yt,qt=at.y-_n,tn=at.x+Yt,er=at.y+_n;const gr=_(at.footprint);if(gr!==void 0&&gr.type==="circle"){const br=gr.value.radius;Bn=Math.min(Bn,at.x-br),qt=Math.min(qt,at.y-br),tn=Math.max(tn,at.x+br),er=Math.max(er,at.y+br)}else if(gr!==void 0&&gr.type!=="rect")for(const br of gr.value.vertices)Bn=Math.min(Bn,br.x),qt=Math.min(qt,br.y),tn=Math.max(tn,br.x),er=Math.max(er,br.y);Bn<fe&&(fe=Bn),qt<Ee&&(Ee=qt),tn>Le&&(Le=tn),er>He&&(He=er)}return Je>=2&&Number.isFinite(fe)?{minX:fe,minY:Ee,maxX:Le,maxY:He}:void 0},[ln,$e,Zr,lt,qe,Cc,Nr]),TD=C.useMemo(()=>{if(lt)return{excluded:Et==="keep"?$e:w3,excludedOpacity:Gt,excludedDesaturate:Ke,emphasis:Re,frame:Qv}},[lt,Et,$e,Gt,Ke,Re,Qv]),Wk=Si??_r,Jv={value:Mn,size:ft,fit:ri,dpr:sn,palette:Nl,visibleItems:Ol,tiers:L5,selection:Jn,zoneSelection:x,renderSelected:Wk,centers:no,openZone:st,paintEffect:TD,frameRect:Qv,layerHiddenKeys:Zr,layerAlpha:ca,effectiveTool:qr,isBoxTool:Gs,connectDraftWorld:y2,sessionWorld:P4,selectedLink:ye,linkEditEnabled:R},$r=C.useRef(Jv),P5=C.useRef(0),Uk=C.useRef(null),kc=C.useCallback(()=>{const fe=$r.current,Ee=fe.size;if(Ee===null)return;const Le=xn.current,He=fe.fit*Le.zoom,Je=fe.dpr,at=yo.current;at!==null&&(at.style.setProperty("--cam-ppu",String(He)),at.style.setProperty("--cam-tx",`${Le.tx}px`),at.style.setProperty("--cam-ty",`${Le.ty}px`));const St=il.current;if(St!==null){const ma=He>0?Z8e(He,100):0;if(ma>0){const Eo=ma*He,Ir=Eo/5;St.style.backgroundSize=`${Eo}px ${Eo}px, ${Eo}px ${Eo}px, ${Ir}px ${Ir}px, ${Ir}px ${Ir}px`,St.style.backgroundPosition=`${Le.tx}px 0, 0 ${Le.ty}px, ${Le.tx}px 0, 0 ${Le.ty}px`}}const $t=Sc.current,Yt=fe.palette;if($t===null||Yt===null)return;const _n=Xe.current,Bn=_n!==null?Math.min(1,(performance.now()-_n.t0)/450):-1,qt=Uk.current;if(qt!==null&&qt.zoom===Le.zoom&&qt.tx===Le.tx&&qt.ty===Le.ty&&qt.vis===fe.visibleItems&&qt.tiers===fe.tiers&&qt.sel===fe.renderSelected&&qt.zsel===fe.zoneSelection&&qt.pal===Yt&&qt.w===Ee.w&&qt.h===Ee.h&&qt.dpr===Je&&qt.val===fe.value&&qt.eff===fe.paintEffect&&qt.phase===P5.current&&qt.lay===fe.layerHiddenKeys&&qt.alp===fe.layerAlpha&&qt.dl===fe.connectDraftWorld&&qt.sw===fe.sessionWorld&&qt.cf===Bn&&qt.slk===fe.selectedLink&&qt.sle===fe.linkEditEnabled)return;Uk.current={zoom:Le.zoom,tx:Le.tx,ty:Le.ty,vis:fe.visibleItems,tiers:fe.tiers,sel:fe.renderSelected,zsel:fe.zoneSelection,pal:Yt,w:Ee.w,h:Ee.h,dpr:Je,val:fe.value,eff:fe.paintEffect,phase:P5.current,lay:fe.layerHiddenKeys,alp:fe.layerAlpha,dl:fe.connectDraftWorld,sw:fe.sessionWorld,cf:Bn,slk:fe.selectedLink,sle:fe.linkEditEnabled};const tn=Math.round(Ee.w*Je),er=Math.round(Ee.h*Je);($t.width!==tn||$t.height!==er)&&($t.width=tn,$t.height=er);const gr=$t.getContext("2d");if(gr===null)return;gr.setTransform(Je,0,0,Je,0,0);const br=fe.paintEffect;try{IOn({ctx:gr,value:fe.value,cam:{ppu:He,tx:Le.tx,ty:Le.ty},width:Ee.w,height:Ee.h,visibleItems:fe.visibleItems,tiers:fe.tiers,selected:fe.renderSelected,selectedZones:fe.zoneSelection,centers:fe.centers,palette:Yt,layerHiddenKeys:fe.layerHiddenKeys,layerAlpha:fe.layerAlpha,...fe.connectDraftWorld!==void 0?{draftLink:fe.connectDraftWorld}:{},...fe.sessionWorld!==null?{session:fe.sessionWorld}:{},..._n!==null?{connectFlash:{from:fe.centers.get(_n.from),to:fe.centers.get(_n.to),phase:Bn}}:{},...fe.selectedLink!==null?{selectedLink:{key:fe.selectedLink.key,editable:fe.linkEditEnabled,...fe.selectedLink.leg!==null?{leg:fe.selectedLink.leg}:{}}}:{},...br!==void 0?{effect:{...br,pulsePhase:P5.current}}:{}})}catch(ma){console.error("[Schematic] paint failed (frame skipped):",ma)}},[]);C.useLayoutEffect(()=>{$r.current=Jv,wr.current=Vr,kc()});const V7=C.useRef(null);V7.current===null&&typeof requestAnimationFrame<"u"&&(V7.current=TOn(requestAnimationFrame,cancelAnimationFrame));const zc=C.useCallback(()=>{const fe=()=>{kc();const Le=xn.current;Ar(He=>He.zoom===Le.zoom&&He.tx===Le.tx&&He.ty===Le.ty?He:{zoom:Le.zoom,tx:Le.tx,ty:Le.ty})},Ee=V7.current;Ee!==null?Ee.request(fe):fe()},[kc]),qk=C.useCallback(()=>{Qr.current!==null&&(cancelAnimationFrame(Qr.current),Qr.current=null)},[]),Ci=C.useCallback(fe=>{MOn(Pa.current,fe)&&qk(),Pa.current=zOn(Pa.current,fe)},[qk]),jl=C.useCallback(fe=>{if($r.current.size===null||$r.current.fit===0)return;ne();const Ee=1.18,Le=()=>{const St=$r.current.size,$t=$r.current.fit;if(St===null||$t===0)return null;const Yt=Math.min(dT,Math.min(St.w/(fe.w*Ee*$t),St.h/(fe.h*Ee*$t)));return{zoom:Yt,tx:St.w/2-(fe.x+fe.w/2)*$t*Yt,ty:St.h/2-(fe.y+fe.h/2)*$t*Yt}},He={...xn.current},Je=performance.now();Qr.current!==null&&cancelAnimationFrame(Qr.current),Ci("flyStart");const at=St=>{const $t=Math.min(1,(St-Je)/350),Yt=1-Math.pow(1-$t,3),_n=Le();if(_n!==null){xn.current={zoom:He.zoom+(_n.zoom-He.zoom)*Yt,tx:He.tx+(_n.tx-He.tx)*Yt,ty:He.ty+(_n.ty-He.ty)*Yt},kc();const Bn=xn.current;Ar({zoom:Bn.zoom,tx:Bn.tx,ty:Bn.ty})}$t<1?Qr.current=requestAnimationFrame(at):(Qr.current=null,Ci("flyEnd"))};Qr.current=requestAnimationFrame(at)},[kc,Ci,ne]),Ad=C.useCallback(fe=>{if(fe.size===0)return;let Ee=1/0,Le=1/0,He=-1/0,Je=-1/0;for(const $t of fe){const Yt=$r.current.centers.get($t);Yt!==void 0&&(Ee=Math.min(Ee,Yt.x),Le=Math.min(Le,Yt.y),He=Math.max(He,Yt.x),Je=Math.max(Je,Yt.y))}if(Ee>He)return;const at=Math.max(4,(He-Ee)*.15),St=Math.max(3,(Je-Le)*.15);jl({x:Ee-at,y:Le-St,w:He-Ee+2*at,h:Je-Le+2*St})},[jl]),Nd=C.useCallback(fe=>{let Ee=1/0,Le=1/0,He=-1/0,Je=-1/0;for(const at of Oa)fe.has(at.key)&&(Ee=Math.min(Ee,at.x),Le=Math.min(Le,at.y),He=Math.max(He,at.x+at.width),Je=Math.max(Je,at.y+at.height));Ee<=He&&jl({x:Ee,y:Le,w:He-Ee,h:Je-Le})},[Oa,jl]),ey=C.useCallback((fe,Ee)=>{const Le=Ee&&d==="multiple";let He;if(Le?(He=new Set($r.current.zoneSelection),He.has(fe)?He.delete(fe):He.add(fe)):He=new Set([fe]),h&&Nd(He),Pd(He,{additive:Le,key:fe}),b){const Je=b;P1("onSelectZone",()=>Je(fe))}},[d,h,Nd,Pd,b]),b2=C.useCallback(()=>{xi.current=null,pi(fe=>fe.length===0?fe:[])},[]),N4=C.useCallback(()=>{Rt.current!==null&&cancelAnimationFrame(Rt.current);const fe=()=>{const Ee=Xe.current;if(Ee===null){Rt.current=null;return}if(kc(),performance.now()-Ee.t0>=450){Xe.current=null,Rt.current=null,kc();return}Rt.current=requestAnimationFrame(fe)};Rt.current=requestAnimationFrame(fe)},[kc]);C.useEffect(()=>()=>{Rt.current!==null&&cancelAnimationFrame(Rt.current)},[]);const ty=C.useCallback((fe,Ee,Le)=>{var He;const Je=`connect-${fe}-${Ee}-${++Dl.current}`,at={key:Je,from:fe,to:Ee},St=Le?xi.current:null,$t=St!==null?[...St.links,at]:[at],Yt=St!==null?St.seeded:[],_n=St!==null?St.key:`net-${++Dl.current}`,Bn=St!==null,{sources:qt,destinations:tn}=G8e($t),er=Mt.filter(br=>br.from===fe&&br.to===Ee||br.from===Ee&&br.to===fe).map(br=>br.key);let gr="none";if(M==="draw")if(!Bn)gr="link",ot({...Pe,created:[...Pe.created,JOn(Je,fe,Ee)]});else{gr="net";const br=QOn(_n,qt,tn),ma=St!==null&&St.drawn==="link"?(He=St.links[0])==null?void 0:He.key:void 0,Eo=new Set(Yt),Ir=Yt.length>0?new Set([...Pe.deleted,...Yt]):Pe.deleted;ot({...Pe,created:Pe.created.filter(ai=>ai.key!==ma&&!Eo.has(ai.key)),createdNets:[...Pe.createdNets.filter(ai=>ai.key!==_n),br],deleted:Ir})}else pi($t);if(xi.current={key:_n,links:$t,drawn:gr,seeded:Yt},Xe.current={from:fe,to:Ee,t0:performance.now()},N4(),z){const br=z;P1("onCreateLink",()=>br({link:at,links:[...$t],net:{key:_n,sources:qt,destinations:tn},additive:Bn,existing:er,absorbed:[...Yt]}))}},[Mt,M,Pe,z,N4]),ny=C.useCallback((fe,Ee,Le)=>{const He=Mt.find($t=>$t.key===fe);if(He===void 0)return;const Je=Ee==="from"?Le:He.from,at=Ee==="to"?Le:He.to;if(Je===at)return;const St=Pe.created.findIndex($t=>$t.key===fe);if(St>=0){const $t=[...Pe.created];$t[St]={...$t[St],from:Je,to:at},ot({...Pe,created:$t})}else{const $t=new Map(Pe.retarget);$t.set(fe,{from:Je,to:at}),ot({...Pe,retarget:$t})}if(Xe.current={from:Je,to:at,t0:performance.now()},N4(),oe){const $t=oe;P1("onEditLink",()=>$t({key:fe,from:Je,to:at}))}},[Mt,Pe,oe,N4]),ry=C.useCallback((fe,Ee,Le)=>{const He=At.find(Yt=>Yt.key===fe);if(He===void 0||He.sources.includes(Le)||He.destinations.includes(Le)||!(He.sources.includes(Ee)||He.destinations.includes(Ee)))return;const at=[...He.sources],St=[...He.destinations,Le],$t=new Map(Pe.netEdits);if($t.set(fe,{sources:at,destinations:St}),ot({...Pe,netEdits:$t}),Xe.current={from:Ee,to:Le,t0:performance.now()},N4(),se){const Yt=se;P1("onEditNet",()=>Yt({key:fe,sources:at,destinations:St}))}},[At,Pe,se,N4]),$4=C.useCallback(()=>{const fe=$r.current.selectedLink;if(fe===null||!$r.current.linkEditEnabled)return;const Ee=fe.key;if(fe.leg!==null){const Le=At.find(He=>He.key===Ee);if(Le!==void 0){const He=fe.leg,Je=He.end==="source"?Le.sources.filter(St=>St!==He.item):[...Le.sources],at=He.end==="destination"?Le.destinations.filter(St=>St!==He.item):[...Le.destinations];if(Je.length>0&&at.length>0){const St=new Map(Pe.netEdits);if(St.set(Ee,{sources:Je,destinations:at}),ot({...Pe,netEdits:St}),me({key:Ee,leg:null}),se){const $t=se;P1("onEditNet",()=>$t({key:Ee,sources:Je,destinations:at}))}return}}}if(Pe.created.some(Le=>Le.key===Ee))ot({...Pe,created:Pe.created.filter(Le=>Le.key!==Ee)});else if(Pe.createdNets.some(Le=>Le.key===Ee))ot({...Pe,createdNets:Pe.createdNets.filter(Le=>Le.key!==Ee)});else{const Le=new Set(Pe.deleted);Le.add(Ee),ot({...Pe,deleted:Le})}if(me(null),ve){const Le=ve;P1("onDeleteLink",()=>Le(Ee))}},[Pe,ve,At,se]),Gk=C.useCallback((fe,Ee,Le)=>{if(N===void 0)return;const He=fe.orig.get(fe.key);if(He===void 0)return;const Je=N,at={key:fe.key,x:Math.min(Math.max(He.x+Ee,0),s),y:Math.min(Math.max(He.y+Le,0),l),keys:[...fe.keys],dx:Ee,dy:Le};P1("onMoveItem",()=>Je(at))},[N,s,l]),$d=C.useRef(null),H7=C.useCallback(fe=>{if(jl({x:fe.x-4,y:fe.y-3,w:8,h:6}),ar(new Set([fe.key]),{additive:!1,key:fe.key,anchor:fe.key}),$d.current=null,dn(Ks.zoneOf.get(fe.key)??null),c){const Ee=c;P1("onSelect",()=>Ee(fe.key))}},[jl,Ks.zoneOf,c,ar]),Id=C.useCallback(fe=>{const{ordered:Ee,indexOf:Le}=Bk;if(Ee.length===0)return;const He=Jn.anchor,Je=He!==null?Le.get(He)??-1:-1;H7(Ee[(Je+fe+Ee.length)%Ee.length])},[Bk,H7,Jn.anchor]),Kk=C.useCallback(fe=>{if(fe.key==="ArrowRight"||fe.key==="ArrowDown")fe.preventDefault(),Id(1);else if(fe.key==="ArrowLeft"||fe.key==="ArrowUp")fe.preventDefault(),Id(-1);else if(fe.key==="Enter"){const Ee=$r.current.selection.anchor;if(Ee!==null&&v){const Le=v;P1("onItemOpen",()=>Le(Ee))}}},[Id,v]),A5=C.useCallback(fe=>{if(jl({x:fe.x,y:fe.y,w:fe.width,h:fe.height}),$d.current=null,dn(fe.key),Pd(new Set([fe.key]),{additive:!1,key:fe.key}),b){const Ee=b;P1("onSelectZone",()=>Ee(fe.key))}},[jl,Pd,b]);C.useEffect(()=>{const fe=M1.current;if(!fe)return;const Ee=Le=>{Le.preventDefault(),ne();const He=fe.getBoundingClientRect(),Je=Le.clientX-He.left,at=Le.clientY-He.top;Ci("wheel"),xn.current=GV(xn.current,Math.exp(-Le.deltaY*.0015),Je,at,1,dT),zc()};return fe.addEventListener("wheel",Ee,{passive:!1}),()=>fe.removeEventListener("wheel",Ee)},[Ci,zc,ne]);const d0=C.useRef(null),f0=C.useRef(new Map),Dd=C.useRef(null),I4=C.useRef(!1),E1=C.useCallback((fe,Ee,Le)=>{var He,Je,at;if($r.current.size===null)return;const $t=xn.current,Yt=$r.current.fit*$t.zoom;if(Yt===0)return;const _n=fe.getBoundingClientRect(),Bn=Ee-_n.left,qt=Le-_n.top,tn=(Bn-$t.tx)/Yt,er=(qt-$t.ty)/Yt;for(const Ir of Ol){if(qn.has(Ir.key)||(L5.get(Ir.key)??Cc)!=="card")continue;const ai=_(Ir.footprint);if(ai===void 0||ai.type==="rect")continue;if(ai.type==="circle"?Math.hypot(tn-Ir.x,er-Ir.y)<=ai.value.radius:Q8e(tn,er,ai.value.vertices))return Ir.key}if(typeof document<"u"){const Ir=(Je=(He=document.elementFromPoint(Ee,Le))==null?void 0:He.closest("[data-card-key]"))==null?void 0:Je.getAttribute("data-card-key");if(Ir!=null&&!qn.has(Ir))return Ir}const gr=((at=Sc.current)==null?void 0:at.getContext("2d"))??null;gr!==null&&(gr.save(),gr.font=$ie);const br={ppu:Yt,tx:$t.tx,ty:$t.ty};let ma=null,Eo=1/0;for(const Ir of Ol){if(qn.has(Ir.key))continue;const ai=L5.get(Ir.key)??Cc;if(ai==="card")continue;const Do=eZe(Ir,ai,br,x2=>gr!==null?gr.measureText(x2).width:x2.length*6);if(!ROn(Do,Bn,qt))continue;const Ys=Math.hypot(Ir.x*Yt+$t.tx-Bn,Ir.y*Yt+$t.ty-qt);Ys<Eo&&(ma=Ir,Eo=Ys)}return gr!==null&&gr.restore(),ma==null?void 0:ma.key},[L5,Cc,Ol,qn]),Od=C.useCallback((fe,Ee,Le,He)=>{const Je=E1(fe,Ee,Le);if(Je===void 0)return!1;const at=He&&d==="multiple";let St;if(at?(St=new Set($r.current.selection.selected),St.has(Je)?St.delete(Je):St.add(Je)):St=new Set([Je]),h&&Ad(St),ar(St,{additive:at,key:Je,anchor:Je}),c){const $t=c;P1("onSelect",()=>$t(Je))}return!0},[E1,c,Ad,d,ar,h]),jd=C.useCallback(fe=>FOn(T1,fe,qn,$e),[T1,qn,$e]),Yk=C.useCallback(fe=>{if(fe.button===0){if(fe.pointerType==="touch"&&(f0.current.set(fe.pointerId,{x:fe.clientX,y:fe.clientY}),f0.current.size===2)){const[Ee,Le]=[...f0.current.values()];Dd.current={dist:Math.hypot(Ee.x-Le.x,Ee.y-Le.y)},d0.current=null,ja.current=null,I4.current=!0;return}if(ne(),fe.target.closest("button")===null){if(fe.currentTarget.setPointerCapture(fe.pointerId),I4.current=!1,$r.current.effectiveTool==="move"){const Ee=E1(fe.currentTarget,fe.clientX,fe.clientY);if(Ee!==void 0){Ci("cancel");const Le=$r.current,He=xn.current,Je=Le.fit*He.zoom,at=fe.currentTarget.getBoundingClientRect(),St=Je>0?(fe.clientX-at.left-He.tx)/Je:0,$t=Je>0?(fe.clientY-at.top-He.ty)/Je:0,Yt=Le.selection.selected.has(Ee)?[...Le.selection.selected]:[Ee],_n=new Map;for(const Bn of Yt){const qt=Le.centers.get(Bn);qt!==void 0&&_n.set(Bn,{x:qt.x,y:qt.y})}ja.current={key:Ee,keys:[..._n.keys()],orig:_n,startWorld:{x:St,y:$t}};return}}if(!fe.shiftKey&&$r.current.linkEditEnabled&&$r.current.selectedLink!==null){const Ee=$r.current,Le=Mt.find(at=>{var St;return at.key===((St=Ee.selectedLink)==null?void 0:St.key)}),He=xn.current,Je=Ee.fit*He.zoom;if(Le!==void 0&&Je>0){const at=fe.currentTarget.getBoundingClientRect(),St=fe.clientX-at.left,$t=fe.clientY-at.top,Yt=Ee.centers.get(Le.from),_n=Ee.centers.get(Le.to),Bn=tn=>tn!==void 0&&Math.hypot(tn.x*Je+He.tx-St,tn.y*Je+He.ty-$t)<=10,qt=Bn(Yt)?"from":Bn(_n)?"to":void 0;if(qt!==void 0){Ci("cancel");const tn=qt==="from"?Le.to:Le.from;Jr.current={from:tn,additive:!1,retarget:{key:Le.key,movingEnd:qt}},Io({from:tn,toWorld:{x:(St-He.tx)/Je,y:($t-He.ty)/Je},target:void 0});return}}}if($r.current.effectiveTool==="connect"){const Ee=E1(fe.currentTarget,fe.clientX,fe.clientY);if(Ee!==void 0){!fe.shiftKey&&xi.current!==null&&b2(),Ci("cancel");const Le=fe.currentTarget.getBoundingClientRect(),He=xn.current,Je=$r.current.fit*He.zoom,at=Je>0?(fe.clientX-Le.left-He.tx)/Je:0,St=Je>0?(fe.clientY-Le.top-He.ty)/Je:0;if(Jr.current={from:Ee,additive:fe.shiftKey},fe.shiftKey&&xi.current===null){const $t=$r.current.selectedLink;if($t!==null&&$t.leg===null){const Yt=At.find(_n=>_n.key===$t.key);if(Yt!==void 0&&(Yt.sources.includes(Ee)||Yt.destinations.includes(Ee)))Jr.current={from:Ee,additive:!0,netExtend:Yt.key};else{const _n=Mt.find(Bn=>Bn.key===$t.key);_n!==void 0&&(_n.from===Ee||_n.to===Ee)&&(xi.current={key:`net-${++Dl.current}`,links:[{key:_n.key,from:_n.from,to:_n.to}],drawn:"none",seeded:[_n.key]})}}}Io({from:Ee,toWorld:{x:at,y:St},target:void 0});return}}if($r.current.isBoxTool){Ci("cancel");const Ee=fe.currentTarget.getBoundingClientRect(),Le=fe.clientX-Ee.left,He=fe.clientY-Ee.top,Je=$r.current.effectiveTool==="marquee"?"marquee":"zoom";an.current={sx:Le,sy:He,mode:Je,additive:fe.shiftKey},to({rect:{x:Le,y:He,w:0,h:0},mode:Je,additive:fe.shiftKey,hits:w3});return}xi.current!==null&&b2(),Ci("pointerDown"),d0.current={x:fe.clientX,y:fe.clientY,tx:xn.current.tx,ty:xn.current.ty}}}},[Ci,E1,Mt,At,ne,b2]),ay=C.useCallback(fe=>{var Ee;const Le=fe.currentTarget;let He=null,Je;if(O!==void 0&&(Je=E1(Le,fe.clientX,fe.clientY),Je!==void 0&&(He="item")),He===null&&j!==void 0&&(Je=A4(Le,fe.clientX,fe.clientY),Je!==void 0&&(He="zone")),He===null&&B!==void 0&&(Je=(Ee=E5(Le,fe.clientX,fe.clientY))==null?void 0:Ee.key,Je!==void 0&&(He="link")),He===null||Je===void 0){Y();return}const at=Z.current;if(at!==null&&at.kind===He&&at.key===Je){ae();return}const St=`${He}:${Je}`;if(G.current!==null&&G.current.target===St)return;J();const $t=Le.getBoundingClientRect();let Yt=fe.clientX-$t.left,_n=fe.clientY-$t.top;if(He==="item"){const br=xn.current,ma=$r.current.fit*br.zoom,Eo=no.get(Je);Eo!==void 0&&ma>0&&(Yt=Eo.x*ma+br.tx,_n=Eo.y*ma+br.ty)}const Bn=He,qt=Je,tn=Yt,er=_n,gr=window.setTimeout(()=>{G.current=null,ae(),U({kind:Bn,key:qt,ax:tn,ay:er})},XOn);G.current={timer:gr,target:St}},[O,j,B,E1,A4,E5,no,Y,J,ae]),Xk=C.useCallback(fe=>{if(fe.pointerType==="touch"&&f0.current.has(fe.pointerId)){f0.current.set(fe.pointerId,{x:fe.clientX,y:fe.clientY});const at=Dd.current;if(at&&f0.current.size>=2){const[St,$t]=[...f0.current.values()],Yt=Math.hypot(St.x-$t.x,St.y-$t.y);if(Yt>0&&at.dist>0){const _n=fe.currentTarget.getBoundingClientRect(),Bn=(St.x+$t.x)/2-_n.left,qt=(St.y+$t.y)/2-_n.top;Ci("wheel"),xn.current=GV(xn.current,Yt/at.dist,Bn,qt,1,dT),zc()}at.dist=Yt;return}}const Ee=ja.current;if(Ee!==null){const St=fe.currentTarget.getBoundingClientRect(),$t=xn.current,Yt=$r.current.fit*$t.zoom;if(Yt>0){const _n=(fe.clientX-St.left-$t.tx)/Yt-Ee.startWorld.x,Bn=(fe.clientY-St.top-$t.ty)/Yt-Ee.startWorld.y;rt(qt=>{const tn=new Map(qt);for(const[er,gr]of Ee.orig)tn.set(er,{x:Math.min(Math.max(gr.x+_n,0),s),y:Math.min(Math.max(gr.y+Bn,0),l)});return tn})}return}const Le=Jr.current;if(Le!==null){const at=fe.currentTarget,St=at.getBoundingClientRect(),$t=xn.current,Yt=$r.current.fit*$t.zoom;if(Yt>0){const _n=(fe.clientX-St.left-$t.tx)/Yt,Bn=(fe.clientY-St.top-$t.ty)/Yt,qt=E1(at,fe.clientX,fe.clientY),tn=qt!==void 0&&qt!==Le.from&&(Le.retarget!==void 0&&Le.retarget.movingEnd==="from"?ge(qt,Le.from):ge(Le.from,qt)),er=tn?qt:void 0,gr=qt!==void 0&&qt!==Le.from&&!tn?qt:void 0;Io({from:Le.from,toWorld:{x:_n,y:Bn},target:er,...gr!==void 0?{forbidden:gr}:{}})}return}const He=an.current;if(He!==null){const at=fe.currentTarget.getBoundingClientRect(),St=fe.clientX-at.left,$t=fe.clientY-at.top;(Math.abs(St-He.sx)>4||Math.abs($t-He.sy)>4)&&(I4.current=!0);const Yt=Math.min(He.sx,St),_n=Math.min(He.sy,$t),Bn=Math.abs(St-He.sx),qt=Math.abs($t-He.sy);to(tn=>({rect:{x:Yt,y:_n,w:Bn,h:qt},mode:He.mode,additive:He.additive,hits:tn!==null?tn.hits:w3})),He.mode==="marquee"&&(hr.current={x0:Yt,y0:_n,sw:Bn,sh:qt},Rn.current===null&&(Rn.current=requestAnimationFrame(()=>{Rn.current=null;const tn=hr.current;if(tn===null||an.current===null)return;const er=xn.current,gr=$r.current.fit*er.zoom,br=tn.sw>6&&tn.sh>6&&gr>0?jd({minX:(tn.x0-er.tx)/gr,minY:(tn.y0-er.ty)/gr,maxX:(tn.x0+tn.sw-er.tx)/gr,maxY:(tn.y0+tn.sh-er.ty)/gr}):w3;to(ma=>ma===null?ma:{...ma,hits:br})})));return}const Je=d0.current;if(!Je){H&&ay(fe);return}(Math.abs(fe.clientX-Je.x)>4||Math.abs(fe.clientY-Je.y)>4)&&(I4.current=!0),xn.current={...xn.current,tx:Je.tx+fe.clientX-Je.x,ty:Je.ty+fe.clientY-Je.y},zc()},[zc,jd,E1,H,ay,s,l,ge,Ci]),W7=C.useCallback(()=>d0.current===null?!1:(d0.current=null,Ci("pointerUp"),!0),[Ci]),ED=C.useCallback(fe=>{fe.pointerType==="touch"&&(f0.current.delete(fe.pointerId),f0.current.size<2&&(Dd.current=null));const Ee=ja.current;if(Ee!==null){ja.current=null;const at=fe.currentTarget.getBoundingClientRect(),St=xn.current,$t=$r.current.fit*St.zoom;if($t>0){const Yt=(fe.clientX-at.left-St.tx)/$t-Ee.startWorld.x,_n=(fe.clientY-at.top-St.ty)/$t-Ee.startWorld.y;Gk(Ee,Yt,_n)}return}const Le=Jr.current;if(Le!==null){Jr.current=null,Io(null);const at=E1(fe.currentTarget,fe.clientX,fe.clientY);at!==void 0&&at!==Le.from&&(Le.retarget!==void 0&&Le.retarget.movingEnd==="from"?ge(at,Le.from):ge(Le.from,at))&&(Le.retarget!==void 0?ny(Le.retarget.key,Le.retarget.movingEnd,at):Le.netExtend!==void 0?ry(Le.netExtend,Le.from,at):ty(Le.from,at,Le.additive));return}const He=an.current;if(He!==null){an.current=null;const at=fe.currentTarget.getBoundingClientRect(),St=fe.clientX-at.left,$t=fe.clientY-at.top,Yt=Math.min(He.sx,St),_n=Math.min(He.sy,$t),Bn=Math.abs(St-He.sx),qt=Math.abs($t-He.sy);to(null);const tn=xn.current,er=$r.current.fit*tn.zoom,gr=Bn>6&&qt>6&&er>0;if(He.mode==="zoom"){gr?jl({x:(Yt-tn.tx)/er,y:(_n-tn.ty)/er,w:Bn/er,h:qt/er}):!Od(fe.currentTarget,fe.clientX,fe.clientY,fe.shiftKey)&&!fe.shiftKey&&On();return}if(gr){const br={minX:(Yt-tn.tx)/er,minY:(_n-tn.ty)/er,maxX:(Yt+Bn-tn.tx)/er,maxY:(_n+qt-tn.ty)/er},ma=jd(br),Eo=He.additive,Ir=Eo?new Set([...$r.current.selection.selected,...ma]):ma;h&&Ad(Ir),ar(Ir,{additive:Eo,region:br,...ma.size>0?{anchor:[...ma][ma.size-1]}:{}})}else if(!Od(fe.currentTarget,fe.clientX,fe.clientY,He.additive)){const br=E5(fe.currentTarget,fe.clientX,fe.clientY);if(br!==void 0)Xv(br.key,br.leg);else{const ma=A4(fe.currentTarget,fe.clientX,fe.clientY);ma!==void 0?ey(ma,He.additive):He.additive||(On(),T5(),me(null))}}return}if(!(!W7()||I4.current)&&!Od(fe.currentTarget,fe.clientX,fe.clientY,fe.shiftKey)){const at=E5(fe.currentTarget,fe.clientX,fe.clientY);if(at!==void 0)Xv(at.key,at.leg);else{const St=A4(fe.currentTarget,fe.clientX,fe.clientY);St!==void 0?ey(St,fe.shiftKey):fe.shiftKey||(On(),T5(),me(null))}}},[W7,Od,jl,Ad,jd,ar,On,h,A4,ey,T5,E1,ty,ny,E5,Xv,Gk,ge,ry]),Zk=C.useCallback(()=>{I4.current=!1;const fe=ja.current;fe!==null&&(ja.current=null,rt(Ee=>{const Le=new Map(Ee);for(const[He,Je]of fe.orig)Le.set(He,Je);return Le})),Jr.current=null,Io(null),an.current=null,to(null),W7()},[W7]),oy=C.useCallback(()=>{Ci("cancel"),xn.current=YE,zc()},[Ci,zc]),_D=C.useCallback(fe=>{if(v!==void 0){const Ee=E1(fe.currentTarget,fe.clientX,fe.clientY);if(Ee!==void 0){const Le=v;P1("onItemOpen",()=>Le(Ee));return}}oy()},[v,E1,oy]),_1=C.useCallback(fe=>{const Ee=$r.current.size;Ee!==null&&(Ci("zoom"),xn.current=GV(xn.current,fe,Ee.w/2,Ee.h/2,1,dT),zc())},[Ci,zc]);C.useEffect(()=>{b2()},[M,b2]),C.useEffect(()=>{Cr!=="connect"&&(Jr.current=null,Io(null),b2()),(Cr==="connect"&&!R||Cr==="move"&&!ie)&&Aa("grab")},[Cr,b2,R,ie]),C.useEffect(()=>{const fe=He=>{if(yr.current){if(He.code==="Space")He.preventDefault(),He.repeat||bo("grab");else if(He.key==="Control"&&!He.repeat)bo("zoom");else if((He.key==="Delete"||He.key==="Backspace")&&$r.current.selectedLink!==null)He.preventDefault(),$4();else if(He.key==="Escape")if(Z.current!==null)ne();else if(ja.current!==null){const Je=ja.current;ja.current=null,rt(at=>{const St=new Map(at);for(const[$t,Yt]of Je.orig)St.set($t,Yt);return St})}else Jr.current!==null?(Jr.current=null,Io(null)):an.current!==null?(an.current=null,to(null)):xi.current!==null?b2():($r.current.selection.selected.size>0||$r.current.zoneSelection.size>0||$r.current.selectedLink!==null)&&(On(),T5(),me(null))}},Ee=He=>{(He.code==="Space"||He.key==="Control")&&bo(null)},Le=()=>bo(null);return window.addEventListener("keydown",fe),window.addEventListener("keyup",Ee),window.addEventListener("blur",Le),()=>{window.removeEventListener("keydown",fe),window.removeEventListener("keyup",Ee),window.removeEventListener("blur",Le)}},[On,T5,b2,$4,ne]);const D4=C.useRef(!1),iy=C.useCallback((fe,Ee,Le)=>{const He=$r.current.size;if(He===null)return;const Je=fe.getBoundingClientRect(),at=(Ee-Je.left)/Je.width*s,St=(Le-Je.top)/Je.height*l,$t=xn.current;xn.current={...$t,tx:He.w/2-at*$r.current.fit*$t.zoom,ty:He.h/2-St*$r.current.fit*$t.zoom},zc()},[s,l,zc]);C.useEffect(()=>()=>{var fe;(fe=V7.current)==null||fe.cancel(),Qr.current!==null&&cancelAnimationFrame(Qr.current)},[Qr]),C.useEffect(()=>{if(!(lt&&Re==="pulse"))return;let fe=0;const Ee=performance.now(),Le=He=>{var Je;const at=(He-Ee)%Y8e/Y8e;P5.current=at,(Je=yo.current)==null||Je.style.setProperty("--pulse",String(Math.sin(at*Math.PI*2)*.5+.5)),kc(),fe=requestAnimationFrame(Le)};return fe=requestAnimationFrame(Le),()=>{var He;cancelAnimationFrame(fe),P5.current=0,(He=yo.current)==null||He.style.setProperty("--pulse","0"),kc()}},[lt,Re,kc]);const Qk=C.useMemo(()=>{if(!(lt&&Ye))return null;const fe=[];for(const Ee of t.items)!$e.has(Ee.key)&&!Zr.has(Ee.key)&&fe.push(Ee.key);return fe.sort(),fe.join("|")},[t.items,$e,Zr,lt,Ye]),sy=ft!==null;C.useEffect(()=>{const fe=pa.current;pa.current=!1;const Ee=$r.current.frameRect;!(lt&&Ye)||Ee===void 0||!sy||fe||jl({x:Ee.minX,y:Ee.minY,w:Math.max(.001,Ee.maxX-Ee.minX),h:Math.max(.001,Ee.maxY-Ee.minY)})},[Qk,lt,Ye,jl,sy]);const Jk=C.useCallback(fe=>{const Ee=$r.current.openZone===fe;$d.current=Ee?fe:null,dn(Ee?Ks.parentOf.get(fe)??null:fe)},[Ks.parentOf]);C.useEffect(()=>{if(_5!==void 0){if($d.current!==null){if($d.current===_5)return;$d.current=null}dn(_5)}},[_5]);const U7=C.useMemo(()=>{const fe=new Set;let Ee=st??void 0;for(;Ee!==void 0;)fe.add(Ee),Ee=Ks.parentOf.get(Ee);return fe},[st,Ks.parentOf]);C.useEffect(()=>{var fe,Ee;const Le=Jn.anchor;Le!==null&&((Ee=(fe=Il.current)==null?void 0:fe.querySelector(`[data-nav-key="${CSS.escape(Le)}"]`))==null||Ee.scrollIntoView({block:"nearest"}))},[Jn,U7]);const ez=(fe,Ee)=>{const Le=U7.has(fe.zone.key),He=fe.items.length+fe.children.reduce((at,St)=>at+St.items.length,0),Je=fe.items.length>0||fe.children.length>0;return p.jsxs(V,{children:[p.jsxs(V,{css:i.navZone,style:{paddingLeft:`${8+Ee*14}px`,top:`calc(var(--nav-row-h) * ${Ee})`,zIndex:30-Ee},...fe.zone.key===_5?{"data-current":""}:{},children:[Je?p.jsx(V,{as:"button",css:i.navCaret,"aria-label":Le?"Collapse zone":"Expand zone","data-open":Le?"":void 0,onClick:()=>Jk(fe.zone.key),children:p.jsx(Ut,{icon:BK})}):p.jsx(V,{css:i.navCaret,"aria-hidden":"true",style:{visibility:"hidden"},children:p.jsx(Ut,{icon:BK})}),p.jsx(V,{as:"button",css:i.navZoneLabel,onClick:()=>A5(fe.zone),children:MD.get(fe.zone.key)??fe.zone.label}),He>0&&p.jsx(V,{as:"span",css:i.navCount,children:He})]}),Le&&fe.children.map(at=>ez(at,Ee+1)),Le&&fe.items.map(at=>p.jsxs(V,{as:"button",css:i.navItem,"data-nav-key":at.key,style:{paddingLeft:`${30+Ee*14}px`},..._r.has(at.key)?{"data-selected":""}:{},onClick:()=>H7(at),children:[p.jsx(V,{as:"span",css:i.statusDot,"data-tone":ZV(at.status)??"neutral"}),at.label,at.metric.type==="some"&&p.jsx(V,{as:"span",css:i.navMetric,children:at.metric.value})]},at.key))]},fe.zone.key)},O4=p.jsxs(V,{css:i.root,...wt!==void 0?{style:{height:wt,maxHeight:Lt??wt}}:Lt!==void 0?{style:{maxHeight:Lt}}:{},children:[p.jsx(UOn,{onResolve:$l}),Be&&pr&&p.jsx(V,{css:i.navCollapsed,children:p.jsx(V,{as:"button",css:i.navToggle,"aria-label":"Expand index",title:"Show index",onClick:()=>Hr(!1),children:p.jsx(Ut,{icon:uoe})})}),Be&&!pr&&p.jsxs(V,{css:i.nav,children:[p.jsxs(V,{css:i.navHeader,children:[p.jsx(V,{as:"span",css:i.navTitle,children:"Index"}),p.jsx(V,{as:"button",css:i.navToggle,"aria-label":"Collapse index",title:"Hide index",onClick:()=>Hr(!0),children:p.jsx(Ut,{icon:foe})})]}),p.jsxs(V,{ref:Il,css:i.navTree,children:[Ks.roots.map(fe=>ez(fe,0)),Ks.floor.map(fe=>p.jsxs(V,{as:"button",css:i.navItem,"data-nav-key":fe.key,style:{paddingLeft:"8px"},..._r.has(fe.key)?{"data-selected":""}:{},onClick:()=>H7(fe),children:[p.jsx(V,{as:"span",css:i.statusDot,"data-tone":ZV(fe.status)??"neutral"}),fe.label]},fe.key))]})]}),p.jsxs(V,{ref:M1,css:i.canvas,"data-schematic-canvas":"",tabIndex:0,role:"application","aria-label":"Schematic canvas — arrow keys traverse items, Enter opens the selected item",onKeyDown:Kk,style:{...wt!==void 0?{minHeight:0}:{aspectRatio:`${s} / ${l}`},...(ta==null?void 0:ta.forbidden)!==void 0?{cursor:"not-allowed"}:Gs||qr==="connect"?{cursor:"crosshair"}:qr==="move"?{cursor:"move"}:{}},onPointerEnter:()=>{yr.current=!0},onPointerLeave:()=>{yr.current=!1,bo(null),Y()},onPointerDown:Yk,onPointerMove:Xk,onPointerUp:ED,onPointerCancel:Zk,onLostPointerCapture:Zk,onDoubleClick:_D,children:[Te&&ft!==null&&p.jsx(V,{ref:il,css:i.grid}),ft!==null&&p.jsxs(p.Fragment,{children:[p.jsx("canvas",{ref:Sc,style:{position:"absolute",inset:0,width:"100%",height:"100%"}}),p.jsx(V,{ref:yo,css:i.cardLayer,children:Ol.map(fe=>{if((L5.get(fe.key)??Cc)!=="card")return null;const Ee=ZV(fe.status),Le=Wk.has(fe.key),He=lt&&Et==="keep"&&$e.has(fe.key),Je=lt&&Re!==void 0&&!$e.has(fe.key),at=qn.has(fe.key),St=(He?Gt:1)*(ca.get(fe.key)??1),$t=_(fe.sublabel),Yt=_(fe.icon),_n=_(fe.meter),Bn=_(fe.metric),qt=_(fe.width),tn=Yt!==void 0?x$e({prefix:"fas",iconName:Yt}):void 0;return p.jsxs(V,{css:i.item,"data-card-key":fe.key,...Le?{"data-selected":""}:{},...Je?{"data-emphasis":Re}:{},...He?{"data-excluded":""}:{},...(ta==null?void 0:ta.forbidden)===fe.key?{"data-forbidden":""}:{},style:{left:0,top:0,transform:`${COn(fe.x,fe.y)} translate(-50%, -50%)`,...typeof qt=="number"?{width:kOn(qt)}:{},...St<1?{opacity:St}:{},...He&&Ke?{filter:"grayscale(1)"}:{},...at?{pointerEvents:"none"}:{}},children:[p.jsxs(V,{css:i.itemHead,children:[tn!==void 0&&p.jsx(V,{as:"span",css:i.itemIcon,children:p.jsx(Ut,{icon:tn})}),p.jsx(V,{as:"span",css:i.itemLabel,children:fe.label}),Ee!==void 0&&p.jsx(V,{as:"span",css:i.statusDot,"data-tone":Ee})]}),$t!==void 0&&p.jsx(V,{css:i.itemSublabel,children:$t}),_n!==void 0&&p.jsx(V,{css:i.meterTrack,children:p.jsx(V,{css:i.meterFill,style:{width:`${_n.max>0?Math.min(100,_n.value/_n.max*100):0}%`}})}),Bn!==void 0&&p.jsx(V,{css:i.itemMetric,children:Bn})]},fe.key)})}),Na!==null&&p.jsx(V,{css:i.selectBox,"data-mode":qr==="marquee"?"marquee":"zoom",style:{left:Na.x,top:Na.y,width:Na.w,height:Na.h},"aria-hidden":"true",children:qr==="marquee"&&Go>0&&p.jsx(V,{as:"span",css:i.selectBoxCount,children:Go})}),K!==null&&te!==null&&p.jsx(V,{css:i.hoverCard,style:{left:Math.round(K.ax),top:Math.round(K.ay),transform:`translate(${K.ax>ft.w*.6?"calc(-100% - 12px)":"12px"}, ${K.ay>ft.h*.6?"calc(-100% - 12px)":"12px"})`},onPointerEnter:ae,onPointerLeave:Y,onPointerMove:fe=>fe.stopPropagation(),onPointerDown:fe=>fe.stopPropagation(),children:p.jsx(mn,{value:te,storageKey:`${n}.hover.${K.kind}`})}),p.jsxs(V,{css:i.controls,children:[p.jsxs(V,{css:i.controlGroup,children:[p.jsx(V,{as:"button",css:i.controlButton,...Cr==="grab"?{"data-active":""}:{},"aria-label":"Grab / pan tool","aria-pressed":Cr==="grab",title:"Grab — drag to pan (hold Space)",onClick:()=>Aa("grab"),children:p.jsx(Ut,{icon:Pae})}),p.jsx(V,{as:"button",css:i.controlButton,...Cr==="zoom"?{"data-active":""}:{},"aria-label":"Zoom-region tool","aria-pressed":Cr==="zoom",title:"Zoom — drag a box to zoom in (hold Ctrl)",onClick:()=>Aa("zoom"),children:p.jsx(Ut,{icon:xVe})})]}),f&&p.jsxs(V,{css:i.controlGroup,children:[p.jsx(V,{as:"button",css:i.controlButton,...Cr==="marquee"?{"data-active":""}:{},"aria-label":"Select-region tool","aria-pressed":Cr==="marquee",title:"Select region — drag a box (Shift adds)",onClick:()=>Aa("marquee"),children:p.jsx(Ut,{icon:wDe})}),_r.size>0&&p.jsx(V,{as:"button",css:i.controlButton,"aria-label":"Clear selection",title:"Clear selection (Esc)",onClick:On,children:p.jsx(Ut,{icon:c0})})]}),(R||ie)&&p.jsxs(V,{css:i.controlGroup,children:[R&&p.jsx(V,{as:"button",css:i.controlButton,...Cr==="connect"?{"data-active":""}:{},"aria-label":"Connect tool","aria-pressed":Cr==="connect",title:"Connect — drag from item to item (Shift adds to the session)",onClick:()=>Aa("connect"),children:p.jsx(Ut,{icon:Rae})}),ie&&p.jsx(V,{as:"button",css:i.controlButton,...Cr==="move"?{"data-active":""}:{},"aria-label":"Move tool","aria-pressed":Cr==="move",title:"Move — drag an item (a selected item moves the whole selection)",onClick:()=>Aa("move"),children:p.jsx(Ut,{icon:Nae})})]}),p.jsx(V,{as:"button",css:i.controlButton,"aria-label":"Zoom in",title:"Zoom in (scroll)",onClick:()=>_1(1.5),children:p.jsx(Ut,{icon:m5})}),p.jsx(V,{as:"button",css:i.controlButton,"aria-label":"Zoom out",title:"Zoom out (scroll)",onClick:()=>_1(1/1.5),children:p.jsx(Ut,{icon:m$})}),p.jsx(V,{as:"button",css:i.controlButton,"aria-label":"Fit view",title:"Fit view (double-click)",onClick:oy,children:p.jsx(Ut,{icon:w$})}),vr&&p.jsx(V,{as:"button",css:i.controlButton,...vo?{"data-active":""}:{},"aria-label":"Layers","aria-expanded":gt,title:"Layers",onClick:()=>Ot(fe=>!fe),children:p.jsx(Ut,{icon:j$})}),_r.size>0&&p.jsxs(V,{css:i.controlGroup,children:[p.jsx(V,{as:"button",css:i.controlButton,"aria-label":"Previous item",title:"Previous item",onClick:()=>Id(-1),children:p.jsx(Ut,{icon:kd})}),p.jsx(V,{as:"button",css:i.controlButton,"aria-label":"Next item",title:"Next item",onClick:()=>Id(1),children:p.jsx(Ut,{icon:r2})})]})]}),vr&>&&p.jsxs(V,{css:i.layerPanel,onPointerDown:fe=>fe.stopPropagation(),children:[p.jsxs(V,{css:i.layerHeader,children:[p.jsx(V,{as:"span",css:i.layerTitle,children:"Layers"}),p.jsx(V,{as:"button",css:i.layerReset,onClick:Wa,children:"Show all"})]}),lr.map(fe=>{var Ee;const Le=sa.has(fe.key),He=Qt===fe.key,Je=Fe[fe.key]??vn(fe.key),at=((Ee=_(fe.tone))==null?void 0:Ee.type)??"muted";return p.jsxs(V,{css:i.layerRow,...Le?{"data-hidden":""}:{},children:[p.jsx(V,{as:"span",css:i.layerSwatch,"data-tone":at}),p.jsx(V,{as:"span",css:i.layerLabel,children:fe.label}),p.jsx(V,{as:"span",css:i.layerCount,children:Ya.get(fe.key)??0}),p.jsx(V,{as:"button",css:i.layerToggle,...He?{"data-active":""}:{},"aria-label":"Isolate layer",title:"Isolate",onClick:()=>Ma(fe.key),children:p.jsx(Ut,{icon:EOe})}),p.jsx(V,{as:"button",css:i.layerToggle,...Je?{"data-active":""}:{},"aria-label":Je?"Unlock layer":"Lock layer",title:Je?"Locked (click to unlock)":"Lock (non-selectable on canvas)",onClick:()=>fi(fe.key),children:p.jsx(Ut,{icon:Je?Jae:Wje})}),p.jsx(V,{as:"button",css:i.layerToggle,"aria-label":Le?"Show layer":"Hide layer",title:Le?"Show":"Hide",onClick:()=>Ha(fe.key),children:p.jsx(Ut,{icon:Le?loe:yae})})]},fe.key)})]}),Me!==void 0&&R5>0&&(()=>{const fe=R5*Nr,Ee=(Le,He)=>`M ${fe*Le/4} 6.5 V ${He}`;return p.jsxs(V,{css:i.scaleBar,children:[p.jsxs(V,{as:"span",css:i.scaleLabel,children:[R5," ",Me]}),p.jsx(V,{as:"svg",css:i.scaleRuler,width:fe,height:7,viewBox:`0 0 ${fe} 7`,children:p.jsx("path",{d:`M 0.5 0 V 6.5 H ${fe-.5} V 0 ${Ee(1,3)} ${Ee(2,1.5)} ${Ee(3,3)}`,fill:"none"})})]})})(),ht&&p.jsxs(V,{css:i.minimap,title:"Jump to a location",style:{width:150,height:150*l/s},onPointerDown:fe=>{fe.stopPropagation();const Ee=fe.currentTarget;Ee.setPointerCapture(fe.pointerId),Ci("cancel"),D4.current=!0,iy(Ee,fe.clientX,fe.clientY)},onPointerMove:fe=>{D4.current&&(fe.stopPropagation(),iy(fe.currentTarget,fe.clientX,fe.clientY))},onPointerUp:fe=>{D4.current=!1,fe.currentTarget.releasePointerCapture(fe.pointerId)},children:[Oa.map(fe=>p.jsx(V,{css:i.minimapZone,style:{left:`${fe.x/s*100}%`,top:`${fe.y/l*100}%`,width:`${fe.width/s*100}%`,height:`${fe.height/l*100}%`}},fe.key)),ft!==null&&p.jsx(V,{css:i.minimapViewport,style:{left:`${Math.max(0,-cr.tx/Nr/s*100)}%`,top:`${Math.max(0,-cr.ty/Nr/l*100)}%`,width:`${Math.min(100,ft.w/Nr/s*100)}%`,height:`${Math.min(100,ft.h/Nr/l*100)}%`}})]})]})]})]});return ut?p.jsxs(V,{css:{...Ve.root,display:"flex",flexDirection:"column",minHeight:0,...wt!==void 0?{height:wt,maxHeight:Lt??wt}:Lt!==void 0?{maxHeight:Lt}:{}},children:[p.jsx(V,{css:{...Ve.frameEyebrow,flexShrink:0},children:Ft}),p.jsx(V,{css:{...Ve.frameBody,flex:"1 1 0%",minHeight:0,position:"relative"},children:O4})]}):O4},(e,t)=>qOn(e.value,t.value)&&e.storageKey===t.storageKey),Es=e=>e.type==="some"?e.value:void 0;function tjn(e,t,n){if(e===void 0||e<=0||n<=0)return 1.4;if(n<=t)return 2;const r=(Math.log1p(e)-Math.log1p(t))/(Math.log1p(n)-Math.log1p(t));return r>=.8?2.5:r>=.4?2:1.6}function njn(e){return e>=1e3?e.toLocaleString(void 0,{maximumFractionDigits:0}):e.toLocaleString(void 0,{maximumFractionDigits:1})}function rjn(e){return Number(e).toLocaleString()}function J8e(e,t,n){return`${e}→${t}#${n}`}function ajn(e){const t=e.lanes.map(b=>({key:b.key,label:Es(b.label)??b.key.toUpperCase()})),n=new Map(t.map((b,y)=>[b.key,y])),r=new Array(Math.max(t.length,1)).fill(0),a=[],o=new Map,i=b=>{const y=r[b]??0;return r[b]=y+1,y};for(const b of e.states){const y=n.get(b.lane)??Math.max(t.length-1,0),x={key:b.key,label:Es(b.label),laneIndex:y,laneOrder:i(y),members:Es(b.members),notes:Es(b.notes),inPlaceKeys:[],ghost:!1};a.push(x),o.set(x.key,x)}const s=[],l=e.links.map(b=>{const y=Es(b.evidence);return y?Es(y.volume):void 0}).filter(b=>b!==void 0&&b>0),c=l.length>0?Math.max(...l):0,u=l.length>0?Math.min(...l):0,d=(b,y)=>{if(o.has(b))return;const x=Math.min(Math.max(y,0),Math.max(t.length-1,0)),S={key:b,label:"No state row",laneIndex:x,laneOrder:i(x),members:void 0,notes:void 0,inPlaceKeys:[],ghost:!0};a.push(S),o.set(b,S)};let f=0,h=0,g=0;e.links.forEach((b,y)=>{var x;if(b.from===b.to){const j=o.get(b.from);j&&j.inPlaceKeys.push(Es(b.key)??J8e(b.from,b.to,y));return}const S=!o.has(b.from)||!o.has(b.to);if(S){const j=o.get(b.from)??o.get(b.to),B=j?j.laneIndex+1:0;d(b.from,B),d(b.to,B)}const z=((x=Es(b.kind))==null?void 0:x.type)??"planned",M=S?"unresolved":z;M==="planned"?f+=1:M==="observed"?h+=1:g+=1;const L=Es(b.evidence),R=L?Es(L.volume):void 0,N=L?Es(L.count):void 0,O=L?Es(L.unit):void 0;s.push({key:Es(b.key)??J8e(b.from,b.to,y),from:b.from,to:b.to,cls:M,trigger:Es(b.trigger),evidence:L,weight:M==="unresolved"?1.4:tjn(R,u,c),badgeText:R!==void 0?`${njn(R)}${O!==void 0?` ${O}`:""}${N!==void 0?` · ${rjn(N)}`:""}`:void 0})});const v=new Map;for(const b of e.triggers)v.set(b.key,{key:b.key,label:b.label,letter:Es(b.letter)??(b.label.length>0?b.label.charAt(0).toUpperCase():"?"),owner:Es(b.owner),queue:Es(b.queue)??[],outcomes:Es(b.outcomes),governs:s.filter(y=>y.trigger===b.key).map(y=>y.key)});return{lanes:t.length>0?t:[{key:"",label:""}],nodes:a,nodesByKey:o,links:s,triggers:v,counts:{total:s.length,planned:f,observed:h,unresolved:g}}}const fT=116,pT=40,ojn=8,ijn=4,epe=16,sjn=166,Sb=40,ljn=96,tpe=48,QV=78,op=3.5,M3=18,Tu=e=>Math.round(e*2)/2;function npe(e,t,n,r,a){const o=e+n/2,i=t+r/2;return{key:a,x:e,y:t,w:n,h:r,cx:o,cy:i,left:{x:e,y:i},right:{x:e+n,y:i},top:{x:o,y:t},bottom:{x:o,y:t+r}}}function Iie(e){if(e.length<2)return{d:"",segs:[]};const t=[];for(let a=0;a<e.length-1;a++){const o=e[a],i=e[a+1];t.push({a:o,b:i})}const n=e[0];let r=`M${Tu(n.x)} ${Tu(n.y)}`;for(let a=1;a<e.length;a++){const o=e[a-1],i=e[a],s=e[a+1];if(s===void 0){r+=`L${Tu(i.x)} ${Tu(i.y)}`;break}const l=Math.abs(i.x-o.x)+Math.abs(i.y-o.y),c=Math.abs(s.x-i.x)+Math.abs(s.y-i.y),u=Math.max(ijn,Math.min(ojn,l/2,c/2)),d=Math.sign(i.x-o.x),f=Math.sign(i.y-o.y),h=Math.sign(s.x-i.x),g=Math.sign(s.y-i.y);r+=`L${Tu(i.x-d*u)} ${Tu(i.y-f*u)}`,r+=`Q${Tu(i.x)} ${Tu(i.y)} ${Tu(i.x+h*u)} ${Tu(i.y+g*u)}`}return{d:r,segs:t}}function oZe(e){if(e.length<2)return e;const t=e.map(i=>({...i})),n=t[0],r=t[1];n.x+=Math.sign(r.x-n.x)*op,n.y+=Math.sign(r.y-n.y)*op;const a=t[t.length-1],o=t[t.length-2];return a.x+=Math.sign(o.x-a.x)*op,a.y+=Math.sign(o.y-a.y)*op,t}function cjn(e){let t,n=-1;for(const r of e){const a=Math.abs(r.b.x-r.a.x)+Math.abs(r.b.y-r.a.y);a>n&&(n=a,t=r)}return t?{x:(t.a.x+t.b.x)/2,y:(t.a.y+t.b.y)/2}:{x:0,y:0}}const oS={left:{x:-1,y:0},right:{x:1,y:0},top:{x:0,y:-1},bottom:{x:0,y:1}},rpe=["left","right","top","bottom"];function iZe(e){const t=[];for(const n of e){const r=t.length;if(!(r>0&&t[r-1].x===n.x&&t[r-1].y===n.y)){if(r>1){const a=t[r-2],o=t[r-1];if(a.x===o.x&&o.x===n.x||a.y===o.y&&o.y===n.y){t[r-1]=n;continue}}t.push(n)}}return t}function sZe(e,t){let n;for(const r of rpe)for(const a of rpe){const o=e[r],i=t[a],s=oS[r],l=oS[a],c=s.x*(t.cx-o.x)+s.y*(t.cy-o.y)>0,u=l.x*(e.cx-i.x)+l.y*(e.cy-i.y)>0;if(!c||!u)continue;const d=Math.abs(o.x-i.x)+Math.abs(o.y-i.y);(n===void 0||d<n.d)&&(n={sa:r,sb:a,d})}return n??{sa:"right",sb:"left"}}function lZe(e,t,n,r,a){const o=e[n],i=t[r],s=oS[n],l=oS[r];let c;if(s.x!==0&&l.x!==0){const u=a??(o.x+i.x)/2;c=o.y===i.y?[o,i]:[o,{x:u,y:o.y},{x:u,y:i.y},i]}else if(s.y!==0&&l.y!==0){const u=(o.y+i.y)/2;c=o.x===i.x?[o,i]:[o,{x:o.x,y:u},{x:i.x,y:u},i]}else s.x!==0?c=[o,{x:i.x,y:o.y},i]:c=[o,{x:o.x,y:i.y},i];return iZe(c)}function ujn(e,t){const{sa:n,sb:r}=sZe(e,t);return Iie(oZe(lZe(e,t,n,r))).d}function djn(e,t,n){const r=e[t],a=oS[t];let o;if(a.x!==0){const i=(r.x+n.x)/2;o=Math.abs(n.y-r.y)<2?[r,n]:[r,{x:i,y:r.y},{x:i,y:n.y},n]}else{const i=(r.y+n.y)/2;o=Math.abs(n.x-r.x)<2?[r,n]:[r,{x:r.x,y:i},{x:n.x,y:i},n]}if(o=iZe(o),o.length>=2){const i=o[0],s=o[1];o[0]={x:i.x+Math.sign(s.x-i.x)*op,y:i.y+Math.sign(s.y-i.y)*op}}return Iie(o).d}function fjn(e,t){const n=new Map,r=new Map;for(const a of e){const o=t(a.from),i=t(a.to);if(!o||!i||o.laneIndex===i.laneIndex)continue;const s=o.laneIndex<i.laneIndex?i.laneIndex:i.laneIndex+1;let l=n.get(s);l===void 0&&(l=new Map,n.set(s,l)),l.set(a.key,l.size),r.set(s,l.size)}return{order:n,count:r}}const ape=(e,t,n)=>e.x-n<t.x+t.w&&e.x+e.w+n>t.x&&e.y-n<t.y+t.h&&e.y+e.h+n>t.y;function pjn(e,t){var n;const r=t.orientation==="TD",a=r?pT:fT,o=r?fT:pT,i=r?112:sjn,s=J=>r?{x:J.y,y:J.x}:J,l=Math.max(e.lanes.length,1),c=Math.max(1,...e.nodes.map(J=>J.laneOrder+1));let u=r?168:ljn;if(r){const J=t.width-Sb-16-tpe;J>c*u&&(u=Math.min(260,Math.floor(J/c)))}const d=r?Number.POSITIVE_INFINITY:t.width-QV,f=Math.max(i,Number.isFinite(d)?Math.floor(d/l):i);let h=Sb+16+c*u+tpe;!r&&t.minHeight!==void 0&&(h=Math.max(h,t.minHeight-(t.legendPad??0))),r&&(h=Math.max(h,t.width));const g=l*f+QV,v=h+(r?0:t.legendPad??0),b=e.lanes.map((J,ae)=>{const ne=s({x:ae*f,y:0}),Y=s({x:(ae+1)*f,y:v});return{key:J.key,label:J.label,x:Math.min(ne.x,Y.x),y:Math.min(ne.y,Y.y),w:Math.abs(Y.x-ne.x),h:Math.abs(Y.y-ne.y),tinted:ae%2===1,cx:ae*f+f/2}}),y=new Map,x=new Map;for(const J of e.nodes){const ne=Math.min(J.laneIndex,l-1)*f+f/2-a/2,Y=Sb+16+J.laneOrder*u;x.set(J.key,npe(ne,Y,a,o,J.key));const te=s({x:ne,y:Y});y.set(J.key,npe(te.x,te.y,fT,pT,J.key))}const S=r?g:h,z=new Map;for(let J=0;J<e.lanes.length;J++){const ae=e.nodes.reduce((ue,oe)=>oe.laneIndex===J?Math.max(ue,oe.laneOrder+1):ue,0),Y=J*f+f/2-a/2,te=Sb+16+ae*u,ie=s({x:Y,y:te});z.set(e.lanes[J].key,{x:ie.x,y:ie.y,w:fT,h:pT})}const M=fjn(e.links,J=>e.nodesByKey.get(J)),L=(J,ae)=>{const ne=(J-1)*f+f/2+a/2,Y=J*f+f/2-a/2,ie=((M.count.get(J)??1)-1)*epe;return(ne+Y)/2-ie/2+ae*epe},R=J=>r?J==="left"?"top":J==="right"?"bottom":J==="top"?"left":"right":J,N=new Map,O=(J,ae,ne)=>{let Y=N.get(J);Y===void 0&&(Y=new Map,N.set(J,Y));const te=R(ae),ie=Y.get(te)??[];ie.push(ne),Y.set(te,ie)},j=[];for(const J of e.links){const ae=x.get(J.from),ne=x.get(J.to);if(!ae||!ne)continue;const Y=e.nodesByKey.get(J.from),te=e.nodesByKey.get(J.to),ie=sZe(ae,ne),ue=ie.sa,oe=ie.sb,ve=ae[ue],se=ne[oe];let pe;if(ue!==oe&&(ue==="left"||ue==="right")&&(oe==="left"||oe==="right")&&Y.laneIndex!==te.laneIndex){const Te=Y.laneIndex<te.laneIndex?te.laneIndex:te.laneIndex+1,Be=(n=M.order.get(Te))==null?void 0:n.get(J.key);Be!==void 0&&(pe=L(Te,Be))}const de=lZe(ae,ne,ue,oe,pe);O(J.from,ue,J.key),O(J.to,oe,J.key);const ge=oZe(de.map(s)),{d:ye}=Iie(ge),me=[],Me=de.map(s);for(let Te=0;Te<Me.length-1;Te++)me.push({a:Me[Te],b:Me[Te+1]});j.push({key:J.key,d:ye,end:s(se),segs:me,mid:cjn(me),ports:[s(ve),s(se)]})}const B=new Map;for(const[J,ae]of N){const ne=y.get(J);if(!ne)continue;const Y=[];for(const[te,ie]of ae)Y.push({side:te,pt:ne[te],links:ie});B.set(J,Y)}const H=J=>J.length*5.8+14,K=[...y.values()].map(J=>({x:J.x,y:J.y,w:J.w,h:J.h}));r?K.push({x:0,y:0,w:108,h:S}):K.push({x:0,y:0,w:g,h:Sb});for(const J of B.values())for(const ae of J)K.push({x:ae.pt.x-6,y:ae.pt.y-6,w:12,h:12});for(const J of e.links){if(J.trigger===void 0)continue;const ae=j.find(ne=>ne.key===J.key);ae&&K.push({x:ae.mid.x-14,y:ae.mid.y-14,w:28,h:28})}for(const J of e.links){if(J.badgeText===void 0)continue;const ae=j.find(ie=>ie.key===J.key);if(!ae)continue;const ne=H(J.badgeText),Y=[...ae.segs].sort((ie,ue)=>Math.abs(ue.b.x-ue.a.x)+Math.abs(ue.b.y-ue.a.y)-(Math.abs(ie.b.x-ie.a.x)+Math.abs(ie.b.y-ie.a.y)));let te;e:for(const ie of Y){const ue=Math.abs(ie.b.x-ie.a.x)<Math.abs(ie.b.y-ie.a.y);for(const oe of[.5,.32,.68]){const ve=ie.a.x+(ie.b.x-ie.a.x)*oe,se=ie.a.y+(ie.b.y-ie.a.y)*oe,pe=ue?{x:ve,y:se}:{x:ve,y:se-M3/2-4},de={x:pe.x-ne/2,y:pe.y-M3/2,w:ne,h:M3};if(!K.some(ge=>ape(de,ge,4))){te=pe;break e}}}if(te===void 0){const ie=Y[0],ue=Math.abs(ie.b.x-ie.a.x)<Math.abs(ie.b.y-ie.a.y);e:for(const oe of[22,-22,40,-40,58,-58,76,-76,94,-94,112,-112]){const ve=ue?{x:ae.mid.x+oe,y:ae.mid.y}:{x:ae.mid.x,y:ae.mid.y+oe},se={x:ve.x-ne/2,y:ve.y-M3/2,w:ne,h:M3};if(!K.some(pe=>ape(se,pe,4))){te=ve;break e}}te??(te={x:ae.mid.x,y:ae.mid.y+26})}ae.badge=te,K.push({x:te.x-ne/2,y:te.y-M3/2,w:ne,h:M3})}const U=s({x:l*f+8,y:14}),Z=s({x:l*f+QV-8,y:v-14}),G=r?h:g,W=(r?g:h)+(t.legendPad??0);return{width:G,height:W,orientation:t.orientation,lanes:b,nodes:y,routes:j,handles:B,laneGhosts:z,laneTail:{x:Math.min(U.x,Z.x),y:Math.min(U.y,Z.y),w:Math.abs(Z.x-U.x),h:Math.abs(Z.y-U.y)}}}const hT=14;function hjn(e,t,n){let r=null;for(const[a,o]of e.nodes)a!==n&&t.x>=o.x-hT&&t.x<=o.x+o.w+hT&&t.y>=o.y-hT&&t.y<=o.y+o.h+hT&&(r=a);return r}function gjn(e,t,n){var r;return(r=e.links.find(a=>a.from===t&&a.to===n))==null?void 0:r.key}function mjn(e,t){for(const n of e.lanes)if(t.x>=n.x&&t.x<=n.x+n.w&&t.y>=n.y&&t.y<=n.y+n.h)return n.key;return null}const vjn=it(zte.Types.Flowchart);function P2(e,t){queueMicrotask(()=>{try{const n=t();n instanceof Promise&&n.catch(r=>console.error(`[Flowchart] ${e} callback failed:`,r))}catch(n){console.error(`[Flowchart] ${e} callback failed:`,n)}})}const zm="var(--fc-ink)",yjn="var(--fc-ink3)",Yh="var(--fc-ink4)",Cb="var(--fc-paper)",bjn="var(--fc-lane)",cZe="var(--fc-rule-strong)",C9="var(--fc-info)",JV="var(--fc-brand)",T3="var(--fc-brand-d)",xjn="var(--fc-brand-dd)",k9="var(--fc-neg)",wjn={planned:zm,observed:C9,unresolved:k9},Sjn={planned:void 0,observed:"5 4",unresolved:"4 4"},Cjn={planned:"ink",observed:"info",unresolved:"neg"},kb="var(--chakra-fonts-mono)",kjn=400,zjn=250,gT=1,oX=.45,Mjn=.15,Tjn={active:!1,restLevel:oX,nodes:new Set,links:new Set};function Ejn(e,t){if(t===null)return Tjn;const n=new Set,r=new Set;if(t.kind==="state"){n.add(t.key);for(const o of e.links)(o.from===t.key||o.to===t.key)&&(r.add(o.key),n.add(o.from),n.add(o.to));return{active:!0,restLevel:oX,nodes:n,links:r}}if(t.kind==="link"){const o=e.links.find(i=>i.key===t.key);return o&&(r.add(o.key),n.add(o.from),n.add(o.to)),{active:!0,restLevel:oX,nodes:n,links:r}}const a=e.triggers.get(t.key);if(a){for(const o of a.governs){r.add(o);const i=e.links.find(s=>s.key===o);i&&(n.add(i.from),n.add(i.to))}for(const o of a.queue)n.add(o)}return{active:!0,restLevel:Mjn,nodes:n,links:r}}function _jn(e,t){return e.some(n=>n.key===t)?T3:e.length>0&&e.every(n=>n.cls==="observed")?C9:e.length>0&&e.every(n=>n.cls==="unresolved")?k9:zm}function Ljn(e,t){return t?{stroke:T3,dash:void 0,text:xjn}:e==="observed"?{stroke:C9,dash:"4 3",text:C9}:e==="unresolved"?{stroke:k9,dash:"4 3",text:k9}:{stroke:cZe,dash:void 0,text:zm}}const Rjn=C.memo(function({value:t,storageKey:n}){var r,a,o;const i=en({key:"flowchart"})(),s=C.useMemo(()=>ajn(t),[t]),l=((r=_(t.orientation))==null?void 0:r.type)??"LR",c=_(t.freshness),u=_(t.legend)??!0,d=_(t.minimap),f=(a=_(t.density))==null?void 0:a.type,h=Tt(_(t.height)),g=Tt(_(t.maxHeight)),v=(o=_(t.linkMode))==null?void 0:o.type,b=_(t.readOnly)??!1,y=C.useMemo(()=>_(t.onSelectState),[t.onSelectState]),x=C.useMemo(()=>_(t.onSelectLink),[t.onSelectLink]),S=C.useMemo(()=>_(t.onSelectTrigger),[t.onSelectTrigger]),z=C.useMemo(()=>_(t.onTracePath),[t.onTracePath]),M=C.useMemo(()=>_(t.onAddLane),[t.onAddLane]),L=C.useMemo(()=>_(t.onRenameLane),[t.onRenameLane]),R=C.useMemo(()=>_(t.onDeleteLane),[t.onDeleteLane]),N=C.useMemo(()=>_(t.onAddState),[t.onAddState]),O=C.useMemo(()=>_(t.onEditState),[t.onEditState]),j=C.useMemo(()=>_(t.onMoveState),[t.onMoveState]),B=N!==void 0&&!b,H=O!==void 0&&!b,K=j!==void 0&&!b,U=C.useMemo(()=>_(t.onCreateLink),[t.onCreateLink]),Z=C.useMemo(()=>_(t.onDeleteLink),[t.onDeleteLink]),G=C.useMemo(()=>_(t.canConnect),[t.canConnect]),W=C.useMemo(()=>_(t.stateHover),[t.stateHover]),J=C.useMemo(()=>_(t.linkHover),[t.linkHover]),ae=C.useMemo(()=>_(t.triggerHover),[t.triggerHover]),ne=_(t.slice),Y=ne==null?void 0:ne.slice,te=rl(Y==null?void 0:Y.key),ie=C.useMemo(()=>(ne==null?void 0:ne.affordances.map(Fe=>Fe.type))??[],[ne]),ue=C.useMemo(()=>Y!==void 0?p.jsx(AL.Provider,{value:"compact",children:p.jsx(zd,{slice:Y,affordanceKinds:ie})}):null,[Y,ie,te]),oe=Y!==void 0?Number(Y.totalCount()):void 0,ve=Y!==void 0?Number(Y.resultCount()??Y.totalCount()):void 0,[se,pe]=C.useState(l);C.useEffect(()=>{pe(l)},[l]);const[de,ge]=C.useState(null),ye=C.useRef(null);ye.current=de;const me=C.useRef(!1);me.current=b;const[Me,Te]=C.useState(null),[Be,ht]=C.useState(null),De=C.useRef(null),Qe=C.useRef(null),bt=C.useCallback(()=>{De.current!==null&&(clearTimeout(De.current),De.current=null),Qe.current!==null&&(clearTimeout(Qe.current),Qe.current=null)},[]);C.useEffect(()=>bt,[bt]);const Ve=C.useCallback(Fe=>Fe==="state"?W:Fe==="link"?J:ae,[W,J,ae]),ut=C.useCallback((Fe,Qt,tt,gt)=>{Ve(Fe)!==void 0&&(bt(),De.current=setTimeout(()=>{De.current=null,ht({kind:Fe,key:Qt,ax:tt,ay:gt})},kjn))},[bt,Ve]),_t=C.useCallback(()=>{De.current!==null&&(clearTimeout(De.current),De.current=null),Qe.current===null&&(Qe.current=setTimeout(()=>{Qe.current=null,ht(null)},zjn))},[]),Ft=C.useCallback(()=>{Qe.current!==null&&(clearTimeout(Qe.current),Qe.current=null)},[]),wt=C.useMemo(()=>{if(Be===null)return null;const Fe=Ve(Be.kind);if(Fe===void 0)return null;try{return Fe(Be.key)}catch(Qt){return console.error("[Flowchart] hover content builder failed:",Qt),null}},[Be,Ve]),[Lt,Jt]=C.useState(null),Dt=C.useRef(null);Dt.current=Lt;const[Et,Gt]=C.useState(null),[Ke,Se]=C.useState(null),[Re,qe]=C.useState(null),[Ye,$e]=C.useState(null),[lt,Pe]=C.useState(null),ot=C.useRef(null);ot.current=lt;const kt=C.useRef(!1);C.useEffect(()=>{if(Et===null)return;const Fe=setTimeout(()=>Gt(null),1100);return()=>clearTimeout(Fe)},[Et]);const Mt=C.useRef(null),[At,fn]=C.useState(null);C.useLayoutEffect(()=>{const Fe=Mt.current;if(!Fe)return;const Qt=()=>fn({w:Fe.clientWidth,h:Fe.clientHeight});Qt();const tt=new ResizeObserver(Qt);return tt.observe(Fe),()=>tt.disconnect()},[]);const rt=C.useMemo(()=>At===null?null:pjn(s,{width:At.w,orientation:se,legendPad:u?122:0,minHeight:h!==void 0&&At.h>0?At.h:void 0}),[s,At,se,u,h]),ln=C.useMemo(()=>Ejn(s,Me),[s,Me]),Mn=Fe=>ln.active?ln.nodes.has(Fe)?gT:ln.restLevel:gT,Jn=Fe=>ln.active?ln.links.has(Fe)?gT:ln.restLevel:gT,Er=(de==null?void 0:de.kind)==="link"?de.key:null,_r=Fe=>Fe?"opacity 150ms ease":void 0,fr=C.useCallback(Fe=>{ge(Fe),Fe!==null&&(Fe.kind==="state"&&y&&P2("onSelectState",()=>y(Fe.key)),Fe.kind==="link"&&x&&P2("onSelectLink",()=>x(Fe.key)),Fe.kind==="trigger"&&S&&P2("onSelectTrigger",()=>S(Fe.key)))},[y,x,S]);C.useEffect(()=>{const Fe=Qt=>{var tt;if(Qt.key==="Escape")ge(null),Te(null),ht(null),Jt(null);else if((Qt.key==="Delete"||Qt.key==="Backspace")&&((tt=ye.current)==null?void 0:tt.kind)==="link"&&Z&&!me.current){const gt=ye.current.key;P2("onDeleteLink",()=>Z(gt))}};return window.addEventListener("keydown",Fe),()=>window.removeEventListener("keydown",Fe)},[Z]);const Vr=C.useCallback((Fe,Qt)=>{if(!G)return!0;try{return G(Fe,Qt)!==!1}catch(tt){return console.error("[Flowchart] canConnect failed (allowing):",tt),!0}},[G]),wr=C.useCallback(Fe=>{var Qt;const tt=(Qt=Mt.current)==null?void 0:Qt.querySelector("[data-flowchart-canvas]"),gt=tt==null?void 0:tt.getBoundingClientRect();return gt?{x:Fe.clientX-gt.left,y:Fe.clientY-gt.top}:{x:0,y:0}},[]),pa=C.useCallback((Fe,Qt,tt)=>{if(v===void 0||b)return;tt.preventDefault(),tt.stopPropagation();const gt=wr(tt);Jt({from:Fe,side:Qt,x:gt.x,y:gt.y,over:null,allowed:!1,dup:void 0});const Ot=Bt=>{var vn;const wn=wr(Bt),Or=((vn=Dt.current)==null?void 0:vn.from)??Fe,Zr=rt?hjn(rt,wn):null,qn=Zr!==null?gjn(s,Or,Zr):void 0,ca=Zr!==null&&qn===void 0&&Vr(Or,Zr);Jt(sa=>sa===null?sa:{...sa,x:wn.x,y:wn.y,over:Zr,allowed:ca,dup:qn})},yn=()=>{window.removeEventListener("pointermove",Ot),window.removeEventListener("pointerup",yn);const Bt=Dt.current;if(Jt(null),!(!Bt||Bt.over===null)){if(Bt.dup!==void 0){Gt(vn=>({from:Bt.from,to:Bt.over,seq:((vn==null?void 0:vn.seq)??0)+1}));return}if(Bt.allowed&&U){const vn={from:Bt.from,to:Bt.over};P2("onCreateLink",()=>U(vn)),Gt(wn=>({from:Bt.from,to:Bt.over,seq:((wn==null?void 0:wn.seq)??0)+1}))}}};window.addEventListener("pointermove",Ot),window.addEventListener("pointerup",yn)},[v,b,wr,rt,s,Vr,U]),ar=C.useCallback((Fe,Qt)=>{if(!K)return;const tt=wr(Qt);let gt=!1;kt.current=!1;const Ot=Bt=>{const vn=wr(Bt);if(!gt){if(Math.abs(vn.x-tt.x)+Math.abs(vn.y-tt.y)<5)return;gt=!0,kt.current=!0,bt(),ht(null)}const wn=rt?mjn(rt,vn):null;Pe({key:Fe,x:vn.x,y:vn.y,overLane:wn})},yn=()=>{var Bt;window.removeEventListener("pointermove",Ot),window.removeEventListener("pointerup",yn);const vn=ot.current;if(Pe(null),!gt||vn===null||vn.overLane===null)return;const wn=s.nodesByKey.get(Fe),Or=wn!==void 0?(Bt=s.lanes[wn.laneIndex])==null?void 0:Bt.key:void 0;if(vn.overLane!==Or&&j){const Zr={key:Fe,lane:vn.overLane};P2("onMoveState",()=>j(Zr))}};window.addEventListener("pointermove",Ot),window.addEventListener("pointerup",yn)},[K,wr,rt,s,j,bt]),On=C.useMemo(()=>new Map(s.links.map(Fe=>[Fe.key,Fe])),[s]),st=d??s.nodes.length>=25,dn=C.useMemo(()=>{if(!rt)return[];const Fe=[],Qt=[],tt=[];for(const gt of rt.routes){const Ot=On.get(gt.key);Ot&&(gt.key===Er?tt.push(gt):Ot.cls==="planned"?Fe.push(gt):Qt.push(gt))}return[...Fe,...Qt,...tt]},[rt,On,Er]);if(s.nodes.length===0&&s.links.length===0)return p.jsx(V,{css:i.root,"data-flowchart-root":!0,style:{height:h,maxHeight:g}});const Pn=p.jsxs(V,{css:i.eyebrow,"data-flowchart-eyebrow":!0,children:[p.jsx(V,{css:i.eyebrowLeft,children:ue}),p.jsxs(V,{css:i.eyebrowRight,children:[p.jsxs(V,{css:i.orientationSegment,role:"group","aria-label":"Orientation",children:[p.jsxs("button",{type:"button","data-active":se==="LR"||void 0,onClick:()=>pe("LR"),children:[p.jsx(Ut,{icon:Nje,style:{fontSize:"9px"}})," LR"]}),p.jsxs("button",{type:"button","data-active":se==="TD"||void 0,onClick:()=>pe("TD"),children:[p.jsx(Ut,{icon:nVe,style:{fontSize:"9px"}})," TD"]})]}),c!==void 0&&p.jsxs(V,{css:i.freshnessChip,children:[p.jsx(V,{as:"span",css:i.freshnessDot}),p.jsx(V,{as:"span",children:c.label}),_(c.date)!==void 0&&p.jsx(V,{as:"span",css:i.freshnessDate,children:_(c.date).toLocaleDateString(void 0,{day:"2-digit",month:"short",timeZone:"UTC"})})]})]})]}),Hn=t.links.length,pr=oe!==void 0&&ve!==void 0&&ve<oe,Hr=pr?Math.round((1-ve/oe)*100):void 0,lr=p.jsxs(V,{css:i.footer,"data-flowchart-footer":!0,children:[p.jsx(V,{as:"span",css:i.footerStrong,children:Hn}),p.jsx(V,{as:"span",children:Hn===1?"link":"links"}),pr&&p.jsxs(p.Fragment,{children:[p.jsxs(V,{as:"span",children:["· narrowed from ",oe.toLocaleString()," ·"]}),p.jsxs(V,{as:"span",css:i.footerNeg,children:["−",Hr,"%"]})]}),p.jsxs(V,{css:i.footerSplit,children:[s.counts.planned," planned · ",s.counts.observed," observed",s.counts.unresolved>0?` · ${s.counts.unresolved} unresolved`:""]})]}),vr=h===void 0&&rt!==null?rt.height:void 0,mo=p.jsxs(V,{ref:Mt,css:i.body,"data-flowchart-body":!0,style:vr!==void 0?{height:vr,flex:"0 0 auto"}:void 0,children:[rt!==null&&p.jsx(V,{css:i.scroll,children:p.jsxs(V,{css:i.canvasWrap,style:{width:rt.width,height:rt.height},children:[p.jsxs("svg",{"data-flowchart-canvas":!0,width:rt.width,height:rt.height,viewBox:`0 0 ${rt.width} ${rt.height}`,style:{position:"absolute",inset:0,display:"block"},children:[p.jsx("defs",{children:[["ink",zm],["info",C9],["neg",k9],["brand",T3]].map(([Fe,Qt])=>p.jsx("marker",{id:`fc-mk-${Fe}-${n}`,viewBox:"0 0 10 10",refX:10,refY:5,markerWidth:12,markerHeight:12,markerUnits:"userSpaceOnUse",orient:"auto",children:p.jsx("path",{d:"M0 0L10 5L0 10z",fill:Qt})},Fe))}),rt.lanes.map(Fe=>Fe.tinted&&p.jsx("rect",{x:Fe.x,y:Fe.y,width:Fe.w,height:Fe.h,fill:bjn},Fe.key)),B&&rt.lanes.map(Fe=>p.jsx("rect",{x:Fe.x,y:Fe.y,width:Fe.w,height:Fe.h,fill:"transparent",onPointerEnter:()=>qe(Fe.key),onPointerLeave:()=>qe(Qt=>Qt===Fe.key?null:Qt)},`bandhit-${Fe.key}`)),lt!==null&<.overLane!==null&&(()=>{const Fe=rt.lanes.find(Qt=>Qt.key===lt.overLane);return Fe?p.jsxs("g",{style:{pointerEvents:"none"},children:[p.jsx("rect",{x:Fe.x,y:Fe.y,width:Fe.w,height:Fe.h,fill:JV,opacity:.07}),p.jsx("rect",{x:Fe.x+2,y:Fe.y+2,width:Fe.w-4,height:Fe.h-4,fill:"none",stroke:T3,strokeDasharray:"6 4",strokeWidth:1.5})]}):null})(),rt.lanes.map(Fe=>{const Qt=rt.orientation==="TD",tt=Qt?12:Fe.cx,gt=Qt?Fe.y+24:26,Ot=L!==void 0&&!b,yn=R!==void 0&&!b,Bt=Fe.label.length*8.2,vn=Qt?tt+Bt+12:tt+Bt/2+14;return p.jsxs("g",{children:[p.jsx("text",{x:tt,y:gt,textAnchor:Qt?"start":"middle",style:{fontFamily:kb,fontSize:10,fontWeight:600,letterSpacing:"2.2px",fill:Yh,cursor:Ot?"text":void 0},"data-flowchart-lane":Fe.key,onClick:Ot?()=>Se({key:Fe.key,label:Fe.label}):void 0,children:Fe.label.toUpperCase()}),yn&&p.jsx("text",{x:vn,y:gt,textAnchor:"start","data-flowchart-lane-delete":Fe.key,style:{fontSize:11,fill:Yh,cursor:"pointer"},onClick:()=>P2("onDeleteLane",()=>R(Fe.key)),children:"×"})]},Fe.key)}),M!==void 0&&!b&&p.jsxs("g",{"data-flowchart-addlane":!0,style:{cursor:"pointer"},onClick:()=>P2("onAddLane",()=>M()),children:[p.jsx("rect",{x:rt.laneTail.x,y:rt.laneTail.y,width:rt.laneTail.w,height:rt.laneTail.h,rx:6,fill:"transparent",stroke:cZe,strokeDasharray:"4 4"}),rt.orientation==="TD"?p.jsxs(p.Fragment,{children:[p.jsx("text",{x:rt.laneTail.x+rt.laneTail.w/2-8,y:rt.laneTail.y+rt.laneTail.h/2+5,textAnchor:"end",style:{fontSize:14,fill:Yh},children:"+"}),p.jsx("text",{x:rt.laneTail.x+rt.laneTail.w/2,y:rt.laneTail.y+rt.laneTail.h/2+4,textAnchor:"start",style:{fontFamily:kb,fontSize:9,letterSpacing:"2px",fill:Yh},children:"LANE"})]}):p.jsxs(p.Fragment,{children:[p.jsx("text",{x:rt.laneTail.x+rt.laneTail.w/2,y:rt.laneTail.y+30,textAnchor:"middle",style:{fontSize:14,fill:Yh},children:"+"}),p.jsx("text",{x:rt.laneTail.x+rt.laneTail.w/2,y:rt.laneTail.y+52,textAnchor:"middle",style:{fontFamily:kb,fontSize:9,letterSpacing:"2px",fill:Yh},children:"LANE"})]})]}),p.jsx("g",{"data-flowchart-links":!0,children:dn.map(Fe=>{const Qt=On.get(Fe.key),tt=Fe.key===Er,gt=Jn(Fe.key);return p.jsxs("g",{style:{opacity:gt,transition:_r(ln.active)},children:[tt&&p.jsx("path",{d:Fe.d,fill:"none",stroke:JV,strokeWidth:9,opacity:.16,strokeLinecap:"round"}),p.jsx("path",{d:Fe.d,fill:"none",stroke:tt?T3:wjn[Qt.cls],strokeWidth:tt?3:Qt.weight,strokeDasharray:Sjn[Qt.cls],markerEnd:`url(#fc-mk-${tt?"brand":Cjn[Qt.cls]}-${n})`}),p.jsx("path",{d:Fe.d,"data-flowchart-link":Fe.key,fill:"none",stroke:"transparent",strokeWidth:12,style:{cursor:"pointer"},onPointerEnter:Ot=>{Te({kind:"link",key:Fe.key});const yn=wr(Ot);ut("link",Fe.key,yn.x,yn.y)},onPointerLeave:()=>{Te(null),_t()},onClick:Ot=>{if(Ot.altKey&&z){P2("onTracePath",()=>z(Fe.key));return}fr({kind:"link",key:Fe.key})}})]},Fe.key)})}),dn.map(Fe=>{const Qt=On.get(Fe.key),tt=Qt.trigger!==void 0?s.triggers.get(Qt.trigger):void 0;return tt===void 0?null:p.jsx("g",{style:{opacity:Jn(Fe.key),transition:_r(ln.active)},children:p.jsxs("g",{"data-flowchart-trigger":tt.key,transform:`translate(${Fe.mid.x},${Fe.mid.y}) rotate(45)`,style:{cursor:"pointer"},onPointerEnter:gt=>{Te({kind:"trigger",key:tt.key});const Ot=wr(gt);ut("trigger",tt.key,Ot.x,Ot.y)},onPointerLeave:()=>{Te(null),_t()},onClick:()=>fr({kind:"trigger",key:tt.key}),children:[p.jsx("rect",{x:-8,y:-8,width:16,height:16,rx:3,fill:Cb,stroke:T3,strokeWidth:1.4}),p.jsx("text",{transform:"rotate(-45)",y:3.5,textAnchor:"middle",style:{fontFamily:kb,fontSize:8.5,fontWeight:700,fill:T3},children:tt.letter})]})},`dia-${Fe.key}`)}),dn.map(Fe=>{const Qt=On.get(Fe.key);if(Qt.badgeText===void 0||Fe.badge===void 0)return null;const tt=Qt.badgeText.length*5.8+14,gt=Ljn(Qt.cls,Fe.key===Er);return p.jsxs("g",{style:{opacity:Jn(Fe.key),transition:_r(ln.active),pointerEvents:"none"},transform:`translate(${Fe.badge.x},${Fe.badge.y})`,children:[p.jsx("rect",{x:-tt/2,y:-M3/2,width:tt,height:M3,rx:4,fill:Cb,stroke:gt.stroke,strokeWidth:1,strokeDasharray:gt.dash}),p.jsx("text",{y:3.5,textAnchor:"middle",style:{fontFamily:kb,fontSize:10,fontWeight:600,fill:gt.text,fontVariantNumeric:"tabular-nums"},children:Qt.badgeText})]},`bdg-${Fe.key}`)})]}),[...rt.nodes.values()].map(Fe=>{const Qt=s.nodesByKey.get(Fe.key);if(!Qt)return null;const tt=(de==null?void 0:de.kind)==="state"&&de.key===Fe.key;return p.jsxs(V,{"data-flowchart-node":Fe.key,css:Qt.ghost?i.ghostNode:i.node,"data-selected":tt||void 0,style:{left:Fe.x,top:Fe.y,width:Fe.w,height:Fe.h,opacity:(lt==null?void 0:lt.key)===Fe.key?.3:Mn(Fe.key),transition:_r(ln.active)},onPointerEnter:gt=>{Te({kind:"state",key:Fe.key});const Ot=wr(gt);ut("state",Fe.key,Ot.x,Ot.y)},onPointerLeave:()=>{Te(null),_t()},onPointerDown:K?gt=>ar(Fe.key,gt):void 0,onClick:()=>{if(kt.current){kt.current=!1;return}fr({kind:"state",key:Fe.key})},onDoubleClick:H&&!Qt.ghost?()=>{$e({mode:"edit",key:Fe.key,code:Fe.key,label:Qt.label??""})}:void 0,children:[p.jsxs(V,{css:i.nodeCode,children:[Fe.key,Qt.members!==void 0&&p.jsxs(V,{as:"span",css:i.nodeBadge,children:["×",String(Qt.members)]}),Qt.inPlaceKeys.length>0&&(()=>{const gt=(de==null?void 0:de.kind)==="link"?Qt.inPlaceKeys.indexOf(de.key):-1,Ot=gt>=0?Qt.inPlaceKeys[gt]:Qt.inPlaceKeys[0];return p.jsxs(V,{as:"span",css:i.nodeBadge,"data-flowchart-inplace":Fe.key,"data-selected":gt>=0||void 0,onPointerDown:yn=>yn.stopPropagation(),onDoubleClick:yn=>yn.stopPropagation(),onClick:yn=>{yn.stopPropagation(),fr({kind:"link",key:Qt.inPlaceKeys[(gt+1)%Qt.inPlaceKeys.length]})},onPointerEnter:yn=>{const Bt=wr(yn);ut("link",Ot,Bt.x,Bt.y)},onPointerLeave:yn=>{const Bt=wr(yn);ut("state",Fe.key,Bt.x,Bt.y)},children:[p.jsx(Ut,{icon:mm,style:{fontSize:"8px"}})," ",Qt.inPlaceKeys.length]})})()]}),Qt.label!==void 0&&p.jsx(V,{css:i.nodeLabel,children:Qt.label})]},Fe.key)}),p.jsxs("svg",{width:rt.width,height:rt.height,viewBox:`0 0 ${rt.width} ${rt.height}`,style:{position:"absolute",inset:0,display:"block",pointerEvents:"none"},children:[[...rt.nodes.values()].map(Fe=>{const Qt=(Me==null?void 0:Me.kind)==="state"&&Me.key===Fe.key||(de==null?void 0:de.kind)==="state"&&de.key===Fe.key||Lt!==null,tt=rt.handles.get(Fe.key)??[],gt=new Set(tt.map(Bt=>Bt.side)),yn=Qt&&(v!==void 0&&!b)?["left","right","top","bottom"].filter(Bt=>!gt.has(Bt)):[];return p.jsxs("g",{style:{opacity:Mn(Fe.key),transition:_r(ln.active)},children:[v!==void 0&&!b&&["left","right","top","bottom"].map(Bt=>p.jsx("circle",{cx:Fe[Bt].x,cy:Fe[Bt].y,r:8,fill:"transparent",style:{pointerEvents:"all",cursor:"crosshair"},onPointerEnter:()=>Te({kind:"state",key:Fe.key}),onPointerDown:vn=>pa(Fe.key,Bt,vn)},`hit-${Bt}`)),tt.map(Bt=>{const vn=Bt.links.map(Or=>On.get(Or)).filter(Or=>Or!==void 0),wn=Qt?4.5:op;return p.jsx("circle",{cx:Bt.pt.x,cy:Bt.pt.y,r:wn,fill:Cb,stroke:_jn(vn,Er),strokeWidth:1.4},Bt.side)}),yn.map(Bt=>p.jsx("circle",{cx:Fe[Bt].x,cy:Fe[Bt].y,r:4.5,fill:Cb,stroke:zm,strokeWidth:1.4},Bt))]},`ports-${Fe.key}`)}),Lt!==null&&(()=>{const Fe=rt.nodes.get(Lt.from);if(!Fe)return null;const Qt=Lt.over!==null?rt.nodes.get(Lt.over):void 0,tt=Lt.allowed||Lt.dup!==void 0,Ot=Lt.over===Lt.from&&tt?void 0:Qt!==void 0&&tt?ujn(Fe,Qt):djn(Fe,Lt.side,{x:Lt.x,y:Lt.y});return p.jsx("g",{children:Ot!==void 0&&p.jsx("path",{d:Ot,fill:"none",stroke:Lt.over!==null&&!tt?k9:T3,strokeWidth:1.6,strokeDasharray:"5 4"})})})(),Et!==null&&dn.map(Fe=>{const Qt=On.get(Fe.key);return!Qt||Qt.from!==Et.from||Qt.to!==Et.to?null:p.jsx("path",{d:Fe.d,fill:"none",stroke:JV,strokeWidth:11,strokeLinecap:"round",opacity:0,style:{pointerEvents:"none",animation:"fc-connect-pulse 0.9s ease-out forwards"}},`pulse-${Et.seq}-${Fe.key}`)})]}),B&&Ye===null&&Re!==null&<===null&&(()=>{const Fe=rt.laneGhosts.get(Re);return Fe?p.jsx(V,{"data-flowchart-ghoststate":Re,css:i.stateGhost,style:{left:Fe.x,top:Fe.y,width:Fe.w,height:Fe.h},onPointerEnter:()=>qe(Re),onClick:()=>$e({mode:"add",lane:Re,code:"",label:""}),children:"+ state"}):null})(),Ye!==null&&(()=>{const Fe=Ye.mode==="add"?rt.laneGhosts.get(Ye.lane):rt.nodes.get(Ye.key);if(!Fe)return null;const Qt=()=>{const gt=Ye;if($e(null),!(gt===null||gt.code.trim()==="")){if(gt.mode==="add"&&N){const Ot={lane:gt.lane,key:gt.code.trim(),label:gt.label.trim()};P2("onAddState",()=>N(Ot))}else if(gt.mode==="edit"&&O){const Ot={key:gt.key,code:gt.code.trim(),label:gt.label.trim()};P2("onEditState",()=>O(Ot))}}},tt=gt=>{gt.key==="Enter"?Qt():gt.key==="Escape"&&(gt.stopPropagation(),$e(null))};return p.jsxs(V,{"data-flowchart-stateeditor":!0,css:i.stateEditor,style:{left:Fe.x,top:Fe.y,width:Fe.w,minHeight:Fe.h},onBlur:gt=>{gt.currentTarget.contains(gt.relatedTarget)||Qt()},children:[p.jsx("input",{autoFocus:!0,placeholder:"CODE",value:Ye.code,onChange:gt=>$e(Ot=>Ot===null?Ot:{...Ot,code:gt.target.value}),onKeyDown:tt}),p.jsx("input",{placeholder:"Name state…",value:Ye.label,onChange:gt=>$e(Ot=>Ot===null?Ot:{...Ot,label:gt.target.value}),onKeyDown:tt})]})})(),lt!==null&&(()=>{const Fe=s.nodesByKey.get(lt.key);return Fe?p.jsxs(V,{css:i.moveClone,style:{left:lt.x+10,top:lt.y+10},children:[p.jsx(V,{css:i.nodeCode,children:lt.key}),Fe.label!==void 0&&p.jsx(V,{css:i.nodeLabel,children:Fe.label})]}):null})(),Lt!==null&&Lt.over!==null&&(()=>{const Fe=Lt.allowed||Lt.dup!==void 0,Qt=Lt.over===Lt.from&&Fe;return!Qt&&Fe?null:p.jsx(V,{style:{position:"absolute",left:Lt.x+12,top:Lt.y-18,pointerEvents:"none",fontSize:13,color:Qt?"var(--fc-brand-d)":"var(--fc-neg)"},children:p.jsx(Ut,{icon:Qt?mm:vae})})})(),Et!==null&&Et.from===Et.to&&(()=>{const Fe=rt.nodes.get(Et.from);return Fe?p.jsx(V,{style:{position:"absolute",left:Fe.x,top:Fe.y,width:Fe.w,height:Fe.h,borderRadius:6,pointerEvents:"none",animation:"fc-node-pulse 0.9s ease-out forwards"}},`nodepulse-${Et.seq}`):null})(),Ke!==null&&(()=>{const Fe=rt.lanes.find(Ot=>Ot.key===Ke.key);if(!Fe)return null;const tt=rt.orientation==="TD"?{left:8,top:Fe.y+8,width:148}:{left:Fe.cx-74,top:8,width:148},gt=()=>{const Ot=Ke;Se(null),Ot!==null&&Ot.label.trim()!==""&&L&&P2("onRenameLane",()=>L({key:Ot.key,label:Ot.label.trim()}))};return p.jsx("input",{"data-flowchart-lane-edit":!0,autoFocus:!0,value:Ke.label,onChange:Ot=>Se(yn=>yn===null?yn:{...yn,label:Ot.target.value}),onBlur:gt,onKeyDown:Ot=>{Ot.key==="Enter"?gt():Ot.key==="Escape"&&(Ot.stopPropagation(),Se(null))},style:{position:"absolute",...tt,zIndex:11,fontFamily:"var(--chakra-fonts-mono)",fontSize:11,fontWeight:600,padding:"3px 8px",borderRadius:4,border:"1px solid var(--fc-brand-d)",background:"var(--fc-paper)",color:"inherit",outline:"none"}})})(),u&&p.jsxs(V,{css:i.legend,"data-flowchart-legend":!0,children:[p.jsx(V,{css:i.legendTitle,children:"Legend"}),p.jsxs(V,{css:i.legendRow,children:[p.jsx("svg",{width:28,height:8,children:p.jsx("line",{x1:1,y1:4,x2:27,y2:4,stroke:zm,strokeWidth:2})}),p.jsx("span",{children:"Planned"})]}),p.jsxs(V,{css:i.legendRow,children:[p.jsx("svg",{width:28,height:8,children:p.jsx("line",{x1:1,y1:4,x2:27,y2:4,stroke:C9,strokeWidth:1.6,strokeDasharray:"5 4"})}),p.jsx("span",{children:"Observed"})]}),p.jsxs(V,{css:i.legendRow,children:[p.jsx("svg",{width:28,height:16,children:p.jsx("rect",{x:9,y:3,width:10,height:10,rx:2,transform:"rotate(45 14 8)",fill:Cb,stroke:T3,strokeWidth:1.2})}),p.jsx("span",{children:"Decision trigger"})]}),p.jsxs(V,{css:i.legendRow,children:[p.jsxs(V,{as:"span",css:i.nodeBadge,children:[p.jsx(Ut,{icon:mm,style:{fontSize:"8px"}})," n"]}),p.jsx("span",{children:"In-place transition"})]})]}),st&&p.jsx(V,{css:i.minimap,"data-flowchart-minimap":!0,children:p.jsx("svg",{width:96,height:64,viewBox:`0 0 ${rt.width} ${rt.height}`,preserveAspectRatio:"xMidYMid meet",children:[...rt.nodes.values()].map(Fe=>p.jsx("rect",{x:Fe.x,y:Fe.y,width:Fe.w,height:Fe.h,rx:8,fill:"none",stroke:yjn,strokeWidth:6},Fe.key))})})]})}),Be!==null&&wt!==null&&rt!==null&&p.jsx(V,{css:i.hoverCard,"data-flowchart-hovercard":!0,style:{left:Math.min(Be.ax+14,Math.max(0,((At==null?void 0:At.w)??320)-300)),top:Be.ay+14},onPointerEnter:Ft,onPointerLeave:_t,children:p.jsx(mn,{value:wt,storageKey:`${n}.hover.${Be.kind}`})})]});return p.jsxs(V,{css:i.root,"data-flowchart-root":!0,"data-density":f,style:{height:h,maxHeight:g??h},children:[Pn,mo,lr]})},(e,t)=>vjn(e.value,t.value)&&e.storageKey===t.storageKey),Pjn=["a","b","c","d"],Ajn='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors © <a href="https://carto.com/attributions">CARTO</a>',Njn='© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',$jn={positron:"light_all",darkMatter:"dark_all",voyager:"voyager"};function k4r(e){if(e.type==="carto")return{url:`https://{s}.basemaps.cartocdn.com/rastertiles/${$jn[e.value.style.type]??"light_all"}/{z}/{x}/{y}{r}.png`,attribution:Ajn,subdomains:Pjn,maxZoom:20,detectRetina:!0};if(e.type==="osm")return{url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",attribution:Njn,subdomains:["a","b","c"],maxZoom:19,detectRetina:!0};const t=e.value;return{url:t.url,attribution:t.attribution,subdomains:t.subdomains.type==="some"?t.subdomains.value:[],maxZoom:t.maxZoom.type==="some"?Number(t.maxZoom.value):19,detectRetina:t.detectRetina.type==="some"?t.detectRetina.value:!1}}const uZe={success:"success",danger:"danger",warning:"warning",info:"brand",neutral:"muted"};function dZe(e){return e.tone.type==="some"?e.tone.value.type:e.status.type==="some"?uZe[e.status.value.type]??"muted":"muted"}function Ijn(e){const t=e.status.type==="some"?e.status.value.type:void 0,n=t==="danger"?"danger":t==="warning"?"warning":t==="success"||t==="info"?"success":void 0;if(e.pulse.type==="some"){if(!e.pulse.value)return;if(n!==void 0)return n;const r=dZe(e);return r==="danger"?"danger":r==="warning"?"warning":"success"}return n}function z4r(e){const t=Ijn(e);return["elara-map-area",e.color.type==="some"?"":`elara-map-area--${dZe(e)}`,t!==void 0?`elara-map-area--pulse-${t}`:""].filter(Boolean).join(" ")}function M4r(e){return e!==void 0?`elara-map-hex-cell elara-map-area--${uZe[e]??"muted"}`:"elara-map-hex-cell elara-map-area--muted"}function fZe(e){return e.style.value.tone.type==="some"?e.style.value.tone.value.type:"brand"}function T4r(e){const t=e.flow.type==="some"&&e.flow.value;return["elara-map-line",`elara-map-line--${fZe(e)}`,t?"elara-map-line--flow":""].filter(Boolean).join(" ")}function E4r(e){return`elara-map-arrowhead elara-map-arrowhead--${fZe(e)}`}function _4r(e){return e.tone.type==="some"?`--${e.tone.value.type}`:"--brand"}function ope(e){return e==="start"?"flex-start":e==="end"?"flex-end":"center"}function Djn({compact:e,interactive:t,styles:n,children:r}){const[a,o]=C.useState(!1);return e&&t&&!a?p.jsx(Ht.button,{type:"button",css:n.overlayToggle,"aria-label":"Show map panel","aria-expanded":!1,onClick:()=>o(!0),children:p.jsx(Ut,{icon:j$})}):p.jsxs(V,{css:n.overlayItem,style:{pointerEvents:t?"auto":"none"},children:[e&&t&&p.jsx(Ht.button,{type:"button",css:n.overlayToggle,"data-dismiss":"","aria-label":"Hide map panel","aria-expanded":!0,onClick:()=>o(!1),children:p.jsx(Ut,{icon:c0})}),r]})}const Ojn=C.lazy(()=>wDt(()=>import("./engine-CkVTyL0W-kG-rG5eh.js"),[],import.meta.url)),jjn=it(cs.Types.Map),Fjn=C.memo(function({value:t,storageKey:n}){const r=en({key:"map"})(),a=_(t.height),o=a===void 0?void 0:a==="fill"?{height:"100%",maxHeight:"100%"}:{height:a,maxHeight:a},i=C.useMemo(()=>_(t.onAreaClick),[t.onAreaClick]),s=C.useMemo(()=>_(t.onMarkerClick),[t.onMarkerClick]),l=C.useMemo(()=>_(t.onZoom),[t.onZoom]),c=C.useMemo(()=>_(t.onSelect),[t.onSelect]),u=C.useMemo(()=>i?y=>{queueMicrotask(()=>i(y))}:void 0,[i]),d=C.useMemo(()=>s?y=>{queueMicrotask(()=>s(y))}:void 0,[s]),f=C.useMemo(()=>l?y=>{queueMicrotask(()=>l(y))}:void 0,[l]),h=C.useMemo(()=>c?y=>{queueMicrotask(()=>c(y))}:void 0,[c]),g=C.useRef(null),v=Rv(g,480),b=C.useMemo(()=>{const y=t.tiles.type==="carto"?`carto:${t.tiles.value.style.type}`:t.tiles.type==="custom"?`custom:${t.tiles.value.url}`:"osm",x=_(t.fitBounds);return[y,String(_(t.minZoom)??""),String(_(t.maxZoom)??""),String(_(t.scrollWheelZoom)??!0),String(_(t.attributionPrefix)??!1),x!==void 0?x.type:""].join("|")},[t.tiles,t.minZoom,t.maxZoom,t.scrollWheelZoom,t.attributionPrefix,t.fitBounds]);return p.jsxs(V,{ref:g,css:r.root,...o!==void 0?{style:o}:{},children:[p.jsx(C.Suspense,{fallback:p.jsx(V,{css:r.fallback}),children:p.jsx(Ojn,{value:t,containerClassName:"elara-map-canvas",onAreaClickFn:u,onMarkerClickFn:d,onZoomFn:f,onSelectFn:h},b)}),t.overlays.map((y,x)=>{const S=_(y.key)??String(x),z=_(y.interactive)??!0;return p.jsx(V,{css:r.overlay,style:{justifyContent:ope(y.align.type),alignItems:ope(y.verticalAlign.type)},children:p.jsx(Djn,{compact:v,interactive:z,styles:r,children:p.jsx(mn,{value:y.content,storageKey:`${n}.overlay.${S}`})})},S)})]})},(e,t)=>jjn(e.value,t.value)&&e.storageKey===t.storageKey);function Bjn({children:e}){const t=ga({key:"dropHint"});return p.jsx(V,{css:t({}),"data-drop-hint":"",children:e})}const Vjn=it(Ix.Types.Blend);function pZe(e){return e.type!=="proposed"?e.type:e.value.type}function gx(e){return Math.abs(e)>=1e3?`${Math.round(e/1e3)}k`:`${Math.round(e)}`}function Hjn({surface:e,targetKey:t,alloc:n,unit:r,capacity:a,styles:o,onAmount:i,onRemove:s}){const l=pZe(n.state),c=n.state.type==="proposed",u=c&&!n.pinned,[d,f]=C.useState(String(n.amount));C.useEffect(()=>{f(String(n.amount))},[n.amount]);const h=C.useMemo(()=>({surface:e,row:t,slot:"alloc",event:n.source}),[e,t,n.source]),g=C.useMemo(()=>p.jsx(V,{css:o.dragGhost,children:n.label}),[o.dragGhost,n.label]),v=CI(h,g,!u),b=C.useCallback(()=>{const S=Number(d);Number.isFinite(S)&&S>=0&&S!==n.amount&&i?i(n.source,S):f(String(n.amount))},[d,n.amount,n.source,i]),y=a>0?Math.round(n.amount/a*100):0,x=_(n.sublabel);return p.jsxs(V,{css:o.allocRow,"data-state":l,onPointerDown:v,...u&&v?{"data-draggable":""}:{},children:[u&&v&&p.jsx(V,{as:"span",css:o.allocGrip,"data-drag-grip":"",children:p.jsx(Ut,{icon:g5})}),p.jsxs(V,{css:o.allocBody,children:[p.jsx(V,{as:"span",css:o.allocLabel,children:n.label}),x!==void 0&&p.jsx(V,{as:"span",css:o.allocSublabel,children:x})]}),n.pinned&&p.jsx(V,{as:"span",css:o.pinBadge,title:"Pinned — held fixed",children:p.jsx(Ut,{icon:WC})}),c&&i?p.jsx(V,{as:"input",css:o.amountInput,value:d,inputMode:"decimal",onPointerDown:S=>S.stopPropagation(),onChange:S=>f(S.target.value),onBlur:b,onKeyDown:S=>{S.key==="Enter"&&S.target.blur()}}):p.jsx(V,{as:"span",css:o.amountText,children:gx(n.amount)}),p.jsxs(V,{as:"span",css:o.share,children:[r," · ",y,"%"]}),u&&s&&p.jsx(V,{as:"button",css:o.allocAction,"aria-label":"Remove allocation",title:"Remove allocation",onPointerDown:S=>S.stopPropagation(),onClick:()=>s(n.source),children:p.jsx(Ut,{icon:UC})})]})}function Wjn({surface:e,target:t,mode:n,badge:r,styles:a,vetoFor:o,onAmount:i,onRemove:s,onAction:l,compactActive:c}){const u=en({key:"commitBar"}),d=C.useMemo(()=>u({}),[u]),f=C.useMemo(()=>({surface:e,row:t.key,slot:"alloc"}),[e,t.key]),h=C.useMemo(()=>o==null?void 0:o(f),[o,f]),g=lk(f,!1,h),v=t.allocations.reduce((S,z)=>S+z.amount,0),b=Math.max(0,t.capacity-v),y=[0,.25,.5,.75,1].map(S=>S*t.capacity),x=_(t.objective);return p.jsxs(V,{ref:g,css:a.panel,"data-mode":n,...c?{"data-compact-active":""}:{},children:[p.jsxs(V,{css:a.panelHead,children:[r!==void 0&&p.jsx(V,{as:"span",css:a.panelBadge,children:r}),p.jsx(V,{as:"span",css:a.panelTitle,children:t.label}),p.jsxs(V,{as:"span",css:a.panelCap,children:["cap ",gx(t.capacity)," ",t.unit," · ",gx(b)," headroom"]})]}),p.jsxs(V,{css:a.compositionBar,children:[t.allocations.map(S=>p.jsx(V,{css:a.segment,"data-state":pZe(S.state),style:{width:`${t.capacity>0?S.amount/t.capacity*100:0}%`},title:`${S.label} · ${gx(S.amount)} ${t.unit}`},S.source)),p.jsx(V,{css:a.headroom,style:{width:`${t.capacity>0?b/t.capacity*100:100}%`}})]}),p.jsx(V,{css:a.axis,children:y.map(S=>p.jsx(V,{as:"span",css:a.axisTick,children:gx(S)},S))}),p.jsxs(V,{css:a.allocList,children:[t.allocations.map(S=>p.jsx(Hjn,{surface:e,targetKey:t.key,alloc:S,unit:t.unit,capacity:t.capacity,styles:a,onAmount:i,onRemove:s},S.source)),p.jsx(Bjn,{children:"drop a source here"})]}),t.metrics.length>0&&p.jsx(V,{css:a.metricList,children:t.metrics.map(S=>{const z=_(S.model),M=_(S.band);return p.jsxs(V,{css:a.metricRow,children:[p.jsx(V,{as:"span",css:a.metricLabel,children:S.label}),p.jsx(V,{as:"span",css:a.metricValue,children:S.value}),z!==void 0&&p.jsx(V,{as:"span",css:a.trustChip,children:z}),M!==void 0&&p.jsxs(V,{as:"span",css:a.bandText,children:["band ",M.min,"–",M.max]})]},S.key)})}),p.jsx(V,{css:a.panelFoot,children:p.jsxs(V,{css:d.root,"data-slot":"panelFoot",children:[p.jsx(V,{css:d.draft,children:x!==void 0&&p.jsxs(V,{as:"span",css:a.objective,children:["objective ",x]})}),l&&p.jsxs(V,{css:d.btnRow,children:[p.jsx(V,{as:"button",css:d.btn,onClick:()=>l("reset"),children:"Reset"}),n==="compare"&&p.jsx(V,{as:"button",css:d.btnDanger,onClick:()=>l("discard"),children:"Discard"}),p.jsx(V,{as:"button",css:d.btnPrimary,onClick:()=>l("apply"),children:"Apply blend"})]})]})})]})}const Ujn=C.memo(function({value:t}){var n;const r=en({key:"blend"})(),a=t.targets.length<=1?"single":t.targets.length===2?"compare":"portfolio",o=C.useMemo(()=>_(t.onDrag),[t.onDrag]),i=C.useMemo(()=>_(t.canDrop),[t.canDrop]),s=kI(i),l=C.useMemo(()=>_(t.onAmountChange),[t.onAmountChange]),c=C.useMemo(()=>_(t.onAction),[t.onAction]),u=_(t.verdict),[d,f]=C.useState(()=>[...t.targets]);C.useEffect(()=>{f([...t.targets])},[t.targets]);const h=C.useCallback((O,j)=>{if(O.type==="add"&&!t7(i,O))return;let B=d;if(O.type==="add"){const{from:H,into:K}=O.value;B=d.map(U=>U.key!==K.row?U:{...U,allocations:[...U.allocations,{source:H.key,label:(j==null?void 0:j.label)??H.key,sublabel:A,amount:0,pinned:!1,state:$("proposed",$("added",null))}]})}else if(O.type==="remove"){const{from:H}=O.value,K=H.event.type==="some"?H.event.value:void 0;B=d.map(U=>U.key!==H.row?U:{...U,allocations:U.allocations.filter(Z=>Z.source!==K)})}f(B),o&&queueMicrotask(()=>o(O))},[d,o,i]),g=C.useMemo(()=>({id:t.id,sources:[...t.sources],kinds:{add:!0,remove:!0},onDrag:h}),[t.id,t.sources,h]);sk(g);const v=C.useCallback(O=>(j,B)=>{f(H=>H.map(K=>K.key!==O?K:{...K,allocations:K.allocations.map(U=>U.source===j?{...U,amount:B}:U)})),l&&queueMicrotask(()=>l({target:O,source:j,amount:B}))},[l]),b=C.useCallback(O=>j=>{const B=$("remove",{from:{surface:t.id,row:O,slot:"alloc",event:P(j)},to:$("trash",null)});h(B)},[t.id,h]),y=C.useCallback(O=>j=>{c&&queueMicrotask(()=>c({target:P(O),action:$(j,null)}))},[c]),x=C.useRef(null),S=Rv(x,480),[z,M]=C.useState(null),L=S&&d.length>1,R=L?z!==null&&d.some(O=>O.key===z)?z:(n=d[0])==null?void 0:n.key:void 0,N=C.useMemo(()=>{if(a!=="compare")return[];const[O,j]=d;return O===void 0||j===void 0?[]:(t.diff.length>0?[...t.diff]:O.metrics.map(H=>H.key)).flatMap(H=>{const K=O.metrics.find(J=>J.key===H),U=j.metrics.find(J=>J.key===H);if(K===void 0&&U===void 0)return[];const Z=K!==void 0?_(K.numeric):void 0,G=U!==void 0?_(U.numeric):void 0,W=typeof Z=="number"&&typeof G=="number"?`${G-Z>=0?"+":""}${Number((G-Z).toFixed(3))}`:"—";return[{key:H,label:(K==null?void 0:K.label)??(U==null?void 0:U.label)??H,a:(K==null?void 0:K.value)??"—",b:(U==null?void 0:U.value)??"—",delta:W}]})},[a,d,t.diff]);return p.jsxs(V,{ref:x,css:r.root,"data-mode":a,children:[p.jsx(V,{css:r.targets,"data-mode":a,children:d.map((O,j)=>{const B=a==="compare"?j===0?"A":"B":void 0;return L&&O.key!==R?p.jsxs(Ht.button,{type:"button",css:r.panelRail,"aria-label":`Show ${O.label}`,onClick:()=>M(O.key),children:[B!==void 0&&p.jsx(V,{as:"span",css:r.panelBadge,children:B}),p.jsx(V,{as:"span",css:r.panelRailLabel,children:O.label})]},O.key):p.jsx(Wjn,{surface:t.id,target:O,mode:a,badge:B,styles:r,vetoFor:s,onAmount:v(O.key),onRemove:b(O.key),onAction:c?y(O.key):void 0,compactActive:L},O.key)})}),a==="compare"&&N.length>0&&p.jsxs(V,{css:r.diff,children:[p.jsxs(V,{css:r.diffRow,"data-head":"",children:[p.jsx(V,{as:"span",children:"metric"}),p.jsx(V,{as:"span",children:"target A"}),p.jsx(V,{as:"span",children:"target B"}),p.jsx(V,{as:"span",children:"Δ (B−A)"})]}),N.map(O=>p.jsxs(V,{css:r.diffRow,children:[p.jsx(V,{as:"span",children:O.label}),p.jsx(V,{as:"span",children:O.a}),p.jsx(V,{as:"span",children:O.b}),p.jsx(V,{as:"span","data-delta":"",children:O.delta})]},O.key)),u!==void 0&&p.jsx(V,{css:r.verdict,children:u})]})]})},(e,t)=>Vjn(e.value,t.value)&&e.storageKey===t.storageKey),qjn=it(Nq.Types.AvatarGroup),Gjn=C.memo(function({value:t}){var n;const r=C.useMemo(()=>_(t.style),[t.style]),a=r?(n=_(r.size))==null?void 0:n.type:void 0,o=r?_(r.borderColor):void 0,i=C.useMemo(()=>_(t.max),[t.max]),s=al(),c=C.useMemo(()=>{var h;return(h=_(t.density))==null?void 0:h.type},[t.density])??s,u=t.avatars,d=i!==void 0?Math.min(Number(i),u.length):u.length,f=u.length-d;return p.jsxs(tNt,{size:a??"xs",spaceX:"-1.5",borderColor:o??"bg.surface",children:[u.slice(0,d).map((h,g)=>{var v;const b=OXe(h),y=_(h.src),x=_(h.name),S=((v=_(h.density))==null?void 0:v.type)??c;return p.jsxs(cK,{...b,...S!==void 0?{density:S}:{},children:[p.jsx(uK,{name:x}),y&&p.jsx(YPe,{src:y})]},g)}),f>0&&p.jsx(cK,{...c!==void 0?{density:c}:{},children:p.jsxs(uK,{children:["+",f]})})]})},(e,t)=>qjn(e.value,t.value)),Kjn=it(xq.Types.Root),Yjn=C.memo(function({value:t}){var n,r,a;const o=_(t.style),i=o?(n=_(o.colorPalette))==null?void 0:n.type:void 0,s=o?(r=_(o.size))==null?void 0:r.type:void 0,c=(o?(a=_(o.orientation))==null?void 0:a.type:void 0)==="horizontal"?"horizontal":"vertical",u=o?_(o.color):void 0,d=o?_(o.fillColor):void 0,f=o?_(o.borderColor):void 0,h=_(t.onChange),g=_(t.disabled),v=_(t.required),b=_(t.name),[y,x]=C.useState(t.value);C.useEffect(()=>{x(t.value)},[t.value]);const S=C.useCallback(M=>{const L=M.value??"";x(L),h&&queueMicrotask(()=>h(L))},[h]),z=c==="horizontal"?Xr:W1;return p.jsx(K$t,{value:y,onValueChange:S,colorPalette:i??"brand",size:s,disabled:g,required:v,name:b,orientation:c,children:p.jsx(z,{gap:"3",align:c==="vertical"?"start":void 0,children:t.items.map(M=>{const L=_(M.disabled)??!1,R=_(M.label)??M.value;return p.jsxs(Y$t,{value:M.value,disabled:L||g,color:u,children:[p.jsx(Q$t,{}),p.jsx(Z$t,{borderColor:f,...d?{_checked:{color:d,borderColor:d}}:{}}),p.jsx(X$t,{children:R})]},M.value)})})})},(e,t)=>Kjn(e.value,t.value)),Xjn=it(wq.Types.Root),Zjn=C.memo(function({value:t}){var n,r,a;const o=_(t.style),i=o?(n=_(o.colorPalette))==null?void 0:n.type:void 0,s=o?(r=_(o.size))==null?void 0:r.type:void 0,l=s==="xs"?"sm":s,u=(o?(a=_(o.orientation))==null?void 0:a.type:void 0)==="horizontal"?"horizontal":"vertical",d=o?_(o.color):void 0,f=o?_(o.descriptionColor):void 0,h=o?_(o.cardBackground):void 0,g=o?_(o.selectedCardBackground):void 0,v=o?_(o.selectedBorderColor):void 0,b=_(t.onChange),y=_(t.disabled),x=_(t.required),S=_(t.name),[z,M]=C.useState(t.value);C.useEffect(()=>{M(t.value)},[t.value]);const L=C.useCallback(N=>{const O=N.value??"";M(O),b&&queueMicrotask(()=>b(O))},[b]),R=u==="horizontal"?Xr:W1;return p.jsx(j$t,{value:z,onValueChange:L,colorPalette:i??"brand",size:l,disabled:y,required:x,name:S,orientation:u,children:p.jsx(R,{gap:"3",align:u==="vertical"?"stretch":void 0,flexWrap:u==="horizontal"?"wrap":void 0,children:t.items.map(N=>{const O=_(N.disabled)??!1,j=_(N.description),B=N.value===z;return p.jsxs(F$t,{value:N.value,disabled:O||y,bg:B?g:h,borderColor:B?v:void 0,children:[p.jsx(q$t,{}),p.jsxs(H$t,{children:[p.jsxs(W$t,{children:[p.jsx(B$t,{color:d,children:N.label}),j&&p.jsx(V$t,{color:f,children:j})]}),p.jsx(U$t,{})]})]},N.value)})})})},(e,t)=>Xjn(e.value,t.value)),Qjn=it(bq.Types.Root);function Xh(e){const n=((typeof e=="bigint"?Number(e):e)%1440+1440)%1440;return new _7(Math.floor(n/60),n%60,0)}function mT(e){return BigInt(e.hour*60+e.minute)}const Jjn=C.memo(function({value:t}){var n;const r=_(t.style),a=r?_(r.color):void 0,o=r?_(r.background):void 0,i=r?_(r.borderColor):void 0,s=r?_(r.focusBorderColor):void 0,l=r?(n=_(r.size))==null?void 0:n.type:void 0,c=C.useMemo(()=>_(t.onChange),[t.onChange]),u=_(t.disabled)??!1,d=_(t.presets),[f,h]=C.useState(Xh(t.startValue)),[g,v]=C.useState(Xh(t.endValue));C.useEffect(()=>{h(Xh(t.startValue))},[t.startValue]),C.useEffect(()=>{v(Xh(t.endValue))},[t.endValue]);const b=C.useCallback(L=>{L&&(h(L),c&&queueMicrotask(()=>c(mT(L),mT(g))))},[c,g]),y=C.useCallback(L=>{L&&(v(L),c&&queueMicrotask(()=>c(mT(f),mT(L))))},[c,f]),x=C.useCallback((L,R)=>{const N=Xh(L),O=Xh(R);h(N),v(O),c&&queueMicrotask(()=>c(L,R))},[c]),S=l==="sm"||l==="xs"?"sm":l==="lg"?"lg":"md",z={...h5,display:"inline-flex",alignItems:"center",_coarse:{minHeight:"44px"},...o!==void 0?{background:o}:{},...a!==void 0?{color:a}:{},...i!==void 0?{borderColor:i}:{},opacity:u?.6:1,_focusWithin:s?{borderColor:s}:P6},M=p.jsxs(Xr,{gap:"2",align:"center",flexWrap:"wrap",children:[p.jsx(V,{css:z,children:p.jsx(p9,{value:f,onChange:b,isReadOnly:u,"aria-label":"Start time",children:p.jsx(h9,{children:({segment:L})=>p.jsx(g9,{segment:L})})})}),p.jsx(Ie,{color:"fg.muted",fontSize:S,children:"–"}),p.jsx(V,{css:z,children:p.jsx(p9,{value:g,onChange:y,isReadOnly:u,"aria-label":"End time",children:p.jsx(h9,{children:({segment:L})=>p.jsx(g9,{segment:L})})})})]});return!d||d.length===0?M:p.jsxs(W1,{gap:"2",align:"flex-start",children:[M,p.jsx(Xre,{gap:"2",children:d.map((L,R)=>p.jsx(fu,{size:"xs",variant:"subtle",disabled:u,onClick:()=>x(L.start,L.end),children:L.label},`${L.label}-${R}`))})]})},(e,t)=>Qjn(e.value,t.value)),eFn=it(yq.Types.Root);function Zh(e){return{calendar:new yi(e.getUTCFullYear(),e.getUTCMonth()+1,e.getUTCDate()),time:new _7(e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds())}}function ipe(e){return new Date(Date.UTC(e.calendar.year,e.calendar.month-1,e.calendar.day,e.time.hour,e.time.minute,e.time.second))}const tFn=C.memo(function({value:t}){var n,r;const a=_(t.style),o=a?_(a.color):void 0,i=a?_(a.background):void 0,s=a?_(a.borderColor):void 0,l=a?_(a.focusBorderColor):void 0,c=a?(n=_(a.size))==null?void 0:n.type:void 0,u=C.useMemo(()=>_(t.onChange),[t.onChange]),d=_(t.disabled)??!1,f=((r=_(t.precision))==null?void 0:r.type)??"date",h=_(t.presets),g=C.useMemo(()=>t.startValue instanceof Date?t.startValue:new Date(t.startValue),[t.startValue]),v=C.useMemo(()=>t.endValue instanceof Date?t.endValue:new Date(t.endValue),[t.endValue]),[b,y]=C.useState(()=>Zh(g)),[x,S]=C.useState(()=>Zh(v));C.useEffect(()=>{y(Zh(g))},[g]),C.useEffect(()=>{S(Zh(v))},[v]);const z=C.useRef(b),M=C.useRef(x);z.current=b,M.current=x;const L=C.useCallback(G=>{u&&queueMicrotask(()=>u(ipe(G.start),ipe(G.end)))},[u]),R=C.useCallback(G=>{if(!G)return;const W=G,J={...z.current,calendar:W};y(J),L({start:J,end:M.current})},[L]),N=C.useCallback(G=>{if(!G)return;const W={...z.current,time:G};y(W),L({start:W,end:M.current})},[L]),O=C.useCallback(G=>{if(!G)return;const W=G,J={...M.current,calendar:W};S(J),L({start:z.current,end:J})},[L]),j=C.useCallback(G=>{if(!G)return;const W={...M.current,time:G};S(W),L({start:z.current,end:W})},[L]),B=C.useCallback((G,W)=>{const J=Zh(G),ae=Zh(W);y(J),S(ae),u&&queueMicrotask(()=>u(G,W))},[u]),H=c==="sm"||c==="xs"?"sm":c==="lg"?"lg":"md",K={...h5,display:"inline-flex",alignItems:"center",gap:"{spacing.2}",_coarse:{minHeight:"44px"},...i!==void 0?{background:i}:{},...o!==void 0?{color:o}:{},...s!==void 0?{borderColor:s}:{},opacity:d?.6:1,_focusWithin:l?{borderColor:l}:P6},U=(G,W,J,ae)=>f==="time"?p.jsx(V,{css:K,children:p.jsx(p9,{value:G.time,onChange:J,isReadOnly:d,"aria-label":`${ae} time`,children:p.jsx(h9,{children:({segment:ne})=>p.jsx(g9,{segment:ne})})})}):f==="date"?p.jsx(V,{css:K,children:p.jsx(VL,{value:G.calendar,onChange:W,isReadOnly:d,"aria-label":`${ae} date`,children:p.jsx(HL,{children:({segment:ne})=>p.jsx(WL,{segment:ne})})})}):p.jsxs(V,{css:K,children:[p.jsx(VL,{value:G.calendar,onChange:W,isReadOnly:d,"aria-label":`${ae} date`,children:p.jsx(HL,{children:({segment:ne})=>p.jsx(WL,{segment:ne})})}),p.jsx(p9,{value:G.time,onChange:J,isReadOnly:d,"aria-label":`${ae} time`,children:p.jsx(h9,{children:({segment:ne})=>p.jsx(g9,{segment:ne})})})]}),Z=p.jsxs(Xr,{gap:"2",align:"center",flexWrap:"wrap",children:[U(b,R,N,"Start"),p.jsx(Ie,{color:"fg.muted",fontSize:H,children:"–"}),U(x,O,j,"End")]});return!h||h.length===0?Z:p.jsxs(W1,{gap:"2",align:"flex-start",children:[Z,p.jsx(Xre,{gap:"2",children:h.map((G,W)=>p.jsx(fu,{size:"xs",variant:"subtle",disabled:d,onClick:()=>B(G.start instanceof Date?G.start:new Date(G.start),G.end instanceof Date?G.end:new Date(G.end)),children:G.label},`${G.label}-${W}`))})]})},(e,t)=>eFn(e.value,t.value)),nFn=it(pq.Types.Switch);function spe(e){var t,n;const r=_(e.style),a=r?(t=_(r.colorPalette))==null?void 0:t.type:void 0,o=r?(n=_(r.size))==null?void 0:n.type:void 0;return{checked:e.checked,disabled:_(e.disabled),colorPalette:a??"brand",size:o}}const rFn=C.memo(function({value:t}){const[n,r]=C.useState(spe(t)),a=C.useMemo(()=>_(t.label),[t.label]),o=C.useMemo(()=>_(t.onChange),[t.onChange]);C.useEffect(()=>{r(()=>spe(t))},[t]);const i=C.useCallback(s=>{r(l=>({...l,checked:s.checked})),o&&queueMicrotask(()=>o(s.checked))},[o]);return p.jsxs(NIt,{...n,onCheckedChange:i,children:[p.jsx(OIt,{}),p.jsx(DIt,{}),a&&p.jsx($It,{children:a})]})},(e,t)=>nFn(e.value,t.value)),aFn=it(uE.Types.Root);function lpe(e){var t;const n=_(e.value),r=_(e.style),a=r?(t=_(r.size))==null?void 0:t.type:void 0,o=r?_(r.color):void 0,i=r?_(r.background):void 0,s=r?_(r.borderColor):void 0;return{value:n?[n]:[],multiple:_(e.multiple),disabled:_(e.disabled),size:a,allowCustomValue:_(e.allowCustomValue),color:o,bg:i,borderColor:s}}const oFn=C.memo(function({value:t}){const[n,r]=C.useState(lpe(t)),a=C.useMemo(()=>_(t.placeholder),[t.placeholder]),o=C.useMemo(()=>_(t.onChange),[t.onChange]),i=C.useMemo(()=>_(t.onChangeMultiple),[t.onChangeMultiple]),s=C.useMemo(()=>_(t.onInputValueChange),[t.onInputValueChange]),l=C.useMemo(()=>_(t.onOpenChange),[t.onOpenChange]),c=C.useMemo(()=>_(t.multiple),[t.multiple]),[u,d]=C.useState("");C.useEffect(()=>{r(()=>lpe(t))},[t]);const f=C.useMemo(()=>t.items.map(y=>({value:y.value,label:y.label,disabled:_(y.disabled)??!1})),[t.items]),h=C.useMemo(()=>{const y=f.filter(x=>x.label.toLowerCase().includes(u.toLowerCase()));return Xne({items:y})},[f,u]),g=C.useCallback(y=>{r(x=>({...x,value:y.value})),c&&i?queueMicrotask(()=>i(y.value)):!c&&o&&y.value.length>0&&queueMicrotask(()=>o(y.value[0]))},[c,o,i]),v=C.useCallback(y=>{d(y.inputValue),s&&queueMicrotask(()=>s(y.inputValue))},[s]),b=C.useCallback(y=>{l&&queueMicrotask(()=>l(y.open))},[l]);return p.jsxs(pK,{...n,collection:h,inputValue:u,onValueChange:g,onInputValueChange:v,onOpenChange:b,children:[p.jsxs(gK,{children:[p.jsx(hK,{placeholder:a??"Search..."}),p.jsxs(cAe,{children:[p.jsx($Nt,{}),p.jsx(iAe,{})]})]}),p.jsx(go,{children:p.jsx(sAe,{children:p.jsxs(lAe,{children:[p.jsx(fAe,{children:"No results found"}),h.items.map(y=>p.jsxs(uAe,{item:y,children:[y.label,p.jsx(dAe,{})]},y.value))]})})})]})},(e,t)=>aFn(e.value,t.value)),iFn=it(hq.Types.Slider);function cpe(e){var t,n,r,a;const o=_(e.style),i=o?(t=_(o.orientation))==null?void 0:t.type:void 0,s=o?(n=_(o.colorPalette))==null?void 0:n.type:void 0,l=o?(r=_(o.size))==null?void 0:r.type:void 0,c=o?(a=_(o.variant))==null?void 0:a.type:void 0;return{value:[e.value],min:_(e.min),max:_(e.max),step:_(e.step),orientation:i,colorPalette:s??"brand",size:l,variant:c,disabled:_(e.disabled)}}const sFn=C.memo(function({value:t}){const[n,r]=C.useState(cpe(t)),a=C.useMemo(()=>_(t.onChange),[t.onChange]),o=C.useMemo(()=>_(t.onChangeEnd),[t.onChangeEnd]);C.useEffect(()=>{r(()=>cpe(t))},[t]);const i=C.useCallback(l=>{r(c=>({...c,value:l.value})),a&&l.value.length>0&&queueMicrotask(()=>a(l.value[0]))},[a]),s=C.useCallback(l=>{r(c=>({...c,value:l.value})),o&&l.value.length>0&&queueMicrotask(()=>o(l.value[0]))},[o]);return p.jsx(fIt,{...n,width:"100%",thumbAlignment:"center",onValueChange:i,onValueChangeEnd:s,children:p.jsxs(wIt,{children:[p.jsx(pIt,{children:p.jsx(hIt,{})}),p.jsx(xIt,{})]})})},(e,t)=>iFn(e.value,t.value)),lFn=it(B3t.Types.Field);function cFn(e){return{required:_(e.required),disabled:_(e.disabled),invalid:_(e.invalid),readOnly:_(e.readOnly)}}const uFn=C.memo(function({value:t,storageKey:n}){const r=C.useMemo(()=>cFn(t),[t]),a=C.useMemo(()=>_(t.helperText),[t.helperText]),o=C.useMemo(()=>_(t.errorText),[t.errorText]),i=C.useMemo(()=>_(t.style),[t.style]),s=C.useMemo(()=>i?_(i.schemaKey):void 0,[i]);return p.jsxs(PE,{...r,children:[p.jsxs(AE,{children:[t.label,s&&p.jsx(V,{as:"span",ml:"2",fontFamily:"mono",fontSize:"11px",fontWeight:"500",letterSpacing:"0",textTransform:"none",color:"fg.muted",children:s})]}),p.jsx(mn,{value:t.control,storageKey:`${n}.control`}),a&&p.jsx(e$t,{children:a}),o&&p.jsx(t$t,{children:o})]})},(e,t)=>lFn(e.value,t.value)&&e.storageKey===t.storageKey),dFn=it(mq.Types.Textarea);function upe(e){var t,n,r;const a=_(e.rows),o=_(e.maxLength),i=_(e.style),s=i?(t=_(i.variant))==null?void 0:t.type:void 0,l=i?(n=_(i.size))==null?void 0:n.type:void 0,c=i?(r=_(i.resize))==null?void 0:r.type:void 0,u=i?_(i.color):void 0,d=i?_(i.background):void 0,f=i?_(i.borderColor):void 0,h=i?_(i.focusBorderColor):void 0;return{value:e.value,placeholder:_(e.placeholder),variant:s,size:l,resize:c,rows:a!==void 0?Number(a):void 0,disabled:_(e.disabled),readOnly:_(e.readOnly),required:_(e.required),..._(e.invalid)?{"aria-invalid":!0}:{},maxLength:o!==void 0?Number(o):void 0,autoresize:_(e.autoresize),color:u,bg:d,borderColor:f,...h?{_focus:{borderColor:h,boxShadow:`0 0 0 1px ${h}`}}:{}}}const fFn=C.memo(function({value:t}){const[n,r]=C.useState(upe(t)),a=C.useMemo(()=>_(t.onChange),[t.onChange]),o=C.useMemo(()=>_(t.onBlur),[t.onBlur]),i=C.useMemo(()=>_(t.onFocus),[t.onFocus]);C.useEffect(()=>{r(()=>upe(t))},[t]);const s=C.useCallback(u=>{const d=u.target.value;r(f=>({...f,value:d})),a&&queueMicrotask(()=>a(d))},[a]),l=C.useCallback(()=>{o&&queueMicrotask(()=>o())},[o]),c=C.useCallback(()=>{i&&queueMicrotask(()=>i())},[i]);return p.jsx(Yre,{...n,onChange:s,onBlur:l,onFocus:c})},(e,t)=>dFn(e.value,t.value)),pFn=it(vq.Types.FileUpload);function hFn(e){var t;const n=_(e.maxFiles),r=_(e.maxFileSize),a=_(e.minFileSize);return{accept:_(e.accept),maxFiles:n!==void 0?Number(n):void 0,maxFileSize:r!==void 0?Number(r):void 0,minFileSize:a!==void 0?Number(a):void 0,directory:_(e.directory),disabled:_(e.disabled),required:_(e.required),allowDrop:_(e.allowDrop),capture:(t=_(e.capture))==null?void 0:t.type,name:_(e.name)}}const gFn=C.memo(function({value:t}){const n=C.useMemo(()=>hFn(t),[t]),r=C.useMemo(()=>_(t.label),[t.label]),a=C.useMemo(()=>_(t.dropzoneText),[t.dropzoneText]),o=C.useMemo(()=>_(t.triggerText),[t.triggerText]),i=C.useMemo(()=>{var d;return(d=_(t.orientation))==null?void 0:d.type},[t.orientation]),s=C.useMemo(()=>_(t.onFileAccept),[t.onFileAccept]),l=C.useMemo(()=>_(t.onFileReject),[t.onFileReject]),c=C.useCallback(d=>{if(s){const f=d.files.map(h=>({name:h.name,size:BigInt(h.size),type:h.type}));queueMicrotask(()=>s(f))}},[s]),u=C.useCallback(d=>{if(l){const f=d.files.map(h=>({file:{name:h.file.name,size:BigInt(h.file.size),type:h.file.type},errors:h.errors.map(g=>String(g))}));queueMicrotask(()=>l(f))}},[l]);return p.jsxs(r$t,{...n,onFileAccept:s?c:void 0,onFileReject:l?u:void 0,children:[r&&p.jsx(s$t,{children:r}),p.jsx(a$t,{py:i==="horizontal"?"4":"6",children:p.jsxs(Vo,{direction:i==="horizontal"?"row":"column",align:"center",justify:"center",gap:"2",textAlign:"center",children:[p.jsx(V,{color:"fg.muted",fontSize:"20px",lineHeight:"1","aria-hidden":!0,children:p.jsx(Ut,{icon:fOe})}),p.jsxs(V,{fontSize:"sm",color:"fg",children:[p.jsx(l$t,{asChild:!0,children:p.jsx(V,{as:"span",color:"link",cursor:"pointer",textDecoration:"underline",textUnderlineOffset:"2px",children:o??"Choose files"})}),a&&p.jsx(V,{as:"span",ml:"2",children:a})]})]})}),p.jsx(_Ae,{children:p.jsx(u$t,{children:({acceptedFiles:d})=>d.map(f=>p.jsxs(TAe,{file:f,children:[p.jsx(wK,{}),p.jsx(LAe,{}),p.jsx(EAe,{})]},f.name))})}),p.jsx(d$t,{})]})},(e,t)=>pFn(e.value,t.value)),mFn=it(Sq.Types.Progress);function vFn(e){var t,n,r;const a=_(e.style),o=_(e.indeterminate)??!1,i=a?(t=_(a.tone))==null?void 0:t.type:void 0,s=a?(n=_(a.size))==null?void 0:n.type:void 0,l=s==="xs"||s==="sm"||s==="md"?s:void 0;return{value:o?null:e.value,min:_(e.min),max:_(e.max),size:l,variant:a?(r=_(a.variant))==null?void 0:r.type:void 0,striped:a?_(a.striped):void 0,animated:a?_(a.animated):void 0,...i!==void 0?{sentiment:i}:{}}}function yFn(e,t,n){if(!e||t===void 0)return;const r=n-e.getTime(),o=Number(t)*1e3-r;if(o<=0)return;const i=Math.max(0,Math.round(o/1e3));if(i<60)return`~${i}s remaining`;const s=Math.floor(i/60),l=i%60;return l===0?`~${s}m remaining`:`~${s}m ${l}s remaining`}const bFn=C.memo(function({value:t}){const n=C.useMemo(()=>vFn(t),[t]),r=C.useMemo(()=>_(t.label),[t.label]),a=C.useMemo(()=>_(t.valueText),[t.valueText]),o=_(t.showValue)??!1,i=_(t.estimatedDuration),s=_(t.startedAt),[l,c]=C.useState(()=>Date.now());C.useEffect(()=>{if(!s||i===void 0)return;const y=window.setInterval(()=>c(Date.now()),1e3);return()=>window.clearInterval(y)},[s,i]);const u=C.useMemo(()=>yFn(s,i,l),[s,i,l]),d=o&&!_(t.indeterminate)?`${Math.round(t.value)}%`:void 0,f=u??a??d,h=_(t.style),g=h?_(h.trackColor):void 0,v=h?_(h.fillColor):void 0,b=h?_(h.labelColor):void 0;return p.jsxs(N$t,{...n,children:[r||f?p.jsxs($$t,{...b!==void 0?{color:b}:{},children:[r,f?p.jsx(O$t,{children:f}):null]}):null,p.jsx(I$t,{...g!==void 0?{style:{background:g}}:{},children:p.jsx(D$t,{...v!==void 0?{style:{background:v}}:{}})})]})},(e,t)=>mFn(e.value,t.value)),xFn=it(kq.Types.EmptyState),wFn=C.memo(function({value:t,storageKey:n}){var r;const a=C.useMemo(()=>_(t.style),[t.style]),o=C.useMemo(()=>_(t.icon),[t.icon]),i=C.useMemo(()=>_(t.glyph),[t.glyph]),s=C.useMemo(()=>_(t.description),[t.description]),l=C.useMemo(()=>_(t.actions),[t.actions]),c=a?(r=_(a.size))==null?void 0:r.type:void 0,u=a?_(a.color):void 0,d=a?_(a.background):void 0,f=a?_(a.borderColor):void 0,h=a?_(a.iconColor):void 0;return p.jsx(mK,{...c!==void 0?{size:c}:{},...u!==void 0?{color:u}:{},...d!==void 0?{bg:d}:{},...f!==void 0?{borderColor:f,borderWidth:"1px"}:{},colorPalette:"brand",paddingInline:"28px",paddingBlock:"36px",children:p.jsxs(vK,{children:[i!==void 0?p.jsx(V,{fontFamily:"mono",fontSize:"36px",letterSpacing:"0.1em",color:h??"border.strong",mb:"3",lineHeight:"1",children:i}):o?p.jsx(yK,{...h!==void 0?{color:h}:{},children:p.jsx(Ut,{icon:[o.prefix,o.name]})}):null,p.jsxs(V,{children:[p.jsx(bK,{fontSize:"15px",fontWeight:"semibold",children:p.jsx(mn,{value:t.title,storageKey:`${n??""}.title`})}),s?p.jsx(xK,{fontSize:"13.5px",color:"fg.subtle",children:p.jsx(mn,{value:s,storageKey:`${n??""}.description`})}):null]}),l?p.jsx(V,{mt:"4",children:p.jsx(mn,{value:l,storageKey:`${n??""}.actions`})}):null]})})},(e,t)=>xFn(e.value,t.value)&&e.storageKey===t.storageKey),SFn=it(zq.Types.Skeleton),CFn=C.memo(function({value:t}){const n=C.useMemo(()=>_(t.style),[t.style]),r=n?_(n.width):void 0,a=n?_(n.height):void 0,o=n?_(n.fontSize):void 0,i=n?_(n.background):void 0,s=n?_(n.shimmerColor):void 0,l=_(t.count),c=l!==void 0?Number(l):1,u={};i!==void 0&&(u["--chakra-colors-bg-emphasized"]=i),s!==void 0&&(u["--chakra-colors-bg"]=s);const d=t.shape.type,f=h=>{if(d==="text"){const g=_(t.lines);return p.jsx(Gre,{noOfLines:g!==void 0?Number(g):3,...o!==void 0?{fontSize:o}:{},...r!==void 0?{width:r}:{},css:u},h)}return d==="circle"?p.jsx(nNe,{size:r??a??"10",css:u},h):p.jsx(d4,{...r!==void 0?{width:r}:{},...a!==void 0?{height:a}:{height:"20px"},css:u},h)};return c<=1?f(0):p.jsx(W1,{align:"stretch",gap:"2",children:Array.from({length:c},(h,g)=>f(g))})},(e,t)=>SFn(e.value,t.value)),kFn=it(Mq.Types.Status),zFn={success:"fg.success",warning:"fg.warning",danger:"fg.danger",info:"fg.info",neutral:"fg.muted"},MFn=C.memo(function({value:t,storageKey:n}){var r;const a=en({key:"status"}),o=C.useMemo(()=>_(t.style),[t.style]),i=C.useMemo(()=>_(t.icon),[t.icon]),s=_(t.pulsing)??!1,[l,c]=C.useState(!1);C.useEffect(()=>{if(typeof window>"u")return;const b=window.matchMedia("(prefers-reduced-motion: reduce)");c(b.matches);const y=x=>c(x.matches);return b.addEventListener("change",y),()=>b.removeEventListener("change",y)},[]);const u=t.value.type,d=o?(r=_(o.size))==null?void 0:r.type:void 0,f=o?_(o.color):void 0,h=o?_(o.dotColor):void 0,v=a({status:u,size:d??"md",pulsing:s&&!l});return p.jsxs(Xr,{css:v.root,...f!==void 0?{color:f}:{},children:[p.jsx(V,{as:"span",css:v.indicator,...h!==void 0?{bg:h}:{}}),i?p.jsx(V,{as:"span",display:"inline-flex",alignItems:"center",color:h??zFn[u],children:p.jsx(Ut,{icon:[i.prefix,i.name]})}):null,p.jsx(V,{css:v.label,children:p.jsx(mn,{value:t.label,storageKey:`${n??""}.label`})})]})},(e,t)=>kFn(e.value,t.value)&&e.storageKey===t.storageKey),TFn=it(Cq.Types.Banner),EFn={info:"banner.partial",success:"banner.ok",warning:"banner.guard",error:"banner.error",neutral:"banner.partial",change:"banner.change",guard:"banner.guard",stale:"banner.dashed.stale"},_Fn={info:"fg.info",success:"fg.success",warning:"fg.warning",error:"fg.danger",neutral:"fg.muted",change:"border.brand",guard:"fg.warning",stale:"fg.muted"},LFn=C.memo(function({value:t,storageKey:n}){var r;const a=C.useMemo(()=>_(t.style),[t.style]),o=C.useMemo(()=>_(t.icon),[t.icon]),i=C.useMemo(()=>_(t.description),[t.description]),s=C.useMemo(()=>_(t.actions),[t.actions]),l=_(t.dismissible)??!1,c=C.useMemo(()=>_(t.onDismiss),[t.onDismiss]),u=t.status.type,d=EFn[u],f=_Fn[u],h=a?(r=_(a.variant))==null?void 0:r.type:void 0,g=a?_(a.background):void 0,v=a?_(a.color):void 0,b=a?_(a.borderColor):void 0,y=(a?_(a.iconColor):void 0)??f,x=C.useCallback(()=>{c&&queueMicrotask(()=>c())},[c]),S=u==="warning"||u==="error"?"alert":"status",z=h==="solid";return p.jsxs(V,{role:S,width:"100%",display:"flex",alignItems:"flex-start",gap:"3",flexWrap:"wrap",...z?{bg:g??f,color:v??"white",paddingX:"4",paddingY:"3",borderRadius:"2px"}:{layerStyle:d,...g!==void 0?{bg:g}:{},...v!==void 0?{color:v}:{}},...b!==void 0?{borderColor:b}:{},children:[o?p.jsx(V,{as:"span",display:"inline-flex",alignItems:"center",color:z?"currentcolor":y,fontSize:"md",flexShrink:0,pt:"0.5",children:p.jsx(Ut,{icon:[o.prefix,o.name],size:"lg"})}):null,p.jsxs(V,{flex:"1",minWidth:0,children:[p.jsx(V,{fontWeight:"semibold",fontSize:"sm",lineHeight:"1.4",children:p.jsx(mn,{value:t.title,storageKey:`${n??""}.title`})}),i?p.jsx(V,{fontSize:"13px",color:"fg.muted",lineHeight:"1.5",mt:"1",children:p.jsx(mn,{value:i,storageKey:`${n??""}.description`})}):null]}),p.jsxs(Xr,{gap:"2",flexShrink:0,children:[s?p.jsx(V,{colorPalette:"brand",children:p.jsx(mn,{value:s,storageKey:`${n??""}.actions`})}):null,l?p.jsx(Lre,{size:"sm",onClick:x}):null]})]})},(e,t)=>TFn(e.value,t.value)&&e.storageKey===t.storageKey),RFn=it(Yb.Types.Card);function PFn(e){var t;const n=_(e.style);return{height:Tt(n?_(n.height):void 0),minHeight:Tt(n?_(n.minHeight):void 0),maxHeight:Tt(n?_(n.maxHeight):void 0),width:Tt(n?_(n.width):void 0),minWidth:Tt(n?_(n.minWidth):void 0),maxWidth:Tt(n?_(n.maxWidth):void 0),flex:n?_(n.flex):void 0,overflow:n?(t=_(n.overflow))==null?void 0:t.type:void 0}}function AFn(e){switch(e){case"loading":return p.jsxs(V,{p:"3",children:[p.jsx(d4,{height:"24px",width:"60%",mb:"3"}),p.jsx(Gre,{noOfLines:3})]});case"empty":return p.jsx(mK,{size:"sm",children:p.jsxs(vK,{children:[p.jsx(yK,{children:p.jsx(Ut,{icon:MFe})}),p.jsxs(V,{children:[p.jsx(bK,{children:"No data"}),p.jsx(xK,{children:"There's nothing to show here yet."})]})]})});case"error":return p.jsxs(WPe,{status:"error",variant:"subtle",m:"3",children:[p.jsx(GPe,{children:p.jsx(Ut,{icon:Tv})}),p.jsxs(WAt,{children:[p.jsx(UPe,{children:"Something went wrong"}),p.jsx(qPe,{children:"This content failed to load."})]})]});case"permission-denied":return p.jsx(mK,{size:"sm",children:p.jsxs(vK,{children:[p.jsx(yK,{children:p.jsx(Ut,{icon:Jae})}),p.jsxs(V,{children:[p.jsx(bK,{children:"Access denied"}),p.jsx(xK,{children:"You don't have permission to view this content."})]})]})});default:return null}}const NFn=C.memo(function({value:t,storageKey:n}){const r=C.useMemo(()=>PFn(t),[t]),a=C.useMemo(()=>_(t.header),[t.header]),o=C.useMemo(()=>_(t.footer),[t.footer]),i=_(t.state),s=(i==null?void 0:i.type)??"ready",l=C.useMemo(()=>{var R;return(R=_(t.density))==null?void 0:R.type},[t.density]),c=_(t.style),u=c?_(c.background):void 0,d=c?_(c.borderColor):void 0,f=c?_(c.headerBackground):void 0,h=c?_(c.footerBackground):void 0,g=c?_(c.accentColor):void 0,v=c?_(c.bodyPadding):void 0,b=(c?_(c.flush):void 0)===!0,y=r.height!==void 0||r.maxHeight!==void 0,x=s==="disabled",S=s==="stale",z=s==="loading"||s==="empty"||s==="error"||s==="permission-denied",M=d??"border.subtle",L=p.jsxs(pNt,{...r,borderRadius:"10px",borderColor:M,borderWidth:"1px",overflow:r.overflow??"hidden",...y?{display:"flex",flexDirection:"column"}:{},...u!==void 0?{bg:u}:{},...g!==void 0?{borderLeftWidth:"3px",borderLeftColor:g}:{},"aria-disabled":x||void 0,opacity:x?.5:void 0,position:S?"relative":void 0,children:[a&&p.jsx(gNt,{paddingY:"12px",paddingX:"18px",borderBottomWidth:"1px",borderBottomColor:M,bg:f??"bg.canvas",display:"flex",flexDirection:"column",gap:"1",fontFamily:"mono",fontSize:"11px",children:p.jsx(mn,{value:a,storageKey:`${n}.header`})}),S&&p.jsxs(V,{layerStyle:"banner.stale",borderRadius:"0",display:"flex",alignItems:"center",gap:"2",children:[p.jsx(V,{as:"span",color:"fg.warning",children:p.jsx(Ut,{icon:xae})}),p.jsx(V,{fontWeight:"semibold",fontSize:"sm",children:"Stale data"})]}),p.jsx(hNt,{padding:b?"0":v??"18px 20px",display:"flex",flexDirection:"column",gap:b?"0":"3",...y?{flex:"1",minHeight:"0"}:{},opacity:S?.6:void 0,children:z?AFn(s):t.body.map((R,N)=>p.jsx(mn,{value:R,storageKey:`${n}.${N}`},N))}),o&&p.jsx(mNt,{paddingY:"10px",paddingX:"18px",borderTopWidth:"1px",borderTopColor:M,bg:h??"bg.canvas",display:"flex",alignItems:"center",gap:"3",children:p.jsx(mn,{value:o,storageKey:`${n}.footer`})})]});return l!==void 0?p.jsx(hu,{value:l,children:L}):L},(e,t)=>RFn(e.value,t.value)&&e.storageKey===t.storageKey),$Fn=it(lG.Types.Tooltip),IFn=500,DFn=C.memo(function({value:t,storageKey:n}){const r=C.useMemo(()=>_(t.style),[t.style]),a=C.useMemo(()=>{var g;return r?(g=_(r.placement))==null?void 0:g.type:void 0},[r]),o=C.useMemo(()=>r?_(r.hasArrow):void 0,[r]),i=Poe(),[s,l]=C.useState(!1),c=C.useRef(void 0);C.useEffect(()=>()=>clearTimeout(c.current),[]);const u=C.useCallback(g=>{g.pointerType!=="touch"&&g.pointerType!=="pen"||(clearTimeout(c.current),c.current=setTimeout(()=>l(!0),IFn))},[]),d=C.useCallback(()=>{clearTimeout(c.current),l(!1)},[]),f=C.useCallback(g=>{g.preventDefault()},[]),h=en({key:"tooltip"})();return i?p.jsxs(s$,{positioning:a?{placement:a}:void 0,children:[p.jsx(l$,{asChild:!0,children:p.jsx("span",{style:{display:"inline-flex"},children:p.jsx(mn,{value:t.trigger,storageKey:`${n}.trigger`})})}),p.jsx(c$,{children:p.jsxs(u$,{children:[o&&p.jsx(lDt,{children:p.jsx(pNe,{})}),t.content]})})]}):p.jsxs(nu,{open:s,positioning:a?{placement:a}:void 0,children:[p.jsx(R6,{asChild:!0,children:p.jsx("span",{style:{display:"inline-flex"},onPointerDown:u,onPointerUp:d,onPointerLeave:d,onPointerCancel:d,onContextMenu:f,children:p.jsx(mn,{value:t.trigger,storageKey:`${n}.trigger`})})}),p.jsx(go,{children:p.jsx(M4,{children:p.jsxs(T4,{css:h.content,width:"auto",children:[o&&p.jsx(n$,{css:h.arrow}),t.content]})})})]})},(e,t)=>$Fn(e.value,t.value)&&e.storageKey===t.storageKey),OFn=it(zg.Types.Menu),jFn=C.memo(function({value:t,storageKey:n}){const r=C.useMemo(()=>_(t.style),[t.style]),a=C.useMemo(()=>{var i;return r?(i=_(r.placement))==null?void 0:i.type:void 0},[r]),o=en({key:"menu"})();return p.jsxs(fm,{positioning:a?{placement:a}:void 0,children:[p.jsx(Ore,{asChild:!0,children:p.jsx("span",{style:{display:"inline-flex"},children:p.jsx(mn,{value:t.trigger,storageKey:`${n}.trigger`})})}),p.jsx(go,{children:p.jsx(pm,{children:p.jsx(hm,{children:t.items.map((i,s)=>Sr(i,{Item:l=>{const c=_(l.icon),u=_(l.command),d=_(l.destructive);return p.jsxs(ep,{value:l.value,disabled:_(l.disabled),...d?{"data-destructive":""}:{},children:[c&&p.jsx(V,{as:"span",css:o.itemIndicator,children:p.jsx(Ut,{icon:["fas",c]})}),l.label,u&&p.jsx(V,{as:"span",css:o.itemCommand,children:u})]},s)},GroupLabel:l=>p.jsx(V,{css:o.itemGroupLabel,children:l.label},s),Separator:()=>p.jsx(OAe,{},s)}))})})})]})},(e,t)=>OFn(e.value,t.value)&&e.storageKey===t.storageKey),FFn=it(uG.Types.Popover),BFn=C.memo(function({value:t,storageKey:n}){const r=C.useMemo(()=>_(t.style),[t.style]),a=C.useMemo(()=>{var d;return r?(d=_(r.placement))==null?void 0:d.type:void 0},[r]),o=C.useMemo(()=>{var d;return r?(d=_(r.size))==null?void 0:d.type:void 0},[r]),i=C.useMemo(()=>r?_(r.hasArrow):void 0,[r]),s=C.useMemo(()=>_(t.title),[t.title]),l=C.useMemo(()=>_(t.description),[t.description]),c=C.useMemo(()=>r?_(r.onOpenChange):void 0,[r]),u=C.useCallback(d=>{c&&queueMicrotask(()=>c(d.open))},[c]);return p.jsxs(nu,{positioning:a?{placement:a}:void 0,size:o,onOpenChange:c?u:void 0,children:[p.jsx(R6,{asChild:!0,children:p.jsx("span",{style:{display:"inline-flex"},children:p.jsx(mn,{value:t.trigger,storageKey:`${n}.trigger`})})}),p.jsx(go,{children:p.jsx(M4,{children:p.jsxs(T4,{children:[i!==!1&&p.jsx(n$,{children:p.jsx(Bre,{})}),p.jsxs($C,{children:[s&&p.jsx(P$t,{children:s}),l&&p.jsx(A$t,{children:l}),t.body.map((d,f)=>p.jsx(mn,{value:d,storageKey:`${n}.${f}`},f))]})]})})})]})},(e,t)=>FFn(e.value,t.value)&&e.storageKey===t.storageKey),VFn=it(dG.Types.HoverCard),HFn=C.memo(function({value:t,storageKey:n}){const r=C.useMemo(()=>_(t.style),[t.style]),a=C.useMemo(()=>_(t.title),[t.title]),o=C.useMemo(()=>_(t.description),[t.description]),i=en({key:"hoverCard"})(),s=C.useMemo(()=>{var x;return r?(x=_(r.placement))==null?void 0:x.type:void 0},[r]),l=C.useMemo(()=>{var x;return r?(x=_(r.size))==null?void 0:x.type:void 0},[r]),c=C.useMemo(()=>r?_(r.hasArrow):void 0,[r]),u=C.useMemo(()=>{const x=r?_(r.openDelay):void 0;return x!==void 0?Number(x):void 0},[r]),d=C.useMemo(()=>{const x=r?_(r.closeDelay):void 0;return x!==void 0?Number(x):void 0},[r]),f=C.useMemo(()=>r?_(r.onOpenChange):void 0,[r]),h=Poe(),[g,v]=C.useState(!1),b=C.useCallback(x=>{h||v(x.open),f&&queueMicrotask(()=>f(x.open))},[h,f]),y=C.useCallback(()=>{const x=!g;v(x),f&&queueMicrotask(()=>f(x))},[g,f]);return p.jsxs(kL,{positioning:s?{placement:s}:void 0,size:l,openDelay:u,closeDelay:d,...h?{}:{open:g},onOpenChange:!h||f?b:void 0,children:[p.jsx(zL,{asChild:!0,children:p.jsx("span",{style:{display:"inline-flex"},...h?{}:{onClick:y},children:p.jsx(mn,{value:t.trigger,storageKey:`${n}.trigger`})})}),p.jsx(go,{children:p.jsx(Nre,{children:p.jsxs($re,{children:[c!==!1&&p.jsx(NAe,{children:p.jsx(Ire,{})}),a&&p.jsx(V,{css:i.title,children:a}),o&&p.jsx(V,{css:i.description,children:o}),t.body.map((x,S)=>p.jsx(mn,{value:x,storageKey:`${n}.${S}`},S))]})})})]})},(e,t)=>VFn(e.value,t.value)&&e.storageKey===t.storageKey),WFn=it(pE.Types.Dialog),UFn={xs:"320px",sm:"400px",md:"480px",lg:"640px",xl:"800px",cover:"calc(100vw - 32px)",full:"100vw"};function qFn(e){var t,n,r,a,o;const i=_(e.style);return{size:i?(t=_(i.size))==null?void 0:t.type:void 0,placement:i?(n=_(i.placement))==null?void 0:n.type:void 0,scrollBehavior:i?(r=_(i.scrollBehavior))==null?void 0:r.type:void 0,motionPreset:i?(a=_(i.motionPreset))==null?void 0:a.type:void 0,role:i?(o=_(i.role))==null?void 0:o.type:void 0}}function hZe({value:e,storageKey:t,trigger:n,open:r,onClose:a,onExitComplete:o}){const i=C.useMemo(()=>qFn(e),[e]),s=en({key:"dialog"})(),l=C.useMemo(()=>_(e.eyebrow),[e.eyebrow]),c=C.useMemo(()=>_(e.title),[e.title]),u=C.useMemo(()=>_(e.description),[e.description]),d=C.useMemo(()=>_(e.style),[e.style]),f=C.useMemo(()=>d?_(d.onOpenChange):void 0,[d]),h=C.useMemo(()=>d?_(d.onExitComplete):void 0,[d]),g=C.useMemo(()=>d?_(d.onEscapeKeyDown):void 0,[d]),v=C.useMemo(()=>d?_(d.onInteractOutside):void 0,[d]),b=C.useCallback(z=>{!z.open&&a&&a(),f&&queueMicrotask(()=>f(z.open))},[f,a]),y=C.useCallback(()=>{h&&queueMicrotask(()=>h()),o&&o()},[h,o]),x=C.useCallback(()=>{g&&queueMicrotask(()=>g())},[g]),S=C.useCallback(()=>{v&&queueMicrotask(()=>v())},[v]);return p.jsxs(hAe,{open:r,size:i.size,placement:i.placement,scrollBehavior:i.scrollBehavior,motionPreset:i.motionPreset,role:i.role,onOpenChange:f||a?b:void 0,onExitComplete:h||o?y:void 0,onEscapeKeyDown:g?x:void 0,onInteractOutside:v?S:void 0,children:[n&&p.jsx(BNt,{asChild:!0,children:p.jsx("span",{children:n})}),p.jsxs(go,{children:[p.jsx(vAe,{}),p.jsx(gAe,{children:p.jsxs(mAe,{maxW:UFn[i.size??"md"]??"480px",children:[l&&p.jsx(V,{css:s.eyebrow,children:l}),c&&p.jsx(HNt,{children:c}),u&&p.jsx(VNt,{children:u}),p.jsx(WNt,{children:e.body.map((z,M)=>p.jsx(mn,{value:z,storageKey:`${t}.${M}`},M))})]})})]})]})}const GFn=C.memo(function({value:t,storageKey:n}){const r=C.useMemo(()=>({body:t.body,eyebrow:t.eyebrow,title:t.title,description:t.description,style:t.style}),[t.body,t.eyebrow,t.title,t.description,t.style]);return p.jsx(hZe,{value:r,storageKey:n,trigger:p.jsx(mn,{value:t.trigger,storageKey:`${n}.trigger`})})},(e,t)=>WFn(e.value,t.value)&&e.storageKey===t.storageKey),KFn=it(hE.Types.Drawer);function YFn(e){var t,n;const r=_(e.style);return{size:r?(t=_(r.size))==null?void 0:t.type:void 0,placement:r?(n=_(r.placement))==null?void 0:n.type:void 0,contained:r?_(r.contained):void 0}}function gZe({value:e,storageKey:t,trigger:n,open:r,onClose:a,onExitComplete:o,railsSlot:i,fullscreen:s,onToggleFullscreen:l}){const c=C.useMemo(()=>YFn(e),[e]),[u,d]=C.useState(!1),f=s??u,h=C.useMemo(()=>_(e.eyebrow),[e.eyebrow]),g=C.useMemo(()=>_(e.title),[e.title]),v=C.useMemo(()=>_(e.description),[e.description]),b=en({key:"drawer"})(),y=C.useMemo(()=>_(e.style),[e.style]),x=C.useMemo(()=>y?_(y.onOpenChange):void 0,[y]),S=C.useMemo(()=>y?_(y.onExitComplete):void 0,[y]),z=C.useMemo(()=>y?_(y.bodyPadding):void 0,[y]),M=C.useMemo(()=>(y?_(y.flush):void 0)===!0,[y]),L=C.useMemo(()=>(y?_(y.fillBody):void 0)===!0,[y]),R=C.useCallback(B=>{!B.open&&a&&a(),x&&queueMicrotask(()=>x(B.open))},[x,a]),N=C.useCallback(()=>{S&&queueMicrotask(()=>S()),o&&o()},[S,o]),O=C.useCallback(()=>{l?l():d(B=>!B)},[l]),j=f?"full":c.size;return p.jsxs(bAe,{open:r,size:j,placement:c.placement,contained:c.contained,onOpenChange:R,onExitComplete:S||o?N:void 0,children:[n&&p.jsx(UNt,{asChild:!0,children:p.jsx("span",{children:n})}),p.jsxs(go,{children:[p.jsx(SAe,{}),p.jsxs(xAe,{children:[i,p.jsxs(wAe,{children:[p.jsxs(kAe,{children:[p.jsxs(V,{flex:"1",minWidth:"0",children:[h&&p.jsx(V,{css:b.eyebrow,children:h}),g&&p.jsx(GNt,{children:g}),v&&p.jsx(qNt,{children:v})]}),p.jsx(fc,{"aria-label":f?"Exit fullscreen":"Enter fullscreen",onClick:O,variant:"ghost",size:"sm",children:p.jsx(Ut,{icon:f?ioe:w$})})]}),p.jsx(CAe,{padding:M?"0":z??"16px 20px",...L?{display:"flex",flexDirection:"column",minHeight:0,overflow:"hidden"}:{},children:e.body.map((B,H)=>p.jsx(mn,{value:B,storageKey:`${t}.${H}`},H))})]})]})]})]})}const XFn=C.memo(function({value:t,storageKey:n}){const r=C.useMemo(()=>({body:t.body,eyebrow:t.eyebrow,title:t.title,description:t.description,style:t.style}),[t.body,t.eyebrow,t.title,t.description,t.style]);return p.jsx(gZe,{value:r,storageKey:n,trigger:p.jsx(mn,{value:t.trigger,storageKey:`${n}.trigger`})})},(e,t)=>KFn(e.value,t.value)&&e.storageKey===t.storageKey),ZFn=it(pG.Types.ActionBar),QFn=C.memo(function({value:t}){const n=C.useMemo(()=>_(t.selectionCount),[t.selectionCount]),r=C.useMemo(()=>_(t.selectionLabel),[t.selectionLabel]),a=C.useMemo(()=>_(t.style),[t.style]),o=n!==void 0&&n>0,i=C.useMemo(()=>a?_(a.onSelect):void 0,[a]),s=C.useMemo(()=>a?_(a.onOpenChange):void 0,[a]),l=C.useCallback(u=>{s&&queueMicrotask(()=>s(u.open))},[s]),c=C.useCallback(u=>()=>{i&&queueMicrotask(()=>i(u))},[i]);return p.jsx(IAt,{open:o,onOpenChange:s?l:void 0,children:p.jsx(go,{children:p.jsx(DAt,{children:p.jsxs(OAt,{children:[p.jsxs(jAt,{children:[n," ",r??"selected"]}),p.jsx($3e,{}),t.items.map((u,d)=>Sr(u,{Action:f=>p.jsx(fu,{variant:"outline",size:"sm",disabled:_(f.disabled),onClick:i?c(f.value):void 0,children:f.label},d),Separator:()=>p.jsx($3e,{},d)}))]})})})})},(e,t)=>ZFn(e.value,t.value)),JFn=it(cG.Types.ToggleTip),eBn=C.memo(function({value:t,storageKey:n}){const r=C.useMemo(()=>_(t.style),[t.style]),a=C.useMemo(()=>{var c;return r?(c=_(r.placement))==null?void 0:c.type:void 0},[r]),o=C.useMemo(()=>r?_(r.hasArrow):void 0,[r]),i=C.useMemo(()=>r?_(r.onOpenChange):void 0,[r]),s=C.useCallback(c=>{i&&queueMicrotask(()=>i(c.open))},[i]),l=en({key:"tooltip"})();return p.jsxs(nu,{positioning:a?{placement:a}:void 0,onOpenChange:i?s:void 0,children:[p.jsx(R6,{asChild:!0,children:p.jsx("span",{style:{display:"inline-flex"},children:p.jsx(mn,{value:t.trigger,storageKey:`${n}.trigger`})})}),p.jsx(go,{children:p.jsx(M4,{children:p.jsxs(T4,{css:l.content,width:"auto",children:[o&&p.jsx(n$,{css:l.arrow}),t.content]})})})]})},(e,t)=>JFn(e.value,t.value)&&e.storageKey===t.storageKey),tBn=it(fG.Types.CommandPalette);function nBn(e,t){if(!t.trim())return e;const n=t.toLowerCase();return e.filter(r=>r.label.toLowerCase().includes(n)||r.keywords.some(a=>a.toLowerCase().includes(n)))}const rBn=C.memo(function({value:t}){const n=_(t.placeholder)??"Type a command…",r=_(t.triggerKey)??"mod+k",a=C.useMemo(()=>_(t.onOpenChange),[t.onOpenChange]),o=_(t.open),i=_(t.style),s=i?_(i.background):void 0,l=i?_(i.borderColor):void 0,c=i?_(i.inputBackground):void 0,u=i?_(i.inputColor):void 0,d=i?_(i.itemColor):void 0,f=i?_(i.selectedBackground):void 0,h=i?_(i.selectedColor):void 0,g=i?_(i.groupLabelColor):void 0,v=C.useMemo(()=>t.commands.map(W=>({id:W.id,label:W.label,shortcut:_(W.shortcut),group:_(W.group),keywords:_(W.keywords)??[],action:W.action})),[t.commands]),[b,y]=C.useState(o??!1);C.useEffect(()=>{o!==void 0&&y(o)},[o]);const[x,S]=C.useState(""),[z,M]=C.useState(0),L=C.useRef(null),R=C.useMemo(()=>nBn(v,x),[v,x]),N=C.useMemo(()=>{const W=new Map;for(const J of R){const ae=J.group??"";W.has(ae)||W.set(ae,[]),W.get(ae).push(J)}return W},[R]),O=C.useCallback(W=>{y(W),W&&(S(""),M(0)),a&&queueMicrotask(()=>a(W))},[a]);C.useEffect(()=>{b&&queueMicrotask(()=>{var W;return(W=L.current)==null?void 0:W.focus()})},[b]);const j=C.useCallback(()=>{const W=R[z];W&&(O(!1),queueMicrotask(()=>W.action()))},[R,z,O]),B=W=>{S(W.target.value),M(0)},H=W=>{W.key==="ArrowDown"?(W.preventDefault(),M(J=>Math.min(J+1,R.length-1))):W.key==="ArrowUp"?(W.preventDefault(),M(J=>Math.max(J-1,0))):W.key==="Enter"&&(W.preventDefault(),j())};let K=0;const U=en({key:"commandPalette"})(),Z="Open command palette",G=r.toLowerCase().split("+").map(W=>W.trim());return p.jsxs(C.Fragment,{children:[p.jsxs(fu,{variant:"outline",size:"sm",onClick:()=>O(!0),"aria-haspopup":"dialog","aria-expanded":b,children:[p.jsx(Ie,{children:Z}),p.jsx(V,{as:"span",ml:"2",display:"inline-flex",gap:"1",children:G.map(W=>p.jsx(Dre,{fontSize:"xs",children:W==="mod"?"⌘":W},W))})]}),p.jsx(hAe,{open:b,onOpenChange:W=>O(W.open),size:"md",placement:"center",children:p.jsxs(go,{children:[p.jsx(vAe,{css:U.backdrop}),p.jsx(gAe,{children:p.jsxs(mAe,{css:U.content,bg:s,borderColor:l,"aria-label":"Command palette",children:[p.jsx(Ht.input,{ref:L,css:U.input,placeholder:n,value:x,onChange:B,onKeyDown:H,bg:c,color:u}),p.jsx(V,{css:U.list,children:R.length===0?p.jsx(V,{css:U.empty,children:"No commands found"}):Array.from(N.entries()).map(([W,J])=>p.jsxs(V,{children:[W&&p.jsx(Ie,{css:U.groupLabel,color:g,children:W}),J.map(ae=>{const ne=K++,Y=ne===z;return p.jsxs(V,{css:U.item,onMouseEnter:()=>M(ne),onClick:j,...Y?{"data-highlighted":""}:{},bg:Y?f:void 0,color:Y?h??d:d,children:[p.jsx(Ie,{css:U.itemText,children:ae.label}),ae.shortcut&&p.jsx(Ie,{css:U.itemKbd,children:ae.shortcut})]},ae.id)})]},W||"_default"))})]})})]})})]})},(e,t)=>tBn(e.value,t.value));zv.add(_v);const aBn=C.createContext(null);let iS=null;function eH(e){var t;const n=_(e.title),r=_(e.style),a=r?_(r.stacked)??!1:!1,o=r?_(r.stackIcon):void 0,i=(r?(t=_(r.placement))==null?void 0:t.type:void 0)??"end";return{title:n,icon:o,stacked:a,placement:i}}const oBn=C.memo(function({meta:t,onClick:n}){const r=en({key:"drawerStackRail"})(),a=t.title??"Back",o=t.placement==="start"?kd:r2;return p.jsxs(Ht.button,{css:r.rail,"aria-label":`Back to ${a}`,onClick:n,children:[p.jsx(Ut,{icon:t.icon?t.icon:o}),p.jsx(Ht.span,{css:r.label,children:a})]})});function iBn({ancestors:e,placement:t,onPopTo:n}){const r=en({key:"drawerStackRail"})(),a=t==="start"||t==="top"?1:-1;return p.jsx(Ht.div,{css:r.railGroup,order:a,children:e.map(({id:o,meta:i})=>p.jsx(oBn,{meta:i,onClick:()=>n(o)},o))})}let sBn=0,lBn=0;function cBn({children:e}){const[t,n]=C.useState([]),[r,a]=C.useState([]),[o,i]=C.useState(new Set),s=C.useCallback(g=>{i(v=>{const b=new Set(v);return b.has(g)?b.delete(g):b.add(g),b})},[]);C.useEffect(()=>{i(g=>{if(g.size===0)return g;const v=new Set(r.map(x=>x.id));let b=!1;const y=new Set;for(const x of g)v.has(x)?y.add(x):b=!0;return b?y:g})},[r]);const l=C.useCallback(g=>{const v=`dialog-${++sBn}`;n(b=>[...b,{id:v,value:g}])},[]),c=C.useCallback(g=>{n(v=>v.filter(b=>b.id!==g))},[]),u=C.useCallback(g=>{const v=`drawer-${++lBn}`;a(b=>[...b,{id:v,value:g}])},[]),d=C.useCallback(g=>{a(v=>v.filter(b=>b.id!==g))},[]),f=C.useCallback(g=>{a(v=>{const b=v.findIndex(y=>y.id===g);return b===-1?v:v.slice(0,b+1)})},[]),h={openDialog:l,openDrawer:u};return iS=h,p.jsxs(aBn.Provider,{value:h,children:[e,t.map(({id:g,value:v})=>p.jsx(uBn,{value:v,onClose:()=>c(g)},g)),(()=>{const g=r.slice(0,-1).map(y=>({id:y.id,meta:eH(y.value)})).filter(({meta:y})=>y.stacked),v=r.length>0?eH(r[r.length-1].value).placement:"end",b=g.length>0?p.jsx(iBn,{ancestors:g,placement:v,onPopTo:f}):void 0;return r.map(({id:y,value:x},S)=>{const z=S===r.length-1;return!z&&eH(x).stacked?null:p.jsx(dBn,{value:x,onClose:()=>d(y),railsSlot:z?b:void 0,fullscreen:o.has(y),onToggleFullscreen:()=>s(y)},y)})})()]})}function uBn({value:e,onClose:t}){const[n,r]=C.useState(!1);C.useEffect(()=>{r(!0)},[]);const a=C.useCallback(()=>r(!1),[]),o=C.useCallback(()=>t(),[t]);return p.jsx(hZe,{value:e,storageKey:"programmatic-dialog",open:n,onClose:a,onExitComplete:o})}function dBn({value:e,onClose:t,railsSlot:n,fullscreen:r,onToggleFullscreen:a}){const[o,i]=C.useState(!1);C.useEffect(()=>{i(!0)},[]);const s=C.useCallback(()=>i(!1),[]),l=C.useCallback(()=>t(),[t]);return p.jsx(gZe,{value:e,storageKey:"programmatic-drawer",open:o,onClose:s,onExitComplete:l,railsSlot:n,fullscreen:r,onToggleFullscreen:a})}const fBn=ECe.implement(e=>{if(!iS){console.warn("Dialog.open called but OverlayManagerProvider is not mounted. Wrap your app in <OverlayManagerProvider>.");return}iS.openDialog(e)}),pBn=LCe.implement(e=>{if(!iS){console.warn("Drawer.open called but OverlayManagerProvider is not mounted. Wrap your app in <OverlayManagerProvider>.");return}iS.openDrawer(e)}),Die=[fBn,pBn];s0(Die);const hBn=it($te.Types.Hotkey);function gBn(e,t){const n=t.toLowerCase().split("+").map(s=>s.trim()),r=n.includes("mod")||n.includes("ctrl")||n.includes("cmd"),a=n.includes("shift"),o=n.includes("alt")||n.includes("option"),i=n[n.length-1];return r&&!(e.metaKey||e.ctrlKey)||!r&&(e.metaKey||e.ctrlKey)||a!==e.shiftKey||o!==e.altKey?!1:e.key.toLowerCase()===i}const mBn=C.memo(function({value:t}){const{chord:n,onTrigger:r}=t;return C.useEffect(()=>{if(typeof document>"u")return;const a=o=>{const i=o.target;!(n.toLowerCase().includes("mod")||n.toLowerCase().includes("ctrl")||n.toLowerCase().includes("cmd"))&&i&&(i.tagName==="INPUT"||i.tagName==="TEXTAREA"||i.isContentEditable)||gBn(o,n)&&(o.preventDefault(),queueMicrotask(()=>r()))};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[n,r]),null},(e,t)=>hBn(e.value,t.value));function vBn(e){if(e.includes("no IR attached"))return"A raw JavaScript function reached the value serializer where an East function (one carrying compiled IR) was expected — typically a plain arrow passed to a prop that must be an East function. The Region below identifies the rendering subtree."}function dk({title:e,message:t,stack:n,context:r}){const a=vBn(t);return p.jsxs(WPe,{status:"error","data-east-error":"true",children:[p.jsx(GPe,{}),p.jsxs(qp,{gap:"2",flex:"1",children:[p.jsx(UPe,{children:e}),p.jsx(qPe,{children:p.jsxs(V,{children:[p.jsxs(qp,{gap:"1",children:[p.jsx(Ie,{fontWeight:"medium",children:t}),a&&p.jsx(Ie,{children:a}),r&&p.jsxs(Ie,{children:["Region: ",r]})]}),n&&p.jsx(qw,{display:"block",whiteSpace:"pre-wrap",fontSize:"xs",mt:"2",p:"2",layerStyle:"banner.error",borderRadius:"sm",maxHeight:"200px",overflow:"auto",children:n})]})})]})]})}function fk(e){const t=e instanceof Error?e.message:String(e),n=e instanceof Error?e.stack:void 0;return{message:t,stack:n}}class mZe extends C.Component{constructor(){super(...arguments),Lg(this,"state",{error:null})}static getDerivedStateFromError(t){return{error:t}}componentDidUpdate(t){t.resetKey!==this.props.resetKey&&this.state.error!==null&&this.setState({error:null})}componentDidCatch(t,n){console.error("[EastErrorBoundary]",t,n)}render(){if(this.state.error!==null){const{message:t,stack:n}=fk(this.state.error);return p.jsx(dk,{title:this.props.title,message:t,stack:n,context:this.props.context})}return this.props.children}}function vZe(e){const t=C.useSyncExternalStore(iht,lht),n=sht(),r=C.useRef(new Map),a=C.useCallback(()=>{for(const c of n)c.enableTracking();try{const c=e(),u=new Map;for(const d of n)u.set(d.id,d.disableTracking());return r.current=u,{ok:!0,value:c}}catch(c){const u=new Map;for(const d of n)u.set(d.id,d.disableTracking());return r.current=u,{ok:!1,error:c}}},[e,n]),o=C.useCallback(c=>{const u=[];for(const d of n){const f=d.getStore();if(!f)continue;const h=r.current.get(d.id)??[];for(const g of h)u.push(f.subscribe(g,c))}return()=>u.forEach(d=>d())},[n]),i=C.useCallback(()=>{const c=[];for(const u of n){const d=u.getStore();if(!d)continue;const f=r.current.get(u.id)??[];c.push(f.map(h=>`${u.id}:${h}:${d.getKeyVersion(h)}`).join(","))}return c.join("|")},[n]),s=C.useSyncExternalStore(o,i);return{result:C.useMemo(()=>a(),[a,s,t]),snapshot:s}}function Oie({value:e,storageKey:t}){const n=C.useCallback(()=>e.render(),[e]),{result:r,snapshot:a}=vZe(n);if(!r.ok){const o=fk(r.error);return p.jsx(dk,{title:"East Render Error",message:o.message,stack:o.stack,context:t})}return r.value===void 0||r.value===null?null:p.jsx(mZe,{title:"East Render Error",resetKey:a,context:t,children:p.jsx(mn,{value:r.value,storageKey:t})})}const yBn=C.memo(function({value:t,storageKey:n}){const r=C.useCallback(()=>t.tag(),[t]),{result:a}=vZe(r);if(!a.ok){const o=fk(a.error);return p.jsx(dk,{title:"East Render Error",message:o.message,stack:o.stack,context:n})}return p.jsx(Oie,{value:t,storageKey:n},`case:${a.value}`)},(e,t)=>e.storageKey===t.storageKey),dpe=C.memo(function({value:t,storageKey:n}){const r=t.navKey,a=C.useCallback(s=>ns().subscribe(r,s),[r]),o=C.useCallback(()=>ns().getKeyVersion(r),[r]),i=C.useSyncExternalStore(a,o);return p.jsx(Oie,{value:t,storageKey:n},`route:${i}`)},(e,t)=>e.value.navKey===t.value.navKey&&e.storageKey===t.storageKey),yZe=new Map;function pk(e,t){yZe.set(e.name,{schema:e.schema,renderer:t,decode:n=>Ra(e.schema,{platform:lv()})(n)})}function bBn(e){return yZe.get(e)}const xBn=C.memo(function({value:t,storageKey:n}){const r=bBn(t.kind),a=C.useMemo(()=>r?r.decode(t.payload):null,[r,t.payload]);if(!r)return p.jsxs(V,{layerStyle:"banner.error",fontFamily:"mono",fontSize:"xs",children:[p.jsx(Ie,{fontWeight:"semibold",children:"Extension renderer missing"}),p.jsxs(Ie,{children:["kind: ",t.kind]})]});const o=r.renderer;return p.jsx(o,{value:a,storageKey:n})}),wBn=it(je);function Vn(e,t){return e?`${e}.${t}`:t}const mn=C.memo(function({value:t,storageKey:n}){const r=C.useMemo(()=>Sr(t,{Text:a=>p.jsx(wjt,{value:a}),Code:a=>p.jsx(kjt,{value:a}),Heading:a=>p.jsx(Tjt,{value:a}),Link:a=>p.jsx(Ljt,{value:a}),Highlight:a=>p.jsx(Ajt,{value:a}),Mark:a=>p.jsx(Ijt,{value:a}),List:a=>p.jsx(rfn,{value:a,storageKey:Vn(n,"List")}),CodeBlock:a=>p.jsx(ifn,{value:a}),Numeric:a=>p.jsx(cfn,{value:a}),Note:a=>p.jsx(pfn,{value:a,storageKey:Vn(n,"Note")}),Button:a=>p.jsx(WVe,{value:a,storageKey:Vn(n,"Button")}),IconButton:a=>p.jsx(QWe,{value:a}),CopyButton:a=>p.jsx(JWe,{value:a}),CloseButton:a=>p.jsx(eUe,{value:a}),Toggle:a=>p.jsx(tUe,{value:a,storageKey:Vn(n,"Toggle")}),ButtonGroup:a=>p.jsx(Jxn,{value:a,storageKey:Vn(n,"ButtonGroup")}),Box:a=>p.jsx(_Rn,{value:a,storageKey:n}),Flex:a=>p.jsx(PRn,{value:a,storageKey:n}),Stack:a=>p.jsx($Rn,{value:a,storageKey:n}),AlignedStack:a=>p.jsx(DRn,{value:a,storageKey:Vn(n,"AlignedStack")}),Separator:a=>p.jsx(FRn,{value:a,storageKey:n}),Grid:a=>p.jsx(HRn,{value:a,storageKey:n}),Splitter:a=>p.jsx(YRn,{value:a,storageKey:Vn(n,"Splitter")}),Sticky:a=>p.jsx(ZRn,{value:a,storageKey:Vn(n,"Sticky")}),ScrollArea:a=>p.jsx(EPn,{value:a,storageKey:Vn(n,"ScrollArea")}),Expandable:a=>p.jsx(RPn,{value:a,storageKey:Vn(n,"Expandable")}),Dock:a=>p.jsx(APn,{value:a,storageKey:Vn(n,"Dock")}),ChipRail:a=>p.jsx($Pn,{value:a,storageKey:Vn(n,"ChipRail")}),StringInput:a=>p.jsx(Y$,{value:a}),IntegerInput:a=>p.jsx(X$,{value:a}),FloatInput:a=>p.jsx(Z$,{value:a}),DateTimeInput:a=>p.jsx(m9,{value:a}),Checkbox:a=>p.jsx(HXe,{value:a}),RadioGroup:a=>p.jsx(Yjn,{value:a}),RadioCardGroup:a=>p.jsx(Zjn,{value:a}),TimeRangeInput:a=>p.jsx(Jjn,{value:a}),DateRangeInput:a=>p.jsx(tFn,{value:a}),Switch:a=>p.jsx(rFn,{value:a}),Select:a=>p.jsx(h6,{value:a}),Combobox:a=>p.jsx(oFn,{value:a}),Slider:a=>p.jsx(sFn,{value:a}),FileUpload:a=>p.jsx(gFn,{value:a}),Field:a=>p.jsx(uFn,{value:a,storageKey:Vn(n,"Field")}),Textarea:a=>p.jsx(fFn,{value:a}),TagsInput:a=>p.jsx(EKe,{value:a}),Progress:a=>p.jsx(bFn,{value:a}),Banner:a=>p.jsx(LFn,{value:a,storageKey:Vn(n,"Banner")}),EmptyState:a=>p.jsx(wFn,{value:a,storageKey:Vn(n,"EmptyState")}),Skeleton:a=>p.jsx(CFn,{value:a}),Status:a=>p.jsx(MFn,{value:a,storageKey:Vn(n,"Status")}),Breadcrumb:a=>p.jsx(PIn,{value:a}),NavList:a=>p.jsx(IXe,{value:a}),Pages:a=>p.jsx(dpe,{value:a,storageKey:Vn(n,"Pages")}),Route:a=>p.jsx(dpe,{value:a,storageKey:Vn(n,"Route")}),App:a=>p.jsx(HIn,{value:a,storageKey:Vn(n,"App")}),Icon:a=>p.jsx(bXe,{value:a}),Badge:a=>p.jsx(qIn,{value:a}),Tag:a=>p.jsx(YIn,{value:a}),Avatar:a=>p.jsx(ZIn,{value:a}),Image:a=>p.jsx(DXe,{value:a}),Stat:a=>p.jsx(eDn,{value:a,storageKey:Vn(n,"Stat")}),MetricChip:a=>p.jsx(rDn,{value:a,storageKey:Vn(n,"MetricChip")}),EditableChip:a=>p.jsx(iDn,{value:a,storageKey:Vn(n,"EditableChip")}),Kbd:a=>p.jsx(lDn,{value:a}),Meter:a=>p.jsx(uDn,{value:a,storageKey:Vn(n,"Meter")}),SegmentedMeter:a=>p.jsx(hDn,{value:a,storageKey:Vn(n,"SegmentedMeter")}),BarStrip:a=>p.jsx(vDn,{value:a,storageKey:Vn(n,"BarStrip")}),AvatarGroup:a=>p.jsx(Gjn,{value:a}),Trace:a=>p.jsx(wDn,{value:a,storageKey:Vn(n,"Trace")}),SliceSummary:a=>p.jsx(aDn,{value:a}),SliceRange:a=>p.jsx(DKe,{value:a}),SliceFilter:a=>p.jsx(PKe,{value:a}),SliceLegend:a=>p.jsx(Qoe,{value:a}),SliceBreakdown:a=>p.jsx($Ke,{value:a}),SliceSearch:a=>p.jsx(AKe,{value:a}),SliceCohort:a=>p.jsx(sY,{value:a}),SliceRail:a=>p.jsx(uzn,{value:a}),Card:a=>p.jsx(NFn,{value:a,storageKey:n}),DataList:a=>p.jsx(SAn,{value:a,storageKey:Vn(n,"DataList")}),Matrix:a=>p.jsx(DNn,{value:a,storageKey:Vn(n,"Matrix")}),Pagination:a=>p.jsx(jNn,{value:a,storageKey:Vn(n,"Pagination")}),Table:a=>p.jsx(WNn,{value:a,storageKey:Vn(n,"Table")}),Gantt:a=>p.jsx(gIn,{value:a,storageKey:Vn(n,"Gantt")}),Planner:a=>p.jsx(EIn,{value:a,storageKey:Vn(n,"Planner")}),Library:a=>p.jsx(EDn,{value:a,storageKey:Vn(n,"Library")}),Deck:a=>p.jsx(ODn,{value:a,storageKey:Vn(n,"Deck")}),DeckReadout:a=>p.jsx($Dn,{value:a}),DeckRows:a=>p.jsx(IDn,{value:a}),DeckNote:a=>p.jsx(DDn,{value:a}),ValueTree:a=>p.jsx(Aie,{value:a,storageKey:Vn(n,"ValueTree")}),Roster:a=>p.jsx(iOn,{value:a,storageKey:Vn(n,"Roster")}),Board:a=>p.jsx(pOn,{value:a,storageKey:Vn(n,"Board")}),Calendar:a=>p.jsx(gOn,{value:a,storageKey:Vn(n,"Calendar")}),Schematic:a=>p.jsx(ejn,{value:a,storageKey:Vn(n,"Schematic")}),Flowchart:a=>p.jsx(Rjn,{value:a,storageKey:Vn(n,"Flowchart")}),Map:a=>p.jsx(Fjn,{value:a,storageKey:Vn(n,"Map")}),Blend:a=>p.jsx(Ujn,{value:a,storageKey:Vn(n,"Blend")}),Sparkline:a=>p.jsx(rwn,{value:a}),VisxChart:a=>p.jsx(yRn,{value:a}),TreeView:a=>p.jsx(XNn,{value:a,storageKey:Vn(n,"TreeView")}),Accordion:a=>p.jsx(BPn,{value:a,storageKey:Vn(n,"Accordion")}),Carousel:a=>p.jsx(WPn,{value:a,storageKey:Vn(n,"Carousel")}),Tabs:a=>p.jsx(ZPn,{value:a,storageKey:Vn(n,"Tabs")}),Story:a=>p.jsx(lAn,{value:a,storageKey:Vn(n,"Story")}),StoryStep:a=>p.jsx(cAn,{value:a,storageKey:Vn(n,"StoryStep")}),StoryProgress:a=>p.jsx(uAn,{value:a,storageKey:Vn(n,"StoryProgress")}),SegmentGroup:a=>p.jsx(pAn,{value:a,storageKey:Vn(n,"SegmentGroup")}),Collapsible:a=>p.jsx(gAn,{value:a,storageKey:Vn(n,"Collapsible")}),Disclosure:a=>p.jsx(vAn,{value:a,storageKey:Vn(n,"Disclosure")}),OptionList:a=>p.jsx(bAn,{value:a,storageKey:Vn(n,"OptionList")}),Tooltip:a=>p.jsx(DFn,{value:a,storageKey:Vn(n,"Tooltip")}),Menu:a=>p.jsx(jFn,{value:a,storageKey:Vn(n,"Menu")}),Popover:a=>p.jsx(BFn,{value:a,storageKey:Vn(n,"Popover")}),HoverCard:a=>p.jsx(HFn,{value:a,storageKey:Vn(n,"HoverCard")}),Dialog:a=>p.jsx(GFn,{value:a,storageKey:Vn(n,"Dialog")}),Drawer:a=>p.jsx(XFn,{value:a,storageKey:Vn(n,"Drawer")}),ActionBar:a=>p.jsx(QFn,{value:a}),ToggleTip:a=>p.jsx(eBn,{value:a,storageKey:Vn(n,"ToggleTip")}),CommandPalette:a=>p.jsx(rBn,{value:a}),Hotkey:a=>p.jsx(mBn,{value:a}),ReactiveComponent:a=>p.jsx(Oie,{value:a,storageKey:Vn(n,"ReactiveComponent")}),Match:a=>p.jsx(yBn,{value:a,storageKey:Vn(n,"Match")}),Extension:a=>p.jsx(xBn,{value:a,storageKey:Vn(n,`Extension:${a.kind}`)})}),[t,n]);return p.jsx(p.Fragment,{children:r})},(e,t)=>wBn(e.value,t.value)&&e.storageKey===t.storageKey);class hk{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}hk.prototype.normal={};hk.prototype.property={};hk.prototype.space=void 0;function bZe(e,t){const n={},r={};for(const a of e)Object.assign(n,a.property),Object.assign(r,a.normal);return new hk(n,r,t)}function fpe(e){return e.toLowerCase()}class g2{constructor(t,n){this.attribute=n,this.property=t}}g2.prototype.attribute="";g2.prototype.booleanish=!1;g2.prototype.boolean=!1;g2.prototype.commaOrSpaceSeparated=!1;g2.prototype.commaSeparated=!1;g2.prototype.defined=!1;g2.prototype.mustUseProperty=!1;g2.prototype.number=!1;g2.prototype.overloadedBoolean=!1;g2.prototype.property="";g2.prototype.spaceSeparated=!1;g2.prototype.space=void 0;let SBn=0;const aa=D7(),Gi=D7(),iX=D7(),pn=D7(),Fo=D7(),Mm=D7(),Oc=D7();function D7(){return 2**++SBn}const sX=Object.freeze(Object.defineProperty({__proto__:null,boolean:aa,booleanish:Gi,commaOrSpaceSeparated:Oc,commaSeparated:Mm,number:pn,overloadedBoolean:iX,spaceSeparated:Fo},Symbol.toStringTag,{value:"Module"})),tH=Object.keys(sX);class xZe extends g2{constructor(t,n,r,a){let o=-1;if(super(t,n),ppe(this,"space",a),typeof r=="number")for(;++o<tH.length;){const i=tH[o];ppe(this,tH[o],(r&sX[i])===sX[i])}}}xZe.prototype.defined=!0;function ppe(e,t,n){n&&(e[t]=n)}function jv(e){const t={},n={};for(const[r,a]of Object.entries(e.properties)){const o=new xZe(r,e.transform(e.attributes||{},r),a,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[fpe(r)]=r,n[fpe(o.attribute)]=r}return new hk(t,n,e.space)}const wZe=jv({properties:{ariaActiveDescendant:null,ariaAtomic:Gi,ariaAutoComplete:null,ariaBusy:Gi,ariaChecked:Gi,ariaColCount:pn,ariaColIndex:pn,ariaColSpan:pn,ariaControls:Fo,ariaCurrent:null,ariaDescribedBy:Fo,ariaDetails:null,ariaDisabled:Gi,ariaDropEffect:Fo,ariaErrorMessage:null,ariaExpanded:Gi,ariaFlowTo:Fo,ariaGrabbed:Gi,ariaHasPopup:null,ariaHidden:Gi,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Fo,ariaLevel:pn,ariaLive:null,ariaModal:Gi,ariaMultiLine:Gi,ariaMultiSelectable:Gi,ariaOrientation:null,ariaOwns:Fo,ariaPlaceholder:null,ariaPosInSet:pn,ariaPressed:Gi,ariaReadOnly:Gi,ariaRelevant:null,ariaRequired:Gi,ariaRoleDescription:Fo,ariaRowCount:pn,ariaRowIndex:pn,ariaRowSpan:pn,ariaSelected:Gi,ariaSetSize:pn,ariaSort:null,ariaValueMax:pn,ariaValueMin:pn,ariaValueNow:pn,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function SZe(e,t){return t in e?e[t]:t}function CZe(e,t){return SZe(e,t.toLowerCase())}const CBn=jv({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Mm,acceptCharset:Fo,accessKey:Fo,action:null,allow:null,allowFullScreen:aa,allowPaymentRequest:aa,allowUserMedia:aa,alt:null,as:null,async:aa,autoCapitalize:null,autoComplete:Fo,autoFocus:aa,autoPlay:aa,blocking:Fo,capture:null,charSet:null,checked:aa,cite:null,className:Fo,cols:pn,colSpan:null,content:null,contentEditable:Gi,controls:aa,controlsList:Fo,coords:pn|Mm,crossOrigin:null,data:null,dateTime:null,decoding:null,default:aa,defer:aa,dir:null,dirName:null,disabled:aa,download:iX,draggable:Gi,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:aa,formTarget:null,headers:Fo,height:pn,hidden:iX,high:pn,href:null,hrefLang:null,htmlFor:Fo,httpEquiv:Fo,id:null,imageSizes:null,imageSrcSet:null,inert:aa,inputMode:null,integrity:null,is:null,isMap:aa,itemId:null,itemProp:Fo,itemRef:Fo,itemScope:aa,itemType:Fo,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:aa,low:pn,manifest:null,max:null,maxLength:pn,media:null,method:null,min:null,minLength:pn,multiple:aa,muted:aa,name:null,nonce:null,noModule:aa,noValidate:aa,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:aa,optimum:pn,pattern:null,ping:Fo,placeholder:null,playsInline:aa,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:aa,referrerPolicy:null,rel:Fo,required:aa,reversed:aa,rows:pn,rowSpan:pn,sandbox:Fo,scope:null,scoped:aa,seamless:aa,selected:aa,shadowRootClonable:aa,shadowRootDelegatesFocus:aa,shadowRootMode:null,shape:null,size:pn,sizes:null,slot:null,span:pn,spellCheck:Gi,src:null,srcDoc:null,srcLang:null,srcSet:null,start:pn,step:null,style:null,tabIndex:pn,target:null,title:null,translate:null,type:null,typeMustMatch:aa,useMap:null,value:Gi,width:pn,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Fo,axis:null,background:null,bgColor:null,border:pn,borderColor:null,bottomMargin:pn,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:aa,declare:aa,event:null,face:null,frame:null,frameBorder:null,hSpace:pn,leftMargin:pn,link:null,longDesc:null,lowSrc:null,marginHeight:pn,marginWidth:pn,noResize:aa,noHref:aa,noShade:aa,noWrap:aa,object:null,profile:null,prompt:null,rev:null,rightMargin:pn,rules:null,scheme:null,scrolling:Gi,standby:null,summary:null,text:null,topMargin:pn,valueType:null,version:null,vAlign:null,vLink:null,vSpace:pn,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:aa,disableRemotePlayback:aa,prefix:null,property:null,results:pn,security:null,unselectable:null},space:"html",transform:CZe}),kBn=jv({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Oc,accentHeight:pn,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:pn,amplitude:pn,arabicForm:null,ascent:pn,attributeName:null,attributeType:null,azimuth:pn,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:pn,by:null,calcMode:null,capHeight:pn,className:Fo,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:pn,diffuseConstant:pn,direction:null,display:null,dur:null,divisor:pn,dominantBaseline:null,download:aa,dx:null,dy:null,edgeMode:null,editable:null,elevation:pn,enableBackground:null,end:null,event:null,exponent:pn,externalResourcesRequired:null,fill:null,fillOpacity:pn,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:Mm,g2:Mm,glyphName:Mm,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:pn,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:pn,horizOriginX:pn,horizOriginY:pn,id:null,ideographic:pn,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:pn,k:pn,k1:pn,k2:pn,k3:pn,k4:pn,kernelMatrix:Oc,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:pn,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:pn,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:pn,overlineThickness:pn,paintOrder:null,panose1:null,path:null,pathLength:pn,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Fo,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:pn,pointsAtY:pn,pointsAtZ:pn,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Oc,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Oc,rev:Oc,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Oc,requiredFeatures:Oc,requiredFonts:Oc,requiredFormats:Oc,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:pn,specularExponent:pn,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:pn,strikethroughThickness:pn,string:null,stroke:null,strokeDashArray:Oc,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:pn,strokeOpacity:pn,strokeWidth:null,style:null,surfaceScale:pn,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Oc,tabIndex:pn,tableValues:null,target:null,targetX:pn,targetY:pn,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Oc,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:pn,underlineThickness:pn,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:pn,values:null,vAlphabetic:pn,vMathematical:pn,vectorEffect:null,vHanging:pn,vIdeographic:pn,version:null,vertAdvY:pn,vertOriginX:pn,vertOriginY:pn,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:pn,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:SZe}),kZe=jv({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(e,t){return"xlink:"+t.slice(5).toLowerCase()}}),zZe=jv({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:CZe}),MZe=jv({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}});bZe([wZe,CBn,kZe,zZe,MZe],"html");bZe([wZe,kBn,kZe,zZe,MZe],"svg");var Qh={},nH,hpe;function zBn(){if(hpe)return nH;hpe=1;var e=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,t=/\n/g,n=/^\s*/,r=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,a=/^:\s*/,o=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,i=/^[;\s]*/,s=/^\s+|\s+$/g,l=`
|
|
673
673
|
`,c="/",u="*",d="",f="comment",h="declaration";function g(b,y){if(typeof b!="string")throw new TypeError("First argument must be a string");if(!b)return[];y=y||{};var x=1,S=1;function z(U){var Z=U.match(t);Z&&(x+=Z.length);var G=U.lastIndexOf(l);S=~G?U.length-G:S+U.length}function M(){var U={line:x,column:S};return function(Z){return Z.position=new L(U),O(),Z}}function L(U){this.start=U,this.end={line:x,column:S},this.source=y.source}L.prototype.content=b;function R(U){var Z=new Error(y.source+":"+x+":"+S+": "+U);if(Z.reason=U,Z.filename=y.source,Z.line=x,Z.column=S,Z.source=b,!y.silent)throw Z}function N(U){var Z=U.exec(b);if(Z){var G=Z[0];return z(G),b=b.slice(G.length),Z}}function O(){N(n)}function j(U){var Z;for(U=U||[];Z=B();)Z!==!1&&U.push(Z);return U}function B(){var U=M();if(!(c!=b.charAt(0)||u!=b.charAt(1))){for(var Z=2;d!=b.charAt(Z)&&(u!=b.charAt(Z)||c!=b.charAt(Z+1));)++Z;if(Z+=2,d===b.charAt(Z-1))return R("End of comment missing");var G=b.slice(2,Z-2);return S+=2,z(G),b=b.slice(Z),S+=2,U({type:f,comment:G})}}function H(){var U=M(),Z=N(r);if(Z){if(B(),!N(a))return R("property missing ':'");var G=N(o),W=U({type:h,property:v(Z[0].replace(e,d)),value:G?v(G[0].replace(e,d)):d});return N(i),W}}function K(){var U=[];j(U);for(var Z;Z=H();)Z!==!1&&(U.push(Z),j(U));return U}return O(),K()}function v(b){return b?b.replace(s,d):d}return nH=g,nH}var gpe;function MBn(){if(gpe)return Qh;gpe=1;var e=Qh&&Qh.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Qh,"__esModule",{value:!0}),Qh.default=n;const t=e(zBn());function n(r,a){let o=null;if(!r||typeof r!="string")return o;const i=(0,t.default)(r),s=typeof a=="function";return i.forEach(l=>{if(l.type!=="declaration")return;const{property:c,value:u}=l;s?a(c,u,l):u&&(o=o||{},o[c]=u)}),o}return Qh}var zb={},mpe;function TBn(){if(mpe)return zb;mpe=1,Object.defineProperty(zb,"__esModule",{value:!0}),zb.camelCase=void 0;var e=/^--[a-zA-Z0-9_-]+$/,t=/-([a-z])/g,n=/^[^-]+$/,r=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(c){return!c||n.test(c)||e.test(c)},i=function(c,u){return u.toUpperCase()},s=function(c,u){return"".concat(u,"-")},l=function(c,u){return u===void 0&&(u={}),o(c)?c:(c=c.toLowerCase(),u.reactCompat?c=c.replace(a,s):c=c.replace(r,s),c.replace(t,i))};return zb.camelCase=l,zb}var Mb,vpe;function EBn(){if(vpe)return Mb;vpe=1;var e=Mb&&Mb.__importDefault||function(a){return a&&a.__esModule?a:{default:a}},t=e(MBn()),n=TBn();function r(a,o){var i={};return!a||typeof a!="string"||(0,t.default)(a,function(s,l){s&&l&&(i[(0,n.camelCase)(s,o)]=l)}),i}return r.default=r,Mb=r,Mb}EBn();function _Bn(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?ype(e.position):"start"in e||"end"in e?ype(e):"line"in e||"column"in e?lX(e):""}function lX(e){return bpe(e&&e.line)+":"+bpe(e&&e.column)}function ype(e){return lX(e&&e.start)+"-"+lX(e&&e.end)}function bpe(e){return e&&typeof e=="number"?e:1}class wc extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let a="",o={},i=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?a=t:!o.cause&&t&&(i=!0,a=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof r=="string"){const l=r.indexOf(":");l===-1?o.ruleId=r:(o.source=r.slice(0,l),o.ruleId=r.slice(l+1))}if(!o.place&&o.ancestors&&o.ancestors){const l=o.ancestors[o.ancestors.length-1];l&&(o.place=l.position)}const s=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=s?s.column:void 0,this.fatal=void 0,this.file="",this.message=a,this.line=s?s.line:void 0,this.name=_Bn(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=i&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}wc.prototype.file="";wc.prototype.name="";wc.prototype.reason="";wc.prototype.message="";wc.prototype.stack="";wc.prototype.column=void 0;wc.prototype.line=void 0;wc.prototype.ancestors=void 0;wc.prototype.cause=void 0;wc.prototype.fatal=void 0;wc.prototype.place=void 0;wc.prototype.ruleId=void 0;wc.prototype.source=void 0;document.createElement("i");function LBn(e,t,n,r){const a=e.length;let o=0,i;if(t<0?t=-t>a?0:a+t:t=t>a?a:t,n=n>0?n:0,r.length<1e4)i=Array.from(r),i.unshift(t,n),e.splice(...i);else for(n&&e.splice(t,n);o<r.length;)i=r.slice(o,o+1e4),i.unshift(t,0),e.splice(...i),o+=1e4,t+=1e4}const sS=TI(/[A-Za-z]/),jie=TI(/[\dA-Za-z]/);function RBn(e){return e!==null&&(e<32||e===127)}function z9(e){return e!==null&&(e<0||e===32)}const TZe=TI(new RegExp("\\p{P}|\\p{S}","u")),lS=TI(/\s/);function TI(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}const EZe={resolveAll:PBn};function PBn(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),r.type==="labelImage"||r.type==="labelLink"||r.type==="labelEnd"){const a=r.type==="labelImage"?4:2;r.type="data",t+=a}}return e.length!==n.length&&LBn(e,0,e.length,n),e}EZe.resolveAll;EZe.resolveAll;const _Ze=(function(e){if(e==null)return IBn;if(typeof e=="function")return EI(e);if(typeof e=="object")return Array.isArray(e)?ABn(e):NBn(e);if(typeof e=="string")return $Bn(e);throw new Error("Expected function, string, or object as test")});function ABn(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=_Ze(e[n]);return EI(r);function r(...a){let o=-1;for(;++o<t.length;)if(t[o].apply(this,a))return!0;return!1}}function NBn(e){const t=e;return EI(n);function n(r){const a=r;let o;for(o in e)if(a[o]!==t[o])return!1;return!0}}function $Bn(e){return EI(t);function t(n){return n&&n.type===e}}function EI(e){return t;function t(n,r,a){return!!(DBn(n)&&e.call(this,n,typeof r=="number"?r:void 0,a||void 0))}}function IBn(){return!0}function DBn(e){return e!==null&&typeof e=="object"&&"type"in e}function xpe(e){if(e)throw e}var rH,wpe;function OBn(){if(wpe)return rH;wpe=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,a=function(c){return typeof Array.isArray=="function"?Array.isArray(c):t.call(c)==="[object Array]"},o=function(c){if(!c||t.call(c)!=="[object Object]")return!1;var u=e.call(c,"constructor"),d=c.constructor&&c.constructor.prototype&&e.call(c.constructor.prototype,"isPrototypeOf");if(c.constructor&&!u&&!d)return!1;var f;for(f in c);return typeof f>"u"||e.call(c,f)},i=function(c,u){n&&u.name==="__proto__"?n(c,u.name,{enumerable:!0,configurable:!0,value:u.newValue,writable:!0}):c[u.name]=u.newValue},s=function(c,u){if(u==="__proto__")if(e.call(c,u)){if(r)return r(c,u).value}else return;return c[u]};return rH=function l(){var c,u,d,f,h,g,v=arguments[0],b=1,y=arguments.length,x=!1;for(typeof v=="boolean"&&(x=v,v=arguments[1]||{},b=2),(v==null||typeof v!="object"&&typeof v!="function")&&(v={});b<y;++b)if(c=arguments[b],c!=null)for(u in c)d=s(v,u),f=s(c,u),v!==f&&(x&&f&&(o(f)||(h=a(f)))?(h?(h=!1,g=d&&a(d)?d:[]):g=d&&o(d)?d:{},i(v,{name:u,newValue:l(x,g,f)})):typeof f<"u"&&i(v,{name:u,newValue:f}));return v},rH}var jBn=OBn();const aH=v5(jBn);function cX(e){if(typeof e!="object"||e===null)return!1;const t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function FBn(){const e=[],t={run:n,use:r};return t;function n(...a){let o=-1;const i=a.pop();if(typeof i!="function")throw new TypeError("Expected function as last argument, not "+i);s(null,...a);function s(l,...c){const u=e[++o];let d=-1;if(l){i(l);return}for(;++d<a.length;)(c[d]===null||c[d]===void 0)&&(c[d]=a[d]);a=c,u?BBn(u,s)(...c):i(null,...c)}}function r(a){if(typeof a!="function")throw new TypeError("Expected `middelware` to be a function, not "+a);return e.push(a),t}}function BBn(e,t){let n;return r;function r(...i){const s=e.length>i.length;let l;s&&i.push(a);try{l=e.apply(this,i)}catch(c){const u=c;if(s&&n)throw u;return a(u)}s||(l&&l.then&&typeof l.then=="function"?l.then(o,a):l instanceof Error?a(l):o(l))}function a(i,...s){n||(n=!0,t(i,...s))}function o(i){a(null,i)}}const Nu={basename:VBn,dirname:HBn,extname:WBn,join:UBn,sep:"/"};function VBn(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');gk(e);let n=0,r=-1,a=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else r<0&&(o=!0,r=a+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let i=-1,s=t.length-1;for(;a--;)if(e.codePointAt(a)===47){if(o){n=a+1;break}}else i<0&&(o=!0,i=a+1),s>-1&&(e.codePointAt(a)===t.codePointAt(s--)?s<0&&(r=a):(s=-1,r=i));return n===r?r=i:r<0&&(r=e.length),e.slice(n,r)}function HBn(e){if(gk(e),e.length===0)return".";let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||(r=!0);return t<0?e.codePointAt(0)===47?"/":".":t===1&&e.codePointAt(0)===47?"//":e.slice(0,t)}function WBn(e){gk(e);let t=e.length,n=-1,r=0,a=-1,o=0,i;for(;t--;){const s=e.codePointAt(t);if(s===47){if(i){r=t+1;break}continue}n<0&&(i=!0,n=t+1),s===46?a<0?a=t:o!==1&&(o=1):a>-1&&(o=-1)}return a<0||n<0||o===0||o===1&&a===n-1&&a===r+1?"":e.slice(a,n)}function UBn(...e){let t=-1,n;for(;++t<e.length;)gk(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":qBn(n)}function qBn(e){gk(e);const t=e.codePointAt(0)===47;let n=GBn(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function GBn(e,t){let n="",r=0,a=-1,o=0,i=-1,s,l;for(;++i<=e.length;){if(i<e.length)s=e.codePointAt(i);else{if(s===47)break;s=47}if(s===47){if(!(a===i-1||o===1))if(a!==i-1&&o===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(l=n.lastIndexOf("/"),l!==n.length-1){l<0?(n="",r=0):(n=n.slice(0,l),r=n.length-1-n.lastIndexOf("/")),a=i,o=0;continue}}else if(n.length>0){n="",r=0,a=i,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(a+1,i):n=e.slice(a+1,i),r=i-a-1;a=i,o=0}else s===46&&o>-1?o++:o=-1}return n}function gk(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const KBn={cwd:YBn};function YBn(){return"/"}function uX(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function XBn(e){if(typeof e=="string")e=new URL(e);else if(!uX(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return ZBn(e)}function ZBn(e){if(e.hostname!==""){const r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const t=e.pathname;let n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){const r=t.codePointAt(n+2);if(r===70||r===102){const a=new TypeError("File URL path must not include encoded / characters");throw a.code="ERR_INVALID_FILE_URL_PATH",a}}return decodeURIComponent(t)}const oH=["history","path","basename","stem","extname","dirname"];class QBn{constructor(t){let n;t?uX(t)?n={path:t}:typeof t=="string"||JBn(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":KBn.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<oH.length;){const o=oH[r];o in n&&n[o]!==void 0&&n[o]!==null&&(this[o]=o==="history"?[...n[o]]:n[o])}let a;for(a in n)oH.includes(a)||(this[a]=n[a])}get basename(){return typeof this.path=="string"?Nu.basename(this.path):void 0}set basename(t){sH(t,"basename"),iH(t,"basename"),this.path=Nu.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Nu.dirname(this.path):void 0}set dirname(t){Spe(this.basename,"dirname"),this.path=Nu.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Nu.extname(this.path):void 0}set extname(t){if(iH(t,"extname"),Spe(this.dirname,"extname"),t){if(t.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(t.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Nu.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){uX(t)&&(t=XBn(t)),sH(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Nu.basename(this.path,this.extname):void 0}set stem(t){sH(t,"stem"),iH(t,"stem"),this.path=Nu.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const a=this.message(t,n,r);throw a.fatal=!0,a}info(t,n,r){const a=this.message(t,n,r);return a.fatal=void 0,a}message(t,n,r){const a=new wc(t,n,r);return this.path&&(a.name=this.path+":"+a.name,a.file=this.path),a.fatal=!1,this.messages.push(a),a}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function iH(e,t){if(e&&e.includes(Nu.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Nu.sep+"`")}function sH(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function Spe(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function JBn(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const eVn=(function(e){const r=this.constructor.prototype,a=r[e],o=function(){return a.apply(o,arguments)};return Object.setPrototypeOf(o,r),o}),tVn={}.hasOwnProperty;class Fie extends eVn{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=FBn()}copy(){const t=new Fie;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(aH(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(uH("data",this.frozen),this.namespace[t]=n,this):tVn.call(this.namespace,t)&&this.namespace[t]||void 0:t?(uH("data",this.frozen),this.namespace=t,this):this.namespace}freeze(){if(this.frozen)return this;const t=this;for(;++this.freezeIndex<this.attachers.length;){const[n,...r]=this.attachers[this.freezeIndex];if(r[0]===!1)continue;r[0]===!0&&(r[0]=void 0);const a=n.call(t,...r);typeof a=="function"&&this.transformers.use(a)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=vT(t),r=this.parser||this.Parser;return lH("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),lH("process",this.parser||this.Parser),cH("process",this.compiler||this.Compiler),n?a(void 0,n):new Promise(a);function a(o,i){const s=vT(t),l=r.parse(s);r.run(l,s,function(u,d,f){if(u||!d||!f)return c(u);const h=d,g=r.stringify(h,f);rVn(g)?f.value=g:f.result=g,c(u,f)});function c(u,d){u||!d?i(u):o?o(d):n(void 0,d)}}}processSync(t){let n=!1,r;return this.freeze(),lH("processSync",this.parser||this.Parser),cH("processSync",this.compiler||this.Compiler),this.process(t,a),kpe("processSync","process",n),r;function a(o,i){n=!0,xpe(o),r=i}}run(t,n,r){Cpe(t),this.freeze();const a=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?o(void 0,r):new Promise(o);function o(i,s){const l=vT(n);a.run(t,l,c);function c(u,d,f){const h=d||t;u?s(u):i?i(h):r(void 0,h,f)}}}runSync(t,n){let r=!1,a;return this.run(t,n,o),kpe("runSync","run",r),a;function o(i,s){xpe(i),a=s,r=!0}}stringify(t,n){this.freeze();const r=vT(n),a=this.compiler||this.Compiler;return cH("stringify",a),Cpe(t),a(t,r)}use(t,...n){const r=this.attachers,a=this.namespace;if(uH("use",this.frozen),t!=null)if(typeof t=="function")l(t,n);else if(typeof t=="object")Array.isArray(t)?s(t):i(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function o(c){if(typeof c=="function")l(c,[]);else if(typeof c=="object")if(Array.isArray(c)){const[u,...d]=c;l(u,d)}else i(c);else throw new TypeError("Expected usable value, not `"+c+"`")}function i(c){if(!("plugins"in c)&&!("settings"in c))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");s(c.plugins),c.settings&&(a.settings=aH(!0,a.settings,c.settings))}function s(c){let u=-1;if(c!=null)if(Array.isArray(c))for(;++u<c.length;){const d=c[u];o(d)}else throw new TypeError("Expected a list of plugins, not `"+c+"`")}function l(c,u){let d=-1,f=-1;for(;++d<r.length;)if(r[d][0]===c){f=d;break}if(f===-1)r.push([c,...u]);else if(u.length>0){let[h,...g]=u;const v=r[f][1];cX(v)&&cX(h)&&(h=aH(!0,v,h)),r[f]=[c,h,...g]}}}}new Fie().freeze();function lH(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function cH(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function uH(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Cpe(e){if(!cX(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function kpe(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function vT(e){return nVn(e)?e:new QBn(e)}function nVn(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function rVn(e){return typeof e=="string"||aVn(e)}function aVn(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}_Ze(["break","delete","emphasis","footnote","footnoteReference","image","imageReference","inlineCode","inlineMath","link","linkReference","mdxJsxTextElement","mdxTextExpression","strong","text","textDirective"]);const oVn={tokenize:uVn,partial:!0},LZe={tokenize:dVn,partial:!0},RZe={tokenize:fVn,partial:!0},PZe={tokenize:pVn,partial:!0},iVn={tokenize:hVn,partial:!0},AZe={name:"wwwAutolink",tokenize:lVn,previous:$Ze},NZe={name:"protocolAutolink",tokenize:cVn,previous:IZe},Md={name:"emailAutolink",tokenize:sVn,previous:DZe},Td={};let u8=48;for(;u8<123;)Td[u8]=Md,u8++,u8===58?u8=65:u8===91&&(u8=97);Td[43]=Md;Td[45]=Md;Td[46]=Md;Td[95]=Md;Td[72]=[Md,NZe];Td[104]=[Md,NZe];Td[87]=[Md,AZe];Td[119]=[Md,AZe];function sVn(e,t,n){const r=this;let a,o;return i;function i(d){return!dX(d)||!DZe.call(r,r.previous)||Bie(r.events)?n(d):(e.enter("literalAutolink"),e.enter("literalAutolinkEmail"),s(d))}function s(d){return dX(d)?(e.consume(d),s):d===64?(e.consume(d),l):n(d)}function l(d){return d===46?e.check(iVn,u,c)(d):d===45||d===95||jie(d)?(o=!0,e.consume(d),l):u(d)}function c(d){return e.consume(d),a=!0,l}function u(d){return o&&a&&sS(r.previous)?(e.exit("literalAutolinkEmail"),e.exit("literalAutolink"),t(d)):n(d)}}function lVn(e,t,n){const r=this;return a;function a(i){return i!==87&&i!==119||!$Ze.call(r,r.previous)||Bie(r.events)?n(i):(e.enter("literalAutolink"),e.enter("literalAutolinkWww"),e.check(oVn,e.attempt(LZe,e.attempt(RZe,o),n),n)(i))}function o(i){return e.exit("literalAutolinkWww"),e.exit("literalAutolink"),t(i)}}function cVn(e,t,n){const r=this;let a="",o=!1;return i;function i(d){return(d===72||d===104)&&IZe.call(r,r.previous)&&!Bie(r.events)?(e.enter("literalAutolink"),e.enter("literalAutolinkHttp"),a+=String.fromCodePoint(d),e.consume(d),s):n(d)}function s(d){if(sS(d)&&a.length<5)return a+=String.fromCodePoint(d),e.consume(d),s;if(d===58){const f=a.toLowerCase();if(f==="http"||f==="https")return e.consume(d),l}return n(d)}function l(d){return d===47?(e.consume(d),o?c:(o=!0,l)):n(d)}function c(d){return d===null||RBn(d)||z9(d)||lS(d)||TZe(d)?n(d):e.attempt(LZe,e.attempt(RZe,u),n)(d)}function u(d){return e.exit("literalAutolinkHttp"),e.exit("literalAutolink"),t(d)}}function uVn(e,t,n){let r=0;return a;function a(i){return(i===87||i===119)&&r<3?(r++,e.consume(i),a):i===46&&r===3?(e.consume(i),o):n(i)}function o(i){return i===null?n(i):t(i)}}function dVn(e,t,n){let r,a,o;return i;function i(c){return c===46||c===95?e.check(PZe,l,s)(c):c===null||z9(c)||lS(c)||c!==45&&TZe(c)?l(c):(o=!0,e.consume(c),i)}function s(c){return c===95?r=!0:(a=r,r=void 0),e.consume(c),i}function l(c){return a||r||!o?n(c):t(c)}}function fVn(e,t){let n=0,r=0;return a;function a(i){return i===40?(n++,e.consume(i),a):i===41&&r<n?o(i):i===33||i===34||i===38||i===39||i===41||i===42||i===44||i===46||i===58||i===59||i===60||i===63||i===93||i===95||i===126?e.check(PZe,t,o)(i):i===null||z9(i)||lS(i)?t(i):(e.consume(i),a)}function o(i){return i===41&&r++,e.consume(i),a}}function pVn(e,t,n){return r;function r(s){return s===33||s===34||s===39||s===41||s===42||s===44||s===46||s===58||s===59||s===63||s===95||s===126?(e.consume(s),r):s===38?(e.consume(s),o):s===93?(e.consume(s),a):s===60||s===null||z9(s)||lS(s)?t(s):n(s)}function a(s){return s===null||s===40||s===91||z9(s)||lS(s)?t(s):r(s)}function o(s){return sS(s)?i(s):n(s)}function i(s){return s===59?(e.consume(s),r):sS(s)?(e.consume(s),i):n(s)}}function hVn(e,t,n){return r;function r(o){return e.consume(o),a}function a(o){return jie(o)?n(o):t(o)}}function $Ze(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||z9(e)}function IZe(e){return!sS(e)}function DZe(e){return!(e===47||dX(e))}function dX(e){return e===43||e===45||e===46||e===95||jie(e)}function Bie(e){let t=e.length,n=!1;for(;t--;){const r=e[t][1];if((r.type==="labelLink"||r.type==="labelImage")&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}const gVn=C.createContext(null);function OZe({store:e,children:t}){const n=e??ns();return C.useEffect(()=>(n.setScheduler(r=>queueMicrotask(r)),()=>{n.setScheduler(void 0)}),[n]),C.useEffect(()=>(typeof window<"u"&&(window.__EAST_UI_STORE__=n),()=>{typeof window<"u"&&delete window.__EAST_UI_STORE__}),[n]),p.jsx(gVn.Provider,{value:n,children:t})}function mVn({render:e,storageKey:t}){const n=C.useMemo(()=>{try{return{ok:!0,value:e()}}catch(r){return{ok:!1,error:r}}},[e]);if(!n.ok){const r=fk(n.error);return p.jsx(dk,{title:"East Render Error",message:r.message,stack:r.stack})}return n.value===void 0||n.value===null?null:p.jsx(mZe,{title:"East Render Error",resetKey:e,children:p.jsx(mn,{value:n.value,storageKey:t})})}function vVn({bytes:e,storageKey:t}){const n=C.useMemo(()=>{const r=performance.now();try{const a=lv(),o=Ra(oQ)(e),i=performance.now(),s=elt(o,a),l=performance.now();return console.log(`[east-fn] decode ${(e.length/1024).toFixed(1)}KB in ${(i-r).toFixed(1)}ms, compile in ${(l-i).toFixed(1)}ms`),{compiled:s,error:null}}catch(a){return{compiled:null,error:a}}},[e]);if(n.error){const r=fk(n.error);return p.jsx(dk,{title:"East Compilation Error",message:r.message,stack:r.stack})}return p.jsx(mVn,{render:n.compiled,storageKey:t})}const yVn=({animate:e=!0,color:t,size:n="68px"})=>{const r=t??"currentColor",a=o=>e?{animation:`elara-pulse 2s ease-in-out ${o}s infinite`}:void 0;return p.jsx(V,{w:n,p:2,color:"link",lineHeight:0,children:p.jsxs("svg",{x:"0px",y:"0px",viewBox:"0 0 82.9 82.9",style:{width:"100%",height:"auto",display:"block"},children:[p.jsxs("g",{children:[p.jsx("path",{fill:r,d:"M80.7,53.4c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C78.5,52.5,79.5,53.4,80.7,53.4z"}),p.jsx("path",{fill:r,d:"M77.4,56.7c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C75.3,55.7,76.2,56.7,77.4,56.7z"}),p.jsx("path",{fill:r,d:"M74.2,60c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S73,60,74.2,60z"}),p.jsx("path",{fill:r,d:"M70.9,63.3c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C68.7,62.3,69.7,63.3,70.9,63.3z"}),p.jsx("path",{fill:r,d:"M67.6,66.5c1.2,0,2.2-1,2.2-2.2c0-1.2-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C65.4,65.6,66.4,66.5,67.6,66.5z"}),p.jsx("path",{fill:r,d:"M64.3,69.8c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2c-1.2,0-2.2,1-2.2,2.2C62.2,68.8,63.1,69.8,64.3,69.8z"}),p.jsx("path",{fill:r,d:"M61.1,73.1c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C58.9,72.1,59.9,73.1,61.1,73.1z"}),p.jsx("path",{fill:r,d:"M57.8,76.3c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C55.6,75.4,56.6,76.3,57.8,76.3z"}),p.jsx("path",{fill:r,d:"M54.5,79.6c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S53.3,79.6,54.5,79.6z"}),p.jsx("path",{fill:r,d:"M51.3,82.9c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S50.1,82.9,51.3,82.9z"}),p.jsx("path",{fill:r,d:"M80.7,46.9c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S79.5,46.9,80.7,46.9z"}),p.jsx("path",{fill:r,d:"M48,79.6c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S46.8,79.6,48,79.6z"}),p.jsx("path",{fill:r,d:"M44.7,82.9c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S43.5,82.9,44.7,82.9z"}),p.jsx("path",{fill:r,d:"M80.7,40.4c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S79.5,40.4,80.7,40.4z"}),p.jsx("path",{fill:r,d:"M38.2,82.9c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S37,82.9,38.2,82.9z"}),p.jsx("path",{fill:r,d:"M80.7,33.8c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S79.5,33.8,80.7,33.8z"}),p.jsx("path",{fill:r,d:"M31.6,82.9c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C29.4,81.9,30.4,82.9,31.6,82.9z"}),p.jsx("path",{fill:r,d:"M77.4,30.5c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S76.2,30.5,77.4,30.5z"}),p.jsx("path",{fill:r,d:"M28.4,79.6c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C26.2,78.6,27.2,79.6,28.4,79.6z"}),p.jsx("path",{fill:r,d:"M74.2,27.3c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S73,27.3,74.2,27.3z"}),p.jsx("path",{fill:r,d:"M25.1,76.3c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C22.9,75.4,23.9,76.3,25.1,76.3z"}),p.jsx("path",{fill:r,d:"M70.9,24c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C68.7,23,69.7,24,70.9,24z"}),p.jsx("path",{fill:r,d:"M21.8,73.1c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C19.6,72.1,20.6,73.1,21.8,73.1z"}),p.jsx("path",{fill:r,d:"M67.6,20.7c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S66.4,20.7,67.6,20.7z"}),p.jsx("path",{fill:r,d:"M18.5,69.8c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C16.4,68.8,17.3,69.8,18.5,69.8z"}),p.jsx("path",{fill:r,d:"M64.3,17.5c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2c-1.2,0-2.2,1-2.2,2.2S63.1,17.5,64.3,17.5z"}),p.jsx("path",{fill:r,d:"M15.3,66.5c1.2,0,2.2-1,2.2-2.2c0-1.2-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C13.1,65.6,14.1,66.5,15.3,66.5z"}),p.jsx("path",{fill:r,d:"M61.1,14.2c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S59.9,14.2,61.1,14.2z"}),p.jsx("path",{fill:r,d:"M12,63.3c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S10.8,63.3,12,63.3z"}),p.jsx("path",{fill:r,d:"M57.8,10.9c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S56.6,10.9,57.8,10.9z"}),p.jsx("path",{fill:r,d:"M8.7,60c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S7.5,60,8.7,60z"}),p.jsx("path",{fill:r,d:"M5.5,56.7c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S4.2,56.7,5.5,56.7z"}),p.jsx("path",{fill:r,d:"M2.2,53.4c1.2,0,2.2-1,2.2-2.2S3.4,49,2.2,49S0,50,0,51.2C0,52.5,1,53.4,2.2,53.4z"}),p.jsx("path",{fill:r,d:"M2.2,46.9c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2S0,43.5,0,44.7S1,46.9,2.2,46.9z"}),p.jsx("path",{fill:r,d:"M2.2,40.4c1.2,0,2.2-1,2.2-2.2S3.4,36,2.2,36S0,37,0,38.2S1,40.4,2.2,40.4z"}),p.jsx("path",{fill:r,d:"M25.1,10.9c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S23.9,10.9,25.1,10.9z"}),p.jsx("path",{fill:r,d:"M21.8,14.2c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S20.6,14.2,21.8,14.2z"}),p.jsx("path",{fill:r,d:"M18.5,17.5c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S17.3,17.5,18.5,17.5z"}),p.jsx("path",{fill:r,d:"M15.3,20.7c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S14.1,20.7,15.3,20.7z"}),p.jsx("path",{fill:r,d:"M12,24c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S10.8,24,12,24z"}),p.jsx("path",{fill:r,d:"M8.7,27.3c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S7.5,27.3,8.7,27.3z"}),p.jsx("path",{fill:r,d:"M5.5,30.5c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S4.2,30.5,5.5,30.5z"}),p.jsx("path",{fill:r,d:"M2.2,33.8c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2S0,30.4,0,31.6S1,33.8,2.2,33.8z"}),p.jsx("path",{fill:r,d:"M54.5,7.6c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S53.3,7.6,54.5,7.6z"}),p.jsx("path",{fill:r,d:"M51.3,4.4c1.2,0,2.2-1,2.2-2.2S52.5,0,51.3,0s-2.2,1-2.2,2.2S50.1,4.4,51.3,4.4z"}),p.jsx("path",{fill:r,d:"M44.7,4.4c1.2,0,2.2-1,2.2-2.2S45.9,0,44.7,0s-2.2,1-2.2,2.2S43.5,4.4,44.7,4.4z"}),p.jsx("path",{fill:r,d:"M38.2,4.4c1.2,0,2.2-1,2.2-2.2S39.4,0,38.2,0S36,1,36,2.2S37,4.4,38.2,4.4z"}),p.jsx("path",{fill:r,d:"M31.6,4.4c1.2,0,2.2-1,2.2-2.2S32.8,0,31.6,0s-2.2,1-2.2,2.2C29.4,3.4,30.4,4.4,31.6,4.4z"}),p.jsx("path",{fill:r,d:"M28.4,7.6c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S27.2,7.6,28.4,7.6z"})]}),p.jsxs("g",{children:[p.jsx("path",{fill:r,d:"M77.4,50.2c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C75.3,49.2,76.2,50.2,77.4,50.2z"}),p.jsx("path",{fill:r,d:"M74.2,53.4c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2S72,50,72,51.2C72,52.5,73,53.4,74.2,53.4z"}),p.jsx("path",{fill:r,d:"M70.9,56.7c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C68.7,55.7,69.7,56.7,70.9,56.7z"}),p.jsx("path",{fill:r,d:"M67.6,60c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S66.4,60,67.6,60z"}),p.jsx("path",{fill:r,d:"M64.3,63.3c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2c-1.2,0-2.2,1-2.2,2.2C62.2,62.3,63.1,63.3,64.3,63.3z"}),p.jsx("path",{fill:r,d:"M61.1,66.5c1.2,0,2.2-1,2.2-2.2c0-1.2-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C58.9,65.6,59.9,66.5,61.1,66.5z"}),p.jsx("path",{fill:r,d:"M57.8,69.8c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S56.6,69.8,57.8,69.8z"}),p.jsx("path",{fill:r,d:"M54.5,73.1c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S53.3,73.1,54.5,73.1z"}),p.jsx("path",{fill:r,d:"M51.3,76.3c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C49.1,75.4,50.1,76.3,51.3,76.3z"}),p.jsx("path",{fill:r,d:"M77.4,43.6c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C75.3,42.6,76.2,43.6,77.4,43.6z"}),p.jsx("path",{fill:r,d:"M74.2,46.9c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S73,46.9,74.2,46.9z"}),p.jsx("path",{fill:r,d:"M44.7,76.3c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C42.5,75.4,43.5,76.3,44.7,76.3z"}),p.jsx("path",{fill:r,d:"M41.4,79.6c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C39.3,78.6,40.2,79.6,41.4,79.6z"}),p.jsx("path",{fill:r,d:"M77.4,37.1c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C75.3,36.1,76.2,37.1,77.4,37.1z"}),p.jsx("path",{fill:r,d:"M74.2,40.4c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2S72,37,72,38.2S73,40.4,74.2,40.4z"}),p.jsx("path",{fill:r,d:"M38.2,76.3c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2C37,72,36,73,36,74.2C36,75.4,37,76.3,38.2,76.3z"}),p.jsx("path",{fill:r,d:"M34.9,79.6c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S33.7,79.6,34.9,79.6z"}),p.jsx("path",{fill:r,d:"M74.2,33.8c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S73,33.8,74.2,33.8z"}),p.jsx("path",{fill:r,d:"M31.6,76.3c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C29.4,75.4,30.4,76.3,31.6,76.3z"}),p.jsx("path",{fill:r,d:"M70.9,30.5c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S69.7,30.5,70.9,30.5z"}),p.jsx("path",{fill:r,d:"M28.4,73.1c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C26.2,72.1,27.2,73.1,28.4,73.1z"}),p.jsx("path",{fill:r,d:"M67.6,27.3c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S66.4,27.3,67.6,27.3z"}),p.jsx("path",{fill:r,d:"M25.1,69.8c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S23.9,69.8,25.1,69.8z"}),p.jsx("path",{fill:r,d:"M64.3,24c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2c-1.2,0-2.2,1-2.2,2.2C62.2,23,63.1,24,64.3,24z"}),p.jsx("path",{fill:r,d:"M21.8,66.5c1.2,0,2.2-1,2.2-2.2c0-1.2-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C19.6,65.6,20.6,66.5,21.8,66.5z"}),p.jsx("path",{fill:r,d:"M61.1,20.7c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C58.9,19.7,59.9,20.7,61.1,20.7z"}),p.jsx("path",{fill:r,d:"M18.5,63.3c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C16.4,62.3,17.3,63.3,18.5,63.3z"}),p.jsx("path",{fill:r,d:"M57.8,17.5c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S56.6,17.5,57.8,17.5z"}),p.jsx("path",{fill:r,d:"M15.3,60c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S14.1,60,15.3,60z"}),p.jsx("path",{fill:r,d:"M54.5,14.2c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S53.3,14.2,54.5,14.2z"}),p.jsx("path",{fill:r,d:"M12,56.7c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S10.8,56.7,12,56.7z"}),p.jsx("path",{fill:r,d:"M8.7,53.4c1.2,0,2.2-1,2.2-2.2S9.9,49,8.7,49s-2.2,1-2.2,2.2C6.5,52.5,7.5,53.4,8.7,53.4z"}),p.jsx("path",{fill:r,d:"M8.7,46.9c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S7.5,46.9,8.7,46.9z"}),p.jsx("path",{fill:r,d:"M5.5,50.2c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S4.2,50.2,5.5,50.2z"}),p.jsx("path",{fill:r,d:"M8.7,40.4c1.2,0,2.2-1,2.2-2.2S9.9,36,8.7,36s-2.2,1-2.2,2.2S7.5,40.4,8.7,40.4z"}),p.jsx("path",{fill:r,d:"M5.5,43.6c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S4.2,43.6,5.5,43.6z"}),p.jsx("path",{fill:r,d:"M28.4,14.2c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S27.2,14.2,28.4,14.2z"}),p.jsx("path",{fill:r,d:"M25.1,17.5c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S23.9,17.5,25.1,17.5z"}),p.jsx("path",{fill:r,d:"M21.8,20.7c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C19.6,19.7,20.6,20.7,21.8,20.7z"}),p.jsx("path",{fill:r,d:"M18.5,24c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C16.4,23,17.3,24,18.5,24z"}),p.jsx("path",{fill:r,d:"M15.3,27.3c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S14.1,27.3,15.3,27.3z"}),p.jsx("path",{fill:r,d:"M12,30.5c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S10.8,30.5,12,30.5z"}),p.jsx("path",{fill:r,d:"M8.7,33.8c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S7.5,33.8,8.7,33.8z"}),p.jsx("path",{fill:r,d:"M5.5,37.1c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S4.2,37.1,5.5,37.1z"}),p.jsx("path",{fill:r,d:"M51.3,10.9c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S50.1,10.9,51.3,10.9z"}),p.jsx("path",{fill:r,d:"M48,7.6c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S46.8,7.6,48,7.6z"}),p.jsx("path",{fill:r,d:"M44.7,10.9c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S43.5,10.9,44.7,10.9z"}),p.jsx("path",{fill:r,d:"M41.4,7.6c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S40.2,7.6,41.4,7.6z"}),p.jsx("path",{fill:r,d:"M38.2,10.9c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2S36,7.5,36,8.7S37,10.9,38.2,10.9z"}),p.jsx("path",{fill:r,d:"M34.9,7.6c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S33.7,7.6,34.9,7.6z"}),p.jsx("path",{fill:r,d:"M31.6,10.9c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C29.4,9.9,30.4,10.9,31.6,10.9z"})]}),p.jsxs("g",{style:a(.5),children:[p.jsx("path",{fill:r,d:"M57.8,50.2c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S56.6,50.2,57.8,50.2z"}),p.jsx("path",{fill:r,d:"M54.5,53.4c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C52.3,52.5,53.3,53.4,54.5,53.4z"}),p.jsx("path",{fill:r,d:"M51.3,56.7c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S50.1,56.7,51.3,56.7z"}),p.jsx("path",{fill:r,d:"M48,60c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S46.8,60,48,60z"}),p.jsx("path",{fill:r,d:"M57.8,37.1c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S56.6,37.1,57.8,37.1z"}),p.jsx("path",{fill:r,d:"M34.9,60c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S33.7,60,34.9,60z"}),p.jsx("path",{fill:r,d:"M54.5,33.8c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S53.3,33.8,54.5,33.8z"}),p.jsx("path",{fill:r,d:"M31.6,56.7c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C29.4,55.7,30.4,56.7,31.6,56.7z"}),p.jsx("path",{fill:r,d:"M51.3,30.5c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S50.1,30.5,51.3,30.5z"}),p.jsx("path",{fill:r,d:"M28.4,53.4c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C26.2,52.5,27.2,53.4,28.4,53.4z"}),p.jsx("path",{fill:r,d:"M48,27.3c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S46.8,27.3,48,27.3z"}),p.jsx("path",{fill:r,d:"M25.1,50.2c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S23.9,50.2,25.1,50.2z"}),p.jsx("path",{fill:r,d:"M34.9,27.3c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S33.7,27.3,34.9,27.3z"}),p.jsx("path",{fill:r,d:"M31.6,30.5c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S30.4,30.5,31.6,30.5z"}),p.jsx("path",{fill:r,d:"M28.4,33.8c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C26.2,32.8,27.2,33.8,28.4,33.8z"}),p.jsx("path",{fill:r,d:"M25.1,37.1c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S23.9,37.1,25.1,37.1z"})]}),p.jsxs("g",{style:a(.32),children:[p.jsx("path",{fill:r,d:"M57.8,43.6c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S56.6,43.6,57.8,43.6z"}),p.jsx("path",{fill:r,d:"M54.5,46.9c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S53.3,46.9,54.5,46.9z"}),p.jsx("path",{fill:r,d:"M51.3,50.2c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S50.1,50.2,51.3,50.2z"}),p.jsx("path",{fill:r,d:"M48,53.4c1.2,0,2.2-1,2.2-2.2S49.2,49,48,49s-2.2,1-2.2,2.2C45.8,52.5,46.8,53.4,48,53.4z"}),p.jsx("path",{fill:r,d:"M44.7,56.7c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S43.5,56.7,44.7,56.7z"}),p.jsx("path",{fill:r,d:"M41.4,60c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C39.3,59,40.2,60,41.4,60z"}),p.jsx("path",{fill:r,d:"M54.5,40.4c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S53.3,40.4,54.5,40.4z"}),p.jsx("path",{fill:r,d:"M38.2,56.7c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S37,56.7,38.2,56.7z"}),p.jsx("path",{fill:r,d:"M51.3,37.1c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S50.1,37.1,51.3,37.1z"}),p.jsx("path",{fill:r,d:"M34.9,53.4c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C32.7,52.5,33.7,53.4,34.9,53.4z"}),p.jsx("path",{fill:r,d:"M48,33.8c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S46.8,33.8,48,33.8z"}),p.jsx("path",{fill:r,d:"M31.6,50.2c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C29.4,49.2,30.4,50.2,31.6,50.2z"}),p.jsx("path",{fill:r,d:"M44.7,30.5c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S43.5,30.5,44.7,30.5z"}),p.jsx("path",{fill:r,d:"M28.4,46.9c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C26.2,45.9,27.2,46.9,28.4,46.9z"}),p.jsx("path",{fill:r,d:"M41.4,27.3c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C39.3,26.3,40.2,27.3,41.4,27.3z"}),p.jsx("path",{fill:r,d:"M38.2,30.5c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S37,30.5,38.2,30.5z"}),p.jsx("path",{fill:r,d:"M34.9,33.8c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S33.7,33.8,34.9,33.8z"}),p.jsx("path",{fill:r,d:"M31.6,37.1c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C29.4,36.1,30.4,37.1,31.6,37.1z"}),p.jsx("path",{fill:r,d:"M28.4,40.4c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C26.2,39.4,27.2,40.4,28.4,40.4z"}),p.jsx("path",{fill:r,d:"M25.1,43.6c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S23.9,43.6,25.1,43.6z"})]}),p.jsxs("g",{style:a(.16),children:[p.jsx("path",{fill:r,d:"M51.3,43.6c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S50.1,43.6,51.3,43.6z"}),p.jsx("path",{fill:r,d:"M48,46.9c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S46.8,46.9,48,46.9z"}),p.jsx("path",{fill:r,d:"M44.7,50.2c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S43.5,50.2,44.7,50.2z"}),p.jsx("path",{fill:r,d:"M41.4,53.4c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C39.3,52.5,40.2,53.4,41.4,53.4z"}),p.jsx("path",{fill:r,d:"M48,40.4c1.2,0,2.2-1,2.2-2.2S49.2,36,48,36s-2.2,1-2.2,2.2S46.8,40.4,48,40.4z"}),p.jsx("path",{fill:r,d:"M38.2,50.2c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2S36,46.8,36,48S37,50.2,38.2,50.2z"}),p.jsx("path",{fill:r,d:"M44.7,37.1c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S43.5,37.1,44.7,37.1z"}),p.jsx("path",{fill:r,d:"M34.9,46.9c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S33.7,46.9,34.9,46.9z"}),p.jsx("path",{fill:r,d:"M41.4,33.8c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C39.3,32.8,40.2,33.8,41.4,33.8z"}),p.jsx("path",{fill:r,d:"M38.2,37.1c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S37,37.1,38.2,37.1z"}),p.jsx("path",{fill:r,d:"M34.9,40.4c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S33.7,40.4,34.9,40.4z"}),p.jsx("path",{fill:r,d:"M31.6,43.6c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C29.4,42.6,30.4,43.6,31.6,43.6z"})]}),p.jsxs("g",{style:a(0),children:[p.jsx("path",{fill:r,d:"M44.7,43.6c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S43.5,43.6,44.7,43.6z"}),p.jsx("path",{fill:r,d:"M41.4,46.9c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C39.3,45.9,40.2,46.9,41.4,46.9z"}),p.jsx("path",{fill:r,d:"M41.4,40.4c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2C39.3,39.4,40.2,40.4,41.4,40.4z"}),p.jsx("path",{fill:r,d:"M38.2,43.6c1.2,0,2.2-1,2.2-2.2s-1-2.2-2.2-2.2s-2.2,1-2.2,2.2S37,43.6,38.2,43.6z"})]})]})})};var Fv=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},up,Of,Dm,obe,bVn=(obe=class extends Fv{constructor(){super();tr(this,up);tr(this,Of);tr(this,Dm);Ln(this,Dm,n=>{if(typeof window<"u"&&window.addEventListener){const r=()=>n();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){We(this,Of)||this.setEventListener(We(this,Dm))}onUnsubscribe(){var n;this.hasListeners()||((n=We(this,Of))==null||n.call(this),Ln(this,Of,void 0))}setEventListener(n){var r;Ln(this,Dm,n),(r=We(this,Of))==null||r.call(this),Ln(this,Of,n(a=>{typeof a=="boolean"?this.setFocused(a):this.onFocus()}))}setFocused(n){We(this,up)!==n&&(Ln(this,up,n),this.onFocus())}onFocus(){const n=this.isFocused();this.listeners.forEach(r=>{r(n)})}isFocused(){var n;return typeof We(this,up)=="boolean"?We(this,up):((n=globalThis.document)==null?void 0:n.visibilityState)!=="hidden"}},up=new WeakMap,Of=new WeakMap,Dm=new WeakMap,obe),Vie=new bVn,xVn={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},jf,QZ,ibe,wVn=(ibe=class{constructor(){tr(this,jf,xVn);tr(this,QZ,!1)}setTimeoutProvider(t){Ln(this,jf,t)}setTimeout(t,n){return We(this,jf).setTimeout(t,n)}clearTimeout(t){We(this,jf).clearTimeout(t)}setInterval(t,n){return We(this,jf).setInterval(t,n)}clearInterval(t){We(this,jf).clearInterval(t)}},jf=new WeakMap,QZ=new WeakMap,ibe),ip=new wVn;function SVn(e){setTimeout(e,0)}var CVn=typeof window>"u"||"Deno"in globalThis;function vl(){}function kVn(e,t){return typeof e=="function"?e(t):e}function fX(e){return typeof e=="number"&&e>=0&&e!==1/0}function jZe(e,t){return Math.max(e+(t||0)-Date.now(),0)}function v6(e,t){return typeof e=="function"?e(t):e}function H2(e,t){return typeof e=="function"?e(t):e}function zpe(e,t){const{type:n="all",exact:r,fetchStatus:a,predicate:o,queryKey:i,stale:s}=e;if(i){if(r){if(t.queryHash!==Hie(i,t.options))return!1}else if(!cS(t.queryKey,i))return!1}if(n!=="all"){const l=t.isActive();if(n==="active"&&!l||n==="inactive"&&l)return!1}return!(typeof s=="boolean"&&t.isStale()!==s||a&&a!==t.state.fetchStatus||o&&!o(t))}function Mpe(e,t){const{exact:n,status:r,predicate:a,mutationKey:o}=e;if(o){if(!t.options.mutationKey)return!1;if(n){if(n7(t.options.mutationKey)!==n7(o))return!1}else if(!cS(t.options.mutationKey,o))return!1}return!(r&&t.state.status!==r||a&&!a(t))}function Hie(e,t){return((t==null?void 0:t.queryKeyHashFn)||n7)(e)}function n7(e){return JSON.stringify(e,(t,n)=>pX(n)?Object.keys(n).sort().reduce((r,a)=>(r[a]=n[a],r),{}):n)}function cS(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>cS(e[n],t[n])):!1}var zVn=Object.prototype.hasOwnProperty;function FZe(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=Tpe(e)&&Tpe(t);if(!r&&!(pX(e)&&pX(t)))return t;const o=(r?e:Object.keys(e)).length,i=r?t:Object.keys(t),s=i.length,l=r?new Array(s):{};let c=0;for(let u=0;u<s;u++){const d=r?u:i[u],f=e[d],h=t[d];if(f===h){l[d]=f,(r?u<o:zVn.call(e,d))&&c++;continue}if(f===null||h===null||typeof f!="object"||typeof h!="object"){l[d]=h;continue}const g=FZe(f,h,n+1);l[d]=g,g===f&&c++}return o===s&&c===o?e:l}function mR(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function Tpe(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function pX(e){if(!Epe(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!Epe(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Epe(e){return Object.prototype.toString.call(e)==="[object Object]"}function MVn(e){return new Promise(t=>{ip.setTimeout(t,e)})}function hX(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?FZe(e,t):t}function TVn(e){return e}function EVn(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function _Vn(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var Wie=Symbol();function BZe(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===Wie?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Uie(e,t){return typeof e=="function"?e(...t):!!e}function LVn(e,t,n){let r=!1,a;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(a??(a=t()),r||(r=!0,a.aborted?n():a.addEventListener("abort",n,{once:!0})),a)}),e}var uS=(()=>{let e=()=>CVn;return{isServer(){return e()},setIsServer(t){e=t}}})();function gX(){let e,t;const n=new Promise((a,o)=>{e=a,t=o});n.status="pending",n.catch(()=>{});function r(a){Object.assign(n,a),delete n.resolve,delete n.reject}return n.resolve=a=>{r({status:"fulfilled",value:a}),e(a)},n.reject=a=>{r({status:"rejected",reason:a}),t(a)},n}var RVn=SVn;function PVn(){let e=[],t=0,n=s=>{s()},r=s=>{s()},a=RVn;const o=s=>{t?e.push(s):a(()=>{n(s)})},i=()=>{const s=e;e=[],s.length&&a(()=>{r(()=>{s.forEach(l=>{n(l)})})})};return{batch:s=>{let l;t++;try{l=s()}finally{t--,t||i()}return l},batchCalls:s=>(...l)=>{o(()=>{s(...l)})},schedule:o,setNotifyFunction:s=>{n=s},setBatchNotifyFunction:s=>{r=s},setScheduler:s=>{a=s}}}var gs=PVn(),Om,Ff,jm,sbe,AVn=(sbe=class extends Fv{constructor(){super();tr(this,Om,!0);tr(this,Ff);tr(this,jm);Ln(this,jm,n=>{if(typeof window<"u"&&window.addEventListener){const r=()=>n(!0),a=()=>n(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",a,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",a)}}})}onSubscribe(){We(this,Ff)||this.setEventListener(We(this,jm))}onUnsubscribe(){var n;this.hasListeners()||((n=We(this,Ff))==null||n.call(this),Ln(this,Ff,void 0))}setEventListener(n){var r;Ln(this,jm,n),(r=We(this,Ff))==null||r.call(this),Ln(this,Ff,n(this.setOnline.bind(this)))}setOnline(n){We(this,Om)!==n&&(Ln(this,Om,n),this.listeners.forEach(a=>{a(n)}))}isOnline(){return We(this,Om)}},Om=new WeakMap,Ff=new WeakMap,jm=new WeakMap,sbe),vR=new AVn;function NVn(e){return Math.min(1e3*2**e,3e4)}function VZe(e){return(e??"online")==="online"?vR.isOnline():!0}var mX=class extends Error{constructor(t){super("CancelledError"),this.revert=t==null?void 0:t.revert,this.silent=t==null?void 0:t.silent}};function HZe(e){let t=!1,n=0,r;const a=gX(),o=()=>a.status!=="pending",i=v=>{var b;if(!o()){const y=new mX(v);f(y),(b=e.onCancel)==null||b.call(e,y)}},s=()=>{t=!0},l=()=>{t=!1},c=()=>Vie.isFocused()&&(e.networkMode==="always"||vR.isOnline())&&e.canRun(),u=()=>VZe(e.networkMode)&&e.canRun(),d=v=>{o()||(r==null||r(),a.resolve(v))},f=v=>{o()||(r==null||r(),a.reject(v))},h=()=>new Promise(v=>{var b;r=y=>{(o()||c())&&v(y)},(b=e.onPause)==null||b.call(e)}).then(()=>{var v;r=void 0,o()||(v=e.onContinue)==null||v.call(e)}),g=()=>{if(o())return;let v;const b=n===0?e.initialPromise:void 0;try{v=b??e.fn()}catch(y){v=Promise.reject(y)}Promise.resolve(v).then(d).catch(y=>{var L;if(o())return;const x=e.retry??(uS.isServer()?0:3),S=e.retryDelay??NVn,z=typeof S=="function"?S(n,y):S,M=x===!0||typeof x=="number"&&n<x||typeof x=="function"&&x(n,y);if(t||!M){f(y);return}n++,(L=e.onFail)==null||L.call(e,n,y),MVn(z).then(()=>c()?void 0:h()).then(()=>{t?f(y):g()})})};return{promise:a,status:()=>a.status,cancel:i,continue:()=>(r==null||r(),a),cancelRetry:s,continueRetry:l,canStart:u,start:()=>(u()?g():h().then(g),a)}}var dp,lbe,WZe=(lbe=class{constructor(){tr(this,dp)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),fX(this.gcTime)&&Ln(this,dp,ip.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(uS.isServer()?1/0:300*1e3))}clearGcTimeout(){We(this,dp)&&(ip.clearTimeout(We(this,dp)),Ln(this,dp,void 0))}},dp=new WeakMap,lbe),fp,Fm,D2,pp,Ls,BS,hp,Gc,UZe,S3,cbe,$Vn=(cbe=class extends WZe{constructor(n){super();tr(this,Gc);tr(this,fp);tr(this,Fm);tr(this,D2);tr(this,pp);tr(this,Ls);tr(this,BS);tr(this,hp);Ln(this,hp,!1),Ln(this,BS,n.defaultOptions),this.setOptions(n.options),this.observers=[],Ln(this,pp,n.client),Ln(this,D2,We(this,pp).getQueryCache()),this.queryKey=n.queryKey,this.queryHash=n.queryHash,Ln(this,fp,Lpe(this.options)),this.state=n.state??We(this,fp),this.scheduleGc()}get meta(){return this.options.meta}get promise(){var n;return(n=We(this,Ls))==null?void 0:n.promise}setOptions(n){if(this.options={...We(this,BS),...n},this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const r=Lpe(this.options);r.data!==void 0&&(this.setState(_pe(r.data,r.dataUpdatedAt)),Ln(this,fp,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&We(this,D2).remove(this)}setData(n,r){const a=hX(this.state.data,n,this.options);return ra(this,Gc,S3).call(this,{data:a,type:"success",dataUpdatedAt:r==null?void 0:r.updatedAt,manual:r==null?void 0:r.manual}),a}setState(n,r){ra(this,Gc,S3).call(this,{type:"setState",state:n,setStateOptions:r})}cancel(n){var a,o;const r=(a=We(this,Ls))==null?void 0:a.promise;return(o=We(this,Ls))==null||o.cancel(n),r?r.then(vl).catch(vl):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return We(this,fp)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(n=>H2(n.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Wie||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(n=>v6(n.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(n=>n.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(n=0){return this.state.data===void 0?!0:n==="static"?!1:this.state.isInvalidated?!0:!jZe(this.state.dataUpdatedAt,n)}onFocus(){var r;const n=this.observers.find(a=>a.shouldFetchOnWindowFocus());n==null||n.refetch({cancelRefetch:!1}),(r=We(this,Ls))==null||r.continue()}onOnline(){var r;const n=this.observers.find(a=>a.shouldFetchOnReconnect());n==null||n.refetch({cancelRefetch:!1}),(r=We(this,Ls))==null||r.continue()}addObserver(n){this.observers.includes(n)||(this.observers.push(n),this.clearGcTimeout(),We(this,D2).notify({type:"observerAdded",query:this,observer:n}))}removeObserver(n){this.observers.includes(n)&&(this.observers=this.observers.filter(r=>r!==n),this.observers.length||(We(this,Ls)&&(We(this,hp)||ra(this,Gc,UZe).call(this)?We(this,Ls).cancel({revert:!0}):We(this,Ls).cancelRetry()),this.scheduleGc()),We(this,D2).notify({type:"observerRemoved",query:this,observer:n}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||ra(this,Gc,S3).call(this,{type:"invalidate"})}async fetch(n,r){var c,u,d,f,h,g,v,b,y,x,S,z;if(this.state.fetchStatus!=="idle"&&((c=We(this,Ls))==null?void 0:c.status())!=="rejected"){if(this.state.data!==void 0&&(r!=null&&r.cancelRefetch))this.cancel({silent:!0});else if(We(this,Ls))return We(this,Ls).continueRetry(),We(this,Ls).promise}if(n&&this.setOptions(n),!this.options.queryFn){const M=this.observers.find(L=>L.options.queryFn);M&&this.setOptions(M.options)}const a=new AbortController,o=M=>{Object.defineProperty(M,"signal",{enumerable:!0,get:()=>(Ln(this,hp,!0),a.signal)})},i=()=>{const M=BZe(this.options,r),R=(()=>{const N={client:We(this,pp),queryKey:this.queryKey,meta:this.meta};return o(N),N})();return Ln(this,hp,!1),this.options.persister?this.options.persister(M,R,this):M(R)},l=(()=>{const M={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:We(this,pp),state:this.state,fetchFn:i};return o(M),M})();(u=this.options.behavior)==null||u.onFetch(l,this),Ln(this,Fm,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((d=l.fetchOptions)==null?void 0:d.meta))&&ra(this,Gc,S3).call(this,{type:"fetch",meta:(f=l.fetchOptions)==null?void 0:f.meta}),Ln(this,Ls,HZe({initialPromise:r==null?void 0:r.initialPromise,fn:l.fetchFn,onCancel:M=>{M instanceof mX&&M.revert&&this.setState({...We(this,Fm),fetchStatus:"idle"}),a.abort()},onFail:(M,L)=>{ra(this,Gc,S3).call(this,{type:"failed",failureCount:M,error:L})},onPause:()=>{ra(this,Gc,S3).call(this,{type:"pause"})},onContinue:()=>{ra(this,Gc,S3).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0}));try{const M=await We(this,Ls).start();if(M===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(M),(g=(h=We(this,D2).config).onSuccess)==null||g.call(h,M,this),(b=(v=We(this,D2).config).onSettled)==null||b.call(v,M,this.state.error,this),M}catch(M){if(M instanceof mX){if(M.silent)return We(this,Ls).promise;if(M.revert){if(this.state.data===void 0)throw M;return this.state.data}}throw ra(this,Gc,S3).call(this,{type:"error",error:M}),(x=(y=We(this,D2).config).onError)==null||x.call(y,M,this),(z=(S=We(this,D2).config).onSettled)==null||z.call(S,this.state.data,M,this),M}finally{this.scheduleGc()}}},fp=new WeakMap,Fm=new WeakMap,D2=new WeakMap,pp=new WeakMap,Ls=new WeakMap,BS=new WeakMap,hp=new WeakMap,Gc=new WeakSet,UZe=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},S3=function(n){const r=a=>{switch(n.type){case"failed":return{...a,fetchFailureCount:n.failureCount,fetchFailureReason:n.error};case"pause":return{...a,fetchStatus:"paused"};case"continue":return{...a,fetchStatus:"fetching"};case"fetch":return{...a,...qZe(a.data,this.options),fetchMeta:n.meta??null};case"success":const o={...a,..._pe(n.data,n.dataUpdatedAt),dataUpdateCount:a.dataUpdateCount+1,...!n.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return Ln(this,Fm,n.manual?o:void 0),o;case"error":const i=n.error;return{...a,error:i,errorUpdateCount:a.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:a.fetchFailureCount+1,fetchFailureReason:i,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...a,isInvalidated:!0};case"setState":return{...a,...n.state}}};this.state=r(this.state),gs.batch(()=>{this.observers.forEach(a=>{a.onQueryUpdate()}),We(this,D2).notify({query:this,type:"updated",action:n})})},cbe);function qZe(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:VZe(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function _pe(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Lpe(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var Jl,Ea,VS,gl,gp,Bm,L3,Bf,HS,Vm,Hm,mp,vp,Vf,Wm,ho,mx,vX,yX,bX,xX,wX,SX,CX,GZe,ube,IVn=(ube=class extends Fv{constructor(t,n){super();tr(this,ho);tr(this,Jl);tr(this,Ea);tr(this,VS);tr(this,gl);tr(this,gp);tr(this,Bm);tr(this,L3);tr(this,Bf);tr(this,HS);tr(this,Vm);tr(this,Hm);tr(this,mp);tr(this,vp);tr(this,Vf);tr(this,Wm,new Set);this.options=n,Ln(this,Jl,t),Ln(this,Bf,null),Ln(this,L3,gX()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(We(this,Ea).addObserver(this),Rpe(We(this,Ea),this.options)?ra(this,ho,mx).call(this):this.updateResult(),ra(this,ho,xX).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return kX(We(this,Ea),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return kX(We(this,Ea),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,ra(this,ho,wX).call(this),ra(this,ho,SX).call(this),We(this,Ea).removeObserver(this)}setOptions(t){const n=this.options,r=We(this,Ea);if(this.options=We(this,Jl).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof H2(this.options.enabled,We(this,Ea))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");ra(this,ho,CX).call(this),We(this,Ea).setOptions(this.options),n._defaulted&&!mR(this.options,n)&&We(this,Jl).getQueryCache().notify({type:"observerOptionsUpdated",query:We(this,Ea),observer:this});const a=this.hasListeners();a&&Ppe(We(this,Ea),r,this.options,n)&&ra(this,ho,mx).call(this),this.updateResult(),a&&(We(this,Ea)!==r||H2(this.options.enabled,We(this,Ea))!==H2(n.enabled,We(this,Ea))||v6(this.options.staleTime,We(this,Ea))!==v6(n.staleTime,We(this,Ea)))&&ra(this,ho,vX).call(this);const o=ra(this,ho,yX).call(this);a&&(We(this,Ea)!==r||H2(this.options.enabled,We(this,Ea))!==H2(n.enabled,We(this,Ea))||o!==We(this,Vf))&&ra(this,ho,bX).call(this,o)}getOptimisticResult(t){const n=We(this,Jl).getQueryCache().build(We(this,Jl),t),r=this.createResult(n,t);return OVn(this,r)&&(Ln(this,gl,r),Ln(this,Bm,this.options),Ln(this,gp,We(this,Ea).state)),r}getCurrentResult(){return We(this,gl)}trackResult(t,n){return new Proxy(t,{get:(r,a)=>(this.trackProp(a),n==null||n(a),a==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&We(this,L3).status==="pending"&&We(this,L3).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,a))})}trackProp(t){We(this,Wm).add(t)}getCurrentQuery(){return We(this,Ea)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=We(this,Jl).defaultQueryOptions(t),r=We(this,Jl).getQueryCache().build(We(this,Jl),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return ra(this,ho,mx).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),We(this,gl)))}createResult(t,n){var O;const r=We(this,Ea),a=this.options,o=We(this,gl),i=We(this,gp),s=We(this,Bm),c=t!==r?t.state:We(this,VS),{state:u}=t;let d={...u},f=!1,h;if(n._optimisticResults){const j=this.hasListeners(),B=!j&&Rpe(t,n),H=j&&Ppe(t,r,n,a);(B||H)&&(d={...d,...qZe(u.data,t.options)}),n._optimisticResults==="isRestoring"&&(d.fetchStatus="idle")}let{error:g,errorUpdatedAt:v,status:b}=d;h=d.data;let y=!1;if(n.placeholderData!==void 0&&h===void 0&&b==="pending"){let j;o!=null&&o.isPlaceholderData&&n.placeholderData===(s==null?void 0:s.placeholderData)?(j=o.data,y=!0):j=typeof n.placeholderData=="function"?n.placeholderData((O=We(this,Hm))==null?void 0:O.state.data,We(this,Hm)):n.placeholderData,j!==void 0&&(b="success",h=hX(o==null?void 0:o.data,j,n),f=!0)}if(n.select&&h!==void 0&&!y)if(o&&h===(i==null?void 0:i.data)&&n.select===We(this,HS))h=We(this,Vm);else try{Ln(this,HS,n.select),h=n.select(h),h=hX(o==null?void 0:o.data,h,n),Ln(this,Vm,h),Ln(this,Bf,null)}catch(j){Ln(this,Bf,j)}We(this,Bf)&&(g=We(this,Bf),h=We(this,Vm),v=Date.now(),b="error");const x=d.fetchStatus==="fetching",S=b==="pending",z=b==="error",M=S&&x,L=h!==void 0,N={status:b,fetchStatus:d.fetchStatus,isPending:S,isSuccess:b==="success",isError:z,isInitialLoading:M,isLoading:M,data:h,dataUpdatedAt:d.dataUpdatedAt,error:g,errorUpdatedAt:v,failureCount:d.fetchFailureCount,failureReason:d.fetchFailureReason,errorUpdateCount:d.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:d.dataUpdateCount>c.dataUpdateCount||d.errorUpdateCount>c.errorUpdateCount,isFetching:x,isRefetching:x&&!S,isLoadingError:z&&!L,isPaused:d.fetchStatus==="paused",isPlaceholderData:f,isRefetchError:z&&L,isStale:qie(t,n),refetch:this.refetch,promise:We(this,L3),isEnabled:H2(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const j=N.data!==void 0,B=N.status==="error"&&!j,H=Z=>{B?Z.reject(N.error):j&&Z.resolve(N.data)},K=()=>{const Z=Ln(this,L3,N.promise=gX());H(Z)},U=We(this,L3);switch(U.status){case"pending":t.queryHash===r.queryHash&&H(U);break;case"fulfilled":(B||N.data!==U.value)&&K();break;case"rejected":(!B||N.error!==U.reason)&&K();break}}return N}updateResult(){const t=We(this,gl),n=this.createResult(We(this,Ea),this.options);if(Ln(this,gp,We(this,Ea).state),Ln(this,Bm,this.options),We(this,gp).data!==void 0&&Ln(this,Hm,We(this,Ea)),mR(n,t))return;Ln(this,gl,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:a}=this.options,o=typeof a=="function"?a():a;if(o==="all"||!o&&!We(this,Wm).size)return!0;const i=new Set(o??We(this,Wm));return this.options.throwOnError&&i.add("error"),Object.keys(We(this,gl)).some(s=>{const l=s;return We(this,gl)[l]!==t[l]&&i.has(l)})};ra(this,ho,GZe).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&ra(this,ho,xX).call(this)}},Jl=new WeakMap,Ea=new WeakMap,VS=new WeakMap,gl=new WeakMap,gp=new WeakMap,Bm=new WeakMap,L3=new WeakMap,Bf=new WeakMap,HS=new WeakMap,Vm=new WeakMap,Hm=new WeakMap,mp=new WeakMap,vp=new WeakMap,Vf=new WeakMap,Wm=new WeakMap,ho=new WeakSet,mx=function(t){ra(this,ho,CX).call(this);let n=We(this,Ea).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(vl)),n},vX=function(){ra(this,ho,wX).call(this);const t=v6(this.options.staleTime,We(this,Ea));if(uS.isServer()||We(this,gl).isStale||!fX(t))return;const r=jZe(We(this,gl).dataUpdatedAt,t)+1;Ln(this,mp,ip.setTimeout(()=>{We(this,gl).isStale||this.updateResult()},r))},yX=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(We(this,Ea)):this.options.refetchInterval)??!1},bX=function(t){ra(this,ho,SX).call(this),Ln(this,Vf,t),!(uS.isServer()||H2(this.options.enabled,We(this,Ea))===!1||!fX(We(this,Vf))||We(this,Vf)===0)&&Ln(this,vp,ip.setInterval(()=>{(this.options.refetchIntervalInBackground||Vie.isFocused())&&ra(this,ho,mx).call(this)},We(this,Vf)))},xX=function(){ra(this,ho,vX).call(this),ra(this,ho,bX).call(this,ra(this,ho,yX).call(this))},wX=function(){We(this,mp)&&(ip.clearTimeout(We(this,mp)),Ln(this,mp,void 0))},SX=function(){We(this,vp)&&(ip.clearInterval(We(this,vp)),Ln(this,vp,void 0))},CX=function(){const t=We(this,Jl).getQueryCache().build(We(this,Jl),this.options);if(t===We(this,Ea))return;const n=We(this,Ea);Ln(this,Ea,t),Ln(this,VS,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},GZe=function(t){gs.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(We(this,gl))}),We(this,Jl).getQueryCache().notify({query:We(this,Ea),type:"observerResultsUpdated"})})},ube);function DVn(e,t){return H2(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&t.retryOnMount===!1)}function Rpe(e,t){return DVn(e,t)||e.state.data!==void 0&&kX(e,t,t.refetchOnMount)}function kX(e,t,n){if(H2(t.enabled,e)!==!1&&v6(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&qie(e,t)}return!1}function Ppe(e,t,n,r){return(e!==t||H2(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&qie(e,n)}function qie(e,t){return H2(t.enabled,e)!==!1&&e.isStaleByTime(v6(t.staleTime,e))}function OVn(e,t){return!mR(e.getCurrentResult(),t)}function Ape(e){return{onFetch:(t,n)=>{var u,d,f,h,g;const r=t.options,a=(f=(d=(u=t.fetchOptions)==null?void 0:u.meta)==null?void 0:d.fetchMore)==null?void 0:f.direction,o=((h=t.state.data)==null?void 0:h.pages)||[],i=((g=t.state.data)==null?void 0:g.pageParams)||[];let s={pages:[],pageParams:[]},l=0;const c=async()=>{let v=!1;const b=S=>{LVn(S,()=>t.signal,()=>v=!0)},y=BZe(t.options,t.fetchOptions),x=async(S,z,M)=>{if(v)return Promise.reject();if(z==null&&S.pages.length)return Promise.resolve(S);const R=(()=>{const B={client:t.client,queryKey:t.queryKey,pageParam:z,direction:M?"backward":"forward",meta:t.options.meta};return b(B),B})(),N=await y(R),{maxPages:O}=t.options,j=M?_Vn:EVn;return{pages:j(S.pages,N,O),pageParams:j(S.pageParams,z,O)}};if(a&&o.length){const S=a==="backward",z=S?jVn:Npe,M={pages:o,pageParams:i},L=z(r,M);s=await x(M,L,S)}else{const S=e??o.length;do{const z=l===0?i[0]??r.initialPageParam:Npe(r,s);if(l>0&&z==null)break;s=await x(s,z),l++}while(l<S)}return s};t.options.persister?t.fetchFn=()=>{var v,b;return(b=(v=t.options).persister)==null?void 0:b.call(v,c,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=c}}}function Npe(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function jVn(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var WS,$u,D1,yp,Iu,wf,dbe,FVn=(dbe=class extends WZe{constructor(n){super();tr(this,Iu);tr(this,WS);tr(this,$u);tr(this,D1);tr(this,yp);Ln(this,WS,n.client),this.mutationId=n.mutationId,Ln(this,D1,n.mutationCache),Ln(this,$u,[]),this.state=n.state||KZe(),this.setOptions(n.options),this.scheduleGc()}setOptions(n){this.options=n,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(n){We(this,$u).includes(n)||(We(this,$u).push(n),this.clearGcTimeout(),We(this,D1).notify({type:"observerAdded",mutation:this,observer:n}))}removeObserver(n){Ln(this,$u,We(this,$u).filter(r=>r!==n)),this.scheduleGc(),We(this,D1).notify({type:"observerRemoved",mutation:this,observer:n})}optionalRemove(){We(this,$u).length||(this.state.status==="pending"?this.scheduleGc():We(this,D1).remove(this))}continue(){var n;return((n=We(this,yp))==null?void 0:n.continue())??this.execute(this.state.variables)}async execute(n){var s,l,c,u,d,f,h,g,v,b,y,x,S,z,M,L,R,N;const r=()=>{ra(this,Iu,wf).call(this,{type:"continue"})},a={client:We(this,WS),meta:this.options.meta,mutationKey:this.options.mutationKey};Ln(this,yp,HZe({fn:()=>this.options.mutationFn?this.options.mutationFn(n,a):Promise.reject(new Error("No mutationFn found")),onFail:(O,j)=>{ra(this,Iu,wf).call(this,{type:"failed",failureCount:O,error:j})},onPause:()=>{ra(this,Iu,wf).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>We(this,D1).canRun(this)}));const o=this.state.status==="pending",i=!We(this,yp).canStart();try{if(o)r();else{ra(this,Iu,wf).call(this,{type:"pending",variables:n,isPaused:i}),We(this,D1).config.onMutate&&await We(this,D1).config.onMutate(n,this,a);const j=await((l=(s=this.options).onMutate)==null?void 0:l.call(s,n,a));j!==this.state.context&&ra(this,Iu,wf).call(this,{type:"pending",context:j,variables:n,isPaused:i})}const O=await We(this,yp).start();return await((u=(c=We(this,D1).config).onSuccess)==null?void 0:u.call(c,O,n,this.state.context,this,a)),await((f=(d=this.options).onSuccess)==null?void 0:f.call(d,O,n,this.state.context,a)),await((g=(h=We(this,D1).config).onSettled)==null?void 0:g.call(h,O,null,this.state.variables,this.state.context,this,a)),await((b=(v=this.options).onSettled)==null?void 0:b.call(v,O,null,n,this.state.context,a)),ra(this,Iu,wf).call(this,{type:"success",data:O}),O}catch(O){try{await((x=(y=We(this,D1).config).onError)==null?void 0:x.call(y,O,n,this.state.context,this,a))}catch(j){Promise.reject(j)}try{await((z=(S=this.options).onError)==null?void 0:z.call(S,O,n,this.state.context,a))}catch(j){Promise.reject(j)}try{await((L=(M=We(this,D1).config).onSettled)==null?void 0:L.call(M,void 0,O,this.state.variables,this.state.context,this,a))}catch(j){Promise.reject(j)}try{await((N=(R=this.options).onSettled)==null?void 0:N.call(R,void 0,O,n,this.state.context,a))}catch(j){Promise.reject(j)}throw ra(this,Iu,wf).call(this,{type:"error",error:O}),O}finally{We(this,D1).runNext(this)}}},WS=new WeakMap,$u=new WeakMap,D1=new WeakMap,yp=new WeakMap,Iu=new WeakSet,wf=function(n){const r=a=>{switch(n.type){case"failed":return{...a,failureCount:n.failureCount,failureReason:n.error};case"pause":return{...a,isPaused:!0};case"continue":return{...a,isPaused:!1};case"pending":return{...a,context:n.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:n.isPaused,status:"pending",variables:n.variables,submittedAt:Date.now()};case"success":return{...a,data:n.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...a,data:void 0,error:n.error,failureCount:a.failureCount+1,failureReason:n.error,isPaused:!1,status:"error"}}};this.state=r(this.state),gs.batch(()=>{We(this,$u).forEach(a=>{a.onMutationUpdate(n)}),We(this,D1).notify({mutation:this,type:"updated",action:n})})},dbe);function KZe(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var R3,k0,US,fbe,BVn=(fbe=class extends Fv{constructor(n={}){super();tr(this,R3);tr(this,k0);tr(this,US);this.config=n,Ln(this,R3,new Set),Ln(this,k0,new Map),Ln(this,US,0)}build(n,r,a){const o=new FVn({client:n,mutationCache:this,mutationId:++eM(this,US)._,options:n.defaultMutationOptions(r),state:a});return this.add(o),o}add(n){We(this,R3).add(n);const r=yT(n);if(typeof r=="string"){const a=We(this,k0).get(r);a?a.push(n):We(this,k0).set(r,[n])}this.notify({type:"added",mutation:n})}remove(n){if(We(this,R3).delete(n)){const r=yT(n);if(typeof r=="string"){const a=We(this,k0).get(r);if(a)if(a.length>1){const o=a.indexOf(n);o!==-1&&a.splice(o,1)}else a[0]===n&&We(this,k0).delete(r)}}this.notify({type:"removed",mutation:n})}canRun(n){const r=yT(n);if(typeof r=="string"){const a=We(this,k0).get(r),o=a==null?void 0:a.find(i=>i.state.status==="pending");return!o||o===n}else return!0}runNext(n){var a;const r=yT(n);if(typeof r=="string"){const o=(a=We(this,k0).get(r))==null?void 0:a.find(i=>i!==n&&i.state.isPaused);return(o==null?void 0:o.continue())??Promise.resolve()}else return Promise.resolve()}clear(){gs.batch(()=>{We(this,R3).forEach(n=>{this.notify({type:"removed",mutation:n})}),We(this,R3).clear(),We(this,k0).clear()})}getAll(){return Array.from(We(this,R3))}find(n){const r={exact:!0,...n};return this.getAll().find(a=>Mpe(r,a))}findAll(n={}){return this.getAll().filter(r=>Mpe(n,r))}notify(n){gs.batch(()=>{this.listeners.forEach(r=>{r(n)})})}resumePausedMutations(){const n=this.getAll().filter(r=>r.state.isPaused);return gs.batch(()=>Promise.all(n.map(r=>r.continue().catch(vl))))}},R3=new WeakMap,k0=new WeakMap,US=new WeakMap,fbe);function yT(e){var t;return(t=e.options.scope)==null?void 0:t.id}var P3,Hf,ec,A3,J3,QE,zX,pbe,VVn=(pbe=class extends Fv{constructor(n,r){super();tr(this,J3);tr(this,P3);tr(this,Hf);tr(this,ec);tr(this,A3);Ln(this,P3,n),this.setOptions(r),this.bindMethods(),ra(this,J3,QE).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var a;const r=this.options;this.options=We(this,P3).defaultMutationOptions(n),mR(this.options,r)||We(this,P3).getMutationCache().notify({type:"observerOptionsUpdated",mutation:We(this,ec),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&n7(r.mutationKey)!==n7(this.options.mutationKey)?this.reset():((a=We(this,ec))==null?void 0:a.state.status)==="pending"&&We(this,ec).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=We(this,ec))==null||n.removeObserver(this)}onMutationUpdate(n){ra(this,J3,QE).call(this),ra(this,J3,zX).call(this,n)}getCurrentResult(){return We(this,Hf)}reset(){var n;(n=We(this,ec))==null||n.removeObserver(this),Ln(this,ec,void 0),ra(this,J3,QE).call(this),ra(this,J3,zX).call(this)}mutate(n,r){var a;return Ln(this,A3,r),(a=We(this,ec))==null||a.removeObserver(this),Ln(this,ec,We(this,P3).getMutationCache().build(We(this,P3),this.options)),We(this,ec).addObserver(this),We(this,ec).execute(n)}},P3=new WeakMap,Hf=new WeakMap,ec=new WeakMap,A3=new WeakMap,J3=new WeakSet,QE=function(){var r;const n=((r=We(this,ec))==null?void 0:r.state)??KZe();Ln(this,Hf,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},zX=function(n){gs.batch(()=>{var r,a,o,i,s,l,c,u;if(We(this,A3)&&this.hasListeners()){const d=We(this,Hf).variables,f=We(this,Hf).context,h={client:We(this,P3),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(a=(r=We(this,A3)).onSuccess)==null||a.call(r,n.data,d,f,h)}catch(g){Promise.reject(g)}try{(i=(o=We(this,A3)).onSettled)==null||i.call(o,n.data,null,d,f,h)}catch(g){Promise.reject(g)}}else if((n==null?void 0:n.type)==="error"){try{(l=(s=We(this,A3)).onError)==null||l.call(s,n.error,d,f,h)}catch(g){Promise.reject(g)}try{(u=(c=We(this,A3)).onSettled)==null||u.call(c,void 0,n.error,d,f,h)}catch(g){Promise.reject(g)}}}this.listeners.forEach(d=>{d(We(this,Hf))})})},pbe),Du,hbe,HVn=(hbe=class extends Fv{constructor(n={}){super();tr(this,Du);this.config=n,Ln(this,Du,new Map)}build(n,r,a){const o=r.queryKey,i=r.queryHash??Hie(o,r);let s=this.get(i);return s||(s=new $Vn({client:n,queryKey:o,queryHash:i,options:n.defaultQueryOptions(r),state:a,defaultOptions:n.getQueryDefaults(o)}),this.add(s)),s}add(n){We(this,Du).has(n.queryHash)||(We(this,Du).set(n.queryHash,n),this.notify({type:"added",query:n}))}remove(n){const r=We(this,Du).get(n.queryHash);r&&(n.destroy(),r===n&&We(this,Du).delete(n.queryHash),this.notify({type:"removed",query:n}))}clear(){gs.batch(()=>{this.getAll().forEach(n=>{this.remove(n)})})}get(n){return We(this,Du).get(n)}getAll(){return[...We(this,Du).values()]}find(n){const r={exact:!0,...n};return this.getAll().find(a=>zpe(r,a))}findAll(n={}){const r=this.getAll();return Object.keys(n).length>0?r.filter(a=>zpe(n,a)):r}notify(n){gs.batch(()=>{this.listeners.forEach(r=>{r(n)})})}onFocus(){gs.batch(()=>{this.getAll().forEach(n=>{n.onFocus()})})}onOnline(){gs.batch(()=>{this.getAll().forEach(n=>{n.onOnline()})})}},Du=new WeakMap,hbe),Mi,Wf,Uf,Um,qm,qf,Gm,Km,gbe,WVn=(gbe=class{constructor(t={}){tr(this,Mi);tr(this,Wf);tr(this,Uf);tr(this,Um);tr(this,qm);tr(this,qf);tr(this,Gm);tr(this,Km);Ln(this,Mi,t.queryCache||new HVn),Ln(this,Wf,t.mutationCache||new BVn),Ln(this,Uf,t.defaultOptions||{}),Ln(this,Um,new Map),Ln(this,qm,new Map),Ln(this,qf,0)}mount(){eM(this,qf)._++,We(this,qf)===1&&(Ln(this,Gm,Vie.subscribe(async t=>{t&&(await this.resumePausedMutations(),We(this,Mi).onFocus())})),Ln(this,Km,vR.subscribe(async t=>{t&&(await this.resumePausedMutations(),We(this,Mi).onOnline())})))}unmount(){var t,n;eM(this,qf)._--,We(this,qf)===0&&((t=We(this,Gm))==null||t.call(this),Ln(this,Gm,void 0),(n=We(this,Km))==null||n.call(this),Ln(this,Km,void 0))}isFetching(t){return We(this,Mi).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return We(this,Wf).findAll({...t,status:"pending"}).length}getQueryData(t){var r;const n=this.defaultQueryOptions({queryKey:t});return(r=We(this,Mi).get(n.queryHash))==null?void 0:r.state.data}ensureQueryData(t){const n=this.defaultQueryOptions(t),r=We(this,Mi).build(this,n),a=r.state.data;return a===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(v6(n.staleTime,r))&&this.prefetchQuery(n),Promise.resolve(a))}getQueriesData(t){return We(this,Mi).findAll(t).map(({queryKey:n,state:r})=>{const a=r.data;return[n,a]})}setQueryData(t,n,r){const a=this.defaultQueryOptions({queryKey:t}),o=We(this,Mi).get(a.queryHash),i=o==null?void 0:o.state.data,s=kVn(n,i);if(s!==void 0)return We(this,Mi).build(this,a).setData(s,{...r,manual:!0})}setQueriesData(t,n,r){return gs.batch(()=>We(this,Mi).findAll(t).map(({queryKey:a})=>[a,this.setQueryData(a,n,r)]))}getQueryState(t){var r;const n=this.defaultQueryOptions({queryKey:t});return(r=We(this,Mi).get(n.queryHash))==null?void 0:r.state}removeQueries(t){const n=We(this,Mi);gs.batch(()=>{n.findAll(t).forEach(r=>{n.remove(r)})})}resetQueries(t,n){const r=We(this,Mi);return gs.batch(()=>(r.findAll(t).forEach(a=>{a.reset()}),this.refetchQueries({type:"active",...t},n)))}cancelQueries(t,n={}){const r={revert:!0,...n},a=gs.batch(()=>We(this,Mi).findAll(t).map(o=>o.cancel(r)));return Promise.all(a).then(vl).catch(vl)}invalidateQueries(t,n={}){return gs.batch(()=>(We(this,Mi).findAll(t).forEach(r=>{r.invalidate()}),(t==null?void 0:t.refetchType)==="none"?Promise.resolve():this.refetchQueries({...t,type:(t==null?void 0:t.refetchType)??(t==null?void 0:t.type)??"active"},n)))}refetchQueries(t,n={}){const r={...n,cancelRefetch:n.cancelRefetch??!0},a=gs.batch(()=>We(this,Mi).findAll(t).filter(o=>!o.isDisabled()&&!o.isStatic()).map(o=>{let i=o.fetch(void 0,r);return r.throwOnError||(i=i.catch(vl)),o.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(a).then(vl)}fetchQuery(t){const n=this.defaultQueryOptions(t);n.retry===void 0&&(n.retry=!1);const r=We(this,Mi).build(this,n);return r.isStaleByTime(v6(n.staleTime,r))?r.fetch(n):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(vl).catch(vl)}fetchInfiniteQuery(t){return t.behavior=Ape(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(vl).catch(vl)}ensureInfiniteQueryData(t){return t.behavior=Ape(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return vR.isOnline()?We(this,Wf).resumePausedMutations():Promise.resolve()}getQueryCache(){return We(this,Mi)}getMutationCache(){return We(this,Wf)}getDefaultOptions(){return We(this,Uf)}setDefaultOptions(t){Ln(this,Uf,t)}setQueryDefaults(t,n){We(this,Um).set(n7(t),{queryKey:t,defaultOptions:n})}getQueryDefaults(t){const n=[...We(this,Um).values()],r={};return n.forEach(a=>{cS(t,a.queryKey)&&Object.assign(r,a.defaultOptions)}),r}setMutationDefaults(t,n){We(this,qm).set(n7(t),{mutationKey:t,defaultOptions:n})}getMutationDefaults(t){const n=[...We(this,qm).values()],r={};return n.forEach(a=>{cS(t,a.mutationKey)&&Object.assign(r,a.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;const n={...We(this,Uf).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return n.queryHash||(n.queryHash=Hie(n.queryKey,n)),n.refetchOnReconnect===void 0&&(n.refetchOnReconnect=n.networkMode!=="always"),n.throwOnError===void 0&&(n.throwOnError=!!n.suspense),!n.networkMode&&n.persister&&(n.networkMode="offlineFirst"),n.queryFn===Wie&&(n.enabled=!1),n}defaultMutationOptions(t){return t!=null&&t._defaulted?t:{...We(this,Uf).mutations,...(t==null?void 0:t.mutationKey)&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){We(this,Mi).clear(),We(this,Wf).clear()}},Mi=new WeakMap,Wf=new WeakMap,Uf=new WeakMap,Um=new WeakMap,qm=new WeakMap,qf=new WeakMap,Gm=new WeakMap,Km=new WeakMap,gbe),YZe=C.createContext(void 0),_I=e=>{const t=C.useContext(YZe);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},UVn=({client:e,children:t})=>(C.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),p.jsx(YZe.Provider,{value:e,children:t})),XZe=C.createContext(!1),qVn=()=>C.useContext(XZe);XZe.Provider;function GVn(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var KVn=C.createContext(GVn()),YVn=()=>C.useContext(KVn),XVn=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?Uie(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},ZVn=e=>{C.useEffect(()=>{e.clearReset()},[e])},QVn=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:a})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(a&&e.data===void 0||Uie(n,[e.error,r])),JVn=e=>{if(e.suspense){const n=a=>a==="static"?a:Math.max(a??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...a)=>n(r(...a)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},eHn=(e,t)=>e.isLoading&&e.isFetching&&!t,tHn=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,$pe=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function nHn(e,t,n){var f,h,g,v;const r=qVn(),a=YVn(),o=_I(),i=o.defaultQueryOptions(e);(h=(f=o.getDefaultOptions().queries)==null?void 0:f._experimental_beforeQuery)==null||h.call(f,i);const s=o.getQueryCache().get(i.queryHash);i._optimisticResults=r?"isRestoring":"optimistic",JVn(i),XVn(i,a,s),ZVn(a);const l=!o.getQueryCache().get(i.queryHash),[c]=C.useState(()=>new t(o,i)),u=c.getOptimisticResult(i),d=!r&&e.subscribed!==!1;if(C.useSyncExternalStore(C.useCallback(b=>{const y=d?c.subscribe(gs.batchCalls(b)):vl;return c.updateResult(),y},[c,d]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),C.useEffect(()=>{c.setOptions(i)},[i,c]),tHn(i,u))throw $pe(i,c,a);if(QVn({result:u,errorResetBoundary:a,throwOnError:i.throwOnError,query:s,suspense:i.suspense}))throw u.error;if((v=(g=o.getDefaultOptions().queries)==null?void 0:g._experimental_afterQuery)==null||v.call(g,i,u),i.experimental_prefetchInRender&&!uS.isServer()&&eHn(u,r)){const b=l?$pe(i,c,a):s==null?void 0:s.promise;b==null||b.catch(vl).finally(()=>{c.updateResult()})}return i.notifyOnChangeProps?u:c.trackResult(u)}function LI(e,t){return nHn(e,IVn)}function rHn(e,t){const n=_I(),[r]=C.useState(()=>new VVn(n,e));C.useEffect(()=>{r.setOptions(e)},[r,e]);const a=C.useSyncExternalStore(C.useCallback(i=>r.subscribe(gs.batchCalls(i)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),o=C.useCallback((i,s)=>{r.mutate(i,s).catch(vl)},[r]);if(a.error&&Uie(r.options.throwOnError,[a.error]))throw a.error;return{...a,mutate:o,mutateAsync:a.mutate}}function Jh(e,t,n){let r=n.initialDeps??[],a,o=!0;function i(){var s,l,c;let u;n.key&&((s=n.debug)!=null&&s.call(n))&&(u=Date.now());const d=e();if(!(d.length!==r.length||d.some((g,v)=>r[v]!==g)))return a;r=d;let h;if(n.key&&((l=n.debug)!=null&&l.call(n))&&(h=Date.now()),a=t(...d),n.key&&((c=n.debug)!=null&&c.call(n))){const g=Math.round((Date.now()-u)*100)/100,v=Math.round((Date.now()-h)*100)/100,b=v/16,y=(x,S)=>{for(x=String(x);x.length<S;)x=" "+x;return x};console.info(`%c⏱ ${y(v,5)} /${y(g,5)} ms`,`
|
|
674
674
|
font-size: .6rem;
|
|
675
675
|
font-weight: bold;
|
|
@@ -2227,7 +2227,7 @@ https://github.com/jquery/jquery/blob/master/src/event.js
|
|
|
2227
2227
|
http://jedwatson.github.io/classnames
|
|
2228
2228
|
*/var gve;function Dcr(){return gve||(gve=1,(function(e){(function(){var t={}.hasOwnProperty;function n(){for(var o="",i=0;i<arguments.length;i++){var s=arguments[i];s&&(o=a(o,r(s)))}return o}function r(o){if(typeof o=="string"||typeof o=="number")return o;if(typeof o!="object")return"";if(Array.isArray(o))return n.apply(null,o);if(o.toString!==Object.prototype.toString&&!o.toString.toString().includes("[native code]"))return o.toString();var i="";for(var s in o)t.call(o,s)&&o[s]&&(i=a(i,s));return i}function a(o,i){return i?o?o+" "+i:o+i:o}e.exports?(n.default=n,e.exports=n):window.classNames=n})()})(SU)),SU.exports}var Ocr=Dcr();const Ok=KI(Ocr);var jcr=["top","left","transform","className","children","innerRef"];function jZ(){return jZ=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},jZ.apply(this,arguments)}function Fcr(e,t){if(e==null)return{};var n={},r=Object.keys(e),a,o;for(o=0;o<r.length;o++)a=r[o],!(t.indexOf(a)>=0)&&(n[a]=e[a]);return n}function x6(e){var t=e.top,n=t===void 0?0:t,r=e.left,a=r===void 0?0:r,o=e.transform,i=e.className,s=e.children,l=e.innerRef,c=Fcr(e,jcr);return C.createElement("g",jZ({ref:l,className:Ok("visx-group",i),transform:o||"translate("+a+", "+n+")"},c),s)}x6.propTypes={top:m3.number,left:m3.number,transform:m3.string,className:m3.string,children:m3.node,innerRef:m3.oneOfType([m3.string,m3.func,m3.object])};function M_(e,t){return e==null||t==null?NaN:e<t?-1:e>t?1:e>=t?0:NaN}function Bcr(e,t){return e==null||t==null?NaN:t<e?-1:t>e?1:t>=e?0:NaN}function Brt(e){let t,n,r;e.length!==2?(t=M_,n=(s,l)=>M_(e(s),l),r=(s,l)=>e(s)-l):(t=e===M_||e===Bcr?e:Vcr,n=e,r=e);function a(s,l,c=0,u=s.length){if(c<u){if(t(l,l)!==0)return u;do{const d=c+u>>>1;n(s[d],l)<0?c=d+1:u=d}while(c<u)}return c}function o(s,l,c=0,u=s.length){if(c<u){if(t(l,l)!==0)return u;do{const d=c+u>>>1;n(s[d],l)<=0?c=d+1:u=d}while(c<u)}return c}function i(s,l,c=0,u=s.length){const d=a(s,l,c,u-1);return d>c&&r(s[d-1],l)>-r(s[d],l)?d-1:d}return{left:a,center:i,right:o}}function Vcr(){return 0}function Hcr(e){return e===null?NaN:+e}const Wcr=Brt(M_),Ucr=Wcr.right;Brt(Hcr).center;const qcr=Math.sqrt(50),Gcr=Math.sqrt(10),Kcr=Math.sqrt(2);function QR(e,t,n){const r=(t-e)/Math.max(0,n),a=Math.floor(Math.log10(r)),o=r/Math.pow(10,a),i=o>=qcr?10:o>=Gcr?5:o>=Kcr?2:1;let s,l,c;return a<0?(c=Math.pow(10,-a)/i,s=Math.round(e*c),l=Math.round(t*c),s/c<e&&++s,l/c>t&&--l,c=-c):(c=Math.pow(10,a)*i,s=Math.round(e/c),l=Math.round(t/c),s*c<e&&++s,l*c>t&&--l),l<s&&.5<=n&&n<2?QR(e,t,n*2):[s,l,c]}function Ycr(e,t,n){if(t=+t,e=+e,n=+n,!(n>0))return[];if(e===t)return[e];const r=t<e,[a,o,i]=r?QR(t,e,n):QR(e,t,n);if(!(o>=a))return[];const s=o-a+1,l=new Array(s);if(r)if(i<0)for(let c=0;c<s;++c)l[c]=(o-c)/-i;else for(let c=0;c<s;++c)l[c]=(o-c)*i;else if(i<0)for(let c=0;c<s;++c)l[c]=(a+c)/-i;else for(let c=0;c<s;++c)l[c]=(a+c)*i;return l}function FZ(e,t,n){return t=+t,e=+e,n=+n,QR(e,t,n)[2]}function Xcr(e,t,n){t=+t,e=+e,n=+n;const r=t<e,a=r?FZ(t,e,n):FZ(e,t,n);return(r?-1:1)*(a<0?1/-a:a)}function Zcr(e,t){switch(arguments.length){case 0:break;case 1:this.range(e);break;default:this.range(t).domain(e);break}return this}function Qcr(e){return function(){return e}}function Jcr(e){return+e}var mve=[0,1];function am(e){return e}function BZ(e,t){return(t-=e=+e)?function(n){return(n-e)/t}:Qcr(isNaN(t)?NaN:.5)}function e2r(e,t){var n;return e>t&&(n=e,e=t,t=n),function(r){return Math.max(e,Math.min(t,r))}}function t2r(e,t,n){var r=e[0],a=e[1],o=t[0],i=t[1];return a<r?(r=BZ(a,r),o=n(i,o)):(r=BZ(r,a),o=n(o,i)),function(s){return o(r(s))}}function n2r(e,t,n){var r=Math.min(e.length,t.length)-1,a=new Array(r),o=new Array(r),i=-1;for(e[r]<e[0]&&(e=e.slice().reverse(),t=t.slice().reverse());++i<r;)a[i]=BZ(e[i],e[i+1]),o[i]=n(t[i],t[i+1]);return function(s){var l=Ucr(e,s,1,r)-1;return o[l](a[l](s))}}function r2r(e,t){return t.domain(e.domain()).range(e.range()).interpolate(e.interpolate()).clamp(e.clamp()).unknown(e.unknown())}function a2r(){var e=mve,t=mve,n=Rm,r,a,o,i=am,s,l,c;function u(){var f=Math.min(e.length,t.length);return i!==am&&(i=e2r(e[0],e[f-1])),s=f>2?n2r:t2r,l=c=null,d}function d(f){return f==null||isNaN(f=+f)?o:(l||(l=s(e.map(r),t,n)))(r(i(f)))}return d.invert=function(f){return i(a((c||(c=s(t,e.map(r),E0)))(f)))},d.domain=function(f){return arguments.length?(e=Array.from(f,Jcr),u()):e.slice()},d.range=function(f){return arguments.length?(t=Array.from(f),u()):t.slice()},d.rangeRound=function(f){return t=Array.from(f),n=QJe,u()},d.clamp=function(f){return arguments.length?(i=f?!0:am,u()):i!==am},d.interpolate=function(f){return arguments.length?(n=f,u()):n},d.unknown=function(f){return arguments.length?(o=f,d):o},function(f,h){return r=f,a=h,u()}}function o2r(){return a2r()(am,am)}function i2r(e){return Math.abs(e=Math.round(e))>=1e21?e.toLocaleString("en").replace(/,/g,""):e.toString(10)}function JR(e,t){if(!isFinite(e)||e===0)return null;var n=(e=t?e.toExponential(t-1):e.toExponential()).indexOf("e"),r=e.slice(0,n);return[r.length>1?r[0]+r.slice(2):r,+e.slice(n+1)]}function B9(e){return e=JR(Math.abs(e)),e?e[1]:NaN}function s2r(e,t){return function(n,r){for(var a=n.length,o=[],i=0,s=e[0],l=0;a>0&&s>0&&(l+s+1>r&&(s=Math.max(1,r-l)),o.push(n.substring(a-=s,a+s)),!((l+=s+1)>r));)s=e[i=(i+1)%e.length];return o.reverse().join(t)}}function l2r(e){return function(t){return t.replace(/[0-9]/g,function(n){return e[+n]})}}var c2r=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function eP(e){if(!(t=c2r.exec(e)))throw new Error("invalid format: "+e);var t;return new i1e({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}eP.prototype=i1e.prototype;function i1e(e){this.fill=e.fill===void 0?" ":e.fill+"",this.align=e.align===void 0?">":e.align+"",this.sign=e.sign===void 0?"-":e.sign+"",this.symbol=e.symbol===void 0?"":e.symbol+"",this.zero=!!e.zero,this.width=e.width===void 0?void 0:+e.width,this.comma=!!e.comma,this.precision=e.precision===void 0?void 0:+e.precision,this.trim=!!e.trim,this.type=e.type===void 0?"":e.type+""}i1e.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function u2r(e){e:for(var t=e.length,n=1,r=-1,a;n<t;++n)switch(e[n]){case".":r=a=n;break;case"0":r===0&&(r=n),a=n;break;default:if(!+e[n])break e;r>0&&(r=0);break}return r>0?e.slice(0,r)+e.slice(a+1):e}var tP;function d2r(e,t){var n=JR(e,t);if(!n)return tP=void 0,e.toPrecision(t);var r=n[0],a=n[1],o=a-(tP=Math.max(-8,Math.min(8,Math.floor(a/3)))*3)+1,i=r.length;return o===i?r:o>i?r+new Array(o-i+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+JR(e,Math.max(0,t+o-1))[0]}function vve(e,t){var n=JR(e,t);if(!n)return e+"";var r=n[0],a=n[1];return a<0?"0."+new Array(-a).join("0")+r:r.length>a+1?r.slice(0,a+1)+"."+r.slice(a+1):r+new Array(a-r.length+2).join("0")}const yve={"%":(e,t)=>(e*100).toFixed(t),b:e=>Math.round(e).toString(2),c:e=>e+"",d:i2r,e:(e,t)=>e.toExponential(t),f:(e,t)=>e.toFixed(t),g:(e,t)=>e.toPrecision(t),o:e=>Math.round(e).toString(8),p:(e,t)=>vve(e*100,t),r:vve,s:d2r,X:e=>Math.round(e).toString(16).toUpperCase(),x:e=>Math.round(e).toString(16)};function bve(e){return e}var xve=Array.prototype.map,wve=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function f2r(e){var t=e.grouping===void 0||e.thousands===void 0?bve:s2r(xve.call(e.grouping,Number),e.thousands+""),n=e.currency===void 0?"":e.currency[0]+"",r=e.currency===void 0?"":e.currency[1]+"",a=e.decimal===void 0?".":e.decimal+"",o=e.numerals===void 0?bve:l2r(xve.call(e.numerals,String)),i=e.percent===void 0?"%":e.percent+"",s=e.minus===void 0?"−":e.minus+"",l=e.nan===void 0?"NaN":e.nan+"";function c(d,f){d=eP(d);var h=d.fill,g=d.align,v=d.sign,b=d.symbol,y=d.zero,x=d.width,S=d.comma,z=d.precision,M=d.trim,L=d.type;L==="n"?(S=!0,L="g"):yve[L]||(z===void 0&&(z=12),M=!0,L="g"),(y||h==="0"&&g==="=")&&(y=!0,h="0",g="=");var R=(f&&f.prefix!==void 0?f.prefix:"")+(b==="$"?n:b==="#"&&/[boxX]/.test(L)?"0"+L.toLowerCase():""),N=(b==="$"?r:/[%p]/.test(L)?i:"")+(f&&f.suffix!==void 0?f.suffix:""),O=yve[L],j=/[defgprs%]/.test(L);z=z===void 0?6:/[gprs]/.test(L)?Math.max(1,Math.min(21,z)):Math.max(0,Math.min(20,z));function B(H){var K=R,U=N,Z,G,W;if(L==="c")U=O(H)+U,H="";else{H=+H;var J=H<0||1/H<0;if(H=isNaN(H)?l:O(Math.abs(H),z),M&&(H=u2r(H)),J&&+H==0&&v!=="+"&&(J=!1),K=(J?v==="("?v:s:v==="-"||v==="("?"":v)+K,U=(L==="s"&&!isNaN(H)&&tP!==void 0?wve[8+tP/3]:"")+U+(J&&v==="("?")":""),j){for(Z=-1,G=H.length;++Z<G;)if(W=H.charCodeAt(Z),48>W||W>57){U=(W===46?a+H.slice(Z+1):H.slice(Z))+U,H=H.slice(0,Z);break}}}S&&!y&&(H=t(H,1/0));var ae=K.length+H.length+U.length,ne=ae<x?new Array(x-ae+1).join(h):"";switch(S&&y&&(H=t(ne+H,ne.length?x-U.length:1/0),ne=""),g){case"<":H=K+H+U+ne;break;case"=":H=K+ne+H+U;break;case"^":H=ne.slice(0,ae=ne.length>>1)+K+H+U+ne.slice(ae);break;default:H=ne+K+H+U;break}return o(H)}return B.toString=function(){return d+""},B}function u(d,f){var h=Math.max(-8,Math.min(8,Math.floor(B9(f)/3)))*3,g=Math.pow(10,-h),v=c((d=eP(d),d.type="f",d),{suffix:wve[8+h/3]});return function(b){return v(g*b)}}return{format:c,formatPrefix:u}}var ZT,Vrt,Hrt;p2r({thousands:",",grouping:[3],currency:["$",""]});function p2r(e){return ZT=f2r(e),Vrt=ZT.format,Hrt=ZT.formatPrefix,ZT}function h2r(e){return Math.max(0,-B9(Math.abs(e)))}function g2r(e,t){return Math.max(0,Math.max(-8,Math.min(8,Math.floor(B9(t)/3)))*3-B9(Math.abs(e)))}function m2r(e,t){return e=Math.abs(e),t=Math.abs(t)-e,Math.max(0,B9(t)-B9(e))+1}function v2r(e,t,n,r){var a=Xcr(e,t,n),o;switch(r=eP(r??",f"),r.type){case"s":{var i=Math.max(Math.abs(e),Math.abs(t));return r.precision==null&&!isNaN(o=g2r(a,i))&&(r.precision=o),Hrt(r,i)}case"":case"e":case"g":case"p":case"r":{r.precision==null&&!isNaN(o=m2r(a,Math.max(Math.abs(e),Math.abs(t))))&&(r.precision=o-(r.type==="e"));break}case"f":case"%":{r.precision==null&&!isNaN(o=h2r(a))&&(r.precision=o-(r.type==="%")*2);break}}return Vrt(r)}function y2r(e){var t=e.domain;return e.ticks=function(n){var r=t();return Ycr(r[0],r[r.length-1],n??10)},e.tickFormat=function(n,r){var a=t();return v2r(a[0],a[a.length-1],n??10,r)},e.nice=function(n){n==null&&(n=10);var r=t(),a=0,o=r.length-1,i=r[a],s=r[o],l,c,u=10;for(s<i&&(c=i,i=s,s=c,c=a,a=o,o=c);u-- >0;){if(c=FZ(i,s,n),c===l)return r[a]=i,r[o]=s,t(r);if(c>0)i=Math.floor(i/c)*c,s=Math.ceil(s/c)*c;else if(c<0)i=Math.ceil(i*c)/c,s=Math.floor(s*c)/c;else break;l=c}return e},e}function Wrt(){var e=o2r();return e.copy=function(){return r2r(e,Wrt())},Zcr.apply(e,arguments),y2r(e)}const CU=new Date,kU=new Date;function z1(e,t,n,r){function a(o){return e(o=arguments.length===0?new Date:new Date(+o)),o}return a.floor=o=>(e(o=new Date(+o)),o),a.ceil=o=>(e(o=new Date(o-1)),t(o,1),e(o),o),a.round=o=>{const i=a(o),s=a.ceil(o);return o-i<s-o?i:s},a.offset=(o,i)=>(t(o=new Date(+o),i==null?1:Math.floor(i)),o),a.range=(o,i,s)=>{const l=[];if(o=a.ceil(o),s=s==null?1:Math.floor(s),!(o<i)||!(s>0))return l;let c;do l.push(c=new Date(+o)),t(o,s),e(o);while(c<o&&o<i);return l},a.filter=o=>z1(i=>{if(i>=i)for(;e(i),!o(i);)i.setTime(i-1)},(i,s)=>{if(i>=i)if(s<0)for(;++s<=0;)for(;t(i,-1),!o(i););else for(;--s>=0;)for(;t(i,1),!o(i););}),n&&(a.count=(o,i)=>(CU.setTime(+o),kU.setTime(+i),e(CU),e(kU),Math.floor(n(CU,kU))),a.every=o=>(o=Math.floor(o),!isFinite(o)||!(o>0)?null:o>1?a.filter(r?i=>r(i)%o===0:i=>a.count(0,i)%o===0):a)),a}const OS=1e3,Q6=OS*60,jS=Q6*60,FS=jS*24,Urt=FS*7,s1e=z1(e=>{e.setTime(e-e.getMilliseconds())},(e,t)=>{e.setTime(+e+t*OS)},(e,t)=>(t-e)/OS,e=>e.getUTCSeconds());s1e.range;const qrt=z1(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*OS)},(e,t)=>{e.setTime(+e+t*Q6)},(e,t)=>(t-e)/Q6,e=>e.getMinutes());qrt.range;const Grt=z1(e=>{e.setUTCSeconds(0,0)},(e,t)=>{e.setTime(+e+t*Q6)},(e,t)=>(t-e)/Q6,e=>e.getUTCMinutes());Grt.range;const Krt=z1(e=>{e.setTime(e-e.getMilliseconds()-e.getSeconds()*OS-e.getMinutes()*Q6)},(e,t)=>{e.setTime(+e+t*jS)},(e,t)=>(t-e)/jS,e=>e.getHours());Krt.range;const Yrt=z1(e=>{e.setUTCMinutes(0,0,0)},(e,t)=>{e.setTime(+e+t*jS)},(e,t)=>(t-e)/jS,e=>e.getUTCHours());Yrt.range;const Xrt=z1(e=>e.setHours(0,0,0,0),(e,t)=>e.setDate(e.getDate()+t),(e,t)=>(t-e-(t.getTimezoneOffset()-e.getTimezoneOffset())*Q6)/FS,e=>e.getDate()-1);Xrt.range;const Zrt=z1(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/FS,e=>e.getUTCDate()-1);Zrt.range;const b2r=z1(e=>{e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCDate(e.getUTCDate()+t)},(e,t)=>(t-e)/FS,e=>Math.floor(e/FS));b2r.range;function F7(e){return z1(t=>{t.setDate(t.getDate()-(t.getDay()+7-e)%7),t.setHours(0,0,0,0)},(t,n)=>{t.setDate(t.getDate()+n*7)},(t,n)=>(n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*Q6)/Urt)}const Qrt=F7(0),x2r=F7(1),w2r=F7(2),S2r=F7(3),C2r=F7(4),k2r=F7(5),z2r=F7(6);Qrt.range;x2r.range;w2r.range;S2r.range;C2r.range;k2r.range;z2r.range;function B7(e){return z1(t=>{t.setUTCDate(t.getUTCDate()-(t.getUTCDay()+7-e)%7),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCDate(t.getUTCDate()+n*7)},(t,n)=>(n-t)/Urt)}const Jrt=B7(0),M2r=B7(1),T2r=B7(2),E2r=B7(3),_2r=B7(4),L2r=B7(5),R2r=B7(6);Jrt.range;M2r.range;T2r.range;E2r.range;_2r.range;L2r.range;R2r.range;const eat=z1(e=>{e.setDate(1),e.setHours(0,0,0,0)},(e,t)=>{e.setMonth(e.getMonth()+t)},(e,t)=>t.getMonth()-e.getMonth()+(t.getFullYear()-e.getFullYear())*12,e=>e.getMonth());eat.range;const tat=z1(e=>{e.setUTCDate(1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCMonth(e.getUTCMonth()+t)},(e,t)=>t.getUTCMonth()-e.getUTCMonth()+(t.getUTCFullYear()-e.getUTCFullYear())*12,e=>e.getUTCMonth());tat.range;const l1e=z1(e=>{e.setMonth(0,1),e.setHours(0,0,0,0)},(e,t)=>{e.setFullYear(e.getFullYear()+t)},(e,t)=>t.getFullYear()-e.getFullYear(),e=>e.getFullYear());l1e.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:z1(t=>{t.setFullYear(Math.floor(t.getFullYear()/e)*e),t.setMonth(0,1),t.setHours(0,0,0,0)},(t,n)=>{t.setFullYear(t.getFullYear()+n*e)});l1e.range;const c1e=z1(e=>{e.setUTCMonth(0,1),e.setUTCHours(0,0,0,0)},(e,t)=>{e.setUTCFullYear(e.getUTCFullYear()+t)},(e,t)=>t.getUTCFullYear()-e.getUTCFullYear(),e=>e.getUTCFullYear());c1e.every=e=>!isFinite(e=Math.floor(e))||!(e>0)?null:z1(t=>{t.setUTCFullYear(Math.floor(t.getUTCFullYear()/e)*e),t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},(t,n)=>{t.setUTCFullYear(t.getUTCFullYear()+n*e)});c1e.range;function P2r(e,t){t.domain&&("nice"in e||"quantiles"in e||"padding"in e,e.domain(t.domain))}function A2r(e,t){t.range&&("padding"in e,e.range(t.range))}function N2r(e,t){"align"in e&&"align"in t&&typeof t.align<"u"&&e.align(t.align)}function $2r(e,t){"base"in e&&"base"in t&&typeof t.base<"u"&&e.base(t.base)}function I2r(e,t){"clamp"in e&&"clamp"in t&&typeof t.clamp<"u"&&e.clamp(t.clamp)}function D2r(e,t){"constant"in e&&"constant"in t&&typeof t.constant<"u"&&e.constant(t.constant)}function O2r(e,t){"exponent"in e&&"exponent"in t&&typeof t.exponent<"u"&&e.exponent(t.exponent)}var Sve={lab:rZn,hcl:aZn,"hcl-long":oZn,hsl:tZn,"hsl-long":nZn,cubehelix:iZn,"cubehelix-long":sZn,rgb:yS};function j2r(e){switch(e){case"lab":case"hcl":case"hcl-long":case"hsl":case"hsl-long":case"cubehelix":case"cubehelix-long":case"rgb":return Sve[e]}var t=e.type,n=e.gamma,r=Sve[t];return typeof n>"u"?r:r.gamma(n)}function F2r(e,t){if("interpolate"in t&&"interpolate"in e&&typeof t.interpolate<"u"){var n=j2r(t.interpolate);e.interpolate(n)}}var B2r=new Date(Date.UTC(2020,1,2,3,4,5)),V2r="%Y-%m-%d %H:%M";function H2r(e){var t=e.tickFormat(1,V2r)(B2r);return t==="2020-02-02 03:04"}var Cve={day:Xrt,hour:Krt,minute:qrt,month:eat,second:s1e,week:Qrt,year:l1e},kve={day:Zrt,hour:Yrt,minute:Grt,month:tat,second:s1e,week:Jrt,year:c1e};function W2r(e,t){if("nice"in t&&typeof t.nice<"u"&&"nice"in e){var n=t.nice;if(typeof n=="boolean")n&&e.nice();else if(typeof n=="number")e.nice(n);else{var r=e,a=H2r(r);if(typeof n=="string")r.nice(a?kve[n]:Cve[n]);else{var o=n.interval,i=n.step,s=(a?kve[o]:Cve[o]).every(i);s!=null&&r.nice(s)}}}}function U2r(e,t){"padding"in e&&"padding"in t&&typeof t.padding<"u"&&e.padding(t.padding),"paddingInner"in e&&"paddingInner"in t&&typeof t.paddingInner<"u"&&e.paddingInner(t.paddingInner),"paddingOuter"in e&&"paddingOuter"in t&&typeof t.paddingOuter<"u"&&e.paddingOuter(t.paddingOuter)}function q2r(e,t){if(t.reverse){var n=e.range().slice().reverse();"padding"in e,e.range(n)}}function G2r(e,t){"round"in t&&typeof t.round<"u"&&(t.round&&"interpolate"in t&&typeof t.interpolate<"u"?console.warn("[visx/scale/applyRound] ignoring round: scale config contains round and interpolate. only applying interpolate. config:",t):"round"in e?e.round(t.round):"interpolate"in e&&t.round&&e.interpolate(QJe))}function K2r(e,t){"unknown"in e&&"unknown"in t&&typeof t.unknown<"u"&&e.unknown(t.unknown)}function Y2r(e,t){if("zero"in t&&t.zero===!0){var n=e.domain(),r=n[0],a=n[1],o=a<r,i=o?[a,r]:[r,a],s=i[0],l=i[1],c=[Math.min(0,s),Math.max(0,l)];e.domain(o?c.reverse():c)}}var X2r=["domain","nice","zero","interpolate","round","range","reverse","align","base","clamp","constant","exponent","padding","unknown"],Z2r={domain:P2r,nice:W2r,zero:Y2r,interpolate:F2r,round:G2r,align:N2r,base:$2r,clamp:I2r,constant:D2r,exponent:O2r,padding:U2r,range:A2r,reverse:q2r,unknown:K2r};function Q2r(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r=new Set(t),a=X2r.filter(function(o){return r.has(o)});return function(i,s){return typeof s<"u"&&a.forEach(function(l){Z2r[l](i,s)}),i}}var J2r=Q2r("domain","range","reverse","clamp","interpolate","nice","round","zero");function nP(e){return J2r(Wrt(),e)}var VZ=Math.PI,HZ=2*VZ,P8=1e-6,e0r=HZ-P8;function WZ(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function u1e(){return new WZ}WZ.prototype=u1e.prototype={constructor:WZ,moveTo:function(e,t){this._+="M"+(this._x0=this._x1=+e)+","+(this._y0=this._y1=+t)},closePath:function(){this._x1!==null&&(this._x1=this._x0,this._y1=this._y0,this._+="Z")},lineTo:function(e,t){this._+="L"+(this._x1=+e)+","+(this._y1=+t)},quadraticCurveTo:function(e,t,n,r){this._+="Q"+ +e+","+ +t+","+(this._x1=+n)+","+(this._y1=+r)},bezierCurveTo:function(e,t,n,r,a,o){this._+="C"+ +e+","+ +t+","+ +n+","+ +r+","+(this._x1=+a)+","+(this._y1=+o)},arcTo:function(e,t,n,r,a){e=+e,t=+t,n=+n,r=+r,a=+a;var o=this._x1,i=this._y1,s=n-e,l=r-t,c=o-e,u=i-t,d=c*c+u*u;if(a<0)throw new Error("negative radius: "+a);if(this._x1===null)this._+="M"+(this._x1=e)+","+(this._y1=t);else if(d>P8)if(!(Math.abs(u*s-l*c)>P8)||!a)this._+="L"+(this._x1=e)+","+(this._y1=t);else{var f=n-o,h=r-i,g=s*s+l*l,v=f*f+h*h,b=Math.sqrt(g),y=Math.sqrt(d),x=a*Math.tan((VZ-Math.acos((g+d-v)/(2*b*y)))/2),S=x/y,z=x/b;Math.abs(S-1)>P8&&(this._+="L"+(e+S*c)+","+(t+S*u)),this._+="A"+a+","+a+",0,0,"+ +(u*f>c*h)+","+(this._x1=e+z*s)+","+(this._y1=t+z*l)}},arc:function(e,t,n,r,a,o){e=+e,t=+t,n=+n,o=!!o;var i=n*Math.cos(r),s=n*Math.sin(r),l=e+i,c=t+s,u=1^o,d=o?r-a:a-r;if(n<0)throw new Error("negative radius: "+n);this._x1===null?this._+="M"+l+","+c:(Math.abs(this._x1-l)>P8||Math.abs(this._y1-c)>P8)&&(this._+="L"+l+","+c),n&&(d<0&&(d=d%HZ+HZ),d>e0r?this._+="A"+n+","+n+",0,1,"+u+","+(e-i)+","+(t-s)+"A"+n+","+n+",0,1,"+u+","+(this._x1=l)+","+(this._y1=c):d>P8&&(this._+="A"+n+","+n+",0,"+ +(d>=VZ)+","+u+","+(this._x1=e+n*Math.cos(a))+","+(this._y1=t+n*Math.sin(a))))},rect:function(e,t,n,r){this._+="M"+(this._x0=this._x1=+e)+","+(this._y0=this._y1=+t)+"h"+ +n+"v"+ +r+"h"+-n+"Z"},toString:function(){return this._}};function Uc(e){return function(){return e}}function nat(e){this._context=e}nat.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t);break}}};function rat(e){return new nat(e)}function aat(e){return e[0]}function oat(e){return e[1]}function iat(){var e=aat,t=oat,n=Uc(!0),r=null,a=rat,o=null;function i(s){var l,c=s.length,u,d=!1,f;for(r==null&&(o=a(f=u1e())),l=0;l<=c;++l)!(l<c&&n(u=s[l],l,s))===d&&((d=!d)?o.lineStart():o.lineEnd()),d&&o.point(+e(u,l,s),+t(u,l,s));if(f)return o=null,f+""||null}return i.x=function(s){return arguments.length?(e=typeof s=="function"?s:Uc(+s),i):e},i.y=function(s){return arguments.length?(t=typeof s=="function"?s:Uc(+s),i):t},i.defined=function(s){return arguments.length?(n=typeof s=="function"?s:Uc(!!s),i):n},i.curve=function(s){return arguments.length?(a=s,r!=null&&(o=a(r)),i):a},i.context=function(s){return arguments.length?(s==null?r=o=null:o=a(r=s),i):r},i}function t0r(){var e=aat,t=null,n=Uc(0),r=oat,a=Uc(!0),o=null,i=rat,s=null;function l(u){var d,f,h,g=u.length,v,b=!1,y,x=new Array(g),S=new Array(g);for(o==null&&(s=i(y=u1e())),d=0;d<=g;++d){if(!(d<g&&a(v=u[d],d,u))===b)if(b=!b)f=d,s.areaStart(),s.lineStart();else{for(s.lineEnd(),s.lineStart(),h=d-1;h>=f;--h)s.point(x[h],S[h]);s.lineEnd(),s.areaEnd()}b&&(x[d]=+e(v,d,u),S[d]=+n(v,d,u),s.point(t?+t(v,d,u):x[d],r?+r(v,d,u):S[d]))}if(y)return s=null,y+""||null}function c(){return iat().defined(a).curve(i).context(o)}return l.x=function(u){return arguments.length?(e=typeof u=="function"?u:Uc(+u),t=null,l):e},l.x0=function(u){return arguments.length?(e=typeof u=="function"?u:Uc(+u),l):e},l.x1=function(u){return arguments.length?(t=u==null?null:typeof u=="function"?u:Uc(+u),l):t},l.y=function(u){return arguments.length?(n=typeof u=="function"?u:Uc(+u),r=null,l):n},l.y0=function(u){return arguments.length?(n=typeof u=="function"?u:Uc(+u),l):n},l.y1=function(u){return arguments.length?(r=u==null?null:typeof u=="function"?u:Uc(+u),l):r},l.lineX0=l.lineY0=function(){return c().x(e).y(n)},l.lineY1=function(){return c().x(e).y(r)},l.lineX1=function(){return c().x(t).y(n)},l.defined=function(u){return arguments.length?(a=typeof u=="function"?u:Uc(!!u),l):a},l.curve=function(u){return arguments.length?(i=u,o!=null&&(s=i(o)),l):i},l.context=function(u){return arguments.length?(u==null?o=s=null:s=i(o=u),l):o},l}function zve(e){return e<0?-1:1}function Mve(e,t,n){var r=e._x1-e._x0,a=t-e._x1,o=(e._y1-e._y0)/(r||a<0&&-0),i=(n-e._y1)/(a||r<0&&-0),s=(o*a+i*r)/(r+a);return(zve(o)+zve(i))*Math.min(Math.abs(o),Math.abs(i),.5*Math.abs(s))||0}function Tve(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function zU(e,t,n){var r=e._x0,a=e._y0,o=e._x1,i=e._y1,s=(o-r)/3;e._context.bezierCurveTo(r+s,a+s*t,o-s,i-s*n,o,i)}function rP(e){this._context=e}rP.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:zU(this,this._t0,Tve(this,this._t0));break}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,!(e===this._x1&&t===this._y1)){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,zU(this,Tve(this,n=Mve(this,e,t)),n);break;default:zU(this,this._t0,n=Mve(this,e,t));break}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};Object.create(rP.prototype).point=function(e,t){rP.prototype.point.call(this,t,e)};function Eve(e){return new rP(e)}function Mf(e,t){e(t)}function n0r(e){var t=e===void 0?{}:e,n=t.x,r=t.x0,a=t.x1,o=t.y,i=t.y0,s=t.y1,l=t.defined,c=t.curve,u=t0r();return n&&Mf(u.x,n),r&&Mf(u.x0,r),a&&Mf(u.x1,a),o&&Mf(u.y,o),i&&Mf(u.y0,i),s&&Mf(u.y1,s),l&&u.defined(l),c&&u.curve(c),u}function r0r(e){var t=e===void 0?{}:e,n=t.x,r=t.y,a=t.defined,o=t.curve,i=iat();return n&&Mf(i.x,n),r&&Mf(i.y,r),a&&i.defined(a),o&&i.curve(o),i}var a0r=["from","to","fill","className","innerRef"];function UZ(){return UZ=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},UZ.apply(this,arguments)}function o0r(e,t){if(e==null)return{};var n={},r=Object.keys(e),a,o;for(o=0;o<r.length;o++)a=r[o],!(t.indexOf(a)>=0)&&(n[a]=e[a]);return n}function _0(e){var t=e.from,n=t===void 0?{x:0,y:0}:t,r=e.to,a=r===void 0?{x:1,y:1}:r,o=e.fill,i=o===void 0?"transparent":o,s=e.className,l=e.innerRef,c=o0r(e,a0r),u=n.x===a.x||n.y===a.y;return C.createElement("line",UZ({ref:l,className:Ok("visx-line",s),x1:n.x,y1:n.y,x2:a.x,y2:a.y,fill:i,shapeRendering:u?"crispEdges":"auto"},c))}var i0r=["children","data","x","y","fill","className","curve","innerRef","defined"];function qZ(){return qZ=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},qZ.apply(this,arguments)}function s0r(e,t){if(e==null)return{};var n={},r=Object.keys(e),a,o;for(o=0;o<r.length;o++)a=r[o],!(t.indexOf(a)>=0)&&(n[a]=e[a]);return n}function l0r(e){var t=e.children,n=e.data,r=n===void 0?[]:n,a=e.x,o=e.y,i=e.fill,s=i===void 0?"transparent":i,l=e.className,c=e.curve,u=e.innerRef,d=e.defined,f=d===void 0?function(){return!0}:d,h=s0r(e,i0r),g=r0r({x:a,y:o,defined:f,curve:c});return t?C.createElement(C.Fragment,null,t({path:g})):C.createElement("path",qZ({ref:u,className:Ok("visx-linepath",l),d:g(r)||"",fill:s,strokeLinecap:"round"},h))}var c0r=["children","x","x0","x1","y","y0","y1","data","defined","className","curve","innerRef"];function GZ(){return GZ=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},GZ.apply(this,arguments)}function u0r(e,t){if(e==null)return{};var n={},r=Object.keys(e),a,o;for(o=0;o<r.length;o++)a=r[o],!(t.indexOf(a)>=0)&&(n[a]=e[a]);return n}function d0r(e){var t=e.children,n=e.x,r=e.x0,a=e.x1,o=e.y,i=e.y0,s=e.y1,l=e.data,c=l===void 0?[]:l,u=e.defined,d=u===void 0?function(){return!0}:u,f=e.className,h=e.curve,g=e.innerRef,v=u0r(e,c0r),b=n0r({x:n,x0:r,x1:a,y:o,y0:i,y1:s,defined:d,curve:h});return t?C.createElement(C.Fragment,null,t({path:b})):C.createElement("path",GZ({ref:g,className:Ok("visx-area",f),d:b(c)||""},v))}var f0r=["className","innerRef"];function KZ(){return KZ=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},KZ.apply(this,arguments)}function p0r(e,t){if(e==null)return{};var n={},r=Object.keys(e),a,o;for(o=0;o<r.length;o++)a=r[o],!(t.indexOf(a)>=0)&&(n[a]=e[a]);return n}function sat(e){var t=e.className,n=e.innerRef,r=p0r(e,f0r);return C.createElement("circle",KZ({ref:n,className:Ok("visx-circle",t)},r))}function lat(e,t){const n=r=>r.replace(/\{(\w+)\}/g,(a,o)=>o in t?t[o]:a);return{term:n(e.term),gist:n(e.gist),detail:n(e.detail),...e.jargon!==void 0?{jargon:n(e.jargon)}:{}}}const cat={guidance:{term:"Guidance",gist:"Plain-language explainers for everything on this surface.",detail:"While this is on, hover any heading, value or chart label to see what it means — in business terms, with the statistical name underneath. Click to turn it off."},header:{term:"The question",gist:"You’re asking whether {treatment} actually moved {outcome}.",detail:"Pick the lever you changed and the result you cared about, then hit Run — the surface answers whether the change is real and trustworthy.",jargon:"a binary-treatment causal effect"},step_treatment:{term:"What did you change?",gist:"The lever you’re testing — a yes/no flag on each {subject}.",detail:"It splits {subjects} into a “did” group and a “didn’t” group; the whole experiment compares those two.",jargon:"the treatment (binary)"},step_outcome:{term:"What did you want it to improve?",gist:"The result you’re hoping {treatment} moved.",detail:"A number measured on each {subject} (revenue, a duration, a score, …). The effect is the change in this we can credit to the lever.",jargon:"the outcome"},step_confounders:{term:"What else was different?",gist:"Things about the “did” group that could also explain the change.",detail:"If the {subjects} you treated already differed on something that matters — bigger, older, higher-value — that, not the lever, could be moving the result. We level the playing field on each of these so the comparison is fair. Add the ones you suspect.",jargon:"confounders / the backdoor adjustment set"},step_population:{term:"Which {subjects}?",gist:"Narrow the experiment to a slice of the {subjects}.",detail:"Filter to a subset you care about — a region, a period, a category — before measuring, so the answer is about the {subjects} that matter.",jargon:"population / cohort filter"},adv_method:{term:"How to compare",gist:"The maths used to make the like-for-like comparison.",detail:"“Regression” fits a line through the confounders; “re-weighting” up-weights rare look-alikes. They usually agree — if they don’t, treat the result with care.",jargon:"estimator: linear regression vs propensity-score weighting"},adv_estimand:{term:"Answer for",gist:"Who the effect is reported for.",detail:"“All” averages over everyone; “only treated” asks what the lever did for the {subjects} you actually treated — useful when you’d only ever apply it to them.",jargon:"estimand: ATE vs ATT"},confounder_imbalance:{term:"How lopsided this one was",gist:"How different the two groups were on this factor, before adjusting.",detail:"A long bar means the treated and untreated {subjects} started far apart here — exactly the kind of gap the adjustment has to close.",jargon:"standardised mean difference (SMD)"},tab_answer:{term:"The answer",gist:"The headline: did {treatment} move {outcome}, and by how much?",detail:"Shows the raw gap, the fair like-for-like estimate, and an honest verdict."},tab_trust:{term:"Can we trust it?",gist:"The stress tests we ran to try to break the answer.",detail:"Each check probes a way the result could be a fluke; green means it held up."},tab_dose:{term:"How much?",gist:"How the result changes as a factor goes up or down.",detail:"Not just yes/no — the shape of the response, so you can find the sweet spot."},answer_effect:{term:"Like-for-like effect",gist:"The change in {outcome} we can credit to {treatment}.",detail:"It compares treated vs untreated {subjects} who were otherwise similar — so it strips out “who you targeted” and leaves the lever’s real impact.",jargon:"the backdoor-adjusted average treatment effect"},answer_ci:{term:"95% range",gist:"Where the true effect most likely sits.",detail:"If this range doesn’t cross 0, the effect is real, not noise. The wider it is, the less certain — usually because of fewer {subjects}.",jargon:"95% confidence interval"},answer_flip:{term:"Raw and like-for-like disagree",gist:"The plain average points one way; the fair comparison points the other.",detail:"This happens when the treated group differed sharply on a confounder. Trust the like-for-like number — the raw gap is misleading here.",jargon:"confounding / Simpson’s-paradox sign flip"},answer_cautious:{term:"Treat this as provisional",gist:"We got a number, but a trust check failed.",detail:"The estimate may still be driven by something we didn’t adjust for. See “Can we trust it?” before acting on it.",jargon:"adjustment_insufficient verdict"},forest_plot:{term:"Raw average vs. like-for-like",gist:"The misleading number next to the fair one.",detail:"Each bar is an estimate with its uncertainty range; the dashed line is “no effect”. A bar clear of that line is a real change.",jargon:"a forest plot of naive vs adjusted estimates"},forest_naive:{term:"Raw average",gist:"The plain difference, with no adjusting.",detail:"Just treated-minus-untreated. It mixes in who you targeted, so it can mislead — it’s here only as the “before” picture.",jargon:"the unadjusted mean difference"},forest_adjusted:{term:"Like-for-like",gist:"The fair comparison after levelling the confounders.",detail:"This is the number to act on — what {treatment} did among otherwise-similar {subjects}.",jargon:"the adjusted effect"},balance:{term:"How unbalanced each one was",gist:"How far apart the two groups started on each factor.",detail:"Big bars are the factors the adjustment had to work hardest to correct — and the ones most worth double-checking.",jargon:"pre-adjustment covariate balance (SMD)"},counts:{term:"The {subject} counts",gist:"How many {subjects} went into the comparison.",detail:"“Compared like-for-like” are the ones with a fair match on the other side; “no fair match” were set aside because nobody comparable existed.",jargon:"n total / on-support / off-support"},overlap_histogram:{term:"Do the two groups overlap?",gist:"Whether treated and untreated {subjects} actually look alike anywhere.",detail:"Each bar is how many {subjects} sit at a given “likelihood of being treated”. Where the two arms both have bars, a fair comparison exists; if they barely meet, there’s nothing to compare.",jargon:"propensity-score overlap / common support"},refusal_positivity:{term:"No like-for-like comparison exists",gist:"The treated and untreated {subjects} are too different to compare.",detail:"For almost every treated {subject} there’s no similar untreated one (or vice-versa), so there’s no fair “other side”. We refuse rather than extrapolate into thin air. Try fewer or different confounders.",jargon:"positivity / overlap violation"},refusal_not_estimable:{term:"Can’t be estimated",gist:"Almost every {subject} is on one side of {treatment}, so there’s no comparison group.",detail:"Measuring an effect needs a decent number of {subjects} who got the lever AND who didn’t. When one side is just a handful, we refuse to guess rather than read too much into a few people.",jargon:"no treatment variation"},trust_intro:{term:"Can we trust it?",gist:"Before believing the answer, we tried to break it.",detail:"Each row is a different way the result could be a fluke; colour shows whether it held up (pass) or wobbled (caution)."},check_shuffle:{term:"Shuffle test",gist:"We randomly re-label who got {treatment} and re-measure.",detail:"On fake labels a genuine effect should collapse to nothing. If a “fake” effect still appears, the real one isn’t trustworthy.",jargon:"placebo / permutation refuter"},check_dropsome:{term:"Drop-some test",gist:"We re-run on random slices of the {subjects}.",detail:"A trustworthy effect barely moves when you drop some data; a jumpy one is resting on a few {subjects}.",jargon:"data-subset refuter"},check_decoy:{term:"Decoy factor",gist:"We add a totally random extra factor and re-measure.",detail:"A made-up factor shouldn’t change the answer. If it does, the model is over-reacting to noise.",jargon:"random-common-cause refuter"},check_hidden:{term:"Hidden cause",gist:"How strong an unrecorded cause would have to be to overturn the result.",detail:"Something you didn’t measure could drive both who got {treatment} and {outcome}. “Holds throughout” means only an implausibly strong hidden cause could flip it.",jargon:"unobserved-confounding sensitivity / E-value"},sensitivity:{term:"Effect as a hidden cause gets stronger",gist:"What happens to the effect if an unrecorded cause is dialled up.",detail:"The line is the estimate as a simulated hidden cause grows. The point where it crosses 0 is how much hidden bias it would take to erase the result.",jargon:"sensitivity (tipping-point) curve"},dose_curve:{term:"{outcome} gained vs. {feature}",gist:"How {outcome} responds as {feature} goes up.",detail:"The line is the average change in {outcome} at each level of {feature}, with its uncertainty band — the shape tells you where more pays off and where it flattens.",jargon:"accumulated local effects (ALE) dose-response"},dose_here:{term:"You are here",gist:"Where most of your {subjects} currently sit on {feature}.",detail:"The busiest level today — your starting point for deciding whether to push higher or lower.",jargon:"the modal bin"},dose_sweet:{term:"Sweet spot",gist:"Where the gains are solid and start to flatten.",detail:"Past here, pushing {feature} higher buys little extra {outcome} — a sensible target.",jargon:"the diminishing-returns knee"},dose_reco:{term:"Recommended",gist:"The level of {feature} we’d aim for.",detail:"The sweet-spot level and the {outcome} you’d expect there, with its range — and the trade-off of going one step further.",jargon:"the recommended operating point"},dose_marginal:{term:"Extra {outcome} per step",gist:"What each additional step of {feature} buys you.",detail:"Tall early bars then short ones is the classic diminishing-returns shape — spend effort where the bars are tall.",jargon:"marginal / incremental effect per bin"},verdict_causal:{term:"Causal",gist:"A real change you can credit to {treatment} — and it held up.",detail:"The like-for-like effect is clear, sizeable, and survived the trust checks. Safe to act on.",jargon:"a robust, identified effect"},verdict_modest:{term:"Modest / unclear",gist:"There may be an effect, but it’s small or fuzzy.",detail:"The fair comparison can’t cleanly separate it from no-effect (the range straddles 0, or it’s tiny). Don’t bet much on it.",jargon:"effect CI spans zero / below materiality"},verdict_adjustment_insufficient:{term:"Not trustworthy yet",gist:"We got a number, but a trust check failed.",detail:"Likely something we didn’t adjust for is still in play. Treat as provisional and look at “Can we trust it?”.",jargon:"placebo / robustness failure"},verdict_non_identifiable_positivity:{term:"No fair comparison",gist:"Treated and untreated {subjects} don’t overlap enough to compare.",detail:"There’s no like-for-like “other side”, so any number would be extrapolation. See the overlap chart.",jargon:"positivity / overlap violation"},verdict_not_estimable:{term:"Can’t be estimated",gist:"Almost everyone is on one side of {treatment} — no comparison group.",detail:"One arm is just a handful of {subjects}, so we won’t guess an effect from it.",jargon:"no treatment variation"},tab_validate:{term:"Prove it",gist:"The real experiment you’d run to prove this — for sure.",detail:"This analysis adjusted for what it could measure. A controlled trial — assigning {treatment} at random — removes any leftover doubt. This tab sizes that trial."},validate_size:{term:"How many to run",gist:"The number of {subjects} the trial needs.",detail:"Enough to spot a change this size if it’s real. A bigger or cleaner effect needs fewer; a small or noisy one needs many more.",jargon:"required sample size at the target power"},validate_split:{term:"How to split them",gist:"How many get {treatment} versus are left alone.",detail:"Assign at random — that’s what makes the two groups comparable with no adjusting. An even split is the most efficient; treating fewer needs a larger total.",jargon:"randomised allocation between arms"},validate_match:{term:"Match the groups on",gist:"Keep both groups balanced on these — they were lopsided last time.",detail:"Give each group the same mix of these factors when you split, so neither one starts ahead. These are the factors that muddied the original comparison most.",jargon:"stratified / blocked randomisation on the high-imbalance covariates"},validate_power:{term:"Chance of detecting it",gist:"How likely the trial is to catch the effect, by size.",detail:"More {subjects} means a better chance of a clear result. The marker shows where today’s data sits — usually well short of a confident answer.",jargon:"statistical power vs sample size"},validate_holdback:{term:"Hold back a control",gist:"Keep a random group untreated to compare against.",detail:"Right now almost everything got {treatment}, so there’s nothing to compare to. Next time, leave a random sample untreated — that group becomes the fair baseline.",jargon:"a randomised control arm"},journal:{term:"Committed experiments",gist:"A log of the questions you’ve saved.",detail:"Each row is a framing you committed — its verdict and headline effect — so the team can see what’s been tried and what held up.",jargon:"the experiment journal"}},SD=C.createContext({on:!0,vars:{}});function h0r({on:e,vars:t,children:n}){return p.jsx(SD.Provider,{value:{on:e,vars:t},children:n})}function g0r({id:e,extraVars:t}){const{vars:n}=C.useContext(SD),r=lat(cat[e],{...n,...t}),a=en({key:"hoverCard"})();return p.jsxs(V,{display:"flex",flexDirection:"column",gap:"1.5",children:[p.jsx(V,{css:a.title,mb:"0",children:r.term}),p.jsx(Ie,{textStyle:"body.sm",color:"fg.default",lineHeight:"1.5",children:r.gist}),p.jsx(V,{css:a.description,lineHeight:"1.5",children:r.detail}),r.jargon&&p.jsxs(Ie,{textStyle:"caption",color:"fg.subtle",mt:"0.5",pt:"1.5",borderTopWidth:"1px",borderColor:"border.subtle",children:["Technically: ",r.jargon]})]})}function uat({id:e,extraVars:t,trigger:n}){return p.jsxs(kL,{openDelay:150,closeDelay:80,size:"sm",positioning:{placement:"top"},children:[p.jsx(zL,{asChild:!0,children:n}),p.jsx(go,{children:p.jsx(Nre,{children:p.jsxs($re,{children:[p.jsx(NAe,{children:p.jsx(Ire,{})}),p.jsx(g0r,{id:e,extraVars:t})]})})})]})}function Di({id:e,extraVars:t,children:n,display:r="inline",gap:a}){const{on:o}=C.useContext(SD);return o?p.jsx(uat,{id:e,extraVars:t,trigger:p.jsx(V,{as:"span",cursor:"help",tabIndex:0,display:r,...a?{alignItems:"center",gap:a}:{},_focusVisible:{outline:"1px dotted",outlineColor:"brand.fg",outlineOffset:"2px",borderRadius:"2px"},children:n})}):p.jsx(p.Fragment,{children:n})}function m0r({id:e,extraVars:t}){const{on:n,vars:r}=C.useContext(SD);if(!n)return null;const a=lat(cat[e],{...r,...t});return p.jsx(Ie,{textStyle:"caption",color:"fg.muted",lineHeight:"1.45",mt:"-1.5",mb:"2.5",children:a.gist})}function v0r({on:e,onToggle:t}){const n=ga({key:"iconButton"});return p.jsx(uat,{id:"guidance",trigger:p.jsx(V,{as:"button",css:n({variant:e?"subtle":"ghost",size:"sm"}),onClick:t,"aria-pressed":e,"aria-label":"Toggle guidance",color:e?"brand.fg":"fg.muted",children:p.jsx(Ur,{icon:iKn})})})}function dat({x:e,y:t,w:n,align:r,size:a,weight:o,color:i,family:s,help:l,children:c}){const u=p.jsx("span",{style:{fontSize:`${a}px`,fontFamily:s,fontWeight:o,color:i,lineHeight:1,whiteSpace:"nowrap"},children:c});return p.jsx("foreignObject",{x:e,y:t,width:n,height:a+6,style:{overflow:"visible"},children:p.jsx("div",{style:{textAlign:r,fontSize:`${a}px`,lineHeight:1},children:l?p.jsx(Di,{id:l,children:u}):u})})}function Qc(e,t,n,r){return{fontSize:`${e}px`,fill:t,fontFamily:n,...r!==void 0?{fontWeight:r}:{}}}function d1e(){const e=C.useRef(null),[t,n]=C.useState(0);return C.useLayoutEffect(()=>{const r=e.current;if(!r)return;const a=()=>n(r.clientWidth);a();const o=new ResizeObserver(a);return o.observe(r),()=>o.disconnect()},[]),[e,t]}function f1e(){const e=l5(),t=(r,a)=>e.token(r,a),n={neg:t("colors.fg.danger","#b85a4a"),pos:t("colors.fg.success","#2f7a5b"),warn:t("colors.fg.warning","#b8862d"),muted:t("colors.fg.muted","#6b8080"),brand:t("colors.brand.solid","#3a7780")};return{mono:t("fonts.mono",'"JetBrains Mono", ui-monospace, monospace'),body:t("fonts.body","system-ui, -apple-system, sans-serif"),ink:t("colors.fg","#111b22"),muted:n.muted,faint:t("colors.fg.subtle","#9bb0b0"),rule:t("colors.border.subtle","#e2e8e8"),ruleStrong:t("colors.border.strong","#cbd5d5"),surface:t("colors.bg.surface","#ffffff"),tone:r=>n[r]??n.brand,labelSize:10,titleSize:11,lineWidth:1.8,barWidth:2.5,dotRadius:2.6,scatterRadius:3.4,areaOpacity:.16}}const fat=e=>Number.isInteger(e)?String(e):e.toFixed(1),YZ=e=>(e>0?"+":"")+fat(e),_ve=e=>{if(e<=1e-9)return 0;const t=Math.pow(10,Math.floor(Math.log10(e))),n=e/t;return(n<=1?1:n<=1.5?1.5:n<=2?2:n<=3?3:n<=4?4:n<=5?5:n<=6?6:n<=8?8:10)*t};function y0r({rows:e,min:t,max:n,unit:r,height:a,rowHelp:o}){const i=f1e(),[s,l]=d1e(),c=e.length,u=a??26+c*38,d=124,f=46,h=20,g=30,v=Math.max(0,l-d-f),b=u-h-g,y=nP({domain:[t,n],range:[0,v]}),x=b/Math.max(1,c),S=Math.max(0,Math.min(v,y(0))),z=N=>n>t?(N-t)/(n-t):.5,M=N=>z(N)<.06?"start":z(N)>.94?"end":"middle",L=z(0),R=L>.12&&L<.88?[t,0,n]:[t,n];return p.jsx(V,{ref:s,width:"100%",height:`${u}px`,children:l>0&&p.jsx("svg",{width:l,height:u,style:{display:"block"},children:p.jsxs(x6,{left:d,top:h,children:[p.jsx(_0,{from:{x:S,y:-4},to:{x:S,y:b},stroke:i.muted,strokeWidth:1,strokeDasharray:"3 2"}),p.jsx("text",{x:S,y:-6,textAnchor:M(0),style:Qc(i.labelSize,i.muted,i.mono),children:"no effect"}),e.map((N,O)=>{const j=x*O+x/2,B=i.tone(N.tone);return p.jsxs(x6,{top:j,children:[p.jsx(_0,{from:{x:y(N.lo),y:0},to:{x:y(N.hi),y:0},stroke:B,strokeWidth:i.barWidth,strokeOpacity:.9,strokeLinecap:"round"}),p.jsx(_0,{from:{x:y(N.lo),y:-4},to:{x:y(N.lo),y:4},stroke:B,strokeWidth:1.5}),p.jsx(_0,{from:{x:y(N.hi),y:-4},to:{x:y(N.hi),y:4},stroke:B,strokeWidth:1.5}),p.jsx(sat,{cx:y(N.est),cy:0,r:i.scatterRadius,fill:B,stroke:i.surface,strokeWidth:1.8}),p.jsx(dat,{x:-d+2,y:-13,w:d-6,align:"left",size:i.labelSize,weight:600,color:i.ink,family:i.body,...o!=null&&o[O]?{help:o[O]}:{},children:N.label}),N.note&&p.jsx("text",{x:-d+2,y:9,style:Qc(9,i.faint,i.body),children:N.note}),p.jsx("text",{x:v+f-2,y:4,textAnchor:"end",style:Qc(i.titleSize,B,i.mono,700),children:YZ(N.est)})]},O)}),p.jsx(_0,{from:{x:0,y:b},to:{x:v,y:b},stroke:i.rule,strokeWidth:1}),R.map((N,O)=>p.jsxs(x6,{left:Math.max(0,Math.min(v,y(N))),children:[p.jsx(_0,{from:{x:0,y:b},to:{x:0,y:b+4},stroke:i.ruleStrong,strokeWidth:1}),p.jsx("text",{x:0,y:b+14,textAnchor:M(N),style:Qc(i.labelSize,i.muted,i.mono),children:YZ(N)})]},`t${O}`)),r&&p.jsx("text",{x:v/2,y:b+26,textAnchor:"middle",style:Qc(i.labelSize,i.muted,i.mono),children:r})]})})})}function XZ({lo:e,mid:t,hi:n,xTicks:r=[],yTicks:a=[],zero:o,tone:i,marks:s=[],height:l,yFormat:c="signed"}){const u=f1e(),[d,f]=d1e(),h=l??100,g=u.tone(i??"brand"),v=a.length?52:6,b=12,y=s.length?22:8,x=r.length?22:12,S=Math.max(0,f-v-b),z=h-y-x,M=nP({domain:[0,Math.max(1,t.length-1)],range:[0,S]}),L=(Z,G)=>typeof Z=="number"&&Number.isFinite(Z)?Z:G,R=t.map((Z,G)=>{const W=L(Z,0);return{i:G,lo:L(e[G],W),hi:L(n[G],W),mid:W}}),N=Math.min(...R.map(Z=>Z.lo),o??1/0),O=Math.max(...R.map(Z=>Z.hi),o??-1/0),j=_ve(Math.max(O,0)),B=N<-.08*j?-_ve(-N):0,H=nP({domain:[B,j],range:[z,0]}),K=Z=>c==="percent"?`${Math.round(Z)}%`:YZ(Z),U=[K(j),K((j+B)/2),K(B)];return p.jsx(V,{ref:d,width:"100%",height:`${h}px`,children:f>0&&p.jsx("svg",{width:f,height:h,style:{display:"block"},children:p.jsxs(x6,{left:v,top:y,children:[p.jsx(_0,{from:{x:0,y:0},to:{x:0,y:z},stroke:u.rule,strokeWidth:1}),a.length>0&&p.jsxs(p.Fragment,{children:[p.jsx("text",{x:-8,y:10,textAnchor:"end",style:Qc(u.labelSize,u.muted,u.mono),children:U[0]}),p.jsx("text",{x:-8,y:z/2+3,textAnchor:"end",style:Qc(u.labelSize,u.muted,u.mono),children:U[1]}),p.jsx("text",{x:-8,y:z-1,textAnchor:"end",style:Qc(u.labelSize,u.muted,u.mono),children:U[2]})]}),o!=null&&p.jsx(_0,{from:{x:0,y:H(o)},to:{x:S,y:H(o)},stroke:u.muted,strokeWidth:1,strokeDasharray:"3 2"}),p.jsx(d0r,{data:R,x:Z=>M(Z.i),y0:Z=>H(Z.lo),y1:Z=>H(Z.hi),curve:Eve,fill:g,fillOpacity:u.areaOpacity,stroke:"transparent"}),p.jsx(l0r,{data:R,x:Z=>M(Z.i),y:Z=>H(Z.mid),curve:Eve,stroke:g,strokeWidth:u.lineWidth}),s.map((Z,G)=>{const W=u.tone(Z.tone),J=H(L(t[Z.at],0)),ae=Math.max(9,J-9),ne=Z.at>=t.length-2,Y=Z.at<=1,te=ne?"right":Y?"left":"center",ie=Z.label.length*6.5+8,ue=ne?-ie-5:Y?5:-ie/2;return p.jsxs(x6,{left:M(Z.at),children:[p.jsx(_0,{from:{x:0,y:-2},to:{x:0,y:z},stroke:W,strokeWidth:1,strokeDasharray:"2 3"}),p.jsx(sat,{cx:0,cy:J,r:u.dotRadius,fill:W,stroke:u.surface,strokeWidth:1.5}),p.jsx(dat,{x:ue,y:ae-11,w:ie,align:te,size:u.labelSize,weight:500,color:W,family:u.body,...Z.help?{help:Z.help}:{},children:Z.label})]},`mk${G}`)}),p.jsx(_0,{from:{x:0,y:z},to:{x:S,y:z},stroke:u.rule,strokeWidth:1}),r.map((Z,G)=>{const W=Number.isNaN(Number(Z));return p.jsx("text",{x:S*G/Math.max(1,r.length-1),y:z+14,textAnchor:G===0?"start":G===r.length-1?"end":"middle",style:Qc(W?9:u.labelSize,W?u.faint:u.muted,W?u.body:u.mono),children:Z},`x${G}`)})]})})})}function b0r({treated:e,control:t,domain:n=[0,1],supportLabel:r,positivityOk:a,height:o}){const i=f1e(),[s,l]=d1e(),c=o??150,u=8,d=8,f=16,h=26,g=Math.max(0,l-u-d),v=c-f-h,b=v/2,y=b-4,x=Math.max(e.length,t.length),S=nP({domain:n,range:[0,g]}),z=n[1]-n[0],M=x>0?g/x:g,L=Math.max(1,M*.78),R=Math.max(1e-9,...e,...t),N=i.tone("pos"),O=i.tone("muted"),j=[n[0],(n[0]+n[1])/2,n[1]],B=H=>S(n[0]+(H+.5)/x*z);return p.jsx(V,{ref:s,width:"100%",height:`${c}px`,children:l>0&&p.jsx("svg",{width:l,height:c,style:{display:"block"},children:p.jsxs(x6,{left:u,top:f,children:[p.jsx("text",{x:0,y:-4,style:Qc(9,i.faint,i.body),children:"treated ↑"}),r&&p.jsx("text",{x:g,y:-4,textAnchor:"end",style:Qc(i.labelSize,a?i.tone("pos"):i.tone("warn"),i.mono,600),children:r}),Array.from({length:x},(H,K)=>{const U=Number(e[K]??0)/R*y,Z=Number(t[K]??0)/R*y,G=B(K)-L/2;return p.jsxs(x6,{children:[U>0&&p.jsx("rect",{x:G,y:b-U,width:L,height:U,fill:N,fillOpacity:.85,rx:.5}),Z>0&&p.jsx("rect",{x:G,y:b,width:L,height:Z,fill:O,fillOpacity:.6,rx:.5})]},K)}),p.jsx(_0,{from:{x:0,y:b},to:{x:g,y:b},stroke:i.ruleStrong,strokeWidth:1}),p.jsx("text",{x:0,y:v+4,style:Qc(9,i.faint,i.body),children:"untreated ↓"}),j.map((H,K)=>p.jsx("text",{x:S(H),y:v+16,textAnchor:K===0?"start":K===j.length-1?"end":"middle",style:Qc(i.labelSize,i.muted,i.mono),children:fat(H)},`x${K}`))]})})})}const F0=e=>e?Array.from(e,Number):[],pat=e=>e?Array.from(e,Number):[],Is=e=>{const t=Number.isInteger(e)?String(e):e.toFixed(1);return t==="-0.0"?"0.0":t},Po=e=>{const t=Is(e);return t==="0"||t==="0.0"||t.startsWith("-")?t:`+${t}`},CD=e=>e<0?0:e>1?1:e;function p1e(e){return e>=.66?{level:"large gap",tone:"neg"}:e>=.33?{level:"some",tone:"warn"}:{level:"small",tone:"muted"}}const kD=(e,t)=>e==null?void 0:e.get(t),zD=(e,t)=>{var n;return _((n=kD(e,t))==null?void 0:n.unit)??""},d1=(e,t)=>{var n;return _((n=kD(e,t))==null?void 0:n.label)??t},hat=(e,t)=>{var n;return(n=e.find(r=>r.name===t))==null?void 0:n.kind},gat={causal:"pos",modest:"warn",adjustment_insufficient:"warn",non_identifiable_positivity:"neg",not_estimable:"muted"},x0r={causal:"Causal effect",modest:"Modest / unclear",adjustment_insufficient:"Not trustworthy yet",non_identifiable_positivity:"No fair comparison",not_estimable:"Can’t be estimated"};function w0r(e){return{tag:e.type,tone:gat[e.type],label:x0r[e.type]}}function S0r(e,t){switch(hat(e,t)){case"boolean":return"yes / no";case"integer":return"count";case"float":return"number";case"string":return"category";default:return"value"}}function C0r(e,t,n,r,a,o){const i=zD(r,e.outcome),s=new Map;for(const b of(n==null?void 0:n.balance)??[]){const y=s.get(b.base_column);(!y||Math.abs(b.std_diff)>Math.abs(y.std_diff))&&s.set(b.base_column,b)}const l=e.common_causes.map(b=>{const y=s.get(b),x=y?Math.abs(y.std_diff):0,{level:S,tone:z}=p1e(x),M=y?y.treated_mean<y.control_mean?"lower":"higher":"",L=y?`the treated group ran ${M} on ${d1(r,b)}`:"measured once you Run";return{col:b,reason:L,imbalance:CD(x),level:S,tone:z}}),c=new Set([e.treatment,e.outcome,...e.common_causes]),u=t.find(b=>!c.has(b.name)),d=u?`add ${u.name}`:"",f=_(e.method),h=(f==null?void 0:f.type)==="propensity_score_weighting"?"reweighting":"regression",g=_(e.estimand),v=g&&(g.type==="att"||g.type==="atc")?"treated":"all";return{treatment:e.treatment,treatmentLabel:d1(r,e.treatment),treatmentKind:S0r(t,e.treatment),outcome:e.outcome,outcomeLabel:d1(r,e.outcome),outcomeKind:i?`number · ${i}`:"number",comparison:hat(t,e.treatment)==="boolean"?"yes · vs no":"high · vs low",confounders:l,suggestion:d,method:h,target:v,dataLabel:`${a} ${o.many}`}}function k0r(e,t){return t.has(e.base_column)&&e.treated_mean>=0&&e.treated_mean<=1&&e.control_mean>=0&&e.control_mean<=1?`${Math.round(e.treated_mean*100)}% vs ${Math.round(e.control_mean*100)}%`:`${e.treated_mean.toFixed(1)} vs ${e.control_mean.toFixed(1)}`}function z0r(e,t,n,r){const a=_(n.ci),o=_(t.naive_ci),i=new Set(_(e.categorical)??[]),s=[...t.balance].sort((g,v)=>Math.abs(v.std_diff)-Math.abs(g.std_diff)).map(g=>({col:g.column,label:g.column===g.base_column?d1(r,g.base_column):`${d1(r,g.base_column)}${g.column.startsWith(g.base_column)?g.column.slice(g.base_column.length):` (${g.column})`}`,treated:g.treated_mean,control:g.control_mean,display:k0r(g,i),frac:CD(Math.abs(g.std_diff)),tone:p1e(Math.abs(g.std_diff)).tone})),l=(a==null?void 0:a.lower)??n.effect,c=(a==null?void 0:a.upper)??n.effect,u=t.verdict.type==="causal"||(a?l>0||c<0:!1),d=Math.sign(t.naive)!==Math.sign(n.effect)&&t.naive!==0,f=Number(t.n_dropped),h=Number(t.n_total);return{treatment:d1(r,e.treatment),outcome:d1(r,e.outcome),unit:zD(r,e.outcome),naive:t.naive,naiveLo:(o==null?void 0:o.lower)??t.naive,naiveHi:(o==null?void 0:o.upper)??t.naive,effect:n.effect,lo:l,hi:c,clear:u,flip:d,cautious:t.verdict.type==="adjustment_insufficient",nTotal:t.n_total,nTreated:t.n_treated,nControl:t.n_control,nCompared:BigInt(Math.max(0,h-f)),nDropped:t.n_dropped,balance:s}}function M0r(e,t,n,r,a){if(t===null)return null;const o=t.unit?` ${t.unit}`:"",i=t.effect>0,s=r===void 0?i?"raises":"lowers":i===r?"improves":"worsens",l=` (likely between ${Po(t.lo)} and ${Po(t.hi)})`,c=(n==null?void 0:n.checks.filter(f=>f.passed).length)??0,u=(n==null?void 0:n.checks.length)??0,d=u===0?"":c===u?` It held up against all ${u} ways we tried to break it.`:` It passed ${c} of ${u} stress tests — see “Can we trust it?”.`;switch(e.verdict.type){case"causal":return{tone:"pos",segments:[{text:"Yes — ",strong:!0},{text:`${t.treatment} genuinely ${s} ${t.outcome}: about `},{text:`${Po(t.effect)}${o}`,strong:!0},{text:` per ${a.one}${l}.${d}`}]};case"modest":{const f=new Set(e.verdict_reasons.map(g=>g.type)),h=f.has("not_material")?` — the change (${Po(t.effect)}${o}) is smaller than what would matter here (±${Is(e.materiality_threshold)}${o}).`:f.has("ci_spans_zero")?` — the likely range (${Po(t.lo)} to ${Po(t.hi)}) includes zero.`:f.has("thin_support")?" — too few treated and untreated look-alikes overlap to be confident.":f.has("low_robustness")?" — a fairly weak hidden factor could overturn it.":t.lo<=0&&t.hi>=0?` — the likely range (${Po(t.lo)} to ${Po(t.hi)}) includes zero.`:".";return{tone:"warn",segments:[{text:"Maybe — ",strong:!0},{text:`there may be an effect of ${t.treatment} on ${t.outcome}, but it’s too small or unclear to act on`},{text:h}]}}case"adjustment_insufficient":return{tone:"warn",segments:[{text:"Don’t act on this yet — ",strong:!0},{text:`we got a number (${Po(t.effect)}${o}), but a stress test failed: something we didn’t adjust for may still be driving it.`}]};default:return null}}function T0r(e,t,n,r){const a=Number(t.n_treated),o=Number(t.n_control),i=Number(t.n_total),s=d1(n,e.treatment);if(t.verdict.type==="not_estimable"){const l=t.verdict.value||"The treatment barely varies, so no comparison can be formed.";return{kind:"not_estimable",title:`Can’t estimate the effect of ${s}`,body:l,evidence:[{label:"treated",value:String(a)},{label:"untreated",value:String(o)},{label:r.many,value:String(i)}]}}if(t.verdict.type==="non_identifiable_positivity"){const l=Math.round(t.overlap.common_support_frac*100);return{kind:"positivity",title:"No like-for-like comparison exists",body:`The treated and untreated groups barely overlap on the confounders — only ${l}% sit in a range where both occur — so there is no fair comparison to adjust toward.`,evidence:[{label:"common support",value:`${l}%`},{label:"treated",value:String(a)},{label:"untreated",value:String(o)}]}}return{kind:"not_estimable",title:`Can’t estimate the effect of ${s}`,body:"The engine could not produce a like-for-like estimate for this configuration.",evidence:[{label:"treated",value:String(a)},{label:"untreated",value:String(o)},{label:r.many,value:String(i)}]}}function E0r(e){const t=Math.round(e.common_support_frac*100);return{treated:F0(e.treated_propensity),control:F0(e.control_propensity),commonSupportFrac:e.common_support_frac,positivityOk:e.positivity_ok,supportLabel:`${t}% common support`}}function _0r(e,t){for(let n=1;n<t.length&&n<e.length;n++){const r=t[n-1],a=t[n];if(r>0&&a<=0||r<0&&a>=0){const o=r/(r-a);return e[n-1]+o*(e[n]-e[n-1])}}return null}function L0r(e,t,n){const r=[],a=(t==null?void 0:t.effect)??0,o=_(e.placebo_effect),i=_(e.placebo_passes);if(o!==void 0||i!==void 0){const h=i??(o!==void 0&&Math.abs(o)<Math.max(.5,Math.abs(a)*.15));r.push({name:"Shuffle test",short:"shuffle",desc:"Shuffle which rows were treated; a real effect should collapse to zero.",value:o!==void 0?h?`vanished (${Po(o)})`:`didn’t vanish (${Po(o)})`:h?"vanished":"didn’t vanish",passed:h,tip:P("Randomly re-label which rows were treated. A genuine effect should vanish."),help:"check_shuffle"})}const s=_(e.data_subset_effect);if(s!==void 0){const h=_(e.data_subset_std)??0,g=Math.abs(s-a)<Math.max(.5,Math.abs(a)*.2);r.push({name:"Drop-some test",short:"drop-some",desc:"Re-estimate on random subsamples; a trustworthy effect stays put.",value:g?`stayed at ${Po(s)} ± ${Is(h)}`:`moved to ${Po(s)} ± ${Is(h)}`,passed:g,tip:A,help:"check_dropsome"})}const l=_(e.random_cc_within_ci);l!==void 0&&r.push({name:"Decoy cause",short:"decoy",desc:"Add an irrelevant random factor; the answer should not move.",value:l?"didn’t move":"moved",passed:l,tip:A,help:"check_decoy"});const c=_(e.sensitivity),u=_(e.robustness_value),d=c?[...c.benchmarks].sort((h,g)=>g.strength-h.strength):[];if(c!==void 0||u!==void 0){const h=c?F0(c.strengths):[],g=c?F0(c.effects):[],v=c?_0r(h,g):null,b=d[0],y=v!==null?b!==void 0?v>b.strength?`flips only beyond ${d1(n,b.column)}`:`a cause weaker than ${d1(n,b.column)} could flip it`:`would flip at ${Is(v)}`:u!==void 0?`holds (E-value ${Is(u)})`:"holds throughout",x=b!==void 0?` For scale, your strongest known factor (${d1(n,b.column)}) sits at ${Is(b.strength)} on this axis.`:"";r.push({name:"Hidden cause",short:"hidden cause",desc:`How strong an unrecorded common cause would need to be to overturn the result.${x}`,value:y,passed:v===null,tip:P("Something unrecorded could drive both the treatment choice and the outcome."),help:"check_hidden"})}let f=null;if(c!==void 0){const h=F0(c.effects);if(h.length){const g=_(t==null?void 0:t.ci),v=g?Math.abs(g.upper-g.lower)/2:0,b=h.map(R=>R-v),y=h.map(R=>R+v),x=Math.min(0,...b),S=Math.max(...y,0),z=F0(c.strengths),M=R=>{if(z.length<2)return null;if(R<=z[0])return 0;for(let N=1;N<z.length;N++)if(R<=z[N]){const O=z[N]-z[N-1];return O>0?N-1+(R-z[N-1])/O:N}return z.length-1},L=d.slice(0,2).flatMap(R=>{const N=M(R.strength);return N===null?[]:[{at:N,label:`as strong as ${d1(n,R.column)}`,tone:"muted",help:"sensitivity"}]});f={lo:b,mid:h,hi:y,xTicks:["none","","stronger"],yTicks:[Is(x),Is((x+S)/2),Is(S)],marks:L}}}return{checks:r,sens:f}}function R0r(e,t,n){const r=F0(e.grid),a=F0(e.effect),o=_(e.lower)?F0(_(e.lower)):a.slice(),i=_(e.upper)?F0(_(e.upper)):a.slice(),s=pat(e.size),l=zD(n,e.feature),c=s.length?s.indexOf(Math.max(...s)):0,u=a.map((H,K)=>K===0?0:H-a[K-1]),d=Math.max(1e-9,...u.map(Math.abs));let f=a.length-1;for(let H=1;H<a.length;H++)if(o[H]>0&&Math.abs(u[H])<.25*d){f=H;break}const g=(r.length?[0,Math.floor(r.length/2),r.length-1]:[]).map(H=>Is(r[H])),v=Math.min(0,...o),b=Math.max(...i,0),y=[Is(v),Is((v+b)/2),Is(b)],x=u.slice(1);let S=x.length-1;for(;S>0&&Math.abs(x[S])<.12*d;)S--;const z=x.slice(0,S+1).map((H,K)=>({label:`${Is(r[K+1])}`,value:H,frac:CD(Math.abs(H)/d)})),M=c<f?c:Math.max(0,f-1),L=(a[f]??0)-(a[M]??0),R=f+1<a.length?a[f+1]-a[f]:0,N=`Going from ${Is(r[M]??0)} to ${Is(r[f]??0)} adds ${Po(L)}; the next step adds only ${Po(R)}.`,O=[];s.length&&O.push({at:c,label:"you are here",tone:"muted",help:"dose_here"}),O.push({at:f,label:"sweet spot",tone:"pos",help:"dose_sweet"});const j=d1(n,e.feature),B=d1(n,t.outcome);return{feature:j,outcome:B,lo:o,mid:a,hi:i,xTicks:g,yTicks:y,marks:O,recoLabel:`aim for ${j} ≈ ${Is(r[f]??0)}${l?" "+l:""}`,recoEffect:a[f]??0,recoLo:o[f]??0,recoHi:i[f]??0,tradeoff:N,marginal:z,framing:`A different question from the headline: how ${B} responds as ${j} itself moves.`}}function P0r(e,t){const n=Math.floor((t.getTime()-e.getTime())/864e5);return n<=0?"today":n===1?"yesterday":n<7?e.toLocaleDateString(void 0,{weekday:"short"}):"last wk"}const A0r={causal:"causal",modest:"modest",adjustment_insufficient:"not robust",non_identifiable_positivity:"no overlap",not_estimable:"n/a"};function N0r(e,t,n){const r=_(e.adjusted);return{treatment:d1(n,e.config.treatment),outcome:d1(n,e.config.outcome),confounders:e.config.common_causes.map(a=>d1(n,a)).join(", "),effect:Po(r!==void 0?r:e.naive),verdict:A0r[e.verdict.type],verdictTone:gat[e.verdict.type],who:e.committed_by,when:P0r(e.committed_at,t),preset:e.preset}}function $0r(e,t,n,r,a,o,i,s,l={one:"record",many:"records"}){var c;const u=r?_(r.adjusted):void 0,d=r?_(r.refutation):void 0,f=r?_(r.dose_response):void 0,h=r&&u?z0r(t,r,u,o):null,g=d?L0r(d,u,o):null,v=_((c=kD(o,t.outcome))==null?void 0:c.higherIsBetter);return{spec:C0r(e,n,r,o,i,l),verdict:r?w0r(r.verdict):null,narrative:r?M0r(r,h,g,v,l):null,answer:h,refusal:r&&!u?T0r(t,r,o,l):null,overlap:r?E0r(r.overlap):null,refute:g,dose:f&&f.effect.length?R0r(f,t,o):null,journal:a?a.map(b=>N0r(b,s,o)):null}}const I0r={detect_observed:"Confirm it with a controlled trial",de_bias:"Make it trustworthy with a controlled trial",resolve_vs_null:"Settle it with a bigger trial",restrict_to_overlap:"You can’t compare yet",create_control:"Hold some back next time"};function D0r(e){return{label:e.label,nTotal:Number(e.n_total),nTreated:Number(e.n_treated),nControl:Number(e.n_control),treatedShare:e.treated_share}}function Lve(e,t,n,r){const a=e.basis.type,o=n.outcome,i=zD(r,o),s=e.options.map(D0r),l=s[0]??{label:"Even split",nTotal:0,nTreated:0,nControl:0,treatedShare:.5},c=new Map;for(const S of(t==null?void 0:t.balance)??[]){const z=c.get(S.base_column);(!z||Math.abs(S.std_diff)>Math.abs(z.std_diff))&&c.set(S.base_column,S)}const u=e.match_on.map(S=>{var z;const M=c.get(S),L=M?Math.abs(M.std_diff):0,{tone:R}=p1e(L);return{col:S,frac:CD(L),tone:R,display:_((z=kD(r,S))==null?void 0:z.label)??S}}),d=pat(e.power_curve.n),f=F0(e.power_curve.power),h=Math.min(d.length,f.length),g=S=>{let z=0,M=1/0;for(let L=0;L<h;L++){const R=Math.abs(d[L]-S);R<M&&(M=R,z=L)}return z},v=h?[String(d[0]),String(d[Math.floor((h-1)/2)]),String(d[h-1])]:[],b=[];h&&b.push({at:g(l.nTotal),label:`target ${(e.target_power*100).toFixed(0)}%`,tone:"pos",help:"validate_power"});const y=_(e.current_power);if(y!==void 0&&h){const S=t?Number(t.n_total):0;if(S>0){const z=S>=(d[h-1]??0);b.push({at:z?h-1:g(S),label:z?`you’re here · ${(y*100).toFixed(0)}% (off-scale)`:`you’re here ${(y*100).toFixed(0)}%`,tone:"muted",help:"validate_power"})}}const x=e.outcome_sd>0&&Math.abs(e.target_effect)/e.outcome_sd<=.011;return{headline:I0r[a]??"Validate this",rationale:e.rationale,primary:l,alternates:s.slice(1),matchOn:u,curve:{mid:f.slice(0,h).map(S=>S*100),xTicks:v,marks:b},targetLabel:`${Po(e.target_effect)}${i?` ${i}`:""}`,targetPctLabel:`${(e.target_power*100).toFixed(0)}%`,holdback:a==="create_control",showOverlap:a==="restrict_to_overlap",faint:x}}const O0r={one:"record",many:"records"},j0r=5e4,F0r={neg:"fg.danger",pos:"fg.success",warn:"fg.warning",muted:"fg.muted",brand:"brand.solid"},T_=e=>F0r[e]??"brand.solid";function B0r(e){switch(e.type){case"Boolean":return"boolean";case"Integer":return"integer";case"Float":return"float";case"String":return"string";case"DateTime":return"datetime";default:return"other"}}function V0r(e,t){const n=t?F6(e,t):void 0;return C.useMemo(()=>{const r=n==null?void 0:n.sourceType;if(!r||r.type!=="Array")return{columns:[],rowArrayType:null};const a=r.value;return{columns:(a.type==="Struct"?a.value:[]).map(i=>({name:i.name,kind:B0r(i.type)})),rowArrayType:uc(r)}},[n==null?void 0:n.sourceType])}function H0r(e,t){return t.every(n=>{const{fieldId:r,op:a}=n.value,o=e[r],i=a.value;switch(a.type){case"eq":case"is":return o===i;case"neq":return o!==i;case"lt":return A1(o)!=null&&A1(i)!=null?A1(o)<A1(i):!0;case"lte":return A1(o)!=null&&A1(i)!=null?A1(o)<=A1(i):!0;case"gt":return A1(o)!=null&&A1(i)!=null?A1(o)>A1(i):!0;case"gte":return A1(o)!=null&&A1(i)!=null?A1(o)>=A1(i):!0;case"in":return Ip(i)?i.has(o):!0;case"notIn":return Ip(i)?!i.has(o):!0;default:return!0}})}const A1=e=>typeof e=="number"?e:typeof e=="bigint"?Number(e):null;function Y3({children:e,help:t}){return p.jsxs(p.Fragment,{children:[p.jsx(Ie,{textStyle:"caption.eyebrow",fontSize:"9px",mb:"2.5",children:t?p.jsx(Di,{id:t,children:e}):e}),t&&p.jsx(m0r,{id:t})]})}function V9({children:e,mt:t="3"}){return p.jsx(V,{layerStyle:"card",p:"3.5",borderRadius:"lg",mt:t,children:e})}function MU({error:e}){const t=(e.stderr||e.stdout||"").trim().split(`
|
|
2229
2229
|
`).slice(-12).join(`
|
|
2230
|
-
`);return p.jsxs(V,{layerStyle:"banner.stale",display:"flex",flexDirection:"column",gap:"2",mt:"3",children:[p.jsxs(V,{display:"inline-flex",alignItems:"flex-start",gap:"2",color:"fg.danger",children:[p.jsx(V,{as:"span",mt:"0.5",fontSize:"12px",flexShrink:"0",children:p.jsx(Ur,{icon:rc})}),p.jsxs(Ie,{textStyle:"body.sm",color:"fg.default",children:[p.jsx(Ie,{as:"span",fontWeight:"bold",children:"Could not run the experiment."})," ",e.message]})]}),t&&p.jsx(V,{as:"pre",m:"0",p:"2",maxH:"160px",overflow:"auto",bg:"bg.canvas",borderRadius:"md",borderWidth:"1px",borderColor:"border.subtle",fontFamily:"mono",fontSize:"11px",color:"fg.muted",whiteSpace:"pre-wrap",children:t})]})}function Rve({button:e,variant:t,label:n,onClick:r,disabled:a,pulse:o=!1}){return p.jsx(V,{as:"button",css:e({variant:t,size:"sm"}),onClick:a?void 0:r,"aria-disabled":a||void 0,opacity:a?.5:void 0,cursor:a?"not-allowed":"pointer",animation:o&&!a?"pulse 1.6s infinite":void 0,children:n})}function mat({tab:e}){const t=ga({key:"skeleton"}),n=(a,o)=>p.jsx(V,{css:t({variant:"line"}),width:a,height:o}),r=a=>p.jsx(V,{css:t({variant:"block"}),width:"100%",minHeight:a});return p.jsxs(V,{p:"4.5",display:"flex",flexDirection:"column",gap:"4",children:[e==="answer"&&p.jsxs(p.Fragment,{children:[p.jsxs(V,{display:"flex",gap:"4.5",alignItems:"flex-end",children:[p.jsxs(V,{display:"flex",flexDirection:"column",gap:"2",children:[n("64px","10px"),n("120px","32px")]}),n("170px","24px")]}),r("120px"),r("120px")]}),e==="trust"&&p.jsxs(p.Fragment,{children:[n("70%","14px"),r("160px")]}),e==="dose"&&p.jsxs(p.Fragment,{children:[r("240px"),p.jsxs(V,{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"3",children:[r("90px"),r("90px")]})]}),e==="validate"&&p.jsxs(p.Fragment,{children:[p.jsxs(V,{display:"flex",gap:"5",alignItems:"flex-end",children:[n("120px","32px"),n("200px","10px")]}),r("110px"),r("150px")]})]})}function W0r(){const e=ga({key:"skeleton"}),t=(r,a)=>p.jsx(V,{css:e({variant:"line"}),width:r,height:a}),n=r=>p.jsx(V,{css:e({variant:"block"}),width:"100%",minHeight:r});return p.jsxs(V,{layerStyle:"surface.frameless",overflow:"visible",children:[p.jsxs(V,{layerStyle:"header.bar",display:"flex",alignItems:"center",gap:"3.5",children:[t("260px","20px"),p.jsx(V,{flex:"1"}),t("72px","16px")]}),p.jsxs(V,{display:"grid",gridTemplateColumns:"304px minmax(0,1fr)",css:{"@media (max-width: 640px)":{gridTemplateColumns:"1fr"}},alignItems:"start",children:[p.jsx(V,{borderRightWidth:"1px",borderColor:"border.subtle",p:"4.5",display:"flex",flexDirection:"column",gap:"5",children:[0,1,2,3].map(r=>p.jsxs(V,{display:"flex",flexDirection:"column",gap:"2",children:[t("150px","12px"),n("40px")]},r))}),p.jsx(mat,{tab:"answer"})]})]})}const U0r=it(Sf.Component.schema),q0r=C.memo(function({value:t}){var n,r,a;const o=t,i=ga({key:"button"}),s=ga({key:"chip"}),l=ga({key:"badge"}),c=en({key:"barStrip"})({}),u=en({key:"status"}),d=en({key:"eyebrowRow"})({}),f=m2().getConfig().workspace??"",h=yU(o.data),g=yU(o.journal.type==="some"?o.journal.value:null),v=_(o.columnMeta),b=_(o.subject)??O0r,y=_(o.readonly)??!1,x=yU(o.configs),S=C.useMemo(()=>x.value??[],[x.value]),[z,M]=C.useState(void 0),L=C.useMemo(()=>S.find(st=>st.id===z)??S[0],[S,z]);C.useEffect(()=>{const st=S[0];z===void 0&&st!==void 0&&M(st.id)},[S,z]);const R=C.useMemo(()=>{const st=new Map;for(const dn of S){const Pn=_(dn.group)??"Questions",Hn=st.get(Pn);Hn?Hn.push(dn):st.set(Pn,[dn])}return[...st].map(([dn,Pn])=>({label:dn,items:Pn}))},[S]),{columns:N,rowArrayType:O}=V0r(f,o.data.source),[j,B]=C.useState(void 0),[H,K]=C.useState([]),[U,Z]=C.useState(!1),G=C.useRef(void 0);C.useEffect(()=>{const st=L==null?void 0:L.id;if(st===G.current)return;const dn=G.current!==void 0;G.current=st,B(L==null?void 0:L.spec),K(_(L==null?void 0:L.population)??[]);const Pn=(L==null?void 0:L.result.type)==="some",Hn=o.experiment.type==="some";Z(dn&&Hn&&!Pn)},[L,o.experiment.type]);const W=j,J=H,ae=C.useMemo(()=>h.value?J.length?h.value.filter(st=>H0r(st,J)):h.value:null,[h.value,J]),ne=C.useMemo(()=>N.filter(st=>st.kind!=="other").map(st=>{var dn;return{fieldId:st.name,label:_((dn=v==null?void 0:v.get(st.name))==null?void 0:dn.label)??st.name,kind:st.kind}}),[N,v]),Y=C.useMemo(()=>O?[O,Sf.Types.Config]:null,[O]),te=dve(o.experiment.type==="some"?o.experiment.value.name:null,Y,Sf.Types.Result),ie=o.experiment.type==="some",ue=te.result??_(L==null?void 0:L.result)??null,oe=o.design.type==="some",ve=C.useMemo(()=>O?[O,Sf.Types.Config,Sf.Types.Result,Sf.Types.DesignConfig]:null,[O]),se=dve(o.design.type==="some"?o.design.value.name:null,ve,Sf.Types.Design),pe=C.useRef(null),[de,ge]=C.useState(null),ye=C.useCallback(()=>{!ae||!W||(pe.current=W,te.call(ae,W))},[ae,W,te]),me=C.useRef(!1),Me=L!==void 0&&L.result.type==="some";C.useEffect(()=>{if(!me.current){if(Me||!ie){me.current=!0;return}if(!(!ae||!W||!O)){if(te.result!==null||te.status==="running"){me.current=!0;return}te.status==="idle"&&(me.current=!0,!(ae.length>j0r)&&ye())}}},[Me,ie,ae,W,O,te.result,te.status,ye]),C.useEffect(()=>{te.result!==null&&ge(pe.current)},[te.result]);const Te=C.useCallback(st=>{y||(o.experiment.type==="some"&&Z(!0),B(st))},[y,o.experiment.type]),Be=C.useCallback(st=>{y||(o.experiment.type==="some"&&Z(!0),K(st))},[y,o.experiment.type]),ht=C.useCallback(st=>{M(st.id)},[]),De=C.useCallback(()=>{ye(),Z(!1)},[ye]),Qe=C.useCallback(async()=>{if(!W||!te.result)return;const st=te.result,dn={config:W,verdict:st.verdict,naive:st.naive,adjusted:st.adjusted.type==="some"?P(st.adjusted.value.effect):A,committed_at:new Date,committed_by:"you",preset:z!==void 0?P(z):A};g.mutate([dn,...g.value??[]]);try{await g.commit(),Z(!1)}catch{}},[W,te.result,g,z]),[bt,Ve]=C.useState(((n=_(o.defaultTab))==null?void 0:n.type)??"answer"),[ut,_t]=C.useState(!0),Ft=C.useMemo(()=>new Date,[]),wt=(ae==null?void 0:ae.length)??0,Lt=C.useMemo(()=>{const st=de??W,dn=Pn=>{var Hn;return Pn?_((Hn=v==null?void 0:v.get(Pn))==null?void 0:Hn.label)??Pn:""};return{treatment:dn(st==null?void 0:st.treatment),outcome:dn(st==null?void 0:st.outcome),subject:b.one,subjects:b.many}},[de,W,v,b]),Jt=C.useMemo(()=>W?$0r(W,de??W,N,ue,g.value,v,wt,Ft,b):null,[W,de,N,ue,g.value,v,wt,Ft,b]),Dt=C.useMemo(()=>({alpha:A,target_power:A,materiality:A,treated_shares:P([.5,.3])}),[]),Et=_(L==null?void 0:L.design)??null,Gt=C.useRef(null);C.useEffect(()=>{var st;bt!=="validate"||!oe||se.pending||Et!==null||!ae||!W||!ue||((st=Gt.current)==null?void 0:st.result)!==ue&&(Gt.current={result:ue,config:de??W},se.call(ae,de??W,ue,Dt))},[bt,oe,Et,ae,W,de,ue,se,Dt]);const Ke=C.useMemo(()=>Et!==null&&ue!==null&&W?Lve(Et,ue,de??W,v):se.result&&Gt.current?Lve(se.result,Gt.current.result,Gt.current.config,v):null,[Et,ue,W,de,se.result,v]),Se=Et!==null&&ue!==null||se.result!==null&&((r=Gt.current)==null?void 0:r.result)===ue&&!se.pending;if(!W||!Jt){const st=te.status==="failed",dn=!x.error&&S.length===0,Pn=h.error?"dataset":x.error?"configs":g.error?"journal":null,Hn=h.error??x.error??g.error,pr=Hn instanceof Error?Hn.message:Hn!=null?String(Hn):null;return pr?p.jsx(V,{layerStyle:"surface.frameless",p:"6",children:p.jsxs(Ie,{textStyle:"body.sm",color:"fg.danger",children:["Couldn’t load the experiment ",Pn,": ",pr]})}):dn?p.jsx(V,{layerStyle:"surface.frameless",p:"6",children:p.jsx(Ie,{textStyle:"body.sm",color:"fg.muted",children:"No questions to show — bind a non-empty configs list."})}):st&&te.error?p.jsx(V,{layerStyle:"surface.frameless",p:"6",children:p.jsx(MU,{error:te.error})}):p.jsx(W0r,{})}const{spec:Re,answer:qe,refusal:Ye,overlap:$e,refute:lt,dose:Pe,journal:ot,verdict:kt}=Jt,Mt=_((a=v==null?void 0:v.get(Re.outcome))==null?void 0:a.higherIsBetter),At=u({status:"success",size:"sm"}),fn=st=>p.jsx(V,{css:c.root,children:st.map((dn,Pn)=>p.jsxs(V,{css:c.row,children:[p.jsx(Ie,{css:c.label,textStyle:"mono.sm",color:"fg.default",truncate:!0,children:dn.label}),p.jsx(V,{css:c.track,children:p.jsx(V,{css:c.fill,width:`${Math.round(dn.frac*100)}%`,bg:T_(dn.tone)})}),p.jsx(Ie,{css:c.value,children:dn.value})]},Pn))}),rt=o.journal.type==="some",ln=!y&&ie,Mn=!y&&ie&&rt,Jn=!h.value||te.pending,Er=te.status!=="succeeded"||te.pending||U,_r=te.status==="failed"&&te.error,fr=ue!==null&&!te.pending&&!_r,Vr=S.some(st=>st.design.type==="some"),wr=oe||Vr,ar=["answer","trust",..._(W.dose_feature)!==void 0||(ue==null?void 0:ue.dose_response.type)==="some"?["dose"]:[],...wr?["validate"]:[]],On=ar.includes(bt)?bt:"answer";return p.jsx(h0r,{on:ut,vars:Lt,children:p.jsxs(V,{layerStyle:"surface.frameless",overflow:"visible",children:[p.jsxs(V,{layerStyle:"header.bar",display:"flex",alignItems:"center",gap:"3.5",children:[S.length>1?p.jsxs(fm,{children:[p.jsx(Ore,{asChild:!0,children:p.jsxs(V,{as:"button",bg:"transparent",border:"0",p:"0",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"2",textAlign:"start",children:[p.jsxs(Ie,{textStyle:"title.card",color:"fg.muted",children:["Does ",p.jsx(Ie,{as:"span",color:"brand.solid",fontWeight:"bold",children:Re.treatmentLabel})," change ",p.jsx(Ie,{as:"span",color:"brand.solid",fontWeight:"bold",children:Re.outcomeLabel}),"?"]}),p.jsx(V,{as:"span",color:"fg.subtle",fontSize:"11px",lineHeight:"1",children:p.jsx(Ur,{icon:hS})})]})}),p.jsx(go,{children:p.jsx(pm,{children:p.jsx(hm,{minW:"280px",children:R.map(st=>p.jsxs(jAe,{children:[st.label!=="Questions"&&p.jsx(FAe,{textStyle:"caption.eyebrow",fontSize:"9px",children:st.label}),st.items.map(dn=>p.jsxs(ep,{value:dn.id,onClick:()=>ht(dn),gap:"2",children:[p.jsx(V,{as:"span",width:"14px",flexShrink:"0",color:"brand.fg",children:dn.id===(L==null?void 0:L.id)&&p.jsx(Ur,{icon:o7,style:{fontSize:"10px"}})}),dn.label]},dn.id))]},st.label))})})})]}):p.jsx(Ie,{textStyle:"title.card",color:"fg.muted",children:p.jsxs(Di,{id:"header",children:["Does ",p.jsx(Ie,{as:"span",color:"brand.solid",fontWeight:"bold",children:Re.treatmentLabel})," change ",p.jsx(Ie,{as:"span",color:"brand.solid",fontWeight:"bold",children:Re.outcomeLabel}),"?"]})}),p.jsx(V,{flex:"1"}),y&&p.jsx(V,{as:"span",css:l({variant:"plain",size:"sm"}),textTransform:"none",letterSpacing:"normal",children:"View only"}),p.jsxs(V,{as:"span",css:At.root,children:[p.jsx(V,{as:"span",css:At.indicator}),p.jsx(V,{as:"span",css:At.label,children:U?`${wt} rows`:Re.dataLabel})]}),p.jsx(v0r,{on:ut,onToggle:()=>_t(st=>!st)}),ln&&p.jsx(Rve,{button:i,variant:"solid",label:"Run",onClick:De,disabled:Jn,pulse:U}),Mn&&p.jsx(Rve,{button:i,variant:"ghost",label:"Commit",onClick:Qe,disabled:Er})]}),p.jsxs(V,{display:"grid",gridTemplateColumns:"304px minmax(0,1fr)",css:{"@media (max-width: 640px)":{gridTemplateColumns:"1fr"}},alignItems:"start",children:[p.jsxs(V,{borderRightWidth:"1px",borderColor:"border.subtle",children:[p.jsxs(QT,{n:1,title:"What did you change?",help:"step_treatment",children:[p.jsx(Pve,{column:Re.treatment,kind:Re.treatmentKind,badge:l,button:i,readonly:y,choices:N.filter(st=>st.kind==="boolean"||st.kind==="integer").map(st=>st.name),onPick:st=>Te({...W,treatment:st})}),p.jsxs(Ie,{textStyle:"caption",mt:"1.5",children:["Treated = ",p.jsx(Ie,{as:"span",color:"fg.default",fontWeight:"semibold",children:Re.comparison})]})]}),p.jsx(QT,{n:2,title:"What did you want it to improve?",help:"step_outcome",children:p.jsx(Pve,{column:Re.outcome,kind:Re.outcomeKind,badge:l,button:i,readonly:y,choices:N.filter(st=>st.kind==="float"||st.kind==="integer").map(st=>st.name),onPick:st=>Te({...W,outcome:st})})}),p.jsx(QT,{n:3,title:"What else was different?",help:"step_confounders",children:p.jsxs(V,{layerStyle:"frame.flat",children:[p.jsx(V,{maxH:"216px",overflowY:"auto",children:Re.confounders.map((st,dn)=>p.jsxs(V,{display:"grid",gridTemplateColumns:y?"1fr 78px":"1fr 78px 16px",gap:"2.5",alignItems:"center",px:"2.5",py:"2.5",borderTopWidth:dn?"1px":"0",borderColor:"border.subtle",children:[p.jsxs(V,{children:[p.jsx(Ie,{textStyle:"mono.sm",fontWeight:"semibold",color:"fg.default",children:st.col}),p.jsx(Ie,{textStyle:"caption",lineHeight:"1.35",mt:"px",children:st.reason})]}),p.jsxs(V,{children:[p.jsx(V,{css:c.track,children:p.jsx(V,{css:c.fill,width:`${Math.round(st.imbalance*100)}%`,bg:T_(st.tone)})}),p.jsx(Ie,{textStyle:"caption.eyebrow",fontSize:"9px",textAlign:"center",mt:"1.5",children:p.jsx(Di,{id:"confounder_imbalance",children:st.level})})]}),!y&&p.jsx(V,{as:"button",css:i({variant:"ghost",size:"xs"}),px:"0",minW:"16px",display:"inline-flex",alignItems:"center",justifyContent:"center","aria-label":`Remove ${st.col}`,onClick:()=>Te({...W,common_causes:W.common_causes.filter(Pn=>Pn!==st.col),categorical:W.categorical.type==="some"?P(W.categorical.value.filter(Pn=>Pn!==st.col)):A}),children:p.jsx(Ur,{icon:E9,style:{fontSize:"11px"}})})]},dn))}),!y&&Re.suggestion&&p.jsx(vat,{choices:N.filter(st=>!new Set([W.treatment,W.outcome,...W.common_causes]).has(st.name)).map(st=>st.name),onPick:st=>Te({...W,common_causes:[...W.common_causes,st]}),children:p.jsxs(V,{as:"button",css:i({variant:"ghost",size:"sm"}),justifyContent:"flex-start",width:"100%",color:"brand.fg",fontFamily:"mono",display:"inline-flex",alignItems:"center",gap:"2",children:[p.jsx(Ur,{icon:DI,style:{fontSize:"9px"}}),"add another"]})})]})}),p.jsx(QT,{n:4,title:`Which ${b.many}?`,help:"step_population",children:p.jsx(X0r,{fields:ne,population:J,onChange:Be,chip:s,button:i,readonly:y,subjectMany:b.many})}),p.jsxs(V,{as:"details",borderTopWidth:"1px",borderColor:"border.subtle",children:[p.jsxs(V,{as:"summary",textStyle:"caption.eyebrow",cursor:"pointer",px:"4.5",py:"2.5",display:"flex",alignItems:"center",gap:"1.5",css:{listStyle:"none","&::-webkit-details-marker":{display:"none"}},children:[p.jsx(V,{as:"span",display:"inline-flex",color:"fg.subtle",fontSize:"10px",transition:"transform 180ms ease",transform:"rotate(-90deg)",css:{"details[open] > summary > &":{transform:"rotate(0deg)"}},children:p.jsx(Ur,{icon:hS})}),"Advanced"]}),p.jsxs(V,{px:"4.5",pb:"3.5",pt:"0.5",children:[p.jsx(Ave,{label:"How to compare",help:"adv_method",left:"regression",right:"reweighting",active:Re.method==="reweighting"?"right":"left",readonly:y,onPick:st=>Te({...W,method:P(st==="right"?$("propensity_score_weighting",{weighting_scheme:A}):$("linear_regression",null))})}),p.jsx(Ave,{label:"Answer for",help:"adv_estimand",left:"all",right:"only treated",active:Re.target==="treated"?"right":"left",readonly:y,onPick:st=>Te({...W,estimand:P($(st==="right"?"att":"ate",null))}),last:!0})]})]})]}),p.jsxs(V,{minW:"0",children:[p.jsxs(V,{display:"flex",alignItems:"center",px:"4",borderBottomWidth:"1px",borderColor:"border.subtle",role:"tablist","aria-label":"Result views",onKeyDown:st=>{var dn;const Pn=ar.indexOf(On);let Hn=Pn;if(st.key==="ArrowRight")Hn=(Pn+1)%ar.length;else if(st.key==="ArrowLeft")Hn=(Pn-1+ar.length)%ar.length;else if(st.key==="Home")Hn=0;else if(st.key==="End")Hn=ar.length-1;else return;st.preventDefault(),Ve(ar[Hn]),(dn=st.currentTarget.querySelectorAll('[role="tab"]')[Hn])==null||dn.focus()},children:[ar.map(st=>{const dn=On===st,Pn=st==="answer"?"tab_answer":st==="trust"?"tab_trust":st==="dose"?"tab_dose":"tab_validate",Hn=st==="answer"?"The answer":st==="trust"?"Can we trust it?":st==="dose"?"How much?":"Prove it";return p.jsx(V,{as:"button",role:"tab","aria-selected":dn,tabIndex:dn?0:-1,onClick:()=>Ve(st),cursor:"pointer",fontSize:"xs",fontWeight:"semibold",px:"3.5",py:"3",mb:"-1px",color:dn?"brand.fg":"fg.muted",borderBottomWidth:"2px",borderColor:dn?"brand.solid":"transparent",_hover:{color:dn?"brand.fg":"fg.default"},_focusVisible:{outline:"2px solid",outlineColor:"brand.solid",outlineOffset:"-2px"},children:p.jsx(Di,{id:Pn,children:Hn})},st)}),te.pending&&p.jsxs(V,{ml:"auto",display:"inline-flex",alignItems:"center",gap:"2",color:"fg.muted",pr:"1",children:[p.jsx(CL,{size:"xs",borderWidth:"1.5px",color:"brand.solid"}),p.jsx(Ie,{textStyle:"caption.eyebrow",children:"Running…"})]})]}),_r?p.jsx(V,{px:"4.5",pt:"4.5",children:p.jsx(MU,{error:te.error})}):fr?p.jsxs(p.Fragment,{children:[U&&p.jsxs(V,{layerStyle:"banner.stale",display:"flex",alignItems:"center",gap:"2",mx:"4.5",mt:"4.5",children:[p.jsx(V,{as:"span",color:"fg.warning",flexShrink:"0",fontSize:"12px",children:p.jsx(Ur,{icon:rc})}),p.jsxs(Ie,{textStyle:"body.sm",color:"fg.default",children:[p.jsx(Ie,{as:"span",fontWeight:"bold",children:"Showing the previous setup."})," Hit Run to update these results for your edits."]})]}),On==="answer"&&qe&&p.jsx(G0r,{a:qe,verdict:kt,narrative:Jt.narrative,checks:(lt==null?void 0:lt.checks)??null,onGoTrust:()=>Ve("trust"),subjectMany:b.many,higherBetter:Mt,badge:l,barList:fn}),On==="answer"&&!qe&&Ye&&p.jsx(K0r,{refusal:Ye,overlap:$e,naiveValue:(ue==null?void 0:ue.naive)??0,outcome:Re.outcomeLabel}),On==="trust"&<&&p.jsxs(V,{p:"4.5",children:[p.jsx(Ie,{textStyle:"body.sm",color:"fg.muted",mb:"3.5",children:p.jsx(Di,{id:"trust_intro",children:"Before trusting the answer we tried to break it — colour shows pass / caution."})}),p.jsx(V,{layerStyle:"frame.flat",children:lt.checks.map((st,dn)=>{const Pn=u({status:st.passed?"success":"warning",size:"sm"});return p.jsxs(V,{display:"grid",gridTemplateColumns:"auto 1fr minmax(96px,auto)",gap:"2.5",alignItems:"start",px:"3.5",py:"2.5",borderTopWidth:dn?"1px":"0",borderColor:"border.subtle",children:[p.jsx(V,{as:"span",css:Pn.root,mt:"1",children:p.jsx(V,{as:"span",css:Pn.indicator})}),p.jsxs(V,{children:[p.jsx(Ie,{textStyle:"body.sm",fontWeight:"semibold",color:"fg.default",children:p.jsx(Di,{id:st.help,children:st.name})}),p.jsx(Ie,{textStyle:"caption",lineHeight:"1.45",mt:"0.5",children:st.desc})]}),p.jsxs(V,{display:"inline-flex",alignItems:"center",justifyContent:"flex-end",gap:"1.5",whiteSpace:"nowrap",color:st.passed?"fg.success":"fg.warning",children:[p.jsx(Ie,{textStyle:"mono.sm",fontWeight:"bold",fontVariantNumeric:"tabular-nums",children:st.value}),p.jsx(Ur,{icon:st.passed?o7:rc,style:{fontSize:"11px"}})]})]},dn)})}),lt.sens&&p.jsxs(V9,{children:[p.jsx(Y3,{help:"sensitivity",children:"Effect as a hidden cause is made stronger"}),p.jsx(XZ,{lo:lt.sens.lo,mid:lt.sens.mid,hi:lt.sens.hi,zero:0,tone:"brand",xTicks:lt.sens.xTicks,yTicks:lt.sens.yTicks,marks:lt.sens.marks,height:lt.sens.marks.length?148:132})]})]}),On==="trust"&&!lt&&((ue==null?void 0:ue.adjusted.type)==="some"?p.jsxs(V,{p:"4.5",children:[p.jsxs(V,{display:"inline-flex",alignItems:"center",gap:"2",mb:"2",color:"fg.muted",children:[p.jsx(Ur,{icon:rc,style:{fontSize:"13px"}}),p.jsx(Ie,{textStyle:"body.sm",fontWeight:"semibold",color:"fg.default",children:"Stress tests not run"})]}),p.jsx(Ie,{textStyle:"body.sm",color:"fg.muted",lineHeight:"1.5",children:"This answer came without a robustness summary — the stress tests weren’t run for this question, so there’s nothing to report here."})]}):p.jsxs(V,{p:"4.5",children:[p.jsxs(V,{display:"inline-flex",alignItems:"center",gap:"2",mb:"2",color:"fg.muted",children:[p.jsx(Ur,{icon:rc,style:{fontSize:"13px"}}),p.jsx(Ie,{textStyle:"body.sm",fontWeight:"semibold",color:"fg.default",children:"Nothing to stress-test"})]}),p.jsxs(Ie,{textStyle:"body.sm",color:"fg.muted",lineHeight:"1.5",children:["There’s no adjusted estimate to try to break — the experiment couldn’t produce one (see the ",p.jsx(Ie,{as:"span",fontWeight:"semibold",color:"fg.default",children:"Answer"})," tab for why)."]})]})),On==="dose"&&Pe&&p.jsxs(V,{p:"4.5",children:[p.jsx(Ie,{textStyle:"body.sm",color:"fg.muted",mb:"3.5",children:p.jsx(Di,{id:"tab_dose",children:Pe.framing})}),p.jsxs(V9,{mt:"0",children:[p.jsxs(Y3,{help:"dose_curve",children:[Pe.outcome," gained vs. ",Pe.feature]}),p.jsx(XZ,{lo:Pe.lo,mid:Pe.mid,hi:Pe.hi,tone:"pos",xTicks:Pe.xTicks,yTicks:Pe.yTicks,marks:Pe.marks.map(st=>({at:st.at,label:st.label,tone:st.tone,help:st.help})),height:256})]}),p.jsxs(V,{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"3",mt:"3",children:[p.jsxs(V,{layerStyle:"card",p:"3.5",borderRadius:"lg",children:[p.jsx(Y3,{help:"dose_reco",children:"Recommended"}),p.jsxs(V,{display:"flex",flexDirection:"column",gap:"0.5",children:[p.jsx(Ie,{textStyle:"caption.eyebrow",children:Pe.recoLabel}),p.jsxs(V,{display:"flex",alignItems:"baseline",gap:"2",children:[p.jsx(Ie,{textStyle:"mono-kpi",fontFamily:"heading",color:"brand.solid",children:Po(Pe.recoEffect)}),p.jsxs(Ie,{textStyle:"mono.sm",color:"fg.muted",children:[Pe.outcome," · ",Po(Pe.recoLo)," … ",Po(Pe.recoHi)]})]})]}),p.jsx(Ie,{textStyle:"caption",mt:"2.5",pt:"2.5",borderTopWidth:"1px",borderColor:"border.subtle",children:Pe.tradeoff})]}),p.jsxs(V,{layerStyle:"card",p:"3.5",borderRadius:"lg",children:[p.jsxs(Y3,{help:"dose_marginal",children:["Extra ",Pe.outcome," per step"]}),p.jsx(V,{py:"0.5",maxH:"200px",overflowY:"auto",children:fn(Pe.marginal.map((st,dn)=>({label:st.label,frac:st.frac,tone:dn<2?"brand":"muted",value:Po(st.value)})))})]})]})]}),On==="dose"&&!Pe&&p.jsxs(V,{p:"4.5",children:[p.jsxs(V,{display:"inline-flex",alignItems:"center",gap:"2",mb:"2",color:"fg.muted",children:[p.jsx(Ur,{icon:rc,style:{fontSize:"13px"}}),p.jsx(Ie,{textStyle:"body.sm",fontWeight:"semibold",color:"fg.default",children:"No dose-response to show"})]}),(ue==null?void 0:ue.adjusted.type)==="some"?p.jsx(Ie,{textStyle:"body.sm",color:"fg.muted",lineHeight:"1.5",children:"The experiment didn’t return a how-much curve for this setup."}):p.jsxs(Ie,{textStyle:"body.sm",color:"fg.muted",lineHeight:"1.5",children:["A how-much curve needs a like-for-like estimate, and the experiment couldn’t produce one (see the ",p.jsx(Ie,{as:"span",fontWeight:"semibold",color:"fg.default",children:"Answer"})," tab for why)."]})]}),On==="validate"&&(se.status==="failed"&&se.error?p.jsx(V,{px:"4.5",pt:"4.5",children:p.jsx(MU,{error:se.error})}):Se&&Ke?p.jsx(Y0r,{vm:Ke,barList:fn}):!oe&&Et===null?p.jsxs(V,{p:"4.5",children:[p.jsxs(V,{display:"inline-flex",alignItems:"center",gap:"2",mb:"2",color:"fg.muted",children:[p.jsx(Ur,{icon:rc,style:{fontSize:"13px"}}),p.jsx(Ie,{textStyle:"body.sm",fontWeight:"semibold",color:"fg.default",children:"No trial recipe for this question"})]}),p.jsx(Ie,{textStyle:"body.sm",color:"fg.muted",lineHeight:"1.5",children:"This question doesn’t include a validation-trial recipe, and no design function is bound to size one."})]}):p.jsxs(V,{p:"4.5",display:"inline-flex",alignItems:"center",gap:"2",color:"fg.muted",children:[p.jsx(CL,{size:"xs",borderWidth:"1.5px",color:"brand.solid"}),p.jsx(Ie,{textStyle:"body.sm",children:"Sizing the trial that would confirm this…"})]}))]}):p.jsx(mat,{tab:On})]})]}),ot&&ot.length>0&&p.jsxs(p.Fragment,{children:[p.jsxs(V,{css:d.root,bg:"bg.canvas",borderTopWidth:"1px",borderColor:"border.subtle",children:[p.jsx(V,{css:d.lbl,children:p.jsx(Di,{id:"journal",children:"Committed experiments"})}),p.jsx(V,{css:d.meta,children:p.jsxs(Ie,{as:"span",children:[p.jsx(Ie,{as:"span",color:"fg.default",fontWeight:"semibold",children:ot.length})," on record",ot.length>50?" · showing newest 50":""]})})]}),ot.slice(0,50).map((st,dn)=>p.jsxs(V,{display:"grid",gridTemplateColumns:"2fr 1fr 1fr 1fr",gap:"3",alignItems:"center",px:"4.5",py:"2.5",borderTopWidth:"1px",borderColor:"border.subtle",children:[p.jsxs(Ie,{textStyle:"body.sm",children:[p.jsxs(Ie,{as:"span",fontWeight:"bold",children:[st.treatment," → ",st.outcome]})," ",p.jsxs(Ie,{as:"span",color:"fg.muted",children:["· vs ",st.confounders]}),(()=>{var Pn;const Hn=_(st.preset);if(Hn===void 0)return null;const pr=((Pn=S.find(Hr=>Hr.id===Hn))==null?void 0:Pn.label)??Hn;return p.jsxs(p.Fragment,{children:[" ",p.jsxs(V,{as:"span",css:s({tone:"brand",size:"sm"}),children:["from ",pr]})]})})()]}),p.jsx(Ie,{textStyle:"mono.sm",fontWeight:"semibold",textAlign:"right",fontVariantNumeric:"tabular-nums",color:st.verdictTone==="pos"?"fg.success":"fg.default",children:st.effect}),p.jsx(Ie,{textStyle:"caption.eyebrow",textAlign:"right",color:T_(st.verdictTone),children:st.verdict}),p.jsxs(Ie,{textStyle:"mono.sm",textAlign:"right",color:"fg.muted",children:[st.who," · ",st.when]})]},dn))]})]})})},(e,t)=>U0r(e.value,t.value)&&e.storageKey===t.storageKey);function G0r({a:e,verdict:t,narrative:n,checks:r,onGoTrust:a,subjectMany:o,higherBetter:i,badge:s,barList:l}){const c=e.effect>0,u=i===void 0?c?"Higher":"Lower":c===i?"Better":"Worse",d=e.naive<0?"lower":"higher",f=e.balance[0]??{label:"",display:""},h=e.clear&&!e.cautious?"fg.success":"fg.warning",g=e.clear&&!e.cautious,v=e.cautious?(t==null?void 0:t.label)??"Not trustworthy yet":e.clear?`${u} with ${e.treatment}`:"No clear effect";return p.jsxs(V,{p:"4.5",children:[n&&p.jsx(Ie,{textStyle:"body.md",color:"fg.default",lineHeight:"1.6",mb:"3.5",children:n.segments.map((b,y)=>b.strong?p.jsx(Ie,{as:"span",fontWeight:"bold",color:T_(n.tone),children:b.text},y):p.jsx(Ie,{as:"span",children:b.text},y))}),p.jsxs(V,{display:"flex",alignItems:"center",gap:"4.5",flexWrap:"wrap",children:[p.jsxs(V,{display:"flex",flexDirection:"column",gap:"0.5",children:[p.jsx(Ie,{textStyle:"mono.sm",color:"fg.muted",children:e.outcome}),p.jsxs(V,{display:"flex",alignItems:"baseline",gap:"2.5",children:[p.jsx(Ie,{textStyle:"mono-kpi",fontFamily:"heading",fontSize:"32px",color:h,children:p.jsxs(Di,{id:"answer_effect",children:[Po(e.effect),e.unit?p.jsxs(Ie,{as:"span",fontSize:"16px",color:"fg.muted",children:[" ",e.unit]}):null]})}),p.jsx(Ie,{textStyle:"mono.sm",color:"fg.muted",children:p.jsxs(Di,{id:"answer_ci",children:["likely between ",Po(e.lo)," and ",Po(e.hi)]})})]})]}),p.jsxs(V,{as:"span",css:s({variant:g?"ok":"warn",size:"md"}),alignSelf:"flex-end",mb:"1",display:"inline-flex",alignItems:"center",gap:"1",children:[e.clear&&!e.cautious&&p.jsx(Ur,{icon:c?tKn:bJe,style:{fontSize:"10px"}}),p.jsx(Di,{id:`verdict_${(t==null?void 0:t.tag)??"modest"}`,children:v})]})]}),r&&r.length>0&&p.jsxs(V,{as:"button",onClick:a,display:"inline-flex",alignItems:"center",gap:"2",flexWrap:"wrap",mt:"2.5",bg:"transparent",border:"0",p:"0",cursor:"pointer",title:"See the full stress-test checklist",children:[p.jsx(Ie,{textStyle:"caption",color:"fg.muted",children:"Stress tests:"}),r.map((b,y)=>p.jsxs(V,{as:"span",display:"inline-flex",alignItems:"center",gap:"1.5",color:b.passed?"fg.success":"fg.warning",children:[p.jsx(Ur,{icon:b.passed?o7:rc,style:{fontSize:"10px"}}),p.jsx(Ie,{as:"span",textStyle:"caption",color:"fg.default",children:b.short}),y<r.length-1&&p.jsx(Ie,{as:"span",textStyle:"caption",color:"fg.subtle",children:"·"})]},y))]}),e.cautious&&p.jsxs(V,{layerStyle:"banner.stale",display:"flex",alignItems:"flex-start",gap:"2",mt:"3",children:[p.jsx(V,{as:"span",color:"fg.warning",flexShrink:"0",mt:"0.5",fontSize:"12px",children:p.jsx(Ur,{icon:rc})}),p.jsxs(Ie,{textStyle:"body.sm",color:"fg.default",children:[p.jsx(Di,{id:"answer_cautious",children:p.jsx(Ie,{as:"span",fontWeight:"bold",children:"Treat this as provisional."})})," We adjusted and got a number, but a robustness check failed — the estimate may still be driven by something we didn’t adjust for. See ",p.jsx(Ie,{as:"span",fontWeight:"semibold",children:"Can we trust it?"})]})]}),e.flip&&p.jsxs(V,{layerStyle:"banner.stale",display:"flex",alignItems:"flex-start",gap:"2",mt:"3",children:[p.jsx(V,{as:"span",color:"fg.warning",flexShrink:"0",mt:"0.5",fontSize:"12px",children:p.jsx(Ur,{icon:rc})}),p.jsxs(Ie,{textStyle:"body.sm",color:"fg.default",children:[p.jsx(Di,{id:"answer_flip",children:p.jsx(Ie,{as:"span",fontWeight:"bold",children:"Raw and like-for-like disagree."})})," In the plain average, the ",p.jsx(Ie,{as:"span",fontWeight:"semibold",children:e.treatment})," group sits ",p.jsx(Ie,{as:"span",fontStyle:"italic",children:d})," on ",p.jsx(Ie,{as:"span",fontWeight:"semibold",children:e.outcome})," (",Po(e.naive),") — but they also differ most on ",p.jsx(Ie,{as:"span",fontWeight:"semibold",children:f.label})," (",f.display,"). Adjusting for it reverses the result."]})]}),p.jsxs(V9,{children:[p.jsx(Y3,{help:"forest_plot",children:"Raw average vs. like-for-like"}),p.jsx(y0r,{rows:[{label:"Raw average",note:"unadjusted",est:e.naive,lo:e.naiveLo,hi:e.naiveHi,tone:e.naive<0?"neg":"pos"},{label:"Like-for-like",note:"adjusted",est:e.effect,lo:e.lo,hi:e.hi,tone:e.clear&&!e.cautious?"pos":"warn"}],min:Math.floor(Math.min(0,e.naiveLo,e.lo)-2),max:Math.ceil(Math.max(0,e.naiveHi,e.hi)+2),unit:`change in ${e.outcome}${e.unit?` (${e.unit})`:""}`,height:150,rowHelp:["forest_naive","forest_adjusted"]})]}),p.jsxs(V,{as:"details",layerStyle:"card",borderRadius:"lg",mt:"3",children:[p.jsxs(V,{as:"summary",textStyle:"caption.eyebrow",fontSize:"9px",cursor:"pointer",p:"3.5",display:"flex",alignItems:"center",gap:"1.5",css:{listStyle:"none","&::-webkit-details-marker":{display:"none"}},children:[p.jsx(V,{as:"span",display:"inline-flex",color:"fg.subtle",fontSize:"10px",transition:"transform 180ms ease",transform:"rotate(-90deg)",css:{"details[open] > summary > &":{transform:"rotate(0deg)"}},children:p.jsx(Ur,{icon:hS})}),p.jsx(Di,{id:"balance",children:"How we levelled the playing field"})]}),p.jsx(V,{px:"3.5",pb:"3.5",py:"0.5",maxH:"208px",overflowY:"auto",children:l(e.balance.map(b=>({label:b.label,frac:b.frac,tone:b.tone,value:b.display})))})]}),p.jsx(V,{mt:"3.5",children:p.jsx(Di,{id:"counts",display:"inline-flex",gap:"4",children:[[e.nTotal,o],[e.nCompared,"compared like-for-like"],[e.nDropped,"had no fair match"]].map(([b,y],x)=>p.jsxs(Ie,{textStyle:"mono.sm",color:"fg.muted",children:[p.jsx(Ie,{as:"span",color:"fg.default",fontWeight:"semibold",children:Number(b)})," ",y]},x))})})]})}function K0r({refusal:e,overlap:t,naiveValue:n,outcome:r}){return p.jsxs(V,{p:"4.5",children:[p.jsxs(V,{display:"inline-flex",alignItems:"center",gap:"2",mb:"2",color:"fg.warning",children:[p.jsx(Ur,{icon:rc,style:{fontSize:"14px"}}),p.jsx(Ie,{textStyle:"title.card",color:"fg.default",children:p.jsx(Di,{id:e.kind==="positivity"?"refusal_positivity":"refusal_not_estimable",children:e.title})})]}),p.jsx(Ie,{textStyle:"body.sm",color:"fg.muted",mb:"3",lineHeight:"1.5",children:e.body}),e.kind==="positivity"&&t&&p.jsxs(V9,{mt:"1",children:[p.jsxs(Y3,{help:"overlap_histogram",children:["Propensity overlap — ",t.supportLabel]}),p.jsx(b0r,{treated:t.treated,control:t.control,supportLabel:t.supportLabel,positivityOk:t.positivityOk,height:170})]}),p.jsx(V,{display:"flex",gap:"4",mt:"3.5",children:e.evidence.map((a,o)=>p.jsxs(Ie,{textStyle:"mono.sm",color:"fg.muted",children:[p.jsx(Ie,{as:"span",color:"fg.default",fontWeight:"semibold",children:a.value})," ",a.label]},o))}),p.jsxs(Ie,{textStyle:"caption",color:"fg.subtle",mt:"3.5",pt:"3",borderTopWidth:"1px",borderColor:"border.subtle",children:["Raw average difference in ",r," (context only, not an answer): ",p.jsx(Ie,{as:"span",fontFamily:"mono",color:"fg.muted",children:Po(n)})]})]})}function Y0r({vm:e,barList:t}){const n=en({key:"stat"})({size:"lg"}),r=en({key:"segmentedMeter"})({});return p.jsxs(V,{p:"4.5",children:[p.jsx(Y3,{help:"tab_validate",children:e.headline}),p.jsxs(V,{display:"flex",alignItems:"flex-end",gap:"5",flexWrap:"wrap",children:[p.jsxs(V,{css:n.root,children:[p.jsx(Ie,{css:n.label,children:p.jsx(Di,{id:"validate_size",children:e.holdback?"to hold back from":"to run"})}),e.faint?p.jsx(Ie,{textStyle:"body.sm",fontWeight:"semibold",color:"fg.warning",maxW:"220px",children:"Effect too faint to size — set a materiality threshold to size a trial."}):p.jsx(Ie,{css:n.valueText,color:"brand.solid",children:e.primary.nTotal.toLocaleString()})]}),p.jsxs(V,{css:r.root,flex:"1",minW:"220px",children:[p.jsx(Ie,{css:r.label,children:p.jsx(Di,{id:"validate_split",children:e.holdback?"Hold-back split":"Split"})}),p.jsxs(V,{css:r.track,children:[p.jsx(V,{css:r.segment,flex:e.primary.treatedShare,bg:"brand.solid"}),p.jsx(V,{css:r.segment,flex:1-e.primary.treatedShare,bg:"bg.emphasized"})]}),p.jsxs(V,{css:r.keyRow,justifyContent:"space-between",children:[p.jsxs(V,{css:r.keyItem,children:[p.jsx(V,{css:r.keyDot,bg:"brand.solid"}),p.jsxs("span",{children:[p.jsx(Ie,{as:"span",css:r.valueText,children:e.primary.nTreated.toLocaleString()})," ",e.holdback?"treated":"get it"]})]}),p.jsxs(V,{css:r.keyItem,children:[p.jsx(V,{css:r.keyDot,bg:"bg.emphasized"}),p.jsxs("span",{children:[p.jsx(Ie,{as:"span",css:r.valueText,children:e.primary.nControl.toLocaleString()})," ",e.holdback?"held back":"left alone"]})]})]})]})]}),e.matchOn.length>0&&p.jsxs(V9,{children:[p.jsx(Y3,{help:"validate_match",children:"Match both groups on"}),p.jsx(V,{py:"0.5",children:t(e.matchOn.map(a=>({label:a.display,frac:a.frac,tone:a.tone,value:""})))})]}),e.curve.mid.length>0&&p.jsxs(V9,{children:[p.jsx(Y3,{help:"validate_power",children:"Chance of detecting it"}),p.jsx(XZ,{lo:e.curve.mid,mid:e.curve.mid,hi:e.curve.mid,tone:"brand",xTicks:e.curve.xTicks,yTicks:["100","50","0"],yFormat:"percent",marks:e.curve.marks.map(a=>({at:a.at,label:a.label,tone:a.tone,help:a.help})),height:170})]}),p.jsx(Ie,{textStyle:"body.sm",color:"fg.default",lineHeight:"1.5",mt:"3.5",children:e.rationale}),e.alternates.length>0&&p.jsx(V,{display:"flex",flexDirection:"column",gap:"1.5",mt:"3",pt:"3",borderTopWidth:"1px",borderColor:"border.subtle",children:e.alternates.map((a,o)=>p.jsxs(Ie,{textStyle:"caption",color:"fg.muted",children:[p.jsx(Ie,{as:"span",fontWeight:"semibold",color:"fg.default",children:a.label})," · ",a.nTotal.toLocaleString()," total (",a.nTreated.toLocaleString()," / ",a.nControl.toLocaleString(),")"]},o))})]})}function X0r({fields:e,population:t,onChange:n,chip:r,button:a,readonly:o,subjectMany:i}){const[s,l]=C.useState(null),c=(f,h)=>n(t.map((g,v)=>v===f?h:g)),u=f=>n(t.filter((h,g)=>g!==f)),d=p.jsx(V,{as:"button",css:a({variant:"outline",size:"xs"}),onClick:()=>l(null),children:"Done"});return o?p.jsx(V,{display:"flex",flexWrap:"wrap",gap:"1.5",alignItems:"center",children:t.length===0?p.jsxs(V,{css:r({tone:"plain",numeric:!0,shape:"rounded"}),children:["all ",i]}):t.map((f,h)=>p.jsx(V,{css:r({tone:"brand",numeric:!0,shape:"rounded"}),flexShrink:0,children:p.jsx(V,{as:"span",whiteSpace:"nowrap",children:Zw(f)})},h))}):p.jsxs(V,{display:"flex",flexWrap:"wrap",gap:"1.5",alignItems:"center",children:[t.map((f,h)=>p.jsx(t4,{open:s===h,onOpenChange:g=>l(g?h:null),label:p.jsxs(p.Fragment,{children:["Edit · ",p.jsx(V,{as:"span",fontFamily:"mono",color:"brand.fg",children:f.value.fieldId})]}),footActions:d,trigger:p.jsxs(V,{css:r({tone:"brand",numeric:!0,shape:"rounded"}),cursor:"pointer",flexShrink:0,children:[p.jsx(V,{as:"span",whiteSpace:"nowrap",children:Zw(f)}),p.jsx(V,{as:"button",display:"inline-flex",alignItems:"center",cursor:"pointer",color:"brand.fg",flexShrink:"0",fontSize:"10px",onClick:g=>{g.stopPropagation(),u(h)},"aria-label":"Remove filter",children:p.jsx(Ur,{icon:E9})})]}),children:s===h?p.jsx(tS,{fields:e,initial:f,lockField:!0,submitLabel:"Apply",onAdd:g=>{c(h,g),l(null)}}):null},h)),p.jsx(t4,{open:s==="add",onOpenChange:f=>l(f?"add":null),label:"Add filter",size:"lg",footActions:d,trigger:p.jsxs(V,{css:r({tone:"dashed",numeric:!0,shape:"rounded"}),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"1.5",children:[p.jsx(V,{as:"span",fontSize:"9px",children:p.jsx(Ur,{icon:DI})}),p.jsx(V,{as:"span",children:"filter"})]}),children:s==="add"?p.jsx(tS,{fields:e,onAdd:f=>{n([...t,f]),l(null)}}):null})]})}function QT({n:e,title:t,help:n,children:r}){return p.jsxs(V,{px:"4.5",py:"3",borderBottomWidth:"1px",borderColor:"border.subtle",children:[p.jsxs(V,{display:"flex",alignItems:"baseline",gap:"2.5",mb:"2",children:[p.jsx(V,{as:"span",fontFamily:"mono",fontSize:"11px",fontWeight:"bold",color:"brand.fg",flex:"0 0 auto",lineHeight:"1",children:e}),p.jsx(Ie,{textStyle:"title.row",children:n?p.jsx(Di,{id:n,children:t}):t})]}),r]})}function vat({choices:e,onPick:t,children:n}){return p.jsxs(fm,{children:[p.jsx(Ore,{asChild:!0,children:n}),p.jsx(go,{children:p.jsx(pm,{children:p.jsx(hm,{children:e.map(r=>p.jsx(ep,{value:r,onClick:()=>t(r),children:r},r))})})})]})}function Pve({column:e,kind:t,choices:n,onPick:r,badge:a,button:o,readonly:i}){return i?p.jsxs(V,{css:o({variant:"outline",size:"sm"}),gap:"1.5",cursor:"default",children:[p.jsx(Ie,{as:"span",fontFamily:"mono",fontWeight:"semibold",children:e}),p.jsx(V,{as:"span",css:a({variant:"plain",size:"sm"}),textTransform:"none",letterSpacing:"normal",children:t})]}):p.jsx(vat,{choices:n,onPick:r,children:p.jsxs(V,{as:"button",css:o({variant:"outline",size:"sm"}),gap:"1.5",children:[p.jsx(Ie,{as:"span",fontFamily:"mono",fontWeight:"semibold",children:e}),p.jsx(V,{as:"span",css:a({variant:"plain",size:"sm"}),textTransform:"none",letterSpacing:"normal",children:t}),p.jsx(V,{as:"span",display:"inline-flex",color:"fg.muted",fontSize:"10px",children:p.jsx(Ur,{icon:hS})})]})})}function Z0r({options:e,active:t,onPick:n,fill:r,size:a="xs"}){const o=en({key:"segmentGroup"})({size:a});return p.jsx(V,{css:o.root,...r?{width:"100%"}:{},role:"radiogroup",onKeyDown:i=>{var s;const l=i.key==="ArrowRight"||i.key==="ArrowDown"?1:i.key==="ArrowLeft"||i.key==="ArrowUp"?-1:0;if(!l)return;i.preventDefault();const c=(t+l+e.length)%e.length;n(c),(s=i.currentTarget.querySelectorAll('[role="radio"]')[c])==null||s.focus()},children:e.map((i,s)=>p.jsx(V,{as:"button",role:"radio","aria-checked":t===s,tabIndex:t===s?0:-1,css:o.item,...r?{flex:"1"}:{},...t===s?{"data-state":"checked"}:{},onClick:()=>n(s),children:p.jsx(V,{as:"span",css:o.itemText,children:i})},s))})}function Q0r({value:e,size:t="xs"}){const n=en({key:"segmentGroup"})({size:t});return p.jsx(V,{css:n.root,alignSelf:"flex-start",children:p.jsx(V,{css:n.item,"data-state":"checked",children:p.jsx(V,{as:"span",css:n.itemText,children:e})})})}function Ave({label:e,left:t,right:n,active:r,onPick:a,last:o,help:i,readonly:s}){return p.jsxs(V,{display:"flex",flexDirection:"column",alignItems:"stretch",gap:"1.5",py:"2",borderBottomWidth:o?"0":"1px",borderColor:"border.subtle",children:[p.jsx(Ie,{textStyle:"caption.eyebrow",textTransform:"none",letterSpacing:"normal",color:"fg.default",children:i?p.jsx(Di,{id:i,children:e}):e}),s?p.jsx(Q0r,{value:r==="left"?t:n}):p.jsx(Z0r,{options:[t,n],active:r==="left"?0:1,onPick:l=>a(l===0?"left":"right"),fill:!0,size:"xs"})]})}pk(Sf.Component,q0r);const yat=k(T),J0r=Ei(yat),eur=Ra(yat);function bat(e){return["decision.selection",...e.map(t=>Jc(t.source))].join("|")}function jk(e){const t=m2().getConfig().workspace??"",n=e.source,r=F6(t,n);if(!r)throw new Error(`Decision.bind: no binding registered for ${Jc(n)} — bind it with Data.bind on the same surface first`);const a=e.patch.type==="some"?e.patch.value:void 0;return g1.buildBindHandle(r.sourceType,n,a,e.mode.type)}function tur(e){return JSON.stringify(e,(t,n)=>typeof n=="bigint"?`${n}n`:n instanceof Date?n.toISOString():Ip(n)?[...n].sort():dit(n)?[...n.entries()].sort((r,a)=>String(r[0]).localeCompare(String(a[0]))):n)}function nur(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)|0;return(t>>>0).toString(36)}function Nve(e){rL.trackKey(e);const t=rL.getStore().read(e);return t===void 0?A:eur(t)}function TU(e,t){return rL.getStore().write(e,J0r(t)),null}function EU(e){return e.flatMap(t=>jk(t).read())}function h1e(e){return jk(e).read()}function zx(e,t){return h1e(e).get(t)??{caseId:t,answers:new Map,knowledge:A,constraints:[],verdict:A,resolvedAt:A}}function JT(e,t,n){const r=new Map(h1e(e));return r.set(t,{...zx(e,t),...n}),jk(e).write(r),null}function rur(e,t){for(const n of e){const r=jk(n),a=r.read();a.some(o=>o.id===t)&&r.write(a.filter(o=>o.id!==t))}}const $ve=new Map;function aur(e){const t=new WeakSet;return JSON.stringify(e,(n,r)=>{if(typeof r=="object"&&r!==null){if(t.has(r))return"<cyc>";t.add(r)}return typeof r=="bigint"?`${r}n`:r})}function our(e,t,n,r){const a=lv(),o=uc(e),i=F.value(t,ce(ti)),s=F.value(n,ti),l=F.value(r,T),{queue:c,selected:u,select:d,clearSelection:f,decision:h,update:g,judgement:v,answer:b,addKnowledge:y,inject:x,resolve:S,commitState:z}=Dc;return{queue:F.compile(F.function([],ce(H1),M=>{M.return(c(i))}),a),selected:F.compile(F.function([],k(T),M=>{M.return(u(l))}),a),select:F.compile(F.function([T],D,(M,L)=>{M.return(d(l,L))}),a),clearSelection:F.compile(F.function([],D,M=>{M.return(f(l))}),a),decision:F.compile(F.function([],k(H1),M=>{M.return(h(i,l))}),a),update:F.compile(F.function([H1],D,(M,L)=>{M.return(g(i,L))}),a),judgement:F.compile(F.function([T],fC(o),(M,L)=>{M.return(v([o],s,L))}),a),answer:F.compile(F.function([T,T,pN],D,(M,L,R,N)=>{M.return(b(s,L,R,N))}),a),addKnowledge:F.compile(F.function([T,T],D,(M,L,R)=>{M.return(y(s,L,R))}),a),inject:F.compile(F.function([T,o],D,(M,L,R)=>{M.return(x([o],s,L,R))}),a),resolve:F.compile(F.function([T,hN],D,(M,L,R)=>{M.return(S(i,s,l,L,R))}),a),commitState:F.compile(F.function([T],jte,(M,L)=>{M.return(z(i,s,L))}),a)}}function xat(e,t,n){const r=n??Zt(Ote),a=bat(e),o=()=>{const l=[...h1e(t).values()].filter(u=>u.verdict.type==="some"),c=u=>u.resolvedAt.type==="some"?u.resolvedAt.value.getTime():0;return l.sort((u,d)=>c(d)-c(u))},i=`${nur(tur({decisions:e,judgements:t}))}|${aur(r)}`;let s=$ve.get(i);return s===void 0&&(s=our(r,e,t,a),$ve.set(i,s)),{decisions:e,judgements:t,journal:o,...s}}const g1e=[N7t.implement(e=>(t,n)=>xat(t,n,e)),Dc.queue.implement(e=>EU(e)),Dc.selected.implement(e=>Nve(e)),Dc.select.implement((e,t)=>TU(e,P(t))),Dc.clearSelection.implement(e=>TU(e,A)),Dc.decision.implement((e,t)=>{const n=Nve(t);if(n.type==="none")return A;const r=EU(e).find(a=>a.id===n.value);return r===void 0?A:P(r)}),Dc.update.implement((e,t)=>{const n=t;for(const r of e){const a=jk(r),o=a.read();o.some(i=>i.id===n.id)&&a.write(o.map(i=>i.id===n.id?n:i))}return null}),Dc.judgement.implement(e=>(t,n)=>zx(t,n)),Dc.answer.implement((e,t,n,r)=>{const a=new Map(zx(e,t).answers);return a.set(n,r),JT(e,t,{answers:a})}),Dc.addKnowledge.implement((e,t,n)=>JT(e,t,{knowledge:P(n)})),Dc.inject.implement(e=>(t,n,r)=>{const a=r,o=zx(t,n).constraints.filter(i=>i.type!==a.type).concat([a]);return JT(t,n,{constraints:o})}),Dc.resolve.implement((e,t,n,r,a)=>(JT(t,r,{verdict:P(a),resolvedAt:P(new Date)}),rur(e,r),TU(n,A),null)),Dc.commitState.implement((e,t,n)=>{const r=n,a=EU(e).find(c=>c.id===r),o=(a==null?void 0:a.prompts)??[],i=zx(t,r).answers,s=o.map(c=>{var u;return(u=i.get(c.id))==null?void 0:u.type});if(s.some(c=>c==="no"))return $("blocked",null);if(s.some(c=>c==="unknown"))return $("handoff",null);const l=s.filter(c=>c===void 0).length;return l>0?$("gated",BigInt(l)):$("ready",null)})];s0(g1e);function iur(e){const t=x5(),n=m2(),r=rL.getStore(),a=n.getConfig().workspace??"",o=C.useMemo(()=>{if(!e)return[];const c=[...e.decisions,e.judgements],u=[];for(const d of c)u.push(Zo(a,d.source)),d.patch.type==="some"&&u.push(Zo(a,d.patch.value));return u},[a,e]),i=e?bat(e.decisions):void 0,s=C.useCallback(c=>{const u=o.flatMap(d=>[t.subscribe(d,c),n.subscribe(d,c)]);return i!==void 0&&u.push(r.subscribe(i,c)),()=>{for(const d of u)d()}},[t,n,r,o,i]),l=C.useCallback(()=>o.reduce((c,u)=>c+t.getKeyVersion(u)+n.getKeyVersion(u),0)+(i!==void 0?r.getKeyVersion(i):0),[t,n,r,o,i]);return C.useSyncExternalStore(s,l)}function wat(e){const t=iur(e),n=C.useMemo(()=>e?xat([...e.decisions],e.judgements):null,[e]),{decisions:r,selected:a,journal:o}=C.useMemo(()=>{try{if(!n)return{decisions:null,selected:null,journal:null};const v=n.selected();return{decisions:n.queue(),selected:v.type==="some"?v.value:null,journal:n.journal()}}catch{return{decisions:null,selected:null,journal:null}}},[n,t]),i=C.useCallback(v=>{try{return n?n.judgement(v):null}catch{return null}},[n,t]),s=C.useCallback(v=>{try{return n?n.commitState(v):null}catch{return null}},[n,t]),l=C.useCallback(v=>{n==null||n.select(v)},[n]),c=C.useCallback(()=>{n==null||n.clearSelection()},[n]),u=C.useCallback(v=>{n==null||n.update(v)},[n]),d=C.useCallback((v,b,y)=>{n==null||n.answer(v,b,$(y,null))},[n]),f=C.useCallback((v,b)=>{n==null||n.addKnowledge(v,b)},[n]),h=C.useCallback((v,b)=>{n==null||n.inject(v,b)},[n]),g=C.useCallback((v,b)=>{n==null||n.resolve(v,b)},[n]);return{decisions:r,selected:a,journal:o,judgementFor:i,commitStateFor:s,select:l,clearSelection:c,update:u,answer:d,addKnowledge:f,inject:h,resolve:g}}const Sat={eq:"=",neq:"≠",atMost:"at most",atLeast:"at least",between:"between",before:"before",after:"after",in:"in",notIn:"not in",is:"is"};function om(e){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:Ip(e)?`{${[...e].map(om).join(", ")}}`:e!==null&&typeof e=="object"&&!e.type?Object.entries(e).map(([t,n])=>`${t} ${om(n)}`).join(" · "):String(e)}function Cat(e,t,n){var r,a;const o=e,i=((r=n==null?void 0:n.find(s=>s.case===o.type))==null?void 0:r.label)??o.type;if((t==null?void 0:t.type)==="Variant"){const s=o.value,l=Sat[s.type]??s.type,c=(a=t.cases)==null?void 0:a[s.type];if((c==null?void 0:c.type)==="Struct"&&s.value!==null&&typeof s.value=="object"){const u=s.value;if("min"in u&&"max"in u)return{lever:i,op:l,value:`${om(u.min)} – ${om(u.max)}`}}return{lever:i,op:l,value:om(s.value)}}return{lever:i,op:"·",value:om(o.value)}}const eE=new Set(["String","Integer","Float","DateTime","Boolean"]);function I2(e){var t;const n=e;if(n.cases!==void 0||n.fields!==void 0){const r={type:n.type};return n.cases&&(r.cases=Object.fromEntries(Object.entries(n.cases).map(([a,o])=>[a,I2(o)]))),n.fields&&(r.fields=Object.fromEntries(Object.entries(n.fields).map(([a,o])=>[a,I2(o)]))),n.key&&(r.key=I2(n.key)),n.value!==void 0&&(n.type==="Array"||n.type==="Dict")&&(r.value=I2(n.value)),r}switch(n.type){case"Struct":return{type:"Struct",fields:Object.fromEntries(n.value.map(r=>[r.name,I2(r.type)]))};case"Variant":return{type:"Variant",cases:Object.fromEntries(n.value.map(r=>[r.name,I2(r.type)]))};case"Array":return{type:"Array",value:I2(n.value)};case"Dict":{const r=n.value;return{type:"Dict",key:I2(r.key),value:I2(r.value)}}case"Recursive":{const r=n.value;return(r==null?void 0:r.type)==="wrapper"&&((t=r.value)!=null&&t.inner)?I2(r.value.inner):{type:n.type}}default:return{type:n.type}}}function E_(e){switch(e.type){case"Integer":return 0n;case"Float":return 0;case"DateTime":return new Date;case"Boolean":return!1;case"String":return"";case"Struct":return Object.fromEntries(Object.entries(e.fields??{}).map(([t,n])=>[t,E_(n)]));default:return null}}function sur(e){return e?eE.has(e.type)?!0:e.type==="Struct"?Object.values(e.fields??{}).every(t=>eE.has(t.type)):e.type==="Variant"?Object.values(e.cases??{}).every(t=>eE.has(t.type)||t.type==="Struct"&&Object.values(t.fields??{}).every(n=>eE.has(n.type))):!1:!1}const yg=P({size:P($("sm",null))});function lur({leverCase:e,payload:t,onInject:n}){var r;const a=ga({key:"button"}),o=t.type==="Variant",i=C.useMemo(()=>o?Object.keys(t.cases??{}):[],[o,t]),[s,l]=C.useState(i[0]??""),c=o?((r=t.cases)==null?void 0:r[s])??{type:"Null"}:t,u=C.useRef(E_(c)),d=C.useRef(`${e}:${s}`);d.current!==`${e}:${s}`&&(d.current=`${e}:${s}`,u.current=E_(c));const f=(v,b,y,x)=>{switch(v.type){case"Integer":return p.jsx(X$,{value:{value:y(),onChange:P(x),style:yg}},b);case"Float":return p.jsx(Z$,{value:{value:y(),onChange:P(x),style:yg}},b);case"DateTime":return p.jsx(m9,{value:{value:y(),onChange:P(x),style:yg}},b);case"Boolean":return p.jsx(h6,{ariaLabel:b,value:{value:P(String(y())),items:[{value:"true",label:"true",disabled:A},{value:"false",label:"false",disabled:A}],placeholder:A,multiple:A,disabled:A,onChange:P(S=>x(S==="true")),onChangeMultiple:A,onOpenChange:A,style:yg}},b);default:return p.jsx(Y$,{value:{value:String(y()??""),onChange:P(x),style:yg}},b)}},h=C.useMemo(()=>{const v=d.current;return c.type==="Struct"?Object.entries(c.fields??{}).map(([b,y])=>p.jsxs(V,{display:"flex",alignItems:"center",gap:"6px",minW:0,children:[p.jsx(V,{as:"span",textStyle:"caption.eyebrow",color:"fg.subtle",flexShrink:0,children:b}),f(y,`${v}.${b}.in`,()=>u.current[b],x=>{u.current[b]=x})]},`${v}.${b}`)):p.jsx(V,{width:"min(180px, 100%)",flexShrink:0,children:f(c,`${v}.value`,()=>u.current,b=>{u.current=b})},`${v}.wrap`)},[c,s,e]),g=()=>{const v=u.current,b=c.type==="Struct"?{...v}:v,y=o?$(e,$(s,b)):$(e,b);n(y),u.current=E_(c)};return p.jsxs(V,{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",minW:0,css:{"& [data-scope=select][data-part=root]":{width:"auto",minWidth:"110px",flexShrink:0},"& [data-scope=number-input][data-part=root]":{width:"150px",flexShrink:0}},children:[o&&p.jsx(h6,{ariaLabel:"Operator",value:{value:P(s),items:i.map(v=>({value:v,label:Sat[v]??v,disabled:A})),placeholder:A,multiple:A,disabled:A,onChange:P(v=>l(v)),onChangeMultiple:A,onOpenChange:A,style:yg}}),h,p.jsx(Ht.button,{type:"button",css:a({variant:"solid",size:"xs"}),onClick:g,children:"Add"})]})}function Mx(e,t,n=!1){return Yp(t,_(e.format),n)}const ic={textStyle:"caption.eyebrow",color:"fg.muted"},cur=C.memo(function({decision:t,children:n}){const r=_(t.stakes),a=_(t.downside),o=_(t.confidence),i=_(t.detail);return p.jsxs(V,{display:"flex",flexDirection:"column",gap:"10px",children:[p.jsxs(V,{display:"flex",alignItems:"baseline",gap:"12px",flexWrap:"wrap",children:[p.jsx(Ie,{...ic,color:"fg",children:"Why this is recommended"}),p.jsxs(Ie,{...ic,children:[r!==void 0&&p.jsxs(p.Fragment,{children:["stakes ",p.jsx(Ie,{as:"span",fontFamily:"mono",fontWeight:"semibold",children:r.type})," · "]}),a!==void 0&&p.jsxs(p.Fragment,{children:["if wrong ",p.jsx(Ie,{as:"span",fontFamily:"mono",fontWeight:"semibold",color:"fg.danger",children:Mx(t,a,!0)})," · "]}),o!==void 0&&p.jsxs(p.Fragment,{children:["confidence ",p.jsxs(Ie,{as:"span",fontFamily:"mono",fontWeight:"semibold",children:[Math.round(o*100),"%"]})]})]})]}),i!==void 0&&p.jsx(Ie,{fontSize:"12.5px",color:"fg.muted",children:i}),t.evidence.length>0&&p.jsx(V,{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"8px",children:t.evidence.map((s,l)=>{const c=_(s.note);return p.jsxs(V,{borderWidth:"1px",borderColor:"border.subtle",borderRadius:"4px",px:"10px",py:"8px",bg:"bg.canvas",children:[p.jsx(Ie,{...ic,children:s.label}),p.jsx(Ie,{fontSize:"13px",fontWeight:"medium",children:s.text}),c!==void 0&&p.jsx(Ie,{fontSize:"11px",fontFamily:"mono",color:"fg.subtle",children:c})]},l)})}),n]})});function uur(e){const t=[...e.alternatives].sort((n,r)=>r.value-n.value).map(n=>({label:n.label,value:n.value,downside:_(n.downside),confidence:_(n.confidence),note:_(n.note),recommended:!1}));return[{label:e.title,value:e.value,downside:_(e.downside),confidence:_(e.confidence),note:_(e.summary),recommended:!0},...t].map((n,r)=>({...n,rank:r+1}))}function Ive(e){const t=[];return e.recommended&&t.push("recommended"),e.confidence!==void 0&&t.push(`${Math.round(e.confidence*100)}% conf`),!e.recommended&&e.note!==void 0&&t.push(e.note),t.join(" · ")}const dur=C.memo(function({decision:t,narrow:n}){const r=uur(t),a=Math.max(...r.map(c=>Math.max(c.value,0)),1e-9),o=Math.max(...r.map(c=>Math.abs(c.downside??0)),1e-9),i=_(t.valueAxis),s=(i==null?void 0:i.label)??"Uplift",l=(i==null?void 0:i.signed)??!0;if(n){const c=(u,d,f,h)=>p.jsxs(V,{display:"grid",gridTemplateColumns:"80px 1fr 64px",alignItems:"center",gap:"8px",children:[p.jsx(Ie,{...ic,whiteSpace:"nowrap",children:u}),p.jsx(V,{height:"6px",bg:"border.subtle",borderRadius:"3px",overflow:"hidden",children:p.jsx(V,{height:"100%",width:`${Math.round(Math.min(Math.abs(d),1)*100)}%`,bg:h==="success"?"fg.success":h==="danger"?"fg.danger":"fg.subtle",opacity:.7})}),p.jsx(Ie,{fontSize:"11px",fontFamily:"mono",fontWeight:"semibold",textAlign:"right",children:f})]});return p.jsxs(V,{display:"flex",flexDirection:"column",gap:"10px",children:[p.jsxs(Ie,{...ic,color:"fg",children:["Options · ",r.length," evaluated"]}),r.map(u=>p.jsxs(V,{display:"flex",flexDirection:"column",gap:"4px",pl:"8px",...u.recommended?{boxShadow:"inset 2px 0 0 var(--chakra-colors-accent-brand)"}:{},children:[p.jsxs(Ie,{fontSize:"12.5px",children:[p.jsx(Ie,{as:"span",fontFamily:"mono",color:"fg.subtle",children:u.rank})," ",p.jsx(Ie,{as:"span",fontWeight:u.recommended?"semibold":"normal",children:u.label})]}),c(s,u.value/a,Mx(t,u.value,l),l?"success":"neutral"),c("If wrong",(u.downside??0)/o,u.downside!==void 0?Mx(t,u.downside,!0):"—","danger")]},u.rank))]})}return p.jsxs(V,{display:"flex",flexDirection:"column",gap:"6px",children:[p.jsxs(V,{display:"grid",gridTemplateColumns:"minmax(180px, 1.1fr) 1fr 1fr",alignItems:"baseline",gap:"8px",children:[p.jsxs(Ie,{...ic,color:"fg",children:["Options · ",r.length," evaluated"]}),p.jsx(Ie,{...ic,textAlign:"center",children:"If wrong"}),p.jsx(Ie,{...ic,textAlign:"right",children:s})]}),r.map(c=>{const u=Math.min(Math.abs(c.downside??0)/o,1),d=Math.min(Math.max(c.value,0)/a,1);return p.jsxs(V,{display:"grid",gridTemplateColumns:"minmax(180px, 1.1fr) 1fr 1fr",alignItems:"center",gap:"8px",py:"4px",...c.recommended?{bg:"bg.brand.subtle",boxShadow:"inset 2px 0 0 var(--chakra-colors-accent-brand)"}:{},children:[p.jsxs(V,{minW:0,pl:c.recommended?"6px":"0",display:"flex",alignItems:"baseline",gap:"6px",children:[p.jsx(Ie,{as:"span",fontFamily:"mono",fontSize:"11px",color:"fg.subtle",flexShrink:0,children:c.rank}),p.jsx(Ie,{as:"span",fontSize:"12.5px",fontWeight:c.recommended?"semibold":"normal",flexShrink:0,children:c.label}),Ive(c)!==""&&p.jsx(Ie,{as:"span",fontFamily:"mono",fontSize:"10.5px",color:"fg.muted",minW:0,truncate:!0,children:Ive(c)})]}),p.jsx(V,{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:"6px",height:"16px",children:c.downside!==void 0&&p.jsxs(p.Fragment,{children:[p.jsx(Ie,{fontSize:"10.5px",fontFamily:"mono",color:"fg.danger",flexShrink:0,children:Mx(t,c.downside,!0)}),p.jsx(V,{height:"12px",width:`${Math.round(u*100)}%`,bg:"fg.danger",opacity:.55})]})}),p.jsx(V,{display:"flex",alignItems:"center",gap:"6px",height:"16px",borderLeftWidth:"1px",borderColor:"border.strong",children:c.value>0&&p.jsxs(p.Fragment,{children:[p.jsx(V,{height:"12px",width:`${Math.round(d*100)}%`,bg:l?"fg.success":"fg.subtle",opacity:.6}),p.jsx(Ie,{fontSize:"10.5px",fontFamily:"mono",color:l?"fg.success":"fg.muted",flexShrink:0,children:Mx(t,c.value,l)})]})})]},c.rank)})]})}),fur=[{literal:"yes",label:"Yes"},{literal:"no",label:"No"},{literal:"unknown",label:"Don't know"}],pur=C.memo(function({decision:t,handle:n,leverPayloads:r}){var a;const o=ga({key:"button"}),i=ga({key:"input"}),s=n.judgementFor(t.id),l=(s==null?void 0:s.knowledge.type)==="some"?s.knowledge.value:"",[c,u]=C.useState(l);C.useEffect(()=>{u(l)},[l]);const d=C.useCallback(()=>{c!==l&&n.addKnowledge(t.id,c)},[c,l,n,t.id]),f=C.useMemo(()=>t.levers.filter(S=>sur(r[S.case])),[t.levers,r]),[h,g]=C.useState(((a=f[0])==null?void 0:a.case)??""),v=f.find(S=>S.case===h)??f[0],b=n.commitStateFor(t.id),y=(b==null?void 0:b.type)==="gated"?b.value===1n?"Answer the judgement question to enable apply":`Answer the ${b.value} judgement questions to enable apply`:(b==null?void 0:b.type)==="blocked"?"Commit blocked — an answer contradicts the recommendation":(b==null?void 0:b.type)==="handoff"?"Awaiting handoff — an answer was don't know":null,x=C.useCallback(S=>{n.inject(t.id,S)},[n,t.id]);return s?p.jsxs(V,{display:"flex",flexDirection:"column",gap:"10px",children:[p.jsxs(V,{display:"flex",alignItems:"baseline",gap:"12px",children:[p.jsx(Ie,{...ic,color:"fg.warning",children:"Required before commit"}),p.jsx(Ie,{...ic,marginLeft:"auto",children:"human-only signal · model can’t see this"})]}),t.prompts.map(S=>{var z;const M=(z=s.answers.get(S.id))==null?void 0:z.type;return p.jsxs(V,{display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap",children:[p.jsx(Ie,{fontSize:"13px",fontWeight:"medium",flex:"1",minW:"min(180px, 100%)",children:S.text}),p.jsx(V,{display:"flex",gap:"6px",flexShrink:0,children:fur.map(L=>p.jsx(Ht.button,{type:"button",css:o({variant:M===L.literal?"solid":"outline",size:"xs"}),onClick:()=>n.answer(t.id,S.id,L.literal),children:L.label},L.literal))})]},S.id)}),p.jsxs(V,{display:"flex",flexDirection:"column",gap:"4px",children:[p.jsx(Ie,{...ic,children:"Knowledge · what the model can’t see"}),p.jsx(Ht.textarea,{css:i({size:"sm"}),rows:2,value:c,placeholder:"Private context — persists with the case",onChange:S=>u(S.target.value),onBlur:d})]}),(f.length>0||s.constraints.length>0)&&p.jsxs(V,{display:"flex",flexDirection:"column",gap:"6px",children:[p.jsx(Ie,{...ic,children:"Inject constraint · next run folds it in"}),s.constraints.length>0&&p.jsx(V,{display:"flex",gap:"12px",flexWrap:"wrap",children:s.constraints.map((S,z)=>{const M=S.type,L=Cat(S,r[M],t.levers);return p.jsxs(Ie,{as:"span",fontFamily:"mono",fontSize:"11px",children:[p.jsx(Ie,{as:"span",color:"accent.brand",fontWeight:"semibold",children:L.lever})," ",p.jsx(Ie,{as:"span",color:"fg.subtle",children:L.op})," ",p.jsx(Ie,{as:"span",fontWeight:"semibold",children:L.value})]},z)})}),v!==void 0&&p.jsxs(V,{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",children:[f.length>1?p.jsx(V,{flexShrink:0,css:{"& [data-scope=select][data-part=root]":{width:"auto",minWidth:"160px"}},children:p.jsx(h6,{ariaLabel:"Lever",value:{value:P(v.case),items:f.map(S=>({value:S.case,label:S.label,disabled:A})),placeholder:A,multiple:A,disabled:A,onChange:P(S=>g(S)),onChangeMultiple:A,onOpenChange:A,style:P({size:P($("sm",null))})}})}):p.jsx(Ie,{...ic,color:"fg",flexShrink:0,children:v.label}),p.jsx(V,{flex:"1",minW:"min(260px, 100%)",children:p.jsx(lur,{leverCase:v.case,payload:r[v.case],onInject:x},v.case)})]})]}),y!==null&&p.jsxs(V,{display:"flex",alignItems:"center",gap:"8px",pt:"4px",children:[p.jsx(V,{width:"7px",height:"7px",borderRadius:"full",bg:"fg.warning",flexShrink:0}),p.jsx(Ie,{...ic,children:y}),p.jsx(Ht.button,{type:"button",css:o({variant:"outline",size:"xs"}),marginLeft:"auto",onClick:()=>n.resolve(t.id,$("deferred",A)),children:"Defer"})]})]}):null}),Dve={overdue:0,due:1,routine:2},kat={overdue:"Overdue",due:"Due today",routine:"Routine"};function hur(e,t){if(t.key==="none")return[{label:"",decisions:e,pastSla:0,total:0,bulk:!1}];const n=a=>{var o;return t.key==="urgency"?kat[a.urgency.type]:t.key==="kind"?a.kind:((o=t.accessor)==null?void 0:o.call(t,a))??""},r=new Map;for(const a of e){const o=n(a);let i=r.get(o);i===void 0&&(i={label:o,decisions:[],pastSla:0,total:0,bulk:t.key==="urgency"&&a.urgency.type==="routine"},r.set(o,i)),i.decisions.push(a),i.total+=a.value,a.urgency.type==="overdue"&&(i.pastSla+=1)}return[...r.values()]}const gur=[{key:"evidence",label:"Evidence"},{key:"options",label:"Options"},{key:"judgement",label:"Judgement"},{key:"modify",label:"Modify"}],mur={overdue:"danger",due:"warning",routine:"neutral"},vur=560,yur=560;function zat(e,t,n=!1){return Yp(t,_(e.format),n)}function bur(e){const t=_(e.deadline);if(t===void 0)return"";if(e.urgency.type==="overdue"){const n=Math.round((Date.now()-t.getTime())/36e5);return n<1?" <1h":n<48?` ${n}h`:` ${Math.round(n/24)}d`}if(e.urgency.type==="due"){const n=t.getHours(),r=t.getMinutes(),a=n>=12?"pm":"am",o=n%12===0?12:n%12;return r===0?` ${o}${a}`:` ${o}:${String(r).padStart(2,"0")}${a}`}return""}function xur(e){const n=m2().getConfig().workspace??"";return C.useMemo(()=>{var r,a,o;if(!e)return{};const i=F6(n,e.judgements.source);if(!(i!=null&&i.sourceType))return{};const l=(o=(a=(r=I2(i.sourceType).value)==null?void 0:r.fields)==null?void 0:a.constraints)==null?void 0:o.value;return(l==null?void 0:l.type)==="Variant"?l.cases??{}:{}},[e,n])}const wur=C.memo(function({decision:t,handle:n,selected:r,narrow:a,leverPayloads:o,modify:i,evidence:s,defaultFacet:l,facetInclude:c,apply:u,reject:d,leaving:f,storageKey:h}){var g,v;const b=en({key:"decisionQueue"}),y=en({key:"status"}),x=en({key:"facetTabs"}),S=ga({key:"button"}),z=b({}),M=x({}),L=y({status:mur[t.urgency.type],size:"md"}),R=C.useMemo(()=>gur.filter(se=>se.key==="modify"?i!==void 0:c===null||c.has(se.key)),[i,c]),N=R.some(se=>se.key===l)?l:((g=R[0])==null?void 0:g.key)??l,[O,j]=C.useState(N);C.useEffect(()=>{r||j(N)},[r,N]);const B=n.commitStateFor(t.id),H=B===null||B.type==="ready",K=!H&&t.prompts.length>0,U=_(t.summary),Z=C.useCallback(()=>{r||n.select(t.id)},[r,n,t.id]),G=C.useCallback(()=>{H&&u(t)},[H,u,t]),W=C.useCallback(()=>{d(t)},[d,t]),J=C.useMemo(()=>!r||O!=="modify"||!i?null:i(t,n.update),[r,O,i,t,n.update]),ae=C.useMemo(()=>!r||O!=="evidence"||!s?null:s(t),[r,O,s,t]),ne=p.jsx(V,{css:M.root,...a?{display:"flex",width:"100%"}:{},children:R.map(se=>p.jsx(V,{as:"button",css:M.tab,...a?{flex:1}:{},...O===se.key?{"data-on":""}:{},...se.key==="judgement"&&K?{"data-pulse":""}:{},"aria-pressed":O===se.key,onClick:()=>j(se.key),children:se.label},se.key))}),Y=p.jsxs(V,{display:"flex",gap:"6px",...a?{justifyContent:"flex-end"}:{},children:[p.jsx(V,{as:"button",css:S({variant:"solid",size:"xs"}),"aria-disabled":!H,opacity:H?void 0:.5,cursor:H?void 0:"not-allowed",title:H?void 0:"Answer the judgement to enable apply",onClick:G,children:"Apply"}),p.jsx(V,{as:"button",css:S({variant:"ghost",size:"xs"}),onClick:W,children:"Reject"})]}),te=`${t.kind} · ${t.title}${U!==void 0?` · ${U}`:""}`,ie=p.jsxs(V,{css:z.titleText,title:te,cursor:r?void 0:"pointer",onClick:Z,children:[p.jsx(Ie,{as:"span",fontWeight:"semibold",children:t.kind}),p.jsx(Ie,{as:"span",color:"fg.subtle",children:" · "}),p.jsx(Ie,{as:"span",children:t.title}),U!==void 0&&!a&&p.jsxs(p.Fragment,{children:[p.jsx(Ie,{as:"span",color:"fg.subtle",children:" · "}),p.jsx(Ie,{as:"span",color:"fg.muted",children:U})]})]}),ue=p.jsxs(V,{as:"span",css:L.root,flexShrink:0,children:[p.jsx(V,{as:"span",css:L.indicator}),p.jsxs(V,{as:"span",css:L.label,children:[t.urgency.type,bur(t)]})]}),oe=((v=_(t.valueAxis))==null?void 0:v.signed)??!0,ve=p.jsx(Ie,{fontFamily:"mono",fontWeight:"semibold",textAlign:"right",...oe&&t.value>=0&&r?{color:"fg.success"}:{},children:zat(t,t.value,oe&&r)});return p.jsxs(V,{css:z.rowShell,...f?{"data-leaving":f}:{},children:[a?p.jsxs(V,{px:"14px",py:"10px",children:[p.jsxs(V,{display:"flex",justifyContent:"space-between",alignItems:"baseline",children:[ue,ve]}),p.jsx(V,{mt:"2px",fontSize:"13px",children:ie}),r&&p.jsxs(p.Fragment,{children:[p.jsx(V,{mt:"8px",children:ne}),p.jsx(V,{mt:"8px",children:Y})]})]}):p.jsxs(V,{css:z.row,children:[ue,p.jsx(V,{css:z.title,p:0,children:ie}),ve,p.jsxs(V,{display:"flex",alignItems:"center",gap:"12px",children:[r&&ne,Y]})]}),r&&p.jsxs(V,{px:a?"14px":"18px",py:"12px",borderTopWidth:"1px",borderColor:"border.subtle",bg:"bg.canvas",children:[O==="evidence"&&p.jsx(cur,{decision:t,children:ae!=null&&p.jsx(mn,{value:ae,storageKey:`${h}-evidence-${t.id}`})}),O==="options"&&p.jsx(dur,{decision:t,narrow:a}),O==="judgement"&&p.jsx(pur,{decision:t,handle:n,leverPayloads:o}),O==="modify"&&J!=null&&p.jsx(mn,{value:J,storageKey:`${h}-modify-${t.id}`})]})]})}),Sur=C.memo(function({routine:t,acceptAll:n,leaving:r,narrow:a}){const o=en({key:"decisionQueue"}),i=en({key:"status"}),s=ga({key:"button"}),l=o({}),c=i({status:"neutral",size:"md"}),u=C.useMemo(()=>t.reduce((h,g)=>h+g.value,0),[t]),d=t[0]?_(t[0].format):void 0,f=C.useCallback(()=>{n&&n(t)},[n,t]);return t.length===0?null:p.jsxs(V,{css:l.routineGroup,children:[t.map(h=>p.jsx(V,{css:l.rowShell,...r.has(h.id)?{"data-leaving":r.get(h.id)}:{},children:p.jsxs(V,{css:l.routineRow,children:[p.jsxs(V,{as:"span",css:c.root,children:[p.jsx(V,{as:"span",css:c.indicator}),p.jsx(V,{as:"span",css:c.label,children:"routine"})]}),p.jsxs(V,{minW:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:[p.jsx(Ie,{as:"span",fontFamily:"mono",children:h.id}),p.jsxs(Ie,{as:"span",color:"fg.muted",children:[" · ",h.kind]})]}),p.jsx(V,{css:l.routineValue,children:zat(h,h.value)})]})},h.id)),p.jsxs(V,{css:l.summary,...a?{marginLeft:"0",flexWrap:"wrap"}:{},children:[p.jsxs(V,{as:"span",css:l.summaryCap,children:[t.length," routine"]}),p.jsx(Ie,{as:"span",color:"fg.subtle",children:"·"}),p.jsx(Ie,{as:"span",fontFamily:"mono",fontWeight:"semibold",children:Yp(u,d)}),p.jsx(Ie,{as:"span",color:"fg.muted",children:"total"}),n&&p.jsx(V,{as:"button",css:s({variant:"solid",size:"xs"}),ml:"auto",onClick:f,children:"Accept all"})]})]})}),Cur=C.memo(function({group:t,collapsible:n,collapsed:r,onToggle:a,acceptAll:o}){const i=en({key:"decisionQueue"}),s=ga({key:"button"}),l=i({}),c=t.decisions[0]?_(t.decisions[0].format):void 0,u=C.useCallback(()=>{n&&a(t.label)},[n,a,t.label]),d=C.useCallback(f=>{f.stopPropagation(),o&&o(t.decisions)},[o,t.decisions]);return p.jsxs(V,{css:l.groupHead,...n?{"data-collapsible":""}:{},onClick:u,children:[n&&p.jsx(V,{as:"span",css:l.groupCaret,children:r?"▸":"▾"}),p.jsxs(V,{as:"span",css:l.groupLabel,children:[t.label," · ",t.decisions.length]}),p.jsxs(V,{as:"span",css:l.groupSummary,children:[Yp(t.total,c),t.pastSla>0?` · ${t.pastSla} past SLA`:""]}),o&&p.jsx(V,{as:"button",css:s({variant:"solid",size:"xs"}),onClick:d,children:"Accept all"})]})}),kur=C.memo(function({value:t,storageKey:n}){var r;const o=en({key:"eyebrowRow"})({}),s=en({key:"decisionQueue"})({}),l=ga({key:"chip"}),c=t.handle,u=wat(c),d=u.decisions,f=xur(c),h=_(t.affordances),g=_(t.slice)??null;rl(g==null?void 0:g.key);const v=g!==null?g.read():null,b=C.useRef(null),y=Rv(b,yur),[x,S]=C.useState(new Map),z=C.useRef(null),M=C.useRef(new Map),L=C.useRef([]);C.useLayoutEffect(()=>{const Ve=z.current;if(z.current=d,!Ve||!d)return;const ut=new Set(d.map(Ft=>Ft.id)),_t=Ve.filter(Ft=>!ut.has(Ft.id));_t.length!==0&&(S(Ft=>{const wt=new Map(Ft);for(const Lt of _t)wt.set(Lt.id,{decision:Lt,reason:M.current.get(Lt.id)??"removed"}),M.current.delete(Lt.id);return wt}),L.current.push(setTimeout(()=>{S(Ft=>{const wt=new Map(Ft);for(const Lt of _t)wt.delete(Lt.id);return wt})},vur)))},[d]),C.useEffect(()=>()=>{for(const Ve of L.current)clearTimeout(Ve)},[]);const R=_(t.heading)??"Decisions waiting",N=C.useMemo(()=>_(t.onApply),[t.onApply]),O=C.useMemo(()=>_(t.onReject),[t.onReject]),j=C.useMemo(()=>_(t.modify),[t.modify]),B=C.useMemo(()=>_(t.evidence),[t.evidence]),H=((r=_(t.defaultFacet))==null?void 0:r.type)??"evidence",K=C.useMemo(()=>{const Ve=_(t.facets);return Ve===void 0?null:new Set(Ve.map(ut=>ut.type))},[t.facets]),U=_(t.defaultExpanded),Z=C.useMemo(()=>_(t.groups)??[],[t.groups]),G=_(t.groupBy),W=G!==void 0,J=W&&(_(t.collapsible)??!0),ae=C.useMemo(()=>[{key:"urgency",label:"Urgency"},{key:"kind",label:"Kind"},...Z.map(Ve=>({key:Ve.label,label:Ve.label,accessor:Ve.value})),{key:"none",label:"None"}],[Z]),{state:ne,setState:Y}=Pl(`${n}.toolbar`,{groupKey:G??"urgency",collapsed:[kat.routine]}),te=ae.find(Ve=>Ve.key===ne.groupKey)??ae[0],ie=u.selected??(U==null?void 0:U.id)??null,ue=C.useCallback((Ve,ut,_t)=>{if(ut)for(const Ft of Ve){const wt=Ft;queueMicrotask(()=>ut(wt))}for(const Ft of Ve)M.current.set(Ft.id,_t),u.resolve(Ft.id,_t==="reject"?$("rejected",null):$("accepted",""))},[u]),oe=C.useCallback(Ve=>ue([Ve],N,"apply"),[ue,N]),ve=C.useCallback(Ve=>ue([Ve],O,"reject"),[ue,O]),se=C.useCallback(Ve=>ue(Ve,N,"apply"),[ue,N]),{merged:pe,active:de,routine:ge,pastSla:ye,visible:me}=C.useMemo(()=>{const Ve=d??[],ut=new Date,_t=g!==null?wht(g.key):void 0,Ft=v!==null&&_t!==void 0?Ve.filter(Lt=>K2(v,_t,Lt,ut)):Ve,wt=[...Ft];for(const{decision:Lt}of x.values())wt.some(Jt=>Jt.id===Lt.id)||wt.push(Lt);return wt.sort((Lt,Jt)=>{var Dt,Et;const Gt=Dve[Lt.urgency.type]-Dve[Jt.urgency.type];if(Gt!==0)return Gt;const Ke=((Dt=_(Lt.deadline))==null?void 0:Dt.getTime())??1/0,Se=((Et=_(Jt.deadline))==null?void 0:Et.getTime())??1/0;return Ke!==Se?Ke-Se:Jt.value-Lt.value}),{merged:wt,active:wt.filter(Lt=>Lt.urgency.type!=="routine"),routine:wt.filter(Lt=>Lt.urgency.type==="routine"),pastSla:wt.filter(Lt=>Lt.urgency.type==="overdue").length,visible:Ft.length}},[d,x,v,g]),Me=C.useMemo(()=>W?hur(pe,te):[],[W,pe,te]),Te=Me.length>0&&Me.every(Ve=>Ve.label===""||ne.collapsed.includes(Ve.label)),Be=C.useCallback(Ve=>{Y(ut=>({...ut,collapsed:ut.collapsed.includes(Ve)?ut.collapsed.filter(_t=>_t!==Ve):[...ut.collapsed,Ve]}))},[Y]),ht=C.useCallback(()=>{const Ve=Te?[]:Me.map(ut=>ut.label).filter(ut=>ut!=="");Y(ut=>({...ut,collapsed:Ve}))},[Y,Te,Me]),De=C.useCallback(Ve=>{Y(ut=>ut.groupKey===Ve?ut:{...ut,groupKey:Ve})},[Y]),Qe=C.useMemo(()=>{const Ve=new Map;for(const[ut,_t]of x)Ve.set(ut,_t.reason);return Ve},[x]),bt=Ve=>p.jsx(wur,{decision:Ve,handle:u,selected:ie===Ve.id,narrow:y,leverPayloads:f,modify:j,evidence:B,defaultFacet:H,facetInclude:K,apply:oe,reject:ve,leaving:Qe.get(Ve.id),storageKey:n},Ve.id);return d===null?p.jsx(V,{layerStyle:"surface.frameless",p:"16px",children:p.jsx(Ie,{color:"fg.muted",fontSize:"13px",children:"Loading decisions…"})}):p.jsxs(V,{ref:b,layerStyle:"surface.frameless",overflow:"hidden",children:[p.jsxs(V,{css:o.root,children:[p.jsx(V,{css:o.lbl,children:R}),g!==null&&h!==void 0&&p.jsx(V,{display:"flex",alignItems:"center",minWidth:"0",flex:"1",justifyContent:"flex-end",marginRight:"10px",children:p.jsx(zd,{slice:g,affordanceKinds:h.map(Ve=>Ve.type)})}),p.jsxs(V,{css:o.meta,gap:"10px",children:[p.jsxs(V,{as:"span",children:[p.jsx(Ie,{as:"span",color:"fg",fontWeight:"semibold",children:me}),y?"":" decisions"]}),ye>0&&p.jsxs(p.Fragment,{children:[p.jsx(V,{as:"span",css:o.sep,children:"·"}),p.jsxs(V,{as:"span",children:[p.jsx(Ie,{as:"span",color:"fg.danger",fontWeight:"semibold",children:ye}),y?" SLA":" past SLA"]})]})]})]}),W&&p.jsxs(V,{css:s.toolbar,children:[p.jsx(V,{as:"span",css:s.segLabel,children:"Group by"}),ae.map(Ve=>p.jsx(V,{as:"button",css:{...l({tone:ne.groupKey===Ve.key?"brand":"neutral",size:"sm"}),cursor:"pointer"},"aria-pressed":ne.groupKey===Ve.key,onClick:()=>De(Ve.key),children:Ve.label},Ve.key)),J&&p.jsx(V,{as:"button",css:s.collapseAll,onClick:ht,children:Te?"Expand all":"Collapse all"})]}),p.jsx(V,{maxHeight:_(t.maxHeight),overflowY:t.maxHeight.type==="some"?"auto":void 0,children:W?Me.map(Ve=>{const ut=J&&Ve.label!==""&&ne.collapsed.includes(Ve.label);return p.jsxs(V,{children:[Ve.label!==""&&p.jsx(Cur,{group:Ve,collapsible:J,collapsed:ut,onToggle:Be,acceptAll:Ve.bulk?se:void 0}),!ut&&Ve.decisions.map(bt)]},Ve.label||"_flat")}):p.jsxs(p.Fragment,{children:[de.map(bt),p.jsx(Sur,{routine:ge,acceptAll:se,leaving:Qe,narrow:y})]})})]})});pk(Q7t.Component,kur);function zur(e){switch(e.type){case"accepted":return{tone:"success",verb:"accepted",detail:e.value!==""?e.value:null};case"rejected":return{tone:"danger",verb:"rejected",detail:null};case"deferred":return{tone:"neutral",verb:"deferred",detail:e.value.type==="some"?e.value.value:null};case"handoff":return{tone:"warning",verb:"handed off",detail:e.value!==""?e.value:null}}}function Mur(e){if(e.resolvedAt.type!=="some")return null;const t=e.resolvedAt.value,n=t.toLocaleString("en",{month:"short"}),r=`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`;return`${n} ${t.getDate()} · ${r}`}const Tur=C.memo(function({value:t}){const n=en({key:"eyebrowRow"}),r=en({key:"status"}),a=n({}),o=wat(t.handle),i=_(t.heading)??"Decision journal",l=m2().getConfig().workspace??"",c=C.useMemo(()=>{var d,f,h;const g=F6(l,t.handle.judgements.source);if(!(g!=null&&g.sourceType))return{};const b=(h=(f=(d=I2(g.sourceType).value)==null?void 0:d.fields)==null?void 0:f.constraints)==null?void 0:h.value;return(b==null?void 0:b.type)==="Variant"?b.cases??{}:{}},[l,t.handle]),u=C.useMemo(()=>o.journal??[],[o.journal]);return p.jsxs(V,{borderWidth:"1px",borderColor:"border.strong",borderRadius:"6px",background:"bg.canvas",overflow:"hidden",children:[p.jsxs(V,{css:a.root,children:[p.jsx(V,{css:a.lbl,children:i}),p.jsx(V,{css:a.meta,children:u.length===1?"1 entry":`${u.length} entries`})]}),p.jsx(V,{maxHeight:_(t.maxHeight),overflowY:t.maxHeight.type==="some"?"auto":void 0,children:u.length===0?p.jsx(Ie,{px:"16px",py:"14px",fontSize:"13px",color:"fg.muted",children:"No resolved cases yet — verdicts land here as the queue clears."}):u.map((d,f)=>{const h=d.verdict.type==="some"?d.verdict.value:null;if(!h)return null;const{tone:g,verb:v,detail:b}=zur(h),y=r({status:g,size:"md"}),x=Mur(d),S=d.knowledge.type==="some"&&d.knowledge.value!==""?d.knowledge.value:null;return p.jsxs(V,{px:"16px",py:"10px",borderTopWidth:f===0?void 0:"1px",borderColor:"border.subtle",display:"flex",flexDirection:"column",gap:"6px",children:[p.jsxs(V,{display:"flex",alignItems:"baseline",gap:"10px",children:[p.jsxs(V,{as:"span",css:y.root,flexShrink:0,children:[p.jsx(V,{as:"span",css:y.indicator}),p.jsx(V,{as:"span",css:y.label,children:v})]}),p.jsx(Ie,{as:"span",fontFamily:"mono",fontSize:"12px",color:"fg.muted",children:d.caseId}),b!==null&&p.jsx(Ie,{as:"span",fontSize:"13px",minW:0,flex:"1",truncate:!0,children:b}),x!==null&&p.jsx(Ie,{as:"span",fontFamily:"mono",fontSize:"11.5px",color:"fg.muted",marginLeft:"auto",flexShrink:0,children:x})]}),S!==null&&p.jsxs(Ie,{fontSize:"12.5px",fontStyle:"italic",color:"fg.muted",borderLeftWidth:"2px",borderColor:"border.strong",paddingLeft:"10px",children:["“",S,"”"]}),d.constraints.length>0&&p.jsx(V,{display:"flex",gap:"12px",flexWrap:"wrap",children:d.constraints.map((z,M)=>{const L=z.type,R=Cat(z,c[L]);return p.jsx(Gkn,{field:R.lever,op:R.op,value:R.value},M)})})]},d.caseId)})})]})});pk(tht.Component,Tur);function Eur(e){if(e instanceof h1&&e.details!=null){const t=e.details;return typeof t=="string"?{message:e.message,details:t}:typeof t=="object"&&"message"in t?{message:e.message,details:String(t.message)}:{message:e.message,details:JSON.stringify(t)}}return{message:e instanceof Error?e.message:String(e)}}function Mat(e){return e instanceof ct?e.formattedMessage:e.message}function _ur(e,t,n,r){return rHn({mutationFn:({path:a,data:o})=>Yte(e,t,n,a,o,r??{token:null})})}function Tat(e,t,n,r,a){const{requestOptions:o,pollInterval:i=5e3,queryOverrides:s}=a??{},l=o??{token:null},c=C.useMemo(()=>(r==null?void 0:r.split(".").filter(Boolean).map(u=>$("field",u)))??[],[r]);return LI({queryKey:["datasetStatus",e,t,n,r],queryFn:async()=>{var u,d;const f=await sgt(e,t,n,c,l);return{path:f.path,type:f.type,refType:f.refType,hash:((u=f.hash)==null?void 0:u.type)==="some"?f.hash.value:null,sizeBytes:((d=f.size)==null?void 0:d.type)==="some"?Number(f.size.value):null}},enabled:!!n&&!!r,refetchInterval:i,...s})}const Lur=[...mN,...Hte,...Vte,...Ete,...Die,...Wte,...Ute,...qte,...g1e,...lQe,...uQe,...xJe];function Eat(e,t,n,r,a){const{requestOptions:o,queryOverrides:i,enabled:s=!0,hash:l,platforms:c,type:u}=a,d=c??Lur,f=o??{token:null},h=C.useMemo(()=>(r==null?void 0:r.split(".").filter(Boolean).map(g=>$("field",g)))??[],[r]);return LI({queryKey:["datasetValue",e,t,n,r,l??null],queryFn:async()=>{const g=await bN(e,t,n,h,f);return{decoded:Ra(u,{platform:d})(g.data),sizeBytes:g.data.length}},enabled:s&&!!n&&!!r&&l!=null,...i})}function Rur(e,t,n,r,a){const o=C.useMemo(()=>a??{token:null},[a]),i=C.useMemo(()=>(r==null?void 0:r.split(".").filter(Boolean).map(s=>$("field",s)))??[],[r]);return C.useCallback(async()=>{if(!n||!r)return;const s=await bN(e,t,n,i,o),l=new Blob([new Uint8Array(s.data)],{type:"application/octet-stream"}),c=URL.createObjectURL(l),u=document.createElement("a");u.href=c,u.download=`${r.replace(/\./g,"_")}.beast2`,document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(c)},[e,t,n,r,i,o])}function m1e(e,t,n,r,a){const o=(a==null?void 0:a.requestOptions)??{token:null};return LI({queryKey:["taskDetails",e,t,n,r],queryFn:()=>KCe(e,t,n,r,o),enabled:!!t&&!!n&&!!r,...a==null?void 0:a.queryOverrides})}function _at(e){var t;return((t=e.kind)==null?void 0:t.type)==="some"?e.kind.value:null}function Pur(e){var t;return((t=e.metadata)==null?void 0:t.type)==="some"?e.metadata.value:null}const Aur={error:{bg:"bg.danger.subtle",titleColor:"fg.danger",messageColor:"fg.muted",detailsBg:"bg.muted",detailsColor:"fg.default"},warning:{bg:"bg.warning.subtle",titleColor:"fg.warning",messageColor:"fg.muted",detailsBg:"bg.muted",detailsColor:"fg.default"},info:{bg:"transparent",titleColor:"fg.muted",messageColor:"fg.subtle",detailsBg:"bg.muted",detailsColor:"fg.default"},loading:{bg:"transparent",titleColor:"fg.muted",messageColor:"fg.subtle",detailsBg:"bg.muted",detailsColor:"fg.default"}};function si({variant:e,title:t,message:n,details:r}){const a=Aur[e];return e==="info"||e==="loading"?p.jsx(V,{"data-status":e,height:"100%",width:"100%",display:"flex",alignItems:"center",justifyContent:"center",bg:a.bg,children:p.jsxs(W1,{gap:2,children:[e==="loading"&&p.jsx(yVn,{animate:!0,size:"52px"}),p.jsx(Ie,{color:a.titleColor,fontSize:e==="loading"?"sm":"lg",children:t}),n&&p.jsx(Ie,{color:a.messageColor,fontSize:"sm",children:n}),r&&p.jsxs(V,{position:"relative",mt:2,width:"100%",children:[p.jsx(qw,{display:"block",whiteSpace:"pre-wrap",p:4,pr:10,bg:a.detailsBg,color:a.detailsColor,borderRadius:"md",fontSize:"sm",overflow:"auto",maxHeight:"300px",children:r}),p.jsx(dK,{value:r,position:"absolute",top:1,right:1,children:p.jsx(fK,{asChild:!0,children:p.jsx(fc,{size:"xs",variant:"ghost","aria-label":"Copy error details",children:p.jsx(Uw,{copied:p.jsx(Ur,{icon:o7}),children:p.jsx(Ur,{icon:qX})})})})})]})]})}):p.jsxs(V,{"data-status":e,p:6,bg:a.bg,height:"100%",width:"100%",children:[p.jsx(Ie,{fontSize:"lg",fontWeight:"bold",color:a.titleColor,mb:4,children:t}),n&&p.jsx(Ie,{color:a.messageColor,mb:r?4:0,children:n}),r&&p.jsxs(V,{position:"relative",children:[p.jsx(qw,{display:"block",whiteSpace:"pre-wrap",p:4,pr:10,bg:a.detailsBg,color:a.detailsColor,borderRadius:"md",fontSize:"sm",overflow:"auto",maxHeight:"300px",children:r}),p.jsx(dK,{value:r,position:"absolute",top:1,right:1,children:p.jsx(fK,{asChild:!0,children:p.jsx(fc,{size:"xs",variant:"ghost","aria-label":"Copy error details",children:p.jsx(Uw,{copied:p.jsx(Ur,{icon:o7}),children:p.jsx(Ur,{icon:qX})})})})})]})]})}class Nur extends C.Component{constructor(t){super(t),this.state={error:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,n){console.error("[ErrorBoundary] render exception caught:",t,n.componentStack)}componentDidUpdate(t){this.state.error!==null&&t.children!==this.props.children&&this.setState({error:null})}render(){return this.state.error!==null?p.jsx(si,{variant:"error",title:"Rendering error",details:Mat(this.state.error)}):this.props.children}}function bg(...e){try{if(typeof localStorage>"u")return;const t=localStorage.getItem("e3-paging-debug");if(t===null||t==="off")return}catch{return}console.info("[e3-paging]",...e)}const v3=500;function $ur(e,t,n){if(e.type==="Array"){const a=e.value;return t.map((o,i)=>({node:$3.materialize(a,o),step:$("index",BigInt(n+i))}))}if(e.type==="Dict"){const{key:a,value:o}=e.value,i=zr(a),s=a.type==="String";return Array.from(t.entries()).map(([l,c],u)=>({node:$3.materialize(o,c),step:s?$("key",l):$("index",BigInt(n+u)),label:s?l:i(l)}))}const r=e.value;return Array.from(t.values()).map((a,o)=>({node:$3.materialize(r,a),step:$("index",BigInt(n+o))}))}function Iur(e){return e.type==="Array"?[]:e.type==="Dict"?new Map:new Set}const Dur=C.memo(function({apiUrl:t,repo:n,workspace:r,path:a,type:o,hash:i,sizeBytes:s,requestOptions:l,onDownload:c}){const u=_I(),[d,f]=C.useState(new Map),[h,g]=C.useState(null),[v,b]=C.useState(0),[y,x]=C.useState(null),S=C.useRef(new Set);C.useEffect(()=>{bg(`reset (path=${a}, hash=${i.slice(0,8)})`),f(new Map),g(null),x(null),S.current.clear()},[a,i]);const z=C.useCallback(O=>{if(S.current.has(O))return;S.current.add(O),b(H=>H+1),bg(`fetch p${O} (offset=${O*v3}, limit=${v3}, hash=${i.slice(0,8)})`);const j=a.split(".").filter(Boolean).map(H=>$("field",H)),B=l??{token:null};u.fetchQuery({queryKey:["datasetPage",t,n,r,a,i,`p${O}`],queryFn:()=>agt(t,n,r,j,{offset:O*v3,limit:v3,hash:i},B),staleTime:1/0}).then(H=>{const K=Ra(o)(H.data),U=$ur(o,K,H.offset);bg(`p${O} ok: count=${H.count} rows=${U.length} offset=${H.offset} total=${H.totalElements} segs=${H.segmentCount}`,U.length>0?`first=${JSON.stringify(U[0].label??"(derived)")}`:"(empty)"),H.count<v3&&H.offset+H.count<H.totalElements&&bg(`p${O} SHORT page: server clamped ${v3} → ${H.count}`),g({elements:H.totalElements,bytes:H.totalBytes}),f(Z=>new Map(Z).set(O,U))}).catch(H=>{bg(`p${O} FAILED:`,H),x(H instanceof Error?H:new Error(String(H)))}).finally(()=>{S.current.delete(O),b(H=>H-1)})},[u,t,n,r,a,i,l,o]);C.useEffect(()=>{h===null&&y===null&&z(0)},[h,y,z]);const M=C.useCallback((O,j)=>{const B=Math.max(0,Math.floor(O/v3)),H=Math.max(B,Math.ceil(j/v3)-1),K=[];for(let U=B;U<=H;U++)d.has(U)||K.push(U);bg(`need rows [${O}, ${j}) → pages ${B}..${H}, missing=[${K.join(",")}], inflight=[${[...S.current].join(",")}]`);for(const U of K)z(U)},[d,z]),L=C.useMemo(()=>({root:$3.materialize(o,Iur(o)),onEdit:A,onInsert:A,onRemove:A,onTag:A,style:P({height:P("100%"),maxHeight:A,openDepth:A,toolbar:P(!0)})}),[o]),R=C.useMemo(()=>h===null?null:{totalRows:h.elements,pageSize:v3,pages:d,onNeedRows:M},[h,d,M]);if(y!==null)return y instanceof h1&&(y.code==="dataset_too_large_unindexed"||y.code==="dataset_too_large")?p.jsxs(Vo,{height:"100%",direction:"column",align:"center",justify:"center",gap:3,p:6,children:[p.jsx(Ie,{fontSize:"lg",color:"fg.warning",fontWeight:"bold",children:"Too large to page"}),p.jsx(Ie,{color:"fg.muted",fontSize:"sm",textAlign:"center",maxW:"32rem",children:typeof y.details=="string"?y.details:"This dataset cannot be paged server-side."}),p.jsx(aP,{onClick:c,label:"Download value"})]}):p.jsx(si,{variant:"error",title:"Paged load failed",message:y.message});if(R===null||h===null)return p.jsx(si,{variant:"loading",title:"Loading..."});const N=o.type==="Dict"?"entries":"items";return p.jsxs(Vo,{direction:"column",height:"100%",overflow:"hidden",children:[p.jsxs(Vo,{px:4,py:2,gap:2,align:"center",flexShrink:0,borderBottom:"1px solid",borderColor:"border.subtle",children:[p.jsxs(Ie,{fontSize:"xs",color:"fg.muted",whiteSpace:"nowrap",children:[h.elements.toLocaleString()," ",N," · ",__(h.bytes>0?h.bytes:s)]}),v>0&&p.jsx(Ie,{fontSize:"xs",color:"fg.muted",children:"Loading…"}),p.jsx(Vo,{flex:1,justify:"flex-end",children:p.jsx(aP,{onClick:c})})]}),p.jsx(V,{flex:1,minHeight:0,overflow:"hidden",children:p.jsx(Aie,{value:L,storageKey:`${a}:page`,paging:R})})]})},(e,t)=>e.path===t.path&&e.workspace===t.workspace&&e.hash===t.hash&&e.sizeBytes===t.sizeBytes),Our=200*1024;function __(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function aP({onClick:e,label:t}){const[n,r]=C.useState(!1),a=async()=>{r(!0);try{await e()}finally{r(!1)}};return p.jsxs(fu,{size:"sm",variant:"outline",onClick:a,loading:n,loadingText:"Downloading...",children:[p.jsx(Ur,{icon:oKn}),t??"Download"]})}const Lat=C.memo(function({apiUrl:t,repo:n,workspace:r,path:a,requestOptions:o,sizeLimit:i=Our,pollInterval:s,editable:l=!1}){var c;const u=Tat(t,n,r,a,{...o!=null&&{requestOptions:o},...s!==void 0&&{pollInterval:s}}),d=u.data,f=(d==null?void 0:d.refType)==="value"&&d.hash!==null,h=(d==null?void 0:d.sizeBytes)??0,g=f&&h>i,v=f&&!g,b=Eat(t,n,r,a,{...o!=null&&{requestOptions:o},type:d==null?void 0:d.type,hash:(d==null?void 0:d.hash)??null,enabled:v,queryOverrides:{placeholderData:TVn}}),y=Rur(t,n,r,a,o),x=_ur(t,n,r,o),S=_I(),z=d==null?void 0:d.type,M=(c=b.data)==null?void 0:c.decoded,L=C.useCallback(async j=>{if(r==null||a==null||z===void 0)return;const B=a.split(".").filter(Boolean).map(K=>$("field",K)),H=Ei(z)(j);await x.mutateAsync({path:B,data:H}),await S.invalidateQueries({queryKey:["datasetStatus",t,n,r,a]})},[t,n,r,a,z,x,S]),R=C.useMemo(()=>{if(z===void 0||M===void 0)return null;const j=$3.materialize(z,M),B=l?{onEdit:P((H,K)=>L($3.applyEdit(z,M,H,{kind:"edit",leaf:K}))),onInsert:P(H=>L($3.applyEdit(z,M,H,{kind:"insert"}))),onRemove:P(H=>L($3.applyEdit(z,M,H,{kind:"remove"}))),onTag:P((H,K)=>L($3.applyEdit(z,M,H,{kind:"tag",tag:K})))}:{onEdit:A,onInsert:A,onRemove:A,onTag:A};return{root:j,...B,style:P({height:P("100%"),maxHeight:A,openDepth:A,toolbar:P(!0)})}},[z,M,l,L]);if(u.isLoading)return p.jsx(si,{variant:"loading",title:"Loading..."});if(u.error){const{message:j,details:B}=Eur(u.error);return p.jsx(si,{variant:"error",title:"Error",message:j,details:B??Mat(u.error)})}if(!d)return p.jsx(si,{variant:"info",title:"No status"});if(!f)return p.jsx(si,{variant:"info",title:"No data available",message:"Waiting for a value to be set"});if(g)return z!==void 0&&(z.type==="Array"||z.type==="Set"||z.type==="Dict")&&r!=null&&a!=null&&d.hash!=null?p.jsx(Dur,{apiUrl:t,repo:n,workspace:r,path:a,type:z,hash:d.hash,sizeBytes:h,...o!=null&&{requestOptions:o},onDownload:y}):p.jsxs(Vo,{height:"100%",direction:"column",align:"center",justify:"center",layerStyle:"banner.stale",borderRadius:"0",gap:3,p:6,children:[p.jsx(Ie,{fontSize:"lg",color:"fg.warning",fontWeight:"bold",children:"Value too large to display"}),p.jsxs(Ie,{color:"fg.muted",fontSize:"sm",children:["The data is ",__(h),", which exceeds the ",__(i)," display limit."]}),p.jsx(aP,{onClick:y,label:"Download value"})]});if(b.isLoading||!b.data)return p.jsx(si,{variant:"loading",title:"Loading..."});if(b.error)return p.jsx(si,{variant:"error",title:"Decode failed",message:b.error.message});const N=z===void 0||M===void 0?null:z.type==="Array"?M.length:z.type==="Set"||z.type==="Dict"?M.size:null,O=N===null?"":`${N.toLocaleString()} ${(z==null?void 0:z.type)==="Dict"?"entries":"items"} · `;return p.jsxs(Vo,{direction:"column",height:"100%",overflow:"hidden",children:[p.jsxs(Vo,{px:4,py:2,justify:"flex-end",flexShrink:0,borderBottom:"1px solid",borderColor:"border.subtle",children:[p.jsxs(Ie,{fontSize:"xs",color:"fg.muted",mr:2,alignSelf:"center",children:[O,__(h)]}),p.jsx(aP,{onClick:y})]}),p.jsx(V,{flex:1,minHeight:0,overflow:"hidden",children:R!==null&&p.jsx(Aie,{value:R,storageKey:a??"value"})})]})});C.memo(function({apiUrl:t,repo:n,workspace:r,path:a,requestOptions:o}){const i=a.replace(/^\.inputs\./,"");return p.jsxs(V,{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden",children:[p.jsx(Vo,{px:4,py:2,borderBottom:"1px solid",borderColor:"border.subtle",bg:"bg.surface",align:"center",justify:"space-between",children:p.jsx(Ie,{fontSize:"sm",fontWeight:"medium",color:"fg",children:i})}),p.jsx(V,{flex:1,overflow:"hidden",minHeight:0,children:p.jsx(Lat,{apiUrl:t,repo:n,workspace:r,path:a,editable:!0,...o!=null&&{requestOptions:o}})})]})},(e,t)=>e.path===t.path&&e.workspace===t.workspace);function jur(e){return e.map(t=>t.value).join(".")}const Fur=C.memo(function({task:t,config:n,pollInterval:r=1e3,bare:a=!1}){var o,i;const s=yKn(),l=SJe(),c=(n==null?void 0:n.apiUrl)??(s==null?void 0:s.apiUrl)??null,u=(n==null?void 0:n.repo)??(s==null?void 0:s.repo)??"default",d=(n==null?void 0:n.workspace)??(s==null?void 0:s.workspace)??null,h={token:(n==null?void 0:n.token)??(s==null?void 0:s.token)??null},g=m1e(c??"",u,d,t,{requestOptions:h}),v=g.data,b=v?_at(v):null,y=b==="ui",x=C.useMemo(()=>{if(!v||!y)return null;const B=Pur(v);return B?l0t(B):{paths:[],functions:[],records:[]}},[v,y]),S=v?jur(v.output):null,z=C.useMemo(()=>x&&d?x.paths.map(B=>({workspace:d,path:B})):[],[x,d]),{loading:M,error:L}=xKn(z),R=C.useMemo(()=>x?[...mN,...Hte,...Vte,...Ete,...Die,...Wte,...Ute,...qte,...g1e,...sWn(x),...hWn(x.functions),...gKn(x.records)]:void 0,[x]);C.useEffect(()=>{if(!(!l||!x||!d)){for(const B of x.paths)l.setRefetchInterval(d,B,r);return()=>{for(const B of x.paths)l.clearRefetchInterval(d,B)}}},[l,x,d,r]);const N=Tat(c??"",u,d,S,{requestOptions:h}),O=Eat(c??"",u,d,S,{requestOptions:h,type:(o=N.data)==null?void 0:o.type,hash:((i=N.data)==null?void 0:i.hash)??null,...R&&{platforms:R}}),j=C.useMemo(()=>oht(),[t]);return c?g.isLoading?p.jsx(si,{variant:"loading",title:"Loading task..."}):g.error?p.jsx(si,{variant:"error",title:"Error",message:g.error.message}):v?y?L?p.jsx(si,{variant:"error",title:"Preload failed",message:L.message}):M?p.jsx(si,{variant:"loading",title:"Loading datasets..."}):N.isLoading||!N.data?p.jsx(si,{variant:"loading",title:"Loading..."}):N.data.refType!=="value"?p.jsx(si,{variant:"info",title:"No output yet",message:"Task has not produced a value"}):O.isLoading||!O.data?p.jsx(si,{variant:"loading",title:"Loading..."}):O.error?p.jsx(si,{variant:"error",title:"Decode failed",message:O.error.message}):p.jsx(OZe,{store:j,children:p.jsx(Nur,{children:p.jsx(V,{height:"100%",overflow:a?void 0:"auto",p:a?void 0:"4",minH:a?0:void 0,children:p.jsx(mn,{value:O.data.decoded,storageKey:S??t})})})}):p.jsx(si,{variant:"error",title:"Not a UI task",message:`Task "${t}" has kind "${b??"(none)"}"`}):p.jsx(si,{variant:"info",title:"No task",message:`Task "${t}" not found`}):p.jsx(si,{variant:"error",title:"Configuration error",message:"No apiUrl available — render UITaskPreview inside an <E3Provider> or pass a config prop."})});function Bur({text:e,lineMatches:t,currentMatchIndex:n,globalMatches:r}){if(t.length===0)return p.jsx(p.Fragment,{children:e||" "});const a=[];let o=0;return t.forEach((i,s)=>{i.start>o&&a.push(p.jsx("span",{children:e.slice(o,i.start)},`t${s}`));const c=r.findIndex(u=>u.lineIndex===i.lineIndex&&u.start===i.start)===n;a.push(p.jsx("span",{style:{backgroundColor:c?"#f59e0b":"#fbbf24",color:"#000",borderRadius:"2px",outline:c?"2px solid #f59e0b":void 0},children:e.slice(i.start,i.end)},`m${s}`)),o=i.end}),o<e.length&&a.push(p.jsx("span",{children:e.slice(o)},"end")),p.jsx(p.Fragment,{children:a})}function Vur({content:e,tabs:t}){const n=C.useRef(null),[r,a]=C.useState(!1),[o,i]=C.useState(""),[s,l]=C.useState(0),[c,u]=C.useState(!0),[d,f]=C.useState(!1),h=C.useMemo(()=>e?e.split(`
|
|
2230
|
+
`);return p.jsxs(V,{layerStyle:"banner.stale",display:"flex",flexDirection:"column",gap:"2",mt:"3",children:[p.jsxs(V,{display:"inline-flex",alignItems:"flex-start",gap:"2",color:"fg.danger",children:[p.jsx(V,{as:"span",mt:"0.5",fontSize:"12px",flexShrink:"0",children:p.jsx(Ur,{icon:rc})}),p.jsxs(Ie,{textStyle:"body.sm",color:"fg.default",children:[p.jsx(Ie,{as:"span",fontWeight:"bold",children:"Could not run the experiment."})," ",e.message]})]}),t&&p.jsx(V,{as:"pre",m:"0",p:"2",maxH:"160px",overflow:"auto",bg:"bg.canvas",borderRadius:"md",borderWidth:"1px",borderColor:"border.subtle",fontFamily:"mono",fontSize:"11px",color:"fg.muted",whiteSpace:"pre-wrap",children:t})]})}function Rve({button:e,variant:t,label:n,onClick:r,disabled:a,pulse:o=!1}){return p.jsx(V,{as:"button",css:e({variant:t,size:"sm"}),onClick:a?void 0:r,"aria-disabled":a||void 0,opacity:a?.5:void 0,cursor:a?"not-allowed":"pointer",animation:o&&!a?"pulse 1.6s infinite":void 0,children:n})}function mat({tab:e}){const t=ga({key:"skeleton"}),n=(a,o)=>p.jsx(V,{css:t({variant:"line"}),width:a,height:o}),r=a=>p.jsx(V,{css:t({variant:"block"}),width:"100%",minHeight:a});return p.jsxs(V,{p:"4.5",display:"flex",flexDirection:"column",gap:"4",children:[e==="answer"&&p.jsxs(p.Fragment,{children:[p.jsxs(V,{display:"flex",gap:"4.5",alignItems:"flex-end",children:[p.jsxs(V,{display:"flex",flexDirection:"column",gap:"2",children:[n("64px","10px"),n("120px","32px")]}),n("170px","24px")]}),r("120px"),r("120px")]}),e==="trust"&&p.jsxs(p.Fragment,{children:[n("70%","14px"),r("160px")]}),e==="dose"&&p.jsxs(p.Fragment,{children:[r("240px"),p.jsxs(V,{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"3",children:[r("90px"),r("90px")]})]}),e==="validate"&&p.jsxs(p.Fragment,{children:[p.jsxs(V,{display:"flex",gap:"5",alignItems:"flex-end",children:[n("120px","32px"),n("200px","10px")]}),r("110px"),r("150px")]})]})}function W0r(){const e=ga({key:"skeleton"}),t=(r,a)=>p.jsx(V,{css:e({variant:"line"}),width:r,height:a}),n=r=>p.jsx(V,{css:e({variant:"block"}),width:"100%",minHeight:r});return p.jsxs(V,{layerStyle:"surface.frameless",overflow:"visible",children:[p.jsxs(V,{layerStyle:"header.bar",display:"flex",alignItems:"center",gap:"3.5",children:[t("260px","20px"),p.jsx(V,{flex:"1"}),t("72px","16px")]}),p.jsxs(V,{display:"grid",gridTemplateColumns:"304px minmax(0,1fr)",css:{"@media (max-width: 640px)":{gridTemplateColumns:"1fr"}},alignItems:"start",children:[p.jsx(V,{borderRightWidth:"1px",borderColor:"border.subtle",p:"4.5",display:"flex",flexDirection:"column",gap:"5",children:[0,1,2,3].map(r=>p.jsxs(V,{display:"flex",flexDirection:"column",gap:"2",children:[t("150px","12px"),n("40px")]},r))}),p.jsx(mat,{tab:"answer"})]})]})}const U0r=it(Sf.Component.schema),q0r=C.memo(function({value:t}){var n,r,a;const o=t,i=ga({key:"button"}),s=ga({key:"chip"}),l=ga({key:"badge"}),c=en({key:"barStrip"})({}),u=en({key:"status"}),d=en({key:"eyebrowRow"})({}),f=m2().getConfig().workspace??"",h=yU(o.data),g=yU(o.journal.type==="some"?o.journal.value:null),v=_(o.columnMeta),b=_(o.subject)??O0r,y=_(o.readonly)??!1,x=yU(o.configs),S=C.useMemo(()=>x.value??[],[x.value]),[z,M]=C.useState(void 0),L=C.useMemo(()=>S.find(st=>st.id===z)??S[0],[S,z]);C.useEffect(()=>{const st=S[0];z===void 0&&st!==void 0&&M(st.id)},[S,z]);const R=C.useMemo(()=>{const st=new Map;for(const dn of S){const Pn=_(dn.group)??"Questions",Hn=st.get(Pn);Hn?Hn.push(dn):st.set(Pn,[dn])}return[...st].map(([dn,Pn])=>({label:dn,items:Pn}))},[S]),{columns:N,rowArrayType:O}=V0r(f,o.data.source),[j,B]=C.useState(void 0),[H,K]=C.useState([]),[U,Z]=C.useState(!1),G=C.useRef(void 0);C.useEffect(()=>{const st=L==null?void 0:L.id;if(st===G.current)return;const dn=G.current!==void 0;G.current=st,B(L==null?void 0:L.spec),K(_(L==null?void 0:L.population)??[]);const Pn=(L==null?void 0:L.result.type)==="some",Hn=o.experiment.type==="some";Z(dn&&Hn&&!Pn)},[L,o.experiment.type]);const W=j,J=H,ae=C.useMemo(()=>h.value?J.length?h.value.filter(st=>H0r(st,J)):h.value:null,[h.value,J]),ne=C.useMemo(()=>N.filter(st=>st.kind!=="other").map(st=>{var dn;return{fieldId:st.name,label:_((dn=v==null?void 0:v.get(st.name))==null?void 0:dn.label)??st.name,kind:st.kind}}),[N,v]),Y=C.useMemo(()=>O?[O,Sf.Types.Config]:null,[O]),te=dve(o.experiment.type==="some"?o.experiment.value.name:null,Y,Sf.Types.Result),ie=o.experiment.type==="some",ue=te.result??_(L==null?void 0:L.result)??null,oe=o.design.type==="some",ve=C.useMemo(()=>O?[O,Sf.Types.Config,Sf.Types.Result,Sf.Types.DesignConfig]:null,[O]),se=dve(o.design.type==="some"?o.design.value.name:null,ve,Sf.Types.Design),pe=C.useRef(null),[de,ge]=C.useState(null),ye=C.useCallback(()=>{!ae||!W||(pe.current=W,te.call(ae,W))},[ae,W,te]),me=C.useRef(!1),Me=L!==void 0&&L.result.type==="some";C.useEffect(()=>{if(!me.current){if(Me||!ie){me.current=!0;return}if(!(!ae||!W||!O)){if(te.result!==null||te.status==="running"){me.current=!0;return}te.status==="idle"&&(me.current=!0,!(ae.length>j0r)&&ye())}}},[Me,ie,ae,W,O,te.result,te.status,ye]),C.useEffect(()=>{te.result!==null&&ge(pe.current)},[te.result]);const Te=C.useCallback(st=>{y||(o.experiment.type==="some"&&Z(!0),B(st))},[y,o.experiment.type]),Be=C.useCallback(st=>{y||(o.experiment.type==="some"&&Z(!0),K(st))},[y,o.experiment.type]),ht=C.useCallback(st=>{M(st.id)},[]),De=C.useCallback(()=>{ye(),Z(!1)},[ye]),Qe=C.useCallback(async()=>{if(!W||!te.result)return;const st=te.result,dn={config:W,verdict:st.verdict,naive:st.naive,adjusted:st.adjusted.type==="some"?P(st.adjusted.value.effect):A,committed_at:new Date,committed_by:"you",preset:z!==void 0?P(z):A};g.mutate([dn,...g.value??[]]);try{await g.commit(),Z(!1)}catch{}},[W,te.result,g,z]),[bt,Ve]=C.useState(((n=_(o.defaultTab))==null?void 0:n.type)??"answer"),[ut,_t]=C.useState(!0),Ft=C.useMemo(()=>new Date,[]),wt=(ae==null?void 0:ae.length)??0,Lt=C.useMemo(()=>{const st=de??W,dn=Pn=>{var Hn;return Pn?_((Hn=v==null?void 0:v.get(Pn))==null?void 0:Hn.label)??Pn:""};return{treatment:dn(st==null?void 0:st.treatment),outcome:dn(st==null?void 0:st.outcome),subject:b.one,subjects:b.many}},[de,W,v,b]),Jt=C.useMemo(()=>W?$0r(W,de??W,N,ue,g.value,v,wt,Ft,b):null,[W,de,N,ue,g.value,v,wt,Ft,b]),Dt=C.useMemo(()=>({alpha:A,target_power:A,materiality:A,treated_shares:P([.5,.3])}),[]),Et=_(L==null?void 0:L.design)??null,Gt=C.useRef(null);C.useEffect(()=>{var st;bt!=="validate"||!oe||se.pending||Et!==null||!ae||!W||!ue||((st=Gt.current)==null?void 0:st.result)!==ue&&(Gt.current={result:ue,config:de??W},se.call(ae,de??W,ue,Dt))},[bt,oe,Et,ae,W,de,ue,se,Dt]);const Ke=C.useMemo(()=>Et!==null&&ue!==null&&W?Lve(Et,ue,de??W,v):se.result&&Gt.current?Lve(se.result,Gt.current.result,Gt.current.config,v):null,[Et,ue,W,de,se.result,v]),Se=Et!==null&&ue!==null||se.result!==null&&((r=Gt.current)==null?void 0:r.result)===ue&&!se.pending;if(!W||!Jt){const st=te.status==="failed",dn=!x.error&&S.length===0,Pn=h.error?"dataset":x.error?"configs":g.error?"journal":null,Hn=h.error??x.error??g.error,pr=Hn instanceof Error?Hn.message:Hn!=null?String(Hn):null;return pr?p.jsx(V,{layerStyle:"surface.frameless",p:"6",children:p.jsxs(Ie,{textStyle:"body.sm",color:"fg.danger",children:["Couldn’t load the experiment ",Pn,": ",pr]})}):dn?p.jsx(V,{layerStyle:"surface.frameless",p:"6",children:p.jsx(Ie,{textStyle:"body.sm",color:"fg.muted",children:"No questions to show — bind a non-empty configs list."})}):st&&te.error?p.jsx(V,{layerStyle:"surface.frameless",p:"6",children:p.jsx(MU,{error:te.error})}):p.jsx(W0r,{})}const{spec:Re,answer:qe,refusal:Ye,overlap:$e,refute:lt,dose:Pe,journal:ot,verdict:kt}=Jt,Mt=_((a=v==null?void 0:v.get(Re.outcome))==null?void 0:a.higherIsBetter),At=u({status:"success",size:"sm"}),fn=st=>p.jsx(V,{css:c.root,children:st.map((dn,Pn)=>p.jsxs(V,{css:c.row,children:[p.jsx(Ie,{css:c.label,textStyle:"mono.sm",color:"fg.default",truncate:!0,children:dn.label}),p.jsx(V,{css:c.track,children:p.jsx(V,{css:c.fill,width:`${Math.round(dn.frac*100)}%`,bg:T_(dn.tone)})}),p.jsx(Ie,{css:c.value,children:dn.value})]},Pn))}),rt=o.journal.type==="some",ln=!y&&ie,Mn=!y&&ie&&rt,Jn=!h.value||te.pending,Er=te.status!=="succeeded"||te.pending||U,_r=te.status==="failed"&&te.error,fr=ue!==null&&!te.pending&&!_r,Vr=S.some(st=>st.design.type==="some"),wr=oe||Vr,ar=["answer","trust",..._(W.dose_feature)!==void 0||(ue==null?void 0:ue.dose_response.type)==="some"?["dose"]:[],...wr?["validate"]:[]],On=ar.includes(bt)?bt:"answer";return p.jsx(h0r,{on:ut,vars:Lt,children:p.jsxs(V,{layerStyle:"surface.frameless",overflow:"visible",children:[p.jsxs(V,{layerStyle:"header.bar",display:"flex",alignItems:"center",gap:"3.5",children:[S.length>1?p.jsxs(fm,{children:[p.jsx(Ore,{asChild:!0,children:p.jsxs(V,{as:"button",bg:"transparent",border:"0",p:"0",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"2",textAlign:"start",children:[p.jsxs(Ie,{textStyle:"title.card",color:"fg.muted",children:["Does ",p.jsx(Ie,{as:"span",color:"brand.solid",fontWeight:"bold",children:Re.treatmentLabel})," change ",p.jsx(Ie,{as:"span",color:"brand.solid",fontWeight:"bold",children:Re.outcomeLabel}),"?"]}),p.jsx(V,{as:"span",color:"fg.subtle",fontSize:"11px",lineHeight:"1",children:p.jsx(Ur,{icon:hS})})]})}),p.jsx(go,{children:p.jsx(pm,{children:p.jsx(hm,{minW:"280px",children:R.map(st=>p.jsxs(jAe,{children:[st.label!=="Questions"&&p.jsx(FAe,{textStyle:"caption.eyebrow",fontSize:"9px",children:st.label}),st.items.map(dn=>p.jsxs(ep,{value:dn.id,onClick:()=>ht(dn),gap:"2",children:[p.jsx(V,{as:"span",width:"14px",flexShrink:"0",color:"brand.fg",children:dn.id===(L==null?void 0:L.id)&&p.jsx(Ur,{icon:o7,style:{fontSize:"10px"}})}),dn.label]},dn.id))]},st.label))})})})]}):p.jsx(Ie,{textStyle:"title.card",color:"fg.muted",children:p.jsxs(Di,{id:"header",children:["Does ",p.jsx(Ie,{as:"span",color:"brand.solid",fontWeight:"bold",children:Re.treatmentLabel})," change ",p.jsx(Ie,{as:"span",color:"brand.solid",fontWeight:"bold",children:Re.outcomeLabel}),"?"]})}),p.jsx(V,{flex:"1"}),y&&p.jsx(V,{as:"span",css:l({variant:"plain",size:"sm"}),textTransform:"none",letterSpacing:"normal",children:"View only"}),p.jsxs(V,{as:"span",css:At.root,children:[p.jsx(V,{as:"span",css:At.indicator}),p.jsx(V,{as:"span",css:At.label,children:U?`${wt} rows`:Re.dataLabel})]}),p.jsx(v0r,{on:ut,onToggle:()=>_t(st=>!st)}),ln&&p.jsx(Rve,{button:i,variant:"solid",label:"Run",onClick:De,disabled:Jn,pulse:U}),Mn&&p.jsx(Rve,{button:i,variant:"ghost",label:"Commit",onClick:Qe,disabled:Er})]}),p.jsxs(V,{display:"grid",gridTemplateColumns:"304px minmax(0,1fr)",css:{"@media (max-width: 640px)":{gridTemplateColumns:"1fr"}},alignItems:"start",children:[p.jsxs(V,{borderRightWidth:"1px",borderColor:"border.subtle",children:[p.jsxs(QT,{n:1,title:"What did you change?",help:"step_treatment",children:[p.jsx(Pve,{column:Re.treatment,kind:Re.treatmentKind,badge:l,button:i,readonly:y,choices:N.filter(st=>st.kind==="boolean"||st.kind==="integer").map(st=>st.name),onPick:st=>Te({...W,treatment:st})}),p.jsxs(Ie,{textStyle:"caption",mt:"1.5",children:["Treated = ",p.jsx(Ie,{as:"span",color:"fg.default",fontWeight:"semibold",children:Re.comparison})]})]}),p.jsx(QT,{n:2,title:"What did you want it to improve?",help:"step_outcome",children:p.jsx(Pve,{column:Re.outcome,kind:Re.outcomeKind,badge:l,button:i,readonly:y,choices:N.filter(st=>st.kind==="float"||st.kind==="integer").map(st=>st.name),onPick:st=>Te({...W,outcome:st})})}),p.jsx(QT,{n:3,title:"What else was different?",help:"step_confounders",children:p.jsxs(V,{layerStyle:"frame.flat",children:[p.jsx(V,{maxH:"216px",overflowY:"auto",children:Re.confounders.map((st,dn)=>p.jsxs(V,{display:"grid",gridTemplateColumns:y?"1fr 78px":"1fr 78px 16px",gap:"2.5",alignItems:"center",px:"2.5",py:"2.5",borderTopWidth:dn?"1px":"0",borderColor:"border.subtle",children:[p.jsxs(V,{children:[p.jsx(Ie,{textStyle:"mono.sm",fontWeight:"semibold",color:"fg.default",children:st.col}),p.jsx(Ie,{textStyle:"caption",lineHeight:"1.35",mt:"px",children:st.reason})]}),p.jsxs(V,{children:[p.jsx(V,{css:c.track,children:p.jsx(V,{css:c.fill,width:`${Math.round(st.imbalance*100)}%`,bg:T_(st.tone)})}),p.jsx(Ie,{textStyle:"caption.eyebrow",fontSize:"9px",textAlign:"center",mt:"1.5",children:p.jsx(Di,{id:"confounder_imbalance",children:st.level})})]}),!y&&p.jsx(V,{as:"button",css:i({variant:"ghost",size:"xs"}),px:"0",minW:"16px",display:"inline-flex",alignItems:"center",justifyContent:"center","aria-label":`Remove ${st.col}`,onClick:()=>Te({...W,common_causes:W.common_causes.filter(Pn=>Pn!==st.col),categorical:W.categorical.type==="some"?P(W.categorical.value.filter(Pn=>Pn!==st.col)):A}),children:p.jsx(Ur,{icon:E9,style:{fontSize:"11px"}})})]},dn))}),!y&&Re.suggestion&&p.jsx(vat,{choices:N.filter(st=>!new Set([W.treatment,W.outcome,...W.common_causes]).has(st.name)).map(st=>st.name),onPick:st=>Te({...W,common_causes:[...W.common_causes,st]}),children:p.jsxs(V,{as:"button",css:i({variant:"ghost",size:"sm"}),justifyContent:"flex-start",width:"100%",color:"brand.fg",fontFamily:"mono",display:"inline-flex",alignItems:"center",gap:"2",children:[p.jsx(Ur,{icon:DI,style:{fontSize:"9px"}}),"add another"]})})]})}),p.jsx(QT,{n:4,title:`Which ${b.many}?`,help:"step_population",children:p.jsx(X0r,{fields:ne,population:J,onChange:Be,chip:s,button:i,readonly:y,subjectMany:b.many})}),p.jsxs(V,{as:"details",borderTopWidth:"1px",borderColor:"border.subtle",children:[p.jsxs(V,{as:"summary",textStyle:"caption.eyebrow",cursor:"pointer",px:"4.5",py:"2.5",display:"flex",alignItems:"center",gap:"1.5",css:{listStyle:"none","&::-webkit-details-marker":{display:"none"}},children:[p.jsx(V,{as:"span",display:"inline-flex",color:"fg.subtle",fontSize:"10px",transition:"transform 180ms ease",transform:"rotate(-90deg)",css:{"details[open] > summary > &":{transform:"rotate(0deg)"}},children:p.jsx(Ur,{icon:hS})}),"Advanced"]}),p.jsxs(V,{px:"4.5",pb:"3.5",pt:"0.5",children:[p.jsx(Ave,{label:"How to compare",help:"adv_method",left:"regression",right:"reweighting",active:Re.method==="reweighting"?"right":"left",readonly:y,onPick:st=>Te({...W,method:P(st==="right"?$("propensity_score_weighting",{weighting_scheme:A}):$("linear_regression",null))})}),p.jsx(Ave,{label:"Answer for",help:"adv_estimand",left:"all",right:"only treated",active:Re.target==="treated"?"right":"left",readonly:y,onPick:st=>Te({...W,estimand:P($(st==="right"?"att":"ate",null))}),last:!0})]})]})]}),p.jsxs(V,{minW:"0",children:[p.jsxs(V,{display:"flex",alignItems:"center",px:"4",borderBottomWidth:"1px",borderColor:"border.subtle",role:"tablist","aria-label":"Result views",onKeyDown:st=>{var dn;const Pn=ar.indexOf(On);let Hn=Pn;if(st.key==="ArrowRight")Hn=(Pn+1)%ar.length;else if(st.key==="ArrowLeft")Hn=(Pn-1+ar.length)%ar.length;else if(st.key==="Home")Hn=0;else if(st.key==="End")Hn=ar.length-1;else return;st.preventDefault(),Ve(ar[Hn]),(dn=st.currentTarget.querySelectorAll('[role="tab"]')[Hn])==null||dn.focus()},children:[ar.map(st=>{const dn=On===st,Pn=st==="answer"?"tab_answer":st==="trust"?"tab_trust":st==="dose"?"tab_dose":"tab_validate",Hn=st==="answer"?"The answer":st==="trust"?"Can we trust it?":st==="dose"?"How much?":"Prove it";return p.jsx(V,{as:"button",role:"tab","aria-selected":dn,tabIndex:dn?0:-1,onClick:()=>Ve(st),cursor:"pointer",fontSize:"xs",fontWeight:"semibold",px:"3.5",py:"3",mb:"-1px",color:dn?"brand.fg":"fg.muted",borderBottomWidth:"2px",borderColor:dn?"brand.solid":"transparent",_hover:{color:dn?"brand.fg":"fg.default"},_focusVisible:{outline:"2px solid",outlineColor:"brand.solid",outlineOffset:"-2px"},children:p.jsx(Di,{id:Pn,children:Hn})},st)}),te.pending&&p.jsxs(V,{ml:"auto",display:"inline-flex",alignItems:"center",gap:"2",color:"fg.muted",pr:"1",children:[p.jsx(CL,{size:"xs",borderWidth:"1.5px",color:"brand.solid"}),p.jsx(Ie,{textStyle:"caption.eyebrow",children:"Running…"})]})]}),_r?p.jsx(V,{px:"4.5",pt:"4.5",children:p.jsx(MU,{error:te.error})}):fr?p.jsxs(p.Fragment,{children:[U&&p.jsxs(V,{layerStyle:"banner.stale",display:"flex",alignItems:"center",gap:"2",mx:"4.5",mt:"4.5",children:[p.jsx(V,{as:"span",color:"fg.warning",flexShrink:"0",fontSize:"12px",children:p.jsx(Ur,{icon:rc})}),p.jsxs(Ie,{textStyle:"body.sm",color:"fg.default",children:[p.jsx(Ie,{as:"span",fontWeight:"bold",children:"Showing the previous setup."})," Hit Run to update these results for your edits."]})]}),On==="answer"&&qe&&p.jsx(G0r,{a:qe,verdict:kt,narrative:Jt.narrative,checks:(lt==null?void 0:lt.checks)??null,onGoTrust:()=>Ve("trust"),subjectMany:b.many,higherBetter:Mt,badge:l,barList:fn}),On==="answer"&&!qe&&Ye&&p.jsx(K0r,{refusal:Ye,overlap:$e,naiveValue:(ue==null?void 0:ue.naive)??0,outcome:Re.outcomeLabel}),On==="trust"&<&&p.jsxs(V,{p:"4.5",children:[p.jsx(Ie,{textStyle:"body.sm",color:"fg.muted",mb:"3.5",children:p.jsx(Di,{id:"trust_intro",children:"Before trusting the answer we tried to break it — colour shows pass / caution."})}),p.jsx(V,{layerStyle:"frame.flat",children:lt.checks.map((st,dn)=>{const Pn=u({status:st.passed?"success":"warning",size:"sm"});return p.jsxs(V,{display:"grid",gridTemplateColumns:"auto 1fr minmax(96px,auto)",gap:"2.5",alignItems:"start",px:"3.5",py:"2.5",borderTopWidth:dn?"1px":"0",borderColor:"border.subtle",children:[p.jsx(V,{as:"span",css:Pn.root,mt:"1",children:p.jsx(V,{as:"span",css:Pn.indicator})}),p.jsxs(V,{children:[p.jsx(Ie,{textStyle:"body.sm",fontWeight:"semibold",color:"fg.default",children:p.jsx(Di,{id:st.help,children:st.name})}),p.jsx(Ie,{textStyle:"caption",lineHeight:"1.45",mt:"0.5",children:st.desc})]}),p.jsxs(V,{display:"inline-flex",alignItems:"center",justifyContent:"flex-end",gap:"1.5",whiteSpace:"nowrap",color:st.passed?"fg.success":"fg.warning",children:[p.jsx(Ie,{textStyle:"mono.sm",fontWeight:"bold",fontVariantNumeric:"tabular-nums",children:st.value}),p.jsx(Ur,{icon:st.passed?o7:rc,style:{fontSize:"11px"}})]})]},dn)})}),lt.sens&&p.jsxs(V9,{children:[p.jsx(Y3,{help:"sensitivity",children:"Effect as a hidden cause is made stronger"}),p.jsx(XZ,{lo:lt.sens.lo,mid:lt.sens.mid,hi:lt.sens.hi,zero:0,tone:"brand",xTicks:lt.sens.xTicks,yTicks:lt.sens.yTicks,marks:lt.sens.marks,height:lt.sens.marks.length?148:132})]})]}),On==="trust"&&!lt&&((ue==null?void 0:ue.adjusted.type)==="some"?p.jsxs(V,{p:"4.5",children:[p.jsxs(V,{display:"inline-flex",alignItems:"center",gap:"2",mb:"2",color:"fg.muted",children:[p.jsx(Ur,{icon:rc,style:{fontSize:"13px"}}),p.jsx(Ie,{textStyle:"body.sm",fontWeight:"semibold",color:"fg.default",children:"Stress tests not run"})]}),p.jsx(Ie,{textStyle:"body.sm",color:"fg.muted",lineHeight:"1.5",children:"This answer came without a robustness summary — the stress tests weren’t run for this question, so there’s nothing to report here."})]}):p.jsxs(V,{p:"4.5",children:[p.jsxs(V,{display:"inline-flex",alignItems:"center",gap:"2",mb:"2",color:"fg.muted",children:[p.jsx(Ur,{icon:rc,style:{fontSize:"13px"}}),p.jsx(Ie,{textStyle:"body.sm",fontWeight:"semibold",color:"fg.default",children:"Nothing to stress-test"})]}),p.jsxs(Ie,{textStyle:"body.sm",color:"fg.muted",lineHeight:"1.5",children:["There’s no adjusted estimate to try to break — the experiment couldn’t produce one (see the ",p.jsx(Ie,{as:"span",fontWeight:"semibold",color:"fg.default",children:"Answer"})," tab for why)."]})]})),On==="dose"&&Pe&&p.jsxs(V,{p:"4.5",children:[p.jsx(Ie,{textStyle:"body.sm",color:"fg.muted",mb:"3.5",children:p.jsx(Di,{id:"tab_dose",children:Pe.framing})}),p.jsxs(V9,{mt:"0",children:[p.jsxs(Y3,{help:"dose_curve",children:[Pe.outcome," gained vs. ",Pe.feature]}),p.jsx(XZ,{lo:Pe.lo,mid:Pe.mid,hi:Pe.hi,tone:"pos",xTicks:Pe.xTicks,yTicks:Pe.yTicks,marks:Pe.marks.map(st=>({at:st.at,label:st.label,tone:st.tone,help:st.help})),height:256})]}),p.jsxs(V,{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"3",mt:"3",children:[p.jsxs(V,{layerStyle:"card",p:"3.5",borderRadius:"lg",children:[p.jsx(Y3,{help:"dose_reco",children:"Recommended"}),p.jsxs(V,{display:"flex",flexDirection:"column",gap:"0.5",children:[p.jsx(Ie,{textStyle:"caption.eyebrow",children:Pe.recoLabel}),p.jsxs(V,{display:"flex",alignItems:"baseline",gap:"2",children:[p.jsx(Ie,{textStyle:"mono-kpi",fontFamily:"heading",color:"brand.solid",children:Po(Pe.recoEffect)}),p.jsxs(Ie,{textStyle:"mono.sm",color:"fg.muted",children:[Pe.outcome," · ",Po(Pe.recoLo)," … ",Po(Pe.recoHi)]})]})]}),p.jsx(Ie,{textStyle:"caption",mt:"2.5",pt:"2.5",borderTopWidth:"1px",borderColor:"border.subtle",children:Pe.tradeoff})]}),p.jsxs(V,{layerStyle:"card",p:"3.5",borderRadius:"lg",children:[p.jsxs(Y3,{help:"dose_marginal",children:["Extra ",Pe.outcome," per step"]}),p.jsx(V,{py:"0.5",maxH:"200px",overflowY:"auto",children:fn(Pe.marginal.map((st,dn)=>({label:st.label,frac:st.frac,tone:dn<2?"brand":"muted",value:Po(st.value)})))})]})]})]}),On==="dose"&&!Pe&&p.jsxs(V,{p:"4.5",children:[p.jsxs(V,{display:"inline-flex",alignItems:"center",gap:"2",mb:"2",color:"fg.muted",children:[p.jsx(Ur,{icon:rc,style:{fontSize:"13px"}}),p.jsx(Ie,{textStyle:"body.sm",fontWeight:"semibold",color:"fg.default",children:"No dose-response to show"})]}),(ue==null?void 0:ue.adjusted.type)==="some"?p.jsx(Ie,{textStyle:"body.sm",color:"fg.muted",lineHeight:"1.5",children:"The experiment didn’t return a how-much curve for this setup."}):p.jsxs(Ie,{textStyle:"body.sm",color:"fg.muted",lineHeight:"1.5",children:["A how-much curve needs a like-for-like estimate, and the experiment couldn’t produce one (see the ",p.jsx(Ie,{as:"span",fontWeight:"semibold",color:"fg.default",children:"Answer"})," tab for why)."]})]}),On==="validate"&&(se.status==="failed"&&se.error?p.jsx(V,{px:"4.5",pt:"4.5",children:p.jsx(MU,{error:se.error})}):Se&&Ke?p.jsx(Y0r,{vm:Ke,barList:fn}):!oe&&Et===null?p.jsxs(V,{p:"4.5",children:[p.jsxs(V,{display:"inline-flex",alignItems:"center",gap:"2",mb:"2",color:"fg.muted",children:[p.jsx(Ur,{icon:rc,style:{fontSize:"13px"}}),p.jsx(Ie,{textStyle:"body.sm",fontWeight:"semibold",color:"fg.default",children:"No trial recipe for this question"})]}),p.jsx(Ie,{textStyle:"body.sm",color:"fg.muted",lineHeight:"1.5",children:"This question doesn’t include a validation-trial recipe, and no design function is bound to size one."})]}):p.jsxs(V,{p:"4.5",display:"inline-flex",alignItems:"center",gap:"2",color:"fg.muted",children:[p.jsx(CL,{size:"xs",borderWidth:"1.5px",color:"brand.solid"}),p.jsx(Ie,{textStyle:"body.sm",children:"Sizing the trial that would confirm this…"})]}))]}):p.jsx(mat,{tab:On})]})]}),ot&&ot.length>0&&p.jsxs(p.Fragment,{children:[p.jsxs(V,{css:d.root,bg:"bg.canvas",borderTopWidth:"1px",borderColor:"border.subtle",children:[p.jsx(V,{css:d.lbl,children:p.jsx(Di,{id:"journal",children:"Committed experiments"})}),p.jsx(V,{css:d.meta,children:p.jsxs(Ie,{as:"span",children:[p.jsx(Ie,{as:"span",color:"fg.default",fontWeight:"semibold",children:ot.length})," on record",ot.length>50?" · showing newest 50":""]})})]}),ot.slice(0,50).map((st,dn)=>p.jsxs(V,{display:"grid",gridTemplateColumns:"2fr 1fr 1fr 1fr",gap:"3",alignItems:"center",px:"4.5",py:"2.5",borderTopWidth:"1px",borderColor:"border.subtle",children:[p.jsxs(Ie,{textStyle:"body.sm",children:[p.jsxs(Ie,{as:"span",fontWeight:"bold",children:[st.treatment," → ",st.outcome]})," ",p.jsxs(Ie,{as:"span",color:"fg.muted",children:["· vs ",st.confounders]}),(()=>{var Pn;const Hn=_(st.preset);if(Hn===void 0)return null;const pr=((Pn=S.find(Hr=>Hr.id===Hn))==null?void 0:Pn.label)??Hn;return p.jsxs(p.Fragment,{children:[" ",p.jsxs(V,{as:"span",css:s({tone:"brand",size:"sm"}),children:["from ",pr]})]})})()]}),p.jsx(Ie,{textStyle:"mono.sm",fontWeight:"semibold",textAlign:"right",fontVariantNumeric:"tabular-nums",color:st.verdictTone==="pos"?"fg.success":"fg.default",children:st.effect}),p.jsx(Ie,{textStyle:"caption.eyebrow",textAlign:"right",color:T_(st.verdictTone),children:st.verdict}),p.jsxs(Ie,{textStyle:"mono.sm",textAlign:"right",color:"fg.muted",children:[st.who," · ",st.when]})]},dn))]})]})})},(e,t)=>U0r(e.value,t.value)&&e.storageKey===t.storageKey);function G0r({a:e,verdict:t,narrative:n,checks:r,onGoTrust:a,subjectMany:o,higherBetter:i,badge:s,barList:l}){const c=e.effect>0,u=i===void 0?c?"Higher":"Lower":c===i?"Better":"Worse",d=e.naive<0?"lower":"higher",f=e.balance[0]??{label:"",display:""},h=e.clear&&!e.cautious?"fg.success":"fg.warning",g=e.clear&&!e.cautious,v=e.cautious?(t==null?void 0:t.label)??"Not trustworthy yet":e.clear?`${u} with ${e.treatment}`:"No clear effect";return p.jsxs(V,{p:"4.5",children:[n&&p.jsx(Ie,{textStyle:"body.md",color:"fg.default",lineHeight:"1.6",mb:"3.5",children:n.segments.map((b,y)=>b.strong?p.jsx(Ie,{as:"span",fontWeight:"bold",color:T_(n.tone),children:b.text},y):p.jsx(Ie,{as:"span",children:b.text},y))}),p.jsxs(V,{display:"flex",alignItems:"center",gap:"4.5",flexWrap:"wrap",children:[p.jsxs(V,{display:"flex",flexDirection:"column",gap:"0.5",children:[p.jsx(Ie,{textStyle:"mono.sm",color:"fg.muted",children:e.outcome}),p.jsxs(V,{display:"flex",alignItems:"baseline",gap:"2.5",children:[p.jsx(Ie,{textStyle:"mono-kpi",fontFamily:"heading",fontSize:"32px",color:h,children:p.jsxs(Di,{id:"answer_effect",children:[Po(e.effect),e.unit?p.jsxs(Ie,{as:"span",fontSize:"16px",color:"fg.muted",children:[" ",e.unit]}):null]})}),p.jsx(Ie,{textStyle:"mono.sm",color:"fg.muted",children:p.jsxs(Di,{id:"answer_ci",children:["likely between ",Po(e.lo)," and ",Po(e.hi)]})})]})]}),p.jsxs(V,{as:"span",css:s({variant:g?"ok":"warn",size:"md"}),alignSelf:"flex-end",mb:"1",display:"inline-flex",alignItems:"center",gap:"1",children:[e.clear&&!e.cautious&&p.jsx(Ur,{icon:c?tKn:bJe,style:{fontSize:"10px"}}),p.jsx(Di,{id:`verdict_${(t==null?void 0:t.tag)??"modest"}`,children:v})]})]}),r&&r.length>0&&p.jsxs(V,{as:"button",onClick:a,display:"inline-flex",alignItems:"center",gap:"2",flexWrap:"wrap",mt:"2.5",bg:"transparent",border:"0",p:"0",cursor:"pointer",title:"See the full stress-test checklist",children:[p.jsx(Ie,{textStyle:"caption",color:"fg.muted",children:"Stress tests:"}),r.map((b,y)=>p.jsxs(V,{as:"span",display:"inline-flex",alignItems:"center",gap:"1.5",color:b.passed?"fg.success":"fg.warning",children:[p.jsx(Ur,{icon:b.passed?o7:rc,style:{fontSize:"10px"}}),p.jsx(Ie,{as:"span",textStyle:"caption",color:"fg.default",children:b.short}),y<r.length-1&&p.jsx(Ie,{as:"span",textStyle:"caption",color:"fg.subtle",children:"·"})]},y))]}),e.cautious&&p.jsxs(V,{layerStyle:"banner.stale",display:"flex",alignItems:"flex-start",gap:"2",mt:"3",children:[p.jsx(V,{as:"span",color:"fg.warning",flexShrink:"0",mt:"0.5",fontSize:"12px",children:p.jsx(Ur,{icon:rc})}),p.jsxs(Ie,{textStyle:"body.sm",color:"fg.default",children:[p.jsx(Di,{id:"answer_cautious",children:p.jsx(Ie,{as:"span",fontWeight:"bold",children:"Treat this as provisional."})})," We adjusted and got a number, but a robustness check failed — the estimate may still be driven by something we didn’t adjust for. See ",p.jsx(Ie,{as:"span",fontWeight:"semibold",children:"Can we trust it?"})]})]}),e.flip&&p.jsxs(V,{layerStyle:"banner.stale",display:"flex",alignItems:"flex-start",gap:"2",mt:"3",children:[p.jsx(V,{as:"span",color:"fg.warning",flexShrink:"0",mt:"0.5",fontSize:"12px",children:p.jsx(Ur,{icon:rc})}),p.jsxs(Ie,{textStyle:"body.sm",color:"fg.default",children:[p.jsx(Di,{id:"answer_flip",children:p.jsx(Ie,{as:"span",fontWeight:"bold",children:"Raw and like-for-like disagree."})})," In the plain average, the ",p.jsx(Ie,{as:"span",fontWeight:"semibold",children:e.treatment})," group sits ",p.jsx(Ie,{as:"span",fontStyle:"italic",children:d})," on ",p.jsx(Ie,{as:"span",fontWeight:"semibold",children:e.outcome})," (",Po(e.naive),") — but they also differ most on ",p.jsx(Ie,{as:"span",fontWeight:"semibold",children:f.label})," (",f.display,"). Adjusting for it reverses the result."]})]}),p.jsxs(V9,{children:[p.jsx(Y3,{help:"forest_plot",children:"Raw average vs. like-for-like"}),p.jsx(y0r,{rows:[{label:"Raw average",note:"unadjusted",est:e.naive,lo:e.naiveLo,hi:e.naiveHi,tone:e.naive<0?"neg":"pos"},{label:"Like-for-like",note:"adjusted",est:e.effect,lo:e.lo,hi:e.hi,tone:e.clear&&!e.cautious?"pos":"warn"}],min:Math.floor(Math.min(0,e.naiveLo,e.lo)-2),max:Math.ceil(Math.max(0,e.naiveHi,e.hi)+2),unit:`change in ${e.outcome}${e.unit?` (${e.unit})`:""}`,height:150,rowHelp:["forest_naive","forest_adjusted"]})]}),p.jsxs(V,{as:"details",layerStyle:"card",borderRadius:"lg",mt:"3",children:[p.jsxs(V,{as:"summary",textStyle:"caption.eyebrow",fontSize:"9px",cursor:"pointer",p:"3.5",display:"flex",alignItems:"center",gap:"1.5",css:{listStyle:"none","&::-webkit-details-marker":{display:"none"}},children:[p.jsx(V,{as:"span",display:"inline-flex",color:"fg.subtle",fontSize:"10px",transition:"transform 180ms ease",transform:"rotate(-90deg)",css:{"details[open] > summary > &":{transform:"rotate(0deg)"}},children:p.jsx(Ur,{icon:hS})}),p.jsx(Di,{id:"balance",children:"How we levelled the playing field"})]}),p.jsx(V,{px:"3.5",pb:"3.5",py:"0.5",maxH:"208px",overflowY:"auto",children:l(e.balance.map(b=>({label:b.label,frac:b.frac,tone:b.tone,value:b.display})))})]}),p.jsx(V,{mt:"3.5",children:p.jsx(Di,{id:"counts",display:"inline-flex",gap:"4",children:[[e.nTotal,o],[e.nCompared,"compared like-for-like"],[e.nDropped,"had no fair match"]].map(([b,y],x)=>p.jsxs(Ie,{textStyle:"mono.sm",color:"fg.muted",children:[p.jsx(Ie,{as:"span",color:"fg.default",fontWeight:"semibold",children:Number(b)})," ",y]},x))})})]})}function K0r({refusal:e,overlap:t,naiveValue:n,outcome:r}){return p.jsxs(V,{p:"4.5",children:[p.jsxs(V,{display:"inline-flex",alignItems:"center",gap:"2",mb:"2",color:"fg.warning",children:[p.jsx(Ur,{icon:rc,style:{fontSize:"14px"}}),p.jsx(Ie,{textStyle:"title.card",color:"fg.default",children:p.jsx(Di,{id:e.kind==="positivity"?"refusal_positivity":"refusal_not_estimable",children:e.title})})]}),p.jsx(Ie,{textStyle:"body.sm",color:"fg.muted",mb:"3",lineHeight:"1.5",children:e.body}),e.kind==="positivity"&&t&&p.jsxs(V9,{mt:"1",children:[p.jsxs(Y3,{help:"overlap_histogram",children:["Propensity overlap — ",t.supportLabel]}),p.jsx(b0r,{treated:t.treated,control:t.control,supportLabel:t.supportLabel,positivityOk:t.positivityOk,height:170})]}),p.jsx(V,{display:"flex",gap:"4",mt:"3.5",children:e.evidence.map((a,o)=>p.jsxs(Ie,{textStyle:"mono.sm",color:"fg.muted",children:[p.jsx(Ie,{as:"span",color:"fg.default",fontWeight:"semibold",children:a.value})," ",a.label]},o))}),p.jsxs(Ie,{textStyle:"caption",color:"fg.subtle",mt:"3.5",pt:"3",borderTopWidth:"1px",borderColor:"border.subtle",children:["Raw average difference in ",r," (context only, not an answer): ",p.jsx(Ie,{as:"span",fontFamily:"mono",color:"fg.muted",children:Po(n)})]})]})}function Y0r({vm:e,barList:t}){const n=en({key:"stat"})({size:"lg"}),r=en({key:"segmentedMeter"})({});return p.jsxs(V,{p:"4.5",children:[p.jsx(Y3,{help:"tab_validate",children:e.headline}),p.jsxs(V,{display:"flex",alignItems:"flex-end",gap:"5",flexWrap:"wrap",children:[p.jsxs(V,{css:n.root,children:[p.jsx(Ie,{css:n.label,children:p.jsx(Di,{id:"validate_size",children:e.holdback?"to hold back from":"to run"})}),e.faint?p.jsx(Ie,{textStyle:"body.sm",fontWeight:"semibold",color:"fg.warning",maxW:"220px",children:"Effect too faint to size — set a materiality threshold to size a trial."}):p.jsx(Ie,{css:n.valueText,color:"brand.solid",children:e.primary.nTotal.toLocaleString()})]}),p.jsxs(V,{css:r.root,flex:"1",minW:"220px",children:[p.jsx(Ie,{css:r.label,children:p.jsx(Di,{id:"validate_split",children:e.holdback?"Hold-back split":"Split"})}),p.jsxs(V,{css:r.track,children:[p.jsx(V,{css:r.segment,flex:e.primary.treatedShare,bg:"brand.solid"}),p.jsx(V,{css:r.segment,flex:1-e.primary.treatedShare,bg:"bg.emphasized"})]}),p.jsxs(V,{css:r.keyRow,justifyContent:"space-between",children:[p.jsxs(V,{css:r.keyItem,children:[p.jsx(V,{css:r.keyDot,bg:"brand.solid"}),p.jsxs("span",{children:[p.jsx(Ie,{as:"span",css:r.valueText,children:e.primary.nTreated.toLocaleString()})," ",e.holdback?"treated":"get it"]})]}),p.jsxs(V,{css:r.keyItem,children:[p.jsx(V,{css:r.keyDot,bg:"bg.emphasized"}),p.jsxs("span",{children:[p.jsx(Ie,{as:"span",css:r.valueText,children:e.primary.nControl.toLocaleString()})," ",e.holdback?"held back":"left alone"]})]})]})]})]}),e.matchOn.length>0&&p.jsxs(V9,{children:[p.jsx(Y3,{help:"validate_match",children:"Match both groups on"}),p.jsx(V,{py:"0.5",children:t(e.matchOn.map(a=>({label:a.display,frac:a.frac,tone:a.tone,value:""})))})]}),e.curve.mid.length>0&&p.jsxs(V9,{children:[p.jsx(Y3,{help:"validate_power",children:"Chance of detecting it"}),p.jsx(XZ,{lo:e.curve.mid,mid:e.curve.mid,hi:e.curve.mid,tone:"brand",xTicks:e.curve.xTicks,yTicks:["100","50","0"],yFormat:"percent",marks:e.curve.marks.map(a=>({at:a.at,label:a.label,tone:a.tone,help:a.help})),height:170})]}),p.jsx(Ie,{textStyle:"body.sm",color:"fg.default",lineHeight:"1.5",mt:"3.5",children:e.rationale}),e.alternates.length>0&&p.jsx(V,{display:"flex",flexDirection:"column",gap:"1.5",mt:"3",pt:"3",borderTopWidth:"1px",borderColor:"border.subtle",children:e.alternates.map((a,o)=>p.jsxs(Ie,{textStyle:"caption",color:"fg.muted",children:[p.jsx(Ie,{as:"span",fontWeight:"semibold",color:"fg.default",children:a.label})," · ",a.nTotal.toLocaleString()," total (",a.nTreated.toLocaleString()," / ",a.nControl.toLocaleString(),")"]},o))})]})}function X0r({fields:e,population:t,onChange:n,chip:r,button:a,readonly:o,subjectMany:i}){const[s,l]=C.useState(null),c=(f,h)=>n(t.map((g,v)=>v===f?h:g)),u=f=>n(t.filter((h,g)=>g!==f)),d=p.jsx(V,{as:"button",css:a({variant:"outline",size:"xs"}),onClick:()=>l(null),children:"Done"});return o?p.jsx(V,{display:"flex",flexWrap:"wrap",gap:"1.5",alignItems:"center",children:t.length===0?p.jsxs(V,{css:r({tone:"plain",numeric:!0,shape:"rounded"}),children:["all ",i]}):t.map((f,h)=>p.jsx(V,{css:r({tone:"brand",numeric:!0,shape:"rounded"}),flexShrink:0,children:p.jsx(V,{as:"span",whiteSpace:"nowrap",children:Zw(f)})},h))}):p.jsxs(V,{display:"flex",flexWrap:"wrap",gap:"1.5",alignItems:"center",children:[t.map((f,h)=>p.jsx(t4,{open:s===h,onOpenChange:g=>l(g?h:null),label:p.jsxs(p.Fragment,{children:["Edit · ",p.jsx(V,{as:"span",fontFamily:"mono",color:"brand.fg",children:f.value.fieldId})]}),footActions:d,trigger:p.jsxs(V,{css:r({tone:"brand",numeric:!0,shape:"rounded"}),cursor:"pointer",flexShrink:0,children:[p.jsx(V,{as:"span",whiteSpace:"nowrap",children:Zw(f)}),p.jsx(V,{as:"button",display:"inline-flex",alignItems:"center",cursor:"pointer",color:"brand.fg",flexShrink:"0",fontSize:"10px",onClick:g=>{g.stopPropagation(),u(h)},"aria-label":"Remove filter",children:p.jsx(Ur,{icon:E9})})]}),children:s===h?p.jsx(tS,{fields:e,initial:f,lockField:!0,submitLabel:"Apply",onAdd:g=>{c(h,g),l(null)}}):null},h)),p.jsx(t4,{open:s==="add",onOpenChange:f=>l(f?"add":null),label:"Add filter",size:"lg",footActions:d,trigger:p.jsxs(V,{css:r({tone:"dashed",numeric:!0,shape:"rounded"}),cursor:"pointer",display:"inline-flex",alignItems:"center",gap:"1.5",children:[p.jsx(V,{as:"span",fontSize:"9px",children:p.jsx(Ur,{icon:DI})}),p.jsx(V,{as:"span",children:"filter"})]}),children:s==="add"?p.jsx(tS,{fields:e,onAdd:f=>{n([...t,f]),l(null)}}):null})]})}function QT({n:e,title:t,help:n,children:r}){return p.jsxs(V,{px:"4.5",py:"3",borderBottomWidth:"1px",borderColor:"border.subtle",children:[p.jsxs(V,{display:"flex",alignItems:"baseline",gap:"2.5",mb:"2",children:[p.jsx(V,{as:"span",fontFamily:"mono",fontSize:"11px",fontWeight:"bold",color:"brand.fg",flex:"0 0 auto",lineHeight:"1",children:e}),p.jsx(Ie,{textStyle:"title.row",children:n?p.jsx(Di,{id:n,children:t}):t})]}),r]})}function vat({choices:e,onPick:t,children:n}){return p.jsxs(fm,{children:[p.jsx(Ore,{asChild:!0,children:n}),p.jsx(go,{children:p.jsx(pm,{children:p.jsx(hm,{children:e.map(r=>p.jsx(ep,{value:r,onClick:()=>t(r),children:r},r))})})})]})}function Pve({column:e,kind:t,choices:n,onPick:r,badge:a,button:o,readonly:i}){return i?p.jsxs(V,{css:o({variant:"outline",size:"sm"}),gap:"1.5",cursor:"default",children:[p.jsx(Ie,{as:"span",fontFamily:"mono",fontWeight:"semibold",children:e}),p.jsx(V,{as:"span",css:a({variant:"plain",size:"sm"}),textTransform:"none",letterSpacing:"normal",children:t})]}):p.jsx(vat,{choices:n,onPick:r,children:p.jsxs(V,{as:"button",css:o({variant:"outline",size:"sm"}),gap:"1.5",children:[p.jsx(Ie,{as:"span",fontFamily:"mono",fontWeight:"semibold",children:e}),p.jsx(V,{as:"span",css:a({variant:"plain",size:"sm"}),textTransform:"none",letterSpacing:"normal",children:t}),p.jsx(V,{as:"span",display:"inline-flex",color:"fg.muted",fontSize:"10px",children:p.jsx(Ur,{icon:hS})})]})})}function Z0r({options:e,active:t,onPick:n,fill:r,size:a="xs"}){const o=en({key:"segmentGroup"})({size:a});return p.jsx(V,{css:o.root,...r?{width:"100%"}:{},role:"radiogroup",onKeyDown:i=>{var s;const l=i.key==="ArrowRight"||i.key==="ArrowDown"?1:i.key==="ArrowLeft"||i.key==="ArrowUp"?-1:0;if(!l)return;i.preventDefault();const c=(t+l+e.length)%e.length;n(c),(s=i.currentTarget.querySelectorAll('[role="radio"]')[c])==null||s.focus()},children:e.map((i,s)=>p.jsx(V,{as:"button",role:"radio","aria-checked":t===s,tabIndex:t===s?0:-1,css:o.item,...r?{flex:"1"}:{},...t===s?{"data-state":"checked"}:{},onClick:()=>n(s),children:p.jsx(V,{as:"span",css:o.itemText,children:i})},s))})}function Q0r({value:e,size:t="xs"}){const n=en({key:"segmentGroup"})({size:t});return p.jsx(V,{css:n.root,alignSelf:"flex-start",children:p.jsx(V,{css:n.item,"data-state":"checked",children:p.jsx(V,{as:"span",css:n.itemText,children:e})})})}function Ave({label:e,left:t,right:n,active:r,onPick:a,last:o,help:i,readonly:s}){return p.jsxs(V,{display:"flex",flexDirection:"column",alignItems:"stretch",gap:"1.5",py:"2",borderBottomWidth:o?"0":"1px",borderColor:"border.subtle",children:[p.jsx(Ie,{textStyle:"caption.eyebrow",textTransform:"none",letterSpacing:"normal",color:"fg.default",children:i?p.jsx(Di,{id:i,children:e}):e}),s?p.jsx(Q0r,{value:r==="left"?t:n}):p.jsx(Z0r,{options:[t,n],active:r==="left"?0:1,onPick:l=>a(l===0?"left":"right"),fill:!0,size:"xs"})]})}pk(Sf.Component,q0r);const yat=k(T),J0r=Ei(yat),eur=Ra(yat);function bat(e){return["decision.selection",...e.map(t=>Jc(t.source))].join("|")}function jk(e){const t=m2().getConfig().workspace??"",n=e.source,r=F6(t,n);if(!r)throw new Error(`Decision.bind: no binding registered for ${Jc(n)} — bind it with Data.bind on the same surface first`);const a=e.patch.type==="some"?e.patch.value:void 0;return g1.buildBindHandle(r.sourceType,n,a,e.mode.type)}function tur(e){return JSON.stringify(e,(t,n)=>typeof n=="bigint"?`${n}n`:n instanceof Date?n.toISOString():Ip(n)?[...n].sort():dit(n)?[...n.entries()].sort((r,a)=>String(r[0]).localeCompare(String(a[0]))):n)}function nur(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t+e.charCodeAt(n)|0;return(t>>>0).toString(36)}function Nve(e){rL.trackKey(e);const t=rL.getStore().read(e);return t===void 0?A:eur(t)}function TU(e,t){return rL.getStore().write(e,J0r(t)),null}function EU(e){return e.flatMap(t=>jk(t).read())}function h1e(e){return jk(e).read()}function zx(e,t){return h1e(e).get(t)??{caseId:t,answers:new Map,knowledge:A,constraints:[],verdict:A,resolvedAt:A}}function JT(e,t,n){const r=new Map(h1e(e));return r.set(t,{...zx(e,t),...n}),jk(e).write(r),null}function rur(e,t){for(const n of e){const r=jk(n),a=r.read();a.some(o=>o.id===t)&&r.write(a.filter(o=>o.id!==t))}}const $ve=new Map;function aur(e){const t=new WeakSet;return JSON.stringify(e,(n,r)=>{if(typeof r=="object"&&r!==null){if(t.has(r))return"<cyc>";t.add(r)}return typeof r=="bigint"?`${r}n`:r})}function our(e,t,n,r){const a=lv(),o=uc(e),i=F.value(t,ce(ti)),s=F.value(n,ti),l=F.value(r,T),{queue:c,selected:u,select:d,clearSelection:f,decision:h,update:g,judgement:v,answer:b,addKnowledge:y,inject:x,resolve:S,commitState:z}=Dc;return{queue:F.compile(F.function([],ce(H1),M=>{M.return(c(i))}),a),selected:F.compile(F.function([],k(T),M=>{M.return(u(l))}),a),select:F.compile(F.function([T],D,(M,L)=>{M.return(d(l,L))}),a),clearSelection:F.compile(F.function([],D,M=>{M.return(f(l))}),a),decision:F.compile(F.function([],k(H1),M=>{M.return(h(i,l))}),a),update:F.compile(F.function([H1],D,(M,L)=>{M.return(g(i,L))}),a),judgement:F.compile(F.function([T],fC(o),(M,L)=>{M.return(v([o],s,L))}),a),answer:F.compile(F.function([T,T,pN],D,(M,L,R,N)=>{M.return(b(s,L,R,N))}),a),addKnowledge:F.compile(F.function([T,T],D,(M,L,R)=>{M.return(y(s,L,R))}),a),inject:F.compile(F.function([T,o],D,(M,L,R)=>{M.return(x([o],s,L,R))}),a),resolve:F.compile(F.function([T,hN],D,(M,L,R)=>{M.return(S(i,s,l,L,R))}),a),commitState:F.compile(F.function([T],jte,(M,L)=>{M.return(z(i,s,L))}),a)}}function xat(e,t,n){const r=n??Zt(Ote),a=bat(e),o=()=>{const l=[...h1e(t).values()].filter(u=>u.verdict.type==="some"),c=u=>u.resolvedAt.type==="some"?u.resolvedAt.value.getTime():0;return l.sort((u,d)=>c(d)-c(u))},i=`${nur(tur({decisions:e,judgements:t}))}|${aur(r)}`;let s=$ve.get(i);return s===void 0&&(s=our(r,e,t,a),$ve.set(i,s)),{decisions:e,judgements:t,journal:o,...s}}const g1e=[N7t.implement(e=>(t,n)=>xat(t,n,e)),Dc.queue.implement(e=>EU(e)),Dc.selected.implement(e=>Nve(e)),Dc.select.implement((e,t)=>TU(e,P(t))),Dc.clearSelection.implement(e=>TU(e,A)),Dc.decision.implement((e,t)=>{const n=Nve(t);if(n.type==="none")return A;const r=EU(e).find(a=>a.id===n.value);return r===void 0?A:P(r)}),Dc.update.implement((e,t)=>{const n=t;for(const r of e){const a=jk(r),o=a.read();o.some(i=>i.id===n.id)&&a.write(o.map(i=>i.id===n.id?n:i))}return null}),Dc.judgement.implement(e=>(t,n)=>zx(t,n)),Dc.answer.implement((e,t,n,r)=>{const a=new Map(zx(e,t).answers);return a.set(n,r),JT(e,t,{answers:a})}),Dc.addKnowledge.implement((e,t,n)=>JT(e,t,{knowledge:P(n)})),Dc.inject.implement(e=>(t,n,r)=>{const a=r,o=zx(t,n).constraints.filter(i=>i.type!==a.type).concat([a]);return JT(t,n,{constraints:o})}),Dc.resolve.implement((e,t,n,r,a)=>(JT(t,r,{verdict:P(a),resolvedAt:P(new Date)}),rur(e,r),TU(n,A),null)),Dc.commitState.implement((e,t,n)=>{const r=n,a=EU(e).find(c=>c.id===r),o=(a==null?void 0:a.prompts)??[],i=zx(t,r).answers,s=o.map(c=>{var u;return(u=i.get(c.id))==null?void 0:u.type});if(s.some(c=>c==="no"))return $("blocked",null);if(s.some(c=>c==="unknown"))return $("handoff",null);const l=s.filter(c=>c===void 0).length;return l>0?$("gated",BigInt(l)):$("ready",null)})];s0(g1e);function iur(e){const t=x5(),n=m2(),r=rL.getStore(),a=n.getConfig().workspace??"",o=C.useMemo(()=>{if(!e)return[];const c=[...e.decisions,e.judgements],u=[];for(const d of c)u.push(Zo(a,d.source)),d.patch.type==="some"&&u.push(Zo(a,d.patch.value));return u},[a,e]),i=e?bat(e.decisions):void 0,s=C.useCallback(c=>{const u=o.flatMap(d=>[t.subscribe(d,c),n.subscribe(d,c)]);return i!==void 0&&u.push(r.subscribe(i,c)),()=>{for(const d of u)d()}},[t,n,r,o,i]),l=C.useCallback(()=>o.reduce((c,u)=>c+t.getKeyVersion(u)+n.getKeyVersion(u),0)+(i!==void 0?r.getKeyVersion(i):0),[t,n,r,o,i]);return C.useSyncExternalStore(s,l)}function wat(e){const t=iur(e),n=C.useMemo(()=>e?xat([...e.decisions],e.judgements):null,[e]),{decisions:r,selected:a,journal:o}=C.useMemo(()=>{try{if(!n)return{decisions:null,selected:null,journal:null};const v=n.selected();return{decisions:n.queue(),selected:v.type==="some"?v.value:null,journal:n.journal()}}catch{return{decisions:null,selected:null,journal:null}}},[n,t]),i=C.useCallback(v=>{try{return n?n.judgement(v):null}catch{return null}},[n,t]),s=C.useCallback(v=>{try{return n?n.commitState(v):null}catch{return null}},[n,t]),l=C.useCallback(v=>{n==null||n.select(v)},[n]),c=C.useCallback(()=>{n==null||n.clearSelection()},[n]),u=C.useCallback(v=>{n==null||n.update(v)},[n]),d=C.useCallback((v,b,y)=>{n==null||n.answer(v,b,$(y,null))},[n]),f=C.useCallback((v,b)=>{n==null||n.addKnowledge(v,b)},[n]),h=C.useCallback((v,b)=>{n==null||n.inject(v,b)},[n]),g=C.useCallback((v,b)=>{n==null||n.resolve(v,b)},[n]);return{decisions:r,selected:a,journal:o,judgementFor:i,commitStateFor:s,select:l,clearSelection:c,update:u,answer:d,addKnowledge:f,inject:h,resolve:g}}const Sat={eq:"=",neq:"≠",atMost:"at most",atLeast:"at least",between:"between",before:"before",after:"after",in:"in",notIn:"not in",is:"is"};function om(e){return e instanceof Date?`${e.toLocaleString("en",{month:"short"})} ${e.getDate()}`:Ip(e)?`{${[...e].map(om).join(", ")}}`:e!==null&&typeof e=="object"&&!e.type?Object.entries(e).map(([t,n])=>`${t} ${om(n)}`).join(" · "):String(e)}function Cat(e,t,n){var r,a;const o=e,i=((r=n==null?void 0:n.find(s=>s.case===o.type))==null?void 0:r.label)??o.type;if((t==null?void 0:t.type)==="Variant"){const s=o.value,l=Sat[s.type]??s.type,c=(a=t.cases)==null?void 0:a[s.type];if((c==null?void 0:c.type)==="Struct"&&s.value!==null&&typeof s.value=="object"){const u=s.value;if("min"in u&&"max"in u)return{lever:i,op:l,value:`${om(u.min)} – ${om(u.max)}`}}return{lever:i,op:l,value:om(s.value)}}return{lever:i,op:"·",value:om(o.value)}}const eE=new Set(["String","Integer","Float","DateTime","Boolean"]);function I2(e){var t;const n=e;if(n.cases!==void 0||n.fields!==void 0){const r={type:n.type};return n.cases&&(r.cases=Object.fromEntries(Object.entries(n.cases).map(([a,o])=>[a,I2(o)]))),n.fields&&(r.fields=Object.fromEntries(Object.entries(n.fields).map(([a,o])=>[a,I2(o)]))),n.key&&(r.key=I2(n.key)),n.value!==void 0&&(n.type==="Array"||n.type==="Dict")&&(r.value=I2(n.value)),r}switch(n.type){case"Struct":return{type:"Struct",fields:Object.fromEntries(n.value.map(r=>[r.name,I2(r.type)]))};case"Variant":return{type:"Variant",cases:Object.fromEntries(n.value.map(r=>[r.name,I2(r.type)]))};case"Array":return{type:"Array",value:I2(n.value)};case"Dict":{const r=n.value;return{type:"Dict",key:I2(r.key),value:I2(r.value)}}case"Recursive":{const r=n.value;return(r==null?void 0:r.type)==="wrapper"&&((t=r.value)!=null&&t.inner)?I2(r.value.inner):{type:n.type}}default:return{type:n.type}}}function E_(e){switch(e.type){case"Integer":return 0n;case"Float":return 0;case"DateTime":return new Date;case"Boolean":return!1;case"String":return"";case"Struct":return Object.fromEntries(Object.entries(e.fields??{}).map(([t,n])=>[t,E_(n)]));default:return null}}function sur(e){return e?eE.has(e.type)?!0:e.type==="Struct"?Object.values(e.fields??{}).every(t=>eE.has(t.type)):e.type==="Variant"?Object.values(e.cases??{}).every(t=>eE.has(t.type)||t.type==="Struct"&&Object.values(t.fields??{}).every(n=>eE.has(n.type))):!1:!1}const yg=P({size:P($("sm",null))});function lur({leverCase:e,payload:t,onInject:n}){var r;const a=ga({key:"button"}),o=t.type==="Variant",i=C.useMemo(()=>o?Object.keys(t.cases??{}):[],[o,t]),[s,l]=C.useState(i[0]??""),c=o?((r=t.cases)==null?void 0:r[s])??{type:"Null"}:t,u=C.useRef(E_(c)),d=C.useRef(`${e}:${s}`);d.current!==`${e}:${s}`&&(d.current=`${e}:${s}`,u.current=E_(c));const f=(v,b,y,x)=>{switch(v.type){case"Integer":return p.jsx(X$,{value:{value:y(),onChange:P(x),style:yg}},b);case"Float":return p.jsx(Z$,{value:{value:y(),onChange:P(x),style:yg}},b);case"DateTime":return p.jsx(m9,{value:{value:y(),onChange:P(x),style:yg}},b);case"Boolean":return p.jsx(h6,{ariaLabel:b,value:{value:P(String(y())),items:[{value:"true",label:"true",disabled:A},{value:"false",label:"false",disabled:A}],placeholder:A,multiple:A,disabled:A,onChange:P(S=>x(S==="true")),onChangeMultiple:A,onOpenChange:A,style:yg}},b);default:return p.jsx(Y$,{value:{value:String(y()??""),onChange:P(x),style:yg}},b)}},h=C.useMemo(()=>{const v=d.current;return c.type==="Struct"?Object.entries(c.fields??{}).map(([b,y])=>p.jsxs(V,{display:"flex",alignItems:"center",gap:"6px",minW:0,children:[p.jsx(V,{as:"span",textStyle:"caption.eyebrow",color:"fg.subtle",flexShrink:0,children:b}),f(y,`${v}.${b}.in`,()=>u.current[b],x=>{u.current[b]=x})]},`${v}.${b}`)):p.jsx(V,{width:"min(180px, 100%)",flexShrink:0,children:f(c,`${v}.value`,()=>u.current,b=>{u.current=b})},`${v}.wrap`)},[c,s,e]),g=()=>{const v=u.current,b=c.type==="Struct"?{...v}:v,y=o?$(e,$(s,b)):$(e,b);n(y),u.current=E_(c)};return p.jsxs(V,{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",minW:0,css:{"& [data-scope=select][data-part=root]":{width:"auto",minWidth:"110px",flexShrink:0},"& [data-scope=number-input][data-part=root]":{width:"150px",flexShrink:0}},children:[o&&p.jsx(h6,{ariaLabel:"Operator",value:{value:P(s),items:i.map(v=>({value:v,label:Sat[v]??v,disabled:A})),placeholder:A,multiple:A,disabled:A,onChange:P(v=>l(v)),onChangeMultiple:A,onOpenChange:A,style:yg}}),h,p.jsx(Ht.button,{type:"button",css:a({variant:"solid",size:"xs"}),onClick:g,children:"Add"})]})}function Mx(e,t,n=!1){return Yp(t,_(e.format),n)}const ic={textStyle:"caption.eyebrow",color:"fg.muted"},cur=C.memo(function({decision:t,children:n}){const r=_(t.stakes),a=_(t.downside),o=_(t.confidence),i=_(t.detail);return p.jsxs(V,{display:"flex",flexDirection:"column",gap:"10px",children:[p.jsxs(V,{display:"flex",alignItems:"baseline",gap:"12px",flexWrap:"wrap",children:[p.jsx(Ie,{...ic,color:"fg",children:"Why this is recommended"}),p.jsxs(Ie,{...ic,children:[r!==void 0&&p.jsxs(p.Fragment,{children:["stakes ",p.jsx(Ie,{as:"span",fontFamily:"mono",fontWeight:"semibold",children:r.type})," · "]}),a!==void 0&&p.jsxs(p.Fragment,{children:["if wrong ",p.jsx(Ie,{as:"span",fontFamily:"mono",fontWeight:"semibold",color:"fg.danger",children:Mx(t,a,!0)})," · "]}),o!==void 0&&p.jsxs(p.Fragment,{children:["confidence ",p.jsxs(Ie,{as:"span",fontFamily:"mono",fontWeight:"semibold",children:[Math.round(o*100),"%"]})]})]})]}),i!==void 0&&p.jsx(Ie,{fontSize:"12.5px",color:"fg.muted",children:i}),t.evidence.length>0&&p.jsx(V,{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:"8px",children:t.evidence.map((s,l)=>{const c=_(s.note);return p.jsxs(V,{borderWidth:"1px",borderColor:"border.subtle",borderRadius:"4px",px:"10px",py:"8px",bg:"bg.canvas",children:[p.jsx(Ie,{...ic,children:s.label}),p.jsx(Ie,{fontSize:"13px",fontWeight:"medium",children:s.text}),c!==void 0&&p.jsx(Ie,{fontSize:"11px",fontFamily:"mono",color:"fg.subtle",children:c})]},l)})}),n]})});function uur(e){const t=[...e.alternatives].sort((n,r)=>r.value-n.value).map(n=>({label:n.label,value:n.value,downside:_(n.downside),confidence:_(n.confidence),note:_(n.note),recommended:!1}));return[{label:e.title,value:e.value,downside:_(e.downside),confidence:_(e.confidence),note:_(e.summary),recommended:!0},...t].map((n,r)=>({...n,rank:r+1}))}function Ive(e){const t=[];return e.recommended&&t.push("recommended"),e.confidence!==void 0&&t.push(`${Math.round(e.confidence*100)}% conf`),!e.recommended&&e.note!==void 0&&t.push(e.note),t.join(" · ")}const dur=C.memo(function({decision:t,narrow:n}){const r=uur(t),a=Math.max(...r.map(c=>Math.max(c.value,0)),1e-9),o=Math.max(...r.map(c=>Math.abs(c.downside??0)),1e-9),i=_(t.valueAxis),s=(i==null?void 0:i.label)??"Uplift",l=(i==null?void 0:i.signed)??!0;if(n){const c=(u,d,f,h)=>p.jsxs(V,{display:"grid",gridTemplateColumns:"80px 1fr 64px",alignItems:"center",gap:"8px",children:[p.jsx(Ie,{...ic,whiteSpace:"nowrap",children:u}),p.jsx(V,{height:"6px",bg:"border.subtle",borderRadius:"3px",overflow:"hidden",children:p.jsx(V,{height:"100%",width:`${Math.round(Math.min(Math.abs(d),1)*100)}%`,bg:h==="success"?"fg.success":h==="danger"?"fg.danger":"fg.subtle",opacity:.7})}),p.jsx(Ie,{fontSize:"11px",fontFamily:"mono",fontWeight:"semibold",textAlign:"right",children:f})]});return p.jsxs(V,{display:"flex",flexDirection:"column",gap:"10px",children:[p.jsxs(Ie,{...ic,color:"fg",children:["Options · ",r.length," evaluated"]}),r.map(u=>p.jsxs(V,{display:"flex",flexDirection:"column",gap:"4px",pl:"8px",...u.recommended?{boxShadow:"inset 2px 0 0 var(--chakra-colors-accent-brand)"}:{},children:[p.jsxs(Ie,{fontSize:"12.5px",children:[p.jsx(Ie,{as:"span",fontFamily:"mono",color:"fg.subtle",children:u.rank})," ",p.jsx(Ie,{as:"span",fontWeight:u.recommended?"semibold":"normal",children:u.label})]}),c(s,u.value/a,Mx(t,u.value,l),l?"success":"neutral"),c("If wrong",(u.downside??0)/o,u.downside!==void 0?Mx(t,u.downside,!0):"—","danger")]},u.rank))]})}return p.jsxs(V,{display:"flex",flexDirection:"column",gap:"6px",children:[p.jsxs(V,{display:"grid",gridTemplateColumns:"minmax(180px, 1.1fr) 1fr 1fr",alignItems:"baseline",gap:"8px",children:[p.jsxs(Ie,{...ic,color:"fg",children:["Options · ",r.length," evaluated"]}),p.jsx(Ie,{...ic,textAlign:"center",children:"If wrong"}),p.jsx(Ie,{...ic,textAlign:"right",children:s})]}),r.map(c=>{const u=Math.min(Math.abs(c.downside??0)/o,1),d=Math.min(Math.max(c.value,0)/a,1);return p.jsxs(V,{display:"grid",gridTemplateColumns:"minmax(180px, 1.1fr) 1fr 1fr",alignItems:"center",gap:"8px",py:"4px",...c.recommended?{bg:"bg.brand.subtle",boxShadow:"inset 2px 0 0 var(--chakra-colors-accent-brand)"}:{},children:[p.jsxs(V,{minW:0,pl:c.recommended?"6px":"0",display:"flex",alignItems:"baseline",gap:"6px",children:[p.jsx(Ie,{as:"span",fontFamily:"mono",fontSize:"11px",color:"fg.subtle",flexShrink:0,children:c.rank}),p.jsx(Ie,{as:"span",fontSize:"12.5px",fontWeight:c.recommended?"semibold":"normal",flexShrink:0,children:c.label}),Ive(c)!==""&&p.jsx(Ie,{as:"span",fontFamily:"mono",fontSize:"10.5px",color:"fg.muted",minW:0,truncate:!0,children:Ive(c)})]}),p.jsx(V,{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:"6px",height:"16px",children:c.downside!==void 0&&p.jsxs(p.Fragment,{children:[p.jsx(Ie,{fontSize:"10.5px",fontFamily:"mono",color:"fg.danger",flexShrink:0,children:Mx(t,c.downside,!0)}),p.jsx(V,{height:"12px",width:`${Math.round(u*100)}%`,bg:"fg.danger",opacity:.55})]})}),p.jsx(V,{display:"flex",alignItems:"center",gap:"6px",height:"16px",borderLeftWidth:"1px",borderColor:"border.strong",children:c.value>0&&p.jsxs(p.Fragment,{children:[p.jsx(V,{height:"12px",width:`${Math.round(d*100)}%`,bg:l?"fg.success":"fg.subtle",opacity:.6}),p.jsx(Ie,{fontSize:"10.5px",fontFamily:"mono",color:l?"fg.success":"fg.muted",flexShrink:0,children:Mx(t,c.value,l)})]})})]},c.rank)})]})}),fur=[{literal:"yes",label:"Yes"},{literal:"no",label:"No"},{literal:"unknown",label:"Don't know"}],pur=C.memo(function({decision:t,handle:n,leverPayloads:r}){var a;const o=ga({key:"button"}),i=ga({key:"input"}),s=n.judgementFor(t.id),l=(s==null?void 0:s.knowledge.type)==="some"?s.knowledge.value:"",[c,u]=C.useState(l);C.useEffect(()=>{u(l)},[l]);const d=C.useCallback(()=>{c!==l&&n.addKnowledge(t.id,c)},[c,l,n,t.id]),f=C.useMemo(()=>t.levers.filter(S=>sur(r[S.case])),[t.levers,r]),[h,g]=C.useState(((a=f[0])==null?void 0:a.case)??""),v=f.find(S=>S.case===h)??f[0],b=n.commitStateFor(t.id),y=(b==null?void 0:b.type)==="gated"?b.value===1n?"Answer the judgement question to enable apply":`Answer the ${b.value} judgement questions to enable apply`:(b==null?void 0:b.type)==="blocked"?"Commit blocked — an answer contradicts the recommendation":(b==null?void 0:b.type)==="handoff"?"Awaiting handoff — an answer was don't know":null,x=C.useCallback(S=>{n.inject(t.id,S)},[n,t.id]);return s?p.jsxs(V,{display:"flex",flexDirection:"column",gap:"10px",children:[p.jsxs(V,{display:"flex",alignItems:"baseline",gap:"12px",children:[p.jsx(Ie,{...ic,color:"fg.warning",children:"Required before commit"}),p.jsx(Ie,{...ic,marginLeft:"auto",children:"human-only signal · model can’t see this"})]}),t.prompts.map(S=>{var z;const M=(z=s.answers.get(S.id))==null?void 0:z.type;return p.jsxs(V,{display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap",children:[p.jsx(Ie,{fontSize:"13px",fontWeight:"medium",flex:"1",minW:"min(180px, 100%)",children:S.text}),p.jsx(V,{display:"flex",gap:"6px",flexShrink:0,children:fur.map(L=>p.jsx(Ht.button,{type:"button",css:o({variant:M===L.literal?"solid":"outline",size:"xs"}),onClick:()=>n.answer(t.id,S.id,L.literal),children:L.label},L.literal))})]},S.id)}),p.jsxs(V,{display:"flex",flexDirection:"column",gap:"4px",children:[p.jsx(Ie,{...ic,children:"Knowledge · what the model can’t see"}),p.jsx(Ht.textarea,{css:i({size:"sm"}),rows:2,value:c,placeholder:"Private context — persists with the case",onChange:S=>u(S.target.value),onBlur:d})]}),(f.length>0||s.constraints.length>0)&&p.jsxs(V,{display:"flex",flexDirection:"column",gap:"6px",children:[p.jsx(Ie,{...ic,children:"Inject constraint · next run folds it in"}),s.constraints.length>0&&p.jsx(V,{display:"flex",gap:"12px",flexWrap:"wrap",children:s.constraints.map((S,z)=>{const M=S.type,L=Cat(S,r[M],t.levers);return p.jsxs(Ie,{as:"span",fontFamily:"mono",fontSize:"11px",children:[p.jsx(Ie,{as:"span",color:"accent.brand",fontWeight:"semibold",children:L.lever})," ",p.jsx(Ie,{as:"span",color:"fg.subtle",children:L.op})," ",p.jsx(Ie,{as:"span",fontWeight:"semibold",children:L.value})]},z)})}),v!==void 0&&p.jsxs(V,{display:"flex",alignItems:"center",gap:"8px",flexWrap:"wrap",children:[f.length>1?p.jsx(V,{flexShrink:0,css:{"& [data-scope=select][data-part=root]":{width:"auto",minWidth:"160px"}},children:p.jsx(h6,{ariaLabel:"Lever",value:{value:P(v.case),items:f.map(S=>({value:S.case,label:S.label,disabled:A})),placeholder:A,multiple:A,disabled:A,onChange:P(S=>g(S)),onChangeMultiple:A,onOpenChange:A,style:P({size:P($("sm",null))})}})}):p.jsx(Ie,{...ic,color:"fg",flexShrink:0,children:v.label}),p.jsx(V,{flex:"1",minW:"min(260px, 100%)",children:p.jsx(lur,{leverCase:v.case,payload:r[v.case],onInject:x},v.case)})]})]}),y!==null&&p.jsxs(V,{display:"flex",alignItems:"center",gap:"8px",pt:"4px",children:[p.jsx(V,{width:"7px",height:"7px",borderRadius:"full",bg:"fg.warning",flexShrink:0}),p.jsx(Ie,{...ic,children:y}),p.jsx(Ht.button,{type:"button",css:o({variant:"outline",size:"xs"}),marginLeft:"auto",onClick:()=>n.resolve(t.id,$("deferred",A)),children:"Defer"})]})]}):null}),Dve={overdue:0,due:1,routine:2},kat={overdue:"Overdue",due:"Due today",routine:"Routine"};function hur(e,t){if(t.key==="none")return[{label:"",decisions:e,pastSla:0,total:0,bulk:!1}];const n=a=>{var o;return t.key==="urgency"?kat[a.urgency.type]:t.key==="kind"?a.kind:((o=t.accessor)==null?void 0:o.call(t,a))??""},r=new Map;for(const a of e){const o=n(a);let i=r.get(o);i===void 0&&(i={label:o,decisions:[],pastSla:0,total:0,bulk:t.key==="urgency"&&a.urgency.type==="routine"},r.set(o,i)),i.decisions.push(a),i.total+=a.value,a.urgency.type==="overdue"&&(i.pastSla+=1)}return[...r.values()]}const gur=[{key:"evidence",label:"Evidence"},{key:"options",label:"Options"},{key:"judgement",label:"Judgement"},{key:"modify",label:"Modify"}],mur={overdue:"danger",due:"warning",routine:"neutral"},vur=560,yur=560;function zat(e,t,n=!1){return Yp(t,_(e.format),n)}function bur(e){const t=_(e.deadline);if(t===void 0)return"";if(e.urgency.type==="overdue"){const n=Math.round((Date.now()-t.getTime())/36e5);return n<1?" <1h":n<48?` ${n}h`:` ${Math.round(n/24)}d`}if(e.urgency.type==="due"){const n=t.getHours(),r=t.getMinutes(),a=n>=12?"pm":"am",o=n%12===0?12:n%12;return r===0?` ${o}${a}`:` ${o}:${String(r).padStart(2,"0")}${a}`}return""}function xur(e){const n=m2().getConfig().workspace??"";return C.useMemo(()=>{var r,a,o;if(!e)return{};const i=F6(n,e.judgements.source);if(!(i!=null&&i.sourceType))return{};const l=(o=(a=(r=I2(i.sourceType).value)==null?void 0:r.fields)==null?void 0:a.constraints)==null?void 0:o.value;return(l==null?void 0:l.type)==="Variant"?l.cases??{}:{}},[e,n])}const wur=C.memo(function({decision:t,handle:n,selected:r,narrow:a,leverPayloads:o,modify:i,evidence:s,defaultFacet:l,facetInclude:c,apply:u,reject:d,leaving:f,storageKey:h}){var g,v;const b=en({key:"decisionQueue"}),y=en({key:"status"}),x=en({key:"facetTabs"}),S=ga({key:"button"}),z=b({}),M=x({}),L=y({status:mur[t.urgency.type],size:"md"}),R=C.useMemo(()=>gur.filter(se=>se.key==="modify"?i!==void 0:c===null||c.has(se.key)),[i,c]),N=R.some(se=>se.key===l)?l:((g=R[0])==null?void 0:g.key)??l,[O,j]=C.useState(N);C.useEffect(()=>{r||j(N)},[r,N]);const B=n.commitStateFor(t.id),H=B===null||B.type==="ready",K=!H&&t.prompts.length>0,U=_(t.summary),Z=C.useCallback(()=>{r||n.select(t.id)},[r,n,t.id]),G=C.useCallback(()=>{H&&u(t)},[H,u,t]),W=C.useCallback(()=>{d(t)},[d,t]),J=C.useMemo(()=>!r||O!=="modify"||!i?null:i(t,n.update),[r,O,i,t,n.update]),ae=C.useMemo(()=>!r||O!=="evidence"||!s?null:s(t),[r,O,s,t]),ne=p.jsx(V,{css:M.root,...a?{display:"flex",width:"100%"}:{},children:R.map(se=>p.jsx(V,{as:"button",css:M.tab,...a?{flex:1}:{},...O===se.key?{"data-on":""}:{},...se.key==="judgement"&&K?{"data-pulse":""}:{},"aria-pressed":O===se.key,onClick:()=>j(se.key),children:se.label},se.key))}),Y=p.jsxs(V,{display:"flex",gap:"6px",...a?{justifyContent:"flex-end"}:{},children:[p.jsx(V,{as:"button",css:S({variant:"solid",size:"xs"}),"aria-disabled":!H,opacity:H?void 0:.5,cursor:H?void 0:"not-allowed",title:H?void 0:"Answer the judgement to enable apply",onClick:G,children:"Apply"}),p.jsx(V,{as:"button",css:S({variant:"ghost",size:"xs"}),onClick:W,children:"Reject"})]}),te=`${t.kind} · ${t.title}${U!==void 0?` · ${U}`:""}`,ie=p.jsxs(V,{css:z.titleText,title:te,cursor:r?void 0:"pointer",onClick:Z,children:[p.jsx(Ie,{as:"span",fontWeight:"semibold",children:t.kind}),p.jsx(Ie,{as:"span",color:"fg.subtle",children:" · "}),p.jsx(Ie,{as:"span",children:t.title}),U!==void 0&&!a&&p.jsxs(p.Fragment,{children:[p.jsx(Ie,{as:"span",color:"fg.subtle",children:" · "}),p.jsx(Ie,{as:"span",color:"fg.muted",children:U})]})]}),ue=p.jsxs(V,{as:"span",css:L.root,flexShrink:0,children:[p.jsx(V,{as:"span",css:L.indicator}),p.jsxs(V,{as:"span",css:L.label,children:[t.urgency.type,bur(t)]})]}),oe=((v=_(t.valueAxis))==null?void 0:v.signed)??!0,ve=p.jsx(Ie,{fontFamily:"mono",fontWeight:"semibold",textAlign:"right",...oe&&t.value>=0&&r?{color:"fg.success"}:{},children:zat(t,t.value,oe&&r)});return p.jsxs(V,{css:z.rowShell,...f?{"data-leaving":f}:{},children:[a?p.jsxs(V,{px:"14px",py:"10px",children:[p.jsxs(V,{display:"flex",justifyContent:"space-between",alignItems:"baseline",children:[ue,ve]}),p.jsx(V,{mt:"2px",fontSize:"13px",children:ie}),r&&p.jsxs(p.Fragment,{children:[p.jsx(V,{mt:"8px",children:ne}),p.jsx(V,{mt:"8px",children:Y})]})]}):p.jsxs(V,{css:z.row,children:[ue,p.jsx(V,{css:z.title,p:0,children:ie}),ve,p.jsxs(V,{display:"flex",alignItems:"center",gap:"12px",children:[r&&ne,Y]})]}),r&&p.jsxs(V,{px:a?"14px":"18px",py:"12px",borderTopWidth:"1px",borderColor:"border.subtle",bg:"bg.canvas",children:[O==="evidence"&&p.jsx(cur,{decision:t,children:ae!=null&&p.jsx(mn,{value:ae,storageKey:`${h}-evidence-${t.id}`})}),O==="options"&&p.jsx(dur,{decision:t,narrow:a}),O==="judgement"&&p.jsx(pur,{decision:t,handle:n,leverPayloads:o}),O==="modify"&&J!=null&&p.jsx(mn,{value:J,storageKey:`${h}-modify-${t.id}`})]})]})}),Sur=C.memo(function({routine:t,acceptAll:n,leaving:r,narrow:a}){const o=en({key:"decisionQueue"}),i=en({key:"status"}),s=ga({key:"button"}),l=o({}),c=i({status:"neutral",size:"md"}),u=C.useMemo(()=>t.reduce((h,g)=>h+g.value,0),[t]),d=t[0]?_(t[0].format):void 0,f=C.useCallback(()=>{n&&n(t)},[n,t]);return t.length===0?null:p.jsxs(V,{css:l.routineGroup,children:[t.map(h=>p.jsx(V,{css:l.rowShell,...r.has(h.id)?{"data-leaving":r.get(h.id)}:{},children:p.jsxs(V,{css:l.routineRow,children:[p.jsxs(V,{as:"span",css:c.root,children:[p.jsx(V,{as:"span",css:c.indicator}),p.jsx(V,{as:"span",css:c.label,children:"routine"})]}),p.jsxs(V,{minW:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",children:[p.jsx(Ie,{as:"span",fontFamily:"mono",children:h.id}),p.jsxs(Ie,{as:"span",color:"fg.muted",children:[" · ",h.kind]})]}),p.jsx(V,{css:l.routineValue,children:zat(h,h.value)})]})},h.id)),p.jsxs(V,{css:l.summary,...a?{marginLeft:"0",flexWrap:"wrap"}:{},children:[p.jsxs(V,{as:"span",css:l.summaryCap,children:[t.length," routine"]}),p.jsx(Ie,{as:"span",color:"fg.subtle",children:"·"}),p.jsx(Ie,{as:"span",fontFamily:"mono",fontWeight:"semibold",children:Yp(u,d)}),p.jsx(Ie,{as:"span",color:"fg.muted",children:"total"}),n&&p.jsx(V,{as:"button",css:s({variant:"solid",size:"xs"}),ml:"auto",onClick:f,children:"Accept all"})]})]})}),Cur=C.memo(function({group:t,collapsible:n,collapsed:r,onToggle:a,acceptAll:o}){const i=en({key:"decisionQueue"}),s=ga({key:"button"}),l=i({}),c=t.decisions[0]?_(t.decisions[0].format):void 0,u=C.useCallback(()=>{n&&a(t.label)},[n,a,t.label]),d=C.useCallback(f=>{f.stopPropagation(),o&&o(t.decisions)},[o,t.decisions]);return p.jsxs(V,{css:l.groupHead,...n?{"data-collapsible":""}:{},onClick:u,children:[n&&p.jsx(V,{as:"span",css:l.groupCaret,children:r?"▸":"▾"}),p.jsxs(V,{as:"span",css:l.groupLabel,children:[t.label," · ",t.decisions.length]}),p.jsxs(V,{as:"span",css:l.groupSummary,children:[Yp(t.total,c),t.pastSla>0?` · ${t.pastSla} past SLA`:""]}),o&&p.jsx(V,{as:"button",css:s({variant:"solid",size:"xs"}),onClick:d,children:"Accept all"})]})}),kur=C.memo(function({value:t,storageKey:n}){var r;const o=en({key:"eyebrowRow"})({}),s=en({key:"decisionQueue"})({}),l=ga({key:"chip"}),c=t.handle,u=wat(c),d=u.decisions,f=xur(c),h=_(t.affordances),g=_(t.slice)??null;rl(g==null?void 0:g.key);const v=g!==null?g.read():null,b=C.useRef(null),y=Rv(b,yur),[x,S]=C.useState(new Map),z=C.useRef(null),M=C.useRef(new Map),L=C.useRef([]);C.useLayoutEffect(()=>{const Ve=z.current;if(z.current=d,!Ve||!d)return;const ut=new Set(d.map(Ft=>Ft.id)),_t=Ve.filter(Ft=>!ut.has(Ft.id));_t.length!==0&&(S(Ft=>{const wt=new Map(Ft);for(const Lt of _t)wt.set(Lt.id,{decision:Lt,reason:M.current.get(Lt.id)??"removed"}),M.current.delete(Lt.id);return wt}),L.current.push(setTimeout(()=>{S(Ft=>{const wt=new Map(Ft);for(const Lt of _t)wt.delete(Lt.id);return wt})},vur)))},[d]),C.useEffect(()=>()=>{for(const Ve of L.current)clearTimeout(Ve)},[]);const R=_(t.heading)??"Decisions waiting",N=C.useMemo(()=>_(t.onApply),[t.onApply]),O=C.useMemo(()=>_(t.onReject),[t.onReject]),j=C.useMemo(()=>_(t.modify),[t.modify]),B=C.useMemo(()=>_(t.evidence),[t.evidence]),H=((r=_(t.defaultFacet))==null?void 0:r.type)??"evidence",K=C.useMemo(()=>{const Ve=_(t.facets);return Ve===void 0?null:new Set(Ve.map(ut=>ut.type))},[t.facets]),U=_(t.defaultExpanded),Z=C.useMemo(()=>_(t.groups)??[],[t.groups]),G=_(t.groupBy),W=G!==void 0,J=W&&(_(t.collapsible)??!0),ae=C.useMemo(()=>[{key:"urgency",label:"Urgency"},{key:"kind",label:"Kind"},...Z.map(Ve=>({key:Ve.label,label:Ve.label,accessor:Ve.value})),{key:"none",label:"None"}],[Z]),{state:ne,setState:Y}=Pl(`${n}.toolbar`,{groupKey:G??"urgency",collapsed:[kat.routine]}),te=ae.find(Ve=>Ve.key===ne.groupKey)??ae[0],ie=u.selected??(U==null?void 0:U.id)??null,ue=C.useCallback((Ve,ut,_t)=>{if(ut)for(const Ft of Ve){const wt=Ft;queueMicrotask(()=>ut(wt))}for(const Ft of Ve)M.current.set(Ft.id,_t),u.resolve(Ft.id,_t==="reject"?$("rejected",null):$("accepted",""))},[u]),oe=C.useCallback(Ve=>ue([Ve],N,"apply"),[ue,N]),ve=C.useCallback(Ve=>ue([Ve],O,"reject"),[ue,O]),se=C.useCallback(Ve=>ue(Ve,N,"apply"),[ue,N]),{merged:pe,active:de,routine:ge,pastSla:ye,visible:me}=C.useMemo(()=>{const Ve=d??[],ut=new Date,_t=g!==null?wht(g.key):void 0,Ft=v!==null&&_t!==void 0?Ve.filter(Lt=>K2(v,_t,Lt,ut)):Ve,wt=[...Ft];for(const{decision:Lt}of x.values())wt.some(Jt=>Jt.id===Lt.id)||wt.push(Lt);return wt.sort((Lt,Jt)=>{var Dt,Et;const Gt=Dve[Lt.urgency.type]-Dve[Jt.urgency.type];if(Gt!==0)return Gt;const Ke=((Dt=_(Lt.deadline))==null?void 0:Dt.getTime())??1/0,Se=((Et=_(Jt.deadline))==null?void 0:Et.getTime())??1/0;return Ke!==Se?Ke-Se:Jt.value-Lt.value}),{merged:wt,active:wt.filter(Lt=>Lt.urgency.type!=="routine"),routine:wt.filter(Lt=>Lt.urgency.type==="routine"),pastSla:wt.filter(Lt=>Lt.urgency.type==="overdue").length,visible:Ft.length}},[d,x,v,g]),Me=C.useMemo(()=>W?hur(pe,te):[],[W,pe,te]),Te=Me.length>0&&Me.every(Ve=>Ve.label===""||ne.collapsed.includes(Ve.label)),Be=C.useCallback(Ve=>{Y(ut=>({...ut,collapsed:ut.collapsed.includes(Ve)?ut.collapsed.filter(_t=>_t!==Ve):[...ut.collapsed,Ve]}))},[Y]),ht=C.useCallback(()=>{const Ve=Te?[]:Me.map(ut=>ut.label).filter(ut=>ut!=="");Y(ut=>({...ut,collapsed:Ve}))},[Y,Te,Me]),De=C.useCallback(Ve=>{Y(ut=>ut.groupKey===Ve?ut:{...ut,groupKey:Ve})},[Y]),Qe=C.useMemo(()=>{const Ve=new Map;for(const[ut,_t]of x)Ve.set(ut,_t.reason);return Ve},[x]),bt=Ve=>p.jsx(wur,{decision:Ve,handle:u,selected:ie===Ve.id,narrow:y,leverPayloads:f,modify:j,evidence:B,defaultFacet:H,facetInclude:K,apply:oe,reject:ve,leaving:Qe.get(Ve.id),storageKey:n},Ve.id);return d===null?p.jsx(V,{layerStyle:"surface.frameless",p:"16px",children:p.jsx(Ie,{color:"fg.muted",fontSize:"13px",children:"Loading decisions…"})}):p.jsxs(V,{ref:b,layerStyle:"surface.frameless",overflow:"hidden",children:[p.jsxs(V,{css:o.root,children:[p.jsx(V,{css:o.lbl,children:R}),g!==null&&h!==void 0&&p.jsx(V,{display:"flex",alignItems:"center",minWidth:"0",flex:"1",justifyContent:"flex-end",marginRight:"10px",children:p.jsx(zd,{slice:g,affordanceKinds:h.map(Ve=>Ve.type)})}),p.jsxs(V,{css:o.meta,gap:"10px",children:[p.jsxs(V,{as:"span",children:[p.jsx(Ie,{as:"span",color:"fg",fontWeight:"semibold",children:me}),y?"":" decisions"]}),ye>0&&p.jsxs(p.Fragment,{children:[p.jsx(V,{as:"span",css:o.sep,children:"·"}),p.jsxs(V,{as:"span",children:[p.jsx(Ie,{as:"span",color:"fg.danger",fontWeight:"semibold",children:ye}),y?" SLA":" past SLA"]})]})]})]}),W&&p.jsxs(V,{css:s.toolbar,children:[p.jsx(V,{as:"span",css:s.segLabel,children:"Group by"}),ae.map(Ve=>p.jsx(V,{as:"button",css:{...l({tone:ne.groupKey===Ve.key?"brand":"neutral",size:"sm"}),cursor:"pointer"},"aria-pressed":ne.groupKey===Ve.key,onClick:()=>De(Ve.key),children:Ve.label},Ve.key)),J&&p.jsx(V,{as:"button",css:s.collapseAll,onClick:ht,children:Te?"Expand all":"Collapse all"})]}),p.jsx(V,{maxHeight:_(t.maxHeight),overflowY:t.maxHeight.type==="some"?"auto":void 0,children:W?Me.map(Ve=>{const ut=J&&Ve.label!==""&&ne.collapsed.includes(Ve.label);return p.jsxs(V,{children:[Ve.label!==""&&p.jsx(Cur,{group:Ve,collapsible:J,collapsed:ut,onToggle:Be,acceptAll:Ve.bulk?se:void 0}),!ut&&Ve.decisions.map(bt)]},Ve.label||"_flat")}):p.jsxs(p.Fragment,{children:[de.map(bt),p.jsx(Sur,{routine:ge,acceptAll:se,leaving:Qe,narrow:y})]})})]})});pk(Q7t.Component,kur);function zur(e){switch(e.type){case"accepted":return{tone:"success",verb:"accepted",detail:e.value!==""?e.value:null};case"rejected":return{tone:"danger",verb:"rejected",detail:null};case"deferred":return{tone:"neutral",verb:"deferred",detail:e.value.type==="some"?e.value.value:null};case"handoff":return{tone:"warning",verb:"handed off",detail:e.value!==""?e.value:null}}}function Mur(e){if(e.resolvedAt.type!=="some")return null;const t=e.resolvedAt.value,n=t.toLocaleString("en",{month:"short"}),r=`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`;return`${n} ${t.getDate()} · ${r}`}const Tur=C.memo(function({value:t}){const n=en({key:"eyebrowRow"}),r=en({key:"status"}),a=n({}),o=wat(t.handle),i=_(t.heading)??"Decision journal",l=m2().getConfig().workspace??"",c=C.useMemo(()=>{var d,f,h;const g=F6(l,t.handle.judgements.source);if(!(g!=null&&g.sourceType))return{};const b=(h=(f=(d=I2(g.sourceType).value)==null?void 0:d.fields)==null?void 0:f.constraints)==null?void 0:h.value;return(b==null?void 0:b.type)==="Variant"?b.cases??{}:{}},[l,t.handle]),u=C.useMemo(()=>o.journal??[],[o.journal]);return p.jsxs(V,{borderWidth:"1px",borderColor:"border.strong",borderRadius:"6px",background:"bg.canvas",overflow:"hidden",children:[p.jsxs(V,{css:a.root,children:[p.jsx(V,{css:a.lbl,children:i}),p.jsx(V,{css:a.meta,children:u.length===1?"1 entry":`${u.length} entries`})]}),p.jsx(V,{maxHeight:_(t.maxHeight),overflowY:t.maxHeight.type==="some"?"auto":void 0,children:u.length===0?p.jsx(Ie,{px:"16px",py:"14px",fontSize:"13px",color:"fg.muted",children:"No resolved cases yet — verdicts land here as the queue clears."}):u.map((d,f)=>{const h=d.verdict.type==="some"?d.verdict.value:null;if(!h)return null;const{tone:g,verb:v,detail:b}=zur(h),y=r({status:g,size:"md"}),x=Mur(d),S=d.knowledge.type==="some"&&d.knowledge.value!==""?d.knowledge.value:null;return p.jsxs(V,{px:"16px",py:"10px",borderTopWidth:f===0?void 0:"1px",borderColor:"border.subtle",display:"flex",flexDirection:"column",gap:"6px",children:[p.jsxs(V,{display:"flex",alignItems:"baseline",gap:"10px",children:[p.jsxs(V,{as:"span",css:y.root,flexShrink:0,children:[p.jsx(V,{as:"span",css:y.indicator}),p.jsx(V,{as:"span",css:y.label,children:v})]}),p.jsx(Ie,{as:"span",fontFamily:"mono",fontSize:"12px",color:"fg.muted",children:d.caseId}),b!==null&&p.jsx(Ie,{as:"span",fontSize:"13px",minW:0,flex:"1",truncate:!0,children:b}),x!==null&&p.jsx(Ie,{as:"span",fontFamily:"mono",fontSize:"11.5px",color:"fg.muted",marginLeft:"auto",flexShrink:0,children:x})]}),S!==null&&p.jsxs(Ie,{fontSize:"12.5px",fontStyle:"italic",color:"fg.muted",borderLeftWidth:"2px",borderColor:"border.strong",paddingLeft:"10px",children:["“",S,"”"]}),d.constraints.length>0&&p.jsx(V,{display:"flex",gap:"12px",flexWrap:"wrap",children:d.constraints.map((z,M)=>{const L=z.type,R=Cat(z,c[L]);return p.jsx(Gkn,{field:R.lever,op:R.op,value:R.value},M)})})]},d.caseId)})})]})});pk(tht.Component,Tur);function Eur(e){if(e instanceof h1&&e.details!=null){const t=e.details;return typeof t=="string"?{message:e.message,details:t}:typeof t=="object"&&"message"in t?{message:e.message,details:String(t.message)}:{message:e.message,details:JSON.stringify(t)}}return{message:e instanceof Error?e.message:String(e)}}function Mat(e){return e instanceof ct?e.formattedMessage:e.message}function _ur(e,t,n,r){return rHn({mutationFn:({path:a,data:o})=>Yte(e,t,n,a,o,r??{token:null})})}function Tat(e,t,n,r,a){const{requestOptions:o,pollInterval:i=5e3,queryOverrides:s}=a??{},l=o??{token:null},c=C.useMemo(()=>(r==null?void 0:r.split(".").filter(Boolean).map(u=>$("field",u)))??[],[r]);return LI({queryKey:["datasetStatus",e,t,n,r],queryFn:async()=>{var u,d;const f=await sgt(e,t,n,c,l);return{path:f.path,type:f.type,refType:f.refType,hash:((u=f.hash)==null?void 0:u.type)==="some"?f.hash.value:null,sizeBytes:((d=f.size)==null?void 0:d.type)==="some"?Number(f.size.value):null}},enabled:!!n&&!!r,refetchInterval:i,...s})}const Lur=[...mN,...Hte,...Vte,...Ete,...Die,...Wte,...Ute,...qte,...g1e,...lQe,...uQe,...xJe];function Eat(e,t,n,r,a){const{requestOptions:o,queryOverrides:i,enabled:s=!0,hash:l,platforms:c,type:u}=a,d=c??Lur,f=o??{token:null},h=C.useMemo(()=>(r==null?void 0:r.split(".").filter(Boolean).map(g=>$("field",g)))??[],[r]);return LI({queryKey:["datasetValue",e,t,n,r,l??null],queryFn:async()=>{const g=await bN(e,t,n,h,f);return{decoded:Ra(u,{platform:d})(g.data),sizeBytes:g.data.length}},enabled:s&&!!n&&!!r&&l!=null,...i})}function Rur(e,t,n,r,a){const o=C.useMemo(()=>a??{token:null},[a]),i=C.useMemo(()=>(r==null?void 0:r.split(".").filter(Boolean).map(s=>$("field",s)))??[],[r]);return C.useCallback(async()=>{if(!n||!r)return;const s=await bN(e,t,n,i,o),l=new Blob([new Uint8Array(s.data)],{type:"application/octet-stream"}),c=URL.createObjectURL(l),u=document.createElement("a");u.href=c,u.download=`${r.replace(/\./g,"_")}.beast2`,document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(c)},[e,t,n,r,i,o])}function m1e(e,t,n,r,a){const o=(a==null?void 0:a.requestOptions)??{token:null};return LI({queryKey:["taskDetails",e,t,n,r],queryFn:()=>KCe(e,t,n,r,o),enabled:!!t&&!!n&&!!r,...a==null?void 0:a.queryOverrides})}function _at(e){var t;return((t=e.kind)==null?void 0:t.type)==="some"?e.kind.value:null}function Pur(e){var t;return((t=e.metadata)==null?void 0:t.type)==="some"?e.metadata.value:null}const Aur={error:{bg:"bg.danger.subtle",titleColor:"fg.danger",messageColor:"fg.muted",detailsBg:"bg.muted",detailsColor:"fg.default"},warning:{bg:"bg.warning.subtle",titleColor:"fg.warning",messageColor:"fg.muted",detailsBg:"bg.muted",detailsColor:"fg.default"},info:{bg:"transparent",titleColor:"fg.muted",messageColor:"fg.subtle",detailsBg:"bg.muted",detailsColor:"fg.default"},loading:{bg:"transparent",titleColor:"fg.muted",messageColor:"fg.subtle",detailsBg:"bg.muted",detailsColor:"fg.default"}};function si({variant:e,title:t,message:n,details:r}){const a=Aur[e];return e==="info"||e==="loading"?p.jsx(V,{"data-status":e,height:"100%",width:"100%",display:"flex",alignItems:"center",justifyContent:"center",bg:a.bg,children:p.jsxs(W1,{gap:2,children:[e==="loading"&&p.jsx(yVn,{animate:!0,size:"52px"}),p.jsx(Ie,{color:a.titleColor,fontSize:e==="loading"?"sm":"lg",children:t}),n&&p.jsx(Ie,{color:a.messageColor,fontSize:"sm",children:n}),r&&p.jsxs(V,{position:"relative",mt:2,width:"100%",children:[p.jsx(qw,{display:"block",whiteSpace:"pre-wrap",p:4,pr:10,bg:a.detailsBg,color:a.detailsColor,borderRadius:"md",fontSize:"sm",overflow:"auto",maxHeight:"300px",children:r}),p.jsx(dK,{value:r,position:"absolute",top:1,right:1,children:p.jsx(fK,{asChild:!0,children:p.jsx(fc,{size:"xs",variant:"ghost","aria-label":"Copy error details",children:p.jsx(Uw,{copied:p.jsx(Ur,{icon:o7}),children:p.jsx(Ur,{icon:qX})})})})})]})]})}):p.jsxs(V,{"data-status":e,p:6,bg:a.bg,height:"100%",width:"100%",children:[p.jsx(Ie,{fontSize:"lg",fontWeight:"bold",color:a.titleColor,mb:4,children:t}),n&&p.jsx(Ie,{color:a.messageColor,mb:r?4:0,children:n}),r&&p.jsxs(V,{position:"relative",children:[p.jsx(qw,{display:"block",whiteSpace:"pre-wrap",p:4,pr:10,bg:a.detailsBg,color:a.detailsColor,borderRadius:"md",fontSize:"sm",overflow:"auto",maxHeight:"300px",children:r}),p.jsx(dK,{value:r,position:"absolute",top:1,right:1,children:p.jsx(fK,{asChild:!0,children:p.jsx(fc,{size:"xs",variant:"ghost","aria-label":"Copy error details",children:p.jsx(Uw,{copied:p.jsx(Ur,{icon:o7}),children:p.jsx(Ur,{icon:qX})})})})})]})]})}class Nur extends C.Component{constructor(t){super(t),this.state={error:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,n){console.error("[ErrorBoundary] render exception caught:",t,n.componentStack)}componentDidUpdate(t){this.state.error!==null&&t.children!==this.props.children&&this.setState({error:null})}render(){return this.state.error!==null?p.jsx(si,{variant:"error",title:"Rendering error",details:Mat(this.state.error)}):this.props.children}}function bg(...e){try{if(typeof localStorage>"u")return;const t=localStorage.getItem("e3-paging-debug");if(t===null||t==="off")return}catch{return}console.info("[e3-paging]",...e)}const v3=500;function $ur(e,t,n){if(e.type==="Array"){const a=e.value;return t.map((o,i)=>({node:$3.materialize(a,o),step:$("index",BigInt(n+i))}))}if(e.type==="Dict"){const{key:a,value:o}=e.value,i=zr(a),s=a.type==="String";return Array.from(t.entries()).map(([l,c],u)=>({node:$3.materialize(o,c),step:s?$("key",l):$("index",BigInt(n+u)),label:s?l:i(l)}))}const r=e.value;return Array.from(t.values()).map((a,o)=>({node:$3.materialize(r,a),step:$("index",BigInt(n+o))}))}function Iur(e){return e.type==="Array"?[]:e.type==="Dict"?new Map:new Set}const Dur=C.memo(function({apiUrl:t,repo:n,workspace:r,path:a,type:o,hash:i,sizeBytes:s,requestOptions:l,onDownload:c}){const u=_I(),[d,f]=C.useState(new Map),[h,g]=C.useState(null),[v,b]=C.useState(0),[y,x]=C.useState(null),S=C.useRef(new Set);C.useEffect(()=>{bg(`reset (path=${a}, hash=${i.slice(0,8)})`),f(new Map),g(null),x(null),S.current.clear()},[a,i]);const z=C.useCallback(O=>{if(S.current.has(O))return;S.current.add(O),b(H=>H+1),bg(`fetch p${O} (offset=${O*v3}, limit=${v3}, hash=${i.slice(0,8)})`);const j=a.split(".").filter(Boolean).map(H=>$("field",H)),B=l??{token:null};u.fetchQuery({queryKey:["datasetPage",t,n,r,a,i,`p${O}`],queryFn:()=>agt(t,n,r,j,{offset:O*v3,limit:v3,hash:i},B),staleTime:1/0}).then(H=>{const K=Ra(o)(H.data),U=$ur(o,K,H.offset);bg(`p${O} ok: count=${H.count} rows=${U.length} offset=${H.offset} total=${H.totalElements} segs=${H.segmentCount}`,U.length>0?`first=${JSON.stringify(U[0].label??"(derived)")}`:"(empty)"),H.count<v3&&H.offset+H.count<H.totalElements&&bg(`p${O} SHORT page: server clamped ${v3} → ${H.count}`),g({elements:H.totalElements,bytes:H.totalBytes}),f(Z=>new Map(Z).set(O,U))}).catch(H=>{bg(`p${O} FAILED:`,H),x(H instanceof Error?H:new Error(String(H)))}).finally(()=>{S.current.delete(O),b(H=>H-1)})},[u,t,n,r,a,i,l,o]);C.useEffect(()=>{h===null&&y===null&&z(0)},[h,y,z]);const M=C.useCallback((O,j)=>{const B=Math.max(0,Math.floor(O/v3)),H=Math.max(B,Math.ceil(j/v3)-1),K=[];for(let U=B;U<=H;U++)d.has(U)||K.push(U);bg(`need rows [${O}, ${j}) → pages ${B}..${H}, missing=[${K.join(",")}], inflight=[${[...S.current].join(",")}]`);for(const U of K)z(U)},[d,z]),L=C.useMemo(()=>({root:$3.materialize(o,Iur(o)),onEdit:A,onInsert:A,onRemove:A,onTag:A,style:P({height:P("100%"),maxHeight:A,openDepth:A,toolbar:P(!0)})}),[o]),R=C.useMemo(()=>h===null?null:{totalRows:h.elements,pageSize:v3,pages:d,onNeedRows:M},[h,d,M]);if(y!==null)return y instanceof h1&&y.code==="dataset_too_large"?p.jsxs(Vo,{height:"100%",direction:"column",align:"center",justify:"center",gap:3,p:6,children:[p.jsx(Ie,{fontSize:"lg",color:"fg.warning",fontWeight:"bold",children:"Too large to page"}),p.jsx(Ie,{color:"fg.muted",fontSize:"sm",textAlign:"center",maxW:"32rem",children:typeof y.details=="string"?y.details:"This dataset cannot be paged server-side."}),p.jsx(aP,{onClick:c,label:"Download value"})]}):p.jsx(si,{variant:"error",title:"Paged load failed",message:y.message});if(R===null||h===null)return p.jsx(si,{variant:"loading",title:"Loading..."});const N=o.type==="Dict"?"entries":"items";return p.jsxs(Vo,{direction:"column",height:"100%",overflow:"hidden",children:[p.jsxs(Vo,{px:4,py:2,gap:2,align:"center",flexShrink:0,borderBottom:"1px solid",borderColor:"border.subtle",children:[p.jsxs(Ie,{fontSize:"xs",color:"fg.muted",whiteSpace:"nowrap",children:[h.elements.toLocaleString()," ",N," · ",__(h.bytes>0?h.bytes:s)]}),v>0&&p.jsx(Ie,{fontSize:"xs",color:"fg.muted",children:"Loading…"}),p.jsx(Vo,{flex:1,justify:"flex-end",children:p.jsx(aP,{onClick:c})})]}),p.jsx(V,{flex:1,minHeight:0,overflow:"hidden",children:p.jsx(Aie,{value:L,storageKey:`${a}:page`,paging:R})})]})},(e,t)=>e.path===t.path&&e.workspace===t.workspace&&e.hash===t.hash&&e.sizeBytes===t.sizeBytes),Our=200*1024;function __(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function aP({onClick:e,label:t}){const[n,r]=C.useState(!1),a=async()=>{r(!0);try{await e()}finally{r(!1)}};return p.jsxs(fu,{size:"sm",variant:"outline",onClick:a,loading:n,loadingText:"Downloading...",children:[p.jsx(Ur,{icon:oKn}),t??"Download"]})}const Lat=C.memo(function({apiUrl:t,repo:n,workspace:r,path:a,requestOptions:o,sizeLimit:i=Our,pollInterval:s,editable:l=!1}){var c;const u=Tat(t,n,r,a,{...o!=null&&{requestOptions:o},...s!==void 0&&{pollInterval:s}}),d=u.data,f=(d==null?void 0:d.refType)==="value"&&d.hash!==null,h=(d==null?void 0:d.sizeBytes)??0,g=f&&h>i,v=f&&!g,b=Eat(t,n,r,a,{...o!=null&&{requestOptions:o},type:d==null?void 0:d.type,hash:(d==null?void 0:d.hash)??null,enabled:v,queryOverrides:{placeholderData:TVn}}),y=Rur(t,n,r,a,o),x=_ur(t,n,r,o),S=_I(),z=d==null?void 0:d.type,M=(c=b.data)==null?void 0:c.decoded,L=C.useCallback(async j=>{if(r==null||a==null||z===void 0)return;const B=a.split(".").filter(Boolean).map(K=>$("field",K)),H=Ei(z)(j);await x.mutateAsync({path:B,data:H}),await S.invalidateQueries({queryKey:["datasetStatus",t,n,r,a]})},[t,n,r,a,z,x,S]),R=C.useMemo(()=>{if(z===void 0||M===void 0)return null;const j=$3.materialize(z,M),B=l?{onEdit:P((H,K)=>L($3.applyEdit(z,M,H,{kind:"edit",leaf:K}))),onInsert:P(H=>L($3.applyEdit(z,M,H,{kind:"insert"}))),onRemove:P(H=>L($3.applyEdit(z,M,H,{kind:"remove"}))),onTag:P((H,K)=>L($3.applyEdit(z,M,H,{kind:"tag",tag:K})))}:{onEdit:A,onInsert:A,onRemove:A,onTag:A};return{root:j,...B,style:P({height:P("100%"),maxHeight:A,openDepth:A,toolbar:P(!0)})}},[z,M,l,L]);if(u.isLoading)return p.jsx(si,{variant:"loading",title:"Loading..."});if(u.error){const{message:j,details:B}=Eur(u.error);return p.jsx(si,{variant:"error",title:"Error",message:j,details:B??Mat(u.error)})}if(!d)return p.jsx(si,{variant:"info",title:"No status"});if(!f)return p.jsx(si,{variant:"info",title:"No data available",message:"Waiting for a value to be set"});if(g)return z!==void 0&&(z.type==="Array"||z.type==="Set"||z.type==="Dict")&&r!=null&&a!=null&&d.hash!=null?p.jsx(Dur,{apiUrl:t,repo:n,workspace:r,path:a,type:z,hash:d.hash,sizeBytes:h,...o!=null&&{requestOptions:o},onDownload:y}):p.jsxs(Vo,{height:"100%",direction:"column",align:"center",justify:"center",layerStyle:"banner.stale",borderRadius:"0",gap:3,p:6,children:[p.jsx(Ie,{fontSize:"lg",color:"fg.warning",fontWeight:"bold",children:"Value too large to display"}),p.jsxs(Ie,{color:"fg.muted",fontSize:"sm",children:["The data is ",__(h),", which exceeds the ",__(i)," display limit."]}),p.jsx(aP,{onClick:y,label:"Download value"})]});if(b.isLoading||!b.data)return p.jsx(si,{variant:"loading",title:"Loading..."});if(b.error)return p.jsx(si,{variant:"error",title:"Decode failed",message:b.error.message});const N=z===void 0||M===void 0?null:z.type==="Array"?M.length:z.type==="Set"||z.type==="Dict"?M.size:null,O=N===null?"":`${N.toLocaleString()} ${(z==null?void 0:z.type)==="Dict"?"entries":"items"} · `;return p.jsxs(Vo,{direction:"column",height:"100%",overflow:"hidden",children:[p.jsxs(Vo,{px:4,py:2,justify:"flex-end",flexShrink:0,borderBottom:"1px solid",borderColor:"border.subtle",children:[p.jsxs(Ie,{fontSize:"xs",color:"fg.muted",mr:2,alignSelf:"center",children:[O,__(h)]}),p.jsx(aP,{onClick:y})]}),p.jsx(V,{flex:1,minHeight:0,overflow:"hidden",children:R!==null&&p.jsx(Aie,{value:R,storageKey:a??"value"})})]})});C.memo(function({apiUrl:t,repo:n,workspace:r,path:a,requestOptions:o}){const i=a.replace(/^\.inputs\./,"");return p.jsxs(V,{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden",children:[p.jsx(Vo,{px:4,py:2,borderBottom:"1px solid",borderColor:"border.subtle",bg:"bg.surface",align:"center",justify:"space-between",children:p.jsx(Ie,{fontSize:"sm",fontWeight:"medium",color:"fg",children:i})}),p.jsx(V,{flex:1,overflow:"hidden",minHeight:0,children:p.jsx(Lat,{apiUrl:t,repo:n,workspace:r,path:a,editable:!0,...o!=null&&{requestOptions:o}})})]})},(e,t)=>e.path===t.path&&e.workspace===t.workspace);function jur(e){return e.map(t=>t.value).join(".")}const Fur=C.memo(function({task:t,config:n,pollInterval:r=1e3,bare:a=!1}){var o,i;const s=yKn(),l=SJe(),c=(n==null?void 0:n.apiUrl)??(s==null?void 0:s.apiUrl)??null,u=(n==null?void 0:n.repo)??(s==null?void 0:s.repo)??"default",d=(n==null?void 0:n.workspace)??(s==null?void 0:s.workspace)??null,h={token:(n==null?void 0:n.token)??(s==null?void 0:s.token)??null},g=m1e(c??"",u,d,t,{requestOptions:h}),v=g.data,b=v?_at(v):null,y=b==="ui",x=C.useMemo(()=>{if(!v||!y)return null;const B=Pur(v);return B?l0t(B):{paths:[],functions:[],records:[]}},[v,y]),S=v?jur(v.output):null,z=C.useMemo(()=>x&&d?x.paths.map(B=>({workspace:d,path:B})):[],[x,d]),{loading:M,error:L}=xKn(z),R=C.useMemo(()=>x?[...mN,...Hte,...Vte,...Ete,...Die,...Wte,...Ute,...qte,...g1e,...sWn(x),...hWn(x.functions),...gKn(x.records)]:void 0,[x]);C.useEffect(()=>{if(!(!l||!x||!d)){for(const B of x.paths)l.setRefetchInterval(d,B,r);return()=>{for(const B of x.paths)l.clearRefetchInterval(d,B)}}},[l,x,d,r]);const N=Tat(c??"",u,d,S,{requestOptions:h}),O=Eat(c??"",u,d,S,{requestOptions:h,type:(o=N.data)==null?void 0:o.type,hash:((i=N.data)==null?void 0:i.hash)??null,...R&&{platforms:R}}),j=C.useMemo(()=>oht(),[t]);return c?g.isLoading?p.jsx(si,{variant:"loading",title:"Loading task..."}):g.error?p.jsx(si,{variant:"error",title:"Error",message:g.error.message}):v?y?L?p.jsx(si,{variant:"error",title:"Preload failed",message:L.message}):M?p.jsx(si,{variant:"loading",title:"Loading datasets..."}):N.isLoading||!N.data?p.jsx(si,{variant:"loading",title:"Loading..."}):N.data.refType!=="value"?p.jsx(si,{variant:"info",title:"No output yet",message:"Task has not produced a value"}):O.isLoading||!O.data?p.jsx(si,{variant:"loading",title:"Loading..."}):O.error?p.jsx(si,{variant:"error",title:"Decode failed",message:O.error.message}):p.jsx(OZe,{store:j,children:p.jsx(Nur,{children:p.jsx(V,{height:"100%",overflow:a?void 0:"auto",p:a?void 0:"4",minH:a?0:void 0,children:p.jsx(mn,{value:O.data.decoded,storageKey:S??t})})})}):p.jsx(si,{variant:"error",title:"Not a UI task",message:`Task "${t}" has kind "${b??"(none)"}"`}):p.jsx(si,{variant:"info",title:"No task",message:`Task "${t}" not found`}):p.jsx(si,{variant:"error",title:"Configuration error",message:"No apiUrl available — render UITaskPreview inside an <E3Provider> or pass a config prop."})});function Bur({text:e,lineMatches:t,currentMatchIndex:n,globalMatches:r}){if(t.length===0)return p.jsx(p.Fragment,{children:e||" "});const a=[];let o=0;return t.forEach((i,s)=>{i.start>o&&a.push(p.jsx("span",{children:e.slice(o,i.start)},`t${s}`));const c=r.findIndex(u=>u.lineIndex===i.lineIndex&&u.start===i.start)===n;a.push(p.jsx("span",{style:{backgroundColor:c?"#f59e0b":"#fbbf24",color:"#000",borderRadius:"2px",outline:c?"2px solid #f59e0b":void 0},children:e.slice(i.start,i.end)},`m${s}`)),o=i.end}),o<e.length&&a.push(p.jsx("span",{children:e.slice(o)},"end")),p.jsx(p.Fragment,{children:a})}function Vur({content:e,tabs:t}){const n=C.useRef(null),[r,a]=C.useState(!1),[o,i]=C.useState(""),[s,l]=C.useState(0),[c,u]=C.useState(!0),[d,f]=C.useState(!1),h=C.useMemo(()=>e?e.split(`
|
|
2231
2231
|
`):[""],[e]),{matches:g,matchesByLine:v}=C.useMemo(()=>{const j=[],B=new Map;if(!o)return{matches:j,matchesByLine:B};const H=o.toLowerCase();return h.forEach((K,U)=>{const Z=K.toLowerCase(),G=[];let W=0;for(;;){const J=Z.indexOf(H,W);if(J===-1)break;const ae={lineIndex:U,start:J,end:J+o.length};j.push(ae),G.push(ae),W=J+1}G.length>0&&B.set(U,G)}),{matches:j,matchesByLine:B}},[h,o]);C.useEffect(()=>{l(0)},[o]);const b=gHn({count:h.length,getScrollElement:()=>n.current,estimateSize:()=>20,overscan:20}),y=C.useCallback(j=>{if(g.length===0)return;const B=g[j];B&&b.scrollToIndex(B.lineIndex,{align:"center"})},[g,b]);C.useEffect(()=>{g.length>0&&y(0)},[g,y]);const x=C.useCallback(()=>{g.length!==0&&l(j=>{const B=j===0?g.length-1:j-1;return y(B),B})},[g.length,y]),S=C.useCallback(()=>{g.length!==0&&l(j=>{const B=j===g.length-1?0:j+1;return y(B),B})},[g.length,y]),z=C.useCallback(j=>{j.key==="Enter"?(j.shiftKey?x():S(),j.preventDefault()):j.key==="Escape"&&i("")},[x,S]),M=C.useCallback(()=>{const j=n.current;return j?j.scrollHeight-j.scrollTop-j.clientHeight<50:!0},[]),L=C.useCallback(()=>{const j=M();u(j),j&&f(!1)},[M]),R=C.useCallback(()=>{b.scrollToIndex(h.length-1,{align:"end"}),f(!1),u(!0)},[b,h.length]),N=C.useRef(h.length);C.useEffect(()=>{h.length>N.current&&(!o&&c?b.scrollToIndex(h.length-1,{align:"end"}):o||f(!0)),N.current=h.length},[h.length,b,o,c]);const O=C.useCallback(async()=>{try{await navigator.clipboard.writeText(e),a(!0),setTimeout(()=>a(!1),2e3)}catch{}},[e]);return p.jsxs(V,{height:"100%",display:"flex",flexDirection:"column",p:"4",children:[p.jsxs(Vo,{px:3,py:2,bg:"gray.800",borderTopRadius:"md",align:"center",justify:"space-between",flexShrink:0,gap:2,children:[p.jsx(HIt,{value:t,size:"sm",variant:"line",children:p.jsxs(uNe,{borderBottom:"none",children:[p.jsx(zK,{value:"stdout",color:"gray.300",_selected:{color:"white"},children:"stdout"}),p.jsx(zK,{value:"stderr",color:"gray.300",_selected:{color:"white"},children:"stderr"})]})}),p.jsxs(Vo,{align:"center",gap:1,children:[p.jsx(s9,{size:"xs",placeholder:"Search...",value:o,onChange:j=>i(j.target.value),onKeyDown:z,bg:"gray.700",border:"none",color:"white",_placeholder:{color:"gray.400"},width:"min(150px, 40vw)"}),o&&p.jsx(Ie,{fontSize:"xs",color:"gray.400",minWidth:"50px",textAlign:"center",children:g.length>0?`${s+1}/${g.length}`:"0/0"}),p.jsx(fc,{variant:"ghost",size:"xs",onClick:x,color:"gray.400",_hover:{color:"white"},"aria-label":"Previous match",disabled:g.length===0,children:p.jsx(Ur,{icon:QGn})}),p.jsx(fc,{variant:"ghost",size:"xs",onClick:S,color:"gray.400",_hover:{color:"white"},"aria-label":"Next match",disabled:g.length===0,children:p.jsx(Ur,{icon:hS})}),p.jsx(fc,{variant:"ghost",size:"xs",onClick:O,color:"gray.400",_hover:{color:"white"},"aria-label":"Copy logs",children:p.jsx(Ur,{icon:r?o7:qX})})]})]}),p.jsxs(V,{position:"relative",flex:"1",minHeight:0,children:[p.jsx(V,{ref:n,layerStyle:"surface.log.dark",height:"100%",overflow:"auto",borderBottomRadius:"md",borderTopWidth:"0",fontFamily:"mono",fontSize:"sm",color:"gray.100",onScroll:L,children:p.jsx("div",{style:{height:`${b.getTotalSize()}px`,width:"100%",position:"relative"},children:b.getVirtualItems().map(j=>{const B=j.index,H=h[B]??"",K=v.get(B)||[];return p.jsx("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:`${j.size}px`,transform:`translateY(${j.start}px)`},children:p.jsxs(Vo,{px:3,py:.5,_hover:{bg:"gray.800"},children:[p.jsx(Ie,{as:"span",color:"gray.500",minWidth:"50px",textAlign:"right",mr:3,userSelect:"none",flexShrink:0,children:B+1}),p.jsx(Ie,{as:"span",whiteSpace:"pre",wordBreak:"break-all",flex:1,children:p.jsx(Bur,{text:H,lineMatches:K,currentMatchIndex:s,globalMatches:g})})]})},j.key)})})}),d&&p.jsx(V,{position:"absolute",bottom:3,right:3,cursor:"pointer",onClick:R,children:p.jsxs(_re,{variant:"brand",px:3,py:1,borderRadius:"full",display:"flex",alignItems:"center",gap:2,boxShadow:"md",children:[p.jsx(Ur,{icon:bJe}),"New logs"]})})]})]})}const Hur=64*1024,Wur=10*1024*1024;async function Uur(e,t,n,r,a,o){try{let i="",s=0,l=0n;for(;;){const c=await ZCe(e,t,n,r,{stream:a,offset:s,limit:Hur},o??{token:null});if(i+=c.data,l=c.totalSize,c.complete||i.length>=Wur||c.size===0n)break;s+=Number(c.size)}return{data:i,offset:0n,size:BigInt(i.length),totalSize:l,complete:!0}}catch{return{data:"",offset:0n,size:0n,totalSize:0n,complete:!0}}}function Ove(e,t,n,r,a="stdout",o,i){return LI({queryKey:["taskLogs",e,t,n,r,a],queryFn:()=>Uur(e,t,n,r,a,o),enabled:!!n&&!!r,refetchInterval:1e3,...i})}const qur=C.memo(function({apiUrl:t,repo:n,workspace:r,task:a,requestOptions:o}){const{data:i}=Ove(t,n,r,a,"stdout",o),{data:s}=Ove(t,n,r,a,"stderr",o),l=C.useMemo(()=>(i==null?void 0:i.data)??"",[i==null?void 0:i.data]),c=C.useMemo(()=>(s==null?void 0:s.data)??"",[s==null?void 0:s.data]),u=TRe({defaultValue:"stdout"}),d=C.useMemo(()=>u.value==="stderr"?c:l,[u.value,c,l]);return p.jsx(Vur,{content:d,tabs:u})});function Gur(e){return e.map(t=>t.value).join(".")}const Kur=C.memo(function({apiUrl:t,repo:n,workspace:r,task:a,requestOptions:o,initialView:i="output",sizeLimit:s}){const[l,c]=C.useState(i),u=m1e(t,n,r,a,{...o!=null&&{requestOptions:o}}),d=u.data?Gur(u.data.output):null;return p.jsxs(V,{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden",children:[p.jsx(Vo,{px:4,py:2,borderBottom:"1px solid",borderColor:"border.subtle",bg:"bg.surface",align:"center",justify:"flex-end",flexShrink:0,children:p.jsxs(Wre,{size:"xs",value:l,onValueChange:f=>c(f.value),children:[p.jsx(Ure,{}),p.jsxs(Gw,{value:"output",title:"Output",children:[p.jsx(Kw,{children:p.jsx(Ur,{icon:JGn})}),p.jsx(Yw,{})]}),p.jsxs(Gw,{value:"logs",title:"Logs",children:[p.jsx(Kw,{children:p.jsx(Ur,{icon:eKn})}),p.jsx(Yw,{})]})]})}),p.jsx(V,{flex:1,overflow:"hidden",minHeight:0,children:l==="output"?u.isLoading?p.jsx(si,{variant:"loading",title:"Loading task..."}):u.error?p.jsx(si,{variant:"error",title:"Error",message:u.error.message}):p.jsx(Lat,{apiUrl:t,repo:n,workspace:r,path:d,...o!=null&&{requestOptions:o},...s!==void 0&&{sizeLimit:s}}):p.jsx(qur,{apiUrl:t,repo:n,workspace:r,task:a,...o!=null&&{requestOptions:o}})})]})}),Yur=C.memo(function({apiUrl:t,repo:n,workspace:r,task:a,requestOptions:o,bare:i=!1}){const s=m1e(t,n,r,a,{...o!=null&&{requestOptions:o}}),l=s.data?_at(s.data):null;return p.jsxs(V,{height:"100%",display:"flex",flexDirection:"column",overflow:"hidden",children:[!i&&p.jsx(Vo,{px:4,py:2,borderBottom:"1px solid",borderColor:"border.subtle",bg:"bg.surface",align:"center",flexShrink:0,children:p.jsx(Ie,{fontSize:"sm",fontWeight:"medium",color:"fg",children:a})}),p.jsx(V,{flex:1,overflow:"hidden",minHeight:0,children:s.isLoading?p.jsx(si,{variant:"loading",title:"Loading task..."}):s.error?p.jsx(si,{variant:"error",title:"Error",message:s.error.message}):l==="ui"?p.jsx(Fur,{task:a,bare:i,config:{apiUrl:t,repo:n,workspace:r,token:(o==null?void 0:o.token)??null}}):p.jsx(Kur,{apiUrl:t,repo:n,workspace:r,task:a,...o!=null&&{requestOptions:o}})})]})},(e,t)=>e.task===t.task&&e.repo===t.repo&&e.workspace===t.workspace&&e.bare===t.bare);var _U={exports:{}},Ub={},LU={exports:{}},RU={};/**
|
|
2232
2232
|
* @license React
|
|
2233
2233
|
* scheduler.production.js
|