@deephaven/embed-chart 0.38.1-beta.7 → 0.38.1-beta.9

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.
@@ -1,2 +1,2 @@
1
- var pe=Object.defineProperty;var ge=(f,s,e)=>s in f?pe(f,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):f[s]=e;var u=(f,s,e)=>(ge(f,typeof s!="symbol"?s+"":s,e),e);import{H as de,A as $,G as le,I as me,J as z,C as W,K as fe,L as Z}from"./vendor-c6328e9a.js";import{L as te,d as Ee,v as ye,a as Se,b as Te}from"./index-9192b18a.js";import{a as G,T as se,D as De,F as ie,b as Ae,u as Fe,c as be,C as Ne}from"./useConnection-87b8bdaa.js";import{P as ee,b as xe,h as we,p as Pe,o as Le,s as Ie,t as Oe,c as oe}from"./plotly-b153f4cb.js";import"./helpers-042e6b4d.js";ee.register([xe,we,Pe,Le,Ie,Oe]);const Me=typeof oe=="function"?oe(ee):oe.default(ee),L=class{constructor(){u(this,"listeners");u(this,"formatter");u(this,"rect");u(this,"isDownsamplingDisabled");u(this,"title");this.listeners=[],this.isDownsamplingDisabled=!1}getData(){return[]}getDefaultTitle(){return""}getLayout(){return{}}getFilterColumnMap(){return new Map}isFilterRequired(){return!1}setFilter(s){}close(){}setFormatter(s){this.formatter=s}setDownsamplingDisabled(s){this.isDownsamplingDisabled=s}setDimensions(s){this.rect=s}setTitle(s){this.title=s}subscribe(s){this.listeners.push(s)}unsubscribe(s){this.listeners=this.listeners.filter(e=>e!==s)}fireEvent(s){for(let e=0;e<this.listeners.length;e+=1)this.listeners[e](s)}fireUpdate(s){this.fireEvent(new CustomEvent(L.EVENT_UPDATED,{detail:s}))}fireDisconnect(){this.fireEvent(new CustomEvent(L.EVENT_DISCONNECT))}fireReconnect(){this.fireEvent(new CustomEvent(L.EVENT_RECONNECT))}fireDownsampleStart(s){this.fireEvent(new CustomEvent(L.EVENT_DOWNSAMPLESTARTED,{detail:s}))}fireDownsampleFinish(s){this.fireEvent(new CustomEvent(L.EVENT_DOWNSAMPLEFINISHED,{detail:s}))}fireDownsampleFail(s){this.fireEvent(new CustomEvent(L.EVENT_DOWNSAMPLEFAILED,{detail:s}))}fireDownsampleNeeded(s){this.fireEvent(new CustomEvent(L.EVENT_DOWNSAMPLENEEDED,{detail:s}))}fireLoadFinished(){this.fireEvent(new CustomEvent(L.EVENT_LOADFINISHED))}};let w=L;u(w,"EVENT_UPDATED","ChartModel.EVENT_UPDATED"),u(w,"EVENT_DISCONNECT","ChartModel.EVENT_DISCONNECT"),u(w,"EVENT_RECONNECT","ChartModel.EVENT_RECONNECT"),u(w,"EVENT_DOWNSAMPLESTARTED","ChartModel.EVENT_DOWNSAMPLESTARTED"),u(w,"EVENT_DOWNSAMPLEFINISHED","ChartModel.EVENT_DOWNSAMPLEFINISHED"),u(w,"EVENT_DOWNSAMPLEFAILED","ChartModel.EVENT_DOWNSAMPLEFAILED"),u(w,"EVENT_DOWNSAMPLENEEDED","ChartModel.EVENT_DOWNSAMPLENEEDED"),u(w,"EVENT_LOADFINISHED","ChartModel.EVENT_LOADFINISHED");const M=w,Re="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",Ce="#403e41",ve="#5b5a5c",ke="#c0bfbf",_e="#4878ea",Ve="rgba(91, 90, 92, 0.7)",T={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:Re,gridcolor:Ce,linecolor:ve,zerolinecolor:ke,activecolor:_e,rangebgcolor:Ve,"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"},I=Object.freeze({paper_bgcolor:T["paper-bgcolor"],plot_bgcolor:T["plot-bgcolor"],title_color:T["title-color"],colorway:T.colorway,gridcolor:T.gridcolor,linecolor:T.linecolor,zerolinecolor:T.zerolinecolor,activecolor:T.activecolor,rangebgcolor:T.rangebgcolor,area_color:T["area-color"],trend_color:T["trend-color"],line_color:T["line-color"],error_band_line_color:T["error-band-line-color"],error_band_fill_color:T["error-band-fill-color"],ohlc_increasing:T["ohlc-increasing"],ohlc_decreasing:T["ohlc-decreasing"]}),j=te.module("ChartUtils"),ce="io.deephaven.time.DateTime",Ue=36e5,He=1e6;function $e(f){return f.asDate!==void 0}function We(f){return f.asNumber!==void 0}function ue(f){return f.dhTimeZone!==void 0}function Be(f){return f!=null&&f.range!=null&&(f.autorange===!1||f.autorange===void 0)}const h=class{constructor(s){u(this,"dh");u(this,"daysOfWeek");this.dh=s,this.daysOfWeek=Object.freeze(s.calendar.DayOfWeek.values())}static getPlotlyErrorBars(s,e,t){const i=t.map((n,r)=>n-s[r]),o=e.map((n,r)=>s[r]-n);return{type:"data",symmetric:!1,array:i,arrayminus:o}}static convertNumberPrefix(s){return s.replace(/\u00A4\u00A4/g,"USD").replace(/\u00A4/g,"$")}static getPlotlyNumberFormat(s,e,t){if(!t)return null;const o=t.split(";")[0].match(/^([^#,0.]*)([#,]*)([0,]*)(\.?)(0*)(#*)(E?0*)(%?)(.*)/);G(o);const[,n,r,a,,c,l,d,p,m]=o,g=a.replace(",","").length,S=r.indexOf(",")>=0||a.indexOf(",")>=0?",":"",b=d!=null&&d!==""?"e":"f",E=p!==""?p:b,x=c.length+l.length,N=`0${g}${S}.${x}${E}`,V=h.convertNumberPrefix(n),R=h.convertNumberPrefix(m);return{tickformat:N,tickprefix:V,ticksuffix:R,automargin:!0}}static addTickSpacing(s,e,t){const{gapBetweenMajorTicks:i}=e;if(i>0){const o=s||{};let n=i;return t&&(n=i/He),e.log&&(n=Math.log(n)),o.tickmode="linear",o.dtick=n,o}return s}static getSourceForAxis(s,e){for(let t=0;t<s.series.length;t+=1){const i=s.series[t];for(let o=0;o<i.sources.length;o+=1){const n=i.sources[o];if(n.axis===e)return n}}return null}static getSeriesVisibility(s,e){return e!=null&&e.hiddenSeries!=null&&e.hiddenSeries.includes(s)?"legendonly":!0}static getHiddenLabels(s){return s!=null&&s.hiddenSeries?[...s.hiddenSeries]:[]}static makeSeriesData(s,e,t,i,o=h.ORIENTATION.VERTICAL){return{type:s,mode:e,name:t,orientation:o,showlegend:i??void 0}}static getMarkerSymbol(s){switch(s){case"SQUARE":return"square";case"CIRCLE":return"circle";case"DIAMOND":return"diamond";case"UP_TRIANGLE":return"triangle-up";case"DOWN_TRIANGLE":return"triangle-down";case"RIGHT_TRIANGLE":return"triangle-right";case"LEFT_TRIANGLE":return"triangle-left";case"ELLIPSE":case"HORIZONTAL_RECTANGLE":case"VERTICAL_RECTANGLE":default:throw new Error(`Unrecognized shape ${s}`)}}static getAllAxes(s){return s.charts.reduce((e,t)=>[...e,...t.axes],[])}static getChartForSeries(s,e){const{charts:t}=s;for(let i=0;i<t.length;i+=1){const o=t[i];for(let n=0;n<o.series.length;n+=1)if(e===o.series[n])return o}return null}static getLayoutRanges(s){const e={},t=Object.keys(s).filter(i=>i.indexOf("axis")>=0);for(let i=0;i<t.length;i+=1){const o=t[i],n=s[o];Be(n)&&(e[o]=[...n.range])}return e}static getAxisLayoutProperty(s,e){const t=e>0?`${e+1}`:"";return`${s??""}axis${t}`}static periodToDecimal(s){const e=s.split(":");return Number(e[0])+Number(e[1])/60}static groupArray(s,e){return s.reduce((t,i)=>{const o=i[e],n=t.get(o)??[];return n.push(i),t.set(o,n),t},new Map)}static getColorwayFromTheme(s=I){let e=[];return s.colorway&&(Array.isArray(s.colorway)?e=s.colorway:typeof s.colorway=="string"?e=s.colorway.split(" "):j.warn(`Unable to handle colorway property: ${s.colorway}`)),e}static titleFromSettings(s){const{series:e,xAxis:t,title:i=`${(e??[]).join(", ")} by ${t}`}=s;return i}getAxisFormats(s,e){const t=new Map,i={tickformat:null,ticksuffix:null},o=h.getAllAxes(s),n=h.groupArray(o,"type"),{charts:r}=s;for(let a=0;a<r.length;a+=1){const c=r[a];for(let l=0;l<c.series.length;l+=1){const d=c.series[l],{sources:p}=d,m=p.filter(g=>g.axis);for(let g=0;g<m.length;g+=1){const D=m[g],{axis:S}=D,{type:b}=S,E=n.get(b);G(E);const x=E.indexOf(S),P=this.getAxisPropertyName(b);if(P!=null){const N=h.getAxisLayoutProperty(P,x);if(t.has(N))j.debug(`${N} already added.`);else{j.debug(`Adding ${N} to axisFormats.`);const V=this.getPlotlyAxisFormat(D,e);if(V===null)t.set(N,i);else{t.set(N,V);const{businessCalendar:R}=S;if(R!=null){const O=[],{businessPeriods:v,businessDays:q,holidays:U,timeZone:H}=R,X=e==null?void 0:e.getColumnTypeFormatter(ce);let k;ue(X)&&(k=X.dhTimeZone);const K=k?(H.standardOffset-k.standardOffset)/60:0;U.length>0&&O.push(...this.createRangeBreakValuesFromHolidays(U,H,k)),v.forEach(_=>O.push({pattern:"hour",bounds:[h.periodToDecimal(_.close)+K,h.periodToDecimal(_.open)+K]})),q.length<this.daysOfWeek.length&&this.createBoundsFromDays(q).forEach(_=>O.push({pattern:"day of week",bounds:_})),V.rangebreaks=O}if(t.size===c.axes.length)return t}}}}}}return t}getPlotlyChartType(s,e){const{dh:t}=this;switch(s){case t.plot.SeriesPlotStyle.SCATTER:return e?"scatter":"scattergl";case t.plot.SeriesPlotStyle.LINE:return"scatter";case t.plot.SeriesPlotStyle.BAR:case t.plot.SeriesPlotStyle.STACKED_BAR:return"bar";case t.plot.SeriesPlotStyle.PIE:return"pie";case t.plot.SeriesPlotStyle.TREEMAP:return"treemap";case t.plot.SeriesPlotStyle.HISTOGRAM:return"histogram";case t.plot.SeriesPlotStyle.OHLC:return"ohlc";default:return}}getPlotlyChartMode(s,e,t){const{dh:i}=this,o=new Set;switch(s){case i.plot.SeriesPlotStyle.SCATTER:(e??!1)&&o.add(h.MODE_LINES),(t??!0)&&o.add(h.MODE_MARKERS);break;case i.plot.SeriesPlotStyle.LINE:(e??!0)&&o.add(h.MODE_LINES),(t??!1)&&o.add(h.MODE_MARKERS);break}return o.size>0?[...o].join("+"):void 0}getPlotlyProperty(s,e){const{dh:t}=this;switch(s){case t.plot.SeriesPlotStyle.PIE:switch(e){case t.plot.SourceType.X:return"labels";case t.plot.SourceType.Y:return"values"}break;case t.plot.SeriesPlotStyle.OHLC:switch(e){case t.plot.SourceType.TIME:return"x"}break;case t.plot.SeriesPlotStyle.TREEMAP:switch(e){case t.plot.SourceType.X:return"ids";case t.plot.SourceType.Y:return"values";case t.plot.SourceType.LABEL:return"labels";case t.plot.SourceType.PARENT:return"parents";case t.plot.SourceType.COLOR:return"marker.colors"}break}switch(e){case t.plot.SourceType.X:return"x";case t.plot.SourceType.Y:return"y";case t.plot.SourceType.Z:return"z";case t.plot.SourceType.X_LOW:return"xLow";case t.plot.SourceType.X_HIGH:return"xHigh";case t.plot.SourceType.Y_LOW:return"yLow";case t.plot.SourceType.Y_HIGH:return"yHigh";case t.plot.SourceType.TIME:return"time";case t.plot.SourceType.OPEN:return"open";case t.plot.SourceType.HIGH:return"high";case t.plot.SourceType.LOW:return"low";case t.plot.SourceType.CLOSE:return"close";case t.plot.SourceType.SHAPE:return"shape";case t.plot.SourceType.SIZE:return"size";case t.plot.SourceType.LABEL:return"label";case t.plot.SourceType.COLOR:return"color";case t.plot.SourceType.PARENT:return"parent";case t.plot.SourceType.HOVER_TEXT:return"hovertext";case t.plot.SourceType.TEXT:return"text";default:throw new Error(`Unrecognized source type: ${e}`)}}getPlotlySeriesOrientation(s){var i,o;const{dh:e}=this,{sources:t}=s;return t.length===2&&((o=(i=t[0])==null?void 0:i.axis)==null?void 0:o.type)===e.plot.AxisType.Y?h.ORIENTATION.HORIZONTAL:h.ORIENTATION.VERTICAL}makeSeriesDataFromSeries(s,e,t,i=null,o=I){const{name:n,isLinesVisible:r,isShapesVisible:a,plotStyle:c,lineColor:l,shapeColor:d,sources:p,shape:m,shapeSize:g}=s,D=p.some(P=>{var N;return(N=P.axis)==null?void 0:N.businessCalendar}),S=this.getChartType(c,D),b=this.getPlotlyChartMode(c,r??void 0,a??void 0),E=this.getPlotlySeriesOrientation(s),x=h.makeSeriesData(S,b,n,i,E);return this.addSourcesToSeriesData(x,c,p,e),this.addStylingToSeriesData(x,c,o,l,d,m,g,t),x}addSourcesToSeriesData(s,e,t,i){const o=s;for(let n=0;n<t.length;n+=1){const r=t[n],{axis:a,type:c}=r,l=this.getPlotlyProperty(e,c);de(o,l,[]);const d=a!=null?this.getAxisPropertyName(a.type):null;if(d!=null){const p=i.get(a.type);if(p){const m=p.indexOf(a),g=m>0?`${m+1}`:"";o[`${d}axis`]=`${d}${g}`}}}}addStylingToSeriesData(s,e,t=I,i=null,o=null,n=null,r=null,a=null){const{dh:c}=this,l=s;if(l.marker={line:{}},l.line={width:1},e===c.plot.SeriesPlotStyle.AREA?l.fill="tozeroy":e===c.plot.SeriesPlotStyle.STACKED_AREA?l.stackgroup="stack":e===c.plot.SeriesPlotStyle.STEP?l.line.shape="hv":e===c.plot.SeriesPlotStyle.HISTOGRAM?(l.width=[],l.marker.line!==void 0&&Object.assign(l.marker.line,{color:t.paper_bgcolor,width:1})):e===c.plot.SeriesPlotStyle.OHLC?(l.increasing={line:{color:t.ohlc_increasing}},l.decreasing={line:{color:t.ohlc_decreasing}}):e===c.plot.SeriesPlotStyle.PIE?(l.textinfo="label+percent",l.outsidetextfont={color:t.title_color}):e===c.plot.SeriesPlotStyle.TREEMAP&&(l.hoverinfo="text",l.textinfo="label+text",l.tiling={packing:"squarify",pad:0},l.textposition="middle center",l.outsidetextfont={color:t.title_color}),i!=null&&(e===c.plot.SeriesPlotStyle.BAR?l.marker.color=i:l.line.color=i),o!=null&&(l.marker.color=o),n!=null&&n.length>0)try{l.marker.symbol=h.getMarkerSymbol(n)}catch(d){j.warn("Unable to handle shape",n,":",d)}r!=null&&(l.marker.size=r*h.DEFAULT_MARKER_SIZE),a!=null&&e!==c.plot.SeriesPlotStyle.PIE&&(l.visible=a)}getChartType(s,e){const{dh:t}=this;switch(s){case t.plot.SeriesPlotStyle.HISTOGRAM:return"bar";default:return this.getPlotlyChartType(s,e)}}getAxisPropertyName(s){const{dh:e}=this;switch(s){case e.plot.AxisType.X:return"x";case e.plot.AxisType.Y:return"y";default:return null}}getAxisSide(s){const{dh:e}=this;switch(s){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}}updateFigureAxes(s,e,t,i=0,o=0,n=I){const r=s,a=h.getAllAxes(e);for(let c=0;c<e.charts.length;c+=1){const l=e.charts[c],d=t==null?void 0:t(l),p=this.getChartBounds(e,l,i,o);this.updateLayoutAxes(r,l.axes,a,i,o,p,d,n)}this.removeStaleAxes(r,a)}getChartBounds(s,e,t,i){const{dh:o}=this,{cols:n,rows:r}=s,{column:a,colspan:c,row:l,rowspan:d}=e,p=a+c,m=l+d,g=1/n,D=1/r,S=h.AXIS_SIZE_PX/t,b=h.AXIS_SIZE_PX/i,E={bottom:(r-m)*D+(m<r?b/2:0),top:(r-l)*D-(l>0?b/2:0),left:a*g+(a>0?S/2:0),right:p*g-(p<n?S/2:0)};return(h.groupArray(e.axes,"position").get(o.plot.AxisPosition.RIGHT)??[]).length>0&&(t>0?E.right-=(E.right-E.left)*Math.max(0,Math.min(h.LEGEND_WIDTH_PX/t,h.MAX_LEGEND_SIZE)):E.right-=(E.right-E.left)*h.DEFAULT_AXIS_SIZE),E}getPlotlyDateFormat(s,e,t){const{dh:i}=this,o=t==null?void 0:t.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 n;const r=s==null?void 0:s.getColumnTypeFormatter(e);return r!=null&&ue(r)&&r.dhTimeZone!=null&&r.showTimeZone&&(n=i.i18n.DateTimeFormat.format(" z",new Date,r.dhTimeZone)),{tickformat:o,ticksuffix:n,automargin:!0}}getPlotlyAxisFormat(s,e=null){const{dh:t}=this,{axis:i,columnType:o}=s,{formatPattern:n}=i;let r=null;return se.isDateType(o)?(r=this.getPlotlyDateFormat(e,o,n),r=h.addTickSpacing(r,i,!0)):se.isNumberType(o)&&(r=h.getPlotlyNumberFormat(e,o,n),r=h.addTickSpacing(r,i,!1)),i.formatType===t.plot.AxisFormatType.CATEGORY&&(r?r.type="category":r={type:"category",tickformat:void 0,ticksuffix:void 0}),r}updateLayoutAxes(s,e,t,i=0,o=0,n={left:0,top:0,right:1,bottom:1},r,a=I){const{dh:c}=this,l=i>0?Math.max(h.MIN_AXIS_SIZE,Math.min(h.AXIS_SIZE_PX/o,h.MAX_AXIS_SIZE)):h.DEFAULT_AXIS_SIZE,d=o>0?Math.max(h.MIN_AXIS_SIZE,Math.min(h.AXIS_SIZE_PX/i,h.MAX_AXIS_SIZE)):h.DEFAULT_AXIS_SIZE,p=s,m=h.groupArray(e,"position"),g=h.groupArray(e,"type"),D=[...g.keys()],S=h.groupArray(t,"type");for(let b=0;b<D.length;b+=1){const E=D[b],x=this.getAxisPropertyName(E);if(x!=null){const P=g.get(E),N=S.get(E),R=E===c.plot.AxisType.Y?o:i;G(P),G(N);for(let O=0;O<P.length;O+=1){const v=P[O],q=N.indexOf(v),U=h.getAxisLayoutProperty(x,q);p[U]==null&&(p[U]=this.makeLayoutAxis(E,a));const H=p[U];if(H!=null){this.updateLayoutAxis(H,v,O,m,l,d,n);const{range:X,autorange:k}=H;if(r!=null&&X!==void 0&&(k===void 0||k===!1)){const K=r(v),[_,ae]=K(X);j.debug("Setting downsample range",R,_,ae),v.range(R,_,ae)}else v.range(R)}}}}}removeStaleAxes(s,e){const t=s,i=h.groupArray(e,"type"),o=[...i.keys()];for(let n=0;n<o.length;n+=1){const r=o[n],a=i.get(r);G(a);let c=a.length;const l=this.getAxisPropertyName(r);if(l!=null){let d=h.getAxisLayoutProperty(l,c);for(;t[d]!=null;)delete t[d],c+=1,d=h.getAxisLayoutProperty(l,c)}}}updateLayoutAxis(s,e,t,i,o,n,r){const{dh:a}=this,l=e.type===a.plot.AxisType.Y?n:o,d=s,p=e.label??"";if(d.title!==void 0&&typeof d.title!="string"?d.title.text=p:d.title={text:p},e.log&&(d.type="log"),d.side=this.getAxisSide(e.position),t>0){d.overlaying=this.getAxisPropertyName(e.type)??void 0;const m=i.get(e.position)??[],g=m.indexOf(e);g>0&&(d.anchor="free",e.position===a.plot.AxisPosition.RIGHT?d.position=r.right+(g-m.length+1)*l:e.position===a.plot.AxisPosition.TOP?d.position=r.top+(g-m.length+1)*l:e.position===a.plot.AxisPosition.BOTTOM?d.position=r.bottom+(m.length-g+1)*l:e.position===a.plot.AxisPosition.LEFT&&(d.position=r.left+(m.length-g+1)*l))}else if(e.type===a.plot.AxisType.X){const m=i.get(a.plot.AxisPosition.LEFT)||[],g=i.get(a.plot.AxisPosition.RIGHT)||[],D=Math.max(r.left,r.left+(m.length-1)*n),S=Math.min(r.right-(g.length-1)*n,r.right);d.domain=[D,S]}else if(e.type===a.plot.AxisType.Y){const m=i.get(a.plot.AxisPosition.BOTTOM)||[],g=i.get(a.plot.AxisPosition.TOP)||[],D=Math.max(r.bottom,r.bottom+(m.length-1)*o),S=Math.min(r.top-(g.length-1)*o,r.top);d.domain=[D,S]}}createBoundsFromDays(s){const e=s.map(n=>this.daysOfWeek.indexOf(n)),t=this.daysOfWeek.filter(n=>!s.includes(n)).map(n=>this.daysOfWeek.indexOf(n)),i=new Set;t.forEach(n=>{for(let r=n+1;r<n+this.daysOfWeek.length;r+=1){const a=r%this.daysOfWeek.length;if(e.includes(a)){i.add(a);break}}});const o=[];return i.forEach(n=>{for(let r=n-1;r>n-this.daysOfWeek.length;r-=1){const a=r<0?r+this.daysOfWeek.length:r;if(e.includes(a)){const c=(a+1)%7;o.push([c,n]);break}}}),o}createRangeBreakValuesFromHolidays(s,e,t){const i=[],o=[];return s.forEach(n=>{n.businessPeriods.length>0?o.push(...this.createPartialHoliday(n,e,t)):i.push(this.createFullHoliday(n,e,t))}),[{values:i},...o]}createFullHoliday(s,e,t){return this.adjustDateForTimeZone(`${s.date.toString()} 00:00:00.000000`,e,t)}createPartialHoliday(s,e,t){const i=s.date.toString(),o=["00:00"];s.businessPeriods.forEach(r=>{o.push(r.open),o.push(r.close)}),o.push("24:00");const n=[];for(let r=0;r<o.length;r+=2){const a=o[r],c=o[r+1];if(a!==c){const l=[this.adjustDateForTimeZone(`${i} ${a}:00.000000`,e,t)],d=Ue*(h.periodToDecimal(c)-h.periodToDecimal(a));n.push({values:l,dvalue:d})}}return n}adjustDateForTimeZone(s,e,t){return t&&t.standardOffset!==e.standardOffset?this.unwrapValue(this.wrapValue(s,ce,e),t):s}makeFigureSettings(s,e){const{dh:t}=this,{series:i,xAxis:o,type:n}=s,r=h.titleFromSettings(s),a={formatType:`${t.plot.AxisFormatType.NUMBER}`,type:`${t.plot.AxisType.X}`,position:`${t.plot.AxisPosition.BOTTOM}`},c={formatType:`${t.plot.AxisFormatType.NUMBER}`,type:`${t.plot.AxisType.Y}`,position:`${t.plot.AxisPosition.LEFT}`};return{charts:[{chartType:`${t.plot.ChartType.XY}`,axes:[a,c],series:(i??[]).map(l=>({plotStyle:`${n}`,name:l,dataSources:[{type:`${t.plot.SourceType.X}`,columnName:o??"",axis:a,table:e},{type:`${t.plot.SourceType.Y}`,columnName:l,axis:c,table:e}]}))}],title:r}}unwrapValue(s,e){const{dh:t}=this;if(s!=null){if($e(s))return t.i18n.DateTimeFormat.format(h.DATE_FORMAT,s,e);if(We(s))return s.asNumber()}return s}wrapValue(s,e,t=null){const{dh:i}=this;if(se.isDateType(e)&&typeof s=="string"){const o=s,n=h.DATE_FORMAT.substr(0,s.length),r=i.i18n.DateTimeFormat.parse(n,o);if(!t)return r;const a=`${n} Z`,c=i.i18n.DateTimeFormat.format("Z",r,t),l=i.i18n.DateTimeFormat.parse(a,`${o} ${c}`),d=i.i18n.DateTimeFormat.format("Z",l,t);return i.i18n.DateTimeFormat.parse(a,`${o} ${d}`)}return s}makeLayoutAxis(s,e=I){const{dh:t}=this,i={automargin:!0,gridcolor:e.gridcolor,linecolor:e.linecolor,rangeslider:{visible:!1},showline:!0,ticklen:5,tickcolor:e.paper_bgcolor,tickfont:{color:e.zerolinecolor},title:{font:{color:e.title_color}}};return s===t.plot.AxisType.X?Object.assign(i,{showgrid:!0}):s===t.plot.AxisType.Y&&Object.assign(i,{zerolinecolor:e.zerolinecolor,zerolinewidth:2}),i}makeDefaultLayout(s=I){const{dh:e}=this,t={...s,autosize:!0,colorway:h.getColorwayFromTheme(s),font:{family:"'Fira Sans', sans-serif"},title:{font:{color:s.title_color},yanchor:"top",pad:{...h.DEFAULT_TITLE_PADDING},y:1},legend:{font:{color:s.title_color}},margin:{...h.DEFAULT_MARGIN},xaxis:this.makeLayoutAxis(e.plot.AxisType.X,s),yaxis:this.makeLayoutAxis(e.plot.AxisType.Y,s)};return t.datarevision=0,t}hydrateSettings(s){const{dh:e}=this;return{...s,type:s.type!=null?e.plot.SeriesPlotStyle[s.type]:void 0}}};let y=h;u(y,"DEFAULT_AXIS_SIZE",.15),u(y,"MIN_AXIS_SIZE",.025),u(y,"MAX_AXIS_SIZE",.2),u(y,"AXIS_SIZE_PX",75),u(y,"LEGEND_WIDTH_PX",50),u(y,"MAX_LEGEND_SIZE",.25),u(y,"ORIENTATION",Object.freeze({HORIZONTAL:"h",VERTICAL:"v"})),u(y,"DATE_FORMAT","yyyy-MM-dd HH:mm:ss.SSSSSS"),u(y,"DEFAULT_MARGIN",Object.freeze({l:60,r:50,t:30,b:60,pad:0})),u(y,"DEFAULT_TITLE_PADDING",Object.freeze({t:8})),u(y,"SUBTITLE_LINE_HEIGHT",25),u(y,"DEFAULT_MARKER_SIZE",6),u(y,"MODE_MARKERS","markers"),u(y,"MODE_LINES","lines");const F=y;const C=te.module("Chart"),B=class extends $.Component{constructor(e){super(e);u(this,"currentSeries");u(this,"plot");u(this,"plotWrapper");u(this,"columnFormats");u(this,"dateTimeFormatterOptions");u(this,"decimalFormatOptions");u(this,"integerFormatOptions");u(this,"rect");u(this,"ranges");u(this,"isSubscribed");u(this,"isLoadedFired");u(this,"getCachedConfig",me((e,t,i,o)=>{const n=[],r=Boolean(e);if(r&&n.push({name:`Downsampling failed: ${e}`,click:()=>{},icon:B.convertIcon(Ee),attr:"fill-warning"}),t||i||o||r){const a=B.downsampleButtonTitle(i,o),c=B.downsampleButtonAttr(i,o),l=i?ye:Se;n.push({name:a,icon:B.convertIcon(l),click:this.handleDownsampleClick,attr:c})}return{displaylogo:!1,displayModeBar:i||r?!0:"hover",modeBarButtons:[n,["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=le.createRef(),this.plotWrapper=le.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,,,,i]=e.icon,o=`${i}`;return{width:t,path:o,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:i}=this.props;this.updateFormatterSettings(i),t!==e.isActive&&(t?this.subscribe():this.unsubscribe())}componentWillUnmount(){this.unsubscribe()}getPlotRect(){var e;return((e=this.plotWrapper.current)==null?void 0:e.getBoundingClientRect())??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){C.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){const{type:t,detail:i}=e;switch(C.debug2("Received data update",t,i),t){case M.EVENT_UPDATED:{this.currentSeries+=1,this.setState(n=>{const{layout:r,revision:a}=n;return typeof r.datarevision=="number"&&(r.datarevision+=1),{data:i,layout:r,revision:a+1}});const{onUpdate:o}=this.props;o({isLoading:!this.isLoadedFired});break}case M.EVENT_LOADFINISHED:{const{onUpdate:o}=this.props;this.isLoadedFired=!0,o({isLoading:!1});break}case M.EVENT_DISCONNECT:{const{onDisconnect:o}=this.props;o();break}case M.EVENT_RECONNECT:{const{onReconnect:o}=this.props;o();break}case M.EVENT_DOWNSAMPLESTARTED:{this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!0,downsamplingError:null});break}case M.EVENT_DOWNSAMPLEFINISHED:{this.setState({isDownsampleFinished:!0,isDownsampleInProgress:!1,downsamplingError:null});break}case M.EVENT_DOWNSAMPLENEEDED:case M.EVENT_DOWNSAMPLEFAILED:{const o=i.message??i;this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,downsamplingError:o});const{onError:n}=this.props;n(new Error(o));break}default:C.debug("Unknown event type",t,e)}}handlePlotUpdate(e){const{layout:t}=e,i=F.getLayoutRanges(t);!z(i,this.ranges)&&(this.ranges=i,this.updateModelDimensions(!0))}handleRelayout(e){if(C.debug("handleRelayout",e),e.hiddenlabels!=null){const{onSettingsChanged:t}=this.props,i=[...e.hiddenlabels];t({hiddenSeries:i})}this.updateModelDimensions()}handleRestyle([e,t]){if(C.debug("handleRestyle",e,t),Object.keys(e).includes("visible")){const{data:i}=this.state,{onSettingsChanged:o}=this.props;if(i!=null){const n=i.reduce((r,{name:a,visible:c})=>a!=null&&c==="legendonly"?[...r,a]:r,[]);o({hiddenSeries:n})}}}updateModelDimensions(e=!1){const t=this.getPlotRect();if(!t){C.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:o,model:n}=this.props;n.setDimensions(t),o&&this.subscribe()}}initFormatter(){const{settings:e}=this.props;this.updateFormatterSettings(e)}updateFormatterSettings(e){const t=ie.getColumnFormats(e),i=ie.getDateTimeFormatterOptions(e),{decimalFormatOptions:o={},integerFormatOptions:n={}}=e;(!z(this.columnFormats,t)||!z(this.dateTimeFormatterOptions,i)||!z(this.decimalFormatOptions,o)||!z(this.integerFormatOptions,n))&&(this.columnFormats=ie.getColumnFormats(e),this.dateTimeFormatterOptions=i,this.decimalFormatOptions=o,this.integerFormatOptions=n,this.updateFormatter())}updateFormatter(){const e=new Ae(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&&ee.relayout(this.plot.current.el,{autosize:!0}).catch(t=>{C.debug("Unable to resize, promise rejected",t)})}render(){const{data:e,downsamplingError:t,isDownsampleFinished:i,isDownsampleInProgress:o,isDownsamplingDisabled:n,layout:r,revision:a}=this.state,c=this.getCachedConfig(t,i,o,n),l=e!=null;return W.jsx("div",{className:"h-100 w-100 chart-wrapper",ref:this.plotWrapper,children:l&&W.jsx(Me,{ref:this.plot,data:e,layout:r,revision:a,config:c,onAfterPlot:this.handleAfterPlot,onError:C.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}};let Q=B;u(Q,"defaultProps",{isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:De.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}});const Xe=Q,A=te.module("FigureChartModel"),ne=class extends M{constructor(e,t,i={},o=I){super();u(this,"chartUtils");u(this,"dh");u(this,"figure");u(this,"settings");u(this,"theme");u(this,"data");u(this,"layout");u(this,"seriesDataMap");u(this,"pendingSeries");u(this,"oneClicks");u(this,"filterColumnMap");u(this,"lastFilter");u(this,"isConnected");u(this,"seriesToProcess");u(this,"addPendingSeries",fe(()=>{const e=F.getAllAxes(this.figure),{pendingSeries:t}=this;for(let i=0;i<t.length;i+=1){const o=t[i],n=this.figure.charts.find(r=>r.series.includes(o));this.addSeries(o,e,(n==null?void 0:n.showLegend)??null),o.subscribe()}this.pendingSeries=[]},ne.ADD_SERIES_DEBOUNCE));u(this,"getTimeZone",Z((e,t)=>{if(t!=null){const i=t.getColumnTypeFormatter(e);if(i!=null)return i.dhTimeZone}}));u(this,"getValueTranslator",Z((e,t)=>{const i=this.getTimeZone(e,t);return o=>this.chartUtils.unwrapValue(o,i)}));u(this,"getValueParser",Z((e,t)=>{const i=this.getTimeZone(e,t);return o=>this.chartUtils.wrapValue(o,e,i)}));u(this,"getRangeParser",Z((e,t)=>i=>{let[o,n]=i;const r=this.getValueParser(e,t);return o=r(o),n=r(n),[o,n]}));u(this,"getAxisRangeParser",Z((e,t)=>i=>{const o=F.getSourceForAxis(e,i);return o?this.getRangeParser(o.columnType,t):n=>n}));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.dh=e,this.chartUtils=new F(e),this.figure=t,this.settings=i,this.theme=o,this.data=[];const n={data:{},layout:this.chartUtils.makeDefaultLayout(o)};this.layout={grid:{rows:t.rows,columns:t.cols,pattern:"independent"},template:n},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=F.getAllAxes(this.figure),i=[];for(let r=0;r<e.length;r+=1){const a=e[r];for(let c=0;c<a.series.length;c+=1){const l=a.series[c];i.push(l.name),this.addSeries(l,t,a.showLegend)}}const n=[...this.seriesDataMap.keys()].filter(r=>i.indexOf(r)<0);for(let r=0;r<n.length;r+=1){const a=n[r];this.seriesDataMap.delete(a)}this.seriesToProcess=new Set([...this.seriesDataMap.keys()])}addSeries(e,t,i){const{dh:o}=this,n=F.groupArray(t,"type"),r=this.chartUtils.makeSeriesDataFromSeries(e,n,F.getSeriesVisibility(e.name,this.settings),i,this.theme);if(this.seriesDataMap.set(e.name,r),this.data=[...this.seriesDataMap.values()],e.plotStyle===o.plot.SeriesPlotStyle.STACKED_BAR?this.layout.barmode="stack":e.plotStyle===o.plot.SeriesPlotStyle.PIE&&(this.layout.hiddenlabels=F.getHiddenLabels(this.settings)),this.layout.showlegend=this.data.length>1||e.plotStyle===o.plot.SeriesPlotStyle.PIE?i??void 0:!1,e.oneClick!=null){const{oneClick:a}=e,{columns:c}=a;for(let l=0;l<c.length;l+=1)this.filterColumnMap.set(c[l].name,c[l]);this.oneClicks.push(a)}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){A.debug("Ignoring subscribe when figure in disconnected state");return}this.figure.subscribe(this.isDownsamplingDisabled?this.dh.plot.DownsampleOptions.DISABLE:this.dh.plot.DownsampleOptions.DEFAULT)}unsubscribeFigure(){this.figure.unsubscribe()}startListeningFigure(){const{dh:e}=this;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(){const{dh:e}=this;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){A.debug("Downsample started",e),this.fireDownsampleStart(e.detail)}handleDownsampleFinish(e){A.debug("Downsample finished",e),this.fireDownsampleFinish(e.detail)}handleDownsampleFail(e){A.error("Downsample failed",e),this.fireDownsampleFail(e.detail)}handleDownsampleNeeded(e){A.info("Downsample needed",e),this.fireDownsampleNeeded(e.detail)}handleFigureUpdated(e){const{detail:t}=e,{series:i}=t;A.debug2("handleFigureUpdated",i);for(let n=0;n<i.length;n+=1){const r=i[n];A.debug2("handleFigureUpdated updating series",r.name);const{sources:a}=r;for(let c=0;c<a.length;c+=1){const l=a[c],{columnType:d,type:p}=l,m=this.getValueTranslator(d,this.formatter),g=t.getArray(r,p,m);this.setDataArrayForSeries(r,p,g)}this.seriesToProcess.delete(r.name),this.seriesToProcess.size===0&&this.fireLoadFinished(),this.cleanSeries(r)}const{data:o}=this;this.fireUpdate(o)}handleRequestFailed(e){A.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){A.debug("Figure disconnected",e),this.isConnected=!1,this.listeners.length>0&&this.unsubscribeFigure(),this.fireDisconnect()}handleFigureReconnected(e){A.debug("Figure reconnected",e),this.isConnected=!0,this.initAllSeries(),this.fireReconnect(),this.listeners.length>0&&this.subscribeFigure()}handleFigureSeriesAdded(e){const{detail:t}=e;A.debug("handleFigureSeriesAdded",t),this.pendingSeries.push(t),this.addPendingSeries()}setDimensions(e){super.setDimensions(e),this.updateAxisPositions()}setTitle(e){var o;super.setTitle(e);const t=((o=(e??"").match(/<br>/g))==null?void 0:o.length)??0,i=F.DEFAULT_MARGIN.t+t*F.SUBTITLE_LINE_HEIGHT;this.layout.margin?this.layout.margin.t=i:this.layout.margin={t:i},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=F.DEFAULT_TITLE_PADDING.t+t*F.SUBTITLE_LINE_HEIGHT*.5)}getPlotWidth(){var e,t;return!this.rect||!this.rect.width?0:Math.max(this.rect.width-(((e=this.layout.margin)==null?void 0:e.l)??0)-(((t=this.layout.margin)==null?void 0:t.r)??0),0)}getPlotHeight(){var e,t;return!this.rect||!this.rect.height?0:Math.max(this.rect.height-(((e=this.layout.margin)==null?void 0:e.t)??0)-(((t=this.layout.margin)==null?void 0:t.b)??0),0)}updateAxisPositions(){const e=this.getPlotWidth(),t=this.getPlotHeight();this.chartUtils.updateFigureAxes(this.layout,this.figure,i=>this.getAxisRangeParser(i,this.formatter),e,t,this.theme)}updateLayoutFormats(){if(!this.formatter)return;this.chartUtils.getAxisFormats(this.figure,this.formatter).forEach((t,i)=>{A.debug(`Assigning ${i}`,this.layout[i],t);const o=this.layout[i];o!=null?Object.assign(o,t):A.debug(`Ignoring null layout.${i}`)})}setDataArrayForSeries(e,t,i){const{name:o,plotStyle:n}=e,r=this.seriesDataMap.get(o),a=this.chartUtils.getPlotlyProperty(n,t);r&&de(r,a,i)}cleanSeries(e){const{dh:t}=this,{name:i,plotStyle:o}=e,n=this.seriesDataMap.get(i);if(n!=null){if(o===t.plot.SeriesPlotStyle.HISTOGRAM){const{xLow:r,xHigh:a}=n;if(r&&a&&r.length===a.length){const c=[];for(let l=0;l<r.length;l+=1)c.push(a[l]-r[l]);n.width=c}}else if(o===t.plot.SeriesPlotStyle.LINE){const{x:r,xLow:a,xHigh:c,y:l,yLow:d,yHigh:p}=n;a&&c&&a!==r&&(n.error_x=F.getPlotlyErrorBars(r,a,c)),d&&p&&d!==l&&(n.error_y=F.getPlotlyErrorBars(l,d,p))}else if(o===t.plot.SeriesPlotStyle.TREEMAP){const{ids:r,labels:a}=n;r!==void 0&&a===void 0&&(n.labels=r)}}}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){A.warn("Trying to set a filter, but no one click!");return}A.debug("setFilter",e);for(let t=0;t<this.oneClicks.length;t+=1){const i=this.oneClicks[t],{columns:o}=i;new Set([...e.keys(),...this.lastFilter.keys()]).forEach(r=>{const a=e.get(r);this.lastFilter.get(r)!==a&&o.find(c=>c.name===r)!=null&&i.setValueForColumn(r,a)})}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 J=ne;u(J,"ADD_SERIES_DEBOUNCE",50);const he=J;class re{static async makeModelFromSettings(s,e,t,i=I){const o=await re.makeFigureFromSettings(s,e,t);return new he(s,o,e,i)}static async makeFigureFromSettings(s,e,t){const i=await t.copy();return i.applyCustomColumns(t.customColumns),i.applyFilter(t.filter),i.applySort(t.sort),s.plot.Figure.create(new F(s).makeFigureSettings(e,i))}static async makeModel(s,e,t,i=I){return new he(s,t,e,i)}}const ze=re;const Y=te.module("EmbedChart.App");async function Ze(f,s){Y.info(`Fetching figure ${s}...`);const e={name:s,type:dh.VariableType.FIGURE};return f.getObject(e)}function Je(){const[f,s]=$.useState(),[e,t]=$.useState(),[i,o]=$.useState(!0),n=$.useMemo(()=>new URLSearchParams(window.location.search),[]),r=Fe(),a=be();$.useEffect(function(){async function d(){try{const p=n.get("name");if(p==null)throw new Error("No name param provided");Y.debug("Loading figure",p,"...");const m=await Ze(r,p);Y.debug("Creating model...");const g=await ze.makeModel(a,void 0,m);s(g),Y.debug("Figure successfully loaded!")}catch(p){Y.error("Unable to load figure",p),t(`${p}`)}o(!1)}d()},[a,r,n]);const c=f!=null;return W.jsxs("div",{className:"App",children:[c&&W.jsx(Xe,{model:f}),!c&&W.jsx(Te,{isLoaded:c,isLoading:i,errorMessage:e??null}),W.jsx(Ne,{})]})}export{Je as default};
2
- //# sourceMappingURL=App-2fd87eab.js.map
1
+ var pe=Object.defineProperty;var ge=(f,s,e)=>s in f?pe(f,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):f[s]=e;var u=(f,s,e)=>(ge(f,typeof s!="symbol"?s+"":s,e),e);import{H as de,A as $,G as le,I as me,J as z,C as W,K as fe,L as Z}from"./vendor-c6328e9a.js";import{L as te,d as Ee,v as ye,a as Se,b as Te}from"./index-3ebf01f9.js";import{a as G,T as se,D as De,F as ie,b as Ae,u as Fe,c as be,C as Ne}from"./useConnection-f6190b1f.js";import{P as ee,b as xe,h as we,p as Pe,o as Le,s as Ie,t as Oe,c as oe}from"./plotly-b153f4cb.js";import"./helpers-042e6b4d.js";ee.register([xe,we,Pe,Le,Ie,Oe]);const Me=typeof oe=="function"?oe(ee):oe.default(ee),L=class{constructor(){u(this,"listeners");u(this,"formatter");u(this,"rect");u(this,"isDownsamplingDisabled");u(this,"title");this.listeners=[],this.isDownsamplingDisabled=!1}getData(){return[]}getDefaultTitle(){return""}getLayout(){return{}}getFilterColumnMap(){return new Map}isFilterRequired(){return!1}setFilter(s){}close(){}setFormatter(s){this.formatter=s}setDownsamplingDisabled(s){this.isDownsamplingDisabled=s}setDimensions(s){this.rect=s}setTitle(s){this.title=s}subscribe(s){this.listeners.push(s)}unsubscribe(s){this.listeners=this.listeners.filter(e=>e!==s)}fireEvent(s){for(let e=0;e<this.listeners.length;e+=1)this.listeners[e](s)}fireUpdate(s){this.fireEvent(new CustomEvent(L.EVENT_UPDATED,{detail:s}))}fireDisconnect(){this.fireEvent(new CustomEvent(L.EVENT_DISCONNECT))}fireReconnect(){this.fireEvent(new CustomEvent(L.EVENT_RECONNECT))}fireDownsampleStart(s){this.fireEvent(new CustomEvent(L.EVENT_DOWNSAMPLESTARTED,{detail:s}))}fireDownsampleFinish(s){this.fireEvent(new CustomEvent(L.EVENT_DOWNSAMPLEFINISHED,{detail:s}))}fireDownsampleFail(s){this.fireEvent(new CustomEvent(L.EVENT_DOWNSAMPLEFAILED,{detail:s}))}fireDownsampleNeeded(s){this.fireEvent(new CustomEvent(L.EVENT_DOWNSAMPLENEEDED,{detail:s}))}fireLoadFinished(){this.fireEvent(new CustomEvent(L.EVENT_LOADFINISHED))}};let w=L;u(w,"EVENT_UPDATED","ChartModel.EVENT_UPDATED"),u(w,"EVENT_DISCONNECT","ChartModel.EVENT_DISCONNECT"),u(w,"EVENT_RECONNECT","ChartModel.EVENT_RECONNECT"),u(w,"EVENT_DOWNSAMPLESTARTED","ChartModel.EVENT_DOWNSAMPLESTARTED"),u(w,"EVENT_DOWNSAMPLEFINISHED","ChartModel.EVENT_DOWNSAMPLEFINISHED"),u(w,"EVENT_DOWNSAMPLEFAILED","ChartModel.EVENT_DOWNSAMPLEFAILED"),u(w,"EVENT_DOWNSAMPLENEEDED","ChartModel.EVENT_DOWNSAMPLENEEDED"),u(w,"EVENT_LOADFINISHED","ChartModel.EVENT_LOADFINISHED");const M=w,Re="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",Ce="#403e41",ve="#5b5a5c",ke="#c0bfbf",_e="#4878ea",Ve="rgba(91, 90, 92, 0.7)",T={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:Re,gridcolor:Ce,linecolor:ve,zerolinecolor:ke,activecolor:_e,rangebgcolor:Ve,"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"},I=Object.freeze({paper_bgcolor:T["paper-bgcolor"],plot_bgcolor:T["plot-bgcolor"],title_color:T["title-color"],colorway:T.colorway,gridcolor:T.gridcolor,linecolor:T.linecolor,zerolinecolor:T.zerolinecolor,activecolor:T.activecolor,rangebgcolor:T.rangebgcolor,area_color:T["area-color"],trend_color:T["trend-color"],line_color:T["line-color"],error_band_line_color:T["error-band-line-color"],error_band_fill_color:T["error-band-fill-color"],ohlc_increasing:T["ohlc-increasing"],ohlc_decreasing:T["ohlc-decreasing"]}),j=te.module("ChartUtils"),ce="io.deephaven.time.DateTime",Ue=36e5,He=1e6;function $e(f){return f.asDate!==void 0}function We(f){return f.asNumber!==void 0}function ue(f){return f.dhTimeZone!==void 0}function Be(f){return f!=null&&f.range!=null&&(f.autorange===!1||f.autorange===void 0)}const h=class{constructor(s){u(this,"dh");u(this,"daysOfWeek");this.dh=s,this.daysOfWeek=Object.freeze(s.calendar.DayOfWeek.values())}static getPlotlyErrorBars(s,e,t){const i=t.map((n,r)=>n-s[r]),o=e.map((n,r)=>s[r]-n);return{type:"data",symmetric:!1,array:i,arrayminus:o}}static convertNumberPrefix(s){return s.replace(/\u00A4\u00A4/g,"USD").replace(/\u00A4/g,"$")}static getPlotlyNumberFormat(s,e,t){if(!t)return null;const o=t.split(";")[0].match(/^([^#,0.]*)([#,]*)([0,]*)(\.?)(0*)(#*)(E?0*)(%?)(.*)/);G(o);const[,n,r,a,,c,l,d,p,m]=o,g=a.replace(",","").length,S=r.indexOf(",")>=0||a.indexOf(",")>=0?",":"",b=d!=null&&d!==""?"e":"f",E=p!==""?p:b,x=c.length+l.length,N=`0${g}${S}.${x}${E}`,V=h.convertNumberPrefix(n),R=h.convertNumberPrefix(m);return{tickformat:N,tickprefix:V,ticksuffix:R,automargin:!0}}static addTickSpacing(s,e,t){const{gapBetweenMajorTicks:i}=e;if(i>0){const o=s||{};let n=i;return t&&(n=i/He),e.log&&(n=Math.log(n)),o.tickmode="linear",o.dtick=n,o}return s}static getSourceForAxis(s,e){for(let t=0;t<s.series.length;t+=1){const i=s.series[t];for(let o=0;o<i.sources.length;o+=1){const n=i.sources[o];if(n.axis===e)return n}}return null}static getSeriesVisibility(s,e){return e!=null&&e.hiddenSeries!=null&&e.hiddenSeries.includes(s)?"legendonly":!0}static getHiddenLabels(s){return s!=null&&s.hiddenSeries?[...s.hiddenSeries]:[]}static makeSeriesData(s,e,t,i,o=h.ORIENTATION.VERTICAL){return{type:s,mode:e,name:t,orientation:o,showlegend:i??void 0}}static getMarkerSymbol(s){switch(s){case"SQUARE":return"square";case"CIRCLE":return"circle";case"DIAMOND":return"diamond";case"UP_TRIANGLE":return"triangle-up";case"DOWN_TRIANGLE":return"triangle-down";case"RIGHT_TRIANGLE":return"triangle-right";case"LEFT_TRIANGLE":return"triangle-left";case"ELLIPSE":case"HORIZONTAL_RECTANGLE":case"VERTICAL_RECTANGLE":default:throw new Error(`Unrecognized shape ${s}`)}}static getAllAxes(s){return s.charts.reduce((e,t)=>[...e,...t.axes],[])}static getChartForSeries(s,e){const{charts:t}=s;for(let i=0;i<t.length;i+=1){const o=t[i];for(let n=0;n<o.series.length;n+=1)if(e===o.series[n])return o}return null}static getLayoutRanges(s){const e={},t=Object.keys(s).filter(i=>i.indexOf("axis")>=0);for(let i=0;i<t.length;i+=1){const o=t[i],n=s[o];Be(n)&&(e[o]=[...n.range])}return e}static getAxisLayoutProperty(s,e){const t=e>0?`${e+1}`:"";return`${s??""}axis${t}`}static periodToDecimal(s){const e=s.split(":");return Number(e[0])+Number(e[1])/60}static groupArray(s,e){return s.reduce((t,i)=>{const o=i[e],n=t.get(o)??[];return n.push(i),t.set(o,n),t},new Map)}static getColorwayFromTheme(s=I){let e=[];return s.colorway&&(Array.isArray(s.colorway)?e=s.colorway:typeof s.colorway=="string"?e=s.colorway.split(" "):j.warn(`Unable to handle colorway property: ${s.colorway}`)),e}static titleFromSettings(s){const{series:e,xAxis:t,title:i=`${(e??[]).join(", ")} by ${t}`}=s;return i}getAxisFormats(s,e){const t=new Map,i={tickformat:null,ticksuffix:null},o=h.getAllAxes(s),n=h.groupArray(o,"type"),{charts:r}=s;for(let a=0;a<r.length;a+=1){const c=r[a];for(let l=0;l<c.series.length;l+=1){const d=c.series[l],{sources:p}=d,m=p.filter(g=>g.axis);for(let g=0;g<m.length;g+=1){const D=m[g],{axis:S}=D,{type:b}=S,E=n.get(b);G(E);const x=E.indexOf(S),P=this.getAxisPropertyName(b);if(P!=null){const N=h.getAxisLayoutProperty(P,x);if(t.has(N))j.debug(`${N} already added.`);else{j.debug(`Adding ${N} to axisFormats.`);const V=this.getPlotlyAxisFormat(D,e);if(V===null)t.set(N,i);else{t.set(N,V);const{businessCalendar:R}=S;if(R!=null){const O=[],{businessPeriods:v,businessDays:q,holidays:U,timeZone:H}=R,X=e==null?void 0:e.getColumnTypeFormatter(ce);let k;ue(X)&&(k=X.dhTimeZone);const K=k?(H.standardOffset-k.standardOffset)/60:0;U.length>0&&O.push(...this.createRangeBreakValuesFromHolidays(U,H,k)),v.forEach(_=>O.push({pattern:"hour",bounds:[h.periodToDecimal(_.close)+K,h.periodToDecimal(_.open)+K]})),q.length<this.daysOfWeek.length&&this.createBoundsFromDays(q).forEach(_=>O.push({pattern:"day of week",bounds:_})),V.rangebreaks=O}if(t.size===c.axes.length)return t}}}}}}return t}getPlotlyChartType(s,e){const{dh:t}=this;switch(s){case t.plot.SeriesPlotStyle.SCATTER:return e?"scatter":"scattergl";case t.plot.SeriesPlotStyle.LINE:return"scatter";case t.plot.SeriesPlotStyle.BAR:case t.plot.SeriesPlotStyle.STACKED_BAR:return"bar";case t.plot.SeriesPlotStyle.PIE:return"pie";case t.plot.SeriesPlotStyle.TREEMAP:return"treemap";case t.plot.SeriesPlotStyle.HISTOGRAM:return"histogram";case t.plot.SeriesPlotStyle.OHLC:return"ohlc";default:return}}getPlotlyChartMode(s,e,t){const{dh:i}=this,o=new Set;switch(s){case i.plot.SeriesPlotStyle.SCATTER:(e??!1)&&o.add(h.MODE_LINES),(t??!0)&&o.add(h.MODE_MARKERS);break;case i.plot.SeriesPlotStyle.LINE:(e??!0)&&o.add(h.MODE_LINES),(t??!1)&&o.add(h.MODE_MARKERS);break}return o.size>0?[...o].join("+"):void 0}getPlotlyProperty(s,e){const{dh:t}=this;switch(s){case t.plot.SeriesPlotStyle.PIE:switch(e){case t.plot.SourceType.X:return"labels";case t.plot.SourceType.Y:return"values"}break;case t.plot.SeriesPlotStyle.OHLC:switch(e){case t.plot.SourceType.TIME:return"x"}break;case t.plot.SeriesPlotStyle.TREEMAP:switch(e){case t.plot.SourceType.X:return"ids";case t.plot.SourceType.Y:return"values";case t.plot.SourceType.LABEL:return"labels";case t.plot.SourceType.PARENT:return"parents";case t.plot.SourceType.COLOR:return"marker.colors"}break}switch(e){case t.plot.SourceType.X:return"x";case t.plot.SourceType.Y:return"y";case t.plot.SourceType.Z:return"z";case t.plot.SourceType.X_LOW:return"xLow";case t.plot.SourceType.X_HIGH:return"xHigh";case t.plot.SourceType.Y_LOW:return"yLow";case t.plot.SourceType.Y_HIGH:return"yHigh";case t.plot.SourceType.TIME:return"time";case t.plot.SourceType.OPEN:return"open";case t.plot.SourceType.HIGH:return"high";case t.plot.SourceType.LOW:return"low";case t.plot.SourceType.CLOSE:return"close";case t.plot.SourceType.SHAPE:return"shape";case t.plot.SourceType.SIZE:return"size";case t.plot.SourceType.LABEL:return"label";case t.plot.SourceType.COLOR:return"color";case t.plot.SourceType.PARENT:return"parent";case t.plot.SourceType.HOVER_TEXT:return"hovertext";case t.plot.SourceType.TEXT:return"text";default:throw new Error(`Unrecognized source type: ${e}`)}}getPlotlySeriesOrientation(s){var i,o;const{dh:e}=this,{sources:t}=s;return t.length===2&&((o=(i=t[0])==null?void 0:i.axis)==null?void 0:o.type)===e.plot.AxisType.Y?h.ORIENTATION.HORIZONTAL:h.ORIENTATION.VERTICAL}makeSeriesDataFromSeries(s,e,t,i=null,o=I){const{name:n,isLinesVisible:r,isShapesVisible:a,plotStyle:c,lineColor:l,shapeColor:d,sources:p,shape:m,shapeSize:g}=s,D=p.some(P=>{var N;return(N=P.axis)==null?void 0:N.businessCalendar}),S=this.getChartType(c,D),b=this.getPlotlyChartMode(c,r??void 0,a??void 0),E=this.getPlotlySeriesOrientation(s),x=h.makeSeriesData(S,b,n,i,E);return this.addSourcesToSeriesData(x,c,p,e),this.addStylingToSeriesData(x,c,o,l,d,m,g,t),x}addSourcesToSeriesData(s,e,t,i){const o=s;for(let n=0;n<t.length;n+=1){const r=t[n],{axis:a,type:c}=r,l=this.getPlotlyProperty(e,c);de(o,l,[]);const d=a!=null?this.getAxisPropertyName(a.type):null;if(d!=null){const p=i.get(a.type);if(p){const m=p.indexOf(a),g=m>0?`${m+1}`:"";o[`${d}axis`]=`${d}${g}`}}}}addStylingToSeriesData(s,e,t=I,i=null,o=null,n=null,r=null,a=null){const{dh:c}=this,l=s;if(l.marker={line:{}},l.line={width:1},e===c.plot.SeriesPlotStyle.AREA?l.fill="tozeroy":e===c.plot.SeriesPlotStyle.STACKED_AREA?l.stackgroup="stack":e===c.plot.SeriesPlotStyle.STEP?l.line.shape="hv":e===c.plot.SeriesPlotStyle.HISTOGRAM?(l.width=[],l.marker.line!==void 0&&Object.assign(l.marker.line,{color:t.paper_bgcolor,width:1})):e===c.plot.SeriesPlotStyle.OHLC?(l.increasing={line:{color:t.ohlc_increasing}},l.decreasing={line:{color:t.ohlc_decreasing}}):e===c.plot.SeriesPlotStyle.PIE?(l.textinfo="label+percent",l.outsidetextfont={color:t.title_color}):e===c.plot.SeriesPlotStyle.TREEMAP&&(l.hoverinfo="text",l.textinfo="label+text",l.tiling={packing:"squarify",pad:0},l.textposition="middle center",l.outsidetextfont={color:t.title_color}),i!=null&&(e===c.plot.SeriesPlotStyle.BAR?l.marker.color=i:l.line.color=i),o!=null&&(l.marker.color=o),n!=null&&n.length>0)try{l.marker.symbol=h.getMarkerSymbol(n)}catch(d){j.warn("Unable to handle shape",n,":",d)}r!=null&&(l.marker.size=r*h.DEFAULT_MARKER_SIZE),a!=null&&e!==c.plot.SeriesPlotStyle.PIE&&(l.visible=a)}getChartType(s,e){const{dh:t}=this;switch(s){case t.plot.SeriesPlotStyle.HISTOGRAM:return"bar";default:return this.getPlotlyChartType(s,e)}}getAxisPropertyName(s){const{dh:e}=this;switch(s){case e.plot.AxisType.X:return"x";case e.plot.AxisType.Y:return"y";default:return null}}getAxisSide(s){const{dh:e}=this;switch(s){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}}updateFigureAxes(s,e,t,i=0,o=0,n=I){const r=s,a=h.getAllAxes(e);for(let c=0;c<e.charts.length;c+=1){const l=e.charts[c],d=t==null?void 0:t(l),p=this.getChartBounds(e,l,i,o);this.updateLayoutAxes(r,l.axes,a,i,o,p,d,n)}this.removeStaleAxes(r,a)}getChartBounds(s,e,t,i){const{dh:o}=this,{cols:n,rows:r}=s,{column:a,colspan:c,row:l,rowspan:d}=e,p=a+c,m=l+d,g=1/n,D=1/r,S=h.AXIS_SIZE_PX/t,b=h.AXIS_SIZE_PX/i,E={bottom:(r-m)*D+(m<r?b/2:0),top:(r-l)*D-(l>0?b/2:0),left:a*g+(a>0?S/2:0),right:p*g-(p<n?S/2:0)};return(h.groupArray(e.axes,"position").get(o.plot.AxisPosition.RIGHT)??[]).length>0&&(t>0?E.right-=(E.right-E.left)*Math.max(0,Math.min(h.LEGEND_WIDTH_PX/t,h.MAX_LEGEND_SIZE)):E.right-=(E.right-E.left)*h.DEFAULT_AXIS_SIZE),E}getPlotlyDateFormat(s,e,t){const{dh:i}=this,o=t==null?void 0:t.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 n;const r=s==null?void 0:s.getColumnTypeFormatter(e);return r!=null&&ue(r)&&r.dhTimeZone!=null&&r.showTimeZone&&(n=i.i18n.DateTimeFormat.format(" z",new Date,r.dhTimeZone)),{tickformat:o,ticksuffix:n,automargin:!0}}getPlotlyAxisFormat(s,e=null){const{dh:t}=this,{axis:i,columnType:o}=s,{formatPattern:n}=i;let r=null;return se.isDateType(o)?(r=this.getPlotlyDateFormat(e,o,n),r=h.addTickSpacing(r,i,!0)):se.isNumberType(o)&&(r=h.getPlotlyNumberFormat(e,o,n),r=h.addTickSpacing(r,i,!1)),i.formatType===t.plot.AxisFormatType.CATEGORY&&(r?r.type="category":r={type:"category",tickformat:void 0,ticksuffix:void 0}),r}updateLayoutAxes(s,e,t,i=0,o=0,n={left:0,top:0,right:1,bottom:1},r,a=I){const{dh:c}=this,l=i>0?Math.max(h.MIN_AXIS_SIZE,Math.min(h.AXIS_SIZE_PX/o,h.MAX_AXIS_SIZE)):h.DEFAULT_AXIS_SIZE,d=o>0?Math.max(h.MIN_AXIS_SIZE,Math.min(h.AXIS_SIZE_PX/i,h.MAX_AXIS_SIZE)):h.DEFAULT_AXIS_SIZE,p=s,m=h.groupArray(e,"position"),g=h.groupArray(e,"type"),D=[...g.keys()],S=h.groupArray(t,"type");for(let b=0;b<D.length;b+=1){const E=D[b],x=this.getAxisPropertyName(E);if(x!=null){const P=g.get(E),N=S.get(E),R=E===c.plot.AxisType.Y?o:i;G(P),G(N);for(let O=0;O<P.length;O+=1){const v=P[O],q=N.indexOf(v),U=h.getAxisLayoutProperty(x,q);p[U]==null&&(p[U]=this.makeLayoutAxis(E,a));const H=p[U];if(H!=null){this.updateLayoutAxis(H,v,O,m,l,d,n);const{range:X,autorange:k}=H;if(r!=null&&X!==void 0&&(k===void 0||k===!1)){const K=r(v),[_,ae]=K(X);j.debug("Setting downsample range",R,_,ae),v.range(R,_,ae)}else v.range(R)}}}}}removeStaleAxes(s,e){const t=s,i=h.groupArray(e,"type"),o=[...i.keys()];for(let n=0;n<o.length;n+=1){const r=o[n],a=i.get(r);G(a);let c=a.length;const l=this.getAxisPropertyName(r);if(l!=null){let d=h.getAxisLayoutProperty(l,c);for(;t[d]!=null;)delete t[d],c+=1,d=h.getAxisLayoutProperty(l,c)}}}updateLayoutAxis(s,e,t,i,o,n,r){const{dh:a}=this,l=e.type===a.plot.AxisType.Y?n:o,d=s,p=e.label??"";if(d.title!==void 0&&typeof d.title!="string"?d.title.text=p:d.title={text:p},e.log&&(d.type="log"),d.side=this.getAxisSide(e.position),t>0){d.overlaying=this.getAxisPropertyName(e.type)??void 0;const m=i.get(e.position)??[],g=m.indexOf(e);g>0&&(d.anchor="free",e.position===a.plot.AxisPosition.RIGHT?d.position=r.right+(g-m.length+1)*l:e.position===a.plot.AxisPosition.TOP?d.position=r.top+(g-m.length+1)*l:e.position===a.plot.AxisPosition.BOTTOM?d.position=r.bottom+(m.length-g+1)*l:e.position===a.plot.AxisPosition.LEFT&&(d.position=r.left+(m.length-g+1)*l))}else if(e.type===a.plot.AxisType.X){const m=i.get(a.plot.AxisPosition.LEFT)||[],g=i.get(a.plot.AxisPosition.RIGHT)||[],D=Math.max(r.left,r.left+(m.length-1)*n),S=Math.min(r.right-(g.length-1)*n,r.right);d.domain=[D,S]}else if(e.type===a.plot.AxisType.Y){const m=i.get(a.plot.AxisPosition.BOTTOM)||[],g=i.get(a.plot.AxisPosition.TOP)||[],D=Math.max(r.bottom,r.bottom+(m.length-1)*o),S=Math.min(r.top-(g.length-1)*o,r.top);d.domain=[D,S]}}createBoundsFromDays(s){const e=s.map(n=>this.daysOfWeek.indexOf(n)),t=this.daysOfWeek.filter(n=>!s.includes(n)).map(n=>this.daysOfWeek.indexOf(n)),i=new Set;t.forEach(n=>{for(let r=n+1;r<n+this.daysOfWeek.length;r+=1){const a=r%this.daysOfWeek.length;if(e.includes(a)){i.add(a);break}}});const o=[];return i.forEach(n=>{for(let r=n-1;r>n-this.daysOfWeek.length;r-=1){const a=r<0?r+this.daysOfWeek.length:r;if(e.includes(a)){const c=(a+1)%7;o.push([c,n]);break}}}),o}createRangeBreakValuesFromHolidays(s,e,t){const i=[],o=[];return s.forEach(n=>{n.businessPeriods.length>0?o.push(...this.createPartialHoliday(n,e,t)):i.push(this.createFullHoliday(n,e,t))}),[{values:i},...o]}createFullHoliday(s,e,t){return this.adjustDateForTimeZone(`${s.date.toString()} 00:00:00.000000`,e,t)}createPartialHoliday(s,e,t){const i=s.date.toString(),o=["00:00"];s.businessPeriods.forEach(r=>{o.push(r.open),o.push(r.close)}),o.push("24:00");const n=[];for(let r=0;r<o.length;r+=2){const a=o[r],c=o[r+1];if(a!==c){const l=[this.adjustDateForTimeZone(`${i} ${a}:00.000000`,e,t)],d=Ue*(h.periodToDecimal(c)-h.periodToDecimal(a));n.push({values:l,dvalue:d})}}return n}adjustDateForTimeZone(s,e,t){return t&&t.standardOffset!==e.standardOffset?this.unwrapValue(this.wrapValue(s,ce,e),t):s}makeFigureSettings(s,e){const{dh:t}=this,{series:i,xAxis:o,type:n}=s,r=h.titleFromSettings(s),a={formatType:`${t.plot.AxisFormatType.NUMBER}`,type:`${t.plot.AxisType.X}`,position:`${t.plot.AxisPosition.BOTTOM}`},c={formatType:`${t.plot.AxisFormatType.NUMBER}`,type:`${t.plot.AxisType.Y}`,position:`${t.plot.AxisPosition.LEFT}`};return{charts:[{chartType:`${t.plot.ChartType.XY}`,axes:[a,c],series:(i??[]).map(l=>({plotStyle:`${n}`,name:l,dataSources:[{type:`${t.plot.SourceType.X}`,columnName:o??"",axis:a,table:e},{type:`${t.plot.SourceType.Y}`,columnName:l,axis:c,table:e}]}))}],title:r}}unwrapValue(s,e){const{dh:t}=this;if(s!=null){if($e(s))return t.i18n.DateTimeFormat.format(h.DATE_FORMAT,s,e);if(We(s))return s.asNumber()}return s}wrapValue(s,e,t=null){const{dh:i}=this;if(se.isDateType(e)&&typeof s=="string"){const o=s,n=h.DATE_FORMAT.substr(0,s.length),r=i.i18n.DateTimeFormat.parse(n,o);if(!t)return r;const a=`${n} Z`,c=i.i18n.DateTimeFormat.format("Z",r,t),l=i.i18n.DateTimeFormat.parse(a,`${o} ${c}`),d=i.i18n.DateTimeFormat.format("Z",l,t);return i.i18n.DateTimeFormat.parse(a,`${o} ${d}`)}return s}makeLayoutAxis(s,e=I){const{dh:t}=this,i={automargin:!0,gridcolor:e.gridcolor,linecolor:e.linecolor,rangeslider:{visible:!1},showline:!0,ticklen:5,tickcolor:e.paper_bgcolor,tickfont:{color:e.zerolinecolor},title:{font:{color:e.title_color}}};return s===t.plot.AxisType.X?Object.assign(i,{showgrid:!0}):s===t.plot.AxisType.Y&&Object.assign(i,{zerolinecolor:e.zerolinecolor,zerolinewidth:2}),i}makeDefaultLayout(s=I){const{dh:e}=this,t={...s,autosize:!0,colorway:h.getColorwayFromTheme(s),font:{family:"'Fira Sans', sans-serif"},title:{font:{color:s.title_color},yanchor:"top",pad:{...h.DEFAULT_TITLE_PADDING},y:1},legend:{font:{color:s.title_color}},margin:{...h.DEFAULT_MARGIN},xaxis:this.makeLayoutAxis(e.plot.AxisType.X,s),yaxis:this.makeLayoutAxis(e.plot.AxisType.Y,s)};return t.datarevision=0,t}hydrateSettings(s){const{dh:e}=this;return{...s,type:s.type!=null?e.plot.SeriesPlotStyle[s.type]:void 0}}};let y=h;u(y,"DEFAULT_AXIS_SIZE",.15),u(y,"MIN_AXIS_SIZE",.025),u(y,"MAX_AXIS_SIZE",.2),u(y,"AXIS_SIZE_PX",75),u(y,"LEGEND_WIDTH_PX",50),u(y,"MAX_LEGEND_SIZE",.25),u(y,"ORIENTATION",Object.freeze({HORIZONTAL:"h",VERTICAL:"v"})),u(y,"DATE_FORMAT","yyyy-MM-dd HH:mm:ss.SSSSSS"),u(y,"DEFAULT_MARGIN",Object.freeze({l:60,r:50,t:30,b:60,pad:0})),u(y,"DEFAULT_TITLE_PADDING",Object.freeze({t:8})),u(y,"SUBTITLE_LINE_HEIGHT",25),u(y,"DEFAULT_MARKER_SIZE",6),u(y,"MODE_MARKERS","markers"),u(y,"MODE_LINES","lines");const F=y;const C=te.module("Chart"),B=class extends $.Component{constructor(e){super(e);u(this,"currentSeries");u(this,"plot");u(this,"plotWrapper");u(this,"columnFormats");u(this,"dateTimeFormatterOptions");u(this,"decimalFormatOptions");u(this,"integerFormatOptions");u(this,"rect");u(this,"ranges");u(this,"isSubscribed");u(this,"isLoadedFired");u(this,"getCachedConfig",me((e,t,i,o)=>{const n=[],r=Boolean(e);if(r&&n.push({name:`Downsampling failed: ${e}`,click:()=>{},icon:B.convertIcon(Ee),attr:"fill-warning"}),t||i||o||r){const a=B.downsampleButtonTitle(i,o),c=B.downsampleButtonAttr(i,o),l=i?ye:Se;n.push({name:a,icon:B.convertIcon(l),click:this.handleDownsampleClick,attr:c})}return{displaylogo:!1,displayModeBar:i||r?!0:"hover",modeBarButtons:[n,["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=le.createRef(),this.plotWrapper=le.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,,,,i]=e.icon,o=`${i}`;return{width:t,path:o,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:i}=this.props;this.updateFormatterSettings(i),t!==e.isActive&&(t?this.subscribe():this.unsubscribe())}componentWillUnmount(){this.unsubscribe()}getPlotRect(){var e;return((e=this.plotWrapper.current)==null?void 0:e.getBoundingClientRect())??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){C.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){const{type:t,detail:i}=e;switch(C.debug2("Received data update",t,i),t){case M.EVENT_UPDATED:{this.currentSeries+=1,this.setState(n=>{const{layout:r,revision:a}=n;return typeof r.datarevision=="number"&&(r.datarevision+=1),{data:i,layout:r,revision:a+1}});const{onUpdate:o}=this.props;o({isLoading:!this.isLoadedFired});break}case M.EVENT_LOADFINISHED:{const{onUpdate:o}=this.props;this.isLoadedFired=!0,o({isLoading:!1});break}case M.EVENT_DISCONNECT:{const{onDisconnect:o}=this.props;o();break}case M.EVENT_RECONNECT:{const{onReconnect:o}=this.props;o();break}case M.EVENT_DOWNSAMPLESTARTED:{this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!0,downsamplingError:null});break}case M.EVENT_DOWNSAMPLEFINISHED:{this.setState({isDownsampleFinished:!0,isDownsampleInProgress:!1,downsamplingError:null});break}case M.EVENT_DOWNSAMPLENEEDED:case M.EVENT_DOWNSAMPLEFAILED:{const o=i.message??i;this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,downsamplingError:o});const{onError:n}=this.props;n(new Error(o));break}default:C.debug("Unknown event type",t,e)}}handlePlotUpdate(e){const{layout:t}=e,i=F.getLayoutRanges(t);!z(i,this.ranges)&&(this.ranges=i,this.updateModelDimensions(!0))}handleRelayout(e){if(C.debug("handleRelayout",e),e.hiddenlabels!=null){const{onSettingsChanged:t}=this.props,i=[...e.hiddenlabels];t({hiddenSeries:i})}this.updateModelDimensions()}handleRestyle([e,t]){if(C.debug("handleRestyle",e,t),Object.keys(e).includes("visible")){const{data:i}=this.state,{onSettingsChanged:o}=this.props;if(i!=null){const n=i.reduce((r,{name:a,visible:c})=>a!=null&&c==="legendonly"?[...r,a]:r,[]);o({hiddenSeries:n})}}}updateModelDimensions(e=!1){const t=this.getPlotRect();if(!t){C.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:o,model:n}=this.props;n.setDimensions(t),o&&this.subscribe()}}initFormatter(){const{settings:e}=this.props;this.updateFormatterSettings(e)}updateFormatterSettings(e){const t=ie.getColumnFormats(e),i=ie.getDateTimeFormatterOptions(e),{decimalFormatOptions:o={},integerFormatOptions:n={}}=e;(!z(this.columnFormats,t)||!z(this.dateTimeFormatterOptions,i)||!z(this.decimalFormatOptions,o)||!z(this.integerFormatOptions,n))&&(this.columnFormats=ie.getColumnFormats(e),this.dateTimeFormatterOptions=i,this.decimalFormatOptions=o,this.integerFormatOptions=n,this.updateFormatter())}updateFormatter(){const{dh:e}=this.props,t=new Ae(e,this.columnFormats,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions),{model:i}=this.props;i.setFormatter(t)}updateDimensions(){const e=this.getPlotRect();this.plot.current!=null&&e!=null&&e.width>0&&e.height>0&&ee.relayout(this.plot.current.el,{autosize:!0}).catch(t=>{C.debug("Unable to resize, promise rejected",t)})}render(){const{data:e,downsamplingError:t,isDownsampleFinished:i,isDownsampleInProgress:o,isDownsamplingDisabled:n,layout:r,revision:a}=this.state,c=this.getCachedConfig(t,i,o,n),l=e!=null;return W.jsx("div",{className:"h-100 w-100 chart-wrapper",ref:this.plotWrapper,children:l&&W.jsx(Me,{ref:this.plot,data:e,layout:r,revision:a,config:c,onAfterPlot:this.handleAfterPlot,onError:C.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}};let Q=B;u(Q,"defaultProps",{isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:De.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}});const Xe=Q,A=te.module("FigureChartModel"),ne=class extends M{constructor(e,t,i={},o=I){super();u(this,"chartUtils");u(this,"dh");u(this,"figure");u(this,"settings");u(this,"theme");u(this,"data");u(this,"layout");u(this,"seriesDataMap");u(this,"pendingSeries");u(this,"oneClicks");u(this,"filterColumnMap");u(this,"lastFilter");u(this,"isConnected");u(this,"seriesToProcess");u(this,"addPendingSeries",fe(()=>{const e=F.getAllAxes(this.figure),{pendingSeries:t}=this;for(let i=0;i<t.length;i+=1){const o=t[i],n=this.figure.charts.find(r=>r.series.includes(o));this.addSeries(o,e,(n==null?void 0:n.showLegend)??null),o.subscribe()}this.pendingSeries=[]},ne.ADD_SERIES_DEBOUNCE));u(this,"getTimeZone",Z((e,t)=>{if(t!=null){const i=t.getColumnTypeFormatter(e);if(i!=null)return i.dhTimeZone}}));u(this,"getValueTranslator",Z((e,t)=>{const i=this.getTimeZone(e,t);return o=>this.chartUtils.unwrapValue(o,i)}));u(this,"getValueParser",Z((e,t)=>{const i=this.getTimeZone(e,t);return o=>this.chartUtils.wrapValue(o,e,i)}));u(this,"getRangeParser",Z((e,t)=>i=>{let[o,n]=i;const r=this.getValueParser(e,t);return o=r(o),n=r(n),[o,n]}));u(this,"getAxisRangeParser",Z((e,t)=>i=>{const o=F.getSourceForAxis(e,i);return o?this.getRangeParser(o.columnType,t):n=>n}));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.dh=e,this.chartUtils=new F(e),this.figure=t,this.settings=i,this.theme=o,this.data=[];const n={data:{},layout:this.chartUtils.makeDefaultLayout(o)};this.layout={grid:{rows:t.rows,columns:t.cols,pattern:"independent"},template:n},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=F.getAllAxes(this.figure),i=[];for(let r=0;r<e.length;r+=1){const a=e[r];for(let c=0;c<a.series.length;c+=1){const l=a.series[c];i.push(l.name),this.addSeries(l,t,a.showLegend)}}const n=[...this.seriesDataMap.keys()].filter(r=>i.indexOf(r)<0);for(let r=0;r<n.length;r+=1){const a=n[r];this.seriesDataMap.delete(a)}this.seriesToProcess=new Set([...this.seriesDataMap.keys()])}addSeries(e,t,i){const{dh:o}=this,n=F.groupArray(t,"type"),r=this.chartUtils.makeSeriesDataFromSeries(e,n,F.getSeriesVisibility(e.name,this.settings),i,this.theme);if(this.seriesDataMap.set(e.name,r),this.data=[...this.seriesDataMap.values()],e.plotStyle===o.plot.SeriesPlotStyle.STACKED_BAR?this.layout.barmode="stack":e.plotStyle===o.plot.SeriesPlotStyle.PIE&&(this.layout.hiddenlabels=F.getHiddenLabels(this.settings)),this.layout.showlegend=this.data.length>1||e.plotStyle===o.plot.SeriesPlotStyle.PIE?i??void 0:!1,e.oneClick!=null){const{oneClick:a}=e,{columns:c}=a;for(let l=0;l<c.length;l+=1)this.filterColumnMap.set(c[l].name,c[l]);this.oneClicks.push(a)}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){A.debug("Ignoring subscribe when figure in disconnected state");return}this.figure.subscribe(this.isDownsamplingDisabled?this.dh.plot.DownsampleOptions.DISABLE:this.dh.plot.DownsampleOptions.DEFAULT)}unsubscribeFigure(){this.figure.unsubscribe()}startListeningFigure(){const{dh:e}=this;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(){const{dh:e}=this;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){A.debug("Downsample started",e),this.fireDownsampleStart(e.detail)}handleDownsampleFinish(e){A.debug("Downsample finished",e),this.fireDownsampleFinish(e.detail)}handleDownsampleFail(e){A.error("Downsample failed",e),this.fireDownsampleFail(e.detail)}handleDownsampleNeeded(e){A.info("Downsample needed",e),this.fireDownsampleNeeded(e.detail)}handleFigureUpdated(e){const{detail:t}=e,{series:i}=t;A.debug2("handleFigureUpdated",i);for(let n=0;n<i.length;n+=1){const r=i[n];A.debug2("handleFigureUpdated updating series",r.name);const{sources:a}=r;for(let c=0;c<a.length;c+=1){const l=a[c],{columnType:d,type:p}=l,m=this.getValueTranslator(d,this.formatter),g=t.getArray(r,p,m);this.setDataArrayForSeries(r,p,g)}this.seriesToProcess.delete(r.name),this.seriesToProcess.size===0&&this.fireLoadFinished(),this.cleanSeries(r)}const{data:o}=this;this.fireUpdate(o)}handleRequestFailed(e){A.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){A.debug("Figure disconnected",e),this.isConnected=!1,this.listeners.length>0&&this.unsubscribeFigure(),this.fireDisconnect()}handleFigureReconnected(e){A.debug("Figure reconnected",e),this.isConnected=!0,this.initAllSeries(),this.fireReconnect(),this.listeners.length>0&&this.subscribeFigure()}handleFigureSeriesAdded(e){const{detail:t}=e;A.debug("handleFigureSeriesAdded",t),this.pendingSeries.push(t),this.addPendingSeries()}setDimensions(e){super.setDimensions(e),this.updateAxisPositions()}setTitle(e){var o;super.setTitle(e);const t=((o=(e??"").match(/<br>/g))==null?void 0:o.length)??0,i=F.DEFAULT_MARGIN.t+t*F.SUBTITLE_LINE_HEIGHT;this.layout.margin?this.layout.margin.t=i:this.layout.margin={t:i},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=F.DEFAULT_TITLE_PADDING.t+t*F.SUBTITLE_LINE_HEIGHT*.5)}getPlotWidth(){var e,t;return!this.rect||!this.rect.width?0:Math.max(this.rect.width-(((e=this.layout.margin)==null?void 0:e.l)??0)-(((t=this.layout.margin)==null?void 0:t.r)??0),0)}getPlotHeight(){var e,t;return!this.rect||!this.rect.height?0:Math.max(this.rect.height-(((e=this.layout.margin)==null?void 0:e.t)??0)-(((t=this.layout.margin)==null?void 0:t.b)??0),0)}updateAxisPositions(){const e=this.getPlotWidth(),t=this.getPlotHeight();this.chartUtils.updateFigureAxes(this.layout,this.figure,i=>this.getAxisRangeParser(i,this.formatter),e,t,this.theme)}updateLayoutFormats(){if(!this.formatter)return;this.chartUtils.getAxisFormats(this.figure,this.formatter).forEach((t,i)=>{A.debug(`Assigning ${i}`,this.layout[i],t);const o=this.layout[i];o!=null?Object.assign(o,t):A.debug(`Ignoring null layout.${i}`)})}setDataArrayForSeries(e,t,i){const{name:o,plotStyle:n}=e,r=this.seriesDataMap.get(o),a=this.chartUtils.getPlotlyProperty(n,t);r&&de(r,a,i)}cleanSeries(e){const{dh:t}=this,{name:i,plotStyle:o}=e,n=this.seriesDataMap.get(i);if(n!=null){if(o===t.plot.SeriesPlotStyle.HISTOGRAM){const{xLow:r,xHigh:a}=n;if(r&&a&&r.length===a.length){const c=[];for(let l=0;l<r.length;l+=1)c.push(a[l]-r[l]);n.width=c}}else if(o===t.plot.SeriesPlotStyle.LINE){const{x:r,xLow:a,xHigh:c,y:l,yLow:d,yHigh:p}=n;a&&c&&a!==r&&(n.error_x=F.getPlotlyErrorBars(r,a,c)),d&&p&&d!==l&&(n.error_y=F.getPlotlyErrorBars(l,d,p))}else if(o===t.plot.SeriesPlotStyle.TREEMAP){const{ids:r,labels:a}=n;r!==void 0&&a===void 0&&(n.labels=r)}}}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){A.warn("Trying to set a filter, but no one click!");return}A.debug("setFilter",e);for(let t=0;t<this.oneClicks.length;t+=1){const i=this.oneClicks[t],{columns:o}=i;new Set([...e.keys(),...this.lastFilter.keys()]).forEach(r=>{const a=e.get(r);this.lastFilter.get(r)!==a&&o.find(c=>c.name===r)!=null&&i.setValueForColumn(r,a)})}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 J=ne;u(J,"ADD_SERIES_DEBOUNCE",50);const he=J;class re{static async makeModelFromSettings(s,e,t,i=I){const o=await re.makeFigureFromSettings(s,e,t);return new he(s,o,e,i)}static async makeFigureFromSettings(s,e,t){const i=await t.copy();return i.applyCustomColumns(t.customColumns),i.applyFilter(t.filter),i.applySort(t.sort),s.plot.Figure.create(new F(s).makeFigureSettings(e,i))}static async makeModel(s,e,t,i=I){return new he(s,t,e,i)}}const ze=re;const Y=te.module("EmbedChart.App");async function Ze(f,s){Y.info(`Fetching figure ${s}...`);const e={name:s,type:dh.VariableType.FIGURE};return f.getObject(e)}function Je(){const[f,s]=$.useState(),[e,t]=$.useState(),[i,o]=$.useState(!0),n=$.useMemo(()=>new URLSearchParams(window.location.search),[]),r=Fe(),a=be();$.useEffect(function(){async function d(){try{const p=n.get("name");if(p==null)throw new Error("No name param provided");Y.debug("Loading figure",p,"...");const m=await Ze(r,p);Y.debug("Creating model...");const g=await ze.makeModel(a,void 0,m);s(g),Y.debug("Figure successfully loaded!")}catch(p){Y.error("Unable to load figure",p),t(`${p}`)}o(!1)}d()},[a,r,n]);const c=f!=null;return W.jsxs("div",{className:"App",children:[c&&W.jsx(Xe,{dh:a,model:f}),!c&&W.jsx(Te,{isLoaded:c,isLoading:i,errorMessage:e??null}),W.jsx(Ne,{})]})}export{Je as default};
2
+ //# sourceMappingURL=App-54751edd.js.map