@marimo-team/frontend 0.22.1-dev25 → 0.22.1-dev26

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.
@@ -26,7 +26,7 @@ ${So(t)}
26
26
  # replace ${e} with your data source
27
27
  ${new dj(a,cj(t,e).toCode()).toCode()}
28
28
  ${a}
29
- `.trim()}function xr(t){let e={};for(let[a,r]of Object.entries(t))r!==void 0&&(e[a]=a==="field"&&typeof r=="string"?new gr(EA(r)):new gr(r));return e}const fx=(0,f.createContext)({fields:[],saveForm:Xa.NOOP,chartType:xa.LINE}),da=()=>(0,f.use)(fx);var pj=te(),Ad=f.forwardRef((t,e)=>{let a=(0,pj.c)(25),{className:r,valueMap:n,...i}=t,[o,l]=oy(!1),{locale:d}=rt(),u=ub,c;a[0]===r?c=a[1]:(c=Y("relative flex touch-none select-none hover:cursor-pointer","data-[orientation=horizontal]:w-full data-[orientation=horizontal]:items-center","data-[orientation=vertical]:h-full data-[orientation=vertical]:justify-center","data-disabled:cursor-not-allowed",r),a[0]=r,a[1]=c);let m;a[2]===Symbol.for("react.memo_cache_sentinel")?(m=Y("relative grow overflow-hidden rounded-full bg-slate-200 dark:bg-accent/60","data-[orientation=horizontal]:h-2 data-[orientation=horizontal]:w-full","data-[orientation=vertical]:h-full data-[orientation=vertical]:w-2"),a[2]=m):m=a[2];let p;a[3]===Symbol.for("react.memo_cache_sentinel")?(p=(0,s.jsx)(hs,{"data-testid":"track",className:m,children:(0,s.jsx)(fs,{"data-testid":"range",className:Y("absolute bg-blue-500 dark:bg-primary","data-[orientation=horizontal]:h-full","data-[orientation=vertical]:w-full","data-disabled:opacity-50")})}),a[3]=p):p=a[3];let h=_t,x=bc,g;a[4]!==l.setFalse||a[5]!==l.setTrue?(g=(0,s.jsx)(Dc,{asChild:!0,children:(0,s.jsx)(Mi,{"data-testid":"thumb",className:"block h-4 w-4 rounded-full shadow-xs-solid border border-blue-500 dark:border-primary dark:bg-accent bg-white hover:bg-blue-300 focus:bg-blue-300 transition-colors focus-visible:outline-hidden data-disabled:pointer-events-none data-disabled:opacity-50",onFocus:l.setTrue,onBlur:l.setFalse,onMouseEnter:l.setTrue,onMouseLeave:l.setFalse})}),a[4]=l.setFalse,a[5]=l.setTrue,a[6]=g):g=a[6];let y=jc,b=i.value!=null&&i.value.length===1&&(0,s.jsx)(wc,{children:bn(n(i.value[0]),{locale:d})},i.value[0]),w;a[7]!==y||a[8]!==b?(w=(0,s.jsx)(y,{children:b}),a[7]=y,a[8]=b,a[9]=w):w=a[9];let D;a[10]!==x||a[11]!==o||a[12]!==g||a[13]!==w?(D=(0,s.jsxs)(x,{delayDuration:0,open:o,children:[g,w]}),a[10]=x,a[11]=o,a[12]=g,a[13]=w,a[14]=D):D=a[14];let j;a[15]!==h||a[16]!==D?(j=(0,s.jsx)(h,{children:D}),a[15]=h,a[16]=D,a[17]=j):j=a[17];let C;return a[18]!==i||a[19]!==e||a[20]!==u.Root||a[21]!==j||a[22]!==c||a[23]!==p?(C=(0,s.jsxs)(u.Root,{ref:e,className:c,...i,children:[p,j]}),a[18]=i,a[19]=e,a[20]=u.Root,a[21]=j,a[22]=c,a[23]=p,a[24]=C):C=a[24],C});Ad.displayName=Pi.displayName;var hj=Na(vi(),1),Ro=0,Wa=1,Zr=2,gx=4;function xx(t){return()=>t}function fj(t){t()}function Zn(t,e){return a=>t(e(a))}function vx(t,e){return()=>t(e)}function gj(t,e){return a=>t(e,a)}function Id(t){return t!==void 0}function xj(...t){return()=>{t.map(fj)}}function Kr(){}function No(t,e){return e(t),t}function vj(t,e){return e(t)}function Ve(...t){return t}function Te(t,e){return t(Wa,e)}function xe(t,e){t(Ro,e)}function Pd(t){t(Zr)}function Ze(t){return t(gx)}function ne(t,e){return Te(t,gj(e,Ro))}function Gt(t,e){let a=t(Wa,r=>{a(),e(r)});return a}function yx(t){let e,a;return r=>n=>{e=n,a&&clearTimeout(a),a=setTimeout(()=>{r(e)},t)}}function bx(t,e){return t===e}function ze(t=bx){let e;return a=>r=>{t(e,r)||(e=r,a(r))}}function ue(t){return e=>a=>{t(a)&&e(a)}}function ae(t){return e=>Zn(e,t)}function ua(t){return e=>()=>{e(t)}}function U(t,...e){let a=yj(...e);return((r,n)=>{switch(r){case Zr:Pd(t);return;case Wa:return Te(t,a(n))}})}function ca(t,e){return a=>r=>{a(e=t(e,r))}}function vr(t){return e=>a=>{t>0?t--:e(a)}}function ka(t){let e=null,a;return r=>n=>{e=n,!a&&(a=setTimeout(()=>{a=void 0,r(e)},t))}}function ye(...t){let e=Array(t.length),a=0,r=null,n=2**t.length-1;return t.forEach((i,o)=>{let l=2**o;Te(i,d=>{let u=a;a|=l,e[o]=d,u!==n&&a===n&&r&&(r(),r=null)})}),i=>o=>{let l=()=>{i([o].concat(e))};a===n?l():r=l}}function yj(...t){return e=>t.reduceRight(vj,e)}function bj(t){let e,a,r=()=>e==null?void 0:e();return function(n,i){switch(n){case Wa:return i?a===i?void 0:(r(),a=i,e=Te(t,i),e):(r(),Kr);case Zr:r(),a=null;return}}}function q(t){let e=t,a=Ce();return((r,n)=>{switch(r){case Ro:e=n;break;case Wa:n(e);break;case gx:return e}return a(r,n)})}function yt(t,e){return No(q(e),a=>ne(t,a))}function Ce(){let t=[];return((e,a)=>{switch(e){case Ro:t.slice().forEach(r=>{r(a)});return;case Zr:t.splice(0,t.length);return;case Wa:return t.push(a),()=>{let r=t.indexOf(a);r>-1&&t.splice(r,1)}}})}function St(t){return No(Ce(),e=>ne(t,e))}function Ee(t,e=[],{singleton:a}={singleton:!0}){return{constructor:t,dependencies:e,id:wj(),singleton:a}}var wj=()=>Symbol();function Dj(t){let e=new Map,a=({constructor:r,dependencies:n,id:i,singleton:o})=>{if(o&&e.has(i))return e.get(i);let l=r(n.map(d=>a(d)));return o&&e.set(i,l),l};return a(t)}function nt(...t){let e=Ce(),a=Array(t.length),r=0,n=2**t.length-1;return t.forEach((i,o)=>{let l=2**o;Te(i,d=>{a[o]=d,r|=l,r===n&&xe(e,a)})}),function(i,o){switch(i){case Zr:Pd(e);return;case Wa:return r===n&&o(a),Te(e,o)}}}function ce(t,e=bx){return U(t,ze(e))}function Md(...t){return function(e,a){switch(e){case Zr:return;case Wa:return xj(...t.map(r=>Te(r,a)))}}}var Ct=(t=>(t[t.DEBUG=0]="DEBUG",t[t.INFO=1]="INFO",t[t.WARN=2]="WARN",t[t.ERROR=3]="ERROR",t))(Ct||{}),jj={0:"debug",3:"error",1:"log",2:"warn"},Cj=()=>typeof globalThis>"u"?window:globalThis,Ua=Ee(()=>{let t=q(3);return{log:q((e,a,r=1)=>{r>=(Cj().VIRTUOSO_LOG_LEVEL??Ze(t))&&console[jj[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",e,a)}),logLevel:t}},[],{singleton:!0});function ma(t,e,a){return Fd(t,e,a).callbackRef}function Fd(t,e,a){let r=f.useRef(null),n=o=>{},i=f.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(o=>{let l=()=>{let d=o[0].target;d.offsetParent!==null&&t(d)};a?l():requestAnimationFrame(l)}):null,[t,a]);return n=o=>{o&&e?(i==null||i.observe(o),r.current=o):(r.current&&(i==null||i.unobserve(r.current)),r.current=null)},{callbackRef:n,ref:r}}function wx(t,e,a,r,n,i,o,l,d){return Fd(f.useCallback(u=>{let c=kj(u.children,e,l?"offsetWidth":"offsetHeight",n),m=u.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;let p=m.lastElementChild.dataset.viewportType==="window",h;p&&(h=m.ownerDocument.defaultView);let x=o?l?o.scrollLeft:o.scrollTop:p?l?h.scrollX||h.document.documentElement.scrollLeft:h.scrollY||h.document.documentElement.scrollTop:l?m.scrollLeft:m.scrollTop,g=o?l?o.scrollWidth:o.scrollHeight:p?l?h.document.documentElement.scrollWidth:h.document.documentElement.scrollHeight:l?m.scrollWidth:m.scrollHeight,y=o?l?o.offsetWidth:o.offsetHeight:p?l?h.innerWidth:h.innerHeight:l?m.offsetWidth:m.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(x,0),viewportHeight:y}),i==null||i(l?Dx("column-gap",getComputedStyle(u).columnGap,n):Dx("row-gap",getComputedStyle(u).rowGap,n)),c!==null&&t(c)},[t,e,n,i,o,r,l]),a,d)}function kj(t,e,a,r){let n=t.length;if(n===0)return null;let i=[];for(let o=0;o<n;o++){let l=t.item(o);if(l.dataset.index===void 0)continue;let d=parseInt(l.dataset.index),u=parseFloat(l.dataset.knownSize),c=e(l,a);if(c===0&&r("Zero-sized element, this should not happen",{child:l},Ct.ERROR),c===u)continue;let m=i[i.length-1];i.length===0||m.size!==c||m.endIndex!==d-1?i.push({endIndex:d,size:c,startIndex:d}):i[i.length-1].endIndex++}return i}function Dx(t,e,a){return e!=="normal"&&!(e!=null&&e.endsWith("px"))&&a(`${t} was not resolved to pixel value correctly`,e,Ct.WARN),e==="normal"?0:parseInt(e??"0",10)}function Vd(t,e,a){let r=f.useRef(null),n=f.useCallback(d=>{if(!(d!=null&&d.offsetParent))return;let u=d.getBoundingClientRect(),c=u.width,m,p;if(e){let h=e.getBoundingClientRect(),x=u.top-h.top;p=h.height-Math.max(0,x),m=x+e.scrollTop}else{let h=o.current.ownerDocument.defaultView;p=h.innerHeight-Math.max(0,u.top),m=u.top+h.scrollY}r.current={offsetTop:m,visibleHeight:p,visibleWidth:c},t(r.current)},[t,e]),{callbackRef:i,ref:o}=Fd(n,!0,a),l=f.useCallback(()=>{n(o.current)},[n,o]);return f.useEffect(()=>{var d;if(e){e.addEventListener("scroll",l);let u=new ResizeObserver(()=>{requestAnimationFrame(l)});return u.observe(e),()=>{e.removeEventListener("scroll",l),u.unobserve(e)}}else{let u=(d=o.current)==null?void 0:d.ownerDocument.defaultView;return u==null||u.addEventListener("scroll",l),u==null||u.addEventListener("resize",l),()=>{u==null||u.removeEventListener("scroll",l),u==null||u.removeEventListener("resize",l)}}},[l,e,o]),i}var Dt=Ee(()=>{let t=Ce(),e=Ce(),a=q(0),r=Ce(),n=q(0),i=Ce(),o=Ce(),l=q(0),d=q(0),u=q(0),c=q(0),m=Ce(),p=Ce(),h=q(!1),x=q(!1),g=q(!1);return ne(U(t,ae(({scrollTop:y})=>y)),e),ne(U(t,ae(({scrollHeight:y})=>y)),o),ne(e,n),{deviation:a,fixedFooterHeight:u,fixedHeaderHeight:d,footerHeight:c,headerHeight:l,horizontalDirection:x,scrollBy:p,scrollContainerState:t,scrollHeight:o,scrollingInProgress:h,scrollTo:m,scrollTop:e,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:n,viewportHeight:i}},[],{singleton:!0}),Kn={lvl:0};function jx(t,e){let a=t.length;if(a===0)return[];let{index:r,value:n}=e(t[0]),i=[];for(let o=1;o<a;o++){let{index:l,value:d}=e(t[o]);i.push({end:l-1,start:r,value:n}),r=l,n=d}return i.push({end:1/0,start:r,value:n}),i}function _e(t){return t===Kn}function Yn(t,e){if(!_e(t))return e===t.k?t.v:e<t.k?Yn(t.l,e):Yn(t.r,e)}function Qt(t,e,a="k"){if(_e(t))return[-1/0,void 0];if(Number(t[a])===e)return[t.k,t.v];if(Number(t[a])<e){let r=Qt(t.r,e,a);return r[0]===-1/0?[t.k,t.v]:r}return Qt(t.l,e,a)}function Et(t,e,a){return _e(t)?Sx(e,a,1):e===t.k?ct(t,{k:e,v:a}):e<t.k?Ex(ct(t,{l:Et(t.l,e,a)})):Ex(ct(t,{r:Et(t.r,e,a)}))}function Yr(){return Kn}function qr(t,e,a){if(_e(t))return[];let r=Qt(t,e)[0];return Sj(Od(t,r,a))}function zd(t,e){if(_e(t))return Kn;let{k:a,l:r,r:n}=t;if(e===a){if(_e(r))return n;if(_e(n))return r;{let[i,o]=kx(r);return Ld(ct(t,{k:i,l:Cx(r),v:o}))}}else return Ld(e<a?ct(t,{l:zd(r,e)}):ct(t,{r:zd(n,e)}))}function yr(t){return _e(t)?[]:[...yr(t.l),{k:t.k,v:t.v},...yr(t.r)]}function Od(t,e,a){if(_e(t))return[];let{k:r,l:n,r:i,v:o}=t,l=[];return r>e&&(l=l.concat(Od(n,e,a))),r>=e&&r<=a&&l.push({k:r,v:o}),r<=a&&(l=l.concat(Od(i,e,a))),l}function Ld(t){let{l:e,lvl:a,r}=t;if(r.lvl>=a-1&&e.lvl>=a-1)return t;if(a>r.lvl+1){if($d(e))return Rx(ct(t,{lvl:a-1}));if(!_e(e)&&!_e(e.r))return ct(e.r,{l:ct(e,{r:e.r.l}),lvl:a,r:ct(t,{l:e.r.r,lvl:a-1})});throw Error("Unexpected empty nodes")}else{if($d(t))return Bd(ct(t,{lvl:a-1}));if(!_e(r)&&!_e(r.l)){let n=r.l,i=$d(n)?r.lvl-1:r.lvl;return ct(n,{l:ct(t,{lvl:a-1,r:n.l}),lvl:n.lvl+1,r:Bd(ct(r,{l:n.r,lvl:i}))})}else throw Error("Unexpected empty nodes")}}function ct(t,e){return Sx(e.k===void 0?t.k:e.k,e.v===void 0?t.v:e.v,e.lvl===void 0?t.lvl:e.lvl,e.l===void 0?t.l:e.l,e.r===void 0?t.r:e.r)}function Cx(t){return _e(t.r)?t.l:Ld(ct(t,{r:Cx(t.r)}))}function $d(t){return _e(t)||t.lvl>t.r.lvl}function kx(t){return _e(t.r)?[t.k,t.v]:kx(t.r)}function Sx(t,e,a,r=Kn,n=Kn){return{k:t,l:r,lvl:a,r:n,v:e}}function Ex(t){return Bd(Rx(t))}function Rx(t){let{l:e}=t;return!_e(e)&&e.lvl===t.lvl?ct(e,{r:ct(t,{l:e.r})}):t}function Bd(t){let{lvl:e,r:a}=t;return!_e(a)&&!_e(a.r)&&a.lvl===e&&a.r.lvl===e?ct(a,{l:ct(t,{r:a.l}),lvl:e+1}):t}function Sj(t){return jx(t,({k:e,v:a})=>({index:e,value:a}))}function Nx(t,e){return!!(t&&t.startIndex===e.startIndex&&t.endIndex===e.endIndex)}function qn(t,e){return!!(t&&t[0]===e[0]&&t[1]===e[1])}var Hd=Ee(()=>({recalcInProgress:q(!1)}),[],{singleton:!0});function Tx(t,e,a){return t[To(t,e,a)]}function To(t,e,a,r=0){let n=t.length-1;for(;r<=n;){let i=Math.floor((r+n)/2),o=t[i],l=a(o,e);if(l===0)return i;if(l===-1){if(n-r<2)return i-1;n=i-1}else{if(n===r)return i;r=i+1}}throw Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${e}`)}function Ej(t,e,a,r){let n=To(t,e,r),i=To(t,a,r,n);return t.slice(n,i+1)}function Jt(t,e){return Math.round(t.getBoundingClientRect()[e])}function _o(t){return!_e(t.groupOffsetTree)}function Wd({index:t},e){return e===t?0:e<t?-1:1}function Rj(){return{groupIndices:[],groupOffsetTree:Yr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Yr()}}function Nj(t,e){let a=_e(t)?0:1/0;for(let r of e){let{endIndex:n,size:i,startIndex:o}=r;if(a=Math.min(a,o),_e(t)){t=Et(t,0,i);continue}let l=qr(t,o-1,n+1);if(l.some(Fj(r)))continue;let d=!1,u=!1;for(let{end:c,start:m,value:p}of l)d?(n>=m||i===p)&&(t=zd(t,m)):(u=p!==i,d=!0),c>n&&n>=m&&p!==i&&(t=Et(t,n+1,p));u&&(t=Et(t,o,i))}return[t,a]}function Tj(t){return typeof t.groupIndex<"u"}function _j({offset:t},e){return e===t?0:e<t?-1:1}function Gn(t,e,a){if(e.length===0)return 0;let{index:r,offset:n,size:i}=Tx(e,t,Wd),o=t-r,l=i*o+(o-1)*a+n;return l>0?l+a:l}function _x(t,e){if(!_o(e))return t;let a=0;for(;e.groupIndices[a]<=t+a;)a++;return t+a}function Ax(t,e,a){if(Tj(t))return e.groupIndices[t.groupIndex]+1;{let r=_x(t.index==="LAST"?a:t.index,e);return r=Math.max(0,r,Math.min(a,r)),r}}function Aj(t,e,a,r=0){return r>0&&(e=Math.max(e,Tx(t,r,Wd).offset)),jx(Ej(t,e,a,_j),Mj)}function Ij(t,[e,a,r,n]){e.length>0&&r("received item sizes",e,Ct.DEBUG);let i=t.sizeTree,o=i,l=0;if(a.length>0&&_e(i)&&e.length===2){let p=e[0].size,h=e[1].size;o=a.reduce((x,g)=>Et(Et(x,g,p),g+1,h),o)}else[o,l]=Nj(o,e);if(o===i)return t;let{lastIndex:d,lastOffset:u,lastSize:c,offsetTree:m}=Ud(t.offsetTree,l,o,n);return{groupIndices:a,groupOffsetTree:a.reduce((p,h)=>Et(p,h,Gn(h,m,n)),Yr()),lastIndex:d,lastOffset:u,lastSize:c,offsetTree:m,sizeTree:o}}function Pj(t){return yr(t).map(({k:e,v:a},r,n)=>{let i=n[r+1];return{endIndex:i?i.k-1:1/0,size:a,startIndex:e}})}function Ix(t,e){let a=0,r=0;for(;a<t;)a+=e[r+1]-e[r]-1,r++;return r-(a===t?0:1)}function Ud(t,e,a,r){let n=t,i=0,o=0,l=0,d=0;if(e!==0){d=To(n,e-1,Wd),l=n[d].offset;let u=Qt(a,e-1);i=u[0],o=u[1],n.length&&n[d].size===Qt(a,e)[1]&&--d,n=n.slice(0,d+1)}else n=[];for(let{start:u,value:c}of qr(a,e,1/0)){let m=u-i,p=m*o+l+m*r;n.push({index:u,offset:p,size:c}),i=u,l=p,o=c}return{lastIndex:i,lastOffset:l,lastSize:o,offsetTree:n}}function Mj(t){return{index:t.index,value:t}}function Fj(t){let{endIndex:e,size:a,startIndex:r}=t;return n=>n.start===r&&(n.end===e||n.end===1/0)&&n.value===a}var Vj={offsetHeight:"height",offsetWidth:"width"},pa=Ee(([{log:t},{recalcInProgress:e}])=>{let a=Ce(),r=Ce(),n=yt(r,0),i=Ce(),o=Ce(),l=q(0),d=q([]),u=q(void 0),c=q(void 0),m=q(void 0),p=q(void 0),h=q((k,v)=>Jt(k,Vj[v])),x=q(void 0),g=q(0),y=Rj(),b=yt(U(a,ye(d,t,g),ca(Ij,y),ze()),y),w=yt(U(d,ze(),ca((k,v)=>({current:v,prev:k.current}),{current:[],prev:[]}),ae(({prev:k})=>k)),[]);ne(U(d,ue(k=>k.length>0),ye(b,g),ae(([k,v,E])=>{let N=k.reduce((R,_,V)=>Et(R,_,Gn(_,v.offsetTree,E)||V),Yr());return{...v,groupIndices:k,groupOffsetTree:N}})),b),ne(U(r,ye(b),ue(([k,{lastIndex:v}])=>k<v),ae(([k,{lastIndex:v,lastSize:E}])=>[{endIndex:v,size:E,startIndex:k}])),a),ne(u,c);let D=yt(U(u,ae(k=>k===void 0)),!0);ne(U(c,ue(k=>k!==void 0&&_e(Ze(b).sizeTree)),ae(k=>{let v=Ze(m),E=Ze(d).length>0;return v?E?[{endIndex:0,size:v,startIndex:0},{endIndex:1,size:k,startIndex:1}]:[]:[{endIndex:0,size:k,startIndex:0}]})),a),ne(U(p,ue(k=>k!==void 0&&k.length>0&&_e(Ze(b).sizeTree)),ae(k=>{let v=[],E=k[0],N=0;for(let R=1;R<k.length;R++){let _=k[R];_!==E&&(v.push({endIndex:R-1,size:E,startIndex:N}),E=_,N=R)}return v.push({endIndex:k.length-1,size:E,startIndex:N}),v})),a),ne(U(d,ye(m,c),ue(([,k,v])=>k!==void 0&&v!==void 0),ae(([k,v,E])=>{let N=[];for(let R=0;R<k.length;R++){let _=k[R],V=k[R+1];N.push({startIndex:_,endIndex:_,size:v}),V!==void 0&&N.push({startIndex:_+1,endIndex:V-1,size:E})}return N})),a);let j=St(U(a,ye(b),ca(({sizes:k},[v,E])=>({changed:E!==k,sizes:E}),{changed:!1,sizes:y}),ae(k=>k.changed)));Te(U(l,ca((k,v)=>({diff:k.prev-v,prev:v}),{diff:0,prev:0}),ae(k=>k.diff)),k=>{let{groupIndices:v}=Ze(b);if(k>0)xe(e,!0),xe(i,k+Ix(k,v));else if(k<0){let E=Ze(w);E.length>0&&(k-=Ix(-k,E)),xe(o,k)}}),Te(U(l,ye(t)),([k,v])=>{k<0&&v("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:l},Ct.ERROR)});let C=St(i);ne(U(i,ye(b),ae(([k,v])=>{let E=v.groupIndices.length>0,N=[],R=v.lastSize;if(E){let _=Yn(v.sizeTree,0),V=0,I=0;for(;V<k;){let T=v.groupIndices[I],P=v.groupIndices.length===I+1?1/0:v.groupIndices[I+1]-T-1;N.push({endIndex:T,size:_,startIndex:T}),N.push({endIndex:T+1+P-1,size:R,startIndex:T+1}),I++,V+=P+1}let A=yr(v.sizeTree);return V!==k&&A.shift(),A.reduce((T,{k:P,v:F})=>{let O=T.ranges;return T.prevSize!==0&&(O=[...T.ranges,{endIndex:P+k-1,size:T.prevSize,startIndex:T.prevIndex}]),{prevIndex:P+k,prevSize:F,ranges:O}},{prevIndex:k,prevSize:0,ranges:N}).ranges}return yr(v.sizeTree).reduce((_,{k:V,v:I})=>({prevIndex:V+k,prevSize:I,ranges:[..._.ranges,{endIndex:V+k-1,size:_.prevSize,startIndex:_.prevIndex}]}),{prevIndex:0,prevSize:R,ranges:[]}).ranges})),a);let S=St(U(o,ye(b,g),ae(([k,{offsetTree:v},E])=>Gn(-k,v,E))));return ne(U(o,ye(b,g),ae(([k,v,E])=>{if(v.groupIndices.length>0){if(_e(v.sizeTree))return v;let N=Yr(),R=Ze(w),_=0,V=0,I=0;for(;_<-k;){I=R[V];let A=R[V+1]-I-1;V++,_+=A+1}if(N=yr(v.sizeTree).reduce((A,{k:T,v:P})=>Et(A,Math.max(0,T+k),P),N),_!==-k){let A=Yn(v.sizeTree,I);N=Et(N,0,A);let T=Qt(v.sizeTree,-k+1)[1];N=Et(N,1,T)}return{...v,sizeTree:N,...Ud(v.offsetTree,0,N,E)}}else{let N=yr(v.sizeTree).reduce((R,{k:_,v:V})=>Et(R,Math.max(0,_+k),V),Yr());return{...v,sizeTree:N,...Ud(v.offsetTree,0,N,E)}}})),b),{beforeUnshiftWith:C,data:x,defaultItemSize:c,firstItemIndex:l,fixedItemSize:u,fixedGroupSize:m,gap:g,groupIndices:d,heightEstimates:p,itemSize:h,listRefresh:j,shiftWith:o,shiftWithOffset:S,sizeRanges:a,sizes:b,statefulTotalCount:n,totalCount:r,trackItemSizes:D,unshiftWith:i}},Ve(Ua,Hd),{singleton:!0});function zj(t){return t.reduce((e,a)=>(e.groupIndices.push(e.totalCount),e.totalCount+=a+1,e),{groupIndices:[],totalCount:0})}var Px=Ee(([{groupIndices:t,sizes:e,totalCount:a},{headerHeight:r,scrollTop:n}])=>{let i=Ce(),o=Ce(),l=St(U(i,ae(zj)));return ne(U(l,ae(d=>d.totalCount)),a),ne(U(l,ae(d=>d.groupIndices)),t),ne(U(nt(n,e,r),ue(([d,u])=>_o(u)),ae(([d,u,c])=>Qt(u.groupOffsetTree,Math.max(d-c,0),"v")[0]),ze(),ae(d=>[d])),o),{groupCounts:i,topItemsIndexes:o}},Ve(pa,Dt)),Za=Ee(([{log:t}])=>{let e=q(!1),a=St(U(e,ue(r=>r),ze()));return Te(e,r=>{r&&Ze(t)("props updated",{},Ct.DEBUG)}),{didMount:a,propsReady:e}},Ve(Ua),{singleton:!0}),Oj=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Mx(t){let e=typeof t=="number"?{index:t}:t;return e.align||(e.align="start"),(!e.behavior||!Oj)&&(e.behavior="auto"),e.offset||(e.offset=0),e}var Qn=Ee(([{gap:t,listRefresh:e,sizes:a,totalCount:r},{fixedFooterHeight:n,fixedHeaderHeight:i,footerHeight:o,headerHeight:l,scrollingInProgress:d,scrollTo:u,smoothScrollTargetReached:c,viewportHeight:m},{log:p}])=>{let h=Ce(),x=Ce(),g=q(0),y=null,b=null,w=null;function D(){y&&(y=(y(),null)),w&&(w=(w(),null)),b&&(b=(clearTimeout(b),null)),xe(d,!1)}return ne(U(h,ye(a,m,r,g,l,o,p),ye(t,i,n),ae(([[j,C,S,k,v,E,N,R],_,V,I])=>{let A=Mx(j),{align:T,behavior:P,offset:F}=A,O=k-1,z=Ax(A,C,O),B=Gn(z,C.offsetTree,_)+E;T==="end"?(B+=V+Qt(C.sizeTree,z)[1]-S+I,z===O&&(B+=N)):T==="center"?B+=(V+Qt(C.sizeTree,z)[1]-S+I)/2:B-=v,F&&(B+=F);let J=ee=>{D(),ee?(R("retrying to scroll to",{location:j},Ct.DEBUG),xe(h,j)):(xe(x,!0),R("list did not change, scroll successful",{},Ct.DEBUG))};if(D(),P==="smooth"){let ee=!1;w=Te(e,X=>{ee||(ee=X)}),y=Gt(c,()=>{J(ee)})}else y=Gt(U(e,Lj(150)),J);return b=setTimeout(()=>{D()},1200),xe(d,!0),R("scrolling from index to",{behavior:P,index:z,top:B},Ct.DEBUG),{behavior:P,top:B}})),u),{scrollTargetReached:x,scrollToIndex:h,topListHeight:g}},Ve(pa,Dt,Ua),{singleton:!0});function Lj(t){return e=>{let a=setTimeout(()=>{e(!1)},t);return r=>{r&&(e(!0),clearTimeout(a))}}}function Zd(t,e){t==0?e():requestAnimationFrame(()=>{Zd(t-1,e)})}function Kd(t,e){let a=e-1;return typeof t=="number"?t:t.index==="LAST"?a:t.index}var Jn=Ee(([{defaultItemSize:t,listRefresh:e,sizes:a},{scrollTop:r},{scrollTargetReached:n,scrollToIndex:i},{didMount:o}])=>{let l=q(!0),d=q(0),u=q(!0);return ne(U(o,ye(d),ue(([c,m])=>!!m),ua(!1)),l),ne(U(o,ye(d),ue(([c,m])=>!!m),ua(!1)),u),Te(U(nt(e,o),ye(l,a,t,u),ue(([[,c],m,{sizeTree:p},h,x])=>c&&(!_e(p)||Id(h))&&!m&&!x),ye(d)),([,c])=>{Gt(n,()=>{xe(u,!0)}),Zd(4,()=>{Gt(r,()=>{xe(l,!0)}),xe(i,c)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:d,scrolledToInitialItem:l}},Ve(pa,Dt,Qn,Za),{singleton:!0});function Fx(t,e){return Math.abs(t-e)<1.01}var Xn="up",ei="down",$j="none",Bj={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Hj=0,ti=Ee(([{footerHeight:t,headerHeight:e,scrollBy:a,scrollContainerState:r,scrollTop:n,viewportHeight:i}])=>{let o=q(!1),l=q(!0),d=Ce(),u=Ce(),c=q(4),m=q(Hj),p=yt(U(Md(U(ce(n),vr(1),ua(!0)),U(ce(n),vr(1),ua(!1),yx(100))),ze()),!1),h=yt(U(Md(U(a,ua(!0)),U(a,ua(!1),yx(200))),ze()),!1);ne(U(nt(ce(n),ce(m)),ae(([w,D])=>w<=D),ze()),l),ne(U(l,ka(50)),u);let x=St(U(nt(r,ce(i),ce(e),ce(t),ce(c)),ca((w,[{scrollHeight:D,scrollTop:j},C,S,k,v])=>{let E=j+C-D>-v,N={scrollHeight:D,scrollTop:j,viewportHeight:C};if(E){let _,V;return j>w.state.scrollTop?(_="SCROLLED_DOWN",V=w.state.scrollTop-j):(_="SIZE_DECREASED",V=w.state.scrollTop-j||w.scrollTopDelta),{atBottom:!0,atBottomBecause:_,scrollTopDelta:V,state:N}}let R;return R=N.scrollHeight>w.state.scrollHeight?"SIZE_INCREASED":C<w.state.viewportHeight?"VIEWPORT_HEIGHT_DECREASING":j<w.state.scrollTop?"SCROLLING_UPWARDS":"NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:R,state:N}},Bj),ze((w,D)=>w&&w.atBottom===D.atBottom))),g=yt(U(r,ca((w,{scrollHeight:D,scrollTop:j,viewportHeight:C})=>{if(Fx(w.scrollHeight,D))return{changed:!1,jump:0,scrollHeight:D,scrollTop:j};{let S=D-(j+C)<1;return w.scrollTop!==j&&S?{changed:!0,jump:w.scrollTop-j,scrollHeight:D,scrollTop:j}:{changed:!0,jump:0,scrollHeight:D,scrollTop:j}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ue(w=>w.changed),ae(w=>w.jump)),0);ne(U(x,ae(w=>w.atBottom)),o),ne(U(o,ka(50)),d);let y=q(ei);ne(U(r,ae(({scrollTop:w})=>w),ze(),ca((w,D)=>Ze(h)?{direction:w.direction,prevScrollTop:D}:{direction:D<w.prevScrollTop?Xn:ei,prevScrollTop:D},{direction:ei,prevScrollTop:0}),ae(w=>w.direction)),y),ne(U(r,ka(50),ua($j)),y);let b=q(0);return ne(U(p,ue(w=>!w),ua(0)),b),ne(U(n,ka(100),ye(p),ue(([w,D])=>D),ca(([w,D],[j])=>[D,j],[0,0]),ae(([w,D])=>D-w)),b),{atBottomState:x,atBottomStateChange:d,atBottomThreshold:c,atTopStateChange:u,atTopThreshold:m,isAtBottom:o,isAtTop:l,isScrolling:p,lastJumpDueToItemResize:g,scrollDirection:y,scrollVelocity:b}},Ve(Dt)),ai="top",ri="bottom",Vx="none";function zx(t,e,a){return typeof t=="number"?a===Xn&&e===ai||a===ei&&e===ri?t:0:a===Xn?e===ai?t.main:t.reverse:e===ri?t.main:t.reverse}function Ox(t,e){return typeof t=="number"?t:t[e]??0}var Yd=Ee(([{deviation:t,fixedHeaderHeight:e,headerHeight:a,scrollTop:r,viewportHeight:n}])=>{let i=Ce(),o=q(0),l=q(0),d=q(0);return{increaseViewportBy:l,listBoundary:i,overscan:d,topListHeight:o,visibleRange:yt(U(nt(ce(r),ce(n),ce(a),ce(i,qn),ce(d),ce(o),ce(e),ce(t),ce(l)),ae(([u,c,m,[p,h],x,g,y,b,w])=>{let D=u-b,j=g+y,C=Math.max(m-D,0),S=Vx,k=Ox(w,ai),v=Ox(w,ri);return p-=b,p+=m+y,h+=m+y,h-=b,p>u+j-k&&(S=Xn),h<u-C+c+v&&(S=ei),S===Vx?null:[Math.max(D-m-zx(x,ai,S)-k,0),D-C-y+c+zx(x,ri,S)+v]}),ue(u=>u!=null),ze(qn)),[0,0])}},Ve(Dt),{singleton:!0});function Wj(t,e,a){if(_o(e)){let r=_x(t,e);return[{index:Qt(e.groupOffsetTree,r)[0],offset:0,size:0},{data:a==null?void 0:a[0],index:r,offset:0,size:0}]}return[{data:a==null?void 0:a[0],index:t,offset:0,size:0}]}var qd={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ao(t,e,a,r,n,i){let{lastIndex:o,lastOffset:l,lastSize:d}=n,u=0,c=0;if(t.length>0){u=t[0].offset;let g=t[t.length-1];c=g.offset+g.size}let m=a-o,p=l+m*d+(m-1)*r,h=u,x=p-c;return{bottom:c,firstItemIndex:i,items:$x(t,n,i),offsetBottom:x,offsetTop:u,top:h,topItems:$x(e,n,i),topListHeight:e.reduce((g,y)=>y.size+g,0),totalCount:a}}function Lx(t,e,a,r,n,i){let o=0;if(a.groupIndices.length>0)for(let u of a.groupIndices){if(u-o>=t)break;o++}let l=t+o,d=Kd(e,l);return Ao(Array.from({length:l}).map((u,c)=>({data:i[c+d],index:c+d,offset:0,size:0})),[],l,n,a,r)}function $x(t,e,a){if(t.length===0)return[];if(!_o(e))return t.map(u=>({...u,index:u.index+a,originalIndex:u.index}));let r=t[0].index,n=t[t.length-1].index,i=[],o=qr(e.groupOffsetTree,r,n),l,d=0;for(let u of t){(!l||l.end<u.index)&&(l=o.shift(),d=e.groupIndices.indexOf(l.start));let c;c=u.index===l.start?{index:d,type:"group"}:{groupIndex:d,index:u.index-(d+1)+a},i.push({...c,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return i}function Bx(t,e){return t===void 0?0:typeof t=="number"?t:t[e]??0}var br=Ee(([{data:t,firstItemIndex:e,gap:a,sizes:r,totalCount:n},i,{listBoundary:o,topListHeight:l,visibleRange:d},{initialTopMostItemIndex:u,scrolledToInitialItem:c},{topListHeight:m},p,{didMount:h},{recalcInProgress:x}])=>{let g=q([]),y=q(0),b=Ce(),w=q(0);ne(i.topItemsIndexes,g);let D=yt(U(nt(h,x,ce(d,qn),ce(n),ce(r),ce(u),c,ce(g),ce(e),ce(a),ce(w),t),ue(([S,k,,v,,,,,,,,E])=>{let N=E&&E.length!==v;return S&&!k&&!N}),ae(([,,[S,k],v,E,N,R,_,V,I,A,T])=>{var $,ie;let P=E,{offsetTree:F,sizeTree:O}=P,z=Ze(y);if(v===0)return{...qd,totalCount:v};if(S===0&&k===0)return z===0?{...qd,totalCount:v}:Lx(z,N,E,V,I,T||[]);if(_e(O))return z>0?null:Ao(Wj(Kd(N,v),P,T),[],v,I,P,V);let B=[];if(_.length>0){let re=_[0],oe=_[_.length-1],ge=0;for(let he of qr(O,re,oe)){let me=he.value,De=Math.max(he.start,re),Le=Math.min(he.end,oe);for(let je=De;je<=Le;je++)B.push({data:T==null?void 0:T[je],index:je,offset:ge,size:me}),ge+=me}}if(!R)return Ao([],B,v,I,P,V);let J=_.length>0?_[_.length-1]+1:0,ee=Aj(F,S,k,J);if(ee.length===0)return null;let X=v-1,se=No([],re=>{for(let oe of ee){let ge=oe.value,he=ge.offset,me=oe.start,De=ge.size;if(ge.offset<S){me+=Math.floor((S-ge.offset+I)/(De+I));let je=me-oe.start;he+=je*De+je*I}me<J&&(he+=(J-me)*De,me=J);let Le=Math.min(oe.end,X);for(let je=me;je<=Le&&!(he>=k);je++)re.push({data:T==null?void 0:T[je],index:je,offset:he,size:De}),he+=De+I}}),pe=Bx(A,ai),G=Bx(A,ri);if(se.length>0&&(pe>0||G>0)){let re=se[0],oe=se[se.length-1];if(pe>0&&re.index>J){let ge=Math.min(pe,re.index-J),he=[],me=re.offset;for(let De=re.index-1;De>=re.index-ge;De--){let Le=(($=qr(O,De,De)[0])==null?void 0:$.value)??re.size;me-=Le+I,he.unshift({data:T==null?void 0:T[De],index:De,offset:me,size:Le})}se.unshift(...he)}if(G>0&&oe.index<X){let ge=Math.min(G,X-oe.index),he=oe.offset+oe.size+I;for(let me=oe.index+1;me<=oe.index+ge;me++){let De=((ie=qr(O,me,me)[0])==null?void 0:ie.value)??oe.size;se.push({data:T==null?void 0:T[me],index:me,offset:he,size:De}),he+=De+I}}}return Ao(se,B,v,I,P,V)}),ue(S=>S!==null),ze()),qd);ne(U(t,ue(Id),ae(S=>S==null?void 0:S.length)),n),ne(U(D,ae(S=>S.topListHeight)),m),ne(m,l),ne(U(D,ae(S=>[S.top,S.bottom])),o),ne(U(D,ae(S=>S.items)),b);let j=St(U(D,ue(({items:S})=>S.length>0),ye(n,t),ue(([{items:S},k])=>S[S.length-1].originalIndex===k-1),ae(([,S,k])=>[S-1,k]),ze(qn),ae(([S])=>S))),C=St(U(D,ka(200),ue(({items:S,topItems:k})=>S.length>0&&S[0].originalIndex===k.length),ae(({items:S})=>S[0].index),ze()));return{endReached:j,initialItemCount:y,itemsRendered:b,listState:D,minOverscanItemCount:w,rangeChanged:St(U(D,ue(({items:S})=>S.length>0),ae(({items:S})=>{let k=0,v=S.length-1;for(;S[k].type==="group"&&k<v;)k++;for(;S[v].type==="group"&&v>k;)v--;return{endIndex:S[v].index,startIndex:S[k].index}}),ze(Nx))),startReached:C,topItemsIndexes:g,...p}},Ve(pa,Px,Yd,Jn,Qn,ti,Za,Hd),{singleton:!0}),Hx=Ee(([{fixedFooterHeight:t,fixedHeaderHeight:e,footerHeight:a,headerHeight:r},{listState:n}])=>{let i=Ce(),o=yt(U(nt(a,t,r,e,n),ae(([l,d,u,c,m])=>l+d+u+c+m.offsetBottom+m.bottom)),0);return ne(ce(o),i),{totalListHeight:o,totalListHeightChanged:i}},Ve(Dt,br),{singleton:!0}),Uj=Ee(([{viewportHeight:t},{totalListHeight:e}])=>{let a=q(!1);return{alignToBottom:a,paddingTopAddition:yt(U(nt(a,t,e),ue(([r])=>r),ae(([,r,n])=>Math.max(0,r-n)),ka(0),ze()),0)}},Ve(Dt,Hx),{singleton:!0}),Wx=Ee(()=>({context:q(null)})),Zj=({itemBottom:t,itemTop:e,locationParams:{align:a,behavior:r,...n},viewportBottom:i,viewportTop:o})=>e<o?{...n,align:a??"start",behavior:r}:t>i?{...n,align:a??"end",behavior:r}:null,Ux=Ee(([{gap:t,sizes:e,totalCount:a},{fixedFooterHeight:r,fixedHeaderHeight:n,headerHeight:i,scrollingInProgress:o,scrollTop:l,viewportHeight:d},{scrollToIndex:u}])=>{let c=Ce();return ne(U(c,ye(e,d,a,i,n,r,l),ye(t),ae(([[m,p,h,x,g,y,b,w],D])=>{let{align:j,behavior:C,calculateViewLocation:S=Zj,done:k,...v}=m,E=Ax(m,p,x-1),N=Gn(E,p.offsetTree,D)+g+y,R=N+Qt(p.sizeTree,E)[1],_=w+y,V=w+h-b,I=S({itemBottom:R,itemTop:N,locationParams:{align:j,behavior:C,...v},viewportBottom:V,viewportTop:_});return I?k&&Gt(U(o,ue(A=>!A),vr(Ze(o)?1:2)),k):k==null||k(),I}),ue(m=>m!==null)),u),{scrollIntoView:c}},Ve(pa,Dt,Qn,br,Ua),{singleton:!0});function Zx(t){return t?t==="smooth"?"smooth":"auto":!1}var Kj=(t,e)=>typeof t=="function"?Zx(t(e)):e&&Zx(t),Yj=Ee(([{listRefresh:t,totalCount:e,fixedItemSize:a,data:r},{atBottomState:n,isAtBottom:i},{scrollToIndex:o},{scrolledToInitialItem:l},{didMount:d,propsReady:u},{log:c},{scrollingInProgress:m},{context:p},{scrollIntoView:h}])=>{let x=q(!1),g=Ce(),y=null;function b(C){xe(o,{align:"end",behavior:C,index:"LAST"})}Te(U(nt(U(ce(e),vr(1)),d),ye(ce(x),i,l,m),ae(([[C,S],k,v,E,N])=>{let R=S&&E,_="auto";return R&&(_=Kj(k,v||N),R&&(R=!!_)),{followOutputBehavior:_,shouldFollow:R,totalCount:C}}),ue(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:S})=>{y&&(y=(y(),null)),Ze(a)?requestAnimationFrame(()=>{Ze(c)("following output to ",{totalCount:S},Ct.DEBUG),b(C)}):y=Gt(t,()=>{Ze(c)("following output to ",{totalCount:S},Ct.DEBUG),b(C),y=null})});function w(C){let S=Gt(n,k=>{C&&!k.atBottom&&k.notAtBottomBecause==="SIZE_INCREASED"&&!y&&(Ze(c)("scrolling to bottom due to increased size",{},Ct.DEBUG),b("auto"))});setTimeout(S,100)}Te(U(nt(ce(x),e,u),ue(([C,,S])=>C&&S),ca(({value:C},[,S])=>({refreshed:C===S,value:S}),{refreshed:!1,value:0}),ue(({refreshed:C})=>C),ye(x,e)),([,C])=>{Ze(l)&&w(C!==!1)}),Te(g,()=>{w(Ze(x)!==!1)}),Te(nt(ce(x),n),([C,S])=>{C&&!S.atBottom&&S.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&b("auto")});let D=q(null),j=Ce();return ne(Md(U(ce(r),ae(C=>(C==null?void 0:C.length)??0)),U(ce(e))),j),Te(U(nt(U(j,vr(1)),d),ye(ce(D),l,m,p),ae(([[C,S],k,v,E,N])=>S&&v&&(k==null?void 0:k({context:N,totalCount:C,scrollingInProgress:E}))),ue(C=>!!C),ka(0)),C=>{y&&(y=(y(),null)),Ze(a)?requestAnimationFrame(()=>{Ze(c)("scrolling into view",{}),xe(h,C)}):y=Gt(t,()=>{Ze(c)("scrolling into view",{}),xe(h,C),y=null})}),{autoscrollToBottom:g,followOutput:x,scrollIntoViewOnChange:D}},Ve(pa,ti,Qn,Jn,Za,Ua,Dt,Wx,Ux)),qj=Ee(([{data:t,firstItemIndex:e,gap:a,sizes:r},{initialTopMostItemIndex:n},{initialItemCount:i,listState:o},{didMount:l}])=>(ne(U(l,ye(i),ue(([,d])=>d!==0),ye(n,r,e,a,t),ae(([[,d],u,c,m,p,h=[]])=>Lx(d,u,c,m,p,h))),o),{}),Ve(pa,Jn,br,Za),{singleton:!0}),Gj=Ee(([{didMount:t},{scrollTo:e},{listState:a}])=>{let r=q(0);return Te(U(t,ye(r),ue(([,n])=>n!==0),ae(([,n])=>({top:n}))),n=>{Gt(U(a,vr(1),ue(i=>i.items.length>1)),()=>{requestAnimationFrame(()=>{xe(e,n)})})}),{initialScrollTop:r}},Ve(Za,Dt,br),{singleton:!0}),Kx=Ee(([{scrollVelocity:t}])=>{let e=q(!1),a=Ce(),r=q(!1);return ne(U(t,ye(r,e,a),ue(([n,i])=>!!i),ae(([n,i,o,l])=>{let{enter:d,exit:u}=i;if(o){if(u(n,l))return!1}else if(d(n,l))return!0;return o}),ze()),e),Te(U(nt(e,t,a),ye(r)),([[n,i,o],l])=>{n&&l&&l.change&&l.change(i,o)}),{isSeeking:e,scrollSeekConfiguration:r,scrollSeekRangeChanged:a,scrollVelocity:t}},Ve(ti),{singleton:!0}),Gd=Ee(([{scrollContainerState:t,scrollTo:e}])=>{let a=Ce(),r=Ce(),n=Ce(),i=q(!1),o=q(void 0);return ne(U(nt(a,r),ae(([{scrollHeight:l,scrollTop:d,viewportHeight:u},{offsetTop:c}])=>({scrollHeight:l,scrollTop:Math.max(0,d-c),viewportHeight:u}))),t),ne(U(e,ye(r),ae(([l,{offsetTop:d}])=>({...l,top:l.top+d}))),n),{customScrollParent:o,useWindowScroll:i,windowScrollContainerState:a,windowScrollTo:n,windowViewportRect:r}},Ve(Dt)),Qj=Ee(([{sizeRanges:t,sizes:e},{headerHeight:a,scrollTop:r},{initialTopMostItemIndex:n},{didMount:i},{useWindowScroll:o,windowScrollContainerState:l,windowViewportRect:d}])=>{let u=Ce(),c=q(void 0),m=q(null),p=q(null);return ne(l,m),ne(d,p),Te(U(u,ye(e,r,o,m,p,a)),([h,x,g,y,b,w,D])=>{let j=Pj(x.sizeTree);y&&b!==null&&w!==null&&(g=b.scrollTop-w.offsetTop),g-=D,h({ranges:j,scrollTop:g})}),ne(U(c,ue(Id),ae(Jj)),n),ne(U(i,ye(c),ue(([,h])=>h!==void 0),ze(),ae(([,h])=>h.ranges)),t),{getState:u,restoreStateFrom:c}},Ve(pa,Dt,Jn,Za,Gd));function Jj(t){return{align:"start",index:0,offset:t.scrollTop}}var Xj=Ee(([{topItemsIndexes:t}])=>{let e=q(0);return ne(U(e,ue(a=>a>=0),ae(a=>Array.from({length:a}).map((r,n)=>n))),t),{topItemCount:e}},Ve(br));function Yx(t){let e=!1,a;return(()=>(e||(e=!0,a=t()),a))}var eC=Yx(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),qx=Ee(([{data:t,defaultItemSize:e,firstItemIndex:a,fixedItemSize:r,fixedGroupSize:n,gap:i,groupIndices:o,heightEstimates:l,itemSize:d,sizeRanges:u,sizes:c,statefulTotalCount:m,totalCount:p,trackItemSizes:h},{initialItemFinalLocationReached:x,initialTopMostItemIndex:g,scrolledToInitialItem:y},b,w,D,j,{scrollToIndex:C},S,{topItemCount:k},{groupCounts:v},E])=>{let{listState:N,minOverscanItemCount:R,topItemsIndexes:_,rangeChanged:V,...I}=j;return ne(V,E.scrollSeekRangeChanged),ne(U(E.windowViewportRect,ae(A=>A.visibleHeight)),b.viewportHeight),{data:t,defaultItemHeight:e,firstItemIndex:a,fixedItemHeight:r,fixedGroupHeight:n,gap:i,groupCounts:v,heightEstimates:l,initialItemFinalLocationReached:x,initialTopMostItemIndex:g,scrolledToInitialItem:y,sizeRanges:u,topItemCount:k,topItemsIndexes:_,totalCount:p,...D,groupIndices:o,itemSize:d,listState:N,minOverscanItemCount:R,scrollToIndex:C,statefulTotalCount:m,trackItemSizes:h,rangeChanged:V,...I,...E,...b,sizes:c,...w}},Ve(pa,Jn,Dt,Qj,Yj,br,Qn,Ee(([{deviation:t,scrollBy:e,scrollingInProgress:a,scrollTop:r},{isAtBottom:n,isScrolling:i,lastJumpDueToItemResize:o,scrollDirection:l},{listState:d},{beforeUnshiftWith:u,gap:c,shiftWithOffset:m,sizes:p},{log:h},{recalcInProgress:x}])=>{let g=St(U(d,ye(o),ca(([,b,w,D],[{bottom:j,items:C,offsetBottom:S,totalCount:k},v])=>{let E=j+S,N=0;return w===k&&b.length>0&&C.length>0&&(C[0].originalIndex===0&&b[0].originalIndex===0||(N=E-D,N!==0&&(N+=v))),[N,C,k,E]},[0,[],0,0]),ue(([b])=>b!==0),ye(r,l,a,n,h,x),ue(([,b,w,D,,,j])=>!j&&!D&&b!==0&&w===Xn),ae(([[b],,,,,w])=>(w("Upward scrolling compensation",{amount:b},Ct.DEBUG),b))));function y(b){b>0?(xe(e,{behavior:"auto",top:-b}),xe(t,0)):(xe(t,0),xe(e,{behavior:"auto",top:-b}))}return Te(U(g,ye(t,i)),([b,w,D])=>{D&&eC()?xe(t,w-b):y(-b)}),Te(U(nt(yt(i,!1),t,x),ue(([b,w,D])=>!b&&!D&&w!==0),ae(([b,w])=>w),ka(1)),y),ne(U(m,ae(b=>({top:-b}))),e),Te(U(u,ye(p,c),ae(([b,{groupIndices:w,lastSize:D,sizeTree:j},C])=>{function S(k){return k*(D+C)}if(w.length===0)return S(b);{let k=0,v=Yn(j,0),E=0,N=0;for(;E<b;){E++,k+=v;let R=w.length===N+1?1/0:w[N+1]-w[N]-1;E+R>b&&(k-=v,R=b-E+1),E+=R,k+=S(R),N++}return k}})),b=>{xe(t,b),requestAnimationFrame(()=>{xe(e,{top:b}),requestAnimationFrame(()=>{xe(t,0),xe(x,!1)})})}),{deviation:t}},Ve(Dt,ti,br,pa,Ua,Hd)),Xj,Px,Ee(([t,e,a,r,n,i,o,l,d,u,c])=>({...t,...e,...a,...r,...n,...i,...o,...l,...d,...u,...c}),Ve(Yd,qj,Za,Kx,Hx,Gj,Uj,Gd,Ux,Ua,Wx))));function tC(t,e){let a={},r={},n=0,i=t.length;for(;n<i;)r[t[n]]=1,n+=1;for(let o in e)Object.hasOwn(r,o)||(a[o]=e[o]);return a}var Io=typeof document<"u"?f.useLayoutEffect:f.useEffect;function Qd(t,e,a){let r=Object.keys(e.required||{}),n=Object.keys(e.optional||{}),i=Object.keys(e.methods||{}),o=Object.keys(e.events||{}),l=f.createContext({});function d(m,p){m.propsReady&&xe(m.propsReady,!1);for(let h of r){let x=m[e.required[h]];xe(x,p[h])}for(let h of n)if(h in p){let x=m[e.optional[h]];xe(x,p[h])}m.propsReady&&xe(m.propsReady,!0)}function u(m){return i.reduce((p,h)=>(p[h]=x=>{let g=m[e.methods[h]];xe(g,x)},p),{})}function c(m){return o.reduce((p,h)=>(p[h]=bj(m[e.events[h]]),p),{})}return{Component:f.forwardRef((m,p)=>{let{children:h,...x}=m,[g]=f.useState(()=>No(Dj(t),w=>{d(w,x)})),[y]=f.useState(vx(c,g));Io(()=>{for(let w of o)w in x&&Te(y[w],x[w]);return()=>{Object.values(y).map(Pd)}},[x,y,g]),Io(()=>{d(g,x)}),f.useImperativeHandle(p,xx(u(g)));let b=a;return(0,s.jsx)(l.Provider,{value:g,children:a?(0,s.jsx)(b,{...tC([...r,...n,...o],x),children:h}):h})}),useEmitter:(m,p)=>{let h=f.useContext(l)[m];Io(()=>Te(h,p),[p,h])},useEmitterValue:m=>{let p=f.useContext(l)[m],[h,x]=f.useState(vx(Ze,p));return Io(()=>Te(p,g=>{g!==h&&x(xx(g))}),[p,h]),h},usePublisher:m=>{let p=f.useContext(l);return f.useCallback(h=>{xe(p[m],h)},[p,m])}}}var Po=f.createContext(void 0),Gx=f.createContext(void 0),Qx=typeof document<"u"?f.useLayoutEffect:f.useEffect;function Jd(t){return"self"in t}function aC(t){return"body"in t}function Jx(t,e,a,r=Kr,n,i){let o=f.useRef(null),l=f.useRef(null),d=f.useRef(null),u=f.useCallback(p=>{let h,x,g,y=p.target;if(aC(y)||Jd(y)){let w=Jd(y)?y:y.defaultView;g=i?w.scrollX:w.scrollY,h=i?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,x=i?w.innerWidth:w.innerHeight}else g=i?y.scrollLeft:y.scrollTop,h=i?y.scrollWidth:y.scrollHeight,x=i?y.offsetWidth:y.offsetHeight;let b=()=>{t({scrollHeight:h,scrollTop:Math.max(g,0),viewportHeight:x})};p.suppressFlushSync?b():hj.flushSync(b),l.current!==null&&(g===l.current||g<=0||g===h-x)&&(l.current=null,e(!0),d.current&&(d.current=(clearTimeout(d.current),null)))},[t,e,i]);f.useEffect(()=>{let p=n||o.current;return r(n||o.current),u({suppressFlushSync:!0,target:p}),p.addEventListener("scroll",u,{passive:!0}),()=>{r(null),p.removeEventListener("scroll",u)}},[o,u,a,r,n]);function c(p){let h=o.current;if(!h||(i?"offsetWidth"in h&&h.offsetWidth===0:"offsetHeight"in h&&h.offsetHeight===0))return;let x=p.behavior==="smooth",g,y,b;Jd(h)?(y=Math.max(Jt(h.document.documentElement,i?"width":"height"),i?h.document.documentElement.scrollWidth:h.document.documentElement.scrollHeight),g=i?h.innerWidth:h.innerHeight,b=i?window.scrollX:window.scrollY):(y=h[i?"scrollWidth":"scrollHeight"],g=Jt(h,i?"width":"height"),b=h[i?"scrollLeft":"scrollTop"]);let w=y-g;if(p.top=Math.ceil(Math.max(Math.min(w,p.top),0)),Fx(g,y)||p.top===b){t({scrollHeight:y,scrollTop:b,viewportHeight:g}),x&&e(!0);return}x?(l.current=p.top,d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,l.current=null,e(!0)},1e3)):l.current=null,i&&(p={behavior:p.behavior,left:p.top}),h.scrollTo(p)}function m(p){i&&(p={behavior:p.behavior,left:p.top}),o.current.scrollBy(p)}return{scrollByCallback:m,scrollerRef:o,scrollToCallback:c}}var Xd="-webkit-sticky",Xx="sticky",eu=Yx(()=>{if(typeof document>"u")return Xx;let t=document.createElement("div");return t.style.position=Xd,t.style.position===Xd?Xd:Xx});function tu(t){return t}var rC=Ee(([t,e])=>({...t,...e}),Ve(qx,Ee(()=>{let t=q(l=>`Item ${l}`),e=q(l=>`Group ${l}`),a=q({}),r=q(tu),n=q("div"),i=q(Kr),o=(l,d=null)=>yt(U(a,ae(u=>u[l]),ze()),d);return{components:a,computeItemKey:r,EmptyPlaceholder:o("EmptyPlaceholder"),FooterComponent:o("Footer"),GroupComponent:o("Group","div"),groupContent:e,HeaderComponent:o("Header"),HeaderFooterTag:n,ItemComponent:o("Item","div"),itemContent:t,ListComponent:o("List","div"),ScrollerComponent:o("Scroller","div"),scrollerRef:i,ScrollSeekPlaceholder:o("ScrollSeekPlaceholder"),TopItemListComponent:o("TopItemList")}}))),nC=({height:t})=>(0,s.jsx)("div",{style:{height:t}}),iC={overflowAnchor:"none",position:eu(),zIndex:1},e1={overflowAnchor:"none"},oC={...e1,display:"inline-block",height:"100%"},t1=f.memo(function({showTopList:t=!1}){let e=fe("listState"),a=Ot("sizeRanges"),r=fe("useWindowScroll"),n=fe("customScrollParent"),i=Ot("windowScrollContainerState"),o=Ot("scrollContainerState"),l=n||r?i:o,d=fe("itemContent"),u=fe("context"),c=fe("groupContent"),m=fe("trackItemSizes"),p=fe("itemSize"),h=fe("log"),x=Ot("gap"),g=fe("horizontalDirection"),{callbackRef:y}=wx(a,p,m,t?Kr:l,h,x,n,g,fe("skipAnimationFrameInResizeObserver")),[b,w]=f.useState(0);nu("deviation",I=>{b!==I&&w(I)});let D=fe("EmptyPlaceholder"),j=fe("ScrollSeekPlaceholder")||nC,C=fe("ListComponent"),S=fe("ItemComponent"),k=fe("GroupComponent"),v=fe("computeItemKey"),E=fe("isSeeking"),N=fe("groupIndices").length>0,R=fe("alignToBottom"),_=fe("initialItemFinalLocationReached"),V=t?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:b===0?R?"auto":0:b,paddingLeft:e.offsetTop,paddingRight:e.offsetBottom,whiteSpace:"nowrap"}:{marginTop:b===0?R?"auto":0:b,paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},..._?{}:{visibility:"hidden"}};return!t&&e.totalCount===0&&D?(0,s.jsx)(D,{...Oe(D,u)}):(0,s.jsx)(C,{...Oe(C,u),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:y,style:V,children:(t?e.topItems:e.items).map(I=>{let A=I.originalIndex,T=v(A+e.firstItemIndex,I.data,u);return E?(0,f.createElement)(j,{...Oe(j,u),height:I.size,index:I.index,key:T,type:I.type||"item",...I.type==="group"?{}:{groupIndex:I.groupIndex}}):I.type==="group"?(0,f.createElement)(k,{...Oe(k,u),"data-index":A,"data-item-index":I.index,"data-known-size":I.size,key:T,style:iC},c(I.index,u)):(0,f.createElement)(S,{...Oe(S,u),...a1(S,I.data),"data-index":A,"data-item-group-index":I.groupIndex,"data-item-index":I.index,"data-known-size":I.size,key:T,style:g?oC:e1},N?d(I.index,I.groupIndex,I.data,u):d(I.index,I.data,u))})})}),lC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},sC={outline:"none",overflowX:"auto",position:"relative"},Gr=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:{}}),dC={position:eu(),top:0,width:"100%",zIndex:1};function Oe(t,e){if(typeof t!="string")return{context:e}}function a1(t,e){return{item:typeof t=="string"?void 0:e}}var uC=f.memo(function(){let t=fe("HeaderComponent"),e=Ot("headerHeight"),a=fe("HeaderFooterTag"),r=ma(f.useMemo(()=>i=>{e(Jt(i,"height"))},[e]),!0,fe("skipAnimationFrameInResizeObserver")),n=fe("context");return t?(0,s.jsx)(a,{ref:r,children:(0,s.jsx)(t,{...Oe(t,n)})}):null}),cC=f.memo(function(){let t=fe("FooterComponent"),e=Ot("footerHeight"),a=fe("HeaderFooterTag"),r=ma(f.useMemo(()=>i=>{e(Jt(i,"height"))},[e]),!0,fe("skipAnimationFrameInResizeObserver")),n=fe("context");return t?(0,s.jsx)(a,{ref:r,children:(0,s.jsx)(t,{...Oe(t,n)})}):null});function au({useEmitter:t,useEmitterValue:e,usePublisher:a}){return f.memo(function({children:r,style:n,context:i,...o}){let l=a("scrollContainerState"),d=e("ScrollerComponent"),u=a("smoothScrollTargetReached"),c=e("scrollerRef"),m=e("horizontalDirection")||!1,{scrollByCallback:p,scrollerRef:h,scrollToCallback:x}=Jx(l,u,d,c,void 0,m);return t("scrollTo",x),t("scrollBy",p),(0,s.jsx)(d,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:h,style:{...m?sC:lC,...n},tabIndex:0,...o,...Oe(d,i),children:r})})}function ru({useEmitter:t,useEmitterValue:e,usePublisher:a}){return f.memo(function({children:r,style:n,context:i,...o}){let l=a("windowScrollContainerState"),d=e("ScrollerComponent"),u=a("smoothScrollTargetReached"),c=e("totalListHeight"),m=e("deviation"),p=e("customScrollParent"),h=f.useRef(null),{scrollByCallback:x,scrollerRef:g,scrollToCallback:y}=Jx(l,u,d,e("scrollerRef"),p);return Qx(()=>{var b;return g.current=p||((b=h.current)==null?void 0:b.ownerDocument.defaultView),()=>{g.current=null}},[g,p]),t("windowScrollTo",y),t("scrollBy",x),(0,s.jsx)(d,{ref:h,"data-virtuoso-scroller":!0,style:{position:"relative",...n,...c===0?{}:{height:c+m}},...o,...Oe(d,i),children:r})})}var mC=({children:t})=>{let e=f.useContext(Po),a=Ot("viewportHeight"),r=Ot("fixedItemHeight"),n=fe("alignToBottom"),i=fe("horizontalDirection"),o=ma(f.useMemo(()=>Zn(a,l=>Jt(l,i?"width":"height")),[a,i]),!0,fe("skipAnimationFrameInResizeObserver"));return f.useEffect(()=>{e&&(a(e.viewportHeight),r(e.itemHeight))},[e,a,r]),(0,s.jsx)("div",{"data-viewport-type":"element",ref:o,style:Gr(n),children:t})},pC=({children:t})=>{let e=f.useContext(Po),a=Ot("windowViewportRect"),r=Ot("fixedItemHeight"),n=Vd(a,fe("customScrollParent"),fe("skipAnimationFrameInResizeObserver")),i=fe("alignToBottom");return f.useEffect(()=>{e&&(r(e.itemHeight),a({offsetTop:0,visibleHeight:e.viewportHeight,visibleWidth:100}))},[e,a,r]),(0,s.jsx)("div",{"data-viewport-type":"window",ref:n,style:Gr(i),children:t})},hC=({children:t})=>{let e=fe("TopItemListComponent")||"div",a=fe("headerHeight");return(0,s.jsx)(e,{style:{...dC,marginTop:`${a}px`},...Oe(e,fe("context")),children:t})},{Component:fC,useEmitter:nu,useEmitterValue:fe,usePublisher:Ot}=Qd(rC,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},f.memo(function(t){let e=fe("useWindowScroll"),a=fe("topItemsIndexes").length>0,r=fe("customScrollParent"),n=fe("context");return(0,s.jsxs)(r||e?xC:gC,{...t,context:n,children:[a&&(0,s.jsx)(hC,{children:(0,s.jsx)(t1,{showTopList:!0})}),(0,s.jsxs)(r||e?pC:mC,{children:[(0,s.jsx)(uC,{}),(0,s.jsx)(t1,{}),(0,s.jsx)(cC,{})]})]})})),gC=au({useEmitter:nu,useEmitterValue:fe,usePublisher:Ot}),xC=ru({useEmitter:nu,useEmitterValue:fe,usePublisher:Ot}),r1=fC,vC=Ee(([t,e])=>({...t,...e}),Ve(qx,Ee(()=>{let t=q(u=>(0,s.jsxs)("td",{children:["Item $",u]})),e=q(null),a=q(u=>(0,s.jsxs)("td",{colSpan:1e3,children:["Group ",u]})),r=q(null),n=q(null),i=q({}),o=q(tu),l=q(Kr),d=(u,c=null)=>yt(U(i,ae(m=>m[u]),ze()),c);return{components:i,computeItemKey:o,context:e,EmptyPlaceholder:d("EmptyPlaceholder"),FillerRow:d("FillerRow"),fixedFooterContent:n,fixedHeaderContent:r,itemContent:t,groupContent:a,ScrollerComponent:d("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder"),TableBodyComponent:d("TableBody","tbody"),TableComponent:d("Table","table"),TableFooterComponent:d("TableFoot","tfoot"),TableHeadComponent:d("TableHead","thead"),TableRowComponent:d("TableRow","tr"),GroupComponent:d("Group","tr")}}))),yC=({height:t})=>(0,s.jsx)("tr",{children:(0,s.jsx)("td",{style:{height:t}})}),bC=({height:t})=>(0,s.jsx)("tr",{children:(0,s.jsx)("td",{style:{border:0,height:t,padding:0}})}),wC={overflowAnchor:"none"},n1={position:eu(),zIndex:2,overflowAnchor:"none"},i1=f.memo(function({showTopList:t=!1}){let e=ve("listState"),a=ve("computeItemKey"),r=ve("firstItemIndex"),n=ve("context"),i=ve("isSeeking"),o=ve("fixedHeaderHeight"),l=ve("groupIndices").length>0,d=ve("itemContent"),u=ve("groupContent"),c=ve("ScrollSeekPlaceholder")||yC,m=ve("GroupComponent"),p=ve("TableRowComponent"),h=(t?e.topItems:[]).reduce((x,g,y)=>(y===0?x.push(g.size):x.push(x[y-1]+g.size),x),[]);return(0,s.jsx)(s.Fragment,{children:(t?e.topItems:e.items).map(x=>{let g=x.originalIndex,y=a(g+r,x.data,n),b=t?g===0?0:h[g-1]:0;return i?(0,f.createElement)(c,{...Oe(c,n),height:x.size,index:x.index,key:y,type:x.type||"item"}):x.type==="group"?(0,f.createElement)(m,{...Oe(m,n),"data-index":g,"data-item-index":x.index,"data-known-size":x.size,key:y,style:{...n1,top:o}},u(x.index,n)):(0,f.createElement)(p,{...Oe(p,n),...a1(p,x.data),"data-index":g,"data-item-index":x.index,"data-known-size":x.size,"data-item-group-index":x.groupIndex,key:y,style:t?{...n1,top:o+b}:wC},l?d(x.index,x.groupIndex,x.data,n):d(x.index,x.data,n))})})}),DC=f.memo(function(){let t=ve("listState"),e=ve("topItemsIndexes").length>0,a=Xt("sizeRanges"),r=ve("useWindowScroll"),n=ve("customScrollParent"),i=Xt("windowScrollContainerState"),o=Xt("scrollContainerState"),l=n||r?i:o,d=ve("trackItemSizes"),{callbackRef:u,ref:c}=wx(a,ve("itemSize"),d,l,ve("log"),void 0,n,!1,ve("skipAnimationFrameInResizeObserver")),[m,p]=f.useState(0);iu("deviation",v=>{m!==v&&(c.current.style.marginTop=`${v}px`,p(v))});let h=ve("EmptyPlaceholder"),x=ve("FillerRow")||bC,g=ve("TableBodyComponent"),y=ve("paddingTopAddition"),b=ve("statefulTotalCount"),w=ve("context");if(b===0&&h)return(0,s.jsx)(h,{...Oe(h,w)});let D=(e?t.topItems:[]).reduce((v,E)=>v+E.size,0),j=t.offsetTop+y+m-D,C=t.offsetBottom,S=j>0?(0,s.jsx)(x,{context:w,height:j},"padding-top"):null,k=C>0?(0,s.jsx)(x,{context:w,height:C},"padding-bottom"):null;return(0,s.jsxs)(g,{"data-testid":"virtuoso-item-list",ref:u,...Oe(g,w),children:[S,e&&(0,s.jsx)(i1,{showTopList:!0}),(0,s.jsx)(i1,{}),k]})}),jC=({children:t})=>{let e=f.useContext(Po),a=Xt("viewportHeight"),r=Xt("fixedItemHeight"),n=ma(f.useMemo(()=>Zn(a,i=>Jt(i,"height")),[a]),!0,ve("skipAnimationFrameInResizeObserver"));return f.useEffect(()=>{e&&(a(e.viewportHeight),r(e.itemHeight))},[e,a,r]),(0,s.jsx)("div",{"data-viewport-type":"element",ref:n,style:Gr(!1),children:t})},CC=({children:t})=>{let e=f.useContext(Po),a=Xt("windowViewportRect"),r=Xt("fixedItemHeight"),n=Vd(a,ve("customScrollParent"),ve("skipAnimationFrameInResizeObserver"));return f.useEffect(()=>{e&&(r(e.itemHeight),a({offsetTop:0,visibleHeight:e.viewportHeight,visibleWidth:100}))},[e,a,r]),(0,s.jsx)("div",{"data-viewport-type":"window",ref:n,style:Gr(!1),children:t})},{Component:UI,useEmitter:iu,useEmitterValue:ve,usePublisher:Xt}=Qd(vC,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",firstItemIndex:"firstItemIndex",itemContent:"itemContent",groupContent:"groupContent",fixedHeaderContent:"fixedHeaderContent",fixedFooterContent:"fixedFooterContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",topItemCount:"topItemCount",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",groupCounts:"groupCounts",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},f.memo(function(t){let e=ve("useWindowScroll"),a=ve("customScrollParent"),r=Xt("fixedHeaderHeight"),n=Xt("fixedFooterHeight"),i=ve("fixedHeaderContent"),o=ve("fixedFooterContent"),l=ve("context"),d=ma(f.useMemo(()=>Zn(r,b=>Jt(b,"height")),[r]),!0,ve("skipAnimationFrameInResizeObserver")),u=ma(f.useMemo(()=>Zn(n,b=>Jt(b,"height")),[n]),!0,ve("skipAnimationFrameInResizeObserver")),c=a||e?SC:kC,m=a||e?CC:jC,p=ve("TableComponent"),h=ve("TableHeadComponent"),x=ve("TableFooterComponent"),g=i?(0,s.jsx)(h,{ref:d,style:{position:"sticky",top:0,zIndex:2},...Oe(h,l),children:i()},"TableHead"):null,y=o?(0,s.jsx)(x,{ref:u,style:{bottom:0,position:"sticky",zIndex:1},...Oe(x,l),children:o()},"TableFoot"):null;return(0,s.jsx)(c,{...t,...Oe(c,l),children:(0,s.jsx)(m,{children:(0,s.jsxs)(p,{style:{borderSpacing:0,overflowAnchor:"none"},...Oe(p,l),children:[g,(0,s.jsx)(DC,{},"TableBody"),y]})})})})),kC=au({useEmitter:iu,useEmitterValue:ve,usePublisher:Xt}),SC=ru({useEmitter:iu,useEmitterValue:ve,usePublisher:Xt}),o1={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},EC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:l1,floor:Mo,max:ni,min:ou,round:s1}=Math;function d1(t,e,a){return Array.from({length:e-t+1}).map((r,n)=>({data:a===null?null:a[n+t],index:n+t}))}function RC(t){return{...EC,items:t}}function Fo(t,e){return t&&t.width===e.width&&t.height===e.height}function NC(t,e){return t&&t.column===e.column&&t.row===e.row}var TC=Ee(([{increaseViewportBy:t,listBoundary:e,overscan:a,visibleRange:r},{footerHeight:n,headerHeight:i,scrollBy:o,scrollContainerState:l,scrollTo:d,scrollTop:u,smoothScrollTargetReached:c,viewportHeight:m},p,h,{didMount:x,propsReady:g},{customScrollParent:y,useWindowScroll:b,windowScrollContainerState:w,windowScrollTo:D,windowViewportRect:j},C])=>{let S=q(0),k=q(0),v=q(o1),E=q({height:0,width:0}),N=q({height:0,width:0}),R=Ce(),_=Ce(),V=q(0),I=q(null),A=q({column:0,row:0}),T=Ce(),P=Ce(),F=q(!1),O=q(0),z=q(!0),B=q(!1),J=q(!1);Te(U(x,ye(O),ue(([$,ie])=>!!ie)),()=>{xe(z,!1)}),Te(U(nt(x,z,N,E,O,B),ue(([$,ie,re,oe,,ge])=>$&&!ie&&re.height!==0&&oe.height!==0&&!ge)),([,,,,$])=>{xe(B,!0),Zd(1,()=>{xe(R,$)}),Gt(U(u),()=>{xe(e,[0,0]),xe(z,!0)})}),ne(U(P,ue($=>$!=null&&$.scrollTop>0),ua(0)),k),Te(U(x,ye(P),ue(([,$])=>$!=null)),([,$])=>{$&&(xe(E,$.viewport),xe(N,$.item),xe(A,$.gap),$.scrollTop>0&&(xe(F,!0),Gt(U(u,vr(1)),ie=>{xe(F,!1)}),xe(d,{top:$.scrollTop})))}),ne(U(E,ae(({height:$})=>$)),m),ne(U(nt(ce(E,Fo),ce(N,Fo),ce(A,($,ie)=>$&&$.column===ie.column&&$.row===ie.row),ce(u)),ae(([$,ie,re,oe])=>({gap:re,item:ie,scrollTop:oe,viewport:$}))),T),ne(U(nt(ce(S),r,ce(A,NC),ce(N,Fo),ce(E,Fo),ce(I),ce(k),ce(F),ce(z),ce(O)),ue(([,,,,,,,$])=>!$),ae(([$,[ie,re],oe,ge,he,me,De,,Le,je])=>{let{column:Ye,row:Ne}=oe,{height:Ae,width:pt}=ge,{width:ot}=he;if(De===0&&($===0||ot===0))return o1;if(pt===0){let pl=Kd(je,$);return RC(d1(pl,pl+Math.max(De-1,0),me))}let Bt=u1(ot,pt,Ye),ta,Ht;Le?ie===0&&re===0&&De>0?(ta=0,Ht=De-1):(ta=Bt*Mo((ie+Ne)/(Ae+Ne)),Ht=Bt*l1((re+Ne)/(Ae+Ne))-1,Ht=ou($-1,ni(Ht,Bt-1)),ta=ou(Ht,ni(0,ta))):(ta=0,Ht=-1);let qa=d1(ta,Ht,me),{bottom:Cr,top:kr}=c1(he,oe,ge,qa),Wt=l1($/Bt);return{bottom:Cr,itemHeight:Ae,items:qa,itemWidth:pt,offsetBottom:Wt*Ae+(Wt-1)*Ne-Cr,offsetTop:kr,top:kr}})),v),ne(U(I,ue($=>$!==null),ae($=>$.length)),S),ne(U(nt(E,N,v,A),ue(([$,ie,{items:re}])=>re.length>0&&ie.height!==0&&$.height!==0),ae(([$,ie,{items:re},oe])=>{let{bottom:ge,top:he}=c1($,oe,ie,re);return[he,ge]}),ze(qn)),e);let ee=q(!1);ne(U(u,ye(ee),ae(([$,ie])=>ie||$!==0)),ee);let X=St(U(nt(v,S),ue(([{items:$}])=>$.length>0),ye(ee),ue(([[$,ie],re])=>{let oe=$.items[$.items.length-1].index===ie-1;return(re||$.bottom>0&&$.itemHeight>0&&$.offsetBottom===0&&$.items.length===ie)&&oe}),ae(([[,$]])=>$-1),ze())),se=St(U(ce(v),ue(({items:$})=>$.length>0&&$[0].index===0),ua(0),ze())),pe=St(U(ce(v),ye(F),ue(([{items:$},ie])=>$.length>0&&!ie),ae(([{items:$}])=>({endIndex:$[$.length-1].index,startIndex:$[0].index})),ze(Nx),ka(0)));ne(pe,h.scrollSeekRangeChanged),ne(U(R,ye(E,N,S,A),ae(([$,ie,re,oe,ge])=>{let he=Mx($),{align:me,behavior:De,offset:Le}=he,je=he.index;je==="LAST"&&(je=oe-1),je=ni(0,je,ou(oe-1,je));let Ye=lu(ie,ge,re,je);return me==="end"?Ye=s1(Ye-ie.height+re.height):me==="center"&&(Ye=s1(Ye-ie.height/2+re.height/2)),Le&&(Ye+=Le),{behavior:De,top:Ye}})),d);let G=yt(U(v,ae($=>$.offsetBottom+$.bottom)),0);return ne(U(j,ae($=>({height:$.visibleHeight,width:$.visibleWidth}))),E),{customScrollParent:y,data:I,deviation:V,footerHeight:n,gap:A,headerHeight:i,increaseViewportBy:t,initialItemCount:k,itemDimensions:N,overscan:a,restoreStateFrom:P,scrollBy:o,scrollContainerState:l,scrollHeight:_,scrollTo:d,scrollToIndex:R,scrollTop:u,smoothScrollTargetReached:c,totalCount:S,useWindowScroll:b,viewportDimensions:E,windowScrollContainerState:w,windowScrollTo:D,windowViewportRect:j,...h,gridState:v,horizontalDirection:J,initialTopMostItemIndex:O,totalListHeight:G,...p,endReached:X,propsReady:g,rangeChanged:pe,startReached:se,stateChanged:T,stateRestoreInProgress:F,...C}},Ve(Yd,Dt,ti,Kx,Za,Gd,Ua));function u1(t,e,a){return ni(1,Mo((t+a)/(Mo(e)+a)))}function c1(t,e,a,r){let{height:n}=a;if(n===void 0||r.length===0)return{bottom:0,top:0};let i=lu(t,e,a,r[0].index);return{bottom:lu(t,e,a,r[r.length-1].index)+n,top:i}}function lu(t,e,a,r){let n=Mo(r/u1(t.width,a.width,e.column)),i=n*a.height+ni(0,n-1)*e.row;return i>0?i+e.row:i}var _C=Ee(([t,e])=>({...t,...e}),Ve(TC,Ee(()=>{let t=q(m=>`Item ${m}`),e=q({}),a=q(null),r=q("virtuoso-grid-item"),n=q("virtuoso-grid-list"),i=q(tu),o=q("div"),l=q(Kr),d=(m,p=null)=>yt(U(e,ae(h=>h[m]),ze()),p),u=q(!1),c=q(!1);return ne(ce(c),u),{components:e,computeItemKey:i,context:a,FooterComponent:d("Footer"),HeaderComponent:d("Header"),headerFooterTag:o,itemClassName:r,ItemComponent:d("Item","div"),itemContent:t,listClassName:n,ListComponent:d("List","div"),readyStateChanged:u,reportReadyState:c,ScrollerComponent:d("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder","div")}}))),AC=f.memo(function(){let t=He("gridState"),e=He("listClassName"),a=He("itemClassName"),r=He("itemContent"),n=He("computeItemKey"),i=He("isSeeking"),o=Lt("scrollHeight"),l=He("ItemComponent"),d=He("ListComponent"),u=He("ScrollSeekPlaceholder"),c=He("context"),m=Lt("itemDimensions"),p=Lt("gap"),h=He("log"),x=He("stateRestoreInProgress"),g=Lt("reportReadyState"),y=ma(f.useMemo(()=>b=>{let w=b.parentElement.parentElement.scrollHeight;o(w);let D=b.firstChild;if(D){let{height:j,width:C}=D.getBoundingClientRect();m({height:j,width:C})}p({column:p1("column-gap",getComputedStyle(b).columnGap,h),row:p1("row-gap",getComputedStyle(b).rowGap,h)})},[o,m,p,h]),!0,!1);return Qx(()=>{t.itemHeight>0&&t.itemWidth>0&&g(!0)},[t]),x?null:(0,s.jsx)(d,{className:e,ref:y,...Oe(d,c),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(b=>{let w=n(b.index,b.data,c);return i?(0,s.jsx)(u,{...Oe(u,c),height:t.itemHeight,index:b.index,width:t.itemWidth},w):(0,f.createElement)(l,{...Oe(l,c),className:a,"data-index":b.index,key:w},r(b.index,b.data,c))})})}),IC=f.memo(function(){let t=He("HeaderComponent"),e=Lt("headerHeight"),a=He("headerFooterTag"),r=ma(f.useMemo(()=>i=>{e(Jt(i,"height"))},[e]),!0,!1),n=He("context");return t?(0,s.jsx)(a,{ref:r,children:(0,s.jsx)(t,{...Oe(t,n)})}):null}),PC=f.memo(function(){let t=He("FooterComponent"),e=Lt("footerHeight"),a=He("headerFooterTag"),r=ma(f.useMemo(()=>i=>{e(Jt(i,"height"))},[e]),!0,!1),n=He("context");return t?(0,s.jsx)(a,{ref:r,children:(0,s.jsx)(t,{...Oe(t,n)})}):null}),MC=({children:t})=>{let e=f.useContext(Gx),a=Lt("itemDimensions"),r=Lt("viewportDimensions"),n=ma(f.useMemo(()=>i=>{r(i.getBoundingClientRect())},[r]),!0,!1);return f.useEffect(()=>{e&&(r({height:e.viewportHeight,width:e.viewportWidth}),a({height:e.itemHeight,width:e.itemWidth}))},[e,r,a]),(0,s.jsx)("div",{ref:n,style:Gr(!1),children:t})},FC=({children:t})=>{let e=f.useContext(Gx),a=Lt("windowViewportRect"),r=Lt("itemDimensions"),n=Vd(a,He("customScrollParent"),!1);return f.useEffect(()=>{e&&(r({height:e.itemHeight,width:e.itemWidth}),a({offsetTop:0,visibleHeight:e.viewportHeight,visibleWidth:e.viewportWidth}))},[e,a,r]),(0,s.jsx)("div",{ref:n,style:Gr(!1),children:t})},{Component:ZI,useEmitter:m1,useEmitterValue:He,usePublisher:Lt}=Qd(_C,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},f.memo(function({...t}){let e=He("useWindowScroll"),a=He("customScrollParent"),r=a||e?zC:VC,n=a||e?FC:MC,i=He("context");return(0,s.jsx)(r,{...t,...Oe(r,i),children:(0,s.jsxs)(n,{children:[(0,s.jsx)(IC,{}),(0,s.jsx)(AC,{}),(0,s.jsx)(PC,{})]})})})),VC=au({useEmitter:m1,useEmitterValue:He,usePublisher:Lt}),zC=ru({useEmitter:m1,useEmitterValue:He,usePublisher:Lt});function p1(t,e,a){return e!=="normal"&&!(e!=null&&e.endsWith("px"))&&a(`${t} was not resolved to pixel value correctly`,e,Ct.WARN),e==="normal"?0:parseInt(e??"0",10)}function h1(t,e){return e.split(/\s+/).every(a=>t.toLowerCase().includes(a.toLowerCase()))?1:0}var OC=te(),LC=class{constructor(){Z(this,"tagName","marimo-multiselect");Z(this,"validator",L({initialValue:Q(M()),label:M().nullable(),options:Q(M()),fullWidth:W().default(!1),maxSelections:H().optional()}))}render(t){return(0,s.jsx)(f1,{...t.data,value:t.value,setValue:t.setValue})}},su="__select_all__",du="__deselect_all__";const f1=t=>{let e=(0,OC.c)(45),{options:a,label:r,value:n,setValue:i,fullWidth:o,maxSelections:l}=t,d=(0,f.useId)(),[u,c]=(0,f.useState)(""),m;e:{if(!u){m=a;break e}let N;if(e[0]!==a||e[1]!==u){let R;e[3]===u?R=e[4]:(R=_=>h1(_,u)===1,e[3]=u,e[4]=R),N=a.filter(R),e[0]=a,e[1]=u,e[2]=N}else N=e[2];m=N}let p=m,h;e[5]!==l||e[6]!==i?(h=N=>{if(!N||N.length===0){i([]);return}if(N=N.filter($C),l===1){i([N[N.length-1]]);return}l!=null&&N.length>l&&(N=N.slice(-l)),i(N)},e[5]=l,e[6]=i,e[7]=h):h=e[7];let x=h,g;e[8]!==a||e[9]!==i?(g=()=>{i(a)},e[8]=a,e[9]=i,e[10]=g):g=e[10];let y=g,b;e[11]===i?b=e[12]:(b=()=>{i([])},e[11]=i,e[12]=b);let w=b,D;if(e[13]!==w||e[14]!==y||e[15]!==l||e[16]!==a.length||e[17]!==n){D=[];let N=a.length>0&&n.length<a.length,R=a.length>0&&n.length>0;if(a.length>2&&l==null){let _=!N,V;e[19]!==y||e[20]!==_?(V=(0,s.jsx)(Ta,{value:su,onSelect:y,disabled:_,children:"Select all"},su),e[19]=y,e[20]=_,e[21]=V):V=e[21],D.push(V)}if(a.length>2){let _=!R,V=l===1?"Deselect":"Deselect all",I;e[22]!==w||e[23]!==_||e[24]!==V?(I=(0,s.jsx)(Ta,{value:du,onSelect:w,disabled:_,children:V},du),e[22]=w,e[23]=_,e[24]=V,e[25]=I):I=e[25];let A;e[26]===Symbol.for("react.memo_cache_sentinel")?(A=(0,s.jsx)(sI,{},"_separator"),e[26]=A):A=e[26],D.push(I,A)}e[13]=w,e[14]=y,e[15]=l,e[16]=a.length,e[17]=n,e[18]=D}else D=e[18];let j;e[27]!==D||e[28]!==p?(j=()=>{if(p.length>200)return(0,s.jsx)(r1,{style:{height:"200px"},totalCount:p.length,overscan:50,itemContent:R=>{let _=(0,s.jsx)(Ta,{value:p[R],children:p[R]},p[R]);return R===0?(0,s.jsxs)(s.Fragment,{children:[D,_]}):_}});let N=p.map(BC);return(0,s.jsxs)(s.Fragment,{children:[D,N]})},e[27]=D,e[28]=p,e[29]=j):j=e[29];let C=j,S;e[30]===o?S=e[31]:(S=Y({"w-full":o}),e[30]=o,e[31]=S);let k;e[32]===C?k=e[33]:(k=C(),e[32]=C,e[33]=k);let v;e[34]!==x||e[35]!==u||e[36]!==S||e[37]!==k||e[38]!==n?(v=(0,s.jsx)(El,{displayValue:HC,placeholder:"Select...",multiple:!0,className:S,value:n,onValueChange:x,shouldFilter:!1,search:u,onSearchChange:c,children:k}),e[34]=x,e[35]=u,e[36]=S,e[37]=k,e[38]=n,e[39]=v):v=e[39];let E;return e[40]!==o||e[41]!==d||e[42]!==r||e[43]!==v?(E=(0,s.jsx)(et,{label:r,id:d,fullWidth:o,children:v}),e[40]=o,e[41]=d,e[42]=r,e[43]=v,e[44]=E):E=e[44],E};function $C(t){return t!==su&&t!==du}function BC(t){return(0,s.jsx)(Ta,{value:t,children:t},t)}function HC(t){return t}var Sa=te();const ea=t=>{let e=(0,Sa.c)(5),{text:a,tooltip:r}=t,n;e[0]===r?n=e[1]:(n=r&&(0,s.jsx)(_a,{content:r,children:(0,s.jsx)(vl,{className:"w-3 h-3 mt-0.5"})}),e[0]=r,e[1]=n);let i;return e[2]!==n||e[3]!==a?(i=(0,s.jsxs)("h2",{className:"font-semibold my-0 flex items-center gap-1",children:[a,n]}),e[2]=n,e[3]=a,e[4]=i):i=e[4],i},g1=t=>{let e=(0,Sa.c)(5),{children:a,className:r}=t,n;e[0]===r?n=e[1]:(n=Y("flex flex-col gap-2",r),e[0]=r,e[1]=n);let i;return e[2]!==a||e[3]!==n?(i=(0,s.jsx)("div",{className:n,children:a}),e[2]=a,e[3]=n,e[4]=i):i=e[4],i},uu=t=>{let e=(0,Sa.c)(4),{className:a}=t,r;e[0]===a?r=e[1]:(r=Y("my-1",a),e[0]=a,e[1]=r);let n;return e[2]===r?n=e[3]:(n=(0,s.jsx)("hr",{className:r}),e[2]=r,e[3]=n),n},Vo=t=>{let e=(0,Sa.c)(5),{children:a,className:r}=t,n;e[0]===r?n=e[1]:(n=Y("flex flex-col gap-1.5",r),e[0]=r,e[1]=n);let i;return e[2]!==a||e[3]!==n?(i=(0,s.jsx)("section",{className:n,children:a}),e[2]=a,e[3]=n,e[4]=i):i=e[4],i},x1=t=>{let e=(0,Sa.c)(7),{Icon:a,text:r}=t,n;e[0]===a?n=e[1]:(n=(0,s.jsx)(a,{className:"w-3 h-3 mr-2"}),e[0]=a,e[1]=n);let i;e[2]===r?i=e[3]:(i=(0,s.jsx)("span",{children:r}),e[2]=r,e[3]=i);let o;return e[4]!==n||e[5]!==i?(o=(0,s.jsxs)("div",{className:"flex items-center",children:[n,i]}),e[4]=n,e[5]=i,e[6]=o):o=e[6],o},Qr=t=>{let e=(0,Sa.c)(5),{children:a,className:r}=t,n;e[0]===r?n=e[1]:(n=Y("py-1",r),e[0]=r,e[1]=n);let i;return e[2]!==a||e[3]!==n?(i=(0,s.jsx)(Vv,{className:n,children:a}),e[2]=a,e[3]=n,e[4]=i):i=e[4],i},Jr=t=>{let e=(0,Sa.c)(3),{children:a,value:r}=t,n;return e[0]!==a||e[1]!==r?(n=(0,s.jsx)(zv,{value:r,className:"border-none",children:a}),e[0]=a,e[1]=r,e[2]=n):n=e[2],n},Xr=t=>{let e=(0,Sa.c)(5),{children:a,wrapperClassName:r}=t,n;e[0]===r?n=e[1]:(n=Y("pb-2 flex flex-col gap-2",r),e[0]=r,e[1]=n);let i;return e[2]!==a||e[3]!==n?(i=(0,s.jsx)(Ov,{wrapperClassName:n,children:a}),e[2]=a,e[3]=n,e[4]=i):i=e[4],i},WC=t=>{let e=(0,Sa.c)(4),{code:a,insertNewCell:r,language:n}=t,i;return e[0]!==a||e[1]!==r||e[2]!==n?(i=(0,s.jsx)(Rc,{minHeight:"330px",maxHeight:"330px",code:a,language:n,showHideCode:!1,showCopyCode:!1,insertNewCell:r}),e[0]=a,e[1]=r,e[2]=n,e[3]=i):i=e[3],i};var Rt=te(),zo="__clear__";const Oo=t=>{let e=(0,Rt.c)(23),{fieldName:a,columns:r,onValueChange:n,includeCountField:i}=t,o=i===void 0?!0:i,l=lt(),d;e[0]===a?d=e[1]:(d=a.replace(".field",".type"),e[0]=a,e[1]=d);let u=d,c;e[2]===a?c=e[3]:(c=a.replace(".field",".selectedDataType"),e[2]=a,e[3]=c);let m=c,p;e[4]!==a||e[5]!==l||e[6]!==n||e[7]!==m||e[8]!==u?(p=()=>{l.setValue(a,""),l.setValue(u,""),l.setValue(m,""),n==null||n("",void 0)},e[4]=a,e[5]=l,e[6]=n,e[7]=m,e[8]=u,e[9]=p):p=e[9];let h=p,x;e[10]!==h||e[11]!==r||e[12]!==a||e[13]!==l||e[14]!==o||e[15]!==n||e[16]!==m||e[17]!==u?(x=y=>{let{field:b}=y;return(0,s.jsx)(ht,{children:(0,s.jsx)(gt,{children:(0,s.jsxs)(ar,{...b,onValueChange:w=>{if(w===zo){h();return}if(w==="__count__"){l.setValue(a,w),l.setValue(u,""),l.setValue(m,""),n==null||n(a,"number");return}let D=r.find(j=>j.name===w);D&&(l.setValue(a,w),l.setValue(u,D.type),l.setValue(m,Sc(D.type)),n==null||n(a,D.type))},value:b.value??"",children:[(0,s.jsx)(Er,{className:"w-40 truncate",onClear:b.value?h:void 0,children:(0,s.jsx)(er,{placeholder:"Select column"})}),(0,s.jsxs)(tr,{children:[b.value&&(0,s.jsx)(Zt,{value:zo,children:(0,s.jsxs)("div",{className:"flex items-center truncate",children:[(0,s.jsx)(ki,{className:"w-3 h-3 mr-2"}),"Clear"]})}),o&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Zt,{value:"__count__",children:(0,s.jsxs)("div",{className:"flex items-center truncate",children:[(0,s.jsx)(Ll,{className:"w-3 h-3 mr-2"}),"Count of records"]})},"__count__"),(0,s.jsx)(Cl,{})]}),r.map(KC)]})]})})})},e[10]=h,e[11]=r,e[12]=a,e[13]=l,e[14]=o,e[15]=n,e[16]=m,e[17]=u,e[18]=x):x=e[18];let g;return e[19]!==a||e[20]!==l.control||e[21]!==x?(g=(0,s.jsx)(mt,{control:l.control,name:a,render:x}),e[19]=a,e[20]=l.control,e[21]=x,e[22]=g):g=e[22],g},cu=t=>{let e=(0,Rt.c)(8),{fieldName:a,label:r,options:n,defaultValue:i}=t,o=lt(),l;e[0]!==i||e[1]!==r||e[2]!==n?(l=u=>{let{field:c}=u;return(0,s.jsxs)(ht,{className:"flex flex-row items-center justify-between",children:[(0,s.jsx)(wt,{children:r}),(0,s.jsx)(gt,{children:(0,s.jsxs)(ar,{...c,onValueChange:c.onChange,value:c.value??i,children:[(0,s.jsx)(Er,{className:"truncate",children:(0,s.jsx)(er,{placeholder:"Select an option"})}),(0,s.jsx)(tr,{children:(0,s.jsx)(hn,{children:n.filter(YC).map(qC)})})]})})]})},e[0]=i,e[1]=r,e[2]=n,e[3]=l):l=e[3];let d;return e[4]!==a||e[5]!==o.control||e[6]!==l?(d=(0,s.jsx)(mt,{control:o.control,name:a,render:l}),e[4]=a,e[5]=o.control,e[6]=l,e[7]=d):d=e[7],d},mu=t=>{let e=(0,Rt.c)(6),{fieldName:a,label:r}=t,n=lt(),i;e[0]===r?i=e[1]:(i=l=>{let{field:d}=l;return(0,s.jsxs)(ht,{className:"flex flex-row gap-2 items-center",children:[(0,s.jsx)(wt,{children:r}),(0,s.jsx)(gt,{children:(0,s.jsx)(Pc,{...d,value:d.value??"",onValueChange:d.onChange,className:"text-xs h-5"})})]})},e[0]=r,e[1]=i);let o;return e[2]!==a||e[3]!==n.control||e[4]!==i?(o=(0,s.jsx)(mt,{control:n.control,name:a,render:i}),e[2]=a,e[3]=n.control,e[4]=i,e[5]=o):o=e[5],o},en=t=>{let e=(0,Rt.c)(17),a,r,n,i,o,l;e[0]===t?(a=e[1],r=e[2],n=e[3],i=e[4],o=e[5],l=e[6]):({fieldName:r,label:o,className:a,inputClassName:n,isDisabled:i,...l}=t,e[0]=t,e[1]=a,e[2]=r,e[3]=n,e[4]=i,e[5]=o,e[6]=l);let d=lt(),u;e[7]!==a||e[8]!==n||e[9]!==i||e[10]!==o||e[11]!==l?(u=m=>{let{field:p}=m;return(0,s.jsxs)(ht,{className:Y("flex flex-row items-center gap-2",a),children:[(0,s.jsx)(wt,{className:"whitespace-nowrap",children:o}),(0,s.jsx)(gt,{children:(0,s.jsx)(p6,{...p,value:p.value,onValueChange:p.onChange,"aria-label":o,className:Y("w-16",n),isDisabled:i,minValue:0,...l})})]})},e[7]=a,e[8]=n,e[9]=i,e[10]=o,e[11]=l,e[12]=u):u=e[12];let c;return e[13]!==r||e[14]!==d.control||e[15]!==u?(c=(0,s.jsx)(mt,{control:d.control,name:r,render:u}),e[13]=r,e[14]=d.control,e[15]=u,e[16]=c):c=e[16],c},tn=t=>{let e=(0,Rt.c)(8),{fieldName:a,label:r,className:n,defaultValue:i}=t,o=lt(),l;e[0]!==n||e[1]!==i||e[2]!==r?(l=u=>{let{field:c}=u;return(0,s.jsxs)(ht,{className:Y("flex flex-row items-center gap-2",n),children:[(0,s.jsx)(wt,{children:r}),(0,s.jsx)(gt,{children:(0,s.jsx)(xl,{checked:c.value??i??!1,onCheckedChange:c.onChange,className:"w-4 h-4"})})]})},e[0]=n,e[1]=i,e[2]=r,e[3]=l):l=e[3];let d;return e[4]!==a||e[5]!==o.control||e[6]!==l?(d=(0,s.jsx)(mt,{control:o.control,name:a,render:l}),e[4]=a,e[5]=o.control,e[6]=l,e[7]=d):d=e[7],d},v1=t=>{let e=(0,Rt.c)(12),{fieldName:a,label:r,defaultValue:n,start:i,stop:o,step:l,className:d}=t,u=lt(),c;e[0]!==d||e[1]!==n||e[2]!==a||e[3]!==r||e[4]!==i||e[5]!==l||e[6]!==o?(c=p=>{let{field:h}=p,x=h.value??n,g=Number(x),y=b=>{typeof b=="string"&&(b=Number(b)),h.onChange(b)};return(0,s.jsxs)(ht,{className:Y("flex flex-row items-center gap-2 w-1/2",d),children:[(0,s.jsx)(wt,{children:r}),(0,s.jsx)(gt,{children:(0,s.jsx)(Ad,{...h,id:a,className:"relative flex items-center select-none",value:[g],min:i,max:o,step:l,onValueChange:b=>{let[w]=b;y(w)},onValueCommit:b=>{let[w]=b;y(w)},valueMap:GC})})]})},e[0]=d,e[1]=n,e[2]=a,e[3]=r,e[4]=i,e[5]=l,e[6]=o,e[7]=c):c=e[7];let m;return e[8]!==a||e[9]!==u.control||e[10]!==c?(m=(0,s.jsx)(mt,{control:u.control,name:a,render:c}),e[8]=a,e[9]=u.control,e[10]=c,e[11]=m):m=e[11],m},UC=t=>{let e=(0,Rt.c)(28),{fieldName:a,label:r,className:n}=t,i=lt(),o;e[0]!==a||e[1]!==i?(o=i.watch(a),e[0]=a,e[1]=i,e[2]=o):o=e[2];let l=o,d;e[3]===l?d=e[4]:(d=l??[],e[3]=l,e[4]=d);let[u,c]=f.useState(d),m;e[5]!==u||e[6]!==a||e[7]!==i?(m=()=>{let D=[...u,"#000000"];c(D),i.setValue(a,D)},e[5]=u,e[6]=a,e[7]=i,e[8]=m):m=e[8];let p=m,h;e[9]!==u||e[10]!==a||e[11]!==i?(h=D=>{let j=u.filter((C,S)=>S!==D);c(j),i.setValue(a,j)},e[9]=u,e[10]=a,e[11]=i,e[12]=h):h=e[12];let x=h,g;e[13]!==u||e[14]!==a||e[15]!==i?(g=(D,j)=>{let C=[...u];C[D]=j,c(C),i.setValue(a,C)},e[13]=u,e[14]=a,e[15]=i,e[16]=g):g=e[16];let y=g,b;e[17]!==p||e[18]!==n||e[19]!==u||e[20]!==r||e[21]!==x||e[22]!==y?(b=()=>(0,s.jsxs)(ht,{className:Y("flex flex-col gap-2",n),children:[(0,s.jsx)(wt,{children:r}),(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[u.map((D,j)=>(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("input",{type:"color",value:D,onChange:C=>y(j,C.target.value),className:"w-4 h-4 rounded cursor-pointer"}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground font-mono",children:D}),(0,s.jsx)(Pe,{variant:"ghost",size:"sm",onClick:()=>x(j),className:"h-4 w-4 p-0",children:(0,s.jsx)(ki,{className:"h-2 w-2"})})]},j)),(0,s.jsxs)(Pe,{variant:"outline",size:"sm",onClick:p,className:"w-fit h-6 text-xs",children:[(0,s.jsx)(dy,{className:"h-3 w-3 mr-1"}),"Add Color"]})]})]}),e[17]=p,e[18]=n,e[19]=u,e[20]=r,e[21]=x,e[22]=y,e[23]=b):b=e[23];let w;return e[24]!==a||e[25]!==i.control||e[26]!==b?(w=(0,s.jsx)(mt,{control:i.control,name:a,render:b}),e[24]=a,e[25]=i.control,e[26]=b,e[27]=w):w=e[27],w},pu=t=>{let e=(0,Rt.c)(10),{fieldName:a,label:r}=t,n=lt(),i;e[0]!==a||e[1]!==n?(i=()=>{n.setValue(a,"")},e[0]=a,e[1]=n,e[2]=i):i=e[2];let o=i,l=QC,d;e[3]!==o||e[4]!==r?(d=c=>{let{field:m}=c;return(0,s.jsxs)(ht,{className:"flex flex-row items-center justify-between w-full",children:[(0,s.jsx)(wt,{children:r}),(0,s.jsx)(gt,{children:(0,s.jsxs)(ar,{...m,onValueChange:p=>{p===zo?o():m.onChange(p)},value:m.value??"yearmonthdate",children:[(0,s.jsx)(Er,{onClear:m.value?o:void 0,children:(0,s.jsx)(er,{placeholder:"Select unit"})}),(0,s.jsxs)(tr,{className:"w-72",children:[m.value&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Zt,{value:zo,children:(0,s.jsxs)("div",{className:"flex items-center truncate",children:[(0,s.jsx)(ki,{className:"w-3 h-3 mr-2"}),"Clear"]})}),(0,s.jsx)(Cl,{})]}),(0,s.jsxs)(hn,{children:[RA.map(l),(0,s.jsx)(Cl,{}),TA.map(l)]})]})]})})]})},e[3]=o,e[4]=r,e[5]=d):d=e[5];let u;return e[6]!==a||e[7]!==n.control||e[8]!==d?(u=(0,s.jsx)(mt,{control:n.control,name:a,render:d}),e[6]=a,e[7]=n.control,e[8]=d,e[9]=u):u=e[9],u},Lo=t=>{let e=(0,Rt.c)(9),{fieldName:a,label:r,defaultValue:n,onValueChange:i}=t,[o,l]=f.useState(!1),d=lt(),u;e[0]!==n||e[1]!==o||e[2]!==r||e[3]!==i?(u=m=>{let{field:p}=m;return(0,s.jsxs)(ht,{className:"flex flex-row items-center justify-between w-full",children:[(0,s.jsx)(wt,{children:r}),(0,s.jsx)(gt,{children:(0,s.jsxs)(ar,{...p,onValueChange:h=>{p.onChange(h),i==null||i(h)},value:p.value??n,open:o,onOpenChange:l,children:[(0,s.jsx)(Er,{children:(0,s.jsx)(er,{placeholder:"Select an option"})}),(0,s.jsx)(tr,{children:(0,s.jsx)(hn,{children:ny.map(h=>{let x=gv[h],g=h==="string"?"categorical":h;return(0,s.jsx)(Zt,{value:h,className:"flex flex-col items-start justify-center",subtitle:o&&(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:bA[h]}),children:(0,s.jsx)(x1,{Icon:x,text:nr(g)})},h)})})})]})})]})},e[0]=n,e[1]=o,e[2]=r,e[3]=i,e[4]=u):u=e[4];let c;return e[5]!==a||e[6]!==d.control||e[7]!==u?(c=(0,s.jsx)(mt,{control:d.control,name:a,render:u}),e[5]=a,e[6]=d.control,e[7]=u,e[8]=c):c=e[8],c},y1=t=>{let e=(0,Rt.c)(12),{fieldName:a,selectedDataType:r,binFieldName:n,defaultAggregation:i}=t,o=lt(),l=r==="string"?SA:ay,{chartType:d}=da(),u=d!==xa.HEATMAP,c=JC,m=XC,p;e[0]!==n||e[1]!==o?(p=y=>{let{value:b,previousValue:w,onChange:D}=y;b==="bin"?o.setValue(n,!0):w==="bin"&&o.setValue(n,!1),D(b)},e[0]=n,e[1]=o,e[2]=p):p=e[2];let h=p,x;e[3]!==l||e[4]!==i||e[5]!==h||e[6]!==u?(x=y=>{let{field:b}=y;return(0,s.jsx)(ht,{children:(0,s.jsx)(gt,{children:(0,s.jsxs)(ar,{...b,value:(b.value??i??"none").toString(),onValueChange:w=>{h({value:w,previousValue:b.value,onChange:b.onChange})},children:[(0,s.jsx)(Er,{variant:"ghost",children:(0,s.jsx)(er,{})}),(0,s.jsx)(tr,{children:(0,s.jsxs)(hn,{children:[(0,s.jsx)(x_,{children:"Aggregation"}),l.map(w=>{let D=IA[w],j=c(jA[w]??"Other"),C=m({value:w,Icon:D??Ll,subtitle:j});return w==="bin"?u?(0,s.jsxs)("div",{children:[(0,s.jsx)(Cl,{}),C]},w):null:C})]})})]})})})},e[3]=l,e[4]=i,e[5]=h,e[6]=u,e[7]=x):x=e[7];let g;return e[8]!==a||e[9]!==o.control||e[10]!==x?(g=(0,s.jsx)(mt,{control:o.control,name:a,render:x}),e[8]=a,e[9]=o.control,e[10]=x,e[11]=g):g=e[11],g},ZC=t=>{let e=(0,Rt.c)(7),{fieldName:a,saveFunction:r}=t,n=lt(),{fields:i}=da(),o=ek,l;e[0]!==i||e[1]!==r?(l=u=>{var p;let{field:c}=u,m=((p=c.value)==null?void 0:p.map(tk))??[];return(0,s.jsx)(ht,{children:(0,s.jsx)(gt,{children:(0,s.jsx)(f1,{options:(i==null?void 0:i.map(ak))??[],value:m,setValue:h=>{let x=(typeof h=="function"?h([]):h).map(g=>o(g,i));c.onChange(x),r()},label:null,fullWidth:!1})})})},e[0]=i,e[1]=r,e[2]=l):l=e[2];let d;return e[3]!==a||e[4]!==n.control||e[5]!==l?(d=(0,s.jsx)(mt,{control:n.control,name:a,render:l}),e[3]=a,e[4]=n.control,e[5]=l,e[6]=d):d=e[6],d},b1=t=>{let e=(0,Rt.c)(5),{fieldName:a,label:r,defaultValue:n}=t,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=iy.map(rk),e[0]=i):i=e[0];let o=n??"ascending",l;return e[1]!==a||e[2]!==r||e[3]!==o?(l=(0,s.jsx)(cu,{fieldName:a,label:r,options:i,defaultValue:o}),e[1]=a,e[2]=r,e[3]=o,e[4]=l):l=e[4],l},hu=t=>{var p,h,x,g;let e=(0,Rt.c)(10),{fieldName:a}=t,r=lt(),n;e[0]===r.control?n=e[1]:(n={control:r.control},e[0]=r.control,e[1]=n);let i=va(n);if(!((h=(p=i[a])==null?void 0:p.bin)!=null&&h.binned))return null;let o=!Number.isNaN((g=(x=i[a])==null?void 0:x.bin)==null?void 0:g.step),l=`${a}.bin.step`,d;e[2]===l?d=e[3]:(d=(0,s.jsx)(en,{fieldName:l,label:"Bin step",inputClassName:"w-14",placeholder:"0.5"}),e[2]=l,e[3]=d);let u=`${a}.bin.maxbins`,c;e[4]!==o||e[5]!==u?(c=(0,s.jsx)(en,{fieldName:u,label:"Max bins",inputClassName:"w-14",isDisabled:o,placeholder:"10"}),e[4]=o,e[5]=u,e[6]=c):c=e[6];let m;return e[7]!==d||e[8]!==c?(m=(0,s.jsxs)("div",{className:"flex flex-row justify-between",children:[d,c]}),e[7]=d,e[8]=c,e[9]=m):m=e[9],m};function KC(t){if(t.name.trim()==="")return null;let e=gv[t.type];return(0,s.jsx)(Zt,{value:t.name,children:(0,s.jsxs)("div",{className:"flex items-center truncate",children:[(0,s.jsx)(e,{className:"w-3 h-3 mr-2"}),t.name]})},t.name)}function YC(t){return t.value!==""}function qC(t){return(0,s.jsx)(Zt,{value:t.value,children:t.display},t.value)}function GC(t){return t}function QC(t){let[e,a]=wA[t];return(0,s.jsx)(Zt,{value:t,className:"flex flex-row",subtitle:(0,s.jsx)("span",{className:"text-xs text-muted-foreground ml-auto",children:a}),children:e},t)}function JC(t){return(0,s.jsx)("span",{className:"text-xs text-muted-foreground pr-10",children:t})}function XC(t){let{value:e,Icon:a,subtitle:r}=t;return(0,s.jsx)(Zt,{value:e,className:"flex flex-col items-start justify-center",subtitle:r,children:(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)(a,{className:"w-3 h-3 mr-2"}),nr(e)]})},e)}function ek(t,e){var a;return{field:t,type:((a=e.find(r=>r.name===t))==null?void 0:a.type)??"string"}}function tk(t){return t.field}function ak(t){return t.name}function rk(t){return{display:(0,s.jsx)(x1,{Icon:t==="ascending"?Kb:tA,text:nr(t)}),value:t}}var wr=te();function Dr(t){return Ia(t==null?void 0:t.field)&&(t==null?void 0:t.field)!=="__count__"}function nk(t){return(t==null?void 0:t.selectedDataType)==="string"&&Dr(t)}function ii(t){return(t==null?void 0:t.selectedDataType)==="number"&&Dr(t)}function fu(t){return(t==null?void 0:t.selectedDataType)==="temporal"&&Dr(t)}function ik(t){return(t==null?void 0:t.selectedDataType)!=="temporal"&&Dr(t)}function $o(t){let e=t!=null&&t.type?Sc(t.type):"string";return{inferredDataType:e,selectedDataType:(t==null?void 0:t.selectedDataType)||e}}var gu=t=>{let e=(0,wr.c)(14),{columnFieldName:a,column:r,columns:n,binFieldName:i,defaultAggregation:o}=t,l;e[0]===r?l=e[1]:(l=$o(r),e[0]=r,e[1]=l);let{selectedDataType:d}=l,u;e[2]!==a||e[3]!==n?(u=(0,s.jsx)(Oo,{fieldName:a,columns:n}),e[2]=a,e[3]=n,e[4]=u):u=e[4];let c;e[5]!==i||e[6]!==r||e[7]!==a||e[8]!==o||e[9]!==d?(c=ik(r)&&(0,s.jsx)(y1,{fieldName:a.replace(".field",".aggregate"),selectedDataType:d,binFieldName:i,defaultAggregation:o}),e[5]=i,e[6]=r,e[7]=a,e[8]=o,e[9]=d,e[10]=c):c=e[10];let m;return e[11]!==u||e[12]!==c?(m=(0,s.jsxs)("div",{className:"flex flex-row justify-between",children:[u,c]}),e[11]=u,e[12]=c,e[13]=m):m=e[13],m};const ok=t=>{let e=(0,wr.c)(7),{value:a,onValueChange:r}=t,n,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=rr({variant:"outline",className:"user-select-none w-full justify-between px-3"}),i=(0,s.jsx)(er,{}),e[0]=n,e[1]=i):(n=e[0],i=e[1]);let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=(0,s.jsxs)(y_,{className:n,children:[i,(0,s.jsx)(v_,{asChild:!0,children:(0,s.jsx)(ly,{className:"h-4 w-4 opacity-50"})})]}),e[2]=o):o=e[2];let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=(0,s.jsxs)("div",{className:"flex flex-row gap-2 items-center",children:[o,(0,s.jsx)(tr,{children:_A.map(dk)})]}),e[3]=l):l=e[3];let d;return e[4]!==r||e[5]!==a?(d=(0,s.jsx)(ar,{value:a,onValueChange:r,children:l}),e[4]=r,e[5]=a,e[6]=d):d=e[6],d};var lk=t=>{let e=(0,wr.c)(10),{chartType:a}=t,r=PA[a],n;e[0]===r?n=e[1]:(n=(0,s.jsx)(r,{className:"w-4 h-4 mr-2"}),e[0]=r,e[1]=n);let i;e[2]===a?i=e[3]:(i=nr(a),e[2]=a,e[3]=i);let o;e[4]!==n||e[5]!==i?(o=(0,s.jsxs)("div",{className:"flex items-center",children:[n,i]}),e[4]=n,e[5]=i,e[6]=o):o=e[6];let l;return e[7]!==a||e[8]!==o?(l=(0,s.jsx)(Zt,{value:a,className:"gap-2",children:o}),e[7]=a,e[8]=o,e[9]=l):l=e[9],l};const w1=()=>{var g,y,b,w,D,j,C;let t=(0,wr.c)(22),e=lt(),a;t[0]===e.control?a=t[1]:(a={control:e.control},t[0]=e.control,t[1]=a);let r=va(a),n=da(),i=(g=r.general)==null?void 0:g.xColumn,o;t[2]===i?o=t[3]:(o=$o(i),t[2]=i,t[3]=o);let{inferredDataType:l}=o,d=n.chartType===xa.LINE||n.chartType===xa.BAR||n.chartType===xa.AREA,u;t[4]===Symbol.for("react.memo_cache_sentinel")?(u=(0,s.jsx)(ea,{text:"X-Axis"}),t[4]=u):u=t[4];let c;t[5]!==n.fields||t[6]!==i?(c=(0,s.jsx)(gu,{columnFieldName:"general.xColumn.field",column:i,columns:n.fields,binFieldName:"xAxis.bin.binned"}),t[5]=n.fields,t[6]=i,t[7]=c):c=t[7];let m;t[8]!==l||t[9]!==i?(m=Dr(i)&&(0,s.jsx)(Lo,{label:"Data Type",fieldName:"general.xColumn.selectedDataType",defaultValue:l}),t[8]=l,t[9]=i,t[10]=m):m=t[10];let p;t[11]===i?p=t[12]:(p=fu(i)&&(0,s.jsx)(pu,{fieldName:"general.xColumn.timeUnit",label:"Time Resolution"}),t[11]=i,t[12]=p);let h;t[13]!==d||t[14]!==((b=(y=r.general)==null?void 0:y.xColumn)==null?void 0:b.sort)||t[15]!==i?(h=Dr(i)&&d&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(b1,{fieldName:"general.xColumn.sort",label:"Sort",defaultValue:(D=(w=r.general)==null?void 0:w.xColumn)==null?void 0:D.sort}),ii(i)&&(0,s.jsx)(hu,{fieldName:"xAxis"})]}),t[13]=d,t[14]=(C=(j=r.general)==null?void 0:j.xColumn)==null?void 0:C.sort,t[15]=i,t[16]=h):h=t[16];let x;return t[17]!==c||t[18]!==m||t[19]!==p||t[20]!==h?(x=(0,s.jsxs)(Vo,{children:[u,c,m,p,h]}),t[17]=c,t[18]=m,t[19]=p,t[20]=h,t[21]=x):x=t[21],x},D1=()=>{var S,k,v;let t=(0,wr.c)(29),e=lt(),a;t[0]===e.control?a=t[1]:(a={control:e.control},t[0]=e.control,t[1]=a);let r=va(a),n=da(),i=(S=r.general)==null?void 0:S.yColumn,o=i==null?void 0:i.field,l;t[2]===o?l=t[3]:(l=Ia(o),t[2]=o,t[3]=l);let d=l,u=(v=(k=r.general)==null?void 0:k.xColumn)==null?void 0:v.field,c;t[4]===u?c=t[5]:(c=Ia(u),t[4]=u,t[5]=c);let m=c,p;t[6]===i?p=t[7]:(p=$o(i),t[6]=i,t[7]=p);let{inferredDataType:h}=p,x;ii(i)?x=DA:nk(i)&&(x="count");let g;t[8]===Symbol.for("react.memo_cache_sentinel")?(g=(0,s.jsx)(ea,{text:"Y-Axis"}),t[8]=g):g=t[8];let y;t[9]!==n.fields||t[10]!==x||t[11]!==i?(y=(0,s.jsx)(gu,{columnFieldName:"general.yColumn.field",column:i,columns:n.fields,binFieldName:"yAxis.bin.binned",defaultAggregation:x}),t[9]=n.fields,t[10]=x,t[11]=i,t[12]=y):y=t[12];let b;t[13]!==h||t[14]!==i?(b=Dr(i)&&(0,s.jsx)(Lo,{label:"Data Type",fieldName:"general.yColumn.selectedDataType",defaultValue:h}),t[13]=h,t[14]=i,t[15]=b):b=t[15];let w;t[16]===i?w=t[17]:(w=fu(i)&&(0,s.jsx)(pu,{fieldName:"general.yColumn.timeUnit",label:"Time Resolution"}),t[16]=i,t[17]=w);let D;t[18]!==m||t[19]!==d?(D=d&&m&&(0,s.jsx)(tn,{fieldName:"general.horizontal",label:"Invert axis"}),t[18]=m,t[19]=d,t[20]=D):D=t[20];let j;t[21]===i?j=t[22]:(j=ii(i)&&(0,s.jsx)(hu,{fieldName:"yAxis"}),t[21]=i,t[22]=j);let C;return t[23]!==D||t[24]!==j||t[25]!==y||t[26]!==b||t[27]!==w?(C=(0,s.jsxs)(Vo,{children:[g,y,b,w,D,j]}),t[23]=D,t[24]=j,t[25]=y,t[26]=b,t[27]=w,t[28]=C):C=t[28],C},j1=()=>{var m;let t=(0,wr.c)(13),{fields:e}=da(),a=lt(),r;t[0]===a.control?r=t[1]:(r={control:a.control},t[0]=a.control,t[1]=r);let n=(m=va(r).general)==null?void 0:m.colorByColumn,i;t[2]===n?i=t[3]:(i=ii(n),t[2]=n,t[3]=i);let o=i,l;t[4]===Symbol.for("react.memo_cache_sentinel")?(l=(0,s.jsx)(ea,{text:"Color by"}),t[4]=l):l=t[4];let d;t[5]!==n||t[6]!==e?(d=(0,s.jsx)(gu,{columnFieldName:"general.colorByColumn.field",column:n,columns:e,binFieldName:"color.bin.binned"}),t[5]=n,t[6]=e,t[7]=d):d=t[7];let u;t[8]===o?u=t[9]:(u=o&&(0,s.jsx)(hu,{fieldName:"color"}),t[8]=o,t[9]=u);let c;return t[10]!==d||t[11]!==u?(c=(0,s.jsxs)(Vo,{children:[l,d,u]}),t[10]=d,t[11]=u,t[12]=c):c=t[12],c},sk=()=>{var d,u;let t=(0,wr.c)(7),e=da().fields,a=lt(),r;t[0]===a.control?r=t[1]:(r={control:a.control},t[0]=a.control,t[1]=r);let n=va(r),i;t[2]!==e||t[3]!==((d=n.general)==null?void 0:d.facet)?(i=c=>{var g,y;let m=(y=(g=n.general)==null?void 0:g.facet)==null?void 0:y[c],p=Ia(m==null?void 0:m.field),{inferredDataType:h}=$o(m),x=c==="row"?"general.facet.row.linkYAxis":"general.facet.column.linkXAxis";return(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsxs)("div",{className:"flex flex-row justify-between",children:[(0,s.jsx)("p",{className:"font-semibold",children:nr(c)}),(0,s.jsx)(Oo,{fieldName:`general.facet.${c}.field`,columns:e})]}),p&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Lo,{label:"Data Type",fieldName:`general.facet.${c}.selectedDataType`,defaultValue:h}),fu(m)&&(0,s.jsx)(pu,{fieldName:`general.facet.${c}.timeUnit`,label:"Time Resolution"}),ii(m)&&(0,s.jsxs)("div",{className:"flex flex-row justify-between",children:[(0,s.jsx)(tn,{fieldName:`general.facet.${c}.binned`,label:"Binned",defaultValue:!0}),(0,s.jsx)(en,{fieldName:`general.facet.${c}.maxbins`,label:"Max Bins",placeholder:"6",defaultValue:6})]}),(0,s.jsx)(b1,{fieldName:`general.facet.${c}.sort`,label:"Sort"}),(0,s.jsx)(tn,{fieldName:x,label:`Link ${c==="row"?"Y":"X"} Axes`,defaultValue:!0})]})]})},t[2]=e,t[3]=(u=n.general)==null?void 0:u.facet,t[4]=i):i=t[4];let o=i,l;return t[5]===o?l=t[6]:(l=(0,s.jsxs)(Vo,{className:"gap-3",children:[o("row"),o("column")]}),t[5]=o,t[6]=l),l};function dk(t){return(0,s.jsx)(lk,{chartType:t},t)}var xu=te();const uk=()=>{var D,j;let t=(0,xu.c)(17),e=lt(),a;t[0]===e.control?a=t[1]:(a={control:e.control},t[0]=e.control,t[1]=a);let r=va(a),n=(D=r.general)==null?void 0:D.yColumn,i=(j=r.general)==null?void 0:j.colorByColumn,o=n==null?void 0:n.field,l;t[2]===o?l=t[3]:(l=Ia(o),t[2]=o,t[3]=l);let d=l,{chartType:u}=da(),c;t[4]!==u||t[5]!==(i==null?void 0:i.field)?(c=Ia(i==null?void 0:i.field)&&(u===xa.BAR||u===xa.LINE),t[4]=u,t[5]=i==null?void 0:i.field,t[6]=c):c=t[6];let m=c,p,h,x;t[7]===Symbol.for("react.memo_cache_sentinel")?(p=(0,s.jsx)(_a,{delayDuration:100,content:"To persist a chart, add the generated Python code to a new cell.",children:(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)($l,{className:"h-3.5 w-3.5 mb-0.5 text-muted-foreground"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Charts are not saved."})]})}),h=(0,s.jsx)(w1,{}),x=(0,s.jsx)(D1,{}),t[7]=p,t[8]=h,t[9]=x):(p=t[7],h=t[8],x=t[9]);let g;t[10]!==m||t[11]!==d?(g=d&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(j1,{}),m&&(0,s.jsx)("div",{className:"flex flex-row gap-2",children:(0,s.jsx)(tn,{fieldName:"general.stacking",label:"Stacked"})})]}),t[10]=m,t[11]=d,t[12]=g):g=t[12];let y,b;t[13]===Symbol.for("react.memo_cache_sentinel")?(y=(0,s.jsx)(uu,{}),b=(0,s.jsx)(vu,{}),t[13]=y,t[14]=b):(y=t[13],b=t[14]);let w;return t[15]===g?w=t[16]:(w=(0,s.jsxs)(s.Fragment,{children:[p,h,x,g,y,b]}),t[15]=g,t[16]=w),w},ck=()=>{let t=(0,xu.c)(15),{chartType:e}=da(),a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=(0,s.jsx)(Qr,{className:"pt-0",children:(0,s.jsx)(ea,{text:"General"})}),t[0]=a):a=t[0];let r;t[1]===Symbol.for("react.memo_cache_sentinel")?(r=(0,s.jsx)(mu,{label:"Plot title",fieldName:"general.title"}),t[1]=r):r=t[1];let n=e===xa.SCATTER,i;t[2]===n?i=t[3]:(i=(0,s.jsxs)(Jr,{value:"general",children:[a,(0,s.jsxs)(Xr,{children:[r,(0,s.jsx)(tn,{fieldName:"style.gridLines",label:"Show grid lines",defaultValue:n})]})]}),t[2]=n,t[3]=i);let o;t[4]===Symbol.for("react.memo_cache_sentinel")?(o=(0,s.jsx)(Qr,{children:(0,s.jsx)(ea,{text:"X-Axis"})}),t[4]=o):o=t[4];let l;t[5]===Symbol.for("react.memo_cache_sentinel")?(l=(0,s.jsxs)(Jr,{value:"xAxis",children:[o,(0,s.jsxs)(Xr,{children:[(0,s.jsx)(mu,{label:"Label",fieldName:"xAxis.label"}),(0,s.jsx)(v1,{fieldName:"xAxis.width",label:"Width",defaultValue:400,start:200,stop:800})]})]}),t[5]=l):l=t[5];let d;t[6]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsx)(Qr,{children:(0,s.jsx)(ea,{text:"Y-Axis"})}),t[6]=d):d=t[6];let u;t[7]===Symbol.for("react.memo_cache_sentinel")?(u=(0,s.jsxs)(Jr,{value:"yAxis",children:[d,(0,s.jsxs)(Xr,{children:[(0,s.jsx)(mu,{label:"Label",fieldName:"yAxis.label"}),(0,s.jsx)(v1,{fieldName:"yAxis.height",label:"Height",defaultValue:300,start:150,stop:600})]})]}),t[7]=u):u=t[7];let c;t[8]===Symbol.for("react.memo_cache_sentinel")?(c=(0,s.jsx)(Qr,{children:(0,s.jsx)(ea,{text:"Color"})}),t[8]=c):c=t[8];let m;t[9]===Symbol.for("react.memo_cache_sentinel")?(m=(0,s.jsx)(cu,{fieldName:"color.field",label:"Field",options:ry.map(mk),defaultValue:Ci}),t[9]=m):m=t[9];let p,h;t[10]===Symbol.for("react.memo_cache_sentinel")?(p=(0,s.jsx)(cu,{fieldName:"color.scheme",label:"Color scheme",defaultValue:ty,options:CA.map(pk)}),h=(0,s.jsx)(UC,{fieldName:"color.range",label:"Color range"}),t[10]=p,t[11]=h):(p=t[10],h=t[11]);let x;t[12]===Symbol.for("react.memo_cache_sentinel")?(x=(0,s.jsxs)(Jr,{value:"color",children:[c,(0,s.jsxs)(Xr,{children:[m,p,h,(0,s.jsxs)("p",{className:"text-xs",children:[(0,s.jsx)(vl,{className:"w-2.5 h-2.5 inline mb-1 mr-1"}),"If you are using color range, color scheme will be ignored."]})]})]}),t[12]=x):x=t[12];let g;return t[13]===i?g=t[14]:(g=(0,s.jsxs)(pc,{type:"multiple",children:[i,l,u,x]}),t[13]=i,t[14]=g),g},vu=()=>{var m;let t=(0,xu.c)(11),{saveForm:e}=da(),a=lt(),r;t[0]===a.control?r=t[1]:(r={control:a.control},t[0]=a.control,t[1]=r);let n=(m=va(r).tooltips)==null?void 0:m.auto,i;t[2]===Symbol.for("react.memo_cache_sentinel")?(i=(0,s.jsx)(Qr,{className:"pt-0",children:(0,s.jsx)(ea,{text:"Faceting",tooltip:"Repeat the chart for each unique field value"})}),t[2]=i):i=t[2];let o;t[3]===Symbol.for("react.memo_cache_sentinel")?(o=(0,s.jsxs)(Jr,{value:"facet",children:[i,(0,s.jsx)(Xr,{children:(0,s.jsx)(sk,{})})]}),t[3]=o):o=t[3];let l;t[4]===Symbol.for("react.memo_cache_sentinel")?(l=(0,s.jsx)(Qr,{children:(0,s.jsx)(ea,{text:"Tooltips"})}),t[4]=l):l=t[4];let d;t[5]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsx)(tn,{fieldName:"tooltips.auto",label:"Include X, Y and Color"}),t[5]=d):d=t[5];let u;t[6]!==n||t[7]!==e?(u=!n&&(0,s.jsx)(ZC,{fieldName:"tooltips.fields",saveFunction:e}),t[6]=n,t[7]=e,t[8]=u):u=t[8];let c;return t[9]===u?c=t[10]:(c=(0,s.jsxs)(pc,{type:"multiple",children:[o,(0,s.jsxs)(Jr,{value:"tooltips",children:[l,(0,s.jsxs)(Xr,{wrapperClassName:"flex-row justify-between",children:[d,u]})]})]}),t[9]=u,t[10]=c),c};function mk(t){return{display:nr(t),value:t}}function pk(t){return{display:nr(t),value:t}}var hk=te();const fk=()=>{var b,w,D,j;let t=(0,hk.c)(17),e=lt(),a;t[0]===e.control?a=t[1]:(a={control:e.control},t[0]=e.control,t[1]=a);let r=va(a),n=(w=(b=r.general)==null?void 0:b.xColumn)==null?void 0:w.field,i;t[2]===n?i=t[3]:(i=Ia(n),t[2]=n,t[3]=i);let o=i,l=(j=(D=r.general)==null?void 0:D.yColumn)==null?void 0:j.field,d;t[4]===l?d=t[5]:(d=Ia(l),t[4]=l,t[5]=d);let u=d,c;t[6]===Symbol.for("react.memo_cache_sentinel")?(c=(0,s.jsx)(w1,{}),t[6]=c):c=t[6];let m;t[7]===o?m=t[8]:(m=o&&(0,s.jsx)(en,{fieldName:"xAxis.bin.maxbins",label:"Number of boxes (max)",className:"justify-between"}),t[7]=o,t[8]=m);let p;t[9]===Symbol.for("react.memo_cache_sentinel")?(p=(0,s.jsx)(D1,{}),t[9]=p):p=t[9];let h;t[10]===u?h=t[11]:(h=u&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(en,{fieldName:"yAxis.bin.maxbins",label:"Number of boxes (max)",className:"justify-between"}),(0,s.jsx)(j1,{})]}),t[10]=u,t[11]=h);let x,g;t[12]===Symbol.for("react.memo_cache_sentinel")?(g=(0,s.jsx)(uu,{}),x=(0,s.jsx)(vu,{}),t[12]=x,t[13]=g):(x=t[12],g=t[13]);let y;return t[14]!==m||t[15]!==h?(y=(0,s.jsxs)(s.Fragment,{children:[c,m,p,h,g,x]}),t[14]=m,t[15]=h,t[16]=y):y=t[16],y};var gk=te();const xk=()=>{var j,C,S;let t=(0,gk.c)(25),e=lt(),{fields:a}=da(),r;t[0]===e.control?r=t[1]:(r={control:e.control},t[0]=e.control,t[1]=r);let n=va(r),i=(j=n.general)==null?void 0:j.colorByColumn,o=(S=(C=n.general)==null?void 0:C.yColumn)==null?void 0:S.selectedDataType;(o===""||!o)&&(o="string");let l;t[2]===i?l=t[3]:(l=i!=null&&i.type?Sc(i.type):"string",t[2]=i,t[3]=l);let d=l,u;t[4]===Symbol.for("react.memo_cache_sentinel")?(u=(0,s.jsx)(ea,{text:"Color by"}),t[4]=u):u=t[4];let c;t[5]===a?c=t[6]:(c=(0,s.jsx)(Oo,{fieldName:"general.colorByColumn.field",columns:a,includeCountField:!1}),t[5]=a,t[6]=c);let m;t[7]!==(i==null?void 0:i.field)||t[8]!==d?(m=Ia(i==null?void 0:i.field)&&(0,s.jsx)(Lo,{fieldName:"general.colorByColumn.selectedDataType",label:"Data Type",defaultValue:d}),t[7]=i==null?void 0:i.field,t[8]=d,t[9]=m):m=t[9];let p;t[10]===Symbol.for("react.memo_cache_sentinel")?(p=(0,s.jsx)(ea,{text:"Size by"}),t[10]=p):p=t[10];let h;t[11]===a?h=t[12]:(h=(0,s.jsx)(Oo,{fieldName:"general.yColumn.field",columns:a}),t[11]=a,t[12]=h);let x;t[13]===o?x=t[14]:(x=(0,s.jsx)(y1,{fieldName:"general.yColumn.aggregate",selectedDataType:o,binFieldName:"yAxis.bin.binned"}),t[13]=o,t[14]=x);let g;t[15]!==h||t[16]!==x?(g=(0,s.jsxs)("div",{className:"flex flex-row justify-between",children:[h,x]}),t[15]=h,t[16]=x,t[17]=g):g=t[17];let y,b,w;t[18]===Symbol.for("react.memo_cache_sentinel")?(w=(0,s.jsx)(en,{fieldName:"style.innerRadius",label:"Donut size",className:"w-32"}),y=(0,s.jsx)(uu,{}),b=(0,s.jsx)(vu,{}),t[18]=y,t[19]=b,t[20]=w):(y=t[18],b=t[19],w=t[20]);let D;return t[21]!==c||t[22]!==m||t[23]!==g?(D=(0,s.jsxs)(s.Fragment,{children:[u,c,m,p,g,w,y,b]}),t[21]=c,t[22]=m,t[23]=g,t[24]=D):D=t[24],D};var C1=te();const vk=t=>{let e=(0,C1.c)(8),{baseSpec:a,data:r,height:n}=t,{theme:i}=vn();if(!r){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=(0,s.jsx)("div",{children:"No data"}),e[0]=u):u=e[0],u}let o;e[1]!==r||e[2]!==n||e[3]!==i?(o=u=>{if(typeof u=="string")return(0,s.jsx)(Uv,{children:u});let c=AA(u,r);return(0,s.jsx)(f.Suspense,{fallback:(0,s.jsx)(yk,{}),children:(0,s.jsx)($_,{spec:c,"data-container-width":rI(c),options:{theme:i==="dark"?"dark":void 0,height:n,actions:{export:!0,source:!1,compiled:!1,editor:!1},mode:"vega",renderer:"canvas",tooltip:aI.call}})})},e[1]=r,e[2]=n,e[3]=i,e[4]=o):o=e[4];let l=o,d;return e[5]!==a||e[6]!==l?(d=(0,s.jsx)("div",{className:"h-full m-auto rounded-md w-full",children:l(a)}),e[5]=a,e[6]=l,e[7]=d):d=e[7],d};var yk=()=>{let t=(0,C1.c)(1),e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,s.jsx)(Uv,{className:"mt-14",children:"Loading chart..."}),t[0]=e):e=t[0],e};const yu=L({binned:W().optional(),step:H().optional(),maxbins:H().optional()});var bu=L({field:M().optional(),type:be([...ko,""]).optional(),selectedDataType:be([...ny,""]).optional(),sort:be(iy).default("ascending").optional(),timeUnit:be(kA).optional()});const wu=bu.extend({aggregate:be(ay).default(Ci).optional()}),bk=bu.extend({linkYAxis:W().default(!0),binned:W().default(!0),maxbins:H().default(6)}),wk=bu.extend({linkXAxis:W().default(!0),binned:W().default(!0),maxbins:H().default(6)}),k1=L({general:L({title:M().optional(),xColumn:wu.optional(),yColumn:wu.optional(),colorByColumn:wu.optional(),facet:L({row:bk,column:wk}).optional(),horizontal:W().optional(),stacking:W().optional()}).optional(),xAxis:L({label:M().optional(),width:H().optional(),bin:yu.optional()}).optional(),yAxis:L({label:M().optional(),height:H().optional(),bin:yu.optional()}).optional(),color:L({field:be([...ry,Ci]).default(Ci),scheme:M().default(ty).optional(),range:Q(M()).optional(),domain:Q(M()).optional(),bin:yu.optional()}).optional(),style:L({innerRadius:H().optional(),gridLines:W().optional()}).optional(),tooltips:L({auto:W(),fields:Q(L({field:M(),type:be(ko)}))}).default({auto:!0,fields:[]}).optional()});function Du(){return{general:{facet:{row:{linkYAxis:!0,binned:!0,maxbins:6},column:{linkXAxis:!0,binned:!0,maxbins:6}}},color:{field:Ci,scheme:"default"},tooltips:{auto:!0,fields:[]}}}const ju="marimo:charts:v2";var Dk=L({tabName:M().transform(t=>t),chartType:M().transform(t=>t),config:k1}),Cu=new XN(ju,Q(ra([M().transform(t=>t),Q(Dk)])),()=>[]),S1={getItem:t=>{try{let e=Cu.get(t);return new Map(e)}catch(e){return de.warn("Error getting chart storage",e),new Map}},setItem:(t,e)=>{Cu.set(t,[...e.entries()])},removeItem:t=>{Cu.remove(t)}};const jk=aT(ju,new Map,S1);function ku(t,e){let a=nr(e);return t===0?`${a} Chart`:`${a} Chart ${t+1}`}var Ck=S1.getItem(ju);function kk(t){let e=Ck.get(t);return e?e.length>0:!1}var Sk=te(),Bo="bar",Ho="table",E1=290,Ek=5e4,Rk=50;const Nk=({cellId:t,data:e,dataTable:a,totalRows:r,columns:n,getDataUrl:i,fieldTypes:o,displayHeader:l,onCloseChartBuilder:d})=>{let[u,c]=xi(jk),m=t?u.get(t)??[]:[],[p,h]=(0,f.useState)(Ho),[x,g]=(0,f.useState)(m.length),y=(0,f.useRef)(l);if(l&&!y.current&&m.length===0&&t){y.current=l;let S=ku(0,Bo),k=new Map(u);k.set(t,[{tabName:S,chartType:Bo,config:Du()}]),c(k),g(1),h(S)}if(y.current=l,!l||m.length===0&&!l)return a;let b=()=>{if(!t)return;let S=ku(x,Bo),k=new Map(u);k.set(t,[...m,{tabName:S,chartType:Bo,config:Du()}]),c(k),g(x+1),h(S)},w=S=>{if(!t)return;let k=m.findIndex(N=>N.tabName===S),v=m.filter(N=>N.tabName!==S),E=new Map(u);E.set(t,v),c(E),v.length===0?d==null||d():S===p&&(k<v.length?h(v[k].tabName):h(v[v.length-1].tabName))},D=({tabName:S,chartType:k,chartConfig:v})=>{if(!t)return;let E=new Map(u);E.set(t,m.map(N=>N.tabName===S?{...N,chartType:k,config:v}:N)),c(E)},j=(S,k)=>{if(!t)return;let v=u.get(t)??[],E=v.findIndex(R=>R.tabName===S);if(E===-1)return;let N=v.map(R=>R.tabName===S?{...R,chartType:k,tabName:ku(E,k)}:R);c(new Map(u).set(t,N)),h(N[E].tabName)},C=r==="too_many"||r>Ek||n>Rk;return(0,s.jsxs)(pn,{value:p,className:"-mt-1",children:[(0,s.jsxs)(wi,{part:"table-tabs",children:[(0,s.jsx)(ga,{className:"text-xs",value:Ho,onClick:()=>h(Ho),children:"Table"}),m.map((S,k)=>(0,s.jsxs)(ga,{className:"text-xs",value:S.tabName,onClick:()=>h(S.tabName),children:[S.tabName,(0,s.jsx)(ki,{className:"w-3 h-3 ml-1 mt-[0.5px] hover:text-red-500 hover:font-semibold",onClick:v=>{v.stopPropagation(),w(S.tabName)}})]},k)),(0,s.jsx)(Pe,{variant:"text",size:"icon",onClick:b,title:"Add chart",children:"+"})]}),(0,s.jsx)(Ut,{className:"mt-1 overflow-hidden",value:Ho,children:a}),m.map((S,k)=>(0,s.jsx)(Ut,{value:S.tabName,className:"h-[400px] mt-1",children:(0,s.jsx)(Tk,{tableData:e,chartConfig:S.config,chartType:S.chartType,saveChart:v=>{D({tabName:S.tabName,chartType:S.chartType,chartConfig:v})},saveChartType:v=>{j(S.tabName,v)},getDataUrl:i,fieldTypes:o??vc(a.props.data),isLargeDataset:C})},k))]})};var R1="X and Y columns are not set";const Tk=({tableData:t,chartConfig:e,chartType:a,saveChart:r,saveChartType:n,getDataUrl:i,fieldTypes:o,isLargeDataset:l})=>{let{theme:d}=vn(),u=by({defaultValues:e??Du(),resolver:wy(k1)}),[c,m]=(0,f.useState)(a),[p,h]=(0,f.useState)(!1),[x,g]=(0,f.useState)(!l),{ref:y}=fI(),{data:b,isPending:w,error:D}=Yt(async()=>{if(!i||t.length===0||!x)return[];let k=await i({});return Array.isArray(k.data_url)?k.data_url:await My(k.data_url,k.format==="arrow"?{type:"arrow"}:k.format==="json"?{type:"json"}:{type:"csv",parse:"auto"},{replacePeriod:!0})},[t,x]),j=u.watch(),C=NA(c,(0,f.useMemo)(()=>structuredClone(j),[j]),d,"container",E1),S=(0,f.useMemo)(()=>w?(0,s.jsx)(S_,{}):D?(0,s.jsx)(V_,{error:D}):x?(0,s.jsx)(vk,{baseSpec:C,data:b,height:E1}):(0,s.jsxs)(Yl,{variant:"warning",className:"flex flex-row gap-2 items-center w-2/3 mx-auto",children:[(0,s.jsx)($l,{className:"h-4 w-4 mt-1"}),(0,s.jsxs)(lI,{className:"flex flex-row justify-between items-center w-full",children:[(0,s.jsx)("span",{children:"Rendering large datasets is not well supported and may crash the browser"}),(0,s.jsx)(Pe,{variant:"warn",onClick:()=>g(!0),className:"h-8",children:"Proceed"})]})]}),[w,D,x,C,b]);return(0,s.jsxs)("div",{className:"flex flex-row gap-2 h-full rounded-md border pr-2",children:[(0,s.jsxs)("div",{className:`relative flex flex-col gap-2 overflow-auto px-2 py-3 scrollbar-thin transition-width duration-200 ${p?"w-8":"w-[300px]"}`,children:[!p&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ok,{value:c,onValueChange:k=>{m(k),n(k)}}),(0,s.jsx)(_k,{form:u,saveChart:r,fieldTypes:o,chartType:c})]}),(0,s.jsx)(Pe,{variant:"outline",size:"icon",className:"border-border ml-auto",onClick:()=>h(k=>!k),title:p?"Expand sidebar":"Collapse sidebar",children:p?(0,s.jsx)(Si,{className:"w-4 h-5"}):(0,s.jsx)(Sl,{className:"w-4 h-5"})})]}),(0,s.jsx)("div",{className:"flex-1 overflow-auto h-full w-full mt-3",children:(()=>{let k=R1;return typeof C!="string"&&(k=mj(C,"_df","_chart")),(0,s.jsxs)(pn,{defaultValue:"chart",children:[(0,s.jsx)("div",{className:"flex flex-row gap-1.5 items-center",children:(0,s.jsxs)(wi,{children:[(0,s.jsxs)(ga,{value:"chart",className:"h-6",children:[(0,s.jsx)(yA,{className:"text-muted-foreground mr-2 w-4 h-4"}),"Chart"]}),(0,s.jsxs)(ga,{value:"code",className:"h-6",children:[(0,s.jsx)(gI,{className:"text-muted-foreground mr-2"}),"Python code"]}),!1]})}),(0,s.jsx)(Ut,{value:"chart",ref:y,children:S}),(0,s.jsx)(Ut,{value:"code",children:(0,s.jsx)(WC,{code:k,insertNewCell:k!==R1,language:"python"})}),!1]})})()})]})};var _k=t=>{let e=(0,Sk.c)(28),{form:a,saveChart:r,fieldTypes:n,chartType:i}=t,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0];let l=o;if(n){let S;e[1]===n?S=e[2]:(S=n.map(Ak),e[1]=n,e[2]=S),l=S}let d;e[3]!==a||e[4]!==r?(d=()=>{r(a.getValues())},e[3]=a,e[4]=r,e[5]=d):d=e[5];let u=Q6(d,300),c=uk;i===xa.PIE?c=xk:i===xa.HEATMAP&&(c=fk);let m;e[6]!==i||e[7]!==u||e[8]!==l?(m={fields:l,saveForm:u,chartType:i},e[6]=i,e[7]=u,e[8]=l,e[9]=m):m=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=(0,s.jsxs)(ga,{value:"data",className:"w-1/2 h-6",children:[(0,s.jsx)(Dv,{className:"w-4 h-4 mr-2"}),"Data"]}),e[10]=p):p=e[10];let h;e[11]===Symbol.for("react.memo_cache_sentinel")?(h=(0,s.jsxs)(wi,{className:"w-full",children:[p,(0,s.jsxs)(ga,{value:"style",className:"w-1/2 h-6",children:[(0,s.jsx)(qN,{className:"w-4 h-4 mr-2"}),"Style"]})]}),e[11]=h):h=e[11];let x;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=(0,s.jsx)("hr",{className:"my-2"}),e[12]=x):x=e[12];let g;e[13]===c?g=e[14]:(g=(0,s.jsxs)(Ut,{value:"data",children:[x,(0,s.jsx)(g1,{children:(0,s.jsx)(c,{})})]}),e[13]=c,e[14]=g);let y;e[15]===Symbol.for("react.memo_cache_sentinel")?(y=(0,s.jsx)("hr",{className:"my-2"}),e[15]=y):y=e[15];let b;e[16]===Symbol.for("react.memo_cache_sentinel")?(b=(0,s.jsxs)(Ut,{value:"style",children:[y,(0,s.jsx)(g1,{children:(0,s.jsx)(ck,{})})]}),e[16]=b):b=e[16];let w;e[17]===g?w=e[18]:(w=(0,s.jsxs)(pn,{defaultValue:"data",children:[h,g,b]}),e[17]=g,e[18]=w);let D;e[19]!==u||e[20]!==w?(D=(0,s.jsx)("form",{onSubmit:Ik,onChange:u,children:w}),e[19]=u,e[20]=w,e[21]=D):D=e[21];let j;e[22]!==a||e[23]!==D?(j=(0,s.jsx)(b6,{...a,children:D}),e[22]=a,e[23]=D,e[24]=j):j=e[24];let C;return e[25]!==j||e[26]!==m?(C=(0,s.jsx)(fx,{value:m,children:j}),e[25]=j,e[26]=m,e[27]=C):C=e[27],C};function Ak(t){return{name:t[0],type:t[1][0]}}function Ik(t){return t.preventDefault()}var Pk=te();function Mk(t,e){let a=(0,Pk.c)(16),r=gl(R_),{focusCell:n}=pI(),i=hI(),[o,l]=xi(M_),[d,u]=xi(eA),[c,m]=xi(O_),p=Fk(t,e);!e&&r&&(de.error("CellId is not found, defaulting to fixed mode"),r=!1);let h=j=>d===p&&c&&j===o,x=i===e,g=d&&Vk(d,e);r&&x&&d!==p&&!g&&u(p);let y=d===p&&c,b;a[0]!==e||a[1]!==n||a[2]!==y||a[3]!==r||a[4]!==p||a[5]!==o||a[6]!==m||a[7]!==u||a[8]!==l?(b=function(j){y?(u(null),m(!1)):(u(p),r&&e&&n({cellId:e}),m(!0),j&&!o&&l(j))},a[0]=e,a[1]=n,a[2]=y,a[3]=r,a[4]=p,a[5]=o,a[6]=m,a[7]=u,a[8]=l,a[9]=b):b=a[9];let w=b,D;return a[10]!==y||a[11]!==h||a[12]!==o||a[13]!==l||a[14]!==w?(D={isPanelOpen:h,isAnyPanelOpen:y,togglePanel:w,panelType:o,setPanelType:l},a[10]=y,a[11]=h,a[12]=o,a[13]=l,a[14]=w,a[15]=D):D=a[15],D}function Fk(t,e){return e?`${e}-${t}`:t}function Vk(t,e){return e?t.startsWith(e):!1}const N1=ut.input(yi.object({format:yi.enum(["csv","json","parquet"])})).output(yi.object({url:yi.string(),filename:yi.string()}));var Su=te();const zk=t=>{let e=(0,Su.c)(40),{previewColumn:a,fieldTypes:r,totalRows:n,totalColumns:i,tableId:o}=t,[l,d]=(0,f.useState)(""),{locale:u}=rt(),c,m,p,h,x,g,y,b,w,D;if(e[0]!==r||e[1]!==u||e[2]!==a||e[3]!==l||e[4]!==o||e[5]!==i||e[6]!==n){let k=r==null?void 0:r.filter($k),v=k==null?void 0:k.filter(R=>{let[_]=R;return _.toLowerCase().includes(l.toLowerCase())});w="mb-3";let E;e[17]!==u||e[18]!==i||e[19]!==n?(E=L_(n,i,u),e[17]=u,e[18]=i,e[19]=n,e[20]=E):E=e[20],D=(0,s.jsxs)("span",{className:"text-xs font-semibold ml-2 flex",children:[E,(0,s.jsx)(zc,{tooltip:"Copy column names",value:(k==null?void 0:k.map(Bk).join(`,
29
+ `.trim()}function xr(t){let e={};for(let[a,r]of Object.entries(t))r!==void 0&&(e[a]=a==="field"&&typeof r=="string"?new gr(EA(r)):new gr(r));return e}const fx=(0,f.createContext)({fields:[],saveForm:Xa.NOOP,chartType:xa.LINE}),da=()=>(0,f.use)(fx);var pj=te(),Ad=f.forwardRef((t,e)=>{let a=(0,pj.c)(25),{className:r,valueMap:n,...i}=t,[o,l]=oy(!1),{locale:d}=rt(),u=ub,c;a[0]===r?c=a[1]:(c=Y("relative flex touch-none select-none hover:cursor-pointer","data-[orientation=horizontal]:w-full data-[orientation=horizontal]:items-center","data-[orientation=vertical]:h-full data-[orientation=vertical]:justify-center","data-disabled:cursor-not-allowed",r),a[0]=r,a[1]=c);let m;a[2]===Symbol.for("react.memo_cache_sentinel")?(m=Y("relative grow overflow-hidden rounded-full bg-slate-200 dark:bg-accent/60","data-[orientation=horizontal]:h-2 data-[orientation=horizontal]:w-full","data-[orientation=vertical]:h-full data-[orientation=vertical]:w-2"),a[2]=m):m=a[2];let p;a[3]===Symbol.for("react.memo_cache_sentinel")?(p=(0,s.jsx)(hs,{"data-testid":"track",className:m,children:(0,s.jsx)(fs,{"data-testid":"range",className:Y("absolute bg-blue-500 dark:bg-primary","data-[orientation=horizontal]:h-full","data-[orientation=vertical]:w-full","data-disabled:opacity-50")})}),a[3]=p):p=a[3];let h=_t,x=bc,g;a[4]!==l.setFalse||a[5]!==l.setTrue?(g=(0,s.jsx)(Dc,{asChild:!0,children:(0,s.jsx)(Mi,{"data-testid":"thumb",className:"block h-4 w-4 rounded-full shadow-xs-solid border border-blue-500 dark:border-primary dark:bg-accent bg-white hover:bg-blue-300 focus:bg-blue-300 transition-colors focus-visible:outline-hidden data-disabled:pointer-events-none data-disabled:opacity-50",onFocus:l.setTrue,onBlur:l.setFalse,onMouseEnter:l.setTrue,onMouseLeave:l.setFalse})}),a[4]=l.setFalse,a[5]=l.setTrue,a[6]=g):g=a[6];let y=jc,b=i.value!=null&&i.value.length===1&&(0,s.jsx)(wc,{children:bn(n(i.value[0]),{locale:d})},i.value[0]),w;a[7]!==y||a[8]!==b?(w=(0,s.jsx)(y,{children:b}),a[7]=y,a[8]=b,a[9]=w):w=a[9];let D;a[10]!==x||a[11]!==o||a[12]!==g||a[13]!==w?(D=(0,s.jsxs)(x,{delayDuration:0,open:o,children:[g,w]}),a[10]=x,a[11]=o,a[12]=g,a[13]=w,a[14]=D):D=a[14];let j;a[15]!==h||a[16]!==D?(j=(0,s.jsx)(h,{children:D}),a[15]=h,a[16]=D,a[17]=j):j=a[17];let C;return a[18]!==i||a[19]!==e||a[20]!==u.Root||a[21]!==j||a[22]!==c||a[23]!==p?(C=(0,s.jsxs)(u.Root,{ref:e,className:c,...i,children:[p,j]}),a[18]=i,a[19]=e,a[20]=u.Root,a[21]=j,a[22]=c,a[23]=p,a[24]=C):C=a[24],C});Ad.displayName=Pi.displayName;var hj=Na(vi(),1),Ro=0,Wa=1,Zr=2,gx=4;function xx(t){return()=>t}function fj(t){t()}function Zn(t,e){return a=>t(e(a))}function vx(t,e){return()=>t(e)}function gj(t,e){return a=>t(e,a)}function Id(t){return t!==void 0}function xj(...t){return()=>{t.map(fj)}}function Kr(){}function No(t,e){return e(t),t}function vj(t,e){return e(t)}function Ve(...t){return t}function Te(t,e){return t(Wa,e)}function xe(t,e){t(Ro,e)}function Pd(t){t(Zr)}function Ze(t){return t(gx)}function ne(t,e){return Te(t,gj(e,Ro))}function Gt(t,e){let a=t(Wa,r=>{a(),e(r)});return a}function yx(t){let e,a;return r=>n=>{e=n,a&&clearTimeout(a),a=setTimeout(()=>{r(e)},t)}}function bx(t,e){return t===e}function ze(t=bx){let e;return a=>r=>{t(e,r)||(e=r,a(r))}}function ue(t){return e=>a=>{t(a)&&e(a)}}function ae(t){return e=>Zn(e,t)}function ua(t){return e=>()=>{e(t)}}function U(t,...e){let a=yj(...e);return((r,n)=>{switch(r){case Zr:Pd(t);return;case Wa:return Te(t,a(n))}})}function ca(t,e){return a=>r=>{a(e=t(e,r))}}function vr(t){return e=>a=>{t>0?t--:e(a)}}function ka(t){let e=null,a;return r=>n=>{e=n,!a&&(a=setTimeout(()=>{a=void 0,r(e)},t))}}function ye(...t){let e=Array(t.length),a=0,r=null,n=2**t.length-1;return t.forEach((i,o)=>{let l=2**o;Te(i,d=>{let u=a;a|=l,e[o]=d,u!==n&&a===n&&r&&(r(),r=null)})}),i=>o=>{let l=()=>{i([o].concat(e))};a===n?l():r=l}}function yj(...t){return e=>t.reduceRight(vj,e)}function bj(t){let e,a,r=()=>e==null?void 0:e();return function(n,i){switch(n){case Wa:return i?a===i?void 0:(r(),a=i,e=Te(t,i),e):(r(),Kr);case Zr:r(),a=null;return}}}function q(t){let e=t,a=Ce();return((r,n)=>{switch(r){case Ro:e=n;break;case Wa:n(e);break;case gx:return e}return a(r,n)})}function yt(t,e){return No(q(e),a=>ne(t,a))}function Ce(){let t=[];return((e,a)=>{switch(e){case Ro:t.slice().forEach(r=>{r(a)});return;case Zr:t.splice(0,t.length);return;case Wa:return t.push(a),()=>{let r=t.indexOf(a);r>-1&&t.splice(r,1)}}})}function St(t){return No(Ce(),e=>ne(t,e))}function Ee(t,e=[],{singleton:a}={singleton:!0}){return{constructor:t,dependencies:e,id:wj(),singleton:a}}var wj=()=>Symbol();function Dj(t){let e=new Map,a=({constructor:r,dependencies:n,id:i,singleton:o})=>{if(o&&e.has(i))return e.get(i);let l=r(n.map(d=>a(d)));return o&&e.set(i,l),l};return a(t)}function nt(...t){let e=Ce(),a=Array(t.length),r=0,n=2**t.length-1;return t.forEach((i,o)=>{let l=2**o;Te(i,d=>{a[o]=d,r|=l,r===n&&xe(e,a)})}),function(i,o){switch(i){case Zr:Pd(e);return;case Wa:return r===n&&o(a),Te(e,o)}}}function ce(t,e=bx){return U(t,ze(e))}function Md(...t){return function(e,a){switch(e){case Zr:return;case Wa:return xj(...t.map(r=>Te(r,a)))}}}var Ct=(t=>(t[t.DEBUG=0]="DEBUG",t[t.INFO=1]="INFO",t[t.WARN=2]="WARN",t[t.ERROR=3]="ERROR",t))(Ct||{}),jj={0:"debug",3:"error",1:"log",2:"warn"},Cj=()=>typeof globalThis>"u"?window:globalThis,Ua=Ee(()=>{let t=q(3);return{log:q((e,a,r=1)=>{r>=(Cj().VIRTUOSO_LOG_LEVEL??Ze(t))&&console[jj[r]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",e,a)}),logLevel:t}},[],{singleton:!0});function ma(t,e,a){return Fd(t,e,a).callbackRef}function Fd(t,e,a){let r=f.useRef(null),n=o=>{},i=f.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(o=>{let l=()=>{let d=o[0].target;d.offsetParent!==null&&t(d)};a?l():requestAnimationFrame(l)}):null,[t,a]);return n=o=>{o&&e?(i==null||i.observe(o),r.current=o):(r.current&&(i==null||i.unobserve(r.current)),r.current=null)},{callbackRef:n,ref:r}}function wx(t,e,a,r,n,i,o,l,d){return Fd(f.useCallback(u=>{let c=kj(u.children,e,l?"offsetWidth":"offsetHeight",n),m=u.parentElement;for(;!m.dataset.virtuosoScroller;)m=m.parentElement;let p=m.lastElementChild.dataset.viewportType==="window",h;p&&(h=m.ownerDocument.defaultView);let x=o?l?o.scrollLeft:o.scrollTop:p?l?h.scrollX||h.document.documentElement.scrollLeft:h.scrollY||h.document.documentElement.scrollTop:l?m.scrollLeft:m.scrollTop,g=o?l?o.scrollWidth:o.scrollHeight:p?l?h.document.documentElement.scrollWidth:h.document.documentElement.scrollHeight:l?m.scrollWidth:m.scrollHeight,y=o?l?o.offsetWidth:o.offsetHeight:p?l?h.innerWidth:h.innerHeight:l?m.offsetWidth:m.offsetHeight;r({scrollHeight:g,scrollTop:Math.max(x,0),viewportHeight:y}),i==null||i(l?Dx("column-gap",getComputedStyle(u).columnGap,n):Dx("row-gap",getComputedStyle(u).rowGap,n)),c!==null&&t(c)},[t,e,n,i,o,r,l]),a,d)}function kj(t,e,a,r){let n=t.length;if(n===0)return null;let i=[];for(let o=0;o<n;o++){let l=t.item(o);if(l.dataset.index===void 0)continue;let d=parseInt(l.dataset.index),u=parseFloat(l.dataset.knownSize),c=e(l,a);if(c===0&&r("Zero-sized element, this should not happen",{child:l},Ct.ERROR),c===u)continue;let m=i[i.length-1];i.length===0||m.size!==c||m.endIndex!==d-1?i.push({endIndex:d,size:c,startIndex:d}):i[i.length-1].endIndex++}return i}function Dx(t,e,a){return e!=="normal"&&!(e!=null&&e.endsWith("px"))&&a(`${t} was not resolved to pixel value correctly`,e,Ct.WARN),e==="normal"?0:parseInt(e??"0",10)}function Vd(t,e,a){let r=f.useRef(null),n=f.useCallback(d=>{if(!(d!=null&&d.offsetParent))return;let u=d.getBoundingClientRect(),c=u.width,m,p;if(e){let h=e.getBoundingClientRect(),x=u.top-h.top;p=h.height-Math.max(0,x),m=x+e.scrollTop}else{let h=o.current.ownerDocument.defaultView;p=h.innerHeight-Math.max(0,u.top),m=u.top+h.scrollY}r.current={offsetTop:m,visibleHeight:p,visibleWidth:c},t(r.current)},[t,e]),{callbackRef:i,ref:o}=Fd(n,!0,a),l=f.useCallback(()=>{n(o.current)},[n,o]);return f.useEffect(()=>{var d;if(e){e.addEventListener("scroll",l);let u=new ResizeObserver(()=>{requestAnimationFrame(l)});return u.observe(e),()=>{e.removeEventListener("scroll",l),u.unobserve(e)}}else{let u=(d=o.current)==null?void 0:d.ownerDocument.defaultView;return u==null||u.addEventListener("scroll",l),u==null||u.addEventListener("resize",l),()=>{u==null||u.removeEventListener("scroll",l),u==null||u.removeEventListener("resize",l)}}},[l,e,o]),i}var Dt=Ee(()=>{let t=Ce(),e=Ce(),a=q(0),r=Ce(),n=q(0),i=Ce(),o=Ce(),l=q(0),d=q(0),u=q(0),c=q(0),m=Ce(),p=Ce(),h=q(!1),x=q(!1),g=q(!1);return ne(U(t,ae(({scrollTop:y})=>y)),e),ne(U(t,ae(({scrollHeight:y})=>y)),o),ne(e,n),{deviation:a,fixedFooterHeight:u,fixedHeaderHeight:d,footerHeight:c,headerHeight:l,horizontalDirection:x,scrollBy:p,scrollContainerState:t,scrollHeight:o,scrollingInProgress:h,scrollTo:m,scrollTop:e,skipAnimationFrameInResizeObserver:g,smoothScrollTargetReached:r,statefulScrollTop:n,viewportHeight:i}},[],{singleton:!0}),Kn={lvl:0};function jx(t,e){let a=t.length;if(a===0)return[];let{index:r,value:n}=e(t[0]),i=[];for(let o=1;o<a;o++){let{index:l,value:d}=e(t[o]);i.push({end:l-1,start:r,value:n}),r=l,n=d}return i.push({end:1/0,start:r,value:n}),i}function _e(t){return t===Kn}function Yn(t,e){if(!_e(t))return e===t.k?t.v:e<t.k?Yn(t.l,e):Yn(t.r,e)}function Qt(t,e,a="k"){if(_e(t))return[-1/0,void 0];if(Number(t[a])===e)return[t.k,t.v];if(Number(t[a])<e){let r=Qt(t.r,e,a);return r[0]===-1/0?[t.k,t.v]:r}return Qt(t.l,e,a)}function Et(t,e,a){return _e(t)?Sx(e,a,1):e===t.k?ct(t,{k:e,v:a}):e<t.k?Ex(ct(t,{l:Et(t.l,e,a)})):Ex(ct(t,{r:Et(t.r,e,a)}))}function Yr(){return Kn}function qr(t,e,a){if(_e(t))return[];let r=Qt(t,e)[0];return Sj(Od(t,r,a))}function zd(t,e){if(_e(t))return Kn;let{k:a,l:r,r:n}=t;if(e===a){if(_e(r))return n;if(_e(n))return r;{let[i,o]=kx(r);return Ld(ct(t,{k:i,l:Cx(r),v:o}))}}else return Ld(e<a?ct(t,{l:zd(r,e)}):ct(t,{r:zd(n,e)}))}function yr(t){return _e(t)?[]:[...yr(t.l),{k:t.k,v:t.v},...yr(t.r)]}function Od(t,e,a){if(_e(t))return[];let{k:r,l:n,r:i,v:o}=t,l=[];return r>e&&(l=l.concat(Od(n,e,a))),r>=e&&r<=a&&l.push({k:r,v:o}),r<=a&&(l=l.concat(Od(i,e,a))),l}function Ld(t){let{l:e,lvl:a,r}=t;if(r.lvl>=a-1&&e.lvl>=a-1)return t;if(a>r.lvl+1){if($d(e))return Rx(ct(t,{lvl:a-1}));if(!_e(e)&&!_e(e.r))return ct(e.r,{l:ct(e,{r:e.r.l}),lvl:a,r:ct(t,{l:e.r.r,lvl:a-1})});throw Error("Unexpected empty nodes")}else{if($d(t))return Bd(ct(t,{lvl:a-1}));if(!_e(r)&&!_e(r.l)){let n=r.l,i=$d(n)?r.lvl-1:r.lvl;return ct(n,{l:ct(t,{lvl:a-1,r:n.l}),lvl:n.lvl+1,r:Bd(ct(r,{l:n.r,lvl:i}))})}else throw Error("Unexpected empty nodes")}}function ct(t,e){return Sx(e.k===void 0?t.k:e.k,e.v===void 0?t.v:e.v,e.lvl===void 0?t.lvl:e.lvl,e.l===void 0?t.l:e.l,e.r===void 0?t.r:e.r)}function Cx(t){return _e(t.r)?t.l:Ld(ct(t,{r:Cx(t.r)}))}function $d(t){return _e(t)||t.lvl>t.r.lvl}function kx(t){return _e(t.r)?[t.k,t.v]:kx(t.r)}function Sx(t,e,a,r=Kn,n=Kn){return{k:t,l:r,lvl:a,r:n,v:e}}function Ex(t){return Bd(Rx(t))}function Rx(t){let{l:e}=t;return!_e(e)&&e.lvl===t.lvl?ct(e,{r:ct(t,{l:e.r})}):t}function Bd(t){let{lvl:e,r:a}=t;return!_e(a)&&!_e(a.r)&&a.lvl===e&&a.r.lvl===e?ct(a,{l:ct(t,{r:a.l}),lvl:e+1}):t}function Sj(t){return jx(t,({k:e,v:a})=>({index:e,value:a}))}function Nx(t,e){return!!(t&&t.startIndex===e.startIndex&&t.endIndex===e.endIndex)}function qn(t,e){return!!(t&&t[0]===e[0]&&t[1]===e[1])}var Hd=Ee(()=>({recalcInProgress:q(!1)}),[],{singleton:!0});function Tx(t,e,a){return t[To(t,e,a)]}function To(t,e,a,r=0){let n=t.length-1;for(;r<=n;){let i=Math.floor((r+n)/2),o=t[i],l=a(o,e);if(l===0)return i;if(l===-1){if(n-r<2)return i-1;n=i-1}else{if(n===r)return i;r=i+1}}throw Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${e}`)}function Ej(t,e,a,r){let n=To(t,e,r),i=To(t,a,r,n);return t.slice(n,i+1)}function Jt(t,e){return Math.round(t.getBoundingClientRect()[e])}function _o(t){return!_e(t.groupOffsetTree)}function Wd({index:t},e){return e===t?0:e<t?-1:1}function Rj(){return{groupIndices:[],groupOffsetTree:Yr(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Yr()}}function Nj(t,e){let a=_e(t)?0:1/0;for(let r of e){let{endIndex:n,size:i,startIndex:o}=r;if(a=Math.min(a,o),_e(t)){t=Et(t,0,i);continue}let l=qr(t,o-1,n+1);if(l.some(Fj(r)))continue;let d=!1,u=!1;for(let{end:c,start:m,value:p}of l)d?(n>=m||i===p)&&(t=zd(t,m)):(u=p!==i,d=!0),c>n&&n>=m&&p!==i&&(t=Et(t,n+1,p));u&&(t=Et(t,o,i))}return[t,a]}function Tj(t){return typeof t.groupIndex<"u"}function _j({offset:t},e){return e===t?0:e<t?-1:1}function Gn(t,e,a){if(e.length===0)return 0;let{index:r,offset:n,size:i}=Tx(e,t,Wd),o=t-r,l=i*o+(o-1)*a+n;return l>0?l+a:l}function _x(t,e){if(!_o(e))return t;let a=0;for(;e.groupIndices[a]<=t+a;)a++;return t+a}function Ax(t,e,a){if(Tj(t))return e.groupIndices[t.groupIndex]+1;{let r=_x(t.index==="LAST"?a:t.index,e);return r=Math.max(0,r,Math.min(a,r)),r}}function Aj(t,e,a,r=0){return r>0&&(e=Math.max(e,Tx(t,r,Wd).offset)),jx(Ej(t,e,a,_j),Mj)}function Ij(t,[e,a,r,n]){e.length>0&&r("received item sizes",e,Ct.DEBUG);let i=t.sizeTree,o=i,l=0;if(a.length>0&&_e(i)&&e.length===2){let p=e[0].size,h=e[1].size;o=a.reduce((x,g)=>Et(Et(x,g,p),g+1,h),o)}else[o,l]=Nj(o,e);if(o===i)return t;let{lastIndex:d,lastOffset:u,lastSize:c,offsetTree:m}=Ud(t.offsetTree,l,o,n);return{groupIndices:a,groupOffsetTree:a.reduce((p,h)=>Et(p,h,Gn(h,m,n)),Yr()),lastIndex:d,lastOffset:u,lastSize:c,offsetTree:m,sizeTree:o}}function Pj(t){return yr(t).map(({k:e,v:a},r,n)=>{let i=n[r+1];return{endIndex:i?i.k-1:1/0,size:a,startIndex:e}})}function Ix(t,e){let a=0,r=0;for(;a<t;)a+=e[r+1]-e[r]-1,r++;return r-(a===t?0:1)}function Ud(t,e,a,r){let n=t,i=0,o=0,l=0,d=0;if(e!==0){d=To(n,e-1,Wd),l=n[d].offset;let u=Qt(a,e-1);i=u[0],o=u[1],n.length&&n[d].size===Qt(a,e)[1]&&--d,n=n.slice(0,d+1)}else n=[];for(let{start:u,value:c}of qr(a,e,1/0)){let m=u-i,p=m*o+l+m*r;n.push({index:u,offset:p,size:c}),i=u,l=p,o=c}return{lastIndex:i,lastOffset:l,lastSize:o,offsetTree:n}}function Mj(t){return{index:t.index,value:t}}function Fj(t){let{endIndex:e,size:a,startIndex:r}=t;return n=>n.start===r&&(n.end===e||n.end===1/0)&&n.value===a}var Vj={offsetHeight:"height",offsetWidth:"width"},pa=Ee(([{log:t},{recalcInProgress:e}])=>{let a=Ce(),r=Ce(),n=yt(r,0),i=Ce(),o=Ce(),l=q(0),d=q([]),u=q(void 0),c=q(void 0),m=q(void 0),p=q(void 0),h=q((k,v)=>Jt(k,Vj[v])),x=q(void 0),g=q(0),y=Rj(),b=yt(U(a,ye(d,t,g),ca(Ij,y),ze()),y),w=yt(U(d,ze(),ca((k,v)=>({current:v,prev:k.current}),{current:[],prev:[]}),ae(({prev:k})=>k)),[]);ne(U(d,ue(k=>k.length>0),ye(b,g),ae(([k,v,E])=>{let N=k.reduce((R,_,V)=>Et(R,_,Gn(_,v.offsetTree,E)||V),Yr());return{...v,groupIndices:k,groupOffsetTree:N}})),b),ne(U(r,ye(b),ue(([k,{lastIndex:v}])=>k<v),ae(([k,{lastIndex:v,lastSize:E}])=>[{endIndex:v,size:E,startIndex:k}])),a),ne(u,c);let D=yt(U(u,ae(k=>k===void 0)),!0);ne(U(c,ue(k=>k!==void 0&&_e(Ze(b).sizeTree)),ae(k=>{let v=Ze(m),E=Ze(d).length>0;return v?E?[{endIndex:0,size:v,startIndex:0},{endIndex:1,size:k,startIndex:1}]:[]:[{endIndex:0,size:k,startIndex:0}]})),a),ne(U(p,ue(k=>k!==void 0&&k.length>0&&_e(Ze(b).sizeTree)),ae(k=>{let v=[],E=k[0],N=0;for(let R=1;R<k.length;R++){let _=k[R];_!==E&&(v.push({endIndex:R-1,size:E,startIndex:N}),E=_,N=R)}return v.push({endIndex:k.length-1,size:E,startIndex:N}),v})),a),ne(U(d,ye(m,c),ue(([,k,v])=>k!==void 0&&v!==void 0),ae(([k,v,E])=>{let N=[];for(let R=0;R<k.length;R++){let _=k[R],V=k[R+1];N.push({startIndex:_,endIndex:_,size:v}),V!==void 0&&N.push({startIndex:_+1,endIndex:V-1,size:E})}return N})),a);let j=St(U(a,ye(b),ca(({sizes:k},[v,E])=>({changed:E!==k,sizes:E}),{changed:!1,sizes:y}),ae(k=>k.changed)));Te(U(l,ca((k,v)=>({diff:k.prev-v,prev:v}),{diff:0,prev:0}),ae(k=>k.diff)),k=>{let{groupIndices:v}=Ze(b);if(k>0)xe(e,!0),xe(i,k+Ix(k,v));else if(k<0){let E=Ze(w);E.length>0&&(k-=Ix(-k,E)),xe(o,k)}}),Te(U(l,ye(t)),([k,v])=>{k<0&&v("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:l},Ct.ERROR)});let C=St(i);ne(U(i,ye(b),ae(([k,v])=>{let E=v.groupIndices.length>0,N=[],R=v.lastSize;if(E){let _=Yn(v.sizeTree,0),V=0,I=0;for(;V<k;){let T=v.groupIndices[I],P=v.groupIndices.length===I+1?1/0:v.groupIndices[I+1]-T-1;N.push({endIndex:T,size:_,startIndex:T}),N.push({endIndex:T+1+P-1,size:R,startIndex:T+1}),I++,V+=P+1}let A=yr(v.sizeTree);return V!==k&&A.shift(),A.reduce((T,{k:P,v:F})=>{let O=T.ranges;return T.prevSize!==0&&(O=[...T.ranges,{endIndex:P+k-1,size:T.prevSize,startIndex:T.prevIndex}]),{prevIndex:P+k,prevSize:F,ranges:O}},{prevIndex:k,prevSize:0,ranges:N}).ranges}return yr(v.sizeTree).reduce((_,{k:V,v:I})=>({prevIndex:V+k,prevSize:I,ranges:[..._.ranges,{endIndex:V+k-1,size:_.prevSize,startIndex:_.prevIndex}]}),{prevIndex:0,prevSize:R,ranges:[]}).ranges})),a);let S=St(U(o,ye(b,g),ae(([k,{offsetTree:v},E])=>Gn(-k,v,E))));return ne(U(o,ye(b,g),ae(([k,v,E])=>{if(v.groupIndices.length>0){if(_e(v.sizeTree))return v;let N=Yr(),R=Ze(w),_=0,V=0,I=0;for(;_<-k;){I=R[V];let A=R[V+1]-I-1;V++,_+=A+1}if(N=yr(v.sizeTree).reduce((A,{k:T,v:P})=>Et(A,Math.max(0,T+k),P),N),_!==-k){let A=Yn(v.sizeTree,I);N=Et(N,0,A);let T=Qt(v.sizeTree,-k+1)[1];N=Et(N,1,T)}return{...v,sizeTree:N,...Ud(v.offsetTree,0,N,E)}}else{let N=yr(v.sizeTree).reduce((R,{k:_,v:V})=>Et(R,Math.max(0,_+k),V),Yr());return{...v,sizeTree:N,...Ud(v.offsetTree,0,N,E)}}})),b),{beforeUnshiftWith:C,data:x,defaultItemSize:c,firstItemIndex:l,fixedItemSize:u,fixedGroupSize:m,gap:g,groupIndices:d,heightEstimates:p,itemSize:h,listRefresh:j,shiftWith:o,shiftWithOffset:S,sizeRanges:a,sizes:b,statefulTotalCount:n,totalCount:r,trackItemSizes:D,unshiftWith:i}},Ve(Ua,Hd),{singleton:!0});function zj(t){return t.reduce((e,a)=>(e.groupIndices.push(e.totalCount),e.totalCount+=a+1,e),{groupIndices:[],totalCount:0})}var Px=Ee(([{groupIndices:t,sizes:e,totalCount:a},{headerHeight:r,scrollTop:n}])=>{let i=Ce(),o=Ce(),l=St(U(i,ae(zj)));return ne(U(l,ae(d=>d.totalCount)),a),ne(U(l,ae(d=>d.groupIndices)),t),ne(U(nt(n,e,r),ue(([d,u])=>_o(u)),ae(([d,u,c])=>Qt(u.groupOffsetTree,Math.max(d-c,0),"v")[0]),ze(),ae(d=>[d])),o),{groupCounts:i,topItemsIndexes:o}},Ve(pa,Dt)),Za=Ee(([{log:t}])=>{let e=q(!1),a=St(U(e,ue(r=>r),ze()));return Te(e,r=>{r&&Ze(t)("props updated",{},Ct.DEBUG)}),{didMount:a,propsReady:e}},Ve(Ua),{singleton:!0}),Oj=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Mx(t){let e=typeof t=="number"?{index:t}:t;return e.align||(e.align="start"),(!e.behavior||!Oj)&&(e.behavior="auto"),e.offset||(e.offset=0),e}var Qn=Ee(([{gap:t,listRefresh:e,sizes:a,totalCount:r},{fixedFooterHeight:n,fixedHeaderHeight:i,footerHeight:o,headerHeight:l,scrollingInProgress:d,scrollTo:u,smoothScrollTargetReached:c,viewportHeight:m},{log:p}])=>{let h=Ce(),x=Ce(),g=q(0),y=null,b=null,w=null;function D(){y&&(y=(y(),null)),w&&(w=(w(),null)),b&&(b=(clearTimeout(b),null)),xe(d,!1)}return ne(U(h,ye(a,m,r,g,l,o,p),ye(t,i,n),ae(([[j,C,S,k,v,E,N,R],_,V,I])=>{let A=Mx(j),{align:T,behavior:P,offset:F}=A,O=k-1,z=Ax(A,C,O),B=Gn(z,C.offsetTree,_)+E;T==="end"?(B+=V+Qt(C.sizeTree,z)[1]-S+I,z===O&&(B+=N)):T==="center"?B+=(V+Qt(C.sizeTree,z)[1]-S+I)/2:B-=v,F&&(B+=F);let J=ee=>{D(),ee?(R("retrying to scroll to",{location:j},Ct.DEBUG),xe(h,j)):(xe(x,!0),R("list did not change, scroll successful",{},Ct.DEBUG))};if(D(),P==="smooth"){let ee=!1;w=Te(e,X=>{ee||(ee=X)}),y=Gt(c,()=>{J(ee)})}else y=Gt(U(e,Lj(150)),J);return b=setTimeout(()=>{D()},1200),xe(d,!0),R("scrolling from index to",{behavior:P,index:z,top:B},Ct.DEBUG),{behavior:P,top:B}})),u),{scrollTargetReached:x,scrollToIndex:h,topListHeight:g}},Ve(pa,Dt,Ua),{singleton:!0});function Lj(t){return e=>{let a=setTimeout(()=>{e(!1)},t);return r=>{r&&(e(!0),clearTimeout(a))}}}function Zd(t,e){t==0?e():requestAnimationFrame(()=>{Zd(t-1,e)})}function Kd(t,e){let a=e-1;return typeof t=="number"?t:t.index==="LAST"?a:t.index}var Jn=Ee(([{defaultItemSize:t,listRefresh:e,sizes:a},{scrollTop:r},{scrollTargetReached:n,scrollToIndex:i},{didMount:o}])=>{let l=q(!0),d=q(0),u=q(!0);return ne(U(o,ye(d),ue(([c,m])=>!!m),ua(!1)),l),ne(U(o,ye(d),ue(([c,m])=>!!m),ua(!1)),u),Te(U(nt(e,o),ye(l,a,t,u),ue(([[,c],m,{sizeTree:p},h,x])=>c&&(!_e(p)||Id(h))&&!m&&!x),ye(d)),([,c])=>{Gt(n,()=>{xe(u,!0)}),Zd(4,()=>{Gt(r,()=>{xe(l,!0)}),xe(i,c)})}),{initialItemFinalLocationReached:u,initialTopMostItemIndex:d,scrolledToInitialItem:l}},Ve(pa,Dt,Qn,Za),{singleton:!0});function Fx(t,e){return Math.abs(t-e)<1.01}var Xn="up",ei="down",$j="none",Bj={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Hj=0,ti=Ee(([{footerHeight:t,headerHeight:e,scrollBy:a,scrollContainerState:r,scrollTop:n,viewportHeight:i}])=>{let o=q(!1),l=q(!0),d=Ce(),u=Ce(),c=q(4),m=q(Hj),p=yt(U(Md(U(ce(n),vr(1),ua(!0)),U(ce(n),vr(1),ua(!1),yx(100))),ze()),!1),h=yt(U(Md(U(a,ua(!0)),U(a,ua(!1),yx(200))),ze()),!1);ne(U(nt(ce(n),ce(m)),ae(([w,D])=>w<=D),ze()),l),ne(U(l,ka(50)),u);let x=St(U(nt(r,ce(i),ce(e),ce(t),ce(c)),ca((w,[{scrollHeight:D,scrollTop:j},C,S,k,v])=>{let E=j+C-D>-v,N={scrollHeight:D,scrollTop:j,viewportHeight:C};if(E){let _,V;return j>w.state.scrollTop?(_="SCROLLED_DOWN",V=w.state.scrollTop-j):(_="SIZE_DECREASED",V=w.state.scrollTop-j||w.scrollTopDelta),{atBottom:!0,atBottomBecause:_,scrollTopDelta:V,state:N}}let R;return R=N.scrollHeight>w.state.scrollHeight?"SIZE_INCREASED":C<w.state.viewportHeight?"VIEWPORT_HEIGHT_DECREASING":j<w.state.scrollTop?"SCROLLING_UPWARDS":"NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:R,state:N}},Bj),ze((w,D)=>w&&w.atBottom===D.atBottom))),g=yt(U(r,ca((w,{scrollHeight:D,scrollTop:j,viewportHeight:C})=>{if(Fx(w.scrollHeight,D))return{changed:!1,jump:0,scrollHeight:D,scrollTop:j};{let S=D-(j+C)<1;return w.scrollTop!==j&&S?{changed:!0,jump:w.scrollTop-j,scrollHeight:D,scrollTop:j}:{changed:!0,jump:0,scrollHeight:D,scrollTop:j}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ue(w=>w.changed),ae(w=>w.jump)),0);ne(U(x,ae(w=>w.atBottom)),o),ne(U(o,ka(50)),d);let y=q(ei);ne(U(r,ae(({scrollTop:w})=>w),ze(),ca((w,D)=>Ze(h)?{direction:w.direction,prevScrollTop:D}:{direction:D<w.prevScrollTop?Xn:ei,prevScrollTop:D},{direction:ei,prevScrollTop:0}),ae(w=>w.direction)),y),ne(U(r,ka(50),ua($j)),y);let b=q(0);return ne(U(p,ue(w=>!w),ua(0)),b),ne(U(n,ka(100),ye(p),ue(([w,D])=>D),ca(([w,D],[j])=>[D,j],[0,0]),ae(([w,D])=>D-w)),b),{atBottomState:x,atBottomStateChange:d,atBottomThreshold:c,atTopStateChange:u,atTopThreshold:m,isAtBottom:o,isAtTop:l,isScrolling:p,lastJumpDueToItemResize:g,scrollDirection:y,scrollVelocity:b}},Ve(Dt)),ai="top",ri="bottom",Vx="none";function zx(t,e,a){return typeof t=="number"?a===Xn&&e===ai||a===ei&&e===ri?t:0:a===Xn?e===ai?t.main:t.reverse:e===ri?t.main:t.reverse}function Ox(t,e){return typeof t=="number"?t:t[e]??0}var Yd=Ee(([{deviation:t,fixedHeaderHeight:e,headerHeight:a,scrollTop:r,viewportHeight:n}])=>{let i=Ce(),o=q(0),l=q(0),d=q(0);return{increaseViewportBy:l,listBoundary:i,overscan:d,topListHeight:o,visibleRange:yt(U(nt(ce(r),ce(n),ce(a),ce(i,qn),ce(d),ce(o),ce(e),ce(t),ce(l)),ae(([u,c,m,[p,h],x,g,y,b,w])=>{let D=u-b,j=g+y,C=Math.max(m-D,0),S=Vx,k=Ox(w,ai),v=Ox(w,ri);return p-=b,p+=m+y,h+=m+y,h-=b,p>u+j-k&&(S=Xn),h<u-C+c+v&&(S=ei),S===Vx?null:[Math.max(D-m-zx(x,ai,S)-k,0),D-C-y+c+zx(x,ri,S)+v]}),ue(u=>u!=null),ze(qn)),[0,0])}},Ve(Dt),{singleton:!0});function Wj(t,e,a){if(_o(e)){let r=_x(t,e);return[{index:Qt(e.groupOffsetTree,r)[0],offset:0,size:0},{data:a==null?void 0:a[0],index:r,offset:0,size:0}]}return[{data:a==null?void 0:a[0],index:t,offset:0,size:0}]}var qd={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Ao(t,e,a,r,n,i){let{lastIndex:o,lastOffset:l,lastSize:d}=n,u=0,c=0;if(t.length>0){u=t[0].offset;let g=t[t.length-1];c=g.offset+g.size}let m=a-o,p=l+m*d+(m-1)*r,h=u,x=p-c;return{bottom:c,firstItemIndex:i,items:$x(t,n,i),offsetBottom:x,offsetTop:u,top:h,topItems:$x(e,n,i),topListHeight:e.reduce((g,y)=>y.size+g,0),totalCount:a}}function Lx(t,e,a,r,n,i){let o=0;if(a.groupIndices.length>0)for(let u of a.groupIndices){if(u-o>=t)break;o++}let l=t+o,d=Kd(e,l);return Ao(Array.from({length:l}).map((u,c)=>({data:i[c+d],index:c+d,offset:0,size:0})),[],l,n,a,r)}function $x(t,e,a){if(t.length===0)return[];if(!_o(e))return t.map(u=>({...u,index:u.index+a,originalIndex:u.index}));let r=t[0].index,n=t[t.length-1].index,i=[],o=qr(e.groupOffsetTree,r,n),l,d=0;for(let u of t){(!l||l.end<u.index)&&(l=o.shift(),d=e.groupIndices.indexOf(l.start));let c;c=u.index===l.start?{index:d,type:"group"}:{groupIndex:d,index:u.index-(d+1)+a},i.push({...c,data:u.data,offset:u.offset,originalIndex:u.index,size:u.size})}return i}function Bx(t,e){return t===void 0?0:typeof t=="number"?t:t[e]??0}var br=Ee(([{data:t,firstItemIndex:e,gap:a,sizes:r,totalCount:n},i,{listBoundary:o,topListHeight:l,visibleRange:d},{initialTopMostItemIndex:u,scrolledToInitialItem:c},{topListHeight:m},p,{didMount:h},{recalcInProgress:x}])=>{let g=q([]),y=q(0),b=Ce(),w=q(0);ne(i.topItemsIndexes,g);let D=yt(U(nt(h,x,ce(d,qn),ce(n),ce(r),ce(u),c,ce(g),ce(e),ce(a),ce(w),t),ue(([S,k,,v,,,,,,,,E])=>{let N=E&&E.length!==v;return S&&!k&&!N}),ae(([,,[S,k],v,E,N,R,_,V,I,A,T])=>{var $,ie;let P=E,{offsetTree:F,sizeTree:O}=P,z=Ze(y);if(v===0)return{...qd,totalCount:v};if(S===0&&k===0)return z===0?{...qd,totalCount:v}:Lx(z,N,E,V,I,T||[]);if(_e(O))return z>0?null:Ao(Wj(Kd(N,v),P,T),[],v,I,P,V);let B=[];if(_.length>0){let re=_[0],oe=_[_.length-1],ge=0;for(let he of qr(O,re,oe)){let me=he.value,De=Math.max(he.start,re),Le=Math.min(he.end,oe);for(let je=De;je<=Le;je++)B.push({data:T==null?void 0:T[je],index:je,offset:ge,size:me}),ge+=me}}if(!R)return Ao([],B,v,I,P,V);let J=_.length>0?_[_.length-1]+1:0,ee=Aj(F,S,k,J);if(ee.length===0)return null;let X=v-1,se=No([],re=>{for(let oe of ee){let ge=oe.value,he=ge.offset,me=oe.start,De=ge.size;if(ge.offset<S){me+=Math.floor((S-ge.offset+I)/(De+I));let je=me-oe.start;he+=je*De+je*I}me<J&&(he+=(J-me)*De,me=J);let Le=Math.min(oe.end,X);for(let je=me;je<=Le&&!(he>=k);je++)re.push({data:T==null?void 0:T[je],index:je,offset:he,size:De}),he+=De+I}}),pe=Bx(A,ai),G=Bx(A,ri);if(se.length>0&&(pe>0||G>0)){let re=se[0],oe=se[se.length-1];if(pe>0&&re.index>J){let ge=Math.min(pe,re.index-J),he=[],me=re.offset;for(let De=re.index-1;De>=re.index-ge;De--){let Le=(($=qr(O,De,De)[0])==null?void 0:$.value)??re.size;me-=Le+I,he.unshift({data:T==null?void 0:T[De],index:De,offset:me,size:Le})}se.unshift(...he)}if(G>0&&oe.index<X){let ge=Math.min(G,X-oe.index),he=oe.offset+oe.size+I;for(let me=oe.index+1;me<=oe.index+ge;me++){let De=((ie=qr(O,me,me)[0])==null?void 0:ie.value)??oe.size;se.push({data:T==null?void 0:T[me],index:me,offset:he,size:De}),he+=De+I}}}return Ao(se,B,v,I,P,V)}),ue(S=>S!==null),ze()),qd);ne(U(t,ue(Id),ae(S=>S==null?void 0:S.length)),n),ne(U(D,ae(S=>S.topListHeight)),m),ne(m,l),ne(U(D,ae(S=>[S.top,S.bottom])),o),ne(U(D,ae(S=>S.items)),b);let j=St(U(D,ue(({items:S})=>S.length>0),ye(n,t),ue(([{items:S},k])=>S[S.length-1].originalIndex===k-1),ae(([,S,k])=>[S-1,k]),ze(qn),ae(([S])=>S))),C=St(U(D,ka(200),ue(({items:S,topItems:k})=>S.length>0&&S[0].originalIndex===k.length),ae(({items:S})=>S[0].index),ze()));return{endReached:j,initialItemCount:y,itemsRendered:b,listState:D,minOverscanItemCount:w,rangeChanged:St(U(D,ue(({items:S})=>S.length>0),ae(({items:S})=>{let k=0,v=S.length-1;for(;S[k].type==="group"&&k<v;)k++;for(;S[v].type==="group"&&v>k;)v--;return{endIndex:S[v].index,startIndex:S[k].index}}),ze(Nx))),startReached:C,topItemsIndexes:g,...p}},Ve(pa,Px,Yd,Jn,Qn,ti,Za,Hd),{singleton:!0}),Hx=Ee(([{fixedFooterHeight:t,fixedHeaderHeight:e,footerHeight:a,headerHeight:r},{listState:n}])=>{let i=Ce(),o=yt(U(nt(a,t,r,e,n),ae(([l,d,u,c,m])=>l+d+u+c+m.offsetBottom+m.bottom)),0);return ne(ce(o),i),{totalListHeight:o,totalListHeightChanged:i}},Ve(Dt,br),{singleton:!0}),Uj=Ee(([{viewportHeight:t},{totalListHeight:e}])=>{let a=q(!1);return{alignToBottom:a,paddingTopAddition:yt(U(nt(a,t,e),ue(([r])=>r),ae(([,r,n])=>Math.max(0,r-n)),ka(0),ze()),0)}},Ve(Dt,Hx),{singleton:!0}),Wx=Ee(()=>({context:q(null)})),Zj=({itemBottom:t,itemTop:e,locationParams:{align:a,behavior:r,...n},viewportBottom:i,viewportTop:o})=>e<o?{...n,align:a??"start",behavior:r}:t>i?{...n,align:a??"end",behavior:r}:null,Ux=Ee(([{gap:t,sizes:e,totalCount:a},{fixedFooterHeight:r,fixedHeaderHeight:n,headerHeight:i,scrollingInProgress:o,scrollTop:l,viewportHeight:d},{scrollToIndex:u}])=>{let c=Ce();return ne(U(c,ye(e,d,a,i,n,r,l),ye(t),ae(([[m,p,h,x,g,y,b,w],D])=>{let{align:j,behavior:C,calculateViewLocation:S=Zj,done:k,...v}=m,E=Ax(m,p,x-1),N=Gn(E,p.offsetTree,D)+g+y,R=N+Qt(p.sizeTree,E)[1],_=w+y,V=w+h-b,I=S({itemBottom:R,itemTop:N,locationParams:{align:j,behavior:C,...v},viewportBottom:V,viewportTop:_});return I?k&&Gt(U(o,ue(A=>!A),vr(Ze(o)?1:2)),k):k==null||k(),I}),ue(m=>m!==null)),u),{scrollIntoView:c}},Ve(pa,Dt,Qn,br,Ua),{singleton:!0});function Zx(t){return t?t==="smooth"?"smooth":"auto":!1}var Kj=(t,e)=>typeof t=="function"?Zx(t(e)):e&&Zx(t),Yj=Ee(([{listRefresh:t,totalCount:e,fixedItemSize:a,data:r},{atBottomState:n,isAtBottom:i},{scrollToIndex:o},{scrolledToInitialItem:l},{didMount:d,propsReady:u},{log:c},{scrollingInProgress:m},{context:p},{scrollIntoView:h}])=>{let x=q(!1),g=Ce(),y=null;function b(C){xe(o,{align:"end",behavior:C,index:"LAST"})}Te(U(nt(U(ce(e),vr(1)),d),ye(ce(x),i,l,m),ae(([[C,S],k,v,E,N])=>{let R=S&&E,_="auto";return R&&(_=Kj(k,v||N),R&&(R=!!_)),{followOutputBehavior:_,shouldFollow:R,totalCount:C}}),ue(({shouldFollow:C})=>C)),({followOutputBehavior:C,totalCount:S})=>{y&&(y=(y(),null)),Ze(a)?requestAnimationFrame(()=>{Ze(c)("following output to ",{totalCount:S},Ct.DEBUG),b(C)}):y=Gt(t,()=>{Ze(c)("following output to ",{totalCount:S},Ct.DEBUG),b(C),y=null})});function w(C){let S=Gt(n,k=>{C&&!k.atBottom&&k.notAtBottomBecause==="SIZE_INCREASED"&&!y&&(Ze(c)("scrolling to bottom due to increased size",{},Ct.DEBUG),b("auto"))});setTimeout(S,100)}Te(U(nt(ce(x),e,u),ue(([C,,S])=>C&&S),ca(({value:C},[,S])=>({refreshed:C===S,value:S}),{refreshed:!1,value:0}),ue(({refreshed:C})=>C),ye(x,e)),([,C])=>{Ze(l)&&w(C!==!1)}),Te(g,()=>{w(Ze(x)!==!1)}),Te(nt(ce(x),n),([C,S])=>{C&&!S.atBottom&&S.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&b("auto")});let D=q(null),j=Ce();return ne(Md(U(ce(r),ae(C=>(C==null?void 0:C.length)??0)),U(ce(e))),j),Te(U(nt(U(j,vr(1)),d),ye(ce(D),l,m,p),ae(([[C,S],k,v,E,N])=>S&&v&&(k==null?void 0:k({context:N,totalCount:C,scrollingInProgress:E}))),ue(C=>!!C),ka(0)),C=>{y&&(y=(y(),null)),Ze(a)?requestAnimationFrame(()=>{Ze(c)("scrolling into view",{}),xe(h,C)}):y=Gt(t,()=>{Ze(c)("scrolling into view",{}),xe(h,C),y=null})}),{autoscrollToBottom:g,followOutput:x,scrollIntoViewOnChange:D}},Ve(pa,ti,Qn,Jn,Za,Ua,Dt,Wx,Ux)),qj=Ee(([{data:t,firstItemIndex:e,gap:a,sizes:r},{initialTopMostItemIndex:n},{initialItemCount:i,listState:o},{didMount:l}])=>(ne(U(l,ye(i),ue(([,d])=>d!==0),ye(n,r,e,a,t),ae(([[,d],u,c,m,p,h=[]])=>Lx(d,u,c,m,p,h))),o),{}),Ve(pa,Jn,br,Za),{singleton:!0}),Gj=Ee(([{didMount:t},{scrollTo:e},{listState:a}])=>{let r=q(0);return Te(U(t,ye(r),ue(([,n])=>n!==0),ae(([,n])=>({top:n}))),n=>{Gt(U(a,vr(1),ue(i=>i.items.length>1)),()=>{requestAnimationFrame(()=>{xe(e,n)})})}),{initialScrollTop:r}},Ve(Za,Dt,br),{singleton:!0}),Kx=Ee(([{scrollVelocity:t}])=>{let e=q(!1),a=Ce(),r=q(!1);return ne(U(t,ye(r,e,a),ue(([n,i])=>!!i),ae(([n,i,o,l])=>{let{enter:d,exit:u}=i;if(o){if(u(n,l))return!1}else if(d(n,l))return!0;return o}),ze()),e),Te(U(nt(e,t,a),ye(r)),([[n,i,o],l])=>{n&&l&&l.change&&l.change(i,o)}),{isSeeking:e,scrollSeekConfiguration:r,scrollSeekRangeChanged:a,scrollVelocity:t}},Ve(ti),{singleton:!0}),Gd=Ee(([{scrollContainerState:t,scrollTo:e}])=>{let a=Ce(),r=Ce(),n=Ce(),i=q(!1),o=q(void 0);return ne(U(nt(a,r),ae(([{scrollHeight:l,scrollTop:d,viewportHeight:u},{offsetTop:c}])=>({scrollHeight:l,scrollTop:Math.max(0,d-c),viewportHeight:u}))),t),ne(U(e,ye(r),ae(([l,{offsetTop:d}])=>({...l,top:l.top+d}))),n),{customScrollParent:o,useWindowScroll:i,windowScrollContainerState:a,windowScrollTo:n,windowViewportRect:r}},Ve(Dt)),Qj=Ee(([{sizeRanges:t,sizes:e},{headerHeight:a,scrollTop:r},{initialTopMostItemIndex:n},{didMount:i},{useWindowScroll:o,windowScrollContainerState:l,windowViewportRect:d}])=>{let u=Ce(),c=q(void 0),m=q(null),p=q(null);return ne(l,m),ne(d,p),Te(U(u,ye(e,r,o,m,p,a)),([h,x,g,y,b,w,D])=>{let j=Pj(x.sizeTree);y&&b!==null&&w!==null&&(g=b.scrollTop-w.offsetTop),g-=D,h({ranges:j,scrollTop:g})}),ne(U(c,ue(Id),ae(Jj)),n),ne(U(i,ye(c),ue(([,h])=>h!==void 0),ze(),ae(([,h])=>h.ranges)),t),{getState:u,restoreStateFrom:c}},Ve(pa,Dt,Jn,Za,Gd));function Jj(t){return{align:"start",index:0,offset:t.scrollTop}}var Xj=Ee(([{topItemsIndexes:t}])=>{let e=q(0);return ne(U(e,ue(a=>a>=0),ae(a=>Array.from({length:a}).map((r,n)=>n))),t),{topItemCount:e}},Ve(br));function Yx(t){let e=!1,a;return(()=>(e||(e=!0,a=t()),a))}var eC=Yx(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),qx=Ee(([{data:t,defaultItemSize:e,firstItemIndex:a,fixedItemSize:r,fixedGroupSize:n,gap:i,groupIndices:o,heightEstimates:l,itemSize:d,sizeRanges:u,sizes:c,statefulTotalCount:m,totalCount:p,trackItemSizes:h},{initialItemFinalLocationReached:x,initialTopMostItemIndex:g,scrolledToInitialItem:y},b,w,D,j,{scrollToIndex:C},S,{topItemCount:k},{groupCounts:v},E])=>{let{listState:N,minOverscanItemCount:R,topItemsIndexes:_,rangeChanged:V,...I}=j;return ne(V,E.scrollSeekRangeChanged),ne(U(E.windowViewportRect,ae(A=>A.visibleHeight)),b.viewportHeight),{data:t,defaultItemHeight:e,firstItemIndex:a,fixedItemHeight:r,fixedGroupHeight:n,gap:i,groupCounts:v,heightEstimates:l,initialItemFinalLocationReached:x,initialTopMostItemIndex:g,scrolledToInitialItem:y,sizeRanges:u,topItemCount:k,topItemsIndexes:_,totalCount:p,...D,groupIndices:o,itemSize:d,listState:N,minOverscanItemCount:R,scrollToIndex:C,statefulTotalCount:m,trackItemSizes:h,rangeChanged:V,...I,...E,...b,sizes:c,...w}},Ve(pa,Jn,Dt,Qj,Yj,br,Qn,Ee(([{deviation:t,scrollBy:e,scrollingInProgress:a,scrollTop:r},{isAtBottom:n,isScrolling:i,lastJumpDueToItemResize:o,scrollDirection:l},{listState:d},{beforeUnshiftWith:u,gap:c,shiftWithOffset:m,sizes:p},{log:h},{recalcInProgress:x}])=>{let g=St(U(d,ye(o),ca(([,b,w,D],[{bottom:j,items:C,offsetBottom:S,totalCount:k},v])=>{let E=j+S,N=0;return w===k&&b.length>0&&C.length>0&&(C[0].originalIndex===0&&b[0].originalIndex===0||(N=E-D,N!==0&&(N+=v))),[N,C,k,E]},[0,[],0,0]),ue(([b])=>b!==0),ye(r,l,a,n,h,x),ue(([,b,w,D,,,j])=>!j&&!D&&b!==0&&w===Xn),ae(([[b],,,,,w])=>(w("Upward scrolling compensation",{amount:b},Ct.DEBUG),b))));function y(b){b>0?(xe(e,{behavior:"auto",top:-b}),xe(t,0)):(xe(t,0),xe(e,{behavior:"auto",top:-b}))}return Te(U(g,ye(t,i)),([b,w,D])=>{D&&eC()?xe(t,w-b):y(-b)}),Te(U(nt(yt(i,!1),t,x),ue(([b,w,D])=>!b&&!D&&w!==0),ae(([b,w])=>w),ka(1)),y),ne(U(m,ae(b=>({top:-b}))),e),Te(U(u,ye(p,c),ae(([b,{groupIndices:w,lastSize:D,sizeTree:j},C])=>{function S(k){return k*(D+C)}if(w.length===0)return S(b);{let k=0,v=Yn(j,0),E=0,N=0;for(;E<b;){E++,k+=v;let R=w.length===N+1?1/0:w[N+1]-w[N]-1;E+R>b&&(k-=v,R=b-E+1),E+=R,k+=S(R),N++}return k}})),b=>{xe(t,b),requestAnimationFrame(()=>{xe(e,{top:b}),requestAnimationFrame(()=>{xe(t,0),xe(x,!1)})})}),{deviation:t}},Ve(Dt,ti,br,pa,Ua,Hd)),Xj,Px,Ee(([t,e,a,r,n,i,o,l,d,u,c])=>({...t,...e,...a,...r,...n,...i,...o,...l,...d,...u,...c}),Ve(Yd,qj,Za,Kx,Hx,Gj,Uj,Gd,Ux,Ua,Wx))));function tC(t,e){let a={},r={},n=0,i=t.length;for(;n<i;)r[t[n]]=1,n+=1;for(let o in e)Object.hasOwn(r,o)||(a[o]=e[o]);return a}var Io=typeof document<"u"?f.useLayoutEffect:f.useEffect;function Qd(t,e,a){let r=Object.keys(e.required||{}),n=Object.keys(e.optional||{}),i=Object.keys(e.methods||{}),o=Object.keys(e.events||{}),l=f.createContext({});function d(m,p){m.propsReady&&xe(m.propsReady,!1);for(let h of r){let x=m[e.required[h]];xe(x,p[h])}for(let h of n)if(h in p){let x=m[e.optional[h]];xe(x,p[h])}m.propsReady&&xe(m.propsReady,!0)}function u(m){return i.reduce((p,h)=>(p[h]=x=>{let g=m[e.methods[h]];xe(g,x)},p),{})}function c(m){return o.reduce((p,h)=>(p[h]=bj(m[e.events[h]]),p),{})}return{Component:f.forwardRef((m,p)=>{let{children:h,...x}=m,[g]=f.useState(()=>No(Dj(t),w=>{d(w,x)})),[y]=f.useState(vx(c,g));Io(()=>{for(let w of o)w in x&&Te(y[w],x[w]);return()=>{Object.values(y).map(Pd)}},[x,y,g]),Io(()=>{d(g,x)}),f.useImperativeHandle(p,xx(u(g)));let b=a;return(0,s.jsx)(l.Provider,{value:g,children:a?(0,s.jsx)(b,{...tC([...r,...n,...o],x),children:h}):h})}),useEmitter:(m,p)=>{let h=f.useContext(l)[m];Io(()=>Te(h,p),[p,h])},useEmitterValue:m=>{let p=f.useContext(l)[m],[h,x]=f.useState(vx(Ze,p));return Io(()=>Te(p,g=>{g!==h&&x(xx(g))}),[p,h]),h},usePublisher:m=>{let p=f.useContext(l);return f.useCallback(h=>{xe(p[m],h)},[p,m])}}}var Po=f.createContext(void 0),Gx=f.createContext(void 0),Qx=typeof document<"u"?f.useLayoutEffect:f.useEffect;function Jd(t){return"self"in t}function aC(t){return"body"in t}function Jx(t,e,a,r=Kr,n,i){let o=f.useRef(null),l=f.useRef(null),d=f.useRef(null),u=f.useCallback(p=>{let h,x,g,y=p.target;if(aC(y)||Jd(y)){let w=Jd(y)?y:y.defaultView;g=i?w.scrollX:w.scrollY,h=i?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight,x=i?w.innerWidth:w.innerHeight}else g=i?y.scrollLeft:y.scrollTop,h=i?y.scrollWidth:y.scrollHeight,x=i?y.offsetWidth:y.offsetHeight;let b=()=>{t({scrollHeight:h,scrollTop:Math.max(g,0),viewportHeight:x})};p.suppressFlushSync?b():hj.flushSync(b),l.current!==null&&(g===l.current||g<=0||g===h-x)&&(l.current=null,e(!0),d.current&&(d.current=(clearTimeout(d.current),null)))},[t,e,i]);f.useEffect(()=>{let p=n||o.current;return r(n||o.current),u({suppressFlushSync:!0,target:p}),p.addEventListener("scroll",u,{passive:!0}),()=>{r(null),p.removeEventListener("scroll",u)}},[o,u,a,r,n]);function c(p){let h=o.current;if(!h||(i?"offsetWidth"in h&&h.offsetWidth===0:"offsetHeight"in h&&h.offsetHeight===0))return;let x=p.behavior==="smooth",g,y,b;Jd(h)?(y=Math.max(Jt(h.document.documentElement,i?"width":"height"),i?h.document.documentElement.scrollWidth:h.document.documentElement.scrollHeight),g=i?h.innerWidth:h.innerHeight,b=i?window.scrollX:window.scrollY):(y=h[i?"scrollWidth":"scrollHeight"],g=Jt(h,i?"width":"height"),b=h[i?"scrollLeft":"scrollTop"]);let w=y-g;if(p.top=Math.ceil(Math.max(Math.min(w,p.top),0)),Fx(g,y)||p.top===b){t({scrollHeight:y,scrollTop:b,viewportHeight:g}),x&&e(!0);return}x?(l.current=p.top,d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,l.current=null,e(!0)},1e3)):l.current=null,i&&(p={behavior:p.behavior,left:p.top}),h.scrollTo(p)}function m(p){i&&(p={behavior:p.behavior,left:p.top}),o.current.scrollBy(p)}return{scrollByCallback:m,scrollerRef:o,scrollToCallback:c}}var Xd="-webkit-sticky",Xx="sticky",eu=Yx(()=>{if(typeof document>"u")return Xx;let t=document.createElement("div");return t.style.position=Xd,t.style.position===Xd?Xd:Xx});function tu(t){return t}var rC=Ee(([t,e])=>({...t,...e}),Ve(qx,Ee(()=>{let t=q(l=>`Item ${l}`),e=q(l=>`Group ${l}`),a=q({}),r=q(tu),n=q("div"),i=q(Kr),o=(l,d=null)=>yt(U(a,ae(u=>u[l]),ze()),d);return{components:a,computeItemKey:r,EmptyPlaceholder:o("EmptyPlaceholder"),FooterComponent:o("Footer"),GroupComponent:o("Group","div"),groupContent:e,HeaderComponent:o("Header"),HeaderFooterTag:n,ItemComponent:o("Item","div"),itemContent:t,ListComponent:o("List","div"),ScrollerComponent:o("Scroller","div"),scrollerRef:i,ScrollSeekPlaceholder:o("ScrollSeekPlaceholder"),TopItemListComponent:o("TopItemList")}}))),nC=({height:t})=>(0,s.jsx)("div",{style:{height:t}}),iC={overflowAnchor:"none",position:eu(),zIndex:1},e1={overflowAnchor:"none"},oC={...e1,display:"inline-block",height:"100%"},t1=f.memo(function({showTopList:t=!1}){let e=fe("listState"),a=Ot("sizeRanges"),r=fe("useWindowScroll"),n=fe("customScrollParent"),i=Ot("windowScrollContainerState"),o=Ot("scrollContainerState"),l=n||r?i:o,d=fe("itemContent"),u=fe("context"),c=fe("groupContent"),m=fe("trackItemSizes"),p=fe("itemSize"),h=fe("log"),x=Ot("gap"),g=fe("horizontalDirection"),{callbackRef:y}=wx(a,p,m,t?Kr:l,h,x,n,g,fe("skipAnimationFrameInResizeObserver")),[b,w]=f.useState(0);nu("deviation",I=>{b!==I&&w(I)});let D=fe("EmptyPlaceholder"),j=fe("ScrollSeekPlaceholder")||nC,C=fe("ListComponent"),S=fe("ItemComponent"),k=fe("GroupComponent"),v=fe("computeItemKey"),E=fe("isSeeking"),N=fe("groupIndices").length>0,R=fe("alignToBottom"),_=fe("initialItemFinalLocationReached"),V=t?{}:{boxSizing:"border-box",...g?{display:"inline-block",height:"100%",marginLeft:b===0?R?"auto":0:b,paddingLeft:e.offsetTop,paddingRight:e.offsetBottom,whiteSpace:"nowrap"}:{marginTop:b===0?R?"auto":0:b,paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},..._?{}:{visibility:"hidden"}};return!t&&e.totalCount===0&&D?(0,s.jsx)(D,{...Oe(D,u)}):(0,s.jsx)(C,{...Oe(C,u),"data-testid":t?"virtuoso-top-item-list":"virtuoso-item-list",ref:y,style:V,children:(t?e.topItems:e.items).map(I=>{let A=I.originalIndex,T=v(A+e.firstItemIndex,I.data,u);return E?(0,f.createElement)(j,{...Oe(j,u),height:I.size,index:I.index,key:T,type:I.type||"item",...I.type==="group"?{}:{groupIndex:I.groupIndex}}):I.type==="group"?(0,f.createElement)(k,{...Oe(k,u),"data-index":A,"data-item-index":I.index,"data-known-size":I.size,key:T,style:iC},c(I.index,u)):(0,f.createElement)(S,{...Oe(S,u),...a1(S,I.data),"data-index":A,"data-item-group-index":I.groupIndex,"data-item-index":I.index,"data-known-size":I.size,key:T,style:g?oC:e1},N?d(I.index,I.groupIndex,I.data,u):d(I.index,I.data,u))})})}),lC={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},sC={outline:"none",overflowX:"auto",position:"relative"},Gr=t=>({height:"100%",position:"absolute",top:0,width:"100%",...t?{display:"flex",flexDirection:"column"}:{}}),dC={position:eu(),top:0,width:"100%",zIndex:1};function Oe(t,e){if(typeof t!="string")return{context:e}}function a1(t,e){return{item:typeof t=="string"?void 0:e}}var uC=f.memo(function(){let t=fe("HeaderComponent"),e=Ot("headerHeight"),a=fe("HeaderFooterTag"),r=ma(f.useMemo(()=>i=>{e(Jt(i,"height"))},[e]),!0,fe("skipAnimationFrameInResizeObserver")),n=fe("context");return t?(0,s.jsx)(a,{ref:r,children:(0,s.jsx)(t,{...Oe(t,n)})}):null}),cC=f.memo(function(){let t=fe("FooterComponent"),e=Ot("footerHeight"),a=fe("HeaderFooterTag"),r=ma(f.useMemo(()=>i=>{e(Jt(i,"height"))},[e]),!0,fe("skipAnimationFrameInResizeObserver")),n=fe("context");return t?(0,s.jsx)(a,{ref:r,children:(0,s.jsx)(t,{...Oe(t,n)})}):null});function au({useEmitter:t,useEmitterValue:e,usePublisher:a}){return f.memo(function({children:r,style:n,context:i,...o}){let l=a("scrollContainerState"),d=e("ScrollerComponent"),u=a("smoothScrollTargetReached"),c=e("scrollerRef"),m=e("horizontalDirection")||!1,{scrollByCallback:p,scrollerRef:h,scrollToCallback:x}=Jx(l,u,d,c,void 0,m);return t("scrollTo",x),t("scrollBy",p),(0,s.jsx)(d,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:h,style:{...m?sC:lC,...n},tabIndex:0,...o,...Oe(d,i),children:r})})}function ru({useEmitter:t,useEmitterValue:e,usePublisher:a}){return f.memo(function({children:r,style:n,context:i,...o}){let l=a("windowScrollContainerState"),d=e("ScrollerComponent"),u=a("smoothScrollTargetReached"),c=e("totalListHeight"),m=e("deviation"),p=e("customScrollParent"),h=f.useRef(null),{scrollByCallback:x,scrollerRef:g,scrollToCallback:y}=Jx(l,u,d,e("scrollerRef"),p);return Qx(()=>{var b;return g.current=p||((b=h.current)==null?void 0:b.ownerDocument.defaultView),()=>{g.current=null}},[g,p]),t("windowScrollTo",y),t("scrollBy",x),(0,s.jsx)(d,{ref:h,"data-virtuoso-scroller":!0,style:{position:"relative",...n,...c===0?{}:{height:c+m}},...o,...Oe(d,i),children:r})})}var mC=({children:t})=>{let e=f.useContext(Po),a=Ot("viewportHeight"),r=Ot("fixedItemHeight"),n=fe("alignToBottom"),i=fe("horizontalDirection"),o=ma(f.useMemo(()=>Zn(a,l=>Jt(l,i?"width":"height")),[a,i]),!0,fe("skipAnimationFrameInResizeObserver"));return f.useEffect(()=>{e&&(a(e.viewportHeight),r(e.itemHeight))},[e,a,r]),(0,s.jsx)("div",{"data-viewport-type":"element",ref:o,style:Gr(n),children:t})},pC=({children:t})=>{let e=f.useContext(Po),a=Ot("windowViewportRect"),r=Ot("fixedItemHeight"),n=Vd(a,fe("customScrollParent"),fe("skipAnimationFrameInResizeObserver")),i=fe("alignToBottom");return f.useEffect(()=>{e&&(r(e.itemHeight),a({offsetTop:0,visibleHeight:e.viewportHeight,visibleWidth:100}))},[e,a,r]),(0,s.jsx)("div",{"data-viewport-type":"window",ref:n,style:Gr(i),children:t})},hC=({children:t})=>{let e=fe("TopItemListComponent")||"div",a=fe("headerHeight");return(0,s.jsx)(e,{style:{...dC,marginTop:`${a}px`},...Oe(e,fe("context")),children:t})},{Component:fC,useEmitter:nu,useEmitterValue:fe,usePublisher:Ot}=Qd(rC,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},f.memo(function(t){let e=fe("useWindowScroll"),a=fe("topItemsIndexes").length>0,r=fe("customScrollParent"),n=fe("context");return(0,s.jsxs)(r||e?xC:gC,{...t,context:n,children:[a&&(0,s.jsx)(hC,{children:(0,s.jsx)(t1,{showTopList:!0})}),(0,s.jsxs)(r||e?pC:mC,{children:[(0,s.jsx)(uC,{}),(0,s.jsx)(t1,{}),(0,s.jsx)(cC,{})]})]})})),gC=au({useEmitter:nu,useEmitterValue:fe,usePublisher:Ot}),xC=ru({useEmitter:nu,useEmitterValue:fe,usePublisher:Ot}),r1=fC,vC=Ee(([t,e])=>({...t,...e}),Ve(qx,Ee(()=>{let t=q(u=>(0,s.jsxs)("td",{children:["Item $",u]})),e=q(null),a=q(u=>(0,s.jsxs)("td",{colSpan:1e3,children:["Group ",u]})),r=q(null),n=q(null),i=q({}),o=q(tu),l=q(Kr),d=(u,c=null)=>yt(U(i,ae(m=>m[u]),ze()),c);return{components:i,computeItemKey:o,context:e,EmptyPlaceholder:d("EmptyPlaceholder"),FillerRow:d("FillerRow"),fixedFooterContent:n,fixedHeaderContent:r,itemContent:t,groupContent:a,ScrollerComponent:d("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder"),TableBodyComponent:d("TableBody","tbody"),TableComponent:d("Table","table"),TableFooterComponent:d("TableFoot","tfoot"),TableHeadComponent:d("TableHead","thead"),TableRowComponent:d("TableRow","tr"),GroupComponent:d("Group","tr")}}))),yC=({height:t})=>(0,s.jsx)("tr",{children:(0,s.jsx)("td",{style:{height:t}})}),bC=({height:t})=>(0,s.jsx)("tr",{children:(0,s.jsx)("td",{style:{border:0,height:t,padding:0}})}),wC={overflowAnchor:"none"},n1={position:eu(),zIndex:2,overflowAnchor:"none"},i1=f.memo(function({showTopList:t=!1}){let e=ve("listState"),a=ve("computeItemKey"),r=ve("firstItemIndex"),n=ve("context"),i=ve("isSeeking"),o=ve("fixedHeaderHeight"),l=ve("groupIndices").length>0,d=ve("itemContent"),u=ve("groupContent"),c=ve("ScrollSeekPlaceholder")||yC,m=ve("GroupComponent"),p=ve("TableRowComponent"),h=(t?e.topItems:[]).reduce((x,g,y)=>(y===0?x.push(g.size):x.push(x[y-1]+g.size),x),[]);return(0,s.jsx)(s.Fragment,{children:(t?e.topItems:e.items).map(x=>{let g=x.originalIndex,y=a(g+r,x.data,n),b=t?g===0?0:h[g-1]:0;return i?(0,f.createElement)(c,{...Oe(c,n),height:x.size,index:x.index,key:y,type:x.type||"item"}):x.type==="group"?(0,f.createElement)(m,{...Oe(m,n),"data-index":g,"data-item-index":x.index,"data-known-size":x.size,key:y,style:{...n1,top:o}},u(x.index,n)):(0,f.createElement)(p,{...Oe(p,n),...a1(p,x.data),"data-index":g,"data-item-index":x.index,"data-known-size":x.size,"data-item-group-index":x.groupIndex,key:y,style:t?{...n1,top:o+b}:wC},l?d(x.index,x.groupIndex,x.data,n):d(x.index,x.data,n))})})}),DC=f.memo(function(){let t=ve("listState"),e=ve("topItemsIndexes").length>0,a=Xt("sizeRanges"),r=ve("useWindowScroll"),n=ve("customScrollParent"),i=Xt("windowScrollContainerState"),o=Xt("scrollContainerState"),l=n||r?i:o,d=ve("trackItemSizes"),{callbackRef:u,ref:c}=wx(a,ve("itemSize"),d,l,ve("log"),void 0,n,!1,ve("skipAnimationFrameInResizeObserver")),[m,p]=f.useState(0);iu("deviation",v=>{m!==v&&(c.current.style.marginTop=`${v}px`,p(v))});let h=ve("EmptyPlaceholder"),x=ve("FillerRow")||bC,g=ve("TableBodyComponent"),y=ve("paddingTopAddition"),b=ve("statefulTotalCount"),w=ve("context");if(b===0&&h)return(0,s.jsx)(h,{...Oe(h,w)});let D=(e?t.topItems:[]).reduce((v,E)=>v+E.size,0),j=t.offsetTop+y+m-D,C=t.offsetBottom,S=j>0?(0,s.jsx)(x,{context:w,height:j},"padding-top"):null,k=C>0?(0,s.jsx)(x,{context:w,height:C},"padding-bottom"):null;return(0,s.jsxs)(g,{"data-testid":"virtuoso-item-list",ref:u,...Oe(g,w),children:[S,e&&(0,s.jsx)(i1,{showTopList:!0}),(0,s.jsx)(i1,{}),k]})}),jC=({children:t})=>{let e=f.useContext(Po),a=Xt("viewportHeight"),r=Xt("fixedItemHeight"),n=ma(f.useMemo(()=>Zn(a,i=>Jt(i,"height")),[a]),!0,ve("skipAnimationFrameInResizeObserver"));return f.useEffect(()=>{e&&(a(e.viewportHeight),r(e.itemHeight))},[e,a,r]),(0,s.jsx)("div",{"data-viewport-type":"element",ref:n,style:Gr(!1),children:t})},CC=({children:t})=>{let e=f.useContext(Po),a=Xt("windowViewportRect"),r=Xt("fixedItemHeight"),n=Vd(a,ve("customScrollParent"),ve("skipAnimationFrameInResizeObserver"));return f.useEffect(()=>{e&&(r(e.itemHeight),a({offsetTop:0,visibleHeight:e.viewportHeight,visibleWidth:100}))},[e,a,r]),(0,s.jsx)("div",{"data-viewport-type":"window",ref:n,style:Gr(!1),children:t})},{Component:UI,useEmitter:iu,useEmitterValue:ve,usePublisher:Xt}=Qd(vC,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",firstItemIndex:"firstItemIndex",itemContent:"itemContent",groupContent:"groupContent",fixedHeaderContent:"fixedHeaderContent",fixedFooterContent:"fixedFooterContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",topItemCount:"topItemCount",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",groupCounts:"groupCounts",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},f.memo(function(t){let e=ve("useWindowScroll"),a=ve("customScrollParent"),r=Xt("fixedHeaderHeight"),n=Xt("fixedFooterHeight"),i=ve("fixedHeaderContent"),o=ve("fixedFooterContent"),l=ve("context"),d=ma(f.useMemo(()=>Zn(r,b=>Jt(b,"height")),[r]),!0,ve("skipAnimationFrameInResizeObserver")),u=ma(f.useMemo(()=>Zn(n,b=>Jt(b,"height")),[n]),!0,ve("skipAnimationFrameInResizeObserver")),c=a||e?SC:kC,m=a||e?CC:jC,p=ve("TableComponent"),h=ve("TableHeadComponent"),x=ve("TableFooterComponent"),g=i?(0,s.jsx)(h,{ref:d,style:{position:"sticky",top:0,zIndex:2},...Oe(h,l),children:i()},"TableHead"):null,y=o?(0,s.jsx)(x,{ref:u,style:{bottom:0,position:"sticky",zIndex:1},...Oe(x,l),children:o()},"TableFoot"):null;return(0,s.jsx)(c,{...t,...Oe(c,l),children:(0,s.jsx)(m,{children:(0,s.jsxs)(p,{style:{borderSpacing:0,overflowAnchor:"none"},...Oe(p,l),children:[g,(0,s.jsx)(DC,{},"TableBody"),y]})})})})),kC=au({useEmitter:iu,useEmitterValue:ve,usePublisher:Xt}),SC=ru({useEmitter:iu,useEmitterValue:ve,usePublisher:Xt}),o1={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},EC={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:l1,floor:Mo,max:ni,min:ou,round:s1}=Math;function d1(t,e,a){return Array.from({length:e-t+1}).map((r,n)=>({data:a===null?null:a[n+t],index:n+t}))}function RC(t){return{...EC,items:t}}function Fo(t,e){return t&&t.width===e.width&&t.height===e.height}function NC(t,e){return t&&t.column===e.column&&t.row===e.row}var TC=Ee(([{increaseViewportBy:t,listBoundary:e,overscan:a,visibleRange:r},{footerHeight:n,headerHeight:i,scrollBy:o,scrollContainerState:l,scrollTo:d,scrollTop:u,smoothScrollTargetReached:c,viewportHeight:m},p,h,{didMount:x,propsReady:g},{customScrollParent:y,useWindowScroll:b,windowScrollContainerState:w,windowScrollTo:D,windowViewportRect:j},C])=>{let S=q(0),k=q(0),v=q(o1),E=q({height:0,width:0}),N=q({height:0,width:0}),R=Ce(),_=Ce(),V=q(0),I=q(null),A=q({column:0,row:0}),T=Ce(),P=Ce(),F=q(!1),O=q(0),z=q(!0),B=q(!1),J=q(!1);Te(U(x,ye(O),ue(([$,ie])=>!!ie)),()=>{xe(z,!1)}),Te(U(nt(x,z,N,E,O,B),ue(([$,ie,re,oe,,ge])=>$&&!ie&&re.height!==0&&oe.height!==0&&!ge)),([,,,,$])=>{xe(B,!0),Zd(1,()=>{xe(R,$)}),Gt(U(u),()=>{xe(e,[0,0]),xe(z,!0)})}),ne(U(P,ue($=>$!=null&&$.scrollTop>0),ua(0)),k),Te(U(x,ye(P),ue(([,$])=>$!=null)),([,$])=>{$&&(xe(E,$.viewport),xe(N,$.item),xe(A,$.gap),$.scrollTop>0&&(xe(F,!0),Gt(U(u,vr(1)),ie=>{xe(F,!1)}),xe(d,{top:$.scrollTop})))}),ne(U(E,ae(({height:$})=>$)),m),ne(U(nt(ce(E,Fo),ce(N,Fo),ce(A,($,ie)=>$&&$.column===ie.column&&$.row===ie.row),ce(u)),ae(([$,ie,re,oe])=>({gap:re,item:ie,scrollTop:oe,viewport:$}))),T),ne(U(nt(ce(S),r,ce(A,NC),ce(N,Fo),ce(E,Fo),ce(I),ce(k),ce(F),ce(z),ce(O)),ue(([,,,,,,,$])=>!$),ae(([$,[ie,re],oe,ge,he,me,De,,Le,je])=>{let{column:Ye,row:Ne}=oe,{height:Ae,width:pt}=ge,{width:ot}=he;if(De===0&&($===0||ot===0))return o1;if(pt===0){let pl=Kd(je,$);return RC(d1(pl,pl+Math.max(De-1,0),me))}let Bt=u1(ot,pt,Ye),ta,Ht;Le?ie===0&&re===0&&De>0?(ta=0,Ht=De-1):(ta=Bt*Mo((ie+Ne)/(Ae+Ne)),Ht=Bt*l1((re+Ne)/(Ae+Ne))-1,Ht=ou($-1,ni(Ht,Bt-1)),ta=ou(Ht,ni(0,ta))):(ta=0,Ht=-1);let qa=d1(ta,Ht,me),{bottom:Cr,top:kr}=c1(he,oe,ge,qa),Wt=l1($/Bt);return{bottom:Cr,itemHeight:Ae,items:qa,itemWidth:pt,offsetBottom:Wt*Ae+(Wt-1)*Ne-Cr,offsetTop:kr,top:kr}})),v),ne(U(I,ue($=>$!==null),ae($=>$.length)),S),ne(U(nt(E,N,v,A),ue(([$,ie,{items:re}])=>re.length>0&&ie.height!==0&&$.height!==0),ae(([$,ie,{items:re},oe])=>{let{bottom:ge,top:he}=c1($,oe,ie,re);return[he,ge]}),ze(qn)),e);let ee=q(!1);ne(U(u,ye(ee),ae(([$,ie])=>ie||$!==0)),ee);let X=St(U(nt(v,S),ue(([{items:$}])=>$.length>0),ye(ee),ue(([[$,ie],re])=>{let oe=$.items[$.items.length-1].index===ie-1;return(re||$.bottom>0&&$.itemHeight>0&&$.offsetBottom===0&&$.items.length===ie)&&oe}),ae(([[,$]])=>$-1),ze())),se=St(U(ce(v),ue(({items:$})=>$.length>0&&$[0].index===0),ua(0),ze())),pe=St(U(ce(v),ye(F),ue(([{items:$},ie])=>$.length>0&&!ie),ae(([{items:$}])=>({endIndex:$[$.length-1].index,startIndex:$[0].index})),ze(Nx),ka(0)));ne(pe,h.scrollSeekRangeChanged),ne(U(R,ye(E,N,S,A),ae(([$,ie,re,oe,ge])=>{let he=Mx($),{align:me,behavior:De,offset:Le}=he,je=he.index;je==="LAST"&&(je=oe-1),je=ni(0,je,ou(oe-1,je));let Ye=lu(ie,ge,re,je);return me==="end"?Ye=s1(Ye-ie.height+re.height):me==="center"&&(Ye=s1(Ye-ie.height/2+re.height/2)),Le&&(Ye+=Le),{behavior:De,top:Ye}})),d);let G=yt(U(v,ae($=>$.offsetBottom+$.bottom)),0);return ne(U(j,ae($=>({height:$.visibleHeight,width:$.visibleWidth}))),E),{customScrollParent:y,data:I,deviation:V,footerHeight:n,gap:A,headerHeight:i,increaseViewportBy:t,initialItemCount:k,itemDimensions:N,overscan:a,restoreStateFrom:P,scrollBy:o,scrollContainerState:l,scrollHeight:_,scrollTo:d,scrollToIndex:R,scrollTop:u,smoothScrollTargetReached:c,totalCount:S,useWindowScroll:b,viewportDimensions:E,windowScrollContainerState:w,windowScrollTo:D,windowViewportRect:j,...h,gridState:v,horizontalDirection:J,initialTopMostItemIndex:O,totalListHeight:G,...p,endReached:X,propsReady:g,rangeChanged:pe,startReached:se,stateChanged:T,stateRestoreInProgress:F,...C}},Ve(Yd,Dt,ti,Kx,Za,Gd,Ua));function u1(t,e,a){return ni(1,Mo((t+a)/(Mo(e)+a)))}function c1(t,e,a,r){let{height:n}=a;if(n===void 0||r.length===0)return{bottom:0,top:0};let i=lu(t,e,a,r[0].index);return{bottom:lu(t,e,a,r[r.length-1].index)+n,top:i}}function lu(t,e,a,r){let n=Mo(r/u1(t.width,a.width,e.column)),i=n*a.height+ni(0,n-1)*e.row;return i>0?i+e.row:i}var _C=Ee(([t,e])=>({...t,...e}),Ve(TC,Ee(()=>{let t=q(m=>`Item ${m}`),e=q({}),a=q(null),r=q("virtuoso-grid-item"),n=q("virtuoso-grid-list"),i=q(tu),o=q("div"),l=q(Kr),d=(m,p=null)=>yt(U(e,ae(h=>h[m]),ze()),p),u=q(!1),c=q(!1);return ne(ce(c),u),{components:e,computeItemKey:i,context:a,FooterComponent:d("Footer"),HeaderComponent:d("Header"),headerFooterTag:o,itemClassName:r,ItemComponent:d("Item","div"),itemContent:t,listClassName:n,ListComponent:d("List","div"),readyStateChanged:u,reportReadyState:c,ScrollerComponent:d("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder","div")}}))),AC=f.memo(function(){let t=He("gridState"),e=He("listClassName"),a=He("itemClassName"),r=He("itemContent"),n=He("computeItemKey"),i=He("isSeeking"),o=Lt("scrollHeight"),l=He("ItemComponent"),d=He("ListComponent"),u=He("ScrollSeekPlaceholder"),c=He("context"),m=Lt("itemDimensions"),p=Lt("gap"),h=He("log"),x=He("stateRestoreInProgress"),g=Lt("reportReadyState"),y=ma(f.useMemo(()=>b=>{let w=b.parentElement.parentElement.scrollHeight;o(w);let D=b.firstChild;if(D){let{height:j,width:C}=D.getBoundingClientRect();m({height:j,width:C})}p({column:p1("column-gap",getComputedStyle(b).columnGap,h),row:p1("row-gap",getComputedStyle(b).rowGap,h)})},[o,m,p,h]),!0,!1);return Qx(()=>{t.itemHeight>0&&t.itemWidth>0&&g(!0)},[t]),x?null:(0,s.jsx)(d,{className:e,ref:y,...Oe(d,c),"data-testid":"virtuoso-item-list",style:{paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},children:t.items.map(b=>{let w=n(b.index,b.data,c);return i?(0,s.jsx)(u,{...Oe(u,c),height:t.itemHeight,index:b.index,width:t.itemWidth},w):(0,f.createElement)(l,{...Oe(l,c),className:a,"data-index":b.index,key:w},r(b.index,b.data,c))})})}),IC=f.memo(function(){let t=He("HeaderComponent"),e=Lt("headerHeight"),a=He("headerFooterTag"),r=ma(f.useMemo(()=>i=>{e(Jt(i,"height"))},[e]),!0,!1),n=He("context");return t?(0,s.jsx)(a,{ref:r,children:(0,s.jsx)(t,{...Oe(t,n)})}):null}),PC=f.memo(function(){let t=He("FooterComponent"),e=Lt("footerHeight"),a=He("headerFooterTag"),r=ma(f.useMemo(()=>i=>{e(Jt(i,"height"))},[e]),!0,!1),n=He("context");return t?(0,s.jsx)(a,{ref:r,children:(0,s.jsx)(t,{...Oe(t,n)})}):null}),MC=({children:t})=>{let e=f.useContext(Gx),a=Lt("itemDimensions"),r=Lt("viewportDimensions"),n=ma(f.useMemo(()=>i=>{r(i.getBoundingClientRect())},[r]),!0,!1);return f.useEffect(()=>{e&&(r({height:e.viewportHeight,width:e.viewportWidth}),a({height:e.itemHeight,width:e.itemWidth}))},[e,r,a]),(0,s.jsx)("div",{ref:n,style:Gr(!1),children:t})},FC=({children:t})=>{let e=f.useContext(Gx),a=Lt("windowViewportRect"),r=Lt("itemDimensions"),n=Vd(a,He("customScrollParent"),!1);return f.useEffect(()=>{e&&(r({height:e.itemHeight,width:e.itemWidth}),a({offsetTop:0,visibleHeight:e.viewportHeight,visibleWidth:e.viewportWidth}))},[e,a,r]),(0,s.jsx)("div",{ref:n,style:Gr(!1),children:t})},{Component:ZI,useEmitter:m1,useEmitterValue:He,usePublisher:Lt}=Qd(_C,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},f.memo(function({...t}){let e=He("useWindowScroll"),a=He("customScrollParent"),r=a||e?zC:VC,n=a||e?FC:MC,i=He("context");return(0,s.jsx)(r,{...t,...Oe(r,i),children:(0,s.jsxs)(n,{children:[(0,s.jsx)(IC,{}),(0,s.jsx)(AC,{}),(0,s.jsx)(PC,{})]})})})),VC=au({useEmitter:m1,useEmitterValue:He,usePublisher:Lt}),zC=ru({useEmitter:m1,useEmitterValue:He,usePublisher:Lt});function p1(t,e,a){return e!=="normal"&&!(e!=null&&e.endsWith("px"))&&a(`${t} was not resolved to pixel value correctly`,e,Ct.WARN),e==="normal"?0:parseInt(e??"0",10)}function h1(t,e){return e.split(/\s+/).every(a=>t.toLowerCase().includes(a.toLowerCase()))?1:0}var OC=te(),LC=class{constructor(){Z(this,"tagName","marimo-multiselect");Z(this,"validator",L({initialValue:Q(M()),label:M().nullable(),options:Q(M()),fullWidth:W().default(!1),maxSelections:H().optional()}))}render(t){return(0,s.jsx)(f1,{...t.data,value:t.value,setValue:t.setValue})}},su="__select_all__",du="__deselect_all__";const f1=t=>{let e=(0,OC.c)(45),{options:a,label:r,value:n,setValue:i,fullWidth:o,maxSelections:l}=t,d=(0,f.useId)(),[u,c]=(0,f.useState)(""),m;e:{if(!u){m=a;break e}let N;if(e[0]!==a||e[1]!==u){let R;e[3]===u?R=e[4]:(R=_=>h1(_,u)===1,e[3]=u,e[4]=R),N=a.filter(R),e[0]=a,e[1]=u,e[2]=N}else N=e[2];m=N}let p=m,h;e[5]!==l||e[6]!==i?(h=N=>{if(!N||N.length===0){i([]);return}if(N=N.filter($C),l===1){i([N[N.length-1]]);return}l!=null&&N.length>l&&(N=N.slice(-l)),i(N)},e[5]=l,e[6]=i,e[7]=h):h=e[7];let x=h,g;e[8]!==a||e[9]!==i?(g=()=>{i(a)},e[8]=a,e[9]=i,e[10]=g):g=e[10];let y=g,b;e[11]===i?b=e[12]:(b=()=>{i([])},e[11]=i,e[12]=b);let w=b,D;if(e[13]!==w||e[14]!==y||e[15]!==l||e[16]!==a.length||e[17]!==n){D=[];let N=a.length>0&&n.length<a.length,R=a.length>0&&n.length>0;if(a.length>2&&l==null){let _=!N,V;e[19]!==y||e[20]!==_?(V=(0,s.jsx)(Ta,{value:su,onSelect:y,disabled:_,children:"Select all"},su),e[19]=y,e[20]=_,e[21]=V):V=e[21],D.push(V)}if(a.length>2){let _=!R,V=l===1?"Deselect":"Deselect all",I;e[22]!==w||e[23]!==_||e[24]!==V?(I=(0,s.jsx)(Ta,{value:du,onSelect:w,disabled:_,children:V},du),e[22]=w,e[23]=_,e[24]=V,e[25]=I):I=e[25];let A;e[26]===Symbol.for("react.memo_cache_sentinel")?(A=(0,s.jsx)(sI,{},"_separator"),e[26]=A):A=e[26],D.push(I,A)}e[13]=w,e[14]=y,e[15]=l,e[16]=a.length,e[17]=n,e[18]=D}else D=e[18];let j;e[27]!==D||e[28]!==p?(j=()=>{if(p.length>200)return(0,s.jsx)(r1,{style:{height:"200px"},totalCount:p.length,overscan:50,itemContent:R=>{let _=(0,s.jsx)(Ta,{value:p[R],children:p[R]},p[R]);return R===0?(0,s.jsxs)(s.Fragment,{children:[D,_]}):_}});let N=p.map(BC);return(0,s.jsxs)(s.Fragment,{children:[D,N]})},e[27]=D,e[28]=p,e[29]=j):j=e[29];let C=j,S;e[30]===o?S=e[31]:(S=Y({"w-full":o}),e[30]=o,e[31]=S);let k;e[32]===C?k=e[33]:(k=C(),e[32]=C,e[33]=k);let v;e[34]!==x||e[35]!==u||e[36]!==S||e[37]!==k||e[38]!==n?(v=(0,s.jsx)(El,{displayValue:HC,placeholder:"Select...",multiple:!0,className:S,value:n,onValueChange:x,shouldFilter:!1,search:u,onSearchChange:c,children:k}),e[34]=x,e[35]=u,e[36]=S,e[37]=k,e[38]=n,e[39]=v):v=e[39];let E;return e[40]!==o||e[41]!==d||e[42]!==r||e[43]!==v?(E=(0,s.jsx)(et,{label:r,id:d,fullWidth:o,children:v}),e[40]=o,e[41]=d,e[42]=r,e[43]=v,e[44]=E):E=e[44],E};function $C(t){return t!==su&&t!==du}function BC(t){return(0,s.jsx)(Ta,{value:t,children:t},t)}function HC(t){return t}var Sa=te();const ea=t=>{let e=(0,Sa.c)(5),{text:a,tooltip:r}=t,n;e[0]===r?n=e[1]:(n=r&&(0,s.jsx)(_a,{content:r,children:(0,s.jsx)(vl,{className:"w-3 h-3 mt-0.5"})}),e[0]=r,e[1]=n);let i;return e[2]!==n||e[3]!==a?(i=(0,s.jsxs)("h2",{className:"font-semibold my-0 flex items-center gap-1",children:[a,n]}),e[2]=n,e[3]=a,e[4]=i):i=e[4],i},g1=t=>{let e=(0,Sa.c)(5),{children:a,className:r}=t,n;e[0]===r?n=e[1]:(n=Y("flex flex-col gap-2",r),e[0]=r,e[1]=n);let i;return e[2]!==a||e[3]!==n?(i=(0,s.jsx)("div",{className:n,children:a}),e[2]=a,e[3]=n,e[4]=i):i=e[4],i},uu=t=>{let e=(0,Sa.c)(4),{className:a}=t,r;e[0]===a?r=e[1]:(r=Y("my-1",a),e[0]=a,e[1]=r);let n;return e[2]===r?n=e[3]:(n=(0,s.jsx)("hr",{className:r}),e[2]=r,e[3]=n),n},Vo=t=>{let e=(0,Sa.c)(5),{children:a,className:r}=t,n;e[0]===r?n=e[1]:(n=Y("flex flex-col gap-1.5",r),e[0]=r,e[1]=n);let i;return e[2]!==a||e[3]!==n?(i=(0,s.jsx)("section",{className:n,children:a}),e[2]=a,e[3]=n,e[4]=i):i=e[4],i},x1=t=>{let e=(0,Sa.c)(7),{Icon:a,text:r}=t,n;e[0]===a?n=e[1]:(n=(0,s.jsx)(a,{className:"w-3 h-3 mr-2"}),e[0]=a,e[1]=n);let i;e[2]===r?i=e[3]:(i=(0,s.jsx)("span",{children:r}),e[2]=r,e[3]=i);let o;return e[4]!==n||e[5]!==i?(o=(0,s.jsxs)("div",{className:"flex items-center",children:[n,i]}),e[4]=n,e[5]=i,e[6]=o):o=e[6],o},Qr=t=>{let e=(0,Sa.c)(5),{children:a,className:r}=t,n;e[0]===r?n=e[1]:(n=Y("py-1",r),e[0]=r,e[1]=n);let i;return e[2]!==a||e[3]!==n?(i=(0,s.jsx)(Vv,{className:n,children:a}),e[2]=a,e[3]=n,e[4]=i):i=e[4],i},Jr=t=>{let e=(0,Sa.c)(3),{children:a,value:r}=t,n;return e[0]!==a||e[1]!==r?(n=(0,s.jsx)(zv,{value:r,className:"border-none",children:a}),e[0]=a,e[1]=r,e[2]=n):n=e[2],n},Xr=t=>{let e=(0,Sa.c)(5),{children:a,wrapperClassName:r}=t,n;e[0]===r?n=e[1]:(n=Y("pb-2 flex flex-col gap-2",r),e[0]=r,e[1]=n);let i;return e[2]!==a||e[3]!==n?(i=(0,s.jsx)(Ov,{wrapperClassName:n,children:a}),e[2]=a,e[3]=n,e[4]=i):i=e[4],i},WC=t=>{let e=(0,Sa.c)(4),{code:a,insertNewCell:r,language:n}=t,i;return e[0]!==a||e[1]!==r||e[2]!==n?(i=(0,s.jsx)(Rc,{minHeight:"330px",maxHeight:"330px",code:a,language:n,showHideCode:!1,showCopyCode:!1,insertNewCell:r}),e[0]=a,e[1]=r,e[2]=n,e[3]=i):i=e[3],i};var Rt=te(),zo="__clear__";const Oo=t=>{let e=(0,Rt.c)(23),{fieldName:a,columns:r,onValueChange:n,includeCountField:i}=t,o=i===void 0?!0:i,l=lt(),d;e[0]===a?d=e[1]:(d=a.replace(".field",".type"),e[0]=a,e[1]=d);let u=d,c;e[2]===a?c=e[3]:(c=a.replace(".field",".selectedDataType"),e[2]=a,e[3]=c);let m=c,p;e[4]!==a||e[5]!==l||e[6]!==n||e[7]!==m||e[8]!==u?(p=()=>{l.setValue(a,""),l.setValue(u,""),l.setValue(m,""),n==null||n("",void 0)},e[4]=a,e[5]=l,e[6]=n,e[7]=m,e[8]=u,e[9]=p):p=e[9];let h=p,x;e[10]!==h||e[11]!==r||e[12]!==a||e[13]!==l||e[14]!==o||e[15]!==n||e[16]!==m||e[17]!==u?(x=y=>{let{field:b}=y;return(0,s.jsx)(ht,{children:(0,s.jsx)(gt,{children:(0,s.jsxs)(ar,{...b,onValueChange:w=>{if(w===zo){h();return}if(w==="__count__"){l.setValue(a,w),l.setValue(u,""),l.setValue(m,""),n==null||n(a,"number");return}let D=r.find(j=>j.name===w);D&&(l.setValue(a,w),l.setValue(u,D.type),l.setValue(m,Sc(D.type)),n==null||n(a,D.type))},value:b.value??"",children:[(0,s.jsx)(Er,{className:"w-40 truncate",onClear:b.value?h:void 0,children:(0,s.jsx)(er,{placeholder:"Select column"})}),(0,s.jsxs)(tr,{children:[b.value&&(0,s.jsx)(Zt,{value:zo,children:(0,s.jsxs)("div",{className:"flex items-center truncate",children:[(0,s.jsx)(ki,{className:"w-3 h-3 mr-2"}),"Clear"]})}),o&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Zt,{value:"__count__",children:(0,s.jsxs)("div",{className:"flex items-center truncate",children:[(0,s.jsx)(Ll,{className:"w-3 h-3 mr-2"}),"Count of records"]})},"__count__"),(0,s.jsx)(Cl,{})]}),r.map(KC)]})]})})})},e[10]=h,e[11]=r,e[12]=a,e[13]=l,e[14]=o,e[15]=n,e[16]=m,e[17]=u,e[18]=x):x=e[18];let g;return e[19]!==a||e[20]!==l.control||e[21]!==x?(g=(0,s.jsx)(mt,{control:l.control,name:a,render:x}),e[19]=a,e[20]=l.control,e[21]=x,e[22]=g):g=e[22],g},cu=t=>{let e=(0,Rt.c)(8),{fieldName:a,label:r,options:n,defaultValue:i}=t,o=lt(),l;e[0]!==i||e[1]!==r||e[2]!==n?(l=u=>{let{field:c}=u;return(0,s.jsxs)(ht,{className:"flex flex-row items-center justify-between",children:[(0,s.jsx)(wt,{children:r}),(0,s.jsx)(gt,{children:(0,s.jsxs)(ar,{...c,onValueChange:c.onChange,value:c.value??i,children:[(0,s.jsx)(Er,{className:"truncate",children:(0,s.jsx)(er,{placeholder:"Select an option"})}),(0,s.jsx)(tr,{children:(0,s.jsx)(hn,{children:n.filter(YC).map(qC)})})]})})]})},e[0]=i,e[1]=r,e[2]=n,e[3]=l):l=e[3];let d;return e[4]!==a||e[5]!==o.control||e[6]!==l?(d=(0,s.jsx)(mt,{control:o.control,name:a,render:l}),e[4]=a,e[5]=o.control,e[6]=l,e[7]=d):d=e[7],d},mu=t=>{let e=(0,Rt.c)(6),{fieldName:a,label:r}=t,n=lt(),i;e[0]===r?i=e[1]:(i=l=>{let{field:d}=l;return(0,s.jsxs)(ht,{className:"flex flex-row gap-2 items-center",children:[(0,s.jsx)(wt,{children:r}),(0,s.jsx)(gt,{children:(0,s.jsx)(Pc,{...d,value:d.value??"",onValueChange:d.onChange,className:"text-xs h-5"})})]})},e[0]=r,e[1]=i);let o;return e[2]!==a||e[3]!==n.control||e[4]!==i?(o=(0,s.jsx)(mt,{control:n.control,name:a,render:i}),e[2]=a,e[3]=n.control,e[4]=i,e[5]=o):o=e[5],o},en=t=>{let e=(0,Rt.c)(17),a,r,n,i,o,l;e[0]===t?(a=e[1],r=e[2],n=e[3],i=e[4],o=e[5],l=e[6]):({fieldName:r,label:o,className:a,inputClassName:n,isDisabled:i,...l}=t,e[0]=t,e[1]=a,e[2]=r,e[3]=n,e[4]=i,e[5]=o,e[6]=l);let d=lt(),u;e[7]!==a||e[8]!==n||e[9]!==i||e[10]!==o||e[11]!==l?(u=m=>{let{field:p}=m;return(0,s.jsxs)(ht,{className:Y("flex flex-row items-center gap-2",a),children:[(0,s.jsx)(wt,{className:"whitespace-nowrap",children:o}),(0,s.jsx)(gt,{children:(0,s.jsx)(p6,{...p,value:p.value,onValueChange:p.onChange,"aria-label":o,className:Y("w-16",n),isDisabled:i,minValue:0,...l})})]})},e[7]=a,e[8]=n,e[9]=i,e[10]=o,e[11]=l,e[12]=u):u=e[12];let c;return e[13]!==r||e[14]!==d.control||e[15]!==u?(c=(0,s.jsx)(mt,{control:d.control,name:r,render:u}),e[13]=r,e[14]=d.control,e[15]=u,e[16]=c):c=e[16],c},tn=t=>{let e=(0,Rt.c)(8),{fieldName:a,label:r,className:n,defaultValue:i}=t,o=lt(),l;e[0]!==n||e[1]!==i||e[2]!==r?(l=u=>{let{field:c}=u;return(0,s.jsxs)(ht,{className:Y("flex flex-row items-center gap-2",n),children:[(0,s.jsx)(wt,{children:r}),(0,s.jsx)(gt,{children:(0,s.jsx)(xl,{checked:c.value??i??!1,onCheckedChange:c.onChange,className:"w-4 h-4"})})]})},e[0]=n,e[1]=i,e[2]=r,e[3]=l):l=e[3];let d;return e[4]!==a||e[5]!==o.control||e[6]!==l?(d=(0,s.jsx)(mt,{control:o.control,name:a,render:l}),e[4]=a,e[5]=o.control,e[6]=l,e[7]=d):d=e[7],d},v1=t=>{let e=(0,Rt.c)(12),{fieldName:a,label:r,defaultValue:n,start:i,stop:o,step:l,className:d}=t,u=lt(),c;e[0]!==d||e[1]!==n||e[2]!==a||e[3]!==r||e[4]!==i||e[5]!==l||e[6]!==o?(c=p=>{let{field:h}=p,x=h.value??n,g=Number(x),y=b=>{typeof b=="string"&&(b=Number(b)),h.onChange(b)};return(0,s.jsxs)(ht,{className:Y("flex flex-row items-center gap-2 w-1/2",d),children:[(0,s.jsx)(wt,{children:r}),(0,s.jsx)(gt,{children:(0,s.jsx)(Ad,{...h,id:a,className:"relative flex items-center select-none",value:[g],min:i,max:o,step:l,onValueChange:b=>{let[w]=b;y(w)},onValueCommit:b=>{let[w]=b;y(w)},valueMap:GC})})]})},e[0]=d,e[1]=n,e[2]=a,e[3]=r,e[4]=i,e[5]=l,e[6]=o,e[7]=c):c=e[7];let m;return e[8]!==a||e[9]!==u.control||e[10]!==c?(m=(0,s.jsx)(mt,{control:u.control,name:a,render:c}),e[8]=a,e[9]=u.control,e[10]=c,e[11]=m):m=e[11],m},UC=t=>{let e=(0,Rt.c)(28),{fieldName:a,label:r,className:n}=t,i=lt(),o;e[0]!==a||e[1]!==i?(o=i.watch(a),e[0]=a,e[1]=i,e[2]=o):o=e[2];let l=o,d;e[3]===l?d=e[4]:(d=l??[],e[3]=l,e[4]=d);let[u,c]=f.useState(d),m;e[5]!==u||e[6]!==a||e[7]!==i?(m=()=>{let D=[...u,"#000000"];c(D),i.setValue(a,D)},e[5]=u,e[6]=a,e[7]=i,e[8]=m):m=e[8];let p=m,h;e[9]!==u||e[10]!==a||e[11]!==i?(h=D=>{let j=u.filter((C,S)=>S!==D);c(j),i.setValue(a,j)},e[9]=u,e[10]=a,e[11]=i,e[12]=h):h=e[12];let x=h,g;e[13]!==u||e[14]!==a||e[15]!==i?(g=(D,j)=>{let C=[...u];C[D]=j,c(C),i.setValue(a,C)},e[13]=u,e[14]=a,e[15]=i,e[16]=g):g=e[16];let y=g,b;e[17]!==p||e[18]!==n||e[19]!==u||e[20]!==r||e[21]!==x||e[22]!==y?(b=()=>(0,s.jsxs)(ht,{className:Y("flex flex-col gap-2",n),children:[(0,s.jsx)(wt,{children:r}),(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[u.map((D,j)=>(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("input",{type:"color",value:D,onChange:C=>y(j,C.target.value),className:"w-4 h-4 rounded cursor-pointer"}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground font-mono",children:D}),(0,s.jsx)(Pe,{variant:"ghost",size:"sm",onClick:()=>x(j),className:"h-4 w-4 p-0",children:(0,s.jsx)(ki,{className:"h-2 w-2"})})]},j)),(0,s.jsxs)(Pe,{variant:"outline",size:"sm",onClick:p,className:"w-fit h-6 text-xs",children:[(0,s.jsx)(dy,{className:"h-3 w-3 mr-1"}),"Add Color"]})]})]}),e[17]=p,e[18]=n,e[19]=u,e[20]=r,e[21]=x,e[22]=y,e[23]=b):b=e[23];let w;return e[24]!==a||e[25]!==i.control||e[26]!==b?(w=(0,s.jsx)(mt,{control:i.control,name:a,render:b}),e[24]=a,e[25]=i.control,e[26]=b,e[27]=w):w=e[27],w},pu=t=>{let e=(0,Rt.c)(10),{fieldName:a,label:r}=t,n=lt(),i;e[0]!==a||e[1]!==n?(i=()=>{n.setValue(a,"")},e[0]=a,e[1]=n,e[2]=i):i=e[2];let o=i,l=QC,d;e[3]!==o||e[4]!==r?(d=c=>{let{field:m}=c;return(0,s.jsxs)(ht,{className:"flex flex-row items-center justify-between w-full",children:[(0,s.jsx)(wt,{children:r}),(0,s.jsx)(gt,{children:(0,s.jsxs)(ar,{...m,onValueChange:p=>{p===zo?o():m.onChange(p)},value:m.value??"yearmonthdate",children:[(0,s.jsx)(Er,{onClear:m.value?o:void 0,children:(0,s.jsx)(er,{placeholder:"Select unit"})}),(0,s.jsxs)(tr,{className:"w-72",children:[m.value&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Zt,{value:zo,children:(0,s.jsxs)("div",{className:"flex items-center truncate",children:[(0,s.jsx)(ki,{className:"w-3 h-3 mr-2"}),"Clear"]})}),(0,s.jsx)(Cl,{})]}),(0,s.jsxs)(hn,{children:[RA.map(l),(0,s.jsx)(Cl,{}),TA.map(l)]})]})]})})]})},e[3]=o,e[4]=r,e[5]=d):d=e[5];let u;return e[6]!==a||e[7]!==n.control||e[8]!==d?(u=(0,s.jsx)(mt,{control:n.control,name:a,render:d}),e[6]=a,e[7]=n.control,e[8]=d,e[9]=u):u=e[9],u},Lo=t=>{let e=(0,Rt.c)(9),{fieldName:a,label:r,defaultValue:n,onValueChange:i}=t,[o,l]=f.useState(!1),d=lt(),u;e[0]!==n||e[1]!==o||e[2]!==r||e[3]!==i?(u=m=>{let{field:p}=m;return(0,s.jsxs)(ht,{className:"flex flex-row items-center justify-between w-full",children:[(0,s.jsx)(wt,{children:r}),(0,s.jsx)(gt,{children:(0,s.jsxs)(ar,{...p,onValueChange:h=>{p.onChange(h),i==null||i(h)},value:p.value??n,open:o,onOpenChange:l,children:[(0,s.jsx)(Er,{children:(0,s.jsx)(er,{placeholder:"Select an option"})}),(0,s.jsx)(tr,{children:(0,s.jsx)(hn,{children:ny.map(h=>{let x=gv[h],g=h==="string"?"categorical":h;return(0,s.jsx)(Zt,{value:h,className:"flex flex-col items-start justify-center",subtitle:o&&(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:bA[h]}),children:(0,s.jsx)(x1,{Icon:x,text:nr(g)})},h)})})})]})})]})},e[0]=n,e[1]=o,e[2]=r,e[3]=i,e[4]=u):u=e[4];let c;return e[5]!==a||e[6]!==d.control||e[7]!==u?(c=(0,s.jsx)(mt,{control:d.control,name:a,render:u}),e[5]=a,e[6]=d.control,e[7]=u,e[8]=c):c=e[8],c},y1=t=>{let e=(0,Rt.c)(12),{fieldName:a,selectedDataType:r,binFieldName:n,defaultAggregation:i}=t,o=lt(),l=r==="string"?SA:ay,{chartType:d}=da(),u=d!==xa.HEATMAP,c=JC,m=XC,p;e[0]!==n||e[1]!==o?(p=y=>{let{value:b,previousValue:w,onChange:D}=y;b==="bin"?o.setValue(n,!0):w==="bin"&&o.setValue(n,!1),D(b)},e[0]=n,e[1]=o,e[2]=p):p=e[2];let h=p,x;e[3]!==l||e[4]!==i||e[5]!==h||e[6]!==u?(x=y=>{let{field:b}=y;return(0,s.jsx)(ht,{children:(0,s.jsx)(gt,{children:(0,s.jsxs)(ar,{...b,value:(b.value??i??"none").toString(),onValueChange:w=>{h({value:w,previousValue:b.value,onChange:b.onChange})},children:[(0,s.jsx)(Er,{variant:"ghost",children:(0,s.jsx)(er,{})}),(0,s.jsx)(tr,{children:(0,s.jsxs)(hn,{children:[(0,s.jsx)(x_,{children:"Aggregation"}),l.map(w=>{let D=IA[w],j=c(jA[w]??"Other"),C=m({value:w,Icon:D??Ll,subtitle:j});return w==="bin"?u?(0,s.jsxs)("div",{children:[(0,s.jsx)(Cl,{}),C]},w):null:C})]})})]})})})},e[3]=l,e[4]=i,e[5]=h,e[6]=u,e[7]=x):x=e[7];let g;return e[8]!==a||e[9]!==o.control||e[10]!==x?(g=(0,s.jsx)(mt,{control:o.control,name:a,render:x}),e[8]=a,e[9]=o.control,e[10]=x,e[11]=g):g=e[11],g},ZC=t=>{let e=(0,Rt.c)(7),{fieldName:a,saveFunction:r}=t,n=lt(),{fields:i}=da(),o=ek,l;e[0]!==i||e[1]!==r?(l=u=>{var p;let{field:c}=u,m=((p=c.value)==null?void 0:p.map(tk))??[];return(0,s.jsx)(ht,{children:(0,s.jsx)(gt,{children:(0,s.jsx)(f1,{options:(i==null?void 0:i.map(ak))??[],value:m,setValue:h=>{let x=(typeof h=="function"?h([]):h).map(g=>o(g,i));c.onChange(x),r()},label:null,fullWidth:!1})})})},e[0]=i,e[1]=r,e[2]=l):l=e[2];let d;return e[3]!==a||e[4]!==n.control||e[5]!==l?(d=(0,s.jsx)(mt,{control:n.control,name:a,render:l}),e[3]=a,e[4]=n.control,e[5]=l,e[6]=d):d=e[6],d},b1=t=>{let e=(0,Rt.c)(5),{fieldName:a,label:r,defaultValue:n}=t,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=iy.map(rk),e[0]=i):i=e[0];let o=n??"ascending",l;return e[1]!==a||e[2]!==r||e[3]!==o?(l=(0,s.jsx)(cu,{fieldName:a,label:r,options:i,defaultValue:o}),e[1]=a,e[2]=r,e[3]=o,e[4]=l):l=e[4],l},hu=t=>{var p,h,x,g;let e=(0,Rt.c)(10),{fieldName:a}=t,r=lt(),n;e[0]===r.control?n=e[1]:(n={control:r.control},e[0]=r.control,e[1]=n);let i=va(n);if(!((h=(p=i[a])==null?void 0:p.bin)!=null&&h.binned))return null;let o=!Number.isNaN((g=(x=i[a])==null?void 0:x.bin)==null?void 0:g.step),l=`${a}.bin.step`,d;e[2]===l?d=e[3]:(d=(0,s.jsx)(en,{fieldName:l,label:"Bin step",inputClassName:"w-14",placeholder:"0.5"}),e[2]=l,e[3]=d);let u=`${a}.bin.maxbins`,c;e[4]!==o||e[5]!==u?(c=(0,s.jsx)(en,{fieldName:u,label:"Max bins",inputClassName:"w-14",isDisabled:o,placeholder:"10"}),e[4]=o,e[5]=u,e[6]=c):c=e[6];let m;return e[7]!==d||e[8]!==c?(m=(0,s.jsxs)("div",{className:"flex flex-row justify-between",children:[d,c]}),e[7]=d,e[8]=c,e[9]=m):m=e[9],m};function KC(t){if(t.name.trim()==="")return null;let e=gv[t.type];return(0,s.jsx)(Zt,{value:t.name,children:(0,s.jsxs)("div",{className:"flex items-center truncate",children:[(0,s.jsx)(e,{className:"w-3 h-3 mr-2"}),t.name]})},t.name)}function YC(t){return t.value!==""}function qC(t){return(0,s.jsx)(Zt,{value:t.value,children:t.display},t.value)}function GC(t){return t}function QC(t){let[e,a]=wA[t];return(0,s.jsx)(Zt,{value:t,className:"flex flex-row",subtitle:(0,s.jsx)("span",{className:"text-xs text-muted-foreground ml-auto",children:a}),children:e},t)}function JC(t){return(0,s.jsx)("span",{className:"text-xs text-muted-foreground pr-10",children:t})}function XC(t){let{value:e,Icon:a,subtitle:r}=t;return(0,s.jsx)(Zt,{value:e,className:"flex flex-col items-start justify-center",subtitle:r,children:(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)(a,{className:"w-3 h-3 mr-2"}),nr(e)]})},e)}function ek(t,e){var a;return{field:t,type:((a=e.find(r=>r.name===t))==null?void 0:a.type)??"string"}}function tk(t){return t.field}function ak(t){return t.name}function rk(t){return{display:(0,s.jsx)(x1,{Icon:t==="ascending"?Kb:tA,text:nr(t)}),value:t}}var wr=te();function Dr(t){return Ia(t==null?void 0:t.field)&&(t==null?void 0:t.field)!=="__count__"}function nk(t){return(t==null?void 0:t.selectedDataType)==="string"&&Dr(t)}function ii(t){return(t==null?void 0:t.selectedDataType)==="number"&&Dr(t)}function fu(t){return(t==null?void 0:t.selectedDataType)==="temporal"&&Dr(t)}function ik(t){return(t==null?void 0:t.selectedDataType)!=="temporal"&&Dr(t)}function $o(t){let e=t!=null&&t.type?Sc(t.type):"string";return{inferredDataType:e,selectedDataType:(t==null?void 0:t.selectedDataType)||e}}var gu=t=>{let e=(0,wr.c)(14),{columnFieldName:a,column:r,columns:n,binFieldName:i,defaultAggregation:o}=t,l;e[0]===r?l=e[1]:(l=$o(r),e[0]=r,e[1]=l);let{selectedDataType:d}=l,u;e[2]!==a||e[3]!==n?(u=(0,s.jsx)(Oo,{fieldName:a,columns:n}),e[2]=a,e[3]=n,e[4]=u):u=e[4];let c;e[5]!==i||e[6]!==r||e[7]!==a||e[8]!==o||e[9]!==d?(c=ik(r)&&(0,s.jsx)(y1,{fieldName:a.replace(".field",".aggregate"),selectedDataType:d,binFieldName:i,defaultAggregation:o}),e[5]=i,e[6]=r,e[7]=a,e[8]=o,e[9]=d,e[10]=c):c=e[10];let m;return e[11]!==u||e[12]!==c?(m=(0,s.jsxs)("div",{className:"flex flex-row justify-between",children:[u,c]}),e[11]=u,e[12]=c,e[13]=m):m=e[13],m};const ok=t=>{let e=(0,wr.c)(7),{value:a,onValueChange:r}=t,n,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=rr({variant:"outline",className:"user-select-none w-full justify-between px-3"}),i=(0,s.jsx)(er,{}),e[0]=n,e[1]=i):(n=e[0],i=e[1]);let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=(0,s.jsxs)(y_,{className:n,children:[i,(0,s.jsx)(v_,{asChild:!0,children:(0,s.jsx)(ly,{className:"h-4 w-4 opacity-50"})})]}),e[2]=o):o=e[2];let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=(0,s.jsxs)("div",{className:"flex flex-row gap-2 items-center",children:[o,(0,s.jsx)(tr,{children:_A.map(dk)})]}),e[3]=l):l=e[3];let d;return e[4]!==r||e[5]!==a?(d=(0,s.jsx)(ar,{value:a,onValueChange:r,children:l}),e[4]=r,e[5]=a,e[6]=d):d=e[6],d};var lk=t=>{let e=(0,wr.c)(10),{chartType:a}=t,r=PA[a],n;e[0]===r?n=e[1]:(n=(0,s.jsx)(r,{className:"w-4 h-4 mr-2"}),e[0]=r,e[1]=n);let i;e[2]===a?i=e[3]:(i=nr(a),e[2]=a,e[3]=i);let o;e[4]!==n||e[5]!==i?(o=(0,s.jsxs)("div",{className:"flex items-center",children:[n,i]}),e[4]=n,e[5]=i,e[6]=o):o=e[6];let l;return e[7]!==a||e[8]!==o?(l=(0,s.jsx)(Zt,{value:a,className:"gap-2",children:o}),e[7]=a,e[8]=o,e[9]=l):l=e[9],l};const w1=()=>{var g,y,b,w,D,j,C;let t=(0,wr.c)(22),e=lt(),a;t[0]===e.control?a=t[1]:(a={control:e.control},t[0]=e.control,t[1]=a);let r=va(a),n=da(),i=(g=r.general)==null?void 0:g.xColumn,o;t[2]===i?o=t[3]:(o=$o(i),t[2]=i,t[3]=o);let{inferredDataType:l}=o,d=n.chartType===xa.LINE||n.chartType===xa.BAR||n.chartType===xa.AREA,u;t[4]===Symbol.for("react.memo_cache_sentinel")?(u=(0,s.jsx)(ea,{text:"X-Axis"}),t[4]=u):u=t[4];let c;t[5]!==n.fields||t[6]!==i?(c=(0,s.jsx)(gu,{columnFieldName:"general.xColumn.field",column:i,columns:n.fields,binFieldName:"xAxis.bin.binned"}),t[5]=n.fields,t[6]=i,t[7]=c):c=t[7];let m;t[8]!==l||t[9]!==i?(m=Dr(i)&&(0,s.jsx)(Lo,{label:"Data Type",fieldName:"general.xColumn.selectedDataType",defaultValue:l}),t[8]=l,t[9]=i,t[10]=m):m=t[10];let p;t[11]===i?p=t[12]:(p=fu(i)&&(0,s.jsx)(pu,{fieldName:"general.xColumn.timeUnit",label:"Time Resolution"}),t[11]=i,t[12]=p);let h;t[13]!==d||t[14]!==((b=(y=r.general)==null?void 0:y.xColumn)==null?void 0:b.sort)||t[15]!==i?(h=Dr(i)&&d&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(b1,{fieldName:"general.xColumn.sort",label:"Sort",defaultValue:(D=(w=r.general)==null?void 0:w.xColumn)==null?void 0:D.sort}),ii(i)&&(0,s.jsx)(hu,{fieldName:"xAxis"})]}),t[13]=d,t[14]=(C=(j=r.general)==null?void 0:j.xColumn)==null?void 0:C.sort,t[15]=i,t[16]=h):h=t[16];let x;return t[17]!==c||t[18]!==m||t[19]!==p||t[20]!==h?(x=(0,s.jsxs)(Vo,{children:[u,c,m,p,h]}),t[17]=c,t[18]=m,t[19]=p,t[20]=h,t[21]=x):x=t[21],x},D1=()=>{var S,k,v;let t=(0,wr.c)(29),e=lt(),a;t[0]===e.control?a=t[1]:(a={control:e.control},t[0]=e.control,t[1]=a);let r=va(a),n=da(),i=(S=r.general)==null?void 0:S.yColumn,o=i==null?void 0:i.field,l;t[2]===o?l=t[3]:(l=Ia(o),t[2]=o,t[3]=l);let d=l,u=(v=(k=r.general)==null?void 0:k.xColumn)==null?void 0:v.field,c;t[4]===u?c=t[5]:(c=Ia(u),t[4]=u,t[5]=c);let m=c,p;t[6]===i?p=t[7]:(p=$o(i),t[6]=i,t[7]=p);let{inferredDataType:h}=p,x;ii(i)?x=DA:nk(i)&&(x="count");let g;t[8]===Symbol.for("react.memo_cache_sentinel")?(g=(0,s.jsx)(ea,{text:"Y-Axis"}),t[8]=g):g=t[8];let y;t[9]!==n.fields||t[10]!==x||t[11]!==i?(y=(0,s.jsx)(gu,{columnFieldName:"general.yColumn.field",column:i,columns:n.fields,binFieldName:"yAxis.bin.binned",defaultAggregation:x}),t[9]=n.fields,t[10]=x,t[11]=i,t[12]=y):y=t[12];let b;t[13]!==h||t[14]!==i?(b=Dr(i)&&(0,s.jsx)(Lo,{label:"Data Type",fieldName:"general.yColumn.selectedDataType",defaultValue:h}),t[13]=h,t[14]=i,t[15]=b):b=t[15];let w;t[16]===i?w=t[17]:(w=fu(i)&&(0,s.jsx)(pu,{fieldName:"general.yColumn.timeUnit",label:"Time Resolution"}),t[16]=i,t[17]=w);let D;t[18]!==m||t[19]!==d?(D=d&&m&&(0,s.jsx)(tn,{fieldName:"general.horizontal",label:"Invert axis"}),t[18]=m,t[19]=d,t[20]=D):D=t[20];let j;t[21]===i?j=t[22]:(j=ii(i)&&(0,s.jsx)(hu,{fieldName:"yAxis"}),t[21]=i,t[22]=j);let C;return t[23]!==D||t[24]!==j||t[25]!==y||t[26]!==b||t[27]!==w?(C=(0,s.jsxs)(Vo,{children:[g,y,b,w,D,j]}),t[23]=D,t[24]=j,t[25]=y,t[26]=b,t[27]=w,t[28]=C):C=t[28],C},j1=()=>{var m;let t=(0,wr.c)(13),{fields:e}=da(),a=lt(),r;t[0]===a.control?r=t[1]:(r={control:a.control},t[0]=a.control,t[1]=r);let n=(m=va(r).general)==null?void 0:m.colorByColumn,i;t[2]===n?i=t[3]:(i=ii(n),t[2]=n,t[3]=i);let o=i,l;t[4]===Symbol.for("react.memo_cache_sentinel")?(l=(0,s.jsx)(ea,{text:"Color by"}),t[4]=l):l=t[4];let d;t[5]!==n||t[6]!==e?(d=(0,s.jsx)(gu,{columnFieldName:"general.colorByColumn.field",column:n,columns:e,binFieldName:"color.bin.binned"}),t[5]=n,t[6]=e,t[7]=d):d=t[7];let u;t[8]===o?u=t[9]:(u=o&&(0,s.jsx)(hu,{fieldName:"color"}),t[8]=o,t[9]=u);let c;return t[10]!==d||t[11]!==u?(c=(0,s.jsxs)(Vo,{children:[l,d,u]}),t[10]=d,t[11]=u,t[12]=c):c=t[12],c},sk=()=>{var d,u;let t=(0,wr.c)(7),e=da().fields,a=lt(),r;t[0]===a.control?r=t[1]:(r={control:a.control},t[0]=a.control,t[1]=r);let n=va(r),i;t[2]!==e||t[3]!==((d=n.general)==null?void 0:d.facet)?(i=c=>{var g,y;let m=(y=(g=n.general)==null?void 0:g.facet)==null?void 0:y[c],p=Ia(m==null?void 0:m.field),{inferredDataType:h}=$o(m),x=c==="row"?"general.facet.row.linkYAxis":"general.facet.column.linkXAxis";return(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,s.jsxs)("div",{className:"flex flex-row justify-between",children:[(0,s.jsx)("p",{className:"font-semibold",children:nr(c)}),(0,s.jsx)(Oo,{fieldName:`general.facet.${c}.field`,columns:e})]}),p&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(Lo,{label:"Data Type",fieldName:`general.facet.${c}.selectedDataType`,defaultValue:h}),fu(m)&&(0,s.jsx)(pu,{fieldName:`general.facet.${c}.timeUnit`,label:"Time Resolution"}),ii(m)&&(0,s.jsxs)("div",{className:"flex flex-row justify-between",children:[(0,s.jsx)(tn,{fieldName:`general.facet.${c}.binned`,label:"Binned",defaultValue:!0}),(0,s.jsx)(en,{fieldName:`general.facet.${c}.maxbins`,label:"Max Bins",placeholder:"6",defaultValue:6})]}),(0,s.jsx)(b1,{fieldName:`general.facet.${c}.sort`,label:"Sort"}),(0,s.jsx)(tn,{fieldName:x,label:`Link ${c==="row"?"Y":"X"} Axes`,defaultValue:!0})]})]})},t[2]=e,t[3]=(u=n.general)==null?void 0:u.facet,t[4]=i):i=t[4];let o=i,l;return t[5]===o?l=t[6]:(l=(0,s.jsxs)(Vo,{className:"gap-3",children:[o("row"),o("column")]}),t[5]=o,t[6]=l),l};function dk(t){return(0,s.jsx)(lk,{chartType:t},t)}var xu=te();const uk=()=>{var D,j;let t=(0,xu.c)(17),e=lt(),a;t[0]===e.control?a=t[1]:(a={control:e.control},t[0]=e.control,t[1]=a);let r=va(a),n=(D=r.general)==null?void 0:D.yColumn,i=(j=r.general)==null?void 0:j.colorByColumn,o=n==null?void 0:n.field,l;t[2]===o?l=t[3]:(l=Ia(o),t[2]=o,t[3]=l);let d=l,{chartType:u}=da(),c;t[4]!==u||t[5]!==(i==null?void 0:i.field)?(c=Ia(i==null?void 0:i.field)&&(u===xa.BAR||u===xa.LINE),t[4]=u,t[5]=i==null?void 0:i.field,t[6]=c):c=t[6];let m=c,p,h,x;t[7]===Symbol.for("react.memo_cache_sentinel")?(p=(0,s.jsx)(_a,{delayDuration:100,content:"To persist a chart, add the generated Python code to a new cell.",children:(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)($l,{className:"h-3.5 w-3.5 mb-0.5 text-muted-foreground"}),(0,s.jsx)("p",{className:"text-sm text-muted-foreground",children:"Charts are not saved."})]})}),h=(0,s.jsx)(w1,{}),x=(0,s.jsx)(D1,{}),t[7]=p,t[8]=h,t[9]=x):(p=t[7],h=t[8],x=t[9]);let g;t[10]!==m||t[11]!==d?(g=d&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(j1,{}),m&&(0,s.jsx)("div",{className:"flex flex-row gap-2",children:(0,s.jsx)(tn,{fieldName:"general.stacking",label:"Stacked"})})]}),t[10]=m,t[11]=d,t[12]=g):g=t[12];let y,b;t[13]===Symbol.for("react.memo_cache_sentinel")?(y=(0,s.jsx)(uu,{}),b=(0,s.jsx)(vu,{}),t[13]=y,t[14]=b):(y=t[13],b=t[14]);let w;return t[15]===g?w=t[16]:(w=(0,s.jsxs)(s.Fragment,{children:[p,h,x,g,y,b]}),t[15]=g,t[16]=w),w},ck=()=>{let t=(0,xu.c)(15),{chartType:e}=da(),a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=(0,s.jsx)(Qr,{className:"pt-0",children:(0,s.jsx)(ea,{text:"General"})}),t[0]=a):a=t[0];let r;t[1]===Symbol.for("react.memo_cache_sentinel")?(r=(0,s.jsx)(mu,{label:"Plot title",fieldName:"general.title"}),t[1]=r):r=t[1];let n=e===xa.SCATTER,i;t[2]===n?i=t[3]:(i=(0,s.jsxs)(Jr,{value:"general",children:[a,(0,s.jsxs)(Xr,{children:[r,(0,s.jsx)(tn,{fieldName:"style.gridLines",label:"Show grid lines",defaultValue:n})]})]}),t[2]=n,t[3]=i);let o;t[4]===Symbol.for("react.memo_cache_sentinel")?(o=(0,s.jsx)(Qr,{children:(0,s.jsx)(ea,{text:"X-Axis"})}),t[4]=o):o=t[4];let l;t[5]===Symbol.for("react.memo_cache_sentinel")?(l=(0,s.jsxs)(Jr,{value:"xAxis",children:[o,(0,s.jsxs)(Xr,{children:[(0,s.jsx)(mu,{label:"Label",fieldName:"xAxis.label"}),(0,s.jsx)(v1,{fieldName:"xAxis.width",label:"Width",defaultValue:400,start:200,stop:800})]})]}),t[5]=l):l=t[5];let d;t[6]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsx)(Qr,{children:(0,s.jsx)(ea,{text:"Y-Axis"})}),t[6]=d):d=t[6];let u;t[7]===Symbol.for("react.memo_cache_sentinel")?(u=(0,s.jsxs)(Jr,{value:"yAxis",children:[d,(0,s.jsxs)(Xr,{children:[(0,s.jsx)(mu,{label:"Label",fieldName:"yAxis.label"}),(0,s.jsx)(v1,{fieldName:"yAxis.height",label:"Height",defaultValue:300,start:150,stop:600})]})]}),t[7]=u):u=t[7];let c;t[8]===Symbol.for("react.memo_cache_sentinel")?(c=(0,s.jsx)(Qr,{children:(0,s.jsx)(ea,{text:"Color"})}),t[8]=c):c=t[8];let m;t[9]===Symbol.for("react.memo_cache_sentinel")?(m=(0,s.jsx)(cu,{fieldName:"color.field",label:"Field",options:ry.map(mk),defaultValue:Ci}),t[9]=m):m=t[9];let p,h;t[10]===Symbol.for("react.memo_cache_sentinel")?(p=(0,s.jsx)(cu,{fieldName:"color.scheme",label:"Color scheme",defaultValue:ty,options:CA.map(pk)}),h=(0,s.jsx)(UC,{fieldName:"color.range",label:"Color range"}),t[10]=p,t[11]=h):(p=t[10],h=t[11]);let x;t[12]===Symbol.for("react.memo_cache_sentinel")?(x=(0,s.jsxs)(Jr,{value:"color",children:[c,(0,s.jsxs)(Xr,{children:[m,p,h,(0,s.jsxs)("p",{className:"text-xs",children:[(0,s.jsx)(vl,{className:"w-2.5 h-2.5 inline mb-1 mr-1"}),"If you are using color range, color scheme will be ignored."]})]})]}),t[12]=x):x=t[12];let g;return t[13]===i?g=t[14]:(g=(0,s.jsxs)(pc,{type:"multiple",children:[i,l,u,x]}),t[13]=i,t[14]=g),g},vu=()=>{var m;let t=(0,xu.c)(11),{saveForm:e}=da(),a=lt(),r;t[0]===a.control?r=t[1]:(r={control:a.control},t[0]=a.control,t[1]=r);let n=(m=va(r).tooltips)==null?void 0:m.auto,i;t[2]===Symbol.for("react.memo_cache_sentinel")?(i=(0,s.jsx)(Qr,{className:"pt-0",children:(0,s.jsx)(ea,{text:"Faceting",tooltip:"Repeat the chart for each unique field value"})}),t[2]=i):i=t[2];let o;t[3]===Symbol.for("react.memo_cache_sentinel")?(o=(0,s.jsxs)(Jr,{value:"facet",children:[i,(0,s.jsx)(Xr,{children:(0,s.jsx)(sk,{})})]}),t[3]=o):o=t[3];let l;t[4]===Symbol.for("react.memo_cache_sentinel")?(l=(0,s.jsx)(Qr,{children:(0,s.jsx)(ea,{text:"Tooltips"})}),t[4]=l):l=t[4];let d;t[5]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsx)(tn,{fieldName:"tooltips.auto",label:"Include X, Y and Color"}),t[5]=d):d=t[5];let u;t[6]!==n||t[7]!==e?(u=!n&&(0,s.jsx)(ZC,{fieldName:"tooltips.fields",saveFunction:e}),t[6]=n,t[7]=e,t[8]=u):u=t[8];let c;return t[9]===u?c=t[10]:(c=(0,s.jsxs)(pc,{type:"multiple",children:[o,(0,s.jsxs)(Jr,{value:"tooltips",children:[l,(0,s.jsxs)(Xr,{wrapperClassName:"flex-row justify-between",children:[d,u]})]})]}),t[9]=u,t[10]=c),c};function mk(t){return{display:nr(t),value:t}}function pk(t){return{display:nr(t),value:t}}var hk=te();const fk=()=>{var b,w,D,j;let t=(0,hk.c)(17),e=lt(),a;t[0]===e.control?a=t[1]:(a={control:e.control},t[0]=e.control,t[1]=a);let r=va(a),n=(w=(b=r.general)==null?void 0:b.xColumn)==null?void 0:w.field,i;t[2]===n?i=t[3]:(i=Ia(n),t[2]=n,t[3]=i);let o=i,l=(j=(D=r.general)==null?void 0:D.yColumn)==null?void 0:j.field,d;t[4]===l?d=t[5]:(d=Ia(l),t[4]=l,t[5]=d);let u=d,c;t[6]===Symbol.for("react.memo_cache_sentinel")?(c=(0,s.jsx)(w1,{}),t[6]=c):c=t[6];let m;t[7]===o?m=t[8]:(m=o&&(0,s.jsx)(en,{fieldName:"xAxis.bin.maxbins",label:"Number of boxes (max)",className:"justify-between"}),t[7]=o,t[8]=m);let p;t[9]===Symbol.for("react.memo_cache_sentinel")?(p=(0,s.jsx)(D1,{}),t[9]=p):p=t[9];let h;t[10]===u?h=t[11]:(h=u&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(en,{fieldName:"yAxis.bin.maxbins",label:"Number of boxes (max)",className:"justify-between"}),(0,s.jsx)(j1,{})]}),t[10]=u,t[11]=h);let x,g;t[12]===Symbol.for("react.memo_cache_sentinel")?(g=(0,s.jsx)(uu,{}),x=(0,s.jsx)(vu,{}),t[12]=x,t[13]=g):(x=t[12],g=t[13]);let y;return t[14]!==m||t[15]!==h?(y=(0,s.jsxs)(s.Fragment,{children:[c,m,p,h,g,x]}),t[14]=m,t[15]=h,t[16]=y):y=t[16],y};var gk=te();const xk=()=>{var j,C,S;let t=(0,gk.c)(25),e=lt(),{fields:a}=da(),r;t[0]===e.control?r=t[1]:(r={control:e.control},t[0]=e.control,t[1]=r);let n=va(r),i=(j=n.general)==null?void 0:j.colorByColumn,o=(S=(C=n.general)==null?void 0:C.yColumn)==null?void 0:S.selectedDataType;(o===""||!o)&&(o="string");let l;t[2]===i?l=t[3]:(l=i!=null&&i.type?Sc(i.type):"string",t[2]=i,t[3]=l);let d=l,u;t[4]===Symbol.for("react.memo_cache_sentinel")?(u=(0,s.jsx)(ea,{text:"Color by"}),t[4]=u):u=t[4];let c;t[5]===a?c=t[6]:(c=(0,s.jsx)(Oo,{fieldName:"general.colorByColumn.field",columns:a,includeCountField:!1}),t[5]=a,t[6]=c);let m;t[7]!==(i==null?void 0:i.field)||t[8]!==d?(m=Ia(i==null?void 0:i.field)&&(0,s.jsx)(Lo,{fieldName:"general.colorByColumn.selectedDataType",label:"Data Type",defaultValue:d}),t[7]=i==null?void 0:i.field,t[8]=d,t[9]=m):m=t[9];let p;t[10]===Symbol.for("react.memo_cache_sentinel")?(p=(0,s.jsx)(ea,{text:"Size by"}),t[10]=p):p=t[10];let h;t[11]===a?h=t[12]:(h=(0,s.jsx)(Oo,{fieldName:"general.yColumn.field",columns:a}),t[11]=a,t[12]=h);let x;t[13]===o?x=t[14]:(x=(0,s.jsx)(y1,{fieldName:"general.yColumn.aggregate",selectedDataType:o,binFieldName:"yAxis.bin.binned"}),t[13]=o,t[14]=x);let g;t[15]!==h||t[16]!==x?(g=(0,s.jsxs)("div",{className:"flex flex-row justify-between",children:[h,x]}),t[15]=h,t[16]=x,t[17]=g):g=t[17];let y,b,w;t[18]===Symbol.for("react.memo_cache_sentinel")?(w=(0,s.jsx)(en,{fieldName:"style.innerRadius",label:"Donut size",className:"w-32"}),y=(0,s.jsx)(uu,{}),b=(0,s.jsx)(vu,{}),t[18]=y,t[19]=b,t[20]=w):(y=t[18],b=t[19],w=t[20]);let D;return t[21]!==c||t[22]!==m||t[23]!==g?(D=(0,s.jsxs)(s.Fragment,{children:[u,c,m,p,g,w,y,b]}),t[21]=c,t[22]=m,t[23]=g,t[24]=D):D=t[24],D};var C1=te();const vk=t=>{let e=(0,C1.c)(8),{baseSpec:a,data:r,height:n}=t,{theme:i}=vn();if(!r){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=(0,s.jsx)("div",{children:"No data"}),e[0]=u):u=e[0],u}let o;e[1]!==r||e[2]!==n||e[3]!==i?(o=u=>{if(typeof u=="string")return(0,s.jsx)(Uv,{children:u});let c=AA(u,r);return(0,s.jsx)(f.Suspense,{fallback:(0,s.jsx)(yk,{}),children:(0,s.jsx)($_,{spec:c,"data-container-width":rI(c),options:{theme:i==="dark"?"dark":void 0,height:n,actions:{export:!0,source:!1,compiled:!1,editor:!1},mode:"vega",renderer:"canvas",tooltip:aI.call}})})},e[1]=r,e[2]=n,e[3]=i,e[4]=o):o=e[4];let l=o,d;return e[5]!==a||e[6]!==l?(d=(0,s.jsx)("div",{className:"h-full m-auto rounded-md w-full",children:l(a)}),e[5]=a,e[6]=l,e[7]=d):d=e[7],d};var yk=()=>{let t=(0,C1.c)(1),e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,s.jsx)(Uv,{className:"mt-14",children:"Loading chart..."}),t[0]=e):e=t[0],e};const yu=L({binned:W().optional(),step:H().optional(),maxbins:H().optional()});var bu=L({field:M().optional(),type:be([...ko,""]).optional(),selectedDataType:be([...ny,""]).optional(),sort:be(iy).default("ascending").optional(),timeUnit:be(kA).optional()});const wu=bu.extend({aggregate:be(ay).default(Ci).optional()}),bk=bu.extend({linkYAxis:W().default(!0),binned:W().default(!0),maxbins:H().default(6)}),wk=bu.extend({linkXAxis:W().default(!0),binned:W().default(!0),maxbins:H().default(6)}),k1=L({general:L({title:M().optional(),xColumn:wu.optional(),yColumn:wu.optional(),colorByColumn:wu.optional(),facet:L({row:bk,column:wk}).optional(),horizontal:W().optional(),stacking:W().optional()}).optional(),xAxis:L({label:M().optional(),width:H().optional(),bin:yu.optional()}).optional(),yAxis:L({label:M().optional(),height:H().optional(),bin:yu.optional()}).optional(),color:L({field:be([...ry,Ci]).default(Ci),scheme:M().default(ty).optional(),range:Q(M()).optional(),domain:Q(M()).optional(),bin:yu.optional()}).optional(),style:L({innerRadius:H().optional(),gridLines:W().optional()}).optional(),tooltips:L({auto:W(),fields:Q(L({field:M(),type:be(ko)}))}).default({auto:!0,fields:[]}).optional()});function Du(){return{general:{facet:{row:{linkYAxis:!0,binned:!0,maxbins:6},column:{linkXAxis:!0,binned:!0,maxbins:6}}},color:{field:Ci,scheme:"default"},tooltips:{auto:!0,fields:[]}}}const ju="marimo:charts:v2";var Dk=L({tabName:M().transform(t=>t),chartType:M().transform(t=>t),config:k1}),Cu=new XN(ju,Q(ra([M().transform(t=>t),Q(Dk)])),()=>[]),S1={getItem:t=>{try{let e=Cu.get(t);return new Map(e)}catch(e){return de.warn("Error getting chart storage",e),new Map}},setItem:(t,e)=>{Cu.set(t,[...e.entries()])},removeItem:t=>{Cu.remove(t)}};const jk=aT(ju,new Map,S1);function ku(t,e){let a=nr(e);return t===0?`${a} Chart`:`${a} Chart ${t+1}`}var Ck=S1.getItem(ju);function kk(t){let e=Ck.get(t);return e?e.length>0:!1}var Sk=te(),Bo="bar",Ho="table",E1=290,Ek=5e4,Rk=50;const Nk=({cellId:t,data:e,dataTable:a,totalRows:r,columns:n,getDataUrl:i,fieldTypes:o,displayHeader:l,onCloseChartBuilder:d})=>{let[u,c]=xi(jk),m=t?u.get(t)??[]:[],[p,h]=(0,f.useState)(Ho),[x,g]=(0,f.useState)(m.length),y=(0,f.useRef)(l);if(l&&!y.current&&m.length===0&&t){y.current=l;let S=ku(0,Bo),k=new Map(u);k.set(t,[{tabName:S,chartType:Bo,config:Du()}]),c(k),g(1),h(S)}if(y.current=l,!l||m.length===0&&!l)return a;let b=()=>{if(!t)return;let S=ku(x,Bo),k=new Map(u);k.set(t,[...m,{tabName:S,chartType:Bo,config:Du()}]),c(k),g(x+1),h(S)},w=S=>{if(!t)return;let k=m.findIndex(N=>N.tabName===S),v=m.filter(N=>N.tabName!==S),E=new Map(u);E.set(t,v),c(E),v.length===0?d==null||d():S===p&&(k<v.length?h(v[k].tabName):h(v[v.length-1].tabName))},D=({tabName:S,chartType:k,chartConfig:v})=>{if(!t)return;let E=new Map(u);E.set(t,m.map(N=>N.tabName===S?{...N,chartType:k,config:v}:N)),c(E)},j=(S,k)=>{if(!t)return;let v=u.get(t)??[],E=v.findIndex(R=>R.tabName===S);if(E===-1)return;let N=v.map(R=>R.tabName===S?{...R,chartType:k,tabName:ku(E,k)}:R);c(new Map(u).set(t,N)),h(N[E].tabName)},C=r==="too_many"||r>Ek||n>Rk;return(0,s.jsxs)(pn,{value:p,className:"-mt-1",children:[(0,s.jsxs)(wi,{part:"table-tabs",children:[(0,s.jsx)(ga,{className:"text-xs",value:Ho,onClick:()=>h(Ho),children:"Table"}),m.map((S,k)=>(0,s.jsxs)(ga,{className:"text-xs",value:S.tabName,onClick:()=>h(S.tabName),children:[S.tabName,(0,s.jsx)(ki,{className:"w-3 h-3 ml-1 mt-[0.5px] hover:text-red-500 hover:font-semibold",onClick:v=>{v.stopPropagation(),w(S.tabName)}})]},k)),(0,s.jsx)(Pe,{variant:"text",size:"icon",onClick:b,title:"Add chart",children:"+"})]}),(0,s.jsx)(Ut,{className:"mt-1 overflow-hidden",value:Ho,children:a}),m.map((S,k)=>(0,s.jsx)(Ut,{value:S.tabName,className:"h-[400px] mt-0",children:(0,s.jsx)(Tk,{tableData:e,chartConfig:S.config,chartType:S.chartType,saveChart:v=>{D({tabName:S.tabName,chartType:S.chartType,chartConfig:v})},saveChartType:v=>{j(S.tabName,v)},getDataUrl:i,fieldTypes:o??vc(a.props.data),isLargeDataset:C})},k))]})};var R1="X and Y columns are not set";const Tk=({tableData:t,chartConfig:e,chartType:a,saveChart:r,saveChartType:n,getDataUrl:i,fieldTypes:o,isLargeDataset:l})=>{let{theme:d}=vn(),u=by({defaultValues:e??Du(),resolver:wy(k1)}),[c,m]=(0,f.useState)(a),[p,h]=(0,f.useState)(!1),[x,g]=(0,f.useState)(!l),{ref:y}=fI(),{data:b,isPending:w,error:D}=Yt(async()=>{if(!i||t.length===0||!x)return[];let k=await i({});return Array.isArray(k.data_url)?k.data_url:await My(k.data_url,k.format==="arrow"?{type:"arrow"}:k.format==="json"?{type:"json"}:{type:"csv",parse:"auto"},{replacePeriod:!0})},[t,x]),j=u.watch(),C=NA(c,(0,f.useMemo)(()=>structuredClone(j),[j]),d,"container",E1),S=(0,f.useMemo)(()=>w?(0,s.jsx)(S_,{}):D?(0,s.jsx)(V_,{error:D}):x?(0,s.jsx)(vk,{baseSpec:C,data:b,height:E1}):(0,s.jsxs)(Yl,{variant:"warning",className:"flex flex-row gap-2 items-center w-2/3 mx-auto",children:[(0,s.jsx)($l,{className:"h-4 w-4 mt-1"}),(0,s.jsxs)(lI,{className:"flex flex-row justify-between items-center w-full",children:[(0,s.jsx)("span",{children:"Rendering large datasets is not well supported and may crash the browser"}),(0,s.jsx)(Pe,{variant:"warn",onClick:()=>g(!0),className:"h-8",children:"Proceed"})]})]}),[w,D,x,C,b]);return(0,s.jsxs)("div",{className:"flex flex-row gap-2 h-full rounded-md border-t pr-2",children:[(0,s.jsxs)("div",{className:`relative flex flex-col gap-2 overflow-auto px-2 py-3 scrollbar-thin transition-width duration-200 ${p?"w-8":"w-[300px]"}`,children:[!p&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ok,{value:c,onValueChange:k=>{m(k),n(k)}}),(0,s.jsx)(_k,{form:u,saveChart:r,fieldTypes:o,chartType:c})]}),(0,s.jsx)(Pe,{variant:"outline",size:"icon",className:"border-border ml-auto",onClick:()=>h(k=>!k),title:p?"Expand sidebar":"Collapse sidebar",children:p?(0,s.jsx)(Si,{className:"w-4 h-5"}):(0,s.jsx)(Sl,{className:"w-4 h-5"})})]}),(0,s.jsx)("div",{className:"flex-1 overflow-auto h-full w-full mt-3",children:(()=>{let k=R1;return typeof C!="string"&&(k=mj(C,"_df","_chart")),(0,s.jsxs)(pn,{defaultValue:"chart",children:[(0,s.jsx)("div",{className:"flex flex-row gap-1.5 items-center",children:(0,s.jsxs)(wi,{children:[(0,s.jsxs)(ga,{value:"chart",className:"h-6",children:[(0,s.jsx)(yA,{className:"text-muted-foreground mr-2 w-4 h-4"}),"Chart"]}),(0,s.jsxs)(ga,{value:"code",className:"h-6",children:[(0,s.jsx)(gI,{className:"text-muted-foreground mr-2"}),"Python code"]}),!1]})}),(0,s.jsx)(Ut,{value:"chart",ref:y,children:S}),(0,s.jsx)(Ut,{value:"code",children:(0,s.jsx)(WC,{code:k,insertNewCell:k!==R1,language:"python"})}),!1]})})()})]})};var _k=t=>{let e=(0,Sk.c)(28),{form:a,saveChart:r,fieldTypes:n,chartType:i}=t,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0];let l=o;if(n){let S;e[1]===n?S=e[2]:(S=n.map(Ak),e[1]=n,e[2]=S),l=S}let d;e[3]!==a||e[4]!==r?(d=()=>{r(a.getValues())},e[3]=a,e[4]=r,e[5]=d):d=e[5];let u=Q6(d,300),c=uk;i===xa.PIE?c=xk:i===xa.HEATMAP&&(c=fk);let m;e[6]!==i||e[7]!==u||e[8]!==l?(m={fields:l,saveForm:u,chartType:i},e[6]=i,e[7]=u,e[8]=l,e[9]=m):m=e[9];let p;e[10]===Symbol.for("react.memo_cache_sentinel")?(p=(0,s.jsxs)(ga,{value:"data",className:"w-1/2 h-6",children:[(0,s.jsx)(Dv,{className:"w-4 h-4 mr-2"}),"Data"]}),e[10]=p):p=e[10];let h;e[11]===Symbol.for("react.memo_cache_sentinel")?(h=(0,s.jsxs)(wi,{className:"w-full",children:[p,(0,s.jsxs)(ga,{value:"style",className:"w-1/2 h-6",children:[(0,s.jsx)(qN,{className:"w-4 h-4 mr-2"}),"Style"]})]}),e[11]=h):h=e[11];let x;e[12]===Symbol.for("react.memo_cache_sentinel")?(x=(0,s.jsx)("hr",{className:"my-2"}),e[12]=x):x=e[12];let g;e[13]===c?g=e[14]:(g=(0,s.jsxs)(Ut,{value:"data",children:[x,(0,s.jsx)(g1,{children:(0,s.jsx)(c,{})})]}),e[13]=c,e[14]=g);let y;e[15]===Symbol.for("react.memo_cache_sentinel")?(y=(0,s.jsx)("hr",{className:"my-2"}),e[15]=y):y=e[15];let b;e[16]===Symbol.for("react.memo_cache_sentinel")?(b=(0,s.jsxs)(Ut,{value:"style",children:[y,(0,s.jsx)(g1,{children:(0,s.jsx)(ck,{})})]}),e[16]=b):b=e[16];let w;e[17]===g?w=e[18]:(w=(0,s.jsxs)(pn,{defaultValue:"data",children:[h,g,b]}),e[17]=g,e[18]=w);let D;e[19]!==u||e[20]!==w?(D=(0,s.jsx)("form",{onSubmit:Ik,onChange:u,children:w}),e[19]=u,e[20]=w,e[21]=D):D=e[21];let j;e[22]!==a||e[23]!==D?(j=(0,s.jsx)(b6,{...a,children:D}),e[22]=a,e[23]=D,e[24]=j):j=e[24];let C;return e[25]!==j||e[26]!==m?(C=(0,s.jsx)(fx,{value:m,children:j}),e[25]=j,e[26]=m,e[27]=C):C=e[27],C};function Ak(t){return{name:t[0],type:t[1][0]}}function Ik(t){return t.preventDefault()}var Pk=te();function Mk(t,e){let a=(0,Pk.c)(16),r=gl(R_),{focusCell:n}=pI(),i=hI(),[o,l]=xi(M_),[d,u]=xi(eA),[c,m]=xi(O_),p=Fk(t,e);!e&&r&&(de.error("CellId is not found, defaulting to fixed mode"),r=!1);let h=j=>d===p&&c&&j===o,x=i===e,g=d&&Vk(d,e);r&&x&&d!==p&&!g&&u(p);let y=d===p&&c,b;a[0]!==e||a[1]!==n||a[2]!==y||a[3]!==r||a[4]!==p||a[5]!==o||a[6]!==m||a[7]!==u||a[8]!==l?(b=function(j){y?(u(null),m(!1)):(u(p),r&&e&&n({cellId:e}),m(!0),j&&!o&&l(j))},a[0]=e,a[1]=n,a[2]=y,a[3]=r,a[4]=p,a[5]=o,a[6]=m,a[7]=u,a[8]=l,a[9]=b):b=a[9];let w=b,D;return a[10]!==y||a[11]!==h||a[12]!==o||a[13]!==l||a[14]!==w?(D={isPanelOpen:h,isAnyPanelOpen:y,togglePanel:w,panelType:o,setPanelType:l},a[10]=y,a[11]=h,a[12]=o,a[13]=l,a[14]=w,a[15]=D):D=a[15],D}function Fk(t,e){return e?`${e}-${t}`:t}function Vk(t,e){return e?t.startsWith(e):!1}const N1=ut.input(yi.object({format:yi.enum(["csv","json","parquet"])})).output(yi.object({url:yi.string(),filename:yi.string()}));var Su=te();const zk=t=>{let e=(0,Su.c)(40),{previewColumn:a,fieldTypes:r,totalRows:n,totalColumns:i,tableId:o}=t,[l,d]=(0,f.useState)(""),{locale:u}=rt(),c,m,p,h,x,g,y,b,w,D;if(e[0]!==r||e[1]!==u||e[2]!==a||e[3]!==l||e[4]!==o||e[5]!==i||e[6]!==n){let k=r==null?void 0:r.filter($k),v=k==null?void 0:k.filter(R=>{let[_]=R;return _.toLowerCase().includes(l.toLowerCase())});w="mb-3";let E;e[17]!==u||e[18]!==i||e[19]!==n?(E=L_(n,i,u),e[17]=u,e[18]=i,e[19]=n,e[20]=E):E=e[20],D=(0,s.jsxs)("span",{className:"text-xs font-semibold ml-2 flex",children:[E,(0,s.jsx)(zc,{tooltip:"Copy column names",value:(k==null?void 0:k.map(Bk).join(`,
30
30
  `))||"",className:"h-3 w-3 ml-1 mt-0.5"})]}),m=zy,g="h-5/6 bg-background",y=!1;let N;e[21]===Symbol.for("react.memo_cache_sentinel")?(N=R=>d(R),e[21]=N):N=e[21],e[22]===l?b=e[23]:(b=(0,s.jsx)(Vy,{placeholder:"Search columns...",value:l,onValueChange:N}),e[22]=l,e[23]=b),c=cI,p="max-h-full",e[24]===Symbol.for("react.memo_cache_sentinel")?(h=(0,s.jsx)(uI,{children:"No results."}),e[24]=h):h=e[24],x=v==null?void 0:v.map((R,_)=>{let[V,I]=R,[A,T]=I;return(0,s.jsx)(Ok,{columnName:V,dataType:A,externalType:T,previewColumn:a,defaultExpanded:_===0},`${o}-${V}`)}),e[0]=r,e[1]=u,e[2]=a,e[3]=l,e[4]=o,e[5]=i,e[6]=n,e[7]=c,e[8]=m,e[9]=p,e[10]=h,e[11]=x,e[12]=g,e[13]=y,e[14]=b,e[15]=w,e[16]=D}else c=e[7],m=e[8],p=e[9],h=e[10],x=e[11],g=e[12],y=e[13],b=e[14],w=e[15],D=e[16];let j;e[25]!==c||e[26]!==p||e[27]!==h||e[28]!==x?(j=(0,s.jsxs)(c,{className:p,children:[h,x]}),e[25]=c,e[26]=p,e[27]=h,e[28]=x,e[29]=j):j=e[29];let C;e[30]!==m||e[31]!==g||e[32]!==y||e[33]!==b||e[34]!==j?(C=(0,s.jsxs)(m,{className:g,shouldFilter:y,children:[b,j]}),e[30]=m,e[31]=g,e[32]=y,e[33]=b,e[34]=j,e[35]=C):C=e[35];let S;return e[36]!==C||e[37]!==w||e[38]!==D?(S=(0,s.jsxs)("div",{className:w,children:[D,C]}),e[36]=C,e[37]=w,e[38]=D,e[39]=S):S=e[39],S};var Ok=t=>{let e=(0,Su.c)(31),{columnName:a,dataType:r,externalType:n,previewColumn:i,defaultExpanded:o}=t,[l,d]=(0,f.useState)(o===void 0?!1:o),u=l?"font-semibold":"",c;e[0]!==a||e[1]!==u?(c=(0,s.jsx)("span",{className:u,children:a}),e[0]=a,e[1]=u,e[2]=c):c=e[2];let m=c,p;e[3]===l?p=e[4]:(p=()=>d(!l),e[3]=l,e[4]=p);let h;e[5]===l?h=e[6]:(h=l?(0,s.jsx)(ly,{className:"w-3 h-3 shrink-0 text-muted-foreground"}):(0,s.jsx)(Si,{className:"w-3 h-3 shrink-0 text-muted-foreground"}),e[5]=l,e[6]=h);let x;e[7]!==m||e[8]!==r?(x=(0,s.jsx)($y,{columnName:m,dataType:r}),e[7]=m,e[8]=r,e[9]=x):x=e[9];let g;e[10]===a?g=e[11]:(g=(0,s.jsx)(_a,{content:"Copy column name",delayDuration:400,children:(0,s.jsx)(Pe,{variant:"text",size:"icon",className:"group-hover:opacity-100 opacity-0 hover:bg-muted text-muted-foreground hover:text-foreground",children:(0,s.jsx)(zc,{tooltip:!1,value:a,className:"h-3 w-3"})})}),e[10]=a,e[11]=g);let y;e[12]===n?y=e[13]:(y=(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:n}),e[12]=n,e[13]=y);let b;e[14]!==g||e[15]!==y?(b=(0,s.jsxs)("div",{className:"ml-auto",children:[g,y]}),e[14]=g,e[15]=y,e[16]=b):b=e[16];let w;e[17]!==a||e[18]!==p||e[19]!==h||e[20]!==x||e[21]!==b?(w=(0,s.jsxs)(dI,{onSelect:p,className:"flex flex-row items-center gap-1.5 group w-full cursor-pointer",children:[h,x,b]},a),e[17]=a,e[18]=p,e[19]=h,e[20]=x,e[21]=b,e[22]=w):w=e[22];let D;e[23]!==a||e[24]!==r||e[25]!==l||e[26]!==i?(D=l&&(0,s.jsx)(yl,{children:(0,s.jsx)(Lk,{previewColumn:i,columnName:a,dataType:r})}),e[23]=a,e[24]=r,e[25]=l,e[26]=i,e[27]=D):D=e[27];let j;return e[28]!==w||e[29]!==D?(j=(0,s.jsxs)(s.Fragment,{children:[w,D]}),e[28]=w,e[29]=D,e[30]=j):j=e[30],j},Lk=t=>{let e=(0,Su.c)(26),{previewColumn:a,columnName:r,dataType:n}=t,{theme:i}=vn(),{locale:o}=rt(),l;e[0]!==r||e[1]!==a?(l=async()=>await a({column:r}),e[0]=r,e[1]=a,e[2]=l):l=e[2];let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=[],e[3]=d):d=e[3];let{data:u,error:c,isPending:m,refetch:p}=Yt(l,d);if(c){let R;return e[4]===c?R=e[5]:(R=(0,s.jsx)(xI,{error:c}),e[4]=c,e[5]=R),R}if(m){let R;return e[6]===Symbol.for("react.memo_cache_sentinel")?(R=(0,s.jsx)(bI,{message:"Loading..."}),e[6]=R):R=e[6],R}if(!u){let R;return e[7]===Symbol.for("react.memo_cache_sentinel")?(R=(0,s.jsx)(vI,{content:"No data",className:"pl-4"}),e[7]=R):R=e[7],R}let{chart_spec:h,chart_code:x,error:g,missing_packages:y,stats:b}=u,w;e[8]!==y||e[9]!==g||e[10]!==p?(w=g&&k6({error:g,missingPackages:y,refetchPreview:p}),e[8]=y,e[9]=g,e[10]=p,e[11]=w):w=e[11];let D=w,j;e[12]!==n||e[13]!==o||e[14]!==b?(j=b&&C6({stats:b,dataType:n,locale:o}),e[12]=n,e[13]=o,e[14]=b,e[15]=j):j=e[15];let C=j,S;e[16]!==h||e[17]!==i?(S=h&&S6(h,i),e[16]=h,e[17]=i,e[18]=S):S=e[18];let k=S,v;e[19]===x?v=e[20]:(v=x&&(0,s.jsx)(E6,{chartCode:x}),e[19]=x,e[20]=v);let E=v,N;return e[21]!==E||e[22]!==k||e[23]!==D||e[24]!==C?(N=(0,s.jsxs)(yI,{className:"px-2 py-1",children:[D,E,k,C]}),e[21]=E,e[22]=k,e[23]=D,e[24]=C,e[25]=N):N=e[25],N};function $k(t){let[e]=t;return!(e==="__select__"||e==="_marimo_row_id"||e.startsWith("__m_column__"))}function Bk(t){let[e]=t;return e}var Hk=te();const Wk=({rowIdx:t,setRowIdx:e,totalRows:a,fieldTypes:r,getRow:n,isSelectable:i,isRowSelected:o,handleRowSelectionChange:l})=>{let[d,u]=(0,f.useState)(""),c=(0,f.useRef)(null),m=(0,f.useId)(),{locale:p}=rt(),h=a===fc,{data:x,error:g}=Yt(async()=>(await n(t)).rows,[n,t,a]),y=C=>{C<0||typeof a=="number"&&C>=a||e(C)},b=()=>{l==null||l(C=>{if(o){let{[t]:S,...k}=C;return k}return{...C,[t]:!0}})};!h&&t>a&&y(a-1);let w=C=>{if(!(C.target instanceof HTMLInputElement))switch(C.key){case"ArrowLeft":y(t-1);break;case"ArrowRight":y(t+1);break;case" ":C.preventDefault(),b();break}},D="h-6 w-6 p-0.5",j=()=>{if(g)return(0,s.jsx)(Ti,{error:g,className:"p-4 mx-3 mt-5"});if(a===0)return(0,s.jsx)(Eu,{kind:"info",Icon:vl,message:"No rows selected"});if(!x)return(0,s.jsx)(gc,{milliseconds:200,children:(0,s.jsx)(Nl,{size:"medium",centered:!0})});if(x.length!==1)return(0,s.jsx)(Eu,{kind:"warn",Icon:$l,message:h?"LazyFrame, no data available.":`Expected 1 row, got ${x.length} rows. Please report the issue.`});let C=x[0];if(typeof C!="object"||!C)return(0,s.jsx)(Eu,{kind:"warn",Icon:$l,message:"Row is not an object. Please report the issue."});let S={};for(let[k,v]of Object.entries(C))k==="__select__"||k==="_marimo_row_id"||(k.startsWith("__m_column__")?S[k.slice(N_.length)]=v:S[k]=v);return(0,s.jsxs)(Bc,{className:"mb-4",children:[(0,s.jsx)(Oy,{children:(0,s.jsxs)(Dn,{children:[(0,s.jsx)(Lc,{className:"w-1/4",children:"Column"}),(0,s.jsx)(Lc,{className:"w-3/4",children:"Value"})]})}),(0,s.jsx)($c,{children:r==null?void 0:r.map(([k,[v,E]])=>{let N=S[k];if(!Uk({columnName:k,columnValue:N,searchQuery:d}))return null;let R=E_({column:{id:k,columnDef:{meta:{dataType:v}},getColumnFormatting:()=>{},applyColumnFormatting:V=>V},renderValue:()=>N,getValue:()=>N,selectCell:void 0,cellStyles:"text-left break-word"}),_=typeof N=="object"?JSON.stringify(N):String(N);return(0,s.jsxs)(Dn,{className:"group",children:[(0,s.jsx)(Ir,{children:(0,s.jsx)($y,{columnName:(0,s.jsx)("span",{children:k}),dataType:v})}),(0,s.jsx)(Ir,{children:(0,s.jsxs)("div",{className:"flex flex-row items-center justify-between gap-1",children:[R,(0,s.jsx)(zc,{value:_,className:"w-3 h-3 mr-1 text-muted-foreground cursor-pointer opacity-0 group-hover:opacity-100"})]})})]},k)})})]})};return(0,s.jsxs)("div",{className:"flex flex-col gap-3 focus:outline-hidden",ref:c,tabIndex:-1,onKeyDown:w,children:[(0,s.jsxs)("div",{className:"flex flex-row gap-2 items-center mr-2 px-2",children:[i&&(0,s.jsxs)("div",{className:"flex items-center",title:"Select/unselect the current row",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)(xl,{id:m,checked:o,onCheckedChange:b,className:"h-3.5 w-3.5"}),(0,s.jsx)("label",{htmlFor:m,className:"text-xs text-muted-foreground cursor-pointer",children:"Select"})]}),(0,s.jsx)(Ly,{shortcut:"Space",className:"scale-75"})]}),(0,s.jsx)(Pe,{variant:"outline",size:"xs",className:`${D} ml-auto`,onClick:()=>y(0),disabled:t===0,"aria-label":"Go to first row",children:(0,s.jsx)(X_,{})}),(0,s.jsx)(Pe,{variant:"outline",size:"xs",className:D,onClick:()=>y(t-1),disabled:t===0,"aria-label":"Previous row",children:(0,s.jsx)(Sl,{})}),(0,s.jsx)("span",{className:"text-xs",children:h?`Row ${t+1}`:`Row ${t+1} of ${K_(a,p)}`}),(0,s.jsx)(Pe,{variant:"outline",size:"xs",className:D,onClick:()=>y(t+1),disabled:!h&&t===a-1,"aria-label":"Next row",children:(0,s.jsx)(Si,{})}),(0,s.jsx)(Pe,{variant:"outline",size:"xs",className:D,onClick:()=>{h||y(a-1)},disabled:h||t===a-1,"aria-label":"Go to last row",children:(0,s.jsx)(z_,{})})]}),(0,s.jsx)(zy,{className:"bg-background",shouldFilter:!1,children:(0,s.jsx)(Vy,{placeholder:"Search",value:d,onValueChange:u,"data-testid":"selection-panel-search-input"})}),j()]})};function Uk({columnName:t,columnValue:e,searchQuery:a}){let r=t.toLowerCase(),n=a.toLowerCase(),i=typeof e=="object"?JSON.stringify(e):String(e);return i=i.toLowerCase(),r.includes(n)||i.includes(n)}var Eu=t=>{let e=(0,Hk.c)(8),{kind:a,Icon:r,message:n}=t,i;e[0]===r?i=e[1]:(i=(0,s.jsx)(r,{className:"w-5 h-5"}),e[0]=r,e[1]=i);let o;e[2]===n?o=e[3]:(o=(0,s.jsx)("span",{children:n}),e[2]=n,e[3]=o);let l;return e[4]!==a||e[5]!==i||e[6]!==o?(l=(0,s.jsxs)(Ar,{kind:a,className:"p-4 mx-3 mt-3 flex flex-row items-center gap-2",children:[i,o]}),e[4]=a,e[5]=i,e[6]=o,e[7]=l):l=e[7],l},Zk=te(),T1="text-[13px] uppercase tracking-wide font-semibold cursor-pointer transition-colors",_1="text-primary",A1="hover:text-foreground";const Kk=t=>{let e=(0,Zk.c)(45),{rowIdx:a,setRowIdx:r,totalRows:n,fieldTypes:i,getRow:o,isSelectable:l,isRowSelected:d,handleRowSelectionChange:u,previewColumn:c,totalColumns:m,tableId:p,showRowExplorer:h,showColumnExplorer:x,activeTab:g,onTabChange:y}=t,b=h&&x,w;e[0]!==i||e[1]!==o||e[2]!==u||e[3]!==d||e[4]!==l||e[5]!==a||e[6]!==r||e[7]!==n?(w=(0,s.jsx)(Wk,{rowIdx:a,setRowIdx:r,totalRows:n,fieldTypes:i,getRow:o,isSelectable:l,isRowSelected:d,handleRowSelectionChange:u}),e[0]=i,e[1]=o,e[2]=u,e[3]=d,e[4]=l,e[5]=a,e[6]=r,e[7]=n,e[8]=w):w=e[8];let D=w,j;e[9]!==i||e[10]!==c||e[11]!==p||e[12]!==m||e[13]!==n?(j=c&&(0,s.jsx)(zk,{previewColumn:c,fieldTypes:i,totalRows:n,totalColumns:m,tableId:p}),e[9]=i,e[10]=c,e[11]=p,e[12]=m,e[13]=n,e[14]=j):j=e[14];let C=j;if(!b)return h?D:x?C:null;let S=g??Rr.ROW_VIEWER,k;e[15]===y?k=e[16]:(k=B=>y(B),e[15]=y,e[16]=k);let v;e[17]===y?v=e[18]:(v=()=>y(Rr.ROW_VIEWER),e[17]=y,e[18]=v);let E=S===Rr.ROW_VIEWER?_1:A1,N;e[19]===E?N=e[20]:(N=Y(T1,E),e[19]=E,e[20]=N);let R;e[21]!==v||e[22]!==N?(R=(0,s.jsx)(Pe,{variant:"text",size:"xs",onClick:v,className:N,children:"Rows"}),e[21]=v,e[22]=N,e[23]=R):R=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=(0,s.jsx)("span",{className:"text-muted-foreground text-xs",children:"|"}),e[24]=_):_=e[24];let V;e[25]===y?V=e[26]:(V=()=>y(Rr.COLUMN_EXPLORER),e[25]=y,e[26]=V);let I=S===Rr.COLUMN_EXPLORER?_1:A1,A;e[27]===I?A=e[28]:(A=Y(T1,I),e[27]=I,e[28]=A);let T;e[29]!==A||e[30]!==V?(T=(0,s.jsx)(Pe,{variant:"text",size:"xs",onClick:V,className:A,children:"Explorer"}),e[29]=A,e[30]=V,e[31]=T):T=e[31];let P;e[32]!==T||e[33]!==R?(P=(0,s.jsx)(Y_,{name:kl.CONTEXT_AWARE_PANEL_HEADER,children:(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[R,_,T]})}),e[32]=T,e[33]=R,e[34]=P):P=e[34];let F;e[35]===D?F=e[36]:(F=(0,s.jsx)(Ut,{value:Rr.ROW_VIEWER,className:"flex-1 overflow-auto",children:D}),e[35]=D,e[36]=F);let O;e[37]===C?O=e[38]:(O=(0,s.jsx)(Ut,{value:Rr.COLUMN_EXPLORER,className:"flex-1 overflow-auto",children:C}),e[37]=C,e[38]=O);let z;return e[39]!==S||e[40]!==P||e[41]!==F||e[42]!==O||e[43]!==k?(z=(0,s.jsxs)(pn,{value:S,onValueChange:k,className:"flex flex-col min-w-[350px]",children:[P,F,O]}),e[39]=S,e[40]=P,e[41]=F,e[42]=O,e[43]=k,e[44]=z):z=e[44],z};var Yk=te();function qk(t,e){let a=(0,Yk.c)(2),r=(0,f.useRef)(!1),n;a[0]===t?n=a[1]:(n=()=>{if(!r.current){r.current=!0;return}t()},a[0]=t,a[1]=n),(0,f.useEffect)(n,e)}const Gk=["int8","int16","int32","int64","uint8","uint16","uint32","uint64","float16","float32","float64","complex64","complex128","bool","object","str","unicode","datetime64","timedelta64"],Ru=["count","sum","mean","median","min","max"];var $t={number:xT().describe(le.of({label:"Value"})),string:M().min(1).describe(le.of({label:"Value"})),stringColumnValues:M().min(1).describe(le.of({label:"Value",special:"column_values"})),stringMultiColumnValues:Q(M()).min(1).describe(le.of({label:"Value",special:"column_values"})),date:Sv().describe(le.of({label:"Value",special:"date"})),datetime:Sv().describe(le.of({label:"Value",special:"datetime"})),time:M().regex(/^\d{2}:\d{2}(:\d{2})?$/).describe(le.of({label:"Value",special:"time"}))};const Wo={is_true:[],is_false:[]};var Uo=t=>({"==":[t],"!=":[t],">":[t],">=":[t],"<":[t],"<=":[t],is_null:[],is_not_null:[]});const an=Uo($t.number),Zo=Uo($t.date),Ko=Uo($t.time),Yo=Uo($t.datetime),qo={equals:[$t.stringColumnValues],does_not_equal:[$t.stringColumnValues],contains:[$t.string],regex:[$t.string],starts_with:[$t.string],ends_with:[$t.string],in:[$t.stringMultiColumnValues],not_in:[$t.stringMultiColumnValues],is_null:[],is_not_null:[]},Qk={...Wo,...an,...Zo,...Ko,...Yo,...qo};function I1(t){return t?t.startsWith("int")?"integer":t.startsWith("float")||t.startsWith("uint")||t.startsWith("number")||t.startsWith("complex")?"number":t.startsWith("string")||t.startsWith("object")||t.startsWith("utf8")?"string":t.startsWith("datetime")?"datetime":t.startsWith("time")?"time":t.startsWith("date")?"date":t.startsWith("bool")?"boolean":"unknown":"unknown"}function P1(t){if(!t)return[];switch(I1(t)){case"integer":return Object.keys(an);case"number":return Object.keys(an);case"string":return Object.keys(qo);case"date":return Object.keys(Zo);case"datetime":return Object.keys(Yo);case"time":return Object.keys(Ko);case"boolean":return Object.keys(Wo);case"unknown":return[]}}function Jk(t,e){if(!t||!e)return[];switch(I1(t)){case"integer":return Nt(an,e);case"number":return Nt(an,e);case"string":return Nt(qo,e);case"date":return Nt(Zo,e);case"datetime":return Nt(Yo,e);case"time":return Nt(Ko,e);case"boolean":return Nt(Wo,e);case"unknown":return[]}}function Xk(t,e){let a=[Nt(Wo,t),Nt(Zo,t),Nt(Ko,t),Nt(Yo,t),Nt(an,t),Nt(qo,t)].flat();return a.length===0?!0:a.some(r=>r.safeParse(e).success)}var Nt=(t,e)=>t[e]?t[e]:[];const oi=Q(ra([kv(),ra([be(ko),M()])])),ha=M().min(1,"Required").or(H()).transform(t=>t).describe(le.of({label:"Column",special:"column_id"})),li=Q(ha.describe(le.of({special:"column_id"}))).min(1,"At least one column is required").default([]).describe(le.of({label:"Columns",minLength:1}));var eS=L({type:Ge("column_conversion"),column_id:ha,data_type:be(Gk).describe(le.of({label:"Data type (numpy)"})).default("bool"),errors:be(["ignore","raise"]).default("ignore").describe(le.of({label:"Handle errors",special:"radio_group"}))}).describe(le.of({})),tS=L({type:Ge("rename_column"),column_id:ha,new_column_id:M().min(1,"Required").transform(t=>t).describe(le.of({label:"New column name",minLength:1}))}),aS=L({type:Ge("sort_column"),column_id:ha,ascending:W().describe(le.of({label:"Ascending"})).default(!0),na_position:be(["first","last"]).describe(le.of({label:"N/A position",special:"radio_group"})).default("last")});const Nu=L({column_id:ha,operator:be(Object.keys(Qk)).describe(le.of({label:" "})),value:aa().describe(le.of({label:"Value"}))}).describe(le.of({direction:"row",special:"column_filter"}));var rS=L({type:Ge("filter_rows"),operation:be(["keep_rows","remove_rows"]).default("keep_rows").describe(le.of({special:"radio_group"})),where:Q(Nu).min(1).describe(le.of({label:"Value",minLength:1})).transform(t=>t.filter(e=>Xk(e.operator,e.value))).default(()=>[{column_id:"",operator:"==",value:""}])}),nS=L({type:Ge("group_by"),column_ids:Q(ha.describe(le.of({special:"column_id"}))).default([]).describe(le.of({label:"Group by columns",minLength:1})),aggregation_column_ids:Q(ha.describe(le.of({special:"column_id"}))).default([]).describe(le.of({label:"Aggregate on columns"})),aggregation:be(Ru).default("count").describe(le.of({label:"Aggregation"})),drop_na:W().default(!1).describe(le.of({label:"Drop N/A"}))}).describe(le.of({})),iS=L({type:Ge("aggregate"),column_ids:li,aggregations:Q(be(Ru)).min(1,"At least one aggregation is required").default(["count"]).describe(le.of({label:"Aggregations",minLength:1}))}).describe(le.of({direction:"row"}));const Tu=Se([rS,L({type:Ge("select_columns"),column_ids:li}),tS,eS,aS,nS,iS,L({type:Ge("sample_rows"),n:H().positive().describe(le.of({label:"Number of rows"})),seed:H().default(()=>Qv()).describe(le.of({label:"Re-sample",special:"random_number_button"})),replace:W().default(!1).describe(le.of({label:"Sample with replacement"}))}),L({type:Ge("shuffle_rows"),seed:H().default(()=>Qv()).describe(le.of({label:"Re-shuffle",special:"random_number_button"}))}),L({type:Ge("explode_columns"),column_ids:li}),L({type:Ge("expand_dict"),column_id:ha}),L({type:Ge("unique"),column_ids:li,keep:be(["first","last","none","any"]).default("first").describe(le.of({label:"Keep"}))}).describe(le.of({direction:"row"})),L({type:Ge("pivot"),column_ids:li,index_column_ids:Q(ha.describe(le.of({special:"column_id"}))).default([]).describe(le.of({label:"Rows"})),value_column_ids:Q(ha.describe(le.of({special:"column_id"}))).default([]).describe(le.of({label:"Values",minLength:1})),aggregation:be(Ru).default("sum").describe(le.of({label:"Aggregation"}))}).describe(le.of({}))]),oS=L({transforms:Q(Tu)});var _u=te(),lS=ey,Ea=Se([H(),gT(),M()]).nullable(),M1=L({total:H().nullable(),nulls:H().nullable(),unique:H().nullable(),true:H().nullable(),false:H().nullable(),min:Ea,max:Ea,std:Ea,mean:Ea,median:Ea,p5:Ea,p25:Ea,p75:Ea,p95:Ea}),sS=Q(L({bin_start:Se([H(),M(),Ev(Date)]),bin_end:Se([H(),M(),Ev(Date)]),count:H()})),dS=Q(L({value:M(),count:H()})),F1=bt(M(),bt(M(),M().nullable())).optional();const uS=zt("marimo-table").withData(L({initialValue:Se([Q(H()),Q(L({rowId:M(),columnName:M()}))]),label:M().nullable(),data:Se([M(),Q(L({}).passthrough())]),rawData:Se([M(),Q(Ga({}))]).nullish(),totalRows:Se([H(),Ge(fc)]),pagination:W().default(!1),pageSize:H().default(10),selection:be(["single","multi","single-cell","multi-cell"]).nullable().default(null),showDownload:W().default(!1),showFilters:W().default(!1),showColumnSummaries:Se([W(),be(["stats","chart"])]).default(!0),showDataTypes:W().default(!0),showPageSizeSelector:W().default(!0),showColumnExplorer:W().default(!0),showRowExplorer:W().default(!0),showChartBuilder:W().default(!0),rowHeaders:oi,freezeColumnsLeft:Q(M()).optional(),freezeColumnsRight:Q(M()).optional(),textJustifyColumns:bt(M(),be(["left","center","right"])).optional(),wrappedColumns:Q(M()).optional(),headerTooltip:bt(M(),M()).optional(),fieldTypes:oi.nullish(),totalColumns:H(),maxColumns:Se([H(),Ge("all")]).default("all"),hasStableRowId:W().default(!1),maxHeight:H().optional(),cellStyles:bt(M(),bt(M(),L({}).passthrough())).optional(),hoverTemplate:M().optional(),cellHoverTexts:F1,lazy:W().default(!1),preload:W().default(!1)})).withFunctions({download_as:N1,get_column_summaries:ut.input(Ga({})).output(L({data:Se([M(),Q(Ga({}))]).nullable(),stats:bt(M(),M1),bin_values:bt(M(),sS),value_counts:bt(M(),dS),show_charts:W(),is_disabled:W().optional()})),search:ut.input(L({sort:Q(L({by:M(),descending:W()})).optional(),query:M().optional(),filters:Q(Nu).optional(),page_number:H(),page_size:H(),max_columns:H().nullable().optional()})).output(L({data:Se([M(),Q(L({}).passthrough())]),total_rows:Se([H(),Ge(fc)]),cell_styles:bt(M(),bt(M(),L({}).passthrough())).nullable(),cell_hover_texts:F1.nullable(),raw_data:Se([M(),Q(Ga({}))]).nullish()})),get_row_ids:ut.input(L({}).passthrough()).output(L({row_ids:Q(H()),all_rows:W(),error:M().nullable()})),get_data_url:ut.input(L({}).passthrough()).output(L({data_url:Se([M(),Q(L({}).passthrough())]),format:be(["csv","json","arrow"])})),calculate_top_k_rows:ut.input(L({column:M(),k:H()})).output(L({data:Q(ra([aa(),H()]))})),preview_column:ut.input(L({column:M()})).output(L({chart_spec:M().nullable(),chart_code:M().nullable(),error:M().nullable(),missing_packages:Q(M()).nullable(),stats:M1.nullable()}))}).renderer(t=>(0,s.jsx)(z1,{children:(0,s.jsx)(pS,{isLazy:t.data.lazy,preload:t.data.preload,host:t.host,children:(0,s.jsx)(Au,{...t.data,...t.functions,host:t.host,enableSearch:!0,data:t.data.data,value:t.value,setValue:t.setValue,cellHoverTexts:t.data.cellHoverTexts})})}));var V1=new Map;function cS(t,e){return t!=null&&e!=null&&V1.get(t)===e}function mS(t,e){t!=null&&e!=null&&V1.set(t,e)}var pS=t=>{var p;let e=(0,_u.c)(13),{isLazy:a,children:r,preload:n,host:i}=t,o,l,d,u;if(e[0]!==i||e[1]!==a||e[2]!==n){let h=i.closest(`[${YN}]`);u=h?un.parse(h):null,o=(p=i.closest(`[${Sr}]`))==null?void 0:p.getAttribute(Sr),l=f.useState,d=a&&!n&&!cS(u,o),e[0]=i,e[1]=a,e[2]=n,e[3]=o,e[4]=l,e[5]=d,e[6]=u}else o=e[3],l=e[4],d=e[5],u=e[6];let[c,m]=l(d);if(c){let h;e[7]!==o||e[8]!==u?(h=()=>{mS(u,o),m(!1)},e[7]=o,e[8]=u,e[9]=h):h=e[9];let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=(0,s.jsx)(wv,{className:"mr-2 h-4 w-4"}),e[10]=x):x=e[10];let g;return e[11]===h?g=e[12]:(g=(0,s.jsx)("div",{className:"flex h-20 items-center justify-center",children:(0,s.jsxs)(Pe,{variant:"outline",size:"xs",onClick:h,children:[x,"Preview data"]})}),e[11]=h,e[12]=g),g}return r};const Au=(0,f.memo)(t=>{let e=(0,_u.c)(104),a;e[0]===t.host?a=e[1]:(a=dT(t.host),e[0]=t.host,e[1]=a);let r=a,n=t.search,i=t.setValue,o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[2]=o):o=e[2];let[l,d]=(0,f.useState)(o),u;e[3]===t.pageSize?u=e[4]:(u={pageSize:t.pageSize,pageIndex:0},e[3]=t.pageSize,e[4]=u);let[c,m]=f.useState(u),[p,h]=(0,f.useState)(""),x;e[5]===Symbol.for("react.memo_cache_sentinel")?(x=[],e[5]=x):x=e[5];let[g,y]=(0,f.useState)(x),b;e[6]!==r||e[7]!==t.showChartBuilder?(b=()=>!t.showChartBuilder||!r?!1:kk(r),e[6]=r,e[7]=t.showChartBuilder,e[8]=b):b=e[8];let[w,D]=(0,f.useState)(b),j;e[9]!==t.hasStableRowId||e[10]!==i?(j=()=>{t.hasStableRowId||i([])},e[9]=t.hasStableRowId,e[10]=i,e[11]=j):j=e[11];let C;e[12]!==g||e[13]!==t.hasStableRowId||e[14]!==p||e[15]!==i||e[16]!==l?(C=[i,g,p,l,t.hasStableRowId],e[12]=g,e[13]=t.hasStableRowId,e[14]=p,e[15]=i,e[16]=l,e[17]=C):C=e[17],qk(j,C);let S,k;e[18]===t.pageSize?(S=e[19],k=e[20]):(S=()=>{m({pageIndex:0,pageSize:t.pageSize})},k=[t.pageSize],e[18]=t.pageSize,e[19]=S,e[20]=k),(0,f.useEffect)(S,k);let v;e[21]!==g||e[22]!==c.pageIndex||e[23]!==c.pageSize||e[24]!==t.cellHoverTexts||e[25]!==t.cellStyles||e[26]!==t.data||e[27]!==t.lazy||e[28]!==t.pageSize||e[29]!==t.rawData||e[30]!==t.totalRows||e[31]!==n||e[32]!==p||e[33]!==l?(v=async()=>{if(t.totalRows===0)return{rows:Aa.EMPTY,totalRows:0,cellStyles:{}};let Ne=t.data,Ae=t.rawData,pt=t.totalRows,ot=t.cellStyles,Bt=t.cellHoverTexts,ta=c.pageSize!==t.pageSize,Ht=p===""&&c.pageIndex===0&&g.length===0&&l.length===0&&!t.lazy&&!ta,qa=n({sort:l.length>0?l.map(fS):void 0,query:p,page_number:c.pageIndex,page_size:c.pageSize,filters:g.flatMap(gS)});if(Ht)qa.catch(xS);else{let Wt=await qa;Ne=Wt.data,Ae=Wt.raw_data,pt=Wt.total_rows,ot=Wt.cell_styles||{},Bt=Wt.cell_hover_texts||{}}let[Cr,kr]=await P_(Ne,Ae);return Ne=Cr,{rows:Ne,rawRows:kr,totalRows:pt,cellStyles:ot,cellHoverTexts:Bt}},e[21]=g,e[22]=c.pageIndex,e[23]=c.pageSize,e[24]=t.cellHoverTexts,e[25]=t.cellStyles,e[26]=t.data,e[27]=t.lazy,e[28]=t.pageSize,e[29]=t.rawData,e[30]=t.totalRows,e[31]=n,e[32]=p,e[33]=l,e[34]=v):v=e[34];let E=sr(t.fieldTypes),N;e[35]!==g||e[36]!==c.pageIndex||e[37]!==c.pageSize||e[38]!==t.cellHoverTexts||e[39]!==t.cellStyles||e[40]!==t.data||e[41]!==t.lazy||e[42]!==t.totalRows||e[43]!==n||e[44]!==p||e[45]!==l||e[46]!==E?(N=[l,n,g,p,E,t.data,t.totalRows,t.lazy,t.cellHoverTexts,t.cellStyles,c.pageSize,c.pageIndex],e[35]=g,e[36]=c.pageIndex,e[37]=c.pageSize,e[38]=t.cellHoverTexts,e[39]=t.cellStyles,e[40]=t.data,e[41]=t.lazy,e[42]=t.totalRows,e[43]=n,e[44]=p,e[45]=l,e[46]=E,e[47]=N):N=e[47];let{data:R,error:_,isPending:V,isFetching:I}=Yt(v,N),A;e[48]!==g||e[49]!==n||e[50]!==p||e[51]!==l?(A=async Ne=>({rows:await aA((await n({page_number:Ne,page_size:1,sort:l.length>0?l.map(vS):void 0,query:p,filters:g.flatMap(yS),max_columns:null})).data)}),e[48]=g,e[49]=n,e[50]=p,e[51]=l,e[52]=A):A=e[52];let T=A,P;e[53]===Symbol.for("react.memo_cache_sentinel")?(P=()=>{m(bS)},e[53]=P):P=e[53];let F=R==null?void 0:R.totalRows,O;e[54]===F?O=e[55]:(O=[F],e[54]=F,e[55]=O),(0,f.useEffect)(P,O);let z;e[56]===t?z=e[57]:(z=async()=>t.totalRows===0||!t.showColumnSummaries?{data:null,stats:{},bin_values:{},value_counts:{},show_charts:!1}:t.get_column_summaries({}),e[56]=t,e[57]=z);let B;e[58]!==g||e[59]!==t.data||e[60]!==t.get_column_summaries||e[61]!==t.showColumnSummaries||e[62]!==t.totalRows||e[63]!==p?(B=[t.get_column_summaries,t.showColumnSummaries,g,p,t.totalRows,t.data],e[58]=g,e[59]=t.data,e[60]=t.get_column_summaries,e[61]=t.showColumnSummaries,e[62]=t.totalRows,e[63]=p,e[64]=B):B=e[64];let{data:J,error:ee}=Yt(z,B),X,se;if(e[65]===ee?(X=e[66],se=e[67]):(X=()=>{ee&&de.error(ee)},se=[ee],e[65]=ee,e[66]=X,e[67]=se),(0,f.useEffect)(X,se),V){let Ne=t.totalRows!=="too_many"&&t.totalRows>0?t.totalRows:t.pageSize,Ae;return e[68]===Ne?Ae=e[69]:(Ae=(0,s.jsx)(gc,{milliseconds:200,children:(0,s.jsx)(px,{pageSize:Ne})}),e[68]=Ne,e[69]=Ae),Ae}let pe=null;if(_){de.error(_);let Ne;e[70]===_?Ne=e[71]:(Ne=!ji()&&(0,s.jsxs)(Yl,{variant:"destructive",className:"mb-2",children:[(0,s.jsx)(Oc,{children:"Error"}),(0,s.jsx)("div",{className:"text-md",children:_.message||"An unknown error occurred"})]}),e[70]=_,e[71]=Ne),pe=Ne}let G;e[72]===w?G=e[73]:(G=()=>{D(!w)},e[72]=w,e[73]=G);let $=G,ie=(R==null?void 0:R.rows)??Aa.EMPTY,re=R==null?void 0:R.rawRows,oe=I&&!V,ge=(R==null?void 0:R.totalRows)??t.totalRows,he=(R==null?void 0:R.cellStyles)??t.cellStyles,me=(R==null?void 0:R.cellHoverTexts)??t.cellHoverTexts,De;e[74]!==r||e[75]!==J||e[76]!==w||e[77]!==g||e[78]!==T||e[79]!==c||e[80]!==t||e[81]!==p||e[82]!==l||e[83]!==ie||e[84]!==re||e[85]!==oe||e[86]!==ge||e[87]!==he||e[88]!==me||e[89]!==$?(De=(0,s.jsx)(hS,{...t,data:ie,rawData:re,columnSummaries:J,sorting:l,setSorting:d,searchQuery:p,setSearchQuery:h,filters:g,setFilters:y,reloading:oe,totalRows:ge,paginationState:c,setPaginationState:m,cellStyles:he,cellHoverTexts:me,toggleDisplayHeader:$,isChartBuilderOpen:w,getRow:T,cellId:r,maxHeight:t.maxHeight}),e[74]=r,e[75]=J,e[76]=w,e[77]=g,e[78]=T,e[79]=c,e[80]=t,e[81]=p,e[82]=l,e[83]=ie,e[84]=re,e[85]=oe,e[86]=ge,e[87]=he,e[88]=me,e[89]=$,e[90]=De):De=e[90];let Le=De,je;e[91]!==r||e[92]!==Le||e[93]!==(R==null?void 0:R.rows)||e[94]!==w||e[95]!==t.fieldTypes||e[96]!==t.get_data_url||e[97]!==t.showChartBuilder||e[98]!==t.totalColumns||e[99]!==t.totalRows?(je=t.showChartBuilder?(0,s.jsx)(Nk,{displayHeader:w,onCloseChartBuilder:()=>D(!1),data:(R==null?void 0:R.rows)||[],columns:t.totalColumns,totalRows:t.totalRows,dataTable:Le,getDataUrl:t.get_data_url,fieldTypes:t.fieldTypes,cellId:r}):Le,e[91]=r,e[92]=Le,e[93]=R==null?void 0:R.rows,e[94]=w,e[95]=t.fieldTypes,e[96]=t.get_data_url,e[97]=t.showChartBuilder,e[98]=t.totalColumns,e[99]=t.totalRows,e[100]=je):je=e[100];let Ye;return e[101]!==pe||e[102]!==je?(Ye=(0,s.jsxs)(s.Fragment,{children:[pe,je]}),e[101]=pe,e[102]=je,e[103]=Ye):Ye=e[103],Ye});Au.displayName="LoadingDataTableComponent";var hS=({label:t,data:e,rawData:a,totalRows:r,maxColumns:n,pagination:i,selection:o,value:l,showFilters:d,showDownload:u,showPageSizeSelector:c,showColumnExplorer:m,showRowExplorer:p,showChartBuilder:h,showDataTypes:x,rowHeaders:g,fieldTypes:y,paginationState:b,setPaginationState:w,download_as:D,columnSummaries:j,className:C,setValue:S,sorting:k,setSorting:v,enableSearch:E,searchQuery:N,setSearchQuery:R,filters:_,setFilters:V,reloading:I,freezeColumnsLeft:A,freezeColumnsRight:T,textJustifyColumns:P,wrappedColumns:F,headerTooltip:O,totalColumns:z,get_row_ids:B,cellStyles:J,hoverTemplate:ee,cellHoverTexts:X,toggleDisplayHeader:se,isChartBuilderOpen:pe,calculate_top_k_rows:G,preview_column:$,getRow:ie,cellId:re,maxHeight:oe})=>{let ge=(0,f.useId)(),[he,me]=(0,f.useState)(0),{isPanelOpen:De,isAnyPanelOpen:Le,togglePanel:je,panelType:Ye,setPanelType:Ne}=Mk(ge,re),Ae=(0,f.useMemo)(()=>{if(!j||!y||!j.stats)return Wv.EMPTY;let qe=xc(y);return new Wv(j.data||[],qe,j.stats,j.bin_values,j.value_counts,{includeCharts:j.show_charts})},[y,j]),pt=sr(y??vc(e)),ot=(0,f.useMemo)(()=>n==="all"?pt:pt.slice(0,n),[n,pt]),Bt=(0,f.useMemo)(()=>{let qe={};if(e&&e.length>0){for(let[Ra,Qu]of ot)if(Qu[0]==="number"){let Ju=0;for(let zN of e){let Xu=zN[Ra];if(typeof Xu=="number"&&Number.isFinite(Xu)){let mv=String(Xu),pv=mv.indexOf(".");pv!==-1&&(Ju=Math.max(Ju,mv.length-pv-1))}}qe[Ra]=Ju}}return qe},[e,ot]),ta=sr(g),Ht=sr(P),qa=sr(F),Cr=sr(Ae),kr=sr(Bt),Wt=ot.length;y||(x=!1);let pl=(0,f.useMemo)(()=>A_({rowHeaders:ta,selection:o,chartSpecModel:Cr,fieldTypes:ot,textJustifyColumns:Ht,wrappedColumns:qa,headerTooltip:O,showDataTypes:x,calculateTopKRows:G,fractionDigitsByColumn:kr}),[o,x,Cr,ta,ot,Ht,qa,O,G,kr]),Ku=(0,f.useMemo)(()=>Object.fromEntries((l||[]).map(qe=>[qe,!0])),[l]),cv=Ue(qe=>{if(o==="single"){let Ra=Xa.asUpdater(qe)({});S(Object.keys(Ra).slice(0,1))}if(o==="multi"){let Ra=Xa.asUpdater(qe)(Ku);S(Object.keys(Ra))}}),MN=Ue(qe=>{if(me(qe),qe<0||typeof r=="number"&&qe>=r||r==="too_many")return;let Ra=__(qe,b.pageIndex,b.pageSize);Ra!==null&&w(Qu=>({...Qu,pageIndex:Ra}))}),Yu=l.filter(qe=>qe instanceof Object&&qe.columnName!==void 0),FN=Ue(qe=>{o==="single-cell"&&S(Xa.asUpdater(qe)(Yu).slice(0,1)),o==="multi-cell"&&S(Xa.asUpdater(qe)(Yu))}),VN=o==="multi"||o==="single",qu=m&&!!$,Gu=e_();return(0,s.jsxs)(s.Fragment,{children:[r==="too_many"&&b.pageSize===e.length&&(0,s.jsxs)(Ar,{className:"mb-1 rounded",children:["Previewing the first ",b.pageSize," rows."]}),Wt<z&&Wt>0&&(0,s.jsxs)(Ar,{className:"mb-1 rounded",children:["Result clipped. Showing ",Wt," of ",z," columns."]}),(j==null?void 0:j.is_disabled)&&(0,s.jsx)(Ar,{className:"mb-1 rounded",children:"Column summaries are unavailable. Filter your data to fewer than 1,000,000 rows."}),Le&&(p||qu)&&(0,s.jsx)(J_,{children:(0,s.jsx)(Kk,{rowIdx:he,setRowIdx:MN,totalRows:r,fieldTypes:pt,getRow:ie,isSelectable:VN,isRowSelected:!!Ku[he],handleRowSelectionChange:cv,previewColumn:$,totalColumns:z,tableId:ge,showRowExplorer:p&&!Gu,showColumnExplorer:qu&&!Gu,activeTab:Ye,onTabChange:Ne})}),(0,s.jsx)(Z_,{value:Ae,children:(0,s.jsx)(et,{label:t,align:"top",fullWidth:!0,children:(0,s.jsx)(Q_,{data:e,rawData:a,columns:pl,className:C,maxHeight:oe,sorting:k,totalRows:r,totalColumns:z,manualSorting:!0,setSorting:v,pagination:i,manualPagination:!0,selection:o,paginationState:b,setPaginationState:w,rowSelection:Ku,cellSelection:Yu,cellStyling:J,hoverTemplate:ee,cellHoverTexts:X,downloadAs:u?D:void 0,enableSearch:E,searchQuery:N,onSearchQueryChange:R,showFilters:d,filters:_,onFiltersChange:V,reloading:I,onRowSelectionChange:cv,freezeColumnsLeft:A,freezeColumnsRight:T,onCellSelectionChange:FN,getRowIds:B,toggleDisplayHeader:se,showChartBuilder:h,isChartBuilderOpen:pe,showPageSizeSelector:c,showTableExplorer:(p||qu)&&!Gu,togglePanel:je,isPanelOpen:De,isAnyPanelOpen:Le,viewedRowIdx:he,onViewedRowChange:qe=>me(qe)})})})]})};const z1=t=>{let e=(0,_u.c)(2),{children:a}=t,r;return e[0]===a?r=e[1]:(r=(0,s.jsx)(yl,{children:(0,s.jsx)(hl,{store:$e,children:(0,s.jsx)(qv,{controller:Di,children:(0,s.jsx)(lS,{children:a})})})}),e[0]=a,e[1]=r),r};function fS(t){return{by:t.id,descending:t.desc}}function gS(t){return Zv(t.id,t.value)}function xS(t){de.error(t)}function vS(t){return{by:t.id,descending:t.desc}}function yS(t){return Zv(t.id,t.value)}function bS(t){return t.pageIndex===0?t:{...t,pageIndex:0}}var wS=te(),DS=t=>{let e=(0,wS.c)(10),a,r,n;e[0]===t?(a=e[1],r=e[2],n=e[3]):({className:a,offset:n,...r}=t,e[0]=t,e[1]=a,e[2]=r,e[3]=n);let i=n===void 0?4:n,o;e[4]===a?o=e[5]:(o=Pa(a,jS),e[4]=a,e[5]=o);let l;return e[6]!==i||e[7]!==r||e[8]!==o?(l=(0,s.jsx)(CD,{offset:i,className:o,...r}),e[6]=i,e[7]=r,e[8]=o,e[9]=l):l=e[9],l};function jS(t){return Y("z-50 rounded-md border bg-popover text-popover-foreground shadow-md outline-hidden","data-entering:animate-in data-entering:fade-in-0 data-entering:zoom-in-95","data-exiting:animate-out data-exiting:fade-out-0 data-exiting:zoom-out-95","data-[placement=bottom]:slide-in-from-top-2 data-[placement=left]:slide-in-from-right-2 data-[placement=right]:slide-in-from-left-2 data-[placement=top]:slide-in-from-bottom-2",t)}var Ka=te(),Go=t=>{let e=(0,Ka.c)(11),{direction:a}=rt(),r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=Y(rr({variant:"outline"}),"size-7 bg-transparent p-0 opacity-50","data-hovered:opacity-100"),e[0]=r):r=e[0];let n;e[1]===a?n=e[2]:(n=(0,s.jsx)(Pl,{slot:"previous",className:r,children:a==="rtl"?(0,s.jsx)(Si,{"aria-hidden":!0,className:"size-4"}):(0,s.jsx)(Sl,{"aria-hidden":!0,className:"size-4"})}),e[1]=a,e[2]=n);let i;e[3]===Symbol.for("react.memo_cache_sentinel")?(i=(0,s.jsx)(LD,{className:"grow text-center text-sm font-medium"}),e[3]=i):i=e[3];let o;e[4]===Symbol.for("react.memo_cache_sentinel")?(o=Y(rr({variant:"outline"}),"size-7 bg-transparent p-0 opacity-50","data-hovered:opacity-100"),e[4]=o):o=e[4];let l;e[5]===a?l=e[6]:(l=(0,s.jsx)(Pl,{slot:"next",className:o,children:a==="rtl"?(0,s.jsx)(Sl,{"aria-hidden":!0,className:"size-4"}):(0,s.jsx)(Si,{"aria-hidden":!0,className:"size-4"})}),e[5]=a,e[6]=l);let d;return e[7]!==t||e[8]!==n||e[9]!==l?(d=(0,s.jsxs)("header",{className:"flex w-full items-center gap-1 px-1 pb-4",...t,children:[n,i,l]}),e[7]=t,e[8]=n,e[9]=l,e[10]=d):d=e[10],d},Qo=t=>{let e=(0,Ka.c)(8),a,r;e[0]===t?(a=e[1],r=e[2]):({className:a,...r}=t,e[0]=t,e[1]=a,e[2]=r);let n;e[3]===a?n=e[4]:(n=Y(" border-separate border-spacing-x-0 border-spacing-y-1 ",a),e[3]=a,e[4]=n);let i;return e[5]!==r||e[6]!==n?(i=(0,s.jsx)(vD,{className:n,...r}),e[5]=r,e[6]=n,e[7]=i):i=e[7],i},Jo=t=>{let e=(0,Ka.c)(4),a;e[0]===t?a=e[1]:({...a}=t,e[0]=t,e[1]=a);let r;return e[2]===a?r=e[3]:(r=(0,s.jsx)(V0,{...a}),e[2]=a,e[3]=r),r},Xo=t=>{let e=(0,Ka.c)(8),a,r;e[0]===t?(a=e[1],r=e[2]):({className:a,...r}=t,e[0]=t,e[1]=a,e[2]=r);let n;e[3]===a?n=e[4]:(n=Y("w-9 rounded-md text-[0.8rem] font-normal text-muted-foreground",a),e[3]=a,e[4]=n);let i;return e[5]!==r||e[6]!==n?(i=(0,s.jsx)(z0,{className:n,...r}),e[5]=r,e[6]=n,e[7]=i):i=e[7],i},el=t=>{let e=(0,Ka.c)(8),a,r;e[0]===t?(a=e[1],r=e[2]):({className:a,...r}=t,e[0]=t,e[1]=a,e[2]=r);let n;e[3]===a?n=e[4]:(n=Y("[&>tr>td]:p-0",a),e[3]=a,e[4]=n);let i;return e[5]!==r||e[6]!==n?(i=(0,s.jsx)(O0,{className:n,...r}),e[5]=r,e[6]=n,e[7]=i):i=e[7],i},tl=t=>{let e=(0,Ka.c)(11),a,r;e[0]===t?(a=e[1],r=e[2]):({className:a,...r}=t,e[0]=t,e[1]=a,e[2]=r);let n=!!f.use(Un),i;e[3]===n?i=e[4]:(i=(d,u)=>Y(rr({variant:"ghost"}),"relative flex size-9 items-center justify-center p-0 text-sm font-normal",u.isDisabled&&"text-muted-foreground opacity-50",u.isSelected&&"bg-primary text-primary-foreground data-focused:bg-primary data-focused:text-primary-foreground",u.isHovered&&u.isSelected&&(u.isSelectionStart||u.isSelectionEnd||!n)&&"data-hovered:bg-primary data-hovered:text-primary-foreground",u.isSelected&&n&&!u.isSelectionStart&&!u.isSelectionEnd&&"rounded-none bg-accent text-accent-foreground",u.isOutsideMonth&&"text-muted-foreground opacity-50 data-selected:bg-accent/50 data-selected:text-muted-foreground data-selected:opacity-30",u.date.compare(eo(In()))===0&&!u.isSelected&&"bg-accent text-accent-foreground",u.isUnavailable&&"cursor-default text-destructive ",u.isInvalid&&"bg-destructive text-destructive-foreground data-focused:bg-destructive data-hovered:bg-destructive data-focused:text-destructive-foreground data-hovered:text-destructive-foreground",d),e[3]=n,e[4]=i);let o;e[5]!==a||e[6]!==i?(o=Pa(a,i),e[5]=a,e[6]=i,e[7]=o):o=e[7];let l;return e[8]!==r||e[9]!==o?(l=(0,s.jsx)(DD,{className:o,...r}),e[8]=r,e[9]=o,e[10]=l):l=e[10],l},CS=t=>{let e=(0,Ka.c)(14),a,r,n;e[0]===t?(a=e[1],r=e[2],n=e[3]):({errorMessage:r,className:a,...n}=t,e[0]=t,e[1]=a,e[2]=r,e[3]=n);let i;e[4]===a?i=e[5]:(i=Pa(a,SS),e[4]=a,e[5]=i);let o;e[6]===Symbol.for("react.memo_cache_sentinel")?(o=(0,s.jsx)(Go,{}),e[6]=o):o=e[6];let l;e[7]===Symbol.for("react.memo_cache_sentinel")?(l=(0,s.jsxs)(Qo,{children:[(0,s.jsx)(Jo,{children:ES}),(0,s.jsx)(el,{children:RS})]}),e[7]=l):l=e[7];let d;e[8]===r?d=e[9]:(d=r&&(0,s.jsx)(Fl,{className:"text-sm text-destructive",slot:"errorMessage",children:r}),e[8]=r,e[9]=d);let u;return e[10]!==n||e[11]!==i||e[12]!==d?(u=(0,s.jsxs)(gD,{className:i,...n,children:[o,l,d]}),e[10]=n,e[11]=i,e[12]=d,e[13]=u):u=e[13],u},kS=t=>{let e=(0,Ka.c)(14),a,r,n;e[0]===t?(a=e[1],r=e[2],n=e[3]):({errorMessage:r,className:a,...n}=t,e[0]=t,e[1]=a,e[2]=r,e[3]=n);let i;e[4]===a?i=e[5]:(i=Pa(a,NS),e[4]=a,e[5]=i);let o;e[6]===Symbol.for("react.memo_cache_sentinel")?(o=(0,s.jsx)(Go,{}),e[6]=o):o=e[6];let l;e[7]===Symbol.for("react.memo_cache_sentinel")?(l=(0,s.jsxs)(Qo,{children:[(0,s.jsx)(Jo,{children:TS}),(0,s.jsx)(el,{children:_S})]}),e[7]=l):l=e[7];let d;e[8]===r?d=e[9]:(d=r&&(0,s.jsx)(Fl,{slot:"errorMessage",className:"text-sm text-destructive",children:r}),e[8]=r,e[9]=d);let u;return e[10]!==n||e[11]!==i||e[12]!==d?(u=(0,s.jsxs)(xD,{className:i,...n,children:[o,l,d]}),e[10]=n,e[11]=i,e[12]=d,e[13]=u):u=e[13],u};function SS(t){return Y("w-fit",t)}function ES(t){return(0,s.jsx)(Xo,{children:t})}function RS(t){return(0,s.jsx)(tl,{date:t})}function NS(t){return Y("w-fit",t)}function TS(t){return(0,s.jsx)(Xo,{children:t})}function _S(t){return(0,s.jsx)(tl,{date:t})}var O1=te(),AS=t=>{let e=(0,O1.c)(8),a,r;e[0]===t?(a=e[1],r=e[2]):({className:a,...r}=t,e[0]=t,e[1]=a,e[2]=r);let n;e[3]===a?n=e[4]:(n=Pa(a,IS),e[3]=a,e[4]=n);let i;return e[5]!==r||e[6]!==n?(i=(0,s.jsx)(ID,{className:n,...r}),e[5]=r,e[6]=n,e[7]=i):i=e[7],i},Iu=t=>{let e=(0,O1.c)(12),a,r,n;e[0]===t?(a=e[1],r=e[2],n=e[3]):({className:a,variant:n,...r}=t,e[0]=t,e[1]=a,e[2]=r,e[3]=n);let i;e[4]===n?i=e[5]:(i=d=>Y(wI({variant:n}),"text-sm",d),e[4]=n,e[5]=i);let o;e[6]!==a||e[7]!==i?(o=Pa(a,i),e[6]=a,e[7]=i,e[8]=o):o=e[8];let l;return e[9]!==r||e[10]!==o?(l=(0,s.jsx)(_D,{className:o,...r,children:PS}),e[9]=r,e[10]=o,e[11]=l):l=e[11],l};function IS(t){return Y("type-literal:px-0 inline rounded p-0.5 caret-transparent outline-solid outline-0","data-placeholder:text-muted-foreground","data-disabled:cursor-not-allowed data-disabled:opacity-50","data-focused:bg-accent data-focused:text-accent-foreground focus:bg-accent focus:text-accent-foreground","data-invalid:data-focused:bg-destructive data-invalid:data-focused:data-placeholder:text-destructive-foreground data-invalid:data-focused:text-destructive-foreground data-invalid:data-placeholder:text-destructive data-invalid:text-destructive",t)}function PS(t){return(0,s.jsx)(AS,{segment:t})}var Pu=te(),L1=t=>{let e=(0,Pu.c)(14),a,r,n;e[0]===t?(a=e[1],r=e[2],n=e[3]):({className:a,popoverClassName:r,...n}=t,e[0]=t,e[1]=a,e[2]=r,e[3]=n);let i;e[4]===r?i=e[5]:(i=Pa(r,FS),e[4]=r,e[5]=i);let o;e[6]===a?o=e[7]:(o=Y("flex w-full flex-col space-y-4 outline-hidden sm:flex-row sm:space-x-4 sm:space-y-0",a),e[6]=a,e[7]=o);let l;e[8]!==n||e[9]!==o?(l=(0,s.jsx)(SD,{className:o,...n}),e[8]=n,e[9]=o,e[10]=l):l=e[10];let d;return e[11]!==i||e[12]!==l?(d=(0,s.jsx)(DS,{className:i,children:l}),e[11]=i,e[12]=l,e[13]=d):d=e[13],d},$1=t=>{let e=(0,Pu.c)(26),a,r,n,i,o;e[0]===t?(a=e[1],r=e[2],n=e[3],i=e[4],o=e[5]):({label:i,description:r,errorMessage:n,className:a,...o}=t,e[0]=t,e[1]=a,e[2]=r,e[3]=n,e[4]=i,e[5]=o);let[l,d]=(0,f.useState)(!1),u;e[6]===a?u=e[7]:(u=Pa(a,VS),e[6]=a,e[7]=u);let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=D=>{d(D)},e[8]=c):c=e[8];let m;e[9]===i?m=e[10]:(m=i&&(0,s.jsx)(By,{children:i}),e[9]=i,e[10]=m);let p;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=(0,s.jsx)(Iu,{"aria-label":"date input",className:"flex-1",variant:"ghost"}),e[11]=p):p=e[11];let h;e[12]===Symbol.for("react.memo_cache_sentinel")?(h=(0,s.jsxs)(Hy,{children:[p,(0,s.jsx)(Pl,{onPressChange:()=>{d(!0)},className:Y(rr({variant:"text",size:"icon"}),"ml-1 size-6 data-focus-visible:ring-offset-0"),children:(0,s.jsx)(Ec,{"aria-hidden":!0,className:"size-4"})})]}),e[12]=h):h=e[12];let x;e[13]===r?x=e[14]:(x=r&&(0,s.jsx)(Fl,{className:"text-sm text-muted-foreground",slot:"description",children:r}),e[13]=r,e[14]=x);let g;e[15]===n?g=e[16]:(g=(0,s.jsx)(Wy,{children:n}),e[15]=n,e[16]=g);let y;e[17]===Symbol.for("react.memo_cache_sentinel")?(y=(0,s.jsx)(Go,{}),e[17]=y):y=e[17];let b;e[18]===Symbol.for("react.memo_cache_sentinel")?(b=(0,s.jsx)(L1,{children:(0,s.jsxs)(CS,{children:[y,(0,s.jsxs)(Qo,{children:[(0,s.jsx)(Jo,{children:zS}),(0,s.jsx)(el,{children:OS})]})]})}),e[18]=b):b=e[18];let w;return e[19]!==l||e[20]!==o||e[21]!==u||e[22]!==m||e[23]!==x||e[24]!==g?(w=(0,s.jsxs)(zD,{isOpen:l,className:u,onOpenChange:c,...o,children:[m,h,x,g,b]}),e[19]=l,e[20]=o,e[21]=u,e[22]=m,e[23]=x,e[24]=g,e[25]=w):w=e[25],w},MS=t=>{let e=(0,Pu.c)(28),a,r,n,i,o;e[0]===t?(a=e[1],r=e[2],n=e[3],i=e[4],o=e[5]):({label:i,description:r,errorMessage:n,className:a,...o}=t,e[0]=t,e[1]=a,e[2]=r,e[3]=n,e[4]=i,e[5]=o);let[l,d]=(0,f.useState)(!1),u;e[6]===a?u=e[7]:(u=Pa(a,LS),e[6]=a,e[7]=u);let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=C=>{d(C)},e[8]=c):c=e[8];let m;e[9]===i?m=e[10]:(m=i&&(0,s.jsx)(By,{children:i}),e[9]=i,e[10]=m);let p,h,x;e[11]===Symbol.for("react.memo_cache_sentinel")?(p=(0,s.jsx)(Iu,{variant:"ghost",slot:"start"}),h=(0,s.jsx)("span",{"aria-hidden":!0,className:"px-2 text-sm text-muted-foreground",children:"-"}),x=(0,s.jsx)(Iu,{className:"flex-1",variant:"ghost",slot:"end"}),e[11]=p,e[12]=h,e[13]=x):(p=e[11],h=e[12],x=e[13]);let g;e[14]===Symbol.for("react.memo_cache_sentinel")?(g=(0,s.jsxs)(Hy,{children:[p,h,x,(0,s.jsx)(Pl,{onPressChange:()=>{d(!0)},className:Y(rr({variant:"text",size:"icon"}),"ml-1 size-6 data-focus-visible:ring-offset-0"),children:(0,s.jsx)(Ec,{"aria-hidden":!0,className:"size-4"})})]}),e[14]=g):g=e[14];let y;e[15]===r?y=e[16]:(y=r&&(0,s.jsx)(Fl,{className:"text-sm text-muted-foreground",slot:"description",children:r}),e[15]=r,e[16]=y);let b;e[17]===n?b=e[18]:(b=(0,s.jsx)(Wy,{children:n}),e[17]=n,e[18]=b);let w;e[19]===Symbol.for("react.memo_cache_sentinel")?(w=(0,s.jsx)(Go,{}),e[19]=w):w=e[19];let D;e[20]===Symbol.for("react.memo_cache_sentinel")?(D=(0,s.jsx)(L1,{children:(0,s.jsxs)(kS,{children:[w,(0,s.jsxs)(Qo,{children:[(0,s.jsx)(Jo,{children:$S}),(0,s.jsx)(el,{children:BS})]})]})}),e[20]=D):D=e[20];let j;return e[21]!==l||e[22]!==o||e[23]!==u||e[24]!==m||e[25]!==y||e[26]!==b?(j=(0,s.jsxs)(OD,{isOpen:l,className:u,onOpenChange:c,...o,children:[m,g,y,b,D]}),e[21]=l,e[22]=o,e[23]=u,e[24]=m,e[25]=y,e[26]=b,e[27]=j):j=e[27],j};function FS(t){return Y("w-auto p-3",t)}function VS(t){return Y("group flex flex-col gap-2",t)}function zS(t){return(0,s.jsx)(Xo,{children:t})}function OS(t){return(0,s.jsx)(tl,{date:t})}function LS(t){return Y("group flex flex-col gap-2",t)}function $S(t){return(0,s.jsx)(Xo,{children:t})}function BS(t){return(0,s.jsx)(tl,{date:t})}var HS=te(),WS=class{constructor(){Z(this,"tagName","marimo-date");Z(this,"validator",L({initialValue:M(),label:M().nullable(),start:M(),stop:M(),step:M().optional(),fullWidth:W().default(!1),disabled:W().optional()}))}render(t){return(0,s.jsx)(US,{...t.data,value:t.value,setValue:t.setValue,disabled:t.data.disabled})}},US=t=>{let e=(0,HS.c)(19),a;e[0]===t?a=e[1]:(a=p=>{if(!p)return;let h=p.toString();t.setValue(h)},e[0]=t,e[1]=a);let r=a,n=t.label,i=t.fullWidth,o;e[2]===t.value?o=e[3]:(o=Oa(t.value),e[2]=t.value,e[3]=o);let l=t.label??"date picker",d;e[4]===t.start?d=e[5]:(d=Oa(t.start),e[4]=t.start,e[5]=d);let u;e[6]===t.stop?u=e[7]:(u=Oa(t.stop),e[6]=t.stop,e[7]=u);let c;e[8]!==r||e[9]!==t.disabled||e[10]!==o||e[11]!==l||e[12]!==d||e[13]!==u?(c=(0,s.jsx)($1,{granularity:"day",value:o,onChange:r,"aria-label":l,minValue:d,maxValue:u,isDisabled:t.disabled}),e[8]=r,e[9]=t.disabled,e[10]=o,e[11]=l,e[12]=d,e[13]=u,e[14]=c):c=e[14];let m;return e[15]!==t.fullWidth||e[16]!==t.label||e[17]!==c?(m=(0,s.jsx)(et,{label:n,fullWidth:i,children:c}),e[15]=t.fullWidth,e[16]=t.label,e[17]=c,e[18]=m):m=e[18],m},ZS=te(),KS=class{constructor(){Z(this,"tagName","marimo-date-range");Z(this,"validator",L({initialValue:ra([M(),M()]),label:M().nullable(),start:M(),stop:M(),step:M().optional(),fullWidth:W().default(!1),disabled:W().optional()}))}render(t){return(0,s.jsx)(YS,{...t.data,value:t.value,setValue:t.setValue})}},YS=t=>{let e=(0,ZS.c)(24),a;e[0]===t?a=e[1]:(a=x=>{if(!x)return;let{start:g,end:y}=x,b=[g.toString(),y.toString()];t.setValue(b)},e[0]=t,e[1]=a);let r=a,n=t.label,i=t.fullWidth,o;e[2]===t.value[0]?o=e[3]:(o=Oa(t.value[0]),e[2]=t.value[0],e[3]=o);let l;e[4]===t.value[1]?l=e[5]:(l=Oa(t.value[1]),e[4]=t.value[1],e[5]=l);let d;e[6]!==o||e[7]!==l?(d={start:o,end:l},e[6]=o,e[7]=l,e[8]=d):d=e[8];let u=t.label??"date range picker",c;e[9]===t.start?c=e[10]:(c=Oa(t.start),e[9]=t.start,e[10]=c);let m;e[11]===t.stop?m=e[12]:(m=Oa(t.stop),e[11]=t.stop,e[12]=m);let p;e[13]!==r||e[14]!==t.disabled||e[15]!==d||e[16]!==u||e[17]!==c||e[18]!==m?(p=(0,s.jsx)(MS,{granularity:"day",value:d,onChange:r,"aria-label":u,minValue:c,maxValue:m,isDisabled:t.disabled}),e[13]=r,e[14]=t.disabled,e[15]=d,e[16]=u,e[17]=c,e[18]=m,e[19]=p):p=e[19];let h;return e[20]!==t.fullWidth||e[21]!==t.label||e[22]!==p?(h=(0,s.jsx)(et,{label:n,fullWidth:i,children:p}),e[20]=t.fullWidth,e[21]=t.label,e[22]=p,e[23]=h):h=e[23],h},qS=te(),GS=class{constructor(){Z(this,"tagName","marimo-datetime");Z(this,"validator",L({initialValue:M(),label:M().nullable(),start:M(),stop:M(),step:M().optional(),precision:be(["hour","minute","second"]).default("minute"),fullWidth:W().default(!1),disabled:W().optional()}))}render(t){return(0,s.jsx)(QS,{...t.data,value:t.value,setValue:t.setValue})}},QS=t=>{let e=(0,qS.c)(20),a;e[0]===t?a=e[1]:(a=x=>{if(!x)return;let g=x.toString();t.setValue(g)},e[0]=t,e[1]=a);let r=a,n;e[2]===t.value?n=e[3]:(n=t.value?no(t.value):void 0,e[2]=t.value,e[3]=n);let i=n,o=t.label,l=t.fullWidth,d=t.precision,u=t.label??"date time picker",c;e[4]===t.start?c=e[5]:(c=no(t.start),e[4]=t.start,e[5]=c);let m;e[6]===t.stop?m=e[7]:(m=no(t.stop),e[6]=t.stop,e[7]=m);let p;e[8]!==r||e[9]!==i||e[10]!==t.disabled||e[11]!==t.precision||e[12]!==u||e[13]!==c||e[14]!==m?(p=(0,s.jsx)($1,{granularity:d,value:i,onChange:r,"aria-label":u,minValue:c,maxValue:m,isDisabled:t.disabled}),e[8]=r,e[9]=i,e[10]=t.disabled,e[11]=t.precision,e[12]=u,e[13]=c,e[14]=m,e[15]=p):p=e[15];let h;return e[16]!==t.fullWidth||e[17]!==t.label||e[18]!==p?(h=(0,s.jsx)(et,{label:o,fullWidth:l,children:p}),e[16]=t.fullWidth,e[17]=t.label,e[18]=p,e[19]=h):h=e[19],h},JS=te(),XS=class{constructor(){Z(this,"tagName","marimo-dict");Z(this,"validator",L({label:M().nullable(),elementIds:bt(M(),M())}))}render(t){return(0,s.jsx)(e5,{...t.data,value:t.value,setValue:t.setValue,children:t.children})}},e5=t=>{let e=(0,JS.c)(4),{elementIds:a,setValue:r,children:n}=t,i,o;return e[0]!==a||e[1]!==r?(i=()=>{let l=d=>{let u=d.detail.element;if(u===null||!(u instanceof Node))return;let c=Td(u);if(c===null)return;let m=a[c];m!==void 0&&r(p=>{let h=p?{...p}:{};return h[m]=d.detail.value,h})};return document.addEventListener(wn.TYPE,l),()=>{document.removeEventListener(wn.TYPE,l)}},o=[a,r],e[0]=a,e[1]=r,e[2]=i,e[3]=o):(i=e[2],o=e[3]),(0,f.useEffect)(i,o),n},t5=te(),si="__none__";const a5=t=>{let e=(0,t5.c)(25),{options:a,value:r,setValue:n,label:i,allowSelectNone:o,fullWidth:l}=t,d=(0,f.useId)(),[u,c]=(0,f.useState)(""),m;e:{if(!u){m=a;break e}let S;if(e[0]!==a||e[1]!==u){let k;e[3]===u?k=e[4]:(k=v=>h1(v,u)===1,e[3]=u,e[4]=k),S=a.filter(k),e[0]=a,e[1]=u,e[2]=S}else S=e[2];m=S}let p=m,h;e[5]===n?h=e[6]:(h=S=>{S!=null&&n(S===si?null:S)},e[5]=n,e[6]=h);let x=h,g;e[7]!==o||e[8]!==p?(g=()=>{let S=o?(0,s.jsx)(Ta,{value:si,children:"--"},si):null;return p.length>200?(0,s.jsx)(r1,{style:{height:"200px"},totalCount:p.length,overscan:50,itemContent:k=>{let v=p[k],E=(0,s.jsx)(Ta,{value:v,children:v},v);return k===0?(0,s.jsxs)(s.Fragment,{children:[S,E]}):E}}):(0,s.jsxs)(s.Fragment,{children:[S,p.map(r5)]})},e[7]=o,e[8]=p,e[9]=g):g=e[9];let y=g,b;e[10]===l?b=e[11]:(b=Y({"w-full":l}),e[10]=l,e[11]=b);let w=r??si,D;e[12]===y?D=e[13]:(D=y(),e[12]=y,e[13]=D);let j;e[14]!==x||e[15]!==u||e[16]!==b||e[17]!==w||e[18]!==D?(j=(0,s.jsx)(El,{displayValue:n5,placeholder:"Select...",multiple:!1,className:b,value:w,onValueChange:x,shouldFilter:!1,search:u,onSearchChange:c,"data-testid":"marimo-plugin-searchable-dropdown",children:D}),e[14]=x,e[15]=u,e[16]=b,e[17]=w,e[18]=D,e[19]=j):j=e[19];let C;return e[20]!==l||e[21]!==d||e[22]!==i||e[23]!==j?(C=(0,s.jsx)(et,{label:i,id:d,fullWidth:l,children:j}),e[20]=l,e[21]=d,e[22]=i,e[23]=j,e[24]=C):C=e[24],C};function r5(t){return(0,s.jsx)(Ta,{value:t,children:t},t)}function n5(t){return t===si?"--":t}var i5=te(),o5=class{constructor(){Z(this,"tagName","marimo-dropdown");Z(this,"validator",L({initialValue:Q(M()),label:M().nullable(),options:Q(M()),allowSelectNone:W(),fullWidth:W().default(!1),searchable:W().default(!1)}))}render(t){if(t.data.searchable){let e=t.value.length>0?t.value[0]:null,a=r=>t.setValue(r?[r]:[]);return(0,s.jsx)(a5,{...t.data,value:e,setValue:a})}return(0,s.jsx)(l5,{...t.data,value:t.value,setValue:t.setValue})}},Mu="--",l5=t=>{let e=(0,i5.c)(24),{label:a,options:r,value:n,setValue:i,allowSelectNone:o,fullWidth:l}=t,d=(0,f.useId)(),u=o?Mu:r[0],c=n.length===0?u:n[0],m;e[0]===i?m=e[1]:(m=b=>{let w=b.target.value;i(w===Mu?[]:[w])},e[0]=i,e[1]=m);let p;e[2]===l?p=e[3]:(p=Y({"w-full":l}),e[2]=l,e[3]=p);let h;e[4]!==o||e[5]!==n.length?(h=o?(0,s.jsx)("option",{value:Mu,selected:n.length===0,children:"--"}):null,e[4]=o,e[5]=n.length,e[6]=h):h=e[6];let x;if(e[7]!==r||e[8]!==n){let b;e[10]===n?b=e[11]:(b=w=>(0,s.jsx)("option",{value:w,selected:n.includes(w),children:w},w),e[10]=n,e[11]=b),x=r.map(b),e[7]=r,e[8]=n,e[9]=x}else x=e[9];let g;e[12]!==d||e[13]!==c||e[14]!==m||e[15]!==p||e[16]!==h||e[17]!==x?(g=(0,s.jsxs)(hc,{"data-testid":"marimo-plugin-dropdown",onChange:m,className:p,value:c,id:d,children:[h,x]}),e[12]=d,e[13]=c,e[14]=m,e[15]=p,e[16]=h,e[17]=x,e[18]=g):g=e[18];let y;return e[19]!==l||e[20]!==d||e[21]!==a||e[22]!==g?(y=(0,s.jsx)(et,{label:a,id:d,fullWidth:l,children:g}),e[19]=l,e[20]=d,e[21]=a,e[22]=g,e[23]=y):y=e[23],y},s5=f.lazy(()=>jt(()=>import("./ConnectedDataExplorerComponent-3OYw-210.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([337,132,13,8,9,10,11,133,134,135,136,338,38,20,42,26,123,161,325,5,6,7,12,14,15,78,16,17,18,19,21,22,25,91,92,76,93,30,40,24,27,28,29,45,158,83,84,82,339,340,341,342,343,344,345,346,347,348,349,350,351,352,353]),import.meta.url));const d5=zt("marimo-data-explorer").withData(L({label:M().nullish(),data:M()})).renderer(t=>(0,s.jsx)(_t,{children:(0,s.jsx)(s5,{...t.data,value:t.value,setValue:t.setValue})})),al=(0,f.createContext)(new Map),B1=(0,f.createContext)(""),Fu=(0,f.createContext)(()=>Promise.resolve({values:[],too_many_values:!1}));var u5=te();const H1=t=>{let e=(0,u5.c)(4),{type:a}=t,r;e[0]===a?r=e[1]:(r=()=>a.startsWith("int")||a.startsWith("float")||a.startsWith("uint")||a.startsWith("number")||a.startsWith("complex")?(0,s.jsx)(Yb,{size:14}):a.startsWith("object")||a.startsWith("string")?(0,s.jsx)(UA,{size:14}):a.startsWith("date")||a.startsWith("time")?(0,s.jsx)(Ec,{size:14}):a.startsWith("bool")?(0,s.jsx)(LA,{size:14}):(0,s.jsx)(JN,{size:14}),e[0]=a,e[1]=r);let n=r,i;return e[2]===n?i=e[3]:(i=(0,s.jsx)("div",{className:"border p-px border-border bg-(--slate-2) flex items-center justify-center rounded",children:n()}),e[2]=n,e[3]=i),i};var Vu=te();const W1=()=>({isMatch:t=>{let{special:e}=le.parse(t.description||"");return e==="column_id"},Component:({schema:t,form:e,path:a})=>{let r=f.use(al),{label:n,description:i}=le.parse(t.description);return(0,s.jsx)(mt,{control:e.control,name:a,render:({field:o})=>(0,s.jsxs)(ht,{children:[(0,s.jsx)(wt,{children:n}),(0,s.jsx)(Ri,{children:i}),(0,s.jsx)(gt,{children:(0,s.jsxs)(ar,{"data-testid":"marimo-plugin-data-frames-column-select",value:o.value==null?o.value:JSON.stringify(o.value),onValueChange:l=>{let d=JSON.parse(l);o.onChange(d)},children:[(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)(Er,{className:"min-w-[180px]",children:(0,s.jsx)(er,{placeholder:"--"})}),(0,s.jsx)(f5,{})]}),(0,s.jsx)(tr,{children:(0,s.jsxs)(hn,{children:[[...r.entries()].map(([l,d])=>(0,s.jsx)(Zt,{value:JSON.stringify(l),children:(0,s.jsxs)("span",{className:"flex items-center gap-2 flex-1",children:[(0,s.jsx)(H1,{type:d}),(0,s.jsx)("span",{className:"flex-1",children:l}),(0,s.jsxs)("span",{className:"text-muted-foreground text-xs font-semibold",children:["(",d,")"]})]})},l)),r.size===0&&(0,s.jsx)(Zt,{disabled:!0,value:"--",children:"No columns"})]})})]})})]})})}}),c5=()=>({isMatch:t=>{if(t instanceof oc){let e=t.element,a=e instanceof vT?e.description:"",{special:r}=le.parse(a||"");return r==="column_id"}return!1},Component:({schema:t,form:e,path:a})=>{let{label:r}=le.parse(t.description);return(0,s.jsx)(m5,{schema:t,form:e,path:a,itemLabel:r})}});var m5=t=>{let e=(0,Vu.c)(11),{schema:a,form:r,path:n,itemLabel:i}=t,o=f.use(al),l;e[0]===a.description?l=e[1]:(l=le.parse(a.description),e[0]=a.description,e[1]=l);let{description:d}=l,u=i?`Select ${i.toLowerCase()}`:void 0,c;e[2]!==o||e[3]!==d||e[4]!==i||e[5]!==u?(c=p=>{let{field:h}=p,x=Gv(h.value);return(0,s.jsxs)(ht,{children:[(0,s.jsx)(wt,{children:i}),(0,s.jsx)(Ri,{children:d}),(0,s.jsx)(gt,{children:(0,s.jsx)(El,{className:"min-w-[180px]",placeholder:u,displayValue:String,multiple:!0,chips:!0,keepPopoverOpenOnSelect:!0,value:x,onValueChange:g=>{h.onChange(g)},children:[...o.entries()].map(y5)})}),(0,s.jsx)(Tr,{})]})},e[2]=o,e[3]=d,e[4]=i,e[5]=u,e[6]=c):c=e[6];let m;return e[7]!==r.control||e[8]!==n||e[9]!==c?(m=(0,s.jsx)(mt,{control:r.control,name:n,render:c}),e[7]=r.control,e[8]=n,e[9]=c,e[10]=m):m=e[10],m};const p5=()=>({isMatch:t=>{if(t instanceof oc){let{special:e}=le.parse(t.description||"");return e==="column_values"}return!1},Component:({schema:t,form:e,path:a})=>{let{label:r,description:n,placeholder:i}=le.parse(t.description),o=f.use(B1),l=f.use(Fu),{data:d,isPending:u}=Yt(()=>l({column:o}),[o]),c=(d==null?void 0:d.values)||[];if(c.length===0&&!u)return(0,s.jsx)(mt,{control:e.control,name:a,render:({field:p})=>(0,s.jsxs)(ht,{children:[(0,s.jsx)(wt,{children:r}),(0,s.jsx)(Ri,{children:n}),(0,s.jsx)(gt,{children:(0,s.jsx)(Pc,{...p,value:p.value,onValueChange:p.onChange,className:"my-0",placeholder:i})}),(0,s.jsx)(Tr,{})]})});let m=c.map(String);return(0,s.jsx)(mt,{control:e.control,name:a,render:({field:p})=>(0,s.jsxs)(ht,{children:[(0,s.jsx)(wt,{className:"whitespace-pre",children:r}),(0,s.jsx)(Ri,{children:n}),(0,s.jsx)(gt,{children:(0,s.jsx)(El,{className:"min-w-[180px]",placeholder:i,multiple:!1,displayValue:h=>h,value:Array.isArray(p.value)?p.value[0]:p.value,onValueChange:p.onChange,children:m.map(h=>(0,s.jsx)(Ta,{value:h,children:h},h))})}),(0,s.jsx)(Tr,{})]})})}}),h5=()=>({isMatch:t=>{let{special:e}=le.parse(t.description||"");return e==="column_values"&&t instanceof oc},Component:({schema:t,form:e,path:a})=>{let r=f.use(B1),n=f.use(Fu),{data:i,isPending:o}=Yt(()=>n({column:r}),[r]),l=(i==null?void 0:i.values)||[];if(l.length===0&&!o)return(0,s.jsx)(mt,{control:e.control,name:a,render:({field:u})=>(0,s.jsxs)(ht,{children:[(0,s.jsx)(wt,{children:t.description}),(0,s.jsx)(gt,{children:(0,s.jsx)(sA,{...u})}),(0,s.jsx)(Tr,{})]})});let d=l.map(String);return(0,s.jsx)(mt,{control:e.control,name:a,render:({field:u})=>{let c=Gv(u.value);return(0,s.jsxs)(ht,{children:[(0,s.jsx)(wt,{children:t.description}),(0,s.jsx)(gt,{children:(0,s.jsx)(mA,{...u,value:c,options:d})}),(0,s.jsx)(Tr,{})]})}})}});var f5=t=>{let e=(0,Vu.c)(4),{className:a}=t,r;e[0]===a?r=e[1]:(r=Y("text-destructive text-xs w-[16px]",a),e[0]=a,e[1]=r);let n;return e[2]===r?n=e[3]:(n=(0,s.jsx)(v6,{className:r}),e[2]=r,e[3]=n),n};const g5=()=>({isMatch:t=>{if(t instanceof fT){let{special:e}=le.parse(t.description||"");return e==="column_filter"}return!1},Component:({schema:t,form:e,path:a})=>(0,s.jsx)(x5,{schema:t,form:e,path:a})});var x5=t=>{var w;let e=(0,Vu.c)(25),{path:a,form:r,schema:n}=t,i;e[0]===n.description?i=e[1]:(i=le.parse(n.description),e[0]=n.description,e[1]=i);let{description:o}=i,l=f.use(al),d=(w=fa.entries(n.shape).find(b5))==null?void 0:w[1],u;e[2]===a?u=e[3]:(u={name:a},e[2]=a,e[3]=u);let{column_id:c,operator:m}=va(u),p=W1(),h=[Jv(d,r,`${a}.column_id`,[p])],x,g;if(e[4]!==c||e[5]!==l||e[6]!==r||e[7]!==a?(x=()=>{let D=P1(l.get(c)),j=r.getValues(`${a}.operator`);D.includes(j)||(r.setValue(`${a}.operator`,D[0]),r.setValue(`${a}.value`,void 0))},g=[c,l,r,a],e[4]=c,e[5]=l,e[6]=r,e[7]=a,e[8]=x,e[9]=g):(x=e[8],g=e[9]),(0,f.useEffect)(x,g),c!=null){let D;e[10]!==c||e[11]!==l?(D=P1(l.get(c)),e[10]=c,e[11]=l,e[12]=D):D=e[12];let j=D;if(j.length===0){let C;e[13]===Symbol.for("react.memo_cache_sentinel")?(C=(0,s.jsxs)("div",{className:"text-muted-foreground text-xs font-semibold",children:[(0,s.jsx)(wt,{className:"whitespace-pre",children:" "}),(0,s.jsx)("p",{children:"This column type does not support filtering."})]},"no_operator"),e[13]=C):C=e[13],h.push(C)}else{let C=`${a}.operator`,S;e[14]!==o||e[15]!==j?(S=v=>{let{field:E}=v;return(0,s.jsxs)(ht,{children:[(0,s.jsx)(wt,{className:"whitespace-pre",children:" "}),(0,s.jsx)(Ri,{children:o}),(0,s.jsx)(gt,{children:(0,s.jsxs)(ar,{"data-testid":"marimo-plugin-data-frames-filter-operator-select",value:E.value,onValueChange:E.onChange,children:[(0,s.jsx)(Er,{className:"min-w-[140px]",children:(0,s.jsx)(er,{placeholder:"--"})}),(0,s.jsx)(tr,{children:(0,s.jsx)(hn,{children:j.map(w5)})})]})}),(0,s.jsx)(Tr,{})]})},e[14]=o,e[15]=j,e[16]=S):S=e[16];let k;e[17]!==r.control||e[18]!==C||e[19]!==S?(k=(0,s.jsx)(mt,{control:r.control,name:C,render:S},"operator"),e[17]=r.control,e[18]=C,e[19]=S,e[20]=k):k=e[20],h.push(k)}}if(m!=null){let D=Jk(l.get(c),m);D.length===1&&h.push((0,s.jsx)(f.Fragment,{children:Jv(D[0],r,`${a}.value`,[])},"value"))}let y=()=>(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsx)("div",{className:Y("flex flex-row gap-2"),children:h}),(0,s.jsx)(Tr,{})]}),b;return e[21]!==r.control||e[22]!==a||e[23]!==y?(b=(0,s.jsx)(mt,{control:r.control,name:a,render:y}),e[21]=r.control,e[22]=a,e[23]=y,e[24]=b):b=e[24],b};const v5=[W1(),c5(),p5(),h5(),g5()];function y5(t){let[e,a]=t;return(0,s.jsx)(Ta,{value:e,children:(0,s.jsxs)("span",{className:"flex items-center gap-2 flex-1",children:[(0,s.jsx)(H1,{type:a}),(0,s.jsx)("span",{className:"flex-1",children:e}),(0,s.jsxs)("span",{className:"text-muted-foreground text-xs font-semibold",children:["(",a,")"]})]})},e)}function b5(t){let[e]=t;return e==="column_id"}function w5(t){return(0,s.jsx)(Zt,{value:t,children:kc.startCase(t)},t)}function D5(t,e,a=0){if(!e||e.length===0)return t;let r=e[Math.min(a,e.length-1)];if(!r)return t;let n=new Map;for(let[i,[o]]of r)n.set(i,o);return n}var U1=te();const j5=({initialValue:t,columns:e,onChange:a,onInvalidChange:r,getColumnValues:n,columnTypesPerStep:i,lazy:o,ref:l})=>{var v;let d=by({resolver:wy(oS),defaultValues:t,mode:"onChange",reValidateMode:"onChange"}),{handleSubmit:u,watch:c,control:m,formState:p}=d,h=Ue(E=>{a(E)}),x=Ue(E=>{r(E)}),g=Ue(()=>{u(E=>{h(E),o&&d.reset(E,{keepValues:!0})},()=>{x(d.getValues())})()});(0,f.useImperativeHandle)(l,()=>({submit:g}),[]),(0,f.useEffect)(()=>{if(o)return;let E=c(()=>{g()});return()=>E.unsubscribe()},[c,g,o]);let[y,b]=f.useState(t.transforms.length>0?0:void 0),w=y6({control:m,name:"transforms"}),D=d.watch("transforms"),j=y===void 0||(v=D[y])==null?void 0:v.type,C=Tu.options.find(E=>Xv(E).value===j),S=(0,f.useMemo)(()=>D5(e,i,y),[e,D,y]),k=E=>{let N=cA(E),R=w.fields.length;w.append(N),b(R)};return(0,s.jsx)(al,{value:S,children:(0,s.jsx)(Fu,{value:n,children:(0,s.jsxs)("form",{onSubmit:E=>E.preventDefault(),onKeyDown:o?E=>E.key==="Enter"&&E.preventDefault():void 0,className:"relative flex flex-row max-h-[400px] overflow-hidden bg-background",children:[(0,s.jsx)(C5,{items:d.watch("transforms"),selected:y,onSelect:E=>{b(E)},onDelete:E=>{w.remove(E);let N=E-1;b(Math.max(N,0))},onAdd:k}),(0,s.jsxs)("div",{className:"flex flex-col flex-1 p-4 overflow-auto min-h-[200px] border-l",children:[y!==void 0&&C&&(0,s.jsx)(pA,{form:d,schema:C,path:`transforms.${y}`,renderers:v5},`transforms.${y}`),(y===void 0||!C)&&(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center grow gap-3",children:[(0,s.jsx)(Gm,{className:"w-8 h-8 text-muted-foreground"}),(0,s.jsx)(Z1,{onAdd:k,children:(0,s.jsx)(Pe,{"data-testid":"marimo-plugin-data-frames-add-transform",variant:"text",size:"xs",children:(0,s.jsx)("div",{className:"text-sm",children:"Select a transform to begin"})})})]})]}),o&&(0,s.jsxs)("div",{className:"absolute bottom-0 right-0 border-l border-t rounded-tl-sm flex flex-row items-center gap-1 p-1.5 pr-1",children:[(0,s.jsx)(Pe,{"data-testid":"marimo-plugin-data-frames-apply",variant:p.isDirty?"warn":"outline",size:"xs",onClick:g,className:"h-6",children:"Apply"}),(0,s.jsx)(_a,{delayDuration:100,content:(0,s.jsxs)("div",{className:"flex flex-col gap-1.5 text-xs text-muted-foreground max-w-96 text-pretty",children:[(0,s.jsxs)("p",{children:["This dataframe is marked lazy to improve performance."," ",(0,s.jsxs)("span",{children:["Click"," ",(0,s.jsx)("span",{className:"px-1 mr-1 rounded border border-border",children:"Apply"}),"to apply the transforms."]})]}),(0,s.jsxs)("p",{children:["Pass"," ",(0,s.jsx)("code",{className:"bg-muted px-1 py-0.5 rounded-sm",children:"lazy=False"})," ","to"," ",(0,s.jsx)("code",{className:"bg-muted px-1 py-0.5 rounded-sm",children:"mo.ui.dataframe"})," ","to automatically apply transformations."]})]}),children:(0,s.jsx)(vl,{className:"w-3 h-3 text-muted-foreground hover:text-foreground cursor-help"})})]})]})})})},C5=t=>{let e=(0,U1.c)(17),{items:a,selected:r,onAdd:n,onSelect:i,onDelete:o}=t,l;if(e[0]!==a||e[1]!==o||e[2]!==i||e[3]!==r){let p;e[5]!==o||e[6]!==i||e[7]!==r?(p=(h,x)=>(0,s.jsxs)("div",{onClick:()=>{i(x)},className:Y("flex flex-row min-h-[40px] items-center px-2 cursor-pointer hover:bg-accent/50 text-sm overflow-hidden hover-actions-parent border border-muted border-l-2 border-l-transparent",{"border-l-primary bg-accent text-accent-foreground":r===x}),children:[(0,s.jsx)("div",{className:"grow text-ellipsis",children:kc.startCase(h.type)}),(0,s.jsx)(R6,{className:"w-3 h-3 hover-action text-muted-foreground hover:text-destructive",onClick:g=>{o(x),g.stopPropagation()}})]},`${JSON.stringify(h)}-${x}`),e[5]=o,e[6]=i,e[7]=r,e[8]=p):p=e[8],l=a.map(p),e[0]=a,e[1]=o,e[2]=i,e[3]=r,e[4]=l}else l=e[4];let d;e[9]===l?d=e[10]:(d=(0,s.jsx)("div",{className:"flex flex-col overflow-y-auto grow",children:l}),e[9]=l,e[10]=d);let u;e[11]===Symbol.for("react.memo_cache_sentinel")?(u=(0,s.jsxs)(Pe,{"data-testid":"marimo-plugin-data-frames-add-transform",variant:"text",className:"w-full rounded-none m-0 hover:text-accent-foreground",size:"xs",children:[(0,s.jsx)(dy,{className:"w-3 h-3 mr-1"}),"Add"]}),e[11]=u):u=e[11];let c;e[12]===n?c=e[13]:(c=(0,s.jsx)("div",{className:"flex flex-row shrink-0",children:(0,s.jsx)(Z1,{onAdd:n,children:u})}),e[12]=n,e[13]=c);let m;return e[14]!==d||e[15]!==c?(m=(0,s.jsxs)("div",{className:"flex flex-col overflow-y-hidden w-[180px] shadow-xs h-full",children:[d,c]}),e[14]=d,e[15]=c,e[16]=m):m=e[16],m};var Z1=t=>{let e=(0,U1.c)(12),{onAdd:a,children:r}=t,n;e[0]===r?n=e[1]:(n=(0,s.jsx)(j_,{asChild:!0,children:r}),e[0]=r,e[1]=n);let i,o;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=(0,s.jsx)(D_,{children:"Add Transform"}),o=(0,s.jsx)(b_,{}),e[2]=i,e[3]=o):(i=e[2],o=e[3]);let l;e[4]===a?l=e[5]:(l=Object.values(Tu.options).map(m=>{let p=Xv(m),h=k5[p.value];return(0,s.jsxs)(Bv,{onSelect:x=>{x.stopPropagation(),a(m)},children:[(0,s.jsx)(h,{className:"w-3.5 h-3.5 mr-2"}),(0,s.jsx)("span",{children:kc.startCase(p.value)})]},p.value)}),e[4]=a,e[5]=l);let d;e[6]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsx)(Bv,{onSelect:S5,children:(0,s.jsx)("span",{className:"underline text-primary text-xs cursor-pointer",children:"Request a transform"})},"_request_"),e[6]=d):d=e[6];let u;e[7]===l?u=e[8]:(u=(0,s.jsxs)(C_,{className:"w-56",children:[i,o,(0,s.jsxs)(w_,{children:[l,d]})]}),e[7]=l,e[8]=u);let c;return e[9]!==n||e[10]!==u?(c=(0,s.jsxs)(k_,{modal:!1,children:[n,u]}),e[9]=n,e[10]=u,e[11]=c):c=e[11],c},k5={aggregate:Ll,column_conversion:tT,filter_rows:W_,group_by:Xb,rename_column:t6,select_columns:tw,sort_column:Zb,shuffle_rows:ew,sample_rows:Gb,explode_columns:qb,expand_dict:qA,unique:Qb,pivot:wv};function S5(t){t.stopPropagation(),window.open("https://github.com/marimo-team/marimo/issues/new?title=New%20dataframe%20transform:&labels=enhancement&template=feature_request.yaml","_blank")}var E5=te();const R5=zt("marimo-dataframe").withData(L({label:M().nullish(),pageSize:H().default(5),showDownload:W().default(!0),dataframeName:M().optional(),columns:Q(ra([M().or(H()),M(),M()])).transform(t=>{let e=new Map;return t.forEach(([a,r])=>{e.set(a,r)}),e}),lazy:W().default(!1)})).withFunctions({get_dataframe:ut.input(L({})).output(L({url:M(),total_rows:H(),row_headers:oi,field_types:oi,column_types_per_step:Q(oi),python_code:M().nullish(),sql_code:M().nullish()})),get_column_values:ut.input(L({column:M()})).output(L({values:Q(aa()),too_many_values:W()})),search:ut.input(L({sort:Q(L({by:M(),descending:W()})).optional(),query:M().optional(),filters:Q(Nu).optional(),page_number:H(),page_size:H()})).output(L({data:Se([M(),Q(L({}).passthrough())]),total_rows:H()})),download_as:N1}).renderer(t=>(0,s.jsx)(z1,{children:(0,s.jsx)(K1,{...t.data,...t.functions,value:t.value,setValue:t.setValue,host:t.host})}));var N5={transforms:[]};const K1=(0,f.memo)(t=>{let e=(0,E5.c)(69),{columns:a,pageSize:r,showDownload:n,lazy:i,value:o,setValue:l,get_dataframe:d,get_column_values:u,search:c,download_as:m,host:p}=t,h;e[0]===d?h=e[1]:(h=()=>d({}),e[0]=d,e[1]=h);let x=o==null?void 0:o.transforms,g;e[2]===x?g=e[3]:(g=[x],e[2]=x,e[3]=g);let{data:y,error:b,isPending:w}=Yt(h,g),D;e[4]===y?D=e[5]:(D=y||{},e[4]=y,e[5]=D);let{url:j,total_rows:C,row_headers:S,field_types:k,column_types_per_step:v,python_code:E,sql_code:N}=D,R=k==null?void 0:k.length,[_,V]=(0,f.useState)(o||N5),I=(0,f.useRef)(null),A;e[6]===i?A=e[7]:(A=ot=>{var Bt;i&&ot!=="transform"&&((Bt=I.current)==null||Bt.submit())},e[6]=i,e[7]=A);let T=A,P=(0,f.useRef)(_),F;e[8]===_?F=e[9]:(F=()=>{P.current=_},e[8]=_,e[9]=F),(0,f.useEffect)(F);let O;e[10]!==l||e[11]!==(o==null?void 0:o.transforms.length)?(O=()=>{let ot=P.current;(o==null?void 0:o.transforms.length)!==ot.transforms.length&&l(ot)},e[10]=l,e[11]=o==null?void 0:o.transforms.length,e[12]=O):O=e[12];let z=o==null?void 0:o.transforms.length,B;e[13]!==y||e[14]!==l||e[15]!==z?(B=[y,z,P,l],e[13]=y,e[14]=l,e[15]=z,e[16]=B):B=e[16],(0,f.useEffect)(O,B);let J;e[17]===Symbol.for("react.memo_cache_sentinel")?(J=(0,s.jsxs)(ga,{value:"transform",className:"text-xs py-1",children:[(0,s.jsx)(Ll,{className:"w-3 h-3 mr-2"}),"Transform"]}),e[17]=J):J=e[17];let ee;e[18]===E?ee=e[19]:(ee=E&&(0,s.jsxs)(ga,{value:"python-code",className:"text-xs py-1",children:[(0,s.jsx)(KA,{className:"w-3 h-3 mr-2"}),"Python Code"]}),e[18]=E,e[19]=ee);let X;e[20]===N?X=e[21]:(X=N&&(0,s.jsxs)(ga,{value:"sql-code",className:"text-xs py-1",children:[(0,s.jsx)(Dv,{className:"w-3 h-3 mr-2"}),"SQL Code"]}),e[20]=N,e[21]=X);let se;e[22]===Symbol.for("react.memo_cache_sentinel")?(se=(0,s.jsx)("div",{className:"grow"}),e[22]=se):se=e[22];let pe;e[23]!==ee||e[24]!==X?(pe=(0,s.jsxs)(wi,{className:"h-8",children:[J,ee,X,se]}),e[23]=ee,e[24]=X,e[25]=pe):pe=e[25];let G;e[26]===w?G=e[27]:(G=w&&(0,s.jsx)(Nl,{size:"small"}),e[26]=w,e[27]=G);let $;e[28]!==pe||e[29]!==G?($=(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[pe,G]}),e[28]=pe,e[29]=G,e[30]=$):$=e[30];let ie;e[31]!==l||e[32]!==o?(ie=ot=>{fl(ot,o)||(l(ot),V(ot))},e[31]=l,e[32]=o,e[33]=ie):ie=e[33];let re;e[34]!==v||e[35]!==a||e[36]!==u||e[37]!==_||e[38]!==i||e[39]!==ie?(re=(0,s.jsx)(Ut,{value:"transform",className:"mt-1 border rounded-t overflow-hidden",children:(0,s.jsx)(j5,{ref:I,initialValue:_,columns:a,onChange:ie,onInvalidChange:V,getColumnValues:u,columnTypesPerStep:v,lazy:i})}),e[34]=v,e[35]=a,e[36]=u,e[37]=_,e[38]=i,e[39]=ie,e[40]=re):re=e[40];let oe;e[41]===E?oe=e[42]:(oe=E&&(0,s.jsx)(Ut,{value:"python-code",className:"mt-1 border rounded-t overflow-hidden",children:(0,s.jsx)(Rc,{minHeight:"215px",maxHeight:"215px",code:E,language:"python"})}),e[41]=E,e[42]=oe);let ge;e[43]===N?ge=e[44]:(ge=N&&(0,s.jsx)(Ut,{value:"sql-code",className:"mt-1 border rounded-t overflow-hidden",children:(0,s.jsx)(Rc,{minHeight:"215px",maxHeight:"215px",code:N,language:"sql"})}),e[43]=N,e[44]=ge);let he;e[45]!==T||e[46]!==$||e[47]!==re||e[48]!==oe||e[49]!==ge?(he=(0,s.jsxs)(pn,{defaultValue:"transform",onValueChange:T,children:[$,re,oe,ge]}),e[45]=T,e[46]=$,e[47]=re,e[48]=oe,e[49]=ge,e[50]=he):he=e[50];let me;e[51]===b?me=e[52]:(me=b&&(0,s.jsx)(Ti,{error:b}),e[51]=b,e[52]=me);let De=j||"",Le=C??0,je=R??0,Ye=S||Aa.EMPTY,Ne=C&&C>5||!1,Ae;e[53]!==m||e[54]!==k||e[55]!==p||e[56]!==r||e[57]!==c||e[58]!==n||e[59]!==De||e[60]!==Le||e[61]!==je||e[62]!==Ye||e[63]!==Ne?(Ae=(0,s.jsx)(Au,{label:null,className:"rounded-b border-x border-b",data:De,hasStableRowId:!1,totalRows:Le,totalColumns:je,maxColumns:"all",pageSize:r,pagination:!0,fieldTypes:k,rowHeaders:Ye,showDownload:n,download_as:m,enableSearch:!1,showFilters:!1,search:c,showColumnSummaries:!1,showDataTypes:!0,get_column_summaries:T5,showPageSizeSelector:Ne,showColumnExplorer:!1,showRowExplorer:!0,showChartBuilder:!1,value:Aa.EMPTY,setValue:Xa.NOOP,selection:null,lazy:!1,host:p}),e[53]=m,e[54]=k,e[55]=p,e[56]=r,e[57]=c,e[58]=n,e[59]=De,e[60]=Le,e[61]=je,e[62]=Ye,e[63]=Ne,e[64]=Ae):Ae=e[64];let pt;return e[65]!==he||e[66]!==me||e[67]!==Ae?(pt=(0,s.jsxs)("div",{children:[he,me,Ae]}),e[65]=he,e[66]=me,e[67]=Ae,e[68]=pt):pt=e[68],pt});K1.displayName="DataFrameComponent";function T5(){return Promise.resolve({data:null,stats:{},bin_values:{},value_counts:{},show_charts:!1})}const _5=zt("marimo-file-browser").withData(L({initialPath:M(),filetypes:Q(M()),selectionMode:M(),multiple:W(),label:M().nullable(),restrictNavigation:W()})).withFunctions({list_directory:ut.input(L({path:M()})).output(L({files:Q(L({id:M(),path:M(),name:M(),is_directory:W()})),total_count:H(),is_truncated:W()}))}).renderer(t=>(0,s.jsx)(A5,{...t.data,...t.functions,host:t.host,value:t.value,setValue:t.setValue}));var zu="..";const A5=({value:t,setValue:e,initialPath:a,selectionMode:r,multiple:n,label:i,restrictNavigation:o,list_directory:l,host:d})=>{var O;let[u,c]=B_(a),[m,p]=(0,f.useState)("Select all"),[h,x]=(0,f.useState)(!1),[g,y]=(0,f.useState)(!1),b=(O=d.closest(`[${Sr}]`))==null?void 0:O.getAttribute(Sr),{data:w,error:D,isPending:j}=Yt(()=>l({path:u}),[u,b]);if((0,f.useEffect)(()=>{if(!j){y(!1);return}let z=window.setTimeout(()=>{y(!0)},200);return()=>{window.clearTimeout(z)}},[j]),!w&&D)return(0,s.jsx)(Ar,{kind:"danger",children:D.message});let{files:C}=w||{};C===void 0&&(C=[]);let S=A6.guessDeliminator(a).deliminator,k=new Set(t.map(z=>z.path)),v=t.map(z=>(0,s.jsx)("li",{children:z.path},z.id)),E=r==="directory"||r==="all",N=r==="file"||r==="all";function R(z){if(h)return;if(x(!0),z===zu){if(u===S){x(!1);return}z=jy.dirname(u),z===""&&(z=S)}let B=z.length<a.length;if(o&&B){ia({title:"Access denied",description:"Access to directories outside initial path is restricted.",variant:"danger"}),x(!1);return}c(z),p("Select all"),x(!1)}function _({path:z,name:B,isDirectory:J}){return{id:z,name:B,path:z,is_directory:J}}function V({path:z,name:B,isDirectory:J}){let ee=_({path:z,name:B,isDirectory:J});n?k.has(z)?(e(t.filter(X=>X.path!==z)),p("Select all")):e([...t,ee]):e([ee])}function I(){e(t.filter(z=>jy.dirname(z.path)!==u)),p("Select all")}function A(){if(!C)return;let z=[];for(let B of C){if(!E&&B.is_directory||k.has(B.path))continue;let J=_({path:B.path,name:B.name,isDirectory:B.is_directory});z.push(J)}e([...t,...z]),p("Deselect all")}let T=[];T.push((0,s.jsxs)(Dn,{className:"hover:bg-primary hover:bg-opacity-25 select-none",onClick:()=>R(zu),children:[(0,s.jsx)(Ir,{className:"w-[50px] pl-4",children:(0,s.jsx)(Jb,{size:16})}),(0,s.jsx)(Ir,{children:zu})]},"Parent directory"));for(let z of C){let B=z.path;B.startsWith("//")&&(B=B.slice(1));let J=z.is_directory?({path:pe})=>R(pe):V,ee=QA[z.is_directory?"directory":GA(z.name)],X=k.has(B),se=()=>E&&z.is_directory||N&&!z.is_directory?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(xl,{checked:X,onClick:pe=>{V({path:B,name:z.name,isDirectory:z.is_directory}),pe.stopPropagation()},className:Y("",{"hidden group-hover:flex":!X})}),(0,s.jsx)(ee,{size:16,className:Y("mr-2",{hidden:X,"group-hover:hidden":!X})})]}):(0,s.jsx)(ee,{size:16,className:"mr-2"});T.push((0,s.jsxs)(Dn,{className:Y("hover:bg-primary hover:bg-opacity-25 group select-none",{"bg-primary bg-opacity-25":X}),onClick:()=>J({path:B,name:z.name,isDirectory:z.is_directory}),children:[(0,s.jsx)(Ir,{className:"w-[50px] pl-4",children:se()}),(0,s.jsx)(Ir,{children:z.name})]},z.id))}let{parentDirectories:P}=N6({path:u,delimiter:S,initialPath:a,restrictNavigation:o}),F=r==="all"?rc.of("file","folder"):r==="directory"?rc.of("folder"):rc.of("file");return(0,s.jsxs)("div",{children:[D&&(0,s.jsx)(Ar,{kind:"danger",children:D.message}),(()=>{i??(i=`Select ${F.join(" and ",2)}...`);let z=(0,s.jsx)(yc,{children:Be({html:i})});return n?(0,s.jsxs)("div",{className:"flex items-center justify-between border px-2",children:[(0,s.jsx)("div",{className:"mb-1",children:z}),(0,s.jsx)("div",{children:(0,s.jsx)(Pe,{size:"xs",variant:"link",onClick:m==="Select all"?()=>A():()=>I(),children:Be({html:m})})})]}):z})(),(0,s.jsx)(hc,{className:"mt-2 w-full",placeholder:u,value:u,onChange:z=>R(z.target.value),children:P.map(z=>(0,s.jsx)("option",{value:z,selected:z===u,children:z},z))}),w&&typeof w.total_count=="number"&&(0,s.jsx)("div",{className:"text-xs text-muted-foreground mt-1 px-1",children:w.is_truncated?`Showing ${C.length} of ${w.total_count} items`:`${w.total_count} ${w.total_count===1?"item":"items"}`}),(0,s.jsxs)("div",{className:"mt-3 overflow-y-auto w-full border relative",style:{height:"14rem"},"aria-busy":j,"aria-live":"polite",children:[g&&(0,s.jsxs)("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2 bg-background/80 text-xs text-muted-foreground pointer-events-none z-10",role:"status",children:[(0,s.jsx)(Nl,{size:"small"}),(0,s.jsx)("span",{children:"Listing files..."})]}),(0,s.jsx)(Bc,{className:"cursor-pointer table-fixed",children:(0,s.jsx)($c,{children:T})})]}),(0,s.jsx)("div",{className:"mt-4",children:t.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)("span",{className:"font-bold text-xs",children:[t.length," ",F.join(" or ",t.length)," ","selected"]}),(0,s.jsx)("button",{className:Y("text-xs text-destructive hover:underline"),onClick:()=>e([]),type:"button",children:"clear all"})]}),(0,s.jsx)("div",{className:"markdown",children:(0,s.jsx)("ul",{style:{marginBlock:0},className:"m-0 text-xs text-muted-foreground",children:v})})]})})]})};var I5=te(),P5=class{constructor(){Z(this,"tagName","marimo-file");Z(this,"validator",L({filetypes:Q(M()),multiple:W(),kind:be(["button","area"]),label:M().nullable(),max_size:H()}))}render(t){return(0,s.jsx)(F5,{label:t.data.label,filetypes:t.data.filetypes,multiple:t.data.multiple,kind:t.data.kind,value:t.value,setValue:t.setValue,max_size:t.data.max_size})}};function M5(t){let e={},a=(r,n)=>{Object.hasOwn(e,r)?e[r].push(n):e[r]=[n]};return t.forEach(r=>{switch(r){case".png":case".jpg":case".jpeg":case".gif":case".avif":case".bmp":case".ico":case".svg":case".tiff":case".webp":a("image/*",r);break;case".avi":case".mp4":case".mpeg":case".ogg":case".webm":a("video/*",r);break;case".pdf":a("application/pdf",r);break;case".csv":a("text/csv",r);break;default:a("text/plain",r)}}),e}const F5=t=>{let e=(0,I5.c)(78),a;e[0]===t.filetypes?a=e[1]:(a=M5(t.filetypes),e[0]=t.filetypes,e[1]=a);let r=a,{setValue:n,kind:i,multiple:o,value:l,max_size:d}=t,u;e[2]===n?u=e[3]:(u=se=>{MA(se).then(pe=>{n(pe)}).catch($5)},e[2]=n,e[3]=u);let c;e[4]!==r||e[5]!==d||e[6]!==o||e[7]!==u?(c={accept:r,multiple:o,maxSize:d,onError:V5,onDropRejected:L5,onDrop:u},e[4]=r,e[5]=d,e[6]=o,e[7]=u,e[8]=c):c=e[8];let{getRootProps:m,getInputProps:p,isFocused:h,isDragAccept:x,isDragReject:g}=T6(c),y;e[9]===l?y=e[10]:(y=l.map(B5),e[9]=l,e[10]=y);let b;e[11]===y?b=e[12]:(b=(0,s.jsx)("ul",{children:y}),e[11]=y,e[12]=b);let w=b,D=l.length>0;if(i==="button"){let se=t.label??"Upload",pe;e[13]===m?pe=e[14]:(pe=m({}),e[13]=m,e[14]=pe);let G;e[15]===Symbol.for("react.memo_cache_sentinel")?(G=rr({variant:"secondary",size:"xs"}),e[15]=G):G=e[15];let $;e[16]===se?$=e[17]:($=Be({html:se}),e[16]=se,e[17]=$);let ie;e[18]===Symbol.for("react.memo_cache_sentinel")?(ie=(0,s.jsx)(Dy,{size:14,className:"ml-2"}),e[18]=ie):ie=e[18];let re;e[19]!==pe||e[20]!==G||e[21]!==$?(re=(0,s.jsxs)("button",{"data-testid":"marimo-plugin-file-upload-button",...pe,className:G,children:[$,ie]}),e[19]=pe,e[20]=G,e[21]=$,e[22]=re):re=e[22];let oe;e[23]===p?oe=e[24]:(oe=p({}),e[23]=p,e[24]=oe);let ge;e[25]===oe?ge=e[26]:(ge=(0,s.jsx)("input",{...oe,type:"file"}),e[25]=oe,e[26]=ge);let he;e[27]!==n||e[28]!==D||e[29]!==w||e[30]!==l.length?(he=D?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(_a,{content:w,children:(0,s.jsxs)("span",{className:"text-xs text-muted-foreground",children:["Uploaded"," ",(0,s.jsxs)("span",{className:"underline cursor-pointer",children:[l.length," ",l.length===1?"file":"files","."]})]})}),(0,s.jsx)("button",{className:Y("text-xs text-destructive hover:underline"),onClick:()=>n([]),type:"button",children:"Click to clear files."})]}):null,e[27]=n,e[28]=D,e[29]=w,e[30]=l.length,e[31]=he):he=e[31];let me;return e[32]!==ge||e[33]!==he||e[34]!==re?(me=(0,s.jsx)(_t,{children:(0,s.jsxs)("div",{className:"flex flex-row items-center justify-start gap-2",children:[re,ge,he]})}),e[32]=ge,e[33]=he,e[34]=re,e[35]=me):me=e[35],me}let j=t.label??`Drag and drop ${o?"files":"a file"} here, or click to open file browser`,C=!h&&"border-input/60 border-dashed",S=h&&"border-solid",k;e[36]!==C||e[37]!==S?(k=Y("hover:text-primary","mt-3 mb-2 w-full flex flex-col items-center justify-center ","px-6 py-6 sm:px-8 sm:py-8 md:py-10 md:px-16","border rounded-sm","text-sm text-muted-foreground","hover:cursor-pointer","active:shadow-xs-solid","focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring focus-visible:border-accent",C,S),e[36]=C,e[37]=S,e[38]=k):k=e[38];let v;e[39]===m?v=e[40]:(v=m(),e[39]=m,e[40]=v);let E;e[41]===p?E=e[42]:(E=p(),e[41]=p,e[42]=E);let N;e[43]===E?N=e[44]:(N=(0,s.jsx)("input",{...E}),e[43]=E,e[44]=N);let R;e[45]!==j||e[46]!==D?(R=D?(0,s.jsxs)("span",{children:["To re-upload: ",Be({html:j})]}):(0,s.jsx)("span",{className:"mt-0",children:Be({html:j})}),e[45]=j,e[46]=D,e[47]=R):R=e[47];let _=x&&"text-primary",V=g&&"text-destructive",I;e[48]!==_||e[49]!==V?(I=Y(_,V),e[48]=_,e[49]=V,e[50]=I):I=e[50];let A;e[51]===I?A=e[52]:(A=(0,s.jsx)(Dy,{strokeWidth:1.4,className:I}),e[51]=I,e[52]=A);let T=x&&"text-primary",P=g&&"text-destructive",F;e[53]!==T||e[54]!==P?(F=Y(T,P),e[53]=T,e[54]=P,e[55]=F):F=e[55];let O;e[56]===F?O=e[57]:(O=(0,s.jsx)(Gm,{strokeWidth:1.4,className:F}),e[56]=F,e[57]=O);let z;e[58]!==A||e[59]!==O?(z=(0,s.jsxs)("div",{className:"flex flex-row items-center justify-center grow gap-3",children:[A,O]}),e[58]=A,e[59]=O,e[60]=z):z=e[60];let B;e[61]!==R||e[62]!==z?(B=(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center grow gap-3",children:[R,z]}),e[61]=R,e[62]=z,e[63]=B):B=e[63];let J;e[64]!==N||e[65]!==B||e[66]!==k||e[67]!==v?(J=(0,s.jsxs)("div",{className:k,...v,children:[N,B]}),e[64]=N,e[65]=B,e[66]=k,e[67]=v,e[68]=J):J=e[68];let ee;e[69]!==o||e[70]!==n||e[71]!==D||e[72]!==w||e[73]!==l.length?(ee=D?(0,s.jsxs)("div",{className:"flex flex-row gap-1",children:[(0,s.jsx)("div",{className:"text-xs text-muted-foreground",children:(0,s.jsxs)(_t,{children:["Uploaded"," ",(0,s.jsx)(_a,{content:w,children:(0,s.jsxs)("span",{className:"underline cursor-pointer",children:[l.length," ",l.length===1?"file":"files","."]})})]})}),(0,s.jsx)("span",{className:"text-xs text-destructive hover:underline hover:cursor-pointer",children:(0,s.jsxs)("button",{className:Y("text-destructive","hover:underline"),onClick:()=>n([]),type:"button",children:["Click to clear ",o?"files":"file","."]})})]}):null,e[69]=o,e[70]=n,e[71]=D,e[72]=w,e[73]=l.length,e[74]=ee):ee=e[74];let X;return e[75]!==J||e[76]!==ee?(X=(0,s.jsx)("section",{children:(0,s.jsxs)("div",{className:"flex flex-col items-start justify-start grow gap-3",children:[J,ee]})}),e[75]=J,e[76]=ee,e[77]=X):X=e[77],X};function V5(t){de.error(t),ia({title:"File upload failed",description:t.message,variant:"danger"})}function z5(t){return t.message}function O5(t){return(0,s.jsxs)("div",{children:[t.file.name," (",t.errors.map(z5).join(", "),")"]},t.file.name)}function L5(t){ia({title:"File upload failed",description:(0,s.jsx)("div",{className:"flex flex-col gap-1",children:t.map(O5)}),variant:"danger"})}function $5(t){de.error(t),ia({title:"File upload failed",description:"Failed to convert file to base64.",variant:"danger"})}function B5(t){let[e]=t;return(0,s.jsx)("li",{children:e},e)}var Y1=te();const H5=zt("marimo-form").withData(L({label:M().nullable(),elementId:M().transform(t=>t),bordered:W().default(!0),loading:W().default(!1),submitButtonLabel:M().default("Submit"),submitButtonTooltip:M().optional(),submitButtonDisabled:W().default(!1),clearOnSubmit:W().default(!1),showClearButton:W().default(!1),clearButtonLabel:M().default("Clear"),clearButtonTooltip:M().optional(),shouldValidate:W().optional()})).withFunctions({validate:ut.input(L({value:Qa()})).output(M().nullish())}).renderer(({data:t,functions:e,...a})=>(0,s.jsx)(_t,{children:(0,s.jsx)(U5,{...t,...a,...e})})),W5=t=>{let e=(0,Y1.c)(46),{children:a,currentValue:r,newValue:n,setValue:i,label:o,bordered:l,loading:d,submitButtonLabel:u,submitButtonTooltip:c,submitButtonDisabled:m,clearOnSubmit:p,showClearButton:h,clearButtonLabel:x,clearButtonTooltip:g,validate:y,shouldValidate:b}=t,w=(0,f.useRef)(null),D=n===r,j=D?"secondary":"action",[C,S]=(0,f.useState)(null),k;e[0]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{w.current&&Ou(w.current)},e[0]=k):k=e[0];let v=k,E;e[1]!==p||e[2]!==n||e[3]!==i||e[4]!==b||e[5]!==y?(E=async X=>{if(X.preventDefault(),b){let se=await y({value:n}).catch(pe=>{S(pe.message??"Error validating")});if(se!=null){S(se);return}}S(null),i(n),p&&v()},e[1]=p,e[2]=n,e[3]=i,e[4]=b,e[5]=y,e[6]=E):E=e[6];let N=!D&&l,R;e[7]!==l||e[8]!==N?(R=Y("flex flex-col gap-4 rounded-lg py-4 px-8",{"bg-(--gray-1) shadow-md border border-input":l,"bg-(--amber-1) border-(--amber-7)":N}),e[7]=l,e[8]=N,e[9]=R):R=e[9];let _;e[10]!==n||e[11]!==i?(_=X=>{X.key==="Enter"&&(X.ctrlKey||X.metaKey)&&(X.preventDefault(),X.stopPropagation(),i(n))},e[10]=n,e[11]=i,e[12]=_):_=e[12];let V;e[13]===o?V=e[14]:(V=o===null?null:(0,s.jsx)("div",{className:"text-center",children:Be({html:o})}),e[13]=o,e[14]=V);let I;e[15]===C?I=e[16]:(I=C!=null&&(0,s.jsx)(Ar,{kind:"danger",className:"rounded",children:C??"Invalid input"}),e[15]=C,e[16]=I);let A;e[17]===a?A=e[18]:(A=(0,s.jsx)("div",{children:a}),e[17]=a,e[18]=A);let T;e[19]!==x||e[20]!==g||e[21]!==h?(T=h&&q1((0,s.jsx)(Pe,{"data-testid":"marimo-plugin-form-clear-button",variant:"text",onClick:X=>{X.preventDefault(),v()},children:x}),g),e[19]=x,e[20]=g,e[21]=h,e[22]=T):T=e[22];let P=m||d,F;e[23]===d?F=e[24]:(F=d&&(0,s.jsx)(Rl,{className:"h-4 w-4 mr-2 animate-spin"}),e[23]=d,e[24]=F);let O;e[25]!==u||e[26]!==P||e[27]!==F||e[28]!==j?(O=(0,s.jsxs)(Pe,{"data-testid":"marimo-plugin-form-submit-button",variant:j,disabled:P,type:"submit",children:[F,u]}),e[25]=u,e[26]=P,e[27]=F,e[28]=j,e[29]=O):O=e[29];let z;e[30]!==c||e[31]!==O?(z=q1(O,c),e[30]=c,e[31]=O,e[32]=z):z=e[32];let B;e[33]!==z||e[34]!==T?(B=(0,s.jsxs)("div",{className:"flex justify-end gap-2 font-code",children:[T,z]}),e[33]=z,e[34]=T,e[35]=B):B=e[35];let J;e[36]!==B||e[37]!==R||e[38]!==_||e[39]!==V||e[40]!==I||e[41]!==A?(J=(0,s.jsxs)("div",{className:R,onKeyDown:_,children:[V,I,A,B]}),e[36]=B,e[37]=R,e[38]=_,e[39]=V,e[40]=I,e[41]=A,e[42]=J):J=e[42];let ee;return e[43]!==J||e[44]!==E?(ee=(0,s.jsx)("form",{className:"contents",ref:w,onSubmit:E,children:J}),e[43]=J,e[44]=E,e[45]=ee):ee=e[45],ee};var U5=t=>{let e=(0,Y1.c)(24),a,r,n,i,o,l;e[0]===t?(a=e[1],r=e[2],n=e[3],i=e[4],o=e[5],l=e[6]):({elementId:n,value:l,setValue:i,children:a,validate:o,...r}=t,e[0]=t,e[1]=a,e[2]=r,e[3]=n,e[4]=i,e[5]=o,e[6]=l);let d;e[7]===n?d=e[8]:(d=Ja.lookupValue(n),e[7]=n,e[8]=d);let[u,c]=(0,f.useState)(d),m,p;e[9]===n?(m=e[10],p=e[11]):(m=()=>{c(Ja.lookupValue(n))},p=[n],e[9]=n,e[10]=m,e[11]=p),(0,f.useEffect)(m,p);let h=Ja.lookupValue(n);Object.is(h,u)||c(h);let x;e[12]===n?x=e[13]:(x=()=>{let b=w=>{let D=w.detail.element;D===null||!(D instanceof Node)||Td(D)===n&&c(w.detail.value)};return document.addEventListener(wn.TYPE,b),()=>{document.removeEventListener(wn.TYPE,b)}},e[12]=n,e[13]=x);let g;e[14]!==n||e[15]!==i?(g=[n,i],e[14]=n,e[15]=i,e[16]=g):g=e[16],(0,f.useEffect)(x,g);let y;return e[17]!==a||e[18]!==r||e[19]!==u||e[20]!==i||e[21]!==o||e[22]!==l?(y=(0,s.jsx)(W5,{currentValue:l,newValue:u,setValue:i,validate:o,...r,children:a}),e[17]=a,e[18]=r,e[19]=u,e[20]=i,e[21]=o,e[22]=l,e[23]=y):y=e[23],y};function q1(t,e){return e?(0,s.jsx)(_a,{content:e,children:t}):t}function Ou(t){t instanceof HTMLElement&&(t.shadowRoot&&[...t.shadowRoot.children].forEach(Ou),[...t.children].forEach(Ou),E3(t)&&t.reset())}var Z5='td.bracket-l:before{border-left:2px solid var(--foreground);content:"";pointer-events:none;width:0;position:absolute;top:0;bottom:0;left:-4px}td.bracket-l.bracket-t:before{border-top:2px solid var(--foreground);width:8px;top:-1px}td.bracket-l.bracket-b:before{border-bottom:2px solid var(--foreground);width:8px;bottom:-1px}td.bracket-r:after{border-right:2px solid var(--foreground);content:"";pointer-events:none;width:0;position:absolute;top:0;bottom:0;right:-4px}td.bracket-r.bracket-t:after{border-top:2px solid var(--foreground);width:8px;top:-1px}td.bracket-r.bracket-b:after{border-bottom:2px solid var(--foreground);width:8px;bottom:-1px}',K5=class{constructor(){Z(this,"tagName","marimo-matrix");Z(this,"cssStyles",[Z5]);Z(this,"validator",L({initialValue:Q(Q(H())),label:M().nullable(),minValue:Q(Q(H())).nullish(),maxValue:Q(Q(H())).nullish(),step:Q(Q(H())),precision:H(),rowLabels:Q(M()).nullish(),columnLabels:Q(M()).nullish(),symmetric:W(),debounce:W().default(!1),scientific:W(),disabled:Q(Q(W()))}))}render(t){return(0,s.jsx)(q5,{...t.data,value:t.value,setValue:t.setValue})}},Y5=10,q5=({value:t,setValue:e,label:a,minValue:r,maxValue:n,step:i,precision:o,rowLabels:l,columnLabels:d,symmetric:u,debounce:c,scientific:m,disabled:p})=>{var V;let h=(0,f.useRef)(null),[x,g]=(0,f.useState)(null),[y,b]=(0,f.useState)(t);(0,f.useEffect)(()=>{b(t)},[t]);let w=x==null?t:y,D=I=>m?I.toExponential(o):I.toFixed(o),j=(0,f.useCallback)((I,A,T)=>{let P=I;return r!=null&&(P=Math.max(P,r[A][T])),n!=null&&(P=Math.min(P,n[A][T])),P},[r,n]),C=(0,f.useCallback)((I,A,T)=>{p[A][T]||!(I.target instanceof Element)||(I.preventDefault(),I.target.setPointerCapture(I.pointerId),h.current={row:A,col:T,startX:I.clientX,startValue:w[A][T]},g({row:A,col:T}))},[p,w]),S=(0,f.useCallback)(I=>{let A=h.current;if(!A)return;let{row:T,col:P,startX:F,startValue:O}=A,z=I.clientX-F,B=i[T][P],J=j(O+Math.round(z/Y5)*B,T,P);if(J!==w[T][P]){let ee=w.map(X=>[...X]);ee[T][P]=J,u&&T!==P&&(ee[P][T]=J),b(ee),c||e(ee)}},[i,j,w,u,c,e]),k=(0,f.useCallback)(()=>{c&&h.current&&e(w),h.current=null,g(null)},[c,w,e]),v=(0,f.useCallback)((I,A,T)=>{if(I.key==="ArrowUp"||I.key==="ArrowDown"){if(p[A][T])return;I.preventDefault();let P=i[A][T],F=I.key==="ArrowUp"?P:-P,O=j(w[A][T]+F,A,T);if(O!==w[A][T]){let z=w.map(B=>[...B]);z[A][T]=O,u&&A!==T&&(z[T][A]=O),b(z),e(z)}}},[p,i,w,j,u,e]),E=l!=null&&l.length>0,N=d!=null&&d.length>0,R=w.length,_=((V=w[0])==null?void 0:V.length)??0;return(0,s.jsx)(et,{label:a,align:"top",className:"items-center",children:(0,s.jsx)("div",{className:"relative inline-block","data-testid":"marimo-plugin-matrix",onPointerMove:S,onPointerUp:k,onPointerCancel:k,children:(0,s.jsxs)("table",{className:"font-mono text-sm tabular-nums select-none border-separate border-spacing-0",role:"group","aria-label":a||"Matrix",children:[N&&(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{children:[E&&(0,s.jsx)("th",{}),d.map((I,A)=>(0,s.jsx)("th",{className:"text-center text-sm font-medium text-foreground px-2 pb-1",children:I},A))]})}),(0,s.jsx)("tbody",{children:w.map((I,A)=>(0,s.jsxs)("tr",{children:[E&&(0,s.jsx)("th",{className:"text-right text-sm font-medium text-foreground pr-3 h-8",children:l[A]}),I.map((T,P)=>{var J,ee;let F=p[A][P],O=(x==null?void 0:x.row)===A&&(x==null?void 0:x.col)===P,z=(l==null?void 0:l[A])??`Row ${A+1}`,B=(d==null?void 0:d[P])??`Column ${P+1}`;return(0,s.jsx)("td",{className:Y("relative text-center min-w-14 h-8 px-2 transition-colors touch-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none",F?"cursor-default text-muted-foreground":"cursor-ew-resize text-[var(--link)] hover:bg-accent",O&&"bg-accent",P===0&&"bracket-l",P===_-1&&"bracket-r",A===0&&"bracket-t",A===R-1&&"bracket-b"),tabIndex:F?-1:0,"aria-label":`${z}, ${B}`,"aria-valuenow":T,"aria-valuemin":(J=r==null?void 0:r[A])==null?void 0:J[P],"aria-valuemax":(ee=n==null?void 0:n[A])==null?void 0:ee[P],"aria-disabled":F||void 0,onPointerDown:X=>C(X,A,P),onKeyDown:X=>v(X,A,P),"data-testid":`matrix-cell-${A}-${P}`,children:D(T)},P)})]},A))})]})})})},G5=te();const Q5=t=>{let e=(0,G5.c)(12),{onStart:a,onStop:r,status:n,time:i}=t,o;e[0]!==a||e[1]!==n?(o=n==="stopped"&&(0,s.jsx)(Pe,{"data-testid":"audio-recorder-start",variant:"secondary",onClick:a,className:"w-[50px]",children:(0,s.jsx)(Hv,{className:Y("w-6 h-6 border border-input rounded-full"),strokeWidth:1.5,fill:"var(--red-9)"})}),e[0]=a,e[1]=n,e[2]=o):o=e[2];let l;e[3]!==r||e[4]!==n?(l=n==="recording"&&(0,s.jsxs)(Pe,{"data-testid":"audio-recorder-pause",variant:"secondary",onClick:r,className:"w-[50px]",children:[(0,s.jsx)(XA,{className:"w-5 h-5 rounded-sm",fill:"var(--red-9)",strokeWidth:1.5}),(0,s.jsx)(Hv,{className:Y("w-6 h-6 absolute opacity-20 animate-ping"),fill:"var(--red-9)",style:{animationDuration:"1.5s"},strokeWidth:0})]}),e[3]=r,e[4]=n,e[5]=l):l=e[5];let d;e[6]===i?d=e[7]:(d=i&&(0,s.jsxs)("span",{className:"text-sm font-bold",children:[i,"s"]}),e[6]=i,e[7]=d);let u;return e[8]!==o||e[9]!==l||e[10]!==d?(u=(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[o,l,d]}),e[8]=o,e[9]=l,e[10]=d,e[11]=u):u=e[11],u};var J5=te();function X5(){let t=(0,J5.c)(14),[e,a]=(0,f.useState)(0),r=(0,f.useRef)(void 0),n;t[0]===Symbol.for("react.memo_cache_sentinel")?(n={minimumFractionDigits:1,maximumFractionDigits:1},t[0]=n):n=t[0];let i=q6(n),o;t[1]===Symbol.for("react.memo_cache_sentinel")?(o=()=>{r.current=window.setInterval(()=>{a(eE)},100)},t[1]=o):o=t[1];let l=Ue(o),d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d=()=>{r.current!=null&&(window.clearInterval(r.current),r.current=void 0)},t[2]=d):d=t[2];let u=Ue(d),c;t[3]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{a(0)},t[3]=c):c=t[3];let m=Ue(c),p,h;t[4]===Symbol.for("react.memo_cache_sentinel")?(p=()=>()=>{window.clearInterval(r.current)},h=[],t[4]=p,t[5]=h):(p=t[4],h=t[5]),(0,f.useEffect)(p,h);let x;t[6]!==i||t[7]!==e?(x=i.format(e),t[6]=i,t[7]=e,t[8]=x):x=t[8];let g;return t[9]!==m||t[10]!==l||t[11]!==u||t[12]!==x?(g={time:x,start:l,stop:u,clear:m},t[9]=m,t[10]=l,t[11]=u,t[12]=x,t[13]=g):g=t[13],g}function eE(t){return t+.1}var tE=te();function aE(t){let e=(0,tE.c)(18),{onDone:a,options:r}=t,[n,i]=(0,f.useState)("stopped"),o=(0,f.useRef)(void 0),[l,d]=(0,f.useState)(!0),[u,c]=(0,f.useState)(),m=X5(),p;e[0]!==a||e[1]!==r||e[2]!==m?(p=()=>{m.clear(),navigator.mediaDevices.getUserMedia({audio:!0}).then(j=>{let C=new MediaRecorder(j,r);i("recording"),o.current=C,C.start(),m.start(),C.addEventListener("dataavailable",S=>{c(S.data),a==null||a(S.data),C.stream.getTracks().forEach(nE),o.current=void 0})}).catch(j=>{de.log(j),d(!1)})},e[0]=a,e[1]=r,e[2]=m,e[3]=p):p=e[3];let h=Ue(p),x;e[4]===m?x=e[5]:(x=()=>{var j;(j=o.current)==null||j.stop(),m.stop(),i("stopped")},e[4]=m,e[5]=x);let g=Ue(x),y;e[6]===m?y=e[7]:(y=()=>{i(j=>{var C,S;return j==="recording"?((C=o.current)==null||C.pause(),m.stop(),"paused"):j==="paused"?((S=o.current)==null||S.resume(),m.start(),"recording"):j})},e[6]=m,e[7]=y);let b=Ue(y),w;e[8]===m?w=e[9]:(w=()=>{var j,C;(j=o.current)==null||j.stream.getTracks().forEach(rE),(C=o.current)==null||C.stop(),m.stop()},e[8]=m,e[9]=w),$A(w);let D;return e[10]!==l||e[11]!==b||e[12]!==u||e[13]!==n||e[14]!==h||e[15]!==g||e[16]!==m.time?(D={start:h,stop:g,pauseResume:b,allowed:l,recordingBlob:u,recordingStatus:n,recordingTime:m.time,mediaRecorder:o},e[10]=l,e[11]=b,e[12]=u,e[13]=n,e[14]=h,e[15]=g,e[16]=m.time,e[17]=D):D=e[17],D}function rE(t){return t.stop()}function nE(t){return t.stop()}var iE=te(),oE=class{constructor(){Z(this,"tagName","marimo-microphone");Z(this,"validator",L({label:M().nullish()}))}render(t){return(0,s.jsx)(lE,{...t})}},lE=t=>{let e=(0,iE.c)(14),{setValue:a,data:r}=t,n;e[0]===a?n=e[1]:(n={onDone:async x=>{a(await VA(x,"base64"))}},e[0]=a,e[1]=n);let{start:i,stop:o,pauseResume:l,recordingStatus:d,recordingTime:u,allowed:c}=aE(n),m;e[2]===c?m=e[3]:(m=!c&&(0,s.jsx)("div",{className:"text-destructive text-sm",children:"Microphone access is disabled. Please allow microphone access in your browser."}),e[2]=c,e[3]=m);let p;e[4]!==l||e[5]!==d||e[6]!==u||e[7]!==i||e[8]!==o?(p=(0,s.jsx)(Q5,{onStart:i,onStop:o,onPause:l,status:d,time:u}),e[4]=l,e[5]=d,e[6]=u,e[7]=i,e[8]=o,e[9]=p):p=e[9];let h;return e[10]!==r.label||e[11]!==m||e[12]!==p?(h=(0,s.jsxs)(et,{label:r.label,align:"top",children:[m,p]}),e[10]=r.label,e[11]=m,e[12]=p,e[13]=h):h=e[13],h},Ya=7,sE={n:"ns-resize",s:"ns-resize",e:"ew-resize",w:"ew-resize",nw:"nwse-resize",se:"nwse-resize",ne:"nesw-resize",sw:"nesw-resize"};function G1(t,e,a){let r=Math.min(e.x,a.x),n=Math.max(e.x,a.x),i=Math.min(e.y,a.y),o=Math.max(e.y,a.y),l=Math.abs(t.x-r)<=Ya,d=Math.abs(t.x-n)<=Ya,u=Math.abs(t.y-i)<=Ya,c=Math.abs(t.y-o)<=Ya,m=t.x>=r-Ya&&t.x<=n+Ya,p=t.y>=i-Ya&&t.y<=o+Ya;return l&&u?"nw":d&&u?"ne":l&&c?"sw":d&&c?"se":u&&m?"n":c&&m?"s":l&&p?"w":d&&p?"e":null}function dE(t,e,a){let r=Math.min(e.x,a.x),n=Math.max(e.x,a.x),i=Math.min(e.y,a.y),o=Math.max(e.y,a.y);switch(t){case"nw":return{anchor:{x:n,y:o},lockX:null,lockY:null};case"ne":return{anchor:{x:r,y:o},lockX:null,lockY:null};case"sw":return{anchor:{x:n,y:i},lockX:null,lockY:null};case"se":return{anchor:{x:r,y:i},lockX:null,lockY:null};case"n":return{anchor:{x:r,y:o},lockX:n,lockY:null};case"s":return{anchor:{x:r,y:i},lockX:n,lockY:null};case"w":return{anchor:{x:n,y:i},lockX:null,lockY:o};case"e":return{anchor:{x:r,y:i},lockX:null,lockY:o}}}function rl(t,e){let[a,r]=e;if(t==="log"){let i=Math.log10(a),o=Math.log10(r)-i;return{normalize:l=>(Math.log10(l)-i)/o,invert:l=>10**(i+l*o)}}let n=r-a;return{normalize:i=>(i-a)/n,invert:i=>a+i*n}}function uE(t,e){let a=!1;for(let r=0,n=e.length-1;r<e.length;n=r++){let i=e[r].x,o=e[r].y,l=e[n].x,d=e[n].y;o>t.y!=d>t.y&&t.x<(l-i)*(t.y-o)/(d-o)+i&&(a=!a)}return a}function Lu(t,e){let[a,r,n,i]=e.axesPixelBounds,o=(t.x-a)/(n-a),l=(t.y-r)/(i-r),d=rl(e.xScale,e.xBounds),u=rl(e.yScale,e.yBounds);return{x:d.invert(o),y:u.invert(1-l)}}function $u(t,e){let[a,r,n,i]=e.axesPixelBounds,o=rl(e.xScale,e.xBounds),l=rl(e.yScale,e.yBounds);return{x:a+o.normalize(t.x)*(n-a),y:r+(1-l.normalize(t.y))*(i-r)}}function di(t,e){let[a,r,n,i]=e.axesPixelBounds;return{x:Math.max(a,Math.min(n,t.x)),y:Math.max(r,Math.min(i,t.y))}}function cE(t,e,a){let r=Math.min(e.x,a.x),n=Math.max(e.x,a.x),i=Math.min(e.y,a.y),o=Math.max(e.y,a.y);return t.x>=r&&t.x<=n&&t.y>=i&&t.y<=o}function Q1(t,e){let[a,r,n,i]=e.axesPixelBounds;return t.x>=a&&t.x<=n&&t.y>=r&&t.y<=i}var mE=(uv=class{constructor(t,e){We(this,pi);We(this,it);We(this,ci);We(this,ke);We(this,Ke,{type:"idle"});We(this,rn,0);We(this,nn,null);We(this,on,0);We(this,mi,"");We(this,ln,()=>{let t=K(this,nn);if(!t)return;let e=K(this,it).getContext("2d");if(!e)return;let a=K(this,ke),r=K(this,Ke),n=globalThis.devicePixelRatio??1;if(e.setTransform(n,0,0,n,0,0),e.clearRect(0,0,a.width,a.height),e.drawImage(t,0,0,a.width,a.height),r.type==="box"){let i=Math.min(r.start.x,r.end.x),o=Math.min(r.start.y,r.end.y),l=Math.abs(r.end.x-r.start.x),d=Math.abs(r.end.y-r.start.y);e.save(),e.fillStyle=a.selectionColor,e.globalAlpha=a.selectionOpacity,e.fillRect(i,o,l,d),e.restore(),e.strokeStyle=a.selectionColor,e.lineWidth=a.strokeWidth,e.strokeRect(i,o,l,d)}if(r.type==="lasso"&&r.points.length>=2){e.beginPath(),e.moveTo(r.points[0].x,r.points[0].y);for(let i=1;i<r.points.length;i++)e.lineTo(r.points[i].x,r.points[i].y);e.closePath(),e.save(),e.fillStyle=a.selectionColor,e.globalAlpha=a.selectionOpacity,e.fill("evenodd"),e.restore(),e.strokeStyle=a.selectionColor,e.lineWidth=a.strokeWidth,e.stroke()}});We(this,kt,()=>{cancelAnimationFrame(K(this,rn)),tt(this,rn,requestAnimationFrame(K(this,ln)))});We(this,hi,t=>{let e=K(this,it).getBoundingClientRect(),a=K(this,ke).width/e.width,r=K(this,ke).height/e.height;return{x:(t.clientX-e.left)*a,y:(t.clientY-e.top)*r}});We(this,jr,(t,e)=>{let a=Lu(t,K(this,ke)),r=Lu(e,K(this,ke));K(this,ke).setValue({type:"box",has_selection:!0,data:{x_min:Math.min(a.x,r.x),x_max:Math.max(a.x,r.x),y_min:Math.min(a.y,r.y),y_max:Math.max(a.y,r.y)}})});We(this,sn,t=>{if(t.length>=3){let e=t.map(a=>{let r=Lu(a,K(this,ke));return[r.x,r.y]});K(this,ke).setValue({type:"lasso",has_selection:!0,data:e})}});We(this,fi,()=>{tt(this,Ke,{type:"idle"}),K(this,ke).setValue({has_selection:!1}),K(this,kt).call(this)});We(this,dn,()=>K(this,Ke).type!=="idle");We(this,gi,t=>{let e=K(this,Ke);return e.type==="box"?cE(t,e.start,e.end):e.type==="lasso"?uE(t,e.points):!1});We(this,ll,t=>{let[e,a,r,n]=K(this,ke).axesPixelBounds;if(!(t.x>=e&&t.x<=r&&t.y>=a&&t.y<=n)){K(this,it).style.cursor="default";return}let i=K(this,Ke);if(i.type==="box"&&i.action===null){let o=G1(t,i.start,i.end);if(o){K(this,it).style.cursor=sE[o];return}}if(K(this,dn).call(this)&&K(this,gi).call(this,t)){K(this,it).style.cursor="move";return}K(this,it).style.cursor="crosshair"});We(this,sl,t=>{if(!(!t||!("has_selection"in t)||!t.has_selection)){if(t.type==="box"){let e=t.data;tt(this,Ke,{type:"box",start:$u({x:e.x_min,y:e.y_min},K(this,ke)),end:$u({x:e.x_max,y:e.y_max},K(this,ke)),action:null})}else t.type==="lasso"&&tt(this,Ke,{type:"lasso",points:t.data.map(([e,a])=>$u({x:e,y:a},K(this,ke))),action:null});K(this,kt).call(this)}});We(this,dl,t=>{K(this,it).setPointerCapture(t.pointerId),K(this,ci).focus();let e=K(this,hi).call(this,t),a=K(this,Ke);if(t.shiftKey){if(!Q1(e,K(this,ke)))return;tt(this,Ke,{type:"lasso",points:[di(e,K(this,ke))],action:{type:"drawing"}}),K(this,kt).call(this);return}if(a.type==="box"&&a.action===null){let n=G1(e,a.start,a.end);if(n){let{anchor:i,lockX:o,lockY:l}=dE(n,a.start,a.end);tt(this,Ke,{type:"box",start:a.start,end:a.end,action:{type:"resizing",anchor:i,lockX:o,lockY:l}});return}}if(K(this,dn).call(this)&&K(this,gi).call(this,e)){a.type==="box"?tt(this,Ke,{type:"box",start:a.start,end:a.end,action:{type:"dragging",origin:e}}):a.type==="lasso"&&tt(this,Ke,{type:"lasso",points:a.points,action:{type:"dragging",origin:e}});return}if(K(this,dn).call(this)&&K(this,fi).call(this),!Q1(e,K(this,ke)))return;let r=di(e,K(this,ke));tt(this,Ke,{type:"box",start:r,end:r,action:{type:"drawing"}}),K(this,kt).call(this)});We(this,ul,t=>{let e=K(this,hi).call(this,t),a=K(this,Ke),r=K(this,ke);if(a.type==="idle"||a.action===null){K(this,ll).call(this,e);return}if(a.type==="lasso"&&a.action.type==="drawing"){a.points.push(di(e,r)),K(this,kt).call(this);return}if(a.type==="box"&&a.action.type==="drawing"){let n=di(e,r);a.end=n,K(this,kt).call(this),r.debounce||K(this,jr).call(this,a.start,n);return}if(a.type==="box"&&a.action.type==="resizing"){let n=di(e,r),{anchor:i,lockX:o,lockY:l}=a.action;a.start=i,a.end={x:o??n.x,y:l??n.y},K(this,kt).call(this),r.debounce||K(this,jr).call(this,a.start,a.end);return}if(a.type==="box"&&a.action.type==="dragging"){let[n,i,o,l]=r.axesPixelBounds,d=e.x-a.action.origin.x,u=e.y-a.action.origin.y;a.action.origin=e;let c=Math.min(a.start.x,a.end.x),m=Math.max(a.start.x,a.end.x),p=Math.min(a.start.y,a.end.y),h=Math.max(a.start.y,a.end.y);d=Math.max(n-c,Math.min(o-m,d)),u=Math.max(i-p,Math.min(l-h,u)),a.start={x:a.start.x+d,y:a.start.y+u},a.end={x:a.end.x+d,y:a.end.y+u},K(this,kt).call(this),r.debounce||K(this,jr).call(this,a.start,a.end);return}if(a.type==="lasso"&&a.action.type==="dragging"){let[n,i,o,l]=r.axesPixelBounds,d=e.x-a.action.origin.x,u=e.y-a.action.origin.y;a.action.origin=e;let c=1/0,m=-1/0,p=1/0,h=-1/0;for(let x of a.points)x.x<c&&(c=x.x),x.x>m&&(m=x.x),x.y<p&&(p=x.y),x.y>h&&(h=x.y);d=Math.max(n-c,Math.min(o-m,d)),u=Math.max(i-p,Math.min(l-h,u));for(let x=0;x<a.points.length;x++)a.points[x]={x:a.points[x].x+d,y:a.points[x].y+u};K(this,kt).call(this),r.debounce||K(this,sn).call(this,a.points)}});We(this,cl,t=>{var r,n;K(this,it).releasePointerCapture(t.pointerId);let e=K(this,Ke),a=K(this,ke);if(e.type==="lasso"&&((r=e.action)==null?void 0:r.type)==="drawing"){e.points.length>=3?(e.action=null,K(this,sn).call(this,e.points)):(tt(this,Ke,{type:"idle"}),K(this,ke).setValue({has_selection:!1})),K(this,kt).call(this);return}if(e.type==="lasso"&&((n=e.action)==null?void 0:n.type)==="dragging"){e.action=null,a.debounce&&K(this,sn).call(this,e.points);return}e.type==="box"&&e.action!==null&&(e.action=null,a.debounce&&K(this,jr).call(this,e.start,e.end))});We(this,ml,t=>{var e;if(t.key==="Escape"){let a=K(this,Ke);if(a.type==="idle")return;((e=a.action)==null?void 0:e.type)==="drawing"?(tt(this,Ke,{type:"idle"}),K(this,kt).call(this)):K(this,fi).call(this)}});tt(this,ci,t),tt(this,ke,e.state),t.tabIndex=-1,t.role="application",t.className="relative inline-block select-none outline-none";let a=document.createElement("canvas");a.className="block cursor-crosshair";let r=globalThis.devicePixelRatio??1;a.width=K(this,ke).width*r,a.height=K(this,ke).height*r,a.style.width=`${K(this,ke).width}px`,a.style.maxWidth="100%",a.style.height="auto",a.style.aspectRatio=`${K(this,ke).width} / ${K(this,ke).height}`,a.style.touchAction="none",t.append(a),tt(this,it,a),a.addEventListener("pointerdown",K(this,dl),{signal:e.signal}),a.addEventListener("pointermove",K(this,ul),{signal:e.signal}),a.addEventListener("pointerup",K(this,cl),{signal:e.signal}),t.addEventListener("keydown",K(this,ml),{signal:e.signal}),e.signal.addEventListener("abort",()=>{cancelAnimationFrame(K(this,rn)),K(this,it).remove()}),tc(this,pi,Kc).call(this,K(this,ke).chartBase64),K(this,sl).call(this,K(this,ke).value)}update(t){let e=K(this,ke);tt(this,ke,t);let a=!1;if(t.width!==e.width||t.height!==e.height){let r=globalThis.devicePixelRatio??1;K(this,it).width=t.width*r,K(this,it).height=t.height*r,K(this,it).style.width=`${t.width}px`,K(this,it).style.maxWidth="100%",K(this,it).style.height="auto",K(this,it).style.aspectRatio=`${t.width} / ${t.height}`,a=!0}if(t.chartBase64!==K(this,mi)){tc(this,pi,Kc).call(this,t.chartBase64);return}(a||t.selectionColor!==e.selectionColor||t.selectionOpacity!==e.selectionOpacity||t.strokeWidth!==e.strokeWidth)&&K(this,ln).call(this)}},it=new WeakMap,ci=new WeakMap,ke=new WeakMap,Ke=new WeakMap,rn=new WeakMap,nn=new WeakMap,on=new WeakMap,mi=new WeakMap,pi=new WeakSet,Kc=function(t){tt(this,mi,t),fv(this,on)._++;let e=K(this,on);tt(this,Ke,{type:"idle"}),tt(this,nn,null);let a=K(this,it).getContext("2d");if(a){let n=globalThis.devicePixelRatio??1;a.setTransform(n,0,0,n,0,0),a.clearRect(0,0,K(this,ke).width,K(this,ke).height)}let r=new Image;r.onload=()=>{e===K(this,on)&&(tt(this,nn,r),K(this,ln).call(this))},r.src=t},ln=new WeakMap,kt=new WeakMap,hi=new WeakMap,jr=new WeakMap,sn=new WeakMap,fi=new WeakMap,dn=new WeakMap,gi=new WeakMap,ll=new WeakMap,sl=new WeakMap,dl=new WeakMap,ul=new WeakMap,cl=new WeakMap,ml=new WeakMap,uv),pE=class{constructor(){Z(this,"tagName","marimo-matplotlib");Z(this,"validator",L({chartBase64:M(),xBounds:ra([H(),H()]),yBounds:ra([H(),H()]),axesPixelBounds:ra([H(),H(),H(),H()]),width:H(),height:H(),selectionColor:M().default("#3b82f6"),selectionOpacity:H().default(.15),strokeWidth:H().default(2),debounce:W(),xScale:be(["linear","log"]).default("linear"),yScale:be(["linear","log"]).default("linear")}))}render(t){return(0,s.jsx)(hE,{...t.data,value:t.value,setValue:t.setValue})}},hE=t=>{let e=(0,f.useRef)(null),a=(0,f.useRef)(null);return(0,f.useEffect)(()=>{let r=e.current;if(!r)return;let n=new AbortController;return a.current=new mE(r,{state:t,signal:n.signal}),()=>{n.abort(),a.current=null}},[]),(0,f.useEffect)(()=>{var r;(r=a.current)==null||r.update(t)}),(0,s.jsx)("div",{ref:e})},fE=class{constructor(t){Z(this,"readyState",WebSocket.OPEN);Z(this,"onopen",null);Z(this,"onmessage",null);Z(this,"onclose",null);this.sendFn=t}send(t){this.sendFn(JSON.parse(t))}receiveJson(t){var e;(e=this.onmessage)==null||e.call(this,new MessageEvent("message",{data:JSON.stringify(t)}))}receiveBinary(t){var r;let e=t.buffer.slice(t.byteOffset,t.byteOffset+t.byteLength),a=new Blob([e]);(r=this.onmessage)==null||r.call(this,new MessageEvent("message",{data:a}))}close(){var t;this.readyState=WebSocket.CLOSED,(t=this.onclose)==null||t.call(this)}},gE=te(),xE="mpl-interactive-figure";const vE=zt("marimo-mpl-interactive").withData(L({mplJsUrl:M(),cssUrl:M(),toolbarImages:bt(M(),M()),width:H(),height:H()})).withFunctions({}).renderer(t=>(0,s.jsx)(DE,{...t}));var nl=null;async function yE(t){if(!window.mpl)return nl||(nl=new Promise((e,a)=>{let r=document.createElement("script");r.src=t,r.onload=()=>e(),r.onerror=()=>{nl=null,a(Error("Failed to load mpl.js"))},document.head.append(r)}),nl)}function bE(t,e){let a=n=>{let i=(n.getAttribute("src")||"").match(/_images\/(.+)\.png$/);if(i){let l=e[i[1]];l&&(n.src=l)}let o=(n.getAttribute("srcset")||"").match(/_images\/(.+)\.png\s+2x$/);if(o){let l=e[o[1]];l&&(n.srcset=`${l} 2x`)}};for(let n of t.querySelectorAll("img"))a(n);let r=new MutationObserver(n=>{for(let i of n)for(let o of i.addedNodes)if(o instanceof HTMLImageElement)a(o);else if(o instanceof HTMLElement)for(let l of o.querySelectorAll("img"))a(l)});return r.observe(t,{childList:!0,subtree:!0}),()=>r.disconnect()}function wE(t,e){let a=document.createElement("link");return a.rel="stylesheet",a.href=e,t.append(a),()=>a.remove()}var DE=t=>{let e=(0,gE.c)(16),{mplJsUrl:a,cssUrl:r,toolbarImages:n,width:i,height:o}=t.data,{model_id:l}=t.value,d=(0,f.useRef)(null),u=(0,f.useRef)(null),c=(0,f.useRef)(null),m;e[0]!==o||e[1]!==l||e[2]!==a||e[3]!==i?(m=async b=>{if(await yE(a),!window.mpl){de.error("mpl.js failed to load");return}let w;try{w=await lc.get(l)}catch{de.error("Failed to get model for mpl interactive",l);return}let D=new fE(v=>{w.send(v)});c.current=D;let j=(v,E)=>{if(v){if(v.type==="json")D.receiveJson(v.data);else if(v.type==="binary"&&E&&E.length>0)D.receiveBinary(E[0]);else if(v.type==="download"&&E&&E.length>0){let N=v.format||"png",R=E[0],_=R.buffer.slice(R.byteOffset,R.byteOffset+R.byteLength);oA(new Blob([_],{type:`image/${N}`}),`figure.${N}`)}}};w.on("msg:custom",j);let C=l,S=new window.mpl.figure(C,D,(v,E)=>{w.send({type:"download",format:E})},b);u.current=S;let k=S.root.querySelector("div[tabindex]");return k&&(k.style.width=`${i}px`,k.style.height=`${o}px`),setTimeout(()=>{var v;(v=D.onopen)==null||v.call(D)},0),()=>{w.off("msg:custom",j),D.close()}},e[0]=o,e[1]=l,e[2]=a,e[3]=i,e[4]=m):m=e[4];let p=m,h;e[5]!==r||e[6]!==p||e[7]!==n?(h=()=>{let b=d.current;if(!b)return;b.innerHTML="";let w=wE(b,r),D=bE(b,n),j,C=!1;return p(b).then(S=>{if(C){S==null||S();return}j=S}).catch(S=>{C||de.error("Failed to set up MPL interactive figure",S)}),()=>{C=!0,w(),D(),j==null||j(),b.innerHTML=""}},e[5]=r,e[6]=p,e[7]=n,e[8]=h):h=e[8];let x;e[9]!==r||e[10]!==l||e[11]!==p||e[12]!==n?(x=[l,r,n,p],e[9]=r,e[10]=l,e[11]=p,e[12]=n,e[13]=x):x=e[13],(0,f.useEffect)(h,x);let g;e[14]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{var w;let b=u.current;!document.hidden&&((w=b==null?void 0:b.ws)==null?void 0:w.readyState)===WebSocket.OPEN&&b.send_message("refresh",{})},e[14]=g):g=e[14],sc(document,"visibilitychange",g);let y;return e[15]===Symbol.for("react.memo_cache_sentinel")?(y=(0,s.jsx)("div",{ref:d,className:xE}),e[15]=y):y=e[15],y},jE=te(),CE=class{constructor(){Z(this,"tagName","marimo-number");Z(this,"validator",L({initialValue:H().nullish(),label:M().nullable(),start:H().nullish(),stop:H().nullish(),step:H().optional(),debounce:W().default(!1),fullWidth:W().default(!1),disabled:W().optional()}))}render(t){return(0,s.jsx)(kE,{...t.data,value:t.value,setValue:t.setValue})}},kE=t=>{let e=(0,jE.c)(25),a=(0,f.useId)(),r;e[0]===t.value?r=e[1]:(r=J1(t.value),e[0]=t.value,e[1]=r);let n=r,i=!t.debounce,o;e[2]!==n||e[3]!==t.setValue||e[4]!==i?(o={initialValue:n,delay:200,disabled:i,onChange:t.setValue},e[2]=n,e[3]=t.setValue,e[4]=i,e[5]=o):o=e[5];let{value:l,onChange:d}=Ay(o),u;e[6]===d?u=e[7]:(u=S=>{d(J1(S))},e[6]=d,e[7]=u);let c=u,m=t.label,p=a,h=t.fullWidth,x=t.fullWidth&&"w-full",g;e[8]===x?g=e[9]:(g=Y("min-w-[3em]",x),e[8]=x,e[9]=g);let y=t.start??void 0,b=t.stop??void 0,w=l??NaN,D=t.label||"Number input",j;e[10]!==c||e[11]!==a||e[12]!==t.disabled||e[13]!==t.step||e[14]!==b||e[15]!==w||e[16]!==D||e[17]!==g||e[18]!==y?(j=(0,s.jsx)(xy,{"data-testid":"marimo-plugin-number-input",className:g,minValue:y,maxValue:b,value:w,step:t.step,onChange:c,id:a,"aria-label":D,isDisabled:t.disabled}),e[10]=c,e[11]=a,e[12]=t.disabled,e[13]=t.step,e[14]=b,e[15]=w,e[16]=D,e[17]=g,e[18]=y,e[19]=j):j=e[19];let C;return e[20]!==a||e[21]!==t.fullWidth||e[22]!==t.label||e[23]!==j?(C=(0,s.jsx)(et,{label:m,id:p,fullWidth:h,children:j}),e[20]=a,e[21]=t.fullWidth,e[22]=t.label,e[23]=j,e[24]=C):C=e[24],C};function J1(t){return t==null||Number.isNaN(t)?null:t}const SE=L({content:Se([L({type:Ge("ACK")}),M()]).nullable()});function il(t,e){if(Array.isArray(t))return t.map(a=>il(a,e));if(t instanceof Map){let a={};for(let[r,n]of t.entries())a[String(r)]=il(n,e);return a}if(typeof t=="object"&&t&&"to_base64"in t&&typeof t.to_base64=="function"){let a=e.length;return e.push(t.to_base64()),{id:a}}if(typeof t=="object"&&t){let a={};for(let r of Object.keys(t))a[r]=il(t[r],e);return a}return t}var EE=class{constructor(t,e=200){Z(this,"buffer",[]);Z(this,"isBlocked",!1);Z(this,"timeout",null);this.processEvents=t,this.blockDuration=e}add(t){this.buffer.push(t),this.flush()}flush(){this.isBlocked||(this.processEvents(),this.block())}block(){this.isBlocked=!0,this.timeout!==null&&clearTimeout(this.timeout),this.timeout=window.setTimeout(()=>{this.isBlocked=!1,this.buffer.length>0&&this.flush()},this.blockDuration)}size(){return this.buffer.length}clear(){this.buffer=[]}getAndClear(){let t=this.buffer;return this.buffer=[],t}};const RE=zt("marimo-panel").withData(L({extension:M().nullable(),docs_json:bt(M(),Qa()),render_json:L({roots:bt(M(),M())}).catchall(Qa())})).withFunctions({send_to_widget:ut.input(L({message:Qa(),buffers:Q(M())})).output(cn().optional())}).renderer(t=>(0,s.jsx)(NE,{...t}));function X1(){return window.Bokeh!=null}var NE=t=>{let{data:e,functions:a,host:r}=t,{extension:n,docs_json:i,render_json:o}=e,l=(0,f.useRef)(null),d=(0,f.useRef)(null),u=(0,f.useRef)(null),[c,m]=(0,f.useState)(!1),[p,h]=(0,f.useState)(null),x=(0,f.useRef)(a);x.current=a;let g=(0,f.useCallback)(()=>{if(!y.current)return;let b=y.current.getAndClear();if(b.length===0)return;let w=b.at(0);if(!ev(w))return;let D=w.document,j=b.filter(v=>ev(v)&&v.document===D),C=D.create_json_patch(j),S=window.Bokeh.protocol.Message.create("PATCH-DOC",{},C),k=[];S.content=il(S.content,k),x.current.send_to_widget({message:S,buffers:k}).catch(v=>{de.warn("Failed to send Panel event to backend",v)})},[]),y=(0,f.useRef)(new EE(g));return(0,f.useEffect)(()=>{if(X1()){m(!0);return}if(n){let w=document.createElement("script");w.innerHTML=n,document.head.append(w)}let b=setInterval(()=>{X1()&&(m(!0),clearInterval(b))},10);return()=>clearInterval(b)},[n,m]),sc(r,oI.TYPE,b=>{if(b.detail.message==null)return;let w=SE.parse(b.detail.message),D=b.detail.buffers,j=u.current;if(!j)return;let C=w.content;if(C!==null&&typeof w.content!="string"){y.current&&y.current.size()>0&&g();return}let S=TE(d.current);if(!S)return;if(D&&D.length>0){let v=D[0];v instanceof ArrayBuffer?j.consume(v):v.buffer instanceof ArrayBuffer&&j.consume(v.buffer)}else if(C&&typeof C=="string")j.consume(C);else return;let k=j.message;k!=null&&Object.keys(k.content).length>0&&(k.content.events!==void 0&&(k.content.events=k.content.events.filter(v=>{var E;return((E=v==null?void 0:v.model)==null?void 0:E.id)&&S._all_models.has(v.model.id)})),S.apply_json_patch(k.content,k.buffers))}),(0,f.useEffect)(()=>{let b=Object.keys(i)[0];!c||p===b||(async()=>{let w={...o,roots:{}};for(let C of Object.keys(o.roots)){let S=o.roots[C];if(l.current){let k=l.current.querySelector(`#${S}`);w.roots[C]=k}}let D=Object.keys(w.roots)[0];await window.Bokeh.embed.embed_items_notebook(i,[w]),d.current=D;let j=window.Bokeh.index.get_by_id(D).model.document;u.current=new window.Bokeh.protocol.Receiver,j.on_change(C=>{var S;_E(C)&&C.sync&&((S=y.current)==null||S.add(C))}),h(b)})()},[i,c,o,p]),(0,s.jsx)("div",{ref:l,children:Object.values(o.roots).map(b=>(0,s.jsx)("div",{id:b,children:(0,s.jsx)("div",{"data-root-id":b,style:{display:"contents"}})},b))})};function TE(t){if(!t)return null;try{return window.Bokeh.index.get_by_id(t).model.document}catch(e){return de.warn("Failed to get Bokeh document",e),null}}function _E(t){return!!t&&typeof t=="object"&&"sync"in t}function ev(t){return!!t&&typeof t=="object"&&"document"in t}var AE={removeOnUnmount:!1};function IE(t,e=AE){let[a,r]=f.useState(()=>{var n;return((n=document.querySelector(`script[src="${t}"]`))==null?void 0:n.dataset.status)||"unknown"});return f.useEffect(()=>{let n=document.querySelector(`script[src="${t}"]`),i=c=>{n&&(n.dataset.status=c,r(c))},o=()=>i("ready"),l=()=>i("error"),d=c=>{let m=new MutationObserver(()=>{let p=c.dataset.status;p&&r(p)});return m.observe(c,{attributes:!0,attributeFilter:["data-status"]}),m};if(!n){n=document.createElement("script"),n.src=t,n.async=!0,i("loading"),document.body.append(n),n.addEventListener("load",o),n.addEventListener("error",l);let c=d(n);return()=>{c.disconnect(),n&&(n.removeEventListener("load",o),n.removeEventListener("error",l),e.removeOnUnmount&&n.remove())}}let u=n.dataset.status;if(u){if(u==="ready"||u==="error")return;let c=d(n);return()=>c.disconnect()}r("unknown")},[t,e.removeOnUnmount]),a}function tv(t){let e=/([^<=>]+)=%{([^}]+)}/g,a={},r;for(;(r=e.exec(t))!==null;)a[r[1]]=r[2];return{update(n){return n===t?this:tv(n)},parse(n){return Object.entries(a).reduce((i,[o,l])=>(i[o]=yT(n,l),i),{})}}}var PE=te();const ME=["dragmode","xaxis","yaxis"],FE=["autosize","dragmode","xaxis","yaxis"];function Bu(t){return{autosize:t.layout.width===void 0,dragmode:"select",height:540,...t.layout}}function VE(t,e){return{...Bu(t),...fa.pick(e,ME)}}function zE(t,e){let a=new Set(FE);for(let r of a)fl(t[r],e[r])||a.delete(r);return a}function OE(t,e,a){let r=zE(t,e),n=fa.omit(t,r);return{...a,...n}}function LE(t){let e=(0,PE.c)(20),{originalFigure:a,initialValue:r,isScriptLoaded:n}=t,i=n===void 0?!0:n,o;e[0]===a?o=e[1]:(o=()=>structuredClone(a),e[0]=a,e[1]=o);let[l,d]=(0,f.useState)(o),u;e[2]!==l||e[3]!==r?(u=()=>({...Bu(l),...r}),e[2]=l,e[3]=r,e[4]=u):u=e[4];let[c,m]=(0,f.useState)(u),p;e[5]===a?p=e[6]:(p=()=>{let j=structuredClone(a);d(j),m(C=>VE(j,C))},e[5]=a,e[6]=p);let h;e[7]!==i||e[8]!==a?(h=[a,i],e[7]=i,e[8]=a,e[9]=h):h=e[9],(0,f.useEffect)(p,h);let x=T_(l)??l,g,y;e[10]!==l.layout||e[11]!==x.layout?(g=()=>{m(j=>OE(l.layout,x.layout,j))},y=[l.layout,x.layout],e[10]=l.layout,e[11]=x.layout,e[12]=g,e[13]=y):(g=e[12],y=e[13]),(0,f.useEffect)(g,y);let b;e[14]===a?b=e[15]:(b=()=>{let j=structuredClone(a);d(j),m(Bu(j))},e[14]=a,e[15]=b);let w=b,D;return e[16]!==l||e[17]!==w||e[18]!==c?(D={figure:l,layout:c,setLayout:m,handleReset:w},e[16]=l,e[17]=w,e[18]=c,e[19]=D):D=e[19],D}var $E=te(),BE=class{constructor(){Z(this,"tagName","marimo-plotly");Z(this,"validator",L({figure:L({}).passthrough().transform(t=>t),config:L({}).passthrough()}))}render(t){return(0,s.jsx)(rv,{...t.data,host:t.host,value:t.value,setValue:t.setValue})}},HE=(0,f.lazy)(()=>jt(()=>import("./Plot-BjXmaHZg.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([354,11,10,9]),import.meta.url).then(t=>({default:t.Plot}))),av=["color","curveNumber","entry","hovertext","id","label","parent","percentEntry","percentParent","percentRoot","pointNumber","root","value"],WE=av;const rv=(0,f.memo)(t=>{let e=(0,$E.c)(37),{figure:a,value:r,setValue:n,config:i}=t,o=IE("https://cdn.jsdelivr.net/npm/mathjax-full@3.2.2/es5/tex-mml-svg.min.js")==="ready",l;e[0]!==o||e[1]!==a||e[2]!==r?(l={originalFigure:a,initialValue:r,isScriptLoaded:o},e[0]=o,e[1]=a,e[2]=r,e[3]=l):l=e[3];let{figure:d,layout:u,handleReset:c}=LE(l),m;e[4]!==c||e[5]!==n?(m=()=>{c(),n({})},e[4]=c,e[5]=n,e[6]=m):m=e[6];let p=Ue(m),h=sr(i),x;e[7]===Symbol.for("react.memo_cache_sentinel")?(x={svg:`
31
31
  <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor"
32
32
  stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-rotate-ccw">