@deephaven/embed-chart 0.40.2-dashboard-panel-wrapper.11 → 0.40.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- var ce=Object.defineProperty;var de=(f,t,e)=>t in f?ce(f,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):f[t]=e;var h=(f,t,e)=>(de(f,typeof t!="symbol"?t+"":t,e),e);import{r as v,G as P,C as T,E as j,F as Z}from"./vendor-f479e584.js";import{q as he,L as V,w as me,x as fe,b as pe}from"./index-0168b447.js";function z(f,t="No value available in context. Was code wrapped in a provider?"){const e=v.useContext(f);if(e==null)throw new Error(t);return e}class ge extends Error{constructor(){super(...arguments);h(this,"isCanceled",!0)}}const J=ge;class Te extends Error{constructor(){super(...arguments);h(this,"isTimeout",!0)}}const te=Te;class Q{static makeCancelable(t,e){let n=!1,r,s;const o=new Promise((a,i)=>{s=i,Promise.resolve(t).then(l=>{n?e&&e(l):(r=l,a(l))}).catch(l=>i(l))});return o.cancel=()=>{n=!0,s(new J),r!=null&&e&&e(r)},o}static isCanceled(t){return t instanceof J}static isTimedOut(t){return t instanceof te}static withTimeout(t,e){return new Promise((n,r)=>{setTimeout(()=>{try{n(e())}catch(s){r(s)}},t)})}}function je(f){if(f==null)throw new Error("Value is null or undefined")}class Me{static join(t,e="and"){if(t==null||t.length===0)return"";if(t.length===1)return t[0];if(t.length===2)return`${t[0]} ${e} ${t[1]}`;const n=t.slice(0,t.length-1).join(", "),r=t[t.length-1];return`${n}, ${e} ${r}`}static toLower(t,e=!0){if(t==null){if(e)return"";throw new Error("Null string passed in to TextUtils.toLower")}return t.toLowerCase()}static sort(t,e,n=!0){return t<e?n?-1:1:t>e?n?1:-1:0}}const Se=Me;function Be(f){return f.then!==void 0}const A=class{static disableAllActions(){A.actionsDisabled=!0}static enableAllActions(){A.actionsDisabled=!1}static isContextActionEvent(t){return Array.isArray(t.contextActions)}static compareActions(t,e){return t.group!==e.group?(t.group??0)>(e.group??0)?1:-1:t.order!==e.order?(t.order??0)>(e.order??0)?1:-1:t.title!==e.title?(t.title??"")>(e.title??"")?1:-1:t!==e?t>e?1:-1:0}static sortActions(t){if(t==null||!Array.isArray(t))return[];const e=t.slice();return e.sort(A.compareActions),e}static isMacPlatform(){const{platform:t}=window.navigator;return t.startsWith("Mac")}static getModifierKey(){return A.isMacPlatform()?"metaKey":"ctrlKey"}static isModifierKeyDown(t){const e=A.getModifierKey();return t[e]}static getMenuItems(t,e=!0){let n=[],r=t;Array.isArray(r)||(r=[r]);for(let s=0;s<r.length;s+=1){const o=r[s];let a;typeof o=="function"?a=o():a=o,a!=null&&(a instanceof Promise?e&&n.push(a):Array.isArray(a)?n=n.concat(a):n.push(a))}return n=n.filter(s=>s.title!==void 0||s.then!=null||s.menuElement),n}static getNextMenuItem(t,e,n){let r=t;r<0&&e<0&&(r=n.length);for(let s=1;s<n.length+1;s+=1){const o=(r+e*s+n.length)%n.length,a=n[o];if(!(a instanceof Promise)&&a.disabled!==!0)return o}return t}};let W=A;h(W,"actionsDisabled",!1);const D=W,X=P.forwardRef((f,t)=>{var $;function e(g){const{menuItem:N,onMenuItemClick:S}=f;S(N,g)}function n(g){const{menuItem:N,onMenuItemMouseMove:S}=f;S(N,g)}function r(g){const{menuItem:N,onMenuItemContextMenu:S}=f;S(N,g)}function s(g,N,S){if(typeof g.type=="string")return g;const{closeMenu:R,menuItem:G,isKeyboardSelected:ie,isMouseSelected:oe,"data-testid":le}=f,ue={menuItem:G,closeMenu:R,isKeyboardSelected:ie,isMouseSelected:oe,iconElement:N,displayShortcut:S,"data-testid":le};return P.cloneElement(g,{forwardedProps:ue})}const{children:o,menuItem:a,isKeyboardSelected:i=!1,isMouseSelected:l=!1,"data-testid":u}=f,m=($=a.shortcut)==null?void 0:$.getDisplayText();let p=null;if(a.icon){const g=a.icon;if(P.isValidElement(g))p=g;else{let N;a.iconColor!=null&&(a.disabled===void 0||!a.disabled)&&(N={color:a.iconColor}),p=T.jsx(Z,{icon:g,style:N})}}let M=null;const y=!!o;a.actions&&(M=T.jsx(Z,{icon:he}));let b=null;if(a.menuElement)b=T.jsx("div",{className:"custom-menu-item",onMouseMove:n,children:s(a.menuElement,p,m)});else{const g=a.disabled,N=a.iconOutline;b=T.jsx("button",{type:"button",className:j("btn-context-menu",{disabled:g},{active:(y||l)&&(g===void 0||!g)},{"keyboard-active":i&&(g===void 0||!g)}),onClick:e,onMouseMove:n,onContextMenu:r,title:a.description??"",children:T.jsxs("div",{className:"btn-context-menu-wrapper",children:[T.jsx("span",{className:j("icon",{outline:N}),children:p}),T.jsx("span",{className:"title",children:a.title}),m!==void 0&&T.jsx("span",{className:"shortcut",children:m}),M&&T.jsx("span",{className:j("submenu-indicator",{disabled:g}),children:M})]})})}return T.jsxs("div",{className:"context-menu-item",ref:t,"data-testid":u,children:[o,b]})});X.displayName="ContextMenuItem";X.defaultProps={children:null,isKeyboardSelected:!1,isMouseSelected:!1,"data-testid":void 0};const ye=X,_=V.module("ContextMenu"),Y=class extends v.PureComponent{constructor(e){super(e);h(this,"container");h(this,"oldFocus");h(this,"activeSubMenuRef");h(this,"subMenuTimer");h(this,"rAF");h(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=P.createRef(),this.oldFocus=document.activeElement,this.activeSubMenuRef=P.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 n;(n=this.container.current)==null||n.focus();const{onMenuOpened:e}=this.props;e(this)})}componentDidUpdate(e,n){var o,a;const{actions:r}=this.props,{activeSubMenu:s}=this.state;s!==n.activeSubMenu&&(s==null?(o=this.container.current)==null||o.focus():this.setActiveSubMenuPosition()),e.actions!==r&&(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:n}=this.state;return n}return this.getMouseIndex()}setKeyboardIndex(e){const{options:n}=this.props;n.separateKeyboardMouse!==void 0&&n.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 n=e.initialKeyboardIndex;n===void 0&&(n=-1);const{actions:r}=this.props,s=D.getMenuItems(r),o=[];for(let a=s.length-1;a>=0;a-=1){const i=s[a];i instanceof Promise?this.initMenuPromise(i):o.push(i)}this.setState({mouseIndex:-1,keyboardIndex:n,activeSubMenu:null,menuItems:D.sortActions(o)})}initMenuPromise(e){const n=Q.makeCancelable(e);this.setState(r=>({pendingItems:r.pendingItems.concat(n)})),n.then(r=>{this.setState(s=>{const o=s.pendingItems.indexOf(n);if(o>=0){const a=s.pendingItems.slice();return a.splice(o,1),{menuItems:D.sortActions(s.menuItems.concat(r)),pendingItems:a}}return null})},r=>{Q.isCanceled(r)||(this.setState(s=>{const o=s.pendingItems.indexOf(n);if(o>=0){const a=s.pendingItems.slice();return a.splice(o,1),{pendingItems:a}}return null}),_.error(r))})}cancelPromises(){const{pendingItems:e}=this.state;e.map(n=>n.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 M,y;const{options:e,updatePosition:n,subMenuParentWidth:r,subMenuParentHeight:s,top:o,left:a}=this.props;if(!this.container.current||e.doNotVerifyPosition!=null&&e.doNotVerifyPosition)return;let{top:i,left:l}=this.initialPosition;const{width:u,height:m}=((M=this.container.current)==null?void 0:M.getBoundingClientRect())??{width:0,height:0},p=(((y=this.container.current)==null?void 0:y.scrollHeight)??0)>window.innerHeight;m===0||u===0||(i+m>window.innerHeight&&(i-m-s>0?i-=m-s:i=window.innerHeight-m),l+u>window.innerWidth&&(l=l-u-r),(a!==l||o!==i)&&(this.setState({hasOverflow:p}),n(i,l)))}handleWindowResize(){this.container.current&&this.closeMenu(!0)}handleBlur(e){if(!this.container.current){_.warn("Container is null!");return}if(!this.container.current.contains(e.relatedTarget)){let n=e.relatedTarget,r=!1;for(;n&&!r;)r=n.hasAttribute("data-dh-context-menu"),n=n.parentElement;r||this.closeMenu(!0)}}isEscapeKey(e){const{left:n}=this.props;return e==="Escape"||n<0&&e==="ArrowRight"||e==="ArrowLeft"}handleKeyDown(e){const{menuItems:n}=this.state,r=this.getKeyboardIndex();let s=r,o=!1;if(e.key==="Enter"||e.key===" "){r>=0&&r<n.length&&this.handleMenuItemClick(n[r],e);return}if(e.key==="ArrowRight"?r>=0&&r<=n.length?o=!0:s=0:this.isEscapeKey(e.key)?s=null:e.key==="ArrowUp"||e.shiftKey&&e.key==="Tab"?s=D.getNextMenuItem(s,-1,n):(e.key==="ArrowDown"||e.key==="Tab")&&(s=D.getNextMenuItem(s,1,n)),o){this.openSubMenu(r),e.preventDefault(),e.stopPropagation();return}r!==s&&(s!==null?this.setKeyboardIndex(s):(this.closeMenu(),this.oldFocus instanceof HTMLElement&&this.oldFocus.focus()),e.preventDefault(),e.stopPropagation())}openSubMenu(e){const{menuItems:n,activeSubMenu:r}=this.state,s=n[e].actions?e:null;r!==s&&this.setState({activeSubMenu:s,subMenuTop:null,subMenuLeft:null})}closeMenu(e=!1){const{closeMenu:n,onMenuClosed:r}=this.props;cancelAnimationFrame(this.rAF),this.rAF=window.requestAnimationFrame(()=>{n(e),r(this)})}closeSubMenu(){this.setState({activeSubMenu:null})}handleCloseSubMenu(e){e?this.closeMenu(!0):this.closeSubMenu()}handleMenuItemClick(e,n){n.preventDefault(),n.stopPropagation();const{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(),this.closeMenu(!0)))}handleMenuItemContextMenu(e,n){n.metaKey||this.handleMenuItemClick(e,n)}handleMenuItemMouseMove(e){const{menuItems:n}=this.state,r=n.indexOf(e);this.setMouseIndex(r),r>=0&&r<n.length&&(e.disabled===void 0||!e.disabled)&&this.openSubMenu(r)}handleMouseLeave(){this.setMouseIndex(-1)}render(){const e=[],{top:n,left:r}=this.props,{activeSubMenu:s,hasOverflow:o,keyboardIndex:a,menuItems:i,mouseIndex:l,pendingItems:u,subMenuTop:m,subMenuLeft:p,subMenuParentWidth:M,subMenuParentHeight:y}=this.state;for(let S=0;S<i.length;S+=1){const R=i[S];S>0&&R.group!==i[S-1].group&&e.push(T.jsx("hr",{},`${S}.separator`));const G=T.jsx(ye,{ref:s===S?this.activeSubMenuRef:null,isKeyboardSelected:a===S,isMouseSelected:l===S,menuItem:R,closeMenu:this.handleCloseSubMenu,onMenuItemClick:this.handleMenuItemClick,onMenuItemMouseMove:this.handleMenuItemMouseMove,onMenuItemContextMenu:this.handleMenuItemContextMenu},S);e.push(G)}let b=null;u.length>0&&(b=T.jsx("div",{className:"loading",children:T.jsx(me,{})}));const{menuStyle:$,"data-testid":g}=this.props,N=s!==null&&m!==null&&p!==null;return T.jsxs(T.Fragment,{children:[T.jsxs("div",{className:j({"has-overflow":o},"context-menu-container"),style:{top:n,left:r,...$},ref:this.container,"data-dh-context-menu":!0,onBlur:this.handleBlur,onKeyDown:this.handleKeyDown,onMouseLeave:this.handleMouseLeave,onContextMenu:Y.handleContextMenu,role:"menuitem",tabIndex:0,"data-testid":g,children:[e,b]}),N&&s!==null&&m!==null&&p!==null&&T.jsx(Y,{actions:i[s].actions||[],closeMenu:this.handleCloseSubMenu,top:m,left:p,updatePosition:(S,R)=>{this.setState({subMenuTop:S,subMenuLeft:R})},subMenuParentWidth:M,subMenuParentHeight:y},`sub-${s}`)]})}};let U=Y;h(U,"defaultProps",{subMenuParentWidth:0,subMenuParentHeight:0,closeMenu(){},onMenuOpened(){},onMenuClosed(){},options:{},menuStyle:{},"data-testid":void 0});const Ee=U;class Fe extends v.Component{constructor(e){super(e);h(this,"container");h(this,"openMenu");this.handleMenuClose=this.handleMenuClose.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.container=P.createRef(),this.openMenu=P.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(!D.isContextActionEvent(e)||!this.container.current||e.metaKey||e.ctrlKey)return;const n=D.getMenuItems(e.contextActions),r=this.container.current.getBoundingClientRect(),s=e.clientY-r.top,o=e.clientX-r.left;if(n.length===0){if(e.target===this.container.current){e.preventDefault(),this.setState({actions:null},()=>{const a=document.elementFromPoint(o,s),i=new MouseEvent("contextmenu",{clientX:e.clientX,clientY:e.clientY,bubbles:!0,cancelable:!0});a==null||a.dispatchEvent(i)});return}return}e.preventDefault(),this.setState({actions:n,top:s,left:o})}handleMenuClose(e){e===this.openMenu.current&&this.setState({actions:null})}render(){let e=null;const{"data-testid":n}=this.props,{actions:r,top:s,left:o}=this.state;return r&&(e=T.jsx(Ee,{ref:this.openMenu,actions:r,onMenuClosed:this.handleMenuClose,top:s,left:o,updatePosition:(a,i)=>{this.setState({top:a,left:i})},"data-testid":n})),T.jsx("div",{className:j("context-menu-root",{active:r}),ref:this.container,children:e})}}const We=Fe;function ne(){return z(fe,"No API available in useApi. Was code wrapped in ApiBootstrap or ApiContext.Provider?")}function Ce(f,t){const e=ne(),n=v.useMemo(()=>new e.CoreClient(f,t),[e,f,t]);return v.useEffect(()=>()=>{n.disconnect()},[n]),n}const re=v.createContext(null);function Ue({serverUrl:f,options:t,children:e}){const n=Ce(f,t);return T.jsx(re.Provider,{value:n,children:e})}function Ne(){return z(re,"No Client available in useClient. Was code wrapped in ClientBootstrap or ClientContext.Provider?")}class K{static isValid(t,e){return!0}static isSameFormat(t,e){throw new Error("isSameFormat not implemented")}static makeFormat(t,e,n){return{label:t,formatString:e,type:n}}format(t,e){return""}}h(K,"TYPE_GLOBAL","type-global"),h(K,"TYPE_CONTEXT_PRESET","type-context-preset"),h(K,"TYPE_CONTEXT_CUSTOM","type-context-custom");const F=K;class be extends F{format(t){switch(t){case 1:case!0:return"true";case 0:case!1:return"false";default:return""}}}const Ie=be;class we extends F{format(t){return String.fromCharCode(t)}}const ve=we,ee=V.module("DateTimeColumnFormatter"),x=class extends F{constructor(e,{timeZone:n="",showTimeZone:r=!0,showTSeparator:s=!1,defaultDateTimeFormatString:o=x.DEFAULT_DATETIME_FORMAT_STRING}={}){super();h(this,"dh");h(this,"dhTimeZone");h(this,"defaultDateTimeFormatString");h(this,"showTimeZone");h(this,"showTSeparator");h(this,"formatStringMap");const a=n||x.DEFAULT_TIME_ZONE_ID;try{this.dhTimeZone=e.i18n.TimeZone.getTimeZone(a)}catch{ee.error("Unsupported time zone id",a),this.dhTimeZone=e.i18n.TimeZone.getTimeZone(x.DEFAULT_TIME_ZONE_ID)}this.dh=e,this.defaultDateTimeFormatString=o,this.showTimeZone=r,this.showTSeparator=s,this.formatStringMap=x.makeFormatStringMap(r,s)}static isValid(e,n){try{return e.i18n.DateTimeFormat.format(n.formatString,new Date),!0}catch{return!1}}static makeFormat(e,n,r=F.TYPE_CONTEXT_PRESET){return{label:e,formatString:n,type:r}}static isSameFormat(e,n){return e===n||e!==null&&n!==null&&e.type===n.type&&e.formatString===n.formatString}static makeGlobalFormatStringMap(e,n){const r=n?"'T'":" ",s=e?" z":"";return new Map([["yyyy-MM-dd HH:mm:ss",`yyyy-MM-dd${r}HH:mm:ss${s}`],["yyyy-MM-dd HH:mm:ss.SSS",`yyyy-MM-dd${r}HH:mm:ss.SSS${s}`],["yyyy-MM-dd HH:mm:ss.SSSSSSSSS",`yyyy-MM-dd${r}HH:mm:ss.SSSSSSSSS${s}`]])}static getGlobalFormats(e,n){return[...x.makeGlobalFormatStringMap(e,n).keys()]}static makeFormatStringMap(e,n){const r=n!==void 0&&n?"'T'":" ",s=e!==void 0&&e?" z":"";return new Map([["yyyy-MM-dd",`yyyy-MM-dd${s}`],["MM-dd-yyyy",`MM-dd-yyyy${s}`],["HH:mm:ss",`HH:mm:ss${s}`],["HH:mm:ss.SSS",`HH:mm:ss.SSS${s}`],["HH:mm:ss.SSSSSSSSS",`HH:mm:ss.SSSSSSSSS${s}`],["yyyy-MM-dd HH:mm:ss",`yyyy-MM-dd${r}HH:mm:ss${s}`],["yyyy-MM-dd HH:mm:ss.SSS",`yyyy-MM-dd${r}HH:mm:ss.SSS${s}`],["yyyy-MM-dd HH:mm:ss.SSSSSSSSS",`yyyy-MM-dd${r}HH:mm:ss.SSSSSSSSS${s}`]])}static getFormats(e,n){return[...x.makeFormatStringMap(e,n).keys()]}getEffectiveFormatString(e){return this.formatStringMap.get(e)??e}format(e,n={}){const r=n.formatString!=null&&n.formatString!==""?n.formatString:this.defaultDateTimeFormatString,s=this.getEffectiveFormatString(r);try{return this.dh.i18n.DateTimeFormat.format(s,e,this.dhTimeZone)}catch{ee.error("Invalid format arguments")}return""}};let H=x;h(H,"DEFAULT_DATETIME_FORMAT_STRING","yyyy-MM-dd HH:mm:ss.SSS"),h(H,"DEFAULT_TIME_ZONE_ID","America/New_York");const ke=V.module("DecimalColumnFormatter"),I=class extends F{constructor(e,{defaultFormatString:n=I.DEFAULT_FORMAT_STRING}={}){super();h(this,"defaultFormatString");h(this,"dh");this.dh=e,this.defaultFormatString=n}static isValid(e,n){try{return e.i18n.NumberFormat.format(n.formatString,0),!0}catch{return!1}}static makeFormat(e,n,r=F.TYPE_CONTEXT_PRESET,s){return{label:e,type:r,formatString:n,multiplier:s}}static makePresetFormat(e,n="",r){return I.makeFormat(e,n,F.TYPE_CONTEXT_PRESET,r)}static makeCustomFormat(e="",n){return I.makeFormat("Custom Format",e,F.TYPE_CONTEXT_CUSTOM,n)}static isSameFormat(e,n){return e===n||e!=null&&n!=null&&e.type===n.type&&e.formatString===n.formatString&&e.multiplier===n.multiplier}format(e,n={}){const r=n.formatString!=null&&n.formatString!==""?n.formatString:this.defaultFormatString,s=n.multiplier!=null&&n.multiplier!==0?e*n.multiplier:e;try{return this.dh.i18n.NumberFormat.format(r,s)}catch{ke.error("Invalid format arguments")}return""}};let w=I;h(w,"DEFAULT_FORMAT_STRING","###,##0.0000"),h(w,"FORMAT_PERCENT",I.makePresetFormat("Percent","##0.00%")),h(w,"FORMAT_BASIS_POINTS",I.makePresetFormat("Basis Points","###,##0 bp",1e4)),h(w,"FORMAT_MILLIONS",I.makePresetFormat("Millions","###,##0.000 mm",1e-6)),h(w,"FORMAT_SCIENTIFIC_NOTATION",I.makePresetFormat("Scientific Notation","0.0000E0")),h(w,"FORMAT_ROUND",I.makePresetFormat("Round","###,##0")),h(w,"FORMAT_ROUND_TWO_DECIMALS",I.makePresetFormat("0.00","###,##0.00")),h(w,"FORMAT_ROUND_FOUR_DECIMALS",I.makePresetFormat("0.0000","###,##0.0000"));class xe extends F{format(t){return`${t}`}}const De=xe,Ae=V.module("IntegerColumnFormatter"),O=class extends F{constructor(e,{defaultFormatString:n=O.DEFAULT_FORMAT_STRING}={}){super();h(this,"dh");h(this,"defaultFormatString");this.dh=e,this.defaultFormatString=n}static isValid(e,n){try{return e.i18n.NumberFormat.format(n.formatString,0),!0}catch{return!1}}static makeFormat(e,n,r=F.TYPE_CONTEXT_PRESET,s){return{label:e,type:r,formatString:n,multiplier:s}}static makePresetFormat(e,n="",r){return O.makeFormat(e,n,F.TYPE_CONTEXT_PRESET,r)}static makeCustomFormat(e="",n){return O.makeFormat("Custom Format",e,F.TYPE_CONTEXT_CUSTOM,n)}static isSameFormat(e,n){return e===n||e!=null&&n!=null&&e.type===n.type&&e.formatString===n.formatString&&e.multiplier===n.multiplier}format(e,n={}){const r=n.formatString!=null&&n.formatString!==""?n.formatString:this.defaultFormatString,s=n.multiplier!=null&&n.multiplier!==0?e*n.multiplier:e;try{return this.dh.i18n.NumberFormat.format(r,s)}catch{Ae.error("Invalid format arguments")}return""}};let L=O;h(L,"DEFAULT_FORMAT_STRING","###,##0"),h(L,"FORMAT_MILLIONS",O.makePresetFormat("Millions","###,##0.000 mm",1e-6)),h(L,"FORMAT_SCIENTIFIC_NOTATION",O.makePresetFormat("Scientific Notation","0.0000E0"));class Oe extends F{format(t){return t}}const C=class{static makeDateWrapper(t,e,n,r=0,s=1,o=0,a=0,i=0,l=0){if(!e)throw new Error("No timezone provided");const u=`${n}`.padStart(4,"0"),m=`${r+1}`.padStart(2,"0"),p=`${s}`.padStart(2,"0"),M=`${o}`.padStart(2,"0"),y=`${a}`.padStart(2,"0"),b=`${i}`.padStart(2,"0"),$=`${l}`.padStart(9,"0"),g=`${u}-${m}-${p} ${M}:${y}:${b}.${$}`;return t.i18n.DateTimeFormat.parse(C.FULL_DATE_FORMAT,g,t.i18n.TimeZone.getTimeZone(e))}static getNextNanos(t){const e=parseInt(t,10),n="0".repeat(9-t.length),r=`${e+1}${n}`;return parseInt(r,10)}static getNextDate(t,e,n,r){let{year:s,month:o,date:a,hours:i,minutes:l,seconds:u,nanos:m}=n;if(e.nanos!=null){if(e.nanos.length===9)return null;m=C.getNextNanos(e.nanos),m>999999999&&(u+=1,m=0)}else e.seconds!=null?u+=1:e.minutes!=null?l+=1:e.hours!=null?i+=1:e.date!=null?a+=1:e.month!=null?o+=1:s+=1;const p=new Date(s,o,a,i,l,u);return C.makeDateWrapper(t,r,p.getFullYear(),p.getMonth(),p.getDate(),p.getHours(),p.getMinutes(),p.getSeconds(),m)}static parseMonth(t){const e=parseInt(t,10);if(!Number.isNaN(e))return e>=1&&e<=12?e-1:NaN;const n=t.trim().toLowerCase();if(n.length>=3){for(let r=0;r<C.months.length;r+=1)if(C.months[r].startsWith(n))return r}return NaN}static parseDateValues(t,e,n,r,s,o,a){const i=parseInt(t,10),l=e!=null?this.parseMonth(e):0,u=n!=null?parseInt(n,10):1,m=r!=null?parseInt(r,10):0,p=s!=null?parseInt(s,10):0,M=o!=null?parseInt(o,10):0,y=a!=null?parseInt(a.padEnd(9,"0"),10):0;return Number.isNaN(i)||Number.isNaN(l)||Number.isNaN(u)||Number.isNaN(m)||Number.isNaN(p)||Number.isNaN(M)||Number.isNaN(y)?null:{year:i,month:l,date:u,hours:m,minutes:p,seconds:M,nanos:y}}static parseDateTimeString(t){const n=/\s*(\d{4})([-./]([\da-z]+))?([-./](\d{1,2}))?([tT\s](\d{2})([:](\d{2}))?([:](\d{2}))?([.](\d{1,9}))?)?(.*)/.exec(t);if(n==null)throw new Error(`Unexpected date string: ${t}`);const[,r,,s,,o,,a,,i,,l,,u,m]=n;if(m!=null&&m.length>0)throw new Error(`Unexpected characters after date string '${t}': ${m}`);return{year:r,month:s,date:o,hours:a,minutes:i,seconds:l,nanos:u}}static parseDateRange(t,e,n){const r=e.trim().toLowerCase();if(r.length===0)throw new Error("Cannot parse date range from empty string");if(r==="null")return[null,null];if(r==="today"){const l=new Date(Date.now()),u=C.makeDateWrapper(t,n,l.getFullYear(),l.getMonth(),l.getDate()),m=C.makeDateWrapper(t,n,l.getFullYear(),l.getMonth(),l.getDate()+1);return[u,m]}if(r==="yesterday"){const l=new Date(Date.now()),u=C.makeDateWrapper(t,n,l.getFullYear(),l.getMonth(),l.getDate()-1),m=C.makeDateWrapper(t,n,l.getFullYear(),l.getMonth(),l.getDate());return[u,m]}if(r==="now"){const l=new Date(Date.now());return[t.DateWrapper.ofJsDate(l),null]}const s=C.parseDateTimeString(r);if(s.year==null&&s.month==null&&s.date==null)throw new Error(`Unable to extract year, month, or day ${r}`);const o=C.parseDateValues(s.year,s.month,s.date,s.hours,s.minutes,s.seconds,s.nanos);if(o==null)throw new Error(`Unable to extract date values from ${s}`);const a=C.makeDateWrapper(t,n,o.year,o.month,o.date,o.hours,o.minutes,o.seconds,o.nanos),i=C.getNextDate(t,s,o,n);return[a,i]}static getJsDate(t){return typeof t=="number"?new Date(t):t.asDate()}};let q=C;h(q,"FULL_DATE_FORMAT","yyyy-MM-dd HH:mm:ss.SSSSSSSSS"),h(q,"months",["january","february","march","april","may","june","july","august","september","october","november","december"]);class B{}h(B,"not","not"),h(B,"and","and"),h(B,"or","or");class d{}h(d,"eq","eq"),h(d,"eqIgnoreCase","eqIgnoreCase"),h(d,"notEq","notEq"),h(d,"notEqIgnoreCase","notEqIgnoreCase"),h(d,"greaterThan","greaterThan"),h(d,"greaterThanOrEqualTo","greaterThanOrEqualTo"),h(d,"lessThan","lessThan"),h(d,"lessThanOrEqualTo","lessThanOrEqualTo"),h(d,"in","in"),h(d,"inIgnoreCase","inIgnoreCase"),h(d,"notIn","notIn"),h(d,"notInIgnoreCase","notInIgnoreCase"),h(d,"isTrue","isTrue"),h(d,"isFalse","isFalse"),h(d,"isNull","isNull"),h(d,"invoke","invoke"),h(d,"contains","contains"),h(d,"notContains","notContains"),h(d,"containsIgnoreCase","containsIgnoreCase"),h(d,"startsWith","startsWith"),h(d,"endsWith","endsWith"),h(d,"containsAny","containsAny");const k=V.module("TableUtils"),c=class{constructor(t){h(this,"dh");this.dh=t}static getSortIndex(t,e){var n;for(let r=0;r<t.length;r+=1)if(((n=t[r].column)==null?void 0:n.name)===e)return r;return null}static getSortForColumn(t,e){const n=c.getSortIndex(t,e);return n!=null?t[n]:null}static getFilterText(t){return t?t.toString():null}static getFilterTypes(t){return c.isBooleanType(t)?[d.isTrue,d.isFalse,d.isNull]:c.isCharType(t)||c.isNumberType(t)||c.isDateType(t)?[d.eq,d.notEq,d.greaterThan,d.greaterThanOrEqualTo,d.lessThan,d.lessThanOrEqualTo]:c.isTextType(t)?[d.eq,d.eqIgnoreCase,d.notEq,d.notEqIgnoreCase,d.contains,d.notContains,d.startsWith,d.endsWith]:[]}static getNextSort(t,e,n){if(n<0||n>=t.length)return null;const r=c.getSortForColumn(e,t[n].name);return r===null?t[n].sort().asc():r.direction===c.sortDirection.ascending?r.desc():null}static makeColumnSort(t,e,n,r){if(e<0||e>=t.length||n===c.sortDirection.none)return null;let s=t[e].sort();switch(n){case c.sortDirection.ascending:s=s.asc();break;case c.sortDirection.descending:s=s.desc();break}return r&&(s=s.abs()),s}static toggleSortForColumn(t,e,n,r=!1){if(n<0||n>=e.length)return[];const s=c.getNextSort(e,t,n);return c.setSortForColumn(t,e[n].name,s,r)}static sortColumn(t,e,n,r,s,o){if(n<0||n>=e.length)return[];const a=c.makeColumnSort(e,n,r,s);return c.setSortForColumn(t,e[n].name,a,o)}static setSortForColumn(t,e,n,r=!1){const s=c.getSortIndex(t,e);let o=[];return r&&(o=o.concat(t.filter(({direction:a})=>a!==c.sortDirection.reverse)),s!==null&&o.splice(s,1)),n!==null&&o.push(n),o}static getNormalizedType(t){switch(t){case"boolean":case"java.lang.Boolean":case c.dataType.BOOLEAN:return c.dataType.BOOLEAN;case"char":case"java.lang.Character":case c.dataType.CHAR:return c.dataType.CHAR;case"java.lang.String":case c.dataType.STRING:return c.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 c.dataType.DATETIME:return c.dataType.DATETIME;case"double":case"java.lang.Double":case"float":case"java.lang.Float":case"java.math.BigDecimal":case c.dataType.DECIMAL:return c.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 c.dataType.INT:return c.dataType.INT;default:return c.dataType.UNKNOWN}}static isLongType(t){switch(t){case"long":case"java.lang.Long":return!0;default:return!1}}static isDateType(t){switch(t){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(t){return c.isIntegerType(t)||c.isDecimalType(t)}static isIntegerType(t){switch(t){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(t){switch(t){case"double":case"java.lang.Double":case"java.math.BigDecimal":case"float":case"java.lang.Float":return!0;default:return!1}}static isBigDecimalType(t){switch(t){case"java.math.BigDecimal":return!0;default:return!1}}static isBigIntegerType(t){switch(t){case"java.math.BigInteger":return!0;default:return!1}}static isBooleanType(t){switch(t){case"boolean":case"java.lang.Boolean":return!0;default:return!1}}static isCharType(t){switch(t){case"char":case"java.lang.Character":return!0;default:return!1}}static isStringType(t){switch(t){case"java.lang.String":return!0;default:return!1}}static isTextType(t){return this.isStringType(t)||this.isCharType(t)}static getBaseType(t){return t.split("[]")[0]}static isCompatibleType(t,e){return c.getNormalizedType(t)===c.getNormalizedType(e)}static quoteValue(t){return t.length>=2&&(t.charAt(0)==='"'&&t.charAt(t.length-1)==='"'||t.charAt(0)==="'"&&t.charAt(t.length-1)==="'")?t:`"${t}"`}static isRangeOperation(t){switch(t){case"<":case"<=":case"=<":case">":case">=":case"=>":return!0;default:return!1}}static makeRangeFilterWithOperation(t,e,n){switch(e){case"=":return t.eq(n);case"<":return t.lessThan(n);case"<=":case"=<":return t.lessThanOrEqualTo(n);case">":return t.greaterThan(n);case">=":case"=>":return t.greaterThanOrEqualTo(n);case"!=":case"!":return t.notEq(n);default:return null}}static makeCancelableTablePromise(t){return Q.makeCancelable(t,e=>{e.close()})}static makeCancelableTableEventPromise(t,e,n=0,r=null){let s,o,a=!0;const i=new Promise((l,u)=>{o=setTimeout(()=>{s(),a=!1,u(new te(`Event "${e}" timed out.`))},n),s=t.addEventListener(e,m=>{if(r!=null&&!r(m)){k.debug2("Event triggered, but matcher returned false.");return}k.debug2("Event triggered, resolving."),s(),clearTimeout(o),a=!1,l(m)})});return i.cancel=()=>{if(a){k.debug2("Pending promise cleanup."),s(),clearTimeout(o),a=!1;return}k.debug2("Ignoring non-pending promise cancel.")},i}static removeCommas(t){return t.replace(/[\s|,]/g,"")}static makeBooleanValue(t,e=!1){if(t===""&&e)return null;switch(t==null?void 0:t.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 '${t}'`)}}static makeNumberValue(t){if(t==="null"||t==="")return null;const e=t.toLowerCase().trim();if(e==="∞"||e==="infinity"||e==="inf")return Number.POSITIVE_INFINITY;if(e==="-∞"||e==="-infinity"||e==="-inf")return Number.NEGATIVE_INFINITY;const n=c.removeCommas(e);if(c.NUMBER_REGEX.test(n))return parseFloat(n);throw new Error(`Invalid number '${t}'`)}static getFilterOperatorString(t){switch(t){case d.eq:return"=";case d.notEq:return"!=";case d.greaterThan:return">";case d.greaterThanOrEqualTo:return">=";case d.lessThan:return"<";case d.lessThanOrEqualTo:return"<=";case d.contains:return"~";case d.notContains:return"!~";default:throw new Error(`Unexpected filter type ${t}`)}}static isTreeTable(t){return t!=null&&t.expand!==void 0&&t.collapse!==void 0}static sortColumns(t,e=!0){return[...t].sort((n,r)=>{const s=n.name.toUpperCase(),o=r.name.toUpperCase();return Se.sort(s,o,e)})}makeQuickFilter(t,e,n){const r=e.split("||");let s=null;for(let o=0;o<r.length;o+=1){const i=r[o].split("&&");let l=null;for(let u=0;u<i.length;u+=1){const m=i[u].trim();if(m.length>0){const p=this.makeQuickFilterFromComponent(t,m,n);if(p)l?l=l.and(p):l=p;else throw new Error(`Unable to parse quick filter from text ${e}`)}}s&&l?s=s.or(l):s=l}return s}makeQuickFilterFromComponent(t,e,n){const{type:r}=t;return c.isNumberType(r)?this.makeQuickNumberFilter(t,e):c.isBooleanType(r)?this.makeQuickBooleanFilter(t,e):n!=null&&c.isDateType(r)?this.makeQuickDateFilter(t,e,n):c.isCharType(r)?this.makeQuickCharFilter(t,e):this.makeQuickTextFilter(t,e)}makeQuickNumberFilter(t,e){const n=t.filter(),{dh:r}=this;let s=null;const a=/\s*(>=|<=|=>|=<|>|<|!=|=|!)?(\s*-\s*)?(\s*\d*(?:,\d{3})*(?:\.\d*)?\s*)?(null|nan|infinity|inf|\u221E)?(.*)/i.exec(e);let i=null,l=null,u=null,m=null,p=null;if(a!==null&&a.length>3&&([,i,l,u,m,p]=a),p!=null&&p.trim().length>0)return null;if(i==null&&(i="="),m!=null){if(!(i==="="||i==="!"||i==="!="))return null;switch(m=m.trim().toLowerCase(),m){case"null":s=n.isNull();break;case"nan":s=r.FilterCondition.invoke("isNaN",n);break;case"infinity":case"inf":case"∞":l!=null?s=r.FilterCondition.invoke("isInf",n).and(n.lessThan(r.FilterValue.ofNumber(0))):s=r.FilterCondition.invoke("isInf",n).and(n.greaterThan(r.FilterValue.ofNumber(0)));break}return s!==null&&(i==="!"||i==="!=")&&(s=s.not()),s}if(u==null)return null;if(u=c.removeCommas(u),c.isLongType(t.type))try{u=r.FilterValue.ofNumber(r.LongWrapper.ofString(`${l!=null?"-":""}${u}`))}catch(M){return k.warn("Unable to create long filter",M),null}else{if(u=parseFloat(u),u==null||Number.isNaN(u))return null;u=r.FilterValue.ofNumber(l!=null?0-u:u)}return s=t.filter(),c.makeRangeFilterWithOperation(s,i,u)}makeQuickTextFilter(t,e){const{dh:n}=this,r=`${e}`.trim(),o=/^(!~|!=|~|=|!)?(.*)/.exec(r);let a=null,i=null;if(o!==null&&o.length>2&&([,a,i]=o,i!=null&&(i=i.trim())),i==null||i.length===0)return null;a==null&&(a="=");const l=t.filter();if(i.toLowerCase()==="null")switch(a){case"=":return l.isNull();case"!=":case"!":return l.isNull().not()}let u=null,m=null;switch(i.startsWith("*")?(u="*",i=i.substring(1)):i.endsWith("*")&&!i.endsWith("\\*")&&(m="*",i=i.substring(0,i.length-1)),i=i.replace("\\",""),a){case"~":return l.isNull().not().and(l.invoke("matches",n.FilterValue.ofString(`(?s)(?i).*\\Q${i}\\E.*`)));case"!~":return l.isNull().or(l.invoke("matches",n.FilterValue.ofString(`(?s)(?i).*\\Q${i}\\E.*`)).not());case"!=":return u==="*"?l.isNull().or(l.invoke("matches",n.FilterValue.ofString(`(?s)(?i).*\\Q${i}\\E$`)).not()):m==="*"?l.isNull().or(l.invoke("matches",n.FilterValue.ofString(`(?s)(?i)^\\Q${i}\\E.*`)).not()):l.notEqIgnoreCase(n.FilterValue.ofString(i.toLowerCase()));case"=":return u==="*"?l.isNull().not().and(l.invoke("matches",n.FilterValue.ofString(`(?s)(?i).*\\Q${i}\\E$`))):m==="*"?l.isNull().not().and(l.invoke("matches",n.FilterValue.ofString(`(?s)(?i)^\\Q${i}\\E.*`))):l.eqIgnoreCase(n.FilterValue.ofString(i.toLowerCase()))}return null}makeQuickBooleanFilter(t,e){const r=/^(!=|=|!)?(.*)/.exec(`${e}`.trim());if(r===null)return null;const[,s,o]=r,a=s==="!"||s==="!=",i=o.trim().toLowerCase();let l=t.filter();try{const u=c.makeBooleanValue(i);return u!=null&&u?l=l.isTrue():u===null?l=l.isNull():l=l.isFalse(),a?l.not():l}catch{return null}}makeQuickDateFilter(t,e,n){const r=e.trim(),o=/\s*(>=|<=|=>|=<|>|<|!=|!|=)?(.*)/.exec(r);if(o==null||o.length<=2)throw new Error(`Unable to parse date filter: ${e}`);let a=null,i=null;[,a,i]=o;let l=d.eq;switch(a){case"<":l=d.lessThan;break;case"<=":case"=<":l=d.lessThanOrEqualTo;break;case">":l=d.greaterThan;break;case">=":case"=>":l=d.greaterThanOrEqualTo;break;case"!=":case"!":l=d.notEq;break;case"=":case"==":default:l=d.eq;break}return this.makeQuickDateFilterWithOperation(t,i,l,n)}makeQuickDateFilterWithOperation(t,e,n,r){const{dh:s}=this,[o,a]=q.parseDateRange(s,e,r),i=o!=null?s.FilterValue.ofNumber(o):null,l=a!=null?s.FilterValue.ofNumber(a):null,u=t.filter();if(i==null)return n===d.notEq?u.isNull().not():u.isNull();switch(n){case d.eq:{if(l!=null){const m=u.greaterThanOrEqualTo(i),p=u.lessThan(l);return m.and(p)}return u.eq(i)}case d.lessThan:return u.lessThan(i);case d.lessThanOrEqualTo:return l!=null?u.lessThan(l):u.lessThanOrEqualTo(i);case d.greaterThan:return l!=null?u.greaterThanOrEqualTo(l):u.greaterThan(i);case d.greaterThanOrEqualTo:return u.greaterThanOrEqualTo(i);case d.notEq:{if(l!=null){const m=u.lessThan(i),p=u.greaterThanOrEqualTo(l);return m.or(p)}return u.notEq(i)}default:throw new Error(`Invalid operator: ${n}`)}}makeQuickCharFilter(t,e){const{dh:n}=this,r=`${e}`.trim(),o=/^(>=|<=|=>|=<|>|<|!=|=|!)?(null|"."|'.'|.)?(.*)/.exec(r);let a=null,i=null,l=null;if(o!==null&&o.length>3&&([,a,i,l]=o),l!=null&&l.trim().length>0||i==null||i.length===0)return null;a==null&&(a="=");const u=t.filter();if(i.toLowerCase()==="null")switch(a){case"=":return u.isNull();case"!=":case"!":return u.isNull().not();default:return null}const m=n.FilterValue.ofString(c.isRangeOperation(a)?c.quoteValue(i):i);return c.makeRangeFilterWithOperation(u,a,m)}makeAdvancedFilter(t,e,n){const{filterItems:r,filterOperators:s,invertSelection:o,selectedValues:a}=e;let i=null;for(let u=0;u<r.length;u+=1){const m=r[u],{selectedType:p,value:M}=m;if(p!=null&&p.length>0&&M!=null&&M.length>0)try{const y=this.makeAdvancedValueFilter(t,p,M,n);if(y!=null){if(u===0)i=y;else if(i!==null&&u-1<s.length){const b=s[u-1];if(b===B.and)i=i.and(y);else if(b===B.or)i=i.or(y);else{k.error("Unexpected filter operator",b,y),i=null;break}}}else k.debug2("Empty filter ignored for",p,M)}catch(y){k.error("Unable to create filter",y),i=null;break}}const l=this.makeSelectValueFilter(t,a,o);return l!=null&&(i!=null?i=i.and(l):i=l),i}makeAdvancedValueFilter(t,e,n,r){const{dh:s}=this;if(c.isDateType(t.type))return this.makeQuickDateFilterWithOperation(t,n,e,r);if(c.isNumberType(t.type)||c.isCharType(t.type))return this.makeQuickFilter(t,`${c.getFilterOperatorString(e)}${n}`);const o=this.makeFilterValue(t.type,n),a=t.filter();switch(e){case d.eq:return a.eq(o);case d.eqIgnoreCase:return a.eqIgnoreCase(o);case d.notEq:return a.notEq(o);case d.notEqIgnoreCase:return a.notEqIgnoreCase(o);case d.greaterThan:return a.greaterThan(o);case d.greaterThanOrEqualTo:return a.greaterThanOrEqualTo(o);case d.lessThan:return a.lessThan(o);case d.lessThanOrEqualTo:return a.lessThanOrEqualTo(o);case d.isTrue:return a.isTrue();case d.isFalse:return a.isFalse();case d.isNull:return a.isNull();case d.contains:return a.isNull().not().and(a.invoke("matches",s.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E.*`)));case d.notContains:return a.isNull().or(a.invoke("matches",s.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E.*`)).not());case d.startsWith:return a.isNull().not().and(a.invoke("matches",s.FilterValue.ofString(`(?s)(?i)^\\Q${n}\\E.*`)));case d.endsWith:return a.isNull().not().and(a.invoke("matches",s.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E$`)));case d.in:case d.inIgnoreCase:case d.notIn:case d.notInIgnoreCase:case d.invoke:default:throw new Error(`Unexpected filter operation: ${e}`)}}async applyNeverFilter(t,e,n=c.APPLY_TABLE_CHANGE_TIMEOUT_MS){if(t==null)return null;const r=t.findColumn(e),s=[this.makeNeverFilter(r)];return await this.applyFilter(t,s,n),t}async applyCustomColumns(t,e,n=c.APPLY_TABLE_CHANGE_TIMEOUT_MS){const{dh:r}=this;return c.executeAndWaitForEvent(s=>s==null?void 0:s.applyCustomColumns(e),t,r.Table.EVENT_CUSTOMCOLUMNSCHANGED,n)}async applyFilter(t,e,n=c.APPLY_TABLE_CHANGE_TIMEOUT_MS){const{dh:r}=this;return c.executeAndWaitForEvent(s=>s==null?void 0:s.applyFilter(e),t,r.Table.EVENT_FILTERCHANGED,n)}async applySort(t,e,n=c.APPLY_TABLE_CHANGE_TIMEOUT_MS){const{dh:r}=this;return c.executeAndWaitForEvent(s=>s==null?void 0:s.applySort(e),t,r.Table.EVENT_SORTCHANGED,n)}makeNeverFilter(t){const{dh:e}=this;let n=null;c.isTextType(t.type)?n=e.FilterValue.ofString("a"):c.isBooleanType(t.type)?n=e.FilterValue.ofBoolean(!0):c.isDateType(t.type)?n=e.FilterValue.ofNumber(e.DateWrapper.ofJsDate(new Date)):n=e.FilterValue.ofNumber(0);const r=t.filter().eq(n),s=t.filter().notEq(n);return r.and(s)}makeFilterValue(t,e){const{dh:n}=this,r=c.getBaseType(t);return c.isTextType(r)?n.FilterValue.ofString(e):c.isLongType(r)?n.FilterValue.ofNumber(n.LongWrapper.ofString(c.removeCommas(e))):n.FilterValue.ofNumber(c.removeCommas(e))}makeFilterRawValue(t,e){const{dh:n}=this;return c.isTextType(t)?n.FilterValue.ofString(e):c.isBooleanType(t)?n.FilterValue.ofBoolean(e):n.FilterValue.ofNumber(e)}makeValue(t,e,n){const{dh:r}=this;if(e==="null")return null;if(c.isTextType(t))return e;if(c.isLongType(t))return r.LongWrapper.ofString(c.removeCommas(e));if(c.isBooleanType(t))return c.makeBooleanValue(e,!0);if(c.isDateType(t)){const[s]=q.parseDateRange(r,e,n);return s}return c.isNumberType(t)?c.makeNumberValue(e):(k.error("Unexpected column type",t),null)}makeSelectValueFilter(t,e,n){const{dh:r}=this;if(e.length===0)return n?null:this.makeNeverFilter(t);const s=[];let o=!1;for(let a=0;a<e.length;a+=1){const i=e[a];i==null?o=!0:c.isTextType(t.type)?s.push(r.FilterValue.ofString(typeof i=="number"?String.fromCharCode(i):i)):c.isBooleanType(t.type)?s.push(r.FilterValue.ofBoolean(!!i)):s.push(r.FilterValue.ofNumber(i))}return o?s.length>0?n?t.filter().isNull().not().and(t.filter().notIn(s)):t.filter().isNull().or(t.filter().in(s)):n?t.filter().isNull().not():t.filter().isNull():n?t.filter().notIn(s):t.filter().in(s)}};let E=c;h(E,"dataType",{BOOLEAN:"boolean",CHAR:"char",DATETIME:"datetime",DECIMAL:"decimal",INT:"int",STRING:"string",UNKNOWN:"unknown"}),h(E,"sortDirection",{ascending:"ASC",descending:"DESC",reverse:"REVERSE",none:null}),h(E,"APPLY_TABLE_CHANGE_TIMEOUT_MS",3e4),h(E,"REVERSE_TYPE",Object.freeze({NONE:"none",PRE_SORT:"pre-sort",POST_SORT:"post-sort"})),h(E,"NUMBER_REGEX",/^-?\d+(\.\d+)?$/),h(E,"executeAndWaitForEvent",async(t,e,n,r=c.APPLY_TABLE_CHANGE_TIMEOUT_MS)=>{if(e==null)return null;const s=c.makeCancelableTableEventPromise(e,n,r);return t(e),await s,e});class se{constructor(t,e=[],n,r,s,o=!1){h(this,"defaultColumnFormatter");h(this,"typeFormatterMap");h(this,"columnFormatMap");h(this,"truncateNumbersWithPound");this.defaultColumnFormatter=new De,this.typeFormatterMap=new Map([[E.dataType.BOOLEAN,new Ie],[E.dataType.CHAR,new ve],[E.dataType.DATETIME,new H(t,n)],[E.dataType.DECIMAL,new w(t,r)],[E.dataType.INT,new L(t,s)],[E.dataType.STRING,new Oe]]),this.columnFormatMap=se.makeColumnFormatMap(e),this.truncateNumbersWithPound=o}static makeColumnFormatMap(t){return t==null?new Map:t.reduce((e,n)=>{const r=E.getNormalizedType(n.columnType);if(r===null)return e;e.has(r)||e.set(r,new Map);const s=e.get(r);return s==null||s.set(n.columnName,n.format),e},new Map)}static makeColumnFormattingRule(t,e,n){return{columnType:t,columnName:e,format:n}}getColumnFormatMapForType(t,e=!1){const n=E.getNormalizedType(t);if(n!==null)return e&&!this.columnFormatMap.has(n)&&this.columnFormatMap.set(n,new Map),this.columnFormatMap.get(n)}getColumnFormat(t,e){const n=this.getColumnFormatMapForType(t);return(n==null?void 0:n.get(e))??null}getColumnTypeFormatter(t){const e=E.getNormalizedType(t);let n=this.defaultColumnFormatter;return e&&(n=this.typeFormatterMap.get(e)??n),n}getFormattedString(t,e,n="",r){if(t==null)return"";const s=this.getColumnTypeFormatter(e),o=r||this.getColumnFormat(e,n);return s.format(t,o??void 0)}get timeZone(){var e;const t=this.typeFormatterMap.get(E.dataType.DATETIME);return(e=t==null?void 0:t.dhTimeZone)==null?void 0:e.id}}function Pe(f){if(f&&f.formatter){const{formatter:t}=f;return t}}function $e(f){return{timeZone:f==null?void 0:f.timeZone,defaultDateTimeFormatString:f==null?void 0:f.defaultDateTimeFormat,showTimeZone:f==null?void 0:f.showTimeZone,showTSeparator:f==null?void 0:f.showTSeparator}}function Re(f,t,e){const n=f.getColumnFormat(e,t);return n!=null&&(n.type===F.TYPE_CONTEXT_PRESET||n.type===F.TYPE_CONTEXT_CUSTOM)}const Ke={getColumnFormats:Pe,getDateTimeFormatterOptions:$e,isCustomColumnFormatDefined:Re},Le=V.module("@deephaven/jsapi-components.ConnectionBootstrap"),ae=v.createContext(null);function Ye({children:f}){const t=ne(),e=Ne(),[n,r]=v.useState(),[s,o]=v.useState();return v.useEffect(function(){let i=!1;async function l(){try{const u=await e.getAsIdeConnection();if(i)return;o(u)}catch(u){if(i)return;r(u)}}return l(),()=>{i=!0}},[t,e]),v.useEffect(function(){if(s==null)return;function i(u){const{detail:m}=u;Le.info("Shutdown",`${JSON.stringify(m)}`),r(`Server shutdown: ${m??"Unknown reason"}`)}return s.addEventListener(t.IdeConnection.EVENT_SHUTDOWN,i)},[t,s]),s==null||n!=null?T.jsx(pe,{"data-testid":"connection-bootstrap-loading",isLoading:s==null,errorMessage:n!=null?`${n}`:void 0}):T.jsx(ae.Provider,{value:s,children:f})}function Ge(){return z(ae,"No IdeConnection available in useConnection. Was code wrapped in ConnectionBootstrap or ConnectionContext.Provider?")}export{Ie as B,We as C,q as D,Ke as F,L as I,Q as P,Oe as S,E as T,je as a,se as b,ne as c,z as d,D as e,ye as f,Ue as g,re as h,Be as i,Ne as j,te as k,ve as l,H as m,w as n,De as o,F as p,Pe as q,$e as r,Re as s,J as t,Ge as u,Ye as v,ae as w};
2
- //# sourceMappingURL=useConnection-e2008d76.js.map
1
+ var ce=Object.defineProperty;var de=(f,t,e)=>t in f?ce(f,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):f[t]=e;var h=(f,t,e)=>(de(f,typeof t!="symbol"?t+"":t,e),e);import{r as v,G as P,C as T,E as j,F as Z}from"./vendor-f479e584.js";import{q as he,L as V,w as me,x as fe,b as pe}from"./index-0b100882.js";function z(f,t="No value available in context. Was code wrapped in a provider?"){const e=v.useContext(f);if(e==null)throw new Error(t);return e}class ge extends Error{constructor(){super(...arguments);h(this,"isCanceled",!0)}}const J=ge;class Te extends Error{constructor(){super(...arguments);h(this,"isTimeout",!0)}}const te=Te;class Q{static makeCancelable(t,e){let n=!1,r,s;const o=new Promise((a,i)=>{s=i,Promise.resolve(t).then(l=>{n?e&&e(l):(r=l,a(l))}).catch(l=>i(l))});return o.cancel=()=>{n=!0,s(new J),r!=null&&e&&e(r)},o}static isCanceled(t){return t instanceof J}static isTimedOut(t){return t instanceof te}static withTimeout(t,e){return new Promise((n,r)=>{setTimeout(()=>{try{n(e())}catch(s){r(s)}},t)})}}function je(f){if(f==null)throw new Error("Value is null or undefined")}class Me{static join(t,e="and"){if(t==null||t.length===0)return"";if(t.length===1)return t[0];if(t.length===2)return`${t[0]} ${e} ${t[1]}`;const n=t.slice(0,t.length-1).join(", "),r=t[t.length-1];return`${n}, ${e} ${r}`}static toLower(t,e=!0){if(t==null){if(e)return"";throw new Error("Null string passed in to TextUtils.toLower")}return t.toLowerCase()}static sort(t,e,n=!0){return t<e?n?-1:1:t>e?n?1:-1:0}}const Se=Me;function Be(f){return f.then!==void 0}const A=class{static disableAllActions(){A.actionsDisabled=!0}static enableAllActions(){A.actionsDisabled=!1}static isContextActionEvent(t){return Array.isArray(t.contextActions)}static compareActions(t,e){return t.group!==e.group?(t.group??0)>(e.group??0)?1:-1:t.order!==e.order?(t.order??0)>(e.order??0)?1:-1:t.title!==e.title?(t.title??"")>(e.title??"")?1:-1:t!==e?t>e?1:-1:0}static sortActions(t){if(t==null||!Array.isArray(t))return[];const e=t.slice();return e.sort(A.compareActions),e}static isMacPlatform(){const{platform:t}=window.navigator;return t.startsWith("Mac")}static getModifierKey(){return A.isMacPlatform()?"metaKey":"ctrlKey"}static isModifierKeyDown(t){const e=A.getModifierKey();return t[e]}static getMenuItems(t,e=!0){let n=[],r=t;Array.isArray(r)||(r=[r]);for(let s=0;s<r.length;s+=1){const o=r[s];let a;typeof o=="function"?a=o():a=o,a!=null&&(a instanceof Promise?e&&n.push(a):Array.isArray(a)?n=n.concat(a):n.push(a))}return n=n.filter(s=>s.title!==void 0||s.then!=null||s.menuElement),n}static getNextMenuItem(t,e,n){let r=t;r<0&&e<0&&(r=n.length);for(let s=1;s<n.length+1;s+=1){const o=(r+e*s+n.length)%n.length,a=n[o];if(!(a instanceof Promise)&&a.disabled!==!0)return o}return t}};let W=A;h(W,"actionsDisabled",!1);const D=W,X=P.forwardRef((f,t)=>{var $;function e(g){const{menuItem:N,onMenuItemClick:S}=f;S(N,g)}function n(g){const{menuItem:N,onMenuItemMouseMove:S}=f;S(N,g)}function r(g){const{menuItem:N,onMenuItemContextMenu:S}=f;S(N,g)}function s(g,N,S){if(typeof g.type=="string")return g;const{closeMenu:R,menuItem:G,isKeyboardSelected:ie,isMouseSelected:oe,"data-testid":le}=f,ue={menuItem:G,closeMenu:R,isKeyboardSelected:ie,isMouseSelected:oe,iconElement:N,displayShortcut:S,"data-testid":le};return P.cloneElement(g,{forwardedProps:ue})}const{children:o,menuItem:a,isKeyboardSelected:i=!1,isMouseSelected:l=!1,"data-testid":u}=f,m=($=a.shortcut)==null?void 0:$.getDisplayText();let p=null;if(a.icon){const g=a.icon;if(P.isValidElement(g))p=g;else{let N;a.iconColor!=null&&(a.disabled===void 0||!a.disabled)&&(N={color:a.iconColor}),p=T.jsx(Z,{icon:g,style:N})}}let M=null;const y=!!o;a.actions&&(M=T.jsx(Z,{icon:he}));let b=null;if(a.menuElement)b=T.jsx("div",{className:"custom-menu-item",onMouseMove:n,children:s(a.menuElement,p,m)});else{const g=a.disabled,N=a.iconOutline;b=T.jsx("button",{type:"button",className:j("btn-context-menu",{disabled:g},{active:(y||l)&&(g===void 0||!g)},{"keyboard-active":i&&(g===void 0||!g)}),onClick:e,onMouseMove:n,onContextMenu:r,title:a.description??"",children:T.jsxs("div",{className:"btn-context-menu-wrapper",children:[T.jsx("span",{className:j("icon",{outline:N}),children:p}),T.jsx("span",{className:"title",children:a.title}),m!==void 0&&T.jsx("span",{className:"shortcut",children:m}),M&&T.jsx("span",{className:j("submenu-indicator",{disabled:g}),children:M})]})})}return T.jsxs("div",{className:"context-menu-item",ref:t,"data-testid":u,children:[o,b]})});X.displayName="ContextMenuItem";X.defaultProps={children:null,isKeyboardSelected:!1,isMouseSelected:!1,"data-testid":void 0};const ye=X,_=V.module("ContextMenu"),Y=class extends v.PureComponent{constructor(e){super(e);h(this,"container");h(this,"oldFocus");h(this,"activeSubMenuRef");h(this,"subMenuTimer");h(this,"rAF");h(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=P.createRef(),this.oldFocus=document.activeElement,this.activeSubMenuRef=P.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 n;(n=this.container.current)==null||n.focus();const{onMenuOpened:e}=this.props;e(this)})}componentDidUpdate(e,n){var o,a;const{actions:r}=this.props,{activeSubMenu:s}=this.state;s!==n.activeSubMenu&&(s==null?(o=this.container.current)==null||o.focus():this.setActiveSubMenuPosition()),e.actions!==r&&(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:n}=this.state;return n}return this.getMouseIndex()}setKeyboardIndex(e){const{options:n}=this.props;n.separateKeyboardMouse!==void 0&&n.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 n=e.initialKeyboardIndex;n===void 0&&(n=-1);const{actions:r}=this.props,s=D.getMenuItems(r),o=[];for(let a=s.length-1;a>=0;a-=1){const i=s[a];i instanceof Promise?this.initMenuPromise(i):o.push(i)}this.setState({mouseIndex:-1,keyboardIndex:n,activeSubMenu:null,menuItems:D.sortActions(o)})}initMenuPromise(e){const n=Q.makeCancelable(e);this.setState(r=>({pendingItems:r.pendingItems.concat(n)})),n.then(r=>{this.setState(s=>{const o=s.pendingItems.indexOf(n);if(o>=0){const a=s.pendingItems.slice();return a.splice(o,1),{menuItems:D.sortActions(s.menuItems.concat(r)),pendingItems:a}}return null})},r=>{Q.isCanceled(r)||(this.setState(s=>{const o=s.pendingItems.indexOf(n);if(o>=0){const a=s.pendingItems.slice();return a.splice(o,1),{pendingItems:a}}return null}),_.error(r))})}cancelPromises(){const{pendingItems:e}=this.state;e.map(n=>n.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 M,y;const{options:e,updatePosition:n,subMenuParentWidth:r,subMenuParentHeight:s,top:o,left:a}=this.props;if(!this.container.current||e.doNotVerifyPosition!=null&&e.doNotVerifyPosition)return;let{top:i,left:l}=this.initialPosition;const{width:u,height:m}=((M=this.container.current)==null?void 0:M.getBoundingClientRect())??{width:0,height:0},p=(((y=this.container.current)==null?void 0:y.scrollHeight)??0)>window.innerHeight;m===0||u===0||(i+m>window.innerHeight&&(i-m-s>0?i-=m-s:i=window.innerHeight-m),l+u>window.innerWidth&&(l=l-u-r),(a!==l||o!==i)&&(this.setState({hasOverflow:p}),n(i,l)))}handleWindowResize(){this.container.current&&this.closeMenu(!0)}handleBlur(e){if(!this.container.current){_.warn("Container is null!");return}if(!this.container.current.contains(e.relatedTarget)){let n=e.relatedTarget,r=!1;for(;n&&!r;)r=n.hasAttribute("data-dh-context-menu"),n=n.parentElement;r||this.closeMenu(!0)}}isEscapeKey(e){const{left:n}=this.props;return e==="Escape"||n<0&&e==="ArrowRight"||e==="ArrowLeft"}handleKeyDown(e){const{menuItems:n}=this.state,r=this.getKeyboardIndex();let s=r,o=!1;if(e.key==="Enter"||e.key===" "){r>=0&&r<n.length&&this.handleMenuItemClick(n[r],e);return}if(e.key==="ArrowRight"?r>=0&&r<=n.length?o=!0:s=0:this.isEscapeKey(e.key)?s=null:e.key==="ArrowUp"||e.shiftKey&&e.key==="Tab"?s=D.getNextMenuItem(s,-1,n):(e.key==="ArrowDown"||e.key==="Tab")&&(s=D.getNextMenuItem(s,1,n)),o){this.openSubMenu(r),e.preventDefault(),e.stopPropagation();return}r!==s&&(s!==null?this.setKeyboardIndex(s):(this.closeMenu(),this.oldFocus instanceof HTMLElement&&this.oldFocus.focus()),e.preventDefault(),e.stopPropagation())}openSubMenu(e){const{menuItems:n,activeSubMenu:r}=this.state,s=n[e].actions?e:null;r!==s&&this.setState({activeSubMenu:s,subMenuTop:null,subMenuLeft:null})}closeMenu(e=!1){const{closeMenu:n,onMenuClosed:r}=this.props;cancelAnimationFrame(this.rAF),this.rAF=window.requestAnimationFrame(()=>{n(e),r(this)})}closeSubMenu(){this.setState({activeSubMenu:null})}handleCloseSubMenu(e){e?this.closeMenu(!0):this.closeSubMenu()}handleMenuItemClick(e,n){n.preventDefault(),n.stopPropagation();const{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(),this.closeMenu(!0)))}handleMenuItemContextMenu(e,n){n.metaKey||this.handleMenuItemClick(e,n)}handleMenuItemMouseMove(e){const{menuItems:n}=this.state,r=n.indexOf(e);this.setMouseIndex(r),r>=0&&r<n.length&&(e.disabled===void 0||!e.disabled)&&this.openSubMenu(r)}handleMouseLeave(){this.setMouseIndex(-1)}render(){const e=[],{top:n,left:r}=this.props,{activeSubMenu:s,hasOverflow:o,keyboardIndex:a,menuItems:i,mouseIndex:l,pendingItems:u,subMenuTop:m,subMenuLeft:p,subMenuParentWidth:M,subMenuParentHeight:y}=this.state;for(let S=0;S<i.length;S+=1){const R=i[S];S>0&&R.group!==i[S-1].group&&e.push(T.jsx("hr",{},`${S}.separator`));const G=T.jsx(ye,{ref:s===S?this.activeSubMenuRef:null,isKeyboardSelected:a===S,isMouseSelected:l===S,menuItem:R,closeMenu:this.handleCloseSubMenu,onMenuItemClick:this.handleMenuItemClick,onMenuItemMouseMove:this.handleMenuItemMouseMove,onMenuItemContextMenu:this.handleMenuItemContextMenu},S);e.push(G)}let b=null;u.length>0&&(b=T.jsx("div",{className:"loading",children:T.jsx(me,{})}));const{menuStyle:$,"data-testid":g}=this.props,N=s!==null&&m!==null&&p!==null;return T.jsxs(T.Fragment,{children:[T.jsxs("div",{className:j({"has-overflow":o},"context-menu-container"),style:{top:n,left:r,...$},ref:this.container,"data-dh-context-menu":!0,onBlur:this.handleBlur,onKeyDown:this.handleKeyDown,onMouseLeave:this.handleMouseLeave,onContextMenu:Y.handleContextMenu,role:"menuitem",tabIndex:0,"data-testid":g,children:[e,b]}),N&&s!==null&&m!==null&&p!==null&&T.jsx(Y,{actions:i[s].actions||[],closeMenu:this.handleCloseSubMenu,top:m,left:p,updatePosition:(S,R)=>{this.setState({subMenuTop:S,subMenuLeft:R})},subMenuParentWidth:M,subMenuParentHeight:y},`sub-${s}`)]})}};let U=Y;h(U,"defaultProps",{subMenuParentWidth:0,subMenuParentHeight:0,closeMenu(){},onMenuOpened(){},onMenuClosed(){},options:{},menuStyle:{},"data-testid":void 0});const Ee=U;class Fe extends v.Component{constructor(e){super(e);h(this,"container");h(this,"openMenu");this.handleMenuClose=this.handleMenuClose.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.container=P.createRef(),this.openMenu=P.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(!D.isContextActionEvent(e)||!this.container.current||e.metaKey||e.ctrlKey)return;const n=D.getMenuItems(e.contextActions),r=this.container.current.getBoundingClientRect(),s=e.clientY-r.top,o=e.clientX-r.left;if(n.length===0){if(e.target===this.container.current){e.preventDefault(),this.setState({actions:null},()=>{const a=document.elementFromPoint(o,s),i=new MouseEvent("contextmenu",{clientX:e.clientX,clientY:e.clientY,bubbles:!0,cancelable:!0});a==null||a.dispatchEvent(i)});return}return}e.preventDefault(),this.setState({actions:n,top:s,left:o})}handleMenuClose(e){e===this.openMenu.current&&this.setState({actions:null})}render(){let e=null;const{"data-testid":n}=this.props,{actions:r,top:s,left:o}=this.state;return r&&(e=T.jsx(Ee,{ref:this.openMenu,actions:r,onMenuClosed:this.handleMenuClose,top:s,left:o,updatePosition:(a,i)=>{this.setState({top:a,left:i})},"data-testid":n})),T.jsx("div",{className:j("context-menu-root",{active:r}),ref:this.container,children:e})}}const We=Fe;function ne(){return z(fe,"No API available in useApi. Was code wrapped in ApiBootstrap or ApiContext.Provider?")}function Ce(f,t){const e=ne(),n=v.useMemo(()=>new e.CoreClient(f,t),[e,f,t]);return v.useEffect(()=>()=>{n.disconnect()},[n]),n}const re=v.createContext(null);function Ue({serverUrl:f,options:t,children:e}){const n=Ce(f,t);return T.jsx(re.Provider,{value:n,children:e})}function Ne(){return z(re,"No Client available in useClient. Was code wrapped in ClientBootstrap or ClientContext.Provider?")}class K{static isValid(t,e){return!0}static isSameFormat(t,e){throw new Error("isSameFormat not implemented")}static makeFormat(t,e,n){return{label:t,formatString:e,type:n}}format(t,e){return""}}h(K,"TYPE_GLOBAL","type-global"),h(K,"TYPE_CONTEXT_PRESET","type-context-preset"),h(K,"TYPE_CONTEXT_CUSTOM","type-context-custom");const F=K;class be extends F{format(t){switch(t){case 1:case!0:return"true";case 0:case!1:return"false";default:return""}}}const Ie=be;class we extends F{format(t){return String.fromCharCode(t)}}const ve=we,ee=V.module("DateTimeColumnFormatter"),x=class extends F{constructor(e,{timeZone:n="",showTimeZone:r=!0,showTSeparator:s=!1,defaultDateTimeFormatString:o=x.DEFAULT_DATETIME_FORMAT_STRING}={}){super();h(this,"dh");h(this,"dhTimeZone");h(this,"defaultDateTimeFormatString");h(this,"showTimeZone");h(this,"showTSeparator");h(this,"formatStringMap");const a=n||x.DEFAULT_TIME_ZONE_ID;try{this.dhTimeZone=e.i18n.TimeZone.getTimeZone(a)}catch{ee.error("Unsupported time zone id",a),this.dhTimeZone=e.i18n.TimeZone.getTimeZone(x.DEFAULT_TIME_ZONE_ID)}this.dh=e,this.defaultDateTimeFormatString=o,this.showTimeZone=r,this.showTSeparator=s,this.formatStringMap=x.makeFormatStringMap(r,s)}static isValid(e,n){try{return e.i18n.DateTimeFormat.format(n.formatString,new Date),!0}catch{return!1}}static makeFormat(e,n,r=F.TYPE_CONTEXT_PRESET){return{label:e,formatString:n,type:r}}static isSameFormat(e,n){return e===n||e!==null&&n!==null&&e.type===n.type&&e.formatString===n.formatString}static makeGlobalFormatStringMap(e,n){const r=n?"'T'":" ",s=e?" z":"";return new Map([["yyyy-MM-dd HH:mm:ss",`yyyy-MM-dd${r}HH:mm:ss${s}`],["yyyy-MM-dd HH:mm:ss.SSS",`yyyy-MM-dd${r}HH:mm:ss.SSS${s}`],["yyyy-MM-dd HH:mm:ss.SSSSSSSSS",`yyyy-MM-dd${r}HH:mm:ss.SSSSSSSSS${s}`]])}static getGlobalFormats(e,n){return[...x.makeGlobalFormatStringMap(e,n).keys()]}static makeFormatStringMap(e,n){const r=n!==void 0&&n?"'T'":" ",s=e!==void 0&&e?" z":"";return new Map([["yyyy-MM-dd",`yyyy-MM-dd${s}`],["MM-dd-yyyy",`MM-dd-yyyy${s}`],["HH:mm:ss",`HH:mm:ss${s}`],["HH:mm:ss.SSS",`HH:mm:ss.SSS${s}`],["HH:mm:ss.SSSSSSSSS",`HH:mm:ss.SSSSSSSSS${s}`],["yyyy-MM-dd HH:mm:ss",`yyyy-MM-dd${r}HH:mm:ss${s}`],["yyyy-MM-dd HH:mm:ss.SSS",`yyyy-MM-dd${r}HH:mm:ss.SSS${s}`],["yyyy-MM-dd HH:mm:ss.SSSSSSSSS",`yyyy-MM-dd${r}HH:mm:ss.SSSSSSSSS${s}`]])}static getFormats(e,n){return[...x.makeFormatStringMap(e,n).keys()]}getEffectiveFormatString(e){return this.formatStringMap.get(e)??e}format(e,n={}){const r=n.formatString!=null&&n.formatString!==""?n.formatString:this.defaultDateTimeFormatString,s=this.getEffectiveFormatString(r);try{return this.dh.i18n.DateTimeFormat.format(s,e,this.dhTimeZone)}catch{ee.error("Invalid format arguments")}return""}};let H=x;h(H,"DEFAULT_DATETIME_FORMAT_STRING","yyyy-MM-dd HH:mm:ss.SSS"),h(H,"DEFAULT_TIME_ZONE_ID","America/New_York");const ke=V.module("DecimalColumnFormatter"),I=class extends F{constructor(e,{defaultFormatString:n=I.DEFAULT_FORMAT_STRING}={}){super();h(this,"defaultFormatString");h(this,"dh");this.dh=e,this.defaultFormatString=n}static isValid(e,n){try{return e.i18n.NumberFormat.format(n.formatString,0),!0}catch{return!1}}static makeFormat(e,n,r=F.TYPE_CONTEXT_PRESET,s){return{label:e,type:r,formatString:n,multiplier:s}}static makePresetFormat(e,n="",r){return I.makeFormat(e,n,F.TYPE_CONTEXT_PRESET,r)}static makeCustomFormat(e="",n){return I.makeFormat("Custom Format",e,F.TYPE_CONTEXT_CUSTOM,n)}static isSameFormat(e,n){return e===n||e!=null&&n!=null&&e.type===n.type&&e.formatString===n.formatString&&e.multiplier===n.multiplier}format(e,n={}){const r=n.formatString!=null&&n.formatString!==""?n.formatString:this.defaultFormatString,s=n.multiplier!=null&&n.multiplier!==0?e*n.multiplier:e;try{return this.dh.i18n.NumberFormat.format(r,s)}catch{ke.error("Invalid format arguments")}return""}};let w=I;h(w,"DEFAULT_FORMAT_STRING","###,##0.0000"),h(w,"FORMAT_PERCENT",I.makePresetFormat("Percent","##0.00%")),h(w,"FORMAT_BASIS_POINTS",I.makePresetFormat("Basis Points","###,##0 bp",1e4)),h(w,"FORMAT_MILLIONS",I.makePresetFormat("Millions","###,##0.000 mm",1e-6)),h(w,"FORMAT_SCIENTIFIC_NOTATION",I.makePresetFormat("Scientific Notation","0.0000E0")),h(w,"FORMAT_ROUND",I.makePresetFormat("Round","###,##0")),h(w,"FORMAT_ROUND_TWO_DECIMALS",I.makePresetFormat("0.00","###,##0.00")),h(w,"FORMAT_ROUND_FOUR_DECIMALS",I.makePresetFormat("0.0000","###,##0.0000"));class xe extends F{format(t){return`${t}`}}const De=xe,Ae=V.module("IntegerColumnFormatter"),O=class extends F{constructor(e,{defaultFormatString:n=O.DEFAULT_FORMAT_STRING}={}){super();h(this,"dh");h(this,"defaultFormatString");this.dh=e,this.defaultFormatString=n}static isValid(e,n){try{return e.i18n.NumberFormat.format(n.formatString,0),!0}catch{return!1}}static makeFormat(e,n,r=F.TYPE_CONTEXT_PRESET,s){return{label:e,type:r,formatString:n,multiplier:s}}static makePresetFormat(e,n="",r){return O.makeFormat(e,n,F.TYPE_CONTEXT_PRESET,r)}static makeCustomFormat(e="",n){return O.makeFormat("Custom Format",e,F.TYPE_CONTEXT_CUSTOM,n)}static isSameFormat(e,n){return e===n||e!=null&&n!=null&&e.type===n.type&&e.formatString===n.formatString&&e.multiplier===n.multiplier}format(e,n={}){const r=n.formatString!=null&&n.formatString!==""?n.formatString:this.defaultFormatString,s=n.multiplier!=null&&n.multiplier!==0?e*n.multiplier:e;try{return this.dh.i18n.NumberFormat.format(r,s)}catch{Ae.error("Invalid format arguments")}return""}};let L=O;h(L,"DEFAULT_FORMAT_STRING","###,##0"),h(L,"FORMAT_MILLIONS",O.makePresetFormat("Millions","###,##0.000 mm",1e-6)),h(L,"FORMAT_SCIENTIFIC_NOTATION",O.makePresetFormat("Scientific Notation","0.0000E0"));class Oe extends F{format(t){return t}}const C=class{static makeDateWrapper(t,e,n,r=0,s=1,o=0,a=0,i=0,l=0){if(!e)throw new Error("No timezone provided");const u=`${n}`.padStart(4,"0"),m=`${r+1}`.padStart(2,"0"),p=`${s}`.padStart(2,"0"),M=`${o}`.padStart(2,"0"),y=`${a}`.padStart(2,"0"),b=`${i}`.padStart(2,"0"),$=`${l}`.padStart(9,"0"),g=`${u}-${m}-${p} ${M}:${y}:${b}.${$}`;return t.i18n.DateTimeFormat.parse(C.FULL_DATE_FORMAT,g,t.i18n.TimeZone.getTimeZone(e))}static getNextNanos(t){const e=parseInt(t,10),n="0".repeat(9-t.length),r=`${e+1}${n}`;return parseInt(r,10)}static getNextDate(t,e,n,r){let{year:s,month:o,date:a,hours:i,minutes:l,seconds:u,nanos:m}=n;if(e.nanos!=null){if(e.nanos.length===9)return null;m=C.getNextNanos(e.nanos),m>999999999&&(u+=1,m=0)}else e.seconds!=null?u+=1:e.minutes!=null?l+=1:e.hours!=null?i+=1:e.date!=null?a+=1:e.month!=null?o+=1:s+=1;const p=new Date(s,o,a,i,l,u);return C.makeDateWrapper(t,r,p.getFullYear(),p.getMonth(),p.getDate(),p.getHours(),p.getMinutes(),p.getSeconds(),m)}static parseMonth(t){const e=parseInt(t,10);if(!Number.isNaN(e))return e>=1&&e<=12?e-1:NaN;const n=t.trim().toLowerCase();if(n.length>=3){for(let r=0;r<C.months.length;r+=1)if(C.months[r].startsWith(n))return r}return NaN}static parseDateValues(t,e,n,r,s,o,a){const i=parseInt(t,10),l=e!=null?this.parseMonth(e):0,u=n!=null?parseInt(n,10):1,m=r!=null?parseInt(r,10):0,p=s!=null?parseInt(s,10):0,M=o!=null?parseInt(o,10):0,y=a!=null?parseInt(a.padEnd(9,"0"),10):0;return Number.isNaN(i)||Number.isNaN(l)||Number.isNaN(u)||Number.isNaN(m)||Number.isNaN(p)||Number.isNaN(M)||Number.isNaN(y)?null:{year:i,month:l,date:u,hours:m,minutes:p,seconds:M,nanos:y}}static parseDateTimeString(t){const n=/\s*(\d{4})([-./]([\da-z]+))?([-./](\d{1,2}))?([tT\s](\d{2})([:](\d{2}))?([:](\d{2}))?([.](\d{1,9}))?)?(.*)/.exec(t);if(n==null)throw new Error(`Unexpected date string: ${t}`);const[,r,,s,,o,,a,,i,,l,,u,m]=n;if(m!=null&&m.length>0)throw new Error(`Unexpected characters after date string '${t}': ${m}`);return{year:r,month:s,date:o,hours:a,minutes:i,seconds:l,nanos:u}}static parseDateRange(t,e,n){const r=e.trim().toLowerCase();if(r.length===0)throw new Error("Cannot parse date range from empty string");if(r==="null")return[null,null];if(r==="today"){const l=new Date(Date.now()),u=C.makeDateWrapper(t,n,l.getFullYear(),l.getMonth(),l.getDate()),m=new Date(l.getFullYear(),l.getMonth(),l.getDate()+1),p=C.makeDateWrapper(t,n,m.getFullYear(),m.getMonth(),m.getDate());return[u,p]}if(r==="yesterday"){const l=new Date(Date.now()),u=new Date(l.getFullYear(),l.getMonth(),l.getDate()-1),m=C.makeDateWrapper(t,n,u.getFullYear(),u.getMonth(),u.getDate()),p=C.makeDateWrapper(t,n,l.getFullYear(),l.getMonth(),l.getDate());return[m,p]}if(r==="now"){const l=new Date(Date.now());return[t.DateWrapper.ofJsDate(l),null]}const s=C.parseDateTimeString(r);if(s.year==null&&s.month==null&&s.date==null)throw new Error(`Unable to extract year, month, or day ${r}`);const o=C.parseDateValues(s.year,s.month,s.date,s.hours,s.minutes,s.seconds,s.nanos);if(o==null)throw new Error(`Unable to extract date values from ${s}`);const a=C.makeDateWrapper(t,n,o.year,o.month,o.date,o.hours,o.minutes,o.seconds,o.nanos),i=C.getNextDate(t,s,o,n);return[a,i]}static getJsDate(t){return typeof t=="number"?new Date(t):t.asDate()}};let q=C;h(q,"FULL_DATE_FORMAT","yyyy-MM-dd HH:mm:ss.SSSSSSSSS"),h(q,"months",["january","february","march","april","may","june","july","august","september","october","november","december"]);class B{}h(B,"not","not"),h(B,"and","and"),h(B,"or","or");class d{}h(d,"eq","eq"),h(d,"eqIgnoreCase","eqIgnoreCase"),h(d,"notEq","notEq"),h(d,"notEqIgnoreCase","notEqIgnoreCase"),h(d,"greaterThan","greaterThan"),h(d,"greaterThanOrEqualTo","greaterThanOrEqualTo"),h(d,"lessThan","lessThan"),h(d,"lessThanOrEqualTo","lessThanOrEqualTo"),h(d,"in","in"),h(d,"inIgnoreCase","inIgnoreCase"),h(d,"notIn","notIn"),h(d,"notInIgnoreCase","notInIgnoreCase"),h(d,"isTrue","isTrue"),h(d,"isFalse","isFalse"),h(d,"isNull","isNull"),h(d,"invoke","invoke"),h(d,"contains","contains"),h(d,"notContains","notContains"),h(d,"containsIgnoreCase","containsIgnoreCase"),h(d,"startsWith","startsWith"),h(d,"endsWith","endsWith"),h(d,"containsAny","containsAny");const k=V.module("TableUtils"),c=class{constructor(t){h(this,"dh");this.dh=t}static getSortIndex(t,e){var n;for(let r=0;r<t.length;r+=1)if(((n=t[r].column)==null?void 0:n.name)===e)return r;return null}static getSortForColumn(t,e){const n=c.getSortIndex(t,e);return n!=null?t[n]:null}static getFilterText(t){return t?t.toString():null}static getFilterTypes(t){return c.isBooleanType(t)?[d.isTrue,d.isFalse,d.isNull]:c.isCharType(t)||c.isNumberType(t)||c.isDateType(t)?[d.eq,d.notEq,d.greaterThan,d.greaterThanOrEqualTo,d.lessThan,d.lessThanOrEqualTo]:c.isTextType(t)?[d.eq,d.eqIgnoreCase,d.notEq,d.notEqIgnoreCase,d.contains,d.notContains,d.startsWith,d.endsWith]:[]}static getNextSort(t,e,n){if(n<0||n>=t.length)return null;const r=c.getSortForColumn(e,t[n].name);return r===null?t[n].sort().asc():r.direction===c.sortDirection.ascending?r.desc():null}static makeColumnSort(t,e,n,r){if(e<0||e>=t.length||n===c.sortDirection.none)return null;let s=t[e].sort();switch(n){case c.sortDirection.ascending:s=s.asc();break;case c.sortDirection.descending:s=s.desc();break}return r&&(s=s.abs()),s}static toggleSortForColumn(t,e,n,r=!1){if(n<0||n>=e.length)return[];const s=c.getNextSort(e,t,n);return c.setSortForColumn(t,e[n].name,s,r)}static sortColumn(t,e,n,r,s,o){if(n<0||n>=e.length)return[];const a=c.makeColumnSort(e,n,r,s);return c.setSortForColumn(t,e[n].name,a,o)}static setSortForColumn(t,e,n,r=!1){const s=c.getSortIndex(t,e);let o=[];return r&&(o=o.concat(t.filter(({direction:a})=>a!==c.sortDirection.reverse)),s!==null&&o.splice(s,1)),n!==null&&o.push(n),o}static getNormalizedType(t){switch(t){case"boolean":case"java.lang.Boolean":case c.dataType.BOOLEAN:return c.dataType.BOOLEAN;case"char":case"java.lang.Character":case c.dataType.CHAR:return c.dataType.CHAR;case"java.lang.String":case c.dataType.STRING:return c.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 c.dataType.DATETIME:return c.dataType.DATETIME;case"double":case"java.lang.Double":case"float":case"java.lang.Float":case"java.math.BigDecimal":case c.dataType.DECIMAL:return c.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 c.dataType.INT:return c.dataType.INT;default:return c.dataType.UNKNOWN}}static isLongType(t){switch(t){case"long":case"java.lang.Long":return!0;default:return!1}}static isDateType(t){switch(t){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(t){return c.isIntegerType(t)||c.isDecimalType(t)}static isIntegerType(t){switch(t){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(t){switch(t){case"double":case"java.lang.Double":case"java.math.BigDecimal":case"float":case"java.lang.Float":return!0;default:return!1}}static isBigDecimalType(t){switch(t){case"java.math.BigDecimal":return!0;default:return!1}}static isBigIntegerType(t){switch(t){case"java.math.BigInteger":return!0;default:return!1}}static isBooleanType(t){switch(t){case"boolean":case"java.lang.Boolean":return!0;default:return!1}}static isCharType(t){switch(t){case"char":case"java.lang.Character":return!0;default:return!1}}static isStringType(t){switch(t){case"java.lang.String":return!0;default:return!1}}static isTextType(t){return this.isStringType(t)||this.isCharType(t)}static getBaseType(t){return t.split("[]")[0]}static isCompatibleType(t,e){return c.getNormalizedType(t)===c.getNormalizedType(e)}static quoteValue(t){return t.length>=2&&(t.charAt(0)==='"'&&t.charAt(t.length-1)==='"'||t.charAt(0)==="'"&&t.charAt(t.length-1)==="'")?t:`"${t}"`}static isRangeOperation(t){switch(t){case"<":case"<=":case"=<":case">":case">=":case"=>":return!0;default:return!1}}static makeRangeFilterWithOperation(t,e,n){switch(e){case"=":return t.eq(n);case"<":return t.lessThan(n);case"<=":case"=<":return t.lessThanOrEqualTo(n);case">":return t.greaterThan(n);case">=":case"=>":return t.greaterThanOrEqualTo(n);case"!=":case"!":return t.notEq(n);default:return null}}static makeCancelableTablePromise(t){return Q.makeCancelable(t,e=>{e.close()})}static makeCancelableTableEventPromise(t,e,n=0,r=null){let s,o,a=!0;const i=new Promise((l,u)=>{o=setTimeout(()=>{s(),a=!1,u(new te(`Event "${e}" timed out.`))},n),s=t.addEventListener(e,m=>{if(r!=null&&!r(m)){k.debug2("Event triggered, but matcher returned false.");return}k.debug2("Event triggered, resolving."),s(),clearTimeout(o),a=!1,l(m)})});return i.cancel=()=>{if(a){k.debug2("Pending promise cleanup."),s(),clearTimeout(o),a=!1;return}k.debug2("Ignoring non-pending promise cancel.")},i}static removeCommas(t){return t.replace(/[\s|,]/g,"")}static makeBooleanValue(t,e=!1){if(t===""&&e)return null;switch(t==null?void 0:t.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 '${t}'`)}}static makeNumberValue(t){if(t==="null"||t==="")return null;const e=t.toLowerCase().trim();if(e==="∞"||e==="infinity"||e==="inf")return Number.POSITIVE_INFINITY;if(e==="-∞"||e==="-infinity"||e==="-inf")return Number.NEGATIVE_INFINITY;const n=c.removeCommas(e);if(c.NUMBER_REGEX.test(n))return parseFloat(n);throw new Error(`Invalid number '${t}'`)}static getFilterOperatorString(t){switch(t){case d.eq:return"=";case d.notEq:return"!=";case d.greaterThan:return">";case d.greaterThanOrEqualTo:return">=";case d.lessThan:return"<";case d.lessThanOrEqualTo:return"<=";case d.contains:return"~";case d.notContains:return"!~";default:throw new Error(`Unexpected filter type ${t}`)}}static isTreeTable(t){return t!=null&&t.expand!==void 0&&t.collapse!==void 0}static sortColumns(t,e=!0){return[...t].sort((n,r)=>{const s=n.name.toUpperCase(),o=r.name.toUpperCase();return Se.sort(s,o,e)})}makeQuickFilter(t,e,n){const r=e.split("||");let s=null;for(let o=0;o<r.length;o+=1){const i=r[o].split("&&");let l=null;for(let u=0;u<i.length;u+=1){const m=i[u].trim();if(m.length>0){const p=this.makeQuickFilterFromComponent(t,m,n);if(p)l?l=l.and(p):l=p;else throw new Error(`Unable to parse quick filter from text ${e}`)}}s&&l?s=s.or(l):s=l}return s}makeQuickFilterFromComponent(t,e,n){const{type:r}=t;return c.isNumberType(r)?this.makeQuickNumberFilter(t,e):c.isBooleanType(r)?this.makeQuickBooleanFilter(t,e):n!=null&&c.isDateType(r)?this.makeQuickDateFilter(t,e,n):c.isCharType(r)?this.makeQuickCharFilter(t,e):this.makeQuickTextFilter(t,e)}makeQuickNumberFilter(t,e){const n=t.filter(),{dh:r}=this;let s=null;const a=/\s*(>=|<=|=>|=<|>|<|!=|=|!)?(\s*-\s*)?(\s*\d*(?:,\d{3})*(?:\.\d*)?\s*)?(null|nan|infinity|inf|\u221E)?(.*)/i.exec(e);let i=null,l=null,u=null,m=null,p=null;if(a!==null&&a.length>3&&([,i,l,u,m,p]=a),p!=null&&p.trim().length>0)return null;if(i==null&&(i="="),m!=null){if(!(i==="="||i==="!"||i==="!="))return null;switch(m=m.trim().toLowerCase(),m){case"null":s=n.isNull();break;case"nan":s=r.FilterCondition.invoke("isNaN",n);break;case"infinity":case"inf":case"∞":l!=null?s=r.FilterCondition.invoke("isInf",n).and(n.lessThan(r.FilterValue.ofNumber(0))):s=r.FilterCondition.invoke("isInf",n).and(n.greaterThan(r.FilterValue.ofNumber(0)));break}return s!==null&&(i==="!"||i==="!=")&&(s=s.not()),s}if(u==null)return null;if(u=c.removeCommas(u),c.isLongType(t.type))try{u=r.FilterValue.ofNumber(r.LongWrapper.ofString(`${l!=null?"-":""}${u}`))}catch(M){return k.warn("Unable to create long filter",M),null}else{if(u=parseFloat(u),u==null||Number.isNaN(u))return null;u=r.FilterValue.ofNumber(l!=null?0-u:u)}return s=t.filter(),c.makeRangeFilterWithOperation(s,i,u)}makeQuickTextFilter(t,e){const{dh:n}=this,r=`${e}`.trim(),o=/^(!~|!=|~|=|!)?(.*)/.exec(r);let a=null,i=null;if(o!==null&&o.length>2&&([,a,i]=o,i!=null&&(i=i.trim())),i==null||i.length===0)return null;a==null&&(a="=");const l=t.filter();if(i.toLowerCase()==="null")switch(a){case"=":return l.isNull();case"!=":case"!":return l.isNull().not()}let u=null,m=null;switch(i.startsWith("*")?(u="*",i=i.substring(1)):i.endsWith("*")&&!i.endsWith("\\*")&&(m="*",i=i.substring(0,i.length-1)),i=i.replace("\\",""),a){case"~":return l.isNull().not().and(l.invoke("matches",n.FilterValue.ofString(`(?s)(?i).*\\Q${i}\\E.*`)));case"!~":return l.isNull().or(l.invoke("matches",n.FilterValue.ofString(`(?s)(?i).*\\Q${i}\\E.*`)).not());case"!=":return u==="*"?l.isNull().or(l.invoke("matches",n.FilterValue.ofString(`(?s)(?i).*\\Q${i}\\E$`)).not()):m==="*"?l.isNull().or(l.invoke("matches",n.FilterValue.ofString(`(?s)(?i)^\\Q${i}\\E.*`)).not()):l.notEqIgnoreCase(n.FilterValue.ofString(i.toLowerCase()));case"=":return u==="*"?l.isNull().not().and(l.invoke("matches",n.FilterValue.ofString(`(?s)(?i).*\\Q${i}\\E$`))):m==="*"?l.isNull().not().and(l.invoke("matches",n.FilterValue.ofString(`(?s)(?i)^\\Q${i}\\E.*`))):l.eqIgnoreCase(n.FilterValue.ofString(i.toLowerCase()))}return null}makeQuickBooleanFilter(t,e){const r=/^(!=|=|!)?(.*)/.exec(`${e}`.trim());if(r===null)return null;const[,s,o]=r,a=s==="!"||s==="!=",i=o.trim().toLowerCase();let l=t.filter();try{const u=c.makeBooleanValue(i);return u!=null&&u?l=l.isTrue():u===null?l=l.isNull():l=l.isFalse(),a?l.not():l}catch{return null}}makeQuickDateFilter(t,e,n){const r=e.trim(),o=/\s*(>=|<=|=>|=<|>|<|!=|!|=)?(.*)/.exec(r);if(o==null||o.length<=2)throw new Error(`Unable to parse date filter: ${e}`);let a=null,i=null;[,a,i]=o;let l=d.eq;switch(a){case"<":l=d.lessThan;break;case"<=":case"=<":l=d.lessThanOrEqualTo;break;case">":l=d.greaterThan;break;case">=":case"=>":l=d.greaterThanOrEqualTo;break;case"!=":case"!":l=d.notEq;break;case"=":case"==":default:l=d.eq;break}return this.makeQuickDateFilterWithOperation(t,i,l,n)}makeQuickDateFilterWithOperation(t,e,n,r){const{dh:s}=this,[o,a]=q.parseDateRange(s,e,r),i=o!=null?s.FilterValue.ofNumber(o):null,l=a!=null?s.FilterValue.ofNumber(a):null,u=t.filter();if(i==null)return n===d.notEq?u.isNull().not():u.isNull();switch(n){case d.eq:{if(l!=null){const m=u.greaterThanOrEqualTo(i),p=u.lessThan(l);return m.and(p)}return u.eq(i)}case d.lessThan:return u.lessThan(i);case d.lessThanOrEqualTo:return l!=null?u.lessThan(l):u.lessThanOrEqualTo(i);case d.greaterThan:return l!=null?u.greaterThanOrEqualTo(l):u.greaterThan(i);case d.greaterThanOrEqualTo:return u.greaterThanOrEqualTo(i);case d.notEq:{if(l!=null){const m=u.lessThan(i),p=u.greaterThanOrEqualTo(l);return m.or(p)}return u.notEq(i)}default:throw new Error(`Invalid operator: ${n}`)}}makeQuickCharFilter(t,e){const{dh:n}=this,r=`${e}`.trim(),o=/^(>=|<=|=>|=<|>|<|!=|=|!)?(null|"."|'.'|.)?(.*)/.exec(r);let a=null,i=null,l=null;if(o!==null&&o.length>3&&([,a,i,l]=o),l!=null&&l.trim().length>0||i==null||i.length===0)return null;a==null&&(a="=");const u=t.filter();if(i.toLowerCase()==="null")switch(a){case"=":return u.isNull();case"!=":case"!":return u.isNull().not();default:return null}const m=n.FilterValue.ofString(c.isRangeOperation(a)?c.quoteValue(i):i);return c.makeRangeFilterWithOperation(u,a,m)}makeAdvancedFilter(t,e,n){const{filterItems:r,filterOperators:s,invertSelection:o,selectedValues:a}=e;let i=null;for(let u=0;u<r.length;u+=1){const m=r[u],{selectedType:p,value:M}=m;if(p!=null&&p.length>0&&M!=null&&M.length>0)try{const y=this.makeAdvancedValueFilter(t,p,M,n);if(y!=null){if(u===0)i=y;else if(i!==null&&u-1<s.length){const b=s[u-1];if(b===B.and)i=i.and(y);else if(b===B.or)i=i.or(y);else{k.error("Unexpected filter operator",b,y),i=null;break}}}else k.debug2("Empty filter ignored for",p,M)}catch(y){k.error("Unable to create filter",y),i=null;break}}const l=this.makeSelectValueFilter(t,a,o);return l!=null&&(i!=null?i=i.and(l):i=l),i}makeAdvancedValueFilter(t,e,n,r){const{dh:s}=this;if(c.isDateType(t.type))return this.makeQuickDateFilterWithOperation(t,n,e,r);if(c.isNumberType(t.type)||c.isCharType(t.type))return this.makeQuickFilter(t,`${c.getFilterOperatorString(e)}${n}`);const o=this.makeFilterValue(t.type,n),a=t.filter();switch(e){case d.eq:return a.eq(o);case d.eqIgnoreCase:return a.eqIgnoreCase(o);case d.notEq:return a.notEq(o);case d.notEqIgnoreCase:return a.notEqIgnoreCase(o);case d.greaterThan:return a.greaterThan(o);case d.greaterThanOrEqualTo:return a.greaterThanOrEqualTo(o);case d.lessThan:return a.lessThan(o);case d.lessThanOrEqualTo:return a.lessThanOrEqualTo(o);case d.isTrue:return a.isTrue();case d.isFalse:return a.isFalse();case d.isNull:return a.isNull();case d.contains:return a.isNull().not().and(a.invoke("matches",s.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E.*`)));case d.notContains:return a.isNull().or(a.invoke("matches",s.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E.*`)).not());case d.startsWith:return a.isNull().not().and(a.invoke("matches",s.FilterValue.ofString(`(?s)(?i)^\\Q${n}\\E.*`)));case d.endsWith:return a.isNull().not().and(a.invoke("matches",s.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E$`)));case d.in:case d.inIgnoreCase:case d.notIn:case d.notInIgnoreCase:case d.invoke:default:throw new Error(`Unexpected filter operation: ${e}`)}}async applyNeverFilter(t,e,n=c.APPLY_TABLE_CHANGE_TIMEOUT_MS){if(t==null)return null;const r=t.findColumn(e),s=[this.makeNeverFilter(r)];return await this.applyFilter(t,s,n),t}async applyCustomColumns(t,e,n=c.APPLY_TABLE_CHANGE_TIMEOUT_MS){const{dh:r}=this;return c.executeAndWaitForEvent(s=>s==null?void 0:s.applyCustomColumns(e),t,r.Table.EVENT_CUSTOMCOLUMNSCHANGED,n)}async applyFilter(t,e,n=c.APPLY_TABLE_CHANGE_TIMEOUT_MS){const{dh:r}=this;return c.executeAndWaitForEvent(s=>s==null?void 0:s.applyFilter(e),t,r.Table.EVENT_FILTERCHANGED,n)}async applySort(t,e,n=c.APPLY_TABLE_CHANGE_TIMEOUT_MS){const{dh:r}=this;return c.executeAndWaitForEvent(s=>s==null?void 0:s.applySort(e),t,r.Table.EVENT_SORTCHANGED,n)}makeNeverFilter(t){const{dh:e}=this;let n=null;c.isTextType(t.type)?n=e.FilterValue.ofString("a"):c.isBooleanType(t.type)?n=e.FilterValue.ofBoolean(!0):c.isDateType(t.type)?n=e.FilterValue.ofNumber(e.DateWrapper.ofJsDate(new Date)):n=e.FilterValue.ofNumber(0);const r=t.filter().eq(n),s=t.filter().notEq(n);return r.and(s)}makeFilterValue(t,e){const{dh:n}=this,r=c.getBaseType(t);return c.isTextType(r)?n.FilterValue.ofString(e):c.isLongType(r)?n.FilterValue.ofNumber(n.LongWrapper.ofString(c.removeCommas(e))):n.FilterValue.ofNumber(c.removeCommas(e))}makeFilterRawValue(t,e){const{dh:n}=this;return c.isTextType(t)?n.FilterValue.ofString(e):c.isBooleanType(t)?n.FilterValue.ofBoolean(e):n.FilterValue.ofNumber(e)}makeValue(t,e,n){const{dh:r}=this;if(e==="null")return null;if(c.isTextType(t))return e;if(c.isLongType(t))return r.LongWrapper.ofString(c.removeCommas(e));if(c.isBooleanType(t))return c.makeBooleanValue(e,!0);if(c.isDateType(t)){const[s]=q.parseDateRange(r,e,n);return s}return c.isNumberType(t)?c.makeNumberValue(e):(k.error("Unexpected column type",t),null)}makeSelectValueFilter(t,e,n){const{dh:r}=this;if(e.length===0)return n?null:this.makeNeverFilter(t);const s=[];let o=!1;for(let a=0;a<e.length;a+=1){const i=e[a];i==null?o=!0:c.isTextType(t.type)?s.push(r.FilterValue.ofString(typeof i=="number"?String.fromCharCode(i):i)):c.isBooleanType(t.type)?s.push(r.FilterValue.ofBoolean(!!i)):s.push(r.FilterValue.ofNumber(i))}return o?s.length>0?n?t.filter().isNull().not().and(t.filter().notIn(s)):t.filter().isNull().or(t.filter().in(s)):n?t.filter().isNull().not():t.filter().isNull():n?t.filter().notIn(s):t.filter().in(s)}};let E=c;h(E,"dataType",{BOOLEAN:"boolean",CHAR:"char",DATETIME:"datetime",DECIMAL:"decimal",INT:"int",STRING:"string",UNKNOWN:"unknown"}),h(E,"sortDirection",{ascending:"ASC",descending:"DESC",reverse:"REVERSE",none:null}),h(E,"APPLY_TABLE_CHANGE_TIMEOUT_MS",3e4),h(E,"REVERSE_TYPE",Object.freeze({NONE:"none",PRE_SORT:"pre-sort",POST_SORT:"post-sort"})),h(E,"NUMBER_REGEX",/^-?\d+(\.\d+)?$/),h(E,"executeAndWaitForEvent",async(t,e,n,r=c.APPLY_TABLE_CHANGE_TIMEOUT_MS)=>{if(e==null)return null;const s=c.makeCancelableTableEventPromise(e,n,r);return t(e),await s,e});class se{constructor(t,e=[],n,r,s,o=!1){h(this,"defaultColumnFormatter");h(this,"typeFormatterMap");h(this,"columnFormatMap");h(this,"truncateNumbersWithPound");this.defaultColumnFormatter=new De,this.typeFormatterMap=new Map([[E.dataType.BOOLEAN,new Ie],[E.dataType.CHAR,new ve],[E.dataType.DATETIME,new H(t,n)],[E.dataType.DECIMAL,new w(t,r)],[E.dataType.INT,new L(t,s)],[E.dataType.STRING,new Oe]]),this.columnFormatMap=se.makeColumnFormatMap(e),this.truncateNumbersWithPound=o}static makeColumnFormatMap(t){return t==null?new Map:t.reduce((e,n)=>{const r=E.getNormalizedType(n.columnType);if(r===null)return e;e.has(r)||e.set(r,new Map);const s=e.get(r);return s==null||s.set(n.columnName,n.format),e},new Map)}static makeColumnFormattingRule(t,e,n){return{columnType:t,columnName:e,format:n}}getColumnFormatMapForType(t,e=!1){const n=E.getNormalizedType(t);if(n!==null)return e&&!this.columnFormatMap.has(n)&&this.columnFormatMap.set(n,new Map),this.columnFormatMap.get(n)}getColumnFormat(t,e){const n=this.getColumnFormatMapForType(t);return(n==null?void 0:n.get(e))??null}getColumnTypeFormatter(t){const e=E.getNormalizedType(t);let n=this.defaultColumnFormatter;return e&&(n=this.typeFormatterMap.get(e)??n),n}getFormattedString(t,e,n="",r){if(t==null)return"";const s=this.getColumnTypeFormatter(e),o=r||this.getColumnFormat(e,n);return s.format(t,o??void 0)}get timeZone(){var e;const t=this.typeFormatterMap.get(E.dataType.DATETIME);return(e=t==null?void 0:t.dhTimeZone)==null?void 0:e.id}}function Pe(f){if(f&&f.formatter){const{formatter:t}=f;return t}}function $e(f){return{timeZone:f==null?void 0:f.timeZone,defaultDateTimeFormatString:f==null?void 0:f.defaultDateTimeFormat,showTimeZone:f==null?void 0:f.showTimeZone,showTSeparator:f==null?void 0:f.showTSeparator}}function Re(f,t,e){const n=f.getColumnFormat(e,t);return n!=null&&(n.type===F.TYPE_CONTEXT_PRESET||n.type===F.TYPE_CONTEXT_CUSTOM)}const Ke={getColumnFormats:Pe,getDateTimeFormatterOptions:$e,isCustomColumnFormatDefined:Re},Le=V.module("@deephaven/jsapi-components.ConnectionBootstrap"),ae=v.createContext(null);function Ye({children:f}){const t=ne(),e=Ne(),[n,r]=v.useState(),[s,o]=v.useState();return v.useEffect(function(){let i=!1;async function l(){try{const u=await e.getAsIdeConnection();if(i)return;o(u)}catch(u){if(i)return;r(u)}}return l(),()=>{i=!0}},[t,e]),v.useEffect(function(){if(s==null)return;function i(u){const{detail:m}=u;Le.info("Shutdown",`${JSON.stringify(m)}`),r(`Server shutdown: ${m??"Unknown reason"}`)}return s.addEventListener(t.IdeConnection.EVENT_SHUTDOWN,i)},[t,s]),s==null||n!=null?T.jsx(pe,{"data-testid":"connection-bootstrap-loading",isLoading:s==null,errorMessage:n!=null?`${n}`:void 0}):T.jsx(ae.Provider,{value:s,children:f})}function Ge(){return z(ae,"No IdeConnection available in useConnection. Was code wrapped in ConnectionBootstrap or ConnectionContext.Provider?")}export{Ie as B,We as C,q as D,Ke as F,L as I,Q as P,Oe as S,E as T,je as a,se as b,ne as c,z as d,D as e,ye as f,Ue as g,re as h,Be as i,Ne as j,te as k,ve as l,H as m,w as n,De as o,F as p,Pe as q,$e as r,Re as s,J as t,Ge as u,Ye as v,ae as w};
2
+ //# sourceMappingURL=useConnection-2baa8601.js.map