@marimo-team/frontend 0.23.3-dev22 → 0.23.3-dev23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{JsonOutput-ChlI2Rcq.js → JsonOutput-BLiYwyAC.js} +1 -1
- package/dist/assets/{add-connection-dialog-D4egHycB.js → add-connection-dialog-C1aIq9FP.js} +1 -1
- package/dist/assets/{agent-panel-B9qfQkjK.js → agent-panel-CF8K90JH.js} +1 -1
- package/dist/assets/{cell-editor-BciNtNBM.js → cell-editor-B1SaikL0.js} +1 -1
- package/dist/assets/{column-preview-DZGGZYAY.js → column-preview-rQE4qc5R.js} +1 -1
- package/dist/assets/{command-palette-C7NnRcfP.js → command-palette-BK7W-HN4.js} +1 -1
- package/dist/assets/{edit-page-BX4jv2i-.js → edit-page-CoE4C833.js} +3 -3
- package/dist/assets/{file-explorer-panel-rRNjUnK5.js → file-explorer-panel-Ci0Cz4JU.js} +1 -1
- package/dist/assets/{form-B5Zfx4cn.js → form-BON4sAdY.js} +1 -1
- package/dist/assets/{hooks-toE2zzDy.js → hooks-CLXoEljg.js} +1 -1
- package/dist/assets/{index-DyhAORlA.js → index-yDm96tKj.js} +3 -3
- package/dist/assets/{layout-CX1oKyFB.js → layout-B31_eP6P.js} +3 -3
- package/dist/assets/{panels-CMep1Kk9.js → panels-CfgYkAvQ.js} +1 -1
- package/dist/assets/{reveal-component-DNVS81N_.js → reveal-component-Bt3Epro6.js} +1 -1
- package/dist/assets/{run-page-fS3bsdcc.js → run-page-4lA-192f.js} +1 -1
- package/dist/assets/{scratchpad-panel-2N56xPu4.js → scratchpad-panel-DZH011QZ.js} +1 -1
- package/dist/assets/{session-panel-DTU0bHW4.js → session-panel-oGdw6hvF.js} +1 -1
- package/dist/assets/{slide-CHcKvgFE.js → slide-C5wPx0qL.js} +1 -1
- package/dist/assets/{state-wy7oHhYg.js → state-DpMLCkRP.js} +1 -1
- package/dist/assets/{useNotebookActions-xdSJIXJ7.js → useNotebookActions-BNa64TgF.js} +1 -1
- package/dist/index.html +5 -5
- package/package.json +1 -1
- package/src/components/editor/file-tree/renderers.tsx +1 -1
|
@@ -42,7 +42,7 @@ To suppress this warning, you need to explicitly provide the \`palette.${e}Chann
|
|
|
42
42
|
`),o;return r&&(o=`<table>${l.map(i=>`<tr>${i.map(c=>`<td>${c.html??By(c.text)}</td>`).join("")}</tr>`).join("")}</table>`),{text:a,html:o}}function By(t){let e=document.createElement("div");return e.textContent=t,e.innerHTML}function Wy(t){let e=0;for(let n of t)n.includes("__select__")||(e+=1);return e}function Gy(t,e){let n=[];for(let r of e){if(r.includes("__select__"))continue;let{rowId:l,columnId:a}=hu(r),o=t.getRow(l);if(!o)continue;let i=za(t,o.index,a)??o.getValue(a),c;if(typeof i=="number")c=i;else if(typeof i=="string"){if(i.trim()==="")continue;c=Number(i)}else continue;Number.isFinite(c)&&n.push(c)}return n}function $r(t,e,n){var h,w;let r=t.getRow(e.rowId),l=t.getRow(n.rowId);if(!r||!l)return[];let a=r.index,o=l.index,i=(h=t.getColumn(e.columnId))==null?void 0:h.getIndex(),c=(w=t.getColumn(n.columnId))==null?void 0:w.getIndex();if(i===void 0||c===void 0)return[];let u=Math.min(a,o),d=Math.max(a,o),p=Math.min(i,c),m=Math.max(i,c),g=[];g.length=(d-u+1)*(m-p+1);let f=0,b=t.getAllColumns().map(v=>v.id),S=t.getRowModel().rows;for(let v=u;v<=d;v++){let j=S[v].id;for(let k=p;k<=m;k++){let C=b[k];g[f++]=qy(j,C)}}return g.length=f,g}function qy(t,e){return`${t}_${e}`}function hu(t){let e=t.indexOf("_");return{rowId:t.slice(0,e),columnId:t.slice(e+1)}}function Ky(){return{selectedCells:new Set,copiedCells:new Set,selectedStartCell:null,focusedCell:null,isSelecting:!1}}var{valueAtom:Pt,useActions:Uy,createActions:fw,reducer:gw}=eS(Ky,{setSelectedCells:(t,e)=>({...t,selectedCells:e}),setSelectedStartCell:(t,e)=>({...t,selectedStartCell:e}),setFocusedCell:(t,e)=>({...t,focusedCell:e}),setIsSelecting:(t,e)=>({...t,isSelecting:e}),setCopiedCells:(t,e)=>({...t,copiedCells:e}),clearSelection:t=>({...t,selectedCells:new Set,selectedStartCell:null,focusedCell:null}),selectAllCells:(t,e)=>{let n=e.getRowModel().rows.flatMap(r=>r.getAllCells().map(l=>l.id));return{...t,selectedCells:new Set(n)}},toggleCurrentRowSelection:(t,e)=>{var r,l;let n=t.focusedCell;return n!=null&&n.rowId&&((l=(r=e.getRow(n==null?void 0:n.rowId))==null?void 0:r.toggleSelected)==null||l.call(r)),t},updateSelection:(t,{newCell:e,isShiftKey:n,table:r})=>{if(n&&t.selectedStartCell){let l=$r(r,t.selectedStartCell,e);return{...t,selectedCells:new Set(l),focusedCell:e}}else return{...t,selectedCells:new Set([e.cellId]),selectedStartCell:e,focusedCell:e}},updateRangeSelection:(t,{cell:e,table:n})=>{if(!t.selectedStartCell)return t;let r={rowId:e.row.id,columnId:e.column.id,cellId:e.id},l=$r(n,t.selectedStartCell,r);return l.length>1&&Yy(),{...t,selectedCells:new Set(l)}},handleCopy:(t,{table:e,onCopyComplete:n})=>{let r=window.getSelection();if(r&&r.toString().length>0)return t;let{text:l,html:a}=Hy(e,t.selectedCells);return on(l,a),n(),{...t,copiedCells:t.selectedCells}},navigate:(t,{direction:e,isShiftKey:n,table:r})=>{let l=t.focusedCell??t.selectedStartCell;if(!l)return t;let a;if(e==="up"||e==="down"){let i=r.getRowModel().rows,c=i.findIndex(d=>d.id===l.rowId);if(c<0)return t;let u=e==="up"?i[c-1]:i[c+1];if(!u)return t;a=u.getAllCells().find(d=>d.column.id===l.columnId)}if(e==="left"||e==="right"){let i=r.getRow(l.rowId).getAllCells(),c=i.findIndex(u=>u.id===l.cellId);if(c<0)return t;a=e==="left"?i[c-1]:i[c+1]}if(!a)return t;let o={rowId:a.row.id,columnId:a.column.id,cellId:a.id};if(n&&t.selectedStartCell){let i=$r(r,t.selectedStartCell,o);return{...t,selectedCells:new Set(i),focusedCell:o}}else return{...t,selectedCells:new Set([o.cellId]),selectedStartCell:o,focusedCell:o}},handleCellMouseDown:(t,{cell:e,isShiftKey:n,isCtrlKey:r,table:l})=>{let a={rowId:e.row.id,columnId:e.column.id,cellId:e.id};if(n&&t.selectedStartCell){let o=$r(l,t.selectedStartCell,a);return{...t,selectedCells:new Set(o),isSelecting:!0}}return r?t:t.selectedCells.size===1&&t.selectedCells.has(a.cellId)?{...t,selectedCells:new Set,selectedStartCell:null,focusedCell:null}:{...t,selectedCells:new Set([a.cellId]),selectedStartCell:a,focusedCell:a,isSelecting:!0}}});const qa=Pe(t=>t(Pt).selectedCells),Jy=Pe(t=>t(Pt).copiedCells);Pe(t=>t(Pt).selectedStartCell),Pe(t=>t(Pt).focusedCell),Pe(t=>t(Pt).isSelecting);const Xy=t=>Pe(e=>{let n=e(qa),r=e(Jy);return{isSelected:n.has(t),isCopied:r.has(t)}}),Yy=()=>{var t;window.getSelection&&((t=window.getSelection())==null||t.empty())};var Qy=L();const Zy=t=>{let e=(0,Qy.c)(3),{children:n}=t,r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=[Pt],e[0]=r):r=e[0];let l;return e[1]===n?l=e[2]:(l=(0,s.jsx)(Ly,{atoms:r,children:n}),e[1]=n,e[2]=l),l};function Yt(t,e,n){let r=n.initialDeps??[],l,a=!0;function o(){var d,p,m;let i;n.key&&((d=n.debug)!=null&&d.call(n))&&(i=Date.now());let c=t();if(!(c.length!==r.length||c.some((g,f)=>r[f]!==g)))return l;r=c;let u;if(n.key&&((p=n.debug)!=null&&p.call(n))&&(u=Date.now()),l=e(...c),n.key&&((m=n.debug)==null?void 0:m.call(n))){let g=Math.round((Date.now()-i)*100)/100,f=Math.round((Date.now()-u)*100)/100,b=f/16,S=(h,w)=>{for(h=String(h);h.length<w;)h=" "+h;return h};console.info(`%c\u23F1 ${S(f,5)} /${S(g,5)} ms`,`
|
|
43
43
|
font-size: .6rem;
|
|
44
44
|
font-weight: bold;
|
|
45
|
-
color: hsl(${Math.max(0,Math.min(120-120*b,120))}deg 100% 31%);`,n==null?void 0:n.key)}return n!=null&&n.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(l),a=!1,l}return o.updateDeps=i=>{r=i},o}function yu(t,e){if(t===void 0)throw Error(`Unexpected undefined${e?`: ${e}`:""}`);return t}var ex=(t,e)=>Math.abs(t-e)<1.01,tx=(t,e,n)=>{let r;return function(...l){t.clearTimeout(r),r=t.setTimeout(()=>e.apply(this,l),n)}},xu=t=>{let{offsetWidth:e,offsetHeight:n}=t;return{width:e,height:n}},nx=t=>t,rx=t=>{let e=Math.max(t.startIndex-t.overscan,0),n=Math.min(t.endIndex+t.overscan,t.count-1),r=[];for(let l=e;l<=n;l++)r.push(l);return r},lx=(t,e)=>{let n=t.scrollElement;if(!n)return;let r=t.targetWindow;if(!r)return;let l=o=>{let{width:i,height:c}=o;e({width:Math.round(i),height:Math.round(c)})};if(l(xu(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(o=>{let i=()=>{let c=o[0];if(c!=null&&c.borderBoxSize){let u=c.borderBoxSize[0];if(u){l({width:u.inlineSize,height:u.blockSize});return}}l(xu(n))};t.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()});return a.observe(n,{box:"border-box"}),()=>{a.unobserve(n)}},bu={passive:!0},vu=typeof window>"u"?!0:"onscrollend"in window,ax=(t,e)=>{let n=t.scrollElement;if(!n)return;let r=t.targetWindow;if(!r)return;let l=0,a=t.options.useScrollendEvent&&vu?()=>{}:tx(r,()=>{e(l,!1)},t.options.isScrollingResetDelay),o=d=>()=>{let{horizontal:p,isRtl:m}=t.options;l=p?n.scrollLeft*(m&&-1||1):n.scrollTop,a(),e(l,d)},i=o(!0),c=o(!1);n.addEventListener("scroll",i,bu);let u=t.options.useScrollendEvent&&vu;return u&&n.addEventListener("scrollend",c,bu),()=>{n.removeEventListener("scroll",i),u&&n.removeEventListener("scrollend",c)}},ox=(t,e,n)=>{if(e!=null&&e.borderBoxSize){let r=e.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return t[n.options.horizontal?"offsetWidth":"offsetHeight"]},ix=(t,{adjustments:e=0,behavior:n},r)=>{var i;var l,a;let o=t+e;(a=(i=l=r.scrollElement)==null?void 0:i.scrollTo)==null||a.call(l,{[r.options.horizontal?"left":"top"]:o,behavior:n})},sx=class{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var n,r,l;var e;return((l=(r=e=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:r.now)==null?void 0:l.call(e))??Date.now()},this.observer=(()=>{let e=null,n=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(r=>{r.forEach(l=>{let a=()=>{let o=l.target,i=this.indexFromElement(o);if(!o.isConnected){this.observer.unobserve(o);return}this.shouldMeasureDuringScroll(i)&&this.resizeItem(i,this.options.measureElement(o,l,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()})}));return{disconnect:()=>{var r;(r=n())==null||r.disconnect(),e=null},observe:r=>{var l;return(l=n())==null?void 0:l.observe(r,{box:"border-box"})},unobserve:r=>{var l;return(l=n())==null?void 0:l.unobserve(r)}}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([n,r])=>{r===void 0&&delete e[n]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:nx,rangeExtractor:rx,onChange:()=>{},measureElement:ox,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var n,r;(r=(n=this.options).onChange)==null||r.call(n,this,e)},this.maybeNotify=Yt(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(r=>{this.observer.observe(r)}),this.unsubs.push(this.options.observeElementRect(this,r=>{this.scrollRect=r,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(r,l)=>{this.scrollAdjustments=0,this.scrollDirection=l?this.getScrollOffset()<r?"forward":"backward":null,this.scrollOffset=r,this.isScrolling=l,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,n)=>{let r=new Map,l=new Map;for(let a=n-1;a>=0;a--){let o=e[a];if(r.has(o.lane))continue;let i=l.get(o.lane);if(i==null||o.end>i.end?l.set(o.lane,o):o.end<i.end&&r.set(o.lane,!0),r.size===this.options.lanes)break}return l.size===this.options.lanes?Array.from(l.values()).sort((a,o)=>a.end===o.end?a.index-o.index:a.end-o.end)[0]:void 0},this.getMeasurementOptions=Yt(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,n,r,l,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==o&&(this.lanesChangedFlag=!0),this.prevLanes=o,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:n,scrollMargin:r,getItemKey:l,enabled:a,lanes:o}),{key:!1}),this.getMeasurements=Yt(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:n,scrollMargin:r,getItemKey:l,enabled:a,lanes:o},i)=>{if(!a)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let p of this.laneAssignments.keys())p>=e&&this.laneAssignments.delete(p);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(p=>{this.itemSizeCache.set(p.key,p.size)}));let c=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let u=this.measurementsCache.slice(0,c),d=Array(o).fill(void 0);for(let p=0;p<c;p++){let m=u[p];m&&(d[m.lane]=p)}for(let p=c;p<e;p++){let m=l(p),g=this.laneAssignments.get(p),f,b;if(g!==void 0&&this.options.lanes>1){f=g;let v=d[f],j=v===void 0?void 0:u[v];b=j?j.end+this.options.gap:n+r}else{let v=this.options.lanes===1?u[p-1]:this.getFurthestMeasurement(u,p);b=v?v.end+this.options.gap:n+r,f=v?v.lane:p%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(p,f)}let S=i.get(m),h=typeof S=="number"?S:this.options.estimateSize(p),w=b+h;u[p]={index:p,start:b,size:h,end:w,key:m,lane:f},d[f]=p}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Yt(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,n,r,l)=>this.range=e.length>0&&n>0?cx({measurements:e,outerSize:n,scrollOffset:r,lanes:l}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Yt(()=>{let e=null,n=null,r=this.calculateRange();return r&&(e=r.startIndex,n=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,n]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,n]},(e,n,r,l,a)=>l===null||a===null?[]:e({startIndex:l,endIndex:a,overscan:n,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let n=this.options.indexAttribute,r=e.getAttribute(n);return r?parseInt(r,10):(console.warn(`Missing attribute name '${n}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{var r;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;let n=this.scrollState.index??((r=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:r.index);if(n!==void 0&&this.range){let l=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),a=Math.max(0,n-l),o=Math.min(this.options.count-1,n+l);return e>=a&&e<=o}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((a,o)=>{a.isConnected||(this.observer.unobserve(a),this.elementsCache.delete(o))});return}let n=this.indexFromElement(e),r=this.options.getItemKey(n),l=this.elementsCache.get(r);l!==e&&(l&&this.observer.unobserve(l),this.observer.observe(e),this.elementsCache.set(r,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,n)=>{var a;let r=this.measurementsCache[e];if(!r)return;let l=n-(this.itemSizeCache.get(r.key)??r.size);l!==0&&(((a=this.scrollState)==null?void 0:a.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(r,l,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=l,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(r.index),this.itemSizeCache=new Map(this.itemSizeCache.set(r.key,n)),this.notify(!1))},this.getVirtualItems=Yt(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,n)=>{let r=[];for(let l=0,a=e.length;l<a;l++){let o=n[e[l]];r.push(o)}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let n=this.getMeasurements();if(n.length!==0)return yu(n[Su(0,n.length-1,r=>yu(n[r]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,n,r=0)=>{if(!this.scrollElement)return 0;let l=this.getSize(),a=this.getScrollOffset();n==="auto"&&(n=e>=a+l?"end":"start"),n==="center"?e+=(r-l)/2:n==="end"&&(e-=l);let o=this.getMaxScrollOffset();return Math.max(Math.min(o,e),0)},this.getOffsetForIndex=(e,n="auto")=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getSize(),l=this.getScrollOffset(),a=this.measurementsCache[e];if(!a)return;if(n==="auto")if(a.end>=l+r-this.options.scrollPaddingEnd)n="end";else if(a.start<=l+this.options.scrollPaddingStart)n="start";else return[l,n];if(n==="end"&&e===this.options.count-1)return[this.getMaxScrollOffset(),n];let o=n==="end"?a.end+this.options.scrollPaddingEnd:a.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(o,n,a.size),n]},this.scrollToOffset=(e,{align:n="start",behavior:r="auto"}={})=>{let l=this.getOffsetForAlignment(e,n);this.scrollState={index:null,align:n,behavior:r,startedAt:this.now(),lastTargetOffset:l,stableFrames:0},this._scrollToOffset(l,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:n="auto",behavior:r="auto"}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let l=this.getOffsetForIndex(e,n);if(!l)return;let[a,o]=l,i=this.now();this.scrollState={index:e,align:o,behavior:r,startedAt:i,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:n="auto"}={})=>{let r=this.getScrollOffset()+e;this.scrollState={index:null,align:"start",behavior:n,startedAt:this.now(),lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var r;let e=this.getMeasurements(),n;if(e.length===0)n=this.options.paddingStart;else if(this.options.lanes===1)n=((r=e[e.length-1])==null?void 0:r.end)??0;else{let l=Array(this.options.lanes).fill(null),a=e.length-1;for(;a>=0&&l.some(o=>o===null);){let o=e[a];l[o.lane]===null&&(l[o.lane]=o.end),a--}n=Math.max(...l.filter(o=>o!==null))}return Math.max(n-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:n,behavior:r})=>{this.options.scrollToFn(e,{behavior:r,adjustments:n},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(t)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let t=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),e=t?t[0]:this.scrollState.lastTargetOffset,n=e!==this.scrollState.lastTargetOffset;if(!n&&ex(e,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=e,this.scrollState.behavior="auto",this._scrollToOffset(e,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}},Su=(t,e,n,r)=>{for(;t<=e;){let l=(t+e)/2|0,a=n(l);if(a<r)t=l+1;else if(a>r)e=l-1;else return l}return t>0?t-1:0};function cx({measurements:t,outerSize:e,scrollOffset:n,lanes:r}){let l=t.length-1,a=c=>t[c].start;if(t.length<=r)return{startIndex:0,endIndex:l};let o=Su(0,l,a,n),i=o;if(r===1)for(;i<l&&t[i].end<n+e;)i++;else if(r>1){let c=Array(r).fill(0);for(;i<l&&c.some(d=>d<n+e);){let d=t[i];c[d.lane]=d.end,i++}let u=Array(r).fill(n+e);for(;o>=0&&u.some(d=>d>=n);){let d=t[o];u[d.lane]=d.start,o--}o=Math.max(0,o-o%r),i=Math.min(l,i+(r-1-i%r))}return{startIndex:o,endIndex:i}}var ux=tv(),wu=typeof document<"u"?x.useLayoutEffect:x.useEffect;function dx({useFlushSync:t=!0,...e}){let n=x.useReducer(()=>({}),{})[1],r={...e,onChange:(a,o)=>{var i;t&&o?(0,ux.flushSync)(n):n(),(i=e.onChange)==null||i.call(e,a,o)}},[l]=x.useState(()=>new sx(r));return l.setOptions(r),wu(()=>l._didMount(),[]),wu(()=>l._willUpdate()),l}function Cu(t){return dx({observeElementRect:lx,observeElementOffset:ax,scrollToFn:ix,...t})}let ft,Ka,ju,ku,_u;ft=L(),No=im,Ao=sm,Ka=uv(cm),ju=ad(mi),ku=ad(vi),_u=x.forwardRef((t,e)=>{let n=(0,ft.c)(14),r,l,a,o;n[0]===t?(r=n[1],l=n[2],a=n[3],o=n[4]):({className:l,inset:a,children:r,...o}=t,n[0]=t,n[1]=r,n[2]=l,n[3]=a,n[4]=o);let i;n[5]!==l||n[6]!==a?(i=fv({className:l,inset:a}),n[5]=l,n[6]=a,n[7]=i):i=n[7];let c;n[8]===Symbol.for("react.memo_cache_sentinel")?(c=(0,s.jsx)(qS,{className:"ml-auto h-4 w-4"}),n[8]=c):c=n[8];let u;return n[9]!==r||n[10]!==o||n[11]!==e||n[12]!==i?(u=(0,s.jsxs)(bi,{ref:e,className:i,...o,children:[r,c]}),n[9]=r,n[10]=o,n[11]=e,n[12]=i,n[13]=u):u=n[13],u}),_u.displayName=bi.displayName;var Ru="data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",mx=x.forwardRef((t,e)=>{let n=(0,ft.c)(9),r,l;n[0]===t?(r=n[1],l=n[2]):({className:r,...l}=t,n[0]=t,n[1]=r,n[2]=l);let a;n[3]===r?a=n[4]:(a=T(id({subcontent:!0}),Ru,r),n[3]=r,n[4]=a);let o;return n[5]!==l||n[6]!==e||n[7]!==a?(o=(0,s.jsx)(ku,{ref:e,className:a,...l}),n[5]=l,n[6]=e,n[7]=a,n[8]=o):o=n[8],o});mx.displayName=vi.displayName,pl=x.forwardRef((t,e)=>{let n=(0,ft.c)(15),r,l,a;n[0]===t?(r=n[1],l=n[2],a=n[3]):({className:r,scrollable:a,...l}=t,n[0]=t,n[1]=r,n[2]=l,n[3]=a);let o=a===void 0?!0:a,i;n[4]!==r||n[5]!==o?(i=T(id(),Ru,o&&"overflow-auto",r),n[4]=r,n[5]=o,n[6]=i):i=n[6];let c=o?`calc(var(--radix-context-menu-content-available-height) - ${dv}px)`:void 0,u;n[7]!==l.style||n[8]!==c?(u={...l.style,maxHeight:c},n[7]=l.style,n[8]=c,n[9]=u):u=n[9];let d;return n[10]!==l||n[11]!==e||n[12]!==i||n[13]!==u?(d=(0,s.jsx)(Ka,{children:(0,s.jsx)(sv,{children:(0,s.jsx)(ju,{ref:e,className:i,style:u,...l})})}),n[10]=l,n[11]=e,n[12]=i,n[13]=u,n[14]=d):d=n[14],d}),pl.displayName=mi.displayName,zt=x.forwardRef((t,e)=>{let n=(0,ft.c)(13),r,l,a,o;n[0]===t?(r=n[1],l=n[2],a=n[3],o=n[4]):({className:r,inset:l,variant:o,...a}=t,n[0]=t,n[1]=r,n[2]=l,n[3]=a,n[4]=o);let i;n[5]!==r||n[6]!==l||n[7]!==o?(i=gv({className:r,inset:l,variant:o}),n[5]=r,n[6]=l,n[7]=o,n[8]=i):i=n[8];let c;return n[9]!==a||n[10]!==e||n[11]!==i?(c=(0,s.jsx)(fi,{ref:e,className:i,...a}),n[9]=a,n[10]=e,n[11]=i,n[12]=c):c=n[12],c}),zt.displayName=fi.displayName,Fo=x.forwardRef((t,e)=>{let n=(0,ft.c)(15),r,l,a,o;n[0]===t?(r=n[1],l=n[2],a=n[3],o=n[4]):({className:a,children:l,checked:r,...o}=t,n[0]=t,n[1]=r,n[2]=l,n[3]=a,n[4]=o);let i;n[5]===a?i=n[6]:(i=mv({className:a}),n[5]=a,n[6]=i);let c;n[7]===Symbol.for("react.memo_cache_sentinel")?(c=no(),n[7]=c):c=n[7];let u;n[8]===Symbol.for("react.memo_cache_sentinel")?(u=(0,s.jsx)("span",{className:c,children:(0,s.jsx)(yi,{children:(0,s.jsx)(WS,{className:"h-4 w-4"})})}),n[8]=u):u=n[8];let d;return n[9]!==r||n[10]!==l||n[11]!==o||n[12]!==e||n[13]!==i?(d=(0,s.jsxs)(gi,{ref:e,className:i,checked:r,...o,children:[u,l]}),n[9]=r,n[10]=l,n[11]=o,n[12]=e,n[13]=i,n[14]=d):d=n[14],d}),Fo.displayName=gi.displayName;var px=x.forwardRef((t,e)=>{let n=(0,ft.c)(13),r,l,a;n[0]===t?(r=n[1],l=n[2],a=n[3]):({className:l,children:r,...a}=t,n[0]=t,n[1]=r,n[2]=l,n[3]=a);let o;n[4]===l?o=n[5]:(o=no({className:l}),n[4]=l,n[5]=o);let i;n[6]===Symbol.for("react.memo_cache_sentinel")?(i=no(),n[6]=i):i=n[6];let c;n[7]===Symbol.for("react.memo_cache_sentinel")?(c=(0,s.jsx)("span",{className:i,children:(0,s.jsx)(yi,{children:(0,s.jsx)(BS,{className:"h-4 w-4 fill-current"})})}),n[7]=c):c=n[7];let u;return n[8]!==r||n[9]!==a||n[10]!==e||n[11]!==o?(u=(0,s.jsxs)(hi,{ref:e,className:o,...a,children:[c,r]}),n[8]=r,n[9]=a,n[10]=e,n[11]=o,n[12]=u):u=n[12],u});px.displayName=hi.displayName;var fx=x.forwardRef((t,e)=>{let n=(0,ft.c)(11),r,l,a;n[0]===t?(r=n[1],l=n[2],a=n[3]):({className:r,inset:l,...a}=t,n[0]=t,n[1]=r,n[2]=l,n[3]=a);let o;n[4]!==r||n[5]!==l?(o=hv({className:r,inset:l}),n[4]=r,n[5]=l,n[6]=o):o=n[6];let i;return n[7]!==a||n[8]!==e||n[9]!==o?(i=(0,s.jsx)(pi,{ref:e,className:o,...a}),n[7]=a,n[8]=e,n[9]=o,n[10]=i):i=n[10],i});fx.displayName=pi.displayName,ml=x.forwardRef((t,e)=>{let n=(0,ft.c)(9),r,l;n[0]===t?(r=n[1],l=n[2]):({className:r,...l}=t,n[0]=t,n[1]=r,n[2]=l);let a;n[3]===r?a=n[4]:(a=T(pv({className:r})),n[3]=r,n[4]=a);let o;return n[5]!==l||n[6]!==e||n[7]!==a?(o=(0,s.jsx)(xi,{ref:e,className:a,...l}),n[5]=l,n[6]=e,n[7]=a,n[8]=o):o=n[8],o}),ml.displayName=xi.displayName;var gx=L();const hx=t=>{let e=(0,gx.c)(12),{contextMenuRef:n,tableBody:r,tableRef:l,copyAllCells:a}=t,o;e[0]!==n||e[1]!==l?(o=p=>{var f;let m=n.current;if(!m)return;let g=(f=l.current)==null?void 0:f.querySelector(`[${Ub}="${m.id}"]`);if(!g){st.error("Context menu cell not found in table");return}p?g.classList.add("bg-(--green-4)"):g.classList.remove("bg-(--green-4)")},e[0]=n,e[1]=l,e[2]=o):o=e[2];let i=it(o),c;e[3]===r?c=e[4]:(c=(0,s.jsx)(Ao,{asChild:!0,children:r}),e[3]=r,e[4]=c);let u;e[5]!==n||e[6]!==a?(u=(0,s.jsx)(Ka,{children:(0,s.jsx)(yx,{cellRef:n,copySelectedCells:a})}),e[5]=n,e[6]=a,e[7]=u):u=e[7];let d;return e[8]!==i||e[9]!==c||e[10]!==u?(d=(0,s.jsxs)(No,{onOpenChange:i,children:[c,u]}),e[8]=i,e[9]=c,e[10]=u,e[11]=d):d=e[11],d},yx=({cellRef:t,copySelectedCells:e})=>{var p;let n=$n(qa).size>1,r=t.current;if(!r){st.error("No cell found in context menu");return}let l=r.getContext().table,a=r.getValue(),o=za(l,r.row.index,r.column.id)??a,i=()=>{try{let{text:m,html:g}=qc(o,a);on(m,g)}catch(m){st.error("Failed to copy context menu cell",m)}},c=r.column,u=c.getCanFilter()&&((p=c.columnDef.meta)==null?void 0:p.filterType),d=m=>{c.setFilterValue(tt.select({options:[o],operator:m}))};return(0,s.jsxs)(pl,{children:[(0,s.jsxs)(zt,{onClick:i,children:[(0,s.jsx)(rl,{className:"mo-dropdown-icon h-3 w-3"}),"Copy cell"]}),n&&(0,s.jsxs)(zt,{onClick:e,children:[(0,s.jsx)($i,{className:"mo-dropdown-icon h-3 w-3"}),"Copy selected cells"]}),u&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ml,{}),(0,s.jsxs)(zt,{onClick:()=>d("in"),children:[(0,s.jsx)(Hn,{className:"mo-dropdown-icon h-3 w-3"}),"Filter by this value"]}),(0,s.jsxs)(zt,{onClick:()=>d("not_in"),children:[(0,s.jsx)(Hn,{className:"mo-dropdown-icon h-3 w-3"}),"Remove rows with this value"]})]})]})};var xx=L();const Nu=(0,x.memo)(t=>{let e=(0,xx.c)(9),{cellId:n,className:r}=t,l;e[0]===n?l=e[1]:(l=Xy(n),e[0]=n,e[1]=l);let{isSelected:a,isCopied:o}=$n(l);if(!a&&!o)return null;let i=a&&"bg-(--green-3)",c=o&&"bg-(--green-4) transition-colors duration-150",u;e[2]!==r||e[3]!==i||e[4]!==c?(u=T("absolute inset-0 pointer-events-none",i,c,r),e[2]=r,e[3]=i,e[4]=c,e[5]=u):u=e[5];let d;return e[6]!==n||e[7]!==u?(d=(0,s.jsx)("div",{"data-cell-id":n,className:u}),e[6]=n,e[7]=u,e[8]=d):d=e[8],d});Nu.displayName="CellRangeSelectionIndicator";var bx=L();const vx=t=>{let e=(0,bx.c)(30),{table:n}=t,r=Uy(),l;e[0]!==r||e[1]!==n?(l=()=>{r.handleCopy({table:n,onCopyComplete:()=>{setTimeout(()=>{r.setCopiedCells(new Set)},500)}})},e[0]=r,e[1]=n,e[2]=l):l=e[2];let a=it(l),o;e[3]!==r||e[4]!==n?(o=(v,j)=>{r.updateSelection({newCell:v,isShiftKey:j,table:n})},e[3]=r,e[4]=n,e[5]=o):o=e[5];let i=it(o),c;e[6]!==r||e[7]!==n?(c=(v,j)=>{r.navigate({direction:j,isShiftKey:v.shiftKey,table:n})},e[6]=r,e[7]=n,e[8]=c):c=e[8];let u=it(c),d;e[9]!==r||e[10]!==a||e[11]!==u||e[12]!==n?(d=v=>{e:switch(v.key){case"c":qe.isMetaOrCtrl(v)&&a();break e;case"ArrowDown":v.preventDefault(),u(v,"down");break e;case"ArrowUp":v.preventDefault(),u(v,"up");break e;case"ArrowLeft":v.preventDefault(),u(v,"left");break e;case"ArrowRight":v.preventDefault(),u(v,"right");break e;case"Enter":v.preventDefault(),r.toggleCurrentRowSelection(n);break e;case"Escape":r.clearSelection();break e;case"a":(v.metaKey||v.ctrlKey)&&(v.preventDefault(),r.selectAllCells(n))}},e[9]=r,e[10]=a,e[11]=u,e[12]=n,e[13]=d):d=e[13];let p=it(d),m;e[14]!==r||e[15]!==n?(m=(v,j)=>{v.buttons!==2&&(wx(v)||r.handleCellMouseDown({cell:j,isShiftKey:v.shiftKey,isCtrlKey:v.ctrlKey,table:n}))},e[14]=r,e[15]=n,e[16]=m):m=e[16];let g=it(m),f;e[17]===r?f=e[18]:(f=()=>{r.setIsSelecting(!1)},e[17]=r,e[18]=f);let b=it(f),S;e[19]!==r||e[20]!==n?(S=(v,j)=>{v.buttons===1&&r.updateRangeSelection({cell:j,table:n})},e[19]=r,e[20]=n,e[21]=S):S=e[21];let h=it(S),w;return e[22]!==r.clearSelection||e[23]!==g||e[24]!==h||e[25]!==b||e[26]!==p||e[27]!==a||e[28]!==i?(w={handleCellMouseDown:g,handleCellMouseUp:b,handleCellMouseOver:h,handleCopy:a,handleCellsKeyDown:p,updateSelection:i,clearSelection:r.clearSelection},e[22]=r.clearSelection,e[23]=g,e[24]=h,e[25]=b,e[26]=p,e[27]=a,e[28]=i,e[29]=w):w=e[29],w};var Sx='input, button, select, textarea, a, label, [role="checkbox"], [role="button"], [contenteditable="true"], marimo-ui-element';function wx(t){let e=t.target;return e===t.currentTarget||!(e instanceof Element)?!1:e.closest(Sx)!==null}var Cx=L(),jx=Pe(t=>t(Pt).focusedCell);function kx(t){let e=(0,Cx.c)(2),n;e[0]===t?n=e[1]:(n=r=>{r!=null&&r.cellId&&setTimeout(()=>{var a;let l=(a=t.current)==null?void 0:a.querySelector(`[data-cell-id="${r.cellId}"]`);if(!l){st.warn("[ScrollIntoView] Could not find cell with ID:",r.cellId);return}l.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})},0)},e[0]=t,e[1]=n),Pb(jx,n)}function _x(t,e){var r;if(!((r=t.getRowModel().rows)!=null&&r.length))return null;let n=l=>l.map(a=>a.headers.map(o=>{let{className:i,style:c}=Mu(o.column);return(0,s.jsx)(aw,{className:T("h-auto min-h-10 whitespace-pre align-top border-r border-r-border/75",i),style:c,ref:u=>{Nx({table:t,column:o.column,thead:u})},children:o.isPlaceholder?null:il(o.column.columnDef.header,o.getContext())},o.id)}));return(0,s.jsx)(lw,{className:T(e&&"sticky top-0 z-10"),children:(0,s.jsxs)(co,{children:[n(t.getLeftHeaderGroups()),n(t.getCenterHeaderGroups()),n(t.getRightHeaderGroups()),t.getAllColumns().length<=4&&(0,s.jsx)("th",{className:"w-full border-0","aria-hidden":"true",role:"presentation"})]})})}const Rx=({table:t,columns:e,rowViewerPanelOpen:n,getRowIndex:r,viewedRowIdx:l,virtualize:a=!1})=>{let o=t.getRowModel().rows,[i,c]=(0,x.useState)(null),u=(0,x.useRef)(null);(0,x.useLayoutEffect)(()=>{var _,y;c(((y=(_=u.current)==null?void 0:_.parentElement)==null?void 0:y.parentElement)??null)},[]);let d=Cu({count:a?o.length:0,getScrollElement:()=>i,estimateSize:()=>24,overscan:10});kx(u);let{handleCellMouseDown:p,handleCellMouseUp:m,handleCellMouseOver:g,handleCellsKeyDown:f,handleCopy:b}=vx({table:t}),S=(0,x.useRef)(null),h=it(_=>{S.current=_});function w(_,y){let R=/{{(\w+)}}/g,A=new Map;for(let I of y){let V=Mn({value:I.getValue(),nullAsEmptyString:!0});A.set(I.column.id,V)}return _.replaceAll(R,(I,V)=>{let E=A.get(V);return E===void 0?`{{${V}}}`:E})}let v=_=>_.map(y=>{var E,D,G,K;let{className:R,style:A}=Mu(y.column),I=Object.assign({},((E=y.getUserStyling)==null?void 0:E.call(y))||{},A),V=((D=y.getHoverTitle)==null?void 0:D.call(y))??void 0;return(0,x.createElement)(kd,{tabIndex:0,...Kb(y.id),key:y.id,className:T("whitespace-pre truncate max-w-[300px] outline-hidden border-r border-r-border/75",y.column.getColumnWrapping&&((K=(G=y.column).getColumnWrapping)==null?void 0:K.call(G))==="wrap"&&"whitespace-pre-wrap min-w-[200px]","px-1.5 py-[0.18rem]",R),style:I,title:V,onMouseDown:se=>p(se,y),onMouseUp:m,onMouseOver:se=>g(se,y),onContextMenu:()=>h(y)},(0,s.jsx)(Nu,{cellId:y.id}),(0,s.jsx)("div",{className:"relative",children:il(y.column.columnDef.cell,y.getContext())}))}),j=_=>{var y;if(n){let R=(r==null?void 0:r(_.original,_.index))??_.index;(y=_.focusRow)==null||y.call(_,R)}},k=t.getState().cellHoverTemplate||null,C=_=>{var I;let y=n?(r==null?void 0:r(_.original,_.index))??_.index:void 0,R=n&&l===y,A;return k&&(A=w(k,((I=_.getVisibleCells)==null?void 0:I.call(_))??[..._.getLeftVisibleCells(),..._.getCenterVisibleCells(),..._.getRightVisibleCells()])),(0,s.jsxs)(co,{"data-state":_.getIsSelected()&&"selected",title:A,className:T("border-t h-6",n&&"cursor-pointer",R&&"bg-(--blue-3) hover:bg-(--blue-3) data-[state=selected]:bg-(--blue-4)"),onClick:()=>j(_),children:[v(_.getLeftVisibleCells()),v(_.getCenterVisibleCells()),v(_.getRightVisibleCells()),e.length<=4&&(0,s.jsx)("td",{className:"border-0","aria-hidden":"true",role:"presentation"})]},_.id)},M=e.length<=4,N=e.length+(M?1:0);return(0,s.jsx)(hx,{tableBody:(0,s.jsx)(ow,{onKeyDown:f,ref:u,children:(()=>{var _,y;if(o.length===0)return(0,s.jsx)(co,{children:(0,s.jsx)(kd,{colSpan:N,className:"h-24 text-center",children:"No results."})});if(a){let R=d.getVirtualItems(),A=d.getTotalSize();return(0,s.jsxs)(s.Fragment,{children:[((_=R[0])==null?void 0:_.start)>0&&(0,s.jsx)("tr",{"data-virtual-spacer":"",style:{height:R[0].start},children:(0,s.jsx)("td",{colSpan:N})}),R.map(I=>C(o[I.index])),R.length>0&&(0,s.jsx)("tr",{"data-virtual-spacer":"",style:{height:A-(((y=R.at(-1))==null?void 0:y.end)??A)},children:(0,s.jsx)("td",{colSpan:N})})]})}return o.map(R=>C(R))})()}),contextMenuRef:S,tableRef:u,copyAllCells:b})};function Mu(t){let e=t.getIsPinned(),n=e==="left"&&t.getIsLastColumn("left"),r=e==="right"&&t.getIsFirstColumn("right");return{className:T(e&&"bg-inherit","shadow-r z-10"),style:{boxShadow:n&&t.id!=="__select__"?"-4px 0 4px -4px var(--slate-8) inset":r?"4px 0 4px -4px var(--slate-8) inset":void 0,left:e==="left"?`${t.getStart("left")}px`:void 0,right:e==="right"?`${t.getAfter("right")}px`:void 0,opacity:1,position:e?"sticky":"relative",zIndex:e?1:0,width:t.getSize()}}}function Nx({table:t,column:e,thead:n}){if(!n)return;let r=Math.round(n.getBoundingClientRect().width);t.getState().columnSizing[e.id]!==r&&t.setColumnSizing(l=>({...l,[e.id]:r}))}const Mx=({table:t,tableLoading:e,showPageSizeSelector:n})=>{let{locale:r}=Ke(),l=Math.min(t.getState().pagination.pageIndex+1,t.getPageCount()),a=t.getPageCount(),o=t.getState().pagination.pageSize,i=u=>{e||u()},c=[...new Set([5,10,25,50,100,o])].toSorted((u,d)=>u-d);return(0,s.jsxs)("div",{className:"flex flex-col lg:flex-row items-center gap-0.5 lg:gap-1 px-2",children:[(0,s.jsx)("div",{className:"order-2 lg:order-first",children:n&&(0,s.jsx)("div",{className:"flex items-center text-xs whitespace-nowrap mr-1 print:hidden",children:(0,s.jsxs)(Zr,{children:[(0,s.jsx)(Xr,{asChild:!0,children:(0,s.jsxs)("button",{type:"button",className:"border rounded justify-between pl-1.5 pr-0.5 h-6 text-xs items-center hover:bg-accent inline-flex gap-0.5",children:[o," / page",(0,s.jsx)(el,{className:"h-3 w-3 opacity-50 mb-px"})]})}),(0,s.jsxs)(Yr,{align:"center",sideOffset:6,children:[(0,s.jsx)(lo,{className:"text-xs text-muted-foreground",children:"Rows per page"}),[...c].map(u=>(0,s.jsx)(ee,{className:T("text-xs cursor-pointer",u===o&&"font-semibold bg-accent"),onSelect:()=>t.setPageSize(u),onMouseDown:qe.preventFocus,children:u},u))]})]})})}),(0,s.jsxs)("div",{className:"order-1 lg:order-last flex items-center print:hidden",children:[(0,s.jsx)(Ce,{content:"First page",children:(0,s.jsx)(ce,{size:"xs",variant:"text","data-testid":"first-page-button",className:"hidden h-6 w-5 p-0 lg:flex",onClick:()=>i(()=>t.setPageIndex(0)),onMouseDown:qe.preventFocus,disabled:!t.getCanPreviousPage(),children:(0,s.jsx)(_o,{className:"h-4 w-4"})})}),(0,s.jsx)(Ce,{content:"Previous page",children:(0,s.jsx)(ce,{size:"xs",variant:"text","data-testid":"previous-page-button",className:"h-6 w-5 p-0",onClick:()=>i(()=>t.previousPage()),onMouseDown:qe.preventFocus,disabled:!t.getCanPreviousPage(),children:(0,s.jsx)(Uv,{className:"h-4 w-4"})})}),(0,s.jsxs)("div",{className:"flex items-center justify-center text-xs font-medium gap-1",children:[(0,s.jsx)("span",{children:"Page"}),(0,s.jsx)(Ix,{currentPage:l,totalPages:a,onPageChange:u=>i(()=>t.setPageIndex(u))}),(0,s.jsxs)("span",{className:"shrink-0",children:["of ",Oe(a,r)]})]}),(0,s.jsx)(Ce,{content:"Next page",children:(0,s.jsx)(ce,{size:"xs",variant:"text","data-testid":"next-page-button",className:"h-6 w-5 p-0",onClick:()=>i(()=>t.nextPage()),onMouseDown:qe.preventFocus,disabled:!t.getCanNextPage(),children:(0,s.jsx)(cS,{className:"h-4 w-4"})})}),(0,s.jsx)(Ce,{content:"Last page",children:(0,s.jsx)(ce,{size:"xs",variant:"text","data-testid":"last-page-button",className:"hidden h-6 w-5 p-0 lg:flex",onClick:()=>i(()=>t.setPageIndex(t.getPageCount()-1)),onMouseDown:qe.preventFocus,disabled:!t.getCanNextPage(),children:(0,s.jsx)(Jo,{className:"h-4 w-4"})})})]})]})};var Ua=32;function Fx(t,e){let n=Number.parseInt(t,10);if(Number.isNaN(n)||n<=0||String(n)!==t)return[];let r=[],l=1;for(;n*l<=e;){let a=n*l,o=Math.min((n+1)*l-1,e);r.push([a,o]),l*=10}return r}function Ax(t,e){if(t==="")return{count:e,pageAtIndex:l=>l+1,indexOfPage:l=>l-1};let n=Fx(t,e),r=0;for(let[l,a]of n)r+=a-l+1;return{count:r,pageAtIndex:l=>{let a=0;for(let[o,i]of n){let c=i-o+1;if(l<a+c)return o+(l-a);a+=c}return-1},indexOfPage:l=>{let a=0;for(let[o,i]of n){if(l>=o&&l<=i)return a+(l-o);a+=i-o+1}return-1}}}const Ix=({currentPage:t,totalPages:e,onPageChange:n})=>{let[r,l]=x.useState(!1),[a,o]=x.useState(""),i=x.useMemo(()=>Ax(a,e),[a,e]),c=d=>{n(d-1),o(""),l(!1)},u=Math.min(i.count*Ua,240);return(0,s.jsxs)(Ur,{open:e>1?r:!1,onOpenChange:d=>{l(d),d||o("")},children:[(0,s.jsx)(qr,{asChild:!0,disabled:e<=1,children:(0,s.jsxs)("button",{type:"button",className:T("border rounded justify-between pl-1.5 pr-0.5 h-6 min-w-9 text-xs items-center inline-flex gap-0.5",e>1?"hover:bg-accent cursor-pointer":"opacity-50 cursor-default"),"data-testid":"page-select",disabled:e<=1,children:[t,(0,s.jsx)(el,{className:"h-3 w-3 opacity-50 mb-px"})]})}),(0,s.jsx)(Kr,{className:"w-36 p-0",align:"center",sideOffset:6,children:(0,s.jsxs)(jd,{shouldFilter:!1,value:String(t),children:[(0,s.jsx)(Sd,{placeholder:`Page (1\u2013${e})`,rootClassName:"px-2 h-8",className:"text-xs h-8",autoFocus:!0,icon:null,value:a,onValueChange:o,onKeyDown:d=>{!["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Enter","Escape"].includes(d.key)&&!/^\d$/.test(d.key)&&d.preventDefault()}}),(0,s.jsx)(Cd,{className:"max-h-60 overflow-hidden",children:i.count===0?(0,s.jsx)(wd,{className:"py-2 text-center text-xs text-muted-foreground",children:"No matching page"}):(0,s.jsx)(Ex,{mapping:i,currentPage:t,listHeight:u,onSelect:c})})]})})]})};var Ex=({mapping:t,currentPage:e,listHeight:n,onSelect:r})=>{let l=x.useRef(null),a=t.indexOfPage(e),o=Cu({count:t.count,getScrollElement:()=>l.current,estimateSize:()=>Ua,overscan:10,initialOffset:a>0?Math.max(0,a*Ua-n/2):0}),i=x.useRef(t.count);return x.useEffect(()=>{t.count!==i.current&&(o.scrollToIndex(0),i.current=t.count)},[t.count,o]),(0,s.jsx)("div",{ref:l,style:{height:n,overflow:"auto"},children:(0,s.jsx)("div",{style:{height:o.getTotalSize(),width:"100%",position:"relative"},children:o.getVirtualItems().map(c=>{let u=t.pageAtIndex(c.index);return(0,s.jsx)(so,{value:String(u),"data-testid":"page-option","aria-selected":u===e,className:T("text-xs cursor-pointer",u===e&&"font-semibold bg-accent"),style:{position:"absolute",top:0,left:0,width:"100%",height:c.size,transform:`translateY(${c.start}px)`},onSelect:()=>r(u),onMouseDown:qe.preventFocus,children:u},u)})})})};Bo=function(t,e){return`${Oe(t,e)} ${new Zu("row").pluralize(t)}`},$o=({numRows:t,totalColumns:e,locale:n})=>[t==="too_many"?"Unknown":Bo(t,n),`${Oe(e,n)} ${new Zu("column").pluralize(e)}`].join(", ");var In=L(),Ja=3;const Fu=t=>{let e=(0,In.c)(21),{table:n,className:r}=t,{locale:l}=Ke(),a=$n(qa),o=Wy(a);if(o<2){let f;e[0]===r?f=e[1]:(f=T("text-xs text-muted-foreground/80 italic",r),e[0]=r,e[1]=f);let b;return e[2]===f?b=e[3]:(b=(0,s.jsx)(Ce,{content:"Select multiple cells to see stats",children:(0,s.jsx)("span",{className:f,children:"No selection"})}),e[2]=f,e[3]=b),b}let i;e[4]!==a||e[5]!==n?(i=Gy(n,a),e[4]=a,e[5]=n,e[6]=i):i=e[6];let c=i,u;e[7]===r?u=e[8]:(u=T("flex items-center justify-end gap-3 text-sm text-muted-foreground shrink-0",r),e[7]=r,e[8]=u);let d;e[9]!==o||e[10]!==l?(d=(0,s.jsx)(Ox,{count:o,locale:l}),e[9]=o,e[10]=l,e[11]=d):d=e[11];let p,m;e[12]!==l||e[13]!==c?(p=(0,s.jsx)($x,{numericValues:c,locale:l}),m=(0,s.jsx)(Tx,{numericValues:c,locale:l}),e[12]=l,e[13]=c,e[14]=p,e[15]=m):(p=e[14],m=e[15]);let g;return e[16]!==u||e[17]!==d||e[18]!==p||e[19]!==m?(g=(0,s.jsxs)("div",{className:u,children:[d,p,m]}),e[16]=u,e[17]=d,e[18]=p,e[19]=m,e[20]=g):g=e[20],g};var Px=(t,e)=>t.toLocaleString(e,{maximumFractionDigits:Ja}),Xa=t=>{let e=(0,In.c)(6),{name:n,value:r,locale:l}=t,a;e[0]!==l||e[1]!==r?(a=Px(r,l),e[0]=l,e[1]=r,e[2]=a):a=e[2];let o;return e[3]!==n||e[4]!==a?(o=(0,s.jsxs)("span",{children:[n,": ",a]}),e[3]=n,e[4]=a,e[5]=o):o=e[5],o},Ox=t=>{let e=(0,In.c)(3),{count:n,locale:r}=t,l;return e[0]!==n||e[1]!==r?(l=(0,s.jsx)(Xa,{name:"Count",value:n,locale:r}),e[0]=n,e[1]=r,e[2]=l):l=e[2],l},$x=t=>{let e=(0,In.c)(6),{numericValues:n,locale:r}=t;if(n.length===0)return null;let l,a;if(e[0]!==n){let c=n.reduce(zx,0);l=Number,a=c.toFixed(Ja),e[0]=n,e[1]=l,e[2]=a}else l=e[1],a=e[2];let o=l(a),i;return e[3]!==r||e[4]!==o?(i=(0,s.jsx)(Xa,{name:"Sum",value:o,locale:r}),e[3]=r,e[4]=o,e[5]=i):i=e[5],i},Tx=t=>{let e=(0,In.c)(5),{numericValues:n,locale:r}=t;if(n.length===0)return null;let l=n.reduce(Vx,0)/n.length,a;e[0]===l?a=e[1]:(a=l.toFixed(Ja),e[0]=l,e[1]=a);let o=Number(a),i;return e[2]!==o||e[3]!==r?(i=(0,s.jsx)(Xa,{name:"Average",value:o,locale:r}),e[2]=o,e[3]=r,e[4]=i):i=e[4],i};function zx(t,e){return t+e}function Vx(t,e){return t+e}const Dx=({pagination:t,totalColumns:e,selection:n,onRowSelectionChange:r,table:l,getRowIds:a,showPageSizeSelector:o,tableLoading:i,part:c,className:u})=>{let{locale:d}=Ke(),p=m=>{if(!r)return;if(!m){r({});return}let g=()=>{let f=Array.from({length:l.getRowCount()},(b,S)=>[S,!0]);r(Object.fromEntries(f))};if(!a){g();return}a({}).then(f=>{if(f.error){Vn({title:"Not available",description:f.error,variant:"danger"});return}f.all_rows?g():r(Object.fromEntries(f.row_ids.map(b=>[b,!0])))})};return(0,s.jsxs)("div",{part:c,className:T("flex lg:grid lg:grid-cols-[1fr_auto_1fr] items-center shrink-0",u),children:[(0,s.jsxs)("div",{className:"flex flex-col text-sm text-muted-foreground px-2 shrink-0",children:[(0,s.jsx)("div",{className:"flex items-center gap-1",children:(()=>{let{rowSelection:m,cellSelection:g}=l.getState(),f=Object.keys(m).length,b=l.getIsAllPageRowsSelected(),S=l.getRowCount(),h=f===S,w=n==="single-cell"||n==="multi-cell";return w&&(f=g.length,b=!1,h=!1),b&&!h?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{children:[Oe(f,d)," selected"]}),(0,s.jsxs)(ce,{size:"xs","data-testid":"select-all-button",variant:"link",className:"h-4 print:hidden",onMouseDown:qe.preventFocus,onClick:()=>p(!0),children:["Select all ",Oe(S,d)]})]}):f?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{children:[Oe(f,d)," selected"]}),(0,s.jsx)(ce,{size:"xs","data-testid":"clear-selection-button",variant:"link",className:"h-4 print:hidden",onMouseDown:qe.preventFocus,onClick:()=>{w?l.resetCellSelection&&l.resetCellSelection():p(!1)},children:"Clear selection"})]}):(0,s.jsx)("span",{children:$o({numRows:l.getRowCount(),totalColumns:e,locale:d})})})()}),(0,s.jsx)(Fu,{table:l,className:"lg:hidden"})]}),(0,s.jsx)("div",{className:"ml-auto lg:ml-0 lg:justify-self-center flex items-center shrink-0",children:t&&(0,s.jsx)(Mx,{table:l,tableLoading:i,showPageSizeSelector:o})}),(0,s.jsx)("div",{className:"hidden lg:flex justify-end",children:(0,s.jsx)(Fu,{table:l,className:"px-2"})})]})};var Lx=L();Ro=t=>{let e=(0,Lx.c)(13),{packages:n,showMaxPackages:r,className:l,onInstall:a}=t,{handleInstallPackages:o}=QS();if(!n||n.length===0)return null;let i;e[0]!==o||e[1]!==a||e[2]!==n?(i=()=>{o(n,a)},e[0]=o,e[1]=a,e[2]=n,e[3]=i):i=e[3];let c;e[4]===l?c=e[5]:(c=T("ml-2",l),e[4]=l,e[5]=c);let u;e[6]!==n||e[7]!==r?(u=r?n.slice(0,r).join(", "):n.join(", "),e[6]=n,e[7]=r,e[8]=u):u=e[8];let d;return e[9]!==i||e[10]!==c||e[11]!==u?(d=(0,s.jsxs)(ce,{variant:"outline",size:"xs",onClick:i,className:c,children:["Install"," ",u]}),e[9]=i,e[10]=c,e[11]=u,e[12]=d):d=e[12],d};var Hx=L();const Bx=t=>{let e=(0,Hx.c)(16),{packages:n,featureName:r,description:l,onInstall:a,className:o}=t;if(!Wb()){let m;e[0]===o?m=e[1]:(m=T("text-xs",o),e[0]=o,e[1]=m);let g;return e[2]!==r||e[3]!==m?(g=(0,s.jsxs)("span",{className:m,children:[r," isn't available in this notebook"]}),e[2]=r,e[3]=m,e[4]=g):g=e[4],g}let i;e[5]===o?i=e[6]:(i=T("text-xs flex flex-col items-end gap-2",o),e[5]=o,e[6]=i);let c=l||`${r} requires ${n.join(", ")}`,u;e[7]===c?u=e[8]:(u=(0,s.jsx)("span",{className:"self-start",children:c}),e[7]=c,e[8]=u);let d;e[9]!==a||e[10]!==n?(d=(0,s.jsx)(Ro,{packages:n,onInstall:a,className:"ml-0"}),e[9]=a,e[10]=n,e[11]=d):d=e[11];let p;return e[12]!==i||e[13]!==u||e[14]!==d?(p=(0,s.jsxs)("div",{className:i,children:[u,d]}),e[12]=i,e[13]=u,e[14]=d,e[15]=p):p=e[15],p};var Wx=L(),Ot={CSV:{label:"CSV",format:"csv",description:"Comma-separated values",icon:pd},JSON:{label:"JSON",format:"json",description:"Raw JSON data",icon:qb},PARQUET:{label:"Parquet",format:"parquet",description:"Columnar binary format",icon:Ri},TSV:{label:"TSV",format:"tsv",description:"Best for Excel and Google Sheets",icon:pd},MARKDOWN:{label:"Markdown",format:"markdown",description:"Preserves hyperlinks and formatting",icon:Jb}},Au=[Ot.CSV,Ot.JSON,Ot.PARQUET],Gx=[Ot.TSV,Ot.JSON,Ot.CSV,Ot.MARKDOWN],qx=t=>{var e;return((e=Au.find(n=>n.format===t))==null?void 0:e.label)??t};const Kx=t=>{let e=(0,Wx.c)(48),{locale:n}=Ke(),[r,l]=x.useState(!1),a=r?"text-primary":"text-muted-foreground",o;e[0]===a?o=e[1]:(o=T("print:hidden text-xs gap-1",a),e[0]=a,e[1]=o);let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=(0,s.jsx)(Go,{className:"w-3.5 h-3.5"}),e[2]=i):i=e[2];let c;e[3]===o?c=e[4]:(c=(0,s.jsxs)(ce,{"data-testid":"export-button",size:"xs",variant:"text",className:o,children:[i,"Export"]}),e[3]=o,e[4]=c);let u=c,d;e[5]===t?d=e[6]:(d=async(R,A)=>{let I;try{I=await t.downloadAs({format:R})}catch(V){let E=V;return Vn({title:"Failed to download",description:typeof E=="object"&&E&&"message"in E?String(E.message):String(E)}),null}return I.missing_packages&&I.missing_packages.length>0?(Vn({title:"Export failed",description:(0,s.jsx)(Bx,{packages:I.missing_packages,featureName:`${qx(R)} export`,description:I.error,onInstall:A})}),null):{url:I.url,filename:I.filename}},e[5]=t,e[6]=d);let p=d,m,g,f,b,S,h,w,v,j,k,C,M,N;if(e[7]!==u||e[8]!==n||e[9]!==r||e[10]!==p){let R=async E=>{let D=await p(E,()=>{R(E)});if(!D)return;let G=(D.filename??"").trim(),K=Kv.withoutExtension(G)||"download";Jv(D.url,`${K}.${E}`)},A=async E=>{let D=await p(E==="csv"?"csv":"json",()=>{A(E)});if(!D)return;let G;e:switch(E){case"tsv":G=Db(await Ya(D.url),n);break e;case"json":{let K=await Ya(D.url);G=JSON.stringify(K,null,2);break e}case"csv":G=await Iu(D.url);break e;case"markdown":G=Lb(await Ya(D.url));break e;default:kt(E);return}await on(G),Vn({title:"Copied to clipboard"})};g=Zr,S=!1,h=r,w=l;let I=r?!1:void 0,V;e[24]===u?V=e[25]:(V=(0,s.jsx)(Xr,{asChild:!0,children:u}),e[24]=u,e[25]=V),e[26]!==I||e[27]!==V?(v=(0,s.jsx)(Ce,{content:"Export",open:I,children:V}),e[26]=I,e[27]=V,e[28]=v):v=e[28],m=Yr,j="bottom",k="print:hidden",e[29]===Symbol.for("react.memo_cache_sentinel")?(C=(0,s.jsx)(lo,{className:"text-xs text-muted-foreground",children:"Download"}),e[29]=C):C=e[29],M=Au.map(E=>(0,s.jsxs)(ee,{onSelect:()=>{R(E.format)},children:[(0,s.jsx)(E.icon,{className:"mo-dropdown-icon"}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("span",{children:E.label}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:E.description})]})]},E.label)),e[30]===Symbol.for("react.memo_cache_sentinel")?(N=(0,s.jsx)(an,{}),f=(0,s.jsx)(lo,{className:"text-xs text-muted-foreground",children:"Copy to clipboard"}),e[30]=f,e[31]=N):(f=e[30],N=e[31]),b=Gx.map(E=>(0,s.jsxs)(ee,{onSelect:async()=>{try{await A(E.format)}catch(D){Vn({title:"Failed to copy to clipboard",description:TS(D),variant:"danger"})}},children:[(0,s.jsx)(E.icon,{className:"mo-dropdown-icon"}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("span",{children:E.label}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:E.description})]})]},E.label)),e[7]=u,e[8]=n,e[9]=r,e[10]=p,e[11]=m,e[12]=g,e[13]=f,e[14]=b,e[15]=S,e[16]=h,e[17]=w,e[18]=v,e[19]=j,e[20]=k,e[21]=C,e[22]=M,e[23]=N}else m=e[11],g=e[12],f=e[13],b=e[14],S=e[15],h=e[16],w=e[17],v=e[18],j=e[19],k=e[20],C=e[21],M=e[22],N=e[23];let _;e[32]!==m||e[33]!==f||e[34]!==b||e[35]!==j||e[36]!==k||e[37]!==C||e[38]!==M||e[39]!==N?(_=(0,s.jsxs)(m,{side:j,className:k,children:[C,M,N,f,b]}),e[32]=m,e[33]=f,e[34]=b,e[35]=j,e[36]=k,e[37]=C,e[38]=M,e[39]=N,e[40]=_):_=e[40];let y;return e[41]!==g||e[42]!==S||e[43]!==h||e[44]!==w||e[45]!==v||e[46]!==_?(y=(0,s.jsxs)(g,{modal:S,open:h,onOpenChange:w,children:[v,_]}),e[41]=g,e[42]=S,e[43]=h,e[44]=w,e[45]=v,e[46]=_,e[47]=y):y=e[47],y};function Ya(t){return Iu(t).then(ed)}function Iu(t){return fetch(t).then(e=>{if(!e.ok)throw Error(e.statusText);return e.text()})}var Ux=()=>{};let Eu;Eu=({enableSearch:t,searchQuery:e,onSearchQueryChange:n,reloading:r,showChartBuilder:l,isChartBuilderOpen:a,toggleDisplayHeader:o,showTableExplorer:i,togglePanel:c,isAnyPanelOpen:u,downloadAs:d})=>{let[p,m]=(0,x.useState)(e||""),g=B1(p,500),f=it(n??Ux),b=x.useRef(null);return(0,x.useEffect)(()=>{f(g)},[g,f]),t&&n||l||i||d?(0,s.jsxs)("div",{className:"flex items-center h-10 px-2 border-b gap-2",children:[n&&t&&(0,s.jsxs)("div",{className:"flex flex-1 items-center gap-1 px-2 rounded-sm focus-within:ring-1 focus-within:ring-border transition-shadow",children:[(0,s.jsx)(yd,{className:"w-4 h-4 text-muted-foreground shrink-0"}),(0,s.jsx)("input",{ref:b,type:"text",className:"h-6 border-none bg-transparent focus:outline-hidden text-sm w-full min-w-0",value:p,onKeyDown:S=>{var h;S.key==="Escape"&&(m(""),(h=b.current)==null||h.blur())},onChange:S=>m(S.target.value),placeholder:"Search..."}),r&&(0,s.jsx)(gd,{size:"small"}),p&&(0,s.jsx)(ce,{variant:"text",size:"xs",className:"h-5 w-5 p-0 shrink-0",onClick:()=>m(""),children:(0,s.jsx)(tl,{className:"w-3 h-3 text-muted-foreground"})})]}),(0,s.jsxs)("div",{className:"flex items-center shrink-0",children:[l&&(0,s.jsxs)(ce,{variant:"text",size:"xs",className:T("print:hidden text-xs gap-1",a?"text-primary":"text-muted-foreground"),onClick:o,children:[(0,s.jsx)(Ni,{className:"w-3.5 h-3.5"}),"Visualize"]}),i&&c&&(0,s.jsxs)(ce,{variant:"text",size:"xs",className:T("print:hidden text-xs gap-1",u?"text-primary":"text-muted-foreground"),onClick:()=>c(ul.ROW_VIEWER),children:[(0,s.jsx)(Pi,{className:"w-3.5 h-3.5"}),"Explore"]}),d&&(0,s.jsx)(Kx,{downloadAs:d})]})]}):null},Ho=(0,x.memo)(({wrapperClassName:t,className:e,maxHeight:n,columns:r,data:l,rawData:a,selection:o,totalColumns:i,totalRows:c,manualSorting:u=!1,sorting:d,setSorting:p,rowSelection:m,cellSelection:g,cellStyling:f,hoverTemplate:b,cellHoverTexts:S,paginationState:h,setPaginationState:w,downloadAs:v,manualPagination:j=!1,pagination:k=!1,onRowSelectionChange:C,onCellSelectionChange:M,getRowIds:N,enableSearch:_=!1,searchQuery:y,onSearchQueryChange:R,showFilters:A=!1,filters:I,onFiltersChange:V,reloading:E,freezeColumnsLeft:D,freezeColumnsRight:G,toggleDisplayHeader:K,showChartBuilder:se,isChartBuilderOpen:q,showPageSizeSelector:Y,showTableExplorer:we,togglePanel:de,isPanelOpen:je,isAnyPanelOpen:Ae,viewedRowIdx:ze,onViewedRowChange:Be})=>{let[Ie,ot]=x.useState(!1),{locale:gt}=Ke(),{columnPinning:Ee,setColumnPinning:We}=Ey(D,G);x.useEffect(()=>{let pe;return E?pe=setTimeout(()=>{ot(!0)},300):ot(!1),()=>{pe&&clearTimeout(pe)}},[E]);function U(pe,Re){return h?Re+(j?h.pageIndex*h.pageSize:0):Re}let te=Lo({_features:[zc,sy,f1,ky,Ry,jy,wy,Ny,Ay],data:l,columns:r,meta:{rawData:a},getCoreRowModel:go(),rowCount:c==="too_many"?void 0:c,...w?{onPaginationChange:w,getRowId:(pe,Re)=>{let P=Nr(pe);if(P)return P;let Ve=U(pe,Re);return String(Ve)}}:{},locale:gt,manualPagination:j,getPaginationRowModel:u1(),...p?{onSortingChange:p}:{},manualSorting:u,enableMultiSort:!0,getSortedRowModel:wo(),manualFiltering:!0,enableColumnFilters:A,getFilteredRowModel:Co(),onColumnFiltersChange:V,onRowSelectionChange:C,onCellSelectionChange:M,enableCellSelection:o==="single-cell"||o==="multi-cell",enableMultiCellSelection:o==="multi-cell",onColumnPinningChange:We,enableFocusRow:!0,onFocusRowChange:Be,state:{...d?{sorting:d}:{},columnFilters:I,...h?{pagination:h}:k&&!h?{}:{pagination:{pageIndex:0,pageSize:l.length}},rowSelection:m??{},cellSelection:g??[],cellStyling:f,columnPinning:Ee,cellHoverTemplate:b,cellHoverTexts:S??{}}}),_e=(je==null?void 0:je(ul.ROW_VIEWER))??!1,Z=!k&&l.length>100,me=Oy({maxHeight:n,virtualize:Z});return(0,s.jsxs)("div",{className:T(t,"flex flex-col space-y-1"),children:[(0,s.jsx)(My,{filters:I,table:te}),(0,s.jsx)(Zy,{children:(0,s.jsxs)("div",{part:"table-wrapper",className:T(e||"rounded-md border overflow-hidden"),children:[(0,s.jsx)(Eu,{enableSearch:_,searchQuery:y,onSearchQueryChange:R,reloading:E,showChartBuilder:se,isChartBuilderOpen:q,toggleDisplayHeader:K,showTableExplorer:we,togglePanel:de,isAnyPanelOpen:Ae,downloadAs:v}),(0,s.jsxs)(iw,{className:T("relative",r.length<=4?"w-auto":"w-full"),ref:me,children:[Ie&&(0,s.jsx)("thead",{className:"absolute top-0 left-0 h-[3px] w-1/2 bg-primary animate-slide"}),_x(te,Z||!!n),(0,s.jsx)(Rx,{table:te,columns:r,rowViewerPanelOpen:_e,getRowIndex:U,viewedRowIdx:ze,virtualize:Z})]}),(0,s.jsx)(Dx,{part:"table-footer",className:"pt-1.5 pb-0.5 border-t border-border",totalColumns:i,pagination:k,selection:o,onRowSelectionChange:C,table:te,getRowIds:N,showPageSizeSelector:Y,tableLoading:E})]})})]})});var Qt=L(),Jx=25;Do=function(t){return t?t.startsWith("image/")||t.startsWith("audio/")||t.startsWith("video/")||t.startsWith("application/pdf"):!1},cl={"application/javascript":"javascript","text/markdown":"markdown","text/html":"html","text/css":"css","text/x-python":"python","application/json":"json","application/xml":"xml","text/x-yaml":"yaml","text/csv":"markdown","text/plain":"markdown",default:"markdown"};function Tr(t){return t.url==null?fS(t.base64,t.mime):t.url}let Qa,Pu,Ou,$u,Tu,zu;Qa=({contents:t})=>{let e=(0,x.useMemo)(()=>io(t),[t]),[n,r]=(0,x.useState)({pageIndex:0,pageSize:Jx}),l=(0,x.useMemo)(()=>uo(e),[e]),a=(0,x.useMemo)(()=>Oo({rowHeaders:Yv.EMPTY,selection:null,fieldTypes:l}),[l]);return(0,s.jsx)(Ho,{data:e,totalRows:e.length,columns:a,totalColumns:a.length,manualPagination:!1,paginationState:n,setPaginationState:r,wrapperClassName:"h-full justify-between pb-1 px-1",pagination:!0,className:"rounded-none border-b flex overflow-hidden",rowSelection:to.EMPTY})},Pu=t=>{let e=(0,Qt.c)(4),n;e[0]===t?n=e[1]:(n=Tr(t),e[0]=t,e[1]=n);let r;return e[2]===n?r=e[3]:(r=(0,s.jsx)("img",{src:n,alt:"Preview"}),e[2]=n,e[3]=r),r},Ou=t=>{let e=(0,Qt.c)(4),n;e[0]===t?n=e[1]:(n=Tr(t),e[0]=t,e[1]=n);let r;return e[2]===n?r=e[3]:(r=(0,s.jsx)("audio",{controls:!0,src:n}),e[2]=n,e[3]=r),r},$u=t=>{let e=(0,Qt.c)(4),n;e[0]===t?n=e[1]:(n=Tr(t),e[0]=t,e[1]=n);let r;return e[2]===n?r=e[3]:(r=(0,s.jsx)("video",{controls:!0,src:n}),e[2]=n,e[3]=r),r},Tu=t=>{let e=(0,Qt.c)(4),n;e[0]===t?n=e[1]:(n=Tr(t),e[0]=t,e[1]=n);let r;return e[2]===n?r=e[3]:(r=(0,s.jsx)("iframe",{src:n,title:"PDF Viewer",className:"w-full h-full"}),e[2]=n,e[3]=r),r},zu=t=>{let e=(0,Qt.c)(11),n,r;if(e[0]===t?(n=e[1],r=e[2]):({mimeType:n,...r}=t,e[0]=t,e[1]=n,e[2]=r),n.startsWith("image/")){let l;return e[3]===r?l=e[4]:(l=(0,s.jsx)(Pu,{...r}),e[3]=r,e[4]=l),l}if(n.startsWith("audio/")){let l;return e[5]===r?l=e[6]:(l=(0,s.jsx)(Ou,{...r}),e[5]=r,e[6]=l),l}if(n.startsWith("video/")){let l;return e[7]===r?l=e[8]:(l=(0,s.jsx)($u,{...r}),e[7]=r,e[8]=l),l}if(n.startsWith("application/pdf")){let l;return e[9]===r?l=e[10]:(l=(0,s.jsx)(Tu,{...r}),e[9]=r,e[10]=l),l}return null},Td=t=>{let e=(0,Qt.c)(17),{mimeType:n,contents:r,mediaSource:l,readOnly:a,onChange:o,extensions:i}=t,c=a===void 0?!0:a,u;e[0]===i?u=e[1]:(u=i===void 0?[]:i,e[0]=i,e[1]=u);let d=u,{theme:p}=ll();if(n==="text/csv"&&r!=null){let m;return e[2]===r?m=e[3]:(m=(0,s.jsx)("div",{className:"flex-1 overflow-hidden flex flex-col",children:(0,s.jsx)(Qa,{contents:r})}),e[2]=r,e[3]=m),m}if(Do(n)&&l){let m;return e[4]!==l||e[5]!==n?(m=(0,s.jsx)("div",{className:"flex-1 overflow-hidden flex flex-col",children:(0,s.jsx)(zu,{...l,mimeType:n})}),e[4]=l,e[5]=n,e[6]=m):m=e[6],m}if(r!=null){let m=cl[n]||cl.default,g=p==="dark"?"dark":"light",f;e[7]===d?f=e[8]:(f=[dd.lineWrapping,...d],e[7]=d,e[8]=f);let b=c?!1:void 0,S=c?void 0:o,h;return e[9]!==r||e[10]!==m||e[11]!==c||e[12]!==g||e[13]!==f||e[14]!==b||e[15]!==S?(h=(0,s.jsx)("div",{className:"flex-1 overflow-auto",children:(0,s.jsx)(x.Suspense,{children:(0,s.jsx)(lS,{theme:g,language:m,className:"border-b",extensions:f,value:r,readOnly:c,editable:b,onChange:S})})}),e[9]=r,e[10]=m,e[11]=c,e[12]=g,e[13]=f,e[14]=b,e[15]=S,e[16]=h):h=e[16],h}return null};function Xx(t,e){let{state:n}=t,r=n.doc;if(e<=0||e>r.lines)return st.warn(`Invalid line number: ${e}. Document has ${r.lines} lines.`),!1;let l=r.line(e);if(l.text.includes("breakpoint()"))return!0;let a=l.text.match(/^(\s*)/),o=`${a?a[1]:""}breakpoint()
|
|
45
|
+
color: hsl(${Math.max(0,Math.min(120-120*b,120))}deg 100% 31%);`,n==null?void 0:n.key)}return n!=null&&n.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(l),a=!1,l}return o.updateDeps=i=>{r=i},o}function yu(t,e){if(t===void 0)throw Error(`Unexpected undefined${e?`: ${e}`:""}`);return t}var ex=(t,e)=>Math.abs(t-e)<1.01,tx=(t,e,n)=>{let r;return function(...l){t.clearTimeout(r),r=t.setTimeout(()=>e.apply(this,l),n)}},xu=t=>{let{offsetWidth:e,offsetHeight:n}=t;return{width:e,height:n}},nx=t=>t,rx=t=>{let e=Math.max(t.startIndex-t.overscan,0),n=Math.min(t.endIndex+t.overscan,t.count-1),r=[];for(let l=e;l<=n;l++)r.push(l);return r},lx=(t,e)=>{let n=t.scrollElement;if(!n)return;let r=t.targetWindow;if(!r)return;let l=o=>{let{width:i,height:c}=o;e({width:Math.round(i),height:Math.round(c)})};if(l(xu(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(o=>{let i=()=>{let c=o[0];if(c!=null&&c.borderBoxSize){let u=c.borderBoxSize[0];if(u){l({width:u.inlineSize,height:u.blockSize});return}}l(xu(n))};t.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(i):i()});return a.observe(n,{box:"border-box"}),()=>{a.unobserve(n)}},bu={passive:!0},vu=typeof window>"u"?!0:"onscrollend"in window,ax=(t,e)=>{let n=t.scrollElement;if(!n)return;let r=t.targetWindow;if(!r)return;let l=0,a=t.options.useScrollendEvent&&vu?()=>{}:tx(r,()=>{e(l,!1)},t.options.isScrollingResetDelay),o=d=>()=>{let{horizontal:p,isRtl:m}=t.options;l=p?n.scrollLeft*(m&&-1||1):n.scrollTop,a(),e(l,d)},i=o(!0),c=o(!1);n.addEventListener("scroll",i,bu);let u=t.options.useScrollendEvent&&vu;return u&&n.addEventListener("scrollend",c,bu),()=>{n.removeEventListener("scroll",i),u&&n.removeEventListener("scrollend",c)}},ox=(t,e,n)=>{if(e!=null&&e.borderBoxSize){let r=e.borderBoxSize[0];if(r)return Math.round(r[n.options.horizontal?"inlineSize":"blockSize"])}return t[n.options.horizontal?"offsetWidth":"offsetHeight"]},ix=(t,{adjustments:e=0,behavior:n},r)=>{var i;var l,a;let o=t+e;(a=(i=l=r.scrollElement)==null?void 0:i.scrollTo)==null||a.call(l,{[r.options.horizontal?"left":"top"]:o,behavior:n})},sx=class{constructor(t){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.now=()=>{var n,r,l;var e;return((l=(r=e=(n=this.targetWindow)==null?void 0:n.performance)==null?void 0:r.now)==null?void 0:l.call(e))??Date.now()},this.observer=(()=>{let e=null,n=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(r=>{r.forEach(l=>{let a=()=>{let o=l.target,i=this.indexFromElement(o);if(!o.isConnected){this.observer.unobserve(o);return}this.shouldMeasureDuringScroll(i)&&this.resizeItem(i,this.options.measureElement(o,l,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()})}));return{disconnect:()=>{var r;(r=n())==null||r.disconnect(),e=null},observe:r=>{var l;return(l=n())==null?void 0:l.observe(r,{box:"border-box"})},unobserve:r=>{var l;return(l=n())==null?void 0:l.unobserve(r)}}})(),this.range=null,this.setOptions=e=>{Object.entries(e).forEach(([n,r])=>{r===void 0&&delete e[n]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:nx,rangeExtractor:rx,onChange:()=>{},measureElement:ox,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...e}},this.notify=e=>{var n,r;(r=(n=this.options).onChange)==null||r.call(n,this,e)},this.maybeNotify=Yt(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var n;let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}this.scrollElement=e,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((n=this.scrollElement)==null?void 0:n.window)??null,this.elementsCache.forEach(r=>{this.observer.observe(r)}),this.unsubs.push(this.options.observeElementRect(this,r=>{this.scrollRect=r,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(r,l)=>{this.scrollAdjustments=0,this.scrollDirection=l?this.getScrollOffset()<r?"forward":"backward":null,this.scrollOffset=r,this.isScrolling=l,this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,n)=>{let r=new Map,l=new Map;for(let a=n-1;a>=0;a--){let o=e[a];if(r.has(o.lane))continue;let i=l.get(o.lane);if(i==null||o.end>i.end?l.set(o.lane,o):o.end<i.end&&r.set(o.lane,!0),r.size===this.options.lanes)break}return l.size===this.options.lanes?Array.from(l.values()).sort((a,o)=>a.end===o.end?a.index-o.index:a.end-o.end)[0]:void 0},this.getMeasurementOptions=Yt(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(e,n,r,l,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==o&&(this.lanesChangedFlag=!0),this.prevLanes=o,this.pendingMeasuredCacheIndexes=[],{count:e,paddingStart:n,scrollMargin:r,getItemKey:l,enabled:a,lanes:o}),{key:!1}),this.getMeasurements=Yt(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:e,paddingStart:n,scrollMargin:r,getItemKey:l,enabled:a,lanes:o},i)=>{if(!a)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let p of this.laneAssignments.keys())p>=e&&this.laneAssignments.delete(p);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(p=>{this.itemSizeCache.set(p.key,p.size)}));let c=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1);let u=this.measurementsCache.slice(0,c),d=Array(o).fill(void 0);for(let p=0;p<c;p++){let m=u[p];m&&(d[m.lane]=p)}for(let p=c;p<e;p++){let m=l(p),g=this.laneAssignments.get(p),f,b;if(g!==void 0&&this.options.lanes>1){f=g;let v=d[f],j=v===void 0?void 0:u[v];b=j?j.end+this.options.gap:n+r}else{let v=this.options.lanes===1?u[p-1]:this.getFurthestMeasurement(u,p);b=v?v.end+this.options.gap:n+r,f=v?v.lane:p%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(p,f)}let S=i.get(m),h=typeof S=="number"?S:this.options.estimateSize(p),w=b+h;u[p]={index:p,start:b,size:h,end:w,key:m,lane:f},d[f]=p}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Yt(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,n,r,l)=>this.range=e.length>0&&n>0?cx({measurements:e,outerSize:n,scrollOffset:r,lanes:l}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Yt(()=>{let e=null,n=null,r=this.calculateRange();return r&&(e=r.startIndex,n=r.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,n]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,n]},(e,n,r,l,a)=>l===null||a===null?[]:e({startIndex:l,endIndex:a,overscan:n,count:r}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let n=this.options.indexAttribute,r=e.getAttribute(n);return r?parseInt(r,10):(console.warn(`Missing attribute name '${n}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{var r;if(!this.scrollState||this.scrollState.behavior!=="smooth")return!0;let n=this.scrollState.index??((r=this.getVirtualItemForOffset(this.scrollState.lastTargetOffset))==null?void 0:r.index);if(n!==void 0&&this.range){let l=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),a=Math.max(0,n-l),o=Math.min(this.options.count-1,n+l);return e>=a&&e<=o}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((a,o)=>{a.isConnected||(this.observer.unobserve(a),this.elementsCache.delete(o))});return}let n=this.indexFromElement(e),r=this.options.getItemKey(n),l=this.elementsCache.get(r);l!==e&&(l&&this.observer.unobserve(l),this.observer.observe(e),this.elementsCache.set(r,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,n)=>{var a;let r=this.measurementsCache[e];if(!r)return;let l=n-(this.itemSizeCache.get(r.key)??r.size);l!==0&&(((a=this.scrollState)==null?void 0:a.behavior)!=="smooth"&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r.start<this.getScrollOffset()+this.scrollAdjustments:this.shouldAdjustScrollPositionOnItemSizeChange(r,l,this))&&this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=l,behavior:void 0}),this.pendingMeasuredCacheIndexes.push(r.index),this.itemSizeCache=new Map(this.itemSizeCache.set(r.key,n)),this.notify(!1))},this.getVirtualItems=Yt(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,n)=>{let r=[];for(let l=0,a=e.length;l<a;l++){let o=n[e[l]];r.push(o)}return r},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let n=this.getMeasurements();if(n.length!==0)return yu(n[Su(0,n.length-1,r=>yu(n[r]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,n,r=0)=>{if(!this.scrollElement)return 0;let l=this.getSize(),a=this.getScrollOffset();n==="auto"&&(n=e>=a+l?"end":"start"),n==="center"?e+=(r-l)/2:n==="end"&&(e-=l);let o=this.getMaxScrollOffset();return Math.max(Math.min(o,e),0)},this.getOffsetForIndex=(e,n="auto")=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getSize(),l=this.getScrollOffset(),a=this.measurementsCache[e];if(!a)return;if(n==="auto")if(a.end>=l+r-this.options.scrollPaddingEnd)n="end";else if(a.start<=l+this.options.scrollPaddingStart)n="start";else return[l,n];if(n==="end"&&e===this.options.count-1)return[this.getMaxScrollOffset(),n];let o=n==="end"?a.end+this.options.scrollPaddingEnd:a.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(o,n,a.size),n]},this.scrollToOffset=(e,{align:n="start",behavior:r="auto"}={})=>{let l=this.getOffsetForAlignment(e,n);this.scrollState={index:null,align:n,behavior:r,startedAt:this.now(),lastTargetOffset:l,stableFrames:0},this._scrollToOffset(l,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:n="auto",behavior:r="auto"}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let l=this.getOffsetForIndex(e,n);if(!l)return;let[a,o]=l,i=this.now();this.scrollState={index:e,align:o,behavior:r,startedAt:i,lastTargetOffset:a,stableFrames:0},this._scrollToOffset(a,{adjustments:void 0,behavior:r}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:n="auto"}={})=>{let r=this.getScrollOffset()+e;this.scrollState={index:null,align:"start",behavior:n,startedAt:this.now(),lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{var r;let e=this.getMeasurements(),n;if(e.length===0)n=this.options.paddingStart;else if(this.options.lanes===1)n=((r=e[e.length-1])==null?void 0:r.end)??0;else{let l=Array(this.options.lanes).fill(null),a=e.length-1;for(;a>=0&&l.some(o=>o===null);){let o=e[a];l[o.lane]===null&&(l[o.lane]=o.end),a--}n=Math.max(...l.filter(o=>o!==null))}return Math.max(n-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(e,{adjustments:n,behavior:r})=>{this.options.scrollToFn(e,{behavior:r,adjustments:n},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(t)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??(this.rafId=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()}))}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let t=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),e=t?t[0]:this.scrollState.lastTargetOffset,n=e!==this.scrollState.lastTargetOffset;if(!n&&ex(e,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.scrollState=null;return}}else this.scrollState.stableFrames=0,n&&(this.scrollState.lastTargetOffset=e,this.scrollState.behavior="auto",this._scrollToOffset(e,{adjustments:void 0,behavior:"auto"}));this.scheduleScrollReconcile()}},Su=(t,e,n,r)=>{for(;t<=e;){let l=(t+e)/2|0,a=n(l);if(a<r)t=l+1;else if(a>r)e=l-1;else return l}return t>0?t-1:0};function cx({measurements:t,outerSize:e,scrollOffset:n,lanes:r}){let l=t.length-1,a=c=>t[c].start;if(t.length<=r)return{startIndex:0,endIndex:l};let o=Su(0,l,a,n),i=o;if(r===1)for(;i<l&&t[i].end<n+e;)i++;else if(r>1){let c=Array(r).fill(0);for(;i<l&&c.some(d=>d<n+e);){let d=t[i];c[d.lane]=d.end,i++}let u=Array(r).fill(n+e);for(;o>=0&&u.some(d=>d>=n);){let d=t[o];u[d.lane]=d.start,o--}o=Math.max(0,o-o%r),i=Math.min(l,i+(r-1-i%r))}return{startIndex:o,endIndex:i}}var ux=tv(),wu=typeof document<"u"?x.useLayoutEffect:x.useEffect;function dx({useFlushSync:t=!0,...e}){let n=x.useReducer(()=>({}),{})[1],r={...e,onChange:(a,o)=>{var i;t&&o?(0,ux.flushSync)(n):n(),(i=e.onChange)==null||i.call(e,a,o)}},[l]=x.useState(()=>new sx(r));return l.setOptions(r),wu(()=>l._didMount(),[]),wu(()=>l._willUpdate()),l}function Cu(t){return dx({observeElementRect:lx,observeElementOffset:ax,scrollToFn:ix,...t})}let ft,Ka,ju,ku,_u;ft=L(),No=im,Ao=sm,Ka=uv(cm),ju=ad(mi),ku=ad(vi),_u=x.forwardRef((t,e)=>{let n=(0,ft.c)(14),r,l,a,o;n[0]===t?(r=n[1],l=n[2],a=n[3],o=n[4]):({className:l,inset:a,children:r,...o}=t,n[0]=t,n[1]=r,n[2]=l,n[3]=a,n[4]=o);let i;n[5]!==l||n[6]!==a?(i=fv({className:l,inset:a}),n[5]=l,n[6]=a,n[7]=i):i=n[7];let c;n[8]===Symbol.for("react.memo_cache_sentinel")?(c=(0,s.jsx)(qS,{className:"ml-auto h-4 w-4"}),n[8]=c):c=n[8];let u;return n[9]!==r||n[10]!==o||n[11]!==e||n[12]!==i?(u=(0,s.jsxs)(bi,{ref:e,className:i,...o,children:[r,c]}),n[9]=r,n[10]=o,n[11]=e,n[12]=i,n[13]=u):u=n[13],u}),_u.displayName=bi.displayName;var Ru="data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",mx=x.forwardRef((t,e)=>{let n=(0,ft.c)(9),r,l;n[0]===t?(r=n[1],l=n[2]):({className:r,...l}=t,n[0]=t,n[1]=r,n[2]=l);let a;n[3]===r?a=n[4]:(a=T(id({subcontent:!0}),Ru,r),n[3]=r,n[4]=a);let o;return n[5]!==l||n[6]!==e||n[7]!==a?(o=(0,s.jsx)(ku,{ref:e,className:a,...l}),n[5]=l,n[6]=e,n[7]=a,n[8]=o):o=n[8],o});mx.displayName=vi.displayName,pl=x.forwardRef((t,e)=>{let n=(0,ft.c)(15),r,l,a;n[0]===t?(r=n[1],l=n[2],a=n[3]):({className:r,scrollable:a,...l}=t,n[0]=t,n[1]=r,n[2]=l,n[3]=a);let o=a===void 0?!0:a,i;n[4]!==r||n[5]!==o?(i=T(id(),Ru,o&&"overflow-auto",r),n[4]=r,n[5]=o,n[6]=i):i=n[6];let c=o?`calc(var(--radix-context-menu-content-available-height) - ${dv}px)`:void 0,u;n[7]!==l.style||n[8]!==c?(u={...l.style,maxHeight:c},n[7]=l.style,n[8]=c,n[9]=u):u=n[9];let d;return n[10]!==l||n[11]!==e||n[12]!==i||n[13]!==u?(d=(0,s.jsx)(Ka,{children:(0,s.jsx)(sv,{children:(0,s.jsx)(ju,{ref:e,className:i,style:u,...l})})}),n[10]=l,n[11]=e,n[12]=i,n[13]=u,n[14]=d):d=n[14],d}),pl.displayName=mi.displayName,zt=x.forwardRef((t,e)=>{let n=(0,ft.c)(13),r,l,a,o;n[0]===t?(r=n[1],l=n[2],a=n[3],o=n[4]):({className:r,inset:l,variant:o,...a}=t,n[0]=t,n[1]=r,n[2]=l,n[3]=a,n[4]=o);let i;n[5]!==r||n[6]!==l||n[7]!==o?(i=gv({className:r,inset:l,variant:o}),n[5]=r,n[6]=l,n[7]=o,n[8]=i):i=n[8];let c;return n[9]!==a||n[10]!==e||n[11]!==i?(c=(0,s.jsx)(fi,{ref:e,className:i,...a}),n[9]=a,n[10]=e,n[11]=i,n[12]=c):c=n[12],c}),zt.displayName=fi.displayName,Fo=x.forwardRef((t,e)=>{let n=(0,ft.c)(15),r,l,a,o;n[0]===t?(r=n[1],l=n[2],a=n[3],o=n[4]):({className:a,children:l,checked:r,...o}=t,n[0]=t,n[1]=r,n[2]=l,n[3]=a,n[4]=o);let i;n[5]===a?i=n[6]:(i=mv({className:a}),n[5]=a,n[6]=i);let c;n[7]===Symbol.for("react.memo_cache_sentinel")?(c=no(),n[7]=c):c=n[7];let u;n[8]===Symbol.for("react.memo_cache_sentinel")?(u=(0,s.jsx)("span",{className:c,children:(0,s.jsx)(yi,{children:(0,s.jsx)(WS,{className:"h-4 w-4"})})}),n[8]=u):u=n[8];let d;return n[9]!==r||n[10]!==l||n[11]!==o||n[12]!==e||n[13]!==i?(d=(0,s.jsxs)(gi,{ref:e,className:i,checked:r,...o,children:[u,l]}),n[9]=r,n[10]=l,n[11]=o,n[12]=e,n[13]=i,n[14]=d):d=n[14],d}),Fo.displayName=gi.displayName;var px=x.forwardRef((t,e)=>{let n=(0,ft.c)(13),r,l,a;n[0]===t?(r=n[1],l=n[2],a=n[3]):({className:l,children:r,...a}=t,n[0]=t,n[1]=r,n[2]=l,n[3]=a);let o;n[4]===l?o=n[5]:(o=no({className:l}),n[4]=l,n[5]=o);let i;n[6]===Symbol.for("react.memo_cache_sentinel")?(i=no(),n[6]=i):i=n[6];let c;n[7]===Symbol.for("react.memo_cache_sentinel")?(c=(0,s.jsx)("span",{className:i,children:(0,s.jsx)(yi,{children:(0,s.jsx)(BS,{className:"h-4 w-4 fill-current"})})}),n[7]=c):c=n[7];let u;return n[8]!==r||n[9]!==a||n[10]!==e||n[11]!==o?(u=(0,s.jsxs)(hi,{ref:e,className:o,...a,children:[c,r]}),n[8]=r,n[9]=a,n[10]=e,n[11]=o,n[12]=u):u=n[12],u});px.displayName=hi.displayName;var fx=x.forwardRef((t,e)=>{let n=(0,ft.c)(11),r,l,a;n[0]===t?(r=n[1],l=n[2],a=n[3]):({className:r,inset:l,...a}=t,n[0]=t,n[1]=r,n[2]=l,n[3]=a);let o;n[4]!==r||n[5]!==l?(o=hv({className:r,inset:l}),n[4]=r,n[5]=l,n[6]=o):o=n[6];let i;return n[7]!==a||n[8]!==e||n[9]!==o?(i=(0,s.jsx)(pi,{ref:e,className:o,...a}),n[7]=a,n[8]=e,n[9]=o,n[10]=i):i=n[10],i});fx.displayName=pi.displayName,ml=x.forwardRef((t,e)=>{let n=(0,ft.c)(9),r,l;n[0]===t?(r=n[1],l=n[2]):({className:r,...l}=t,n[0]=t,n[1]=r,n[2]=l);let a;n[3]===r?a=n[4]:(a=T(pv({className:r})),n[3]=r,n[4]=a);let o;return n[5]!==l||n[6]!==e||n[7]!==a?(o=(0,s.jsx)(xi,{ref:e,className:a,...l}),n[5]=l,n[6]=e,n[7]=a,n[8]=o):o=n[8],o}),ml.displayName=xi.displayName;var gx=L();const hx=t=>{let e=(0,gx.c)(12),{contextMenuRef:n,tableBody:r,tableRef:l,copyAllCells:a}=t,o;e[0]!==n||e[1]!==l?(o=p=>{var f;let m=n.current;if(!m)return;let g=(f=l.current)==null?void 0:f.querySelector(`[${Ub}="${m.id}"]`);if(!g){st.error("Context menu cell not found in table");return}p?g.classList.add("bg-(--green-4)"):g.classList.remove("bg-(--green-4)")},e[0]=n,e[1]=l,e[2]=o):o=e[2];let i=it(o),c;e[3]===r?c=e[4]:(c=(0,s.jsx)(Ao,{asChild:!0,children:r}),e[3]=r,e[4]=c);let u;e[5]!==n||e[6]!==a?(u=(0,s.jsx)(Ka,{children:(0,s.jsx)(yx,{cellRef:n,copySelectedCells:a})}),e[5]=n,e[6]=a,e[7]=u):u=e[7];let d;return e[8]!==i||e[9]!==c||e[10]!==u?(d=(0,s.jsxs)(No,{onOpenChange:i,children:[c,u]}),e[8]=i,e[9]=c,e[10]=u,e[11]=d):d=e[11],d},yx=({cellRef:t,copySelectedCells:e})=>{var p;let n=$n(qa).size>1,r=t.current;if(!r){st.error("No cell found in context menu");return}let l=r.getContext().table,a=r.getValue(),o=za(l,r.row.index,r.column.id)??a,i=()=>{try{let{text:m,html:g}=qc(o,a);on(m,g)}catch(m){st.error("Failed to copy context menu cell",m)}},c=r.column,u=c.getCanFilter()&&((p=c.columnDef.meta)==null?void 0:p.filterType),d=m=>{c.setFilterValue(tt.select({options:[o],operator:m}))};return(0,s.jsxs)(pl,{children:[(0,s.jsxs)(zt,{onClick:i,children:[(0,s.jsx)(rl,{className:"mo-dropdown-icon h-3 w-3"}),"Copy cell"]}),n&&(0,s.jsxs)(zt,{onClick:e,children:[(0,s.jsx)($i,{className:"mo-dropdown-icon h-3 w-3"}),"Copy selected cells"]}),u&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ml,{}),(0,s.jsxs)(zt,{onClick:()=>d("in"),children:[(0,s.jsx)(Hn,{className:"mo-dropdown-icon h-3 w-3"}),"Filter by this value"]}),(0,s.jsxs)(zt,{onClick:()=>d("not_in"),children:[(0,s.jsx)(Hn,{className:"mo-dropdown-icon h-3 w-3"}),"Remove rows with this value"]})]})]})};var xx=L();const Nu=(0,x.memo)(t=>{let e=(0,xx.c)(9),{cellId:n,className:r}=t,l;e[0]===n?l=e[1]:(l=Xy(n),e[0]=n,e[1]=l);let{isSelected:a,isCopied:o}=$n(l);if(!a&&!o)return null;let i=a&&"bg-(--green-3)",c=o&&"bg-(--green-4) transition-colors duration-150",u;e[2]!==r||e[3]!==i||e[4]!==c?(u=T("absolute inset-0 pointer-events-none",i,c,r),e[2]=r,e[3]=i,e[4]=c,e[5]=u):u=e[5];let d;return e[6]!==n||e[7]!==u?(d=(0,s.jsx)("div",{"data-cell-id":n,className:u}),e[6]=n,e[7]=u,e[8]=d):d=e[8],d});Nu.displayName="CellRangeSelectionIndicator";var bx=L();const vx=t=>{let e=(0,bx.c)(30),{table:n}=t,r=Uy(),l;e[0]!==r||e[1]!==n?(l=()=>{r.handleCopy({table:n,onCopyComplete:()=>{setTimeout(()=>{r.setCopiedCells(new Set)},500)}})},e[0]=r,e[1]=n,e[2]=l):l=e[2];let a=it(l),o;e[3]!==r||e[4]!==n?(o=(v,j)=>{r.updateSelection({newCell:v,isShiftKey:j,table:n})},e[3]=r,e[4]=n,e[5]=o):o=e[5];let i=it(o),c;e[6]!==r||e[7]!==n?(c=(v,j)=>{r.navigate({direction:j,isShiftKey:v.shiftKey,table:n})},e[6]=r,e[7]=n,e[8]=c):c=e[8];let u=it(c),d;e[9]!==r||e[10]!==a||e[11]!==u||e[12]!==n?(d=v=>{e:switch(v.key){case"c":qe.isMetaOrCtrl(v)&&a();break e;case"ArrowDown":v.preventDefault(),u(v,"down");break e;case"ArrowUp":v.preventDefault(),u(v,"up");break e;case"ArrowLeft":v.preventDefault(),u(v,"left");break e;case"ArrowRight":v.preventDefault(),u(v,"right");break e;case"Enter":v.preventDefault(),r.toggleCurrentRowSelection(n);break e;case"Escape":r.clearSelection();break e;case"a":(v.metaKey||v.ctrlKey)&&(v.preventDefault(),r.selectAllCells(n))}},e[9]=r,e[10]=a,e[11]=u,e[12]=n,e[13]=d):d=e[13];let p=it(d),m;e[14]!==r||e[15]!==n?(m=(v,j)=>{v.buttons!==2&&(wx(v)||r.handleCellMouseDown({cell:j,isShiftKey:v.shiftKey,isCtrlKey:v.ctrlKey,table:n}))},e[14]=r,e[15]=n,e[16]=m):m=e[16];let g=it(m),f;e[17]===r?f=e[18]:(f=()=>{r.setIsSelecting(!1)},e[17]=r,e[18]=f);let b=it(f),S;e[19]!==r||e[20]!==n?(S=(v,j)=>{v.buttons===1&&r.updateRangeSelection({cell:j,table:n})},e[19]=r,e[20]=n,e[21]=S):S=e[21];let h=it(S),w;return e[22]!==r.clearSelection||e[23]!==g||e[24]!==h||e[25]!==b||e[26]!==p||e[27]!==a||e[28]!==i?(w={handleCellMouseDown:g,handleCellMouseUp:b,handleCellMouseOver:h,handleCopy:a,handleCellsKeyDown:p,updateSelection:i,clearSelection:r.clearSelection},e[22]=r.clearSelection,e[23]=g,e[24]=h,e[25]=b,e[26]=p,e[27]=a,e[28]=i,e[29]=w):w=e[29],w};var Sx='input, button, select, textarea, a, label, [role="checkbox"], [role="button"], [contenteditable="true"], marimo-ui-element';function wx(t){let e=t.target;return e===t.currentTarget||!(e instanceof Element)?!1:e.closest(Sx)!==null}var Cx=L(),jx=Pe(t=>t(Pt).focusedCell);function kx(t){let e=(0,Cx.c)(2),n;e[0]===t?n=e[1]:(n=r=>{r!=null&&r.cellId&&setTimeout(()=>{var a;let l=(a=t.current)==null?void 0:a.querySelector(`[data-cell-id="${r.cellId}"]`);if(!l){st.warn("[ScrollIntoView] Could not find cell with ID:",r.cellId);return}l.scrollIntoView({behavior:"smooth",block:"nearest",inline:"nearest"})},0)},e[0]=t,e[1]=n),Pb(jx,n)}function _x(t,e){var r;if(!((r=t.getRowModel().rows)!=null&&r.length))return null;let n=l=>l.map(a=>a.headers.map(o=>{let{className:i,style:c}=Mu(o.column);return(0,s.jsx)(aw,{className:T("h-auto min-h-10 whitespace-pre align-top border-r border-r-border/75",i),style:c,ref:u=>{Nx({table:t,column:o.column,thead:u})},children:o.isPlaceholder?null:il(o.column.columnDef.header,o.getContext())},o.id)}));return(0,s.jsx)(lw,{className:T(e&&"sticky top-0 z-10"),children:(0,s.jsxs)(co,{children:[n(t.getLeftHeaderGroups()),n(t.getCenterHeaderGroups()),n(t.getRightHeaderGroups()),t.getAllColumns().length<=4&&(0,s.jsx)("th",{className:"w-full border-0","aria-hidden":"true",role:"presentation"})]})})}const Rx=({table:t,columns:e,rowViewerPanelOpen:n,getRowIndex:r,viewedRowIdx:l,virtualize:a=!1})=>{let o=t.getRowModel().rows,[i,c]=(0,x.useState)(null),u=(0,x.useRef)(null);(0,x.useLayoutEffect)(()=>{var _,y;c(((y=(_=u.current)==null?void 0:_.parentElement)==null?void 0:y.parentElement)??null)},[]);let d=Cu({count:a?o.length:0,getScrollElement:()=>i,estimateSize:()=>24,overscan:10});kx(u);let{handleCellMouseDown:p,handleCellMouseUp:m,handleCellMouseOver:g,handleCellsKeyDown:f,handleCopy:b}=vx({table:t}),S=(0,x.useRef)(null),h=it(_=>{S.current=_});function w(_,y){let R=/{{(\w+)}}/g,A=new Map;for(let I of y){let V=Mn({value:I.getValue(),nullAsEmptyString:!0});A.set(I.column.id,V)}return _.replaceAll(R,(I,V)=>{let E=A.get(V);return E===void 0?`{{${V}}}`:E})}let v=_=>_.map(y=>{var E,D,G,K;let{className:R,style:A}=Mu(y.column),I=Object.assign({},((E=y.getUserStyling)==null?void 0:E.call(y))||{},A),V=((D=y.getHoverTitle)==null?void 0:D.call(y))??void 0;return(0,x.createElement)(kd,{tabIndex:0,...Kb(y.id),key:y.id,className:T("whitespace-pre truncate max-w-[300px] outline-hidden border-r border-r-border/75",y.column.getColumnWrapping&&((K=(G=y.column).getColumnWrapping)==null?void 0:K.call(G))==="wrap"&&"whitespace-pre-wrap min-w-[200px]","px-1.5 py-[0.18rem]",R),style:I,title:V,onMouseDown:se=>p(se,y),onMouseUp:m,onMouseOver:se=>g(se,y),onContextMenu:()=>h(y)},(0,s.jsx)(Nu,{cellId:y.id}),(0,s.jsx)("div",{className:"relative",children:il(y.column.columnDef.cell,y.getContext())}))}),j=_=>{var y;if(n){let R=(r==null?void 0:r(_.original,_.index))??_.index;(y=_.focusRow)==null||y.call(_,R)}},k=t.getState().cellHoverTemplate||null,C=_=>{var I;let y=n?(r==null?void 0:r(_.original,_.index))??_.index:void 0,R=n&&l===y,A;return k&&(A=w(k,((I=_.getVisibleCells)==null?void 0:I.call(_))??[..._.getLeftVisibleCells(),..._.getCenterVisibleCells(),..._.getRightVisibleCells()])),(0,s.jsxs)(co,{"data-state":_.getIsSelected()&&"selected",title:A,className:T("border-t h-6",n&&"cursor-pointer",R&&"bg-(--blue-3) hover:bg-(--blue-3) data-[state=selected]:bg-(--blue-4)"),onClick:()=>j(_),children:[v(_.getLeftVisibleCells()),v(_.getCenterVisibleCells()),v(_.getRightVisibleCells()),e.length<=4&&(0,s.jsx)("td",{className:"border-0","aria-hidden":"true",role:"presentation"})]},_.id)},M=e.length<=4,N=e.length+(M?1:0);return(0,s.jsx)(hx,{tableBody:(0,s.jsx)(ow,{onKeyDown:f,ref:u,children:(()=>{var _,y;if(o.length===0)return(0,s.jsx)(co,{children:(0,s.jsx)(kd,{colSpan:N,className:"h-24 text-center",children:"No results."})});if(a){let R=d.getVirtualItems(),A=d.getTotalSize();return(0,s.jsxs)(s.Fragment,{children:[((_=R[0])==null?void 0:_.start)>0&&(0,s.jsx)("tr",{"data-virtual-spacer":"",style:{height:R[0].start},children:(0,s.jsx)("td",{colSpan:N})}),R.map(I=>C(o[I.index])),R.length>0&&(0,s.jsx)("tr",{"data-virtual-spacer":"",style:{height:A-(((y=R.at(-1))==null?void 0:y.end)??A)},children:(0,s.jsx)("td",{colSpan:N})})]})}return o.map(R=>C(R))})()}),contextMenuRef:S,tableRef:u,copyAllCells:b})};function Mu(t){let e=t.getIsPinned(),n=e==="left"&&t.getIsLastColumn("left"),r=e==="right"&&t.getIsFirstColumn("right");return{className:T(e&&"bg-inherit","shadow-r z-10"),style:{boxShadow:n&&t.id!=="__select__"?"-4px 0 4px -4px var(--slate-8) inset":r?"4px 0 4px -4px var(--slate-8) inset":void 0,left:e==="left"?`${t.getStart("left")}px`:void 0,right:e==="right"?`${t.getAfter("right")}px`:void 0,opacity:1,position:e?"sticky":"relative",zIndex:e?1:0,width:t.getSize()}}}function Nx({table:t,column:e,thead:n}){if(!n)return;let r=Math.round(n.getBoundingClientRect().width);t.getState().columnSizing[e.id]!==r&&t.setColumnSizing(l=>({...l,[e.id]:r}))}const Mx=({table:t,tableLoading:e,showPageSizeSelector:n})=>{let{locale:r}=Ke(),l=Math.min(t.getState().pagination.pageIndex+1,t.getPageCount()),a=t.getPageCount(),o=t.getState().pagination.pageSize,i=u=>{e||u()},c=[...new Set([5,10,25,50,100,o])].toSorted((u,d)=>u-d);return(0,s.jsxs)("div",{className:"flex flex-col lg:flex-row items-center gap-0.5 lg:gap-1 px-2",children:[(0,s.jsx)("div",{className:"order-2 lg:order-first",children:n&&(0,s.jsx)("div",{className:"flex items-center text-xs whitespace-nowrap mr-1 print:hidden",children:(0,s.jsxs)(Zr,{children:[(0,s.jsx)(Xr,{asChild:!0,children:(0,s.jsxs)("button",{type:"button",className:"border rounded justify-between pl-1.5 pr-0.5 h-6 text-xs items-center hover:bg-accent inline-flex gap-0.5",children:[o," / page",(0,s.jsx)(el,{className:"h-3 w-3 opacity-50 mb-px"})]})}),(0,s.jsxs)(Yr,{align:"center",sideOffset:6,children:[(0,s.jsx)(lo,{className:"text-xs text-muted-foreground",children:"Rows per page"}),[...c].map(u=>(0,s.jsx)(ee,{className:T("text-xs cursor-pointer",u===o&&"font-semibold bg-accent"),onSelect:()=>t.setPageSize(u),onMouseDown:qe.preventFocus,children:u},u))]})]})})}),(0,s.jsxs)("div",{className:"order-1 lg:order-last flex items-center print:hidden",children:[(0,s.jsx)(Ce,{content:"First page",children:(0,s.jsx)(ce,{size:"xs",variant:"text","data-testid":"first-page-button",className:"hidden h-6 w-5 p-0 lg:flex",onClick:()=>i(()=>t.setPageIndex(0)),onMouseDown:qe.preventFocus,disabled:!t.getCanPreviousPage(),children:(0,s.jsx)(_o,{className:"h-4 w-4"})})}),(0,s.jsx)(Ce,{content:"Previous page",children:(0,s.jsx)(ce,{size:"xs",variant:"text","data-testid":"previous-page-button",className:"h-6 w-5 p-0",onClick:()=>i(()=>t.previousPage()),onMouseDown:qe.preventFocus,disabled:!t.getCanPreviousPage(),children:(0,s.jsx)(Uv,{className:"h-4 w-4"})})}),(0,s.jsxs)("div",{className:"flex items-center justify-center text-xs font-medium gap-1",children:[(0,s.jsx)("span",{children:"Page"}),(0,s.jsx)(Ix,{currentPage:l,totalPages:a,onPageChange:u=>i(()=>t.setPageIndex(u))}),(0,s.jsxs)("span",{className:"shrink-0",children:["of ",Oe(a,r)]})]}),(0,s.jsx)(Ce,{content:"Next page",children:(0,s.jsx)(ce,{size:"xs",variant:"text","data-testid":"next-page-button",className:"h-6 w-5 p-0",onClick:()=>i(()=>t.nextPage()),onMouseDown:qe.preventFocus,disabled:!t.getCanNextPage(),children:(0,s.jsx)(cS,{className:"h-4 w-4"})})}),(0,s.jsx)(Ce,{content:"Last page",children:(0,s.jsx)(ce,{size:"xs",variant:"text","data-testid":"last-page-button",className:"hidden h-6 w-5 p-0 lg:flex",onClick:()=>i(()=>t.setPageIndex(t.getPageCount()-1)),onMouseDown:qe.preventFocus,disabled:!t.getCanNextPage(),children:(0,s.jsx)(Jo,{className:"h-4 w-4"})})})]})]})};var Ua=32;function Fx(t,e){let n=Number.parseInt(t,10);if(Number.isNaN(n)||n<=0||String(n)!==t)return[];let r=[],l=1;for(;n*l<=e;){let a=n*l,o=Math.min((n+1)*l-1,e);r.push([a,o]),l*=10}return r}function Ax(t,e){if(t==="")return{count:e,pageAtIndex:l=>l+1,indexOfPage:l=>l-1};let n=Fx(t,e),r=0;for(let[l,a]of n)r+=a-l+1;return{count:r,pageAtIndex:l=>{let a=0;for(let[o,i]of n){let c=i-o+1;if(l<a+c)return o+(l-a);a+=c}return-1},indexOfPage:l=>{let a=0;for(let[o,i]of n){if(l>=o&&l<=i)return a+(l-o);a+=i-o+1}return-1}}}const Ix=({currentPage:t,totalPages:e,onPageChange:n})=>{let[r,l]=x.useState(!1),[a,o]=x.useState(""),i=x.useMemo(()=>Ax(a,e),[a,e]),c=d=>{n(d-1),o(""),l(!1)},u=Math.min(i.count*Ua,240);return(0,s.jsxs)(Ur,{open:e>1?r:!1,onOpenChange:d=>{l(d),d||o("")},children:[(0,s.jsx)(qr,{asChild:!0,disabled:e<=1,children:(0,s.jsxs)("button",{type:"button",className:T("border rounded justify-between pl-1.5 pr-0.5 h-6 min-w-9 text-xs items-center inline-flex gap-0.5",e>1?"hover:bg-accent cursor-pointer":"opacity-50 cursor-default"),"data-testid":"page-select",disabled:e<=1,children:[t,(0,s.jsx)(el,{className:"h-3 w-3 opacity-50 mb-px"})]})}),(0,s.jsx)(Kr,{className:"w-36 p-0",align:"center",sideOffset:6,children:(0,s.jsxs)(jd,{shouldFilter:!1,value:String(t),children:[(0,s.jsx)(Sd,{placeholder:`Page (1\u2013${e})`,rootClassName:"px-2 h-8",className:"text-xs h-8",autoFocus:!0,icon:null,value:a,onValueChange:o,onKeyDown:d=>{!["Backspace","Delete","ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Tab","Enter","Escape"].includes(d.key)&&!/^\d$/.test(d.key)&&d.preventDefault()}}),(0,s.jsx)(Cd,{className:"max-h-60 overflow-hidden",children:i.count===0?(0,s.jsx)(wd,{className:"py-2 text-center text-xs text-muted-foreground",children:"No matching page"}):(0,s.jsx)(Ex,{mapping:i,currentPage:t,listHeight:u,onSelect:c})})]})})]})};var Ex=({mapping:t,currentPage:e,listHeight:n,onSelect:r})=>{let l=x.useRef(null),a=t.indexOfPage(e),o=Cu({count:t.count,getScrollElement:()=>l.current,estimateSize:()=>Ua,overscan:10,initialOffset:a>0?Math.max(0,a*Ua-n/2):0}),i=x.useRef(t.count);return x.useEffect(()=>{t.count!==i.current&&(o.scrollToIndex(0),i.current=t.count)},[t.count,o]),(0,s.jsx)("div",{ref:l,style:{height:n,overflow:"auto"},children:(0,s.jsx)("div",{style:{height:o.getTotalSize(),width:"100%",position:"relative"},children:o.getVirtualItems().map(c=>{let u=t.pageAtIndex(c.index);return(0,s.jsx)(so,{value:String(u),"data-testid":"page-option","aria-selected":u===e,className:T("text-xs cursor-pointer",u===e&&"font-semibold bg-accent"),style:{position:"absolute",top:0,left:0,width:"100%",height:c.size,transform:`translateY(${c.start}px)`},onSelect:()=>r(u),onMouseDown:qe.preventFocus,children:u},u)})})})};Bo=function(t,e){return`${Oe(t,e)} ${new Zu("row").pluralize(t)}`},$o=({numRows:t,totalColumns:e,locale:n})=>[t==="too_many"?"Unknown":Bo(t,n),`${Oe(e,n)} ${new Zu("column").pluralize(e)}`].join(", ");var In=L(),Ja=3;const Fu=t=>{let e=(0,In.c)(21),{table:n,className:r}=t,{locale:l}=Ke(),a=$n(qa),o=Wy(a);if(o<2){let f;e[0]===r?f=e[1]:(f=T("text-xs text-muted-foreground/80 italic",r),e[0]=r,e[1]=f);let b;return e[2]===f?b=e[3]:(b=(0,s.jsx)(Ce,{content:"Select multiple cells to see stats",children:(0,s.jsx)("span",{className:f,children:"No selection"})}),e[2]=f,e[3]=b),b}let i;e[4]!==a||e[5]!==n?(i=Gy(n,a),e[4]=a,e[5]=n,e[6]=i):i=e[6];let c=i,u;e[7]===r?u=e[8]:(u=T("flex items-center justify-end gap-3 text-sm text-muted-foreground shrink-0",r),e[7]=r,e[8]=u);let d;e[9]!==o||e[10]!==l?(d=(0,s.jsx)(Ox,{count:o,locale:l}),e[9]=o,e[10]=l,e[11]=d):d=e[11];let p,m;e[12]!==l||e[13]!==c?(p=(0,s.jsx)($x,{numericValues:c,locale:l}),m=(0,s.jsx)(Tx,{numericValues:c,locale:l}),e[12]=l,e[13]=c,e[14]=p,e[15]=m):(p=e[14],m=e[15]);let g;return e[16]!==u||e[17]!==d||e[18]!==p||e[19]!==m?(g=(0,s.jsxs)("div",{className:u,children:[d,p,m]}),e[16]=u,e[17]=d,e[18]=p,e[19]=m,e[20]=g):g=e[20],g};var Px=(t,e)=>t.toLocaleString(e,{maximumFractionDigits:Ja}),Xa=t=>{let e=(0,In.c)(6),{name:n,value:r,locale:l}=t,a;e[0]!==l||e[1]!==r?(a=Px(r,l),e[0]=l,e[1]=r,e[2]=a):a=e[2];let o;return e[3]!==n||e[4]!==a?(o=(0,s.jsxs)("span",{children:[n,": ",a]}),e[3]=n,e[4]=a,e[5]=o):o=e[5],o},Ox=t=>{let e=(0,In.c)(3),{count:n,locale:r}=t,l;return e[0]!==n||e[1]!==r?(l=(0,s.jsx)(Xa,{name:"Count",value:n,locale:r}),e[0]=n,e[1]=r,e[2]=l):l=e[2],l},$x=t=>{let e=(0,In.c)(6),{numericValues:n,locale:r}=t;if(n.length===0)return null;let l,a;if(e[0]!==n){let c=n.reduce(zx,0);l=Number,a=c.toFixed(Ja),e[0]=n,e[1]=l,e[2]=a}else l=e[1],a=e[2];let o=l(a),i;return e[3]!==r||e[4]!==o?(i=(0,s.jsx)(Xa,{name:"Sum",value:o,locale:r}),e[3]=r,e[4]=o,e[5]=i):i=e[5],i},Tx=t=>{let e=(0,In.c)(5),{numericValues:n,locale:r}=t;if(n.length===0)return null;let l=n.reduce(Vx,0)/n.length,a;e[0]===l?a=e[1]:(a=l.toFixed(Ja),e[0]=l,e[1]=a);let o=Number(a),i;return e[2]!==o||e[3]!==r?(i=(0,s.jsx)(Xa,{name:"Average",value:o,locale:r}),e[2]=o,e[3]=r,e[4]=i):i=e[4],i};function zx(t,e){return t+e}function Vx(t,e){return t+e}const Dx=({pagination:t,totalColumns:e,selection:n,onRowSelectionChange:r,table:l,getRowIds:a,showPageSizeSelector:o,tableLoading:i,part:c,className:u})=>{let{locale:d}=Ke(),p=m=>{if(!r)return;if(!m){r({});return}let g=()=>{let f=Array.from({length:l.getRowCount()},(b,S)=>[S,!0]);r(Object.fromEntries(f))};if(!a){g();return}a({}).then(f=>{if(f.error){Vn({title:"Not available",description:f.error,variant:"danger"});return}f.all_rows?g():r(Object.fromEntries(f.row_ids.map(b=>[b,!0])))})};return(0,s.jsxs)("div",{part:c,className:T("flex lg:grid lg:grid-cols-[1fr_auto_1fr] items-center shrink-0",u),children:[(0,s.jsxs)("div",{className:"flex flex-col text-sm text-muted-foreground px-2 shrink-0",children:[(0,s.jsx)("div",{className:"flex items-center gap-1",children:(()=>{let{rowSelection:m,cellSelection:g}=l.getState(),f=Object.keys(m).length,b=l.getIsAllPageRowsSelected(),S=l.getRowCount(),h=f===S,w=n==="single-cell"||n==="multi-cell";return w&&(f=g.length,b=!1,h=!1),b&&!h?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{children:[Oe(f,d)," selected"]}),(0,s.jsxs)(ce,{size:"xs","data-testid":"select-all-button",variant:"link",className:"h-4 print:hidden",onMouseDown:qe.preventFocus,onClick:()=>p(!0),children:["Select all ",Oe(S,d)]})]}):f?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("span",{children:[Oe(f,d)," selected"]}),(0,s.jsx)(ce,{size:"xs","data-testid":"clear-selection-button",variant:"link",className:"h-4 print:hidden",onMouseDown:qe.preventFocus,onClick:()=>{w?l.resetCellSelection&&l.resetCellSelection():p(!1)},children:"Clear selection"})]}):(0,s.jsx)("span",{children:$o({numRows:l.getRowCount(),totalColumns:e,locale:d})})})()}),(0,s.jsx)(Fu,{table:l,className:"lg:hidden"})]}),(0,s.jsx)("div",{className:"ml-auto lg:ml-0 lg:justify-self-center flex items-center shrink-0",children:t&&(0,s.jsx)(Mx,{table:l,tableLoading:i,showPageSizeSelector:o})}),(0,s.jsx)("div",{className:"hidden lg:flex justify-end",children:(0,s.jsx)(Fu,{table:l,className:"px-2"})})]})};var Lx=L();Ro=t=>{let e=(0,Lx.c)(13),{packages:n,showMaxPackages:r,className:l,onInstall:a}=t,{handleInstallPackages:o}=QS();if(!n||n.length===0)return null;let i;e[0]!==o||e[1]!==a||e[2]!==n?(i=()=>{o(n,a)},e[0]=o,e[1]=a,e[2]=n,e[3]=i):i=e[3];let c;e[4]===l?c=e[5]:(c=T("ml-2",l),e[4]=l,e[5]=c);let u;e[6]!==n||e[7]!==r?(u=r?n.slice(0,r).join(", "):n.join(", "),e[6]=n,e[7]=r,e[8]=u):u=e[8];let d;return e[9]!==i||e[10]!==c||e[11]!==u?(d=(0,s.jsxs)(ce,{variant:"outline",size:"xs",onClick:i,className:c,children:["Install"," ",u]}),e[9]=i,e[10]=c,e[11]=u,e[12]=d):d=e[12],d};var Hx=L();const Bx=t=>{let e=(0,Hx.c)(16),{packages:n,featureName:r,description:l,onInstall:a,className:o}=t;if(!Wb()){let m;e[0]===o?m=e[1]:(m=T("text-xs",o),e[0]=o,e[1]=m);let g;return e[2]!==r||e[3]!==m?(g=(0,s.jsxs)("span",{className:m,children:[r," isn't available in this notebook"]}),e[2]=r,e[3]=m,e[4]=g):g=e[4],g}let i;e[5]===o?i=e[6]:(i=T("text-xs flex flex-col items-end gap-2",o),e[5]=o,e[6]=i);let c=l||`${r} requires ${n.join(", ")}`,u;e[7]===c?u=e[8]:(u=(0,s.jsx)("span",{className:"self-start",children:c}),e[7]=c,e[8]=u);let d;e[9]!==a||e[10]!==n?(d=(0,s.jsx)(Ro,{packages:n,onInstall:a,className:"ml-0"}),e[9]=a,e[10]=n,e[11]=d):d=e[11];let p;return e[12]!==i||e[13]!==u||e[14]!==d?(p=(0,s.jsxs)("div",{className:i,children:[u,d]}),e[12]=i,e[13]=u,e[14]=d,e[15]=p):p=e[15],p};var Wx=L(),Ot={CSV:{label:"CSV",format:"csv",description:"Comma-separated values",icon:pd},JSON:{label:"JSON",format:"json",description:"Raw JSON data",icon:qb},PARQUET:{label:"Parquet",format:"parquet",description:"Columnar binary format",icon:Ri},TSV:{label:"TSV",format:"tsv",description:"Best for Excel and Google Sheets",icon:pd},MARKDOWN:{label:"Markdown",format:"markdown",description:"Preserves hyperlinks and formatting",icon:Jb}},Au=[Ot.CSV,Ot.JSON,Ot.PARQUET],Gx=[Ot.TSV,Ot.JSON,Ot.CSV,Ot.MARKDOWN],qx=t=>{var e;return((e=Au.find(n=>n.format===t))==null?void 0:e.label)??t};const Kx=t=>{let e=(0,Wx.c)(48),{locale:n}=Ke(),[r,l]=x.useState(!1),a=r?"text-primary":"text-muted-foreground",o;e[0]===a?o=e[1]:(o=T("print:hidden text-xs gap-1",a),e[0]=a,e[1]=o);let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=(0,s.jsx)(Go,{className:"w-3.5 h-3.5"}),e[2]=i):i=e[2];let c;e[3]===o?c=e[4]:(c=(0,s.jsxs)(ce,{"data-testid":"export-button",size:"xs",variant:"text",className:o,children:[i,"Export"]}),e[3]=o,e[4]=c);let u=c,d;e[5]===t?d=e[6]:(d=async(R,A)=>{let I;try{I=await t.downloadAs({format:R})}catch(V){let E=V;return Vn({title:"Failed to download",description:typeof E=="object"&&E&&"message"in E?String(E.message):String(E)}),null}return I.missing_packages&&I.missing_packages.length>0?(Vn({title:"Export failed",description:(0,s.jsx)(Bx,{packages:I.missing_packages,featureName:`${qx(R)} export`,description:I.error,onInstall:A})}),null):{url:I.url,filename:I.filename}},e[5]=t,e[6]=d);let p=d,m,g,f,b,S,h,w,v,j,k,C,M,N;if(e[7]!==u||e[8]!==n||e[9]!==r||e[10]!==p){let R=async E=>{let D=await p(E,()=>{R(E)});if(!D)return;let G=(D.filename??"").trim(),K=Kv.withoutExtension(G)||"download";Jv(D.url,`${K}.${E}`)},A=async E=>{let D=await p(E==="csv"?"csv":"json",()=>{A(E)});if(!D)return;let G;e:switch(E){case"tsv":G=Db(await Ya(D.url),n);break e;case"json":{let K=await Ya(D.url);G=JSON.stringify(K,null,2);break e}case"csv":G=await Iu(D.url);break e;case"markdown":G=Lb(await Ya(D.url));break e;default:kt(E);return}await on(G),Vn({title:"Copied to clipboard"})};g=Zr,S=!1,h=r,w=l;let I=r?!1:void 0,V;e[24]===u?V=e[25]:(V=(0,s.jsx)(Xr,{asChild:!0,children:u}),e[24]=u,e[25]=V),e[26]!==I||e[27]!==V?(v=(0,s.jsx)(Ce,{content:"Export",open:I,children:V}),e[26]=I,e[27]=V,e[28]=v):v=e[28],m=Yr,j="bottom",k="print:hidden",e[29]===Symbol.for("react.memo_cache_sentinel")?(C=(0,s.jsx)(lo,{className:"text-xs text-muted-foreground",children:"Download"}),e[29]=C):C=e[29],M=Au.map(E=>(0,s.jsxs)(ee,{onSelect:()=>{R(E.format)},children:[(0,s.jsx)(E.icon,{className:"mo-dropdown-icon"}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("span",{children:E.label}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:E.description})]})]},E.label)),e[30]===Symbol.for("react.memo_cache_sentinel")?(N=(0,s.jsx)(an,{}),f=(0,s.jsx)(lo,{className:"text-xs text-muted-foreground",children:"Copy to clipboard"}),e[30]=f,e[31]=N):(f=e[30],N=e[31]),b=Gx.map(E=>(0,s.jsxs)(ee,{onSelect:async()=>{try{await A(E.format)}catch(D){Vn({title:"Failed to copy to clipboard",description:TS(D),variant:"danger"})}},children:[(0,s.jsx)(E.icon,{className:"mo-dropdown-icon"}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("span",{children:E.label}),(0,s.jsx)("span",{className:"text-xs text-muted-foreground",children:E.description})]})]},E.label)),e[7]=u,e[8]=n,e[9]=r,e[10]=p,e[11]=m,e[12]=g,e[13]=f,e[14]=b,e[15]=S,e[16]=h,e[17]=w,e[18]=v,e[19]=j,e[20]=k,e[21]=C,e[22]=M,e[23]=N}else m=e[11],g=e[12],f=e[13],b=e[14],S=e[15],h=e[16],w=e[17],v=e[18],j=e[19],k=e[20],C=e[21],M=e[22],N=e[23];let _;e[32]!==m||e[33]!==f||e[34]!==b||e[35]!==j||e[36]!==k||e[37]!==C||e[38]!==M||e[39]!==N?(_=(0,s.jsxs)(m,{side:j,className:k,children:[C,M,N,f,b]}),e[32]=m,e[33]=f,e[34]=b,e[35]=j,e[36]=k,e[37]=C,e[38]=M,e[39]=N,e[40]=_):_=e[40];let y;return e[41]!==g||e[42]!==S||e[43]!==h||e[44]!==w||e[45]!==v||e[46]!==_?(y=(0,s.jsxs)(g,{modal:S,open:h,onOpenChange:w,children:[v,_]}),e[41]=g,e[42]=S,e[43]=h,e[44]=w,e[45]=v,e[46]=_,e[47]=y):y=e[47],y};function Ya(t){return Iu(t).then(ed)}function Iu(t){return fetch(t).then(e=>{if(!e.ok)throw Error(e.statusText);return e.text()})}var Ux=()=>{};let Eu;Eu=({enableSearch:t,searchQuery:e,onSearchQueryChange:n,reloading:r,showChartBuilder:l,isChartBuilderOpen:a,toggleDisplayHeader:o,showTableExplorer:i,togglePanel:c,isAnyPanelOpen:u,downloadAs:d})=>{let[p,m]=(0,x.useState)(e||""),g=B1(p,500),f=it(n??Ux),b=x.useRef(null);return(0,x.useEffect)(()=>{f(g)},[g,f]),t&&n||l||i||d?(0,s.jsxs)("div",{className:"flex items-center h-10 px-2 border-b gap-2",children:[n&&t&&(0,s.jsxs)("div",{className:"flex flex-1 items-center gap-1 px-2 rounded-sm focus-within:ring-1 focus-within:ring-border transition-shadow",children:[(0,s.jsx)(yd,{className:"w-4 h-4 text-muted-foreground shrink-0"}),(0,s.jsx)("input",{ref:b,type:"text",className:"h-6 border-none bg-transparent focus:outline-hidden text-sm w-full min-w-0",value:p,onKeyDown:S=>{var h;S.key==="Escape"&&(m(""),(h=b.current)==null||h.blur())},onChange:S=>m(S.target.value),placeholder:"Search..."}),r&&(0,s.jsx)(gd,{size:"small"}),p&&(0,s.jsx)(ce,{variant:"text",size:"xs",className:"h-5 w-5 p-0 shrink-0",onClick:()=>m(""),children:(0,s.jsx)(tl,{className:"w-3 h-3 text-muted-foreground"})})]}),(0,s.jsxs)("div",{className:"flex items-center shrink-0",children:[l&&(0,s.jsxs)(ce,{variant:"text",size:"xs",className:T("print:hidden text-xs gap-1",a?"text-primary":"text-muted-foreground"),onClick:o,children:[(0,s.jsx)(Ni,{className:"w-3.5 h-3.5"}),"Visualize"]}),i&&c&&(0,s.jsxs)(ce,{variant:"text",size:"xs",className:T("print:hidden text-xs gap-1",u?"text-primary":"text-muted-foreground"),onClick:()=>c(ul.ROW_VIEWER),children:[(0,s.jsx)(Pi,{className:"w-3.5 h-3.5"}),"Explore"]}),d&&(0,s.jsx)(Kx,{downloadAs:d})]})]}):null},Ho=(0,x.memo)(({wrapperClassName:t,className:e,maxHeight:n,columns:r,data:l,rawData:a,selection:o,totalColumns:i,totalRows:c,manualSorting:u=!1,sorting:d,setSorting:p,rowSelection:m,cellSelection:g,cellStyling:f,hoverTemplate:b,cellHoverTexts:S,paginationState:h,setPaginationState:w,downloadAs:v,manualPagination:j=!1,pagination:k=!1,onRowSelectionChange:C,onCellSelectionChange:M,getRowIds:N,enableSearch:_=!1,searchQuery:y,onSearchQueryChange:R,showFilters:A=!1,filters:I,onFiltersChange:V,reloading:E,freezeColumnsLeft:D,freezeColumnsRight:G,toggleDisplayHeader:K,showChartBuilder:se,isChartBuilderOpen:q,showPageSizeSelector:Y,showTableExplorer:we,togglePanel:de,isPanelOpen:je,isAnyPanelOpen:Ae,viewedRowIdx:ze,onViewedRowChange:Be})=>{let[Ie,ot]=x.useState(!1),{locale:gt}=Ke(),{columnPinning:Ee,setColumnPinning:We}=Ey(D,G);x.useEffect(()=>{let pe;return E?pe=setTimeout(()=>{ot(!0)},300):ot(!1),()=>{pe&&clearTimeout(pe)}},[E]);function U(pe,Re){return h?Re+(j?h.pageIndex*h.pageSize:0):Re}let te=Lo({_features:[zc,sy,f1,ky,Ry,jy,wy,Ny,Ay],data:l,columns:r,meta:{rawData:a},getCoreRowModel:go(),rowCount:c==="too_many"?void 0:c,...w?{onPaginationChange:w,getRowId:(pe,Re)=>{let P=Nr(pe);if(P)return P;let Ve=U(pe,Re);return String(Ve)}}:{},locale:gt,manualPagination:j,getPaginationRowModel:u1(),...p?{onSortingChange:p}:{},manualSorting:u,enableMultiSort:!0,getSortedRowModel:wo(),manualFiltering:!0,enableColumnFilters:A,getFilteredRowModel:Co(),onColumnFiltersChange:V,onRowSelectionChange:C,onCellSelectionChange:M,enableCellSelection:o==="single-cell"||o==="multi-cell",enableMultiCellSelection:o==="multi-cell",onColumnPinningChange:We,enableFocusRow:!0,onFocusRowChange:Be,state:{...d?{sorting:d}:{},columnFilters:I,...h?{pagination:h}:k&&!h?{}:{pagination:{pageIndex:0,pageSize:l.length}},rowSelection:m??{},cellSelection:g??[],cellStyling:f,columnPinning:Ee,cellHoverTemplate:b,cellHoverTexts:S??{}}}),_e=(je==null?void 0:je(ul.ROW_VIEWER))??!1,Z=!k&&l.length>100,me=Oy({maxHeight:n,virtualize:Z});return(0,s.jsxs)("div",{className:T(t,"flex flex-col space-y-1"),children:[(0,s.jsx)(My,{filters:I,table:te}),(0,s.jsx)(Zy,{children:(0,s.jsxs)("div",{part:"table-wrapper",className:T(e||"rounded-md border overflow-hidden"),children:[(0,s.jsx)(Eu,{enableSearch:_,searchQuery:y,onSearchQueryChange:R,reloading:E,showChartBuilder:se,isChartBuilderOpen:q,toggleDisplayHeader:K,showTableExplorer:we,togglePanel:de,isAnyPanelOpen:Ae,downloadAs:v}),(0,s.jsxs)(iw,{className:T("relative",r.length<=4?"w-auto":"w-full"),ref:me,children:[Ie&&(0,s.jsx)("thead",{className:"absolute top-0 left-0 h-[3px] w-1/2 bg-primary animate-slide"}),_x(te,Z||!!n),(0,s.jsx)(Rx,{table:te,columns:r,rowViewerPanelOpen:_e,getRowIndex:U,viewedRowIdx:ze,virtualize:Z})]}),(0,s.jsx)(Dx,{part:"table-footer",className:"pt-1.5 pb-0.5 border-t border-border",totalColumns:i,pagination:k,selection:o,onRowSelectionChange:C,table:te,getRowIds:N,showPageSizeSelector:Y,tableLoading:E})]})})]})});var Qt=L(),Jx=25;Do=function(t){return t?t.startsWith("image/")||t.startsWith("audio/")||t.startsWith("video/")||t.startsWith("application/pdf"):!1},cl={"application/javascript":"javascript","text/markdown":"markdown","text/html":"html","text/css":"css","text/x-python":"python","application/json":"json","application/xml":"xml","text/x-yaml":"yaml","text/csv":"markdown","text/plain":"markdown",default:"markdown"};function Tr(t){return t.url==null?fS(t.base64,t.mime):t.url}let Qa,Pu,Ou,$u,Tu,zu;Qa=({contents:t})=>{let e=(0,x.useMemo)(()=>io(t),[t]),[n,r]=(0,x.useState)({pageIndex:0,pageSize:Jx}),l=(0,x.useMemo)(()=>uo(e),[e]),a=(0,x.useMemo)(()=>Oo({rowHeaders:Yv.EMPTY,selection:null,fieldTypes:l}),[l]);return(0,s.jsx)(Ho,{data:e,totalRows:e.length,columns:a,totalColumns:a.length,manualPagination:!1,paginationState:n,setPaginationState:r,wrapperClassName:"h-full justify-between pb-1 px-1",pagination:!0,className:"rounded-none border-b flex flex-col overflow-hidden",rowSelection:to.EMPTY})},Pu=t=>{let e=(0,Qt.c)(4),n;e[0]===t?n=e[1]:(n=Tr(t),e[0]=t,e[1]=n);let r;return e[2]===n?r=e[3]:(r=(0,s.jsx)("img",{src:n,alt:"Preview"}),e[2]=n,e[3]=r),r},Ou=t=>{let e=(0,Qt.c)(4),n;e[0]===t?n=e[1]:(n=Tr(t),e[0]=t,e[1]=n);let r;return e[2]===n?r=e[3]:(r=(0,s.jsx)("audio",{controls:!0,src:n}),e[2]=n,e[3]=r),r},$u=t=>{let e=(0,Qt.c)(4),n;e[0]===t?n=e[1]:(n=Tr(t),e[0]=t,e[1]=n);let r;return e[2]===n?r=e[3]:(r=(0,s.jsx)("video",{controls:!0,src:n}),e[2]=n,e[3]=r),r},Tu=t=>{let e=(0,Qt.c)(4),n;e[0]===t?n=e[1]:(n=Tr(t),e[0]=t,e[1]=n);let r;return e[2]===n?r=e[3]:(r=(0,s.jsx)("iframe",{src:n,title:"PDF Viewer",className:"w-full h-full"}),e[2]=n,e[3]=r),r},zu=t=>{let e=(0,Qt.c)(11),n,r;if(e[0]===t?(n=e[1],r=e[2]):({mimeType:n,...r}=t,e[0]=t,e[1]=n,e[2]=r),n.startsWith("image/")){let l;return e[3]===r?l=e[4]:(l=(0,s.jsx)(Pu,{...r}),e[3]=r,e[4]=l),l}if(n.startsWith("audio/")){let l;return e[5]===r?l=e[6]:(l=(0,s.jsx)(Ou,{...r}),e[5]=r,e[6]=l),l}if(n.startsWith("video/")){let l;return e[7]===r?l=e[8]:(l=(0,s.jsx)($u,{...r}),e[7]=r,e[8]=l),l}if(n.startsWith("application/pdf")){let l;return e[9]===r?l=e[10]:(l=(0,s.jsx)(Tu,{...r}),e[9]=r,e[10]=l),l}return null},Td=t=>{let e=(0,Qt.c)(17),{mimeType:n,contents:r,mediaSource:l,readOnly:a,onChange:o,extensions:i}=t,c=a===void 0?!0:a,u;e[0]===i?u=e[1]:(u=i===void 0?[]:i,e[0]=i,e[1]=u);let d=u,{theme:p}=ll();if(n==="text/csv"&&r!=null){let m;return e[2]===r?m=e[3]:(m=(0,s.jsx)("div",{className:"flex-1 overflow-hidden flex flex-col",children:(0,s.jsx)(Qa,{contents:r})}),e[2]=r,e[3]=m),m}if(Do(n)&&l){let m;return e[4]!==l||e[5]!==n?(m=(0,s.jsx)("div",{className:"flex-1 overflow-hidden flex flex-col",children:(0,s.jsx)(zu,{...l,mimeType:n})}),e[4]=l,e[5]=n,e[6]=m):m=e[6],m}if(r!=null){let m=cl[n]||cl.default,g=p==="dark"?"dark":"light",f;e[7]===d?f=e[8]:(f=[dd.lineWrapping,...d],e[7]=d,e[8]=f);let b=c?!1:void 0,S=c?void 0:o,h;return e[9]!==r||e[10]!==m||e[11]!==c||e[12]!==g||e[13]!==f||e[14]!==b||e[15]!==S?(h=(0,s.jsx)("div",{className:"flex-1 overflow-auto",children:(0,s.jsx)(x.Suspense,{children:(0,s.jsx)(lS,{theme:g,language:m,className:"border-b",extensions:f,value:r,readOnly:c,editable:b,onChange:S})})}),e[9]=r,e[10]=m,e[11]=c,e[12]=g,e[13]=f,e[14]=b,e[15]=S,e[16]=h):h=e[16],h}return null};function Xx(t,e){let{state:n}=t,r=n.doc;if(e<=0||e>r.lines)return st.warn(`Invalid line number: ${e}. Document has ${r.lines} lines.`),!1;let l=r.line(e);if(l.text.includes("breakpoint()"))return!0;let a=l.text.match(/^(\s*)/),o=`${a?a[1]:""}breakpoint()
|
|
46
46
|
`,i=l.from;return t.dispatch({changes:{from:i,to:i,insert:o},selection:{anchor:i+o.length-1,head:i+o.length-1},scrollIntoView:!0,effects:[dd.scrollIntoView(i,{y:"center"})]}),t.focus(),!0}var Vu=L(),Du="item";const Yx=t=>{var we;let e=(0,Vu.c)(47),{onRefactorWithAI:n,traceback:r,cellId:l}=t,a;e[0]===r?a=e[1]:(a=ao({html:r,additionalReplacements:[Zx,eb]}),e[0]=r,e[1]=a);let o=a,[i,c]=(0,x.useState)(!0),u=Qx(r),d=$n(rv),p;e[2]===r?p=e[3]:(p=(we=Yb(r))==null?void 0:we.at(0),e[2]=r,e[3]=p);let m=p,g;e[4]!==l||e[5]!==m?(g=m&&m.kind==="cell"&&!rd()&&!Bn()&&l!=="__scratch__",e[4]=l,e[5]=m,e[6]=g):g=e[6];let f=g,b;e[7]!==d||e[8]!==n?(b=n&&d&&!Bn(),e[7]=d,e[8]=n,e[9]=b):b=e[9];let S=b,h=!Bn(),w=de=>{n==null||n({prompt:`My code gives the following error:
|
|
47
47
|
|
|
48
48
|
${u}`,triggerImmediately:de})},[v,j]=u.split(":",2),k=i?Du:"",C;e[10]===Symbol.for("react.memo_cache_sentinel")?(C=()=>c(nb),e[10]=C):C=e[10];let M=i?"rotate-180":"rotate-0",N;e[11]===M?N=e[12]:(N=T("h-4 w-4 text-muted-foreground transition-transform duration-200 shrink-0",M),e[11]=M,e[12]=N);let _;e[13]===N?_=e[14]:(_=(0,s.jsx)(el,{className:N}),e[13]=N,e[14]=_);let y=v||"Error",R;e[15]===y?R=e[16]:(R=(0,s.jsxs)("span",{className:"text-destructive",children:[y,":"]}),e[15]=y,e[16]=R);let A;e[17]!==j||e[18]!==R?(A=(0,s.jsxs)("div",{className:"text-sm inline font-mono",children:[R," ",j]}),e[17]=j,e[18]=R,e[19]=A):A=e[19];let I;e[20]!==A||e[21]!==_?(I=(0,s.jsxs)("div",{className:"flex gap-2 h-10 px-2 hover:bg-muted rounded-sm select-none items-center cursor-pointer transition-all",onClick:C,children:[_,A]}),e[20]=A,e[21]=_,e[22]=I):I=e[22];let V;e[23]===o?V=e[24]:(V=(0,s.jsx)(bv,{className:"text-muted-foreground px-4 pt-2 text-xs overflow-auto",children:o}),e[23]=o,e[24]=V);let E;e[25]!==I||e[26]!==V?(E=(0,s.jsxs)(yv,{value:Du,className:"border-none",children:[I,V]}),e[25]=I,e[26]=V,e[27]=E):E=e[27];let D;e[28]!==E||e[29]!==k?(D=(0,s.jsx)(xv,{type:"single",collapsible:!0,value:k,children:E}),e[28]=E,e[29]=k,e[30]=D):D=e[30];let G;e[31]!==w||e[32]!==S?(G=S&&(0,s.jsx)(wS,{tooltip:"Fix with AI",openPrompt:()=>w(!1),applyAutofix:()=>w(!0)}),e[31]=w,e[32]=S,e[33]=G):G=e[33];let K;e[34]!==f||e[35]!==m?(K=f&&(0,s.jsx)(Ce,{content:"Attach pdb to the exception point.",children:(0,s.jsxs)(ce,{size:"xs",variant:"outline",onClick:()=>{md().sendPdb({cellId:m.cellId})},children:[(0,s.jsx)(hl,{className:"h-3 w-3 mr-2"}),"Launch debugger"]})}),e[34]=f,e[35]=m,e[36]=K):K=e[36];let se;e[37]!==u||e[38]!==r?(se=h&&(0,s.jsxs)(Zr,{children:[(0,s.jsx)(Xr,{asChild:!0,children:(0,s.jsxs)(ce,{size:"xs",variant:"text",children:["Get help",(0,s.jsx)(el,{className:"h-3 w-3 ml-1"})]})}),(0,s.jsxs)(Yr,{align:"end",className:"w-56",children:[(0,s.jsx)(ee,{asChild:!0,children:(0,s.jsxs)("a",{target:"_blank",href:`https://www.google.com/search?q=${encodeURIComponent(u)}`,rel:"noreferrer",children:[(0,s.jsx)(yd,{className:"h-4 w-4 mr-2"}),"Search on Google",(0,s.jsx)(fd,{className:"h-3 w-3 ml-auto"})]})}),(0,s.jsx)(ee,{asChild:!0,children:(0,s.jsxs)("a",{target:"_blank",href:"https://marimo.io/discord?ref=notebook",rel:"noopener",children:[(0,s.jsx)(SS,{className:"h-4 w-4 mr-2"}),"Ask in Discord",(0,s.jsx)(fd,{className:"h-3 w-3 ml-auto"})]})}),(0,s.jsxs)(ee,{onClick:()=>{let de=document.createElement("div");de.innerHTML=nd(r),on(de.textContent||"")},children:[(0,s.jsx)(rl,{className:"h-4 w-4 mr-2"}),"Copy to clipboard"]})]})]}),e[37]=u,e[38]=r,e[39]=se):se=e[39];let q;e[40]!==G||e[41]!==K||e[42]!==se?(q=(0,s.jsxs)("div",{className:"flex gap-2",children:[G,K,se]}),e[40]=G,e[41]=K,e[42]=se,e[43]=q):q=e[43];let Y;return e[44]!==D||e[45]!==q?(Y=(0,s.jsxs)("div",{className:"flex flex-col gap-2 min-w-full w-fit",children:[D,q]}),e[44]=D,e[45]=q,e[46]=Y):Y=e[46],Y};function Qx(t){var n,r;let e=document.createElement("div");return e.innerHTML=nd(t),((r=(n=e.textContent)==null?void 0:n.split(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Ge=Object.defineProperty;var Ve=(t,e,s)=>e in t?Ge(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var z=(t,e,s)=>Ve(t,typeof e!="symbol"?e+"":e,s);import{s as oe}from"./chunk-LvLJmgfZ.js";import{t as Ze}from"./react-Bj1aDYRI.js";import{E as Qe,Ot as ce,Wn as g}from"./cells-_QgKZKXb.js";import{D as M,P as y,R as u,T as D,_ as ae,i as Je,k as _,m as Ye}from"./zod-H_cgTO0M.js";import{t as B}from"./compiler-runtime-B3qBwwSJ.js";import{v as Xe}from"./useEventListener-BR0C1MaI.js";import{t as G}from"./cn-DCUzRj2J.js";import{t as et}from"./jsx-runtime-BqBOg78p.js";import{a as tt,c as ie,o as le,s as st}from"./popover-UExmgBsf.js";import{c as rt,i as nt,n as ot,r as ct,s as at,t as it}from"./select-5i7URBEn.js";import{a as J,c as de,o as lt,p as dt,r as pt,t as ht}from"./dropdown-menu-D1A3cFC8.js";import{m as mt,o as ut,t as bt,u as a}from"./form-B5Zfx4cn.js";import{t as Y}from"./button-D9nb17Rw.js";import{l as ft}from"./arrays-DYDL-3-i.js";import{r as U}from"./strings-md4mFbOQ.js";import{t as gt}from"./createLucideIcon-D5guW7EU.js";import{t as yt}from"./circle-plus-BdiiIXu5.js";import{t as _t}from"./database-zap-kIkTfzTX.js";import{t as St}from"./github-BKS_2Qwn.js";import{n as wt}from"./DeferredRequestRegistry-Bobqy1XF.js";import{o as xt,r as kt}from"./input-gOeJx-hY.js";import{a as vt,c as $t,d as jt,g as At,l as Ct,o as Rt,p as Tt,s as Lt,u as Dt}from"./textarea-DLywVJ2b.js";import{r as It}from"./useTheme-DhrO1NvC.js";import{a as Pt,c as qt,l as Nt,n as Ft,r as Et,t as Bt}from"./dialog-BEgS5oXa.js";import{n as Ot}from"./ImperativeModal-QWJWbLVR.js";import{t as V}from"./links-D-VMsA11.js";import{n as Mt}from"./useAsyncData-BRNkjHs1.js";import{o as Ut}from"./focus-Ci7q4lAK.js";import{n as Kt,t as Wt}from"./azure-DZ9IQ5nj.js";import{t as Ht}from"./request-registry-BoWteoOD.js";import{n as zt,t as Gt}from"./write-secret-modal-Chu5xifR.js";var X=gt("hard-drive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]),ee="env:";function Ir(t){return t}function K(t){return typeof t=="string"?t.startsWith(ee):!1}function te(t){return`${ee}${t}`}function pe(t){return t.replace(ee,"")}var Vt=B(),N=oe(Ze(),1),o=oe(et(),1),he=(0,N.createContext)({providerNames:[],secretKeys:[],loading:!1,error:void 0,refreshSecrets:Xe.NOOP});const Zt=()=>(0,N.use)(he),Qt=t=>{let e=(0,Vt.c)(14),{children:s}=t,n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],e[0]=n):n=e[0];let{data:r,isPending:d,error:i,refetch:c}=Mt(ts,n),l;e[1]===(r==null?void 0:r.secretKeys)?l=e[2]:(l=(r==null?void 0:r.secretKeys)||[],e[1]=r==null?void 0:r.secretKeys,e[2]=l);let h;e[3]===(r==null?void 0:r.providerNames)?h=e[4]:(h=(r==null?void 0:r.providerNames)||[],e[3]=r==null?void 0:r.providerNames,e[4]=h);let p;e[5]!==i||e[6]!==d||e[7]!==c||e[8]!==l||e[9]!==h?(p={secretKeys:l,providerNames:h,loading:d,error:i,refreshSecrets:c},e[5]=i,e[6]=d,e[7]=c,e[8]=l,e[9]=h,e[10]=p):p=e[10];let f;return e[11]!==s||e[12]!==p?(f=(0,o.jsx)(he,{value:p,children:s}),e[11]=s,e[12]=p,e[13]=f):f=e[13],f},Jt={isMatch:t=>{if(t instanceof ae||t instanceof Ye){let{optionRegex:e}=a.parse(t.description||"");return!!e}return!1},Component:({schema:t,form:e,path:s})=>{let{secretKeys:n,providerNames:r,refreshSecrets:d}=Zt(),{openModal:i,closeModal:c}=Ot(),{label:l,description:h,optionRegex:p=""}=a.parse(t.description||""),[f,b]=ft(n,m=>new RegExp(p,"i").test(m));return(0,o.jsx)($t,{control:e.control,name:s,render:({field:m})=>(0,o.jsxs)(Ct,{children:[(0,o.jsx)(Dt,{children:l}),(0,o.jsx)(Rt,{children:h}),(0,o.jsx)(vt,{children:(0,o.jsxs)("div",{className:"flex gap-2",children:[t instanceof ae?(0,o.jsx)(kt,{...m,value:m.value,onChange:m.onChange,className:G("flex-1")}):(0,o.jsx)(xt,{...m,value:m.value,onChange:m.onChange,className:"flex-1"}),(0,o.jsxs)(ht,{children:[(0,o.jsx)(dt,{asChild:!0,children:(0,o.jsx)(Y,{variant:"outline",size:"icon",className:G(K(m.value)&&"bg-accent"),children:(0,o.jsx)(wt,{className:"h-3 w-3"})})}),(0,o.jsxs)(pt,{align:"end",className:"max-h-60 overflow-y-auto",children:[(0,o.jsxs)(J,{onSelect:()=>{i((0,o.jsx)(Gt,{providerNames:r,onSuccess:S=>{d(),m.onChange(te(S)),c()},onClose:c}))},children:[(0,o.jsx)(yt,{className:"mr-2 h-3.5 w-3.5"}),"Create a new secret"]}),f.length>0&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(de,{}),(0,o.jsx)(lt,{children:"Recommended"})]}),f.map(S=>(0,o.jsx)(J,{onSelect:()=>m.onChange(te(S)),children:S},S)),b.length>0&&(0,o.jsx)(de,{}),b.map(S=>(0,o.jsx)(J,{onSelect:()=>m.onChange(te(S)),children:S},S))]})]})]})}),(0,o.jsx)(jt,{})]})})}};function Yt(t){return t.provider!=="env"}function Xt(t){return t.name}function es(t){return t.keys}async function ts(){let t=await Ht.request({}),e=zt(t.secrets).filter(Yt).map(Xt);return{secretKeys:t.secrets.flatMap(es).toSorted(),providerNames:e}}var W=B(),ss=[Jt];const se=t=>{let e=(0,W.c)(2),{children:s}=t,n;return e[0]===s?n=e[1]:(n=(0,o.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:s}),e[0]=s,e[1]=n),n},re=t=>{let e=(0,W.c)(9),{name:s,color:n,icon:r,onSelect:d}=t,i;e[0]===n?i=e[1]:(i={backgroundColor:n},e[0]=n,e[1]=i);let c;e[2]===s?c=e[3]:(c=(0,o.jsx)("span",{className:"text-white font-medium text-lg",children:s}),e[2]=s,e[3]=c);let l;return e[4]!==r||e[5]!==d||e[6]!==i||e[7]!==c?(l=(0,o.jsxs)("button",{type:"button",className:"py-3 flex flex-col items-center justify-center gap-1 transition-all hover:scale-105 hover:brightness-110 rounded shadow-sm-solid hover:shadow-md-solid",style:i,onClick:d,children:[r,c]}),e[4]=r,e[5]=d,e[6]=i,e[7]=c,e[8]=l):l=e[8],l},rs=t=>{let e=(0,W.c)(25),{onBack:s,isValid:n,libraries:r,preferredLibrary:d,onLibraryChange:i,displayNames:c,libraryLabel:l}=t,h=l===void 0?"Preferred library":l,p;e[0]===s?p=e[1]:(p=(0,o.jsx)(Y,{type:"button",variant:"outline",onClick:s,children:"Back"}),e[0]=s,e[1]=p);let f=!n,b;e[2]===f?b=e[3]:(b=(0,o.jsx)(Y,{type:"submit",disabled:f,children:"Add"}),e[2]=f,e[3]=b);let m;e[4]!==p||e[5]!==b?(m=(0,o.jsxs)("div",{className:"flex gap-2",children:[p,b]}),e[4]=p,e[5]=b,e[6]=m):m=e[6];let S;e[7]===Symbol.for("react.memo_cache_sentinel")?(S=(0,o.jsx)(at,{children:(0,o.jsx)(rt,{placeholder:"Select a library"})}),e[7]=S):S=e[7];let w;e[8]===h?w=e[9]:(w=(0,o.jsxs)("div",{className:"flex flex-col gap-1 items-end",children:[S,(0,o.jsx)("span",{className:"text-xs text-muted-foreground",children:h})]}),e[8]=h,e[9]=w);let $;if(e[10]!==c||e[11]!==r){let j;e[13]===c?j=e[14]:(j=T=>(0,o.jsx)(nt,{value:T,children:c[T]??T},T),e[13]=c,e[14]=j),$=r.map(j),e[10]=c,e[11]=r,e[12]=$}else $=e[12];let x;e[15]===$?x=e[16]:(x=(0,o.jsx)(ot,{children:(0,o.jsx)(ct,{children:$})}),e[15]=$,e[16]=x);let v;e[17]!==i||e[18]!==d||e[19]!==w||e[20]!==x?(v=(0,o.jsx)("div",{children:(0,o.jsxs)(it,{value:d,onValueChange:i,children:[w,x]})}),e[17]=i,e[18]=d,e[19]=w,e[20]=x,e[21]=v):v=e[21];let A;return e[22]!==v||e[23]!==m?(A=(0,o.jsxs)("div",{className:"flex gap-2 justify-between",children:[m,v]}),e[22]=v,e[23]=m,e[24]=A):A=e[24],A};function ns(){let t=(0,W.c)(3),{createNewCell:e}=Qe(),s=Ut(),n;return t[0]!==e||t[1]!==s?(n=r=>{e({code:r,before:!1,cellId:s??"__end__",skipIfCodeExists:!0})},t[0]=e,t[1]=s,t[2]=n):n=t[2],n}const me=t=>{let e=(0,W.c)(30),{schema:s,libraries:n,preferredLibrary:r,displayNames:d,libraryLabel:i,generateCode:c,onSubmit:l,onBack:h}=t,p;e[0]===s?p=e[1]:(p=ut(s),e[0]=s,e[1]=p);let f=p,b;e[2]===s?b=e[3]:(b=Tt(s),e[2]=s,e[3]=b);let m;e[4]!==f||e[5]!==b?(m={defaultValues:f,resolver:b,reValidateMode:"onChange"},e[4]=f,e[5]=b,e[6]=m):m=e[6];let S=At(m),[w,$]=N.useState(r),x=ns(),v;e[7]!==c||e[8]!==x||e[9]!==l||e[10]!==w?(v=ze=>{x(c(ze,w)),l()},e[7]=c,e[8]=x,e[9]=l,e[10]=w,e[11]=v):v=e[11];let A=v,j;e[12]!==S||e[13]!==A?(j=S.handleSubmit(A),e[12]=S,e[13]=A,e[14]=j):j=e[14];let T;e[15]===Symbol.for("react.memo_cache_sentinel")?(T=(0,o.jsx)(Lt,{}),e[15]=T):T=e[15];let F;e[16]!==S||e[17]!==s?(F=(0,o.jsx)(Qt,{children:(0,o.jsx)(bt,{schema:s,form:S,renderers:ss,children:T})}),e[16]=S,e[17]=s,e[18]=F):F=e[18];let E;e[19]!==d||e[20]!==S.formState.isValid||e[21]!==n||e[22]!==i||e[23]!==h||e[24]!==w?(E=(0,o.jsx)(rs,{onBack:h,isValid:S.formState.isValid,libraries:n,preferredLibrary:w,onLibraryChange:$,displayNames:d,libraryLabel:i}),e[19]=d,e[20]=S.formState.isValid,e[21]=n,e[22]=i,e[23]=h,e[24]=w,e[25]=E):E=e[25];let H;return e[26]!==j||e[27]!==F||e[28]!==E?(H=(0,o.jsxs)("form",{onSubmit:j,className:"space-y-4",children:[F,E]}),e[26]=j,e[27]=F,e[28]=E,e[29]=H):H=e[29],H};function I(){return u().optional().describe(a.of({label:"Password",inputType:"password",placeholder:"password",optionRegex:".*password.*"}))}function Z(t,e){let s=u();return s=e?s.nonempty():s.optional(),s=s.describe(a.of({label:t||"Token",inputType:"password",placeholder:"token",optionRegex:".*token.*"})),s}function Q(){return u().optional().describe(a.of({label:"Warehouse Name",placeholder:"warehouse",optionRegex:".*warehouse.*"}))}function ne(t,e){let s=u();return s=e?s.nonempty():s.optional(),s.describe(a.of({label:t||"URI",optionRegex:".*uri.*"}))}function L(t){return u().nonempty().describe(a.of({label:t||"Host",placeholder:"localhost",optionRegex:".*host.*"}))}function C(){return u().describe(a.of({label:"Database",placeholder:"db name",optionRegex:".*database.*"}))}function os(){return u().describe(a.of({label:"Schema",placeholder:"schema name",optionRegex:".*schema.*"}))}function R(){return u().nonempty().describe(a.of({label:"Username",placeholder:"username",optionRegex:".*username.*"}))}function P(t){let e=Je().describe(a.of({label:"Port",inputType:"number",placeholder:t==null?void 0:t.toString()})).transform(Number).refine(s=>s>=0&&s<=65535,{message:"Port must be between 0 and 65535"});return t===void 0?e:e.default(t)}function ue(){return D().default(!1).describe(a.of({label:"Read Only"}))}const be=y({type:_("postgres"),host:L(),port:P(5432).optional(),database:C(),username:R(),password:I(),ssl:D().default(!1).describe(a.of({label:"Use SSL"}))}).describe(a.of({direction:"two-columns"})),fe=y({type:_("mysql"),host:L(),port:P(3306),database:C(),username:R(),password:I(),ssl:D().default(!1).describe(a.of({label:"Use SSL"}))}).describe(a.of({direction:"two-columns"})),ge=y({type:_("sqlite"),database:C().describe(a.of({label:"Database Path"}))}).describe(a.of({direction:"two-columns"})),ye=y({type:_("duckdb"),database:C().describe(a.of({label:"Database Path"})),read_only:ue()}).describe(a.of({direction:"two-columns"})),_e=y({type:_("motherduck"),database:C().default("my_db").describe(a.of({label:"Database Name"})),token:Z()}).describe(a.of({direction:"two-columns"})),Se=y({type:_("snowflake"),account:u().nonempty().describe(a.of({label:"Account",optionRegex:".*snowflake.*"})),warehouse:u().optional().describe(a.of({label:"Warehouse",optionRegex:".*snowflake.*"})),database:C(),schema:u().optional().describe(a.of({label:"Schema",optionRegex:".*snowflake.*"})),role:u().optional().describe(a.of({label:"Role"})),authType:M("type",[y({type:_("Password"),username:R(),password:I(),enable_mfa:D().default(!1).describe(a.of({label:"Enable MFA (Duo Push)"}))}),y({type:_("SSO (Browser)"),username:R()}),y({type:_("Key Pair"),username:R(),private_key_path:u().nonempty().describe(a.of({label:"Private Key Path",placeholder:"/path/to/rsa_key.p8"})),private_key_passphrase:u().optional().describe(a.of({label:"Private Key Passphrase",inputType:"password",optionRegex:".*passphrase.*"}))}),y({type:_("OAuth / PAT"),token:Z("Token",!0)})]).default({type:"Password",username:"username",enable_mfa:!1}).describe(a.of({special:"tabs"}))}).describe(a.of({direction:"two-columns"})),we=y({type:_("bigquery"),project:u().nonempty().describe(a.of({label:"Project ID",optionRegex:".*bigquery.*"})),dataset:u().nonempty().describe(a.of({label:"Dataset",optionRegex:".*bigquery.*"})),credentials_json:u().describe(a.of({label:"Credentials JSON",inputType:"textarea"}))}).describe(a.of({direction:"two-columns"})),xe=y({type:_("clickhouse_connect"),host:L(),port:P(8123).optional(),username:R(),password:I(),secure:D().default(!1).describe(a.of({label:"Use HTTPs"})),proxy_path:u().optional().describe(a.of({label:"Proxy Path",placeholder:"/clickhouse"}))}).describe(a.of({direction:"two-columns"})),ke=y({type:_("timeplus"),host:L().default("localhost"),port:P(8123).optional(),username:R().default("default"),password:I().default("")}).describe(a.of({direction:"two-columns"})),ve=y({type:_("chdb"),database:C().describe(a.of({label:"Database Path"})),read_only:ue()}).describe(a.of({direction:"two-columns"})),$e=y({type:_("trino"),host:L(),port:P(8080),database:C(),schema:os().optional(),username:R(),password:I(),async_support:D().default(!1).describe(a.of({label:"Async Support"}))}).describe(a.of({direction:"two-columns"})),je=y({type:_("iceberg"),name:u().describe(a.of({label:"Catalog Name"})),catalog:M("type",[y({type:_("REST"),warehouse:Q(),uri:u().optional().describe(a.of({label:"URI",placeholder:"https://",optionRegex:".*uri.*"})),token:Z()}),y({type:_("SQL"),warehouse:Q(),uri:u().optional().describe(a.of({label:"URI",placeholder:"jdbc:iceberg://host:port/database",optionRegex:".*uri.*"}))}),y({type:_("Hive"),warehouse:Q(),uri:ne()}),y({type:_("Glue"),warehouse:Q(),uri:ne()}),y({type:_("DynamoDB"),"dynamodb.profile-name":u().optional().describe(a.of({label:"Profile Name"})),"dynamodb.region":u().optional().describe(a.of({label:"Region"})),"dynamodb.access-key-id":u().optional().describe(a.of({label:"Access Key ID"})),"dynamodb.secret-access-key":u().optional().describe(a.of({label:"Secret Access Key",inputType:"password"})),"dynamodb.session-token":u().optional().describe(a.of({label:"Session Token",inputType:"password"}))})]).default({type:"REST",token:void 0}).describe(a.of({special:"tabs"}))}),Ae=y({type:_("datafusion"),sessionContext:D().optional().describe(a.of({label:"Use Session Context"}))}),Ce=y({type:_("pyspark"),host:L().optional(),port:P().optional()}),Re=y({type:_("redshift"),host:L(),port:P(5439),connectionType:M("type",[y({type:_("IAM credentials"),region:u().describe(a.of({label:"Region"})),aws_access_key_id:u().nonempty().describe(a.of({label:"AWS Access Key ID",inputType:"password",optionRegex:".*aws_access_key_id.*"})),aws_secret_access_key:u().nonempty().describe(a.of({label:"AWS Secret Access Key",inputType:"password",optionRegex:".*aws_secret_access_key.*"})),aws_session_token:u().optional().describe(a.of({label:"AWS Session Token",inputType:"password",optionRegex:".*aws_session_token.*"}))}),y({type:_("DB credentials"),user:R(),password:I()})]).default({type:"IAM credentials",aws_access_key_id:"",aws_secret_access_key:"",region:""}),database:C()}).describe(a.of({direction:"two-columns"})),Te=y({type:_("databricks"),access_token:Z("Access Token",!0),server_hostname:L("Server Hostname"),http_path:ne("HTTP Path",!0),catalog:u().optional().describe(a.of({label:"Catalog"})),schema:u().optional().describe(a.of({label:"Schema"}))}).describe(a.of({direction:"two-columns"})),Le=y({type:_("supabase"),host:L(),port:P(5432).optional(),database:C(),username:R(),password:I(),disable_client_pooling:D().default(!1).describe(a.of({label:"Disable Client-Side Pooling"}))}).describe(a.of({direction:"two-columns"})),cs=M("type",[be,fe,ge,ye,_e,Se,we,xe,ke,ve,$e,je,Ae,Ce,Re,Te,Le]),De={sqlmodel:"SQLModel",sqlalchemy:"SQLAlchemy",duckdb:"DuckDB",clickhouse_connect:"ClickHouse Connect",chdb:"chDB",pyiceberg:"PyIceberg",ibis:"Ibis",motherduck:"MotherDuck",redshift:"Redshift",databricks:"Databricks"};var k=class{constructor(t,e,s){this.connection=t,this.orm=e,this.secrets=s}get imports(){let t=new Set(this.generateImports());switch(this.orm){case"sqlalchemy":t.add("import sqlalchemy");break;case"sqlmodel":t.add("import sqlmodel");break;case"duckdb":t.add("import duckdb");break;case"ibis":t.add("import ibis");break}return t}},as=t=>`_${t}`,is=class{constructor(){z(this,"secrets",{})}get imports(){return Object.keys(this.secrets).length===0?new Set:new Set(["import os"])}print(t,e,s){if(t=as(t),K(e)){let n=pe(e),r=s?`os.environ.get("${n}", "${s}")`:`os.environ.get("${n}")`;return this.secrets[t]=r,t}if(s!=null){let n=`os.environ.get("${e}", "${s}")`;return this.secrets[t]=n,t}return typeof e=="number"||typeof e=="number"?`${e}`:typeof e=="boolean"?O(e):e?`"${e}"`:""}printInFString(t,e,s){if(e===void 0)return"";if(typeof e=="number")return`${e}`;if(typeof e=="boolean")return O(e);let n=this.print(t,e,s);return n.startsWith('"')&&n.endsWith('"')?n.slice(1,-1):`{${n}}`}printPassword(t,e,s,n){let r=s?this.printInFString.bind(this):this.print.bind(this);return K(t)?r(n||"password",t):r(n||"password",e,t)}getSecrets(){return this.secrets}formatSecrets(){return Object.keys(this.secrets).length===0?"":Object.entries(this.secrets).map(([t,e])=>`${t} = ${e}`).join(`
|
|
1
|
+
var Ge=Object.defineProperty;var Ve=(t,e,s)=>e in t?Ge(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var z=(t,e,s)=>Ve(t,typeof e!="symbol"?e+"":e,s);import{s as oe}from"./chunk-LvLJmgfZ.js";import{t as Ze}from"./react-Bj1aDYRI.js";import{E as Qe,Ot as ce,Wn as g}from"./cells-_QgKZKXb.js";import{D as M,P as y,R as u,T as D,_ as ae,i as Je,k as _,m as Ye}from"./zod-H_cgTO0M.js";import{t as B}from"./compiler-runtime-B3qBwwSJ.js";import{v as Xe}from"./useEventListener-BR0C1MaI.js";import{t as G}from"./cn-DCUzRj2J.js";import{t as et}from"./jsx-runtime-BqBOg78p.js";import{a as tt,c as ie,o as le,s as st}from"./popover-UExmgBsf.js";import{c as rt,i as nt,n as ot,r as ct,s as at,t as it}from"./select-5i7URBEn.js";import{a as J,c as de,o as lt,p as dt,r as pt,t as ht}from"./dropdown-menu-D1A3cFC8.js";import{m as mt,o as ut,t as bt,u as a}from"./form-BON4sAdY.js";import{t as Y}from"./button-D9nb17Rw.js";import{l as ft}from"./arrays-DYDL-3-i.js";import{r as U}from"./strings-md4mFbOQ.js";import{t as gt}from"./createLucideIcon-D5guW7EU.js";import{t as yt}from"./circle-plus-BdiiIXu5.js";import{t as _t}from"./database-zap-kIkTfzTX.js";import{t as St}from"./github-BKS_2Qwn.js";import{n as wt}from"./DeferredRequestRegistry-Bobqy1XF.js";import{o as xt,r as kt}from"./input-gOeJx-hY.js";import{a as vt,c as $t,d as jt,g as At,l as Ct,o as Rt,p as Tt,s as Lt,u as Dt}from"./textarea-DLywVJ2b.js";import{r as It}from"./useTheme-DhrO1NvC.js";import{a as Pt,c as qt,l as Nt,n as Ft,r as Et,t as Bt}from"./dialog-BEgS5oXa.js";import{n as Ot}from"./ImperativeModal-QWJWbLVR.js";import{t as V}from"./links-D-VMsA11.js";import{n as Mt}from"./useAsyncData-BRNkjHs1.js";import{o as Ut}from"./focus-Ci7q4lAK.js";import{n as Kt,t as Wt}from"./azure-DZ9IQ5nj.js";import{t as Ht}from"./request-registry-BoWteoOD.js";import{n as zt,t as Gt}from"./write-secret-modal-Chu5xifR.js";var X=gt("hard-drive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]),ee="env:";function Ir(t){return t}function K(t){return typeof t=="string"?t.startsWith(ee):!1}function te(t){return`${ee}${t}`}function pe(t){return t.replace(ee,"")}var Vt=B(),N=oe(Ze(),1),o=oe(et(),1),he=(0,N.createContext)({providerNames:[],secretKeys:[],loading:!1,error:void 0,refreshSecrets:Xe.NOOP});const Zt=()=>(0,N.use)(he),Qt=t=>{let e=(0,Vt.c)(14),{children:s}=t,n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],e[0]=n):n=e[0];let{data:r,isPending:d,error:i,refetch:c}=Mt(ts,n),l;e[1]===(r==null?void 0:r.secretKeys)?l=e[2]:(l=(r==null?void 0:r.secretKeys)||[],e[1]=r==null?void 0:r.secretKeys,e[2]=l);let h;e[3]===(r==null?void 0:r.providerNames)?h=e[4]:(h=(r==null?void 0:r.providerNames)||[],e[3]=r==null?void 0:r.providerNames,e[4]=h);let p;e[5]!==i||e[6]!==d||e[7]!==c||e[8]!==l||e[9]!==h?(p={secretKeys:l,providerNames:h,loading:d,error:i,refreshSecrets:c},e[5]=i,e[6]=d,e[7]=c,e[8]=l,e[9]=h,e[10]=p):p=e[10];let f;return e[11]!==s||e[12]!==p?(f=(0,o.jsx)(he,{value:p,children:s}),e[11]=s,e[12]=p,e[13]=f):f=e[13],f},Jt={isMatch:t=>{if(t instanceof ae||t instanceof Ye){let{optionRegex:e}=a.parse(t.description||"");return!!e}return!1},Component:({schema:t,form:e,path:s})=>{let{secretKeys:n,providerNames:r,refreshSecrets:d}=Zt(),{openModal:i,closeModal:c}=Ot(),{label:l,description:h,optionRegex:p=""}=a.parse(t.description||""),[f,b]=ft(n,m=>new RegExp(p,"i").test(m));return(0,o.jsx)($t,{control:e.control,name:s,render:({field:m})=>(0,o.jsxs)(Ct,{children:[(0,o.jsx)(Dt,{children:l}),(0,o.jsx)(Rt,{children:h}),(0,o.jsx)(vt,{children:(0,o.jsxs)("div",{className:"flex gap-2",children:[t instanceof ae?(0,o.jsx)(kt,{...m,value:m.value,onChange:m.onChange,className:G("flex-1")}):(0,o.jsx)(xt,{...m,value:m.value,onChange:m.onChange,className:"flex-1"}),(0,o.jsxs)(ht,{children:[(0,o.jsx)(dt,{asChild:!0,children:(0,o.jsx)(Y,{variant:"outline",size:"icon",className:G(K(m.value)&&"bg-accent"),children:(0,o.jsx)(wt,{className:"h-3 w-3"})})}),(0,o.jsxs)(pt,{align:"end",className:"max-h-60 overflow-y-auto",children:[(0,o.jsxs)(J,{onSelect:()=>{i((0,o.jsx)(Gt,{providerNames:r,onSuccess:S=>{d(),m.onChange(te(S)),c()},onClose:c}))},children:[(0,o.jsx)(yt,{className:"mr-2 h-3.5 w-3.5"}),"Create a new secret"]}),f.length>0&&(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(de,{}),(0,o.jsx)(lt,{children:"Recommended"})]}),f.map(S=>(0,o.jsx)(J,{onSelect:()=>m.onChange(te(S)),children:S},S)),b.length>0&&(0,o.jsx)(de,{}),b.map(S=>(0,o.jsx)(J,{onSelect:()=>m.onChange(te(S)),children:S},S))]})]})]})}),(0,o.jsx)(jt,{})]})})}};function Yt(t){return t.provider!=="env"}function Xt(t){return t.name}function es(t){return t.keys}async function ts(){let t=await Ht.request({}),e=zt(t.secrets).filter(Yt).map(Xt);return{secretKeys:t.secrets.flatMap(es).toSorted(),providerNames:e}}var W=B(),ss=[Jt];const se=t=>{let e=(0,W.c)(2),{children:s}=t,n;return e[0]===s?n=e[1]:(n=(0,o.jsx)("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:s}),e[0]=s,e[1]=n),n},re=t=>{let e=(0,W.c)(9),{name:s,color:n,icon:r,onSelect:d}=t,i;e[0]===n?i=e[1]:(i={backgroundColor:n},e[0]=n,e[1]=i);let c;e[2]===s?c=e[3]:(c=(0,o.jsx)("span",{className:"text-white font-medium text-lg",children:s}),e[2]=s,e[3]=c);let l;return e[4]!==r||e[5]!==d||e[6]!==i||e[7]!==c?(l=(0,o.jsxs)("button",{type:"button",className:"py-3 flex flex-col items-center justify-center gap-1 transition-all hover:scale-105 hover:brightness-110 rounded shadow-sm-solid hover:shadow-md-solid",style:i,onClick:d,children:[r,c]}),e[4]=r,e[5]=d,e[6]=i,e[7]=c,e[8]=l):l=e[8],l},rs=t=>{let e=(0,W.c)(25),{onBack:s,isValid:n,libraries:r,preferredLibrary:d,onLibraryChange:i,displayNames:c,libraryLabel:l}=t,h=l===void 0?"Preferred library":l,p;e[0]===s?p=e[1]:(p=(0,o.jsx)(Y,{type:"button",variant:"outline",onClick:s,children:"Back"}),e[0]=s,e[1]=p);let f=!n,b;e[2]===f?b=e[3]:(b=(0,o.jsx)(Y,{type:"submit",disabled:f,children:"Add"}),e[2]=f,e[3]=b);let m;e[4]!==p||e[5]!==b?(m=(0,o.jsxs)("div",{className:"flex gap-2",children:[p,b]}),e[4]=p,e[5]=b,e[6]=m):m=e[6];let S;e[7]===Symbol.for("react.memo_cache_sentinel")?(S=(0,o.jsx)(at,{children:(0,o.jsx)(rt,{placeholder:"Select a library"})}),e[7]=S):S=e[7];let w;e[8]===h?w=e[9]:(w=(0,o.jsxs)("div",{className:"flex flex-col gap-1 items-end",children:[S,(0,o.jsx)("span",{className:"text-xs text-muted-foreground",children:h})]}),e[8]=h,e[9]=w);let $;if(e[10]!==c||e[11]!==r){let j;e[13]===c?j=e[14]:(j=T=>(0,o.jsx)(nt,{value:T,children:c[T]??T},T),e[13]=c,e[14]=j),$=r.map(j),e[10]=c,e[11]=r,e[12]=$}else $=e[12];let x;e[15]===$?x=e[16]:(x=(0,o.jsx)(ot,{children:(0,o.jsx)(ct,{children:$})}),e[15]=$,e[16]=x);let v;e[17]!==i||e[18]!==d||e[19]!==w||e[20]!==x?(v=(0,o.jsx)("div",{children:(0,o.jsxs)(it,{value:d,onValueChange:i,children:[w,x]})}),e[17]=i,e[18]=d,e[19]=w,e[20]=x,e[21]=v):v=e[21];let A;return e[22]!==v||e[23]!==m?(A=(0,o.jsxs)("div",{className:"flex gap-2 justify-between",children:[m,v]}),e[22]=v,e[23]=m,e[24]=A):A=e[24],A};function ns(){let t=(0,W.c)(3),{createNewCell:e}=Qe(),s=Ut(),n;return t[0]!==e||t[1]!==s?(n=r=>{e({code:r,before:!1,cellId:s??"__end__",skipIfCodeExists:!0})},t[0]=e,t[1]=s,t[2]=n):n=t[2],n}const me=t=>{let e=(0,W.c)(30),{schema:s,libraries:n,preferredLibrary:r,displayNames:d,libraryLabel:i,generateCode:c,onSubmit:l,onBack:h}=t,p;e[0]===s?p=e[1]:(p=ut(s),e[0]=s,e[1]=p);let f=p,b;e[2]===s?b=e[3]:(b=Tt(s),e[2]=s,e[3]=b);let m;e[4]!==f||e[5]!==b?(m={defaultValues:f,resolver:b,reValidateMode:"onChange"},e[4]=f,e[5]=b,e[6]=m):m=e[6];let S=At(m),[w,$]=N.useState(r),x=ns(),v;e[7]!==c||e[8]!==x||e[9]!==l||e[10]!==w?(v=ze=>{x(c(ze,w)),l()},e[7]=c,e[8]=x,e[9]=l,e[10]=w,e[11]=v):v=e[11];let A=v,j;e[12]!==S||e[13]!==A?(j=S.handleSubmit(A),e[12]=S,e[13]=A,e[14]=j):j=e[14];let T;e[15]===Symbol.for("react.memo_cache_sentinel")?(T=(0,o.jsx)(Lt,{}),e[15]=T):T=e[15];let F;e[16]!==S||e[17]!==s?(F=(0,o.jsx)(Qt,{children:(0,o.jsx)(bt,{schema:s,form:S,renderers:ss,children:T})}),e[16]=S,e[17]=s,e[18]=F):F=e[18];let E;e[19]!==d||e[20]!==S.formState.isValid||e[21]!==n||e[22]!==i||e[23]!==h||e[24]!==w?(E=(0,o.jsx)(rs,{onBack:h,isValid:S.formState.isValid,libraries:n,preferredLibrary:w,onLibraryChange:$,displayNames:d,libraryLabel:i}),e[19]=d,e[20]=S.formState.isValid,e[21]=n,e[22]=i,e[23]=h,e[24]=w,e[25]=E):E=e[25];let H;return e[26]!==j||e[27]!==F||e[28]!==E?(H=(0,o.jsxs)("form",{onSubmit:j,className:"space-y-4",children:[F,E]}),e[26]=j,e[27]=F,e[28]=E,e[29]=H):H=e[29],H};function I(){return u().optional().describe(a.of({label:"Password",inputType:"password",placeholder:"password",optionRegex:".*password.*"}))}function Z(t,e){let s=u();return s=e?s.nonempty():s.optional(),s=s.describe(a.of({label:t||"Token",inputType:"password",placeholder:"token",optionRegex:".*token.*"})),s}function Q(){return u().optional().describe(a.of({label:"Warehouse Name",placeholder:"warehouse",optionRegex:".*warehouse.*"}))}function ne(t,e){let s=u();return s=e?s.nonempty():s.optional(),s.describe(a.of({label:t||"URI",optionRegex:".*uri.*"}))}function L(t){return u().nonempty().describe(a.of({label:t||"Host",placeholder:"localhost",optionRegex:".*host.*"}))}function C(){return u().describe(a.of({label:"Database",placeholder:"db name",optionRegex:".*database.*"}))}function os(){return u().describe(a.of({label:"Schema",placeholder:"schema name",optionRegex:".*schema.*"}))}function R(){return u().nonempty().describe(a.of({label:"Username",placeholder:"username",optionRegex:".*username.*"}))}function P(t){let e=Je().describe(a.of({label:"Port",inputType:"number",placeholder:t==null?void 0:t.toString()})).transform(Number).refine(s=>s>=0&&s<=65535,{message:"Port must be between 0 and 65535"});return t===void 0?e:e.default(t)}function ue(){return D().default(!1).describe(a.of({label:"Read Only"}))}const be=y({type:_("postgres"),host:L(),port:P(5432).optional(),database:C(),username:R(),password:I(),ssl:D().default(!1).describe(a.of({label:"Use SSL"}))}).describe(a.of({direction:"two-columns"})),fe=y({type:_("mysql"),host:L(),port:P(3306),database:C(),username:R(),password:I(),ssl:D().default(!1).describe(a.of({label:"Use SSL"}))}).describe(a.of({direction:"two-columns"})),ge=y({type:_("sqlite"),database:C().describe(a.of({label:"Database Path"}))}).describe(a.of({direction:"two-columns"})),ye=y({type:_("duckdb"),database:C().describe(a.of({label:"Database Path"})),read_only:ue()}).describe(a.of({direction:"two-columns"})),_e=y({type:_("motherduck"),database:C().default("my_db").describe(a.of({label:"Database Name"})),token:Z()}).describe(a.of({direction:"two-columns"})),Se=y({type:_("snowflake"),account:u().nonempty().describe(a.of({label:"Account",optionRegex:".*snowflake.*"})),warehouse:u().optional().describe(a.of({label:"Warehouse",optionRegex:".*snowflake.*"})),database:C(),schema:u().optional().describe(a.of({label:"Schema",optionRegex:".*snowflake.*"})),role:u().optional().describe(a.of({label:"Role"})),authType:M("type",[y({type:_("Password"),username:R(),password:I(),enable_mfa:D().default(!1).describe(a.of({label:"Enable MFA (Duo Push)"}))}),y({type:_("SSO (Browser)"),username:R()}),y({type:_("Key Pair"),username:R(),private_key_path:u().nonempty().describe(a.of({label:"Private Key Path",placeholder:"/path/to/rsa_key.p8"})),private_key_passphrase:u().optional().describe(a.of({label:"Private Key Passphrase",inputType:"password",optionRegex:".*passphrase.*"}))}),y({type:_("OAuth / PAT"),token:Z("Token",!0)})]).default({type:"Password",username:"username",enable_mfa:!1}).describe(a.of({special:"tabs"}))}).describe(a.of({direction:"two-columns"})),we=y({type:_("bigquery"),project:u().nonempty().describe(a.of({label:"Project ID",optionRegex:".*bigquery.*"})),dataset:u().nonempty().describe(a.of({label:"Dataset",optionRegex:".*bigquery.*"})),credentials_json:u().describe(a.of({label:"Credentials JSON",inputType:"textarea"}))}).describe(a.of({direction:"two-columns"})),xe=y({type:_("clickhouse_connect"),host:L(),port:P(8123).optional(),username:R(),password:I(),secure:D().default(!1).describe(a.of({label:"Use HTTPs"})),proxy_path:u().optional().describe(a.of({label:"Proxy Path",placeholder:"/clickhouse"}))}).describe(a.of({direction:"two-columns"})),ke=y({type:_("timeplus"),host:L().default("localhost"),port:P(8123).optional(),username:R().default("default"),password:I().default("")}).describe(a.of({direction:"two-columns"})),ve=y({type:_("chdb"),database:C().describe(a.of({label:"Database Path"})),read_only:ue()}).describe(a.of({direction:"two-columns"})),$e=y({type:_("trino"),host:L(),port:P(8080),database:C(),schema:os().optional(),username:R(),password:I(),async_support:D().default(!1).describe(a.of({label:"Async Support"}))}).describe(a.of({direction:"two-columns"})),je=y({type:_("iceberg"),name:u().describe(a.of({label:"Catalog Name"})),catalog:M("type",[y({type:_("REST"),warehouse:Q(),uri:u().optional().describe(a.of({label:"URI",placeholder:"https://",optionRegex:".*uri.*"})),token:Z()}),y({type:_("SQL"),warehouse:Q(),uri:u().optional().describe(a.of({label:"URI",placeholder:"jdbc:iceberg://host:port/database",optionRegex:".*uri.*"}))}),y({type:_("Hive"),warehouse:Q(),uri:ne()}),y({type:_("Glue"),warehouse:Q(),uri:ne()}),y({type:_("DynamoDB"),"dynamodb.profile-name":u().optional().describe(a.of({label:"Profile Name"})),"dynamodb.region":u().optional().describe(a.of({label:"Region"})),"dynamodb.access-key-id":u().optional().describe(a.of({label:"Access Key ID"})),"dynamodb.secret-access-key":u().optional().describe(a.of({label:"Secret Access Key",inputType:"password"})),"dynamodb.session-token":u().optional().describe(a.of({label:"Session Token",inputType:"password"}))})]).default({type:"REST",token:void 0}).describe(a.of({special:"tabs"}))}),Ae=y({type:_("datafusion"),sessionContext:D().optional().describe(a.of({label:"Use Session Context"}))}),Ce=y({type:_("pyspark"),host:L().optional(),port:P().optional()}),Re=y({type:_("redshift"),host:L(),port:P(5439),connectionType:M("type",[y({type:_("IAM credentials"),region:u().describe(a.of({label:"Region"})),aws_access_key_id:u().nonempty().describe(a.of({label:"AWS Access Key ID",inputType:"password",optionRegex:".*aws_access_key_id.*"})),aws_secret_access_key:u().nonempty().describe(a.of({label:"AWS Secret Access Key",inputType:"password",optionRegex:".*aws_secret_access_key.*"})),aws_session_token:u().optional().describe(a.of({label:"AWS Session Token",inputType:"password",optionRegex:".*aws_session_token.*"}))}),y({type:_("DB credentials"),user:R(),password:I()})]).default({type:"IAM credentials",aws_access_key_id:"",aws_secret_access_key:"",region:""}),database:C()}).describe(a.of({direction:"two-columns"})),Te=y({type:_("databricks"),access_token:Z("Access Token",!0),server_hostname:L("Server Hostname"),http_path:ne("HTTP Path",!0),catalog:u().optional().describe(a.of({label:"Catalog"})),schema:u().optional().describe(a.of({label:"Schema"}))}).describe(a.of({direction:"two-columns"})),Le=y({type:_("supabase"),host:L(),port:P(5432).optional(),database:C(),username:R(),password:I(),disable_client_pooling:D().default(!1).describe(a.of({label:"Disable Client-Side Pooling"}))}).describe(a.of({direction:"two-columns"})),cs=M("type",[be,fe,ge,ye,_e,Se,we,xe,ke,ve,$e,je,Ae,Ce,Re,Te,Le]),De={sqlmodel:"SQLModel",sqlalchemy:"SQLAlchemy",duckdb:"DuckDB",clickhouse_connect:"ClickHouse Connect",chdb:"chDB",pyiceberg:"PyIceberg",ibis:"Ibis",motherduck:"MotherDuck",redshift:"Redshift",databricks:"Databricks"};var k=class{constructor(t,e,s){this.connection=t,this.orm=e,this.secrets=s}get imports(){let t=new Set(this.generateImports());switch(this.orm){case"sqlalchemy":t.add("import sqlalchemy");break;case"sqlmodel":t.add("import sqlmodel");break;case"duckdb":t.add("import duckdb");break;case"ibis":t.add("import ibis");break}return t}},as=t=>`_${t}`,is=class{constructor(){z(this,"secrets",{})}get imports(){return Object.keys(this.secrets).length===0?new Set:new Set(["import os"])}print(t,e,s){if(t=as(t),K(e)){let n=pe(e),r=s?`os.environ.get("${n}", "${s}")`:`os.environ.get("${n}")`;return this.secrets[t]=r,t}if(s!=null){let n=`os.environ.get("${e}", "${s}")`;return this.secrets[t]=n,t}return typeof e=="number"||typeof e=="number"?`${e}`:typeof e=="boolean"?O(e):e?`"${e}"`:""}printInFString(t,e,s){if(e===void 0)return"";if(typeof e=="number")return`${e}`;if(typeof e=="boolean")return O(e);let n=this.print(t,e,s);return n.startsWith('"')&&n.endsWith('"')?n.slice(1,-1):`{${n}}`}printPassword(t,e,s,n){let r=s?this.printInFString.bind(this):this.print.bind(this);return K(t)?r(n||"password",t):r(n||"password",e,t)}getSecrets(){return this.secrets}formatSecrets(){return Object.keys(this.secrets).length===0?"":Object.entries(this.secrets).map(([t,e])=>`${t} = ${e}`).join(`
|
|
2
2
|
`)}},ls=class extends k{generateImports(){return[]}generateConnectionCode(){let t=this.connection.ssl?", connect_args={'sslmode': 'require'}":"",e=this.secrets.printPassword(this.connection.password,"POSTGRES_PASSWORD",!0);return g(`
|
|
3
3
|
DATABASE_URL = f"postgresql://${this.secrets.printInFString("username",this.connection.username)}:${e}@${this.secrets.printInFString("host",this.connection.host)}:${this.secrets.printInFString("port",this.connection.port)}/${this.secrets.printInFString("database",this.connection.database)}"
|
|
4
4
|
engine = ${this.orm}.create_engine(DATABASE_URL${t})
|