@deephaven/embed-chart 0.34.1-beta.0 → 0.34.1-relative-links.6

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