@deephaven/embed-grid 0.21.1 → 0.21.2-beta.0

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.
@@ -27,6 +27,6 @@ ${t}`):s.setValue(`${t}`);const o=s.getLineCount(),r=s.getLineLength(o)+1;this.e
27
27
  `&&(n+=`
28
28
  `))}}if(n=n.trimRight(),this.editor.setValue(n),t){const i=(s=this.editor.getModel())==null?void 0:s.getLineCount();O(i),this.editor.revealLine(i,1)}this.stopFlushTimer(),this.bufferedMessages=[]}truncateLogIfNecessary(){this.messages.length>st.maxLogSize&&(this.messages=this.messages.splice(this.messages.length-st.truncateSize))}scrollToBottom(){var t,n,s;if(!this.editor)return;const e=(s=(n=(t=this.editor)==null?void 0:t.getModel)==null?void 0:n.call(t))==null?void 0:s.getLineCount();O(e),this.editor.revealLine(e,1)}isBottomVisible(){if(!this.editor)return!0;const e=this.editor.getModel(),t=e==null?void 0:e.getLineCount();return O(t),this.isLineVisible(t)}isLineVisible(e){var n;const t=(n=this.editor)==null?void 0:n.getVisibleRanges();if(t==null||t.length===0)return!1;for(let s=0;s<t.length;s+=1){const i=t[s];if(i.startLineNumber<=e&&e<=i.endLineNumber)return!0}return!1}isLogItemVisible(e){const{shownLogLevels:t}=this.state;return t[e.logLevel]}flush(){let e="";for(let t=0;t<this.bufferedMessages.length;t+=1){const n=this.bufferedMessages[t],s=st.getLogText(n);e+=s,s.charAt(s.length-1)!==`
29
29
  `&&(e+=`
30
- `)}this.bufferedMessages=[],this.appendLogText(e)}queue(e){this.bufferedMessages.push(e),this.bufferedMessages.length===1&&(this.flushTimer=setTimeout(this.handleFlushTimeout,st.bufferTimeout))}stopFlushTimer(){this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=void 0)}updateDimensions(){this.editor&&this.editor.layout()}handleClearClick(){this.clearLogs()}clearLogs(){this.messages=[],this.refreshLogText()}handleFlushTimeout(){this.stopFlushTimer(),this.flush()}handleLogMessage(e){this.messages.push(e),this.editor&&this.isLogItemVisible(e)&&this.queue(e)}handleMenuItemClick(e){this.toggleLogLevel(e)}handleResetClick(){this.resetLogLevels()}handleResize(){this.updateDimensions()}handleToggleAllClick(){this.toggleAll()}render(){const e={placement:"bottom-end"},{shownLogLevels:t}=this.state,n=this.getMenuActions(t);return T("div",{className:"log-pane h-100 w-100",children:[T("div",{className:"log-pane-menu",children:[h(me,{kind:"ghost",className:"btn-clear-logs",onClick:this.handleClearClick,icon:Wd,tooltip:"Clear log"}),h(me,{kind:"ghost",className:"btn-link-icon btn-overflow",icon:hd,tooltip:"Log Settings",onClick:()=>{},children:h(Ln,{actions:n,popperClassName:"log-level-menu-popper",popperOptions:e})})]}),h("div",{className:"log-pane-editor h-100 w-100",ref:s=>{this.editorContainer=s}})]})}};let oi=st;oi.DefaultLogLevels=[Ye.STDOUT,Ye.ERROR,Ye.FATAL,Ye.STDERR,Ye.WARN];oi.AllLogLevels=[Ye.INFO,Ye.STDOUT,Ye.ERROR,Ye.FATAL,Ye.STDERR,Ye.WARN,Ye.DEBUG,Ye.TRACE];oi.bufferTimeout=16;oi.maxLogSize=131072;oi.truncateSize=65536;_i.register([gc,fc,Cc,bc,wc,Sc]);const rg=typeof vo=="function"?vo(_i):vo.default(_i),hn=class{constructor(){this.listeners=[],this.isDownsamplingDisabled=!1}getData(){return[]}getDefaultTitle(){return""}getLayout(){return{}}getFilterColumnMap(){return new Map}isFilterRequired(){return!1}setFilter(e){}close(){}setFormatter(e){this.formatter=e}setDownsamplingDisabled(e){this.isDownsamplingDisabled=e}setDimensions(e){this.rect=e}setTitle(e){this.title=e}subscribe(e){this.listeners.push(e)}unsubscribe(e){this.listeners=this.listeners.filter(t=>t!==e)}fireEvent(e){for(let t=0;t<this.listeners.length;t+=1)this.listeners[t](e)}fireUpdate(e){this.fireEvent(new CustomEvent(hn.EVENT_UPDATED,{detail:e}))}fireDisconnect(){this.fireEvent(new CustomEvent(hn.EVENT_DISCONNECT))}fireReconnect(){this.fireEvent(new CustomEvent(hn.EVENT_RECONNECT))}fireDownsampleStart(e){this.fireEvent(new CustomEvent(hn.EVENT_DOWNSAMPLESTARTED,{detail:e}))}fireDownsampleFinish(e){this.fireEvent(new CustomEvent(hn.EVENT_DOWNSAMPLEFINISHED,{detail:e}))}fireDownsampleFail(e){this.fireEvent(new CustomEvent(hn.EVENT_DOWNSAMPLEFAILED,{detail:e}))}fireDownsampleNeeded(e){this.fireEvent(new CustomEvent(hn.EVENT_DOWNSAMPLENEEDED,{detail:e}))}fireLoadFinished(){this.fireEvent(new CustomEvent(hn.EVENT_LOADFINISHED))}};let Qe=hn;Qe.EVENT_UPDATED="ChartModel.EVENT_UPDATED";Qe.EVENT_DISCONNECT="ChartModel.EVENT_DISCONNECT";Qe.EVENT_RECONNECT="ChartModel.EVENT_RECONNECT";Qe.EVENT_DOWNSAMPLESTARTED="ChartModel.EVENT_DOWNSAMPLESTARTED";Qe.EVENT_DOWNSAMPLEFINISHED="ChartModel.EVENT_DOWNSAMPLEFINISHED";Qe.EVENT_DOWNSAMPLEFAILED="ChartModel.EVENT_DOWNSAMPLEFAILED";Qe.EVENT_DOWNSAMPLENEEDED="ChartModel.EVENT_DOWNSAMPLENEEDED";Qe.EVENT_LOADFINISHED="ChartModel.EVENT_LOADFINISHED";const lg="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",ag="#403e41",cg="#5b5a5c",dg="#c0bfbf",ug="#4878ea",hg="rgba(91, 90, 92, 0.7)",Je={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:lg,gridcolor:ag,linecolor:cg,zerolinecolor:dg,activecolor:ug,rangebgcolor:hg,"area-color":"#76d9e4","trend-color":"#d5f0c1","line-color":"#9edc6f","error-band-line-color":"white","error-band-fill-color":"rgba(213, 240, 193, 0.1)","ohlc-increasing":"#9edc6f","ohlc-decreasing":"#f95d84"},Fn=Object.freeze({paper_bgcolor:Je["paper-bgcolor"],plot_bgcolor:Je["plot-bgcolor"],title_color:Je["title-color"],colorway:Je.colorway,gridcolor:Je.gridcolor,linecolor:Je.linecolor,zerolinecolor:Je.zerolinecolor,activecolor:Je.activecolor,rangebgcolor:Je.rangebgcolor,area_color:Je["area-color"],trend_color:Je["trend-color"],line_color:Je["line-color"],error_band_line_color:Je["error-band-line-color"],error_band_fill_color:Je["error-band-fill-color"],ohlc_increasing:Je["ohlc-increasing"],ohlc_decreasing:Je["ohlc-decreasing"]}),Ai=J.module("ChartUtils"),yn=Object.freeze(E.calendar.DayOfWeek.values()),Dl="io.deephaven.time.DateTime",mg=36e5,pg=1e6;function gg(e){return e.asDate!==void 0}function fg(e){return e.asNumber!==void 0}function Nl(e){return e.dhTimeZone!==void 0}function Cg(e){return e!=null&&e.range&&(e.autorange===!1||e.autorange===void 0)}const Y=class{static getPlotlyChartType(e,t){switch(e){case E.plot.SeriesPlotStyle.SCATTER:return t?"scatter":"scattergl";case E.plot.SeriesPlotStyle.LINE:return"scatter";case E.plot.SeriesPlotStyle.BAR:case E.plot.SeriesPlotStyle.STACKED_BAR:return"bar";case E.plot.SeriesPlotStyle.PIE:return"pie";case E.plot.SeriesPlotStyle.TREEMAP:return"treemap";case E.plot.SeriesPlotStyle.HISTOGRAM:return"histogram";case E.plot.SeriesPlotStyle.OHLC:return"ohlc";default:return}}static getPlotlyChartMode(e){switch(e){case E.plot.SeriesPlotStyle.SCATTER:return"markers";case E.plot.SeriesPlotStyle.LINE:return"lines";default:return}}static getPlotlyProperty(e,t){switch(e){case E.plot.SeriesPlotStyle.PIE:switch(t){case E.plot.SourceType.X:return"labels";case E.plot.SourceType.Y:return"values"}break;case E.plot.SeriesPlotStyle.OHLC:switch(t){case E.plot.SourceType.TIME:return"x"}break;case E.plot.SeriesPlotStyle.TREEMAP:switch(t){case E.plot.SourceType.X:return"ids";case E.plot.SourceType.Y:return"values";case E.plot.SourceType.LABEL:return"labels";case E.plot.SourceType.PARENT:return"parents";case E.plot.SourceType.COLOR:return"marker.colors"}break}switch(t){case E.plot.SourceType.X:return"x";case E.plot.SourceType.Y:return"y";case E.plot.SourceType.Z:return"z";case E.plot.SourceType.X_LOW:return"xLow";case E.plot.SourceType.X_HIGH:return"xHigh";case E.plot.SourceType.Y_LOW:return"yLow";case E.plot.SourceType.Y_HIGH:return"yHigh";case E.plot.SourceType.TIME:return"time";case E.plot.SourceType.OPEN:return"open";case E.plot.SourceType.HIGH:return"high";case E.plot.SourceType.LOW:return"low";case E.plot.SourceType.CLOSE:return"close";case E.plot.SourceType.SHAPE:return"shape";case E.plot.SourceType.SIZE:return"size";case E.plot.SourceType.LABEL:return"label";case E.plot.SourceType.COLOR:return"color";case E.plot.SourceType.PARENT:return"parent";case E.plot.SourceType.HOVER_TEXT:return"hovertext";case E.plot.SourceType.TEXT:return"text";default:throw new Error(`Unrecognized source type: ${t}`)}}static getPlotlySeriesOrientation(e){var n,s;const{sources:t}=e;return t.length===2&&((s=(n=t[0])==null?void 0:n.axis)==null?void 0:s.type)===E.plot.AxisType.Y?Y.ORIENTATION.HORIZONTAL:Y.ORIENTATION.VERTICAL}static getPlotlyErrorBars(e,t,n){const s=n.map((o,r)=>o-e[r]),i=t.map((o,r)=>e[r]-o);return{type:"data",symmetric:!1,array:s,arrayminus:i}}static getPlotlyDateFormat(e,t,n){const s=n==null?void 0:n.replace("%","%%").replace(/S{9}/g,"%9f").replace(/S{8}/g,"%8f").replace(/S{7}/g,"%7f").replace(/S{6}/g,"%6f").replace(/S{5}/g,"%5f").replace(/S{4}/g,"%4f").replace(/S{3}/g,"%3f").replace(/S{2}/g,"%2f").replace(/S{1}/g,"%1f").replace(/y{4}/g,"%Y").replace(/y{2}/g,"%y").replace(/M{4}/g,"%B").replace(/M{3}/g,"%b").replace(/M{2}/g,"%m").replace(/M{1}/g,"%-m").replace(/E{4,}/g,"%A").replace(/E{1,}/g,"%a").replace(/d{2}/g,"%d").replace(/([^%]|^)d{1}/g,"$1%-d").replace(/H{2}/g,"%H").replace(/h{2}/g,"%I").replace(/h{1}/g,"%-I").replace(/m{2}/g,"%M").replace(/s{2}/g,"%S").replace("'T'","T").replace(" z","");let i;const o=e==null?void 0:e.getColumnTypeFormatter(t);return o!=null&&Nl(o)&&o.dhTimeZone!=null&&o.showTimeZone&&(i=E.i18n.DateTimeFormat.format(" z",new Date,o.dhTimeZone)),{tickformat:s,ticksuffix:i,automargin:!0}}static convertNumberPrefix(e){return e.replace(/\u00A4\u00A4/g,"USD").replace(/\u00A4/g,"$")}static getPlotlyNumberFormat(e,t,n){if(!n)return null;const i=n.split(";")[0].match(/^([^#,0.]*)([#,]*)([0,]*)(\.?)(0*)(#*)(E?0*)(%?)(.*)/);O(i);const[,o,r,l,,a,c,d,u,m]=i,p=l.replace(",","").length,f=r.indexOf(",")>=0||l.indexOf(",")>=0?",":"",C=d!=null&&d!==""?"e":"f",b=u!==""?u:C,w=a.length+c.length,I=`0${p}${f}.${w}${b}`,v=Y.convertNumberPrefix(o),R=Y.convertNumberPrefix(m);return{tickformat:I,tickprefix:v,ticksuffix:R,automargin:!0}}static getPlotlyAxisFormat(e,t=null){const{axis:n,columnType:s}=e,{formatPattern:i}=n;let o=null;return x.isDateType(s)?(o=Y.getPlotlyDateFormat(t,s,i),o=Y.addTickSpacing(o,n,!0)):x.isNumberType(s)&&(o=Y.getPlotlyNumberFormat(t,s,i),o=Y.addTickSpacing(o,n,!1)),n.formatType===E.plot.AxisFormatType.CATEGORY&&(o?o.type="category":o={type:"category",tickformat:void 0,ticksuffix:void 0}),o}static addTickSpacing(e,t,n){const{gapBetweenMajorTicks:s}=t;if(s>0){const i=e||{};let o=s;return n&&(o=s/pg),t.log&&(o=Math.log(o)),i.tickmode="linear",i.dtick=o,i}return e}static getSourceForAxis(e,t){for(let n=0;n<e.series.length;n+=1){const s=e.series[n];for(let i=0;i<s.sources.length;i+=1){const o=s.sources[i];if(o.axis===t)return o}}return null}static getSeriesVisibility(e,t){return t!=null&&t.hiddenSeries!=null&&t.hiddenSeries.includes(e)?"legendonly":!0}static getHiddenLabels(e){return e!=null&&e.hiddenSeries?[...e.hiddenSeries]:[]}static makeSeriesData(e,t,n,s=Y.ORIENTATION.VERTICAL){return{type:e,mode:t,name:n,orientation:s}}static makeSeriesDataFromSeries(e,t,n,s=Fn){const{name:i,plotStyle:o,lineColor:r,shapeColor:l,sources:a}=e,c=a.some(g=>{var f;return(f=g.axis)==null?void 0:f.businessCalendar}),d=Y.getChartType(o,c),u=Y.getPlotlyChartMode(o),m=Y.getPlotlySeriesOrientation(e),p=Y.makeSeriesData(d,u,i,m);return Y.addSourcesToSeriesData(p,o,a,t),Y.addStylingToSeriesData(p,o,s,r,l,n),p}static addSourcesToSeriesData(e,t,n,s){const i=e;for(let o=0;o<n.length;o+=1){const r=n[o],{axis:l,type:a}=r,c=Y.getPlotlyProperty(t,a);Ol(i,c,[]);const d=l!=null?Y.getAxisPropertyName(l.type):null;if(d!=null){const u=s.get(l.type);if(u){const m=u.indexOf(l),p=m>0?`${m+1}`:"";i[`${d}axis`]=`${d}${p}`}}}}static addStylingToSeriesData(e,t,n=Fn,s=null,i=null,o=null){const r=e;r.marker={line:{}},r.line={width:1},t===E.plot.SeriesPlotStyle.AREA?r.fill="tozeroy":t===E.plot.SeriesPlotStyle.STACKED_AREA?r.stackgroup="stack":t===E.plot.SeriesPlotStyle.STEP?r.line.shape="hv":t===E.plot.SeriesPlotStyle.HISTOGRAM?(r.width=[],r.marker.line!==void 0&&Object.assign(r.marker.line,{color:n.paper_bgcolor,width:1})):t===E.plot.SeriesPlotStyle.OHLC?(r.increasing={line:{color:n.ohlc_increasing}},r.decreasing={line:{color:n.ohlc_decreasing}}):t===E.plot.SeriesPlotStyle.PIE?(r.textinfo="label+percent",r.outsidetextfont={color:n.title_color}):t===E.plot.SeriesPlotStyle.TREEMAP&&(r.hoverinfo="text",r.textinfo="label+text",r.tiling={packing:"squarify",pad:0},r.textposition="middle center",r.outsidetextfont={color:n.title_color}),s!=null&&(t===E.plot.SeriesPlotStyle.BAR?r.marker.color=s:r.line.color=s),i!=null&&(r.marker.color=i),o!=null&&t!==E.plot.SeriesPlotStyle.PIE&&(r.visible=o)}static getAxisFormats(e,t){const n=new Map,s={tickformat:null,ticksuffix:null},i=Y.getAllAxes(e),o=Y.groupArray(i,"type"),{charts:r}=e;for(let l=0;l<r.length;l+=1){const a=r[l];for(let c=0;c<a.series.length;c+=1){const d=a.series[c],{sources:u}=d,m=u.filter(p=>p.axis);for(let p=0;p<m.length;p+=1){const g=m[p],{axis:f}=g,{type:C}=f,b=o.get(C);O(b);const w=b.indexOf(f),S=Y.getAxisPropertyName(C);if(S!=null){const I=Y.getAxisLayoutProperty(S,w);if(n.has(I))Ai.debug(`${I} already added.`);else{Ai.debug(`Adding ${I} to axisFormats.`);const v=Y.getPlotlyAxisFormat(g,t);if(v===null)n.set(I,s);else{n.set(I,v);const{businessCalendar:R}=f;if(R!=null){const M=[],{businessPeriods:F,businessDays:P,holidays:W,timeZone:B}=R,N=t==null?void 0:t.getColumnTypeFormatter(Dl);let H;Nl(N)&&(H=N.dhTimeZone);const A=H?(B.standardOffset-H.standardOffset)/60:0;W.length>0&&M.push(...Y.createRangeBreakValuesFromHolidays(W,B,H)),F.forEach(L=>M.push({pattern:"hour",bounds:[Y.periodToDecimal(L.close)+A,Y.periodToDecimal(L.open)+A]})),P.length<yn.length&&Y.createBoundsFromDays(P).forEach(L=>M.push({pattern:"day of week",bounds:L})),v.rangebreaks=M}if(n.size===a.axes.length)return n}}}}}}return n}static getChartType(e,t){switch(e){case E.plot.SeriesPlotStyle.HISTOGRAM:return"bar";default:return Y.getPlotlyChartType(e,t)}}static getAxisPropertyName(e){switch(e){case E.plot.AxisType.X:return"x";case E.plot.AxisType.Y:return"y";default:return null}}static getAxisSide(e){switch(e){case E.plot.AxisPosition.BOTTOM:return"bottom";case E.plot.AxisPosition.TOP:return"top";case E.plot.AxisPosition.LEFT:return"left";case E.plot.AxisPosition.RIGHT:return"right";default:return}}static getAllAxes(e){return e.charts.reduce((t,n)=>[...t,...n.axes],[])}static getChartForSeries(e,t){const{charts:n}=e;for(let s=0;s<n.length;s+=1){const i=n[s];for(let o=0;o<i.series.length;o+=1)if(t===i.series[o])return i}return null}static getLayoutRanges(e){const t={},n=Object.keys(e).filter(s=>s.indexOf("axis")>=0);for(let s=0;s<n.length;s+=1){const i=n[s],o=e[i];Cg(o)&&(t[i]=[...o.range])}return t}static updateFigureAxes(e,t,n,s=0,i=0,o=Fn){const r=e,l=Y.getAllAxes(t);for(let a=0;a<t.charts.length;a+=1){const c=t.charts[a],d=n==null?void 0:n(c),u=Y.getChartBounds(t,c,s,i);Y.updateLayoutAxes(r,c.axes,l,s,i,u,d,o)}Y.removeStaleAxes(r,l)}static getChartBounds(e,t,n=0,s=0){var S;const{cols:i,rows:o}=e,{column:r,colspan:l,row:a,rowspan:c}=t,d=r+l,u=a+c,m=1/i,p=1/o,g=Y.AXIS_SIZE_PX/n,f=Y.AXIS_SIZE_PX/s,C={left:r*m+(r>0?g/2:0),bottom:a*p+(a>0?f/2:0),top:u*p-(u<o?f/2:0),right:d*m-(d<i?g/2:0)};return((S=Y.groupArray(t.axes,"position").get(E.plot.AxisPosition.RIGHT))!=null?S:[]).length>0&&(n>0?C.right-=(C.right-C.left)*Math.max(0,Math.min(Y.LEGEND_WIDTH_PX/n,Y.MAX_LEGEND_SIZE)):C.right-=(C.right-C.left)*Y.DEFAULT_AXIS_SIZE),C}static updateLayoutAxes(e,t,n,s=0,i=0,o={left:0,top:0,right:1,bottom:1},r,l=Fn){const a=s>0?Math.max(Y.MIN_AXIS_SIZE,Math.min(Y.AXIS_SIZE_PX/i,Y.MAX_AXIS_SIZE)):Y.DEFAULT_AXIS_SIZE,c=i>0?Math.max(Y.MIN_AXIS_SIZE,Math.min(Y.AXIS_SIZE_PX/s,Y.MAX_AXIS_SIZE)):Y.DEFAULT_AXIS_SIZE,d=e,u=Y.groupArray(t,"position"),m=Y.groupArray(t,"type"),p=[...m.keys()],g=Y.groupArray(n,"type");for(let f=0;f<p.length;f+=1){const C=p[f],b=Y.getAxisPropertyName(C);if(b!=null){const w=m.get(C),S=g.get(C),v=C===E.plot.AxisType.Y?i:s;O(w),O(S);for(let R=0;R<w.length;R+=1){const M=w[R],F=S.indexOf(M),P=Y.getAxisLayoutProperty(b,F);d[P]==null&&(d[P]=Y.makeLayoutAxis(C,l));const W=d[P];if(W!=null){Y.updateLayoutAxis(W,M,R,u,a,c,o);const{range:B,autorange:N}=W;if(r!=null&&B!==void 0&&(N===void 0||N===!1)){const H=r(M),[A,L]=H(B);Ai.debug("Setting downsample range",v,A,L),M.range(v,A,L)}else M.range(v)}}}}}static removeStaleAxes(e,t){const n=e,s=Y.groupArray(t,"type"),i=[...s.keys()];for(let o=0;o<i.length;o+=1){const r=i[o],l=s.get(r);O(l);let a=l.length;const c=Y.getAxisPropertyName(r);if(c!=null){let d=Y.getAxisLayoutProperty(c,a);for(;n[d]!=null;)delete n[d],a+=1,d=Y.getAxisLayoutProperty(c,a)}}}static getAxisLayoutProperty(e,t){const n=t>0?`${t+1}`:"";return`${e!=null?e:""}axis${n}`}static updateLayoutAxis(e,t,n,s,i,o,r){var u,m,p;const a=t.type===E.plot.AxisType.Y?o:i,c=e,d=(u=t.label)!=null?u:"";if(c.title!==void 0&&typeof c.title!="string"?c.title.text=d:c.title={text:d},t.log&&(c.type="log"),c.side=Y.getAxisSide(t.position),n>0){c.overlaying=(m=Y.getAxisPropertyName(t.type))!=null?m:void 0;const g=(p=s.get(t.position))!=null?p:[],f=g.indexOf(t);f>0&&(c.anchor="free",t.position===E.plot.AxisPosition.RIGHT?c.position=r.right+(f-g.length+1)*a:t.position===E.plot.AxisPosition.TOP?c.position=r.top+(f-g.length+1)*a:t.position===E.plot.AxisPosition.BOTTOM?c.position=r.bottom+(g.length-f+1)*a:t.position===E.plot.AxisPosition.LEFT&&(c.position=r.left+(g.length-f+1)*a))}else if(t.type===E.plot.AxisType.X){const g=s.get(E.plot.AxisPosition.LEFT)||[],f=s.get(E.plot.AxisPosition.RIGHT)||[],C=Math.max(r.left,r.left+(g.length-1)*o),b=Math.min(r.right-(f.length-1)*o,r.right);c.domain=[C,b]}else if(t.type===E.plot.AxisType.Y){const g=s.get(E.plot.AxisPosition.BOTTOM)||[],f=s.get(E.plot.AxisPosition.TOP)||[],C=Math.max(r.bottom,r.bottom+(g.length-1)*i),b=Math.min(r.top-(f.length-1)*i,r.top);c.domain=[C,b]}}static periodToDecimal(e){const t=e.split(":");return Number(t[0])+Number(t[1])/60}static createBoundsFromDays(e){const t=e.map(o=>yn.indexOf(o)),n=yn.filter(o=>!e.includes(o)).map(o=>yn.indexOf(o)),s=new Set;n.forEach(o=>{for(let r=o+1;r<o+yn.length;r+=1){const l=r%yn.length;if(t.includes(l)){s.add(l);break}}});const i=[];return s.forEach(o=>{for(let r=o-1;r>o-yn.length;r-=1){const l=r<0?r+yn.length:r;if(t.includes(l)){const a=(l+1)%7;i.push([a,o]);break}}}),i}static createRangeBreakValuesFromHolidays(e,t,n){const s=[],i=[];return e.forEach(o=>{o.businessPeriods.length>0?i.push(...Y.createPartialHoliday(o,t,n)):s.push(Y.createFullHoliday(o,t,n))}),[{values:s},...i]}static createFullHoliday(e,t,n){return Y.adjustDateForTimeZone(`${e.date.toString()} 00:00:00.000000`,t,n)}static createPartialHoliday(e,t,n){const s=e.date.toString(),i=["00:00"];e.businessPeriods.forEach(r=>{i.push(r.open),i.push(r.close)}),i.push("24:00");const o=[];for(let r=0;r<i.length;r+=2){const l=i[r],a=i[r+1];if(l!==a){const c=[Y.adjustDateForTimeZone(`${s} ${l}:00.000000`,t,n)],d=mg*(Y.periodToDecimal(a)-Y.periodToDecimal(l));o.push({values:c,dvalue:d})}}return o}static adjustDateForTimeZone(e,t,n){return n&&n.standardOffset!==t.standardOffset?Y.unwrapValue(Y.wrapValue(e,Dl,t),n):e}static groupArray(e,t){return e.reduce((n,s)=>{var r;const i=s[t],o=(r=n.get(i))!=null?r:[];return o.push(s),n.set(i,o),n},new Map)}static unwrapValue(e,t){if(e!=null){if(gg(e))return E.i18n.DateTimeFormat.format(Y.DATE_FORMAT,e,t);if(fg(e))return e.asNumber()}return e}static wrapValue(e,t,n=null){if(x.isDateType(t)&&typeof e=="string"){const s=e,i=Y.DATE_FORMAT.substr(0,e.length),o=E.i18n.DateTimeFormat.parse(i,s);if(!n)return o;const r=`${i} Z`,l=E.i18n.DateTimeFormat.format("Z",o,n),a=E.i18n.DateTimeFormat.parse(r,`${s} ${l}`),c=E.i18n.DateTimeFormat.format("Z",a,n);return E.i18n.DateTimeFormat.parse(r,`${s} ${c}`)}return e}static makeLayoutAxis(e,t=Fn){const n={automargin:!0,gridcolor:t.gridcolor,linecolor:t.linecolor,rangeslider:{visible:!1},showline:!0,ticklen:5,tickcolor:t.paper_bgcolor,tickfont:{color:t.zerolinecolor},title:{font:{color:t.title_color}}};return e===E.plot.AxisType.X?Object.assign(n,{showgrid:!0}):e===E.plot.AxisType.Y&&Object.assign(n,{zerolinecolor:t.zerolinecolor,zerolinewidth:2}),n}static getColorwayFromTheme(e=Fn){let t=[];return e.colorway&&(Array.isArray(e.colorway)?t=e.colorway:typeof e.colorway=="string"?t=e.colorway.split(" "):Ai.warn(`Unable to handle colorway property: ${e.colorway}`)),t}static makeDefaultLayout(e=Fn){const t={...e,autosize:!0,colorway:Y.getColorwayFromTheme(e),font:{family:"'Fira Sans', sans-serif"},title:{font:{color:e.title_color},yanchor:"top",pad:{...Y.DEFAULT_TITLE_PADDING},y:1},legend:{font:{color:e.title_color}},margin:{...Y.DEFAULT_MARGIN},xaxis:Y.makeLayoutAxis(E.plot.AxisType.X,e),yaxis:Y.makeLayoutAxis(E.plot.AxisType.Y,e)};return t.datarevision=0,t}static hydrateSettings(e){return{...e,type:E.plot.SeriesPlotStyle[e.type]}}static titleFromSettings(e){const{series:t,xAxis:n,title:s=`${t.join(", ")} by ${n}`}=e;return s}static makeFigureSettings(e,t){const{series:n,xAxis:s,type:i}=e,o=Y.titleFromSettings(e),r={formatType:`${E.plot.AxisFormatType.NUMBER}`,type:`${E.plot.AxisType.X}`,position:`${E.plot.AxisPosition.BOTTOM}`},l={formatType:`${E.plot.AxisFormatType.NUMBER}`,type:`${E.plot.AxisType.Y}`,position:`${E.plot.AxisPosition.LEFT}`};return{charts:[{chartType:`${E.plot.ChartType.XY}`,axes:[r,l],series:n.map(a=>({plotStyle:`${i}`,name:a,dataSources:[{type:`${E.plot.SourceType.X}`,columnName:s,axis:r,table:t},{type:`${E.plot.SourceType.Y}`,columnName:a,axis:l,table:t}]}))}],title:o}}};let Ee=Y;Ee.DEFAULT_AXIS_SIZE=.15;Ee.MIN_AXIS_SIZE=.025;Ee.MAX_AXIS_SIZE=.2;Ee.AXIS_SIZE_PX=75;Ee.LEGEND_WIDTH_PX=50;Ee.MAX_LEGEND_SIZE=.25;Ee.ORIENTATION=Object.freeze({HORIZONTAL:"h",VERTICAL:"v"});Ee.DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSS";Ee.DEFAULT_MARGIN=Object.freeze({l:60,r:50,t:30,b:60,pad:0});Ee.DEFAULT_TITLE_PADDING=Object.freeze({t:8});Ee.SUBTITLE_LINE_HEIGHT=25;const Rn=J.module("Chart"),Qs=class extends y.exports.Component{constructor(e){super(e),this.getCachedConfig=Ie((t,n,s,i)=>{const o=[],r=Boolean(t);if(r&&o.push({name:`Downsampling failed: ${t}`,click:()=>{},icon:Qs.convertIcon(Xl),attr:"fill-warning"}),n||s||i||r){const l=Qs.downsampleButtonTitle(s,i),a=Qs.downsampleButtonAttr(s,i),c=s?zl:Ld;o.push({name:l,icon:Qs.convertIcon(c),click:this.handleDownsampleClick,attr:a})}return{displaylogo:!1,displayModeBar:s||r?!0:"hover",modeBarButtons:[o,["toImage"],["zoom2d","pan2d"],["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]]}}),this.handleAfterPlot=this.handleAfterPlot.bind(this),this.handleDownsampleClick=this.handleDownsampleClick.bind(this),this.handleModelEvent=this.handleModelEvent.bind(this),this.handlePlotUpdate=this.handlePlotUpdate.bind(this),this.handleRelayout=this.handleRelayout.bind(this),this.handleRestyle=this.handleRestyle.bind(this),this.plot=Q.createRef(),this.plotWrapper=Q.createRef(),this.columnFormats=[],this.dateTimeFormatterOptions={},this.decimalFormatOptions={},this.integerFormatOptions={},this.isSubscribed=!1,this.isLoadedFired=!1,this.currentSeries=0,this.state={data:null,downsamplingError:null,isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,layout:{datarevision:0},revision:0}}static convertIcon(e){const[t,,,,n]=e.icon,s=`${n}`;return{width:t,path:s,ascent:t,descent:0,transform:"matrix(1, 0, 0, 1, 0, 0)"}}static downsampleButtonTitle(e,t){return e?"Downsampling in progress...":t?"Downsampling disabled, click to enable":"Downsampling enabled, click to disable"}static downsampleButtonAttr(e,t){return e?"animation-spin":t?void 0:"fill-active"}componentDidMount(){this.updateDimensions(),this.updateModelDimensions(),this.initData(),this.initFormatter();const{isActive:e}=this.props;e&&this.subscribe()}componentDidUpdate(e){const{isActive:t,settings:n}=this.props;this.updateFormatterSettings(n),t!==e.isActive&&(t?this.subscribe():this.unsubscribe())}componentWillUnmount(){this.unsubscribe()}getPlotRect(){var e,t;return(t=(e=this.plotWrapper.current)==null?void 0:e.getBoundingClientRect())!=null?t:null}initData(){const{model:e}=this.props,{layout:t}=this.state;this.setState({data:e.getData(),layout:{...t,...e.getLayout()}})}subscribe(){if(this.isSubscribed)return;const{model:e}=this.props;if(!this.rect||this.rect.width===0||this.rect.height===0){Rn.debug2("Delaying subscription until model dimensions are set");return}e.subscribe(this.handleModelEvent),this.isSubscribed=!0}unsubscribe(){if(!this.isSubscribed)return;const{model:e}=this.props;e.unsubscribe(this.handleModelEvent),this.isSubscribed=!1}handleAfterPlot(){this.plot.current!=null}handleDownsampleClick(){this.setState(({isDownsamplingDisabled:e})=>({downsamplingError:null,isDownsampleInProgress:!1,isDownsampleFinished:!1,isDownsamplingDisabled:!e}),()=>{const{model:e}=this.props,{isDownsamplingDisabled:t}=this.state;e.setDownsamplingDisabled(t)})}handleModelEvent(e){var s;const{type:t,detail:n}=e;switch(Rn.debug2("Received data update",t,n),t){case Qe.EVENT_UPDATED:{this.currentSeries+=1,this.setState(o=>{const{layout:r,revision:l}=o;return typeof r.datarevision=="number"&&(r.datarevision+=1),{data:n,layout:r,revision:l+1}});const{onUpdate:i}=this.props;i({isLoading:!this.isLoadedFired});break}case Qe.EVENT_LOADFINISHED:{const{onUpdate:i}=this.props;this.isLoadedFired=!0,i({isLoading:!1});break}case Qe.EVENT_DISCONNECT:{const{onDisconnect:i}=this.props;i();break}case Qe.EVENT_RECONNECT:{const{onReconnect:i}=this.props;i();break}case Qe.EVENT_DOWNSAMPLESTARTED:{this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!0,downsamplingError:null});break}case Qe.EVENT_DOWNSAMPLEFINISHED:{this.setState({isDownsampleFinished:!0,isDownsampleInProgress:!1,downsamplingError:null});break}case Qe.EVENT_DOWNSAMPLENEEDED:case Qe.EVENT_DOWNSAMPLEFAILED:{const i=(s=n.message)!=null?s:n;this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,downsamplingError:i});const{onError:o}=this.props;o(new Error(i));break}default:Rn.debug("Unknown event type",t,e)}}handlePlotUpdate(e){const{layout:t}=e,n=Ee.getLayoutRanges(t);!ct(n,this.ranges)&&(this.ranges=n,this.updateModelDimensions(!0))}handleRelayout(e){if(Rn.debug("handleRelayout",e),e.hiddenlabels!=null){const{onSettingsChanged:t}=this.props,n=[...e.hiddenlabels];t({hiddenSeries:n})}this.updateModelDimensions()}handleRestyle([e,t]){if(Rn.debug("handleRestyle",e,t),Object.keys(e).includes("visible")){const{data:n}=this.state,{onSettingsChanged:s}=this.props;if(n!=null){const i=n.reduce((o,{name:r,visible:l})=>r!=null&&l==="legendonly"?[...o,r]:o,[]);s({hiddenSeries:i})}}}updateModelDimensions(e=!1){const t=this.getPlotRect();if(!t){Rn.warn("Unable to get plotting rect");return}if(!this.rect||this.rect.width!==t.width||this.rect.height!==t.height||e){this.rect=t;const{isActive:s,model:i}=this.props;i.setDimensions(t),s&&this.subscribe()}}initFormatter(){const{settings:e}=this.props;this.updateFormatterSettings(e)}updateFormatterSettings(e){const t=ls.getColumnFormats(e),n=ls.getDateTimeFormatterOptions(e),{decimalFormatOptions:s={},integerFormatOptions:i={}}=e;(!ct(this.columnFormats,t)||!ct(this.dateTimeFormatterOptions,n)||!ct(this.decimalFormatOptions,s)||!ct(this.integerFormatOptions,i))&&(this.columnFormats=ls.getColumnFormats(e),this.dateTimeFormatterOptions=n,this.decimalFormatOptions=s,this.integerFormatOptions=i,this.updateFormatter())}updateFormatter(){const e=new jt(this.columnFormats,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions),{model:t}=this.props;t.setFormatter(e)}updateDimensions(){const e=this.getPlotRect();this.plot.current!=null&&e!=null&&e.width>0&&e.height>0&&_i.relayout(this.plot.current.el,{autosize:!0}).catch(t=>{Rn.debug("Unable to resize, promise rejected",t)})}render(){const{data:e,downsamplingError:t,isDownsampleFinished:n,isDownsampleInProgress:s,isDownsamplingDisabled:i,layout:o,revision:r}=this.state,l=this.getCachedConfig(t,n,s,i),a=e!=null;return h("div",{className:"h-100 w-100 chart-wrapper",ref:this.plotWrapper,children:a&&h(rg,{ref:this.plot,data:e,layout:o,revision:r,config:l,onAfterPlot:this.handleAfterPlot,onError:Rn.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}};let bg=Qs;bg.defaultProps={isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:Hn.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}};const nt=J.module("FigureChartModel"),sc=class extends Qe{constructor(e,t={},n=Fn){super(),this.addPendingSeries=Tt(()=>{const i=Ee.getAllAxes(this.figure),{pendingSeries:o}=this;for(let r=0;r<o.length;r+=1){const l=o[r];this.addSeries(l,i),l.subscribe()}this.pendingSeries=[]},sc.ADD_SERIES_DEBOUNCE),this.getTimeZone=he((i,o)=>{if(o!=null){const r=o.getColumnTypeFormatter(i);if(r!=null)return r.dhTimeZone}return null}),this.getValueTranslator=he((i,o)=>{const r=this.getTimeZone(i,o);return l=>Ee.unwrapValue(l,r)}),this.getValueParser=he((i,o)=>{const r=this.getTimeZone(i,o);return l=>Ee.wrapValue(l,i,r)}),this.getRangeParser=he((i,o)=>r=>{let[l,a]=r;const c=this.getValueParser(i,o);return l=c(l),a=c(a),[l,a]}),this.getAxisRangeParser=he((i,o)=>r=>{const l=Ee.getSourceForAxis(i,r);return l?this.getRangeParser(l.columnType,o):a=>a}),this.handleFigureUpdated=this.handleFigureUpdated.bind(this),this.handleFigureDisconnected=this.handleFigureDisconnected.bind(this),this.handleFigureReconnected=this.handleFigureReconnected.bind(this),this.handleFigureSeriesAdded=this.handleFigureSeriesAdded.bind(this),this.handleDownsampleStart=this.handleDownsampleStart.bind(this),this.handleDownsampleFinish=this.handleDownsampleFinish.bind(this),this.handleDownsampleFail=this.handleDownsampleFail.bind(this),this.handleDownsampleNeeded=this.handleDownsampleNeeded.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.figure=e,this.settings=t,this.theme=n,this.data=[];const s={data:{},layout:Ee.makeDefaultLayout(n)};this.layout={grid:{rows:e.rows,columns:e.cols,pattern:"independent"},template:s},this.seriesDataMap=new Map,this.pendingSeries=[],this.oneClicks=[],this.filterColumnMap=new Map,this.lastFilter=new Map,this.isConnected=!0,this.seriesToProcess=new Set,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure()}close(){this.figure.close(),this.addPendingSeries.cancel(),this.stopListeningFigure()}getDefaultTitle(){return this.figure.charts.length>0?this.figure.charts[0].title:""}initAllSeries(){this.oneClicks=[],this.filterColumnMap.clear();const{charts:e}=this.figure,t=Ee.getAllAxes(this.figure),n=[];for(let o=0;o<e.length;o+=1){const r=e[o];for(let l=0;l<r.series.length;l+=1){const a=r.series[l];n.push(a.name),this.addSeries(a,t)}}const i=[...this.seriesDataMap.keys()].filter(o=>n.indexOf(o)<0);for(let o=0;o<i.length;o+=1){const r=i[o];this.seriesDataMap.delete(r)}this.seriesToProcess=new Set([...this.seriesDataMap.keys()])}addSeries(e,t){const n=Ee.groupArray(t,"type"),s=Ee.makeSeriesDataFromSeries(e,n,Ee.getSeriesVisibility(e.name,this.settings),this.theme);if(this.seriesDataMap.set(e.name,s),this.data=[...this.seriesDataMap.values()],e.plotStyle===E.plot.SeriesPlotStyle.STACKED_BAR?this.layout.barmode="stack":e.plotStyle===E.plot.SeriesPlotStyle.PIE&&(this.layout.hiddenlabels=Ee.getHiddenLabels(this.settings)),this.layout.showlegend=this.data.length>1||e.plotStyle===E.plot.SeriesPlotStyle.PIE,e.oneClick!=null){const{oneClick:i}=e,{columns:o}=i;for(let r=0;r<o.length;r+=1)this.filterColumnMap.set(o[r].name,o[r]);this.oneClicks.push(i)}this.updateLayoutFormats()}subscribe(e){super.subscribe(e),this.listeners.length===1&&(this.initAllSeries(),this.subscribeFigure())}unsubscribe(e){super.unsubscribe(e),this.listeners.length===0&&this.unsubscribeFigure()}subscribeFigure(){if(!this.isConnected){nt.debug("Ignoring subscribe when figure in disconnected state");return}this.figure.subscribe(this.isDownsamplingDisabled?E.plot.DownsampleOptions.DISABLE:E.plot.DownsampleOptions.DEFAULT)}unsubscribeFigure(){this.figure.unsubscribe()}startListeningFigure(){this.figure.addEventListener(E.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.addEventListener(E.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.addEventListener(E.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.addEventListener(E.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.addEventListener(E.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.addEventListener(E.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.addEventListener(E.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.addEventListener(E.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.addEventListener(E.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}stopListeningFigure(){this.figure.removeEventListener(E.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.removeEventListener(E.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.removeEventListener(E.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.removeEventListener(E.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.removeEventListener(E.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.removeEventListener(E.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.removeEventListener(E.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.removeEventListener(E.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.removeEventListener(E.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}handleDownsampleStart(e){nt.debug("Downsample started",e),this.fireDownsampleStart(e.detail)}handleDownsampleFinish(e){nt.debug("Downsample finished",e),this.fireDownsampleFinish(e.detail)}handleDownsampleFail(e){nt.error("Downsample failed",e),this.fireDownsampleFail(e.detail)}handleDownsampleNeeded(e){nt.info("Downsample needed",e),this.fireDownsampleNeeded(e.detail)}handleFigureUpdated(e){const{detail:t}=e,{series:n}=t;nt.debug2("handleFigureUpdated",n);for(let i=0;i<n.length;i+=1){const o=n[i];nt.debug2("handleFigureUpdated updating series",o.name);const{sources:r}=o;for(let l=0;l<r.length;l+=1){const a=r[l],{columnType:c,type:d}=a,u=this.getValueTranslator(c,this.formatter),m=t.getArray(o,d,u);this.setDataArrayForSeries(o,d,m)}this.seriesToProcess.delete(o.name),this.seriesToProcess.size===0&&this.fireLoadFinished(),this.cleanSeries(o)}const{data:s}=this;this.fireUpdate(s)}handleRequestFailed(e){nt.error("Request failed",e)}resubscribe(){this.listeners.length>0&&(this.unsubscribeFigure(),this.subscribeFigure())}setFormatter(e){super.setFormatter(e),this.updateLayoutFormats(),this.resubscribe()}setDownsamplingDisabled(e){super.setDownsamplingDisabled(e),this.resubscribe()}handleFigureDisconnected(e){nt.debug("Figure disconnected",e),this.isConnected=!1,this.listeners.length>0&&this.unsubscribeFigure(),this.fireDisconnect()}handleFigureReconnected(e){nt.debug("Figure reconnected",e),this.isConnected=!0,this.initAllSeries(),this.fireReconnect(),this.listeners.length>0&&this.subscribeFigure()}handleFigureSeriesAdded(e){const{detail:t}=e;nt.debug("handleFigureSeriesAdded",t),this.pendingSeries.push(t),this.addPendingSeries()}setDimensions(e){super.setDimensions(e),this.updateAxisPositions()}setTitle(e){var s,i;super.setTitle(e);const t=(i=(s=(e!=null?e:"").match(/<br>/g))==null?void 0:s.length)!=null?i:0,n=Ee.DEFAULT_MARGIN.t+t*Ee.SUBTITLE_LINE_HEIGHT;this.layout.margin?this.layout.margin.t=n:this.layout.margin={t:n},typeof this.layout.title=="string"?this.layout.title=e:(this.layout.title={...this.layout.title},this.layout.title.text=e,this.layout.title.pad={...this.layout.title.pad},this.layout.title.pad.t=Ee.DEFAULT_TITLE_PADDING.t+t*Ee.SUBTITLE_LINE_HEIGHT*.5)}getPlotWidth(){var e,t,n,s;return!this.rect||!this.rect.width?0:Math.max(this.rect.width-((t=(e=this.layout.margin)==null?void 0:e.l)!=null?t:0)-((s=(n=this.layout.margin)==null?void 0:n.r)!=null?s:0),0)}getPlotHeight(){var e,t,n,s;return!this.rect||!this.rect.height?0:Math.max(this.rect.height-((t=(e=this.layout.margin)==null?void 0:e.t)!=null?t:0)-((s=(n=this.layout.margin)==null?void 0:n.b)!=null?s:0),0)}updateAxisPositions(){const e=this.getPlotWidth(),t=this.getPlotHeight();Ee.updateFigureAxes(this.layout,this.figure,n=>this.getAxisRangeParser(n,this.formatter),e,t,this.theme)}updateLayoutFormats(){if(!this.formatter)return;Ee.getAxisFormats(this.figure,this.formatter).forEach((t,n)=>{nt.debug(`Assigning ${n}`,this.layout[n],t);const s=this.layout[n];s!=null?Object.assign(s,t):nt.debug(`Ignoring null layout.${n}`)})}setDataArrayForSeries(e,t,n){const{name:s,plotStyle:i}=e,o=this.seriesDataMap.get(s),r=Ee.getPlotlyProperty(i,t);o&&Ol(o,r,n)}cleanSeries(e){const{name:t,plotStyle:n}=e,s=this.seriesDataMap.get(t);if(s!=null){if(n===E.plot.SeriesPlotStyle.HISTOGRAM){const{xLow:i,xHigh:o}=s;if(i&&o&&i.length===o.length){const r=[];for(let l=0;l<i.length;l+=1)r.push(o[l]-i[l]);s.width=r}}else if(n===E.plot.SeriesPlotStyle.LINE){const{x:i,xLow:o,xHigh:r,y:l,yLow:a,yHigh:c}=s;o&&r&&o!==i&&(s.error_x=Ee.getPlotlyErrorBars(i,o,r)),a&&c&&a!==l&&(s.error_y=Ee.getPlotlyErrorBars(l,a,c))}else if(n===E.plot.SeriesPlotStyle.TREEMAP){const{ids:i,labels:o}=s;i!==void 0&&o===void 0&&(s.labels=i)}}}getData(){return this.data}getLayout(){return this.layout}getFilterColumnMap(){return new Map(this.filterColumnMap)}isFilterRequired(){return this.oneClicks.find(e=>e.requireAllFiltersToDisplay)!=null}setFilter(e){if(this.oneClicks.length===0){nt.warn("Trying to set a filter, but no one click!");return}nt.debug("setFilter",e);for(let t=0;t<this.oneClicks.length;t+=1){const n=this.oneClicks[t],{columns:s}=n;new Set([...e.keys(),...this.lastFilter.keys()]).forEach(o=>{const r=e.get(o);this.lastFilter.get(o)!==r&&s.find(l=>l.name===o)!=null&&n.setValueForColumn(o,r)})}this.lastFilter=new Map(e)}setFigure(e){this.close(),this.figure=e,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure(),this.listeners.length>0&&this.subscribeFigure()}updateSettings(e){this.settings=e}};let wg=sc;wg.ADD_SERIES_DEBOUNCE=50;function Sg({text:e,isOpen:t,onClose:n}){const[s,i]=y.exports.useState(!1),[o,r]=y.exports.useState(0),[l,a]=y.exports.useState(!1),[c,d]=y.exports.useState(!1),[u,m]=y.exports.useState(!1),p=y.exports.useRef(),g=y.exports.useRef(null),[f,C]=y.exports.useState(!1);y.exports.useEffect(function(){if(!!t){try{JSON.parse(e),m(!0)}catch{m(!1)}d(!1)}},[t,e]),y.exports.useEffect(function(){p.current&&p.current.layout()},[o]),y.exports.useEffect(function(){p.current&&p.current.updateOptions({lineNumbers:l?"on":"off"})},[l]),y.exports.useEffect(()=>(g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{C(!1)},1e3),()=>{g.current&&clearTimeout(g.current)}),[f]);function b(){var M,F;ve.copyToClipboard((F=(M=p.current)==null?void 0:M.getValue())!=null?F:e).then(()=>{C(!0)})}function w(){a(!l)}function S(){var F;const M=(F=p.current)==null?void 0:F.getModel();!u||!M||(c?(M.setValue(e),d(!1)):(M.setValue(JSON.stringify(JSON.parse(e),void 0,2)),d(!0)),I())}function I(){var F,P;const M=p.current;!M||a(((P=(F=M.getModel())==null?void 0:F.getLineCount())!=null?P:0)>1)}function v(){s&&(p.current=void 0,n())}function R(M){p.current=M,M.onDidContentSizeChange(({contentHeight:F})=>r(F)),I()}return!t&&!s?null:T(Jc,{isOpen:t,centered:!0,keyboard:!0,toggle:v,onOpened:()=>i(!0),onClosed:()=>{i(!1),r(0)},className:"theme-bg-dark cell-overflow-modal",children:[T(td,{toggle:n,children:[h("h5",{className:"overflow-modal-title",children:"Cell Contents"}),h(me,{kind:"inline",icon:f?$l:Vl,tooltip:f?"Copied contents":"Copy contents",onClick:b}),h(me,{kind:"inline",active:l,icon:fd,tooltip:"Toggle line numbers",onClick:w}),u&&h(me,{kind:"inline",icon:md,active:c,tooltip:"Format as JSON",onClick:S})]}),h(ed,{style:{height:o},children:h(Tr,{onEditorInitialized:R,settings:{value:e,readOnly:!0,wordWrap:"on",language:u?"typescript":"plaintext",folding:u,padding:{bottom:16},lineNumbers:l?"on":"off",overviewRulerLanes:0,renderLineHighlight:"none",find:{seedSearchStringFromSelection:"never"}}})})]})}const vg="###,##0",Tg=({gotoRow:e,gotoRowError:t,onSubmit:n,isShown:s,onEntering:i,onEntered:o,onExiting:r,onExited:l,model:a,onGotoRowNumberChanged:c,onClose:d})=>{const u=y.exports.useRef(null),m="Row number",{rowCount:p}=a;return y.exports.useEffect(()=>{var g;document.activeElement!==u.current&&((g=u.current)==null||g.select())},[e]),h(io,{isShown:s,className:$("goto-row"),onEntering:i,onEntered:()=>{var g;o(),(g=u.current)==null||g.select()},onExiting:r,onExited:l,children:T(Fe,{children:[T("div",{className:"goto-row-wrapper",children:[h("div",{className:"goto-row-text",children:"Go to row"}),h("div",{className:"goto-row-input",children:h("input",{ref:u,type:"number",onKeyDown:g=>{g.key==="Enter"&&(g.stopPropagation(),g.preventDefault(),n())},className:$("form-control",{"is-invalid":t!==""}),placeholder:m,onChange:g=>{c(g)},value:e})}),T("div",{className:"goto-row-text",children:["of ",dh.i18n.NumberFormat.format(vg,p)]}),t&&h("div",{className:"goto-row-error text-danger",children:t})]}),h("div",{className:"goto-row-close",children:h(me,{kind:"ghost",onClick:d,children:h(K,{icon:ti,style:{marginRight:"0"}})})})]})})},oe=J.module("IrisGrid"),Eg=500,yg=250,Rg=250,ic=Object.freeze({aggregations:[],showOnTop:!1});function Fl({advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a}){return e.size===0&&t.aggregations.length===0&&n.length===0&&s.size===0&&i===x.REVERSE_TYPE.NONE&&o==null&&r==null&&l.length===0&&a.length===0}const ss=class extends y.exports.Component{constructor(e){super(e),this.getAdvancedMenuOpenedHandler=he(L=>this.handleAdvancedMenuOpened.bind(this,L),{max:100}),this.getCachedAdvancedFilterMenuActions=he((L,_,V,G,j)=>h(wr,{model:L,column:_,onFilterChange:this.handleAdvancedFilterChange,onSortChange:this.handleAdvancedFilterSortChange,onDone:this.handleAdvancedFilterDone,options:V,sortDirection:G,formatter:j}),{max:50}),this.getCachedOptionItems=he((L,_,V,G,j,ee,re,be,ce,Te,_e,Ke,Mt,Xe,Ze)=>{const Le=[];return L&&Le.push({type:we.CHART_BUILDER,title:"Chart Builder",icon:Pd}),Le.push({type:we.VISIBILITY_ORDERING_BUILDER,title:"Column Visibility & Ordering",icon:_o}),V&&Le.push({type:we.CONDITIONAL_FORMATTING,title:"Conditional Formatting",icon:Ul}),_&&Le.push({type:we.CUSTOM_COLUMN_BUILDER,title:"Manage Custom Columns",icon:yd}),G&&Le.push({type:we.ROLLUP_ROWS,title:"Rollup Rows",icon:zd}),j&&Le.push({type:we.AGGREGATIONS,title:"Aggregate Columns",icon:Rd}),ee&&Le.push({type:we.SELECT_DISTINCT,title:"Select Distinct Values",icon:Ed}),re&&Mt&&Le.push({type:we.TABLE_EXPORTER,title:"Download CSV",icon:cd}),Le.push({type:we.ADVANCED_SETTINGS,title:"Advanced Settings",icon:Id}),Le.push({type:we.QUICK_FILTERS,title:"Quick Filters",subtitle:be.shortcut.getDisplayText(),icon:Vi,isOn:_e,onChange:be.action}),Xe&&Le.push({type:we.SEARCH_BAR,title:"Search Bar",subtitle:ce.shortcut.getDisplayText(),icon:ql,isOn:Ke,onChange:ce.action}),Le.push({type:we.GOTO,title:"Go to",subtitle:Te.shortcut.getDisplayText(),icon:Td,isOn:Ze,onChange:Te.action}),Le},{max:1}),this.getCachedHiddenColumns=he(L=>L,{max:1,normalizer:([L])=>L.join()}),this.getAggregationMap=he((L,_)=>{const V={};return _.forEach(({operation:G,selected:j,invert:ee})=>{V[G]=On.getOperationColumnNames(L,G,j,ee)}),V}),this.getOperationMap=he((L,_)=>{const V={};return _.filter(G=>!On.isRollupOperation(G.operation)).forEach(({operation:G,selected:j,invert:ee})=>{On.getOperationColumnNames(L,G,j,ee).forEach(re=>{var ce;const be=[...(ce=V[re])!=null?ce:[],G];V[re]=be})}),V}),this.getOperationOrder=he(L=>L.map(_=>_.operation).filter(_=>!On.isRollupOperation(_))),this.getCachedFormatColumns=he((L,_)=>rm(L,_)),this.getCachedModelColumns=he((L,_)=>L.columns),this.getCachedPreviewFormatColumns=he((L,_,V,G)=>{if(oe.debug("getCachedPreviewFormatColumns",_,V,G),V!==void 0&&G!==void 0){const j=[..._];return j[G]=V,this.getCachedFormatColumns(L,j)}return this.getCachedFormatColumns(L,_)}),this.getModelRollupConfig=he((L,_,V)=>ne.getModelRollupConfig(L,_,V)),this.getModelTotalsConfig=he((L,_,V)=>{var be,ce,Te;const{aggregations:G,showOnTop:j}=V;if(((ce=(be=_==null?void 0:_.columns)==null?void 0:be.length)!=null?ce:0)>0||((Te=G==null?void 0:G.length)!=null?Te:0)===0)return null;const ee=this.getOperationMap(L,G),re=this.getOperationOrder(G);return{operationMap:ee,operationOrder:re,showOnTop:j}}),this.getCachedStateOverride=he((L,_,V,G,j,ee,re,be,ce,Te)=>({hoverSelectColumn:L,isFilterBarShown:_,isSelectingColumn:V,loadingScrimProgress:G,quickFilters:j,advancedFilters:ee,sorts:re,reverseType:be,rollupConfig:ce,isMenuShown:Te}),{max:1}),this.getCachedFilter=he((L,_,V,G,j)=>[...L!=null?L:[],...G!=null?G:[],...ne.getFiltersFromFilterMap(_),...ne.getFiltersFromFilterMap(V),...j!=null?j:[]],{max:1}),this.getCachedTheme=he((L,_)=>({...Aa,...L,autoSelectRow:!_}),{max:1}),this.getAlwaysFetchColumns=he((L,_,V,G,j,ee)=>{const re=[];for(let ce=0;ce<G;ce+=1)re.push(_[U.getModelIndex(ce,V)].name);for(let ce=0;ce<j;ce+=1)re.push(_[U.getModelIndex(_.length-1-ce,V)].name);if(ee)for(let ce=ee[0];ce<=ee[1];ce+=1)re.push(_[U.getModelIndex(ce,V)].name);return[...new Set([...L,...re])]}),this.updateSearchFilter=Tt((L,_,V,G)=>{const j=xi.createSearchFilter(L,_,V,G);this.setState({searchFilter:j})},yg),this.handleConditionalFormatEditorUpdate=Tt(L=>{this.setState({conditionalFormatPreview:L})},Rg),this.handleDownloadProgressUpdate=cs((L,_)=>{const{tableDownloadStatus:V}=this.state;V===wt.DOWNLOAD_STATUS.DOWNLOADING&&this.setState({tableDownloadProgress:L,tableDownloadEstimatedTime:_})},Eg),this.getOverflowButtonTooltip=he(L=>{if(L==null)return null;const _={position:"absolute",...L,pointerEvents:"none"};return h("div",{style:_,children:h(ge,{options:{placement:"left",modifiers:{flip:{behavior:["left","right"]}}},ref:this.handleTooltipRef,children:"View full contents"},Date.now())})}),this.handleAdvancedFilterChange=this.handleAdvancedFilterChange.bind(this),this.handleAdvancedFilterSortChange=this.handleAdvancedFilterSortChange.bind(this),this.handleAdvancedFilterDone=this.handleAdvancedFilterDone.bind(this),this.handleAdvancedMenuOpened=this.handleAdvancedMenuOpened.bind(this),this.handleGotoRowOpened=this.handleGotoRowOpened.bind(this),this.handleGotoRowClosed=this.handleGotoRowClosed.bind(this),this.handleAdvancedMenuClosed=this.handleAdvancedMenuClosed.bind(this),this.handleAggregationChange=this.handleAggregationChange.bind(this),this.handleAggregationsChange=this.handleAggregationsChange.bind(this),this.handleAggregationEdit=this.handleAggregationEdit.bind(this),this.handleAnimationLoop=this.handleAnimationLoop.bind(this),this.handleAnimationStart=this.handleAnimationStart.bind(this),this.handleAnimationEnd=this.handleAnimationEnd.bind(this),this.handleChartChange=this.handleChartChange.bind(this),this.handleChartCreate=this.handleChartCreate.bind(this),this.handleGridError=this.handleGridError.bind(this),this.handleFilterBarChange=this.handleFilterBarChange.bind(this),this.handleFilterBarDone=this.handleFilterBarDone.bind(this),this.handleFilterBarTab=this.handleFilterBarTab.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleMenu=this.handleMenu.bind(this),this.handleMenuClose=this.handleMenuClose.bind(this),this.handleMenuSelect=this.handleMenuSelect.bind(this),this.handleMenuBack=this.handleMenuBack.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.handleSelectionChanged=this.handleSelectionChanged.bind(this),this.handleMovedColumnsChanged=this.handleMovedColumnsChanged.bind(this),this.handleUpdate=this.handleUpdate.bind(this),this.handleTooltipRef=this.handleTooltipRef.bind(this),this.handleViewChanged=this.handleViewChanged.bind(this),this.handleFormatSelection=this.handleFormatSelection.bind(this),this.handleConditionalFormatCreate=this.handleConditionalFormatCreate.bind(this),this.handleConditionalFormatEdit=this.handleConditionalFormatEdit.bind(this),this.handleConditionalFormatsChange=this.handleConditionalFormatsChange.bind(this),this.handleConditionalFormatEditorSave=this.handleConditionalFormatEditorSave.bind(this),this.handleConditionalFormatEditorCancel=this.handleConditionalFormatEditorCancel.bind(this),this.handleUpdateCustomColumns=this.handleUpdateCustomColumns.bind(this),this.handleCustomColumnsChanged=this.handleCustomColumnsChanged.bind(this),this.handleSelectDistinctChanged=this.handleSelectDistinctChanged.bind(this),this.handlePendingDataUpdated=this.handlePendingDataUpdated.bind(this),this.handlePendingCommitClicked=this.handlePendingCommitClicked.bind(this),this.handlePendingDiscardClicked=this.handlePendingDiscardClicked.bind(this),this.handleGotoRowSelectedRowNumberSubmit=this.handleGotoRowSelectedRowNumberSubmit.bind(this),this.focusRowInGrid=this.focusRowInGrid.bind(this),this.handleDownloadTable=this.handleDownloadTable.bind(this),this.handleDownloadTableStart=this.handleDownloadTableStart.bind(this),this.handleCancelDownloadTable=this.handleCancelDownloadTable.bind(this),this.handleDownloadCanceled=this.handleDownloadCanceled.bind(this),this.handleDownloadCompleted=this.handleDownloadCompleted.bind(this),this.handlePartitionAppend=this.handlePartitionAppend.bind(this),this.handlePartitionChange=this.handlePartitionChange.bind(this),this.handlePartitionFetchAll=this.handlePartitionFetchAll.bind(this),this.handlePartitionDone=this.handlePartitionDone.bind(this),this.handleColumnVisibilityChanged=this.handleColumnVisibilityChanged.bind(this),this.handleCrossColumnSearch=this.handleCrossColumnSearch.bind(this),this.handleRollupChange=this.handleRollupChange.bind(this),this.handleOverflowClose=this.handleOverflowClose.bind(this),this.getColumnBoundingRect=this.getColumnBoundingRect.bind(this),this.handleGotoRowSelectedRowNumberChanged=this.handleGotoRowSelectedRowNumberChanged.bind(this),this.grid=null,this.gridWrapper=null,this.lastLoadedConfig=null,this.pending=new Ji,this.globalColumnFormats=[],this.decimalFormatOptions={},this.integerFormatOptions={},this.truncateNumbersWithPound=!1,this.renderer=new Zs,this.tableSaver=null,this.crossColumnRef=Q.createRef(),this.isAnimating=!1,this.filterInputRef=Q.createRef(),this.toggleFilterBarAction={action:()=>this.toggleFilterBar(),shortcut:Pt.TABLE.TOGGLE_QUICK_FILTER},this.toggleSearchBarAction={action:()=>this.toggleSearchBar(),shortcut:Pt.TABLE.TOGGLE_SEARCH},this.toggleGotoRowAction={action:()=>this.toggleGotoRow(),shortcut:Pt.TABLE.GOTO_ROW},this.discardAction={action:()=>{const{model:L}=this.props;Ae(L)&&L.isEditable&&L.pendingDataMap.size>0&&this.discardPending().catch(oe.error)},shortcut:Pt.INPUT_TABLE.DISCARD},this.commitAction={action:()=>{const{model:L}=this.props;Ae(L)&&L.isEditable&&L.pendingDataMap.size>0&&L.pendingDataErrors.size===0&&this.commitPending().catch(oe.error)},shortcut:Pt.INPUT_TABLE.COMMIT},this.contextActions=[this.toggleFilterBarAction,this.toggleSearchBarAction,this.toggleGotoRowAction,this.discardAction,this.commitAction];const{aggregationSettings:t,conditionalFormats:n,customColumnFormatMap:s,isFilterBarShown:i,isSelectingPartition:o,model:r,movedColumns:l,movedRows:a,partition:c,partitionColumn:d,rollupConfig:u,userColumnWidths:m,userRowHeights:p,showSearchBar:g,searchValue:f,selectedSearchColumns:C,invertSearchColumns:b,advancedFilters:w,quickFilters:S,selectDistinctColumns:I,pendingDataMap:v,canCopy:R,frozenColumns:M}=e,F=[new pm(this),new gm(this)];R&&F.push(new um(this));const P=[new fm(this),new Cm(this),new bm(this),new Tm(this),new vm(this),new Cn(this),new Sm(this),new Em(this)],W=l.length>0?l:r.movedColumns,B=a.length>0?a:r.movedRows,N=new Im({userColumnWidths:new Map(m),userRowHeights:new Map(p),movedColumns:W}),H=C!=null?C:[],A=xi.createSearchFilter(f,H,r.columns,b);this.state={isFilterBarShown:i,isSelectingPartition:o,focusedFilterBarColumn:null,metricCalculator:N,metrics:void 0,keyHandlers:F,mouseHandlers:P,partition:c,partitionColumn:d,partitionTable:null,partitionFilters:[],quickFilters:S?new Map(S):new Map,advancedFilters:new Map(w),shownAdvancedFilter:null,hoverAdvancedFilter:null,sorts:[],reverseType:x.REVERSE_TYPE.NONE,customColumns:[],selectDistinctColumns:I,selectedRanges:[],copyOperation:null,loadingText:null,loadingScrimProgress:null,loadingSpinnerShown:!1,movedColumns:W,movedRows:B,shownColumnTooltip:null,formatter:new jt,isMenuShown:!1,customColumnFormatMap:new Map(s),conditionalFormats:n,conditionalFormatEditIndex:null,conditionalFormatPreview:void 0,hoverSelectColumn:null,isTableDownloading:!1,isReady:!1,tableDownloadStatus:"",tableDownloadProgress:0,tableDownloadEstimatedTime:0,showSearchBar:g,searchFilter:A,searchValue:f,selectedSearchColumns:H,invertSearchColumns:b,rollupConfig:u,rollupSelectedColumns:[],aggregationSettings:t,selectedAggregation:null,openOptions:[],pendingRowCount:0,pendingDataMap:v!=null?v:new Map,pendingDataErrors:new Map,pendingSavePromise:null,pendingSaveError:null,toastMessage:null,frozenColumns:M,showOverflowModal:!1,overflowText:"",overflowButtonTooltipProps:null,isGotoRowShown:!1,gotoRow:"",gotoRowError:""}}static makeQuickFilter(e,t,n){try{return x.makeQuickFilter(e,t,n)}catch(s){oe.error("Error creating quick filter",s)}return null}componentDidMount(){const{partitionColumn:e,model:t}=this.props,n=e!=null?e:t.columns.find(s=>s.isPartitionColumn);t.isFilterRequired&&t.isValuesTableAvailable&&n!=null?this.loadPartitionsTable(n):this.initState(),this.startListening(t)}componentDidUpdate(e){var d;const{inputFilters:t,isSelectingColumn:n,settings:s,model:i,customFilters:o,sorts:r}=this.props;i!==e.model&&(this.stopListening(e.model),this.startListening(i));const l=t!==e.inputFilters?t.filter(u=>!e.inputFilters.includes(u)):[];if(l.length>0){const{advancedSettings:u}=this.props,m=(d=u.get(ds.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS))!=null?d:!1;m&&(this.clearGridInputField(),this.clearCrossColumSearch()),this.startLoading("Filtering...",!0),this.applyInputFilters(l,m)}n!==e.isSelectingColumn&&this.resetColumnSelection(),s!==e.settings&&this.updateFormatterSettings(s),o!==e.customFilters&&this.startLoading("Filtering...",!0),r!==e.sorts&&this.updateSorts(r);const{loadingScrimStartTime:a,loadingScrimFinishTime:c}=this;a!=null&&c!=null&&window.requestAnimationFrame(()=>{const u=Date.now(),m=u-a,p=c-a,g=Math.min(m/p,1);c<u&&(this.loadingScrimStartTime=void 0,this.loadingScrimFinishTime=void 0),this.setState(f=>f.loadingScrimProgress==null?(oe.debug2("Ignoring scrim update because loading cancelled."),null):{loadingScrimProgress:g})}),this.sendStateChange()}componentWillUnmount(){const{model:e}=this.props;this.stopListening(e),this.pending.cancel(),this.updateSearchFilter.cancel(),this.loadingTimer&&clearTimeout(this.loadingTimer),this.handleDownloadProgressUpdate.cancel(),this.animationFrame!==void 0&&cancelAnimationFrame(this.animationFrame)}getValueForCell(e,t,n=!1){const{model:s}=this.props,i=this.getModelColumn(e),o=this.getModelRow(t);return n&&i!=null&&o!=null?s.valueForCell(i,o):n?null:i!=null&&o!=null?s.textForCell(i,o):""}getModelColumn(e){const{metrics:t}=this.state;O(t);const{modelColumns:n}=t;return n==null?null:e!=null?n.get(e):null}getModelRow(e){const{metrics:t}=this.state;O(t);const{modelRows:n}=t;return n==null?null:e!=null?n.get(e):null}getTheme(){var n;const{model:e,theme:t}=this.props;return this.getCachedTheme(t,(n=Ae(e)&&e.isEditable)!=null?n:!1)}getVisibleColumn(e){const{movedColumns:t}=this.state;return U.getVisibleIndex(e,t)}applyInputFilters(e,t=!1){const{model:n}=this.props,{advancedFilters:s,quickFilters:i}=this.state,o=t?new Map:new Map(s),r=t?new Map:new Map(i);let l=t&&s.size>0;e.forEach(({name:a,type:c,value:d})=>{const u=n.columns.findIndex(({name:m,type:p})=>m===a&&p===c);u>=0?(l=o.delete(u)||l,l=this.applyQuickFilter(u,d,r)||l):oe.error("Unable to find column for inputFilter",a,c,d)}),l&&this.setState({quickFilters:r,advancedFilters:o})}applyQuickFilter(e,t,n){const{model:s}=this.props,{formatter:i}=s,o=s.columns[e];if(t!=null&&`${t}`.trim().length>0){const r=n.get(e);if(r!=null){const{text:l}=r;if(l===t)return oe.debug2("Ignoring change to existing filter"),!1}return n.set(e,{text:t,filter:ss.makeQuickFilter(o,t,i.timeZone)}),!0}return n.delete(e)}setAdvancedFilterMap(e){this.setState({advancedFilters:e})}setAdvancedFilter(e,t,n){oe.debug("Setting advanced filter",e,t),this.startLoading("Filtering...",!0),this.setState(({advancedFilters:s})=>{const i=new Map(s);return t==null?i.delete(e):i.set(e,{filter:t,options:n}),{advancedFilters:i}})}setQuickFilter(e,t,n){oe.debug("Setting quick filter",e,t,n),this.startLoading("Filtering...",!0),this.setState(({quickFilters:s})=>{const i=new Map(s);return i.set(e,{filter:t,text:n}),{quickFilters:i}})}setFilterMap(e){var i;oe.debug("setFilterMap",e);const{advancedSettings:t}=this.props;((i=t.get(ds.LINK_CHANGE_CLEARS_ALL_FILTERS))!=null?i:!1)&&this.clearAllFilters();const{model:s}=this.props;e.forEach(({columnType:o,text:r,value:l},a)=>{const c=s.columns.find(u=>u.name===a&&u.type===o);if(c==null)return;const d=s.getColumnIndexByName(c.name);if(O(d),l===null)this.setQuickFilter(d,c.filter().isNull(),"=null");else{const u=x.isTextType(o)?E.FilterValue.ofString(l):E.FilterValue.ofNumber(l);this.setQuickFilter(d,c.filter().eq(u),`${r}`)}})}removeColumnFilter(e){this.startLoading("Filtering...",!0),this.setState(({advancedFilters:t,quickFilters:n})=>{const s=t?new Map(t):new Map,i=n?new Map(n):new Map;return i.delete(e),s.delete(e),{quickFilters:i,advancedFilters:s}})}clearAllFilters(){oe.debug("Clearing all filters");const{advancedFilters:e,quickFilters:t,searchFilter:n}=this.state;t.size===0&&e.size===0&&n===null||(this.clearGridInputField(),this.startLoading("Clearing Filters...",!0),this.setState({quickFilters:new Map,advancedFilters:new Map,searchValue:"",searchFilter:void 0}))}clearCrossColumSearch(){oe.debug("Clearing cross-column search"),this.setState({searchValue:"",searchFilter:void 0})}clearGridInputField(){this.filterInputRef.current!=null&&this.filterInputRef.current.setValue("")}rebuildFilters(){oe.debug("Rebuilding filters");const{model:e}=this.props,{advancedFilters:t,quickFilters:n}=this.state,{columns:s,formatter:i}=e,o=new Map,r=new Map;t.forEach((l,a)=>{const{options:c}=l,d=s[a],u=x.makeAdvancedFilter(d,c,i.timeZone);o.set(a,{options:c,filter:u})}),n.forEach((l,a)=>{const{text:c}=l,d=s[a];r.set(a,{text:c,filter:ss.makeQuickFilter(d,c,i.timeZone)})}),this.startLoading("Rebuilding filters...",!0),this.setState({quickFilters:r,advancedFilters:o})}setFilters({quickFilters:e,advancedFilters:t}){this.setState({quickFilters:e,advancedFilters:t})}updateFormatterSettings(e,t=!0){var m,p,g;const n=ls.getColumnFormats(e),s=ls.getDateTimeFormatterOptions(e),i=(m=e==null?void 0:e.defaultDecimalFormatOptions)!=null?m:{},o=(p=e==null?void 0:e.defaultIntegerFormatOptions)!=null?p:{},r=(g=e==null?void 0:e.truncateNumbersWithPound)!=null?g:!1,l=!ct(this.globalColumnFormats,n),a=!ct(this.dateTimeFormatterOptions,s),c=!ct(this.decimalFormatOptions,e==null?void 0:e.defaultDecimalFormatOptions),d=!ct(this.integerFormatOptions,o),u=this.truncateNumbersWithPound!==r;(l||a||c||d||u)&&(this.globalColumnFormats=n,this.dateTimeFormatterOptions=s,this.decimalFormatOptions=i,this.integerFormatOptions=o,this.truncateNumbersWithPound=r,this.updateFormatter({},t),a&&t&&this.rebuildFilters())}updateFormatter(e,t=!0){var r;const{customColumnFormatMap:n}=this.state,s={customColumnFormatMap:n,...e},i=[...(r=this.globalColumnFormats)!=null?r:[],...s.customColumnFormatMap.values()],o=new jt(i,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions,this.truncateNumbersWithPound);oe.debug("updateFormatter",this.globalColumnFormats,i),this.setState({...s,formatter:o},()=>{t&&this.grid&&this.grid.forceUpdate()})}initFormatter(){const{settings:e}=this.props;this.updateFormatterSettings(e)}initState(){const{applyInputFiltersOnInit:e,inputFilters:t,sorts:n,model:s,reverseType:i,customColumns:o,searchValue:r,selectedSearchColumns:l,invertSearchColumns:a}=this.props,c=l!=null?l:[],d=xi.createSearchFilter(r,c,s.columns,a);if(e){const u=t.filter(m=>m.value!=null);this.applyInputFilters(u)}this.setState({sorts:n,reverseType:i,customColumns:o,isReady:!0,searchFilter:d}),this.initFormatter()}async loadPartitionsTable(e){const{model:t}=this.props;this.setState({isSelectingPartition:!0});try{const n=await this.pending.add(t.valuesTable(e),r=>r.close()),s=n.columns[0],i=s.sort().desc();n.applySort([i]),n.setViewport(0,0,[s]);const o=await this.pending.add(n.getViewportData());if(o.rows.length>0){const l=o.rows[0].get(s);this.updatePartition(l,e),this.setState({isSelectingPartition:!0})}else oe.info("Table does not have any data, just fetching all"),this.setState({isSelectingPartition:!1}),this.handlePartitionFetchAll();this.setState({partitionTable:n,partitionColumn:e},()=>{this.initState()})}catch(n){this.handleTableLoadError(n)}}updatePartition(e,t){const s=[t.filter().eq(E.FilterValue.ofString(e))];this.setState({partition:e,partitionFilters:s})}copyCell(e,t,n=!1){const{canCopy:s}=this.props;if(s){const i=String(this.getValueForCell(e,t,n));ve.copyToClipboard(i).catch(o=>oe.error("Unable to copy cell",o))}else oe.error("Attempted to copyCell for user without copy permission.")}copyRanges(e,t=!1,n=!0,s){const{model:i,canCopy:o}=this.props,{metricCalculator:r,movedColumns:l}=this.state,a=r.getUserColumnWidths();if(o){const c={ranges:Z.boundedRanges(e,i.columnCount,i.rowCount),includeHeaders:t,formatValues:n,movedColumns:l,userColumnWidths:a,error:s};this.setState({copyOperation:c})}else oe.error("Attempted copyRanges for user without copy permission.")}startLoading(e,t=!1){var s,i;this.setState({loadingText:e});const n=this.getTheme();if(t&&this.grid&&(this.grid.clearSelectedRanges(),this.grid.setViewState({top:0},!0)),this.loadingScrimStartTime==null){const{minScrimTransitionTime:o,maxScrimTransitionTime:r}=n;O(o),O(r);const l=(i=(s=this.gridWrapper)==null?void 0:s.getBoundingClientRect().height)!=null?i:0,a=Math.max(o,Math.min(l/2,r));this.loadingScrimStartTime=Date.now(),this.loadingScrimFinishTime=this.loadingScrimStartTime+a,this.setState({loadingScrimProgress:0}),this.loadingTimer=setTimeout(()=>{this.setState({loadingSpinnerShown:!0})},ss.loadingSpinnerDelay)}}stopLoading(){this.loadingScrimStartTime=void 0,this.loadingScrimFinishTime=void 0,this.setState({loadingText:null,loadingScrimProgress:null,loadingSpinnerShown:!1}),this.loadingTimer!=null&&(clearTimeout(this.loadingTimer),this.loadingTimer=void 0)}rollback(){if(this.lastLoadedConfig){oe.debug("loading last loading config",this.lastLoadedConfig);const{advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a}=this.lastLoadedConfig;this.lastLoadedConfig=null,this.setState({advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a})}else oe.debug("remove all sorts, filters, and custom columns"),this.setState({advancedFilters:new Map,aggregationSettings:ic,customColumns:[],quickFilters:new Map,reverseType:x.REVERSE_TYPE.NONE,rollupConfig:void 0,selectDistinctColumns:[],sorts:[]})}canRollback(){return this.lastLoadedConfig!=null||!Fl(this.state)}startListening(e){e.addEventListener(ue.EVENT.UPDATED,this.handleUpdate),e.addEventListener(ue.EVENT.REQUEST_FAILED,this.handleRequestFailed),e.addEventListener(ue.EVENT.COLUMNS_CHANGED,this.handleCustomColumnsChanged),e.addEventListener(ue.EVENT.PENDING_DATA_UPDATED,this.handlePendingDataUpdated)}stopListening(e){e.removeEventListener(ue.EVENT.UPDATED,this.handleUpdate),e.removeEventListener(ue.EVENT.REQUEST_FAILED,this.handleRequestFailed),e.removeEventListener(ue.EVENT.COLUMNS_CHANGED,this.handleCustomColumnsChanged),e.removeEventListener(ue.EVENT.PENDING_DATA_UPDATED,this.handlePendingDataUpdated)}focus(){var e;(e=this.grid)==null||e.focus()}focusFilterBar(e){var d,u,m;const{model:t}=this.props,{columnCount:n}=t,s=this.getModelColumn(e);if(e==null||s==null||e<0||n<=e||!t.isFilterable(s)){this.setState({focusedFilterBarColumn:null});return}const{metricCalculator:i,metrics:o}=this.state;O(o);const{gridX:r,left:l,rightVisible:a,lastLeft:c}=o;if(e<l)(d=this.grid)==null||d.setViewState({left:e},!0);else if(a<e){const p=(u=this.grid)==null?void 0:u.getMetricState();O(p);const g=i.getLastLeft(p,e,r);(m=this.grid)==null||m.setViewState({left:Math.min(g,c)},!0)}this.lastFocusedFilterBarColumn=e,this.setState({focusedFilterBarColumn:e,isFilterBarShown:!0})}hideColumnByVisibleIndex(e){var s;const{metricCalculator:t,movedColumns:n}=this.state;t.setColumnWidth(U.getModelIndex(e,n),0),(s=this.grid)==null||s.forceUpdate()}freezeColumnByColumnName(e){const{frozenColumns:t,movedColumns:n}=this.state,{model:s}=this.props;oe.debug2("freezing column",e);const i=t==null?new Set(s.frozenColumns):new Set(t);i.add(e);const o=s.getColumnIndexByName(e);O(o);const r=U.getVisibleIndex(o,n),l=U.moveItem(r,i.size-1,n);this.setState({frozenColumns:[...i],movedColumns:l})}unFreezeColumnByColumnName(e){const{frozenColumns:t,movedColumns:n}=this.state,{model:s}=this.props;oe.debug2("unfreezing column",e);const i=t==null?new Set(s.frozenColumns):new Set(t);i.delete(e);const o=s.getColumnIndexByName(e);O(o);const r=U.getVisibleIndex(o,n),l=U.moveItem(r,i.size+s.frontColumns.length,n);this.setState({frozenColumns:[...i],movedColumns:l})}handleColumnVisibilityChanged(e,t){var s;const{metricCalculator:n}=this.state;t===us.VISIBILITY_OPTIONS.SHOW?e.forEach(i=>{n.resetColumnWidth(i)}):e.forEach(i=>{n.setColumnWidth(i,0)}),(s=this.grid)==null||s.forceUpdate()}handleCrossColumnSearch(e,t,n){const{model:s}=this.props;this.updateSearchFilter(e,t,s.columns,n),this.setState({searchValue:e,selectedSearchColumns:t,invertSearchColumns:n})}handleAnimationLoop(){var e,t;(e=this.grid)==null||e.updateCanvasScale(),(t=this.grid)==null||t.updateCanvas(),this.isAnimating&&(this.animationFrame=requestAnimationFrame(this.handleAnimationLoop))}handleAnimationStart(){oe.debug2("handleAnimationStart"),this.isAnimating=!0,this.animationFrame=requestAnimationFrame(this.handleAnimationLoop)}handleAnimationEnd(){oe.debug2("handleAnimationEnd"),this.isAnimating=!1}handlePartitionAppend(e){const{onPartitionAppend:t}=this.props,{partitionColumn:n}=this.state;t(n,e)}handlePartitionChange(e){const{partitionColumn:t}=this.state;this.updatePartition(e,t)}handlePartitionFetchAll(){this.setState({partitionFilters:[],isSelectingPartition:!1})}handlePartitionDone(){this.setState({isSelectingPartition:!1})}handleTableLoadError(e){if(He.isCanceled(e))return;oe.error(e);const{onError:t}=this.props;t(e)}showAllColumns(){var s;const{metricCalculator:e}=this.state,n=[...e.getUserColumnWidths().entries()];for(let i=0;i<n.length;i+=1){const[o,r]=n[i];r===0&&e.resetColumnWidth(o)}(s=this.grid)==null||s.forceUpdate()}toggleSort(e,t){oe.info("Toggling sort for column",e);const{model:n}=this.props,{sorts:s}=this.state,i=this.getModelColumn(e);O(i);const o=x.toggleSortForColumn(s,n.columns,i,t);this.updateSorts(o)}updateSorts(e){var t;this.startLoading("Sorting..."),this.setState({sorts:e}),(t=this.grid)==null||t.forceUpdate()}sortColumn(e,t=x.sortDirection.none,n=!1,s=!1){var r;O(e);const{model:i}=this.props,o=x.sortColumn(i.sort,i.columns,e,t,n,s);this.startLoading("Sorting..."),this.setState({sorts:o}),(r=this.grid)==null||r.forceUpdate()}reverse(e){var t;this.startLoading("Reversing..."),this.setState({reverseType:e}),(t=this.grid)==null||t.forceUpdate()}isReversible(){const{model:e}=this.props;return e.isReversible}toggleFilterBar(e=this.lastFocusedFilterBarColumn){var n;let{isFilterBarShown:t}=this.state;if(t=!t,this.setState({isFilterBarShown:t}),t)if(e!=null)this.focusFilterBar(e);else{let s=0;const{model:i}=this.props,{columnCount:o}=i;for(let r=0;r<o;r+=1){const l=this.getModelColumn(r);if(l!=null){const a=i.columns[l];if(a!=null&&x.isTextType(a.type)){s=r;break}}}this.focusFilterBar(s)}else(n=this.grid)==null||n.focus()}isTableSearchAvailable(){var s,i,o;const{model:e,canToggleSearch:t}=this.props,n=(s=e==null?void 0:e.layoutHints)==null?void 0:s.searchDisplayMode;return n===((i=E.SearchDisplayMode)==null?void 0:i.SEARCH_DISPLAY_HIDE)?!1:n===((o=E.SearchDisplayMode)==null?void 0:o.SEARCH_DISPLAY_SHOW)?!0:t}toggleSearchBar(){const{showSearchBar:e}=this.state;if(!this.isTableSearchAvailable())return;const t=!e;this.setState({showSearchBar:t},()=>{var n,s,i;t&&((n=this.crossColumnRef)==null?void 0:n.current)?(s=this.crossColumnRef)==null||s.current.focus():(i=this.grid)==null||i.focus()})}toggleGotoRow(e=""){const{isGotoRowShown:t}=this.state;if(e){this.setState({isGotoRowShown:!0,gotoRow:e,gotoRowError:""});return}this.setState({isGotoRowShown:!t,gotoRow:"",gotoRowError:""})}async commitPending(){var i,o;const{model:e}=this.props;if(!Ae(e)||!e.isEditable)throw new Error("Cannot save, table is not editable");const{pendingSavePromise:t}=this.state;if(t!=null)throw new Error("Save already in progress");const n=(i=document==null?void 0:document.activeElement)==null?void 0:i.classList.contains("grid-cell-input-field");if(n!=null&&n){if(document.activeElement!=null&&document.activeElement.classList.contains("error"))throw new Zd("Current input is invalid");(o=this.grid)==null||o.focus()}const s=this.pending.add(e.commitPending()).then(()=>{this.setState({pendingSaveError:null,pendingSavePromise:null})}).catch(r=>{He.isCanceled(r)||this.setState({pendingSaveError:r,pendingSavePromise:null})});return this.setState({pendingSavePromise:s}),s}async discardPending(){const{pendingSavePromise:e}=this.state;if(e!=null)throw new Error("Cannot cancel a save in progress");this.setState({pendingSavePromise:null,pendingSaveError:null,pendingDataMap:new Map,pendingDataErrors:new Map})}selectColumn(e){const{onColumnSelected:t}=this.props;t(e)}selectData(e,t){const{model:n}=this.props,{columns:s}=n,i={};for(let r=0;r<s.length;r+=1){const l=s[r],{name:a,type:c}=l,d=n.valueForCell(r,t),u=n.textForCell(r,t);i[a]={value:d,text:u,type:c}}const{onDataSelected:o}=this.props;o(t,i)}handleAdvancedFilterChange(e,t,n){const{model:s}=this.props,i=s.getColumnIndexByName(e.name);O(i),this.setAdvancedFilter(i,t,n)}handleAdvancedFilterSortChange(e,t,n=!1){var a;const{model:s}=this.props,i=s.getColumnIndexByName(e.name);O(i);const o=x.getSortForColumn(s.sort,i);let r=null;(o==null||o.direction!==t)&&(t===x.sortDirection.descending?r=e.sort().desc():r=e.sort().asc());const l=x.setSortForColumn(s.sort,i,r,n);oe.info("Setting table sorts",l),this.startLoading("Sorting..."),this.setState({sorts:l}),(a=this.grid)==null||a.forceUpdate()}handleAdvancedFilterDone(){var e;(e=this.grid)==null||e.focus()}handleAdvancedMenuOpened(e){this.setState({shownAdvancedFilter:e})}handleGotoRowOpened(){this.setState({isGotoRowShown:!0})}handleGotoRowClosed(){this.setState({isGotoRowShown:!1})}handleAdvancedMenuClosed(e){var s,i;const{focusedFilterBarColumn:t,isFilterBarShown:n}=this.state;n&&t===e&&((s=this.filterInputRef)==null?void 0:s.current)!==null?((i=this.filterInputRef)==null||i.current.focus(),this.setState({shownAdvancedFilter:null})):this.setState({focusedFilterBarColumn:null,shownAdvancedFilter:null})}handleCancel(){this.rollback()}handleChartChange(){}handleChartCreate(e){const{model:t,onCreateChart:n}=this.props;n(e,t)}handleGridError(e){oe.warn("Grid Error",e),this.setState({toastMessage:h("div",{className:"error-message",children:`${e}`})})}handleFilterBarChange(e){this.startLoading("Filtering...",!0),this.setState(({focusedFilterBarColumn:t,quickFilters:n})=>{const s=new Map(n);if(t!=null){const i=this.getModelColumn(t);O(i),this.applyQuickFilter(i,e,s)}return{quickFilters:s}})}handleFilterBarDone(e=!0,t=!0){var n;e&&((n=this.grid)==null||n.focus()),t&&this.setState({focusedFilterBarColumn:null})}handleFilterBarTab(e){const{focusedFilterBarColumn:t}=this.state;O(t),e?this.focusFilterBar(t-1):this.focusFilterBar(t+1)}handleFormatSelection(e,t){const{model:n}=this.props,s=n.columns[e],{customColumnFormatMap:i}=this.state,o=new Map(i);if(t!=null){const r=x.getNormalizedType(s.type);O(r);const l=jt.makeColumnFormattingRule(r,s.name,t);o.set(s.name,l)}else o.delete(s.name);this.updateFormatter({customColumnFormatMap:o})}handleMenu(e){e.stopPropagation(),this.setState({isMenuShown:!0})}handleMenuClose(){this.setState({isMenuShown:!1,openOptions:[]})}handleMenuBack(){this.setState(({openOptions:e})=>{const t=[...e];return t.pop(),{openOptions:t}})}handleMenuSelect(e){this.setState(({openOptions:t})=>({openOptions:[...t,e]}))}handleRequestFailed(e){const t=e;if(oe.error("request failed:",t.detail),this.stopLoading(),this.canRollback())this.startLoading("Rolling back changes...",!0),this.rollback();else{oe.error("Table failed and unable to rollback");const{onError:n}=this.props;n(new Error(`Error displaying table: ${t.detail}`))}}handleUpdate(){var d;this.stopLoading(),oe.debug2("Received model update");const{advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a}=this.state,c={advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a};Fl(c)?this.lastLoadedConfig=null:this.lastLoadedConfig=c,(d=this.grid)==null||d.forceUpdate()}handleViewChanged(e){var i,o;const{model:t}=this.props,{selectionEndRow:n=0}=(o=(i=this.grid)==null?void 0:i.state)!=null?o:{};let s=0;if(Ae(t)&&t.isEditable){O(e);const{bottomViewport:r}=e,l=t.rowCount-t.floatingBottomRowCount;n===l-1?s=t.pendingRowCount+1:n===l-2?s=t.pendingRowCount:s=Math.max(0,r-(t.rowCount-t.pendingRowCount)-t.floatingTopRowCount-t.floatingBottomRowCount-1)}this.setState({metrics:e,pendingRowCount:s})}handleSelectionChanged(e){O(e);const{onSelectionChanged:t}=this.props,{copyOperation:n}=this.state;this.setState({selectedRanges:e}),n!=null&&this.setState({copyOperation:null}),t(e)}handleMovedColumnsChanged(e,t=()=>null){this.setState({movedColumns:e},t)}handleTooltipRef(e){e!=null&&e.startTimer(),this.tooltip=e}handleConditionalFormatsChange(e){oe.debug("Updated conditional formats",e),this.setState({conditionalFormats:e})}handleConditionalFormatCreate(){oe.debug("Create new conditional format");const{openOptions:e,conditionalFormats:t}=this.state;this.setState({openOptions:[...e,{type:we.CONDITIONAL_FORMATTING_EDIT,title:"Create Formatting Rule"}],conditionalFormatEditIndex:t.length,conditionalFormatPreview:void 0})}handleConditionalFormatEdit(e){oe.debug("Edit conditional format",e);const{openOptions:t,conditionalFormats:n}=this.state;this.setState({openOptions:[...t,{type:we.CONDITIONAL_FORMATTING_EDIT,title:"Edit Formatting Rule"}],conditionalFormatEditIndex:e,conditionalFormatPreview:{...n[e]}})}handleConditionalFormatEditorSave(e){oe.debug("Save conditional format changes",e),this.setState(t=>{if(t.conditionalFormatEditIndex===null)return oe.debug("Invalid format index"),null;const n=[...t.conditionalFormats];return n[t.conditionalFormatEditIndex]=e,{conditionalFormats:n}},()=>{this.handleMenuBack()})}handleConditionalFormatEditorCancel(){this.handleMenuBack(),this.setState({conditionalFormatEditIndex:null})}handleUpdateCustomColumns(e){oe.info("handleUpdateCustomColumns:",e);const{model:t}=this.props,{movedColumns:n,sorts:s,quickFilters:i,advancedFilters:o,selectDistinctColumns:r}=this.state,{columns:l}=t,a=t.customColumns.map(d=>`${d}`),c=ne.getRemovedCustomColumnNames(a,e);if(c.length>0){const d=ne.removeSortsInColumns(s,c),u=ne.removeFiltersInColumns(l,i,c),m=ne.removeFiltersInColumns(l,o,c),p=ne.removeColumnFromMovedColumns(l,n,c),g=ne.removeColumnsFromSelectDistinctColumns(r,c);d.length!==s.length&&(oe.debug("removing sorts from removed custom columns..."),this.setState({sorts:d})),(u.size!==i.size||m.size!==o.size)&&(oe.debug("removing filters from removed custom columns..."),this.setState({quickFilters:u,advancedFilters:m})),ct(n,p)||(oe.debug("change moved columns for removed custom columns",p),this.setState({movedColumns:p})),ct(r,g)||(oe.debug("change selectDistinct columns for removed custom columns",p),this.setState({selectDistinctColumns:g}))}this.setState({customColumns:e}),this.startLoading("Applying custom columns...")}handleCustomColumnsChanged(){var t;oe.debug("custom columns changed");const{isReady:e}=this.state;e?(this.stopLoading(),(t=this.grid)==null||t.forceUpdate()):this.initState()}handlePendingCommitClicked(){return this.commitPending()}handlePendingDiscardClicked(){return this.discardPending()}handlePendingDataUpdated(){var s;oe.debug("pending data updated");const{model:e}=this.props,{pendingDataMap:t,pendingDataErrors:n}=e;this.setState({pendingDataMap:t,pendingDataErrors:n,pendingSaveError:null}),(s=this.grid)==null||s.forceUpdate()}handleAggregationsChange(e){oe.debug("handleAggregationsChange",e),this.startLoading(`Aggregating ${e.aggregations.map(t=>t.operation).join(", ")}...`),this.setState({aggregationSettings:e})}handleAggregationChange(e){oe.debug("handleAggregationChange",e),this.startLoading(`Aggregating ${e.operation}...`),this.setState(({aggregationSettings:t})=>({selectedAggregation:e,aggregationSettings:{...t,aggregations:t.aggregations.map(n=>n.operation===e.operation?e:n)}}))}handleAggregationEdit(e){oe.debug("handleAggregationEdit",e);const{openOptions:t}=this.state;this.setState({openOptions:[...t,{type:we.AGGREGATION_EDIT,title:`Edit Columns to ${e.operation}`}],selectedAggregation:e})}handleRollupChange(e){var t,n;oe.info("Rollup change",e),this.resetGridViewState(),this.showAllColumns(),this.clearAllFilters(),this.startLoading(`Grouping by columns ${(n=(t=e==null?void 0:e.columns)==null?void 0:t.join(", "))!=null?n:""}...`),this.setState({rollupConfig:e,movedColumns:[],sorts:[],reverseType:x.REVERSE_TYPE.NONE,selectDistinctColumns:[]})}handleSelectDistinctChanged(e){oe.debug("SelectDistinct change",e),this.resetGridViewState(),this.showAllColumns(),this.clearAllFilters(),this.startLoading(`Selecting distinct values in ${e.length>0?e.join(", "):""}...`),this.setState({selectDistinctColumns:e,movedColumns:[],sorts:[],reverseType:x.REVERSE_TYPE.NONE})}handleDownloadTableStart(){const{canDownloadCsv:e}=this.props;e?this.setState({isTableDownloading:!0,tableDownloadProgress:0,tableDownloadEstimatedTime:null,tableDownloadStatus:wt.DOWNLOAD_STATUS.INITIATING}):oe.error("Attempted to handleDownloadTableStart for user without download CSV permission.")}handleDownloadTable(e,t,n,s){const{canDownloadCsv:i}=this.props;i?(oe.info("start table downloading",e,t,n,s),this.setState(()=>(this.tableSaver&&this.tableSaver.startDownload(e,t,n,s),{tableDownloadStatus:wt.DOWNLOAD_STATUS.DOWNLOADING}))):oe.error("Attempted to handleDownloadTable for user without download CSV permission.")}handleCancelDownloadTable(){var e;(e=this.tableSaver)==null||e.cancelDownload(),this.setState({isTableDownloading:!1})}handleDownloadCompleted(){this.setState({isTableDownloading:!1,tableDownloadProgress:100,tableDownloadStatus:wt.DOWNLOAD_STATUS.FINISHED})}handleDownloadCanceled(){this.setState({isTableDownloading:!1,tableDownloadProgress:0,tableDownloadStatus:wt.DOWNLOAD_STATUS.CANCELED})}deleteRanges(e){const{model:t}=this.props;this.pending.add(t.delete(e)).catch(n=>{He.isCanceled(n)||oe.error("Unable to delete ranges",e,n)})}resetColumnSelection(){if(this.grid==null)return;const{isSelectingColumn:e}=this.props;if(e){const{columnAllowedCursor:t}=this.props;this.grid.setState({cursor:t})}else this.grid.setState({cursor:null}),this.setState({hoverSelectColumn:null})}resetGridViewState(e=!0){!this.grid||(this.grid.clearSelectedRanges(),this.grid.setViewState({left:0,top:0,topOffset:0,leftOffset:0},e))}sendStateChange(){if(!this.grid)return;const{state:e}=this,{state:t}=this.grid,{onStateChange:n}=this.props;n(e,t)}handleOverflowClose(){this.setState({showOverflowModal:!1})}getColumnBoundingRect(){var m;const{metrics:e,shownColumnTooltip:t}=this.state;O(e),O(t);const n=(m=this.gridWrapper)==null?void 0:m.getBoundingClientRect(),s=20;O(n);const{columnHeaderHeight:i,visibleColumnXs:o,visibleColumnWidths:r,width:l,columnHeaderMaxDepth:a}=e,c=o.get(t),d=r.get(t);O(c),O(d);const u=n.left+rt(c+d/2,s,l-s);return{top:n.top+(a-1)*i,left:n.left+rt(c+d/2,s,l-s),bottom:n.top+a*i,right:n.left+rt(c+d/2,s,l-s)+1,width:1,height:i,x:u,y:n.top,toJSON:()=>{throw new Error("not implemented")}}}handleGotoRowSelectedRowNumberSubmit(){const{gotoRow:e}=this.state;this.focusRowInGrid(e)}focusRowInGrid(e){var i,o,r;const{model:t}=this.props,{rowCount:n}=t;if(this.setState({gotoRow:e}),e===""){this.setState({gotoRowError:""});return}const s=parseInt(e,10);s>n||s<-n?this.setState({gotoRowError:"Invalid row index"}):s===0?(this.setState({gotoRowError:""}),(i=this.grid)==null||i.setFocusRow(0)):s<0?(this.setState({gotoRowError:""}),(o=this.grid)==null||o.setFocusRow(s+n)):((r=this.grid)==null||r.setFocusRow(s-1),this.setState({gotoRowError:""}))}handleGotoRowSelectedRowNumberChanged(e){const t=e.target.value;this.focusRowInGrid(t)}getColumnTooltip(e,t,n){const{columnHeaderHeight:s,columnHeaderMaxDepth:i,visibleColumnXs:o,visibleColumnWidths:r,width:l}=t,a=o.get(e),c=r.get(e);if(a==null||c==null)return null;const d=Math.max(0,a);let u=c;a+c>l?u=l-a:a<0&&(u=c-Math.abs(a));const m={position:"absolute",top:(i-1)*s,left:d,width:u,height:s,pointerEvents:"none"},p={clientWidth:1,clientHeight:s,getBoundingClientRect:this.getColumnBoundingRect},g={placement:"bottom",modifiers:{flip:{behavior:["bottom","top"]}}},f=this.getModelColumn(e);if(f==null)return null;const C=n.columns[f];return C==null?null:h("div",{style:m,children:h(ge,{timeout:400,interactive:!0,options:g,ref:this.handleTooltipRef,referenceObject:p,onExited:()=>{this.setState({shownColumnTooltip:null})},children:h(ka,{model:n,column:C,onStatistics:()=>{var b;(b=this.tooltip)==null||b.update()}})},C.name)})}render(){var We,ps,Ir,Mr,Dr,Nr,Fr,xr,Or;const{children:e,customFilters:t,getDownloadWorker:n,isSelectingColumn:s,isStuckToBottom:i,isStuckToRight:o,model:r,name:l,onlyFetchVisibleColumns:a,alwaysFetchColumns:c,advancedSettings:d,onAdvancedSettingsChange:u,canDownloadCsv:m,onCreateChart:p}=this.props,{metricCalculator:g,metrics:f,isFilterBarShown:C,isSelectingPartition:b,isMenuShown:w,isReady:S,copyOperation:I,focusedFilterBarColumn:v,loadingText:R,loadingScrimProgress:M,loadingSpinnerShown:F,keyHandlers:P,mouseHandlers:W,shownColumnTooltip:B,hoverAdvancedFilter:N,shownAdvancedFilter:H,hoverSelectColumn:A,quickFilters:L,advancedFilters:_,partition:V,partitionFilters:G,partitionTable:j,partitionColumn:ee,searchFilter:re,selectDistinctColumns:be,movedColumns:ce,movedRows:Te,formatter:_e,conditionalFormats:Ke,conditionalFormatPreview:Mt,conditionalFormatEditIndex:Xe,sorts:Ze,reverseType:Le,customColumns:Ut,selectedRanges:Bn,isTableDownloading:tn,tableDownloadStatus:tt,tableDownloadProgress:pe,tableDownloadEstimatedTime:ze,showSearchBar:Be,searchValue:ut,selectedSearchColumns:Dt,invertSearchColumns:Nt,aggregationSettings:ht,selectedAggregation:Wn,rollupConfig:Ft,openOptions:xt,pendingSavePromise:zn,pendingSaveError:ao,pendingRowCount:co,pendingDataErrors:uo,pendingDataMap:li,toastMessage:ai,frozenColumns:ci,showOverflowModal:di,overflowText:ui,overflowButtonTooltipProps:hi,isGotoRowShown:mi,gotoRow:ho,gotoRowError:mo}=this.state;if(!S)return null;const $n=this.getTheme(),po=this.getCachedFilter(t,L,_,G,re),ms=g.getUserColumnWidths(),Ps=this.getCachedStateOverride(A,C,s,M,L,_,Ze,Le,Ft,w),pi=f?f.top:0,gi=f?f.bottomViewport:0;let Hs=null,_s=null;a&&(Hs=f?f.left:0,_s=f?f.right:0);const go=f!=null&&f.width>0&&f.height>0,fo=((ps=(We=Ft==null?void 0:Ft.columns)==null?void 0:We.length)!=null?ps:0)>0;let fi=null;const Co=f?Math.min(Math.max(ss.minDebounce,Math.round(f.rowCount/200)),ss.maxDebounce):ss.maxDebounce;if(C&&v!=null&&f!=null){const{gridX:xe,gridY:mt,visibleColumnXs:bn,visibleColumnWidths:Vs}=f,Gn=bn.get(v),Bt=Vs.get(v);if(Gn!=null&&Bt!=null){const pt=xe+Gn,lt=mt-((Ir=$n.filterBarHeight)!=null?Ir:0),nn=Bt+1,qn=((Mr=$n.filterBarHeight)!=null?Mr:0)-1,Kn={top:lt,left:pt,minWidth:nn,height:qn};let gs="",sn=!0;const Xn=this.getModelColumn(v);O(Xn);const Yn=L.get(Xn),Us=_.get(Xn);Yn!=null&&(gs=Yn.text,sn=Yn.filter!=null);const Qn=L.size!==0||_.size!==0;fi=h(Na,{ref:this.filterInputRef,style:Kn,className:$({error:!sn,active:gs!==""||Us!=null,"iris-grid-has-filter":Qn}),isAdvancedFilterSet:Us!=null,onAdvancedFiltersTriggered:()=>{this.setState({shownAdvancedFilter:v})},onChange:this.handleFilterBarChange,onDone:this.handleFilterBarDone,onTab:this.handleFilterBarTab,onContextMenu:(Dr=this.grid)==null?void 0:Dr.handleContextMenu,debounceMs:Co,value:gs},v)}}let Ci=null;if(R!=null){const xe=T("div",{className:"iris-grid-loading-status",children:[h("div",{className:$("iris-grid-loading-status-bar",{show:F}),children:R}),T("button",{type:"button",onClick:this.handleCancel,className:$("iris-grid-btn-cancel",{show:F}),children:[h(K,{icon:ti,transform:"down-1"}),"Cancel"]})]}),mt=f?f.gridY:0;Ci=h("div",{className:"iris-grid-loading",style:{top:mt},children:xe})}let bi=null;B!=null&&f&&(bi=this.getColumnTooltip(B,f,r),(Nr=this.tooltip)==null||Nr.update());const wi=[];if(f&&C){const{gridX:xe,gridY:mt,visibleColumns:bn,visibleColumnXs:Vs,visibleColumnWidths:Gn}=f,{filterBarHeight:Bt}=$n;for(let pt=0;pt<bn.length;pt+=1){const lt=bn[pt],nn=Vs.get(lt),qn=Gn.get(lt),Kn=this.getModelColumn(lt);if(Kn!=null&&r.isFilterable(Kn)&&nn!=null&&qn!=null&&qn>0){const sn=xe+nn+qn-24,Xn=mt-(Bt!=null?Bt:0)+2,Yn={position:"absolute",top:Xn,left:sn},Qn=_.get(Kn)!=null,Ti=lt===N||lt===v||Qn,So=h("div",{className:$("advanced-filter-button-container",{hidden:!Ti}),style:Yn,children:Ti&&h("button",{type:"button",className:$("btn btn-link btn-link-icon advanced-filter-button",{"filter-set":Qn}),onClick:()=>{this.setState({shownAdvancedFilter:lt})},onContextMenu:ac=>{var Ar;(Ar=this.grid)==null||Ar.handleContextMenu(ac)},onMouseEnter:()=>{this.setState({hoverAdvancedFilter:lt})},onMouseLeave:()=>{this.setState({hoverAdvancedFilter:null})},children:T("div",{className:"fa-layers",children:[h(K,{icon:jo,className:"filter-solid"}),h(K,{icon:Vi,className:"filter-light"})]})})},lt);wi.push(So)}}}const Si=[];if(f){const{gridX:xe,visibleColumns:mt,visibleColumnXs:bn,visibleColumnWidths:Vs,columnHeaderHeight:Gn}=f;for(let Bt=0;Bt<mt.length;Bt+=1){const pt=mt[Bt],lt=bn.get(pt),nn=Vs.get(pt);if(lt!=null&&nn!=null&&nn>0){const qn=xe+lt,Kn=xe+lt+nn-20,gs=C?{position:"absolute",top:Gn,left:Kn,width:20,height:$n.filterBarHeight}:{position:"absolute",top:0,left:qn,width:nn,height:Gn},sn=this.getModelColumn(pt);if(sn!=null){const Xn=r.columns[sn],Yn=_.get(sn),{options:Us}=Yn||{},Qn=x.getSortForColumn(r.sort,sn),Ti=Qn?Qn.direction:null,So=h("div",{className:"advanced-filter-menu-container",style:gs,children:h(fn,{className:"advanced-filter-menu-popper",onEntered:this.getAdvancedMenuOpenedHandler(pt),onExited:()=>{this.handleAdvancedMenuClosed(pt)},isShown:H===pt,interactive:!0,closeOnBlur:!0,children:this.getCachedAdvancedFilterMenuActions(r,Xn,Us,Ti,_e)})},pt);Si.push(So)}}}}const vi=this.getCachedOptionItems(p!==void 0&&r.isChartBuilderAvailable,r.isCustomColumnsAvailable,r.isFormatColumnsAvailable,r.isRollupAvailable,r.isTotalsAvailable,r.isSelectDistinctAvailable,r.isExportAvailable,this.toggleFilterBarAction,this.toggleSearchBarAction,this.toggleGotoRowAction,C,Be,m,this.isTableSearchAvailable(),mi),bo=xt.map(xe=>{switch(xe.type){case we.CHART_BUILDER:return h(ba,{model:r,onChange:this.handleChartChange,onSubmit:this.handleChartCreate},we.CHART_BUILDER);case we.VISIBILITY_ORDERING_BUILDER:return h(us,{model:r,movedColumns:ce,userColumnWidths:ms,onColumnVisibilityChanged:this.handleColumnVisibilityChanged,onMovedColumnsChanged:this.handleMovedColumnsChanged},we.VISIBILITY_ORDERING_BUILDER);case we.CONDITIONAL_FORMATTING:return h(Hm,{rules:Ke,onChange:this.handleConditionalFormatsChange,onCreate:this.handleConditionalFormatCreate,onSelect:this.handleConditionalFormatEdit});case we.CONDITIONAL_FORMATTING_EDIT:return O(r.columns),O(this.handleConditionalFormatEditorUpdate),h(dp,{columns:r.columns,rule:Mt,onUpdate:this.handleConditionalFormatEditorUpdate,onSave:this.handleConditionalFormatEditorSave,onCancel:this.handleConditionalFormatEditorCancel});case we.CUSTOM_COLUMN_BUILDER:return h(gr,{model:r,customColumns:Ut,onSave:this.handleUpdateCustomColumns,onCancel:this.handleMenuBack},we.CUSTOM_COLUMN_BUILDER);case we.ROLLUP_ROWS:return h(fr,{model:r,onChange:this.handleRollupChange,config:Ft},we.ROLLUP_ROWS);case we.AGGREGATIONS:return h(Qu,{settings:ht,isRollup:fo,onChange:this.handleAggregationsChange,onEdit:this.handleAggregationEdit});case we.AGGREGATION_EDIT:return Wn&&h(Zu,{aggregation:Wn,columns:r.originalColumns,onChange:this.handleAggregationChange});case we.TABLE_EXPORTER:return h(wt,{model:r,name:l,isDownloading:tn,tableDownloadStatus:tt,tableDownloadProgress:pe,tableDownloadEstimatedTime:ze!=null?ze:void 0,onDownload:this.handleDownloadTable,onDownloadStart:this.handleDownloadTableStart,onCancel:this.handleCancelDownloadTable,selectedRanges:Bn},we.TABLE_EXPORTER);case we.SELECT_DISTINCT:return h(Ha,{model:r,selectDistinctColumns:be,onChange:this.handleSelectDistinctChanged});case we.ADVANCED_SETTINGS:return h(Sr,{items:d,onChange:u});default:throw Error(`Unexpected option type ${xe.type}`)}}),wo=this.getCachedHiddenColumns(ne.getHiddenColumns(ms));return T("div",{className:"iris-grid",role:"presentation",children:[T("div",{className:"iris-grid-column",children:[e!=null&&h("div",{className:"iris-grid-bar",children:e}),h(ot,{in:b,timeout:Rt.transitionSlowMs,classNames:"iris-grid-bar-horizontal",onEnter:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExit:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:"iris-grid-partition-selector-wrapper iris-grid-bar iris-grid-bar-primary",children:j&&ee&&h(Pa,{table:j,getFormattedString:(xe,mt,bn)=>r.displayString(xe,mt,bn),columnName:ee.name,partition:V,onChange:this.handlePartitionChange,onFetchAll:this.handlePartitionFetchAll,onAppend:this.handlePartitionAppend,onDone:this.handlePartitionDone})})}),h(ot,{in:Be,timeout:Rt.transitionSlowMs,classNames:"iris-grid-bar-horizontal",onEnter:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExit:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:"iris-grid-bar",children:h(xi,{value:ut,selectedColumns:Dt,invertSelection:Nt,onChange:this.handleCrossColumnSearch,columns:r.columns,ref:this.crossColumnRef})})}),T("div",{className:"grid-wrapper",ref:xe=>{this.gridWrapper=xe},children:[h(As,{ref:xe=>{this.grid=xe},isStickyBottom:!Ae(r)||!r.isEditable,isStuckToBottom:i,isStuckToRight:o,metricCalculator:g,model:r,keyHandlers:P,mouseHandlers:W,movedColumns:ce,movedRows:Te,onError:this.handleGridError,onViewChanged:this.handleViewChanged,onSelectionChanged:this.handleSelectionChanged,onMovedColumnsChanged:this.handleMovedColumnsChanged,renderer:this.renderer,stateOverride:Ps,theme:$n}),h(Sg,{isOpen:di,text:ui,onClose:this.handleOverflowClose}),go&&h(Oa,{model:r,modelColumns:r.columns,top:pi,bottom:gi,left:Hs,right:_s,filter:po,formatter:_e,sorts:Ze,reverseType:Le,movedColumns:ce,customColumns:Ut,hiddenColumns:wo,alwaysFetchColumns:this.getAlwaysFetchColumns(c,r.columns,ce,r.floatingLeftColumnCount,r.floatingRightColumnCount,(xr=(Fr=this.grid)==null?void 0:Fr.state.draggingColumn)==null?void 0:xr.range),formatColumns:this.getCachedPreviewFormatColumns(this.getCachedModelColumns(r,Ut),Ke,Mt,((Or=xt[xt.length-1])==null?void 0:Or.type)===we.CONDITIONAL_FORMATTING_EDIT&&Xe!=null?Xe:void 0),rollupConfig:this.getModelRollupConfig(r.originalColumns,Ft,ht),totalsConfig:this.getModelTotalsConfig(r.columns,Ft,ht),selectDistinctColumns:be,pendingRowCount:co,pendingDataMap:li,frozenColumns:ci}),!w&&h("div",{className:"grid-settings-button",children:h("button",{type:"button","data-testid":`btn-iris-grid-settings-button-${l}`,className:"btn btn-link btn-link-icon",onClick:this.handleMenu,children:h(K,{icon:bd,transform:"up-1"})})}),fi,Ci,wi,bi,Si,hi&&this.getOverflowButtonTooltip(hi)]}),h(Tg,{model:r,isShown:mi,gotoRow:ho,gotoRowError:mo,onSubmit:this.handleGotoRowSelectedRowNumberSubmit,onGotoRowNumberChanged:this.handleGotoRowSelectedRowNumberChanged,onClose:this.handleGotoRowClosed,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:()=>{this.handleAnimationStart(),this.focus()},onExited:this.handleAnimationEnd}),h(dm,{error:ao,isSaving:zn!=null,saveTooltip:`Commit (${this.commitAction.shortcut.getDisplayText()})`,discardTooltip:`Discard (${this.discardAction.shortcut.getDisplayText()})`,pendingDataErrors:uo,pendingDataMap:li,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd,onSave:this.handlePendingCommitClicked,onDiscard:this.handlePendingDiscardClicked}),h(Rm,{children:ai}),h(Ls,{model:r,copyOperation:I!=null?I:void 0,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd}),h(ks,{ref:xe=>{this.tableSaver=xe},getDownloadWorker:n,onDownloadCompleted:this.handleDownloadCompleted,onDownloadCanceled:this.handleDownloadCanceled,onDownloadProgressUpdate:this.handleDownloadProgressUpdate,isDownloading:tt===wt.DOWNLOAD_STATUS.DOWNLOADING,formatter:_e})]}),h(ot,{in:w,timeout:Rt.transitionMidMs,classNames:"slide-left",onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:"table-sidebar",children:T(bu,{children:[h(Zr,{title:"Table Options",onClose:this.handleMenuClose,children:h(ma,{onSelect:xe=>this.handleMenuSelect(vi[xe]),items:vi})}),bo.map((xe,mt)=>h(Zr,{title:xt[mt].title,onBack:this.handleMenuBack,onClose:this.handleMenuClose,children:xe},xt[mt].type))]})})}),h(se,{actions:this.contextActions})]})}};let ri=ss;ri.minDebounce=150;ri.maxDebounce=500;ri.loadingSpinnerDelay=800;ri.defaultProps={children:null,advancedFilters:new Map,advancedSettings:new Map,alwaysFetchColumns:[],conditionalFormats:[],customColumnFormatMap:new Map,isFilterBarShown:!1,applyInputFiltersOnInit:!1,movedColumns:[],movedRows:[],inputFilters:[],customFilters:[],onCreateChart:void 0,onColumnSelected:()=>{},onDataSelected:()=>{},onError:()=>{},onStateChange:()=>{},onPartitionAppend:()=>{},onAdvancedSettingsChange:()=>{},partition:null,partitionColumn:null,quickFilters:new Map,selectDistinctColumns:[],sorts:[],reverseType:x.REVERSE_TYPE.NONE,customColumns:[],aggregationSettings:ic,rollupConfig:void 0,userColumnWidths:new Map,userRowHeights:new Map,onSelectionChanged:()=>{},isSelectingColumn:!1,isSelectingPartition:!1,isStuckToBottom:!1,isStuckToRight:!1,columnSelectionValidator:null,columnAllowedCursor:null,columnNotAllowedCursor:null,name:"table",onlyFetchVisibleColumns:!0,showSearchBar:!1,searchValue:"",selectedSearchColumns:null,invertSearchColumns:!0,onContextMenu:()=>{},pendingDataMap:new Map,getDownloadWorker:void 0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:Hn.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,truncateNumbersWithPound:!1,formatter:[],decimalFormatOptions:D.exports.shape({defaultFormatString:D.exports.string}),integerFormatOptions:D.exports.shape({defaultFormatString:D.exports.string})},canCopy:!0,canDownloadCsv:!0,frozenColumns:null,theme:Aa,canToggleSearch:!0};class Ig extends Error{constructor(t,n){super(`${n} can't be empty (on pending row ${t+1})`),this.isMissingKey=!0,this.rowIndex=t,this.columnName=n}}const Mg=J.module("ColumnHeaderGroup");function xl(e){return e instanceof oc}class oc{constructor({name:t,children:n,color:s,depth:i,childIndexes:o}){this.getVisibleRange=Ie(r=>{const l=this.childIndexes.flat(),a=U.getVisibleIndexes(l,r),c=Math.min(...a),d=Math.max(...a);return d-c!==l.length-1&&Mg.warn(`Column header group ${this.name} is not contiguous`),[c,d]}),this.name=t,this.children=n,this.color=s,this.depth=i,this.childIndexes=o}}const Pe=J.module("IrisGridTableModel"),Dg=150,Ng=0;function ki(e){return e.table!==void 0}const Go=class extends ue{constructor(e,t=new jt,n=null){super(),this.pendingNewRowCount=0,this.columnHeaderGroupMap=new Map,this.columnHeaderParentMap=new Map,this._columnHeaderMaxDepth=null,this._columnHeaderGroups=[],this.getMemoizedColumnMap=Ie(s=>{const i=new Map;return s.forEach(o=>i.set(o.name,o)),i}),this.getColumnIndicesByNameMap=Ie(s=>{const i=new Map;return s.forEach(({name:o},r)=>i.set(o,r)),i}),this.setViewport=cs((s,i,o)=>{if(i<s){Pe.error("Invalid viewport",s,i);return}const{viewport:r}=this;if(r!=null&&r.top===s&&r.bottom===i&&r.columns===o){Pe.debug2("Ignoring duplicate viewport",r);return}this.viewport={top:s,bottom:i,columns:o},Pe.debug2("setViewport",this.viewport),this.applyViewport()},Dg),this.applyViewport=cs(()=>{if(!this.viewport)return;Pe.debug2("applyViewport",this.viewport);const{top:s,bottom:i,columns:o}=this.viewport,[r,l]=this.getCachedViewportRowRange(s,i);this.applyBufferedViewport(r,l,o)},Ng,{leading:!1}),this.getCachedFormattedString=St((s,i,o,r,l)=>s.getFormattedString(i,o,r,l),{max:1e4}),this.getCachedCustomColumnFormatFlag=St(ls.isCustomColumnFormatDefined,{max:1e4}),this.getCachedViewportRowRange=Ie((s,i)=>{const o=i-s,r=Math.max(0,s-o*Go.ROW_BUFFER_PAGES),l=i+o*Go.ROW_BUFFER_PAGES;return[r,l]}),this.getCachedPendingErrors=Ie((s,i,o)=>{const r=new Map;return s.forEach((l,a)=>{var d;const{data:c}=l;for(let u=0;u<o;u+=1)c.has(u)||(r.has(a)||r.set(a,[]),(d=r.get(a))==null||d.push(new Ig(a,i[u].name)))}),r}),this.handleTableDisconnect=this.handleTableDisconnect.bind(this),this.handleTableReconnect=this.handleTableReconnect.bind(this),this.handleTableUpdate=this.handleTableUpdate.bind(this),this.handleTotalsUpdate=this.handleTotalsUpdate.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.handleCustomColumnsChanged=this.handleCustomColumnsChanged.bind(this),this.irisFormatter=t,this.inputTable=n,this.subscription=null,this.table=e,this.viewport=null,this.viewportData=null,this.formattedStringData=[],this.pendingStringData=[],this.isSaveInProgress=!1,this.totalsTable=null,this.totalsTablePromise=null,this.totals=null,this.totalsDataMap=null,this.pendingNewDataMap=new Map,this.pendingNewDataErrors=null,this.pendingNewRowCount=0}export(){throw new Error("Method not implemented.")}columnStatistics(e){throw new Error("Method not implemented.")}get customColumns(){return[]}set customColumns(e){throw new Error("Method not implemented.")}get formatColumns(){return[]}set formatColumns(e){throw new Error("Method not implemented.")}updateFrozenColumns(e){throw new Error("Method not implemented.")}get rollupConfig(){throw new Error("Method not implemented.")}set rollupConfig(e){throw new Error("Method not implemented.")}get selectDistinctColumns(){throw new Error("Method not implemented.")}set selectDistinctColumns(e){throw new Error("Method not implemented.")}get columns(){return this.table.columns}close(){this.table.close(),this.totalsTable!==null&&this.totalsTable.close(),this.totalsTablePromise!==null&&this.totalsTablePromise.cancel()}startListening(){super.startListening(),this.table.addEventListener(E.Table.EVENT_DISCONNECT,this.handleTableDisconnect),this.table.addEventListener(E.Table.EVENT_RECONNECT,this.handleTableReconnect),this.table.addEventListener(E.Table.EVENT_UPDATED,this.handleTableUpdate),this.table.addEventListener(E.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed),this.table.addEventListener(E.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleCustomColumnsChanged),this.totalsTable!=null&&this.addTotalsListeners(this.totalsTable),this.applyViewport()}stopListening(){super.stopListening(),this.table.removeEventListener(E.Table.EVENT_DISCONNECT,this.handleTableDisconnect),this.table.removeEventListener(E.Table.EVENT_RECONNECT,this.handleTableReconnect),this.table.removeEventListener(E.Table.EVENT_UPDATED,this.handleTableUpdate),this.table.removeEventListener(E.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed),this.table.removeEventListener(E.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleCustomColumnsChanged),this.totalsTable!=null&&this.removeTotalsListeners(this.totalsTable),this.closeSubscription()}addTotalsListeners(e){e.addEventListener(E.Table.EVENT_UPDATED,this.handleTotalsUpdate),e.setViewport(0,0)}removeTotalsListeners(e){e.removeEventListener(E.Table.EVENT_UPDATED,this.handleTotalsUpdate)}handleTableDisconnect(){this.dispatchEvent(new Re(ue.EVENT.DISCONNECT))}handleTableReconnect(){this.dispatchEvent(new Re(ue.EVENT.RECONNECT))}handleTableUpdate(e){this.copyViewportData(e.detail),this.dispatchEvent(new Re(ue.EVENT.UPDATED))}handleTotalsUpdate(e){this.copyTotalsData(e.detail),this.dispatchEvent(new Re(ue.EVENT.UPDATED))}handleRequestFailed(e){this.dispatchEvent(new Re(ue.EVENT.REQUEST_FAILED,e))}handleCustomColumnsChanged(){this.dispatchEvent(new Re(ue.EVENT.COLUMNS_CHANGED,{detail:this.columns}))}get rowCount(){var e,t,n;return this.table.size+this.pendingNewRowCount+((n=(t=(e=this.totals)==null?void 0:e.operationOrder)==null?void 0:t.length)!=null?n:0)}get pendingDataErrors(){var e,t;return this.getCachedPendingErrors(this.pendingNewDataMap,this.columns,(t=(e=this.inputTable)==null?void 0:e.keyColumns.length)!=null?t:0)}get pendingDataMap(){return this.pendingNewDataMap}set pendingDataMap(e){e!==this.pendingNewDataMap&&(e.forEach((t,n)=>{if(!ne.isValidIndex(n))throw new Error(`Invalid rowIndex ${n}`);const{data:s}=t;s.forEach((i,o)=>{if(!ne.isValidIndex(o))throw new Error(`Invalid columnIndex ${o}`)})}),this.pendingNewDataMap=e,this.pendingNewRowCount=Math.max(this.pendingNewRowCount,this.maxPendingDataRow),this.formattedStringData=[],this.dispatchEvent(new Re(ue.EVENT.PENDING_DATA_UPDATED)))}get pendingRowCount(){return this.pendingNewRowCount}set pendingRowCount(e){e!==this.pendingNewRowCount&&(this.pendingNewRowCount=Math.max(0,e,this.maxPendingDataRow),this.dispatchEvent(new Re(ue.EVENT.UPDATED)))}get maxPendingDataRow(){return this.pendingNewDataMap.size>0?Math.max(...this.pendingNewDataMap.keys())+1:0}get columnCount(){return this.columns.length}get floatingBottomRowCount(){var e,t,n;return this.totals!=null&&this.totals.showOnTop?0:(n=(t=(e=this.totals)==null?void 0:e.operationOrder)==null?void 0:t.length)!=null?n:0}get floatingTopRowCount(){var e,t,n;return this.totals!=null&&this.totals.showOnTop&&(n=(t=(e=this.totals)==null?void 0:e.operationOrder)==null?void 0:t.length)!=null?n:0}get isChartBuilderAvailable(){return!0}get isTotalsAvailable(){return this.table.getTotalsTable!=null}get isEditable(){return!this.isSaveInProgress&&this.inputTable!=null}cacheFormattedValue(e,t,n){this.formattedStringData[e]==null&&(this.formattedStringData[e]=[]),this.formattedStringData[e][t]=n}cachePendingValue(e,t,n){this.pendingStringData[e]==null&&(this.pendingStringData[e]=[]),this.pendingStringData[e][t]=n}clearPendingValue(e,t){const n=this.pendingStringData[e];n!=null&&delete n[t]}textValueForCell(e,t){var n,s,i;if(((n=this.pendingStringData[e])==null?void 0:n[t])!==void 0)return this.pendingStringData[e][t];if(((s=this.formattedStringData[e])==null?void 0:s[t])===void 0){const o=this.valueForCell(e,t);if(o==null)return null;const r=(i=this.totalsColumn(e,t))!=null?i:this.columns[e],l=this.getCachedCustomColumnFormatFlag(this.formatter,r.name,r.type);let a;if(!l){const d=this.formatForCell(e,t);(d==null?void 0:d.formatString)!=null&&(a=d)}const c=this.displayString(o,r.type,r.name,a);this.cacheFormattedValue(e,t,c)}return this.formattedStringData[e][t]}textForCell(e,t){const n=this.textValueForCell(e,t);if(n==null&&this.isKeyColumn(e)){const s=this.pendingRow(t);if(s!=null&&this.pendingDataMap.has(s))return"*"}return n!=null?n:""}truncationCharForCell(e){const t=this.columns[e],{type:n}=t;if(x.isNumberType(n)&&this.formatter.truncateNumbersWithPound)return"#"}colorForCell(e,t,n){var i;const s=this.dataForCell(e,t);if(s){const{format:o,value:r}=s;if(r==null||r==="")return O(n.nullStringColor),n.nullStringColor;if(o&&o.color)return o.color;if(this.isPendingRow(t))return O(n.pendingTextColor),n.pendingTextColor;if(r!=null){const l=(i=this.totalsColumn(e,t))!=null?i:this.columns[e];if(x.isDateType(l.type)||l.name==="Date")return O(n.dateColor),n.dateColor;if(x.isNumberType(l.type))return r>0?(O(n.positiveNumberColor),n.positiveNumberColor):r<0?(O(n.negativeNumberColor),n.negativeNumberColor):(O(n.zeroNumberColor),n.zeroNumberColor)}}else if(this.isPendingRow(t)&&this.isKeyColumn(e))return O(n.errorTextColor),n.errorTextColor;return n.textColor}backgroundColorForCell(e,t){var n,s;return(s=(n=this.formatForCell(e,t))==null?void 0:n.backgroundColor)!=null?s:null}textAlignForCell(e){const t=this.columns[e],{type:n}=t;return x.isNumberType(n)?"right":x.isDateType(n)||t.name==="Date"?"center":"left"}textForColumnHeader(e,t=0){var n,s;return(s=(n=this.columnAtDepth(e,t))==null?void 0:n.name)!=null?s:void 0}colorForColumnHeader(e,t=0){var s;const n=this.columnAtDepth(e,t);return xl(n)&&(s=n.color)!=null?s:null}getColumnHeaderGroup(e,t){const n=this.columnAtDepth(e,t);if(xl(n))return n}getColumnHeaderParentGroup(e,t){var n,s;return this.columnHeaderParentMap.get((s=(n=this.columnAtDepth(e,t))==null?void 0:n.name)!=null?s:"")}columnAtDepth(e,t=0){var o;if(t===0)return this.columns[e];const n=(o=this.columns[e])==null?void 0:o.name;let s=this.columnHeaderParentMap.get(n);if(!s)return;let i=s.depth;for(;i<t;){if(s=this.columnHeaderParentMap.get(s.name),!s)return;i=s.depth}if(s.depth===t)return s}textForRowFooter(e){const t=this.totalsRow(e);return t!=null&&this.totals?this.totals.operationOrder[t]:""}get movedColumns(){var i;let e=[];const t=(o,r)=>{const l=this.getColumnIndexByName(o);if(l==null)throw new Error(`Unknown layout hint column: ${o}`);const a=U.getVisibleIndex(l,e);e=U.moveItem(a,r,e)},n=(o,r)=>{const l=this.columnHeaderGroupMap.get(o);if(!l)throw new Error(`Unknown layout hint group: ${o}`);const a=l.getVisibleRange(e);e=U.moveRange(a,r,e)};if(this.frontColumns.length||this.backColumns.length||this.frozenColumns.length){const o=new Set;let r=0;this.frozenColumns.forEach(a=>{if(o.has(a))throw new Error(`Column specified in multiple layout hints: ${a}`);t(a,r),r+=1}),this.frontColumns.forEach(a=>{if(o.has(a))throw new Error(`Column specified in multiple layout hints: ${a}`);t(a,r),r+=1});let l=this.columnMap.size-1;this.backColumns.forEach(a=>{if(o.has(a))throw new Error(`Column specified in multiple layout hints: ${a}`);t(a,l),l-=1})}const s=(i=this.layoutHints)==null?void 0:i.columnGroups;if(s){this.setColumnHeaderGroups(s);const o=[...this.columnHeaderGroupMap.values()];o.sort((r,l)=>r.depth-l.depth),o.forEach(r=>{const l=r.children[0],a=this.getColumnIndexByName(l);let c;if(a!=null)c=U.getVisibleIndex(a,e);else{const d=this.columnHeaderGroupMap.get(l);if(!d)throw new Error(`Unknown column ${l} in group ${r.name}`);[,c]=d.getVisibleRange(e)}for(let d=1;d<r.children.length;d+=1){const u=r.children[d],m=this.columnHeaderGroupMap.get(u),p=this.getColumnIndexByName(u);if(m){const f=m.getVisibleRange(e)[0]<c?c-m.childIndexes.length+1:c+1;n(u,f),c=f+m.childIndexes.length-1}else if(p!=null){const f=U.getVisibleIndex(p,e)<c?c:c+1;t(u,f),c=f}}})}return e}get columnMap(){return this.getMemoizedColumnMap(this.table.columns)}get columnHeaderMaxDepth(){var e,t;return this._columnHeaderMaxDepth==null&&this.setColumnHeaderGroups((e=this.layoutHints)==null?void 0:e.columnGroups),(t=this._columnHeaderMaxDepth)!=null?t:1}set columnHeaderMaxDepth(e){this._columnHeaderMaxDepth=e}setColumnHeaderGroups(e){if(e===this._columnHeaderGroups||(this._columnHeaderGroups=e!=null?e:[],this.columnHeaderMaxDepth=1,this.columnHeaderParentMap=new Map,this.columnHeaderGroupMap=new Map,!e||e.length===0))return;const t=new Map(e.map(o=>[o.name,o])),n=new Set,s=o=>{const{name:r}=o;if(this.getColumnIndexByName(r)!=null)throw new Error(`Column header group has same name as column: ${r}`);const l=this.columnHeaderGroupMap.get(r);if(l)return l;const a=[];let c=1;o.children.forEach(u=>{if(n.has(u))throw new Error(`Column group child ${u} specified in multiple groups`);n.add(u);const m=t.get(u),p=this.getColumnIndexByName(u);if(m){const g=s(m);a.push(g.childIndexes.flat()),c=Math.max(c,g.depth+1)}else if(p!=null)a.push(p),c=Math.max(c,1);else throw new Error(`Unknown child ${u} in group ${r}`)});const d=new oc({...o,depth:c,childIndexes:a});return this.columnHeaderGroupMap.set(r,d),o.children.forEach(u=>this.columnHeaderParentMap.set(u,d)),this.columnHeaderMaxDepth=Math.max(this.columnHeaderMaxDepth,d.depth+1),d},i=new Set;e.forEach(o=>{const{name:r}=o;if(i.has(r))throw new Error(`Duplicate column group name: ${r}`);i.add(r),s(o)})}get groupedColumns(){return[]}row(e){var l,a,c,d,u,m,p,g,f,C,b,w,S,I;const t=(c=(a=(l=this.totals)==null?void 0:l.operationOrder)==null?void 0:a.length)!=null?c:0,n=(u=(d=this.totals)==null?void 0:d.showOnTop)!=null?u:!1,s=this.totalsRow(e);if(s!=null){const v=(m=this.totals)==null?void 0:m.operationOrder[s];return O(v),(g=(p=this.totalsDataMap)==null?void 0:p.get(v))!=null?g:null}const i=this.pendingRow(e);if(i!=null)return(f=this.pendingNewDataMap.get(i))!=null?f:null;const o=(b=(C=this.viewportData)==null?void 0:C.offset)!=null?b:0,r=(n?e-t:e)-o;return(I=(S=(w=this.viewportData)==null?void 0:w.rows)==null?void 0:S[r])!=null?I:null}totalsColumn(e,t){var r,l,a,c;const n=this.totalsRow(t);if(n==null)return null;const s=(r=this.totals)==null?void 0:r.operationOrder[n],i=(a=(l=this.totals)==null?void 0:l.defaultOperation)!=null?a:Se.SUM,o=this.columns[e];return(c=this.totalsTable)==null?void 0:c.columns.find(d=>{var u;return d.name===`${o.name}__${s}`||(s===i||((u=this.totals)==null?void 0:u.operationOrder.length)===1)&&d.name===o.name})}totalsRow(e){var i,o,r,l,a;const t=(r=(o=(i=this.totals)==null?void 0:i.operationOrder)==null?void 0:o.length)!=null?r:0,s=((a=(l=this.totals)==null?void 0:l.showOnTop)!=null?a:!1)?e:e-this.table.size;return s>=0&&s<t?s:null}pendingRow(e){const t=e-this.floatingTopRowCount-this.table.size;return t>=0&&t<this.pendingNewRowCount?t:null}isTotalsRow(e){return this.totalsRow(e)!=null}isPendingRow(e){return this.pendingRow(e)!=null}dataForCell(e,t){var n;return(n=this.row(t))==null?void 0:n.data.get(e)}formatForCell(e,t){var n;return(n=this.dataForCell(e,t))==null?void 0:n.format}valueForCell(e,t){var s;const n=this.dataForCell(e,t);if(n)return(s=n.value)!=null?s:null}copyViewportData(e){if(e==null){Pe.warn("invalid data!");return}this.viewportData=this.extractViewportData(e),this.formattedStringData=[]}copyTotalsData(e){var l,a,c,d,u;if(e==null){Pe.warn("invalid data!");return}const{columns:t,rows:n}=e;if(n.length!==1){Pe.error("Unexpected number of rows received for totals table, ignoring update");return}const s=new Map,i=n[0],o=(a=(l=this.totals)==null?void 0:l.defaultOperation)!=null?a:Se.SUM,r=(c=this.totals)==null?void 0:c.operationMap;for(let m=0;m<t.length;m+=1){const p=t[m],[g,f=(u=(d=r==null?void 0:r[g])==null?void 0:d[0])!=null?u:o]=p.name.split("__");s.has(f)||s.set(f,{data:new Map});const{data:C}=s.get(f),b=this.columns.findIndex(w=>w.name===g);C.set(b,{value:i.get(p),format:i.getFormat(p)})}Pe.debug2("copyTotalsData",s),this.totalsDataMap=s,this.formattedStringData=[]}getColumnIndexByName(e){return this.getColumnIndicesByNameMap(this.columns).get(e)}extractViewportData(e){const t={offset:e.offset,rows:[]},{columns:n}=e;for(let s=0;s<e.rows.length;s+=1){const i=e.rows[s],o=this.extractViewportRow(i,n);t.rows.push(o)}return t}extractViewportRow(e,t){const n=new Map;for(let s=0;s<t.length;s+=1){const i=t[s],o=this.getColumnIndexByName(i.name);O(o),n.set(o,{value:e.get(i),format:e.getFormat(i)})}return{data:n}}closeSubscription(){Pe.debug2("closeSubscription",this.subscription),this.subscription&&(this.subscription.close(),this.subscription=null),this.setViewport.cancel(),this.applyViewport.cancel()}get filter(){return this.table.filter}set filter(e){this.closeSubscription(),this.table.applyFilter(e),this.applyViewport()}get formatter(){return this.irisFormatter}set formatter(e){this.irisFormatter=e,this.formattedStringData=[],this.dispatchEvent(new Re(ue.EVENT.FORMATTER_UPDATED))}displayString(e,t,n="",s){return this.getCachedFormattedString(this.formatter,e,t,n,s)}get sort(){return this.table.sort}set sort(e){this.closeSubscription(),this.table.applySort(e),this.applyViewport()}set totalsConfig(e){if(Pe.debug("set totalsConfig",e),e!==this.totals){if(this.totals=e,this.formattedStringData=[],this.totalsTablePromise!=null&&this.totalsTablePromise.cancel(),this.setTotalsTable(null),e==null){this.dispatchEvent(new Re(ue.EVENT.UPDATED));return}this.totalsTablePromise=He.makeCancelable(this.table.getTotalsTable(e),t=>t.close()),this.totalsTablePromise.then(t=>{this.totalsTablePromise=null,this.setTotalsTable(t)}).catch(t=>{He.isCanceled(t)||(Pe.error("Unable to set next totalsTable",t),this.totalsTablePromise=null,this.dispatchEvent(new Re(ue.EVENT.REQUEST_FAILED,{detail:t})))})}}setTotalsTable(e){Pe.debug("setTotalsTable",e),this.totalsTable!==null&&(this.listenerCount>0&&this.removeTotalsListeners(this.totalsTable),this.totalsTable.close()),this.totalsTable=e,this.totalsDataMap=null,this.listenerCount>0&&this.totalsTable!=null&&this.addTotalsListeners(this.totalsTable)}applyBufferedViewport(e,t,n){Pe.debug2("applyBufferedViewport",e,t,n),this.subscription==null?(Pe.debug2("applyBufferedViewport creating new subscription"),this.subscription=this.table.setViewport(e,t,n)):(Pe.debug2("applyBufferedViewport using existing subscription"),this.subscription.setViewport(e,t,n))}async snapshot(e,t=!1,n=s=>s){if(this.subscription==null)throw new Error("No subscription available");const s=Z.consolidate(e);if(!ne.isValidSnapshotRanges(s))throw new Error(`Invalid snapshot ranges ${e}`);const i=new Set,o=[],r=new Set;for(let u=0;u<s.length;u+=1){const m=s[u];O(m.endRow),O(m.startRow);for(let p=m.startRow;p<=m.endRow&&p<this.floatingTopRowCount;p+=1)i.add(p);m.endRow>=this.floatingTopRowCount&&m.startRow<=this.floatingTopRowCount+this.table.size&&o.push(new Z(m.startColumn,Math.min(Math.max(0,m.startRow-this.floatingTopRowCount)),m.endColumn,Math.min(Math.max(0,m.endRow-this.floatingTopRowCount),this.table.size-this.floatingTopRowCount)));for(let p=Math.max(m.startRow,this.floatingTopRowCount+this.table.size);p<=m.endRow&&p<this.floatingTopRowCount+this.table.size+this.floatingBottomRowCount;p+=1)r.add(p)}const l=ne.columnsFromRanges(s,this.columns),a=[];t&&a.push(l.map(u=>u.name));const c=[...i].sort();for(let u=0;u<c.length;u+=1){const m=c[u],p=l.map(g=>{const f=this.getColumnIndexByName(g.name);return O(f),n(this.valueForCell(f,m),g)});t&&p.push(this.textForRowFooter(m)),a.push(p)}if(o.length>0){const u=ne.rangeSetFromRanges(o),m=await this.subscription.snapshot(u,l);a.push(...m.rows.map(p=>l.map(g=>n(p.get(g),g))))}const d=[...r].sort();for(let u=0;u<d.length;u+=1){const m=d[u],p=l.map(g=>{const f=this.getColumnIndexByName(g.name);return O(f),n(this.valueForCell(f,m),g)});t&&p.push(this.textForRowFooter(m)),a.push(p)}return a}async textSnapshot(e,t=!1,n=s=>`${s}`){return Pe.debug2("textSnapshot",e,t),(await this.snapshot(e,t,n)).map(i=>i.join(" ")).join(`
30
+ `)}this.bufferedMessages=[],this.appendLogText(e)}queue(e){this.bufferedMessages.push(e),this.bufferedMessages.length===1&&(this.flushTimer=setTimeout(this.handleFlushTimeout,st.bufferTimeout))}stopFlushTimer(){this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=void 0)}updateDimensions(){this.editor&&this.editor.layout()}handleClearClick(){this.clearLogs()}clearLogs(){this.messages=[],this.refreshLogText()}handleFlushTimeout(){this.stopFlushTimer(),this.flush()}handleLogMessage(e){this.messages.push(e),this.editor&&this.isLogItemVisible(e)&&this.queue(e)}handleMenuItemClick(e){this.toggleLogLevel(e)}handleResetClick(){this.resetLogLevels()}handleResize(){this.updateDimensions()}handleToggleAllClick(){this.toggleAll()}render(){const e={placement:"bottom-end"},{shownLogLevels:t}=this.state,n=this.getMenuActions(t);return T("div",{className:"log-pane h-100 w-100",children:[T("div",{className:"log-pane-menu",children:[h(me,{kind:"ghost",className:"btn-clear-logs",onClick:this.handleClearClick,icon:Wd,tooltip:"Clear log"}),h(me,{kind:"ghost",className:"btn-link-icon btn-overflow",icon:hd,tooltip:"Log Settings",onClick:()=>{},children:h(Ln,{actions:n,popperClassName:"log-level-menu-popper",popperOptions:e})})]}),h("div",{className:"log-pane-editor h-100 w-100",ref:s=>{this.editorContainer=s}})]})}};let oi=st;oi.DefaultLogLevels=[Ye.STDOUT,Ye.ERROR,Ye.FATAL,Ye.STDERR,Ye.WARN];oi.AllLogLevels=[Ye.INFO,Ye.STDOUT,Ye.ERROR,Ye.FATAL,Ye.STDERR,Ye.WARN,Ye.DEBUG,Ye.TRACE];oi.bufferTimeout=16;oi.maxLogSize=131072;oi.truncateSize=65536;_i.register([gc,fc,Cc,bc,wc,Sc]);const rg=typeof vo=="function"?vo(_i):vo.default(_i),hn=class{constructor(){this.listeners=[],this.isDownsamplingDisabled=!1}getData(){return[]}getDefaultTitle(){return""}getLayout(){return{}}getFilterColumnMap(){return new Map}isFilterRequired(){return!1}setFilter(e){}close(){}setFormatter(e){this.formatter=e}setDownsamplingDisabled(e){this.isDownsamplingDisabled=e}setDimensions(e){this.rect=e}setTitle(e){this.title=e}subscribe(e){this.listeners.push(e)}unsubscribe(e){this.listeners=this.listeners.filter(t=>t!==e)}fireEvent(e){for(let t=0;t<this.listeners.length;t+=1)this.listeners[t](e)}fireUpdate(e){this.fireEvent(new CustomEvent(hn.EVENT_UPDATED,{detail:e}))}fireDisconnect(){this.fireEvent(new CustomEvent(hn.EVENT_DISCONNECT))}fireReconnect(){this.fireEvent(new CustomEvent(hn.EVENT_RECONNECT))}fireDownsampleStart(e){this.fireEvent(new CustomEvent(hn.EVENT_DOWNSAMPLESTARTED,{detail:e}))}fireDownsampleFinish(e){this.fireEvent(new CustomEvent(hn.EVENT_DOWNSAMPLEFINISHED,{detail:e}))}fireDownsampleFail(e){this.fireEvent(new CustomEvent(hn.EVENT_DOWNSAMPLEFAILED,{detail:e}))}fireDownsampleNeeded(e){this.fireEvent(new CustomEvent(hn.EVENT_DOWNSAMPLENEEDED,{detail:e}))}fireLoadFinished(){this.fireEvent(new CustomEvent(hn.EVENT_LOADFINISHED))}};let Qe=hn;Qe.EVENT_UPDATED="ChartModel.EVENT_UPDATED";Qe.EVENT_DISCONNECT="ChartModel.EVENT_DISCONNECT";Qe.EVENT_RECONNECT="ChartModel.EVENT_RECONNECT";Qe.EVENT_DOWNSAMPLESTARTED="ChartModel.EVENT_DOWNSAMPLESTARTED";Qe.EVENT_DOWNSAMPLEFINISHED="ChartModel.EVENT_DOWNSAMPLEFINISHED";Qe.EVENT_DOWNSAMPLEFAILED="ChartModel.EVENT_DOWNSAMPLEFAILED";Qe.EVENT_DOWNSAMPLENEEDED="ChartModel.EVENT_DOWNSAMPLENEEDED";Qe.EVENT_LOADFINISHED="ChartModel.EVENT_LOADFINISHED";const lg="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",ag="#403e41",cg="#5b5a5c",dg="#c0bfbf",ug="#4878ea",hg="rgba(91, 90, 92, 0.7)",Je={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:lg,gridcolor:ag,linecolor:cg,zerolinecolor:dg,activecolor:ug,rangebgcolor:hg,"area-color":"#76d9e4","trend-color":"#d5f0c1","line-color":"#9edc6f","error-band-line-color":"white","error-band-fill-color":"rgba(213, 240, 193, 0.1)","ohlc-increasing":"#9edc6f","ohlc-decreasing":"#f95d84"},Fn=Object.freeze({paper_bgcolor:Je["paper-bgcolor"],plot_bgcolor:Je["plot-bgcolor"],title_color:Je["title-color"],colorway:Je.colorway,gridcolor:Je.gridcolor,linecolor:Je.linecolor,zerolinecolor:Je.zerolinecolor,activecolor:Je.activecolor,rangebgcolor:Je.rangebgcolor,area_color:Je["area-color"],trend_color:Je["trend-color"],line_color:Je["line-color"],error_band_line_color:Je["error-band-line-color"],error_band_fill_color:Je["error-band-fill-color"],ohlc_increasing:Je["ohlc-increasing"],ohlc_decreasing:Je["ohlc-decreasing"]}),Ai=J.module("ChartUtils"),yn=Object.freeze(E.calendar.DayOfWeek.values()),Dl="io.deephaven.time.DateTime",mg=36e5,pg=1e6;function gg(e){return e.asDate!==void 0}function fg(e){return e.asNumber!==void 0}function Nl(e){return e.dhTimeZone!==void 0}function Cg(e){return e!=null&&e.range&&(e.autorange===!1||e.autorange===void 0)}const Y=class{static getPlotlyChartType(e,t){switch(e){case E.plot.SeriesPlotStyle.SCATTER:return t?"scatter":"scattergl";case E.plot.SeriesPlotStyle.LINE:return"scatter";case E.plot.SeriesPlotStyle.BAR:case E.plot.SeriesPlotStyle.STACKED_BAR:return"bar";case E.plot.SeriesPlotStyle.PIE:return"pie";case E.plot.SeriesPlotStyle.TREEMAP:return"treemap";case E.plot.SeriesPlotStyle.HISTOGRAM:return"histogram";case E.plot.SeriesPlotStyle.OHLC:return"ohlc";default:return}}static getPlotlyChartMode(e){switch(e){case E.plot.SeriesPlotStyle.SCATTER:return"markers";case E.plot.SeriesPlotStyle.LINE:return"lines";default:return}}static getPlotlyProperty(e,t){switch(e){case E.plot.SeriesPlotStyle.PIE:switch(t){case E.plot.SourceType.X:return"labels";case E.plot.SourceType.Y:return"values"}break;case E.plot.SeriesPlotStyle.OHLC:switch(t){case E.plot.SourceType.TIME:return"x"}break;case E.plot.SeriesPlotStyle.TREEMAP:switch(t){case E.plot.SourceType.X:return"ids";case E.plot.SourceType.Y:return"values";case E.plot.SourceType.LABEL:return"labels";case E.plot.SourceType.PARENT:return"parents";case E.plot.SourceType.COLOR:return"marker.colors"}break}switch(t){case E.plot.SourceType.X:return"x";case E.plot.SourceType.Y:return"y";case E.plot.SourceType.Z:return"z";case E.plot.SourceType.X_LOW:return"xLow";case E.plot.SourceType.X_HIGH:return"xHigh";case E.plot.SourceType.Y_LOW:return"yLow";case E.plot.SourceType.Y_HIGH:return"yHigh";case E.plot.SourceType.TIME:return"time";case E.plot.SourceType.OPEN:return"open";case E.plot.SourceType.HIGH:return"high";case E.plot.SourceType.LOW:return"low";case E.plot.SourceType.CLOSE:return"close";case E.plot.SourceType.SHAPE:return"shape";case E.plot.SourceType.SIZE:return"size";case E.plot.SourceType.LABEL:return"label";case E.plot.SourceType.COLOR:return"color";case E.plot.SourceType.PARENT:return"parent";case E.plot.SourceType.HOVER_TEXT:return"hovertext";case E.plot.SourceType.TEXT:return"text";default:throw new Error(`Unrecognized source type: ${t}`)}}static getPlotlySeriesOrientation(e){var n,s;const{sources:t}=e;return t.length===2&&((s=(n=t[0])==null?void 0:n.axis)==null?void 0:s.type)===E.plot.AxisType.Y?Y.ORIENTATION.HORIZONTAL:Y.ORIENTATION.VERTICAL}static getPlotlyErrorBars(e,t,n){const s=n.map((o,r)=>o-e[r]),i=t.map((o,r)=>e[r]-o);return{type:"data",symmetric:!1,array:s,arrayminus:i}}static getPlotlyDateFormat(e,t,n){const s=n==null?void 0:n.replace("%","%%").replace(/S{9}/g,"%9f").replace(/S{8}/g,"%8f").replace(/S{7}/g,"%7f").replace(/S{6}/g,"%6f").replace(/S{5}/g,"%5f").replace(/S{4}/g,"%4f").replace(/S{3}/g,"%3f").replace(/S{2}/g,"%2f").replace(/S{1}/g,"%1f").replace(/y{4}/g,"%Y").replace(/y{2}/g,"%y").replace(/M{4}/g,"%B").replace(/M{3}/g,"%b").replace(/M{2}/g,"%m").replace(/M{1}/g,"%-m").replace(/E{4,}/g,"%A").replace(/E{1,}/g,"%a").replace(/d{2}/g,"%d").replace(/([^%]|^)d{1}/g,"$1%-d").replace(/H{2}/g,"%H").replace(/h{2}/g,"%I").replace(/h{1}/g,"%-I").replace(/m{2}/g,"%M").replace(/s{2}/g,"%S").replace("'T'","T").replace(" z","");let i;const o=e==null?void 0:e.getColumnTypeFormatter(t);return o!=null&&Nl(o)&&o.dhTimeZone!=null&&o.showTimeZone&&(i=E.i18n.DateTimeFormat.format(" z",new Date,o.dhTimeZone)),{tickformat:s,ticksuffix:i,automargin:!0}}static convertNumberPrefix(e){return e.replace(/\u00A4\u00A4/g,"USD").replace(/\u00A4/g,"$")}static getPlotlyNumberFormat(e,t,n){if(!n)return null;const i=n.split(";")[0].match(/^([^#,0.]*)([#,]*)([0,]*)(\.?)(0*)(#*)(E?0*)(%?)(.*)/);O(i);const[,o,r,l,,a,c,d,u,m]=i,p=l.replace(",","").length,f=r.indexOf(",")>=0||l.indexOf(",")>=0?",":"",C=d!=null&&d!==""?"e":"f",b=u!==""?u:C,w=a.length+c.length,I=`0${p}${f}.${w}${b}`,v=Y.convertNumberPrefix(o),R=Y.convertNumberPrefix(m);return{tickformat:I,tickprefix:v,ticksuffix:R,automargin:!0}}static getPlotlyAxisFormat(e,t=null){const{axis:n,columnType:s}=e,{formatPattern:i}=n;let o=null;return x.isDateType(s)?(o=Y.getPlotlyDateFormat(t,s,i),o=Y.addTickSpacing(o,n,!0)):x.isNumberType(s)&&(o=Y.getPlotlyNumberFormat(t,s,i),o=Y.addTickSpacing(o,n,!1)),n.formatType===E.plot.AxisFormatType.CATEGORY&&(o?o.type="category":o={type:"category",tickformat:void 0,ticksuffix:void 0}),o}static addTickSpacing(e,t,n){const{gapBetweenMajorTicks:s}=t;if(s>0){const i=e||{};let o=s;return n&&(o=s/pg),t.log&&(o=Math.log(o)),i.tickmode="linear",i.dtick=o,i}return e}static getSourceForAxis(e,t){for(let n=0;n<e.series.length;n+=1){const s=e.series[n];for(let i=0;i<s.sources.length;i+=1){const o=s.sources[i];if(o.axis===t)return o}}return null}static getSeriesVisibility(e,t){return t!=null&&t.hiddenSeries!=null&&t.hiddenSeries.includes(e)?"legendonly":!0}static getHiddenLabels(e){return e!=null&&e.hiddenSeries?[...e.hiddenSeries]:[]}static makeSeriesData(e,t,n,s=Y.ORIENTATION.VERTICAL){return{type:e,mode:t,name:n,orientation:s}}static makeSeriesDataFromSeries(e,t,n,s=Fn){const{name:i,plotStyle:o,lineColor:r,shapeColor:l,sources:a}=e,c=a.some(g=>{var f;return(f=g.axis)==null?void 0:f.businessCalendar}),d=Y.getChartType(o,c),u=Y.getPlotlyChartMode(o),m=Y.getPlotlySeriesOrientation(e),p=Y.makeSeriesData(d,u,i,m);return Y.addSourcesToSeriesData(p,o,a,t),Y.addStylingToSeriesData(p,o,s,r,l,n),p}static addSourcesToSeriesData(e,t,n,s){const i=e;for(let o=0;o<n.length;o+=1){const r=n[o],{axis:l,type:a}=r,c=Y.getPlotlyProperty(t,a);Ol(i,c,[]);const d=l!=null?Y.getAxisPropertyName(l.type):null;if(d!=null){const u=s.get(l.type);if(u){const m=u.indexOf(l),p=m>0?`${m+1}`:"";i[`${d}axis`]=`${d}${p}`}}}}static addStylingToSeriesData(e,t,n=Fn,s=null,i=null,o=null){const r=e;r.marker={line:{}},r.line={width:1},t===E.plot.SeriesPlotStyle.AREA?r.fill="tozeroy":t===E.plot.SeriesPlotStyle.STACKED_AREA?r.stackgroup="stack":t===E.plot.SeriesPlotStyle.STEP?r.line.shape="hv":t===E.plot.SeriesPlotStyle.HISTOGRAM?(r.width=[],r.marker.line!==void 0&&Object.assign(r.marker.line,{color:n.paper_bgcolor,width:1})):t===E.plot.SeriesPlotStyle.OHLC?(r.increasing={line:{color:n.ohlc_increasing}},r.decreasing={line:{color:n.ohlc_decreasing}}):t===E.plot.SeriesPlotStyle.PIE?(r.textinfo="label+percent",r.outsidetextfont={color:n.title_color}):t===E.plot.SeriesPlotStyle.TREEMAP&&(r.hoverinfo="text",r.textinfo="label+text",r.tiling={packing:"squarify",pad:0},r.textposition="middle center",r.outsidetextfont={color:n.title_color}),s!=null&&(t===E.plot.SeriesPlotStyle.BAR?r.marker.color=s:r.line.color=s),i!=null&&(r.marker.color=i),o!=null&&t!==E.plot.SeriesPlotStyle.PIE&&(r.visible=o)}static getAxisFormats(e,t){const n=new Map,s={tickformat:null,ticksuffix:null},i=Y.getAllAxes(e),o=Y.groupArray(i,"type"),{charts:r}=e;for(let l=0;l<r.length;l+=1){const a=r[l];for(let c=0;c<a.series.length;c+=1){const d=a.series[c],{sources:u}=d,m=u.filter(p=>p.axis);for(let p=0;p<m.length;p+=1){const g=m[p],{axis:f}=g,{type:C}=f,b=o.get(C);O(b);const w=b.indexOf(f),S=Y.getAxisPropertyName(C);if(S!=null){const I=Y.getAxisLayoutProperty(S,w);if(n.has(I))Ai.debug(`${I} already added.`);else{Ai.debug(`Adding ${I} to axisFormats.`);const v=Y.getPlotlyAxisFormat(g,t);if(v===null)n.set(I,s);else{n.set(I,v);const{businessCalendar:R}=f;if(R!=null){const M=[],{businessPeriods:F,businessDays:P,holidays:W,timeZone:B}=R,N=t==null?void 0:t.getColumnTypeFormatter(Dl);let H;Nl(N)&&(H=N.dhTimeZone);const A=H?(B.standardOffset-H.standardOffset)/60:0;W.length>0&&M.push(...Y.createRangeBreakValuesFromHolidays(W,B,H)),F.forEach(L=>M.push({pattern:"hour",bounds:[Y.periodToDecimal(L.close)+A,Y.periodToDecimal(L.open)+A]})),P.length<yn.length&&Y.createBoundsFromDays(P).forEach(L=>M.push({pattern:"day of week",bounds:L})),v.rangebreaks=M}if(n.size===a.axes.length)return n}}}}}}return n}static getChartType(e,t){switch(e){case E.plot.SeriesPlotStyle.HISTOGRAM:return"bar";default:return Y.getPlotlyChartType(e,t)}}static getAxisPropertyName(e){switch(e){case E.plot.AxisType.X:return"x";case E.plot.AxisType.Y:return"y";default:return null}}static getAxisSide(e){switch(e){case E.plot.AxisPosition.BOTTOM:return"bottom";case E.plot.AxisPosition.TOP:return"top";case E.plot.AxisPosition.LEFT:return"left";case E.plot.AxisPosition.RIGHT:return"right";default:return}}static getAllAxes(e){return e.charts.reduce((t,n)=>[...t,...n.axes],[])}static getChartForSeries(e,t){const{charts:n}=e;for(let s=0;s<n.length;s+=1){const i=n[s];for(let o=0;o<i.series.length;o+=1)if(t===i.series[o])return i}return null}static getLayoutRanges(e){const t={},n=Object.keys(e).filter(s=>s.indexOf("axis")>=0);for(let s=0;s<n.length;s+=1){const i=n[s],o=e[i];Cg(o)&&(t[i]=[...o.range])}return t}static updateFigureAxes(e,t,n,s=0,i=0,o=Fn){const r=e,l=Y.getAllAxes(t);for(let a=0;a<t.charts.length;a+=1){const c=t.charts[a],d=n==null?void 0:n(c),u=Y.getChartBounds(t,c,s,i);Y.updateLayoutAxes(r,c.axes,l,s,i,u,d,o)}Y.removeStaleAxes(r,l)}static getChartBounds(e,t,n=0,s=0){var S;const{cols:i,rows:o}=e,{column:r,colspan:l,row:a,rowspan:c}=t,d=r+l,u=a+c,m=1/i,p=1/o,g=Y.AXIS_SIZE_PX/n,f=Y.AXIS_SIZE_PX/s,C={left:r*m+(r>0?g/2:0),bottom:a*p+(a>0?f/2:0),top:u*p-(u<o?f/2:0),right:d*m-(d<i?g/2:0)};return((S=Y.groupArray(t.axes,"position").get(E.plot.AxisPosition.RIGHT))!=null?S:[]).length>0&&(n>0?C.right-=(C.right-C.left)*Math.max(0,Math.min(Y.LEGEND_WIDTH_PX/n,Y.MAX_LEGEND_SIZE)):C.right-=(C.right-C.left)*Y.DEFAULT_AXIS_SIZE),C}static updateLayoutAxes(e,t,n,s=0,i=0,o={left:0,top:0,right:1,bottom:1},r,l=Fn){const a=s>0?Math.max(Y.MIN_AXIS_SIZE,Math.min(Y.AXIS_SIZE_PX/i,Y.MAX_AXIS_SIZE)):Y.DEFAULT_AXIS_SIZE,c=i>0?Math.max(Y.MIN_AXIS_SIZE,Math.min(Y.AXIS_SIZE_PX/s,Y.MAX_AXIS_SIZE)):Y.DEFAULT_AXIS_SIZE,d=e,u=Y.groupArray(t,"position"),m=Y.groupArray(t,"type"),p=[...m.keys()],g=Y.groupArray(n,"type");for(let f=0;f<p.length;f+=1){const C=p[f],b=Y.getAxisPropertyName(C);if(b!=null){const w=m.get(C),S=g.get(C),v=C===E.plot.AxisType.Y?i:s;O(w),O(S);for(let R=0;R<w.length;R+=1){const M=w[R],F=S.indexOf(M),P=Y.getAxisLayoutProperty(b,F);d[P]==null&&(d[P]=Y.makeLayoutAxis(C,l));const W=d[P];if(W!=null){Y.updateLayoutAxis(W,M,R,u,a,c,o);const{range:B,autorange:N}=W;if(r!=null&&B!==void 0&&(N===void 0||N===!1)){const H=r(M),[A,L]=H(B);Ai.debug("Setting downsample range",v,A,L),M.range(v,A,L)}else M.range(v)}}}}}static removeStaleAxes(e,t){const n=e,s=Y.groupArray(t,"type"),i=[...s.keys()];for(let o=0;o<i.length;o+=1){const r=i[o],l=s.get(r);O(l);let a=l.length;const c=Y.getAxisPropertyName(r);if(c!=null){let d=Y.getAxisLayoutProperty(c,a);for(;n[d]!=null;)delete n[d],a+=1,d=Y.getAxisLayoutProperty(c,a)}}}static getAxisLayoutProperty(e,t){const n=t>0?`${t+1}`:"";return`${e!=null?e:""}axis${n}`}static updateLayoutAxis(e,t,n,s,i,o,r){var u,m,p;const a=t.type===E.plot.AxisType.Y?o:i,c=e,d=(u=t.label)!=null?u:"";if(c.title!==void 0&&typeof c.title!="string"?c.title.text=d:c.title={text:d},t.log&&(c.type="log"),c.side=Y.getAxisSide(t.position),n>0){c.overlaying=(m=Y.getAxisPropertyName(t.type))!=null?m:void 0;const g=(p=s.get(t.position))!=null?p:[],f=g.indexOf(t);f>0&&(c.anchor="free",t.position===E.plot.AxisPosition.RIGHT?c.position=r.right+(f-g.length+1)*a:t.position===E.plot.AxisPosition.TOP?c.position=r.top+(f-g.length+1)*a:t.position===E.plot.AxisPosition.BOTTOM?c.position=r.bottom+(g.length-f+1)*a:t.position===E.plot.AxisPosition.LEFT&&(c.position=r.left+(g.length-f+1)*a))}else if(t.type===E.plot.AxisType.X){const g=s.get(E.plot.AxisPosition.LEFT)||[],f=s.get(E.plot.AxisPosition.RIGHT)||[],C=Math.max(r.left,r.left+(g.length-1)*o),b=Math.min(r.right-(f.length-1)*o,r.right);c.domain=[C,b]}else if(t.type===E.plot.AxisType.Y){const g=s.get(E.plot.AxisPosition.BOTTOM)||[],f=s.get(E.plot.AxisPosition.TOP)||[],C=Math.max(r.bottom,r.bottom+(g.length-1)*i),b=Math.min(r.top-(f.length-1)*i,r.top);c.domain=[C,b]}}static periodToDecimal(e){const t=e.split(":");return Number(t[0])+Number(t[1])/60}static createBoundsFromDays(e){const t=e.map(o=>yn.indexOf(o)),n=yn.filter(o=>!e.includes(o)).map(o=>yn.indexOf(o)),s=new Set;n.forEach(o=>{for(let r=o+1;r<o+yn.length;r+=1){const l=r%yn.length;if(t.includes(l)){s.add(l);break}}});const i=[];return s.forEach(o=>{for(let r=o-1;r>o-yn.length;r-=1){const l=r<0?r+yn.length:r;if(t.includes(l)){const a=(l+1)%7;i.push([a,o]);break}}}),i}static createRangeBreakValuesFromHolidays(e,t,n){const s=[],i=[];return e.forEach(o=>{o.businessPeriods.length>0?i.push(...Y.createPartialHoliday(o,t,n)):s.push(Y.createFullHoliday(o,t,n))}),[{values:s},...i]}static createFullHoliday(e,t,n){return Y.adjustDateForTimeZone(`${e.date.toString()} 00:00:00.000000`,t,n)}static createPartialHoliday(e,t,n){const s=e.date.toString(),i=["00:00"];e.businessPeriods.forEach(r=>{i.push(r.open),i.push(r.close)}),i.push("24:00");const o=[];for(let r=0;r<i.length;r+=2){const l=i[r],a=i[r+1];if(l!==a){const c=[Y.adjustDateForTimeZone(`${s} ${l}:00.000000`,t,n)],d=mg*(Y.periodToDecimal(a)-Y.periodToDecimal(l));o.push({values:c,dvalue:d})}}return o}static adjustDateForTimeZone(e,t,n){return n&&n.standardOffset!==t.standardOffset?Y.unwrapValue(Y.wrapValue(e,Dl,t),n):e}static groupArray(e,t){return e.reduce((n,s)=>{var r;const i=s[t],o=(r=n.get(i))!=null?r:[];return o.push(s),n.set(i,o),n},new Map)}static unwrapValue(e,t){if(e!=null){if(gg(e))return E.i18n.DateTimeFormat.format(Y.DATE_FORMAT,e,t);if(fg(e))return e.asNumber()}return e}static wrapValue(e,t,n=null){if(x.isDateType(t)&&typeof e=="string"){const s=e,i=Y.DATE_FORMAT.substr(0,e.length),o=E.i18n.DateTimeFormat.parse(i,s);if(!n)return o;const r=`${i} Z`,l=E.i18n.DateTimeFormat.format("Z",o,n),a=E.i18n.DateTimeFormat.parse(r,`${s} ${l}`),c=E.i18n.DateTimeFormat.format("Z",a,n);return E.i18n.DateTimeFormat.parse(r,`${s} ${c}`)}return e}static makeLayoutAxis(e,t=Fn){const n={automargin:!0,gridcolor:t.gridcolor,linecolor:t.linecolor,rangeslider:{visible:!1},showline:!0,ticklen:5,tickcolor:t.paper_bgcolor,tickfont:{color:t.zerolinecolor},title:{font:{color:t.title_color}}};return e===E.plot.AxisType.X?Object.assign(n,{showgrid:!0}):e===E.plot.AxisType.Y&&Object.assign(n,{zerolinecolor:t.zerolinecolor,zerolinewidth:2}),n}static getColorwayFromTheme(e=Fn){let t=[];return e.colorway&&(Array.isArray(e.colorway)?t=e.colorway:typeof e.colorway=="string"?t=e.colorway.split(" "):Ai.warn(`Unable to handle colorway property: ${e.colorway}`)),t}static makeDefaultLayout(e=Fn){const t={...e,autosize:!0,colorway:Y.getColorwayFromTheme(e),font:{family:"'Fira Sans', sans-serif"},title:{font:{color:e.title_color},yanchor:"top",pad:{...Y.DEFAULT_TITLE_PADDING},y:1},legend:{font:{color:e.title_color}},margin:{...Y.DEFAULT_MARGIN},xaxis:Y.makeLayoutAxis(E.plot.AxisType.X,e),yaxis:Y.makeLayoutAxis(E.plot.AxisType.Y,e)};return t.datarevision=0,t}static hydrateSettings(e){return{...e,type:E.plot.SeriesPlotStyle[e.type]}}static titleFromSettings(e){const{series:t,xAxis:n,title:s=`${t.join(", ")} by ${n}`}=e;return s}static makeFigureSettings(e,t){const{series:n,xAxis:s,type:i}=e,o=Y.titleFromSettings(e),r={formatType:`${E.plot.AxisFormatType.NUMBER}`,type:`${E.plot.AxisType.X}`,position:`${E.plot.AxisPosition.BOTTOM}`},l={formatType:`${E.plot.AxisFormatType.NUMBER}`,type:`${E.plot.AxisType.Y}`,position:`${E.plot.AxisPosition.LEFT}`};return{charts:[{chartType:`${E.plot.ChartType.XY}`,axes:[r,l],series:n.map(a=>({plotStyle:`${i}`,name:a,dataSources:[{type:`${E.plot.SourceType.X}`,columnName:s,axis:r,table:t},{type:`${E.plot.SourceType.Y}`,columnName:a,axis:l,table:t}]}))}],title:o}}};let Ee=Y;Ee.DEFAULT_AXIS_SIZE=.15;Ee.MIN_AXIS_SIZE=.025;Ee.MAX_AXIS_SIZE=.2;Ee.AXIS_SIZE_PX=75;Ee.LEGEND_WIDTH_PX=50;Ee.MAX_LEGEND_SIZE=.25;Ee.ORIENTATION=Object.freeze({HORIZONTAL:"h",VERTICAL:"v"});Ee.DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSS";Ee.DEFAULT_MARGIN=Object.freeze({l:60,r:50,t:30,b:60,pad:0});Ee.DEFAULT_TITLE_PADDING=Object.freeze({t:8});Ee.SUBTITLE_LINE_HEIGHT=25;const Rn=J.module("Chart"),Qs=class extends y.exports.Component{constructor(e){super(e),this.getCachedConfig=Ie((t,n,s,i)=>{const o=[],r=Boolean(t);if(r&&o.push({name:`Downsampling failed: ${t}`,click:()=>{},icon:Qs.convertIcon(Xl),attr:"fill-warning"}),n||s||i||r){const l=Qs.downsampleButtonTitle(s,i),a=Qs.downsampleButtonAttr(s,i),c=s?zl:Ld;o.push({name:l,icon:Qs.convertIcon(c),click:this.handleDownsampleClick,attr:a})}return{displaylogo:!1,displayModeBar:s||r?!0:"hover",modeBarButtons:[o,["toImage"],["zoom2d","pan2d"],["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]]}}),this.handleAfterPlot=this.handleAfterPlot.bind(this),this.handleDownsampleClick=this.handleDownsampleClick.bind(this),this.handleModelEvent=this.handleModelEvent.bind(this),this.handlePlotUpdate=this.handlePlotUpdate.bind(this),this.handleRelayout=this.handleRelayout.bind(this),this.handleRestyle=this.handleRestyle.bind(this),this.plot=Q.createRef(),this.plotWrapper=Q.createRef(),this.columnFormats=[],this.dateTimeFormatterOptions={},this.decimalFormatOptions={},this.integerFormatOptions={},this.isSubscribed=!1,this.isLoadedFired=!1,this.currentSeries=0,this.state={data:null,downsamplingError:null,isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,layout:{datarevision:0},revision:0}}static convertIcon(e){const[t,,,,n]=e.icon,s=`${n}`;return{width:t,path:s,ascent:t,descent:0,transform:"matrix(1, 0, 0, 1, 0, 0)"}}static downsampleButtonTitle(e,t){return e?"Downsampling in progress...":t?"Downsampling disabled, click to enable":"Downsampling enabled, click to disable"}static downsampleButtonAttr(e,t){return e?"animation-spin":t?void 0:"fill-active"}componentDidMount(){this.updateDimensions(),this.updateModelDimensions(),this.initData(),this.initFormatter();const{isActive:e}=this.props;e&&this.subscribe()}componentDidUpdate(e){const{isActive:t,settings:n}=this.props;this.updateFormatterSettings(n),t!==e.isActive&&(t?this.subscribe():this.unsubscribe())}componentWillUnmount(){this.unsubscribe()}getPlotRect(){var e,t;return(t=(e=this.plotWrapper.current)==null?void 0:e.getBoundingClientRect())!=null?t:null}initData(){const{model:e}=this.props,{layout:t}=this.state;this.setState({data:e.getData(),layout:{...t,...e.getLayout()}})}subscribe(){if(this.isSubscribed)return;const{model:e}=this.props;if(!this.rect||this.rect.width===0||this.rect.height===0){Rn.debug2("Delaying subscription until model dimensions are set");return}e.subscribe(this.handleModelEvent),this.isSubscribed=!0}unsubscribe(){if(!this.isSubscribed)return;const{model:e}=this.props;e.unsubscribe(this.handleModelEvent),this.isSubscribed=!1}handleAfterPlot(){this.plot.current!=null}handleDownsampleClick(){this.setState(({isDownsamplingDisabled:e})=>({downsamplingError:null,isDownsampleInProgress:!1,isDownsampleFinished:!1,isDownsamplingDisabled:!e}),()=>{const{model:e}=this.props,{isDownsamplingDisabled:t}=this.state;e.setDownsamplingDisabled(t)})}handleModelEvent(e){var s;const{type:t,detail:n}=e;switch(Rn.debug2("Received data update",t,n),t){case Qe.EVENT_UPDATED:{this.currentSeries+=1,this.setState(o=>{const{layout:r,revision:l}=o;return typeof r.datarevision=="number"&&(r.datarevision+=1),{data:n,layout:r,revision:l+1}});const{onUpdate:i}=this.props;i({isLoading:!this.isLoadedFired});break}case Qe.EVENT_LOADFINISHED:{const{onUpdate:i}=this.props;this.isLoadedFired=!0,i({isLoading:!1});break}case Qe.EVENT_DISCONNECT:{const{onDisconnect:i}=this.props;i();break}case Qe.EVENT_RECONNECT:{const{onReconnect:i}=this.props;i();break}case Qe.EVENT_DOWNSAMPLESTARTED:{this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!0,downsamplingError:null});break}case Qe.EVENT_DOWNSAMPLEFINISHED:{this.setState({isDownsampleFinished:!0,isDownsampleInProgress:!1,downsamplingError:null});break}case Qe.EVENT_DOWNSAMPLENEEDED:case Qe.EVENT_DOWNSAMPLEFAILED:{const i=(s=n.message)!=null?s:n;this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,downsamplingError:i});const{onError:o}=this.props;o(new Error(i));break}default:Rn.debug("Unknown event type",t,e)}}handlePlotUpdate(e){const{layout:t}=e,n=Ee.getLayoutRanges(t);!ct(n,this.ranges)&&(this.ranges=n,this.updateModelDimensions(!0))}handleRelayout(e){if(Rn.debug("handleRelayout",e),e.hiddenlabels!=null){const{onSettingsChanged:t}=this.props,n=[...e.hiddenlabels];t({hiddenSeries:n})}this.updateModelDimensions()}handleRestyle([e,t]){if(Rn.debug("handleRestyle",e,t),Object.keys(e).includes("visible")){const{data:n}=this.state,{onSettingsChanged:s}=this.props;if(n!=null){const i=n.reduce((o,{name:r,visible:l})=>r!=null&&l==="legendonly"?[...o,r]:o,[]);s({hiddenSeries:i})}}}updateModelDimensions(e=!1){const t=this.getPlotRect();if(!t){Rn.warn("Unable to get plotting rect");return}if(!this.rect||this.rect.width!==t.width||this.rect.height!==t.height||e){this.rect=t;const{isActive:s,model:i}=this.props;i.setDimensions(t),s&&this.subscribe()}}initFormatter(){const{settings:e}=this.props;this.updateFormatterSettings(e)}updateFormatterSettings(e){const t=ls.getColumnFormats(e),n=ls.getDateTimeFormatterOptions(e),{decimalFormatOptions:s={},integerFormatOptions:i={}}=e;(!ct(this.columnFormats,t)||!ct(this.dateTimeFormatterOptions,n)||!ct(this.decimalFormatOptions,s)||!ct(this.integerFormatOptions,i))&&(this.columnFormats=ls.getColumnFormats(e),this.dateTimeFormatterOptions=n,this.decimalFormatOptions=s,this.integerFormatOptions=i,this.updateFormatter())}updateFormatter(){const e=new jt(this.columnFormats,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions),{model:t}=this.props;t.setFormatter(e)}updateDimensions(){const e=this.getPlotRect();this.plot.current!=null&&e!=null&&e.width>0&&e.height>0&&_i.relayout(this.plot.current.el,{autosize:!0}).catch(t=>{Rn.debug("Unable to resize, promise rejected",t)})}render(){const{data:e,downsamplingError:t,isDownsampleFinished:n,isDownsampleInProgress:s,isDownsamplingDisabled:i,layout:o,revision:r}=this.state,l=this.getCachedConfig(t,n,s,i),a=e!=null;return h("div",{className:"h-100 w-100 chart-wrapper",ref:this.plotWrapper,children:a&&h(rg,{ref:this.plot,data:e,layout:o,revision:r,config:l,onAfterPlot:this.handleAfterPlot,onError:Rn.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}};let bg=Qs;bg.defaultProps={isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:Hn.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}};const nt=J.module("FigureChartModel"),sc=class extends Qe{constructor(e,t={},n=Fn){super(),this.addPendingSeries=Tt(()=>{const i=Ee.getAllAxes(this.figure),{pendingSeries:o}=this;for(let r=0;r<o.length;r+=1){const l=o[r];this.addSeries(l,i),l.subscribe()}this.pendingSeries=[]},sc.ADD_SERIES_DEBOUNCE),this.getTimeZone=he((i,o)=>{if(o!=null){const r=o.getColumnTypeFormatter(i);if(r!=null)return r.dhTimeZone}return null}),this.getValueTranslator=he((i,o)=>{const r=this.getTimeZone(i,o);return l=>Ee.unwrapValue(l,r)}),this.getValueParser=he((i,o)=>{const r=this.getTimeZone(i,o);return l=>Ee.wrapValue(l,i,r)}),this.getRangeParser=he((i,o)=>r=>{let[l,a]=r;const c=this.getValueParser(i,o);return l=c(l),a=c(a),[l,a]}),this.getAxisRangeParser=he((i,o)=>r=>{const l=Ee.getSourceForAxis(i,r);return l?this.getRangeParser(l.columnType,o):a=>a}),this.handleFigureUpdated=this.handleFigureUpdated.bind(this),this.handleFigureDisconnected=this.handleFigureDisconnected.bind(this),this.handleFigureReconnected=this.handleFigureReconnected.bind(this),this.handleFigureSeriesAdded=this.handleFigureSeriesAdded.bind(this),this.handleDownsampleStart=this.handleDownsampleStart.bind(this),this.handleDownsampleFinish=this.handleDownsampleFinish.bind(this),this.handleDownsampleFail=this.handleDownsampleFail.bind(this),this.handleDownsampleNeeded=this.handleDownsampleNeeded.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.figure=e,this.settings=t,this.theme=n,this.data=[];const s={data:{},layout:Ee.makeDefaultLayout(n)};this.layout={grid:{rows:e.rows,columns:e.cols,pattern:"independent"},template:s},this.seriesDataMap=new Map,this.pendingSeries=[],this.oneClicks=[],this.filterColumnMap=new Map,this.lastFilter=new Map,this.isConnected=!0,this.seriesToProcess=new Set,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure()}close(){this.figure.close(),this.addPendingSeries.cancel(),this.stopListeningFigure()}getDefaultTitle(){return this.figure.charts.length>0?this.figure.charts[0].title:""}initAllSeries(){this.oneClicks=[],this.filterColumnMap.clear();const{charts:e}=this.figure,t=Ee.getAllAxes(this.figure),n=[];for(let o=0;o<e.length;o+=1){const r=e[o];for(let l=0;l<r.series.length;l+=1){const a=r.series[l];n.push(a.name),this.addSeries(a,t)}}const i=[...this.seriesDataMap.keys()].filter(o=>n.indexOf(o)<0);for(let o=0;o<i.length;o+=1){const r=i[o];this.seriesDataMap.delete(r)}this.seriesToProcess=new Set([...this.seriesDataMap.keys()])}addSeries(e,t){const n=Ee.groupArray(t,"type"),s=Ee.makeSeriesDataFromSeries(e,n,Ee.getSeriesVisibility(e.name,this.settings),this.theme);if(this.seriesDataMap.set(e.name,s),this.data=[...this.seriesDataMap.values()],e.plotStyle===E.plot.SeriesPlotStyle.STACKED_BAR?this.layout.barmode="stack":e.plotStyle===E.plot.SeriesPlotStyle.PIE&&(this.layout.hiddenlabels=Ee.getHiddenLabels(this.settings)),this.layout.showlegend=this.data.length>1||e.plotStyle===E.plot.SeriesPlotStyle.PIE,e.oneClick!=null){const{oneClick:i}=e,{columns:o}=i;for(let r=0;r<o.length;r+=1)this.filterColumnMap.set(o[r].name,o[r]);this.oneClicks.push(i)}this.updateLayoutFormats()}subscribe(e){super.subscribe(e),this.listeners.length===1&&(this.initAllSeries(),this.subscribeFigure())}unsubscribe(e){super.unsubscribe(e),this.listeners.length===0&&this.unsubscribeFigure()}subscribeFigure(){if(!this.isConnected){nt.debug("Ignoring subscribe when figure in disconnected state");return}this.figure.subscribe(this.isDownsamplingDisabled?E.plot.DownsampleOptions.DISABLE:E.plot.DownsampleOptions.DEFAULT)}unsubscribeFigure(){this.figure.unsubscribe()}startListeningFigure(){this.figure.addEventListener(E.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.addEventListener(E.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.addEventListener(E.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.addEventListener(E.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.addEventListener(E.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.addEventListener(E.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.addEventListener(E.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.addEventListener(E.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.addEventListener(E.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}stopListeningFigure(){this.figure.removeEventListener(E.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.removeEventListener(E.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.removeEventListener(E.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.removeEventListener(E.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.removeEventListener(E.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.removeEventListener(E.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.removeEventListener(E.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.removeEventListener(E.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.removeEventListener(E.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}handleDownsampleStart(e){nt.debug("Downsample started",e),this.fireDownsampleStart(e.detail)}handleDownsampleFinish(e){nt.debug("Downsample finished",e),this.fireDownsampleFinish(e.detail)}handleDownsampleFail(e){nt.error("Downsample failed",e),this.fireDownsampleFail(e.detail)}handleDownsampleNeeded(e){nt.info("Downsample needed",e),this.fireDownsampleNeeded(e.detail)}handleFigureUpdated(e){const{detail:t}=e,{series:n}=t;nt.debug2("handleFigureUpdated",n);for(let i=0;i<n.length;i+=1){const o=n[i];nt.debug2("handleFigureUpdated updating series",o.name);const{sources:r}=o;for(let l=0;l<r.length;l+=1){const a=r[l],{columnType:c,type:d}=a,u=this.getValueTranslator(c,this.formatter),m=t.getArray(o,d,u);this.setDataArrayForSeries(o,d,m)}this.seriesToProcess.delete(o.name),this.seriesToProcess.size===0&&this.fireLoadFinished(),this.cleanSeries(o)}const{data:s}=this;this.fireUpdate(s)}handleRequestFailed(e){nt.error("Request failed",e)}resubscribe(){this.listeners.length>0&&(this.unsubscribeFigure(),this.subscribeFigure())}setFormatter(e){super.setFormatter(e),this.updateLayoutFormats(),this.resubscribe()}setDownsamplingDisabled(e){super.setDownsamplingDisabled(e),this.resubscribe()}handleFigureDisconnected(e){nt.debug("Figure disconnected",e),this.isConnected=!1,this.listeners.length>0&&this.unsubscribeFigure(),this.fireDisconnect()}handleFigureReconnected(e){nt.debug("Figure reconnected",e),this.isConnected=!0,this.initAllSeries(),this.fireReconnect(),this.listeners.length>0&&this.subscribeFigure()}handleFigureSeriesAdded(e){const{detail:t}=e;nt.debug("handleFigureSeriesAdded",t),this.pendingSeries.push(t),this.addPendingSeries()}setDimensions(e){super.setDimensions(e),this.updateAxisPositions()}setTitle(e){var s,i;super.setTitle(e);const t=(i=(s=(e!=null?e:"").match(/<br>/g))==null?void 0:s.length)!=null?i:0,n=Ee.DEFAULT_MARGIN.t+t*Ee.SUBTITLE_LINE_HEIGHT;this.layout.margin?this.layout.margin.t=n:this.layout.margin={t:n},typeof this.layout.title=="string"?this.layout.title=e:(this.layout.title={...this.layout.title},this.layout.title.text=e,this.layout.title.pad={...this.layout.title.pad},this.layout.title.pad.t=Ee.DEFAULT_TITLE_PADDING.t+t*Ee.SUBTITLE_LINE_HEIGHT*.5)}getPlotWidth(){var e,t,n,s;return!this.rect||!this.rect.width?0:Math.max(this.rect.width-((t=(e=this.layout.margin)==null?void 0:e.l)!=null?t:0)-((s=(n=this.layout.margin)==null?void 0:n.r)!=null?s:0),0)}getPlotHeight(){var e,t,n,s;return!this.rect||!this.rect.height?0:Math.max(this.rect.height-((t=(e=this.layout.margin)==null?void 0:e.t)!=null?t:0)-((s=(n=this.layout.margin)==null?void 0:n.b)!=null?s:0),0)}updateAxisPositions(){const e=this.getPlotWidth(),t=this.getPlotHeight();Ee.updateFigureAxes(this.layout,this.figure,n=>this.getAxisRangeParser(n,this.formatter),e,t,this.theme)}updateLayoutFormats(){if(!this.formatter)return;Ee.getAxisFormats(this.figure,this.formatter).forEach((t,n)=>{nt.debug(`Assigning ${n}`,this.layout[n],t);const s=this.layout[n];s!=null?Object.assign(s,t):nt.debug(`Ignoring null layout.${n}`)})}setDataArrayForSeries(e,t,n){const{name:s,plotStyle:i}=e,o=this.seriesDataMap.get(s),r=Ee.getPlotlyProperty(i,t);o&&Ol(o,r,n)}cleanSeries(e){const{name:t,plotStyle:n}=e,s=this.seriesDataMap.get(t);if(s!=null){if(n===E.plot.SeriesPlotStyle.HISTOGRAM){const{xLow:i,xHigh:o}=s;if(i&&o&&i.length===o.length){const r=[];for(let l=0;l<i.length;l+=1)r.push(o[l]-i[l]);s.width=r}}else if(n===E.plot.SeriesPlotStyle.LINE){const{x:i,xLow:o,xHigh:r,y:l,yLow:a,yHigh:c}=s;o&&r&&o!==i&&(s.error_x=Ee.getPlotlyErrorBars(i,o,r)),a&&c&&a!==l&&(s.error_y=Ee.getPlotlyErrorBars(l,a,c))}else if(n===E.plot.SeriesPlotStyle.TREEMAP){const{ids:i,labels:o}=s;i!==void 0&&o===void 0&&(s.labels=i)}}}getData(){return this.data}getLayout(){return this.layout}getFilterColumnMap(){return new Map(this.filterColumnMap)}isFilterRequired(){return this.oneClicks.find(e=>e.requireAllFiltersToDisplay)!=null}setFilter(e){if(this.oneClicks.length===0){nt.warn("Trying to set a filter, but no one click!");return}nt.debug("setFilter",e);for(let t=0;t<this.oneClicks.length;t+=1){const n=this.oneClicks[t],{columns:s}=n;new Set([...e.keys(),...this.lastFilter.keys()]).forEach(o=>{const r=e.get(o);this.lastFilter.get(o)!==r&&s.find(l=>l.name===o)!=null&&n.setValueForColumn(o,r)})}this.lastFilter=new Map(e)}setFigure(e){this.close(),this.figure=e,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure(),this.listeners.length>0&&this.subscribeFigure()}updateSettings(e){this.settings=e}};let wg=sc;wg.ADD_SERIES_DEBOUNCE=50;function Sg({text:e,isOpen:t,onClose:n}){const[s,i]=y.exports.useState(!1),[o,r]=y.exports.useState(0),[l,a]=y.exports.useState(!1),[c,d]=y.exports.useState(!1),[u,m]=y.exports.useState(!1),p=y.exports.useRef(),g=y.exports.useRef(null),[f,C]=y.exports.useState(!1);y.exports.useEffect(function(){if(!!t){try{JSON.parse(e),m(!0)}catch{m(!1)}d(!1)}},[t,e]),y.exports.useEffect(function(){p.current&&p.current.layout()},[o]),y.exports.useEffect(function(){p.current&&p.current.updateOptions({lineNumbers:l?"on":"off"})},[l]),y.exports.useEffect(()=>(g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{C(!1)},1e3),()=>{g.current&&clearTimeout(g.current)}),[f]);function b(){var M,F;ve.copyToClipboard((F=(M=p.current)==null?void 0:M.getValue())!=null?F:e).then(()=>{C(!0)})}function w(){a(!l)}function S(){var F;const M=(F=p.current)==null?void 0:F.getModel();!u||!M||(c?(M.setValue(e),d(!1)):(M.setValue(JSON.stringify(JSON.parse(e),void 0,2)),d(!0)),I())}function I(){var F,P;const M=p.current;!M||a(((P=(F=M.getModel())==null?void 0:F.getLineCount())!=null?P:0)>1)}function v(){s&&(p.current=void 0,n())}function R(M){p.current=M,M.onDidContentSizeChange(({contentHeight:F})=>r(F)),I()}return!t&&!s?null:T(Jc,{isOpen:t,centered:!0,keyboard:!0,toggle:v,onOpened:()=>i(!0),onClosed:()=>{i(!1),r(0)},className:"theme-bg-dark cell-overflow-modal",children:[T(td,{toggle:n,children:[h("h5",{className:"overflow-modal-title",children:"Cell Contents"}),h(me,{kind:"inline",icon:f?$l:Vl,tooltip:f?"Copied contents":"Copy contents",onClick:b}),h(me,{kind:"inline",active:l,icon:fd,tooltip:"Toggle line numbers",onClick:w}),u&&h(me,{kind:"inline",icon:md,active:c,tooltip:"Format as JSON",onClick:S})]}),h(ed,{style:{height:o},children:h(Tr,{onEditorInitialized:R,settings:{value:e,readOnly:!0,wordWrap:"on",language:u?"typescript":"plaintext",folding:u,padding:{bottom:16},lineNumbers:l?"on":"off",overviewRulerLanes:0,renderLineHighlight:"none",find:{seedSearchStringFromSelection:"never"}}})})]})}const vg="###,##0",Tg=({gotoRow:e,gotoRowError:t,onSubmit:n,isShown:s,onEntering:i,onEntered:o,onExiting:r,onExited:l,model:a,onGotoRowNumberChanged:c,onClose:d})=>{const u=y.exports.useRef(null),m="Row number",{rowCount:p}=a;return y.exports.useEffect(()=>{var g;document.activeElement!==u.current&&((g=u.current)==null||g.select())},[e]),h(io,{isShown:s,className:$("goto-row"),onEntering:i,onEntered:()=>{var g;o(),(g=u.current)==null||g.select()},onExiting:r,onExited:l,children:T(Fe,{children:[T("div",{className:"goto-row-wrapper",children:[h("div",{className:"goto-row-text",children:"Go to row"}),h("div",{className:"goto-row-input",children:h("input",{ref:u,type:"number",onKeyDown:g=>{g.key==="Enter"&&(g.stopPropagation(),g.preventDefault(),n())},className:$("form-control",{"is-invalid":t!==""}),placeholder:m,onChange:g=>{c(g)},value:e})}),T("div",{className:"goto-row-text",children:["of ",dh.i18n.NumberFormat.format(vg,p)]}),t&&h("div",{className:"goto-row-error text-danger",children:t})]}),h("div",{className:"goto-row-close",children:h(me,{kind:"ghost",onClick:d,children:h(K,{icon:ti,style:{marginRight:"0"}})})})]})})},oe=J.module("IrisGrid"),Eg=500,yg=250,Rg=250,ic=Object.freeze({aggregations:[],showOnTop:!1});function Fl({advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a}){return e.size===0&&t.aggregations.length===0&&n.length===0&&s.size===0&&i===x.REVERSE_TYPE.NONE&&o==null&&r==null&&l.length===0&&a.length===0}const ss=class extends y.exports.Component{constructor(e){super(e),this.getAdvancedMenuOpenedHandler=he(L=>this.handleAdvancedMenuOpened.bind(this,L),{max:100}),this.getCachedAdvancedFilterMenuActions=he((L,_,V,G,j)=>h(wr,{model:L,column:_,onFilterChange:this.handleAdvancedFilterChange,onSortChange:this.handleAdvancedFilterSortChange,onDone:this.handleAdvancedFilterDone,options:V,sortDirection:G,formatter:j}),{max:50}),this.getCachedOptionItems=he((L,_,V,G,j,ee,re,be,ce,Te,_e,Ke,Mt,Xe,Ze)=>{const Le=[];return L&&Le.push({type:we.CHART_BUILDER,title:"Chart Builder",icon:Pd}),Le.push({type:we.VISIBILITY_ORDERING_BUILDER,title:"Column Visibility & Ordering",icon:_o}),V&&Le.push({type:we.CONDITIONAL_FORMATTING,title:"Conditional Formatting",icon:Ul}),_&&Le.push({type:we.CUSTOM_COLUMN_BUILDER,title:"Manage Custom Columns",icon:yd}),G&&Le.push({type:we.ROLLUP_ROWS,title:"Rollup Rows",icon:zd}),j&&Le.push({type:we.AGGREGATIONS,title:"Aggregate Columns",icon:Rd}),ee&&Le.push({type:we.SELECT_DISTINCT,title:"Select Distinct Values",icon:Ed}),re&&Mt&&Le.push({type:we.TABLE_EXPORTER,title:"Download CSV",icon:cd}),Le.push({type:we.ADVANCED_SETTINGS,title:"Advanced Settings",icon:Id}),Le.push({type:we.QUICK_FILTERS,title:"Quick Filters",subtitle:be.shortcut.getDisplayText(),icon:Vi,isOn:_e,onChange:be.action}),Xe&&Le.push({type:we.SEARCH_BAR,title:"Search Bar",subtitle:ce.shortcut.getDisplayText(),icon:ql,isOn:Ke,onChange:ce.action}),Le.push({type:we.GOTO,title:"Go to",subtitle:Te.shortcut.getDisplayText(),icon:Td,isOn:Ze,onChange:Te.action}),Le},{max:1}),this.getCachedHiddenColumns=he(L=>L,{max:1,normalizer:([L])=>L.join()}),this.getAggregationMap=he((L,_)=>{const V={};return _.forEach(({operation:G,selected:j,invert:ee})=>{V[G]=On.getOperationColumnNames(L,G,j,ee)}),V}),this.getOperationMap=he((L,_)=>{const V={};return _.filter(G=>!On.isRollupOperation(G.operation)).forEach(({operation:G,selected:j,invert:ee})=>{On.getOperationColumnNames(L,G,j,ee).forEach(re=>{var ce;const be=[...(ce=V[re])!=null?ce:[],G];V[re]=be})}),V}),this.getOperationOrder=he(L=>L.map(_=>_.operation).filter(_=>!On.isRollupOperation(_))),this.getCachedFormatColumns=he((L,_)=>rm(L,_)),this.getCachedModelColumns=he((L,_)=>L.columns),this.getCachedPreviewFormatColumns=he((L,_,V,G)=>{if(oe.debug("getCachedPreviewFormatColumns",_,V,G),V!==void 0&&G!==void 0){const j=[..._];return j[G]=V,this.getCachedFormatColumns(L,j)}return this.getCachedFormatColumns(L,_)}),this.getModelRollupConfig=he((L,_,V)=>ne.getModelRollupConfig(L,_,V)),this.getModelTotalsConfig=he((L,_,V)=>{var be,ce,Te;const{aggregations:G,showOnTop:j}=V;if(((ce=(be=_==null?void 0:_.columns)==null?void 0:be.length)!=null?ce:0)>0||((Te=G==null?void 0:G.length)!=null?Te:0)===0)return null;const ee=this.getOperationMap(L,G),re=this.getOperationOrder(G);return{operationMap:ee,operationOrder:re,showOnTop:j}}),this.getCachedStateOverride=he((L,_,V,G,j,ee,re,be,ce,Te)=>({hoverSelectColumn:L,isFilterBarShown:_,isSelectingColumn:V,loadingScrimProgress:G,quickFilters:j,advancedFilters:ee,sorts:re,reverseType:be,rollupConfig:ce,isMenuShown:Te}),{max:1}),this.getCachedFilter=he((L,_,V,G,j)=>[...L!=null?L:[],...G!=null?G:[],...ne.getFiltersFromFilterMap(_),...ne.getFiltersFromFilterMap(V),...j!=null?j:[]],{max:1}),this.getCachedTheme=he((L,_)=>({...Aa,...L,autoSelectRow:!_}),{max:1}),this.getAlwaysFetchColumns=he((L,_,V,G,j,ee)=>{const re=[];for(let ce=0;ce<G;ce+=1)re.push(_[U.getModelIndex(ce,V)].name);for(let ce=0;ce<j;ce+=1)re.push(_[U.getModelIndex(_.length-1-ce,V)].name);if(ee)for(let ce=ee[0];ce<=ee[1];ce+=1)re.push(_[U.getModelIndex(ce,V)].name);return[...new Set([...L,...re])]}),this.updateSearchFilter=Tt((L,_,V,G)=>{const j=xi.createSearchFilter(L,_,V,G);this.setState({searchFilter:j})},yg),this.handleConditionalFormatEditorUpdate=Tt(L=>{this.setState({conditionalFormatPreview:L})},Rg),this.handleDownloadProgressUpdate=cs((L,_)=>{const{tableDownloadStatus:V}=this.state;V===wt.DOWNLOAD_STATUS.DOWNLOADING&&this.setState({tableDownloadProgress:L,tableDownloadEstimatedTime:_})},Eg),this.getOverflowButtonTooltip=he(L=>{if(L==null)return null;const _={position:"absolute",...L,pointerEvents:"none"};return h("div",{style:_,children:h(ge,{options:{placement:"left",modifiers:{flip:{behavior:["left","right"]}}},ref:this.handleTooltipRef,children:"View full contents"},Date.now())})}),this.handleAdvancedFilterChange=this.handleAdvancedFilterChange.bind(this),this.handleAdvancedFilterSortChange=this.handleAdvancedFilterSortChange.bind(this),this.handleAdvancedFilterDone=this.handleAdvancedFilterDone.bind(this),this.handleAdvancedMenuOpened=this.handleAdvancedMenuOpened.bind(this),this.handleGotoRowOpened=this.handleGotoRowOpened.bind(this),this.handleGotoRowClosed=this.handleGotoRowClosed.bind(this),this.handleAdvancedMenuClosed=this.handleAdvancedMenuClosed.bind(this),this.handleAggregationChange=this.handleAggregationChange.bind(this),this.handleAggregationsChange=this.handleAggregationsChange.bind(this),this.handleAggregationEdit=this.handleAggregationEdit.bind(this),this.handleAnimationLoop=this.handleAnimationLoop.bind(this),this.handleAnimationStart=this.handleAnimationStart.bind(this),this.handleAnimationEnd=this.handleAnimationEnd.bind(this),this.handleChartChange=this.handleChartChange.bind(this),this.handleChartCreate=this.handleChartCreate.bind(this),this.handleGridError=this.handleGridError.bind(this),this.handleFilterBarChange=this.handleFilterBarChange.bind(this),this.handleFilterBarDone=this.handleFilterBarDone.bind(this),this.handleFilterBarTab=this.handleFilterBarTab.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleMenu=this.handleMenu.bind(this),this.handleMenuClose=this.handleMenuClose.bind(this),this.handleMenuSelect=this.handleMenuSelect.bind(this),this.handleMenuBack=this.handleMenuBack.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.handleSelectionChanged=this.handleSelectionChanged.bind(this),this.handleMovedColumnsChanged=this.handleMovedColumnsChanged.bind(this),this.handleUpdate=this.handleUpdate.bind(this),this.handleTooltipRef=this.handleTooltipRef.bind(this),this.handleViewChanged=this.handleViewChanged.bind(this),this.handleFormatSelection=this.handleFormatSelection.bind(this),this.handleConditionalFormatCreate=this.handleConditionalFormatCreate.bind(this),this.handleConditionalFormatEdit=this.handleConditionalFormatEdit.bind(this),this.handleConditionalFormatsChange=this.handleConditionalFormatsChange.bind(this),this.handleConditionalFormatEditorSave=this.handleConditionalFormatEditorSave.bind(this),this.handleConditionalFormatEditorCancel=this.handleConditionalFormatEditorCancel.bind(this),this.handleUpdateCustomColumns=this.handleUpdateCustomColumns.bind(this),this.handleCustomColumnsChanged=this.handleCustomColumnsChanged.bind(this),this.handleSelectDistinctChanged=this.handleSelectDistinctChanged.bind(this),this.handlePendingDataUpdated=this.handlePendingDataUpdated.bind(this),this.handlePendingCommitClicked=this.handlePendingCommitClicked.bind(this),this.handlePendingDiscardClicked=this.handlePendingDiscardClicked.bind(this),this.handleGotoRowSelectedRowNumberSubmit=this.handleGotoRowSelectedRowNumberSubmit.bind(this),this.focusRowInGrid=this.focusRowInGrid.bind(this),this.handleDownloadTable=this.handleDownloadTable.bind(this),this.handleDownloadTableStart=this.handleDownloadTableStart.bind(this),this.handleCancelDownloadTable=this.handleCancelDownloadTable.bind(this),this.handleDownloadCanceled=this.handleDownloadCanceled.bind(this),this.handleDownloadCompleted=this.handleDownloadCompleted.bind(this),this.handlePartitionAppend=this.handlePartitionAppend.bind(this),this.handlePartitionChange=this.handlePartitionChange.bind(this),this.handlePartitionFetchAll=this.handlePartitionFetchAll.bind(this),this.handlePartitionDone=this.handlePartitionDone.bind(this),this.handleColumnVisibilityChanged=this.handleColumnVisibilityChanged.bind(this),this.handleCrossColumnSearch=this.handleCrossColumnSearch.bind(this),this.handleRollupChange=this.handleRollupChange.bind(this),this.handleOverflowClose=this.handleOverflowClose.bind(this),this.getColumnBoundingRect=this.getColumnBoundingRect.bind(this),this.handleGotoRowSelectedRowNumberChanged=this.handleGotoRowSelectedRowNumberChanged.bind(this),this.grid=null,this.gridWrapper=null,this.lastLoadedConfig=null,this.pending=new Ji,this.globalColumnFormats=[],this.decimalFormatOptions={},this.integerFormatOptions={},this.truncateNumbersWithPound=!1,this.renderer=new Zs,this.tableSaver=null,this.crossColumnRef=Q.createRef(),this.isAnimating=!1,this.filterInputRef=Q.createRef(),this.toggleFilterBarAction={action:()=>this.toggleFilterBar(),shortcut:Pt.TABLE.TOGGLE_QUICK_FILTER},this.toggleSearchBarAction={action:()=>this.toggleSearchBar(),shortcut:Pt.TABLE.TOGGLE_SEARCH},this.toggleGotoRowAction={action:()=>this.toggleGotoRow(),shortcut:Pt.TABLE.GOTO_ROW},this.discardAction={action:()=>{const{model:L}=this.props;Ae(L)&&L.isEditable&&L.pendingDataMap.size>0&&this.discardPending().catch(oe.error)},shortcut:Pt.INPUT_TABLE.DISCARD},this.commitAction={action:()=>{const{model:L}=this.props;Ae(L)&&L.isEditable&&L.pendingDataMap.size>0&&L.pendingDataErrors.size===0&&this.commitPending().catch(oe.error)},shortcut:Pt.INPUT_TABLE.COMMIT},this.contextActions=[this.toggleFilterBarAction,this.toggleSearchBarAction,this.toggleGotoRowAction,this.discardAction,this.commitAction];const{aggregationSettings:t,conditionalFormats:n,customColumnFormatMap:s,isFilterBarShown:i,isSelectingPartition:o,model:r,movedColumns:l,movedRows:a,partition:c,partitionColumn:d,rollupConfig:u,userColumnWidths:m,userRowHeights:p,showSearchBar:g,searchValue:f,selectedSearchColumns:C,invertSearchColumns:b,advancedFilters:w,quickFilters:S,selectDistinctColumns:I,pendingDataMap:v,canCopy:R,frozenColumns:M}=e,F=[new pm(this),new gm(this)];R&&F.push(new um(this));const P=[new fm(this),new Cm(this),new bm(this),new Tm(this),new vm(this),new Cn(this),new Sm(this),new Em(this)],W=l.length>0?l:r.movedColumns,B=a.length>0?a:r.movedRows,N=new Im({userColumnWidths:new Map(m),userRowHeights:new Map(p),movedColumns:W}),H=C!=null?C:[],A=xi.createSearchFilter(f,H,r.columns,b);this.state={isFilterBarShown:i,isSelectingPartition:o,focusedFilterBarColumn:null,metricCalculator:N,metrics:void 0,keyHandlers:F,mouseHandlers:P,partition:c,partitionColumn:d,partitionTable:null,partitionFilters:[],quickFilters:S?new Map(S):new Map,advancedFilters:new Map(w),shownAdvancedFilter:null,hoverAdvancedFilter:null,sorts:[],reverseType:x.REVERSE_TYPE.NONE,customColumns:[],selectDistinctColumns:I,selectedRanges:[],copyOperation:null,loadingText:null,loadingScrimProgress:null,loadingSpinnerShown:!1,movedColumns:W,movedRows:B,shownColumnTooltip:null,formatter:new jt,isMenuShown:!1,customColumnFormatMap:new Map(s),conditionalFormats:n,conditionalFormatEditIndex:null,conditionalFormatPreview:void 0,hoverSelectColumn:null,isTableDownloading:!1,isReady:!1,tableDownloadStatus:"",tableDownloadProgress:0,tableDownloadEstimatedTime:0,showSearchBar:g,searchFilter:A,searchValue:f,selectedSearchColumns:H,invertSearchColumns:b,rollupConfig:u,rollupSelectedColumns:[],aggregationSettings:t,selectedAggregation:null,openOptions:[],pendingRowCount:0,pendingDataMap:v!=null?v:new Map,pendingDataErrors:new Map,pendingSavePromise:null,pendingSaveError:null,toastMessage:null,frozenColumns:M,showOverflowModal:!1,overflowText:"",overflowButtonTooltipProps:null,isGotoRowShown:!1,gotoRow:"",gotoRowError:""}}static makeQuickFilter(e,t,n){try{return x.makeQuickFilter(e,t,n)}catch(s){oe.error("Error creating quick filter",s)}return null}componentDidMount(){const{partitionColumn:e,model:t}=this.props,n=e!=null?e:t.columns.find(s=>s.isPartitionColumn);t.isFilterRequired&&t.isValuesTableAvailable&&n!=null?this.loadPartitionsTable(n):this.initState(),this.startListening(t)}componentDidUpdate(e){var d;const{inputFilters:t,isSelectingColumn:n,settings:s,model:i,customFilters:o,sorts:r}=this.props;i!==e.model&&(this.stopListening(e.model),this.startListening(i));const l=t!==e.inputFilters?t.filter(u=>!e.inputFilters.includes(u)):[];if(l.length>0){const{advancedSettings:u}=this.props,m=(d=u.get(ds.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS))!=null?d:!1;m&&(this.clearGridInputField(),this.clearCrossColumSearch()),this.startLoading("Filtering...",!0),this.applyInputFilters(l,m)}n!==e.isSelectingColumn&&this.resetColumnSelection(),s!==e.settings&&this.updateFormatterSettings(s),o!==e.customFilters&&this.startLoading("Filtering...",!0),r!==e.sorts&&this.updateSorts(r);const{loadingScrimStartTime:a,loadingScrimFinishTime:c}=this;a!=null&&c!=null&&window.requestAnimationFrame(()=>{const u=Date.now(),m=u-a,p=c-a,g=Math.min(m/p,1);c<u&&(this.loadingScrimStartTime=void 0,this.loadingScrimFinishTime=void 0),this.setState(f=>f.loadingScrimProgress==null?(oe.debug2("Ignoring scrim update because loading cancelled."),null):{loadingScrimProgress:g})}),this.sendStateChange()}componentWillUnmount(){const{model:e}=this.props;this.stopListening(e),this.pending.cancel(),this.updateSearchFilter.cancel(),this.loadingTimer&&clearTimeout(this.loadingTimer),this.handleDownloadProgressUpdate.cancel(),this.animationFrame!==void 0&&cancelAnimationFrame(this.animationFrame)}getValueForCell(e,t,n=!1){const{model:s}=this.props,i=this.getModelColumn(e),o=this.getModelRow(t);return n&&i!=null&&o!=null?s.valueForCell(i,o):n?null:i!=null&&o!=null?s.textForCell(i,o):""}getModelColumn(e){const{metrics:t}=this.state;O(t);const{modelColumns:n}=t;return n==null?null:e!=null?n.get(e):null}getModelRow(e){const{metrics:t}=this.state;O(t);const{modelRows:n}=t;return n==null?null:e!=null?n.get(e):null}getTheme(){var n;const{model:e,theme:t}=this.props;return this.getCachedTheme(t,(n=Ae(e)&&e.isEditable)!=null?n:!1)}getVisibleColumn(e){const{movedColumns:t}=this.state;return U.getVisibleIndex(e,t)}applyInputFilters(e,t=!1){const{model:n}=this.props,{advancedFilters:s,quickFilters:i}=this.state,o=t?new Map:new Map(s),r=t?new Map:new Map(i);let l=t&&s.size>0;e.forEach(({name:a,type:c,value:d})=>{const u=n.columns.findIndex(({name:m,type:p})=>m===a&&p===c);u>=0?(l=o.delete(u)||l,l=this.applyQuickFilter(u,d,r)||l):oe.error("Unable to find column for inputFilter",a,c,d)}),l&&this.setState({quickFilters:r,advancedFilters:o})}applyQuickFilter(e,t,n){const{model:s}=this.props,{formatter:i}=s,o=s.columns[e];if(t!=null&&`${t}`.trim().length>0){const r=n.get(e);if(r!=null){const{text:l}=r;if(l===t)return oe.debug2("Ignoring change to existing filter"),!1}return n.set(e,{text:t,filter:ss.makeQuickFilter(o,t,i.timeZone)}),!0}return n.delete(e)}setAdvancedFilterMap(e){this.setState({advancedFilters:e})}setAdvancedFilter(e,t,n){oe.debug("Setting advanced filter",e,t),this.startLoading("Filtering...",!0),this.setState(({advancedFilters:s})=>{const i=new Map(s);return t==null?i.delete(e):i.set(e,{filter:t,options:n}),{advancedFilters:i}})}setQuickFilter(e,t,n){oe.debug("Setting quick filter",e,t,n),this.startLoading("Filtering...",!0),this.setState(({quickFilters:s})=>{const i=new Map(s);return i.set(e,{filter:t,text:n}),{quickFilters:i}})}setFilterMap(e){var i;oe.debug("setFilterMap",e);const{advancedSettings:t}=this.props;((i=t.get(ds.LINK_CHANGE_CLEARS_ALL_FILTERS))!=null?i:!1)&&this.clearAllFilters();const{model:s}=this.props;e.forEach(({columnType:o,text:r,value:l},a)=>{const c=s.columns.find(u=>u.name===a&&u.type===o);if(c==null)return;const d=s.getColumnIndexByName(c.name);if(O(d),l===null)this.setQuickFilter(d,c.filter().isNull(),"=null");else{const u=x.isTextType(o)?E.FilterValue.ofString(l):E.FilterValue.ofNumber(l);this.setQuickFilter(d,c.filter().eq(u),`${r}`)}})}removeColumnFilter(e){this.startLoading("Filtering...",!0),this.setState(({advancedFilters:t,quickFilters:n})=>{const s=t?new Map(t):new Map,i=n?new Map(n):new Map;return i.delete(e),s.delete(e),{quickFilters:i,advancedFilters:s}})}clearAllFilters(){oe.debug("Clearing all filters");const{advancedFilters:e,quickFilters:t,searchFilter:n}=this.state;t.size===0&&e.size===0&&n===null||(this.clearGridInputField(),this.startLoading("Clearing Filters...",!0),this.setState({quickFilters:new Map,advancedFilters:new Map,searchValue:"",searchFilter:void 0}))}clearCrossColumSearch(){oe.debug("Clearing cross-column search"),this.setState({searchValue:"",searchFilter:void 0})}clearGridInputField(){this.filterInputRef.current!=null&&this.filterInputRef.current.setValue("")}rebuildFilters(){oe.debug("Rebuilding filters");const{model:e}=this.props,{advancedFilters:t,quickFilters:n}=this.state,{columns:s,formatter:i}=e,o=new Map,r=new Map;t.forEach((l,a)=>{const{options:c}=l,d=s[a],u=x.makeAdvancedFilter(d,c,i.timeZone);o.set(a,{options:c,filter:u})}),n.forEach((l,a)=>{const{text:c}=l,d=s[a];r.set(a,{text:c,filter:ss.makeQuickFilter(d,c,i.timeZone)})}),this.startLoading("Rebuilding filters...",!0),this.setState({quickFilters:r,advancedFilters:o})}setFilters({quickFilters:e,advancedFilters:t}){this.setState({quickFilters:e,advancedFilters:t})}updateFormatterSettings(e,t=!0){var m,p,g;const n=ls.getColumnFormats(e),s=ls.getDateTimeFormatterOptions(e),i=(m=e==null?void 0:e.defaultDecimalFormatOptions)!=null?m:{},o=(p=e==null?void 0:e.defaultIntegerFormatOptions)!=null?p:{},r=(g=e==null?void 0:e.truncateNumbersWithPound)!=null?g:!1,l=!ct(this.globalColumnFormats,n),a=!ct(this.dateTimeFormatterOptions,s),c=!ct(this.decimalFormatOptions,e==null?void 0:e.defaultDecimalFormatOptions),d=!ct(this.integerFormatOptions,o),u=this.truncateNumbersWithPound!==r;(l||a||c||d||u)&&(this.globalColumnFormats=n,this.dateTimeFormatterOptions=s,this.decimalFormatOptions=i,this.integerFormatOptions=o,this.truncateNumbersWithPound=r,this.updateFormatter({},t),a&&t&&this.rebuildFilters())}updateFormatter(e,t=!0){var r;const{customColumnFormatMap:n}=this.state,s={customColumnFormatMap:n,...e},i=[...(r=this.globalColumnFormats)!=null?r:[],...s.customColumnFormatMap.values()],o=new jt(i,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions,this.truncateNumbersWithPound);oe.debug("updateFormatter",this.globalColumnFormats,i),this.setState({...s,formatter:o},()=>{t&&this.grid&&this.grid.forceUpdate()})}initFormatter(){const{settings:e}=this.props;this.updateFormatterSettings(e)}initState(){const{applyInputFiltersOnInit:e,inputFilters:t,sorts:n,model:s,reverseType:i,customColumns:o,searchValue:r,selectedSearchColumns:l,invertSearchColumns:a}=this.props,c=l!=null?l:[],d=xi.createSearchFilter(r,c,s.columns,a);if(e){const u=t.filter(m=>m.value!=null);this.applyInputFilters(u)}this.setState({sorts:n,reverseType:i,customColumns:o,isReady:!0,searchFilter:d}),this.initFormatter()}async loadPartitionsTable(e){const{model:t}=this.props;this.setState({isSelectingPartition:!0});try{const n=await this.pending.add(t.valuesTable(e),r=>r.close()),s=n.columns[0],i=s.sort().desc();n.applySort([i]),n.setViewport(0,0,[s]);const o=await this.pending.add(n.getViewportData());if(o.rows.length>0){const l=o.rows[0].get(s);this.updatePartition(l,e),this.setState({isSelectingPartition:!0})}else oe.info("Table does not have any data, just fetching all"),this.setState({isSelectingPartition:!1}),this.handlePartitionFetchAll();this.setState({partitionTable:n,partitionColumn:e},()=>{this.initState()})}catch(n){this.handleTableLoadError(n)}}updatePartition(e,t){const s=[t.filter().eq(E.FilterValue.ofString(e))];this.setState({partition:e,partitionFilters:s})}copyCell(e,t,n=!1){const{canCopy:s}=this.props;if(s){const i=String(this.getValueForCell(e,t,n));ve.copyToClipboard(i).catch(o=>oe.error("Unable to copy cell",o))}else oe.error("Attempted to copyCell for user without copy permission.")}copyRanges(e,t=!1,n=!0,s){const{model:i,canCopy:o}=this.props,{metricCalculator:r,movedColumns:l}=this.state,a=r.getUserColumnWidths();if(o){const c={ranges:Z.boundedRanges(e,i.columnCount,i.rowCount),includeHeaders:t,formatValues:n,movedColumns:l,userColumnWidths:a,error:s};this.setState({copyOperation:c})}else oe.error("Attempted copyRanges for user without copy permission.")}startLoading(e,t=!1){var s,i;this.setState({loadingText:e});const n=this.getTheme();if(t&&this.grid&&(this.grid.clearSelectedRanges(),this.grid.setViewState({top:0},!0)),this.loadingScrimStartTime==null){const{minScrimTransitionTime:o,maxScrimTransitionTime:r}=n;O(o),O(r);const l=(i=(s=this.gridWrapper)==null?void 0:s.getBoundingClientRect().height)!=null?i:0,a=Math.max(o,Math.min(l/2,r));this.loadingScrimStartTime=Date.now(),this.loadingScrimFinishTime=this.loadingScrimStartTime+a,this.setState({loadingScrimProgress:0}),this.loadingTimer=setTimeout(()=>{this.setState({loadingSpinnerShown:!0})},ss.loadingSpinnerDelay)}}stopLoading(){this.loadingScrimStartTime=void 0,this.loadingScrimFinishTime=void 0,this.setState({loadingText:null,loadingScrimProgress:null,loadingSpinnerShown:!1}),this.loadingTimer!=null&&(clearTimeout(this.loadingTimer),this.loadingTimer=void 0)}rollback(){if(this.lastLoadedConfig){oe.debug("loading last loading config",this.lastLoadedConfig);const{advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a}=this.lastLoadedConfig;this.lastLoadedConfig=null,this.setState({advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a})}else oe.debug("remove all sorts, filters, and custom columns"),this.setState({advancedFilters:new Map,aggregationSettings:ic,customColumns:[],quickFilters:new Map,reverseType:x.REVERSE_TYPE.NONE,rollupConfig:void 0,selectDistinctColumns:[],sorts:[]})}canRollback(){return this.lastLoadedConfig!=null||!Fl(this.state)}startListening(e){e.addEventListener(ue.EVENT.UPDATED,this.handleUpdate),e.addEventListener(ue.EVENT.REQUEST_FAILED,this.handleRequestFailed),e.addEventListener(ue.EVENT.COLUMNS_CHANGED,this.handleCustomColumnsChanged),e.addEventListener(ue.EVENT.PENDING_DATA_UPDATED,this.handlePendingDataUpdated)}stopListening(e){e.removeEventListener(ue.EVENT.UPDATED,this.handleUpdate),e.removeEventListener(ue.EVENT.REQUEST_FAILED,this.handleRequestFailed),e.removeEventListener(ue.EVENT.COLUMNS_CHANGED,this.handleCustomColumnsChanged),e.removeEventListener(ue.EVENT.PENDING_DATA_UPDATED,this.handlePendingDataUpdated)}focus(){var e;(e=this.grid)==null||e.focus()}focusFilterBar(e){var d,u,m;const{model:t}=this.props,{columnCount:n}=t,s=this.getModelColumn(e);if(e==null||s==null||e<0||n<=e||!t.isFilterable(s)){this.setState({focusedFilterBarColumn:null});return}const{metricCalculator:i,metrics:o}=this.state;O(o);const{gridX:r,left:l,rightVisible:a,lastLeft:c}=o;if(e<l)(d=this.grid)==null||d.setViewState({left:e},!0);else if(a<e){const p=(u=this.grid)==null?void 0:u.getMetricState();O(p);const g=i.getLastLeft(p,e,r);(m=this.grid)==null||m.setViewState({left:Math.min(g,c)},!0)}this.lastFocusedFilterBarColumn=e,this.setState({focusedFilterBarColumn:e,isFilterBarShown:!0})}hideColumnByVisibleIndex(e){var s;const{metricCalculator:t,movedColumns:n}=this.state;t.setColumnWidth(U.getModelIndex(e,n),0),(s=this.grid)==null||s.forceUpdate()}freezeColumnByColumnName(e){const{frozenColumns:t,movedColumns:n}=this.state,{model:s}=this.props;oe.debug2("freezing column",e);const i=t==null?new Set(s.frozenColumns):new Set(t);i.add(e);const o=s.getColumnIndexByName(e);O(o);const r=U.getVisibleIndex(o,n),l=U.moveItem(r,i.size-1,n);this.setState({frozenColumns:[...i],movedColumns:l})}unFreezeColumnByColumnName(e){const{frozenColumns:t,movedColumns:n}=this.state,{model:s}=this.props;oe.debug2("unfreezing column",e);const i=t==null?new Set(s.frozenColumns):new Set(t);i.delete(e);const o=s.getColumnIndexByName(e);O(o);const r=U.getVisibleIndex(o,n),l=U.moveItem(r,i.size+s.frontColumns.length,n);this.setState({frozenColumns:[...i],movedColumns:l})}handleColumnVisibilityChanged(e,t){var s;const{metricCalculator:n}=this.state;t===us.VISIBILITY_OPTIONS.SHOW?e.forEach(i=>{n.resetColumnWidth(i)}):e.forEach(i=>{n.setColumnWidth(i,0)}),(s=this.grid)==null||s.forceUpdate()}handleCrossColumnSearch(e,t,n){const{model:s}=this.props;this.updateSearchFilter(e,t,s.columns,n),this.setState({searchValue:e,selectedSearchColumns:t,invertSearchColumns:n})}handleAnimationLoop(){var e,t;(e=this.grid)==null||e.updateCanvasScale(),(t=this.grid)==null||t.updateCanvas(),this.isAnimating&&(this.animationFrame=requestAnimationFrame(this.handleAnimationLoop))}handleAnimationStart(){oe.debug2("handleAnimationStart"),this.isAnimating=!0,this.animationFrame=requestAnimationFrame(this.handleAnimationLoop)}handleAnimationEnd(){oe.debug2("handleAnimationEnd"),this.isAnimating=!1}handlePartitionAppend(e){const{onPartitionAppend:t}=this.props,{partitionColumn:n}=this.state;t(n,e)}handlePartitionChange(e){const{partitionColumn:t}=this.state;this.updatePartition(e,t)}handlePartitionFetchAll(){this.setState({partitionFilters:[],isSelectingPartition:!1})}handlePartitionDone(){this.setState({isSelectingPartition:!1})}handleTableLoadError(e){if(He.isCanceled(e))return;oe.error(e);const{onError:t}=this.props;t(e)}showAllColumns(){var s;const{metricCalculator:e}=this.state,n=[...e.getUserColumnWidths().entries()];for(let i=0;i<n.length;i+=1){const[o,r]=n[i];r===0&&e.resetColumnWidth(o)}(s=this.grid)==null||s.forceUpdate()}toggleSort(e,t){oe.info("Toggling sort for column",e);const{model:n}=this.props,{sorts:s}=this.state,i=this.getModelColumn(e);O(i);const o=x.toggleSortForColumn(s,n.columns,i,t);this.updateSorts(o)}updateSorts(e){var t;this.startLoading("Sorting..."),this.setState({sorts:e}),(t=this.grid)==null||t.forceUpdate()}sortColumn(e,t=x.sortDirection.none,n=!1,s=!1){var r;O(e);const{model:i}=this.props,o=x.sortColumn(i.sort,i.columns,e,t,n,s);this.startLoading("Sorting..."),this.setState({sorts:o}),(r=this.grid)==null||r.forceUpdate()}reverse(e){var t;this.startLoading("Reversing..."),this.setState({reverseType:e}),(t=this.grid)==null||t.forceUpdate()}isReversible(){const{model:e}=this.props;return e.isReversible}toggleFilterBar(e=this.lastFocusedFilterBarColumn){var n;let{isFilterBarShown:t}=this.state;if(t=!t,this.setState({isFilterBarShown:t}),t)if(e!=null)this.focusFilterBar(e);else{let s=0;const{model:i}=this.props,{columnCount:o}=i;for(let r=0;r<o;r+=1){const l=this.getModelColumn(r);if(l!=null){const a=i.columns[l];if(a!=null&&x.isTextType(a.type)){s=r;break}}}this.focusFilterBar(s)}else(n=this.grid)==null||n.focus()}isTableSearchAvailable(){var s,i,o;const{model:e,canToggleSearch:t}=this.props,n=(s=e==null?void 0:e.layoutHints)==null?void 0:s.searchDisplayMode;return n===((i=E.SearchDisplayMode)==null?void 0:i.SEARCH_DISPLAY_HIDE)?!1:n===((o=E.SearchDisplayMode)==null?void 0:o.SEARCH_DISPLAY_SHOW)?!0:t}toggleSearchBar(){const{showSearchBar:e}=this.state;if(!this.isTableSearchAvailable())return;const t=!e;this.setState({showSearchBar:t},()=>{var n,s,i;t&&((n=this.crossColumnRef)==null?void 0:n.current)?(s=this.crossColumnRef)==null||s.current.focus():(i=this.grid)==null||i.focus()})}toggleGotoRow(e=""){const{isGotoRowShown:t}=this.state;if(e){this.setState({isGotoRowShown:!0,gotoRow:e,gotoRowError:""});return}this.setState({isGotoRowShown:!t,gotoRow:"",gotoRowError:""})}async commitPending(){var i,o;const{model:e}=this.props;if(!Ae(e)||!e.isEditable)throw new Error("Cannot save, table is not editable");const{pendingSavePromise:t}=this.state;if(t!=null)throw new Error("Save already in progress");const n=(i=document==null?void 0:document.activeElement)==null?void 0:i.classList.contains("grid-cell-input-field");if(n!=null&&n){if(document.activeElement!=null&&document.activeElement.classList.contains("error"))throw new Zd("Current input is invalid");(o=this.grid)==null||o.focus()}const s=this.pending.add(e.commitPending()).then(()=>{this.setState({pendingSaveError:null,pendingSavePromise:null})}).catch(r=>{He.isCanceled(r)||this.setState({pendingSaveError:r,pendingSavePromise:null})});return this.setState({pendingSavePromise:s}),s}async discardPending(){const{pendingSavePromise:e}=this.state;if(e!=null)throw new Error("Cannot cancel a save in progress");this.setState({pendingSavePromise:null,pendingSaveError:null,pendingDataMap:new Map,pendingDataErrors:new Map})}selectColumn(e){const{onColumnSelected:t}=this.props;t(e)}selectData(e,t){const{model:n}=this.props,{columns:s}=n,i={};for(let r=0;r<s.length;r+=1){const l=s[r],{name:a,type:c}=l,d=n.valueForCell(r,t),u=n.textForCell(r,t);i[a]={value:d,text:u,type:c}}const{onDataSelected:o}=this.props;o(t,i)}handleAdvancedFilterChange(e,t,n){const{model:s}=this.props,i=s.getColumnIndexByName(e.name);O(i),this.setAdvancedFilter(i,t,n)}handleAdvancedFilterSortChange(e,t,n=!1){var a;const{model:s}=this.props,i=s.getColumnIndexByName(e.name);O(i);const o=x.getSortForColumn(s.sort,i);let r=null;(o==null||o.direction!==t)&&(t===x.sortDirection.descending?r=e.sort().desc():r=e.sort().asc());const l=x.setSortForColumn(s.sort,i,r,n);oe.info("Setting table sorts",l),this.startLoading("Sorting..."),this.setState({sorts:l}),(a=this.grid)==null||a.forceUpdate()}handleAdvancedFilterDone(){var e;(e=this.grid)==null||e.focus()}handleAdvancedMenuOpened(e){this.setState({shownAdvancedFilter:e})}handleGotoRowOpened(){this.setState({isGotoRowShown:!0})}handleGotoRowClosed(){this.setState({isGotoRowShown:!1})}handleAdvancedMenuClosed(e){var s,i;const{focusedFilterBarColumn:t,isFilterBarShown:n}=this.state;n&&t===e&&((s=this.filterInputRef)==null?void 0:s.current)!==null?((i=this.filterInputRef)==null||i.current.focus(),this.setState({shownAdvancedFilter:null})):this.setState({focusedFilterBarColumn:null,shownAdvancedFilter:null})}handleCancel(){this.rollback()}handleChartChange(){}handleChartCreate(e){const{model:t,onCreateChart:n}=this.props;n(e,t)}handleGridError(e){oe.warn("Grid Error",e),this.setState({toastMessage:h("div",{className:"error-message",children:`${e}`})})}handleFilterBarChange(e){this.startLoading("Filtering...",!0),this.setState(({focusedFilterBarColumn:t,quickFilters:n})=>{const s=new Map(n);if(t!=null){const i=this.getModelColumn(t);O(i),this.applyQuickFilter(i,e,s)}return{quickFilters:s}})}handleFilterBarDone(e=!0,t=!0){var n;e&&((n=this.grid)==null||n.focus()),t&&this.setState({focusedFilterBarColumn:null})}handleFilterBarTab(e){const{focusedFilterBarColumn:t}=this.state;O(t),e?this.focusFilterBar(t-1):this.focusFilterBar(t+1)}handleFormatSelection(e,t){const{model:n}=this.props,s=n.columns[e],{customColumnFormatMap:i}=this.state,o=new Map(i);if(t!=null){const r=x.getNormalizedType(s.type);O(r);const l=jt.makeColumnFormattingRule(r,s.name,t);o.set(s.name,l)}else o.delete(s.name);this.updateFormatter({customColumnFormatMap:o})}handleMenu(e){e.stopPropagation(),this.setState({isMenuShown:!0})}handleMenuClose(){this.setState({isMenuShown:!1,openOptions:[]})}handleMenuBack(){this.setState(({openOptions:e})=>{const t=[...e];return t.pop(),{openOptions:t}})}handleMenuSelect(e){this.setState(({openOptions:t})=>({openOptions:[...t,e]}))}handleRequestFailed(e){const t=e;if(oe.error("request failed:",t.detail),this.stopLoading(),this.canRollback())this.startLoading("Rolling back changes...",!0),this.rollback();else{oe.error("Table failed and unable to rollback");const{onError:n}=this.props;n(new Error(`Error displaying table: ${t.detail}`))}}handleUpdate(){var d;this.stopLoading(),oe.debug2("Received model update");const{advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a}=this.state,c={advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a};Fl(c)?this.lastLoadedConfig=null:this.lastLoadedConfig=c,(d=this.grid)==null||d.forceUpdate()}handleViewChanged(e){var i,o;const{model:t}=this.props,{selectionEndRow:n=0}=(o=(i=this.grid)==null?void 0:i.state)!=null?o:{};let s=0;if(Ae(t)&&t.isEditable){O(e);const{bottomViewport:r}=e,l=t.rowCount-t.floatingBottomRowCount;n===l-1?s=t.pendingRowCount+1:n===l-2?s=t.pendingRowCount:s=Math.max(0,r-(t.rowCount-t.pendingRowCount)-t.floatingTopRowCount-t.floatingBottomRowCount-1)}this.setState({metrics:e,pendingRowCount:s})}handleSelectionChanged(e){O(e);const{onSelectionChanged:t}=this.props,{copyOperation:n}=this.state;this.setState({selectedRanges:e}),n!=null&&this.setState({copyOperation:null}),t(e)}handleMovedColumnsChanged(e,t=()=>null){this.setState({movedColumns:e},t)}handleTooltipRef(e){e!=null&&e.startTimer(),this.tooltip=e}handleConditionalFormatsChange(e){oe.debug("Updated conditional formats",e),this.setState({conditionalFormats:e})}handleConditionalFormatCreate(){oe.debug("Create new conditional format");const{openOptions:e,conditionalFormats:t}=this.state;this.setState({openOptions:[...e,{type:we.CONDITIONAL_FORMATTING_EDIT,title:"Create Formatting Rule"}],conditionalFormatEditIndex:t.length,conditionalFormatPreview:void 0})}handleConditionalFormatEdit(e){oe.debug("Edit conditional format",e);const{openOptions:t,conditionalFormats:n}=this.state;this.setState({openOptions:[...t,{type:we.CONDITIONAL_FORMATTING_EDIT,title:"Edit Formatting Rule"}],conditionalFormatEditIndex:e,conditionalFormatPreview:{...n[e]}})}handleConditionalFormatEditorSave(e){oe.debug("Save conditional format changes",e),this.setState(t=>{if(t.conditionalFormatEditIndex===null)return oe.debug("Invalid format index"),null;const n=[...t.conditionalFormats];return n[t.conditionalFormatEditIndex]=e,{conditionalFormats:n}},()=>{this.handleMenuBack()})}handleConditionalFormatEditorCancel(){this.handleMenuBack(),this.setState({conditionalFormatEditIndex:null})}handleUpdateCustomColumns(e){oe.info("handleUpdateCustomColumns:",e);const{model:t}=this.props,{movedColumns:n,sorts:s,quickFilters:i,advancedFilters:o,selectDistinctColumns:r}=this.state,{columns:l}=t,a=t.customColumns.map(d=>`${d}`),c=ne.getRemovedCustomColumnNames(a,e);if(c.length>0){const d=ne.removeSortsInColumns(s,c),u=ne.removeFiltersInColumns(l,i,c),m=ne.removeFiltersInColumns(l,o,c),p=ne.removeColumnFromMovedColumns(l,n,c),g=ne.removeColumnsFromSelectDistinctColumns(r,c);d.length!==s.length&&(oe.debug("removing sorts from removed custom columns..."),this.setState({sorts:d})),(u.size!==i.size||m.size!==o.size)&&(oe.debug("removing filters from removed custom columns..."),this.setState({quickFilters:u,advancedFilters:m})),ct(n,p)||(oe.debug("change moved columns for removed custom columns",p),this.setState({movedColumns:p})),ct(r,g)||(oe.debug("change selectDistinct columns for removed custom columns",p),this.setState({selectDistinctColumns:g}))}this.setState({customColumns:e}),this.startLoading("Applying custom columns...")}handleCustomColumnsChanged(){var t;oe.debug("custom columns changed");const{isReady:e}=this.state;e?(this.stopLoading(),(t=this.grid)==null||t.forceUpdate()):this.initState()}handlePendingCommitClicked(){return this.commitPending()}handlePendingDiscardClicked(){return this.discardPending()}handlePendingDataUpdated(){var s;oe.debug("pending data updated");const{model:e}=this.props,{pendingDataMap:t,pendingDataErrors:n}=e;this.setState({pendingDataMap:t,pendingDataErrors:n,pendingSaveError:null}),(s=this.grid)==null||s.forceUpdate()}handleAggregationsChange(e){oe.debug("handleAggregationsChange",e),this.startLoading(`Aggregating ${e.aggregations.map(t=>t.operation).join(", ")}...`),this.setState({aggregationSettings:e})}handleAggregationChange(e){oe.debug("handleAggregationChange",e),this.startLoading(`Aggregating ${e.operation}...`),this.setState(({aggregationSettings:t})=>({selectedAggregation:e,aggregationSettings:{...t,aggregations:t.aggregations.map(n=>n.operation===e.operation?e:n)}}))}handleAggregationEdit(e){oe.debug("handleAggregationEdit",e);const{openOptions:t}=this.state;this.setState({openOptions:[...t,{type:we.AGGREGATION_EDIT,title:`Edit Columns to ${e.operation}`}],selectedAggregation:e})}handleRollupChange(e){var t,n;oe.info("Rollup change",e),this.resetGridViewState(),this.showAllColumns(),this.clearAllFilters(),this.startLoading(`Grouping by columns ${(n=(t=e==null?void 0:e.columns)==null?void 0:t.join(", "))!=null?n:""}...`),this.setState({rollupConfig:e,movedColumns:[],sorts:[],reverseType:x.REVERSE_TYPE.NONE,selectDistinctColumns:[]})}handleSelectDistinctChanged(e){oe.debug("SelectDistinct change",e),this.resetGridViewState(),this.showAllColumns(),this.clearAllFilters(),this.startLoading(`Selecting distinct values in ${e.length>0?e.join(", "):""}...`),this.setState({selectDistinctColumns:e,movedColumns:[],sorts:[],reverseType:x.REVERSE_TYPE.NONE})}handleDownloadTableStart(){const{canDownloadCsv:e}=this.props;e?this.setState({isTableDownloading:!0,tableDownloadProgress:0,tableDownloadEstimatedTime:null,tableDownloadStatus:wt.DOWNLOAD_STATUS.INITIATING}):oe.error("Attempted to handleDownloadTableStart for user without download CSV permission.")}handleDownloadTable(e,t,n,s){const{canDownloadCsv:i}=this.props;i?(oe.info("start table downloading",e,t,n,s),this.setState(()=>(this.tableSaver&&this.tableSaver.startDownload(e,t,n,s),{tableDownloadStatus:wt.DOWNLOAD_STATUS.DOWNLOADING}))):oe.error("Attempted to handleDownloadTable for user without download CSV permission.")}handleCancelDownloadTable(){var e;(e=this.tableSaver)==null||e.cancelDownload(),this.setState({isTableDownloading:!1})}handleDownloadCompleted(){this.setState({isTableDownloading:!1,tableDownloadProgress:100,tableDownloadStatus:wt.DOWNLOAD_STATUS.FINISHED})}handleDownloadCanceled(){this.setState({isTableDownloading:!1,tableDownloadProgress:0,tableDownloadStatus:wt.DOWNLOAD_STATUS.CANCELED})}deleteRanges(e){const{model:t}=this.props;this.pending.add(t.delete(e)).catch(n=>{He.isCanceled(n)||oe.error("Unable to delete ranges",e,n)})}resetColumnSelection(){if(this.grid==null)return;const{isSelectingColumn:e}=this.props;if(e){const{columnAllowedCursor:t}=this.props;this.grid.setState({cursor:t})}else this.grid.setState({cursor:null}),this.setState({hoverSelectColumn:null})}resetGridViewState(e=!0){!this.grid||(this.grid.clearSelectedRanges(),this.grid.setViewState({left:0,top:0,topOffset:0,leftOffset:0},e))}sendStateChange(){if(!this.grid)return;const{state:e}=this,{state:t}=this.grid,{onStateChange:n}=this.props;n(e,t)}handleOverflowClose(){this.setState({showOverflowModal:!1})}getColumnBoundingRect(){var m;const{metrics:e,shownColumnTooltip:t}=this.state;O(e),O(t);const n=(m=this.gridWrapper)==null?void 0:m.getBoundingClientRect(),s=20;O(n);const{columnHeaderHeight:i,visibleColumnXs:o,visibleColumnWidths:r,width:l,columnHeaderMaxDepth:a}=e,c=o.get(t),d=r.get(t);O(c),O(d);const u=n.left+rt(c+d/2,s,l-s);return{top:n.top+(a-1)*i,left:n.left+rt(c+d/2,s,l-s),bottom:n.top+a*i,right:n.left+rt(c+d/2,s,l-s)+1,width:1,height:i,x:u,y:n.top,toJSON:()=>{throw new Error("not implemented")}}}handleGotoRowSelectedRowNumberSubmit(){const{gotoRow:e}=this.state;this.focusRowInGrid(e)}focusRowInGrid(e){var i,o,r;const{model:t}=this.props,{rowCount:n}=t;if(this.setState({gotoRow:e}),e===""){this.setState({gotoRowError:""});return}const s=parseInt(e,10);s>n||s<-n?this.setState({gotoRowError:"Invalid row index"}):s===0?(this.setState({gotoRowError:""}),(i=this.grid)==null||i.setFocusRow(0)):s<0?(this.setState({gotoRowError:""}),(o=this.grid)==null||o.setFocusRow(s+n)):((r=this.grid)==null||r.setFocusRow(s-1),this.setState({gotoRowError:""}))}handleGotoRowSelectedRowNumberChanged(e){const t=e.target.value;this.focusRowInGrid(t)}getColumnTooltip(e,t,n){const{columnHeaderHeight:s,columnHeaderMaxDepth:i,visibleColumnXs:o,visibleColumnWidths:r,width:l}=t,a=o.get(e),c=r.get(e);if(a==null||c==null)return null;const d=Math.max(0,a);let u=c;a+c>l?u=l-a:a<0&&(u=c-Math.abs(a));const m={position:"absolute",top:(i-1)*s,left:d,width:u,height:s,pointerEvents:"none"},p={clientWidth:1,clientHeight:s,getBoundingClientRect:this.getColumnBoundingRect},g={placement:"bottom",modifiers:{flip:{behavior:["bottom","top"]}}},f=this.getModelColumn(e);if(f==null)return null;const C=n.columns[f];return C==null?null:h("div",{style:m,children:h(ge,{timeout:400,interactive:!0,options:g,ref:this.handleTooltipRef,referenceObject:p,onExited:()=>{this.setState({shownColumnTooltip:null})},children:h(ka,{model:n,column:C,onStatistics:()=>{var b;(b=this.tooltip)==null||b.update()}})},C.name)})}render(){var We,ps,Ir,Mr,Dr,Nr,Fr,xr,Or;const{children:e,customFilters:t,getDownloadWorker:n,isSelectingColumn:s,isStuckToBottom:i,isStuckToRight:o,model:r,name:l,onlyFetchVisibleColumns:a,alwaysFetchColumns:c,advancedSettings:d,onAdvancedSettingsChange:u,canDownloadCsv:m,onCreateChart:p}=this.props,{metricCalculator:g,metrics:f,isFilterBarShown:C,isSelectingPartition:b,isMenuShown:w,isReady:S,copyOperation:I,focusedFilterBarColumn:v,loadingText:R,loadingScrimProgress:M,loadingSpinnerShown:F,keyHandlers:P,mouseHandlers:W,shownColumnTooltip:B,hoverAdvancedFilter:N,shownAdvancedFilter:H,hoverSelectColumn:A,quickFilters:L,advancedFilters:_,partition:V,partitionFilters:G,partitionTable:j,partitionColumn:ee,searchFilter:re,selectDistinctColumns:be,movedColumns:ce,movedRows:Te,formatter:_e,conditionalFormats:Ke,conditionalFormatPreview:Mt,conditionalFormatEditIndex:Xe,sorts:Ze,reverseType:Le,customColumns:Ut,selectedRanges:Bn,isTableDownloading:tn,tableDownloadStatus:tt,tableDownloadProgress:pe,tableDownloadEstimatedTime:ze,showSearchBar:Be,searchValue:ut,selectedSearchColumns:Dt,invertSearchColumns:Nt,aggregationSettings:ht,selectedAggregation:Wn,rollupConfig:Ft,openOptions:xt,pendingSavePromise:zn,pendingSaveError:ao,pendingRowCount:co,pendingDataErrors:uo,pendingDataMap:li,toastMessage:ai,frozenColumns:ci,showOverflowModal:di,overflowText:ui,overflowButtonTooltipProps:hi,isGotoRowShown:mi,gotoRow:ho,gotoRowError:mo}=this.state;if(!S)return null;const $n=this.getTheme(),po=this.getCachedFilter(t,L,_,G,re),ms=g.getUserColumnWidths(),Ps=this.getCachedStateOverride(A,C,s,M,L,_,Ze,Le,Ft,w),pi=f?f.top:0,gi=f?f.bottomViewport:0;let Hs=null,_s=null;a&&(Hs=f?f.left:0,_s=f?f.right:0);const go=f!=null&&f.width>0&&f.height>0,fo=((ps=(We=Ft==null?void 0:Ft.columns)==null?void 0:We.length)!=null?ps:0)>0;let fi=null;const Co=f?Math.min(Math.max(ss.minDebounce,Math.round(f.rowCount/200)),ss.maxDebounce):ss.maxDebounce;if(C&&v!=null&&f!=null){const{gridX:xe,gridY:mt,visibleColumnXs:bn,visibleColumnWidths:Vs}=f,Gn=bn.get(v),Bt=Vs.get(v);if(Gn!=null&&Bt!=null){const pt=xe+Gn,lt=mt-((Ir=$n.filterBarHeight)!=null?Ir:0),nn=Bt+1,qn=((Mr=$n.filterBarHeight)!=null?Mr:0)-1,Kn={top:lt,left:pt,minWidth:nn,height:qn};let gs="",sn=!0;const Xn=this.getModelColumn(v);O(Xn);const Yn=L.get(Xn),Us=_.get(Xn);Yn!=null&&(gs=Yn.text,sn=Yn.filter!=null);const Qn=L.size!==0||_.size!==0;fi=h(Na,{ref:this.filterInputRef,style:Kn,className:$({error:!sn,active:gs!==""||Us!=null,"iris-grid-has-filter":Qn}),isAdvancedFilterSet:Us!=null,onAdvancedFiltersTriggered:()=>{this.setState({shownAdvancedFilter:v})},onChange:this.handleFilterBarChange,onDone:this.handleFilterBarDone,onTab:this.handleFilterBarTab,onContextMenu:(Dr=this.grid)==null?void 0:Dr.handleContextMenu,debounceMs:Co,value:gs},v)}}let Ci=null;if(R!=null){const xe=T("div",{className:"iris-grid-loading-status",children:[h("div",{className:$("iris-grid-loading-status-bar",{show:F}),children:R}),T("button",{type:"button",onClick:this.handleCancel,className:$("iris-grid-btn-cancel",{show:F}),children:[h(K,{icon:ti,transform:"down-1"}),"Cancel"]})]}),mt=f?f.gridY:0;Ci=h("div",{className:"iris-grid-loading",style:{top:mt},children:xe})}let bi=null;B!=null&&f&&(bi=this.getColumnTooltip(B,f,r),(Nr=this.tooltip)==null||Nr.update());const wi=[];if(f&&C){const{gridX:xe,gridY:mt,visibleColumns:bn,visibleColumnXs:Vs,visibleColumnWidths:Gn}=f,{filterBarHeight:Bt}=$n;for(let pt=0;pt<bn.length;pt+=1){const lt=bn[pt],nn=Vs.get(lt),qn=Gn.get(lt),Kn=this.getModelColumn(lt);if(Kn!=null&&r.isFilterable(Kn)&&nn!=null&&qn!=null&&qn>0){const sn=xe+nn+qn-24,Xn=mt-(Bt!=null?Bt:0)+2,Yn={position:"absolute",top:Xn,left:sn},Qn=_.get(Kn)!=null,Ti=lt===N||lt===v||Qn,So=h("div",{className:$("advanced-filter-button-container",{hidden:!Ti}),style:Yn,children:Ti&&h("button",{type:"button",className:$("btn btn-link btn-link-icon advanced-filter-button",{"filter-set":Qn}),onClick:()=>{this.setState({shownAdvancedFilter:lt})},onContextMenu:ac=>{var Ar;(Ar=this.grid)==null||Ar.handleContextMenu(ac)},onMouseEnter:()=>{this.setState({hoverAdvancedFilter:lt})},onMouseLeave:()=>{this.setState({hoverAdvancedFilter:null})},children:T("div",{className:"fa-layers",children:[h(K,{icon:jo,className:"filter-solid"}),h(K,{icon:Vi,className:"filter-light"})]})})},lt);wi.push(So)}}}const Si=[];if(f){const{gridX:xe,visibleColumns:mt,visibleColumnXs:bn,visibleColumnWidths:Vs,columnHeaderHeight:Gn}=f;for(let Bt=0;Bt<mt.length;Bt+=1){const pt=mt[Bt],lt=bn.get(pt),nn=Vs.get(pt);if(lt!=null&&nn!=null&&nn>0){const qn=xe+lt,Kn=xe+lt+nn-20,gs=C?{position:"absolute",top:Gn,left:Kn,width:20,height:$n.filterBarHeight}:{position:"absolute",top:0,left:qn,width:nn,height:Gn},sn=this.getModelColumn(pt);if(sn!=null){const Xn=r.columns[sn],Yn=_.get(sn),{options:Us}=Yn||{},Qn=x.getSortForColumn(r.sort,sn),Ti=Qn?Qn.direction:null,So=h("div",{className:"advanced-filter-menu-container",style:gs,children:h(fn,{className:"advanced-filter-menu-popper",onEntered:this.getAdvancedMenuOpenedHandler(pt),onExited:()=>{this.handleAdvancedMenuClosed(pt)},isShown:H===pt,interactive:!0,closeOnBlur:!0,options:{positionFixed:!0},children:this.getCachedAdvancedFilterMenuActions(r,Xn,Us,Ti,_e)})},pt);Si.push(So)}}}}const vi=this.getCachedOptionItems(p!==void 0&&r.isChartBuilderAvailable,r.isCustomColumnsAvailable,r.isFormatColumnsAvailable,r.isRollupAvailable,r.isTotalsAvailable,r.isSelectDistinctAvailable,r.isExportAvailable,this.toggleFilterBarAction,this.toggleSearchBarAction,this.toggleGotoRowAction,C,Be,m,this.isTableSearchAvailable(),mi),bo=xt.map(xe=>{switch(xe.type){case we.CHART_BUILDER:return h(ba,{model:r,onChange:this.handleChartChange,onSubmit:this.handleChartCreate},we.CHART_BUILDER);case we.VISIBILITY_ORDERING_BUILDER:return h(us,{model:r,movedColumns:ce,userColumnWidths:ms,onColumnVisibilityChanged:this.handleColumnVisibilityChanged,onMovedColumnsChanged:this.handleMovedColumnsChanged},we.VISIBILITY_ORDERING_BUILDER);case we.CONDITIONAL_FORMATTING:return h(Hm,{rules:Ke,onChange:this.handleConditionalFormatsChange,onCreate:this.handleConditionalFormatCreate,onSelect:this.handleConditionalFormatEdit});case we.CONDITIONAL_FORMATTING_EDIT:return O(r.columns),O(this.handleConditionalFormatEditorUpdate),h(dp,{columns:r.columns,rule:Mt,onUpdate:this.handleConditionalFormatEditorUpdate,onSave:this.handleConditionalFormatEditorSave,onCancel:this.handleConditionalFormatEditorCancel});case we.CUSTOM_COLUMN_BUILDER:return h(gr,{model:r,customColumns:Ut,onSave:this.handleUpdateCustomColumns,onCancel:this.handleMenuBack},we.CUSTOM_COLUMN_BUILDER);case we.ROLLUP_ROWS:return h(fr,{model:r,onChange:this.handleRollupChange,config:Ft},we.ROLLUP_ROWS);case we.AGGREGATIONS:return h(Qu,{settings:ht,isRollup:fo,onChange:this.handleAggregationsChange,onEdit:this.handleAggregationEdit});case we.AGGREGATION_EDIT:return Wn&&h(Zu,{aggregation:Wn,columns:r.originalColumns,onChange:this.handleAggregationChange});case we.TABLE_EXPORTER:return h(wt,{model:r,name:l,isDownloading:tn,tableDownloadStatus:tt,tableDownloadProgress:pe,tableDownloadEstimatedTime:ze!=null?ze:void 0,onDownload:this.handleDownloadTable,onDownloadStart:this.handleDownloadTableStart,onCancel:this.handleCancelDownloadTable,selectedRanges:Bn},we.TABLE_EXPORTER);case we.SELECT_DISTINCT:return h(Ha,{model:r,selectDistinctColumns:be,onChange:this.handleSelectDistinctChanged});case we.ADVANCED_SETTINGS:return h(Sr,{items:d,onChange:u});default:throw Error(`Unexpected option type ${xe.type}`)}}),wo=this.getCachedHiddenColumns(ne.getHiddenColumns(ms));return T("div",{className:"iris-grid",role:"presentation",children:[T("div",{className:"iris-grid-column",children:[e!=null&&h("div",{className:"iris-grid-bar",children:e}),h(ot,{in:b,timeout:Rt.transitionSlowMs,classNames:"iris-grid-bar-horizontal",onEnter:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExit:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:"iris-grid-partition-selector-wrapper iris-grid-bar iris-grid-bar-primary",children:j&&ee&&h(Pa,{table:j,getFormattedString:(xe,mt,bn)=>r.displayString(xe,mt,bn),columnName:ee.name,partition:V,onChange:this.handlePartitionChange,onFetchAll:this.handlePartitionFetchAll,onAppend:this.handlePartitionAppend,onDone:this.handlePartitionDone})})}),h(ot,{in:Be,timeout:Rt.transitionSlowMs,classNames:"iris-grid-bar-horizontal",onEnter:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExit:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:"iris-grid-bar",children:h(xi,{value:ut,selectedColumns:Dt,invertSelection:Nt,onChange:this.handleCrossColumnSearch,columns:r.columns,ref:this.crossColumnRef})})}),T("div",{className:"grid-wrapper",ref:xe=>{this.gridWrapper=xe},children:[h(As,{ref:xe=>{this.grid=xe},isStickyBottom:!Ae(r)||!r.isEditable,isStuckToBottom:i,isStuckToRight:o,metricCalculator:g,model:r,keyHandlers:P,mouseHandlers:W,movedColumns:ce,movedRows:Te,onError:this.handleGridError,onViewChanged:this.handleViewChanged,onSelectionChanged:this.handleSelectionChanged,onMovedColumnsChanged:this.handleMovedColumnsChanged,renderer:this.renderer,stateOverride:Ps,theme:$n}),h(Sg,{isOpen:di,text:ui,onClose:this.handleOverflowClose}),go&&h(Oa,{model:r,modelColumns:r.columns,top:pi,bottom:gi,left:Hs,right:_s,filter:po,formatter:_e,sorts:Ze,reverseType:Le,movedColumns:ce,customColumns:Ut,hiddenColumns:wo,alwaysFetchColumns:this.getAlwaysFetchColumns(c,r.columns,ce,r.floatingLeftColumnCount,r.floatingRightColumnCount,(xr=(Fr=this.grid)==null?void 0:Fr.state.draggingColumn)==null?void 0:xr.range),formatColumns:this.getCachedPreviewFormatColumns(this.getCachedModelColumns(r,Ut),Ke,Mt,((Or=xt[xt.length-1])==null?void 0:Or.type)===we.CONDITIONAL_FORMATTING_EDIT&&Xe!=null?Xe:void 0),rollupConfig:this.getModelRollupConfig(r.originalColumns,Ft,ht),totalsConfig:this.getModelTotalsConfig(r.columns,Ft,ht),selectDistinctColumns:be,pendingRowCount:co,pendingDataMap:li,frozenColumns:ci}),!w&&h("div",{className:"grid-settings-button",children:h("button",{type:"button","data-testid":`btn-iris-grid-settings-button-${l}`,className:"btn btn-link btn-link-icon",onClick:this.handleMenu,children:h(K,{icon:bd,transform:"up-1"})})}),fi,Ci,wi,bi,Si,hi&&this.getOverflowButtonTooltip(hi)]}),h(Tg,{model:r,isShown:mi,gotoRow:ho,gotoRowError:mo,onSubmit:this.handleGotoRowSelectedRowNumberSubmit,onGotoRowNumberChanged:this.handleGotoRowSelectedRowNumberChanged,onClose:this.handleGotoRowClosed,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:()=>{this.handleAnimationStart(),this.focus()},onExited:this.handleAnimationEnd}),h(dm,{error:ao,isSaving:zn!=null,saveTooltip:`Commit (${this.commitAction.shortcut.getDisplayText()})`,discardTooltip:`Discard (${this.discardAction.shortcut.getDisplayText()})`,pendingDataErrors:uo,pendingDataMap:li,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd,onSave:this.handlePendingCommitClicked,onDiscard:this.handlePendingDiscardClicked}),h(Rm,{children:ai}),h(Ls,{model:r,copyOperation:I!=null?I:void 0,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd}),h(ks,{ref:xe=>{this.tableSaver=xe},getDownloadWorker:n,onDownloadCompleted:this.handleDownloadCompleted,onDownloadCanceled:this.handleDownloadCanceled,onDownloadProgressUpdate:this.handleDownloadProgressUpdate,isDownloading:tt===wt.DOWNLOAD_STATUS.DOWNLOADING,formatter:_e})]}),h(ot,{in:w,timeout:Rt.transitionMidMs,classNames:"slide-left",onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:"table-sidebar",children:T(bu,{children:[h(Zr,{title:"Table Options",onClose:this.handleMenuClose,children:h(ma,{onSelect:xe=>this.handleMenuSelect(vi[xe]),items:vi})}),bo.map((xe,mt)=>h(Zr,{title:xt[mt].title,onBack:this.handleMenuBack,onClose:this.handleMenuClose,children:xe},xt[mt].type))]})})}),h(se,{actions:this.contextActions})]})}};let ri=ss;ri.minDebounce=150;ri.maxDebounce=500;ri.loadingSpinnerDelay=800;ri.defaultProps={children:null,advancedFilters:new Map,advancedSettings:new Map,alwaysFetchColumns:[],conditionalFormats:[],customColumnFormatMap:new Map,isFilterBarShown:!1,applyInputFiltersOnInit:!1,movedColumns:[],movedRows:[],inputFilters:[],customFilters:[],onCreateChart:void 0,onColumnSelected:()=>{},onDataSelected:()=>{},onError:()=>{},onStateChange:()=>{},onPartitionAppend:()=>{},onAdvancedSettingsChange:()=>{},partition:null,partitionColumn:null,quickFilters:new Map,selectDistinctColumns:[],sorts:[],reverseType:x.REVERSE_TYPE.NONE,customColumns:[],aggregationSettings:ic,rollupConfig:void 0,userColumnWidths:new Map,userRowHeights:new Map,onSelectionChanged:()=>{},isSelectingColumn:!1,isSelectingPartition:!1,isStuckToBottom:!1,isStuckToRight:!1,columnSelectionValidator:null,columnAllowedCursor:null,columnNotAllowedCursor:null,name:"table",onlyFetchVisibleColumns:!0,showSearchBar:!1,searchValue:"",selectedSearchColumns:null,invertSearchColumns:!0,onContextMenu:()=>{},pendingDataMap:new Map,getDownloadWorker:void 0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:Hn.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,truncateNumbersWithPound:!1,formatter:[],decimalFormatOptions:D.exports.shape({defaultFormatString:D.exports.string}),integerFormatOptions:D.exports.shape({defaultFormatString:D.exports.string})},canCopy:!0,canDownloadCsv:!0,frozenColumns:null,theme:Aa,canToggleSearch:!0};class Ig extends Error{constructor(t,n){super(`${n} can't be empty (on pending row ${t+1})`),this.isMissingKey=!0,this.rowIndex=t,this.columnName=n}}const Mg=J.module("ColumnHeaderGroup");function xl(e){return e instanceof oc}class oc{constructor({name:t,children:n,color:s,depth:i,childIndexes:o}){this.getVisibleRange=Ie(r=>{const l=this.childIndexes.flat(),a=U.getVisibleIndexes(l,r),c=Math.min(...a),d=Math.max(...a);return d-c!==l.length-1&&Mg.warn(`Column header group ${this.name} is not contiguous`),[c,d]}),this.name=t,this.children=n,this.color=s,this.depth=i,this.childIndexes=o}}const Pe=J.module("IrisGridTableModel"),Dg=150,Ng=0;function ki(e){return e.table!==void 0}const Go=class extends ue{constructor(e,t=new jt,n=null){super(),this.pendingNewRowCount=0,this.columnHeaderGroupMap=new Map,this.columnHeaderParentMap=new Map,this._columnHeaderMaxDepth=null,this._columnHeaderGroups=[],this.getMemoizedColumnMap=Ie(s=>{const i=new Map;return s.forEach(o=>i.set(o.name,o)),i}),this.getColumnIndicesByNameMap=Ie(s=>{const i=new Map;return s.forEach(({name:o},r)=>i.set(o,r)),i}),this.setViewport=cs((s,i,o)=>{if(i<s){Pe.error("Invalid viewport",s,i);return}const{viewport:r}=this;if(r!=null&&r.top===s&&r.bottom===i&&r.columns===o){Pe.debug2("Ignoring duplicate viewport",r);return}this.viewport={top:s,bottom:i,columns:o},Pe.debug2("setViewport",this.viewport),this.applyViewport()},Dg),this.applyViewport=cs(()=>{if(!this.viewport)return;Pe.debug2("applyViewport",this.viewport);const{top:s,bottom:i,columns:o}=this.viewport,[r,l]=this.getCachedViewportRowRange(s,i);this.applyBufferedViewport(r,l,o)},Ng,{leading:!1}),this.getCachedFormattedString=St((s,i,o,r,l)=>s.getFormattedString(i,o,r,l),{max:1e4}),this.getCachedCustomColumnFormatFlag=St(ls.isCustomColumnFormatDefined,{max:1e4}),this.getCachedViewportRowRange=Ie((s,i)=>{const o=i-s,r=Math.max(0,s-o*Go.ROW_BUFFER_PAGES),l=i+o*Go.ROW_BUFFER_PAGES;return[r,l]}),this.getCachedPendingErrors=Ie((s,i,o)=>{const r=new Map;return s.forEach((l,a)=>{var d;const{data:c}=l;for(let u=0;u<o;u+=1)c.has(u)||(r.has(a)||r.set(a,[]),(d=r.get(a))==null||d.push(new Ig(a,i[u].name)))}),r}),this.handleTableDisconnect=this.handleTableDisconnect.bind(this),this.handleTableReconnect=this.handleTableReconnect.bind(this),this.handleTableUpdate=this.handleTableUpdate.bind(this),this.handleTotalsUpdate=this.handleTotalsUpdate.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.handleCustomColumnsChanged=this.handleCustomColumnsChanged.bind(this),this.irisFormatter=t,this.inputTable=n,this.subscription=null,this.table=e,this.viewport=null,this.viewportData=null,this.formattedStringData=[],this.pendingStringData=[],this.isSaveInProgress=!1,this.totalsTable=null,this.totalsTablePromise=null,this.totals=null,this.totalsDataMap=null,this.pendingNewDataMap=new Map,this.pendingNewDataErrors=null,this.pendingNewRowCount=0}export(){throw new Error("Method not implemented.")}columnStatistics(e){throw new Error("Method not implemented.")}get customColumns(){return[]}set customColumns(e){throw new Error("Method not implemented.")}get formatColumns(){return[]}set formatColumns(e){throw new Error("Method not implemented.")}updateFrozenColumns(e){throw new Error("Method not implemented.")}get rollupConfig(){throw new Error("Method not implemented.")}set rollupConfig(e){throw new Error("Method not implemented.")}get selectDistinctColumns(){throw new Error("Method not implemented.")}set selectDistinctColumns(e){throw new Error("Method not implemented.")}get columns(){return this.table.columns}close(){this.table.close(),this.totalsTable!==null&&this.totalsTable.close(),this.totalsTablePromise!==null&&this.totalsTablePromise.cancel()}startListening(){super.startListening(),this.table.addEventListener(E.Table.EVENT_DISCONNECT,this.handleTableDisconnect),this.table.addEventListener(E.Table.EVENT_RECONNECT,this.handleTableReconnect),this.table.addEventListener(E.Table.EVENT_UPDATED,this.handleTableUpdate),this.table.addEventListener(E.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed),this.table.addEventListener(E.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleCustomColumnsChanged),this.totalsTable!=null&&this.addTotalsListeners(this.totalsTable),this.applyViewport()}stopListening(){super.stopListening(),this.table.removeEventListener(E.Table.EVENT_DISCONNECT,this.handleTableDisconnect),this.table.removeEventListener(E.Table.EVENT_RECONNECT,this.handleTableReconnect),this.table.removeEventListener(E.Table.EVENT_UPDATED,this.handleTableUpdate),this.table.removeEventListener(E.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed),this.table.removeEventListener(E.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleCustomColumnsChanged),this.totalsTable!=null&&this.removeTotalsListeners(this.totalsTable),this.closeSubscription()}addTotalsListeners(e){e.addEventListener(E.Table.EVENT_UPDATED,this.handleTotalsUpdate),e.setViewport(0,0)}removeTotalsListeners(e){e.removeEventListener(E.Table.EVENT_UPDATED,this.handleTotalsUpdate)}handleTableDisconnect(){this.dispatchEvent(new Re(ue.EVENT.DISCONNECT))}handleTableReconnect(){this.dispatchEvent(new Re(ue.EVENT.RECONNECT))}handleTableUpdate(e){this.copyViewportData(e.detail),this.dispatchEvent(new Re(ue.EVENT.UPDATED))}handleTotalsUpdate(e){this.copyTotalsData(e.detail),this.dispatchEvent(new Re(ue.EVENT.UPDATED))}handleRequestFailed(e){this.dispatchEvent(new Re(ue.EVENT.REQUEST_FAILED,e))}handleCustomColumnsChanged(){this.dispatchEvent(new Re(ue.EVENT.COLUMNS_CHANGED,{detail:this.columns}))}get rowCount(){var e,t,n;return this.table.size+this.pendingNewRowCount+((n=(t=(e=this.totals)==null?void 0:e.operationOrder)==null?void 0:t.length)!=null?n:0)}get pendingDataErrors(){var e,t;return this.getCachedPendingErrors(this.pendingNewDataMap,this.columns,(t=(e=this.inputTable)==null?void 0:e.keyColumns.length)!=null?t:0)}get pendingDataMap(){return this.pendingNewDataMap}set pendingDataMap(e){e!==this.pendingNewDataMap&&(e.forEach((t,n)=>{if(!ne.isValidIndex(n))throw new Error(`Invalid rowIndex ${n}`);const{data:s}=t;s.forEach((i,o)=>{if(!ne.isValidIndex(o))throw new Error(`Invalid columnIndex ${o}`)})}),this.pendingNewDataMap=e,this.pendingNewRowCount=Math.max(this.pendingNewRowCount,this.maxPendingDataRow),this.formattedStringData=[],this.dispatchEvent(new Re(ue.EVENT.PENDING_DATA_UPDATED)))}get pendingRowCount(){return this.pendingNewRowCount}set pendingRowCount(e){e!==this.pendingNewRowCount&&(this.pendingNewRowCount=Math.max(0,e,this.maxPendingDataRow),this.dispatchEvent(new Re(ue.EVENT.UPDATED)))}get maxPendingDataRow(){return this.pendingNewDataMap.size>0?Math.max(...this.pendingNewDataMap.keys())+1:0}get columnCount(){return this.columns.length}get floatingBottomRowCount(){var e,t,n;return this.totals!=null&&this.totals.showOnTop?0:(n=(t=(e=this.totals)==null?void 0:e.operationOrder)==null?void 0:t.length)!=null?n:0}get floatingTopRowCount(){var e,t,n;return this.totals!=null&&this.totals.showOnTop&&(n=(t=(e=this.totals)==null?void 0:e.operationOrder)==null?void 0:t.length)!=null?n:0}get isChartBuilderAvailable(){return!0}get isTotalsAvailable(){return this.table.getTotalsTable!=null}get isEditable(){return!this.isSaveInProgress&&this.inputTable!=null}cacheFormattedValue(e,t,n){this.formattedStringData[e]==null&&(this.formattedStringData[e]=[]),this.formattedStringData[e][t]=n}cachePendingValue(e,t,n){this.pendingStringData[e]==null&&(this.pendingStringData[e]=[]),this.pendingStringData[e][t]=n}clearPendingValue(e,t){const n=this.pendingStringData[e];n!=null&&delete n[t]}textValueForCell(e,t){var n,s,i;if(((n=this.pendingStringData[e])==null?void 0:n[t])!==void 0)return this.pendingStringData[e][t];if(((s=this.formattedStringData[e])==null?void 0:s[t])===void 0){const o=this.valueForCell(e,t);if(o==null)return null;const r=(i=this.totalsColumn(e,t))!=null?i:this.columns[e],l=this.getCachedCustomColumnFormatFlag(this.formatter,r.name,r.type);let a;if(!l){const d=this.formatForCell(e,t);(d==null?void 0:d.formatString)!=null&&(a=d)}const c=this.displayString(o,r.type,r.name,a);this.cacheFormattedValue(e,t,c)}return this.formattedStringData[e][t]}textForCell(e,t){const n=this.textValueForCell(e,t);if(n==null&&this.isKeyColumn(e)){const s=this.pendingRow(t);if(s!=null&&this.pendingDataMap.has(s))return"*"}return n!=null?n:""}truncationCharForCell(e){const t=this.columns[e],{type:n}=t;if(x.isNumberType(n)&&this.formatter.truncateNumbersWithPound)return"#"}colorForCell(e,t,n){var i;const s=this.dataForCell(e,t);if(s){const{format:o,value:r}=s;if(r==null||r==="")return O(n.nullStringColor),n.nullStringColor;if(o&&o.color)return o.color;if(this.isPendingRow(t))return O(n.pendingTextColor),n.pendingTextColor;if(r!=null){const l=(i=this.totalsColumn(e,t))!=null?i:this.columns[e];if(x.isDateType(l.type)||l.name==="Date")return O(n.dateColor),n.dateColor;if(x.isNumberType(l.type))return r>0?(O(n.positiveNumberColor),n.positiveNumberColor):r<0?(O(n.negativeNumberColor),n.negativeNumberColor):(O(n.zeroNumberColor),n.zeroNumberColor)}}else if(this.isPendingRow(t)&&this.isKeyColumn(e))return O(n.errorTextColor),n.errorTextColor;return n.textColor}backgroundColorForCell(e,t){var n,s;return(s=(n=this.formatForCell(e,t))==null?void 0:n.backgroundColor)!=null?s:null}textAlignForCell(e){const t=this.columns[e],{type:n}=t;return x.isNumberType(n)?"right":x.isDateType(n)||t.name==="Date"?"center":"left"}textForColumnHeader(e,t=0){var n,s;return(s=(n=this.columnAtDepth(e,t))==null?void 0:n.name)!=null?s:void 0}colorForColumnHeader(e,t=0){var s;const n=this.columnAtDepth(e,t);return xl(n)&&(s=n.color)!=null?s:null}getColumnHeaderGroup(e,t){const n=this.columnAtDepth(e,t);if(xl(n))return n}getColumnHeaderParentGroup(e,t){var n,s;return this.columnHeaderParentMap.get((s=(n=this.columnAtDepth(e,t))==null?void 0:n.name)!=null?s:"")}columnAtDepth(e,t=0){var o;if(t===0)return this.columns[e];const n=(o=this.columns[e])==null?void 0:o.name;let s=this.columnHeaderParentMap.get(n);if(!s)return;let i=s.depth;for(;i<t;){if(s=this.columnHeaderParentMap.get(s.name),!s)return;i=s.depth}if(s.depth===t)return s}textForRowFooter(e){const t=this.totalsRow(e);return t!=null&&this.totals?this.totals.operationOrder[t]:""}get movedColumns(){var i;let e=[];const t=(o,r)=>{const l=this.getColumnIndexByName(o);if(l==null)throw new Error(`Unknown layout hint column: ${o}`);const a=U.getVisibleIndex(l,e);e=U.moveItem(a,r,e)},n=(o,r)=>{const l=this.columnHeaderGroupMap.get(o);if(!l)throw new Error(`Unknown layout hint group: ${o}`);const a=l.getVisibleRange(e);e=U.moveRange(a,r,e)};if(this.frontColumns.length||this.backColumns.length||this.frozenColumns.length){const o=new Set;let r=0;this.frozenColumns.forEach(a=>{if(o.has(a))throw new Error(`Column specified in multiple layout hints: ${a}`);t(a,r),r+=1}),this.frontColumns.forEach(a=>{if(o.has(a))throw new Error(`Column specified in multiple layout hints: ${a}`);t(a,r),r+=1});let l=this.columnMap.size-1;this.backColumns.forEach(a=>{if(o.has(a))throw new Error(`Column specified in multiple layout hints: ${a}`);t(a,l),l-=1})}const s=(i=this.layoutHints)==null?void 0:i.columnGroups;if(s){this.setColumnHeaderGroups(s);const o=[...this.columnHeaderGroupMap.values()];o.sort((r,l)=>r.depth-l.depth),o.forEach(r=>{const l=r.children[0],a=this.getColumnIndexByName(l);let c;if(a!=null)c=U.getVisibleIndex(a,e);else{const d=this.columnHeaderGroupMap.get(l);if(!d)throw new Error(`Unknown column ${l} in group ${r.name}`);[,c]=d.getVisibleRange(e)}for(let d=1;d<r.children.length;d+=1){const u=r.children[d],m=this.columnHeaderGroupMap.get(u),p=this.getColumnIndexByName(u);if(m){const f=m.getVisibleRange(e)[0]<c?c-m.childIndexes.length+1:c+1;n(u,f),c=f+m.childIndexes.length-1}else if(p!=null){const f=U.getVisibleIndex(p,e)<c?c:c+1;t(u,f),c=f}}})}return e}get columnMap(){return this.getMemoizedColumnMap(this.table.columns)}get columnHeaderMaxDepth(){var e,t;return this._columnHeaderMaxDepth==null&&this.setColumnHeaderGroups((e=this.layoutHints)==null?void 0:e.columnGroups),(t=this._columnHeaderMaxDepth)!=null?t:1}set columnHeaderMaxDepth(e){this._columnHeaderMaxDepth=e}setColumnHeaderGroups(e){if(e===this._columnHeaderGroups||(this._columnHeaderGroups=e!=null?e:[],this.columnHeaderMaxDepth=1,this.columnHeaderParentMap=new Map,this.columnHeaderGroupMap=new Map,!e||e.length===0))return;const t=new Map(e.map(o=>[o.name,o])),n=new Set,s=o=>{const{name:r}=o;if(this.getColumnIndexByName(r)!=null)throw new Error(`Column header group has same name as column: ${r}`);const l=this.columnHeaderGroupMap.get(r);if(l)return l;const a=[];let c=1;o.children.forEach(u=>{if(n.has(u))throw new Error(`Column group child ${u} specified in multiple groups`);n.add(u);const m=t.get(u),p=this.getColumnIndexByName(u);if(m){const g=s(m);a.push(g.childIndexes.flat()),c=Math.max(c,g.depth+1)}else if(p!=null)a.push(p),c=Math.max(c,1);else throw new Error(`Unknown child ${u} in group ${r}`)});const d=new oc({...o,depth:c,childIndexes:a});return this.columnHeaderGroupMap.set(r,d),o.children.forEach(u=>this.columnHeaderParentMap.set(u,d)),this.columnHeaderMaxDepth=Math.max(this.columnHeaderMaxDepth,d.depth+1),d},i=new Set;e.forEach(o=>{const{name:r}=o;if(i.has(r))throw new Error(`Duplicate column group name: ${r}`);i.add(r),s(o)})}get groupedColumns(){return[]}row(e){var l,a,c,d,u,m,p,g,f,C,b,w,S,I;const t=(c=(a=(l=this.totals)==null?void 0:l.operationOrder)==null?void 0:a.length)!=null?c:0,n=(u=(d=this.totals)==null?void 0:d.showOnTop)!=null?u:!1,s=this.totalsRow(e);if(s!=null){const v=(m=this.totals)==null?void 0:m.operationOrder[s];return O(v),(g=(p=this.totalsDataMap)==null?void 0:p.get(v))!=null?g:null}const i=this.pendingRow(e);if(i!=null)return(f=this.pendingNewDataMap.get(i))!=null?f:null;const o=(b=(C=this.viewportData)==null?void 0:C.offset)!=null?b:0,r=(n?e-t:e)-o;return(I=(S=(w=this.viewportData)==null?void 0:w.rows)==null?void 0:S[r])!=null?I:null}totalsColumn(e,t){var r,l,a,c;const n=this.totalsRow(t);if(n==null)return null;const s=(r=this.totals)==null?void 0:r.operationOrder[n],i=(a=(l=this.totals)==null?void 0:l.defaultOperation)!=null?a:Se.SUM,o=this.columns[e];return(c=this.totalsTable)==null?void 0:c.columns.find(d=>{var u;return d.name===`${o.name}__${s}`||(s===i||((u=this.totals)==null?void 0:u.operationOrder.length)===1)&&d.name===o.name})}totalsRow(e){var i,o,r,l,a;const t=(r=(o=(i=this.totals)==null?void 0:i.operationOrder)==null?void 0:o.length)!=null?r:0,s=((a=(l=this.totals)==null?void 0:l.showOnTop)!=null?a:!1)?e:e-this.table.size;return s>=0&&s<t?s:null}pendingRow(e){const t=e-this.floatingTopRowCount-this.table.size;return t>=0&&t<this.pendingNewRowCount?t:null}isTotalsRow(e){return this.totalsRow(e)!=null}isPendingRow(e){return this.pendingRow(e)!=null}dataForCell(e,t){var n;return(n=this.row(t))==null?void 0:n.data.get(e)}formatForCell(e,t){var n;return(n=this.dataForCell(e,t))==null?void 0:n.format}valueForCell(e,t){var s;const n=this.dataForCell(e,t);if(n)return(s=n.value)!=null?s:null}copyViewportData(e){if(e==null){Pe.warn("invalid data!");return}this.viewportData=this.extractViewportData(e),this.formattedStringData=[]}copyTotalsData(e){var l,a,c,d,u;if(e==null){Pe.warn("invalid data!");return}const{columns:t,rows:n}=e;if(n.length!==1){Pe.error("Unexpected number of rows received for totals table, ignoring update");return}const s=new Map,i=n[0],o=(a=(l=this.totals)==null?void 0:l.defaultOperation)!=null?a:Se.SUM,r=(c=this.totals)==null?void 0:c.operationMap;for(let m=0;m<t.length;m+=1){const p=t[m],[g,f=(u=(d=r==null?void 0:r[g])==null?void 0:d[0])!=null?u:o]=p.name.split("__");s.has(f)||s.set(f,{data:new Map});const{data:C}=s.get(f),b=this.columns.findIndex(w=>w.name===g);C.set(b,{value:i.get(p),format:i.getFormat(p)})}Pe.debug2("copyTotalsData",s),this.totalsDataMap=s,this.formattedStringData=[]}getColumnIndexByName(e){return this.getColumnIndicesByNameMap(this.columns).get(e)}extractViewportData(e){const t={offset:e.offset,rows:[]},{columns:n}=e;for(let s=0;s<e.rows.length;s+=1){const i=e.rows[s],o=this.extractViewportRow(i,n);t.rows.push(o)}return t}extractViewportRow(e,t){const n=new Map;for(let s=0;s<t.length;s+=1){const i=t[s],o=this.getColumnIndexByName(i.name);O(o),n.set(o,{value:e.get(i),format:e.getFormat(i)})}return{data:n}}closeSubscription(){Pe.debug2("closeSubscription",this.subscription),this.subscription&&(this.subscription.close(),this.subscription=null),this.setViewport.cancel(),this.applyViewport.cancel()}get filter(){return this.table.filter}set filter(e){this.closeSubscription(),this.table.applyFilter(e),this.applyViewport()}get formatter(){return this.irisFormatter}set formatter(e){this.irisFormatter=e,this.formattedStringData=[],this.dispatchEvent(new Re(ue.EVENT.FORMATTER_UPDATED))}displayString(e,t,n="",s){return this.getCachedFormattedString(this.formatter,e,t,n,s)}get sort(){return this.table.sort}set sort(e){this.closeSubscription(),this.table.applySort(e),this.applyViewport()}set totalsConfig(e){if(Pe.debug("set totalsConfig",e),e!==this.totals){if(this.totals=e,this.formattedStringData=[],this.totalsTablePromise!=null&&this.totalsTablePromise.cancel(),this.setTotalsTable(null),e==null){this.dispatchEvent(new Re(ue.EVENT.UPDATED));return}this.totalsTablePromise=He.makeCancelable(this.table.getTotalsTable(e),t=>t.close()),this.totalsTablePromise.then(t=>{this.totalsTablePromise=null,this.setTotalsTable(t)}).catch(t=>{He.isCanceled(t)||(Pe.error("Unable to set next totalsTable",t),this.totalsTablePromise=null,this.dispatchEvent(new Re(ue.EVENT.REQUEST_FAILED,{detail:t})))})}}setTotalsTable(e){Pe.debug("setTotalsTable",e),this.totalsTable!==null&&(this.listenerCount>0&&this.removeTotalsListeners(this.totalsTable),this.totalsTable.close()),this.totalsTable=e,this.totalsDataMap=null,this.listenerCount>0&&this.totalsTable!=null&&this.addTotalsListeners(this.totalsTable)}applyBufferedViewport(e,t,n){Pe.debug2("applyBufferedViewport",e,t,n),this.subscription==null?(Pe.debug2("applyBufferedViewport creating new subscription"),this.subscription=this.table.setViewport(e,t,n)):(Pe.debug2("applyBufferedViewport using existing subscription"),this.subscription.setViewport(e,t,n))}async snapshot(e,t=!1,n=s=>s){if(this.subscription==null)throw new Error("No subscription available");const s=Z.consolidate(e);if(!ne.isValidSnapshotRanges(s))throw new Error(`Invalid snapshot ranges ${e}`);const i=new Set,o=[],r=new Set;for(let u=0;u<s.length;u+=1){const m=s[u];O(m.endRow),O(m.startRow);for(let p=m.startRow;p<=m.endRow&&p<this.floatingTopRowCount;p+=1)i.add(p);m.endRow>=this.floatingTopRowCount&&m.startRow<=this.floatingTopRowCount+this.table.size&&o.push(new Z(m.startColumn,Math.min(Math.max(0,m.startRow-this.floatingTopRowCount)),m.endColumn,Math.min(Math.max(0,m.endRow-this.floatingTopRowCount),this.table.size-this.floatingTopRowCount)));for(let p=Math.max(m.startRow,this.floatingTopRowCount+this.table.size);p<=m.endRow&&p<this.floatingTopRowCount+this.table.size+this.floatingBottomRowCount;p+=1)r.add(p)}const l=ne.columnsFromRanges(s,this.columns),a=[];t&&a.push(l.map(u=>u.name));const c=[...i].sort();for(let u=0;u<c.length;u+=1){const m=c[u],p=l.map(g=>{const f=this.getColumnIndexByName(g.name);return O(f),n(this.valueForCell(f,m),g)});t&&p.push(this.textForRowFooter(m)),a.push(p)}if(o.length>0){const u=ne.rangeSetFromRanges(o),m=await this.subscription.snapshot(u,l);a.push(...m.rows.map(p=>l.map(g=>n(p.get(g),g))))}const d=[...r].sort();for(let u=0;u<d.length;u+=1){const m=d[u],p=l.map(g=>{const f=this.getColumnIndexByName(g.name);return O(f),n(this.valueForCell(f,m),g)});t&&p.push(this.textForRowFooter(m)),a.push(p)}return a}async textSnapshot(e,t=!1,n=s=>`${s}`){return Pe.debug2("textSnapshot",e,t),(await this.snapshot(e,t,n)).map(i=>i.join(" ")).join(`
31
31
  `)}async valuesTable(e){let t=null;try{return t=await this.table.copy(),t.applyFilter([]),t.applySort([]),t.selectDistinct([e])}finally{t!=null&&t.close()}}isColumnMovable(e,t){if(e<0||e>=this.columnCount)return!1;if(t>0)return!0;const n=this.columns[e].name;return this.frontColumns.includes(n)||this.backColumns.includes(n)||this.frozenColumns.includes(n)||!n?!1:!this.isKeyColumn(e)}isKeyColumn(e){var t,n;return e<((n=(t=this.inputTable)==null?void 0:t.keyColumns.length)!=null?n:0)}isRowMovable(){return!1}isEditableRange(e){return this.inputTable!=null&&Z.isBounded(e)&&(this.isPendingRow(e.startRow)&&this.isPendingRow(e.endRow)||e.startColumn>=this.inputTable.keyColumns.length&&e.endColumn>=this.inputTable.keyColumns.length)&&e.startRow>=this.floatingTopRowCount&&e.startRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount&&e.endRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount}isDeletableRange(e){return this.inputTable!=null&&e.startRow!=null&&e.endRow!=null&&e.startRow>=this.floatingTopRowCount&&e.startRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount&&e.endRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount}isEditableRanges(e){return e.every(t=>this.isEditableRange(t))}isDeletableRanges(e){return e.every(t=>this.isDeletableRange(t))}getTableAreaRange(){return new Z(null,this.floatingTopRowCount,null,this.floatingTopRowCount+this.table.size-1)}getPendingAreaRange(){return new Z(null,this.floatingTopRowCount+this.table.size,null,this.floatingTopRowCount+this.table.size+this.pendingNewRowCount-1)}async setValueForCell(e,t,n){return this.setValueForRanges([new Z(e,t,e,t)],n)}async setValueForRanges(e,t){var n;if(!this.isEditableRanges(e))throw new Error(`Uneditable ranges ${e}`);try{const s=new Set,i=[];Z.forEachCell(e,(c,d)=>{const u=this.columns[c];if(s.add(u),i[c]===void 0){const m=x.makeValue(u.type,t,this.formatter.timeZone);i[c]=m!=null?this.displayString(m,u.type,u.name):null}this.cachePendingValue(c,d,i[c])});const o=this.getPendingAreaRange(),r=e.map(c=>Z.intersection(o,c)).filter(c=>c!=null).map(c=>(O(c),Z.offset(c,0,-(this.floatingTopRowCount+this.table.size))));if(r.length>0){const c=new Map(this.pendingNewDataMap);Z.forEachCell(r,(d,u)=>{c.has(u)||c.set(u,{data:new Map});const m=this.columns[d],p=c.get(u);O(p);const{data:g}=p,f=new Map(g),C=x.makeValue(m.type,t,this.formatter.timeZone);C!=null?f.set(d,{value:C}):f.delete(d),f.size>0?c.set(u,{...p,data:f}):c.delete(u)}),this.pendingDataMap=c}this.dispatchEvent(new Re(ue.EVENT.UPDATED));const l=this.getTableAreaRange(),a=e.map(c=>Z.intersection(l,c)).filter(c=>c!=null);if(a.length>0){const d=(await this.snapshot(a.map(m=>{var p,g;return new Z(null,(p=m==null?void 0:m.startRow)!=null?p:null,null,(g=m==null?void 0:m.endRow)!=null?g:null)}))).map(m=>{const p={};for(let g=0;g<this.columns.length;g+=1)p[this.columns[g].name]=m[g];return s.forEach(g=>{p[g.name]=x.makeValue(g.type,t,this.formatter.timeZone)}),p}),u=await((n=this.inputTable)==null?void 0:n.addRows(d));Pe.debug("setValueForRanges(",e,",",t,") set tableRanges",a,"result",u)}Z.forEachCell(e,(c,d)=>{const u=i[c];O(u),this.cacheFormattedValue(c,d,u)})}catch(s){Pe.error("Unable to set ranges",e,t,s)}finally{Z.forEachCell(e,(s,i)=>{this.clearPendingValue(s,i)})}}async setValues(e=[]){var t;if(Pe.debug("setValues(",e,")"),!e.every(n=>{var s,i;return this.isEditableRange(Z.makeCell((s=n.column)!=null?s:n.x,(i=n.row)!=null?i:n.y))}))throw new Error(`Uneditable ranges ${e}`);try{const n=new Map(this.pendingNewDataMap);e.forEach(l=>{var f,C;const{text:a}=l,c=(f=l.column)!=null?f:l.x,d=(C=l.row)!=null?C:l.y,u=this.columns[c],m=x.makeValue(u.type,a,this.formatter.timeZone),p=m!=null?this.displayString(m,u.type,u.name):null;this.cachePendingValue(c,d,p);const g=this.pendingRow(d);if(g!=null){n.has(g)||n.set(g,{data:new Map});const b=n.get(g);O(b);const{data:w}=b,S=new Map(w);m!=null?S.set(c,{value:m}):S.delete(c),S.size>0?n.set(g,{...b,data:S}):n.delete(g)}}),this.pendingDataMap=n,this.dispatchEvent(new Re(ue.EVENT.UPDATED));const s=e.reduce((l,a)=>{var d,u;const c=(d=a.row)!=null?d:a.y;return l.has(c)||l.set(c,[]),(u=l.get(c))==null||u.push(a),l},new Map),i=Z.consolidate(e.map(l=>{var a,c;return Z.makeCell((a=l.column)!=null?a:l.x,(c=l.row)!=null?c:l.y)})),o=this.getTableAreaRange(),r=i.map(l=>Z.intersection(o,l)).filter(l=>l!=null);if(r.length>0){const a=(await this.snapshot(r.map(d=>(O(d),new Z(null,d.startRow,null,d.endRow))))).map((d,u)=>{let m=null,p=u;for(let C=0;C<r.length;C+=1){const b=r[C];O(b);const w=Z.rowCount([b]);if(p<w){O(b.startRow),m=b.startRow+p;break}p-=w}const g={};for(let C=0;C<this.columns.length;C+=1)g[this.columns[C].name]=d[C];O(m);const f=s.get(m);return f!=null&&f.forEach(C=>{var w;const b=this.columns[(w=C.column)!=null?w:C.x];g[b.name]=x.makeValue(b.type,C.text,this.formatter.timeZone)}),g});Pe.info("setValues setting tableRanges",r);const c=await((t=this.inputTable)==null?void 0:t.addRows(a));Pe.info("setValues set tableRanges",r,"SUCCESS",c)}e.forEach(l=>{var g,f;const{text:a}=l,c=(g=l.column)!=null?g:l.x,d=(f=l.row)!=null?f:l.y,u=this.columns[c],m=x.makeValue(u.type,a,this.formatter.timeZone),p=m!=null?this.displayString(m,u.type,u.name):null;this.cacheFormattedValue(c,d,p)})}finally{e.forEach(n=>{this.clearPendingValue(n.column,n.row)})}}async commitPending(){var e,t,n;if(this.pendingNewDataMap.size<=0)throw new Error("No pending changes to commit");try{this.isSaveInProgress=!0;const s=[];this.pendingNewDataMap.forEach(o=>{const r={};o.data.forEach(({value:l},a)=>{const c=this.columns[a];r[c.name]=l}),s.push(r)});const i=await((e=this.inputTable)==null?void 0:e.addRows(s));Pe.debug("commitPending()",this.pendingNewDataMap,"result",i),this.pendingNewDataMap=new Map,this.pendingNewDataErrors=new Map,this.pendingNewRowCount=Math.max(0,((n=(t=this.viewport)==null?void 0:t.bottom)!=null?n:0)-this.table.size),this.formattedStringData=[],this.dispatchEvent(new Re(ue.EVENT.PENDING_DATA_UPDATED))}finally{this.isSaveInProgress=!1}}editValueForCell(e,t){return this.textValueForCell(e,t)}async delete(e){if(!this.isDeletableRanges(e))throw new Error(`Undeletable ranges ${e}`);O(this.inputTable);const{keyColumns:t}=this.inputTable;if(t.length===0)throw new Error("No key columns to allow deletion");const n=this.getPendingAreaRange(),s=e.map(d=>Z.intersection(n,d)).filter(d=>d!=null).map(d=>(O(d),Z.offset(d,0,-(this.floatingTopRowCount+this.table.size))));if(s.length>0){const d=new Map(this.pendingNewDataMap);for(let u=0;u<s.length;u+=1){const m=s[u];O(m.startRow),O(m.endRow);for(let p=m.startRow;p<=m.endRow;p+=1)d.delete(p)}this.pendingNewDataMap=d,this.formattedStringData=[],this.dispatchEvent(new Re(ue.EVENT.PENDING_DATA_UPDATED)),this.dispatchEvent(new Re(ue.EVENT.UPDATED))}const i=this.getTableAreaRange(),o=e.map(d=>Z.intersection(i,d)).filter(d=>d!=null);if(o.length<=0)return;const[r,l]=await Promise.all([this.snapshot(o.map(d=>(O(d),new Z(0,d.startRow,t.length-1,d.endRow)))),this.table.copy()]),c=r.map(d=>{const u=[];for(let m=0;m<t.length;m+=1){const p=t[m],g=d[m],f=x.makeFilterRawValue(p.type,g),C=p.filter().eq(f);u.push(C)}return u.reduce((m,p)=>{var g;return(g=m==null?void 0:m.and(p))!=null?g:p})}).reduce((d,u)=>{var m;return(m=d==null?void 0:d.or(u))!=null?m:u});l.applyFilter([c]),l.close()}isValidForCell(e,t,n){try{const s=this.columns[e];return x.makeValue(s.type,n,this.formatter.timeZone),!0}catch{return!1}}};let yr=Go;yr.ROW_BUFFER_PAGES=1;const In=J.module("IrisGridTableModel"),ko=Object.freeze([]);class Fg extends yr{constructor(t,n=new jt,s=null){super(t,n,s),this.getMemoizedFrontColumns=Ie(i=>i!=null?i:ko),this.getMemoizedBackColumns=Ie(i=>i!=null?i:ko),this.getMemoizedFrozenColumns=Ie((i,o)=>{var r;return(r=o!=null?o:i)!=null?r:ko}),this.getCachedFilterableColumnSet=Ie(i=>new Set(i.map((o,r)=>r))),this.customColumnList=[],this.formatColumnList=[]}get isExportAvailable(){return this.table.freeze!=null}get isColumnStatisticsAvailable(){return this.table.getColumnStatistics!=null}get isValuesTableAvailable(){return this.table.selectDistinct!=null&&this.table.copy!=null}get isRollupAvailable(){return this.table.rollup!=null}get isSelectDistinctAvailable(){return this.table.selectDistinct!=null}get isCustomColumnsAvailable(){return this.table.applyCustomColumns!=null}get isFormatColumnsAvailable(){return this.table.applyCustomColumns!=null}get frontColumns(){var t;return this.getMemoizedFrontColumns((t=this.layoutHints)==null?void 0:t.frontColumns)}get backColumns(){var t;return this.getMemoizedBackColumns((t=this.layoutHints)==null?void 0:t.backColumns)}get frozenColumns(){var t;return this.getMemoizedFrozenColumns((t=this.layoutHints)==null?void 0:t.frozenColumns,this.userFrozenColumns)}get layoutHints(){return this.table.layoutHints}get floatingLeftColumnCount(){return this.frozenColumns.length}get description(){return this.table.description}get customColumns(){return this.customColumnList}set customColumns(t){if(In.debug2("set customColumns",t,this.customColumnList,t===this.customColumnList),this.customColumnList.length===0&&t.length===0){In.debug("Ignore empty initial customColumns"),this.customColumnList=t;return}if(this.customColumnList===t){In.debug("Ignore same customColumns");return}this.closeSubscription(),this.customColumnList=t,this.table.applyCustomColumns([...t,...this.formatColumns]),this.applyViewport()}get formatColumns(){return this.formatColumnList}set formatColumns(t){if(In.debug2("set formatColumns",t,this.formatColumnList,t===this.formatColumnList),this.formatColumnList.length===0&&t.length===0){In.debug("Ignore empty initial formatColumns"),this.formatColumnList=t;return}if(this.formatColumnList===t){In.debug("Ignore same formatColumns");return}this.closeSubscription(),this.formatColumnList=t,this.table.applyCustomColumns([...this.customColumns,...t]),this.applyViewport()}updateFrozenColumns(t){this.userFrozenColumns=t,this.dispatchEvent(new Re(ue.EVENT.TABLE_CHANGED,{detail:this.table}))}set totalsConfig(t){if(In.debug("set totalsConfig",t),t!==this.totals){if(this.totals=t,this.formattedStringData=[],this.totalsTablePromise!=null&&this.totalsTablePromise.cancel(),this.setTotalsTable(null),t==null){this.dispatchEvent(new Re(ue.EVENT.UPDATED));return}this.totalsTablePromise=He.makeCancelable(this.table.getTotalsTable(t),n=>n.close()),this.totalsTablePromise.then(n=>{this.totalsTablePromise=null,this.setTotalsTable(n)}).catch(n=>{He.isCanceled(n)||(In.error("Unable to set next totalsTable",n),this.totalsTablePromise=null,this.dispatchEvent(new Re(ue.EVENT.REQUEST_FAILED,{detail:n})))})}}get isFilterRequired(){return this.table.isUncoalesced}isFilterable(t){return this.getCachedFilterableColumnSet(this.columns).has(t)}async export(){return this.table.freeze()}columnStatistics(t){return this.table.getColumnStatistics(t)}isColumnMovable(t){const n=this.columns[t].name;return this.frontColumns.includes(n)||this.backColumns.includes(n)||this.frozenColumns.includes(n)?!1:!this.isKeyColumn(t)}isColumnFrozen(t){return this.frozenColumns.includes(this.columns[t].name)}async delete(t){var u;if(!this.isDeletableRanges(t))throw new Error(`Undeletable ranges ${t}`);O(this.inputTable);const{keyColumns:n}=this.inputTable;if(n.length===0)throw new Error("No key columns to allow deletion");const s=this.getPendingAreaRange(),i=t.map(m=>Z.intersection(s,m)).filter(m=>m!=null).map(m=>(O(m),Z.offset(m,0,-(this.floatingTopRowCount+this.table.size))));if(i.length>0){const m=new Map(super.pendingDataMap);for(let p=0;p<i.length;p+=1){const g=i[p];O(g.startRow),O(g.endRow);for(let f=g.startRow;f<=g.endRow;f+=1)m.delete(f)}super.pendingDataMap=m,this.formattedStringData=[],this.dispatchEvent(new Re(ue.EVENT.PENDING_DATA_UPDATED)),this.dispatchEvent(new Re(ue.EVENT.UPDATED))}const o=this.getTableAreaRange(),r=t.map(m=>Z.intersection(o,m)).filter(m=>m!=null);if(r.length<=0)return;const[l,a]=await Promise.all([this.snapshot(r.map(m=>(O(m),new Z(0,m.startRow,n.length-1,m.endRow)))),this.table.copy()]),d=l.map(m=>{const p=[];for(let g=0;g<n.length;g+=1){const f=n[g],C=m[g],b=x.makeFilterRawValue(f.type,C),w=f.filter().eq(b);p.push(w)}return p.reduce((g,f)=>{var C;return(C=g==null?void 0:g.and(f))!=null?C:f})}).reduce((m,p)=>{var g;return(g=m==null?void 0:m.or(p))!=null?g:p});a.applyFilter([d]),await((u=this.inputTable)==null?void 0:u.deleteTable(a)),a.close()}}class xg extends yr{constructor(){super(...arguments),this.getCachedFilterableColumnSet=Ie((t,n)=>new Set(((n==null?void 0:n.length)>0?n:t).map(s=>t.findIndex(i=>s.name===i.name))))}applyBufferedViewport(t,n,s){this.table.setViewport(t,n,s)}textForCell(t,n){const s=this.columns[t],i=this.row(n);if(i!=null&&s!=null&&!i.hasChildren&&s.constituentType!=null){const o=this.valueForCell(t,n);return this.displayString(o,s.constituentType,s.name)}return super.textForCell(t,n)}extractViewportRow(t,n){const{isExpanded:s,hasChildren:i,depth:o}=t;return{...super.extractViewportRow(t,n),isExpanded:s,hasChildren:i,depth:o}}async snapshot(t,n,s){var l,a,c,d;O(this.viewport),O(this.viewportData);const{columns:i}=this.viewport,o=[];n!=null&&n&&o.push(i.map(u=>u.name));const r=new Z(0,(l=this.viewportData)==null?void 0:l.offset,i.length,((a=this.viewportData)==null?void 0:a.offset)+((c=this.viewportData)==null?void 0:c.rows.length));for(let u=0;u<t.length;u+=1){const m=Z.intersection(r,t[u]);O(m),O(m.startRow),O(m.endRow);for(let p=m.startRow;p<=m.endRow;p+=1){const g=[],f=this.viewportData.rows[p-this.viewportData.offset];O(m.startColumn),O(m.endColumn);for(let C=m.startColumn;C<=m.endColumn;C+=1)O(s),g.push(s((d=f.data.get(C))==null?void 0:d.value,this.columns[C]));o.push(g)}}return o}get groupedColumns(){return[]}get hasExpandableRows(){return!0}get isChartBuilderAvailable(){return!1}get isSelectDistinctAvailable(){return!1}get isReversible(){return!1}isFilterable(t){return this.getCachedFilterableColumnSet(this.columns,this.groupedColumns).has(t)}isColumnMovable(t){return t>=this.groupedColumns.length}isRowExpandable(t){var s;const n=this.row(t);return(s=n==null?void 0:n.hasChildren)!=null?s:!1}isRowExpanded(t){var s;const n=this.row(t);return(s=n==null?void 0:n.isExpanded)!=null?s:!1}setRowExpanded(t,n){this.table.setExpanded(t,n)}depthForRow(t){var s;const n=this.row(t);return((s=n==null?void 0:n.depth)!=null?s:1)-1}}const Mn=J.module("IrisGridProxyModel");function Lo(e,t,n){return x.isTreeTable(e)?new xg(e,t):new Fg(e,t,n)}class Og extends ue{constructor(t,n=new jt,s=null){super(),this.textForCell=(...o)=>this.model.textForCell(...o),this.truncationCharForCell=(...o)=>this.model.truncationCharForCell(...o),this.textAlignForCell=(...o)=>this.model.textAlignForCell(...o),this.colorForCell=(...o)=>this.model.colorForCell(...o),this.backgroundColorForCell=(...o)=>this.model.backgroundColorForCell(...o),this.textForColumnHeader=(...o)=>this.model.textForColumnHeader(...o),this.colorForColumnHeader=(...o)=>this.model.colorForColumnHeader(...o),this.textForRowHeader=(...o)=>this.model.textForRowHeader(...o),this.textForRowFooter=(...o)=>this.model.textForRowFooter(...o),this.isRowMovable=(...o)=>this.model.isRowMovable(...o),this.isColumnMovable=(...o)=>this.model.isColumnMovable(...o),this.isRowExpandable=(...o)=>qe(this.model)?this.model.isRowExpandable(...o):!1,this.isRowExpanded=(...o)=>qe(this.model)?this.model.isRowExpanded(...o):!1,this.setRowExpanded=(...o)=>{if(qe(this.model))return this.model.setRowExpanded(...o);throw Error("Function setRowExpanded does not exist on IrisGridTableModel")},this.depthForRow=(...o)=>qe(this.model)?this.model.depthForRow(...o):0,this.getColumnHeaderGroup=(...o)=>this.model.getColumnHeaderGroup(...o),this.getColumnHeaderParentGroup=(...o)=>this.model.getColumnHeaderParentGroup(...o),this.formatForCell=(...o)=>this.model.formatForCell(...o),this.valueForCell=(...o)=>this.model.valueForCell(...o),this.displayString=(...o)=>this.model.displayString(...o),this.isEditableRange=(...o)=>Ae(this.model)?this.model.isEditableRange(...o):!1,this.isFilterable=(...o)=>this.model.isFilterable(...o),this.setViewport=(o,r,l)=>this.model.setViewport(o,r,l),this.snapshot=(...o)=>this.model.snapshot(...o),this.textSnapshot=(...o)=>this.model.textSnapshot(...o),this.valuesTable=(...o)=>this.model.valuesTable(...o),this.editValueForCell=(...o)=>(Ae(this.model)&&this.model.editValueForCell(...o),""),this.setValueForCell=(...o)=>Ae(this.model)?this.model.setValueForCell(...o):Promise.reject(new Error("Model is not editable")),this.setValueForRanges=(...o)=>Ae(this.model)?this.model.setValueForRanges(...o):Promise.reject(new Error("Model is not editable")),this.setValues=(...o)=>Ae(this.model)?this.model.setValues(...o):Promise.resolve(),this.isValidForCell=(...o)=>Ae(this.model)?this.model.isValidForCell(...o):!1,this.delete=(...o)=>this.model.delete(...o),this.commitPending=(...o)=>this.model.commitPending(...o),this.handleModelEvent=this.handleModelEvent.bind(this);const i=Lo(t,n,s);this.originalModel=i,this.model=i,this.modelPromise=null,this.rollup=null,this.selectDistinct=[]}close(){this.originalModel.close(),this.model!==this.originalModel&&this.model.close(),this.modelPromise!=null&&this.modelPromise.cancel()}handleModelEvent(t){Mn.debug2("handleModelEvent",t);const{detail:n,type:s}=t;this.dispatchEvent(new Re(s,{detail:n}))}setModel(t){Mn.debug("setModel",t);const n=this.model;n!==this.originalModel&&n.close(),this.model=t,this.listenerCount>0&&this.addListeners(t),this.dispatchEvent(new Re(ue.EVENT.COLUMNS_CHANGED,{detail:t.columns})),ki(t)&&this.dispatchEvent(new Re(ue.EVENT.TABLE_CHANGED,{detail:t.table}))}setNextModel(t){Mn.debug2("setNextModel"),this.modelPromise&&this.modelPromise.cancel(),this.listenerCount>0&&this.removeListeners(this.model),this.modelPromise=He.makeCancelable(t,n=>n.close()),this.modelPromise.then(n=>{this.modelPromise=null,this.setModel(n)}).catch(n=>{if(He.isCanceled(n)){Mn.debug2("setNextModel cancelled");return}Mn.error("Unable to set next model",n),this.modelPromise=null,this.dispatchEvent(new Re(ue.EVENT.REQUEST_FAILED,{detail:n}))})}startListening(){super.startListening(),this.addListeners(this.model)}stopListening(){super.stopListening(),this.removeListeners(this.model)}addListeners(t){const n=Object.keys(ue.EVENT);for(let s=0;s<n.length;s+=1)t.addEventListener(n[s],this.handleModelEvent)}removeListeners(t){const n=Object.keys(ue.EVENT);for(let s=0;s<n.length;s+=1)t.removeEventListener(n[s],this.handleModelEvent)}get rowCount(){return this.model.rowCount}get columnCount(){return this.model.columnCount}get floatingTopRowCount(){return this.model.floatingTopRowCount}get floatingBottomRowCount(){return this.model.floatingBottomRowCount}get floatingLeftColumnCount(){return this.model.floatingLeftColumnCount}get floatingRightColumnCount(){return this.model.floatingRightColumnCount}isColumnFrozen(t){return this.model.isColumnFrozen(t)}get hasExpandableRows(){return qe(this.model)?this.model.hasExpandableRows:!1}get isExportAvailable(){return this.model.isExportAvailable}get isColumnStatisticsAvailable(){return this.model.isColumnStatisticsAvailable}get isValuesTableAvailable(){return this.model.isValuesTableAvailable}get isCustomColumnsAvailable(){return this.model.isCustomColumnsAvailable&&!(this.isSelectDistinctAvailable&&this.selectDistinctColumns.length>0)}get isFormatColumnsAvailable(){return this.model.isFormatColumnsAvailable}get isChartBuilderAvailable(){return this.model.isChartBuilderAvailable}get isRollupAvailable(){return(this.originalModel.isRollupAvailable||this.rollup!=null)&&this.selectDistinct.length===0}get isSelectDistinctAvailable(){return(this.originalModel.isSelectDistinctAvailable||this.selectDistinct.length>0)&&this.rollup==null}get isTotalsAvailable(){return this.model.isTotalsAvailable}get isReversible(){return this.model.isReversible}get columns(){return this.model.columns}get movedColumns(){return this.model.movedColumns}get movedRows(){return this.model.movedRows}get layoutHints(){return this.model.layoutHints}get frontColumns(){return this.model.frontColumns}get backColumns(){return this.model.backColumns}get frozenColumns(){return this.model.frozenColumns}get columnHeaderMaxDepth(){return this.model.columnHeaderMaxDepth}updateFrozenColumns(t){return this.model.updateFrozenColumns(t)}get originalColumns(){return this.originalModel.columns}get groupedColumns(){return this.model.groupedColumns}get description(){return this.model.description}get filter(){return this.model.filter}set filter(t){this.model.filter=t}get formatter(){return this.model.formatter}set formatter(t){this.model.formatter=t}get sort(){return this.model.sort}set sort(t){this.model.sort=t}get customColumns(){return this.model.customColumns}set customColumns(t){this.model.customColumns=t}get formatColumns(){return this.model.formatColumns}set formatColumns(t){this.model.formatColumns=t}get rollupConfig(){return this.rollup}set rollupConfig(t){if(Mn.debug("set rollupConfig",t),!this.isRollupAvailable)throw new Error("Rollup Rows are not available");if(ct(t,this.rollup))return;this.rollup=t;let n=Promise.resolve(this.originalModel);ki(this.originalModel)&&t!=null&&(n=this.originalModel.table.rollup(t).then(s=>Lo(s,this.formatter))),this.setNextModel(n)}get selectDistinctColumns(){return this.selectDistinct}set selectDistinctColumns(t){if(Mn.debug("set selectDistinctColumns",t),!this.isSelectDistinctAvailable)throw new Error("Select distinct is not available");if(t===this.selectDistinctColumns||t.length===0&&this.selectDistinctColumns.length===0){Mn.debug("Ignore same selectDistinctColumns",t);return}this.selectDistinct=t;const n=t.map(i=>this.originalColumns.find(o=>o.name===i)).filter(i=>i!=null);let s=Promise.resolve(this.originalModel);ki(this.originalModel)&&n.length>0&&(s=this.originalModel.table.selectDistinct(n).then(i=>Lo(i,this.formatter))),this.setNextModel(s)}get table(){if(ki(this.model))return this.model.table}get totalsConfig(){return this.model.totalsConfig}set totalsConfig(t){this.model.totalsConfig=t}get isFilterRequired(){return this.model.isFilterRequired}get isEditable(){return Ae(this.model)&&this.model.isEditable}export(){if(x.isTreeTable(this.model))throw new Error("TreeTable has no 'export' property");return this.model.export()}columnStatistics(t){if(x.isTreeTable(this.model))throw new Error("TreeTable has no 'columnStatistics' function");return this.model.columnStatistics(t)}get pendingDataMap(){return this.model.pendingDataMap}set pendingDataMap(t){this.model.pendingDataMap=t}get pendingRowCount(){return this.model.pendingRowCount}set pendingRowCount(t){this.model.pendingRowCount=t}get pendingDataErrors(){return this.model.pendingDataErrors}getColumnIndexByName(t){return this.model.getColumnIndexByName(t)}}class Ag{static async makeModel(t,n=new jt){let s=null;return!x.isTreeTable(t)&&t.hasInputTable&&(s=await t.inputTable()),new Og(t,n,s)}}const an=J.module("TableViewportUpdater"),kg=150,js=class extends y.exports.PureComponent{constructor(){super(...arguments),this.getViewportRowRange=Ie((e,t,n)=>{const s=n-t,i=Math.max(0,t-s*js.ROW_BUFFER_PAGES),o=n+s*js.ROW_BUFFER_PAGES;return[i,o]}),this.getViewportColumns=Ie((e,t,n,s)=>{if(t==null||n==null)return null;const i=n-t,o=Math.max(0,t-i*js.COLUMN_BUFFER_PAGES),r=Math.min(n+i*js.COLUMN_BUFFER_PAGES,e.columns.length-1),l=[];for(let a=o;a<=r;a+=1){const c=U.getModelIndex(a,s);l.push(e.columns[c])}return l}),this.updateViewport=cs((e,t,n,s,i)=>{if(t<e){an.error("Invalid viewport",e,t);return}if(e===0&&t===0){an.debug2("Ignoring 0-0 viewport");return}const{movedColumns:o,table:r}=this.props,[l,a]=this.getViewportRowRange(r,e,t),c=i!=null?i:this.getViewportColumns(r,n,s,o);if(an.debug2("Setting Viewport Top:",l,"Bottom:",a,"Columns:",c),this.subscription==null){an.debug2("updateViewport creating new subscription"),this.subscription=r.setViewport(l,a,c);const{onSubscription:d}=this.props;d(this.subscription)}else an.debug2("updateViewport using existing subscription"),this.subscription.setViewport(l,a,c)},kg)}componentDidMount(){const{top:e,bottom:t,left:n,right:s,table:i,filters:o,sorts:r,columns:l,customColumns:a}=this.props;i.applyFilter(o),i.applySort(r),i.applyCustomColumns(a),this.updateViewport(e,t,n,s,l)}componentDidUpdate(e){const{top:t,bottom:n,left:s,right:i,table:o,filters:r,sorts:l,customColumns:a,columns:c}=this.props,d=r!==e.filters,u=l!==e.sorts,m=a!==e.customColumns,p=o!==e.table;(d||u||m||p)&&this.closeSubscription(),(d||p)&&(an.debug("update table filter",r),o.applyFilter(r)),(u||p)&&(an.debug("update table sort",l),o.applySort(l)),(m||p)&&(an.debug("update table custom columns",a),o.applyCustomColumns(a)),this.updateViewport(t,n,s,i,c)}componentWillUnmount(){this.closeSubscription()}closeSubscription(){if(an.debug2("closeSubscription",this.subscription),this.subscription){this.subscription.close(),this.subscription=void 0;const{onSubscription:e}=this.props;e()}this.updateViewport.cancel()}render(){return null}};let Rr=js;Rr.ROW_BUFFER_PAGES=3;Rr.COLUMN_BUFFER_PAGES=1;Rr.defaultProps={top:0,bottom:0,left:null,right:null,columns:null,onSubscription:()=>{},filters:[],sorts:[],customColumns:[],movedColumns:[]};const Ss=J.module("TreeTableViewportUpdater"),Lg=150,rc=class extends y.exports.PureComponent{constructor(e){super(e),this.updateViewport=cs((t,n)=>{if(n<t){Ss.error("Invalid viewport",t,n);return}if(t===0&&n===0){Ss.debug2("Ignoring 0-0 viewport");return}const{table:s,updateInterval:i}=this.props,o=n-t,r=Math.max(0,t-o*3),l=n+o*3+1;if(Ss.debug2("Setting Viewport Top:",r,"Bottom:",l,s),!this.listenerCleanup){const{onViewportUpdate:a}=this.props;this.listenerCleanup=s.addEventListener(E.TreeTable.EVENT_UPDATED,a)}s.setViewport(r,l,void 0,i)},Lg),this.updateViewport=this.updateViewport.bind(this),this.listenerCleanup=null}componentDidMount(){const{top:e,bottom:t,table:n,filters:s,sorts:i}=this.props;Ss.debug("componentDidMount",this.props),n.applyFilter(s),n.applySort(i),this.updateViewport(e,t)}componentDidUpdate(e){const{top:t,bottom:n,table:s,filters:i,sorts:o}=this.props;i!==e.filters&&(Ss.debug("update table filter",i),s.applyFilter(i)),o!==e.sorts&&(Ss.debug("update table sort",o),s.applySort(o)),this.updateViewport(t,n)}componentWillUnmount(){this.updateViewport.cancel(),this.listenerCleanup&&this.listenerCleanup()}render(){return null}};let lc=rc;lc.UPDATE_INTERVAL=1e3;lc.defaultProps={top:0,bottom:0,onViewportUpdate:()=>{},filters:[],sorts:[],updateInterval:rc.UPDATE_INTERVAL};J.setLogLevel(parseInt("2",10));const ys=J.module("EmbedGrid.App");async function Pg(e,t){ys.info(`Fetching table ${t}...`);const n={name:t,type:E.VariableType.TABLE};return e.getObject(n)}function Hg(){const[e,t]=y.exports.useState(),[n,s]=y.exports.useState(),[i,o]=y.exports.useState(),[r,l]=y.exports.useState(),[a,c]=y.exports.useState(!0),d=y.exports.useMemo(()=>new URLSearchParams(window.location.search),[]),u=d.get("canCopy")!=null,m=d.get("canDownloadCsv")!=null;y.exports.useEffect(function(){async function f(){try{const C=d.get("name");if(C==null)throw new Error("No name param provided");const b=new URL("/jsapi",`${window.location}`),w=`${b.protocol}//${b.host}`;ys.debug("Starting connection...");const S=new E.IdeConnection(w);ys.debug("Loading table",C,"...");const I=await Pg(S,C);ys.debug("Creating model...");const v=await Ag.makeModel(I);t(v),ys.debug("Table successfully loaded!")}catch(C){ys.error("Unable to load table",C),s(`${C}`)}c(!1)}f()},[d]),y.exports.useEffect(function(){function f(C){const{command:b,value:w}=C.data;switch(b){case"filter":{const I=w.map(({name:v,value:R})=>{const M=e==null?void 0:e.columns.find(F=>F.name===v);if(M==null)throw new Error(`Could not find column named ${v}`);return{name:v,value:R,type:x.getNormalizedType(M.type)}});o(I);break}case"sort":{const I=w.map(({name:v,direction:R})=>{const M=e==null?void 0:e.columns.find(F=>F.name===v);if(M==null)throw new Error(`Could not find column named ${v}`);return R==="DESC"?M.sort().desc():M.sort().asc()});l(I);break}}}return window.addEventListener("message",f),()=>{window.removeEventListener("message",f)}},[e]);const p=e!=null;return T("div",{className:"App",children:[p&&h(ri,{canCopy:u,canDownloadCsv:m,model:e,inputFilters:i,sorts:r}),!p&&h(ua,{isLoaded:p,isLoading:a,errorMessage:n!=null?n:null}),h(Jd,{})]})}qo.render(h(Hg,{}),document.getElementById("root"));
32
- //# sourceMappingURL=index.324c34b1.js.map
32
+ //# sourceMappingURL=index.63e68ea8.js.map