@deephaven/embed-chart 0.53.1-beta.5 → 0.53.1-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- import{r as H,G as Y,C as T,E as ge,F as je,aP as gt,L as vt,aQ as pt,a3 as He,aR as lt,ab as de,ai as yt,K as St,W as he}from"./vendor-8935a0fe.js";import{m as Et,L as W,w as Tt,E as bt,H as Ft,D as Pt,B as Dt,z as wt,O as Mt,S as Nt,p as fe,ab as At,aL as Ot,aM as Ct,J as It,F as xt,V as Rt}from"./index-30363d28.js";import{c as Me,P as ut,b as Lt,h as kt,p as _t,o as Vt,s as jt,t as Ht}from"./plotly-767c2d02.js";var Rn=Object.freeze([]),Ln=new Map,kn=()=>{};function Ne(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];return e.filter(r=>r!=null)}function $t(n,e,t){return e=Wt(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Wt(n){var e=Bt(n,"string");return typeof e=="symbol"?e:String(e)}function Bt(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}class qt extends Error{constructor(){super(...arguments),$t(this,"isCanceled",!0)}}const $e=qt;function Kt(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,t=zt(n,e);t.forEach(r=>{n[r]=n[r].bind(n)})}function zt(n,e){for(var t=new Set,r=n,a=0;r!=null&&r!==Object.prototype&&(a<=1||e);){for(var i of Object.getOwnPropertyNames(r))i!=="constructor"&&typeof r[i]=="function"&&t.add(i);r=Object.getPrototypeOf(r),a+=1}return[...t.keys()]}function Gt(n,e,t){return e=Xt(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Xt(n){var e=Yt(n,"string");return typeof e=="symbol"?e:String(e)}function Yt(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}class Zt extends Error{constructor(){super(...arguments),Gt(this,"isTimeout",!0)}}const ct=Zt;class Ie{static makeCancelable(e,t){var r=!1,a,i,l=new Promise((s,o)=>{i=o,Promise.resolve(e).then(u=>{r?t&&t(u):(a=u,s(u))}).catch(u=>o(u))});return l.cancel=()=>{r=!0,i(new $e),a!=null&&t&&t(a)},l}static isCanceled(e){return e instanceof $e}static isTimedOut(e){return e instanceof ct}static withTimeout(e,t){return new Promise((r,a)=>{setTimeout(()=>{try{r(t())}catch(i){a(i)}},e)})}}class Qt{static join(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"and";if(e==null||e.length===0)return"";if(e.length===1)return e[0];if(e.length===2)return"".concat(e[0]," ").concat(t," ").concat(e[1]);var r=e.slice(0,e.length-1).join(", "),a=e[e.length-1];return"".concat(r,", ").concat(t," ").concat(a)}static toLower(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;if(e==null){if(t)return"";throw new Error("Null string passed in to TextUtils.toLower")}return e.toLowerCase()}static sort(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e<t?r?-1:1:e>t?r?1:-1:0}}const Jt=Qt;function Pe(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"No value available in context. Was code wrapped in a provider?",t=H.useContext(n);if(t==null)throw new Error(e);return t}function Ut(n,e,t){return e=er(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function er(n){var e=tr(n,"string");return typeof e=="symbol"?e:String(e)}function tr(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function _n(n){return n.then!==void 0}class te{static disableAllActions(){te.actionsDisabled=!0}static enableAllActions(){te.actionsDisabled=!1}static isContextActionEvent(e){return Array.isArray(e.contextActions)}static compareActions(e,t){if(e.group!==t.group){var r,a;return((r=e.group)!==null&&r!==void 0?r:0)>((a=t.group)!==null&&a!==void 0?a:0)?1:-1}if(e.order!==t.order){var i,l;return((i=e.order)!==null&&i!==void 0?i:0)>((l=t.order)!==null&&l!==void 0?l:0)?1:-1}if(e.title!==t.title){var s,o;return((s=e.title)!==null&&s!==void 0?s:"")>((o=t.title)!==null&&o!==void 0?o:"")?1:-1}return e!==t?e>t?1:-1:0}static sortActions(e){if(e==null||!Array.isArray(e))return[];var t=e.slice();return t.sort(te.compareActions),t}static isMacPlatform(){var{platform:e}=window.navigator;return e.startsWith("Mac")}static getModifierKey(){return te.isMacPlatform()?"metaKey":"ctrlKey"}static isModifierKeyDown(e){var t=te.getModifierKey();return e[t]}static getMenuItems(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,r=[],a=e;Array.isArray(a)||(a=[a]);for(var i=0;i<a.length;i+=1){var l=a[i],s=void 0;typeof l=="function"?s=l():s=l,s!=null&&(s instanceof Promise?t&&r.push(s):Array.isArray(s)?r=r.concat(s):r.push(s))}return r=r.filter(o=>o.title!==void 0||o.then!=null||o.menuElement),r}static getNextMenuItem(e,t,r){var a=e;a<0&&t<0&&(a=r.length);for(var i=1;i<r.length+1;i+=1){var l=(a+t*i+r.length)%r.length,s=r[l];if(!(s instanceof Promise)&&s.disabled!==!0)return l}return e}}Ut(te,"actionsDisabled",!1);const ae=te;var xe=Y.forwardRef((n,e)=>{var t;function r(M){var{menuItem:I,onMenuItemClick:x}=n;x(I,M)}function a(M){var{menuItem:I,onMenuItemMouseMove:x}=n;x(I,M)}function i(M){var{menuItem:I,onMenuItemContextMenu:x}=n;x(I,M)}function l(M,I,x){if(typeof M.type=="string")return M;var{closeMenu:_,menuItem:re,isKeyboardSelected:Z,isMouseSelected:B,"data-testid":oe}=n,ne={menuItem:re,closeMenu:_,isKeyboardSelected:Z,isMouseSelected:B,iconElement:I,displayShortcut:x,"data-testid":oe};return Y.cloneElement(M,{forwardedProps:ne})}var{children:s,menuItem:o,isKeyboardSelected:u=!1,isMouseSelected:c=!1,"data-testid":d}=n,f=(t=o.shortcut)===null||t===void 0?void 0:t.getDisplayText(),p=null;if(o.icon){var v=o.icon;if(Y.isValidElement(v))p=v;else{var y;o.iconColor!=null&&(o.disabled===void 0||!o.disabled)&&(y={color:o.iconColor}),p=T.jsx(je,{icon:v,style:y})}}var S=null,E=!!s;o.actions&&(S=T.jsx(je,{icon:Et}));var F=null;if(o.menuElement)F=T.jsx("div",{className:"custom-menu-item",onMouseMove:a,children:l(o.menuElement,p,f)});else{var b,P=o.disabled,A=o.iconOutline;F=T.jsx("button",{type:"button",className:ge("btn-context-menu",{disabled:P},{active:(E||c)&&(P===void 0||!P)},{"keyboard-active":u&&(P===void 0||!P)}),onClick:r,onMouseMove:a,onContextMenu:i,title:(b=o.description)!==null&&b!==void 0?b:"",children:T.jsxs("div",{className:"btn-context-menu-wrapper",children:[T.jsx("span",{className:ge("icon",{outline:A}),children:p}),T.jsx("span",{className:"title",children:o.title}),f!==void 0&&T.jsx("span",{className:"shortcut",children:f}),S&&T.jsx("span",{className:ge("submenu-indicator",{disabled:P}),children:S})]})})}return T.jsxs("div",{className:"context-menu-item",ref:e,"data-testid":d,children:[s,F]})});xe.displayName="ContextMenuItem";xe.defaultProps={children:null,isKeyboardSelected:!1,isMouseSelected:!1,"data-testid":void 0};const rr=xe;function We(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(n,a).enumerable})),t.push.apply(t,r)}return t}function nr(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?We(Object(t),!0).forEach(function(r){U(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):We(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function U(n,e,t){return e=ar(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function ar(n){var e=ir(n,"string");return typeof e=="symbol"?e:String(e)}function ir(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}var Be=W.module("ContextMenu");class ve extends H.PureComponent{static handleContextMenu(e){e.metaKey||(e.stopPropagation(),e.preventDefault())}constructor(e){super(e),U(this,"container",void 0),U(this,"oldFocus",void 0),U(this,"activeSubMenuRef",void 0),U(this,"subMenuTimer",void 0),U(this,"rAF",void 0),U(this,"initialPosition",void 0),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=Y.createRef(),this.oldFocus=document.activeElement,this.activeSubMenuRef=Y.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}}componentDidMount(){this.initMenu(),this.verifyPosition(),window.addEventListener("resize",this.handleWindowResize),this.rAF=window.requestAnimationFrame(()=>{var e;(e=this.container.current)===null||e===void 0||e.focus();var{onMenuOpened:t}=this.props;t(this)})}componentDidUpdate(e,t){var{actions:r}=this.props,{activeSubMenu:a}=this.state;if(a!==t.activeSubMenu)if(a==null){var i;(i=this.container.current)===null||i===void 0||i.focus()}else this.setActiveSubMenuPosition();if(e.actions!==r&&(this.initMenu(),this.container.current==null||!this.container.current.contains(document.activeElement))){var l;(l=this.container.current)===null||l===void 0||l.focus()}this.verifyPosition()}componentWillUnmount(){this.cancelPromises(),window.removeEventListener("resize",this.handleWindowResize),cancelAnimationFrame(this.rAF)}getKeyboardIndex(){var{options:e}=this.props;if(e.separateKeyboardMouse!==void 0&&e.separateKeyboardMouse){var{keyboardIndex:t}=this.state;return t}return this.getMouseIndex()}setKeyboardIndex(e){var{options:t}=this.props;t.separateKeyboardMouse!==void 0&&t.separateKeyboardMouse?this.setState({keyboardIndex:e}):this.setMouseIndex(e)}getMouseIndex(){var{mouseIndex:e}=this.state;return e}setMouseIndex(e){this.setState({mouseIndex:e})}initMenu(){this.cancelPromises(),cancelAnimationFrame(this.rAF);var{options:e}=this.props,t=e.initialKeyboardIndex;t===void 0&&(t=-1);for(var{actions:r}=this.props,a=ae.getMenuItems(r),i=[],l=a.length-1;l>=0;l-=1){var s=a[l];s instanceof Promise?this.initMenuPromise(s):i.push(s)}this.setState({mouseIndex:-1,keyboardIndex:t,activeSubMenu:null,menuItems:ae.sortActions(i)})}initMenuPromise(e){var t=Ie.makeCancelable(e);this.setState(r=>({pendingItems:r.pendingItems.concat(t)})),t.then(r=>{this.setState(a=>{var i=a.pendingItems.indexOf(t);if(i>=0){var l=a.pendingItems.slice();return l.splice(i,1),{menuItems:ae.sortActions(a.menuItems.concat(r)),pendingItems:l}}return null})},r=>{Ie.isCanceled(r)||(this.setState(a=>{var i=a.pendingItems.indexOf(t);if(i>=0){var l=a.pendingItems.slice();return l.splice(i,1),{pendingItems:l}}return null}),Be.error(r))})}cancelPromises(){var{pendingItems:e}=this.state;e.map(t=>t.cancel())}setActiveSubMenuPosition(){if(this.activeSubMenuRef.current!==null){var e=this.activeSubMenuRef.current.getBoundingClientRect();this.setState({subMenuTop:e.top,subMenuLeft:e.right,subMenuParentHeight:e.height,subMenuParentWidth:e.width})}}verifyPosition(){var e,t,r,a,{options:i,updatePosition:l,subMenuParentWidth:s,subMenuParentHeight:o,top:u,left:c}=this.props;if(!(!this.container.current||i.doNotVerifyPosition!=null&&i.doNotVerifyPosition)){var{top:d,left:f}=this.initialPosition,{width:p,height:v}=(e=(t=this.container.current)===null||t===void 0?void 0:t.getBoundingClientRect())!==null&&e!==void 0?e:{width:0,height:0},y=((r=(a=this.container.current)===null||a===void 0?void 0:a.scrollHeight)!==null&&r!==void 0?r:0)>window.innerHeight;v===0||p===0||(d+v>window.innerHeight&&(d-v-o>0?d-=v-o:d=window.innerHeight-v),f+p>window.innerWidth&&(f=f-p-s),(c!==f||u!==d)&&(this.setState({hasOverflow:y}),l(d,f)))}}handleWindowResize(){this.container.current&&this.closeMenu(!0)}handleBlur(e){if(!this.container.current){Be.warn("Container is null!");return}if(!this.container.current.contains(e.relatedTarget)){for(var t=e.relatedTarget,r=!1;t&&!r;)r=t.hasAttribute("data-dh-context-menu"),t=t.parentElement;r||this.closeMenu(!0)}}isEscapeKey(e){var{left:t}=this.props;return e==="Escape"||t<0&&e==="ArrowRight"||e==="ArrowLeft"}handleKeyDown(e){var{menuItems:t}=this.state,r=this.getKeyboardIndex(),a=r,i=!1;if(e.key==="Enter"||e.key===" "){r>=0&&r<t.length&&this.handleMenuItemClick(t[r],e);return}if(e.key==="ArrowRight"?r>=0&&r<=t.length?i=!0:a=0:this.isEscapeKey(e.key)?a=null:e.key==="ArrowUp"||e.shiftKey&&e.key==="Tab"?a=ae.getNextMenuItem(a,-1,t):(e.key==="ArrowDown"||e.key==="Tab")&&(a=ae.getNextMenuItem(a,1,t)),i){this.openSubMenu(r),e.preventDefault(),e.stopPropagation();return}r!==a&&(a!==null?this.setKeyboardIndex(a):(this.closeMenu(),this.oldFocus instanceof HTMLElement&&this.oldFocus.focus()),e.preventDefault(),e.stopPropagation())}openSubMenu(e){var{menuItems:t,activeSubMenu:r}=this.state,a=t[e].actions?e:null;r!==a&&this.setState({activeSubMenu:a,subMenuTop:null,subMenuLeft:null})}closeMenu(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,{closeMenu:t,onMenuClosed:r}=this.props;cancelAnimationFrame(this.rAF),this.rAF=window.requestAnimationFrame(()=>{t(e),r(this)})}closeSubMenu(){this.setState({activeSubMenu:null})}handleCloseSubMenu(e){e?this.closeMenu(!0):this.closeSubMenu()}handleMenuItemClick(e,t){t.preventDefault(),t.stopPropagation();var{menuItems:r}=this.state;e!=null&&(e.disabled===void 0||!e.disabled)&&(e.actions!=null?this.openSubMenu(r.indexOf(e)):e.action!=null&&(e.action(t.nativeEvent),this.closeMenu(!0)))}handleMenuItemContextMenu(e,t){t.metaKey||this.handleMenuItemClick(e,t)}handleMenuItemMouseMove(e){var{menuItems:t}=this.state,r=t.indexOf(e);this.setMouseIndex(r),r>=0&&r<t.length&&(e.disabled===void 0||!e.disabled)&&this.openSubMenu(r)}handleMouseLeave(){this.setMouseIndex(-1)}render(){for(var e=[],{top:t,left:r}=this.props,{activeSubMenu:a,hasOverflow:i,keyboardIndex:l,menuItems:s,mouseIndex:o,pendingItems:u,subMenuTop:c,subMenuLeft:d,subMenuParentWidth:f,subMenuParentHeight:p}=this.state,v=0;v<s.length;v+=1){var y=s[v];v>0&&y.group!==s[v-1].group&&e.push(T.jsx("hr",{},"".concat(v,".separator")));var S=T.jsx(rr,{ref:a===v?this.activeSubMenuRef:null,isKeyboardSelected:l===v,isMouseSelected:o===v,menuItem:y,closeMenu:this.handleCloseSubMenu,onMenuItemClick:this.handleMenuItemClick,onMenuItemMouseMove:this.handleMenuItemMouseMove,onMenuItemContextMenu:this.handleMenuItemContextMenu},v);e.push(S)}var E=null;u.length>0&&(E=T.jsx("div",{className:"loading",children:T.jsx(Tt,{className:"loading-spinner-vertical-align"})}));var{menuStyle:F,"data-testid":b}=this.props,P=a!==null&&c!==null&&d!==null;return T.jsxs(T.Fragment,{children:[T.jsxs("div",{className:ge({"has-overflow":i},"context-menu-container"),style:nr({top:t,left:r},F),ref:this.container,"data-dh-context-menu":!0,onBlur:this.handleBlur,onKeyDown:this.handleKeyDown,onMouseLeave:this.handleMouseLeave,onContextMenu:ve.handleContextMenu,role:"menuitem",tabIndex:0,"data-testid":b,children:[e,E]}),P&&a!==null&&c!==null&&d!==null&&T.jsx(ve,{actions:s[a].actions||[],closeMenu:this.handleCloseSubMenu,top:c,left:d,updatePosition:(A,M)=>{this.setState({subMenuTop:A,subMenuLeft:M})},subMenuParentWidth:f,subMenuParentHeight:p},"sub-".concat(a))]})}}U(ve,"defaultProps",{subMenuParentWidth:0,subMenuParentHeight:0,closeMenu(){},onMenuOpened(){},onMenuClosed(){},options:{},menuStyle:{},"data-testid":void 0});const sr=ve;function qe(n,e,t){return e=or(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function or(n){var e=lr(n,"string");return typeof e=="symbol"?e:String(e)}function lr(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}class ur extends H.Component{constructor(e){super(e),qe(this,"container",void 0),qe(this,"openMenu",void 0),this.handleMenuClose=this.handleMenuClose.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.container=Y.createRef(),this.openMenu=Y.createRef(),this.state={actions:null,left:0,top:0}}componentDidMount(){var e;(e=this.container.current)!==null&&e!==void 0&&e.parentElement&&this.container.current.parentElement.addEventListener("contextmenu",this.handleContextMenu)}componentWillUnmount(){var e;(e=this.container.current)!==null&&e!==void 0&&e.parentElement&&this.container.current.parentElement.removeEventListener("contextmenu",this.handleContextMenu)}handleContextMenu(e){if(this.container.current){var t=this.container.current.getBoundingClientRect(),r=e.clientY-t.top,a=e.clientX-t.left,{actions:i}=this.state;if(i!=null&&e.target===this.container.current){e.preventDefault(),this.setState({actions:null},()=>{var s=document.elementFromPoint(a,r),o=new MouseEvent("contextmenu",{clientX:e.clientX,clientY:e.clientY,bubbles:!0,cancelable:!0});s==null||s.dispatchEvent(o)});return}if(ae.isContextActionEvent(e)&&!(e.metaKey||e.ctrlKey)){var l=ae.getMenuItems(e.contextActions);l.length!==0&&(e.preventDefault(),this.setState({actions:l,top:r,left:a}))}}}handleMenuClose(e){e===this.openMenu.current&&this.setState({actions:null})}render(){var e=null,{"data-testid":t}=this.props,{actions:r,top:a,left:i}=this.state;return r&&(e=T.jsx(sr,{ref:this.openMenu,actions:r,onMenuClosed:this.handleMenuClose,top:a,left:i,updatePosition:(l,s)=>{this.setState({top:l,left:s})},"data-testid":t})),T.jsx("div",{className:ge("context-menu-root",{active:r}),ref:this.container,children:e})}}const Vn=ur,cr={"dh-spectrum-palette":"_dh-spectrum-palette_1mcqx_1"},dr={"dh-spectrum-alias":"_dh-spectrum-alias_83lrx_1"},hr={};function Ke(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(n,a).enumerable})),t.push.apply(t,r)}return t}function Ae(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ke(Object(t),!0).forEach(function(r){fr(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Ke(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function fr(n,e,t){return e=mr(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function mr(n){var e=gr(n,"string");return typeof e=="symbol"?e:String(e)}function gr(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}var ze=Ae(Ae(Ae({},cr),dr),hr);function Ge(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(n,a).enumerable})),t.push.apply(t,r)}return t}function be(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ge(Object(t),!0).forEach(function(r){vr(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Ge(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function vr(n,e,t){return e=pr(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function pr(n){var e=yr(n,"string");return typeof e=="symbol"?e:String(e)}function yr(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}var{global:Sr,light:Er,dark:Tr,medium:br,large:Fr}=gt,Pr={global:Sr,light:be(be({},Er),ze),dark:be(be({},Tr),ze),medium:br,large:Fr};function Dr(n){var{children:e,isPortal:t=!1,theme:r=Pr,colorScheme:a}=n,[i]=H.useState(t?vt():null);return T.jsx(pt,{theme:r,colorScheme:a,"data-unique-id":i,children:e})}var wr=W.module("ThemeProvider"),dt=H.createContext(null);function jn(n){var{themes:e,children:t}=n,r=H.useMemo(()=>bt(),[]),[a,i]=H.useState(()=>{var o,u;return(o=(u=Ft())===null||u===void 0?void 0:u.themeKey)!==null&&o!==void 0?o:Pt}),l=H.useMemo(()=>e==null?null:Dt(a,{base:r,custom:e??[]}),[r,a,e]);H.useEffect(function(){if(!(l==null||e==null)){var u=wt();wr.debug2("updateThemePreloadData:",{active:l.map(c=>c.themeKey),all:e.map(c=>c.themeKey),preloadStyleContent:u,selectedThemeKey:a}),Mt({themeKey:a,preloadStyleContent:u})}},[l,a,e]);var s=H.useMemo(()=>({activeThemes:l,selectedThemeKey:a,setSelectedThemeKey:i}),[l,a]);return T.jsxs(dt.Provider,{value:s,children:[l==null?null:T.jsx(T.Fragment,{children:l.map(o=>T.jsx("style",{"data-theme-key":o.themeKey,children:o.styleContent},o.themeKey))}),T.jsx(Dr,{children:t})]})}function Mr(){return Pe(dt,"No ThemeContext value found. Component must be wrapped in a ThemeContext.Provider")}function Hn(){return Pe(Nt,"No API available in useApi. Was code wrapped in ApiBootstrap or ApiContext.Provider?")}function Re(n,e,t){return e=Nr(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Nr(n){var e=Ar(n,"string");return typeof e=="symbol"?e:String(e)}function Ar(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}class De{static isValid(e,t){return!0}static isSameFormat(e,t){throw new Error("isSameFormat not implemented")}static makeFormat(e,t,r){return{label:e,formatString:t,type:r}}format(e,t){return""}}Re(De,"TYPE_GLOBAL","type-global");Re(De,"TYPE_CONTEXT_PRESET","type-context-preset");Re(De,"TYPE_CONTEXT_CUSTOM","type-context-custom");const k=De;class Or extends k{format(e){switch(e){case 1:case!0:return"true";case 0:case!1:return"false";default:return""}}}const Cr=Or;class Ir extends k{format(e){return String.fromCharCode(e)}}const xr=Ir;function ee(n,e,t){return e=Rr(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Rr(n){var e=Lr(n,"string");return typeof e=="symbol"?e:String(e)}function Lr(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}var Xe=W.module("DateTimeColumnFormatter");class q extends k{static isValid(e,t){try{return e.i18n.DateTimeFormat.format(t.formatString,new Date),!0}catch{return!1}}static makeFormat(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:k.TYPE_CONTEXT_PRESET;return{label:e,formatString:t,type:r}}static isSameFormat(e,t){return e===t||e!==null&&t!==null&&e.type===t.type&&e.formatString===t.formatString}static makeGlobalFormatStringMap(e,t){var r=t?"'T'":" ",a=e?" z":"";return new Map([["yyyy-MM-dd HH:mm:ss","yyyy-MM-dd".concat(r,"HH:mm:ss").concat(a)],["yyyy-MM-dd HH:mm:ss.SSS","yyyy-MM-dd".concat(r,"HH:mm:ss.SSS").concat(a)],["yyyy-MM-dd HH:mm:ss.SSSSSSSSS","yyyy-MM-dd".concat(r,"HH:mm:ss.SSSSSSSSS").concat(a)]])}static getGlobalFormats(e,t){var r=q.makeGlobalFormatStringMap(e,t);return[...r.keys()]}static makeFormatStringMap(e,t){var r=t!==void 0&&t?"'T'":" ",a=e!==void 0&&e?" z":"";return new Map([["yyyy-MM-dd","yyyy-MM-dd".concat(a)],["MM-dd-yyyy","MM-dd-yyyy".concat(a)],["HH:mm:ss","HH:mm:ss".concat(a)],["HH:mm:ss.SSS","HH:mm:ss.SSS".concat(a)],["HH:mm:ss.SSSSSSSSS","HH:mm:ss.SSSSSSSSS".concat(a)],["yyyy-MM-dd HH:mm:ss","yyyy-MM-dd".concat(r,"HH:mm:ss").concat(a)],["yyyy-MM-dd HH:mm:ss.SSS","yyyy-MM-dd".concat(r,"HH:mm:ss.SSS").concat(a)],["yyyy-MM-dd HH:mm:ss.SSSSSSSSS","yyyy-MM-dd".concat(r,"HH:mm:ss.SSSSSSSSS").concat(a)]])}static getFormats(e,t){var r=q.makeFormatStringMap(e,t);return[...r.keys()]}constructor(e){var{timeZone:t="",showTimeZone:r=!0,showTSeparator:a=!1,defaultDateTimeFormatString:i=q.DEFAULT_DATETIME_FORMAT_STRING}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),ee(this,"dh",void 0),ee(this,"dhTimeZone",void 0),ee(this,"defaultDateTimeFormatString",void 0),ee(this,"showTimeZone",void 0),ee(this,"showTSeparator",void 0),ee(this,"formatStringMap",void 0);var l=t||q.DEFAULT_TIME_ZONE_ID;try{this.dhTimeZone=e.i18n.TimeZone.getTimeZone(l)}catch{Xe.error("Unsupported time zone id",l),this.dhTimeZone=e.i18n.TimeZone.getTimeZone(q.DEFAULT_TIME_ZONE_ID)}this.dh=e,this.defaultDateTimeFormatString=i,this.showTimeZone=r,this.showTSeparator=a,this.formatStringMap=q.makeFormatStringMap(r,a)}getEffectiveFormatString(e){var t;return(t=this.formatStringMap.get(e))!==null&&t!==void 0?t:e}format(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultDateTimeFormatString,a=this.getEffectiveFormatString(r);try{return this.dh.i18n.DateTimeFormat.format(a,e,this.dhTimeZone)}catch{Xe.error("Invalid format arguments")}return""}}ee(q,"DEFAULT_DATETIME_FORMAT_STRING","yyyy-MM-dd HH:mm:ss.SSS");ee(q,"DEFAULT_TIME_ZONE_ID","America/New_York");function z(n,e,t){return e=kr(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function kr(n){var e=_r(n,"string");return typeof e=="symbol"?e:String(e)}function _r(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}var Vr=W.module("DecimalColumnFormatter");class N extends k{static isValid(e,t){try{return e.i18n.NumberFormat.format(t.formatString,0),!0}catch{return!1}}static makeFormat(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:k.TYPE_CONTEXT_PRESET,a=arguments.length>3?arguments[3]:void 0;return{label:e,type:r,formatString:t,multiplier:a}}static makePresetFormat(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",r=arguments.length>2?arguments[2]:void 0;return N.makeFormat(e,t,k.TYPE_CONTEXT_PRESET,r)}static makeCustomFormat(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;return N.makeFormat("Custom Format",e,k.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}constructor(e){var{defaultFormatString:t=N.DEFAULT_FORMAT_STRING}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),z(this,"defaultFormatString",void 0),z(this,"dh",void 0),this.dh=e,this.defaultFormatString=t}format(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultFormatString,a=t.multiplier!=null&&t.multiplier!==0?e*t.multiplier:e;try{return this.dh.i18n.NumberFormat.format(r,a)}catch{Vr.error("Invalid format arguments")}return""}}z(N,"DEFAULT_FORMAT_STRING","###,##0.0000");z(N,"FORMAT_PERCENT",N.makePresetFormat("Percent","##0.00%"));z(N,"FORMAT_BASIS_POINTS",N.makePresetFormat("Basis Points","###,##0 bp",1e4));z(N,"FORMAT_MILLIONS",N.makePresetFormat("Millions","###,##0.000 mm",1e-6));z(N,"FORMAT_SCIENTIFIC_NOTATION",N.makePresetFormat("Scientific Notation","0.0000E0"));z(N,"FORMAT_ROUND",N.makePresetFormat("Round","###,##0"));z(N,"FORMAT_ROUND_TWO_DECIMALS",N.makePresetFormat("0.00","###,##0.00"));z(N,"FORMAT_ROUND_FOUR_DECIMALS",N.makePresetFormat("0.0000","###,##0.0000"));class jr extends k{format(e){return"".concat(e)}}const Hr=jr;function pe(n,e,t){return e=$r(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function $r(n){var e=Wr(n,"string");return typeof e=="symbol"?e:String(e)}function Wr(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}var Br=W.module("IntegerColumnFormatter");class K extends k{static isValid(e,t){try{return e.i18n.NumberFormat.format(t.formatString,0),!0}catch{return!1}}static makeFormat(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:k.TYPE_CONTEXT_PRESET,a=arguments.length>3?arguments[3]:void 0;return{label:e,type:r,formatString:t,multiplier:a}}static makePresetFormat(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",r=arguments.length>2?arguments[2]:void 0;return K.makeFormat(e,t,k.TYPE_CONTEXT_PRESET,r)}static makeCustomFormat(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;return K.makeFormat("Custom Format",e,k.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}constructor(e){var{defaultFormatString:t=K.DEFAULT_FORMAT_STRING}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),pe(this,"dh",void 0),pe(this,"defaultFormatString",void 0),this.dh=e,this.defaultFormatString=t}format(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultFormatString,a=t.multiplier!=null&&t.multiplier!==0?e*t.multiplier:e;try{return this.dh.i18n.NumberFormat.format(r,a)}catch{Br.error("Invalid format arguments")}return""}}pe(K,"DEFAULT_FORMAT_STRING","###,##0");pe(K,"FORMAT_MILLIONS",K.makePresetFormat("Millions","###,##0.000 mm",1e-6));pe(K,"FORMAT_SCIENTIFIC_NOTATION",K.makePresetFormat("Scientific Notation","0.0000E0"));class qr extends k{format(e){return e}}function ht(n,e,t){return e=Kr(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Kr(n){var e=zr(n,"string");return typeof e=="symbol"?e:String(e)}function zr(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}class O{static makeDateWrapper(e,t,r){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:1,l=arguments.length>5&&arguments[5]!==void 0?arguments[5]:0,s=arguments.length>6&&arguments[6]!==void 0?arguments[6]:0,o=arguments.length>7&&arguments[7]!==void 0?arguments[7]:0,u=arguments.length>8&&arguments[8]!==void 0?arguments[8]:0;if(!t)throw new Error("No timezone provided");var c="".concat(r).padStart(4,"0"),d="".concat(a+1).padStart(2,"0"),f="".concat(i).padStart(2,"0"),p="".concat(l).padStart(2,"0"),v="".concat(s).padStart(2,"0"),y="".concat(o).padStart(2,"0"),S="".concat(u).padStart(9,"0"),E="".concat(c,"-").concat(d,"-").concat(f," ").concat(p,":").concat(v,":").concat(y,".").concat(S);return e.i18n.DateTimeFormat.parse(O.FULL_DATE_FORMAT,E,e.i18n.TimeZone.getTimeZone(t))}static getNextNanos(e){var t=parseInt(e,10),r="0".repeat(9-e.length),a="".concat(t+1).concat(r);return parseInt(a,10)}static getNextDate(e,t,r,a){var{year:i,month:l,date:s,hours:o,minutes:u,seconds:c,nanos:d}=r;if(t.nanos!=null){if(t.nanos.length===9)return null;d=O.getNextNanos(t.nanos),d>999999999&&(c+=1,d=0)}else t.seconds!=null?c+=1:t.minutes!=null?u+=1:t.hours!=null?o+=1:t.date!=null?s+=1:t.month!=null?l+=1:i+=1;var f=new Date(i,l,s,o,u,c);return O.makeDateWrapper(e,a,f.getFullYear(),f.getMonth(),f.getDate(),f.getHours(),f.getMinutes(),f.getSeconds(),d)}static parseMonth(e){var t=parseInt(e,10);if(!Number.isNaN(t))return t>=1&&t<=12?t-1:NaN;var r=e.trim().toLowerCase();if(r.length>=3){for(var a=0;a<O.months.length;a+=1)if(O.months[a].startsWith(r))return a}return NaN}static parseDateValues(e,t,r,a,i,l,s){var o=parseInt(e,10),u=t!=null?this.parseMonth(t):0,c=r!=null?parseInt(r,10):1,d=a!=null?parseInt(a,10):0,f=i!=null?parseInt(i,10):0,p=l!=null?parseInt(l,10):0,v=s!=null?parseInt(s.padEnd(9,"0"),10):0;return Number.isNaN(o)||Number.isNaN(u)||Number.isNaN(c)||Number.isNaN(d)||Number.isNaN(f)||Number.isNaN(p)||Number.isNaN(v)?null:{year:o,month:u,date:c,hours:d,minutes:f,seconds:p,nanos:v}}static parseDateTimeString(e){var t=/\s*(\d{4})([-./]([\da-z]+))?([-./](\d{1,2}))?([tT\s](\d{2})([:](\d{2}))?([:](\d{2}))?([.](\d{1,9}))?)?(.*)/,r=t.exec(e);if(r==null)throw new Error("Unexpected date string: ".concat(e));var[,a,,i,,l,,s,,o,,u,,c,d]=r;if(d!=null&&d.length>0)throw new Error("Unexpected characters after date string '".concat(e,"': ").concat(d));return{year:a,month:i,date:l,hours:s,minutes:o,seconds:u,nanos:c}}static parseDateRange(e,t,r){var a=t.trim().toLowerCase();if(a.length===0)throw new Error("Cannot parse date range from empty string");if(a==="null")return[null,null];if(a==="today"){var i=new Date(Date.now()),l=O.makeDateWrapper(e,r,i.getFullYear(),i.getMonth(),i.getDate()),s=new Date(i.getFullYear(),i.getMonth(),i.getDate()+1),o=O.makeDateWrapper(e,r,s.getFullYear(),s.getMonth(),s.getDate());return[l,o]}if(a==="yesterday"){var u=new Date(Date.now()),c=new Date(u.getFullYear(),u.getMonth(),u.getDate()-1),d=O.makeDateWrapper(e,r,c.getFullYear(),c.getMonth(),c.getDate()),f=O.makeDateWrapper(e,r,u.getFullYear(),u.getMonth(),u.getDate());return[d,f]}if(a==="now"){var p=new Date(Date.now()),v=e.DateWrapper.ofJsDate(p);return[v,null]}var y=O.parseDateTimeString(a);if(y.year==null&&y.month==null&&y.date==null)throw new Error("Unable to extract year, month, or day ".concat(a));var S=O.parseDateValues(y.year,y.month,y.date,y.hours,y.minutes,y.seconds,y.nanos);if(S==null)throw new Error("Unable to extract date values from ".concat(y));var E=O.makeDateWrapper(e,r,S.year,S.month,S.date,S.hours,S.minutes,S.seconds,S.nanos),F=O.getNextDate(e,y,S,r);return[E,F]}static getJsDate(e){return typeof e=="number"?new Date(e):e.asDate()}}ht(O,"FULL_DATE_FORMAT","yyyy-MM-dd HH:mm:ss.SSSSSSSSS");ht(O,"months",["january","february","march","april","may","june","july","august","september","october","november","december"]);function $n(n,e){return n===e?{operator:"notEq",value:""}:{operator:"eq",value:n}}function Wn(n,e,t){return function(a){var i=t.trim();if(i==="")return null;var l=ft(e,s=>s.filter().containsIgnoreCase(n.makeFilterValue(s.type,i)),"or");return l(a)}}function ft(n,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"or";return function(a){var i=a==null?void 0:a.findColumns(typeof n=="string"?[n]:n);if(i==null||i.length===0)return null;var l=i.map(e);return l.reduce((s,o)=>s[t](o))}}function Gr(n,e,t,r){return ft(e,a=>a.filter()[r](n.makeFilterValue(a.type,t)),"or")}function Bn(n,e,t,r,a){return function(l){var s=l==null?void 0:l.findColumn(e),o=t==="all"||r&&t.size===0;return s==null||o?null:n.makeSelectValueFilter(s,[...t.keys()],a)}}function qn(n){return function(t){return t.filter().isNull().not().and(t.filter().notEq(n.makeFilterValue(t.type,"")))}}function Kn(n,e){return function(r){var a=r.filter(),i=n.makeFilterValue(r.type,""),l=a.eq(i);return e?a.isNull().or(l):l.or(a.notEq(i))}}function Le(n,e,t){return e=Xr(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Xr(n){var e=Yr(n,"string");return typeof e=="symbol"?e:String(e)}function Yr(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}class ye{}Le(ye,"not","not");Le(ye,"and","and");Le(ye,"or","or");function zn(n){if(!(n==="not"||n==="and"||n==="or"))throw new Error("operator is not a valid FilterOperatorValue")}function w(n,e,t){return e=Zr(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Zr(n){var e=Qr(n,"string");return typeof e=="symbol"?e:String(e)}function Qr(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}class m{}w(m,"eq","eq");w(m,"eqIgnoreCase","eqIgnoreCase");w(m,"notEq","notEq");w(m,"notEqIgnoreCase","notEqIgnoreCase");w(m,"greaterThan","greaterThan");w(m,"greaterThanOrEqualTo","greaterThanOrEqualTo");w(m,"lessThan","lessThan");w(m,"lessThanOrEqualTo","lessThanOrEqualTo");w(m,"in","in");w(m,"inIgnoreCase","inIgnoreCase");w(m,"notIn","notIn");w(m,"notInIgnoreCase","notInIgnoreCase");w(m,"isTrue","isTrue");w(m,"isFalse","isFalse");w(m,"isNull","isNull");w(m,"invoke","invoke");w(m,"contains","contains");w(m,"notContains","notContains");w(m,"containsIgnoreCase","containsIgnoreCase");w(m,"startsWith","startsWith");w(m,"endsWith","endsWith");w(m,"containsAny","containsAny");var Ye=W.module("ViewportDataUtils");function Jr(n,e){return String(n.offsetInSnapshot+e)}function Gn(n,e){var{bulkUpdate:t}=n;return function(a){var{columns:i,offset:l,rows:s}=a.detail;Ye.debug("table updated",a.detail);var o=new Map;s.forEach(u=>{var c=e(u,i),d=Jr(u,l);o.set(d,{key:d,item:c})}),Ye.debug("update keys",o),t(o)}}function Xn(n,e){return e.reduce((t,r)=>(t[r.name]=n.get(r),t),{})}function*Yn(n,e){for(var t=n;t<=e;++t)yield{key:String(t)}}function Ur(n){return n==null||en(n)?0:n.size}function en(n){return"isClosed"in n?n.isClosed:!1}function Zn(n,e,t,r){var a=n+e-1,[i,l]=[0,r-1],s=He(n-t,i,l),o=He(a+t,i,l);return[s,o]}function Ze(n,e,t,r,a,i,l){try{var s=n[i](l),o=s.value}catch(u){t(u);return}s.done?e(o):Promise.resolve(o).then(r,a)}function J(n){return function(){var e=this,t=arguments;return new Promise(function(r,a){var i=n.apply(e,t);function l(o){Ze(i,r,a,l,s,"next",o)}function s(o){Ze(i,r,a,l,s,"throw",o)}l(void 0)})}}function se(n,e,t){return e=tn(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function tn(n){var e=rn(n,"string");return typeof e=="symbol"?e:String(e)}function rn(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}var G=W.module("TableUtils");class h{static copyTableAndApplyFilters(e){var t=arguments;return J(function*(){if(e==null)return null;for(var r=yield e.copy(),a=t.length,i=new Array(a>1?a-1:0),l=1;l<a;l++)i[l-1]=t[l];return r.applyFilter(Ne(...i.map(s=>s(r)))),r})()}static getSortIndex(e,t){for(var r=0;r<e.length;r+=1){var a,i=e[r];if(((a=i.column)===null||a===void 0?void 0:a.name)===t)return r}return null}static getSortForColumn(e,t){var r=h.getSortIndex(e,t);return r!=null?e[r]:null}static getFilterText(e){return e?e.toString():null}static getFilterTypes(e){return h.isBooleanType(e)?[m.isTrue,m.isFalse,m.isNull]:h.isCharType(e)||h.isNumberType(e)||h.isDateType(e)?[m.eq,m.notEq,m.greaterThan,m.greaterThanOrEqualTo,m.lessThan,m.lessThanOrEqualTo]:h.isTextType(e)?[m.eq,m.eqIgnoreCase,m.notEq,m.notEqIgnoreCase,m.contains,m.notContains,m.startsWith,m.endsWith]:[]}static getNextSort(e,t,r){if(r<0||r>=e.length)return null;var a=h.getSortForColumn(t,e[r].name);return a===null?e[r].sort().asc():a.direction===h.sortDirection.ascending?a.desc():null}static makeColumnSort(e,t,r,a){if(t<0||t>=e.length||r===h.sortDirection.none)return null;var i=e[t].sort();switch(r){case h.sortDirection.ascending:i=i.asc();break;case h.sortDirection.descending:i=i.desc();break}return a&&(i=i.abs()),i}static toggleSortForColumn(e,t,r){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(r<0||r>=t.length)return[];var i=h.getNextSort(t,e,r);return h.setSortForColumn(e,t[r].name,i,a)}static sortColumn(e,t,r,a,i,l){if(r<0||r>=t.length)return[];var s=h.makeColumnSort(t,r,a,i);return h.setSortForColumn(e,t[r].name,s,l)}static setSortForColumn(e,t,r){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,i=h.getSortIndex(e,t),l=[];return a&&(l=l.concat(e.filter(s=>{var{direction:o}=s;return o!==h.sortDirection.reverse})),i!==null&&l.splice(i,1)),r!==null&&l.push(r),l}static getNormalizedType(e){switch(e){case"boolean":case"java.lang.Boolean":case h.dataType.BOOLEAN:return h.dataType.BOOLEAN;case"char":case"java.lang.Character":case h.dataType.CHAR:return h.dataType.CHAR;case"java.lang.String":case h.dataType.STRING:return h.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 h.dataType.DATETIME:return h.dataType.DATETIME;case"double":case"java.lang.Double":case"float":case"java.lang.Float":case"java.math.BigDecimal":case h.dataType.DECIMAL:return h.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 h.dataType.INT:return h.dataType.INT;default:return h.dataType.UNKNOWN}}static isLongType(e){switch(e){case"long":case"java.lang.Long":return!0;default:return!1}}static isDateType(e){switch(e){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(e){return h.isIntegerType(e)||h.isDecimalType(e)}static isIntegerType(e){switch(e){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(e){switch(e){case"double":case"java.lang.Double":case"java.math.BigDecimal":case"float":case"java.lang.Float":return!0;default:return!1}}static isBigDecimalType(e){switch(e){case"java.math.BigDecimal":return!0;default:return!1}}static isBigIntegerType(e){switch(e){case"java.math.BigInteger":return!0;default:return!1}}static isBooleanType(e){switch(e){case"boolean":case"java.lang.Boolean":return!0;default:return!1}}static isCharType(e){switch(e){case"char":case"java.lang.Character":return!0;default:return!1}}static isStringType(e){switch(e){case"java.lang.String":return!0;default:return!1}}static isTextType(e){return this.isStringType(e)||this.isCharType(e)}static getBaseType(e){return e.split("[]")[0]}static isCompatibleType(e,t){return h.getNormalizedType(e)===h.getNormalizedType(t)}static quoteValue(e){return e.length>=2&&(e.charAt(0)==='"'&&e.charAt(e.length-1)==='"'||e.charAt(0)==="'"&&e.charAt(e.length-1)==="'")?e:'"'.concat(e,'"')}static isRangeOperation(e){switch(e){case"<":case"<=":case"=<":case">":case">=":case"=>":return!0;default:return!1}}static makeRangeFilterWithOperation(e,t,r){switch(t){case"=":return e.eq(r);case"<":return e.lessThan(r);case"<=":case"=<":return e.lessThanOrEqualTo(r);case">":return e.greaterThan(r);case">=":case"=>":return e.greaterThanOrEqualTo(r);case"!=":case"!":return e.notEq(r);default:return null}}static makeCancelableTablePromise(e){return Ie.makeCancelable(e,t=>{t.close()})}static makeCancelableTableEventPromise(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null,i,l,s=!0,o=new Promise((u,c)=>{l=setTimeout(()=>{i(),s=!1,c(new ct('Event "'.concat(t,'" timed out.')))},r),i=e.addEventListener(t,d=>{if(a!=null&&!a(d)){G.debug2("Event triggered, but matcher returned false.");return}G.debug2("Event triggered, resolving."),i(),clearTimeout(l),s=!1,u(d)})});return o.cancel=()=>{if(s){G.debug2("Pending promise cleanup."),i(),clearTimeout(l),s=!1;return}G.debug2("Ignoring non-pending promise cancel.")},o}static removeCommas(e){return e.replace(/[\s|,]/g,"")}static makeBooleanValue(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(e===""&&t)return null;switch(e==null?void 0:e.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 '".concat(e,"'"))}}static makeNumberValue(e){if(e==="null"||e==="")return null;var t=e.toLowerCase().trim();if(t==="∞"||t==="infinity"||t==="inf")return Number.POSITIVE_INFINITY;if(t==="-∞"||t==="-infinity"||t==="-inf")return Number.NEGATIVE_INFINITY;var r=h.removeCommas(t);if(h.NUMBER_REGEX.test(r))return parseFloat(r);throw new Error("Invalid number '".concat(e,"'"))}static getFilterOperatorString(e){switch(e){case m.eq:return"=";case m.notEq:return"!=";case m.greaterThan:return">";case m.greaterThanOrEqualTo:return">=";case m.lessThan:return"<";case m.lessThanOrEqualTo:return"<=";case m.contains:return"~";case m.notContains:return"!~";default:throw new Error("Unexpected filter type ".concat(e))}}static isTreeTable(e){return e!=null&&e.expand!==void 0&&e.collapse!==void 0}static sortColumns(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return[...e].sort((r,a)=>{var i=r.name.toUpperCase(),l=a.name.toUpperCase();return Jt.sort(i,l,t)})}constructor(e){se(this,"dh",void 0),this.dh=e,Kt(this)}createDistinctSortedColumnTable(e,t,r){var a=arguments,i=this;return J(function*(){if(e==null)return null;for(var l=e,s=a.length,o=new Array(s>3?s-3:0),u=3;u<s;u++)o[u-3]=a[u];o.length>0&&(l=yield e.copy(),yield l.applyFilter(Ne(...o.map(p=>p(l)))));var c=l.findColumn(t),d=yield l.selectDistinct([c]);l!==e&&l.close();var f=d.findColumn(t).sort()[r]();return i.applySort(d,[f])})()}doesColumnValueExist(e,t,r,a){var i=this;return J(function*(){if(e==null)return null;var l=Gr(i,t,r,a?"eq":"eqIgnoreCase"),s=yield e.copy();yield i.applyFilter(s,Ne(l(s)));var o=Ur(s);return s.close(),o>0})()}makeQuickFilter(e,t,r){for(var a=t.split("||"),i=null,l=0;l<a.length;l+=1){for(var s=a[l],o=s.split("&&"),u=null,c=0;c<o.length;c+=1){var d=o[c].trim();if(d.length>0){var f=this.makeQuickFilterFromComponent(e,d,r);if(f)u?u=u.and(f):u=f;else throw new Error("Unable to parse quick filter from text ".concat(t))}}i&&u?i=i.or(u):i=u}return i}makeQuickFilterFromComponent(e,t,r){var{type:a}=e;return h.isNumberType(a)?this.makeQuickNumberFilter(e,t):h.isBooleanType(a)?this.makeQuickBooleanFilter(e,t):r!=null&&h.isDateType(a)?this.makeQuickDateFilter(e,t,r):h.isCharType(a)?this.makeQuickCharFilter(e,t):this.makeQuickTextFilter(e,t)}makeQuickNumberFilter(e,t){var r=e.filter(),{dh:a}=this,i=null,l=/\s*(>=|<=|=>|=<|>|<|!=|=|!)?(\s*-\s*)?(\s*\d*(?:,\d{3})*(?:\.\d*)?\s*)?(null|nan|infinity|inf|\u221E)?(.*)/i,s=l.exec(t),o=null,u=null,c=null,d=null,f=null;if(s!==null&&s.length>3&&([,o,u,c,d,f]=s),f!=null&&f.trim().length>0)return null;if(o==null&&(o="="),d!=null){if(!(o==="="||o==="!"||o==="!="))return null;switch(d=d.trim().toLowerCase(),d){case"null":i=r.isNull();break;case"nan":i=a.FilterCondition.invoke("isNaN",r);break;case"infinity":case"inf":case"∞":u!=null?i=a.FilterCondition.invoke("isInf",r).and(r.lessThan(a.FilterValue.ofNumber(0))):i=a.FilterCondition.invoke("isInf",r).and(r.greaterThan(a.FilterValue.ofNumber(0)));break}return i!==null&&(o==="!"||o==="!=")&&(i=i.not()),i}if(c==null)return null;if(c=h.removeCommas(c),h.isLongType(e.type))try{c=a.FilterValue.ofNumber(a.LongWrapper.ofString("".concat(u!=null?"-":"").concat(c)))}catch(p){return G.warn("Unable to create long filter",p),null}else{if(c=parseFloat(c),c==null||Number.isNaN(c))return null;c=a.FilterValue.ofNumber(u!=null?0-c:c)}return i=e.filter(),h.makeRangeFilterWithOperation(i,o,c)}static escapeQuickTextFilter(e){var t,r;if(e==null)return null;var a=/^(!~|!=|~|=|!)?(.*)/,i=/^\\*null$/,l=a.exec(e),s=null,o=null;if(l!==null&&l.length>2&&([,s,o]=l),s!=null){var u;return"\\".concat(s).concat((u=o)!==null&&u!==void 0?u:"")}return o!=null&&i.test(o.toLowerCase())||o!=null&&o.startsWith("*")?"\\".concat(o):o!=null&&o.endsWith("*")&&!o.endsWith("\\*")?(o=o.substring(0,o.length-1),"".concat(o,"\\*")):"".concat((t=s)!==null&&t!==void 0?t:"").concat((r=o)!==null&&r!==void 0?r:"")}static unescapeQuickTextFilter(e){var t,r,a=/^(\\!~|\\!=|\\~|\\=|\\!)?(.*)/,i=/^\\*null$/,l=a.exec(e),s=null,o=null;return l!==null&&l.length>2&&([,s,o]=l),s!=null&&(s=s.replace("\\","")),o!=null&&i.test(o.toLowerCase())&&(o=o.replace("\\","")),s==null&&o!=null&&o.startsWith("\\*")&&(o=o.substring(1)),s==null&&o!=null&&o.endsWith("\\*")?(o=o.substring(0,o.length-2),"".concat(o,"*")):"".concat((t=s)!==null&&t!==void 0?t:"").concat((r=o)!==null&&r!==void 0?r:"")}makeQuickTextFilter(e,t){var{dh:r}=this,a="".concat(t).trim(),i=/^(!~|!=|~|=|!)?(.*)/,l=i.exec(a),s=null,o=null;if(l!==null&&l.length>2&&([,s,o]=l,o!=null&&(o=o.trim())),o==null||o.length===0&&!(s==="="||s==="!="))return null;s==null&&(s="=");var u=e.filter();if(o.toLowerCase()==="null")switch(s){case"=":return u.isNull();case"!=":case"!":return u.isNull().not()}var c=null,d=null;switch(o.startsWith("*")?(c="*",o=o.substring(1)):o.endsWith("*")&&!o.endsWith("\\*")&&(d="*",o=o.substring(0,o.length-1)),o=h.unescapeQuickTextFilter(o),s){case"~":return u.isNull().not().and(u.invoke("matches",r.FilterValue.ofString("(?s)(?i).*\\Q".concat(o,"\\E.*"))));case"!~":return u.isNull().or(u.invoke("matches",r.FilterValue.ofString("(?s)(?i).*\\Q".concat(o,"\\E.*"))).not());case"!=":return c==="*"?u.isNull().or(u.invoke("matches",r.FilterValue.ofString("(?s)(?i).*\\Q".concat(o,"\\E$"))).not()):d==="*"?u.isNull().or(u.invoke("matches",r.FilterValue.ofString("(?s)(?i)^\\Q".concat(o,"\\E.*"))).not()):u.notEqIgnoreCase(r.FilterValue.ofString(o.toLowerCase()));case"=":return c==="*"?u.isNull().not().and(u.invoke("matches",r.FilterValue.ofString("(?s)(?i).*\\Q".concat(o,"\\E$")))):d==="*"?u.isNull().not().and(u.invoke("matches",r.FilterValue.ofString("(?s)(?i)^\\Q".concat(o,"\\E.*")))):u.eqIgnoreCase(r.FilterValue.ofString(o.toLowerCase()))}return null}makeQuickBooleanFilter(e,t){var r=/^(!=|=|!)?(.*)/,a=r.exec("".concat(t).trim());if(a===null)return null;var[,i,l]=a,s=i==="!"||i==="!=",o=l.trim().toLowerCase(),u=e.filter();try{var c=h.makeBooleanValue(o);return c!=null&&c?u=u.isTrue():c===null?u=u.isNull():u=u.isFalse(),s?u.not():u}catch{return null}}makeQuickDateFilter(e,t,r){var a=t.trim(),i=/\s*(>=|<=|=>|=<|>|<|!=|!|=)?(.*)/,l=i.exec(a);if(l==null||l.length<=2)throw new Error("Unable to parse date filter: ".concat(t));var s=null,o=null;[,s,o]=l;var u=m.eq;switch(s){case"<":u=m.lessThan;break;case"<=":case"=<":u=m.lessThanOrEqualTo;break;case">":u=m.greaterThan;break;case">=":case"=>":u=m.greaterThanOrEqualTo;break;case"!=":case"!":u=m.notEq;break;case"=":case"==":default:u=m.eq;break}return this.makeQuickDateFilterWithOperation(e,o,u,r)}makeQuickDateFilterWithOperation(e,t,r,a){var{dh:i}=this,[l,s]=O.parseDateRange(i,t,a),o=l!=null?i.FilterValue.ofNumber(l):null,u=s!=null?i.FilterValue.ofNumber(s):null,c=e.filter();if(o==null)return r===m.notEq?c.isNull().not():c.isNull();switch(r){case m.eq:{if(u!=null){var d=c.greaterThanOrEqualTo(o),f=c.lessThan(u);return d.and(f)}return c.eq(o)}case m.lessThan:return c.lessThan(o);case m.lessThanOrEqualTo:return u!=null?c.lessThan(u):c.lessThanOrEqualTo(o);case m.greaterThan:return u!=null?c.greaterThanOrEqualTo(u):c.greaterThan(o);case m.greaterThanOrEqualTo:return c.greaterThanOrEqualTo(o);case m.notEq:{if(u!=null){var p=c.lessThan(o),v=c.greaterThanOrEqualTo(u);return p.or(v)}return c.notEq(o)}default:throw new Error("Invalid operator: ".concat(r))}}makeQuickCharFilter(e,t){var{dh:r}=this,a="".concat(t).trim(),i=/^(>=|<=|=>|=<|>|<|!=|=|!)?(null|"."|'.'|.)?(.*)/,l=i.exec(a),s=null,o=null,u=null;if(l!==null&&l.length>3&&([,s,o,u]=l),u!=null&&u.trim().length>0||o==null||o.length===0)return null;s==null&&(s="=");var c=e.filter();if(o.toLowerCase()==="null")switch(s){case"=":return c.isNull();case"!=":case"!":return c.isNull().not();default:return null}var d=r.FilterValue.ofString(h.isRangeOperation(s)?h.quoteValue(o):o);return h.makeRangeFilterWithOperation(c,s,d)}makeAdvancedFilter(e,t,r){for(var{filterItems:a,filterOperators:i,invertSelection:l,selectedValues:s}=t,o=null,u=0;u<a.length;u+=1){var c=a[u],{selectedType:d,value:f}=c;if(d!=null&&d.length>0&&f!=null&&f.length>0)try{var p=this.makeAdvancedValueFilter(e,d,f,r);if(p!=null){if(u===0)o=p;else if(o!==null&&u-1<i.length){var v=i[u-1];if(v===ye.and)o=o.and(p);else if(v===ye.or)o=o.or(p);else{G.error("Unexpected filter operator",v,p),o=null;break}}}else G.debug2("Empty filter ignored for",d,f)}catch(S){G.error("Unable to create filter",S),o=null;break}}var y=this.makeSelectValueFilter(e,s,l);return y!=null&&(o!=null?o=o.and(y):o=y),o}makeAdvancedValueFilter(e,t,r,a){var{dh:i}=this;if(h.isDateType(e.type))return this.makeQuickDateFilterWithOperation(e,r,t,a);if(h.isNumberType(e.type)||h.isCharType(e.type))return this.makeQuickFilter(e,"".concat(h.getFilterOperatorString(t)).concat(r));var l=this.makeFilterValue(e.type,r),s=e.filter();switch(t){case m.eq:return s.eq(l);case m.eqIgnoreCase:return s.eqIgnoreCase(l);case m.notEq:return s.notEq(l);case m.notEqIgnoreCase:return s.notEqIgnoreCase(l);case m.greaterThan:return s.greaterThan(l);case m.greaterThanOrEqualTo:return s.greaterThanOrEqualTo(l);case m.lessThan:return s.lessThan(l);case m.lessThanOrEqualTo:return s.lessThanOrEqualTo(l);case m.isTrue:return s.isTrue();case m.isFalse:return s.isFalse();case m.isNull:return s.isNull();case m.contains:return s.isNull().not().and(s.invoke("matches",i.FilterValue.ofString("(?s)(?i).*\\Q".concat(r,"\\E.*"))));case m.notContains:return s.isNull().or(s.invoke("matches",i.FilterValue.ofString("(?s)(?i).*\\Q".concat(r,"\\E.*"))).not());case m.startsWith:return s.isNull().not().and(s.invoke("matches",i.FilterValue.ofString("(?s)(?i)^\\Q".concat(r,"\\E.*"))));case m.endsWith:return s.isNull().not().and(s.invoke("matches",i.FilterValue.ofString("(?s)(?i).*\\Q".concat(r,"\\E$"))));case m.in:case m.inIgnoreCase:case m.notIn:case m.notInIgnoreCase:case m.invoke:default:throw new Error("Unexpected filter operation: ".concat(t))}}applyNeverFilter(e,t){var r=arguments,a=this;return J(function*(){var i=r.length>2&&r[2]!==void 0?r[2]:h.APPLY_TABLE_CHANGE_TIMEOUT_MS;if(e==null)return null;var l=e.findColumn(t),s=[a.makeNeverFilter(l)];return yield a.applyFilter(e,s,i),e})()}applyCustomColumns(e,t){var r=arguments,a=this;return J(function*(){var i=r.length>2&&r[2]!==void 0?r[2]:h.APPLY_TABLE_CHANGE_TIMEOUT_MS,{dh:l}=a;return h.executeAndWaitForEvent(s=>s==null?void 0:s.applyCustomColumns(t),e,l.Table.EVENT_CUSTOMCOLUMNSCHANGED,i)})()}applyFilter(e,t){var r=arguments,a=this;return J(function*(){var i=r.length>2&&r[2]!==void 0?r[2]:h.APPLY_TABLE_CHANGE_TIMEOUT_MS,{dh:l}=a;return h.executeAndWaitForEvent(s=>s==null?void 0:s.applyFilter(t),e,l.Table.EVENT_FILTERCHANGED,i)})()}applySort(e,t){var r=arguments,a=this;return J(function*(){var i=r.length>2&&r[2]!==void 0?r[2]:h.APPLY_TABLE_CHANGE_TIMEOUT_MS,{dh:l}=a;return h.executeAndWaitForEvent(s=>s==null?void 0:s.applySort(t),e,l.Table.EVENT_SORTCHANGED,i)})()}makeNeverFilter(e){var{dh:t}=this,r=null;h.isTextType(e.type)?r=t.FilterValue.ofString("a"):h.isBooleanType(e.type)?r=t.FilterValue.ofBoolean(!0):h.isDateType(e.type)?r=t.FilterValue.ofNumber(t.DateWrapper.ofJsDate(new Date)):r=t.FilterValue.ofNumber(0);var a=e.filter().eq(r),i=e.filter().notEq(r);return a.and(i)}makeFilterValue(e,t){var{dh:r}=this,a=h.getBaseType(e);return h.isTextType(a)?r.FilterValue.ofString(t):h.isLongType(a)?r.FilterValue.ofNumber(r.LongWrapper.ofString(h.removeCommas(t))):r.FilterValue.ofNumber(h.removeCommas(t))}makeFilterRawValue(e,t){var{dh:r}=this;return h.isTextType(e)?r.FilterValue.ofString(t):h.isBooleanType(e)?r.FilterValue.ofBoolean(t):r.FilterValue.ofNumber(t)}makeValue(e,t,r){var{dh:a}=this;if(t==="null")return null;if(h.isTextType(e))return t;if(h.isLongType(e))return a.LongWrapper.ofString(h.removeCommas(t));if(h.isBooleanType(e))return h.makeBooleanValue(t,!0);if(h.isDateType(e)){var[i]=O.parseDateRange(a,t,r);return i}return h.isNumberType(e)?h.makeNumberValue(t):(G.error("Unexpected column type",e),null)}makeSelectValueFilter(e,t,r){var{dh:a}=this;if(t.length===0)return r?null:this.makeNeverFilter(e);for(var i=[],l=!1,s=0;s<t.length;s+=1){var o=t[s];o==null?l=!0:h.isTextType(e.type)?i.push(a.FilterValue.ofString(typeof o=="number"?String.fromCharCode(o):o)):h.isBooleanType(e.type)?i.push(a.FilterValue.ofBoolean(!!o)):i.push(a.FilterValue.ofNumber(o))}return l?i.length>0?r?e.filter().isNull().not().and(e.filter().notIn(i)):e.filter().isNull().or(e.filter().in(i)):r?e.filter().isNull().not():e.filter().isNull():r?e.filter().notIn(i):e.filter().in(i)}}se(h,"dataType",{BOOLEAN:"boolean",CHAR:"char",DATETIME:"datetime",DECIMAL:"decimal",INT:"int",STRING:"string",UNKNOWN:"unknown"});se(h,"sortDirection",{ascending:"ASC",descending:"DESC",reverse:"REVERSE",none:null});se(h,"APPLY_TABLE_CHANGE_TIMEOUT_MS",3e4);se(h,"REVERSE_TYPE",Object.freeze({NONE:"none",PRE_SORT:"pre-sort",POST_SORT:"post-sort"}));se(h,"NUMBER_REGEX",/^-?\d+(\.\d+)?$/);se(h,"executeAndWaitForEvent",function(){var n=J(function*(e,t,r){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:h.APPLY_TABLE_CHANGE_TIMEOUT_MS;if(t==null)return null;var i=h.makeCancelableTableEventPromise(t,r,a);return e(t),yield i,t});return function(e,t,r){return n.apply(this,arguments)}}());function Fe(n,e,t){return e=nn(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function nn(n){var e=an(n,"string");return typeof e=="symbol"?e:String(e)}function an(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}class ke{static makeColumnFormatMap(e){return e==null?new Map:e.reduce((t,r)=>{var a=h.getNormalizedType(r.columnType);if(a===null)return t;t.has(a)||t.set(a,new Map);var i=t.get(a);return i==null||i.set(r.columnName,r.format),t},new Map)}static makeColumnFormattingRule(e,t,r){return{columnType:e,columnName:t,format:r}}constructor(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],r=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0,l=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!1;Fe(this,"defaultColumnFormatter",void 0),Fe(this,"typeFormatterMap",void 0),Fe(this,"columnFormatMap",void 0),Fe(this,"truncateNumbersWithPound",void 0),this.defaultColumnFormatter=new Hr,this.typeFormatterMap=new Map([[h.dataType.BOOLEAN,new Cr],[h.dataType.CHAR,new xr],[h.dataType.DATETIME,new q(e,r)],[h.dataType.DECIMAL,new N(e,a)],[h.dataType.INT,new K(e,i)],[h.dataType.STRING,new qr]]),this.columnFormatMap=ke.makeColumnFormatMap(t),this.truncateNumbersWithPound=l}getColumnFormatMapForType(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,r=h.getNormalizedType(e);if(r!==null)return t&&!this.columnFormatMap.has(r)&&this.columnFormatMap.set(r,new Map),this.columnFormatMap.get(r)}getColumnFormat(e,t){var r,a=this.getColumnFormatMapForType(e);return(r=a==null?void 0:a.get(t))!==null&&r!==void 0?r:null}getColumnTypeFormatter(e){var t=h.getNormalizedType(e),r=this.defaultColumnFormatter;if(t){var a;r=(a=this.typeFormatterMap.get(t))!==null&&a!==void 0?a:r}return r}getFormattedString(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"",a=arguments.length>3?arguments[3]:void 0;if(e==null)return"";var i=this.getColumnTypeFormatter(t),l=a||this.getColumnFormat(t,r);return i.format(e,l??void 0)}get timeZone(){var e,t=this.typeFormatterMap.get(h.dataType.DATETIME);return t==null||(e=t.dhTimeZone)===null||e===void 0?void 0:e.id}}function sn(n){if(n&&n.formatter){var{formatter:e}=n;return e}}function on(n){return{timeZone:n==null?void 0:n.timeZone,defaultDateTimeFormatString:n==null?void 0:n.defaultDateTimeFormat,showTimeZone:n==null?void 0:n.showTimeZone,showTSeparator:n==null?void 0:n.showTSeparator}}function ln(n,e,t){var r=n.getColumnFormat(t,e);return r!=null&&(r.type===k.TYPE_CONTEXT_PRESET||r.type===k.TYPE_CONTEXT_CUSTOM)}const Oe={getColumnFormats:sn,getDateTimeFormatterOptions:on,isCustomColumnFormatDefined:ln},un=typeof Me=="function"?Me:Me.default;ut.register([Lt,kt,_t,Vt,jt,Ht]);function $(n,e,t){return e=cn(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function cn(n){var e=dn(n,"string");return typeof e=="symbol"?e:String(e)}function dn(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}class C{constructor(e){$(this,"dh",void 0),$(this,"listeners",void 0),$(this,"formatter",void 0),$(this,"rect",void 0),$(this,"isDownsamplingDisabled",void 0),$(this,"title",void 0),this.dh=e,this.listeners=[],this.isDownsamplingDisabled=!1}getData(){return[]}getDefaultTitle(){return""}getLayout(){return{}}getFilterColumnMap(){return new Map}isFilterRequired(){return!1}setFilter(e){}close(){}setFormatter(e){this.formatter=e}setDownsamplingDisabled(e){this.isDownsamplingDisabled=e}setDimensions(e){this.rect=e}setTitle(e){this.title=e}subscribe(e){this.listeners.push(e)}unsubscribe(e){this.listeners=this.listeners.filter(t=>t!==e)}fireEvent(e){for(var t=0;t<this.listeners.length;t+=1)this.listeners[t](e)}fireUpdate(e){this.fireEvent(new CustomEvent(C.EVENT_UPDATED,{detail:e}))}fireDisconnect(){this.fireEvent(new CustomEvent(C.EVENT_DISCONNECT))}fireReconnect(){this.fireEvent(new CustomEvent(C.EVENT_RECONNECT))}fireDownsampleStart(e){this.fireEvent(new CustomEvent(C.EVENT_DOWNSAMPLESTARTED,{detail:e}))}fireDownsampleFinish(e){this.fireEvent(new CustomEvent(C.EVENT_DOWNSAMPLEFINISHED,{detail:e}))}fireDownsampleFail(e){this.fireEvent(new CustomEvent(C.EVENT_DOWNSAMPLEFAILED,{detail:e}))}fireDownsampleNeeded(e){this.fireEvent(new CustomEvent(C.EVENT_DOWNSAMPLENEEDED,{detail:e}))}fireLoadFinished(){this.fireEvent(new CustomEvent(C.EVENT_LOADFINISHED))}}$(C,"EVENT_UPDATED","ChartModel.EVENT_UPDATED");$(C,"EVENT_DISCONNECT","ChartModel.EVENT_DISCONNECT");$(C,"EVENT_RECONNECT","ChartModel.EVENT_RECONNECT");$(C,"EVENT_DOWNSAMPLESTARTED","ChartModel.EVENT_DOWNSAMPLESTARTED");$(C,"EVENT_DOWNSAMPLEFINISHED","ChartModel.EVENT_DOWNSAMPLEFINISHED");$(C,"EVENT_DOWNSAMPLEFAILED","ChartModel.EVENT_DOWNSAMPLEFAILED");$(C,"EVENT_DOWNSAMPLENEEDED","ChartModel.EVENT_DOWNSAMPLENEEDED");$(C,"EVENT_LOADFINISHED","ChartModel.EVENT_LOADFINISHED");const X=C;function Qe(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(n,a).enumerable})),t.push.apply(t,r)}return t}function le(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Qe(Object(t),!0).forEach(function(r){R(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Qe(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function R(n,e,t){return e=hn(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function hn(n){var e=fn(n,"string");return typeof e=="symbol"?e:String(e)}function fn(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}var me=W.module("ChartUtils"),Je="io.deephaven.time.DateTime",mn=36e5,gn=1e6;function vn(n){return n.asDate!==void 0}function pn(n){return n.asNumber!==void 0}function Ue(n){return n.dhTimeZone!==void 0}function yn(n){return n!=null&&n.range!=null&&(n.autorange===!1||n.autorange===void 0)}class g{static getPlotlyErrorBars(e,t,r,a){var i=r.map((s,o)=>s-e[o]),l=t.map((s,o)=>e[o]-s);return{type:"data",symmetric:!1,array:i,arrayminus:l,color:a.error_band_line_color}}static convertNumberPrefix(e){return e.replace(/\u00A4\u00A4/g,"USD").replace(/\u00A4/g,"$")}static getPlotlyNumberFormat(e,t,r){if(!r)return null;var a=r.split(";"),i=a[0].match(/^([^#,0.]*)([#,]*)([0,]*)(\.?)(0*)(#*)(E?0*)(%?)(.*)/);fe(i);var[,l,s,o,,u,c,d,f,p]=i,v=o.replace(",","").length,y=s.indexOf(",")>=0||o.indexOf(",")>=0,S=y?",":"",E=d!=null&&d!==""?"e":"f",F=f!==""?f:E,b=u.length+c.length,P="",A="0".concat(v).concat(S,".").concat(b).concat(P).concat(F),M=g.convertNumberPrefix(l),I=g.convertNumberPrefix(p);return{tickformat:A,tickprefix:M,ticksuffix:I,automargin:!0}}static addTickSpacing(e,t,r){var{gapBetweenMajorTicks:a}=t;if(a>0){var i=e||{},l=a;return r&&(l=a/gn),t.log&&(l=Math.log(l)),i.tickmode="linear",i.dtick=l,i}return e}static getSourceForAxis(e,t){for(var r=0;r<e.series.length;r+=1)for(var a=e.series[r],i=0;i<a.sources.length;i+=1){var l=a.sources[i];if(l.axis===t)return l}return null}static getSeriesVisibility(e,t){return t!=null&&t.hiddenSeries!=null&&t.hiddenSeries.includes(e)?"legendonly":!0}static getHiddenLabels(e){return e!=null&&e.hiddenSeries?[...e.hiddenSeries]:[]}static makeSeriesData(e,t,r,a){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:g.ORIENTATION.VERTICAL;return{type:e,mode:t,name:r,orientation:i,showlegend:a??void 0}}static getMarkerSymbol(e){switch(e){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 ".concat(e))}}static getAllAxes(e){return e.charts.reduce((t,r)=>[...t,...r.axes],[])}static getChartForSeries(e,t){for(var{charts:r}=e,a=0;a<r.length;a+=1)for(var i=r[a],l=0;l<i.series.length;l+=1)if(t===i.series[l])return i;return null}static getLayoutRanges(e){for(var t={},r=Object.keys(e).filter(s=>s.indexOf("axis")>=0),a=0;a<r.length;a+=1){var i=r[a],l=e[i];yn(l)&&(t[i]=[...l.range])}return t}static getAxisLayoutProperty(e,t){var r=t>0?"".concat(t+1):"";return"".concat(e??"","axis").concat(r)}static periodToDecimal(e){var t=e.split(":");return Number(t[0])+Number(t[1])/60}static groupArray(e,t){return e.reduce((r,a)=>{var i,l=a[t],s=(i=r.get(l))!==null&&i!==void 0?i:[];return s.push(a),r.set(l,s),r},new Map)}static getColorwayFromTheme(e){var t=[];return e.colorway&&(Array.isArray(e.colorway)?t=e.colorway:typeof e.colorway=="string"?t=e.colorway.split(" "):me.warn("Unable to handle colorway property: ".concat(e.colorway))),t}static titleFromSettings(e){var{series:t,xAxis:r,title:a="".concat((t??[]).join(", ")," by ").concat(r)}=e;return a}constructor(e){R(this,"dh",void 0),R(this,"daysOfWeek",void 0),this.dh=e,this.daysOfWeek=Object.freeze(e.calendar.DayOfWeek.values())}getAxisFormats(e,t){for(var r=this,a=new Map,i={tickformat:null,ticksuffix:null},l=g.getAllAxes(e),s=g.groupArray(l,"type"),{charts:o}=e,u=0;u<o.length;u+=1)for(var c=o[u],d=0;d<c.series.length;d+=1)for(var f=c.series[d],{sources:p}=f,v=p.filter(F=>F.axis),y=function(){var b=v[S],{axis:P}=b,{type:A}=P,M=s.get(A);fe(M);var I=M.indexOf(P),x=r.getAxisPropertyName(A);if(x!=null){var _=g.getAxisLayoutProperty(x,I);if(a.has(_))me.debug("".concat(_," already added."));else{me.debug("Adding ".concat(_," to axisFormats."));var re=r.getPlotlyAxisFormat(b,t);if(re===null)a.set(_,i);else{a.set(_,re);var{businessCalendar:Z}=P;if(Z!=null){var B=[],{businessPeriods:oe,businessDays:ne,holidays:Se,timeZone:ue}=Z,ce=t==null?void 0:t.getColumnTypeFormatter(Je),Ee;Ue(ce)&&(Ee=ce.dhTimeZone);var Ve=Ee?(ue.standardOffset-Ee.standardOffset)/60:0;Se.length>0&&B.push(...r.createRangeBreakValuesFromHolidays(Se,ue,Ee)),oe.forEach(Te=>B.push({pattern:"hour",bounds:[g.periodToDecimal(Te.close)+Ve,g.periodToDecimal(Te.open)+Ve]})),ne.length<r.daysOfWeek.length&&r.createBoundsFromDays(ne).forEach(Te=>B.push({pattern:"day of week",bounds:Te})),re.rangebreaks=B}if(a.size===c.axes.length)return{v:a}}}}},S=0;S<v.length;S+=1){var E=y();if(typeof E=="object")return E.v}return a}getPlotlyChartType(e,t){var{dh:r}=this;switch(e){case r.plot.SeriesPlotStyle.SCATTER:return t?"scatter":"scattergl";case r.plot.SeriesPlotStyle.LINE:return"scatter";case r.plot.SeriesPlotStyle.BAR:case r.plot.SeriesPlotStyle.STACKED_BAR:return"bar";case r.plot.SeriesPlotStyle.PIE:return"pie";case r.plot.SeriesPlotStyle.TREEMAP:return"treemap";case r.plot.SeriesPlotStyle.HISTOGRAM:return"histogram";case r.plot.SeriesPlotStyle.OHLC:return"ohlc";default:return}}getPlotlyChartMode(e,t,r){var{dh:a}=this,i=new Set;switch(e){case a.plot.SeriesPlotStyle.SCATTER:(t??!1)&&i.add(g.MODE_LINES),(r??!0)&&i.add(g.MODE_MARKERS);break;case a.plot.SeriesPlotStyle.LINE:(t??!0)&&i.add(g.MODE_LINES),(r??!1)&&i.add(g.MODE_MARKERS);break}return i.size>0?[...i].join("+"):void 0}getPlotlyProperty(e,t){var{dh:r}=this;switch(e){case r.plot.SeriesPlotStyle.PIE:switch(t){case r.plot.SourceType.X:return"labels";case r.plot.SourceType.Y:return"values"}break;case r.plot.SeriesPlotStyle.OHLC:switch(t){case r.plot.SourceType.TIME:return"x"}break;case r.plot.SeriesPlotStyle.TREEMAP:switch(t){case r.plot.SourceType.X:return"ids";case r.plot.SourceType.Y:return"values";case r.plot.SourceType.LABEL:return"labels";case r.plot.SourceType.PARENT:return"parents";case r.plot.SourceType.COLOR:return"marker.colors"}break}switch(t){case r.plot.SourceType.X:return"x";case r.plot.SourceType.Y:return"y";case r.plot.SourceType.Z:return"z";case r.plot.SourceType.X_LOW:return"xLow";case r.plot.SourceType.X_HIGH:return"xHigh";case r.plot.SourceType.Y_LOW:return"yLow";case r.plot.SourceType.Y_HIGH:return"yHigh";case r.plot.SourceType.TIME:return"time";case r.plot.SourceType.OPEN:return"open";case r.plot.SourceType.HIGH:return"high";case r.plot.SourceType.LOW:return"low";case r.plot.SourceType.CLOSE:return"close";case r.plot.SourceType.SHAPE:return"shape";case r.plot.SourceType.SIZE:return"size";case r.plot.SourceType.LABEL:return"label";case r.plot.SourceType.COLOR:return"color";case r.plot.SourceType.PARENT:return"parent";case r.plot.SourceType.HOVER_TEXT:return"hovertext";case r.plot.SourceType.TEXT:return"text";default:throw new Error("Unrecognized source type: ".concat(t))}}getPlotlySeriesOrientation(e){var t,r,{dh:a}=this,{sources:i}=e;return i.length===2&&((t=i[0])===null||t===void 0||(r=t.axis)===null||r===void 0?void 0:r.type)===a.plot.AxisType.Y?g.ORIENTATION.HORIZONTAL:g.ORIENTATION.VERTICAL}makeSeriesDataFromSeries(e,t,r,a){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:null,{name:l,isLinesVisible:s,isShapesVisible:o,plotStyle:u,lineColor:c,shapeColor:d,sources:f,shape:p,shapeSize:v}=e,y=f.some(P=>{var A;return(A=P.axis)===null||A===void 0?void 0:A.businessCalendar}),S=this.getChartType(u,y),E=this.getPlotlyChartMode(u,s??void 0,o??void 0),F=this.getPlotlySeriesOrientation(e),b=g.makeSeriesData(S,E,l,i,F);return this.addSourcesToSeriesData(b,u,f,t),this.addStylingToSeriesData(b,u,a,c,d,p,v,r),b}addSourcesToSeriesData(e,t,r,a){for(var i=e,l=0;l<r.length;l+=1){var s=r[l],{axis:o,type:u}=s,c=this.getPlotlyProperty(t,u);lt(i,c,[]);var d=o!=null?this.getAxisPropertyName(o.type):null;if(d!=null){var f=a.get(o.type);if(f){var p=f.indexOf(o),v=p>0?"".concat(p+1):"";i["".concat(d,"axis")]="".concat(d).concat(v)}}}}addStylingToSeriesData(e,t,r){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:null,l=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null,s=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,o=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null,{dh:u}=this,c=e;if(c.marker={line:{}},c.line={width:1},t===u.plot.SeriesPlotStyle.AREA?c.fill="tozeroy":t===u.plot.SeriesPlotStyle.STACKED_AREA?c.stackgroup="stack":t===u.plot.SeriesPlotStyle.STEP?c.line.shape="hv":t===u.plot.SeriesPlotStyle.HISTOGRAM?(c.width=[],c.marker.line!==void 0&&Object.assign(c.marker.line,{color:r.paper_bgcolor,width:1})):t===u.plot.SeriesPlotStyle.OHLC?(c.increasing={line:{color:r.ohlc_increasing}},c.decreasing={line:{color:r.ohlc_decreasing}}):t===u.plot.SeriesPlotStyle.PIE?(c.textinfo="label+percent",c.outsidetextfont={color:r.title_color}):t===u.plot.SeriesPlotStyle.TREEMAP&&(c.hoverinfo="text",c.textinfo="label+text",c.tiling={packing:"squarify",pad:0},c.textposition="middle center",c.outsidetextfont={color:r.title_color}),a!=null&&(t===u.plot.SeriesPlotStyle.BAR?c.marker.color=a:c.line.color=a),i!=null&&(c.marker.color=i),l!=null&&l.length>0)try{c.marker.symbol=g.getMarkerSymbol(l)}catch(d){me.warn("Unable to handle shape",l,":",d)}s!=null&&(c.marker.size=s*g.DEFAULT_MARKER_SIZE),o!=null&&t!==u.plot.SeriesPlotStyle.PIE&&(c.visible=o)}getChartType(e,t){var{dh:r}=this;switch(e){case r.plot.SeriesPlotStyle.HISTOGRAM:return"bar";default:return this.getPlotlyChartType(e,t)}}getAxisPropertyName(e){var{dh:t}=this;switch(e){case t.plot.AxisType.X:return"x";case t.plot.AxisType.Y:return"y";default:return null}}getAxisSide(e){var{dh:t}=this;switch(e){case t.plot.AxisPosition.BOTTOM:return"bottom";case t.plot.AxisPosition.TOP:return"top";case t.plot.AxisPosition.LEFT:return"left";case t.plot.AxisPosition.RIGHT:return"right";default:return}}updateFigureAxes(e,t,r,a){for(var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0,l=arguments.length>5&&arguments[5]!==void 0?arguments[5]:0,s=e,o=g.getAllAxes(t),u=0;u<t.charts.length;u+=1){var c=t.charts[u],d=a==null?void 0:a(c),f=this.getChartBounds(t,c,i,l);this.updateLayoutAxes(s,c.axes,o,r,i,l,f,d)}this.removeStaleAxes(s,o)}getChartBounds(e,t,r,a){var i,{dh:l}=this,{cols:s,rows:o}=e,{column:u,colspan:c,row:d,rowspan:f}=t,p=u+c,v=d+f,y=1/s,S=1/o,E=g.AXIS_SIZE_PX/r,F=g.AXIS_SIZE_PX/a,b={bottom:(o-v)*S+(v<o?F/2:0),top:(o-d)*S-(d>0?F/2:0),left:u*y+(u>0?E/2:0),right:p*y-(p<s?E/2:0)},P=g.groupArray(t.axes,"position"),A=(i=P.get(l.plot.AxisPosition.RIGHT))!==null&&i!==void 0?i:[];return A.length>0&&(r>0?b.right-=(b.right-b.left)*Math.max(0,Math.min(g.LEGEND_WIDTH_PX/r,g.MAX_LEGEND_SIZE)):b.right-=(b.right-b.left)*g.DEFAULT_AXIS_SIZE),b}getPlotlyDateFormat(e,t,r){var{dh:a}=this,i=r==null?void 0:r.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",""),l,s=e==null?void 0:e.getColumnTypeFormatter(t);return s!=null&&Ue(s)&&s.dhTimeZone!=null&&s.showTimeZone&&(l=a.i18n.DateTimeFormat.format(" z",new Date,s.dhTimeZone)),{tickformat:i,ticksuffix:l,automargin:!0}}getPlotlyAxisFormat(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,{dh:r}=this,{axis:a,columnType:i}=e,{formatPattern:l}=a,s=null;return h.isDateType(i)?(s=this.getPlotlyDateFormat(t,i,l),s=g.addTickSpacing(s,a,!0)):h.isNumberType(i)&&(s=g.getPlotlyNumberFormat(t,i,l),s=g.addTickSpacing(s,a,!1)),a.formatType===r.plot.AxisFormatType.CATEGORY&&(s?s.type="category":s={type:"category",tickformat:void 0,ticksuffix:void 0}),s}updateLayoutAxes(e,t,r,a){for(var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0,l=arguments.length>5&&arguments[5]!==void 0?arguments[5]:0,s=arguments.length>6&&arguments[6]!==void 0?arguments[6]:{left:0,top:0,right:1,bottom:1},o=arguments.length>7?arguments[7]:void 0,{dh:u}=this,c=i>0?Math.max(g.MIN_AXIS_SIZE,Math.min(g.AXIS_SIZE_PX/l,g.MAX_AXIS_SIZE)):g.DEFAULT_AXIS_SIZE,d=l>0?Math.max(g.MIN_AXIS_SIZE,Math.min(g.AXIS_SIZE_PX/i,g.MAX_AXIS_SIZE)):g.DEFAULT_AXIS_SIZE,f=e,p=g.groupArray(t,"position"),v=g.groupArray(t,"type"),y=[...v.keys()],S=g.groupArray(r,"type"),E=0;E<y.length;E+=1){var F=y[E],b=this.getAxisPropertyName(F);if(b!=null){var P=v.get(F),A=S.get(F),M=F===u.plot.AxisType.Y,I=M?l:i;fe(P),fe(A);for(var x=0;x<P.length;x+=1){var _=P[x],re=A.indexOf(_),Z=g.getAxisLayoutProperty(b,re);f[Z]==null&&(f[Z]=this.makeLayoutAxis(F,a));var B=f[Z];if(B!=null){this.updateLayoutAxis(B,_,x,p,c,d,s);var{range:oe,autorange:ne}=B;if(o!=null&&oe!==void 0&&(ne===void 0||ne===!1)){var Se=o(_),[ue,ce]=Se(oe);me.debug("Setting downsample range",I,ue,ce),_.range(I,ue,ce)}else _.range(I)}}}}}removeStaleAxes(e,t){for(var r=e,a=g.groupArray(t,"type"),i=[...a.keys()],l=0;l<i.length;l+=1){var s=i[l],o=a.get(s);fe(o);var u=o.length,c=this.getAxisPropertyName(s);if(c!=null)for(var d=g.getAxisLayoutProperty(c,u);r[d]!=null;)delete r[d],u+=1,d=g.getAxisLayoutProperty(c,u)}}updateLayoutAxis(e,t,r,a,i,l,s){var o,{dh:u}=this,c=t.type===u.plot.AxisType.Y,d=c?l:i,f=e,p=(o=t.label)!==null&&o!==void 0?o:"";if(f.title!==void 0&&typeof f.title!="string"?f.title.text=p:f.title={text:p},t.log&&(f.type="log"),f.side=this.getAxisSide(t.position),r>0){var v,y;f.overlaying=(v=this.getAxisPropertyName(t.type))!==null&&v!==void 0?v:void 0;var S=(y=a.get(t.position))!==null&&y!==void 0?y:[],E=S.indexOf(t);E>0&&(f.anchor="free",t.position===u.plot.AxisPosition.RIGHT?f.position=s.right+(E-S.length+1)*d:t.position===u.plot.AxisPosition.TOP?f.position=s.top+(E-S.length+1)*d:t.position===u.plot.AxisPosition.BOTTOM?f.position=s.bottom+(S.length-E+1)*d:t.position===u.plot.AxisPosition.LEFT&&(f.position=s.left+(S.length-E+1)*d))}else if(t.type===u.plot.AxisType.X){var F=a.get(u.plot.AxisPosition.LEFT)||[],b=a.get(u.plot.AxisPosition.RIGHT)||[],P=Math.max(s.left,s.left+(F.length-1)*l),A=Math.min(s.right-(b.length-1)*l,s.right);f.domain=[P,A]}else if(t.type===u.plot.AxisType.Y){var M=a.get(u.plot.AxisPosition.BOTTOM)||[],I=a.get(u.plot.AxisPosition.TOP)||[],x=Math.max(s.bottom,s.bottom+(M.length-1)*i),_=Math.min(s.top-(I.length-1)*i,s.top);f.domain=[x,_]}}createBoundsFromDays(e){var t=e.map(l=>this.daysOfWeek.indexOf(l)),r=this.daysOfWeek.filter(l=>!e.includes(l)).map(l=>this.daysOfWeek.indexOf(l)),a=new Set;r.forEach(l=>{for(var s=l+1;s<l+this.daysOfWeek.length;s+=1){var o=s%this.daysOfWeek.length;if(t.includes(o)){a.add(o);break}}});var i=[];return a.forEach(l=>{for(var s=l-1;s>l-this.daysOfWeek.length;s-=1){var o=s<0?s+this.daysOfWeek.length:s;if(t.includes(o)){var u=(o+1)%7;i.push([u,l]);break}}}),i}createRangeBreakValuesFromHolidays(e,t,r){var a=[],i=[];return e.forEach(l=>{l.businessPeriods.length>0?i.push(...this.createPartialHoliday(l,t,r)):a.push(this.createFullHoliday(l,t,r))}),[{values:a},...i]}createFullHoliday(e,t,r){return this.adjustDateForTimeZone("".concat(e.date.toString()," 00:00:00.000000"),t,r)}createPartialHoliday(e,t,r){var a=e.date.toString(),i=["00:00"];e.businessPeriods.forEach(f=>{i.push(f.open),i.push(f.close)}),i.push("24:00");for(var l=[],s=0;s<i.length;s+=2){var o=i[s],u=i[s+1];if(o!==u){var c=[this.adjustDateForTimeZone("".concat(a," ").concat(o,":00.000000"),t,r)],d=mn*(g.periodToDecimal(u)-g.periodToDecimal(o));l.push({values:c,dvalue:d})}}return l}adjustDateForTimeZone(e,t,r){return r&&r.standardOffset!==t.standardOffset?this.unwrapValue(this.wrapValue(e,Je,t),r):e}makeFigureSettings(e,t){var{dh:r}=this,{series:a,xAxis:i,type:l}=e,s=g.titleFromSettings(e),o={formatType:"".concat(r.plot.AxisFormatType.NUMBER),type:"".concat(r.plot.AxisType.X),position:"".concat(r.plot.AxisPosition.BOTTOM)},u={formatType:"".concat(r.plot.AxisFormatType.NUMBER),type:"".concat(r.plot.AxisType.Y),position:"".concat(r.plot.AxisPosition.LEFT)};return{charts:[{chartType:"".concat(r.plot.ChartType.XY),axes:[o,u],series:(a??[]).map(c=>({plotStyle:"".concat(l),name:c,dataSources:[{type:"".concat(r.plot.SourceType.X),columnName:i??"",axis:o,table:t},{type:"".concat(r.plot.SourceType.Y),columnName:c,axis:u,table:t}]}))}],title:s}}unwrapValue(e,t){var{dh:r}=this;if(e!=null){if(vn(e))return r.i18n.DateTimeFormat.format(g.DATE_FORMAT,e,t);if(pn(e))return e.asNumber()}return e}wrapValue(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,{dh:a}=this;if(h.isDateType(t)&&typeof e=="string"){var i=e,l=g.DATE_FORMAT.substr(0,e.length),s=a.i18n.DateTimeFormat.parse(l,i);if(!r)return s;var o="".concat(l," Z"),u=a.i18n.DateTimeFormat.format("Z",s,r),c=a.i18n.DateTimeFormat.parse(o,"".concat(i," ").concat(u)),d=a.i18n.DateTimeFormat.format("Z",c,r);return a.i18n.DateTimeFormat.parse(o,"".concat(i," ").concat(d))}return e}makeLayoutAxis(e,t){var{dh:r}=this,a={automargin:!0,gridcolor:t.gridcolor,linecolor:t.linecolor,rangeslider:{visible:!1},showline:!0,ticklen:5,tickcolor:t.paper_bgcolor,tickfont:{color:t.zerolinecolor},title:{font:{color:t.title_color}}};return e===r.plot.AxisType.X?Object.assign(a,{showgrid:!0}):e===r.plot.AxisType.Y&&Object.assign(a,{zerolinecolor:t.zerolinecolor,zerolinewidth:2}),a}makeDefaultLayout(e){var{dh:t}=this,r=le(le({},e),{},{autosize:!0,colorway:g.getColorwayFromTheme(e),font:{family:"'Fira Sans', sans-serif",color:e.title_color},title:{font:{color:e.title_color},yanchor:"top",pad:le({},g.DEFAULT_TITLE_PADDING),y:1},legend:{font:{color:e.title_color}},margin:le({},g.DEFAULT_MARGIN),xaxis:this.makeLayoutAxis(t.plot.AxisType.X,e),yaxis:this.makeLayoutAxis(t.plot.AxisType.Y,e),polar:{angularaxis:this.makeLayoutAxis(t.plot.AxisType.SHAPE,e),radialaxis:this.makeLayoutAxis(t.plot.AxisType.SHAPE,e),bgcolor:e.plot_bgcolor},scene:{xaxis:this.makeLayoutAxis(t.plot.AxisType.X,e),yaxis:this.makeLayoutAxis(t.plot.AxisType.Y,e),zaxis:this.makeLayoutAxis(t.plot.AxisType.Z,e)}});return r.datarevision=0,r}hydrateSettings(e){var{dh:t}=this;return le(le({},e),{},{type:e.type!=null?t.plot.SeriesPlotStyle[e.type]:void 0})}}R(g,"DEFAULT_AXIS_SIZE",.15);R(g,"MIN_AXIS_SIZE",.025);R(g,"MAX_AXIS_SIZE",.2);R(g,"AXIS_SIZE_PX",75);R(g,"LEGEND_WIDTH_PX",50);R(g,"MAX_LEGEND_SIZE",.25);R(g,"ORIENTATION",Object.freeze({HORIZONTAL:"h",VERTICAL:"v"}));R(g,"DATE_FORMAT","yyyy-MM-dd HH:mm:ss.SSSSSS");R(g,"DEFAULT_MARGIN",Object.freeze({l:60,r:50,t:30,b:60,pad:0}));R(g,"DEFAULT_TITLE_PADDING",Object.freeze({t:8}));R(g,"SUBTITLE_LINE_HEIGHT",25);R(g,"DEFAULT_MARKER_SIZE",6);R(g,"MODE_MARKERS","markers");R(g,"MODE_LINES","lines");const j=g;function et(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(n,a).enumerable})),t.push.apply(t,r)}return t}function tt(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?et(Object(t),!0).forEach(function(r){L(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):et(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function L(n,e,t){return e=Sn(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Sn(n){var e=En(n,"string");return typeof e=="symbol"?e:String(e)}function En(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}var Q=W.module("Chart");class ie extends H.Component{static convertIcon(e){var[t,,,,r]=e.icon,a="".concat(r);return{width:t,path:a,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"}constructor(e){super(e),L(this,"currentSeries",void 0),L(this,"PlotComponent",void 0),L(this,"plot",void 0),L(this,"plotWrapper",void 0),L(this,"columnFormats",void 0),L(this,"dateTimeFormatterOptions",void 0),L(this,"decimalFormatOptions",void 0),L(this,"integerFormatOptions",void 0),L(this,"rect",void 0),L(this,"ranges",void 0),L(this,"isSubscribed",void 0),L(this,"isLoadedFired",void 0),L(this,"resizeObserver",void 0),L(this,"getCachedConfig",yt((t,r,a,i,l)=>{var s=[],o=!!t;if(o&&s.push({name:"Downsampling failed: ".concat(t),title:"Downsampling failed",click:()=>{},icon:ie.convertIcon(At),attr:"fill-warning"}),r||a||i||o){var u=ie.downsampleButtonTitle(a,i),c=ie.downsampleButtonAttr(a,i),d=a?Ot:Ct;s.push({name:u,title:"Downsampling status",icon:ie.convertIcon(d),click:this.handleDownsampleClick,attr:c})}var f=l.some(S=>{var{type:E}=S;return E!=null&&!E.includes("3d")}),p=l.some(S=>{var{type:E}=S;return E!=null&&E.includes("3d")}),v=["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"],y=["orbitRotation","tableRotation","resetCameraDefault3d"];return{displaylogo:!1,displayModeBar:a||o?!0:"hover",modeBarButtons:[s,["toImage"],["zoom2d","pan2d"],[...f?v:[],...p?y:[]]]}})),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.handleResize=this.handleResize.bind(this),this.handleRestyle=this.handleRestyle.bind(this),this.PlotComponent=un(e.Plotly),this.plot=Y.createRef(),this.plotWrapper=Y.createRef(),this.columnFormats=[],this.dateTimeFormatterOptions={},this.decimalFormatOptions={},this.integerFormatOptions={},this.isSubscribed=!1,this.isLoadedFired=!1,this.currentSeries=0,this.resizeObserver=new window.ResizeObserver(this.handleResize),this.state={data:null,downsamplingError:null,isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,layout:{datarevision:0},revision:0}}componentDidMount(){this.updateDimensions(),this.updateModelDimensions(),this.initData(),this.initFormatter();var{isActive:e,model:t}=this.props;e&&this.subscribe(t),this.plotWrapper.current!=null&&this.resizeObserver.observe(this.plotWrapper.current)}componentDidUpdate(e){var{isActive:t,model:r,settings:a}=this.props;this.updateFormatterSettings(a),r!==e.model&&(this.unsubscribe(e.model),this.subscribe(r)),t!==e.isActive&&(t?(this.updateDimensions(),this.subscribe(r)):this.unsubscribe(r))}componentWillUnmount(){var{model:e}=this.props;this.unsubscribe(e),this.resizeObserver.disconnect()}getPlotRect(){var e,t;return(e=(t=this.plotWrapper.current)===null||t===void 0?void 0:t.getBoundingClientRect())!==null&&e!==void 0?e:null}initData(){var{model:e}=this.props,{layout:t}=this.state;this.setState({data:e.getData(),layout:tt(tt({},t),e.getLayout())})}subscribe(e){if(!this.isSubscribed){if(!this.rect||this.rect.width===0||this.rect.height===0){Q.debug2("Delaying subscription until model dimensions are set");return}e.subscribe(this.handleModelEvent),this.isSubscribed=!0}}unsubscribe(e){this.isSubscribed&&(e.unsubscribe(this.handleModelEvent),this.isSubscribed=!1)}handleAfterPlot(){this.plot.current!=null}handleDownsampleClick(){this.setState(e=>{var{isDownsamplingDisabled:t}=e;return{downsamplingError:null,isDownsampleInProgress:!1,isDownsampleFinished:!1,isDownsamplingDisabled:!t}},()=>{var{model:e}=this.props,{isDownsamplingDisabled:t}=this.state;e.setDownsamplingDisabled(t)})}handleModelEvent(e){var{type:t,detail:r}=e;switch(Q.debug2("Received data update",t,r),t){case X.EVENT_UPDATED:{this.currentSeries+=1,this.setState(d=>{var{layout:f,revision:p}=d;return typeof f.datarevision=="number"&&(f.datarevision+=1),{data:r,layout:f,revision:p+1}});var{onUpdate:a}=this.props;a({isLoading:!this.isLoadedFired});break}case X.EVENT_LOADFINISHED:{var{onUpdate:i}=this.props;this.isLoadedFired=!0,i({isLoading:!1});break}case X.EVENT_DISCONNECT:{var{onDisconnect:l}=this.props;l();break}case X.EVENT_RECONNECT:{var{onReconnect:s}=this.props;s();break}case X.EVENT_DOWNSAMPLESTARTED:{this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!0,downsamplingError:null});break}case X.EVENT_DOWNSAMPLEFINISHED:{this.setState({isDownsampleFinished:!0,isDownsampleInProgress:!1,downsamplingError:null});break}case X.EVENT_DOWNSAMPLENEEDED:case X.EVENT_DOWNSAMPLEFAILED:{var o,u=(o=r.message)!==null&&o!==void 0?o:r;this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,downsamplingError:u});var{onError:c}=this.props;c(new Error(u));break}default:Q.debug("Unknown event type",t,e)}}handlePlotUpdate(e){var{layout:t}=e,r=j.getLayoutRanges(t),a=!de(r,this.ranges);a&&(this.ranges=r,this.updateModelDimensions(!0))}handleRelayout(e){if(Q.debug("handleRelayout",e),e.hiddenlabels!=null){var{onSettingsChanged:t}=this.props,r=[...e.hiddenlabels];t({hiddenSeries:r})}this.updateModelDimensions()}handleResize(){this.updateDimensions()}handleRestyle(e){var[t,r]=e;if(Q.debug("handleRestyle",t,r),Object.keys(t).includes("visible")){var{data:a}=this.state,{onSettingsChanged:i}=this.props;if(a!=null){var l=a.reduce((s,o)=>{var{name:u,visible:c}=o;return u!=null&&c==="legendonly"?[...s,u]:s},[]);i({hiddenSeries:l})}}}updateModelDimensions(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,t=this.getPlotRect();if(!t){Q.warn("Unable to get plotting rect");return}var r=!this.rect||this.rect.width!==t.width||this.rect.height!==t.height;if(r||e){this.rect=t;var{isActive:a,model:i}=this.props;i.setDimensions(t),a&&this.subscribe(i)}}initFormatter(){var{settings:e}=this.props;this.updateFormatterSettings(e)}updateFormatterSettings(e){var t=Oe.getColumnFormats(e),r=Oe.getDateTimeFormatterOptions(e),{decimalFormatOptions:a={},integerFormatOptions:i={}}=e;(!de(this.columnFormats,t)||!de(this.dateTimeFormatterOptions,r)||!de(this.decimalFormatOptions,a)||!de(this.integerFormatOptions,i))&&(this.columnFormats=Oe.getColumnFormats(e),this.dateTimeFormatterOptions=r,this.decimalFormatOptions=a,this.integerFormatOptions=i,this.updateFormatter())}updateFormatter(){var{model:e}=this.props,t=new ke(e.dh,this.columnFormats,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions);e.setFormatter(t)}updateDimensions(){var e=this.getPlotRect(),{Plotly:t}=this.props;this.plot.current!=null&&e!=null&&e.width>0&&e.height>0&&t.relayout(this.plot.current.el,{autosize:!0}).catch(r=>{Q.debug("Unable to resize, promise rejected",r)})}render(){var{PlotComponent:e}=this,{data:t,downsamplingError:r,isDownsampleFinished:a,isDownsampleInProgress:i,isDownsamplingDisabled:l,layout:s,revision:o}=this.state,u=this.getCachedConfig(r,a,i,l,t??[]),c=t!=null;return T.jsx("div",{className:"h-100 w-100 chart-wrapper",ref:this.plotWrapper,children:c&&T.jsx(e,{ref:this.plot,data:t,layout:s,revision:o,config:u,onAfterPlot:this.handleAfterPlot,onError:Q.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}}L(ie,"defaultProps",{isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:O.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},Plotly:ut,onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}});const Qn=ie;function rt(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(n,a).enumerable})),t.push.apply(t,r)}return t}function nt(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?rt(Object(t),!0).forEach(function(r){D(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):rt(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function D(n,e,t){return e=Tn(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Tn(n){var e=bn(n,"string");return typeof e=="symbol"?e:String(e)}function bn(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}var V=W.module("FigureChartModel");class we extends X{constructor(e,t,r){var a,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(e),a=this,D(this,"chartUtils",void 0),D(this,"dh",void 0),D(this,"figure",void 0),D(this,"settings",void 0),D(this,"theme",void 0),D(this,"data",void 0),D(this,"layout",void 0),D(this,"seriesDataMap",void 0),D(this,"pendingSeries",void 0),D(this,"oneClicks",void 0),D(this,"filterColumnMap",void 0),D(this,"lastFilter",void 0),D(this,"isConnected",void 0),D(this,"seriesToProcess",void 0),D(this,"addPendingSeries",St(()=>{for(var s=j.getAllAxes(this.figure),{pendingSeries:o}=this,u=function(){var f,p=o[c],v=a.figure.charts.find(y=>y.series.includes(p));a.addSeries(p,s,(f=v==null?void 0:v.showLegend)!==null&&f!==void 0?f:null),p.subscribe()},c=0;c<o.length;c+=1)u();this.pendingSeries=[]},we.ADD_SERIES_DEBOUNCE)),D(this,"getTimeZone",he((s,o)=>{if(o!=null){var u=o.getColumnTypeFormatter(s);if(u!=null)return u.dhTimeZone}})),D(this,"getValueTranslator",he((s,o)=>{var u=this.getTimeZone(s,o);return c=>this.chartUtils.unwrapValue(c,u)})),D(this,"getValueParser",he((s,o)=>{var u=this.getTimeZone(s,o);return c=>this.chartUtils.wrapValue(c,s,u)})),D(this,"getRangeParser",he((s,o)=>u=>{var[c,d]=u,f=this.getValueParser(s,o);return c=f(c),d=f(d),[c,d]})),D(this,"getAxisRangeParser",he((s,o)=>u=>{var c=j.getSourceForAxis(s,u);return c!=null?this.getRangeParser(c.columnType,o):d=>d})),this.handleFigureUpdated=this.handleFigureUpdated.bind(this),this.handleFigureDisconnected=this.handleFigureDisconnected.bind(this),this.handleFigureReconnected=this.handleFigureReconnected.bind(this),this.handleFigureSeriesAdded=this.handleFigureSeriesAdded.bind(this),this.handleDownsampleStart=this.handleDownsampleStart.bind(this),this.handleDownsampleFinish=this.handleDownsampleFinish.bind(this),this.handleDownsampleFail=this.handleDownsampleFail.bind(this),this.handleDownsampleNeeded=this.handleDownsampleNeeded.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.dh=e,this.chartUtils=new j(e),this.figure=t,this.settings=i,this.theme=r,this.data=[];var l={data:{},layout:this.chartUtils.makeDefaultLayout(r)};this.layout={grid:{rows:t.rows,columns:t.cols,pattern:"independent"},template:l},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(){if(this.figure.charts.length>0){var e=this.figure.charts[0];return e.title}return""}initAllSeries(){this.oneClicks=[],this.filterColumnMap.clear();for(var{charts:e}=this.figure,t=j.getAllAxes(this.figure),r=[],a=0;a<e.length;a+=1)for(var i=e[a],l=0;l<i.series.length;l+=1){var s=i.series[l];r.push(s.name),this.addSeries(s,t,i.showLegend)}for(var o=[...this.seriesDataMap.keys()],u=o.filter(f=>r.indexOf(f)<0),c=0;c<u.length;c+=1){var d=u[c];this.seriesDataMap.delete(d)}this.seriesToProcess=new Set([...this.seriesDataMap.keys()])}addSeries(e,t,r){var{dh:a}=this,i=j.groupArray(t,"type"),l=this.chartUtils.makeSeriesDataFromSeries(e,i,j.getSeriesVisibility(e.name,this.settings),this.theme,r);if(this.seriesDataMap.set(e.name,l),this.data=[...this.seriesDataMap.values()],e.plotStyle===a.plot.SeriesPlotStyle.STACKED_BAR?this.layout.barmode="stack":e.plotStyle===a.plot.SeriesPlotStyle.PIE&&(this.layout.hiddenlabels=j.getHiddenLabels(this.settings)),this.layout.showlegend=this.data.length>1||e.plotStyle===a.plot.SeriesPlotStyle.PIE?r??void 0:!1,e.oneClick!=null){for(var{oneClick:s}=e,{columns:o}=s,u=0;u<o.length;u+=1)this.filterColumnMap.set(o[u].name,o[u]);this.oneClicks.push(s)}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?this.dh.plot.DownsampleOptions.DISABLE:this.dh.plot.DownsampleOptions.DEFAULT)}unsubscribeFigure(){this.figure.unsubscribe()}startListeningFigure(){var{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(){var{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){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){var{detail:t}=e,{series:r}=t;V.debug2("handleFigureUpdated",r);for(var a=0;a<r.length;a+=1){var i=r[a];V.debug2("handleFigureUpdated updating series",i.name);for(var{sources:l}=i,s=0;s<l.length;s+=1){var o=l[s],{columnType:u,type:c}=o,d=this.getValueTranslator(u,this.formatter),f=t.getArray(i,c,d);this.setDataArrayForSeries(i,c,f)}this.seriesToProcess.delete(i.name),this.seriesToProcess.size===0&&this.fireLoadFinished(),this.cleanSeries(i)}var{data:p}=this;this.fireUpdate(p)}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){var{detail:t}=e;V.debug("handleFigureSeriesAdded",t),this.pendingSeries.push(t),this.addPendingSeries()}setDimensions(e){super.setDimensions(e),this.updateAxisPositions()}setTitle(e){var t,r;super.setTitle(e);var a=(t=(r=(e??"").match(/<br>/g))===null||r===void 0?void 0:r.length)!==null&&t!==void 0?t:0,i=j.DEFAULT_MARGIN.t+a*j.SUBTITLE_LINE_HEIGHT;this.layout.margin?this.layout.margin.t=i:this.layout.margin={t:i},typeof this.layout.title=="string"?this.layout.title=e:(this.layout.title=nt({},this.layout.title),this.layout.title.text=e,this.layout.title.pad=nt({},this.layout.title.pad),this.layout.title.pad.t=j.DEFAULT_TITLE_PADDING.t+a*j.SUBTITLE_LINE_HEIGHT*.5)}getPlotWidth(){var e,t,r,a;return!this.rect||!this.rect.width?0:Math.max(this.rect.width-((e=(t=this.layout.margin)===null||t===void 0?void 0:t.l)!==null&&e!==void 0?e:0)-((r=(a=this.layout.margin)===null||a===void 0?void 0:a.r)!==null&&r!==void 0?r:0),0)}getPlotHeight(){var e,t,r,a;return!this.rect||!this.rect.height?0:Math.max(this.rect.height-((e=(t=this.layout.margin)===null||t===void 0?void 0:t.t)!==null&&e!==void 0?e:0)-((r=(a=this.layout.margin)===null||a===void 0?void 0:a.b)!==null&&r!==void 0?r:0),0)}updateAxisPositions(){var e=this.getPlotWidth(),t=this.getPlotHeight();this.chartUtils.updateFigureAxes(this.layout,this.figure,this.theme,r=>this.getAxisRangeParser(r,this.formatter),e,t)}updateLayoutFormats(){if(this.formatter){var e=this.chartUtils.getAxisFormats(this.figure,this.formatter);e.forEach((t,r)=>{V.debug("Assigning ".concat(r),this.layout[r],t);var a=this.layout[r];a!=null?Object.assign(a,t):V.debug("Ignoring null layout.".concat(r))})}}setDataArrayForSeries(e,t,r){var{name:a,plotStyle:i}=e,l=this.seriesDataMap.get(a),s=this.chartUtils.getPlotlyProperty(i,t);l&&lt(l,s,r)}cleanSeries(e){var{dh:t}=this,{name:r,plotStyle:a}=e,i=this.seriesDataMap.get(r);if(i!=null){if(a===t.plot.SeriesPlotStyle.HISTOGRAM){var{xLow:l,xHigh:s}=i;if(l&&s&&l.length===s.length){for(var o=[],u=0;u<l.length;u+=1)o.push(s[u]-l[u]);i.width=o}}else if(a===t.plot.SeriesPlotStyle.LINE||a===t.plot.SeriesPlotStyle.ERROR_BAR||a===t.plot.SeriesPlotStyle.BAR){var{x:c,xLow:d,xHigh:f,y:p,yLow:v,yHigh:y}=i;d&&f&&d!==c&&(i.error_x=j.getPlotlyErrorBars(c,d,f,this.theme)),v&&y&&v!==p&&(i.error_y=j.getPlotlyErrorBars(p,v,y,this.theme))}else if(a===t.plot.SeriesPlotStyle.TREEMAP){var{ids:S,labels:E}=i;S!==void 0&&E===void 0&&(i.labels=S)}}}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){var t=this;if(this.oneClicks.length===0){V.warn("Trying to set a filter, but no one click!");return}V.debug("setFilter",e);for(var r=function(){var l=t.oneClicks[a],{columns:s}=l,o=new Set([...e.keys(),...t.lastFilter.keys()]);o.forEach(u=>{var c=e.get(u);t.lastFilter.get(u)!==c&&s.find(d=>d.name===u)!=null&&l.setValueForColumn(u,c)})},a=0;a<this.oneClicks.length;a+=1)r();this.lastFilter=new Map(e)}setFigure(e){this.close(),this.figure=e,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure(),this.listeners.length>0&&this.subscribeFigure()}updateSettings(e){this.settings=e}}D(we,"ADD_SERIES_DEBOUNCE",50);const at=we;function it(n,e,t,r,a,i,l){try{var s=n[i](l),o=s.value}catch(u){t(u);return}s.done?e(o):Promise.resolve(o).then(r,a)}function Ce(n){return function(){var e=this,t=arguments;return new Promise(function(r,a){var i=n.apply(e,t);function l(o){it(i,r,a,l,s,"next",o)}function s(o){it(i,r,a,l,s,"throw",o)}l(void 0)})}}class _e{static makeModelFromSettings(e,t,r,a){return Ce(function*(){var i=yield _e.makeFigureFromSettings(e,t,r);return new at(e,i,a,t)})()}static makeFigureFromSettings(e,t,r){return Ce(function*(){var a=yield r.copy();return a.applyCustomColumns(r.customColumns),a.applyFilter(r.filter),a.applySort(r.sort),e.plot.Figure.create(new j(e).makeFigureSettings(t,a))})()}static makeModel(e,t,r,a){return Ce(function*(){return new at(e,r,a,t)})()}}const Jn=_e,Fn="var(--dh-color-chart-colorway)",Pn="var(--dh-color-chart-grid)",Dn="var(--dh-color-chart-axis-line)",wn="var(--dh-color-chart-axis-line-zero)",Mn="var(--dh-color-chart-active)",Nn="var(--dh-color-chart-range-bg)",st={"paper-bgcolor":"var(--dh-color-chart-bg)","plot-bgcolor":"var(--dh-color-chart-plot-bg)","title-color":"var(--dh-color-chart-title)",colorway:Fn,gridcolor:Pn,linecolor:Dn,zerolinecolor:wn,activecolor:Mn,rangebgcolor:Nn,"area-color":"var(--dh-color-chart-area)","trend-color":"var(--dh-color-chart-trend)","line-color":"var(--dh-color-chart-line-deprecated)","error-band-line-color":"var(--dh-color-chart-error-band-line)","error-band-fill-color":"var(--dh-color-chart-error-band-fill)","ohlc-increasing":"var(--dh-color-chart-ohlc-increase)","ohlc-decreasing":"var(--dh-color-chart-ohlc-decrease)"};var ot=W.module("ChartTheme");function An(){var n,e=It(st);return e.colorway=xt((n=e.colorway)!==null&&n!==void 0?n:"").map(t=>{var[r,a]=t;return Rt.normalizeCssColor(e.colorway.substring(r,a+1))}).join(" "),ot.debug2("Chart theme:",st),ot.debug2("Chart theme derived:",e),Object.freeze({paper_bgcolor:e["paper-bgcolor"],plot_bgcolor:e["plot-bgcolor"],title_color:e["title-color"],colorway:e.colorway,gridcolor:e.gridcolor,linecolor:e.linecolor,zerolinecolor:e.zerolinecolor,activecolor:e.activecolor,rangebgcolor:e.rangebgcolor,area_color:e["area-color"],trend_color:e["trend-color"],line_color:e["line-color"],error_band_line_color:e["error-band-line-color"],error_band_fill_color:e["error-band-fill-color"],ohlc_increasing:e["ohlc-increasing"],ohlc_decreasing:e["ohlc-decreasing"]})}var mt=H.createContext(null);function Un(n){var{children:e}=n,{activeThemes:t}=Mr(),[r,a]=H.useState(null);return H.useEffect(()=>{t!=null&&a(An())},[t]),T.jsx(mt.Provider,{value:r,children:e})}function ea(){return Pe(mt,"No ChartThemeContext value found.")}var On=H.createContext(null);function ta(){return Pe(On,"No IdeConnection available in useConnection. Was code wrapped in ConnectionContext.Provider?")}export{kn as $,Wn as A,Cr as B,Qn as C,q as D,Bn as E,ke as F,Kn as G,Gr as H,K as I,Xn as J,Yn as K,sn as L,on as M,Ur as N,en as O,Ie as P,ln as Q,Zn as R,qr as S,dt as T,X as U,An as V,j as W,un as X,mt as Y,Un as Z,at as _,Hn as a,Ne as a0,On as a1,$e as a2,Rn as a3,Ln as a4,ye as a5,zn as a6,Jt as a7,ea as b,Vn as c,Jn as d,Pe as e,ae as f,rr as g,jn as h,_n as i,Mr as j,ct as k,m as l,xr as m,O as n,N as o,Hr as p,Oe as q,k as r,h as s,Pr as t,ta as u,$n as v,ft as w,Jr as x,qn as y,Gn as z};
2
- //# sourceMappingURL=useConnection-9ba5449b.js.map
1
+ import{r as H,G as Y,C as T,E as ge,F as je,aP as gt,L as vt,aQ as pt,a3 as He,aR as lt,ab as de,ai as yt,K as St,W as he}from"./vendor-8935a0fe.js";import{m as Et,L as W,w as Tt,E as bt,H as Ft,D as Pt,B as Dt,z as wt,O as Mt,S as Nt,p as fe,ab as At,aL as Ot,aM as Ct,J as It,F as xt,V as Rt}from"./index-7ea8f059.js";import{c as Me,P as ut,b as Lt,h as kt,p as _t,o as Vt,s as jt,t as Ht}from"./plotly-767c2d02.js";var Rn=Object.freeze([]),Ln=new Map,kn=()=>{};function Ne(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];return e.filter(r=>r!=null)}function $t(n,e,t){return e=Wt(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Wt(n){var e=Bt(n,"string");return typeof e=="symbol"?e:String(e)}function Bt(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}class qt extends Error{constructor(){super(...arguments),$t(this,"isCanceled",!0)}}const $e=qt;function Kt(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,t=zt(n,e);t.forEach(r=>{n[r]=n[r].bind(n)})}function zt(n,e){for(var t=new Set,r=n,a=0;r!=null&&r!==Object.prototype&&(a<=1||e);){for(var i of Object.getOwnPropertyNames(r))i!=="constructor"&&typeof r[i]=="function"&&t.add(i);r=Object.getPrototypeOf(r),a+=1}return[...t.keys()]}function Gt(n,e,t){return e=Xt(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Xt(n){var e=Yt(n,"string");return typeof e=="symbol"?e:String(e)}function Yt(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}class Zt extends Error{constructor(){super(...arguments),Gt(this,"isTimeout",!0)}}const ct=Zt;class Ie{static makeCancelable(e,t){var r=!1,a,i,l=new Promise((s,o)=>{i=o,Promise.resolve(e).then(u=>{r?t&&t(u):(a=u,s(u))}).catch(u=>o(u))});return l.cancel=()=>{r=!0,i(new $e),a!=null&&t&&t(a)},l}static isCanceled(e){return e instanceof $e}static isTimedOut(e){return e instanceof ct}static withTimeout(e,t){return new Promise((r,a)=>{setTimeout(()=>{try{r(t())}catch(i){a(i)}},e)})}}class Qt{static join(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"and";if(e==null||e.length===0)return"";if(e.length===1)return e[0];if(e.length===2)return"".concat(e[0]," ").concat(t," ").concat(e[1]);var r=e.slice(0,e.length-1).join(", "),a=e[e.length-1];return"".concat(r,", ").concat(t," ").concat(a)}static toLower(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;if(e==null){if(t)return"";throw new Error("Null string passed in to TextUtils.toLower")}return e.toLowerCase()}static sort(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0;return e<t?r?-1:1:e>t?r?1:-1:0}}const Jt=Qt;function Pe(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"No value available in context. Was code wrapped in a provider?",t=H.useContext(n);if(t==null)throw new Error(e);return t}function Ut(n,e,t){return e=er(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function er(n){var e=tr(n,"string");return typeof e=="symbol"?e:String(e)}function tr(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}function _n(n){return n.then!==void 0}class te{static disableAllActions(){te.actionsDisabled=!0}static enableAllActions(){te.actionsDisabled=!1}static isContextActionEvent(e){return Array.isArray(e.contextActions)}static compareActions(e,t){if(e.group!==t.group){var r,a;return((r=e.group)!==null&&r!==void 0?r:0)>((a=t.group)!==null&&a!==void 0?a:0)?1:-1}if(e.order!==t.order){var i,l;return((i=e.order)!==null&&i!==void 0?i:0)>((l=t.order)!==null&&l!==void 0?l:0)?1:-1}if(e.title!==t.title){var s,o;return((s=e.title)!==null&&s!==void 0?s:"")>((o=t.title)!==null&&o!==void 0?o:"")?1:-1}return e!==t?e>t?1:-1:0}static sortActions(e){if(e==null||!Array.isArray(e))return[];var t=e.slice();return t.sort(te.compareActions),t}static isMacPlatform(){var{platform:e}=window.navigator;return e.startsWith("Mac")}static getModifierKey(){return te.isMacPlatform()?"metaKey":"ctrlKey"}static isModifierKeyDown(e){var t=te.getModifierKey();return e[t]}static getMenuItems(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,r=[],a=e;Array.isArray(a)||(a=[a]);for(var i=0;i<a.length;i+=1){var l=a[i],s=void 0;typeof l=="function"?s=l():s=l,s!=null&&(s instanceof Promise?t&&r.push(s):Array.isArray(s)?r=r.concat(s):r.push(s))}return r=r.filter(o=>o.title!==void 0||o.then!=null||o.menuElement),r}static getNextMenuItem(e,t,r){var a=e;a<0&&t<0&&(a=r.length);for(var i=1;i<r.length+1;i+=1){var l=(a+t*i+r.length)%r.length,s=r[l];if(!(s instanceof Promise)&&s.disabled!==!0)return l}return e}}Ut(te,"actionsDisabled",!1);const ae=te;var xe=Y.forwardRef((n,e)=>{var t;function r(M){var{menuItem:I,onMenuItemClick:x}=n;x(I,M)}function a(M){var{menuItem:I,onMenuItemMouseMove:x}=n;x(I,M)}function i(M){var{menuItem:I,onMenuItemContextMenu:x}=n;x(I,M)}function l(M,I,x){if(typeof M.type=="string")return M;var{closeMenu:_,menuItem:re,isKeyboardSelected:Z,isMouseSelected:B,"data-testid":oe}=n,ne={menuItem:re,closeMenu:_,isKeyboardSelected:Z,isMouseSelected:B,iconElement:I,displayShortcut:x,"data-testid":oe};return Y.cloneElement(M,{forwardedProps:ne})}var{children:s,menuItem:o,isKeyboardSelected:u=!1,isMouseSelected:c=!1,"data-testid":d}=n,f=(t=o.shortcut)===null||t===void 0?void 0:t.getDisplayText(),p=null;if(o.icon){var v=o.icon;if(Y.isValidElement(v))p=v;else{var y;o.iconColor!=null&&(o.disabled===void 0||!o.disabled)&&(y={color:o.iconColor}),p=T.jsx(je,{icon:v,style:y})}}var S=null,E=!!s;o.actions&&(S=T.jsx(je,{icon:Et}));var F=null;if(o.menuElement)F=T.jsx("div",{className:"custom-menu-item",onMouseMove:a,children:l(o.menuElement,p,f)});else{var b,P=o.disabled,A=o.iconOutline;F=T.jsx("button",{type:"button",className:ge("btn-context-menu",{disabled:P},{active:(E||c)&&(P===void 0||!P)},{"keyboard-active":u&&(P===void 0||!P)}),onClick:r,onMouseMove:a,onContextMenu:i,title:(b=o.description)!==null&&b!==void 0?b:"",children:T.jsxs("div",{className:"btn-context-menu-wrapper",children:[T.jsx("span",{className:ge("icon",{outline:A}),children:p}),T.jsx("span",{className:"title",children:o.title}),f!==void 0&&T.jsx("span",{className:"shortcut",children:f}),S&&T.jsx("span",{className:ge("submenu-indicator",{disabled:P}),children:S})]})})}return T.jsxs("div",{className:"context-menu-item",ref:e,"data-testid":d,children:[s,F]})});xe.displayName="ContextMenuItem";xe.defaultProps={children:null,isKeyboardSelected:!1,isMouseSelected:!1,"data-testid":void 0};const rr=xe;function We(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(n,a).enumerable})),t.push.apply(t,r)}return t}function nr(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?We(Object(t),!0).forEach(function(r){U(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):We(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function U(n,e,t){return e=ar(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function ar(n){var e=ir(n,"string");return typeof e=="symbol"?e:String(e)}function ir(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}var Be=W.module("ContextMenu");class ve extends H.PureComponent{static handleContextMenu(e){e.metaKey||(e.stopPropagation(),e.preventDefault())}constructor(e){super(e),U(this,"container",void 0),U(this,"oldFocus",void 0),U(this,"activeSubMenuRef",void 0),U(this,"subMenuTimer",void 0),U(this,"rAF",void 0),U(this,"initialPosition",void 0),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=Y.createRef(),this.oldFocus=document.activeElement,this.activeSubMenuRef=Y.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}}componentDidMount(){this.initMenu(),this.verifyPosition(),window.addEventListener("resize",this.handleWindowResize),this.rAF=window.requestAnimationFrame(()=>{var e;(e=this.container.current)===null||e===void 0||e.focus();var{onMenuOpened:t}=this.props;t(this)})}componentDidUpdate(e,t){var{actions:r}=this.props,{activeSubMenu:a}=this.state;if(a!==t.activeSubMenu)if(a==null){var i;(i=this.container.current)===null||i===void 0||i.focus()}else this.setActiveSubMenuPosition();if(e.actions!==r&&(this.initMenu(),this.container.current==null||!this.container.current.contains(document.activeElement))){var l;(l=this.container.current)===null||l===void 0||l.focus()}this.verifyPosition()}componentWillUnmount(){this.cancelPromises(),window.removeEventListener("resize",this.handleWindowResize),cancelAnimationFrame(this.rAF)}getKeyboardIndex(){var{options:e}=this.props;if(e.separateKeyboardMouse!==void 0&&e.separateKeyboardMouse){var{keyboardIndex:t}=this.state;return t}return this.getMouseIndex()}setKeyboardIndex(e){var{options:t}=this.props;t.separateKeyboardMouse!==void 0&&t.separateKeyboardMouse?this.setState({keyboardIndex:e}):this.setMouseIndex(e)}getMouseIndex(){var{mouseIndex:e}=this.state;return e}setMouseIndex(e){this.setState({mouseIndex:e})}initMenu(){this.cancelPromises(),cancelAnimationFrame(this.rAF);var{options:e}=this.props,t=e.initialKeyboardIndex;t===void 0&&(t=-1);for(var{actions:r}=this.props,a=ae.getMenuItems(r),i=[],l=a.length-1;l>=0;l-=1){var s=a[l];s instanceof Promise?this.initMenuPromise(s):i.push(s)}this.setState({mouseIndex:-1,keyboardIndex:t,activeSubMenu:null,menuItems:ae.sortActions(i)})}initMenuPromise(e){var t=Ie.makeCancelable(e);this.setState(r=>({pendingItems:r.pendingItems.concat(t)})),t.then(r=>{this.setState(a=>{var i=a.pendingItems.indexOf(t);if(i>=0){var l=a.pendingItems.slice();return l.splice(i,1),{menuItems:ae.sortActions(a.menuItems.concat(r)),pendingItems:l}}return null})},r=>{Ie.isCanceled(r)||(this.setState(a=>{var i=a.pendingItems.indexOf(t);if(i>=0){var l=a.pendingItems.slice();return l.splice(i,1),{pendingItems:l}}return null}),Be.error(r))})}cancelPromises(){var{pendingItems:e}=this.state;e.map(t=>t.cancel())}setActiveSubMenuPosition(){if(this.activeSubMenuRef.current!==null){var e=this.activeSubMenuRef.current.getBoundingClientRect();this.setState({subMenuTop:e.top,subMenuLeft:e.right,subMenuParentHeight:e.height,subMenuParentWidth:e.width})}}verifyPosition(){var e,t,r,a,{options:i,updatePosition:l,subMenuParentWidth:s,subMenuParentHeight:o,top:u,left:c}=this.props;if(!(!this.container.current||i.doNotVerifyPosition!=null&&i.doNotVerifyPosition)){var{top:d,left:f}=this.initialPosition,{width:p,height:v}=(e=(t=this.container.current)===null||t===void 0?void 0:t.getBoundingClientRect())!==null&&e!==void 0?e:{width:0,height:0},y=((r=(a=this.container.current)===null||a===void 0?void 0:a.scrollHeight)!==null&&r!==void 0?r:0)>window.innerHeight;v===0||p===0||(d+v>window.innerHeight&&(d-v-o>0?d-=v-o:d=window.innerHeight-v),f+p>window.innerWidth&&(f=f-p-s),(c!==f||u!==d)&&(this.setState({hasOverflow:y}),l(d,f)))}}handleWindowResize(){this.container.current&&this.closeMenu(!0)}handleBlur(e){if(!this.container.current){Be.warn("Container is null!");return}if(!this.container.current.contains(e.relatedTarget)){for(var t=e.relatedTarget,r=!1;t&&!r;)r=t.hasAttribute("data-dh-context-menu"),t=t.parentElement;r||this.closeMenu(!0)}}isEscapeKey(e){var{left:t}=this.props;return e==="Escape"||t<0&&e==="ArrowRight"||e==="ArrowLeft"}handleKeyDown(e){var{menuItems:t}=this.state,r=this.getKeyboardIndex(),a=r,i=!1;if(e.key==="Enter"||e.key===" "){r>=0&&r<t.length&&this.handleMenuItemClick(t[r],e);return}if(e.key==="ArrowRight"?r>=0&&r<=t.length?i=!0:a=0:this.isEscapeKey(e.key)?a=null:e.key==="ArrowUp"||e.shiftKey&&e.key==="Tab"?a=ae.getNextMenuItem(a,-1,t):(e.key==="ArrowDown"||e.key==="Tab")&&(a=ae.getNextMenuItem(a,1,t)),i){this.openSubMenu(r),e.preventDefault(),e.stopPropagation();return}r!==a&&(a!==null?this.setKeyboardIndex(a):(this.closeMenu(),this.oldFocus instanceof HTMLElement&&this.oldFocus.focus()),e.preventDefault(),e.stopPropagation())}openSubMenu(e){var{menuItems:t,activeSubMenu:r}=this.state,a=t[e].actions?e:null;r!==a&&this.setState({activeSubMenu:a,subMenuTop:null,subMenuLeft:null})}closeMenu(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,{closeMenu:t,onMenuClosed:r}=this.props;cancelAnimationFrame(this.rAF),this.rAF=window.requestAnimationFrame(()=>{t(e),r(this)})}closeSubMenu(){this.setState({activeSubMenu:null})}handleCloseSubMenu(e){e?this.closeMenu(!0):this.closeSubMenu()}handleMenuItemClick(e,t){t.preventDefault(),t.stopPropagation();var{menuItems:r}=this.state;e!=null&&(e.disabled===void 0||!e.disabled)&&(e.actions!=null?this.openSubMenu(r.indexOf(e)):e.action!=null&&(e.action(t.nativeEvent),this.closeMenu(!0)))}handleMenuItemContextMenu(e,t){t.metaKey||this.handleMenuItemClick(e,t)}handleMenuItemMouseMove(e){var{menuItems:t}=this.state,r=t.indexOf(e);this.setMouseIndex(r),r>=0&&r<t.length&&(e.disabled===void 0||!e.disabled)&&this.openSubMenu(r)}handleMouseLeave(){this.setMouseIndex(-1)}render(){for(var e=[],{top:t,left:r}=this.props,{activeSubMenu:a,hasOverflow:i,keyboardIndex:l,menuItems:s,mouseIndex:o,pendingItems:u,subMenuTop:c,subMenuLeft:d,subMenuParentWidth:f,subMenuParentHeight:p}=this.state,v=0;v<s.length;v+=1){var y=s[v];v>0&&y.group!==s[v-1].group&&e.push(T.jsx("hr",{},"".concat(v,".separator")));var S=T.jsx(rr,{ref:a===v?this.activeSubMenuRef:null,isKeyboardSelected:l===v,isMouseSelected:o===v,menuItem:y,closeMenu:this.handleCloseSubMenu,onMenuItemClick:this.handleMenuItemClick,onMenuItemMouseMove:this.handleMenuItemMouseMove,onMenuItemContextMenu:this.handleMenuItemContextMenu},v);e.push(S)}var E=null;u.length>0&&(E=T.jsx("div",{className:"loading",children:T.jsx(Tt,{className:"loading-spinner-vertical-align"})}));var{menuStyle:F,"data-testid":b}=this.props,P=a!==null&&c!==null&&d!==null;return T.jsxs(T.Fragment,{children:[T.jsxs("div",{className:ge({"has-overflow":i},"context-menu-container"),style:nr({top:t,left:r},F),ref:this.container,"data-dh-context-menu":!0,onBlur:this.handleBlur,onKeyDown:this.handleKeyDown,onMouseLeave:this.handleMouseLeave,onContextMenu:ve.handleContextMenu,role:"menuitem",tabIndex:0,"data-testid":b,children:[e,E]}),P&&a!==null&&c!==null&&d!==null&&T.jsx(ve,{actions:s[a].actions||[],closeMenu:this.handleCloseSubMenu,top:c,left:d,updatePosition:(A,M)=>{this.setState({subMenuTop:A,subMenuLeft:M})},subMenuParentWidth:f,subMenuParentHeight:p},"sub-".concat(a))]})}}U(ve,"defaultProps",{subMenuParentWidth:0,subMenuParentHeight:0,closeMenu(){},onMenuOpened(){},onMenuClosed(){},options:{},menuStyle:{},"data-testid":void 0});const sr=ve;function qe(n,e,t){return e=or(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function or(n){var e=lr(n,"string");return typeof e=="symbol"?e:String(e)}function lr(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}class ur extends H.Component{constructor(e){super(e),qe(this,"container",void 0),qe(this,"openMenu",void 0),this.handleMenuClose=this.handleMenuClose.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.container=Y.createRef(),this.openMenu=Y.createRef(),this.state={actions:null,left:0,top:0}}componentDidMount(){var e;(e=this.container.current)!==null&&e!==void 0&&e.parentElement&&this.container.current.parentElement.addEventListener("contextmenu",this.handleContextMenu)}componentWillUnmount(){var e;(e=this.container.current)!==null&&e!==void 0&&e.parentElement&&this.container.current.parentElement.removeEventListener("contextmenu",this.handleContextMenu)}handleContextMenu(e){if(this.container.current){var t=this.container.current.getBoundingClientRect(),r=e.clientY-t.top,a=e.clientX-t.left,{actions:i}=this.state;if(i!=null&&e.target===this.container.current){e.preventDefault(),this.setState({actions:null},()=>{var s=document.elementFromPoint(a,r),o=new MouseEvent("contextmenu",{clientX:e.clientX,clientY:e.clientY,bubbles:!0,cancelable:!0});s==null||s.dispatchEvent(o)});return}if(ae.isContextActionEvent(e)&&!(e.metaKey||e.ctrlKey)){var l=ae.getMenuItems(e.contextActions);l.length!==0&&(e.preventDefault(),this.setState({actions:l,top:r,left:a}))}}}handleMenuClose(e){e===this.openMenu.current&&this.setState({actions:null})}render(){var e=null,{"data-testid":t}=this.props,{actions:r,top:a,left:i}=this.state;return r&&(e=T.jsx(sr,{ref:this.openMenu,actions:r,onMenuClosed:this.handleMenuClose,top:a,left:i,updatePosition:(l,s)=>{this.setState({top:l,left:s})},"data-testid":t})),T.jsx("div",{className:ge("context-menu-root",{active:r}),ref:this.container,children:e})}}const Vn=ur,cr={"dh-spectrum-palette":"_dh-spectrum-palette_1mcqx_1"},dr={"dh-spectrum-alias":"_dh-spectrum-alias_83lrx_1"},hr={};function Ke(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(n,a).enumerable})),t.push.apply(t,r)}return t}function Ae(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ke(Object(t),!0).forEach(function(r){fr(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Ke(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function fr(n,e,t){return e=mr(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function mr(n){var e=gr(n,"string");return typeof e=="symbol"?e:String(e)}function gr(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}var ze=Ae(Ae(Ae({},cr),dr),hr);function Ge(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(n,a).enumerable})),t.push.apply(t,r)}return t}function be(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ge(Object(t),!0).forEach(function(r){vr(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Ge(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function vr(n,e,t){return e=pr(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function pr(n){var e=yr(n,"string");return typeof e=="symbol"?e:String(e)}function yr(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}var{global:Sr,light:Er,dark:Tr,medium:br,large:Fr}=gt,Pr={global:Sr,light:be(be({},Er),ze),dark:be(be({},Tr),ze),medium:br,large:Fr};function Dr(n){var{children:e,isPortal:t=!1,theme:r=Pr,colorScheme:a}=n,[i]=H.useState(t?vt():null);return T.jsx(pt,{theme:r,colorScheme:a,"data-unique-id":i,children:e})}var wr=W.module("ThemeProvider"),dt=H.createContext(null);function jn(n){var{themes:e,children:t}=n,r=H.useMemo(()=>bt(),[]),[a,i]=H.useState(()=>{var o,u;return(o=(u=Ft())===null||u===void 0?void 0:u.themeKey)!==null&&o!==void 0?o:Pt}),l=H.useMemo(()=>e==null?null:Dt(a,{base:r,custom:e??[]}),[r,a,e]);H.useEffect(function(){if(!(l==null||e==null)){var u=wt();wr.debug2("updateThemePreloadData:",{active:l.map(c=>c.themeKey),all:e.map(c=>c.themeKey),preloadStyleContent:u,selectedThemeKey:a}),Mt({themeKey:a,preloadStyleContent:u})}},[l,a,e]);var s=H.useMemo(()=>({activeThemes:l,selectedThemeKey:a,setSelectedThemeKey:i}),[l,a]);return T.jsxs(dt.Provider,{value:s,children:[l==null?null:T.jsx(T.Fragment,{children:l.map(o=>T.jsx("style",{"data-theme-key":o.themeKey,children:o.styleContent},o.themeKey))}),T.jsx(Dr,{children:t})]})}function Mr(){return Pe(dt,"No ThemeContext value found. Component must be wrapped in a ThemeContext.Provider")}function Hn(){return Pe(Nt,"No API available in useApi. Was code wrapped in ApiBootstrap or ApiContext.Provider?")}function Re(n,e,t){return e=Nr(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Nr(n){var e=Ar(n,"string");return typeof e=="symbol"?e:String(e)}function Ar(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}class De{static isValid(e,t){return!0}static isSameFormat(e,t){throw new Error("isSameFormat not implemented")}static makeFormat(e,t,r){return{label:e,formatString:t,type:r}}format(e,t){return""}}Re(De,"TYPE_GLOBAL","type-global");Re(De,"TYPE_CONTEXT_PRESET","type-context-preset");Re(De,"TYPE_CONTEXT_CUSTOM","type-context-custom");const k=De;class Or extends k{format(e){switch(e){case 1:case!0:return"true";case 0:case!1:return"false";default:return""}}}const Cr=Or;class Ir extends k{format(e){return String.fromCharCode(e)}}const xr=Ir;function ee(n,e,t){return e=Rr(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Rr(n){var e=Lr(n,"string");return typeof e=="symbol"?e:String(e)}function Lr(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}var Xe=W.module("DateTimeColumnFormatter");class q extends k{static isValid(e,t){try{return e.i18n.DateTimeFormat.format(t.formatString,new Date),!0}catch{return!1}}static makeFormat(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:k.TYPE_CONTEXT_PRESET;return{label:e,formatString:t,type:r}}static isSameFormat(e,t){return e===t||e!==null&&t!==null&&e.type===t.type&&e.formatString===t.formatString}static makeGlobalFormatStringMap(e,t){var r=t?"'T'":" ",a=e?" z":"";return new Map([["yyyy-MM-dd HH:mm:ss","yyyy-MM-dd".concat(r,"HH:mm:ss").concat(a)],["yyyy-MM-dd HH:mm:ss.SSS","yyyy-MM-dd".concat(r,"HH:mm:ss.SSS").concat(a)],["yyyy-MM-dd HH:mm:ss.SSSSSSSSS","yyyy-MM-dd".concat(r,"HH:mm:ss.SSSSSSSSS").concat(a)]])}static getGlobalFormats(e,t){var r=q.makeGlobalFormatStringMap(e,t);return[...r.keys()]}static makeFormatStringMap(e,t){var r=t!==void 0&&t?"'T'":" ",a=e!==void 0&&e?" z":"";return new Map([["yyyy-MM-dd","yyyy-MM-dd".concat(a)],["MM-dd-yyyy","MM-dd-yyyy".concat(a)],["HH:mm:ss","HH:mm:ss".concat(a)],["HH:mm:ss.SSS","HH:mm:ss.SSS".concat(a)],["HH:mm:ss.SSSSSSSSS","HH:mm:ss.SSSSSSSSS".concat(a)],["yyyy-MM-dd HH:mm:ss","yyyy-MM-dd".concat(r,"HH:mm:ss").concat(a)],["yyyy-MM-dd HH:mm:ss.SSS","yyyy-MM-dd".concat(r,"HH:mm:ss.SSS").concat(a)],["yyyy-MM-dd HH:mm:ss.SSSSSSSSS","yyyy-MM-dd".concat(r,"HH:mm:ss.SSSSSSSSS").concat(a)]])}static getFormats(e,t){var r=q.makeFormatStringMap(e,t);return[...r.keys()]}constructor(e){var{timeZone:t="",showTimeZone:r=!0,showTSeparator:a=!1,defaultDateTimeFormatString:i=q.DEFAULT_DATETIME_FORMAT_STRING}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),ee(this,"dh",void 0),ee(this,"dhTimeZone",void 0),ee(this,"defaultDateTimeFormatString",void 0),ee(this,"showTimeZone",void 0),ee(this,"showTSeparator",void 0),ee(this,"formatStringMap",void 0);var l=t||q.DEFAULT_TIME_ZONE_ID;try{this.dhTimeZone=e.i18n.TimeZone.getTimeZone(l)}catch{Xe.error("Unsupported time zone id",l),this.dhTimeZone=e.i18n.TimeZone.getTimeZone(q.DEFAULT_TIME_ZONE_ID)}this.dh=e,this.defaultDateTimeFormatString=i,this.showTimeZone=r,this.showTSeparator=a,this.formatStringMap=q.makeFormatStringMap(r,a)}getEffectiveFormatString(e){var t;return(t=this.formatStringMap.get(e))!==null&&t!==void 0?t:e}format(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultDateTimeFormatString,a=this.getEffectiveFormatString(r);try{return this.dh.i18n.DateTimeFormat.format(a,e,this.dhTimeZone)}catch{Xe.error("Invalid format arguments")}return""}}ee(q,"DEFAULT_DATETIME_FORMAT_STRING","yyyy-MM-dd HH:mm:ss.SSS");ee(q,"DEFAULT_TIME_ZONE_ID","America/New_York");function z(n,e,t){return e=kr(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function kr(n){var e=_r(n,"string");return typeof e=="symbol"?e:String(e)}function _r(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}var Vr=W.module("DecimalColumnFormatter");class N extends k{static isValid(e,t){try{return e.i18n.NumberFormat.format(t.formatString,0),!0}catch{return!1}}static makeFormat(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:k.TYPE_CONTEXT_PRESET,a=arguments.length>3?arguments[3]:void 0;return{label:e,type:r,formatString:t,multiplier:a}}static makePresetFormat(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",r=arguments.length>2?arguments[2]:void 0;return N.makeFormat(e,t,k.TYPE_CONTEXT_PRESET,r)}static makeCustomFormat(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;return N.makeFormat("Custom Format",e,k.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}constructor(e){var{defaultFormatString:t=N.DEFAULT_FORMAT_STRING}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),z(this,"defaultFormatString",void 0),z(this,"dh",void 0),this.dh=e,this.defaultFormatString=t}format(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultFormatString,a=t.multiplier!=null&&t.multiplier!==0?e*t.multiplier:e;try{return this.dh.i18n.NumberFormat.format(r,a)}catch{Vr.error("Invalid format arguments")}return""}}z(N,"DEFAULT_FORMAT_STRING","###,##0.0000");z(N,"FORMAT_PERCENT",N.makePresetFormat("Percent","##0.00%"));z(N,"FORMAT_BASIS_POINTS",N.makePresetFormat("Basis Points","###,##0 bp",1e4));z(N,"FORMAT_MILLIONS",N.makePresetFormat("Millions","###,##0.000 mm",1e-6));z(N,"FORMAT_SCIENTIFIC_NOTATION",N.makePresetFormat("Scientific Notation","0.0000E0"));z(N,"FORMAT_ROUND",N.makePresetFormat("Round","###,##0"));z(N,"FORMAT_ROUND_TWO_DECIMALS",N.makePresetFormat("0.00","###,##0.00"));z(N,"FORMAT_ROUND_FOUR_DECIMALS",N.makePresetFormat("0.0000","###,##0.0000"));class jr extends k{format(e){return"".concat(e)}}const Hr=jr;function pe(n,e,t){return e=$r(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function $r(n){var e=Wr(n,"string");return typeof e=="symbol"?e:String(e)}function Wr(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}var Br=W.module("IntegerColumnFormatter");class K extends k{static isValid(e,t){try{return e.i18n.NumberFormat.format(t.formatString,0),!0}catch{return!1}}static makeFormat(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:k.TYPE_CONTEXT_PRESET,a=arguments.length>3?arguments[3]:void 0;return{label:e,type:r,formatString:t,multiplier:a}}static makePresetFormat(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",r=arguments.length>2?arguments[2]:void 0;return K.makeFormat(e,t,k.TYPE_CONTEXT_PRESET,r)}static makeCustomFormat(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;return K.makeFormat("Custom Format",e,k.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}constructor(e){var{defaultFormatString:t=K.DEFAULT_FORMAT_STRING}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),pe(this,"dh",void 0),pe(this,"defaultFormatString",void 0),this.dh=e,this.defaultFormatString=t}format(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultFormatString,a=t.multiplier!=null&&t.multiplier!==0?e*t.multiplier:e;try{return this.dh.i18n.NumberFormat.format(r,a)}catch{Br.error("Invalid format arguments")}return""}}pe(K,"DEFAULT_FORMAT_STRING","###,##0");pe(K,"FORMAT_MILLIONS",K.makePresetFormat("Millions","###,##0.000 mm",1e-6));pe(K,"FORMAT_SCIENTIFIC_NOTATION",K.makePresetFormat("Scientific Notation","0.0000E0"));class qr extends k{format(e){return e}}function ht(n,e,t){return e=Kr(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Kr(n){var e=zr(n,"string");return typeof e=="symbol"?e:String(e)}function zr(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}class O{static makeDateWrapper(e,t,r){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:1,l=arguments.length>5&&arguments[5]!==void 0?arguments[5]:0,s=arguments.length>6&&arguments[6]!==void 0?arguments[6]:0,o=arguments.length>7&&arguments[7]!==void 0?arguments[7]:0,u=arguments.length>8&&arguments[8]!==void 0?arguments[8]:0;if(!t)throw new Error("No timezone provided");var c="".concat(r).padStart(4,"0"),d="".concat(a+1).padStart(2,"0"),f="".concat(i).padStart(2,"0"),p="".concat(l).padStart(2,"0"),v="".concat(s).padStart(2,"0"),y="".concat(o).padStart(2,"0"),S="".concat(u).padStart(9,"0"),E="".concat(c,"-").concat(d,"-").concat(f," ").concat(p,":").concat(v,":").concat(y,".").concat(S);return e.i18n.DateTimeFormat.parse(O.FULL_DATE_FORMAT,E,e.i18n.TimeZone.getTimeZone(t))}static getNextNanos(e){var t=parseInt(e,10),r="0".repeat(9-e.length),a="".concat(t+1).concat(r);return parseInt(a,10)}static getNextDate(e,t,r,a){var{year:i,month:l,date:s,hours:o,minutes:u,seconds:c,nanos:d}=r;if(t.nanos!=null){if(t.nanos.length===9)return null;d=O.getNextNanos(t.nanos),d>999999999&&(c+=1,d=0)}else t.seconds!=null?c+=1:t.minutes!=null?u+=1:t.hours!=null?o+=1:t.date!=null?s+=1:t.month!=null?l+=1:i+=1;var f=new Date(i,l,s,o,u,c);return O.makeDateWrapper(e,a,f.getFullYear(),f.getMonth(),f.getDate(),f.getHours(),f.getMinutes(),f.getSeconds(),d)}static parseMonth(e){var t=parseInt(e,10);if(!Number.isNaN(t))return t>=1&&t<=12?t-1:NaN;var r=e.trim().toLowerCase();if(r.length>=3){for(var a=0;a<O.months.length;a+=1)if(O.months[a].startsWith(r))return a}return NaN}static parseDateValues(e,t,r,a,i,l,s){var o=parseInt(e,10),u=t!=null?this.parseMonth(t):0,c=r!=null?parseInt(r,10):1,d=a!=null?parseInt(a,10):0,f=i!=null?parseInt(i,10):0,p=l!=null?parseInt(l,10):0,v=s!=null?parseInt(s.padEnd(9,"0"),10):0;return Number.isNaN(o)||Number.isNaN(u)||Number.isNaN(c)||Number.isNaN(d)||Number.isNaN(f)||Number.isNaN(p)||Number.isNaN(v)?null:{year:o,month:u,date:c,hours:d,minutes:f,seconds:p,nanos:v}}static parseDateTimeString(e){var t=/\s*(\d{4})([-./]([\da-z]+))?([-./](\d{1,2}))?([tT\s](\d{2})([:](\d{2}))?([:](\d{2}))?([.](\d{1,9}))?)?(.*)/,r=t.exec(e);if(r==null)throw new Error("Unexpected date string: ".concat(e));var[,a,,i,,l,,s,,o,,u,,c,d]=r;if(d!=null&&d.length>0)throw new Error("Unexpected characters after date string '".concat(e,"': ").concat(d));return{year:a,month:i,date:l,hours:s,minutes:o,seconds:u,nanos:c}}static parseDateRange(e,t,r){var a=t.trim().toLowerCase();if(a.length===0)throw new Error("Cannot parse date range from empty string");if(a==="null")return[null,null];if(a==="today"){var i=new Date(Date.now()),l=O.makeDateWrapper(e,r,i.getFullYear(),i.getMonth(),i.getDate()),s=new Date(i.getFullYear(),i.getMonth(),i.getDate()+1),o=O.makeDateWrapper(e,r,s.getFullYear(),s.getMonth(),s.getDate());return[l,o]}if(a==="yesterday"){var u=new Date(Date.now()),c=new Date(u.getFullYear(),u.getMonth(),u.getDate()-1),d=O.makeDateWrapper(e,r,c.getFullYear(),c.getMonth(),c.getDate()),f=O.makeDateWrapper(e,r,u.getFullYear(),u.getMonth(),u.getDate());return[d,f]}if(a==="now"){var p=new Date(Date.now()),v=e.DateWrapper.ofJsDate(p);return[v,null]}var y=O.parseDateTimeString(a);if(y.year==null&&y.month==null&&y.date==null)throw new Error("Unable to extract year, month, or day ".concat(a));var S=O.parseDateValues(y.year,y.month,y.date,y.hours,y.minutes,y.seconds,y.nanos);if(S==null)throw new Error("Unable to extract date values from ".concat(y));var E=O.makeDateWrapper(e,r,S.year,S.month,S.date,S.hours,S.minutes,S.seconds,S.nanos),F=O.getNextDate(e,y,S,r);return[E,F]}static getJsDate(e){return typeof e=="number"?new Date(e):e.asDate()}}ht(O,"FULL_DATE_FORMAT","yyyy-MM-dd HH:mm:ss.SSSSSSSSS");ht(O,"months",["january","february","march","april","may","june","july","august","september","october","november","december"]);function $n(n,e){return n===e?{operator:"notEq",value:""}:{operator:"eq",value:n}}function Wn(n,e,t){return function(a){var i=t.trim();if(i==="")return null;var l=ft(e,s=>s.filter().containsIgnoreCase(n.makeFilterValue(s.type,i)),"or");return l(a)}}function ft(n,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"or";return function(a){var i=a==null?void 0:a.findColumns(typeof n=="string"?[n]:n);if(i==null||i.length===0)return null;var l=i.map(e);return l.reduce((s,o)=>s[t](o))}}function Gr(n,e,t,r){return ft(e,a=>a.filter()[r](n.makeFilterValue(a.type,t)),"or")}function Bn(n,e,t,r,a){return function(l){var s=l==null?void 0:l.findColumn(e),o=t==="all"||r&&t.size===0;return s==null||o?null:n.makeSelectValueFilter(s,[...t.keys()],a)}}function qn(n){return function(t){return t.filter().isNull().not().and(t.filter().notEq(n.makeFilterValue(t.type,"")))}}function Kn(n,e){return function(r){var a=r.filter(),i=n.makeFilterValue(r.type,""),l=a.eq(i);return e?a.isNull().or(l):l.or(a.notEq(i))}}function Le(n,e,t){return e=Xr(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Xr(n){var e=Yr(n,"string");return typeof e=="symbol"?e:String(e)}function Yr(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}class ye{}Le(ye,"not","not");Le(ye,"and","and");Le(ye,"or","or");function zn(n){if(!(n==="not"||n==="and"||n==="or"))throw new Error("operator is not a valid FilterOperatorValue")}function w(n,e,t){return e=Zr(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Zr(n){var e=Qr(n,"string");return typeof e=="symbol"?e:String(e)}function Qr(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}class m{}w(m,"eq","eq");w(m,"eqIgnoreCase","eqIgnoreCase");w(m,"notEq","notEq");w(m,"notEqIgnoreCase","notEqIgnoreCase");w(m,"greaterThan","greaterThan");w(m,"greaterThanOrEqualTo","greaterThanOrEqualTo");w(m,"lessThan","lessThan");w(m,"lessThanOrEqualTo","lessThanOrEqualTo");w(m,"in","in");w(m,"inIgnoreCase","inIgnoreCase");w(m,"notIn","notIn");w(m,"notInIgnoreCase","notInIgnoreCase");w(m,"isTrue","isTrue");w(m,"isFalse","isFalse");w(m,"isNull","isNull");w(m,"invoke","invoke");w(m,"contains","contains");w(m,"notContains","notContains");w(m,"containsIgnoreCase","containsIgnoreCase");w(m,"startsWith","startsWith");w(m,"endsWith","endsWith");w(m,"containsAny","containsAny");var Ye=W.module("ViewportDataUtils");function Jr(n,e){return String(n.offsetInSnapshot+e)}function Gn(n,e){var{bulkUpdate:t}=n;return function(a){var{columns:i,offset:l,rows:s}=a.detail;Ye.debug("table updated",a.detail);var o=new Map;s.forEach(u=>{var c=e(u,i),d=Jr(u,l);o.set(d,{key:d,item:c})}),Ye.debug("update keys",o),t(o)}}function Xn(n,e){return e.reduce((t,r)=>(t[r.name]=n.get(r),t),{})}function*Yn(n,e){for(var t=n;t<=e;++t)yield{key:String(t)}}function Ur(n){return n==null||en(n)?0:n.size}function en(n){return"isClosed"in n?n.isClosed:!1}function Zn(n,e,t,r){var a=n+e-1,[i,l]=[0,r-1],s=He(n-t,i,l),o=He(a+t,i,l);return[s,o]}function Ze(n,e,t,r,a,i,l){try{var s=n[i](l),o=s.value}catch(u){t(u);return}s.done?e(o):Promise.resolve(o).then(r,a)}function J(n){return function(){var e=this,t=arguments;return new Promise(function(r,a){var i=n.apply(e,t);function l(o){Ze(i,r,a,l,s,"next",o)}function s(o){Ze(i,r,a,l,s,"throw",o)}l(void 0)})}}function se(n,e,t){return e=tn(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function tn(n){var e=rn(n,"string");return typeof e=="symbol"?e:String(e)}function rn(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}var G=W.module("TableUtils");class h{static copyTableAndApplyFilters(e){var t=arguments;return J(function*(){if(e==null)return null;for(var r=yield e.copy(),a=t.length,i=new Array(a>1?a-1:0),l=1;l<a;l++)i[l-1]=t[l];return r.applyFilter(Ne(...i.map(s=>s(r)))),r})()}static getSortIndex(e,t){for(var r=0;r<e.length;r+=1){var a,i=e[r];if(((a=i.column)===null||a===void 0?void 0:a.name)===t)return r}return null}static getSortForColumn(e,t){var r=h.getSortIndex(e,t);return r!=null?e[r]:null}static getFilterText(e){return e?e.toString():null}static getFilterTypes(e){return h.isBooleanType(e)?[m.isTrue,m.isFalse,m.isNull]:h.isCharType(e)||h.isNumberType(e)||h.isDateType(e)?[m.eq,m.notEq,m.greaterThan,m.greaterThanOrEqualTo,m.lessThan,m.lessThanOrEqualTo]:h.isTextType(e)?[m.eq,m.eqIgnoreCase,m.notEq,m.notEqIgnoreCase,m.contains,m.notContains,m.startsWith,m.endsWith]:[]}static getNextSort(e,t,r){if(r<0||r>=e.length)return null;var a=h.getSortForColumn(t,e[r].name);return a===null?e[r].sort().asc():a.direction===h.sortDirection.ascending?a.desc():null}static makeColumnSort(e,t,r,a){if(t<0||t>=e.length||r===h.sortDirection.none)return null;var i=e[t].sort();switch(r){case h.sortDirection.ascending:i=i.asc();break;case h.sortDirection.descending:i=i.desc();break}return a&&(i=i.abs()),i}static toggleSortForColumn(e,t,r){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(r<0||r>=t.length)return[];var i=h.getNextSort(t,e,r);return h.setSortForColumn(e,t[r].name,i,a)}static sortColumn(e,t,r,a,i,l){if(r<0||r>=t.length)return[];var s=h.makeColumnSort(t,r,a,i);return h.setSortForColumn(e,t[r].name,s,l)}static setSortForColumn(e,t,r){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1,i=h.getSortIndex(e,t),l=[];return a&&(l=l.concat(e.filter(s=>{var{direction:o}=s;return o!==h.sortDirection.reverse})),i!==null&&l.splice(i,1)),r!==null&&l.push(r),l}static getNormalizedType(e){switch(e){case"boolean":case"java.lang.Boolean":case h.dataType.BOOLEAN:return h.dataType.BOOLEAN;case"char":case"java.lang.Character":case h.dataType.CHAR:return h.dataType.CHAR;case"java.lang.String":case h.dataType.STRING:return h.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 h.dataType.DATETIME:return h.dataType.DATETIME;case"double":case"java.lang.Double":case"float":case"java.lang.Float":case"java.math.BigDecimal":case h.dataType.DECIMAL:return h.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 h.dataType.INT:return h.dataType.INT;default:return h.dataType.UNKNOWN}}static isLongType(e){switch(e){case"long":case"java.lang.Long":return!0;default:return!1}}static isDateType(e){switch(e){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(e){return h.isIntegerType(e)||h.isDecimalType(e)}static isIntegerType(e){switch(e){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(e){switch(e){case"double":case"java.lang.Double":case"java.math.BigDecimal":case"float":case"java.lang.Float":return!0;default:return!1}}static isBigDecimalType(e){switch(e){case"java.math.BigDecimal":return!0;default:return!1}}static isBigIntegerType(e){switch(e){case"java.math.BigInteger":return!0;default:return!1}}static isBooleanType(e){switch(e){case"boolean":case"java.lang.Boolean":return!0;default:return!1}}static isCharType(e){switch(e){case"char":case"java.lang.Character":return!0;default:return!1}}static isStringType(e){switch(e){case"java.lang.String":return!0;default:return!1}}static isTextType(e){return this.isStringType(e)||this.isCharType(e)}static getBaseType(e){return e.split("[]")[0]}static isCompatibleType(e,t){return h.getNormalizedType(e)===h.getNormalizedType(t)}static quoteValue(e){return e.length>=2&&(e.charAt(0)==='"'&&e.charAt(e.length-1)==='"'||e.charAt(0)==="'"&&e.charAt(e.length-1)==="'")?e:'"'.concat(e,'"')}static isRangeOperation(e){switch(e){case"<":case"<=":case"=<":case">":case">=":case"=>":return!0;default:return!1}}static makeRangeFilterWithOperation(e,t,r){switch(t){case"=":return e.eq(r);case"<":return e.lessThan(r);case"<=":case"=<":return e.lessThanOrEqualTo(r);case">":return e.greaterThan(r);case">=":case"=>":return e.greaterThanOrEqualTo(r);case"!=":case"!":return e.notEq(r);default:return null}}static makeCancelableTablePromise(e){return Ie.makeCancelable(e,t=>{t.close()})}static makeCancelableTableEventPromise(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null,i,l,s=!0,o=new Promise((u,c)=>{l=setTimeout(()=>{i(),s=!1,c(new ct('Event "'.concat(t,'" timed out.')))},r),i=e.addEventListener(t,d=>{if(a!=null&&!a(d)){G.debug2("Event triggered, but matcher returned false.");return}G.debug2("Event triggered, resolving."),i(),clearTimeout(l),s=!1,u(d)})});return o.cancel=()=>{if(s){G.debug2("Pending promise cleanup."),i(),clearTimeout(l),s=!1;return}G.debug2("Ignoring non-pending promise cancel.")},o}static removeCommas(e){return e.replace(/[\s|,]/g,"")}static makeBooleanValue(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(e===""&&t)return null;switch(e==null?void 0:e.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 '".concat(e,"'"))}}static makeNumberValue(e){if(e==="null"||e==="")return null;var t=e.toLowerCase().trim();if(t==="∞"||t==="infinity"||t==="inf")return Number.POSITIVE_INFINITY;if(t==="-∞"||t==="-infinity"||t==="-inf")return Number.NEGATIVE_INFINITY;var r=h.removeCommas(t);if(h.NUMBER_REGEX.test(r))return parseFloat(r);throw new Error("Invalid number '".concat(e,"'"))}static getFilterOperatorString(e){switch(e){case m.eq:return"=";case m.notEq:return"!=";case m.greaterThan:return">";case m.greaterThanOrEqualTo:return">=";case m.lessThan:return"<";case m.lessThanOrEqualTo:return"<=";case m.contains:return"~";case m.notContains:return"!~";default:throw new Error("Unexpected filter type ".concat(e))}}static isTreeTable(e){return e!=null&&e.expand!==void 0&&e.collapse!==void 0}static sortColumns(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;return[...e].sort((r,a)=>{var i=r.name.toUpperCase(),l=a.name.toUpperCase();return Jt.sort(i,l,t)})}constructor(e){se(this,"dh",void 0),this.dh=e,Kt(this)}createDistinctSortedColumnTable(e,t,r){var a=arguments,i=this;return J(function*(){if(e==null)return null;for(var l=e,s=a.length,o=new Array(s>3?s-3:0),u=3;u<s;u++)o[u-3]=a[u];o.length>0&&(l=yield e.copy(),yield l.applyFilter(Ne(...o.map(p=>p(l)))));var c=l.findColumn(t),d=yield l.selectDistinct([c]);l!==e&&l.close();var f=d.findColumn(t).sort()[r]();return i.applySort(d,[f])})()}doesColumnValueExist(e,t,r,a){var i=this;return J(function*(){if(e==null)return null;var l=Gr(i,t,r,a?"eq":"eqIgnoreCase"),s=yield e.copy();yield i.applyFilter(s,Ne(l(s)));var o=Ur(s);return s.close(),o>0})()}makeQuickFilter(e,t,r){for(var a=t.split("||"),i=null,l=0;l<a.length;l+=1){for(var s=a[l],o=s.split("&&"),u=null,c=0;c<o.length;c+=1){var d=o[c].trim();if(d.length>0){var f=this.makeQuickFilterFromComponent(e,d,r);if(f)u?u=u.and(f):u=f;else throw new Error("Unable to parse quick filter from text ".concat(t))}}i&&u?i=i.or(u):i=u}return i}makeQuickFilterFromComponent(e,t,r){var{type:a}=e;return h.isNumberType(a)?this.makeQuickNumberFilter(e,t):h.isBooleanType(a)?this.makeQuickBooleanFilter(e,t):r!=null&&h.isDateType(a)?this.makeQuickDateFilter(e,t,r):h.isCharType(a)?this.makeQuickCharFilter(e,t):this.makeQuickTextFilter(e,t)}makeQuickNumberFilter(e,t){var r=e.filter(),{dh:a}=this,i=null,l=/\s*(>=|<=|=>|=<|>|<|!=|=|!)?(\s*-\s*)?(\s*\d*(?:,\d{3})*(?:\.\d*)?\s*)?(null|nan|infinity|inf|\u221E)?(.*)/i,s=l.exec(t),o=null,u=null,c=null,d=null,f=null;if(s!==null&&s.length>3&&([,o,u,c,d,f]=s),f!=null&&f.trim().length>0)return null;if(o==null&&(o="="),d!=null){if(!(o==="="||o==="!"||o==="!="))return null;switch(d=d.trim().toLowerCase(),d){case"null":i=r.isNull();break;case"nan":i=a.FilterCondition.invoke("isNaN",r);break;case"infinity":case"inf":case"∞":u!=null?i=a.FilterCondition.invoke("isInf",r).and(r.lessThan(a.FilterValue.ofNumber(0))):i=a.FilterCondition.invoke("isInf",r).and(r.greaterThan(a.FilterValue.ofNumber(0)));break}return i!==null&&(o==="!"||o==="!=")&&(i=i.not()),i}if(c==null)return null;if(c=h.removeCommas(c),h.isLongType(e.type))try{c=a.FilterValue.ofNumber(a.LongWrapper.ofString("".concat(u!=null?"-":"").concat(c)))}catch(p){return G.warn("Unable to create long filter",p),null}else{if(c=parseFloat(c),c==null||Number.isNaN(c))return null;c=a.FilterValue.ofNumber(u!=null?0-c:c)}return i=e.filter(),h.makeRangeFilterWithOperation(i,o,c)}static escapeQuickTextFilter(e){var t,r;if(e==null)return null;var a=/^(!~|!=|~|=|!)?(.*)/,i=/^\\*null$/,l=a.exec(e),s=null,o=null;if(l!==null&&l.length>2&&([,s,o]=l),s!=null){var u;return"\\".concat(s).concat((u=o)!==null&&u!==void 0?u:"")}return o!=null&&i.test(o.toLowerCase())||o!=null&&o.startsWith("*")?"\\".concat(o):o!=null&&o.endsWith("*")&&!o.endsWith("\\*")?(o=o.substring(0,o.length-1),"".concat(o,"\\*")):"".concat((t=s)!==null&&t!==void 0?t:"").concat((r=o)!==null&&r!==void 0?r:"")}static unescapeQuickTextFilter(e){var t,r,a=/^(\\!~|\\!=|\\~|\\=|\\!)?(.*)/,i=/^\\*null$/,l=a.exec(e),s=null,o=null;return l!==null&&l.length>2&&([,s,o]=l),s!=null&&(s=s.replace("\\","")),o!=null&&i.test(o.toLowerCase())&&(o=o.replace("\\","")),s==null&&o!=null&&o.startsWith("\\*")&&(o=o.substring(1)),s==null&&o!=null&&o.endsWith("\\*")?(o=o.substring(0,o.length-2),"".concat(o,"*")):"".concat((t=s)!==null&&t!==void 0?t:"").concat((r=o)!==null&&r!==void 0?r:"")}makeQuickTextFilter(e,t){var{dh:r}=this,a="".concat(t).trim(),i=/^(!~|!=|~|=|!)?(.*)/,l=i.exec(a),s=null,o=null;if(l!==null&&l.length>2&&([,s,o]=l,o!=null&&(o=o.trim())),o==null||o.length===0&&!(s==="="||s==="!="))return null;s==null&&(s="=");var u=e.filter();if(o.toLowerCase()==="null")switch(s){case"=":return u.isNull();case"!=":case"!":return u.isNull().not()}var c=null,d=null;switch(o.startsWith("*")?(c="*",o=o.substring(1)):o.endsWith("*")&&!o.endsWith("\\*")&&(d="*",o=o.substring(0,o.length-1)),o=h.unescapeQuickTextFilter(o),s){case"~":return u.isNull().not().and(u.invoke("matches",r.FilterValue.ofString("(?s)(?i).*\\Q".concat(o,"\\E.*"))));case"!~":return u.isNull().or(u.invoke("matches",r.FilterValue.ofString("(?s)(?i).*\\Q".concat(o,"\\E.*"))).not());case"!=":return c==="*"?u.isNull().or(u.invoke("matches",r.FilterValue.ofString("(?s)(?i).*\\Q".concat(o,"\\E$"))).not()):d==="*"?u.isNull().or(u.invoke("matches",r.FilterValue.ofString("(?s)(?i)^\\Q".concat(o,"\\E.*"))).not()):u.notEqIgnoreCase(r.FilterValue.ofString(o.toLowerCase()));case"=":return c==="*"?u.isNull().not().and(u.invoke("matches",r.FilterValue.ofString("(?s)(?i).*\\Q".concat(o,"\\E$")))):d==="*"?u.isNull().not().and(u.invoke("matches",r.FilterValue.ofString("(?s)(?i)^\\Q".concat(o,"\\E.*")))):u.eqIgnoreCase(r.FilterValue.ofString(o.toLowerCase()))}return null}makeQuickBooleanFilter(e,t){var r=/^(!=|=|!)?(.*)/,a=r.exec("".concat(t).trim());if(a===null)return null;var[,i,l]=a,s=i==="!"||i==="!=",o=l.trim().toLowerCase(),u=e.filter();try{var c=h.makeBooleanValue(o);return c!=null&&c?u=u.isTrue():c===null?u=u.isNull():u=u.isFalse(),s?u.not():u}catch{return null}}makeQuickDateFilter(e,t,r){var a=t.trim(),i=/\s*(>=|<=|=>|=<|>|<|!=|!|=)?(.*)/,l=i.exec(a);if(l==null||l.length<=2)throw new Error("Unable to parse date filter: ".concat(t));var s=null,o=null;[,s,o]=l;var u=m.eq;switch(s){case"<":u=m.lessThan;break;case"<=":case"=<":u=m.lessThanOrEqualTo;break;case">":u=m.greaterThan;break;case">=":case"=>":u=m.greaterThanOrEqualTo;break;case"!=":case"!":u=m.notEq;break;case"=":case"==":default:u=m.eq;break}return this.makeQuickDateFilterWithOperation(e,o,u,r)}makeQuickDateFilterWithOperation(e,t,r,a){var{dh:i}=this,[l,s]=O.parseDateRange(i,t,a),o=l!=null?i.FilterValue.ofNumber(l):null,u=s!=null?i.FilterValue.ofNumber(s):null,c=e.filter();if(o==null)return r===m.notEq?c.isNull().not():c.isNull();switch(r){case m.eq:{if(u!=null){var d=c.greaterThanOrEqualTo(o),f=c.lessThan(u);return d.and(f)}return c.eq(o)}case m.lessThan:return c.lessThan(o);case m.lessThanOrEqualTo:return u!=null?c.lessThan(u):c.lessThanOrEqualTo(o);case m.greaterThan:return u!=null?c.greaterThanOrEqualTo(u):c.greaterThan(o);case m.greaterThanOrEqualTo:return c.greaterThanOrEqualTo(o);case m.notEq:{if(u!=null){var p=c.lessThan(o),v=c.greaterThanOrEqualTo(u);return p.or(v)}return c.notEq(o)}default:throw new Error("Invalid operator: ".concat(r))}}makeQuickCharFilter(e,t){var{dh:r}=this,a="".concat(t).trim(),i=/^(>=|<=|=>|=<|>|<|!=|=|!)?(null|"."|'.'|.)?(.*)/,l=i.exec(a),s=null,o=null,u=null;if(l!==null&&l.length>3&&([,s,o,u]=l),u!=null&&u.trim().length>0||o==null||o.length===0)return null;s==null&&(s="=");var c=e.filter();if(o.toLowerCase()==="null")switch(s){case"=":return c.isNull();case"!=":case"!":return c.isNull().not();default:return null}var d=r.FilterValue.ofString(h.isRangeOperation(s)?h.quoteValue(o):o);return h.makeRangeFilterWithOperation(c,s,d)}makeAdvancedFilter(e,t,r){for(var{filterItems:a,filterOperators:i,invertSelection:l,selectedValues:s}=t,o=null,u=0;u<a.length;u+=1){var c=a[u],{selectedType:d,value:f}=c;if(d!=null&&d.length>0&&f!=null&&f.length>0)try{var p=this.makeAdvancedValueFilter(e,d,f,r);if(p!=null){if(u===0)o=p;else if(o!==null&&u-1<i.length){var v=i[u-1];if(v===ye.and)o=o.and(p);else if(v===ye.or)o=o.or(p);else{G.error("Unexpected filter operator",v,p),o=null;break}}}else G.debug2("Empty filter ignored for",d,f)}catch(S){G.error("Unable to create filter",S),o=null;break}}var y=this.makeSelectValueFilter(e,s,l);return y!=null&&(o!=null?o=o.and(y):o=y),o}makeAdvancedValueFilter(e,t,r,a){var{dh:i}=this;if(h.isDateType(e.type))return this.makeQuickDateFilterWithOperation(e,r,t,a);if(h.isNumberType(e.type)||h.isCharType(e.type))return this.makeQuickFilter(e,"".concat(h.getFilterOperatorString(t)).concat(r));var l=this.makeFilterValue(e.type,r),s=e.filter();switch(t){case m.eq:return s.eq(l);case m.eqIgnoreCase:return s.eqIgnoreCase(l);case m.notEq:return s.notEq(l);case m.notEqIgnoreCase:return s.notEqIgnoreCase(l);case m.greaterThan:return s.greaterThan(l);case m.greaterThanOrEqualTo:return s.greaterThanOrEqualTo(l);case m.lessThan:return s.lessThan(l);case m.lessThanOrEqualTo:return s.lessThanOrEqualTo(l);case m.isTrue:return s.isTrue();case m.isFalse:return s.isFalse();case m.isNull:return s.isNull();case m.contains:return s.isNull().not().and(s.invoke("matches",i.FilterValue.ofString("(?s)(?i).*\\Q".concat(r,"\\E.*"))));case m.notContains:return s.isNull().or(s.invoke("matches",i.FilterValue.ofString("(?s)(?i).*\\Q".concat(r,"\\E.*"))).not());case m.startsWith:return s.isNull().not().and(s.invoke("matches",i.FilterValue.ofString("(?s)(?i)^\\Q".concat(r,"\\E.*"))));case m.endsWith:return s.isNull().not().and(s.invoke("matches",i.FilterValue.ofString("(?s)(?i).*\\Q".concat(r,"\\E$"))));case m.in:case m.inIgnoreCase:case m.notIn:case m.notInIgnoreCase:case m.invoke:default:throw new Error("Unexpected filter operation: ".concat(t))}}applyNeverFilter(e,t){var r=arguments,a=this;return J(function*(){var i=r.length>2&&r[2]!==void 0?r[2]:h.APPLY_TABLE_CHANGE_TIMEOUT_MS;if(e==null)return null;var l=e.findColumn(t),s=[a.makeNeverFilter(l)];return yield a.applyFilter(e,s,i),e})()}applyCustomColumns(e,t){var r=arguments,a=this;return J(function*(){var i=r.length>2&&r[2]!==void 0?r[2]:h.APPLY_TABLE_CHANGE_TIMEOUT_MS,{dh:l}=a;return h.executeAndWaitForEvent(s=>s==null?void 0:s.applyCustomColumns(t),e,l.Table.EVENT_CUSTOMCOLUMNSCHANGED,i)})()}applyFilter(e,t){var r=arguments,a=this;return J(function*(){var i=r.length>2&&r[2]!==void 0?r[2]:h.APPLY_TABLE_CHANGE_TIMEOUT_MS,{dh:l}=a;return h.executeAndWaitForEvent(s=>s==null?void 0:s.applyFilter(t),e,l.Table.EVENT_FILTERCHANGED,i)})()}applySort(e,t){var r=arguments,a=this;return J(function*(){var i=r.length>2&&r[2]!==void 0?r[2]:h.APPLY_TABLE_CHANGE_TIMEOUT_MS,{dh:l}=a;return h.executeAndWaitForEvent(s=>s==null?void 0:s.applySort(t),e,l.Table.EVENT_SORTCHANGED,i)})()}makeNeverFilter(e){var{dh:t}=this,r=null;h.isTextType(e.type)?r=t.FilterValue.ofString("a"):h.isBooleanType(e.type)?r=t.FilterValue.ofBoolean(!0):h.isDateType(e.type)?r=t.FilterValue.ofNumber(t.DateWrapper.ofJsDate(new Date)):r=t.FilterValue.ofNumber(0);var a=e.filter().eq(r),i=e.filter().notEq(r);return a.and(i)}makeFilterValue(e,t){var{dh:r}=this,a=h.getBaseType(e);return h.isTextType(a)?r.FilterValue.ofString(t):h.isLongType(a)?r.FilterValue.ofNumber(r.LongWrapper.ofString(h.removeCommas(t))):r.FilterValue.ofNumber(h.removeCommas(t))}makeFilterRawValue(e,t){var{dh:r}=this;return h.isTextType(e)?r.FilterValue.ofString(t):h.isBooleanType(e)?r.FilterValue.ofBoolean(t):r.FilterValue.ofNumber(t)}makeValue(e,t,r){var{dh:a}=this;if(t==="null")return null;if(h.isTextType(e))return t;if(h.isLongType(e))return a.LongWrapper.ofString(h.removeCommas(t));if(h.isBooleanType(e))return h.makeBooleanValue(t,!0);if(h.isDateType(e)){var[i]=O.parseDateRange(a,t,r);return i}return h.isNumberType(e)?h.makeNumberValue(t):(G.error("Unexpected column type",e),null)}makeSelectValueFilter(e,t,r){var{dh:a}=this;if(t.length===0)return r?null:this.makeNeverFilter(e);for(var i=[],l=!1,s=0;s<t.length;s+=1){var o=t[s];o==null?l=!0:h.isTextType(e.type)?i.push(a.FilterValue.ofString(typeof o=="number"?String.fromCharCode(o):o)):h.isBooleanType(e.type)?i.push(a.FilterValue.ofBoolean(!!o)):i.push(a.FilterValue.ofNumber(o))}return l?i.length>0?r?e.filter().isNull().not().and(e.filter().notIn(i)):e.filter().isNull().or(e.filter().in(i)):r?e.filter().isNull().not():e.filter().isNull():r?e.filter().notIn(i):e.filter().in(i)}}se(h,"dataType",{BOOLEAN:"boolean",CHAR:"char",DATETIME:"datetime",DECIMAL:"decimal",INT:"int",STRING:"string",UNKNOWN:"unknown"});se(h,"sortDirection",{ascending:"ASC",descending:"DESC",reverse:"REVERSE",none:null});se(h,"APPLY_TABLE_CHANGE_TIMEOUT_MS",3e4);se(h,"REVERSE_TYPE",Object.freeze({NONE:"none",PRE_SORT:"pre-sort",POST_SORT:"post-sort"}));se(h,"NUMBER_REGEX",/^-?\d+(\.\d+)?$/);se(h,"executeAndWaitForEvent",function(){var n=J(function*(e,t,r){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:h.APPLY_TABLE_CHANGE_TIMEOUT_MS;if(t==null)return null;var i=h.makeCancelableTableEventPromise(t,r,a);return e(t),yield i,t});return function(e,t,r){return n.apply(this,arguments)}}());function Fe(n,e,t){return e=nn(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function nn(n){var e=an(n,"string");return typeof e=="symbol"?e:String(e)}function an(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}class ke{static makeColumnFormatMap(e){return e==null?new Map:e.reduce((t,r)=>{var a=h.getNormalizedType(r.columnType);if(a===null)return t;t.has(a)||t.set(a,new Map);var i=t.get(a);return i==null||i.set(r.columnName,r.format),t},new Map)}static makeColumnFormattingRule(e,t,r){return{columnType:e,columnName:t,format:r}}constructor(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],r=arguments.length>2?arguments[2]:void 0,a=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0,l=arguments.length>5&&arguments[5]!==void 0?arguments[5]:!1;Fe(this,"defaultColumnFormatter",void 0),Fe(this,"typeFormatterMap",void 0),Fe(this,"columnFormatMap",void 0),Fe(this,"truncateNumbersWithPound",void 0),this.defaultColumnFormatter=new Hr,this.typeFormatterMap=new Map([[h.dataType.BOOLEAN,new Cr],[h.dataType.CHAR,new xr],[h.dataType.DATETIME,new q(e,r)],[h.dataType.DECIMAL,new N(e,a)],[h.dataType.INT,new K(e,i)],[h.dataType.STRING,new qr]]),this.columnFormatMap=ke.makeColumnFormatMap(t),this.truncateNumbersWithPound=l}getColumnFormatMapForType(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,r=h.getNormalizedType(e);if(r!==null)return t&&!this.columnFormatMap.has(r)&&this.columnFormatMap.set(r,new Map),this.columnFormatMap.get(r)}getColumnFormat(e,t){var r,a=this.getColumnFormatMapForType(e);return(r=a==null?void 0:a.get(t))!==null&&r!==void 0?r:null}getColumnTypeFormatter(e){var t=h.getNormalizedType(e),r=this.defaultColumnFormatter;if(t){var a;r=(a=this.typeFormatterMap.get(t))!==null&&a!==void 0?a:r}return r}getFormattedString(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"",a=arguments.length>3?arguments[3]:void 0;if(e==null)return"";var i=this.getColumnTypeFormatter(t),l=a||this.getColumnFormat(t,r);return i.format(e,l??void 0)}get timeZone(){var e,t=this.typeFormatterMap.get(h.dataType.DATETIME);return t==null||(e=t.dhTimeZone)===null||e===void 0?void 0:e.id}}function sn(n){if(n&&n.formatter){var{formatter:e}=n;return e}}function on(n){return{timeZone:n==null?void 0:n.timeZone,defaultDateTimeFormatString:n==null?void 0:n.defaultDateTimeFormat,showTimeZone:n==null?void 0:n.showTimeZone,showTSeparator:n==null?void 0:n.showTSeparator}}function ln(n,e,t){var r=n.getColumnFormat(t,e);return r!=null&&(r.type===k.TYPE_CONTEXT_PRESET||r.type===k.TYPE_CONTEXT_CUSTOM)}const Oe={getColumnFormats:sn,getDateTimeFormatterOptions:on,isCustomColumnFormatDefined:ln},un=typeof Me=="function"?Me:Me.default;ut.register([Lt,kt,_t,Vt,jt,Ht]);function $(n,e,t){return e=cn(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function cn(n){var e=dn(n,"string");return typeof e=="symbol"?e:String(e)}function dn(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}class C{constructor(e){$(this,"dh",void 0),$(this,"listeners",void 0),$(this,"formatter",void 0),$(this,"rect",void 0),$(this,"isDownsamplingDisabled",void 0),$(this,"title",void 0),this.dh=e,this.listeners=[],this.isDownsamplingDisabled=!1}getData(){return[]}getDefaultTitle(){return""}getLayout(){return{}}getFilterColumnMap(){return new Map}isFilterRequired(){return!1}setFilter(e){}close(){}setFormatter(e){this.formatter=e}setDownsamplingDisabled(e){this.isDownsamplingDisabled=e}setDimensions(e){this.rect=e}setTitle(e){this.title=e}subscribe(e){this.listeners.push(e)}unsubscribe(e){this.listeners=this.listeners.filter(t=>t!==e)}fireEvent(e){for(var t=0;t<this.listeners.length;t+=1)this.listeners[t](e)}fireUpdate(e){this.fireEvent(new CustomEvent(C.EVENT_UPDATED,{detail:e}))}fireDisconnect(){this.fireEvent(new CustomEvent(C.EVENT_DISCONNECT))}fireReconnect(){this.fireEvent(new CustomEvent(C.EVENT_RECONNECT))}fireDownsampleStart(e){this.fireEvent(new CustomEvent(C.EVENT_DOWNSAMPLESTARTED,{detail:e}))}fireDownsampleFinish(e){this.fireEvent(new CustomEvent(C.EVENT_DOWNSAMPLEFINISHED,{detail:e}))}fireDownsampleFail(e){this.fireEvent(new CustomEvent(C.EVENT_DOWNSAMPLEFAILED,{detail:e}))}fireDownsampleNeeded(e){this.fireEvent(new CustomEvent(C.EVENT_DOWNSAMPLENEEDED,{detail:e}))}fireLoadFinished(){this.fireEvent(new CustomEvent(C.EVENT_LOADFINISHED))}}$(C,"EVENT_UPDATED","ChartModel.EVENT_UPDATED");$(C,"EVENT_DISCONNECT","ChartModel.EVENT_DISCONNECT");$(C,"EVENT_RECONNECT","ChartModel.EVENT_RECONNECT");$(C,"EVENT_DOWNSAMPLESTARTED","ChartModel.EVENT_DOWNSAMPLESTARTED");$(C,"EVENT_DOWNSAMPLEFINISHED","ChartModel.EVENT_DOWNSAMPLEFINISHED");$(C,"EVENT_DOWNSAMPLEFAILED","ChartModel.EVENT_DOWNSAMPLEFAILED");$(C,"EVENT_DOWNSAMPLENEEDED","ChartModel.EVENT_DOWNSAMPLENEEDED");$(C,"EVENT_LOADFINISHED","ChartModel.EVENT_LOADFINISHED");const X=C;function Qe(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(n,a).enumerable})),t.push.apply(t,r)}return t}function le(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Qe(Object(t),!0).forEach(function(r){R(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):Qe(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function R(n,e,t){return e=hn(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function hn(n){var e=fn(n,"string");return typeof e=="symbol"?e:String(e)}function fn(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}var me=W.module("ChartUtils"),Je="io.deephaven.time.DateTime",mn=36e5,gn=1e6;function vn(n){return n.asDate!==void 0}function pn(n){return n.asNumber!==void 0}function Ue(n){return n.dhTimeZone!==void 0}function yn(n){return n!=null&&n.range!=null&&(n.autorange===!1||n.autorange===void 0)}class g{static getPlotlyErrorBars(e,t,r,a){var i=r.map((s,o)=>s-e[o]),l=t.map((s,o)=>e[o]-s);return{type:"data",symmetric:!1,array:i,arrayminus:l,color:a.error_band_line_color}}static convertNumberPrefix(e){return e.replace(/\u00A4\u00A4/g,"USD").replace(/\u00A4/g,"$")}static getPlotlyNumberFormat(e,t,r){if(!r)return null;var a=r.split(";"),i=a[0].match(/^([^#,0.]*)([#,]*)([0,]*)(\.?)(0*)(#*)(E?0*)(%?)(.*)/);fe(i);var[,l,s,o,,u,c,d,f,p]=i,v=o.replace(",","").length,y=s.indexOf(",")>=0||o.indexOf(",")>=0,S=y?",":"",E=d!=null&&d!==""?"e":"f",F=f!==""?f:E,b=u.length+c.length,P="",A="0".concat(v).concat(S,".").concat(b).concat(P).concat(F),M=g.convertNumberPrefix(l),I=g.convertNumberPrefix(p);return{tickformat:A,tickprefix:M,ticksuffix:I,automargin:!0}}static addTickSpacing(e,t,r){var{gapBetweenMajorTicks:a}=t;if(a>0){var i=e||{},l=a;return r&&(l=a/gn),t.log&&(l=Math.log(l)),i.tickmode="linear",i.dtick=l,i}return e}static getSourceForAxis(e,t){for(var r=0;r<e.series.length;r+=1)for(var a=e.series[r],i=0;i<a.sources.length;i+=1){var l=a.sources[i];if(l.axis===t)return l}return null}static getSeriesVisibility(e,t){return t!=null&&t.hiddenSeries!=null&&t.hiddenSeries.includes(e)?"legendonly":!0}static getHiddenLabels(e){return e!=null&&e.hiddenSeries?[...e.hiddenSeries]:[]}static makeSeriesData(e,t,r,a){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:g.ORIENTATION.VERTICAL;return{type:e,mode:t,name:r,orientation:i,showlegend:a??void 0}}static getMarkerSymbol(e){switch(e){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 ".concat(e))}}static getAllAxes(e){return e.charts.reduce((t,r)=>[...t,...r.axes],[])}static getChartForSeries(e,t){for(var{charts:r}=e,a=0;a<r.length;a+=1)for(var i=r[a],l=0;l<i.series.length;l+=1)if(t===i.series[l])return i;return null}static getLayoutRanges(e){for(var t={},r=Object.keys(e).filter(s=>s.indexOf("axis")>=0),a=0;a<r.length;a+=1){var i=r[a],l=e[i];yn(l)&&(t[i]=[...l.range])}return t}static getAxisLayoutProperty(e,t){var r=t>0?"".concat(t+1):"";return"".concat(e??"","axis").concat(r)}static periodToDecimal(e){var t=e.split(":");return Number(t[0])+Number(t[1])/60}static groupArray(e,t){return e.reduce((r,a)=>{var i,l=a[t],s=(i=r.get(l))!==null&&i!==void 0?i:[];return s.push(a),r.set(l,s),r},new Map)}static getColorwayFromTheme(e){var t=[];return e.colorway&&(Array.isArray(e.colorway)?t=e.colorway:typeof e.colorway=="string"?t=e.colorway.split(" "):me.warn("Unable to handle colorway property: ".concat(e.colorway))),t}static titleFromSettings(e){var{series:t,xAxis:r,title:a="".concat((t??[]).join(", ")," by ").concat(r)}=e;return a}constructor(e){R(this,"dh",void 0),R(this,"daysOfWeek",void 0),this.dh=e,this.daysOfWeek=Object.freeze(e.calendar.DayOfWeek.values())}getAxisFormats(e,t){for(var r=this,a=new Map,i={tickformat:null,ticksuffix:null},l=g.getAllAxes(e),s=g.groupArray(l,"type"),{charts:o}=e,u=0;u<o.length;u+=1)for(var c=o[u],d=0;d<c.series.length;d+=1)for(var f=c.series[d],{sources:p}=f,v=p.filter(F=>F.axis),y=function(){var b=v[S],{axis:P}=b,{type:A}=P,M=s.get(A);fe(M);var I=M.indexOf(P),x=r.getAxisPropertyName(A);if(x!=null){var _=g.getAxisLayoutProperty(x,I);if(a.has(_))me.debug("".concat(_," already added."));else{me.debug("Adding ".concat(_," to axisFormats."));var re=r.getPlotlyAxisFormat(b,t);if(re===null)a.set(_,i);else{a.set(_,re);var{businessCalendar:Z}=P;if(Z!=null){var B=[],{businessPeriods:oe,businessDays:ne,holidays:Se,timeZone:ue}=Z,ce=t==null?void 0:t.getColumnTypeFormatter(Je),Ee;Ue(ce)&&(Ee=ce.dhTimeZone);var Ve=Ee?(ue.standardOffset-Ee.standardOffset)/60:0;Se.length>0&&B.push(...r.createRangeBreakValuesFromHolidays(Se,ue,Ee)),oe.forEach(Te=>B.push({pattern:"hour",bounds:[g.periodToDecimal(Te.close)+Ve,g.periodToDecimal(Te.open)+Ve]})),ne.length<r.daysOfWeek.length&&r.createBoundsFromDays(ne).forEach(Te=>B.push({pattern:"day of week",bounds:Te})),re.rangebreaks=B}if(a.size===c.axes.length)return{v:a}}}}},S=0;S<v.length;S+=1){var E=y();if(typeof E=="object")return E.v}return a}getPlotlyChartType(e,t){var{dh:r}=this;switch(e){case r.plot.SeriesPlotStyle.SCATTER:return t?"scatter":"scattergl";case r.plot.SeriesPlotStyle.LINE:return"scatter";case r.plot.SeriesPlotStyle.BAR:case r.plot.SeriesPlotStyle.STACKED_BAR:return"bar";case r.plot.SeriesPlotStyle.PIE:return"pie";case r.plot.SeriesPlotStyle.TREEMAP:return"treemap";case r.plot.SeriesPlotStyle.HISTOGRAM:return"histogram";case r.plot.SeriesPlotStyle.OHLC:return"ohlc";default:return}}getPlotlyChartMode(e,t,r){var{dh:a}=this,i=new Set;switch(e){case a.plot.SeriesPlotStyle.SCATTER:(t??!1)&&i.add(g.MODE_LINES),(r??!0)&&i.add(g.MODE_MARKERS);break;case a.plot.SeriesPlotStyle.LINE:(t??!0)&&i.add(g.MODE_LINES),(r??!1)&&i.add(g.MODE_MARKERS);break}return i.size>0?[...i].join("+"):void 0}getPlotlyProperty(e,t){var{dh:r}=this;switch(e){case r.plot.SeriesPlotStyle.PIE:switch(t){case r.plot.SourceType.X:return"labels";case r.plot.SourceType.Y:return"values"}break;case r.plot.SeriesPlotStyle.OHLC:switch(t){case r.plot.SourceType.TIME:return"x"}break;case r.plot.SeriesPlotStyle.TREEMAP:switch(t){case r.plot.SourceType.X:return"ids";case r.plot.SourceType.Y:return"values";case r.plot.SourceType.LABEL:return"labels";case r.plot.SourceType.PARENT:return"parents";case r.plot.SourceType.COLOR:return"marker.colors"}break}switch(t){case r.plot.SourceType.X:return"x";case r.plot.SourceType.Y:return"y";case r.plot.SourceType.Z:return"z";case r.plot.SourceType.X_LOW:return"xLow";case r.plot.SourceType.X_HIGH:return"xHigh";case r.plot.SourceType.Y_LOW:return"yLow";case r.plot.SourceType.Y_HIGH:return"yHigh";case r.plot.SourceType.TIME:return"time";case r.plot.SourceType.OPEN:return"open";case r.plot.SourceType.HIGH:return"high";case r.plot.SourceType.LOW:return"low";case r.plot.SourceType.CLOSE:return"close";case r.plot.SourceType.SHAPE:return"shape";case r.plot.SourceType.SIZE:return"size";case r.plot.SourceType.LABEL:return"label";case r.plot.SourceType.COLOR:return"color";case r.plot.SourceType.PARENT:return"parent";case r.plot.SourceType.HOVER_TEXT:return"hovertext";case r.plot.SourceType.TEXT:return"text";default:throw new Error("Unrecognized source type: ".concat(t))}}getPlotlySeriesOrientation(e){var t,r,{dh:a}=this,{sources:i}=e;return i.length===2&&((t=i[0])===null||t===void 0||(r=t.axis)===null||r===void 0?void 0:r.type)===a.plot.AxisType.Y?g.ORIENTATION.HORIZONTAL:g.ORIENTATION.VERTICAL}makeSeriesDataFromSeries(e,t,r,a){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:null,{name:l,isLinesVisible:s,isShapesVisible:o,plotStyle:u,lineColor:c,shapeColor:d,sources:f,shape:p,shapeSize:v}=e,y=f.some(P=>{var A;return(A=P.axis)===null||A===void 0?void 0:A.businessCalendar}),S=this.getChartType(u,y),E=this.getPlotlyChartMode(u,s??void 0,o??void 0),F=this.getPlotlySeriesOrientation(e),b=g.makeSeriesData(S,E,l,i,F);return this.addSourcesToSeriesData(b,u,f,t),this.addStylingToSeriesData(b,u,a,c,d,p,v,r),b}addSourcesToSeriesData(e,t,r,a){for(var i=e,l=0;l<r.length;l+=1){var s=r[l],{axis:o,type:u}=s,c=this.getPlotlyProperty(t,u);lt(i,c,[]);var d=o!=null?this.getAxisPropertyName(o.type):null;if(d!=null){var f=a.get(o.type);if(f){var p=f.indexOf(o),v=p>0?"".concat(p+1):"";i["".concat(d,"axis")]="".concat(d).concat(v)}}}}addStylingToSeriesData(e,t,r){var a=arguments.length>3&&arguments[3]!==void 0?arguments[3]:null,i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:null,l=arguments.length>5&&arguments[5]!==void 0?arguments[5]:null,s=arguments.length>6&&arguments[6]!==void 0?arguments[6]:null,o=arguments.length>7&&arguments[7]!==void 0?arguments[7]:null,{dh:u}=this,c=e;if(c.marker={line:{}},c.line={width:1},t===u.plot.SeriesPlotStyle.AREA?c.fill="tozeroy":t===u.plot.SeriesPlotStyle.STACKED_AREA?c.stackgroup="stack":t===u.plot.SeriesPlotStyle.STEP?c.line.shape="hv":t===u.plot.SeriesPlotStyle.HISTOGRAM?(c.width=[],c.marker.line!==void 0&&Object.assign(c.marker.line,{color:r.paper_bgcolor,width:1})):t===u.plot.SeriesPlotStyle.OHLC?(c.increasing={line:{color:r.ohlc_increasing}},c.decreasing={line:{color:r.ohlc_decreasing}}):t===u.plot.SeriesPlotStyle.PIE?(c.textinfo="label+percent",c.outsidetextfont={color:r.title_color}):t===u.plot.SeriesPlotStyle.TREEMAP&&(c.hoverinfo="text",c.textinfo="label+text",c.tiling={packing:"squarify",pad:0},c.textposition="middle center",c.outsidetextfont={color:r.title_color}),a!=null&&(t===u.plot.SeriesPlotStyle.BAR?c.marker.color=a:c.line.color=a),i!=null&&(c.marker.color=i),l!=null&&l.length>0)try{c.marker.symbol=g.getMarkerSymbol(l)}catch(d){me.warn("Unable to handle shape",l,":",d)}s!=null&&(c.marker.size=s*g.DEFAULT_MARKER_SIZE),o!=null&&t!==u.plot.SeriesPlotStyle.PIE&&(c.visible=o)}getChartType(e,t){var{dh:r}=this;switch(e){case r.plot.SeriesPlotStyle.HISTOGRAM:return"bar";default:return this.getPlotlyChartType(e,t)}}getAxisPropertyName(e){var{dh:t}=this;switch(e){case t.plot.AxisType.X:return"x";case t.plot.AxisType.Y:return"y";default:return null}}getAxisSide(e){var{dh:t}=this;switch(e){case t.plot.AxisPosition.BOTTOM:return"bottom";case t.plot.AxisPosition.TOP:return"top";case t.plot.AxisPosition.LEFT:return"left";case t.plot.AxisPosition.RIGHT:return"right";default:return}}updateFigureAxes(e,t,r,a){for(var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0,l=arguments.length>5&&arguments[5]!==void 0?arguments[5]:0,s=e,o=g.getAllAxes(t),u=0;u<t.charts.length;u+=1){var c=t.charts[u],d=a==null?void 0:a(c),f=this.getChartBounds(t,c,i,l);this.updateLayoutAxes(s,c.axes,o,r,i,l,f,d)}this.removeStaleAxes(s,o)}getChartBounds(e,t,r,a){var i,{dh:l}=this,{cols:s,rows:o}=e,{column:u,colspan:c,row:d,rowspan:f}=t,p=u+c,v=d+f,y=1/s,S=1/o,E=g.AXIS_SIZE_PX/r,F=g.AXIS_SIZE_PX/a,b={bottom:(o-v)*S+(v<o?F/2:0),top:(o-d)*S-(d>0?F/2:0),left:u*y+(u>0?E/2:0),right:p*y-(p<s?E/2:0)},P=g.groupArray(t.axes,"position"),A=(i=P.get(l.plot.AxisPosition.RIGHT))!==null&&i!==void 0?i:[];return A.length>0&&(r>0?b.right-=(b.right-b.left)*Math.max(0,Math.min(g.LEGEND_WIDTH_PX/r,g.MAX_LEGEND_SIZE)):b.right-=(b.right-b.left)*g.DEFAULT_AXIS_SIZE),b}getPlotlyDateFormat(e,t,r){var{dh:a}=this,i=r==null?void 0:r.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",""),l,s=e==null?void 0:e.getColumnTypeFormatter(t);return s!=null&&Ue(s)&&s.dhTimeZone!=null&&s.showTimeZone&&(l=a.i18n.DateTimeFormat.format(" z",new Date,s.dhTimeZone)),{tickformat:i,ticksuffix:l,automargin:!0}}getPlotlyAxisFormat(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,{dh:r}=this,{axis:a,columnType:i}=e,{formatPattern:l}=a,s=null;return h.isDateType(i)?(s=this.getPlotlyDateFormat(t,i,l),s=g.addTickSpacing(s,a,!0)):h.isNumberType(i)&&(s=g.getPlotlyNumberFormat(t,i,l),s=g.addTickSpacing(s,a,!1)),a.formatType===r.plot.AxisFormatType.CATEGORY&&(s?s.type="category":s={type:"category",tickformat:void 0,ticksuffix:void 0}),s}updateLayoutAxes(e,t,r,a){for(var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0,l=arguments.length>5&&arguments[5]!==void 0?arguments[5]:0,s=arguments.length>6&&arguments[6]!==void 0?arguments[6]:{left:0,top:0,right:1,bottom:1},o=arguments.length>7?arguments[7]:void 0,{dh:u}=this,c=i>0?Math.max(g.MIN_AXIS_SIZE,Math.min(g.AXIS_SIZE_PX/l,g.MAX_AXIS_SIZE)):g.DEFAULT_AXIS_SIZE,d=l>0?Math.max(g.MIN_AXIS_SIZE,Math.min(g.AXIS_SIZE_PX/i,g.MAX_AXIS_SIZE)):g.DEFAULT_AXIS_SIZE,f=e,p=g.groupArray(t,"position"),v=g.groupArray(t,"type"),y=[...v.keys()],S=g.groupArray(r,"type"),E=0;E<y.length;E+=1){var F=y[E],b=this.getAxisPropertyName(F);if(b!=null){var P=v.get(F),A=S.get(F),M=F===u.plot.AxisType.Y,I=M?l:i;fe(P),fe(A);for(var x=0;x<P.length;x+=1){var _=P[x],re=A.indexOf(_),Z=g.getAxisLayoutProperty(b,re);f[Z]==null&&(f[Z]=this.makeLayoutAxis(F,a));var B=f[Z];if(B!=null){this.updateLayoutAxis(B,_,x,p,c,d,s);var{range:oe,autorange:ne}=B;if(o!=null&&oe!==void 0&&(ne===void 0||ne===!1)){var Se=o(_),[ue,ce]=Se(oe);me.debug("Setting downsample range",I,ue,ce),_.range(I,ue,ce)}else _.range(I)}}}}}removeStaleAxes(e,t){for(var r=e,a=g.groupArray(t,"type"),i=[...a.keys()],l=0;l<i.length;l+=1){var s=i[l],o=a.get(s);fe(o);var u=o.length,c=this.getAxisPropertyName(s);if(c!=null)for(var d=g.getAxisLayoutProperty(c,u);r[d]!=null;)delete r[d],u+=1,d=g.getAxisLayoutProperty(c,u)}}updateLayoutAxis(e,t,r,a,i,l,s){var o,{dh:u}=this,c=t.type===u.plot.AxisType.Y,d=c?l:i,f=e,p=(o=t.label)!==null&&o!==void 0?o:"";if(f.title!==void 0&&typeof f.title!="string"?f.title.text=p:f.title={text:p},t.log&&(f.type="log"),f.side=this.getAxisSide(t.position),r>0){var v,y;f.overlaying=(v=this.getAxisPropertyName(t.type))!==null&&v!==void 0?v:void 0;var S=(y=a.get(t.position))!==null&&y!==void 0?y:[],E=S.indexOf(t);E>0&&(f.anchor="free",t.position===u.plot.AxisPosition.RIGHT?f.position=s.right+(E-S.length+1)*d:t.position===u.plot.AxisPosition.TOP?f.position=s.top+(E-S.length+1)*d:t.position===u.plot.AxisPosition.BOTTOM?f.position=s.bottom+(S.length-E+1)*d:t.position===u.plot.AxisPosition.LEFT&&(f.position=s.left+(S.length-E+1)*d))}else if(t.type===u.plot.AxisType.X){var F=a.get(u.plot.AxisPosition.LEFT)||[],b=a.get(u.plot.AxisPosition.RIGHT)||[],P=Math.max(s.left,s.left+(F.length-1)*l),A=Math.min(s.right-(b.length-1)*l,s.right);f.domain=[P,A]}else if(t.type===u.plot.AxisType.Y){var M=a.get(u.plot.AxisPosition.BOTTOM)||[],I=a.get(u.plot.AxisPosition.TOP)||[],x=Math.max(s.bottom,s.bottom+(M.length-1)*i),_=Math.min(s.top-(I.length-1)*i,s.top);f.domain=[x,_]}}createBoundsFromDays(e){var t=e.map(l=>this.daysOfWeek.indexOf(l)),r=this.daysOfWeek.filter(l=>!e.includes(l)).map(l=>this.daysOfWeek.indexOf(l)),a=new Set;r.forEach(l=>{for(var s=l+1;s<l+this.daysOfWeek.length;s+=1){var o=s%this.daysOfWeek.length;if(t.includes(o)){a.add(o);break}}});var i=[];return a.forEach(l=>{for(var s=l-1;s>l-this.daysOfWeek.length;s-=1){var o=s<0?s+this.daysOfWeek.length:s;if(t.includes(o)){var u=(o+1)%7;i.push([u,l]);break}}}),i}createRangeBreakValuesFromHolidays(e,t,r){var a=[],i=[];return e.forEach(l=>{l.businessPeriods.length>0?i.push(...this.createPartialHoliday(l,t,r)):a.push(this.createFullHoliday(l,t,r))}),[{values:a},...i]}createFullHoliday(e,t,r){return this.adjustDateForTimeZone("".concat(e.date.toString()," 00:00:00.000000"),t,r)}createPartialHoliday(e,t,r){var a=e.date.toString(),i=["00:00"];e.businessPeriods.forEach(f=>{i.push(f.open),i.push(f.close)}),i.push("24:00");for(var l=[],s=0;s<i.length;s+=2){var o=i[s],u=i[s+1];if(o!==u){var c=[this.adjustDateForTimeZone("".concat(a," ").concat(o,":00.000000"),t,r)],d=mn*(g.periodToDecimal(u)-g.periodToDecimal(o));l.push({values:c,dvalue:d})}}return l}adjustDateForTimeZone(e,t,r){return r&&r.standardOffset!==t.standardOffset?this.unwrapValue(this.wrapValue(e,Je,t),r):e}makeFigureSettings(e,t){var{dh:r}=this,{series:a,xAxis:i,type:l}=e,s=g.titleFromSettings(e),o={formatType:"".concat(r.plot.AxisFormatType.NUMBER),type:"".concat(r.plot.AxisType.X),position:"".concat(r.plot.AxisPosition.BOTTOM)},u={formatType:"".concat(r.plot.AxisFormatType.NUMBER),type:"".concat(r.plot.AxisType.Y),position:"".concat(r.plot.AxisPosition.LEFT)};return{charts:[{chartType:"".concat(r.plot.ChartType.XY),axes:[o,u],series:(a??[]).map(c=>({plotStyle:"".concat(l),name:c,dataSources:[{type:"".concat(r.plot.SourceType.X),columnName:i??"",axis:o,table:t},{type:"".concat(r.plot.SourceType.Y),columnName:c,axis:u,table:t}]}))}],title:s}}unwrapValue(e,t){var{dh:r}=this;if(e!=null){if(vn(e))return r.i18n.DateTimeFormat.format(g.DATE_FORMAT,e,t);if(pn(e))return e.asNumber()}return e}wrapValue(e,t){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null,{dh:a}=this;if(h.isDateType(t)&&typeof e=="string"){var i=e,l=g.DATE_FORMAT.substr(0,e.length),s=a.i18n.DateTimeFormat.parse(l,i);if(!r)return s;var o="".concat(l," Z"),u=a.i18n.DateTimeFormat.format("Z",s,r),c=a.i18n.DateTimeFormat.parse(o,"".concat(i," ").concat(u)),d=a.i18n.DateTimeFormat.format("Z",c,r);return a.i18n.DateTimeFormat.parse(o,"".concat(i," ").concat(d))}return e}makeLayoutAxis(e,t){var{dh:r}=this,a={automargin:!0,gridcolor:t.gridcolor,linecolor:t.linecolor,rangeslider:{visible:!1},showline:!0,ticklen:5,tickcolor:t.paper_bgcolor,tickfont:{color:t.zerolinecolor},title:{font:{color:t.title_color}}};return e===r.plot.AxisType.X?Object.assign(a,{showgrid:!0}):e===r.plot.AxisType.Y&&Object.assign(a,{zerolinecolor:t.zerolinecolor,zerolinewidth:2}),a}makeDefaultLayout(e){var{dh:t}=this,r=le(le({},e),{},{autosize:!0,colorway:g.getColorwayFromTheme(e),font:{family:"'Fira Sans', sans-serif",color:e.title_color},title:{font:{color:e.title_color},yanchor:"top",pad:le({},g.DEFAULT_TITLE_PADDING),y:1},legend:{font:{color:e.title_color}},margin:le({},g.DEFAULT_MARGIN),xaxis:this.makeLayoutAxis(t.plot.AxisType.X,e),yaxis:this.makeLayoutAxis(t.plot.AxisType.Y,e),polar:{angularaxis:this.makeLayoutAxis(t.plot.AxisType.SHAPE,e),radialaxis:this.makeLayoutAxis(t.plot.AxisType.SHAPE,e),bgcolor:e.plot_bgcolor},scene:{xaxis:this.makeLayoutAxis(t.plot.AxisType.X,e),yaxis:this.makeLayoutAxis(t.plot.AxisType.Y,e),zaxis:this.makeLayoutAxis(t.plot.AxisType.Z,e)}});return r.datarevision=0,r}hydrateSettings(e){var{dh:t}=this;return le(le({},e),{},{type:e.type!=null?t.plot.SeriesPlotStyle[e.type]:void 0})}}R(g,"DEFAULT_AXIS_SIZE",.15);R(g,"MIN_AXIS_SIZE",.025);R(g,"MAX_AXIS_SIZE",.2);R(g,"AXIS_SIZE_PX",75);R(g,"LEGEND_WIDTH_PX",50);R(g,"MAX_LEGEND_SIZE",.25);R(g,"ORIENTATION",Object.freeze({HORIZONTAL:"h",VERTICAL:"v"}));R(g,"DATE_FORMAT","yyyy-MM-dd HH:mm:ss.SSSSSS");R(g,"DEFAULT_MARGIN",Object.freeze({l:60,r:50,t:30,b:60,pad:0}));R(g,"DEFAULT_TITLE_PADDING",Object.freeze({t:8}));R(g,"SUBTITLE_LINE_HEIGHT",25);R(g,"DEFAULT_MARKER_SIZE",6);R(g,"MODE_MARKERS","markers");R(g,"MODE_LINES","lines");const j=g;function et(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(n,a).enumerable})),t.push.apply(t,r)}return t}function tt(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?et(Object(t),!0).forEach(function(r){L(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):et(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function L(n,e,t){return e=Sn(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Sn(n){var e=En(n,"string");return typeof e=="symbol"?e:String(e)}function En(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}var Q=W.module("Chart");class ie extends H.Component{static convertIcon(e){var[t,,,,r]=e.icon,a="".concat(r);return{width:t,path:a,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"}constructor(e){super(e),L(this,"currentSeries",void 0),L(this,"PlotComponent",void 0),L(this,"plot",void 0),L(this,"plotWrapper",void 0),L(this,"columnFormats",void 0),L(this,"dateTimeFormatterOptions",void 0),L(this,"decimalFormatOptions",void 0),L(this,"integerFormatOptions",void 0),L(this,"rect",void 0),L(this,"ranges",void 0),L(this,"isSubscribed",void 0),L(this,"isLoadedFired",void 0),L(this,"resizeObserver",void 0),L(this,"getCachedConfig",yt((t,r,a,i,l)=>{var s=[],o=!!t;if(o&&s.push({name:"Downsampling failed: ".concat(t),title:"Downsampling failed",click:()=>{},icon:ie.convertIcon(At),attr:"fill-warning"}),r||a||i||o){var u=ie.downsampleButtonTitle(a,i),c=ie.downsampleButtonAttr(a,i),d=a?Ot:Ct;s.push({name:u,title:"Downsampling status",icon:ie.convertIcon(d),click:this.handleDownsampleClick,attr:c})}var f=l.some(S=>{var{type:E}=S;return E!=null&&!E.includes("3d")}),p=l.some(S=>{var{type:E}=S;return E!=null&&E.includes("3d")}),v=["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"],y=["orbitRotation","tableRotation","resetCameraDefault3d"];return{displaylogo:!1,displayModeBar:a||o?!0:"hover",modeBarButtons:[s,["toImage"],["zoom2d","pan2d"],[...f?v:[],...p?y:[]]]}})),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.handleResize=this.handleResize.bind(this),this.handleRestyle=this.handleRestyle.bind(this),this.PlotComponent=un(e.Plotly),this.plot=Y.createRef(),this.plotWrapper=Y.createRef(),this.columnFormats=[],this.dateTimeFormatterOptions={},this.decimalFormatOptions={},this.integerFormatOptions={},this.isSubscribed=!1,this.isLoadedFired=!1,this.currentSeries=0,this.resizeObserver=new window.ResizeObserver(this.handleResize),this.state={data:null,downsamplingError:null,isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,layout:{datarevision:0},revision:0}}componentDidMount(){this.updateDimensions(),this.updateModelDimensions(),this.initData(),this.initFormatter();var{isActive:e,model:t}=this.props;e&&this.subscribe(t),this.plotWrapper.current!=null&&this.resizeObserver.observe(this.plotWrapper.current)}componentDidUpdate(e){var{isActive:t,model:r,settings:a}=this.props;this.updateFormatterSettings(a),r!==e.model&&(this.unsubscribe(e.model),this.subscribe(r)),t!==e.isActive&&(t?(this.updateDimensions(),this.subscribe(r)):this.unsubscribe(r))}componentWillUnmount(){var{model:e}=this.props;this.unsubscribe(e),this.resizeObserver.disconnect()}getPlotRect(){var e,t;return(e=(t=this.plotWrapper.current)===null||t===void 0?void 0:t.getBoundingClientRect())!==null&&e!==void 0?e:null}initData(){var{model:e}=this.props,{layout:t}=this.state;this.setState({data:e.getData(),layout:tt(tt({},t),e.getLayout())})}subscribe(e){if(!this.isSubscribed){if(!this.rect||this.rect.width===0||this.rect.height===0){Q.debug2("Delaying subscription until model dimensions are set");return}e.subscribe(this.handleModelEvent),this.isSubscribed=!0}}unsubscribe(e){this.isSubscribed&&(e.unsubscribe(this.handleModelEvent),this.isSubscribed=!1)}handleAfterPlot(){this.plot.current!=null}handleDownsampleClick(){this.setState(e=>{var{isDownsamplingDisabled:t}=e;return{downsamplingError:null,isDownsampleInProgress:!1,isDownsampleFinished:!1,isDownsamplingDisabled:!t}},()=>{var{model:e}=this.props,{isDownsamplingDisabled:t}=this.state;e.setDownsamplingDisabled(t)})}handleModelEvent(e){var{type:t,detail:r}=e;switch(Q.debug2("Received data update",t,r),t){case X.EVENT_UPDATED:{this.currentSeries+=1,this.setState(d=>{var{layout:f,revision:p}=d;return typeof f.datarevision=="number"&&(f.datarevision+=1),{data:r,layout:f,revision:p+1}});var{onUpdate:a}=this.props;a({isLoading:!this.isLoadedFired});break}case X.EVENT_LOADFINISHED:{var{onUpdate:i}=this.props;this.isLoadedFired=!0,i({isLoading:!1});break}case X.EVENT_DISCONNECT:{var{onDisconnect:l}=this.props;l();break}case X.EVENT_RECONNECT:{var{onReconnect:s}=this.props;s();break}case X.EVENT_DOWNSAMPLESTARTED:{this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!0,downsamplingError:null});break}case X.EVENT_DOWNSAMPLEFINISHED:{this.setState({isDownsampleFinished:!0,isDownsampleInProgress:!1,downsamplingError:null});break}case X.EVENT_DOWNSAMPLENEEDED:case X.EVENT_DOWNSAMPLEFAILED:{var o,u=(o=r.message)!==null&&o!==void 0?o:r;this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,downsamplingError:u});var{onError:c}=this.props;c(new Error(u));break}default:Q.debug("Unknown event type",t,e)}}handlePlotUpdate(e){var{layout:t}=e,r=j.getLayoutRanges(t),a=!de(r,this.ranges);a&&(this.ranges=r,this.updateModelDimensions(!0))}handleRelayout(e){if(Q.debug("handleRelayout",e),e.hiddenlabels!=null){var{onSettingsChanged:t}=this.props,r=[...e.hiddenlabels];t({hiddenSeries:r})}this.updateModelDimensions()}handleResize(){this.updateDimensions()}handleRestyle(e){var[t,r]=e;if(Q.debug("handleRestyle",t,r),Object.keys(t).includes("visible")){var{data:a}=this.state,{onSettingsChanged:i}=this.props;if(a!=null){var l=a.reduce((s,o)=>{var{name:u,visible:c}=o;return u!=null&&c==="legendonly"?[...s,u]:s},[]);i({hiddenSeries:l})}}}updateModelDimensions(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,t=this.getPlotRect();if(!t){Q.warn("Unable to get plotting rect");return}var r=!this.rect||this.rect.width!==t.width||this.rect.height!==t.height;if(r||e){this.rect=t;var{isActive:a,model:i}=this.props;i.setDimensions(t),a&&this.subscribe(i)}}initFormatter(){var{settings:e}=this.props;this.updateFormatterSettings(e)}updateFormatterSettings(e){var t=Oe.getColumnFormats(e),r=Oe.getDateTimeFormatterOptions(e),{decimalFormatOptions:a={},integerFormatOptions:i={}}=e;(!de(this.columnFormats,t)||!de(this.dateTimeFormatterOptions,r)||!de(this.decimalFormatOptions,a)||!de(this.integerFormatOptions,i))&&(this.columnFormats=Oe.getColumnFormats(e),this.dateTimeFormatterOptions=r,this.decimalFormatOptions=a,this.integerFormatOptions=i,this.updateFormatter())}updateFormatter(){var{model:e}=this.props,t=new ke(e.dh,this.columnFormats,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions);e.setFormatter(t)}updateDimensions(){var e=this.getPlotRect(),{Plotly:t}=this.props;this.plot.current!=null&&e!=null&&e.width>0&&e.height>0&&t.relayout(this.plot.current.el,{autosize:!0}).catch(r=>{Q.debug("Unable to resize, promise rejected",r)})}render(){var{PlotComponent:e}=this,{data:t,downsamplingError:r,isDownsampleFinished:a,isDownsampleInProgress:i,isDownsamplingDisabled:l,layout:s,revision:o}=this.state,u=this.getCachedConfig(r,a,i,l,t??[]),c=t!=null;return T.jsx("div",{className:"h-100 w-100 chart-wrapper",ref:this.plotWrapper,children:c&&T.jsx(e,{ref:this.plot,data:t,layout:s,revision:o,config:u,onAfterPlot:this.handleAfterPlot,onError:Q.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}}L(ie,"defaultProps",{isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:O.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},Plotly:ut,onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}});const Qn=ie;function rt(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(n);e&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(n,a).enumerable})),t.push.apply(t,r)}return t}function nt(n){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?rt(Object(t),!0).forEach(function(r){D(n,r,t[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(t)):rt(Object(t)).forEach(function(r){Object.defineProperty(n,r,Object.getOwnPropertyDescriptor(t,r))})}return n}function D(n,e,t){return e=Tn(e),e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Tn(n){var e=bn(n,"string");return typeof e=="symbol"?e:String(e)}function bn(n,e){if(typeof n!="object"||n===null)return n;var t=n[Symbol.toPrimitive];if(t!==void 0){var r=t.call(n,e||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(n)}var V=W.module("FigureChartModel");class we extends X{constructor(e,t,r){var a,i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};super(e),a=this,D(this,"chartUtils",void 0),D(this,"dh",void 0),D(this,"figure",void 0),D(this,"settings",void 0),D(this,"theme",void 0),D(this,"data",void 0),D(this,"layout",void 0),D(this,"seriesDataMap",void 0),D(this,"pendingSeries",void 0),D(this,"oneClicks",void 0),D(this,"filterColumnMap",void 0),D(this,"lastFilter",void 0),D(this,"isConnected",void 0),D(this,"seriesToProcess",void 0),D(this,"addPendingSeries",St(()=>{for(var s=j.getAllAxes(this.figure),{pendingSeries:o}=this,u=function(){var f,p=o[c],v=a.figure.charts.find(y=>y.series.includes(p));a.addSeries(p,s,(f=v==null?void 0:v.showLegend)!==null&&f!==void 0?f:null),p.subscribe()},c=0;c<o.length;c+=1)u();this.pendingSeries=[]},we.ADD_SERIES_DEBOUNCE)),D(this,"getTimeZone",he((s,o)=>{if(o!=null){var u=o.getColumnTypeFormatter(s);if(u!=null)return u.dhTimeZone}})),D(this,"getValueTranslator",he((s,o)=>{var u=this.getTimeZone(s,o);return c=>this.chartUtils.unwrapValue(c,u)})),D(this,"getValueParser",he((s,o)=>{var u=this.getTimeZone(s,o);return c=>this.chartUtils.wrapValue(c,s,u)})),D(this,"getRangeParser",he((s,o)=>u=>{var[c,d]=u,f=this.getValueParser(s,o);return c=f(c),d=f(d),[c,d]})),D(this,"getAxisRangeParser",he((s,o)=>u=>{var c=j.getSourceForAxis(s,u);return c!=null?this.getRangeParser(c.columnType,o):d=>d})),this.handleFigureUpdated=this.handleFigureUpdated.bind(this),this.handleFigureDisconnected=this.handleFigureDisconnected.bind(this),this.handleFigureReconnected=this.handleFigureReconnected.bind(this),this.handleFigureSeriesAdded=this.handleFigureSeriesAdded.bind(this),this.handleDownsampleStart=this.handleDownsampleStart.bind(this),this.handleDownsampleFinish=this.handleDownsampleFinish.bind(this),this.handleDownsampleFail=this.handleDownsampleFail.bind(this),this.handleDownsampleNeeded=this.handleDownsampleNeeded.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.dh=e,this.chartUtils=new j(e),this.figure=t,this.settings=i,this.theme=r,this.data=[];var l={data:{},layout:this.chartUtils.makeDefaultLayout(r)};this.layout={grid:{rows:t.rows,columns:t.cols,pattern:"independent"},template:l},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(){if(this.figure.charts.length>0){var e=this.figure.charts[0];return e.title}return""}initAllSeries(){this.oneClicks=[],this.filterColumnMap.clear();for(var{charts:e}=this.figure,t=j.getAllAxes(this.figure),r=[],a=0;a<e.length;a+=1)for(var i=e[a],l=0;l<i.series.length;l+=1){var s=i.series[l];r.push(s.name),this.addSeries(s,t,i.showLegend)}for(var o=[...this.seriesDataMap.keys()],u=o.filter(f=>r.indexOf(f)<0),c=0;c<u.length;c+=1){var d=u[c];this.seriesDataMap.delete(d)}this.seriesToProcess=new Set([...this.seriesDataMap.keys()])}addSeries(e,t,r){var{dh:a}=this,i=j.groupArray(t,"type"),l=this.chartUtils.makeSeriesDataFromSeries(e,i,j.getSeriesVisibility(e.name,this.settings),this.theme,r);if(this.seriesDataMap.set(e.name,l),this.data=[...this.seriesDataMap.values()],e.plotStyle===a.plot.SeriesPlotStyle.STACKED_BAR?this.layout.barmode="stack":e.plotStyle===a.plot.SeriesPlotStyle.PIE&&(this.layout.hiddenlabels=j.getHiddenLabels(this.settings)),this.layout.showlegend=this.data.length>1||e.plotStyle===a.plot.SeriesPlotStyle.PIE?r??void 0:!1,e.oneClick!=null){for(var{oneClick:s}=e,{columns:o}=s,u=0;u<o.length;u+=1)this.filterColumnMap.set(o[u].name,o[u]);this.oneClicks.push(s)}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?this.dh.plot.DownsampleOptions.DISABLE:this.dh.plot.DownsampleOptions.DEFAULT)}unsubscribeFigure(){this.figure.unsubscribe()}startListeningFigure(){var{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(){var{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){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){var{detail:t}=e,{series:r}=t;V.debug2("handleFigureUpdated",r);for(var a=0;a<r.length;a+=1){var i=r[a];V.debug2("handleFigureUpdated updating series",i.name);for(var{sources:l}=i,s=0;s<l.length;s+=1){var o=l[s],{columnType:u,type:c}=o,d=this.getValueTranslator(u,this.formatter),f=t.getArray(i,c,d);this.setDataArrayForSeries(i,c,f)}this.seriesToProcess.delete(i.name),this.seriesToProcess.size===0&&this.fireLoadFinished(),this.cleanSeries(i)}var{data:p}=this;this.fireUpdate(p)}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){var{detail:t}=e;V.debug("handleFigureSeriesAdded",t),this.pendingSeries.push(t),this.addPendingSeries()}setDimensions(e){super.setDimensions(e),this.updateAxisPositions()}setTitle(e){var t,r;super.setTitle(e);var a=(t=(r=(e??"").match(/<br>/g))===null||r===void 0?void 0:r.length)!==null&&t!==void 0?t:0,i=j.DEFAULT_MARGIN.t+a*j.SUBTITLE_LINE_HEIGHT;this.layout.margin?this.layout.margin.t=i:this.layout.margin={t:i},typeof this.layout.title=="string"?this.layout.title=e:(this.layout.title=nt({},this.layout.title),this.layout.title.text=e,this.layout.title.pad=nt({},this.layout.title.pad),this.layout.title.pad.t=j.DEFAULT_TITLE_PADDING.t+a*j.SUBTITLE_LINE_HEIGHT*.5)}getPlotWidth(){var e,t,r,a;return!this.rect||!this.rect.width?0:Math.max(this.rect.width-((e=(t=this.layout.margin)===null||t===void 0?void 0:t.l)!==null&&e!==void 0?e:0)-((r=(a=this.layout.margin)===null||a===void 0?void 0:a.r)!==null&&r!==void 0?r:0),0)}getPlotHeight(){var e,t,r,a;return!this.rect||!this.rect.height?0:Math.max(this.rect.height-((e=(t=this.layout.margin)===null||t===void 0?void 0:t.t)!==null&&e!==void 0?e:0)-((r=(a=this.layout.margin)===null||a===void 0?void 0:a.b)!==null&&r!==void 0?r:0),0)}updateAxisPositions(){var e=this.getPlotWidth(),t=this.getPlotHeight();this.chartUtils.updateFigureAxes(this.layout,this.figure,this.theme,r=>this.getAxisRangeParser(r,this.formatter),e,t)}updateLayoutFormats(){if(this.formatter){var e=this.chartUtils.getAxisFormats(this.figure,this.formatter);e.forEach((t,r)=>{V.debug("Assigning ".concat(r),this.layout[r],t);var a=this.layout[r];a!=null?Object.assign(a,t):V.debug("Ignoring null layout.".concat(r))})}}setDataArrayForSeries(e,t,r){var{name:a,plotStyle:i}=e,l=this.seriesDataMap.get(a),s=this.chartUtils.getPlotlyProperty(i,t);l&&lt(l,s,r)}cleanSeries(e){var{dh:t}=this,{name:r,plotStyle:a}=e,i=this.seriesDataMap.get(r);if(i!=null){if(a===t.plot.SeriesPlotStyle.HISTOGRAM){var{xLow:l,xHigh:s}=i;if(l&&s&&l.length===s.length){for(var o=[],u=0;u<l.length;u+=1)o.push(s[u]-l[u]);i.width=o}}else if(a===t.plot.SeriesPlotStyle.LINE||a===t.plot.SeriesPlotStyle.ERROR_BAR||a===t.plot.SeriesPlotStyle.BAR){var{x:c,xLow:d,xHigh:f,y:p,yLow:v,yHigh:y}=i;d&&f&&d!==c&&(i.error_x=j.getPlotlyErrorBars(c,d,f,this.theme)),v&&y&&v!==p&&(i.error_y=j.getPlotlyErrorBars(p,v,y,this.theme))}else if(a===t.plot.SeriesPlotStyle.TREEMAP){var{ids:S,labels:E}=i;S!==void 0&&E===void 0&&(i.labels=S)}}}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){var t=this;if(this.oneClicks.length===0){V.warn("Trying to set a filter, but no one click!");return}V.debug("setFilter",e);for(var r=function(){var l=t.oneClicks[a],{columns:s}=l,o=new Set([...e.keys(),...t.lastFilter.keys()]);o.forEach(u=>{var c=e.get(u);t.lastFilter.get(u)!==c&&s.find(d=>d.name===u)!=null&&l.setValueForColumn(u,c)})},a=0;a<this.oneClicks.length;a+=1)r();this.lastFilter=new Map(e)}setFigure(e){this.close(),this.figure=e,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure(),this.listeners.length>0&&this.subscribeFigure()}updateSettings(e){this.settings=e}}D(we,"ADD_SERIES_DEBOUNCE",50);const at=we;function it(n,e,t,r,a,i,l){try{var s=n[i](l),o=s.value}catch(u){t(u);return}s.done?e(o):Promise.resolve(o).then(r,a)}function Ce(n){return function(){var e=this,t=arguments;return new Promise(function(r,a){var i=n.apply(e,t);function l(o){it(i,r,a,l,s,"next",o)}function s(o){it(i,r,a,l,s,"throw",o)}l(void 0)})}}class _e{static makeModelFromSettings(e,t,r,a){return Ce(function*(){var i=yield _e.makeFigureFromSettings(e,t,r);return new at(e,i,a,t)})()}static makeFigureFromSettings(e,t,r){return Ce(function*(){var a=yield r.copy();return a.applyCustomColumns(r.customColumns),a.applyFilter(r.filter),a.applySort(r.sort),e.plot.Figure.create(new j(e).makeFigureSettings(t,a))})()}static makeModel(e,t,r,a){return Ce(function*(){return new at(e,r,a,t)})()}}const Jn=_e,Fn="var(--dh-color-chart-colorway)",Pn="var(--dh-color-chart-grid)",Dn="var(--dh-color-chart-axis-line)",wn="var(--dh-color-chart-axis-line-zero)",Mn="var(--dh-color-chart-active)",Nn="var(--dh-color-chart-range-bg)",st={"paper-bgcolor":"var(--dh-color-chart-bg)","plot-bgcolor":"var(--dh-color-chart-plot-bg)","title-color":"var(--dh-color-chart-title)",colorway:Fn,gridcolor:Pn,linecolor:Dn,zerolinecolor:wn,activecolor:Mn,rangebgcolor:Nn,"area-color":"var(--dh-color-chart-area)","trend-color":"var(--dh-color-chart-trend)","line-color":"var(--dh-color-chart-line-deprecated)","error-band-line-color":"var(--dh-color-chart-error-band-line)","error-band-fill-color":"var(--dh-color-chart-error-band-fill)","ohlc-increasing":"var(--dh-color-chart-ohlc-increase)","ohlc-decreasing":"var(--dh-color-chart-ohlc-decrease)"};var ot=W.module("ChartTheme");function An(){var n,e=It(st);return e.colorway=xt((n=e.colorway)!==null&&n!==void 0?n:"").map(t=>{var[r,a]=t;return Rt.normalizeCssColor(e.colorway.substring(r,a+1))}).join(" "),ot.debug2("Chart theme:",st),ot.debug2("Chart theme derived:",e),Object.freeze({paper_bgcolor:e["paper-bgcolor"],plot_bgcolor:e["plot-bgcolor"],title_color:e["title-color"],colorway:e.colorway,gridcolor:e.gridcolor,linecolor:e.linecolor,zerolinecolor:e.zerolinecolor,activecolor:e.activecolor,rangebgcolor:e.rangebgcolor,area_color:e["area-color"],trend_color:e["trend-color"],line_color:e["line-color"],error_band_line_color:e["error-band-line-color"],error_band_fill_color:e["error-band-fill-color"],ohlc_increasing:e["ohlc-increasing"],ohlc_decreasing:e["ohlc-decreasing"]})}var mt=H.createContext(null);function Un(n){var{children:e}=n,{activeThemes:t}=Mr(),[r,a]=H.useState(null);return H.useEffect(()=>{t!=null&&a(An())},[t]),T.jsx(mt.Provider,{value:r,children:e})}function ea(){return Pe(mt,"No ChartThemeContext value found.")}var On=H.createContext(null);function ta(){return Pe(On,"No IdeConnection available in useConnection. Was code wrapped in ConnectionContext.Provider?")}export{kn as $,Wn as A,Cr as B,Qn as C,q as D,Bn as E,ke as F,Kn as G,Gr as H,K as I,Xn as J,Yn as K,sn as L,on as M,Ur as N,en as O,Ie as P,ln as Q,Zn as R,qr as S,dt as T,X as U,An as V,j as W,un as X,mt as Y,Un as Z,at as _,Hn as a,Ne as a0,On as a1,$e as a2,Rn as a3,Ln as a4,ye as a5,zn as a6,Jt as a7,ea as b,Vn as c,Jn as d,Pe as e,ae as f,rr as g,jn as h,_n as i,Mr as j,ct as k,m as l,xr as m,O as n,N as o,Hr as p,Oe as q,k as r,h as s,Pr as t,ta as u,$n as v,ft as w,Jr as x,qn as y,Gn as z};
2
+ //# sourceMappingURL=useConnection-ce8a0cb3.js.map