@deephaven/embed-chart 0.35.1-sideEffects.3 → 0.35.1-test-envoy.18

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.
@@ -0,0 +1,2 @@
1
+ var We=Object.defineProperty;var qe=(g,s,e)=>s in g?We(g,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):g[s]=e;var u=(g,s,e)=>(qe(g,typeof s!="symbol"?s+"":s,e),e);import{G as X,C as D,E as Te,F as Le,A as K,H as je,I as _e,J as pe,K as ae,L as ze}from"./vendor-7841d969.js";import{v as Xe,L as Z,a as Ze,d as Ge,b as Ye,c as Ke,e as Qe}from"./index-6a67baac.js";import{P as Me,b as Je,h as et,p as tt,o as st,s as nt,t as it,c as we}from"./plotly-34743311.js";import"./helpers-042e6b4d.js";const ee=class{static disableAllActions(){ee.actionsDisabled=!0}static enableAllActions(){ee.actionsDisabled=!1}static isContextActionEvent(s){return Array.isArray(s.contextActions)}static compareActions(s,e){return s.group!==e.group?(s.group??0)>(e.group??0)?1:-1:s.order!==e.order?(s.order??0)>(e.order??0)?1:-1:s.title!==e.title?(s.title??"")>(e.title??"")?1:-1:s!==e?s>e?1:-1:0}static sortActions(s){if(s==null||!Array.isArray(s))return[];const e=s.slice();return e.sort(ee.compareActions),e}static isMacPlatform(){const{platform:s}=window.navigator;return s.startsWith("Mac")}static getModifierKey(){return ee.isMacPlatform()?"metaKey":"ctrlKey"}static isModifierKeyDown(s){const e=ee.getModifierKey();return s[e]}static getMenuItems(s,e=!0){let t=[],n=s;Array.isArray(n)||(n=[n]);for(let i=0;i<n.length;i+=1){const r=n[i];let a;typeof r=="function"?a=r():a=r,a!=null&&(a instanceof Promise?e&&t.push(a):Array.isArray(a)?t=t.concat(a):t.push(a))}return t=t.filter(i=>i.title!==void 0||i.then!=null||i.menuElement),t}static getNextMenuItem(s,e,t){let n=s;n<0&&e<0&&(n=t.length);for(let i=1;i<t.length+1;i+=1){const r=(n+e*i+t.length)%t.length,a=t[r];if(!(a instanceof Promise)&&a.disabled!==!0)return r}return s}};let ye=ee;u(ye,"actionsDisabled",!1);const J=ye,Ce=X.forwardRef((g,s)=>{var M;function e(y){const{menuItem:E,onMenuItemClick:b}=g;b(E,y)}function t(y){const{menuItem:E,onMenuItemMouseMove:b}=g;b(E,y)}function n(y){const{menuItem:E,onMenuItemContextMenu:b}=g;b(E,y)}function i(y,E,b){if(typeof y.type=="string")return y;const{closeMenu:N,menuItem:v,isKeyboardSelected:H,isMouseSelected:k,"data-testid":q}=g,O={menuItem:v,closeMenu:N,isKeyboardSelected:H,isMouseSelected:k,iconElement:E,displayShortcut:b,"data-testid":q};return X.cloneElement(y,{forwardedProps:O})}const{children:r,menuItem:a,isKeyboardSelected:o=!1,isMouseSelected:l=!1,"data-testid":c}=g,h=(M=a.shortcut)==null?void 0:M.getDisplayText();let m=null;if(a.icon){const y=a.icon;if(X.isValidElement(y))m=y;else{let E;a.iconColor!=null&&(a.disabled===void 0||!a.disabled)&&(E={color:a.iconColor}),m=D.jsx(Le,{icon:y,style:E})}}let T=null;const S=Boolean(r);a.actions&&(T=D.jsx(Le,{icon:Xe}));let F=null;if(a.menuElement)F=D.jsx("div",{className:"custom-menu-item",onMouseMove:t,children:i(a.menuElement,m,h)});else{const y=a.disabled,E=a.iconOutline;F=D.jsx("button",{type:"button",className:Te("btn-context-menu",{disabled:y},{active:(S||l)&&(y===void 0||!y)},{"keyboard-active":o&&(y===void 0||!y)}),onClick:e,onMouseMove:t,onContextMenu:n,title:a.description??"",children:D.jsxs("div",{className:"btn-context-menu-wrapper",children:[D.jsx("span",{className:Te("icon",{outline:E}),children:m}),D.jsx("span",{className:"title",children:a.title}),h!==void 0&&D.jsx("span",{className:"shortcut",children:h}),T&&D.jsx("span",{className:Te("submenu-indicator",{disabled:y}),children:T})]})})}return D.jsxs("div",{className:"context-menu-item",ref:s,"data-testid":c,children:[r,F]})});Ce.displayName="ContextMenuItem";Ce.defaultProps={children:null,isKeyboardSelected:!1,isMouseSelected:!1,"data-testid":void 0};const rt=Ce;class at extends Error{constructor(){super(...arguments);u(this,"isCanceled",!0)}}const ke=at;class ot extends Error{constructor(){super(...arguments);u(this,"isTimeout",!0)}}const Be=ot;class xe{static makeCancelable(s,e){let t=!1,n,i;const r=new Promise((a,o)=>{i=o,Promise.resolve(s).then(l=>{t?e&&e(l):(n=l,a(l))}).catch(l=>o(l))});return r.cancel=()=>{t=!0,i(new ke),n!=null&&e&&e(n)},r}static isCanceled(s){return s instanceof ke}static isTimedOut(s){return s instanceof Be}static withTimeout(s,e){return new Promise((t,n)=>{setTimeout(()=>{try{t(e())}catch(i){n(i)}},s)})}}function me(g){if(g==null)throw new Error("Value is null or undefined")}class lt{static join(s,e="and"){if(s==null||s.length===0)return"";if(s.length===1)return s[0];if(s.length===2)return`${s[0]} ${e} ${s[1]}`;const t=s.slice(0,s.length-1).join(", "),n=s[s.length-1];return`${t}, ${e} ${n}`}static toLower(s,e=!0){if(s==null){if(e)return"";throw new Error("Null string passed in to TextUtils.toLower")}return s.toLowerCase()}static sort(s,e,t=!0){return s<e?t?-1:1:s>e?t?1:-1:0}}const ct=lt,Re=Z.module("ContextMenu"),Ae=class extends K.PureComponent{constructor(e){super(e);u(this,"container");u(this,"oldFocus");u(this,"activeSubMenuRef");u(this,"subMenuTimer");u(this,"rAF");u(this,"initialPosition");this.handleBlur=this.handleBlur.bind(this),this.handleCloseSubMenu=this.handleCloseSubMenu.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleMenuItemClick=this.handleMenuItemClick.bind(this),this.handleMenuItemContextMenu=this.handleMenuItemContextMenu.bind(this),this.handleMenuItemMouseMove=this.handleMenuItemMouseMove.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleWindowResize=this.handleWindowResize.bind(this),this.container=X.createRef(),this.oldFocus=document.activeElement,this.activeSubMenuRef=X.createRef(),this.subMenuTimer=0,this.rAF=0,this.initialPosition={top:e.top,left:e.left},this.state={menuItems:[],pendingItems:[],activeSubMenu:null,hasOverflow:!1,subMenuTop:null,subMenuLeft:null,subMenuParentWidth:0,subMenuParentHeight:0,keyboardIndex:-1,mouseIndex:-1}}static handleContextMenu(e){e.metaKey||(e.stopPropagation(),e.preventDefault())}componentDidMount(){this.initMenu(),this.verifyPosition(),window.addEventListener("resize",this.handleWindowResize),this.rAF=window.requestAnimationFrame(()=>{var t;(t=this.container.current)==null||t.focus();const{onMenuOpened:e}=this.props;e(this)})}componentDidUpdate(e,t){var r,a;const{actions:n}=this.props,{activeSubMenu:i}=this.state;i!==t.activeSubMenu&&(i==null?(r=this.container.current)==null||r.focus():this.setActiveSubMenuPosition()),e.actions!==n&&(this.initMenu(),(this.container.current==null||!this.container.current.contains(document.activeElement))&&((a=this.container.current)==null||a.focus())),this.verifyPosition()}componentWillUnmount(){this.cancelPromises(),window.removeEventListener("resize",this.handleWindowResize),cancelAnimationFrame(this.rAF)}getKeyboardIndex(){const{options:e}=this.props;if(e.separateKeyboardMouse!==void 0&&e.separateKeyboardMouse){const{keyboardIndex:t}=this.state;return t}return this.getMouseIndex()}setKeyboardIndex(e){const{options:t}=this.props;t.separateKeyboardMouse!==void 0&&t.separateKeyboardMouse?this.setState({keyboardIndex:e}):this.setMouseIndex(e)}getMouseIndex(){const{mouseIndex:e}=this.state;return e}setMouseIndex(e){this.setState({mouseIndex:e})}initMenu(){this.cancelPromises(),cancelAnimationFrame(this.rAF);const{options:e}=this.props;let t=e.initialKeyboardIndex;t===void 0&&(t=-1);const{actions:n}=this.props,i=J.getMenuItems(n),r=[];for(let a=i.length-1;a>=0;a-=1){const o=i[a];o instanceof Promise?this.initMenuPromise(o):r.push(o)}this.setState({mouseIndex:-1,keyboardIndex:t,activeSubMenu:null,menuItems:J.sortActions(r)})}initMenuPromise(e){const t=xe.makeCancelable(e);this.setState(n=>({pendingItems:n.pendingItems.concat(t)})),t.then(n=>{this.setState(i=>{const r=i.pendingItems.indexOf(t);if(r>=0){const a=i.pendingItems.slice();return a.splice(r,1),{menuItems:J.sortActions(i.menuItems.concat(n)),pendingItems:a}}return null})},n=>{xe.isCanceled(n)||(this.setState(i=>{const r=i.pendingItems.indexOf(t);if(r>=0){const a=i.pendingItems.slice();return a.splice(r,1),{pendingItems:a}}return null}),Re.error(n))})}cancelPromises(){const{pendingItems:e}=this.state;e.map(t=>t.cancel())}setActiveSubMenuPosition(){if(this.activeSubMenuRef.current===null)return;const e=this.activeSubMenuRef.current.getBoundingClientRect();this.setState({subMenuTop:e.top,subMenuLeft:e.right,subMenuParentHeight:e.height,subMenuParentWidth:e.width})}verifyPosition(){var T,S;const{options:e,updatePosition:t,subMenuParentWidth:n,subMenuParentHeight:i,top:r,left:a}=this.props;if(!this.container.current||e.doNotVerifyPosition!=null&&e.doNotVerifyPosition)return;let{top:o,left:l}=this.initialPosition;const{width:c,height:h}=((T=this.container.current)==null?void 0:T.getBoundingClientRect())??{width:0,height:0},m=(((S=this.container.current)==null?void 0:S.scrollHeight)??0)>window.innerHeight;h===0||c===0||(o+h>window.innerHeight&&(o-h-i>0?o-=h-i:o=window.innerHeight-h),l+c>window.innerWidth&&(l=l-c-n),(a!==l||r!==o)&&(this.setState({hasOverflow:m}),t(o,l)))}handleWindowResize(){this.container.current&&this.closeMenu(!0)}handleBlur(e){if(!this.container.current){Re.warn("Container is null!");return}if(!this.container.current.contains(e.relatedTarget)){let t=e.relatedTarget,n=!1;for(;t&&!n;)n=t.hasAttribute("data-dh-context-menu"),t=t.parentElement;n||this.closeMenu(!0)}}isEscapeKey(e){const{left:t}=this.props;return e==="Escape"||t<0&&e==="ArrowRight"||e==="ArrowLeft"}handleKeyDown(e){const{menuItems:t}=this.state,n=this.getKeyboardIndex();let i=n,r=!1;if(e.key==="Enter"||e.key===" "){n>=0&&n<t.length&&this.handleMenuItemClick(t[n],e);return}if(e.key==="ArrowRight"?n>=0&&n<=t.length?r=!0:i=0:this.isEscapeKey(e.key)?i=null:e.key==="ArrowUp"||e.shiftKey&&e.key==="Tab"?i=J.getNextMenuItem(i,-1,t):(e.key==="ArrowDown"||e.key==="Tab")&&(i=J.getNextMenuItem(i,1,t)),r){this.openSubMenu(n),e.preventDefault(),e.stopPropagation();return}n!==i&&(i!==null?this.setKeyboardIndex(i):(this.closeMenu(),this.oldFocus instanceof HTMLElement&&this.oldFocus.focus()),e.preventDefault(),e.stopPropagation())}openSubMenu(e){const{menuItems:t,activeSubMenu:n}=this.state,i=t[e].actions?e:null;n!==i&&this.setState({activeSubMenu:i,subMenuTop:null,subMenuLeft:null})}closeMenu(e=!1){const{closeMenu:t,onMenuClosed:n}=this.props;cancelAnimationFrame(this.rAF),this.rAF=window.requestAnimationFrame(()=>{t(e),n(this)})}closeSubMenu(){this.setState({activeSubMenu:null})}handleCloseSubMenu(e){e?this.closeMenu(!0):this.closeSubMenu()}handleMenuItemClick(e,t){t.preventDefault(),t.stopPropagation();const{menuItems:n}=this.state;e!=null&&(e.disabled===void 0||!e.disabled)&&(e.actions!=null?this.openSubMenu(n.indexOf(e)):e.action!=null&&(e.action(),this.closeMenu(!0)))}handleMenuItemContextMenu(e,t){t.metaKey||this.handleMenuItemClick(e,t)}handleMenuItemMouseMove(e){const{menuItems:t}=this.state,n=t.indexOf(e);this.setMouseIndex(n),n>=0&&n<t.length&&(e.disabled===void 0||!e.disabled)&&this.openSubMenu(n)}handleMouseLeave(){this.setMouseIndex(-1)}render(){const e=[],{top:t,left:n}=this.props,{activeSubMenu:i,hasOverflow:r,keyboardIndex:a,menuItems:o,mouseIndex:l,pendingItems:c,subMenuTop:h,subMenuLeft:m,subMenuParentWidth:T,subMenuParentHeight:S}=this.state;for(let b=0;b<o.length;b+=1){const N=o[b];b>0&&N.group!==o[b-1].group&&e.push(D.jsx("hr",{},`${b}.separator`));const v=D.jsx(rt,{ref:i===b?this.activeSubMenuRef:null,isKeyboardSelected:a===b,isMouseSelected:l===b,menuItem:N,closeMenu:this.handleCloseSubMenu,onMenuItemClick:this.handleMenuItemClick,onMenuItemMouseMove:this.handleMenuItemMouseMove,onMenuItemContextMenu:this.handleMenuItemContextMenu},b);e.push(v)}let F=null;c.length>0&&(F=D.jsx("div",{className:"loading",children:D.jsx(Ze,{})}));const{menuStyle:M,"data-testid":y}=this.props,E=i!==null&&h!==null&&m!==null;return D.jsxs(D.Fragment,{children:[D.jsxs("div",{className:Te({"has-overflow":r},"context-menu-container"),style:{top:t,left:n,...M},ref:this.container,"data-dh-context-menu":!0,onBlur:this.handleBlur,onKeyDown:this.handleKeyDown,onMouseLeave:this.handleMouseLeave,onContextMenu:Ae.handleContextMenu,role:"menuitem",tabIndex:0,"data-testid":y,children:[e,F]}),E&&i!==null&&h!==null&&m!==null&&D.jsx(Ae,{actions:o[i].actions||[],closeMenu:this.handleCloseSubMenu,top:h,left:m,updatePosition:(b,N)=>{this.setState({subMenuTop:b,subMenuLeft:N})},subMenuParentWidth:T,subMenuParentHeight:S},`sub-${i}`)]})}};let Ee=Ae;u(Ee,"defaultProps",{subMenuParentWidth:0,subMenuParentHeight:0,closeMenu(){},onMenuOpened(){},onMenuClosed(){},options:{},menuStyle:{},"data-testid":void 0});const ut=Ee;class ht extends K.Component{constructor(e){super(e);u(this,"container");u(this,"openMenu");this.handleMenuClose=this.handleMenuClose.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.container=X.createRef(),this.openMenu=X.createRef(),this.state={actions:null,left:0,top:0}}componentDidMount(){var e;(e=this.container.current)!=null&&e.parentElement&&this.container.current.parentElement.addEventListener("contextmenu",this.handleContextMenu)}componentWillUnmount(){var e;(e=this.container.current)!=null&&e.parentElement&&this.container.current.parentElement.removeEventListener("contextmenu",this.handleContextMenu)}handleContextMenu(e){if(!J.isContextActionEvent(e)||!this.container.current||e.metaKey||e.ctrlKey)return;const t=J.getMenuItems(e.contextActions),n=this.container.current.getBoundingClientRect(),i=e.clientY-n.top,r=e.clientX-n.left;if(t.length===0){if(e.target===this.container.current){e.preventDefault(),this.setState({actions:null},()=>{const a=document.elementFromPoint(r,i),o=new MouseEvent("contextmenu",{clientX:e.clientX,clientY:e.clientY,bubbles:!0,cancelable:!0});a==null||a.dispatchEvent(o)});return}return}e.preventDefault(),this.setState({actions:t,top:i,left:r})}handleMenuClose(e){e===this.openMenu.current&&this.setState({actions:null})}render(){let e=null;const{"data-testid":t}=this.props,{actions:n,top:i,left:r}=this.state;return n&&(e=D.jsx(ut,{ref:this.openMenu,actions:n,onMenuClosed:this.handleMenuClose,top:i,left:r,updatePosition:(a,o)=>{this.setState({top:a,left:o})},"data-testid":t})),D.jsx("div",{className:Te("context-menu-root",{active:n}),ref:this.container,children:e})}}const dt=ht;class Fe{static isValid(s){return!0}static isSameFormat(s,e){throw new Error("isSameFormat not implemented")}static makeFormat(s,e,t){return{label:s,formatString:e,type:t}}format(s,e){return""}}u(Fe,"TYPE_GLOBAL","type-global"),u(Fe,"TYPE_CONTEXT_PRESET","type-context-preset"),u(Fe,"TYPE_CONTEXT_CUSTOM","type-context-custom");const I=Fe;class pt extends I{format(s){switch(s){case 1:case!0:return"true";case 0:case!1:return"false";default:return""}}}const mt=pt;class gt extends I{format(s){return String.fromCharCode(s)}}const ft=gt,{dh:Tt}=globalThis,V=Tt,$e=Z.module("DateTimeColumnFormatter"),Y=class extends I{constructor({timeZone:e="",showTimeZone:t=!0,showTSeparator:n=!1,defaultDateTimeFormatString:i=Y.DEFAULT_DATETIME_FORMAT_STRING}={}){super();u(this,"dhTimeZone");u(this,"defaultDateTimeFormatString");u(this,"showTimeZone");u(this,"showTSeparator");u(this,"formatStringMap");const r=e||Y.DEFAULT_TIME_ZONE_ID;try{this.dhTimeZone=V.i18n.TimeZone.getTimeZone(r)}catch{$e.error("Unsupported time zone id",r),this.dhTimeZone=V.i18n.TimeZone.getTimeZone(Y.DEFAULT_TIME_ZONE_ID)}this.defaultDateTimeFormatString=i,this.showTimeZone=t,this.showTSeparator=n,this.formatStringMap=Y.makeFormatStringMap(t,n)}static isValid(e){try{return V.i18n.DateTimeFormat.format(e.formatString,new Date),!0}catch{return!1}}static makeFormat(e,t,n=I.TYPE_CONTEXT_PRESET){return{label:e,formatString:t,type:n}}static isSameFormat(e,t){return e===t||e!==null&&t!==null&&e.type===t.type&&e.formatString===t.formatString}static makeGlobalFormatStringMap(e,t){const n=t?"'T'":" ",i=e?" z":"";return new Map([["yyyy-MM-dd HH:mm:ss",`yyyy-MM-dd${n}HH:mm:ss${i}`],["yyyy-MM-dd HH:mm:ss.SSS",`yyyy-MM-dd${n}HH:mm:ss.SSS${i}`],["yyyy-MM-dd HH:mm:ss.SSSSSSSSS",`yyyy-MM-dd${n}HH:mm:ss.SSSSSSSSS${i}`]])}static getGlobalFormats(e,t){return[...Y.makeGlobalFormatStringMap(e,t).keys()]}static makeFormatStringMap(e,t){const n=t!==void 0&&t?"'T'":" ",i=e!==void 0&&e?" z":"";return new Map([["yyyy-MM-dd",`yyyy-MM-dd${i}`],["MM-dd-yyyy",`MM-dd-yyyy${i}`],["HH:mm:ss",`HH:mm:ss${i}`],["HH:mm:ss.SSS",`HH:mm:ss.SSS${i}`],["HH:mm:ss.SSSSSSSSS",`HH:mm:ss.SSSSSSSSS${i}`],["yyyy-MM-dd HH:mm:ss",`yyyy-MM-dd${n}HH:mm:ss${i}`],["yyyy-MM-dd HH:mm:ss.SSS",`yyyy-MM-dd${n}HH:mm:ss.SSS${i}`],["yyyy-MM-dd HH:mm:ss.SSSSSSSSS",`yyyy-MM-dd${n}HH:mm:ss.SSSSSSSSS${i}`]])}static getFormats(e,t){return[...Y.makeFormatStringMap(e,t).keys()]}getEffectiveFormatString(e){return this.formatStringMap.get(e)??e}format(e,t={}){const n=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultDateTimeFormatString,i=this.getEffectiveFormatString(n);try{return V.i18n.DateTimeFormat.format(i,e,this.dhTimeZone)}catch{$e.error("Invalid format arguments")}return""}};let fe=Y;u(fe,"DEFAULT_DATETIME_FORMAT_STRING","yyyy-MM-dd HH:mm:ss.SSS"),u(fe,"DEFAULT_TIME_ZONE_ID","America/New_York");const St=Z.module("DecimalColumnFormatter"),L=class extends I{constructor({defaultFormatString:e=L.DEFAULT_FORMAT_STRING}={}){super();u(this,"defaultFormatString");this.defaultFormatString=e}static isValid(e){try{return V.i18n.NumberFormat.format(e.formatString,0),!0}catch{return!1}}static makeFormat(e,t,n=I.TYPE_CONTEXT_PRESET,i){return{label:e,type:n,formatString:t,multiplier:i}}static makePresetFormat(e,t="",n){return L.makeFormat(e,t,I.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(e="",t){return L.makeFormat("Custom Format",e,I.TYPE_CONTEXT_CUSTOM,t)}static isSameFormat(e,t){return e===t||e!=null&&t!=null&&e.type===t.type&&e.formatString===t.formatString&&e.multiplier===t.multiplier}format(e,t={}){const n=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultFormatString,i=t.multiplier!=null&&t.multiplier!==0?e*t.multiplier:e;try{return V.i18n.NumberFormat.format(n,i)}catch{St.error("Invalid format arguments")}return""}};let R=L;u(R,"DEFAULT_FORMAT_STRING","###,##0.0000"),u(R,"FORMAT_PERCENT",L.makePresetFormat("Percent","##0.00%")),u(R,"FORMAT_BASIS_POINTS",L.makePresetFormat("Basis Points","###,##0 bp",1e4)),u(R,"FORMAT_MILLIONS",L.makePresetFormat("Millions","###,##0.000 mm",1e-6)),u(R,"FORMAT_SCIENTIFIC_NOTATION",L.makePresetFormat("Scientific Notation","0.0000E0")),u(R,"FORMAT_ROUND",L.makePresetFormat("Round","###,##0")),u(R,"FORMAT_ROUND_TWO_DECIMALS",L.makePresetFormat("0.00","###,##0.00")),u(R,"FORMAT_ROUND_FOUR_DECIMALS",L.makePresetFormat("0.0000","###,##0.0000"));class yt extends I{format(s){return`${s}`}}const Et=yt,Ft=Z.module("IntegerColumnFormatter"),te=class extends I{constructor({defaultFormatString:e=te.DEFAULT_FORMAT_STRING}={}){super();u(this,"defaultFormatString");this.defaultFormatString=e}static isValid(e){try{return V.i18n.NumberFormat.format(e.formatString,0),!0}catch{return!1}}static makeFormat(e,t,n=I.TYPE_CONTEXT_PRESET,i){return{label:e,type:n,formatString:t,multiplier:i}}static makePresetFormat(e,t="",n){return te.makeFormat(e,t,I.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(e="",t){return te.makeFormat("Custom Format",e,I.TYPE_CONTEXT_CUSTOM,t)}static isSameFormat(e,t){return e===t||e!=null&&t!=null&&e.type===t.type&&e.formatString===t.formatString&&e.multiplier===t.multiplier}format(e,t={}){const n=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultFormatString,i=t.multiplier!=null&&t.multiplier!==0?e*t.multiplier:e;try{return V.i18n.NumberFormat.format(n,i)}catch{Ft.error("Invalid format arguments")}return""}};let oe=te;u(oe,"DEFAULT_FORMAT_STRING","###,##0"),u(oe,"FORMAT_MILLIONS",te.makePresetFormat("Millions","###,##0.000 mm",1e-6)),u(oe,"FORMAT_SCIENTIFIC_NOTATION",te.makePresetFormat("Scientific Notation","0.0000E0"));class bt extends I{format(s){return s}}const P=class{static makeDateWrapper(s,e,t,n=0,i=1,r=0,a=0,o=0,l=0){if(!e)throw new Error("No timezone provided");const c=`${t}`.padStart(4,"0"),h=`${n+1}`.padStart(2,"0"),m=`${i}`.padStart(2,"0"),T=`${r}`.padStart(2,"0"),S=`${a}`.padStart(2,"0"),F=`${o}`.padStart(2,"0"),M=`${l}`.padStart(9,"0"),y=`${c}-${h}-${m} ${T}:${S}:${F}.${M}`;return s.i18n.DateTimeFormat.parse(P.FULL_DATE_FORMAT,y,s.i18n.TimeZone.getTimeZone(e))}static getNextNanos(s){const e=parseInt(s,10),t="0".repeat(9-s.length),n=`${e+1}${t}`;return parseInt(n,10)}static getNextDate(s,e,t,n){let{year:i,month:r,date:a,hours:o,minutes:l,seconds:c,nanos:h}=t;if(e.nanos!=null){if(e.nanos.length===9)return null;h=P.getNextNanos(e.nanos),h>999999999&&(c+=1,h=0)}else e.seconds!=null?c+=1:e.minutes!=null?l+=1:e.hours!=null?o+=1:e.date!=null?a+=1:e.month!=null?r+=1:i+=1;const m=new Date(i,r,a,o,l,c);return P.makeDateWrapper(s,n,m.getFullYear(),m.getMonth(),m.getDate(),m.getHours(),m.getMinutes(),m.getSeconds(),h)}static parseMonth(s){const e=parseInt(s,10);if(!Number.isNaN(e))return e>=1&&e<=12?e-1:NaN;const t=s.trim().toLowerCase();if(t.length>=3){for(let n=0;n<P.months.length;n+=1)if(P.months[n].startsWith(t))return n}return NaN}static parseDateValues(s,e,t,n,i,r,a){const o=parseInt(s,10),l=e!=null?this.parseMonth(e):0,c=t!=null?parseInt(t,10):1,h=n!=null?parseInt(n,10):0,m=i!=null?parseInt(i,10):0,T=r!=null?parseInt(r,10):0,S=a!=null?parseInt(a.padEnd(9,"0"),10):0;return Number.isNaN(o)||Number.isNaN(l)||Number.isNaN(c)||Number.isNaN(h)||Number.isNaN(m)||Number.isNaN(T)||Number.isNaN(S)?null:{year:o,month:l,date:c,hours:h,minutes:m,seconds:T,nanos:S}}static parseDateTimeString(s){const t=/\s*(\d{4})([-./]([\da-z]+))?([-./](\d{1,2}))?([tT\s](\d{2})([:](\d{2}))?([:](\d{2}))?([.](\d{1,9}))?)?(.*)/.exec(s);if(t==null)throw new Error(`Unexpected date string: ${s}`);const[,n,,i,,r,,a,,o,,l,,c,h]=t;if(h!=null&&h.length>0)throw new Error(`Unexpected characters after date string '${s}': ${h}`);return{year:n,month:i,date:r,hours:a,minutes:o,seconds:l,nanos:c}}static parseDateRange(s,e,t){const n=e.trim().toLowerCase();if(n.length===0)throw new Error("Cannot parse date range from empty string");if(n==="null")return[null,null];if(n==="today"){const l=new Date(Date.now()),c=P.makeDateWrapper(s,t,l.getFullYear(),l.getMonth(),l.getDate()),h=P.makeDateWrapper(s,t,l.getFullYear(),l.getMonth(),l.getDate()+1);return[c,h]}if(n==="yesterday"){const l=new Date(Date.now()),c=P.makeDateWrapper(s,t,l.getFullYear(),l.getMonth(),l.getDate()-1),h=P.makeDateWrapper(s,t,l.getFullYear(),l.getMonth(),l.getDate());return[c,h]}if(n==="now"){const l=new Date(Date.now());return[s.DateWrapper.ofJsDate(l),null]}const i=P.parseDateTimeString(n);if(i.year==null&&i.month==null&&i.date==null)throw new Error(`Unable to extract year, month, or day ${n}`);const r=P.parseDateValues(i.year,i.month,i.date,i.hours,i.minutes,i.seconds,i.nanos);if(r==null)throw new Error(`Unable to extract date values from ${i}`);const a=P.makeDateWrapper(s,t,r.year,r.month,r.date,r.hours,r.minutes,r.seconds,r.nanos),o=P.getNextDate(s,i,r,t);return[a,o]}static getJsDate(s){return typeof s=="number"?new Date(s):s.asDate()}};let se=P;u(se,"FULL_DATE_FORMAT","yyyy-MM-dd HH:mm:ss.SSSSSSSSS"),u(se,"months",["january","february","march","april","may","june","july","august","september","october","november","december"]);class Se{}u(Se,"not","not"),u(Se,"and","and"),u(Se,"or","or");class d{}u(d,"eq","eq"),u(d,"eqIgnoreCase","eqIgnoreCase"),u(d,"notEq","notEq"),u(d,"notEqIgnoreCase","notEqIgnoreCase"),u(d,"greaterThan","greaterThan"),u(d,"greaterThanOrEqualTo","greaterThanOrEqualTo"),u(d,"lessThan","lessThan"),u(d,"lessThanOrEqualTo","lessThanOrEqualTo"),u(d,"in","in"),u(d,"inIgnoreCase","inIgnoreCase"),u(d,"notIn","notIn"),u(d,"notInIgnoreCase","notInIgnoreCase"),u(d,"isTrue","isTrue"),u(d,"isFalse","isFalse"),u(d,"isNull","isNull"),u(d,"invoke","invoke"),u(d,"contains","contains"),u(d,"notContains","notContains"),u(d,"startsWith","startsWith"),u(d,"endsWith","endsWith"),u(d,"containsAny","containsAny");const _=Z.module("TableUtils"),p=class{constructor(s){u(this,"dh");this.dh=s}static getSortIndex(s,e){var t;for(let n=0;n<s.length;n+=1)if(((t=s[n].column)==null?void 0:t.name)===e)return n;return null}static getSortForColumn(s,e){const t=p.getSortIndex(s,e);return t!=null?s[t]:null}static getFilterText(s){return s?s.toString():null}static getFilterTypes(s){return p.isBooleanType(s)?[d.isTrue,d.isFalse,d.isNull]:p.isCharType(s)||p.isNumberType(s)||p.isDateType(s)?[d.eq,d.notEq,d.greaterThan,d.greaterThanOrEqualTo,d.lessThan,d.lessThanOrEqualTo]:p.isTextType(s)?[d.eq,d.eqIgnoreCase,d.notEq,d.notEqIgnoreCase,d.contains,d.notContains,d.startsWith,d.endsWith]:[]}static getNextSort(s,e,t){if(t<0||t>=s.length)return null;const n=p.getSortForColumn(e,s[t].name);return n===null?s[t].sort().asc():n.direction===p.sortDirection.ascending?n.desc():null}static makeColumnSort(s,e,t,n){if(e<0||e>=s.length||t===p.sortDirection.none)return null;let i=s[e].sort();switch(t){case p.sortDirection.ascending:i=i.asc();break;case p.sortDirection.descending:i=i.desc();break}return n&&(i=i.abs()),i}static toggleSortForColumn(s,e,t,n=!1){if(t<0||t>=e.length)return[];const i=p.getNextSort(e,s,t);return p.setSortForColumn(s,e[t].name,i,n)}static sortColumn(s,e,t,n,i,r){if(t<0||t>=e.length)return[];const a=p.makeColumnSort(e,t,n,i);return p.setSortForColumn(s,e[t].name,a,r)}static setSortForColumn(s,e,t,n=!1){const i=p.getSortIndex(s,e);let r=[];return n&&(r=r.concat(s.filter(({direction:a})=>a!==p.sortDirection.reverse)),i!==null&&r.splice(i,1)),t!==null&&r.push(t),r}static getNormalizedType(s){switch(s){case"boolean":case"java.lang.Boolean":case p.dataType.BOOLEAN:return p.dataType.BOOLEAN;case"char":case"java.lang.Character":case p.dataType.CHAR:return p.dataType.CHAR;case"java.lang.String":case p.dataType.STRING:return p.dataType.STRING;case"io.deephaven.db.tables.utils.DBDateTime":case"io.deephaven.time.DateTime":case"com.illumon.iris.db.tables.utils.DBDateTime":case"java.time.Instant":case"java.time.ZonedDateTime":case p.dataType.DATETIME:return p.dataType.DATETIME;case"double":case"java.lang.Double":case"float":case"java.lang.Float":case"java.math.BigDecimal":case p.dataType.DECIMAL:return p.dataType.DECIMAL;case"int":case"java.lang.Integer":case"long":case"java.lang.Long":case"short":case"java.lang.Short":case"byte":case"java.lang.Byte":case"java.math.BigInteger":case p.dataType.INT:return p.dataType.INT;default:return p.dataType.UNKNOWN}}static isLongType(s){switch(s){case"long":case"java.lang.Long":return!0;default:return!1}}static isDateType(s){switch(s){case"io.deephaven.db.tables.utils.DBDateTime":case"io.deephaven.time.DateTime":case"java.time.Instant":case"java.time.ZonedDateTime":case"com.illumon.iris.db.tables.utils.DBDateTime":return!0;default:return!1}}static isNumberType(s){return p.isIntegerType(s)||p.isDecimalType(s)}static isIntegerType(s){switch(s){case"int":case"java.lang.Integer":case"java.math.BigInteger":case"long":case"java.lang.Long":case"short":case"java.lang.Short":case"byte":case"java.lang.Byte":return!0;default:return!1}}static isDecimalType(s){switch(s){case"double":case"java.lang.Double":case"java.math.BigDecimal":case"float":case"java.lang.Float":return!0;default:return!1}}static isBigDecimalType(s){switch(s){case"java.math.BigDecimal":return!0;default:return!1}}static isBigIntegerType(s){switch(s){case"java.math.BigInteger":return!0;default:return!1}}static isBooleanType(s){switch(s){case"boolean":case"java.lang.Boolean":return!0;default:return!1}}static isCharType(s){switch(s){case"char":case"java.lang.Character":return!0;default:return!1}}static isStringType(s){switch(s){case"java.lang.String":return!0;default:return!1}}static isTextType(s){return this.isStringType(s)||this.isCharType(s)}static getBaseType(s){return s.split("[]")[0]}static isCompatibleType(s,e){return p.getNormalizedType(s)===p.getNormalizedType(e)}static quoteValue(s){return s.length>=2&&(s.charAt(0)==='"'&&s.charAt(s.length-1)==='"'||s.charAt(0)==="'"&&s.charAt(s.length-1)==="'")?s:`"${s}"`}static isRangeOperation(s){switch(s){case"<":case"<=":case"=<":case">":case">=":case"=>":return!0;default:return!1}}static makeRangeFilterWithOperation(s,e,t){switch(e){case"=":return s.eq(t);case"<":return s.lessThan(t);case"<=":case"=<":return s.lessThanOrEqualTo(t);case">":return s.greaterThan(t);case">=":case"=>":return s.greaterThanOrEqualTo(t);case"!=":case"!":return s.notEq(t);default:return null}}static makeCancelableTablePromise(s){return xe.makeCancelable(s,e=>{e.close()})}static makeCancelableTableEventPromise(s,e,t=0,n=null){let i,r,a=!0;const o=new Promise((l,c)=>{r=setTimeout(()=>{i(),a=!1,c(new Be(`Event "${e}" timed out.`))},t),i=s.addEventListener(e,h=>{if(n!=null&&!n(h)){_.debug2("Event triggered, but matcher returned false.");return}_.debug2("Event triggered, resolving."),i(),clearTimeout(r),a=!1,l(h)})});return o.cancel=()=>{if(a){_.debug2("Pending promise cleanup."),i(),clearTimeout(r),a=!1;return}_.debug2("Ignoring non-pending promise cancel.")},o}static removeCommas(s){return s.replace(/[\s|,]/g,"")}static makeBooleanValue(s,e=!1){if(s===""&&e)return null;switch(s==null?void 0:s.toLowerCase()){case"null":return null;case"0":case"f":case"fa":case"fal":case"fals":case"false":case"n":case"no":return!1;case"1":case"t":case"tr":case"tru":case"true":case"y":case"ye":case"yes":return!0;default:throw new Error(`Invalid boolean '${s}'`)}}static makeNumberValue(s){if(s==="null"||s==="")return null;const e=s.toLowerCase().trim();if(e==="∞"||e==="infinity"||e==="inf")return Number.POSITIVE_INFINITY;if(e==="-∞"||e==="-infinity"||e==="-inf")return Number.NEGATIVE_INFINITY;const t=p.removeCommas(e);if(p.NUMBER_REGEX.test(t))return parseFloat(t);throw new Error(`Invalid number '${s}'`)}static getFilterOperatorString(s){switch(s){case d.eq:return"=";case d.notEq:return"!=";case d.greaterThan:return">";case d.greaterThanOrEqualTo:return">=";case d.lessThan:return"<";case d.lessThanOrEqualTo:return"<=";case d.contains:return"~";case d.notContains:return"!~";default:throw new Error(`Unexpected filter type ${s}`)}}static isTreeTable(s){return s!=null&&s.expand!==void 0&&s.collapse!==void 0}static sortColumns(s,e=!0){return[...s].sort((t,n)=>{const i=t.name.toUpperCase(),r=n.name.toUpperCase();return ct.sort(i,r,e)})}makeQuickFilter(s,e,t){const n=e.split("||");let i=null;for(let r=0;r<n.length;r+=1){const o=n[r].split("&&");let l=null;for(let c=0;c<o.length;c+=1){const h=o[c].trim();if(h.length>0){const m=this.makeQuickFilterFromComponent(s,h,t);if(m)l?l=l.and(m):l=m;else throw new Error(`Unable to parse quick filter from text ${e}`)}}i&&l?i=i.or(l):i=l}return i}makeQuickFilterFromComponent(s,e,t){const{type:n}=s;return p.isNumberType(n)?this.makeQuickNumberFilter(s,e):p.isBooleanType(n)?this.makeQuickBooleanFilter(s,e):t!=null&&p.isDateType(n)?this.makeQuickDateFilter(s,e,t):p.isCharType(n)?this.makeQuickCharFilter(s,e):this.makeQuickTextFilter(s,e)}makeQuickNumberFilter(s,e){const t=s.filter(),{dh:n}=this;let i=null;const a=/\s*(>=|<=|=>|=<|>|<|!=|=|!)?(\s*-\s*)?(\s*\d*(?:,\d{3})*(?:\.\d*)?\s*)?(null|nan|infinity|inf|\u221E)?(.*)/i.exec(e);let o=null,l=null,c=null,h=null,m=null;if(a!==null&&a.length>3&&([,o,l,c,h,m]=a),m!=null&&m.trim().length>0)return null;if(o==null&&(o="="),h!=null){if(!(o==="="||o==="!"||o==="!="))return null;switch(h=h.trim().toLowerCase(),h){case"null":i=t.isNull();break;case"nan":i=n.FilterCondition.invoke("isNaN",t);break;case"infinity":case"inf":case"∞":l!=null?i=n.FilterCondition.invoke("isInf",t).and(t.lessThan(n.FilterValue.ofNumber(0))):i=n.FilterCondition.invoke("isInf",t).and(t.greaterThan(n.FilterValue.ofNumber(0)));break}return i!==null&&(o==="!"||o==="!=")&&(i=i.not()),i}if(c==null)return null;if(c=p.removeCommas(c),p.isLongType(s.type))try{c=n.FilterValue.ofNumber(n.LongWrapper.ofString(`${l!=null?"-":""}${c}`))}catch(T){return _.warn("Unable to create long filter",T),null}else{if(c=parseFloat(c),c==null||Number.isNaN(c))return null;c=n.FilterValue.ofNumber(l!=null?0-c:c)}return i=s.filter(),p.makeRangeFilterWithOperation(i,o,c)}makeQuickTextFilter(s,e){const{dh:t}=this,n=`${e}`.trim(),r=/^(!~|!=|~|=|!)?(.*)/.exec(n);let a=null,o=null;if(r!==null&&r.length>2&&([,a,o]=r,o!=null&&(o=o.trim())),o==null||o.length===0)return null;a==null&&(a="=");const l=s.filter();if(o.toLowerCase()==="null")switch(a){case"=":return l.isNull();case"!=":case"!":return l.isNull().not()}let c=null,h=null;switch(o.startsWith("*")?(c="*",o=o.substring(1)):o.endsWith("*")&&!o.endsWith("\\*")&&(h="*",o=o.substring(0,o.length-1)),o=o.replace("\\",""),a){case"~":return l.isNull().not().and(l.invoke("matches",t.FilterValue.ofString(`(?s)(?i).*\\Q${o}\\E.*`)));case"!~":return l.isNull().or(l.invoke("matches",t.FilterValue.ofString(`(?s)(?i).*\\Q${o}\\E.*`)).not());case"!=":return c==="*"?l.isNull().or(l.invoke("matches",t.FilterValue.ofString(`(?s)(?i).*\\Q${o}\\E$`)).not()):h==="*"?l.isNull().or(l.invoke("matches",t.FilterValue.ofString(`(?s)(?i)^\\Q${o}\\E.*`)).not()):l.notEqIgnoreCase(t.FilterValue.ofString(o.toLowerCase()));case"=":return c==="*"?l.isNull().not().and(l.invoke("matches",t.FilterValue.ofString(`(?s)(?i).*\\Q${o}\\E$`))):h==="*"?l.isNull().not().and(l.invoke("matches",t.FilterValue.ofString(`(?s)(?i)^\\Q${o}\\E.*`))):l.eqIgnoreCase(t.FilterValue.ofString(o.toLowerCase()))}return null}makeQuickBooleanFilter(s,e){const n=/^(!=|=|!)?(.*)/.exec(`${e}`.trim());if(n===null)return null;const[,i,r]=n,a=i==="!"||i==="!=",o=r.trim().toLowerCase();let l=s.filter();try{const c=p.makeBooleanValue(o);return c!=null&&c?l=l.isTrue():c===null?l=l.isNull():l=l.isFalse(),a?l.not():l}catch{return null}}makeQuickDateFilter(s,e,t){const n=e.trim(),r=/\s*(>=|<=|=>|=<|>|<|!=|!|=)?(.*)/.exec(n);if(r==null||r.length<=2)throw new Error(`Unable to parse date filter: ${e}`);let a=null,o=null;[,a,o]=r;let l=d.eq;switch(a){case"<":l=d.lessThan;break;case"<=":case"=<":l=d.lessThanOrEqualTo;break;case">":l=d.greaterThan;break;case">=":case"=>":l=d.greaterThanOrEqualTo;break;case"!=":case"!":l=d.notEq;break;case"=":case"==":default:l=d.eq;break}return this.makeQuickDateFilterWithOperation(s,o,l,t)}makeQuickDateFilterWithOperation(s,e,t,n){const{dh:i}=this,[r,a]=se.parseDateRange(i,e,n),o=r!=null?i.FilterValue.ofNumber(r):null,l=a!=null?i.FilterValue.ofNumber(a):null,c=s.filter();if(o==null)return t===d.notEq?c.isNull().not():c.isNull();switch(t){case d.eq:{if(l!=null){const h=c.greaterThanOrEqualTo(o),m=c.lessThan(l);return h.and(m)}return c.eq(o)}case d.lessThan:return c.lessThan(o);case d.lessThanOrEqualTo:return l!=null?c.lessThan(l):c.lessThanOrEqualTo(o);case d.greaterThan:return l!=null?c.greaterThanOrEqualTo(l):c.greaterThan(o);case d.greaterThanOrEqualTo:return c.greaterThanOrEqualTo(o);case d.notEq:{if(l!=null){const h=c.lessThan(o),m=c.greaterThanOrEqualTo(l);return h.or(m)}return c.notEq(o)}default:throw new Error(`Invalid operator: ${t}`)}}makeQuickCharFilter(s,e){const{dh:t}=this,n=`${e}`.trim(),r=/^(>=|<=|=>|=<|>|<|!=|=|!)?(null|"."|'.'|.)?(.*)/.exec(n);let a=null,o=null,l=null;if(r!==null&&r.length>3&&([,a,o,l]=r),l!=null&&l.trim().length>0||o==null||o.length===0)return null;a==null&&(a="=");const c=s.filter();if(o.toLowerCase()==="null")switch(a){case"=":return c.isNull();case"!=":case"!":return c.isNull().not();default:return null}const h=t.FilterValue.ofString(p.isRangeOperation(a)?p.quoteValue(o):o);return p.makeRangeFilterWithOperation(c,a,h)}makeAdvancedFilter(s,e,t){const{filterItems:n,filterOperators:i,invertSelection:r,selectedValues:a}=e;let o=null;for(let c=0;c<n.length;c+=1){const h=n[c],{selectedType:m,value:T}=h;if(m!=null&&m.length>0&&T!=null&&T.length>0)try{const S=this.makeAdvancedValueFilter(s,m,T,t);if(S!=null){if(c===0)o=S;else if(o!==null&&c-1<i.length){const F=i[c-1];if(F===Se.and)o=o.and(S);else if(F===Se.or)o=o.or(S);else{_.error("Unexpected filter operator",F,S),o=null;break}}}else _.debug2("Empty filter ignored for",m,T)}catch(S){_.error("Unable to create filter",S),o=null;break}}const l=this.makeSelectValueFilter(s,a,r);return l!=null&&(o!=null?o=o.and(l):o=l),o}makeAdvancedValueFilter(s,e,t,n){if(p.isDateType(s.type))return this.makeQuickDateFilterWithOperation(s,t,e,n);if(p.isNumberType(s.type)||p.isCharType(s.type))return this.makeQuickFilter(s,`${p.getFilterOperatorString(e)}${t}`);const i=this.makeFilterValue(s.type,t),r=s.filter();switch(e){case d.eq:return r.eq(i);case d.eqIgnoreCase:return r.eqIgnoreCase(i);case d.notEq:return r.notEq(i);case d.notEqIgnoreCase:return r.notEqIgnoreCase(i);case d.greaterThan:return r.greaterThan(i);case d.greaterThanOrEqualTo:return r.greaterThanOrEqualTo(i);case d.lessThan:return r.lessThan(i);case d.lessThanOrEqualTo:return r.lessThanOrEqualTo(i);case d.isTrue:return r.isTrue();case d.isFalse:return r.isFalse();case d.isNull:return r.isNull();case d.contains:return r.isNull().not().and(r.invoke("matches",dh.FilterValue.ofString(`(?s)(?i).*\\Q${t}\\E.*`)));case d.notContains:return r.isNull().or(r.invoke("matches",dh.FilterValue.ofString(`(?s)(?i).*\\Q${t}\\E.*`)).not());case d.startsWith:return r.isNull().not().and(r.invoke("matches",dh.FilterValue.ofString(`(?s)(?i)^\\Q${t}\\E.*`)));case d.endsWith:return r.isNull().not().and(r.invoke("matches",dh.FilterValue.ofString(`(?s)(?i).*\\Q${t}\\E$`)));case d.in:case d.inIgnoreCase:case d.notIn:case d.notInIgnoreCase:case d.invoke:default:throw new Error(`Unexpected filter operation: ${e}`)}}makeFilterValue(s,e){const{dh:t}=this,n=p.getBaseType(s);return p.isTextType(n)?t.FilterValue.ofString(e):p.isLongType(n)?t.FilterValue.ofNumber(t.LongWrapper.ofString(p.removeCommas(e))):t.FilterValue.ofNumber(p.removeCommas(e))}makeFilterRawValue(s,e){const{dh:t}=this;return p.isTextType(s)?t.FilterValue.ofString(e):p.isBooleanType(s)?t.FilterValue.ofBoolean(e):t.FilterValue.ofNumber(e)}makeValue(s,e,t){const{dh:n}=this;if(e==="null")return null;if(p.isTextType(s))return e;if(p.isLongType(s))return n.LongWrapper.ofString(p.removeCommas(e));if(p.isBooleanType(s))return p.makeBooleanValue(e,!0);if(p.isDateType(s)){const[i]=se.parseDateRange(n,e,t);return i}return p.isNumberType(s)?p.makeNumberValue(e):(_.error("Unexpected column type",s),null)}makeSelectValueFilter(s,e,t){const{dh:n}=this;if(e.length===0){if(t)return null;let a=null;p.isTextType(s.type)?a=n.FilterValue.ofString("a"):p.isBooleanType(s.type)?a=n.FilterValue.ofBoolean(!0):p.isDateType(s.type)?a=n.FilterValue.ofNumber(n.DateWrapper.ofJsDate(new Date)):a=n.FilterValue.ofNumber(0);const o=s.filter().eq(a),l=s.filter().notEq(a);return o.and(l)}const i=[];let r=!1;for(let a=0;a<e.length;a+=1){const o=e[a];o==null?r=!0:p.isTextType(s.type)?i.push(n.FilterValue.ofString(typeof o=="number"?String.fromCharCode(o):o)):p.isBooleanType(s.type)?i.push(n.FilterValue.ofBoolean(Boolean(o))):i.push(n.FilterValue.ofNumber(o))}return r?i.length>0?t?s.filter().isNull().not().and(s.filter().notIn(i)):s.filter().isNull().or(s.filter().in(i)):t?s.filter().isNull().not():s.filter().isNull():t?s.filter().notIn(i):s.filter().in(i)}};let W=p;u(W,"dataType",{BOOLEAN:"boolean",CHAR:"char",DATETIME:"datetime",DECIMAL:"decimal",INT:"int",STRING:"string",UNKNOWN:"unknown"}),u(W,"sortDirection",{ascending:"ASC",descending:"DESC",reverse:"REVERSE",none:null}),u(W,"REVERSE_TYPE",Object.freeze({NONE:"none",PRE_SORT:"pre-sort",POST_SORT:"post-sort"})),u(W,"NUMBER_REGEX",/^-?\d+(\.\d+)?$/);const U=W;class Pe{constructor(s=[],e,t,n,i=!1){u(this,"defaultColumnFormatter");u(this,"typeFormatterMap");u(this,"columnFormatMap");u(this,"truncateNumbersWithPound");this.defaultColumnFormatter=new Et,this.typeFormatterMap=new Map([[U.dataType.BOOLEAN,new mt],[U.dataType.CHAR,new ft],[U.dataType.DATETIME,new fe(e)],[U.dataType.DECIMAL,new R(t)],[U.dataType.INT,new oe(n)],[U.dataType.STRING,new bt]]),this.columnFormatMap=Pe.makeColumnFormatMap(s),this.truncateNumbersWithPound=i}static makeColumnFormatMap(s){return s==null?new Map:s.reduce((e,t)=>{const n=U.getNormalizedType(t.columnType);if(n===null)return e;e.has(n)||e.set(n,new Map);const i=e.get(n);return i==null||i.set(t.columnName,t.format),e},new Map)}static makeColumnFormattingRule(s,e,t){return{columnType:s,columnName:e,format:t}}getColumnFormatMapForType(s,e=!1){const t=U.getNormalizedType(s);if(t!==null)return e&&!this.columnFormatMap.has(t)&&this.columnFormatMap.set(t,new Map),this.columnFormatMap.get(t)}getColumnFormat(s,e){const t=this.getColumnFormatMapForType(s);return(t==null?void 0:t.get(e))??null}getColumnTypeFormatter(s){const e=U.getNormalizedType(s);let t=this.defaultColumnFormatter;return e&&(t=this.typeFormatterMap.get(e)??t),t}getFormattedString(s,e,t="",n){if(s==null)return"";const i=this.getColumnTypeFormatter(e),r=n||this.getColumnFormat(e,t);return i.format(s,r??void 0)}get timeZone(){var e;const s=this.typeFormatterMap.get(U.dataType.DATETIME);return(e=s==null?void 0:s.dhTimeZone)==null?void 0:e.id}}function Dt(g){if(g&&g.formatter){const{formatter:s}=g;return s}}function Mt(g){return{timeZone:g==null?void 0:g.timeZone,defaultDateTimeFormatString:g==null?void 0:g.defaultDateTimeFormat,showTimeZone:g==null?void 0:g.showTimeZone,showTSeparator:g==null?void 0:g.showTSeparator}}function At(g,s,e){const t=g.getColumnFormat(e,s);return t!=null&&(t.type===I.TYPE_CONTEXT_PRESET||t.type===I.TYPE_CONTEXT_CUSTOM)}const Ie={getColumnFormats:Dt,getDateTimeFormatterOptions:Mt,isCustomColumnFormatDefined:At};Me.register([Je,et,tt,st,nt,it]);const Nt=typeof we=="function"?we(Me):we.default(Me),j=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(j.EVENT_UPDATED,{detail:s}))}fireDisconnect(){this.fireEvent(new CustomEvent(j.EVENT_DISCONNECT))}fireReconnect(){this.fireEvent(new CustomEvent(j.EVENT_RECONNECT))}fireDownsampleStart(s){this.fireEvent(new CustomEvent(j.EVENT_DOWNSAMPLESTARTED,{detail:s}))}fireDownsampleFinish(s){this.fireEvent(new CustomEvent(j.EVENT_DOWNSAMPLEFINISHED,{detail:s}))}fireDownsampleFail(s){this.fireEvent(new CustomEvent(j.EVENT_DOWNSAMPLEFAILED,{detail:s}))}fireDownsampleNeeded(s){this.fireEvent(new CustomEvent(j.EVENT_DOWNSAMPLENEEDED,{detail:s}))}fireLoadFinished(){this.fireEvent(new CustomEvent(j.EVENT_LOADFINISHED))}};let $=j;u($,"EVENT_UPDATED","ChartModel.EVENT_UPDATED"),u($,"EVENT_DISCONNECT","ChartModel.EVENT_DISCONNECT"),u($,"EVENT_RECONNECT","ChartModel.EVENT_RECONNECT"),u($,"EVENT_DOWNSAMPLESTARTED","ChartModel.EVENT_DOWNSAMPLESTARTED"),u($,"EVENT_DOWNSAMPLEFINISHED","ChartModel.EVENT_DOWNSAMPLEFINISHED"),u($,"EVENT_DOWNSAMPLEFAILED","ChartModel.EVENT_DOWNSAMPLEFAILED"),u($,"EVENT_DOWNSAMPLENEEDED","ChartModel.EVENT_DOWNSAMPLENEEDED"),u($,"EVENT_LOADFINISHED","ChartModel.EVENT_LOADFINISHED");const z=$,wt="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",It="#403e41",xt="#5b5a5c",Ct="#c0bfbf",Pt="#4878ea",vt="rgba(91, 90, 92, 0.7)",w={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:wt,gridcolor:It,linecolor:xt,zerolinecolor:Ct,activecolor:Pt,rangebgcolor:vt,"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"},B=Object.freeze({paper_bgcolor:w["paper-bgcolor"],plot_bgcolor:w["plot-bgcolor"],title_color:w["title-color"],colorway:w.colorway,gridcolor:w.gridcolor,linecolor:w.linecolor,zerolinecolor:w.zerolinecolor,activecolor:w.activecolor,rangebgcolor:w.rangebgcolor,area_color:w["area-color"],trend_color:w["trend-color"],line_color:w["line-color"],error_band_line_color:w["error-band-line-color"],error_band_fill_color:w["error-band-fill-color"],ohlc_increasing:w["ohlc-increasing"],ohlc_decreasing:w["ohlc-decreasing"]}),ge=Z.module("ChartUtils"),Ve="io.deephaven.time.DateTime",Ot=36e5,Lt=1e6;function kt(g){return g.asDate!==void 0}function Rt(g){return g.asNumber!==void 0}function He(g){return g.dhTimeZone!==void 0}function $t(g){return g!=null&&g.range!=null&&(g.autorange===!1||g.autorange===void 0)}const f=class{constructor(s){u(this,"dh");u(this,"days");this.dh=s,this.days=Object.freeze(s.calendar.DayOfWeek.values())}static getPlotlyErrorBars(s,e,t){const n=t.map((r,a)=>r-s[a]),i=e.map((r,a)=>s[a]-r);return{type:"data",symmetric:!1,array:n,arrayminus:i}}static getPlotlyDateFormat(s,e,t,n){const i=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 r;const a=e==null?void 0:e.getColumnTypeFormatter(t);return a!=null&&He(a)&&a.dhTimeZone!=null&&a.showTimeZone&&(r=s.i18n.DateTimeFormat.format(" z",new Date,a.dhTimeZone)),{tickformat:i,ticksuffix:r,automargin:!0}}static convertNumberPrefix(s){return s.replace(/\u00A4\u00A4/g,"USD").replace(/\u00A4/g,"$")}static getPlotlyNumberFormat(s,e,t){if(!t)return null;const i=t.split(";")[0].match(/^([^#,0.]*)([#,]*)([0,]*)(\.?)(0*)(#*)(E?0*)(%?)(.*)/);me(i);const[,r,a,o,,l,c,h,m,T]=i,S=o.replace(",","").length,M=a.indexOf(",")>=0||o.indexOf(",")>=0?",":"",y=h!=null&&h!==""?"e":"f",E=m!==""?m:y,b=l.length+c.length,v=`0${S}${M}.${b}${E}`,H=f.convertNumberPrefix(r),k=f.convertNumberPrefix(T);return{tickformat:v,tickprefix:H,ticksuffix:k,automargin:!0}}static getPlotlyAxisFormat(s,e,t=null){const{axis:n,columnType:i}=e,{formatPattern:r}=n;let a=null;return W.isDateType(i)?(a=f.getPlotlyDateFormat(s,t,i,r),a=f.addTickSpacing(a,n,!0)):W.isNumberType(i)&&(a=f.getPlotlyNumberFormat(t,i,r),a=f.addTickSpacing(a,n,!1)),n.formatType===s.plot.AxisFormatType.CATEGORY&&(a?a.type="category":a={type:"category",tickformat:void 0,ticksuffix:void 0}),a}static addTickSpacing(s,e,t){const{gapBetweenMajorTicks:n}=e;if(n>0){const i=s||{};let r=n;return t&&(r=n/Lt),e.log&&(r=Math.log(r)),i.tickmode="linear",i.dtick=r,i}return s}static getSourceForAxis(s,e){for(let t=0;t<s.series.length;t+=1){const n=s.series[t];for(let i=0;i<n.sources.length;i+=1){const r=n.sources[i];if(r.axis===e)return r}}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,n,i=f.ORIENTATION.VERTICAL){return{type:s,mode:e,name:t,orientation:i,showlegend:n??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 n=0;n<t.length;n+=1){const i=t[n];for(let r=0;r<i.series.length;r+=1)if(e===i.series[r])return i}return null}static getLayoutRanges(s){const e={},t=Object.keys(s).filter(n=>n.indexOf("axis")>=0);for(let n=0;n<t.length;n+=1){const i=t[n],r=s[i];$t(r)&&(e[i]=[...r.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,n)=>{const i=n[e],r=t.get(i)??[];return r.push(n),t.set(i,r),t},new Map)}static getColorwayFromTheme(s=B){let e=[];return s.colorway&&(Array.isArray(s.colorway)?e=s.colorway:typeof s.colorway=="string"?e=s.colorway.split(" "):ge.warn(`Unable to handle colorway property: ${s.colorway}`)),e}static titleFromSettings(s){const{series:e,xAxis:t,title:n=`${(e??[]).join(", ")} by ${t}`}=s;return n}getAxisFormats(s,e){const{dh:t}=this,n=new Map,i={tickformat:null,ticksuffix:null},r=f.getAllAxes(s),a=f.groupArray(r,"type"),{charts:o}=s;for(let l=0;l<o.length;l+=1){const c=o[l];for(let h=0;h<c.series.length;h+=1){const m=c.series[h],{sources:T}=m,S=T.filter(F=>F.axis);for(let F=0;F<S.length;F+=1){const M=S[F],{axis:y}=M,{type:E}=y,b=a.get(E);me(b);const N=b.indexOf(y),v=this.getAxisPropertyName(E);if(v!=null){const H=f.getAxisLayoutProperty(v,N);if(n.has(H))ge.debug(`${H} already added.`);else{ge.debug(`Adding ${H} to axisFormats.`);const k=f.getPlotlyAxisFormat(t,M,e);if(k===null)n.set(H,i);else{n.set(H,k);const{businessCalendar:q}=y;if(q!=null){const O=[],{businessPeriods:Ne,businessDays:ne,holidays:ie,timeZone:ue}=q,he=e==null?void 0:e.getColumnTypeFormatter(Ve);let re;He(he)&&(re=he.dhTimeZone);const de=re?(ue.standardOffset-re.standardOffset)/60:0;ie.length>0&&O.push(...this.createRangeBreakValuesFromHolidays(ie,ue,re)),Ne.forEach(Q=>O.push({pattern:"hour",bounds:[f.periodToDecimal(Q.close)+de,f.periodToDecimal(Q.open)+de]})),ne.length<this.days.length&&this.createBoundsFromDays(ne).forEach(Q=>O.push({pattern:"day of week",bounds:Q})),k.rangebreaks=O}if(n.size===c.axes.length)return n}}}}}}return n}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:n}=this,i=new Set;switch(s){case n.plot.SeriesPlotStyle.SCATTER:(e??!1)&&i.add(f.MODE_LINES),(t??!0)&&i.add(f.MODE_MARKERS);break;case n.plot.SeriesPlotStyle.LINE:(e??!0)&&i.add(f.MODE_LINES),(t??!1)&&i.add(f.MODE_MARKERS);break}return i.size>0?[...i].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 n,i;const{dh:e}=this,{sources:t}=s;return t.length===2&&((i=(n=t[0])==null?void 0:n.axis)==null?void 0:i.type)===e.plot.AxisType.Y?f.ORIENTATION.HORIZONTAL:f.ORIENTATION.VERTICAL}makeSeriesDataFromSeries(s,e,t,n=null,i=B){const{name:r,isLinesVisible:a,isShapesVisible:o,plotStyle:l,lineColor:c,shapeColor:h,sources:m,shape:T,shapeSize:S}=s,F=m.some(N=>{var v;return(v=N.axis)==null?void 0:v.businessCalendar}),M=this.getChartType(l,F),y=this.getPlotlyChartMode(l,a??void 0,o??void 0),E=this.getPlotlySeriesOrientation(s),b=f.makeSeriesData(M,y,r,n,E);return this.addSourcesToSeriesData(b,l,m,e),this.addStylingToSeriesData(b,l,i,c,h,T,S,t),b}addSourcesToSeriesData(s,e,t,n){const i=s;for(let r=0;r<t.length;r+=1){const a=t[r],{axis:o,type:l}=a,c=this.getPlotlyProperty(e,l);je(i,c,[]);const h=o!=null?this.getAxisPropertyName(o.type):null;if(h!=null){const m=n.get(o.type);if(m){const T=m.indexOf(o),S=T>0?`${T+1}`:"";i[`${h}axis`]=`${h}${S}`}}}}addStylingToSeriesData(s,e,t=B,n=null,i=null,r=null,a=null,o=null){const{dh:l}=this,c=s;if(c.marker={line:{}},c.line={width:1},e===l.plot.SeriesPlotStyle.AREA?c.fill="tozeroy":e===l.plot.SeriesPlotStyle.STACKED_AREA?c.stackgroup="stack":e===l.plot.SeriesPlotStyle.STEP?c.line.shape="hv":e===l.plot.SeriesPlotStyle.HISTOGRAM?(c.width=[],c.marker.line!==void 0&&Object.assign(c.marker.line,{color:t.paper_bgcolor,width:1})):e===l.plot.SeriesPlotStyle.OHLC?(c.increasing={line:{color:t.ohlc_increasing}},c.decreasing={line:{color:t.ohlc_decreasing}}):e===l.plot.SeriesPlotStyle.PIE?(c.textinfo="label+percent",c.outsidetextfont={color:t.title_color}):e===l.plot.SeriesPlotStyle.TREEMAP&&(c.hoverinfo="text",c.textinfo="label+text",c.tiling={packing:"squarify",pad:0},c.textposition="middle center",c.outsidetextfont={color:t.title_color}),n!=null&&(e===l.plot.SeriesPlotStyle.BAR?c.marker.color=n:c.line.color=n),i!=null&&(c.marker.color=i),r!=null&&r.length>0)try{c.marker.symbol=f.getMarkerSymbol(r)}catch(h){ge.warn("Unable to handle shape",r,":",h)}a!=null&&(c.marker.size=a*f.DEFAULT_MARKER_SIZE),o!=null&&e!==l.plot.SeriesPlotStyle.PIE&&(c.visible=o)}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,n=0,i=0,r=B){const a=s,o=f.getAllAxes(e);for(let l=0;l<e.charts.length;l+=1){const c=e.charts[l],h=t==null?void 0:t(c),m=this.getChartBounds(e,c,n,i);this.updateLayoutAxes(a,c.axes,o,n,i,m,h,r)}this.removeStaleAxes(a,o)}getChartBounds(s,e,t,n){const{dh:i}=this,{cols:r,rows:a}=s,{column:o,colspan:l,row:c,rowspan:h}=e,m=o+l,T=c+h,S=1/r,F=1/a,M=f.AXIS_SIZE_PX/t,y=f.AXIS_SIZE_PX/n,E={bottom:(a-T)*F+(T<a?y/2:0),top:(a-c)*F-(c>0?y/2:0),left:o*S+(o>0?M/2:0),right:m*S-(m<r?M/2:0)};return(f.groupArray(e.axes,"position").get(i.plot.AxisPosition.RIGHT)??[]).length>0&&(t>0?E.right-=(E.right-E.left)*Math.max(0,Math.min(f.LEGEND_WIDTH_PX/t,f.MAX_LEGEND_SIZE)):E.right-=(E.right-E.left)*f.DEFAULT_AXIS_SIZE),E}updateLayoutAxes(s,e,t,n=0,i=0,r={left:0,top:0,right:1,bottom:1},a,o=B){const{dh:l}=this,c=n>0?Math.max(f.MIN_AXIS_SIZE,Math.min(f.AXIS_SIZE_PX/i,f.MAX_AXIS_SIZE)):f.DEFAULT_AXIS_SIZE,h=i>0?Math.max(f.MIN_AXIS_SIZE,Math.min(f.AXIS_SIZE_PX/n,f.MAX_AXIS_SIZE)):f.DEFAULT_AXIS_SIZE,m=s,T=f.groupArray(e,"position"),S=f.groupArray(e,"type"),F=[...S.keys()],M=f.groupArray(t,"type");for(let y=0;y<F.length;y+=1){const E=F[y],b=this.getAxisPropertyName(E);if(b!=null){const N=S.get(E),v=M.get(E),k=E===l.plot.AxisType.Y?i:n;me(N),me(v);for(let q=0;q<N.length;q+=1){const O=N[q],Ne=v.indexOf(O),ne=f.getAxisLayoutProperty(b,Ne);m[ne]==null&&(m[ne]=this.makeLayoutAxis(E,o));const ie=m[ne];if(ie!=null){this.updateLayoutAxis(ie,O,q,T,c,h,r);const{range:ue,autorange:he}=ie;if(a!=null&&ue!==void 0&&(he===void 0||he===!1)){const re=a(O),[de,Q]=re(ue);ge.debug("Setting downsample range",k,de,Q),O.range(k,de,Q)}else O.range(k)}}}}}removeStaleAxes(s,e){const t=s,n=f.groupArray(e,"type"),i=[...n.keys()];for(let r=0;r<i.length;r+=1){const a=i[r],o=n.get(a);me(o);let l=o.length;const c=this.getAxisPropertyName(a);if(c!=null){let h=f.getAxisLayoutProperty(c,l);for(;t[h]!=null;)delete t[h],l+=1,h=f.getAxisLayoutProperty(c,l)}}}updateLayoutAxis(s,e,t,n,i,r,a){const{dh:o}=this,c=e.type===o.plot.AxisType.Y?r:i,h=s,m=e.label??"";if(h.title!==void 0&&typeof h.title!="string"?h.title.text=m:h.title={text:m},e.log&&(h.type="log"),h.side=this.getAxisSide(e.position),t>0){h.overlaying=this.getAxisPropertyName(e.type)??void 0;const T=n.get(e.position)??[],S=T.indexOf(e);S>0&&(h.anchor="free",e.position===o.plot.AxisPosition.RIGHT?h.position=a.right+(S-T.length+1)*c:e.position===o.plot.AxisPosition.TOP?h.position=a.top+(S-T.length+1)*c:e.position===o.plot.AxisPosition.BOTTOM?h.position=a.bottom+(T.length-S+1)*c:e.position===o.plot.AxisPosition.LEFT&&(h.position=a.left+(T.length-S+1)*c))}else if(e.type===o.plot.AxisType.X){const T=n.get(o.plot.AxisPosition.LEFT)||[],S=n.get(o.plot.AxisPosition.RIGHT)||[],F=Math.max(a.left,a.left+(T.length-1)*r),M=Math.min(a.right-(S.length-1)*r,a.right);h.domain=[F,M]}else if(e.type===o.plot.AxisType.Y){const T=n.get(o.plot.AxisPosition.BOTTOM)||[],S=n.get(o.plot.AxisPosition.TOP)||[],F=Math.max(a.bottom,a.bottom+(T.length-1)*i),M=Math.min(a.top-(S.length-1)*i,a.top);h.domain=[F,M]}}createBoundsFromDays(s){const e=s.map(r=>this.days.indexOf(r)),t=this.days.filter(r=>!s.includes(r)).map(r=>this.days.indexOf(r)),n=new Set;t.forEach(r=>{for(let a=r+1;a<r+this.days.length;a+=1){const o=a%this.days.length;if(e.includes(o)){n.add(o);break}}});const i=[];return n.forEach(r=>{for(let a=r-1;a>r-this.days.length;a-=1){const o=a<0?a+this.days.length:a;if(e.includes(o)){const l=(o+1)%7;i.push([l,r]);break}}}),i}createRangeBreakValuesFromHolidays(s,e,t){const n=[],i=[];return s.forEach(r=>{r.businessPeriods.length>0?i.push(...this.createPartialHoliday(r,e,t)):n.push(this.createFullHoliday(r,e,t))}),[{values:n},...i]}createFullHoliday(s,e,t){return this.adjustDateForTimeZone(`${s.date.toString()} 00:00:00.000000`,e,t)}createPartialHoliday(s,e,t){const n=s.date.toString(),i=["00:00"];s.businessPeriods.forEach(a=>{i.push(a.open),i.push(a.close)}),i.push("24:00");const r=[];for(let a=0;a<i.length;a+=2){const o=i[a],l=i[a+1];if(o!==l){const c=[this.adjustDateForTimeZone(`${n} ${o}:00.000000`,e,t)],h=Ot*(f.periodToDecimal(l)-f.periodToDecimal(o));r.push({values:c,dvalue:h})}}return r}adjustDateForTimeZone(s,e,t){return t&&t.standardOffset!==e.standardOffset?this.unwrapValue(this.wrapValue(s,Ve,e),t):s}makeFigureSettings(s,e){const{dh:t}=this,{series:n,xAxis:i,type:r}=s,a=f.titleFromSettings(s),o={formatType:`${t.plot.AxisFormatType.NUMBER}`,type:`${t.plot.AxisType.X}`,position:`${t.plot.AxisPosition.BOTTOM}`},l={formatType:`${t.plot.AxisFormatType.NUMBER}`,type:`${t.plot.AxisType.Y}`,position:`${t.plot.AxisPosition.LEFT}`};return{charts:[{chartType:`${t.plot.ChartType.XY}`,axes:[o,l],series:(n??[]).map(c=>({plotStyle:`${r}`,name:c,dataSources:[{type:`${t.plot.SourceType.X}`,columnName:i??"",axis:o,table:e},{type:`${t.plot.SourceType.Y}`,columnName:c,axis:l,table:e}]}))}],title:a}}unwrapValue(s,e){const{dh:t}=this;if(s!=null){if(kt(s))return t.i18n.DateTimeFormat.format(f.DATE_FORMAT,s,e);if(Rt(s))return s.asNumber()}return s}wrapValue(s,e,t=null){const{dh:n}=this;if(W.isDateType(e)&&typeof s=="string"){const i=s,r=f.DATE_FORMAT.substr(0,s.length),a=n.i18n.DateTimeFormat.parse(r,i);if(!t)return a;const o=`${r} Z`,l=n.i18n.DateTimeFormat.format("Z",a,t),c=n.i18n.DateTimeFormat.parse(o,`${i} ${l}`),h=n.i18n.DateTimeFormat.format("Z",c,t);return n.i18n.DateTimeFormat.parse(o,`${i} ${h}`)}return s}makeLayoutAxis(s,e=B){const{dh:t}=this,n={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(n,{showgrid:!0}):s===t.plot.AxisType.Y&&Object.assign(n,{zerolinecolor:e.zerolinecolor,zerolinewidth:2}),n}makeDefaultLayout(s=B){const{dh:e}=this,t={...s,autosize:!0,colorway:f.getColorwayFromTheme(s),font:{family:"'Fira Sans', sans-serif"},title:{font:{color:s.title_color},yanchor:"top",pad:{...f.DEFAULT_TITLE_PADDING},y:1},legend:{font:{color:s.title_color}},margin:{...f.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 A=f;u(A,"DEFAULT_AXIS_SIZE",.15),u(A,"MIN_AXIS_SIZE",.025),u(A,"MAX_AXIS_SIZE",.2),u(A,"AXIS_SIZE_PX",75),u(A,"LEGEND_WIDTH_PX",50),u(A,"MAX_LEGEND_SIZE",.25),u(A,"ORIENTATION",Object.freeze({HORIZONTAL:"h",VERTICAL:"v"})),u(A,"DATE_FORMAT","yyyy-MM-dd HH:mm:ss.SSSSSS"),u(A,"DEFAULT_MARGIN",Object.freeze({l:60,r:50,t:30,b:60,pad:0})),u(A,"DEFAULT_TITLE_PADDING",Object.freeze({t:8})),u(A,"SUBTITLE_LINE_HEIGHT",25),u(A,"DEFAULT_MARKER_SIZE",6),u(A,"MODE_MARKERS","markers"),u(A,"MODE_LINES","lines");const C=A;const G=Z.module("Chart"),ce=class extends K.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",_e((e,t,n,i)=>{const r=[],a=Boolean(e);if(a&&r.push({name:`Downsampling failed: ${e}`,click:()=>{},icon:ce.convertIcon(Ge),attr:"fill-warning"}),t||n||i||a){const o=ce.downsampleButtonTitle(n,i),l=ce.downsampleButtonAttr(n,i),c=n?Ye:Ke;r.push({name:o,icon:ce.convertIcon(c),click:this.handleDownsampleClick,attr:l})}return{displaylogo:!1,displayModeBar:n||a?!0:"hover",modeBarButtons:[r,["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=X.createRef(),this.plotWrapper=X.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,i=`${n}`;return{width:t,path:i,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;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){G.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:n}=e;switch(G.debug2("Received data update",t,n),t){case z.EVENT_UPDATED:{this.currentSeries+=1,this.setState(r=>{const{layout:a,revision:o}=r;return typeof a.datarevision=="number"&&(a.datarevision+=1),{data:n,layout:a,revision:o+1}});const{onUpdate:i}=this.props;i({isLoading:!this.isLoadedFired});break}case z.EVENT_LOADFINISHED:{const{onUpdate:i}=this.props;this.isLoadedFired=!0,i({isLoading:!1});break}case z.EVENT_DISCONNECT:{const{onDisconnect:i}=this.props;i();break}case z.EVENT_RECONNECT:{const{onReconnect:i}=this.props;i();break}case z.EVENT_DOWNSAMPLESTARTED:{this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!0,downsamplingError:null});break}case z.EVENT_DOWNSAMPLEFINISHED:{this.setState({isDownsampleFinished:!0,isDownsampleInProgress:!1,downsamplingError:null});break}case z.EVENT_DOWNSAMPLENEEDED:case z.EVENT_DOWNSAMPLEFAILED:{const i=n.message??n;this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,downsamplingError:i});const{onError:r}=this.props;r(new Error(i));break}default:G.debug("Unknown event type",t,e)}}handlePlotUpdate(e){const{layout:t}=e,n=C.getLayoutRanges(t);!pe(n,this.ranges)&&(this.ranges=n,this.updateModelDimensions(!0))}handleRelayout(e){if(G.debug("handleRelayout",e),e.hiddenlabels!=null){const{onSettingsChanged:t}=this.props,n=[...e.hiddenlabels];t({hiddenSeries:n})}this.updateModelDimensions()}handleRestyle([e,t]){if(G.debug("handleRestyle",e,t),Object.keys(e).includes("visible")){const{data:n}=this.state,{onSettingsChanged:i}=this.props;if(n!=null){const r=n.reduce((a,{name:o,visible:l})=>o!=null&&l==="legendonly"?[...a,o]:a,[]);i({hiddenSeries:r})}}}updateModelDimensions(e=!1){const t=this.getPlotRect();if(!t){G.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:i,model:r}=this.props;r.setDimensions(t),i&&this.subscribe()}}initFormatter(){const{settings:e}=this.props;this.updateFormatterSettings(e)}updateFormatterSettings(e){const t=Ie.getColumnFormats(e),n=Ie.getDateTimeFormatterOptions(e),{decimalFormatOptions:i={},integerFormatOptions:r={}}=e;(!pe(this.columnFormats,t)||!pe(this.dateTimeFormatterOptions,n)||!pe(this.decimalFormatOptions,i)||!pe(this.integerFormatOptions,r))&&(this.columnFormats=Ie.getColumnFormats(e),this.dateTimeFormatterOptions=n,this.decimalFormatOptions=i,this.integerFormatOptions=r,this.updateFormatter())}updateFormatter(){const e=new Pe(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&&Me.relayout(this.plot.current.el,{autosize:!0}).catch(t=>{G.debug("Unable to resize, promise rejected",t)})}render(){const{data:e,downsamplingError:t,isDownsampleFinished:n,isDownsampleInProgress:i,isDownsamplingDisabled:r,layout:a,revision:o}=this.state,l=this.getCachedConfig(t,n,i,r),c=e!=null;return D.jsx("div",{className:"h-100 w-100 chart-wrapper",ref:this.plotWrapper,children:c&&D.jsx(Nt,{ref:this.plot,data:e,layout:a,revision:o,config:l,onAfterPlot:this.handleAfterPlot,onError:G.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}};let be=ce;u(be,"defaultProps",{isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:se.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}});const Vt=be,x=Z.module("FigureChartModel"),Oe=class extends z{constructor(e,t,n={},i=B){super();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,"getCachedChartUtils",ae(e=>new C(e),{max:1}));u(this,"addPendingSeries",ze(()=>{const e=C.getAllAxes(this.figure),{pendingSeries:t}=this;for(let n=0;n<t.length;n+=1){const i=t[n],r=this.figure.charts.find(a=>a.series.includes(i));this.addSeries(i,e,(r==null?void 0:r.showLegend)??null),i.subscribe()}this.pendingSeries=[]},Oe.ADD_SERIES_DEBOUNCE));u(this,"getTimeZone",ae((e,t)=>{if(t!=null){const n=t.getColumnTypeFormatter(e);if(n!=null)return n.dhTimeZone}}));u(this,"getValueTranslator",ae((e,t)=>{const n=this.getTimeZone(e,t);return i=>this.getChartUtils().unwrapValue(i,n)}));u(this,"getValueParser",ae((e,t)=>{const n=this.getTimeZone(e,t);return i=>this.getChartUtils().wrapValue(i,e,n)}));u(this,"getRangeParser",ae((e,t)=>n=>{let[i,r]=n;const a=this.getValueParser(e,t);return i=a(i),r=a(r),[i,r]}));u(this,"getAxisRangeParser",ae((e,t)=>n=>{const i=C.getSourceForAxis(e,n);return i?this.getRangeParser(i.columnType,t):r=>r}));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.figure=t,this.settings=n,this.theme=i,this.data=[];const r={data:{},layout:this.getChartUtils().makeDefaultLayout(i)};this.layout={grid:{rows:t.rows,columns:t.cols,pattern:"independent"},template:r},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()}getChartUtils(){return this.getCachedChartUtils(this.dh)}getDefaultTitle(){return this.figure.charts.length>0?this.figure.charts[0].title:""}initAllSeries(){this.oneClicks=[],this.filterColumnMap.clear();const{charts:e}=this.figure,t=C.getAllAxes(this.figure),n=[];for(let a=0;a<e.length;a+=1){const o=e[a];for(let l=0;l<o.series.length;l+=1){const c=o.series[l];n.push(c.name),this.addSeries(c,t,o.showLegend)}}const r=[...this.seriesDataMap.keys()].filter(a=>n.indexOf(a)<0);for(let a=0;a<r.length;a+=1){const o=r[a];this.seriesDataMap.delete(o)}this.seriesToProcess=new Set([...this.seriesDataMap.keys()])}addSeries(e,t,n){const{dh:i}=this,r=C.groupArray(t,"type"),a=this.getChartUtils().makeSeriesDataFromSeries(e,r,C.getSeriesVisibility(e.name,this.settings),n,this.theme);if(this.seriesDataMap.set(e.name,a),this.data=[...this.seriesDataMap.values()],e.plotStyle===i.plot.SeriesPlotStyle.STACKED_BAR?this.layout.barmode="stack":e.plotStyle===i.plot.SeriesPlotStyle.PIE&&(this.layout.hiddenlabels=C.getHiddenLabels(this.settings)),this.layout.showlegend=this.data.length>1||e.plotStyle===i.plot.SeriesPlotStyle.PIE?n??void 0:!1,e.oneClick!=null){const{oneClick:o}=e,{columns:l}=o;for(let c=0;c<l.length;c+=1)this.filterColumnMap.set(l[c].name,l[c]);this.oneClicks.push(o)}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){x.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){x.debug("Downsample started",e),this.fireDownsampleStart(e.detail)}handleDownsampleFinish(e){x.debug("Downsample finished",e),this.fireDownsampleFinish(e.detail)}handleDownsampleFail(e){x.error("Downsample failed",e),this.fireDownsampleFail(e.detail)}handleDownsampleNeeded(e){x.info("Downsample needed",e),this.fireDownsampleNeeded(e.detail)}handleFigureUpdated(e){const{detail:t}=e,{series:n}=t;x.debug2("handleFigureUpdated",n);for(let r=0;r<n.length;r+=1){const a=n[r];x.debug2("handleFigureUpdated updating series",a.name);const{sources:o}=a;for(let l=0;l<o.length;l+=1){const c=o[l],{columnType:h,type:m}=c,T=this.getValueTranslator(h,this.formatter),S=t.getArray(a,m,T);this.setDataArrayForSeries(a,m,S)}this.seriesToProcess.delete(a.name),this.seriesToProcess.size===0&&this.fireLoadFinished(),this.cleanSeries(a)}const{data:i}=this;this.fireUpdate(i)}handleRequestFailed(e){x.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){x.debug("Figure disconnected",e),this.isConnected=!1,this.listeners.length>0&&this.unsubscribeFigure(),this.fireDisconnect()}handleFigureReconnected(e){x.debug("Figure reconnected",e),this.isConnected=!0,this.initAllSeries(),this.fireReconnect(),this.listeners.length>0&&this.subscribeFigure()}handleFigureSeriesAdded(e){const{detail:t}=e;x.debug("handleFigureSeriesAdded",t),this.pendingSeries.push(t),this.addPendingSeries()}setDimensions(e){super.setDimensions(e),this.updateAxisPositions()}setTitle(e){var i;super.setTitle(e);const t=((i=(e??"").match(/<br>/g))==null?void 0:i.length)??0,n=C.DEFAULT_MARGIN.t+t*C.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=C.DEFAULT_TITLE_PADDING.t+t*C.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.getChartUtils().updateFigureAxes(this.layout,this.figure,n=>this.getAxisRangeParser(n,this.formatter),e,t,this.theme)}updateLayoutFormats(){if(!this.formatter)return;this.getChartUtils().getAxisFormats(this.figure,this.formatter).forEach((t,n)=>{x.debug(`Assigning ${n}`,this.layout[n],t);const i=this.layout[n];i!=null?Object.assign(i,t):x.debug(`Ignoring null layout.${n}`)})}setDataArrayForSeries(e,t,n){const{name:i,plotStyle:r}=e,a=this.seriesDataMap.get(i),o=this.getChartUtils().getPlotlyProperty(r,t);a&&je(a,o,n)}cleanSeries(e){const{dh:t}=this,{name:n,plotStyle:i}=e,r=this.seriesDataMap.get(n);if(r!=null){if(i===t.plot.SeriesPlotStyle.HISTOGRAM){const{xLow:a,xHigh:o}=r;if(a&&o&&a.length===o.length){const l=[];for(let c=0;c<a.length;c+=1)l.push(o[c]-a[c]);r.width=l}}else if(i===t.plot.SeriesPlotStyle.LINE){const{x:a,xLow:o,xHigh:l,y:c,yLow:h,yHigh:m}=r;o&&l&&o!==a&&(r.error_x=C.getPlotlyErrorBars(a,o,l)),h&&m&&h!==c&&(r.error_y=C.getPlotlyErrorBars(c,h,m))}else if(i===t.plot.SeriesPlotStyle.TREEMAP){const{ids:a,labels:o}=r;a!==void 0&&o===void 0&&(r.labels=a)}}}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){x.warn("Trying to set a filter, but no one click!");return}x.debug("setFilter",e);for(let t=0;t<this.oneClicks.length;t+=1){const n=this.oneClicks[t],{columns:i}=n;new Set([...e.keys(),...this.lastFilter.keys()]).forEach(a=>{const o=e.get(a);this.lastFilter.get(a)!==o&&i.find(l=>l.name===a)!=null&&n.setValueForColumn(a,o)})}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 De=Oe;u(De,"ADD_SERIES_DEBOUNCE",50);const Ue=De;class ve{static async makeModelFromSettings(s,e,t,n=B){const i=await ve.makeFigureFromSettings(s,e,t);return new Ue(s,i,e,n)}static async makeFigureFromSettings(s,e,t){const n=await t.copy();return n.applyCustomColumns(t.customColumns),n.applyFilter(t.filter),n.applySort(t.sort),s.plot.Figure.create(new C(s).makeFigureSettings(e,n))}static async makeModel(s,e,t,n=B){return new Ue(s,t,e,n)}}const Ht=ve;const le=Z.module("EmbedChart.App");async function Ut(g,s){le.info(`Fetching figure ${s}...`);const e={name:s,type:V.VariableType.FIGURE};return g.getObject(e)}function zt(){const[g,s]=K.useState(),[e,t]=K.useState(),[n,i]=K.useState(!0),r=K.useMemo(()=>new URLSearchParams(window.location.search),[]);K.useEffect(function(){async function l(){try{const c=r.get("name");if(c==null)throw new Error("No name param provided");const h=new URL("../../../jsapi",`${window.location}`),m=`${h.protocol}//${h.host}`;le.debug("Starting connection...");const T=new V.IdeConnection(m);le.debug("Loading figure",c,"...");const S=await Ut(T,c);le.debug("Creating model...");const F=await Ht.makeModel(V,void 0,S);s(F),le.debug("Figure successfully loaded!")}catch(c){le.error("Unable to load figure",c),t(`${c}`)}i(!1)}l()},[r]);const a=g!=null;return D.jsxs("div",{className:"App",children:[a&&D.jsx(Vt,{model:g}),!a&&D.jsx(Qe,{isLoaded:a,isLoading:n,errorMessage:e??null}),D.jsx(dt,{})]})}export{zt as default};
2
+ //# sourceMappingURL=App-cdfac578.js.map