@deephaven/code-studio 0.31.3 → 0.31.4

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,4 +1,4 @@
1
- import{A as b,F as v,E as K,C as h,R as de,T as bp,K as J,D as Ht,L as Se,M as $e,B as M,U as wp,V as ge,W as ra,X as Pn,J as Je,I as Ie,Y as mh,Z as ct,_ as xa,$ as Tp,a0 as vp,a1 as Ep,a2 as yp,a3 as pe,G as No,a4 as Hd,a5 as Oa,a6 as Rp,a7 as Ip,a8 as ph,a9 as Qe,aa as la,H as Fp,ab as Zr,Q as gh,S as Aa,ac as Ud,ad as Dp,ae as On,af as Np,ag as _p,ah as Mp,ai as kp,aj as aa,ak as xp,al as Op,am as Ap,an as Vd,ao as Lp,ap as Pp,aq as Bd,ar as Hp,as as Up,at as Vp,au as Bp,av as $p,aw as vt,ax as fh,ay as Gp,az as Ch,aA as Wp,aB as Sh,aC as zp,aD as qp,aE as Yp,aF as Kp,aG as Xp,aH as jp,aI as Zp,aJ as Qp,aK as Jp,aL as eg,aM as $d,aN as tg}from"./vendor.7d6152a1.js";import{P as ye,C as Hn,a as ng,u as sg,B as V,v as ig,b as og,c as rg,d as lg,e as Ui,T as Xe,f as da,g as ag,h as bh,i as La,L as as,j as Qr,k as ts,l as wh,m as ee,r as qe,M as Te,K as Fe,n as Gd,o as dg,p as cg,q as hg,G as ls,s as le,t as ug,w as sn,x as Os,D as Vi,y as mn,z as ns,A as Th,S as Bi,E as Jr,F as ut,H as ss,I as el,J as Mi,N as mg,O as pg,Q as Wd,R as Mr,U as zd,V as vh,W as ko,X as ki,Y as gg,Z as xo,_ as fg,$ as Eh,a0 as Cg,a1 as Sg,a2 as He,a3 as Pa,a4 as Jn,a5 as Ha,a6 as kr,a7 as Wn,a8 as bg,a9 as wg,aa as Tg,ab as vg,ac as Eg,ad as Ua,ae as yg,af as As,ag as qd,ah as Sn,ai as Oo,aj as is,ak as Va,al as Ba,am as yh,an as Rg,ao as tl,ap as Ig,aq as xr,ar as Fg,as as $a,at as Rh,au as ti,av as Dg,aw as Ng,ax as _g,ay as Mg,az as kg,aA as xg,aB as nl,aC as Yd,aD as Bl,aE as Og,aF as Ag,aG as Lg,aH as Ih,aI as sl,aJ as il,aK as Pg,aL as Hg,aM as ol,aN as Fh,aO as Ug,aP as Vg,aQ as Bg,aR as $g,aS as Dh,aT as Gg,aU as Wg,aV as zg,aW as qg,aX as Yg,aY as Kg,aZ as Xg,a_ as Ke,a$ as Kd,b0 as Nh,b1 as jg,b2 as Zg,b3 as Qg,b4 as Jg,b5 as Xd,b6 as Or,b7 as ef,b8 as _h,b9 as tf,ba as nf,bb as Mh,bc as sf,bd as ca,be as ha,bf as of,bg as rf,bh as lf,bi as af,bj as fn,bk as df,bl as cf,bm as hf,bn as uf,bo as mf,bp as pf,bq as gf,br as ff,bs as jd,bt as Cf,bu as Sf}from"./index.5b541cb5.js";import{e as os,l as Ti,K as cn,a as Zd,b as Ds,_ as bf,W as wf}from"./monaco.1292e04e.js";import{P as Ar,b as Tf,h as vf,p as Ef,o as yf,s as Rf,t as If,c as $l}from"./plotly.4a640e26.js";import"./helpers.162e09a8.js";function Ga({className:t,isFlipped:e,children:n,"data-testid":s}){const i=a=>{if(n.length!==2)throw new Error("CardFlip requires 2 children to function");return n[a]},o=b.exports.useRef(null),r=b.exports.useCallback(a=>{a.target===a.currentTarget&&document.body.classList.add("card-flip--is-flipping")},[]),l=b.exports.useCallback(a=>{a.target===a.currentTarget&&document.body.classList.remove("card-flip--is-flipping")},[]);return b.exports.useEffect(function(){if(!o.current)throw Error("ref undefined");o.current.addEventListener("transitionstart",r);const d=o.current;return function(){if(d!=null)return d.removeEventListener("transitionstart",r)}},[r]),v("div",{className:K(t,{"card-flip--show-front":e,"card-flip--show-back":!e}),"data-testid":s,children:[h("div",{className:"card-flip--back",children:i(0)}),h("div",{ref:o,className:"card-flip--front",onTransitionEnd:l,children:i(1)})]})}class rl{static isDark(e){const n=document.createElement("div");n.style.display="none",n.style.color=e;const s=getComputedStyle(document.body.appendChild(n)).color,i=s.match(/\d+/g);let o=[];if(i)o=i.map(l=>parseInt(l,10));else throw new Error(`Invalid color received. Got ${s}`);return document.body.removeChild(n),rl.getBrightness(o)<125}static getBrightness(e){return Math.round((e[0]*299+e[1]*587+e[2]*114)/1e3)}}function Ff(t,e){return t?t.closest(`.${e}`):null}const Df={getClosestByClassName:Ff};class ds{constructor(){this.pending=[],this.resolved=[]}add(e,n){const s=ye.makeCancelable(e,n);return this.pending.push(s),s.then(()=>{this.resolve(s)},()=>{this.resolve(s)}),s}remove(e){for(let n=0;n<this.pending.length;n+=1)if(this.pending[n]===e){this.pending.splice(n,1);return}}resolve(e){this.remove(e),this.resolved.push(e)}cancel(){const e=[...this.pending,...this.resolved];for(let n=0;n<e.length;n+=1)e[n].cancel();this.pending=[],this.resolved=[]}}function k(t){if(t==null)throw new Error("Value is null or undefined")}class jt{static join(e,n="and"){if(e==null||e.length===0)return"";if(e.length===1)return e[0];if(e.length===2)return`${e[0]} ${n} ${e[1]}`;const s=e.slice(0,e.length-1).join(", "),i=e[e.length-1];return`${s}, ${n} ${i}`}static toLower(e,n=!0){if(e==null){if(n)return"";throw new Error("Null string passed in to TextUtils.toLower")}return e.toLowerCase()}static sort(e,n,s=!0){return e<n?s?-1:1:e>n?s?1:-1:0}}class Di extends Error{constructor(){super(...arguments),this.isInvalid=!0}}class kh extends b.exports.Component{constructor(e){super(e),this.handleMenuClose=this.handleMenuClose.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.container=de.createRef(),this.openMenu=de.createRef(),this.state={actions:null,left:0,top:0}}componentDidMount(){this.container.current?.parentElement&&this.container.current.parentElement.addEventListener("contextmenu",this.handleContextMenu)}componentWillUnmount(){this.container.current?.parentElement&&this.container.current.parentElement.removeEventListener("contextmenu",this.handleContextMenu)}handleContextMenu(e){if(!Hn.isContextActionEvent(e)||!this.container.current||e.metaKey||e.ctrlKey)return;const n=Hn.getMenuItems(e.contextActions),s=this.container.current.getBoundingClientRect(),i=e.clientY-s.top,o=e.clientX-s.left;if(n.length===0){if(e.target===this.container.current){e.preventDefault(),this.setState({actions:null},()=>{const r=document.elementFromPoint(o,i),l=new MouseEvent("contextmenu",{clientX:e.clientX,clientY:e.clientY,bubbles:!0,cancelable:!0});r?.dispatchEvent(l)});return}return}e.preventDefault(),this.setState({actions:n,top:i,left:o})}handleMenuClose(e){e===this.openMenu.current&&this.setState({actions:null})}render(){let e=null;const{"data-testid":n}=this.props,{actions:s,top:i,left:o}=this.state;return s&&(e=h(ng,{ref:this.openMenu,actions:s,onMenuClosed:this.handleMenuClose,top:i,left:o,updatePosition:(r,l)=>{this.setState({top:r,left:l})},"data-testid":n})),h("div",{className:K("context-menu-root",{active:s}),ref:this.container,children:e})}}function ll(t){const e=b.exports.useRef();return b.exports.useEffect(function(){e.current=t}),e.current}function al({copy:t,kind:e="ghost",tooltip:n="Copy",className:s,"data-testid":i,children:o}){const[r,l]=sg();return h(V,{kind:e,className:s,"data-testid":i,icon:r?ig:og,tooltip:r?"Copied":n,onClick:()=>{l(typeof t=="function"?t():t)},children:o})}class qt{static reorder(e,n,s,i){const o=e===s?qt.adjustDestinationIndex(i,n):i,r=qt.removeItems(e,n);return s.splice(o,0,...r),r}static removeItems(e,n){const s=[],i=n.map((o,r)=>({range:o,index:r})).sort((o,r)=>r.range[0]-o.range[0]);for(let o=0;o<i.length;o+=1){const{range:r,index:l}=i[o],[a,d]=r;s[l]=e.splice(a,d-a+1)}return bp(s)}static adjustDestinationIndex(e,n){let s=e;for(let i=0;i<n.length;i+=1){const[o,r]=n[i];if(o>e)break;s-=Math.min(r,e-1)-o+1}return s}static startDragging(){document.documentElement.classList.add("drag-pointer-events-none")}static stopDragging(){document.documentElement.classList.remove("drag-pointer-events-none")}}function xh({on:t,id:e,className:n,isInvalid:s,disabled:i=!1,onClick:o,"data-testid":r}){return h("button",{type:"button",className:K("btn","btn-switch",n,{active:t},{"is-invalid":s}),id:e,onClick:o,disabled:i,"data-testid":r,children:h("div",{className:"handle"})})}function Qd(t){return t.isOn!==void 0}function Nf({item:t,onSelect:e=()=>{},"data-testid":n}){const{icon:s,subtitle:i,title:o}=t,r=b.exports.useMemo(()=>Qd(t)?()=>{t.onChange(!t.isOn)}:e,[t,e]);return v("div",{className:"btn btn-navigation-menu-item","data-testid":`menu-item-${o}`,onClick:r,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&r()},tabIndex:0,role:"menuitem",children:[s!==void 0&&h("div",{className:"icon",children:h(J,{icon:s})}),h("div",{className:"title",children:o}),i!==void 0&&h("div",{className:"shortcut",children:i}),h("div",{className:"accessory","data-testid":n,children:Qd(t)?h(xh,{on:t.isOn,onClick:l=>{l.stopPropagation(),r()}}):h(J,{icon:rg})})]})}function Oh({items:t,onSelect:e=()=>{},"data-testid":n}){return h("div",{className:"navigation-menu-view","data-testid":n,children:h("ul",{className:"navigation-menu-list",children:t.map((s,i)=>h("li",{children:h(Nf,{item:s,onSelect:()=>{e(i)}})},s.title))})})}function Jd({children:t,onBack:e,onClose:n,title:s,"data-testid":i}){return v("div",{className:"navigation-page","data-testid":i,children:[v("div",{className:"navigation-title-bar",children:[h("div",{className:"navigation-left-buttons",children:e!==void 0&&h(V,{kind:"ghost",className:"btn-back","data-testid":"btn-page-back",onClick:e,icon:lg,children:"Back"})}),h("div",{className:"navigation-title",children:s}),h("div",{className:"navigation-right-buttons",children:n!==void 0&&h(V,{kind:"ghost",className:"btn-close px-2 m-1","data-testid":"btn-page-close",onClick:n,icon:Ui,tooltip:"Close"})})]}),h("div",{className:"navigation-content",children:t})]})}function _f({children:t,"data-testid":e}){const n=b.exports.useMemo(()=>de.Children.toArray(t),[t]),s=ll(n),[i,o]=b.exports.useState(n[n.length-1]),[r,l]=b.exports.useState(null),[a,d]=b.exports.useState(null);b.exports.useEffect(function(){if(s===void 0||n===s)return;const p=n[n.length-1];n.length===s.length||s.length===0||r!==null||a!==null?r!==null&&p!==r?l(p):p!==a&&p!==i&&o(p):n.length>s.length?l(p):n.length<s.length&&(o(p),d(s[s.length-1]))},[n,s,r,a,i]);const c=b.exports.useCallback(()=>{o(r),l(null)},[r]),u=b.exports.useCallback(()=>{d(null)},[]);return v("div",{className:"navigation-stack",children:[h("div",{className:"main-view","data-testid":e,children:i}),h(Ht,{in:a!=null,timeout:Xe.transitionMidMs,classNames:"slide-right",onEntered:u,children:h(Se,{children:a!=null&&h("div",{className:"popping-view",children:a})})}),h(Ht,{in:r!=null,timeout:Xe.transitionMidMs,classNames:"slide-left",onEntered:c,children:h(Se,{children:r!=null&&h("div",{className:"pushing-view",children:r})})})]})}function Mf({children:t,disabled:e,value:n,"data-testid":s}){return h("option",{value:n,disabled:e,"data-testid":s,children:t})}function dl(t){const{children:e,disabled:n=!1,name:s,onChange:i,value:o="","data-testid":r}=t,[l]=b.exports.useState(s??$e());return h(Se,{children:de.Children.map(e,a=>a?de.cloneElement(a,{name:l,onChange:a.props.onChange??i,checked:o===a.props.value,disabled:a.props.disabled??n,"data-testid":r}):null)})}function kf({children:t,onBlur:e,onChange:n,className:s,defaultValue:i,name:o,value:r,disabled:l,"data-testid":a}){const d=b.exports.useCallback(c=>{n(c.target.value)},[n]);return h("select",{className:K("custom-select",s),onBlur:e,onChange:d,defaultValue:i,value:r,name:o,disabled:l,"data-testid":a,children:t})}const{dh:I}=globalThis,cl=M.exports.shape({name:M.exports.string.isRequired,type:M.exports.string.isRequired,description:M.exports.string,constituentType:M.exports.string}),Ah=M.exports.shape({not:M.exports.func.isRequired,and:M.exports.func.isRequired,or:M.exports.func.isRequired}),xf=M.exports.shape({asc:M.exports.func.isRequired,desc:M.exports.func.isRequired,abs:M.exports.func.isRequired,column:cl.isRequired,direction:M.exports.string.isRequired,isAbs:M.exports.bool.isRequired}),Of=M.exports.shape({columns:M.exports.arrayOf(cl).isRequired,customColumns:M.exports.arrayOf(M.exports.string).isRequired,filter:M.exports.arrayOf(Ah),addEventListener:M.exports.func.isRequired,removeEventListener:M.exports.func.isRequired,size:M.exports.number.isRequired,sort:M.exports.arrayOf(M.exports.any),copy:M.exports.func.isRequired,applyFilter:M.exports.func.isRequired,applySort:M.exports.func.isRequired,applyCustomColumns:M.exports.func.isRequired,description:M.exports.string}),Af=M.exports.shape({columns:M.exports.arrayOf(cl),filter:M.exports.arrayOf(M.exports.any),isExpanded:M.exports.func.isRequired,saveExpandedState:M.exports.func.isRequired,addEventListener:M.exports.func.isRequired,removeEventListener:M.exports.func.isRequired,size:M.exports.number.isRequired,sort:M.exports.arrayOf(M.exports.any),applyFilter:M.exports.func.isRequired,applySort:M.exports.func.isRequired}),Er=M.exports.shape({name:M.exports.string.isRequired,type:M.exports.string.isRequired}),Lf=M.exports.shape({created:M.exports.arrayOf(Er).isRequired,updated:M.exports.arrayOf(Er).isRequired,removed:M.exports.arrayOf(Er).isRequired}),Pf=M.exports.shape({groupingColumns:M.exports.arrayOf(M.exports.string),aggregations:M.exports.shape({}),includeConstituents:M.exports.bool,includeOriginalColumns:M.exports.bool,includeDescriptions:M.exports.bool}),Hf=M.exports.shape({addEventListener:M.exports.func.isRequired,removeEventListener:M.exports.func.isRequired,onLogMessage:M.exports.func,getTable:M.exports.func.isRequired,runCode:M.exports.func.isRequired});Object.freeze({Column:cl,FilterCondition:Ah,IdeSession:Hf,RollupConfig:Pf,Sort:xf,Table:Of,TreeTable:Af,VariableChanges:Lf,VariableDefinition:Er});function Lh({type:t}){switch(t){case I.VariableType.TABLE:case I.VariableType.TABLEMAP:case I.VariableType.TREETABLE:case I.VariableType.HIERARCHICALTABLE:return h(J,{icon:La});case I.VariableType.FIGURE:return h(J,{icon:bh});case I.VariableType.PANDAS:return h(J,{icon:ag});default:return h(J,{icon:da})}}class hl extends b.exports.Component{constructor(e){super(e),this.container=null}componentDidMount(){this.colorize()}colorize(){const{children:e}=this.props;this.container&&e!=null&&os.colorizeElement(this.container,{theme:"dh-dark"})}render(){const{children:e,language:n}=this.props;return h("div",{children:h("div",{"data-lang":n,ref:s=>{this.container=s},style:{pointerEvents:"none"},children:e})})}}class Ph{static get LANGUAGE_MAP(){return new Map([["python","Python"],["groovy","Groovy"],["scala","Scala"]])}}class xi{static hasComment(e){return e.comment!==void 0}static hasPattern(e){return e.pattern!==void 0}static hasOp(e){return e.op!==void 0}static parseArguments(e){return e==null||!(typeof e=="string"||e instanceof String)?[]:wp.parse(e).filter(n=>!this.hasComment(n)).map(n=>this.hasPattern(n)?n.pattern:this.hasOp(n)?n.op:`${n}`)}static formatTimestamp(e){if(e==null||!(e instanceof Date))return null;const n=`${e.getHours()}`.padStart(2,"0"),s=`${e.getMinutes()}`.padStart(2,"0"),i=`${e.getSeconds()}`.padStart(2,"0"),o=`${e.getMilliseconds()}`.padStart(3,"0");return`${n}:${s}:${i}.${o}`}static isTableType(e){return e===I.VariableType.TABLE||e===I.VariableType.TREETABLE||e===I.VariableType.HIERARCHICALTABLE}static isWidgetType(e){return e===I.VariableType.FIGURE||e===I.VariableType.OTHERWIDGET||e===I.VariableType.PANDAS}static isOpenableType(e){return xi.isTableType(e)||xi.isWidgetType(e)}static isFigureType(e){return e===I.VariableType.FIGURE}static isPandas(e){return e===I.VariableType.PANDAS}}function Hh({children:t}){return v("div",{className:"console-history-item-result",children:[h("div",{className:"console-history-gutter",children:"-"}),h("div",{className:"console-history-content",children:t})]})}Hh.propTypes={children:M.exports.node.isRequired};class Uh extends b.exports.Component{constructor(e){super(e),this.updateElapsed=this.updateElapsed.bind(this),this.startTime=Date.now(),this.state={elapsed:0}}componentDidMount(){this.timer=setInterval(this.updateElapsed,1e3)}componentWillUnmount(){this.timer&&clearInterval(this.timer),this.timer=void 0}updateElapsed(){this.setState({elapsed:Math.round((Date.now()-this.startTime)/1e3)})}render(){const{disabled:e,onCancelClick:n}=this.props,{elapsed:s}=this.state;return h("div",{className:K("console-history-result-in-progress",{disabled:e}),children:v("span",{className:"badge",children:[h(as,{}),"\xA0Running... ",Qr.formatElapsedTime(s),"\xA0",h(V,{className:"console-history-result-in-progress-cancel",kind:"ghost",icon:Ui,tooltip:"Cancel",onClick:n,disabled:e})]})})}}Uh.defaultProps={disabled:!1};const ua=class extends b.exports.PureComponent{constructor(t){super(t),this.handleKeyPress=this.handleKeyPress.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this.handleToggleError=this.handleToggleError.bind(this),this.handleMouseEnter=this.handleMouseEnter.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.mouseX=null,this.mouseY=null,this.isClicking=!1,this.state={isExpanded:!1,isTriggerHovered:!1}}handleKeyPress(t){switch(t.key){case"Enter":case" ":this.handleToggleError(),t.stopPropagation(),t.preventDefault();break}}handleMouseDown(t){this.mouseX=t.clientX,this.mouseY=t.clientY,this.isClicking=!0}handleMouseMove(t){this.mouseX!=null&&this.mouseY!=null?(Math.abs(t.clientX-this.mouseX)>=ua.mouseDragThreshold||Math.abs(t.clientY-this.mouseY)>=ua.mouseDragThreshold)&&(this.isClicking=!1):this.isClicking&&(this.isClicking=!1)}handleMouseUp(t){this.isClicking&&!t.shiftKey&&!t.metaKey&&!t.altKey&&this.handleToggleError(),this.mouseX=null,this.mouseY=null,this.isClicking=!1}handleToggleError(){this.setState(t=>({isExpanded:!t.isExpanded}))}handleMouseEnter(){this.setState({isTriggerHovered:!0})}handleMouseLeave(){this.setState({isTriggerHovered:!1})}render(){const{isExpanded:t,isTriggerHovered:e}=this.state,{message:n}=this.props;k(n);const s=n.indexOf(`
1
+ import{A as b,F as v,E as K,C as h,R as de,T as bp,K as J,D as Ht,L as Se,M as $e,B as M,U as wp,V as ge,W as ra,X as Pn,J as Je,I as Ie,Y as mh,Z as ct,_ as xa,$ as Tp,a0 as vp,a1 as Ep,a2 as yp,a3 as pe,G as No,a4 as Hd,a5 as Oa,a6 as Rp,a7 as Ip,a8 as ph,a9 as Qe,aa as la,H as Fp,ab as Zr,Q as gh,S as Aa,ac as Ud,ad as Dp,ae as On,af as Np,ag as _p,ah as Mp,ai as kp,aj as aa,ak as xp,al as Op,am as Ap,an as Vd,ao as Lp,ap as Pp,aq as Bd,ar as Hp,as as Up,at as Vp,au as Bp,av as $p,aw as vt,ax as fh,ay as Gp,az as Ch,aA as Wp,aB as Sh,aC as zp,aD as qp,aE as Yp,aF as Kp,aG as Xp,aH as jp,aI as Zp,aJ as Qp,aK as Jp,aL as eg,aM as $d,aN as tg}from"./vendor.7d6152a1.js";import{P as ye,C as Hn,a as ng,u as sg,B as V,v as ig,b as og,c as rg,d as lg,e as Ui,T as Xe,f as da,g as ag,h as bh,i as La,L as as,j as Qr,k as ts,l as wh,m as ee,r as qe,M as Te,K as Fe,n as Gd,o as dg,p as cg,q as hg,G as ls,s as le,t as ug,w as sn,x as Os,D as Vi,y as mn,z as ns,A as Th,S as Bi,E as Jr,F as ut,H as ss,I as el,J as Mi,N as mg,O as pg,Q as Wd,R as Mr,U as zd,V as vh,W as ko,X as ki,Y as gg,Z as xo,_ as fg,$ as Eh,a0 as Cg,a1 as Sg,a2 as He,a3 as Pa,a4 as Jn,a5 as Ha,a6 as kr,a7 as Wn,a8 as bg,a9 as wg,aa as Tg,ab as vg,ac as Eg,ad as Ua,ae as yg,af as As,ag as qd,ah as Sn,ai as Oo,aj as is,ak as Va,al as Ba,am as yh,an as Rg,ao as tl,ap as Ig,aq as xr,ar as Fg,as as $a,at as Rh,au as ti,av as Dg,aw as Ng,ax as _g,ay as Mg,az as kg,aA as xg,aB as nl,aC as Yd,aD as Bl,aE as Og,aF as Ag,aG as Lg,aH as Ih,aI as sl,aJ as il,aK as Pg,aL as Hg,aM as ol,aN as Fh,aO as Ug,aP as Vg,aQ as Bg,aR as $g,aS as Dh,aT as Gg,aU as Wg,aV as zg,aW as qg,aX as Yg,aY as Kg,aZ as Xg,a_ as Ke,a$ as Kd,b0 as Nh,b1 as jg,b2 as Zg,b3 as Qg,b4 as Jg,b5 as Xd,b6 as Or,b7 as ef,b8 as _h,b9 as tf,ba as nf,bb as Mh,bc as sf,bd as ca,be as ha,bf as of,bg as rf,bh as lf,bi as af,bj as fn,bk as df,bl as cf,bm as hf,bn as uf,bo as mf,bp as pf,bq as gf,br as ff,bs as jd,bt as Cf,bu as Sf}from"./index.98012d47.js";import{e as os,l as Ti,K as cn,a as Zd,b as Ds,_ as bf,W as wf}from"./monaco.1292e04e.js";import{P as Ar,b as Tf,h as vf,p as Ef,o as yf,s as Rf,t as If,c as $l}from"./plotly.4a640e26.js";import"./helpers.162e09a8.js";function Ga({className:t,isFlipped:e,children:n,"data-testid":s}){const i=a=>{if(n.length!==2)throw new Error("CardFlip requires 2 children to function");return n[a]},o=b.exports.useRef(null),r=b.exports.useCallback(a=>{a.target===a.currentTarget&&document.body.classList.add("card-flip--is-flipping")},[]),l=b.exports.useCallback(a=>{a.target===a.currentTarget&&document.body.classList.remove("card-flip--is-flipping")},[]);return b.exports.useEffect(function(){if(!o.current)throw Error("ref undefined");o.current.addEventListener("transitionstart",r);const d=o.current;return function(){if(d!=null)return d.removeEventListener("transitionstart",r)}},[r]),v("div",{className:K(t,{"card-flip--show-front":e,"card-flip--show-back":!e}),"data-testid":s,children:[h("div",{className:"card-flip--back",children:i(0)}),h("div",{ref:o,className:"card-flip--front",onTransitionEnd:l,children:i(1)})]})}class rl{static isDark(e){const n=document.createElement("div");n.style.display="none",n.style.color=e;const s=getComputedStyle(document.body.appendChild(n)).color,i=s.match(/\d+/g);let o=[];if(i)o=i.map(l=>parseInt(l,10));else throw new Error(`Invalid color received. Got ${s}`);return document.body.removeChild(n),rl.getBrightness(o)<125}static getBrightness(e){return Math.round((e[0]*299+e[1]*587+e[2]*114)/1e3)}}function Ff(t,e){return t?t.closest(`.${e}`):null}const Df={getClosestByClassName:Ff};class ds{constructor(){this.pending=[],this.resolved=[]}add(e,n){const s=ye.makeCancelable(e,n);return this.pending.push(s),s.then(()=>{this.resolve(s)},()=>{this.resolve(s)}),s}remove(e){for(let n=0;n<this.pending.length;n+=1)if(this.pending[n]===e){this.pending.splice(n,1);return}}resolve(e){this.remove(e),this.resolved.push(e)}cancel(){const e=[...this.pending,...this.resolved];for(let n=0;n<e.length;n+=1)e[n].cancel();this.pending=[],this.resolved=[]}}function k(t){if(t==null)throw new Error("Value is null or undefined")}class jt{static join(e,n="and"){if(e==null||e.length===0)return"";if(e.length===1)return e[0];if(e.length===2)return`${e[0]} ${n} ${e[1]}`;const s=e.slice(0,e.length-1).join(", "),i=e[e.length-1];return`${s}, ${n} ${i}`}static toLower(e,n=!0){if(e==null){if(n)return"";throw new Error("Null string passed in to TextUtils.toLower")}return e.toLowerCase()}static sort(e,n,s=!0){return e<n?s?-1:1:e>n?s?1:-1:0}}class Di extends Error{constructor(){super(...arguments),this.isInvalid=!0}}class kh extends b.exports.Component{constructor(e){super(e),this.handleMenuClose=this.handleMenuClose.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.container=de.createRef(),this.openMenu=de.createRef(),this.state={actions:null,left:0,top:0}}componentDidMount(){this.container.current?.parentElement&&this.container.current.parentElement.addEventListener("contextmenu",this.handleContextMenu)}componentWillUnmount(){this.container.current?.parentElement&&this.container.current.parentElement.removeEventListener("contextmenu",this.handleContextMenu)}handleContextMenu(e){if(!Hn.isContextActionEvent(e)||!this.container.current||e.metaKey||e.ctrlKey)return;const n=Hn.getMenuItems(e.contextActions),s=this.container.current.getBoundingClientRect(),i=e.clientY-s.top,o=e.clientX-s.left;if(n.length===0){if(e.target===this.container.current){e.preventDefault(),this.setState({actions:null},()=>{const r=document.elementFromPoint(o,i),l=new MouseEvent("contextmenu",{clientX:e.clientX,clientY:e.clientY,bubbles:!0,cancelable:!0});r?.dispatchEvent(l)});return}return}e.preventDefault(),this.setState({actions:n,top:i,left:o})}handleMenuClose(e){e===this.openMenu.current&&this.setState({actions:null})}render(){let e=null;const{"data-testid":n}=this.props,{actions:s,top:i,left:o}=this.state;return s&&(e=h(ng,{ref:this.openMenu,actions:s,onMenuClosed:this.handleMenuClose,top:i,left:o,updatePosition:(r,l)=>{this.setState({top:r,left:l})},"data-testid":n})),h("div",{className:K("context-menu-root",{active:s}),ref:this.container,children:e})}}function ll(t){const e=b.exports.useRef();return b.exports.useEffect(function(){e.current=t}),e.current}function al({copy:t,kind:e="ghost",tooltip:n="Copy",className:s,"data-testid":i,children:o}){const[r,l]=sg();return h(V,{kind:e,className:s,"data-testid":i,icon:r?ig:og,tooltip:r?"Copied":n,onClick:()=>{l(typeof t=="function"?t():t)},children:o})}class qt{static reorder(e,n,s,i){const o=e===s?qt.adjustDestinationIndex(i,n):i,r=qt.removeItems(e,n);return s.splice(o,0,...r),r}static removeItems(e,n){const s=[],i=n.map((o,r)=>({range:o,index:r})).sort((o,r)=>r.range[0]-o.range[0]);for(let o=0;o<i.length;o+=1){const{range:r,index:l}=i[o],[a,d]=r;s[l]=e.splice(a,d-a+1)}return bp(s)}static adjustDestinationIndex(e,n){let s=e;for(let i=0;i<n.length;i+=1){const[o,r]=n[i];if(o>e)break;s-=Math.min(r,e-1)-o+1}return s}static startDragging(){document.documentElement.classList.add("drag-pointer-events-none")}static stopDragging(){document.documentElement.classList.remove("drag-pointer-events-none")}}function xh({on:t,id:e,className:n,isInvalid:s,disabled:i=!1,onClick:o,"data-testid":r}){return h("button",{type:"button",className:K("btn","btn-switch",n,{active:t},{"is-invalid":s}),id:e,onClick:o,disabled:i,"data-testid":r,children:h("div",{className:"handle"})})}function Qd(t){return t.isOn!==void 0}function Nf({item:t,onSelect:e=()=>{},"data-testid":n}){const{icon:s,subtitle:i,title:o}=t,r=b.exports.useMemo(()=>Qd(t)?()=>{t.onChange(!t.isOn)}:e,[t,e]);return v("div",{className:"btn btn-navigation-menu-item","data-testid":`menu-item-${o}`,onClick:r,onKeyDown:l=>{(l.key==="Enter"||l.key===" ")&&r()},tabIndex:0,role:"menuitem",children:[s!==void 0&&h("div",{className:"icon",children:h(J,{icon:s})}),h("div",{className:"title",children:o}),i!==void 0&&h("div",{className:"shortcut",children:i}),h("div",{className:"accessory","data-testid":n,children:Qd(t)?h(xh,{on:t.isOn,onClick:l=>{l.stopPropagation(),r()}}):h(J,{icon:rg})})]})}function Oh({items:t,onSelect:e=()=>{},"data-testid":n}){return h("div",{className:"navigation-menu-view","data-testid":n,children:h("ul",{className:"navigation-menu-list",children:t.map((s,i)=>h("li",{children:h(Nf,{item:s,onSelect:()=>{e(i)}})},s.title))})})}function Jd({children:t,onBack:e,onClose:n,title:s,"data-testid":i}){return v("div",{className:"navigation-page","data-testid":i,children:[v("div",{className:"navigation-title-bar",children:[h("div",{className:"navigation-left-buttons",children:e!==void 0&&h(V,{kind:"ghost",className:"btn-back","data-testid":"btn-page-back",onClick:e,icon:lg,children:"Back"})}),h("div",{className:"navigation-title",children:s}),h("div",{className:"navigation-right-buttons",children:n!==void 0&&h(V,{kind:"ghost",className:"btn-close px-2 m-1","data-testid":"btn-page-close",onClick:n,icon:Ui,tooltip:"Close"})})]}),h("div",{className:"navigation-content",children:t})]})}function _f({children:t,"data-testid":e}){const n=b.exports.useMemo(()=>de.Children.toArray(t),[t]),s=ll(n),[i,o]=b.exports.useState(n[n.length-1]),[r,l]=b.exports.useState(null),[a,d]=b.exports.useState(null);b.exports.useEffect(function(){if(s===void 0||n===s)return;const p=n[n.length-1];n.length===s.length||s.length===0||r!==null||a!==null?r!==null&&p!==r?l(p):p!==a&&p!==i&&o(p):n.length>s.length?l(p):n.length<s.length&&(o(p),d(s[s.length-1]))},[n,s,r,a,i]);const c=b.exports.useCallback(()=>{o(r),l(null)},[r]),u=b.exports.useCallback(()=>{d(null)},[]);return v("div",{className:"navigation-stack",children:[h("div",{className:"main-view","data-testid":e,children:i}),h(Ht,{in:a!=null,timeout:Xe.transitionMidMs,classNames:"slide-right",onEntered:u,children:h(Se,{children:a!=null&&h("div",{className:"popping-view",children:a})})}),h(Ht,{in:r!=null,timeout:Xe.transitionMidMs,classNames:"slide-left",onEntered:c,children:h(Se,{children:r!=null&&h("div",{className:"pushing-view",children:r})})})]})}function Mf({children:t,disabled:e,value:n,"data-testid":s}){return h("option",{value:n,disabled:e,"data-testid":s,children:t})}function dl(t){const{children:e,disabled:n=!1,name:s,onChange:i,value:o="","data-testid":r}=t,[l]=b.exports.useState(s??$e());return h(Se,{children:de.Children.map(e,a=>a?de.cloneElement(a,{name:l,onChange:a.props.onChange??i,checked:o===a.props.value,disabled:a.props.disabled??n,"data-testid":r}):null)})}function kf({children:t,onBlur:e,onChange:n,className:s,defaultValue:i,name:o,value:r,disabled:l,"data-testid":a}){const d=b.exports.useCallback(c=>{n(c.target.value)},[n]);return h("select",{className:K("custom-select",s),onBlur:e,onChange:d,defaultValue:i,value:r,name:o,disabled:l,"data-testid":a,children:t})}const{dh:I}=globalThis,cl=M.exports.shape({name:M.exports.string.isRequired,type:M.exports.string.isRequired,description:M.exports.string,constituentType:M.exports.string}),Ah=M.exports.shape({not:M.exports.func.isRequired,and:M.exports.func.isRequired,or:M.exports.func.isRequired}),xf=M.exports.shape({asc:M.exports.func.isRequired,desc:M.exports.func.isRequired,abs:M.exports.func.isRequired,column:cl.isRequired,direction:M.exports.string.isRequired,isAbs:M.exports.bool.isRequired}),Of=M.exports.shape({columns:M.exports.arrayOf(cl).isRequired,customColumns:M.exports.arrayOf(M.exports.string).isRequired,filter:M.exports.arrayOf(Ah),addEventListener:M.exports.func.isRequired,removeEventListener:M.exports.func.isRequired,size:M.exports.number.isRequired,sort:M.exports.arrayOf(M.exports.any),copy:M.exports.func.isRequired,applyFilter:M.exports.func.isRequired,applySort:M.exports.func.isRequired,applyCustomColumns:M.exports.func.isRequired,description:M.exports.string}),Af=M.exports.shape({columns:M.exports.arrayOf(cl),filter:M.exports.arrayOf(M.exports.any),isExpanded:M.exports.func.isRequired,saveExpandedState:M.exports.func.isRequired,addEventListener:M.exports.func.isRequired,removeEventListener:M.exports.func.isRequired,size:M.exports.number.isRequired,sort:M.exports.arrayOf(M.exports.any),applyFilter:M.exports.func.isRequired,applySort:M.exports.func.isRequired}),Er=M.exports.shape({name:M.exports.string.isRequired,type:M.exports.string.isRequired}),Lf=M.exports.shape({created:M.exports.arrayOf(Er).isRequired,updated:M.exports.arrayOf(Er).isRequired,removed:M.exports.arrayOf(Er).isRequired}),Pf=M.exports.shape({groupingColumns:M.exports.arrayOf(M.exports.string),aggregations:M.exports.shape({}),includeConstituents:M.exports.bool,includeOriginalColumns:M.exports.bool,includeDescriptions:M.exports.bool}),Hf=M.exports.shape({addEventListener:M.exports.func.isRequired,removeEventListener:M.exports.func.isRequired,onLogMessage:M.exports.func,getTable:M.exports.func.isRequired,runCode:M.exports.func.isRequired});Object.freeze({Column:cl,FilterCondition:Ah,IdeSession:Hf,RollupConfig:Pf,Sort:xf,Table:Of,TreeTable:Af,VariableChanges:Lf,VariableDefinition:Er});function Lh({type:t}){switch(t){case I.VariableType.TABLE:case I.VariableType.TABLEMAP:case I.VariableType.TREETABLE:case I.VariableType.HIERARCHICALTABLE:return h(J,{icon:La});case I.VariableType.FIGURE:return h(J,{icon:bh});case I.VariableType.PANDAS:return h(J,{icon:ag});default:return h(J,{icon:da})}}class hl extends b.exports.Component{constructor(e){super(e),this.container=null}componentDidMount(){this.colorize()}colorize(){const{children:e}=this.props;this.container&&e!=null&&os.colorizeElement(this.container,{theme:"dh-dark"})}render(){const{children:e,language:n}=this.props;return h("div",{children:h("div",{"data-lang":n,ref:s=>{this.container=s},style:{pointerEvents:"none"},children:e})})}}class Ph{static get LANGUAGE_MAP(){return new Map([["python","Python"],["groovy","Groovy"],["scala","Scala"]])}}class xi{static hasComment(e){return e.comment!==void 0}static hasPattern(e){return e.pattern!==void 0}static hasOp(e){return e.op!==void 0}static parseArguments(e){return e==null||!(typeof e=="string"||e instanceof String)?[]:wp.parse(e).filter(n=>!this.hasComment(n)).map(n=>this.hasPattern(n)?n.pattern:this.hasOp(n)?n.op:`${n}`)}static formatTimestamp(e){if(e==null||!(e instanceof Date))return null;const n=`${e.getHours()}`.padStart(2,"0"),s=`${e.getMinutes()}`.padStart(2,"0"),i=`${e.getSeconds()}`.padStart(2,"0"),o=`${e.getMilliseconds()}`.padStart(3,"0");return`${n}:${s}:${i}.${o}`}static isTableType(e){return e===I.VariableType.TABLE||e===I.VariableType.TREETABLE||e===I.VariableType.HIERARCHICALTABLE}static isWidgetType(e){return e===I.VariableType.FIGURE||e===I.VariableType.OTHERWIDGET||e===I.VariableType.PANDAS}static isOpenableType(e){return xi.isTableType(e)||xi.isWidgetType(e)}static isFigureType(e){return e===I.VariableType.FIGURE}static isPandas(e){return e===I.VariableType.PANDAS}}function Hh({children:t}){return v("div",{className:"console-history-item-result",children:[h("div",{className:"console-history-gutter",children:"-"}),h("div",{className:"console-history-content",children:t})]})}Hh.propTypes={children:M.exports.node.isRequired};class Uh extends b.exports.Component{constructor(e){super(e),this.updateElapsed=this.updateElapsed.bind(this),this.startTime=Date.now(),this.state={elapsed:0}}componentDidMount(){this.timer=setInterval(this.updateElapsed,1e3)}componentWillUnmount(){this.timer&&clearInterval(this.timer),this.timer=void 0}updateElapsed(){this.setState({elapsed:Math.round((Date.now()-this.startTime)/1e3)})}render(){const{disabled:e,onCancelClick:n}=this.props,{elapsed:s}=this.state;return h("div",{className:K("console-history-result-in-progress",{disabled:e}),children:v("span",{className:"badge",children:[h(as,{}),"\xA0Running... ",Qr.formatElapsedTime(s),"\xA0",h(V,{className:"console-history-result-in-progress-cancel",kind:"ghost",icon:Ui,tooltip:"Cancel",onClick:n,disabled:e})]})})}}Uh.defaultProps={disabled:!1};const ua=class extends b.exports.PureComponent{constructor(t){super(t),this.handleKeyPress=this.handleKeyPress.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this.handleToggleError=this.handleToggleError.bind(this),this.handleMouseEnter=this.handleMouseEnter.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.mouseX=null,this.mouseY=null,this.isClicking=!1,this.state={isExpanded:!1,isTriggerHovered:!1}}handleKeyPress(t){switch(t.key){case"Enter":case" ":this.handleToggleError(),t.stopPropagation(),t.preventDefault();break}}handleMouseDown(t){this.mouseX=t.clientX,this.mouseY=t.clientY,this.isClicking=!0}handleMouseMove(t){this.mouseX!=null&&this.mouseY!=null?(Math.abs(t.clientX-this.mouseX)>=ua.mouseDragThreshold||Math.abs(t.clientY-this.mouseY)>=ua.mouseDragThreshold)&&(this.isClicking=!1):this.isClicking&&(this.isClicking=!1)}handleMouseUp(t){this.isClicking&&!t.shiftKey&&!t.metaKey&&!t.altKey&&this.handleToggleError(),this.mouseX=null,this.mouseY=null,this.isClicking=!1}handleToggleError(){this.setState(t=>({isExpanded:!t.isExpanded}))}handleMouseEnter(){this.setState({isTriggerHovered:!0})}handleMouseLeave(){this.setState({isTriggerHovered:!1})}render(){const{isExpanded:t,isTriggerHovered:e}=this.state,{message:n}=this.props;k(n);const s=n.indexOf(`
2
2
  `),i=s>-1;let o=n;i&&(o=n.slice(0,s));const r=n.slice(s),l=e?"error-btn-link error-btn-link--active":"error-btn-link";return v("div",{className:K("error-message",{expanded:t}),children:[i&&v(Se,{children:[h("div",{className:"error-gutter",children:h("button",{type:"button",onClick:this.handleToggleError,className:l,tabIndex:-1,children:h(J,{icon:t?ts:wh,transform:"left-3"})})}),v("div",{className:"error-content",children:[h("div",{className:"console-error-text-trigger",role:"button",tabIndex:0,onKeyPress:this.handleKeyPress,onMouseDown:this.handleMouseDown,onMouseMove:this.handleMouseMove,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,onMouseUp:this.handleMouseUp,children:o}),t?r:""]})]}),!i&&h("div",{className:"error-content",children:h("div",{className:"console-error-text",children:o})})]},"error")}};let Wa=ua;Wa.defaultProps={message:""};Wa.mouseDragThreshold=5;const ec=ee.module("ConsoleHistoryItem");class Vh extends b.exports.PureComponent{constructor(e){super(e),this.handleCancelClick=this.handleCancelClick.bind(this),this.handleObjectClick=this.handleObjectClick.bind(this)}handleObjectClick(e){ec.debug("handleObjectClick",e);const{openObject:n}=this.props;n(e)}handleCancelClick(){const{item:e}=this.props;e!=null&&e.cancelResult&&(ec.debug(`Cancelling command: ${e.command}`),e.cancelResult())}render(){const{disabled:e,item:n,language:s}=this.props,{disabledObjects:i,result:o}=n;let r=null;n.command!=null&&n.command!==""&&(r=v("div",{className:"console-history-item-command",children:[h("div",{className:"console-history-gutter",children:">"}),h("div",{className:"console-history-content",children:h(hl,{language:s,children:n.command})})]}));const l=[];let a=!1;if(o){const{error:c,message:u,changes:m}=o;if(m){const{created:p,updated:g}=m;[...p,...g].forEach(f=>{a=!0;const{title:C}=f,S=`${C}`,w=e===void 0||e||(i??[]).indexOf(S)>=0,T=h(V,{kind:"primary",onClick:()=>this.handleObjectClick(f),className:"btn-console-object",disabled:w,icon:h(Lh,{type:f.type}),children:C},S);l.push(T)})}if(c!=null&&n.command==null){let p=`${c.message??c}`;p||(p=c);const g=h(Wa,{message:p},"result-error");l.push(g)}if(u!==void 0&&u!==""){const p=h("div",{className:"log-message",children:u},"log-message");l.push(p)}}else{a=!0;const c=h(Uh,{onCancelClick:this.handleCancelClick,disabled:e},"in_progress");l.push(c)}let d=null;return l.length>0&&(d=h(Hh,{children:l})),v("div",{className:K("console-command-result",{"console-result-buttons":a}),children:[r,d]})}}Vh.defaultProps={disabled:!1};const Bh=class extends b.exports.Component{static itemKey(t,e){return`${t}.${e.command}.${e.result&&e.result.message}.${e.result&&e.result.error}`}render(){const{disabled:t,items:e,language:n,openObject:s}=this.props,i=[];for(let o=0;o<e.length;o+=1){const r=e[o],l=h(Vh,{disabled:t,item:r,openObject:s,language:n},Bh.itemKey(o,r));i.push(l)}return h("div",{className:"container-fluid console-history",children:i})}};let $h=Bh;$h.defaultProps={disabled:!1};const Uf={name:"Console",CLEAR:qe.createAndAdd({id:"CONSOLE.CLEAR",name:"Clear",shortcut:[Te.CTRL,Fe.L],macShortcut:[Te.CTRL,Fe.C]}),FOCUS_HISTORY:qe.createAndAdd({id:"CONSOLE.FOCUS_HISTORY",name:"Focus History",shortcut:[Te.CTRL,Fe.H],macShortcut:[Te.CTRL,Te.OPTION,Fe.H]})},Vf={name:"Command History",FOCUS_HISTORY:qe.createAndAdd({id:"COMMAND_HISTORY.FOCUS_HISTORY",name:"Focus History Search",shortcut:[Te.CTRL,Fe.H],macShortcut:[Te.CTRL,Te.OPTION,Fe.H]}),SEND_TO_CONSOLE:qe.createAndAdd({id:"COMMAND_HISTORY.SEND_TO_CONSOLE",name:"Send to Console",shortcut:[Fe.ENTER],macShortcut:[Fe.ENTER]}),SEND_TO_NOTEBOOK:qe.createAndAdd({id:"COMMAND_HISTORY.SEND_TO_NOTEBOOK",name:"Send to Notebook",shortcut:[Te.CTRL,Fe.ENTER],macShortcut:[Te.CMD,Fe.ENTER]}),RUN:qe.createAndAdd({id:"COMMAND_HISTORY.RUN",name:"Run",shortcut:[Te.ALT,Fe.R],macShortcut:[Te.OPTION,Fe.R]})},Bf={name:"Notebook",RUN:qe.createAndAdd({id:"NOTEBOOK.RUN",name:"Run",shortcut:[Te.ALT,Fe.R],macShortcut:[Te.OPTION,Fe.R]}),RUN_SELECTED:qe.createAndAdd({id:"NOTEBOOK.RUN_SELECTED",name:"Run Selected",shortcut:[Te.ALT,Te.SHIFT,Fe.R],macShortcut:[Te.OPTION,Te.SHIFT,Fe.R]}),FIND:qe.createAndAdd({id:"NOTEBOOK.FIND",name:"Find",shortcut:[Te.CTRL,Fe.F],macShortcut:[Te.CMD,Fe.F],isEditable:!1}),MINIMAP:qe.createAndAdd({id:"NOTEBOOK.MINIMAP",name:"Show Minimap",shortcut:[Te.ALT,Fe.M],macShortcut:[Te.OPTION,Fe.M]}),WORDWRAP:qe.createAndAdd({id:"NOTEBOOK.WORDWRAP",name:"Word Wrap",shortcut:[Te.ALT,Fe.Z],macShortcut:[Te.OPTION,Fe.Z]})},Pt={CONSOLE:Uf,COMMAND_HISTORY:Vf,NOTEBOOK:Bf},St=Object.freeze({FATAL:"FATAL",STDERR:"STDERR",ERROR:"ERROR",WARN:"WARN",STDOUT:"STDOUT",INFO:"INFO",DEBUG:"DEBUG",TRACE:"TRACE"}),$f="#2d2a2e",Gf="#fcfcfa",Wf="#fcd65b",zf="#b2b1b2",qf="#9edc6f",Yf="#76d9e4",Kf="#f95d84",Xf="#aa9af4",jf="#f95d84",Zf="#fcfcfa",Qf="#7c7b7c",we={"error-foreground":"#f95d84",background:$f,foreground:Gf,"line-height":"19px",string:Wf,"string-delim":"#929192",delimiter:zf,predefined:qf,keyword:Yf,storage:Kf,number:Xf,operator:jf,identifier:Zf,"namespace-identifier":"#f95d84","identifier-js":"#fcd65b",comment:Qf,"input-option-active-border":"#929192","focus-border":"rgba(72, 120, 234, 0.85)","input-background":"#555356","input-foreground":"#f0f0ee","input-border":"#929192","editor-line-number-foreground":"#929192","editor-selection-background":"#676368","editor-line-highlight-bg":"#373438","context-menu-background":"#555356","context-menu-foreground":"#f0f0ee","menu-selection-background":"#4878ea","log-date":"#929192","log-error":"#f95d84","log-info":"#76d9e4","log-stdout":"#f0f0ee","log-warn":"#fcd65b","log-debug":"#aa9af4","log-trace":"#9edc6f","editor-find-match-background":"#3c5595","editor-find-match-highlight-background":"#343e5d","editor-widget-background":"#403e41","input-option-active-background":"#4878ea","input-option-active-foreground":"#f0f0ee","editor-suggest-widget-background":"#403e41","editor-suggest-widget-border":"#5b5a5c","editor-suggest-widget-foreground":"#f0f0ee","editor-suggest-widget-selected-background":"#41475a","editor-suggest-widget-highlightForeground":"#4878ea","list-hover-background":"#555356"},Jf="python",eC={comments:{lineComment:"#",blockComment:["'''","'''"]},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"',notIn:["string"]},{open:"'",close:"'",notIn:["string","comment"]}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],onEnterRules:[{beforeText:/^\s*(?:def|class|for|if|elif|else|while|try|with|finally|except|async).*?:\s*$/,action:{indentAction:1}}],folding:{offSide:!0,markers:{start:/^\s*#region\b/,end:/^\s*#endregion\b/}}},tC={keywords:["and","del","from","not","while","as","elif","global","or","with","assert","else","if","pass","yield","break","except","import","print","exec","in","raise","continue","finally","is","return","for","try",":","=","isinstance","__debug__"],storage:["class","def","async","lambda"],operators:["+","-","*","**","/","//","%","<<",">>","&","|","^","~","<",">","<=",">=","==","!=","<>","+=","-=","*=","/","//=","%=","&=","|=","^=",">>=","<<=","**="],brackets:[{open:"{",close:"}",token:"delimiter.curly"},{open:"[",close:"]",token:"delimiter.square"},{open:"(",close:")",token:"delimiter.parenthesis"}],symbols:/[=><!~&|+\-*/^%]+/,delimiters:/[;=.@:,`]/,escapes:/\\(?:[abfnrtv\\"'\n\r]|x[0-9A-Fa-f]{2}|[0-7]{3}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8}|N\{\w+\})/,rawpre:/(?:[rR]|ur|Ur|uR|UR|br|Br|bR|BR)/,strpre:/(?:[buBU])/,tokenizer:{root:[[/@strpre?("""|''')/,{token:"string.delim",bracket:"@open",next:"@mstring.$1"}],[/@strpre?"([^"\\]|\\.)*$/,"string.invalid"],[/@strpre?'([^'\\]|\\.)*$/,"string.invalid"],[/@strpre?(["])/,{token:"string.delim",bracket:"@open",next:"@sstring.$1",nextEmbedded:"deephavenDb"}],[/@strpre?(["'])/,{token:"string.delim",bracket:"@open",next:"@string.$1"}],[/@rawpre("""|''')/,{token:"string.delim",bracket:"@open",next:"@mrawstring.$1"}],[/@rawpre"([^"\\]|\\.)*$/,"string.invalid"],[/@rawpre'([^'\\]|\\.)*$/,"string.invalid"],[/@rawpre(["'])/,{token:"string.delim",bracket:"@open",next:"@rawstring.$1"}],[/__[\w$]*/,"predefined"],[/[a-z_$][\w$]*/,{cases:{"@keywords":"keyword","@storage":"storage","@default":"identifier"}}],[/[A-Z][\w]*/,{cases:{"~[A-Z0-9_]+":"constructor.identifier","@default":"namespace.identifier"}}],{include:"@whitespace"},[/[{}()[\]]/,"@brackets"],[/@symbols/,{cases:{"@keywords":"keyword","@operators":"operator","@default":""}}],[/\d*\.\d+([eE][-+]?\d+)?/,"number.float"],[/0[xX][0-9a-fA-F]+[lL]?/,"number.hex"],[/0[bB][0-1]+[lL]?/,"number.binary"],[/(0[oO][0-7]+|0[0-7]+)[lL]?/,"number.octal"],[/(0|[1-9]\d*)[lL]?/,"number"],[":",{token:"keyword",bracket:"@open"}],[/@delimiters/,{cases:{"@keywords":"keyword","@default":"delimiter"}}]],comment:[[/[^/*]+/,"comment"],[/\/\*/,"comment","@push"],["\\*/","comment","@pop"],[/[/*]/,"comment"]],mstring:[{include:"@strcontent"},[/"""|'''/,{cases:{"$#==$S2":{token:"string.delim",bracket:"@close",next:"@pop"},"@default":{token:"string"}}}],[/["']/,"string"],[/./,"string.invalid"]],sstring:[{include:"@strcontent"},[/["]/,{token:"string.delim",bracket:"@close",next:"@pop",nextEmbedded:"@pop"}],[/./,"string.invalid"]],string:[{include:"@strcontent"},[/[']/,{token:"string.delim",bracket:"@close",next:"@pop"}],[/./,"string.invalid"]],strcontent:[[/[^\\"']+/,"string"],[/\\$/,"string.escape"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"]],mrawstring:[{include:"@rawstrcontent"},[/"""|'''/,{cases:{"$#==$S2":{token:"string.delim",bracket:"@close",next:"@pop"},"@default":{token:"string"}}}],[/["']/,"string"],[/./,"string.invalid"]],rawstring:[{include:"@rawstrcontent"},[/["']/,{cases:{"$#==$S2":{token:"string.delim",bracket:"@close",next:"@pop"},"@default":{token:"string"}}}],[/./,"string.invalid"]],rawstrcontent:[[/[^\\"']+/,"string"],[/\\["']/,"string"],[/\\u[0-9A-Fa-f]{4}/,"string.escape"],[/\\/,"string"]],whitespace:[[/\s+/,"white"],[/(^#.*$)/,"comment"],[/'''/,"string","@endDocString"],[/"""/,"string","@endDblDocString"]],endDocString:[[/[^']+/,"string"],[/\\'/,"string"],[/'''/,"string","@popall"],[/'/,"string"]],endDblDocString:[[/[^"]+/,"string"],[/\\"/,"string"],[/"""/,"string","@popall"],[/"/,"string"]]}},nC={id:Jf,conf:eC,language:tC},sC="groovy",iC={comments:{lineComment:"//",blockComment:["/*","*/"]},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"',notIn:["string"]},{open:"'",close:"'",notIn:["string","comment"]}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],onEnterRules:[{beforeText:/^\s*(?:def|class|for|if|elif|else|while|try|with|finally|except|async).*?:\s*$/,action:{indentAction:1}}],folding:{offSide:!0,markers:{start:/^\s*#region\b/,end:/^\s*#endregion\b/}}},oC={keywords:["and","del","from","not","while","as","elif","global","or","with","assert","else","if","pass","yield","break","except","import","print","println","class","exec","in","raise","continue","finally","is","return","def","for","lambda","try",":","=","isinstance","__debug__"],operators:["+","-","*","**","/","//","%","<<",">>","&","|","^","~","<",">","<=",">=","==","!=","<>","+=","-=","*=","/","//=","%=","&=","|=","^=",">>=","<<=","**="],brackets:[{open:"{",close:"}",token:"delimiter.curly"},{open:"[",close:"]",token:"delimiter.square"},{open:"(",close:")",token:"delimiter.parenthesis"}],symbols:/[=><!~&|+\-*/^%]+/,delimiters:/[;=.@:,`]/,escapes:/\\(?:[abfnrtv\\"'\n\r]|x[0-9A-Fa-f]{2}|[0-7]{3}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8}|N\{\w+\})/,rawpre:/(?:[rR]|ur|Ur|uR|UR|br|Br|bR|BR)/,strpre:/(?:[buBU])/,tokenizer:{root:[[/@strpre?("""|''')/,{token:"string.delim",bracket:"@open",next:"@mstring.$1"}],[/@strpre?"([^"\\]|\\.)*$/,"string.invalid"],[/@strpre?'([^'\\]|\\.)*$/,"string.invalid"],[/@strpre?(["])/,{token:"string.delim",bracket:"@open",next:"@sstring.$1",nextEmbedded:"deephavenDb"}],[/@strpre?(["'])/,{token:"string.delim",bracket:"@open",next:"@string.$1"}],[/@rawpre("""|''')/,{token:"string.delim",bracket:"@open",next:"@mrawstring.$1"}],[/@rawpre"([^"\\]|\\.)*$/,"string.invalid"],[/@rawpre'([^'\\]|\\.)*$/,"string.invalid"],[/@rawpre(["'])/,{token:"string.delim",bracket:"@open",next:"@rawstring.$1"}],[/__[\w$]*/,"predefined"],[/[a-z_$][\w$]*/,{cases:{"@keywords":"keyword","@default":"identifier"}}],[/[A-Z][\w]*/,{cases:{"~[A-Z0-9_]+":"constructor.identifier","@default":"namespace.identifier"}}],{include:"@whitespace"},[/[{}()[\]]/,"@brackets"],[/@symbols/,{cases:{"@keywords":"keyword","@operators":"operator","@default":""}}],[/\d*\.\d+([eE][-+]?\d+)?/,"number.float"],[/0[xX][0-9a-fA-F]+[lL]?/,"number.hex"],[/0[bB][0-1]+[lL]?/,"number.binary"],[/(0[oO][0-7]+|0[0-7]+)[lL]?/,"number.octal"],[/(0|[1-9]\d*)[lL]?/,"number"],[":",{token:"keyword",bracket:"@open"}],[/@delimiters/,{cases:{"@keywords":"keyword","@default":"delimiter"}}]],mstring:[{include:"@strcontent"},[/"""|'''/,{cases:{"$#==$S2":{token:"string.delim",bracket:"@close",next:"@pop"},"@default":{token:"string"}}}],[/["']/,"string"],[/./,"string.invalid"]],sstring:[{include:"@strcontent"},[/["]/,{token:"string.delim",bracket:"@close",next:"@pop",nextEmbedded:"@pop"}],[/./,"string.invalid"]],string:[{include:"@strcontent"},[/[']/,{token:"string.delim",bracket:"@close",next:"@pop"}],[/./,"string.invalid"]],strcontent:[[/[^\\"']+/,"string"],[/\\$/,"string.escape"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"]],mrawstring:[{include:"@rawstrcontent"},[/"""|'''/,{cases:{"$#==$S2":{token:"string.delim",bracket:"@close",next:"@pop"},"@default":{token:"string"}}}],[/["']/,"string"],[/./,"string.invalid"]],rawstring:[{include:"@rawstrcontent"},[/["']/,{cases:{"$#==$S2":{token:"string.delim",bracket:"@close",next:"@pop"},"@default":{token:"string"}}}],[/./,"string.invalid"]],rawstrcontent:[[/[^\\"']+/,"string"],[/\\["']/,"string"],[/\\u[0-9A-Fa-f]{4}/,"string.escape"],[/\\/,"string"]],whitespace:[[/[ \t\r\n]+/,""],[/\/\*\*(?!\/)/,"comment.doc","@doccomment"],[/\/\*/,"comment","@comment"],[/\/\/.*$/,"comment"]],comment:[[/[^/*]+/,"comment"],[/\*\//,"comment","@pop"],[/[/*]/,"comment"]],doccomment:[[/[^/*]+/,"comment.doc"],[/\*\//,"comment.doc","@pop"],[/[/*]/,"comment.doc"]]}},rC={id:sC,conf:iC,language:oC},lC="scala",aC={wordPattern:/(unary_[@~!#%^&*()\-=+\\|:<>/?]+)|([a-zA-Z_$][\w$]*?_=)|(`[^`]+`)|([a-zA-Z_$][\w$]*)/g,comments:{lineComment:"//",blockComment:["/*","*/"]},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],folding:{markers:{start:/^\s*\/\/\s*(?:(?:#?region\b)|(?:<editor-fold\b))/,end:/^\s*\/\/\s*(?:(?:#?endregion\b)|(?:<\/editor-fold>))/}}},dC={keywords:["asInstanceOf","catch","class","classOf","def","do","else","extends","finally","for","foreach","forSome","if","import","isInstanceOf","macro","match","new","object","package","return","throw","trait","try","type","until","val","var","while","with","yield","given","enum","then"],softKeywords:["as","export","extension","end","derives","on"],constants:["true","false","null","this","super"],modifiers:["abstract","final","implicit","lazy","override","private","protected","sealed"],softModifiers:["inline","opaque","open","transparent","using"],name:/(?:[a-z_$][\w$]*|`[^`]+`)/,type:/(?:[A-Z][\w$]*)/,symbols:/[=><!~?:&|+\-*/^\\%@#]+/,digits:/\d+(_+\d+)*/,hexdigits:/[[0-9a-fA-F]+(_+[0-9a-fA-F]+)*/,escapes:/\\(?:[btnfr\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,fstring_conv:/[bBhHsScCdoxXeEfgGaAt]|[Tn](?:[HIklMSLNpzZsQ]|[BbhAaCYyjmde]|[RTrDFC])/,tokenizer:{root:[[/\braw"""/,{token:"string.quote",bracket:"@open",next:"@rawstringt"}],[/\braw"/,{token:"string.quote",bracket:"@open",next:"@rawstring"}],[/\bs"""/,{token:"string.quote",bracket:"@open",next:"@sstringt"}],[/\bs"/,{token:"string.quote",bracket:"@open",next:"@sstring"}],[/\bf""""/,{token:"string.quote",bracket:"@open",next:"@fstringt"}],[/\bf"/,{token:"string.quote",bracket:"@open",next:"@fstring"}],[/"""/,{token:"string.quote",bracket:"@open",next:"@stringt"}],[/"/,{token:"string.quote",bracket:"@open",next:"@string"}],[/(@digits)[eE]([-+]?(@digits))?[fFdD]?/,"number.float","@allowMethod"],[/(@digits)\.(@digits)([eE][-+]?(@digits))?[fFdD]?/,"number.float","@allowMethod"],[/0[xX](@hexdigits)[Ll]?/,"number.hex","@allowMethod"],[/(@digits)[fFdD]/,"number.float","@allowMethod"],[/(@digits)[lL]?/,"number","@allowMethod"],[/\b_\*/,"key"],[/\b(_)\b/,"keyword","@allowMethod"],[/\bimport\b/,"keyword","@import"],[/\b(case)([ \t]+)(class)\b/,["keyword.modifier","white","keyword"]],[/\bcase\b/,"keyword","@case"],[/\bva[lr]\b/,"keyword","@vardef"],[/\b(def)([ \t]+)((?:unary_)?@symbols|@name(?:_=)|@name)/,["keyword","white","identifier"]],[/@name(?=[ \t]*:(?!:))/,"variable"],[/(\.)(@name|@symbols)/,[{token:"operator"},{token:"@rematch",next:"@allowMethod"}]],[/([{(])(\s*)(@name(?=\s*=>))/,["@brackets","white","variable"]],[/@name/,{cases:{"@keywords":"keyword","@softKeywords":"keyword","@modifiers":"keyword.modifier","@softModifiers":"keyword.modifier","@constants":{token:"constant",next:"@allowMethod"},"@default":{token:"identifier",next:"@allowMethod"}}}],[/@type/,"type","@allowMethod"],{include:"@whitespace"},[/@[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*/,"annotation"],[/[{(]/,"@brackets"],[/[})]/,"@brackets","@allowMethod"],[/\[/,"operator.square"],[/](?!\s*(?:va[rl]|def|type)\b)/,"operator.square","@allowMethod"],[/]/,"operator.square"],[/([=-]>|<-|>:|<:|:>|<%)(?=[\s\w()[\]{},."'`])/,"keyword"],[/@symbols/,"operator"],[/[;,.]/,"delimiter"],[/'[a-zA-Z$][\w$]*(?!')/,"attribute.name"],[/'[^\\']'/,"string","@allowMethod"],[/(')(@escapes)(')/,[{token:"string"},{token:"string.escape"},{token:"string",next:"@allowMethod"}]],[/'/,"string.invalid"]],import:[[/;/,"delimiter","@pop"],[/^|$/,"","@pop"],[/[ \t]+/,"white"],[/[\n\r]+/,"white","@pop"],[/\/\*/,"comment","@comment"],[/@name|@type/,"type"],[/[(){}]/,"@brackets"],[/[[\]]/,"operator.square"],[/[.,]/,"delimiter"]],allowMethod:[[/^|$/,"","@pop"],[/[ \t]+/,"white"],[/[\n\r]+/,"white","@pop"],[/\/\*/,"comment","@comment"],[/(?==>[\s\w([{])/,"keyword","@pop"],[/(@name|@symbols)(?=[ \t]*[[({"'`]|[ \t]+(?:[+-]?\.?\d|\w))/,{cases:{"@keywords":{token:"keyword",next:"@pop"},"->|<-|>:|<:|<%":{token:"keyword",next:"@pop"},"@default":{token:"@rematch",next:"@pop"}}}],["","","@pop"]],comment:[[/[^/*]+/,"comment"],[/\/\*/,"comment","@push"],[/\*\//,"comment","@pop"],[/[/*]/,"comment"]],case:[[/\b_\*/,"key"],[/\b(_|true|false|null|this|super)\b/,"keyword","@allowMethod"],[/\bif\b|=>/,"keyword","@pop"],[/`[^`]+`/,"identifier","@allowMethod"],[/@name/,"variable","@allowMethod"],[/:::?|\||@(?![a-z_$])/,"keyword"],{include:"@root"}],vardef:[[/\b_\*/,"key"],[/\b(_|true|false|null|this|super)\b/,"keyword"],[/@name/,"variable"],[/:::?|\||@(?![a-z_$])/,"keyword"],[/=|:(?!:)/,"operator","@pop"],[/$/,"white","@pop"],{include:"@root"}],string:[[/[^\\"\n\r]+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/"/,{token:"string.quote",bracket:"@close",switchTo:"@allowMethod"}]],stringt:[[/[^\\"\n\r]+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/"(?=""")/,"string"],[/"""/,{token:"string.quote",bracket:"@close",switchTo:"@allowMethod"}],[/"/,"string"]],fstring:[[/@escapes/,"string.escape"],[/"/,{token:"string.quote",bracket:"@close",switchTo:"@allowMethod"}],[/\$\$/,"string"],[/(\$)([a-z_]\w*)/,["operator","identifier"]],[/\$\{/,"operator","@interp"],[/%%/,"string"],[/(%)([-#+ 0,(])(\d+|\.\d+|\d+\.\d+)(@fstring_conv)/,["metatag","keyword.modifier","number","metatag"]],[/(%)(\d+|\.\d+|\d+\.\d+)(@fstring_conv)/,["metatag","number","metatag"]],[/(%)([-#+ 0,(])(@fstring_conv)/,["metatag","keyword.modifier","metatag"]],[/(%)(@fstring_conv)/,["metatag","metatag"]],[/./,"string"]],fstringt:[[/@escapes/,"string.escape"],[/"(?=""")/,"string"],[/"""/,{token:"string.quote",bracket:"@close",switchTo:"@allowMethod"}],[/\$\$/,"string"],[/(\$)([a-z_]\w*)/,["operator","identifier"]],[/\$\{/,"operator","@interp"],[/%%/,"string"],[/(%)([-#+ 0,(])(\d+|\.\d+|\d+\.\d+)(@fstring_conv)/,["metatag","keyword.modifier","number","metatag"]],[/(%)(\d+|\.\d+|\d+\.\d+)(@fstring_conv)/,["metatag","number","metatag"]],[/(%)([-#+ 0,(])(@fstring_conv)/,["metatag","keyword.modifier","metatag"]],[/(%)(@fstring_conv)/,["metatag","metatag"]],[/./,"string"]],sstring:[[/@escapes/,"string.escape"],[/"/,{token:"string.quote",bracket:"@close",switchTo:"@allowMethod"}],[/\$\$/,"string"],[/(\$)([a-z_]\w*)/,["operator","identifier"]],[/\$\{/,"operator","@interp"],[/./,"string"]],sstringt:[[/@escapes/,"string.escape"],[/"(?=""")/,"string"],[/"""/,{token:"string.quote",bracket:"@close",switchTo:"@allowMethod"}],[/\$\$/,"string"],[/(\$)([a-z_]\w*)/,["operator","identifier"]],[/\$\{/,"operator","@interp"],[/./,"string"]],interp:[[/{/,"operator","@push"],[/}/,"operator","@pop"],{include:"@root"}],rawstring:[[/[^"]/,"string"],[/"/,{token:"string.quote",bracket:"@close",switchTo:"@allowMethod"}]],rawstringt:[[/[^"]/,"string"],[/"(?=""")/,"string"],[/"""/,{token:"string.quote",bracket:"@close",switchTo:"@allowMethod"}],[/"/,"string"]],whitespace:[[/[ \t\r\n]+/,"white"],[/\/\*/,"comment","@comment"],[/\/\/.*$/,"comment"]]}},cC={id:lC,conf:aC,language:dC},hC="deephavenDb",uC={comments:{lineComment:"#",blockComment:["'''","'''"]},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"',notIn:["string"]},{open:"'",close:"'",notIn:["string","comment"]}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],onEnterRules:[{beforeText:/^\s*(?:def|class|for|if|elif|else|while|try|with|finally|except|async).*?:\s*$/,action:{indentAction:1}}],folding:{offSide:!0,markers:{start:/^\s*#region\b/,end:/^\s*#endregion\b/}}},mC={tokenPostfix:".js",keywords:["boolean","break","byte","case","catch","char","class","const","continue","debugger","default","delete","do","double","else","enum","export","extends","false","final","finally","float","for","function","goto","if","implements","import","in","instanceof","int","interface","long","native","new","null","package","private","protected","public","return","short","static","super","switch","synchronized","this","throw","throws","transient","true","try","typeof","var","void","volatile","while","with"],builtins:["define","require","window","document","undefined"],operators:["=",">","<","!","~","?",":","==","<=",">=","!=","&&","||","++","--","+","-","*","/","&","|","^","%","<<",">>",">>>","+=","-=","*=","/=","&=","|=","^=","%=","<<=",">>=",">>>="],brackets:[{open:"{",close:"}",token:"delimiter.curly"},{open:"[",close:"]",token:"delimiter.bracket"},{open:"(",close:")",token:"delimiter.parenthesis"}],symbols:/[~!@#%\^&*-+=|\\:`<>.?\/]+/,escapes:/\\(?:[btnfr\\"']|[0-7][0-7]?|[0-3][0-7]{2})/,exponent:/[eE][\-+]?[0-9]+/,regexpctl:/[(){}\[\]\$\^|\-*+?\.]/,regexpesc:/\\(?:[bBdDfnrstvwWn0\\\/]|@regexpctl|c[A-Z]|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4})/,tokenizer:{root:[[/([a-zA-Z_\$][\w\$]*)(\s*)(:?)/,{cases:{"$1@keywords":["keyword","white","delimiter"],$3:["key.identifier","white","delimiter"],"$1@builtins":["predefined.identifier","white","delimiter"],"@default":["identifier","white","delimiter"]}}],{include:"@whitespace"},[/\/(?=([^\\\/]|\\.)+\/)/,{token:"regexp.slash",bracket:"@open",next:"@regexp"}],[/[{}()\[\]]/,"@brackets"],[/[;,.]/,"delimiter"],[/@symbols/,{cases:{"@operators":"operator","@default":""}}],[/\d+\.\d*(@exponent)?/,"number.float"],[/\.\d+(@exponent)?/,"number.float"],[/\d+@exponent/,"number.float"],[/0[xX][\da-fA-F]+/,"number.hex"],[/0[0-7]+/,"number.octal"],[/\d+/,"number"],[/"([^"\\]|\\.)*$/,"string.invalid"],[/'([^'\\]|\\.)*$/,"string.invalid"],[/"/,"string",'@string."'],[/'/,"string","@string.'"]],whitespace:[[/[ \t\r\n]+/,"white"],[/\/\*/,"comment","@comment"],[/\/\/.*$/,"comment"]],comment:[[/[^\/*]+/,"comment"],[/\/\*/,"comment.invalid"],["\\*/","comment","@pop"],[/[\/*]/,"comment"]],string:[[/[^\\"']+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/["']/,{cases:{"$#==$S2":{token:"string",next:"@pop"},"@default":"string"}}]],regexp:[[/(\{)(\d+(?:,\d*)?)(\})/,["@brackets.regexp.escape.control","regexp.escape.control","@brackets.regexp.escape.control"]],[/(\[)(\^?)(?=(?:[^\]\\\/]|\\.)+)/,[{token:"@brackets.regexp.escape.control"},{token:"regexp.escape.control",next:"@regexrange"}]],[/(\()(\?:|\?=|\?!)/,["@brackets.regexp.escape.control","regexp.escape.control"]],[/[()]/,"@brackets.regexp.escape.control"],[/@regexpctl/,"regexp.escape.control"],[/[^\\\/]/,"regexp"],[/@regexpesc/,"regexp.escape"],[/\\\./,"regexp.invalid"],["/",{token:"regexp.slash",bracket:"@close"},"@pop"]],regexrange:[[/-/,"regexp.escape.control"],[/\^/,"regexp.invalid"],[/@regexpesc/,"regexp.escape"],[/[^\]]/,"regexp"],[/\]/,"@brackets.regexp.escape.control","@pop"]]}},pC={id:hC,conf:uC,language:mC},gC="log",fC={},CC={tokenizer:{root:[[/ FATAL[\s\S]*/,{token:"error",next:"@error"}],[/ ERROR[\s\S]*/,{token:"error",next:"@error"}],[/ STDERR[\s\S]*/,{token:"error",next:"@error"}],[/ STDOUT.*/,{token:"stdout",next:"@stdout"}],[/ INFO[\s\S]*/,{token:"info",next:"@info"}],[/ WARN.*/,{token:"warn",next:"@warn"}],[/ TRACE[\s\S]*/,{token:"trace",next:"@trace"}],[/ DEBUG[.\s\S]*/,{token:"debug",next:"@debug"}],[/^\d{2}:\d{2}:\d{2}.\d{3}/,"date"]],error:[{include:"@body"}],info:[{include:"@body"}],warn:[{include:"@body"}],stdout:[{include:"@body"}],trace:[{include:"@body"}],debug:[{include:"@body"}],body:[[/^\d{2}:\d{2}:\d{2}.\d{3}/,{token:"date",next:"@pop"}],[/[\s\S]*/,{token:"$S0"}]]}},SC={id:gC,conf:fC,language:CC},Dn=ee.module("MonacoUtils");class lt{static init({getWorker:e}={}){Dn.debug("Initializing Monaco..."),e!==void 0&&lt.registerGetWorker(e);const{registerLanguages:n,removeHashtag:s}=lt,i=[{token:"",foreground:s(we.foreground)},{token:"string",foreground:s(we.string)},{token:"string.delim",foreground:s(we["string-delim"])},{token:"keyword",foreground:s(we.keyword)},{token:"identifier.js",foreground:s(we["identifier-js"])},{token:"delimiter",foreground:s(we.delimiter)},{token:"comment",foreground:s(we.comment)},{token:"number",foreground:s(we.number)},{token:"storage",foreground:s(we.storage)},{token:"identifier",foreground:s(we.identifier)},{token:"namespace.identifier",foreground:s(we["namespace-identifier"])},{token:"operator",foreground:s(we.operator)},{token:"predefined",foreground:s(we.predefined)},{token:"error.log",foreground:we["log-error"].substring(1)},{token:"warn.log",foreground:s(we["log-warn"])},{token:"info.log",foreground:s(we["log-info"])},{token:"stdout.log",foreground:s(we["log-stdout"])},{token:"trace.log",foreground:s(we["log-trace"])},{token:"debug.log",foreground:s(we["log-debug"])},{token:"date.log",foreground:s(we["log-date"])}],o={errorForeground:we["error-foreground"],"inputOption.activeBorder":we["input-option-active-border"],"editor.background":we.background,"editor.foreground":we.foreground,"editor.lineHighlightBackground":we["editor-line-highlight-bg"],"editorLineNumber.foreground":we["editor-line-number-foreground"],"editor.selectionBackground":we["editor-selection-background"],"editor.findMatchBackground":we["editor-find-match-background"],"editor.findMatchHighlightBackground":we["editor-find-match-highlight-background"],"editorSuggestWidget.background":we["editor-suggest-widget-background"],"editorSuggestWidget.border":we["editor-suggest-widget-border"],"editorSuggestWidget.foreground":we["editor-suggest-widget-foreground"],"editorSuggestWidget.selectedBackground":we["editor-suggest-widget-selected-background"],"editorSuggestWidget.highlightForeground":we["editor-suggest-widget-highlightForeground"],"list.hoverBackground":we["list-hover-background"],"dropdown.background":we["context-menu-background"],"dropdown.foreground":we["context-menu-foreground"],"menu.selectionBackground":we["menu-selection-background"],"list.focusBackground":we["menu-selection-background"],"editorWidget.background":we["editor-widget-background"],"inputOption.activeBackground":we["input-option-active-background"],"inputOption.activeForeground":we["input-option-active-foreground"],focusBorder:we["focus-border"],"input.background":we["input-background"],"input.foreground":we["input-foreground"],"input.border":we["input-border"]};os.defineTheme("dh-dark",{base:"vs-dark",inherit:!0,rules:i,colors:o}),Dn.debug2("monaco theme: ",we),os.setTheme("dh-dark"),n([pC,nC,rC,SC,cC]),Dn.debug("Monaco initialized.")}static registerGetWorker(e){window.MonacoEnvironment={...window.MonacoEnvironment,getWorker:e}}static removeHashtag(e){return e.substring(1)}static registerLanguages(e){const n=e.map(({id:s})=>s);Ti.getLanguages().filter(({id:s})=>n.includes(s)).forEach(s=>{const i=s;Dn.debug2("Overriding default language loader:",i.id)}),e.forEach(s=>{lt.registerLanguage(s)})}static registerLanguage(e){Dn.debug2("Registering language: ",e.id),Ti.register(e),Ti.onLanguage(e.id,()=>{Ti.setLanguageConfiguration(e.id,e.conf),Ti.setMonarchTokensProvider(e.id,e.language)})}static setEOL(e,n=os.EndOfLineSequence.LF){e.getModel()?.setEOL(n)}static openDocument(e,n){const s=e.getModel();k(s);const i={textDocument:{uri:`${s.uri}`,languageId:s.getLanguageId(),version:s.getVersionId(),text:s.getValue()}};return Dn.debug2("didOpenDocumentParams: ",i),n.openDocument(i),e.onDidChangeModelContent(r=>{const{changes:l,versionId:a}=r,d=[];for(let c=0;c<l.length;c+=1){const u=l[c],{range:m,rangeLength:p,text:g}=u,f={range:{start:{line:m.startLineNumber-1,character:m.startColumn-1},end:{line:m.endLineNumber-1,character:m.endColumn-1}},rangeLength:p,text:g};d.push(f)}if(d.length>0){const c={textDocument:{version:a,uri:`${s.uri}`},contentChanges:d};Dn.debug2("didChangeDocumentParams",c),n.changeDocument(c)}})}static closeDocument(e,n){const s=e.getModel();k(s);const i={textDocument:{uri:`${s.uri}`}};n.closeDocument(i)}static registerPasteHandler(e){e.onDidPaste(n=>{const s=/“|”/g,i=/\u200b/g,o=/\u00A0/g,r=e.getModel();k(r);const l=r.getValueInRange(n.range);(s.test(l)||i.test(l)||o.test(l))&&r.applyEdits([{range:n.range,text:l.replace(s,'"').replace(i,"").replace(o," ")}])})}static isMacPlatform(){const{platform:e}=window.navigator;return e.startsWith("Mac")}static removeConflictingKeybindings(e){const n=[{windows:"ctrl+D",mac:"meta+D"},{windows:"ctrl+H"}];try{n.forEach(s=>{lt.isMacPlatform()&&s.mac===""||!lt.isMacPlatform()&&s.windows===""||lt.removeKeybinding(e,lt.isMacPlatform()?s.mac:s.windows)})}catch(s){Dn.error(s)}}static removeKeybinding(e,n){if(n===void 0)return;const s=e._standaloneKeybindingService._getResolver()._map.get(n);s!=null?s.forEach(i=>{Dn.debug2(`Removing Monaco keybinding ${n} for ${i.command}`),e._standaloneKeybindingService.addDynamicKeybinding(`-${i.command}`,null,()=>{})}):Dn.warn(`Did not find any keybindings to remove for ${n}`)}static getMonacoKeyCodeFromShortcut(e){const{keyState:n}=e,{keyValue:s}=n;return s===null?0:lt.isMacPlatform()?(n.metaKey?cn.CtrlCmd:0)|(n.shiftKey?cn.Shift:0)|(n.altKey?cn.Alt:0)|(n.ctrlKey?cn.WinCtrl:0)|Zd.fromString(s):(n.ctrlKey?cn.CtrlCmd:0)|(n.shiftKey?cn.Shift:0)|(n.altKey?cn.Alt:0)|(n.metaKey?cn.WinCtrl:0)|Zd.fromString(s)}}const tc=ee.module("MonacoCompletionProvider");class Gh extends b.exports.PureComponent{constructor(e){super(e),this.handleCompletionRequest=this.handleCompletionRequest.bind(this)}componentDidMount(){const{language:e}=this.props;this.registeredCompletionProvider=Ti.registerCompletionItemProvider(e??"",{provideCompletionItems:this.handleCompletionRequest,triggerCharacters:['"',".","'","(","[","{",","]})}componentWillUnmount(){this.registeredCompletionProvider?.dispose()}handleCompletionRequest(e,n,s){const{model:i,session:o}=this.props;if(e!==i)return null;const r={textDocument:{uri:`${e.uri}`,version:e.getVersionId()},position:{line:n.lineNumber-1,character:n.column-1},context:s},l=o.getCompletionItems(r);return tc.debug("Completion items received: ",r,l),l.then(d=>{const c=d.map(u=>{const{label:m,kind:p,detail:g,documentation:f,sortText:C,filterText:S,textEdit:w,insertTextFormat:T}=u,{start:y,end:E}=w.range,R={startLineNumber:y.line+1,startColumn:y.character+1,endLineNumber:E.line+1,endColumn:E.character+1};return{label:m,kind:p,detail:g,documentation:f,sortText:C,filterText:S,insertText:w.text,insertTextRules:T===2?4:T,range:R}});return{incomplete:!0,suggestions:c}}).catch(d=>(tc.error("There was an error retrieving completion items",d),{suggestions:[]}))}render(){return null}}const Gl=ee.module("ConsoleInput"),Lr=parseInt(we["line-height"],10),Wh=6,zh=6,bC=Lr+Wh+zh,Wl=100,qh=class extends b.exports.PureComponent{constructor(t){super(t),this.handleWindowResize=this.handleWindowResize.bind(this),this.commandContainer=de.createRef(),this.commandHistoryIndex=null,this.timestamp=Date.now(),this.bufferIndex=0,this.history=[],this.modifiedCommands=new Map,this.state={commandEditorHeight:Lr,isFocused:!1,model:null}}componentDidMount(){this.initCommandEditor(),window.addEventListener("resize",this.handleWindowResize),this.loadMoreHistory()}componentDidUpdate(){this.layoutEditor()}componentWillUnmount(){window.removeEventListener("resize",this.handleWindowResize),this.loadingPromise!=null&&this.loadingPromise.cancel(),this.destroyCommandEditor()}setConsoleText(t,e=!0,n=!1){!t||(Gl.debug("Command received: ",t),n||(this.commandHistoryIndex=null,this.commandEditor?.setValue(t)),e&&this.focusEnd(),this.updateDimensions(),n&&this.processCommand(t))}initCommandEditor(){const{language:t,session:e}=this.props,n={copyWithSyntaxHighlighting:!1,cursorStyle:"block",fixedOverflowWidgets:!0,folding:!1,fontFamily:"Fira Mono",glyphMargin:!1,language:t,lineHeight:Lr,lineDecorationsWidth:3,lineNumbers:"off",minimap:{enabled:!1},renderLineHighlight:"none",scrollBeyondLastLine:!1,scrollbar:{arrowSize:0,horizontal:"hidden",horizontalScrollbarSize:0},padding:{top:Wh,bottom:zh},tabCompletion:"on",value:"",wordWrap:"on"},s=this.commandContainer.current;k(s),this.commandEditor=os.create(s,n),lt.setEOL(this.commandEditor),lt.openDocument(this.commandEditor,e),this.commandEditor.onDidChangeModelContent(()=>{const i=this.commandEditor?.getValue();this.modifiedCommands.set(this.commandHistoryIndex,i??null),this.updateDimensions()}),this.commandEditor.onDidFocusEditorText(()=>{this.setState({isFocused:!0})}),this.commandEditor.onDidBlurEditorText(()=>{this.setState({isFocused:!1})}),this.commandEditor.onKeyDown(i=>{const{commandEditor:o,commandHistoryIndex:r}=this,l=o?.getPosition();k(l);const{lineNumber:a}=l,d=o?.getModel();if(i.code==="ArrowUp"&&!this.isSuggestionMenuPopulated()&&a===1){r!=null?this.loadCommand(r+1):this.loadCommand(0),this.focusStart(),i.stopPropagation(),i.preventDefault();return}if(i.code==="ArrowDown"&&!this.isSuggestionMenuPopulated()&&a===d?.getLineCount()){r!=null&&r>0?this.loadCommand(r-1):this.loadCommand(null),this.focusEnd(),i.stopPropagation(),i.preventDefault();return}if(!i.altKey&&!i.shiftKey&&!i.metaKey)if(i.keyCode===Ds.Enter){if(!this.isSuggestionMenuPopulated()){i.stopPropagation(),i.preventDefault();const c=this.commandEditor?.getValue().trim();c!==void 0&&(this.processCommand(c),this.commandEditor?.setValue(""))}}else i.keyCode===Ds.Tab&&(this.isSuggestionMenuActive()?this.isSuggestionMenuPopulated()||(i.stopPropagation(),i.preventDefault()):(i.stopPropagation(),i.preventDefault(),this.commandEditor?.trigger("Tab key trigger suggestions","editor.action.triggerSuggest",{})))}),this.commandEditor.addCommand(cn.CtrlCmd|Ds.KeyF,()=>{}),lt.removeConflictingKeybindings(this.commandEditor),lt.registerPasteHandler(this.commandEditor),this.commandEditor.focus(),this.updateDimensions(),this.setState({model:this.commandEditor.getModel()})}destroyCommandEditor(){const{session:t}=this.props;this.commandEditor&&(lt.closeDocument(this.commandEditor,t),this.commandEditor.dispose(),this.commandEditor=void 0)}handleWindowResize(){this.updateDimensions()}isSuggestionMenuActive(){return this.commandSuggestionContainer||(this.commandSuggestionContainer=this.commandEditor?.getDomNode()?.querySelector(".suggest-widget")),(this.commandSuggestionContainer&&this.commandSuggestionContainer.classList.contains("visible"))??!1}isSuggestionMenuPopulated(){return this.isSuggestionMenuActive()&&(this.commandSuggestionContainer?.querySelector(".monaco-list-rows")?.childElementCount??0)>0}focus(){this.commandEditor?.focus()}focusStart(){const t=this.commandEditor?.getModel();k(t);const e=t.getLineLength(1)+1,n=this.commandEditor?.getTopForPosition(1,e);k(n),this.commandEditor?.setPosition({lineNumber:1,column:e}),this.commandEditor?.setScrollTop(n),this.commandEditor?.focus()}focusEnd(){const t=this.commandEditor?.getModel();k(t);const e=t.getLineCount(),n=t.getLineLength(e)+1,s=this.commandEditor?.getTopForPosition(e,n);k(s),this.commandEditor?.setPosition({lineNumber:e,column:n}),this.commandEditor?.setScrollTop(s),this.commandEditor?.focus()}clear(){this.commandEditor?.focus(),this.commandEditor?.getModel()?.setValue(""),this.commandHistoryIndex=null}layoutEditor(){this.commandEditor&&this.commandEditor.layout()}loadCommand(t){if(t!==null&&t>=this.history.length)return;const e=this.modifiedCommands.get(t),n=t===null?"":this.history[this.history.length-t-1];this.commandHistoryIndex=t,this.commandEditor?.getModel()?.setValue(e??n),t!==null&&t>this.history.length-Wl&&this.loadMoreHistory()}async loadMoreHistory(){try{if(this.loadingPromise!=null||this.bufferIndex==null)return;const{commandHistoryStorage:t,language:e,scope:n}=this.props;this.loadingPromise=ye.makeCancelable(t.getTable(e,n??"",this.timestamp),o=>o.close());const s=await this.loadingPromise;s.setReversed(!0),s.setViewport({top:this.bufferIndex,bottom:this.bufferIndex+Wl-1}),this.loadingPromise=ye.makeCancelable(s.getViewportData(),()=>s.close());const i=await this.loadingPromise;this.bufferIndex+=Wl,this.bufferIndex>=s.size&&(this.bufferIndex=null),this.history=[...i.items.filter(({name:o},r,l)=>r===0||o!==l[r-1].name).map(({name:o})=>o).reverse(),...this.history],this.loadingPromise=void 0,s.close()}catch(t){if(this.loadingPromise=void 0,ye.isCanceled(t)){Gl.debug2("Promise canceled, not loading history");return}Gl.error("Error fetching history",t)}}processCommand(t){this.commandHistoryIndex=null,this.modifiedCommands.clear(),k(t),t!==""&&(this.history.length===0||t!==this.history[this.history.length-1])&&this.history.push(t),this.updateDimensions();const{onSubmit:e}=this.props;e(t)}updateDimensions(){if(!this.commandEditor)return;const{maxHeight:t}=this.props;k(t);const e=this.commandEditor.getContentHeight(),n=Math.max(Math.min(e,t),bC),i={overviewRulerLanes:e>n?void 0:0};this.setState({commandEditorHeight:n},()=>{this.commandEditor?.updateOptions(i),this.commandEditor?.layout()})}render(){const{disabled:t,language:e,session:n}=this.props,{commandEditorHeight:s,isFocused:i,model:o}=this.state;return h("div",{className:K("console-input-wrapper",{disabled:t}),children:v("div",{className:K("console-input-inner-wrapper",{focus:i}),children:[h("div",{className:qh.INPUT_CLASS_NAME,ref:this.commandContainer,style:{height:s}}),o&&h(Gh,{model:o,language:e,session:n})]})})}};let Pr=qh;Pr.defaultProps={maxHeight:Lr*10,scope:null,disabled:!1};Pr.INPUT_CLASS_NAME="console-input";const nc="pasted values",wC=[/^audio.*/,/^font.*/,/^image.*/,/^video.*/],zl=[".csv",".tsv",".tab",".psv",".dsv",".txt"],sc=[".zip"],vi=class extends b.exports.Component{constructor(t){super(t),this.getValidExtensions=ge(e=>e?[...zl,...sc]:[...zl]),this.getAcceptString=ge(e=>this.getValidExtensions(e).join(", ")),this.getFileTypeErrorString=ge(e=>jt.join(this.getValidExtensions(e),"or")),this.handleSelectFile=this.handleSelectFile.bind(this),this.handleFiles=this.handleFiles.bind(this),this.handleDrop=this.handleDrop.bind(this),this.unstageFile=this.unstageFile.bind(this),this.handleMenuPaste=this.handleMenuPaste.bind(this),this.handlePasteEvent=this.handlePasteEvent.bind(this),this.fileElem=de.createRef(),this.divElem=de.createRef(),this.state={selectedFileName:""}}static isValidDropItem(t){return t!=null&&t.kind==="file"&&!wC.find(e=>e.test(t.type))}static isValidExtension(t,e=!1){return zl.some(n=>t.endsWith(n))||e&&sc.some(n=>t.endsWith(n))}static handleDragOver(t){t.preventDefault(),t.stopPropagation()}static getIcon(t){return t===nc?Gd:t.endsWith(".csv")?dg:t.endsWith(".zip")?cg:hg}componentDidMount(){this.divElem.current?.addEventListener("paste",this.handlePasteEvent),this.divElem.current?.focus()}componentWillUnmount(){this.divElem.current?.removeEventListener("paste",this.handlePasteEvent)}handleSelectFile(){this.fileElem.current&&(this.fileElem.current.value="",this.fileElem.current?.click())}handleFiles(t){t.stopPropagation(),t.preventDefault();const{files:e}=t.target;e!=null&&this.handleFile(e[0])}handleDrop(t){const{allowZip:e,clearDragError:n,dragError:s}=this.props;if(t.preventDefault(),t.stopPropagation(),s!=null){n();return}if(t.dataTransfer==null||t.dataTransfer.items==null||t.dataTransfer.items.length===0)return;const i=t.dataTransfer.items[0].getAsFile();k(i),vi.isValidExtension(i.name,e)?this.handleFile(i):this.setState({dropError:vi.FILE_TYPE_ERROR})}unstageFile(t){const{onCancel:e}=this.props;t.stopPropagation(),t.preventDefault(),e(),this.setState({selectedFileName:"",dropError:void 0})}handleFile(t){const{onFileOpened:e}=this.props;e(t),this.setState({selectedFileName:t.name,dropError:void 0})}handleMenuPaste(){const{onPaste:t,onError:e,uploadInProgress:n}=this.props;n||navigator.clipboard.readText().then(s=>{t(s),this.setState({selectedFileName:nc,dropError:void 0})}).catch(s=>e(s))}handlePasteEvent(t){t.stopPropagation(),t.preventDefault(),this.handleMenuPaste()}makeContextMenuItems(){const{uploadInProgress:t}=this.props;return[{title:"Paste",icon:Gd,action:this.handleMenuPaste,shortcut:ls.PASTE,disabled:t}]}render(){const{allowZip:t,dragError:e,uploadInProgress:n}=this.props,{selectedFileName:s,dropError:i}=this.state,o=e??i,r=this.makeContextMenuItems();return v("div",{ref:this.divElem,className:"csv-overlay fill-parent-absolute",onDragOver:vi.handleDragOver,onDrop:this.handleDrop,tabIndex:-1,children:[h(le,{actions:r}),h("input",{ref:this.fileElem,type:"file",id:"fileElem",accept:this.getAcceptString(t),style:{display:"none"},onChange:this.handleFiles,"data-testid":"fileElem"}),!s&&(o===void 0||o==="")&&v("div",{className:"message-content",children:[h("div",{className:"message-icon",children:h(J,{icon:ug})}),h("label",{children:"Drop file (or paste values) here to import"}),h("div",{className:"message-small",children:h("label",{children:"or"})}),h(V,{kind:"primary",onClick:this.handleSelectFile,children:"Select File..."})]}),s&&(o===void 0||o==="")&&v("div",{className:"selected-content",children:[h("div",{className:"selected-icon",children:h(J,{icon:vi.getIcon(s)})}),v("div",{className:"selected-text",children:[h("label",{children:"Selected File"}),v("label",{className:"selected-name",children:[s,!n&&h(V,{kind:"ghost",className:"ml-2",onClick:this.unstageFile,icon:sn,tooltip:"Remove"})]})]})]}),Boolean(o)&&v("div",{className:"message-content",children:[h("div",{className:"message-icon",children:h(J,{icon:Os})}),h("label",{children:o}),o===vi.FILE_TYPE_ERROR&&h("div",{className:"message-small",children:h("label",{children:this.getFileTypeErrorString(t)})})]})]})}};let es=vi;es.defaultProps={allowZip:!1,dragError:null};es.MULTIPLE_FILE_ERROR="Please select only one file";es.FILE_TYPE_ERROR="Filetype not supported.";class Me{}Me.INTEGER="int";Me.LONG="long";Me.DOUBLE="double";Me.BOOLEAN="bool";Me.STRING="string";Me.DATE_TIME="datetime";Me.LOCAL_TIME="localtime";const ic="unknown",TC=2147483647,vC=-2147483648,oc=/^[0-9]{4}-[0-1][0-9]-[0-3][0-9][ T][0-2][0-9]:[0-5][0-9]:[0-6][0-9](?:\.[0-9]{1,9})?(?: [a-zA-Z]+)?$/,rc=/^([0-9]+T)?([0-9]+):([0-9]+)(:[0-9]+)?(?:\.[0-9]{1,9})?$/;class Nt{static determineType(e,n,s){if(!e||e===s)return n;switch(n){case Me.STRING:return Me.STRING;case Me.INTEGER:return Nt.checkInteger(e);case Me.LONG:return Nt.checkLong(e);case Me.DOUBLE:return Nt.checkDouble(e);case Me.BOOLEAN:return Nt.checkBoolean(e);case Me.DATE_TIME:return Nt.checkDateTime(e);case Me.LOCAL_TIME:return Nt.checkLocalTime(e);default:return Nt.getTypeFromUnknown(e)}}static isNotParsableNumber(e){return isNaN(e)||e==="Infinity"||e==="-Infinity"}static checkInteger(e){const n=e.replace(/,/g,"");return Nt.isNotParsableNumber(n)?Me.STRING:Nt.getNumberType(n)}static checkLong(e){const n=e.replace(/,/g,"");return Nt.isNotParsableNumber(n)?Me.STRING:n.includes(".")?Me.DOUBLE:Me.LONG}static checkDouble(e){const n=e.replace(/,/g,"");return Nt.isNotParsableNumber(n)?Me.STRING:Me.DOUBLE}static checkBoolean(e){const n=e.toLowerCase();return n==="true"||n==="false"?Me.BOOLEAN:Me.STRING}static checkDateTime(e){return oc.test(e)?Me.DATE_TIME:Me.STRING}static checkLocalTime(e){return rc.test(e)?Me.LOCAL_TIME:Me.STRING}static getTypeFromUnknown(e){const n=e.replace(/,/g,"");if(Nt.isNotParsableNumber(n)){const s=e.toLowerCase();return s==="true"||s==="false"?Me.BOOLEAN:oc.test(e)&&e.includes(":")?Me.DATE_TIME:rc.test(e)?Me.LOCAL_TIME:Me.STRING}return Nt.getNumberType(n)}static getNumberType(e){if(e.includes("."))return Me.DOUBLE;const n=e.startsWith("-")?11:10;if(e.length>n)return Me.LONG;const s=parseInt(e,10);return s>TC||s<vC?Me.LONG:Me.INTEGER}constructor(e,n,s,i,o,r,l,a,d,c){this.onFileCompleted=e,this.file=n,this.readHeaders=s,this.nullString=o,this.onProgress=r,this.onError=l,this.chunks=0,this.totalChunks=a,this.isZip=d,this.shouldTrim=c,this.zipProgress=0,this.handleChunk=this.handleChunk.bind(this),this.handleComplete=this.handleComplete.bind(this),this.handleError=this.handleError.bind(this),this.handleNodeUpdate=this.handleNodeUpdate.bind(this),this.config={...i,error:this.handleError,chunk:this.handleChunk,complete:this.handleComplete}}parse(){const e=this.isZip?this.file.nodeStream("nodebuffer",this.handleNodeUpdate):this.file;ra.parse(e,this.config)}handleChunk(e,n){let{data:s}=e;if(!this.types){if(s==null||s.length===0){n.abort(),this.onError("Error parsing CSV: no data in file.");return}this.types=new Array(s[0].length).fill(ic),this.readHeaders&&(s=s.slice(1))}k(this.types);const i=[...this.types];s.forEach(l=>{if(l.length>=i.length){for(let a=0;a<i.length;a+=1)i[a]=Nt.determineType(this.shouldTrim?l[a].trim():l[a],i[a],this.nullString);this.types=i}else n.abort(),this.onError(`Error parsing CSV: Insufficient data in row.
3
3
  Expected length ${i.length} but found ${l.length}.
4
4
  Row = ${l}`)}),this.chunks+=1;let o=0;this.totalChunks>0?o=Math.round(this.chunks/this.totalChunks*50):o=Math.round(this.zipProgress/2),this.onProgress(o)&&n.abort()}handleComplete(e){const{types:n,onFileCompleted:s}=this;k(n),(e==null||!e.meta.aborted)&&s(n.map(i=>i===ic?Me.STRING:i))}handleError(e){const{onError:n}=this;n(e)}handleNodeUpdate(e){this.zipProgress=e.percent}}const or=ee.module("CsvParser"),EC=650,Hr=class{static generateHeaderRecursive(t){let e="",n=t;return t>=26&&(e=e.concat(Hr.generateHeaderRecursive(Math.floor(t/26)-1)),n=t%26),e.concat(String.fromCharCode(65+n))}constructor({onFileCompleted:t,session:e,file:n,type:s,readHeaders:i=!0,onProgress:o,onError:r,timeZone:l,isZip:a}){this.onFileCompleted=t,this.session=e,this.file=n,this.isZip=a,this.type=s,this.readHeaders=i,this.timeZone=l,this.onProgress=o,this.onError=r,this.tables=[],this.chunks=0,this.totalChunks=a?0:Math.ceil(n.size/ra.LocalChunkSize),this.isComplete=!1,this.zipProgress=0,this.numConsolidated=0,this.isCancelled=!1,this.handleChunk=this.handleChunk.bind(this),this.handleError=this.handleError.bind(this),this.handleComplete=this.handleComplete.bind(this),this.handleNodeUpdate=this.handleNodeUpdate.bind(this),this.handleCreateTable=this.handleCreateTable.bind(this),this.config={delimiter:s.delimiter,newline:s.newline,escapeChar:s.escapeChar,dynamicTyping:!1,error:this.handleError,skipEmptyLines:s.skipEmptyLines,chunk:this.handleChunk,complete:this.handleComplete,fastMode:!1}}cancel(){this.isCancelled=!0}transpose(t,e){const n=e.length,s=new Array(t).fill(null).map(()=>new Array(n));for(let i=0;i<n;i+=1){const o=e[i];if(o.length<t)throw new Error(`Insufficient columns. Expected ${t} but found ${o.length}
@@ -15,7 +15,7 @@ ${e}`):s.setValue(`${e}`);const o=s.getLineCount(),r=s.getLineLength(o)+1;this.e
15
15
  `&&(n+=`
16
16
  `))}}if(n=n.trimRight(),this.editor.setValue(n),e){const s=this.editor.getModel()?.getLineCount();k(s),this.editor.revealLine(s,1)}this.stopFlushTimer(),this.bufferedMessages=[]}truncateLogIfNecessary(){this.messages.length>At.maxLogSize&&(this.messages=this.messages.splice(this.messages.length-At.truncateSize))}scrollToBottom(){if(!this.editor)return;const t=this.editor?.getModel?.()?.getLineCount();k(t),this.editor.revealLine(t,1)}isBottomVisible(){if(!this.editor)return!0;const e=this.editor.getModel()?.getLineCount();return k(e),this.isLineVisible(e)}isLineVisible(t){const e=this.editor?.getVisibleRanges();if(e==null||e.length===0)return!1;for(let n=0;n<e.length;n+=1){const s=e[n];if(s.startLineNumber<=t&&t<=s.endLineNumber)return!0}return!1}isLogItemVisible(t){const{shownLogLevels:e}=this.state;return e[t.logLevel]}flush(){let t="";for(let e=0;e<this.bufferedMessages.length;e+=1){const n=this.bufferedMessages[e],s=At.getLogText(n);t+=s,s.charAt(s.length-1)!==`
17
17
  `&&(t+=`
18
- `)}this.bufferedMessages=[],this.appendLogText(t)}queue(t){this.bufferedMessages.push(t),this.bufferedMessages.length===1&&(this.flushTimer=setTimeout(this.handleFlushTimeout,At.bufferTimeout))}stopFlushTimer(){this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=void 0)}updateDimensions(){this.editor&&this.editor.layout()}handleClearClick(){this.clearLogs()}clearLogs(){this.messages=[],this.refreshLogText()}handleFlushTimeout(){this.stopFlushTimer(),this.flush()}handleLogMessage(t){this.messages.push(t),this.editor&&this.isLogItemVisible(t)&&this.queue(t)}handleMenuItemClick(t){this.toggleLogLevel(t)}handleResetClick(){this.resetLogLevels()}handleResize(){this.updateDimensions()}handleToggleAllClick(){this.toggleAll()}render(){const t={placement:"bottom-end"},{shownLogLevels:e}=this.state,n=this.getMenuActions(e);return v("div",{className:"log-pane h-100 w-100",children:[v("div",{className:"log-pane-menu",children:[h(V,{kind:"ghost",className:"btn-clear-logs",onClick:this.handleClearClick,icon:gg,tooltip:"Clear log"}),h(V,{kind:"ghost",className:"btn-link-icon btn-overflow",icon:xo,tooltip:"Log Settings",onClick:()=>{},children:h(ns,{actions:n,popperClassName:"log-level-menu-popper",popperOptions:t})})]}),h("div",{className:"log-pane-editor h-100 w-100",ref:s=>{this.editorContainer=s}})]})}};let $i=At;$i.DefaultLogLevels=[St.STDOUT,St.ERROR,St.FATAL,St.STDERR,St.WARN];$i.AllLogLevels=[St.INFO,St.STDOUT,St.ERROR,St.FATAL,St.STDERR,St.WARN,St.DEBUG,St.TRACE];$i.bufferTimeout=16;$i.maxLogSize=131072;$i.truncateSize=65536;class nt{static isValid(e){return!0}static isSameFormat(e,n){throw new Error("isSameFormat not implemented")}static makeFormat(e,n,s){return{label:e,formatString:n,type:s}}format(e,n){return""}}nt.TYPE_GLOBAL="type-global";nt.TYPE_CONTEXT_PRESET="type-context-preset";nt.TYPE_CONTEXT_CUSTOM="type-context-custom";class kC extends nt{format(e){switch(e){case 1:case!0:return"true";case 0:case!1:return"false";default:return""}}}class xC extends nt{format(e){return String.fromCharCode(e)}}const mc=ee.module("DateTimeColumnFormatter"),Xs=class extends nt{constructor({timeZone:t="",showTimeZone:e=!0,showTSeparator:n=!1,defaultDateTimeFormatString:s=Xs.DEFAULT_DATETIME_FORMAT_STRING}={}){super();const i=t||Xs.DEFAULT_TIME_ZONE_ID;try{this.dhTimeZone=I.i18n.TimeZone.getTimeZone(i)}catch{mc.error("Unsupported time zone id",i),this.dhTimeZone=I.i18n.TimeZone.getTimeZone(Xs.DEFAULT_TIME_ZONE_ID)}this.defaultDateTimeFormatString=s,this.showTimeZone=e,this.showTSeparator=n,this.formatStringMap=Xs.makeFormatStringMap(e,n)}static isValid(t){try{return I.i18n.DateTimeFormat.format(t.formatString,new Date),!0}catch{return!1}}static makeFormat(t,e,n=nt.TYPE_CONTEXT_PRESET){return{label:t,formatString:e,type:n}}static isSameFormat(t,e){return t===e||t!==null&&e!==null&&t.type===e.type&&t.formatString===e.formatString}static makeGlobalFormatStringMap(t,e){const n=e?"'T'":" ",s=t?" z":"";return new Map([["yyyy-MM-dd HH:mm:ss",`yyyy-MM-dd${n}HH:mm:ss${s}`],["yyyy-MM-dd HH:mm:ss.SSS",`yyyy-MM-dd${n}HH:mm:ss.SSS${s}`],["yyyy-MM-dd HH:mm:ss.SSSSSSSSS",`yyyy-MM-dd${n}HH:mm:ss.SSSSSSSSS${s}`]])}static getGlobalFormats(t,e){return[...Xs.makeGlobalFormatStringMap(t,e).keys()]}static makeFormatStringMap(t,e){const n=e!==void 0&&e?"'T'":" ",s=t!==void 0&&t?" 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${n}HH:mm:ss${s}`],["yyyy-MM-dd HH:mm:ss.SSS",`yyyy-MM-dd${n}HH:mm:ss.SSS${s}`],["yyyy-MM-dd HH:mm:ss.SSSSSSSSS",`yyyy-MM-dd${n}HH:mm:ss.SSSSSSSSS${s}`]])}static getFormats(t,e){return[...Xs.makeFormatStringMap(t,e).keys()]}getEffectiveFormatString(t){return this.formatStringMap.get(t)??t}format(t,e={}){const n=e.formatString!=null&&e.formatString!==""?e.formatString:this.defaultDateTimeFormatString,s=this.getEffectiveFormatString(n);try{return I.i18n.DateTimeFormat.format(s,t,this.dhTimeZone)}catch{mc.error("Invalid format arguments")}return""}};let st=Xs;st.DEFAULT_DATETIME_FORMAT_STRING="yyyy-MM-dd HH:mm:ss.SSS";st.DEFAULT_TIME_ZONE_ID="America/New_York";const OC=ee.module("DecimalColumnFormatter"),Tn=class extends nt{constructor({defaultFormatString:t=Tn.DEFAULT_FORMAT_STRING}={}){super(),this.defaultFormatString=t}static isValid(t){try{return I.i18n.NumberFormat.format(t.formatString,0),!0}catch{return!1}}static makeFormat(t,e,n=nt.TYPE_CONTEXT_PRESET,s){return{label:t,type:n,formatString:e,multiplier:s}}static makePresetFormat(t,e="",n){return Tn.makeFormat(t,e,nt.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(t="",e){return Tn.makeFormat("Custom Format",t,nt.TYPE_CONTEXT_CUSTOM,e)}static isSameFormat(t,e){return t===e||t!=null&&e!=null&&t.type===e.type&&t.formatString===e.formatString&&t.multiplier===e.multiplier}format(t,e={}){const n=e.formatString!=null&&e.formatString!==""?e.formatString:this.defaultFormatString,s=e.multiplier!==void 0&&e.multiplier!==0?t*e.multiplier:t;try{return I.i18n.NumberFormat.format(n,s)}catch{OC.error("Invalid format arguments")}return""}};let ke=Tn;ke.DEFAULT_FORMAT_STRING="###,##0.0000";ke.FORMAT_PERCENT=Tn.makePresetFormat("Percent","##0.00%");ke.FORMAT_BASIS_POINTS=Tn.makePresetFormat("Basis Points","###,##0 bp",1e4);ke.FORMAT_MILLIONS=Tn.makePresetFormat("Millions","###,##0.000 mm",1e-6);ke.FORMAT_SCIENTIFIC_NOTATION=Tn.makePresetFormat("Scientific Notation","0.0000E0");ke.FORMAT_ROUND=Tn.makePresetFormat("Round","###,##0");ke.FORMAT_ROUND_TWO_DECIMALS=Tn.makePresetFormat("0.00","###,##0.00");ke.FORMAT_ROUND_FOUR_DECIMALS=Tn.makePresetFormat("0.0000","###,##0.0000");class AC extends nt{format(e){return`${e}`}}const LC=ee.module("IntegerColumnFormatter"),Ni=class extends nt{constructor({defaultFormatString:t=Ni.DEFAULT_FORMAT_STRING}={}){super(),this.defaultFormatString=t}static isValid(t){try{return I.i18n.NumberFormat.format(t.formatString,0),!0}catch{return!1}}static makeFormat(t,e,n=nt.TYPE_CONTEXT_PRESET,s){return{label:t,type:n,formatString:e,multiplier:s}}static makePresetFormat(t,e="",n){return Ni.makeFormat(t,e,nt.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(t="",e){return Ni.makeFormat("Custom Format",t,nt.TYPE_CONTEXT_CUSTOM,e)}static isSameFormat(t,e){return t===e||t!=null&&e!=null&&t.type===e.type&&t.formatString===e.formatString&&t.multiplier===e.multiplier}format(t,e={}){const n=e.formatString!=null&&e.formatString!==""?e.formatString:this.defaultFormatString,s=e.multiplier!==void 0&&e.multiplier!==0?t*e.multiplier:t;try{return I.i18n.NumberFormat.format(n,s)}catch{LC.error("Invalid format arguments")}return""}};let Ze=Ni;Ze.DEFAULT_FORMAT_STRING="###,##0";Ze.FORMAT_MILLIONS=Ni.makePresetFormat("Millions","###,##0.000 mm",1e-6);Ze.FORMAT_SCIENTIFIC_NOTATION=Ni.makePresetFormat("Scientific Notation","0.0000E0");class PC extends nt{format(e){return e}}const $t=class{static makeDateWrapper(t,e,n=0,s=1,i=0,o=0,r=0,l=0){if(!t)throw new Error("No timezone provided");const a=`${e}`.padStart(4,"0"),d=`${n+1}`.padStart(2,"0"),c=`${s}`.padStart(2,"0"),u=`${i}`.padStart(2,"0"),m=`${o}`.padStart(2,"0"),p=`${r}`.padStart(2,"0"),g=`${l}`.padStart(9,"0"),f=`${a}-${d}-${c} ${u}:${m}:${p}.${g}`;return I.i18n.DateTimeFormat.parse($t.FULL_DATE_FORMAT,f,I.i18n.TimeZone.getTimeZone(t))}static getNextNanos(t){const e=parseInt(t,10),n="0".repeat(9-t.length),s=`${e+1}${n}`;return parseInt(s,10)}static getNextDate(t,e,n){let{year:s,month:i,date:o,hours:r,minutes:l,seconds:a,nanos:d}=e;if(t.nanos!=null){if(t.nanos.length===9)return null;d=$t.getNextNanos(t.nanos),d>999999999&&(a+=1,d=0)}else t.seconds!=null?a+=1:t.minutes!=null?l+=1:t.hours!=null?r+=1:t.date!=null?o+=1:t.month!=null?i+=1:s+=1;const c=new Date(s,i,o,r,l,a);return $t.makeDateWrapper(n,c.getFullYear(),c.getMonth(),c.getDate(),c.getHours(),c.getMinutes(),c.getSeconds(),d)}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 s=0;s<$t.months.length;s+=1)if($t.months[s].startsWith(n))return s}return NaN}static parseDateValues(t,e,n,s,i,o,r){const l=parseInt(t,10),a=e!=null?this.parseMonth(e):0,d=n!=null?parseInt(n,10):1,c=s!=null?parseInt(s,10):0,u=i!=null?parseInt(i,10):0,m=o!=null?parseInt(o,10):0,p=r!=null?parseInt(r.padEnd(9,"0"),10):0;return Number.isNaN(l)||Number.isNaN(a)||Number.isNaN(d)||Number.isNaN(c)||Number.isNaN(u)||Number.isNaN(m)||Number.isNaN(p)?null:{year:l,month:a,date:d,hours:c,minutes:u,seconds:m,nanos:p}}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[,s,,i,,o,,r,,l,,a,,d,c]=n;if(c!=null&&c.length>0)throw new Error(`Unexpected characters after date string '${t}': ${c}`);return{year:s,month:i,date:o,hours:r,minutes:l,seconds:a,nanos:d}}static parseDateRange(t,e){const n=t.trim().toLowerCase();if(n.length===0)throw new Error("Cannot parse date range from empty string");if(n==="null")return[null,null];if(n==="today"){const l=new Date(Date.now()),a=$t.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate()),d=$t.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate()+1);return[a,d]}if(n==="yesterday"){const l=new Date(Date.now()),a=$t.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate()-1),d=$t.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate());return[a,d]}if(n==="now"){const l=new Date(Date.now());return[I.DateWrapper.ofJsDate(l),null]}const s=$t.parseDateTimeString(n);if(s.year==null&&s.month==null&&s.date==null)throw new Error(`Unable to extract year, month, or day ${n}`);const i=$t.parseDateValues(s.year,s.month,s.date,s.hours,s.minutes,s.seconds,s.nanos);if(i==null)throw new Error(`Unable to extract date values from ${s}`);const o=$t.makeDateWrapper(e,i.year,i.month,i.date,i.hours,i.minutes,i.seconds,i.nanos),r=$t.getNextDate(s,i,e);return[o,r]}static getJsDate(t){return typeof t=="number"?new Date(t):t.asDate()}};let vn=$t;vn.FULL_DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSSSSS";vn.months=["january","february","march","april","may","june","july","august","september","october","november","december"];class zt{}zt.not="not";zt.and="and";zt.or="or";function HC(t){if(!(t==="not"||t==="and"||t==="or"))throw new Error("operator is not a valid FilterOperatorValue")}class ${}$.eq="eq";$.eqIgnoreCase="eqIgnoreCase";$.notEq="notEq";$.notEqIgnoreCase="notEqIgnoreCase";$.greaterThan="greaterThan";$.greaterThanOrEqualTo="greaterThanOrEqualTo";$.lessThan="lessThan";$.lessThanOrEqualTo="lessThanOrEqualTo";$.in="in";$.inIgnoreCase="inIgnoreCase";$.notIn="notIn";$.notInIgnoreCase="notInIgnoreCase";$.isTrue="isTrue";$.isFalse="isFalse";$.isNull="isNull";$.invoke="invoke";$.contains="contains";$.notContains="notContains";$.startsWith="startsWith";$.endsWith="endsWith";$.containsAny="containsAny";function eu(t){switch(t){case $.eq:return"is exactly";case $.eqIgnoreCase:return"is exactly (ignore case)";case $.notEq:return"is not exactly";case $.notEqIgnoreCase:return"is not exactly (ignore case)";case $.contains:return"contains";case $.notContains:return"does not contain";case $.startsWith:return"starts with";case $.endsWith:return"ends with";default:throw new Error(`Unrecognized text filter type ${t}`)}}function tu(t){switch(t){case $.eq:return"is equal to";case $.notEq:return"is not equal to";case $.greaterThan:return"greater than";case $.greaterThanOrEqualTo:return"greater than or equal to";case $.lessThan:return"less than";case $.lessThanOrEqualTo:return"less than or equal to";default:throw new Error(`Unrecognized number filter type ${t}`)}}function nu(t){switch(t){case $.eq:return"date is";case $.notEq:return"date is not";case $.notEqIgnoreCase:case $.greaterThan:return"date is after";case $.greaterThanOrEqualTo:return"date is after or equal";case $.lessThan:return"date is before";case $.lessThanOrEqualTo:return"date is before or equal";default:throw new Error(`Unrecognized date filter type ${t}`)}}function UC(t){switch(t){case $.isTrue:return"Is True";case $.isFalse:return"Is False";case $.isNull:return"Is Null";default:throw new Error(`Unrecognized boolean filter type ${t}`)}}const qn=ee.module("TableUtils"),re=class{static getSortIndex(t,e){for(let n=0;n<t.length;n+=1)if(t[n].column?.index===e)return n;return null}static getSortForColumn(t,e){const n=re.getSortIndex(t,e);return n!=null?t[n]:null}static getFilterText(t){return t?t.toString():null}static getFilterTypes(t){return re.isBooleanType(t)?[$.isTrue,$.isFalse,$.isNull]:re.isCharType(t)||re.isNumberType(t)||re.isDateType(t)?[$.eq,$.notEq,$.greaterThan,$.greaterThanOrEqualTo,$.lessThan,$.lessThanOrEqualTo]:re.isTextType(t)?[$.eq,$.eqIgnoreCase,$.notEq,$.notEqIgnoreCase,$.contains,$.notContains,$.startsWith,$.endsWith]:[]}static getNextSort(t,e,n){if(t==null||n<0||n>=t.length)return null;const s=re.getSortForColumn(e,n);return s===null?t[n].sort().asc():s.direction===re.sortDirection.ascending?s.desc():null}static makeColumnSort(t,e,n,s){if(t==null||e<0||e>=t.length||n===re.sortDirection.none)return null;let i=t[e].sort();switch(n){case re.sortDirection.ascending:i=i.asc();break;case re.sortDirection.descending:i=i.desc();break}return s&&(i=i.abs()),i}static toggleSortForColumn(t,e,n,s=!1){if(n<0||n>=e.length)return[];const i=re.getNextSort(e,t,n);return re.setSortForColumn(t,n,i,s)}static sortColumn(t,e,n,s,i,o){if(t==null||n<0||n>=e.length)return[];const r=re.makeColumnSort(e,n,s,i);return re.setSortForColumn(t,n,r,o)}static setSortForColumn(t,e,n,s=!1){const i=re.getSortIndex(t,e);let o=[];return s&&(o=o.concat(t.filter(({direction:r})=>r!==re.sortDirection.reverse)),i!==null&&o.splice(i,1)),n!==null&&o.push(n),o}static getNormalizedType(t){switch(t){case"boolean":case"java.lang.Boolean":case re.dataType.BOOLEAN:return re.dataType.BOOLEAN;case"char":case"java.lang.Character":case re.dataType.CHAR:return re.dataType.CHAR;case"java.lang.String":case re.dataType.STRING:return re.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 re.dataType.DATETIME:return re.dataType.DATETIME;case"double":case"java.lang.Double":case"float":case"java.lang.Float":case"java.math.BigDecimal":case re.dataType.DECIMAL:return re.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 re.dataType.INT:return re.dataType.INT;default:return re.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 re.isIntegerType(t)||re.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 re.getNormalizedType(t)===re.getNormalizedType(e)}static makeQuickFilter(t,e,n){const s=e.split("||");let i=null;for(let o=0;o<s.length;o+=1){const l=s[o].split("&&");let a=null;for(let d=0;d<l.length;d+=1){const c=l[d].trim();if(c.length>0){const u=re.makeQuickFilterFromComponent(t,c,n);if(u)a?a=a.and(u):a=u;else throw new Error(`Unable to parse quick filter from text ${e}`)}}i&&a?i=i.or(a):i=a}return i}static makeQuickFilterFromComponent(t,e,n){const{type:s}=t;return re.isNumberType(s)?this.makeQuickNumberFilter(t,e):re.isBooleanType(s)?this.makeQuickBooleanFilter(t,e):n!=null&&re.isDateType(s)?this.makeQuickDateFilter(t,e,n):re.isCharType(s)?this.makeQuickCharFilter(t,e):this.makeQuickTextFilter(t,e)}static makeQuickNumberFilter(t,e){if(e==null)return null;const n=t.filter();let s=null;const o=/\s*(>=|<=|=>|=<|>|<|!=|=|!)?(\s*-\s*)?(\s*\d*(?:,\d{3})*(?:\.\d*)?\s*)?(null|nan|infinity|inf|\u221E)?(.*)/i.exec(e);let r=null,l=null,a=null,d=null,c=null;if(o!==null&&o.length>3&&([,r,l,a,d,c]=o),c!=null&&c.trim().length>0)return null;if(r==null&&(r="="),d!=null){if(!(r==="="||r==="!"||r==="!="))return null;switch(d=d.trim().toLowerCase(),d){case"null":s=n.isNull();break;case"nan":s=I.FilterCondition.invoke("isNaN",n);break;case"infinity":case"inf":case"\u221E":l!=null?s=I.FilterCondition.invoke("isInf",n).and(n.lessThan(I.FilterValue.ofNumber(0))):s=I.FilterCondition.invoke("isInf",n).and(n.greaterThan(I.FilterValue.ofNumber(0)));break}return s!==null&&(r==="!"||r==="!=")&&(s=s.not()),s}if(a==null)return null;if(a=re.removeCommas(a),re.isLongType(t.type))try{a=I.FilterValue.ofNumber(I.LongWrapper.ofString(`${l!=null?"-":""}${a}`))}catch(u){return qn.warn("Unable to create long filter",u),null}else{if(a=parseFloat(a),a==null||Number.isNaN(a))return null;a=I.FilterValue.ofNumber(l!=null?0-a:a)}return s=t.filter(),re.makeRangeFilterWithOperation(s,r,a)}static makeQuickTextFilter(t,e){if(e==null)return null;const n=`${e}`.trim(),i=/^(!~|!=|~|=|!)?(.*)/.exec(n);let o=null,r=null;if(i!==null&&i.length>2&&([,o,r]=i,r!=null&&(r=r.trim())),r==null||r.length===0)return null;o==null&&(o="=");const l=t.filter();if(r.toLowerCase()==="null")switch(o){case"=":return l.isNull();case"!=":case"!":return l.isNull().not()}let a=null,d=null;switch(r.startsWith("*")?(a="*",r=r.substring(1)):r.endsWith("*")&&!r.endsWith("\\*")&&(d="*",r=r.substring(0,r.length-1)),r=r.replace("\\",""),o){case"~":return l.isNull().not().and(l.invoke("matches",I.FilterValue.ofString(`(?s)(?i).*\\Q${r}\\E.*`)));case"!~":return l.isNull().or(l.invoke("matches",I.FilterValue.ofString(`(?s)(?i).*\\Q${r}\\E.*`)).not());case"!=":return a==="*"?l.isNull().or(l.invoke("matches",I.FilterValue.ofString(`(?s)(?i).*\\Q${r}\\E$`)).not()):d==="*"?l.isNull().or(l.invoke("matches",I.FilterValue.ofString(`(?s)(?i)^\\Q${r}\\E.*`)).not()):l.notEqIgnoreCase(I.FilterValue.ofString(r.toLowerCase()));case"=":return a==="*"?l.isNull().not().and(l.invoke("matches",I.FilterValue.ofString(`(?s)(?i).*\\Q${r}\\E$`))):d==="*"?l.isNull().not().and(l.invoke("matches",I.FilterValue.ofString(`(?s)(?i)^\\Q${r}\\E.*`))):l.eqIgnoreCase(I.FilterValue.ofString(r.toLowerCase()))}return null}static makeQuickBooleanFilter(t,e){if(e==null)return null;const s=/^(!=|=|!)?(.*)/.exec(`${e}`.trim());if(s===null)return null;const[,i,o]=s,r=i==="!"||i==="!=",l=o.trim().toLowerCase();let a=t.filter();try{const d=re.makeBooleanValue(l);return d!=null&&d?a=a.isTrue():d===null?a=a.isNull():a=a.isFalse(),r?a.not():a}catch{return null}}static makeQuickDateFilter(t,e,n){const s=e.trim(),o=/\s*(>=|<=|=>|=<|>|<|!=|!|=)?(.*)/.exec(s);if(o==null||o.length<=2)throw new Error(`Unable to parse date filter: ${e}`);let r=null,l=null;[,r,l]=o;let a=$.eq;switch(r){case"<":a=$.lessThan;break;case"<=":case"=<":a=$.lessThanOrEqualTo;break;case">":a=$.greaterThan;break;case">=":case"=>":a=$.greaterThanOrEqualTo;break;case"!=":case"!":a=$.notEq;break;case"=":case"==":default:a=$.eq;break}return re.makeQuickDateFilterWithOperation(t,l,a,n)}static makeQuickDateFilterWithOperation(t,e,n,s){if(t==null)throw new Error("Column is null");const[i,o]=vn.parseDateRange(e,s),r=i!=null?I.FilterValue.ofNumber(i):null,l=o!=null?I.FilterValue.ofNumber(o):null,a=t.filter();if(r==null)return n===$.notEq?a.isNull().not():a.isNull();switch(n){case $.eq:{if(l!=null){const d=a.greaterThanOrEqualTo(r),c=a.lessThan(l);return d.and(c)}return a.eq(r)}case $.lessThan:return a.lessThan(r);case $.lessThanOrEqualTo:return l!=null?a.lessThan(l):a.lessThanOrEqualTo(r);case $.greaterThan:return l!=null?a.greaterThanOrEqualTo(l):a.greaterThan(r);case $.greaterThanOrEqualTo:return a.greaterThanOrEqualTo(r);case $.notEq:{if(l!=null){const d=a.lessThan(r),c=a.greaterThanOrEqualTo(l);return d.or(c)}return a.notEq(r)}default:throw new Error(`Invalid operator: ${n}`)}}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 makeQuickCharFilter(t,e){if(e==null)return null;const n=`${e}`.trim(),i=/^(>=|<=|=>|=<|>|<|!=|=|!)?(null|"."|'.'|.)?(.*)/.exec(n);let o=null,r=null,l=null;if(i!==null&&i.length>3&&([,o,r,l]=i),l!=null&&l.trim().length>0||r==null||r.length===0)return null;o==null&&(o="=");const a=t.filter();if(r.toLowerCase()==="null")switch(o){case"=":return a.isNull();case"!=":case"!":return a.isNull().not();default:return null}const d=I.FilterValue.ofString(re.isRangeOperation(o)?re.quoteValue(r):r);return re.makeRangeFilterWithOperation(a,o,d)}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 ye.makeCancelable(t,e=>{e.close()})}static makeCancelableTableEventPromise(t,e,n=0,s=null){let i,o,r=!0;const l=new Promise((a,d)=>{o=setTimeout(()=>{i(),r=!1,d(new fg(`Event "${e}" timed out.`))},n),i=t.addEventListener(e,c=>{if(s!=null&&!s(c)){qn.debug2("Event triggered, but matcher returned false.");return}qn.debug2("Event triggered, resolving."),i(),clearTimeout(o),r=!1,a(c)})});return l.cancel=()=>{if(r){qn.debug2("Pending promise cleanup."),i(),clearTimeout(o),r=!1;return}qn.debug2("Ignoring non-pending promise cancel.")},l}static makeAdvancedFilter(t,e,n){const{filterItems:s,filterOperators:i,invertSelection:o,selectedValues:r}=e;let l=null;for(let d=0;d<s.length;d+=1){const c=s[d],{selectedType:u,value:m}=c;if(u!=null&&u.length>0&&m!=null&&m.length>0)try{const p=re.makeAdvancedValueFilter(t,u,m,n);if(p!=null){if(d===0)l=p;else if(l!==null&&d-1<i.length){const g=i[d-1];if(g===zt.and)l=l.and(p);else if(g===zt.or)l=l.or(p);else{qn.error("Unexpected filter operator",g,p),l=null;break}}}else qn.debug2("Empty filter ignored for",u,m)}catch(p){qn.error("Unable to create filter",p),l=null;break}}const a=re.makeSelectValueFilter(t,r,o);return a!=null&&(l!=null?l=l.and(a):l=a),l}static removeCommas(t){return t.replace(/[\s|,]/g,"")}static makeFilterValue(t,e){const n=re.getBaseType(t);return re.isTextType(n)?I.FilterValue.ofString(e):re.isLongType(n)?I.FilterValue.ofNumber(I.LongWrapper.ofString(re.removeCommas(e))):I.FilterValue.ofNumber(re.removeCommas(e))}static makeFilterRawValue(t,e){return re.isTextType(t)?I.FilterValue.ofString(e):re.isBooleanType(t)?I.FilterValue.ofBoolean(e):I.FilterValue.ofNumber(e)}static makeValue(t,e,n){if(e==null||e==="null")return null;if(re.isTextType(t))return e;if(re.isLongType(t))return I.LongWrapper.ofString(re.removeCommas(e));if(re.isBooleanType(t))return re.makeBooleanValue(e,!0);if(re.isDateType(t)){const[s]=vn.parseDateRange(e,n);return s}return re.isNumberType(t)?re.makeNumberValue(e):(qn.error("Unexpected column type",t),null)}static makeBooleanValue(t,e=!1){if(t===""&&e)return null;switch(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==="null"||t==="")return null;const e=t.toLowerCase().trim();if(e==="\u221E"||e==="infinity"||e==="inf")return Number.POSITIVE_INFINITY;if(e==="-\u221E"||e==="-infinity"||e==="-inf")return Number.NEGATIVE_INFINITY;const n=re.removeCommas(e);if(re.NUMBER_REGEX.test(n))return parseFloat(n);throw new Error(`Invalid number '${t}'`)}static getFilterOperatorString(t){switch(t){case $.eq:return"=";case $.notEq:return"!=";case $.greaterThan:return">";case $.greaterThanOrEqualTo:return">=";case $.lessThan:return"<";case $.lessThanOrEqualTo:return"<=";case $.contains:return"~";case $.notContains:return"!~";default:throw new Error(`Unexpected filter type ${t}`)}}static makeAdvancedValueFilter(t,e,n,s){if(re.isDateType(t.type))return re.makeQuickDateFilterWithOperation(t,n,e,s);if(re.isNumberType(t.type)||re.isCharType(t.type))return re.makeQuickFilter(t,`${re.getFilterOperatorString(e)}${n}`);const i=re.makeFilterValue(t.type,n),o=t.filter();switch(e){case $.eq:return o.eq(i);case $.eqIgnoreCase:return o.eqIgnoreCase(i);case $.notEq:return o.notEq(i);case $.notEqIgnoreCase:return o.notEqIgnoreCase(i);case $.greaterThan:return o.greaterThan(i);case $.greaterThanOrEqualTo:return o.greaterThanOrEqualTo(i);case $.lessThan:return o.lessThan(i);case $.lessThanOrEqualTo:return o.lessThanOrEqualTo(i);case $.isTrue:return o.isTrue();case $.isFalse:return o.isFalse();case $.isNull:return o.isNull();case $.contains:return o.isNull().not().and(o.invoke("matches",I.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E.*`)));case $.notContains:return o.isNull().or(o.invoke("matches",I.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E.*`)).not());case $.startsWith:return o.isNull().not().and(o.invoke("matches",I.FilterValue.ofString(`(?s)(?i)^\\Q${n}\\E.*`)));case $.endsWith:return o.isNull().not().and(o.invoke("matches",I.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E$`)));case $.in:case $.inIgnoreCase:case $.notIn:case $.notInIgnoreCase:case $.invoke:default:throw new Error(`Unexpected filter operation: ${e}`)}}static makeSelectValueFilter(t,e,n){if(e.length===0){if(n)return null;let o=null;re.isTextType(t.type)?o=I.FilterValue.ofString("a"):re.isBooleanType(t.type)?o=I.FilterValue.ofBoolean(!0):re.isDateType(t.type)?o=I.FilterValue.ofNumber(I.DateWrapper.ofJsDate(new Date)):o=I.FilterValue.ofNumber(0);const r=t.filter().eq(o),l=t.filter().notEq(o);return r.and(l)}const s=[];let i=!1;for(let o=0;o<e.length;o+=1){const r=e[o];r==null?i=!0:re.isTextType(t.type)?s.push(I.FilterValue.ofString(typeof r=="number"?String.fromCharCode(r):r)):re.isBooleanType(t.type)?s.push(I.FilterValue.ofBoolean(Boolean(r))):s.push(I.FilterValue.ofNumber(r))}return i?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)}static isTreeTable(t){return t!=null&&t.expand!==void 0&&t.collapse!==void 0}static sortColumns(t,e=!0){return[...t].sort((n,s)=>{const i=n.name.toUpperCase(),o=s.name.toUpperCase();return jt.sort(i,o,e)})}};let N=re;N.dataType={BOOLEAN:"boolean",CHAR:"char",DATETIME:"datetime",DECIMAL:"decimal",INT:"int",STRING:"string",UNKNOWN:"unknown"};N.sortDirection={ascending:"ASC",descending:"DESC",reverse:"REVERSE",none:null};N.REVERSE_TYPE=Object.freeze({NONE:"none",PRE_SORT:"pre-sort",POST_SORT:"post-sort"});N.NUMBER_REGEX=/^-?\d+(\.\d+)?$/;class nn{static makeColumnFormatMap(e){return e==null?new Map:e.reduce((n,s)=>{const i=N.getNormalizedType(s.columnType);return i===null||(n.has(i)||n.set(i,new Map),n.get(i)?.set(s.columnName,s.format)),n},new Map)}static makeColumnFormattingRule(e,n,s){return{columnType:e,columnName:n,format:s}}constructor(e=[],n,s,i,o=!1){this.defaultColumnFormatter=new AC,this.typeFormatterMap=new Map([[N.dataType.BOOLEAN,new kC],[N.dataType.CHAR,new xC],[N.dataType.DATETIME,new st(n)],[N.dataType.DECIMAL,new ke(s)],[N.dataType.INT,new Ze(i)],[N.dataType.STRING,new PC]]),this.columnFormatMap=nn.makeColumnFormatMap(e),this.truncateNumbersWithPound=o}getColumnFormatMapForType(e,n=!1){const s=N.getNormalizedType(e);if(s!==null)return n&&!this.columnFormatMap.has(s)&&this.columnFormatMap.set(s,new Map),this.columnFormatMap.get(s)}getColumnFormat(e,n){return this.getColumnFormatMapForType(e)?.get(n)??null}getColumnTypeFormatter(e){const n=N.getNormalizedType(e);let s=this.defaultColumnFormatter;return n&&(s=this.typeFormatterMap.get(n)??s),s}getFormattedString(e,n,s="",i){if(e==null)return"";const o=this.getColumnTypeFormatter(n),r=i||this.getColumnFormat(n,s);return o.format(e,r??void 0)}get timeZone(){return this.typeFormatterMap.get(N.dataType.DATETIME)?.dhTimeZone?.id}}function VC(t){if(t&&t.formatter){const{formatter:e}=t;return e}}function BC(t){return{timeZone:t?.timeZone,defaultDateTimeFormatString:t?.defaultDateTimeFormat,showTimeZone:t?.showTimeZone,showTSeparator:t?.showTSeparator}}function $C(t,e,n){const s=t.getColumnFormat(n,e);return s!=null&&(s.type===nt.TYPE_CONTEXT_PRESET||s.type===nt.TYPE_CONTEXT_CUSTOM)}const rs={getColumnFormats:VC,getDateTimeFormatterOptions:BC,isCustomColumnFormatDefined:$C};Ar.register([Tf,vf,Ef,yf,Rf,If]);const su=typeof $l=="function"?$l(Ar):$l.default(Ar),jn=class{constructor(){this.listeners=[],this.isDownsamplingDisabled=!1}getData(){return[]}getDefaultTitle(){return""}getLayout(){return{}}getFilterColumnMap(){return new Map}isFilterRequired(){return!1}setFilter(t){}close(){}setFormatter(t){this.formatter=t}setDownsamplingDisabled(t){this.isDownsamplingDisabled=t}setDimensions(t){this.rect=t}setTitle(t){this.title=t}subscribe(t){this.listeners.push(t)}unsubscribe(t){this.listeners=this.listeners.filter(e=>e!==t)}fireEvent(t){for(let e=0;e<this.listeners.length;e+=1)this.listeners[e](t)}fireUpdate(t){this.fireEvent(new CustomEvent(jn.EVENT_UPDATED,{detail:t}))}fireDisconnect(){this.fireEvent(new CustomEvent(jn.EVENT_DISCONNECT))}fireReconnect(){this.fireEvent(new CustomEvent(jn.EVENT_RECONNECT))}fireDownsampleStart(t){this.fireEvent(new CustomEvent(jn.EVENT_DOWNSAMPLESTARTED,{detail:t}))}fireDownsampleFinish(t){this.fireEvent(new CustomEvent(jn.EVENT_DOWNSAMPLEFINISHED,{detail:t}))}fireDownsampleFail(t){this.fireEvent(new CustomEvent(jn.EVENT_DOWNSAMPLEFAILED,{detail:t}))}fireDownsampleNeeded(t){this.fireEvent(new CustomEvent(jn.EVENT_DOWNSAMPLENEEDED,{detail:t}))}fireLoadFinished(){this.fireEvent(new CustomEvent(jn.EVENT_LOADFINISHED))}};let bt=jn;bt.EVENT_UPDATED="ChartModel.EVENT_UPDATED";bt.EVENT_DISCONNECT="ChartModel.EVENT_DISCONNECT";bt.EVENT_RECONNECT="ChartModel.EVENT_RECONNECT";bt.EVENT_DOWNSAMPLESTARTED="ChartModel.EVENT_DOWNSAMPLESTARTED";bt.EVENT_DOWNSAMPLEFINISHED="ChartModel.EVENT_DOWNSAMPLEFINISHED";bt.EVENT_DOWNSAMPLEFAILED="ChartModel.EVENT_DOWNSAMPLEFAILED";bt.EVENT_DOWNSAMPLENEEDED="ChartModel.EVENT_DOWNSAMPLENEEDED";bt.EVENT_LOADFINISHED="ChartModel.EVENT_LOADFINISHED";const GC="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",WC="#403e41",zC="#5b5a5c",qC="#c0bfbf",YC="#4878ea",KC="rgba(91, 90, 92, 0.7)",It={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:GC,gridcolor:WC,linecolor:zC,zerolinecolor:qC,activecolor:YC,rangebgcolor:KC,"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"},Gt=Object.freeze({paper_bgcolor:It["paper-bgcolor"],plot_bgcolor:It["plot-bgcolor"],title_color:It["title-color"],colorway:It.colorway,gridcolor:It.gridcolor,linecolor:It.linecolor,zerolinecolor:It.zerolinecolor,activecolor:It.activecolor,rangebgcolor:It.rangebgcolor,area_color:It["area-color"],trend_color:It["trend-color"],line_color:It["line-color"],error_band_line_color:It["error-band-line-color"],error_band_fill_color:It["error-band-fill-color"],ohlc_increasing:It["ohlc-increasing"],ohlc_decreasing:It["ohlc-decreasing"]}),io=ee.module("ChartUtils"),fs=Object.freeze(I.calendar.DayOfWeek.values()),pc="io.deephaven.time.DateTime",XC=36e5,jC=1e6;function ZC(t){return t.asDate!==void 0}function QC(t){return t.asNumber!==void 0}function gc(t){return t.dhTimeZone!==void 0}function JC(t){return t!=null&&t.range!=null&&(t.autorange===!1||t.autorange===void 0)}const oe=class{static getPlotlyChartType(t,e){switch(t){case I.plot.SeriesPlotStyle.SCATTER:return e?"scatter":"scattergl";case I.plot.SeriesPlotStyle.LINE:return"scatter";case I.plot.SeriesPlotStyle.BAR:case I.plot.SeriesPlotStyle.STACKED_BAR:return"bar";case I.plot.SeriesPlotStyle.PIE:return"pie";case I.plot.SeriesPlotStyle.TREEMAP:return"treemap";case I.plot.SeriesPlotStyle.HISTOGRAM:return"histogram";case I.plot.SeriesPlotStyle.OHLC:return"ohlc";default:return}}static getPlotlyChartMode(t,e,n){const s=new Set;switch(t){case I.plot.SeriesPlotStyle.SCATTER:(e??!1)&&s.add(oe.MODE_LINES),(n??!0)&&s.add(oe.MODE_MARKERS);break;case I.plot.SeriesPlotStyle.LINE:(e??!0)&&s.add(oe.MODE_LINES),(n??!1)&&s.add(oe.MODE_MARKERS);break}return s.size>0?[...s].join("+"):void 0}static getPlotlyProperty(t,e){switch(t){case I.plot.SeriesPlotStyle.PIE:switch(e){case I.plot.SourceType.X:return"labels";case I.plot.SourceType.Y:return"values"}break;case I.plot.SeriesPlotStyle.OHLC:switch(e){case I.plot.SourceType.TIME:return"x"}break;case I.plot.SeriesPlotStyle.TREEMAP:switch(e){case I.plot.SourceType.X:return"ids";case I.plot.SourceType.Y:return"values";case I.plot.SourceType.LABEL:return"labels";case I.plot.SourceType.PARENT:return"parents";case I.plot.SourceType.COLOR:return"marker.colors"}break}switch(e){case I.plot.SourceType.X:return"x";case I.plot.SourceType.Y:return"y";case I.plot.SourceType.Z:return"z";case I.plot.SourceType.X_LOW:return"xLow";case I.plot.SourceType.X_HIGH:return"xHigh";case I.plot.SourceType.Y_LOW:return"yLow";case I.plot.SourceType.Y_HIGH:return"yHigh";case I.plot.SourceType.TIME:return"time";case I.plot.SourceType.OPEN:return"open";case I.plot.SourceType.HIGH:return"high";case I.plot.SourceType.LOW:return"low";case I.plot.SourceType.CLOSE:return"close";case I.plot.SourceType.SHAPE:return"shape";case I.plot.SourceType.SIZE:return"size";case I.plot.SourceType.LABEL:return"label";case I.plot.SourceType.COLOR:return"color";case I.plot.SourceType.PARENT:return"parent";case I.plot.SourceType.HOVER_TEXT:return"hovertext";case I.plot.SourceType.TEXT:return"text";default:throw new Error(`Unrecognized source type: ${e}`)}}static getPlotlySeriesOrientation(t){const{sources:e}=t;return e.length===2&&e[0]?.axis?.type===I.plot.AxisType.Y?oe.ORIENTATION.HORIZONTAL:oe.ORIENTATION.VERTICAL}static getPlotlyErrorBars(t,e,n){const s=n.map((o,r)=>o-t[r]),i=e.map((o,r)=>t[r]-o);return{type:"data",symmetric:!1,array:s,arrayminus:i}}static getPlotlyDateFormat(t,e,n){const s=n?.replace("%","%%").replace(/S{9}/g,"%9f").replace(/S{8}/g,"%8f").replace(/S{7}/g,"%7f").replace(/S{6}/g,"%6f").replace(/S{5}/g,"%5f").replace(/S{4}/g,"%4f").replace(/S{3}/g,"%3f").replace(/S{2}/g,"%2f").replace(/S{1}/g,"%1f").replace(/y{4}/g,"%Y").replace(/y{2}/g,"%y").replace(/M{4}/g,"%B").replace(/M{3}/g,"%b").replace(/M{2}/g,"%m").replace(/M{1}/g,"%-m").replace(/E{4,}/g,"%A").replace(/E{1,}/g,"%a").replace(/d{2}/g,"%d").replace(/([^%]|^)d{1}/g,"$1%-d").replace(/H{2}/g,"%H").replace(/h{2}/g,"%I").replace(/h{1}/g,"%-I").replace(/m{2}/g,"%M").replace(/s{2}/g,"%S").replace("'T'","T").replace(" z","");let i;const o=t?.getColumnTypeFormatter(e);return o!=null&&gc(o)&&o.dhTimeZone!=null&&o.showTimeZone&&(i=I.i18n.DateTimeFormat.format(" z",new Date,o.dhTimeZone)),{tickformat:s,ticksuffix:i,automargin:!0}}static convertNumberPrefix(t){return t.replace(/\u00A4\u00A4/g,"USD").replace(/\u00A4/g,"$")}static getPlotlyNumberFormat(t,e,n){if(!n)return null;const i=n.split(";")[0].match(/^([^#,0.]*)([#,]*)([0,]*)(\.?)(0*)(#*)(E?0*)(%?)(.*)/);k(i);const[,o,r,l,,a,d,c,u,m]=i,p=l.replace(",","").length,f=r.indexOf(",")>=0||l.indexOf(",")>=0?",":"",C=c!=null&&c!==""?"e":"f",S=u!==""?u:C,w=a.length+d.length,y=`0${p}${f}.${w}${S}`,E=oe.convertNumberPrefix(o),R=oe.convertNumberPrefix(m);return{tickformat:y,tickprefix:E,ticksuffix:R,automargin:!0}}static getPlotlyAxisFormat(t,e=null){const{axis:n,columnType:s}=t,{formatPattern:i}=n;let o=null;return N.isDateType(s)?(o=oe.getPlotlyDateFormat(e,s,i),o=oe.addTickSpacing(o,n,!0)):N.isNumberType(s)&&(o=oe.getPlotlyNumberFormat(e,s,i),o=oe.addTickSpacing(o,n,!1)),n.formatType===I.plot.AxisFormatType.CATEGORY&&(o?o.type="category":o={type:"category",tickformat:void 0,ticksuffix:void 0}),o}static addTickSpacing(t,e,n){const{gapBetweenMajorTicks:s}=e;if(s>0){const i=t||{};let o=s;return n&&(o=s/jC),e.log&&(o=Math.log(o)),i.tickmode="linear",i.dtick=o,i}return t}static getSourceForAxis(t,e){for(let n=0;n<t.series.length;n+=1){const s=t.series[n];for(let i=0;i<s.sources.length;i+=1){const o=s.sources[i];if(o.axis===e)return o}}return null}static getSeriesVisibility(t,e){return e!=null&&e.hiddenSeries!=null&&e.hiddenSeries.includes(t)?"legendonly":!0}static getHiddenLabels(t){return t?.hiddenSeries?[...t.hiddenSeries]:[]}static makeSeriesData(t,e,n,s,i=oe.ORIENTATION.VERTICAL){return{type:t,mode:e,name:n,orientation:i,showlegend:s??void 0}}static makeSeriesDataFromSeries(t,e,n,s=null,i=Gt){const{name:o,isLinesVisible:r,isShapesVisible:l,plotStyle:a,lineColor:d,shapeColor:c,sources:u,shape:m,shapeSize:p}=t,g=u.some(T=>T.axis?.businessCalendar),f=oe.getChartType(a,g),C=oe.getPlotlyChartMode(a,r??void 0,l??void 0),S=oe.getPlotlySeriesOrientation(t),w=oe.makeSeriesData(f,C,o,s,S);return oe.addSourcesToSeriesData(w,a,u,e),oe.addStylingToSeriesData(w,a,i,d,c,m,p,n),w}static addSourcesToSeriesData(t,e,n,s){const i=t;for(let o=0;o<n.length;o+=1){const r=n[o],{axis:l,type:a}=r,d=oe.getPlotlyProperty(e,a);mh(i,d,[]);const c=l!=null?oe.getAxisPropertyName(l.type):null;if(c!=null){const u=s.get(l.type);if(u){const m=u.indexOf(l),p=m>0?`${m+1}`:"";i[`${c}axis`]=`${c}${p}`}}}}static addStylingToSeriesData(t,e,n=Gt,s=null,i=null,o=null,r=null,l=null){const a=t;if(a.marker={line:{}},a.line={width:1},e===I.plot.SeriesPlotStyle.AREA?a.fill="tozeroy":e===I.plot.SeriesPlotStyle.STACKED_AREA?a.stackgroup="stack":e===I.plot.SeriesPlotStyle.STEP?a.line.shape="hv":e===I.plot.SeriesPlotStyle.HISTOGRAM?(a.width=[],a.marker.line!==void 0&&Object.assign(a.marker.line,{color:n.paper_bgcolor,width:1})):e===I.plot.SeriesPlotStyle.OHLC?(a.increasing={line:{color:n.ohlc_increasing}},a.decreasing={line:{color:n.ohlc_decreasing}}):e===I.plot.SeriesPlotStyle.PIE?(a.textinfo="label+percent",a.outsidetextfont={color:n.title_color}):e===I.plot.SeriesPlotStyle.TREEMAP&&(a.hoverinfo="text",a.textinfo="label+text",a.tiling={packing:"squarify",pad:0},a.textposition="middle center",a.outsidetextfont={color:n.title_color}),s!=null&&(e===I.plot.SeriesPlotStyle.BAR?a.marker.color=s:a.line.color=s),i!=null&&(a.marker.color=i),o!=null&&o.length>0)try{a.marker.symbol=oe.getMarkerSymbol(o)}catch(d){io.warn("Unable to handle shape",o,":",d)}r!=null&&(a.marker.size=r*oe.DEFAULT_MARKER_SIZE),l!=null&&e!==I.plot.SeriesPlotStyle.PIE&&(a.visible=l)}static getMarkerSymbol(t){switch(t){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 ${t}`)}}static getAxisFormats(t,e){const n=new Map,s={tickformat:null,ticksuffix:null},i=oe.getAllAxes(t),o=oe.groupArray(i,"type"),{charts:r}=t;for(let l=0;l<r.length;l+=1){const a=r[l];for(let d=0;d<a.series.length;d+=1){const c=a.series[d],{sources:u}=c,m=u.filter(p=>p.axis);for(let p=0;p<m.length;p+=1){const g=m[p],{axis:f}=g,{type:C}=f,S=o.get(C);k(S);const w=S.indexOf(f),T=oe.getAxisPropertyName(C);if(T!=null){const y=oe.getAxisLayoutProperty(T,w);if(n.has(y))io.debug(`${y} already added.`);else{io.debug(`Adding ${y} to axisFormats.`);const E=oe.getPlotlyAxisFormat(g,e);if(E===null)n.set(y,s);else{n.set(y,E);const{businessCalendar:R}=f;if(R!=null){const F=[],{businessPeriods:D,businessDays:_,holidays:H,timeZone:U}=R,A=e?.getColumnTypeFormatter(pc);let Y;gc(A)&&(Y=A.dhTimeZone);const G=Y?(U.standardOffset-Y.standardOffset)/60:0;H.length>0&&F.push(...oe.createRangeBreakValuesFromHolidays(H,U,Y)),D.forEach(z=>F.push({pattern:"hour",bounds:[oe.periodToDecimal(z.close)+G,oe.periodToDecimal(z.open)+G]})),_.length<fs.length&&oe.createBoundsFromDays(_).forEach(z=>F.push({pattern:"day of week",bounds:z})),E.rangebreaks=F}if(n.size===a.axes.length)return n}}}}}}return n}static getChartType(t,e){switch(t){case I.plot.SeriesPlotStyle.HISTOGRAM:return"bar";default:return oe.getPlotlyChartType(t,e)}}static getAxisPropertyName(t){switch(t){case I.plot.AxisType.X:return"x";case I.plot.AxisType.Y:return"y";default:return null}}static getAxisSide(t){switch(t){case I.plot.AxisPosition.BOTTOM:return"bottom";case I.plot.AxisPosition.TOP:return"top";case I.plot.AxisPosition.LEFT:return"left";case I.plot.AxisPosition.RIGHT:return"right";default:return}}static getAllAxes(t){return t.charts.reduce((e,n)=>[...e,...n.axes],[])}static getChartForSeries(t,e){const{charts:n}=t;for(let s=0;s<n.length;s+=1){const i=n[s];for(let o=0;o<i.series.length;o+=1)if(e===i.series[o])return i}return null}static getLayoutRanges(t){const e={},n=Object.keys(t).filter(s=>s.indexOf("axis")>=0);for(let s=0;s<n.length;s+=1){const i=n[s],o=t[i];JC(o)&&(e[i]=[...o.range])}return e}static updateFigureAxes(t,e,n,s=0,i=0,o=Gt){const r=t,l=oe.getAllAxes(e);for(let a=0;a<e.charts.length;a+=1){const d=e.charts[a],c=n?.(d),u=oe.getChartBounds(e,d,s,i);oe.updateLayoutAxes(r,d.axes,l,s,i,u,c,o)}oe.removeStaleAxes(r,l)}static getChartBounds(t,e,n,s){const{cols:i,rows:o}=t,{column:r,colspan:l,row:a,rowspan:d}=e,c=r+l,u=a+d,m=1/i,p=1/o,g=oe.AXIS_SIZE_PX/n,f=oe.AXIS_SIZE_PX/s,C={bottom:(o-u)*p+(u<o?f/2:0),top:(o-a)*p-(a>0?f/2:0),left:r*m+(r>0?g/2:0),right:c*m-(c<i?g/2:0)};return(oe.groupArray(e.axes,"position").get(I.plot.AxisPosition.RIGHT)??[]).length>0&&(n>0?C.right-=(C.right-C.left)*Math.max(0,Math.min(oe.LEGEND_WIDTH_PX/n,oe.MAX_LEGEND_SIZE)):C.right-=(C.right-C.left)*oe.DEFAULT_AXIS_SIZE),C}static updateLayoutAxes(t,e,n,s=0,i=0,o={left:0,top:0,right:1,bottom:1},r,l=Gt){const a=s>0?Math.max(oe.MIN_AXIS_SIZE,Math.min(oe.AXIS_SIZE_PX/i,oe.MAX_AXIS_SIZE)):oe.DEFAULT_AXIS_SIZE,d=i>0?Math.max(oe.MIN_AXIS_SIZE,Math.min(oe.AXIS_SIZE_PX/s,oe.MAX_AXIS_SIZE)):oe.DEFAULT_AXIS_SIZE,c=t,u=oe.groupArray(e,"position"),m=oe.groupArray(e,"type"),p=[...m.keys()],g=oe.groupArray(n,"type");for(let f=0;f<p.length;f+=1){const C=p[f],S=oe.getAxisPropertyName(C);if(S!=null){const w=m.get(C),T=g.get(C),E=C===I.plot.AxisType.Y?i:s;k(w),k(T);for(let R=0;R<w.length;R+=1){const F=w[R],D=T.indexOf(F),_=oe.getAxisLayoutProperty(S,D);c[_]==null&&(c[_]=oe.makeLayoutAxis(C,l));const H=c[_];if(H!=null){oe.updateLayoutAxis(H,F,R,u,a,d,o);const{range:U,autorange:A}=H;if(r!=null&&U!==void 0&&(A===void 0||A===!1)){const Y=r(F),[G,z]=Y(U);io.debug("Setting downsample range",E,G,z),F.range(E,G,z)}else F.range(E)}}}}}static removeStaleAxes(t,e){const n=t,s=oe.groupArray(e,"type"),i=[...s.keys()];for(let o=0;o<i.length;o+=1){const r=i[o],l=s.get(r);k(l);let a=l.length;const d=oe.getAxisPropertyName(r);if(d!=null){let c=oe.getAxisLayoutProperty(d,a);for(;n[c]!=null;)delete n[c],a+=1,c=oe.getAxisLayoutProperty(d,a)}}}static getAxisLayoutProperty(t,e){const n=e>0?`${e+1}`:"";return`${t??""}axis${n}`}static updateLayoutAxis(t,e,n,s,i,o,r){const a=e.type===I.plot.AxisType.Y?o:i,d=t,c=e.label??"";if(d.title!==void 0&&typeof d.title!="string"?d.title.text=c:d.title={text:c},e.log&&(d.type="log"),d.side=oe.getAxisSide(e.position),n>0){d.overlaying=oe.getAxisPropertyName(e.type)??void 0;const u=s.get(e.position)??[],m=u.indexOf(e);m>0&&(d.anchor="free",e.position===I.plot.AxisPosition.RIGHT?d.position=r.right+(m-u.length+1)*a:e.position===I.plot.AxisPosition.TOP?d.position=r.top+(m-u.length+1)*a:e.position===I.plot.AxisPosition.BOTTOM?d.position=r.bottom+(u.length-m+1)*a:e.position===I.plot.AxisPosition.LEFT&&(d.position=r.left+(u.length-m+1)*a))}else if(e.type===I.plot.AxisType.X){const u=s.get(I.plot.AxisPosition.LEFT)||[],m=s.get(I.plot.AxisPosition.RIGHT)||[],p=Math.max(r.left,r.left+(u.length-1)*o),g=Math.min(r.right-(m.length-1)*o,r.right);d.domain=[p,g]}else if(e.type===I.plot.AxisType.Y){const u=s.get(I.plot.AxisPosition.BOTTOM)||[],m=s.get(I.plot.AxisPosition.TOP)||[],p=Math.max(r.bottom,r.bottom+(u.length-1)*i),g=Math.min(r.top-(m.length-1)*i,r.top);d.domain=[p,g]}}static periodToDecimal(t){const e=t.split(":");return Number(e[0])+Number(e[1])/60}static createBoundsFromDays(t){const e=t.map(o=>fs.indexOf(o)),n=fs.filter(o=>!t.includes(o)).map(o=>fs.indexOf(o)),s=new Set;n.forEach(o=>{for(let r=o+1;r<o+fs.length;r+=1){const l=r%fs.length;if(e.includes(l)){s.add(l);break}}});const i=[];return s.forEach(o=>{for(let r=o-1;r>o-fs.length;r-=1){const l=r<0?r+fs.length:r;if(e.includes(l)){const a=(l+1)%7;i.push([a,o]);break}}}),i}static createRangeBreakValuesFromHolidays(t,e,n){const s=[],i=[];return t.forEach(o=>{o.businessPeriods.length>0?i.push(...oe.createPartialHoliday(o,e,n)):s.push(oe.createFullHoliday(o,e,n))}),[{values:s},...i]}static createFullHoliday(t,e,n){return oe.adjustDateForTimeZone(`${t.date.toString()} 00:00:00.000000`,e,n)}static createPartialHoliday(t,e,n){const s=t.date.toString(),i=["00:00"];t.businessPeriods.forEach(r=>{i.push(r.open),i.push(r.close)}),i.push("24:00");const o=[];for(let r=0;r<i.length;r+=2){const l=i[r],a=i[r+1];if(l!==a){const d=[oe.adjustDateForTimeZone(`${s} ${l}:00.000000`,e,n)],c=XC*(oe.periodToDecimal(a)-oe.periodToDecimal(l));o.push({values:d,dvalue:c})}}return o}static adjustDateForTimeZone(t,e,n){return n&&n.standardOffset!==e.standardOffset?oe.unwrapValue(oe.wrapValue(t,pc,e),n):t}static groupArray(t,e){return t.reduce((n,s)=>{const i=s[e],o=n.get(i)??[];return o.push(s),n.set(i,o),n},new Map)}static unwrapValue(t,e){if(t!=null){if(ZC(t))return I.i18n.DateTimeFormat.format(oe.DATE_FORMAT,t,e);if(QC(t))return t.asNumber()}return t}static wrapValue(t,e,n=null){if(N.isDateType(e)&&typeof t=="string"){const s=t,i=oe.DATE_FORMAT.substr(0,t.length),o=I.i18n.DateTimeFormat.parse(i,s);if(!n)return o;const r=`${i} Z`,l=I.i18n.DateTimeFormat.format("Z",o,n),a=I.i18n.DateTimeFormat.parse(r,`${s} ${l}`),d=I.i18n.DateTimeFormat.format("Z",a,n);return I.i18n.DateTimeFormat.parse(r,`${s} ${d}`)}return t}static makeLayoutAxis(t,e=Gt){const n={automargin:!0,gridcolor:e.gridcolor,linecolor:e.linecolor,rangeslider:{visible:!1},showline:!0,ticklen:5,tickcolor:e.paper_bgcolor,tickfont:{color:e.zerolinecolor},title:{font:{color:e.title_color}}};return t===I.plot.AxisType.X?Object.assign(n,{showgrid:!0}):t===I.plot.AxisType.Y&&Object.assign(n,{zerolinecolor:e.zerolinecolor,zerolinewidth:2}),n}static getColorwayFromTheme(t=Gt){let e=[];return t.colorway&&(Array.isArray(t.colorway)?e=t.colorway:typeof t.colorway=="string"?e=t.colorway.split(" "):io.warn(`Unable to handle colorway property: ${t.colorway}`)),e}static makeDefaultLayout(t=Gt){const e={...t,autosize:!0,colorway:oe.getColorwayFromTheme(t),font:{family:"'Fira Sans', sans-serif"},title:{font:{color:t.title_color},yanchor:"top",pad:{...oe.DEFAULT_TITLE_PADDING},y:1},legend:{font:{color:t.title_color}},margin:{...oe.DEFAULT_MARGIN},xaxis:oe.makeLayoutAxis(I.plot.AxisType.X,t),yaxis:oe.makeLayoutAxis(I.plot.AxisType.Y,t)};return e.datarevision=0,e}static hydrateSettings(t){return{...t,type:I.plot.SeriesPlotStyle[t.type]}}static titleFromSettings(t){const{series:e,xAxis:n,title:s=`${e.join(", ")} by ${n}`}=t;return s}static makeFigureSettings(t,e){const{series:n,xAxis:s,type:i}=t,o=oe.titleFromSettings(t),r={formatType:`${I.plot.AxisFormatType.NUMBER}`,type:`${I.plot.AxisType.X}`,position:`${I.plot.AxisPosition.BOTTOM}`},l={formatType:`${I.plot.AxisFormatType.NUMBER}`,type:`${I.plot.AxisType.Y}`,position:`${I.plot.AxisPosition.LEFT}`};return{charts:[{chartType:`${I.plot.ChartType.XY}`,axes:[r,l],series:n.map(a=>({plotStyle:`${i}`,name:a,dataSources:[{type:`${I.plot.SourceType.X}`,columnName:s,axis:r,table:e},{type:`${I.plot.SourceType.Y}`,columnName:a,axis:l,table:e}]}))}],title:o}}};let _e=oe;_e.DEFAULT_AXIS_SIZE=.15;_e.MIN_AXIS_SIZE=.025;_e.MAX_AXIS_SIZE=.2;_e.AXIS_SIZE_PX=75;_e.LEGEND_WIDTH_PX=50;_e.MAX_LEGEND_SIZE=.25;_e.ORIENTATION=Object.freeze({HORIZONTAL:"h",VERTICAL:"v"});_e.DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSS";_e.DEFAULT_MARGIN=Object.freeze({l:60,r:50,t:30,b:60,pad:0});_e.DEFAULT_TITLE_PADDING=Object.freeze({t:8});_e.SUBTITLE_LINE_HEIGHT=25;_e.DEFAULT_MARKER_SIZE=6;_e.MODE_MARKERS="markers";_e.MODE_LINES="lines";const Cs=ee.module("Chart"),fo=class extends b.exports.Component{constructor(t){super(t),this.getCachedConfig=ge((e,n,s,i)=>{const o=[],r=Boolean(e);if(r&&o.push({name:`Downsampling failed: ${e}`,click:()=>{},icon:fo.convertIcon(Eh),attr:"fill-warning"}),n||s||i||r){const l=fo.downsampleButtonTitle(s,i),a=fo.downsampleButtonAttr(s,i),d=s?Cg:Sg;o.push({name:l,icon:fo.convertIcon(d),click:this.handleDownsampleClick,attr:a})}return{displaylogo:!1,displayModeBar:s||r?!0:"hover",modeBarButtons:[o,["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=de.createRef(),this.plotWrapper=de.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(t){const[e,,,,n]=t.icon,s=`${n}`;return{width:e,path:s,ascent:e,descent:0,transform:"matrix(1, 0, 0, 1, 0, 0)"}}static downsampleButtonTitle(t,e){return t?"Downsampling in progress...":e?"Downsampling disabled, click to enable":"Downsampling enabled, click to disable"}static downsampleButtonAttr(t,e){return t?"animation-spin":e?void 0:"fill-active"}componentDidMount(){this.updateDimensions(),this.updateModelDimensions(),this.initData(),this.initFormatter();const{isActive:t}=this.props;t&&this.subscribe()}componentDidUpdate(t){const{isActive:e,settings:n}=this.props;this.updateFormatterSettings(n),e!==t.isActive&&(e?this.subscribe():this.unsubscribe())}componentWillUnmount(){this.unsubscribe()}getPlotRect(){return this.plotWrapper.current?.getBoundingClientRect()??null}initData(){const{model:t}=this.props,{layout:e}=this.state;this.setState({data:t.getData(),layout:{...e,...t.getLayout()}})}subscribe(){if(this.isSubscribed)return;const{model:t}=this.props;if(!this.rect||this.rect.width===0||this.rect.height===0){Cs.debug2("Delaying subscription until model dimensions are set");return}t.subscribe(this.handleModelEvent),this.isSubscribed=!0}unsubscribe(){if(!this.isSubscribed)return;const{model:t}=this.props;t.unsubscribe(this.handleModelEvent),this.isSubscribed=!1}handleAfterPlot(){this.plot.current!=null}handleDownsampleClick(){this.setState(({isDownsamplingDisabled:t})=>({downsamplingError:null,isDownsampleInProgress:!1,isDownsampleFinished:!1,isDownsamplingDisabled:!t}),()=>{const{model:t}=this.props,{isDownsamplingDisabled:e}=this.state;t.setDownsamplingDisabled(e)})}handleModelEvent(t){const{type:e,detail:n}=t;switch(Cs.debug2("Received data update",e,n),e){case bt.EVENT_UPDATED:{this.currentSeries+=1,this.setState(i=>{const{layout:o,revision:r}=i;return typeof o.datarevision=="number"&&(o.datarevision+=1),{data:n,layout:o,revision:r+1}});const{onUpdate:s}=this.props;s({isLoading:!this.isLoadedFired});break}case bt.EVENT_LOADFINISHED:{const{onUpdate:s}=this.props;this.isLoadedFired=!0,s({isLoading:!1});break}case bt.EVENT_DISCONNECT:{const{onDisconnect:s}=this.props;s();break}case bt.EVENT_RECONNECT:{const{onReconnect:s}=this.props;s();break}case bt.EVENT_DOWNSAMPLESTARTED:{this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!0,downsamplingError:null});break}case bt.EVENT_DOWNSAMPLEFINISHED:{this.setState({isDownsampleFinished:!0,isDownsampleInProgress:!1,downsamplingError:null});break}case bt.EVENT_DOWNSAMPLENEEDED:case bt.EVENT_DOWNSAMPLEFAILED:{const s=n.message??n;this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,downsamplingError:s});const{onError:i}=this.props;i(new Error(s));break}default:Cs.debug("Unknown event type",e,t)}}handlePlotUpdate(t){const{layout:e}=t,n=_e.getLayoutRanges(e);!ct(n,this.ranges)&&(this.ranges=n,this.updateModelDimensions(!0))}handleRelayout(t){if(Cs.debug("handleRelayout",t),t.hiddenlabels!=null){const{onSettingsChanged:e}=this.props,n=[...t.hiddenlabels];e({hiddenSeries:n})}this.updateModelDimensions()}handleRestyle([t,e]){if(Cs.debug("handleRestyle",t,e),Object.keys(t).includes("visible")){const{data:n}=this.state,{onSettingsChanged:s}=this.props;if(n!=null){const i=n.reduce((o,{name:r,visible:l})=>r!=null&&l==="legendonly"?[...o,r]:o,[]);s({hiddenSeries:i})}}}updateModelDimensions(t=!1){const e=this.getPlotRect();if(!e){Cs.warn("Unable to get plotting rect");return}if(!this.rect||this.rect.width!==e.width||this.rect.height!==e.height||t){this.rect=e;const{isActive:s,model:i}=this.props;i.setDimensions(e),s&&this.subscribe()}}initFormatter(){const{settings:t}=this.props;this.updateFormatterSettings(t)}updateFormatterSettings(t){const e=rs.getColumnFormats(t),n=rs.getDateTimeFormatterOptions(t),{decimalFormatOptions:s={},integerFormatOptions:i={}}=t;(!ct(this.columnFormats,e)||!ct(this.dateTimeFormatterOptions,n)||!ct(this.decimalFormatOptions,s)||!ct(this.integerFormatOptions,i))&&(this.columnFormats=rs.getColumnFormats(t),this.dateTimeFormatterOptions=n,this.decimalFormatOptions=s,this.integerFormatOptions=i,this.updateFormatter())}updateFormatter(){const t=new nn(this.columnFormats,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions),{model:e}=this.props;e.setFormatter(t)}updateDimensions(){const t=this.getPlotRect();this.plot.current!=null&&t!=null&&t.width>0&&t.height>0&&Ar.relayout(this.plot.current.el,{autosize:!0}).catch(e=>{Cs.debug("Unable to resize, promise rejected",e)})}render(){const{data:t,downsamplingError:e,isDownsampleFinished:n,isDownsampleInProgress:s,isDownsamplingDisabled:i,layout:o,revision:r}=this.state,l=this.getCachedConfig(e,n,s,i),a=t!=null;return h("div",{className:"h-100 w-100 chart-wrapper",ref:this.plotWrapper,children:a&&h(su,{ref:this.plot,data:t,layout:o,revision:r,config:l,onAfterPlot:this.handleAfterPlot,onError:Cs.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}};let iu=fo;iu.defaultProps={isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:vn.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}};const kt=ee.module("FigureChartModel"),ou=class extends bt{constructor(t,e={},n=Gt){super(),this.addPendingSeries=Je(()=>{const i=_e.getAllAxes(this.figure),{pendingSeries:o}=this;for(let r=0;r<o.length;r+=1){const l=o[r],a=this.figure.charts.find(d=>d.series.includes(l));this.addSeries(l,i,a?.showLegend??null),l.subscribe()}this.pendingSeries=[]},ou.ADD_SERIES_DEBOUNCE),this.getTimeZone=Ie((i,o)=>{if(o!=null){const r=o.getColumnTypeFormatter(i);if(r!=null)return r.dhTimeZone}}),this.getValueTranslator=Ie((i,o)=>{const r=this.getTimeZone(i,o);return l=>_e.unwrapValue(l,r)}),this.getValueParser=Ie((i,o)=>{const r=this.getTimeZone(i,o);return l=>_e.wrapValue(l,i,r)}),this.getRangeParser=Ie((i,o)=>r=>{let[l,a]=r;const d=this.getValueParser(i,o);return l=d(l),a=d(a),[l,a]}),this.getAxisRangeParser=Ie((i,o)=>r=>{const l=_e.getSourceForAxis(i,r);return l?this.getRangeParser(l.columnType,o):a=>a}),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=t,this.settings=e,this.theme=n,this.data=[];const s={data:{},layout:_e.makeDefaultLayout(n)};this.layout={grid:{rows:t.rows,columns:t.cols,pattern:"independent"},template:s},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:t}=this.figure,e=_e.getAllAxes(this.figure),n=[];for(let o=0;o<t.length;o+=1){const r=t[o];for(let l=0;l<r.series.length;l+=1){const a=r.series[l];n.push(a.name),this.addSeries(a,e,r.showLegend)}}const i=[...this.seriesDataMap.keys()].filter(o=>n.indexOf(o)<0);for(let o=0;o<i.length;o+=1){const r=i[o];this.seriesDataMap.delete(r)}this.seriesToProcess=new Set([...this.seriesDataMap.keys()])}addSeries(t,e,n){const s=_e.groupArray(e,"type"),i=_e.makeSeriesDataFromSeries(t,s,_e.getSeriesVisibility(t.name,this.settings),n,this.theme);if(this.seriesDataMap.set(t.name,i),this.data=[...this.seriesDataMap.values()],t.plotStyle===I.plot.SeriesPlotStyle.STACKED_BAR?this.layout.barmode="stack":t.plotStyle===I.plot.SeriesPlotStyle.PIE&&(this.layout.hiddenlabels=_e.getHiddenLabels(this.settings)),this.layout.showlegend=this.data.length>1||t.plotStyle===I.plot.SeriesPlotStyle.PIE?n??void 0:!1,t.oneClick!=null){const{oneClick:o}=t,{columns:r}=o;for(let l=0;l<r.length;l+=1)this.filterColumnMap.set(r[l].name,r[l]);this.oneClicks.push(o)}this.updateLayoutFormats()}subscribe(t){super.subscribe(t),this.listeners.length===1&&(this.initAllSeries(),this.subscribeFigure())}unsubscribe(t){super.unsubscribe(t),this.listeners.length===0&&this.unsubscribeFigure()}subscribeFigure(){if(!this.isConnected){kt.debug("Ignoring subscribe when figure in disconnected state");return}this.figure.subscribe(this.isDownsamplingDisabled?I.plot.DownsampleOptions.DISABLE:I.plot.DownsampleOptions.DEFAULT)}unsubscribeFigure(){this.figure.unsubscribe()}startListeningFigure(){this.figure.addEventListener(I.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.addEventListener(I.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.addEventListener(I.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.addEventListener(I.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.addEventListener(I.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.addEventListener(I.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.addEventListener(I.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.addEventListener(I.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.addEventListener(I.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}stopListeningFigure(){this.figure.removeEventListener(I.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.removeEventListener(I.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.removeEventListener(I.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.removeEventListener(I.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.removeEventListener(I.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.removeEventListener(I.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.removeEventListener(I.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.removeEventListener(I.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.removeEventListener(I.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}handleDownsampleStart(t){kt.debug("Downsample started",t),this.fireDownsampleStart(t.detail)}handleDownsampleFinish(t){kt.debug("Downsample finished",t),this.fireDownsampleFinish(t.detail)}handleDownsampleFail(t){kt.error("Downsample failed",t),this.fireDownsampleFail(t.detail)}handleDownsampleNeeded(t){kt.info("Downsample needed",t),this.fireDownsampleNeeded(t.detail)}handleFigureUpdated(t){const{detail:e}=t,{series:n}=e;kt.debug2("handleFigureUpdated",n);for(let i=0;i<n.length;i+=1){const o=n[i];kt.debug2("handleFigureUpdated updating series",o.name);const{sources:r}=o;for(let l=0;l<r.length;l+=1){const a=r[l],{columnType:d,type:c}=a,u=this.getValueTranslator(d,this.formatter),m=e.getArray(o,c,u);this.setDataArrayForSeries(o,c,m)}this.seriesToProcess.delete(o.name),this.seriesToProcess.size===0&&this.fireLoadFinished(),this.cleanSeries(o)}const{data:s}=this;this.fireUpdate(s)}handleRequestFailed(t){kt.error("Request failed",t)}resubscribe(){this.listeners.length>0&&(this.unsubscribeFigure(),this.subscribeFigure())}setFormatter(t){super.setFormatter(t),this.updateLayoutFormats(),this.resubscribe()}setDownsamplingDisabled(t){super.setDownsamplingDisabled(t),this.resubscribe()}handleFigureDisconnected(t){kt.debug("Figure disconnected",t),this.isConnected=!1,this.listeners.length>0&&this.unsubscribeFigure(),this.fireDisconnect()}handleFigureReconnected(t){kt.debug("Figure reconnected",t),this.isConnected=!0,this.initAllSeries(),this.fireReconnect(),this.listeners.length>0&&this.subscribeFigure()}handleFigureSeriesAdded(t){const{detail:e}=t;kt.debug("handleFigureSeriesAdded",e),this.pendingSeries.push(e),this.addPendingSeries()}setDimensions(t){super.setDimensions(t),this.updateAxisPositions()}setTitle(t){super.setTitle(t);const e=(t??"").match(/<br>/g)?.length??0,n=_e.DEFAULT_MARGIN.t+e*_e.SUBTITLE_LINE_HEIGHT;this.layout.margin?this.layout.margin.t=n:this.layout.margin={t:n},typeof this.layout.title=="string"?this.layout.title=t:(this.layout.title={...this.layout.title},this.layout.title.text=t,this.layout.title.pad={...this.layout.title.pad},this.layout.title.pad.t=_e.DEFAULT_TITLE_PADDING.t+e*_e.SUBTITLE_LINE_HEIGHT*.5)}getPlotWidth(){return!this.rect||!this.rect.width?0:Math.max(this.rect.width-(this.layout.margin?.l??0)-(this.layout.margin?.r??0),0)}getPlotHeight(){return!this.rect||!this.rect.height?0:Math.max(this.rect.height-(this.layout.margin?.t??0)-(this.layout.margin?.b??0),0)}updateAxisPositions(){const t=this.getPlotWidth(),e=this.getPlotHeight();_e.updateFigureAxes(this.layout,this.figure,n=>this.getAxisRangeParser(n,this.formatter),t,e,this.theme)}updateLayoutFormats(){if(!this.formatter)return;_e.getAxisFormats(this.figure,this.formatter).forEach((e,n)=>{kt.debug(`Assigning ${n}`,this.layout[n],e);const s=this.layout[n];s!=null?Object.assign(s,e):kt.debug(`Ignoring null layout.${n}`)})}setDataArrayForSeries(t,e,n){const{name:s,plotStyle:i}=t,o=this.seriesDataMap.get(s),r=_e.getPlotlyProperty(i,e);o&&mh(o,r,n)}cleanSeries(t){const{name:e,plotStyle:n}=t,s=this.seriesDataMap.get(e);if(s!=null){if(n===I.plot.SeriesPlotStyle.HISTOGRAM){const{xLow:i,xHigh:o}=s;if(i&&o&&i.length===o.length){const r=[];for(let l=0;l<i.length;l+=1)r.push(o[l]-i[l]);s.width=r}}else if(n===I.plot.SeriesPlotStyle.LINE){const{x:i,xLow:o,xHigh:r,y:l,yLow:a,yHigh:d}=s;o&&r&&o!==i&&(s.error_x=_e.getPlotlyErrorBars(i,o,r)),a&&d&&a!==l&&(s.error_y=_e.getPlotlyErrorBars(l,a,d))}else if(n===I.plot.SeriesPlotStyle.TREEMAP){const{ids:i,labels:o}=s;i!==void 0&&o===void 0&&(s.labels=i)}}}getData(){return this.data}getLayout(){return this.layout}getFilterColumnMap(){return new Map(this.filterColumnMap)}isFilterRequired(){return this.oneClicks.find(t=>t.requireAllFiltersToDisplay)!=null}setFilter(t){if(this.oneClicks.length===0){kt.warn("Trying to set a filter, but no one click!");return}kt.debug("setFilter",t);for(let e=0;e<this.oneClicks.length;e+=1){const n=this.oneClicks[e],{columns:s}=n;new Set([...t.keys(),...this.lastFilter.keys()]).forEach(o=>{const r=t.get(o);this.lastFilter.get(o)!==r&&s.find(l=>l.name===o)!=null&&n.setValueForColumn(o,r)})}this.lastFilter=new Map(t)}setFigure(t){this.close(),this.figure=t,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure(),this.listeners.length>0&&this.subscribeFigure()}updateSettings(t){this.settings=t}};let ma=ou;ma.ADD_SERIES_DEBOUNCE=50;class Oi{static async makeModelFromSettings(e,n,s=Gt){const i=await Oi.makeFigureFromSettings(e,n);return new ma(i,e,s)}static async makeFigureFromSettings(e,n){const s=await n.copy();return s.applyCustomColumns(n.customColumns),s.applyFilter(n.filter),s.applySort(n.sort),I.plot.Figure.create(_e.makeFigureSettings(e,s))}static async makeModel(e,n,s=Gt){return new ma(n,e,s)}}function fc(t){return t.setFigure!==void 0}function eS({connection:t,defaultUpdateInterval:e,hoverUpdateInterval:n,bgMonitoring:s=!0,monitorDuration:i}){const[o,r]=b.exports.useState({freeMemory:0,maximumHeapSize:999,totalHeapSize:0}),[l,a]=b.exports.useState(!1),d=b.exports.useRef({timestamps:[],usages:[]});b.exports.useEffect(function(){const U=async()=>{const Y=await t.getWorkerHeapInfo();if(r(Y),s||l){const G=(Y.totalHeapSize-Y.freeMemory)/Y.maximumHeapSize,z=Date.now(),{timestamps:x,usages:L}=d.current;for(;x.length!==0&&z-x[0]>i*1.5;)x.shift(),L.shift();x.push(z),L.push(G)}else d.current={timestamps:[],usages:[]}};U();const A=setInterval(U,l?n:e);return()=>{clearInterval(A)}},[l,n,t,e,i,s]);const c=(H,U)=>Math.round(H*10**U)/10**U,u=2,m=1024**3,{freeMemory:p,totalHeapSize:g,maximumHeapSize:f}=o,C=c(p/m,u),S=c(g/m,u),w=c(f/m,u),T=S-C,y=(H,U,A=!1)=>v("div",{className:K("heap-usage-info-row",{"heading-bottom-border":A}),children:[h("div",{className:"font-weight-bold",children:H}),h("div",{children:U})]}),{timestamps:E,usages:R}=d.current,F=E[E.length-1]??0,D=g/f,_=(g-p)/f;return v(Se,{children:[v("div",{className:"max-memory",children:[h("div",{className:"total-memory",style:{width:`calc(${D*100}% - ${D*2}px`}}),h("div",{className:K("used-memory",{"heap-overflow":(g-p)/f>.95}),style:{width:`calc(${_*100}% - ${_*2}px`}}),v("div",{className:"memory-text",children:[w.toFixed(1)," GB"]})]}),h(ut,{onEntered:()=>a(!0),onExited:()=>a(!1),interactive:!0,children:v("div",{className:"heap-tooltip",children:[y("In use:",`${T.toFixed(u)} of ${w.toFixed(u)} GB`,!0),y("Free:",`${C.toFixed(u)} GB`),y("Total:",`${S.toFixed(u)} GB`),y("Max:",`${w.toFixed(u)} GB`),h("div",{className:"heap-plot",children:h(su,{data:[{x:[...E],y:[...R],type:"scatter",mode:"lines"}],config:{staticPlot:!0,responsive:!0},style:{width:"196px",height:"100px"},layout:{legend:!1,margin:{l:2,t:2,r:2,b:2},plot_bgcolor:"transparent",paper_bgcolor:"transparent",colorway:["#4878ea"],xaxis:{dtick:Math.round(i/6),gridcolor:Gt.linecolor,range:[F-i,F],linecolor:Gt.linecolor,linewidth:2,mirror:!0},yaxis:{dtick:.2,gridcolor:Gt.linecolor,range:[0,1],linecolor:Gt.linecolor,linewidth:2,mirror:!0}}})}),v("div",{className:"heap-utilisation-text",children:["% utilization over ",Math.round(i/1e3/60)," min."]})]})})]})}const qa=Object.freeze({}),tS=new Map,ru=t=>t.user,Ya=t=>t.storage,lu=t=>Ya(t).commandHistoryStorage,au=t=>Ya(t).fileStorage,nS=t=>Ya(t).workspaceStorage,pl=t=>t.workspace,Et=t=>pl(t).data.settings,du=t=>Et(t).defaultDateTimeFormat,cu=t=>Et(t).defaultDecimalFormatOptions??qa,hu=t=>Et(t).defaultIntegerFormatOptions??qa,uu=t=>Et(t).formatter,Ao=t=>Et(t).timeZone,mu=t=>Et(t).showTimeZone,pu=t=>Et(t).showTSeparator,gu=t=>Et(t).truncateNumbersWithPound,sS=t=>Et(t).shortcutOverrides,iS=t=>Et(t).defaultNotebookSettings??qa,gl=t=>t.activeTool,oS=t=>t.plugins??tS,fu="SET_ACTIVE_TOOL",Cu="SET_COMMAND_HISTORY_STORAGE",Su="SET_FILE_STORAGE",bu="SET_PLUGINS",wu="SET_USER",Tu="SET_WORKSPACE",vu="SET_WORKSPACE_STORAGE",Eu="SET_SERVER_CONFIG_VALUES",rS=t=>({type:wu,payload:t}),yu=t=>({type:Tu,payload:t}),lS=t=>({type:vu,payload:t}),aS=t=>({type:Cu,payload:t}),dS=t=>({type:Su,payload:t}),cS=t=>(e,n)=>{e(yu(t));const{storage:s}=n(),{workspaceStorage:i}=s;return i.save(t)},Ru=t=>(e,n)=>{const{workspace:s}=n(),{data:i}=s,o={...s,data:{...i,...t}};return e(cS(o))},fl=t=>e=>e(Ru({settings:t})),Cl=t=>({type:fu,payload:t}),hS=t=>({type:bu,payload:t}),uS=t=>({type:Eu,payload:t});function Iu(t,e){return(n=e,s)=>{switch(s.type){case t:{const i=s.payload;return i==null?null:n!=null?{...n,...i}:{...i}}default:return n}}}function mS(t,e={},n=!0){return(s=e,i)=>{switch(i.type){case t:{const{id:o,payload:r}=i;return n&&ct({payload:r},{payload:s[o]})?s:{...s,[o]:r}}default:return s}}}function Ls(t,e){return(n=e,s)=>{switch(s.type){case t:return s.payload;default:return n}}}const pS=Ls(fu,null),gS=Ls(bu,null),fS=Ls(Cu,null),CS=Ls(Su,null),SS=Ls(vu,null),bS=xa({commandHistoryStorage:fS,fileStorage:CS,workspaceStorage:SS}),wS=Iu(wu,null),TS=Iu(Tu,null),vS=Ls(Eu,null),ES={activeTool:pS,plugins:gS,storage:bS,user:wS,workspace:TS,serverConfigValues:vS};class yS{constructor(){this.reducers={},this.listener=null}register(e,n){this.reducers={...this.reducers,[e]:n},this.listener?.(this.reducers)}setListener(e){this.listener=e}}const Gi=new yS,Cc=ee.module("redux-logger"),RS=t=>e=>n=>{Cc.debug("dispatching",n);const s=e(n);return Cc.debug("next state",t.getState()),s},IS=ee.module("redux-crashReporter"),FS=t=>e=>n=>{try{return e(n)}catch(s){throw IS.error("Error executing",n," with state ",t.getState(),":",s),s}},DS=[RS,FS,Tp];Object.entries(ES).map(([t,e])=>Gi.register(t,e));const NS=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__??yp,Sl=vp(xa(Gi.reducers),NS(Ep(...DS)));Gi.setListener(t=>{Sl.replaceReducer(xa(t))});const Fu=Object.freeze({openPopouts:[],settings:{hasHeaders:!0,constrainDragToContainer:!0,reorderEnabled:!0,selectionEnabled:!1,popoutWholeStack:!1,blockedPopoutsThrowError:!0,closePopoutsOnUnload:!0,showPopoutIcon:!0,showMaximiseIcon:!0,showCloseIcon:!0,responsiveMode:"onload",tabOverlapAllowance:0,tabControlOffset:10},dimensions:{borderWidth:5,borderGrabWidth:10,minItemHeight:10,minItemWidth:10,headerHeight:20,dragProxyWidth:300,dragProxyHeight:200},labels:{close:"Close",maximise:"Maximize",minimise:"Minimize",popout:"Open in new window",popin:"Pop in",tabDropdown:"Additional tabs",tabNextLabel:"Next",tabPreviousLabel:"Previous"},content:[]});function Du(t){return t.componentName!==void 0}function _S(t){return t.component!==void 0}const Nu=Object.freeze({type:"default",isClosable:!0,isFocusOnShow:!0,reorderEnabled:!0,title:""}),MS=Object.freeze(Object.defineProperty({__proto__:null,defaultConfig:Fu,isGLComponentConfig:Du,isReactComponentConfig:_S,itemDefaultConfig:Nu},Symbol.toStringTag,{value:"Module"})),pa=class{constructor(){this.off=this.unbind,this.trigger=this.emit,this._mSubscriptions={},this._mSubscriptions[pa.ALL_EVENT]=[]}on(t,e,n){if(typeof e!="function")throw new Error("Tried to listen to event "+t+" with non-function callback "+e);this._mSubscriptions[t]||(this._mSubscriptions[t]=[]),this._mSubscriptions[t].push({fn:e,ctx:n})}emit(t,...e){const n=this._mSubscriptions[t];if(n)for(let i=0;i<n.length;i++){const o=n[i].ctx||{};n[i].fn.apply(o,e)}e.unshift(t);const s=this._mSubscriptions[pa.ALL_EVENT];for(let i=0;i<s.length;i++){const o=s[i].ctx||{};s[i].fn.apply(o,e)}}unbind(t,e,n){if(!this._mSubscriptions[t])throw new Error("No subscribtions to unsubscribe for event "+t);let s=!1;for(let i=0;i<this._mSubscriptions[t].length;i++)(!e||this._mSubscriptions[t][i].fn===e)&&(!n||n===this._mSubscriptions[t][i].ctx)&&(this._mSubscriptions[t].splice(i,1),s=!0);if(s===!1)throw new Error("Nothing to unbind for "+t)}};let pn=pa;pn.ALL_EVENT="__all";class ga extends pn{constructor(e,n,s){super(),this.isHidden=!1,this._element=pe(['<div class="lm_item_container">','<div class="lm_content" tabindex="-1"></div>',"</div>"].join("")),this.title=Du(e)?e.componentName:"",this.parent=n,this.layoutManager=s,this._config=e,this._contentElement=this._element.find(".lm_content"),this.beforeCloseHandler=null}getElement(){return this._contentElement}hide(){this.emit("hide"),this.isHidden=!0,this._element.hide()}show(){this.emit("show"),this.isHidden=!1,this._element.show(),(this.height!=0||this.width!=0)&&this.emit("shown")}setSize(e,n){let s=this.parent,i=null;for(;s&&!s.isColumn&&!s.isRow;)if(i=s,s=s.parent,s?.isRoot)return!1;if(!s||!i)return!1;const o=s.isColumn?"height":"width",r=o==="height"?n:e,l=(this[o]??0)*(1/((i.config[o]??0)/100)),a=r/l*100,d=((i.config[o]??0)-a)/(s.contentItems.length-1);for(let c=0;c<s.contentItems.length;c++)s.contentItems[c]===i?s.contentItems[c].config[o]=a:s.contentItems[c].config[o]=(s.contentItems[c].config[o]??0)+d;return s.callDownwards("setSize"),!0}close(e){!this._config.isClosable||(this.beforeCloseHandler?.(e)??!0)&&(this.emit("close"),this.parent.close())}beforeClose(e){this.beforeCloseHandler=e}getState(){return this._config.componentState}extendState(e){this.setState(pe.extend(!0,this.getState(),e))}setState(e){this._config.componentState=e,this.parent.emitBubblingEvent("stateChanged")}setTitle(e){this.parent.setTitle(e)}_$setSize(e=0,n=0){if(e!==this.width||n!==this.height){this.width=e,this.height=n;var s=this._contentElement[0],i=s.offsetWidth-s.clientWidth,o=s.offsetHeight-s.clientHeight;this._contentElement.width(this.width-i).height(this.height-o),this.emit("resize")}}}const kS=Object.freeze(Object.defineProperty({__proto__:null,ItemContainer:ga,Container:ga},Symbol.toStringTag,{value:"Module"}));function _u(t){var e=location.hash.match(new RegExp(t+"=([^&]*)"));return e?e[1]:null}function Mu(t){if(window.location.hash)return _u(t);if(!window.location.search)return null;var e=window.location.search.substr(1).split("&"),n={},s,i;for(i=0;i<e.length;i++)s=e[i].split("="),n[s[0]]=s[1];return n[t]||null}function bl(t){return window.requestAnimationFrame(t)}function xS(t,e){var n=e.indexOf(t);if(n===-1)throw new Error("Can't remove item from array. Item is not in the array");e.splice(n,1)}function Ka(){return(Math.random()*1e15).toString(36).replace(".","")}function OS(t,e){var n=t.replace(/javascript/gi,"j&#97;vascript").replace(/expression/gi,"expr&#101;ssion").replace(/onload/gi,"onlo&#97;d").replace(/script/gi,"&#115;cript").replace(/onerror/gi,"on&#101;rror");return e===!0?n:n.replace(/>/g,"&gt;").replace(/</g,"&lt;")}function Xa(t){return pe.trim(t.replace(/(<([^>]+)>)/gi,""))}class Lo extends pn{constructor(e,n=!1){super(),this._nDelay=400,this._nDistance=10,this._nX=0,this._nY=0,this._nOriginalX=0,this._nOriginalY=0,this._bDragging=!1,this._eElement=e,this._oDocument=pe(document),this._eBody=pe(document.body),this._destroyAfterMouseUp=n,this.onMouseMove=this.onMouseMove.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this._startDrag=this._startDrag.bind(this),this._eElement?.on("mousedown",this.onMouseDown)}destroy(){this._eElement?.unbind("mousedown",this.onMouseDown),this._oDocument?.unbind("mouseup",this.onMouseUp),this._eElement=void 0,this._oDocument=void 0,this._eBody=void 0,clearTimeout(this._timeout),this._timeout=void 0}onMouseDown(e){if(e.preventDefault(),e.button===0){var n=this._getCoordinates(e);this._nOriginalX=n.x??0,this._nOriginalY=n.y??0,this._oDocument?.on("mousemove",this.onMouseMove),this._oDocument?.on("mouseup",this.onMouseUp),this._timeout=window.setTimeout(this._startDrag,this._nDelay)}}onMouseMove(e){if(this._timeout!=null){e.preventDefault();var n=this._getCoordinates(e);this._nX=(n.x??0)-this._nOriginalX,this._nY=(n.y??0)-this._nOriginalY,this._bDragging===!1&&(Math.abs(this._nX)>this._nDistance||Math.abs(this._nY)>this._nDistance)&&this._startDrag(),this._bDragging&&this.emit("drag",this._nX,this._nY,e)}}onMouseUp(e){this._timeout!=null&&(clearTimeout(this._timeout),this._oDocument?.unbind("mousemove",this.onMouseMove),this._oDocument?.unbind("mouseup",this.onMouseUp),this._oDocument?.find("iframe")?.css("pointer-events",""),this._bDragging===!0&&(this._bDragging=!1,this.emit("dragStop",e,this._nOriginalX+this._nX)),this._eBody?.removeClass("lm_dragging"),this._eElement instanceof Window||this._eElement?.removeClass("lm_dragging"),this._destroyAfterMouseUp&&this.destroy())}_startDrag(){window.clearTimeout(this._timeout),this._bDragging=!0,this._eBody?.addClass("lm_dragging"),this._eElement?.addClass("lm_dragging"),this._oDocument?.find("iframe")?.css("pointer-events","none"),this.emit("dragStart",this._nOriginalX,this._nOriginalY)}_getCoordinates(e){return{x:e.pageX??0,y:e.pageY??0}}}class ku{constructor(e,n){this._reactComponent=null,this._originalComponentWillUpdate=null,this._reactComponent=null,this._originalComponentWillUpdate=null,this._container=e,this._initialState=n,this._reactClass=this._getReactClass(),this._container.on("open",this._render,this),this._container.on("destroy",this._destroy,this)}_render(){No.render(this._getReactComponent(),this._container.getElement()[0])}_gotReactComponent(e){if(!e)return;this._reactComponent=e,this._originalComponentWillUpdate=this._reactComponent.componentWillUpdate||function(){},this._reactComponent.componentWillUpdate=this._onUpdate.bind(this);const n=this._container.getState();n&&this._reactComponent.setState(n)}_destroy(){No.unmountComponentAtNode(this._container.getElement()[0]),this._container.off("open",this._render,this),this._container.off("destroy",this._destroy,this)}_onUpdate(e,n){this._container.setState(n),this._originalComponentWillUpdate?.call(this._reactComponent,e,n)}_getReactClass(){var e=this._container._config.component;if(!e)throw new Error("No react component name. type: react-component needs a field `component`");const n=this._container.layoutManager.getComponent(e)||this._container.layoutManager.getFallbackComponent();if(!n)throw new Error('React component "'+e+'" not found. Please register all components with GoldenLayout using `registerComponent(name, component)`');return n}_getReactComponent(){var e={glEventHub:this._container.layoutManager.eventHub,glContainer:this._container,ref:this._gotReactComponent.bind(this)},n=pe.extend(e,this._container._config.props);return de.createElement(this._reactClass,n)}}const Br=["settings","hasHeaders","constrainDragToContainer","selectionEnabled","dimensions","borderWidth","minItemHeight","minItemWidth","headerHeight","dragProxyWidth","dragProxyHeight","labels","close","maximise","minimise","popout","content","componentName","componentState","id","width","type","height","isClosable","title","popoutWholeStack","openPopouts","parentId","activeItemIndex","reorderEnabled","borderGrabWidth"],AS=[!0,!1,"row","column","stack","component","close","maximise","minimise","open in new window"];function ja(t){if(Br.length>36)throw new Error("Too many keys in config minifier map");const e={};return Za(t,e,"_min"),e}function fa(t){if(Br.length>36)throw new Error("Too many keys in config minifier map");const e={};return Za(t,e,"_max"),e}function Za(t,e,n){const s=n==="_min"?LS:PS;for(let i in t){if(!t.hasOwnProperty(i))continue;const o=Array.isArray(t)?t[Number.parseInt(i,10)]:t[i];if(typeof o=="object"&&o!=null){const r=o instanceof Array?[]:{};if(Array.isArray(e))e[Number.parseInt(i,10)]=r;else{const l=s(i,Br);e[l]=r}Za(o,r,n)}else{const r=s(o,AS);if(Array.isArray(e))e[Number.parseInt(i,10)]=r;else{const l=s(i,Br);e[l]=r}}}}function LS(t,e){if(typeof t=="string"&&t.length===1)return"___"+t;var n=e.indexOf(t);return n===-1?t:n.toString(36)}function PS(t,e){return typeof t=="string"&&t.length===1?e[parseInt(t,36)]:typeof t=="string"&&t.substr(0,3)==="___"?t[3]:t}class Ca{constructor(e,n){this.name=e,this.origin=n,this.isPropagationStopped=!1}stopPropagation(){this.isPropagationStopped=!0}}class xu extends pn{constructor(e){super(),this._layoutManager=e,this._dontPropagateToParent=null,this._childEventSource=null,this.on(pn.ALL_EVENT,this._onEventFromThis.bind(this)),this._boundOnEventFromChild=this._onEventFromChild.bind(this),pe(window).on("gl_child_event",this._boundOnEventFromChild)}_onEventFromThis(...e){this._layoutManager.isSubWindow&&e[0]!==this._dontPropagateToParent&&this._propagateToParent(e),this._propagateToChildren(e),this._dontPropagateToParent=null,this._childEventSource=null}_$onEventFromParent(e){this._dontPropagateToParent=e[0],this.emit.apply(this,e)}_onEventFromChild(e){this._childEventSource=e.originalEvent.__gl,this.emit.apply(this,e.originalEvent.__glArgs)}_propagateToParent(e){const n="gl_child_event",s=window.opener?.document.createEvent("HTMLEvents");s.initEvent(n,!0,!0),s.eventName=n,s.__glArgs=e,s.__gl=this._layoutManager,window.opener.dispatchEvent(s)}_propagateToChildren(e){for(let n=0;n<this._layoutManager.openPopouts.length;n++){const s=this._layoutManager.openPopouts[n].getGlInstance();s&&s!==this._childEventSource&&s.eventHub._$onEventFromParent(e)}}destroy(){pe(window).off("gl_child_event",this._boundOnEventFromChild)}}const HS=Object.freeze(Object.defineProperty({__proto__:null,EventEmitter:pn,DragListener:Lo,ReactComponentHandler:ku,BubblingEvent:Ca,EventHub:xu,getHashValue:_u,getQueryStringParam:Mu,animFrame:bl,removeFromArray:xS,getUniqueId:Ka,filterXss:OS,stripTags:Xa,minifyConfig:ja,unminifyConfig:fa},Symbol.toStringTag,{value:"Module"}));class Ou extends pn{constructor(e,n,s,i,o){super(),this.isInitialised=!1,this._popoutWindow=null,this._id=null,this._config=e,this._dimensions=n,this._parentId=s,this._indexInParent=i,this._layoutManager=o,this._createWindow()}toConfig(){if(this.isInitialised===!1)throw new Error("Can't create config, layout not yet initialised");return{dimensions:{width:this.getGlInstance()?.width,height:this.getGlInstance()?.height,left:this._popoutWindow?.screenX??this._popoutWindow?.screenLeft??0,top:this._popoutWindow?.screenY??this._popoutWindow?.screenTop??0},content:this.getGlInstance()?.toConfig().content,parentId:this._parentId,indexInParent:this._indexInParent}}getGlInstance(){return this._popoutWindow?.__glInstance}getWindow(){return this._popoutWindow}close(){if(this.getGlInstance())this.getGlInstance()?._$closeWindow();else try{this.getWindow()?.close()}catch{}}popIn(){this._indexInParent;let e=null,n=null;this._parentId&&(e=pe.extend(!0,{},this.getGlInstance()?.toConfig()).content[0],n=this._layoutManager.root.getItemsById(this._parentId)[0],n||((this._layoutManager.root.contentItems.length??0)>0?n=this._layoutManager.root.contentItems[0]:n=this._layoutManager.root)),e&&(n?.addChild(e,this._indexInParent),this.close())}_createWindow(){const e=this._createUrl(),n=Math.floor(Math.random()*1e6).toString(36),s=this._serializeWindowOptions({width:this._dimensions.width,height:this._dimensions.height,innerWidth:this._dimensions.width,innerHeight:this._dimensions.height,menubar:"no",toolbar:"no",location:"no",personalbar:"no",resizable:"yes",scrollbars:"no",status:"no"});if(this._popoutWindow=window.open(e,n,s),!this._popoutWindow)if(this._layoutManager.config.settings.blockedPopoutsThrowError===!0){const o=new Error("Popout blocked");throw o.type="popoutBlocked",o}else return;pe(this._popoutWindow).on("load",this._positionWindow.bind(this)).on("unload beforeunload",this._onClose.bind(this));let i=window.setInterval(()=>{this._popoutWindow?.__glInstance&&this._popoutWindow.__glInstance.isInitialised&&(this._onInitialised(),window.clearInterval(i))},10)}_serializeWindowOptions(e){var n=[],s;for(s in e)n.push(s+"="+e[s]);return n.join(",")}_createUrl(){var e={content:this._config};const n="gl-window-config-"+Ka();e=ja(e);try{localStorage.setItem(n,JSON.stringify(e))}catch(i){throw new Error("Error while writing to localStorage "+i.toString())}const s=document.location.href.split("?");return s.length===1?s[0]+"?gl-window="+n:document.location.href+"&gl-window="+n}_positionWindow(){this._popoutWindow?.moveTo(this._dimensions.left,this._dimensions.top),this._popoutWindow?.focus()}_onInitialised(){this.isInitialised=!0,this.getGlInstance()?.on("popIn",this.popIn,this),this.emit("initialised")}_onClose(){setTimeout(this.emit.bind(this,"closed"),50)}}const Au=class extends pn{constructor(t,e,n,s,i,o){super(),this._area=null,this._lastValidArea=null,this._dragListener=n,this._layoutManager=s,this._contentItem=i,this._originalParent=o,this._dragListener.on("drag",this._onDrag,this),this._dragListener.on("dragStop",this._onDrop,this),this._contentItem.tab&&this._contentItem.tab.element&&(this._layoutManager.tabDropPlaceholder.width(this._contentItem.tab.element.outerWidth(!0)??0),this._layoutManager.tabDropPlaceholder.height(this._contentItem.tab.element.outerHeight(!0)??0)),this.element=pe(Au._template),o&&o._side&&(this._sided=o._sided,this.element.addClass("lm_"+o._side),["right","bottom"].indexOf(o._side.toString())>=0&&this.element.find(".lm_content").after(this.element.find(".lm_header"))),this.element.css({left:t,top:e}),this._proxyTab=this.element.find(".lm_tab"),this._proxyTab.attr("title",Xa(this._contentItem.config.title??"")),this.element.find(".lm_title").html(this._contentItem.config.title??""),this.childElementContainer=this.element.find(".lm_content"),this.childElementContainer.append(i.element),this._updateTree(),this._layoutManager._$calculateItemAreas(),this._setDimensions(),pe(document.body).append(this.element),!this._contentItem.tab&&this._proxyTab.length&&(this._layoutManager.tabDropPlaceholder.width(this._proxyTab.outerWidth(!0)??0),this._layoutManager.tabDropPlaceholder.height(this._proxyTab.outerHeight(!0)??0));var r=this._layoutManager.container.offset();this._minX=r?.left??0,this._minY=r?.top??0,this._maxX=(this._layoutManager.container.width()??0)+this._minX,this._maxY=(this._layoutManager.container.height()??0)+this._minY,this._width=this.element.width()??0,this._height=this.element.height()??0,this._setDropPosition(t,e),this._layoutManager.emit("itemPickedUp",this._contentItem)}_onDrag(t,e,n){const s=n.pageX??0,i=n.pageY??0;!(s>this._minX&&s<this._maxX&&i>this._minY&&i<this._maxY)&&this._layoutManager.config.settings.constrainDragToContainer===!0||this._setDropPosition(s,i)}_setDropPosition(t,e){this.element.css({left:t,top:e}),this._area=this._layoutManager._$getArea(t,e),this._area!==null&&(this._lastValidArea=this._area,this._area.contentItem._$highlightDropZone(t,e,this._area))}_onDrop(){this._layoutManager.dropTargetIndicator?.hide(),this._area!==null?this._area.contentItem._$onDrop(this._contentItem,this._area):this._lastValidArea!==null?this._lastValidArea.contentItem._$onDrop(this._contentItem,this._lastValidArea):this._originalParent?this._originalParent.addChild(this._contentItem):this._contentItem._$destroy(),this._dragListener.off("drag",this._onDrag,this),this._dragListener.off("dragStop",this._onDrop,this),this.element.remove(),this._layoutManager.emit("itemDropped",this._contentItem)}_updateTree(){this._contentItem.parent&&this._contentItem.parent.removeChild(this._contentItem,!0),this._contentItem._$setParent(null)}_setDimensions(){const t=this._layoutManager.config.dimensions;let e=t.dragProxyWidth,n=t.dragProxyHeight;this.element.width(e),this.element.height(n),e-=this._sided?t.headerHeight:0,n-=this._sided?0:t.headerHeight,this.childElementContainer.width(e),this.childElementContainer.height(n),this._contentItem.element.width(e),this._contentItem.element.height(n),this._contentItem.callDownwards("_$show"),this._contentItem.callDownwards("setSize")}};let Po=Au;Po._template='<div class="lm_dragProxy"><div class="lm_header"><ul class="lm_tabs"><li class="lm_tab lm_active"><i class="lm_left"></i><span class="lm_title"></span><i class="lm_right"></i></li></ul></div><div class="lm_content"></div></div>';class Lu{constructor(e,n,s){this._element=e,this._itemConfig=n,this._layoutManager=s,this._dragListener=this._createDragListener()}_createDragListener(){return this._dragListener=new Lo(this._element,!0),this._dragListener.on("dragStart",this._onDragStart,this),this._dragListener.on("dragStop",this._createDragListener,this),this._dragListener}_onDragStart(e,n){let s=this._itemConfig;typeof s=="function"&&(s=s());const i=this._layoutManager._$normalizeContentItem(pe.extend(!0,{},s)),o=new Po(e,n,this._dragListener,this._layoutManager,i,null);this._layoutManager.transitionIndicator?.transitionElements(this._element,o.element)}}class Pu{constructor(e,n,s){this._element=pe(window),this._itemConfig=e,this._layoutManager=n,this._createDragListener(s)}_createDragListener(e){this._dragListener&&this._dragListener.destroy(),this._element&&(this._dragListener=new Lo(this._element,!0),this._dragListener.on("dragStart",this._onDragStart,this),this._dragListener.on("dragStop",this._destroy,this),this._dragListener.onMouseDown(e),this._dragListener._startDrag())}_destroy(){this._dragListener=void 0,this._element=void 0,this._itemConfig=void 0,this._layoutManager=void 0}_onDragStart(e,n){if(!(!this._dragListener||!this._layoutManager)){var s=this._itemConfig;typeof s=="function"&&(s=s());var i=this._layoutManager._$normalizeContentItem(pe.extend(!0,{},s));new Po(e,n,this._dragListener,this._layoutManager,i,null)}}}const Hu=class{constructor(){this.element=pe(Hu._template),pe(document.body).append(this.element)}destroy(){this.element.remove()}highlightArea(t){this.element.css({left:t.x1,top:t.y1,width:Math.floor(t.x2-t.x1),height:Math.floor(t.y2-t.y1)}).show()}hide(){this.element.hide()}};let Qa=Hu;Qa._template='<div class="lm_dropTargetIndicator"><div class="lm_inner"></div></div>';class Co{constructor(e,n,s,i){this._header=e,this.element=pe('<li class="'+s+'" title="'+n+'"></li>'),this._header.on("destroy",this._$destroy,this),this._action=i,this.element.on("click",this._action),this._header.controlsContainer.append(this.element)}_$destroy(){this.element.off(),this.element.remove()}}class ni extends Error{constructor(e,n){super(),this.name="Configuration Error",this.message=e,this.node=n}}const US=Object.freeze(Object.defineProperty({__proto__:null,ConfigurationError:ni},Symbol.toStringTag,{value:"Module"}));function _o(t){return t.isStack}function hn(t){return t.isComponent}function Uu(t){return t.isRoot}class Tt extends pn{constructor(e,n,s,i){super(),this.isInitialised=!1,this.isMaximised=!1,this.isRoot=!1,this.isRow=!1,this.isColumn=!1,this.isStack=!1,this.isComponent=!1,this.element=i,this.config=this._extendItemNode(n),this.type=n.type,this.contentItems=[],this.parent=s,this.layoutManager=e,this._pendingEventPropagations={},this._throttledEvents=["stateChanged"],this.on(pn.ALL_EVENT,this._propagateEvent,this),n.content&&this._createContentItems(n)}callDownwards(e,n=[],s=!1,i=!1){s!==!0&&i!==!0&&this[e].apply(this,n);for(let o=0;o<this.contentItems.length;o++)this.contentItems[o].callDownwards(e,n,s);s===!0&&i!==!0&&this[e].apply(this,n)}removeChild(e,n=!1){const s=this.contentItems.indexOf(e);if(s===-1)throw new Error("Can't remove child item. Unknown content item");n!==!0&&this.contentItems[s]._$destroy(),this.contentItems.splice(s,1),this.config.content?.splice(s,1),this.contentItems.length>0?this.callDownwards("setSize"):this.type!=="root"&&this.config.isClosable&&this.parent?.removeChild(this)}addChild(e,n){e=this.layoutManager._$normalizeContentItem(e,this),n===void 0&&(n=this.contentItems.length),this.contentItems.splice(n,0,e),this.config.content===void 0&&(this.config.content=[]),this.config.content.splice(n,0,e.config),e.parent=this,e.parent.isInitialised===!0&&e.isInitialised===!1&&e._$init()}replaceChild(e,n,s=!1){n=this.layoutManager._$normalizeContentItem(n);const i=this.contentItems.indexOf(e),o=e.element[0].parentNode;if(i===-1)throw new Error("Can't replace child. oldChild is not child of this");o?.replaceChild(n.element[0],e.element[0]),s===!0&&(e.parent=null,e._$destroy()),this.contentItems[i]=n,n.parent=this,_o(this)&&(this.header.tabs[i].contentItem=n),n.parent.isInitialised===!0&&n.isInitialised===!1&&n._$init(),this.callDownwards("setSize")}remove(){this.parent?.removeChild(this)}popout(){var e=this.layoutManager.createPopout(this);return this.emitBubblingEvent("stateChanged"),e}toggleMaximise(e){e&&e.preventDefault(),this.isMaximised===!0?this.layoutManager._$minimiseItem(this):this.layoutManager._$maximiseItem(this),this.isMaximised=!this.isMaximised,this.emitBubblingEvent("stateChanged")}select(){this.layoutManager.selectedItem!==this&&(this.layoutManager.selectItem(this,!0),this.element.addClass("lm_selected"))}deselect(){this.layoutManager.selectedItem===this&&(this.layoutManager.selectedItem=null,this.element.removeClass("lm_selected"))}setTitle(e){this.config.title=e,this.emit("titleChanged",e),this.emitBubblingEvent("stateChanged")}hasId(e){if(this.config.id){if(typeof this.config.id=="string")return this.config.id===e;if(this.config.id instanceof Array)return this.config.id.indexOf(e)!==-1}else return!1}addId(e){this.hasId(e)||(this.config.id?typeof this.config.id=="string"?this.config.id=[this.config.id,e]:this.config.id instanceof Array&&this.config.id.push(e):this.config.id=e)}removeId(e){if(!this.hasId(e))throw new Error("Id not found");if(typeof this.config.id=="string")delete this.config.id;else if(this.config.id instanceof Array){var n=this.config.id.indexOf(e);this.config.id.splice(n,1)}}getItemsByFilter(e){const n=[],s=function(i){for(let o=0;o<i.contentItems.length;o++)e(i.contentItems[o])===!0&&n.push(i.contentItems[o]),s(i.contentItems[o])};return s(this),n}getItemsById(e){return this.getItemsByFilter(function(n){return n.config.id instanceof Array?n.config.id.indexOf(e)!==-1:n.config.id===e})}getItemsByType(e){return this._$getItemsByProperty("type",e)}getComponentsByName(e){const n=this._$getItemsByProperty("componentName",e),s=[];for(let i=0;i<n.length;i++)s.push(n[i].instance);return s}_$getItemsByProperty(e,n){return this.getItemsByFilter(function(s){return s[e]===n})}_$setParent(e){this.parent=e}_$highlightDropZone(e,n,s){this.layoutManager.dropTargetIndicator?.highlightArea(s)}_$onDrop(e,n){this.addChild(e)}_$hide(){this._callOnActiveComponents("hide"),this.element.hide(),this.layoutManager.updateSize()}_$show(){this._callOnActiveComponents("show"),this.element.show(),this.layoutManager.updateSize()}_callOnActiveComponents(e){const n=this.getItemsByType("stack");let s=null;for(let i=0;i<n.length;i++)s=n[i].getActiveContentItem(),s&&hn(s)&&s.container[e]()}_$destroy(){this.emitBubblingEvent("beforeItemDestroyed"),this.callDownwards("_$destroy",[],!0,!0),this.element.remove(),this.emitBubblingEvent("itemDestroyed")}_$getArea(e){e=e||this.element;const n=e.offset()??{left:0,top:0},s=e.width()??0,i=e.height()??0;return{x1:n.left,y1:n.top,x2:n.left+s,y2:n.top+i,surface:s*i,contentItem:this,side:""}}_$init(){this.setSize();for(let e=0;e<this.contentItems.length;e++)this.childElementContainer?.append(this.contentItems[e].element);this.isInitialised=!0,this.emitBubblingEvent("itemCreated"),this.emitBubblingEvent(this.type+"Created")}emitBubblingEvent(e){var n=new Ca(e,this);this.emit(e,n)}_createContentItems(e){var n;if(!(e.content instanceof Array))throw new ni("content must be an Array",e);for(let s=0;s<e.content.length;s++)n=this.layoutManager.createContentItem(e.content[s],this),this.contentItems.push(n)}_extendItemNode(e){for(let[n,s]of Object.entries(Nu)){const i=n;e[i]===void 0&&(e[i]=s)}return e}_propagateEvent(e,n){n instanceof Ca&&n.isPropagationStopped===!1&&this.isInitialised===!0&&(this.isRoot===!1&&this.parent?this.parent.emit.apply(this.parent,[e,n]):this._scheduleEventPropagationToLayoutManager(e,n))}_scheduleEventPropagationToLayoutManager(e,n){this._throttledEvents.indexOf(e)===-1?this.layoutManager.emit(e,n.origin):this._pendingEventPropagations[e]!==!0&&(this._pendingEventPropagations[e]=!0,bl(this._propagateEventToLayoutManager.bind(this,e,n)))}_propagateEventToLayoutManager(e,n){this._pendingEventPropagations[e]=!1,this.layoutManager.emit(e,n)}}class Vu extends Tt{constructor(e,n,s){super(e,n,s,pe()),this.config=n,this.parent=s;const i=e.getComponent(this.config.componentName)||e.getFallbackComponent(),o=pe.extend(!0,{},this.config.componentState||{});if(i==null)throw new ni('Unknown component "'+this.config.componentName+'"');o.componentName=this.config.componentName,this.componentName=this.config.componentName,this.config.title===""&&(this.config.title=this.config.componentName),this.isComponent=!0,this.container=new ga(this.config,this,e),this.instance=new i(this.container,o),this.element=this.container._element}close(){this.parent.removeChild(this)}setSize(){this.element.is(":visible")&&this.container._$setSize(this.element.width(),this.element.height())}_$init(){Tt.prototype._$init.call(this),this.container.emit("open")}_$hide(){this.container.hide(),Tt.prototype._$hide.call(this)}_$show(){this.container.show(),this.container._config.isFocusOnShow&&this.container._contentElement[0].focus({preventScroll:!0}),Tt.prototype._$show.call(this)}_$destroy(){this.container.emit("destroy",this),Tt.prototype._$destroy.call(this)}_$getArea(){return null}}class $r extends Tt{constructor(e,n,s,i){super(n,s,i,pe('<div class="lm_item lm_'+(e?"column":"row")+'"></div>')),this._splitter=[],this._splitterPosition=null,this._splitterMinPosition=null,this._splitterMaxPosition=null,this.parent=i,this.isRow=!e,this.isColumn=e,this.childElementContainer=this.element,this._splitterSize=n.config.dimensions.borderWidth,this._splitterGrabSize=n.config.dimensions.borderGrabWidth,this._isColumn=e,this._dimension=e?"height":"width",this._splitterPosition=null,this._splitterMinPosition=null,this._splitterMaxPosition=null}addChild(e,n,s){var i,o,r,l;if(e=this.layoutManager._$normalizeContentItem(e,this),n===void 0&&(n=this.contentItems.length),this.contentItems.length>0?(l=this._createSplitter(Math.max(0,n-1)).element,n>0?(this.contentItems[n-1].element.after(l),l.after(e.element)):(this.contentItems[0].element.before(l),l.before(e.element))):this.childElementContainer.append(e.element),Tt.prototype.addChild.call(this,e,n),i=1/this.contentItems.length*100,s===!0){this.emitBubblingEvent("stateChanged");return}for(r=0;r<this.contentItems.length;r++)this.contentItems[r]===e?e.config[this._dimension]=i:(o=(this.contentItems[r].config[this._dimension]??0)*(100-i)/100,this.contentItems[r].config[this._dimension]=o);this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged")}removeChild(e,n){var s=e.config[this._dimension]??0,i=this.contentItems.indexOf(e),o=Math.max(i-1,0),r,l;if(i===-1)throw new Error("Can't remove child. ContentItem is not child of this Row or Column");for(this._splitter[o]&&(this._splitter[o]._$destroy(),this._splitter.splice(o,1)),r=0;r<this.contentItems.length;r++)this.contentItems[r]!==e&&(this.contentItems[r].config[this._dimension]=(this.contentItems[r].config[this._dimension]??0)+s/(this.contentItems.length-1));Tt.prototype.removeChild.call(this,e,n),this.contentItems.length===1&&this.config.isClosable===!0?(l=this.contentItems[0],this.contentItems=[],this.parent.replaceChild(this,l,!0)):(this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged"))}replaceChild(e,n){var s=e.config[this._dimension];super.replaceChild(e,n),n.config[this._dimension]=s,this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged")}setSize(){this.contentItems.length>0&&(this._calculateRelativeSizes(),this._setAbsoluteSizes()),this.emitBubblingEvent("stateChanged"),this.emit("resize")}_$init(){if(this.isInitialised!==!0){var e;for(Tt.prototype._$init.call(this),e=0;e<this.contentItems.length-1;e++)this.contentItems[e].element.after(this._createSplitter(e).element)}}_setAbsoluteSizes(){var e,n=this._calculateAbsoluteSizes();for(e=0;e<this.contentItems.length;e++)n.additionalPixel-e>0&&n.itemSizes[e]++,this._isColumn?(this.contentItems[e].element.width(n.totalWidth),this.contentItems[e].element.height(n.itemSizes[e])):(this.contentItems[e].element.width(n.itemSizes[e]),this.contentItems[e].element.height(n.totalHeight))}_calculateAbsoluteSizes(){const e=(this.contentItems.length-1)*this._splitterSize;let n=this.element.width()??0,s=this.element.height()??0,i=0;const o=[];this._isColumn?s-=e:n-=e;for(let l=0;l<this.contentItems.length;l++){const a=this._isColumn?Math.floor(s*((this.contentItems[l].config.height??0)/100)):Math.floor(n*((this.contentItems[l].config.width??0)/100));i+=a,o.push(a)}const r=Math.floor((this._isColumn?s:n)-i);return{itemSizes:o,additionalPixel:r,totalWidth:n,totalHeight:s}}_calculateRelativeSizes(){let e=0;const n=[],s=this._isColumn?"height":"width";for(let i=0;i<this.contentItems.length;i++)this.contentItems[i].config[s]!==void 0?e+=this.contentItems[i].config[s]??0:n.push(this.contentItems[i]);if(Math.round(e)===100){this._respectMinItemWidth();return}if(Math.round(e)<100&&n.length>0){for(let i=0;i<n.length;i++)n[i].config[s]=(100-e)/n.length;this._respectMinItemWidth();return}if(Math.round(e)>100)for(let i=0;i<n.length;i++)n[i].config[s]=50,e+=50;for(let i=0;i<this.contentItems.length;i++)this.contentItems[i].config[s]=(this.contentItems[i].config[s]??0)/e*100;this._respectMinItemWidth()}_respectMinItemWidth(){const e=this.layoutManager.config.dimensions?this.layoutManager.config.dimensions.minItemWidth??0:0,n=[];let s=0,i=0,o=0;const r=[];let l;if(this._isColumn||!e||this.contentItems.length<=1)return;const a=this._calculateAbsoluteSizes();for(let c=0;c<this.contentItems.length;c++){this.contentItems[c];const u=a.itemSizes[c];u<e?(i+=e-u,l={width:e}):(s+=u-e,l={width:u},n.push(l)),r.push(l)}if(i===0||i>s)return;const d=i/s;o=i;for(let c=0;c<n.length;c++){l=n[c];const u=Math.round((l.width-e)*d);o-=u,l.width-=u}o!==0&&(r[r.length-1].width-=o);for(let c=0;c<this.contentItems.length;c++)this.contentItems[c].config.width=r[c].width/a.totalWidth*100}_createSplitter(e){var n;return n=new $u(this._isColumn,this._splitterSize,this._splitterGrabSize),n.on("drag",this._onSplitterDrag.bind(this,n),this),n.on("dragStop",this._onSplitterDragStop.bind(this,n),this),n.on("dragStart",this._onSplitterDragStart.bind(this,n),this),this._splitter.splice(e,0,n),n}_getItemsForSplitter(e){const n=this._splitter.indexOf(e);if(n<0)throw new Error("Splitter not found in RowOrColumn");return{before:this.contentItems[n],after:this.contentItems[n+1]}}_getMinimumDimensions(e){for(var n=0,s=0,i=0;i<e.length;++i)n=Math.max(e[i].minWidth??0,n),s=Math.max(e[i].minHeight??0,s);return{horizontal:n,vertical:s}}_onSplitterDragStart(e){const n=this._getItemsForSplitter(e),s=this.layoutManager.config.dimensions[this._isColumn?"minItemHeight":"minItemWidth"];var i=this._getMinimumDimensions(n.before.config.content??[]),o=this._isColumn?i.vertical:i.horizontal,r=this._getMinimumDimensions(n.after.config.content??[]),l=this._isColumn?r.vertical:r.horizontal;this._splitterPosition=0,this._splitterMinPosition=-1*((n.before.element[this._dimension]()??0)-(o||s)),this._splitterMaxPosition=(n.after.element[this._dimension]()??0)-(l||s)}_onSplitterDrag(e,n,s){const i=this._isColumn?s:n;this._splitterMaxPosition==null||this._splitterMinPosition==null||i>this._splitterMinPosition&&i<this._splitterMaxPosition&&(this._splitterPosition=i,e.element.css(this._isColumn?"top":"left",i))}_onSplitterDragStop(e){const n=this._getItemsForSplitter(e),s=n.before.element[this._dimension]()??0,i=n.after.element[this._dimension]()??0,o=((this._splitterPosition??0)+s)/(s+i),r=(n.before.config[this._dimension]??0)+(n.after.config[this._dimension]??0);n.before.config[this._dimension]=o*r,n.after.config[this._dimension]=(1-o)*r,e.element.css({top:0,left:0}),bl(this.callDownwards.bind(this,"setSize",void 0,void 0,void 0))}}class Sa extends Tt{constructor(e,n,s){super(e,{...n,type:"root"},null,pe('<div class="lm_goldenlayout lm_item lm_root"></div>')),this.isRoot=!0,this.type="root",this.childElementContainer=this.element,this._containerElement=s,this._containerElement.append(this.element)}addChild(e,n){if(this.contentItems.length>0)throw new Error("Root node can only have a single child");e=this.layoutManager._$normalizeContentItem(e,this),this.childElementContainer.append(e.element),super.addChild(e,n),this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged")}setSize(e,n){e=typeof e>"u"?this._containerElement.width()??0:e,n=typeof n>"u"?this._containerElement.height()??0:n,this.element.width(e),this.element.height(n),this.contentItems[0]&&(this.contentItems[0].element.width(e),this.contentItems[0].element.height(n))}_$getArea(){const e=super._$getArea();if(e==null)throw new Error("Unable to get root area");return e}_$highlightDropZone(e,n,s){this.layoutManager.tabDropPlaceholder.remove(),super._$highlightDropZone(e,n,s)}_$onDrop(e,n){var s;if(hn(e)&&(s=this.layoutManager.createContentItem({type:"stack",header:e.config.header||{}},this),s._$init(),s.addChild(e),e=s),!this.contentItems.length)this.addChild(e);else{const{side:i}=n,o=i==="left"||i==="right"?"row":"column",r=i==="left"||i==="right"?"width":"height",l=i==="left"||i==="top",a=this.contentItems[0];if(!(a instanceof $r)||a.type!=o){const d=this.layoutManager.createContentItem({type:o},this);this.replaceChild(a,d),d.addChild(e,l?0:void 0,!0),d.addChild(a,l?void 0:0,!0),a.config[r]=50,e.config[r]=50,d.callDownwards("setSize")}else{const d=a.contentItems[l?0:a.contentItems.length-1];a.addChild(e,l?0:void 0,!0),d.config[r]=(d.config[r]??0)*.5,e.config[r]=d.config[r],a.callDownwards("setSize")}}}}class ba extends Tt{constructor(e,n,s){super(e,n,s,pe('<div class="lm_item lm_stack"></div>')),this._activeContentItem=null,this.childElementContainer=pe('<div class="lm_items"></div>'),this.isStack=!0,this._dropZones={},this._dropSegment=null,this._contentAreaDimensions=null,this._sided=!1,this.parent=s,this.config=n;const i=e.config;this._side=!1,this._header={show:i.settings?.hasHeaders&&n.hasHeaders!==!1,popout:i.settings?.showPopoutIcon?i.labels?.popout:void 0,maximise:i.settings?.showMaximiseIcon?i.labels?.maximise:void 0,close:i.settings?.showCloseIcon?i.labels?.close:void 0,minimise:i.labels?.minimise??void 0},i.header&&(this._header={...this._header,...i.header}),n.header&&(this._header={...this._header,...n.header}),n.content&&n.content[0]&&n.content[0].header&&(this._header={...this._header,...n.content[0].header}),this.header=new Ho(e,this),this.element.append(this.header.element),this.element.append(this.childElementContainer),this._setupHeaderPosition(),this._$validateClosability()}setSize(){var e,n=this._header.show?this.layoutManager.config.dimensions?.headerHeight??0:0,s=(this.element.width()??0)-(this._sided?n:0),i=(this.element.height()??0)-(this._sided?0:n);for(this.childElementContainer.width(s),this.childElementContainer.height(i),e=0;e<this.contentItems.length;e++)this.contentItems[e].element.width(s).height(i);this.emit("resize"),this.emitBubblingEvent("stateChanged")}_$init(){if(this.isInitialised!==!0){this.header._attachWheelListener(),super._$init();for(let e=0;e<this.contentItems.length;e++)this.header.createTab(this.contentItems[e]),this.contentItems[e]._$hide();if(this.contentItems.length>0){const e=this.contentItems[this.config.activeItemIndex||0];if(!e)throw new Error("Configured activeItemIndex out of bounds");this.setActiveContentItem(e)}}}setActiveContentItem(e){if(this.contentItems.indexOf(e)===-1)throw new Error("contentItem is not a child of this stack");this._activeContentItem!==null&&this._activeContentItem._$hide(),this._activeContentItem=e,this.header.setActiveContentItem(e),e._$show(),this.emit("activeContentItemChanged",e),this.layoutManager.emit("activeContentItemChanged",e),this.emitBubblingEvent("stateChanged")}getActiveContentItem(){return this.header.activeContentItem}addChild(e,n){e=this.layoutManager._$normalizeContentItem(e,this),super.addChild(e,n),this.childElementContainer.append(e.element),this.header.createTab(e,n),this.setActiveContentItem(e),this.callDownwards("setSize"),this._$validateClosability(),this.emitBubblingEvent("stateChanged")}removeChild(e,n=!1){var s=this.contentItems.indexOf(e);super.removeChild(e,n),this.header.removeTab(e),this.header.activeContentItem===e&&(this.contentItems.length>0?this.setActiveContentItem(this.contentItems[Math.max(s-1,0)]):this._activeContentItem=null),this._$validateClosability(),this.emitBubblingEvent("stateChanged")}_$validateClosability(){let e=this.header._isClosable();for(let n=0,s=this.contentItems.length;n<s&&e;n++)e=this.contentItems[n].config.isClosable??!1;this.header._$setClosable(e)}_$destroy(){Tt.prototype._$destroy.call(this),this.header._$destroy()}_$onDrop(e){if(this._dropSegment==="header"){this._resetHeaderDropZone(),this.addChild(e,this._dropIndex);return}if(this._dropSegment==="body"){this.addChild(e);return}const n=this._dropSegment==="top"||this._dropSegment==="bottom",s=this._dropSegment==="left"||this._dropSegment==="right",i=this._dropSegment==="top"||this._dropSegment==="left",o=n&&this.parent.isColumn||s&&this.parent.isRow,r=n?"column":"row",l=n?"height":"width";if(hn(e)){const a=this.layoutManager.createContentItem({type:"stack",header:e.config.header||{}},this);a._$init(),a.addChild(e),e=a}if(o){const a=this.parent.contentItems.indexOf(this);this.parent.addChild(e,i?a:a+1,!0),this.config[l]=(this.config[l]??0)*.5,e.config[l]=this.config[l],this.parent.callDownwards("setSize")}else{const a=this.layoutManager.createContentItem({type:r},this);this.parent.replaceChild(this,a),a.addChild(e,i?0:void 0,!0),a.addChild(this,i?void 0:0,!0),this.config[l]=50,e.config[l]=50,a.callDownwards("setSize")}}_$highlightDropZone(e,n){if(!!this._contentAreaDimensions)for(let[s,i]of Object.entries(this._contentAreaDimensions)){const o=i.hoverArea;if(o.x1<e&&o.x2>e&&o.y1<n&&o.y2>n){s==="header"?(this._dropSegment="header",this._highlightHeaderDropZone(e)):(this._resetHeaderDropZone(),this._highlightBodyDropZone(s));return}}}_$getArea(){if(this.element.is(":visible")===!1)return null;const e=super._$getArea(this.header.element),n=super._$getArea(this.childElementContainer);if(e==null||n==null)return null;const s=n.x2-n.x1,i=n.y2-n.y1;return this._contentAreaDimensions={header:{hoverArea:{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2},highlightArea:{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2}}},this._activeContentItem&&this._activeContentItem.isComponent===!1?e:this.contentItems.length===0?(this._contentAreaDimensions.body={hoverArea:{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2},highlightArea:{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2}},super._$getArea(this.element)):(this._contentAreaDimensions.left={hoverArea:{x1:n.x1,y1:n.y1,x2:n.x1+s*.25,y2:n.y2},highlightArea:{x1:n.x1,y1:n.y1,x2:n.x1+s*.5,y2:n.y2}},this._contentAreaDimensions.top={hoverArea:{x1:n.x1+s*.25,y1:n.y1,x2:n.x1+s*.75,y2:n.y1+i*.5},highlightArea:{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y1+i*.5}},this._contentAreaDimensions.right={hoverArea:{x1:n.x1+s*.75,y1:n.y1,x2:n.x2,y2:n.y2},highlightArea:{x1:n.x1+s*.5,y1:n.y1,x2:n.x2,y2:n.y2}},this._contentAreaDimensions.bottom={hoverArea:{x1:n.x1+s*.25,y1:n.y1+i*.5,x2:n.x1+s*.75,y2:n.y2},highlightArea:{x1:n.x1,y1:n.y1+i*.5,x2:n.x2,y2:n.y2}},super._$getArea(this.element))}_highlightHeaderDropZone(e){const n=this.header.tabs.length;if(n===0){const u=this.header.element.offset();this.layoutManager.dropTargetIndicator?.highlightArea({x1:u?.left??0,x2:(u?.left??0)+100,y1:this.header.element.offset()?.top??0,y2:(this.header.element.offset()?.top??0)+(this.header.element.innerHeight()??0)});return}const i=this.header.tabsContainer.get(0)?.getBoundingClientRect(),o=this.layoutManager.tabDropPlaceholder.get(0)?.getBoundingClientRect();if(!i||!o)return;e<i.left?e=i.left+1:e>i.right&&(e=i.right-1);let r,l;if(!(o.left<e&&e<o.right)){for(var a=0;a<n;a++)if(r=this.header.tabs[a].element,l=r.get(0)?.getBoundingClientRect(),l&&l.left<e&&e<l.right){this._dropIndex=a;break}r&&l&&e<l.left+l.width*.5?r.before(this.layoutManager.tabDropPlaceholder):r&&(this._dropIndex=Math.min((this._dropIndex??0)+1,n),r.after(this.layoutManager.tabDropPlaceholder))}let d=this.layoutManager.tabDropPlaceholder.offset()?.left??0;d=Math.max(d,this.header.tabsContainer.offset()?.left??0);var c=d+(this.layoutManager.tabDropPlaceholder.width()??0);c=Math.min(c,(this.header.tabsContainer.offset()?.left??0)+(this.header.tabsContainer.innerWidth()??0)),this.layoutManager.dropTargetIndicator?.highlightArea({x1:d,x2:c,y1:this.header.element.offset()?.top??0,y2:(this.header.element.offset()?.top??0)+(this.header.element.innerHeight()??0)})}_resetHeaderDropZone(){this.layoutManager.tabDropPlaceholder.remove()}_setupHeaderPosition(){const e=["right","left","bottom"].some(n=>n===this._header.show)?this._header.show:void 0;if(this.header.element.toggle(!!this._header.show),!!e&&(this._side=e,this._sided=["right","left"].indexOf(this._side.toString())>=0,this.element.removeClass("lm_left lm_right lm_bottom"),this._side&&this.element.addClass("lm_"+this._side),this.element.find(".lm_header").length&&this.childElementContainer)){const n=["right","bottom"].indexOf(this._side.toString())>=0?"before":"after";this.header.element[n](this.childElementContainer),this.callDownwards("setSize")}}_highlightBodyDropZone(e){const n=this._contentAreaDimensions?.[e]?.highlightArea;n&&this.layoutManager.dropTargetIndicator?.highlightArea(n),this._dropSegment=e}}const VS=Object.freeze(Object.defineProperty({__proto__:null,AbstractContentItem:Tt,ContentItem:Tt,Component:Vu,Root:Sa,RowOrColumn:$r,Stack:ba,isStack:_o,isComponent:hn,isRoot:Uu},Symbol.toStringTag,{value:"Module"})),Bu=class{constructor(t,e){this.element=pe(Bu._template),this.isActive=!1,this.header=t,this.contentItem=e,this.titleElement=this.element.find(".lm_title"),this.closeElement=this.element.find(".lm_close_tab"),this.closeElement[e.config.isClosable?"show":"hide"](),this.setTitle(e.config.title),this.contentItem.on("titleChanged",this.setTitle,this),this._layoutManager=this.contentItem.layoutManager,this._layoutManager.config.settings?.reorderEnabled&&e.config.reorderEnabled&&(this._dragListener=new Lo(this.element),this._dragListener.on("dragStart",this._onDragStart,this),this.contentItem.on("destroy",this._dragListener.destroy,this._dragListener)),this._onTabClick=this._onTabClick.bind(this),this._onCloseClick=this._onCloseClick.bind(this),this._onTabContentFocusIn=this._onTabContentFocusIn.bind(this),this._onTabContentFocusOut=this._onTabContentFocusOut.bind(this),this.element.on("click",this._onTabClick),this.element.on("auxclick",this._onTabClick),this.contentItem.config.isClosable?(this.closeElement.on("click",this._onCloseClick),this.closeElement.on("mousedown",this._onCloseMousedown)):this.closeElement.remove(),this.contentItem.tab=this,this.contentItem.emit("tab",this),this.contentItem.layoutManager.emit("tabCreated",this),hn(this.contentItem)&&(this.contentItem.container._contentElement.on("focusin",this._onTabContentFocusIn).on("focusout",this._onTabContentFocusOut),this.contentItem.container._contentElement[0].addEventListener("click",this._onTabContentFocusIn,!0),this.contentItem.container.tab=this,this.contentItem.container.emit("tab",this))}setTitle(t=""){this.titleElement.html(t)}setActive(t){t!==this.isActive&&(this.isActive=t,t?this.element.addClass("lm_active"):this.element.removeClass("lm_active"))}_$destroy(){this.element.off("click",this._onTabClick),this.element.off("auxclick",this._onTabClick),this.closeElement.off("click",this._onCloseClick),hn(this.contentItem)&&(this.contentItem.container._contentElement.off(),this.contentItem.container._contentElement[0].removeEventListener("click",this._onTabContentFocusIn,!0)),this._dragListener&&(this.contentItem.off("destroy",this._dragListener.destroy,this._dragListener),this._dragListener.off("dragStart",this._onDragStart),this._dragListener=void 0),this.element.remove()}_onDragStart(t,e){this.contentItem.parent?.isMaximised&&this.contentItem.parent.toggleMaximise(),this._dragListener&&new Po(t,e,this._dragListener,this._layoutManager,this.contentItem,this.header.parent)}_onTabContentFocusIn(){hn(this.contentItem)&&!this.contentItem.container._contentElement[0].contains(document.activeElement)&&this.contentItem.container._contentElement[0].focus(),this.element.addClass("lm_focusin")}_onTabContentFocusOut(){hn(this.contentItem)&&!this.contentItem.container._contentElement[0].contains(document.activeElement)&&this.element.removeClass("lm_focusin")}_onTabClick(t){if(!t||t.button===0){var e=this.header.parent.getActiveContentItem();this.contentItem!==e&&hn(this.contentItem)?(this.header.parent.setActiveContentItem(this.contentItem),this.contentItem.container.emit("tabClicked")):hn(this.contentItem)&&!this.contentItem.container._contentElement[0].contains(document.activeElement)&&(this.contentItem.container._contentElement.focus(),this.contentItem.container.emit("tabClicked")),this.header._hideAdditionalTabsDropdown(),this.element.get(0)?.scrollIntoView({inline:"nearest"})}else t.button===1&&this.contentItem.config.isClosable&&this._onCloseClick(t)}_onCloseClick(t){t.stopPropagation(),hn(this.contentItem)?this.contentItem.container.close():this.header.parent.removeChild(this.contentItem)}_onCloseMousedown(t){t.stopPropagation()}};let Ja=Bu;Ja._template=['<li class="lm_tab">','<span class="lm_title_before"></span>','<span class="lm_title"></span>','<div class="lm_close_tab"></div>',"</li>"].join("");const yr=class extends pn{constructor(t,e){super(),this.element=pe(yr._template),this.tabDropdownList=null,this.tabs=[],this.activeContentItem=null,this.closeButton=null,this.tabDropdownButton=null,this.tabNextButton=pe(yr._nextButtonTemplate),this.tabPreviousButton=pe(yr._previousButtonTemplate),this.holdTimer=null,this.rAF=null,this.CLICK_TIMEOUT=500,this.START_SPEED=.01,this.ACCELERATION=5e-4,this.SCROLL_LEFT="left",this.SCROLL_RIGHT="right",this.isDraggingTab=!1,this.isOverflowing=!1,this.isDropdownShown=!1,this.dropdownKeyIndex=0,this._lastVisibleTabIndex=-1,this.layoutManager=t,this.layoutManager.config.settings?.selectionEnabled&&(this.element.addClass("lm_selectable"),this.element.on("click",this._onHeaderClick.bind(this))),this.tabsContainer=this.element.find(".lm_tabs"),this.tabDropdownContainer=this.element.find(".lm_tabdropdown_list"),this.tabDropdownContainer.hide(),this.tabDropdownSearch=this.element.find(".lm_tabdropdown_search input"),this._handleFilterInput=this._handleFilterInput.bind(this),this._handleFilterKeydown=this._handleFilterKeydown.bind(this),this.tabDropdownSearch.on("input",this._handleFilterInput),this.tabDropdownSearch.on("keydown",this._handleFilterKeydown),this.controlsContainer=this.element.find(".lm_controls"),this.parent=e,this.parent.on("resize",this._updateTabSizes,this),this._handleItemPickedUp=this._handleItemPickedUp.bind(this),this._handleItemDropped=this._handleItemDropped.bind(this),this._handleNextMouseEnter=this._handleNextMouseEnter.bind(this),this._handleNextMouseLeave=this._handleNextMouseLeave.bind(this),this._handlePreviousMouseEnter=this._handlePreviousMouseEnter.bind(this),this._handlePreviousMouseLeave=this._handlePreviousMouseLeave.bind(this),this._handleScrollRepeat=this._handleScrollRepeat.bind(this),this._handleNextButtonMouseDown=this._handleNextButtonMouseDown.bind(this),this._handlePreviousButtonMouseDown=this._handlePreviousButtonMouseDown.bind(this),this._handleScrollButtonMouseDown=this._handleScrollButtonMouseDown.bind(this),this._handleScrollButtonMouseUp=this._handleScrollButtonMouseUp.bind(this),this._handleScrollEvent=this._handleScrollEvent.bind(this),this.tabNextButton.on("mousedown",this._handleNextButtonMouseDown),this.tabPreviousButton.on("mousedown",this._handlePreviousButtonMouseDown),this.tabsContainer.on("scroll",this._handleScrollEvent),this.layoutManager.on("itemPickedUp",this._handleItemPickedUp),this.layoutManager.on("itemDropped",this._handleItemDropped),this.tabsContainer.before(this.tabPreviousButton),this.tabPreviousButton=this.tabPreviousButton.find(">:first-child"),this.tabPreviousButton.hide(),this._showAdditionalTabsDropdown=this._showAdditionalTabsDropdown.bind(this),this._hideAdditionalTabsDropdown=this._hideAdditionalTabsDropdown.bind(this),this._tabControlOffset=this.layoutManager.config.settings?.tabControlOffset,this._createControls()}createTab(t,e){for(let s=0;s<this.tabs.length;s++)if(this.tabs[s].contentItem===t)return;const n=new Ja(this,t);if(this.tabs.length===0){this.tabs.push(n),this.tabsContainer.append(n.element);return}e===void 0&&(e=this.tabs.length),e>0?this.tabs[e-1].element.after(n.element):this.tabs[0].element.before(n.element),this.tabs.splice(e,0,n),this._updateTabSizes()}removeTab(t){for(var e=0;e<this.tabs.length;e++)if(this.tabs[e].contentItem===t){this.tabs[e]._$destroy(),this.tabs.splice(e,1);return}throw new Error("contentItem is not controlled by this header")}setActiveContentItem(t){for(var e,n=0;n<this.tabs.length;n++)e=this.tabs[n].contentItem===t,this.tabs[n].setActive(e),e===!0&&(this.activeContentItem=t,this.parent.config.activeItemIndex=n);this.tabs[this.parent.config.activeItemIndex??0].element.get(0)?.scrollIntoView({inline:"nearest"}),this._hideAdditionalTabsDropdown(),this._updateTabSizes(),this.parent.emitBubblingEvent("stateChanged")}position(t){let e=this.parent._header.show;return e&&!this.parent._side&&(e="top"),t!==void 0&&this.parent._header.show!==t&&(this.parent._header.show=t,this.parent._setupHeaderPosition()),e}_attachWheelListener(){this.tabsContainer.get(0)?.addEventListener("wheel",this._handleWheelEvent,{passive:!0})}_detachWheelListener(){this.tabsContainer.get(0)?.removeEventListener("wheel",this._handleWheelEvent)}_handleWheelEvent(t){const e=t.currentTarget;if(!(e instanceof HTMLElement))return;let n=Math.abs(t.deltaY)>Math.abs(t.deltaX)?t.deltaY:t.deltaX;t.deltaMode===WheelEvent.DOM_DELTA_PAGE?n*=this.tabsContainer.innerWidth()??1:t.deltaMode===WheelEvent.DOM_DELTA_LINE&&(n*=100/3),e.scrollLeft+=Math.round(n)}_handleScrollEvent(){this._checkScrollArrows()}_handleItemPickedUp(){this.isDraggingTab=!0,this.controlsContainer.on("mouseenter",this._handleNextMouseEnter),this.tabPreviousButton.on("mouseenter",this._handlePreviousMouseEnter)}_handleItemDropped(){this.isDraggingTab=!1,window.cancelAnimationFrame(this.rAF??-1),this.rAF=null,this.controlsContainer.off("mouseenter",this._handleNextMouseEnter),this.controlsContainer.off("mouseleave",this._handleNextMouseLeave),this.tabPreviousButton.off("mouseenter",this._handlePreviousMouseEnter),this.tabPreviousButton.off("mouseleave",this._handlePreviousMouseLeave)}_handleNextMouseEnter(){this.controlsContainer.on("mouseleave",this._handleNextMouseLeave),this._handleScrollRepeat(this.SCROLL_RIGHT,this.tabsContainer.scrollLeft()??0)}_handlePreviousMouseEnter(){this.tabPreviousButton.on("mouseleave",this._handlePreviousMouseLeave),this._handleScrollRepeat(this.SCROLL_LEFT,this.tabsContainer.scrollLeft()??0)}_handleNextMouseLeave(){window.cancelAnimationFrame(this.rAF??-1),this.rAF=null,this.controlsContainer.off("mouseleave",this._handleNextMouseLeave)}_handlePreviousMouseLeave(){window.cancelAnimationFrame(this.rAF??-1),this.rAF=null,this.tabPreviousButton.off("mouseleave",this._handlePreviousMouseLeave)}_handleNextButtonMouseDown(){var t;for(let e=0;e<this.tabs.length;e+=1)if((this.tabs[e].element.get(0)?.offsetLeft??0)>(this.tabsContainer.get(0)?.offsetWidth??0)+(this.tabsContainer.scrollLeft()??0)){t=this.tabs[e].element.get(0);break}if(t)t.scrollIntoView({behavior:"smooth",inline:"nearest"}),this._handleScrollButtonMouseDown(this.SCROLL_RIGHT);else{const e=this.tabsContainer.get(0);e&&(e.scrollLeft=this.tabsContainer.get(0)?.scrollWidth??0)}}_handlePreviousButtonMouseDown(){for(var t,e=this.tabs.length-1;e>=0;e-=1)if((this.tabs[e].element.get(0)?.offsetLeft??0)<(this.tabsContainer.scrollLeft()??0)){t=this.tabs[e].element.get(0);break}if(t)t.scrollIntoView({behavior:"smooth",inline:"start"}),this._handleScrollButtonMouseDown(this.SCROLL_LEFT);else{const n=this.tabsContainer.get(0);n&&(n.scrollLeft=0)}}_handleScrollButtonMouseDown(t){this.holdTimer=window.setTimeout(()=>{this._handleScrollRepeat(t,this.tabsContainer.scrollLeft()??0,100)},this.CLICK_TIMEOUT),window.addEventListener("mouseup",this._handleScrollButtonMouseUp)}_handleScrollButtonMouseUp(){clearTimeout(this.holdTimer??-1),this.holdTimer=null,cancelAnimationFrame(this.rAF??-1),this.rAF=null,window.removeEventListener("mouseup",this._handleScrollButtonMouseUp)}_checkScrollArrows(){this.tabsContainer.scrollLeft()===0?this.tabPreviousButton.first().prop("disabled",!0):(this.tabsContainer.scrollLeft()??0)+(this.tabsContainer.innerWidth()??0)===this.tabsContainer.get(0)?.scrollWidth?this.tabNextButton.prop("disabled",!0):(this.tabNextButton.prop("disabled",!1),this.tabPreviousButton.first().prop("disabled",!1))}_handleScrollRepeat(t,e,n=0,s){const i=this.tabsContainer.get(0);if(!i)return;const o=i.getBoundingClientRect();if(t===this.SCROLL_LEFT){if(this.tabsContainer.scrollLeft(e-n),this.isDraggingTab&&this.parent._highlightHeaderDropZone(o.left-1),this.tabsContainer.scrollLeft()===0){this._checkScrollArrows();return}}else if(t===this.SCROLL_RIGHT&&(this.tabsContainer.scrollLeft(e+n),this.isDraggingTab&&this.parent._highlightHeaderDropZone(o.right+1),(this.tabsContainer.scrollLeft()??0)+(this.tabsContainer.innerWidth()??0)===i.scrollWidth)){this._checkScrollArrows();return}window.cancelAnimationFrame(this.rAF??-1),this.rAF=window.requestAnimationFrame(r=>{var l=s||r,a=r-l,d=this.START_SPEED*a+.5*this.ACCELERATION*(a*a);d=Math.min(d,this.tabsContainer.get(0)?.scrollWidth??1/0),this._handleScrollRepeat(t,e,d,l)})}_$setClosable(t){return this.closeButton&&this._isClosable()?(this.closeButton.element[t?"show":"hide"](),!0):!1}_$destroy(){this.emit("destroy",this);for(var t=0;t<this.tabs.length;t++)this.tabs[t]._$destroy();this._detachWheelListener(),this._handleItemDropped(),pe(document).off("mouseup",this._hideAdditionalTabsDropdown),this.tabDropdownSearch.off("input",this._handleFilterInput),this.tabDropdownSearch.off("keydown",this._handleFilterKeydown),this.element.remove()}_getHeaderSetting(t){if(t in this.parent._header)return this.parent._header[t]}_createControls(){var t,e,n,s,i;if(i=this.layoutManager.config.labels.tabDropdown,this.layoutManager.config.labels.tabNextLabel,this.layoutManager.config.labels.tabPreviousLabel,this.tabDropdownButton=new Co(this,i,"lm_tabdropdown",this._showAdditionalTabsDropdown),this.tabDropdownButton.element.hide(),this.controlsContainer.prepend(this.tabNextButton),this.tabNextButton.hide(),this._getHeaderSetting("popout")&&(e=this._onPopoutClick.bind(this),n=this._getHeaderSetting("popout"),new Co(this,n,"lm_popout",e)),this._getHeaderSetting("maximise")){s=this.parent.toggleMaximise.bind(this.parent);const o=this._getHeaderSetting("maximise"),r=this._getHeaderSetting("minimise"),l=new Co(this,o,"lm_maximise",s);this.parent.on("maximised",function(){l.element.attr("title",r??"")}),this.parent.on("minimised",function(){l.element.attr("title",o??"")})}this._isClosable()&&(t=this.parent.remove.bind(this.parent),n=this._getHeaderSetting("close"),this.closeButton=new Co(this,n,"lm_close",t))}_showAdditionalTabsDropdown(){if(this.isDropdownShown){this._hideAdditionalTabsDropdown();return}this.tabDropdownList=this.tabsContainer.clone(!0).appendTo(this.tabDropdownContainer).children().removeClass("lm_active"),this.tabDropdownContainer.show(),this.isDropdownShown=!0,this.element.addClass("lm_dropdown_open"),this.tabDropdownSearch.val("").focus(),this.dropdownKeyIndex=0,this.tabDropdownList.eq(this.dropdownKeyIndex).addClass("lm_keyboard_active"),pe(document).on("mousedown",this._hideAdditionalTabsDropdown),this._updateAdditionalTabsDropdown()}_handleFilterKeydown(t){if(this.dropdownKeyIndex===-1)return;if(t.key==="Escape"){this._hideAdditionalTabsDropdown();return}if(t.key==="Enter"||t.key===" "){this._hideAdditionalTabsDropdown(),this.tabs[this.dropdownKeyIndex]._onTabClick();return}function e(n,s,i){if(i==null||i.length<2)return-1;for(var o=(n+s+i.length)%i.length;o!==n;){if(i.eq(o).css("display")!=="none")return o;o=(o+s+i.length)%i.length}return n}t.key==="ArrowDown"||t.key==="Tab"&&t.shiftKey===!1?(t.preventDefault(),this.tabDropdownList?.eq(this.dropdownKeyIndex).removeClass("lm_keyboard_active"),this.dropdownKeyIndex=e(this.dropdownKeyIndex,1,this.tabDropdownList),this.tabDropdownList?.eq(this.dropdownKeyIndex).addClass("lm_keyboard_active")):(t.key==="ArrowUp"||t.key==="Tab")&&(t.preventDefault(),this.tabDropdownList?.eq(this.dropdownKeyIndex).removeClass("lm_keyboard_active"),this.dropdownKeyIndex=e(this.dropdownKeyIndex,-1,this.tabDropdownList),this.tabDropdownList?.eq(this.dropdownKeyIndex).addClass("lm_keyboard_active"))}_handleFilterInput(t){if(this.tabDropdownList!=null){this.tabDropdownList.eq(this.dropdownKeyIndex).removeClass("lm_keyboard_active"),this.dropdownKeyIndex=-1;for(var e=0;e<this.tabDropdownList.length;e++)(this.tabs[e].contentItem.config.title?.toLowerCase().indexOf(t.target.value.toLowerCase())??-1)!==-1?(this.tabDropdownList.eq(e).css("display",""),this.dropdownKeyIndex===-1&&(this.dropdownKeyIndex=e)):this.tabDropdownList.eq(e).css("display","none");this.dropdownKeyIndex!==-1&&this.tabDropdownList.eq(this.dropdownKeyIndex).addClass("lm_keyboard_active")}}_hideAdditionalTabsDropdown(t){!this.isDropdownShown||t&&this.tabDropdownContainer.get(0)?.contains(t.target)||t&&this.tabDropdownButton?.element.get(0)===t.target||(this.element.removeClass("lm_dropdown_open"),this.tabDropdownContainer.hide(),this.isDropdownShown=!1,this.tabDropdownContainer.find(".lm_tabs").remove(),pe(document).off("mousedown",this._hideAdditionalTabsDropdown))}_updateAdditionalTabsDropdown(){this.tabDropdownContainer.css("max-height","");const t=this.tabDropdownContainer[0].scrollHeight;if(t===0)return;const e=(this.tabDropdownContainer.offset()?.top??0)-(pe(window).scrollTop()??0);e+t>(pe(window).height()??0)&&this.tabDropdownContainer.css("max-height",(pe(window).height()??0)-e-10)}_isClosable(){return Boolean(this.parent.config.isClosable&&this.layoutManager.config.settings.showCloseIcon)}_onPopoutClick(){this.layoutManager.config.settings.popoutWholeStack===!0?this.parent.popout():this.activeContentItem?.popout()}_onHeaderClick(t){t.target===this.element[0]&&this.parent.select()}_updateTabSizes(){if(this.tabs.length===0)return;const t=this.tabsContainer.get(0);!t||(!this.isOverflowing&&t.scrollWidth>t.clientWidth?(this.tabDropdownButton?.element.show(),this.tabNextButton.show(),this.tabPreviousButton.show(),this.isOverflowing=!0):this.isOverflowing&&t.scrollWidth<=t.clientWidth&&(this.tabDropdownButton?.element.hide(),this.tabNextButton.hide(),this.tabPreviousButton.hide(),this.isOverflowing=!1),this.isOverflowing&&this._checkScrollArrows())}};let Ho=yr;Ho._template=['<div class="lm_header">','<ul class="lm_tabs"></ul>','<ul class="lm_controls"></ul>','<ul class="lm_tabdropdown_list">','<li class="lm_tabdropdown_search"><input type="text" placeholder="Find tab..."></li>',"</ul>","</div>"].join("");Ho._previousButtonTemplate=['<ul class="lm_controls">','<li class="lm_tabpreviousbutton"></li>',"</ul>"].join("");Ho._nextButtonTemplate=['<li class="lm_tabnextbutton"></li>'].join("");class $u{constructor(e,n,s){this._isVertical=e,this._size=n,this._grabSize=s<n?n:s,this.element=this._createElement(),this._dragListener=new Lo(this.element)}on(e,n,s){this._dragListener?.on(e,n,s)}_$destroy(){this._dragListener?.destroy(),this._dragListener=null,this.element.remove()}_createElement(){var e=pe('<div class="lm_drag_handle"></div>'),n=pe('<div class="lm_splitter"></div>');n.append(e);var s=this._grabSize-this._size,i=s/2;return this._isVertical?(e.css("top",-i),e.css("height",this._size+s),n.addClass("lm_vertical"),n.height(this._size)):(e.css("left",-i),e.css("width",this._size+s),n.addClass("lm_horizontal"),n.width(this._size)),n}}class Gu{constructor(){this._element=pe('<div class="lm_transition_indicator"></div>'),this._toElement=null,this._fromDimensions={},this._totalAnimationDuration=200,this._animationStartTime=null,pe(document.body).append(this._element)}destroy(){this._element.remove()}transitionElements(e,n){}_nextAnimationFrame(){if(!this._toElement||this._animationStartTime==null)return;const e=this._measure(this._toElement),n=(Date.now()-this._animationStartTime)/this._totalAnimationDuration,s={};if(n>=1){this._element.hide();return}e.opacity=0;const i=Object.keys(this._fromDimensions);for(let o of i)s[o]=(this._fromDimensions[o]??0)+((e[o]??0)-(this._fromDimensions[o]??0))*n;this._element.css(s),bl(this._nextAnimationFrame.bind(this))}_measure(e){const n=e.offset();return{left:n?.left,top:n?.top,width:e.outerWidth(),height:e.outerHeight()}}}const BS=Object.freeze(Object.defineProperty({__proto__:null,BrowserPopout:Ou,DragProxy:Po,DragSource:Lu,DragSourceFromEvent:Pu,DropTargetIndicator:Qa,Header:Ho,HeaderButton:Co,Splitter:$u,Tab:Ja,TransitionIndicator:Gu},Symbol.toStringTag,{value:"Module"})),$S={config:MS,container:kS,controls:BS,errors:US,items:VS,utils:HS};class ed extends pn{constructor(e,n){super(),this.isInitialised=!1,this._isFullPage=!1,this._components={"lm-react-component":ku},this._itemAreas=[],this._maximisedItem=null,this._maximisePlaceholder=pe('<div class="lm_maximise_place"></div>'),this._creationTimeoutPassed=!1,this._subWindowsCreated=!1,this._dragSources=[],this._updatingColumnsResponsive=!1,this._firstLoad=!0,this.width=null,this.height=null,this.openPopouts=[],this.selectedItem=null,this.isSubWindow=!1,this.eventHub=new xu(this),this.dropTargetIndicator=null,this.transitionIndicator=null,this.tabDropPlaceholder=pe('<div class="lm_drop_tab_placeholder"></div>'),this._onResize=this._onResize.bind(this),this._onUnload=this._onUnload.bind(this),this._windowBlur=this._windowBlur.bind(this),this._windowFocus=this._windowFocus.bind(this),this.config=this._createConfig(e),this._originalContainer=n,this.container=this._getContainer(),this.isSubWindow&&pe("body").css("visibility","hidden"),this._typeToItem={column:$r.bind(this,!0),row:$r.bind(this,!1),stack:ba,component:Vu}}static minifyConfig(e){return ja(e)}static unminifyConfig(e){return fa(e)}registerComponent(e,n){if(typeof n!="function"&&(n==null||n.render==null||typeof n.render!="function"))throw new Error("Please register a constructor function");if(this._components[e]!==void 0)throw new Error("Component "+e+" is already registered");return this._components[e]=n,()=>{if(this._components[e]===void 0)throw new Error("Component "+e+" is not registered");delete this._components[e]}}setFallbackComponent(e){this._fallbackComponent=e}toConfig(e){if(this.isInitialised===!1)throw new Error("Can't create config, layout not yet initialised");if(e&&!(e instanceof Tt))throw new Error("Root must be a ContentItem");const n={settings:{...this.config.settings},dimensions:{...this.config.dimensions},labels:{...this.config.labels},content:[]},s=function(i,o){for(let r in o.config)r!=="content"&&(i[r]=o.config[r]);if(i.componentName==="lm-react-component"&&(i.type="react-component"),o.contentItems.length){i.content=[];for(let r=0;r<o.contentItems.length;r++)i.content[r]={},s(i.content[r],o.contentItems[r])}};e?s(n,{contentItems:[e]}):s(n,this.root),this._$reconcilePopoutWindows(),n.openPopouts=[];for(let i=0;i<this.openPopouts.length;i++)n.openPopouts.push(this.openPopouts[i].toConfig());return n.maximisedItemId=this._maximisedItem?"__glMaximised":void 0,n}getComponent(e){return this._components[e]}getFallbackComponent(){return this._fallbackComponent}init(){if(this._subWindowsCreated===!1&&(this._createSubWindows(),this._subWindowsCreated=!0),document.readyState==="loading"||document.body===null){pe(document).ready(this.init.bind(this));return}if(this.isSubWindow===!0&&this._creationTimeoutPassed===!1){setTimeout(this.init.bind(this),7),this._creationTimeoutPassed=!0;return}this.isSubWindow===!0&&this._adjustToWindowMode(),this._setContainer(),this.dropTargetIndicator=new Qa,this.transitionIndicator=new Gu,this.updateSize(),this._create(this.config),this._bindEvents(),this.isInitialised=!0,this._adjustColumnsResponsive(),this.emit("initialised")}updateSize(e,n){this.width=e??this.container.width()??0,this.height=n??this.container.height()??0,this.isInitialised===!0&&(this.root.callDownwards("setSize",[this.width,this.height]),this._maximisedItem&&(this._maximisedItem.element.width(this.container.width()??0),this._maximisedItem.element.height(this.container.height()??0),this._maximisedItem.callDownwards("setSize")),this._adjustColumnsResponsive())}destroy(){this.isInitialised===!1||!this.root||(this._onUnload(),pe(window).off("resize",this._onResize),pe(window).off("unload beforeunload",this._onUnload),pe(window).off("blur.lm").off("focus.lm"),this.root.callDownwards("_$destroy",[],!0),this.root.contentItems=[],this.tabDropPlaceholder.remove(),this.dropTargetIndicator?.destroy(),this.transitionIndicator?.destroy(),this.eventHub.destroy(),this._dragSources.forEach(function(e){e._dragListener.destroy()}),this._dragSources=[])}createContentItem(e,n){var s,i;if(typeof e.type!="string")throw new ni("Missing parameter 'type'",e);if(e.type==="react-component"&&(e.type="component",e.componentName="lm-react-component"),!this._typeToItem[e.type])throw s="Unknown type '"+e.type+"'. Valid types are "+Object.keys(this._typeToItem).join(","),new ni(s);return e.type==="component"&&!(n instanceof ba)&&!!n&&!(this.isSubWindow===!0&&n instanceof Sa)&&(e={type:"stack",width:e.width,height:e.height,content:[e]}),i=new this._typeToItem[e.type](this,e,n),i}createPopout(e,n,s,i){let o=[];const r=e instanceof Tt,l=this;if(r){o=this.toConfig(e).content,s=Ka();let d=e.parent,c=e;for(;d?.contentItems.length===1&&!d.isRoot;)c=d,d=d.parent;d?.addId(s),(i==null||Number.isNaN(i))&&(i=d?.contentItems.indexOf(c))}else e instanceof Array?o=e:o=[e];if(!n&&r){const d=window.screenX||window.screenLeft,c=window.screenY||window.screenTop,u=e.element.offset()??{left:0,top:0};n={left:d+u.left,top:c+u.top,width:e.element.width()??0,height:e.element.height()??0}}if(!n&&!r&&(n={left:window.screenX||window.screenLeft+20,top:window.screenY||window.screenTop+20,width:500,height:309}),r&&e.remove(),!n||!s||i===void 0)return;const a=new Ou(o,n,s,i,this);return a.on("initialised",function(){l.emit("windowOpened",a)}),a.on("closed",function(){l._$reconcilePopoutWindows()}),this.openPopouts.push(a),a}createDragSource(e,n){this.config.settings.constrainDragToContainer=!1;var s=new Lu(e,n,this);return this._dragSources.push(s),s}createDragSourceFromEvent(e,n){return this.config.settings.constrainDragToContainer=!1,new Pu(e,this,n)}selectItem(e,n){if(this.config.settings.selectionEnabled!==!0)throw new Error("Please set selectionEnabled to true to use this feature");e!==this.selectedItem&&(this.selectedItem!==null&&this.selectedItem.deselect(),e&&n!==!0&&e.select(),this.selectedItem=e,this.emit("selectionChanged",e))}_$maximiseItem(e){this._maximisedItem!==null&&this._$minimiseItem(this._maximisedItem),this._maximisedItem=e,this._maximisedItem.addId("__glMaximised"),e.element.addClass("lm_maximised"),e.element.after(this._maximisePlaceholder),this.root.element.prepend(e.element),e.element.width(this.container.width()??0),e.element.height(this.container.height()??0),e.callDownwards("setSize"),this._maximisedItem.emit("maximised"),this.emit("stateChanged")}_$minimiseItem(e){e.element.removeClass("lm_maximised"),e.removeId("__glMaximised"),this._maximisePlaceholder.after(e.element),this._maximisePlaceholder.remove(),e.parent?.callDownwards("setSize"),this._maximisedItem=null,e.emit("minimised"),this.emit("stateChanged")}_$closeWindow(){window.setTimeout(function(){window.close()},1)}_$getArea(e,n){let s=1/0,i=null;for(let o=0;o<this._itemAreas.length;o++){const r=this._itemAreas[o];e>r.x1&&e<r.x2&&n>r.y1&&n<r.y2&&s>r.surface&&(s=r.surface,i=r)}return i}_$createRootItemAreas(){const n={...this.root._$getArea()},s=[{...n,side:"left",x2:n.x1+50},{...n,side:"right",x1:n.x2-50},{...n,side:"top",y2:n.y1+50},{...n,side:"bottom",y1:n.y2-50}];s.forEach(i=>{i.surface=(i.x2-i.x1)*(i.y2-i.y1)}),this._itemAreas.push(...s)}_$calculateItemAreas(){const e=this._getAllContentItems();if(this._itemAreas=[],e.length===1){this._itemAreas.push(this.root._$getArea());return}this._$createRootItemAreas();for(let n=0;n<e.length;n++){const s=e[n];if(!_o(s))continue;const i=s._$getArea();if(i!==null)if(i instanceof Array)this._itemAreas=this._itemAreas.concat(i);else{this._itemAreas.push(i);let o={...i,...i.contentItem._contentAreaDimensions?.header.highlightArea};o.surface=(o.x2-o.x1)*(o.y2-o.y1),this._itemAreas.push(o)}}}_$normalizeContentItem(e,n){if(!e)throw new Error("No content item defined");if(typeof e=="function"&&(e=e()),e instanceof Tt)return e;if(pe.isPlainObject(e)&&e.type){var s=this.createContentItem(e,n);return s.callDownwards("_$init"),s}else throw new Error("Invalid contentItem")}_$reconcilePopoutWindows(){const e=[];for(let n=0;n<this.openPopouts.length;n++)this.openPopouts[n].getWindow()?.closed===!1?e.push(this.openPopouts[n]):this.emit("windowClosed",this.openPopouts[n]);this.openPopouts.length!==e.length&&(this.emit("stateChanged"),this.openPopouts=e)}_getAllContentItems(){const e=[],n=s=>{if(e.push(s),s.contentItems instanceof Array)for(let i=0;i<s.contentItems.length;i++)n(s.contentItems[i])};return n(this.root),e}_bindEvents(){this._isFullPage&&pe(window).resize(this._onResize),pe(window).on("unload beforeunload",this._onUnload).on("blur.lm",this._windowBlur).on("focus.lm",this._windowFocus)}_windowBlur(){this.root.element.addClass("lm_window_blur")}_windowFocus(){this.root.element.removeClass("lm_window_blur")}_onResize(){clearTimeout(this._resizeTimeoutId),this._resizeTimeoutId=window.setTimeout(this.updateSize.bind(this),100)}_createConfig(e){var n=Mu("gl-window");n&&(this.isSubWindow=!0,e=JSON.parse(localStorage.getItem(n)||"{}"),e=fa(e),localStorage.removeItem(n)),e=pe.extend(!0,{},Fu,e);var s=function(i){for(var o in i){const r=i[o];o!=="props"&&typeof r=="object"&&r!=null?s(r):o==="type"&&r==="react-component"&&(i.type="component",i.componentName="lm-react-component")}};return s(e),e.settings?.hasHeaders===!1&&(e.dimensions.headerHeight=0),e}_adjustToWindowMode(){var e=pe('<div class="lm_popin" title="'+this.config.labels.popin+'"><div class="lm_icon"></div><div class="lm_bg"></div></div>');e.click(()=>{this.emit("popIn")}),document.title=Xa(this.config.content[0].title??""),pe("head").append(pe("body link, body style, template, .gl_keep")),this.container=pe("body").html("").css("visibility","visible").append(e),document.body.offsetHeight,window.__glInstance=this}_createSubWindows(){if(!!this.config.openPopouts)for(let e=0;e<this.config.openPopouts.length;e++){const n=this.config.openPopouts[e];this.createPopout(n.content,n.dimensions,n.parentId,n.indexInParent)}}_getContainer(){const e=this._originalContainer?pe(this._originalContainer):pe("body");if(e.length===0)throw new Error("GoldenLayout container not found");if(e.length>1)throw new Error("GoldenLayout more than one container element specified");return e}_setContainer(){const e=this._getContainer();e[0]===document.body&&(this._isFullPage=!0,pe("html, body").css({height:"100%",margin:0,padding:0,overflow:"hidden"})),this.container=e}_create(e){var n;if(!(e.content instanceof Array))throw e.content===void 0?n="Missing setting 'content' on top level of configuration":n="Configuration parameter 'content' must be an array",new ni(n,e);if(e.content.length>1)throw n="Top level content can't contain more then one element.",new ni(n,e);this.root=new Sa(this,{content:e.content},this.container),this.root.callDownwards("_$init"),e.maximisedItemId==="__glMaximised"&&this.root.getItemsById(e.maximisedItemId)[0].toggleMaximise()}_onUnload(){if(this.config.settings.closePopoutsOnUnload===!0)for(var e=0;e<this.openPopouts.length;e++)this.openPopouts[e].close()}_adjustColumnsResponsive(){if(!this._useResponsiveLayout()||this._updatingColumnsResponsive||!this.config.dimensions||!this.config.dimensions.minItemWidth||this.root.contentItems.length===0||!this.root.contentItems[0].isRow){this._firstLoad=!1;return}this._firstLoad=!1;var e=this.root.contentItems[0].contentItems.length;if(!(e<=1)){var n=this.config.dimensions.minItemWidth,s=e*n;if(!(this.width==null||s<=this.width)){this._updatingColumnsResponsive=!0;for(var i=Math.max(Math.floor(this.width/n),1),o=e-i,r=this.root.contentItems[0],l=this._findAllStackContainers()[0],a=0;a<o;a++){var d=r.contentItems[r.contentItems.length-1];this._addChildContentItemsToContainer(l,d)}this._updatingColumnsResponsive=!1}}}_useResponsiveLayout(){return this.config.settings&&(this.config.settings.responsiveMode=="always"||this.config.settings.responsiveMode=="onload"&&this._firstLoad)}_addChildContentItemsToContainer(e,n){n.type==="stack"?n.contentItems.forEach(function(s){e.addChild(s),n.removeChild(s,!0)}):n.contentItems.forEach(s=>{this._addChildContentItemsToContainer(e,s)})}_findAllStackContainers(){const e=[];return this._findAllStackContainersRecursive(e,this.root),e}_findAllStackContainersRecursive(e,n){n.contentItems.forEach(s=>{_o(s)?e.push(s):s.isComponent||this._findAllStackContainersRecursive(e,s)})}}ed.__lm=$S;const GS="_lm_root_15d73_3",WS="_lm_row_15d73_7",zS="_lm_item_15d73_7",qS="_lm_content_15d73_11",YS="_lm_dragging_15d73_17",KS="_lm_maximised_15d73_23",XS="_lm_maximise_placeholder_15d73_30",jS="_lm_splitter_15d73_34",ZS="_lm_vertical_15d73_41",QS="_lm_drag_handle_15d73_41",JS="_lm_horizontal_15d73_46",eb="_lm_header_15d73_56",tb="_lm_dropdown_open_15d73_63",nb="_lm_controls_15d73_69",sb="_lm_tabs_15d73_89",ib="_lm_tab_15d73_89",ob="_lm_title_15d73_104",rb="_lm_close_tab_15d73_111",lb="_lm_stack_15d73_120",ab="_lm_left_15d73_120",db="_lm_right_15d73_121",cb="_lm_dragProxy_15d73_125",hb="_lm_items_15d73_148",ub="_lm_tabdropdown_list_15d73_165",mb="_lm_bottom_15d73_192",pb="_lm_drop_tab_placeholder_15d73_207",gb="_lm_tabdropdown_15d73_165",fb="_lm_dropTargetIndicator_15d73_258",Cb="_lm_inner_15d73_264",Sb="_lm_transition_indicator_15d73_272",bb="_lm_popin_15d73_282",wb="_lm_bg_15d73_297",Tb="_lm_icon_15d73_300",vb="_lm_goldenlayout_15d73_304",Eb="_lm_selectable_15d73_340",yb="_lm_active_15d73_370",Rb="_lm_selected_15d73_388",Ib="_lm_keyboard_active_15d73_397",Fb="_lm_popout_15d73_416",Db="_lm_maximise_15d73_23",Nb="_lm_close_15d73_111",_b="_lm_tabnextbutton_15d73_425",Mb="_lm_tabpreviousbutton_15d73_428",kb="_lm_title_before_15d73_544",xb="_lm_focusin_15d73_568",Ob="_lm_window_blur_15d73_573",Ab="_lm_tabdropdown_search_15d73_631",Lb="_march_15d73_1",Pb="_app_15d73_712",Hb="_plotly_15d73_721",Sc={"tab-height":"28px","drag-border-width":"5px",lm_root:GS,lm_row:WS,lm_item:zS,lm_content:qS,lm_dragging:YS,lm_maximised:KS,lm_maximise_placeholder:XS,lm_splitter:jS,lm_vertical:ZS,lm_drag_handle:QS,lm_horizontal:JS,lm_header:eb,lm_dropdown_open:tb,lm_controls:nb,lm_tabs:sb,lm_tab:ib,lm_title:ob,lm_close_tab:rb,lm_stack:lb,lm_left:ab,lm_right:db,lm_dragProxy:cb,lm_items:hb,lm_tabdropdown_list:ub,lm_bottom:mb,lm_drop_tab_placeholder:pb,lm_tabdropdown:gb,lm_dropTargetIndicator:fb,lm_inner:Cb,lm_transition_indicator:Sb,lm_popin:bb,lm_bg:wb,lm_icon:Tb,lm_goldenlayout:vb,lm_selectable:Eb,lm_active:yb,lm_selected:Rb,lm_keyboard_active:Ib,lm_popout:Fb,lm_maximise:Db,lm_close:Nb,lm_tabnextbutton:_b,lm_tabpreviousbutton:Mb,lm_title_before:kb,"editor-unsaved-indicator":"_editor-unsaved-indicator_15d73_548","is-unsaved":"_is-unsaved_15d73_556",lm_focusin:xb,lm_window_blur:Ob,lm_tabdropdown_search:Ab,march:Lb,app:Pb,"js-plotly-plot":"_js-plotly-plot_15d73_721",plotly:Hb},bc=Object.freeze({tabHeight:parseInt(Sc["tab-height"],10),dragBorderWidth:parseInt(Sc["drag-border-width"],10)}),Ss=ee.module("LayoutUtils");function Wu(t){return t.componentName!==void 0}function Ri(t){const e=t;return(Wu(t)&&t.componentName==="lm-react-component"||t.type==="react-component")&&e.component!==void 0}function rr(t){return t.focus!==void 0}function wc(t){return t.type==="stack"}const Ve=class{static activateTab(t,e){const n=Ve.getStackForRoot(t,e,!1);if(!n){Ss.error("Could not find stack for config",e);return}const s=Ve.getContentItemInStack(n,e);s&&n.setActiveContentItem(s)}static isActiveTab(t,e){const n=Ve.getStackForRoot(t,e,!1);if(!n)return Ss.error("Could not find stack for config",e),!1;const s=Ve.getContentItemInStack(n,e);return n.getActiveContentItem()===s}static addStack(t,e=!0){const n=e?"column":"row";if(Uu(t)){(t.contentItems==null||t.contentItems.length===0)&&t.addChild({type:n});const o=t.contentItems[0];if(!(e?o.isColumn:o.isRow)){t.removeChild(o,!0),t.addChild({type:n});const l=document.activeElement;t.contentItems[0].addChild(o),l&&l.focus!=null&&l.focus()}return this.addStack(t.contentItems[0],e)}if(t.contentItems.length<2)return t.addChild({type:"stack"}),t.contentItems[t.contentItems.length-1];let s=t.contentItems[t.contentItems.length-1];return(e?s.isRow:s.isColumn)||(t.addChild({type:e?"row":"column"}),t.removeChild(s,!0),t.contentItems[t.contentItems.length-1].addChild(s),s=t.contentItems[t.contentItems.length-1]),this.addStack(s,!e)}static getStackForConfig(t,e={},n=!1){if(n&&_o(t)&&t.contentItems.length===0)return t;if(t.contentItems==null)return null;for(let s=0;s<t.contentItems.length;s+=1){const i=t.contentItems[s];if(i.isComponent&&i.config!=null&&Hd(i.config,e))return t;const o=this.getStackForConfig(i,e,n);if(o)return o}return null}static getStackForRoot(t,e,n=!0,s=!0,i=!0){let o=this.getStackForConfig(t,e);return!o&&s&&(o=this.getStackForConfig(t,{component:e.component},i)),!o&&n&&(o=this.addStack(t)),o}static getStackForComponentTypes(t,e,n=!0,s=!0,i=!0){for(let o=0;o<e.length;o+=1){const r=e[o],l=o===e.length-1,a=Ve.getStackForRoot(t,{component:r},n&&l,s,i);if(a)return a}return null}static getContentItemInStack(t,e){if(!t)return null;for(let n=0;n<t.contentItems.length;n+=1){const s=t.contentItems[n];if(s.isComponent&&s.config!=null&&Hd(s.config,e))return s}return null}static dehydrateLayoutConfig(t,e){if(t==null||!t.length)return[];const n=[];for(let s=0;s<t.length;s+=1){const i=t[s],{component:o,content:r}=i;if(o){const l=e(o,i);l!=null?n.push(l):Ss.debug2(`dehydrateLayoutConfig: skipping unmapped component "${o}"`)}else if(r){const l={...i,content:Ve.dehydrateLayoutConfig(r,e)};n.push(l)}else n.push(i)}return n}static getTabPoint(t){const{tab:e}=t;if(e==null)throw new Error(`Cannot get tab for panel container ${t}`);const n=e.element[0].getBoundingClientRect();return[n.left+n.width*.5,n.bottom-8]}static dropLayoutMinorChange(t){for(let e=0;e<t.length;e+=1){const n=t[e],{content:s}=n;s!==void 0?(wc(n)&&delete n.activeItemIndex,Ve.dropLayoutMinorChange(s)):Ri(n)&&n.component==="IrisGridPanel"&&n.props.panelState!=null&&(delete n.id,n.props.panelState.irisGridState.sorts=[],n.props.panelState.irisGridState.quickFilters=[])}}static isEqual(t,e,n=!1){if(n){const s=Ve.cloneLayout(t),i=Ve.cloneLayout(e);return Ve.dropLayoutMinorChange(s),Ve.dropLayoutMinorChange(i),ct(s,i)}return ct(t,e)}static cloneLayout(t){return JSON.parse(JSON.stringify(t))}static hydrateLayoutConfig(t,e){if(t==null||!t.length)return[];const n=[];for(let s=0;s<t.length;s+=1){const i=t[s];if(Ri(i)){const{component:o,props:r={}}=i;n.push({...i,id:i?.id??$e(),props:e(o,r)})}else if(i.content!==void 0){const o=Ve.hydrateLayoutConfig(i.content,e);wc(i)&&i.activeItemIndex!=null&&i.activeItemIndex>=o.length&&(Ss.warn("Fixing bad activeItemIndex!",i.activeItemIndex,i),i.activeItemIndex=0),n.push({...i,content:o})}else n.push(i)}return n}static openComponent({root:t,config:e,replaceExisting:n=!0,replaceConfig:s=void 0,createNewStack:i=!1,focusElement:o=void 0,dragEvent:r=void 0}={}){const l=document.activeElement,a={...e};if(a.id==null&&(a.id=$e.generate()),r){t?.layoutManager.createDragSourceFromEvent(a,r);return}const d=s||{id:a.id,component:a.component};k(t);const c=i?Ve.addStack(t):Ve.getStackForRoot(t,d);k(c);const u=Ve.getContentItemInStack(c,d);if(o!=null){const m=p=>{Ss.debug("Component created, focusing element",o),c.off("componentCreated",m);const{element:g}=p.origin;requestAnimationFrame(()=>{Ve.focusElement(g[0],o)})};c.on("componentCreated",m)}if(n&&u){const m=c.contentItems.indexOf(u);c.addChild(a,m+1),c.removeChild(u),c.setActiveContentItem(c.contentItems[m])}else c.addChild(a);o==null&&l&&rr(l)&&l.focus()}static openComponentInStack(t,e,n=!0){const s=document.activeElement,i={id:e.id},o=Ve.getContentItemInStack(t,i);if(n&&o&&t){const r=t?.contentItems.indexOf(o);t.addChild(e,r+1),t.removeChild(o),t.setActiveContentItem(t.contentItems[r])}else t?.addChild(e);s&&rr(s)&&s.focus()}static closeComponent(t,e,n){const s=Ve.getStackForRoot(t,e,!1,!1,!1);if(!s){Ss.warn("Cannot find stack for component, ignoring close",e);return}const i=Ve.getContentItemInStack(s,e),o=document.activeElement;i&&(hn(i)?i.container.close(n):s.removeChild(i)),o&&document.contains(o)&&rr(o)&&o.focus()}static renameComponent(t,e,n){const s=Ve.getStackForRoot(t,e,!1);if(!s){Ss.error("Could not find stack for config",e);return}const i=Ve.getContentItemInStack(s,e);i&&i.setTitle(n)}static cloneComponent(t,e){const n=Ve.getStackForRoot(t,e,!1);if(!n)return Ss.error("Could not find stack for config",e),null;const{props:s={}}=e,i=Ve.getPanelComponentState(e),o={type:"react-component",component:e.component,props:{...s,panelState:i},title:`${e.title} Copy`,id:$e.generate()};return Ve.openComponentInStack(n,o),o}static getPanelComponentState(t){return Wu(t)?t.componentState?.panelState:Ri(t)?t.props?.panelState:null}static makeDefaultLayout(){return{dimensions:{headerHeight:bc.tabHeight,borderWidth:bc.dragBorderWidth,borderGrabWidth:10},settings:{showPopoutIcon:!1,showCloseIcon:!1,constrainDragToContainer:!1}}}static getRootFromContainer(t){return t.layoutManager.root}static getComponentConfigFromContainer(t){return t?t.tab!=null&&t.tab.contentItem!=null?t.tab.contentItem.config:t._config:null}static getTitleFromContainer(t){return t!=null&&t.tab!=null&&t.tab.contentItem!=null?t.tab.contentItem.config.title:null}static getTitleFromTab(t){return t!=null&&t.contentItem!=null?t.contentItem.config.title:null}static getIdFromContainer(t){const e=Ve.getComponentConfigFromContainer(t);return e?e.id:null}static getIdFromPanel(t){const{glContainer:e}=t.props;return Ve.getIdFromContainer(e)}static getComponentNameFromPanel(t){const{glContainer:e}=t.props,n=Ve.getComponentConfigFromContainer(e);return n&&Ri(n)?n.component??null:null}static getComponentName(t){const e=t.WrappedComponent?.displayName??t.displayName;if(e==null)throw new Error(`Component displayName not defined ${t}`);return e}static focusElement(t,e=Ve.DEFAULT_FOCUS_SELECTOR){if(t==null)return null;const n=t.querySelector(e);return n==null?null:(rr(n)&&n.focus(),n)}static onInitialized(t){return new Promise(e=>{if(t.isInitialised){e();return}const n=()=>{t.off("initialised",n),e()};t.on("initialised",n)})}};let ie=Ve;ie.DEFAULT_FOCUS_SELECTOR="input, select, textarea, button";const zu=de.forwardRef((t,e)=>{const n=ie.getComponentNameFromPanel({props:t});return v("div",{ref:e,className:"panel-placeholder",children:['Component "',n,'" is not registered.']})});zu.displayName="PanelPlaceholder";const Ee=Object.freeze({FOCUS:"PanelEvent.FOCUS",MOUNT:"PanelEvent.MOUNT",UNMOUNT:"PanelEvent.UNMOUNT",TITLE_CHANGED:"PanelEvent.TITLE_CHANGED",REOPEN:"PanelEvent.REOPEN",DELETE:"PanelEvent.DELETE",CLONED:"PanelEvent.CLONED",CLOSED:"PanelEvent.CLOSED",OPEN:"PanelEvent.OPEN",CLOSE:"PanelEvent.CLOSE",DRAGGING:"PanelEvent.DRAGGING",DROPPED:"PanelEvent.DROPPED"});function Tc(t){return t?.WrappedComponent!==void 0}function Ub(t){return typeof t.id=="string"&&t.layout instanceof ed&&t.panelManager instanceof td&&typeof t.registerComponent=="function"}function Ps(t){if(!Ub(t))throw new Error(`Expected dashboard plugin props, but instead received ${t}`)}const an=ee.module("PanelManager");class td{constructor(e,n=(l,a)=>a,s=(l,a)=>a,i=new Map,o=[],r=()=>{}){this.handleFocus=this.handleFocus.bind(this),this.handleMount=this.handleMount.bind(this),this.handleUnmount=this.handleUnmount.bind(this),this.handleReopen=this.handleReopen.bind(this),this.handleDeleted=this.handleDeleted.bind(this),this.handleClosed=this.handleClosed.bind(this),this.handleControlClose=this.handleControlClose.bind(this),this.layout=e,this.hydrateComponent=n,this.dehydrateComponent=s,this.onPanelsUpdated=r,this.openedMap=new Map(i),this.closed=[...o],this.startListening()}startListening(){const{eventHub:e}=this.layout;e.on(Ee.FOCUS,this.handleFocus),e.on(Ee.MOUNT,this.handleMount),e.on(Ee.UNMOUNT,this.handleUnmount),e.on(Ee.REOPEN,this.handleReopen),e.on(Ee.DELETE,this.handleDeleted),e.on(Ee.CLOSED,this.handleClosed),e.on(Ee.CLOSE,this.handleControlClose)}stopListening(){const{eventHub:e}=this.layout;e.off(Ee.FOCUS,this.handleFocus),e.off(Ee.MOUNT,this.handleMount),e.off(Ee.UNMOUNT,this.handleUnmount),e.off(Ee.REOPEN,this.handleReopen),e.off(Ee.DELETE,this.handleDeleted),e.off(Ee.CLOSED,this.handleClosed),e.off(Ee.CLOSE,this.handleControlClose)}getClosedPanelConfigsOfType(e){return this.closed.filter(n=>n.component===e)}getOpenedPanels(){return Array.from(this.openedMap.values())}getOpenedPanelConfigs(){return this.getOpenedPanels().map(e=>{const{glContainer:n}=e.props;return ie.getComponentConfigFromContainer(n)})}getOpenedPanelConfigsOfType(e){return this.getOpenedPanelConfigs().filter(n=>n!=null&&Ri(n)&&n.component===e)}getOpenedPanelById(e){return this.openedMap.get(e)}getContainerByPanelId(e){const n=ie.getStackForConfig(this.layout.root,{id:e});return(n&&ie.getContentItemInStack(n,{id:e}))??null}getLastUsedPanel(e){const n=this.getOpenedPanels();for(let s=n.length-1;s>=0;s-=1){const i=n[s];if(e==null||e(i))return i}}getLastUsedPanelOfType(e){return this.getLastUsedPanelOfTypes([e])}getLastUsedPanelOfTypes(e){return this.getLastUsedPanel(n=>e.some(s=>Tc(s)&&n instanceof s.WrappedComponent||!Tc(s)&&n instanceof s))}updatePanel(e){const n=ie.getIdFromPanel(e);if(n==null){an.error("updatePanel Panel did not have an ID",e);return}an.debug2(`Updating panel ID ${n} in open panels map`),this.openedMap.delete(n),this.openedMap.set(n,e)}removePanel(e){const n=ie.getIdFromPanel(e);if(n==null){an.error("removePanel Panel did not have an ID",e);return}if(!this.openedMap.has(n)){an.error(`Missing panel ID ${n} in open panels map`);return}if(this.openedMap.get(n)!==e){an.debug(`Panel argument doesn't match the open panels map entry for ${n}, removePanel ignored`);return}an.debug2(`Removing panel ID ${n} from open panels map`),this.openedMap.delete(n)}removeClosedPanelConfig(e){const n=this.closed.findIndex(s=>s===e||s.id!=null&&e.id!=null&&s.id===e.id);n>=0&&this.closed.splice(n,1)}handleFocus(e){an.debug2("Focus: ",e),this.updatePanel(e)}handleMount(e){an.debug2("Mount: ",e),this.updatePanel(e),this.sendUpdate()}handleUnmount(e){an.debug2("Unmount: ",e),this.removePanel(e),this.sendUpdate()}handleReopen(e,n){an.debug2("Reopen:",e,n),this.removeClosedPanelConfig(e);const{component:s}=e;let{props:i}=e;i=this.hydrateComponent(s,i);const o={...e,props:i},{root:r}=this.layout;ie.openComponent({root:r,config:o,replaceConfig:n})}handleDeleted(e){an.debug2("Deleted:",e),this.removeClosedPanelConfig(e),this.sendUpdate()}handleClosed(e,n){an.debug2("Closed: ",e),this.addClosedPanel(n),this.sendUpdate()}handleControlClose(e){const n={id:e},{root:s}=this.layout;ie.closeComponent(s,n)}addClosedPanel(e){const n=ie.getComponentConfigFromContainer(e);if(n&&Ri(n)){const s=this.dehydrateComponent(n.component,n);s!=null&&this.closed.push(s)}}sendUpdate(){const{closed:e,openedMap:n}=this;this.onPanelsUpdated({closed:[...e],openedMap:new Map(n)})}}td.MAX_CLOSED_PANEL_COUNT=100;const Vb=ee.module("PanelErrorBoundary");class Bb extends b.exports.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){this.setState({error:e})}componentWillUnmount(){const{glContainer:e,glEventHub:n}=this.props,s=ie.getIdFromContainer(e);Vb.debug("componentWillUnmount",s),n.emit(Ee.CLOSED,s,e)}render(){const{children:e}=this.props,{error:n}=this.state;return n!=null?h("div",{className:"panel-error-boundary",children:h(el,{errorMessage:`${n}`,isLoading:!1,isLoaded:!1})}):e}}function nd(t){const{props:e,componentState:n}=t,{metadata:s}=e;let{panelState:i=null}=e;n&&({panelState:i}=n);const o={};return s!=null&&(o.metadata=s),i!=null&&(o.panelState=i),{...t,componentState:null,props:o,type:"react-component"}}function sd(t,e=""){return{metadata:{},...t,localDashboardId:e}}const wa={dehydrate:nd,hydrate:sd},$b=M.exports.shape({on:M.exports.func,off:M.exports.func,isHidden:M.exports.bool,tab:M.exports.shape({header:M.exports.shape({tabs:M.exports.arrayOf(M.exports.shape({contentItem:M.exports.shape({})}))})}),title:M.exports.string,setTitle:M.exports.func,close:M.exports.func}),qu=M.exports.shape({on:M.exports.func,off:M.exports.func,emit:M.exports.func}),Gb=M.exports.shape({registerComponent:M.exports.func,root:M.exports.shape({addChild:M.exports.func}),on:M.exports.func,off:M.exports.func,eventHub:qu}),id=Object.freeze({Container:$b,EventHub:qu,Layout:Gb}),Be=(t,e,n)=>b.exports.useEffect(function(){return t.on(e,n),()=>{t.off(e,n)}},[t,e,n]),Yu="SET_DASHBOARD_DATA",Wb=mS(Yu,{},!1),zb={dashboardData:Wb},qb=new Map,Yb=Object.freeze({}),Kb=Object.freeze([]),Xb=t=>t.dashboardData,Yt=(t,e)=>Xb(t)[e]??Yb,jb=(t,e)=>Yt(t,e).closed??Kb,Ku=(t,e)=>Yt(t,e).openedMap??qb,Xu=(t,e)=>({type:Yu,id:t,payload:e}),Vn=(t,e)=>(n,s)=>n(Xu(t,{...Yt(s(),t),...e}));Object.entries(zb).map(([t,e])=>Gi.register(t,e));const lr=ee.module("DashboardLayout"),Zb=Object.freeze({}),Qb=[],vc=()=>{},Ec=t=>t;function ju({id:t,children:e,emptyDashboard:n=h("div",{children:"Dashboard is empty."}),layout:s,layoutConfig:i=Qb,onLayoutChange:o=vc,onLayoutInitialized:r=vc,hydrate:l=sd,dehydrate:a=nd}){const d=Oa(),c=Rp(x=>Yt(x,t))??Zb,[u,m]=b.exports.useState(!1),[p,g]=b.exports.useState(!1),[f,C]=b.exports.useState(),[S]=b.exports.useState(c?.closed??[]),[w,T]=b.exports.useState(!1),y=b.exports.useMemo(()=>new Map,[]),E=b.exports.useMemo(()=>new Map,[]),R=Ip(),F=b.exports.useCallback((x,L,P=l,Z=a)=>{lr.debug2("registerComponent",x,L,P,Z);function ne(X,se){const ce=L,{glContainer:Q,glEventHub:he}=X;return h(ph,{store:R,children:h(Bb,{glContainer:Q,glEventHub:he,children:h(ce,{...X,ref:se})})})}const B=de.forwardRef(ne),W=s.registerComponent(x,B);return y.set(x,P),E.set(x,Z),W},[l,a,y,E,s,R]),D=b.exports.useCallback((x,L)=>(y.get(x)??Ec)(L,t),[y,t]),_=b.exports.useCallback((x,L)=>(E.get(x)??Ec)(L,t),[E,t]),H=b.exports.useMemo(()=>new td(s,D,_,new Map,S,({closed:x,openedMap:L})=>{d(Vn(t,{closed:x,openedMap:L}))}),[_,d,D,t,S,s]),U=b.exports.useCallback(()=>{if(p)return;w||(r(),T(!0));const L=s.toConfig().content,P=ie.dehydrateLayoutConfig(L,_),Z=f==null||!ie.isEqual(f,P);lr.debug("handleLayoutStateChanged",Z,L,P),Z&&(m(s.root.contentItems.length===0),C(P),o(P))},[_,w,p,f,s,o,r]),A=b.exports.useCallback(x=>{const L=ie.getIdFromContainer(x);s.eventHub.emit(Ee.DRAGGING,L),g(!0)},[s.eventHub]),Y=b.exports.useCallback(x=>{const L=ie.getIdFromContainer(x);s.eventHub.emit(Ee.DROPPED,L),g(!1)},[s.eventHub]),G=b.exports.useCallback(x=>{if(lr.debug2("handleComponentCreated",x),x==null||x.config==null||x.config.component==null||x.element==null)return;const P=`${x.config.component.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}-component`;x.element.addClass(P)},[]);Be(s,"stateChanged",U),Be(s,"itemPickedUp",A),Be(s,"itemDropped",Y),Be(s,"componentCreated",G),Be(s.eventHub,Ee.TITLE_CHANGED,U);const z=ll(i);return b.exports.useEffect(function(){if(z!==i&&i!==f){lr.debug("Setting new layout content...");const L=ie.hydrateLayoutConfig(i,D);for(;s.root.contentItems.length>0;)s.root.contentItems[0].remove();for(let P=0;P<L.length;P+=1)s.root.addChild(L[P]);m(s.root.contentItems.length===0)}},[D,s,i,f,H,z]),v(Se,{children:[u&&n,de.Children.map(e,x=>x!=null?de.cloneElement(x,{id:t,layout:s,panelManager:H,registerComponent:F}):null)]})}ju.propTypes={id:M.exports.string.isRequired,children:M.exports.node,data:M.exports.shape({}),emptyDashboard:M.exports.node,layout:id.Layout.isRequired,layoutConfig:M.exports.arrayOf(M.exports.shape({})),onLayoutChange:M.exports.func,onLayoutInitialized:M.exports.func};const Jb=100,ql=()=>{},ew=Object.freeze({});function tw({id:t="default",children:e,emptyDashboard:n,layoutConfig:s,layoutSettings:i=ew,onLayoutConfigChange:o=ql,onGoldenLayoutChange:r=ql,onLayoutInitialized:l=ql,fallbackComponent:a=zu,hydrate:d,dehydrate:c}){const u=b.exports.useRef(null),[m,p]=b.exports.useState(!1),[g,f]=b.exports.useState();b.exports.useEffect(function(){if(!u.current){f(void 0);return}const w={...ie.makeDefaultLayout()};w.settings===void 0&&(w.settings={}),Object.assign(w.settings,i),w.content=[];const T=new ed(w,u.current),y=()=>{T.off("initialised",y),p(!0)};return T.on("initialised",y),a!=null&&T.setFallbackComponent(a),T.init(),f(T),r(T),()=>{T.destroy()}},[i,a,r,p,f]);const C=b.exports.useMemo(()=>Pn(()=>{g!=null&&g.isInitialised&&g?.updateSize()},Jb),[g]);return b.exports.useEffect(function(){return window.addEventListener("resize",C),()=>{window.removeEventListener("resize",C)}},[C]),v("div",{className:"dashboard-container w-100 h-100",children:[h("div",{className:"w-100 h-100",ref:u}),m&&g&&h(ju,{emptyDashboard:n,id:t,layout:g,layoutConfig:s,onLayoutChange:o,onLayoutInitialized:l,hydrate:d,dehydrate:c,children:e})]})}const bn="default";class Zu extends Error{constructor(){super(...arguments),this.isAssertionFailed=!0}}function yc(t){if(t==null)throw new Zu(`Expected 'val' to be defined, but received ${t}`)}class Yl extends Error{constructor(){super(...arguments),this.isPasteError=!0}}function tt(t){return t?.isEditable!==void 0}function Rc(t){if(!tt(t))throw new Zu(`Expected 'model' to be editable, but received ${t}`)}function ze(t){return t?.hasExpandableRows!==void 0}var wn=(t=>(t.DOWN="DOWN",t.UP="UP",t.LEFT="LEFT",t.RIGHT="RIGHT",t))(wn||{});const ve=class{static normalize(t,e,n,s){let i=t,o=e,r=n,l=s;return i!=null&&r!=null&&r<i&&(i=r,r=t),o!=null&&l!=null&&l<o&&(o=l,l=e),[i,o,r,l]}static makeNormalized(t,e,n,s){return new ve(...ve.normalize(t,e,n,s))}static makeCell(t,e){return new ve(t,e,t,e)}static makeColumn(t){return new ve(t,null,t,null)}static makeRow(t){return new ve(null,t,null,t)}static minOrNull(t,e){return t==null||e==null?null:Math.min(t,e)}static maxOrNull(t,e){return t==null||e==null?null:Math.max(t,e)}static consolidate(t){const e=t.slice();let n=!0;for(;n;){n=!1;for(let s=0;s<e.length&&!n;s+=1){const i=e[s];for(let o=e.length-1;o>s;o-=1){const r=e[o];if(i.contains(r))e.splice(o,1);else if(r.contains(i)){n=!0,e[s]=r,e.splice(o,1);break}else if(i.startRow===r.startRow&&i.endRow===r.endRow){if(i.touches(r)){const{startRow:l,endRow:a}=i,d=ve.minOrNull(i.startColumn,r.startColumn),c=ve.maxOrNull(i.endColumn,r.endColumn);n=!0,e[s]=new ve(d,l,c,a),e.splice(o,1);break}}else if(i.startColumn===r.startColumn&&i.endColumn===r.endColumn&&i.touches(r)){const{startColumn:l,endColumn:a}=i,d=ve.minOrNull(i.startRow,r.startRow),c=ve.maxOrNull(i.endRow,r.endRow);n=!0,e[s]=new ve(l,d,a,c),e.splice(o,1);break}}}}return e}static isAxisRangeTouching(t,e,n,s){return t==null?e==null||n==null?!0:n<=e+1:e==null?s==null?!0:s>=t-1:n==null?s==null?!0:t<=s+1:s==null?e>=n-1:n>=t-1?n<=e+1:s>=t-1}static rangeArraysEqual(t,e){if(t===e)return!0;if(t==null||e==null||t.length!==e.length)return!1;for(let n=0;n<t.length;n+=1)if(!t[n].equals(e[n]))return!1;return!0}static intersection(t,e){if(t.equals(e))return t;let{startColumn:n,startRow:s,endColumn:i,endRow:o}=t;return n=n!=null&&e.startColumn!=null?Math.max(n,e.startColumn):n??e.startColumn,i=i!=null&&e.endColumn!=null?Math.min(i,e.endColumn):i??e.endColumn,s=s!=null&&e.startRow!=null?Math.max(s,e.startRow):s??e.startRow,o=o!=null&&e.endRow!=null?Math.min(o,e.endRow):o??e.endRow,n!=null&&n>(i??-1)||s!=null&&s>(o??-1)?null:new ve(n,s,i,o)}static subtractFromRange(t,e){const n=[],s=ve.intersection(t,e);return s==null?[t]:(s.startRow!=null&&(t.startRow==null||t.startRow<s.startRow)&&n.push(new ve(t.startColumn,t.startRow,t.endColumn,s.startRow-1)),s.startColumn!=null&&(t.startColumn==null||t.startColumn<s.startColumn)&&n.push(new ve(t.startColumn,s.startRow,s.startColumn-1,s.endRow)),s.endColumn!=null&&(t.endColumn==null||t.endColumn>s.endColumn)&&n.push(new ve(s.endColumn+1,s.startRow,t.endColumn,s.endRow)),s.endRow!=null&&(t.endRow==null||t.endRow>s.endRow)&&n.push(new ve(t.startColumn,s.endRow+1,t.endColumn,t.endRow)),n)}static subtractFromRanges(t,e){const n=[];for(let s=0;s<t.length;s+=1)n.push(...ve.subtractFromRange(t[s],e));return n}static subtractRangesFromRanges(t,e){let n=[...t];for(let s=0;s<e.length;s+=1)n=ve.subtractFromRanges(n,e[s]);return n}static isBounded(t){return t.startRow!=null&&t.startColumn!=null&&t.endRow!=null&&t.endColumn!=null}static boundedRange(t,e,n){return ve.isBounded(t)?t:new ve(t.startColumn??0,t.startRow??0,t.endColumn??e-1,t.endRow??n-1)}static boundedRanges(t,e,n){return t.map(s=>ve.boundedRange(s,e,n))}static offset(t,e,n){return new ve(t.startColumn!=null?t.startColumn+e:null,t.startRow!=null?t.startRow+n:null,t.endColumn!=null?t.endColumn+e:null,t.endRow!=null?t.endRow+n:null)}static nextCell(t,e=null,n=null,s=ve.SELECTION_DIRECTION.DOWN){if(t.length===0)return null;let i=-1;if(e!=null&&n!=null&&(i=t.findIndex(o=>o.containsCell(e,n)),i>=0)){const r=t[i].nextCell(e,n,s);if(r!=null)return r}switch(s){case ve.SELECTION_DIRECTION.DOWN:case ve.SELECTION_DIRECTION.RIGHT:{const o=i<t.length-1?i+1:0;return t[o].startCell(s)}case ve.SELECTION_DIRECTION.LEFT:case ve.SELECTION_DIRECTION.UP:{const o=i>0?i-1:t.length-1;return t[o].startCell(s)}default:throw new Error(`Invalid direction: ${s}`)}}static cellCount(t){return t.reduce((e,n)=>e+((n.endRow??NaN)-(n.startRow??NaN)+1)*((n.endColumn??NaN)-(n.startColumn??NaN)+1),0)}static rowCount(t){return t.reduce((e,n)=>e+(n.endRow??NaN)-(n.startRow??NaN)+1,0)}static columnCount(t){return t.reduce((e,n)=>e+(n.endColumn??NaN)-(n.startColumn??NaN)+1,0)}static containsCell(t,e,n){for(let s=0;s<t.length;s+=1)if(t[s].containsCell(e,n))return!0;return!1}static forEachCell(t,e,n=ve.SELECTION_DIRECTION.RIGHT){for(let s=0;s<t.length;s+=1)t[s].forEach(e,n)}constructor(t,e,n,s){this.startColumn=t,this.startRow=e,this.endColumn=n,this.endRow=s}equals(t){return this.startColumn===t.startColumn&&this.startRow===t.startRow&&this.endColumn===t.endColumn&&this.endRow===t.endRow}contains(t){return(this.startColumn==null||t.startColumn!=null&&this.startColumn<=t.startColumn)&&(this.startRow==null||t.startRow!=null&&this.startRow<=t.startRow)&&(this.endColumn==null||t.endColumn!=null&&this.endColumn>=t.endColumn)&&(this.endRow==null||t.endRow!=null&&this.endRow>=t.endRow)}containsCell(t,e){return t==null||e==null?!1:(this.startColumn==null||this.startColumn<=t)&&(this.endColumn==null||this.endColumn>=t)&&(this.startRow==null||this.startRow<=e)&&(this.endRow==null||this.endRow>=e)}touches(t){return ve.isAxisRangeTouching(this.startRow,this.endRow,t.startRow,t.endRow)&&ve.isAxisRangeTouching(this.startColumn,this.endColumn,t.startColumn,t.endColumn)}subtract(t){return ve.subtractFromRange(this,t)}startCell(t=ve.SELECTION_DIRECTION.DOWN){if(!ve.isBounded(this))throw new Error("Cannot get the startCell of an unbounded range");switch(t){case ve.SELECTION_DIRECTION.DOWN:case ve.SELECTION_DIRECTION.RIGHT:return{column:this.startColumn,row:this.startRow};case ve.SELECTION_DIRECTION.LEFT:case ve.SELECTION_DIRECTION.UP:return{column:this.endColumn,row:this.endRow};default:throw new Error(`Invalid direction: ${t}`)}}nextCell(t,e,n){if(!ve.isBounded(this))throw new Error("Bounded range required");if(t==null||e==null)throw new Error("Require a non-null cursor");const{startColumn:s,endColumn:i,startRow:o,endRow:r}=this;switch(n){case ve.SELECTION_DIRECTION.DOWN:if(e<r)return{column:t,row:Math.max(e+1,o)};if(t<i)return{column:Math.max(t+1,s),row:o};break;case ve.SELECTION_DIRECTION.UP:if(e>o)return{column:t,row:Math.min(e-1,r)};if(t>s)return{column:Math.min(t-1,i),row:r};break;case ve.SELECTION_DIRECTION.RIGHT:if(t<i)return{column:Math.max(t+1,s),row:e};if(e<r)return{column:s,row:Math.max(e+1,o)};break;case ve.SELECTION_DIRECTION.LEFT:if(t>s)return{column:Math.min(t-1,i),row:e};if(e>o)return{column:i,row:Math.min(e-1,r)};break;default:throw new Error(`Invalid direction: ${n}`)}return null}forEach(t,e=ve.SELECTION_DIRECTION.RIGHT){let n=0,{column:s,row:i}=this.startCell(e);for(;s!=null&&i!=null;)t(s,i,n),n+=1,{column:s,row:i}=this.nextCell(s,i,e)??{}}};let ae=ve;ae.SELECTION_DIRECTION=wn;function nw(t){return Array.isArray(t)&&t.length===2&&(t[0]===null||typeof t[0]=="number")&&(t[1]===null||typeof t[1]=="number")}function ar(t){return nw(t)&&t[0]!=null&&t[1]!=null}const Ne=class{static getGridPointFromXY(t,e,n){const s=Ne.getColumnAtX(t,n),i=Ne.getRowAtY(e,n),o=Ne.getColumnHeaderDepthAtY(e,n);return{x:t,y:e,row:i,column:s,columnHeaderDepth:o}}static getCellInfoFromXY(t,e,n){const{row:s,column:i}=Ne.getGridPointFromXY(t,e,n),{allColumnWidths:o,allRowHeights:r,allColumnXs:l,allRowYs:a,modelColumns:d,modelRows:c}=n,u=s!==null?c.get(s):null,m=i!==null?d.get(i):null,p=i!==null?l.get(i):null,g=s!==null?a.get(s):null,f=i!==null?o.get(i):null,C=s!==null?r.get(s):null;return{row:s,column:i,modelRow:u??null,modelColumn:m??null,left:p??null,top:g??null,columnWidth:f??null,rowHeight:C??null}}static getColumnHeaderDepthAtY(t,e){const n=Ne.getRowAtY(t,e),{columnHeaderHeight:s,columnHeaderMaxDepth:i}=e;if(n===null&&t<=s*i)return Qe(i-Math.ceil(t/s),0,i-1)}static iterateFloatingStart(t,e,n){for(let s=0;s<t&&s<e;s+=1){const i=n(s);if(i!==void 0)return i}}static iterateFloatingEnd(t,e,n){for(let s=0;s<t&&e-(t-s)>=0;s+=1){const i=n(e-(t-s));if(i!==void 0)return i}}static iterateFloating(t,e,n,s){const i=Ne.iterateFloatingStart(t,n,s);return i!==void 0?i:Ne.iterateFloatingEnd(e,n,s)}static iterateAllItems(t,e,n,s,i,o){const r=Math.max(t,n),l=Math.min(e,i-s-1);let a=Ne.iterateFloating(n,s,i,o);if(a!==void 0)return a;for(let d=r;d<=l;d+=1)if(a=o(d),a!==void 0)return a}static isInItem(t,e,n,s){const i=e.get(t)??0,o=n.get(t)??0;return i<=s&&s<=i+o}static getItemAtOffset(t,e,n,s,i,o,r,l=!1){const a=l?void 0:Ne.iterateFloating(n,s,e,d=>{if(Ne.isInItem(d,o,r,t))return d});if(!l&&a!==void 0)return a;for(let d=0;d<i.length;d+=1){const c=i[d];if(Ne.isInItem(c,o,r,t))return c}return null}static getColumnAtX(t,e,n=!1){const{columnCount:s,floatingLeftColumnCount:i,floatingRightColumnCount:o,visibleColumns:r,allColumnXs:l,allColumnWidths:a,gridX:d}=e;return t<d?null:this.getItemAtOffset(t-d,s,i,o,r,l,a,n)}static getRowAtY(t,e){const{floatingTopRowCount:n,floatingBottomRowCount:s,rowCount:i,visibleRows:o,allRowYs:r,allRowHeights:l,gridY:a}=e;return t<a?null:this.getItemAtOffset(t-a,i,n,s,o,r,l)}static getNextShownItem(t,e,n,s){let i=n.findIndex(o=>o===t)||0;for(i-=1;i!=null&&i>=0;){const o=n[i],r=e.get(o);if(r!=null&&s.get(r)!==0)return o;i-=1}return null}static getNextShownColumn(t,e){const{modelColumns:n,visibleColumns:s,userColumnWidths:i}=e;return Ne.getNextShownItem(t,n,s,i)}static getNextShownRow(t,e){const{modelRows:n,visibleRows:s,userRowHeights:i}=e;return Ne.getNextShownItem(t,n,s,i)}static getColumnSeparatorIndex(t,e,n,s){const{rowHeaderWidth:i,columnHeaderHeight:o,floatingColumns:r,floatingLeftWidth:l,visibleColumns:a,allColumnXs:d,allColumnWidths:c,columnHeaderMaxDepth:u}=n,{allowColumnResize:m,headerSeparatorHandleSize:p}=s;if(u*o<e||!m||p<=0)return null;const g=t-i,f=p*.5;let C=!1;for(let S=r.length-1;S>=0;S-=1){const w=r[S],T=d.get(w)??0,y=c.get(w)??0,E=y===0;if(!C||!E){let R=T+y;E?R+=f:C&&(R-=f);const F=R-f,D=R+f;if(F<=g&&g<=D)return w;C=E}}C=!1;for(let S=a.length-1;S>=0;S-=1){const w=a[S],T=d.get(w)??0,y=c.get(w)??0,E=y===0;if(T<l-y)return null;if(!C||!E){let R=T+y;E?R+=f:C&&(R-=f);const F=R-f,D=R+f;if(F<=g&&g<=D)return w;C=E}}return null}static isItemHidden(t,e){return e.get(t)===0}static isColumnHidden(t,e){const{allColumnWidths:n}=e;return Ne.isItemHidden(t,n)}static isFloatingRow(t,e){if(t==null)return!1;const{floatingTopRowCount:n,floatingBottomRowCount:s,rowCount:i}=e;return t<n||t>=i-s}static isFloatingColumn(t,e){if(t==null)return!1;const{floatingLeftColumnCount:n,floatingRightColumnCount:s,columnCount:i}=e;return t<n||t>=i-s}static getHiddenItems(t,e,n){if(!Ne.isItemHidden(t,e))return[];const s=[t],i=n.findIndex(o=>o===t);for(let o=i-1;o>=0;o-=1){const r=n[o];if(!Ne.isItemHidden(r,e))break;s.push(r)}return s}static getHiddenColumns(t,e){const{visibleColumns:n,allColumnWidths:s}=e;return Ne.getHiddenItems(t,s,n)}static getRowSeparatorIndex(t,e,n,s){const{rowHeaderWidth:i,columnHeaderHeight:o,visibleRows:r,allRowYs:l,allRowHeights:a}=n,{allowRowResize:d,headerSeparatorHandleSize:c}=s;if(i<t||!d||c<=0)return null;const u=e-o,m=c*.5;let p=!1;for(let g=r.length-1;g>=0;g-=1){const f=r[g],C=l.get(f)??0,S=a.get(f)??0,w=S===0;if(!p||!w){let T=C+S;w?T+=m:p&&(T-=m);const y=T-m,E=T+m;if(y<=u&&u<=E)return f;p=w}}return null}static isRowHidden(t,e){const{allRowHeights:n}=e;return Ne.isItemHidden(t,n)}static getHiddenRows(t,e){const{visibleRows:n,allRowHeights:s}=e;return Ne.getHiddenItems(t,s,n)}static moveItem(t,e,n){if(t===e)return[...n];const s=[...n],i=s[s.length-1];return i!=null&&!ar(i.from)&&i.to===t?i.from===e?s.pop():s[s.length-1]={...i,to:e}:s.push({from:t,to:e}),s}static moveRange(t,e,n,s=!1){if(t[0]===t[1])return Ne.moveItem(t[0],e,n);let i=e;if(s&&t[0]<e&&(i-=t[1]-t[0]),t[0]===i)return[...n];const o=[...n],r=o[o.length-1];r!=null&&ar(r.from)&&r.from[1]-r.from[0]===t[1]-t[0]&&r.to===t[0]?o[o.length-1]={...r,to:i}:o.push({from:t,to:i});const l=o[o.length-1];return ar(l.from)&&l.from[0]===l.to&&o.pop(),o}static moveItemOrRange(t,e,n,s=!1){return Array.isArray(t)?Ne.moveRange(t,e,n,s):Ne.moveItem(t,e,n)}static applyItemMoves(t,e,n,s=!1){let i=[[t,e]];for(let o=s?n.length-1:0;s?o>=0:o<n.length;s?o-=1:o+=1){const{from:r,to:l}=n[o];let a=1,d;ar(r)?(a=r[1]-r[0]+1,[d]=r):d=r;const c=s?l:d,u=c+a-1,m=s?d:l,p=m-c,g=[];for(let f=0;f<i.length;f+=1){const C=i[f][0]??Number.NEGATIVE_INFINITY,S=i[f][1]??Number.POSITIVE_INFINITY;let w;const T=[[C,c-1],[c,u],[u+1,S]].map(([y,E])=>[Math.max(y,C),Math.min(E,S)]).filter(([y,E])=>y<=E).map(y=>{const[E,R]=y;return c<=E&&u>=R?(w=[E+p,R+p],w):u<E?[E-a,R-a]:y}).map(y=>{const[E,R]=y;return m>E&&m<=R?[[E,m-1],[m+a,R+a]]:y===w?[y]:m<=E?[[E+a,R+a]]:[y]}).flat();g.push(...T)}i=g.map(([f,C])=>[Number.isFinite(f)?f:null,Number.isFinite(C)?C:null])}return i}static translateRange(t,e,n,s){const i=Ne.applyItemMoves(t.startColumn,t.endColumn,e,s),o=Ne.applyItemMoves(t.startRow,t.endRow,n,s),r=[];for(let l=0;l<i.length;l+=1){const a=i[l];for(let d=0;d<o.length;d+=1){const c=o[d];r.push(new ae(a[0],c[0],a[1],c[1]))}}return r}static getModelIndex(t,e){return Ne.applyItemMoves(t,t,e,!0)[0][0]}static getModelIndexes(t,e){return t.map(n=>Ne.getModelIndex(n,e))}static getModelRangeIndexes(t,e,n){return Ne.applyItemMoves(t,e,n,!0)}static getModelRange(t,e=He,n=He){return Ne.translateRange(t,e,n,!0)}static getModelRanges(t,e=He,n=He){const s=[];for(let i=0;i<t.length;i+=1)s.push(...Ne.getModelRange(t[i],e,n));return s}static getVisibleRangeIndexes(t,e,n){return Ne.applyItemMoves(t,e,n,!1)}static getVisibleRange(t,e=He,n=He){return this.translateRange(t,e,n,!1)}static getVisibleRanges(t,e=He,n=He){const s=[];for(let i=0;i<t.length;i+=1)s.push(...Ne.getVisibleRange(t[i],e,n));return s}static getVisibleIndex(t,e){return Ne.applyItemMoves(t,t,e)[0][0]}static getVisibleIndexes(t,e){return t.map(n=>Ne.getVisibleIndex(n,e))}static isMacPlatform(){const{platform:t}=window.navigator;return t.startsWith("Mac")}static getModifierKey(){return Ne.isMacPlatform()?"metaKey":"ctrlKey"}static isModifierKeyDown(t){const e=Ne.getModifierKey();return t[e]}static checkColumnHidden(t,e){return e.get(t)===0}static checkAllColumnsHidden(t,e){return e.size===0?!1:t.every(n=>e.get(n)===0)}static getScrollDragBounds(t,e,n){const{gridX:s,gridY:i,width:o,height:r,floatingTopRowCount:l,floatingBottomRowCount:a,floatingLeftColumnCount:d,floatingRightColumnCount:c,floatingLeftWidth:u,floatingRightWidth:m,floatingTopHeight:p,floatingBottomHeight:g,columnCount:f,rowCount:C}=t;let S=s,w=i,T=o,y=r;return n!=null&&(n>d&&(S+=u),n<f-c&&(T-=m)),e!=null&&(e>l&&(w+=p),e<C-a&&(y-=g)),{x1:S,y1:w,x2:T,y2:y}}static getScrollDelta(t,e=1024,n=768,s=20,i=20){let{deltaX:o,deltaY:r}=t;return!Ne.isMacPlatform()&&t.shiftKey&&t.deltaX===0&&t.deltaY!==0&&(o=t.deltaY,r=t.deltaX),t?.deltaMode===WheelEvent.DOM_DELTA_PAGE?(o*=e,r*=n):t?.deltaMode===WheelEvent.DOM_DELTA_LINE&&(Ne.isMacPlatform()?(o=Math.round(o*s),r=Math.round(r*i)):(o=Math.round(o*this.PIXELS_PER_LINE),r=Math.round(r*this.PIXELS_PER_LINE))),{deltaX:o,deltaY:r}}static compareRanges(t,e){return t[0]==null||t[1]==null||e[0]==null||e[1]==null?0:t[0]!==e[0]?t[0]-e[0]:t[1]-e[1]}static mergeSortedRanges(t){const e=[];for(let n=0;n<t.length;n+=1){const s=t[n],i=s[0],o=s[1];n===0?e.push([i,o]):i-1<=e[e.length-1][1]?e[e.length-1][1]=Math.max(e[e.length-1][1],o):e.push([i,o])}return e}};let q=Ne;q.PIXELS_PER_LINE=100/3;function O(t,e,n=void 0){const s=t.get(e)??n;if(s!==void 0)return s;throw new Error(`Missing value for key ${e}`)}function dr(t,e=Uo.CACHE_SIZE,n=Math.floor(e/2)){if(t.size>e){const s=t.keys();for(;t.size>n;)t.delete(s.next().value)}}function Ic(t,e,n,s,i){const o=new Map;let r=0;for(let l=0;l<t&&l<n;l+=1)o.set(l,r),r+=O(i,l);r=s;for(let l=0;l<e&&n-l-1>=0;l+=1)r-=O(i,n-l-1),o.set(n-l-1,r);return o}const Qu=class{constructor({userColumnWidths:t=new Map,userRowHeights:e=new Map,calculatedColumnWidths:n=new Map,calculatedRowHeights:s=new Map,fontWidths:i=new Map,modelRows:o=new Map,modelColumns:r=new Map,movedRows:l=[],movedColumns:a=[],initialRowHeights:d=new Map,initialColumnWidths:c=new Map}={}){this.userColumnWidths=t,this.userRowHeights=e,this.calculatedRowHeights=s,this.calculatedColumnWidths=n,this.fontWidths=i,this.modelRows=o,this.modelColumns=r,this.movedRows=l,this.movedColumns=a,this.initialRowHeights=d,this.initialColumnWidths=c}getMetrics(t){const{left:e,top:n,leftOffset:s,topOffset:i,width:o,height:r,theme:l,model:a,movedRows:d,movedColumns:c,draggingColumn:u}=t,{rowHeight:m,rowHeaderWidth:p,rowFooterWidth:g,columnWidth:f,columnHeaderHeight:C,minScrollHandleSize:S,scrollBarSize:w}=l;d!==this.movedRows&&(this.movedRows=d,this.modelRows.clear()),c!==this.movedColumns&&(this.movedColumns=c,this.modelColumns.clear());const{columnCount:T,rowCount:y,floatingTopRowCount:E,floatingBottomRowCount:R,floatingLeftColumnCount:F,floatingRightColumnCount:D,columnHeaderMaxDepth:_}=a,H=this.getFirstRow(t),U=this.getFirstColumn(t),A=this.getGridX(t),Y=this.getGridY(t),G=ze(a)&&a.hasExpandableRows?this.calculateTreePaddingX(t):0,z=0,x=this.getVisibleRowHeights(t),L=this.getVisibleColumnWidths(t,U,G),P=Array.from(x.keys()),Z=Array.from(L.keys()),ne=new Map([...x,...this.getFloatingRowHeights(t)]),B=new Map([...L,...this.getFloatingColumnWidths(t)]),W=this.getVisibleColumnXs(B,Z,s),X=this.getVisibleRowYs(ne,P,i),se=P.length>0?P[P.length-1]:n,ce=Z.length>0?Z[Z.length-1]:e,Q=this.getBottomViewport(t,P,X,ne),he=this.getRightViewport(t,Z,W,B),be=this.getFloatingTopHeight(t,ne),Re=this.getFloatingBottomHeight(t,ne),et=this.getFloatingLeftWidth(t,B),yt=this.getFloatingRightWidth(t,B),je=Array.from(B.values()),En=Array.from(ne.values()),Ut=je.reduce((it,In)=>it+In,0)-s,De=En.reduce((it,In)=>it+In,0)-i,mt=s+Ut+g,at=i+De,Rt=o-A,Vt=r-Y,yn=this.getLastLeft(t,null,Rt-g),on=this.getLastLeft(t,null,Rt-g-w),hi=this.getLastTop(t,null,Vt-Re),Hs=this.getLastTop(t,null,Vt-Re-w);let rn=on,cs=Hs;yn===0&&hi===0&&(rn=0,cs=0);const ui=rn>0,Zi=ui?w:0,mi=cs>0,pi=mi?w:0,Go=A,Wo=_*C,hs=o-Go-pi,Us=r-Wo-Zi,xl=T===1?hs/mt:(T-rn)/T,zo=y===1?Us/at:(y-cs)/y,Qi=ui?Qe(hs*xl,S,hs-1):0,Ji=mi?Qe(Us*zo,S,Us-1):0,qo=O(B,e,0),Yo=O(ne,n,0),Ol=qo>0?s/qo:0,Al=Yo>0?i/Yo:0,Ll=T===1?s/(mt-Rt):(e+Ol)/rn,Vs=y===1?i/(at-Vt):(n+Al)/cs,Pl=ui?Ll*(hs-Qi):0,Ko=mi?Vs*(Us-Ji):0,Xo=[...Array(E).keys(),...[...Array(R).keys()].map(it=>y-it-1)],eo=new Map([...X,...this.getFloatingRowYs(t,ne,Math.floor(r-Y-Zi))]),jo=[...Array(F).keys(),...[...Array(D).keys()].map(it=>T-it-1)],us=new Map([...W,...this.getFloatingColumnXs(t,B,Math.floor(o-A-pi))]),to=[];if(u)for(let it=u.range[0];it<=u.range[1];it+=1)to.push(it),B.has(it)||B.set(it,this.getVisibleColumnWidth(it,t)),us.has(it)||us.set(it,0);const Zo=P.concat(Xo),no=Z.concat(jo).concat(to),so=this.getModelRows(Zo,t),Hl=this.getModelColumns(no,t),Qo=this.getVisibleRowTreeBoxes(ne,so,t),Jo=this.getTopVisible(t,eo,ne,P),er=this.getLeftVisible(t,us,B,Z),tr=cs>0?this.getBottomVisible(t,eo,ne,P,Y):se,nr=rn>0?this.getRightVisible(t,us,B,Z,A):ce,{fontWidths:sr,userColumnWidths:Ul,userRowHeights:Ye,calculatedRowHeights:_t,calculatedColumnWidths:Rn}=this;return{rowHeight:m,rowHeaderWidth:p,rowFooterWidth:g,rowCount:y,columnWidth:f,columnCount:T,columnHeaderHeight:C,floatingTopRowCount:E,floatingBottomRowCount:R,floatingLeftColumnCount:F,floatingRightColumnCount:D,gridX:A,gridY:Y,firstRow:H,firstColumn:U,treePaddingX:G,treePaddingY:z,left:e,top:n,bottom:se,right:ce,topOffset:i,leftOffset:s,topVisible:Jo,leftVisible:er,bottomVisible:tr,rightVisible:nr,bottomViewport:Q,rightViewport:he,width:o,height:r,maxX:Ut,maxY:De,lastLeft:rn,lastTop:cs,barHeight:Us,barTop:Wo,barWidth:hs,barLeft:Go,handleHeight:Ji,handleWidth:Qi,hasHorizontalBar:ui,hasVerticalBar:mi,verticalBarWidth:pi,horizontalBarHeight:Zi,scrollX:Pl,scrollY:Ko,scrollableContentWidth:mt,scrollableContentHeight:at,scrollableViewportWidth:Rt,scrollableViewportHeight:Vt,visibleRows:P,visibleColumns:Z,visibleRowHeights:x,visibleColumnWidths:L,floatingRows:Xo,floatingColumns:jo,allRows:Zo,allColumns:no,allRowHeights:ne,allColumnWidths:B,floatingTopHeight:be,floatingBottomHeight:Re,floatingLeftWidth:et,floatingRightWidth:yt,visibleRowYs:X,visibleColumnXs:W,allRowYs:eo,allColumnXs:us,visibleRowTreeBoxes:Qo,modelRows:so,modelColumns:Hl,movedRows:d,movedColumns:c,fontWidths:sr,userColumnWidths:Ul,userRowHeights:Ye,calculatedRowHeights:_t,calculatedColumnWidths:Rn,columnHeaderMaxDepth:_}}getGridX(t){const{theme:e}=t,{rowHeaderWidth:n}=e;return n}getGridY(t){const{theme:e,model:n}=t,{columnHeaderHeight:s}=e,{columnHeaderMaxDepth:i}=n;return i*s}getVisibleHeight(t,e=this.getFloatingRowHeights(t)){const{height:n,theme:s}=t,{scrollBarSize:i}=s,o=this.getGridY(t),r=this.getFloatingBottomHeight(t,e),l=this.getFloatingTopHeight(t,e);return n-r-l-o-i}getVisibleWidth(t,e=this.getFloatingColumnWidths(t)){const{width:n,theme:s}=t,{scrollBarSize:i,rowFooterWidth:o}=s,r=this.getGridX(t),l=this.getFloatingRightWidth(t,e),a=this.getFloatingLeftWidth(t,e);return n-a-l-r-i-o}getFirstIndex(t,e,n){const s=t.size+1;for(let i=0;i<s;i+=1){const o=e(i,n);if(t.get(o)!==0)return i}return 0}getFirstColumn(t){return this.getFirstIndex(this.userColumnWidths,this.getModelColumn.bind(this),t)}getFirstRow(t){return this.getFirstIndex(this.userRowHeights,this.getModelRow.bind(this),t)}getLastLeft(t,e,n){const{model:s}=t,{columnCount:i,floatingRightColumnCount:o}=s;let r=Math.max(0,i-o-1);e!=null&&(r=e);let l=0;for(;r>=0;){if(l+=this.getVisibleColumnWidth(r,t),l>=n)return Qe(r+1,0,e??i-1);r-=1}return 0}getLastTop(t,e,n){const{model:s}=t,{rowCount:i,floatingBottomRowCount:o}=s;let r=Math.max(0,i-o-1);e!=null&&(r=e);let l=0;for(;r>=0;){if(l+=this.getVisibleRowHeight(r,t),l>=n)return Qe(r+1,0,i-1);r-=1}return 0}getTopForTopVisible(t,e){const n=this.getFloatingTopHeight(t);let s=e,i=0;for(;s>0&&i<n;)s-=1,i+=this.getVisibleRowHeight(s,t);return s}getTopForBottomVisible(t,e){const{height:n}=t,s=this.getGridY(t),i=this.getFloatingBottomHeight(t),o=n-s-i;return this.getLastTop(t,e,o)}getLeftForLeftVisible(t,e){const n=this.getFloatingLeftWidth(t);let s=e,i=0;for(;s>0&&i<n;)s-=1,i+=this.getVisibleColumnWidth(s,t);return s}getLeftForRightVisible(t,e){const{width:n}=t,s=this.getGridX(t),i=this.getFloatingRightWidth(t),o=n-s-i;return this.getLastLeft(t,e,o)}getFloatingRowHeights(t){const{model:e}=t,{floatingTopRowCount:n,floatingBottomRowCount:s,rowCount:i}=e,o=new Map;for(let r=0;r<n&&r<i;r+=1)o.set(r,this.getVisibleRowHeight(r,t));for(let r=0;r<s&&i-r-1>=0;r+=1){const l=i-r-1;o.set(l,this.getVisibleRowHeight(l,t))}return o}getVisibleRowHeights(t){const{top:e,topOffset:n,height:s,model:i}=t;let o=0,r=e;const l=new Map,{rowCount:a}=i;for(;o<s+n&&r<a;){const d=this.getVisibleRowHeight(r,t);l.set(r,d),o+=d,r+=1}return l}getFloatingColumnWidths(t,e=this.getFirstColumn(t),n=this.calculateTreePaddingX(t)){const{model:s}=t,{columnCount:i,floatingLeftColumnCount:o,floatingRightColumnCount:r}=s,l=new Map;for(let a=0;a<o&&a<i;a+=1)l.set(a,this.getVisibleColumnWidth(a,t,e,n));for(let a=0;a<r&&i-a-1>=0;a+=1){const d=i-a-1;l.set(d,this.getVisibleColumnWidth(d,t,e,n))}return l}getVisibleColumnWidths(t,e=this.getFirstColumn(t),n=this.calculateTreePaddingX(t)){const{left:s,leftOffset:i,width:o,model:r}=t;let l=0,a=s;const d=new Map,{columnCount:c}=r;for(;l<o+i&&a<c;){const u=this.getVisibleColumnWidth(a,t,e,n);d.set(a,u),l+=u,a+=1}return d}getFloatingColumnXs(t,e,n){const{model:s}=t,{columnCount:i,floatingLeftColumnCount:o,floatingRightColumnCount:r}=s;return Ic(o,r,i,n,e)}getVisibleColumnXs(t,e,n){const s=new Map;let i=-n;for(let o=0;o<e.length;o+=1){const r=e[o],l=O(t,r);s.set(r,i),i+=l}return s}getFloatingRowYs(t,e,n){const{model:s}=t,{floatingTopRowCount:i,floatingBottomRowCount:o,rowCount:r}=s;return Ic(i,o,r,n,e)}getVisibleRowYs(t,e,n){const s=new Map;let i=-n;for(let o=0;o<e.length;o+=1){const r=e[o],l=O(t,r);s.set(r,i),i+=l}return s}getVisibleRowTreeBoxes(t,e,n){const s=new Map,{model:i,theme:o}=n,{treeDepthIndent:r,treeHorizontalPadding:l}=o;return ze(i)&&i.hasExpandableRows&&t.forEach((a,d)=>{const c=O(e,d);if(i.isRowExpandable(c)){const u=i.depthForRow(c),m=u*r+l,p=(u+1)*r+l,g=0,f=a;s.set(d,{x1:m,y1:g,x2:p,y2:f})}}),s}getFloatingLeftWidth(t,e=this.getFloatingColumnWidths(t)){const{model:n}=t,{floatingLeftColumnCount:s}=n;let i=0;for(let o=0;o<s;o+=1)i+=O(e,o);return i}getFloatingRightWidth(t,e=this.getFloatingColumnWidths(t)){const{model:n}=t,{floatingRightColumnCount:s,columnCount:i}=n;let o=0;for(let r=0;r<s;r+=1)o+=O(e,i-r-1);return o}getFloatingTopHeight(t,e=this.getFloatingRowHeights(t)){const{model:n}=t,{floatingTopRowCount:s}=n;let i=0;for(let o=0;o<s;o+=1)i+=O(e,o);return i}getFloatingBottomHeight(t,e=this.getFloatingRowHeights(t)){const{model:n}=t,{floatingBottomRowCount:s,rowCount:i}=n;let o=0;for(let r=0;r<s;r+=1)o+=O(e,i-r-1);return o}getTopVisible(t,e,n,s){const i=this.getFloatingTopHeight(t,n);for(let o=0;o<s.length;o+=1){const r=s[o];if(O(e,r)>=i)return r}return 0}getLeftVisible(t,e,n,s){const i=this.getFloatingLeftWidth(t,n);for(let o=0;o<s.length;o+=1){const r=s[o];if(O(e,r)>=i)return r}return 0}getBottomVisible(t,e,n,s,i){const{height:o,theme:r}=t,{scrollBarSize:l}=r,a=this.getFloatingBottomHeight(t,n),d=o-i-l-a;for(let c=s.length-1;c>=0;c-=1){const u=s[c],m=O(e,u),p=O(n,u);if(m+p<=d)return u}return 0}getRightVisible(t,e,n,s,i){const{width:o,theme:r}=t,{scrollBarSize:l}=r,a=this.getFloatingRightWidth(t,n),d=o-i-l-a;for(let c=s.length-1;c>=0;c-=1){const u=s[c],m=O(e,u),p=O(n,u);if(m+p<=d)return u}return 0}getBottomViewport(t,e,n,s){const{height:i,theme:o}=t,{rowHeight:r}=o;return this.getLastIndexViewport(e,n,s,i,r)}getRightViewport(t,e,n,s){const{width:i,theme:o}=t,{columnWidth:r}=o;return this.getLastIndexViewport(e,n,s,i,r)}getLastIndexViewport(t,e,n,s,i){let o=0,r=0;return t.length>0&&(o=t[t.length-1],r=O(e,o)+O(n,o)),r<s&&(o+=Math.ceil((s-r)/i)),o}getVisibleItemSize(t,e,n){return e.get(t)??n()}getVisibleRowHeight(t,e){const n=this.getModelRow(t,e),s=this.calculateRowHeight(t,n,e);return this.getVisibleItemSize(n,this.userRowHeights,()=>{const i=this.initialRowHeights.get(n);return i!==void 0?i:s})}getVisibleColumnWidth(t,e,n=this.getFirstColumn(e),s=this.calculateTreePaddingX(e)){const i=this.getModelColumn(t,e),o=this.calculateColumnWidth(t,i,e,n,s);return this.getVisibleItemSize(i,this.userColumnWidths,()=>{const r=this.initialColumnWidths.get(i);return r!==void 0?r:o})}getModelRows(t,e){const n=new Map;for(let s=0;s<t.length;s+=1){const i=t[s],o=this.getModelRow(i,e);n.set(i,o)}return n}getModelRow(t,e){if(this.modelRows.has(t))return O(this.modelRows,t);const{movedRows:n}=e,s=q.getModelIndex(t,n);return this.modelRows.set(t,s),s}getModelColumns(t,e){const n=new Map;for(let s=0;s<t.length;s+=1){const i=t[s],o=this.getModelColumn(i,e);n.set(i,o)}return n}getModelColumn(t,e){if(this.modelColumns.has(t))return O(this.modelColumns,t);const{movedColumns:s}=e,i=q.getModelIndex(t,s);return this.modelColumns.set(t,i),i}calculateRowHeight(t,e,n){const{theme:s}=n,{autoSizeRows:i,rowHeight:o}=s;if(!i)return o;const r=this.calculatedRowHeights.get(e);return r??(this.calculatedRowHeights.set(e,Math.ceil(o)),dr(this.calculatedRowHeights),o)}calculateColumnWidth(t,e,n,s=this.getFirstColumn(n),i=this.calculateTreePaddingX(n)){const{theme:o}=n,{autoSizeColumns:r,minColumnWidth:l}=o;if(!r){const{columnWidth:m}=o;return m}const a=this.calculateColumnHeaderWidth(e,n),d=this.calculateColumnDataWidth(e,n),c=this.calculatedColumnWidths.get(e);let u=Math.ceil(Math.max(a,d));return u=Math.max(l,u),c!=null&&c>u?u=c:(this.calculatedColumnWidths.set(e,u),dr(this.calculatedColumnWidths)),t===s&&(u+=i),u}calculateColumnHeaderWidth(t,e){const{model:n,theme:s}=e,{headerFont:i,headerHorizontalPadding:o}=s,r=n.textForColumnHeader(t,0);if(r!==void 0&&r!==""){const l=this.getWidthForFont(i,e);return r.length*l+o*2}return o*2}calculateColumnDataWidth(t,e){const{top:n,height:s,width:i,model:o,theme:r}=e,{floatingTopRowCount:l,floatingBottomRowCount:a,rowCount:d}=o,{font:c,cellHorizontalPadding:u,rowHeight:m,rowHeaderWidth:p,rowFooterWidth:g,scrollBarSize:f}=r;let C=0;const S=this.getWidthForFont(c,e),w=s/m,T=Math.ceil(n+w);return q.iterateAllItems(n,T,l,a,d,y=>{const E=this.getModelRow(y,e),R=o.textForCell(t,E);if(R){const F=u*2;C=Math.max(C,R.length*S+F)}}),C=Math.max(Math.min(C,(i-p-f-g)*Qu.MAX_COLUMN_WIDTH),u*2),C}calculateTreePaddingX(t){const{top:e,height:n,model:s,theme:i}=t,{rowHeight:o,treeDepthIndent:r}=i;if(!ze(s)||!s.hasExpandableRows)return 0;let l=0;const a=n/o,d=Math.ceil(e+a);for(let c=e;c<=d;c+=1){const u=this.getModelRow(c,t),m=s.depthForRow(u);l=Math.max(l,r*(m+1))}return l}getWidthForFont(t,e){if(this.fontWidths.has(t))return O(this.fontWidths,t);const{context:n}=e;n.font=t;const s=n.measureText("8"),{width:i}=s;return this.fontWidths.set(t,i),this.fontWidths.set(n.font,i),i}setColumnWidth(t,e){const n=new Map(this.userColumnWidths);n.set(t,Math.ceil(e)),dr(n),this.userColumnWidths=n}resetColumnWidth(t){const e=new Map(this.userColumnWidths);e.delete(t),this.userColumnWidths=e}setRowHeight(t,e){const n=new Map(this.userRowHeights);n.set(t,Math.ceil(e)),dr(n),this.userRowHeights=n}resetRowHeight(t){const e=new Map(this.userRowHeights);e.delete(t),this.userRowHeights=e,this.calculatedRowHeights.delete(t)}};let Uo=Qu;Uo.CACHE_SIZE=1e4;Uo.MAX_COLUMN_WIDTH=.8;const sw=Object.freeze({allowColumnResize:!0,allowRowResize:!0,autoSelectRow:!1,autoSelectColumn:!1,autoSizeColumns:!0,autoSizeRows:!0,backgroundColor:"#000000",black:"#000000",white:"#ffffff",cellHorizontalPadding:5,headerHorizontalPadding:5,font:"12px Arial, sans serif",gridColumnColor:"#8f8f8f66",gridRowColor:"#8f8f8f66",headerBackgroundColor:"#222222",headerSeparatorColor:"#000000",headerSeparatorHoverColor:"#888888",headerSeparatorHandleSize:5,headerHiddenSeparatorSize:5,headerHiddenSeparatorHoverColor:"#8888FF",headerColor:"#d5d5d5",headerFont:"10px Arial, sans serif",columnHoverBackgroundColor:"#444444",selectedColumnHoverBackgroundColor:"#494949",rowBackgroundColors:"#333333 #222222",rowHoverBackgroundColor:"#444444",selectedRowHoverBackgroundColor:"#494949",minScrollHandleSize:50,scrollBarBackgroundColor:"#111111",scrollBarHoverBackgroundColor:"#333333",scrollBarCasingColor:"#000000",scrollBarCornerColor:"#000000",scrollBarColor:"#555555",scrollBarHoverColor:"#888888",scrollBarActiveColor:"#AAAAAA",scrollBarSize:12,scrollBarHoverSize:16,scrollBarCasingWidth:1,scrollSnapToColumn:!1,scrollSnapToRow:!1,selectionColor:"#4286f433",selectionOutlineColor:"#4286f4",selectionOutlineCasingColor:"#222222",scrollBarSelectionTick:!0,scrollBarSelectionTickColor:"#4286f433",scrollBarActiveSelectionTickColor:"#4286f480",shadowBlur:8,shadowColor:"#000000",textColor:"#ffffff",maxDepth:6,treeDepthIndent:10,treeHorizontalPadding:5,treeLineColor:"#888888",treeMarkerColor:"#cccccc",treeMarkerHoverColor:"#ffffff",rowHeight:20,columnWidth:100,minRowHeight:20,minColumnWidth:55,columnHeaderHeight:20,rowHeaderWidth:30,rowFooterWidth:0,headerResizeSnapThreshold:10,headerResizeHiddenSnapThreshold:8,allowColumnReorder:!0,allowRowReorder:!0,reorderOffset:2,floatingGridColumnColor:"#8f8f8f66",floatingGridRowColor:"#8f8f8f66",floatingRowBackgroundColors:"#393939 #292929",floatingDividerOuterColor:"#000000",floatingDividerInnerColor:"#cccccc"}),Jt=(t,e)=>{let n=!1;const s=Ie(t,{...e,dispose:()=>{n||(n=!0,s.clear(),n=!1)}});return s};function iw(t,e,n=6){const s=la.hex.lab.raw(t);return s[0]=Math.max(s[0]-s[0]/n*e,0),`#${la.lab.hex(s)}`}function ow(t,e){const[n,s,i]=la.hex.rgb(t);return`rgba(${n}, ${s}, ${i}, ${e})`}const Fc={colorWithAlpha:ow,darkenForDepth:iw};class ft{constructor(e=5e3){this.cursor=null,this.order=e}onDown(e,n,s){return!1}onMove(e,n,s){return!1}onDrag(e,n,s){return!1}onLeave(e,n,s){return!1}onClick(e,n,s){return!1}onContextMenu(e,n,s){return!1}onDoubleClick(e,n,s){return!1}onUp(e,n,s){return!1}onWheel(e,n,s){return!1}}class Ju extends ft{constructor(){super(...arguments),this.resizingItems=[],this.hiddenItems=[],this.targetSizes=new Map,this.dragOffset=0}onDown(e,n){const{metrics:s}=n,{model:i}=n.props,o=n.getTheme();if(!s)throw new Error("metrics not set");const r=this.getSeparator(e,s,i,o);if(r!=null){const l=r.index;return this.dragOffset=0,this.draggingIndex=l,this.resizingItems=[l],this.hiddenItems=this.getHiddenItems(l,s).reverse(),this.targetSizes.clear(),this.addTargetSize(s,l),this.updateCursor(s,l),this.updateSeparator(n,r),!0}return!1}onMove(e,n){const{metrics:s}=n,{model:i}=n.props,o=n.getTheme();if(!s)throw new Error("metrics not set");const r=this.getSeparator(e,s,i,o);return r!=null?(this.updateCursor(s,r.index),!0):!1}onDrag(e,n){if(this.draggingIndex==null)return!1;const s=e[this.pointProperty],{metricCalculator:i,metrics:o}=n;if(!o)throw new Error("metrics not set");const r=n.getTheme(),l=o[this.visibleOffsetProperty],a=o[this.marginProperty],d=o[this.calculatedSizesProperty],c=o[this.modelIndexesProperty],u=o[this.firstIndexProperty],m=o[this.treePaddingProperty],p=new Map;let g=this.resizingItems[this.resizingItems.length-1];for(;g!=null;){const f=O(l,g),C=s-a-f-this.dragOffset,S=O(c,g),w=this.targetSizes.get(S),T=this.resizingItems.length>1,y=this.hiddenItems.indexOf(g);let E=O(d,S);g===u&&(E+=m);let R=C;Math.abs(C-E)<=r.headerResizeSnapThreshold?R=E:w!==void 0&&C>w&&(T&&y!==0||y>0)?R=w:C<=r.headerResizeHiddenSnapThreshold&&(R=0),p.set(S,R),C<-r.headerResizeSnapThreshold&&R===0?y>=0&&T?(this.resizingItems.pop(),this.removeTargetSize(o,g),g=this.resizingItems[this.resizingItems.length-1],this.dragOffset-=this.targetSizes.get(O(c,g))??0):(g=this.getNextShownItem(g,o),g!==null&&(this.resizingItems.push(g),this.addTargetSize(o,g))):w!==void 0&&C>w+r.headerResizeSnapThreshold&&R===w?y>0?(this.dragOffset+=R,g=this.hiddenItems[y-1],this.resizingItems.push(g),this.addTargetSize(o,g)):T?(this.resizingItems.pop(),this.removeTargetSize(o,g),g=this.resizingItems[this.resizingItems.length-1]):g=null:g=null}return p.forEach((f,C)=>{const S=i[this.initialSizesProperty].get(C)??d.get(C);f===S?this.resetSize(i,C):this.setSize(i,C,f)}),this.updateCursor(o,this.draggingIndex),!0}onUp(e,n){return this.draggingIndex!=null&&(this.draggingIndex=void 0,this.resizingItems=[],this.hiddenItems=[],this.targetSizes.clear(),this.updateSeparator(n,null)),!1}onDoubleClick(e,n){const{metrics:s,metricCalculator:i}=n,{model:o}=n.props,r=n.getTheme();if(!s)throw new Error("metrics not set");const l=this.getSeparator(e,s,o,r);if(l!=null){const a=s[this.modelIndexesProperty],d=O(a,l.index),c=O(s[this.calculatedSizesProperty],d),u=i[this.initialSizesProperty].get(d);return c===u?this.resetSize(i,d):this.setSize(i,d,c),n.forceUpdate(),!0}return!1}updateCursor(e,n){const s=e[this.visibleSizesProperty];O(s,n)===0?this.cursor=this.hiddenCursor:this.cursor=this.defaultCursor}addTargetSize(e,n){const s=e[this.modelIndexesProperty],i=e[this.userSizesProperty],o=e[this.calculatedSizesProperty],r=n===0?e[this.treePaddingProperty]:0,l=O(s,n);let a=i.get(l);(a==null||a===0)&&(a=O(o,l)+r),this.targetSizes.set(l,a)}removeTargetSize(e,n){const s=e[this.modelIndexesProperty],i=O(s,n);this.targetSizes.delete(i)}}class wl extends Ju{constructor(){super(...arguments),this.hiddenCursor="e-resize",this.defaultCursor="col-resize",this.pointProperty="x",this.userSizesProperty="userColumnWidths",this.visibleOffsetProperty="visibleColumnXs",this.visibleSizesProperty="visibleColumnWidths",this.marginProperty="rowHeaderWidth",this.calculatedSizesProperty="calculatedColumnWidths",this.initialSizesProperty="initialColumnWidths",this.modelIndexesProperty="modelColumns",this.firstIndexProperty="firstColumn",this.treePaddingProperty="treePaddingX",this.getHiddenItems=q.getHiddenColumns,this.getNextShownItem=q.getNextShownColumn,this.getSeparator=wl.getColumnSeparator}static getColumnSeparator(e,n,s,i){if(!i.allowColumnResize)return null;const{x:o,y:r,columnHeaderDepth:l}=e,{modelColumns:a}=n,d=q.getColumnSeparatorIndex(o,r,n,i);return d==null||l==null||l>0?null:a.get(d)!=null?{index:d,depth:0}:null}setSize(e,n,s){e.setColumnWidth(n,s)}resetSize(e,n){e.resetColumnWidth(n)}updateSeparator(e,n){e.setState({draggingColumnSeparator:n,isDragging:n!==null})}}const Zn=class{constructor(){this.getCachedTruncatedString=Jt((t,e,n,s,i)=>Zn.truncateToWidth(t,e,n,s,i),{max:1e4}),this.getCachedBackgroundColors=Jt((t,e)=>t.split(" ").map(n=>{const s=[];for(let i=0;i<e;i+=1)s.push(Fc.darkenForDepth(n,i,e));return s}),{max:1e3}),this.getCachedColorWithAlpha=Jt((t,e)=>Fc.colorWithAlpha(t,e),{max:1e3}),this.getCachedColorIsDark=Jt(t=>rl.isDark(t),{max:1e3})}static truncate(t,e){return e<t.length?t.substr(0,e)+"\u2026":t}static binaryTruncateToWidth(t,e,n,s=0,i=e.length,o){if(i>=e.length&&t.measureText(e).width<=n)return e;if(o!==void 0){const d=t.measureText(o).width;return o.repeat(Math.max(1,Math.floor(n/d)))}let r=s,l=Math.min(e.length-1,i),a=e;for(;l>=r;){const d=Math.ceil((l+r)/2),c=Zn.truncate(e,d);if(t.measureText(c).width<=n){if(a=c,r===d)break;r=d}else if(d===0){a=c;break}else l=d-1}return a}static truncateToWidth(t,e,n,s=Zn.DEFAULT_FONT_WIDTH,i){if(n<=0||e.length<=0)return"";const o=Math.min(Math.max(0,Math.floor(n/s/2)-5),e.length),r=Math.min(Math.ceil(n/s*2),e.length);return Zn.binaryTruncateToWidth(t,e,n,o,r,i)}drawCanvas(t){const{context:e}=t;e.save(),this.configureContext(e,t),this.drawBackground(e,t),this.drawGrid(e,t),this.drawHeaders(e,t),this.drawFooters(e,t),this.drawDraggingColumn(e,t),this.drawDraggingRow(e,t),this.drawScrollBars(e,t),e.restore()}configureContext(t,e){const{theme:n}=e;t.font=n.font,t.textBaseline="middle",t.lineCap="butt"}drawBackground(t,e){const{theme:n,metrics:s}=e,{width:i,height:o}=s;t.fillStyle=n.backgroundColor,t.fillRect(0,0,i,o)}drawGrid(t,e){const{metrics:n,draggingRow:s,draggingColumn:i}=e,{gridX:o,gridY:r}=n;t.translate(o,r),this.drawGridBackground(t,e,s==null&&i==null),this.drawCellContents(t,e),this.drawFloatingRows(t,e),this.drawFloatingColumns(t,e),t.translate(-o,-r)}drawFloatingRows(t,e){const{draggingRow:n,draggingColumn:s,metrics:i,theme:o}=e,{floatingTopRowCount:r,floatingBottomRowCount:l,floatingRows:a,rowCount:d,visibleColumns:c,allRowYs:u,allRowHeights:m}=i;if(a.length!==0){o.floatingRowBackgroundColors&&this.drawRowStripesForRows(t,e,a,o.floatingRowBackgroundColors),n==null&&s==null&&this.drawFloatingMouseRowHover(t,e),this.drawGridLinesForItems(t,e,c,a,o.floatingGridColumnColor,o.floatingGridRowColor),this.drawCellBackgroundsForItems(t,e,c,a),this.drawFloatingBorders(t,e),r>0&&this.drawSelectedRanges(t,e,{top:0,bottom:r-1,maxY:O(u,r-1)+O(m,r-1)-.5}),l>0&&this.drawSelectedRanges(t,e,{top:d-l-1,bottom:d-1,minY:O(u,d-l)+.5,maxY:O(u,d-1)+O(m,d-1)-.5});for(let p=0;p<c.length;p+=1){const g=c[p];for(let f=0;f<a.length;f+=1){const C=a[f];this.drawCellContent(t,e,g,C)}}}}drawFloatingColumns(t,e){const{draggingRow:n,draggingColumn:s,metrics:i,theme:o}=e,{floatingLeftColumnCount:r,floatingRightColumnCount:l,floatingLeftWidth:a,floatingRightWidth:d,floatingColumns:c,gridX:u,maxX:m,columnCount:p,visibleRows:g,allColumnXs:f,allColumnWidths:C,width:S,height:w}=i;if(c.length!==0){o.floatingRowBackgroundColors&&(this.drawRowStripesForRows(t,e,g,o.floatingRowBackgroundColors,0,a),this.drawRowStripesForRows(t,e,g,o.floatingRowBackgroundColors,S-u-d,m)),n==null&&s==null&&this.drawFloatingMouseRowHover(t,e),t.save(),t.beginPath(),t.rect(0,0,a,w),t.clip(),this.drawGridLinesForItems(t,e,c,g,o.floatingGridColumnColor,o.floatingGridRowColor),t.restore(),this.drawCellBackgroundsForItems(t,e,c,g),this.drawFloatingBorders(t,e),r>0&&this.drawSelectedRanges(t,e,{left:0,maxX:O(f,r-1)+O(C,r-1)}),l>0&&this.drawSelectedRanges(t,e,{left:p-l,right:p-1,minX:O(f,p-l)+.5,maxX:O(f,p-1)+O(C,p-1)});for(let T=0;T<c.length;T+=1){const y=c[T];for(let E=0;E<g.length;E+=1){const R=g[E];this.drawCellContent(t,e,y,R)}}}}drawFloatingBorders(t,e){const{metrics:n,theme:s}=e,{floatingTopRowCount:i,floatingBottomRowCount:o,floatingLeftColumnCount:r,floatingRightColumnCount:l,rowCount:a,columnCount:d,allRowYs:c,allColumnXs:u,allRowHeights:m,allColumnWidths:p,maxX:g,maxY:f}=n,{floatingDividerOuterColor:C,floatingDividerInnerColor:S}=s;if(t.lineWidth=3,t.beginPath(),t.strokeStyle=C,i>0){const w=O(c,i-1)+O(m,i-1)+.5;t.moveTo(0,w),t.lineTo(g,w)}if(o>0){const w=O(c,a-o)-.5;t.moveTo(0,w),t.lineTo(g,w)}if(r>0){const w=O(u,r-1)+O(p,r-1)+.5;t.moveTo(w,0),t.lineTo(w,f)}if(l>0){const w=O(u,d-l)-.5;t.moveTo(w,0),t.lineTo(w,f)}if(t.stroke(),t.beginPath(),t.lineWidth=1,t.strokeStyle=S,i>0){const w=O(c,i-1)+O(m,i-1)+.5;t.moveTo(0,w),t.lineTo(g,w)}if(o>0){const w=O(c,a-o)-.5;t.moveTo(0,w),t.lineTo(g,w)}if(r>0){const w=O(u,r-1)+O(p,r-1)+.5;t.moveTo(w,0),t.lineTo(w,f)}if(l>0){const w=O(u,d-l)-.5;t.moveTo(w,0),t.lineTo(w,f)}t.stroke()}drawGridBackground(t,e,n=!1){this.drawRowStripes(t,e),n&&(this.drawMouseColumnHover(t,e),this.drawMouseRowHover(t,e)),this.drawGridLines(t,e),this.drawCellBackgrounds(t,e);const{metrics:s}=e,{bottom:i,right:o,floatingBottomRowCount:r,floatingLeftColumnCount:l,floatingRightColumnCount:a,floatingTopRowCount:d,columnCount:c,rowCount:u,allRowHeights:m,allRowYs:p,allColumnXs:g,allColumnWidths:f,width:C,height:S}=s;this.drawSelectedRanges(t,e,{bottom:Math.min(i,u-r-1),right:Math.min(o,c-a-1),minX:l>0&&g.has(l+1)?O(g,l+1):-10,minY:d>0&&p.has(d+1)?O(p,d+1):-10,maxX:a>0&&g.has(c-a-1)?O(g,c-a-1)+O(f,c-a-1)-.5:C+10,maxY:r>0&&p.has(u-r-1)?O(p,u-r-1)+O(m,u-r-1)-.5:S+10})}drawRowStripes(t,e){const{metrics:n,theme:s}=e,{visibleRows:i}=n,{rowBackgroundColors:o}=s;!o||this.drawRowStripesForRows(t,e,i,o)}drawRowStripesForRows(t,e,n,s,i=0,o=e.metrics.maxX){const{theme:r,metrics:l,model:a}=e,{maxDepth:d,shadowBlur:c,shadowColor:u}=r,m=this.getCachedBackgroundColors(s,d),{allRowYs:p,allRowHeights:g}=l,f=new Map,C=[],S=[],w=(T,y)=>{const E=ze(a)?a.depthForRow(T):0,R=m[T%m.length],F=R[Math.min(E,R.length-1)];if(f.has(F)||f.set(F,[]),f.get(F).push(T),y!=null){const D=ze(a)?a.depthForRow(y):0;D<E?C.push(T):D>E&&S.push(y)}};for(let T=0;T<n.length;T+=1){const y=n[T],E=T>0?n[T-1]:void 0;w(y,E)}if(f.forEach((T,y)=>{t.fillStyle=y,t.beginPath();for(let E=0;E<T.length;E+=1){const R=T[E],F=O(p,R),D=O(g,R);t.rect(i,F,o,D)}t.fill()}),C.length>0){t.save();const T=this.getCachedColorWithAlpha(u,.15),y=this.getCachedColorWithAlpha(u,0),E=t.createLinearGradient(0,0,0,c);E.addColorStop(0,T),E.addColorStop(1,y),t.fillStyle=E;for(let R=0;R<C.length;R+=1){const F=C[R],D=O(p,F);t.translate(0,D),t.fillRect(i,0,o,c),t.translate(0,-D)}t.restore()}if(S.length>0){t.save();const T=this.getCachedColorWithAlpha(u,0),y=this.getCachedColorWithAlpha(u,.15),E=t.createLinearGradient(0,0,0,c);E.addColorStop(0,T),E.addColorStop(1,y),t.fillStyle=E;for(let R=0;R<S.length;R+=1){const F=S[R],D=O(p,F),_=O(g,F),H=D+_-c;t.translate(0,H),t.fillRect(i,0,o,c),t.translate(0,-H)}t.restore()}}drawMouseColumnHover(t,e){const{mouseX:n,mouseY:s,theme:i,metrics:o}=e;if(n==null||s==null)return;const r=q.getColumnAtX(n,o);if(r==null||i.columnHoverBackgroundColor==null)return;const{allColumnWidths:l,allColumnXs:a,maxY:d}=o;if(s>d)return;const c=O(a,r),u=O(l,r);t.fillStyle=i.columnHoverBackgroundColor,t.fillRect(c,0,u,d)}drawMouseRowHover(t,e){const{mouseX:n,mouseY:s,theme:i,metrics:o}=e;if(n==null||s==null)return;const{maxX:r}=o;if(n>r||i.rowHoverBackgroundColor==null)return;const l=q.getRowAtY(s,o);l!=null&&this.drawMouseRowHoverForRow(t,e,l)}drawFloatingMouseRowHover(t,e){const{mouseX:n,mouseY:s,theme:i,metrics:o}=e,{maxX:r,floatingTopRowCount:l,floatingBottomRowCount:a,rowCount:d,rowFooterWidth:c}=o;if(n==null||s==null||n>r+c||i.rowHoverBackgroundColor==null)return;const u=q.getRowAtY(s,o);u!=null&&(u<l||d-a<=u)&&this.drawMouseRowHoverForRow(t,e,u)}drawMouseRowHoverForRow(t,e,n){const{metrics:s,selectedRanges:i,theme:o}=e,{allRowHeights:r,allRowYs:l,maxX:a}=s,d=O(l,n),c=O(r,n);o.rowHoverBackgroundColor!=null&&(t.fillStyle=o.rowHoverBackgroundColor);for(let u=0;u<i.length;u+=1){const{startRow:m,endRow:p}=i[u];if(m!=null&&p!=null&&m<=n&&p>=n){o.selectedRowHoverBackgroundColor!=null&&(t.fillStyle=o.selectedRowHoverBackgroundColor);break}}t.fillRect(0,d,a,c)}drawGridLines(t,e){const{metrics:n,theme:s}=e,{visibleColumns:i,visibleRows:o}=n;this.drawGridLinesForItems(t,e,i,o,s.gridColumnColor,s.gridRowColor)}drawGridLinesForItems(t,e,n,s,i,o){i==null&&o==null||(t.lineWidth=1,t.beginPath(),i!=null&&(t.strokeStyle=i,this.drawGridLinesForColumns(t,e,n)),o!=null&&(t.strokeStyle=o,this.drawGridLinesForRows(t,e,s)),t.stroke())}drawGridLinesForColumns(t,e,n){const{metrics:s}=e,{allColumnXs:i,maxY:o}=s;for(let r=0;r<n.length;r+=1){const l=n[r],a=O(i,l)+.5;t.moveTo(a,0),t.lineTo(a,o)}}drawGridLinesForRows(t,e,n){const{metrics:s}=e,{allRowYs:i,maxX:o}=s,r=o;for(let l=0;l<n.length;l+=1){const a=n[l],d=O(i,a)+.5;t.moveTo(.5,d),t.lineTo(r-.5,d)}}drawCellBackgrounds(t,e){const{metrics:n}=e,{visibleColumns:s,visibleRows:i}=n;this.drawCellBackgroundsForItems(t,e,s,i)}drawCellBackgroundsForItems(t,e,n,s){t.save();for(let i=0;i<n.length;i+=1){const o=n[i];for(let r=0;r<s.length;r+=1){const l=s[r],a=r+1<s.length?s[r+1]:void 0;this.drawCellBackground(t,e,o,l,a)}}t.restore()}drawCellBackground(t,e,n,s,i){const{metrics:o,model:r,theme:l}=e,{firstColumn:a,modelColumns:d,modelRows:c,allColumnXs:u,allColumnWidths:m,allRowYs:p,allRowHeights:g}=o,f=O(c,s),C=O(d,n),S=r.backgroundColorForCell(C,f,l),w=n===a,T=ze(r)&&r.hasExpandableRows;if(S!=null){const y=O(u,n)+1,E=O(p,s)+1,R=O(m,n)-1,F=O(g,s)-1;t.fillStyle=S,t.fillRect(y,E,R,F)}w&&T&&this.drawCellRowTreeDepthLines(t,e,s,i)}drawCellContents(t,e){const{metrics:n}=e,{visibleColumns:s}=n;for(let i=0;i<s.length;i+=1){const o=s[i];this.drawColumnCellContents(t,e,o)}}drawColumnCellContents(t,e,n){const{metrics:s}=e,{allColumnXs:i,allColumnWidths:o,visibleRows:r,height:l}=s,a=O(i,n),d=O(o,n);t.save(),t.beginPath(),t.rect(a,0,d,l),t.clip();for(let c=0;c<r.length;c+=1){const u=r[c];this.drawCellContent(t,e,n,u)}t.restore()}getTextRenderMetrics(t,e,n,s){const{textAlign:i}=t,{metrics:o,model:r,theme:l}=e,{firstColumn:a,allColumnXs:d,allColumnWidths:c,allRowYs:u,allRowHeights:m}=o,{cellHorizontalPadding:p,treeDepthIndent:g,treeHorizontalPadding:f}=l,C=O(d,n),S=O(u,s),w=O(c,n),T=O(m,s),y=n===a;let E=0;ze(r)&&r.hasExpandableRows&&y&&(E=g*(r.depthForRow(s)+1)+f);const R=w-E;let F=C+p;const D=S+T*.5;return i==="right"?F=C+R-p:i==="center"&&(F=C+R*.5),F+=E,{width:R-p*2,x:F,y:D}}drawCellContent(t,e,n,s,i){const{metrics:o,model:r,theme:l}=e,{firstColumn:a,fontWidths:d,modelColumns:c,modelRows:u,allRowHeights:m}=o,{textColor:p}=l,g=O(m,s),f=O(u,s),C=O(c,n),S=i??r.textForCell(C,f),w=r.truncationCharForCell(C,f),T=n===a;if(S&&g>0){const y=r.textAlignForCell(C,f)||"left";t.textAlign=y;const E=r.colorForCell(C,f,l)||p;t.fillStyle=E;const{width:R,x:F,y:D}=this.getTextRenderMetrics(t,e,n,s),_=d.get(t.font)??Zn.DEFAULT_FONT_WIDTH,H=this.getCachedTruncatedString(t,S,R,_,w);H&&t.fillText(H,F,D)}T&&ze(r)&&r.hasExpandableRows&&this.drawCellRowTreeMarker(t,e,s)}drawCellRowTreeMarker(t,e,n){const{metrics:s,model:i,mouseX:o,mouseY:r,theme:l}=e,{firstColumn:a,gridX:d,gridY:c,allColumnXs:u,allColumnWidths:m,allRowYs:p,allRowHeights:g,visibleRowTreeBoxes:f}=s,{treeMarkerColor:C,treeMarkerHoverColor:S}=l,w=O(u,a),T=O(m,a),y=O(p,n),E=O(g,n);if(!ze(i)||!i.isRowExpandable(n))return;const R=O(f,n),F=o!=null&&r!=null&&o>=d+w&&o<=d+w+T&&r>=c+y&&r<=c+y+E?S:C;this.drawTreeMarker(t,e,w,y,R,F,i.isRowExpanded(n))}drawTreeMarker(t,e,n,s,i,o,r){const{x1:l,y1:a,x2:d,y2:c}=i,u=r?"\u229F":"\u229E",m=n+(l+d)*.5+.5,p=s+(a+c)*.5+.5;t.fillStyle=o,t.textAlign="center",t.fillText(u,m,p)}drawCellRowTreeDepthLines(t,e,n,s){const{metrics:i,model:o,theme:r}=e;if(!ze(o))return;const l=o.depthForRow(n);if(l===0)return;const{firstColumn:a,allColumnXs:d,allRowYs:c,allRowHeights:u}=i,{treeDepthIndent:m,treeHorizontalPadding:p,treeLineColor:g}=r,f=O(d,a),C=O(c,n),S=O(u,n),w=s!==void 0?o.depthForRow(s):0,T=l>w?l-w:0;if(t.strokeStyle=g,t.lineWidth=1,l-T>0){t.beginPath();for(let y=0;y<l-T;y+=1){const E=f+y*m+m*.5+p+.5;t.moveTo(E,C),t.lineTo(E,C+S)}t.stroke()}if(T>0){t.beginPath();for(let y=l-T;y<l;y+=1){const E=f+y*m+m*.5+p+.5;t.moveTo(E,C),t.lineTo(E,C+Math.ceil(S/2)),t.moveTo(E-.5,C+Math.ceil(S/2)+.5),t.lineTo(E+m-.5,C+Math.ceil(S/2)+.5)}t.stroke()}}drawHeaders(t,e){const{theme:n}=e;t.font=n.headerFont,this.drawColumnHeaders(t,e),this.drawRowHeaders(t,e)}drawFooters(t,e){const{theme:n}=e;t.font=n.headerFont,this.drawRowFooters(t,e)}drawColumnHeaders(t,e){const{mouseX:n,mouseY:s,theme:i,metrics:o,draggingColumnSeparator:r,isDragging:l,model:a}=e,{columnHeaderHeight:d,floatingColumns:c,gridX:u,width:m,visibleColumns:p,allColumnWidths:g,allColumnXs:f,floatingLeftColumnCount:C,floatingLeftWidth:S,floatingRightWidth:w,modelColumns:T,columnHeaderMaxDepth:y}=o;if(d<=0)return;const{headerHiddenSeparatorSize:E,headerHiddenSeparatorHoverColor:R,headerSeparatorColor:F,headerSeparatorHoverColor:D}=i,_=d*.5,H=d*(y-1)+d*.5-_*.5,U=C>0;if(t.save(),this.drawColumnHeadersForRange(t,e,[p[0],p[p.length-1]],{minX:u+S,maxX:m-w}),U&&this.drawColumnHeadersForRange(t,e,[c[0],c[c.length-1]],{minX:u,maxX:u+S}),F){t.strokeStyle=F;const A=[...g.entries()].filter(([Y,G])=>G===0).map(([Y])=>Y);t.beginPath(),t.fillStyle=F;for(let Y=0;Y<A.length;Y+=1){const G=A[Y],z=O(f,G),x=O(g,G),L=u+z+x+.5-E*.5;t.rect(L,H,E,_)}t.fill()}if(D){let{index:A,depth:Y}=r??{};if(A==null&&n!=null&&s!=null){const z=wl.getColumnSeparator(q.getGridPointFromXY(n,s,o),o,a,i);A=z?.index,Y=z?.depth}let G;if(A==null)G=!1;else{const z=T.get(A),x=T.get(A+1);z==null||x==null?G=!1:G=a.textForColumnHeader(z,Y)!==a.textForColumnHeader(x,Y)}if(G&&A!=null&&Y!=null&&(!l||r!=null)){t.strokeStyle=D;const z=O(f,A),x=O(g,A),L=u+z+x+.5,P=p.indexOf(A),Z=P<p.length-1?p[P+1]:null,ne=Z!=null?g.get(Z):null,B=x===0,W=ne!=null&&ne===0;B?(t.strokeStyle=R,t.fillStyle=R,t.fillRect(L,H,E*.5,_)):W&&(t.fillStyle=D,t.fillRect(L-E*.5,H,E*.5,_)),t.beginPath(),t.moveTo(L,(y-Y-1)*d),t.lineTo(L,(y-Y)*d-1),t.stroke()}}t.restore()}drawColumnHeadersForRange(t,e,n,s){const{model:i}=e,{columnHeaderMaxDepth:o}=i;if(o!==0)for(let r=0;r<=o;r+=1)this.drawColumnHeadersAtDepth(t,e,n,s,r)}drawColumnHeadersAtDepth(t,e,n,s,i){const{metrics:o,model:r,theme:l}=e,{modelColumns:a,allColumnXs:d,gridX:c,calculatedColumnWidths:u,userColumnWidths:m,allColumnWidths:p,movedColumns:g}=o,{columnHeaderHeight:f,columnWidth:C}=l,{columnHeaderMaxDepth:S}=r,{minX:w,maxX:T}=s,y=T-w;if(S===0)return;const E=n[0],R=n[1];if(t.save(),t.translate(0,(S-i-1)*f),i===0){this.drawColumnHeader(t,e,"",w,T);for(let F=E;F<=R;F+=1)this.drawColumnHeaderAtIndex(t,e,F,s)}if(i>0){let F=E;for(;F<=R;){const{columnCount:D}=o,_=O(a,F),H=r.textForColumnHeader(_,i),U=r.colorForColumnHeader(_,i);let A=O(d,F)+c,Y=A+O(p,F);if(H!=null){let G=F-1;for(;G>=0&&(Y-A<y||A>w);){const P=a.get(G)??q.getModelIndex(G,g);if(P==null||r.textForColumnHeader(P,i)!==H)break;A-=m.get(P)??u.get(P)??C,G-=1}let z=F+1;for(;z<D&&(Y-A<y||Y<T);){const P=a.get(z)??q.getModelIndex(z,g);if(r.textForColumnHeader(P,i)!==H)break;Y+=m.get(P)??u.get(P)??C,z+=1}F=z-1;const x=Y-A>=y;let L=A;x&&(Y<T?L=Y-y:A<w&&(L=w)),this.drawColumnHeader(t,e,H,L,Math.min(Y-A,y),{backgroundColor:U??void 0},s)}F+=1}}t.restore()}drawColumnHeaderAtIndex(t,e,n,s){const{metrics:i,model:o}=e,{modelColumns:r,allColumnWidths:l,allColumnXs:a,gridX:d}=i,c=O(l,n),u=O(a,n)+d,m=O(r,n),p=o.textForColumnHeader(m);p!=null&&this.drawColumnHeader(t,e,p,u,c,{backgroundColor:o.colorForColumnHeader(m)??void 0},s)}drawColumnHeader(t,e,n,s,i,o,r){if(i<=0)return;const{metrics:l,theme:a}=e,{headerHorizontalPadding:d,columnHeaderHeight:c,headerBackgroundColor:u,headerColor:m,headerSeparatorColor:p,black:g,white:f}=a,{fontWidths:C,width:S}=l,w=C.get(t.font)??Zn.DEFAULT_FONT_WIDTH,y=(i-d*2)/w,{backgroundColor:E=u,separatorColor:R=p}=o??{};let{textColor:F=m}=o??{};try{const B=this.getCachedColorIsDark(E),W=this.getCachedColorIsDark(F);B&&W?F=f:!B&&!W&&(F=g)}catch{}let{minX:D=0,maxX:_=S}=r??{};t.save(),t.rect(D,0,_-D,c),t.clip(),E!=null&&(t.fillStyle=E,t.fillRect(s,0,i,c)),R!=null&&(t.strokeStyle=R,t.beginPath(),s>0&&(t.moveTo(s+.5,0),t.lineTo(s+.5,c)),t.moveTo(s+i+.5,0),t.lineTo(s+i+.5,c),t.moveTo(s,c-.5),t.lineTo(s+i,c-.5),t.stroke()),t.beginPath(),t.rect(s,0,i,c),t.clip(),t.fillStyle=F;let H=n;y<=0?H="":H.length>y&&(H=`${H.substring(0,y-1)}\u2026`);const U=H.length*w;let A=s+i*.5;const Y=c*.5;D+=d,_-=d;const G=s+d,z=Qe(G,D,_),x=s+i-d,P=Qe(x,D,_)-z,Z=A-U*.5<D,ne=A+U*.5>_;Z?U<P?A=D+U*.5:A=x-U*.5:ne&&(U<P?A=_-U*.5:A=G+U*.5),t.textAlign="center",t.fillText(H,A,Y),t.restore()}drawRowHeaders(t,e){const{mouseX:n,mouseY:s,metrics:i,theme:o,draggingRowSeparator:r}=e,{gridY:l,rowHeaderWidth:a,height:d,visibleRows:c,allRowHeights:u,allRowYs:m}=i;if(a<=0)return;const{headerBackgroundColor:p,headerColor:g,headerHiddenSeparatorSize:f,headerHiddenSeparatorHoverColor:C,headerSeparatorColor:S,headerSeparatorHoverColor:w}=o,T=a*.5,y=a*.5-T*.5;if(t.save(),t.beginPath(),t.fillStyle=p,t.fillRect(0,0,a,d),S){t.strokeStyle=S,t.beginPath(),t.moveTo(0,l+.5),t.lineTo(a,l+.5);const E=[];let R=!1;for(let F=0;F<c.length;F+=1){const D=c[F],_=O(m,D),H=O(u,D);if(H>0){const U=l+_+H+.5;t.moveTo(0,U),t.lineTo(a,U),R=!1}else R||(R=!0,E.push(D))}t.moveTo(a-.5,0),t.lineTo(a-.5,d),t.stroke(),t.beginPath(),t.fillStyle=S;for(let F=0;F<E.length;F+=1){const D=E[F],_=O(m,D),H=O(u,D),U=l+_+H+.5-f*.5;t.rect(y,U,T,f)}t.fill()}if(w){let{index:E=null}=r??{};if(E==null&&n!=null&&s!=null&&(E=q.getRowSeparatorIndex(n,s,i,o)),E!=null){t.strokeStyle=w;const R=O(m,E),F=O(u,E),D=l+R+F+.5,_=c.indexOf(E),H=_<c.length-1?c[_+1]:null,U=H!=null?u.get(H):null,A=F===0,Y=U!=null&&U===0;A?(t.strokeStyle=C,t.fillStyle=C,t.fillRect(y,D,T,f*.5)):Y&&(t.fillStyle=w,t.fillRect(y,D-f*.5,T,f*.5)),t.beginPath(),t.moveTo(.5,D),t.lineTo(a+.5,D),t.stroke()}}t.beginPath(),t.rect(0,l,a,d),t.clip(),t.fillStyle=g,t.textAlign="right";for(let E=0;E<c.length;E+=1){const R=c[E],F=O(u,R),D=O(m,R)+l;this.drawRowHeader(t,e,R,D,F)}t.restore()}drawRowHeader(t,e,n,s,i){if(i<=0)return;const{metrics:o,model:r,theme:l}=e,{modelRows:a,rowHeaderWidth:d}=o,c=O(a,n),u=d-l.cellHorizontalPadding,m=s+i*.5;t.fillText(r.textForRowHeader(c),u,m)}drawRowFooters(t,e){const{mouseX:n,mouseY:s,metrics:i,model:o,theme:r,draggingRowSeparator:l}=e,{gridY:a,gridX:d,maxX:c,modelRows:u,rowFooterWidth:m,height:p,verticalBarWidth:g,visibleRows:f,allRowHeights:C,allRowYs:S,width:w}=i;if(m<=0)return;const{cellHorizontalPadding:T,headerBackgroundColor:y,headerColor:E,headerHiddenSeparatorSize:R,headerHiddenSeparatorHoverColor:F,headerSeparatorColor:D,headerSeparatorHoverColor:_}=r,H=m*.5,U=m*.5-H*.5,A=Math.min(d+c,w-m-g);if(t.save(),t.beginPath(),t.fillStyle=y,t.fillRect(A,a,m,p),D){t.strokeStyle=D,t.beginPath(),t.moveTo(A,a+.5),t.lineTo(m,a+.5);const G=[];let z=!1;for(let x=0;x<f.length;x+=1){const L=f[x],P=O(S,L),Z=O(C,L);if(Z>0){const ne=a+P+Z+.5;t.moveTo(A+.5,ne),t.lineTo(A+m-.5,ne),z=!1}else z||(z=!0,G.push(L))}t.moveTo(A+.5,a),t.lineTo(A+.5,p),t.stroke(),t.beginPath(),t.fillStyle=D;for(let x=0;x<G.length;x+=1){const L=G[x],P=O(S,L),Z=O(C,L),ne=a+P+Z+.5-R*.5;t.rect(A+U,ne,H,R)}t.fill()}if(_){let{index:G=null}=l??{};if(G==null&&n!=null&&s!=null&&(G=q.getRowSeparatorIndex(n,s,i,r)),G!=null){t.strokeStyle=_;const z=O(S,G),x=O(C,G),L=a+z+x+.5,P=f.indexOf(G),Z=P<f.length-1?f[P+1]:null,ne=Z!=null?C.get(Z):null,B=x===0,W=ne!=null&&ne===0;B?(t.strokeStyle=F,t.fillStyle=F,t.fillRect(U,L,H,R*.5)):W&&(t.fillStyle=_,t.fillRect(U,L-R*.5,H,R*.5)),t.beginPath(),t.moveTo(A+.5,L),t.lineTo(A+m+.5,L),t.stroke()}}t.beginPath(),t.rect(A,a,m,p),t.clip(),t.fillStyle=E,t.textAlign="left";const Y=A+T;for(let G=0;G<f.length;G+=1){const z=f[G],x=O(C,z);if(x>0){const L=O(S,z)+a,P=O(u,z),Z=L+x*.5;t.fillText(o.textForRowFooter(P),Y,Z)}}t.restore()}drawSelectedRanges(t,e,n={}){const{cursorColumn:s,cursorRow:i,draggingRow:o,draggingColumn:r,editingCell:l,metrics:a,model:d,selectedRanges:c,theme:u}=e,{allColumnWidths:m,allColumnXs:p,allRowHeights:g,allRowYs:f,width:C,height:S}=a,{left:w=a.left,top:T=a.top,right:y=a.right,bottom:E=a.bottom,minY:R=-10,maxY:F=S+10,minX:D=-10,maxX:_=C+10}=n;if(c.length===0)return;const H=tt(d)&&d.isEditable&&l==null&&o==null&&r==null&&s!=null&&i!=null&&p.has(s)&&f.has(i);if(H){const U=O(p,s),A=O(f,i),Y=O(m,s),G=O(g,i);t.save(),t.beginPath(),t.rect(0,0,C,S),t.rect(U,A,Y,G),t.clip("evenodd")}t.beginPath();for(let U=0;U<c.length;U+=1){const A=c[U],Y=A.startColumn!==null?A.startColumn:w,G=A.startRow!==null?A.startRow:T,z=A.endColumn!==null?A.endColumn:y,x=A.endRow!==null?A.endRow:E;if(x>=T&&E>=G&&z>=w&&y>=Y){const L=Y>=w&&p.has(Y)?Math.round(O(p,Y))+.5:D,P=G>=T&&f.has(G)?Math.max(Math.round(O(f,G))+.5,.5):R,Z=z<=y&&p.has(z)?Math.round(O(p,z)+O(m,z))-.5:_,ne=x<=E&&f.has(x)?Math.round(O(f,x)+O(g,x))-.5:F;t.rect(L,P,Z-L,ne-P)}t.fillStyle=u.selectionColor,t.fill(),t.save(),t.clip(),t.strokeStyle=u.selectionOutlineCasingColor,t.lineWidth=3,t.stroke(),t.restore(),t.strokeStyle=u.selectionOutlineColor,t.lineWidth=1,t.stroke()}H&&s!=null&&i!=null&&(t.restore(),this.drawActiveCell(t,e,s,i))}drawActiveCell(t,e,n,s,i=Zn.ACTIVE_CELL_BORDER_WIDTH){const{metrics:o,theme:r}=e,{allColumnWidths:l,allColumnXs:a,allRowHeights:d,allRowYs:c}=o,u=O(a,n),m=O(c,s),p=O(l,n),g=O(d,s);let f=u-i*.5,C=m-i*.5,S=p+i,w=g+i;f<=0&&(S+=f-1,f=1),C<=0&&(w+=C-1,C=1);const{lineWidth:T}=t;t.beginPath(),t.lineWidth=i,t.strokeStyle=r.selectionOutlineColor,this.drawRoundedRect(t,f,C,S,w),t.stroke(),t.lineWidth=T}drawRoundedRect(t,e,n,s,i,o=Zn.DEFAULT_EDGE_RADIUS){t.beginPath(),t.moveTo(e+o,n),t.lineTo(e+s-o,n),t.quadraticCurveTo(e+s,n,e+s,n+o),t.lineTo(e+s,n+i-o),t.quadraticCurveTo(e+s,n+i,e+s-o,n+i),t.lineTo(e+o,n+i),t.quadraticCurveTo(e,n+i,e,n+i-o),t.lineTo(e,n+o),t.quadraticCurveTo(e,n,e+o,n),t.closePath()}drawDraggingColumn(t,e){const{draggingColumn:n,metrics:s,mouseX:i,theme:o,model:r}=e;if(n==null||i==null)return;const{range:l,depth:a}=n,{gridX:d,gridY:c,allColumnXs:u,allColumnWidths:m,height:p,width:g,columnHeaderMaxDepth:f,columnHeaderHeight:C,movedColumns:S,modelColumns:w,floatingLeftWidth:T}=s,y=w.get(l[0])??q.getModelIndex(l[0],S),E=r.getColumnHeaderGroup(y,a);if(a>0&&!E)return;const[R,F]=l,D=O(u,R),H=O(u,F)+O(m,F)-D,U=n.left,{backgroundColor:A,font:Y,headerFont:G,reorderOffset:z,shadowBlur:x,shadowColor:L}=o,P=(f-a-1)*C;t.save(),t.translate(d,0),t.save(),t.beginPath(),t.rect(T,0,g,p),t.clip(),t.fillStyle=A,t.fillRect(D,P,H,p),t.restore(),t.translate(0,z),t.save(),t.shadowColor=L,t.shadowBlur=x,t.fillStyle=A,t.fillRect(n.left,P+z,n.width,p),t.restore(),t.beginPath(),t.rect(n.left,P,n.width+1,p),t.clip(),t.translate(U-D,0),t.font=G;const Z=[];for(let ne=n.range[0];ne<=n.range[1];ne+=1)Z.push(ne);this.drawColumnHeaders(t,e),this.drawColumnHeadersForRange(t,e,[Z[0],Z[Z.length-1]],{minX:D,maxX:g}),t.translate(0,c),t.font=Y,this.drawGridBackground(t,e);for(let ne=R;ne<=F;ne+=1)this.drawColumnCellContents(t,e,ne);t.restore()}drawDraggingRow(t,e){const{draggingRow:n,draggingRowOffset:s,metrics:i,mouseY:o,theme:r}=e;if(n==null||o==null)return;const{gridX:l,gridY:a,allRowYs:d,allRowHeights:c,width:u}=i,m=O(d,n),p=O(c,n)+1,{backgroundColor:g,font:f,headerFont:C,reorderOffset:S,shadowBlur:w,shadowColor:T}=r;t.save(),t.translate(0,a),t.fillStyle=g,t.fillRect(0,m,u,p),t.translate(l+S,o-m-a-(s??0)),t.save(),t.shadowColor=T,t.shadowBlur=w,t.fillStyle=g,t.fillRect(-l,m,u,p),t.restore(),t.beginPath(),t.rect(-l,m,u,p),t.clip(),t.font=f,this.drawGridBackground(t,e),this.drawCellContents(t,e),t.translate(-l,-a),t.font=C,this.drawRowHeaders(t,e),t.restore()}drawScrollBars(t,e){const{isDraggingHorizontalScrollBar:n,isDraggingVerticalScrollBar:s,isDragging:i,metrics:o,mouseX:r,mouseY:l,theme:a}=e;if(a.scrollBarSize<=0)return;const{width:d,height:c,handleHeight:u,handleWidth:m,scrollX:p,scrollY:g,hasHorizontalBar:f,hasVerticalBar:C,barWidth:S,barHeight:w,barLeft:T,barTop:y}=o,{scrollBarBackgroundColor:E,scrollBarHoverBackgroundColor:R,scrollBarCasingColor:F,scrollBarCornerColor:D,scrollBarColor:_,scrollBarHoverColor:H,scrollBarActiveColor:U,scrollBarSize:A,scrollBarHoverSize:Y,scrollBarCasingWidth:G,scrollBarSelectionTick:z,scrollBarSelectionTickColor:x,scrollBarActiveSelectionTickColor:L,autoSelectRow:P,autoSelectColumn:Z}=a,ne=r!=null&&l!=null&&r<=d&&l<=c,B=s||C&&!n&&!i&&r!=null&&l!=null&&r>=d-Y&&l>=y&&ne,W=n||f&&!s&&!i&&!B&&r!=null&&l!=null&&l>=c-Y&&r>=T&&ne,X=W?Y:A,se=B?Y:A;if(t.translate(T,y),f&&C&&(t.fillStyle=F,t.fillRect(d-T-A,c-y-A,A,A),t.fillStyle=D,t.fillRect(d-T-A+G,c-y-A+G,A-G,A-G)),f){const ce=p,Q=c-y-X;if(t.fillStyle=F,t.fillRect(0,Q,S,X-G),t.fillStyle=W?R:E,t.fillRect(0,Q+G,S,X-G),n?t.fillStyle=U:W?t.fillStyle=H:t.fillStyle=_,t.fillRect(ce,Q+G,m,X-G),!P&&z&&x!=null&&L!=null){t.fillStyle=x;const{selectedRanges:he,cursorColumn:be}=e,{lastLeft:Re,columnCount:et}=o,je=[...he].filter(De=>De.startColumn!=null&&De.endColumn!=null).map(De=>[De.startColumn,De.endColumn]).sort(q.compareRanges),En=q.mergeSortedRanges(je),Ut=De=>De<=Re?De/Re*(S-m):S-m+(De-Re)/(et-Re)*m;for(let De=0;De<En.length;De+=1){const mt=En[De],at=mt[0],Rt=mt[1];if(at!=null&&Rt!=null&&(at!==be||Rt!==be)){const Vt=Ut(at),yn=Math.max(1,Math.round(Ut(Rt+1)-Vt)),on=X-G;t.fillRect(Vt,Q+G+Math.round(on/3),yn,Math.round(on/3))}}if(be!=null){const De=Ut(be),mt=2,at=X-G;t.fillStyle=L,t.fillRect(De,Q+G,mt,at)}}}if(C){const ce=d-T-se,Q=g;if(t.fillStyle=F,t.fillRect(ce,0,se-G,w),t.fillStyle=B?R:E,t.fillRect(ce+G,0,se-G,w),s?t.fillStyle=U:B?t.fillStyle=H:t.fillStyle=_,t.fillRect(ce+G,Q,se-G,u),!Z&&z&&x!=null&&L!=null){const{selectedRanges:he,cursorRow:be}=e,{lastTop:Re,rowCount:et}=o,yt=De=>De<=Re?De/Re*(w-u):w-u+(De-Re)/(et-Re)*u;t.fillStyle=x;const En=[...he].filter(De=>De.startRow!=null&&De.endRow!=null).map(De=>[De.startRow,De.endRow]).sort(q.compareRanges),Ut=q.mergeSortedRanges(En);for(let De=0;De<Ut.length;De+=1){const mt=Ut[De],at=mt[0],Rt=mt[1];if(at!=null&&Rt!=null&&(at!==be||Rt!==be)){const Vt=yt(at),yn=se-G,on=Math.max(1,Math.round(yt(Rt+1)-Vt));t.fillRect(ce+G+Math.round(yn/3),Vt,Math.round(yn/3),on)}}if(be!=null){const De=Math.round(yt(be)),mt=se-G,at=2;t.fillStyle=L,t.fillRect(ce+G,De,mt,at)}}}t.translate(-T,-y)}};let li=Zn;li.DEFAULT_FONT_WIDTH=10;li.DEFAULT_EDGE_RADIUS=2;li.ACTIVE_CELL_BORDER_WIDTH=2;const Dc=100;class rw extends ft{constructor(){super(...arguments),this.hasExtendedFloating=!1}onDown(e,n,s){const{x:i,y:o,column:r,row:l}=e,{metrics:a}=n;if(!a)throw new Error("metrics not set");const{gridX:d,gridY:c,maxX:u,maxY:m}=a,p=i-d,g=o-c;if(p<0||g<0||r==null&&p>u||l==null&&g>m)return!1;const f=q.isModifierKeyDown(s),C=s.shiftKey;f||(C?n.trimSelectedRanges():n.clearSelectedRanges());const S=n.getTheme(),{autoSelectRow:w,autoSelectColumn:T}=S;return(r!==null||!T)&&(l!==null||!w)&&(n.focus(),n.moveCursorToPosition(r,l,C,!1,C&&f)),this.startPoint=e,this.hasExtendedFloating=!1,this.dragBounds=q.getScrollDragBounds(a,l,r),!0}onDrag(e,n){if(this.startPoint===void 0)return!1;this.stopTimer();const{row:s,column:i}=this.startPoint,{x:o,y:r}=e;let{row:l,column:a}=e;const{metrics:d}=n;if(!d)throw new Error("metrics not set");const{left:c,lastLeft:u,top:m,lastTop:p,columnWidth:g,rowHeight:f}=d,C=q.getScrollDragBounds(d,s,i);let S=0,w=0;if(c<u&&(o<C.x1?S=o-C.x1:o>C.x2&&(S=o-C.x2)),m<p&&(r<C.y1?w=r-C.y1:r>C.y2&&(w=r-C.y2)),S!==0||w!==0)this.startTimer(n,e,S>0?Math.ceil(S/g):Math.floor(S/g),w>0?Math.ceil(w/f):Math.floor(w/f));else if(l!=null&&a!=null){const{floatingTopRowCount:T,floatingBottomRowCount:y,floatingLeftColumnCount:E,floatingRightColumnCount:R,columnCount:F,rowCount:D,bottom:_,right:H,topVisible:U,bottomVisible:A,leftVisible:Y,rightVisible:G}=d;this.hasExtendedFloating||(s!==null&&s<T&&l>=T?(l=T,this.hasExtendedFloating=!0):s!==null&&s>=D-y&&l<D-y&&(l=D-y-1,this.hasExtendedFloating=!0),i!==null&&i<E&&a>=E?(a=E,this.hasExtendedFloating=!0):i!==null&&i>=F-R&&a<F-R&&(a=F-R-1,this.hasExtendedFloating=!0)),s!==null&&!q.isFloatingRow(s,d)&&q.isFloatingRow(l,d)&&(s>l&&l<m?l=U-1:s<l&&l>_&&(l=A+1)),i!==null&&!q.isFloatingColumn(i,d)&&q.isFloatingColumn(a,d)&&(i>a&&a<c?a=Y-1:i<a&&a>H&&(a=G+1)),n.moveCursorToPosition(a,l,!0,!0)}return!0}onUp(e,n){return this.startPoint!==void 0&&(this.startPoint=void 0,this.dragBounds=void 0,this.stopTimer(),n.commitSelection()),!1}moveSelection(e,n,s,i){const{row:o,column:r}=n,{metrics:l}=e;if(!l)throw new Error("metrics not set");const{selectionEndRow:a,selectionEndColumn:d}=e.state;if(a==null||d==null)throw new Error("selection not set");const{rowCount:c,columnCount:u}=l,m=s<0&&r!=null?r:0,p=s>0&&r!=null?r:u-1,g=i<0&&o!=null?o:0,f=i>0&&o!=null?o:c-1;e.moveCursorToPosition(Math.min(Math.max(m,d+s),p),Math.min(Math.max(g,a+i),f),!0),this.lastTriggerTime=Date.now()}startTimer(e,n,s,i){this.stopTimer();const o=this.lastTriggerTime!=null?Dc-Math.min(Dc,Date.now()-this.lastTriggerTime):0;this.timer=setTimeout(()=>{this.moveSelection(e,n,s,i),this.startTimer(e,n,s,i)},o)}stopTimer(){this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0)}}const Nc=5,lw=1e3/60,cr=10;function bs(t,e,n,s){const{modelColumns:i,movedColumns:o,allColumnXs:r,columnCount:l,allColumnWidths:a,userColumnWidths:d,calculatedColumnWidths:c,floatingLeftWidth:u,maxX:m}=n;if(e==null||t==null||t>l||t<0)return null;const p=i.get(t)??q.getModelIndex(t,o),g=s.getColumnHeaderGroup(p,e),f=g!=null;let C,S,w;if(g!=null){const[T,y]=g.getVisibleRange(o);C=r.get(T)??u,S=(r.get(y)??m)+(a.get(y)??0),w=[T,y]}else{const T=r.get(t);if(T==null)return null;C=T,S=C+(a.get(t)??d.get(p)??c.get(p)??0),w=[t,t]}return{visibleIndex:t,modelIndex:p,left:C,right:S,width:S-C,isColumnGroup:f,range:w,depth:e}}class aw extends ft{constructor(){super(...arguments),this.cursor=null,this.draggingColumn=null}setScrollInterval(e,n){this.scrollingInterval!=null&&n===this.scrollingDirection||(this.scrollingDirection=n,this.scrollingInterval=window.setInterval(()=>{const{metrics:s}=e;if(!s)return;const{left:i,lastLeft:o,leftOffset:r,userColumnWidths:l,calculatedColumnWidths:a,movedColumns:d,allColumnWidths:c}=s;let u=i,m=r;if(n==="left")for(m-=cr;m<0;){u-=1;const f=q.getModelIndex(i-1,d),C=l.get(f)??a.get(f);C===void 0?m=0:m+=C,u<0&&(m=0,u=0)}else{m+=cr;let f=c.get(i);for(;f!==void 0&&m>f;){u+=1,m-=f;const C=q.getModelIndex(i+1,d);f=l.get(C)??a.get(C),u>o&&(m=0,u=o)}}const{mouseX:p,mouseY:g}=e.state;s==null||p==null||g==null||(this.moveDraggingColumn(p,e,n==="left"?-cr:cr),e.setState({left:u,leftOffset:m}),(n==="left"&&u===0&&r===0||n==="right"&&u===o)&&this.clearScrollInterval())},lw))}clearScrollInterval(){this.scrollingDirection=void 0,window.clearInterval(this.scrollingInterval),this.scrollingInterval=void 0}onLeave(){return this.clearScrollInterval(),!1}onDown(e,n){const{model:s}=n.props,{x:i,column:o,columnHeaderDepth:r}=e,{metrics:l}=n;if(!l)throw new Error("Metrics not set");const a=bs(o,r,l,s);if(o==null||a==null||r==null||r>0&&!a.isColumnGroup)return!1;const{rowHeaderWidth:d}=l;return this.initialGridPoint=e,this.draggingColumn=null,this.cursor=null,a.modelIndex!=null&&r!=null&&s.isColumnMovable(a.modelIndex,r)&&(this.draggingOffset=i-a.left-d,this.initialOffset=this.draggingOffset),!1}onDrag(e,n,s){if(this.draggingOffset===void 0||this.initialGridPoint===void 0||this.initialOffset===void 0)return!1;const{x:i,y:o}=e,{columnHeaderDepth:r}=this.initialGridPoint,{model:l}=n.props;let{draggingColumn:a}=this;const{metrics:d}=n;if(!d)throw new Error("Metrics not set");if(!a&&Math.abs(this.initialGridPoint.x-i)<Nc&&Math.abs(this.initialGridPoint.y-o)<Nc)return!1;if(a==null){const c=bs(this.initialGridPoint.column,r,d,l);if(!c||r==null||!l.isColumnMovable(c.modelIndex)||r>0&&!c.isColumnGroup||c.range[0]==null)return!1;a={range:c.range,depth:r,left:c.left,width:c.width};const u=bs(a.range[0],0,d,l),m=bs(a.range[1],0,d,l);if(!u||!m)return!1;this.draggingColumn=a,n.setState({draggingColumn:a,isDragging:!0})}return this.cursor="move",this.moveDraggingColumn(e.x,n,s.movementX),!0}moveDraggingColumn(e,n,s){if(this.draggingOffset===void 0||this.initialGridPoint===void 0||this.initialOffset===void 0||this.draggingColumn==null||s===0)return;if(this.initialOffset!==this.draggingOffset){this.draggingOffset<this.initialOffset&&this.initialOffset<this.draggingOffset+s||this.draggingOffset>this.initialOffset&&this.initialOffset>this.draggingOffset+s?this.draggingOffset=this.initialOffset:this.draggingOffset+=s,this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},n.setState({draggingColumn:this.draggingColumn});return}const{depth:i}=this.draggingColumn,{model:o}=n.props,{movedColumns:r}=n.state,{metrics:l}=n;if(!l)throw new Error("Metrics not set");const{floatingLeftWidth:a,width:d,columnHeaderMaxDepth:c,allColumnXs:u}=l,m=s<0,p=bs(this.draggingColumn.range[0],i,l,o);if(!p)return;const g=e-this.draggingOffset,f=g+p.width;this.draggingColumn={...this.draggingColumn,left:g},n.setState({draggingColumn:this.draggingColumn});const C=bs(q.getColumnAtX(Qe(m?g:f,a,d),l,!0),i,l,o),S=o.getColumnHeaderParentGroup(p.modelIndex,p.depth);if(!C)return;if(S!==void 0){const F=S.getVisibleRange(r);if(C.visibleIndex<F[0]){const D=this.moveColumn(p,F[0],r);this.draggingOffset=e-(u.get(F[0])??0),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},this.clearScrollInterval(),n.setState({draggingColumn:this.draggingColumn,movedColumns:D});return}if(C.visibleIndex>F[1]){const D=this.moveColumn(p,F[1]-(p.range[1]-p.range[0]),r),{right:_=0}=bs(F[1],0,l,o)??{};this.draggingOffset=e-(_-p.width),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},this.clearScrollInterval(),n.setState({draggingColumn:this.draggingColumn,movedColumns:D});return}}if(!o.isColumnMovable(C.modelIndex)){let F=C.visibleIndex;if(m)for(F+=1;F<p.visibleIndex&&!o.isColumnMovable(q.getModelIndex(F,r));)F+=1;else for(F-=1;F>p.visibleIndex&&!o.isColumnMovable(q.getModelIndex(F,r));)F-=1;if(F!==p.visibleIndex){m||(F-=p.range[1]-p.range[0]);const _=this.moveColumn(p,F,r);n.setState({movedColumns:_,draggingColumn:this.draggingColumn})}const D=bs(F,0,l,o);m?this.draggingOffset=e-(D?.left??0):this.draggingOffset=e-((D?.right??0)-p.width),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},n.setState({draggingColumn:this.draggingColumn});return}if(g<=a?this.setScrollInterval(n,"left"):f>d?this.setScrollInterval(n,"right"):this.clearScrollInterval(),C.visibleIndex===p.visibleIndex||m&&p.visibleIndex<C.visibleIndex||!m&&p.visibleIndex>C.visibleIndex)return;const w=C.left+C.width*.5,T=o.getColumnHeaderParentGroup(p.modelIndex,p.depth);let y,E=(T?.depth??c)-1;for(;E>=0&&y===void 0;)y=o.getColumnHeaderGroup(C.modelIndex,E),E-=1;let R;m&&g<w&&(!y||C.visibleIndex===y.getVisibleRange(r)[0])&&(R=this.moveColumn(p,C.range[0],r)),!m&&f>w&&(!y||C.visibleIndex===y.getVisibleRange(r)[1])&&(R=this.moveColumn(p,C.range[1]-(p.range[1]-p.range[0]),r)),R&&(this.draggingColumn={...this.draggingColumn,left:g},n.setState({movedColumns:R,draggingColumn:this.draggingColumn}))}moveColumn(e,n,s){const i=e.isColumnGroup?q.moveRange(e.range,n,s):q.moveItem(e.visibleIndex,n,s),o=n-e.range[0],r=[e.range[0]+o,e.range[1]+o];return this.draggingColumn&&(this.draggingColumn={...this.draggingColumn,range:r}),i}onUp(e,n){return this.cursor=null,this.clearScrollInterval(),this.draggingOffset!=null?(this.draggingOffset=void 0,n.setState({draggingColumn:null,isDragging:!1}),!0):!1}}class od extends ft{constructor(){super(...arguments),this.cursor="default"}static getLeftWithOffsetFromRawLeft(e,n){const s=e.getTheme(),{metrics:i,metricCalculator:o}=e;if(!i)throw new Error("metrics not set");if(s.scrollSnapToColumn)return{left:Math.round(n),leftOffset:0};const r=Math.floor(n),l=n-r;let a=i.allColumnWidths.get(r);if(a==null){const c=e.getMetricState();a=o.getVisibleColumnWidth(r,c)}const d=a*l;return{left:r,leftOffset:d}}isInScrollBar(e,n){const s=n.getTheme(),{scrollBarSize:i,scrollBarHoverSize:o}=s,{metrics:r}=n;if(!r)throw new Error("metrics not set");const{x:l,y:a}=e,{barLeft:d,barWidth:c,height:u,hasHorizontalBar:m}=r;return m&&i>0&&a>=u-o&&a<u&&l>d&&l<d+c}getLeftWithOffset(e,n){const{metrics:s}=n;if(!s)throw new Error("metrics not set");const{x:i}=e,{barWidth:o,handleWidth:r,lastLeft:l,barLeft:a,columnCount:d,scrollableContentWidth:c,scrollableViewportWidth:u}=s,m=i-a,p=Qe((m-(this.dragOffset??0))/(o-r),0,1);if(d===1)return{left:0,leftOffset:p*(c-u)};const g=p*l;return od.getLeftWithOffsetFromRawLeft(n,g)}onDown(e,n){const{metrics:s}=n;if(!s)throw new Error("metrics not set");const{x:i}=e,{handleWidth:o,barLeft:r,scrollX:l}=s;if(!this.isInScrollBar(e,n))return!1;const a=i-r;if(a>=l&&a<=l+o)this.dragOffset=a-l,n.setState({isDraggingHorizontalScrollBar:!0});else{this.dragOffset=0;const{left:d,leftOffset:c}=this.getLeftWithOffset(e,n);n.setViewState({left:d,leftOffset:c,isDraggingHorizontalScrollBar:!0,isDragging:!0})}return!0}onDrag(e,n){if(this.dragOffset!=null){const{left:s,leftOffset:i}=this.getLeftWithOffset(e,n);return n.setViewState({left:s,leftOffset:i,isDraggingHorizontalScrollBar:!0,isDragging:!0}),!0}return!1}onMove(e,n){return this.isInScrollBar(e,n)}onUp(e,n){return this.dragOffset!==void 0&&(this.dragOffset=void 0,n.setState({isDraggingHorizontalScrollBar:!1,isDragging:!1})),this.isInScrollBar(e,n)}onClick(e,n){return this.isInScrollBar(e,n)}}class dw extends ft{constructor(){super(...arguments),this.cursor="move"}onDown(e,n){const{model:s}=n.props,{x:i,y:o,row:r}=e,{metrics:l}=n;if(!l)throw new Error("metrics not set");const{columnHeaderHeight:a,rowHeaderWidth:d,allRowYs:c}=l;if(i<=d&&r!==null&&s.isRowMovable(r)){const u=O(c,r);this.draggingOffset=o-u-a,n.setState({draggingRowOffset:this.draggingOffset})}return!1}onDrag(e,n){if(this.draggingOffset==null)return!1;const{model:s}=n.props;let{draggingRow:i}=n.state;const{mouseX:o,mouseY:r}=n.state;if(o==null||r==null)return!1;if(i==null){const{row:R}=n.getGridPointFromXY(o,r);if(R!=null&&!s.isRowMovable(R)||(i=R,n.setState({draggingRow:i,isDragging:!0}),i==null))return!1}const{metrics:l}=n;if(!l)throw new Error("metrics not set");const{top:a,lastTop:d,bottom:c,bottomVisible:u,rowCount:m,columnHeaderHeight:p,allRowHeights:g,allRowYs:f,height:C}=l;let S=p;if(a<i){const R=i-1;S=O(f,R)+O(g,R)*.5+p}let w=C;if(i<c){const R=i+1;w=O(f,R)+O(g,R)*.5+p}let{movedRows:T}=n.state;r<S&&i>0&&s.isRowMovable(i-1)?(T=q.moveItem(i,i-1,T),i-=1):w<r&&i<m-1&&s.isRowMovable(i+1)&&(T=q.moveItem(i,i+1,T),i+=1),n.setState({movedRows:T,draggingRow:i});const y=p+O(g,a)*.5,E=p+O(f,u)+O(g,u)*.5;return r<y&&a>0?n.setState({top:a-1}):r>E&&a<d&&n.setState({top:a+1}),!0}onUp(e,n){return this.draggingOffset!==void 0?(this.draggingOffset=void 0,n.setState({draggingRowOffset:null,draggingRow:null,isDragging:!1}),!0):!1}}class rd extends Ju{constructor(){super(...arguments),this.hiddenCursor="s-resize",this.defaultCursor="row-resize",this.pointProperty="y",this.userSizesProperty="userRowHeights",this.visibleOffsetProperty="visibleRowYs",this.visibleSizesProperty="visibleRowHeights",this.marginProperty="columnHeaderHeight",this.calculatedSizesProperty="calculatedRowHeights",this.initialSizesProperty="initialRowHeights",this.modelIndexesProperty="modelRows",this.firstIndexProperty="firstRow",this.treePaddingProperty="treePaddingY",this.getHiddenItems=q.getHiddenRows,this.getNextShownItem=q.getNextShownRow,this.getSeparator=rd.getRowSeparator}static getRowSeparator(e,n,s,i){if(!i.allowRowResize)return null;const{x:o,y:r}=e,l=q.getRowSeparatorIndex(o,r,n,i);return l!=null?{index:l,depth:0}:null}setSize(e,n,s){e.setRowHeight(n,s)}resetSize(e,n){e.resetRowHeight(n)}updateSeparator(e,n){e.setState({draggingRowSeparator:n,isDragging:n!==null})}}class Ai extends ft{static isInTreeBox(e,n){const{column:s,row:i,x:o,y:r}=e,{metrics:l}=n;if(!l)throw new Error("metrics not set");const{gridX:a,gridY:d,firstColumn:c,allColumnXs:u,allColumnWidths:m,allRowHeights:p,allRowYs:g,visibleRowTreeBoxes:f}=l;if(s===c&&i!=null&&f.get(i)!=null&&o>a&&r>d){const C=O(u,s),S=O(m,s),w=O(g,i),T=O(p,i);if(o>=a+C&&o<=a+C+S&&r>=d+w&&r<=d+w+T)return!0}return!1}onDown(e,n){return Ai.isInTreeBox(e,n)}onClick(e,n,s){if(Ai.isInTreeBox(e,n)){const{row:i}=e;if(i!==null)return n.toggleRowExpanded(i,q.isModifierKeyDown(s)),!0}return!1}}class cw extends ft{isInCorner(e,n){const s=n.getTheme(),{scrollBarSize:i}=s,{metrics:o}=n;if(!o)throw new Error("metrics not set");const{x:r,y:l}=e,{width:a,height:d,hasVerticalBar:c,hasHorizontalBar:u}=o;return i>0&&c&&u&&r>=a-i&&l>=d-i&&r<=a&&l<=d}onDown(e,n){return this.isInCorner(e,n)}onUp(e,n){return this.isInCorner(e,n)}onClick(e,n){return this.isInCorner(e,n)}}class ld extends ft{constructor(){super(...arguments),this.cursor="default"}static getTopWithOffsetFromRawTop(e,n){const s=e.getTheme(),{metrics:i,metricCalculator:o}=e;if(!i)throw new Error("metrics not set");if(s.scrollSnapToRow)return{top:Math.round(n),topOffset:0};const r=Math.floor(n),l=n-r;let a=i.allRowHeights.get(r);if(a==null){const c=e.getMetricState();a=o.getVisibleRowHeight(r,c)}const d=a*l;return{top:r,topOffset:d}}isInScrollBar(e,n){const s=n.getTheme(),{scrollBarSize:i,scrollBarHoverSize:o}=s,{metrics:r}=n;if(!r)throw new Error("metrics not set");const{x:l,y:a}=e,{barTop:d,barHeight:c,width:u,hasVerticalBar:m}=r;return m&&i>0&&l>=u-o&&l<u&&a>d&&a<d+c}getTopWithOffset(e,n){const{metrics:s}=n;if(!s)throw new Error("metrics not set");const{y:i}=e,{barHeight:o,handleHeight:r,lastTop:l,barTop:a,rowCount:d,scrollableContentHeight:c,scrollableViewportHeight:u}=s,m=i-a,p=Qe((m-(this.dragOffset??0))/(o-r),0,1);if(d===1)return{top:0,topOffset:p*(c-u)};const g=p*l;return ld.getTopWithOffsetFromRawTop(n,g)}onDown(e,n){const{metrics:s}=n;if(!s)throw new Error("metrics not set");const{y:i}=e,{handleHeight:o,barTop:r,scrollY:l}=s;if(!this.isInScrollBar(e,n))return!1;const a=i-r;if(a>=l&&a<=l+o)this.dragOffset=a-l,n.setState({isDraggingVerticalScrollBar:!0});else{this.dragOffset=0;const{top:d,topOffset:c}=this.getTopWithOffset(e,n);n.setViewState({top:d,topOffset:c,isDraggingVerticalScrollBar:!0,isDragging:!0})}return!0}onMove(e,n){return this.isInScrollBar(e,n)}onDrag(e,n){if(this.dragOffset!=null){const{top:s,topOffset:i}=this.getTopWithOffset(e,n);return n.setViewState({top:s,topOffset:i,isDraggingVerticalScrollBar:!0,isDragging:!0}),!0}return!1}onUp(e,n){return this.dragOffset!==void 0&&(this.dragOffset=void 0,n.setState({isDraggingVerticalScrollBar:!1,isDragging:!1})),this.isInScrollBar(e,n)}onClick(e,n){return this.isInScrollBar(e,n)}}class hw extends ft{onDoubleClick({column:e,row:n},s){const{model:i}=s.props;return tt(i)&&e!=null&&n!=null&&i.isEditableRange(ae.makeCell(e,n))?(s.startEditing(e,n),!0):!1}}class ci{constructor(e=5e3){this.order=e}onDown(e,n){return!1}}class uw extends ci{onDown(e,n){switch(e.key){case"a":if(q.isModifierKeyDown(e))return n.selectAll(),!0;break;case"ArrowUp":return this.handleArrowMove(0,-1,e,n);case"ArrowDown":return this.handleArrowMove(0,1,e,n);case"ArrowRight":return this.handleArrowMove(1,0,e,n);case"ArrowLeft":return this.handleArrowMove(-1,0,e,n);case"k":case"K":return q.isModifierKeyDown(e)?!1:this.handlePageUp(e,n);case"j":case"J":return q.isModifierKeyDown(e)?!1:this.handlePageDown(e,n);case"h":case"H":return q.isModifierKeyDown(e)?!1:(e.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(0,n.state.cursorRow,e.shiftKey),!0);case"l":case"L":{if(q.isModifierKeyDown(e))return!1;const{model:s}=n.props,{columnCount:i}=s;return e.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(i-1,n.state.cursorRow,e.shiftKey),!0}case"PageDown":return this.handlePageDown(e,n);case"PageUp":return this.handlePageUp(e,n);case"Home":return e.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(q.isModifierKeyDown(e)?n.state.cursorColumn:0,q.isModifierKeyDown(e)?0:n.state.cursorRow,e.shiftKey,!0,!0),!0;case"End":{const{model:s}=n.props,{columnCount:i,rowCount:o}=s;return e.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(q.isModifierKeyDown(e)?n.state.cursorColumn:i-1,q.isModifierKeyDown(e)?o-1:n.state.cursorRow,e.shiftKey,!0,!0),!0}case"Escape":return n.clearSelectedRanges(),{preventDefault:!1,stopPropagation:!1};case"Enter":if(n.state.selectedRanges.length>0)return n.moveCursorInDirection(e.shiftKey?ae.SELECTION_DIRECTION.UP:ae.SELECTION_DIRECTION.DOWN),!0;break;case"Tab":if(n.state.selectedRanges.length>0)return n.moveCursorInDirection(e.shiftKey?ae.SELECTION_DIRECTION.LEFT:ae.SELECTION_DIRECTION.RIGHT),!0;break}return!1}handleArrowMove(e,n,s,i){const o=s.shiftKey,r=q.isModifierKeyDown(s);o?i.trimSelectedRanges():i.clearSelectedRanges();const{cursorRow:l,cursorColumn:a,selectionEndColumn:d,selectionEndRow:c}=i.state,u=o?d:a,m=o?c:l;if(r){const{model:p}=i.props,{columnCount:g,rowCount:f}=p,C=r&&o;let S=null,w=null;e<0?(S=0,w=m):e>0?(S=g-1,w=m):n<0?(S=u,w=0):n>0&&(S=u,w=f-1),S!=null&&w!=null&&i.moveCursorToPosition(S,w,o,!0,C)}else{if(!i.metrics)throw new Error("grid.metrics are not set");const{theme:p}=i.props,{autoSelectRow:g=!1,autoSelectColumn:f=!1}=p;if(g&&e!==0){const{lastLeft:C}=i.metrics;let{left:S}=i.state;S=Qe(S+e,0,C),i.moveCursorToPosition(S,l,o,!1),i.setViewState({left:S})}else if(f&&n!==0){const{lastTop:C}=i.metrics;let{top:S}=i.state;S=Qe(S+n,0,C),i.moveCursorToPosition(S,a,o,!1),i.setViewState({top:S})}else i.moveCursor(e,n,o)}return!0}handlePageUp(e,n){const s=e.shiftKey;s?n.trimSelectedRanges():n.clearSelectedRanges();const{cursorColumn:i,selectionEndRow:o}=n.state,r=o,l=i;if(r==null)return!1;const a=n.getMetricState(),{metricCalculator:d}=n,{bottomVisible:c,topVisible:u,hasHorizontalBar:m}=d.getMetrics(a);let p=r-(c-u);p-=m?0:1,p=Math.max(p,0);const g=Math.max(p-(r-u),0);return n.moveCursorToPosition(l,p,s,!1),n.setViewState({top:g}),!0}handlePageDown(e,n){const s=e.shiftKey;s?n.trimSelectedRanges():n.clearSelectedRanges();const{selectionEndRow:i,cursorColumn:o}=n.state,r=i,l=o;if(r===null)return!1;const a=n.getMetricState(),{metricCalculator:d}=n,{bottomVisible:c,topVisible:u,hasHorizontalBar:m,rowCount:p,lastTop:g}=d.getMetrics(a),f=p-1;let C=c-u+r;C+=m?0:1,C=Math.min(C,f);const S=Math.min(g,C-(r-u));return n.moveCursorToPosition(l,C,s,!1),n.setViewState({top:S}),!0}}class mw extends ci{onDown(e,n){switch(e.key){case"Enter":case" ":return this.handleExpandKey(e,n)}return!1}handleExpandKey(e,n){const{selectedRanges:s}=n.state;if(s.length===1){const i=s[0];if(i.startRow===i.endRow&&i.startColumn===i.endColumn){if(!n.metrics)throw new Error("grid.metrics not set");const{model:o}=n.props,{startRow:r,startColumn:l}=i;if(r!=null){const a=n.getModelRow(r);if((l===0||l==null)&&ze(o)&&o.isRowExpandable(a))return n.toggleRowExpanded(r),!0}}}return!1}}class pw extends ci{onDown(e,n){if(q.isModifierKeyDown(e))return!1;const{model:s}=n.props,{cursorColumn:i,cursorRow:o}=n.state;if(i==null||o==null||!tt(s)||!s.isEditableRange(ae.makeCell(i,o)))return!1;const r=i,l=o;return r==null||l==null?!1:e.key.length===1?(n.startEditing(r,l,!0,[1,1],e.key),!0):e.key==="F2"?(n.startEditing(r,l),!0):e.key==="Backspace"?(n.startEditing(r,l,!0,void 0,""),!0):e.key==="Delete"?(n.setValueForCell(r,l,""),!0):!1}}function gw(t){const e=[],n=t.querySelectorAll("tr");for(let s=0;s<n.length;s+=1){const o=n[s].querySelectorAll("td"),r=[];for(let l=0;l<o.length;l+=1){const a=o[l];r.push(a.textContent?.trim()??"")}e.push(r)}return e}function fw(t){const e=[];return t.forEach(n=>{const s=n.textContent??"";s.length>0&&e.push(s.split(/\t|\u00a0\u00a0 \u00a0/))}),e}function Cw(t){const e=t.querySelector("table");if(e!=null)return gw(e);const n=t.textContent?.trim()??"";if(n.length>0){const{childNodes:s}=t,i=n.includes(" "),o=n.includes("\xA0\xA0 \xA0");return i&&s.length!==0&&(s.length===1||s.length>1&&(s[0].textContent==null||!s[0].textContent.includes(" ")))?n.split(`
18
+ `)}this.bufferedMessages=[],this.appendLogText(t)}queue(t){this.bufferedMessages.push(t),this.bufferedMessages.length===1&&(this.flushTimer=setTimeout(this.handleFlushTimeout,At.bufferTimeout))}stopFlushTimer(){this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=void 0)}updateDimensions(){this.editor&&this.editor.layout()}handleClearClick(){this.clearLogs()}clearLogs(){this.messages=[],this.refreshLogText()}handleFlushTimeout(){this.stopFlushTimer(),this.flush()}handleLogMessage(t){this.messages.push(t),this.editor&&this.isLogItemVisible(t)&&this.queue(t)}handleMenuItemClick(t){this.toggleLogLevel(t)}handleResetClick(){this.resetLogLevels()}handleResize(){this.updateDimensions()}handleToggleAllClick(){this.toggleAll()}render(){const t={placement:"bottom-end"},{shownLogLevels:e}=this.state,n=this.getMenuActions(e);return v("div",{className:"log-pane h-100 w-100",children:[v("div",{className:"log-pane-menu",children:[h(V,{kind:"ghost",className:"btn-clear-logs",onClick:this.handleClearClick,icon:gg,tooltip:"Clear log"}),h(V,{kind:"ghost",className:"btn-link-icon btn-overflow",icon:xo,tooltip:"Log Settings",onClick:()=>{},children:h(ns,{actions:n,popperClassName:"log-level-menu-popper",popperOptions:t})})]}),h("div",{className:"log-pane-editor h-100 w-100",ref:s=>{this.editorContainer=s}})]})}};let $i=At;$i.DefaultLogLevels=[St.STDOUT,St.ERROR,St.FATAL,St.STDERR,St.WARN];$i.AllLogLevels=[St.INFO,St.STDOUT,St.ERROR,St.FATAL,St.STDERR,St.WARN,St.DEBUG,St.TRACE];$i.bufferTimeout=16;$i.maxLogSize=131072;$i.truncateSize=65536;class nt{static isValid(e){return!0}static isSameFormat(e,n){throw new Error("isSameFormat not implemented")}static makeFormat(e,n,s){return{label:e,formatString:n,type:s}}format(e,n){return""}}nt.TYPE_GLOBAL="type-global";nt.TYPE_CONTEXT_PRESET="type-context-preset";nt.TYPE_CONTEXT_CUSTOM="type-context-custom";class kC extends nt{format(e){switch(e){case 1:case!0:return"true";case 0:case!1:return"false";default:return""}}}class xC extends nt{format(e){return String.fromCharCode(e)}}const mc=ee.module("DateTimeColumnFormatter"),Xs=class extends nt{constructor({timeZone:t="",showTimeZone:e=!0,showTSeparator:n=!1,defaultDateTimeFormatString:s=Xs.DEFAULT_DATETIME_FORMAT_STRING}={}){super();const i=t||Xs.DEFAULT_TIME_ZONE_ID;try{this.dhTimeZone=I.i18n.TimeZone.getTimeZone(i)}catch{mc.error("Unsupported time zone id",i),this.dhTimeZone=I.i18n.TimeZone.getTimeZone(Xs.DEFAULT_TIME_ZONE_ID)}this.defaultDateTimeFormatString=s,this.showTimeZone=e,this.showTSeparator=n,this.formatStringMap=Xs.makeFormatStringMap(e,n)}static isValid(t){try{return I.i18n.DateTimeFormat.format(t.formatString,new Date),!0}catch{return!1}}static makeFormat(t,e,n=nt.TYPE_CONTEXT_PRESET){return{label:t,formatString:e,type:n}}static isSameFormat(t,e){return t===e||t!==null&&e!==null&&t.type===e.type&&t.formatString===e.formatString}static makeGlobalFormatStringMap(t,e){const n=e?"'T'":" ",s=t?" z":"";return new Map([["yyyy-MM-dd HH:mm:ss",`yyyy-MM-dd${n}HH:mm:ss${s}`],["yyyy-MM-dd HH:mm:ss.SSS",`yyyy-MM-dd${n}HH:mm:ss.SSS${s}`],["yyyy-MM-dd HH:mm:ss.SSSSSSSSS",`yyyy-MM-dd${n}HH:mm:ss.SSSSSSSSS${s}`]])}static getGlobalFormats(t,e){return[...Xs.makeGlobalFormatStringMap(t,e).keys()]}static makeFormatStringMap(t,e){const n=e!==void 0&&e?"'T'":" ",s=t!==void 0&&t?" 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${n}HH:mm:ss${s}`],["yyyy-MM-dd HH:mm:ss.SSS",`yyyy-MM-dd${n}HH:mm:ss.SSS${s}`],["yyyy-MM-dd HH:mm:ss.SSSSSSSSS",`yyyy-MM-dd${n}HH:mm:ss.SSSSSSSSS${s}`]])}static getFormats(t,e){return[...Xs.makeFormatStringMap(t,e).keys()]}getEffectiveFormatString(t){return this.formatStringMap.get(t)??t}format(t,e={}){const n=e.formatString!=null&&e.formatString!==""?e.formatString:this.defaultDateTimeFormatString,s=this.getEffectiveFormatString(n);try{return I.i18n.DateTimeFormat.format(s,t,this.dhTimeZone)}catch{mc.error("Invalid format arguments")}return""}};let st=Xs;st.DEFAULT_DATETIME_FORMAT_STRING="yyyy-MM-dd HH:mm:ss.SSS";st.DEFAULT_TIME_ZONE_ID="America/New_York";const OC=ee.module("DecimalColumnFormatter"),Tn=class extends nt{constructor({defaultFormatString:t=Tn.DEFAULT_FORMAT_STRING}={}){super(),this.defaultFormatString=t}static isValid(t){try{return I.i18n.NumberFormat.format(t.formatString,0),!0}catch{return!1}}static makeFormat(t,e,n=nt.TYPE_CONTEXT_PRESET,s){return{label:t,type:n,formatString:e,multiplier:s}}static makePresetFormat(t,e="",n){return Tn.makeFormat(t,e,nt.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(t="",e){return Tn.makeFormat("Custom Format",t,nt.TYPE_CONTEXT_CUSTOM,e)}static isSameFormat(t,e){return t===e||t!=null&&e!=null&&t.type===e.type&&t.formatString===e.formatString&&t.multiplier===e.multiplier}format(t,e={}){const n=e.formatString!=null&&e.formatString!==""?e.formatString:this.defaultFormatString,s=e.multiplier!=null&&e.multiplier!==0?t*e.multiplier:t;try{return I.i18n.NumberFormat.format(n,s)}catch{OC.error("Invalid format arguments")}return""}};let ke=Tn;ke.DEFAULT_FORMAT_STRING="###,##0.0000";ke.FORMAT_PERCENT=Tn.makePresetFormat("Percent","##0.00%");ke.FORMAT_BASIS_POINTS=Tn.makePresetFormat("Basis Points","###,##0 bp",1e4);ke.FORMAT_MILLIONS=Tn.makePresetFormat("Millions","###,##0.000 mm",1e-6);ke.FORMAT_SCIENTIFIC_NOTATION=Tn.makePresetFormat("Scientific Notation","0.0000E0");ke.FORMAT_ROUND=Tn.makePresetFormat("Round","###,##0");ke.FORMAT_ROUND_TWO_DECIMALS=Tn.makePresetFormat("0.00","###,##0.00");ke.FORMAT_ROUND_FOUR_DECIMALS=Tn.makePresetFormat("0.0000","###,##0.0000");class AC extends nt{format(e){return`${e}`}}const LC=ee.module("IntegerColumnFormatter"),Ni=class extends nt{constructor({defaultFormatString:t=Ni.DEFAULT_FORMAT_STRING}={}){super(),this.defaultFormatString=t}static isValid(t){try{return I.i18n.NumberFormat.format(t.formatString,0),!0}catch{return!1}}static makeFormat(t,e,n=nt.TYPE_CONTEXT_PRESET,s){return{label:t,type:n,formatString:e,multiplier:s}}static makePresetFormat(t,e="",n){return Ni.makeFormat(t,e,nt.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(t="",e){return Ni.makeFormat("Custom Format",t,nt.TYPE_CONTEXT_CUSTOM,e)}static isSameFormat(t,e){return t===e||t!=null&&e!=null&&t.type===e.type&&t.formatString===e.formatString&&t.multiplier===e.multiplier}format(t,e={}){const n=e.formatString!=null&&e.formatString!==""?e.formatString:this.defaultFormatString,s=e.multiplier!=null&&e.multiplier!==0?t*e.multiplier:t;try{return I.i18n.NumberFormat.format(n,s)}catch{LC.error("Invalid format arguments")}return""}};let Ze=Ni;Ze.DEFAULT_FORMAT_STRING="###,##0";Ze.FORMAT_MILLIONS=Ni.makePresetFormat("Millions","###,##0.000 mm",1e-6);Ze.FORMAT_SCIENTIFIC_NOTATION=Ni.makePresetFormat("Scientific Notation","0.0000E0");class PC extends nt{format(e){return e}}const $t=class{static makeDateWrapper(t,e,n=0,s=1,i=0,o=0,r=0,l=0){if(!t)throw new Error("No timezone provided");const a=`${e}`.padStart(4,"0"),d=`${n+1}`.padStart(2,"0"),c=`${s}`.padStart(2,"0"),u=`${i}`.padStart(2,"0"),m=`${o}`.padStart(2,"0"),p=`${r}`.padStart(2,"0"),g=`${l}`.padStart(9,"0"),f=`${a}-${d}-${c} ${u}:${m}:${p}.${g}`;return I.i18n.DateTimeFormat.parse($t.FULL_DATE_FORMAT,f,I.i18n.TimeZone.getTimeZone(t))}static getNextNanos(t){const e=parseInt(t,10),n="0".repeat(9-t.length),s=`${e+1}${n}`;return parseInt(s,10)}static getNextDate(t,e,n){let{year:s,month:i,date:o,hours:r,minutes:l,seconds:a,nanos:d}=e;if(t.nanos!=null){if(t.nanos.length===9)return null;d=$t.getNextNanos(t.nanos),d>999999999&&(a+=1,d=0)}else t.seconds!=null?a+=1:t.minutes!=null?l+=1:t.hours!=null?r+=1:t.date!=null?o+=1:t.month!=null?i+=1:s+=1;const c=new Date(s,i,o,r,l,a);return $t.makeDateWrapper(n,c.getFullYear(),c.getMonth(),c.getDate(),c.getHours(),c.getMinutes(),c.getSeconds(),d)}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 s=0;s<$t.months.length;s+=1)if($t.months[s].startsWith(n))return s}return NaN}static parseDateValues(t,e,n,s,i,o,r){const l=parseInt(t,10),a=e!=null?this.parseMonth(e):0,d=n!=null?parseInt(n,10):1,c=s!=null?parseInt(s,10):0,u=i!=null?parseInt(i,10):0,m=o!=null?parseInt(o,10):0,p=r!=null?parseInt(r.padEnd(9,"0"),10):0;return Number.isNaN(l)||Number.isNaN(a)||Number.isNaN(d)||Number.isNaN(c)||Number.isNaN(u)||Number.isNaN(m)||Number.isNaN(p)?null:{year:l,month:a,date:d,hours:c,minutes:u,seconds:m,nanos:p}}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[,s,,i,,o,,r,,l,,a,,d,c]=n;if(c!=null&&c.length>0)throw new Error(`Unexpected characters after date string '${t}': ${c}`);return{year:s,month:i,date:o,hours:r,minutes:l,seconds:a,nanos:d}}static parseDateRange(t,e){const n=t.trim().toLowerCase();if(n.length===0)throw new Error("Cannot parse date range from empty string");if(n==="null")return[null,null];if(n==="today"){const l=new Date(Date.now()),a=$t.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate()),d=$t.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate()+1);return[a,d]}if(n==="yesterday"){const l=new Date(Date.now()),a=$t.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate()-1),d=$t.makeDateWrapper(e,l.getFullYear(),l.getMonth(),l.getDate());return[a,d]}if(n==="now"){const l=new Date(Date.now());return[I.DateWrapper.ofJsDate(l),null]}const s=$t.parseDateTimeString(n);if(s.year==null&&s.month==null&&s.date==null)throw new Error(`Unable to extract year, month, or day ${n}`);const i=$t.parseDateValues(s.year,s.month,s.date,s.hours,s.minutes,s.seconds,s.nanos);if(i==null)throw new Error(`Unable to extract date values from ${s}`);const o=$t.makeDateWrapper(e,i.year,i.month,i.date,i.hours,i.minutes,i.seconds,i.nanos),r=$t.getNextDate(s,i,e);return[o,r]}static getJsDate(t){return typeof t=="number"?new Date(t):t.asDate()}};let vn=$t;vn.FULL_DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSSSSS";vn.months=["january","february","march","april","may","june","july","august","september","october","november","december"];class zt{}zt.not="not";zt.and="and";zt.or="or";function HC(t){if(!(t==="not"||t==="and"||t==="or"))throw new Error("operator is not a valid FilterOperatorValue")}class ${}$.eq="eq";$.eqIgnoreCase="eqIgnoreCase";$.notEq="notEq";$.notEqIgnoreCase="notEqIgnoreCase";$.greaterThan="greaterThan";$.greaterThanOrEqualTo="greaterThanOrEqualTo";$.lessThan="lessThan";$.lessThanOrEqualTo="lessThanOrEqualTo";$.in="in";$.inIgnoreCase="inIgnoreCase";$.notIn="notIn";$.notInIgnoreCase="notInIgnoreCase";$.isTrue="isTrue";$.isFalse="isFalse";$.isNull="isNull";$.invoke="invoke";$.contains="contains";$.notContains="notContains";$.startsWith="startsWith";$.endsWith="endsWith";$.containsAny="containsAny";function eu(t){switch(t){case $.eq:return"is exactly";case $.eqIgnoreCase:return"is exactly (ignore case)";case $.notEq:return"is not exactly";case $.notEqIgnoreCase:return"is not exactly (ignore case)";case $.contains:return"contains";case $.notContains:return"does not contain";case $.startsWith:return"starts with";case $.endsWith:return"ends with";default:throw new Error(`Unrecognized text filter type ${t}`)}}function tu(t){switch(t){case $.eq:return"is equal to";case $.notEq:return"is not equal to";case $.greaterThan:return"greater than";case $.greaterThanOrEqualTo:return"greater than or equal to";case $.lessThan:return"less than";case $.lessThanOrEqualTo:return"less than or equal to";default:throw new Error(`Unrecognized number filter type ${t}`)}}function nu(t){switch(t){case $.eq:return"date is";case $.notEq:return"date is not";case $.notEqIgnoreCase:case $.greaterThan:return"date is after";case $.greaterThanOrEqualTo:return"date is after or equal";case $.lessThan:return"date is before";case $.lessThanOrEqualTo:return"date is before or equal";default:throw new Error(`Unrecognized date filter type ${t}`)}}function UC(t){switch(t){case $.isTrue:return"Is True";case $.isFalse:return"Is False";case $.isNull:return"Is Null";default:throw new Error(`Unrecognized boolean filter type ${t}`)}}const qn=ee.module("TableUtils"),re=class{static getSortIndex(t,e){for(let n=0;n<t.length;n+=1)if(t[n].column?.index===e)return n;return null}static getSortForColumn(t,e){const n=re.getSortIndex(t,e);return n!=null?t[n]:null}static getFilterText(t){return t?t.toString():null}static getFilterTypes(t){return re.isBooleanType(t)?[$.isTrue,$.isFalse,$.isNull]:re.isCharType(t)||re.isNumberType(t)||re.isDateType(t)?[$.eq,$.notEq,$.greaterThan,$.greaterThanOrEqualTo,$.lessThan,$.lessThanOrEqualTo]:re.isTextType(t)?[$.eq,$.eqIgnoreCase,$.notEq,$.notEqIgnoreCase,$.contains,$.notContains,$.startsWith,$.endsWith]:[]}static getNextSort(t,e,n){if(t==null||n<0||n>=t.length)return null;const s=re.getSortForColumn(e,n);return s===null?t[n].sort().asc():s.direction===re.sortDirection.ascending?s.desc():null}static makeColumnSort(t,e,n,s){if(t==null||e<0||e>=t.length||n===re.sortDirection.none)return null;let i=t[e].sort();switch(n){case re.sortDirection.ascending:i=i.asc();break;case re.sortDirection.descending:i=i.desc();break}return s&&(i=i.abs()),i}static toggleSortForColumn(t,e,n,s=!1){if(n<0||n>=e.length)return[];const i=re.getNextSort(e,t,n);return re.setSortForColumn(t,n,i,s)}static sortColumn(t,e,n,s,i,o){if(t==null||n<0||n>=e.length)return[];const r=re.makeColumnSort(e,n,s,i);return re.setSortForColumn(t,n,r,o)}static setSortForColumn(t,e,n,s=!1){const i=re.getSortIndex(t,e);let o=[];return s&&(o=o.concat(t.filter(({direction:r})=>r!==re.sortDirection.reverse)),i!==null&&o.splice(i,1)),n!==null&&o.push(n),o}static getNormalizedType(t){switch(t){case"boolean":case"java.lang.Boolean":case re.dataType.BOOLEAN:return re.dataType.BOOLEAN;case"char":case"java.lang.Character":case re.dataType.CHAR:return re.dataType.CHAR;case"java.lang.String":case re.dataType.STRING:return re.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 re.dataType.DATETIME:return re.dataType.DATETIME;case"double":case"java.lang.Double":case"float":case"java.lang.Float":case"java.math.BigDecimal":case re.dataType.DECIMAL:return re.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 re.dataType.INT:return re.dataType.INT;default:return re.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 re.isIntegerType(t)||re.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 re.getNormalizedType(t)===re.getNormalizedType(e)}static makeQuickFilter(t,e,n){const s=e.split("||");let i=null;for(let o=0;o<s.length;o+=1){const l=s[o].split("&&");let a=null;for(let d=0;d<l.length;d+=1){const c=l[d].trim();if(c.length>0){const u=re.makeQuickFilterFromComponent(t,c,n);if(u)a?a=a.and(u):a=u;else throw new Error(`Unable to parse quick filter from text ${e}`)}}i&&a?i=i.or(a):i=a}return i}static makeQuickFilterFromComponent(t,e,n){const{type:s}=t;return re.isNumberType(s)?this.makeQuickNumberFilter(t,e):re.isBooleanType(s)?this.makeQuickBooleanFilter(t,e):n!=null&&re.isDateType(s)?this.makeQuickDateFilter(t,e,n):re.isCharType(s)?this.makeQuickCharFilter(t,e):this.makeQuickTextFilter(t,e)}static makeQuickNumberFilter(t,e){if(e==null)return null;const n=t.filter();let s=null;const o=/\s*(>=|<=|=>|=<|>|<|!=|=|!)?(\s*-\s*)?(\s*\d*(?:,\d{3})*(?:\.\d*)?\s*)?(null|nan|infinity|inf|\u221E)?(.*)/i.exec(e);let r=null,l=null,a=null,d=null,c=null;if(o!==null&&o.length>3&&([,r,l,a,d,c]=o),c!=null&&c.trim().length>0)return null;if(r==null&&(r="="),d!=null){if(!(r==="="||r==="!"||r==="!="))return null;switch(d=d.trim().toLowerCase(),d){case"null":s=n.isNull();break;case"nan":s=I.FilterCondition.invoke("isNaN",n);break;case"infinity":case"inf":case"\u221E":l!=null?s=I.FilterCondition.invoke("isInf",n).and(n.lessThan(I.FilterValue.ofNumber(0))):s=I.FilterCondition.invoke("isInf",n).and(n.greaterThan(I.FilterValue.ofNumber(0)));break}return s!==null&&(r==="!"||r==="!=")&&(s=s.not()),s}if(a==null)return null;if(a=re.removeCommas(a),re.isLongType(t.type))try{a=I.FilterValue.ofNumber(I.LongWrapper.ofString(`${l!=null?"-":""}${a}`))}catch(u){return qn.warn("Unable to create long filter",u),null}else{if(a=parseFloat(a),a==null||Number.isNaN(a))return null;a=I.FilterValue.ofNumber(l!=null?0-a:a)}return s=t.filter(),re.makeRangeFilterWithOperation(s,r,a)}static makeQuickTextFilter(t,e){if(e==null)return null;const n=`${e}`.trim(),i=/^(!~|!=|~|=|!)?(.*)/.exec(n);let o=null,r=null;if(i!==null&&i.length>2&&([,o,r]=i,r!=null&&(r=r.trim())),r==null||r.length===0)return null;o==null&&(o="=");const l=t.filter();if(r.toLowerCase()==="null")switch(o){case"=":return l.isNull();case"!=":case"!":return l.isNull().not()}let a=null,d=null;switch(r.startsWith("*")?(a="*",r=r.substring(1)):r.endsWith("*")&&!r.endsWith("\\*")&&(d="*",r=r.substring(0,r.length-1)),r=r.replace("\\",""),o){case"~":return l.isNull().not().and(l.invoke("matches",I.FilterValue.ofString(`(?s)(?i).*\\Q${r}\\E.*`)));case"!~":return l.isNull().or(l.invoke("matches",I.FilterValue.ofString(`(?s)(?i).*\\Q${r}\\E.*`)).not());case"!=":return a==="*"?l.isNull().or(l.invoke("matches",I.FilterValue.ofString(`(?s)(?i).*\\Q${r}\\E$`)).not()):d==="*"?l.isNull().or(l.invoke("matches",I.FilterValue.ofString(`(?s)(?i)^\\Q${r}\\E.*`)).not()):l.notEqIgnoreCase(I.FilterValue.ofString(r.toLowerCase()));case"=":return a==="*"?l.isNull().not().and(l.invoke("matches",I.FilterValue.ofString(`(?s)(?i).*\\Q${r}\\E$`))):d==="*"?l.isNull().not().and(l.invoke("matches",I.FilterValue.ofString(`(?s)(?i)^\\Q${r}\\E.*`))):l.eqIgnoreCase(I.FilterValue.ofString(r.toLowerCase()))}return null}static makeQuickBooleanFilter(t,e){if(e==null)return null;const s=/^(!=|=|!)?(.*)/.exec(`${e}`.trim());if(s===null)return null;const[,i,o]=s,r=i==="!"||i==="!=",l=o.trim().toLowerCase();let a=t.filter();try{const d=re.makeBooleanValue(l);return d!=null&&d?a=a.isTrue():d===null?a=a.isNull():a=a.isFalse(),r?a.not():a}catch{return null}}static makeQuickDateFilter(t,e,n){const s=e.trim(),o=/\s*(>=|<=|=>|=<|>|<|!=|!|=)?(.*)/.exec(s);if(o==null||o.length<=2)throw new Error(`Unable to parse date filter: ${e}`);let r=null,l=null;[,r,l]=o;let a=$.eq;switch(r){case"<":a=$.lessThan;break;case"<=":case"=<":a=$.lessThanOrEqualTo;break;case">":a=$.greaterThan;break;case">=":case"=>":a=$.greaterThanOrEqualTo;break;case"!=":case"!":a=$.notEq;break;case"=":case"==":default:a=$.eq;break}return re.makeQuickDateFilterWithOperation(t,l,a,n)}static makeQuickDateFilterWithOperation(t,e,n,s){if(t==null)throw new Error("Column is null");const[i,o]=vn.parseDateRange(e,s),r=i!=null?I.FilterValue.ofNumber(i):null,l=o!=null?I.FilterValue.ofNumber(o):null,a=t.filter();if(r==null)return n===$.notEq?a.isNull().not():a.isNull();switch(n){case $.eq:{if(l!=null){const d=a.greaterThanOrEqualTo(r),c=a.lessThan(l);return d.and(c)}return a.eq(r)}case $.lessThan:return a.lessThan(r);case $.lessThanOrEqualTo:return l!=null?a.lessThan(l):a.lessThanOrEqualTo(r);case $.greaterThan:return l!=null?a.greaterThanOrEqualTo(l):a.greaterThan(r);case $.greaterThanOrEqualTo:return a.greaterThanOrEqualTo(r);case $.notEq:{if(l!=null){const d=a.lessThan(r),c=a.greaterThanOrEqualTo(l);return d.or(c)}return a.notEq(r)}default:throw new Error(`Invalid operator: ${n}`)}}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 makeQuickCharFilter(t,e){if(e==null)return null;const n=`${e}`.trim(),i=/^(>=|<=|=>|=<|>|<|!=|=|!)?(null|"."|'.'|.)?(.*)/.exec(n);let o=null,r=null,l=null;if(i!==null&&i.length>3&&([,o,r,l]=i),l!=null&&l.trim().length>0||r==null||r.length===0)return null;o==null&&(o="=");const a=t.filter();if(r.toLowerCase()==="null")switch(o){case"=":return a.isNull();case"!=":case"!":return a.isNull().not();default:return null}const d=I.FilterValue.ofString(re.isRangeOperation(o)?re.quoteValue(r):r);return re.makeRangeFilterWithOperation(a,o,d)}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 ye.makeCancelable(t,e=>{e.close()})}static makeCancelableTableEventPromise(t,e,n=0,s=null){let i,o,r=!0;const l=new Promise((a,d)=>{o=setTimeout(()=>{i(),r=!1,d(new fg(`Event "${e}" timed out.`))},n),i=t.addEventListener(e,c=>{if(s!=null&&!s(c)){qn.debug2("Event triggered, but matcher returned false.");return}qn.debug2("Event triggered, resolving."),i(),clearTimeout(o),r=!1,a(c)})});return l.cancel=()=>{if(r){qn.debug2("Pending promise cleanup."),i(),clearTimeout(o),r=!1;return}qn.debug2("Ignoring non-pending promise cancel.")},l}static makeAdvancedFilter(t,e,n){const{filterItems:s,filterOperators:i,invertSelection:o,selectedValues:r}=e;let l=null;for(let d=0;d<s.length;d+=1){const c=s[d],{selectedType:u,value:m}=c;if(u!=null&&u.length>0&&m!=null&&m.length>0)try{const p=re.makeAdvancedValueFilter(t,u,m,n);if(p!=null){if(d===0)l=p;else if(l!==null&&d-1<i.length){const g=i[d-1];if(g===zt.and)l=l.and(p);else if(g===zt.or)l=l.or(p);else{qn.error("Unexpected filter operator",g,p),l=null;break}}}else qn.debug2("Empty filter ignored for",u,m)}catch(p){qn.error("Unable to create filter",p),l=null;break}}const a=re.makeSelectValueFilter(t,r,o);return a!=null&&(l!=null?l=l.and(a):l=a),l}static removeCommas(t){return t.replace(/[\s|,]/g,"")}static makeFilterValue(t,e){const n=re.getBaseType(t);return re.isTextType(n)?I.FilterValue.ofString(e):re.isLongType(n)?I.FilterValue.ofNumber(I.LongWrapper.ofString(re.removeCommas(e))):I.FilterValue.ofNumber(re.removeCommas(e))}static makeFilterRawValue(t,e){return re.isTextType(t)?I.FilterValue.ofString(e):re.isBooleanType(t)?I.FilterValue.ofBoolean(e):I.FilterValue.ofNumber(e)}static makeValue(t,e,n){if(e==null||e==="null")return null;if(re.isTextType(t))return e;if(re.isLongType(t))return I.LongWrapper.ofString(re.removeCommas(e));if(re.isBooleanType(t))return re.makeBooleanValue(e,!0);if(re.isDateType(t)){const[s]=vn.parseDateRange(e,n);return s}return re.isNumberType(t)?re.makeNumberValue(e):(qn.error("Unexpected column type",t),null)}static makeBooleanValue(t,e=!1){if(t===""&&e)return null;switch(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==="null"||t==="")return null;const e=t.toLowerCase().trim();if(e==="\u221E"||e==="infinity"||e==="inf")return Number.POSITIVE_INFINITY;if(e==="-\u221E"||e==="-infinity"||e==="-inf")return Number.NEGATIVE_INFINITY;const n=re.removeCommas(e);if(re.NUMBER_REGEX.test(n))return parseFloat(n);throw new Error(`Invalid number '${t}'`)}static getFilterOperatorString(t){switch(t){case $.eq:return"=";case $.notEq:return"!=";case $.greaterThan:return">";case $.greaterThanOrEqualTo:return">=";case $.lessThan:return"<";case $.lessThanOrEqualTo:return"<=";case $.contains:return"~";case $.notContains:return"!~";default:throw new Error(`Unexpected filter type ${t}`)}}static makeAdvancedValueFilter(t,e,n,s){if(re.isDateType(t.type))return re.makeQuickDateFilterWithOperation(t,n,e,s);if(re.isNumberType(t.type)||re.isCharType(t.type))return re.makeQuickFilter(t,`${re.getFilterOperatorString(e)}${n}`);const i=re.makeFilterValue(t.type,n),o=t.filter();switch(e){case $.eq:return o.eq(i);case $.eqIgnoreCase:return o.eqIgnoreCase(i);case $.notEq:return o.notEq(i);case $.notEqIgnoreCase:return o.notEqIgnoreCase(i);case $.greaterThan:return o.greaterThan(i);case $.greaterThanOrEqualTo:return o.greaterThanOrEqualTo(i);case $.lessThan:return o.lessThan(i);case $.lessThanOrEqualTo:return o.lessThanOrEqualTo(i);case $.isTrue:return o.isTrue();case $.isFalse:return o.isFalse();case $.isNull:return o.isNull();case $.contains:return o.isNull().not().and(o.invoke("matches",I.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E.*`)));case $.notContains:return o.isNull().or(o.invoke("matches",I.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E.*`)).not());case $.startsWith:return o.isNull().not().and(o.invoke("matches",I.FilterValue.ofString(`(?s)(?i)^\\Q${n}\\E.*`)));case $.endsWith:return o.isNull().not().and(o.invoke("matches",I.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E$`)));case $.in:case $.inIgnoreCase:case $.notIn:case $.notInIgnoreCase:case $.invoke:default:throw new Error(`Unexpected filter operation: ${e}`)}}static makeSelectValueFilter(t,e,n){if(e.length===0){if(n)return null;let o=null;re.isTextType(t.type)?o=I.FilterValue.ofString("a"):re.isBooleanType(t.type)?o=I.FilterValue.ofBoolean(!0):re.isDateType(t.type)?o=I.FilterValue.ofNumber(I.DateWrapper.ofJsDate(new Date)):o=I.FilterValue.ofNumber(0);const r=t.filter().eq(o),l=t.filter().notEq(o);return r.and(l)}const s=[];let i=!1;for(let o=0;o<e.length;o+=1){const r=e[o];r==null?i=!0:re.isTextType(t.type)?s.push(I.FilterValue.ofString(typeof r=="number"?String.fromCharCode(r):r)):re.isBooleanType(t.type)?s.push(I.FilterValue.ofBoolean(Boolean(r))):s.push(I.FilterValue.ofNumber(r))}return i?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)}static isTreeTable(t){return t!=null&&t.expand!==void 0&&t.collapse!==void 0}static sortColumns(t,e=!0){return[...t].sort((n,s)=>{const i=n.name.toUpperCase(),o=s.name.toUpperCase();return jt.sort(i,o,e)})}};let N=re;N.dataType={BOOLEAN:"boolean",CHAR:"char",DATETIME:"datetime",DECIMAL:"decimal",INT:"int",STRING:"string",UNKNOWN:"unknown"};N.sortDirection={ascending:"ASC",descending:"DESC",reverse:"REVERSE",none:null};N.REVERSE_TYPE=Object.freeze({NONE:"none",PRE_SORT:"pre-sort",POST_SORT:"post-sort"});N.NUMBER_REGEX=/^-?\d+(\.\d+)?$/;class nn{static makeColumnFormatMap(e){return e==null?new Map:e.reduce((n,s)=>{const i=N.getNormalizedType(s.columnType);return i===null||(n.has(i)||n.set(i,new Map),n.get(i)?.set(s.columnName,s.format)),n},new Map)}static makeColumnFormattingRule(e,n,s){return{columnType:e,columnName:n,format:s}}constructor(e=[],n,s,i,o=!1){this.defaultColumnFormatter=new AC,this.typeFormatterMap=new Map([[N.dataType.BOOLEAN,new kC],[N.dataType.CHAR,new xC],[N.dataType.DATETIME,new st(n)],[N.dataType.DECIMAL,new ke(s)],[N.dataType.INT,new Ze(i)],[N.dataType.STRING,new PC]]),this.columnFormatMap=nn.makeColumnFormatMap(e),this.truncateNumbersWithPound=o}getColumnFormatMapForType(e,n=!1){const s=N.getNormalizedType(e);if(s!==null)return n&&!this.columnFormatMap.has(s)&&this.columnFormatMap.set(s,new Map),this.columnFormatMap.get(s)}getColumnFormat(e,n){return this.getColumnFormatMapForType(e)?.get(n)??null}getColumnTypeFormatter(e){const n=N.getNormalizedType(e);let s=this.defaultColumnFormatter;return n&&(s=this.typeFormatterMap.get(n)??s),s}getFormattedString(e,n,s="",i){if(e==null)return"";const o=this.getColumnTypeFormatter(n),r=i||this.getColumnFormat(n,s);return o.format(e,r??void 0)}get timeZone(){return this.typeFormatterMap.get(N.dataType.DATETIME)?.dhTimeZone?.id}}function VC(t){if(t&&t.formatter){const{formatter:e}=t;return e}}function BC(t){return{timeZone:t?.timeZone,defaultDateTimeFormatString:t?.defaultDateTimeFormat,showTimeZone:t?.showTimeZone,showTSeparator:t?.showTSeparator}}function $C(t,e,n){const s=t.getColumnFormat(n,e);return s!=null&&(s.type===nt.TYPE_CONTEXT_PRESET||s.type===nt.TYPE_CONTEXT_CUSTOM)}const rs={getColumnFormats:VC,getDateTimeFormatterOptions:BC,isCustomColumnFormatDefined:$C};Ar.register([Tf,vf,Ef,yf,Rf,If]);const su=typeof $l=="function"?$l(Ar):$l.default(Ar),jn=class{constructor(){this.listeners=[],this.isDownsamplingDisabled=!1}getData(){return[]}getDefaultTitle(){return""}getLayout(){return{}}getFilterColumnMap(){return new Map}isFilterRequired(){return!1}setFilter(t){}close(){}setFormatter(t){this.formatter=t}setDownsamplingDisabled(t){this.isDownsamplingDisabled=t}setDimensions(t){this.rect=t}setTitle(t){this.title=t}subscribe(t){this.listeners.push(t)}unsubscribe(t){this.listeners=this.listeners.filter(e=>e!==t)}fireEvent(t){for(let e=0;e<this.listeners.length;e+=1)this.listeners[e](t)}fireUpdate(t){this.fireEvent(new CustomEvent(jn.EVENT_UPDATED,{detail:t}))}fireDisconnect(){this.fireEvent(new CustomEvent(jn.EVENT_DISCONNECT))}fireReconnect(){this.fireEvent(new CustomEvent(jn.EVENT_RECONNECT))}fireDownsampleStart(t){this.fireEvent(new CustomEvent(jn.EVENT_DOWNSAMPLESTARTED,{detail:t}))}fireDownsampleFinish(t){this.fireEvent(new CustomEvent(jn.EVENT_DOWNSAMPLEFINISHED,{detail:t}))}fireDownsampleFail(t){this.fireEvent(new CustomEvent(jn.EVENT_DOWNSAMPLEFAILED,{detail:t}))}fireDownsampleNeeded(t){this.fireEvent(new CustomEvent(jn.EVENT_DOWNSAMPLENEEDED,{detail:t}))}fireLoadFinished(){this.fireEvent(new CustomEvent(jn.EVENT_LOADFINISHED))}};let bt=jn;bt.EVENT_UPDATED="ChartModel.EVENT_UPDATED";bt.EVENT_DISCONNECT="ChartModel.EVENT_DISCONNECT";bt.EVENT_RECONNECT="ChartModel.EVENT_RECONNECT";bt.EVENT_DOWNSAMPLESTARTED="ChartModel.EVENT_DOWNSAMPLESTARTED";bt.EVENT_DOWNSAMPLEFINISHED="ChartModel.EVENT_DOWNSAMPLEFINISHED";bt.EVENT_DOWNSAMPLEFAILED="ChartModel.EVENT_DOWNSAMPLEFAILED";bt.EVENT_DOWNSAMPLENEEDED="ChartModel.EVENT_DOWNSAMPLENEEDED";bt.EVENT_LOADFINISHED="ChartModel.EVENT_LOADFINISHED";const GC="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",WC="#403e41",zC="#5b5a5c",qC="#c0bfbf",YC="#4878ea",KC="rgba(91, 90, 92, 0.7)",It={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:GC,gridcolor:WC,linecolor:zC,zerolinecolor:qC,activecolor:YC,rangebgcolor:KC,"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"},Gt=Object.freeze({paper_bgcolor:It["paper-bgcolor"],plot_bgcolor:It["plot-bgcolor"],title_color:It["title-color"],colorway:It.colorway,gridcolor:It.gridcolor,linecolor:It.linecolor,zerolinecolor:It.zerolinecolor,activecolor:It.activecolor,rangebgcolor:It.rangebgcolor,area_color:It["area-color"],trend_color:It["trend-color"],line_color:It["line-color"],error_band_line_color:It["error-band-line-color"],error_band_fill_color:It["error-band-fill-color"],ohlc_increasing:It["ohlc-increasing"],ohlc_decreasing:It["ohlc-decreasing"]}),io=ee.module("ChartUtils"),fs=Object.freeze(I.calendar.DayOfWeek.values()),pc="io.deephaven.time.DateTime",XC=36e5,jC=1e6;function ZC(t){return t.asDate!==void 0}function QC(t){return t.asNumber!==void 0}function gc(t){return t.dhTimeZone!==void 0}function JC(t){return t!=null&&t.range!=null&&(t.autorange===!1||t.autorange===void 0)}const oe=class{static getPlotlyChartType(t,e){switch(t){case I.plot.SeriesPlotStyle.SCATTER:return e?"scatter":"scattergl";case I.plot.SeriesPlotStyle.LINE:return"scatter";case I.plot.SeriesPlotStyle.BAR:case I.plot.SeriesPlotStyle.STACKED_BAR:return"bar";case I.plot.SeriesPlotStyle.PIE:return"pie";case I.plot.SeriesPlotStyle.TREEMAP:return"treemap";case I.plot.SeriesPlotStyle.HISTOGRAM:return"histogram";case I.plot.SeriesPlotStyle.OHLC:return"ohlc";default:return}}static getPlotlyChartMode(t,e,n){const s=new Set;switch(t){case I.plot.SeriesPlotStyle.SCATTER:(e??!1)&&s.add(oe.MODE_LINES),(n??!0)&&s.add(oe.MODE_MARKERS);break;case I.plot.SeriesPlotStyle.LINE:(e??!0)&&s.add(oe.MODE_LINES),(n??!1)&&s.add(oe.MODE_MARKERS);break}return s.size>0?[...s].join("+"):void 0}static getPlotlyProperty(t,e){switch(t){case I.plot.SeriesPlotStyle.PIE:switch(e){case I.plot.SourceType.X:return"labels";case I.plot.SourceType.Y:return"values"}break;case I.plot.SeriesPlotStyle.OHLC:switch(e){case I.plot.SourceType.TIME:return"x"}break;case I.plot.SeriesPlotStyle.TREEMAP:switch(e){case I.plot.SourceType.X:return"ids";case I.plot.SourceType.Y:return"values";case I.plot.SourceType.LABEL:return"labels";case I.plot.SourceType.PARENT:return"parents";case I.plot.SourceType.COLOR:return"marker.colors"}break}switch(e){case I.plot.SourceType.X:return"x";case I.plot.SourceType.Y:return"y";case I.plot.SourceType.Z:return"z";case I.plot.SourceType.X_LOW:return"xLow";case I.plot.SourceType.X_HIGH:return"xHigh";case I.plot.SourceType.Y_LOW:return"yLow";case I.plot.SourceType.Y_HIGH:return"yHigh";case I.plot.SourceType.TIME:return"time";case I.plot.SourceType.OPEN:return"open";case I.plot.SourceType.HIGH:return"high";case I.plot.SourceType.LOW:return"low";case I.plot.SourceType.CLOSE:return"close";case I.plot.SourceType.SHAPE:return"shape";case I.plot.SourceType.SIZE:return"size";case I.plot.SourceType.LABEL:return"label";case I.plot.SourceType.COLOR:return"color";case I.plot.SourceType.PARENT:return"parent";case I.plot.SourceType.HOVER_TEXT:return"hovertext";case I.plot.SourceType.TEXT:return"text";default:throw new Error(`Unrecognized source type: ${e}`)}}static getPlotlySeriesOrientation(t){const{sources:e}=t;return e.length===2&&e[0]?.axis?.type===I.plot.AxisType.Y?oe.ORIENTATION.HORIZONTAL:oe.ORIENTATION.VERTICAL}static getPlotlyErrorBars(t,e,n){const s=n.map((o,r)=>o-t[r]),i=e.map((o,r)=>t[r]-o);return{type:"data",symmetric:!1,array:s,arrayminus:i}}static getPlotlyDateFormat(t,e,n){const s=n?.replace("%","%%").replace(/S{9}/g,"%9f").replace(/S{8}/g,"%8f").replace(/S{7}/g,"%7f").replace(/S{6}/g,"%6f").replace(/S{5}/g,"%5f").replace(/S{4}/g,"%4f").replace(/S{3}/g,"%3f").replace(/S{2}/g,"%2f").replace(/S{1}/g,"%1f").replace(/y{4}/g,"%Y").replace(/y{2}/g,"%y").replace(/M{4}/g,"%B").replace(/M{3}/g,"%b").replace(/M{2}/g,"%m").replace(/M{1}/g,"%-m").replace(/E{4,}/g,"%A").replace(/E{1,}/g,"%a").replace(/d{2}/g,"%d").replace(/([^%]|^)d{1}/g,"$1%-d").replace(/H{2}/g,"%H").replace(/h{2}/g,"%I").replace(/h{1}/g,"%-I").replace(/m{2}/g,"%M").replace(/s{2}/g,"%S").replace("'T'","T").replace(" z","");let i;const o=t?.getColumnTypeFormatter(e);return o!=null&&gc(o)&&o.dhTimeZone!=null&&o.showTimeZone&&(i=I.i18n.DateTimeFormat.format(" z",new Date,o.dhTimeZone)),{tickformat:s,ticksuffix:i,automargin:!0}}static convertNumberPrefix(t){return t.replace(/\u00A4\u00A4/g,"USD").replace(/\u00A4/g,"$")}static getPlotlyNumberFormat(t,e,n){if(!n)return null;const i=n.split(";")[0].match(/^([^#,0.]*)([#,]*)([0,]*)(\.?)(0*)(#*)(E?0*)(%?)(.*)/);k(i);const[,o,r,l,,a,d,c,u,m]=i,p=l.replace(",","").length,f=r.indexOf(",")>=0||l.indexOf(",")>=0?",":"",C=c!=null&&c!==""?"e":"f",S=u!==""?u:C,w=a.length+d.length,y=`0${p}${f}.${w}${S}`,E=oe.convertNumberPrefix(o),R=oe.convertNumberPrefix(m);return{tickformat:y,tickprefix:E,ticksuffix:R,automargin:!0}}static getPlotlyAxisFormat(t,e=null){const{axis:n,columnType:s}=t,{formatPattern:i}=n;let o=null;return N.isDateType(s)?(o=oe.getPlotlyDateFormat(e,s,i),o=oe.addTickSpacing(o,n,!0)):N.isNumberType(s)&&(o=oe.getPlotlyNumberFormat(e,s,i),o=oe.addTickSpacing(o,n,!1)),n.formatType===I.plot.AxisFormatType.CATEGORY&&(o?o.type="category":o={type:"category",tickformat:void 0,ticksuffix:void 0}),o}static addTickSpacing(t,e,n){const{gapBetweenMajorTicks:s}=e;if(s>0){const i=t||{};let o=s;return n&&(o=s/jC),e.log&&(o=Math.log(o)),i.tickmode="linear",i.dtick=o,i}return t}static getSourceForAxis(t,e){for(let n=0;n<t.series.length;n+=1){const s=t.series[n];for(let i=0;i<s.sources.length;i+=1){const o=s.sources[i];if(o.axis===e)return o}}return null}static getSeriesVisibility(t,e){return e!=null&&e.hiddenSeries!=null&&e.hiddenSeries.includes(t)?"legendonly":!0}static getHiddenLabels(t){return t?.hiddenSeries?[...t.hiddenSeries]:[]}static makeSeriesData(t,e,n,s,i=oe.ORIENTATION.VERTICAL){return{type:t,mode:e,name:n,orientation:i,showlegend:s??void 0}}static makeSeriesDataFromSeries(t,e,n,s=null,i=Gt){const{name:o,isLinesVisible:r,isShapesVisible:l,plotStyle:a,lineColor:d,shapeColor:c,sources:u,shape:m,shapeSize:p}=t,g=u.some(T=>T.axis?.businessCalendar),f=oe.getChartType(a,g),C=oe.getPlotlyChartMode(a,r??void 0,l??void 0),S=oe.getPlotlySeriesOrientation(t),w=oe.makeSeriesData(f,C,o,s,S);return oe.addSourcesToSeriesData(w,a,u,e),oe.addStylingToSeriesData(w,a,i,d,c,m,p,n),w}static addSourcesToSeriesData(t,e,n,s){const i=t;for(let o=0;o<n.length;o+=1){const r=n[o],{axis:l,type:a}=r,d=oe.getPlotlyProperty(e,a);mh(i,d,[]);const c=l!=null?oe.getAxisPropertyName(l.type):null;if(c!=null){const u=s.get(l.type);if(u){const m=u.indexOf(l),p=m>0?`${m+1}`:"";i[`${c}axis`]=`${c}${p}`}}}}static addStylingToSeriesData(t,e,n=Gt,s=null,i=null,o=null,r=null,l=null){const a=t;if(a.marker={line:{}},a.line={width:1},e===I.plot.SeriesPlotStyle.AREA?a.fill="tozeroy":e===I.plot.SeriesPlotStyle.STACKED_AREA?a.stackgroup="stack":e===I.plot.SeriesPlotStyle.STEP?a.line.shape="hv":e===I.plot.SeriesPlotStyle.HISTOGRAM?(a.width=[],a.marker.line!==void 0&&Object.assign(a.marker.line,{color:n.paper_bgcolor,width:1})):e===I.plot.SeriesPlotStyle.OHLC?(a.increasing={line:{color:n.ohlc_increasing}},a.decreasing={line:{color:n.ohlc_decreasing}}):e===I.plot.SeriesPlotStyle.PIE?(a.textinfo="label+percent",a.outsidetextfont={color:n.title_color}):e===I.plot.SeriesPlotStyle.TREEMAP&&(a.hoverinfo="text",a.textinfo="label+text",a.tiling={packing:"squarify",pad:0},a.textposition="middle center",a.outsidetextfont={color:n.title_color}),s!=null&&(e===I.plot.SeriesPlotStyle.BAR?a.marker.color=s:a.line.color=s),i!=null&&(a.marker.color=i),o!=null&&o.length>0)try{a.marker.symbol=oe.getMarkerSymbol(o)}catch(d){io.warn("Unable to handle shape",o,":",d)}r!=null&&(a.marker.size=r*oe.DEFAULT_MARKER_SIZE),l!=null&&e!==I.plot.SeriesPlotStyle.PIE&&(a.visible=l)}static getMarkerSymbol(t){switch(t){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 ${t}`)}}static getAxisFormats(t,e){const n=new Map,s={tickformat:null,ticksuffix:null},i=oe.getAllAxes(t),o=oe.groupArray(i,"type"),{charts:r}=t;for(let l=0;l<r.length;l+=1){const a=r[l];for(let d=0;d<a.series.length;d+=1){const c=a.series[d],{sources:u}=c,m=u.filter(p=>p.axis);for(let p=0;p<m.length;p+=1){const g=m[p],{axis:f}=g,{type:C}=f,S=o.get(C);k(S);const w=S.indexOf(f),T=oe.getAxisPropertyName(C);if(T!=null){const y=oe.getAxisLayoutProperty(T,w);if(n.has(y))io.debug(`${y} already added.`);else{io.debug(`Adding ${y} to axisFormats.`);const E=oe.getPlotlyAxisFormat(g,e);if(E===null)n.set(y,s);else{n.set(y,E);const{businessCalendar:R}=f;if(R!=null){const F=[],{businessPeriods:D,businessDays:_,holidays:H,timeZone:U}=R,A=e?.getColumnTypeFormatter(pc);let Y;gc(A)&&(Y=A.dhTimeZone);const G=Y?(U.standardOffset-Y.standardOffset)/60:0;H.length>0&&F.push(...oe.createRangeBreakValuesFromHolidays(H,U,Y)),D.forEach(z=>F.push({pattern:"hour",bounds:[oe.periodToDecimal(z.close)+G,oe.periodToDecimal(z.open)+G]})),_.length<fs.length&&oe.createBoundsFromDays(_).forEach(z=>F.push({pattern:"day of week",bounds:z})),E.rangebreaks=F}if(n.size===a.axes.length)return n}}}}}}return n}static getChartType(t,e){switch(t){case I.plot.SeriesPlotStyle.HISTOGRAM:return"bar";default:return oe.getPlotlyChartType(t,e)}}static getAxisPropertyName(t){switch(t){case I.plot.AxisType.X:return"x";case I.plot.AxisType.Y:return"y";default:return null}}static getAxisSide(t){switch(t){case I.plot.AxisPosition.BOTTOM:return"bottom";case I.plot.AxisPosition.TOP:return"top";case I.plot.AxisPosition.LEFT:return"left";case I.plot.AxisPosition.RIGHT:return"right";default:return}}static getAllAxes(t){return t.charts.reduce((e,n)=>[...e,...n.axes],[])}static getChartForSeries(t,e){const{charts:n}=t;for(let s=0;s<n.length;s+=1){const i=n[s];for(let o=0;o<i.series.length;o+=1)if(e===i.series[o])return i}return null}static getLayoutRanges(t){const e={},n=Object.keys(t).filter(s=>s.indexOf("axis")>=0);for(let s=0;s<n.length;s+=1){const i=n[s],o=t[i];JC(o)&&(e[i]=[...o.range])}return e}static updateFigureAxes(t,e,n,s=0,i=0,o=Gt){const r=t,l=oe.getAllAxes(e);for(let a=0;a<e.charts.length;a+=1){const d=e.charts[a],c=n?.(d),u=oe.getChartBounds(e,d,s,i);oe.updateLayoutAxes(r,d.axes,l,s,i,u,c,o)}oe.removeStaleAxes(r,l)}static getChartBounds(t,e,n,s){const{cols:i,rows:o}=t,{column:r,colspan:l,row:a,rowspan:d}=e,c=r+l,u=a+d,m=1/i,p=1/o,g=oe.AXIS_SIZE_PX/n,f=oe.AXIS_SIZE_PX/s,C={bottom:(o-u)*p+(u<o?f/2:0),top:(o-a)*p-(a>0?f/2:0),left:r*m+(r>0?g/2:0),right:c*m-(c<i?g/2:0)};return(oe.groupArray(e.axes,"position").get(I.plot.AxisPosition.RIGHT)??[]).length>0&&(n>0?C.right-=(C.right-C.left)*Math.max(0,Math.min(oe.LEGEND_WIDTH_PX/n,oe.MAX_LEGEND_SIZE)):C.right-=(C.right-C.left)*oe.DEFAULT_AXIS_SIZE),C}static updateLayoutAxes(t,e,n,s=0,i=0,o={left:0,top:0,right:1,bottom:1},r,l=Gt){const a=s>0?Math.max(oe.MIN_AXIS_SIZE,Math.min(oe.AXIS_SIZE_PX/i,oe.MAX_AXIS_SIZE)):oe.DEFAULT_AXIS_SIZE,d=i>0?Math.max(oe.MIN_AXIS_SIZE,Math.min(oe.AXIS_SIZE_PX/s,oe.MAX_AXIS_SIZE)):oe.DEFAULT_AXIS_SIZE,c=t,u=oe.groupArray(e,"position"),m=oe.groupArray(e,"type"),p=[...m.keys()],g=oe.groupArray(n,"type");for(let f=0;f<p.length;f+=1){const C=p[f],S=oe.getAxisPropertyName(C);if(S!=null){const w=m.get(C),T=g.get(C),E=C===I.plot.AxisType.Y?i:s;k(w),k(T);for(let R=0;R<w.length;R+=1){const F=w[R],D=T.indexOf(F),_=oe.getAxisLayoutProperty(S,D);c[_]==null&&(c[_]=oe.makeLayoutAxis(C,l));const H=c[_];if(H!=null){oe.updateLayoutAxis(H,F,R,u,a,d,o);const{range:U,autorange:A}=H;if(r!=null&&U!==void 0&&(A===void 0||A===!1)){const Y=r(F),[G,z]=Y(U);io.debug("Setting downsample range",E,G,z),F.range(E,G,z)}else F.range(E)}}}}}static removeStaleAxes(t,e){const n=t,s=oe.groupArray(e,"type"),i=[...s.keys()];for(let o=0;o<i.length;o+=1){const r=i[o],l=s.get(r);k(l);let a=l.length;const d=oe.getAxisPropertyName(r);if(d!=null){let c=oe.getAxisLayoutProperty(d,a);for(;n[c]!=null;)delete n[c],a+=1,c=oe.getAxisLayoutProperty(d,a)}}}static getAxisLayoutProperty(t,e){const n=e>0?`${e+1}`:"";return`${t??""}axis${n}`}static updateLayoutAxis(t,e,n,s,i,o,r){const a=e.type===I.plot.AxisType.Y?o:i,d=t,c=e.label??"";if(d.title!==void 0&&typeof d.title!="string"?d.title.text=c:d.title={text:c},e.log&&(d.type="log"),d.side=oe.getAxisSide(e.position),n>0){d.overlaying=oe.getAxisPropertyName(e.type)??void 0;const u=s.get(e.position)??[],m=u.indexOf(e);m>0&&(d.anchor="free",e.position===I.plot.AxisPosition.RIGHT?d.position=r.right+(m-u.length+1)*a:e.position===I.plot.AxisPosition.TOP?d.position=r.top+(m-u.length+1)*a:e.position===I.plot.AxisPosition.BOTTOM?d.position=r.bottom+(u.length-m+1)*a:e.position===I.plot.AxisPosition.LEFT&&(d.position=r.left+(u.length-m+1)*a))}else if(e.type===I.plot.AxisType.X){const u=s.get(I.plot.AxisPosition.LEFT)||[],m=s.get(I.plot.AxisPosition.RIGHT)||[],p=Math.max(r.left,r.left+(u.length-1)*o),g=Math.min(r.right-(m.length-1)*o,r.right);d.domain=[p,g]}else if(e.type===I.plot.AxisType.Y){const u=s.get(I.plot.AxisPosition.BOTTOM)||[],m=s.get(I.plot.AxisPosition.TOP)||[],p=Math.max(r.bottom,r.bottom+(u.length-1)*i),g=Math.min(r.top-(m.length-1)*i,r.top);d.domain=[p,g]}}static periodToDecimal(t){const e=t.split(":");return Number(e[0])+Number(e[1])/60}static createBoundsFromDays(t){const e=t.map(o=>fs.indexOf(o)),n=fs.filter(o=>!t.includes(o)).map(o=>fs.indexOf(o)),s=new Set;n.forEach(o=>{for(let r=o+1;r<o+fs.length;r+=1){const l=r%fs.length;if(e.includes(l)){s.add(l);break}}});const i=[];return s.forEach(o=>{for(let r=o-1;r>o-fs.length;r-=1){const l=r<0?r+fs.length:r;if(e.includes(l)){const a=(l+1)%7;i.push([a,o]);break}}}),i}static createRangeBreakValuesFromHolidays(t,e,n){const s=[],i=[];return t.forEach(o=>{o.businessPeriods.length>0?i.push(...oe.createPartialHoliday(o,e,n)):s.push(oe.createFullHoliday(o,e,n))}),[{values:s},...i]}static createFullHoliday(t,e,n){return oe.adjustDateForTimeZone(`${t.date.toString()} 00:00:00.000000`,e,n)}static createPartialHoliday(t,e,n){const s=t.date.toString(),i=["00:00"];t.businessPeriods.forEach(r=>{i.push(r.open),i.push(r.close)}),i.push("24:00");const o=[];for(let r=0;r<i.length;r+=2){const l=i[r],a=i[r+1];if(l!==a){const d=[oe.adjustDateForTimeZone(`${s} ${l}:00.000000`,e,n)],c=XC*(oe.periodToDecimal(a)-oe.periodToDecimal(l));o.push({values:d,dvalue:c})}}return o}static adjustDateForTimeZone(t,e,n){return n&&n.standardOffset!==e.standardOffset?oe.unwrapValue(oe.wrapValue(t,pc,e),n):t}static groupArray(t,e){return t.reduce((n,s)=>{const i=s[e],o=n.get(i)??[];return o.push(s),n.set(i,o),n},new Map)}static unwrapValue(t,e){if(t!=null){if(ZC(t))return I.i18n.DateTimeFormat.format(oe.DATE_FORMAT,t,e);if(QC(t))return t.asNumber()}return t}static wrapValue(t,e,n=null){if(N.isDateType(e)&&typeof t=="string"){const s=t,i=oe.DATE_FORMAT.substr(0,t.length),o=I.i18n.DateTimeFormat.parse(i,s);if(!n)return o;const r=`${i} Z`,l=I.i18n.DateTimeFormat.format("Z",o,n),a=I.i18n.DateTimeFormat.parse(r,`${s} ${l}`),d=I.i18n.DateTimeFormat.format("Z",a,n);return I.i18n.DateTimeFormat.parse(r,`${s} ${d}`)}return t}static makeLayoutAxis(t,e=Gt){const n={automargin:!0,gridcolor:e.gridcolor,linecolor:e.linecolor,rangeslider:{visible:!1},showline:!0,ticklen:5,tickcolor:e.paper_bgcolor,tickfont:{color:e.zerolinecolor},title:{font:{color:e.title_color}}};return t===I.plot.AxisType.X?Object.assign(n,{showgrid:!0}):t===I.plot.AxisType.Y&&Object.assign(n,{zerolinecolor:e.zerolinecolor,zerolinewidth:2}),n}static getColorwayFromTheme(t=Gt){let e=[];return t.colorway&&(Array.isArray(t.colorway)?e=t.colorway:typeof t.colorway=="string"?e=t.colorway.split(" "):io.warn(`Unable to handle colorway property: ${t.colorway}`)),e}static makeDefaultLayout(t=Gt){const e={...t,autosize:!0,colorway:oe.getColorwayFromTheme(t),font:{family:"'Fira Sans', sans-serif"},title:{font:{color:t.title_color},yanchor:"top",pad:{...oe.DEFAULT_TITLE_PADDING},y:1},legend:{font:{color:t.title_color}},margin:{...oe.DEFAULT_MARGIN},xaxis:oe.makeLayoutAxis(I.plot.AxisType.X,t),yaxis:oe.makeLayoutAxis(I.plot.AxisType.Y,t)};return e.datarevision=0,e}static hydrateSettings(t){return{...t,type:I.plot.SeriesPlotStyle[t.type]}}static titleFromSettings(t){const{series:e,xAxis:n,title:s=`${e.join(", ")} by ${n}`}=t;return s}static makeFigureSettings(t,e){const{series:n,xAxis:s,type:i}=t,o=oe.titleFromSettings(t),r={formatType:`${I.plot.AxisFormatType.NUMBER}`,type:`${I.plot.AxisType.X}`,position:`${I.plot.AxisPosition.BOTTOM}`},l={formatType:`${I.plot.AxisFormatType.NUMBER}`,type:`${I.plot.AxisType.Y}`,position:`${I.plot.AxisPosition.LEFT}`};return{charts:[{chartType:`${I.plot.ChartType.XY}`,axes:[r,l],series:n.map(a=>({plotStyle:`${i}`,name:a,dataSources:[{type:`${I.plot.SourceType.X}`,columnName:s,axis:r,table:e},{type:`${I.plot.SourceType.Y}`,columnName:a,axis:l,table:e}]}))}],title:o}}};let _e=oe;_e.DEFAULT_AXIS_SIZE=.15;_e.MIN_AXIS_SIZE=.025;_e.MAX_AXIS_SIZE=.2;_e.AXIS_SIZE_PX=75;_e.LEGEND_WIDTH_PX=50;_e.MAX_LEGEND_SIZE=.25;_e.ORIENTATION=Object.freeze({HORIZONTAL:"h",VERTICAL:"v"});_e.DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSS";_e.DEFAULT_MARGIN=Object.freeze({l:60,r:50,t:30,b:60,pad:0});_e.DEFAULT_TITLE_PADDING=Object.freeze({t:8});_e.SUBTITLE_LINE_HEIGHT=25;_e.DEFAULT_MARKER_SIZE=6;_e.MODE_MARKERS="markers";_e.MODE_LINES="lines";const Cs=ee.module("Chart"),fo=class extends b.exports.Component{constructor(t){super(t),this.getCachedConfig=ge((e,n,s,i)=>{const o=[],r=Boolean(e);if(r&&o.push({name:`Downsampling failed: ${e}`,click:()=>{},icon:fo.convertIcon(Eh),attr:"fill-warning"}),n||s||i||r){const l=fo.downsampleButtonTitle(s,i),a=fo.downsampleButtonAttr(s,i),d=s?Cg:Sg;o.push({name:l,icon:fo.convertIcon(d),click:this.handleDownsampleClick,attr:a})}return{displaylogo:!1,displayModeBar:s||r?!0:"hover",modeBarButtons:[o,["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=de.createRef(),this.plotWrapper=de.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(t){const[e,,,,n]=t.icon,s=`${n}`;return{width:e,path:s,ascent:e,descent:0,transform:"matrix(1, 0, 0, 1, 0, 0)"}}static downsampleButtonTitle(t,e){return t?"Downsampling in progress...":e?"Downsampling disabled, click to enable":"Downsampling enabled, click to disable"}static downsampleButtonAttr(t,e){return t?"animation-spin":e?void 0:"fill-active"}componentDidMount(){this.updateDimensions(),this.updateModelDimensions(),this.initData(),this.initFormatter();const{isActive:t}=this.props;t&&this.subscribe()}componentDidUpdate(t){const{isActive:e,settings:n}=this.props;this.updateFormatterSettings(n),e!==t.isActive&&(e?this.subscribe():this.unsubscribe())}componentWillUnmount(){this.unsubscribe()}getPlotRect(){return this.plotWrapper.current?.getBoundingClientRect()??null}initData(){const{model:t}=this.props,{layout:e}=this.state;this.setState({data:t.getData(),layout:{...e,...t.getLayout()}})}subscribe(){if(this.isSubscribed)return;const{model:t}=this.props;if(!this.rect||this.rect.width===0||this.rect.height===0){Cs.debug2("Delaying subscription until model dimensions are set");return}t.subscribe(this.handleModelEvent),this.isSubscribed=!0}unsubscribe(){if(!this.isSubscribed)return;const{model:t}=this.props;t.unsubscribe(this.handleModelEvent),this.isSubscribed=!1}handleAfterPlot(){this.plot.current!=null}handleDownsampleClick(){this.setState(({isDownsamplingDisabled:t})=>({downsamplingError:null,isDownsampleInProgress:!1,isDownsampleFinished:!1,isDownsamplingDisabled:!t}),()=>{const{model:t}=this.props,{isDownsamplingDisabled:e}=this.state;t.setDownsamplingDisabled(e)})}handleModelEvent(t){const{type:e,detail:n}=t;switch(Cs.debug2("Received data update",e,n),e){case bt.EVENT_UPDATED:{this.currentSeries+=1,this.setState(i=>{const{layout:o,revision:r}=i;return typeof o.datarevision=="number"&&(o.datarevision+=1),{data:n,layout:o,revision:r+1}});const{onUpdate:s}=this.props;s({isLoading:!this.isLoadedFired});break}case bt.EVENT_LOADFINISHED:{const{onUpdate:s}=this.props;this.isLoadedFired=!0,s({isLoading:!1});break}case bt.EVENT_DISCONNECT:{const{onDisconnect:s}=this.props;s();break}case bt.EVENT_RECONNECT:{const{onReconnect:s}=this.props;s();break}case bt.EVENT_DOWNSAMPLESTARTED:{this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!0,downsamplingError:null});break}case bt.EVENT_DOWNSAMPLEFINISHED:{this.setState({isDownsampleFinished:!0,isDownsampleInProgress:!1,downsamplingError:null});break}case bt.EVENT_DOWNSAMPLENEEDED:case bt.EVENT_DOWNSAMPLEFAILED:{const s=n.message??n;this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!1,isDownsamplingDisabled:!1,downsamplingError:s});const{onError:i}=this.props;i(new Error(s));break}default:Cs.debug("Unknown event type",e,t)}}handlePlotUpdate(t){const{layout:e}=t,n=_e.getLayoutRanges(e);!ct(n,this.ranges)&&(this.ranges=n,this.updateModelDimensions(!0))}handleRelayout(t){if(Cs.debug("handleRelayout",t),t.hiddenlabels!=null){const{onSettingsChanged:e}=this.props,n=[...t.hiddenlabels];e({hiddenSeries:n})}this.updateModelDimensions()}handleRestyle([t,e]){if(Cs.debug("handleRestyle",t,e),Object.keys(t).includes("visible")){const{data:n}=this.state,{onSettingsChanged:s}=this.props;if(n!=null){const i=n.reduce((o,{name:r,visible:l})=>r!=null&&l==="legendonly"?[...o,r]:o,[]);s({hiddenSeries:i})}}}updateModelDimensions(t=!1){const e=this.getPlotRect();if(!e){Cs.warn("Unable to get plotting rect");return}if(!this.rect||this.rect.width!==e.width||this.rect.height!==e.height||t){this.rect=e;const{isActive:s,model:i}=this.props;i.setDimensions(e),s&&this.subscribe()}}initFormatter(){const{settings:t}=this.props;this.updateFormatterSettings(t)}updateFormatterSettings(t){const e=rs.getColumnFormats(t),n=rs.getDateTimeFormatterOptions(t),{decimalFormatOptions:s={},integerFormatOptions:i={}}=t;(!ct(this.columnFormats,e)||!ct(this.dateTimeFormatterOptions,n)||!ct(this.decimalFormatOptions,s)||!ct(this.integerFormatOptions,i))&&(this.columnFormats=rs.getColumnFormats(t),this.dateTimeFormatterOptions=n,this.decimalFormatOptions=s,this.integerFormatOptions=i,this.updateFormatter())}updateFormatter(){const t=new nn(this.columnFormats,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions),{model:e}=this.props;e.setFormatter(t)}updateDimensions(){const t=this.getPlotRect();this.plot.current!=null&&t!=null&&t.width>0&&t.height>0&&Ar.relayout(this.plot.current.el,{autosize:!0}).catch(e=>{Cs.debug("Unable to resize, promise rejected",e)})}render(){const{data:t,downsamplingError:e,isDownsampleFinished:n,isDownsampleInProgress:s,isDownsamplingDisabled:i,layout:o,revision:r}=this.state,l=this.getCachedConfig(e,n,s,i),a=t!=null;return h("div",{className:"h-100 w-100 chart-wrapper",ref:this.plotWrapper,children:a&&h(su,{ref:this.plot,data:t,layout:o,revision:r,config:l,onAfterPlot:this.handleAfterPlot,onError:Cs.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}};let iu=fo;iu.defaultProps={isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:vn.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}};const kt=ee.module("FigureChartModel"),ou=class extends bt{constructor(t,e={},n=Gt){super(),this.addPendingSeries=Je(()=>{const i=_e.getAllAxes(this.figure),{pendingSeries:o}=this;for(let r=0;r<o.length;r+=1){const l=o[r],a=this.figure.charts.find(d=>d.series.includes(l));this.addSeries(l,i,a?.showLegend??null),l.subscribe()}this.pendingSeries=[]},ou.ADD_SERIES_DEBOUNCE),this.getTimeZone=Ie((i,o)=>{if(o!=null){const r=o.getColumnTypeFormatter(i);if(r!=null)return r.dhTimeZone}}),this.getValueTranslator=Ie((i,o)=>{const r=this.getTimeZone(i,o);return l=>_e.unwrapValue(l,r)}),this.getValueParser=Ie((i,o)=>{const r=this.getTimeZone(i,o);return l=>_e.wrapValue(l,i,r)}),this.getRangeParser=Ie((i,o)=>r=>{let[l,a]=r;const d=this.getValueParser(i,o);return l=d(l),a=d(a),[l,a]}),this.getAxisRangeParser=Ie((i,o)=>r=>{const l=_e.getSourceForAxis(i,r);return l?this.getRangeParser(l.columnType,o):a=>a}),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=t,this.settings=e,this.theme=n,this.data=[];const s={data:{},layout:_e.makeDefaultLayout(n)};this.layout={grid:{rows:t.rows,columns:t.cols,pattern:"independent"},template:s},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:t}=this.figure,e=_e.getAllAxes(this.figure),n=[];for(let o=0;o<t.length;o+=1){const r=t[o];for(let l=0;l<r.series.length;l+=1){const a=r.series[l];n.push(a.name),this.addSeries(a,e,r.showLegend)}}const i=[...this.seriesDataMap.keys()].filter(o=>n.indexOf(o)<0);for(let o=0;o<i.length;o+=1){const r=i[o];this.seriesDataMap.delete(r)}this.seriesToProcess=new Set([...this.seriesDataMap.keys()])}addSeries(t,e,n){const s=_e.groupArray(e,"type"),i=_e.makeSeriesDataFromSeries(t,s,_e.getSeriesVisibility(t.name,this.settings),n,this.theme);if(this.seriesDataMap.set(t.name,i),this.data=[...this.seriesDataMap.values()],t.plotStyle===I.plot.SeriesPlotStyle.STACKED_BAR?this.layout.barmode="stack":t.plotStyle===I.plot.SeriesPlotStyle.PIE&&(this.layout.hiddenlabels=_e.getHiddenLabels(this.settings)),this.layout.showlegend=this.data.length>1||t.plotStyle===I.plot.SeriesPlotStyle.PIE?n??void 0:!1,t.oneClick!=null){const{oneClick:o}=t,{columns:r}=o;for(let l=0;l<r.length;l+=1)this.filterColumnMap.set(r[l].name,r[l]);this.oneClicks.push(o)}this.updateLayoutFormats()}subscribe(t){super.subscribe(t),this.listeners.length===1&&(this.initAllSeries(),this.subscribeFigure())}unsubscribe(t){super.unsubscribe(t),this.listeners.length===0&&this.unsubscribeFigure()}subscribeFigure(){if(!this.isConnected){kt.debug("Ignoring subscribe when figure in disconnected state");return}this.figure.subscribe(this.isDownsamplingDisabled?I.plot.DownsampleOptions.DISABLE:I.plot.DownsampleOptions.DEFAULT)}unsubscribeFigure(){this.figure.unsubscribe()}startListeningFigure(){this.figure.addEventListener(I.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.addEventListener(I.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.addEventListener(I.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.addEventListener(I.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.addEventListener(I.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.addEventListener(I.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.addEventListener(I.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.addEventListener(I.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.addEventListener(I.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}stopListeningFigure(){this.figure.removeEventListener(I.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.removeEventListener(I.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.removeEventListener(I.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.removeEventListener(I.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.removeEventListener(I.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.removeEventListener(I.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.removeEventListener(I.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.removeEventListener(I.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.removeEventListener(I.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}handleDownsampleStart(t){kt.debug("Downsample started",t),this.fireDownsampleStart(t.detail)}handleDownsampleFinish(t){kt.debug("Downsample finished",t),this.fireDownsampleFinish(t.detail)}handleDownsampleFail(t){kt.error("Downsample failed",t),this.fireDownsampleFail(t.detail)}handleDownsampleNeeded(t){kt.info("Downsample needed",t),this.fireDownsampleNeeded(t.detail)}handleFigureUpdated(t){const{detail:e}=t,{series:n}=e;kt.debug2("handleFigureUpdated",n);for(let i=0;i<n.length;i+=1){const o=n[i];kt.debug2("handleFigureUpdated updating series",o.name);const{sources:r}=o;for(let l=0;l<r.length;l+=1){const a=r[l],{columnType:d,type:c}=a,u=this.getValueTranslator(d,this.formatter),m=e.getArray(o,c,u);this.setDataArrayForSeries(o,c,m)}this.seriesToProcess.delete(o.name),this.seriesToProcess.size===0&&this.fireLoadFinished(),this.cleanSeries(o)}const{data:s}=this;this.fireUpdate(s)}handleRequestFailed(t){kt.error("Request failed",t)}resubscribe(){this.listeners.length>0&&(this.unsubscribeFigure(),this.subscribeFigure())}setFormatter(t){super.setFormatter(t),this.updateLayoutFormats(),this.resubscribe()}setDownsamplingDisabled(t){super.setDownsamplingDisabled(t),this.resubscribe()}handleFigureDisconnected(t){kt.debug("Figure disconnected",t),this.isConnected=!1,this.listeners.length>0&&this.unsubscribeFigure(),this.fireDisconnect()}handleFigureReconnected(t){kt.debug("Figure reconnected",t),this.isConnected=!0,this.initAllSeries(),this.fireReconnect(),this.listeners.length>0&&this.subscribeFigure()}handleFigureSeriesAdded(t){const{detail:e}=t;kt.debug("handleFigureSeriesAdded",e),this.pendingSeries.push(e),this.addPendingSeries()}setDimensions(t){super.setDimensions(t),this.updateAxisPositions()}setTitle(t){super.setTitle(t);const e=(t??"").match(/<br>/g)?.length??0,n=_e.DEFAULT_MARGIN.t+e*_e.SUBTITLE_LINE_HEIGHT;this.layout.margin?this.layout.margin.t=n:this.layout.margin={t:n},typeof this.layout.title=="string"?this.layout.title=t:(this.layout.title={...this.layout.title},this.layout.title.text=t,this.layout.title.pad={...this.layout.title.pad},this.layout.title.pad.t=_e.DEFAULT_TITLE_PADDING.t+e*_e.SUBTITLE_LINE_HEIGHT*.5)}getPlotWidth(){return!this.rect||!this.rect.width?0:Math.max(this.rect.width-(this.layout.margin?.l??0)-(this.layout.margin?.r??0),0)}getPlotHeight(){return!this.rect||!this.rect.height?0:Math.max(this.rect.height-(this.layout.margin?.t??0)-(this.layout.margin?.b??0),0)}updateAxisPositions(){const t=this.getPlotWidth(),e=this.getPlotHeight();_e.updateFigureAxes(this.layout,this.figure,n=>this.getAxisRangeParser(n,this.formatter),t,e,this.theme)}updateLayoutFormats(){if(!this.formatter)return;_e.getAxisFormats(this.figure,this.formatter).forEach((e,n)=>{kt.debug(`Assigning ${n}`,this.layout[n],e);const s=this.layout[n];s!=null?Object.assign(s,e):kt.debug(`Ignoring null layout.${n}`)})}setDataArrayForSeries(t,e,n){const{name:s,plotStyle:i}=t,o=this.seriesDataMap.get(s),r=_e.getPlotlyProperty(i,e);o&&mh(o,r,n)}cleanSeries(t){const{name:e,plotStyle:n}=t,s=this.seriesDataMap.get(e);if(s!=null){if(n===I.plot.SeriesPlotStyle.HISTOGRAM){const{xLow:i,xHigh:o}=s;if(i&&o&&i.length===o.length){const r=[];for(let l=0;l<i.length;l+=1)r.push(o[l]-i[l]);s.width=r}}else if(n===I.plot.SeriesPlotStyle.LINE){const{x:i,xLow:o,xHigh:r,y:l,yLow:a,yHigh:d}=s;o&&r&&o!==i&&(s.error_x=_e.getPlotlyErrorBars(i,o,r)),a&&d&&a!==l&&(s.error_y=_e.getPlotlyErrorBars(l,a,d))}else if(n===I.plot.SeriesPlotStyle.TREEMAP){const{ids:i,labels:o}=s;i!==void 0&&o===void 0&&(s.labels=i)}}}getData(){return this.data}getLayout(){return this.layout}getFilterColumnMap(){return new Map(this.filterColumnMap)}isFilterRequired(){return this.oneClicks.find(t=>t.requireAllFiltersToDisplay)!=null}setFilter(t){if(this.oneClicks.length===0){kt.warn("Trying to set a filter, but no one click!");return}kt.debug("setFilter",t);for(let e=0;e<this.oneClicks.length;e+=1){const n=this.oneClicks[e],{columns:s}=n;new Set([...t.keys(),...this.lastFilter.keys()]).forEach(o=>{const r=t.get(o);this.lastFilter.get(o)!==r&&s.find(l=>l.name===o)!=null&&n.setValueForColumn(o,r)})}this.lastFilter=new Map(t)}setFigure(t){this.close(),this.figure=t,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure(),this.listeners.length>0&&this.subscribeFigure()}updateSettings(t){this.settings=t}};let ma=ou;ma.ADD_SERIES_DEBOUNCE=50;class Oi{static async makeModelFromSettings(e,n,s=Gt){const i=await Oi.makeFigureFromSettings(e,n);return new ma(i,e,s)}static async makeFigureFromSettings(e,n){const s=await n.copy();return s.applyCustomColumns(n.customColumns),s.applyFilter(n.filter),s.applySort(n.sort),I.plot.Figure.create(_e.makeFigureSettings(e,s))}static async makeModel(e,n,s=Gt){return new ma(n,e,s)}}function fc(t){return t.setFigure!==void 0}function eS({connection:t,defaultUpdateInterval:e,hoverUpdateInterval:n,bgMonitoring:s=!0,monitorDuration:i}){const[o,r]=b.exports.useState({freeMemory:0,maximumHeapSize:999,totalHeapSize:0}),[l,a]=b.exports.useState(!1),d=b.exports.useRef({timestamps:[],usages:[]});b.exports.useEffect(function(){const U=async()=>{const Y=await t.getWorkerHeapInfo();if(r(Y),s||l){const G=(Y.totalHeapSize-Y.freeMemory)/Y.maximumHeapSize,z=Date.now(),{timestamps:x,usages:L}=d.current;for(;x.length!==0&&z-x[0]>i*1.5;)x.shift(),L.shift();x.push(z),L.push(G)}else d.current={timestamps:[],usages:[]}};U();const A=setInterval(U,l?n:e);return()=>{clearInterval(A)}},[l,n,t,e,i,s]);const c=(H,U)=>Math.round(H*10**U)/10**U,u=2,m=1024**3,{freeMemory:p,totalHeapSize:g,maximumHeapSize:f}=o,C=c(p/m,u),S=c(g/m,u),w=c(f/m,u),T=S-C,y=(H,U,A=!1)=>v("div",{className:K("heap-usage-info-row",{"heading-bottom-border":A}),children:[h("div",{className:"font-weight-bold",children:H}),h("div",{children:U})]}),{timestamps:E,usages:R}=d.current,F=E[E.length-1]??0,D=g/f,_=(g-p)/f;return v(Se,{children:[v("div",{className:"max-memory",children:[h("div",{className:"total-memory",style:{width:`calc(${D*100}% - ${D*2}px`}}),h("div",{className:K("used-memory",{"heap-overflow":(g-p)/f>.95}),style:{width:`calc(${_*100}% - ${_*2}px`}}),v("div",{className:"memory-text",children:[w.toFixed(1)," GB"]})]}),h(ut,{onEntered:()=>a(!0),onExited:()=>a(!1),interactive:!0,children:v("div",{className:"heap-tooltip",children:[y("In use:",`${T.toFixed(u)} of ${w.toFixed(u)} GB`,!0),y("Free:",`${C.toFixed(u)} GB`),y("Total:",`${S.toFixed(u)} GB`),y("Max:",`${w.toFixed(u)} GB`),h("div",{className:"heap-plot",children:h(su,{data:[{x:[...E],y:[...R],type:"scatter",mode:"lines"}],config:{staticPlot:!0,responsive:!0},style:{width:"196px",height:"100px"},layout:{legend:!1,margin:{l:2,t:2,r:2,b:2},plot_bgcolor:"transparent",paper_bgcolor:"transparent",colorway:["#4878ea"],xaxis:{dtick:Math.round(i/6),gridcolor:Gt.linecolor,range:[F-i,F],linecolor:Gt.linecolor,linewidth:2,mirror:!0},yaxis:{dtick:.2,gridcolor:Gt.linecolor,range:[0,1],linecolor:Gt.linecolor,linewidth:2,mirror:!0}}})}),v("div",{className:"heap-utilisation-text",children:["% utilization over ",Math.round(i/1e3/60)," min."]})]})})]})}const qa=Object.freeze({}),tS=new Map,ru=t=>t.user,Ya=t=>t.storage,lu=t=>Ya(t).commandHistoryStorage,au=t=>Ya(t).fileStorage,nS=t=>Ya(t).workspaceStorage,pl=t=>t.workspace,Et=t=>pl(t).data.settings,du=t=>Et(t).defaultDateTimeFormat,cu=t=>Et(t).defaultDecimalFormatOptions??qa,hu=t=>Et(t).defaultIntegerFormatOptions??qa,uu=t=>Et(t).formatter,Ao=t=>Et(t).timeZone,mu=t=>Et(t).showTimeZone,pu=t=>Et(t).showTSeparator,gu=t=>Et(t).truncateNumbersWithPound,sS=t=>Et(t).shortcutOverrides,iS=t=>Et(t).defaultNotebookSettings??qa,gl=t=>t.activeTool,oS=t=>t.plugins??tS,fu="SET_ACTIVE_TOOL",Cu="SET_COMMAND_HISTORY_STORAGE",Su="SET_FILE_STORAGE",bu="SET_PLUGINS",wu="SET_USER",Tu="SET_WORKSPACE",vu="SET_WORKSPACE_STORAGE",Eu="SET_SERVER_CONFIG_VALUES",rS=t=>({type:wu,payload:t}),yu=t=>({type:Tu,payload:t}),lS=t=>({type:vu,payload:t}),aS=t=>({type:Cu,payload:t}),dS=t=>({type:Su,payload:t}),cS=t=>(e,n)=>{e(yu(t));const{storage:s}=n(),{workspaceStorage:i}=s;return i.save(t)},Ru=t=>(e,n)=>{const{workspace:s}=n(),{data:i}=s,o={...s,data:{...i,...t}};return e(cS(o))},fl=t=>e=>e(Ru({settings:t})),Cl=t=>({type:fu,payload:t}),hS=t=>({type:bu,payload:t}),uS=t=>({type:Eu,payload:t});function Iu(t,e){return(n=e,s)=>{switch(s.type){case t:{const i=s.payload;return i==null?null:n!=null?{...n,...i}:{...i}}default:return n}}}function mS(t,e={},n=!0){return(s=e,i)=>{switch(i.type){case t:{const{id:o,payload:r}=i;return n&&ct({payload:r},{payload:s[o]})?s:{...s,[o]:r}}default:return s}}}function Ls(t,e){return(n=e,s)=>{switch(s.type){case t:return s.payload;default:return n}}}const pS=Ls(fu,null),gS=Ls(bu,null),fS=Ls(Cu,null),CS=Ls(Su,null),SS=Ls(vu,null),bS=xa({commandHistoryStorage:fS,fileStorage:CS,workspaceStorage:SS}),wS=Iu(wu,null),TS=Iu(Tu,null),vS=Ls(Eu,null),ES={activeTool:pS,plugins:gS,storage:bS,user:wS,workspace:TS,serverConfigValues:vS};class yS{constructor(){this.reducers={},this.listener=null}register(e,n){this.reducers={...this.reducers,[e]:n},this.listener?.(this.reducers)}setListener(e){this.listener=e}}const Gi=new yS,Cc=ee.module("redux-logger"),RS=t=>e=>n=>{Cc.debug("dispatching",n);const s=e(n);return Cc.debug("next state",t.getState()),s},IS=ee.module("redux-crashReporter"),FS=t=>e=>n=>{try{return e(n)}catch(s){throw IS.error("Error executing",n," with state ",t.getState(),":",s),s}},DS=[RS,FS,Tp];Object.entries(ES).map(([t,e])=>Gi.register(t,e));const NS=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__??yp,Sl=vp(xa(Gi.reducers),NS(Ep(...DS)));Gi.setListener(t=>{Sl.replaceReducer(xa(t))});const Fu=Object.freeze({openPopouts:[],settings:{hasHeaders:!0,constrainDragToContainer:!0,reorderEnabled:!0,selectionEnabled:!1,popoutWholeStack:!1,blockedPopoutsThrowError:!0,closePopoutsOnUnload:!0,showPopoutIcon:!0,showMaximiseIcon:!0,showCloseIcon:!0,responsiveMode:"onload",tabOverlapAllowance:0,tabControlOffset:10},dimensions:{borderWidth:5,borderGrabWidth:10,minItemHeight:10,minItemWidth:10,headerHeight:20,dragProxyWidth:300,dragProxyHeight:200},labels:{close:"Close",maximise:"Maximize",minimise:"Minimize",popout:"Open in new window",popin:"Pop in",tabDropdown:"Additional tabs",tabNextLabel:"Next",tabPreviousLabel:"Previous"},content:[]});function Du(t){return t.componentName!==void 0}function _S(t){return t.component!==void 0}const Nu=Object.freeze({type:"default",isClosable:!0,isFocusOnShow:!0,reorderEnabled:!0,title:""}),MS=Object.freeze(Object.defineProperty({__proto__:null,defaultConfig:Fu,isGLComponentConfig:Du,isReactComponentConfig:_S,itemDefaultConfig:Nu},Symbol.toStringTag,{value:"Module"})),pa=class{constructor(){this.off=this.unbind,this.trigger=this.emit,this._mSubscriptions={},this._mSubscriptions[pa.ALL_EVENT]=[]}on(t,e,n){if(typeof e!="function")throw new Error("Tried to listen to event "+t+" with non-function callback "+e);this._mSubscriptions[t]||(this._mSubscriptions[t]=[]),this._mSubscriptions[t].push({fn:e,ctx:n})}emit(t,...e){const n=this._mSubscriptions[t];if(n)for(let i=0;i<n.length;i++){const o=n[i].ctx||{};n[i].fn.apply(o,e)}e.unshift(t);const s=this._mSubscriptions[pa.ALL_EVENT];for(let i=0;i<s.length;i++){const o=s[i].ctx||{};s[i].fn.apply(o,e)}}unbind(t,e,n){if(!this._mSubscriptions[t])throw new Error("No subscribtions to unsubscribe for event "+t);let s=!1;for(let i=0;i<this._mSubscriptions[t].length;i++)(!e||this._mSubscriptions[t][i].fn===e)&&(!n||n===this._mSubscriptions[t][i].ctx)&&(this._mSubscriptions[t].splice(i,1),s=!0);if(s===!1)throw new Error("Nothing to unbind for "+t)}};let pn=pa;pn.ALL_EVENT="__all";class ga extends pn{constructor(e,n,s){super(),this.isHidden=!1,this._element=pe(['<div class="lm_item_container">','<div class="lm_content" tabindex="-1"></div>',"</div>"].join("")),this.title=Du(e)?e.componentName:"",this.parent=n,this.layoutManager=s,this._config=e,this._contentElement=this._element.find(".lm_content"),this.beforeCloseHandler=null}getElement(){return this._contentElement}hide(){this.emit("hide"),this.isHidden=!0,this._element.hide()}show(){this.emit("show"),this.isHidden=!1,this._element.show(),(this.height!=0||this.width!=0)&&this.emit("shown")}setSize(e,n){let s=this.parent,i=null;for(;s&&!s.isColumn&&!s.isRow;)if(i=s,s=s.parent,s?.isRoot)return!1;if(!s||!i)return!1;const o=s.isColumn?"height":"width",r=o==="height"?n:e,l=(this[o]??0)*(1/((i.config[o]??0)/100)),a=r/l*100,d=((i.config[o]??0)-a)/(s.contentItems.length-1);for(let c=0;c<s.contentItems.length;c++)s.contentItems[c]===i?s.contentItems[c].config[o]=a:s.contentItems[c].config[o]=(s.contentItems[c].config[o]??0)+d;return s.callDownwards("setSize"),!0}close(e){!this._config.isClosable||(this.beforeCloseHandler?.(e)??!0)&&(this.emit("close"),this.parent.close())}beforeClose(e){this.beforeCloseHandler=e}getState(){return this._config.componentState}extendState(e){this.setState(pe.extend(!0,this.getState(),e))}setState(e){this._config.componentState=e,this.parent.emitBubblingEvent("stateChanged")}setTitle(e){this.parent.setTitle(e)}_$setSize(e=0,n=0){if(e!==this.width||n!==this.height){this.width=e,this.height=n;var s=this._contentElement[0],i=s.offsetWidth-s.clientWidth,o=s.offsetHeight-s.clientHeight;this._contentElement.width(this.width-i).height(this.height-o),this.emit("resize")}}}const kS=Object.freeze(Object.defineProperty({__proto__:null,ItemContainer:ga,Container:ga},Symbol.toStringTag,{value:"Module"}));function _u(t){var e=location.hash.match(new RegExp(t+"=([^&]*)"));return e?e[1]:null}function Mu(t){if(window.location.hash)return _u(t);if(!window.location.search)return null;var e=window.location.search.substr(1).split("&"),n={},s,i;for(i=0;i<e.length;i++)s=e[i].split("="),n[s[0]]=s[1];return n[t]||null}function bl(t){return window.requestAnimationFrame(t)}function xS(t,e){var n=e.indexOf(t);if(n===-1)throw new Error("Can't remove item from array. Item is not in the array");e.splice(n,1)}function Ka(){return(Math.random()*1e15).toString(36).replace(".","")}function OS(t,e){var n=t.replace(/javascript/gi,"j&#97;vascript").replace(/expression/gi,"expr&#101;ssion").replace(/onload/gi,"onlo&#97;d").replace(/script/gi,"&#115;cript").replace(/onerror/gi,"on&#101;rror");return e===!0?n:n.replace(/>/g,"&gt;").replace(/</g,"&lt;")}function Xa(t){return pe.trim(t.replace(/(<([^>]+)>)/gi,""))}class Lo extends pn{constructor(e,n=!1){super(),this._nDelay=400,this._nDistance=10,this._nX=0,this._nY=0,this._nOriginalX=0,this._nOriginalY=0,this._bDragging=!1,this._eElement=e,this._oDocument=pe(document),this._eBody=pe(document.body),this._destroyAfterMouseUp=n,this.onMouseMove=this.onMouseMove.bind(this),this.onMouseUp=this.onMouseUp.bind(this),this.onMouseDown=this.onMouseDown.bind(this),this._startDrag=this._startDrag.bind(this),this._eElement?.on("mousedown",this.onMouseDown)}destroy(){this._eElement?.unbind("mousedown",this.onMouseDown),this._oDocument?.unbind("mouseup",this.onMouseUp),this._eElement=void 0,this._oDocument=void 0,this._eBody=void 0,clearTimeout(this._timeout),this._timeout=void 0}onMouseDown(e){if(e.preventDefault(),e.button===0){var n=this._getCoordinates(e);this._nOriginalX=n.x??0,this._nOriginalY=n.y??0,this._oDocument?.on("mousemove",this.onMouseMove),this._oDocument?.on("mouseup",this.onMouseUp),this._timeout=window.setTimeout(this._startDrag,this._nDelay)}}onMouseMove(e){if(this._timeout!=null){e.preventDefault();var n=this._getCoordinates(e);this._nX=(n.x??0)-this._nOriginalX,this._nY=(n.y??0)-this._nOriginalY,this._bDragging===!1&&(Math.abs(this._nX)>this._nDistance||Math.abs(this._nY)>this._nDistance)&&this._startDrag(),this._bDragging&&this.emit("drag",this._nX,this._nY,e)}}onMouseUp(e){this._timeout!=null&&(clearTimeout(this._timeout),this._oDocument?.unbind("mousemove",this.onMouseMove),this._oDocument?.unbind("mouseup",this.onMouseUp),this._oDocument?.find("iframe")?.css("pointer-events",""),this._bDragging===!0&&(this._bDragging=!1,this.emit("dragStop",e,this._nOriginalX+this._nX)),this._eBody?.removeClass("lm_dragging"),this._eElement instanceof Window||this._eElement?.removeClass("lm_dragging"),this._destroyAfterMouseUp&&this.destroy())}_startDrag(){window.clearTimeout(this._timeout),this._bDragging=!0,this._eBody?.addClass("lm_dragging"),this._eElement?.addClass("lm_dragging"),this._oDocument?.find("iframe")?.css("pointer-events","none"),this.emit("dragStart",this._nOriginalX,this._nOriginalY)}_getCoordinates(e){return{x:e.pageX??0,y:e.pageY??0}}}class ku{constructor(e,n){this._reactComponent=null,this._originalComponentWillUpdate=null,this._reactComponent=null,this._originalComponentWillUpdate=null,this._container=e,this._initialState=n,this._reactClass=this._getReactClass(),this._container.on("open",this._render,this),this._container.on("destroy",this._destroy,this)}_render(){No.render(this._getReactComponent(),this._container.getElement()[0])}_gotReactComponent(e){if(!e)return;this._reactComponent=e,this._originalComponentWillUpdate=this._reactComponent.componentWillUpdate||function(){},this._reactComponent.componentWillUpdate=this._onUpdate.bind(this);const n=this._container.getState();n&&this._reactComponent.setState(n)}_destroy(){No.unmountComponentAtNode(this._container.getElement()[0]),this._container.off("open",this._render,this),this._container.off("destroy",this._destroy,this)}_onUpdate(e,n){this._container.setState(n),this._originalComponentWillUpdate?.call(this._reactComponent,e,n)}_getReactClass(){var e=this._container._config.component;if(!e)throw new Error("No react component name. type: react-component needs a field `component`");const n=this._container.layoutManager.getComponent(e)||this._container.layoutManager.getFallbackComponent();if(!n)throw new Error('React component "'+e+'" not found. Please register all components with GoldenLayout using `registerComponent(name, component)`');return n}_getReactComponent(){var e={glEventHub:this._container.layoutManager.eventHub,glContainer:this._container,ref:this._gotReactComponent.bind(this)},n=pe.extend(e,this._container._config.props);return de.createElement(this._reactClass,n)}}const Br=["settings","hasHeaders","constrainDragToContainer","selectionEnabled","dimensions","borderWidth","minItemHeight","minItemWidth","headerHeight","dragProxyWidth","dragProxyHeight","labels","close","maximise","minimise","popout","content","componentName","componentState","id","width","type","height","isClosable","title","popoutWholeStack","openPopouts","parentId","activeItemIndex","reorderEnabled","borderGrabWidth"],AS=[!0,!1,"row","column","stack","component","close","maximise","minimise","open in new window"];function ja(t){if(Br.length>36)throw new Error("Too many keys in config minifier map");const e={};return Za(t,e,"_min"),e}function fa(t){if(Br.length>36)throw new Error("Too many keys in config minifier map");const e={};return Za(t,e,"_max"),e}function Za(t,e,n){const s=n==="_min"?LS:PS;for(let i in t){if(!t.hasOwnProperty(i))continue;const o=Array.isArray(t)?t[Number.parseInt(i,10)]:t[i];if(typeof o=="object"&&o!=null){const r=o instanceof Array?[]:{};if(Array.isArray(e))e[Number.parseInt(i,10)]=r;else{const l=s(i,Br);e[l]=r}Za(o,r,n)}else{const r=s(o,AS);if(Array.isArray(e))e[Number.parseInt(i,10)]=r;else{const l=s(i,Br);e[l]=r}}}}function LS(t,e){if(typeof t=="string"&&t.length===1)return"___"+t;var n=e.indexOf(t);return n===-1?t:n.toString(36)}function PS(t,e){return typeof t=="string"&&t.length===1?e[parseInt(t,36)]:typeof t=="string"&&t.substr(0,3)==="___"?t[3]:t}class Ca{constructor(e,n){this.name=e,this.origin=n,this.isPropagationStopped=!1}stopPropagation(){this.isPropagationStopped=!0}}class xu extends pn{constructor(e){super(),this._layoutManager=e,this._dontPropagateToParent=null,this._childEventSource=null,this.on(pn.ALL_EVENT,this._onEventFromThis.bind(this)),this._boundOnEventFromChild=this._onEventFromChild.bind(this),pe(window).on("gl_child_event",this._boundOnEventFromChild)}_onEventFromThis(...e){this._layoutManager.isSubWindow&&e[0]!==this._dontPropagateToParent&&this._propagateToParent(e),this._propagateToChildren(e),this._dontPropagateToParent=null,this._childEventSource=null}_$onEventFromParent(e){this._dontPropagateToParent=e[0],this.emit.apply(this,e)}_onEventFromChild(e){this._childEventSource=e.originalEvent.__gl,this.emit.apply(this,e.originalEvent.__glArgs)}_propagateToParent(e){const n="gl_child_event",s=window.opener?.document.createEvent("HTMLEvents");s.initEvent(n,!0,!0),s.eventName=n,s.__glArgs=e,s.__gl=this._layoutManager,window.opener.dispatchEvent(s)}_propagateToChildren(e){for(let n=0;n<this._layoutManager.openPopouts.length;n++){const s=this._layoutManager.openPopouts[n].getGlInstance();s&&s!==this._childEventSource&&s.eventHub._$onEventFromParent(e)}}destroy(){pe(window).off("gl_child_event",this._boundOnEventFromChild)}}const HS=Object.freeze(Object.defineProperty({__proto__:null,EventEmitter:pn,DragListener:Lo,ReactComponentHandler:ku,BubblingEvent:Ca,EventHub:xu,getHashValue:_u,getQueryStringParam:Mu,animFrame:bl,removeFromArray:xS,getUniqueId:Ka,filterXss:OS,stripTags:Xa,minifyConfig:ja,unminifyConfig:fa},Symbol.toStringTag,{value:"Module"}));class Ou extends pn{constructor(e,n,s,i,o){super(),this.isInitialised=!1,this._popoutWindow=null,this._id=null,this._config=e,this._dimensions=n,this._parentId=s,this._indexInParent=i,this._layoutManager=o,this._createWindow()}toConfig(){if(this.isInitialised===!1)throw new Error("Can't create config, layout not yet initialised");return{dimensions:{width:this.getGlInstance()?.width,height:this.getGlInstance()?.height,left:this._popoutWindow?.screenX??this._popoutWindow?.screenLeft??0,top:this._popoutWindow?.screenY??this._popoutWindow?.screenTop??0},content:this.getGlInstance()?.toConfig().content,parentId:this._parentId,indexInParent:this._indexInParent}}getGlInstance(){return this._popoutWindow?.__glInstance}getWindow(){return this._popoutWindow}close(){if(this.getGlInstance())this.getGlInstance()?._$closeWindow();else try{this.getWindow()?.close()}catch{}}popIn(){this._indexInParent;let e=null,n=null;this._parentId&&(e=pe.extend(!0,{},this.getGlInstance()?.toConfig()).content[0],n=this._layoutManager.root.getItemsById(this._parentId)[0],n||((this._layoutManager.root.contentItems.length??0)>0?n=this._layoutManager.root.contentItems[0]:n=this._layoutManager.root)),e&&(n?.addChild(e,this._indexInParent),this.close())}_createWindow(){const e=this._createUrl(),n=Math.floor(Math.random()*1e6).toString(36),s=this._serializeWindowOptions({width:this._dimensions.width,height:this._dimensions.height,innerWidth:this._dimensions.width,innerHeight:this._dimensions.height,menubar:"no",toolbar:"no",location:"no",personalbar:"no",resizable:"yes",scrollbars:"no",status:"no"});if(this._popoutWindow=window.open(e,n,s),!this._popoutWindow)if(this._layoutManager.config.settings.blockedPopoutsThrowError===!0){const o=new Error("Popout blocked");throw o.type="popoutBlocked",o}else return;pe(this._popoutWindow).on("load",this._positionWindow.bind(this)).on("unload beforeunload",this._onClose.bind(this));let i=window.setInterval(()=>{this._popoutWindow?.__glInstance&&this._popoutWindow.__glInstance.isInitialised&&(this._onInitialised(),window.clearInterval(i))},10)}_serializeWindowOptions(e){var n=[],s;for(s in e)n.push(s+"="+e[s]);return n.join(",")}_createUrl(){var e={content:this._config};const n="gl-window-config-"+Ka();e=ja(e);try{localStorage.setItem(n,JSON.stringify(e))}catch(i){throw new Error("Error while writing to localStorage "+i.toString())}const s=document.location.href.split("?");return s.length===1?s[0]+"?gl-window="+n:document.location.href+"&gl-window="+n}_positionWindow(){this._popoutWindow?.moveTo(this._dimensions.left,this._dimensions.top),this._popoutWindow?.focus()}_onInitialised(){this.isInitialised=!0,this.getGlInstance()?.on("popIn",this.popIn,this),this.emit("initialised")}_onClose(){setTimeout(this.emit.bind(this,"closed"),50)}}const Au=class extends pn{constructor(t,e,n,s,i,o){super(),this._area=null,this._lastValidArea=null,this._dragListener=n,this._layoutManager=s,this._contentItem=i,this._originalParent=o,this._dragListener.on("drag",this._onDrag,this),this._dragListener.on("dragStop",this._onDrop,this),this._contentItem.tab&&this._contentItem.tab.element&&(this._layoutManager.tabDropPlaceholder.width(this._contentItem.tab.element.outerWidth(!0)??0),this._layoutManager.tabDropPlaceholder.height(this._contentItem.tab.element.outerHeight(!0)??0)),this.element=pe(Au._template),o&&o._side&&(this._sided=o._sided,this.element.addClass("lm_"+o._side),["right","bottom"].indexOf(o._side.toString())>=0&&this.element.find(".lm_content").after(this.element.find(".lm_header"))),this.element.css({left:t,top:e}),this._proxyTab=this.element.find(".lm_tab"),this._proxyTab.attr("title",Xa(this._contentItem.config.title??"")),this.element.find(".lm_title").html(this._contentItem.config.title??""),this.childElementContainer=this.element.find(".lm_content"),this.childElementContainer.append(i.element),this._updateTree(),this._layoutManager._$calculateItemAreas(),this._setDimensions(),pe(document.body).append(this.element),!this._contentItem.tab&&this._proxyTab.length&&(this._layoutManager.tabDropPlaceholder.width(this._proxyTab.outerWidth(!0)??0),this._layoutManager.tabDropPlaceholder.height(this._proxyTab.outerHeight(!0)??0));var r=this._layoutManager.container.offset();this._minX=r?.left??0,this._minY=r?.top??0,this._maxX=(this._layoutManager.container.width()??0)+this._minX,this._maxY=(this._layoutManager.container.height()??0)+this._minY,this._width=this.element.width()??0,this._height=this.element.height()??0,this._setDropPosition(t,e),this._layoutManager.emit("itemPickedUp",this._contentItem)}_onDrag(t,e,n){const s=n.pageX??0,i=n.pageY??0;!(s>this._minX&&s<this._maxX&&i>this._minY&&i<this._maxY)&&this._layoutManager.config.settings.constrainDragToContainer===!0||this._setDropPosition(s,i)}_setDropPosition(t,e){this.element.css({left:t,top:e}),this._area=this._layoutManager._$getArea(t,e),this._area!==null&&(this._lastValidArea=this._area,this._area.contentItem._$highlightDropZone(t,e,this._area))}_onDrop(){this._layoutManager.dropTargetIndicator?.hide(),this._area!==null?this._area.contentItem._$onDrop(this._contentItem,this._area):this._lastValidArea!==null?this._lastValidArea.contentItem._$onDrop(this._contentItem,this._lastValidArea):this._originalParent?this._originalParent.addChild(this._contentItem):this._contentItem._$destroy(),this._dragListener.off("drag",this._onDrag,this),this._dragListener.off("dragStop",this._onDrop,this),this.element.remove(),this._layoutManager.emit("itemDropped",this._contentItem)}_updateTree(){this._contentItem.parent&&this._contentItem.parent.removeChild(this._contentItem,!0),this._contentItem._$setParent(null)}_setDimensions(){const t=this._layoutManager.config.dimensions;let e=t.dragProxyWidth,n=t.dragProxyHeight;this.element.width(e),this.element.height(n),e-=this._sided?t.headerHeight:0,n-=this._sided?0:t.headerHeight,this.childElementContainer.width(e),this.childElementContainer.height(n),this._contentItem.element.width(e),this._contentItem.element.height(n),this._contentItem.callDownwards("_$show"),this._contentItem.callDownwards("setSize")}};let Po=Au;Po._template='<div class="lm_dragProxy"><div class="lm_header"><ul class="lm_tabs"><li class="lm_tab lm_active"><i class="lm_left"></i><span class="lm_title"></span><i class="lm_right"></i></li></ul></div><div class="lm_content"></div></div>';class Lu{constructor(e,n,s){this._element=e,this._itemConfig=n,this._layoutManager=s,this._dragListener=this._createDragListener()}_createDragListener(){return this._dragListener=new Lo(this._element,!0),this._dragListener.on("dragStart",this._onDragStart,this),this._dragListener.on("dragStop",this._createDragListener,this),this._dragListener}_onDragStart(e,n){let s=this._itemConfig;typeof s=="function"&&(s=s());const i=this._layoutManager._$normalizeContentItem(pe.extend(!0,{},s)),o=new Po(e,n,this._dragListener,this._layoutManager,i,null);this._layoutManager.transitionIndicator?.transitionElements(this._element,o.element)}}class Pu{constructor(e,n,s){this._element=pe(window),this._itemConfig=e,this._layoutManager=n,this._createDragListener(s)}_createDragListener(e){this._dragListener&&this._dragListener.destroy(),this._element&&(this._dragListener=new Lo(this._element,!0),this._dragListener.on("dragStart",this._onDragStart,this),this._dragListener.on("dragStop",this._destroy,this),this._dragListener.onMouseDown(e),this._dragListener._startDrag())}_destroy(){this._dragListener=void 0,this._element=void 0,this._itemConfig=void 0,this._layoutManager=void 0}_onDragStart(e,n){if(!(!this._dragListener||!this._layoutManager)){var s=this._itemConfig;typeof s=="function"&&(s=s());var i=this._layoutManager._$normalizeContentItem(pe.extend(!0,{},s));new Po(e,n,this._dragListener,this._layoutManager,i,null)}}}const Hu=class{constructor(){this.element=pe(Hu._template),pe(document.body).append(this.element)}destroy(){this.element.remove()}highlightArea(t){this.element.css({left:t.x1,top:t.y1,width:Math.floor(t.x2-t.x1),height:Math.floor(t.y2-t.y1)}).show()}hide(){this.element.hide()}};let Qa=Hu;Qa._template='<div class="lm_dropTargetIndicator"><div class="lm_inner"></div></div>';class Co{constructor(e,n,s,i){this._header=e,this.element=pe('<li class="'+s+'" title="'+n+'"></li>'),this._header.on("destroy",this._$destroy,this),this._action=i,this.element.on("click",this._action),this._header.controlsContainer.append(this.element)}_$destroy(){this.element.off(),this.element.remove()}}class ni extends Error{constructor(e,n){super(),this.name="Configuration Error",this.message=e,this.node=n}}const US=Object.freeze(Object.defineProperty({__proto__:null,ConfigurationError:ni},Symbol.toStringTag,{value:"Module"}));function _o(t){return t.isStack}function hn(t){return t.isComponent}function Uu(t){return t.isRoot}class Tt extends pn{constructor(e,n,s,i){super(),this.isInitialised=!1,this.isMaximised=!1,this.isRoot=!1,this.isRow=!1,this.isColumn=!1,this.isStack=!1,this.isComponent=!1,this.element=i,this.config=this._extendItemNode(n),this.type=n.type,this.contentItems=[],this.parent=s,this.layoutManager=e,this._pendingEventPropagations={},this._throttledEvents=["stateChanged"],this.on(pn.ALL_EVENT,this._propagateEvent,this),n.content&&this._createContentItems(n)}callDownwards(e,n=[],s=!1,i=!1){s!==!0&&i!==!0&&this[e].apply(this,n);for(let o=0;o<this.contentItems.length;o++)this.contentItems[o].callDownwards(e,n,s);s===!0&&i!==!0&&this[e].apply(this,n)}removeChild(e,n=!1){const s=this.contentItems.indexOf(e);if(s===-1)throw new Error("Can't remove child item. Unknown content item");n!==!0&&this.contentItems[s]._$destroy(),this.contentItems.splice(s,1),this.config.content?.splice(s,1),this.contentItems.length>0?this.callDownwards("setSize"):this.type!=="root"&&this.config.isClosable&&this.parent?.removeChild(this)}addChild(e,n){e=this.layoutManager._$normalizeContentItem(e,this),n===void 0&&(n=this.contentItems.length),this.contentItems.splice(n,0,e),this.config.content===void 0&&(this.config.content=[]),this.config.content.splice(n,0,e.config),e.parent=this,e.parent.isInitialised===!0&&e.isInitialised===!1&&e._$init()}replaceChild(e,n,s=!1){n=this.layoutManager._$normalizeContentItem(n);const i=this.contentItems.indexOf(e),o=e.element[0].parentNode;if(i===-1)throw new Error("Can't replace child. oldChild is not child of this");o?.replaceChild(n.element[0],e.element[0]),s===!0&&(e.parent=null,e._$destroy()),this.contentItems[i]=n,n.parent=this,_o(this)&&(this.header.tabs[i].contentItem=n),n.parent.isInitialised===!0&&n.isInitialised===!1&&n._$init(),this.callDownwards("setSize")}remove(){this.parent?.removeChild(this)}popout(){var e=this.layoutManager.createPopout(this);return this.emitBubblingEvent("stateChanged"),e}toggleMaximise(e){e&&e.preventDefault(),this.isMaximised===!0?this.layoutManager._$minimiseItem(this):this.layoutManager._$maximiseItem(this),this.isMaximised=!this.isMaximised,this.emitBubblingEvent("stateChanged")}select(){this.layoutManager.selectedItem!==this&&(this.layoutManager.selectItem(this,!0),this.element.addClass("lm_selected"))}deselect(){this.layoutManager.selectedItem===this&&(this.layoutManager.selectedItem=null,this.element.removeClass("lm_selected"))}setTitle(e){this.config.title=e,this.emit("titleChanged",e),this.emitBubblingEvent("stateChanged")}hasId(e){if(this.config.id){if(typeof this.config.id=="string")return this.config.id===e;if(this.config.id instanceof Array)return this.config.id.indexOf(e)!==-1}else return!1}addId(e){this.hasId(e)||(this.config.id?typeof this.config.id=="string"?this.config.id=[this.config.id,e]:this.config.id instanceof Array&&this.config.id.push(e):this.config.id=e)}removeId(e){if(!this.hasId(e))throw new Error("Id not found");if(typeof this.config.id=="string")delete this.config.id;else if(this.config.id instanceof Array){var n=this.config.id.indexOf(e);this.config.id.splice(n,1)}}getItemsByFilter(e){const n=[],s=function(i){for(let o=0;o<i.contentItems.length;o++)e(i.contentItems[o])===!0&&n.push(i.contentItems[o]),s(i.contentItems[o])};return s(this),n}getItemsById(e){return this.getItemsByFilter(function(n){return n.config.id instanceof Array?n.config.id.indexOf(e)!==-1:n.config.id===e})}getItemsByType(e){return this._$getItemsByProperty("type",e)}getComponentsByName(e){const n=this._$getItemsByProperty("componentName",e),s=[];for(let i=0;i<n.length;i++)s.push(n[i].instance);return s}_$getItemsByProperty(e,n){return this.getItemsByFilter(function(s){return s[e]===n})}_$setParent(e){this.parent=e}_$highlightDropZone(e,n,s){this.layoutManager.dropTargetIndicator?.highlightArea(s)}_$onDrop(e,n){this.addChild(e)}_$hide(){this._callOnActiveComponents("hide"),this.element.hide(),this.layoutManager.updateSize()}_$show(){this._callOnActiveComponents("show"),this.element.show(),this.layoutManager.updateSize()}_callOnActiveComponents(e){const n=this.getItemsByType("stack");let s=null;for(let i=0;i<n.length;i++)s=n[i].getActiveContentItem(),s&&hn(s)&&s.container[e]()}_$destroy(){this.emitBubblingEvent("beforeItemDestroyed"),this.callDownwards("_$destroy",[],!0,!0),this.element.remove(),this.emitBubblingEvent("itemDestroyed")}_$getArea(e){e=e||this.element;const n=e.offset()??{left:0,top:0},s=e.width()??0,i=e.height()??0;return{x1:n.left,y1:n.top,x2:n.left+s,y2:n.top+i,surface:s*i,contentItem:this,side:""}}_$init(){this.setSize();for(let e=0;e<this.contentItems.length;e++)this.childElementContainer?.append(this.contentItems[e].element);this.isInitialised=!0,this.emitBubblingEvent("itemCreated"),this.emitBubblingEvent(this.type+"Created")}emitBubblingEvent(e){var n=new Ca(e,this);this.emit(e,n)}_createContentItems(e){var n;if(!(e.content instanceof Array))throw new ni("content must be an Array",e);for(let s=0;s<e.content.length;s++)n=this.layoutManager.createContentItem(e.content[s],this),this.contentItems.push(n)}_extendItemNode(e){for(let[n,s]of Object.entries(Nu)){const i=n;e[i]===void 0&&(e[i]=s)}return e}_propagateEvent(e,n){n instanceof Ca&&n.isPropagationStopped===!1&&this.isInitialised===!0&&(this.isRoot===!1&&this.parent?this.parent.emit.apply(this.parent,[e,n]):this._scheduleEventPropagationToLayoutManager(e,n))}_scheduleEventPropagationToLayoutManager(e,n){this._throttledEvents.indexOf(e)===-1?this.layoutManager.emit(e,n.origin):this._pendingEventPropagations[e]!==!0&&(this._pendingEventPropagations[e]=!0,bl(this._propagateEventToLayoutManager.bind(this,e,n)))}_propagateEventToLayoutManager(e,n){this._pendingEventPropagations[e]=!1,this.layoutManager.emit(e,n)}}class Vu extends Tt{constructor(e,n,s){super(e,n,s,pe()),this.config=n,this.parent=s;const i=e.getComponent(this.config.componentName)||e.getFallbackComponent(),o=pe.extend(!0,{},this.config.componentState||{});if(i==null)throw new ni('Unknown component "'+this.config.componentName+'"');o.componentName=this.config.componentName,this.componentName=this.config.componentName,this.config.title===""&&(this.config.title=this.config.componentName),this.isComponent=!0,this.container=new ga(this.config,this,e),this.instance=new i(this.container,o),this.element=this.container._element}close(){this.parent.removeChild(this)}setSize(){this.element.is(":visible")&&this.container._$setSize(this.element.width(),this.element.height())}_$init(){Tt.prototype._$init.call(this),this.container.emit("open")}_$hide(){this.container.hide(),Tt.prototype._$hide.call(this)}_$show(){this.container.show(),this.container._config.isFocusOnShow&&this.container._contentElement[0].focus({preventScroll:!0}),Tt.prototype._$show.call(this)}_$destroy(){this.container.emit("destroy",this),Tt.prototype._$destroy.call(this)}_$getArea(){return null}}class $r extends Tt{constructor(e,n,s,i){super(n,s,i,pe('<div class="lm_item lm_'+(e?"column":"row")+'"></div>')),this._splitter=[],this._splitterPosition=null,this._splitterMinPosition=null,this._splitterMaxPosition=null,this.parent=i,this.isRow=!e,this.isColumn=e,this.childElementContainer=this.element,this._splitterSize=n.config.dimensions.borderWidth,this._splitterGrabSize=n.config.dimensions.borderGrabWidth,this._isColumn=e,this._dimension=e?"height":"width",this._splitterPosition=null,this._splitterMinPosition=null,this._splitterMaxPosition=null}addChild(e,n,s){var i,o,r,l;if(e=this.layoutManager._$normalizeContentItem(e,this),n===void 0&&(n=this.contentItems.length),this.contentItems.length>0?(l=this._createSplitter(Math.max(0,n-1)).element,n>0?(this.contentItems[n-1].element.after(l),l.after(e.element)):(this.contentItems[0].element.before(l),l.before(e.element))):this.childElementContainer.append(e.element),Tt.prototype.addChild.call(this,e,n),i=1/this.contentItems.length*100,s===!0){this.emitBubblingEvent("stateChanged");return}for(r=0;r<this.contentItems.length;r++)this.contentItems[r]===e?e.config[this._dimension]=i:(o=(this.contentItems[r].config[this._dimension]??0)*(100-i)/100,this.contentItems[r].config[this._dimension]=o);this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged")}removeChild(e,n){var s=e.config[this._dimension]??0,i=this.contentItems.indexOf(e),o=Math.max(i-1,0),r,l;if(i===-1)throw new Error("Can't remove child. ContentItem is not child of this Row or Column");for(this._splitter[o]&&(this._splitter[o]._$destroy(),this._splitter.splice(o,1)),r=0;r<this.contentItems.length;r++)this.contentItems[r]!==e&&(this.contentItems[r].config[this._dimension]=(this.contentItems[r].config[this._dimension]??0)+s/(this.contentItems.length-1));Tt.prototype.removeChild.call(this,e,n),this.contentItems.length===1&&this.config.isClosable===!0?(l=this.contentItems[0],this.contentItems=[],this.parent.replaceChild(this,l,!0)):(this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged"))}replaceChild(e,n){var s=e.config[this._dimension];super.replaceChild(e,n),n.config[this._dimension]=s,this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged")}setSize(){this.contentItems.length>0&&(this._calculateRelativeSizes(),this._setAbsoluteSizes()),this.emitBubblingEvent("stateChanged"),this.emit("resize")}_$init(){if(this.isInitialised!==!0){var e;for(Tt.prototype._$init.call(this),e=0;e<this.contentItems.length-1;e++)this.contentItems[e].element.after(this._createSplitter(e).element)}}_setAbsoluteSizes(){var e,n=this._calculateAbsoluteSizes();for(e=0;e<this.contentItems.length;e++)n.additionalPixel-e>0&&n.itemSizes[e]++,this._isColumn?(this.contentItems[e].element.width(n.totalWidth),this.contentItems[e].element.height(n.itemSizes[e])):(this.contentItems[e].element.width(n.itemSizes[e]),this.contentItems[e].element.height(n.totalHeight))}_calculateAbsoluteSizes(){const e=(this.contentItems.length-1)*this._splitterSize;let n=this.element.width()??0,s=this.element.height()??0,i=0;const o=[];this._isColumn?s-=e:n-=e;for(let l=0;l<this.contentItems.length;l++){const a=this._isColumn?Math.floor(s*((this.contentItems[l].config.height??0)/100)):Math.floor(n*((this.contentItems[l].config.width??0)/100));i+=a,o.push(a)}const r=Math.floor((this._isColumn?s:n)-i);return{itemSizes:o,additionalPixel:r,totalWidth:n,totalHeight:s}}_calculateRelativeSizes(){let e=0;const n=[],s=this._isColumn?"height":"width";for(let i=0;i<this.contentItems.length;i++)this.contentItems[i].config[s]!==void 0?e+=this.contentItems[i].config[s]??0:n.push(this.contentItems[i]);if(Math.round(e)===100){this._respectMinItemWidth();return}if(Math.round(e)<100&&n.length>0){for(let i=0;i<n.length;i++)n[i].config[s]=(100-e)/n.length;this._respectMinItemWidth();return}if(Math.round(e)>100)for(let i=0;i<n.length;i++)n[i].config[s]=50,e+=50;for(let i=0;i<this.contentItems.length;i++)this.contentItems[i].config[s]=(this.contentItems[i].config[s]??0)/e*100;this._respectMinItemWidth()}_respectMinItemWidth(){const e=this.layoutManager.config.dimensions?this.layoutManager.config.dimensions.minItemWidth??0:0,n=[];let s=0,i=0,o=0;const r=[];let l;if(this._isColumn||!e||this.contentItems.length<=1)return;const a=this._calculateAbsoluteSizes();for(let c=0;c<this.contentItems.length;c++){this.contentItems[c];const u=a.itemSizes[c];u<e?(i+=e-u,l={width:e}):(s+=u-e,l={width:u},n.push(l)),r.push(l)}if(i===0||i>s)return;const d=i/s;o=i;for(let c=0;c<n.length;c++){l=n[c];const u=Math.round((l.width-e)*d);o-=u,l.width-=u}o!==0&&(r[r.length-1].width-=o);for(let c=0;c<this.contentItems.length;c++)this.contentItems[c].config.width=r[c].width/a.totalWidth*100}_createSplitter(e){var n;return n=new $u(this._isColumn,this._splitterSize,this._splitterGrabSize),n.on("drag",this._onSplitterDrag.bind(this,n),this),n.on("dragStop",this._onSplitterDragStop.bind(this,n),this),n.on("dragStart",this._onSplitterDragStart.bind(this,n),this),this._splitter.splice(e,0,n),n}_getItemsForSplitter(e){const n=this._splitter.indexOf(e);if(n<0)throw new Error("Splitter not found in RowOrColumn");return{before:this.contentItems[n],after:this.contentItems[n+1]}}_getMinimumDimensions(e){for(var n=0,s=0,i=0;i<e.length;++i)n=Math.max(e[i].minWidth??0,n),s=Math.max(e[i].minHeight??0,s);return{horizontal:n,vertical:s}}_onSplitterDragStart(e){const n=this._getItemsForSplitter(e),s=this.layoutManager.config.dimensions[this._isColumn?"minItemHeight":"minItemWidth"];var i=this._getMinimumDimensions(n.before.config.content??[]),o=this._isColumn?i.vertical:i.horizontal,r=this._getMinimumDimensions(n.after.config.content??[]),l=this._isColumn?r.vertical:r.horizontal;this._splitterPosition=0,this._splitterMinPosition=-1*((n.before.element[this._dimension]()??0)-(o||s)),this._splitterMaxPosition=(n.after.element[this._dimension]()??0)-(l||s)}_onSplitterDrag(e,n,s){const i=this._isColumn?s:n;this._splitterMaxPosition==null||this._splitterMinPosition==null||i>this._splitterMinPosition&&i<this._splitterMaxPosition&&(this._splitterPosition=i,e.element.css(this._isColumn?"top":"left",i))}_onSplitterDragStop(e){const n=this._getItemsForSplitter(e),s=n.before.element[this._dimension]()??0,i=n.after.element[this._dimension]()??0,o=((this._splitterPosition??0)+s)/(s+i),r=(n.before.config[this._dimension]??0)+(n.after.config[this._dimension]??0);n.before.config[this._dimension]=o*r,n.after.config[this._dimension]=(1-o)*r,e.element.css({top:0,left:0}),bl(this.callDownwards.bind(this,"setSize",void 0,void 0,void 0))}}class Sa extends Tt{constructor(e,n,s){super(e,{...n,type:"root"},null,pe('<div class="lm_goldenlayout lm_item lm_root"></div>')),this.isRoot=!0,this.type="root",this.childElementContainer=this.element,this._containerElement=s,this._containerElement.append(this.element)}addChild(e,n){if(this.contentItems.length>0)throw new Error("Root node can only have a single child");e=this.layoutManager._$normalizeContentItem(e,this),this.childElementContainer.append(e.element),super.addChild(e,n),this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged")}setSize(e,n){e=typeof e>"u"?this._containerElement.width()??0:e,n=typeof n>"u"?this._containerElement.height()??0:n,this.element.width(e),this.element.height(n),this.contentItems[0]&&(this.contentItems[0].element.width(e),this.contentItems[0].element.height(n))}_$getArea(){const e=super._$getArea();if(e==null)throw new Error("Unable to get root area");return e}_$highlightDropZone(e,n,s){this.layoutManager.tabDropPlaceholder.remove(),super._$highlightDropZone(e,n,s)}_$onDrop(e,n){var s;if(hn(e)&&(s=this.layoutManager.createContentItem({type:"stack",header:e.config.header||{}},this),s._$init(),s.addChild(e),e=s),!this.contentItems.length)this.addChild(e);else{const{side:i}=n,o=i==="left"||i==="right"?"row":"column",r=i==="left"||i==="right"?"width":"height",l=i==="left"||i==="top",a=this.contentItems[0];if(!(a instanceof $r)||a.type!=o){const d=this.layoutManager.createContentItem({type:o},this);this.replaceChild(a,d),d.addChild(e,l?0:void 0,!0),d.addChild(a,l?void 0:0,!0),a.config[r]=50,e.config[r]=50,d.callDownwards("setSize")}else{const d=a.contentItems[l?0:a.contentItems.length-1];a.addChild(e,l?0:void 0,!0),d.config[r]=(d.config[r]??0)*.5,e.config[r]=d.config[r],a.callDownwards("setSize")}}}}class ba extends Tt{constructor(e,n,s){super(e,n,s,pe('<div class="lm_item lm_stack"></div>')),this._activeContentItem=null,this.childElementContainer=pe('<div class="lm_items"></div>'),this.isStack=!0,this._dropZones={},this._dropSegment=null,this._contentAreaDimensions=null,this._sided=!1,this.parent=s,this.config=n;const i=e.config;this._side=!1,this._header={show:i.settings?.hasHeaders&&n.hasHeaders!==!1,popout:i.settings?.showPopoutIcon?i.labels?.popout:void 0,maximise:i.settings?.showMaximiseIcon?i.labels?.maximise:void 0,close:i.settings?.showCloseIcon?i.labels?.close:void 0,minimise:i.labels?.minimise??void 0},i.header&&(this._header={...this._header,...i.header}),n.header&&(this._header={...this._header,...n.header}),n.content&&n.content[0]&&n.content[0].header&&(this._header={...this._header,...n.content[0].header}),this.header=new Ho(e,this),this.element.append(this.header.element),this.element.append(this.childElementContainer),this._setupHeaderPosition(),this._$validateClosability()}setSize(){var e,n=this._header.show?this.layoutManager.config.dimensions?.headerHeight??0:0,s=(this.element.width()??0)-(this._sided?n:0),i=(this.element.height()??0)-(this._sided?0:n);for(this.childElementContainer.width(s),this.childElementContainer.height(i),e=0;e<this.contentItems.length;e++)this.contentItems[e].element.width(s).height(i);this.emit("resize"),this.emitBubblingEvent("stateChanged")}_$init(){if(this.isInitialised!==!0){this.header._attachWheelListener(),super._$init();for(let e=0;e<this.contentItems.length;e++)this.header.createTab(this.contentItems[e]),this.contentItems[e]._$hide();if(this.contentItems.length>0){const e=this.contentItems[this.config.activeItemIndex||0];if(!e)throw new Error("Configured activeItemIndex out of bounds");this.setActiveContentItem(e)}}}setActiveContentItem(e){if(this.contentItems.indexOf(e)===-1)throw new Error("contentItem is not a child of this stack");this._activeContentItem!==null&&this._activeContentItem._$hide(),this._activeContentItem=e,this.header.setActiveContentItem(e),e._$show(),this.emit("activeContentItemChanged",e),this.layoutManager.emit("activeContentItemChanged",e),this.emitBubblingEvent("stateChanged")}getActiveContentItem(){return this.header.activeContentItem}addChild(e,n){e=this.layoutManager._$normalizeContentItem(e,this),super.addChild(e,n),this.childElementContainer.append(e.element),this.header.createTab(e,n),this.setActiveContentItem(e),this.callDownwards("setSize"),this._$validateClosability(),this.emitBubblingEvent("stateChanged")}removeChild(e,n=!1){var s=this.contentItems.indexOf(e);super.removeChild(e,n),this.header.removeTab(e),this.header.activeContentItem===e&&(this.contentItems.length>0?this.setActiveContentItem(this.contentItems[Math.max(s-1,0)]):this._activeContentItem=null),this._$validateClosability(),this.emitBubblingEvent("stateChanged")}_$validateClosability(){let e=this.header._isClosable();for(let n=0,s=this.contentItems.length;n<s&&e;n++)e=this.contentItems[n].config.isClosable??!1;this.header._$setClosable(e)}_$destroy(){Tt.prototype._$destroy.call(this),this.header._$destroy()}_$onDrop(e){if(this._dropSegment==="header"){this._resetHeaderDropZone(),this.addChild(e,this._dropIndex);return}if(this._dropSegment==="body"){this.addChild(e);return}const n=this._dropSegment==="top"||this._dropSegment==="bottom",s=this._dropSegment==="left"||this._dropSegment==="right",i=this._dropSegment==="top"||this._dropSegment==="left",o=n&&this.parent.isColumn||s&&this.parent.isRow,r=n?"column":"row",l=n?"height":"width";if(hn(e)){const a=this.layoutManager.createContentItem({type:"stack",header:e.config.header||{}},this);a._$init(),a.addChild(e),e=a}if(o){const a=this.parent.contentItems.indexOf(this);this.parent.addChild(e,i?a:a+1,!0),this.config[l]=(this.config[l]??0)*.5,e.config[l]=this.config[l],this.parent.callDownwards("setSize")}else{const a=this.layoutManager.createContentItem({type:r},this);this.parent.replaceChild(this,a),a.addChild(e,i?0:void 0,!0),a.addChild(this,i?void 0:0,!0),this.config[l]=50,e.config[l]=50,a.callDownwards("setSize")}}_$highlightDropZone(e,n){if(!!this._contentAreaDimensions)for(let[s,i]of Object.entries(this._contentAreaDimensions)){const o=i.hoverArea;if(o.x1<e&&o.x2>e&&o.y1<n&&o.y2>n){s==="header"?(this._dropSegment="header",this._highlightHeaderDropZone(e)):(this._resetHeaderDropZone(),this._highlightBodyDropZone(s));return}}}_$getArea(){if(this.element.is(":visible")===!1)return null;const e=super._$getArea(this.header.element),n=super._$getArea(this.childElementContainer);if(e==null||n==null)return null;const s=n.x2-n.x1,i=n.y2-n.y1;return this._contentAreaDimensions={header:{hoverArea:{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2},highlightArea:{x1:e.x1,y1:e.y1,x2:e.x2,y2:e.y2}}},this._activeContentItem&&this._activeContentItem.isComponent===!1?e:this.contentItems.length===0?(this._contentAreaDimensions.body={hoverArea:{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2},highlightArea:{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2}},super._$getArea(this.element)):(this._contentAreaDimensions.left={hoverArea:{x1:n.x1,y1:n.y1,x2:n.x1+s*.25,y2:n.y2},highlightArea:{x1:n.x1,y1:n.y1,x2:n.x1+s*.5,y2:n.y2}},this._contentAreaDimensions.top={hoverArea:{x1:n.x1+s*.25,y1:n.y1,x2:n.x1+s*.75,y2:n.y1+i*.5},highlightArea:{x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y1+i*.5}},this._contentAreaDimensions.right={hoverArea:{x1:n.x1+s*.75,y1:n.y1,x2:n.x2,y2:n.y2},highlightArea:{x1:n.x1+s*.5,y1:n.y1,x2:n.x2,y2:n.y2}},this._contentAreaDimensions.bottom={hoverArea:{x1:n.x1+s*.25,y1:n.y1+i*.5,x2:n.x1+s*.75,y2:n.y2},highlightArea:{x1:n.x1,y1:n.y1+i*.5,x2:n.x2,y2:n.y2}},super._$getArea(this.element))}_highlightHeaderDropZone(e){const n=this.header.tabs.length;if(n===0){const u=this.header.element.offset();this.layoutManager.dropTargetIndicator?.highlightArea({x1:u?.left??0,x2:(u?.left??0)+100,y1:this.header.element.offset()?.top??0,y2:(this.header.element.offset()?.top??0)+(this.header.element.innerHeight()??0)});return}const i=this.header.tabsContainer.get(0)?.getBoundingClientRect(),o=this.layoutManager.tabDropPlaceholder.get(0)?.getBoundingClientRect();if(!i||!o)return;e<i.left?e=i.left+1:e>i.right&&(e=i.right-1);let r,l;if(!(o.left<e&&e<o.right)){for(var a=0;a<n;a++)if(r=this.header.tabs[a].element,l=r.get(0)?.getBoundingClientRect(),l&&l.left<e&&e<l.right){this._dropIndex=a;break}r&&l&&e<l.left+l.width*.5?r.before(this.layoutManager.tabDropPlaceholder):r&&(this._dropIndex=Math.min((this._dropIndex??0)+1,n),r.after(this.layoutManager.tabDropPlaceholder))}let d=this.layoutManager.tabDropPlaceholder.offset()?.left??0;d=Math.max(d,this.header.tabsContainer.offset()?.left??0);var c=d+(this.layoutManager.tabDropPlaceholder.width()??0);c=Math.min(c,(this.header.tabsContainer.offset()?.left??0)+(this.header.tabsContainer.innerWidth()??0)),this.layoutManager.dropTargetIndicator?.highlightArea({x1:d,x2:c,y1:this.header.element.offset()?.top??0,y2:(this.header.element.offset()?.top??0)+(this.header.element.innerHeight()??0)})}_resetHeaderDropZone(){this.layoutManager.tabDropPlaceholder.remove()}_setupHeaderPosition(){const e=["right","left","bottom"].some(n=>n===this._header.show)?this._header.show:void 0;if(this.header.element.toggle(!!this._header.show),!!e&&(this._side=e,this._sided=["right","left"].indexOf(this._side.toString())>=0,this.element.removeClass("lm_left lm_right lm_bottom"),this._side&&this.element.addClass("lm_"+this._side),this.element.find(".lm_header").length&&this.childElementContainer)){const n=["right","bottom"].indexOf(this._side.toString())>=0?"before":"after";this.header.element[n](this.childElementContainer),this.callDownwards("setSize")}}_highlightBodyDropZone(e){const n=this._contentAreaDimensions?.[e]?.highlightArea;n&&this.layoutManager.dropTargetIndicator?.highlightArea(n),this._dropSegment=e}}const VS=Object.freeze(Object.defineProperty({__proto__:null,AbstractContentItem:Tt,ContentItem:Tt,Component:Vu,Root:Sa,RowOrColumn:$r,Stack:ba,isStack:_o,isComponent:hn,isRoot:Uu},Symbol.toStringTag,{value:"Module"})),Bu=class{constructor(t,e){this.element=pe(Bu._template),this.isActive=!1,this.header=t,this.contentItem=e,this.titleElement=this.element.find(".lm_title"),this.closeElement=this.element.find(".lm_close_tab"),this.closeElement[e.config.isClosable?"show":"hide"](),this.setTitle(e.config.title),this.contentItem.on("titleChanged",this.setTitle,this),this._layoutManager=this.contentItem.layoutManager,this._layoutManager.config.settings?.reorderEnabled&&e.config.reorderEnabled&&(this._dragListener=new Lo(this.element),this._dragListener.on("dragStart",this._onDragStart,this),this.contentItem.on("destroy",this._dragListener.destroy,this._dragListener)),this._onTabClick=this._onTabClick.bind(this),this._onCloseClick=this._onCloseClick.bind(this),this._onTabContentFocusIn=this._onTabContentFocusIn.bind(this),this._onTabContentFocusOut=this._onTabContentFocusOut.bind(this),this.element.on("click",this._onTabClick),this.element.on("auxclick",this._onTabClick),this.contentItem.config.isClosable?(this.closeElement.on("click",this._onCloseClick),this.closeElement.on("mousedown",this._onCloseMousedown)):this.closeElement.remove(),this.contentItem.tab=this,this.contentItem.emit("tab",this),this.contentItem.layoutManager.emit("tabCreated",this),hn(this.contentItem)&&(this.contentItem.container._contentElement.on("focusin",this._onTabContentFocusIn).on("focusout",this._onTabContentFocusOut),this.contentItem.container._contentElement[0].addEventListener("click",this._onTabContentFocusIn,!0),this.contentItem.container.tab=this,this.contentItem.container.emit("tab",this))}setTitle(t=""){this.titleElement.html(t)}setActive(t){t!==this.isActive&&(this.isActive=t,t?this.element.addClass("lm_active"):this.element.removeClass("lm_active"))}_$destroy(){this.element.off("click",this._onTabClick),this.element.off("auxclick",this._onTabClick),this.closeElement.off("click",this._onCloseClick),hn(this.contentItem)&&(this.contentItem.container._contentElement.off(),this.contentItem.container._contentElement[0].removeEventListener("click",this._onTabContentFocusIn,!0)),this._dragListener&&(this.contentItem.off("destroy",this._dragListener.destroy,this._dragListener),this._dragListener.off("dragStart",this._onDragStart),this._dragListener=void 0),this.element.remove()}_onDragStart(t,e){this.contentItem.parent?.isMaximised&&this.contentItem.parent.toggleMaximise(),this._dragListener&&new Po(t,e,this._dragListener,this._layoutManager,this.contentItem,this.header.parent)}_onTabContentFocusIn(){hn(this.contentItem)&&!this.contentItem.container._contentElement[0].contains(document.activeElement)&&this.contentItem.container._contentElement[0].focus(),this.element.addClass("lm_focusin")}_onTabContentFocusOut(){hn(this.contentItem)&&!this.contentItem.container._contentElement[0].contains(document.activeElement)&&this.element.removeClass("lm_focusin")}_onTabClick(t){if(!t||t.button===0){var e=this.header.parent.getActiveContentItem();this.contentItem!==e&&hn(this.contentItem)?(this.header.parent.setActiveContentItem(this.contentItem),this.contentItem.container.emit("tabClicked")):hn(this.contentItem)&&!this.contentItem.container._contentElement[0].contains(document.activeElement)&&(this.contentItem.container._contentElement.focus(),this.contentItem.container.emit("tabClicked")),this.header._hideAdditionalTabsDropdown(),this.element.get(0)?.scrollIntoView({inline:"nearest"})}else t.button===1&&this.contentItem.config.isClosable&&this._onCloseClick(t)}_onCloseClick(t){t.stopPropagation(),hn(this.contentItem)?this.contentItem.container.close():this.header.parent.removeChild(this.contentItem)}_onCloseMousedown(t){t.stopPropagation()}};let Ja=Bu;Ja._template=['<li class="lm_tab">','<span class="lm_title_before"></span>','<span class="lm_title"></span>','<div class="lm_close_tab"></div>',"</li>"].join("");const yr=class extends pn{constructor(t,e){super(),this.element=pe(yr._template),this.tabDropdownList=null,this.tabs=[],this.activeContentItem=null,this.closeButton=null,this.tabDropdownButton=null,this.tabNextButton=pe(yr._nextButtonTemplate),this.tabPreviousButton=pe(yr._previousButtonTemplate),this.holdTimer=null,this.rAF=null,this.CLICK_TIMEOUT=500,this.START_SPEED=.01,this.ACCELERATION=5e-4,this.SCROLL_LEFT="left",this.SCROLL_RIGHT="right",this.isDraggingTab=!1,this.isOverflowing=!1,this.isDropdownShown=!1,this.dropdownKeyIndex=0,this._lastVisibleTabIndex=-1,this.layoutManager=t,this.layoutManager.config.settings?.selectionEnabled&&(this.element.addClass("lm_selectable"),this.element.on("click",this._onHeaderClick.bind(this))),this.tabsContainer=this.element.find(".lm_tabs"),this.tabDropdownContainer=this.element.find(".lm_tabdropdown_list"),this.tabDropdownContainer.hide(),this.tabDropdownSearch=this.element.find(".lm_tabdropdown_search input"),this._handleFilterInput=this._handleFilterInput.bind(this),this._handleFilterKeydown=this._handleFilterKeydown.bind(this),this.tabDropdownSearch.on("input",this._handleFilterInput),this.tabDropdownSearch.on("keydown",this._handleFilterKeydown),this.controlsContainer=this.element.find(".lm_controls"),this.parent=e,this.parent.on("resize",this._updateTabSizes,this),this._handleItemPickedUp=this._handleItemPickedUp.bind(this),this._handleItemDropped=this._handleItemDropped.bind(this),this._handleNextMouseEnter=this._handleNextMouseEnter.bind(this),this._handleNextMouseLeave=this._handleNextMouseLeave.bind(this),this._handlePreviousMouseEnter=this._handlePreviousMouseEnter.bind(this),this._handlePreviousMouseLeave=this._handlePreviousMouseLeave.bind(this),this._handleScrollRepeat=this._handleScrollRepeat.bind(this),this._handleNextButtonMouseDown=this._handleNextButtonMouseDown.bind(this),this._handlePreviousButtonMouseDown=this._handlePreviousButtonMouseDown.bind(this),this._handleScrollButtonMouseDown=this._handleScrollButtonMouseDown.bind(this),this._handleScrollButtonMouseUp=this._handleScrollButtonMouseUp.bind(this),this._handleScrollEvent=this._handleScrollEvent.bind(this),this.tabNextButton.on("mousedown",this._handleNextButtonMouseDown),this.tabPreviousButton.on("mousedown",this._handlePreviousButtonMouseDown),this.tabsContainer.on("scroll",this._handleScrollEvent),this.layoutManager.on("itemPickedUp",this._handleItemPickedUp),this.layoutManager.on("itemDropped",this._handleItemDropped),this.tabsContainer.before(this.tabPreviousButton),this.tabPreviousButton=this.tabPreviousButton.find(">:first-child"),this.tabPreviousButton.hide(),this._showAdditionalTabsDropdown=this._showAdditionalTabsDropdown.bind(this),this._hideAdditionalTabsDropdown=this._hideAdditionalTabsDropdown.bind(this),this._tabControlOffset=this.layoutManager.config.settings?.tabControlOffset,this._createControls()}createTab(t,e){for(let s=0;s<this.tabs.length;s++)if(this.tabs[s].contentItem===t)return;const n=new Ja(this,t);if(this.tabs.length===0){this.tabs.push(n),this.tabsContainer.append(n.element);return}e===void 0&&(e=this.tabs.length),e>0?this.tabs[e-1].element.after(n.element):this.tabs[0].element.before(n.element),this.tabs.splice(e,0,n),this._updateTabSizes()}removeTab(t){for(var e=0;e<this.tabs.length;e++)if(this.tabs[e].contentItem===t){this.tabs[e]._$destroy(),this.tabs.splice(e,1);return}throw new Error("contentItem is not controlled by this header")}setActiveContentItem(t){for(var e,n=0;n<this.tabs.length;n++)e=this.tabs[n].contentItem===t,this.tabs[n].setActive(e),e===!0&&(this.activeContentItem=t,this.parent.config.activeItemIndex=n);this.tabs[this.parent.config.activeItemIndex??0].element.get(0)?.scrollIntoView({inline:"nearest"}),this._hideAdditionalTabsDropdown(),this._updateTabSizes(),this.parent.emitBubblingEvent("stateChanged")}position(t){let e=this.parent._header.show;return e&&!this.parent._side&&(e="top"),t!==void 0&&this.parent._header.show!==t&&(this.parent._header.show=t,this.parent._setupHeaderPosition()),e}_attachWheelListener(){this.tabsContainer.get(0)?.addEventListener("wheel",this._handleWheelEvent,{passive:!0})}_detachWheelListener(){this.tabsContainer.get(0)?.removeEventListener("wheel",this._handleWheelEvent)}_handleWheelEvent(t){const e=t.currentTarget;if(!(e instanceof HTMLElement))return;let n=Math.abs(t.deltaY)>Math.abs(t.deltaX)?t.deltaY:t.deltaX;t.deltaMode===WheelEvent.DOM_DELTA_PAGE?n*=this.tabsContainer.innerWidth()??1:t.deltaMode===WheelEvent.DOM_DELTA_LINE&&(n*=100/3),e.scrollLeft+=Math.round(n)}_handleScrollEvent(){this._checkScrollArrows()}_handleItemPickedUp(){this.isDraggingTab=!0,this.controlsContainer.on("mouseenter",this._handleNextMouseEnter),this.tabPreviousButton.on("mouseenter",this._handlePreviousMouseEnter)}_handleItemDropped(){this.isDraggingTab=!1,window.cancelAnimationFrame(this.rAF??-1),this.rAF=null,this.controlsContainer.off("mouseenter",this._handleNextMouseEnter),this.controlsContainer.off("mouseleave",this._handleNextMouseLeave),this.tabPreviousButton.off("mouseenter",this._handlePreviousMouseEnter),this.tabPreviousButton.off("mouseleave",this._handlePreviousMouseLeave)}_handleNextMouseEnter(){this.controlsContainer.on("mouseleave",this._handleNextMouseLeave),this._handleScrollRepeat(this.SCROLL_RIGHT,this.tabsContainer.scrollLeft()??0)}_handlePreviousMouseEnter(){this.tabPreviousButton.on("mouseleave",this._handlePreviousMouseLeave),this._handleScrollRepeat(this.SCROLL_LEFT,this.tabsContainer.scrollLeft()??0)}_handleNextMouseLeave(){window.cancelAnimationFrame(this.rAF??-1),this.rAF=null,this.controlsContainer.off("mouseleave",this._handleNextMouseLeave)}_handlePreviousMouseLeave(){window.cancelAnimationFrame(this.rAF??-1),this.rAF=null,this.tabPreviousButton.off("mouseleave",this._handlePreviousMouseLeave)}_handleNextButtonMouseDown(){var t;for(let e=0;e<this.tabs.length;e+=1)if((this.tabs[e].element.get(0)?.offsetLeft??0)>(this.tabsContainer.get(0)?.offsetWidth??0)+(this.tabsContainer.scrollLeft()??0)){t=this.tabs[e].element.get(0);break}if(t)t.scrollIntoView({behavior:"smooth",inline:"nearest"}),this._handleScrollButtonMouseDown(this.SCROLL_RIGHT);else{const e=this.tabsContainer.get(0);e&&(e.scrollLeft=this.tabsContainer.get(0)?.scrollWidth??0)}}_handlePreviousButtonMouseDown(){for(var t,e=this.tabs.length-1;e>=0;e-=1)if((this.tabs[e].element.get(0)?.offsetLeft??0)<(this.tabsContainer.scrollLeft()??0)){t=this.tabs[e].element.get(0);break}if(t)t.scrollIntoView({behavior:"smooth",inline:"start"}),this._handleScrollButtonMouseDown(this.SCROLL_LEFT);else{const n=this.tabsContainer.get(0);n&&(n.scrollLeft=0)}}_handleScrollButtonMouseDown(t){this.holdTimer=window.setTimeout(()=>{this._handleScrollRepeat(t,this.tabsContainer.scrollLeft()??0,100)},this.CLICK_TIMEOUT),window.addEventListener("mouseup",this._handleScrollButtonMouseUp)}_handleScrollButtonMouseUp(){clearTimeout(this.holdTimer??-1),this.holdTimer=null,cancelAnimationFrame(this.rAF??-1),this.rAF=null,window.removeEventListener("mouseup",this._handleScrollButtonMouseUp)}_checkScrollArrows(){this.tabsContainer.scrollLeft()===0?this.tabPreviousButton.first().prop("disabled",!0):(this.tabsContainer.scrollLeft()??0)+(this.tabsContainer.innerWidth()??0)===this.tabsContainer.get(0)?.scrollWidth?this.tabNextButton.prop("disabled",!0):(this.tabNextButton.prop("disabled",!1),this.tabPreviousButton.first().prop("disabled",!1))}_handleScrollRepeat(t,e,n=0,s){const i=this.tabsContainer.get(0);if(!i)return;const o=i.getBoundingClientRect();if(t===this.SCROLL_LEFT){if(this.tabsContainer.scrollLeft(e-n),this.isDraggingTab&&this.parent._highlightHeaderDropZone(o.left-1),this.tabsContainer.scrollLeft()===0){this._checkScrollArrows();return}}else if(t===this.SCROLL_RIGHT&&(this.tabsContainer.scrollLeft(e+n),this.isDraggingTab&&this.parent._highlightHeaderDropZone(o.right+1),(this.tabsContainer.scrollLeft()??0)+(this.tabsContainer.innerWidth()??0)===i.scrollWidth)){this._checkScrollArrows();return}window.cancelAnimationFrame(this.rAF??-1),this.rAF=window.requestAnimationFrame(r=>{var l=s||r,a=r-l,d=this.START_SPEED*a+.5*this.ACCELERATION*(a*a);d=Math.min(d,this.tabsContainer.get(0)?.scrollWidth??1/0),this._handleScrollRepeat(t,e,d,l)})}_$setClosable(t){return this.closeButton&&this._isClosable()?(this.closeButton.element[t?"show":"hide"](),!0):!1}_$destroy(){this.emit("destroy",this);for(var t=0;t<this.tabs.length;t++)this.tabs[t]._$destroy();this._detachWheelListener(),this._handleItemDropped(),pe(document).off("mouseup",this._hideAdditionalTabsDropdown),this.tabDropdownSearch.off("input",this._handleFilterInput),this.tabDropdownSearch.off("keydown",this._handleFilterKeydown),this.element.remove()}_getHeaderSetting(t){if(t in this.parent._header)return this.parent._header[t]}_createControls(){var t,e,n,s,i;if(i=this.layoutManager.config.labels.tabDropdown,this.layoutManager.config.labels.tabNextLabel,this.layoutManager.config.labels.tabPreviousLabel,this.tabDropdownButton=new Co(this,i,"lm_tabdropdown",this._showAdditionalTabsDropdown),this.tabDropdownButton.element.hide(),this.controlsContainer.prepend(this.tabNextButton),this.tabNextButton.hide(),this._getHeaderSetting("popout")&&(e=this._onPopoutClick.bind(this),n=this._getHeaderSetting("popout"),new Co(this,n,"lm_popout",e)),this._getHeaderSetting("maximise")){s=this.parent.toggleMaximise.bind(this.parent);const o=this._getHeaderSetting("maximise"),r=this._getHeaderSetting("minimise"),l=new Co(this,o,"lm_maximise",s);this.parent.on("maximised",function(){l.element.attr("title",r??"")}),this.parent.on("minimised",function(){l.element.attr("title",o??"")})}this._isClosable()&&(t=this.parent.remove.bind(this.parent),n=this._getHeaderSetting("close"),this.closeButton=new Co(this,n,"lm_close",t))}_showAdditionalTabsDropdown(){if(this.isDropdownShown){this._hideAdditionalTabsDropdown();return}this.tabDropdownList=this.tabsContainer.clone(!0).appendTo(this.tabDropdownContainer).children().removeClass("lm_active"),this.tabDropdownContainer.show(),this.isDropdownShown=!0,this.element.addClass("lm_dropdown_open"),this.tabDropdownSearch.val("").focus(),this.dropdownKeyIndex=0,this.tabDropdownList.eq(this.dropdownKeyIndex).addClass("lm_keyboard_active"),pe(document).on("mousedown",this._hideAdditionalTabsDropdown),this._updateAdditionalTabsDropdown()}_handleFilterKeydown(t){if(this.dropdownKeyIndex===-1)return;if(t.key==="Escape"){this._hideAdditionalTabsDropdown();return}if(t.key==="Enter"||t.key===" "){this._hideAdditionalTabsDropdown(),this.tabs[this.dropdownKeyIndex]._onTabClick();return}function e(n,s,i){if(i==null||i.length<2)return-1;for(var o=(n+s+i.length)%i.length;o!==n;){if(i.eq(o).css("display")!=="none")return o;o=(o+s+i.length)%i.length}return n}t.key==="ArrowDown"||t.key==="Tab"&&t.shiftKey===!1?(t.preventDefault(),this.tabDropdownList?.eq(this.dropdownKeyIndex).removeClass("lm_keyboard_active"),this.dropdownKeyIndex=e(this.dropdownKeyIndex,1,this.tabDropdownList),this.tabDropdownList?.eq(this.dropdownKeyIndex).addClass("lm_keyboard_active")):(t.key==="ArrowUp"||t.key==="Tab")&&(t.preventDefault(),this.tabDropdownList?.eq(this.dropdownKeyIndex).removeClass("lm_keyboard_active"),this.dropdownKeyIndex=e(this.dropdownKeyIndex,-1,this.tabDropdownList),this.tabDropdownList?.eq(this.dropdownKeyIndex).addClass("lm_keyboard_active"))}_handleFilterInput(t){if(this.tabDropdownList!=null){this.tabDropdownList.eq(this.dropdownKeyIndex).removeClass("lm_keyboard_active"),this.dropdownKeyIndex=-1;for(var e=0;e<this.tabDropdownList.length;e++)(this.tabs[e].contentItem.config.title?.toLowerCase().indexOf(t.target.value.toLowerCase())??-1)!==-1?(this.tabDropdownList.eq(e).css("display",""),this.dropdownKeyIndex===-1&&(this.dropdownKeyIndex=e)):this.tabDropdownList.eq(e).css("display","none");this.dropdownKeyIndex!==-1&&this.tabDropdownList.eq(this.dropdownKeyIndex).addClass("lm_keyboard_active")}}_hideAdditionalTabsDropdown(t){!this.isDropdownShown||t&&this.tabDropdownContainer.get(0)?.contains(t.target)||t&&this.tabDropdownButton?.element.get(0)===t.target||(this.element.removeClass("lm_dropdown_open"),this.tabDropdownContainer.hide(),this.isDropdownShown=!1,this.tabDropdownContainer.find(".lm_tabs").remove(),pe(document).off("mousedown",this._hideAdditionalTabsDropdown))}_updateAdditionalTabsDropdown(){this.tabDropdownContainer.css("max-height","");const t=this.tabDropdownContainer[0].scrollHeight;if(t===0)return;const e=(this.tabDropdownContainer.offset()?.top??0)-(pe(window).scrollTop()??0);e+t>(pe(window).height()??0)&&this.tabDropdownContainer.css("max-height",(pe(window).height()??0)-e-10)}_isClosable(){return Boolean(this.parent.config.isClosable&&this.layoutManager.config.settings.showCloseIcon)}_onPopoutClick(){this.layoutManager.config.settings.popoutWholeStack===!0?this.parent.popout():this.activeContentItem?.popout()}_onHeaderClick(t){t.target===this.element[0]&&this.parent.select()}_updateTabSizes(){if(this.tabs.length===0)return;const t=this.tabsContainer.get(0);!t||(!this.isOverflowing&&t.scrollWidth>t.clientWidth?(this.tabDropdownButton?.element.show(),this.tabNextButton.show(),this.tabPreviousButton.show(),this.isOverflowing=!0):this.isOverflowing&&t.scrollWidth<=t.clientWidth&&(this.tabDropdownButton?.element.hide(),this.tabNextButton.hide(),this.tabPreviousButton.hide(),this.isOverflowing=!1),this.isOverflowing&&this._checkScrollArrows())}};let Ho=yr;Ho._template=['<div class="lm_header">','<ul class="lm_tabs"></ul>','<ul class="lm_controls"></ul>','<ul class="lm_tabdropdown_list">','<li class="lm_tabdropdown_search"><input type="text" placeholder="Find tab..."></li>',"</ul>","</div>"].join("");Ho._previousButtonTemplate=['<ul class="lm_controls">','<li class="lm_tabpreviousbutton"></li>',"</ul>"].join("");Ho._nextButtonTemplate=['<li class="lm_tabnextbutton"></li>'].join("");class $u{constructor(e,n,s){this._isVertical=e,this._size=n,this._grabSize=s<n?n:s,this.element=this._createElement(),this._dragListener=new Lo(this.element)}on(e,n,s){this._dragListener?.on(e,n,s)}_$destroy(){this._dragListener?.destroy(),this._dragListener=null,this.element.remove()}_createElement(){var e=pe('<div class="lm_drag_handle"></div>'),n=pe('<div class="lm_splitter"></div>');n.append(e);var s=this._grabSize-this._size,i=s/2;return this._isVertical?(e.css("top",-i),e.css("height",this._size+s),n.addClass("lm_vertical"),n.height(this._size)):(e.css("left",-i),e.css("width",this._size+s),n.addClass("lm_horizontal"),n.width(this._size)),n}}class Gu{constructor(){this._element=pe('<div class="lm_transition_indicator"></div>'),this._toElement=null,this._fromDimensions={},this._totalAnimationDuration=200,this._animationStartTime=null,pe(document.body).append(this._element)}destroy(){this._element.remove()}transitionElements(e,n){}_nextAnimationFrame(){if(!this._toElement||this._animationStartTime==null)return;const e=this._measure(this._toElement),n=(Date.now()-this._animationStartTime)/this._totalAnimationDuration,s={};if(n>=1){this._element.hide();return}e.opacity=0;const i=Object.keys(this._fromDimensions);for(let o of i)s[o]=(this._fromDimensions[o]??0)+((e[o]??0)-(this._fromDimensions[o]??0))*n;this._element.css(s),bl(this._nextAnimationFrame.bind(this))}_measure(e){const n=e.offset();return{left:n?.left,top:n?.top,width:e.outerWidth(),height:e.outerHeight()}}}const BS=Object.freeze(Object.defineProperty({__proto__:null,BrowserPopout:Ou,DragProxy:Po,DragSource:Lu,DragSourceFromEvent:Pu,DropTargetIndicator:Qa,Header:Ho,HeaderButton:Co,Splitter:$u,Tab:Ja,TransitionIndicator:Gu},Symbol.toStringTag,{value:"Module"})),$S={config:MS,container:kS,controls:BS,errors:US,items:VS,utils:HS};class ed extends pn{constructor(e,n){super(),this.isInitialised=!1,this._isFullPage=!1,this._components={"lm-react-component":ku},this._itemAreas=[],this._maximisedItem=null,this._maximisePlaceholder=pe('<div class="lm_maximise_place"></div>'),this._creationTimeoutPassed=!1,this._subWindowsCreated=!1,this._dragSources=[],this._updatingColumnsResponsive=!1,this._firstLoad=!0,this.width=null,this.height=null,this.openPopouts=[],this.selectedItem=null,this.isSubWindow=!1,this.eventHub=new xu(this),this.dropTargetIndicator=null,this.transitionIndicator=null,this.tabDropPlaceholder=pe('<div class="lm_drop_tab_placeholder"></div>'),this._onResize=this._onResize.bind(this),this._onUnload=this._onUnload.bind(this),this._windowBlur=this._windowBlur.bind(this),this._windowFocus=this._windowFocus.bind(this),this.config=this._createConfig(e),this._originalContainer=n,this.container=this._getContainer(),this.isSubWindow&&pe("body").css("visibility","hidden"),this._typeToItem={column:$r.bind(this,!0),row:$r.bind(this,!1),stack:ba,component:Vu}}static minifyConfig(e){return ja(e)}static unminifyConfig(e){return fa(e)}registerComponent(e,n){if(typeof n!="function"&&(n==null||n.render==null||typeof n.render!="function"))throw new Error("Please register a constructor function");if(this._components[e]!==void 0)throw new Error("Component "+e+" is already registered");return this._components[e]=n,()=>{if(this._components[e]===void 0)throw new Error("Component "+e+" is not registered");delete this._components[e]}}setFallbackComponent(e){this._fallbackComponent=e}toConfig(e){if(this.isInitialised===!1)throw new Error("Can't create config, layout not yet initialised");if(e&&!(e instanceof Tt))throw new Error("Root must be a ContentItem");const n={settings:{...this.config.settings},dimensions:{...this.config.dimensions},labels:{...this.config.labels},content:[]},s=function(i,o){for(let r in o.config)r!=="content"&&(i[r]=o.config[r]);if(i.componentName==="lm-react-component"&&(i.type="react-component"),o.contentItems.length){i.content=[];for(let r=0;r<o.contentItems.length;r++)i.content[r]={},s(i.content[r],o.contentItems[r])}};e?s(n,{contentItems:[e]}):s(n,this.root),this._$reconcilePopoutWindows(),n.openPopouts=[];for(let i=0;i<this.openPopouts.length;i++)n.openPopouts.push(this.openPopouts[i].toConfig());return n.maximisedItemId=this._maximisedItem?"__glMaximised":void 0,n}getComponent(e){return this._components[e]}getFallbackComponent(){return this._fallbackComponent}init(){if(this._subWindowsCreated===!1&&(this._createSubWindows(),this._subWindowsCreated=!0),document.readyState==="loading"||document.body===null){pe(document).ready(this.init.bind(this));return}if(this.isSubWindow===!0&&this._creationTimeoutPassed===!1){setTimeout(this.init.bind(this),7),this._creationTimeoutPassed=!0;return}this.isSubWindow===!0&&this._adjustToWindowMode(),this._setContainer(),this.dropTargetIndicator=new Qa,this.transitionIndicator=new Gu,this.updateSize(),this._create(this.config),this._bindEvents(),this.isInitialised=!0,this._adjustColumnsResponsive(),this.emit("initialised")}updateSize(e,n){this.width=e??this.container.width()??0,this.height=n??this.container.height()??0,this.isInitialised===!0&&(this.root.callDownwards("setSize",[this.width,this.height]),this._maximisedItem&&(this._maximisedItem.element.width(this.container.width()??0),this._maximisedItem.element.height(this.container.height()??0),this._maximisedItem.callDownwards("setSize")),this._adjustColumnsResponsive())}destroy(){this.isInitialised===!1||!this.root||(this._onUnload(),pe(window).off("resize",this._onResize),pe(window).off("unload beforeunload",this._onUnload),pe(window).off("blur.lm").off("focus.lm"),this.root.callDownwards("_$destroy",[],!0),this.root.contentItems=[],this.tabDropPlaceholder.remove(),this.dropTargetIndicator?.destroy(),this.transitionIndicator?.destroy(),this.eventHub.destroy(),this._dragSources.forEach(function(e){e._dragListener.destroy()}),this._dragSources=[])}createContentItem(e,n){var s,i;if(typeof e.type!="string")throw new ni("Missing parameter 'type'",e);if(e.type==="react-component"&&(e.type="component",e.componentName="lm-react-component"),!this._typeToItem[e.type])throw s="Unknown type '"+e.type+"'. Valid types are "+Object.keys(this._typeToItem).join(","),new ni(s);return e.type==="component"&&!(n instanceof ba)&&!!n&&!(this.isSubWindow===!0&&n instanceof Sa)&&(e={type:"stack",width:e.width,height:e.height,content:[e]}),i=new this._typeToItem[e.type](this,e,n),i}createPopout(e,n,s,i){let o=[];const r=e instanceof Tt,l=this;if(r){o=this.toConfig(e).content,s=Ka();let d=e.parent,c=e;for(;d?.contentItems.length===1&&!d.isRoot;)c=d,d=d.parent;d?.addId(s),(i==null||Number.isNaN(i))&&(i=d?.contentItems.indexOf(c))}else e instanceof Array?o=e:o=[e];if(!n&&r){const d=window.screenX||window.screenLeft,c=window.screenY||window.screenTop,u=e.element.offset()??{left:0,top:0};n={left:d+u.left,top:c+u.top,width:e.element.width()??0,height:e.element.height()??0}}if(!n&&!r&&(n={left:window.screenX||window.screenLeft+20,top:window.screenY||window.screenTop+20,width:500,height:309}),r&&e.remove(),!n||!s||i===void 0)return;const a=new Ou(o,n,s,i,this);return a.on("initialised",function(){l.emit("windowOpened",a)}),a.on("closed",function(){l._$reconcilePopoutWindows()}),this.openPopouts.push(a),a}createDragSource(e,n){this.config.settings.constrainDragToContainer=!1;var s=new Lu(e,n,this);return this._dragSources.push(s),s}createDragSourceFromEvent(e,n){return this.config.settings.constrainDragToContainer=!1,new Pu(e,this,n)}selectItem(e,n){if(this.config.settings.selectionEnabled!==!0)throw new Error("Please set selectionEnabled to true to use this feature");e!==this.selectedItem&&(this.selectedItem!==null&&this.selectedItem.deselect(),e&&n!==!0&&e.select(),this.selectedItem=e,this.emit("selectionChanged",e))}_$maximiseItem(e){this._maximisedItem!==null&&this._$minimiseItem(this._maximisedItem),this._maximisedItem=e,this._maximisedItem.addId("__glMaximised"),e.element.addClass("lm_maximised"),e.element.after(this._maximisePlaceholder),this.root.element.prepend(e.element),e.element.width(this.container.width()??0),e.element.height(this.container.height()??0),e.callDownwards("setSize"),this._maximisedItem.emit("maximised"),this.emit("stateChanged")}_$minimiseItem(e){e.element.removeClass("lm_maximised"),e.removeId("__glMaximised"),this._maximisePlaceholder.after(e.element),this._maximisePlaceholder.remove(),e.parent?.callDownwards("setSize"),this._maximisedItem=null,e.emit("minimised"),this.emit("stateChanged")}_$closeWindow(){window.setTimeout(function(){window.close()},1)}_$getArea(e,n){let s=1/0,i=null;for(let o=0;o<this._itemAreas.length;o++){const r=this._itemAreas[o];e>r.x1&&e<r.x2&&n>r.y1&&n<r.y2&&s>r.surface&&(s=r.surface,i=r)}return i}_$createRootItemAreas(){const n={...this.root._$getArea()},s=[{...n,side:"left",x2:n.x1+50},{...n,side:"right",x1:n.x2-50},{...n,side:"top",y2:n.y1+50},{...n,side:"bottom",y1:n.y2-50}];s.forEach(i=>{i.surface=(i.x2-i.x1)*(i.y2-i.y1)}),this._itemAreas.push(...s)}_$calculateItemAreas(){const e=this._getAllContentItems();if(this._itemAreas=[],e.length===1){this._itemAreas.push(this.root._$getArea());return}this._$createRootItemAreas();for(let n=0;n<e.length;n++){const s=e[n];if(!_o(s))continue;const i=s._$getArea();if(i!==null)if(i instanceof Array)this._itemAreas=this._itemAreas.concat(i);else{this._itemAreas.push(i);let o={...i,...i.contentItem._contentAreaDimensions?.header.highlightArea};o.surface=(o.x2-o.x1)*(o.y2-o.y1),this._itemAreas.push(o)}}}_$normalizeContentItem(e,n){if(!e)throw new Error("No content item defined");if(typeof e=="function"&&(e=e()),e instanceof Tt)return e;if(pe.isPlainObject(e)&&e.type){var s=this.createContentItem(e,n);return s.callDownwards("_$init"),s}else throw new Error("Invalid contentItem")}_$reconcilePopoutWindows(){const e=[];for(let n=0;n<this.openPopouts.length;n++)this.openPopouts[n].getWindow()?.closed===!1?e.push(this.openPopouts[n]):this.emit("windowClosed",this.openPopouts[n]);this.openPopouts.length!==e.length&&(this.emit("stateChanged"),this.openPopouts=e)}_getAllContentItems(){const e=[],n=s=>{if(e.push(s),s.contentItems instanceof Array)for(let i=0;i<s.contentItems.length;i++)n(s.contentItems[i])};return n(this.root),e}_bindEvents(){this._isFullPage&&pe(window).resize(this._onResize),pe(window).on("unload beforeunload",this._onUnload).on("blur.lm",this._windowBlur).on("focus.lm",this._windowFocus)}_windowBlur(){this.root.element.addClass("lm_window_blur")}_windowFocus(){this.root.element.removeClass("lm_window_blur")}_onResize(){clearTimeout(this._resizeTimeoutId),this._resizeTimeoutId=window.setTimeout(this.updateSize.bind(this),100)}_createConfig(e){var n=Mu("gl-window");n&&(this.isSubWindow=!0,e=JSON.parse(localStorage.getItem(n)||"{}"),e=fa(e),localStorage.removeItem(n)),e=pe.extend(!0,{},Fu,e);var s=function(i){for(var o in i){const r=i[o];o!=="props"&&typeof r=="object"&&r!=null?s(r):o==="type"&&r==="react-component"&&(i.type="component",i.componentName="lm-react-component")}};return s(e),e.settings?.hasHeaders===!1&&(e.dimensions.headerHeight=0),e}_adjustToWindowMode(){var e=pe('<div class="lm_popin" title="'+this.config.labels.popin+'"><div class="lm_icon"></div><div class="lm_bg"></div></div>');e.click(()=>{this.emit("popIn")}),document.title=Xa(this.config.content[0].title??""),pe("head").append(pe("body link, body style, template, .gl_keep")),this.container=pe("body").html("").css("visibility","visible").append(e),document.body.offsetHeight,window.__glInstance=this}_createSubWindows(){if(!!this.config.openPopouts)for(let e=0;e<this.config.openPopouts.length;e++){const n=this.config.openPopouts[e];this.createPopout(n.content,n.dimensions,n.parentId,n.indexInParent)}}_getContainer(){const e=this._originalContainer?pe(this._originalContainer):pe("body");if(e.length===0)throw new Error("GoldenLayout container not found");if(e.length>1)throw new Error("GoldenLayout more than one container element specified");return e}_setContainer(){const e=this._getContainer();e[0]===document.body&&(this._isFullPage=!0,pe("html, body").css({height:"100%",margin:0,padding:0,overflow:"hidden"})),this.container=e}_create(e){var n;if(!(e.content instanceof Array))throw e.content===void 0?n="Missing setting 'content' on top level of configuration":n="Configuration parameter 'content' must be an array",new ni(n,e);if(e.content.length>1)throw n="Top level content can't contain more then one element.",new ni(n,e);this.root=new Sa(this,{content:e.content},this.container),this.root.callDownwards("_$init"),e.maximisedItemId==="__glMaximised"&&this.root.getItemsById(e.maximisedItemId)[0].toggleMaximise()}_onUnload(){if(this.config.settings.closePopoutsOnUnload===!0)for(var e=0;e<this.openPopouts.length;e++)this.openPopouts[e].close()}_adjustColumnsResponsive(){if(!this._useResponsiveLayout()||this._updatingColumnsResponsive||!this.config.dimensions||!this.config.dimensions.minItemWidth||this.root.contentItems.length===0||!this.root.contentItems[0].isRow){this._firstLoad=!1;return}this._firstLoad=!1;var e=this.root.contentItems[0].contentItems.length;if(!(e<=1)){var n=this.config.dimensions.minItemWidth,s=e*n;if(!(this.width==null||s<=this.width)){this._updatingColumnsResponsive=!0;for(var i=Math.max(Math.floor(this.width/n),1),o=e-i,r=this.root.contentItems[0],l=this._findAllStackContainers()[0],a=0;a<o;a++){var d=r.contentItems[r.contentItems.length-1];this._addChildContentItemsToContainer(l,d)}this._updatingColumnsResponsive=!1}}}_useResponsiveLayout(){return this.config.settings&&(this.config.settings.responsiveMode=="always"||this.config.settings.responsiveMode=="onload"&&this._firstLoad)}_addChildContentItemsToContainer(e,n){n.type==="stack"?n.contentItems.forEach(function(s){e.addChild(s),n.removeChild(s,!0)}):n.contentItems.forEach(s=>{this._addChildContentItemsToContainer(e,s)})}_findAllStackContainers(){const e=[];return this._findAllStackContainersRecursive(e,this.root),e}_findAllStackContainersRecursive(e,n){n.contentItems.forEach(s=>{_o(s)?e.push(s):s.isComponent||this._findAllStackContainersRecursive(e,s)})}}ed.__lm=$S;const GS="_lm_root_15d73_3",WS="_lm_row_15d73_7",zS="_lm_item_15d73_7",qS="_lm_content_15d73_11",YS="_lm_dragging_15d73_17",KS="_lm_maximised_15d73_23",XS="_lm_maximise_placeholder_15d73_30",jS="_lm_splitter_15d73_34",ZS="_lm_vertical_15d73_41",QS="_lm_drag_handle_15d73_41",JS="_lm_horizontal_15d73_46",eb="_lm_header_15d73_56",tb="_lm_dropdown_open_15d73_63",nb="_lm_controls_15d73_69",sb="_lm_tabs_15d73_89",ib="_lm_tab_15d73_89",ob="_lm_title_15d73_104",rb="_lm_close_tab_15d73_111",lb="_lm_stack_15d73_120",ab="_lm_left_15d73_120",db="_lm_right_15d73_121",cb="_lm_dragProxy_15d73_125",hb="_lm_items_15d73_148",ub="_lm_tabdropdown_list_15d73_165",mb="_lm_bottom_15d73_192",pb="_lm_drop_tab_placeholder_15d73_207",gb="_lm_tabdropdown_15d73_165",fb="_lm_dropTargetIndicator_15d73_258",Cb="_lm_inner_15d73_264",Sb="_lm_transition_indicator_15d73_272",bb="_lm_popin_15d73_282",wb="_lm_bg_15d73_297",Tb="_lm_icon_15d73_300",vb="_lm_goldenlayout_15d73_304",Eb="_lm_selectable_15d73_340",yb="_lm_active_15d73_370",Rb="_lm_selected_15d73_388",Ib="_lm_keyboard_active_15d73_397",Fb="_lm_popout_15d73_416",Db="_lm_maximise_15d73_23",Nb="_lm_close_15d73_111",_b="_lm_tabnextbutton_15d73_425",Mb="_lm_tabpreviousbutton_15d73_428",kb="_lm_title_before_15d73_544",xb="_lm_focusin_15d73_568",Ob="_lm_window_blur_15d73_573",Ab="_lm_tabdropdown_search_15d73_631",Lb="_march_15d73_1",Pb="_app_15d73_712",Hb="_plotly_15d73_721",Sc={"tab-height":"28px","drag-border-width":"5px",lm_root:GS,lm_row:WS,lm_item:zS,lm_content:qS,lm_dragging:YS,lm_maximised:KS,lm_maximise_placeholder:XS,lm_splitter:jS,lm_vertical:ZS,lm_drag_handle:QS,lm_horizontal:JS,lm_header:eb,lm_dropdown_open:tb,lm_controls:nb,lm_tabs:sb,lm_tab:ib,lm_title:ob,lm_close_tab:rb,lm_stack:lb,lm_left:ab,lm_right:db,lm_dragProxy:cb,lm_items:hb,lm_tabdropdown_list:ub,lm_bottom:mb,lm_drop_tab_placeholder:pb,lm_tabdropdown:gb,lm_dropTargetIndicator:fb,lm_inner:Cb,lm_transition_indicator:Sb,lm_popin:bb,lm_bg:wb,lm_icon:Tb,lm_goldenlayout:vb,lm_selectable:Eb,lm_active:yb,lm_selected:Rb,lm_keyboard_active:Ib,lm_popout:Fb,lm_maximise:Db,lm_close:Nb,lm_tabnextbutton:_b,lm_tabpreviousbutton:Mb,lm_title_before:kb,"editor-unsaved-indicator":"_editor-unsaved-indicator_15d73_548","is-unsaved":"_is-unsaved_15d73_556",lm_focusin:xb,lm_window_blur:Ob,lm_tabdropdown_search:Ab,march:Lb,app:Pb,"js-plotly-plot":"_js-plotly-plot_15d73_721",plotly:Hb},bc=Object.freeze({tabHeight:parseInt(Sc["tab-height"],10),dragBorderWidth:parseInt(Sc["drag-border-width"],10)}),Ss=ee.module("LayoutUtils");function Wu(t){return t.componentName!==void 0}function Ri(t){const e=t;return(Wu(t)&&t.componentName==="lm-react-component"||t.type==="react-component")&&e.component!==void 0}function rr(t){return t.focus!==void 0}function wc(t){return t.type==="stack"}const Ve=class{static activateTab(t,e){const n=Ve.getStackForRoot(t,e,!1);if(!n){Ss.error("Could not find stack for config",e);return}const s=Ve.getContentItemInStack(n,e);s&&n.setActiveContentItem(s)}static isActiveTab(t,e){const n=Ve.getStackForRoot(t,e,!1);if(!n)return Ss.error("Could not find stack for config",e),!1;const s=Ve.getContentItemInStack(n,e);return n.getActiveContentItem()===s}static addStack(t,e=!0){const n=e?"column":"row";if(Uu(t)){(t.contentItems==null||t.contentItems.length===0)&&t.addChild({type:n});const o=t.contentItems[0];if(!(e?o.isColumn:o.isRow)){t.removeChild(o,!0),t.addChild({type:n});const l=document.activeElement;t.contentItems[0].addChild(o),l&&l.focus!=null&&l.focus()}return this.addStack(t.contentItems[0],e)}if(t.contentItems.length<2)return t.addChild({type:"stack"}),t.contentItems[t.contentItems.length-1];let s=t.contentItems[t.contentItems.length-1];return(e?s.isRow:s.isColumn)||(t.addChild({type:e?"row":"column"}),t.removeChild(s,!0),t.contentItems[t.contentItems.length-1].addChild(s),s=t.contentItems[t.contentItems.length-1]),this.addStack(s,!e)}static getStackForConfig(t,e={},n=!1){if(n&&_o(t)&&t.contentItems.length===0)return t;if(t.contentItems==null)return null;for(let s=0;s<t.contentItems.length;s+=1){const i=t.contentItems[s];if(i.isComponent&&i.config!=null&&Hd(i.config,e))return t;const o=this.getStackForConfig(i,e,n);if(o)return o}return null}static getStackForRoot(t,e,n=!0,s=!0,i=!0){let o=this.getStackForConfig(t,e);return!o&&s&&(o=this.getStackForConfig(t,{component:e.component},i)),!o&&n&&(o=this.addStack(t)),o}static getStackForComponentTypes(t,e,n=!0,s=!0,i=!0){for(let o=0;o<e.length;o+=1){const r=e[o],l=o===e.length-1,a=Ve.getStackForRoot(t,{component:r},n&&l,s,i);if(a)return a}return null}static getContentItemInStack(t,e){if(!t)return null;for(let n=0;n<t.contentItems.length;n+=1){const s=t.contentItems[n];if(s.isComponent&&s.config!=null&&Hd(s.config,e))return s}return null}static dehydrateLayoutConfig(t,e){if(t==null||!t.length)return[];const n=[];for(let s=0;s<t.length;s+=1){const i=t[s],{component:o,content:r}=i;if(o){const l=e(o,i);l!=null?n.push(l):Ss.debug2(`dehydrateLayoutConfig: skipping unmapped component "${o}"`)}else if(r){const l={...i,content:Ve.dehydrateLayoutConfig(r,e)};n.push(l)}else n.push(i)}return n}static getTabPoint(t){const{tab:e}=t;if(e==null)throw new Error(`Cannot get tab for panel container ${t}`);const n=e.element[0].getBoundingClientRect();return[n.left+n.width*.5,n.bottom-8]}static dropLayoutMinorChange(t){for(let e=0;e<t.length;e+=1){const n=t[e],{content:s}=n;s!==void 0?(wc(n)&&delete n.activeItemIndex,Ve.dropLayoutMinorChange(s)):Ri(n)&&n.component==="IrisGridPanel"&&n.props.panelState!=null&&(delete n.id,n.props.panelState.irisGridState.sorts=[],n.props.panelState.irisGridState.quickFilters=[])}}static isEqual(t,e,n=!1){if(n){const s=Ve.cloneLayout(t),i=Ve.cloneLayout(e);return Ve.dropLayoutMinorChange(s),Ve.dropLayoutMinorChange(i),ct(s,i)}return ct(t,e)}static cloneLayout(t){return JSON.parse(JSON.stringify(t))}static hydrateLayoutConfig(t,e){if(t==null||!t.length)return[];const n=[];for(let s=0;s<t.length;s+=1){const i=t[s];if(Ri(i)){const{component:o,props:r={}}=i;n.push({...i,id:i?.id??$e(),props:e(o,r)})}else if(i.content!==void 0){const o=Ve.hydrateLayoutConfig(i.content,e);wc(i)&&i.activeItemIndex!=null&&i.activeItemIndex>=o.length&&(Ss.warn("Fixing bad activeItemIndex!",i.activeItemIndex,i),i.activeItemIndex=0),n.push({...i,content:o})}else n.push(i)}return n}static openComponent({root:t,config:e,replaceExisting:n=!0,replaceConfig:s=void 0,createNewStack:i=!1,focusElement:o=void 0,dragEvent:r=void 0}={}){const l=document.activeElement,a={...e};if(a.id==null&&(a.id=$e.generate()),r){t?.layoutManager.createDragSourceFromEvent(a,r);return}const d=s||{id:a.id,component:a.component};k(t);const c=i?Ve.addStack(t):Ve.getStackForRoot(t,d);k(c);const u=Ve.getContentItemInStack(c,d);if(o!=null){const m=p=>{Ss.debug("Component created, focusing element",o),c.off("componentCreated",m);const{element:g}=p.origin;requestAnimationFrame(()=>{Ve.focusElement(g[0],o)})};c.on("componentCreated",m)}if(n&&u){const m=c.contentItems.indexOf(u);c.addChild(a,m+1),c.removeChild(u),c.setActiveContentItem(c.contentItems[m])}else c.addChild(a);o==null&&l&&rr(l)&&l.focus()}static openComponentInStack(t,e,n=!0){const s=document.activeElement,i={id:e.id},o=Ve.getContentItemInStack(t,i);if(n&&o&&t){const r=t?.contentItems.indexOf(o);t.addChild(e,r+1),t.removeChild(o),t.setActiveContentItem(t.contentItems[r])}else t?.addChild(e);s&&rr(s)&&s.focus()}static closeComponent(t,e,n){const s=Ve.getStackForRoot(t,e,!1,!1,!1);if(!s){Ss.warn("Cannot find stack for component, ignoring close",e);return}const i=Ve.getContentItemInStack(s,e),o=document.activeElement;i&&(hn(i)?i.container.close(n):s.removeChild(i)),o&&document.contains(o)&&rr(o)&&o.focus()}static renameComponent(t,e,n){const s=Ve.getStackForRoot(t,e,!1);if(!s){Ss.error("Could not find stack for config",e);return}const i=Ve.getContentItemInStack(s,e);i&&i.setTitle(n)}static cloneComponent(t,e){const n=Ve.getStackForRoot(t,e,!1);if(!n)return Ss.error("Could not find stack for config",e),null;const{props:s={}}=e,i=Ve.getPanelComponentState(e),o={type:"react-component",component:e.component,props:{...s,panelState:i},title:`${e.title} Copy`,id:$e.generate()};return Ve.openComponentInStack(n,o),o}static getPanelComponentState(t){return Wu(t)?t.componentState?.panelState:Ri(t)?t.props?.panelState:null}static makeDefaultLayout(){return{dimensions:{headerHeight:bc.tabHeight,borderWidth:bc.dragBorderWidth,borderGrabWidth:10},settings:{showPopoutIcon:!1,showCloseIcon:!1,constrainDragToContainer:!1}}}static getRootFromContainer(t){return t.layoutManager.root}static getComponentConfigFromContainer(t){return t?t.tab!=null&&t.tab.contentItem!=null?t.tab.contentItem.config:t._config:null}static getTitleFromContainer(t){return t!=null&&t.tab!=null&&t.tab.contentItem!=null?t.tab.contentItem.config.title:null}static getTitleFromTab(t){return t!=null&&t.contentItem!=null?t.contentItem.config.title:null}static getIdFromContainer(t){const e=Ve.getComponentConfigFromContainer(t);return e?e.id:null}static getIdFromPanel(t){const{glContainer:e}=t.props;return Ve.getIdFromContainer(e)}static getComponentNameFromPanel(t){const{glContainer:e}=t.props,n=Ve.getComponentConfigFromContainer(e);return n&&Ri(n)?n.component??null:null}static getComponentName(t){const e=t.WrappedComponent?.displayName??t.displayName;if(e==null)throw new Error(`Component displayName not defined ${t}`);return e}static focusElement(t,e=Ve.DEFAULT_FOCUS_SELECTOR){if(t==null)return null;const n=t.querySelector(e);return n==null?null:(rr(n)&&n.focus(),n)}static onInitialized(t){return new Promise(e=>{if(t.isInitialised){e();return}const n=()=>{t.off("initialised",n),e()};t.on("initialised",n)})}};let ie=Ve;ie.DEFAULT_FOCUS_SELECTOR="input, select, textarea, button";const zu=de.forwardRef((t,e)=>{const n=ie.getComponentNameFromPanel({props:t});return v("div",{ref:e,className:"panel-placeholder",children:['Component "',n,'" is not registered.']})});zu.displayName="PanelPlaceholder";const Ee=Object.freeze({FOCUS:"PanelEvent.FOCUS",MOUNT:"PanelEvent.MOUNT",UNMOUNT:"PanelEvent.UNMOUNT",TITLE_CHANGED:"PanelEvent.TITLE_CHANGED",REOPEN:"PanelEvent.REOPEN",DELETE:"PanelEvent.DELETE",CLONED:"PanelEvent.CLONED",CLOSED:"PanelEvent.CLOSED",OPEN:"PanelEvent.OPEN",CLOSE:"PanelEvent.CLOSE",DRAGGING:"PanelEvent.DRAGGING",DROPPED:"PanelEvent.DROPPED"});function Tc(t){return t?.WrappedComponent!==void 0}function Ub(t){return typeof t.id=="string"&&t.layout instanceof ed&&t.panelManager instanceof td&&typeof t.registerComponent=="function"}function Ps(t){if(!Ub(t))throw new Error(`Expected dashboard plugin props, but instead received ${t}`)}const an=ee.module("PanelManager");class td{constructor(e,n=(l,a)=>a,s=(l,a)=>a,i=new Map,o=[],r=()=>{}){this.handleFocus=this.handleFocus.bind(this),this.handleMount=this.handleMount.bind(this),this.handleUnmount=this.handleUnmount.bind(this),this.handleReopen=this.handleReopen.bind(this),this.handleDeleted=this.handleDeleted.bind(this),this.handleClosed=this.handleClosed.bind(this),this.handleControlClose=this.handleControlClose.bind(this),this.layout=e,this.hydrateComponent=n,this.dehydrateComponent=s,this.onPanelsUpdated=r,this.openedMap=new Map(i),this.closed=[...o],this.startListening()}startListening(){const{eventHub:e}=this.layout;e.on(Ee.FOCUS,this.handleFocus),e.on(Ee.MOUNT,this.handleMount),e.on(Ee.UNMOUNT,this.handleUnmount),e.on(Ee.REOPEN,this.handleReopen),e.on(Ee.DELETE,this.handleDeleted),e.on(Ee.CLOSED,this.handleClosed),e.on(Ee.CLOSE,this.handleControlClose)}stopListening(){const{eventHub:e}=this.layout;e.off(Ee.FOCUS,this.handleFocus),e.off(Ee.MOUNT,this.handleMount),e.off(Ee.UNMOUNT,this.handleUnmount),e.off(Ee.REOPEN,this.handleReopen),e.off(Ee.DELETE,this.handleDeleted),e.off(Ee.CLOSED,this.handleClosed),e.off(Ee.CLOSE,this.handleControlClose)}getClosedPanelConfigsOfType(e){return this.closed.filter(n=>n.component===e)}getOpenedPanels(){return Array.from(this.openedMap.values())}getOpenedPanelConfigs(){return this.getOpenedPanels().map(e=>{const{glContainer:n}=e.props;return ie.getComponentConfigFromContainer(n)})}getOpenedPanelConfigsOfType(e){return this.getOpenedPanelConfigs().filter(n=>n!=null&&Ri(n)&&n.component===e)}getOpenedPanelById(e){return this.openedMap.get(e)}getContainerByPanelId(e){const n=ie.getStackForConfig(this.layout.root,{id:e});return(n&&ie.getContentItemInStack(n,{id:e}))??null}getLastUsedPanel(e){const n=this.getOpenedPanels();for(let s=n.length-1;s>=0;s-=1){const i=n[s];if(e==null||e(i))return i}}getLastUsedPanelOfType(e){return this.getLastUsedPanelOfTypes([e])}getLastUsedPanelOfTypes(e){return this.getLastUsedPanel(n=>e.some(s=>Tc(s)&&n instanceof s.WrappedComponent||!Tc(s)&&n instanceof s))}updatePanel(e){const n=ie.getIdFromPanel(e);if(n==null){an.error("updatePanel Panel did not have an ID",e);return}an.debug2(`Updating panel ID ${n} in open panels map`),this.openedMap.delete(n),this.openedMap.set(n,e)}removePanel(e){const n=ie.getIdFromPanel(e);if(n==null){an.error("removePanel Panel did not have an ID",e);return}if(!this.openedMap.has(n)){an.error(`Missing panel ID ${n} in open panels map`);return}if(this.openedMap.get(n)!==e){an.debug(`Panel argument doesn't match the open panels map entry for ${n}, removePanel ignored`);return}an.debug2(`Removing panel ID ${n} from open panels map`),this.openedMap.delete(n)}removeClosedPanelConfig(e){const n=this.closed.findIndex(s=>s===e||s.id!=null&&e.id!=null&&s.id===e.id);n>=0&&this.closed.splice(n,1)}handleFocus(e){an.debug2("Focus: ",e),this.updatePanel(e)}handleMount(e){an.debug2("Mount: ",e),this.updatePanel(e),this.sendUpdate()}handleUnmount(e){an.debug2("Unmount: ",e),this.removePanel(e),this.sendUpdate()}handleReopen(e,n){an.debug2("Reopen:",e,n),this.removeClosedPanelConfig(e);const{component:s}=e;let{props:i}=e;i=this.hydrateComponent(s,i);const o={...e,props:i},{root:r}=this.layout;ie.openComponent({root:r,config:o,replaceConfig:n})}handleDeleted(e){an.debug2("Deleted:",e),this.removeClosedPanelConfig(e),this.sendUpdate()}handleClosed(e,n){an.debug2("Closed: ",e),this.addClosedPanel(n),this.sendUpdate()}handleControlClose(e){const n={id:e},{root:s}=this.layout;ie.closeComponent(s,n)}addClosedPanel(e){const n=ie.getComponentConfigFromContainer(e);if(n&&Ri(n)){const s=this.dehydrateComponent(n.component,n);s!=null&&this.closed.push(s)}}sendUpdate(){const{closed:e,openedMap:n}=this;this.onPanelsUpdated({closed:[...e],openedMap:new Map(n)})}}td.MAX_CLOSED_PANEL_COUNT=100;const Vb=ee.module("PanelErrorBoundary");class Bb extends b.exports.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){this.setState({error:e})}componentWillUnmount(){const{glContainer:e,glEventHub:n}=this.props,s=ie.getIdFromContainer(e);Vb.debug("componentWillUnmount",s),n.emit(Ee.CLOSED,s,e)}render(){const{children:e}=this.props,{error:n}=this.state;return n!=null?h("div",{className:"panel-error-boundary",children:h(el,{errorMessage:`${n}`,isLoading:!1,isLoaded:!1})}):e}}function nd(t){const{props:e,componentState:n}=t,{metadata:s}=e;let{panelState:i=null}=e;n&&({panelState:i}=n);const o={};return s!=null&&(o.metadata=s),i!=null&&(o.panelState=i),{...t,componentState:null,props:o,type:"react-component"}}function sd(t,e=""){return{metadata:{},...t,localDashboardId:e}}const wa={dehydrate:nd,hydrate:sd},$b=M.exports.shape({on:M.exports.func,off:M.exports.func,isHidden:M.exports.bool,tab:M.exports.shape({header:M.exports.shape({tabs:M.exports.arrayOf(M.exports.shape({contentItem:M.exports.shape({})}))})}),title:M.exports.string,setTitle:M.exports.func,close:M.exports.func}),qu=M.exports.shape({on:M.exports.func,off:M.exports.func,emit:M.exports.func}),Gb=M.exports.shape({registerComponent:M.exports.func,root:M.exports.shape({addChild:M.exports.func}),on:M.exports.func,off:M.exports.func,eventHub:qu}),id=Object.freeze({Container:$b,EventHub:qu,Layout:Gb}),Be=(t,e,n)=>b.exports.useEffect(function(){return t.on(e,n),()=>{t.off(e,n)}},[t,e,n]),Yu="SET_DASHBOARD_DATA",Wb=mS(Yu,{},!1),zb={dashboardData:Wb},qb=new Map,Yb=Object.freeze({}),Kb=Object.freeze([]),Xb=t=>t.dashboardData,Yt=(t,e)=>Xb(t)[e]??Yb,jb=(t,e)=>Yt(t,e).closed??Kb,Ku=(t,e)=>Yt(t,e).openedMap??qb,Xu=(t,e)=>({type:Yu,id:t,payload:e}),Vn=(t,e)=>(n,s)=>n(Xu(t,{...Yt(s(),t),...e}));Object.entries(zb).map(([t,e])=>Gi.register(t,e));const lr=ee.module("DashboardLayout"),Zb=Object.freeze({}),Qb=[],vc=()=>{},Ec=t=>t;function ju({id:t,children:e,emptyDashboard:n=h("div",{children:"Dashboard is empty."}),layout:s,layoutConfig:i=Qb,onLayoutChange:o=vc,onLayoutInitialized:r=vc,hydrate:l=sd,dehydrate:a=nd}){const d=Oa(),c=Rp(x=>Yt(x,t))??Zb,[u,m]=b.exports.useState(!1),[p,g]=b.exports.useState(!1),[f,C]=b.exports.useState(),[S]=b.exports.useState(c?.closed??[]),[w,T]=b.exports.useState(!1),y=b.exports.useMemo(()=>new Map,[]),E=b.exports.useMemo(()=>new Map,[]),R=Ip(),F=b.exports.useCallback((x,L,P=l,Z=a)=>{lr.debug2("registerComponent",x,L,P,Z);function ne(X,se){const ce=L,{glContainer:Q,glEventHub:he}=X;return h(ph,{store:R,children:h(Bb,{glContainer:Q,glEventHub:he,children:h(ce,{...X,ref:se})})})}const B=de.forwardRef(ne),W=s.registerComponent(x,B);return y.set(x,P),E.set(x,Z),W},[l,a,y,E,s,R]),D=b.exports.useCallback((x,L)=>(y.get(x)??Ec)(L,t),[y,t]),_=b.exports.useCallback((x,L)=>(E.get(x)??Ec)(L,t),[E,t]),H=b.exports.useMemo(()=>new td(s,D,_,new Map,S,({closed:x,openedMap:L})=>{d(Vn(t,{closed:x,openedMap:L}))}),[_,d,D,t,S,s]),U=b.exports.useCallback(()=>{if(p)return;w||(r(),T(!0));const L=s.toConfig().content,P=ie.dehydrateLayoutConfig(L,_),Z=f==null||!ie.isEqual(f,P);lr.debug("handleLayoutStateChanged",Z,L,P),Z&&(m(s.root.contentItems.length===0),C(P),o(P))},[_,w,p,f,s,o,r]),A=b.exports.useCallback(x=>{const L=ie.getIdFromContainer(x);s.eventHub.emit(Ee.DRAGGING,L),g(!0)},[s.eventHub]),Y=b.exports.useCallback(x=>{const L=ie.getIdFromContainer(x);s.eventHub.emit(Ee.DROPPED,L),g(!1)},[s.eventHub]),G=b.exports.useCallback(x=>{if(lr.debug2("handleComponentCreated",x),x==null||x.config==null||x.config.component==null||x.element==null)return;const P=`${x.config.component.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}-component`;x.element.addClass(P)},[]);Be(s,"stateChanged",U),Be(s,"itemPickedUp",A),Be(s,"itemDropped",Y),Be(s,"componentCreated",G),Be(s.eventHub,Ee.TITLE_CHANGED,U);const z=ll(i);return b.exports.useEffect(function(){if(z!==i&&i!==f){lr.debug("Setting new layout content...");const L=ie.hydrateLayoutConfig(i,D);for(;s.root.contentItems.length>0;)s.root.contentItems[0].remove();for(let P=0;P<L.length;P+=1)s.root.addChild(L[P]);m(s.root.contentItems.length===0)}},[D,s,i,f,H,z]),v(Se,{children:[u&&n,de.Children.map(e,x=>x!=null?de.cloneElement(x,{id:t,layout:s,panelManager:H,registerComponent:F}):null)]})}ju.propTypes={id:M.exports.string.isRequired,children:M.exports.node,data:M.exports.shape({}),emptyDashboard:M.exports.node,layout:id.Layout.isRequired,layoutConfig:M.exports.arrayOf(M.exports.shape({})),onLayoutChange:M.exports.func,onLayoutInitialized:M.exports.func};const Jb=100,ql=()=>{},ew=Object.freeze({});function tw({id:t="default",children:e,emptyDashboard:n,layoutConfig:s,layoutSettings:i=ew,onLayoutConfigChange:o=ql,onGoldenLayoutChange:r=ql,onLayoutInitialized:l=ql,fallbackComponent:a=zu,hydrate:d,dehydrate:c}){const u=b.exports.useRef(null),[m,p]=b.exports.useState(!1),[g,f]=b.exports.useState();b.exports.useEffect(function(){if(!u.current){f(void 0);return}const w={...ie.makeDefaultLayout()};w.settings===void 0&&(w.settings={}),Object.assign(w.settings,i),w.content=[];const T=new ed(w,u.current),y=()=>{T.off("initialised",y),p(!0)};return T.on("initialised",y),a!=null&&T.setFallbackComponent(a),T.init(),f(T),r(T),()=>{T.destroy()}},[i,a,r,p,f]);const C=b.exports.useMemo(()=>Pn(()=>{g!=null&&g.isInitialised&&g?.updateSize()},Jb),[g]);return b.exports.useEffect(function(){return window.addEventListener("resize",C),()=>{window.removeEventListener("resize",C)}},[C]),v("div",{className:"dashboard-container w-100 h-100",children:[h("div",{className:"w-100 h-100",ref:u}),m&&g&&h(ju,{emptyDashboard:n,id:t,layout:g,layoutConfig:s,onLayoutChange:o,onLayoutInitialized:l,hydrate:d,dehydrate:c,children:e})]})}const bn="default";class Zu extends Error{constructor(){super(...arguments),this.isAssertionFailed=!0}}function yc(t){if(t==null)throw new Zu(`Expected 'val' to be defined, but received ${t}`)}class Yl extends Error{constructor(){super(...arguments),this.isPasteError=!0}}function tt(t){return t?.isEditable!==void 0}function Rc(t){if(!tt(t))throw new Zu(`Expected 'model' to be editable, but received ${t}`)}function ze(t){return t?.hasExpandableRows!==void 0}var wn=(t=>(t.DOWN="DOWN",t.UP="UP",t.LEFT="LEFT",t.RIGHT="RIGHT",t))(wn||{});const ve=class{static normalize(t,e,n,s){let i=t,o=e,r=n,l=s;return i!=null&&r!=null&&r<i&&(i=r,r=t),o!=null&&l!=null&&l<o&&(o=l,l=e),[i,o,r,l]}static makeNormalized(t,e,n,s){return new ve(...ve.normalize(t,e,n,s))}static makeCell(t,e){return new ve(t,e,t,e)}static makeColumn(t){return new ve(t,null,t,null)}static makeRow(t){return new ve(null,t,null,t)}static minOrNull(t,e){return t==null||e==null?null:Math.min(t,e)}static maxOrNull(t,e){return t==null||e==null?null:Math.max(t,e)}static consolidate(t){const e=t.slice();let n=!0;for(;n;){n=!1;for(let s=0;s<e.length&&!n;s+=1){const i=e[s];for(let o=e.length-1;o>s;o-=1){const r=e[o];if(i.contains(r))e.splice(o,1);else if(r.contains(i)){n=!0,e[s]=r,e.splice(o,1);break}else if(i.startRow===r.startRow&&i.endRow===r.endRow){if(i.touches(r)){const{startRow:l,endRow:a}=i,d=ve.minOrNull(i.startColumn,r.startColumn),c=ve.maxOrNull(i.endColumn,r.endColumn);n=!0,e[s]=new ve(d,l,c,a),e.splice(o,1);break}}else if(i.startColumn===r.startColumn&&i.endColumn===r.endColumn&&i.touches(r)){const{startColumn:l,endColumn:a}=i,d=ve.minOrNull(i.startRow,r.startRow),c=ve.maxOrNull(i.endRow,r.endRow);n=!0,e[s]=new ve(l,d,a,c),e.splice(o,1);break}}}}return e}static isAxisRangeTouching(t,e,n,s){return t==null?e==null||n==null?!0:n<=e+1:e==null?s==null?!0:s>=t-1:n==null?s==null?!0:t<=s+1:s==null?e>=n-1:n>=t-1?n<=e+1:s>=t-1}static rangeArraysEqual(t,e){if(t===e)return!0;if(t==null||e==null||t.length!==e.length)return!1;for(let n=0;n<t.length;n+=1)if(!t[n].equals(e[n]))return!1;return!0}static intersection(t,e){if(t.equals(e))return t;let{startColumn:n,startRow:s,endColumn:i,endRow:o}=t;return n=n!=null&&e.startColumn!=null?Math.max(n,e.startColumn):n??e.startColumn,i=i!=null&&e.endColumn!=null?Math.min(i,e.endColumn):i??e.endColumn,s=s!=null&&e.startRow!=null?Math.max(s,e.startRow):s??e.startRow,o=o!=null&&e.endRow!=null?Math.min(o,e.endRow):o??e.endRow,n!=null&&n>(i??-1)||s!=null&&s>(o??-1)?null:new ve(n,s,i,o)}static subtractFromRange(t,e){const n=[],s=ve.intersection(t,e);return s==null?[t]:(s.startRow!=null&&(t.startRow==null||t.startRow<s.startRow)&&n.push(new ve(t.startColumn,t.startRow,t.endColumn,s.startRow-1)),s.startColumn!=null&&(t.startColumn==null||t.startColumn<s.startColumn)&&n.push(new ve(t.startColumn,s.startRow,s.startColumn-1,s.endRow)),s.endColumn!=null&&(t.endColumn==null||t.endColumn>s.endColumn)&&n.push(new ve(s.endColumn+1,s.startRow,t.endColumn,s.endRow)),s.endRow!=null&&(t.endRow==null||t.endRow>s.endRow)&&n.push(new ve(t.startColumn,s.endRow+1,t.endColumn,t.endRow)),n)}static subtractFromRanges(t,e){const n=[];for(let s=0;s<t.length;s+=1)n.push(...ve.subtractFromRange(t[s],e));return n}static subtractRangesFromRanges(t,e){let n=[...t];for(let s=0;s<e.length;s+=1)n=ve.subtractFromRanges(n,e[s]);return n}static isBounded(t){return t.startRow!=null&&t.startColumn!=null&&t.endRow!=null&&t.endColumn!=null}static boundedRange(t,e,n){return ve.isBounded(t)?t:new ve(t.startColumn??0,t.startRow??0,t.endColumn??e-1,t.endRow??n-1)}static boundedRanges(t,e,n){return t.map(s=>ve.boundedRange(s,e,n))}static offset(t,e,n){return new ve(t.startColumn!=null?t.startColumn+e:null,t.startRow!=null?t.startRow+n:null,t.endColumn!=null?t.endColumn+e:null,t.endRow!=null?t.endRow+n:null)}static nextCell(t,e=null,n=null,s=ve.SELECTION_DIRECTION.DOWN){if(t.length===0)return null;let i=-1;if(e!=null&&n!=null&&(i=t.findIndex(o=>o.containsCell(e,n)),i>=0)){const r=t[i].nextCell(e,n,s);if(r!=null)return r}switch(s){case ve.SELECTION_DIRECTION.DOWN:case ve.SELECTION_DIRECTION.RIGHT:{const o=i<t.length-1?i+1:0;return t[o].startCell(s)}case ve.SELECTION_DIRECTION.LEFT:case ve.SELECTION_DIRECTION.UP:{const o=i>0?i-1:t.length-1;return t[o].startCell(s)}default:throw new Error(`Invalid direction: ${s}`)}}static cellCount(t){return t.reduce((e,n)=>e+((n.endRow??NaN)-(n.startRow??NaN)+1)*((n.endColumn??NaN)-(n.startColumn??NaN)+1),0)}static rowCount(t){return t.reduce((e,n)=>e+(n.endRow??NaN)-(n.startRow??NaN)+1,0)}static columnCount(t){return t.reduce((e,n)=>e+(n.endColumn??NaN)-(n.startColumn??NaN)+1,0)}static containsCell(t,e,n){for(let s=0;s<t.length;s+=1)if(t[s].containsCell(e,n))return!0;return!1}static forEachCell(t,e,n=ve.SELECTION_DIRECTION.RIGHT){for(let s=0;s<t.length;s+=1)t[s].forEach(e,n)}constructor(t,e,n,s){this.startColumn=t,this.startRow=e,this.endColumn=n,this.endRow=s}equals(t){return this.startColumn===t.startColumn&&this.startRow===t.startRow&&this.endColumn===t.endColumn&&this.endRow===t.endRow}contains(t){return(this.startColumn==null||t.startColumn!=null&&this.startColumn<=t.startColumn)&&(this.startRow==null||t.startRow!=null&&this.startRow<=t.startRow)&&(this.endColumn==null||t.endColumn!=null&&this.endColumn>=t.endColumn)&&(this.endRow==null||t.endRow!=null&&this.endRow>=t.endRow)}containsCell(t,e){return t==null||e==null?!1:(this.startColumn==null||this.startColumn<=t)&&(this.endColumn==null||this.endColumn>=t)&&(this.startRow==null||this.startRow<=e)&&(this.endRow==null||this.endRow>=e)}touches(t){return ve.isAxisRangeTouching(this.startRow,this.endRow,t.startRow,t.endRow)&&ve.isAxisRangeTouching(this.startColumn,this.endColumn,t.startColumn,t.endColumn)}subtract(t){return ve.subtractFromRange(this,t)}startCell(t=ve.SELECTION_DIRECTION.DOWN){if(!ve.isBounded(this))throw new Error("Cannot get the startCell of an unbounded range");switch(t){case ve.SELECTION_DIRECTION.DOWN:case ve.SELECTION_DIRECTION.RIGHT:return{column:this.startColumn,row:this.startRow};case ve.SELECTION_DIRECTION.LEFT:case ve.SELECTION_DIRECTION.UP:return{column:this.endColumn,row:this.endRow};default:throw new Error(`Invalid direction: ${t}`)}}nextCell(t,e,n){if(!ve.isBounded(this))throw new Error("Bounded range required");if(t==null||e==null)throw new Error("Require a non-null cursor");const{startColumn:s,endColumn:i,startRow:o,endRow:r}=this;switch(n){case ve.SELECTION_DIRECTION.DOWN:if(e<r)return{column:t,row:Math.max(e+1,o)};if(t<i)return{column:Math.max(t+1,s),row:o};break;case ve.SELECTION_DIRECTION.UP:if(e>o)return{column:t,row:Math.min(e-1,r)};if(t>s)return{column:Math.min(t-1,i),row:r};break;case ve.SELECTION_DIRECTION.RIGHT:if(t<i)return{column:Math.max(t+1,s),row:e};if(e<r)return{column:s,row:Math.max(e+1,o)};break;case ve.SELECTION_DIRECTION.LEFT:if(t>s)return{column:Math.min(t-1,i),row:e};if(e>o)return{column:i,row:Math.min(e-1,r)};break;default:throw new Error(`Invalid direction: ${n}`)}return null}forEach(t,e=ve.SELECTION_DIRECTION.RIGHT){let n=0,{column:s,row:i}=this.startCell(e);for(;s!=null&&i!=null;)t(s,i,n),n+=1,{column:s,row:i}=this.nextCell(s,i,e)??{}}};let ae=ve;ae.SELECTION_DIRECTION=wn;function nw(t){return Array.isArray(t)&&t.length===2&&(t[0]===null||typeof t[0]=="number")&&(t[1]===null||typeof t[1]=="number")}function ar(t){return nw(t)&&t[0]!=null&&t[1]!=null}const Ne=class{static getGridPointFromXY(t,e,n){const s=Ne.getColumnAtX(t,n),i=Ne.getRowAtY(e,n),o=Ne.getColumnHeaderDepthAtY(e,n);return{x:t,y:e,row:i,column:s,columnHeaderDepth:o}}static getCellInfoFromXY(t,e,n){const{row:s,column:i}=Ne.getGridPointFromXY(t,e,n),{allColumnWidths:o,allRowHeights:r,allColumnXs:l,allRowYs:a,modelColumns:d,modelRows:c}=n,u=s!==null?c.get(s):null,m=i!==null?d.get(i):null,p=i!==null?l.get(i):null,g=s!==null?a.get(s):null,f=i!==null?o.get(i):null,C=s!==null?r.get(s):null;return{row:s,column:i,modelRow:u??null,modelColumn:m??null,left:p??null,top:g??null,columnWidth:f??null,rowHeight:C??null}}static getColumnHeaderDepthAtY(t,e){const n=Ne.getRowAtY(t,e),{columnHeaderHeight:s,columnHeaderMaxDepth:i}=e;if(n===null&&t<=s*i)return Qe(i-Math.ceil(t/s),0,i-1)}static iterateFloatingStart(t,e,n){for(let s=0;s<t&&s<e;s+=1){const i=n(s);if(i!==void 0)return i}}static iterateFloatingEnd(t,e,n){for(let s=0;s<t&&e-(t-s)>=0;s+=1){const i=n(e-(t-s));if(i!==void 0)return i}}static iterateFloating(t,e,n,s){const i=Ne.iterateFloatingStart(t,n,s);return i!==void 0?i:Ne.iterateFloatingEnd(e,n,s)}static iterateAllItems(t,e,n,s,i,o){const r=Math.max(t,n),l=Math.min(e,i-s-1);let a=Ne.iterateFloating(n,s,i,o);if(a!==void 0)return a;for(let d=r;d<=l;d+=1)if(a=o(d),a!==void 0)return a}static isInItem(t,e,n,s){const i=e.get(t)??0,o=n.get(t)??0;return i<=s&&s<=i+o}static getItemAtOffset(t,e,n,s,i,o,r,l=!1){const a=l?void 0:Ne.iterateFloating(n,s,e,d=>{if(Ne.isInItem(d,o,r,t))return d});if(!l&&a!==void 0)return a;for(let d=0;d<i.length;d+=1){const c=i[d];if(Ne.isInItem(c,o,r,t))return c}return null}static getColumnAtX(t,e,n=!1){const{columnCount:s,floatingLeftColumnCount:i,floatingRightColumnCount:o,visibleColumns:r,allColumnXs:l,allColumnWidths:a,gridX:d}=e;return t<d?null:this.getItemAtOffset(t-d,s,i,o,r,l,a,n)}static getRowAtY(t,e){const{floatingTopRowCount:n,floatingBottomRowCount:s,rowCount:i,visibleRows:o,allRowYs:r,allRowHeights:l,gridY:a}=e;return t<a?null:this.getItemAtOffset(t-a,i,n,s,o,r,l)}static getNextShownItem(t,e,n,s){let i=n.findIndex(o=>o===t)||0;for(i-=1;i!=null&&i>=0;){const o=n[i],r=e.get(o);if(r!=null&&s.get(r)!==0)return o;i-=1}return null}static getNextShownColumn(t,e){const{modelColumns:n,visibleColumns:s,userColumnWidths:i}=e;return Ne.getNextShownItem(t,n,s,i)}static getNextShownRow(t,e){const{modelRows:n,visibleRows:s,userRowHeights:i}=e;return Ne.getNextShownItem(t,n,s,i)}static getColumnSeparatorIndex(t,e,n,s){const{rowHeaderWidth:i,columnHeaderHeight:o,floatingColumns:r,floatingLeftWidth:l,visibleColumns:a,allColumnXs:d,allColumnWidths:c,columnHeaderMaxDepth:u}=n,{allowColumnResize:m,headerSeparatorHandleSize:p}=s;if(u*o<e||!m||p<=0)return null;const g=t-i,f=p*.5;let C=!1;for(let S=r.length-1;S>=0;S-=1){const w=r[S],T=d.get(w)??0,y=c.get(w)??0,E=y===0;if(!C||!E){let R=T+y;E?R+=f:C&&(R-=f);const F=R-f,D=R+f;if(F<=g&&g<=D)return w;C=E}}C=!1;for(let S=a.length-1;S>=0;S-=1){const w=a[S],T=d.get(w)??0,y=c.get(w)??0,E=y===0;if(T<l-y)return null;if(!C||!E){let R=T+y;E?R+=f:C&&(R-=f);const F=R-f,D=R+f;if(F<=g&&g<=D)return w;C=E}}return null}static isItemHidden(t,e){return e.get(t)===0}static isColumnHidden(t,e){const{allColumnWidths:n}=e;return Ne.isItemHidden(t,n)}static isFloatingRow(t,e){if(t==null)return!1;const{floatingTopRowCount:n,floatingBottomRowCount:s,rowCount:i}=e;return t<n||t>=i-s}static isFloatingColumn(t,e){if(t==null)return!1;const{floatingLeftColumnCount:n,floatingRightColumnCount:s,columnCount:i}=e;return t<n||t>=i-s}static getHiddenItems(t,e,n){if(!Ne.isItemHidden(t,e))return[];const s=[t],i=n.findIndex(o=>o===t);for(let o=i-1;o>=0;o-=1){const r=n[o];if(!Ne.isItemHidden(r,e))break;s.push(r)}return s}static getHiddenColumns(t,e){const{visibleColumns:n,allColumnWidths:s}=e;return Ne.getHiddenItems(t,s,n)}static getRowSeparatorIndex(t,e,n,s){const{rowHeaderWidth:i,columnHeaderHeight:o,visibleRows:r,allRowYs:l,allRowHeights:a}=n,{allowRowResize:d,headerSeparatorHandleSize:c}=s;if(i<t||!d||c<=0)return null;const u=e-o,m=c*.5;let p=!1;for(let g=r.length-1;g>=0;g-=1){const f=r[g],C=l.get(f)??0,S=a.get(f)??0,w=S===0;if(!p||!w){let T=C+S;w?T+=m:p&&(T-=m);const y=T-m,E=T+m;if(y<=u&&u<=E)return f;p=w}}return null}static isRowHidden(t,e){const{allRowHeights:n}=e;return Ne.isItemHidden(t,n)}static getHiddenRows(t,e){const{visibleRows:n,allRowHeights:s}=e;return Ne.getHiddenItems(t,s,n)}static moveItem(t,e,n){if(t===e)return[...n];const s=[...n],i=s[s.length-1];return i!=null&&!ar(i.from)&&i.to===t?i.from===e?s.pop():s[s.length-1]={...i,to:e}:s.push({from:t,to:e}),s}static moveRange(t,e,n,s=!1){if(t[0]===t[1])return Ne.moveItem(t[0],e,n);let i=e;if(s&&t[0]<e&&(i-=t[1]-t[0]),t[0]===i)return[...n];const o=[...n],r=o[o.length-1];r!=null&&ar(r.from)&&r.from[1]-r.from[0]===t[1]-t[0]&&r.to===t[0]?o[o.length-1]={...r,to:i}:o.push({from:t,to:i});const l=o[o.length-1];return ar(l.from)&&l.from[0]===l.to&&o.pop(),o}static moveItemOrRange(t,e,n,s=!1){return Array.isArray(t)?Ne.moveRange(t,e,n,s):Ne.moveItem(t,e,n)}static applyItemMoves(t,e,n,s=!1){let i=[[t,e]];for(let o=s?n.length-1:0;s?o>=0:o<n.length;s?o-=1:o+=1){const{from:r,to:l}=n[o];let a=1,d;ar(r)?(a=r[1]-r[0]+1,[d]=r):d=r;const c=s?l:d,u=c+a-1,m=s?d:l,p=m-c,g=[];for(let f=0;f<i.length;f+=1){const C=i[f][0]??Number.NEGATIVE_INFINITY,S=i[f][1]??Number.POSITIVE_INFINITY;let w;const T=[[C,c-1],[c,u],[u+1,S]].map(([y,E])=>[Math.max(y,C),Math.min(E,S)]).filter(([y,E])=>y<=E).map(y=>{const[E,R]=y;return c<=E&&u>=R?(w=[E+p,R+p],w):u<E?[E-a,R-a]:y}).map(y=>{const[E,R]=y;return m>E&&m<=R?[[E,m-1],[m+a,R+a]]:y===w?[y]:m<=E?[[E+a,R+a]]:[y]}).flat();g.push(...T)}i=g.map(([f,C])=>[Number.isFinite(f)?f:null,Number.isFinite(C)?C:null])}return i}static translateRange(t,e,n,s){const i=Ne.applyItemMoves(t.startColumn,t.endColumn,e,s),o=Ne.applyItemMoves(t.startRow,t.endRow,n,s),r=[];for(let l=0;l<i.length;l+=1){const a=i[l];for(let d=0;d<o.length;d+=1){const c=o[d];r.push(new ae(a[0],c[0],a[1],c[1]))}}return r}static getModelIndex(t,e){return Ne.applyItemMoves(t,t,e,!0)[0][0]}static getModelIndexes(t,e){return t.map(n=>Ne.getModelIndex(n,e))}static getModelRangeIndexes(t,e,n){return Ne.applyItemMoves(t,e,n,!0)}static getModelRange(t,e=He,n=He){return Ne.translateRange(t,e,n,!0)}static getModelRanges(t,e=He,n=He){const s=[];for(let i=0;i<t.length;i+=1)s.push(...Ne.getModelRange(t[i],e,n));return s}static getVisibleRangeIndexes(t,e,n){return Ne.applyItemMoves(t,e,n,!1)}static getVisibleRange(t,e=He,n=He){return this.translateRange(t,e,n,!1)}static getVisibleRanges(t,e=He,n=He){const s=[];for(let i=0;i<t.length;i+=1)s.push(...Ne.getVisibleRange(t[i],e,n));return s}static getVisibleIndex(t,e){return Ne.applyItemMoves(t,t,e)[0][0]}static getVisibleIndexes(t,e){return t.map(n=>Ne.getVisibleIndex(n,e))}static isMacPlatform(){const{platform:t}=window.navigator;return t.startsWith("Mac")}static getModifierKey(){return Ne.isMacPlatform()?"metaKey":"ctrlKey"}static isModifierKeyDown(t){const e=Ne.getModifierKey();return t[e]}static checkColumnHidden(t,e){return e.get(t)===0}static checkAllColumnsHidden(t,e){return e.size===0?!1:t.every(n=>e.get(n)===0)}static getScrollDragBounds(t,e,n){const{gridX:s,gridY:i,width:o,height:r,floatingTopRowCount:l,floatingBottomRowCount:a,floatingLeftColumnCount:d,floatingRightColumnCount:c,floatingLeftWidth:u,floatingRightWidth:m,floatingTopHeight:p,floatingBottomHeight:g,columnCount:f,rowCount:C}=t;let S=s,w=i,T=o,y=r;return n!=null&&(n>d&&(S+=u),n<f-c&&(T-=m)),e!=null&&(e>l&&(w+=p),e<C-a&&(y-=g)),{x1:S,y1:w,x2:T,y2:y}}static getScrollDelta(t,e=1024,n=768,s=20,i=20){let{deltaX:o,deltaY:r}=t;return!Ne.isMacPlatform()&&t.shiftKey&&t.deltaX===0&&t.deltaY!==0&&(o=t.deltaY,r=t.deltaX),t?.deltaMode===WheelEvent.DOM_DELTA_PAGE?(o*=e,r*=n):t?.deltaMode===WheelEvent.DOM_DELTA_LINE&&(Ne.isMacPlatform()?(o=Math.round(o*s),r=Math.round(r*i)):(o=Math.round(o*this.PIXELS_PER_LINE),r=Math.round(r*this.PIXELS_PER_LINE))),{deltaX:o,deltaY:r}}static compareRanges(t,e){return t[0]==null||t[1]==null||e[0]==null||e[1]==null?0:t[0]!==e[0]?t[0]-e[0]:t[1]-e[1]}static mergeSortedRanges(t){const e=[];for(let n=0;n<t.length;n+=1){const s=t[n],i=s[0],o=s[1];n===0?e.push([i,o]):i-1<=e[e.length-1][1]?e[e.length-1][1]=Math.max(e[e.length-1][1],o):e.push([i,o])}return e}};let q=Ne;q.PIXELS_PER_LINE=100/3;function O(t,e,n=void 0){const s=t.get(e)??n;if(s!==void 0)return s;throw new Error(`Missing value for key ${e}`)}function dr(t,e=Uo.CACHE_SIZE,n=Math.floor(e/2)){if(t.size>e){const s=t.keys();for(;t.size>n;)t.delete(s.next().value)}}function Ic(t,e,n,s,i){const o=new Map;let r=0;for(let l=0;l<t&&l<n;l+=1)o.set(l,r),r+=O(i,l);r=s;for(let l=0;l<e&&n-l-1>=0;l+=1)r-=O(i,n-l-1),o.set(n-l-1,r);return o}const Qu=class{constructor({userColumnWidths:t=new Map,userRowHeights:e=new Map,calculatedColumnWidths:n=new Map,calculatedRowHeights:s=new Map,fontWidths:i=new Map,modelRows:o=new Map,modelColumns:r=new Map,movedRows:l=[],movedColumns:a=[],initialRowHeights:d=new Map,initialColumnWidths:c=new Map}={}){this.userColumnWidths=t,this.userRowHeights=e,this.calculatedRowHeights=s,this.calculatedColumnWidths=n,this.fontWidths=i,this.modelRows=o,this.modelColumns=r,this.movedRows=l,this.movedColumns=a,this.initialRowHeights=d,this.initialColumnWidths=c}getMetrics(t){const{left:e,top:n,leftOffset:s,topOffset:i,width:o,height:r,theme:l,model:a,movedRows:d,movedColumns:c,draggingColumn:u}=t,{rowHeight:m,rowHeaderWidth:p,rowFooterWidth:g,columnWidth:f,columnHeaderHeight:C,minScrollHandleSize:S,scrollBarSize:w}=l;d!==this.movedRows&&(this.movedRows=d,this.modelRows.clear()),c!==this.movedColumns&&(this.movedColumns=c,this.modelColumns.clear());const{columnCount:T,rowCount:y,floatingTopRowCount:E,floatingBottomRowCount:R,floatingLeftColumnCount:F,floatingRightColumnCount:D,columnHeaderMaxDepth:_}=a,H=this.getFirstRow(t),U=this.getFirstColumn(t),A=this.getGridX(t),Y=this.getGridY(t),G=ze(a)&&a.hasExpandableRows?this.calculateTreePaddingX(t):0,z=0,x=this.getVisibleRowHeights(t),L=this.getVisibleColumnWidths(t,U,G),P=Array.from(x.keys()),Z=Array.from(L.keys()),ne=new Map([...x,...this.getFloatingRowHeights(t)]),B=new Map([...L,...this.getFloatingColumnWidths(t)]),W=this.getVisibleColumnXs(B,Z,s),X=this.getVisibleRowYs(ne,P,i),se=P.length>0?P[P.length-1]:n,ce=Z.length>0?Z[Z.length-1]:e,Q=this.getBottomViewport(t,P,X,ne),he=this.getRightViewport(t,Z,W,B),be=this.getFloatingTopHeight(t,ne),Re=this.getFloatingBottomHeight(t,ne),et=this.getFloatingLeftWidth(t,B),yt=this.getFloatingRightWidth(t,B),je=Array.from(B.values()),En=Array.from(ne.values()),Ut=je.reduce((it,In)=>it+In,0)-s,De=En.reduce((it,In)=>it+In,0)-i,mt=s+Ut+g,at=i+De,Rt=o-A,Vt=r-Y,yn=this.getLastLeft(t,null,Rt-g),on=this.getLastLeft(t,null,Rt-g-w),hi=this.getLastTop(t,null,Vt-Re),Hs=this.getLastTop(t,null,Vt-Re-w);let rn=on,cs=Hs;yn===0&&hi===0&&(rn=0,cs=0);const ui=rn>0,Zi=ui?w:0,mi=cs>0,pi=mi?w:0,Go=A,Wo=_*C,hs=o-Go-pi,Us=r-Wo-Zi,xl=T===1?hs/mt:(T-rn)/T,zo=y===1?Us/at:(y-cs)/y,Qi=ui?Qe(hs*xl,S,hs-1):0,Ji=mi?Qe(Us*zo,S,Us-1):0,qo=O(B,e,0),Yo=O(ne,n,0),Ol=qo>0?s/qo:0,Al=Yo>0?i/Yo:0,Ll=T===1?s/(mt-Rt):(e+Ol)/rn,Vs=y===1?i/(at-Vt):(n+Al)/cs,Pl=ui?Ll*(hs-Qi):0,Ko=mi?Vs*(Us-Ji):0,Xo=[...Array(E).keys(),...[...Array(R).keys()].map(it=>y-it-1)],eo=new Map([...X,...this.getFloatingRowYs(t,ne,Math.floor(r-Y-Zi))]),jo=[...Array(F).keys(),...[...Array(D).keys()].map(it=>T-it-1)],us=new Map([...W,...this.getFloatingColumnXs(t,B,Math.floor(o-A-pi))]),to=[];if(u)for(let it=u.range[0];it<=u.range[1];it+=1)to.push(it),B.has(it)||B.set(it,this.getVisibleColumnWidth(it,t)),us.has(it)||us.set(it,0);const Zo=P.concat(Xo),no=Z.concat(jo).concat(to),so=this.getModelRows(Zo,t),Hl=this.getModelColumns(no,t),Qo=this.getVisibleRowTreeBoxes(ne,so,t),Jo=this.getTopVisible(t,eo,ne,P),er=this.getLeftVisible(t,us,B,Z),tr=cs>0?this.getBottomVisible(t,eo,ne,P,Y):se,nr=rn>0?this.getRightVisible(t,us,B,Z,A):ce,{fontWidths:sr,userColumnWidths:Ul,userRowHeights:Ye,calculatedRowHeights:_t,calculatedColumnWidths:Rn}=this;return{rowHeight:m,rowHeaderWidth:p,rowFooterWidth:g,rowCount:y,columnWidth:f,columnCount:T,columnHeaderHeight:C,floatingTopRowCount:E,floatingBottomRowCount:R,floatingLeftColumnCount:F,floatingRightColumnCount:D,gridX:A,gridY:Y,firstRow:H,firstColumn:U,treePaddingX:G,treePaddingY:z,left:e,top:n,bottom:se,right:ce,topOffset:i,leftOffset:s,topVisible:Jo,leftVisible:er,bottomVisible:tr,rightVisible:nr,bottomViewport:Q,rightViewport:he,width:o,height:r,maxX:Ut,maxY:De,lastLeft:rn,lastTop:cs,barHeight:Us,barTop:Wo,barWidth:hs,barLeft:Go,handleHeight:Ji,handleWidth:Qi,hasHorizontalBar:ui,hasVerticalBar:mi,verticalBarWidth:pi,horizontalBarHeight:Zi,scrollX:Pl,scrollY:Ko,scrollableContentWidth:mt,scrollableContentHeight:at,scrollableViewportWidth:Rt,scrollableViewportHeight:Vt,visibleRows:P,visibleColumns:Z,visibleRowHeights:x,visibleColumnWidths:L,floatingRows:Xo,floatingColumns:jo,allRows:Zo,allColumns:no,allRowHeights:ne,allColumnWidths:B,floatingTopHeight:be,floatingBottomHeight:Re,floatingLeftWidth:et,floatingRightWidth:yt,visibleRowYs:X,visibleColumnXs:W,allRowYs:eo,allColumnXs:us,visibleRowTreeBoxes:Qo,modelRows:so,modelColumns:Hl,movedRows:d,movedColumns:c,fontWidths:sr,userColumnWidths:Ul,userRowHeights:Ye,calculatedRowHeights:_t,calculatedColumnWidths:Rn,columnHeaderMaxDepth:_}}getGridX(t){const{theme:e}=t,{rowHeaderWidth:n}=e;return n}getGridY(t){const{theme:e,model:n}=t,{columnHeaderHeight:s}=e,{columnHeaderMaxDepth:i}=n;return i*s}getVisibleHeight(t,e=this.getFloatingRowHeights(t)){const{height:n,theme:s}=t,{scrollBarSize:i}=s,o=this.getGridY(t),r=this.getFloatingBottomHeight(t,e),l=this.getFloatingTopHeight(t,e);return n-r-l-o-i}getVisibleWidth(t,e=this.getFloatingColumnWidths(t)){const{width:n,theme:s}=t,{scrollBarSize:i,rowFooterWidth:o}=s,r=this.getGridX(t),l=this.getFloatingRightWidth(t,e),a=this.getFloatingLeftWidth(t,e);return n-a-l-r-i-o}getFirstIndex(t,e,n){const s=t.size+1;for(let i=0;i<s;i+=1){const o=e(i,n);if(t.get(o)!==0)return i}return 0}getFirstColumn(t){return this.getFirstIndex(this.userColumnWidths,this.getModelColumn.bind(this),t)}getFirstRow(t){return this.getFirstIndex(this.userRowHeights,this.getModelRow.bind(this),t)}getLastLeft(t,e,n){const{model:s}=t,{columnCount:i,floatingRightColumnCount:o}=s;let r=Math.max(0,i-o-1);e!=null&&(r=e);let l=0;for(;r>=0;){if(l+=this.getVisibleColumnWidth(r,t),l>=n)return Qe(r+1,0,e??i-1);r-=1}return 0}getLastTop(t,e,n){const{model:s}=t,{rowCount:i,floatingBottomRowCount:o}=s;let r=Math.max(0,i-o-1);e!=null&&(r=e);let l=0;for(;r>=0;){if(l+=this.getVisibleRowHeight(r,t),l>=n)return Qe(r+1,0,i-1);r-=1}return 0}getTopForTopVisible(t,e){const n=this.getFloatingTopHeight(t);let s=e,i=0;for(;s>0&&i<n;)s-=1,i+=this.getVisibleRowHeight(s,t);return s}getTopForBottomVisible(t,e){const{height:n}=t,s=this.getGridY(t),i=this.getFloatingBottomHeight(t),o=n-s-i;return this.getLastTop(t,e,o)}getLeftForLeftVisible(t,e){const n=this.getFloatingLeftWidth(t);let s=e,i=0;for(;s>0&&i<n;)s-=1,i+=this.getVisibleColumnWidth(s,t);return s}getLeftForRightVisible(t,e){const{width:n}=t,s=this.getGridX(t),i=this.getFloatingRightWidth(t),o=n-s-i;return this.getLastLeft(t,e,o)}getFloatingRowHeights(t){const{model:e}=t,{floatingTopRowCount:n,floatingBottomRowCount:s,rowCount:i}=e,o=new Map;for(let r=0;r<n&&r<i;r+=1)o.set(r,this.getVisibleRowHeight(r,t));for(let r=0;r<s&&i-r-1>=0;r+=1){const l=i-r-1;o.set(l,this.getVisibleRowHeight(l,t))}return o}getVisibleRowHeights(t){const{top:e,topOffset:n,height:s,model:i}=t;let o=0,r=e;const l=new Map,{rowCount:a}=i;for(;o<s+n&&r<a;){const d=this.getVisibleRowHeight(r,t);l.set(r,d),o+=d,r+=1}return l}getFloatingColumnWidths(t,e=this.getFirstColumn(t),n=this.calculateTreePaddingX(t)){const{model:s}=t,{columnCount:i,floatingLeftColumnCount:o,floatingRightColumnCount:r}=s,l=new Map;for(let a=0;a<o&&a<i;a+=1)l.set(a,this.getVisibleColumnWidth(a,t,e,n));for(let a=0;a<r&&i-a-1>=0;a+=1){const d=i-a-1;l.set(d,this.getVisibleColumnWidth(d,t,e,n))}return l}getVisibleColumnWidths(t,e=this.getFirstColumn(t),n=this.calculateTreePaddingX(t)){const{left:s,leftOffset:i,width:o,model:r}=t;let l=0,a=s;const d=new Map,{columnCount:c}=r;for(;l<o+i&&a<c;){const u=this.getVisibleColumnWidth(a,t,e,n);d.set(a,u),l+=u,a+=1}return d}getFloatingColumnXs(t,e,n){const{model:s}=t,{columnCount:i,floatingLeftColumnCount:o,floatingRightColumnCount:r}=s;return Ic(o,r,i,n,e)}getVisibleColumnXs(t,e,n){const s=new Map;let i=-n;for(let o=0;o<e.length;o+=1){const r=e[o],l=O(t,r);s.set(r,i),i+=l}return s}getFloatingRowYs(t,e,n){const{model:s}=t,{floatingTopRowCount:i,floatingBottomRowCount:o,rowCount:r}=s;return Ic(i,o,r,n,e)}getVisibleRowYs(t,e,n){const s=new Map;let i=-n;for(let o=0;o<e.length;o+=1){const r=e[o],l=O(t,r);s.set(r,i),i+=l}return s}getVisibleRowTreeBoxes(t,e,n){const s=new Map,{model:i,theme:o}=n,{treeDepthIndent:r,treeHorizontalPadding:l}=o;return ze(i)&&i.hasExpandableRows&&t.forEach((a,d)=>{const c=O(e,d);if(i.isRowExpandable(c)){const u=i.depthForRow(c),m=u*r+l,p=(u+1)*r+l,g=0,f=a;s.set(d,{x1:m,y1:g,x2:p,y2:f})}}),s}getFloatingLeftWidth(t,e=this.getFloatingColumnWidths(t)){const{model:n}=t,{floatingLeftColumnCount:s}=n;let i=0;for(let o=0;o<s;o+=1)i+=O(e,o);return i}getFloatingRightWidth(t,e=this.getFloatingColumnWidths(t)){const{model:n}=t,{floatingRightColumnCount:s,columnCount:i}=n;let o=0;for(let r=0;r<s;r+=1)o+=O(e,i-r-1);return o}getFloatingTopHeight(t,e=this.getFloatingRowHeights(t)){const{model:n}=t,{floatingTopRowCount:s}=n;let i=0;for(let o=0;o<s;o+=1)i+=O(e,o);return i}getFloatingBottomHeight(t,e=this.getFloatingRowHeights(t)){const{model:n}=t,{floatingBottomRowCount:s,rowCount:i}=n;let o=0;for(let r=0;r<s;r+=1)o+=O(e,i-r-1);return o}getTopVisible(t,e,n,s){const i=this.getFloatingTopHeight(t,n);for(let o=0;o<s.length;o+=1){const r=s[o];if(O(e,r)>=i)return r}return 0}getLeftVisible(t,e,n,s){const i=this.getFloatingLeftWidth(t,n);for(let o=0;o<s.length;o+=1){const r=s[o];if(O(e,r)>=i)return r}return 0}getBottomVisible(t,e,n,s,i){const{height:o,theme:r}=t,{scrollBarSize:l}=r,a=this.getFloatingBottomHeight(t,n),d=o-i-l-a;for(let c=s.length-1;c>=0;c-=1){const u=s[c],m=O(e,u),p=O(n,u);if(m+p<=d)return u}return 0}getRightVisible(t,e,n,s,i){const{width:o,theme:r}=t,{scrollBarSize:l}=r,a=this.getFloatingRightWidth(t,n),d=o-i-l-a;for(let c=s.length-1;c>=0;c-=1){const u=s[c],m=O(e,u),p=O(n,u);if(m+p<=d)return u}return 0}getBottomViewport(t,e,n,s){const{height:i,theme:o}=t,{rowHeight:r}=o;return this.getLastIndexViewport(e,n,s,i,r)}getRightViewport(t,e,n,s){const{width:i,theme:o}=t,{columnWidth:r}=o;return this.getLastIndexViewport(e,n,s,i,r)}getLastIndexViewport(t,e,n,s,i){let o=0,r=0;return t.length>0&&(o=t[t.length-1],r=O(e,o)+O(n,o)),r<s&&(o+=Math.ceil((s-r)/i)),o}getVisibleItemSize(t,e,n){return e.get(t)??n()}getVisibleRowHeight(t,e){const n=this.getModelRow(t,e),s=this.calculateRowHeight(t,n,e);return this.getVisibleItemSize(n,this.userRowHeights,()=>{const i=this.initialRowHeights.get(n);return i!==void 0?i:s})}getVisibleColumnWidth(t,e,n=this.getFirstColumn(e),s=this.calculateTreePaddingX(e)){const i=this.getModelColumn(t,e),o=this.calculateColumnWidth(t,i,e,n,s);return this.getVisibleItemSize(i,this.userColumnWidths,()=>{const r=this.initialColumnWidths.get(i);return r!==void 0?r:o})}getModelRows(t,e){const n=new Map;for(let s=0;s<t.length;s+=1){const i=t[s],o=this.getModelRow(i,e);n.set(i,o)}return n}getModelRow(t,e){if(this.modelRows.has(t))return O(this.modelRows,t);const{movedRows:n}=e,s=q.getModelIndex(t,n);return this.modelRows.set(t,s),s}getModelColumns(t,e){const n=new Map;for(let s=0;s<t.length;s+=1){const i=t[s],o=this.getModelColumn(i,e);n.set(i,o)}return n}getModelColumn(t,e){if(this.modelColumns.has(t))return O(this.modelColumns,t);const{movedColumns:s}=e,i=q.getModelIndex(t,s);return this.modelColumns.set(t,i),i}calculateRowHeight(t,e,n){const{theme:s}=n,{autoSizeRows:i,rowHeight:o}=s;if(!i)return o;const r=this.calculatedRowHeights.get(e);return r??(this.calculatedRowHeights.set(e,Math.ceil(o)),dr(this.calculatedRowHeights),o)}calculateColumnWidth(t,e,n,s=this.getFirstColumn(n),i=this.calculateTreePaddingX(n)){const{theme:o}=n,{autoSizeColumns:r,minColumnWidth:l}=o;if(!r){const{columnWidth:m}=o;return m}const a=this.calculateColumnHeaderWidth(e,n),d=this.calculateColumnDataWidth(e,n),c=this.calculatedColumnWidths.get(e);let u=Math.ceil(Math.max(a,d));return u=Math.max(l,u),c!=null&&c>u?u=c:(this.calculatedColumnWidths.set(e,u),dr(this.calculatedColumnWidths)),t===s&&(u+=i),u}calculateColumnHeaderWidth(t,e){const{model:n,theme:s}=e,{headerFont:i,headerHorizontalPadding:o}=s,r=n.textForColumnHeader(t,0);if(r!==void 0&&r!==""){const l=this.getWidthForFont(i,e);return r.length*l+o*2}return o*2}calculateColumnDataWidth(t,e){const{top:n,height:s,width:i,model:o,theme:r}=e,{floatingTopRowCount:l,floatingBottomRowCount:a,rowCount:d}=o,{font:c,cellHorizontalPadding:u,rowHeight:m,rowHeaderWidth:p,rowFooterWidth:g,scrollBarSize:f}=r;let C=0;const S=this.getWidthForFont(c,e),w=s/m,T=Math.ceil(n+w);return q.iterateAllItems(n,T,l,a,d,y=>{const E=this.getModelRow(y,e),R=o.textForCell(t,E);if(R){const F=u*2;C=Math.max(C,R.length*S+F)}}),C=Math.max(Math.min(C,(i-p-f-g)*Qu.MAX_COLUMN_WIDTH),u*2),C}calculateTreePaddingX(t){const{top:e,height:n,model:s,theme:i}=t,{rowHeight:o,treeDepthIndent:r}=i;if(!ze(s)||!s.hasExpandableRows)return 0;let l=0;const a=n/o,d=Math.ceil(e+a);for(let c=e;c<=d;c+=1){const u=this.getModelRow(c,t),m=s.depthForRow(u);l=Math.max(l,r*(m+1))}return l}getWidthForFont(t,e){if(this.fontWidths.has(t))return O(this.fontWidths,t);const{context:n}=e;n.font=t;const s=n.measureText("8"),{width:i}=s;return this.fontWidths.set(t,i),this.fontWidths.set(n.font,i),i}setColumnWidth(t,e){const n=new Map(this.userColumnWidths);n.set(t,Math.ceil(e)),dr(n),this.userColumnWidths=n}resetColumnWidth(t){const e=new Map(this.userColumnWidths);e.delete(t),this.userColumnWidths=e}setRowHeight(t,e){const n=new Map(this.userRowHeights);n.set(t,Math.ceil(e)),dr(n),this.userRowHeights=n}resetRowHeight(t){const e=new Map(this.userRowHeights);e.delete(t),this.userRowHeights=e,this.calculatedRowHeights.delete(t)}};let Uo=Qu;Uo.CACHE_SIZE=1e4;Uo.MAX_COLUMN_WIDTH=.8;const sw=Object.freeze({allowColumnResize:!0,allowRowResize:!0,autoSelectRow:!1,autoSelectColumn:!1,autoSizeColumns:!0,autoSizeRows:!0,backgroundColor:"#000000",black:"#000000",white:"#ffffff",cellHorizontalPadding:5,headerHorizontalPadding:5,font:"12px Arial, sans serif",gridColumnColor:"#8f8f8f66",gridRowColor:"#8f8f8f66",headerBackgroundColor:"#222222",headerSeparatorColor:"#000000",headerSeparatorHoverColor:"#888888",headerSeparatorHandleSize:5,headerHiddenSeparatorSize:5,headerHiddenSeparatorHoverColor:"#8888FF",headerColor:"#d5d5d5",headerFont:"10px Arial, sans serif",columnHoverBackgroundColor:"#444444",selectedColumnHoverBackgroundColor:"#494949",rowBackgroundColors:"#333333 #222222",rowHoverBackgroundColor:"#444444",selectedRowHoverBackgroundColor:"#494949",minScrollHandleSize:50,scrollBarBackgroundColor:"#111111",scrollBarHoverBackgroundColor:"#333333",scrollBarCasingColor:"#000000",scrollBarCornerColor:"#000000",scrollBarColor:"#555555",scrollBarHoverColor:"#888888",scrollBarActiveColor:"#AAAAAA",scrollBarSize:12,scrollBarHoverSize:16,scrollBarCasingWidth:1,scrollSnapToColumn:!1,scrollSnapToRow:!1,selectionColor:"#4286f433",selectionOutlineColor:"#4286f4",selectionOutlineCasingColor:"#222222",scrollBarSelectionTick:!0,scrollBarSelectionTickColor:"#4286f433",scrollBarActiveSelectionTickColor:"#4286f480",shadowBlur:8,shadowColor:"#000000",textColor:"#ffffff",maxDepth:6,treeDepthIndent:10,treeHorizontalPadding:5,treeLineColor:"#888888",treeMarkerColor:"#cccccc",treeMarkerHoverColor:"#ffffff",rowHeight:20,columnWidth:100,minRowHeight:20,minColumnWidth:55,columnHeaderHeight:20,rowHeaderWidth:30,rowFooterWidth:0,headerResizeSnapThreshold:10,headerResizeHiddenSnapThreshold:8,allowColumnReorder:!0,allowRowReorder:!0,reorderOffset:2,floatingGridColumnColor:"#8f8f8f66",floatingGridRowColor:"#8f8f8f66",floatingRowBackgroundColors:"#393939 #292929",floatingDividerOuterColor:"#000000",floatingDividerInnerColor:"#cccccc"}),Jt=(t,e)=>{let n=!1;const s=Ie(t,{...e,dispose:()=>{n||(n=!0,s.clear(),n=!1)}});return s};function iw(t,e,n=6){const s=la.hex.lab.raw(t);return s[0]=Math.max(s[0]-s[0]/n*e,0),`#${la.lab.hex(s)}`}function ow(t,e){const[n,s,i]=la.hex.rgb(t);return`rgba(${n}, ${s}, ${i}, ${e})`}const Fc={colorWithAlpha:ow,darkenForDepth:iw};class ft{constructor(e=5e3){this.cursor=null,this.order=e}onDown(e,n,s){return!1}onMove(e,n,s){return!1}onDrag(e,n,s){return!1}onLeave(e,n,s){return!1}onClick(e,n,s){return!1}onContextMenu(e,n,s){return!1}onDoubleClick(e,n,s){return!1}onUp(e,n,s){return!1}onWheel(e,n,s){return!1}}class Ju extends ft{constructor(){super(...arguments),this.resizingItems=[],this.hiddenItems=[],this.targetSizes=new Map,this.dragOffset=0}onDown(e,n){const{metrics:s}=n,{model:i}=n.props,o=n.getTheme();if(!s)throw new Error("metrics not set");const r=this.getSeparator(e,s,i,o);if(r!=null){const l=r.index;return this.dragOffset=0,this.draggingIndex=l,this.resizingItems=[l],this.hiddenItems=this.getHiddenItems(l,s).reverse(),this.targetSizes.clear(),this.addTargetSize(s,l),this.updateCursor(s,l),this.updateSeparator(n,r),!0}return!1}onMove(e,n){const{metrics:s}=n,{model:i}=n.props,o=n.getTheme();if(!s)throw new Error("metrics not set");const r=this.getSeparator(e,s,i,o);return r!=null?(this.updateCursor(s,r.index),!0):!1}onDrag(e,n){if(this.draggingIndex==null)return!1;const s=e[this.pointProperty],{metricCalculator:i,metrics:o}=n;if(!o)throw new Error("metrics not set");const r=n.getTheme(),l=o[this.visibleOffsetProperty],a=o[this.marginProperty],d=o[this.calculatedSizesProperty],c=o[this.modelIndexesProperty],u=o[this.firstIndexProperty],m=o[this.treePaddingProperty],p=new Map;let g=this.resizingItems[this.resizingItems.length-1];for(;g!=null;){const f=O(l,g),C=s-a-f-this.dragOffset,S=O(c,g),w=this.targetSizes.get(S),T=this.resizingItems.length>1,y=this.hiddenItems.indexOf(g);let E=O(d,S);g===u&&(E+=m);let R=C;Math.abs(C-E)<=r.headerResizeSnapThreshold?R=E:w!==void 0&&C>w&&(T&&y!==0||y>0)?R=w:C<=r.headerResizeHiddenSnapThreshold&&(R=0),p.set(S,R),C<-r.headerResizeSnapThreshold&&R===0?y>=0&&T?(this.resizingItems.pop(),this.removeTargetSize(o,g),g=this.resizingItems[this.resizingItems.length-1],this.dragOffset-=this.targetSizes.get(O(c,g))??0):(g=this.getNextShownItem(g,o),g!==null&&(this.resizingItems.push(g),this.addTargetSize(o,g))):w!==void 0&&C>w+r.headerResizeSnapThreshold&&R===w?y>0?(this.dragOffset+=R,g=this.hiddenItems[y-1],this.resizingItems.push(g),this.addTargetSize(o,g)):T?(this.resizingItems.pop(),this.removeTargetSize(o,g),g=this.resizingItems[this.resizingItems.length-1]):g=null:g=null}return p.forEach((f,C)=>{const S=i[this.initialSizesProperty].get(C)??d.get(C);f===S?this.resetSize(i,C):this.setSize(i,C,f)}),this.updateCursor(o,this.draggingIndex),!0}onUp(e,n){return this.draggingIndex!=null&&(this.draggingIndex=void 0,this.resizingItems=[],this.hiddenItems=[],this.targetSizes.clear(),this.updateSeparator(n,null)),!1}onDoubleClick(e,n){const{metrics:s,metricCalculator:i}=n,{model:o}=n.props,r=n.getTheme();if(!s)throw new Error("metrics not set");const l=this.getSeparator(e,s,o,r);if(l!=null){const a=s[this.modelIndexesProperty],d=O(a,l.index),c=O(s[this.calculatedSizesProperty],d),u=i[this.initialSizesProperty].get(d);return c===u?this.resetSize(i,d):this.setSize(i,d,c),n.forceUpdate(),!0}return!1}updateCursor(e,n){const s=e[this.visibleSizesProperty];O(s,n)===0?this.cursor=this.hiddenCursor:this.cursor=this.defaultCursor}addTargetSize(e,n){const s=e[this.modelIndexesProperty],i=e[this.userSizesProperty],o=e[this.calculatedSizesProperty],r=n===0?e[this.treePaddingProperty]:0,l=O(s,n);let a=i.get(l);(a==null||a===0)&&(a=O(o,l)+r),this.targetSizes.set(l,a)}removeTargetSize(e,n){const s=e[this.modelIndexesProperty],i=O(s,n);this.targetSizes.delete(i)}}class wl extends Ju{constructor(){super(...arguments),this.hiddenCursor="e-resize",this.defaultCursor="col-resize",this.pointProperty="x",this.userSizesProperty="userColumnWidths",this.visibleOffsetProperty="visibleColumnXs",this.visibleSizesProperty="visibleColumnWidths",this.marginProperty="rowHeaderWidth",this.calculatedSizesProperty="calculatedColumnWidths",this.initialSizesProperty="initialColumnWidths",this.modelIndexesProperty="modelColumns",this.firstIndexProperty="firstColumn",this.treePaddingProperty="treePaddingX",this.getHiddenItems=q.getHiddenColumns,this.getNextShownItem=q.getNextShownColumn,this.getSeparator=wl.getColumnSeparator}static getColumnSeparator(e,n,s,i){if(!i.allowColumnResize)return null;const{x:o,y:r,columnHeaderDepth:l}=e,{modelColumns:a}=n,d=q.getColumnSeparatorIndex(o,r,n,i);return d==null||l==null||l>0?null:a.get(d)!=null?{index:d,depth:0}:null}setSize(e,n,s){e.setColumnWidth(n,s)}resetSize(e,n){e.resetColumnWidth(n)}updateSeparator(e,n){e.setState({draggingColumnSeparator:n,isDragging:n!==null})}}const Zn=class{constructor(){this.getCachedTruncatedString=Jt((t,e,n,s,i)=>Zn.truncateToWidth(t,e,n,s,i),{max:1e4}),this.getCachedBackgroundColors=Jt((t,e)=>t.split(" ").map(n=>{const s=[];for(let i=0;i<e;i+=1)s.push(Fc.darkenForDepth(n,i,e));return s}),{max:1e3}),this.getCachedColorWithAlpha=Jt((t,e)=>Fc.colorWithAlpha(t,e),{max:1e3}),this.getCachedColorIsDark=Jt(t=>rl.isDark(t),{max:1e3})}static truncate(t,e){return e<t.length?t.substr(0,e)+"\u2026":t}static binaryTruncateToWidth(t,e,n,s=0,i=e.length,o){if(i>=e.length&&t.measureText(e).width<=n)return e;if(o!==void 0){const d=t.measureText(o).width;return o.repeat(Math.max(1,Math.floor(n/d)))}let r=s,l=Math.min(e.length-1,i),a=e;for(;l>=r;){const d=Math.ceil((l+r)/2),c=Zn.truncate(e,d);if(t.measureText(c).width<=n){if(a=c,r===d)break;r=d}else if(d===0){a=c;break}else l=d-1}return a}static truncateToWidth(t,e,n,s=Zn.DEFAULT_FONT_WIDTH,i){if(n<=0||e.length<=0)return"";const o=Math.min(Math.max(0,Math.floor(n/s/2)-5),e.length),r=Math.min(Math.ceil(n/s*2),e.length);return Zn.binaryTruncateToWidth(t,e,n,o,r,i)}drawCanvas(t){const{context:e}=t;e.save(),this.configureContext(e,t),this.drawBackground(e,t),this.drawGrid(e,t),this.drawHeaders(e,t),this.drawFooters(e,t),this.drawDraggingColumn(e,t),this.drawDraggingRow(e,t),this.drawScrollBars(e,t),e.restore()}configureContext(t,e){const{theme:n}=e;t.font=n.font,t.textBaseline="middle",t.lineCap="butt"}drawBackground(t,e){const{theme:n,metrics:s}=e,{width:i,height:o}=s;t.fillStyle=n.backgroundColor,t.fillRect(0,0,i,o)}drawGrid(t,e){const{metrics:n,draggingRow:s,draggingColumn:i}=e,{gridX:o,gridY:r}=n;t.translate(o,r),this.drawGridBackground(t,e,s==null&&i==null),this.drawCellContents(t,e),this.drawFloatingRows(t,e),this.drawFloatingColumns(t,e),t.translate(-o,-r)}drawFloatingRows(t,e){const{draggingRow:n,draggingColumn:s,metrics:i,theme:o}=e,{floatingTopRowCount:r,floatingBottomRowCount:l,floatingRows:a,rowCount:d,visibleColumns:c,allRowYs:u,allRowHeights:m}=i;if(a.length!==0){o.floatingRowBackgroundColors&&this.drawRowStripesForRows(t,e,a,o.floatingRowBackgroundColors),n==null&&s==null&&this.drawFloatingMouseRowHover(t,e),this.drawGridLinesForItems(t,e,c,a,o.floatingGridColumnColor,o.floatingGridRowColor),this.drawCellBackgroundsForItems(t,e,c,a),this.drawFloatingBorders(t,e),r>0&&this.drawSelectedRanges(t,e,{top:0,bottom:r-1,maxY:O(u,r-1)+O(m,r-1)-.5}),l>0&&this.drawSelectedRanges(t,e,{top:d-l-1,bottom:d-1,minY:O(u,d-l)+.5,maxY:O(u,d-1)+O(m,d-1)-.5});for(let p=0;p<c.length;p+=1){const g=c[p];for(let f=0;f<a.length;f+=1){const C=a[f];this.drawCellContent(t,e,g,C)}}}}drawFloatingColumns(t,e){const{draggingRow:n,draggingColumn:s,metrics:i,theme:o}=e,{floatingLeftColumnCount:r,floatingRightColumnCount:l,floatingLeftWidth:a,floatingRightWidth:d,floatingColumns:c,gridX:u,maxX:m,columnCount:p,visibleRows:g,allColumnXs:f,allColumnWidths:C,width:S,height:w}=i;if(c.length!==0){o.floatingRowBackgroundColors&&(this.drawRowStripesForRows(t,e,g,o.floatingRowBackgroundColors,0,a),this.drawRowStripesForRows(t,e,g,o.floatingRowBackgroundColors,S-u-d,m)),n==null&&s==null&&this.drawFloatingMouseRowHover(t,e),t.save(),t.beginPath(),t.rect(0,0,a,w),t.clip(),this.drawGridLinesForItems(t,e,c,g,o.floatingGridColumnColor,o.floatingGridRowColor),t.restore(),this.drawCellBackgroundsForItems(t,e,c,g),this.drawFloatingBorders(t,e),r>0&&this.drawSelectedRanges(t,e,{left:0,maxX:O(f,r-1)+O(C,r-1)}),l>0&&this.drawSelectedRanges(t,e,{left:p-l,right:p-1,minX:O(f,p-l)+.5,maxX:O(f,p-1)+O(C,p-1)});for(let T=0;T<c.length;T+=1){const y=c[T];for(let E=0;E<g.length;E+=1){const R=g[E];this.drawCellContent(t,e,y,R)}}}}drawFloatingBorders(t,e){const{metrics:n,theme:s}=e,{floatingTopRowCount:i,floatingBottomRowCount:o,floatingLeftColumnCount:r,floatingRightColumnCount:l,rowCount:a,columnCount:d,allRowYs:c,allColumnXs:u,allRowHeights:m,allColumnWidths:p,maxX:g,maxY:f}=n,{floatingDividerOuterColor:C,floatingDividerInnerColor:S}=s;if(t.lineWidth=3,t.beginPath(),t.strokeStyle=C,i>0){const w=O(c,i-1)+O(m,i-1)+.5;t.moveTo(0,w),t.lineTo(g,w)}if(o>0){const w=O(c,a-o)-.5;t.moveTo(0,w),t.lineTo(g,w)}if(r>0){const w=O(u,r-1)+O(p,r-1)+.5;t.moveTo(w,0),t.lineTo(w,f)}if(l>0){const w=O(u,d-l)-.5;t.moveTo(w,0),t.lineTo(w,f)}if(t.stroke(),t.beginPath(),t.lineWidth=1,t.strokeStyle=S,i>0){const w=O(c,i-1)+O(m,i-1)+.5;t.moveTo(0,w),t.lineTo(g,w)}if(o>0){const w=O(c,a-o)-.5;t.moveTo(0,w),t.lineTo(g,w)}if(r>0){const w=O(u,r-1)+O(p,r-1)+.5;t.moveTo(w,0),t.lineTo(w,f)}if(l>0){const w=O(u,d-l)-.5;t.moveTo(w,0),t.lineTo(w,f)}t.stroke()}drawGridBackground(t,e,n=!1){this.drawRowStripes(t,e),n&&(this.drawMouseColumnHover(t,e),this.drawMouseRowHover(t,e)),this.drawGridLines(t,e),this.drawCellBackgrounds(t,e);const{metrics:s}=e,{bottom:i,right:o,floatingBottomRowCount:r,floatingLeftColumnCount:l,floatingRightColumnCount:a,floatingTopRowCount:d,columnCount:c,rowCount:u,allRowHeights:m,allRowYs:p,allColumnXs:g,allColumnWidths:f,width:C,height:S}=s;this.drawSelectedRanges(t,e,{bottom:Math.min(i,u-r-1),right:Math.min(o,c-a-1),minX:l>0&&g.has(l+1)?O(g,l+1):-10,minY:d>0&&p.has(d+1)?O(p,d+1):-10,maxX:a>0&&g.has(c-a-1)?O(g,c-a-1)+O(f,c-a-1)-.5:C+10,maxY:r>0&&p.has(u-r-1)?O(p,u-r-1)+O(m,u-r-1)-.5:S+10})}drawRowStripes(t,e){const{metrics:n,theme:s}=e,{visibleRows:i}=n,{rowBackgroundColors:o}=s;!o||this.drawRowStripesForRows(t,e,i,o)}drawRowStripesForRows(t,e,n,s,i=0,o=e.metrics.maxX){const{theme:r,metrics:l,model:a}=e,{maxDepth:d,shadowBlur:c,shadowColor:u}=r,m=this.getCachedBackgroundColors(s,d),{allRowYs:p,allRowHeights:g}=l,f=new Map,C=[],S=[],w=(T,y)=>{const E=ze(a)?a.depthForRow(T):0,R=m[T%m.length],F=R[Math.min(E,R.length-1)];if(f.has(F)||f.set(F,[]),f.get(F).push(T),y!=null){const D=ze(a)?a.depthForRow(y):0;D<E?C.push(T):D>E&&S.push(y)}};for(let T=0;T<n.length;T+=1){const y=n[T],E=T>0?n[T-1]:void 0;w(y,E)}if(f.forEach((T,y)=>{t.fillStyle=y,t.beginPath();for(let E=0;E<T.length;E+=1){const R=T[E],F=O(p,R),D=O(g,R);t.rect(i,F,o,D)}t.fill()}),C.length>0){t.save();const T=this.getCachedColorWithAlpha(u,.15),y=this.getCachedColorWithAlpha(u,0),E=t.createLinearGradient(0,0,0,c);E.addColorStop(0,T),E.addColorStop(1,y),t.fillStyle=E;for(let R=0;R<C.length;R+=1){const F=C[R],D=O(p,F);t.translate(0,D),t.fillRect(i,0,o,c),t.translate(0,-D)}t.restore()}if(S.length>0){t.save();const T=this.getCachedColorWithAlpha(u,0),y=this.getCachedColorWithAlpha(u,.15),E=t.createLinearGradient(0,0,0,c);E.addColorStop(0,T),E.addColorStop(1,y),t.fillStyle=E;for(let R=0;R<S.length;R+=1){const F=S[R],D=O(p,F),_=O(g,F),H=D+_-c;t.translate(0,H),t.fillRect(i,0,o,c),t.translate(0,-H)}t.restore()}}drawMouseColumnHover(t,e){const{mouseX:n,mouseY:s,theme:i,metrics:o}=e;if(n==null||s==null)return;const r=q.getColumnAtX(n,o);if(r==null||i.columnHoverBackgroundColor==null)return;const{allColumnWidths:l,allColumnXs:a,maxY:d}=o;if(s>d)return;const c=O(a,r),u=O(l,r);t.fillStyle=i.columnHoverBackgroundColor,t.fillRect(c,0,u,d)}drawMouseRowHover(t,e){const{mouseX:n,mouseY:s,theme:i,metrics:o}=e;if(n==null||s==null)return;const{maxX:r}=o;if(n>r||i.rowHoverBackgroundColor==null)return;const l=q.getRowAtY(s,o);l!=null&&this.drawMouseRowHoverForRow(t,e,l)}drawFloatingMouseRowHover(t,e){const{mouseX:n,mouseY:s,theme:i,metrics:o}=e,{maxX:r,floatingTopRowCount:l,floatingBottomRowCount:a,rowCount:d,rowFooterWidth:c}=o;if(n==null||s==null||n>r+c||i.rowHoverBackgroundColor==null)return;const u=q.getRowAtY(s,o);u!=null&&(u<l||d-a<=u)&&this.drawMouseRowHoverForRow(t,e,u)}drawMouseRowHoverForRow(t,e,n){const{metrics:s,selectedRanges:i,theme:o}=e,{allRowHeights:r,allRowYs:l,maxX:a}=s,d=O(l,n),c=O(r,n);o.rowHoverBackgroundColor!=null&&(t.fillStyle=o.rowHoverBackgroundColor);for(let u=0;u<i.length;u+=1){const{startRow:m,endRow:p}=i[u];if(m!=null&&p!=null&&m<=n&&p>=n){o.selectedRowHoverBackgroundColor!=null&&(t.fillStyle=o.selectedRowHoverBackgroundColor);break}}t.fillRect(0,d,a,c)}drawGridLines(t,e){const{metrics:n,theme:s}=e,{visibleColumns:i,visibleRows:o}=n;this.drawGridLinesForItems(t,e,i,o,s.gridColumnColor,s.gridRowColor)}drawGridLinesForItems(t,e,n,s,i,o){i==null&&o==null||(t.lineWidth=1,t.beginPath(),i!=null&&(t.strokeStyle=i,this.drawGridLinesForColumns(t,e,n)),o!=null&&(t.strokeStyle=o,this.drawGridLinesForRows(t,e,s)),t.stroke())}drawGridLinesForColumns(t,e,n){const{metrics:s}=e,{allColumnXs:i,maxY:o}=s;for(let r=0;r<n.length;r+=1){const l=n[r],a=O(i,l)+.5;t.moveTo(a,0),t.lineTo(a,o)}}drawGridLinesForRows(t,e,n){const{metrics:s}=e,{allRowYs:i,maxX:o}=s,r=o;for(let l=0;l<n.length;l+=1){const a=n[l],d=O(i,a)+.5;t.moveTo(.5,d),t.lineTo(r-.5,d)}}drawCellBackgrounds(t,e){const{metrics:n}=e,{visibleColumns:s,visibleRows:i}=n;this.drawCellBackgroundsForItems(t,e,s,i)}drawCellBackgroundsForItems(t,e,n,s){t.save();for(let i=0;i<n.length;i+=1){const o=n[i];for(let r=0;r<s.length;r+=1){const l=s[r],a=r+1<s.length?s[r+1]:void 0;this.drawCellBackground(t,e,o,l,a)}}t.restore()}drawCellBackground(t,e,n,s,i){const{metrics:o,model:r,theme:l}=e,{firstColumn:a,modelColumns:d,modelRows:c,allColumnXs:u,allColumnWidths:m,allRowYs:p,allRowHeights:g}=o,f=O(c,s),C=O(d,n),S=r.backgroundColorForCell(C,f,l),w=n===a,T=ze(r)&&r.hasExpandableRows;if(S!=null){const y=O(u,n)+1,E=O(p,s)+1,R=O(m,n)-1,F=O(g,s)-1;t.fillStyle=S,t.fillRect(y,E,R,F)}w&&T&&this.drawCellRowTreeDepthLines(t,e,s,i)}drawCellContents(t,e){const{metrics:n}=e,{visibleColumns:s}=n;for(let i=0;i<s.length;i+=1){const o=s[i];this.drawColumnCellContents(t,e,o)}}drawColumnCellContents(t,e,n){const{metrics:s}=e,{allColumnXs:i,allColumnWidths:o,visibleRows:r,height:l}=s,a=O(i,n),d=O(o,n);t.save(),t.beginPath(),t.rect(a,0,d,l),t.clip();for(let c=0;c<r.length;c+=1){const u=r[c];this.drawCellContent(t,e,n,u)}t.restore()}getTextRenderMetrics(t,e,n,s){const{textAlign:i}=t,{metrics:o,model:r,theme:l}=e,{firstColumn:a,allColumnXs:d,allColumnWidths:c,allRowYs:u,allRowHeights:m}=o,{cellHorizontalPadding:p,treeDepthIndent:g,treeHorizontalPadding:f}=l,C=O(d,n),S=O(u,s),w=O(c,n),T=O(m,s),y=n===a;let E=0;ze(r)&&r.hasExpandableRows&&y&&(E=g*(r.depthForRow(s)+1)+f);const R=w-E;let F=C+p;const D=S+T*.5;return i==="right"?F=C+R-p:i==="center"&&(F=C+R*.5),F+=E,{width:R-p*2,x:F,y:D}}drawCellContent(t,e,n,s,i){const{metrics:o,model:r,theme:l}=e,{firstColumn:a,fontWidths:d,modelColumns:c,modelRows:u,allRowHeights:m}=o,{textColor:p}=l,g=O(m,s),f=O(u,s),C=O(c,n),S=i??r.textForCell(C,f),w=r.truncationCharForCell(C,f),T=n===a;if(S&&g>0){const y=r.textAlignForCell(C,f)||"left";t.textAlign=y;const E=r.colorForCell(C,f,l)||p;t.fillStyle=E;const{width:R,x:F,y:D}=this.getTextRenderMetrics(t,e,n,s),_=d.get(t.font)??Zn.DEFAULT_FONT_WIDTH,H=this.getCachedTruncatedString(t,S,R,_,w);H&&t.fillText(H,F,D)}T&&ze(r)&&r.hasExpandableRows&&this.drawCellRowTreeMarker(t,e,s)}drawCellRowTreeMarker(t,e,n){const{metrics:s,model:i,mouseX:o,mouseY:r,theme:l}=e,{firstColumn:a,gridX:d,gridY:c,allColumnXs:u,allColumnWidths:m,allRowYs:p,allRowHeights:g,visibleRowTreeBoxes:f}=s,{treeMarkerColor:C,treeMarkerHoverColor:S}=l,w=O(u,a),T=O(m,a),y=O(p,n),E=O(g,n);if(!ze(i)||!i.isRowExpandable(n))return;const R=O(f,n),F=o!=null&&r!=null&&o>=d+w&&o<=d+w+T&&r>=c+y&&r<=c+y+E?S:C;this.drawTreeMarker(t,e,w,y,R,F,i.isRowExpanded(n))}drawTreeMarker(t,e,n,s,i,o,r){const{x1:l,y1:a,x2:d,y2:c}=i,u=r?"\u229F":"\u229E",m=n+(l+d)*.5+.5,p=s+(a+c)*.5+.5;t.fillStyle=o,t.textAlign="center",t.fillText(u,m,p)}drawCellRowTreeDepthLines(t,e,n,s){const{metrics:i,model:o,theme:r}=e;if(!ze(o))return;const l=o.depthForRow(n);if(l===0)return;const{firstColumn:a,allColumnXs:d,allRowYs:c,allRowHeights:u}=i,{treeDepthIndent:m,treeHorizontalPadding:p,treeLineColor:g}=r,f=O(d,a),C=O(c,n),S=O(u,n),w=s!==void 0?o.depthForRow(s):0,T=l>w?l-w:0;if(t.strokeStyle=g,t.lineWidth=1,l-T>0){t.beginPath();for(let y=0;y<l-T;y+=1){const E=f+y*m+m*.5+p+.5;t.moveTo(E,C),t.lineTo(E,C+S)}t.stroke()}if(T>0){t.beginPath();for(let y=l-T;y<l;y+=1){const E=f+y*m+m*.5+p+.5;t.moveTo(E,C),t.lineTo(E,C+Math.ceil(S/2)),t.moveTo(E-.5,C+Math.ceil(S/2)+.5),t.lineTo(E+m-.5,C+Math.ceil(S/2)+.5)}t.stroke()}}drawHeaders(t,e){const{theme:n}=e;t.font=n.headerFont,this.drawColumnHeaders(t,e),this.drawRowHeaders(t,e)}drawFooters(t,e){const{theme:n}=e;t.font=n.headerFont,this.drawRowFooters(t,e)}drawColumnHeaders(t,e){const{mouseX:n,mouseY:s,theme:i,metrics:o,draggingColumnSeparator:r,isDragging:l,model:a}=e,{columnHeaderHeight:d,floatingColumns:c,gridX:u,width:m,visibleColumns:p,allColumnWidths:g,allColumnXs:f,floatingLeftColumnCount:C,floatingLeftWidth:S,floatingRightWidth:w,modelColumns:T,columnHeaderMaxDepth:y}=o;if(d<=0)return;const{headerHiddenSeparatorSize:E,headerHiddenSeparatorHoverColor:R,headerSeparatorColor:F,headerSeparatorHoverColor:D}=i,_=d*.5,H=d*(y-1)+d*.5-_*.5,U=C>0;if(t.save(),this.drawColumnHeadersForRange(t,e,[p[0],p[p.length-1]],{minX:u+S,maxX:m-w}),U&&this.drawColumnHeadersForRange(t,e,[c[0],c[c.length-1]],{minX:u,maxX:u+S}),F){t.strokeStyle=F;const A=[...g.entries()].filter(([Y,G])=>G===0).map(([Y])=>Y);t.beginPath(),t.fillStyle=F;for(let Y=0;Y<A.length;Y+=1){const G=A[Y],z=O(f,G),x=O(g,G),L=u+z+x+.5-E*.5;t.rect(L,H,E,_)}t.fill()}if(D){let{index:A,depth:Y}=r??{};if(A==null&&n!=null&&s!=null){const z=wl.getColumnSeparator(q.getGridPointFromXY(n,s,o),o,a,i);A=z?.index,Y=z?.depth}let G;if(A==null)G=!1;else{const z=T.get(A),x=T.get(A+1);z==null||x==null?G=!1:G=a.textForColumnHeader(z,Y)!==a.textForColumnHeader(x,Y)}if(G&&A!=null&&Y!=null&&(!l||r!=null)){t.strokeStyle=D;const z=O(f,A),x=O(g,A),L=u+z+x+.5,P=p.indexOf(A),Z=P<p.length-1?p[P+1]:null,ne=Z!=null?g.get(Z):null,B=x===0,W=ne!=null&&ne===0;B?(t.strokeStyle=R,t.fillStyle=R,t.fillRect(L,H,E*.5,_)):W&&(t.fillStyle=D,t.fillRect(L-E*.5,H,E*.5,_)),t.beginPath(),t.moveTo(L,(y-Y-1)*d),t.lineTo(L,(y-Y)*d-1),t.stroke()}}t.restore()}drawColumnHeadersForRange(t,e,n,s){const{model:i}=e,{columnHeaderMaxDepth:o}=i;if(o!==0)for(let r=0;r<=o;r+=1)this.drawColumnHeadersAtDepth(t,e,n,s,r)}drawColumnHeadersAtDepth(t,e,n,s,i){const{metrics:o,model:r,theme:l}=e,{modelColumns:a,allColumnXs:d,gridX:c,calculatedColumnWidths:u,userColumnWidths:m,allColumnWidths:p,movedColumns:g}=o,{columnHeaderHeight:f,columnWidth:C}=l,{columnHeaderMaxDepth:S}=r,{minX:w,maxX:T}=s,y=T-w;if(S===0)return;const E=n[0],R=n[1];if(t.save(),t.translate(0,(S-i-1)*f),i===0){this.drawColumnHeader(t,e,"",w,T);for(let F=E;F<=R;F+=1)this.drawColumnHeaderAtIndex(t,e,F,s)}if(i>0){let F=E;for(;F<=R;){const{columnCount:D}=o,_=O(a,F),H=r.textForColumnHeader(_,i),U=r.colorForColumnHeader(_,i);let A=O(d,F)+c,Y=A+O(p,F);if(H!=null){let G=F-1;for(;G>=0&&(Y-A<y||A>w);){const P=a.get(G)??q.getModelIndex(G,g);if(P==null||r.textForColumnHeader(P,i)!==H)break;A-=m.get(P)??u.get(P)??C,G-=1}let z=F+1;for(;z<D&&(Y-A<y||Y<T);){const P=a.get(z)??q.getModelIndex(z,g);if(r.textForColumnHeader(P,i)!==H)break;Y+=m.get(P)??u.get(P)??C,z+=1}F=z-1;const x=Y-A>=y;let L=A;x&&(Y<T?L=Y-y:A<w&&(L=w)),this.drawColumnHeader(t,e,H,L,Math.min(Y-A,y),{backgroundColor:U??void 0},s)}F+=1}}t.restore()}drawColumnHeaderAtIndex(t,e,n,s){const{metrics:i,model:o}=e,{modelColumns:r,allColumnWidths:l,allColumnXs:a,gridX:d}=i,c=O(l,n),u=O(a,n)+d,m=O(r,n),p=o.textForColumnHeader(m);p!=null&&this.drawColumnHeader(t,e,p,u,c,{backgroundColor:o.colorForColumnHeader(m)??void 0},s)}drawColumnHeader(t,e,n,s,i,o,r){if(i<=0)return;const{metrics:l,theme:a}=e,{headerHorizontalPadding:d,columnHeaderHeight:c,headerBackgroundColor:u,headerColor:m,headerSeparatorColor:p,black:g,white:f}=a,{fontWidths:C,width:S}=l,w=C.get(t.font)??Zn.DEFAULT_FONT_WIDTH,y=(i-d*2)/w,{backgroundColor:E=u,separatorColor:R=p}=o??{};let{textColor:F=m}=o??{};try{const B=this.getCachedColorIsDark(E),W=this.getCachedColorIsDark(F);B&&W?F=f:!B&&!W&&(F=g)}catch{}let{minX:D=0,maxX:_=S}=r??{};t.save(),t.rect(D,0,_-D,c),t.clip(),E!=null&&(t.fillStyle=E,t.fillRect(s,0,i,c)),R!=null&&(t.strokeStyle=R,t.beginPath(),s>0&&(t.moveTo(s+.5,0),t.lineTo(s+.5,c)),t.moveTo(s+i+.5,0),t.lineTo(s+i+.5,c),t.moveTo(s,c-.5),t.lineTo(s+i,c-.5),t.stroke()),t.beginPath(),t.rect(s,0,i,c),t.clip(),t.fillStyle=F;let H=n;y<=0?H="":H.length>y&&(H=`${H.substring(0,y-1)}\u2026`);const U=H.length*w;let A=s+i*.5;const Y=c*.5;D+=d,_-=d;const G=s+d,z=Qe(G,D,_),x=s+i-d,P=Qe(x,D,_)-z,Z=A-U*.5<D,ne=A+U*.5>_;Z?U<P?A=D+U*.5:A=x-U*.5:ne&&(U<P?A=_-U*.5:A=G+U*.5),t.textAlign="center",t.fillText(H,A,Y),t.restore()}drawRowHeaders(t,e){const{mouseX:n,mouseY:s,metrics:i,theme:o,draggingRowSeparator:r}=e,{gridY:l,rowHeaderWidth:a,height:d,visibleRows:c,allRowHeights:u,allRowYs:m}=i;if(a<=0)return;const{headerBackgroundColor:p,headerColor:g,headerHiddenSeparatorSize:f,headerHiddenSeparatorHoverColor:C,headerSeparatorColor:S,headerSeparatorHoverColor:w}=o,T=a*.5,y=a*.5-T*.5;if(t.save(),t.beginPath(),t.fillStyle=p,t.fillRect(0,0,a,d),S){t.strokeStyle=S,t.beginPath(),t.moveTo(0,l+.5),t.lineTo(a,l+.5);const E=[];let R=!1;for(let F=0;F<c.length;F+=1){const D=c[F],_=O(m,D),H=O(u,D);if(H>0){const U=l+_+H+.5;t.moveTo(0,U),t.lineTo(a,U),R=!1}else R||(R=!0,E.push(D))}t.moveTo(a-.5,0),t.lineTo(a-.5,d),t.stroke(),t.beginPath(),t.fillStyle=S;for(let F=0;F<E.length;F+=1){const D=E[F],_=O(m,D),H=O(u,D),U=l+_+H+.5-f*.5;t.rect(y,U,T,f)}t.fill()}if(w){let{index:E=null}=r??{};if(E==null&&n!=null&&s!=null&&(E=q.getRowSeparatorIndex(n,s,i,o)),E!=null){t.strokeStyle=w;const R=O(m,E),F=O(u,E),D=l+R+F+.5,_=c.indexOf(E),H=_<c.length-1?c[_+1]:null,U=H!=null?u.get(H):null,A=F===0,Y=U!=null&&U===0;A?(t.strokeStyle=C,t.fillStyle=C,t.fillRect(y,D,T,f*.5)):Y&&(t.fillStyle=w,t.fillRect(y,D-f*.5,T,f*.5)),t.beginPath(),t.moveTo(.5,D),t.lineTo(a+.5,D),t.stroke()}}t.beginPath(),t.rect(0,l,a,d),t.clip(),t.fillStyle=g,t.textAlign="right";for(let E=0;E<c.length;E+=1){const R=c[E],F=O(u,R),D=O(m,R)+l;this.drawRowHeader(t,e,R,D,F)}t.restore()}drawRowHeader(t,e,n,s,i){if(i<=0)return;const{metrics:o,model:r,theme:l}=e,{modelRows:a,rowHeaderWidth:d}=o,c=O(a,n),u=d-l.cellHorizontalPadding,m=s+i*.5;t.fillText(r.textForRowHeader(c),u,m)}drawRowFooters(t,e){const{mouseX:n,mouseY:s,metrics:i,model:o,theme:r,draggingRowSeparator:l}=e,{gridY:a,gridX:d,maxX:c,modelRows:u,rowFooterWidth:m,height:p,verticalBarWidth:g,visibleRows:f,allRowHeights:C,allRowYs:S,width:w}=i;if(m<=0)return;const{cellHorizontalPadding:T,headerBackgroundColor:y,headerColor:E,headerHiddenSeparatorSize:R,headerHiddenSeparatorHoverColor:F,headerSeparatorColor:D,headerSeparatorHoverColor:_}=r,H=m*.5,U=m*.5-H*.5,A=Math.min(d+c,w-m-g);if(t.save(),t.beginPath(),t.fillStyle=y,t.fillRect(A,a,m,p),D){t.strokeStyle=D,t.beginPath(),t.moveTo(A,a+.5),t.lineTo(m,a+.5);const G=[];let z=!1;for(let x=0;x<f.length;x+=1){const L=f[x],P=O(S,L),Z=O(C,L);if(Z>0){const ne=a+P+Z+.5;t.moveTo(A+.5,ne),t.lineTo(A+m-.5,ne),z=!1}else z||(z=!0,G.push(L))}t.moveTo(A+.5,a),t.lineTo(A+.5,p),t.stroke(),t.beginPath(),t.fillStyle=D;for(let x=0;x<G.length;x+=1){const L=G[x],P=O(S,L),Z=O(C,L),ne=a+P+Z+.5-R*.5;t.rect(A+U,ne,H,R)}t.fill()}if(_){let{index:G=null}=l??{};if(G==null&&n!=null&&s!=null&&(G=q.getRowSeparatorIndex(n,s,i,r)),G!=null){t.strokeStyle=_;const z=O(S,G),x=O(C,G),L=a+z+x+.5,P=f.indexOf(G),Z=P<f.length-1?f[P+1]:null,ne=Z!=null?C.get(Z):null,B=x===0,W=ne!=null&&ne===0;B?(t.strokeStyle=F,t.fillStyle=F,t.fillRect(U,L,H,R*.5)):W&&(t.fillStyle=_,t.fillRect(U,L-R*.5,H,R*.5)),t.beginPath(),t.moveTo(A+.5,L),t.lineTo(A+m+.5,L),t.stroke()}}t.beginPath(),t.rect(A,a,m,p),t.clip(),t.fillStyle=E,t.textAlign="left";const Y=A+T;for(let G=0;G<f.length;G+=1){const z=f[G],x=O(C,z);if(x>0){const L=O(S,z)+a,P=O(u,z),Z=L+x*.5;t.fillText(o.textForRowFooter(P),Y,Z)}}t.restore()}drawSelectedRanges(t,e,n={}){const{cursorColumn:s,cursorRow:i,draggingRow:o,draggingColumn:r,editingCell:l,metrics:a,model:d,selectedRanges:c,theme:u}=e,{allColumnWidths:m,allColumnXs:p,allRowHeights:g,allRowYs:f,width:C,height:S}=a,{left:w=a.left,top:T=a.top,right:y=a.right,bottom:E=a.bottom,minY:R=-10,maxY:F=S+10,minX:D=-10,maxX:_=C+10}=n;if(c.length===0)return;const H=tt(d)&&d.isEditable&&l==null&&o==null&&r==null&&s!=null&&i!=null&&p.has(s)&&f.has(i);if(H){const U=O(p,s),A=O(f,i),Y=O(m,s),G=O(g,i);t.save(),t.beginPath(),t.rect(0,0,C,S),t.rect(U,A,Y,G),t.clip("evenodd")}t.beginPath();for(let U=0;U<c.length;U+=1){const A=c[U],Y=A.startColumn!==null?A.startColumn:w,G=A.startRow!==null?A.startRow:T,z=A.endColumn!==null?A.endColumn:y,x=A.endRow!==null?A.endRow:E;if(x>=T&&E>=G&&z>=w&&y>=Y){const L=Y>=w&&p.has(Y)?Math.round(O(p,Y))+.5:D,P=G>=T&&f.has(G)?Math.max(Math.round(O(f,G))+.5,.5):R,Z=z<=y&&p.has(z)?Math.round(O(p,z)+O(m,z))-.5:_,ne=x<=E&&f.has(x)?Math.round(O(f,x)+O(g,x))-.5:F;t.rect(L,P,Z-L,ne-P)}t.fillStyle=u.selectionColor,t.fill(),t.save(),t.clip(),t.strokeStyle=u.selectionOutlineCasingColor,t.lineWidth=3,t.stroke(),t.restore(),t.strokeStyle=u.selectionOutlineColor,t.lineWidth=1,t.stroke()}H&&s!=null&&i!=null&&(t.restore(),this.drawActiveCell(t,e,s,i))}drawActiveCell(t,e,n,s,i=Zn.ACTIVE_CELL_BORDER_WIDTH){const{metrics:o,theme:r}=e,{allColumnWidths:l,allColumnXs:a,allRowHeights:d,allRowYs:c}=o,u=O(a,n),m=O(c,s),p=O(l,n),g=O(d,s);let f=u-i*.5,C=m-i*.5,S=p+i,w=g+i;f<=0&&(S+=f-1,f=1),C<=0&&(w+=C-1,C=1);const{lineWidth:T}=t;t.beginPath(),t.lineWidth=i,t.strokeStyle=r.selectionOutlineColor,this.drawRoundedRect(t,f,C,S,w),t.stroke(),t.lineWidth=T}drawRoundedRect(t,e,n,s,i,o=Zn.DEFAULT_EDGE_RADIUS){t.beginPath(),t.moveTo(e+o,n),t.lineTo(e+s-o,n),t.quadraticCurveTo(e+s,n,e+s,n+o),t.lineTo(e+s,n+i-o),t.quadraticCurveTo(e+s,n+i,e+s-o,n+i),t.lineTo(e+o,n+i),t.quadraticCurveTo(e,n+i,e,n+i-o),t.lineTo(e,n+o),t.quadraticCurveTo(e,n,e+o,n),t.closePath()}drawDraggingColumn(t,e){const{draggingColumn:n,metrics:s,mouseX:i,theme:o,model:r}=e;if(n==null||i==null)return;const{range:l,depth:a}=n,{gridX:d,gridY:c,allColumnXs:u,allColumnWidths:m,height:p,width:g,columnHeaderMaxDepth:f,columnHeaderHeight:C,movedColumns:S,modelColumns:w,floatingLeftWidth:T}=s,y=w.get(l[0])??q.getModelIndex(l[0],S),E=r.getColumnHeaderGroup(y,a);if(a>0&&!E)return;const[R,F]=l,D=O(u,R),H=O(u,F)+O(m,F)-D,U=n.left,{backgroundColor:A,font:Y,headerFont:G,reorderOffset:z,shadowBlur:x,shadowColor:L}=o,P=(f-a-1)*C;t.save(),t.translate(d,0),t.save(),t.beginPath(),t.rect(T,0,g,p),t.clip(),t.fillStyle=A,t.fillRect(D,P,H,p),t.restore(),t.translate(0,z),t.save(),t.shadowColor=L,t.shadowBlur=x,t.fillStyle=A,t.fillRect(n.left,P+z,n.width,p),t.restore(),t.beginPath(),t.rect(n.left,P,n.width+1,p),t.clip(),t.translate(U-D,0),t.font=G;const Z=[];for(let ne=n.range[0];ne<=n.range[1];ne+=1)Z.push(ne);this.drawColumnHeaders(t,e),this.drawColumnHeadersForRange(t,e,[Z[0],Z[Z.length-1]],{minX:D,maxX:g}),t.translate(0,c),t.font=Y,this.drawGridBackground(t,e);for(let ne=R;ne<=F;ne+=1)this.drawColumnCellContents(t,e,ne);t.restore()}drawDraggingRow(t,e){const{draggingRow:n,draggingRowOffset:s,metrics:i,mouseY:o,theme:r}=e;if(n==null||o==null)return;const{gridX:l,gridY:a,allRowYs:d,allRowHeights:c,width:u}=i,m=O(d,n),p=O(c,n)+1,{backgroundColor:g,font:f,headerFont:C,reorderOffset:S,shadowBlur:w,shadowColor:T}=r;t.save(),t.translate(0,a),t.fillStyle=g,t.fillRect(0,m,u,p),t.translate(l+S,o-m-a-(s??0)),t.save(),t.shadowColor=T,t.shadowBlur=w,t.fillStyle=g,t.fillRect(-l,m,u,p),t.restore(),t.beginPath(),t.rect(-l,m,u,p),t.clip(),t.font=f,this.drawGridBackground(t,e),this.drawCellContents(t,e),t.translate(-l,-a),t.font=C,this.drawRowHeaders(t,e),t.restore()}drawScrollBars(t,e){const{isDraggingHorizontalScrollBar:n,isDraggingVerticalScrollBar:s,isDragging:i,metrics:o,mouseX:r,mouseY:l,theme:a}=e;if(a.scrollBarSize<=0)return;const{width:d,height:c,handleHeight:u,handleWidth:m,scrollX:p,scrollY:g,hasHorizontalBar:f,hasVerticalBar:C,barWidth:S,barHeight:w,barLeft:T,barTop:y}=o,{scrollBarBackgroundColor:E,scrollBarHoverBackgroundColor:R,scrollBarCasingColor:F,scrollBarCornerColor:D,scrollBarColor:_,scrollBarHoverColor:H,scrollBarActiveColor:U,scrollBarSize:A,scrollBarHoverSize:Y,scrollBarCasingWidth:G,scrollBarSelectionTick:z,scrollBarSelectionTickColor:x,scrollBarActiveSelectionTickColor:L,autoSelectRow:P,autoSelectColumn:Z}=a,ne=r!=null&&l!=null&&r<=d&&l<=c,B=s||C&&!n&&!i&&r!=null&&l!=null&&r>=d-Y&&l>=y&&ne,W=n||f&&!s&&!i&&!B&&r!=null&&l!=null&&l>=c-Y&&r>=T&&ne,X=W?Y:A,se=B?Y:A;if(t.translate(T,y),f&&C&&(t.fillStyle=F,t.fillRect(d-T-A,c-y-A,A,A),t.fillStyle=D,t.fillRect(d-T-A+G,c-y-A+G,A-G,A-G)),f){const ce=p,Q=c-y-X;if(t.fillStyle=F,t.fillRect(0,Q,S,X-G),t.fillStyle=W?R:E,t.fillRect(0,Q+G,S,X-G),n?t.fillStyle=U:W?t.fillStyle=H:t.fillStyle=_,t.fillRect(ce,Q+G,m,X-G),!P&&z&&x!=null&&L!=null){t.fillStyle=x;const{selectedRanges:he,cursorColumn:be}=e,{lastLeft:Re,columnCount:et}=o,je=[...he].filter(De=>De.startColumn!=null&&De.endColumn!=null).map(De=>[De.startColumn,De.endColumn]).sort(q.compareRanges),En=q.mergeSortedRanges(je),Ut=De=>De<=Re?De/Re*(S-m):S-m+(De-Re)/(et-Re)*m;for(let De=0;De<En.length;De+=1){const mt=En[De],at=mt[0],Rt=mt[1];if(at!=null&&Rt!=null&&(at!==be||Rt!==be)){const Vt=Ut(at),yn=Math.max(1,Math.round(Ut(Rt+1)-Vt)),on=X-G;t.fillRect(Vt,Q+G+Math.round(on/3),yn,Math.round(on/3))}}if(be!=null){const De=Ut(be),mt=2,at=X-G;t.fillStyle=L,t.fillRect(De,Q+G,mt,at)}}}if(C){const ce=d-T-se,Q=g;if(t.fillStyle=F,t.fillRect(ce,0,se-G,w),t.fillStyle=B?R:E,t.fillRect(ce+G,0,se-G,w),s?t.fillStyle=U:B?t.fillStyle=H:t.fillStyle=_,t.fillRect(ce+G,Q,se-G,u),!Z&&z&&x!=null&&L!=null){const{selectedRanges:he,cursorRow:be}=e,{lastTop:Re,rowCount:et}=o,yt=De=>De<=Re?De/Re*(w-u):w-u+(De-Re)/(et-Re)*u;t.fillStyle=x;const En=[...he].filter(De=>De.startRow!=null&&De.endRow!=null).map(De=>[De.startRow,De.endRow]).sort(q.compareRanges),Ut=q.mergeSortedRanges(En);for(let De=0;De<Ut.length;De+=1){const mt=Ut[De],at=mt[0],Rt=mt[1];if(at!=null&&Rt!=null&&(at!==be||Rt!==be)){const Vt=yt(at),yn=se-G,on=Math.max(1,Math.round(yt(Rt+1)-Vt));t.fillRect(ce+G+Math.round(yn/3),Vt,Math.round(yn/3),on)}}if(be!=null){const De=Math.round(yt(be)),mt=se-G,at=2;t.fillStyle=L,t.fillRect(ce+G,De,mt,at)}}}t.translate(-T,-y)}};let li=Zn;li.DEFAULT_FONT_WIDTH=10;li.DEFAULT_EDGE_RADIUS=2;li.ACTIVE_CELL_BORDER_WIDTH=2;const Dc=100;class rw extends ft{constructor(){super(...arguments),this.hasExtendedFloating=!1}onDown(e,n,s){const{x:i,y:o,column:r,row:l}=e,{metrics:a}=n;if(!a)throw new Error("metrics not set");const{gridX:d,gridY:c,maxX:u,maxY:m}=a,p=i-d,g=o-c;if(p<0||g<0||r==null&&p>u||l==null&&g>m)return!1;const f=q.isModifierKeyDown(s),C=s.shiftKey;f||(C?n.trimSelectedRanges():n.clearSelectedRanges());const S=n.getTheme(),{autoSelectRow:w,autoSelectColumn:T}=S;return(r!==null||!T)&&(l!==null||!w)&&(n.focus(),n.moveCursorToPosition(r,l,C,!1,C&&f)),this.startPoint=e,this.hasExtendedFloating=!1,this.dragBounds=q.getScrollDragBounds(a,l,r),!0}onDrag(e,n){if(this.startPoint===void 0)return!1;this.stopTimer();const{row:s,column:i}=this.startPoint,{x:o,y:r}=e;let{row:l,column:a}=e;const{metrics:d}=n;if(!d)throw new Error("metrics not set");const{left:c,lastLeft:u,top:m,lastTop:p,columnWidth:g,rowHeight:f}=d,C=q.getScrollDragBounds(d,s,i);let S=0,w=0;if(c<u&&(o<C.x1?S=o-C.x1:o>C.x2&&(S=o-C.x2)),m<p&&(r<C.y1?w=r-C.y1:r>C.y2&&(w=r-C.y2)),S!==0||w!==0)this.startTimer(n,e,S>0?Math.ceil(S/g):Math.floor(S/g),w>0?Math.ceil(w/f):Math.floor(w/f));else if(l!=null&&a!=null){const{floatingTopRowCount:T,floatingBottomRowCount:y,floatingLeftColumnCount:E,floatingRightColumnCount:R,columnCount:F,rowCount:D,bottom:_,right:H,topVisible:U,bottomVisible:A,leftVisible:Y,rightVisible:G}=d;this.hasExtendedFloating||(s!==null&&s<T&&l>=T?(l=T,this.hasExtendedFloating=!0):s!==null&&s>=D-y&&l<D-y&&(l=D-y-1,this.hasExtendedFloating=!0),i!==null&&i<E&&a>=E?(a=E,this.hasExtendedFloating=!0):i!==null&&i>=F-R&&a<F-R&&(a=F-R-1,this.hasExtendedFloating=!0)),s!==null&&!q.isFloatingRow(s,d)&&q.isFloatingRow(l,d)&&(s>l&&l<m?l=U-1:s<l&&l>_&&(l=A+1)),i!==null&&!q.isFloatingColumn(i,d)&&q.isFloatingColumn(a,d)&&(i>a&&a<c?a=Y-1:i<a&&a>H&&(a=G+1)),n.moveCursorToPosition(a,l,!0,!0)}return!0}onUp(e,n){return this.startPoint!==void 0&&(this.startPoint=void 0,this.dragBounds=void 0,this.stopTimer(),n.commitSelection()),!1}moveSelection(e,n,s,i){const{row:o,column:r}=n,{metrics:l}=e;if(!l)throw new Error("metrics not set");const{selectionEndRow:a,selectionEndColumn:d}=e.state;if(a==null||d==null)throw new Error("selection not set");const{rowCount:c,columnCount:u}=l,m=s<0&&r!=null?r:0,p=s>0&&r!=null?r:u-1,g=i<0&&o!=null?o:0,f=i>0&&o!=null?o:c-1;e.moveCursorToPosition(Math.min(Math.max(m,d+s),p),Math.min(Math.max(g,a+i),f),!0),this.lastTriggerTime=Date.now()}startTimer(e,n,s,i){this.stopTimer();const o=this.lastTriggerTime!=null?Dc-Math.min(Dc,Date.now()-this.lastTriggerTime):0;this.timer=setTimeout(()=>{this.moveSelection(e,n,s,i),this.startTimer(e,n,s,i)},o)}stopTimer(){this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0)}}const Nc=5,lw=1e3/60,cr=10;function bs(t,e,n,s){const{modelColumns:i,movedColumns:o,allColumnXs:r,columnCount:l,allColumnWidths:a,userColumnWidths:d,calculatedColumnWidths:c,floatingLeftWidth:u,maxX:m}=n;if(e==null||t==null||t>l||t<0)return null;const p=i.get(t)??q.getModelIndex(t,o),g=s.getColumnHeaderGroup(p,e),f=g!=null;let C,S,w;if(g!=null){const[T,y]=g.getVisibleRange(o);C=r.get(T)??u,S=(r.get(y)??m)+(a.get(y)??0),w=[T,y]}else{const T=r.get(t);if(T==null)return null;C=T,S=C+(a.get(t)??d.get(p)??c.get(p)??0),w=[t,t]}return{visibleIndex:t,modelIndex:p,left:C,right:S,width:S-C,isColumnGroup:f,range:w,depth:e}}class aw extends ft{constructor(){super(...arguments),this.cursor=null,this.draggingColumn=null}setScrollInterval(e,n){this.scrollingInterval!=null&&n===this.scrollingDirection||(this.scrollingDirection=n,this.scrollingInterval=window.setInterval(()=>{const{metrics:s}=e;if(!s)return;const{left:i,lastLeft:o,leftOffset:r,userColumnWidths:l,calculatedColumnWidths:a,movedColumns:d,allColumnWidths:c}=s;let u=i,m=r;if(n==="left")for(m-=cr;m<0;){u-=1;const f=q.getModelIndex(i-1,d),C=l.get(f)??a.get(f);C===void 0?m=0:m+=C,u<0&&(m=0,u=0)}else{m+=cr;let f=c.get(i);for(;f!==void 0&&m>f;){u+=1,m-=f;const C=q.getModelIndex(i+1,d);f=l.get(C)??a.get(C),u>o&&(m=0,u=o)}}const{mouseX:p,mouseY:g}=e.state;s==null||p==null||g==null||(this.moveDraggingColumn(p,e,n==="left"?-cr:cr),e.setState({left:u,leftOffset:m}),(n==="left"&&u===0&&r===0||n==="right"&&u===o)&&this.clearScrollInterval())},lw))}clearScrollInterval(){this.scrollingDirection=void 0,window.clearInterval(this.scrollingInterval),this.scrollingInterval=void 0}onLeave(){return this.clearScrollInterval(),!1}onDown(e,n){const{model:s}=n.props,{x:i,column:o,columnHeaderDepth:r}=e,{metrics:l}=n;if(!l)throw new Error("Metrics not set");const a=bs(o,r,l,s);if(o==null||a==null||r==null||r>0&&!a.isColumnGroup)return!1;const{rowHeaderWidth:d}=l;return this.initialGridPoint=e,this.draggingColumn=null,this.cursor=null,a.modelIndex!=null&&r!=null&&s.isColumnMovable(a.modelIndex,r)&&(this.draggingOffset=i-a.left-d,this.initialOffset=this.draggingOffset),!1}onDrag(e,n,s){if(this.draggingOffset===void 0||this.initialGridPoint===void 0||this.initialOffset===void 0)return!1;const{x:i,y:o}=e,{columnHeaderDepth:r}=this.initialGridPoint,{model:l}=n.props;let{draggingColumn:a}=this;const{metrics:d}=n;if(!d)throw new Error("Metrics not set");if(!a&&Math.abs(this.initialGridPoint.x-i)<Nc&&Math.abs(this.initialGridPoint.y-o)<Nc)return!1;if(a==null){const c=bs(this.initialGridPoint.column,r,d,l);if(!c||r==null||!l.isColumnMovable(c.modelIndex)||r>0&&!c.isColumnGroup||c.range[0]==null)return!1;a={range:c.range,depth:r,left:c.left,width:c.width};const u=bs(a.range[0],0,d,l),m=bs(a.range[1],0,d,l);if(!u||!m)return!1;this.draggingColumn=a,n.setState({draggingColumn:a,isDragging:!0})}return this.cursor="move",this.moveDraggingColumn(e.x,n,s.movementX),!0}moveDraggingColumn(e,n,s){if(this.draggingOffset===void 0||this.initialGridPoint===void 0||this.initialOffset===void 0||this.draggingColumn==null||s===0)return;if(this.initialOffset!==this.draggingOffset){this.draggingOffset<this.initialOffset&&this.initialOffset<this.draggingOffset+s||this.draggingOffset>this.initialOffset&&this.initialOffset>this.draggingOffset+s?this.draggingOffset=this.initialOffset:this.draggingOffset+=s,this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},n.setState({draggingColumn:this.draggingColumn});return}const{depth:i}=this.draggingColumn,{model:o}=n.props,{movedColumns:r}=n.state,{metrics:l}=n;if(!l)throw new Error("Metrics not set");const{floatingLeftWidth:a,width:d,columnHeaderMaxDepth:c,allColumnXs:u}=l,m=s<0,p=bs(this.draggingColumn.range[0],i,l,o);if(!p)return;const g=e-this.draggingOffset,f=g+p.width;this.draggingColumn={...this.draggingColumn,left:g},n.setState({draggingColumn:this.draggingColumn});const C=bs(q.getColumnAtX(Qe(m?g:f,a,d),l,!0),i,l,o),S=o.getColumnHeaderParentGroup(p.modelIndex,p.depth);if(!C)return;if(S!==void 0){const F=S.getVisibleRange(r);if(C.visibleIndex<F[0]){const D=this.moveColumn(p,F[0],r);this.draggingOffset=e-(u.get(F[0])??0),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},this.clearScrollInterval(),n.setState({draggingColumn:this.draggingColumn,movedColumns:D});return}if(C.visibleIndex>F[1]){const D=this.moveColumn(p,F[1]-(p.range[1]-p.range[0]),r),{right:_=0}=bs(F[1],0,l,o)??{};this.draggingOffset=e-(_-p.width),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},this.clearScrollInterval(),n.setState({draggingColumn:this.draggingColumn,movedColumns:D});return}}if(!o.isColumnMovable(C.modelIndex)){let F=C.visibleIndex;if(m)for(F+=1;F<p.visibleIndex&&!o.isColumnMovable(q.getModelIndex(F,r));)F+=1;else for(F-=1;F>p.visibleIndex&&!o.isColumnMovable(q.getModelIndex(F,r));)F-=1;if(F!==p.visibleIndex){m||(F-=p.range[1]-p.range[0]);const _=this.moveColumn(p,F,r);n.setState({movedColumns:_,draggingColumn:this.draggingColumn})}const D=bs(F,0,l,o);m?this.draggingOffset=e-(D?.left??0):this.draggingOffset=e-((D?.right??0)-p.width),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},n.setState({draggingColumn:this.draggingColumn});return}if(g<=a?this.setScrollInterval(n,"left"):f>d?this.setScrollInterval(n,"right"):this.clearScrollInterval(),C.visibleIndex===p.visibleIndex||m&&p.visibleIndex<C.visibleIndex||!m&&p.visibleIndex>C.visibleIndex)return;const w=C.left+C.width*.5,T=o.getColumnHeaderParentGroup(p.modelIndex,p.depth);let y,E=(T?.depth??c)-1;for(;E>=0&&y===void 0;)y=o.getColumnHeaderGroup(C.modelIndex,E),E-=1;let R;m&&g<w&&(!y||C.visibleIndex===y.getVisibleRange(r)[0])&&(R=this.moveColumn(p,C.range[0],r)),!m&&f>w&&(!y||C.visibleIndex===y.getVisibleRange(r)[1])&&(R=this.moveColumn(p,C.range[1]-(p.range[1]-p.range[0]),r)),R&&(this.draggingColumn={...this.draggingColumn,left:g},n.setState({movedColumns:R,draggingColumn:this.draggingColumn}))}moveColumn(e,n,s){const i=e.isColumnGroup?q.moveRange(e.range,n,s):q.moveItem(e.visibleIndex,n,s),o=n-e.range[0],r=[e.range[0]+o,e.range[1]+o];return this.draggingColumn&&(this.draggingColumn={...this.draggingColumn,range:r}),i}onUp(e,n){return this.cursor=null,this.clearScrollInterval(),this.draggingOffset!=null?(this.draggingOffset=void 0,n.setState({draggingColumn:null,isDragging:!1}),!0):!1}}class od extends ft{constructor(){super(...arguments),this.cursor="default"}static getLeftWithOffsetFromRawLeft(e,n){const s=e.getTheme(),{metrics:i,metricCalculator:o}=e;if(!i)throw new Error("metrics not set");if(s.scrollSnapToColumn)return{left:Math.round(n),leftOffset:0};const r=Math.floor(n),l=n-r;let a=i.allColumnWidths.get(r);if(a==null){const c=e.getMetricState();a=o.getVisibleColumnWidth(r,c)}const d=a*l;return{left:r,leftOffset:d}}isInScrollBar(e,n){const s=n.getTheme(),{scrollBarSize:i,scrollBarHoverSize:o}=s,{metrics:r}=n;if(!r)throw new Error("metrics not set");const{x:l,y:a}=e,{barLeft:d,barWidth:c,height:u,hasHorizontalBar:m}=r;return m&&i>0&&a>=u-o&&a<u&&l>d&&l<d+c}getLeftWithOffset(e,n){const{metrics:s}=n;if(!s)throw new Error("metrics not set");const{x:i}=e,{barWidth:o,handleWidth:r,lastLeft:l,barLeft:a,columnCount:d,scrollableContentWidth:c,scrollableViewportWidth:u}=s,m=i-a,p=Qe((m-(this.dragOffset??0))/(o-r),0,1);if(d===1)return{left:0,leftOffset:p*(c-u)};const g=p*l;return od.getLeftWithOffsetFromRawLeft(n,g)}onDown(e,n){const{metrics:s}=n;if(!s)throw new Error("metrics not set");const{x:i}=e,{handleWidth:o,barLeft:r,scrollX:l}=s;if(!this.isInScrollBar(e,n))return!1;const a=i-r;if(a>=l&&a<=l+o)this.dragOffset=a-l,n.setState({isDraggingHorizontalScrollBar:!0});else{this.dragOffset=0;const{left:d,leftOffset:c}=this.getLeftWithOffset(e,n);n.setViewState({left:d,leftOffset:c,isDraggingHorizontalScrollBar:!0,isDragging:!0})}return!0}onDrag(e,n){if(this.dragOffset!=null){const{left:s,leftOffset:i}=this.getLeftWithOffset(e,n);return n.setViewState({left:s,leftOffset:i,isDraggingHorizontalScrollBar:!0,isDragging:!0}),!0}return!1}onMove(e,n){return this.isInScrollBar(e,n)}onUp(e,n){return this.dragOffset!==void 0&&(this.dragOffset=void 0,n.setState({isDraggingHorizontalScrollBar:!1,isDragging:!1})),this.isInScrollBar(e,n)}onClick(e,n){return this.isInScrollBar(e,n)}}class dw extends ft{constructor(){super(...arguments),this.cursor="move"}onDown(e,n){const{model:s}=n.props,{x:i,y:o,row:r}=e,{metrics:l}=n;if(!l)throw new Error("metrics not set");const{columnHeaderHeight:a,rowHeaderWidth:d,allRowYs:c}=l;if(i<=d&&r!==null&&s.isRowMovable(r)){const u=O(c,r);this.draggingOffset=o-u-a,n.setState({draggingRowOffset:this.draggingOffset})}return!1}onDrag(e,n){if(this.draggingOffset==null)return!1;const{model:s}=n.props;let{draggingRow:i}=n.state;const{mouseX:o,mouseY:r}=n.state;if(o==null||r==null)return!1;if(i==null){const{row:R}=n.getGridPointFromXY(o,r);if(R!=null&&!s.isRowMovable(R)||(i=R,n.setState({draggingRow:i,isDragging:!0}),i==null))return!1}const{metrics:l}=n;if(!l)throw new Error("metrics not set");const{top:a,lastTop:d,bottom:c,bottomVisible:u,rowCount:m,columnHeaderHeight:p,allRowHeights:g,allRowYs:f,height:C}=l;let S=p;if(a<i){const R=i-1;S=O(f,R)+O(g,R)*.5+p}let w=C;if(i<c){const R=i+1;w=O(f,R)+O(g,R)*.5+p}let{movedRows:T}=n.state;r<S&&i>0&&s.isRowMovable(i-1)?(T=q.moveItem(i,i-1,T),i-=1):w<r&&i<m-1&&s.isRowMovable(i+1)&&(T=q.moveItem(i,i+1,T),i+=1),n.setState({movedRows:T,draggingRow:i});const y=p+O(g,a)*.5,E=p+O(f,u)+O(g,u)*.5;return r<y&&a>0?n.setState({top:a-1}):r>E&&a<d&&n.setState({top:a+1}),!0}onUp(e,n){return this.draggingOffset!==void 0?(this.draggingOffset=void 0,n.setState({draggingRowOffset:null,draggingRow:null,isDragging:!1}),!0):!1}}class rd extends Ju{constructor(){super(...arguments),this.hiddenCursor="s-resize",this.defaultCursor="row-resize",this.pointProperty="y",this.userSizesProperty="userRowHeights",this.visibleOffsetProperty="visibleRowYs",this.visibleSizesProperty="visibleRowHeights",this.marginProperty="columnHeaderHeight",this.calculatedSizesProperty="calculatedRowHeights",this.initialSizesProperty="initialRowHeights",this.modelIndexesProperty="modelRows",this.firstIndexProperty="firstRow",this.treePaddingProperty="treePaddingY",this.getHiddenItems=q.getHiddenRows,this.getNextShownItem=q.getNextShownRow,this.getSeparator=rd.getRowSeparator}static getRowSeparator(e,n,s,i){if(!i.allowRowResize)return null;const{x:o,y:r}=e,l=q.getRowSeparatorIndex(o,r,n,i);return l!=null?{index:l,depth:0}:null}setSize(e,n,s){e.setRowHeight(n,s)}resetSize(e,n){e.resetRowHeight(n)}updateSeparator(e,n){e.setState({draggingRowSeparator:n,isDragging:n!==null})}}class Ai extends ft{static isInTreeBox(e,n){const{column:s,row:i,x:o,y:r}=e,{metrics:l}=n;if(!l)throw new Error("metrics not set");const{gridX:a,gridY:d,firstColumn:c,allColumnXs:u,allColumnWidths:m,allRowHeights:p,allRowYs:g,visibleRowTreeBoxes:f}=l;if(s===c&&i!=null&&f.get(i)!=null&&o>a&&r>d){const C=O(u,s),S=O(m,s),w=O(g,i),T=O(p,i);if(o>=a+C&&o<=a+C+S&&r>=d+w&&r<=d+w+T)return!0}return!1}onDown(e,n){return Ai.isInTreeBox(e,n)}onClick(e,n,s){if(Ai.isInTreeBox(e,n)){const{row:i}=e;if(i!==null)return n.toggleRowExpanded(i,q.isModifierKeyDown(s)),!0}return!1}}class cw extends ft{isInCorner(e,n){const s=n.getTheme(),{scrollBarSize:i}=s,{metrics:o}=n;if(!o)throw new Error("metrics not set");const{x:r,y:l}=e,{width:a,height:d,hasVerticalBar:c,hasHorizontalBar:u}=o;return i>0&&c&&u&&r>=a-i&&l>=d-i&&r<=a&&l<=d}onDown(e,n){return this.isInCorner(e,n)}onUp(e,n){return this.isInCorner(e,n)}onClick(e,n){return this.isInCorner(e,n)}}class ld extends ft{constructor(){super(...arguments),this.cursor="default"}static getTopWithOffsetFromRawTop(e,n){const s=e.getTheme(),{metrics:i,metricCalculator:o}=e;if(!i)throw new Error("metrics not set");if(s.scrollSnapToRow)return{top:Math.round(n),topOffset:0};const r=Math.floor(n),l=n-r;let a=i.allRowHeights.get(r);if(a==null){const c=e.getMetricState();a=o.getVisibleRowHeight(r,c)}const d=a*l;return{top:r,topOffset:d}}isInScrollBar(e,n){const s=n.getTheme(),{scrollBarSize:i,scrollBarHoverSize:o}=s,{metrics:r}=n;if(!r)throw new Error("metrics not set");const{x:l,y:a}=e,{barTop:d,barHeight:c,width:u,hasVerticalBar:m}=r;return m&&i>0&&l>=u-o&&l<u&&a>d&&a<d+c}getTopWithOffset(e,n){const{metrics:s}=n;if(!s)throw new Error("metrics not set");const{y:i}=e,{barHeight:o,handleHeight:r,lastTop:l,barTop:a,rowCount:d,scrollableContentHeight:c,scrollableViewportHeight:u}=s,m=i-a,p=Qe((m-(this.dragOffset??0))/(o-r),0,1);if(d===1)return{top:0,topOffset:p*(c-u)};const g=p*l;return ld.getTopWithOffsetFromRawTop(n,g)}onDown(e,n){const{metrics:s}=n;if(!s)throw new Error("metrics not set");const{y:i}=e,{handleHeight:o,barTop:r,scrollY:l}=s;if(!this.isInScrollBar(e,n))return!1;const a=i-r;if(a>=l&&a<=l+o)this.dragOffset=a-l,n.setState({isDraggingVerticalScrollBar:!0});else{this.dragOffset=0;const{top:d,topOffset:c}=this.getTopWithOffset(e,n);n.setViewState({top:d,topOffset:c,isDraggingVerticalScrollBar:!0,isDragging:!0})}return!0}onMove(e,n){return this.isInScrollBar(e,n)}onDrag(e,n){if(this.dragOffset!=null){const{top:s,topOffset:i}=this.getTopWithOffset(e,n);return n.setViewState({top:s,topOffset:i,isDraggingVerticalScrollBar:!0,isDragging:!0}),!0}return!1}onUp(e,n){return this.dragOffset!==void 0&&(this.dragOffset=void 0,n.setState({isDraggingVerticalScrollBar:!1,isDragging:!1})),this.isInScrollBar(e,n)}onClick(e,n){return this.isInScrollBar(e,n)}}class hw extends ft{onDoubleClick({column:e,row:n},s){const{model:i}=s.props;return tt(i)&&e!=null&&n!=null&&i.isEditableRange(ae.makeCell(e,n))?(s.startEditing(e,n),!0):!1}}class ci{constructor(e=5e3){this.order=e}onDown(e,n){return!1}}class uw extends ci{onDown(e,n){switch(e.key){case"a":if(q.isModifierKeyDown(e))return n.selectAll(),!0;break;case"ArrowUp":return this.handleArrowMove(0,-1,e,n);case"ArrowDown":return this.handleArrowMove(0,1,e,n);case"ArrowRight":return this.handleArrowMove(1,0,e,n);case"ArrowLeft":return this.handleArrowMove(-1,0,e,n);case"k":case"K":return q.isModifierKeyDown(e)?!1:this.handlePageUp(e,n);case"j":case"J":return q.isModifierKeyDown(e)?!1:this.handlePageDown(e,n);case"h":case"H":return q.isModifierKeyDown(e)?!1:(e.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(0,n.state.cursorRow,e.shiftKey),!0);case"l":case"L":{if(q.isModifierKeyDown(e))return!1;const{model:s}=n.props,{columnCount:i}=s;return e.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(i-1,n.state.cursorRow,e.shiftKey),!0}case"PageDown":return this.handlePageDown(e,n);case"PageUp":return this.handlePageUp(e,n);case"Home":return e.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(q.isModifierKeyDown(e)?n.state.cursorColumn:0,q.isModifierKeyDown(e)?0:n.state.cursorRow,e.shiftKey,!0,!0),!0;case"End":{const{model:s}=n.props,{columnCount:i,rowCount:o}=s;return e.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(q.isModifierKeyDown(e)?n.state.cursorColumn:i-1,q.isModifierKeyDown(e)?o-1:n.state.cursorRow,e.shiftKey,!0,!0),!0}case"Escape":return n.clearSelectedRanges(),{preventDefault:!1,stopPropagation:!1};case"Enter":if(n.state.selectedRanges.length>0)return n.moveCursorInDirection(e.shiftKey?ae.SELECTION_DIRECTION.UP:ae.SELECTION_DIRECTION.DOWN),!0;break;case"Tab":if(n.state.selectedRanges.length>0)return n.moveCursorInDirection(e.shiftKey?ae.SELECTION_DIRECTION.LEFT:ae.SELECTION_DIRECTION.RIGHT),!0;break}return!1}handleArrowMove(e,n,s,i){const o=s.shiftKey,r=q.isModifierKeyDown(s);o?i.trimSelectedRanges():i.clearSelectedRanges();const{cursorRow:l,cursorColumn:a,selectionEndColumn:d,selectionEndRow:c}=i.state,u=o?d:a,m=o?c:l;if(r){const{model:p}=i.props,{columnCount:g,rowCount:f}=p,C=r&&o;let S=null,w=null;e<0?(S=0,w=m):e>0?(S=g-1,w=m):n<0?(S=u,w=0):n>0&&(S=u,w=f-1),S!=null&&w!=null&&i.moveCursorToPosition(S,w,o,!0,C)}else{if(!i.metrics)throw new Error("grid.metrics are not set");const{theme:p}=i.props,{autoSelectRow:g=!1,autoSelectColumn:f=!1}=p;if(g&&e!==0){const{lastLeft:C}=i.metrics;let{left:S}=i.state;S=Qe(S+e,0,C),i.moveCursorToPosition(S,l,o,!1),i.setViewState({left:S})}else if(f&&n!==0){const{lastTop:C}=i.metrics;let{top:S}=i.state;S=Qe(S+n,0,C),i.moveCursorToPosition(S,a,o,!1),i.setViewState({top:S})}else i.moveCursor(e,n,o)}return!0}handlePageUp(e,n){const s=e.shiftKey;s?n.trimSelectedRanges():n.clearSelectedRanges();const{cursorColumn:i,selectionEndRow:o}=n.state,r=o,l=i;if(r==null)return!1;const a=n.getMetricState(),{metricCalculator:d}=n,{bottomVisible:c,topVisible:u,hasHorizontalBar:m}=d.getMetrics(a);let p=r-(c-u);p-=m?0:1,p=Math.max(p,0);const g=Math.max(p-(r-u),0);return n.moveCursorToPosition(l,p,s,!1),n.setViewState({top:g}),!0}handlePageDown(e,n){const s=e.shiftKey;s?n.trimSelectedRanges():n.clearSelectedRanges();const{selectionEndRow:i,cursorColumn:o}=n.state,r=i,l=o;if(r===null)return!1;const a=n.getMetricState(),{metricCalculator:d}=n,{bottomVisible:c,topVisible:u,hasHorizontalBar:m,rowCount:p,lastTop:g}=d.getMetrics(a),f=p-1;let C=c-u+r;C+=m?0:1,C=Math.min(C,f);const S=Math.min(g,C-(r-u));return n.moveCursorToPosition(l,C,s,!1),n.setViewState({top:S}),!0}}class mw extends ci{onDown(e,n){switch(e.key){case"Enter":case" ":return this.handleExpandKey(e,n)}return!1}handleExpandKey(e,n){const{selectedRanges:s}=n.state;if(s.length===1){const i=s[0];if(i.startRow===i.endRow&&i.startColumn===i.endColumn){if(!n.metrics)throw new Error("grid.metrics not set");const{model:o}=n.props,{startRow:r,startColumn:l}=i;if(r!=null){const a=n.getModelRow(r);if((l===0||l==null)&&ze(o)&&o.isRowExpandable(a))return n.toggleRowExpanded(r),!0}}}return!1}}class pw extends ci{onDown(e,n){if(q.isModifierKeyDown(e))return!1;const{model:s}=n.props,{cursorColumn:i,cursorRow:o}=n.state;if(i==null||o==null||!tt(s)||!s.isEditableRange(ae.makeCell(i,o)))return!1;const r=i,l=o;return r==null||l==null?!1:e.key.length===1?(n.startEditing(r,l,!0,[1,1],e.key),!0):e.key==="F2"?(n.startEditing(r,l),!0):e.key==="Backspace"?(n.startEditing(r,l,!0,void 0,""),!0):e.key==="Delete"?(n.setValueForCell(r,l,""),!0):!1}}function gw(t){const e=[],n=t.querySelectorAll("tr");for(let s=0;s<n.length;s+=1){const o=n[s].querySelectorAll("td"),r=[];for(let l=0;l<o.length;l+=1){const a=o[l];r.push(a.textContent?.trim()??"")}e.push(r)}return e}function fw(t){const e=[];return t.forEach(n=>{const s=n.textContent??"";s.length>0&&e.push(s.split(/\t|\u00a0\u00a0 \u00a0/))}),e}function Cw(t){const e=t.querySelector("table");if(e!=null)return gw(e);const n=t.textContent?.trim()??"";if(n.length>0){const{childNodes:s}=t,i=n.includes(" "),o=n.includes("\xA0\xA0 \xA0");return i&&s.length!==0&&(s.length===1||s.length>1&&(s[0].textContent==null||!s[0].textContent.includes(" ")))?n.split(`
19
19
  `).map(r=>r.split(" ")):s.length>1||o?fw(t.childNodes):n}return null}class Sw extends ci{onDown(e,n){switch(e.key){case"v":if(q.isModifierKeyDown(e)){const s=document.createElement("div");document.body.appendChild(s),s.setAttribute("contenteditable","true"),s.setAttribute("style",'clip-path: "inset(50%)"; height: 1px; width: 1px; margin: -1px; overflow: hidden; padding 0; position: absolute;');const i=()=>{s.removeEventListener("input",i),s.remove(),n.focus();const o=Cw(s);o!=null&&n.pasteValue(o)};return s.addEventListener("input",i),s.focus(),{preventDefault:!1,stopPropagation:!0}}break}return!1}}const bw=t=>{switch(t){case"ArrowDown":return wn.DOWN;case"ArrowUp":return wn.UP;case"ArrowLeft":return wn.LEFT;case"ArrowRight":return wn.RIGHT;default:return}};function ad({selectionRange:t=void 0,className:e="",disabled:n=!1,value:s="",isQuickEdit:i=!0,onChange:o=()=>{},onCancel:r=()=>{},onDone:l=()=>{},onContextMenu:a=()=>{},style:d={}}){const c=b.exports.useRef(null),u=b.exports.useRef(!1),[m]=b.exports.useState(s),[p,g]=b.exports.useState(!1),[f,C]=b.exports.useState(i),[S,w]=b.exports.useState(s);b.exports.useEffect(function(){const{current:A}=c;A!=null&&(A.focus(),t?A.setSelectionRange(t[0],t[1]):A.setSelectionRange(A.value.length,A.value.length))},[t]);const T=b.exports.useCallback(U=>{o(U)},[o]),y=b.exports.useCallback(U=>{const{value:A}=U.target;w(A),g(!0),T(A)},[T,w,g]),E=b.exports.useCallback(()=>{u.current=!0,p&&T(m),g(!1),r()},[m,p,r,T]),R=b.exports.useCallback(()=>{C(!1)},[C]),F=b.exports.useCallback((U,A=!1)=>{l(S,{direction:U,fillRange:A})},[l,S]),D=b.exports.useCallback(()=>{u.current||F(null)},[u,F]),_=b.exports.useCallback(U=>{switch(U.stopPropagation(),U.key){case"Escape":U.preventDefault(),E();break;case"Enter":if(U.preventDefault(),q.isModifierKeyDown(U))F(void 0,!0);else if(U.altKey){const A=`${S}
20
20
  `;w(A),g(!0),T(A)}else F(U.shiftKey?wn.UP:wn.DOWN);break;case"Tab":U.preventDefault(),F(U.shiftKey?wn.LEFT:wn.RIGHT);break;case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":f&&(U.preventDefault(),F(bw(U.key)));break}},[E,F,f,w,g,T,S]),H=b.exports.useCallback(U=>{a(U)},[a]);return h("textarea",{ref:c,className:K("grid-cell-input-field",e),value:S,onBlur:D,onChange:y,onKeyDown:_,onContextMenu:H,onClick:R,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false",disabled:n,style:d})}ad.propTypes={selectionRange:M.exports.arrayOf(M.exports.number),className:M.exports.string,disabled:M.exports.bool,isQuickEdit:M.exports.bool,value:M.exports.string,onChange:M.exports.func,onCancel:M.exports.func,onDone:M.exports.func,onContextMenu:M.exports.func,style:M.exports.shape({})};ad.defaultProps={selectionRange:null,className:"",disabled:!1,value:"",isQuickEdit:!0,onChange:()=>{},onCancel:()=>{},onDone:()=>{},onContextMenu:()=>{},style:{}};const ww=de.createContext({}),js=class extends b.exports.PureComponent{constructor(t){super(t),this.getCachedKeyHandlers=ge(l=>[...l,...this.keyHandlers].sort((a,d)=>a.order-d.order)),this.getCachedMouseHandlers=ge(l=>[...l,...this.mouseHandlers].sort((a,d)=>a.order-d.order)),this.handleClick=this.handleClick.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.handleEditCellCancel=this.handleEditCellCancel.bind(this),this.handleEditCellChange=this.handleEditCellChange.bind(this),this.handleEditCellCommit=this.handleEditCellCommit.bind(this),this.handleDoubleClick=this.handleDoubleClick.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseDrag=this.handleMouseDrag.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this.handleResize=this.handleResize.bind(this),this.handleWheel=this.handleWheel.bind(this);const{isStuckToBottom:e,isStuckToRight:n,metricCalculator:s,movedColumns:i,movedRows:o,renderer:r}=t;this.renderer=r||new li,this.metricCalculator=s||new Uo,this.canvas=null,this.canvasContext=null,this.animationFrame=null,this.prevMetrics=null,this.metrics=null,this.documentCursor=null,this.dragTimer=null,this.keyHandlers=[new pw(400),new Sw(450),new uw(500),new mw(900)],this.mouseHandlers=[new rd(100),new wl(200),new dw(300),new aw(400),new hw(450),new ld(500),new od(600),new cw(700),new Ai(800),new rw(900)],this.state={top:0,left:0,topOffset:0,leftOffset:0,draggingColumn:null,draggingRow:null,draggingRowOffset:null,draggingColumnSeparator:null,draggingRowSeparator:null,isDraggingHorizontalScrollBar:!1,isDraggingVerticalScrollBar:!1,isDragging:!1,mouseX:null,mouseY:null,movedColumns:i,movedRows:o,cursorRow:null,cursorColumn:null,selectionStartRow:null,selectionStartColumn:null,selectionEndRow:null,selectionEndColumn:null,selectedRanges:He,lastSelectedRanges:He,cursor:null,editingCell:null,isStuckToBottom:e,isStuckToRight:n}}static getScale(t){const e=window.devicePixelRatio||1,n=t,s=n.webkitBackingStorePixelRatio??n.mozBackingStorePixelRatio??n.msBackingStorePixelRatio??n.oBackingStorePixelRatio??n.backingStorePixelRatio??1;return e/s}static getCursorClassName(t){return t!=null&&t!==""?`grid-cursor-${t}`:null}componentDidMount(){this.initContext(),this.canvas?.addEventListener("wheel",this.handleWheel,{passive:!1}),window.addEventListener("resize",this.handleResize),this.updateCanvasScale(),this.updateCanvas();const{isStuckToBottom:t,isStuckToRight:e}=this.props;t&&this.scrollToBottom(),e&&this.scrollToRight()}componentDidUpdate(t,e){const{isStickyBottom:n,isStickyRight:s,movedColumns:i,movedRows:o,onMovedColumnsChanged:r,onMoveColumnComplete:l,onMovedRowsChanged:a,onMoveRowComplete:d}=this.props,{isStickyBottom:c,isStickyRight:u,movedColumns:m,movedRows:p}=t,{movedColumns:g,movedRows:f}=e,{draggingColumn:C,draggingRow:S,movedColumns:w,movedRows:T}=this.state;if(m!==i&&this.setState({movedColumns:i}),p!==o&&this.setState({movedRows:o}),g!==w&&r(w),e.draggingColumn!=null&&C==null&&l(w),f!==T&&a(T),e.draggingRow!=null&&S==null&&d(T),n!==c&&this.setState({isStuckToBottom:!1}),s!==u&&this.setState({isStuckToRight:!1}),this.updateMetrics(),this.requestUpdateCanvas(),!this.metrics||!this.prevMetrics)return;const{rowCount:y,columnCount:E,height:R,width:F}=this.metrics,{rowCount:D,columnCount:_,height:H,width:U}=this.prevMetrics;if(D!==y||R!==H){const{isStuckToBottom:A}=this.state;A&&this.scrollToBottom()}if(_!==E||F!==U){const{isStuckToRight:A}=this.state;A&&this.scrollToRight()}this.validateSelection()&&this.checkSelectionChange(e)}componentWillUnmount(){this.animationFrame!=null&&cancelAnimationFrame(this.animationFrame),this.canvas?.removeEventListener("wheel",this.handleWheel),window.removeEventListener("mousemove",this.handleMouseDrag,!0),window.removeEventListener("mouseup",this.handleMouseUp,!0),window.removeEventListener("resize",this.handleResize),this.stopDragTimer()}getTheme(){const{theme:t}=this.props;return js.getTheme(this.context,t)}getGridPointFromEvent(t){yc(this.canvas);const e=this.canvas.getBoundingClientRect(),n=t.clientX-e.left,s=t.clientY-e.top;return this.getGridPointFromXY(n,s)}getGridPointFromXY(t,e){if(!this.metrics)throw new Error("metrics must be set");return q.getGridPointFromXY(t,e,this.metrics)}getMetricState(t=this.state){const e=this.getTheme(),{model:n,stateOverride:s}=this.props;if(!this.canvasContext||!this.canvas)throw new Error("Canvas and context must be defined to get metrics");const i=this.canvasContext,o=this.canvas.clientWidth,r=this.canvas.clientHeight,{left:l,top:a,leftOffset:d,topOffset:c,movedColumns:u,movedRows:m,isDraggingHorizontalScrollBar:p,isDraggingVerticalScrollBar:g,draggingColumn:f}=t;return{left:l,top:a,leftOffset:d,topOffset:c,width:o,height:r,context:i,theme:e,model:n,movedColumns:u,movedRows:m,isDraggingHorizontalScrollBar:p,isDraggingVerticalScrollBar:g,draggingColumn:f,...s}}getKeyHandlers(){const{keyHandlers:t}=this.props;return this.getCachedKeyHandlers(t)}getMouseHandlers(){const{mouseHandlers:t}=this.props;return this.getCachedMouseHandlers(t)}getModelColumn(t){const e=this.metrics?.modelColumns?.get(t);if(e===void 0)throw new Error(`Unable to get ModelIndex for column ${t}`);return e}getModelRow(t){const e=this.metrics?.modelRows?.get(t);if(e===void 0)throw new Error(`Unable to get ModelIndex for row ${t}`);return e}toggleRowExpanded(t,e=!1){const n=this.getModelRow(t),{model:s}=this.props;ze(s)&&s.isRowExpandable(n)&&s.setRowExpanded(n,!s.isRowExpanded(n),e),this.clearSelectedRanges(),this.commitSelection(),this.moveCursorToPosition(0,t),this.commitSelection(),this.setState({isStuckToBottom:!1})}scrollToBottom(){if(!this.metrics)return;const{bottomVisible:t,rowCount:e,top:n,lastTop:s}=this.metrics;(t<e-1&&t>0||n>s)&&this.setState({top:s})}scrollToRight(){if(!this.metrics)return;const{rightVisible:t,columnCount:e,left:n,lastLeft:s}=this.metrics;(t<e-1&&t>0||n>s)&&this.setState({left:s})}setSelectedRanges(t){const{model:e}=this.props,{columnCount:n,rowCount:s}=e,{cursorRow:i,cursorColumn:o,selectedRanges:r}=this.state;if(this.setState({selectedRanges:t,lastSelectedRanges:r}),t.length>0){const l=ae.boundedRange(t[0],n,s);let a=i,d=o;l.containsCell(o,i)||({row:a,column:d}=l.startCell()),this.setState({selectionStartColumn:l.startColumn,selectionStartRow:l.startRow,selectionEndColumn:l.endColumn,selectionEndRow:l.endRow,cursorColumn:d,cursorRow:a})}}initContext(){const{canvas:t}=this,{canvasOptions:e}=this.props;if(!t)throw new Error("Canvas not set");this.canvasContext=t.getContext("2d",e)}requestUpdateCanvas(){this.animationFrame==null&&(this.animationFrame=requestAnimationFrame(()=>{if(this.animationFrame=null,!this.metrics)throw new Error("Metrics not set");this.updateCanvas(this.metrics)}))}updateCanvas(t=this.updateMetrics()){this.updateCanvasScale();const{onViewChanged:e}=this.props;e(t),this.drawCanvas(t)}updateCanvasScale(){const{canvas:t,canvasContext:e}=this;if(!t)throw new Error("canvas not set");if(!e)throw new Error("canvasContext not set");if(!t.parentElement)throw new Error("Canvas has no parent element");const n=js.getScale(e),s=t.parentElement.getBoundingClientRect(),i=Math.floor(s.width),o=Math.floor(s.height);t.style.width=`${i}px`,t.style.height=`${o}px`,t.width=i*n,t.height=o*n,e.scale(n,n)}updateScrollBounds(){if(!this.metrics)throw new Error("metrics not set");const{left:t,top:e}=this.state,{lastLeft:n,lastTop:s}=this.metrics;t>n&&this.setState({left:n,leftOffset:0}),e>s&&this.setState({top:s,topOffset:0})}updateMetrics(t=this.state){this.prevMetrics=this.metrics;const{metricCalculator:e}=this,n=this.getMetricState(t);return this.metrics=e.getMetrics(n),this.updateScrollBounds(),this.metrics}checkSelectionChange(t){const{selectedRanges:e}=t,{selectedRanges:n}=this.state;if(n!==e){const{onSelectionChanged:s}=this.props;s(n)}}validateSelection(){const{model:t}=this.props,{selectedRanges:e}=this.state,{columnCount:n,rowCount:s}=t;for(let i=0;i<e.length;i+=1){const o=e[i];if(o.endColumn!=null&&o.endColumn>=n||o.endRow!=null&&o.endRow>=s)return this.setState({selectedRanges:[],lastSelectedRanges:[]}),!1}return!0}clearSelectedRanges(){const{selectedRanges:t}=this.state;this.setState({selectedRanges:[],lastSelectedRanges:t})}trimSelectedRanges(){const{selectedRanges:t}=this.state;t.length>0&&this.setState({selectedRanges:t.slice(t.length-1)})}beginSelection(t,e){this.setState({selectionStartColumn:t,selectionStartRow:e,selectionEndColumn:t,selectionEndRow:e,cursorColumn:t,cursorRow:e})}moveSelection(t,e,n=!1,s=!1){this.setState(i=>{const{selectedRanges:o,selectionStartRow:r,selectionStartColumn:l}=i,{theme:a}=this.props,{autoSelectRow:d,autoSelectColumn:c}=a;if(n&&o.length>0){const g=o[o.length-1];let f=null,C=null,S=null,w=null;s?(f=d!==void 0&&d?null:Math.min(t??0,g.startColumn??0),C=c!==void 0&&c?null:Math.min(e??0,g.startRow??0),S=d!==void 0&&d?null:Math.max(t??0,g.endColumn??0),w=c!==void 0&&c?null:Math.max(e??0,g.endRow??0)):(f=g.startColumn,C=g.startRow,(l!=null||r!=null)&&((d===void 0||!d)&&(f=l),(c===void 0||!c)&&(C=r)),S=d!==void 0&&d?null:t,w=c!==void 0&&c?null:e);const T=ae.makeNormalized(f,C,S,w);if(g.equals(T))return null;const y=[...o];return y[y.length-1]=T,{selectedRanges:y,selectionEndColumn:t,selectionEndRow:e}}const u=[...o],m=d!==void 0&&d?null:t,p=c!==void 0&&c?null:e;return u.push(ae.makeNormalized(m,p,m,p)),{selectedRanges:u,selectionEndColumn:t,selectionEndRow:e}})}commitSelection(){this.setState(t=>{const{theme:e}=this.props,{autoSelectRow:n}=e,{selectedRanges:s,lastSelectedRanges:i,cursorRow:o,cursorColumn:r}=t;if(s.length===1&&(n!==void 0&&n?ae.rowCount(s)===1:ae.cellCount(s)===1)&&ae.rangeArraysEqual(s,i))return{selectedRanges:[],lastSelectedRanges:[],cursorColumn:null,cursorRow:null};let l=s.slice();if(l.length>1){const c=l[l.length-1];for(let u=0;u<l.length-1;u+=1){const m=l[u];if(m.contains(c)){const p=m.subtract(c);l.pop(),l.splice(u,1),l=l.concat(p);break}}l=ae.consolidate(l)}let a=r,d=o;if(!ae.containsCell(l,r,o)){const{model:c}=this.props,{columnCount:u,rowCount:m}=c,p=ae.nextCell(ae.boundedRanges(s,u,m));p!=null?{column:a,row:d}=p:(a=null,d=null)}return l.length===0&&(a=null,d=null),{cursorRow:d,cursorColumn:a,selectedRanges:l,lastSelectedRanges:s}})}setFocusRow(t){if(!this.metrics||!this.prevMetrics)return;const{gridY:e,height:n,lastTop:s,userRowHeights:i,rowHeight:o}=this.metrics,r=n-e,l=Math.round(r/2)+(i.get(t)??o),a=this.getMetricState(),d=this.metricCalculator.getLastTop(a,t+1,l);this.setState({top:Math.min(s,d),selectedRanges:[new ae(null,t,null,t)],isStuckToBottom:!1});const{cursorColumn:c}=this.state;this.moveCursorToPosition(c,t,!1,!1)}selectAll(){const{model:t,theme:e}=this.props,{autoSelectRow:n,autoSelectColumn:s}=e,i=s!==void 0&&s?null:0,o=s!==void 0&&s?null:t.rowCount-1,r=n!==void 0&&n?null:0,l=n!==void 0&&n?null:t.columnCount-1;this.setSelectedRanges([new ae(r,i,l,o)])}moveCursor(t,e,n){const{cursorRow:s,cursorColumn:i,selectionEndColumn:o,selectionEndRow:r}=this.state,l=n?o:i,a=n?r:s;if(a===null||l===null){const{left:d,top:c}=this.state;this.moveCursorToPosition(d,c,n)}else{const{model:d}=this.props,{columnCount:c,rowCount:u}=d,m=Qe(l+t,0,c-1),p=Qe(a+e,0,u-1);this.moveCursorToPosition(m,p,n)}}moveCursorInDirection(t=ae.SELECTION_DIRECTION.DOWN){const{model:e}=this.props,{columnCount:n,rowCount:s}=e,{cursorRow:i,cursorColumn:o,selectedRanges:r}=this.state,l=r.length>0?r:[ae.makeCell(o,i)];let a=null;if(l.length===1&&ae.cellCount(l)===1){const d=new ae(0,0,n-1,s-1);a=d.nextCell(o,i,t)??d.startCell(t)}else a=ae.nextCell(ae.boundedRanges(l,n,s),o,i,t);if(a!=null){const{column:d,row:c}=a;this.setState({cursorColumn:d,cursorRow:c}),ae.containsCell(r,d,c)||this.setState({selectedRanges:[ae.makeCell(d,c)],selectionStartColumn:d,selectionStartRow:c,selectionEndColumn:d,selectionEndRow:c}),this.moveViewToCell(a.column,a.row)}}moveCursorToPosition(t,e,n=!1,s=!0,i=!1){n||this.beginSelection(t,e),this.moveSelection(t,e,n,i),s&&this.moveViewToCell(t,e)}moveViewToCell(t,e){if(!this.metrics)throw new Error("metrics not set");const{metricCalculator:n}=this,{bottomVisible:s,rightVisible:i,topVisible:o,leftVisible:r}=this.metrics,l=this.getMetricState(this.state);let{top:a,left:d,topOffset:c,leftOffset:u}=this.state;e!=null&&!q.isFloatingRow(e,this.metrics)&&(e<o?(a=n.getTopForTopVisible(l,e),c=0):e>s&&(a=n.getTopForBottomVisible(l,e),c=0)),t!=null&&!q.isFloatingColumn(t,this.metrics)&&(t<r?(d=n.getLeftForLeftVisible(l,t),u=0):t>i&&(d=n.getLeftForRightVisible(l,t),u=0)),this.setViewState({top:a,left:d,topOffset:c,leftOffset:u})}setViewState(t,e=!1){if(!this.metrics)throw new Error("metrics not set");const{isStickyBottom:n,isStickyRight:s}=this.props,{top:i,left:o}=t,{lastTop:r,lastLeft:l}=this.metrics;i!=null&&this.setState({isStuckToBottom:n&&i>=r}),o!=null&&this.setState({isStuckToRight:s&&o>=l}),this.setState(t),e&&this.forceUpdate()}startEditing(t,e,n=!1,s,i){const{model:o}=this.props;if(!tt(o))throw new Error("model is not editable");const r=this.getModelColumn(t),l=this.getModelRow(e),a={column:t,row:e,selectionRange:s,value:i!==void 0?i:o.editValueForCell(r,l),isQuickEdit:n};this.setState({editingCell:a,cursorColumn:t,cursorRow:e}),this.moveViewToCell(t,e)}isValidForCell(t,e,n){const{model:s}=this.props,i=this.getModelColumn(t),o=this.getModelRow(e);return tt(s)&&s.isValidForCell(i,o,n)}async pasteValue(t){const{model:e}=this.props,{movedColumns:n,movedRows:s,selectedRanges:i}=this.state;try{if(Rc(e),!e.isEditable||!i.every(u=>e.isEditableRange(u)))throw new Yl("Can't paste in to read-only area.");if(i.length<=0)throw new Yl("Select an area to paste to.");if(typeof t=="string"){const u=[],m=q.getModelRanges(i,n,s);ae.forEachCell(m,(p,g)=>{u.push({column:p,row:g,text:t})}),await e.setValues(u);return}const o=t.length,r=t[0].length,{columnCount:l,rowCount:a}=e;let d=i;if(d.every(u=>ae.cellCount([u])===1&&(u.startColumn??0)+r<=l&&(u.startRow??0)+o<=a)&&(d=d.map(u=>new ae(u.startColumn,u.startRow,(u.startColumn??0)+r-1,(u.startRow??0)+o-1)),this.setSelectedRanges(d)),!d.every(u=>ae.rowCount([u])===o&&ae.columnCount([u])===r))throw new Yl("Copy and paste area are not same size.");const c=[];d.forEach(u=>{for(let m=0;m<r;m+=1)for(let p=0;p<o;p+=1)c.push({column:(u.startColumn??0)+m,row:(u.startRow??0)+p,text:t[p][m]})}),await e.setValues(c)}catch(o){const{onError:r}=this.props;r(o instanceof Error?o:new Error(`${o}`))}}setValueForCell(t,e,n){const{model:s}=this.props;Rc(s);const i=this.getModelColumn(t),o=this.getModelRow(e);return s.isValidForCell(i,o,n)?(s.setValueForCell(i,o,n),!0):!1}setValueForRanges(t,e){const{model:n}=this.props,{movedColumns:s,movedRows:i}=this.state,o=q.getModelRanges(t,s,i);tt(n)&&n.setValueForRanges(o,e)}isSelected(t,e){const{selectedRanges:n}=this.state;for(let s=0;s<n.length;s+=1){const i=n[s],o=i.startRow===null||i.startRow<=t&&t<=(i.endRow??0),r=i.startColumn===null||i.startColumn<=e&&e<=(i.endColumn??0);if(o&&r)return!0}return!1}addDocumentCursor(t=null){this.documentCursor!==js.getCursorClassName(t)&&(this.documentCursor!=null&&document.documentElement.classList.remove(this.documentCursor),this.documentCursor=js.getCursorClassName(t),this.documentCursor!=null&&document.documentElement.classList.add(this.documentCursor),document.documentElement.classList.add("grid-block-events"))}removeDocumentCursor(){this.documentCursor!=null&&(document.documentElement.classList.remove(this.documentCursor),document.documentElement.classList.remove("grid-block-events"),this.documentCursor=null)}startDragTimer(t){this.stopDragTimer();const e=new MouseEvent("custom",t.nativeEvent);this.dragTimer=setTimeout(()=>{this.handleMouseDrag(e)},js.dragTimeout)}stopDragTimer(){this.dragTimer&&(clearTimeout(this.dragTimer),this.dragTimer=null)}drawCanvas(t=this.updateMetrics()){if(!this.canvas)throw new Error("canvas is not set");if(!this.canvasContext)throw new Error("context not set");const{cursorColumn:e,cursorRow:n,draggingColumn:s,draggingColumnSeparator:i,draggingRow:o,draggingRowOffset:r,draggingRowSeparator:l,editingCell:a,isDraggingHorizontalScrollBar:d,isDraggingVerticalScrollBar:c,isDragging:u,mouseX:m,mouseY:p,selectedRanges:g}=this.state,{model:f,stateOverride:C}=this.props,{renderer:S}=this,w=this.canvasContext,T=this.getTheme(),y=this.canvas.clientWidth,E=this.canvas.clientHeight,R={width:y,height:E,context:w,theme:T,model:f,metrics:t,mouseX:m,mouseY:p,selectedRanges:g,draggingColumn:s,draggingColumnSeparator:i,draggingRow:o,draggingRowOffset:r,draggingRowSeparator:l,editingCell:a,isDraggingHorizontalScrollBar:d,isDraggingVerticalScrollBar:c,isDragging:u,cursorColumn:e,cursorRow:n,...C};w.save(),S.drawCanvas(R),w.restore()}focus(){this.canvas?.focus()}isFocused(){return document.activeElement===this.canvas}handleClick(t){const e=this.getGridPointFromEvent(t),n=this.getMouseHandlers();for(let s=0;s<n.length;s+=1)if(n[s].onClick(e,this,t)!==!1){t.stopPropagation(),t.preventDefault();break}this.canvas?.focus()}handleContextMenu(t){const e=this.getGridPointFromEvent(t),n=this.getMouseHandlers();for(let s=0;s<n.length;s+=1)if(n[s].onContextMenu(e,this,t)!==!1){t.stopPropagation(),t.preventDefault();break}}handleKeyDown(t){const e=this.getKeyHandlers();for(let n=0;n<e.length;n+=1){const i=e[n].onDown(t,this);if(i!==!1){const o=i;(o?.stopPropagation??!0)&&t.stopPropagation(),(o?.preventDefault??!0)&&t.preventDefault();break}}}notifyMouseHandlers(t,e,n=!0,s=!1){const i=this.getGridPointFromEvent(e),o=this.getMouseHandlers();let r=null;for(let l=0;l<o.length;l+=1){const a=o[l],d=a[t]!=null&&a[t](i,this,e);if(d!==!1){a.cursor!=null&&({cursor:r}=a,s&&this.addDocumentCursor(r));const c=d;(c?.stopPropagation??!0)&&e.stopPropagation(),(c?.preventDefault??!0)&&e.preventDefault();break}}if(this.setState({cursor:r}),n){const{x:l,y:a}=i;this.setState({mouseX:l,mouseY:a})}}handleMouseDown(t){window.addEventListener("mousemove",this.handleMouseDrag,!0),window.addEventListener("mouseup",this.handleMouseUp,!0),!(t.button!=null&&t.button!==0)&&(this.notifyMouseHandlers("onDown",t),this.startDragTimer(t))}handleDoubleClick(t){this.notifyMouseHandlers("onDoubleClick",t)}handleMouseMove(t){this.notifyMouseHandlers("onMove",t)}handleMouseLeave(t){this.notifyMouseHandlers("onLeave",t,!1),this.setState({mouseX:null,mouseY:null})}handleMouseDrag(t){this.setState({isDragging:!0}),this.notifyMouseHandlers("onDrag",t,!0,!0),this.stopDragTimer()}handleMouseUp(t){window.removeEventListener("mousemove",this.handleMouseDrag,!0),window.removeEventListener("mouseup",this.handleMouseUp,!0),!(t.button!=null&&t.button!==0)&&(this.notifyMouseHandlers("onUp",t,!1),this.stopDragTimer(),this.removeDocumentCursor())}handleResize(){if(this.updateCanvasScale(),this.updateCanvas(),!this.metrics)throw new Error("metrics not set");this.forceUpdate()}handleWheel(t){if(this.notifyMouseHandlers("onWheel",t),t.defaultPrevented)return;const{metricCalculator:e,metrics:n}=this,s=this.getMetricState();if(!n)throw new Error("metrics not set");const{lastTop:i,lastLeft:o,columnCount:r,rowCount:l,scrollableContentWidth:a,scrollableViewportWidth:d,scrollableContentHeight:c,scrollableViewportHeight:u,hasHorizontalBar:m,hasVerticalBar:p}=n;let{top:g,left:f,topOffset:C,leftOffset:S}=n;const w=this.getTheme();let{deltaX:T,deltaY:y}=q.getScrollDelta(t,n.barWidth,n.barHeight,n.rowHeight,n.rowHeight);for(;m&&T!==0;){if(S+=T,T=0,r>1){if(S>0&&f>=o||S<0&&f<=0){S=0;break}}else{if(S<=0){S=0;break}const E=a-d;if(S>=E){S=E;break}}if(S>0){const E=n.allColumnWidths.get(f)??e.getVisibleColumnWidth(f,s);S>=E?(T=S-E,S=0,f+=1):w.scrollSnapToColumn&&r>1&&(S=0,f+=1)}else if(S<0){const E=n.allColumnWidths.get(f-1)??e.getVisibleColumnWidth(f-1,s);Math.abs(S)<=E&&w.scrollSnapToColumn&&r>1?(S=0,f-=1):(T=S+E,S=0,f-=1)}}for(;p&&y!==0;){if(C+=y,y=0,l>1){if(C>0&&g>=i||C<0&&g<=0){C=0;break}}else{if(C<=0){C=0;break}const E=c-u;if(C>=E){C=E;break}}if(C>0){const E=n.allRowHeights.get(g)??e.getVisibleRowHeight(g,s);C>=E?(y=C-E,C=0,g+=1):w.scrollSnapToRow&&l>1&&(C=0,g+=1)}else if(C<0){const E=n.allRowHeights.get(g-1)??e.getVisibleRowHeight(g-1,s);Math.abs(C)<=E&&w.scrollSnapToRow&&l>1?(C=0,g-=1):(y=C+E,C=0,g-=1)}}this.setViewState({top:g,left:f,leftOffset:S,topOffset:C}),t.stopPropagation(),t.preventDefault()}handleEditCellCancel(){this.setState({editingCell:null}),this.focus()}handleEditCellChange(t){this.setState(({editingCell:e})=>{try{return yc(e),{editingCell:{...e,value:t}}}catch(n){const{onError:s}=this.props;return s(n instanceof Error?n:new Error(`${n}`)),null}})}handleEditCellCommit(t,{direction:e=wn.DOWN,fillRange:n=!1}={}){const{editingCell:s,selectedRanges:i}=this.state;if(!s)throw new Error("editingCell not set");const{column:o,row:r}=s;if(!this.isValidForCell(o,r,t)){e===null&&this.setState({editingCell:null});return}n?this.setValueForRanges(i,t):this.setValueForCell(o,r,t),e!==null&&this.moveCursorInDirection(e),this.setState({editingCell:null}),this.focus()}renderInputField(){const{model:t}=this.props,{editingCell:e}=this.state,{metrics:n}=this;if(e==null||n==null||!tt(t))return null;const{selectionRange:s,value:i,isQuickEdit:o}=e,{column:r,row:l}=e,{gridX:a,gridY:d,allColumnXs:c,allRowYs:u,allColumnWidths:m,allRowHeights:p}=n,g=c.get(r),f=u.get(l),C=m.get(r),S=p.get(l),w=g!=null&&f!=null&&C!=null&&S!=null?{position:"absolute",left:a+g,top:d+f,width:C,height:S}:{opacity:0},T=this.getModelColumn(r),y=this.getModelRow(l),E=T!=null&&y!=null?{textAlign:t.textAlignForCell(T,y)}:void 0,R=t.isValidForCell(T,y,i);return h("div",{style:w,children:h(ad,{selectionRange:s,className:K({error:!R}),onCancel:this.handleEditCellCancel,onChange:this.handleEditCellChange,onDone:this.handleEditCellCommit,isQuickEdit:o,style:E,value:i},`${r},${l}`)})}render(){const{cursor:t}=this.state;return v(Se,{children:[h("canvas",{className:K("grid-canvas",js.getCursorClassName(t)),ref:e=>{this.canvas=e},onClick:this.handleClick,onContextMenu:this.handleContextMenu,onDoubleClick:this.handleDoubleClick,onKeyDown:this.handleKeyDown,onMouseDown:this.handleMouseDown,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,tabIndex:0,children:"Your browser does not support HTML canvas. Update your browser?"}),this.renderInputField()]})}};let Wi=js;Wi.contextType=ww;Wi.defaultProps={canvasOptions:{alpha:!1},isStickyBottom:!1,isStickyRight:!1,isStuckToBottom:!1,isStuckToRight:!1,keyHandlers:He,mouseHandlers:He,movedColumns:He,movedRows:He,onError:()=>{},onSelectionChanged:()=>{},onMovedColumnsChanged:t=>{},onMoveColumnComplete:()=>{},onMovedRowsChanged:()=>{},onMoveRowComplete:()=>{},onViewChanged:()=>{},stateOverride:{},theme:{autoSelectColumn:!1,autoSelectRow:!1}};Wi.pixelsPerLine=100/3;Wi.dragTimeout=1e3;Wi.getTheme=ge((t,e)=>({...sw,...t,...e}));class em extends Fp{get floatingTopRowCount(){return 0}get floatingBottomRowCount(){return 0}get floatingLeftColumnCount(){return 0}get floatingRightColumnCount(){return 0}get columnHeaderMaxDepth(){return 1}truncationCharForCell(e,n){}textAlignForCell(e,n){return"left"}colorForCell(e,n,s){return s.textColor}backgroundColorForCell(e,n,s){return null}colorForColumnHeader(e,n=0){return null}textForRowHeader(e){return""}textForRowFooter(e){return""}isColumnMovable(e,n=0){return!0}isRowMovable(e){return!0}getColumnHeaderGroup(e,n){}getColumnHeaderParentGroup(e,n){}}class Tw extends em{constructor({rowCount:e=1e9,columnCount:n=100,floatingTopRowCount:s=0,floatingBottomRowCount:i=0,floatingLeftColumnCount:o=0,floatingRightColumnCount:r=0,isEditable:l=!1,editedData:a=[]}={}){super(),this.numRows=e,this.numColumns=n,this.floatingTop=s,this.floatingBottom=i,this.floatingLeft=o,this.floatingRight=r,this.editable=l,this.editedData=a}get rowCount(){return this.numRows}get columnCount(){return this.numColumns}get floatingTopRowCount(){return this.floatingTop}get floatingBottomRowCount(){return this.floatingBottom}get floatingLeftColumnCount(){return this.floatingLeft}get floatingRightColumnCount(){return this.floatingRight}get isEditable(){return this.editable}textForCell(e,n){return this.editedData[e]?.[n]??`${e},${n}`}colorForCell(e,n,s){return s.textColor}textForColumnHeader(e,n=0){return`${e}`}textForRowHeader(e){return`${e}`}textForRowFooter(e){return`${e}`}async setValueForCell(e,n,s){this.editedData[e]==null&&(this.editedData[e]=[]),this.editedData[e][n]=`${s}`}async setValueForRanges(e,n){ae.forEachCell(e,(s,i)=>{this.setValueForCell(s,i,n)})}async setValues(e){for(let n=0;n<e.length;n+=1){const s=e[n];this.setValueForCell(s.column??s.x,s.row??s.y,s.text)}}editValueForCell(e,n){return this.textForCell(e,n)}isValidForCell(e,n,s){return!0}isEditableRange(e){return this.isEditable}delete(e){throw new Error("Method not implemented.")}}const Zs=class extends Tw{constructor({rowCount:t=Zs.DEFAULT_ROW_COUNT,columnCount:e=Zs.DEFAULT_COLUMN_COUNT,children:n=new Map,childRowCount:s=Math.ceil(Math.max(Zs.MIN_CHILD_ROW_COUNT,t*Zs.DEFAULT_CHILD_ROW_COUNT_FACTOR)),maxDepth:i=Zs.MAX_DEPTH}={}){super({rowCount:t,columnCount:e}),this.getCachedModelRowOffset=Jt((o,r)=>{let l=null,a=r;const d=[...o].sort((c,u)=>c[0]-u[0]);for(let c=0;c<d.length;c+=1){const[u,m]=d[c];if(a<=u)break;const p=m.rowCount;if(a<=u+p){l=u,a=a-u-1;break}a-=p}return{key:l,offsetRow:a}}),this.getCachedTextForRowHeader=Jt((o,r)=>{const{key:l,offsetRow:a}=this.getCachedModelRowOffset(o,r);if(l!=null){const d=o.get(l);if(d!==void 0)return`${l}.${d.textForRowHeader(a)}`}return`${a}`}),this.getCachedTextForCell=Jt((o,r,l)=>{const{key:a,offsetRow:d}=this.getCachedModelRowOffset(o,l);if(a!=null){const c=o.get(a);if(c!==void 0)return`${a}.${c.textForCell(r,d)}`}return`${r},${d}`}),this.getCachedIsRowExpandable=Jt((o,r,l)=>this.getCachedDepthForRow(o,r)<l),this.getCachedIsRowExpanded=Jt((o,r)=>{const{key:l,offsetRow:a}=this.getCachedModelRowOffset(o,r);if(l!=null){const d=o.get(l);if(d!==void 0)return d.isRowExpanded(a)}return o.has(a)}),this.getCachedDepthForRow=Jt((o,r)=>{const{key:l,offsetRow:a}=this.getCachedModelRowOffset(o,r);if(l!=null){const d=o.get(l);if(d!==void 0)return d.depthForRow(a)+1}return 0}),this.children=n,this.childRowCount=s,this.maxDepth=i}textForCell(t,e){return this.getCachedTextForCell(this.children,t,e)}textForRowHeader(t){return this.getCachedTextForRowHeader(this.children,t)}isRowMovable(t){return!1}get hasExpandableRows(){return!0}get isExpandAllAvailable(){return!1}get floatingBottomRowCount(){return 0}isRowExpandable(t){return this.getCachedIsRowExpandable(this.children,t,this.maxDepth)}isRowExpanded(t){return this.getCachedIsRowExpanded(this.children,t)}setRowExpanded(t,e,n=!1){const{key:s,offsetRow:i}=this.getCachedModelRowOffset(this.children,t),o=new Map(this.children);if(s!=null){const r=this.children.get(s);if(r!==void 0){const{rowCount:l}=r;r.setRowExpanded(i,e,n),this.numRows+=r.rowCount-l}}else if(e){const r=new Zs({rowCount:this.childRowCount,columnCount:this.numColumns});o.set(i,r),this.numRows+=r.rowCount}else{const r=o.get(i);r!==void 0&&(this.numRows-=r.rowCount,o.delete(i))}this.children=o}expandAll(){throw new Error("Expand all not implemented.")}collapseAll(){throw new Error("Collapse all not implemented.")}depthForRow(t){return this.getCachedDepthForRow(this.children,t)}};let Vo=Zs;Vo.DEFAULT_ROW_COUNT=1e9;Vo.DEFAULT_COLUMN_COUNT=100;Vo.DEFAULT_CHILD_ROW_COUNT_FACTOR=.01;Vo.MIN_CHILD_ROW_COUNT=10;Vo.MAX_DEPTH=10;function vw(t,e){const n=Rw(t);return n===void 0?void 0:`${Mw(t)} ? ${n} : ${e}`}function Ew(t){return dh.Column.formatRowColor(t)}function yw(t,e){return t.formatColor(e)}const vo=ee.module("ConditionalFormattingUtils");var Un=(t=>(t.CONDITIONAL="conditional",t.ROWS="rows",t))(Un||{}),We=(t=>(t.IS_EQUAL="is-equal",t.IS_NOT_EQUAL="is-not-equal",t.IS_BETWEEN="is-between",t.GREATER_THAN="greater-than",t.GREATER_THAN_OR_EQUAL="greater-than-or-equal",t.LESS_THAN="less-than",t.LESS_THAN_OR_EQUAL="less-than-or-equal",t.IS_NULL="is-null",t.IS_NOT_NULL="is-not-null",t))(We||{}),Zt=(t=>(t.IS_EXACTLY="is-exactly",t.IS_NOT_EXACTLY="is-not-exactly",t.CONTAINS="contains",t.DOES_NOT_CONTAIN="does-not-contain",t.STARTS_WITH="starts-with",t.ENDS_WITH="ends-with",t.IS_NULL="is-null",t.IS_NOT_NULL="is-not-null",t))(Zt||{}),Lt=(t=>(t.IS_EXACTLY="is-exactly",t.IS_NOT_EXACTLY="is-not-exactly",t.IS_BEFORE="is-before",t.IS_BEFORE_OR_EQUAL="is-before-or-equal",t.IS_AFTER="is-after",t.IS_AFTER_OR_EQUAL="is-after-or-equal",t.IS_NULL="is-null",t.IS_NOT_NULL="is-not-null",t))(Lt||{}),So=(t=>(t.IS_TRUE="is-true",t.IS_FALSE="is-false",t.IS_NULL="is-null",t.IS_NOT_NULL="is-not-null",t))(So||{}),si=(t=>(t.IS_EQUAL="is-equal",t.IS_NOT_EQUAL="is-not-equal",t.IS_NULL="is-null",t.IS_NOT_NULL="is-not-null",t))(si||{}),Cn=(t=>(t.NO_FORMATTING="no-formatting",t.POSITIVE="positive",t.NEGATIVE="negative",t.WARN="warn",t.NEUTRAL="neutral",t.ACCENT_1="accent-1",t.ACCENT_2="accent-2",t.CUSTOM="custom",t))(Cn||{});function _c(t){switch(t){case"no-formatting":return"No formatting";case"positive":return"Positive";case"negative":return"Negative";case"warn":return"Warn";case"neutral":return"Neutral";case"accent-1":return"Accent 1";case"accent-2":return"Accent 2";case"custom":return"Custom..."}}function Gr(t){const{type:e,customConfig:n}=t;switch(e){case"no-formatting":return;case"positive":return"#9fde6f";case"negative":return"#ff6087";case"warn":return"#f67f40";case"neutral":return"#ffd95c";case"accent-1":return"#78dce8";case"accent-2":return"#ab9bf5";case"custom":return n?.background;default:return}}function Wr(t){const{type:e,customConfig:n}=t;switch(e){case"no-formatting":return;case"positive":return"#526a3f";case"negative":return"#802f44";case"warn":return"#663318";case"neutral":return"#63562b";case"accent-1":return"#3f6469";case"accent-2":return"#554d72";case"custom":return n?.color;default:return}}function Rw(t){const e=Wr(t.style),n=Gr(t.style);if(!(e===void 0||n===void 0))return`bgfg(\`${n}\`, \`${e}\`)`}function Iw(t){const{column:e,value:n,start:s,end:i}=t;return $w(e.name,t.condition,n,s,i)}function Fw(t){const{column:e,value:n}=t;return Gw(e.name,t.condition,n)}function Dw(t){const{column:e,value:n}=t;return Ww(e.name,t.condition,n)}function Nw(t){const{column:e}=t;return zw(e.name,t.condition)}function _w(t){const{column:e,value:n}=t;return qw(e.name,t.condition,n)}function Mw(t){const{column:e}=t;if(N.isNumberType(e.type))return Iw(t);if(N.isCharType(e.type))return _w(t);if(N.isStringType(e.type))return Fw(t);if(N.isDateType(e.type))return Dw(t);if(N.isBooleanType(e.type))return Nw(t);throw new Error("Invalid column type")}function kw(t){switch(t){case"is-equal":return"is equal to";case"is-not-equal":return"is not equal to";case"is-between":return"is between";case"greater-than":return"greater than";case"greater-than-or-equal":return"greater than or equal to";case"less-than":return"less than";case"less-than-or-equal":return"less than or equal to";case"is-null":return"is null";case"is-not-null":return"is not null"}}function xw(t){switch(t){case"is-exactly":return"is exactly";case"is-not-exactly":return"is not exactly";case"contains":return"contains";case"does-not-contain":return"does not contain";case"starts-with":return"starts with";case"ends-with":return"ends with";case"is-null":return"is null";case"is-not-null":return"is not null"}}function Ow(t){switch(t){case"is-exactly":return"is";case"is-not-exactly":return"is not";case"is-before":return"is before";case"is-before-or-equal":return"is before or equal";case"is-after":return"is after";case"is-after-or-equal":return"is after or equal";case"is-null":return"is null";case"is-not-null":return"is not null"}}function Aw(t){switch(t){case"is-true":return"is true";case"is-false":return"is false";case"is-null":return"is null";case"is-not-null":return"is not null"}}function Lw(t){switch(t){case"is-equal":return"is";case"is-not-equal":return"is not";case"is-null":return"is null";case"is-not-null":return"is not null"}}function tm(t){if(N.isNumberType(t)||N.isCharType(t))return"is-equal";if(N.isStringType(t)||N.isDateType(t))return"is-exactly";if(N.isBooleanType(t))return"is-true";throw new Error("Invalid column type")}function nm(t){if(N.isCharType(t)||N.isStringType(t))return""}function sm(t){const{condition:e,value:n,start:s,end:i}=t;return{condition:e,value:n,start:s,end:i}}function Tl(t){return{condition:tm(t),value:nm(t),start:void 0,end:void 0}}function im(){return{type:"no-formatting"}}function Pw(t){switch(t){case"is-exactly":return"==";case"is-not-exactly":return"!=";case"contains":return"contains";case"does-not-contain":return"does not contain";case"starts-with":return"starts with";case"ends-with":return"ends with";case"is-null":return"is null";case"is-not-null":return"is not null"}}function Hw(t){switch(t){case"is-exactly":return"==";case"is-not-exactly":return"!=";case"is-before":return"<";case"is-before-or-equal":return"<=";case"is-after":return">";case"is-after-or-equal":return">=";case"is-null":return"is null";case"is-not-null":return"is not null"}}function Uw(t){switch(t){case"is-true":return"is true";case"is-false":return"is false";case"is-null":return"is null";case"is-not-null":return"is not null"}}function Vw(t){switch(t){case"is-equal":return"==";case"is-not-equal":return"!=";case"is-null":return"is null";case"is-not-null":return"is not null"}}function Bw(t){switch(t){case"is-equal":return"==";case"is-not-equal":return"!=";case"is-between":return"==";case"greater-than":return">";case"greater-than-or-equal":return">=";case"less-than":return"<";case"less-than-or-equal":return"<=";case"is-null":return"is null";case"is-not-null":return"is not null"}}function $w(t,e,n,s,i){switch(e){case"is-equal":return`${t} == ${n}`;case"is-not-equal":return`${t} != ${n}`;case"is-between":return`${t} > ${s} && ${t} < ${i}`;case"greater-than":return`${t} > ${n}`;case"greater-than-or-equal":return`${t} >= ${n}`;case"less-than":return`${t} < ${n}`;case"less-than-or-equal":return`${t} <= ${n}`;case"is-null":return`${t} == null`;case"is-not-null":return`${t} != null`}}function Gw(t,e,n){switch(e){case"is-exactly":return`${t} == "${n}"`;case"is-not-exactly":return`${t} != "${n}"`;case"contains":return`${t} != null && ${t}.contains("${n}")`;case"does-not-contain":return`${t} != null && !${t}.contains("${n}")`;case"starts-with":return`${t} != null && ${t}.startsWith("${n}")`;case"ends-with":return`${t} != null && ${t}.endsWith("${n}")`;case"is-null":return`${t} == null`;case"is-not-null":return`${t} != null`}}function Ww(t,e,n){switch(e){case"is-exactly":return`${t} == convertDateTime("${n}")`;case"is-not-exactly":return`${t} != convertDateTime(\`${n}\`)`;case"is-before":return`${t} < convertDateTime(\`${n}\`)`;case"is-before-or-equal":return`${t} <= convertDateTime("${n}")`;case"is-after":return`${t} > convertDateTime(\`${n}\`)`;case"is-after-or-equal":return`${t} >= convertDateTime(\`${n}\`)`;case"is-null":return`${t} == null`;case"is-not-null":return`${t} != null`}}function zw(t,e){switch(e){case"is-true":return`${t} == true`;case"is-false":return`${t} == false`;case"is-null":return`${t} == null`;case"is-not-null":return`${t} != null`}}function qw(t,e,n){switch(e){case"is-equal":return`${t} == '${n}'`;case"is-not-equal":return`${t} != '${n}'`;case"is-null":return`isNull(${t})`;case"is-not-null":return`!isNull(${t})`}}function Yw(t,e){if(N.isNumberType(t))return Bw(e);if(N.isCharType(t))return Vw(e);if(N.isStringType(t))return Pw(e);if(N.isDateType(t))return Hw(e);if(N.isBooleanType(t))return Uw(e);throw new Error("Invalid column type")}function Kw(t,e){if(e===void 0)return vo.debug("no rules passed."),[];const n=[];let s;const i=new Map;return e.forEach(({config:o,type:r})=>{const{column:l}=o,a=t.find(({name:g,type:f})=>g===l.name&&f===l.type);if(a===void 0){vo.debug(`Column ${l.name}:${l.type} not found. Ignoring format rule.`,o);return}const[d,c]=(r==="conditional"?i.get(a.name):s)??["null",void 0],u=vw(o,d);if(u===void 0){vo.debug("Ignoring format rule.",o);return}const m=c===void 0?-1:n.indexOf(c);m>-1&&n.splice(m,1);const p=r==="conditional"?yw(a,u):Ew(u);n.push(p),r==="conditional"?i.set(a.name,[u,p]):s=[u,p]}),n}function Xw(t,e){switch(t){case"is-null":case"is-not-null":return!0;default:{const[n,...s]=(e??"").split(" "),i=s.join(" ");try{vn.parseDateTimeString(n)}catch{return vo.debug("Invalid datetime string",n),!1}try{dh.i18n.TimeZone.getTimeZone(i)}catch{return vo.debug("Invalid timezone string",i),!1}return!0}}}function jw({type:t}){return N.isNumberType(t)||N.isCharType(t)||N.isStringType(t)||N.isDateType(t)||N.isBooleanType(t)}function vl({animation:t="iris-grid-bottom-bar-slide-up",children:e,className:n,isShown:s,onClick:i,onEntering:o,onEntered:r,onExiting:l,onExited:a}){return h(Ht,{in:s,timeout:Xe.transitionMs,classNames:t,onEntering:o,onEntered:r,onExiting:l,onExited:a,mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:K("iris-grid-bottom-bar",n),role:"presentation",onClick:i,onKeyPress:i,children:e})})}const Zw=3e3,Qw=5;function Jw({isSaving:t=!1,onSave:e,onDiscard:n,discardTooltip:s,saveTooltip:i,error:o,pendingDataErrors:r,pendingDataMap:l,onEntering:a,onEntered:d,onExiting:c,onExited:u}){const[m,p]=b.exports.useState(!1),[g,f]=b.exports.useState(!1),C=b.exports.useRef(),S=ll(t),w=b.exports.useMemo(()=>r.size===0?o:r.size<=Qw?`Key can't be empty (on pending row${r.size>1?"s":""} ${Array.from(r.keys()).join(", ").trim()})`:`Key can't be empty (on ${r.size} rows)`,[o,r]);b.exports.useEffect(function(){S!=null&&S&&!t&&w==null&&(p(!0),f(!0),C.current=setTimeout(()=>{p(!1)},Zw))},[w,t,S]),b.exports.useEffect(function(){C.current&&l.size>0&&(clearTimeout(C.current),p(!1),f(!1))},[l]),b.exports.useEffect(function(){return()=>C.current?clearTimeout(C.current):void 0},[]);const T=l.size;let y;return t?y=h(as,{}):g&&(y=Pa),v(vl,{className:"pending-data-bottom-bar",isShown:T>0||m||w!=null,onEntering:a,onEntered:d,onExiting:c,onExited:()=>{f(!1),u&&u()},children:[w!=null&&w!==""&&v("div",{className:"error-message",children:[h(J,{icon:Os}),h("span",{children:`${w}`})]}),(w==null||w==="")&&h("div",{className:"status-message",children:T>0&&h("span",{children:`${T} row${T>1?"s":""} pending`})}),v("div",{className:"buttons-container",children:[!t&&!g&&h(V,{kind:"secondary",onClick:n,tooltip:s,children:"Discard"}),v(V,{kind:g?"success":"primary",onClick:e,icon:y,disabled:t||g||w!=null,tooltip:i,children:[t&&"Committing...",!t&&g&&"Success",!t&&!g&&"Commit"]})]})]})}var Oe=(t=>(t.COUNT="Count",t.MIN="Min",t.MAX="Max",t.SUM="Sum",t.ABS_SUM="AbsSum",t.VAR="Var",t.AVG="Avg",t.STD="Std",t.FIRST="First",t.LAST="Last",t.SKIP="Skip",t.COUNT_DISTINCT="CountDistinct",t.DISTINCT="Distinct",t.UNIQUE="Unique",t))(Oe||{});const eT=t=>{switch(t){default:return!1}},tT=(t,e)=>{switch(t){case Oe.COUNT:case Oe.FIRST:case Oe.LAST:case Oe.COUNT_DISTINCT:case Oe.DISTINCT:case Oe.UNIQUE:return!0;case Oe.MIN:case Oe.MAX:return N.isNumberType(e)||N.isDateType(e)||N.isTextType(e);case Oe.SUM:case Oe.ABS_SUM:case Oe.VAR:case Oe.AVG:case Oe.STD:return N.isNumberType(e);case Oe.SKIP:return!1}},dd=(t,e)=>t.filter(n=>tT(e,n.type)),nT=(t,e,n,s)=>dd(t,e).map(({name:i})=>i).filter(i=>n.includes(i)?!s:s),_s={isRollupOperation:eT,filterValidColumns:dd,getOperationColumnNames:nT};var ai=(t=>(t.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS="filter-control-change-clears-all-filters",t.LINK_CHANGE_CLEARS_ALL_FILTERS="link-change-clears-all-filters",t))(ai||{});const sT=Object.freeze([[ai.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS,!1],[ai.LINK_CHANGE_CLEARS_ALL_FILTERS,!1]]),om={DEFAULTS:sT},iT=ee.module("ColumnHeaderGroup");function Kl(t){return t instanceof xn}const rm=class{constructor({name:t,children:e,color:n,depth:s,childIndexes:i,parent:o}){this.getVisibleRange=ge(r=>{const l=this.childIndexes.flat(),a=q.getVisibleIndexes(l,r),d=Math.min(...a),c=Math.max(...a);return c-d!==l.length-1&&iT.warn(`Column header group ${this.name} is not contiguous`),[d,c]}),this.name=t,this.children=e,this.color=n,this.depth=s,this.childIndexes=i,this.parent=o}setParent(t){this.parent=t}addChildren(t){const e=new Set(this.children.concat(t));this.children=[...e]}removeChildren(t){const e=new Set(this.children);t.forEach(n=>e.delete(n)),this.children=[...e]}get isNew(){return this.name.startsWith(rm.NEW_GROUP_PREFIX)}};let xn=rm;xn.NEW_GROUP_PREFIX=":newGroup";const oo=ee.module("IrisGridUtils");function ws(t,e){return t>=0&&t<e.length}function oT(t){return t.asDate!=null}class te{static dehydrateGridState(e,n){const{isStuckToBottom:s,isStuckToRight:i,movedColumns:o,movedRows:r}=n,{columns:l}=e;return{isStuckToBottom:s,isStuckToRight:i,movedColumns:[...o].filter(({to:a,from:d})=>ws(a,l)&&(typeof d=="number"&&ws(d,l)||Array.isArray(d)&&ws(d[0],l)&&ws(d[1],l))).map(({to:a,from:d})=>({to:l[a].name,from:Array.isArray(d)?[l[d[0]].name,l[d[1]].name]:l[d].name})),movedRows:[...r]}}static hydrateGridState(e,n,s=[]){const{isStuckToBottom:i,isStuckToRight:o,movedColumns:r,movedRows:l}=n,{columns:a}=e,d=te.parseCustomColumnNames(s),c=a.map(({name:u})=>u).concat(d);return{isStuckToBottom:i,isStuckToRight:o,movedColumns:[...r].map(({to:u,from:m})=>{const p=g=>typeof g=="string"?c.findIndex(f=>f===g):g;return{to:p(u),from:Array.isArray(m)?[p(m[0]),p(m[1])]:p(m)}}).filter(({to:u,from:m})=>ws(u,c)&&(typeof m=="number"&&ws(m,c)||Array.isArray(m)&&ws(m[0],c)&&ws(m[1],c))),movedRows:[...l]}}static dehydrateIrisGridState(e,n){const{aggregationSettings:s={aggregations:He,showOnTop:!1},advancedFilters:i,customColumnFormatMap:o,isFilterBarShown:r,metrics:l,quickFilters:a,customColumns:d,conditionalFormats:c=He,reverseType:u,rollupConfig:m=void 0,showSearchBar:p,searchValue:g,selectDistinctColumns:f=He,selectedSearchColumns:C,sorts:S,invertSearchColumns:w,pendingDataMap:T=Jn,frozenColumns:y,columnHeaderGroups:E}=n;k(l);const{userColumnWidths:R,userRowHeights:F}=l,{columns:D}=e;return{advancedFilters:te.dehydrateAdvancedFilters(D,i),aggregationSettings:s,customColumnFormatMap:[...o],isFilterBarShown:r,quickFilters:te.dehydrateQuickFilters(a),sorts:te.dehydrateSort(S),userColumnWidths:[...R].filter(([_])=>_!=null&&_>=0&&_<D.length).map(([_,H])=>[D[_].name,H]),userRowHeights:[...F],customColumns:[...d],conditionalFormats:[...c],reverseType:u,rollupConfig:m,showSearchBar:p,searchValue:g,selectDistinctColumns:[...f],selectedSearchColumns:C,invertSearchColumns:w,pendingDataMap:te.dehydratePendingDataMap(D,T),frozenColumns:y,columnHeaderGroups:E?.map(_=>({name:_.name,children:_.children,color:_.color}))}}static hydrateIrisGridState(e,n){const{advancedFilters:s,aggregationSettings:i={aggregations:[],showOnTop:!1},customColumnFormatMap:o,isFilterBarShown:r,quickFilters:l,sorts:a,customColumns:d,conditionalFormats:c,userColumnWidths:u,userRowHeights:m,reverseType:p,rollupConfig:g=void 0,showSearchBar:f,searchValue:C,selectDistinctColumns:S,selectedSearchColumns:w,invertSearchColumns:T=!0,pendingDataMap:y=[],frozenColumns:E,columnHeaderGroups:R}=n,{columns:F,formatter:D}=e;return{advancedFilters:te.hydrateAdvancedFilters(F,s,D.timeZone),aggregationSettings:i,customColumnFormatMap:new Map(o),isFilterBarShown:r,quickFilters:te.hydrateQuickFilters(F,l,D.timeZone),sorts:te.hydrateSort(F,a),userColumnWidths:new Map(u.map(([_,H])=>typeof _=="string"||_ instanceof String?[F.findIndex(({name:U})=>U===_),H]:[_,H]).filter(([_])=>_!=null&&_>=0&&_<F.length)),customColumns:d,conditionalFormats:c,userRowHeights:new Map(m),reverseType:p,rollupConfig:g,showSearchBar:f,searchValue:C,selectDistinctColumns:S,selectedSearchColumns:w,invertSearchColumns:T,pendingDataMap:te.hydratePendingDataMap(F,y),frozenColumns:E,columnHeaderGroups:te.parseColumnHeaderGroups(e,R??e.layoutHints?.columnGroups??[]).groups}}static dehydrateIrisGridPanelState(e,n){const{isSelectingPartition:s,partition:i,partitionColumn:o,advancedSettings:r}=n;return{isSelectingPartition:s,partition:i,partitionColumn:o?.name,advancedSettings:[...r]}}static hydrateIrisGridPanelState(e,n){const{isSelectingPartition:s,partition:i,partitionColumn:o,advancedSettings:r}=n,{columns:l}=e;return{isSelectingPartition:s,partition:i,partitionColumn:o!=null?te.getColumnByName(l,o):void 0,advancedSettings:new Map([...om.DEFAULTS,...r])}}static dehydrateQuickFilters(e){return[...e].map(([n,s])=>{const{text:i}=s;return[n,{text:i}]})}static hydrateQuickFilters(e,n,s){const i=n.map(([o,r])=>{const{text:l}=r;let a=null;try{const d=te.getColumn(e,o);d!=null&&(a=N.makeQuickFilter(d,l,s))}catch(d){oo.error("hydrateQuickFilters error with",l,d)}return[o,{text:l,filter:a}]});return new Map(i)}static dehydrateAdvancedFilters(e,n){return[...n].map(([s,i])=>{const o=te.getColumn(e,s);k(o);const r=te.dehydrateAdvancedFilterOptions(o,i.options);return[s,{options:r}]})}static hydrateAdvancedFilters(e,n,s){const i=n.map(([o,r])=>{const l=te.getColumn(e,o);k(l);const a=te.hydrateAdvancedFilterOptions(l,r.options);let d=null;try{te.getColumn(e,o)!=null&&(d=N.makeAdvancedFilter(l,a,s))}catch(c){oo.error("hydrateAdvancedFilters error with",a,c)}return[o,{options:a,filter:d}]});return new Map(i)}static dehydrateAdvancedFilterOptions(e,n){const{selectedValues:s,...i}=n;return{selectedValues:s?.map(o=>te.dehydrateValue(o,e?.type)),...i}}static hydrateAdvancedFilterOptions(e,n){const{selectedValues:s,...i}=n;return{selectedValues:s?.map(o=>te.hydrateValue(o,e?.type)),...i}}static dehydratePendingDataMap(e,n){return[...n].map(([s,{data:i}])=>[s,{data:[...i].map(([o,r])=>[e[o].name,te.dehydrateValue(r,e[o].type)])}])}static hydratePendingDataMap(e,n){const s=new Map,i=o=>(s.has(o)||s.set(o,e.findIndex(({name:r})=>r===o)),s.get(o));return new Map(n.map(([o,{data:r}])=>[o,{data:new Map(r.map(([l,a])=>{const d=i(l);return k(d),[i(l)??null,te.hydrateValue(a,e[d].type)]}))}]))}static dehydrateValue(e,n){return N.isDateType(n)?te.dehydrateDateTime(e):N.isLongType(n)?te.dehydrateLong(e):e}static hydrateValue(e,n){return N.isDateType(n)?te.hydrateDateTime(e):N.isLongType(n)?te.hydrateLong(e):e}static dehydrateDateTime(e){return e!=null?I.i18n.DateTimeFormat.format(vn.FULL_DATE_FORMAT,e):null}static hydrateDateTime(e){return e!=null?I.i18n.DateTimeFormat.parse(vn.FULL_DATE_FORMAT,e):null}static dehydrateLong(e){return e!=null?`${e}`:null}static hydrateLong(e){return e!=null?I.LongWrapper.ofString(e):null}static dehydrateSort(e){return e.map(n=>{const{column:s,isAbs:i,direction:o}=n;return{column:s.index,isAbs:i,direction:o}})}static hydrateSort(e,n){return n.map(s=>{const{column:i,isAbs:o,direction:r}=s;if(r===N.sortDirection.reverse)return I.Table.reverse();const l=te.getColumn(e,i);if(l!=null){let a=l.sort();return o&&(a=a.abs()),r===N.sortDirection.descending?a=a.desc():a=a.asc(),a}return null}).filter(s=>s!=null&&s.direction!==N.sortDirection.reverse)}static extractTableSettings(e,n=[]){const{irisGridPanelState:s,irisGridState:i}=e,{partitionColumn:o,partition:r}=s,{advancedFilters:l,quickFilters:a,sorts:d}=i;return{advancedFilters:l,inputFilters:n,partition:r,partitionColumn:o,quickFilters:a,sorts:d}}static applyTableSettings(e,n,s){const{columns:i}=e;let o=[];n.quickFilters&&(o=te.getFiltersFromFilterMap(te.hydrateQuickFilters(i,n.quickFilters,s)));let r=[];n.advancedFilters&&(r=te.getFiltersFromFilterMap(te.hydrateAdvancedFilters(i,n.advancedFilters,s)));const l=te.getFiltersFromInputFilters(i,n.inputFilters,s);let a=[];n.sorts&&(a=te.hydrateSort(i,n.sorts));let d=[...o,...r];const{partition:c,partitionColumn:u}=n;if(c!=null&&u!=null){const m=te.getColumnByName(i,u);m&&(d=[m.filter().eq(I.FilterValue.ofString(c)),...d])}d=[...l,...d],e.applyFilter(d),e.applySort(a)}static getInputFiltersForColumns(e,n=[]){return n.filter(({name:s,type:i})=>e.find(({name:o,type:r})=>o===s&&r===i))}static getFiltersFromInputFilters(e,n=[],s){return n.map(({name:i,type:o,value:r})=>{const l=e.find(({name:a,type:d})=>a===i&&d===o);if(l)try{return N.makeQuickFilter(l,r,s)}catch(a){oo.debug("Unable to create input filter",a)}return null}).filter(i=>i!=null)}static getFiltersFromFilterMap(e){const n=[],s=Array.from(e.keys());for(let i=0;i<s.length;i+=1){const o=s[i],r=e.get(o);r?.filter!=null&&n.push(r.filter)}return n}static getHiddenColumns(e){return[...e.entries()].filter(([,n])=>n===0).map(([n])=>n)}static parseCustomColumnNames(e){return e.map(n=>n.split("=")[0])}static getRemovedCustomColumnNames(e,n){const s=te.parseCustomColumnNames(e),i=te.parseCustomColumnNames(n);return s.filter(o=>!i.includes(o))}static removeSortsInColumns(e,n){return e.filter(s=>!n.includes(s.column.name))}static removeFiltersInColumns(e,n,s){const i=e.map(({name:r})=>r),o=new Map(n);return s.forEach(r=>o.delete(i.indexOf(r))),o}static removeColumnFromMovedColumns(e,n,s){const i=e.map(({name:r})=>r);let o=[...n];for(let r=0;r<s.length;r+=1){const l=s[r];let a=i.findIndex(c=>c===l);const d=[];for(let c=0;c<o.length;c+=1){const u=o[c],m={...u};let[p,g]=Array.isArray(u.from)?u.from:[u.from,u.from];a<=u.to&&(m.to-=1),a<p&&(p-=1),a<=g&&(g-=1),p<=g&&p!==m.to&&(p===g?d.push({...m,from:p}):d.push({...m,from:[p,g]})),a=q.applyItemMoves(a,a,[u])[0][0]}o=d,i.splice(i.findIndex(c=>c===l),1)}return o}static removeColumnsFromSelectDistinctColumns(e,n){return e.filter(s=>!n.includes(s))}static getVisibleColumnsInRange(e,n,s,i,o){const r=[];for(let l=n;l<=s;l+=1){const a=q.getModelIndex(l,i);a>=0&&a<e.length&&!o.includes(a)&&r.push(e[a])}return r}static getPrevVisibleColumns(e,n,s,i,o){const r=[];let l=n;for(;l>=0&&r.length<s;){const a=q.getModelIndex(l,i);a>=0&&a<e.length&&!o.includes(a)&&r.unshift(e[a]),l-=1}return r}static getNextVisibleColumns(e,n,s,i,o){const r=[];let l=n;for(;l<e.length&&r.length<s;){const a=q.getModelIndex(l,i);a>=0&&a<e.length&&!o.includes(a)&&r.push(e[a]),l+=1}return r}static getColumnsToFetch(e,n,s){const i=[...n];return s.forEach(o=>{const r=e.find(({name:l})=>l===o);r!=null&&!n.includes(r)&&i.push(r)}),i}static getModelViewportColumns(e,n,s,i,o=[],r=[],l=0){if(n==null||s==null)return null;const a=te.getVisibleColumnsInRange(e,n,s,i,o),d=a.length*l,c=te.getPrevVisibleColumns(e,n-1,d,i,o),u=te.getNextVisibleColumns(e,s+1,d,i,o),m=[...c,...a,...u];return te.getColumnsToFetch(e,m,r)}static rangeSetFromRanges(e){const n=e.slice().sort((s,i)=>(k(s.startRow),k(i.startRow),s.startRow-i.startRow)).map(s=>{const{startRow:i,endRow:o}=s;return k(i),k(o),I.RangeSet.ofRange(i,o)});return I.RangeSet.ofRanges(n)}static isValidSnapshotRanges(e){if(e==null||e.length===0)return!1;const n=new Map;for(let o=0;o<e.length;o+=1){const r=e[o],l=`${r.startRow}:${r.endRow}`,a=`${r.startColumn}:${r.endColumn}`;n.has(l)||n.set(l,[]),n.get(l).push(a)}const s=[...n.keys()],i=n.get(s[0]).sort().join(",");for(let o=1;o<s.length;o+=1)if(n.get(s[o]).sort().join(",")!==i)return!1;return!0}static isValidIndex(e){return!Number.isInteger(e)||typeof e!="number"?!1:e>=0}static columnsFromRanges(e,n){if(e==null||e.length===0)return[];if(e[0].startColumn===null&&e[0].endColumn===null)return[...n];const s=new Set;for(let i=0;i<e.length;i+=1){const o=e[i];k(o.startColumn),k(o.endColumn);for(let r=o.startColumn??0;r<=(o.endColumn??n.length-1);r+=1)s.add(r)}return[...s].map(i=>n[i])}static snapshotDataToMatrix(e){const{columns:n,rows:s}=e,i=[];for(let o=0;o<s.length;o+=1){const r=s[o],l=[];for(let a=0;a<n.length;a+=1){const d=n[a],c=r.get(d);l.push(c)}i.push(l)}return i}static getModelRollupConfig(e,n,s){if((n?.columns?.length??0)===0)return null;const{columns:i=[],showConstituents:o=!0,showNonAggregatedColumns:r=!0,includeDescriptions:l=!0}=n??{},{aggregations:a=[]}=s??{},d=a.map(({operation:u,selected:m,invert:p})=>_s.isRollupOperation(u)?[]:_s.getOperationColumnNames(e,u,m,p)),c={};for(let u=0;u<a.length;u+=1)c[a[u].operation]=d[u];if(r){const u=new Set(e.map(m=>m.name).filter(m=>!i.includes(m)));if(d.forEach(m=>{m.forEach(p=>u.delete(p))}),u.size>0){const m=c[Oe.FIRST]??[];c[Oe.FIRST]=[...m,...u]}}return{groupingColumns:i,includeConstituents:o,includeDescriptions:l,aggregations:c}}static getPendingErrors(e){e.forEach((n,s)=>{if(!te.isValidIndex(s))throw new Error(`Invalid rowIndex ${s}`);const{data:i}=n;i.forEach((o,r)=>{if(!te.isValidIndex(r))throw new Error(`Invalid columnIndex ${r}`)})})}static getColumn(e,n){return n<e.length?e[n]:(oo.error("Unable to retrieve column",n,">=",e.length),null)}static getColumnByName(e,n){const s=e.find(({name:i})=>i===n);return s==null&&oo.error("Unable to retrieve column by name",n,e.map(({name:i})=>i)),s}static changeFilterColumnNamesToIndexes(e,n){return n.map(({name:s,filter:i})=>{const o=e.findIndex(r=>r.name===s);return o<0?null:[o,i]}).filter(s=>s!=null)}static combineFiltersFromList(e,n){n.sort((i,o)=>i.operator==="eq"&&o.operator!=="eq"?1:i.operator!=="eq"&&o.operator==="eq"?-1:i.startColumnIndex-o.startColumnIndex);let s="";for(let i=0;i<n.length;i+=1){const{text:o,value:r,operator:l}=n[i];if(r!==void 0){let a="";l!==void 0&&(r==null&&l==="eq"?a="=":l!=="eq"&&(l==="startsWith"||l==="endsWith"?a="*":a=N.getFilterOperatorString(l)));let d=`${a}${o}`;l==="startsWith"&&(d=`${o}${a}`),e!=null&&r!==null&&N.isCharType(e)&&(d=`${a}${String.fromCharCode(parseInt(o,10))}`),i!==0&&(s+=l==="eq"?" || ":" && "),s+=d}}return s}static parseColumnHeaderGroups(e,n){let s=1;const i=new Map,o=new Map,r=n?.filter(({children:u})=>u.length>0);if(r.length===0)return{groups:[],maxDepth:s,parentMap:i,groupMap:o};const l=new Map(r.map(u=>[u.name,u])),a=new Set,d=u=>{const{name:m}=u;if(e.getColumnIndexByName(m)!=null)throw new Error(`Column header group has same name as column: ${m}`);const p=o.get(m);if(p)return p;const g=[];let f=1;u.children.forEach(S=>{if(a.has(S))throw new Error(`Column group child ${S} specified in multiple groups`);a.add(S);const w=l.get(S),T=e.getColumnIndexByName(S);if(w){const y=d(w);g.push(...y.childIndexes),f=Math.max(f,y.depth+1)}else if(T!=null)g.push(T),f=Math.max(f,1);else throw new Error(`Unknown child ${S} in group ${m}`)});const C=new xn({...u,depth:f,childIndexes:g.flat()});return o.set(m,C),u.children.forEach(S=>i.set(S,C)),s=Math.max(s,C.depth+1),C},c=new Set;return r.forEach(u=>{const{name:m}=u;if(c.has(m))throw new Error(`Duplicate column group name: ${m}`);c.add(m),d(u)}),o.forEach(u=>{u.setParent(i.get(u.name)?.name)}),{groups:[...o.values()],maxDepth:s,groupMap:o,parentMap:i}}static convertValueToText(e,n){if(n!=null&&N.isCharType(n)&&e!=null&&typeof e=="number")return String.fromCharCode(e);if(N.isDateType(n)&&oT(e)){const s=new Date(e.asDate()),i=s.getTimezoneOffset();return new Date(s.getTime()-i*60*1e3).toISOString().replace("T"," ").substring(0,23)}return e==null?"":`${e}`}}const Kt=ee.module("IrisGridCopyHandler"),Pe=class extends b.exports.Component{constructor(t){super(t),this.handleBackgroundClick=this.handleBackgroundClick.bind(this),this.handleCancelClick=this.handleCancelClick.bind(this),this.handleCopyClick=this.handleCopyClick.bind(this),this.handleHideTimeout=this.handleHideTimeout.bind(this),this.state={error:void 0,copyState:Pe.COPY_STATES.IDLE,buttonState:Pe.BUTTON_STATES.COPY,isShown:!1,rowCount:0}}static getStatusMessageText(t,e){switch(t){case Pe.COPY_STATES.CONFIRMATION_REQUIRED:return`Are you sure you want to copy ${e.toLocaleString()} rows to your clipboard?`;case Pe.COPY_STATES.CLICK_REQUIRED:return`Fetched ${e.toLocaleString()} rows!`;case Pe.COPY_STATES.FETCH_ERROR:return"Unable to copy data.";case Pe.COPY_STATES.FETCH_IN_PROGRESS:return`Fetching ${e.toLocaleString()} rows for clipboard...`;case Pe.COPY_STATES.DONE:return"Copied to Clipboard!";default:return""}}static getCopyButtonText(t){switch(t){case Pe.BUTTON_STATES.FETCH_IN_PROGRESS:return"Fetching";case Pe.BUTTON_STATES.CLICK_TO_COPY:return"Click to Copy";case Pe.BUTTON_STATES.RETRY:return"Retry";default:return"Copy"}}componentDidMount(){const{copyOperation:t}=this.props;t!=null&&this.startCopy()}componentDidUpdate(t){const{copyOperation:e}=this.props;t.copyOperation!==e&&this.startCopy()}componentWillUnmount(){this.stopCopy()}startCopy(){Kt.debug2("startCopy"),this.stopCopy();const{copyOperation:t}=this.props;if(t==null){Kt.debug2("No copy operation set, cancelling out"),this.setState({isShown:!1});return}const{ranges:e,error:n}=t;if(n!=null){Kt.debug("Showing copy error",n),this.setState({isShown:!0,copyState:Pe.COPY_STATES.DONE,error:n}),this.startHideTimer();return}const s=ae.rowCount(e);this.setState({rowCount:s,isShown:!0,error:void 0}),s>Pe.NO_PROMPT_THRESHOLD?this.setState({buttonState:Pe.BUTTON_STATES.COPY,copyState:Pe.COPY_STATES.CONFIRMATION_REQUIRED}):this.startFetch()}stopCopy(){this.textData=void 0,this.stopFetch(),this.stopHideTimer()}handleBackgroundClick(){Kt.debug2("handleBackgroundClick");const{copyState:t}=this.state;t===Pe.COPY_STATES.DONE&&this.setState({isShown:!1})}handleCancelClick(){Kt.debug2("handleCancelClick"),this.stopFetch(),this.setState({isShown:!1})}handleCopyClick(){Kt.debug2("handleCopyClick"),this.textData!=null?this.copyText(this.textData):this.startFetch()}handleHideTimeout(){Kt.debug2("handleHideTimeout"),this.stopHideTimer(),this.setState({isShown:!1})}copyText(t){Kt.debug2("copyText",t),this.textData=t,ko(t).then(()=>{this.setState({copyState:Pe.COPY_STATES.DONE}),this.startHideTimer()},e=>{Kt.error("copyText error",e),this.setState({buttonState:Pe.BUTTON_STATES.CLICK_TO_COPY,copyState:Pe.COPY_STATES.CLICK_REQUIRED})})}startFetch(){this.stopFetch(),this.setState({buttonState:Pe.BUTTON_STATES.FETCH_IN_PROGRESS,copyState:Pe.COPY_STATES.FETCH_IN_PROGRESS});const{model:t,copyOperation:e}=this.props,{ranges:n,includeHeaders:s,userColumnWidths:i,movedColumns:o,formatValues:r}=e;Kt.debug("startFetch",n);const l=te.getHiddenColumns(i);let a=q.getModelRanges(n,o);if(l.length>0){const c=l.map(ae.makeColumn);a=ae.subtractRangesFromRanges(a,c)}const d=r!=null&&r?(c,u)=>t.displayString(c,u.type,u.name):c=>`${c}`;this.fetchPromise=ye.makeCancelable(t.textSnapshot(a,s,d)),this.fetchPromise.then(c=>{this.fetchPromise=void 0,this.copyText(c)}).catch(c=>{c instanceof Jr?Kt.debug("User cancelled copy."):(Kt.error("Error fetching contents",c),this.fetchPromise=void 0,this.setState({buttonState:Pe.BUTTON_STATES.RETRY,copyState:Pe.COPY_STATES.FETCH_ERROR}))})}stopFetch(){this.fetchPromise&&(Kt.debug2("stopFetch"),this.fetchPromise.cancel(),this.fetchPromise=void 0)}startHideTimer(){this.stopHideTimer(),this.hideTimer=setTimeout(this.handleHideTimeout,Pe.HIDE_TIMEOUT)}stopHideTimer(){this.hideTimer!=null&&(clearTimeout(this.hideTimer),this.hideTimer=void 0)}render(){const{onEntering:t,onEntered:e,onExiting:n,onExited:s}=this.props,{buttonState:i,copyState:o,isShown:r,rowCount:l,error:a}=this.state,d=o===Pe.COPY_STATES.DONE?"fade":"copy-slide-up",c=Pe.getCopyButtonText(i),u=a??Pe.getStatusMessageText(o,l),m=o!==Pe.COPY_STATES.DONE,p=i===Pe.BUTTON_STATES.FETCH_IN_PROGRESS,g=o===Pe.COPY_STATES.DONE;return v(vl,{animation:d,isShown:r,className:K("iris-grid-copy-handler",{"copy-done":g}),onClick:this.handleBackgroundClick,onEntering:t,onEntered:e,onExiting:n,onExited:s,children:[h("div",{className:"status-message",children:h("span",{children:u})}),h(Ht,{in:m,timeout:Xe.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:v("div",{className:"buttons-container",children:[h("button",{type:"button",className:"btn btn-outline-secondary btn-cancel",onClick:this.handleCancelClick,children:"Cancel"}),v(V,{kind:p?"tertiary":"primary",className:K("btn-copy",{"btn-spinner":p}),onClick:this.handleCopyClick,disabled:p,children:[p&&h(as,{}),c]})]})})]})}};let zi=Pe;zi.NO_PROMPT_THRESHOLD=1e4;zi.HIDE_TIMEOUT=3e3;zi.COPY_STATES={IDLE:"IDLE",CONFIRMATION_REQUIRED:"CONFIRMATION_REQUIRED",FETCH_IN_PROGRESS:"FETCH_IN_PROGRESS",FETCH_ERROR:"FETCH_ERROR",CLICK_REQUIRED:"CLICK_REQUIRED",DONE:"DONE"};zi.BUTTON_STATES={COPY:"COPY",FETCH_IN_PROGRESS:"FETCH_IN_PROGRESS",CLICK_TO_COPY:"CLICK_TO_COPY",RETRY:"RETRY"};zi.defaultProps={copyOperation:null,onEntering:()=>{},onEntered:()=>{},onExiting:()=>{},onExited:()=>{}};class lm extends b.exports.PureComponent{constructor(e){super(e);const{debounceMs:n}=e;this.debouncedSendUpdate=Je(this.sendUpdate.bind(this),n),this.handleCancel=this.handleCancel.bind(this),this.handleChange=this.handleChange.bind(this),this.handleCommit=this.handleCommit.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.inputField=null;const{value:s}=e;this.initialValue=s,this.state={isChanged:!1,value:s}}componentDidMount(){this.inputField?.focus()}componentDidUpdate(e){const{debounceMs:n}=this.props;e.debounceMs!==n&&(this.debouncedSendUpdate.flush(),this.debouncedSendUpdate=Je(this.sendUpdate.bind(this),n))}componentWillUnmount(){this.debouncedSendUpdate.cancel()}setValue(e){this.initialValue=e,this.setState({value:e})}focus(){this.inputField?.focus()}handleChange(e){const{value:n}=e.target;this.setState({value:n,isChanged:!0}),this.debouncedSendUpdate(n)}handleCancel(){this.debouncedSendUpdate.cancel();const{initialValue:e}=this,{isChanged:n}=this.state;n&&this.sendUpdate(e);const{onDone:s}=this.props;s()}handleCommit(e=!0,n=!0){this.debouncedSendUpdate.flush();const{onDone:s}=this.props;s(e,n)}handleFocus(){this.inputField?.select()}handleBlur(e){const{relatedTarget:n}=e;n!=null&&n.classList.contains("context-menu-container")?this.handleCommit(!1,!0):n!=null&&n.classList.contains("advanced-filter-button")?this.handleCommit(!1,!1):this.handleCommit(!0,!0)}handleTab(e=!1){this.debouncedSendUpdate.flush();const{onTab:n}=this.props;n(e)}handleKeyDown(e){switch(e.key){case"Escape":e.stopPropagation(),e.preventDefault(),this.handleCancel();break;case"Enter":e.stopPropagation(),e.preventDefault(),this.handleCommit();break;case"Tab":e.stopPropagation(),e.preventDefault(),this.handleTab(e.shiftKey);break}}handleContextMenu(e){const{onContextMenu:n}=this.props;n(e)}sendUpdate(e){const{onChange:n}=this.props;n(e)}render(){const{className:e,style:n,isAdvancedFilterSet:s,onAdvancedFiltersTriggered:i}=this.props,{value:o}=this.state;return v("div",{style:n,className:"iris-grid-input-autosized-wrapper","data-value":o,children:[h("input",{ref:r=>{this.inputField=r},className:K("iris-grid-input-field",e),type:"text",value:o,onBlur:this.handleBlur,onFocus:this.handleFocus,onChange:this.handleChange,onKeyDown:this.handleKeyDown,onContextMenu:this.handleContextMenu,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false"}),h("div",{className:"advanced-filter-button-container",children:h(V,{kind:"ghost",className:K("btn-link-icon advanced-filter-button",{"filter-set":s}),onClick:i,onContextMenu:this.handleContextMenu,children:v("div",{className:"fa-layers ",children:[h(J,{icon:Ha,className:"filter-solid"}),h(J,{icon:kr,className:"filter-light"})]})})})]})}}lm.defaultProps={style:{},className:"",value:"",isAdvancedFilterSet:!1,onAdvancedFiltersTriggered:()=>{},onChange:()=>{},onDone:()=>{},onTab:()=>{},onContextMenu:()=>{},debounceMs:150};class rT extends ci{constructor(e){super(),this.irisGrid=e}onDown(e){const{selectedRanges:n}=this.irisGrid.state;return e.key==="c"&&Hn.isModifierKeyDown(e)?(te.isValidSnapshotRanges(n)?this.irisGrid.copyRanges(n):this.irisGrid.copyRanges(n,!1,!1,"Invalid copy ranges"),!0):!1}}const lT={TOGGLE_QUICK_FILTER:qe.createAndAdd({id:"TABLE.TOGGLE_QUICK_FILTER",name:"Toggle Quick Filter",shortcut:[Te.CTRL,Fe.F],macShortcut:[Te.CMD,Fe.F]}),CLEAR_ALL_FILTERS:qe.createAndAdd({id:"TABLE.CLEAR_ALL_FILTERS",name:"Clear All Table Filters",shortcut:[Te.CTRL,Fe.E],macShortcut:[Te.CMD,Fe.E]}),CLEAR_FILTERS:qe.createAndAdd({id:"TABLE.CLEAR_FILTERS",name:"Clear Active Table Filters",shortcut:[Te.CTRL,Te.SHIFT,Fe.E],macShortcut:[Te.CMD,Te.SHIFT,Fe.E]}),REVERSE:qe.createAndAdd({id:"TABLE.REVERSE",name:"Reverse",shortcut:[Te.CTRL,Fe.I],macShortcut:[Te.CMD,Fe.I]}),TOGGLE_SEARCH:qe.createAndAdd({id:"TABLE.TOGGLE_SEARCH",name:"Toggle Search",shortcut:[Te.CTRL,Te.SHIFT,Fe.F],macShortcut:[Te.CMD,Te.SHIFT,Fe.F]}),GOTO_ROW:qe.createAndAdd({id:"TABLE.GOTO_ROW",name:"Go to Row",shortcut:[Te.CTRL,Fe.G],macShortcut:[Te.CMD,Fe.G]})},aT={COMMIT:qe.createAndAdd({id:"INPUT_TABLE.COMMIT",name:"Commit",shortcut:[Te.CTRL,Fe.S],macShortcut:[Te.CMD,Fe.S]}),DISCARD:qe.createAndAdd({id:"INPUT_TABLE.DISCARD",name:"Discard",shortcut:[Te.CTRL,Te.ALT,Fe.S],macShortcut:[Te.CMD,Te.OPTION,Fe.S]})},en={TABLE:lT,INPUT_TABLE:aT};class dT extends ci{constructor(e){super(),this.irisGrid=e}onDown(e){if(en.TABLE.REVERSE.matchesEvent(e)){if(!this.irisGrid.isReversible())return!1;const{reverseType:n}=this.irisGrid.state;return n===N.REVERSE_TYPE.NONE?this.irisGrid.reverse(N.REVERSE_TYPE.POST_SORT):this.irisGrid.reverse(N.REVERSE_TYPE.NONE),!0}return!1}}class cT extends ci{constructor(e){super(),this.irisGrid=e}onDown(e){return en.TABLE.CLEAR_FILTERS.matchesEvent(e)?(this.irisGrid.clearAllFilters(),!0):!1}}class hT extends ft{constructor(e){super(850),this.irisGrid=e}destroyColumnTooltip(){this.irisGrid.setState({overflowButtonTooltipProps:null})}setCursor(e){return this.isHoveringOverflowButton(e)?(this.cursor="pointer",{stopPropagation:!1,preventDefault:!1}):(this.cursor=null,!1)}getButtonPosition({x:e,y:n,column:s,row:i}){if(s==null||i==null)return null;const{renderer:o,grid:r,state:l,props:a}=this.irisGrid;if(!r)return null;const{metrics:d}=l,{model:c}=a,{canvasContext:u}=r,m=r.getTheme(),p={context:u,mouseX:e,mouseY:n,metrics:d,model:c,theme:m},{left:g,top:f,width:C,height:S}=o.getCellOverflowButtonPosition(p);return g==null||C==null||f==null||S==null?null:{left:g,top:f,width:C,height:S}}isHoveringOverflowButton(e){const{x:n,y:s}=e,{left:i,top:o,width:r,height:l}=this.getButtonPosition(e)??{};if(i==null||r==null||o==null||l==null)return!1;const{renderer:a,grid:d,state:c,props:u}=this.irisGrid;if(!d)return!1;const{metrics:m}=c,{model:p}=u,{canvasContext:g}=d,f=d.getTheme(),C={context:g,mouseX:n,mouseY:s,metrics:m,model:p,theme:f};return a.shouldRenderOverflowButton(C)&&n>=i&&n<=i+r&&s>=o&&s<=o+l}onMove(e){if(this.isHoveringOverflowButton(e)){const{overflowButtonTooltipProps:n}=this.irisGrid.state,s=this.getButtonPosition(e);ct(n,s)||this.irisGrid.setState({overflowButtonTooltipProps:s})}else this.destroyColumnTooltip();return this.setCursor(e)}onWheel(e){return this.destroyColumnTooltip(),this.onMove(e)}onDown(e){this.destroyColumnTooltip();const{column:n,row:s}=e;return this.isHoveringOverflowButton(e)&&this.irisGrid.setState({showOverflowModal:!0,overflowText:this.irisGrid.getValueForCell(n,s)}),!1}onContextMenu(){return this.destroyColumnTooltip(),!1}onLeave(){return this.destroyColumnTooltip(),!1}}class uT extends ft{constructor(e){super(),this.irisGrid=e,this.cursor=null}isActive(){const{isSelectingColumn:e}=this.irisGrid.props;return e}isValidColumn(e){if(e==null)return!1;const{columnSelectionValidator:n}=this.irisGrid.props;return n!=null?n(e):!0}updateColumnSelectionStatus(){const{columnSelectionValidator:e}=this.irisGrid.props;e?.(null)}getTableColumn(e){if(e==null)return null;const{model:n}=this.irisGrid.props,s=this.irisGrid.getModelColumn(e);return s==null?null:n.columns[s]}onMove(e){if(!this.isActive())return!1;const{columnAllowedCursor:n,columnNotAllowedCursor:s}=this.irisGrid.props,{column:i}=e,o=this.getTableColumn(i);return this.isValidColumn(o)?(this.cursor=n,this.irisGrid.setState({hoverSelectColumn:i})):(this.cursor=s,this.irisGrid.setState({hoverSelectColumn:null})),!0}onWheel(e){if(!this.isActive())return!1;const{columnAllowedCursor:n,columnNotAllowedCursor:s}=this.irisGrid.props,{column:i}=e,o=this.getTableColumn(i);return this.isValidColumn(o)?this.cursor=n:this.cursor=s,{preventDefault:!1,stopPropagation:!1}}onLeave(){return this.isActive()&&this.irisGrid.setState({hoverSelectColumn:null}),this.updateColumnSelectionStatus(),!1}onDown(){return this.isActive()}onClick(e){if(!this.isActive())return!1;const{column:n}=e,s=this.getTableColumn(n);return s!=null&&this.isValidColumn(s)&&this.irisGrid.selectColumn(s),!0}}class mT extends ft{constructor(e){super(),this.irisGrid=e}hideColumnTooltip(){const{tooltip:e}=this.irisGrid;e&&(e.stopTimer(),e.hide())}onDown(){return this.hideColumnTooltip(),!1}onContextMenu(){return this.hideColumnTooltip(),!1}onWheel(){return this.hideColumnTooltip(),!1}onLeave(e,n,s){const{relatedTarget:i}=s instanceof MouseEvent?s:s.nativeEvent,{tooltip:o}=this.irisGrid;if(!o)return!1;const r=o.popper.current;return r&&i instanceof Element&&r.element.contains(i)||this.hideColumnTooltip(),!1}onMove(e){const{column:n,row:s,columnHeaderDepth:i}=e,{shownColumnTooltip:o}=this.irisGrid.state;let r=null;return n!==null&&s===null&&i===0&&(r=n),r!==o&&this.irisGrid.setState({shownColumnTooltip:r}),!1}}const am=class extends b.exports.Component{constructor(t=am.defaultProps){super(t),this.handleInputChange=this.handleInputChange.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.inputRef=de.createRef()}handleInputChange(){const{onChange:t}=this.props;this.inputRef.current&&t(this.inputRef.current.value)}closeContextMenu(){const{forwardedProps:t}=this.props,{closeMenu:e}=t;e(!0)}revertToDefault(){const{onChange:t}=this.props;t(null)}returnFocusToContextMenu(){const t=Df.getClosestByClassName(this.inputRef.current,"context-menu-container");t instanceof HTMLElement&&t.focus()}handleKeyDown(t){switch(t.key){case"Enter":t.stopPropagation(),this.closeContextMenu();break;case"Escape":t.stopPropagation(),this.revertToDefault(),this.closeContextMenu();break;case"ArrowRight":case"ArrowLeft":t.stopPropagation();break;case"ArrowUp":case"ArrowDown":this.returnFocusToContextMenu();break;default:t.stopPropagation()}}render(){const{formatString:t,forwardedProps:e,placeholder:n,title:s}=this.props,{menuItem:{description:i},iconElement:o}=e;return v("div",{className:"form-group flex-grow mb-0",children:[v("div",{className:"custom-format-title",children:[h("span",{className:"icon",children:o}),v("label",{className:"title mb-0",htmlFor:"custom-format-input",children:[s,i!=null&&h(ut,{children:i})]})]}),h("div",{className:"pl-2 pr-2 pb-2",children:h("input",{id:"custom-format-input",className:"form-control text-right mb-0",type:"text",defaultValue:t,ref:this.inputRef,placeholder:n,onKeyDown:this.handleKeyDown,onChange:this.handleInputChange,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false"})})]})}};let dm=am;dm.defaultProps={formatString:"",forwardedProps:{menuItem:{},closeMenu(t){},iconElement:null},placeholder:"",title:"",onChange(t){}};class tn{static isDefaultSelected(e){return!e||![nt.TYPE_CONTEXT_CUSTOM,nt.TYPE_CONTEXT_PRESET].includes(e.type)}static isCustomSelected(e){return e!=null&&e.type===nt.TYPE_CONTEXT_CUSTOM}static makeOption(e,n,s,i){return{title:e,description:e,group:s,format:n,isSelected:i}}static makeCustomFormatOption(e,n,s,i,o){return{title:e.label,description:e.label,format:e,group:n,isSelected:i,menuElement:h(dm,{formatString:e.formatString,title:e.label,placeholder:s,onChange:o})}}}const Mn=class{static getOptions(t,e){const n=new Date,i=[{group:Mn.dateGroup,formatString:"yyyy-MM-dd"},{group:Mn.dateGroup,formatString:"MM-dd-yyyy"},{group:Mn.timeGroup,formatString:"HH:mm:ss"},{group:Mn.timeGroup,formatString:"HH:mm:ss.SSS"},{group:Mn.timeGroup,formatString:"HH:mm:ss.SSSSSSSSS"},{group:Mn.dateTimeGroup,formatString:"yyyy-MM-dd HH:mm:ss"},{group:Mn.dateTimeGroup,formatString:"yyyy-MM-dd HH:mm:ss.SSS"},{group:Mn.dateTimeGroup,formatString:"yyyy-MM-dd HH:mm:ss.SSSSSSSSS"}].map(r=>{const l=st.makeFormat("",r.formatString,st.TYPE_CONTEXT_PRESET),a=t.getFormattedString(n,N.dataType.DATETIME,"",l);return tn.makeOption(a,l,r.group,st.isSameFormat(l,e))});return[tn.makeOption("Default",null,Mn.dateGroup,tn.isDefaultSelected(e)),...i]}};let El=Mn;El.dateGroup=10;El.timeGroup=20;El.dateTimeGroup=30;const kn=class{static getOptions(t,e){const n=[{format:ke.FORMAT_PERCENT,group:kn.presetGroup},{format:ke.FORMAT_BASIS_POINTS,group:kn.presetGroup},{format:ke.FORMAT_MILLIONS,group:kn.presetGroup},{format:ke.FORMAT_SCIENTIFIC_NOTATION,group:kn.presetGroup},{format:ke.FORMAT_ROUND,group:kn.presetRoundGroup},{format:ke.FORMAT_ROUND_TWO_DECIMALS,group:kn.presetRoundGroup},{format:ke.FORMAT_ROUND_FOUR_DECIMALS,group:kn.presetRoundGroup}],s=tn.makeOption("Default",null,kn.defaultGroup,tn.isDefaultSelected(t)),i=n.map(a=>tn.makeOption(a.format.label,a.format,a.group,ke.isSameFormat(a.format,t))),o=tn.isCustomSelected(t),r=o?t:ke.makeCustomFormat(),l=tn.makeCustomFormatOption(r,kn.customGroup,ke.DEFAULT_FORMAT_STRING,o,a=>{if(a!=null){const d=ke.makeCustomFormat(a);ke.isValid(d)&&e(d)}else e(null)});return[s,...i,l]}};let Bo=kn;Bo.defaultGroup=10;Bo.presetGroup=20;Bo.presetRoundGroup=30;Bo.customGroup=40;const bo=class{static getOptions(t,e){const n=[{format:Ze.FORMAT_MILLIONS,group:bo.presetGroup},{format:Ze.FORMAT_SCIENTIFIC_NOTATION,group:bo.presetGroup}],s=tn.makeOption("Default",null,bo.defaultGroup,tn.isDefaultSelected(t)),i=n.map(a=>tn.makeOption(a.format.label,a.format,a.group,Ze.isSameFormat(a.format,t))),o=tn.isCustomSelected(t),r=o?t:Ze.makeCustomFormat(),l=tn.makeCustomFormatOption(r,bo.customGroup,Ze.DEFAULT_FORMAT_STRING,o,a=>{if(a!=null){const d=Ze.makeCustomFormat(a);Ze.isValid(d)&&e(d)}else e(null)});return[s,...i,l]}};let yl=bo;yl.defaultGroup=10;yl.presetGroup=20;yl.customGroup=30;const Mc=ee.module("IrisGridContextMenuHandler"),pT=150,kc="yyyy-MM-dd HH:mm:ss.SSSSSSSSS",j=class extends ft{constructor(t){super(),this.debouncedUpdateCustomFormat=Je(t.handleFormatSelection,pT),this.irisGrid=t}static getQuickFilterCondition(t,e,n){return t&&n==="&&"?t.and(e):t&&n==="||"?t.or(e):e}static getQuickFilterText(t,e,n){return n&&t!=null?`${t} ${n} ${e}`:e}static getOperatorAsText(t){return t==="&&"?"And":"Or"}static getNumberValueEqualsFilter(t,e){const n=t.filter();if(e===Number.POSITIVE_INFINITY)return I.FilterCondition.invoke("isInf",n).and(n.greaterThan(I.FilterValue.ofNumber(0)));if(e===Number.NEGATIVE_INFINITY)return I.FilterCondition.invoke("isInf",n).and(n.lessThan(I.FilterValue.ofNumber(0)));if(Number.isNaN(e))return I.FilterCondition.invoke("isNaN",n);const s=j.getFilterValueForNumberOrChar(t.type,e);return n.eq(s)}static getFilterValueForNumberOrChar(t,e){return N.isCharType(t)?I.FilterValue.ofString(String.fromCharCode(e)):I.FilterValue.ofNumber(e)}static getRowOptionFormatted(t,e,n=30){return`${t} "${li.truncate(e,n-t.length-3)}"`}componentWillUnmount(){this.debouncedUpdateCustomFormat.flush()}getHeaderActions(t,e){const{irisGrid:n}=this,{column:s}=e;k(s);const{model:i}=n.props,{columns:o}=i,r=o[t],l=[],{metrics:a,reverseType:d,quickFilters:c,advancedFilters:u,searchFilter:m}=n.state,p=n.getTheme();k(a);const{filterIconColor:g,filterBarActiveColor:f,contextMenuSortIconColor:C,contextMenuReverseIconColor:S}=p,w=i.sort,T=N.getSortForColumn(w,t),y=d!==N.REVERSE_TYPE.NONE,{userColumnWidths:E}=a,R=[...E.values()].some(_=>_===0),F=i.getColumnHeaderParentGroup(t,0)===void 0,D=i.isColumnFrozen(t);return l.push({title:"Hide Column",group:j.GROUP_HIDE_COLUMNS,action:()=>{this.irisGrid.hideColumnByVisibleIndex(s)}}),l.push({title:D?"Unfreeze Column":"Freeze Column",group:j.GROUP_HIDE_COLUMNS,disabled:!F,action:()=>{D?this.irisGrid.unFreezeColumnByColumnName(r.name):this.irisGrid.freezeColumnByColumnName(r.name)},order:10}),l.push({title:"Show All Columns",group:j.GROUP_HIDE_COLUMNS,action:()=>{this.irisGrid.showAllColumns()},disabled:!R}),l.push({title:"Quick Filters",icon:Wn,iconColor:f,shortcut:en.TABLE.TOGGLE_QUICK_FILTER,group:j.GROUP_FILTER,order:10,action:()=>{this.irisGrid.toggleFilterBar(s)}}),l.push({title:"Advanced Filters",icon:u.get(t)?Ha:kr,iconColor:g,group:j.GROUP_FILTER,order:20,action:()=>{this.irisGrid.handleAdvancedMenuOpened(s)}}),l.push({title:"Clear Table Filters",group:j.GROUP_FILTER,order:40,shortcut:en.TABLE.CLEAR_FILTERS,action:()=>{this.irisGrid.clearAllFilters()},disabled:!(c.size>0||u.size>0||m!=null)}),l.push({title:"Sort by",icon:Wn,iconColor:C,group:j.GROUP_SORT,order:10,actions:this.sortByActions(r,t,T)}),l.push({title:"Add Additional Sort",disabled:T&&w.length===1||y&&w.length===1||T&&y&&w.length===2||w.length===0,group:j.GROUP_SORT,order:20,actions:this.additionalSortActions(r,t)}),l.push({title:"Clear Table Sorting",disabled:w.length===0||y&&w.length===1,group:j.GROUP_SORT,action:()=>{this.irisGrid.sortColumn(s,j.COLUMN_SORT_DIRECTION.none)},order:30}),l.push({title:d===N.REVERSE_TYPE.NONE?"Reverse Table":"Clear Reverse Table",icon:Wn,iconColor:S,group:j.GROUP_SORT,order:40,disabled:!i.isReversible,shortcut:en.TABLE.REVERSE,action:()=>{d===N.REVERSE_TYPE.NONE?this.irisGrid.reverse(N.REVERSE_TYPE.POST_SORT):this.irisGrid.reverse(N.REVERSE_TYPE.NONE)}}),l.push({title:"Copy Column Name",group:j.GROUP_COPY,action:()=>{ko(i.textForColumnHeader(t)??"").catch(_=>Mc.error("Unable to copy header",_))}}),N.isDateType(r.type)?l.push({title:"Date/Time Format",group:j.GROUP_FORMAT,actions:this.dateFormatActions(r)}):N.isNumberType(r.type)&&l.push({title:"Number Format",group:j.GROUP_FORMAT,actions:this.numberFormatActions(r)??void 0}),l}getCellActions(t,e,n){k(t);const{irisGrid:s}=this,{column:i,row:o}=n,{model:r,canCopy:l}=s.props,{columns:a}=r,d=s.getModelRow(o);k(d);const c=r.valueForCell(t,d),u=r.textForCell(t,d),m=a[t],p=[],{quickFilters:g}=s.state,f=s.getTheme(),{filterIconColor:C}=f,{settings:S}=s.props,w=new st({timeZone:S?.timeZone,showTimeZone:!1,showTSeparator:!0,defaultDateTimeFormatString:kc}),T=new st({timeZone:S?.timeZone,showTimeZone:S?.showTimeZone,showTSeparator:S?.showTSeparator,defaultDateTimeFormatString:kc});if(m==null||o==null)return p;if(r.isFilterable(t)){const E={title:"Filter by Value",icon:Wn,iconColor:C,group:j.GROUP_FILTER,order:10,actions:[]};if(c==null)g.get(t)&&E.actions.push({title:"And",actions:this.nullFilterActions(m,g.get(t),"&&"),order:2,group:le.groups.high}),E.actions.push(...this.nullFilterActions(m));else if(N.isBooleanType(m.type))g.get(t)&&E.actions.push({title:"Or",actions:this.booleanFilterActions(m,u,g.get(t),"||"),order:2,group:le.groups.high}),E.actions.push(...this.booleanFilterActions(m,u));else if(N.isNumberType(m.type)||N.isCharType(m.type)){k(t);const R=N.isCharType(m.type)?String.fromCharCode(c):`${c}`;g.get(t)&&E.actions.push({title:"And",actions:this.numberFilterActions(m,R,c,g.get(t),"&&"),order:2,group:le.groups.high}),E.actions.push(...this.numberFilterActions(m,R,c,g.get(t)))}else if(N.isDateType(m.type)){const R=w.format(c),F=T.format(c);g.get(t)&&E.actions.push({title:"And",actions:this.dateFilterActions(m,R,F,c,g.get(t),"&&"),order:2,group:le.groups.high}),E.actions.push(...this.dateFilterActions(m,R,F,c,g.get(t)))}else g.get(t)&&E.actions.push({title:"And",actions:this.stringFilterActions(m,u,c,g.get(t),"&&"),order:2,group:le.groups.high}),E.actions.push(...this.stringFilterActions(m,u,c));E.actions!=null&&E.actions.length>0&&p.push(E)}if(ze(r)&&r.isRowExpandable(d)){const E=r.groupedColumns.length>0?r.depthForRow(d)-1:0,F=r.valueForCell(E,d)==null?"null":r.textForCell(E,d);p.push({title:j.getRowOptionFormatted(r.isRowExpanded(d)?"Collapse":"Expand",F),group:j.GROUP_EXPAND_COLLAPSE,order:10,action:()=>{r.setRowExpanded(d,!r.isRowExpanded(d))}}),r.isExpandAllAvailable===!0&&p.push({title:j.getRowOptionFormatted("Expand All in",F),group:j.GROUP_EXPAND_COLLAPSE,order:20,action:()=>{r.setRowExpanded(d,!0,!0)}})}ze(r)&&r.hasExpandableRows&&r.isExpandAllAvailable===!0&&(p.push({title:"Expand Entire Table",group:j.GROUP_EXPAND_COLLAPSE,order:30,action:()=>{r.expandAll()}}),p.push({title:"Collapse Entire Table",group:j.GROUP_EXPAND_COLLAPSE,order:40,action:()=>{r.collapseAll()}}));const y={title:"Go to",iconColor:C,shortcut:en.TABLE.GOTO_ROW,group:j.GROUP_GOTO,order:10,action:()=>this.irisGrid.toggleGotoRow(`${o+1}`,`${c}`,m.name)};return p.push(y),l&&(p.push({title:"Copy Cell",group:j.GROUP_COPY,order:10,action:()=>{s.copyCell(i,o)}}),p.push({title:"Copy Cell Unformatted",group:j.GROUP_COPY,order:20,action:()=>{s.copyCell(i,o,!0)}})),p}onContextMenu(t,e,n){const{irisGrid:s}=this,{y:i,column:o,row:r,columnHeaderDepth:l}=t,a=s.getModelColumn(o),d=s.getModelRow(r),{model:c,canCopy:u}=s.props,{columns:m}=c,{metrics:p,isFilterBarShown:g,quickFilters:f,advancedFilters:C,selectedRanges:S}=s.state;k(p);const{columnHeaderHeight:w,gridY:T,columnHeaderMaxDepth:y}=p,E=[];if(a!=null&&d!=null){const R=c.valueForCell(a,d),F=c.textForCell(a,d),D=m[a],{onContextMenu:_}=s.props;D!=null&&E.push(_({model:c,value:R,valueText:F,column:D,rowIndex:r,columnIndex:o,modelRow:d,modelColumn:a}))}return a!=null&&c.isFilterable(a)&&E.push({title:"Clear Column Filter",group:j.GROUP_FILTER,order:30,action:()=>{this.irisGrid.removeColumnFilter(a)},disabled:!(f.has(a)||C.has(a))}),(g?i<=T:i<=w*y&&l===0)?a!=null&&E.push(...this.getHeaderActions(a,t)):(a!=null&&d!=null&&E.push(...this.getCellActions(a,e,t)),u&&S.length>0&&(E.push({title:"Copy Selection",shortcut:ls.COPY,group:j.GROUP_COPY,order:30,action:()=>{s.copyRanges(S)}}),E.push({title:"Copy Selection w/ Headers",group:j.GROUP_COPY,order:40,action:()=>{s.copyRanges(S,!0)}})),tt(c)&&c.isEditable&&S.length>0&&E.push({title:"Delete Selected Rows",group:j.GROUP_EDIT,order:50,action:()=>{this.irisGrid.deleteRanges(S)}})),E.length===0?!1:(k(s.gridWrapper),le.triggerMenu(s.gridWrapper,n.pageX,n.pageY,E),!0)}dateFormatActions(t){const{model:e}=this.irisGrid.props,{formatter:n}=e,s=n.getColumnFormat(t.type,t.name),i=El.getOptions(n,s),o=[];for(let r=0;r<i.length;r+=1){const{description:l,format:a,group:d,isSelected:c,title:u}=i[r];o.push({title:u,description:l,icon:c?ss:void 0,group:d,order:r,action:()=>{const m=e.getColumnIndexByName(t.name);k(m),this.irisGrid.handleFormatSelection(m,a)}})}return o}numberFormatActions(t){const{model:e}=this.irisGrid.props,{formatter:n}=e,s=n.getColumnFormat(t.type,t.name);let i;const o=e.getColumnIndexByName(t.name);if(N.isDecimalType(t.type))i=Bo.getOptions(s,l=>{k(o),this.debouncedUpdateCustomFormat(o,l)});else if(N.isIntegerType(t.type))i=yl.getOptions(s,l=>{k(o),this.debouncedUpdateCustomFormat(o,l)});else return Mc.error("Invalid column type in numberFormatActions"),null;const r=[];for(let l=0;l<i.length;l+=1){const{format:a,isSelected:d}=i[l];r.push({...i[l],icon:d?ss:void 0,order:l,action:()=>{o===void 0&&a&&a.type===nt.TYPE_CONTEXT_CUSTOM||(k(o),this.irisGrid.handleFormatSelection(o,a))}})}return r}stringFilterActions(t,e,n,s,i){const o=I.FilterValue.ofString(n);let r=s;r||(r={filter:null,text:null});const{filter:l,text:a}=r,d=[],{model:c}=this.irisGrid.props,u=c.getColumnIndexByName(t.name);return k(u),d.push({menuElement:v("div",{className:"iris-grid-filter-menu-item-value",children:[i?j.getOperatorAsText(i):""," ",'"',e,'"']}),order:1,group:le.groups.high}),d.push({title:"text is exactly",description:`Show only rows where ${t.name} is ${n} (case sensitive)`,action:()=>{this.irisGrid.setQuickFilter(u,j.getQuickFilterCondition(l,t.filter().eq(o),i),j.getQuickFilterText(a,`=${e}`,i))},order:10,group:le.groups.low}),d.push({title:"text is not exactly",description:`Show only rows where ${t.name} is not ${e} (case sensitive)`,action:()=>{this.irisGrid.setQuickFilter(u,j.getQuickFilterCondition(l,t.filter().notEq(o),i),j.getQuickFilterText(a,`!=${e}`,i))},order:20,group:le.groups.low}),d.push({title:"text contains",description:`Show only rows where ${t.name} contains ${e}`,action:()=>{this.irisGrid.setQuickFilter(u,j.getQuickFilterCondition(l,t.filter().contains(o),i),j.getQuickFilterText(a,`~${e}`,i))},order:30,group:le.groups.low}),d.push({title:"text does not contain",description:`Show only rows where ${t.name} does not contain ${n}`,action:()=>{this.irisGrid.setQuickFilter(u,j.getQuickFilterCondition(l,t.filter().contains(o).not(),i),j.getQuickFilterText(a,`!~${e}`,i))},order:40,group:le.groups.low}),d.push({title:"text starts with",description:`Show only rows where ${t.name} starts with ${e}`,action:()=>{this.irisGrid.setQuickFilter(u,j.getQuickFilterCondition(l,t.filter().invoke("startsWith",o),i),j.getQuickFilterText(a,`${e}*`,i))},order:50,group:le.groups.low}),d.push({title:"text ends with",description:`Show only rows where ${t.name} ends with ${e}`,action:()=>{this.irisGrid.setQuickFilter(u,j.getQuickFilterCondition(l,t.filter().invoke("endsWith",o),i),j.getQuickFilterText(a,`*${e}`,i))},order:60,group:le.groups.low}),d}numberFilterActions(t,e,n,s,i){const o=j.getFilterValueForNumberOrChar(t.type,n);let r=null,l=null;s&&(r=s.filter,l=s.text);const a=[],d=n!==Number.POSITIVE_INFINITY&&n!==Number.NEGATIVE_INFINITY&&!Number.isNaN(n),{model:c}=this.irisGrid.props,u=c.getColumnIndexByName(t.name);return k(u),a.push({menuElement:v("div",{className:"iris-grid-filter-menu-item-value",children:[i?j.getOperatorAsText(i):""," ",'"',e,'"']}),order:1,group:le.groups.high}),a.push({title:"is equal to",description:`Show only rows where ${t.name} is ${e}`,action:()=>{const m=j.getNumberValueEqualsFilter(t,n);this.irisGrid.setQuickFilter(u,j.getQuickFilterCondition(r,m,i),j.getQuickFilterText(l,`=${e}`,i))},order:10,group:le.groups.low}),a.push({title:"is not equal to",description:`Show only rows where ${t.name} is not ${e}`,action:()=>{const m=j.getNumberValueEqualsFilter(t,n).not();this.irisGrid.setQuickFilter(u,j.getQuickFilterCondition(r,m,i),j.getQuickFilterText(l,`!=${e}`,i))},order:20,group:le.groups.low}),d&&!N.isCharType(t.type)&&(a.push({title:"greater than",description:`Show only rows where ${t.name} is greater than ${e}`,action:()=>{this.irisGrid.setQuickFilter(u,j.getQuickFilterCondition(r,t.filter().greaterThan(o),i),j.getQuickFilterText(l,`>${e}`,i))},order:30,group:le.groups.low}),a.push({title:"greater than or equal to",description:`Show only rows where ${t.name} is greater than or equal to ${e}`,action:()=>{this.irisGrid.setQuickFilter(u,j.getQuickFilterCondition(r,t.filter().greaterThanOrEqualTo(o),i),j.getQuickFilterText(l,`>=${e}`,i))},order:40,group:le.groups.low}),a.push({title:"less than",description:`Show only rows where ${t.name} is less than ${e}`,action:()=>{this.irisGrid.setQuickFilter(u,j.getQuickFilterCondition(r,t.filter().lessThan(o),i),j.getQuickFilterText(l,`<${e}`,i))},order:50,group:le.groups.low}),a.push({title:"less than or equal to",description:`Show only rows where ${t.name} is less than or equal to ${e}`,action:()=>{this.irisGrid.setQuickFilter(u,j.getQuickFilterCondition(r,t.filter().lessThanOrEqualTo(o),i),j.getQuickFilterText(l,`<=${e}`,i))},order:60,group:le.groups.low})),a}booleanFilterActions(t,e,n,s){const i=[],{model:o}=this.irisGrid.props,{filter:r,text:l}=n||{},a=o.getColumnIndexByName(t.name);return k(a),i.push({menuElement:v("div",{className:"iris-grid-filter-menu-item-value",children:[s?j.getOperatorAsText(s):""," ",'"',e??"null",'"']}),order:1,group:le.groups.high}),i.push({title:"true",description:`Show only rows where ${t.name} is true`,action:()=>{this.irisGrid.setQuickFilter(a,j.getQuickFilterCondition(r,t.filter().isTrue(),s),j.getQuickFilterText(l,"true",s))},order:10,group:le.groups.low}),i.push({title:"false",description:`Show only rows where ${t.name} is false`,action:()=>{this.irisGrid.setQuickFilter(a,j.getQuickFilterCondition(r,t.filter().isFalse(),s),j.getQuickFilterText(l,"false",s))},order:20,group:le.groups.low}),i.push({title:"is null",description:`Show only rows where ${t.name} is null`,action:()=>{this.irisGrid.setQuickFilter(a,j.getQuickFilterCondition(r,t.filter().isNull(),s),j.getQuickFilterText(l,"null",s))},order:30,group:le.groups.low}),i.push({title:"is not null",description:`Show only rows where ${t.name} is not null`,action:()=>{this.irisGrid.setQuickFilter(a,j.getQuickFilterCondition(r,t.filter().isNull().not(),s),j.getQuickFilterText(l,"!null",s))},order:40,group:le.groups.low}),i}dateFilterActions(t,e,n,s,i,o){const r=I.FilterValue.ofNumber(s);let l=null,a=null;i&&(l=i.filter,a=i.text);const{model:d}=this.irisGrid.props,c=d.getColumnIndexByName(t.name);k(c);const u=[];return u.push({menuElement:v("div",{className:"iris-grid-filter-menu-item-value",children:[o?j.getOperatorAsText(o):""," ",'"',n,'"']}),order:1,group:le.groups.high}),u.push({title:"date is",description:`Show only rows where ${t.name} is ${n}`,action:()=>{this.irisGrid.setQuickFilter(c,j.getQuickFilterCondition(l,t.filter().eq(r),o),j.getQuickFilterText(a,`=${e}`,o))},order:10,group:le.groups.low}),u.push({title:"date is not",description:`Show only rows where ${t.name} is not ${n}`,action:()=>{this.irisGrid.setQuickFilter(c,j.getQuickFilterCondition(l,t.filter().notEq(r),o),j.getQuickFilterText(a,`!=${e}`,o))},order:20,group:le.groups.low}),u.push({title:"date is before",description:`Show only rows where ${t.name} is before ${n}`,action:()=>{this.irisGrid.setQuickFilter(c,j.getQuickFilterCondition(l,t.filter().lessThan(r),o),j.getQuickFilterText(a,`<${e}`,o))},order:30,group:le.groups.low}),u.push({title:"date is before or equal",description:`Show only rows where ${t.name} is before or equal to ${n}`,action:()=>{this.irisGrid.setQuickFilter(c,j.getQuickFilterCondition(l,t.filter().lessThanOrEqualTo(r),o),j.getQuickFilterText(a,`<=${e}`,o))},order:40,group:le.groups.low}),u.push({title:"date is after",description:`Show only rows where ${t.name} is greater than ${n}`,action:()=>{this.irisGrid.setQuickFilter(c,j.getQuickFilterCondition(l,t.filter().greaterThan(r),o),j.getQuickFilterText(a,`>${e}`,o))},order:50,group:le.groups.low}),u.push({title:"date is after or equal",description:`Show only rows where ${t.name} is after or equal to ${n}`,action:()=>{this.irisGrid.setQuickFilter(c,j.getQuickFilterCondition(l,t.filter().greaterThanOrEqualTo(r),o),j.getQuickFilterText(a,`>=${e}`,o))},order:60,group:le.groups.low}),u}nullFilterActions(t,e,n){let s=null,i=null;e&&(s=e.filter,i=e.text);const o=[],{model:r}=this.irisGrid.props,l=r.getColumnIndexByName(t.name);return k(l),o.push({menuElement:v("div",{className:"iris-grid-filter-menu-item-value",children:[n?j.getOperatorAsText(n):""," ",'"null"']}),order:1,group:le.groups.high}),o.push({title:"is null",description:`Show only rows where ${t.name} is null`,action:()=>{this.irisGrid.setQuickFilter(l,j.getQuickFilterCondition(s,t.filter().isNull(),n),j.getQuickFilterText(i,"null",n))},order:10,group:le.groups.low}),o.push({title:"is not null",description:`Show only rows where ${t.name} is not null`,action:()=>{this.irisGrid.setQuickFilter(l,j.getQuickFilterCondition(s,t.filter().isNull().not(),n),j.getQuickFilterText(i,"!null",n))},order:20,group:le.groups.low}),o}sortByActions(t,e,n){const s=this.irisGrid.getTheme(),{contextMenuSortIconColor:i}=s,o=[{title:`${t.name} Ascending`,order:10,action:()=>{this.irisGrid.sortColumn(e,j.COLUMN_SORT_DIRECTION.ascending)},icon:this.checkColumnSort(n,j.COLUMN_SORT_DIRECTION.ascending)?Wn:void 0,iconColor:i},{title:`${t.name} Descending`,order:20,action:()=>{this.irisGrid.sortColumn(e,j.COLUMN_SORT_DIRECTION.descending)},icon:this.checkColumnSort(n,j.COLUMN_SORT_DIRECTION.descending)?Wn:void 0,iconColor:i},{title:"Remove Sort",order:50,action:()=>{this.irisGrid.sortColumn(e,j.COLUMN_SORT_DIRECTION.none,!1,!0)},disabled:!n}];return N.isNumberType(t.type)&&(o.push({title:`ABS(${t.name}) Ascending`,order:30,action:()=>{this.irisGrid.sortColumn(e,j.COLUMN_SORT_DIRECTION.ascending,!0)},icon:this.checkColumnSort(n,j.COLUMN_SORT_DIRECTION.ascending,!0)?Wn:void 0,iconColor:i}),o.push({title:`ABS(${t.name}) Descending`,order:40,action:()=>{this.irisGrid.sortColumn(e,j.COLUMN_SORT_DIRECTION.descending,!0)},icon:this.checkColumnSort(n,j.COLUMN_SORT_DIRECTION.descending,!0)?Wn:void 0,iconColor:i})),o}additionalSortActions(t,e){const n=this.irisGrid.getTheme(),{contextMenuSortIconColor:s}=n,i=[{title:"Add Sort By",menuElement:v("div",{className:"btn-context-menu menu-title",children:[h("span",{className:"icon",children:h(J,{icon:Wn,style:{color:s??void 0}})}),h("span",{className:"title",children:"Add Additional Sort"}),h("span",{className:"shortcut",children:Hn.isMacPlatform()?"\u2318Click":"Ctrl+Click"})]}),order:1},{title:`${t.name} Ascending`,order:10,action:()=>{this.irisGrid.sortColumn(e,j.COLUMN_SORT_DIRECTION.ascending,!1,!0)}},{title:`${t.name} Descending`,order:20,action:()=>{this.irisGrid.sortColumn(e,j.COLUMN_SORT_DIRECTION.descending,!1,!0)}}];return N.isNumberType(t.type)&&(i.push({title:`ABS(${t.name}) Ascending`,order:30,action:()=>{this.irisGrid.sortColumn(e,j.COLUMN_SORT_DIRECTION.ascending,!0,!0)}}),i.push({title:`ABS(${t.name}) Descending`,order:40,action:()=>{this.irisGrid.sortColumn(e,j.COLUMN_SORT_DIRECTION.descending,!0,!0)}})),i}checkColumnSort(t,e=null,n=!1){return t?t.direction===e&&t.isAbs===n:!1}};let Bn=j;Bn.GROUP_EDIT=le.groups.high+10;Bn.GROUP_HIDE_COLUMNS=le.groups.high+25;Bn.GROUP_FILTER=le.groups.high+50;Bn.GROUP_EXPAND_COLLAPSE=le.groups.high+55;Bn.GROUP_GOTO=le.groups.high+60;Bn.GROUP_SORT=le.groups.high+75;Bn.GROUP_COPY=le.groups.high+100;Bn.GROUP_FORMAT=le.groups.high+150;Bn.COLUMN_SORT_DIRECTION={ascending:"ASC",descending:"DESC",none:null};class gT extends ft{constructor(e){super(),this.irisGrid=e}onDoubleClick(e){const{column:n,row:s}=e;return s==null||n==null?!1:(this.irisGrid.selectData(n,s),!0)}}class fT extends ft{constructor(e){super(),this.irisGrid=e}onDown(e){const{y:n,column:s,row:i}=e;if(s!==null&&i===null){const{isFilterBarShown:o,metrics:r}=this.irisGrid.state;if(!r)throw new Error("Metrics not set");const{columnHeaderMaxDepth:l}=r,a=this.irisGrid.getTheme();if(o&&a.columnHeaderHeight!=null&&a.filterBarHeight!=null&&n>a.columnHeaderHeight*l&&n<=a.columnHeaderHeight*l+a.filterBarHeight)return this.irisGrid.focusFilterBar(s),!0}return!1}onMove(e){const{y:n,column:s}=e,{isFilterBarShown:i,hoverAdvancedFilter:o,metrics:r}=this.irisGrid.state;if(!r)throw new Error("Metrics not set");const{columnHeaderMaxDepth:l}=r,a=this.irisGrid.getTheme();let d=null;return i&&a.columnHeaderHeight!=null&&a.filterBarHeight!=null&&s!==null&&n>=a.columnHeaderHeight*l&&n<=a.columnHeaderHeight*l+a.filterBarHeight&&(d=s),d!==o&&this.irisGrid.setState({hoverAdvancedFilter:d}),!1}onLeave(e){const{column:n}=e,{hoverAdvancedFilter:s}=this.irisGrid.state;return s!==null&&n!==s&&this.irisGrid.setState({hoverAdvancedFilter:null}),!1}}class CT extends ft{constructor(e){super(750),this.irisGrid=e}destroyTooltip(){this.irisGrid.setState({expandCellTooltipProps:null})}setCursor(e,n){return Ai.isInTreeBox(e,n)?(this.cursor="pointer",{stopPropagation:!1,preventDefault:!1}):(this.cursor=null,!1)}getButtonPosition({x:e,y:n,column:s,row:i}){if(s==null||i==null)return null;const{renderer:o,grid:r,state:l,props:a}=this.irisGrid;if(!r)return null;const{metrics:d}=l,{model:c}=a,{canvasContext:u}=r,m=r.getTheme(),p={context:u,mouseX:e,mouseY:n,metrics:d,model:c,theme:m},g=ze(c)?c.depthForRow(i):null,{left:f,top:C,width:S,height:w}=o.getExpandButtonPosition(p,g);return f==null||S==null||C==null||w==null?null:{left:f,top:C,width:S,height:w}}onMove(e,n){if(Ai.isInTreeBox(e,n)){const{expandCellTooltipProps:s}=this.irisGrid.state,{model:i}=this.irisGrid.props,o=this.getButtonPosition(e),{row:r}=e;k(r);const l=ze(i)&&i.isRowExpanded(r);ct(s,o)||this.irisGrid.setState({expandCellTooltipProps:o,expandTooltipDisplayValue:l?"collapse":"expand"})}else this.destroyTooltip();return this.setCursor(e,n)}onDown(){return this.destroyTooltip(),!1}onContextMenu(){return this.destroyTooltip(),!1}onWheel(){return this.destroyTooltip(),!1}onLeave(){return this.destroyTooltip(),!1}}class ST extends ft{constructor(e){super(),this.column=null,this.irisGrid=e}getColumnFromGridPoint(e){const{column:n,row:s,columnHeaderDepth:i}=e;return n!==null&&s===null&&i===0?n:null}onDown(e){return this.column=this.getColumnFromGridPoint(e),!1}onClick(e,n,s){const i=this.getColumnFromGridPoint(e);if(i!=null&&i===this.column){const o=Hn.isModifierKeyDown(s);return this.irisGrid.toggleSort(i,o),!0}return!1}}class bT extends ft{constructor(e){super(),this.irisGrid=e}onWheel(e,n,s){const{irisGrid:i}=this,{model:o}=i.props,{metrics:r,pendingRowCount:l}=i.state;k(r);const{bottom:a,rowCount:d,rowHeight:c}=r,{deltaY:u}=q.getScrollDelta(s);return tt(o)&&o.isEditable&&a>=d-1&&u>0&&i.setState({pendingRowCount:l+Math.ceil(u/c)}),!1}}const wT=3e3;function TT({children:t=null,onEntering:e,onEntered:n,onExiting:s,onExited:i}){const[o,r]=b.exports.useState(!1),l=b.exports.useRef(),a=ll(t),d=b.exports.useCallback(()=>{r(!0),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{r(!1)},wT)},[r,l]);return b.exports.useEffect(()=>{a!==t&&t!=null&&d()},[t,a,r,d]),b.exports.useEffect(()=>()=>l.current?clearTimeout(l.current):void 0,[]),h(vl,{className:"toast-bottom-bar",isShown:o,onEntering:e,onEntered:n,onExiting:s,onExited:i,children:t})}class vT extends Uo{getGridY(e){let n=super.getGridY(e);const{isFilterBarShown:s,theme:i,advancedFilters:o,quickFilters:r,sorts:l,reverseType:a}=e;return s?n+=i.filterBarHeight:(r!=null&&r.size>0||o!=null&&o.size>0)&&(n+=i.filterBarCollapsedHeight),a!==N.REVERSE_TYPE.NONE&&l!=null&&l.length>0&&(n+=i.reverseHeaderBarHeight),n}getUserColumnWidths(){return this.userColumnWidths}}const ET=1,cm=de.memo(({model:t,modelColumns:e,top:n,bottom:s,left:i,right:o,filter:r,formatter:l,reverseType:a=N.REVERSE_TYPE.NONE,sorts:d,customColumns:c,movedColumns:u,hiddenColumns:m,alwaysFetchColumns:p,rollupConfig:g=null,totalsConfig:f=null,selectDistinctColumns:C=He,pendingRowCount:S=0,pendingDataMap:w=Jn,frozenColumns:T,formatColumns:y,columnHeaderGroups:E})=>{const R=b.exports.useMemo(()=>te.getModelViewportColumns(e,i,o,u,m,p,ET),[e,i,o,u,m,p]);return b.exports.useEffect(function(){t.filter=r},[t,r]),b.exports.useEffect(function(){const D=[...d];a!==N.REVERSE_TYPE.NONE&&D.push(I.Table.reverse()),t.sort=D},[t,d,a]),b.exports.useEffect(function(){t.formatter=l},[t,l]),b.exports.useEffect(function(){t.isCustomColumnsAvailable&&(t.customColumns=c)},[t,c]),b.exports.useEffect(function(){t.isFormatColumnsAvailable&&(t.formatColumns=y)},[t,y]),b.exports.useEffect(function(){t.setViewport(n,s,R)},[t,n,s,R]),b.exports.useEffect(function(){t.isRollupAvailable&&(t.rollupConfig=g)},[t,t.isRollupAvailable,g]),b.exports.useEffect(function(){t.isSelectDistinctAvailable&&(t.selectDistinctColumns=C)},[t,C]),b.exports.useEffect(function(){t.isTotalsAvailable&&(t.totalsConfig=f)},[t,t.isTotalsAvailable,f]),b.exports.useEffect(function(){t.pendingRowCount=S},[t,S]),b.exports.useEffect(function(){t.pendingDataMap=w},[t,w]),b.exports.useEffect(function(){T&&t.updateFrozenColumns(T)},[t,T]),b.exports.useEffect(function(){t.columnHeaderGroups=E},[t,E]),null});cm.displayName="IrisGridModelUpdater";const Nn=Object.freeze({SORT_UP:"sortUp",SORT_DOWN:"sortDown",CARET_DOWN:"caretDown",CARET_RIGHT:"caretRight",CELL_OVERFLOW:"cellOverflow"}),xc=10,Xl=16;class Eo extends li{constructor(){super(),this.icons={},this.initIcons()}static isFilterValid(e,n){const s=e==null||e.filter!=null,i=n==null||n.filter!=null;return s&&i}initIcons(){this.setIcon(Nn.SORT_UP,bg),this.setIcon(Nn.SORT_DOWN,wg),this.setIcon(Nn.CARET_DOWN,ts),this.setIcon(Nn.CARET_RIGHT,wh),this.setIcon(Nn.CELL_OVERFLOW,Tg)}setIcon(e,n){const s=Array.isArray(n.icon[4])?n.icon[4][0]:n.icon[4],i=new Path2D(s),o=new Path2D,r={a:Xl/n.icon[0],d:Xl/n.icon[1]};o.addPath(i,r),this.icons[e]=o}getIcon(e){return this.icons[e]}getSortIcon(e){return e?e.direction===N.sortDirection.ascending?this.getIcon(Nn.SORT_UP):e.direction===N.sortDirection.descending?this.getIcon(Nn.SORT_DOWN):null:null}drawCanvas(e){super.drawCanvas(e),this.drawScrim(e)}drawGrid(e,n){super.drawGrid(e,n),this.drawCellOverflowButton(n)}drawGridLines(e,n){super.drawGridLines(e,n),this.drawGroupedColumnLine(e,n),this.drawPendingRowLine(e,n)}drawCellContent(e,n,s,i){const{metrics:o,model:r}=n,{modelColumns:l,modelRows:a}=o,d=O(a,i),c=l.get(s);if(c===void 0)return;const u=r.valueForCell(c,d);if(N.isTextType(r.columns[c]?.type)&&(u===null||u==="")){const m=e.font;e.font=`italic ${m}`;const p=u===null?"null":"empty";super.drawCellContent(e,n,s,i,p),e.font=m;return}super.drawCellContent(e,n,s,i)}drawGroupedColumnLine(e,n){const{metrics:s,model:i,theme:o}=n,{groupedColumns:r,columns:l}=i,{maxY:a,allColumnWidths:d,allColumnXs:c}=s;if(r.length===0||o.groupedColumnDividerColor==null)return;const u=r[r.length-1],m=l.findIndex(C=>C.name===u.name),p=c.get(m),g=d.get(m);if(p==null||g==null)return;const f=p+g+.5;e.strokeStyle=o.groupedColumnDividerColor,e.lineWidth=1,e.beginPath(),e.moveTo(f,0),e.lineTo(f,a),e.stroke()}drawPendingRowLine(e,n){const{metrics:s,model:i,theme:o}=n,{allRowYs:r,maxX:l}=s,{pendingRowCount:a}=i;if(a<=0)return;const d=i.rowCount-i.pendingRowCount-i.floatingBottomRowCount;let c=r.get(d);c!=null&&(c-=.5,e.save(),e.setLineDash([4,2]),e.strokeStyle=o.pendingTextColor,e.lineWidth=1,e.beginPath(),e.moveTo(0,c),e.lineTo(l,c),e.stroke(),e.restore())}drawMouseColumnHover(e,n){const{theme:s,metrics:i,hoverSelectColumn:o}=n;if(o==null||s.linkerColumnHoverBackgroundColor==null)return;const{allColumnWidths:r,allColumnXs:l,maxY:a}=i,d=l.get(o),c=r.get(o);k(d),k(c),e.fillStyle=s.linkerColumnHoverBackgroundColor,e.fillRect(d,0,c,a)}drawMouseRowHover(e,n){const{isSelectingColumn:s}=n;s||super.drawMouseRowHover(e,n)}drawScrim(e){const{context:n,loadingScrimProgress:s,metrics:i,theme:o}=e;if(s==null)return;const{width:r,height:l,gridY:a}=i,{scrimBlurSize:d,scrimColor:c}=o;n.save(),n.globalCompositeOperation="color",n.filter=`blur(${d}px)`,c!=null&&(n.fillStyle=c),n.beginPath(),n.rect(0,a,r,l-a),n.clip(),n.fillRect(-d,-d+a,d*2+r,(d*2+(l-a))*s),n.globalCompositeOperation="overlay",n.filter=`blur(${d}px) opacity(15%)`,n.fillRect(-d,-d+a,d*2+r,(d*2+(l-a))*s),n.restore()}drawColumnHeaders(e,n){super.drawColumnHeaders(e,n);const{theme:s,metrics:i,model:o,reverseType:r}=n,{columnHeaderHeight:l}=i;if(this.drawFilterHeaders(e,n),l<=0)return;const{sort:a}=o;if(a.length===1){const d=r!==N.REVERSE_TYPE.NONE;let c;d?c=s.headerReverseBarColor:c=s.headerSortBarColor,this.drawHeaderBar(e,n,c,d?s.reverseHeaderBarHeight:s.sortHeaderBarHeight)}else a.length>1&&(r!==N.REVERSE_TYPE.NONE&&this.drawHeaderBar(e,n,s.headerReverseBarColor,s.reverseHeaderBarHeight,!1),this.drawHeaderBar(e,n,s.headerSortBarColor,s.sortHeaderBarHeight))}drawHeaderBar(e,n,s,i,o=!0){const{theme:r,metrics:l,model:a}=n,{columnHeaderHeight:d,width:c}=l;let u=0;o||(u=i),e.fillStyle=r.headerBarCasingColor,e.fillRect(0,a.columnHeaderMaxDepth*d-i-2+u,c,i+2),e.fillStyle=s,e.fillRect(0,a.columnHeaderMaxDepth*d-i-1+u,c,i)}drawColumnHeadersAtDepth(e,n,s,i,o){const{metrics:r,model:l,isMenuShown:a}=n,{columnHeaderMaxDepth:d}=l,{width:c}=r,u={...i,maxX:o===d-1&&i.maxX===c?c-(a?0:30):i.maxX};super.drawColumnHeadersAtDepth(e,n,s,u,o)}drawColumnHeaderAtIndex(e,n,s,i){super.drawColumnHeaderAtIndex(e,n,s,i);const{metrics:o,model:r,theme:l}=n,{modelColumns:a,allColumnWidths:d,allColumnXs:c,gridX:u,columnHeaderHeight:m,fontWidths:p}=o,{headerHorizontalPadding:g}=l,f=O(d,s,0),C=O(c,s)+u,S=a.get(s);if(S==null)return;const w=N.getSortForColumn(r.sort,S);if(!w)return;const T=this.getSortIcon(w);if(!T)return;const y=r.textForColumnHeader(S);if(y===void 0)return;const E=p.get(e.font)??li.DEFAULT_FONT_WIDTH;k(E);const R=y.length*E,F=u+C+R+g;let{maxX:D}=i;D-=g;const _=u+C+f-g-1,H=F>D?F+1:Math.min(D,_),U=w.direction===N.sortDirection.ascending?-6:-12,A=m*.5+U;e.save(),e.beginPath(),e.rect(C,0,f,m),e.clip(),e.fillStyle=l.headerSortBarColor,e.translate(H,A),e.fill(T),e.restore()}drawFilterHeaders(e,n){const{isFilterBarShown:s,quickFilters:i,advancedFilters:o}=n;s?this.drawExpandedFilterHeaders(e,n):(i!=null&&i.size>0||o!=null&&o.size>0)&&this.drawCollapsedFilterHeaders(e,n)}drawExpandedFilterHeaders(e,n){const{metrics:s,model:i,theme:o,quickFilters:r,advancedFilters:l}=n,{filterBarHeight:a}=o;if(a<=0)return;const{gridX:d,gridY:c,maxX:u,modelColumns:m,visibleColumns:p,allColumnWidths:g,allColumnXs:f}=s,C=c-a;e.save(),e.font=o.font,e.textAlign="left",r!=null&&r.size>0||l!=null&&l.size>0?e.fillStyle=o.filterBarExpandedActiveBackgroundColor:e.fillStyle=o.filterBarExpandedBackgroundColor,e.fillRect(d,C,u,a-1),e.fillStyle=o.headerBarCasingColor,e.fillRect(d,C+a-1,u,1);const S=C;e.strokeStyle=o.filterBarSeparatorColor,e.beginPath();for(let w=0;w<p.length;w+=1){const T=p[w],y=O(m,T),E=O(f,T),R=O(g,T);if(i.isFilterable(y)&&R>0){const F=d+(E??0);e.rect(F+.5,S+.5,R,a-2)}}e.stroke();for(let w=0;w<p.length;w+=1){const T=p[w],y=O(g,T),R=O(f,T)+d;this.drawExpandedFilterHeader(e,n,T,R,y)}e.restore()}drawExpandedFilterHeader(e,n,s,i,o){if(o<=0)return;const{metrics:r,theme:l,quickFilters:a,advancedFilters:d}=n,{modelColumns:c,gridY:u}=r,{filterBarHeight:m,filterBarExpandedActiveCellBackgroundColor:p,filterBarErrorColor:g,filterBarHorizontalPadding:f,headerColor:C}=l,S=u-m,w=c.get(s);if(w===void 0)return;const T=a.get(w),y=d.get(w);if(T==null&&y==null)return;let E=null;if(T!=null){const{text:F}=T;if(E=F,E||(E=N.getFilterText(T.filter)),E!=null){const{fontWidths:D}=r;let _=D.get(e.font);(_==null||_===0)&&(_=e.measureText("8").width,_||(_=10));const H=(o-f*2)/_;H<=0?E="":E.length>H&&(E=`${E.substring(0,H-1)}\u2026`)}}if(e.save(),Eo.isFilterValid(y,T)&&p!=null)e.fillStyle=p,e.fillRect(i+1,S+1,o-1,m-3);else if(g!=null){e.fillStyle=g,e.lineWidth=2,e.strokeStyle=g;const F=i+2,D=S+2,_=o-3,H=m-5;e.strokeRect(F,D,_,H)}if(E!=null&&E!==""){const F=i+f,D=S+m*.5+1;e.fillStyle=C,e.fillText(E,F,D)}e.restore()}drawCollapsedFilterHeaders(e,n){const{metrics:s,theme:i}=n,{headerSeparatorColor:o,filterBarCollapsedHeight:r}=i;if(r<=0)return;const{gridX:l,gridY:a,maxX:d,visibleColumns:c,allColumnWidths:u,allColumnXs:m}=s,p=a-r;e.save(),e.fillStyle=o,e.fillRect(l,p,d,r);for(let g=0;g<c.length;g+=1){const f=c[g],C=u.get(f),S=m.get(f);if(S!=null&&C!=null){const w=S+l;this.drawCollapsedFilterHeader(e,n,f,w,C)}}e.restore()}drawCollapsedFilterHeader(e,n,s,i,o){if(o<=0)return;const{metrics:r,theme:l,quickFilters:a,advancedFilters:d}=n,{modelColumns:c,gridY:u}=r,m=c.get(s);if(m===void 0)return;const p=a.get(m),g=d.get(m),{filterBarCollapsedHeight:f,filterBarActiveColor:C,filterBarActiveBackgroundColor:S,filterBarErrorColor:w}=l;e.save();const T=Eo.isFilterValid(g,p);S!=null&&p==null&&g==null?e.fillStyle=S:C!=null&&T?e.fillStyle=C:w!=null&&(e.fillStyle=w);const y=i+1,E=u-f,R=o-1,F=f-1;e.fillRect(y,E,R,F),e.restore()}drawTreeMarker(e,n,s,i,o,r,l){e.save();const{x1:a,y1:d}=o,c=l?this.getIcon(Nn.CARET_DOWN):this.getIcon(Nn.CARET_RIGHT),u=s+a-2,m=i+d+2.5;e.fillStyle=r,e.textAlign="center",e.translate(u,m),e.fill(c),e.restore()}drawRowFooters(e,n){const{metrics:s,model:i,mouseX:o,mouseY:r,theme:l}=n,{gridY:a,gridX:d,maxX:c,modelRows:u,floatingTopHeight:m,floatingBottomHeight:p,floatingRows:g,rowFooterWidth:f,height:C,horizontalBarHeight:S,verticalBarWidth:w,allRowHeights:T,allRowYs:y,width:E}=s;if(f<=0||g.length===0)return;const{cellHorizontalPadding:R,floatingGridRowColor:F,floatingRowBackgroundColors:D,headerColor:_,rowHoverBackgroundColor:H}=l;e.translate(d,a),e.beginPath();const U=Math.min(c,E-f-w-d);e.fillStyle=D,m>0&&e.rect(U,0,f,m),p>0&&e.rect(U,C-a-S-p,f,p),e.fill();const A=o!=null&&r!=null&&o>=d&&o<=c+f?q.getRowAtY(r,s):null;if(H!=null&&A!==null&&g.includes(A)){e.fillStyle=H;const G=y.get(A),z=T.get(A);k(G),k(z),e.fillRect(U,G,f,z)}if(e.beginPath(),F!=null&&(e.strokeStyle=F),m>0&&(e.moveTo(U+.5,.5),e.lineTo(U+.5,m-.5)),p>0){const G=C-a-S-p;e.moveTo(U-.5,G+.5),e.lineTo(U-.5,G+p-.5)}e.stroke(),e.fillStyle=_,e.textAlign="left";const Y=U+R;for(let G=0;G<g.length;G+=1){const z=g[G],x=T.get(z),L=y.get(z),P=u.get(z);if(L!=null&&x!=null&&P!=null){const Z=L+x*.5;e.fillText(i.textForRowFooter(P),Y,Z)}}e.translate(-d,-a)}getTextRenderMetrics(e,n,s,i){const o=super.getTextRenderMetrics(e,n,s,i),{mouseX:r,mouseY:l,metrics:a}=n;if(r==null||l==null)return o;const{column:d,row:c}=q.getGridPointFromXY(r,l,a);if(s===d&&i===c){const{left:u}=this.getCellOverflowButtonPosition(n);this.shouldRenderOverflowButton(n)&&u!=null&&(o.width=u-a.gridX-o.x)}return o}shouldRenderOverflowButton(e){const{context:n,mouseX:s,mouseY:i,metrics:o,model:r,theme:l}=e;if(s==null||i==null)return!1;const{row:a,column:d,modelRow:c,modelColumn:u}=q.getCellInfoFromXY(s,i,o);if(a==null||d==null||c==null||u==null||!N.isStringType(r.columns[u].type))return!1;const m=r.textForCell(u,c)??"",{width:p}=super.getTextRenderMetrics(n,e,d,a),g=o.fontWidths.get(l.font)??Eo.DEFAULT_FONT_WIDTH;n.save(),n.font=l.font;const f=this.getCachedTruncatedString(n,m,p,g,r.truncationCharForCell(u,c));return n.restore(),m!==""&&f!==m}getCellOverflowButtonPosition({mouseX:e,mouseY:n,metrics:s,theme:i}){const o={left:null,top:null,width:null,height:null};if(e==null||n==null||!s)return o;const{rowHeight:r,columnWidth:l,left:a,top:d}=q.getCellInfoFromXY(e,n,s);k(a),k(l),k(d);const{width:c,verticalBarWidth:u}=s,{cellHorizontalPadding:m}=i,p=Xl+2*m,g=r,C=Math.min(s.gridX+a+l,c-u)-p,S=s.gridY+d;return{left:C,top:S,width:p,height:g}}drawCellOverflowButton(e){const{context:n,mouseX:s,mouseY:i,theme:o}=e;if(s==null||i==null||!this.shouldRenderOverflowButton(e))return;const{left:r,top:l,width:a,height:d}=this.getCellOverflowButtonPosition(e),{cellHorizontalPadding:c,overflowButtonColor:u,overflowButtonHoverColor:m}=o;n.save(),m!=null&&r!=null&&a!=null&&l!=null&&d!=null&&s>=r&&s<=r+a&&i>=l&&i<=l+d?n.fillStyle=m:u!=null&&(n.fillStyle=u);const p=this.getIcon(Nn.CELL_OVERFLOW);r!=null&&l!=null&&n.translate(r+c,l+2),n.fill(p),n.restore()}getExpandButtonPosition({mouseX:e,mouseY:n,metrics:s,theme:i},o){const r={left:null,top:null,width:null,height:null};if(e==null||n==null||o==null||!s)return r;const{rowHeight:l,left:a,top:d}=q.getCellInfoFromXY(e,n,s);k(a),k(l),k(d);const{cellHorizontalPadding:c}=i,u=xc+2*c,m=Math.max(a+xc*o,s.gridX),p=s.gridY+d;return{left:m,top:p,width:u,height:l}}}const yT="12px Fira Sans, sans-serif",RT="#f0f0ee",IT="#1a171a",ue={"grid-bg":"#211f22",font:yT,white:RT,black:IT,"header-bg":"#2d2a2e","header-color":"#f0f0ee","header-height":"30px","header-separator-color":"#211f22","header-separator-hover-color":"#929192","header-hidden-separator-hover-color":"#4878ea","header-sort-bar-color":"#aa9af4","header-reverse-bar-color":"#548d29","header-bar-casing-color":"#211f22","header-font":"600 12px Fira Sans, sans-serif","row-height":"19px","row-background-colors":"#373438 #2d2a2e","selection-color":"rgba(118, 217, 228, 0.09)","selection-outline-color":"#76d9e4","selection-outline-casing-color":"#211f22","row-hover-bg":"#4b494c","selected-row-hover-bg":"rgba(118, 217, 228, 0.25)","scroll-bar-active-selection-tick-color":"rgba(118, 217, 228, 0.5)","scroll-bar-bg":"#322f33","scroll-bar-hover-bg":"#373438","scroll-bar-casing-color":"#555356","scroll-bar-corner-color":"#322f33","scroll-bar-color":"#5b5a5c","scroll-bar-hover-color":"#929192","scroll-bar-active-color":"#c0bfbf","text-color":"#f0f0ee","positive-number-color":"#9edc6f","negative-number-color":"#f95d84","zero-number-color":"#fcd65b","date-color":"#fcd65b","pending-text-color":"#fde38d","error-text-color":"#f95d84","null-string-color":"#929192","filter-bar-active-bg":"#425175","filter-bar-active-color":"#4878ea","filter-bar-expanded-bg":"#373438","filter-bar-expanded-active-bg":"#313849","filter-bar-expanded-active-cell-bg":"#374d80","filter-bar-separator-color":"#929192","filter-bar-error-color":"#f95d84","filter-icon-color":"#4878ea","scrim-color":"#211f22","context-menu-sort-icon-color":"#aa9af4","context-menu-reverse-icon-color":"#548d29","linker-column-hover-bg":"rgba(118, 217, 228, 0.09)","tree-line-color":"#5b5a5c","tree-marker-color":"#c0bfbf","tree-marker-hover-color":"#fcfcfa","grouped-column-divider-color":"#1a171a","floating-grid-row-color":"#555356","floating-row-background-colors":"#403e41","floating-divider-inner-color":"#403e41","floating-divider-outer-color":"#211f22","overflow-button-color":"#c0bfbf","overflow-button-hover-color":"#fcfcfa"},hm=Object.freeze({backgroundColor:ue["grid-bg"],white:ue.white,black:ue.black,font:ue.font,headerBackgroundColor:ue["header-bg"],headerColor:ue["header-color"],headerSeparatorColor:ue["header-separator-color"],headerSeparatorHoverColor:ue["header-separator-hover-color"],headerHiddenSeparatorHoverColor:ue["header-hidden-separator-hover-color"],headerSortBarColor:ue["header-sort-bar-color"],headerReverseBarColor:ue["header-reverse-bar-color"],headerBarCasingColor:ue["header-bar-casing-color"],headerFont:ue["header-font"],rowBackgroundColors:ue["row-background-colors"],rowHoverBackgroundColor:ue["row-hover-bg"],selectionColor:ue["selection-color"],selectionOutlineColor:ue["selection-outline-color"],selectionOutlineCasingColor:ue["selection-outline-casing-color"],selectedRowHoverBackgroundColor:ue["selected-row-hover-bg"],scrollBarBackgroundColor:ue["scroll-bar-bg"],scrollBarHoverBackgroundColor:ue["scroll-bar-hover-bg"],scrollBarCasingColor:ue["scroll-bar-casing-color"],scrollBarCornerColor:ue["scroll-bar-corner-color"],scrollBarColor:ue["scroll-bar-color"],scrollBarHoverColor:ue["scroll-bar-hover-color"],scrollBarActiveColor:ue["scroll-bar-active-color"],scrollBarSelectionTickColor:ue["selected-row-hover-bg"],scrollBarActiveSelectionTickColor:ue["scroll-bar-active-selection-tick-color"],textColor:ue["text-color"],positiveNumberColor:ue["positive-number-color"],negativeNumberColor:ue["negative-number-color"],zeroNumberColor:ue["zero-number-color"],dateColor:ue["date-color"],pendingTextColor:ue["pending-text-color"],errorTextColor:ue["error-text-color"],nullStringColor:ue["null-string-color"],filterBarActiveBackgroundColor:ue["filter-bar-active-bg"],filterBarExpandedBackgroundColor:ue["filter-bar-expanded-bg"],filterBarExpandedActiveBackgroundColor:ue["filter-bar-expanded-active-bg"],filterBarExpandedActiveCellBackgroundColor:ue["filter-bar-expanded-active-cell-bg"],filterBarSeparatorColor:ue["filter-bar-separator-color"],filterBarActiveColor:ue["filter-bar-active-color"],filterBarErrorColor:ue["filter-bar-error-color"],filterIconColor:ue["filter-icon-color"],scrimColor:ue["scrim-color"],contextMenuSortIconColor:ue["context-menu-sort-icon-color"],contextMenuReverseIconColor:ue["context-menu-reverse-icon-color"],allowRowResize:!1,autoSelectRow:!0,gridColumnColor:null,gridRowColor:null,groupedColumnDividerColor:ue["grouped-column-divider-color"],columnHoverBackgroundColor:null,headerHorizontalPadding:12,scrollBarSize:13,scrollBarHoverSize:16,minScrollHandleSize:24,rowHeight:parseInt(ue["row-height"],10)||19,columnWidth:100,rowHeaderWidth:0,rowFooterWidth:60,columnHeaderHeight:parseInt(ue["header-height"],10)||30,filterBarHeight:30,filterBarCollapsedHeight:5,sortHeaderBarHeight:2,reverseHeaderBarHeight:4,filterBarHorizontalPadding:4,scrimBlurSize:25,minScrimTransitionTime:150,maxScrimTransitionTime:350,scrollSnapToRow:!0,linkerColumnHoverBackgroundColor:ue["linker-column-hover-bg"],treeLineColor:ue["tree-line-color"],treeMarkerColor:ue["tree-marker-color"],treeMarkerHoverColor:ue["tree-marker-hover-color"],floatingGridColumnColor:null,floatingGridRowColor:ue["floating-grid-row-color"],floatingRowBackgroundColors:ue["floating-row-background-colors"],floatingDividerInnerColor:ue["floating-divider-inner-color"],floatingDividerOuterColor:ue["floating-divider-outer-color"],overflowButtonColor:ue["overflow-button-color"],overflowButtonHoverColor:ue["overflow-button-hover-color"]});const jl=ee.module("ColumnStatistics"),FT={SIZE:"Number of Rows"},Ta=class extends b.exports.Component{constructor(t){super(t),this.handleError=this.handleError.bind(this),this.handleGenerateStatistics=this.handleGenerateStatistics.bind(this),this.handleStatistics=this.handleStatistics.bind(this),this.cancelablePromise=null,this.state={error:null,loading:!1,statistics:null,numRows:0}}static getStatsLabel(t){return FT[t]??t.split(" ").map(e=>e[0].toUpperCase()+e.substr(1).toLowerCase()).join(" ")}componentDidMount(){this.maybeGenerateStatistics()}componentWillUnmount(){this.cancelablePromise&&this.cancelablePromise.cancel()}maybeGenerateStatistics(){const{model:t}=this.props,e=t.rowCount-t.pendingRowCount;this.setState({numRows:e}),t.isColumnStatisticsAvailable?e<Ta.AUTO_GENERATE_LIMIT&&this.handleGenerateStatistics():this.setState({loading:!1})}handleGenerateStatistics(){this.setState({loading:!0});const{column:t,model:e}=this.props;this.cancelablePromise=ye.makeCancelable(e.columnStatistics(t)),this.cancelablePromise.then(this.handleStatistics).catch(this.handleError)}handleStatistics(t){jl.debug("Received statistics",t);const{model:e,onStatistics:n}=this.props,s=[];t.statisticsMap.forEach((i,o)=>{s.push({operation:Ta.getStatsLabel(o),value:i,type:t.getType(o)})}),t.uniqueValues.forEach((i,o)=>{s.push({operation:o,className:"column-statistics-unique-value",value:i,type:"long"})}),this.setState({loading:!1,statistics:s,numRows:e.rowCount-e.pendingRowCount}),n()}handleError(t){if(t!=null&&ye.isCanceled(t)){jl.debug("Called handleError on a cancelled promise result");return}jl.error("Error generating statistics",t),this.setState({error:t,loading:!1,statistics:null})}render(){const{column:t,model:e}=this.props,{error:n,loading:s,statistics:i,numRows:o}=this.state,r=!s&&n==null&&i==null&&e.isColumnStatisticsAvailable,l=[],a=t.type.substring(t.type.lastIndexOf(".")+1),d=t.description===null?null:t.description;if(i!=null)for(let p=0;p<i.length;p+=1){const{operation:g,className:f,value:C,type:S}=i[p],w=S?e.displayString(C,S):e.displayString(C,t.type,t.name),T=v(de.Fragment,{children:[h("div",{className:K("column-statistic-operation",f),children:g}),h("div",{className:"column-statistic-value",children:w})]},g);l.push(T)}const c=ze(e)&&e.hasExpandableRows?"Expanded Rows":"Number of Rows",u=e.displayString(o,"long"),m=e.getColumnIndexByName(t.name);return v("div",{className:"column-statistics",children:[v("div",{className:"column-statistics-title",children:[t.name,v("span",{className:"column-statistics-type",children:["\xA0(",a,")"]}),h(al,{className:"column-statistics-copy",tooltip:"Copy column name",copy:t.name})]}),d!=null&&h("div",{className:"column-statistics-description",children:d}),m!=null&&!e.isColumnMovable(m)&&v("div",{className:"column-statistics-status",children:[h(J,{icon:e.isColumnFrozen(m)?vg:Eg,className:"mr-1"}),e.isColumnFrozen(m)?"Frozen":"Not movable"]}),v("div",{className:"column-statistics-grid",children:[i==null&&v(Se,{children:[h("div",{className:"column-statistic-operation",children:c}),h("div",{className:"column-statistic-value",children:u})]}),l]}),r&&h(V,{kind:"ghost",className:"px-0",onClick:this.handleGenerateStatistics,children:"Generate Stats"}),n!=null&&h("div",{className:"error-message",children:`${n}`}),i&&!s&&h(V,{kind:"ghost",className:"px-0",onClick:this.handleGenerateStatistics,icon:h(J,{icon:Ua,className:"mr-1"}),children:"Refresh"}),s&&v("div",{className:"column-statistics-loading",children:[h(as,{className:"mr-2"}),"Calculating Stats..."]})]})}};let um=Ta;um.AUTO_GENERATE_LIMIT=1e5;const hr=ee.module("AdvancedFilterCreatorFilterItem");class cd extends b.exports.PureComponent{constructor(e){super(e),this.getCachedIsValid=ge((o,r,l,a)=>{try{return!l||N.makeAdvancedValueFilter(o,r,l,a)!=null}catch{return!1}}),this.handleDelete=this.handleDelete.bind(this),this.handleTypeChange=this.handleTypeChange.bind(this),this.handleValueChange=this.handleValueChange.bind(this),this.typeDropdown=null;const{value:n="",filterTypes:s,selectedType:i=s[0]}=e;this.state={selectedType:i,value:n}}static getLabelForFilter(e,n){try{if(N.isNumberType(e)||N.isCharType(e))return tu(n);if(N.isTextType(e))return eu(n);if(N.isDateType(e))return nu(n);if(N.isBooleanType(e))return UC(n);throw new Error(`Unrecognized column type: ${e}`)}catch(s){return hr.warn(s),""}}componentDidMount(){this.typeDropdown?.focus()}componentDidUpdate(e){const{value:n,selectedType:s}=this.props;s!==void 0&&e.selectedType!==s&&this.setState({selectedType:s}),n!==void 0&&e.value!==n&&this.setState({value:n})}handleTypeChange(e){const n=e.target.value;hr.debug2("typeChange",n),this.setState({selectedType:n});const{onChange:s}=this.props,{value:i}=this.state;i!=null&&i.length>0&&s(n,i)}handleValueChange(e){hr.debug2("valueChange");const{value:n}=e.target;this.setState({value:n});const{onChange:s}=this.props,{selectedType:i}=this.state;i!=null&&s(i,n)}handleDelete(){hr.debug("delete");const{onDelete:e}=this.props;e()}render(){const{column:e,filterTypes:n,formatter:s}=this.props,{selectedType:i,value:o}=this.state,r=!N.isBooleanType(e.type),l=[],a=this.getCachedIsValid(e,i,o,s.timeZone);for(let d=0;d<n.length;d+=1){const c=n[d],u=cd.getLabelForFilter(e.type,c),m=h("option",{value:c,children:u},c);l.push(m)}return h("div",{className:"advanced-filter-creator-filter-item",children:v("div",{className:"form-row",children:[h("div",{className:"form-group col",children:h("select",{className:"form-control custom-select",value:i,onChange:this.handleTypeChange,ref:d=>{this.typeDropdown=d},children:l})}),r&&h("div",{className:"form-group col",children:h("div",{className:"input-group",children:h("input",{type:"text",className:K("form-control",{error:!a}),placeholder:"Enter value",value:o,onChange:this.handleValueChange})})}),h("div",{className:"form-group col-1 px-0",children:h(V,{kind:"ghost",className:"w-100 h-100 p-0 m-0",onClick:this.handleDelete,icon:sn,tooltip:"Remove Filter"})})]})})}}const Oc=ee.module("AdvancedFilterCreatorSelectValueList"),va=class extends b.exports.PureComponent{constructor(t){super(t),this.handleSelect=this.handleSelect.bind(this),this.handleViewportChange=this.handleViewportChange.bind(this),this.handleSelectionUpdate=this.handleSelectionUpdate.bind(this),this.handleTableUpdate=this.handleTableUpdate.bind(this),this.list=null;const{selectedValues:e}=this.props;this.state={itemCount:0,items:[],offset:0,selectedValues:e,isLoading:!0}}static indexOf(t,e){for(let n=0;n<e.length;n+=1){const s=e[n];if(s===t||s!=null&&s.valueOf!=null&&t!=null&&t.valueOf!=null&&s.valueOf()===t.valueOf())return n}return-1}componentDidMount(){const{table:t}=this.props;t&&this.startListening(t)}componentDidUpdate(t){const{filters:e,invertSelection:n,selectedValues:s,table:i}=this.props;t.table!==i&&(t.table&&this.stopListening(t.table),i&&this.startListening(i),this.resetViewport()),t.invertSelection!==n&&this.setState({selectedValues:[]},this.handleSelectionUpdate),t.selectedValues!==s&&this.setState({selectedValues:s},this.handleSelectionUpdate),t.filters!==e&&(i?.applyFilter(e),this.resetViewport())}componentWillUnmount(){const{table:t}=this.props;t&&this.stopListening(t)}handleSelect(t,e){const{invertSelection:n}=this.props;let{selectedValues:s}=this.state;s=[...s];const i=va.indexOf(e,s);i>=0?s.splice(i,1):s.push(e);let o=i<0;n&&(o=!o);const{offset:r}=this.state;let{items:l}=this.state;l=[...l];const a=t-r;a>=0&&a<l.length&&(l[a].isSelected=o),this.setState({items:l,selectedValues:s});const{onChange:d}=this.props;d(s,n)}handleViewportChange(t,e){this.updateViewport(t,e)}handleSelectionUpdate(){this.updateItemSelection()}handleTableUpdate(t){const{table:e,formatter:n}=this.props;if(!e)return;const s=t.detail,{offset:i}=s,o=[],r=e.columns[0];for(let a=0;a<s.rows.length;a+=1){const c=s.rows[a].get(r),u=n.getFormattedString(c,r.type,r.name),m=this.isValueSelected(c);o.push({displayValue:u,value:c,isSelected:m})}Oc.debug2("Received table update:",i,o.length);const l=e.size;this.setState({itemCount:l,items:o,offset:i,isLoading:!1})}isValueSelected(t){const{invertSelection:e}=this.props,{selectedValues:n}=this.state,s=va.indexOf(t,n);return e?s<0:s>=0}startListening(t){t.addEventListener(I.Table.EVENT_UPDATED,this.handleTableUpdate)}stopListening(t){t.removeEventListener(I.Table.EVENT_UPDATED,this.handleTableUpdate)}resetViewport(){this.list&&this.list.topRow!=null&&this.list.bottomRow!=null&&this.updateViewport(this.list.topRow,this.list.bottomRow,!0)}updateItemSelection(){let{items:t}=this.state;t=[...t];for(let e=0;e<t.length;e+=1){const n=t[e],{value:s}=n;n.isSelected=this.isValueSelected(s)}this.setState({items:t})}updateViewport(t,e,n=!1){const{table:s}=this.props;if(s==null)return;n&&this.setState({isLoading:!0});const i=e-t+1,o=Math.max(0,t-i*3),r=Math.max(o,e+i*3);Oc.debug2("Setting viewport",o,",",r),s.setViewport(o,r)}render(){const{offset:t,isLoading:e,items:n,itemCount:s}=this.state;return v("div",{className:"select-value-list-wrapper",children:[h(yg,{itemCount:s,items:n,offset:t,onSelect:this.handleSelect,onViewportChange:this.handleViewportChange,ref:i=>{this.list=i}}),h(Ht,{in:e,timeout:250,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:"loading-list",children:h(as,{className:"loading-spinner-large"})})})]})}};let mm=va;mm.defaultProps={invertSelection:!0,selectedValues:[],onChange:()=>{}};const pm=class extends b.exports.PureComponent{constructor(t){super(t),this.handleSelectAllClick=this.handleSelectAllClick.bind(this),this.handleClearAllClick=this.handleClearAllClick.bind(this),this.handleListChange=this.handleListChange.bind(this),this.handleSearchChange=this.handleSearchChange.bind(this),this.handleUpdateFilterTimeout=this.handleUpdateFilterTimeout.bind(this);const{invertSelection:e,selectedValues:n}=t;this.state={filters:[],invertSelection:e,selectedValues:n,searchText:""}}componentDidMount(){this.initSearchTable()}componentDidUpdate(t,e){const{invertSelection:n,selectedValues:s,table:i}=this.props;t.table!==i&&this.initSearchTable(),t.invertSelection!==n&&this.setState({invertSelection:n}),t.selectedValues!==s&&this.setState({selectedValues:s});const{table:o,searchText:r}=this.state;o!==e.table&&(e.table!=null&&e.table.close(),o!=null&&this.startUpdateFilterTimer()),r!==e.searchText&&this.startUpdateFilterTimer()}componentWillUnmount(){const{table:t}=this.state;t?.close(),this.searchTablePromise=void 0,this.stopUpdateFilterTimer()}getColumnName(){const{table:t}=this.props;return t!=null?t.columns[0].name:""}getDisplayedValuesCount(){const{invertSelection:t,selectedValues:e,table:n}=this.state;return n==null?null:t?n.totalSize-e.length:e.length}getDisplayedValueText(){const t=this.getDisplayedValuesCount(),{table:e}=this.state,{formatter:n}=this.props;if(t!=null&&e!=null){const s=n.getFormattedString(t,"long"),i=n.getFormattedString(e.totalSize,"long");let o="";return t<1e6&&(o="Displaying "),`${o}${s} of ${i}`}return null}initSearchTable(){const{table:t}=this.props;if(t==null)return;const e=t.copy();this.searchTablePromise=e,this.searchTablePromise.then(n=>{this.searchTablePromise===e?(this.setState({table:n}),this.searchTablePromise=void 0):n.close()})}handleListChange(t,e){this.setState({selectedValues:t,invertSelection:e});const{onChange:n}=this.props;n(t,e)}handleSearchChange(t){const e=t.target.value;this.setState({searchText:e})}handleSelectAllClick(){this.resetSelection(!0)}handleClearAllClick(){this.resetSelection(!1)}handleUpdateFilterTimeout(){this.updateFilterTimer=void 0,this.updateTableFilter()}resetSelection(t){const e=[];this.setState({invertSelection:t,selectedValues:e});const{onChange:n}=this.props;n(e,t)}startUpdateFilterTimer(){this.stopUpdateFilterTimer(),this.updateFilterTimer=setTimeout(this.handleUpdateFilterTimeout,pm.searchDebounceTime)}stopUpdateFilterTimer(){this.updateFilterTimer!=null&&(clearTimeout(this.updateFilterTimer),this.updateFilterTimer=void 0)}updateTableFilter(){const{table:t,searchText:e}=this.state,{timeZone:n}=this.props,s=t?.columns[0],i=[];if(s==null)return;let o;if(e.length>0){let r=null;N.isCharType(s.type)?r=N.makeQuickFilter(s,e):N.isTextType(s.type)?r=N.makeQuickFilter(s,`~${e}`,n):r=N.makeQuickFilter(s,`>=${e}`,n),r!=null?i.push(r):o="Invalid search text"}this.setState({filters:i,error:o})}render(){const{error:t,filters:e,invertSelection:n,selectedValues:s,searchText:i,table:o}=this.state,{formatter:r,showSearch:l}=this.props,a=this.getColumnName(),d=this.getDisplayedValueText(),c=a?`Find ${a}...`:"";return v("div",{className:"advanced-filter-creator-select-value",children:[v("div",{className:l?"form-group":"",children:[h("label",{htmlFor:"advanced-filter-creator-select-value-input",children:"Select Values"}),l&&h("input",{type:"text",className:K("form-control",{"is-invalid":t!=null}),id:"advanced-filter-creator-select-value-input",placeholder:c,value:i,onChange:this.handleSearchChange})]}),h(mm,{table:o,filters:e,invertSelection:n,selectedValues:s,formatter:r,onChange:this.handleListChange}),v("div",{className:"advanced-filter-creator-select-meta-row",children:[v("div",{children:[h(V,{kind:"ghost",onClick:this.handleSelectAllClick,children:"Select All"}),h(V,{kind:"ghost",onClick:this.handleClearAllClick,children:"Clear"})]}),h(Ht,{in:d!=null,timeout:250,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:"row-count-info",children:d})})]})]})}};let hd=pm;hd.searchDebounceTime=250;hd.defaultProps={invertSelection:!0,selectedValues:[],onChange:()=>{},showSearch:!0};const ro=ee.module("AdvancedFilterCreator"),Qs=class extends b.exports.PureComponent{constructor(t){super(t),this.getFilterTypes=ge(r=>N.getFilterTypes(r)),this.handleAddAnd=this.handleAddAnd.bind(this),this.handleAddOr=this.handleAddOr.bind(this),this.handleChangeFilterOperator=this.handleChangeFilterOperator.bind(this),this.handleDone=this.handleDone.bind(this),this.handleFilterChange=this.handleFilterChange.bind(this),this.handleFilterDelete=this.handleFilterDelete.bind(this),this.handleSelectValueChange=this.handleSelectValueChange.bind(this),this.handleReset=this.handleReset.bind(this),this.handleSortDown=this.handleSortDown.bind(this),this.handleSortUp=this.handleSortUp.bind(this),this.handleSubmit=this.handleSubmit.bind(this),this.handleFocusTrapStart=this.handleFocusTrapStart.bind(this),this.handleFocusTrapEnd=this.handleFocusTrapEnd.bind(this),this.handleUpdateTimeout=this.handleUpdateTimeout.bind(this),this.focusTrapContainer=de.createRef();const{options:e}=t;let{filterOperators:n,invertSelection:s,selectedValues:i}=e;const o=e.filterItems?.map(({selectedType:r,value:l})=>({selectedType:r,value:l,key:$e()}))??[];o.length===0&&o.push(Qs.makeFilterItem()),n==null&&(n=[]),s==null&&(s=!0),i==null&&(i=[]),this.state={filterItems:o,filterOperators:n,invertSelection:s,selectedValues:i,valuesTableError:null,valuesTable:void 0}}static makeFilterItem(){return{key:$e()}}componentDidMount(){this.initValuesTable()}componentWillUnmount(){this.debounceTimeout!=null&&(clearTimeout(this.debounceTimeout),this.sendUpdate()),this.valuesTablePromise!=null&&this.valuesTablePromise.cancel()}getFilterChangeHandler(t){return this.handleFilterChange.bind(this,t)}getFilterDeleteHandler(t){return this.handleFilterDelete.bind(this,t)}initValuesTable(){const{model:t,column:e}=this.props;if(!t.isValuesTableAvailable){ro.debug("No values table for this model, just ignore");return}this.valuesTablePromise=N.makeCancelableTablePromise(t.valuesTable(e)),this.valuesTablePromise.then(n=>{const s=n.columns[0].sort().asc();n.applySort([s]),this.setState({valuesTable:n})}).catch(n=>{ye.isCanceled(n)||(ro.error("Unable to open values table",n),this.setState({valuesTableError:n}))})}handleFocusTrapEnd(){(this.focusTrapContainer?.current?.querySelector("button,select,input,textarea")).focus()}handleFocusTrapStart(){const t=this.focusTrapContainer?.current?.querySelectorAll("button,select,input,textarea");t&&t.length>0&&t[t.length-1].focus()}handleAddAnd(){let{filterItems:t,filterOperators:e}=this.state;t=t.concat(Qs.makeFilterItem()),e=e.concat(zt.and),this.setState({filterItems:t,filterOperators:e})}handleAddOr(){let{filterItems:t,filterOperators:e}=this.state;t=t.concat(Qs.makeFilterItem()),e=e.concat(zt.or),this.setState({filterItems:t,filterOperators:e})}handleChangeFilterOperator(t,e){let{filterOperators:n}=this.state;n=[...n],HC(e),n[t]=e,this.setState({filterOperators:n}),this.startUpdateTimer()}handleFilterChange(t,e,n){let{filterItems:s}=this.state;s=[...s];const{key:i}=s[t];s[t]={key:i,selectedType:e,value:n},this.setState({filterItems:s}),this.startUpdateTimer()}handleFilterDelete(t){let{filterItems:e,filterOperators:n}=this.state;e=[...e],n=[...n],t<e.length&&e.splice(t,1),t<n.length?n.splice(t,1):t===n.length&&n.splice(n.length-1,1),e.length===0&&e.push(Qs.makeFilterItem()),this.setState({filterItems:e,filterOperators:n}),this.startUpdateTimer()}handleSelectValueChange(t,e){this.setState({selectedValues:t,invertSelection:e}),this.startUpdateTimer()}handleReset(){ro.debug("Resetting Advanced Filter"),this.setState({filterItems:[Qs.makeFilterItem()],filterOperators:[],selectedValues:[],invertSelection:!0}),this.startUpdateTimer()}handleSortDown(t){const e=Hn.isModifierKeyDown(t);this.sortTable(N.sortDirection.descending,e)}handleSortUp(t){const e=Hn.isModifierKeyDown(t);this.sortTable(N.sortDirection.ascending,e)}handleSubmit(t){ro.debug("Submitting Advanced Filter"),this.stopUpdateTimer(),this.sendUpdate(),t.preventDefault()}handleDone(t){ro.debug("Submitting and Closing Advanced Filter"),this.stopUpdateTimer(),this.sendUpdate();const{onDone:e}=this.props;e(),t.preventDefault()}handleUpdateTimeout(){this.debounceTimeout=void 0,this.sendUpdate()}shouldShowAddFilter(){const{filterItems:t}=this.state;if(t.length===0)return!1;const e=t[t.length-1],{selectedType:n,value:s}=e;return n!=null&&n.length>0&&s!=null&&s.length>0}sortTable(t,e=!1){const{column:n,onSortChange:s}=this.props;s(n,t,e)}startUpdateTimer(){this.stopUpdateTimer(),this.debounceTimeout=setTimeout(this.handleUpdateTimeout,Qs.debounceFilterUpdate)}stopUpdateTimer(){this.debounceTimeout!==void 0&&(clearTimeout(this.debounceTimeout),this.debounceTimeout=void 0)}sendUpdate(){const{filterItems:t,filterOperators:e,invertSelection:n,selectedValues:s}=this.state,{column:i,onFilterChange:o,model:r}=this.props,{formatter:l}=r,a=t.filter(({selectedType:m,value:p})=>m!=null&&p!=null&&p!==""),d=e.filter((m,p)=>m!=null&&t[p].selectedType!=null&&t[p].value!=null&&t[p].value!=="").slice(0,a.length-1),c={filterItems:a,filterOperators:d,invertSelection:n,selectedValues:s},u=N.makeAdvancedFilter(i,c,l.timeZone);o(i,u,c)}render(){const{column:t,model:e,sortDirection:n,formatter:s}=this.props,{filterItems:i,filterOperators:o,invertSelection:r,selectedValues:l,valuesTable:a,valuesTableError:d}=this.state,{isValuesTableAvailable:c}=e,u=N.isBooleanType(t.type),m=N.isDateType(t.type),p=this.getFilterTypes(t.type),g=t.type.substring(t.type.lastIndexOf(".")+1),f=[];if(!u&&p.length)for(let w=0;w<i.length;w+=1){const T=i[w],{key:y,selectedType:E,value:R}=T,F=h(cd,{column:t,filterTypes:p,onChange:this.getFilterChangeHandler(w),onDelete:this.getFilterDeleteHandler(w),selectedType:E,value:R,formatter:s},y);if(f.push(F),w<o.length){const _=o[w]===zt.and,H=v("div",{className:"form-row justify-content-end advanced-filter-creator-filter-operator",children:[h(V,{kind:"ghost",className:K("filter-operator",{active:_}),onClick:()=>this.handleChangeFilterOperator(w,zt.and),children:"AND"}),h(V,{kind:"ghost",className:K("filter-operator",{active:!_}),onClick:()=>this.handleChangeFilterOperator(w,zt.or),children:"OR"})]},`filterOperator${y}`);f.push(H)}}const C=this.shouldShowAddFilter(),S=v("div",{className:K("form-row justify-content-end add-filter-item",{hidden:!C}),children:[h("span",{className:"text-muted",children:h(J,{icon:As})}),h(V,{kind:"ghost",className:"btn-filter-item",onClick:this.handleAddAnd,disabled:!C,tooltip:"Add filter with AND",children:"AND"}),h(V,{kind:"ghost",className:"btn-filter-item",onClick:this.handleAddOr,disabled:!C,tooltip:"Add filter with OR",children:"OR"})]},"addFilterItem");return f.push(S),v("div",{className:"advanced-filter-creator",role:"presentation",children:[h("div",{tabIndex:0,onFocus:this.handleFocusTrapStart}),v("form",{onSubmit:this.handleSubmit,ref:this.focusTrapContainer,children:[v("div",{className:"title-bar",children:[h("h6",{className:"advanced-filter-title",children:"Advanced Filters"}),v("div",{className:"advanced-filter-menu-buttons",children:[h(V,{kind:"ghost",className:K("sort-operator",{active:n===N.sortDirection.descending}),onClick:this.handleSortDown,icon:qd,tooltip:`Sort ${t.name} Descending`}),h(V,{kind:"ghost",className:K("sort-operator",{active:n===N.sortDirection.ascending}),onClick:this.handleSortUp,icon:h(J,{icon:qd,rotation:180}),tooltip:`Sort ${t.name} Ascending`})]})]}),h("hr",{}),v("div",{className:"advanced-filter-column-name",children:[t.name,"\xA0",v("span",{className:"column-type",children:["(",g,")"]})]}),f,c&&d==null&&v(Se,{children:[!u&&h("hr",{}),h("div",{className:"form-group",children:h(hd,{table:a,onChange:this.handleSelectValueChange,invertSelection:r,selectedValues:l,formatter:s,showSearch:!m,timeZone:s.timeZone})})]}),v("div",{className:"form-row justify-content-end",children:[h(V,{kind:"secondary",className:"mr-2",onClick:this.handleReset,children:"Reset"}),h(V,{kind:"primary",onClick:this.handleDone,children:"Done"})]})]}),h("div",{tabIndex:0,onFocus:this.handleFocusTrapEnd})]})}};let ud=Qs;ud.debounceFilterUpdate=250;ud.defaultProps={options:{filterItems:null,filterOperators:null,invertSelection:!0,selectedValues:[]},sortDirection:null};const Ac=ee.module("Aggregations"),DT=[Oe.SUM,Oe.ABS_SUM,Oe.MIN,Oe.MAX,Oe.VAR,Oe.AVG,Oe.STD,Oe.FIRST,Oe.LAST,Oe.COUNT_DISTINCT,Oe.DISTINCT,Oe.COUNT,Oe.UNIQUE];function NT({isRollup:t,settings:e,onChange:n,onEdit:s}){const{aggregations:i,showOnTop:o}=e,r=b.exports.useMemo(()=>DT.filter(_=>!i.some(H=>H.operation===_)),[i]),[l,a]=b.exports.useState(r[0]),[d,c]=b.exports.useState([]),u=b.exports.useCallback(_=>{n({...e,..._})},[n,e]),m=b.exports.useCallback(_=>{u({aggregations:_})},[u]),p=b.exports.useCallback(_=>{u({showOnTop:_})},[u]),g=b.exports.useCallback(()=>{Ac.debug("handleDragStart"),qt.startDragging()},[]),f=b.exports.useCallback(({destination:_,source:H})=>{if(Ac.debug("handleDragEnd",_,H),qt.stopDragging(),_===null)return;let U=_.index;H.index<_.index&&(U+=1);const A=[...i],Y=qt.reorder(A,d,A,U),G=qt.adjustDestinationIndex(U,d),z=[[G,G+Y.length-1]];m(A),c(z)},[m,i,d,c]),C=b.exports.useCallback(_=>{a(_)},[a]),S=b.exports.useCallback(()=>{m([...i,{operation:l,selected:[],invert:!0}])},[i,l,m]),w=b.exports.useCallback(_=>{m(i.filter((H,U)=>U!==_))},[i,m]),T=b.exports.useCallback(_=>{c(_)},[c]),y=b.exports.useCallback(_=>{const H=i[_];_s.isRollupOperation(H.operation)||s(H)},[i,s]),E=b.exports.useCallback(_=>{p(_.target.value==="true")},[p]);b.exports.useEffect(function(){r.length>0&&!r.includes(l)&&a(r[0])},[r,l]);const R=b.exports.useCallback(({item:_,itemIndex:H,isClone:U=!1,selectedCount:A})=>{const Y=_.operation,G=U?`${A}`:void 0,z=U?"item-list-item-clone":void 0,x=_s.isRollupOperation(_.operation),L=!U&&!x;return v(Se,{children:[v("div",{className:K("item-list-item-content","draggable-item-list-item-content",z),children:[v("span",{className:"title",children:[Y,!t&&x&&v("span",{className:"small text-warning",children:[h(J,{icon:Eh})," Requires rollup"]})]}),Sn.renderBadge({text:G}),Sn.renderHandle()]}),!U&&v(Se,{children:[h(V,{kind:"ghost",className:"btn-edit",icon:Oo,tooltip:"Edit Columns",onClick:()=>s(_),disabled:!L}),h(V,{kind:"ghost",className:"btn-delete",icon:sn,tooltip:"Delete Aggregation",onClick:()=>w(H)})]})]})},[w,s,t]),F=r.length>0,D=i.length>0;return v("div",{className:"aggregations",children:[F&&v("div",{className:"form-inline",children:[h(kf,{onChange:C,value:l,children:r.map(_=>h(Mf,{value:_,children:_},_))}),v("button",{type:"button",className:"btn btn-link btn-add",onClick:S,children:[h(J,{icon:As}),"Add Aggregation"]})]}),F&&D&&h("hr",{}),D&&v(Se,{children:[!t&&v("div",{className:"form-inline",children:[h("label",{children:"Placement:\xA0"}),v(dl,{onChange:E,value:`${o}`,children:[h(is,{value:"true",children:"Top"}),h(is,{value:"false",children:"Bottom"})]})]}),h(Zr,{onDragStart:g,onDragEnd:f,children:h(Sn,{className:"selected-aggregations",itemCount:i.length,items:i,renderItem:R,offset:0,onSelectionChange:T,onSelect:y,selectedRanges:d,isMultiSelect:!0})})]})]})}const _T=30;function MT({aggregation:t,columns:e,onChange:n}){const[s,i]=b.exports.useState(-1),[o,r]=b.exports.useState(-1),[l,a]=b.exports.useState(0),{invert:d,selected:c}=t,u=b.exports.useRef(null),m=b.exports.useCallback(E=>c.includes(E)?!d:d,[d,c]),p=b.exports.useMemo(()=>{let E=dd(e,t.operation);return l!==0&&(E=N.sortColumns(E,l===1)),E},[e,t.operation,l]),g=b.exports.useMemo(()=>s>=0?p.slice(s,o+1).map(E=>({value:E.name,displayValue:E.name,isSelected:m(E.name)})):[],[p,m,o,s]),f=b.exports.useCallback(E=>{const{name:R}=p[E],F=c.indexOf(R);let D=[...c],_=d;F>=0?D.splice(F,1):(D.push(R),D.length===p.length&&(D=[],_=!d)),n({...t,selected:D,invert:_})},[t,d,p,c,n]),C=b.exports.useCallback(()=>{a(0),n({...t,selected:[],invert:!0})},[t,n]),S=b.exports.useCallback((E,R)=>{i(E),r(R)},[i,r]),w=b.exports.useCallback(()=>{c.length===0?n({...t,invert:!d}):n({...t,selected:[],invert:!0})},[t,d,n,c]),T=c.length===0?d:null,y=c.length!==0||!d||l!==0;return v("div",{role:"menu",className:"aggregation-edit",children:[h("div",{className:"top-menu",children:v("div",{className:"form-inline",children:[h(mn,{checked:T,onChange:w,children:"Toggle All"}),h("div",{className:"spacer"}),h(Ht,{in:y,timeout:Xe.transitionSlowMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:h(V,{kind:"ghost",className:"btn-reset",onClick:C,children:"Reset"})}),h(V,{kind:"ghost",className:K({active:l===1}),icon:Va,tooltip:"Sort ascending",onClick:()=>a(1)}),h(V,{kind:"ghost",className:K({active:l===2}),icon:Ba,tooltip:"Sort descending",onClick:()=>a(2)})]})}),h("div",{className:"aggregation-edit-item-list",children:h(ki,{itemCount:p.length,items:g,offset:s,renderItem:({item:E})=>h(mn,{checked:m(E.value),children:E.displayValue}),onSelect:f,onViewportChange:S,rowHeight:_T,focusSelector:"input",ref:u})})]})}function kT(t){return h("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...t,children:v("g",{fill:"none",fillRule:"evenodd",children:[h("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),h("path",{fill:"#7DA4FF",d:"M8 26h4v15H8zM15 17h4v24h-4zM22 21h4v20h-4zM29 17h4v24h-4zM36 11h4v30h-4z"})]})})}function xT(t){return h("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...t,children:v("g",{fill:"none",fillRule:"evenodd",children:[h("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),h("path",{fill:"#7DA4FF",d:"M7 34h4v8H7zM12 31h4v11h-4zM17 27h4v15h-4zM22 22h4v20h-4zM27 27h4v15h-4zM32 29h4v13h-4zM37 31h4v11h-4z"})]})})}function OT(t){return h("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...t,children:v("g",{fill:"none",fillRule:"evenodd",children:[h("path",{fill:"#C1C0C0",d:"M4 4h1v40H4zM44 43v1H5v-1z"}),h("path",{stroke:"#7DA4FF",d:"M7.984 32.44l7.982-11.378 5.273 3.739 9.952-10.838 2.826 1.894 7.45-5.802"}),h("path",{stroke:"#BECDEF",d:"M8.244 37.926L17 33.496l5 .87 10.637-10.35 10.615-1.381"})]})})}function AT(t){return h("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...t,children:v("g",{fill:"none",fillRule:"evenodd",children:[h("path",{d:"M24 10c7.732 0 14 6.268 14 14s-6.268 14-14 14-14-6.268-14-14h14V10z",fill:"#80A6FF"}),h("path",{d:"M10 24c0-7.732 6.268-14 14-14v14H10z",fill:"#C1C0C0"})]})})}function LT(t){return h("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...t,children:v("g",{fill:"none",fillRule:"evenodd",children:[h("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),h("path",{fill:"#939293",d:"M44 34v1H4v-1zM44 25v1H4v-1zM44 16v1H4v-1z"}),h("circle",{fill:"#7DA4FF",cx:9.5,cy:37.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:16.5,cy:30.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:22.5,cy:36.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:28.5,cy:30.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:15.5,cy:38.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:23.5,cy:25.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:19.5,cy:19.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:29.5,cy:19.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:32.5,cy:26.5,r:1.5}),h("circle",{fill:"#7DA4FF",cx:36.5,cy:13.5,r:1.5})]})})}function PT(t){return v("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:[h("rect",{width:"48",height:"48",fill:"none"}),h("rect",{x:"26",y:"10",width:"15",height:"4",fill:"#9FDE70"}),h("rect",{x:"26",y:"22",width:"15",height:"4",fill:"#9FDE70"}),h("rect",{x:"26",y:"28",width:"15",height:"4",fill:"#FFD95C"}),h("rect",{x:"26",y:"34",width:"15",height:"4",fill:"#9FDE70"})]})}function HT(t){return v("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:[h("rect",{width:"48",height:"48",fill:"none"}),h("rect",{x:"4",y:"16",width:"40",height:"4",fill:"#FFD95C"}),h("rect",{x:"4",y:"10",width:"40",height:"4",fill:"#78DCE8"}),h("rect",{x:"4",y:"34",width:"40",height:"4",fill:"#78DCE8"})]})}const Lc=ee.module("ChartBuilder"),pt=class extends b.exports.PureComponent{static getTypeName(t){switch(t){case I.plot.SeriesPlotStyle.LINE:return"Line";case I.plot.SeriesPlotStyle.BAR:return"Bar";case I.plot.SeriesPlotStyle.SCATTER:return"Scatter";case I.plot.SeriesPlotStyle.PIE:return"Pie";case I.plot.SeriesPlotStyle.HISTOGRAM:return"Histogram";default:return t}}static getTypeIcon(t){switch(t){case I.plot.SeriesPlotStyle.LINE:return h(OT,{});case I.plot.SeriesPlotStyle.BAR:return h(kT,{});case I.plot.SeriesPlotStyle.SCATTER:return h(LT,{});case I.plot.SeriesPlotStyle.PIE:return h(AT,{});case I.plot.SeriesPlotStyle.HISTOGRAM:return h(xT,{});default:return null}}static getMaxSeriesCount(t){switch(t){case I.plot.SeriesPlotStyle.PIE:return 1;case I.plot.SeriesPlotStyle.HISTOGRAM:return 0;default:return 100}}static getXAxisLabel(t){switch(t){case I.plot.SeriesPlotStyle.PIE:return"Labels";case I.plot.SeriesPlotStyle.HISTOGRAM:return"Data";default:return"X-Axis"}}static getSeriesLabel(t){switch(t){case I.plot.SeriesPlotStyle.PIE:return"Values";default:return"Series"}}static makeSeriesItem(t){return{id:$e.generate(),value:t}}static makeDefaultSeriesItems(t,e){if(pt.getMaxSeriesCount(t)===0||e==null||e.length===0)return[];const s=e.length>1?e[1].name:e[0].name;return[pt.makeSeriesItem(s)]}static getDefaultXAxis(t,e){return e!=null&&e.length>0?e[0].name:null}constructor(t){super(t),this.handleAddSeries=this.handleAddSeries.bind(this),this.handleLinkStateChange=this.handleLinkStateChange.bind(this),this.handleReset=this.handleReset.bind(this),this.handleSeriesChange=this.handleSeriesChange.bind(this),this.handleSeriesDeleteClick=this.handleSeriesDeleteClick.bind(this),this.handleSubmit=this.handleSubmit.bind(this),this.handleTypeClick=this.handleTypeClick.bind(this),this.handleXAxisChange=this.handleXAxisChange.bind(this),this.sendChange=this.sendChange.bind(this);const{model:e}=t,{columns:n}=e,s=pt.types[0],i=pt.getDefaultXAxis(s,n),o=pt.makeDefaultSeriesItems(s,n);this.state={type:s,seriesItems:o,xAxis:i,isLinked:!0}}handleAddSeries(){this.setState(t=>{const{seriesItems:e}=t,n=[...e],{model:s}=this.props,{columns:i}=s;return n.push({id:$e.generate(),value:i[0].name}),{seriesItems:n}},this.sendChange)}handleLinkStateChange(t){this.setState({isLinked:t.target.value==="true"},this.sendChange)}handleReset(){const{model:t}=this.props,{columns:e}=t,n=pt.types[0],s=pt.getDefaultXAxis(n,e),i=pt.makeDefaultSeriesItems(n,e),o=!0;this.setState({type:n,seriesItems:i,xAxis:s,isLinked:o},this.sendChange)}handleSeriesChange(t){const{value:e}=t.target,n=t.target.getAttribute("data-index"),s=parseInt(n,10);this.setState(i=>{let{seriesItems:o}=i;return o=[...o],o[s].value=e,{seriesItems:o}},this.sendChange)}handleSeriesDeleteClick(t){const n=t.target.getAttribute("data-index"),s=parseInt(n,10);this.setState(i=>{const{seriesItems:o}=i,r=[...o];return r.splice(s,1),{seriesItems:r}},this.sendChange)}handleSubmit(t){t.preventDefault();const{onSubmit:e}=this.props,{type:n,seriesItems:s,xAxis:i,isLinked:o}=this.state,r=s.map(l=>l.value);e({type:`${n}`,series:r,xAxis:i,isLinked:o})}handleTypeClick(t){const n=t.target.getAttribute("data-index"),s=parseInt(n,10),i=pt.types[s];Lc.debug2("handleTypeSelect",i),this.setState(o=>{const r=pt.getMaxSeriesCount(i);let{seriesItems:l}=o;if(l=l.slice(0,r),l.length===0&&r>0){const{model:a}=this.props,{columns:d}=a;l=pt.makeDefaultSeriesItems(i,d)}return{type:i,seriesItems:l}},this.sendChange)}handleXAxisChange(t){const e=t.target.value;Lc.debug2("x-axis change",e),this.setState({xAxis:e},this.sendChange)}sendChange(){const{onChange:t}=this.props,{isLinked:e,type:n,seriesItems:s,xAxis:i}=this.state,o=s.map(r=>r.value);t({type:n,series:o,xAxis:i,isLinked:e})}render(){const{model:t}=this.props,{columns:e}=t,{seriesItems:n,type:s,xAxis:i,isLinked:o}=this.state,r=pt.getMaxSeriesCount(s),l=pt.getXAxisLabel(s),a=pt.getSeriesLabel(s),d=n.length>0,c=n.length<r;return h("div",{className:"chart-builder",children:v("form",{onSubmit:this.handleSubmit,children:[v("div",{className:"form-row",children:[h("label",{children:"Select Chart Type"}),h("div",{className:"form-row",children:pt.types.map((u,m)=>{const p=u;return h("div",{className:"col col-chart-type",children:v("button",{type:"button",className:K("btn","btn-icon","btn-chart-type",{active:u===s}),"data-index":m,onClick:this.handleTypeClick,children:[pt.getTypeIcon(u),pt.getTypeName(u)]})},p)})})]}),h("hr",{}),v("div",{className:"form-row form-inline",children:[h("label",{className:"col-2 label-left",children:l}),h("select",{className:"form-control custom-select select-x-axis col",value:i,onChange:this.handleXAxisChange,children:e.map(u=>h("option",{value:u.name,children:u.name},u.name))})]}),d&&h("hr",{}),n.map((u,m)=>v("div",{className:"form-row form-inline form-series-item","data-testid":`form-series-item-${m}`,children:[h("label",{className:"col-2 label-left",children:m===0?a:""}),h("select",{className:"form-control custom-select select-series col",value:u.value,onChange:this.handleSeriesChange,"data-testid":`select-series-item-${m}`,"data-index":m,children:e.map(p=>h("option",{value:p.name,"data-index":m,children:p.name},p.name))}),n.length>1&&h(V,{kind:"ghost",className:"btn-delete-series ml-2 px-2","data-index":m,"data-testid":`delete-series-${m}`,onClick:this.handleSeriesDeleteClick,icon:sn,tooltip:"Delete"})]},u.id)),c&&v("div",{className:"form-row",children:[h("div",{className:"col-2"}),h(V,{kind:"ghost",className:"btn-add-series mt-1",onClick:this.handleAddSeries,icon:As,children:"Add Series"})]}),v("div",{className:"form-row chart-builder-link",children:[h("label",{className:"col-2 label-right",children:v("div",{className:"fa-md fa-layers",children:[h(J,{mask:La,icon:Mi,transform:"right-5 down-5"}),h(J,{icon:o?yh:Rg,transform:"grow-2 right-8 down-6"})]})}),v(dl,{onChange:this.handleLinkStateChange,value:`${o}`,children:[h(is,{value:"true",children:"Sync State"}),h(is,{value:"false",children:"Freeze State"})]})]}),v("div",{className:"form-row",children:[h("div",{className:"col-2 label-right"}),h("div",{className:"col chart-builder-link-info",children:o?"Charts with synced state will update to match any filters or user modifications applied to the parent table.":"Freeze State disconnects the chart state from the parent table. New filters or user modifications on the parent table will not be applied."})]}),v("div",{className:K("form-row","justify-content-end","my-3"),children:[h(V,{kind:"secondary",className:"btn-reset",onClick:this.handleReset,children:"Reset"}),h(V,{kind:"primary",type:"submit",className:"btn-submit",children:"Create"})]})]})})}};let gm=pt;gm.types=[I.plot.SeriesPlotStyle.LINE,I.plot.SeriesPlotStyle.BAR,I.plot.SeriesPlotStyle.SCATTER,I.plot.SeriesPlotStyle.PIE];class fm extends b.exports.Component{constructor(e){super(e),this.handleContentChanged=this.handleContentChanged.bind(this),this.handleEditorFocus=this.handleEditorFocus.bind(this),this.handleEditorBlur=this.handleEditorBlur.bind(this),this.handleContainerClick=this.handleContainerClick.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.state={isEditorFocused:!1,isEditorEmpty:!0},this.editorContainer=null}componentDidMount(){this.initEditor()}componentWillUnmount(){this.destroyEditor()}initEditor(){const{value:e,editorSettings:n}=this.props,s={copyWithSyntaxHighlighting:"false",fixedOverflowWidgets:!0,folding:!1,fontFamily:"Fira Mono",glyphMargin:!1,language:"groovyDB",lineDecorationsWidth:8,lineNumbers:"off",minimap:{enabled:!1},renderLineHighlight:"none",scrollbar:{arrowSize:0,horizontal:"hidden",horizontalScrollbarSize:0},scrollBeyondLastLine:!1,padding:{top:6,bottom:6},tabCompletion:"off",useTabStops:!0,value:e,wordWrap:"on",automaticLayout:!0,...n};if(!this.editorContainer)throw new Error("editorContainer is null");this.editor=os.create(this.editorContainer,s),this.editor.layout(),this.editor.getModel()?.updateOptions({tabSize:0}),this.editor.onKeyDown(this.handleKeyDown),this.editor.onDidChangeModelContent(this.handleContentChanged),this.editor.onDidFocusEditorText(this.handleEditorFocus),this.editor.onDidBlurEditorText(this.handleEditorBlur)}destroyEditor(){this.editor?.dispose(),this.editor=void 0}handleContentChanged(){const{onContentChanged:e}=this.props,n=this.editor?.getModel()?.getValue();n!==void 0&&this.setState({isEditorEmpty:n.length===0}),e(n)}handleEditorFocus(){this.setState({isEditorFocused:!0})}handleEditorBlur(){const e=this.editor?.getModel()?.getValue()??"";this.setState({isEditorEmpty:e.length===0,isEditorFocused:!1})}handleContainerClick(){const{isEditorFocused:e}=this.state;e||this.editor?.focus()}handleKeyDown(e){const{onTab:n,editorIndex:s}=this.props;e.code==="Tab"&&(e.stopPropagation(),e.preventDefault(),n(s,e.shiftKey))}render(){const{value:e,invalid:n}=this.props,{isEditorFocused:s,isEditorEmpty:i}=this.state;return v("div",{className:K("input-editor-wrapper",{focused:s,invalid:n}),role:"presentation",onClick:this.handleContainerClick,children:[h("div",{className:"editor-container",ref:o=>{this.editorContainer=o}}),i&&!e&&h("div",{className:"editor-placeholder text-muted",children:"Column Formula"})]})}}fm.defaultProps={value:"",onContentChanged:()=>{},editorSettings:{},editorIndex:0,onTab:()=>{},invalid:!1};const Pc=Object.freeze({NAME:"name",FORMULA:"formula"}),UT=()=>{};function VT({eventKey:t,name:e,inputIndex:n,formula:s,onChange:i,onDeleteColumn:o,onTabInEditor:r,invalid:l,isDuplicate:a}){const d=e===""||Vi.isValidColumnName(e),c=b.exports.useCallback(u=>{u!==void 0&&(u.replace(/(\r\n|\n|\r)/gm,""),i(t,Pc.FORMULA,u))},[i,t]);return h(gh,{draggableId:t,index:n,disableInteractiveElementBlocking:!0,children:(u,m)=>v("div",{className:K("draggable-container",{dragging:m.isDragging}),ref:u.innerRef,...u.draggableProps,children:[v("div",{className:"custom-column-input-container",children:[v("div",{className:"pb-3",children:[v("div",{className:"d-flex flex-row custom-column-name",children:[h("input",{className:K("form-control custom-column-input",{"is-invalid":l||!d||a}),placeholder:"Column Name",value:e,onChange:p=>{i(t,Pc.NAME,p.target.value)}}),h(V,{kind:"ghost",className:"ml-1 px-2",onClick:()=>{o(t)},icon:sn,tooltip:"Delete custom column"}),h(V,{kind:"ghost",className:"btn-drag-handle",onClick:UT,...u.dragHandleProps,icon:tl,tooltip:"Drag column to re-order"})]}),(!d||a)&&h("p",{className:"validate-label-error text-danger mb-0 mt-2 pl-1",children:d?"Duplicate name":"Invalid name"})]}),h(fm,{editorSettings:{language:"deephavenDb"},editorIndex:n,value:s,onContentChanged:c,onTab:r,invalid:l})]}),h("hr",{})]})})}const Zl=[];class Ce extends em{constructor(){super(),this.listenerCount=0}addEventListener(e,n,s){super.addEventListener(e,n,s),this.listenerCount+=1,this.listenerCount===1&&this.startListening()}removeEventListener(e,n,s){super.removeEventListener(e,n,s),this.listenerCount-=1,this.listenerCount===0&&this.stopListening()}startListening(){}stopListening(){}get originalColumns(){return this.columns}get layoutHints(){return null}get frontColumns(){return Zl}get backColumns(){return Zl}get frozenColumns(){return Zl}isColumnFrozen(e){return!1}get isFilterRequired(){return!1}get isReversible(){return!0}get isColumnStatisticsAvailable(){return!1}get description(){return""}get isCustomColumnsAvailable(){return!1}get isFormatColumnsAvailable(){return!1}get isExportAvailable(){return!1}get isValuesTableAvailable(){return!1}get isChartBuilderAvailable(){return!1}get isRollupAvailable(){return!1}get isSelectDistinctAvailable(){return!1}get isTotalsAvailable(){return!1}isFilterable(e){return!1}close(){}isRowMovable(){return!1}get isSeekRowAvailable(){return!1}}Ce.EVENT=Object.freeze({UPDATED:"UPDATED",FORMATTER_UPDATED:"FORMATTER_UPDATED",REQUEST_FAILED:"REQUEST_FAILED",COLUMNS_CHANGED:"COLUMNS_CHANGED",TABLE_CHANGED:"TABLE_CHANGED",FILTERS_CHANGED:"FILTERS_CHANGED",SORTS_CHANGED:"SORTS_CHANGED",DISCONNECT:"DISCONNECT",RECONNECT:"RECONNECT",TOTALS_UPDATED:"TOTALS_UPDATED",PENDING_DATA_UPDATED:"PENDING_DATA_UPDATED"});const Ei=class extends b.exports.Component{constructor(t){super(t),this.getInput=ge((e,n)=>e.find(s=>s.eventKey===n)),this.getInputIndex=ge((e,n)=>e.findIndex(s=>s.eventKey===n)),this.handleAddColumnClick=this.handleAddColumnClick.bind(this),this.handleSaveClick=this.handleSaveClick.bind(this),this.handleInputChange=this.handleInputChange.bind(this),this.handleDeleteColumn=this.handleDeleteColumn.bind(this),this.handleCustomColumnUpdated=this.handleCustomColumnUpdated.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.handleDragEnd=this.handleDragEnd.bind(this),this.resetRequestFailed=this.resetRequestFailed.bind(this),this.handleEditorTabNavigation=this.handleEditorTabNavigation.bind(this),this.state={inputs:[],isCustomColumnApplying:!1,errorMessage:null,hasRequestFailed:!1,isSuccessShowing:!1},this.container=null,this.successButtonTimer=null}static makeCustomColumnInputEventKey(){return $e.generate()}static createCustomColumnInput(){return{eventKey:$e.generate(),name:"",formula:""}}componentDidMount(){const{customColumns:t}=this.props;this.parseCustomColumns(t),this.startListening()}componentWillUnmount(){this.stopListening(),this.successButtonTimer&&clearTimeout(this.successButtonTimer)}resetErrorMessage(){this.setState({errorMessage:null})}startListening(){const{model:t}=this.props;t.addEventListener(Ce.EVENT.COLUMNS_CHANGED,this.handleCustomColumnUpdated),t.addEventListener(Ce.EVENT.UPDATED,this.handleCustomColumnUpdated),t.addEventListener(Ce.EVENT.REQUEST_FAILED,this.handleRequestFailed)}stopListening(){const{model:t}=this.props;t.removeEventListener(Ce.EVENT.COLUMNS_CHANGED,this.handleCustomColumnUpdated),t.removeEventListener(Ce.EVENT.UPDATED,this.handleCustomColumnUpdated),t.removeEventListener(Ce.EVENT.REQUEST_FAILED,this.handleRequestFailed)}parseCustomColumns(t){if(t.length>0){const e=t.map(n=>{const s=n.split(/=(.+)/,2);return{eventKey:Ei.makeCustomColumnInputEventKey(),name:s[0],formula:s[1]}});this.setState({inputs:e})}else this.setState({inputs:[Ei.createCustomColumnInput()]})}handleAddColumnClick(){const{inputs:t}=this.state,e=[...t];e.push(Ei.createCustomColumnInput()),this.setState({inputs:e})}handleDeleteColumn(t){const{inputs:e}=this.state,n=this.getInputIndex(e,t),s=[...e];s.splice(n,1),s.length===0&&s.push(Ei.createCustomColumnInput()),this.setState({inputs:s})}handleInputChange(t,e,n){const{inputs:s}=this.state,i=this.getInputIndex(s,t),r={...this.getInput(s,t)};r[e]=n;const l=[...s];l.splice(i,1,r),this.setState({inputs:l})}handleCustomColumnUpdated(){const{isCustomColumnApplying:t}=this.state;!t||this.setState({isCustomColumnApplying:!1,isSuccessShowing:!0},()=>{this.successButtonTimer=setTimeout(()=>this.setState({isSuccessShowing:!1}),Ei.SUCCESS_SHOW_DURATION)})}handleRequestFailed(t){const e=t,{isCustomColumnApplying:n}=this.state;!n||this.setState({isCustomColumnApplying:!1,errorMessage:v(Se,{children:[v("p",{children:[h(J,{icon:Os})," Failed to apply custom columns."]}),v("div",{className:"error-box",children:[e.detail.errorMessage,h("br",{}),"Table configuration:"," ",JSON.stringify(e.detail.configuration)]})]}),hasRequestFailed:!0})}handleDragEnd(t){if(qt.stopDragging(),!t.destination)return;const{inputs:e}=this.state,n=t.source.index,s=t.destination.index,i=[...e],o=e[n];i.splice(n,1),i.splice(s,0,o),this.setState({inputs:i})}handleEditorTabNavigation(t,e){const{inputs:n}=this.state;if(e){(this.container?.querySelectorAll(".btn-drag-handle")[t]).focus();return}if(t===n.length-1)this.container?.querySelector(".btn-add-column")?.focus();else{const s=t+1;(this.container?.querySelectorAll(".custom-column-input")[s]).focus()}}handleSaveClick(){const{onSave:t,customColumns:e}=this.props,{inputs:n,isCustomColumnApplying:s}=this.state;if(s)return;const i=[];n.forEach(o=>{const{name:r,formula:l}=o;r&&l&&i.push(`${r}=${l}`)}),this.resetErrorMessage(),this.setState({isCustomColumnApplying:i.length>0||e.length>0}),t(i)}resetRequestFailed(){this.setState(({hasRequestFailed:t})=>t?{hasRequestFailed:!1}:null)}renderInputs(){const{inputs:t,hasRequestFailed:e}=this.state,n=new Map;return t.forEach(({name:s})=>n.set(s,(n.get(s)??0)+1)),t.map((s,i)=>{const{eventKey:o,name:r,formula:l}=s,a=(n.get(r)??0)>1;return h(VT,{inputIndex:i,eventKey:o,name:r,formula:l,onChange:this.handleInputChange,onDeleteColumn:this.handleDeleteColumn,onTabInEditor:this.handleEditorTabNavigation,invalid:e,isDuplicate:a},o)})}renderSaveButton(){const{inputs:t,isCustomColumnApplying:e,isSuccessShowing:n}=this.state,s=t.length>1?"Save Columns":"Save Column",i=t.every(({name:l})=>l===""||Vi.isValidColumnName(l)),o=t.filter(({name:l})=>l!=="").map(({name:l})=>l),r=new Set(o).size===o.length;return v(V,{kind:n?"success":"primary",className:K("btn-apply",{"btn-spinner":e}),disabled:n||e||!i||!r,onClick:this.handleSaveClick,children:[e&&v("span",{children:[h(as,{}),h("span",{className:"btn-normal-content",children:"Applying"})]}),!n&&!e&&s,n&&v(Se,{children:[h(J,{icon:Pa})," Success"]})]})}render(){const{onCancel:t}=this.props,{errorMessage:e}=this.state;return v("div",{role:"presentation",className:"custom-column-builder-container",ref:n=>{this.container=n},onClick:this.resetRequestFailed,onFocus:this.resetRequestFailed,children:[h("hr",{}),h(Zr,{onDragStart:qt.startDragging,onDragEnd:this.handleDragEnd,children:h(Aa,{droppableId:"droppable-custom-columns",children:(n,s)=>v("div",{ref:n.innerRef,...n.droppableProps,className:K("droppable-container",{dragging:s.draggingFromThisWith}),children:[this.renderInputs(),n.placeholder]})})}),h("div",{className:"pt-1 px-3",children:h(V,{kind:"ghost",className:"btn-add-column",onClick:this.handleAddColumnClick,icon:As,children:"Add Another Column"})}),v("div",{className:"custom-column-builder-footer",children:[e&&h("div",{className:"error-message",children:e}),v("div",{className:"d-flex justify-content-end",children:[h(V,{kind:"secondary",className:"mr-2",onClick:t,children:"Cancel"}),this.renderSaveButton()]})]})]})}};let Cm=Ei;Cm.SUCCESS_SHOW_DURATION=750;var xe=(t=>(t.ADVANCED_SETTINGS="ADVANCED_SETTINGS",t.AGGREGATIONS="AGGREGATIONS",t.AGGREGATION_EDIT="AGGREGATIONS_EDIT",t.CHART_BUILDER="CHART_BUILDER",t.CUSTOM_COLUMN_BUILDER="CUSTOM_COLUMN_BUILDER",t.QUICK_FILTERS="QUICK_FILTERS",t.ROLLUP_ROWS="ROLLUP_ROWS",t.SEARCH_BAR="SEARCH_BAR",t.SELECT_DISTINCT="SELECT_DISTINCT",t.TABLE_EXPORTER="TABLE_EXPORTER",t.VISIBILITY_ORDERING_BUILDER="VISIBILITY_ORDERING_BUILDER",t.CONDITIONAL_FORMATTING="CONDITIONAL_FORMATTING",t.CONDITIONAL_FORMATTING_EDIT="CONDITIONAL_FORMATTING_EDIT",t.GOTO="GOTO",t))(xe||{});const lo=ee.module("RollupRows"),BT=150,ur="grouped-rollup-rows",mr="ungrouped-rollup-rows",gn=class extends b.exports.Component{constructor(t){super(t),this.search=Je(o=>{const r=this.getSortedUngroupedColumns(),l=[];let a=null;for(let d=0;d<r.length;d+=1)r[d].name.toLowerCase().includes(o.toLowerCase())&&(a==null&&(a=d),l.push([d,d]));k(a),this.setState({ungroupedSelectedRanges:l}),l.length>0&&this.ungroupedList.current&&this.ungroupedList.current.scrollToItem(a)},BT),this.getCachedUngroupedColumns=Ie((o,r)=>o.filter(l=>gn.isGroupable(l)&&r.find(a=>a===l.name)==null)),this.getCachedSortedColumns=Ie((o,r)=>r==null?[...o]:N.sortColumns(o,r===gn.SORT.ASCENDING)),this.handleDeleteClicked=this.handleDeleteClicked.bind(this),this.handleSearchChange=this.handleSearchChange.bind(this),this.handleUngroupedSelect=this.handleUngroupedSelect.bind(this),this.handleUngroupedSelectionChange=this.handleUngroupedSelectionChange.bind(this),this.handleDragStart=this.handleDragStart.bind(this),this.handleDragEnd=this.handleDragEnd.bind(this),this.handleGroupedSelectionChange=this.handleGroupedSelectionChange.bind(this),this.handleShowConstituentsChange=this.handleShowConstituentsChange.bind(this),this.handleShowNonAggregatedColumnsChange=this.handleShowNonAggregatedColumnsChange.bind(this),this.handleSortAscending=this.handleSortAscending.bind(this),this.handleSortDescending=this.handleSortDescending.bind(this),this.renderGroupedItem=this.renderGroupedItem.bind(this),this.ungroupedList=de.createRef(),this.groupedList=de.createRef();const{config:e}=t,{columns:n=[],showConstituents:s=!0,showNonAggregatedColumns:i=!0}=e??{};this.state={ungroupedSelectedRanges:[],columns:n,groupedSelectedRanges:[],searchFilter:"",showConstituents:s,showNonAggregatedColumns:i,dragSource:null,sort:null}}static renderColumn({item:t,isClone:e,selectedCount:n}){const s=t?.name,i=e!==void 0&&e?`${n}`:void 0,o=e!==void 0&&e?"item-list-item-clone":"";return Sn.renderTextItem({text:s,badgeText:i,className:o})}static addGroupings(t,e,n=t.length){if(e==null||e.length===0)return t;let s=n;const i=t.filter((o,r)=>e.includes(o)?(r<s&&(s-=1),!1):!0);return i.splice(s,0,...e),i}static isGroupable(t){return!N.isDecimalType(t.type)}componentDidUpdate(t,e){const{config:n}=this.props,{columns:s,showConstituents:i,showNonAggregatedColumns:o}=this.state;n!==t.config?this.updateFromConfig():(s!==e.columns||i!==e.showConstituents||o!==e.showNonAggregatedColumns)&&(n==null||s!==n.columns||i!==n.showConstituents||o!==n.showNonAggregatedColumns)&&this.sendChange()}componentWillUnmount(){this.search.cancel()}handleSearchChange(t){const e=t.target.value;if(this.setState({searchFilter:e}),!e){this.search.cancel(),this.resetSelection();return}this.search(e)}handleSortAscending(){this.setState(({sort:t})=>({sort:t===gn.SORT.ASCENDING?null:gn.SORT.ASCENDING}))}handleSortDescending(){this.setState(({sort:t})=>({sort:t===gn.SORT.DESCENDING?null:gn.SORT.DESCENDING}))}resetSelection(){this.setState({ungroupedSelectedRanges:[],groupedSelectedRanges:[]})}handleDragStart(t){lo.debug("handleDragStart",t),document.documentElement.classList.add("drag-pointer-events-none"),this.setState({dragSource:t.source})}handleDragEnd(t){lo.debug("handleDragEnd",t),document.documentElement.classList.remove("drag-pointer-events-none"),this.setState({dragSource:null});const{destination:e,source:n}=t;if(e==null||n==null)return;if(e.droppableId===mr){this.setState(({groupedSelectedRanges:o,columns:r})=>{const l=[...r];return qt.reorder(l,o,[],0),{columns:l,ungroupedSelectedRanges:[],groupedSelectedRanges:[]}});return}const s=n.droppableId===ur;let i=e.index;s&&n.index<e.index&&(i+=1),this.setState(({columns:o,ungroupedSelectedRanges:r,groupedSelectedRanges:l})=>{const a=[...o],d=s?a:this.getSortedUngroupedColumns().map(g=>g.name),c=s?l:r,u=qt.reorder(d,c,a,i),m=s?qt.adjustDestinationIndex(i,l):i,p=[[m,m+u.length-1]];return{columns:a,ungroupedSelectedRanges:[],groupedSelectedRanges:p}}),this.resetSelection()}handleUngroupedSelect(t){lo.debug("handleUngroupedSelect"),this.setState(({columns:e})=>({columns:gn.addGroupings(e,[this.getSortedUngroupedColumns()[t].name]),ungroupedSelectedRanges:[],groupedSelectedRanges:[]}))}handleUngroupedSelectionChange(t){lo.debug2("handleUngroupedSelectionChange",t),this.setState(({ungroupedSelectedRanges:e})=>t===e?null:{ungroupedSelectedRanges:t,groupedSelectedRanges:[]})}handleGroupedSelectionChange(t){lo.debug2("handleGroupedSelectedRanges",t),this.setState(({groupedSelectedRanges:e})=>t===e?null:{groupedSelectedRanges:t,ungroupedSelectedRanges:[]})}handleDeleteClicked(t){this.setState(({columns:e})=>{const n=e.slice();return n.splice(t,1),{columns:n}})}handleShowConstituentsChange(){this.setState(({showConstituents:t})=>({showConstituents:!t}))}handleShowNonAggregatedColumnsChange(){this.setState(({showNonAggregatedColumns:t})=>({showNonAggregatedColumns:!t}))}updateFromConfig(){const{config:t}=this.props,{columns:e=[],showConstituents:n=!0,showNonAggregatedColumns:s=!0}=t??{};this.setState({columns:e,showConstituents:n,showNonAggregatedColumns:s})}sendChange(){const{onChange:t}=this.props,{columns:e,showConstituents:n,showNonAggregatedColumns:s}=this.state;t({columns:e,showConstituents:n,showNonAggregatedColumns:s})}getUngroupedColumns(){const{model:t}=this.props,{columns:e}=this.state,{originalColumns:n}=t;return this.getCachedUngroupedColumns(n,e)}getSortedUngroupedColumns(){const{sort:t}=this.state,e=this.getUngroupedColumns();return this.getCachedSortedColumns(e,t)}renderGroupedItem({item:t,itemIndex:e,isClone:n,selectedCount:s}){const o=`${n!==void 0&&n?"":"\xA0\xA0".repeat(e)}${t}`,r=n!==void 0&&n?`${s}`:void 0,l=n!==void 0&&n?"item-list-item-clone":"";return v(Se,{children:[Sn.renderTextItem({text:o,badgeText:r,className:l}),(n===void 0||!n)&&h(V,{kind:"ghost",className:"btn btn-link btn-link-icon btn-delete-grouping float-right",onClick:()=>this.handleDeleteClicked(e),children:h(J,{icon:sn})})]})}render(){const{columns:t,dragSource:e,searchFilter:n,groupedSelectedRanges:s,ungroupedSelectedRanges:i,showConstituents:o,showNonAggregatedColumns:r,sort:l}=this.state,a=this.getSortedUngroupedColumns();let d=t.length*Sn.DEFAULT_ROW_HEIGHT;e?.droppableId===mr&&(d+=Sn.DEFAULT_ROW_HEIGHT);const c=a.length*Sn.DEFAULT_ROW_HEIGHT+10,u=Math.min(3*Sn.DEFAULT_ROW_HEIGHT,c);return h("div",{role:"menu",className:K("rollup-rows",{"is-dragging":e!=null}),tabIndex:0,children:v(Zr,{onDragEnd:this.handleDragEnd,onDragStart:this.handleDragStart,children:[v("div",{className:"rollup-rows-group-by",children:[h("div",{className:"section-title",children:"Group By"}),t.length===0&&h(Aa,{droppableId:"placeholder",children:(m,p)=>h("div",{className:K("placeholder","text-muted",{"is-dragging-from-this":p.draggingFromThisWith,"is-dragging-over":p.isDraggingOver,"is-dropping":p.draggingOverWith}),ref:m.innerRef,...m.droppableProps,children:"To create a rollup, drag columns from the list below and drop them into this area."})}),t.length>0&&h(Sn,{draggingItemClassName:"rollup-rows-dragging-grouped-item",draggablePrefix:ur,droppableId:ur,itemCount:t.length,items:t,offset:0,onSelectionChange:this.handleGroupedSelectionChange,ref:this.groupedList,renderItem:this.renderGroupedItem,selectedRanges:s,style:{height:d},isMultiSelect:!0})]}),v("div",{className:"rollup-rows-available-columns",children:[h("div",{className:"section-title",children:"Available Grouping Columns"}),v("div",{className:"top-menu",children:[h(Bi,{className:"w-100",value:n,matchCount:n?i.length:void 0,placeholder:"Find column...",onChange:this.handleSearchChange}),v(V,{kind:"ghost",className:K("btn-link btn-link-icon",{active:l===gn.SORT.ASCENDING}),onClick:this.handleSortAscending,children:[h(J,{icon:Va}),h(ut,{children:"Sort ascending"})]}),v(V,{kind:"ghost",className:K("btn-link btn-link-icon",{active:l===gn.SORT.DESCENDING}),onClick:this.handleSortDescending,children:[h(J,{icon:Ba}),h(ut,{children:"Sort descending"})]})]}),h(Sn,{className:"rollup-available-grouping-columns",draggablePrefix:mr,droppableId:mr,itemCount:a.length,items:a,renderItem:gn.renderColumn,offset:0,onSelect:this.handleUngroupedSelect,onSelectionChange:this.handleUngroupedSelectionChange,ref:this.ungroupedList,selectedRanges:i,style:{maxHeight:c,minHeight:u},isDropDisabled:e?.droppableId!==ur,isMultiSelect:!0}),v("div",{className:"bottom-menu",children:[h("div",{className:"label",children:"Show:"}),h(mn,{checked:o,onChange:this.handleShowConstituentsChange,children:"Constituents"}),h(mn,{checked:r,onChange:this.handleShowNonAggregatedColumnsChange,children:"Non-Aggregated Columns"})]})]})]})})}};let md=gn;md.SORT=Object.freeze({ASCENDING:"ASC",DESCENDING:"DESC"});md.defaultProps={config:null,onChange:()=>{}};const $T=ee.module("TableCsvExporter"),Ge=class extends b.exports.Component{static getDateString(){return I.i18n.DateTimeFormat.format(Ge.FILENAME_DATE_FORMAT,new Date)}constructor(t){super(t),this.handleDownloadClick=this.handleDownloadClick.bind(this),this.handleDownloadRowOptionChanged=this.handleDownloadRowOptionChanged.bind(this),this.handleCustomizedDownloadRowOptionChanged=this.handleCustomizedDownloadRowOptionChanged.bind(this),this.handleCustomizedDownloadRowsChanged=this.handleCustomizedDownloadRowsChanged.bind(this),this.handleIncludeColumnHeadersChanged=this.handleIncludeColumnHeadersChanged.bind(this),this.handleIncludeHiddenColumnsChanged=this.handleIncludeHiddenColumnsChanged.bind(this),this.handleUseUnformattedValuesChanged=this.handleUseUnformattedValuesChanged.bind(this);const{name:e}=t;this.state={fileName:`${e}-${Ge.getDateString()}.csv`,downloadRowOption:Ge.DOWNLOAD_ROW_OPTIONS.ALL_ROWS,customizedDownloadRowOption:Ge.CUSTOMIZED_ROWS_OPTIONS.FIRST,customizedDownloadRows:Ge.DEFAULT_DOWNLOAD_ROWS,includeColumnHeaders:!0,includeHiddenColumns:!1,useUnformattedValues:!1,errorMessage:null,id:$e.generate()}}getSnapshotRanges(){const{model:t,selectedRanges:e}=this.props,{downloadRowOption:n,customizedDownloadRowOption:s,customizedDownloadRows:i}=this.state,{rowCount:o,columnCount:r}=t;let l=[];switch(n){case Ge.DOWNLOAD_ROW_OPTIONS.ALL_ROWS:l.push(new ae(0,0,r-1,o-1));break;case Ge.DOWNLOAD_ROW_OPTIONS.SELECTED_ROWS:l=e.map(a=>({...a,startColumn:0,endColumn:r-1})).sort((a,d)=>a.startRow!=null&&d.startRow!=null?a.startRow-d.startRow:0);break;case Ge.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS:switch(s){case Ge.CUSTOMIZED_ROWS_OPTIONS.FIRST:l.push(new ae(0,0,r-1,Math.min(i-1,o-1)));break;case Ge.CUSTOMIZED_ROWS_OPTIONS.LAST:l.push(new ae(0,Math.max(0,o-i),r-1,o-1));break}break}return l}getModelRanges(t){const{userColumnWidths:e,movedColumns:n}=this.props,{includeHiddenColumns:s}=this.state,i=te.getHiddenColumns(e);let o=q.getModelRanges(t,n);if(!s&&i.length>0){const r=i.map(ae.makeColumn);o=ae.subtractRangesFromRanges(o,r)}return o}resetDownloadState(){this.setState({errorMessage:null})}async handleDownloadClick(){const{model:t,isDownloading:e,onDownloadStart:n,onDownload:s,onCancel:i}=this.props,{fileName:o,includeColumnHeaders:r,useUnformattedValues:l}=this.state;if(e){i();return}this.resetDownloadState();const a=this.getSnapshotRanges(),d=this.getModelRanges(a);if(this.validateOptionInput()){n();try{const c=await t.export(),u=c.setViewport(0,0);await u.getViewportData(),s(o,c,u,a,d,r,l)}catch(c){$T.error("CSV download failed",c),this.setState({errorMessage:v("p",{children:[h(J,{icon:Os})," ",`${c}`]})}),i()}}}handleDownloadRowOptionChanged(t){this.setState({downloadRowOption:t.target.value})}handleCustomizedDownloadRowOptionChanged(t){this.setState({customizedDownloadRowOption:t.target.value})}handleCustomizedDownloadRowsChanged(t){this.setState({customizedDownloadRows:parseInt(t.target.value,10)})}handleIncludeColumnHeadersChanged(){this.setState(({includeColumnHeaders:t})=>({includeColumnHeaders:!t}))}handleIncludeHiddenColumnsChanged(){this.setState(({includeHiddenColumns:t})=>({includeHiddenColumns:!t}))}handleUseUnformattedValuesChanged(){this.setState(({useUnformattedValues:t})=>({useUnformattedValues:!t}))}validateOptionInput(){const{selectedRanges:t}=this.props,{downloadRowOption:e,customizedDownloadRows:n}=this.state;return e===Ge.DOWNLOAD_ROW_OPTIONS.SELECTED_ROWS&&t.length===0?(this.setState({errorMessage:v("p",{children:[h(J,{icon:Os})," No rows selected. Please select some rows in the table."]})}),!1):e===Ge.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS&&n<=0?(this.setState({errorMessage:v("p",{children:[h(J,{icon:Os})," Number of rows to output must be greater than 0"]})}),!1):!0}render(){const{model:t,isDownloading:e,tableDownloadProgress:n,tableDownloadEstimatedTime:s,selectedRanges:i,tableDownloadStatus:o}=this.props,{fileName:r,downloadRowOption:l,customizedDownloadRowOption:a,customizedDownloadRows:d,includeColumnHeaders:c,includeHiddenColumns:u,useUnformattedValues:m,errorMessage:p,id:g}=this.state,{rowCount:f}=t;return v("div",{className:"table-csv-exporter",children:[h("div",{className:"section-title",children:"Download Rows"}),h("div",{className:"form-group",children:v(dl,{onChange:this.handleDownloadRowOptionChanged,value:l,disabled:e,children:[v(is,{value:Ge.DOWNLOAD_ROW_OPTIONS.ALL_ROWS,"data-testid":"radio-csv-exporter-download-all",children:["All Rows",h("span",{className:"text-muted ml-2",children:`(${f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")} rows)`})]}),v(is,{value:Ge.DOWNLOAD_ROW_OPTIONS.SELECTED_ROWS,"data-testid":"radio-csv-exporter-only-selected",children:["Only Selected Rows",h("span",{className:"text-muted ml-2",children:i.length>0?`(${ae.rowCount(i).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")} rows)`:null})]}),h(is,{value:Ge.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS,"data-testid":"radio-csv-exporter-customized-rows",children:v("div",{className:"radio-input-row",role:"presentation",onClick:()=>{this.setState({downloadRowOption:Ge.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS})},children:[v("select",{value:a,"data-testid":"select-csv-exporter-customized-rows",className:"custom-select",disabled:e,onChange:this.handleCustomizedDownloadRowOptionChanged,children:[h("option",{value:"FIRST",children:"First"}),h("option",{value:"LAST",children:"Last"})]}),h("input",{type:"number",className:"form-control",id:`customizedRows-${g}`,"data-testid":"input-csv-exporter-customized-rows",name:`customizedRows-${g}`,placeholder:"100",value:d,disabled:e,onChange:this.handleCustomizedDownloadRowsChanged}),h("div",{children:"Rows"})]})})]})}),v("div",{className:"form-group",children:[h("label",{htmlFor:`customizedRows-${g}`,children:"File Name"}),h("input",{type:"text",className:"form-control",id:`filename-${g}`,"data-testid":"input-csv-exporter-file-name",name:`filename-${g}`,value:r,onChange:C=>{this.setState({fileName:C.target.value})},disabled:e})]}),v("div",{className:"checkbox-options",children:[h(mn,{checked:c,onChange:this.handleIncludeColumnHeadersChanged,children:"Include column headers"}),h(mn,{checked:u,onChange:this.handleIncludeHiddenColumnsChanged,children:"Include hidden columns"}),h(mn,{checked:m,onChange:this.handleUseUnformattedValuesChanged,children:"Use unformatted values"})]}),v("div",{className:"section-footer flex-column",children:[p!=null&&h("div",{className:"error-message",children:p}),o&&v("div",{className:"download-status",children:[(o===Ge.DOWNLOAD_STATUS.DOWNLOADING||o===Ge.DOWNLOAD_STATUS.INITIATING)&&v(Se,{children:[o===Ge.DOWNLOAD_STATUS.INITIATING&&h("div",{className:"text-muted",children:"Starting Download..."}),o===Ge.DOWNLOAD_STATUS.DOWNLOADING&&v("div",{className:"text-muted d-flex justify-content-between",children:[h("span",{children:s||s===0?`Estimated time: ${Qr.formatElapsedTime(s)}`:null}),h("span",{children:`${n}%`})]})]}),o===Ge.DOWNLOAD_STATUS.FINISHED&&h("div",{className:"text-muted text-right",children:"Download Completed"}),o===Ge.DOWNLOAD_STATUS.CANCELED&&h("div",{className:"text-muted",children:"Download Canceled"}),(o===Ge.DOWNLOAD_STATUS.DOWNLOADING||o===Ge.DOWNLOAD_STATUS.INITIATING)&&h("div",{className:"progress",children:h("div",{className:"progress-bar progress-bar-striped progress-bar-animated",style:{width:`${n}%`}})}),o===Ge.DOWNLOAD_STATUS.FINISHED&&h("div",{className:"progress",children:h("div",{className:"progress-bar bg-success",style:{width:`${n}%`}})})]}),v(V,{kind:"primary","data-testid":"btn-csv-exporter-download",className:K("btn-downloading",{"btn-spinner btn-cancelable":e}),onClick:this.handleDownloadClick,children:[e&&v("span",{children:[h(as,{}),h("span",{className:"btn-normal-content",children:"Downloading"}),h("span",{className:"btn-hover-content",children:"Cancel"})]}),!e&&"Download"]})]})]})}};let Qt=Ge;Qt.FILENAME_DATE_FORMAT="yyyy-MM-dd-HHmmss";Qt.DOWNLOAD_STATUS={INITIATING:"INITIATING",DOWNLOADING:"DOWNLOADING",FINISHED:"FINISHED",CANCELED:"CANCELED"};Qt.DOWNLOAD_ROW_OPTIONS={ALL_ROWS:"ALL_ROWS",SELECTED_ROWS:"SELECTED_ROWS",CUSTOMIZED_ROWS:"CUSTOMIZED_ROWS"};Qt.CUSTOMIZED_ROWS_OPTIONS={FIRST:"FIRST",LAST:"LAST"};Qt.DEFAULT_DOWNLOAD_ROWS=100;Qt.defaultProps={onDownloadStart:()=>{},isDownloading:!1,tableDownloadStatus:"",tableDownloadProgress:0,tableDownloadEstimatedTime:null,selectedRanges:[]};const Yn=ee.module("TableSaver"),GT="yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS z";function WT(t){return t.added!==void 0}function zT(t){if(!WT(t))throw new Error("event is not UpdateEventData")}const Rs=class extends b.exports.PureComponent{constructor(t){super(t),this.WritableStream=window.WritableStream??Ud,this.getCachedCustomColumnFormatFlag=Jt(rs.isCustomColumnFormatDefined,{max:1e4}),this.handlePortMessage=this.handlePortMessage.bind(this),this.handleSnapshotResolved=this.handleSnapshotResolved.bind(this),this.handleDownloadTimeout=this.handleDownloadTimeout.bind(this),this.state={},this.gridRanges=[],this.gridRangeCounter=0,this.rangedSnapshotsTotal=[],this.rangedSnapshotCounter=0,this.includeColumnHeaders=!0,this.useUnformattedValues=!1,this.snapshotsTotal=0,this.snapshotCounter=0,this.snapshotsBuffer=new Map,this.currentSnapshotIndex=0,this.snapshotPending=0,this.cancelableSnapshots=[],this.WritableStream=window.WritableStream??Ud,this.iframes=[],this.useBlobFallback=!1}static csvEscapeString(t){return`"${t.replace(/"/g,'""')}"`}componentDidMount(){const{getDownloadWorker:t}=this.props;t().then(e=>{Yn.info("found active service worker"),this.sw=e,this.sw.postMessage("ping")}).catch(e=>{Yn.warn("Download csv is not optimized.",e),this.useBlobFallback=!0})}componentWillUnmount(){this.iframes.length>0&&this.iframes.forEach(t=>{t.remove()}),this.streamTimeout&&clearTimeout(this.streamTimeout),this.snapshotHandlerTimeout&&clearTimeout(this.snapshotHandlerTimeout)}createWriterStream(t){const e=this.useBlobFallback,n=[];let s=null;e&&(s=TextEncoder.prototype.encode.bind(new TextEncoder));const{fileName:i}=this,o={};return e?(o.write=r=>{k(s),r.header!==void 0&&n.push(s(r.header)),r.rows!==void 0&&n.push(s(r.rows))},o.close=()=>{k(i);const r=new Blob(n,{type:"application/octet-stream; charset=utf-8"}),l=document.createElement("a");l.href=URL.createObjectURL(r),l.download=i,l.click()},o.abort=()=>{t.postMessage({cancel:!0}),t.close()}):(o.write=r=>{t.postMessage(r)},o.close=()=>{t.postMessage({end:!0}),t.close()},o.abort=()=>{t.postMessage({cancel:!0}),t.close()}),new this.WritableStream(o)}startDownload(t,e,n,s,i,o,r){const{isDownloading:l}=this.props;if(l)return;this.downloadStartTime=Date.now(),Yn.info(`start downloading ${t}`),this.table=e,this.columns=te.columnsFromRanges(i,e.columns),this.tableSubscription=n,this.gridRanges=s,this.includeColumnHeaders=o,this.useUnformattedValues=r;const a=encodeURIComponent(t.replace(/\//g,":")).replace(/['()]/g,escape).replace(/\*/g,"%2A"),d=new MessageChannel;if(this.port=d.port1,this.fileName=t,this.fileWriter=this.createWriterStream(this.port).getWriter(),this.useBlobFallback){this.writeCsvTable(o);return}this.sw&&this.sw.postMessage({encodedFileName:a},[d.port2]),this.port.onmessage=this.handlePortMessage}finishDownload(){this.table&&this.table.close(),this.tableSubscription&&this.tableSubscription.close(),this.fileWriter&&this.fileWriter.close();const{onDownloadCompleted:t}=this.props;t(),this.resetTableSaver(),this.downloadStartTime!==void 0&&Yn.info(`download finished, total elapsed time ${(Date.now()-this.downloadStartTime)/1e3} seconds`)}cancelDownload(){this.table&&this.table.close(),this.tableSubscription&&this.tableSubscription.close(),this.fileWriter&&this.fileWriter.abort(),this.cancelableSnapshots.forEach(e=>{e&&(e.catch(()=>null),e.cancel())});const{onDownloadCanceled:t}=this.props;t(),this.resetTableSaver()}resetTableSaver(){this.table=void 0,this.tableSubscription=void 0,this.columns=void 0,this.chunkRows=void 0,this.gridRanges=[],this.gridRangeCounter=0,this.rangedSnapshotsTotal=[],this.rangedSnapshotCounter=0,this.includeColumnHeaders=!0,this.useUnformattedValues=!1,this.snapshotsTotal=0,this.snapshotCounter=0,this.snapshotsBuffer=new Map,this.currentSnapshotIndex=0,this.snapshotPending=0,this.cancelableSnapshots=[],this.streamTimeout!=null&&clearTimeout(this.streamTimeout),this.snapshotHandlerTimeout!=null&&clearTimeout(this.snapshotHandlerTimeout),this.streamTimeout=void 0,this.snapshotHandlerTimeout=void 0}handleDownloadTimeout(){Yn.info("download canceled"),this.cancelDownload()}writeTableHeader(){let t="";if(this.columns)for(let e=0;e<this.columns.length;e+=1)t+=this.columns[e].name,t+=e===this.columns.length-1?`
21
21
  `:",";this.fileWriter?.write({header:t}).then(()=>null)}startWriteTableBody(){this.columns&&this.gridRanges!=null&&(this.chunkRows=Math.floor(Rs.DOWNLOAD_CELL_CHUNK/this.columns.length),this.rangedSnapshotsTotal=this.gridRanges.map(t=>(k(t.endRow),k(t.startRow),k(this.chunkRows),Math.ceil((t.endRow-t.startRow+1)/this.chunkRows))),this.snapshotsTotal=this.rangedSnapshotsTotal.reduce((t,e)=>t+e),Yn.info("start writing table, total snapshots: ",this.snapshotsTotal),this.makeSnapshot(Math.min(Rs.SNAPSHOT_BUFFER_SIZE,this.snapshotsTotal)))}writeCsvTable(t){t&&this.writeTableHeader(),this.startWriteTableBody()}writeSnapshot(t,e,n){if(this.currentSnapshotIndex===t&&this.fileWriter){for(;this.snapshotsBuffer.has(this.currentSnapshotIndex);){const s=this.snapshotsBuffer.get(this.currentSnapshotIndex);k(s),this.fileWriter.write({rows:this.convertSnapshotIntoCsv(s)}),this.snapshotsBuffer.delete(this.currentSnapshotIndex),this.currentSnapshotIndex+=1,this.updateDownloadProgress(t)}if(this.snapshotsTotal&&this.currentSnapshotIndex>=this.snapshotsTotal){this.finishDownload();return}}this.snapshotCounter&&this.snapshotsTotal&&this.snapshotCounter<this.snapshotsTotal&&(Yn.debug2(`
@@ -34,9 +34,9 @@ ${l} does not exist yet.`}if(i){const{widgetName:r}=this.props;return`${r} is un
34
34
  ${Nr.makeCirclePath(s,i,ih)}
35
35
  ${Nr.makeCirclePath(o,r,ih)}`,R=`link-select-clip-${l}`,F=Math.atan2(r-T,o-w),D=F-sh+Math.PI,_=F+sh+Math.PI,H=o+Math.cos(F)*nh,U=r+Math.sin(F)*nh,A=H+Math.cos(D)*wr,Y=U+Math.sin(D)*wr,G=H+Math.cos(_)*wr,z=U+Math.sin(_)*wr,x=`${H},${U} ${A},${Y} ${G},${z}`,L=.25*s+.5*w+.25*o,P=.25*i+.5*T+.25*r,Z=w-s+(o-w),B=(T-i+(r-T))/Z;let X=20/Math.sqrt(1+B**2),se=X*B,ce=X*-1,Q=se*-1;Number.isFinite(B)?B>0?(X*=-1,se*=-1,ce*=-1,Q*=-1,ce-=50-10*(Math.abs(u)%ys),Q+=10*(Math.abs(u)%ys),X-=50-10*(Math.abs(u)%ys),se+=10*(Math.abs(u)%ys)):B<0?(ce+=10*(Math.abs(u)%ys),Q+=10*(Math.abs(u)%ys),X+=10*(Math.abs(u)%ys),se+=10*(Math.abs(u)%ys)):(ce=15,Q=10,X=-25,se=10):(ce=10,Q=5,X=10,se=-35);let he="";return e!==void 0&&(e==="startsWith"?he="a*":e==="endsWith"?he="*z":he=N.getFilterOperatorString(e)),v(Se,{children:[v("svg",{className:K(t,{hovering:d}),children:[h("clipPath",{id:R,children:h("path",{d:E,clipRule:"evenodd"})}),h("path",{className:"link-select",d:y,onClick:this.handleClick,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,clipPath:`url(#${R})`}),h("path",{className:"link-background",d:y}),h("path",{className:"link-foreground",d:y}),h("circle",{className:"link-dot",cx:s,cy:i,r:"5"}),h("polygon",{className:"link-triangle",points:x})]}),a!=null&&n&&v(Se,{children:[h(V,{kind:"primary",className:"btn-fab btn-operator",style:{top:P+(B>=0?se:Q),left:L+(B>=0?X:ce)},onClick:()=>{},icon:v("div",{className:"fa-md fa-layers",children:[h("b",{children:he}),h(J,{icon:ts,transform:"right-8 down-9 shrink-5"})]}),tooltip:"Change comparison operator",children:h(ns,{actions:this.getDropdownActions,popperOptions:{placement:"bottom-start"}})}),h(V,{kind:"primary",className:"btn-fab btn-delete",style:{top:P+(B<0?se:Q),left:L+(B<0?X:ce)},onClick:this.handleDelete,icon:sn,tooltip:"Delete"})]})]})}};let jm=Nr;jm.defaultProps={className:"",isSelected:!1,onClick(){},onDelete(){}};const sa=ee.module("LinkerOverlayContent");class Zm extends b.exports.Component{constructor(e){super(e),this.handleBlur=this.handleBlur.bind(this),this.handleResize=this.handleResize.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleKeyUp=this.handleKeyUp.bind(this),this.handleEscapePressed=this.handleEscapePressed.bind(this),this.handleOperatorChanged=this.handleOperatorChanged.bind(this),this.dialogRef=de.createRef(),this.state={mouse:void 0,dialog:void 0,offset:{x:0,y:0},isDragging:!1,mode:"select"}}componentDidMount(){window.addEventListener("blur",this.handleBlur,!0),window.addEventListener("mousemove",this.handleMouseMove,!0),window.addEventListener("mouseup",this.handleMouseUp,!0),window.addEventListener("keydown",this.handleKeyDown,!0),window.addEventListener("keyup",this.handleKeyUp,!0),window.addEventListener("resize",this.handleResize,!0)}componentDidCatch(e,n){sa.error("componentDidCatch",e,n)}componentWillUnmount(){window.removeEventListener("blur",this.handleBlur,!0),window.removeEventListener("mousemove",this.handleMouseMove,!0),window.removeEventListener("mouseup",this.handleMouseUp,!0),window.removeEventListener("keydown",this.handleKeyDown,!0),window.removeEventListener("keyup",this.handleKeyUp,!0),window.removeEventListener("resize",this.handleResize,!0)}getPointFromLinkPoint(e){const{panelManager:n}=this.props,{panelId:s,columnName:i}=e,o=n.getOpenedPanelById(s);if(o!=null){if(!qm(o))throw new Error(`Panel does not have getCoordinateForColumn method: ${s}`);try{const l=o.getCoordinateForColumn(i);if(l!=null)return l}catch{sa.error("Could not get coordinate for column",i,o)}}const r=n.getContainerByPanelId(s);if(r==null)throw new Error(`Unable to find panel container for id: ${s}`);return ie.getTabPoint(r)}handleOperatorChanged(e,n){const{links:s,onLinksUpdated:i}=this.props,o=s.map(r=>r.id===e?{...r,operator:n}:r);i(o)}handleBlur(){this.setState({mode:"select"})}handleResize(){const{dialog:e}=this.state;if(e&&this.dialogRef.current){const n=this.dialogRef.current.getBoundingClientRect(),s=Qe(e.x,0,window.innerWidth-n.width),i=Qe(e.y,0,window.innerHeight-n.height);this.setState({dialog:{x:s,y:i}})}}handleMouseMove(e){const{offset:n,isDragging:s}=this.state;if(this.setState({mouse:{x:e.clientX,y:e.clientY}}),s&&this.dialogRef.current){const i=this.dialogRef.current.getBoundingClientRect(),o=Qe(window.innerWidth-(e.clientX+i.width+n.x),0,window.innerWidth-i.width),r=Qe(window.innerHeight-(e.clientY+i.height+n.y),0,window.innerHeight-i.height);this.setState({dialog:{x:o,y:r}})}}handleMouseDown(e){const n={x:0,y:0};if(this.dialogRef.current){const s=this.dialogRef.current.getBoundingClientRect();n.x=s.right-(s.width+e.clientX),n.y=s.bottom-(s.height+e.clientY)}this.setState({isDragging:!0,offset:n})}handleMouseUp(){this.setState({isDragging:!1})}handleKeyDown(e){if(e.key==="Alt")e.preventDefault(),this.setState({mode:"delete"});else if(e.key==="Delete"||e.key==="Backspace"){const{selectedIds:n,onLinkDeleted:s}=this.props;e.preventDefault(),n.forEach(i=>s(i))}}handleKeyUp(e){e.key==="Alt"&&(e.preventDefault(),this.setState({mode:"select"}))}handleEscapePressed(){const{onCancel:e}=this.props;e()}render(){const{disabled:e,links:n,selectedIds:s,messageText:i,onLinkSelected:o,onLinkDeleted:r,onAllLinksDeleted:l,onDone:a}=this.props,{mouse:d,dialog:c,isDragging:u,mode:m}=this.state,p=n.map(g=>{try{const{id:f,type:C,isReversed:S,start:w,end:T,operator:y}=g,E=w.columnType;let[R,F]=this.getPointFromLinkPoint(w),D=d?.x??R,_=d?.y??F;if(T!=null&&([D,_]=this.getPointFromLinkPoint(T)),S!=null&&S){const[U,A]=[R,F];[R,F]=[D,_],[D,_]=[U,A]}const H=K("linker-link",{disabled:e},{"link-filter-source":C==="filterSource"},{"link-invalid":C==="invalid"},{interactive:g.end==null},{"link-is-selected":s.has(f)},{"danger-delete":m==="delete"});return{x1:R,y1:F,x2:D,y2:_,id:f,className:H,operator:y,startColumnType:E}}catch(f){return sa.warn("Unable to get point for link",g,f),null}}).filter(g=>g!=null);return v("div",{className:K("linker-overlay",{"danger-delete":m==="delete"}),children:[p.map(({x1:g,y1:f,x2:C,y2:S,id:w,className:T,operator:y,startColumnType:E})=>h(jm,{className:T,id:w,x1:g,y1:f,x2:C,y2:S,onClick:o,onDelete:r,isSelected:s.has(w),operator:y,startColumnType:E,onOperatorChanged:this.handleOperatorChanged},w)),v("div",{className:K("linker-toast-dialog",{dragging:u}),ref:this.dialogRef,style:{bottom:c?.y,right:c?.x},children:[h(V,{draggable:!0,kind:"inline",className:"btn-drag-handle",icon:tl,onClick:()=>{},onMouseDown:this.handleMouseDown,children:!u&&h(ut,{children:"Drag to reposition"})}),h("div",{className:"toast-body",children:i}),v("div",{className:"toast-footer",children:[h(V,{kind:"secondary",onClick:l,children:"Clear All"}),h(V,{kind:"primary",onClick:a,children:"Done"})]})]}),h(le,{actions:[{action:this.handleEscapePressed,shortcut:ls.LINKER_CLOSE,isGlobal:!0}]})]})}}Zm.defaultProps={disabled:"false"};const Dt=ee.module("Linker"),gy=(t,e)=>({activeTool:gl(t),isolatedLinkerPanelId:Td(t,e.localDashboardId),links:Ki(t,e.localDashboardId),timeZone:Ao(t)}),fy=vt(gy,{setActiveTool:Cl,setDashboardLinks:Ed,addDashboardLinks:wE,deleteDashboardLinks:TE,setDashboardIsolatedLinkerPanelId:Pm,setDashboardColumnSelectionValidator:vE});class Cy extends b.exports.Component{constructor(e){super(e),this.getCachedLinks=ge((n,s,i)=>{const o=[...n];return s!=null&&s.start!=null&&o.push(s),i!==void 0?o.filter(r=>r?.start?.panelId===i||r?.end?.panelId===i||r?.end==null):o}),this.handleCancel=this.handleCancel.bind(this),this.handleDone=this.handleDone.bind(this),this.handlePanelCloned=this.handlePanelCloned.bind(this),this.handleFilterColumnSelect=this.handleFilterColumnSelect.bind(this),this.handleColumnsChanged=this.handleColumnsChanged.bind(this),this.handlePanelClosed=this.handlePanelClosed.bind(this),this.handleLayoutStateChanged=this.handleLayoutStateChanged.bind(this),this.handleAllLinksDeleted=this.handleAllLinksDeleted.bind(this),this.handleLinkDeleted=this.handleLinkDeleted.bind(this),this.handleLinksUpdated=this.handleLinksUpdated.bind(this),this.handleChartColumnSelect=this.handleChartColumnSelect.bind(this),this.handleGridColumnSelect=this.handleGridColumnSelect.bind(this),this.handleUpdateValues=this.handleUpdateValues.bind(this),this.handleStateChange=this.handleStateChange.bind(this),this.handleExited=this.handleExited.bind(this),this.handleLinkSelected=this.handleLinkSelected.bind(this),this.handlePanelDragging=this.handlePanelDragging.bind(this),this.handlePanelDropped=this.handlePanelDropped.bind(this),this.isColumnSelectionValid=this.isColumnSelectionValid.bind(this),this.state={linkInProgress:void 0,selectedIds:new Set,isDraggingPanel:!1}}componentDidMount(){const{layout:e}=this.props;this.startListening(e),this.updateSelectionValidators()}componentDidUpdate(e){const{activeTool:n,layout:s}=this.props;s!==e.layout&&(this.stopListening(e.layout),this.startListening(s)),n!==e.activeTool&&(this.updateSelectionValidators(),n===Wt.DEFAULT&&this.reset())}componentDidCatch(e,n){Dt.error("componentDidCatch",e,n)}componentWillUnmount(){const{layout:e}=this.props;this.stopListening(e)}startListening(e){e.on("stateChanged",this.handleLayoutStateChanged);const{eventHub:n}=e;n.on(wt.COLUMN_SELECTED,this.handleGridColumnSelect),n.on(wt.DATA_SELECTED,this.handleUpdateValues),n.on(wt.STATE_CHANGED,this.handleStateChange),n.on(Li.COLUMN_SELECTED,this.handleChartColumnSelect),n.on(Ee.CLONED,this.handlePanelCloned),n.on(Le.COLUMN_SELECTED,this.handleFilterColumnSelect),n.on(Le.COLUMNS_CHANGED,this.handleColumnsChanged),n.on(Ee.CLOSE,this.handlePanelClosed),n.on(Ee.CLOSED,this.handlePanelClosed),n.on(Ee.DRAGGING,this.handlePanelDragging),n.on(Ee.DROPPED,this.handlePanelDropped)}stopListening(e){e.off("stateChanged",this.handleLayoutStateChanged);const{eventHub:n}=e;n.off(wt.COLUMN_SELECTED,this.handleGridColumnSelect),n.off(wt.DATA_SELECTED,this.handleUpdateValues),n.off(wt.STATE_CHANGED,this.handleStateChange),n.off(Li.COLUMN_SELECTED,this.handleChartColumnSelect),n.off(Ee.CLONED,this.handlePanelCloned),n.off(Le.COLUMN_SELECTED,this.handleFilterColumnSelect),n.off(Le.COLUMNS_CHANGED,this.handleColumnsChanged),n.off(Ee.CLOSE,this.handlePanelClosed),n.off(Ee.CLOSED,this.handlePanelClosed),n.off(Ee.DRAGGING,this.handlePanelDragging),n.off(Ee.DROPPED,this.handlePanelDropped)}reset(){this.setState({linkInProgress:void 0,selectedIds:new Set})}handleCancel(){const{linkInProgress:e}=this.state;if(e==null){const{setActiveTool:n}=this.props;n(Wt.DEFAULT)}this.setState({linkInProgress:void 0})}handleDone(){const{setActiveTool:e}=this.props;e(Wt.DEFAULT)}handleChartColumnSelect(e,n){this.columnSelected(e,n,!0)}handleFilterColumnSelect(e,n){Dt.debug("handleFilterColumnSelect",this.isOverlayShown());const{links:s,localDashboardId:i,setActiveTool:o,setDashboardIsolatedLinkerPanelId:r}=this.props,l=ie.getIdFromPanel(e),a=s.filter(d=>d.start?.panelId===l||d.end?.panelId===l);if(!this.isOverlayShown()&&l!=null){o(Wt.LINKER),r(i,l),a.length===0&&this.columnSelected(e,n,!0,l);return}this.columnSelected(e,n,!0)}handleColumnsChanged(e,n){Dt.debug("handleColumnsChanged",e,n);const{links:s}=this.props,i=ie.getIdFromPanel(e);if(i==null){Dt.error("Invalid panelId",e);return}const o=s.filter(({start:r,end:l})=>r.panelId===i&&ei.findColumn(n,r)==null||l!=null&&l.panelId===i&&ei.findColumn(n,l)==null);this.deleteLinks(o)}handleGridColumnSelect(e,n){if(!Jc(n)){Dt.debug2("Column is not filterable");return}this.columnSelected(e,n)}columnSelected(e,n,s=!1,i){if(i===void 0&&!this.isOverlayShown())return;const{isolatedLinkerPanelId:o}=this.props,{linkInProgress:r}=this.state,l=ie.getIdFromPanel(e);if(l==null)return;const a=ie.getComponentNameFromPanel(e),{name:d,type:c}=n;if(r==null||r.start==null){const u={id:$e.generate(),start:{panelId:l,panelComponent:a,columnName:d,columnType:c},type:"invalid",isReversed:s};Dt.debug("starting link",u),this.setState({linkInProgress:u})}else{const{links:u}=this.props,{start:m,id:p,isReversed:g}=r,f={panelId:l,panelComponent:a,columnName:d,columnType:c},C=ei.getLinkType(g!==void 0&&g?f:m,g!==void 0&&g?m:f,i??o);switch(C){case"invalid":Dt.debug("Ignore invalid link connection",r,f);return;case"filterSource":{const w=g!==void 0&&g?m.panelId:f.panelId,T=u.filter(({end:y})=>y?.panelId===w);this.deleteLinks(T);break}}const S={start:g!==void 0&&g?f:m,end:g!==void 0&&g?m:f,id:p,type:C,operator:$.eq};Dt.info("creating link",S),this.setState({linkInProgress:void 0,selectedIds:new Set([p])},()=>{this.addLinks([S])})}}unsetFilterValueForLink(e){const{panelManager:n}=this.props;if(e.end){const{end:s}=e,{panelId:i,columnName:o,columnType:r}=s,l=n.getOpenedPanelById(i);l?Qc(l)?l.unsetFilterValue(o,r):Dt.debug("endPanel.unsetFilterValue not implemented",l):Dt.debug("endPanel no longer exists, ignoring unsetFilterValue",i)}}setPanelFilterMap(e,n){Dt.debug("Set filter data for panel:",e,n);const{panelManager:s}=this.props,i=s.getOpenedPanelById(e);i?Qc(i)?i.setFilterMap(n):Dt.debug("panel.setFilterMap not implemented",e,i):Dt.debug("panel no longer exists, ignoring setFilterMap",e)}addLinks(e){const{addDashboardLinks:n,localDashboardId:s}=this.props;n(s,e)}deleteLinks(e,n=!1){const{localDashboardId:s}=this.props;if(e.forEach(i=>this.unsetFilterValueForLink(i)),n){const{setDashboardLinks:i}=this.props;i(s,[])}else if(e.length>0){const{deleteDashboardLinks:i}=this.props;i(s,e.map(({id:o})=>o))}}handleAllLinksDeleted(){const{links:e,isolatedLinkerPanelId:n}=this.props;if(n===void 0)this.deleteLinks(e,!0);else{const s=e.filter(i=>i?.start?.panelId===n||i?.end?.panelId===n);this.deleteLinks(s)}this.reset()}handleLinkDeleted(e){const{links:n}=this.props,s=n.find(i=>i.id===e);s?this.deleteLinks([s]):Dt.error("Unable to find link to delete",e)}handleUpdateValues(e,n){const s=ie.getIdFromPanel(e),{links:i,timeZone:o}=this.props,r=new Map;for(let l=0;l<i.length;l+=1){const{start:a,end:d,operator:c}=i[l];if(a.panelId===s&&d!=null){const{panelId:u,columnName:m,columnType:p}=d,g=r.has(u)?r.get(u):new Map,f=g.has(m)===!0?g.get(m).filterList:[],{visibleIndex:C,isExpandable:S,isGrouped:w}=n[a.columnName];let{value:T}=n[a.columnName],y=`${T}`;T===null&&S&&w&&(T=void 0),p!=null&&N.isDateType(p)&&(y=new st({timeZone:o,showTimeZone:!1,showTSeparator:!0,defaultDateTimeFormatString:vn.FULL_DATE_FORMAT}).format(T));const E={operator:c,text:y,value:T,startColumnIndex:C};f.push(E),g.set(m,{columnType:p,filterList:f}),r.set(u,g)}}r.forEach((l,a)=>{this.setPanelFilterMap(a,l)})}handlePanelCloned(e,n){const{links:s}=this.props,i=ie.getIdFromPanel(e),o=n.id;if(i!=null){const r=ei.cloneLinksForPanel(s,i,o);this.addLinks(r)}}handlePanelDragging(e){const{links:n}=this.props;for(let s=0;s<n.length;s+=1){const i=n[s],{start:o,end:r}=i;if(o.panelId===e||r?.panelId===e){this.setState({isDraggingPanel:!0});return}}}handlePanelDropped(){this.setState({isDraggingPanel:!1})}handlePanelClosed(e){Dt.debug(`Panel ${e} closed, deleting links.`),this.deleteLinksForPanelId(e)}handleLinkSelected(e){this.setState({selectedIds:new Set([e])})}handleLinksUpdated(e){const{localDashboardId:n,setDashboardLinks:s}=this.props;s(n,e)}handleLayoutStateChanged(){this.forceUpdate()}handleStateChange(){this.forceUpdate()}handleExited(){const{localDashboardId:e,setDashboardIsolatedLinkerPanelId:n}=this.props;n(e,void 0)}deleteLinksForPanelId(e){const{links:n}=this.props;for(let s=0;s<n.length;s+=1){const i=n[s],{start:o,end:r,id:l}=i;(o.panelId===e||r?.panelId===e)&&this.handleLinkDeleted(l)}}isOverlayShown(){const{activeTool:e}=this.props;return e===Wt.LINKER}updateSelectionValidators(){const{activeTool:e,setDashboardColumnSelectionValidator:n,localDashboardId:s}=this.props;switch(e){case Wt.LINKER:n(s,this.isColumnSelectionValid);break;default:n(s,void 0);break}}updateLinkInProgressType(e,n="invalid"){this.setState({linkInProgress:{...e,type:n}})}isColumnSelectionValid(e,n){const{linkInProgress:s}=this.state,{isolatedLinkerPanelId:i}=this.props;if(n==null)return s?.start!=null&&this.updateLinkInProgressType(s),!1;if(!Jc(n))return Dt.debug2("Column is not filterable",n.description),s?.start!=null&&this.updateLinkInProgressType(s,"invalid"),!1;if(s?.start==null)return!0;const{isReversed:o,start:r}=s,l=ie.getIdFromPanel(e);if(l==null)return!1;const a={panelId:l,panelComponent:ie.getComponentNameFromPanel(e),columnName:n.name,columnType:n.type},d=o!==void 0&&o?ei.getLinkType(a,r,i):ei.getLinkType(r,a,i);return this.updateLinkInProgressType(s,d),d!=="invalid"}render(){const{links:e,isolatedLinkerPanelId:n,panelManager:s}=this.props,{linkInProgress:i,selectedIds:o,isDraggingPanel:r}=this.state,l=this.isOverlayShown(),a=i!=null&&i.start!=null,d=n===void 0?"Click a column source, then click a column target to create a filter link. The filter comparison operator used by a selected link can be changed. Delete a filter link by clicking the delete button or with alt+click. Click done when finished.":"Create a link between the source column button and a table column by clicking on one, then the other. Delete a filter link by clicking the delete button or with alt+click. Click done when finished.";return r?null:h(Ht,{in:l,timeout:Xe.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,onExited:this.handleExited,children:h(Zm,{disabled:a,panelManager:s,links:this.getCachedLinks(e,i,n),selectedIds:o,messageText:d,onLinkSelected:this.handleLinkSelected,onLinkDeleted:this.handleLinkDeleted,onAllLinksDeleted:this.handleAllLinksDeleted,onLinksUpdated:this.handleLinksUpdated,onDone:this.handleDone,onCancel:this.handleCancel})})}}const Sy=fy(Cy);function by(t){Ps(t);const{id:e,layout:n,panelManager:s}=t;return h(Sy,{layout:n,localDashboardId:e,panelManager:s})}const Na=class{static getNewMarkdownTitle(t){let e=`${Na.DEFAULT_TITLE}`,n=0;for(;t.indexOf(e)>=0;)n+=1,e=`${Na.DEFAULT_TITLE}-${n}`;return e}};let Io=Na;Io.DEFAULT_TITLE="Note";Io.DEFAULT_CONTENT=`# Markdown Note
36
36
 
37
- This note can be edited using **markdown** for styling.`;function wy(t){Ps(t);const{id:e,layout:n,panelManager:s,registerComponent:i}=t,o=b.exports.useCallback(l=>{const{title:a,componentState:d,props:c}=l;let{panelState:u=null}=c;return d!=null&&({panelState:u=null}=d),a==null||u==null||u.content==null||u.content.length===0||u.content===Io.DEFAULT_CONTENT?null:nd(l)},[]),r=b.exports.useCallback(({title:l="",metadata:a={},id:d=$e.generate(),focusElement:c=ie.DEFAULT_FOCUS_SELECTOR,createNewStack:u=!1,dragEvent:m=null}={})=>{const p=s.getOpenedPanelConfigsOfType(ho.COMPONENT),g=s.getClosedPanelConfigsOfType(ho.COMPONENT),f=p.map(y=>y.title??""),C=l!=null&&l!==""?l:Io.getNewMarkdownTitle(f),S=g.length>0?null:Io.DEFAULT_CONTENT,w={type:"react-component",component:ho.COMPONENT,props:{id:d,metadata:a,panelState:{content:S},localDashboardId:e},title:C,id:d},{root:T}=n;ie.openComponent({root:T,config:w,focusElement:c,createNewStack:u,dragEvent:m})},[e,n,s]);return b.exports.useEffect(function(){const a=[i(ho.COMPONENT,ho,sd,o)];return()=>{a.forEach(d=>d())}},[o,i]),Be(n.eventHub,xm.OPEN,r),null}function Ty(t){Ps(t);const{hydrate:e,id:n,layout:s,registerComponent:i}=t,o=b.exports.useCallback(({dragEvent:r,fetch:l,panelId:a=$e.generate(),widget:d})=>{const{name:c,type:u}=d;if(u!==dh.VariableType.PANDAS)return;const m={name:c,table:c},p=()=>l().then(C=>Cd.makeModel(C)),g={type:"react-component",component:Ro.COMPONENT,props:{localDashboardId:n,id:a,metadata:m,makeModel:p},title:c,id:a},{root:f}=s;ie.openComponent({root:f,config:g,dragEvent:r})},[n,s]);return b.exports.useEffect(function(){const l=[i(Ro.COMPONENT,Ro,e)];return()=>{l.forEach(a=>a())}},[e,i]),Be(s.eventHub,Ee.OPEN,o),null}class un{}un.DROPDOWN_FILTER="ControlType.DROPDOWN_FILTER";un.INPUT_FILTER="ControlType.INPUT_FILTER";un.MARKDOWN="ControlType.MARKDOWN";un.FILTER_SET_MANAGER="ControlType.FILTER_SET_MANAGER";const vy=M.exports.shape({state:M.exports.shape({panelState:M.exports.shape({})})}),Ey=M.exports.shape({panelId:M.exports.string.isRequired,columnName:M.exports.string.isRequired,columnType:M.exports.string.isRequired}),oh=M.exports.shape({panelId:M.exports.string.isRequired,columnName:M.exports.string.isRequired}),Qm=M.exports.shape({start:oh,end:oh,id:M.exports.string,isReversed:M.exports.bool}),yy=M.exports.arrayOf(Qm),Ry=M.exports.shape({name:M.exports.string.isRequired,operateAs:M.exports.string.isRequired,groups:M.exports.arrayOf(M.exports.string).isRequired,permissions:M.exports.shape({isSuperUser:M.exports.bool.isRequired,isQueryViewOnly:M.exports.bool.isRequired,isNonInteractive:M.exports.bool.isRequired,canUsePanels:M.exports.bool.isRequired,canCreateDashboard:M.exports.bool.isRequired,canCreateCodeStudio:M.exports.bool.isRequired,canCreateQueryMonitor:M.exports.bool.isRequired,canCopy:M.exports.bool.isRequired,canDownloadCsv:M.exports.bool.isRequired}).isRequired});Object.freeze({LinkPoint:Ey,Link:Qm,Links:yy,Panel:vy,User:Ry});const Iy=(t,e)=>t[e]===null?null:M.exports.bool,Fy=(t,e)=>t[e]===null?null:M.exports.string;Object.freeze({nullableBoolean:Iy,nullableString:Fy});ee.module("StorageTableViewportUpdater");class rh{static makeSortConfig(e,n){return{column:e,direction:n}}static makeFilterConfig(e){const n=[],s=[];return e.forEach((i,o)=>{n.push(i),o>0&&s.push(zt.and)}),{filterItems:n,filterOperators:s}}static combineFilterConfigs(e,n,s=zt.and){return{filterItems:[...e.filterItems,...n.filterItems],filterOperators:[...e.filterOperators,s,...n.filterOperators]}}static makeFilterItem(e,n,s){return{columnName:e,type:n,value:s}}}const ia=ee.module("PouchStorageTable"),Dy="Deephaven.";Ch.plugin(Wp);function Ny(t,e){switch(t){case $.in:case $.contains:return{$regex:new RegExp(`${e}`)};case $.inIgnoreCase:return{$regex:new RegExp(`${e}`,"i")};case $.eq:return{$eq:e};case $.notEq:return{$neq:e};case $.greaterThan:return{$gt:e};case $.greaterThanOrEqualTo:return{$gte:e};case $.lessThan:return{$lt:e};case $.lessThanOrEqualTo:return{$lte:e};case $.startsWith:return{$regex:new RegExp(`^(?${e}).*`)};default:throw new Error(`Unsupported type: ${t}`)}}function _y(t){const{filterItems:e,filterOperators:n}=t;let s=null;for(let i=0;i<e.length;i+=1){const o=e[i],{columnName:r,type:l,value:a}=o,d={[r]:Ny(l,a)};if(i===0)s=d;else if(s!==null&&i-1<n.length){const c=n[i-1];if(c===zt.and)s={$and:[s,d]};else if(c===zt.or)s={$or:[s,d]};else throw new Error(`Unexpected filter operator ${c}, ${d}`)}}if(s==null)throw new Error(`Invalid filter config ${t}`);return s}function oa(t=[]){return{$and:[...t.map(e=>_y(e)),{name:{$gt:null}},{id:{$gt:null}}]}}function My(t,e=!1){return[{id:e?"desc":"asc"},...t?.map(n=>({[n.column]:n.direction}))??[]]}class ky{constructor(e){this.listeners=[],this.itemListeners=new Map,this.currentSize=0,this.currentReverse=!1,this.currentFilter=null,this.currentSort=null,this.db=new Ch(`${Dy}${e}`),this.db._remote=!1,this.db.changes({live:!0,since:"now",include_docs:!0}).on("change",this.dbUpdate.bind(this)),this.db.createIndex({index:{fields:["id","name"]}}),this.refreshInfo()}onUpdate(e){return this.listeners=[...this.listeners,e],()=>{this.listeners=this.listeners.filter(n=>n!==e)}}onItemUpdate(e,n){return this.itemListeners.has(e)||this.itemListeners.set(e,[]),this.itemListeners.set(e,[...this.itemListeners.get(e),n]),this.refreshItem(e),()=>{this.itemListeners.set(e,this.itemListeners.get(e).filter(s=>s!==n))}}close(){this.listeners=[]}get size(){return this.currentSize}get viewport(){return this.currentViewport}setReversed(e){this.currentReverse=e,this.currentViewportData=void 0,this.refreshData()}setViewport(e){this.currentViewport=e,this.refreshInfo(),this.refreshData()}setSorts(e){this.currentSort=e,this.currentViewportData=void 0,this.refreshData()}setFilters(e){this.currentFilter=e,this.currentViewportData=void 0,this.refreshInfo(),this.refreshData()}get data(){return this.currentViewportData}async getViewportData(){return this.viewportUpdatePromise||this.refreshData(),this.viewportUpdatePromise??Promise.resolve({items:[],offset:0})}async put(e){const n={...e,_id:e.id};return await this.db.put(n),n}sendUpdate(){const{listeners:e}=this,n=this.currentViewportData??{items:[],offset:0};for(let s=0;s<e.length;s+=1)e[s](n)}sendItemUpdate(e){const n=this.itemListeners.get(e.id);if(n!==void 0)for(let s=0;s<n.length;s+=1)n[s](e)}dbUpdate(e){ia.debug("Update received",e),this.refreshInfo(),e.doc!==void 0&&this.sendItemUpdate(e.doc),this.refreshData()}async refreshInfo(){try{this.infoUpdatePromise?.cancel(),this.infoUpdatePromise=ye.makeCancelable(this.db.find({selector:oa(this.currentFilter??[]),fields:[]}));const e=await this.infoUpdatePromise;this.currentSize=e.docs.length,this.sendUpdate()}catch(e){if(!ye.isCanceled(e))throw ia.error("Unable to refreshInfo",e),e}}async refreshData(){if(!!this.currentViewport)try{const{currentViewport:e}=this,n=My(this.currentSort,this.currentReverse);this.viewportUpdatePromise?.cancel(),this.viewportUpdatePromise=ye.makeCancelable(this.db.find({selector:oa(this.currentFilter??[]),skip:e.top,limit:e.bottom-e.top+1,sort:n,fields:["id","name"]}).then(i=>({items:i.docs,offset:e.top})));const s=await this.viewportUpdatePromise;return this.currentViewportData=s,this.sendUpdate(),s}catch(e){if(!ye.isCanceled(e))throw ia.error("Unable to refreshData",e),e}}async refreshItem(e){const s=(await this.db.find({selector:{id:e},limit:1})).docs[0];return s!==void 0&&this.sendItemUpdate(s),s}async getSnapshot(e){const n=new Map,s=[{id:this.currentReverse?"desc":"asc"}];return await Promise.all(e.map(async([i,o])=>{const r=o-i+1;return this.db.find({selector:oa(this.currentFilter??[]),skip:i,limit:r,sort:s,fields:["id","name"]}).then(l=>{for(let a=0;a<r;a+=1){const d=i+a;n.set(d,l.docs[a])}})})),n}}class lh extends ky{constructor(e){super(`CommandHistoryStorage.${e}`)}setSearch(e){this.setFilters(e?[rh.makeFilterConfig([rh.makeFilterItem("name",$.contains,e)])]:[])}}const ah=ee.module("PouchCommandHistoryStorage");class xy{constructor(){this.updateTableMap=new Map}getUpdateTable(e){return this.updateTableMap.has(e)||this.updateTableMap.set(e,new lh(e)),this.updateTableMap.get(e)}async getTable(e){return new lh(e)}async addItem(e,n,s,i){return this.updateItem(e,{id:`${new Date().getTime()}`,name:s,data:i})}async updateItem(e,n){const s=this.getUpdateTable(e),o={...await s.refreshItem(n.id)??{},...n};return ah.debug("Updating item",o),await s.put(o),ah.debug("Update saved"),n}listenItem(e,n,s){return this.getUpdateTable(e).onItemUpdate(n,s)}}const Jm="SET_LAYOUT_STORAGE",Oy=t=>({type:Jm,payload:t}),ep="/ide/assets/community-wordmark-app.d2c5c1eb.svg";const Ay=ee.module("FormattingSectionContent");function Ly(t){return t.formatString!=null}function _a(t){const e=t?.querySelector("input, select, textarea");e&&e.focus()}function tp(t,e){return t.defaultFormatString===e.defaultFormatString}function Py(t,e){return tp(t,e)}function Hy(t,e){return tp(t,e)}function np(t){return t!==""&&Vi.isValidColumnName(t)}function Ms(t,e){if(!t||e.formatString==null||!Ly(e))return!1;switch(t){case"datetime":return st.isValid(e);case"decimal":return ke.isValid(e);case"int":return Ze.isValid(e);default:return Ay.warn("Trying to validate format of unknown type"),!0}}function sp(t){const{id:e,isNewRule:n,...s}=t;return s}function ip(t){return np(t.columnName)&&Ms(t.columnType,t.format)}function op(t){const{timestamp:e,timeZone:n,showTimeZone:s,showTSeparator:i,isGlobalOptions:o,legacyGlobalFormat:r}=t,l=new nn([],{timeZone:n,showTimeZone:s,showTSeparator:i}),a=o?st.getGlobalFormats(s,i):st.getFormats(s,i);return r!=null&&!a.includes(r)&&a.unshift(r),h(Se,{children:a.map(d=>{const c=st.makeFormat("",d,st.TYPE_GLOBAL);return h("option",{value:d,"data-testid":"time-format",children:l.getFormattedString(e,N.dataType.DATETIME,"",c)},d)})})}function Uy(){return h(Se,{children:Qr.TIME_ZONES.map(t=>{const{label:e,value:n}=t;return h("option",{value:n,children:e},n)})})}const Ks=ee.module("FormattingSectionContent"),rp=class extends b.exports.PureComponent{constructor(t){super(t),this.getCachedDateTimeFormatOptions=Ie((c,u,m,p=!1,g)=>{const{timestampAtMenuOpen:f}=this.state;return h(op,{timestamp:f,timeZone:c,showTimeZone:u,showTSeparator:m,isGlobalOptions:p,legacyGlobalFormat:g})}),this.debouncedCommitChanges=Je(this.commitChanges.bind(this),rp.inputDebounceTime),this.handleDefaultDateTimeFormatChange=this.handleDefaultDateTimeFormatChange.bind(this),this.handleDefaultDecimalFormatChange=this.handleDefaultDecimalFormatChange.bind(this),this.handleDefaultIntegerFormatChange=this.handleDefaultIntegerFormatChange.bind(this),this.handleShowTimeZoneChange=this.handleShowTimeZoneChange.bind(this),this.handleShowTSeparatorChange=this.handleShowTSeparatorChange.bind(this),this.handleTimeZoneChange=this.handleTimeZoneChange.bind(this),this.handleResetDateTimeFormat=this.handleResetDateTimeFormat.bind(this),this.handleResetDecimalFormat=this.handleResetDecimalFormat.bind(this),this.handleResetIntegerFormat=this.handleResetIntegerFormat.bind(this),this.handleResetTimeZone=this.handleResetTimeZone.bind(this),this.handleTruncateNumbersWithPoundChange=this.handleTruncateNumbersWithPoundChange.bind(this);const{formatter:e,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,showTimeZone:o,showTSeparator:r,timeZone:l,truncateNumbersWithPound:a}=t,d=e.map((c,u)=>({...c,id:u}));this.containerRef=de.createRef(),this.state={formatSettings:d,showTimeZone:o,showTSeparator:r,timeZone:l,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,truncateNumbersWithPound:a,timestampAtMenuOpen:new Date}}componentDidMount(){_a(this.containerRef.current)}componentWillUnmount(){this.debouncedCommitChanges.flush()}handleDefaultDateTimeFormatChange(t){Ks.debug("handleDefaultDateTimeFormatChange",t.target.value),this.setState({defaultDateTimeFormat:t.target.value},()=>{this.debouncedCommitChanges()})}handleDefaultDecimalFormatChange(t){Ks.debug("handleDefaultDecimalFormatChange",t.target.value),this.setState({defaultDecimalFormatOptions:{defaultFormatString:t.target.value}},()=>{this.debouncedCommitChanges()})}handleDefaultIntegerFormatChange(t){Ks.debug("handleDefaultIntegerFormatChange",t.target.value),this.setState({defaultIntegerFormatOptions:{defaultFormatString:t.target.value}},()=>{this.debouncedCommitChanges()})}handleShowTimeZoneChange(){this.setState(t=>({showTimeZone:!t.showTimeZone}),()=>{this.debouncedCommitChanges()})}handleShowTSeparatorChange(){this.setState(t=>({showTSeparator:!t.showTSeparator}),()=>{this.debouncedCommitChanges()})}handleTimeZoneChange(t){this.setState({timeZone:t.target.value},()=>{this.debouncedCommitChanges()})}handleResetDateTimeFormat(){const{defaults:t}=this.props,{defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s}=t;Ks.debug("handleResetDateTimeFormat"),this.setState({defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s},()=>{this.debouncedCommitChanges()})}handleResetTimeZone(){const{defaults:t}=this.props,{timeZone:e}=t;Ks.debug("handleResetTimeZone"),this.setState({timeZone:e},()=>{this.debouncedCommitChanges()})}handleResetDecimalFormat(){const{defaults:t}=this.props,{defaultDecimalFormatOptions:e}=t;Ks.debug("handleResetDecimalFormat"),this.setState({defaultDecimalFormatOptions:e},()=>{this.debouncedCommitChanges()})}handleResetIntegerFormat(){const{defaults:t}=this.props,{defaultIntegerFormatOptions:e}=t;Ks.debug("handleResetIntegerFormat"),this.setState({defaultIntegerFormatOptions:e},()=>{this.debouncedCommitChanges()})}handleTruncateNumbersWithPoundChange(){this.setState(t=>({truncateNumbersWithPound:!t.truncateNumbersWithPound}),()=>{this.debouncedCommitChanges()})}commitChanges(){const{formatSettings:t,defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s,timeZone:i,defaultDecimalFormatOptions:o,defaultIntegerFormatOptions:r,truncateNumbersWithPound:l}=this.state,a=t.filter(ip).map(sp)??[],{settings:d,saveSettings:c}=this.props,u={...d,formatter:a,defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s,timeZone:i,truncateNumbersWithPound:l};Ms(N.dataType.DECIMAL,ke.makeCustomFormat(o.defaultFormatString))&&(u.defaultDecimalFormatOptions=o),Ms(N.dataType.INT,Ze.makeCustomFormat(r.defaultFormatString))&&(u.defaultIntegerFormatOptions=r),c(u)}render(){const{defaults:t}=this.props,{defaultDateTimeFormat:e,defaultDecimalFormatOptions:n,defaultIntegerFormatOptions:s,timeZone:i,showTimeZone:o,showTSeparator:r,truncateNumbersWithPound:l}=this.state,{defaultFormatString:a=ke.DEFAULT_FORMAT_STRING}=n??{},{defaultFormatString:d=Ze.DEFAULT_FORMAT_STRING}=s??{},c=i===t.timeZone,u=r===t.showTSeparator&&o===t.showTimeZone&&e===t.defaultDateTimeFormat,m=Py(n,t.defaultDecimalFormatOptions),p=Hy(s,t.defaultIntegerFormatOptions);return h("div",{className:"app-settings-formatting-section",ref:this.containerRef,children:v("div",{className:"container-fluid p-0",children:[h("div",{className:"app-settings-menu-description mb-3",children:"Choose the default formatting rule to apply to all table columns based on their type."}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"select-reset-timezone",children:"Time zone"}),h("div",{className:"col pr-0",children:h("select",{className:"custom-select",value:i,onChange:this.handleTimeZoneChange,id:"select-reset-timezone",children:h(Uy,{})})}),h("div",{className:"col-1 btn-col",children:h(V,{kind:"ghost",icon:ti,onClick:this.handleResetTimeZone,tooltip:"Reset Time Zone",className:K("btn-reset","btn-reset-time-zone",{hidden:c})})})]}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"select-default-time-format",children:"DateTime"}),h("div",{className:"col pr-0",children:h("select",{className:"custom-select",value:e,onChange:this.handleDefaultDateTimeFormatChange,id:"select-default-time-format",children:this.getCachedDateTimeFormatOptions(i,o,r,!0,e)})}),h("div",{className:"col-1 btn-col",children:h(V,{kind:"ghost",icon:ti,onClick:this.handleResetDateTimeFormat,tooltip:"Reset DateTime Options",className:K("btn-reset","btn-reset-date-time",{hidden:u})})})]}),h("div",{className:"form-row",children:h("div",{className:"offset-3 col-9",children:h(mn,{checked:o??null,onChange:this.handleShowTimeZoneChange,children:"Show time zone in dates"})})}),h("div",{className:"form-row mb-3",children:h("div",{className:"offset-3 col-9",children:h(mn,{checked:r??null,onChange:this.handleShowTSeparatorChange,children:"Show 'T' separator"})})}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"default-decimal-format-input",children:"Decimal"}),h("div",{className:"col pr-0",children:h("input",{className:K("form-control","flex-grow-1","default-decimal-format-input",{"is-invalid":!Ms(N.dataType.DECIMAL,ke.makeCustomFormat(a))}),"data-lpignore":!0,placeholder:ke.DEFAULT_FORMAT_STRING,type:"text",id:"default-decimal-format-input",value:a,onChange:this.handleDefaultDecimalFormatChange})}),h("div",{className:"col-1 btn-col",children:h(V,{kind:"ghost",icon:ti,onClick:this.handleResetDecimalFormat,tooltip:"Reset Decimal Formatting",className:K("btn-reset","btn-reset-decimal",{hidden:m}),"data-testid":"btn-reset-decimal"})})]}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"default-integer-format-input",children:"Integer"}),h("div",{className:"col pr-0",children:h("input",{className:K("form-control","flex-grow-1","default-integer-format-input",{"is-invalid":!Ms(N.dataType.INT,Ze.makeCustomFormat(d))}),"data-lpignore":!0,placeholder:Ze.DEFAULT_FORMAT_STRING,type:"text",id:"default-integer-format-input",value:d,onChange:this.handleDefaultIntegerFormatChange})}),h("div",{className:"col-1 btn-col",children:h(V,{kind:"ghost",icon:ti,onClick:this.handleResetIntegerFormat,tooltip:"Reset Integer Formatting",className:K("btn-reset","btn-reset-integer",{hidden:p}),"data-testid":"btn-reset-integer"})})]}),h("div",{className:"form-row mb-3",children:h("div",{className:"offset-3 col-9",children:h(mn,{checked:l??null,onChange:this.handleTruncateNumbersWithPoundChange,children:"Truncate numbers with #"})})})]})})}};let Od=rp;Od.defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:st.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:ke.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:Ze.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:st.DEFAULT_TIME_ZONE_ID}};Od.inputDebounceTime=250;const Vy=t=>({formatter:uu(t),defaultDateTimeFormat:du(t),defaultDecimalFormatOptions:cu(t),defaultIntegerFormatOptions:hu(t),showTimeZone:mu(t),showTSeparator:pu(t),truncateNumbersWithPound:gu(t),timeZone:Ao(t),settings:Et(t)}),By=vt(Vy,{saveSettings:fl})(Od);function $y(){const[t,e]=b.exports.useState(!1),n=()=>{e(!t)};return v(V,{kind:"ghost",onClick:n,icon:lf,children:["Legal Notices",v(sl,{isOpen:t,toggle:n,className:"theme-bg-light",children:[h(il,{toggle:n,children:"Legal Notice"}),v(ol,{children:[h("p",{children:"Deephaven software is protected by U.S. Patent Nos. 9,612,959; 9,613,018; 9,613,109; 9,619,210; 9,633,060; 9,639,570; 9,672,238; 9,679,006; 9,690,821; 9,710,511; 9,760,591; 9,805,084; 9,836,495; 9,836,494; 9,886,469; 9,898,496; 9,934,266; 10,002,153; 10,002,154; 10,002,155; 10,003,673; 10,019,138; 10,069,943; 10,176,211; 10,198,465; 10,198,466; 10,198,469; 10,212,257; 10,241,960; 10,241,965; 10,242,040; 10,242,041; 10,353,893; 10,346,394; 10,452,649; 10,496,639; 10,540,351; 10,552,412; 10,565,194; 10,565,206; 10,572,474; 10,621,168; 10,642,829; 10,657,184; 10,678,787; 10,691,686; and 10,783,191. Other patents pending."}),v("p",{children:["\xA9 2016-",new Date().getFullYear()," Deephaven Data Labs LLC. Patent Pending."]})]})]})]})}function Fo(t){const{children:e,isExpanded:n,sectionKey:s,title:i,onToggle:o}=t;return v(Se,{children:[h("div",{children:v(V,{kind:"ghost",className:"btn-collapse-trigger",onClick:()=>o(s),children:[h("div",{className:"flex-grow-1",children:i}),h("div",{className:"flex-shrink-0",children:h(J,{transform:n?"flip-v":"",icon:ts})})]})}),h(af,{in:n,autoFocusOnShow:!0,children:e})]})}Fo.propTypes={children:M.exports.node,isExpanded:M.exports.bool.isRequired,sectionKey:M.exports.string.isRequired,title:M.exports.node.isRequired,onToggle:M.exports.func};Fo.defaultProps={children:null,onToggle:()=>{}};function Gy({shortcut:t,displayText:e,categoryName:n,onChange:s}){const[i,o]=b.exports.useState(e),[r,l]=b.exports.useState(t.getKeyState()),[a,d]=b.exports.useState(!1),[c,u]=b.exports.useState("");b.exports.useEffect(function(){o(e),l(t.getKeyState())},[e,t]),b.exports.useEffect(function(){o(fn.getDisplayText(r)),t.matchesKeyState(r)&&d(!1)},[r,t]),b.exports.useEffect(function(){if(a){if(!fn.isValidKeyState(r)){fn.isAllowedKey(r.keyValue)?u("Must contain a modifier key"):u("Must contain an allowed action key");return}const y=qe.getConflictingShortcuts(r).filter(E=>E.id.startsWith(n)&&E!==t).map(E=>E.name);if(y.length){u(`Conflicts with ${y.join(", ")}`);return}u("")}else u("")},[a,r,n,t]);function m(T){if(T.stopPropagation(),T.preventDefault(),t.isEditable&&!T.repeat){const y=fn.getKeyStateFromEvent(T),E=fn.createKeyState([Fe.BACKSPACE]);fn.doKeyStatesMatch(y,E)?l(fn.NULL_KEY_STATE):l(y)}}function p(T){T.stopPropagation(),T.preventDefault(),t.matchesKeyState(r)||d(!0)}function g(){Hn.disableAllActions()}function f(){Hn.enableAllActions()}function C(){t.setKeyState(r),d(!1),s(t)}function S(){const T=t.getKeyState();l(T),d(!1)}function w(){d(!0),l(t.getDefaultKeyState())}return v(Se,{children:[v("div",{className:"shortcut-item-container",children:[v("label",{className:"shortcut-item-name",children:[t.name,t.tooltip!==void 0&&h(ut,{children:t.tooltip})]}),v("div",{className:"shortcut-item-input-container",children:[h("input",{className:K("form-control",{"is-invalid":c}),onKeyDown:m,onKeyUp:p,onFocus:g,onBlur:f,disabled:!t.isEditable,value:i,readOnly:!0}),!fn.doKeyStatesMatch(r,t.getDefaultKeyState())&&!c&&h(V,{className:"reset-to-default-button",kind:"ghost",icon:h(J,{icon:ti,transform:{rotate:90,flipX:!0}}),tooltip:"Reset to default",onClick:w})]})]}),a&&v("div",{className:K("shortcut-item-message-container",{"is-invalid":c}),children:[h("div",{className:"shortcut-item-message",children:c}),v("div",{className:"shortcut-item-message-buttons",children:[fn.isValidKeyState(r)&&h(V,{kind:"ghost",onClick:C,children:"Confirm"}),h(V,{kind:"ghost",onClick:S,children:"Undo"})]})]})]})}function Wy({shortcutOverrides:t={},settings:e,saveSettings:n}){const s=b.exports.useCallback(l=>{const a=fn.isMacPlatform,d={mac:{...t.mac},windows:{...t.windows}},c=a?d.mac:d.windows;l.forEach(u=>{u.isDefault()?delete c[u.id]:c[u.id]=u.getKeyState()}),n({...e,shortcutOverrides:d})},[e,n,t]);let i=Array.from(qe.shortcutsByCategory.entries()).map(([l,a])=>({name:l,shortcuts:a}));const o=i.findIndex(l=>l.name.toUpperCase()==="GLOBAL"),r=i.splice(o,1);return i=i.concat(r),v(Se,{children:[h("div",{className:"app-settings-menu-description",children:"Customize shortcuts below. To prevent unexpected results, avoid conflicting shortcuts with the browser or IDE editor."}),i.map(l=>h(zy,{name:l.name,shortcuts:l.shortcuts,saveShortcutOverrides:s},l.name))]})}function zy({name:t,shortcuts:e,saveShortcutOverrides:n}){function s(a){return a.split("_").map(d=>`${d[0].toUpperCase()}${d.slice(1).toLowerCase()}`).join(" ")}const[i,o]=b.exports.useState(e);function r(a){const d=i.filter(u=>u!==a&&!u.isNull()&&u.matchesKeyState(a.getKeyState()));d.forEach(u=>u.setToNull());const c=[a,...d];n(c),o(u=>[...u])}const l=b.exports.useMemo(()=>i.map(a=>a.getDisplayText()),[i]);return v("div",{className:"mt-3",children:[h("div",{className:"font-weight-bold",children:s(t)}),i.map((a,d)=>h(Gy,{shortcut:a,displayText:l[d],categoryName:t,onChange:r},a.id))]})}const qy=t=>({settings:Et(t),shortcutOverrides:sS(t)}),Yy={saveSettings:fl},Ky=vt(qy,Yy)(Wy),Xy="yyyy-MM-dd-HHmmss";function lp(t,e="root",n=new Map([[t,""]])){const s={};return Object.entries(t).forEach(([i,o])=>{try{JSON.stringify(o),s[i]=o}catch{const l=o;if(typeof o=="bigint")s[i]=o.toString();else if(n.has(l))s[i]=`Circular ref to ${n.get(l)}`;else{const a=`${e}.${i}`;n.set(l,a),s[i]=lp(o,a,n)}}}),s}function jy(){const t=Sl.getState();return JSON.stringify(lp(t),null,2)}function Zy(t){const e={uiVersion:"0.31.3",userAgent:navigator.userAgent,...t};return JSON.stringify(e,null,2)}async function Qy(t=`${I.i18n.DateTimeFormat.format(Xy,new Date)}_support_logs`,e){const n=new Sh,s=n.folder(t);s.file("console.txt",df.getFormattedHistory()),s.file("redux.json",jy()),s.file("metadata.json",Zy(e));const i=await n.generateAsync({type:"blob"}),o=document.createElement("a");o.href=URL.createObjectURL(i),o.download=`${t}.zip`,o.click()}const Jy=[{value:N.dataType.DATETIME,label:"DateTime"},{value:N.dataType.DECIMAL,label:"Decimal"},{value:N.dataType.INT,label:"Integer"}];function eR(){const t=Jy.map(e=>h("option",{value:e.value,children:e.label},`key-columnType-${e.value}`));return v(Se,{children:[h("option",{disabled:!0,value:"",children:"Select Type"},"key-columnType-placeholder"),t]})}const ap=class extends b.exports.PureComponent{constructor(t){super(t),this.getCachedColumnTypeOptions=Ie(()=>h(eR,{})),this.getCachedDateTimeFormatOptions=Ie((c,u,m,p=!1,g)=>{const{timestampAtMenuOpen:f}=this.state;return h(op,{timestamp:f,timeZone:c,showTimeZone:u,showTSeparator:m,isGlobalOptions:p,legacyGlobalFormat:g})}),this.debouncedCommitChanges=Je(this.commitChanges.bind(this),ap.inputDebounceTime),this.handleFormatRuleEntered=this.handleFormatRuleEntered.bind(this),this.handleFormatRuleChange=this.handleFormatRuleChange.bind(this),this.handleFormatRuleCreate=this.handleFormatRuleCreate.bind(this),this.handleFormatRuleDelete=this.handleFormatRuleDelete.bind(this);const{formatter:e,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,showTimeZone:o,showTSeparator:r,timeZone:l,truncateNumbersWithPound:a}=t,d=e.map((c,u)=>({...c,id:u}));this.containerRef=de.createRef(),this.addFormatRuleButtonRef=de.createRef(),this.lastFormatRuleIndex=d.length,this.state={formatSettings:d,formatRulesChanged:!1,showTimeZone:o,showTSeparator:r,timeZone:l,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,truncateNumbersWithPound:a,timestampAtMenuOpen:new Date}}componentDidMount(){_a(this.containerRef.current)}componentWillUnmount(){this.debouncedCommitChanges.flush()}isDuplicateRule(t){const{formatSettings:e}=this.state;return e.some(n=>n.id!==t.id&&n.columnName===t.columnName&&n.columnType===t.columnType)??!1}getAutoIncrementFormatRuleIndex(){const{lastFormatRuleIndex:t}=this;return this.lastFormatRuleIndex+=1,t}handleFormatRuleChange(t,e,n){this.setState(s=>{const{formatSettings:i}=s;k(i);const o=[...i];let r={};e==="columnType"&&(r={format:""});const l={...o[t],...r,[e]:n};return o[t]=l,{formatSettings:o}},()=>{this.debouncedCommitChanges()})}handleFormatRuleCreate(){this.setState(t=>{const{formatSettings:e}=t,n={columnType:N.dataType.DATETIME,columnName:"",format:{},id:this.getAutoIncrementFormatRuleIndex(),isNewRule:!0};return{formatSettings:e!=null?[...e,n]:[n],formatRulesChanged:!0}})}handleFormatRuleDelete(t){this.setState(e=>{const{formatSettings:n}=e;return{formatSettings:n.filter((i,o)=>o!==t),formatRulesChanged:!0}},()=>{this.debouncedCommitChanges()})}handleFormatRuleEntered(t){this.scrollToFormatBlockBottom(),_a(t)}commitChanges(){const{formatSettings:t,defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s,timeZone:i,defaultDecimalFormatOptions:o,defaultIntegerFormatOptions:r,truncateNumbersWithPound:l}=this.state,a=t.filter(ip).map(sp)??[],{settings:d,saveSettings:c}=this.props,u={...d,formatter:a,defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s,timeZone:i,truncateNumbersWithPound:l};Ms(N.dataType.DECIMAL,ke.makeCustomFormat(o.defaultFormatString))&&(u.defaultDecimalFormatOptions=o),Ms(N.dataType.INT,Ze.makeCustomFormat(r.defaultFormatString))&&(u.defaultIntegerFormatOptions=r),c(u)}scrollToFormatBlockBottom(){const{scrollTo:t}=this.props;t(0,(this.addFormatRuleButtonRef.current?.offsetHeight??0)+(this.addFormatRuleButtonRef.current?.offsetTop??0))}getRuleError(t){const e={hasColumnNameError:!1,hasFormatError:!1,message:""},n=[];return t.isNewRule!==void 0&&t.isNewRule||(this.isDuplicateRule(t)&&(e.hasColumnNameError=!0,n.push("Duplicate column name/type combo.")),np(t.columnName)||(e.hasColumnNameError=!0,n.push("Column names must start with a letter or underscore and contain only alphanumeric characters or underscores.")),t.format.formatString!==void 0&&t.format.formatString.length===0?(e.hasFormatError=!0,n.push("Empty formatting rule.")):Ms(t.columnType,t.format)||(e.hasFormatError=!0,n.push("Invalid formatting rule.")),e.message=n.join(`
38
- `)),e}renderFormatRule(t,e){const n=`input-${t}-columnName`,s=`input-${t}-columnType`,i=`input-${t}-format`,o=this.getCachedColumnTypeOptions(),r=c=>this.handleFormatRuleChange(t,"columnName",c.target.value),l=()=>this.handleFormatRuleChange(t,"isNewRule",!1),a=c=>this.handleFormatRuleChange(t,"columnType",c.target.value),d=this.getRuleError(e);return v("fieldset",{className:"container-fluid format-rule-container",children:[v("div",{className:"form-row",children:[v("div",{className:"form-group col-7 mb-2",children:[h("label",{htmlFor:n,children:"Column Name"}),h("input",{id:n,className:K("form-control",{"is-invalid":d.hasColumnNameError}),"data-lpignore":!0,type:"text",value:e.columnName,onChange:r,onBlur:l})]}),v("div",{className:"form-group col mb-2",children:[h(V,{kind:"ghost",className:"btn-delete-format-rule float-right",tabIndex:-1,onClick:()=>this.handleFormatRuleDelete(t),icon:sn,tooltip:"Delete","aria-label":"Delete Format Rule"}),h("label",{htmlFor:s,children:"Column Type"}),h("select",{id:s,className:"custom-select",value:e.columnType,onChange:a,children:o})]})]}),h("div",{className:"form-row",children:v("div",{className:"form-group col-12 d-flex mb-2",children:[h("label",{className:"flex-shrink-0 col-form-label mr-3",htmlFor:i,children:"Formatting Rule"}),this.renderFormatRuleInput(t,e.columnType,i,e.format,d.hasFormatError)]})}),h("div",{className:"form-row",children:h("div",{className:"form-group col-12 d-flex mb-2",children:d.message&&h("p",{className:"text-danger",children:d.message})})})]},t)}renderFormatRuleInput(t,e,n,s,i){switch(N.getNormalizedType(e)){case N.dataType.DATETIME:return this.renderDateTimeFormatRuleInput(t,n,s,i);case N.dataType.DECIMAL:return this.renderDecimalFormatRuleInput(t,n,s,i);case N.dataType.INT:return this.renderIntegerFormatRuleInput(t,n,s,i);default:throw new Error(`Unrecognized column type: ${e}`)}}renderDateTimeFormatRuleInput(t,e,n,s){const{showTimeZone:i,showTSeparator:o,timeZone:r}=this.state,l=n.formatString??"";return v("select",{className:K("custom-select",{"is-invalid":s}),value:l,id:e,onChange:a=>{const d=st.makeFormat("",a.target.value,st.TYPE_GLOBAL);this.handleFormatRuleChange(t,"format",d)},children:[h("option",{value:"",disabled:!0,children:"Select format"},"default"),this.getCachedDateTimeFormatOptions(r,i,o)]})}renderIntegerFormatRuleInput(t,e,n,s){const i=n.formatString??"";return h("input",{className:K("form-control","flex-grow-1",{"is-invalid":s}),"data-lpignore":!0,id:e,placeholder:Ze.DEFAULT_FORMAT_STRING,type:"text",value:i,onChange:o=>{const r=Ze.makeFormat("",o.target.value,Ze.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(t,"format",r)}})}renderDecimalFormatRuleInput(t,e,n,s){const i=n.formatString??"";return h("input",{className:K("form-control","flex-grow-1",{"is-invalid":s}),"data-lpignore":!0,id:e,placeholder:ke.DEFAULT_FORMAT_STRING,type:"text",value:i,onChange:o=>{const r=ke.makeFormat("",o.target.value,ke.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(t,"format",r)}})}render(){const{formatRulesChanged:t,formatSettings:e}=this.state,n=e.map((i,o)=>h(Ht,{classNames:"fade",timeout:Xe.transitionMs,onEnter:this.handleFormatRuleEntered,children:this.renderFormatRule(o,i)},i.id)),s=h(V,{kind:"ghost",className:"mb-3",onClick:this.handleFormatRuleCreate,ref:this.addFormatRuleButtonRef,icon:As,children:"Add New Rule"});return v("div",{className:"app-settings-formatting-section",ref:this.containerRef,children:[h("div",{className:"app-settings-menu-description mb-3",children:"Customize the formatting of table columns by applying rules based on matching both a column name and column type."}),h(zp,{appear:t,enter:t,exit:t,children:n}),s]})}};let Ad=ap;Ad.defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:st.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:ke.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:Ze.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:st.DEFAULT_TIME_ZONE_ID}};Ad.inputDebounceTime=250;const tR=t=>({formatter:uu(t),defaultDateTimeFormat:du(t),defaultDecimalFormatOptions:cu(t),defaultIntegerFormatOptions:hu(t),showTimeZone:mu(t),showTSeparator:pu(t),truncateNumbersWithPound:gu(t),timeZone:Ao(t),settings:Et(t)}),nR=vt(tR,{saveSettings:fl})(Ad),Qn=class extends b.exports.Component{constructor(t){super(t),this.handleClose=this.handleClose.bind(this),this.handleScrollTo=this.handleScrollTo.bind(this),this.handleSectionToggle=this.handleSectionToggle.bind(this),this.handleExportSupportLogs=this.handleExportSupportLogs.bind(this),this.menuContentRef=de.createRef(),this.state={expandedSectionKey:Qn.FORMATTING_SECTION_KEY}}static focusFirstInputInContainer(t){const e=t?.querySelector("input, select, textarea");e&&e.focus()}componentDidMount(){Qn.focusFirstInputInContainer(this.menuContentRef.current)}isSectionExpanded(t){const{expandedSectionKey:e}=this.state;return e===t}handleScrollTo(t,e){this.menuContentRef.current?.scrollTo(t,e)}handleSectionToggle(t){this.setState(e=>({expandedSectionKey:e.expandedSectionKey===t?void 0:t}))}handleClose(){const{onDone:t}=this.props;t()}handleExportSupportLogs(){const{serverConfigValues:t}=this.props;Qy(void 0,Object.fromEntries(t))}render(){const t="0.31.3",e="https://github.com/deephaven/web-client-ui/",n="https://deephaven.io/core/docs/",{serverConfigValues:s}=this.props,i=s.get("barrage.version"),o=s.get("java.version"),r=s.get("deephaven.version"),l=(a,d)=>v(Se,{children:[h("div",{children:a}),h("div",{children:d})]});return v("div",{className:"app-settings-menu",children:[v("header",{className:"app-settings-menu-header",children:[h("div",{className:"flex-spacer"}),h(V,{kind:"ghost",className:"btn-close-settings-menu",onClick:this.handleClose,icon:h(J,{icon:Ui,transform:"grow-4"}),tooltip:"Close"})]}),v("div",{className:"app-settings-menu-content",ref:this.menuContentRef,children:[h("h5",{children:"Settings"}),h("hr",{className:"my-0"}),h(Fo,{sectionKey:Qn.FORMATTING_SECTION_KEY,isExpanded:this.isSectionExpanded(Qn.FORMATTING_SECTION_KEY),title:v(Se,{children:[h(J,{icon:cf,transform:"grow-4",className:"mr-2"}),"Default Format & Time zone"]}),onToggle:this.handleSectionToggle,children:h(By,{})}),h(Fo,{sectionKey:Qn.COLUMN_SPECIFIC_SECTION_KEY,isExpanded:this.isSectionExpanded(Qn.COLUMN_SPECIFIC_SECTION_KEY),title:v(Se,{children:[h(J,{icon:hf,transform:"grow-4",className:"mr-2"}),"Format by Column Name & Type"]}),onToggle:this.handleSectionToggle,children:h(nR,{scrollTo:this.handleScrollTo})}),h(Fo,{sectionKey:Qn.SHORTCUT_SECTION_KEY,isExpanded:this.isSectionExpanded(Qn.SHORTCUT_SECTION_KEY),title:v(Se,{children:[h(J,{icon:uf,transform:"grow-2"})," ","Keyboard Shortcuts"]}),onToggle:this.handleSectionToggle,children:h(Ky,{})}),v("div",{className:"app-settings-footer",children:[v("div",{className:"app-settings-footer-section",children:[v("div",{className:"app-settings-footer-item",children:[h("div",{className:"font-weight-bold",children:"Support"}),v("div",{children:["GitHub:\xA0",h("a",{href:e,className:"custom-link",target:"_blank",rel:"noopener noreferrer",children:e})]}),h(V,{kind:"tertiary",className:"mt-2 py-2",onClick:this.handleExportSupportLogs,children:"Export Logs"})]}),v("div",{className:"app-settings-footer-item",children:[h("div",{className:"font-weight-bold",children:"Documentation"}),h("a",{target:"_blank",rel:"noreferrer noopener",href:n,className:"custom-link",children:n})]}),v("div",{className:"app-settings-footer-item",children:[h("div",{className:"font-weight-bold",children:"Version"}),v("span",{className:"d-inline-block text-muted",children:[r," ",h(J,{icon:mf}),v(ut,{interactive:!0,children:[v("div",{className:"detailed-server-config",children:[l("Engine Version",r),l("Web UI Version",t),l("Java Version",o),l("Barrage Version",i)]}),h(al,{tooltip:"Copy version numbers",copy:`Engine Version: ${r}
37
+ This note can be edited using **markdown** for styling.`;function wy(t){Ps(t);const{id:e,layout:n,panelManager:s,registerComponent:i}=t,o=b.exports.useCallback(l=>{const{title:a,componentState:d,props:c}=l;let{panelState:u=null}=c;return d!=null&&({panelState:u=null}=d),a==null||u==null||u.content==null||u.content.length===0||u.content===Io.DEFAULT_CONTENT?null:nd(l)},[]),r=b.exports.useCallback(({title:l="",metadata:a={},id:d=$e.generate(),focusElement:c=ie.DEFAULT_FOCUS_SELECTOR,createNewStack:u=!1,dragEvent:m=null}={})=>{const p=s.getOpenedPanelConfigsOfType(ho.COMPONENT),g=s.getClosedPanelConfigsOfType(ho.COMPONENT),f=p.map(y=>y.title??""),C=l!=null&&l!==""?l:Io.getNewMarkdownTitle(f),S=g.length>0?null:Io.DEFAULT_CONTENT,w={type:"react-component",component:ho.COMPONENT,props:{id:d,metadata:a,panelState:{content:S},localDashboardId:e},title:C,id:d},{root:T}=n;ie.openComponent({root:T,config:w,focusElement:c,createNewStack:u,dragEvent:m})},[e,n,s]);return b.exports.useEffect(function(){const a=[i(ho.COMPONENT,ho,sd,o)];return()=>{a.forEach(d=>d())}},[o,i]),Be(n.eventHub,xm.OPEN,r),null}function Ty(t){Ps(t);const{hydrate:e,id:n,layout:s,registerComponent:i}=t,o=b.exports.useCallback(({dragEvent:r,fetch:l,panelId:a=$e.generate(),widget:d})=>{const{name:c,type:u}=d;if(u!==dh.VariableType.PANDAS)return;const m={name:c,table:c},p=()=>l().then(C=>Cd.makeModel(C)),g={type:"react-component",component:Ro.COMPONENT,props:{localDashboardId:n,id:a,metadata:m,makeModel:p},title:c,id:a},{root:f}=s;ie.openComponent({root:f,config:g,dragEvent:r})},[n,s]);return b.exports.useEffect(function(){const l=[i(Ro.COMPONENT,Ro,e)];return()=>{l.forEach(a=>a())}},[e,i]),Be(s.eventHub,Ee.OPEN,o),null}class un{}un.DROPDOWN_FILTER="ControlType.DROPDOWN_FILTER";un.INPUT_FILTER="ControlType.INPUT_FILTER";un.MARKDOWN="ControlType.MARKDOWN";un.FILTER_SET_MANAGER="ControlType.FILTER_SET_MANAGER";const vy=M.exports.shape({state:M.exports.shape({panelState:M.exports.shape({})})}),Ey=M.exports.shape({panelId:M.exports.string.isRequired,columnName:M.exports.string.isRequired,columnType:M.exports.string.isRequired}),oh=M.exports.shape({panelId:M.exports.string.isRequired,columnName:M.exports.string.isRequired}),Qm=M.exports.shape({start:oh,end:oh,id:M.exports.string,isReversed:M.exports.bool}),yy=M.exports.arrayOf(Qm),Ry=M.exports.shape({name:M.exports.string.isRequired,operateAs:M.exports.string.isRequired,groups:M.exports.arrayOf(M.exports.string).isRequired,permissions:M.exports.shape({isSuperUser:M.exports.bool.isRequired,isQueryViewOnly:M.exports.bool.isRequired,isNonInteractive:M.exports.bool.isRequired,canUsePanels:M.exports.bool.isRequired,canCreateDashboard:M.exports.bool.isRequired,canCreateCodeStudio:M.exports.bool.isRequired,canCreateQueryMonitor:M.exports.bool.isRequired,canCopy:M.exports.bool.isRequired,canDownloadCsv:M.exports.bool.isRequired}).isRequired});Object.freeze({LinkPoint:Ey,Link:Qm,Links:yy,Panel:vy,User:Ry});const Iy=(t,e)=>t[e]===null?null:M.exports.bool,Fy=(t,e)=>t[e]===null?null:M.exports.string;Object.freeze({nullableBoolean:Iy,nullableString:Fy});ee.module("StorageTableViewportUpdater");class rh{static makeSortConfig(e,n){return{column:e,direction:n}}static makeFilterConfig(e){const n=[],s=[];return e.forEach((i,o)=>{n.push(i),o>0&&s.push(zt.and)}),{filterItems:n,filterOperators:s}}static combineFilterConfigs(e,n,s=zt.and){return{filterItems:[...e.filterItems,...n.filterItems],filterOperators:[...e.filterOperators,s,...n.filterOperators]}}static makeFilterItem(e,n,s){return{columnName:e,type:n,value:s}}}const ia=ee.module("PouchStorageTable"),Dy="Deephaven.";Ch.plugin(Wp);function Ny(t,e){switch(t){case $.in:case $.contains:return{$regex:new RegExp(`${e}`)};case $.inIgnoreCase:return{$regex:new RegExp(`${e}`,"i")};case $.eq:return{$eq:e};case $.notEq:return{$neq:e};case $.greaterThan:return{$gt:e};case $.greaterThanOrEqualTo:return{$gte:e};case $.lessThan:return{$lt:e};case $.lessThanOrEqualTo:return{$lte:e};case $.startsWith:return{$regex:new RegExp(`^(?${e}).*`)};default:throw new Error(`Unsupported type: ${t}`)}}function _y(t){const{filterItems:e,filterOperators:n}=t;let s=null;for(let i=0;i<e.length;i+=1){const o=e[i],{columnName:r,type:l,value:a}=o,d={[r]:Ny(l,a)};if(i===0)s=d;else if(s!==null&&i-1<n.length){const c=n[i-1];if(c===zt.and)s={$and:[s,d]};else if(c===zt.or)s={$or:[s,d]};else throw new Error(`Unexpected filter operator ${c}, ${d}`)}}if(s==null)throw new Error(`Invalid filter config ${t}`);return s}function oa(t=[]){return{$and:[...t.map(e=>_y(e)),{name:{$gt:null}},{id:{$gt:null}}]}}function My(t,e=!1){return[{id:e?"desc":"asc"},...t?.map(n=>({[n.column]:n.direction}))??[]]}class ky{constructor(e){this.listeners=[],this.itemListeners=new Map,this.currentSize=0,this.currentReverse=!1,this.currentFilter=null,this.currentSort=null,this.db=new Ch(`${Dy}${e}`),this.db._remote=!1,this.db.changes({live:!0,since:"now",include_docs:!0}).on("change",this.dbUpdate.bind(this)),this.db.createIndex({index:{fields:["id","name"]}}),this.refreshInfo()}onUpdate(e){return this.listeners=[...this.listeners,e],()=>{this.listeners=this.listeners.filter(n=>n!==e)}}onItemUpdate(e,n){return this.itemListeners.has(e)||this.itemListeners.set(e,[]),this.itemListeners.set(e,[...this.itemListeners.get(e),n]),this.refreshItem(e),()=>{this.itemListeners.set(e,this.itemListeners.get(e).filter(s=>s!==n))}}close(){this.listeners=[]}get size(){return this.currentSize}get viewport(){return this.currentViewport}setReversed(e){this.currentReverse=e,this.currentViewportData=void 0,this.refreshData()}setViewport(e){this.currentViewport=e,this.refreshInfo(),this.refreshData()}setSorts(e){this.currentSort=e,this.currentViewportData=void 0,this.refreshData()}setFilters(e){this.currentFilter=e,this.currentViewportData=void 0,this.refreshInfo(),this.refreshData()}get data(){return this.currentViewportData}async getViewportData(){return this.viewportUpdatePromise||this.refreshData(),this.viewportUpdatePromise??Promise.resolve({items:[],offset:0})}async put(e){const n={...e,_id:e.id};return await this.db.put(n),n}sendUpdate(){const{listeners:e}=this,n=this.currentViewportData??{items:[],offset:0};for(let s=0;s<e.length;s+=1)e[s](n)}sendItemUpdate(e){const n=this.itemListeners.get(e.id);if(n!==void 0)for(let s=0;s<n.length;s+=1)n[s](e)}dbUpdate(e){ia.debug("Update received",e),this.refreshInfo(),e.doc!==void 0&&this.sendItemUpdate(e.doc),this.refreshData()}async refreshInfo(){try{this.infoUpdatePromise?.cancel(),this.infoUpdatePromise=ye.makeCancelable(this.db.find({selector:oa(this.currentFilter??[]),fields:[]}));const e=await this.infoUpdatePromise;this.currentSize=e.docs.length,this.sendUpdate()}catch(e){if(!ye.isCanceled(e))throw ia.error("Unable to refreshInfo",e),e}}async refreshData(){if(!!this.currentViewport)try{const{currentViewport:e}=this,n=My(this.currentSort,this.currentReverse);this.viewportUpdatePromise?.cancel(),this.viewportUpdatePromise=ye.makeCancelable(this.db.find({selector:oa(this.currentFilter??[]),skip:e.top,limit:e.bottom-e.top+1,sort:n,fields:["id","name"]}).then(i=>({items:i.docs,offset:e.top})));const s=await this.viewportUpdatePromise;return this.currentViewportData=s,this.sendUpdate(),s}catch(e){if(!ye.isCanceled(e))throw ia.error("Unable to refreshData",e),e}}async refreshItem(e){const s=(await this.db.find({selector:{id:e},limit:1})).docs[0];return s!==void 0&&this.sendItemUpdate(s),s}async getSnapshot(e){const n=new Map,s=[{id:this.currentReverse?"desc":"asc"}];return await Promise.all(e.map(async([i,o])=>{const r=o-i+1;return this.db.find({selector:oa(this.currentFilter??[]),skip:i,limit:r,sort:s,fields:["id","name"]}).then(l=>{for(let a=0;a<r;a+=1){const d=i+a;n.set(d,l.docs[a])}})})),n}}class lh extends ky{constructor(e){super(`CommandHistoryStorage.${e}`)}setSearch(e){this.setFilters(e?[rh.makeFilterConfig([rh.makeFilterItem("name",$.contains,e)])]:[])}}const ah=ee.module("PouchCommandHistoryStorage");class xy{constructor(){this.updateTableMap=new Map}getUpdateTable(e){return this.updateTableMap.has(e)||this.updateTableMap.set(e,new lh(e)),this.updateTableMap.get(e)}async getTable(e){return new lh(e)}async addItem(e,n,s,i){return this.updateItem(e,{id:`${new Date().getTime()}`,name:s,data:i})}async updateItem(e,n){const s=this.getUpdateTable(e),o={...await s.refreshItem(n.id)??{},...n};return ah.debug("Updating item",o),await s.put(o),ah.debug("Update saved"),n}listenItem(e,n,s){return this.getUpdateTable(e).onItemUpdate(n,s)}}const Jm="SET_LAYOUT_STORAGE",Oy=t=>({type:Jm,payload:t}),ep="/ide/assets/community-wordmark-app.d2c5c1eb.svg";const Ay=ee.module("FormattingSectionContent");function Ly(t){return t.formatString!=null}function _a(t){const e=t?.querySelector("input, select, textarea");e&&e.focus()}function tp(t,e){return t.defaultFormatString===e.defaultFormatString}function Py(t,e){return tp(t,e)}function Hy(t,e){return tp(t,e)}function np(t){return t!==""&&Vi.isValidColumnName(t)}function Ms(t,e){if(!t||e.formatString==null||!Ly(e))return!1;switch(t){case"datetime":return st.isValid(e);case"decimal":return ke.isValid(e);case"int":return Ze.isValid(e);default:return Ay.warn("Trying to validate format of unknown type"),!0}}function sp(t){const{id:e,isNewRule:n,...s}=t;return s}function ip(t){return np(t.columnName)&&Ms(t.columnType,t.format)}function op(t){const{timestamp:e,timeZone:n,showTimeZone:s,showTSeparator:i,isGlobalOptions:o,legacyGlobalFormat:r}=t,l=new nn([],{timeZone:n,showTimeZone:s,showTSeparator:i}),a=o?st.getGlobalFormats(s,i):st.getFormats(s,i);return r!=null&&!a.includes(r)&&a.unshift(r),h(Se,{children:a.map(d=>{const c=st.makeFormat("",d,st.TYPE_GLOBAL);return h("option",{value:d,"data-testid":"time-format",children:l.getFormattedString(e,N.dataType.DATETIME,"",c)},d)})})}function Uy(){return h(Se,{children:Qr.TIME_ZONES.map(t=>{const{label:e,value:n}=t;return h("option",{value:n,children:e},n)})})}const Ks=ee.module("FormattingSectionContent"),rp=class extends b.exports.PureComponent{constructor(t){super(t),this.getCachedDateTimeFormatOptions=Ie((c,u,m,p=!1,g)=>{const{timestampAtMenuOpen:f}=this.state;return h(op,{timestamp:f,timeZone:c,showTimeZone:u,showTSeparator:m,isGlobalOptions:p,legacyGlobalFormat:g})}),this.debouncedCommitChanges=Je(this.commitChanges.bind(this),rp.inputDebounceTime),this.handleDefaultDateTimeFormatChange=this.handleDefaultDateTimeFormatChange.bind(this),this.handleDefaultDecimalFormatChange=this.handleDefaultDecimalFormatChange.bind(this),this.handleDefaultIntegerFormatChange=this.handleDefaultIntegerFormatChange.bind(this),this.handleShowTimeZoneChange=this.handleShowTimeZoneChange.bind(this),this.handleShowTSeparatorChange=this.handleShowTSeparatorChange.bind(this),this.handleTimeZoneChange=this.handleTimeZoneChange.bind(this),this.handleResetDateTimeFormat=this.handleResetDateTimeFormat.bind(this),this.handleResetDecimalFormat=this.handleResetDecimalFormat.bind(this),this.handleResetIntegerFormat=this.handleResetIntegerFormat.bind(this),this.handleResetTimeZone=this.handleResetTimeZone.bind(this),this.handleTruncateNumbersWithPoundChange=this.handleTruncateNumbersWithPoundChange.bind(this);const{formatter:e,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,showTimeZone:o,showTSeparator:r,timeZone:l,truncateNumbersWithPound:a}=t,d=e.map((c,u)=>({...c,id:u}));this.containerRef=de.createRef(),this.state={formatSettings:d,showTimeZone:o,showTSeparator:r,timeZone:l,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,truncateNumbersWithPound:a,timestampAtMenuOpen:new Date}}componentDidMount(){_a(this.containerRef.current)}componentWillUnmount(){this.debouncedCommitChanges.flush()}handleDefaultDateTimeFormatChange(t){Ks.debug("handleDefaultDateTimeFormatChange",t.target.value),this.setState({defaultDateTimeFormat:t.target.value},()=>{this.debouncedCommitChanges()})}handleDefaultDecimalFormatChange(t){Ks.debug("handleDefaultDecimalFormatChange",t.target.value),this.setState({defaultDecimalFormatOptions:{defaultFormatString:t.target.value}},()=>{this.debouncedCommitChanges()})}handleDefaultIntegerFormatChange(t){Ks.debug("handleDefaultIntegerFormatChange",t.target.value),this.setState({defaultIntegerFormatOptions:{defaultFormatString:t.target.value}},()=>{this.debouncedCommitChanges()})}handleShowTimeZoneChange(){this.setState(t=>({showTimeZone:!t.showTimeZone}),()=>{this.debouncedCommitChanges()})}handleShowTSeparatorChange(){this.setState(t=>({showTSeparator:!t.showTSeparator}),()=>{this.debouncedCommitChanges()})}handleTimeZoneChange(t){this.setState({timeZone:t.target.value},()=>{this.debouncedCommitChanges()})}handleResetDateTimeFormat(){const{defaults:t}=this.props,{defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s}=t;Ks.debug("handleResetDateTimeFormat"),this.setState({defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s},()=>{this.debouncedCommitChanges()})}handleResetTimeZone(){const{defaults:t}=this.props,{timeZone:e}=t;Ks.debug("handleResetTimeZone"),this.setState({timeZone:e},()=>{this.debouncedCommitChanges()})}handleResetDecimalFormat(){const{defaults:t}=this.props,{defaultDecimalFormatOptions:e}=t;Ks.debug("handleResetDecimalFormat"),this.setState({defaultDecimalFormatOptions:e},()=>{this.debouncedCommitChanges()})}handleResetIntegerFormat(){const{defaults:t}=this.props,{defaultIntegerFormatOptions:e}=t;Ks.debug("handleResetIntegerFormat"),this.setState({defaultIntegerFormatOptions:e},()=>{this.debouncedCommitChanges()})}handleTruncateNumbersWithPoundChange(){this.setState(t=>({truncateNumbersWithPound:!t.truncateNumbersWithPound}),()=>{this.debouncedCommitChanges()})}commitChanges(){const{formatSettings:t,defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s,timeZone:i,defaultDecimalFormatOptions:o,defaultIntegerFormatOptions:r,truncateNumbersWithPound:l}=this.state,a=t.filter(ip).map(sp)??[],{settings:d,saveSettings:c}=this.props,u={...d,formatter:a,defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s,timeZone:i,truncateNumbersWithPound:l};Ms(N.dataType.DECIMAL,ke.makeCustomFormat(o.defaultFormatString))&&(u.defaultDecimalFormatOptions=o),Ms(N.dataType.INT,Ze.makeCustomFormat(r.defaultFormatString))&&(u.defaultIntegerFormatOptions=r),c(u)}render(){const{defaults:t}=this.props,{defaultDateTimeFormat:e,defaultDecimalFormatOptions:n,defaultIntegerFormatOptions:s,timeZone:i,showTimeZone:o,showTSeparator:r,truncateNumbersWithPound:l}=this.state,{defaultFormatString:a=ke.DEFAULT_FORMAT_STRING}=n??{},{defaultFormatString:d=Ze.DEFAULT_FORMAT_STRING}=s??{},c=i===t.timeZone,u=r===t.showTSeparator&&o===t.showTimeZone&&e===t.defaultDateTimeFormat,m=Py(n,t.defaultDecimalFormatOptions),p=Hy(s,t.defaultIntegerFormatOptions);return h("div",{className:"app-settings-formatting-section",ref:this.containerRef,children:v("div",{className:"container-fluid p-0",children:[h("div",{className:"app-settings-menu-description mb-3",children:"Choose the default formatting rule to apply to all table columns based on their type."}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"select-reset-timezone",children:"Time zone"}),h("div",{className:"col pr-0",children:h("select",{className:"custom-select",value:i,onChange:this.handleTimeZoneChange,id:"select-reset-timezone",children:h(Uy,{})})}),h("div",{className:"col-1 btn-col",children:h(V,{kind:"ghost",icon:ti,onClick:this.handleResetTimeZone,tooltip:"Reset Time Zone",className:K("btn-reset","btn-reset-time-zone",{hidden:c})})})]}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"select-default-time-format",children:"DateTime"}),h("div",{className:"col pr-0",children:h("select",{className:"custom-select",value:e,onChange:this.handleDefaultDateTimeFormatChange,id:"select-default-time-format",children:this.getCachedDateTimeFormatOptions(i,o,r,!0,e)})}),h("div",{className:"col-1 btn-col",children:h(V,{kind:"ghost",icon:ti,onClick:this.handleResetDateTimeFormat,tooltip:"Reset DateTime Options",className:K("btn-reset","btn-reset-date-time",{hidden:u})})})]}),h("div",{className:"form-row",children:h("div",{className:"offset-3 col-9",children:h(mn,{checked:o??null,onChange:this.handleShowTimeZoneChange,children:"Show time zone in dates"})})}),h("div",{className:"form-row mb-3",children:h("div",{className:"offset-3 col-9",children:h(mn,{checked:r??null,onChange:this.handleShowTSeparatorChange,children:"Show 'T' separator"})})}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"default-decimal-format-input",children:"Decimal"}),h("div",{className:"col pr-0",children:h("input",{className:K("form-control","flex-grow-1","default-decimal-format-input",{"is-invalid":!Ms(N.dataType.DECIMAL,ke.makeCustomFormat(a))}),"data-lpignore":!0,placeholder:ke.DEFAULT_FORMAT_STRING,type:"text",id:"default-decimal-format-input",value:a,onChange:this.handleDefaultDecimalFormatChange})}),h("div",{className:"col-1 btn-col",children:h(V,{kind:"ghost",icon:ti,onClick:this.handleResetDecimalFormat,tooltip:"Reset Decimal Formatting",className:K("btn-reset","btn-reset-decimal",{hidden:m}),"data-testid":"btn-reset-decimal"})})]}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"default-integer-format-input",children:"Integer"}),h("div",{className:"col pr-0",children:h("input",{className:K("form-control","flex-grow-1","default-integer-format-input",{"is-invalid":!Ms(N.dataType.INT,Ze.makeCustomFormat(d))}),"data-lpignore":!0,placeholder:Ze.DEFAULT_FORMAT_STRING,type:"text",id:"default-integer-format-input",value:d,onChange:this.handleDefaultIntegerFormatChange})}),h("div",{className:"col-1 btn-col",children:h(V,{kind:"ghost",icon:ti,onClick:this.handleResetIntegerFormat,tooltip:"Reset Integer Formatting",className:K("btn-reset","btn-reset-integer",{hidden:p}),"data-testid":"btn-reset-integer"})})]}),h("div",{className:"form-row mb-3",children:h("div",{className:"offset-3 col-9",children:h(mn,{checked:l??null,onChange:this.handleTruncateNumbersWithPoundChange,children:"Truncate numbers with #"})})})]})})}};let Od=rp;Od.defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:st.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:ke.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:Ze.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:st.DEFAULT_TIME_ZONE_ID}};Od.inputDebounceTime=250;const Vy=t=>({formatter:uu(t),defaultDateTimeFormat:du(t),defaultDecimalFormatOptions:cu(t),defaultIntegerFormatOptions:hu(t),showTimeZone:mu(t),showTSeparator:pu(t),truncateNumbersWithPound:gu(t),timeZone:Ao(t),settings:Et(t)}),By=vt(Vy,{saveSettings:fl})(Od);function $y(){const[t,e]=b.exports.useState(!1),n=()=>{e(!t)};return v(V,{kind:"ghost",onClick:n,icon:lf,children:["Legal Notices",v(sl,{isOpen:t,toggle:n,className:"theme-bg-light",children:[h(il,{toggle:n,children:"Legal Notice"}),v(ol,{children:[h("p",{children:"Deephaven software is protected by U.S. Patent Nos. 9,612,959; 9,613,018; 9,613,109; 9,619,210; 9,633,060; 9,639,570; 9,672,238; 9,679,006; 9,690,821; 9,710,511; 9,760,591; 9,805,084; 9,836,495; 9,836,494; 9,886,469; 9,898,496; 9,934,266; 10,002,153; 10,002,154; 10,002,155; 10,003,673; 10,019,138; 10,069,943; 10,176,211; 10,198,465; 10,198,466; 10,198,469; 10,212,257; 10,241,960; 10,241,965; 10,242,040; 10,242,041; 10,353,893; 10,346,394; 10,452,649; 10,496,639; 10,540,351; 10,552,412; 10,565,194; 10,565,206; 10,572,474; 10,621,168; 10,642,829; 10,657,184; 10,678,787; 10,691,686; and 10,783,191. Other patents pending."}),v("p",{children:["\xA9 2016-",new Date().getFullYear()," Deephaven Data Labs LLC. Patent Pending."]})]})]})]})}function Fo(t){const{children:e,isExpanded:n,sectionKey:s,title:i,onToggle:o}=t;return v(Se,{children:[h("div",{children:v(V,{kind:"ghost",className:"btn-collapse-trigger",onClick:()=>o(s),children:[h("div",{className:"flex-grow-1",children:i}),h("div",{className:"flex-shrink-0",children:h(J,{transform:n?"flip-v":"",icon:ts})})]})}),h(af,{in:n,autoFocusOnShow:!0,children:e})]})}Fo.propTypes={children:M.exports.node,isExpanded:M.exports.bool.isRequired,sectionKey:M.exports.string.isRequired,title:M.exports.node.isRequired,onToggle:M.exports.func};Fo.defaultProps={children:null,onToggle:()=>{}};function Gy({shortcut:t,displayText:e,categoryName:n,onChange:s}){const[i,o]=b.exports.useState(e),[r,l]=b.exports.useState(t.getKeyState()),[a,d]=b.exports.useState(!1),[c,u]=b.exports.useState("");b.exports.useEffect(function(){o(e),l(t.getKeyState())},[e,t]),b.exports.useEffect(function(){o(fn.getDisplayText(r)),t.matchesKeyState(r)&&d(!1)},[r,t]),b.exports.useEffect(function(){if(a){if(!fn.isValidKeyState(r)){fn.isAllowedKey(r.keyValue)?u("Must contain a modifier key"):u("Must contain an allowed action key");return}const y=qe.getConflictingShortcuts(r).filter(E=>E.id.startsWith(n)&&E!==t).map(E=>E.name);if(y.length){u(`Conflicts with ${y.join(", ")}`);return}u("")}else u("")},[a,r,n,t]);function m(T){if(T.stopPropagation(),T.preventDefault(),t.isEditable&&!T.repeat){const y=fn.getKeyStateFromEvent(T),E=fn.createKeyState([Fe.BACKSPACE]);fn.doKeyStatesMatch(y,E)?l(fn.NULL_KEY_STATE):l(y)}}function p(T){T.stopPropagation(),T.preventDefault(),t.matchesKeyState(r)||d(!0)}function g(){Hn.disableAllActions()}function f(){Hn.enableAllActions()}function C(){t.setKeyState(r),d(!1),s(t)}function S(){const T=t.getKeyState();l(T),d(!1)}function w(){d(!0),l(t.getDefaultKeyState())}return v(Se,{children:[v("div",{className:"shortcut-item-container",children:[v("label",{className:"shortcut-item-name",children:[t.name,t.tooltip!==void 0&&h(ut,{children:t.tooltip})]}),v("div",{className:"shortcut-item-input-container",children:[h("input",{className:K("form-control",{"is-invalid":c}),onKeyDown:m,onKeyUp:p,onFocus:g,onBlur:f,disabled:!t.isEditable,value:i,readOnly:!0}),!fn.doKeyStatesMatch(r,t.getDefaultKeyState())&&!c&&h(V,{className:"reset-to-default-button",kind:"ghost",icon:h(J,{icon:ti,transform:{rotate:90,flipX:!0}}),tooltip:"Reset to default",onClick:w})]})]}),a&&v("div",{className:K("shortcut-item-message-container",{"is-invalid":c}),children:[h("div",{className:"shortcut-item-message",children:c}),v("div",{className:"shortcut-item-message-buttons",children:[fn.isValidKeyState(r)&&h(V,{kind:"ghost",onClick:C,children:"Confirm"}),h(V,{kind:"ghost",onClick:S,children:"Undo"})]})]})]})}function Wy({shortcutOverrides:t={},settings:e,saveSettings:n}){const s=b.exports.useCallback(l=>{const a=fn.isMacPlatform,d={mac:{...t.mac},windows:{...t.windows}},c=a?d.mac:d.windows;l.forEach(u=>{u.isDefault()?delete c[u.id]:c[u.id]=u.getKeyState()}),n({...e,shortcutOverrides:d})},[e,n,t]);let i=Array.from(qe.shortcutsByCategory.entries()).map(([l,a])=>({name:l,shortcuts:a}));const o=i.findIndex(l=>l.name.toUpperCase()==="GLOBAL"),r=i.splice(o,1);return i=i.concat(r),v(Se,{children:[h("div",{className:"app-settings-menu-description",children:"Customize shortcuts below. To prevent unexpected results, avoid conflicting shortcuts with the browser or IDE editor."}),i.map(l=>h(zy,{name:l.name,shortcuts:l.shortcuts,saveShortcutOverrides:s},l.name))]})}function zy({name:t,shortcuts:e,saveShortcutOverrides:n}){function s(a){return a.split("_").map(d=>`${d[0].toUpperCase()}${d.slice(1).toLowerCase()}`).join(" ")}const[i,o]=b.exports.useState(e);function r(a){const d=i.filter(u=>u!==a&&!u.isNull()&&u.matchesKeyState(a.getKeyState()));d.forEach(u=>u.setToNull());const c=[a,...d];n(c),o(u=>[...u])}const l=b.exports.useMemo(()=>i.map(a=>a.getDisplayText()),[i]);return v("div",{className:"mt-3",children:[h("div",{className:"font-weight-bold",children:s(t)}),i.map((a,d)=>h(Gy,{shortcut:a,displayText:l[d],categoryName:t,onChange:r},a.id))]})}const qy=t=>({settings:Et(t),shortcutOverrides:sS(t)}),Yy={saveSettings:fl},Ky=vt(qy,Yy)(Wy),Xy="yyyy-MM-dd-HHmmss";function lp(t,e="root",n=new Map([[t,""]])){const s={};return Object.entries(t).forEach(([i,o])=>{try{JSON.stringify(o),s[i]=o}catch{const l=o;if(typeof o=="bigint")s[i]=o.toString();else if(n.has(l))s[i]=`Circular ref to ${n.get(l)}`;else{const a=`${e}.${i}`;n.set(l,a),s[i]=lp(o,a,n)}}}),s}function jy(){const t=Sl.getState();return JSON.stringify(lp(t),null,2)}function Zy(t){const e={uiVersion:"0.31.4",userAgent:navigator.userAgent,...t};return JSON.stringify(e,null,2)}async function Qy(t=`${I.i18n.DateTimeFormat.format(Xy,new Date)}_support_logs`,e){const n=new Sh,s=n.folder(t);s.file("console.txt",df.getFormattedHistory()),s.file("redux.json",jy()),s.file("metadata.json",Zy(e));const i=await n.generateAsync({type:"blob"}),o=document.createElement("a");o.href=URL.createObjectURL(i),o.download=`${t}.zip`,o.click()}const Jy=[{value:N.dataType.DATETIME,label:"DateTime"},{value:N.dataType.DECIMAL,label:"Decimal"},{value:N.dataType.INT,label:"Integer"}];function eR(){const t=Jy.map(e=>h("option",{value:e.value,children:e.label},`key-columnType-${e.value}`));return v(Se,{children:[h("option",{disabled:!0,value:"",children:"Select Type"},"key-columnType-placeholder"),t]})}const ap=class extends b.exports.PureComponent{constructor(t){super(t),this.getCachedColumnTypeOptions=Ie(()=>h(eR,{})),this.getCachedDateTimeFormatOptions=Ie((c,u,m,p=!1,g)=>{const{timestampAtMenuOpen:f}=this.state;return h(op,{timestamp:f,timeZone:c,showTimeZone:u,showTSeparator:m,isGlobalOptions:p,legacyGlobalFormat:g})}),this.debouncedCommitChanges=Je(this.commitChanges.bind(this),ap.inputDebounceTime),this.handleFormatRuleEntered=this.handleFormatRuleEntered.bind(this),this.handleFormatRuleChange=this.handleFormatRuleChange.bind(this),this.handleFormatRuleCreate=this.handleFormatRuleCreate.bind(this),this.handleFormatRuleDelete=this.handleFormatRuleDelete.bind(this);const{formatter:e,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,showTimeZone:o,showTSeparator:r,timeZone:l,truncateNumbersWithPound:a}=t,d=e.map((c,u)=>({...c,id:u}));this.containerRef=de.createRef(),this.addFormatRuleButtonRef=de.createRef(),this.lastFormatRuleIndex=d.length,this.state={formatSettings:d,formatRulesChanged:!1,showTimeZone:o,showTSeparator:r,timeZone:l,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,truncateNumbersWithPound:a,timestampAtMenuOpen:new Date}}componentDidMount(){_a(this.containerRef.current)}componentWillUnmount(){this.debouncedCommitChanges.flush()}isDuplicateRule(t){const{formatSettings:e}=this.state;return e.some(n=>n.id!==t.id&&n.columnName===t.columnName&&n.columnType===t.columnType)??!1}getAutoIncrementFormatRuleIndex(){const{lastFormatRuleIndex:t}=this;return this.lastFormatRuleIndex+=1,t}handleFormatRuleChange(t,e,n){this.setState(s=>{const{formatSettings:i}=s;k(i);const o=[...i];let r={};e==="columnType"&&(r={format:""});const l={...o[t],...r,[e]:n};return o[t]=l,{formatSettings:o}},()=>{this.debouncedCommitChanges()})}handleFormatRuleCreate(){this.setState(t=>{const{formatSettings:e}=t,n={columnType:N.dataType.DATETIME,columnName:"",format:{},id:this.getAutoIncrementFormatRuleIndex(),isNewRule:!0};return{formatSettings:e!=null?[...e,n]:[n],formatRulesChanged:!0}})}handleFormatRuleDelete(t){this.setState(e=>{const{formatSettings:n}=e;return{formatSettings:n.filter((i,o)=>o!==t),formatRulesChanged:!0}},()=>{this.debouncedCommitChanges()})}handleFormatRuleEntered(t){this.scrollToFormatBlockBottom(),_a(t)}commitChanges(){const{formatSettings:t,defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s,timeZone:i,defaultDecimalFormatOptions:o,defaultIntegerFormatOptions:r,truncateNumbersWithPound:l}=this.state,a=t.filter(ip).map(sp)??[],{settings:d,saveSettings:c}=this.props,u={...d,formatter:a,defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s,timeZone:i,truncateNumbersWithPound:l};Ms(N.dataType.DECIMAL,ke.makeCustomFormat(o.defaultFormatString))&&(u.defaultDecimalFormatOptions=o),Ms(N.dataType.INT,Ze.makeCustomFormat(r.defaultFormatString))&&(u.defaultIntegerFormatOptions=r),c(u)}scrollToFormatBlockBottom(){const{scrollTo:t}=this.props;t(0,(this.addFormatRuleButtonRef.current?.offsetHeight??0)+(this.addFormatRuleButtonRef.current?.offsetTop??0))}getRuleError(t){const e={hasColumnNameError:!1,hasFormatError:!1,message:""},n=[];return t.isNewRule!==void 0&&t.isNewRule||(this.isDuplicateRule(t)&&(e.hasColumnNameError=!0,n.push("Duplicate column name/type combo.")),np(t.columnName)||(e.hasColumnNameError=!0,n.push("Column names must start with a letter or underscore and contain only alphanumeric characters or underscores.")),t.format.formatString!==void 0&&t.format.formatString.length===0?(e.hasFormatError=!0,n.push("Empty formatting rule.")):Ms(t.columnType,t.format)||(e.hasFormatError=!0,n.push("Invalid formatting rule.")),e.message=n.join(`
38
+ `)),e}renderFormatRule(t,e){const n=`input-${t}-columnName`,s=`input-${t}-columnType`,i=`input-${t}-format`,o=this.getCachedColumnTypeOptions(),r=c=>this.handleFormatRuleChange(t,"columnName",c.target.value),l=()=>this.handleFormatRuleChange(t,"isNewRule",!1),a=c=>this.handleFormatRuleChange(t,"columnType",c.target.value),d=this.getRuleError(e);return v("fieldset",{className:"container-fluid format-rule-container",children:[v("div",{className:"form-row",children:[v("div",{className:"form-group col-7 mb-2",children:[h("label",{htmlFor:n,children:"Column Name"}),h("input",{id:n,className:K("form-control",{"is-invalid":d.hasColumnNameError}),"data-lpignore":!0,type:"text",value:e.columnName,onChange:r,onBlur:l})]}),v("div",{className:"form-group col mb-2",children:[h(V,{kind:"ghost",className:"btn-delete-format-rule float-right",tabIndex:-1,onClick:()=>this.handleFormatRuleDelete(t),icon:sn,tooltip:"Delete","aria-label":"Delete Format Rule"}),h("label",{htmlFor:s,children:"Column Type"}),h("select",{id:s,className:"custom-select",value:e.columnType,onChange:a,children:o})]})]}),h("div",{className:"form-row",children:v("div",{className:"form-group col-12 d-flex mb-2",children:[h("label",{className:"flex-shrink-0 col-form-label mr-3",htmlFor:i,children:"Formatting Rule"}),this.renderFormatRuleInput(t,e.columnType,i,e.format,d.hasFormatError)]})}),h("div",{className:"form-row",children:h("div",{className:"form-group col-12 d-flex mb-2",children:d.message&&h("p",{className:"text-danger",children:d.message})})})]},t)}renderFormatRuleInput(t,e,n,s,i){switch(N.getNormalizedType(e)){case N.dataType.DATETIME:return this.renderDateTimeFormatRuleInput(t,n,s,i);case N.dataType.DECIMAL:return this.renderDecimalFormatRuleInput(t,n,s,i);case N.dataType.INT:return this.renderIntegerFormatRuleInput(t,n,s,i);default:throw new Error(`Unrecognized column type: ${e}`)}}renderDateTimeFormatRuleInput(t,e,n,s){const{showTimeZone:i,showTSeparator:o,timeZone:r}=this.state,l=n.formatString??"";return v("select",{className:K("custom-select",{"is-invalid":s}),value:l,id:e,onChange:a=>{const d=st.makeFormat("",a.target.value,st.TYPE_GLOBAL);this.handleFormatRuleChange(t,"format",d)},children:[h("option",{value:"",disabled:!0,children:"Select format"},"default"),this.getCachedDateTimeFormatOptions(r,i,o)]})}renderIntegerFormatRuleInput(t,e,n,s){const i=n.formatString??"";return h("input",{className:K("form-control","flex-grow-1",{"is-invalid":s}),"data-lpignore":!0,id:e,placeholder:Ze.DEFAULT_FORMAT_STRING,type:"text",value:i,onChange:o=>{const r=Ze.makeFormat("",o.target.value,Ze.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(t,"format",r)}})}renderDecimalFormatRuleInput(t,e,n,s){const i=n.formatString??"";return h("input",{className:K("form-control","flex-grow-1",{"is-invalid":s}),"data-lpignore":!0,id:e,placeholder:ke.DEFAULT_FORMAT_STRING,type:"text",value:i,onChange:o=>{const r=ke.makeFormat("",o.target.value,ke.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(t,"format",r)}})}render(){const{formatRulesChanged:t,formatSettings:e}=this.state,n=e.map((i,o)=>h(Ht,{classNames:"fade",timeout:Xe.transitionMs,onEnter:this.handleFormatRuleEntered,children:this.renderFormatRule(o,i)},i.id)),s=h(V,{kind:"ghost",className:"mb-3",onClick:this.handleFormatRuleCreate,ref:this.addFormatRuleButtonRef,icon:As,children:"Add New Rule"});return v("div",{className:"app-settings-formatting-section",ref:this.containerRef,children:[h("div",{className:"app-settings-menu-description mb-3",children:"Customize the formatting of table columns by applying rules based on matching both a column name and column type."}),h(zp,{appear:t,enter:t,exit:t,children:n}),s]})}};let Ad=ap;Ad.defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:st.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:ke.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:Ze.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:st.DEFAULT_TIME_ZONE_ID}};Ad.inputDebounceTime=250;const tR=t=>({formatter:uu(t),defaultDateTimeFormat:du(t),defaultDecimalFormatOptions:cu(t),defaultIntegerFormatOptions:hu(t),showTimeZone:mu(t),showTSeparator:pu(t),truncateNumbersWithPound:gu(t),timeZone:Ao(t),settings:Et(t)}),nR=vt(tR,{saveSettings:fl})(Ad),Qn=class extends b.exports.Component{constructor(t){super(t),this.handleClose=this.handleClose.bind(this),this.handleScrollTo=this.handleScrollTo.bind(this),this.handleSectionToggle=this.handleSectionToggle.bind(this),this.handleExportSupportLogs=this.handleExportSupportLogs.bind(this),this.menuContentRef=de.createRef(),this.state={expandedSectionKey:Qn.FORMATTING_SECTION_KEY}}static focusFirstInputInContainer(t){const e=t?.querySelector("input, select, textarea");e&&e.focus()}componentDidMount(){Qn.focusFirstInputInContainer(this.menuContentRef.current)}isSectionExpanded(t){const{expandedSectionKey:e}=this.state;return e===t}handleScrollTo(t,e){this.menuContentRef.current?.scrollTo(t,e)}handleSectionToggle(t){this.setState(e=>({expandedSectionKey:e.expandedSectionKey===t?void 0:t}))}handleClose(){const{onDone:t}=this.props;t()}handleExportSupportLogs(){const{serverConfigValues:t}=this.props;Qy(void 0,Object.fromEntries(t))}render(){const t="0.31.4",e="https://github.com/deephaven/web-client-ui/",n="https://deephaven.io/core/docs/",{serverConfigValues:s}=this.props,i=s.get("barrage.version"),o=s.get("java.version"),r=s.get("deephaven.version"),l=(a,d)=>v(Se,{children:[h("div",{children:a}),h("div",{children:d})]});return v("div",{className:"app-settings-menu",children:[v("header",{className:"app-settings-menu-header",children:[h("div",{className:"flex-spacer"}),h(V,{kind:"ghost",className:"btn-close-settings-menu",onClick:this.handleClose,icon:h(J,{icon:Ui,transform:"grow-4"}),tooltip:"Close"})]}),v("div",{className:"app-settings-menu-content",ref:this.menuContentRef,children:[h("h5",{children:"Settings"}),h("hr",{className:"my-0"}),h(Fo,{sectionKey:Qn.FORMATTING_SECTION_KEY,isExpanded:this.isSectionExpanded(Qn.FORMATTING_SECTION_KEY),title:v(Se,{children:[h(J,{icon:cf,transform:"grow-4",className:"mr-2"}),"Default Format & Time zone"]}),onToggle:this.handleSectionToggle,children:h(By,{})}),h(Fo,{sectionKey:Qn.COLUMN_SPECIFIC_SECTION_KEY,isExpanded:this.isSectionExpanded(Qn.COLUMN_SPECIFIC_SECTION_KEY),title:v(Se,{children:[h(J,{icon:hf,transform:"grow-4",className:"mr-2"}),"Format by Column Name & Type"]}),onToggle:this.handleSectionToggle,children:h(nR,{scrollTo:this.handleScrollTo})}),h(Fo,{sectionKey:Qn.SHORTCUT_SECTION_KEY,isExpanded:this.isSectionExpanded(Qn.SHORTCUT_SECTION_KEY),title:v(Se,{children:[h(J,{icon:uf,transform:"grow-2"})," ","Keyboard Shortcuts"]}),onToggle:this.handleSectionToggle,children:h(Ky,{})}),v("div",{className:"app-settings-footer",children:[v("div",{className:"app-settings-footer-section",children:[v("div",{className:"app-settings-footer-item",children:[h("div",{className:"font-weight-bold",children:"Support"}),v("div",{children:["GitHub:\xA0",h("a",{href:e,className:"custom-link",target:"_blank",rel:"noopener noreferrer",children:e})]}),h(V,{kind:"tertiary",className:"mt-2 py-2",onClick:this.handleExportSupportLogs,children:"Export Logs"})]}),v("div",{className:"app-settings-footer-item",children:[h("div",{className:"font-weight-bold",children:"Documentation"}),h("a",{target:"_blank",rel:"noreferrer noopener",href:n,className:"custom-link",children:n})]}),v("div",{className:"app-settings-footer-item",children:[h("div",{className:"font-weight-bold",children:"Version"}),v("span",{className:"d-inline-block text-muted",children:[r," ",h(J,{icon:mf}),v(ut,{interactive:!0,children:[v("div",{className:"detailed-server-config",children:[l("Engine Version",r),l("Web UI Version",t),l("Java Version",o),l("Barrage Version",i)]}),h(al,{tooltip:"Copy version numbers",copy:`Engine Version: ${r}
39
39
  Web UI Version: ${t}
40
40
  Java Version: ${o}
41
- Barrage Version: ${i}`,children:"Copy Versions"})]})]})]}),h("div",{className:"app-settings-footer-item",children:h($y,{})})]}),h("div",{className:"app-settings-footer-section",children:h("div",{className:"logo",children:h("a",{target:"_blank",rel:"noreferrer noopener",href:"https://deephaven.io",className:"d-inline-block custom-link p-1",children:h("img",{src:ep,alt:"Deephaven Data Labs",width:"230px"})})})})]})]})]})}};let ji=Qn;ji.defaultProps={onDone:()=>{}};ji.FORMATTING_SECTION_KEY="SettingsMenu.formatting";ji.COLUMN_SPECIFIC_SECTION_KEY="SettingsMenu.columnFormatting";ji.APPLICATION_SECTION_KEY="ApplicationMenu.settings";ji.SHORTCUT_SECTION_KEY="SettingsMenu.shortcuts";const ch=10;function Fi(t){const{forwardedProps:{menuItem:{action:e,title:n,disabled:s},iconElement:i,displayShortcut:o,isMouseSelected:r,isKeyboardSelected:l,closeMenu:a}}=t,d=b.exports.useRef(),c=b.exports.useRef(),u=b.exports.useRef(null),[m,p]=b.exports.useState(!1),g=b.exports.useCallback(S=>{d.current!=null&&c.current!=null&&u.current&&(Math.abs(d.current-S.clientX)>=ch||Math.abs(c.current-S.clientY)>=ch)&&(p(!0),window.removeEventListener("mousemove",g),a(),e(S),u.current=null)},[e,a]);function f(S){d.current=S.clientX,c.current=S.clientY,u.current=S.target,window.addEventListener("mousemove",g)}function C(S){u.current===S.target&&(p(!0),a(),e(),window.removeEventListener("mousemove",g)),u.current=null}return b.exports.useEffect(function(){return function(){return window.removeEventListener("mousemove",g)}},[g]),v("button",{type:"button",className:K("btn-context-menu",{disabled:s},{active:r&&!s},{"keyboard-active":l&&!s}),onMouseDown:f,onMouseUp:C,disabled:m,children:[h("span",{className:K("icon"),children:i}),h("span",{className:"title",children:n}),h("span",{className:"shortcut",children:o})]})}function Ld(t){const{handleControlSelect:e,handleToolSelect:n,onClearFilter:s}=t,i=b.exports.useMemo(()=>[{title:"Input Filter",icon:pf,menuElement:h(Fi,{}),action:o=>{e(un.INPUT_FILTER,o)},order:10},{title:"Dropdown Filter",icon:Dh,menuElement:h(Fi,{}),action:o=>{e(un.DROPDOWN_FILTER,o)},order:15},{title:"Markdown Widget",icon:gf,menuElement:h(Fi,{}),action:o=>{e(un.MARKDOWN,o)},order:20},{title:"Filter Sets",icon:ca,menuElement:h(Fi,{}),action:o=>{e(un.FILTER_SET_MANAGER,o)},order:25},{disabled:!0,menuElement:h("div",{className:"context-menu-group-header",children:"Tools"}),order:30},{title:"Linker",icon:yh,action:()=>{n(Wt.LINKER)},order:40,shortcut:ls.LINKER},{disabled:!0,menuElement:h("div",{className:"context-menu-group-header",children:"Actions"}),order:50},{title:"Clear All Filters",icon:ff,action:()=>{s()},order:60,shortcut:en.TABLE.CLEAR_ALL_FILTERS}],[e,n,s]);return h(ns,{popperClassName:"controls-menu-popper",actions:i})}Ld.propTypes={handleControlSelect:M.exports.func,handleToolSelect:M.exports.func,onClearFilter:M.exports.func};Ld.defaultProps={handleControlSelect:()=>{},handleToolSelect:()=>{},onClearFilter:()=>{}};Fi.propTypes={forwardedProps:M.exports.shape({iconElement:M.exports.node,displayShortcut:M.exports.string,isMouseSelected:M.exports.bool.isRequired,isKeyboardSelected:M.exports.bool.isRequired,closeMenu:M.exports.func.isRequired,menuItem:M.exports.shape({action:M.exports.func,title:M.exports.string,disabled:M.exports.bool}).isRequired})};Fi.defaultProps={forwardedProps:null};const sR=Ls(Jm,null),iR={layoutStorage:sR},oR=t=>t.layoutStorage,rR=t=>t.serverConfigValues;Object.entries(iR).map(([t,e])=>Gi.register(t,e));const hh=10;function lR(t){const{onExportLayout:e,onImportLayout:n,onResetLayout:s,onSelect:i,widgets:o=[]}=t,[r,l]=b.exports.useState(!1),[a,d]=b.exports.useState(""),c=b.exports.useRef(null),u=b.exports.useRef(),m=b.exports.useCallback((y,E)=>{y!=null&&i(y,E)},[i]),p=b.exports.useCallback(y=>{d(y.target.value)},[]),g=b.exports.useCallback(y=>{u.current!=null&&(Math.abs(u.current.x-y.clientX)>=hh||Math.abs(u.current.y-y.clientY)>=hh)&&(l(!0),window.removeEventListener("mousemove",g),m(u.current.widget,y),u.current=void 0)},[u,m]),f=b.exports.useCallback((y,E)=>{u.current={x:y.clientX,y:y.clientY,widget:E},window.addEventListener("mousemove",g)},[g]),C=b.exports.useCallback((y,E)=>{window.removeEventListener("mousemove",g),u.current?.widget===E&&(l(!0),m(E)),u.current=void 0},[g,u,m]),S=b.exports.useMemo(()=>o.filter(y=>a?y.name?.toLowerCase().includes(a.toLowerCase()):!0),[a,o]).sort((y,E)=>y.name?.localeCompare(E.name??"")??0),w=b.exports.useMemo(()=>S.map(y=>h("li",{children:v(V,{kind:"ghost","data-testid":`panel-list-item-${y.name??""}-button`,onMouseDown:E=>{f(E,y)},onMouseUp:E=>{C(E,y)},onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&m(y)},disabled:r,onClick:()=>{},children:[h(Lh,{type:y.type})," ",y.name??""]})},y.name)),[S,r,f,C,m]),T=b.exports.useMemo(()=>w.length===0?h("span",{children:"No bound variables found."}):null,[w]);return v("div",{className:"widget-list-container d-flex flex-column",children:[h("div",{className:"widget-list-header",children:h(Bi,{value:a,placeholder:"Find Table, Plot or Widget",onChange:p,ref:c})}),v("ul",{className:"widget-list flex-grow-1",children:[T&&h("li",{className:"widget-list-message",children:T}),!T&&w]}),h("div",{children:h("hr",{})}),v("div",{className:"widget-list-footer",children:[v(V,{kind:"ghost",onClick:e,children:[v("div",{className:"fa-md fa-layers",children:[h(J,{mask:da,icon:jd,transform:"right-5 down-5"}),h(J,{icon:jd,transform:"right-8 down-6"})]}),"Export Layout"]}),v(V,{kind:"ghost",onClick:n,children:[v("div",{className:"fa-md fa-layers",children:[h(J,{mask:da,icon:ha,transform:"right-5 down-5"}),h(J,{icon:ha,transform:"right-8 down-6"})]}),"Import Layout"]}),h(V,{kind:"ghost",icon:ti,onClick:s,tooltip:"Reset Layout"})]})]})}const aR=async(t,e,n)=>{let s,i,o,r;if(Rr(e)?(s=e.settings,i=e.table,o=void 0,r=e.tableSettings):(s={},i="",o=e.figure,r={}),n!==void 0&&(n.tableSettings!=null&&(r=n.tableSettings),n.table!=null&&(i=n.table),n.figure!=null&&(o=n.figure),n.settings!=null&&(s={...s,...n.settings})),o!==void 0){const d={title:o,name:o,type:I.VariableType.FIGURE},c=await t.getObject(d);return Oi.makeModel(s,c)}const l={title:o,name:i,type:I.VariableType.TABLE},a=await t.getObject(l);return te.applyTableSettings(a,r,Ao(Sl.getState())),Oi.makeModelFromSettings(s,a)},dR=async(t,e,n=I.VariableType.TABLE)=>{const{table:s}=e,i={title:s,name:s,type:n},o=await t.getObject(i);return Cd.makeModel(o)};function cR({onAutoFillClick:t=()=>{}}){return v("div",{className:"empty-dashboard-container",children:[v("div",{className:"hint-container",children:[h(J,{icon:Fh})," ",h("br",{}),"Use the panel list to add objects from a query."]}),v("div",{className:"empty-dashboard",children:[h("div",{className:"add-panels-hint",children:"Drag Panels Here"}),h(V,{kind:"tertiary",onClick:t,children:"Auto fill objects"})]})]})}function hR(t){return t.version===2}function uR(t){return Array.isArray(t)}const Tr=ee.module("UserLayoutUtils"),mR={layoutConfig:[{type:"column",content:[{type:"row",height:40,content:[{type:"stack",content:[{type:"react-component",component:Ii.COMPONENT,title:Ii.TITLE,isClosable:!1},{type:"react-component",component:Xr.COMPONENT,title:Xr.TITLE,isClosable:!1}]},{type:"stack",width:25,content:[{type:"react-component",component:qr.COMPONENT,title:qr.TITLE,isClosable:!1},{type:"react-component",component:Yr.COMPONENT,title:Yr.TITLE,isClosable:!1}]}]},{type:"row",content:[{type:"stack",title:"Notebooks",content:[]}]}]}],links:[],filterSets:[],version:2},pR={layoutConfig:[],links:[],filterSets:[],version:2};function dp(t){if(hR(t))return t;if(uR(t))return{layoutConfig:t,links:[],filterSets:[],version:2};throw new Error(`Unexpected layout import format: ${t}`)}async function gR(t,e=!0){try{const n=await t.getLayouts();if(n.length>0)try{const s=await t.getLayout(n[0]);return dp(s)}catch(s){Tr.error("Unable to load layout",n[0],":",s),Tr.warn("No valid layouts found, falling back to default layout")}}catch(n){Tr.error("Unable to fetch layout list",n),Tr.warn("Falling back to default layout")}return e?mR:pR}function fR(t){const{filterSets:e,layoutConfig:n,links:s}=t;return{filterSets:e,layoutConfig:n,links:s,version:2}}const _r={exportLayout:fR,getDefaultLayout:gR,normalizeLayout:dp},vr=ee.module("DownloadServiceWorkerUtils"),cp=class{static registerOnLoaded(){new URL("/ide/",window.location.href).origin===window.location.origin&&("serviceWorker"in navigator?window.addEventListener("load",()=>{const e=new URL("/ide/download/serviceWorker.js",window.location.href);navigator.serviceWorker.register(e).then(n=>{n.update(),vr.info("Registering service worker on ",e,n)}).catch(n=>{vr.error("Failed to register service worker",n)})}):vr.info("Service worker is not supported."))}static async getServiceWorker(){if("serviceWorker"in navigator){const e=(await navigator.serviceWorker.getRegistrations()).find(n=>n.scope.endsWith(cp.DOWNLOAD_PATH));if(e&&e.active)return vr.info("Download service worker is active."),e.active;throw new Error("Can not find download service worker.")}throw new Error("Download service worker is not available.")}static unregisterSW(){}};let jr=cp;jr.DOWNLOAD_PATH="/download/";const hp={react:de,"react-dom":No,redux:qp,"react-redux":Yp},CR=Kp(hp),SR=Xp({requires:CR}),bR=jp.createRequires(hp),wR=Zp({requires:bR}),TR=ee.module("PluginUtils");class Ma{static loadComponentPlugin(e){if("".split(",").includes(e)){const o=de.lazy(()=>bf(()=>import(`./internal/${e}`),[])),r=de.forwardRef((l,a)=>h(b.exports.Suspense,{fallback:h("div",{children:"Loading Plugin..."}),children:h(o,{ref:a,...l})}));return r.pluginName=e,r.displayName="Local Plugin",r}const n=new URL("/ide/plugins/",`${window.location}`),s=new URL(`${e}.js`,n),i=de.forwardRef((o,r)=>h(SR,{url:s,render:({err:l,Component:a})=>{if(l!=null&&l!==""){const d=`Error loading plugin ${e} from ${s} due to ${l}`;return TR.error(d),h("div",{className:"error-message",children:`${d}`})}return h(a,{ref:r,...o})}}));return i.pluginName=e,i.displayName="Plugin",i}static async loadModulePlugin(e){return await wR(e)}static async loadJson(e){return new Promise((n,s)=>{const i=new XMLHttpRequest;i.addEventListener("load",()=>{try{const o=JSON.parse(i.responseText);n(o)}catch(o){s(o)}}),i.addEventListener("error",o=>{s(o)}),i.open("GET",e),i.send()})}}const Ot=ee.module("AppMainContainer");class Do extends b.exports.Component{constructor(e){super(e),this.getDashboardPlugins=ge(n=>[...n.entries()].filter(([,s])=>s.DashboardPlugin!=null).map(([s,{DashboardPlugin:i}])=>h(i,{},s))),this.handleSettingsMenuHide=this.handleSettingsMenuHide.bind(this),this.handleSettingsMenuShow=this.handleSettingsMenuShow.bind(this),this.handleError=this.handleError.bind(this),this.handleControlSelect=this.handleControlSelect.bind(this),this.handleToolSelect=this.handleToolSelect.bind(this),this.handleClearFilter=this.handleClearFilter.bind(this),this.handleDataChange=this.handleDataChange.bind(this),this.handleAutoFillClick=this.handleAutoFillClick.bind(this),this.handleGoldenLayoutChange=this.handleGoldenLayoutChange.bind(this),this.handleLayoutConfigChange=this.handleLayoutConfigChange.bind(this),this.handleExportLayoutClick=this.handleExportLayoutClick.bind(this),this.handleImportLayoutClick=this.handleImportLayoutClick.bind(this),this.handleImportLayoutFiles=this.handleImportLayoutFiles.bind(this),this.handleLoadTablePlugin=this.handleLoadTablePlugin.bind(this),this.handleResetLayoutClick=this.handleResetLayoutClick.bind(this),this.handleWidgetMenuClick=this.handleWidgetMenuClick.bind(this),this.handleWidgetsMenuClose=this.handleWidgetsMenuClose.bind(this),this.handleWidgetSelect=this.handleWidgetSelect.bind(this),this.handlePaste=this.handlePaste.bind(this),this.hydrateChart=this.hydrateChart.bind(this),this.hydrateGrid=this.hydrateGrid.bind(this),this.hydratePandas=this.hydratePandas.bind(this),this.hydrateDefault=this.hydrateDefault.bind(this),this.openNotebookFromURL=this.openNotebookFromURL.bind(this),this.importElement=de.createRef(),this.state={contextActions:[{action:()=>{this.handleToolSelect(Wt.LINKER)},shortcut:ls.LINKER,isGlobal:!0},{action:()=>{this.sendClearFilter()},shortcut:en.TABLE.CLEAR_ALL_FILTERS,isGlobal:!0},{action:()=>{Ot.debug("Consume unhandled save shortcut")},shortcut:ls.SAVE,isGlobal:!0}],isPanelsMenuShown:!1,isSettingsMenuShown:!1,widgets:[]}}static handleWindowBeforeUnload(e){e.preventDefault(),e.returnValue=""}static hydrateConsole(e,n){return wa.hydrate({...e,unzip:s=>Sh.loadAsync(s).then(i=>Object.values(i.files))},n)}componentDidMount(){this.initWidgets(),window.addEventListener("beforeunload",Do.handleWindowBeforeUnload)}componentDidUpdate(e){const{dashboardData:n}=this.props;e.dashboardData!==n&&this.handleDataChange(n)}componentWillUnmount(){this.deinitWidgets(),window.removeEventListener("beforeunload",Do.handleWindowBeforeUnload)}initWidgets(){const{connection:e}=this.props;if(e.subscribeToFieldUpdates==null){Ot.warn("subscribeToFieldUpdates not supported, not initializing widgets");return}this.widgetListenerRemover=e.subscribeToFieldUpdates(n=>{Ot.debug("Got updates",n),this.setState(({widgets:s})=>{const{updated:i,created:o,removed:r}=n,l=[...i,...r],a=s.filter(c=>!l.some(u=>u.name===c.name));return[...i,...o].forEach(c=>{c.name!=null&&c.name!==""&&a.push(c)}),{widgets:a}})})}deinitWidgets(){this.widgetListenerRemover?.()}openNotebookFromURL(){const{match:e}=this.props,{notebookPath:n}=e.params;if(n){const{session:s,sessionConfig:i}=this.props;if(s==null||i==null){Ot.error("No session available to open notebook URL",n);return}const o={id:`/${n}`,itemName:`/${n}`},r=i.type,l={value:null,language:r};this.emitLayoutEvent(Ae.SELECT_NOTEBOOK,s,r,l,o,!0)}}sendClearFilter(){this.emitLayoutEvent(Le.CLEAR_ALL_FILTERS)}emitLayoutEvent(e,...n){this.goldenLayout?.eventHub.emit(e,...n)}handleError(e){ye.isCanceled(e)||Ot.error(e)}handleSettingsMenuHide(){this.setState({isSettingsMenuShown:!1})}handleSettingsMenuShow(){this.setState({isSettingsMenuShown:!0})}handleControlSelect(e,n=null){switch(Ot.debug("handleControlSelect",e),e){case un.DROPDOWN_FILTER:this.emitLayoutEvent(Le.OPEN_DROPDOWN,{title:"DropdownFilter",type:e,createNewStack:!0,dragEvent:n});break;case un.INPUT_FILTER:this.emitLayoutEvent(Le.OPEN_INPUT,{title:"InputFilter",type:e,createNewStack:!0,dragEvent:n});break;case un.MARKDOWN:this.emitLayoutEvent(xm.OPEN,{title:"Markdown",type:e,dragEvent:n});break;case un.FILTER_SET_MANAGER:this.emitLayoutEvent(Le.OPEN_FILTER_SET_MANAGER,{title:"FilterSets",type:e,dragEvent:n});break;default:throw new Error(`Unrecognized control type ${e}`)}}handleToolSelect(e){Ot.debug("handleToolSelect",e);const{activeTool:n,setActiveTool:s}=this.props;s(n===e?Wt.DEFAULT:e)}handleClearFilter(){this.sendClearFilter()}handleDataChange(e){const{updateWorkspaceData:n}=this.props,{closed:s,filterSets:i,links:o}=e;n({closed:s,filterSets:i,links:o})}handleGoldenLayoutChange(e){this.goldenLayout=e}handleLayoutConfigChange(e){const{updateWorkspaceData:n}=this.props;n({layoutConfig:e})}handleWidgetMenuClick(){this.setState(({isPanelsMenuShown:e})=>({isPanelsMenuShown:!e}))}handleWidgetSelect(e,n){this.setState({isPanelsMenuShown:!1}),Ot.debug("handleWidgetSelect",e,n),this.openWidget(e,n)}handleWidgetsMenuClose(){this.setState({isPanelsMenuShown:!1})}handleAutoFillClick(){const{widgets:e}=this.state;Ot.debug("handleAutoFillClick",e);const n=e.sort((s,i)=>s.title!=null&&i.title!=null?s.title.localeCompare(i.title):0);for(let s=0;s<n.length;s+=1)this.openWidget(n[s])}handleExportLayoutClick(){Ot.info("handleExportLayoutClick"),this.setState({isPanelsMenuShown:!1});try{const{workspace:e}=this.props,{data:n}=e,s=_r.exportLayout(n);Ot.info("handleExportLayoutClick exportedConfig",s);const i=new Blob([JSON.stringify(s)],{type:"application/json"}),o=I.i18n.DateTimeFormat.format("yyyy-MM-dd-HHmmss",new Date),r=document.createElement("a");r.href=URL.createObjectURL(i),r.download=`deephaven-app-layout-${o}.json`,r.click()}catch(e){Ot.error("Unable to export layout",e)}}handleImportLayoutClick(){Ot.info("handleImportLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.importElement.current!=null&&(this.importElement.current.value="",this.importElement.current.click())}handleResetLayoutClick(){Ot.info("handleResetLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.resetLayout()}handleImportLayoutFiles(e){e.stopPropagation(),e.preventDefault(),e.target.files!=null&&this.importLayoutFile(e.target.files?.[0])}async importLayoutFile(e){try{const{updateDashboardData:n,updateWorkspaceData:s}=this.props,i=await e.text(),o=JSON.parse(i),{filterSets:r,layoutConfig:l,links:a}=_r.normalizeLayout(o);s({layoutConfig:l}),n(bn,{filterSets:r,links:a})}catch(n){Ot.error("Unable to import layout",n)}}async resetLayout(){const{layoutStorage:e,session:n}=this.props,{filterSets:s,layoutConfig:i,links:o}=await _r.getDefaultLayout(e,n!==void 0),{updateDashboardData:r,updateWorkspaceData:l}=this.props;l({layoutConfig:i}),r(bn,{filterSets:s,links:o})}handlePaste(e){if(e.target instanceof HTMLElement&&e.target.closest(".monaco-editor"))return;const{clipboardData:n}=e,s=n.getData("Text"),i=/“|”/g;i.test(s)&&(e.preventDefault(),e.stopPropagation(),document.execCommand("insertText",!1,s.replace(i,'"')))}handleLoadTablePlugin(e){const{plugins:n}=this.props,s=n.get(e);return s!=null&&s.TablePlugin!=null?s.TablePlugin:Ma.loadComponentPlugin(e)}hydrateDefault(e,n){const{connection:s}=this.props,{metadata:i}=e;if(i?.type!=null&&(i?.id!=null||i?.name!=null)){const o=i.id!=null?{type:i.type,id:i.id}:{type:i.type,name:i.name,title:i.name};return{fetch:()=>s.getObject(o),localDashboardId:n,...e}}return wa.hydrate(e,n)}hydrateGrid(e,n){return this.hydrateTable(e,n,e.metadata.type??I.VariableType.TABLE)}hydratePandas(e,n){return this.hydrateTable(e,n,I.VariableType.PANDAS)}hydrateTable(e,n,s=I.VariableType.TABLE){const{connection:i}=this.props;return{...e,getDownloadWorker:jr.getServiceWorker,loadPlugin:this.handleLoadTablePlugin,localDashboardId:n,makeModel:()=>dR(i,e.metadata,s)}}hydrateChart(e,n){const{connection:s}=this.props;return{...e,localDashboardId:n,makeModel:()=>{const{metadata:i,panelState:o}=e;return aR(s,i,o)}}}openWidget(e,n){const{connection:s}=this.props;this.emitLayoutEvent(Ee.OPEN,{dragEvent:n,fetch:()=>s.getObject(e),widget:e})}render(){const{activeTool:e,plugins:n,user:s,workspace:i,serverConfigValues:o}=this.props,{data:r}=i,{layoutConfig:l}=r,{permissions:a}=s,{canUsePanels:d}=a,{contextActions:c,isPanelsMenuShown:u,isSettingsMenuShown:m,widgets:p}=this.state,g=this.getDashboardPlugins(n);return v("div",{className:K("app-main-tabs","w-100","h-100","d-flex","flex-column",e?`active-tool-${e.toLowerCase()}`:""),onPaste:this.handlePaste,tabIndex:-1,children:[h("nav",{className:"nav-container",children:v("div",{className:"app-main-top-nav-menus",children:[h("img",{src:ep,alt:"Deephaven Data Labs",width:"115px",className:"ml-1"}),v("div",{children:[v(V,{kind:"ghost",className:"btn-panels-menu",icon:Cf,onClick:()=>{},children:["Controls",h(Ld,{handleControlSelect:this.handleControlSelect,handleToolSelect:this.handleToolSelect,onClearFilter:this.handleClearFilter})]}),d&&v(V,{kind:"ghost",className:"btn-panels-menu btn-show-panels","data-testid":"app-main-panels-button",onClick:this.handleWidgetMenuClick,icon:Sf,children:["Panels",h(nl,{isShown:u,className:"panels-menu-popper",onExited:this.handleWidgetsMenuClose,closeOnBlur:!0,interactive:!0,children:h(lR,{widgets:p,onExportLayout:this.handleExportLayoutClick,onImportLayout:this.handleImportLayoutClick,onResetLayout:this.handleResetLayoutClick,onSelect:this.handleWidgetSelect})})]}),h(V,{kind:"ghost",className:K("btn-settings-menu",{"text-warning":s.operateAs!==s.name}),onClick:this.handleSettingsMenuShow,icon:h(J,{icon:xo,transform:"grow-3 right-1 down-1"}),tooltip:"User Settings"})]})]})}),v(tw,{emptyDashboard:h(cR,{onAutoFillClick:this.handleAutoFillClick}),id:bn,layoutConfig:l,onGoldenLayoutChange:this.handleGoldenLayoutChange,onLayoutConfigChange:this.handleLayoutConfigChange,onLayoutInitialized:this.openNotebookFromURL,hydrate:this.hydrateDefault,children:[h(my,{hydrate:this.hydrateGrid,getDownloadWorker:jr.getServiceWorker,loadPlugin:this.handleLoadTablePlugin}),h(ly,{hydrate:this.hydrateChart}),h(ay,{}),h(cy,{hydrateConsole:Do.hydrateConsole,notebooksUrl:new URL("/notebooks/",`${window.location}`).href}),h(hy,{}),h(Ty,{hydrate:this.hydratePandas}),h(wy,{}),h(by,{}),g]}),h(Ht,{in:m,timeout:Xe.transitionMidMs,classNames:"slide-left",mountOnEnter:!0,unmountOnExit:!0,children:h(ji,{serverConfigValues:o,onDone:this.handleSettingsMenuHide})}),h(le,{actions:c}),h("input",{ref:this.importElement,type:"file",accept:".json",style:{display:"none"},onChange:this.handleImportLayoutFiles})]})}}const vR=t=>({activeTool:gl(t),dashboardData:Yt(t,bn),layoutStorage:oR(t),plugins:oS(t),connection:CE(t,bn),session:di(t,bn)?.session,sessionConfig:di(t,bn)?.config,user:ru(t),workspace:pl(t),serverConfigValues:rR(t)}),ER=vt(vR,{setActiveTool:Cl,updateDashboardData:Vn,updateWorkspaceData:Ru})(Qp(Do));function yR(){return v("div",{className:"app",children:[h(ER,{}),h(kh,{})]})}const RR=ee.module("LocalWorkspaceStorage"),To=class{static async makeDefaultWorkspaceData(t,e){const{filterSets:n,links:s,layoutConfig:i}=await _r.getDefaultLayout(t,e?.isConsoleAvailable);return{settings:{defaultDateTimeFormat:st.DEFAULT_DATETIME_FORMAT_STRING,formatter:[],timeZone:st.DEFAULT_TIME_ZONE_ID,showTimeZone:!1,showTSeparator:!0,disableMoveConfirmation:!1,defaultDecimalFormatOptions:{defaultFormatString:ke.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:Ze.DEFAULT_FORMAT_STRING},truncateNumbersWithPound:!1,defaultNotebookSettings:{isMinimapEnabled:!1}},layoutConfig:i,closed:[{}],links:s,filterSets:n}}static async makeDefaultWorkspace(t,e){return{data:await To.makeDefaultWorkspaceData(t,e)}}constructor(t){this.layoutStorage=t}async load(t){try{return JSON.parse(localStorage.getItem(To.STORAGE_KEY)??"")}catch{return RR.info("Unable to load workspace data, initializing to default data"),To.makeDefaultWorkspace(this.layoutStorage,t)}}async save(t){return localStorage.setItem(To.STORAGE_KEY,JSON.stringify(t)),t}};let up=To;up.STORAGE_KEY="deephaven.WorkspaceStorage";class IR extends Error{constructor(){super(...arguments),this.isNoConsolesError=!0}}function FR(t){return t.isNoConsolesError}const ks=ee.module("SessionUtils");var mp=(t=>(t.ANONYMOUS="anonymous",t.PARENT="parent",t))(mp||{});function DR(){return new URL("/jsapi",`${window.location}`)}function pp(){const t=DR();return`${t.protocol}//${t.host}`}function NR(){switch(new URLSearchParams(window.location.search).get("authProvider")){case"parent":return"parent";default:return"anonymous"}}function _R(){const t=pp();return ks.info(`Starting connection to '${t}'...`),new I.IdeConnection(t)}async function MR(t){ks.info("Getting console types...");const e=await t.getConsoleTypes();if(ks.info("Available types:",e),e.length===0)throw new IR("No console types available");const n=e[0];ks.info("Starting session with type",n);const s=await t.startSession(n),i={type:n,id:$e.generate()};return ks.info("Console session established",i),{session:s,config:i,connection:t}}function kR(){const t=pp();return ks.info("createCoreClient",t),new I.CoreClient(t)}async function xR(){if(window.opener==null)throw new Error("window.opener is null, unable to send auth request.");return new Promise(t=>{const e=n=>{const{data:s}=n;if(ks.debug("Received message",s),s?.message!=="loginOptions"){ks.debug("Ignore received message",s);return}window.removeEventListener("message",e),t(s.payload)};window.addEventListener("message",e),window.opener.postMessage("requestLoginOptionsFromParent","*")})}async function OR(t){switch(t){case"parent":return xR();case"anonymous":return{type:I.CoreClient.LOGIN_TYPE_ANONYMOUS};default:throw new Error(`Unknown auth type: ${t}`)}}class AR{constructor(e,n=""){this.storageService=e,this.root=n}async getLayouts(){return(await this.storageService.listItems(this.root,"*.json")).map(n=>n.basename)}async getLayout(e){const s=await(await this.storageService.loadFile(`${this.root}/${e}`)).text();return JSON.parse(s)}}const po=ee.module("GrpcFileStorageTable"),ka=class{constructor(t,e="",n=e){this.currentSize=0,this.listeners=[],this.childTables=new Map,this.storageService=t,this.baseRoot=e,this.root=n,n===e&&(this.doRefresh=Je(this.doRefresh.bind(this),ka.REFRESH_DEBOUNCE))}removeBaseRoot(t){return me.removeRoot(this.baseRoot,t)}getViewportData(){return this.viewportUpdatePromise||this.refreshInternal(),this.viewportUpdatePromise??Promise.resolve({items:[],offset:0})}getSnapshot(t){throw new Error("Method not implemented.")}get size(){return this.currentSize}setExpanded(t,e){const n=t.split("/");let s=n.shift();if((s===void 0||s==="")&&(s=n.shift()),s===void 0||s==="")throw new Error(`Invalid path: ${t}`);const i=n.join("/");if(e){if(!this.childTables.has(s)){const o=new ka(this.storageService,this.baseRoot,`${this.root}/${s}`);this.childTables.set(s,o)}i&&this.childTables.get(s)?.setExpanded(i,e)}else this.childTables.has(s)&&(i?this.childTables.get(s)?.setExpanded(i,e):this.childTables.delete(s));this.currentViewport&&this.refreshInternal()}collapseAll(){this.childTables.clear(),this.currentViewport&&this.refreshInternal()}setSearch(t){throw new Error("Method not implemented.")}setViewport(t){this.currentViewport=t,this.refreshInternal()}setFilters(){throw new Error("Method not implemented.")}setSorts(){throw new Error("Method not implemented.")}setReversed(){throw new Error("Method not implemented.")}close(){this.listeners=[]}onUpdate(t){return this.listeners=[...this.listeners,t],()=>{this.listeners=this.listeners.filter(e=>e!==t)}}doRefresh(t){po.debug2("doRefresh",this.root),t(this.fetchData())}refresh(){po.debug2("refresh",this.root),this.viewportUpdatePromise?.cancel();const t=new Promise(n=>{this.doRefresh(n)}),e=ye.makeCancelable(t.then(n=>{if(this.viewportUpdatePromise!==e)throw new Jr;return this.currentViewportData=n,this.sendUpdate(),n}));e.catch(n=>{ye.isCanceled(n)||po.error("Error updating viewport",n)}),this.viewportUpdatePromise=e}refreshInternal(){try{this.refresh()}catch(t){ye.isCanceled(t)||po.error("Unable to refresh data",t)}}async fetchData(){const{currentViewport:t}=this;if(!t)throw new Error("No viewport set");let n=(await this.storageService.listItems(this.root)).map(s=>({type:s.type,filename:this.removeBaseRoot(s.filename),basename:s.basename,id:this.removeBaseRoot(s.filename),isExpanded:s.type==="directory"?this.childTables.has(s.basename):void 0})).sort((s,i)=>s.type!==i.type?s.type==="directory"?-1:1:s.basename.localeCompare(i.basename));for(let s=0;s<n.length;s+=1){const i=n[s],{basename:o,filename:r}=i;if(r===this.removeBaseRoot(`${this.root}/${o}`)&&i.type==="directory"){const l=this.childTables.get(o);if(l!=null){l.setViewport({top:0,bottom:t.bottom-s});const a=await l.getViewportData();n.splice(s+1,0,...a.items)}}}return this.currentSize=n.length,po.debug2(this.root,"items",n,t),n=n.slice(t.top,t.bottom),{items:n,offset:t.top}}sendUpdate(){const{listeners:t}=this,e=this.currentViewportData??{items:[],offset:0};for(let n=0;n<t.length;n+=1)t[n](e)}};let gp=ka;gp.REFRESH_DEBOUNCE=50;const LR=ee.module("GrpcFileStorage"),fp=class{constructor(t,e=""){this.tables=[],this.refreshTables=Pn(()=>{this.tables.forEach(n=>n.refresh())},fp.REFRESH_THROTTLE),this.storageService=t,this.root=e}removeRoot(t){return me.removeRoot(this.root,t)}addRoot(t){return me.addRoot(this.root,t)}async createDirectory(t){return await this.storageService.createDirectory(this.addRoot(t)),this.refreshTables(),{type:"directory",id:t,filename:t,basename:me.getBaseName(t)}}async getTable(){const t=new gp(this.storageService,this.root);return this.tables.push(t),t}async saveFile(t){const e=dh.storage.FileContents.text(t.content);return await this.storageService.saveFile(this.addRoot(t.filename),e,!0),this.refreshTables(),t}async loadFile(t){const n=await(await this.storageService.loadFile(this.addRoot(t))).text();return{filename:t,basename:me.getBaseName(t),content:n}}async deleteFile(t){await this.storageService.deleteItem(this.addRoot(t)),this.refreshTables()}async moveFile(t,e){await this.storageService.moveItem(this.addRoot(t),this.addRoot(e)),this.refreshTables()}async info(t){const e=await this.storageService.listItems(this.addRoot(me.getPath(t)),me.getBaseName(t));if(e.length===0)throw new Fd;if(e.length>1)throw LR.error("More than one matching file found, should never happen.",e),new Error("More than one matching file found");const n=e[0];return{filename:this.removeRoot(n.filename),basename:n.basename,id:this.removeRoot(n.filename),type:n.type}}};let Cp=fp;Cp.REFRESH_THROTTLE=150;const xs=ee.module("AppInit");async function PR(){xs.debug("Loading plugins...");try{const t=await Ma.loadJson("/js-plugins/manifest.json");xs.debug("Plugin manifest loaded:",t);const e=[];for(let i=0;i<t.plugins.length;i+=1){const{name:o,main:r}=t.plugins[i],l=`/js-plugins/${o}/${r}`;e.push(Ma.loadModulePlugin(l))}const n=await Promise.all(e),s=new Map;for(let i=0;i<n.length;i+=1){const{name:o}=t.plugins[i];s.set(o,n[i])}return xs.info("Plugins loaded:",s),s}catch(t){return xs.error("Unable to load plugins:",t),new Map}}async function HR(t){let e;try{e=await MR(t)}catch(n){if(!FR(n))throw n}return e}function Pd(t){const{workspace:e,setActiveTool:n,setCommandHistoryStorage:s,setDashboardData:i,setFileStorage:o,setLayoutStorage:r,setDashboardConnection:l,setDashboardSessionWrapper:a,setPlugins:d,setUser:c,setWorkspace:u,setWorkspaceStorage:m,setServerConfigValues:p}=t,[g,f]=b.exports.useState(),[C,S]=b.exports.useState(!0),w=b.exports.useCallback(async()=>{try{xs.info("Initializing Web UI","0.31.3",navigator.userAgent);const F=kR(),D=NR();xs.info(`Login using auth type ${D}...`),await F.login(await OR(D));const _=await PR(),H=await(D===mp.ANONYMOUS&&F.getAsIdeConnection==null?_R():F.getAsIdeConnection());H.addEventListener(I.IdeConnection.HACK_CONNECTION_FAILURE,be=>{const{detail:Re}=be;xs.error("Connection failure",`${JSON.stringify(Re)}`),f(`Unable to connect: ${Re.details??"Unknown Error"}`)});const U=await HR(H),A="user",Y=F.getStorageService(),G=new AR(Y,"/layouts"),z=new Cp(Y,"/notebooks"),x=new up(G),L=new xy,P=await x.load({isConsoleAvailable:U!==void 0}),{data:Z}=P,{settings:ne}=Z;ne.defaultDecimalFormatOptions===void 0&&(ne.defaultDecimalFormatOptions={defaultFormatString:ke.DEFAULT_FORMAT_STRING}),ne.defaultIntegerFormatOptions===void 0&&(ne.defaultIntegerFormatOptions={defaultFormatString:Ze.DEFAULT_FORMAT_STRING}),ne.truncateNumbersWithPound===void 0&&(ne.truncateNumbersWithPound=!1);const{shortcutOverrides:B={}}=ne,X=fn.isMacPlatform?B.mac??{}:B.windows??{};Object.entries(X).forEach(([be,Re])=>{qe.get(be)?.setKeyState(Re)});const se={filterSets:Z.filterSets,links:Z.links},ce=await F.getServerConfigValues(),Q=new Map(ce),he={name:A,operateAs:A,groups:[],permissions:{isSuperUser:!1,isQueryViewOnly:!1,isNonInteractive:!1,canUsePanels:!0,canCreateDashboard:!0,canCreateCodeStudio:!0,canCreateQueryMonitor:!0,canCopy:Q.get("internal.webClient.appInit.canCopy")!=="false",canDownloadCsv:Q.get("internal.webClient.appInit.canDownloadCsv")!=="false"}};n(Wt.DEFAULT),p(Q),s(L),i(bn,se),o(z),r(G),l(bn,H),U!==void 0&&a(bn,U),d(_),c(he),m(x),u(P)}catch(F){xs.error(F),f(F)}},[n,s,i,o,r,l,a,d,c,u,m,p]),T=b.exports.useCallback(()=>{document.fonts!=null?document.fonts.ready.then(()=>{S(!1)}):S(!1)},[]);b.exports.useEffect(function(){w(),T()},[w,T]);const y=e==null&&g==null||C,E=!y&&g==null,R=g!=null?`${g}`:null;return v(Se,{children:[E&&h(yR,{}),h(el,{isLoading:y,isLoaded:E,errorMessage:R}),v("div",{id:"preload-fonts",style:{visibility:"hidden",position:"absolute",top:-1e4},children:[h("p",{className:"fira-sans-regular",children:"preload"}),h("p",{className:"fira-sans-semibold",children:"preload"}),h("p",{className:"fira-mono",children:"preload"})]})]})}Pd.propTypes={workspace:M.exports.shape({}),workspaceStorage:M.exports.shape({close:M.exports.func}),setActiveTool:M.exports.func.isRequired,setCommandHistoryStorage:M.exports.func.isRequired,setDashboardData:M.exports.func.isRequired,setFileStorage:M.exports.func.isRequired,setLayoutStorage:M.exports.func.isRequired,setDashboardConnection:M.exports.func.isRequired,setDashboardSessionWrapper:M.exports.func.isRequired,setPlugins:M.exports.func.isRequired,setUser:M.exports.func.isRequired,setWorkspace:M.exports.func.isRequired,setWorkspaceStorage:M.exports.func.isRequired};Pd.defaultProps={workspace:null,workspaceStorage:null};const UR=t=>({workspace:pl(t),workspaceStorage:nS(t)}),uh=vt(UR,{setActiveTool:Cl,setCommandHistoryStorage:aS,setDashboardData:Xu,setFileStorage:dS,setLayoutStorage:Oy,setDashboardConnection:SE,setDashboardSessionWrapper:bE,setPlugins:hS,setUser:rS,setWorkspace:yu,setWorkspaceStorage:lS,setServerConfigValues:uS})(Pd);function VR(){return h(Jp,{basename:"/ide/",children:v(eg,{children:[h($d,{exact:!0,path:"/",component:uh}),h($d,{path:"/notebook/:notebookPath+",component:uh}),h(tg,{from:"*",to:"/"})]})})}Boolean(window.location.hostname==="localhost"||window.location.hostname==="[::1]"||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));function BR(){"serviceWorker"in navigator&&navigator.serviceWorker.getRegistrations().then(t=>{t.forEach(e=>{e.scope.endsWith("/download/")||e.unregister()})})}function YR(){return BR(),jr.registerOnLoaded(),lt.init({getWorker:()=>new wf}),window["__react-beautiful-dnd-disable-dev-warnings"]=!0,h(ph,{store:Sl,children:h(VR,{})})}export{YR as AppRoot,YR as default};
42
- //# sourceMappingURL=AppRoot.718c80bc.js.map
41
+ Barrage Version: ${i}`,children:"Copy Versions"})]})]})]}),h("div",{className:"app-settings-footer-item",children:h($y,{})})]}),h("div",{className:"app-settings-footer-section",children:h("div",{className:"logo",children:h("a",{target:"_blank",rel:"noreferrer noopener",href:"https://deephaven.io",className:"d-inline-block custom-link p-1",children:h("img",{src:ep,alt:"Deephaven Data Labs",width:"230px"})})})})]})]})]})}};let ji=Qn;ji.defaultProps={onDone:()=>{}};ji.FORMATTING_SECTION_KEY="SettingsMenu.formatting";ji.COLUMN_SPECIFIC_SECTION_KEY="SettingsMenu.columnFormatting";ji.APPLICATION_SECTION_KEY="ApplicationMenu.settings";ji.SHORTCUT_SECTION_KEY="SettingsMenu.shortcuts";const ch=10;function Fi(t){const{forwardedProps:{menuItem:{action:e,title:n,disabled:s},iconElement:i,displayShortcut:o,isMouseSelected:r,isKeyboardSelected:l,closeMenu:a}}=t,d=b.exports.useRef(),c=b.exports.useRef(),u=b.exports.useRef(null),[m,p]=b.exports.useState(!1),g=b.exports.useCallback(S=>{d.current!=null&&c.current!=null&&u.current&&(Math.abs(d.current-S.clientX)>=ch||Math.abs(c.current-S.clientY)>=ch)&&(p(!0),window.removeEventListener("mousemove",g),a(),e(S),u.current=null)},[e,a]);function f(S){d.current=S.clientX,c.current=S.clientY,u.current=S.target,window.addEventListener("mousemove",g)}function C(S){u.current===S.target&&(p(!0),a(),e(),window.removeEventListener("mousemove",g)),u.current=null}return b.exports.useEffect(function(){return function(){return window.removeEventListener("mousemove",g)}},[g]),v("button",{type:"button",className:K("btn-context-menu",{disabled:s},{active:r&&!s},{"keyboard-active":l&&!s}),onMouseDown:f,onMouseUp:C,disabled:m,children:[h("span",{className:K("icon"),children:i}),h("span",{className:"title",children:n}),h("span",{className:"shortcut",children:o})]})}function Ld(t){const{handleControlSelect:e,handleToolSelect:n,onClearFilter:s}=t,i=b.exports.useMemo(()=>[{title:"Input Filter",icon:pf,menuElement:h(Fi,{}),action:o=>{e(un.INPUT_FILTER,o)},order:10},{title:"Dropdown Filter",icon:Dh,menuElement:h(Fi,{}),action:o=>{e(un.DROPDOWN_FILTER,o)},order:15},{title:"Markdown Widget",icon:gf,menuElement:h(Fi,{}),action:o=>{e(un.MARKDOWN,o)},order:20},{title:"Filter Sets",icon:ca,menuElement:h(Fi,{}),action:o=>{e(un.FILTER_SET_MANAGER,o)},order:25},{disabled:!0,menuElement:h("div",{className:"context-menu-group-header",children:"Tools"}),order:30},{title:"Linker",icon:yh,action:()=>{n(Wt.LINKER)},order:40,shortcut:ls.LINKER},{disabled:!0,menuElement:h("div",{className:"context-menu-group-header",children:"Actions"}),order:50},{title:"Clear All Filters",icon:ff,action:()=>{s()},order:60,shortcut:en.TABLE.CLEAR_ALL_FILTERS}],[e,n,s]);return h(ns,{popperClassName:"controls-menu-popper",actions:i})}Ld.propTypes={handleControlSelect:M.exports.func,handleToolSelect:M.exports.func,onClearFilter:M.exports.func};Ld.defaultProps={handleControlSelect:()=>{},handleToolSelect:()=>{},onClearFilter:()=>{}};Fi.propTypes={forwardedProps:M.exports.shape({iconElement:M.exports.node,displayShortcut:M.exports.string,isMouseSelected:M.exports.bool.isRequired,isKeyboardSelected:M.exports.bool.isRequired,closeMenu:M.exports.func.isRequired,menuItem:M.exports.shape({action:M.exports.func,title:M.exports.string,disabled:M.exports.bool}).isRequired})};Fi.defaultProps={forwardedProps:null};const sR=Ls(Jm,null),iR={layoutStorage:sR},oR=t=>t.layoutStorage,rR=t=>t.serverConfigValues;Object.entries(iR).map(([t,e])=>Gi.register(t,e));const hh=10;function lR(t){const{onExportLayout:e,onImportLayout:n,onResetLayout:s,onSelect:i,widgets:o=[]}=t,[r,l]=b.exports.useState(!1),[a,d]=b.exports.useState(""),c=b.exports.useRef(null),u=b.exports.useRef(),m=b.exports.useCallback((y,E)=>{y!=null&&i(y,E)},[i]),p=b.exports.useCallback(y=>{d(y.target.value)},[]),g=b.exports.useCallback(y=>{u.current!=null&&(Math.abs(u.current.x-y.clientX)>=hh||Math.abs(u.current.y-y.clientY)>=hh)&&(l(!0),window.removeEventListener("mousemove",g),m(u.current.widget,y),u.current=void 0)},[u,m]),f=b.exports.useCallback((y,E)=>{u.current={x:y.clientX,y:y.clientY,widget:E},window.addEventListener("mousemove",g)},[g]),C=b.exports.useCallback((y,E)=>{window.removeEventListener("mousemove",g),u.current?.widget===E&&(l(!0),m(E)),u.current=void 0},[g,u,m]),S=b.exports.useMemo(()=>o.filter(y=>a?y.name?.toLowerCase().includes(a.toLowerCase()):!0),[a,o]).sort((y,E)=>y.name?.localeCompare(E.name??"")??0),w=b.exports.useMemo(()=>S.map(y=>h("li",{children:v(V,{kind:"ghost","data-testid":`panel-list-item-${y.name??""}-button`,onMouseDown:E=>{f(E,y)},onMouseUp:E=>{C(E,y)},onKeyDown:E=>{(E.key==="Enter"||E.key===" ")&&m(y)},disabled:r,onClick:()=>{},children:[h(Lh,{type:y.type})," ",y.name??""]})},y.name)),[S,r,f,C,m]),T=b.exports.useMemo(()=>w.length===0?h("span",{children:"No bound variables found."}):null,[w]);return v("div",{className:"widget-list-container d-flex flex-column",children:[h("div",{className:"widget-list-header",children:h(Bi,{value:a,placeholder:"Find Table, Plot or Widget",onChange:p,ref:c})}),v("ul",{className:"widget-list flex-grow-1",children:[T&&h("li",{className:"widget-list-message",children:T}),!T&&w]}),h("div",{children:h("hr",{})}),v("div",{className:"widget-list-footer",children:[v(V,{kind:"ghost",onClick:e,children:[v("div",{className:"fa-md fa-layers",children:[h(J,{mask:da,icon:jd,transform:"right-5 down-5"}),h(J,{icon:jd,transform:"right-8 down-6"})]}),"Export Layout"]}),v(V,{kind:"ghost",onClick:n,children:[v("div",{className:"fa-md fa-layers",children:[h(J,{mask:da,icon:ha,transform:"right-5 down-5"}),h(J,{icon:ha,transform:"right-8 down-6"})]}),"Import Layout"]}),h(V,{kind:"ghost",icon:ti,onClick:s,tooltip:"Reset Layout"})]})]})}const aR=async(t,e,n)=>{let s,i,o,r;if(Rr(e)?(s=e.settings,i=e.table,o=void 0,r=e.tableSettings):(s={},i="",o=e.figure,r={}),n!==void 0&&(n.tableSettings!=null&&(r=n.tableSettings),n.table!=null&&(i=n.table),n.figure!=null&&(o=n.figure),n.settings!=null&&(s={...s,...n.settings})),o!==void 0){const d={title:o,name:o,type:I.VariableType.FIGURE},c=await t.getObject(d);return Oi.makeModel(s,c)}const l={title:o,name:i,type:I.VariableType.TABLE},a=await t.getObject(l);return te.applyTableSettings(a,r,Ao(Sl.getState())),Oi.makeModelFromSettings(s,a)},dR=async(t,e,n=I.VariableType.TABLE)=>{const{table:s}=e,i={title:s,name:s,type:n},o=await t.getObject(i);return Cd.makeModel(o)};function cR({onAutoFillClick:t=()=>{}}){return v("div",{className:"empty-dashboard-container",children:[v("div",{className:"hint-container",children:[h(J,{icon:Fh})," ",h("br",{}),"Use the panel list to add objects from a query."]}),v("div",{className:"empty-dashboard",children:[h("div",{className:"add-panels-hint",children:"Drag Panels Here"}),h(V,{kind:"tertiary",onClick:t,children:"Auto fill objects"})]})]})}function hR(t){return t.version===2}function uR(t){return Array.isArray(t)}const Tr=ee.module("UserLayoutUtils"),mR={layoutConfig:[{type:"column",content:[{type:"row",height:40,content:[{type:"stack",content:[{type:"react-component",component:Ii.COMPONENT,title:Ii.TITLE,isClosable:!1},{type:"react-component",component:Xr.COMPONENT,title:Xr.TITLE,isClosable:!1}]},{type:"stack",width:25,content:[{type:"react-component",component:qr.COMPONENT,title:qr.TITLE,isClosable:!1},{type:"react-component",component:Yr.COMPONENT,title:Yr.TITLE,isClosable:!1}]}]},{type:"row",content:[{type:"stack",title:"Notebooks",content:[]}]}]}],links:[],filterSets:[],version:2},pR={layoutConfig:[],links:[],filterSets:[],version:2};function dp(t){if(hR(t))return t;if(uR(t))return{layoutConfig:t,links:[],filterSets:[],version:2};throw new Error(`Unexpected layout import format: ${t}`)}async function gR(t,e=!0){try{const n=await t.getLayouts();if(n.length>0)try{const s=await t.getLayout(n[0]);return dp(s)}catch(s){Tr.error("Unable to load layout",n[0],":",s),Tr.warn("No valid layouts found, falling back to default layout")}}catch(n){Tr.error("Unable to fetch layout list",n),Tr.warn("Falling back to default layout")}return e?mR:pR}function fR(t){const{filterSets:e,layoutConfig:n,links:s}=t;return{filterSets:e,layoutConfig:n,links:s,version:2}}const _r={exportLayout:fR,getDefaultLayout:gR,normalizeLayout:dp},vr=ee.module("DownloadServiceWorkerUtils"),cp=class{static registerOnLoaded(){new URL("/ide/",window.location.href).origin===window.location.origin&&("serviceWorker"in navigator?window.addEventListener("load",()=>{const e=new URL("/ide/download/serviceWorker.js",window.location.href);navigator.serviceWorker.register(e).then(n=>{n.update(),vr.info("Registering service worker on ",e,n)}).catch(n=>{vr.error("Failed to register service worker",n)})}):vr.info("Service worker is not supported."))}static async getServiceWorker(){if("serviceWorker"in navigator){const e=(await navigator.serviceWorker.getRegistrations()).find(n=>n.scope.endsWith(cp.DOWNLOAD_PATH));if(e&&e.active)return vr.info("Download service worker is active."),e.active;throw new Error("Can not find download service worker.")}throw new Error("Download service worker is not available.")}static unregisterSW(){}};let jr=cp;jr.DOWNLOAD_PATH="/download/";const hp={react:de,"react-dom":No,redux:qp,"react-redux":Yp},CR=Kp(hp),SR=Xp({requires:CR}),bR=jp.createRequires(hp),wR=Zp({requires:bR}),TR=ee.module("PluginUtils");class Ma{static loadComponentPlugin(e){if("".split(",").includes(e)){const o=de.lazy(()=>bf(()=>import(`./internal/${e}`),[])),r=de.forwardRef((l,a)=>h(b.exports.Suspense,{fallback:h("div",{children:"Loading Plugin..."}),children:h(o,{ref:a,...l})}));return r.pluginName=e,r.displayName="Local Plugin",r}const n=new URL("/ide/plugins/",`${window.location}`),s=new URL(`${e}.js`,n),i=de.forwardRef((o,r)=>h(SR,{url:s,render:({err:l,Component:a})=>{if(l!=null&&l!==""){const d=`Error loading plugin ${e} from ${s} due to ${l}`;return TR.error(d),h("div",{className:"error-message",children:`${d}`})}return h(a,{ref:r,...o})}}));return i.pluginName=e,i.displayName="Plugin",i}static async loadModulePlugin(e){return await wR(e)}static async loadJson(e){return new Promise((n,s)=>{const i=new XMLHttpRequest;i.addEventListener("load",()=>{try{const o=JSON.parse(i.responseText);n(o)}catch(o){s(o)}}),i.addEventListener("error",o=>{s(o)}),i.open("GET",e),i.send()})}}const Ot=ee.module("AppMainContainer");class Do extends b.exports.Component{constructor(e){super(e),this.getDashboardPlugins=ge(n=>[...n.entries()].filter(([,s])=>s.DashboardPlugin!=null).map(([s,{DashboardPlugin:i}])=>h(i,{},s))),this.handleSettingsMenuHide=this.handleSettingsMenuHide.bind(this),this.handleSettingsMenuShow=this.handleSettingsMenuShow.bind(this),this.handleError=this.handleError.bind(this),this.handleControlSelect=this.handleControlSelect.bind(this),this.handleToolSelect=this.handleToolSelect.bind(this),this.handleClearFilter=this.handleClearFilter.bind(this),this.handleDataChange=this.handleDataChange.bind(this),this.handleAutoFillClick=this.handleAutoFillClick.bind(this),this.handleGoldenLayoutChange=this.handleGoldenLayoutChange.bind(this),this.handleLayoutConfigChange=this.handleLayoutConfigChange.bind(this),this.handleExportLayoutClick=this.handleExportLayoutClick.bind(this),this.handleImportLayoutClick=this.handleImportLayoutClick.bind(this),this.handleImportLayoutFiles=this.handleImportLayoutFiles.bind(this),this.handleLoadTablePlugin=this.handleLoadTablePlugin.bind(this),this.handleResetLayoutClick=this.handleResetLayoutClick.bind(this),this.handleWidgetMenuClick=this.handleWidgetMenuClick.bind(this),this.handleWidgetsMenuClose=this.handleWidgetsMenuClose.bind(this),this.handleWidgetSelect=this.handleWidgetSelect.bind(this),this.handlePaste=this.handlePaste.bind(this),this.hydrateChart=this.hydrateChart.bind(this),this.hydrateGrid=this.hydrateGrid.bind(this),this.hydratePandas=this.hydratePandas.bind(this),this.hydrateDefault=this.hydrateDefault.bind(this),this.openNotebookFromURL=this.openNotebookFromURL.bind(this),this.importElement=de.createRef(),this.state={contextActions:[{action:()=>{this.handleToolSelect(Wt.LINKER)},shortcut:ls.LINKER,isGlobal:!0},{action:()=>{this.sendClearFilter()},shortcut:en.TABLE.CLEAR_ALL_FILTERS,isGlobal:!0},{action:()=>{Ot.debug("Consume unhandled save shortcut")},shortcut:ls.SAVE,isGlobal:!0}],isPanelsMenuShown:!1,isSettingsMenuShown:!1,widgets:[]}}static handleWindowBeforeUnload(e){e.preventDefault(),e.returnValue=""}static hydrateConsole(e,n){return wa.hydrate({...e,unzip:s=>Sh.loadAsync(s).then(i=>Object.values(i.files))},n)}componentDidMount(){this.initWidgets(),window.addEventListener("beforeunload",Do.handleWindowBeforeUnload)}componentDidUpdate(e){const{dashboardData:n}=this.props;e.dashboardData!==n&&this.handleDataChange(n)}componentWillUnmount(){this.deinitWidgets(),window.removeEventListener("beforeunload",Do.handleWindowBeforeUnload)}initWidgets(){const{connection:e}=this.props;if(e.subscribeToFieldUpdates==null){Ot.warn("subscribeToFieldUpdates not supported, not initializing widgets");return}this.widgetListenerRemover=e.subscribeToFieldUpdates(n=>{Ot.debug("Got updates",n),this.setState(({widgets:s})=>{const{updated:i,created:o,removed:r}=n,l=[...i,...r],a=s.filter(c=>!l.some(u=>u.name===c.name));return[...i,...o].forEach(c=>{c.name!=null&&c.name!==""&&a.push(c)}),{widgets:a}})})}deinitWidgets(){this.widgetListenerRemover?.()}openNotebookFromURL(){const{match:e}=this.props,{notebookPath:n}=e.params;if(n){const{session:s,sessionConfig:i}=this.props;if(s==null||i==null){Ot.error("No session available to open notebook URL",n);return}const o={id:`/${n}`,itemName:`/${n}`},r=i.type,l={value:null,language:r};this.emitLayoutEvent(Ae.SELECT_NOTEBOOK,s,r,l,o,!0)}}sendClearFilter(){this.emitLayoutEvent(Le.CLEAR_ALL_FILTERS)}emitLayoutEvent(e,...n){this.goldenLayout?.eventHub.emit(e,...n)}handleError(e){ye.isCanceled(e)||Ot.error(e)}handleSettingsMenuHide(){this.setState({isSettingsMenuShown:!1})}handleSettingsMenuShow(){this.setState({isSettingsMenuShown:!0})}handleControlSelect(e,n=null){switch(Ot.debug("handleControlSelect",e),e){case un.DROPDOWN_FILTER:this.emitLayoutEvent(Le.OPEN_DROPDOWN,{title:"DropdownFilter",type:e,createNewStack:!0,dragEvent:n});break;case un.INPUT_FILTER:this.emitLayoutEvent(Le.OPEN_INPUT,{title:"InputFilter",type:e,createNewStack:!0,dragEvent:n});break;case un.MARKDOWN:this.emitLayoutEvent(xm.OPEN,{title:"Markdown",type:e,dragEvent:n});break;case un.FILTER_SET_MANAGER:this.emitLayoutEvent(Le.OPEN_FILTER_SET_MANAGER,{title:"FilterSets",type:e,dragEvent:n});break;default:throw new Error(`Unrecognized control type ${e}`)}}handleToolSelect(e){Ot.debug("handleToolSelect",e);const{activeTool:n,setActiveTool:s}=this.props;s(n===e?Wt.DEFAULT:e)}handleClearFilter(){this.sendClearFilter()}handleDataChange(e){const{updateWorkspaceData:n}=this.props,{closed:s,filterSets:i,links:o}=e;n({closed:s,filterSets:i,links:o})}handleGoldenLayoutChange(e){this.goldenLayout=e}handleLayoutConfigChange(e){const{updateWorkspaceData:n}=this.props;n({layoutConfig:e})}handleWidgetMenuClick(){this.setState(({isPanelsMenuShown:e})=>({isPanelsMenuShown:!e}))}handleWidgetSelect(e,n){this.setState({isPanelsMenuShown:!1}),Ot.debug("handleWidgetSelect",e,n),this.openWidget(e,n)}handleWidgetsMenuClose(){this.setState({isPanelsMenuShown:!1})}handleAutoFillClick(){const{widgets:e}=this.state;Ot.debug("handleAutoFillClick",e);const n=e.sort((s,i)=>s.title!=null&&i.title!=null?s.title.localeCompare(i.title):0);for(let s=0;s<n.length;s+=1)this.openWidget(n[s])}handleExportLayoutClick(){Ot.info("handleExportLayoutClick"),this.setState({isPanelsMenuShown:!1});try{const{workspace:e}=this.props,{data:n}=e,s=_r.exportLayout(n);Ot.info("handleExportLayoutClick exportedConfig",s);const i=new Blob([JSON.stringify(s)],{type:"application/json"}),o=I.i18n.DateTimeFormat.format("yyyy-MM-dd-HHmmss",new Date),r=document.createElement("a");r.href=URL.createObjectURL(i),r.download=`deephaven-app-layout-${o}.json`,r.click()}catch(e){Ot.error("Unable to export layout",e)}}handleImportLayoutClick(){Ot.info("handleImportLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.importElement.current!=null&&(this.importElement.current.value="",this.importElement.current.click())}handleResetLayoutClick(){Ot.info("handleResetLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.resetLayout()}handleImportLayoutFiles(e){e.stopPropagation(),e.preventDefault(),e.target.files!=null&&this.importLayoutFile(e.target.files?.[0])}async importLayoutFile(e){try{const{updateDashboardData:n,updateWorkspaceData:s}=this.props,i=await e.text(),o=JSON.parse(i),{filterSets:r,layoutConfig:l,links:a}=_r.normalizeLayout(o);s({layoutConfig:l}),n(bn,{filterSets:r,links:a})}catch(n){Ot.error("Unable to import layout",n)}}async resetLayout(){const{layoutStorage:e,session:n}=this.props,{filterSets:s,layoutConfig:i,links:o}=await _r.getDefaultLayout(e,n!==void 0),{updateDashboardData:r,updateWorkspaceData:l}=this.props;l({layoutConfig:i}),r(bn,{filterSets:s,links:o})}handlePaste(e){if(e.target instanceof HTMLElement&&e.target.closest(".monaco-editor"))return;const{clipboardData:n}=e,s=n.getData("Text"),i=/“|”/g;i.test(s)&&(e.preventDefault(),e.stopPropagation(),document.execCommand("insertText",!1,s.replace(i,'"')))}handleLoadTablePlugin(e){const{plugins:n}=this.props,s=n.get(e);return s!=null&&s.TablePlugin!=null?s.TablePlugin:Ma.loadComponentPlugin(e)}hydrateDefault(e,n){const{connection:s}=this.props,{metadata:i}=e;if(i?.type!=null&&(i?.id!=null||i?.name!=null)){const o=i.id!=null?{type:i.type,id:i.id}:{type:i.type,name:i.name,title:i.name};return{fetch:()=>s.getObject(o),localDashboardId:n,...e}}return wa.hydrate(e,n)}hydrateGrid(e,n){return this.hydrateTable(e,n,e.metadata.type??I.VariableType.TABLE)}hydratePandas(e,n){return this.hydrateTable(e,n,I.VariableType.PANDAS)}hydrateTable(e,n,s=I.VariableType.TABLE){const{connection:i}=this.props;return{...e,getDownloadWorker:jr.getServiceWorker,loadPlugin:this.handleLoadTablePlugin,localDashboardId:n,makeModel:()=>dR(i,e.metadata,s)}}hydrateChart(e,n){const{connection:s}=this.props;return{...e,localDashboardId:n,makeModel:()=>{const{metadata:i,panelState:o}=e;return aR(s,i,o)}}}openWidget(e,n){const{connection:s}=this.props;this.emitLayoutEvent(Ee.OPEN,{dragEvent:n,fetch:()=>s.getObject(e),widget:e})}render(){const{activeTool:e,plugins:n,user:s,workspace:i,serverConfigValues:o}=this.props,{data:r}=i,{layoutConfig:l}=r,{permissions:a}=s,{canUsePanels:d}=a,{contextActions:c,isPanelsMenuShown:u,isSettingsMenuShown:m,widgets:p}=this.state,g=this.getDashboardPlugins(n);return v("div",{className:K("app-main-tabs","w-100","h-100","d-flex","flex-column",e?`active-tool-${e.toLowerCase()}`:""),onPaste:this.handlePaste,tabIndex:-1,children:[h("nav",{className:"nav-container",children:v("div",{className:"app-main-top-nav-menus",children:[h("img",{src:ep,alt:"Deephaven Data Labs",width:"115px",className:"ml-1"}),v("div",{children:[v(V,{kind:"ghost",className:"btn-panels-menu",icon:Cf,onClick:()=>{},children:["Controls",h(Ld,{handleControlSelect:this.handleControlSelect,handleToolSelect:this.handleToolSelect,onClearFilter:this.handleClearFilter})]}),d&&v(V,{kind:"ghost",className:"btn-panels-menu btn-show-panels","data-testid":"app-main-panels-button",onClick:this.handleWidgetMenuClick,icon:Sf,children:["Panels",h(nl,{isShown:u,className:"panels-menu-popper",onExited:this.handleWidgetsMenuClose,closeOnBlur:!0,interactive:!0,children:h(lR,{widgets:p,onExportLayout:this.handleExportLayoutClick,onImportLayout:this.handleImportLayoutClick,onResetLayout:this.handleResetLayoutClick,onSelect:this.handleWidgetSelect})})]}),h(V,{kind:"ghost",className:K("btn-settings-menu",{"text-warning":s.operateAs!==s.name}),onClick:this.handleSettingsMenuShow,icon:h(J,{icon:xo,transform:"grow-3 right-1 down-1"}),tooltip:"User Settings"})]})]})}),v(tw,{emptyDashboard:h(cR,{onAutoFillClick:this.handleAutoFillClick}),id:bn,layoutConfig:l,onGoldenLayoutChange:this.handleGoldenLayoutChange,onLayoutConfigChange:this.handleLayoutConfigChange,onLayoutInitialized:this.openNotebookFromURL,hydrate:this.hydrateDefault,children:[h(my,{hydrate:this.hydrateGrid,getDownloadWorker:jr.getServiceWorker,loadPlugin:this.handleLoadTablePlugin}),h(ly,{hydrate:this.hydrateChart}),h(ay,{}),h(cy,{hydrateConsole:Do.hydrateConsole,notebooksUrl:new URL("/notebooks/",`${window.location}`).href}),h(hy,{}),h(Ty,{hydrate:this.hydratePandas}),h(wy,{}),h(by,{}),g]}),h(Ht,{in:m,timeout:Xe.transitionMidMs,classNames:"slide-left",mountOnEnter:!0,unmountOnExit:!0,children:h(ji,{serverConfigValues:o,onDone:this.handleSettingsMenuHide})}),h(le,{actions:c}),h("input",{ref:this.importElement,type:"file",accept:".json",style:{display:"none"},onChange:this.handleImportLayoutFiles})]})}}const vR=t=>({activeTool:gl(t),dashboardData:Yt(t,bn),layoutStorage:oR(t),plugins:oS(t),connection:CE(t,bn),session:di(t,bn)?.session,sessionConfig:di(t,bn)?.config,user:ru(t),workspace:pl(t),serverConfigValues:rR(t)}),ER=vt(vR,{setActiveTool:Cl,updateDashboardData:Vn,updateWorkspaceData:Ru})(Qp(Do));function yR(){return v("div",{className:"app",children:[h(ER,{}),h(kh,{})]})}const RR=ee.module("LocalWorkspaceStorage"),To=class{static async makeDefaultWorkspaceData(t,e){const{filterSets:n,links:s,layoutConfig:i}=await _r.getDefaultLayout(t,e?.isConsoleAvailable);return{settings:{defaultDateTimeFormat:st.DEFAULT_DATETIME_FORMAT_STRING,formatter:[],timeZone:st.DEFAULT_TIME_ZONE_ID,showTimeZone:!1,showTSeparator:!0,disableMoveConfirmation:!1,defaultDecimalFormatOptions:{defaultFormatString:ke.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:Ze.DEFAULT_FORMAT_STRING},truncateNumbersWithPound:!1,defaultNotebookSettings:{isMinimapEnabled:!1}},layoutConfig:i,closed:[{}],links:s,filterSets:n}}static async makeDefaultWorkspace(t,e){return{data:await To.makeDefaultWorkspaceData(t,e)}}constructor(t){this.layoutStorage=t}async load(t){try{return JSON.parse(localStorage.getItem(To.STORAGE_KEY)??"")}catch{return RR.info("Unable to load workspace data, initializing to default data"),To.makeDefaultWorkspace(this.layoutStorage,t)}}async save(t){return localStorage.setItem(To.STORAGE_KEY,JSON.stringify(t)),t}};let up=To;up.STORAGE_KEY="deephaven.WorkspaceStorage";class IR extends Error{constructor(){super(...arguments),this.isNoConsolesError=!0}}function FR(t){return t.isNoConsolesError}const ks=ee.module("SessionUtils");var mp=(t=>(t.ANONYMOUS="anonymous",t.PARENT="parent",t))(mp||{});function DR(){return new URL("/jsapi",`${window.location}`)}function pp(){const t=DR();return`${t.protocol}//${t.host}`}function NR(){switch(new URLSearchParams(window.location.search).get("authProvider")){case"parent":return"parent";default:return"anonymous"}}function _R(){const t=pp();return ks.info(`Starting connection to '${t}'...`),new I.IdeConnection(t)}async function MR(t){ks.info("Getting console types...");const e=await t.getConsoleTypes();if(ks.info("Available types:",e),e.length===0)throw new IR("No console types available");const n=e[0];ks.info("Starting session with type",n);const s=await t.startSession(n),i={type:n,id:$e.generate()};return ks.info("Console session established",i),{session:s,config:i,connection:t}}function kR(){const t=pp();return ks.info("createCoreClient",t),new I.CoreClient(t)}async function xR(){if(window.opener==null)throw new Error("window.opener is null, unable to send auth request.");return new Promise(t=>{const e=n=>{const{data:s}=n;if(ks.debug("Received message",s),s?.message!=="loginOptions"){ks.debug("Ignore received message",s);return}window.removeEventListener("message",e),t(s.payload)};window.addEventListener("message",e),window.opener.postMessage("requestLoginOptionsFromParent","*")})}async function OR(t){switch(t){case"parent":return xR();case"anonymous":return{type:I.CoreClient.LOGIN_TYPE_ANONYMOUS};default:throw new Error(`Unknown auth type: ${t}`)}}class AR{constructor(e,n=""){this.storageService=e,this.root=n}async getLayouts(){return(await this.storageService.listItems(this.root,"*.json")).map(n=>n.basename)}async getLayout(e){const s=await(await this.storageService.loadFile(`${this.root}/${e}`)).text();return JSON.parse(s)}}const po=ee.module("GrpcFileStorageTable"),ka=class{constructor(t,e="",n=e){this.currentSize=0,this.listeners=[],this.childTables=new Map,this.storageService=t,this.baseRoot=e,this.root=n,n===e&&(this.doRefresh=Je(this.doRefresh.bind(this),ka.REFRESH_DEBOUNCE))}removeBaseRoot(t){return me.removeRoot(this.baseRoot,t)}getViewportData(){return this.viewportUpdatePromise||this.refreshInternal(),this.viewportUpdatePromise??Promise.resolve({items:[],offset:0})}getSnapshot(t){throw new Error("Method not implemented.")}get size(){return this.currentSize}setExpanded(t,e){const n=t.split("/");let s=n.shift();if((s===void 0||s==="")&&(s=n.shift()),s===void 0||s==="")throw new Error(`Invalid path: ${t}`);const i=n.join("/");if(e){if(!this.childTables.has(s)){const o=new ka(this.storageService,this.baseRoot,`${this.root}/${s}`);this.childTables.set(s,o)}i&&this.childTables.get(s)?.setExpanded(i,e)}else this.childTables.has(s)&&(i?this.childTables.get(s)?.setExpanded(i,e):this.childTables.delete(s));this.currentViewport&&this.refreshInternal()}collapseAll(){this.childTables.clear(),this.currentViewport&&this.refreshInternal()}setSearch(t){throw new Error("Method not implemented.")}setViewport(t){this.currentViewport=t,this.refreshInternal()}setFilters(){throw new Error("Method not implemented.")}setSorts(){throw new Error("Method not implemented.")}setReversed(){throw new Error("Method not implemented.")}close(){this.listeners=[]}onUpdate(t){return this.listeners=[...this.listeners,t],()=>{this.listeners=this.listeners.filter(e=>e!==t)}}doRefresh(t){po.debug2("doRefresh",this.root),t(this.fetchData())}refresh(){po.debug2("refresh",this.root),this.viewportUpdatePromise?.cancel();const t=new Promise(n=>{this.doRefresh(n)}),e=ye.makeCancelable(t.then(n=>{if(this.viewportUpdatePromise!==e)throw new Jr;return this.currentViewportData=n,this.sendUpdate(),n}));e.catch(n=>{ye.isCanceled(n)||po.error("Error updating viewport",n)}),this.viewportUpdatePromise=e}refreshInternal(){try{this.refresh()}catch(t){ye.isCanceled(t)||po.error("Unable to refresh data",t)}}async fetchData(){const{currentViewport:t}=this;if(!t)throw new Error("No viewport set");let n=(await this.storageService.listItems(this.root)).map(s=>({type:s.type,filename:this.removeBaseRoot(s.filename),basename:s.basename,id:this.removeBaseRoot(s.filename),isExpanded:s.type==="directory"?this.childTables.has(s.basename):void 0})).sort((s,i)=>s.type!==i.type?s.type==="directory"?-1:1:s.basename.localeCompare(i.basename));for(let s=0;s<n.length;s+=1){const i=n[s],{basename:o,filename:r}=i;if(r===this.removeBaseRoot(`${this.root}/${o}`)&&i.type==="directory"){const l=this.childTables.get(o);if(l!=null){l.setViewport({top:0,bottom:t.bottom-s});const a=await l.getViewportData();n.splice(s+1,0,...a.items)}}}return this.currentSize=n.length,po.debug2(this.root,"items",n,t),n=n.slice(t.top,t.bottom),{items:n,offset:t.top}}sendUpdate(){const{listeners:t}=this,e=this.currentViewportData??{items:[],offset:0};for(let n=0;n<t.length;n+=1)t[n](e)}};let gp=ka;gp.REFRESH_DEBOUNCE=50;const LR=ee.module("GrpcFileStorage"),fp=class{constructor(t,e=""){this.tables=[],this.refreshTables=Pn(()=>{this.tables.forEach(n=>n.refresh())},fp.REFRESH_THROTTLE),this.storageService=t,this.root=e}removeRoot(t){return me.removeRoot(this.root,t)}addRoot(t){return me.addRoot(this.root,t)}async createDirectory(t){return await this.storageService.createDirectory(this.addRoot(t)),this.refreshTables(),{type:"directory",id:t,filename:t,basename:me.getBaseName(t)}}async getTable(){const t=new gp(this.storageService,this.root);return this.tables.push(t),t}async saveFile(t){const e=dh.storage.FileContents.text(t.content);return await this.storageService.saveFile(this.addRoot(t.filename),e,!0),this.refreshTables(),t}async loadFile(t){const n=await(await this.storageService.loadFile(this.addRoot(t))).text();return{filename:t,basename:me.getBaseName(t),content:n}}async deleteFile(t){await this.storageService.deleteItem(this.addRoot(t)),this.refreshTables()}async moveFile(t,e){await this.storageService.moveItem(this.addRoot(t),this.addRoot(e)),this.refreshTables()}async info(t){const e=await this.storageService.listItems(this.addRoot(me.getPath(t)),me.getBaseName(t));if(e.length===0)throw new Fd;if(e.length>1)throw LR.error("More than one matching file found, should never happen.",e),new Error("More than one matching file found");const n=e[0];return{filename:this.removeRoot(n.filename),basename:n.basename,id:this.removeRoot(n.filename),type:n.type}}};let Cp=fp;Cp.REFRESH_THROTTLE=150;const xs=ee.module("AppInit");async function PR(){xs.debug("Loading plugins...");try{const t=await Ma.loadJson("/js-plugins/manifest.json");xs.debug("Plugin manifest loaded:",t);const e=[];for(let i=0;i<t.plugins.length;i+=1){const{name:o,main:r}=t.plugins[i],l=`/js-plugins/${o}/${r}`;e.push(Ma.loadModulePlugin(l))}const n=await Promise.all(e),s=new Map;for(let i=0;i<n.length;i+=1){const{name:o}=t.plugins[i];s.set(o,n[i])}return xs.info("Plugins loaded:",s),s}catch(t){return xs.error("Unable to load plugins:",t),new Map}}async function HR(t){let e;try{e=await MR(t)}catch(n){if(!FR(n))throw n}return e}function Pd(t){const{workspace:e,setActiveTool:n,setCommandHistoryStorage:s,setDashboardData:i,setFileStorage:o,setLayoutStorage:r,setDashboardConnection:l,setDashboardSessionWrapper:a,setPlugins:d,setUser:c,setWorkspace:u,setWorkspaceStorage:m,setServerConfigValues:p}=t,[g,f]=b.exports.useState(),[C,S]=b.exports.useState(!0),w=b.exports.useCallback(async()=>{try{xs.info("Initializing Web UI","0.31.4",navigator.userAgent);const F=kR(),D=NR();xs.info(`Login using auth type ${D}...`),await F.login(await OR(D));const _=await PR(),H=await(D===mp.ANONYMOUS&&F.getAsIdeConnection==null?_R():F.getAsIdeConnection());H.addEventListener(I.IdeConnection.HACK_CONNECTION_FAILURE,be=>{const{detail:Re}=be;xs.error("Connection failure",`${JSON.stringify(Re)}`),f(`Unable to connect: ${Re.details??"Unknown Error"}`)});const U=await HR(H),A="user",Y=F.getStorageService(),G=new AR(Y,"/layouts"),z=new Cp(Y,"/notebooks"),x=new up(G),L=new xy,P=await x.load({isConsoleAvailable:U!==void 0}),{data:Z}=P,{settings:ne}=Z;ne.defaultDecimalFormatOptions===void 0&&(ne.defaultDecimalFormatOptions={defaultFormatString:ke.DEFAULT_FORMAT_STRING}),ne.defaultIntegerFormatOptions===void 0&&(ne.defaultIntegerFormatOptions={defaultFormatString:Ze.DEFAULT_FORMAT_STRING}),ne.truncateNumbersWithPound===void 0&&(ne.truncateNumbersWithPound=!1);const{shortcutOverrides:B={}}=ne,X=fn.isMacPlatform?B.mac??{}:B.windows??{};Object.entries(X).forEach(([be,Re])=>{qe.get(be)?.setKeyState(Re)});const se={filterSets:Z.filterSets,links:Z.links},ce=await F.getServerConfigValues(),Q=new Map(ce),he={name:A,operateAs:A,groups:[],permissions:{isSuperUser:!1,isQueryViewOnly:!1,isNonInteractive:!1,canUsePanels:!0,canCreateDashboard:!0,canCreateCodeStudio:!0,canCreateQueryMonitor:!0,canCopy:Q.get("internal.webClient.appInit.canCopy")!=="false",canDownloadCsv:Q.get("internal.webClient.appInit.canDownloadCsv")!=="false"}};n(Wt.DEFAULT),p(Q),s(L),i(bn,se),o(z),r(G),l(bn,H),U!==void 0&&a(bn,U),d(_),c(he),m(x),u(P)}catch(F){xs.error(F),f(F)}},[n,s,i,o,r,l,a,d,c,u,m,p]),T=b.exports.useCallback(()=>{document.fonts!=null?document.fonts.ready.then(()=>{S(!1)}):S(!1)},[]);b.exports.useEffect(function(){w(),T()},[w,T]);const y=e==null&&g==null||C,E=!y&&g==null,R=g!=null?`${g}`:null;return v(Se,{children:[E&&h(yR,{}),h(el,{isLoading:y,isLoaded:E,errorMessage:R}),v("div",{id:"preload-fonts",style:{visibility:"hidden",position:"absolute",top:-1e4},children:[h("p",{className:"fira-sans-regular",children:"preload"}),h("p",{className:"fira-sans-semibold",children:"preload"}),h("p",{className:"fira-mono",children:"preload"})]})]})}Pd.propTypes={workspace:M.exports.shape({}),workspaceStorage:M.exports.shape({close:M.exports.func}),setActiveTool:M.exports.func.isRequired,setCommandHistoryStorage:M.exports.func.isRequired,setDashboardData:M.exports.func.isRequired,setFileStorage:M.exports.func.isRequired,setLayoutStorage:M.exports.func.isRequired,setDashboardConnection:M.exports.func.isRequired,setDashboardSessionWrapper:M.exports.func.isRequired,setPlugins:M.exports.func.isRequired,setUser:M.exports.func.isRequired,setWorkspace:M.exports.func.isRequired,setWorkspaceStorage:M.exports.func.isRequired};Pd.defaultProps={workspace:null,workspaceStorage:null};const UR=t=>({workspace:pl(t),workspaceStorage:nS(t)}),uh=vt(UR,{setActiveTool:Cl,setCommandHistoryStorage:aS,setDashboardData:Xu,setFileStorage:dS,setLayoutStorage:Oy,setDashboardConnection:SE,setDashboardSessionWrapper:bE,setPlugins:hS,setUser:rS,setWorkspace:yu,setWorkspaceStorage:lS,setServerConfigValues:uS})(Pd);function VR(){return h(Jp,{basename:"/ide/",children:v(eg,{children:[h($d,{exact:!0,path:"/",component:uh}),h($d,{path:"/notebook/:notebookPath+",component:uh}),h(tg,{from:"*",to:"/"})]})})}Boolean(window.location.hostname==="localhost"||window.location.hostname==="[::1]"||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));function BR(){"serviceWorker"in navigator&&navigator.serviceWorker.getRegistrations().then(t=>{t.forEach(e=>{e.scope.endsWith("/download/")||e.unregister()})})}function YR(){return BR(),jr.registerOnLoaded(),lt.init({getWorker:()=>new wf}),window["__react-beautiful-dnd-disable-dev-warnings"]=!0,h(ph,{store:Sl,children:h(VR,{})})}export{YR as AppRoot,YR as default};
42
+ //# sourceMappingURL=AppRoot.ccd4065e.js.map