@deephaven/embed-chart 0.36.1-beta.6 → 0.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.html CHANGED
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="en">
3
3
  <head>
4
- <meta name="ui-version" content="v0.36.0" />
4
+ <meta name="ui-version" content="v0.37.0" />
5
5
  <meta charset="utf-8" />
6
6
  <meta
7
7
  name="viewport"
@@ -16,10 +16,10 @@
16
16
 
17
17
  <link rel="icon" href="./favicon-cc-app.svg" />
18
18
  <title>Deephaven Embedded Chart</title>
19
- <script type="module" crossorigin src="./assets/index-e6fa6275.js"></script>
19
+ <script type="module" crossorigin src="./assets/index-7bce681d.js"></script>
20
20
  <link rel="modulepreload" crossorigin href="./assets/helpers-042e6b4d.js">
21
- <link rel="modulepreload" crossorigin href="./assets/vendor-26ef4017.js">
22
- <link rel="stylesheet" href="./assets/vendor-63828250.css">
21
+ <link rel="modulepreload" crossorigin href="./assets/vendor-73e67738.js">
22
+ <link rel="stylesheet" href="./assets/vendor-458ea229.css">
23
23
  <link rel="stylesheet" href="./assets/index-04780174.css">
24
24
  </head>
25
25
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deephaven/embed-chart",
3
- "version": "0.36.1-beta.6+38c37a48",
3
+ "version": "0.37.0",
4
4
  "description": "Deephaven Embedded Chart",
5
5
  "author": "Deephaven Data Labs LLC",
6
6
  "license": "Apache-2.0",
@@ -16,12 +16,13 @@
16
16
  "build"
17
17
  ],
18
18
  "dependencies": {
19
- "@deephaven/chart": "^0.36.1-beta.6+38c37a48",
20
- "@deephaven/components": "^0.36.1-beta.6+38c37a48",
21
- "@deephaven/jsapi-bootstrap": "^0.36.1-beta.6+38c37a48",
22
- "@deephaven/jsapi-shim": "^0.36.1-beta.6+38c37a48",
23
- "@deephaven/jsapi-utils": "^0.36.1-beta.6+38c37a48",
24
- "@deephaven/log": "^0.36.1-beta.6+38c37a48",
19
+ "@deephaven/app-utils": "^0.37.0",
20
+ "@deephaven/chart": "^0.37.0",
21
+ "@deephaven/components": "^0.37.0",
22
+ "@deephaven/jsapi-bootstrap": "^0.37.0",
23
+ "@deephaven/jsapi-shim": "^0.37.0",
24
+ "@deephaven/jsapi-utils": "^0.37.0",
25
+ "@deephaven/log": "^0.37.0",
25
26
  "fira": "mozilla/fira#4.202",
26
27
  "react": "^17.0.2",
27
28
  "react-dom": "^17.0.2"
@@ -33,16 +34,16 @@
33
34
  "preview": "vite preview"
34
35
  },
35
36
  "devDependencies": {
36
- "@deephaven/eslint-config": "^0.36.1-beta.6+38c37a48",
37
- "@deephaven/mocks": "^0.36.1-beta.6+38c37a48",
38
- "@deephaven/prettier-config": "^0.36.1-beta.6+38c37a48",
39
- "@deephaven/stylelint-config": "^0.36.1-beta.6+38c37a48",
40
- "@deephaven/tsconfig": "^0.36.1-beta.6+38c37a48",
37
+ "@deephaven/eslint-config": "^0.37.0",
38
+ "@deephaven/mocks": "^0.37.0",
39
+ "@deephaven/prettier-config": "^0.37.0",
40
+ "@deephaven/stylelint-config": "^0.37.0",
41
+ "@deephaven/tsconfig": "^0.37.0",
41
42
  "@vitejs/plugin-react-swc": "^3.2.0",
42
43
  "vite": "^4.1.4"
43
44
  },
44
45
  "publishConfig": {
45
46
  "access": "public"
46
47
  },
47
- "gitHead": "38c37a4830a57666ed78d29aa49d0b9b541ca26f"
48
+ "gitHead": "de7a110ea64f279ec37087bcbda9cf85d8c523f8"
48
49
  }
@@ -1,2 +0,0 @@
1
- var We=Object.defineProperty;var qe=(f,s,e)=>s in f?We(f,s,{enumerable:!0,configurable:!0,writable:!0,value:e}):f[s]=e;var u=(f,s,e)=>(qe(f,typeof s!="symbol"?s+"":s,e),e);import{G as X,C as D,E as Se,F as Le,A as _,H as je,I as ze,J as pe,K as Xe,L as me}from"./vendor-26ef4017.js";import{v as Ze,L as Z,a as Ge,d as Ye,b as Ke,c as _e,e as Qe}from"./index-e6fa6275.js";import{P as Ae,b as Je,h as et,p as tt,o as st,s as nt,t as rt,c as Ie}from"./plotly-df8f737d.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 r=0;r<n.length;r+=1){const i=n[r];let a;typeof i=="function"?a=i():a=i,a!=null&&(a instanceof Promise?e&&t.push(a):Array.isArray(a)?t=t.concat(a):t.push(a))}return t=t.filter(r=>r.title!==void 0||r.then!=null||r.menuElement),t}static getNextMenuItem(s,e,t){let n=s;n<0&&e<0&&(n=t.length);for(let r=1;r<t.length+1;r+=1){const i=(n+e*r+t.length)%t.length,a=t[i];if(!(a instanceof Promise)&&a.disabled!==!0)return i}return s}};let ye=ee;u(ye,"actionsDisabled",!1);const J=ye,Ce=X.forwardRef((f,s)=>{var A;function e(y){const{menuItem:M,onMenuItemClick:F}=f;F(M,y)}function t(y){const{menuItem:M,onMenuItemMouseMove:F}=f;F(M,y)}function n(y){const{menuItem:M,onMenuItemContextMenu:F}=f;F(M,y)}function r(y,M,F){if(typeof y.type=="string")return y;const{closeMenu:C,menuItem:P,isKeyboardSelected:R,isMouseSelected:$,"data-testid":L}=f,ce={menuItem:P,closeMenu:C,isKeyboardSelected:R,isMouseSelected:$,iconElement:M,displayShortcut:F,"data-testid":L};return X.cloneElement(y,{forwardedProps:ce})}const{children:i,menuItem:a,isKeyboardSelected:l=!1,isMouseSelected:o=!1,"data-testid":d}=f,h=(A=a.shortcut)==null?void 0:A.getDisplayText();let T=null;if(a.icon){const y=a.icon;if(X.isValidElement(y))T=y;else{let M;a.iconColor!=null&&(a.disabled===void 0||!a.disabled)&&(M={color:a.iconColor}),T=D.jsx(Le,{icon:y,style:M})}}let S=null;const E=Boolean(i);a.actions&&(S=D.jsx(Le,{icon:Ze}));let b=null;if(a.menuElement)b=D.jsx("div",{className:"custom-menu-item",onMouseMove:t,children:r(a.menuElement,T,h)});else{const y=a.disabled,M=a.iconOutline;b=D.jsx("button",{type:"button",className:Se("btn-context-menu",{disabled:y},{active:(E||o)&&(y===void 0||!y)},{"keyboard-active":l&&(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:Se("icon",{outline:M}),children:T}),D.jsx("span",{className:"title",children:a.title}),h!==void 0&&D.jsx("span",{className:"shortcut",children:h}),S&&D.jsx("span",{className:Se("submenu-indicator",{disabled:y}),children:S})]})})}return D.jsxs("div",{className:"context-menu-item",ref:s,"data-testid":d,children:[i,b]})});Ce.displayName="ContextMenuItem";Ce.defaultProps={children:null,isKeyboardSelected:!1,isMouseSelected:!1,"data-testid":void 0};const it=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,r;const i=new Promise((a,l)=>{r=l,Promise.resolve(s).then(o=>{t?e&&e(o):(n=o,a(o))}).catch(o=>l(o))});return i.cancel=()=>{t=!0,r(new ke),n!=null&&e&&e(n)},i}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(r){n(r)}},s)})}}function ge(f){if(f==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"),Ne=class extends _.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 i,a;const{actions:n}=this.props,{activeSubMenu:r}=this.state;r!==t.activeSubMenu&&(r==null?(i=this.container.current)==null||i.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,r=J.getMenuItems(n),i=[];for(let a=r.length-1;a>=0;a-=1){const l=r[a];l instanceof Promise?this.initMenuPromise(l):i.push(l)}this.setState({mouseIndex:-1,keyboardIndex:t,activeSubMenu:null,menuItems:J.sortActions(i)})}initMenuPromise(e){const t=xe.makeCancelable(e);this.setState(n=>({pendingItems:n.pendingItems.concat(t)})),t.then(n=>{this.setState(r=>{const i=r.pendingItems.indexOf(t);if(i>=0){const a=r.pendingItems.slice();return a.splice(i,1),{menuItems:J.sortActions(r.menuItems.concat(n)),pendingItems:a}}return null})},n=>{xe.isCanceled(n)||(this.setState(r=>{const i=r.pendingItems.indexOf(t);if(i>=0){const a=r.pendingItems.slice();return a.splice(i,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 S,E;const{options:e,updatePosition:t,subMenuParentWidth:n,subMenuParentHeight:r,top:i,left:a}=this.props;if(!this.container.current||e.doNotVerifyPosition!=null&&e.doNotVerifyPosition)return;let{top:l,left:o}=this.initialPosition;const{width:d,height:h}=((S=this.container.current)==null?void 0:S.getBoundingClientRect())??{width:0,height:0},T=(((E=this.container.current)==null?void 0:E.scrollHeight)??0)>window.innerHeight;h===0||d===0||(l+h>window.innerHeight&&(l-h-r>0?l-=h-r:l=window.innerHeight-h),o+d>window.innerWidth&&(o=o-d-n),(a!==o||i!==l)&&(this.setState({hasOverflow:T}),t(l,o)))}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 r=n,i=!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?i=!0:r=0:this.isEscapeKey(e.key)?r=null:e.key==="ArrowUp"||e.shiftKey&&e.key==="Tab"?r=J.getNextMenuItem(r,-1,t):(e.key==="ArrowDown"||e.key==="Tab")&&(r=J.getNextMenuItem(r,1,t)),i){this.openSubMenu(n),e.preventDefault(),e.stopPropagation();return}n!==r&&(r!==null?this.setKeyboardIndex(r):(this.closeMenu(),this.oldFocus instanceof HTMLElement&&this.oldFocus.focus()),e.preventDefault(),e.stopPropagation())}openSubMenu(e){const{menuItems:t,activeSubMenu:n}=this.state,r=t[e].actions?e:null;n!==r&&this.setState({activeSubMenu:r,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:r,hasOverflow:i,keyboardIndex:a,menuItems:l,mouseIndex:o,pendingItems:d,subMenuTop:h,subMenuLeft:T,subMenuParentWidth:S,subMenuParentHeight:E}=this.state;for(let F=0;F<l.length;F+=1){const C=l[F];F>0&&C.group!==l[F-1].group&&e.push(D.jsx("hr",{},`${F}.separator`));const P=D.jsx(it,{ref:r===F?this.activeSubMenuRef:null,isKeyboardSelected:a===F,isMouseSelected:o===F,menuItem:C,closeMenu:this.handleCloseSubMenu,onMenuItemClick:this.handleMenuItemClick,onMenuItemMouseMove:this.handleMenuItemMouseMove,onMenuItemContextMenu:this.handleMenuItemContextMenu},F);e.push(P)}let b=null;d.length>0&&(b=D.jsx("div",{className:"loading",children:D.jsx(Ge,{})}));const{menuStyle:A,"data-testid":y}=this.props,M=r!==null&&h!==null&&T!==null;return D.jsxs(D.Fragment,{children:[D.jsxs("div",{className:Se({"has-overflow":i},"context-menu-container"),style:{top:t,left:n,...A},ref:this.container,"data-dh-context-menu":!0,onBlur:this.handleBlur,onKeyDown:this.handleKeyDown,onMouseLeave:this.handleMouseLeave,onContextMenu:Ne.handleContextMenu,role:"menuitem",tabIndex:0,"data-testid":y,children:[e,b]}),M&&r!==null&&h!==null&&T!==null&&D.jsx(Ne,{actions:l[r].actions||[],closeMenu:this.handleCloseSubMenu,top:h,left:T,updatePosition:(F,C)=>{this.setState({subMenuTop:F,subMenuLeft:C})},subMenuParentWidth:S,subMenuParentHeight:E},`sub-${r}`)]})}};let Fe=Ne;u(Fe,"defaultProps",{subMenuParentWidth:0,subMenuParentHeight:0,closeMenu(){},onMenuOpened(){},onMenuClosed(){},options:{},menuStyle:{},"data-testid":void 0});const ut=Fe;class dt extends _.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(),r=e.clientY-n.top,i=e.clientX-n.left;if(t.length===0){if(e.target===this.container.current){e.preventDefault(),this.setState({actions:null},()=>{const a=document.elementFromPoint(i,r),l=new MouseEvent("contextmenu",{clientX:e.clientX,clientY:e.clientY,bubbles:!0,cancelable:!0});a==null||a.dispatchEvent(l)});return}return}e.preventDefault(),this.setState({actions:t,top:r,left:i})}handleMenuClose(e){e===this.openMenu.current&&this.setState({actions:null})}render(){let e=null;const{"data-testid":t}=this.props,{actions:n,top:r,left:i}=this.state;return n&&(e=D.jsx(ut,{ref:this.openMenu,actions:n,onMenuClosed:this.handleMenuClose,top:r,left:i,updatePosition:(a,l)=>{this.setState({top:a,left:l})},"data-testid":t})),D.jsx("div",{className:Se("context-menu-root",{active:n}),ref:this.container,children:e})}}const ht=dt;class be{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(be,"TYPE_GLOBAL","type-global"),u(be,"TYPE_CONTEXT_PRESET","type-context-preset"),u(be,"TYPE_CONTEXT_CUSTOM","type-context-custom");const x=be;class pt extends x{format(s){switch(s){case 1:case!0:return"true";case 0:case!1:return"false";default:return""}}}const mt=pt;class gt extends x{format(s){return String.fromCharCode(s)}}const ft=gt,{dh:Tt}=globalThis,c=Tt,$e=Z.module("DateTimeColumnFormatter"),K=class extends x{constructor({timeZone:e="",showTimeZone:t=!0,showTSeparator:n=!1,defaultDateTimeFormatString:r=K.DEFAULT_DATETIME_FORMAT_STRING}={}){super();u(this,"dhTimeZone");u(this,"defaultDateTimeFormatString");u(this,"showTimeZone");u(this,"showTSeparator");u(this,"formatStringMap");const i=e||K.DEFAULT_TIME_ZONE_ID;try{this.dhTimeZone=c.i18n.TimeZone.getTimeZone(i)}catch{$e.error("Unsupported time zone id",i),this.dhTimeZone=c.i18n.TimeZone.getTimeZone(K.DEFAULT_TIME_ZONE_ID)}this.defaultDateTimeFormatString=r,this.showTimeZone=t,this.showTSeparator=n,this.formatStringMap=K.makeFormatStringMap(t,n)}static isValid(e){try{return c.i18n.DateTimeFormat.format(e.formatString,new Date),!0}catch{return!1}}static makeFormat(e,t,n=x.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'":" ",r=e?" z":"";return new Map([["yyyy-MM-dd HH:mm:ss",`yyyy-MM-dd${n}HH:mm:ss${r}`],["yyyy-MM-dd HH:mm:ss.SSS",`yyyy-MM-dd${n}HH:mm:ss.SSS${r}`],["yyyy-MM-dd HH:mm:ss.SSSSSSSSS",`yyyy-MM-dd${n}HH:mm:ss.SSSSSSSSS${r}`]])}static getGlobalFormats(e,t){return[...K.makeGlobalFormatStringMap(e,t).keys()]}static makeFormatStringMap(e,t){const n=t!==void 0&&t?"'T'":" ",r=e!==void 0&&e?" z":"";return new Map([["yyyy-MM-dd",`yyyy-MM-dd${r}`],["MM-dd-yyyy",`MM-dd-yyyy${r}`],["HH:mm:ss",`HH:mm:ss${r}`],["HH:mm:ss.SSS",`HH:mm:ss.SSS${r}`],["HH:mm:ss.SSSSSSSSS",`HH:mm:ss.SSSSSSSSS${r}`],["yyyy-MM-dd HH:mm:ss",`yyyy-MM-dd${n}HH:mm:ss${r}`],["yyyy-MM-dd HH:mm:ss.SSS",`yyyy-MM-dd${n}HH:mm:ss.SSS${r}`],["yyyy-MM-dd HH:mm:ss.SSSSSSSSS",`yyyy-MM-dd${n}HH:mm:ss.SSSSSSSSS${r}`]])}static getFormats(e,t){return[...K.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,r=this.getEffectiveFormatString(n);try{return c.i18n.DateTimeFormat.format(r,e,this.dhTimeZone)}catch{$e.error("Invalid format arguments")}return""}};let Te=K;u(Te,"DEFAULT_DATETIME_FORMAT_STRING","yyyy-MM-dd HH:mm:ss.SSS"),u(Te,"DEFAULT_TIME_ZONE_ID","America/New_York");const St=Z.module("DecimalColumnFormatter"),k=class extends x{constructor({defaultFormatString:e=k.DEFAULT_FORMAT_STRING}={}){super();u(this,"defaultFormatString");this.defaultFormatString=e}static isValid(e){try{return c.i18n.NumberFormat.format(e.formatString,0),!0}catch{return!1}}static makeFormat(e,t,n=x.TYPE_CONTEXT_PRESET,r){return{label:e,type:n,formatString:t,multiplier:r}}static makePresetFormat(e,t="",n){return k.makeFormat(e,t,x.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(e="",t){return k.makeFormat("Custom Format",e,x.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,r=t.multiplier!=null&&t.multiplier!==0?e*t.multiplier:e;try{return c.i18n.NumberFormat.format(n,r)}catch{St.error("Invalid format arguments")}return""}};let V=k;u(V,"DEFAULT_FORMAT_STRING","###,##0.0000"),u(V,"FORMAT_PERCENT",k.makePresetFormat("Percent","##0.00%")),u(V,"FORMAT_BASIS_POINTS",k.makePresetFormat("Basis Points","###,##0 bp",1e4)),u(V,"FORMAT_MILLIONS",k.makePresetFormat("Millions","###,##0.000 mm",1e-6)),u(V,"FORMAT_SCIENTIFIC_NOTATION",k.makePresetFormat("Scientific Notation","0.0000E0")),u(V,"FORMAT_ROUND",k.makePresetFormat("Round","###,##0")),u(V,"FORMAT_ROUND_TWO_DECIMALS",k.makePresetFormat("0.00","###,##0.00")),u(V,"FORMAT_ROUND_FOUR_DECIMALS",k.makePresetFormat("0.0000","###,##0.0000"));class Et extends x{format(s){return`${s}`}}const yt=Et,Ft=Z.module("IntegerColumnFormatter"),te=class extends x{constructor({defaultFormatString:e=te.DEFAULT_FORMAT_STRING}={}){super();u(this,"defaultFormatString");this.defaultFormatString=e}static isValid(e){try{return c.i18n.NumberFormat.format(e.formatString,0),!0}catch{return!1}}static makeFormat(e,t,n=x.TYPE_CONTEXT_PRESET,r){return{label:e,type:n,formatString:t,multiplier:r}}static makePresetFormat(e,t="",n){return te.makeFormat(e,t,x.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(e="",t){return te.makeFormat("Custom Format",e,x.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,r=t.multiplier!=null&&t.multiplier!==0?e*t.multiplier:e;try{return c.i18n.NumberFormat.format(n,r)}catch{Ft.error("Invalid format arguments")}return""}};let ae=te;u(ae,"DEFAULT_FORMAT_STRING","###,##0"),u(ae,"FORMAT_MILLIONS",te.makePresetFormat("Millions","###,##0.000 mm",1e-6)),u(ae,"FORMAT_SCIENTIFIC_NOTATION",te.makePresetFormat("Scientific Notation","0.0000E0"));class bt extends x{format(s){return s}}const O=class{static makeDateWrapper(s,e,t=0,n=1,r=0,i=0,a=0,l=0){if(!s)throw new Error("No timezone provided");const o=`${e}`.padStart(4,"0"),d=`${t+1}`.padStart(2,"0"),h=`${n}`.padStart(2,"0"),T=`${r}`.padStart(2,"0"),S=`${i}`.padStart(2,"0"),E=`${a}`.padStart(2,"0"),b=`${l}`.padStart(9,"0"),A=`${o}-${d}-${h} ${T}:${S}:${E}.${b}`;return c.i18n.DateTimeFormat.parse(O.FULL_DATE_FORMAT,A,c.i18n.TimeZone.getTimeZone(s))}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){let{year:n,month:r,date:i,hours:a,minutes:l,seconds:o,nanos:d}=e;if(s.nanos!=null){if(s.nanos.length===9)return null;d=O.getNextNanos(s.nanos),d>999999999&&(o+=1,d=0)}else s.seconds!=null?o+=1:s.minutes!=null?l+=1:s.hours!=null?a+=1:s.date!=null?i+=1:s.month!=null?r+=1:n+=1;const h=new Date(n,r,i,a,l,o);return O.makeDateWrapper(t,h.getFullYear(),h.getMonth(),h.getDate(),h.getHours(),h.getMinutes(),h.getSeconds(),d)}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<O.months.length;n+=1)if(O.months[n].startsWith(t))return n}return NaN}static parseDateValues(s,e,t,n,r,i,a){const l=parseInt(s,10),o=e!=null?this.parseMonth(e):0,d=t!=null?parseInt(t,10):1,h=n!=null?parseInt(n,10):0,T=r!=null?parseInt(r,10):0,S=i!=null?parseInt(i,10):0,E=a!=null?parseInt(a.padEnd(9,"0"),10):0;return Number.isNaN(l)||Number.isNaN(o)||Number.isNaN(d)||Number.isNaN(h)||Number.isNaN(T)||Number.isNaN(S)||Number.isNaN(E)?null:{year:l,month:o,date:d,hours:h,minutes:T,seconds:S,nanos:E}}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,,r,,i,,a,,l,,o,,d,h]=t;if(h!=null&&h.length>0)throw new Error(`Unexpected characters after date string '${s}': ${h}`);return{year:n,month:r,date:i,hours:a,minutes:l,seconds:o,nanos:d}}static parseDateRange(s,e){const t=s.trim().toLowerCase();if(t.length===0)throw new Error("Cannot parse date range from empty string");if(t==="null")return[null,null];if(t==="today"){const l=new Date(Date.now()),o=O.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate()),d=O.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate()+1);return[o,d]}if(t==="yesterday"){const l=new Date(Date.now()),o=O.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate()-1),d=O.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate());return[o,d]}if(t==="now"){const l=new Date(Date.now());return[c.DateWrapper.ofJsDate(l),null]}const n=O.parseDateTimeString(t);if(n.year==null&&n.month==null&&n.date==null)throw new Error(`Unable to extract year, month, or day ${t}`);const r=O.parseDateValues(n.year,n.month,n.date,n.hours,n.minutes,n.seconds,n.nanos);if(r==null)throw new Error(`Unable to extract date values from ${n}`);const i=O.makeDateWrapper(e,r.year,r.month,r.date,r.hours,r.minutes,r.seconds,r.nanos),a=O.getNextDate(n,r,e);return[i,a]}static getJsDate(s){return typeof s=="number"?new Date(s):s.asDate()}};let se=O;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 Ee{}u(Ee,"not","not"),u(Ee,"and","and"),u(Ee,"or","or");class g{}u(g,"eq","eq"),u(g,"eqIgnoreCase","eqIgnoreCase"),u(g,"notEq","notEq"),u(g,"notEqIgnoreCase","notEqIgnoreCase"),u(g,"greaterThan","greaterThan"),u(g,"greaterThanOrEqualTo","greaterThanOrEqualTo"),u(g,"lessThan","lessThan"),u(g,"lessThanOrEqualTo","lessThanOrEqualTo"),u(g,"in","in"),u(g,"inIgnoreCase","inIgnoreCase"),u(g,"notIn","notIn"),u(g,"notInIgnoreCase","notInIgnoreCase"),u(g,"isTrue","isTrue"),u(g,"isFalse","isFalse"),u(g,"isNull","isNull"),u(g,"invoke","invoke"),u(g,"contains","contains"),u(g,"notContains","notContains"),u(g,"startsWith","startsWith"),u(g,"endsWith","endsWith"),u(g,"containsAny","containsAny");const q=Z.module("TableUtils"),m=class{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=m.getSortIndex(s,e);return t!=null?s[t]:null}static getFilterText(s){return s?s.toString():null}static getFilterTypes(s){return m.isBooleanType(s)?[g.isTrue,g.isFalse,g.isNull]:m.isCharType(s)||m.isNumberType(s)||m.isDateType(s)?[g.eq,g.notEq,g.greaterThan,g.greaterThanOrEqualTo,g.lessThan,g.lessThanOrEqualTo]:m.isTextType(s)?[g.eq,g.eqIgnoreCase,g.notEq,g.notEqIgnoreCase,g.contains,g.notContains,g.startsWith,g.endsWith]:[]}static getNextSort(s,e,t){if(t<0||t>=s.length)return null;const n=m.getSortForColumn(e,s[t].name);return n===null?s[t].sort().asc():n.direction===m.sortDirection.ascending?n.desc():null}static makeColumnSort(s,e,t,n){if(e<0||e>=s.length||t===m.sortDirection.none)return null;let r=s[e].sort();switch(t){case m.sortDirection.ascending:r=r.asc();break;case m.sortDirection.descending:r=r.desc();break}return n&&(r=r.abs()),r}static toggleSortForColumn(s,e,t,n=!1){if(t<0||t>=e.length)return[];const r=m.getNextSort(e,s,t);return m.setSortForColumn(s,e[t].name,r,n)}static sortColumn(s,e,t,n,r,i){if(t<0||t>=e.length)return[];const a=m.makeColumnSort(e,t,n,r);return m.setSortForColumn(s,e[t].name,a,i)}static setSortForColumn(s,e,t,n=!1){const r=m.getSortIndex(s,e);let i=[];return n&&(i=i.concat(s.filter(({direction:a})=>a!==m.sortDirection.reverse)),r!==null&&i.splice(r,1)),t!==null&&i.push(t),i}static getNormalizedType(s){switch(s){case"boolean":case"java.lang.Boolean":case m.dataType.BOOLEAN:return m.dataType.BOOLEAN;case"char":case"java.lang.Character":case m.dataType.CHAR:return m.dataType.CHAR;case"java.lang.String":case m.dataType.STRING:return m.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 m.dataType.DATETIME:return m.dataType.DATETIME;case"double":case"java.lang.Double":case"float":case"java.lang.Float":case"java.math.BigDecimal":case m.dataType.DECIMAL:return m.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 m.dataType.INT:return m.dataType.INT;default:return m.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 m.isIntegerType(s)||m.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 m.getNormalizedType(s)===m.getNormalizedType(e)}static makeQuickFilter(s,e,t){const n=e.split("||");let r=null;for(let i=0;i<n.length;i+=1){const l=n[i].split("&&");let o=null;for(let d=0;d<l.length;d+=1){const h=l[d].trim();if(h.length>0){const T=m.makeQuickFilterFromComponent(s,h,t);if(T)o?o=o.and(T):o=T;else throw new Error(`Unable to parse quick filter from text ${e}`)}}r&&o?r=r.or(o):r=o}return r}static makeQuickFilterFromComponent(s,e,t){const{type:n}=s;return m.isNumberType(n)?this.makeQuickNumberFilter(s,e):m.isBooleanType(n)?this.makeQuickBooleanFilter(s,e):t!=null&&m.isDateType(n)?this.makeQuickDateFilter(s,e,t):m.isCharType(n)?this.makeQuickCharFilter(s,e):this.makeQuickTextFilter(s,e)}static makeQuickNumberFilter(s,e){const t=s.filter();let n=null;const i=/\s*(>=|<=|=>|=<|>|<|!=|=|!)?(\s*-\s*)?(\s*\d*(?:,\d{3})*(?:\.\d*)?\s*)?(null|nan|infinity|inf|\u221E)?(.*)/i.exec(e);let a=null,l=null,o=null,d=null,h=null;if(i!==null&&i.length>3&&([,a,l,o,d,h]=i),h!=null&&h.trim().length>0)return null;if(a==null&&(a="="),d!=null){if(!(a==="="||a==="!"||a==="!="))return null;switch(d=d.trim().toLowerCase(),d){case"null":n=t.isNull();break;case"nan":n=c.FilterCondition.invoke("isNaN",t);break;case"infinity":case"inf":case"∞":l!=null?n=c.FilterCondition.invoke("isInf",t).and(t.lessThan(c.FilterValue.ofNumber(0))):n=c.FilterCondition.invoke("isInf",t).and(t.greaterThan(c.FilterValue.ofNumber(0)));break}return n!==null&&(a==="!"||a==="!=")&&(n=n.not()),n}if(o==null)return null;if(o=m.removeCommas(o),m.isLongType(s.type))try{o=c.FilterValue.ofNumber(c.LongWrapper.ofString(`${l!=null?"-":""}${o}`))}catch(T){return q.warn("Unable to create long filter",T),null}else{if(o=parseFloat(o),o==null||Number.isNaN(o))return null;o=c.FilterValue.ofNumber(l!=null?0-o:o)}return n=s.filter(),m.makeRangeFilterWithOperation(n,a,o)}static makeQuickTextFilter(s,e){const t=`${e}`.trim(),r=/^(!~|!=|~|=|!)?(.*)/.exec(t);let i=null,a=null;if(r!==null&&r.length>2&&([,i,a]=r,a!=null&&(a=a.trim())),a==null||a.length===0)return null;i==null&&(i="=");const l=s.filter();if(a.toLowerCase()==="null")switch(i){case"=":return l.isNull();case"!=":case"!":return l.isNull().not()}let o=null,d=null;switch(a.startsWith("*")?(o="*",a=a.substring(1)):a.endsWith("*")&&!a.endsWith("\\*")&&(d="*",a=a.substring(0,a.length-1)),a=a.replace("\\",""),i){case"~":return l.isNull().not().and(l.invoke("matches",c.FilterValue.ofString(`(?s)(?i).*\\Q${a}\\E.*`)));case"!~":return l.isNull().or(l.invoke("matches",c.FilterValue.ofString(`(?s)(?i).*\\Q${a}\\E.*`)).not());case"!=":return o==="*"?l.isNull().or(l.invoke("matches",c.FilterValue.ofString(`(?s)(?i).*\\Q${a}\\E$`)).not()):d==="*"?l.isNull().or(l.invoke("matches",c.FilterValue.ofString(`(?s)(?i)^\\Q${a}\\E.*`)).not()):l.notEqIgnoreCase(c.FilterValue.ofString(a.toLowerCase()));case"=":return o==="*"?l.isNull().not().and(l.invoke("matches",c.FilterValue.ofString(`(?s)(?i).*\\Q${a}\\E$`))):d==="*"?l.isNull().not().and(l.invoke("matches",c.FilterValue.ofString(`(?s)(?i)^\\Q${a}\\E.*`))):l.eqIgnoreCase(c.FilterValue.ofString(a.toLowerCase()))}return null}static makeQuickBooleanFilter(s,e){const n=/^(!=|=|!)?(.*)/.exec(`${e}`.trim());if(n===null)return null;const[,r,i]=n,a=r==="!"||r==="!=",l=i.trim().toLowerCase();let o=s.filter();try{const d=m.makeBooleanValue(l);return d!=null&&d?o=o.isTrue():d===null?o=o.isNull():o=o.isFalse(),a?o.not():o}catch{return null}}static makeQuickDateFilter(s,e,t){const n=e.trim(),i=/\s*(>=|<=|=>|=<|>|<|!=|!|=)?(.*)/.exec(n);if(i==null||i.length<=2)throw new Error(`Unable to parse date filter: ${e}`);let a=null,l=null;[,a,l]=i;let o=g.eq;switch(a){case"<":o=g.lessThan;break;case"<=":case"=<":o=g.lessThanOrEqualTo;break;case">":o=g.greaterThan;break;case">=":case"=>":o=g.greaterThanOrEqualTo;break;case"!=":case"!":o=g.notEq;break;case"=":case"==":default:o=g.eq;break}return m.makeQuickDateFilterWithOperation(s,l,o,t)}static makeQuickDateFilterWithOperation(s,e,t,n){const[r,i]=se.parseDateRange(e,n),a=r!=null?c.FilterValue.ofNumber(r):null,l=i!=null?c.FilterValue.ofNumber(i):null,o=s.filter();if(a==null)return t===g.notEq?o.isNull().not():o.isNull();switch(t){case g.eq:{if(l!=null){const d=o.greaterThanOrEqualTo(a),h=o.lessThan(l);return d.and(h)}return o.eq(a)}case g.lessThan:return o.lessThan(a);case g.lessThanOrEqualTo:return l!=null?o.lessThan(l):o.lessThanOrEqualTo(a);case g.greaterThan:return l!=null?o.greaterThanOrEqualTo(l):o.greaterThan(a);case g.greaterThanOrEqualTo:return o.greaterThanOrEqualTo(a);case g.notEq:{if(l!=null){const d=o.lessThan(a),h=o.greaterThanOrEqualTo(l);return d.or(h)}return o.notEq(a)}default:throw new Error(`Invalid operator: ${t}`)}}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 makeQuickCharFilter(s,e){const t=`${e}`.trim(),r=/^(>=|<=|=>|=<|>|<|!=|=|!)?(null|"."|'.'|.)?(.*)/.exec(t);let i=null,a=null,l=null;if(r!==null&&r.length>3&&([,i,a,l]=r),l!=null&&l.trim().length>0||a==null||a.length===0)return null;i==null&&(i="=");const o=s.filter();if(a.toLowerCase()==="null")switch(i){case"=":return o.isNull();case"!=":case"!":return o.isNull().not();default:return null}const d=c.FilterValue.ofString(m.isRangeOperation(i)?m.quoteValue(a):a);return m.makeRangeFilterWithOperation(o,i,d)}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 r,i,a=!0;const l=new Promise((o,d)=>{i=setTimeout(()=>{r(),a=!1,d(new Be(`Event "${e}" timed out.`))},t),r=s.addEventListener(e,h=>{if(n!=null&&!n(h)){q.debug2("Event triggered, but matcher returned false.");return}q.debug2("Event triggered, resolving."),r(),clearTimeout(i),a=!1,o(h)})});return l.cancel=()=>{if(a){q.debug2("Pending promise cleanup."),r(),clearTimeout(i),a=!1;return}q.debug2("Ignoring non-pending promise cancel.")},l}static makeAdvancedFilter(s,e,t){const{filterItems:n,filterOperators:r,invertSelection:i,selectedValues:a}=e;let l=null;for(let d=0;d<n.length;d+=1){const h=n[d],{selectedType:T,value:S}=h;if(T!=null&&T.length>0&&S!=null&&S.length>0)try{const E=m.makeAdvancedValueFilter(s,T,S,t);if(E!=null){if(d===0)l=E;else if(l!==null&&d-1<r.length){const b=r[d-1];if(b===Ee.and)l=l.and(E);else if(b===Ee.or)l=l.or(E);else{q.error("Unexpected filter operator",b,E),l=null;break}}}else q.debug2("Empty filter ignored for",T,S)}catch(E){q.error("Unable to create filter",E),l=null;break}}const o=m.makeSelectValueFilter(s,a,i);return o!=null&&(l!=null?l=l.and(o):l=o),l}static removeCommas(s){return s.replace(/[\s|,]/g,"")}static makeFilterValue(s,e){const t=m.getBaseType(s);return m.isTextType(t)?c.FilterValue.ofString(e):m.isLongType(t)?c.FilterValue.ofNumber(c.LongWrapper.ofString(m.removeCommas(e))):c.FilterValue.ofNumber(m.removeCommas(e))}static makeFilterRawValue(s,e){return m.isTextType(s)?c.FilterValue.ofString(e):m.isBooleanType(s)?c.FilterValue.ofBoolean(e):c.FilterValue.ofNumber(e)}static makeValue(s,e,t){if(e==="null")return null;if(m.isTextType(s))return e;if(m.isLongType(s))return c.LongWrapper.ofString(m.removeCommas(e));if(m.isBooleanType(s))return m.makeBooleanValue(e,!0);if(m.isDateType(s)){const[n]=se.parseDateRange(e,t);return n}return m.isNumberType(s)?m.makeNumberValue(e):(q.error("Unexpected column type",s),null)}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=m.removeCommas(e);if(m.NUMBER_REGEX.test(t))return parseFloat(t);throw new Error(`Invalid number '${s}'`)}static getFilterOperatorString(s){switch(s){case g.eq:return"=";case g.notEq:return"!=";case g.greaterThan:return">";case g.greaterThanOrEqualTo:return">=";case g.lessThan:return"<";case g.lessThanOrEqualTo:return"<=";case g.contains:return"~";case g.notContains:return"!~";default:throw new Error(`Unexpected filter type ${s}`)}}static makeAdvancedValueFilter(s,e,t,n){if(m.isDateType(s.type))return m.makeQuickDateFilterWithOperation(s,t,e,n);if(m.isNumberType(s.type)||m.isCharType(s.type))return m.makeQuickFilter(s,`${m.getFilterOperatorString(e)}${t}`);const r=m.makeFilterValue(s.type,t),i=s.filter();switch(e){case g.eq:return i.eq(r);case g.eqIgnoreCase:return i.eqIgnoreCase(r);case g.notEq:return i.notEq(r);case g.notEqIgnoreCase:return i.notEqIgnoreCase(r);case g.greaterThan:return i.greaterThan(r);case g.greaterThanOrEqualTo:return i.greaterThanOrEqualTo(r);case g.lessThan:return i.lessThan(r);case g.lessThanOrEqualTo:return i.lessThanOrEqualTo(r);case g.isTrue:return i.isTrue();case g.isFalse:return i.isFalse();case g.isNull:return i.isNull();case g.contains:return i.isNull().not().and(i.invoke("matches",c.FilterValue.ofString(`(?s)(?i).*\\Q${t}\\E.*`)));case g.notContains:return i.isNull().or(i.invoke("matches",c.FilterValue.ofString(`(?s)(?i).*\\Q${t}\\E.*`)).not());case g.startsWith:return i.isNull().not().and(i.invoke("matches",c.FilterValue.ofString(`(?s)(?i)^\\Q${t}\\E.*`)));case g.endsWith:return i.isNull().not().and(i.invoke("matches",c.FilterValue.ofString(`(?s)(?i).*\\Q${t}\\E$`)));case g.in:case g.inIgnoreCase:case g.notIn:case g.notInIgnoreCase:case g.invoke:default:throw new Error(`Unexpected filter operation: ${e}`)}}static makeSelectValueFilter(s,e,t){if(e.length===0){if(t)return null;let i=null;m.isTextType(s.type)?i=c.FilterValue.ofString("a"):m.isBooleanType(s.type)?i=c.FilterValue.ofBoolean(!0):m.isDateType(s.type)?i=c.FilterValue.ofNumber(c.DateWrapper.ofJsDate(new Date)):i=c.FilterValue.ofNumber(0);const a=s.filter().eq(i),l=s.filter().notEq(i);return a.and(l)}const n=[];let r=!1;for(let i=0;i<e.length;i+=1){const a=e[i];a==null?r=!0:m.isTextType(s.type)?n.push(c.FilterValue.ofString(typeof a=="number"?String.fromCharCode(a):a)):m.isBooleanType(s.type)?n.push(c.FilterValue.ofBoolean(Boolean(a))):n.push(c.FilterValue.ofNumber(a))}return r?n.length>0?t?s.filter().isNull().not().and(s.filter().notIn(n)):s.filter().isNull().or(s.filter().in(n)):t?s.filter().isNull().not():s.filter().isNull():t?s.filter().notIn(n):s.filter().in(n)}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 r=t.name.toUpperCase(),i=n.name.toUpperCase();return ct.sort(r,i,e)})}};let W=m;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,r=!1){u(this,"defaultColumnFormatter");u(this,"typeFormatterMap");u(this,"columnFormatMap");u(this,"truncateNumbersWithPound");this.defaultColumnFormatter=new yt,this.typeFormatterMap=new Map([[U.dataType.BOOLEAN,new mt],[U.dataType.CHAR,new ft],[U.dataType.DATETIME,new Te(e)],[U.dataType.DECIMAL,new V(t)],[U.dataType.INT,new ae(n)],[U.dataType.STRING,new bt]]),this.columnFormatMap=Pe.makeColumnFormatMap(s),this.truncateNumbersWithPound=r}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 r=e.get(n);return r==null||r.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 r=this.getColumnTypeFormatter(e),i=n||this.getColumnFormat(e,t);return r.format(s,i??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(f){if(f&&f.formatter){const{formatter:s}=f;return s}}function Mt(f){return{timeZone:f==null?void 0:f.timeZone,defaultDateTimeFormatString:f==null?void 0:f.defaultDateTimeFormat,showTimeZone:f==null?void 0:f.showTimeZone,showTSeparator:f==null?void 0:f.showTSeparator}}function At(f,s,e){const t=f.getColumnFormat(e,s);return t!=null&&(t.type===x.TYPE_CONTEXT_PRESET||t.type===x.TYPE_CONTEXT_CUSTOM)}const we={getColumnFormats:Dt,getDateTimeFormatterOptions:Mt,isCustomColumnFormatDefined:At};Ae.register([Je,et,tt,st,nt,rt]);const Nt=typeof Ie=="function"?Ie(Ae):Ie.default(Ae),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 H=j;u(H,"EVENT_UPDATED","ChartModel.EVENT_UPDATED"),u(H,"EVENT_DISCONNECT","ChartModel.EVENT_DISCONNECT"),u(H,"EVENT_RECONNECT","ChartModel.EVENT_RECONNECT"),u(H,"EVENT_DOWNSAMPLESTARTED","ChartModel.EVENT_DOWNSAMPLESTARTED"),u(H,"EVENT_DOWNSAMPLEFINISHED","ChartModel.EVENT_DOWNSAMPLEFINISHED"),u(H,"EVENT_DOWNSAMPLEFAILED","ChartModel.EVENT_DOWNSAMPLEFAILED"),u(H,"EVENT_DOWNSAMPLENEEDED","ChartModel.EVENT_DOWNSAMPLENEEDED"),u(H,"EVENT_LOADFINISHED","ChartModel.EVENT_LOADFINISHED");const z=H,It="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",wt="#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:It,gridcolor:wt,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"]}),fe=Z.module("ChartUtils"),G=Object.freeze(c.calendar.DayOfWeek.values()),Ve="io.deephaven.time.DateTime",Ot=36e5,Lt=1e6;function kt(f){return f.asDate!==void 0}function Rt(f){return f.asNumber!==void 0}function He(f){return f.dhTimeZone!==void 0}function $t(f){return f!=null&&f.range!=null&&(f.autorange===!1||f.autorange===void 0)}const p=class{static getPlotlyChartType(s,e){switch(s){case c.plot.SeriesPlotStyle.SCATTER:return e?"scatter":"scattergl";case c.plot.SeriesPlotStyle.LINE:return"scatter";case c.plot.SeriesPlotStyle.BAR:case c.plot.SeriesPlotStyle.STACKED_BAR:return"bar";case c.plot.SeriesPlotStyle.PIE:return"pie";case c.plot.SeriesPlotStyle.TREEMAP:return"treemap";case c.plot.SeriesPlotStyle.HISTOGRAM:return"histogram";case c.plot.SeriesPlotStyle.OHLC:return"ohlc";default:return}}static getPlotlyChartMode(s,e,t){const n=new Set;switch(s){case c.plot.SeriesPlotStyle.SCATTER:(e??!1)&&n.add(p.MODE_LINES),(t??!0)&&n.add(p.MODE_MARKERS);break;case c.plot.SeriesPlotStyle.LINE:(e??!0)&&n.add(p.MODE_LINES),(t??!1)&&n.add(p.MODE_MARKERS);break}return n.size>0?[...n].join("+"):void 0}static getPlotlyProperty(s,e){switch(s){case c.plot.SeriesPlotStyle.PIE:switch(e){case c.plot.SourceType.X:return"labels";case c.plot.SourceType.Y:return"values"}break;case c.plot.SeriesPlotStyle.OHLC:switch(e){case c.plot.SourceType.TIME:return"x"}break;case c.plot.SeriesPlotStyle.TREEMAP:switch(e){case c.plot.SourceType.X:return"ids";case c.plot.SourceType.Y:return"values";case c.plot.SourceType.LABEL:return"labels";case c.plot.SourceType.PARENT:return"parents";case c.plot.SourceType.COLOR:return"marker.colors"}break}switch(e){case c.plot.SourceType.X:return"x";case c.plot.SourceType.Y:return"y";case c.plot.SourceType.Z:return"z";case c.plot.SourceType.X_LOW:return"xLow";case c.plot.SourceType.X_HIGH:return"xHigh";case c.plot.SourceType.Y_LOW:return"yLow";case c.plot.SourceType.Y_HIGH:return"yHigh";case c.plot.SourceType.TIME:return"time";case c.plot.SourceType.OPEN:return"open";case c.plot.SourceType.HIGH:return"high";case c.plot.SourceType.LOW:return"low";case c.plot.SourceType.CLOSE:return"close";case c.plot.SourceType.SHAPE:return"shape";case c.plot.SourceType.SIZE:return"size";case c.plot.SourceType.LABEL:return"label";case c.plot.SourceType.COLOR:return"color";case c.plot.SourceType.PARENT:return"parent";case c.plot.SourceType.HOVER_TEXT:return"hovertext";case c.plot.SourceType.TEXT:return"text";default:throw new Error(`Unrecognized source type: ${e}`)}}static getPlotlySeriesOrientation(s){var t,n;const{sources:e}=s;return e.length===2&&((n=(t=e[0])==null?void 0:t.axis)==null?void 0:n.type)===c.plot.AxisType.Y?p.ORIENTATION.HORIZONTAL:p.ORIENTATION.VERTICAL}static getPlotlyErrorBars(s,e,t){const n=t.map((i,a)=>i-s[a]),r=e.map((i,a)=>s[a]-i);return{type:"data",symmetric:!1,array:n,arrayminus:r}}static getPlotlyDateFormat(s,e,t){const n=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 r;const i=s==null?void 0:s.getColumnTypeFormatter(e);return i!=null&&He(i)&&i.dhTimeZone!=null&&i.showTimeZone&&(r=c.i18n.DateTimeFormat.format(" z",new Date,i.dhTimeZone)),{tickformat:n,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 r=t.split(";")[0].match(/^([^#,0.]*)([#,]*)([0,]*)(\.?)(0*)(#*)(E?0*)(%?)(.*)/);ge(r);const[,i,a,l,,o,d,h,T,S]=r,E=l.replace(",","").length,A=a.indexOf(",")>=0||l.indexOf(",")>=0?",":"",y=h!=null&&h!==""?"e":"f",M=T!==""?T:y,F=o.length+d.length,P=`0${E}${A}.${F}${M}`,R=p.convertNumberPrefix(i),$=p.convertNumberPrefix(S);return{tickformat:P,tickprefix:R,ticksuffix:$,automargin:!0}}static getPlotlyAxisFormat(s,e=null){const{axis:t,columnType:n}=s,{formatPattern:r}=t;let i=null;return W.isDateType(n)?(i=p.getPlotlyDateFormat(e,n,r),i=p.addTickSpacing(i,t,!0)):W.isNumberType(n)&&(i=p.getPlotlyNumberFormat(e,n,r),i=p.addTickSpacing(i,t,!1)),t.formatType===c.plot.AxisFormatType.CATEGORY&&(i?i.type="category":i={type:"category",tickformat:void 0,ticksuffix:void 0}),i}static addTickSpacing(s,e,t){const{gapBetweenMajorTicks:n}=e;if(n>0){const r=s||{};let i=n;return t&&(i=n/Lt),e.log&&(i=Math.log(i)),r.tickmode="linear",r.dtick=i,r}return s}static getSourceForAxis(s,e){for(let t=0;t<s.series.length;t+=1){const n=s.series[t];for(let r=0;r<n.sources.length;r+=1){const i=n.sources[r];if(i.axis===e)return i}}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,r=p.ORIENTATION.VERTICAL){return{type:s,mode:e,name:t,orientation:r,showlegend:n??void 0}}static makeSeriesDataFromSeries(s,e,t,n=null,r=B){const{name:i,isLinesVisible:a,isShapesVisible:l,plotStyle:o,lineColor:d,shapeColor:h,sources:T,shape:S,shapeSize:E}=s,b=T.some(C=>{var P;return(P=C.axis)==null?void 0:P.businessCalendar}),A=p.getChartType(o,b),y=p.getPlotlyChartMode(o,a??void 0,l??void 0),M=p.getPlotlySeriesOrientation(s),F=p.makeSeriesData(A,y,i,n,M);return p.addSourcesToSeriesData(F,o,T,e),p.addStylingToSeriesData(F,o,r,d,h,S,E,t),F}static addSourcesToSeriesData(s,e,t,n){const r=s;for(let i=0;i<t.length;i+=1){const a=t[i],{axis:l,type:o}=a,d=p.getPlotlyProperty(e,o);je(r,d,[]);const h=l!=null?p.getAxisPropertyName(l.type):null;if(h!=null){const T=n.get(l.type);if(T){const S=T.indexOf(l),E=S>0?`${S+1}`:"";r[`${h}axis`]=`${h}${E}`}}}}static addStylingToSeriesData(s,e,t=B,n=null,r=null,i=null,a=null,l=null){const o=s;if(o.marker={line:{}},o.line={width:1},e===c.plot.SeriesPlotStyle.AREA?o.fill="tozeroy":e===c.plot.SeriesPlotStyle.STACKED_AREA?o.stackgroup="stack":e===c.plot.SeriesPlotStyle.STEP?o.line.shape="hv":e===c.plot.SeriesPlotStyle.HISTOGRAM?(o.width=[],o.marker.line!==void 0&&Object.assign(o.marker.line,{color:t.paper_bgcolor,width:1})):e===c.plot.SeriesPlotStyle.OHLC?(o.increasing={line:{color:t.ohlc_increasing}},o.decreasing={line:{color:t.ohlc_decreasing}}):e===c.plot.SeriesPlotStyle.PIE?(o.textinfo="label+percent",o.outsidetextfont={color:t.title_color}):e===c.plot.SeriesPlotStyle.TREEMAP&&(o.hoverinfo="text",o.textinfo="label+text",o.tiling={packing:"squarify",pad:0},o.textposition="middle center",o.outsidetextfont={color:t.title_color}),n!=null&&(e===c.plot.SeriesPlotStyle.BAR?o.marker.color=n:o.line.color=n),r!=null&&(o.marker.color=r),i!=null&&i.length>0)try{o.marker.symbol=p.getMarkerSymbol(i)}catch(d){fe.warn("Unable to handle shape",i,":",d)}a!=null&&(o.marker.size=a*p.DEFAULT_MARKER_SIZE),l!=null&&e!==c.plot.SeriesPlotStyle.PIE&&(o.visible=l)}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 getAxisFormats(s,e){const t=new Map,n={tickformat:null,ticksuffix:null},r=p.getAllAxes(s),i=p.groupArray(r,"type"),{charts:a}=s;for(let l=0;l<a.length;l+=1){const o=a[l];for(let d=0;d<o.series.length;d+=1){const h=o.series[d],{sources:T}=h,S=T.filter(E=>E.axis);for(let E=0;E<S.length;E+=1){const b=S[E],{axis:A}=b,{type:y}=A,M=i.get(y);ge(M);const F=M.indexOf(A),C=p.getAxisPropertyName(y);if(C!=null){const P=p.getAxisLayoutProperty(C,F);if(t.has(P))fe.debug(`${P} already added.`);else{fe.debug(`Adding ${P} to axisFormats.`);const R=p.getPlotlyAxisFormat(b,e);if(R===null)t.set(P,n);else{t.set(P,R);const{businessCalendar:$}=A;if($!=null){const L=[],{businessPeriods:ce,businessDays:ne,holidays:re,timeZone:ue}=$,de=e==null?void 0:e.getColumnTypeFormatter(Ve);let ie;He(de)&&(ie=de.dhTimeZone);const he=ie?(ue.standardOffset-ie.standardOffset)/60:0;re.length>0&&L.push(...p.createRangeBreakValuesFromHolidays(re,ue,ie)),ce.forEach(Q=>L.push({pattern:"hour",bounds:[p.periodToDecimal(Q.close)+he,p.periodToDecimal(Q.open)+he]})),ne.length<G.length&&p.createBoundsFromDays(ne).forEach(Q=>L.push({pattern:"day of week",bounds:Q})),R.rangebreaks=L}if(t.size===o.axes.length)return t}}}}}}return t}static getChartType(s,e){switch(s){case c.plot.SeriesPlotStyle.HISTOGRAM:return"bar";default:return p.getPlotlyChartType(s,e)}}static getAxisPropertyName(s){switch(s){case c.plot.AxisType.X:return"x";case c.plot.AxisType.Y:return"y";default:return null}}static getAxisSide(s){switch(s){case c.plot.AxisPosition.BOTTOM:return"bottom";case c.plot.AxisPosition.TOP:return"top";case c.plot.AxisPosition.LEFT:return"left";case c.plot.AxisPosition.RIGHT:return"right";default:return}}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 r=t[n];for(let i=0;i<r.series.length;i+=1)if(e===r.series[i])return r}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 r=t[n],i=s[r];$t(i)&&(e[r]=[...i.range])}return e}static updateFigureAxes(s,e,t,n=0,r=0,i=B){const a=s,l=p.getAllAxes(e);for(let o=0;o<e.charts.length;o+=1){const d=e.charts[o],h=t==null?void 0:t(d),T=p.getChartBounds(e,d,n,r);p.updateLayoutAxes(a,d.axes,l,n,r,T,h,i)}p.removeStaleAxes(a,l)}static getChartBounds(s,e,t,n){const{cols:r,rows:i}=s,{column:a,colspan:l,row:o,rowspan:d}=e,h=a+l,T=o+d,S=1/r,E=1/i,b=p.AXIS_SIZE_PX/t,A=p.AXIS_SIZE_PX/n,y={bottom:(i-T)*E+(T<i?A/2:0),top:(i-o)*E-(o>0?A/2:0),left:a*S+(a>0?b/2:0),right:h*S-(h<r?b/2:0)};return(p.groupArray(e.axes,"position").get(c.plot.AxisPosition.RIGHT)??[]).length>0&&(t>0?y.right-=(y.right-y.left)*Math.max(0,Math.min(p.LEGEND_WIDTH_PX/t,p.MAX_LEGEND_SIZE)):y.right-=(y.right-y.left)*p.DEFAULT_AXIS_SIZE),y}static updateLayoutAxes(s,e,t,n=0,r=0,i={left:0,top:0,right:1,bottom:1},a,l=B){const o=n>0?Math.max(p.MIN_AXIS_SIZE,Math.min(p.AXIS_SIZE_PX/r,p.MAX_AXIS_SIZE)):p.DEFAULT_AXIS_SIZE,d=r>0?Math.max(p.MIN_AXIS_SIZE,Math.min(p.AXIS_SIZE_PX/n,p.MAX_AXIS_SIZE)):p.DEFAULT_AXIS_SIZE,h=s,T=p.groupArray(e,"position"),S=p.groupArray(e,"type"),E=[...S.keys()],b=p.groupArray(t,"type");for(let A=0;A<E.length;A+=1){const y=E[A],M=p.getAxisPropertyName(y);if(M!=null){const F=S.get(y),C=b.get(y),R=y===c.plot.AxisType.Y?r:n;ge(F),ge(C);for(let $=0;$<F.length;$+=1){const L=F[$],ce=C.indexOf(L),ne=p.getAxisLayoutProperty(M,ce);h[ne]==null&&(h[ne]=p.makeLayoutAxis(y,l));const re=h[ne];if(re!=null){p.updateLayoutAxis(re,L,$,T,o,d,i);const{range:ue,autorange:de}=re;if(a!=null&&ue!==void 0&&(de===void 0||de===!1)){const ie=a(L),[he,Q]=ie(ue);fe.debug("Setting downsample range",R,he,Q),L.range(R,he,Q)}else L.range(R)}}}}}static removeStaleAxes(s,e){const t=s,n=p.groupArray(e,"type"),r=[...n.keys()];for(let i=0;i<r.length;i+=1){const a=r[i],l=n.get(a);ge(l);let o=l.length;const d=p.getAxisPropertyName(a);if(d!=null){let h=p.getAxisLayoutProperty(d,o);for(;t[h]!=null;)delete t[h],o+=1,h=p.getAxisLayoutProperty(d,o)}}}static getAxisLayoutProperty(s,e){const t=e>0?`${e+1}`:"";return`${s??""}axis${t}`}static updateLayoutAxis(s,e,t,n,r,i,a){const o=e.type===c.plot.AxisType.Y?i:r,d=s,h=e.label??"";if(d.title!==void 0&&typeof d.title!="string"?d.title.text=h:d.title={text:h},e.log&&(d.type="log"),d.side=p.getAxisSide(e.position),t>0){d.overlaying=p.getAxisPropertyName(e.type)??void 0;const T=n.get(e.position)??[],S=T.indexOf(e);S>0&&(d.anchor="free",e.position===c.plot.AxisPosition.RIGHT?d.position=a.right+(S-T.length+1)*o:e.position===c.plot.AxisPosition.TOP?d.position=a.top+(S-T.length+1)*o:e.position===c.plot.AxisPosition.BOTTOM?d.position=a.bottom+(T.length-S+1)*o:e.position===c.plot.AxisPosition.LEFT&&(d.position=a.left+(T.length-S+1)*o))}else if(e.type===c.plot.AxisType.X){const T=n.get(c.plot.AxisPosition.LEFT)||[],S=n.get(c.plot.AxisPosition.RIGHT)||[],E=Math.max(a.left,a.left+(T.length-1)*i),b=Math.min(a.right-(S.length-1)*i,a.right);d.domain=[E,b]}else if(e.type===c.plot.AxisType.Y){const T=n.get(c.plot.AxisPosition.BOTTOM)||[],S=n.get(c.plot.AxisPosition.TOP)||[],E=Math.max(a.bottom,a.bottom+(T.length-1)*r),b=Math.min(a.top-(S.length-1)*r,a.top);d.domain=[E,b]}}static periodToDecimal(s){const e=s.split(":");return Number(e[0])+Number(e[1])/60}static createBoundsFromDays(s){const e=s.map(i=>G.indexOf(i)),t=G.filter(i=>!s.includes(i)).map(i=>G.indexOf(i)),n=new Set;t.forEach(i=>{for(let a=i+1;a<i+G.length;a+=1){const l=a%G.length;if(e.includes(l)){n.add(l);break}}});const r=[];return n.forEach(i=>{for(let a=i-1;a>i-G.length;a-=1){const l=a<0?a+G.length:a;if(e.includes(l)){const o=(l+1)%7;r.push([o,i]);break}}}),r}static createRangeBreakValuesFromHolidays(s,e,t){const n=[],r=[];return s.forEach(i=>{i.businessPeriods.length>0?r.push(...p.createPartialHoliday(i,e,t)):n.push(p.createFullHoliday(i,e,t))}),[{values:n},...r]}static createFullHoliday(s,e,t){return p.adjustDateForTimeZone(`${s.date.toString()} 00:00:00.000000`,e,t)}static createPartialHoliday(s,e,t){const n=s.date.toString(),r=["00:00"];s.businessPeriods.forEach(a=>{r.push(a.open),r.push(a.close)}),r.push("24:00");const i=[];for(let a=0;a<r.length;a+=2){const l=r[a],o=r[a+1];if(l!==o){const d=[p.adjustDateForTimeZone(`${n} ${l}:00.000000`,e,t)],h=Ot*(p.periodToDecimal(o)-p.periodToDecimal(l));i.push({values:d,dvalue:h})}}return i}static adjustDateForTimeZone(s,e,t){return t&&t.standardOffset!==e.standardOffset?p.unwrapValue(p.wrapValue(s,Ve,e),t):s}static groupArray(s,e){return s.reduce((t,n)=>{const r=n[e],i=t.get(r)??[];return i.push(n),t.set(r,i),t},new Map)}static unwrapValue(s,e){if(s!=null){if(kt(s))return c.i18n.DateTimeFormat.format(p.DATE_FORMAT,s,e);if(Rt(s))return s.asNumber()}return s}static wrapValue(s,e,t=null){if(W.isDateType(e)&&typeof s=="string"){const n=s,r=p.DATE_FORMAT.substr(0,s.length),i=c.i18n.DateTimeFormat.parse(r,n);if(!t)return i;const a=`${r} Z`,l=c.i18n.DateTimeFormat.format("Z",i,t),o=c.i18n.DateTimeFormat.parse(a,`${n} ${l}`),d=c.i18n.DateTimeFormat.format("Z",o,t);return c.i18n.DateTimeFormat.parse(a,`${n} ${d}`)}return s}static makeLayoutAxis(s,e=B){const t={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===c.plot.AxisType.X?Object.assign(t,{showgrid:!0}):s===c.plot.AxisType.Y&&Object.assign(t,{zerolinecolor:e.zerolinecolor,zerolinewidth:2}),t}static getColorwayFromTheme(s=B){let e=[];return s.colorway&&(Array.isArray(s.colorway)?e=s.colorway:typeof s.colorway=="string"?e=s.colorway.split(" "):fe.warn(`Unable to handle colorway property: ${s.colorway}`)),e}static makeDefaultLayout(s=B){const e={...s,autosize:!0,colorway:p.getColorwayFromTheme(s),font:{family:"'Fira Sans', sans-serif"},title:{font:{color:s.title_color},yanchor:"top",pad:{...p.DEFAULT_TITLE_PADDING},y:1},legend:{font:{color:s.title_color}},margin:{...p.DEFAULT_MARGIN},xaxis:p.makeLayoutAxis(c.plot.AxisType.X,s),yaxis:p.makeLayoutAxis(c.plot.AxisType.Y,s)};return e.datarevision=0,e}static hydrateSettings(s){return{...s,type:s.type!=null?c.plot.SeriesPlotStyle[s.type]:void 0}}static titleFromSettings(s){const{series:e,xAxis:t,title:n=`${(e??[]).join(", ")} by ${t}`}=s;return n}static makeFigureSettings(s,e){const{series:t,xAxis:n,type:r}=s,i=p.titleFromSettings(s),a={formatType:`${c.plot.AxisFormatType.NUMBER}`,type:`${c.plot.AxisType.X}`,position:`${c.plot.AxisPosition.BOTTOM}`},l={formatType:`${c.plot.AxisFormatType.NUMBER}`,type:`${c.plot.AxisType.Y}`,position:`${c.plot.AxisPosition.LEFT}`};return{charts:[{chartType:`${c.plot.ChartType.XY}`,axes:[a,l],series:(t??[]).map(o=>({plotStyle:`${r}`,name:o,dataSources:[{type:`${c.plot.SourceType.X}`,columnName:n??"",axis:a,table:e},{type:`${c.plot.SourceType.Y}`,columnName:o,axis:l,table:e}]}))}],title:i}}};let I=p;u(I,"DEFAULT_AXIS_SIZE",.15),u(I,"MIN_AXIS_SIZE",.025),u(I,"MAX_AXIS_SIZE",.2),u(I,"AXIS_SIZE_PX",75),u(I,"LEGEND_WIDTH_PX",50),u(I,"MAX_LEGEND_SIZE",.25),u(I,"ORIENTATION",Object.freeze({HORIZONTAL:"h",VERTICAL:"v"})),u(I,"DATE_FORMAT","yyyy-MM-dd HH:mm:ss.SSSSSS"),u(I,"DEFAULT_MARGIN",Object.freeze({l:60,r:50,t:30,b:60,pad:0})),u(I,"DEFAULT_TITLE_PADDING",Object.freeze({t:8})),u(I,"SUBTITLE_LINE_HEIGHT",25),u(I,"DEFAULT_MARKER_SIZE",6),u(I,"MODE_MARKERS","markers"),u(I,"MODE_LINES","lines");const N=I;const Y=Z.module("Chart"),le=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",ze((e,t,n,r)=>{const i=[],a=Boolean(e);if(a&&i.push({name:`Downsampling failed: ${e}`,click:()=>{},icon:le.convertIcon(Ye),attr:"fill-warning"}),t||n||r||a){const l=le.downsampleButtonTitle(n,r),o=le.downsampleButtonAttr(n,r),d=n?Ke:_e;i.push({name:l,icon:le.convertIcon(d),click:this.handleDownsampleClick,attr:o})}return{displaylogo:!1,displayModeBar:n||a?!0:"hover",modeBarButtons:[i,["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,r=`${n}`;return{width:t,path:r,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){Y.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(Y.debug2("Received data update",t,n),t){case z.EVENT_UPDATED:{this.currentSeries+=1,this.setState(i=>{const{layout:a,revision:l}=i;return typeof a.datarevision=="number"&&(a.datarevision+=1),{data:n,layout:a,revision:l+1}});const{onUpdate:r}=this.props;r({isLoading:!this.isLoadedFired});break}case z.EVENT_LOADFINISHED:{const{onUpdate:r}=this.props;this.isLoadedFired=!0,r({isLoading:!1});break}case z.EVENT_DISCONNECT:{const{onDisconnect:r}=this.props;r();break}case z.EVENT_RECONNECT:{const{onReconnect:r}=this.props;r();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 r=n.message??n;this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,downsamplingError:r});const{onError:i}=this.props;i(new Error(r));break}default:Y.debug("Unknown event type",t,e)}}handlePlotUpdate(e){const{layout:t}=e,n=N.getLayoutRanges(t);!pe(n,this.ranges)&&(this.ranges=n,this.updateModelDimensions(!0))}handleRelayout(e){if(Y.debug("handleRelayout",e),e.hiddenlabels!=null){const{onSettingsChanged:t}=this.props,n=[...e.hiddenlabels];t({hiddenSeries:n})}this.updateModelDimensions()}handleRestyle([e,t]){if(Y.debug("handleRestyle",e,t),Object.keys(e).includes("visible")){const{data:n}=this.state,{onSettingsChanged:r}=this.props;if(n!=null){const i=n.reduce((a,{name:l,visible:o})=>l!=null&&o==="legendonly"?[...a,l]:a,[]);r({hiddenSeries:i})}}}updateModelDimensions(e=!1){const t=this.getPlotRect();if(!t){Y.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:r,model:i}=this.props;i.setDimensions(t),r&&this.subscribe()}}initFormatter(){const{settings:e}=this.props;this.updateFormatterSettings(e)}updateFormatterSettings(e){const t=we.getColumnFormats(e),n=we.getDateTimeFormatterOptions(e),{decimalFormatOptions:r={},integerFormatOptions:i={}}=e;(!pe(this.columnFormats,t)||!pe(this.dateTimeFormatterOptions,n)||!pe(this.decimalFormatOptions,r)||!pe(this.integerFormatOptions,i))&&(this.columnFormats=we.getColumnFormats(e),this.dateTimeFormatterOptions=n,this.decimalFormatOptions=r,this.integerFormatOptions=i,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&&Ae.relayout(this.plot.current.el,{autosize:!0}).catch(t=>{Y.debug("Unable to resize, promise rejected",t)})}render(){const{data:e,downsamplingError:t,isDownsampleFinished:n,isDownsampleInProgress:r,isDownsamplingDisabled:i,layout:a,revision:l}=this.state,o=this.getCachedConfig(t,n,r,i),d=e!=null;return D.jsx("div",{className:"h-100 w-100 chart-wrapper",ref:this.plotWrapper,children:d&&D.jsx(Nt,{ref:this.plot,data:e,layout:a,revision:l,config:o,onAfterPlot:this.handleAfterPlot,onError:Y.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}};let De=le;u(De,"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=De,v=Z.module("FigureChartModel"),Oe=class extends z{constructor(e,t={},n=B){super();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",Xe(()=>{const e=N.getAllAxes(this.figure),{pendingSeries:t}=this;for(let n=0;n<t.length;n+=1){const r=t[n],i=this.figure.charts.find(a=>a.series.includes(r));this.addSeries(r,e,(i==null?void 0:i.showLegend)??null),r.subscribe()}this.pendingSeries=[]},Oe.ADD_SERIES_DEBOUNCE));u(this,"getTimeZone",me((e,t)=>{if(t!=null){const n=t.getColumnTypeFormatter(e);if(n!=null)return n.dhTimeZone}}));u(this,"getValueTranslator",me((e,t)=>{const n=this.getTimeZone(e,t);return r=>N.unwrapValue(r,n)}));u(this,"getValueParser",me((e,t)=>{const n=this.getTimeZone(e,t);return r=>N.wrapValue(r,e,n)}));u(this,"getRangeParser",me((e,t)=>n=>{let[r,i]=n;const a=this.getValueParser(e,t);return r=a(r),i=a(i),[r,i]}));u(this,"getAxisRangeParser",me((e,t)=>n=>{const r=N.getSourceForAxis(e,n);return r?this.getRangeParser(r.columnType,t):i=>i}));this.handleFigureUpdated=this.handleFigureUpdated.bind(this),this.handleFigureDisconnected=this.handleFigureDisconnected.bind(this),this.handleFigureReconnected=this.handleFigureReconnected.bind(this),this.handleFigureSeriesAdded=this.handleFigureSeriesAdded.bind(this),this.handleDownsampleStart=this.handleDownsampleStart.bind(this),this.handleDownsampleFinish=this.handleDownsampleFinish.bind(this),this.handleDownsampleFail=this.handleDownsampleFail.bind(this),this.handleDownsampleNeeded=this.handleDownsampleNeeded.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.figure=e,this.settings=t,this.theme=n,this.data=[];const r={data:{},layout:N.makeDefaultLayout(n)};this.layout={grid:{rows:e.rows,columns:e.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()}getDefaultTitle(){return this.figure.charts.length>0?this.figure.charts[0].title:""}initAllSeries(){this.oneClicks=[],this.filterColumnMap.clear();const{charts:e}=this.figure,t=N.getAllAxes(this.figure),n=[];for(let a=0;a<e.length;a+=1){const l=e[a];for(let o=0;o<l.series.length;o+=1){const d=l.series[o];n.push(d.name),this.addSeries(d,t,l.showLegend)}}const i=[...this.seriesDataMap.keys()].filter(a=>n.indexOf(a)<0);for(let a=0;a<i.length;a+=1){const l=i[a];this.seriesDataMap.delete(l)}this.seriesToProcess=new Set([...this.seriesDataMap.keys()])}addSeries(e,t,n){const r=N.groupArray(t,"type"),i=N.makeSeriesDataFromSeries(e,r,N.getSeriesVisibility(e.name,this.settings),n,this.theme);if(this.seriesDataMap.set(e.name,i),this.data=[...this.seriesDataMap.values()],e.plotStyle===c.plot.SeriesPlotStyle.STACKED_BAR?this.layout.barmode="stack":e.plotStyle===c.plot.SeriesPlotStyle.PIE&&(this.layout.hiddenlabels=N.getHiddenLabels(this.settings)),this.layout.showlegend=this.data.length>1||e.plotStyle===c.plot.SeriesPlotStyle.PIE?n??void 0:!1,e.oneClick!=null){const{oneClick:a}=e,{columns:l}=a;for(let o=0;o<l.length;o+=1)this.filterColumnMap.set(l[o].name,l[o]);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){v.debug("Ignoring subscribe when figure in disconnected state");return}this.figure.subscribe(this.isDownsamplingDisabled?c.plot.DownsampleOptions.DISABLE:c.plot.DownsampleOptions.DEFAULT)}unsubscribeFigure(){this.figure.unsubscribe()}startListeningFigure(){this.figure.addEventListener(c.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.addEventListener(c.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.addEventListener(c.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.addEventListener(c.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.addEventListener(c.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.addEventListener(c.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.addEventListener(c.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.addEventListener(c.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.addEventListener(c.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}stopListeningFigure(){this.figure.removeEventListener(c.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.removeEventListener(c.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.removeEventListener(c.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.removeEventListener(c.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.removeEventListener(c.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.removeEventListener(c.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.removeEventListener(c.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.removeEventListener(c.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.removeEventListener(c.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}handleDownsampleStart(e){v.debug("Downsample started",e),this.fireDownsampleStart(e.detail)}handleDownsampleFinish(e){v.debug("Downsample finished",e),this.fireDownsampleFinish(e.detail)}handleDownsampleFail(e){v.error("Downsample failed",e),this.fireDownsampleFail(e.detail)}handleDownsampleNeeded(e){v.info("Downsample needed",e),this.fireDownsampleNeeded(e.detail)}handleFigureUpdated(e){const{detail:t}=e,{series:n}=t;v.debug2("handleFigureUpdated",n);for(let i=0;i<n.length;i+=1){const a=n[i];v.debug2("handleFigureUpdated updating series",a.name);const{sources:l}=a;for(let o=0;o<l.length;o+=1){const d=l[o],{columnType:h,type:T}=d,S=this.getValueTranslator(h,this.formatter),E=t.getArray(a,T,S);this.setDataArrayForSeries(a,T,E)}this.seriesToProcess.delete(a.name),this.seriesToProcess.size===0&&this.fireLoadFinished(),this.cleanSeries(a)}const{data:r}=this;this.fireUpdate(r)}handleRequestFailed(e){v.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){v.debug("Figure disconnected",e),this.isConnected=!1,this.listeners.length>0&&this.unsubscribeFigure(),this.fireDisconnect()}handleFigureReconnected(e){v.debug("Figure reconnected",e),this.isConnected=!0,this.initAllSeries(),this.fireReconnect(),this.listeners.length>0&&this.subscribeFigure()}handleFigureSeriesAdded(e){const{detail:t}=e;v.debug("handleFigureSeriesAdded",t),this.pendingSeries.push(t),this.addPendingSeries()}setDimensions(e){super.setDimensions(e),this.updateAxisPositions()}setTitle(e){var r;super.setTitle(e);const t=((r=(e??"").match(/<br>/g))==null?void 0:r.length)??0,n=N.DEFAULT_MARGIN.t+t*N.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=N.DEFAULT_TITLE_PADDING.t+t*N.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();N.updateFigureAxes(this.layout,this.figure,n=>this.getAxisRangeParser(n,this.formatter),e,t,this.theme)}updateLayoutFormats(){if(!this.formatter)return;N.getAxisFormats(this.figure,this.formatter).forEach((t,n)=>{v.debug(`Assigning ${n}`,this.layout[n],t);const r=this.layout[n];r!=null?Object.assign(r,t):v.debug(`Ignoring null layout.${n}`)})}setDataArrayForSeries(e,t,n){const{name:r,plotStyle:i}=e,a=this.seriesDataMap.get(r),l=N.getPlotlyProperty(i,t);a&&je(a,l,n)}cleanSeries(e){const{name:t,plotStyle:n}=e,r=this.seriesDataMap.get(t);if(r!=null){if(n===c.plot.SeriesPlotStyle.HISTOGRAM){const{xLow:i,xHigh:a}=r;if(i&&a&&i.length===a.length){const l=[];for(let o=0;o<i.length;o+=1)l.push(a[o]-i[o]);r.width=l}}else if(n===c.plot.SeriesPlotStyle.LINE){const{x:i,xLow:a,xHigh:l,y:o,yLow:d,yHigh:h}=r;a&&l&&a!==i&&(r.error_x=N.getPlotlyErrorBars(i,a,l)),d&&h&&d!==o&&(r.error_y=N.getPlotlyErrorBars(o,d,h))}else if(n===c.plot.SeriesPlotStyle.TREEMAP){const{ids:i,labels:a}=r;i!==void 0&&a===void 0&&(r.labels=i)}}}getData(){return this.data}getLayout(){return this.layout}getFilterColumnMap(){return new Map(this.filterColumnMap)}isFilterRequired(){return this.oneClicks.find(e=>e.requireAllFiltersToDisplay)!=null}setFilter(e){if(this.oneClicks.length===0){v.warn("Trying to set a filter, but no one click!");return}v.debug("setFilter",e);for(let t=0;t<this.oneClicks.length;t+=1){const n=this.oneClicks[t],{columns:r}=n;new Set([...e.keys(),...this.lastFilter.keys()]).forEach(a=>{const l=e.get(a);this.lastFilter.get(a)!==l&&r.find(o=>o.name===a)!=null&&n.setValueForColumn(a,l)})}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 Me=Oe;u(Me,"ADD_SERIES_DEBOUNCE",50);const Ue=Me;class ve{static async makeModelFromSettings(s,e,t=B){const n=await ve.makeFigureFromSettings(s,e);return new Ue(n,s,t)}static async makeFigureFromSettings(s,e){const t=await e.copy();return t.applyCustomColumns(e.customColumns),t.applyFilter(e.filter),t.applySort(e.sort),c.plot.Figure.create(N.makeFigureSettings(s,t))}static async makeModel(s,e,t=B){return new Ue(e,s,t)}}const Ht=ve;const oe=Z.module("EmbedChart.App");async function Ut(f,s){oe.info(`Fetching figure ${s}...`);const e={name:s,type:c.VariableType.FIGURE};return f.getObject(e)}function Xt(){const[f,s]=_.useState(),[e,t]=_.useState(),[n,r]=_.useState(!0),i=_.useMemo(()=>new URLSearchParams(window.location.search),[]);_.useEffect(function(){async function o(){try{const d=i.get("name");if(d==null)throw new Error("No name param provided");const h=new URL("/jsapi",`${window.location}`),T=`${h.protocol}//${h.host}`;oe.debug("Starting connection...");const S=new c.IdeConnection(T);oe.debug("Loading figure",d,"...");const E=await Ut(S,d);oe.debug("Creating model...");const b=await Ht.makeModel(void 0,E);s(b),oe.debug("Figure successfully loaded!")}catch(d){oe.error("Unable to load figure",d),t(`${d}`)}r(!1)}o()},[i]);const a=f!=null;return D.jsxs("div",{className:"App",children:[a&&D.jsx(Vt,{model:f}),!a&&D.jsx(Qe,{isLoaded:a,isLoading:n,errorMessage:e??null}),D.jsx(ht,{})]})}export{Xt as default};
2
- //# sourceMappingURL=App-162340ec.js.map