@deephaven/code-studio 0.30.1-beta.0 → 0.30.1

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 T,E as Y,C as h,R as de,T as Sp,K as Z,D as Ht,L as be,M as $e,B as M,U as bp,V as ge,W as ra,X as Ln,J as Je,I as Ie,Y as mh,Z as ct,_ as xa,$ as wp,a0 as Tp,a1 as vp,a2 as Ep,a3 as pe,G as Nr,a4 as Hd,a5 as Oa,a6 as yp,a7 as Rp,a8 as ph,a9 as Ze,aa as la,H as Ip,ab as jr,Q as gh,S as Aa,ac as Ud,ad as Fp,ae as xn,af as Dp,ag as Np,ah as _p,ai as Mp,aj as aa,ak as kp,al as xp,am as Op,an as Vd,ao as Ap,ap as Lp,aq as Bd,ar as Pp,as as Hp,at as Up,au as Vp,av as Bp,aw as vt,ax as fh,ay as $p,az as Ch,aA as Gp,aB as Sh,aC as Wp,aD as zp,aE as qp,aF as Yp,aG as Kp,aH as Xp,aI as jp,aJ as Qp,aK as $d,aL as Zp}from"./vendor.bc49f178.js";import{P as ye,C as Pn,a as Jp,u as eg,B as U,v as tg,b as ng,c as sg,d as ig,e as Ui,T as Xe,f as da,g as og,h as bh,i as La,L as as,j as Qr,k as ts,l as wh,m as J,r as qe,M as Te,K as Fe,n as Gd,o as rg,p as lg,q as ag,G as ls,s as le,t as dg,w as sn,x as Os,D as Vi,y as mn,z as ns,A as Th,S as Bi,E as Zr,F as ut,H as ss,I as Jr,J as Mi,N as cg,O as hg,Q as Wd,R as _r,U as zd,V as vh,W as No,X as ki,Y as ug,Z as _o,_ as mg,$ as Eh,a0 as pg,a1 as gg,a2 as He,a3 as Pa,a4 as Jn,a5 as Ha,a6 as Mr,a7 as Wn,a8 as fg,a9 as Cg,aa as Sg,ab as bg,ac as wg,ad as Ua,ae as Tg,af as As,ag as qd,ah as Cn,ai as Mo,aj as is,ak as Va,al as Ba,am as yh,an as vg,ao as el,ap as Eg,aq as kr,ar as yg,as as $a,at as Rh,au as ei,av as Rg,aw as Ig,ax as Fg,ay as Dg,az as Ng,aA as _g,aB as tl,aC as Yd,aD as Vl,aE as Mg,aF as kg,aG as xg,aH as Ih,aI as nl,aJ as sl,aK as Og,aL as Ag,aM as il,aN as Fh,aO as Lg,aP as Pg,aQ as Hg,aR as Ug,aS as Dh,aT as Vg,aU as Bg,aV as $g,aW as Gg,aX as Wg,aY as zg,aZ as qg,a_ as Ke,a$ as Kd,b0 as Nh,b1 as Yg,b2 as Kg,b3 as Xg,b4 as jg,b5 as Xd,b6 as xr,b7 as Qg,b8 as _h,b9 as Zg,ba as Jg,bb as Mh,bc as ef,bd as ca,be as ha,bf as tf,bg as nf,bh as sf,bi as of,bj as fn,bk as rf,bl as lf,bm as af,bn as df,bo as cf,bp as hf,bq as uf,br as mf,bs as jd,bt as pf,bu as gf}from"./index.adb9c7e5.js";import{e as os,l as Ti,K as cn,a as Qd,b as Ds,_ as ff,W as Cf}from"./monaco.1292e04e.js";import{P as Or,b as Sf,h as bf,p as wf,o as Tf,s as vf,t as Ef,c as Bl}from"./plotly.23481c2c.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]),T("div",{className:Y(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 ol{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),ol.getBrightness(o)<125}static getBrightness(e){return Math.round((e[0]*299+e[1]*587+e[2]*114)/1e3)}}function yf(t,e){return t?t.closest(`.${e}`):null}const Rf={getClosestByClassName:yf};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(!Pn.isContextActionEvent(e)||!this.container.current||e.metaKey||e.ctrlKey)return;const n=Pn.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(Jp,{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:Y("context-menu-root",{active:s}),ref:this.container,children:e})}}function rl(t){const e=b.exports.useRef();return b.exports.useEffect(function(){e.current=t}),e.current}function ll({copy:t,kind:e="ghost",tooltip:n="Copy",className:s,"data-testid":i,children:o}){const[r,l]=eg();return h(U,{kind:e,className:s,"data-testid":i,icon:r?tg:ng,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 Sp(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:Y("btn","btn-switch",n,{active:t},{"is-invalid":s}),id:e,onClick:o,disabled:i,"data-testid":r,children:h("div",{className:"handle"})})}function Zd(t){return t.isOn!==void 0}function If({item:t,onSelect:e=()=>{},"data-testid":n}){const{icon:s,subtitle:i,title:o}=t,r=b.exports.useMemo(()=>Zd(t)?()=>{t.onChange(!t.isOn)}:e,[t,e]);return T("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(Z,{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:Zd(t)?h(xh,{on:t.isOn,onClick:l=>{l.stopPropagation(),r()}}):h(Z,{icon:sg})})]})}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(If,{item:s,onSelect:()=>{e(i)}})},s.title))})})}function Jd({children:t,onBack:e,onClose:n,title:s,"data-testid":i}){return T("div",{className:"navigation-page","data-testid":i,children:[T("div",{className:"navigation-title-bar",children:[h("div",{className:"navigation-left-buttons",children:e!==void 0&&h(U,{kind:"ghost",className:"btn-back","data-testid":"btn-page-back",onClick:e,icon:ig,children:"Back"})}),h("div",{className:"navigation-title",children:s}),h("div",{className:"navigation-right-buttons",children:n!==void 0&&h(U,{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 Ff({children:t,"data-testid":e}){const n=b.exports.useMemo(()=>de.Children.toArray(t),[t]),s=rl(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 T("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(be,{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(be,{children:r!=null&&h("div",{className:"pushing-view",children:r})})})]})}function Df({children:t,disabled:e,value:n,"data-testid":s}){return h("option",{value:n,disabled:e,"data-testid":s,children:t})}function al(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(be,{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 Nf({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:Y("custom-select",s),onBlur:e,onChange:d,defaultValue:i,value:r,name:o,disabled:l,"data-testid":a,children:t})}const{dh:I}=globalThis,dl=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}),_f=M.exports.shape({asc:M.exports.func.isRequired,desc:M.exports.func.isRequired,abs:M.exports.func.isRequired,column:dl.isRequired,direction:M.exports.string.isRequired,isAbs:M.exports.bool.isRequired}),Mf=M.exports.shape({columns:M.exports.arrayOf(dl).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}),kf=M.exports.shape({columns:M.exports.arrayOf(dl),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}),Tr=M.exports.shape({name:M.exports.string.isRequired,type:M.exports.string.isRequired}),xf=M.exports.shape({created:M.exports.arrayOf(Tr).isRequired,updated:M.exports.arrayOf(Tr).isRequired,removed:M.exports.arrayOf(Tr).isRequired}),Of=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}),Af=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:dl,FilterCondition:Ah,IdeSession:Af,RollupConfig:Of,Sort:_f,Table:Mf,TreeTable:kf,VariableChanges:xf,VariableDefinition:Tr});dh;function Lh({type:t}){switch(t){case I.VariableType.TABLE:case I.VariableType.TABLEMAP:case I.VariableType.TREETABLE:case I.VariableType.HIERARCHICALTABLE:return h(Z,{icon:La});case I.VariableType.FIGURE:return h(Z,{icon:bh});case I.VariableType.PANDAS:return h(Z,{icon:og});default:return h(Z,{icon:da})}}class cl 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)?[]:bp.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 T("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:Y("console-history-result-in-progress",{disabled:e}),children:T("span",{className:"badge",children:[h(as,{}),"\xA0Running... ",Qr.formatElapsedTime(s),"\xA0",h(U,{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 T,E as Y,C as h,R as de,T as Sp,K as Z,D as Ht,L as be,M as $e,B as M,U as bp,V as ge,W as ra,X as Ln,J as Je,I as Ie,Y as mh,Z as ct,_ as xa,$ as wp,a0 as Tp,a1 as vp,a2 as Ep,a3 as pe,G as Nr,a4 as Hd,a5 as Oa,a6 as yp,a7 as Rp,a8 as ph,a9 as Ze,aa as la,H as Ip,ab as jr,Q as gh,S as Aa,ac as Ud,ad as Fp,ae as xn,af as Dp,ag as Np,ah as _p,ai as Mp,aj as aa,ak as kp,al as xp,am as Op,an as Vd,ao as Ap,ap as Lp,aq as Bd,ar as Pp,as as Hp,at as Up,au as Vp,av as Bp,aw as vt,ax as fh,ay as $p,az as Ch,aA as Gp,aB as Sh,aC as Wp,aD as zp,aE as qp,aF as Yp,aG as Kp,aH as Xp,aI as jp,aJ as Qp,aK as $d,aL as Zp}from"./vendor.bc49f178.js";import{P as ye,C as Pn,a as Jp,u as eg,B as U,v as tg,b as ng,c as sg,d as ig,e as Ui,T as Xe,f as da,g as og,h as bh,i as La,L as as,j as Qr,k as ts,l as wh,m as J,r as qe,M as Te,K as Fe,n as Gd,o as rg,p as lg,q as ag,G as ls,s as le,t as dg,w as sn,x as Os,D as Vi,y as mn,z as ns,A as Th,S as Bi,E as Zr,F as ut,H as ss,I as Jr,J as Mi,N as cg,O as hg,Q as Wd,R as _r,U as zd,V as vh,W as No,X as ki,Y as ug,Z as _o,_ as mg,$ as Eh,a0 as pg,a1 as gg,a2 as He,a3 as Pa,a4 as Jn,a5 as Ha,a6 as Mr,a7 as Wn,a8 as fg,a9 as Cg,aa as Sg,ab as bg,ac as wg,ad as Ua,ae as Tg,af as As,ag as qd,ah as Cn,ai as Mo,aj as is,ak as Va,al as Ba,am as yh,an as vg,ao as el,ap as Eg,aq as kr,ar as yg,as as $a,at as Rh,au as ei,av as Rg,aw as Ig,ax as Fg,ay as Dg,az as Ng,aA as _g,aB as tl,aC as Yd,aD as Vl,aE as Mg,aF as kg,aG as xg,aH as Ih,aI as nl,aJ as sl,aK as Og,aL as Ag,aM as il,aN as Fh,aO as Lg,aP as Pg,aQ as Hg,aR as Ug,aS as Dh,aT as Vg,aU as Bg,aV as $g,aW as Gg,aX as Wg,aY as zg,aZ as qg,a_ as Ke,a$ as Kd,b0 as Nh,b1 as Yg,b2 as Kg,b3 as Xg,b4 as jg,b5 as Xd,b6 as xr,b7 as Qg,b8 as _h,b9 as Zg,ba as Jg,bb as Mh,bc as ef,bd as ca,be as ha,bf as tf,bg as nf,bh as sf,bi as of,bj as fn,bk as rf,bl as lf,bm as af,bn as df,bo as cf,bp as hf,bq as uf,br as mf,bs as jd,bt as pf,bu as gf}from"./index.f6d0d37c.js";import{e as os,l as Ti,K as cn,a as Qd,b as Ds,_ as ff,W as Cf}from"./monaco.1292e04e.js";import{P as Or,b as Sf,h as bf,p as wf,o as Tf,s as vf,t as Ef,c as Bl}from"./plotly.23481c2c.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]),T("div",{className:Y(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 ol{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),ol.getBrightness(o)<125}static getBrightness(e){return Math.round((e[0]*299+e[1]*587+e[2]*114)/1e3)}}function yf(t,e){return t?t.closest(`.${e}`):null}const Rf={getClosestByClassName:yf};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(!Pn.isContextActionEvent(e)||!this.container.current||e.metaKey||e.ctrlKey)return;const n=Pn.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(Jp,{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:Y("context-menu-root",{active:s}),ref:this.container,children:e})}}function rl(t){const e=b.exports.useRef();return b.exports.useEffect(function(){e.current=t}),e.current}function ll({copy:t,kind:e="ghost",tooltip:n="Copy",className:s,"data-testid":i,children:o}){const[r,l]=eg();return h(U,{kind:e,className:s,"data-testid":i,icon:r?tg:ng,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 Sp(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:Y("btn","btn-switch",n,{active:t},{"is-invalid":s}),id:e,onClick:o,disabled:i,"data-testid":r,children:h("div",{className:"handle"})})}function Zd(t){return t.isOn!==void 0}function If({item:t,onSelect:e=()=>{},"data-testid":n}){const{icon:s,subtitle:i,title:o}=t,r=b.exports.useMemo(()=>Zd(t)?()=>{t.onChange(!t.isOn)}:e,[t,e]);return T("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(Z,{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:Zd(t)?h(xh,{on:t.isOn,onClick:l=>{l.stopPropagation(),r()}}):h(Z,{icon:sg})})]})}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(If,{item:s,onSelect:()=>{e(i)}})},s.title))})})}function Jd({children:t,onBack:e,onClose:n,title:s,"data-testid":i}){return T("div",{className:"navigation-page","data-testid":i,children:[T("div",{className:"navigation-title-bar",children:[h("div",{className:"navigation-left-buttons",children:e!==void 0&&h(U,{kind:"ghost",className:"btn-back","data-testid":"btn-page-back",onClick:e,icon:ig,children:"Back"})}),h("div",{className:"navigation-title",children:s}),h("div",{className:"navigation-right-buttons",children:n!==void 0&&h(U,{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 Ff({children:t,"data-testid":e}){const n=b.exports.useMemo(()=>de.Children.toArray(t),[t]),s=rl(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 T("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(be,{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(be,{children:r!=null&&h("div",{className:"pushing-view",children:r})})})]})}function Df({children:t,disabled:e,value:n,"data-testid":s}){return h("option",{value:n,disabled:e,"data-testid":s,children:t})}function al(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(be,{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 Nf({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:Y("custom-select",s),onBlur:e,onChange:d,defaultValue:i,value:r,name:o,disabled:l,"data-testid":a,children:t})}const{dh:I}=globalThis,dl=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}),_f=M.exports.shape({asc:M.exports.func.isRequired,desc:M.exports.func.isRequired,abs:M.exports.func.isRequired,column:dl.isRequired,direction:M.exports.string.isRequired,isAbs:M.exports.bool.isRequired}),Mf=M.exports.shape({columns:M.exports.arrayOf(dl).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}),kf=M.exports.shape({columns:M.exports.arrayOf(dl),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}),Tr=M.exports.shape({name:M.exports.string.isRequired,type:M.exports.string.isRequired}),xf=M.exports.shape({created:M.exports.arrayOf(Tr).isRequired,updated:M.exports.arrayOf(Tr).isRequired,removed:M.exports.arrayOf(Tr).isRequired}),Of=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}),Af=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:dl,FilterCondition:Ah,IdeSession:Af,RollupConfig:Of,Sort:_f,Table:Mf,TreeTable:kf,VariableChanges:xf,VariableDefinition:Tr});function Lh({type:t}){switch(t){case I.VariableType.TABLE:case I.VariableType.TABLEMAP:case I.VariableType.TREETABLE:case I.VariableType.HIERARCHICALTABLE:return h(Z,{icon:La});case I.VariableType.FIGURE:return h(Z,{icon:bh});case I.VariableType.PANDAS:return h(Z,{icon:og});default:return h(Z,{icon:da})}}class cl 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)?[]:bp.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 T("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:Y("console-history-result-in-progress",{disabled:e}),children:T("span",{className:"badge",children:[h(as,{}),"\xA0Running... ",Qr.formatElapsedTime(s),"\xA0",h(U,{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 T("div",{className:Y("error-message",{expanded:t}),children:[i&&T(be,{children:[h("div",{className:"error-gutter",children:h("button",{type:"button",onClick:this.handleToggleError,className:l,tabIndex:-1,children:h(Z,{icon:t?ts:wh,transform:"left-3"})})}),T("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=J.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=T("div",{className:"console-history-item-command",children:[h("div",{className:"console-history-gutter",children:">"}),h("div",{className:"console-history-content",children:h(cl,{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,v=h(U,{kind:"primary",onClick:()=>this.handleObjectClick(f),className:"btn-console-object",disabled:w,icon:h(Lh,{type:f.type}),children:C},S);l.push(v)})}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})),T("div",{className:Y("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 Lf={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]})},Pf={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]})},Hf={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:Lf,COMMAND_HISTORY:Pf,NOTEBOOK:Hf},St=Object.freeze({FATAL:"FATAL",STDERR:"STDERR",ERROR:"ERROR",WARN:"WARN",STDOUT:"STDOUT",INFO:"INFO",DEBUG:"DEBUG",TRACE:"TRACE"}),Uf="#2d2a2e",Vf="#fcfcfa",Bf="#fcd65b",$f="#b2b1b2",Gf="#9edc6f",Wf="#76d9e4",zf="#f95d84",qf="#aa9af4",Yf="#f95d84",Kf="#fcfcfa",Xf="#7c7b7c",we={"error-foreground":"#f95d84",background:Uf,foreground:Vf,"line-height":"19px",string:Bf,"string-delim":"#929192",delimiter:$f,predefined:Gf,keyword:Wf,storage:zf,number:qf,operator:Yf,identifier:Kf,"namespace-identifier":"#f95d84","identifier-js":"#fcd65b",comment:Xf,"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",Qf={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/}}},Zf={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"]]}},Jf={id:jf,conf:Qf,language:Zf},eC="groovy",tC={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/}}},nC={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"]]}},sC={id:eC,conf:tC,language:nC},iC="scala",oC={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>))/}}},rC={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"]]}},lC={id:iC,conf:oC,language:rC},aC="deephavenDb",dC={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/}}},cC={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"]]}},hC={id:aC,conf:dC,language:cC},uC="log",mC={},pC={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"}]]}},gC={id:uC,conf:mC,language:pC},In=J.module("MonacoUtils");class lt{static init({getWorker:e}={}){In.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}),In.debug2("monaco theme: ",we),os.setTheme("dh-dark"),n([hC,Jf,sC,gC,lC]),In.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;In.debug2("Overriding default language loader:",i.id)}),e.forEach(s=>{lt.registerLanguage(s)})}static registerLanguage(e){In.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 In.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};In.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){In.error(s)}}static removeKeybinding(e,n){if(n===void 0)return;const s=e._standaloneKeybindingService._getResolver()._map.get(n);s!=null?s.forEach(i=>{In.debug2(`Removing Monaco keybinding ${n} for ${i.command}`),e._standaloneKeybindingService.addDynamicKeybinding(`-${i.command}`,null,()=>{})}):In.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)|Qd.fromString(s):(n.ctrlKey?cn.CtrlCmd:0)|(n.shiftKey?cn.Shift:0)|(n.altKey?cn.Alt:0)|(n.metaKey?cn.WinCtrl:0)|Qd.fromString(s)}}const tc=J.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:v}=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:v===2?4:v,range:R}});return{incomplete:!0,suggestions:c}}).catch(d=>(tc.error("There was an error retrieving completion items",d),{suggestions:[]}))}render(){return null}}const $l=J.module("ConsoleInput"),Ar=parseInt(we["line-height"],10),Wh=6,zh=6,fC=Ar+Wh+zh,Gl=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:Ar,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||($l.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:Ar,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-Gl&&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+Gl-1}),this.loadingPromise=ye.makeCancelable(s.getViewportData(),()=>s.close());const i=await this.loadingPromise;this.bufferIndex+=Gl,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)){$l.debug2("Promise canceled, not loading history");return}$l.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),fC),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:Y("console-input-wrapper",{disabled:t}),children:T("div",{className:Y("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 Lr=qh;Lr.defaultProps={maxHeight:Ar*10,scope:null,disabled:!1};Lr.INPUT_CLASS_NAME="console-input";const nc="pasted values",CC=[/^audio.*/,/^font.*/,/^image.*/,/^video.*/],Wl=[".csv",".tsv",".tab",".psv",".dsv",".txt"],sc=[".zip"],vi=class extends b.exports.Component{constructor(t){super(t),this.getValidExtensions=ge(e=>e?[...Wl,...sc]:[...Wl]),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"&&!CC.find(e=>e.test(t.type))}static isValidExtension(t,e=!1){return Wl.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")?rg:t.endsWith(".zip")?lg:ag}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 T("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==="")&&T("div",{className:"message-content",children:[h("div",{className:"message-icon",children:h(Z,{icon:dg})}),h("label",{children:"Drop file (or paste values) here to import"}),h("div",{className:"message-small",children:h("label",{children:"or"})}),h(U,{kind:"primary",onClick:this.handleSelectFile,children:"Select File..."})]}),s&&(o===void 0||o==="")&&T("div",{className:"selected-content",children:[h("div",{className:"selected-icon",children:h(Z,{icon:vi.getIcon(s)})}),T("div",{className:"selected-text",children:[h("label",{children:"Selected File"}),T("label",{className:"selected-name",children:[s,!n&&h(U,{kind:"ghost",className:"ml-2",onClick:this.unstageFile,icon:sn,tooltip:"Remove"})]})]})]}),Boolean(o)&&T("div",{className:"message-content",children:[h("div",{className:"message-icon",children:h(Z,{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",SC=2147483647,bC=-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>SC||s<bC?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 sr=J.module("CsvParser"),wC=650,Pr=class{static generateHeaderRecursive(t){let e="",n=t;return t>=26&&(e=e.concat(Pr.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 T("div",{className:"log-pane h-100 w-100",children:[T("div",{className:"log-pane-menu",children:[h(U,{kind:"ghost",className:"btn-clear-logs",onClick:this.handleClearClick,icon:ug,tooltip:"Clear log"}),h(U,{kind:"ghost",className:"btn-link-icon btn-overflow",icon:_o,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 NC extends nt{format(e){switch(e){case 1:case!0:return"true";case 0:case!1:return"false";default:return""}}}class _C extends nt{format(e){return String.fromCharCode(e)}}const mc=J.module("DateTimeColumnFormatter"),Ks=class extends nt{constructor({timeZone:t="",showTimeZone:e=!0,showTSeparator:n=!1,defaultDateTimeFormatString:s=Ks.DEFAULT_DATETIME_FORMAT_STRING}={}){super();const i=t||Ks.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(Ks.DEFAULT_TIME_ZONE_ID)}this.defaultDateTimeFormatString=s,this.showTimeZone=e,this.showTSeparator=n,this.formatStringMap=Ks.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[...Ks.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[...Ks.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=Ks;st.DEFAULT_DATETIME_FORMAT_STRING="yyyy-MM-dd HH:mm:ss.SSS";st.DEFAULT_TIME_ZONE_ID="America/New_York";const MC=J.module("DecimalColumnFormatter"),wn=class extends nt{constructor({defaultFormatString:t=wn.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 wn.makeFormat(t,e,nt.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(t="",e){return wn.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{MC.error("Invalid format arguments")}return""}};let ke=wn;ke.DEFAULT_FORMAT_STRING="###,##0.0000";ke.FORMAT_PERCENT=wn.makePresetFormat("Percent","##0.00%");ke.FORMAT_BASIS_POINTS=wn.makePresetFormat("Basis Points","###,##0 bp",1e4);ke.FORMAT_MILLIONS=wn.makePresetFormat("Millions","###,##0.000 mm",1e-6);ke.FORMAT_SCIENTIFIC_NOTATION=wn.makePresetFormat("Scientific Notation","0.0000E0");ke.FORMAT_ROUND=wn.makePresetFormat("Round","###,##0");ke.FORMAT_ROUND_TWO_DECIMALS=wn.makePresetFormat("0.00","###,##0.00");ke.FORMAT_ROUND_FOUR_DECIMALS=wn.makePresetFormat("0.0000","###,##0.0000");class kC extends nt{format(e){return`${e}`}}const xC=J.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{xC.error("Invalid format arguments")}return""}};let Qe=Ni;Qe.DEFAULT_FORMAT_STRING="###,##0";Qe.FORMAT_MILLIONS=Ni.makePresetFormat("Millions","###,##0.000 mm",1e-6);Qe.FORMAT_SCIENTIFIC_NOTATION=Ni.makePresetFormat("Scientific Notation","0.0000E0");class OC 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 Hn=$t;Hn.FULL_DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSSSSS";Hn.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 AC(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 LC(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=J.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 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"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();default:return null}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]=Hn.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 mg(`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]=Hn.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 _=re;_.dataType={BOOLEAN:"boolean",CHAR:"char",DATETIME:"datetime",DECIMAL:"decimal",INT:"int",STRING:"string",UNKNOWN:"unknown"};_.sortDirection={ascending:"ASC",descending:"DESC",reverse:"REVERSE",none:null};_.REVERSE_TYPE=Object.freeze({NONE:"none",PRE_SORT:"pre-sort",POST_SORT:"post-sort"});_.NUMBER_REGEX=/^-?\d+(\.\d+)?$/;class nn{static makeColumnFormatMap(e){return e==null?new Map:e.reduce((n,s)=>{const i=_.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 kC,this.typeFormatterMap=new Map([[_.dataType.BOOLEAN,new NC],[_.dataType.CHAR,new _C],[_.dataType.DATETIME,new st(n)],[_.dataType.DECIMAL,new ke(s)],[_.dataType.INT,new Qe(i)],[_.dataType.STRING,new OC]]),this.columnFormatMap=nn.makeColumnFormatMap(e),this.truncateNumbersWithPound=o}getColumnFormatMapForType(e,n=!1){const s=_.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=_.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(_.dataType.DATETIME)?.dhTimeZone?.id}}function PC(t){if(t&&t.formatter){const{formatter:e}=t;return e}}function HC(t){return{timeZone:t?.timeZone,defaultDateTimeFormatString:t?.defaultDateTimeFormat,showTimeZone:t?.showTimeZone,showTSeparator:t?.showTSeparator}}function UC(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:PC,getDateTimeFormatterOptions:HC,isCustomColumnFormatDefined:UC};Or.register([Sf,bf,wf,Tf,vf,Ef]);const su=typeof Bl=="function"?Bl(Or):Bl.default(Or),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 VC="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",BC="#403e41",$C="#5b5a5c",GC="#c0bfbf",WC="#4878ea",zC="rgba(91, 90, 92, 0.7)",It={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:VC,gridcolor:BC,linecolor:$C,zerolinecolor:GC,activecolor:WC,rangebgcolor:zC,"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"]}),so=J.module("ChartUtils"),fs=Object.freeze(I.calendar.DayOfWeek.values()),pc="io.deephaven.time.DateTime",qC=36e5,YC=1e6;function KC(t){return t.asDate!==void 0}function XC(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 _.isDateType(s)?(o=oe.getPlotlyDateFormat(e,s,i),o=oe.addTickSpacing(o,n,!0)):_.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/YC),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(v=>v.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){so.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),v=oe.getAxisPropertyName(C);if(v!=null){const y=oe.getAxisLayoutProperty(v,w);if(n.has(y))so.debug(`${y} already added.`);else{so.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:N,holidays:P,timeZone:H}=R,A=e?.getColumnTypeFormatter(pc);let q;gc(A)&&(q=A.dhTimeZone);const B=q?(H.standardOffset-q.standardOffset)/60:0;P.length>0&&F.push(...oe.createRangeBreakValuesFromHolidays(P,H,q)),D.forEach(K=>F.push({pattern:"hour",bounds:[oe.periodToDecimal(K.close)+B,oe.periodToDecimal(K.open)+B]})),N.length<fs.length&&oe.createBoundsFromDays(N).forEach(K=>F.push({pattern:"day of week",bounds:K})),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=0,s=0){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={left:r*m+(r>0?g/2:0),bottom:a*p+(a>0?f/2:0),top:u*p-(u<o?f/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),v=g.get(C),E=C===I.plot.AxisType.Y?i:s;k(w),k(v);for(let R=0;R<w.length;R+=1){const F=w[R],D=v.indexOf(F),N=oe.getAxisLayoutProperty(S,D);c[N]==null&&(c[N]=oe.makeLayoutAxis(C,l));const P=c[N];if(P!=null){oe.updateLayoutAxis(P,F,R,u,a,d,o);const{range:H,autorange:A}=P;if(r!=null&&H!==void 0&&(A===void 0||A===!1)){const q=r(F),[B,K]=q(H);so.debug("Setting downsample range",E,B,K),F.range(E,B,K)}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=qC*(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(KC(t))return I.i18n.DateTimeFormat.format(oe.DATE_FORMAT,t,e);if(XC(t))return t.asNumber()}return t}static wrapValue(t,e,n=null){if(_.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(" "):so.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=J.module("Chart"),go=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:go.convertIcon(Eh),attr:"fill-warning"}),n||s||i||r){const l=go.downsampleButtonTitle(s,i),a=go.downsampleButtonAttr(s,i),d=s?pg:gg;o.push({name:l,icon:go.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&&Or.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=go;iu.defaultProps={isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:Hn.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}};const kt=J.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 QC({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 H=async()=>{const q=await t.getWorkerHeapInfo();if(r(q),s||l){const B=(q.totalHeapSize-q.freeMemory)/q.maximumHeapSize,K=Date.now(),{timestamps:x,usages:O}=d.current;for(;x.length!==0&&K-x[0]>i*1.5;)x.shift(),O.shift();x.push(K),O.push(B)}else d.current={timestamps:[],usages:[]}};H();const A=setInterval(H,l?n:e);return()=>{clearInterval(A)}},[l,n,t,e,i,s]);const c=(P,H)=>Math.round(P*10**H)/10**H,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),v=S-C,y=(P,H,A=!1)=>T("div",{className:Y("heap-usage-info-row",{"heading-bottom-border":A}),children:[h("div",{className:"font-weight-bold",children:P}),h("div",{children:H})]}),{timestamps:E,usages:R}=d.current,F=E[E.length-1]??0,D=g/f,N=(g-p)/f;return T(be,{children:[T("div",{className:"max-memory",children:[h("div",{className:"total-memory",style:{width:`calc(${D*100}% - ${D*2}px`}}),h("div",{className:Y("used-memory",{"heap-overflow":(g-p)/f>.95}),style:{width:`calc(${N*100}% - ${N*2}px`}}),T("div",{className:"memory-text",children:[w.toFixed(1)," GB"]})]}),h(ut,{onEntered:()=>a(!0),onExited:()=>a(!1),interactive:!0,children:T("div",{className:"heap-tooltip",children:[y("In use:",`${v.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}}})}),T("div",{className:"heap-utilisation-text",children:["% utilization over ",Math.round(i/1e3/60)," min."]})]})})]})}const qa=Object.freeze({}),ZC=new Map,ru=t=>t.user,Ya=t=>t.storage,lu=t=>Ya(t).commandHistoryStorage,au=t=>Ya(t).fileStorage,JC=t=>Ya(t).workspaceStorage,ml=t=>t.workspace,Et=t=>ml(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,ko=t=>Et(t).timeZone,mu=t=>Et(t).showTimeZone,pu=t=>Et(t).showTSeparator,gu=t=>Et(t).truncateNumbersWithPound,eS=t=>Et(t).shortcutOverrides,tS=t=>Et(t).defaultNotebookSettings??qa,pl=t=>t.activeTool,nS=t=>t.plugins??ZC,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",sS=t=>({type:wu,payload:t}),yu=t=>({type:Tu,payload:t}),iS=t=>({type:vu,payload:t}),oS=t=>({type:Cu,payload:t}),rS=t=>({type:Su,payload:t}),lS=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(lS(o))},gl=t=>e=>e(Ru({settings:t})),fl=t=>({type:fu,payload:t}),aS=t=>({type:bu,payload:t}),dS=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 cS(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 hS=Ls(fu,null),uS=Ls(bu,null),mS=Ls(Cu,null),pS=Ls(Su,null),gS=Ls(vu,null),fS=xa({commandHistoryStorage:mS,fileStorage:pS,workspaceStorage:gS}),CS=Iu(wu,null),SS=Iu(Tu,null),bS=Ls(Eu,null),wS={activeTool:hS,plugins:uS,storage:fS,user:CS,workspace:SS,serverConfigValues:bS};class TS{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 TS,Cc=J.module("redux-logger"),vS=t=>e=>n=>{Cc.debug("dispatching",n);const s=e(n);return Cc.debug("next state",t.getState()),s},ES=J.module("redux-crashReporter"),yS=t=>e=>n=>{try{return e(n)}catch(s){throw ES.error("Error executing",n," with state ",t.getState(),":",s),s}},RS=[vS,yS,wp];Object.entries(wS).map(([t,e])=>Gi.register(t,e));const IS=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__??Ep,Cl=Tp(xa(Gi.reducers),IS(vp(...RS)));Gi.setListener(t=>{Cl.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 FS(t){return t.component!==void 0}const Nu=Object.freeze({type:"default",isClosable:!0,isFocusOnShow:!0,reorderEnabled:!0,title:""}),DS=Object.freeze(Object.defineProperty({__proto__:null,defaultConfig:Fu,isGLComponentConfig:Du,isReactComponentConfig:FS,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 NS=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 Sl(t){return window.requestAnimationFrame(t)}function _S(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 MS(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 xo 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(){Nr.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(){Nr.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 Vr=["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"],kS=[!0,!1,"row","column","stack","component","close","maximise","minimise","open in new window"];function ja(t){if(Vr.length>36)throw new Error("Too many keys in config minifier map");const e={};return Qa(t,e,"_min"),e}function fa(t){if(Vr.length>36)throw new Error("Too many keys in config minifier map");const e={};return Qa(t,e,"_max"),e}function Qa(t,e,n){const s=n==="_min"?xS:OS;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,Vr);e[l]=r}Qa(o,r,n)}else{const r=s(o,kS);if(Array.isArray(e))e[Number.parseInt(i,10)]=r;else{const l=s(i,Vr);e[l]=r}}}}function xS(t,e){if(typeof t=="string"&&t.length===1)return"___"+t;var n=e.indexOf(t);return n===-1?t:n.toString(36)}function OS(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 AS=Object.freeze(Object.defineProperty({__proto__:null,EventEmitter:pn,DragListener:xo,ReactComponentHandler:ku,BubblingEvent:Ca,EventHub:xu,getHashValue:_u,getQueryStringParam:Mu,animFrame:Sl,removeFromArray:_S,getUniqueId:Ka,filterXss:MS,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 Oo=Au;Oo._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 xo(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 Oo(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 xo(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 Oo(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 Za=Hu;Za._template='<div class="lm_dropTargetIndicator"><div class="lm_inner"></div></div>';class fo{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 ti extends Error{constructor(e,n){super(),this.name="Configuration Error",this.message=e,this.node=n}}const LS=Object.freeze(Object.defineProperty({__proto__:null,ConfigurationError:ti},Symbol.toStringTag,{value:"Module"}));function Fo(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,Fo(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 ti("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,Sl(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 ti('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 Br 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}),Sl(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 Br)||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 Ao(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(!!e&&(this.header.element.toggle(!!this._header.show),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 PS=Object.freeze(Object.defineProperty({__proto__:null,AbstractContentItem:Tt,ContentItem:Tt,Component:Vu,Root:Sa,RowOrColumn:Br,Stack:ba,isStack:Fo,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 xo(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 Oo(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 vr=class extends pn{constructor(t,e){super(),this.element=pe(vr._template),this.tabDropdownList=null,this.tabs=[],this.activeContentItem=null,this.closeButton=null,this.tabDropdownButton=null,this.tabNextButton=pe(vr._nextButtonTemplate),this.tabPreviousButton=pe(vr._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 fo(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 fo(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 fo(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 fo(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 Ao=vr;Ao._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("");Ao._previousButtonTemplate=['<ul class="lm_controls">','<li class="lm_tabpreviousbutton"></li>',"</ul>"].join("");Ao._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 xo(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),Sl(this._nextAnimationFrame.bind(this))}_measure(e){const n=e.offset();return{left:n?.left,top:n?.top,width:e.outerWidth(),height:e.outerHeight()}}}const HS=Object.freeze(Object.defineProperty({__proto__:null,BrowserPopout:Ou,DragProxy:Oo,DragSource:Lu,DragSourceFromEvent:Pu,DropTargetIndicator:Za,Header:Ao,HeaderButton:fo,Splitter:$u,Tab:Ja,TransitionIndicator:Gu},Symbol.toStringTag,{value:"Module"})),US={config:DS,container:NS,controls:HS,errors:LS,items:PS,utils:AS};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:Br.bind(this,!0),row:Br.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 Za,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 ti("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 ti(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(!Fo(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 ti(n,e);if(e.content.length>1)throw n="Top level content can't contain more then one element.",new ti(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=>{Fo(s)?e.push(s):s.isComponent||this._findAllStackContainersRecursive(e,s)})}}ed.__lm=US;const VS="_lm_root_15d73_3",BS="_lm_row_15d73_7",$S="_lm_item_15d73_7",GS="_lm_content_15d73_11",WS="_lm_dragging_15d73_17",zS="_lm_maximised_15d73_23",qS="_lm_maximise_placeholder_15d73_30",YS="_lm_splitter_15d73_34",KS="_lm_vertical_15d73_41",XS="_lm_drag_handle_15d73_41",jS="_lm_horizontal_15d73_46",QS="_lm_header_15d73_56",ZS="_lm_dropdown_open_15d73_63",JS="_lm_controls_15d73_69",eb="_lm_tabs_15d73_89",tb="_lm_tab_15d73_89",nb="_lm_title_15d73_104",sb="_lm_close_tab_15d73_111",ib="_lm_stack_15d73_120",ob="_lm_left_15d73_120",rb="_lm_right_15d73_121",lb="_lm_dragProxy_15d73_125",ab="_lm_items_15d73_148",db="_lm_tabdropdown_list_15d73_165",cb="_lm_bottom_15d73_192",hb="_lm_drop_tab_placeholder_15d73_207",ub="_lm_tabdropdown_15d73_165",mb="_lm_dropTargetIndicator_15d73_258",pb="_lm_inner_15d73_264",gb="_lm_transition_indicator_15d73_272",fb="_lm_popin_15d73_282",Cb="_lm_bg_15d73_297",Sb="_lm_icon_15d73_300",bb="_lm_goldenlayout_15d73_304",wb="_lm_selectable_15d73_340",Tb="_lm_active_15d73_370",vb="_lm_selected_15d73_388",Eb="_lm_keyboard_active_15d73_397",yb="_lm_popout_15d73_416",Rb="_lm_maximise_15d73_23",Ib="_lm_close_15d73_111",Fb="_lm_tabnextbutton_15d73_425",Db="_lm_tabpreviousbutton_15d73_428",Nb="_lm_title_before_15d73_544",_b="_lm_focusin_15d73_568",Mb="_lm_window_blur_15d73_573",kb="_lm_tabdropdown_search_15d73_631",xb="_march_15d73_1",Ob="_app_15d73_712",Ab="_plotly_15d73_721",Sc={"tab-height":"28px","drag-border-width":"5px",lm_root:VS,lm_row:BS,lm_item:$S,lm_content:GS,lm_dragging:WS,lm_maximised:zS,lm_maximise_placeholder:qS,lm_splitter:YS,lm_vertical:KS,lm_drag_handle:XS,lm_horizontal:jS,lm_header:QS,lm_dropdown_open:ZS,lm_controls:JS,lm_tabs:eb,lm_tab:tb,lm_title:nb,lm_close_tab:sb,lm_stack:ib,lm_left:ob,lm_right:rb,lm_dragProxy:lb,lm_items:ab,lm_tabdropdown_list:db,lm_bottom:cb,lm_drop_tab_placeholder:hb,lm_tabdropdown:ub,lm_dropTargetIndicator:mb,lm_inner:pb,lm_transition_indicator:gb,lm_popin:fb,lm_bg:Cb,lm_icon:Sb,lm_goldenlayout:bb,lm_selectable:wb,lm_active:Tb,lm_selected:vb,lm_keyboard_active:Eb,lm_popout:yb,lm_maximise:Rb,lm_close:Ib,lm_tabnextbutton:Fb,lm_tabpreviousbutton:Db,lm_title_before:Nb,"editor-unsaved-indicator":"_editor-unsaved-indicator_15d73_548","is-unsaved":"_is-unsaved_15d73_556",lm_focusin:_b,lm_window_blur:Mb,lm_tabdropdown_search:kb,march:xb,app:Ob,"js-plotly-plot":"_js-plotly-plot_15d73_721",plotly:Ab},bc=Object.freeze({tabHeight:parseInt(Sc["tab-height"],10),dragBorderWidth:parseInt(Sc["drag-border-width"],10)}),Ss=J.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 ir(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&&Fo(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&&ir(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&&ir(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)&&ir(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:(ir(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 T("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 Lb(t){return typeof t.id=="string"&&t.layout instanceof ed&&t.panelManager instanceof td&&typeof t.registerComponent=="function"}function Ps(t){if(!Lb(t))throw new Error(`Expected dashboard plugin props, but instead received ${t}`)}const an=J.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 Pb=J.module("PanelErrorBoundary");class Hb 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);Pb.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(Jr,{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},Ub=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}),Vb=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:Ub,EventHub:qu,Layout:Vb}),Be=(t,e,n)=>b.exports.useEffect(function(){return t.on(e,n),()=>{t.off(e,n)}},[t,e,n]),Yu="SET_DASHBOARD_DATA",Bb=cS(Yu,{},!1),$b={dashboardData:Bb},Gb=new Map,Wb=Object.freeze({}),zb=Object.freeze([]),qb=t=>t.dashboardData,Yt=(t,e)=>qb(t)[e]??Wb,Yb=(t,e)=>Yt(t,e).closed??zb,Ku=(t,e)=>Yt(t,e).openedMap??Gb,Xu=(t,e)=>({type:Yu,id:t,payload:e}),Vn=(t,e)=>(n,s)=>n(Xu(t,{...Yt(s(),t),...e}));Object.entries($b).map(([t,e])=>Gi.register(t,e));const or=J.module("DashboardLayout"),Kb=Object.freeze({}),Xb=[],vc=()=>{},Ec=t=>t;function ju({id:t,children:e,emptyDashboard:n=h("div",{children:"Dashboard is empty."}),layout:s,layoutConfig:i=Xb,onLayoutChange:o=vc,onLayoutInitialized:r=vc,hydrate:l=sd,dehydrate:a=nd}){const d=Oa(),c=yp(x=>Yt(x,t))??Kb,[u,m]=b.exports.useState(!1),[p,g]=b.exports.useState(!1),[f,C]=b.exports.useState(),[S]=b.exports.useState(c?.closed??[]),[w,v]=b.exports.useState(!1),y=b.exports.useMemo(()=>new Map,[]),E=b.exports.useMemo(()=>new Map,[]),R=Rp(),F=b.exports.useCallback((x,O,G=l,ee=a)=>{or.debug2("registerComponent",x,O,G,ee);function ne(X,se){const ce=O,{glContainer:Q,glEventHub:he}=X;return h(ph,{store:R,children:h(Hb,{glContainer:Q,glEventHub:he,children:h(ce,{...X,ref:se})})})}const V=de.forwardRef(ne),W=s.registerComponent(x,V);return y.set(x,G),E.set(x,ee),W},[l,a,y,E,s,R]),D=b.exports.useCallback((x,O)=>(y.get(x)??Ec)(O,t),[y,t]),N=b.exports.useCallback((x,O)=>(E.get(x)??Ec)(O,t),[E,t]),P=b.exports.useMemo(()=>new td(s,D,N,new Map,S,({closed:x,openedMap:O})=>{d(Vn(t,{closed:x,openedMap:O}))}),[N,d,D,t,S,s]),H=b.exports.useCallback(()=>{if(p)return;w||(r(),v(!0));const O=s.toConfig().content,G=ie.dehydrateLayoutConfig(O,N),ee=f==null||!ie.isEqual(f,G);or.debug("handleLayoutStateChanged",ee,O,G),ee&&(m(s.root.contentItems.length===0),C(G),o(G))},[N,w,p,f,s,o,r]),A=b.exports.useCallback(x=>{const O=ie.getIdFromContainer(x);s.eventHub.emit(Ee.DRAGGING,O),g(!0)},[s.eventHub]),q=b.exports.useCallback(x=>{const O=ie.getIdFromContainer(x);s.eventHub.emit(Ee.DROPPED,O),g(!1)},[s.eventHub]),B=b.exports.useCallback(x=>{if(or.debug2("handleComponentCreated",x),x==null||x.config==null||x.config.component==null||x.element==null)return;const G=`${x.config.component.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}-component`;x.element.addClass(G)},[]);Be(s,"stateChanged",H),Be(s,"itemPickedUp",A),Be(s,"itemDropped",q),Be(s,"componentCreated",B),Be(s.eventHub,Ee.TITLE_CHANGED,H);const K=rl(i);return b.exports.useEffect(function(){if(K!==i&&i!==f){or.debug("Setting new layout content...");const O=ie.hydrateLayoutConfig(i,D);for(;s.root.contentItems.length>0;)s.root.contentItems[0].remove();for(let G=0;G<O.length;G+=1)s.root.addChild(O[G]);m(s.root.contentItems.length===0)}},[D,s,i,f,P,K]),T(be,{children:[u&&n,de.Children.map(e,x=>x!=null?de.cloneElement(x,{id:t,layout:s,panelManager:P,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,zl=()=>{},Qb=Object.freeze({});function Zb({id:t="default",children:e,emptyDashboard:n,layoutConfig:s,layoutSettings:i=Qb,onLayoutConfigChange:o=zl,onGoldenLayoutChange:r=zl,onLayoutInitialized:l=zl,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 v=new ed(w,u.current),y=()=>{v.off("initialised",y),p(!0)};return v.on("initialised",y),a!=null&&v.setFallbackComponent(a),v.init(),f(v),r(v),()=>{v.destroy()}},[i,a,r,p,f]);const C=b.exports.useMemo(()=>Ln(()=>{g!=null&&g.isInitialised&&g?.updateSize()},jb),[g]);return b.exports.useEffect(function(){return window.addEventListener("resize",C),()=>{window.removeEventListener("resize",C)}},[C]),T("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 Sn="default";class Qu extends Error{constructor(){super(...arguments),this.isAssertionFailed=!0}}function yc(t){if(t==null)throw new Qu(`Expected 'val' to be defined, but received ${t}`)}class ql extends Error{constructor(){super(...arguments),this.isPasteError=!0}}function tt(t){return t?.isEditable!==void 0}function Rc(t){if(!tt(t))throw new Qu(`Expected 'model' to be editable, but received ${t}`)}function ze(t){return t?.hasExpandableRows!==void 0}var bn=(t=>(t.DOWN="DOWN",t.UP="UP",t.LEFT="LEFT",t.RIGHT="RIGHT",t))(bn||{});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=bn;function Jb(t){return Array.isArray(t)&&t.length===2&&(t[0]===null||typeof t[0]=="number")&&(t[1]===null||typeof t[1]=="number")}function rr(t){return Jb(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 Ze(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],v=d.get(w)??0,y=c.get(w)??0,E=y===0;if(!C||!E){let R=v+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],v=d.get(w)??0,y=c.get(w)??0,E=y===0;if(v<l-y)return null;if(!C||!E){let R=v+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 v=C+S;w?v+=m:p&&(v-=m);const y=v-m,E=v+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&&!rr(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&&rr(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 rr(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;rr(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 v=[[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(...v)}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,v=o,y=r;return n!=null&&(n>d&&(S+=u),n<f-c&&(v-=m)),e!=null&&(e>l&&(w+=p),e<C-a&&(y-=g)),{x1:S,y1:w,x2:v,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 z=Ne;z.PIXELS_PER_LINE=100/3;function L(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 lr(t,e=Lo.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+=L(i,l);r=s;for(let l=0;l<e&&n-l-1>=0;l+=1)r-=L(i,n-l-1),o.set(n-l-1,r);return o}const Zu=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:v,rowCount:y,floatingTopRowCount:E,floatingBottomRowCount:R,floatingLeftColumnCount:F,floatingRightColumnCount:D,columnHeaderMaxDepth:N}=a,P=this.getFirstRow(t),H=this.getFirstColumn(t),A=this.getGridX(t),q=this.getGridY(t),B=ze(a)&&a.hasExpandableRows?this.calculateTreePaddingX(t):0,K=0,x=this.getVisibleRowHeights(t),O=this.getVisibleColumnWidths(t,H,B),G=Array.from(x.keys()),ee=Array.from(O.keys()),ne=new Map([...x,...this.getFloatingRowHeights(t)]),V=new Map([...O,...this.getFloatingColumnWidths(t)]),W=this.getVisibleColumnXs(V,ee,s),X=this.getVisibleRowYs(ne,G,i),se=G.length>0?G[G.length-1]:n,ce=ee.length>0?ee[ee.length-1]:e,Q=this.getBottomViewport(t,G,X,ne),he=this.getRightViewport(t,ee,W,V),Se=this.getFloatingTopHeight(t,ne),Re=this.getFloatingBottomHeight(t,ne),et=this.getFloatingLeftWidth(t,V),yt=this.getFloatingRightWidth(t,V),je=Array.from(V.values()),Tn=Array.from(ne.values()),Ut=je.reduce((it,yn)=>it+yn,0)-s,De=Tn.reduce((it,yn)=>it+yn,0)-i,mt=s+Ut+g,at=i+De,Rt=o-A,Vt=r-q,vn=this.getLastLeft(t,null,Rt-g),on=this.getLastLeft(t,null,Rt-g-w),ci=this.getLastTop(t,null,Vt-Re),Hs=this.getLastTop(t,null,Vt-Re-w);let rn=on,cs=Hs;vn===0&&ci===0&&(rn=0,cs=0);const hi=rn>0,Qi=hi?w:0,ui=cs>0,mi=ui?w:0,Vo=A,Bo=N*C,hs=o-Vo-mi,Us=r-Bo-Qi,kl=v===1?hs/mt:(v-rn)/v,$o=y===1?Us/at:(y-cs)/y,Zi=hi?Ze(hs*kl,S,hs-1):0,Ji=ui?Ze(Us*$o,S,Us-1):0,Go=L(V,e,0),Wo=L(ne,n,0),xl=Go>0?s/Go:0,Ol=Wo>0?i/Wo:0,Al=v===1?s/(mt-Rt):(e+xl)/rn,Vs=y===1?i/(at-Vt):(n+Ol)/cs,Ll=hi?Al*(hs-Zi):0,zo=ui?Vs*(Us-Ji):0,qo=[...Array(E).keys(),...[...Array(R).keys()].map(it=>y-it-1)],eo=new Map([...X,...this.getFloatingRowYs(t,ne,Math.floor(r-q-Qi))]),Yo=[...Array(F).keys(),...[...Array(D).keys()].map(it=>v-it-1)],us=new Map([...W,...this.getFloatingColumnXs(t,V,Math.floor(o-A-mi))]),to=[];if(u)for(let it=u.range[0];it<=u.range[1];it+=1)to.push(it),V.has(it)||V.set(it,this.getVisibleColumnWidth(it,t)),us.has(it)||us.set(it,0);const Ko=G.concat(qo),Xo=ee.concat(Yo).concat(to),no=this.getModelRows(Ko,t),Pl=this.getModelColumns(Xo,t),jo=this.getVisibleRowTreeBoxes(ne,no,t),Qo=this.getTopVisible(t,eo,ne,G),Zo=this.getLeftVisible(t,us,V,ee),Jo=cs>0?this.getBottomVisible(t,eo,ne,G,q):se,er=rn>0?this.getRightVisible(t,us,V,ee,A):ce,{fontWidths:tr,userColumnWidths:Hl,userRowHeights:Ye,calculatedRowHeights:_t,calculatedColumnWidths:En}=this;return{rowHeight:m,rowHeaderWidth:p,rowFooterWidth:g,rowCount:y,columnWidth:f,columnCount:v,columnHeaderHeight:C,floatingTopRowCount:E,floatingBottomRowCount:R,floatingLeftColumnCount:F,floatingRightColumnCount:D,gridX:A,gridY:q,firstRow:P,firstColumn:H,treePaddingX:B,treePaddingY:K,left:e,top:n,bottom:se,right:ce,topOffset:i,leftOffset:s,topVisible:Qo,leftVisible:Zo,bottomVisible:Jo,rightVisible:er,bottomViewport:Q,rightViewport:he,width:o,height:r,maxX:Ut,maxY:De,lastLeft:rn,lastTop:cs,barHeight:Us,barTop:Bo,barWidth:hs,barLeft:Vo,handleHeight:Ji,handleWidth:Zi,hasHorizontalBar:hi,hasVerticalBar:ui,verticalBarWidth:mi,horizontalBarHeight:Qi,scrollX:Ll,scrollY:zo,scrollableContentWidth:mt,scrollableContentHeight:at,scrollableViewportWidth:Rt,scrollableViewportHeight:Vt,visibleRows:G,visibleColumns:ee,visibleRowHeights:x,visibleColumnWidths:O,floatingRows:qo,floatingColumns:Yo,allRows:Ko,allColumns:Xo,allRowHeights:ne,allColumnWidths:V,floatingTopHeight:Se,floatingBottomHeight:Re,floatingLeftWidth:et,floatingRightWidth:yt,visibleRowYs:X,visibleColumnXs:W,allRowYs:eo,allColumnXs:us,visibleRowTreeBoxes:jo,modelRows:no,modelColumns:Pl,movedRows:d,movedColumns:c,fontWidths:tr,userColumnWidths:Hl,userRowHeights:Ye,calculatedRowHeights:_t,calculatedColumnWidths:En,columnHeaderMaxDepth:N}}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 Ze(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 Ze(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=L(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=L(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=L(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+=L(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+=L(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+=L(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+=L(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(L(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(L(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=L(e,u),p=L(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=L(e,u),p=L(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=L(e,o)+L(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 L(this.modelRows,t);const{movedRows:n}=e,s=z.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 L(this.modelColumns,t);const{movedColumns:s}=e,i=z.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)),lr(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),lr(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,v=Math.ceil(n+w);return z.iterateAllItems(n,v,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)*Zu.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 L(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)),lr(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)),lr(n),this.userRowHeights=n}resetRowHeight(t){const e=new Map(this.userRowHeights);e.delete(t),this.userRowHeights=e,this.calculatedRowHeights.delete(t)}};let Lo=Zu;Lo.CACHE_SIZE=1e4;Lo.MAX_COLUMN_WIDTH=.8;const ew=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 tw(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 nw(t,e){const[n,s,i]=la.hex.rgb(t);return`rgba(${n}, ${s}, ${i}, ${e})`}const Fc={colorWithAlpha:nw,darkenForDepth:tw};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=L(l,g),C=s-a-f-this.dragOffset,S=L(c,g),w=this.targetSizes.get(S),v=this.resizingItems.length>1,y=this.hiddenItems.indexOf(g);let E=L(d,S);g===u&&(E+=m);let R=C;Math.abs(C-E)<=r.headerResizeSnapThreshold?R=E:w!==void 0&&C>w&&(v&&y!==0||y>0)?R=w:C<=r.headerResizeHiddenSnapThreshold&&(R=0),p.set(S,R),C<-r.headerResizeSnapThreshold&&R===0?y>=0&&v?(this.resizingItems.pop(),this.removeTargetSize(o,g),g=this.resizingItems[this.resizingItems.length-1],this.dragOffset-=this.targetSizes.get(L(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)):v?(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=L(a,l.index),c=L(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];L(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=L(s,n);let a=i.get(l);(a==null||a===0)&&(a=L(o,l)+r),this.targetSizes.set(l,a)}removeTargetSize(e,n){const s=e[this.modelIndexesProperty],i=L(s,n);this.targetSizes.delete(i)}}class bl 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=z.getHiddenColumns,this.getNextShownItem=z.getNextShownColumn,this.getSeparator=bl.getColumnSeparator}static getColumnSeparator(e,n,s,i){if(!i.allowColumnResize)return null;const{x:o,y:r,columnHeaderDepth:l}=e,{modelColumns:a}=n,d=z.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 Qn=class{constructor(){this.getCachedTruncatedString=Jt((t,e,n,s,i)=>Qn.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=>ol.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=Qn.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=Qn.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 Qn.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:L(u,r-1)+L(m,r-1)-.5}),l>0&&this.drawSelectedRanges(t,e,{top:d-l-1,bottom:d-1,minY:L(u,d-l)+.5,maxY:L(u,d-1)+L(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:L(f,r-1)+L(C,r-1)}),l>0&&this.drawSelectedRanges(t,e,{left:p-l,right:p-1,minX:L(f,p-l)+.5,maxX:L(f,p-1)+L(C,p-1)});for(let v=0;v<c.length;v+=1){const y=c[v];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=L(c,i-1)+L(m,i-1)+.5;t.moveTo(0,w),t.lineTo(g,w)}if(o>0){const w=L(c,a-o)-.5;t.moveTo(0,w),t.lineTo(g,w)}if(r>0){const w=L(u,r-1)+L(p,r-1)+.5;t.moveTo(w,0),t.lineTo(w,f)}if(l>0){const w=L(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=L(c,i-1)+L(m,i-1)+.5;t.moveTo(0,w),t.lineTo(g,w)}if(o>0){const w=L(c,a-o)-.5;t.moveTo(0,w),t.lineTo(g,w)}if(r>0){const w=L(u,r-1)+L(p,r-1)+.5;t.moveTo(w,0),t.lineTo(w,f)}if(l>0){const w=L(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)?L(g,l+1):-10,minY:d>0&&p.has(d+1)?L(p,d+1):-10,maxX:a>0&&g.has(c-a-1)?L(g,c-a-1)+L(f,c-a-1)-.5:C+10,maxY:r>0&&p.has(u-r-1)?L(p,u-r-1)+L(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=(v,y)=>{const E=ze(a)?a.depthForRow(v):0,R=m[v%m.length],F=R[Math.min(E,R.length-1)];if(f.has(F)||f.set(F,[]),f.get(F).push(v),y!=null){const D=ze(a)?a.depthForRow(y):0;D<E?C.push(v):D>E&&S.push(y)}};for(let v=0;v<n.length;v+=1){const y=n[v],E=v>0?n[v-1]:void 0;w(y,E)}if(f.forEach((v,y)=>{t.fillStyle=y,t.beginPath();for(let E=0;E<v.length;E+=1){const R=v[E],F=L(p,R),D=L(g,R);t.rect(i,F,o,D)}t.fill()}),C.length>0){t.save();const v=this.getCachedColorWithAlpha(u,.15),y=this.getCachedColorWithAlpha(u,0),E=t.createLinearGradient(0,0,0,c);E.addColorStop(0,v),E.addColorStop(1,y),t.fillStyle=E;for(let R=0;R<C.length;R+=1){const F=C[R],D=L(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 v=this.getCachedColorWithAlpha(u,0),y=this.getCachedColorWithAlpha(u,.15),E=t.createLinearGradient(0,0,0,c);E.addColorStop(0,v),E.addColorStop(1,y),t.fillStyle=E;for(let R=0;R<S.length;R+=1){const F=S[R],D=L(p,F),N=L(g,F),P=D+N-c;t.translate(0,P),t.fillRect(i,0,o,c),t.translate(0,-P)}t.restore()}}drawMouseColumnHover(t,e){const{mouseX:n,mouseY:s,theme:i,metrics:o}=e;if(n==null||s==null)return;const r=z.getColumnAtX(n,o);if(r==null||i.columnHoverBackgroundColor==null)return;const{allColumnWidths:l,allColumnXs:a,maxY:d}=o;if(s>d)return;const c=L(a,r),u=L(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=z.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=z.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=L(l,n),c=L(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=L(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=L(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=L(c,s),C=L(d,n),S=r.backgroundColorForCell(C,f,l),w=n===a,v=ze(r)&&r.hasExpandableRows;if(S!=null){const y=L(u,n)+1,E=L(p,s)+1,R=L(m,n)-1,F=L(g,s)-1;t.fillStyle=S,t.fillRect(y,E,R,F)}w&&v&&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=L(i,n),d=L(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=L(d,n),S=L(u,s),w=L(c,n),v=L(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+v*.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=L(m,s),f=L(u,s),C=L(c,n),S=i??r.textForCell(C,f),w=r.truncationCharForCell(C,f),v=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),N=d.get(t.font)??Qn.DEFAULT_FONT_WIDTH,P=this.getCachedTruncatedString(t,S,R,N,w);P&&t.fillText(P,F,D)}v&&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=L(u,a),v=L(m,a),y=L(p,n),E=L(g,n);if(!ze(i)||!i.isRowExpandable(n))return;const R=L(f,n),F=o!=null&&r!=null&&o>=d+w&&o<=d+w+v&&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=L(d,a),C=L(c,n),S=L(u,n),w=s!==void 0?o.depthForRow(s):0,v=l>w?l-w:0;if(t.strokeStyle=g,t.lineWidth=1,l-v>0){t.beginPath();for(let y=0;y<l-v;y+=1){const E=f+y*m+m*.5+p+.5;t.moveTo(E,C),t.lineTo(E,C+S)}t.stroke()}if(v>0){t.beginPath();for(let y=l-v;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:v,columnHeaderMaxDepth:y}=o;if(d<=0)return;const{headerHiddenSeparatorSize:E,headerHiddenSeparatorHoverColor:R,headerSeparatorColor:F,headerSeparatorHoverColor:D}=i,N=d*.5,P=d*(y-1)+d*.5-N*.5,H=C>0;if(t.save(),this.drawColumnHeadersForRange(t,e,[p[0],p[p.length-1]],{minX:u+S,maxX:m-w}),H&&this.drawColumnHeadersForRange(t,e,[c[0],c[c.length-1]],{minX:u,maxX:u+S}),F){t.strokeStyle=F;const A=[...g.entries()].filter(([q,B])=>B===0).map(([q])=>q);t.beginPath(),t.fillStyle=F;for(let q=0;q<A.length;q+=1){const B=A[q],K=L(f,B),x=L(g,B),O=u+K+x+.5-E*.5;t.rect(O,P,E,N)}t.fill()}if(D){let{index:A,depth:q}=r??{};if(A==null&&n!=null&&s!=null){const K=bl.getColumnSeparator(z.getGridPointFromXY(n,s,o),o,a,i);A=K?.index,q=K?.depth}let B;if(A==null)B=!1;else{const K=v.get(A),x=v.get(A+1);K==null||x==null?B=!1:B=a.textForColumnHeader(K,q)!==a.textForColumnHeader(x,q)}if(B&&A!=null&&q!=null&&(!l||r!=null)){t.strokeStyle=D;const K=L(f,A),x=L(g,A),O=u+K+x+.5,G=p.indexOf(A),ee=G<p.length-1?p[G+1]:null,ne=ee!=null?g.get(ee):null,V=x===0,W=ne!=null&&ne===0;V?(t.strokeStyle=R,t.fillStyle=R,t.fillRect(O,P,E*.5,N)):W&&(t.fillStyle=D,t.fillRect(O-E*.5,P,E*.5,N)),t.beginPath(),t.moveTo(O,(y-q-1)*d),t.lineTo(O,(y-q)*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:v}=s,y=v-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,v);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,N=L(a,F),P=r.textForColumnHeader(N,i),H=r.colorForColumnHeader(N,i);let A=L(d,F)+c,q=A+L(p,F);if(P!=null){let B=F-1;for(;B>=0&&(q-A<y||A>w);){const G=a.get(B)??z.getModelIndex(B,g);if(G==null||r.textForColumnHeader(G,i)!==P)break;A-=m.get(G)??u.get(G)??C,B-=1}let K=F+1;for(;K<D&&(q-A<y||q<v);){const G=a.get(K)??z.getModelIndex(K,g);if(r.textForColumnHeader(G,i)!==P)break;q+=m.get(G)??u.get(G)??C,K+=1}F=K-1;const x=q-A>=y;let O=A;x&&(q<v?O=q-y:A<w&&(O=w)),this.drawColumnHeader(t,e,P,O,Math.min(q-A,y),{backgroundColor:H??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=L(l,n),u=L(a,n)+d,m=L(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)??Qn.DEFAULT_FONT_WIDTH,y=(i-d*2)/w,{backgroundColor:E=u,separatorColor:R=p}=o??{};let{textColor:F=m}=o??{};try{const V=this.getCachedColorIsDark(E),W=this.getCachedColorIsDark(F);V&&W?F=f:!V&&!W&&(F=g)}catch{}let{minX:D=0,maxX:N=S}=r??{};t.save(),t.rect(D,0,N-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 P=n;y<=0?P="":P.length>y&&(P=`${P.substring(0,y-1)}\u2026`);const H=P.length*w;let A=s+i*.5;const q=c*.5;D+=d,N-=d;const B=s+d,K=Ze(B,D,N),x=s+i-d,G=Ze(x,D,N)-K,ee=A-H*.5<D,ne=A+H*.5>N;ee?H<G?A=D+H*.5:A=x-H*.5:ne&&(H<G?A=N-H*.5:A=B+H*.5),t.textAlign="center",t.fillText(P,A,q),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,v=a*.5,y=a*.5-v*.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],N=L(m,D),P=L(u,D);if(P>0){const H=l+N+P+.5;t.moveTo(0,H),t.lineTo(a,H),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],N=L(m,D),P=L(u,D),H=l+N+P+.5-f*.5;t.rect(y,H,v,f)}t.fill()}if(w){let{index:E=null}=r??{};if(E==null&&n!=null&&s!=null&&(E=z.getRowSeparatorIndex(n,s,i,o)),E!=null){t.strokeStyle=w;const R=L(m,E),F=L(u,E),D=l+R+F+.5,N=c.indexOf(E),P=N<c.length-1?c[N+1]:null,H=P!=null?u.get(P):null,A=F===0,q=H!=null&&H===0;A?(t.strokeStyle=C,t.fillStyle=C,t.fillRect(y,D,v,f*.5)):q&&(t.fillStyle=w,t.fillRect(y,D-f*.5,v,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=L(u,R),D=L(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=L(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:v,headerBackgroundColor:y,headerColor:E,headerHiddenSeparatorSize:R,headerHiddenSeparatorHoverColor:F,headerSeparatorColor:D,headerSeparatorHoverColor:N}=r,P=m*.5,H=m*.5-P*.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 B=[];let K=!1;for(let x=0;x<f.length;x+=1){const O=f[x],G=L(S,O),ee=L(C,O);if(ee>0){const ne=a+G+ee+.5;t.moveTo(A+.5,ne),t.lineTo(A+m-.5,ne),K=!1}else K||(K=!0,B.push(O))}t.moveTo(A+.5,a),t.lineTo(A+.5,p),t.stroke(),t.beginPath(),t.fillStyle=D;for(let x=0;x<B.length;x+=1){const O=B[x],G=L(S,O),ee=L(C,O),ne=a+G+ee+.5-R*.5;t.rect(A+H,ne,P,R)}t.fill()}if(N){let{index:B=null}=l??{};if(B==null&&n!=null&&s!=null&&(B=z.getRowSeparatorIndex(n,s,i,r)),B!=null){t.strokeStyle=N;const K=L(S,B),x=L(C,B),O=a+K+x+.5,G=f.indexOf(B),ee=G<f.length-1?f[G+1]:null,ne=ee!=null?C.get(ee):null,V=x===0,W=ne!=null&&ne===0;V?(t.strokeStyle=F,t.fillStyle=F,t.fillRect(H,O,P,R*.5)):W&&(t.fillStyle=N,t.fillRect(H,O-R*.5,P,R*.5)),t.beginPath(),t.moveTo(A+.5,O),t.lineTo(A+m+.5,O),t.stroke()}}t.beginPath(),t.rect(A,a,m,p),t.clip(),t.fillStyle=E,t.textAlign="left";const q=A+v;for(let B=0;B<f.length;B+=1){const K=f[B],x=L(C,K);if(x>0){const O=L(S,K)+a,G=L(u,K),ee=O+x*.5;t.fillText(o.textForRowFooter(G),q,ee)}}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:v=a.top,right:y=a.right,bottom:E=a.bottom,minY:R=-10,maxY:F=S+10,minX:D=-10,maxX:N=C+10}=n;if(c.length===0)return;const P=tt(d)&&d.isEditable&&l==null&&o==null&&r==null&&s!=null&&i!=null&&p.has(s)&&f.has(i);if(P){const H=L(p,s),A=L(f,i),q=L(m,s),B=L(g,i);t.save(),t.beginPath(),t.rect(0,0,C,S),t.rect(H,A,q,B),t.clip("evenodd")}t.beginPath();for(let H=0;H<c.length;H+=1){const A=c[H],q=A.startColumn!==null?A.startColumn:w,B=A.startRow!==null?A.startRow:v,K=A.endColumn!==null?A.endColumn:y,x=A.endRow!==null?A.endRow:E;if(x>=v&&E>=B&&K>=w&&y>=q){const O=q>=w&&p.has(q)?Math.round(L(p,q))+.5:D,G=B>=v&&f.has(B)?Math.max(Math.round(L(f,B))+.5,.5):R,ee=K<=y&&p.has(K)?Math.round(L(p,K)+L(m,K))-.5:N,ne=x<=E&&f.has(x)?Math.round(L(f,x)+L(g,x))-.5:F;t.rect(O,G,ee-O,ne-G)}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()}P&&s!=null&&i!=null&&(t.restore(),this.drawActiveCell(t,e,s,i))}drawActiveCell(t,e,n,s,i=Qn.ACTIVE_CELL_BORDER_WIDTH){const{metrics:o,theme:r}=e,{allColumnWidths:l,allColumnXs:a,allRowHeights:d,allRowYs:c}=o,u=L(a,n),m=L(c,s),p=L(l,n),g=L(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:v}=t;t.beginPath(),t.lineWidth=i,t.strokeStyle=r.selectionOutlineColor,this.drawRoundedRect(t,f,C,S,w),t.stroke(),t.lineWidth=v}drawRoundedRect(t,e,n,s,i,o=Qn.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:v}=s,y=w.get(l[0])??z.getModelIndex(l[0],S),E=r.getColumnHeaderGroup(y,a);if(a>0&&!E)return;const[R,F]=l,D=L(u,R),P=L(u,F)+L(m,F)-D,H=n.left,{backgroundColor:A,font:q,headerFont:B,reorderOffset:K,shadowBlur:x,shadowColor:O}=o,G=(f-a-1)*C;t.save(),t.translate(d,0),t.save(),t.beginPath(),t.rect(v,0,g,p),t.clip(),t.fillStyle=A,t.fillRect(D,G,P,p),t.restore(),t.translate(0,K),t.save(),t.shadowColor=O,t.shadowBlur=x,t.fillStyle=A,t.fillRect(n.left,G+K,n.width,p),t.restore(),t.beginPath(),t.rect(n.left,G,n.width+1,p),t.clip(),t.translate(H-D,0),t.font=B;const ee=[];for(let ne=n.range[0];ne<=n.range[1];ne+=1)ee.push(ne);this.drawColumnHeaders(t,e),this.drawColumnHeadersForRange(t,e,[ee[0],ee[ee.length-1]],{minX:D,maxX:g}),t.translate(0,c),t.font=q,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=L(d,n),p=L(c,n)+1,{backgroundColor:g,font:f,headerFont:C,reorderOffset:S,shadowBlur:w,shadowColor:v}=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=v,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:v,barTop:y}=o,{scrollBarBackgroundColor:E,scrollBarHoverBackgroundColor:R,scrollBarCasingColor:F,scrollBarCornerColor:D,scrollBarColor:N,scrollBarHoverColor:P,scrollBarActiveColor:H,scrollBarSize:A,scrollBarHoverSize:q,scrollBarCasingWidth:B,scrollBarSelectionTick:K,scrollBarSelectionTickColor:x,scrollBarActiveSelectionTickColor:O,autoSelectRow:G,autoSelectColumn:ee}=a,ne=r!=null&&l!=null&&r<=d&&l<=c,V=s||C&&!n&&!i&&r!=null&&l!=null&&r>=d-q&&l>=y&&ne,W=n||f&&!s&&!i&&!V&&r!=null&&l!=null&&l>=c-q&&r>=v&&ne,X=W?q:A,se=V?q:A;if(t.translate(v,y),f&&C&&(t.fillStyle=F,t.fillRect(d-v-A,c-y-A,A,A),t.fillStyle=D,t.fillRect(d-v-A+B,c-y-A+B,A-B,A-B)),f){const ce=p,Q=c-y-X;if(t.fillStyle=F,t.fillRect(0,Q,S,X-B),t.fillStyle=W?R:E,t.fillRect(0,Q+B,S,X-B),n?t.fillStyle=H:W?t.fillStyle=P:t.fillStyle=N,t.fillRect(ce,Q+B,m,X-B),!G&&K&&x!=null&&O!=null){t.fillStyle=x;const{selectedRanges:he,cursorColumn:Se}=e,{lastLeft:Re,columnCount:et}=o,je=[...he].filter(De=>De.startColumn!=null&&De.endColumn!=null).map(De=>[De.startColumn,De.endColumn]).sort(z.compareRanges),Tn=z.mergeSortedRanges(je),Ut=De=>De<=Re?De/Re*(S-m):S-m+(De-Re)/(et-Re)*m;for(let De=0;De<Tn.length;De+=1){const mt=Tn[De],at=mt[0],Rt=mt[1];if(at!=null&&Rt!=null&&(at!==Se||Rt!==Se)){const Vt=Ut(at),vn=Math.max(1,Math.round(Ut(Rt+1)-Vt)),on=X-B;t.fillRect(Vt,Q+B+Math.round(on/3),vn,Math.round(on/3))}}if(Se!=null){const De=Ut(Se),mt=2,at=X-B;t.fillStyle=O,t.fillRect(De,Q+B,mt,at)}}}if(C){const ce=d-v-se,Q=g;if(t.fillStyle=F,t.fillRect(ce,0,se-B,w),t.fillStyle=V?R:E,t.fillRect(ce+B,0,se-B,w),s?t.fillStyle=H:V?t.fillStyle=P:t.fillStyle=N,t.fillRect(ce+B,Q,se-B,u),!ee&&K&&x!=null&&O!=null){const{selectedRanges:he,cursorRow:Se}=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 Tn=[...he].filter(De=>De.startRow!=null&&De.endRow!=null).map(De=>[De.startRow,De.endRow]).sort(z.compareRanges),Ut=z.mergeSortedRanges(Tn);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!==Se||Rt!==Se)){const Vt=yt(at),vn=se-B,on=Math.max(1,Math.round(yt(Rt+1)-Vt));t.fillRect(ce+B+Math.round(vn/3),Vt,Math.round(vn/3),on)}}if(Se!=null){const De=Math.round(yt(Se)),mt=se-B,at=2;t.fillStyle=O,t.fillRect(ce+B,De,mt,at)}}}t.translate(-v,-y)}};let ri=Qn;ri.DEFAULT_FONT_WIDTH=10;ri.DEFAULT_EDGE_RADIUS=2;ri.ACTIVE_CELL_BORDER_WIDTH=2;const Dc=100;class sw 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=z.isModifierKeyDown(s),C=s.shiftKey;f||(C?n.trimSelectedRanges():n.clearSelectedRanges());const S=n.getTheme(),{autoSelectRow:w,autoSelectColumn:v}=S;return(r!==null||!v)&&(l!==null||!w)&&(n.focus(),n.moveCursorToPosition(r,l,C,!1,C&&f)),this.startPoint=e,this.hasExtendedFloating=!1,this.dragBounds=z.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=z.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:v,floatingBottomRowCount:y,floatingLeftColumnCount:E,floatingRightColumnCount:R,columnCount:F,rowCount:D,bottom:N,right:P,topVisible:H,bottomVisible:A,leftVisible:q,rightVisible:B}=d;this.hasExtendedFloating||(s!==null&&s<v&&l>=v?(l=v,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&&!z.isFloatingRow(s,d)&&z.isFloatingRow(l,d)&&(s>l&&l<m?l=H-1:s<l&&l>N&&(l=A+1)),i!==null&&!z.isFloatingColumn(i,d)&&z.isFloatingColumn(a,d)&&(i>a&&a<c?a=q-1:i<a&&a>P&&(a=B+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,iw=1e3/60,ar=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)??z.getModelIndex(t,o),g=s.getColumnHeaderGroup(p,e),f=g!=null;let C,S,w;if(g!=null){const[v,y]=g.getVisibleRange(o);C=r.get(v)??u,S=(r.get(y)??m)+(a.get(y)??0),w=[v,y]}else{const v=r.get(t);if(v==null)return null;C=v,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 ow 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-=ar;m<0;){u-=1;const f=z.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+=ar;let f=c.get(i);for(;f!==void 0&&m>f;){u+=1,m-=f;const C=z.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"?-ar:ar),e.setState({left:u,leftOffset:m}),(n==="left"&&u===0&&r===0||n==="right"&&u===o)&&this.clearScrollInterval())},iw))}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(z.getColumnAtX(Ze(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:N=0}=bs(F[1],0,l,o)??{};this.draggingOffset=e-(N-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(z.getModelIndex(F,r));)F+=1;else for(F-=1;F>p.visibleIndex&&!o.isColumnMovable(z.getModelIndex(F,r));)F-=1;if(F!==p.visibleIndex){m||(F-=p.range[1]-p.range[0]);const N=this.moveColumn(p,F,r);n.setState({movedColumns:N,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,v=o.getColumnHeaderParentGroup(p.modelIndex,p.depth);let y,E=(v?.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?z.moveRange(e.range,n,s):z.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=Ze((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 rw 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=L(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=L(f,R)+L(g,R)*.5+p}let w=C;if(i<c){const R=i+1;w=L(f,R)+L(g,R)*.5+p}let{movedRows:v}=n.state;r<S&&i>0&&s.isRowMovable(i-1)?(v=z.moveItem(i,i-1,v),i-=1):w<r&&i<m-1&&s.isRowMovable(i+1)&&(v=z.moveItem(i,i+1,v),i+=1),n.setState({movedRows:v,draggingRow:i});const y=p+L(g,a)*.5,E=p+L(f,u)+L(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=z.getHiddenRows,this.getNextShownItem=z.getNextShownRow,this.getSeparator=rd.getRowSeparator}static getRowSeparator(e,n,s,i){if(!i.allowRowResize)return null;const{x:o,y:r}=e,l=z.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=L(u,s),S=L(m,s),w=L(g,i),v=L(p,i);if(o>=a+C&&o<=a+C+S&&r>=d+w&&r<=d+w+v)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,z.isModifierKeyDown(s)),!0}return!1}}class lw 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=Ze((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 aw 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 di{constructor(e=5e3){this.order=e}onDown(e,n){return!1}}class dw extends di{onDown(e,n){switch(e.key){case"a":if(z.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 z.isModifierKeyDown(e)?!1:this.handlePageUp(e,n);case"j":case"J":return z.isModifierKeyDown(e)?!1:this.handlePageDown(e,n);case"h":case"H":return z.isModifierKeyDown(e)?!1:(e.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(0,n.state.cursorRow,e.shiftKey),!0);case"l":case"L":{if(z.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(z.isModifierKeyDown(e)?n.state.cursorColumn:0,z.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(z.isModifierKeyDown(e)?n.state.cursorColumn:i-1,z.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=z.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=Ze(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=Ze(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 cw extends di{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 hw extends di{onDown(e,n){if(z.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 uw(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 mw(t){const e=[];return t.forEach(n=>{const s=n.textContent??"";s.length>0&&e.push(s.split(/\t|\u00a0\u00a0 \u00a0/))}),e}function pw(t){const e=t.querySelector("table");if(e!=null)return uw(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 T("div",{className:"log-pane h-100 w-100",children:[T("div",{className:"log-pane-menu",children:[h(U,{kind:"ghost",className:"btn-clear-logs",onClick:this.handleClearClick,icon:ug,tooltip:"Clear log"}),h(U,{kind:"ghost",className:"btn-link-icon btn-overflow",icon:_o,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 NC extends nt{format(e){switch(e){case 1:case!0:return"true";case 0:case!1:return"false";default:return""}}}class _C extends nt{format(e){return String.fromCharCode(e)}}const mc=J.module("DateTimeColumnFormatter"),Ks=class extends nt{constructor({timeZone:t="",showTimeZone:e=!0,showTSeparator:n=!1,defaultDateTimeFormatString:s=Ks.DEFAULT_DATETIME_FORMAT_STRING}={}){super();const i=t||Ks.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(Ks.DEFAULT_TIME_ZONE_ID)}this.defaultDateTimeFormatString=s,this.showTimeZone=e,this.showTSeparator=n,this.formatStringMap=Ks.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[...Ks.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[...Ks.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=Ks;st.DEFAULT_DATETIME_FORMAT_STRING="yyyy-MM-dd HH:mm:ss.SSS";st.DEFAULT_TIME_ZONE_ID="America/New_York";const MC=J.module("DecimalColumnFormatter"),wn=class extends nt{constructor({defaultFormatString:t=wn.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 wn.makeFormat(t,e,nt.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(t="",e){return wn.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{MC.error("Invalid format arguments")}return""}};let ke=wn;ke.DEFAULT_FORMAT_STRING="###,##0.0000";ke.FORMAT_PERCENT=wn.makePresetFormat("Percent","##0.00%");ke.FORMAT_BASIS_POINTS=wn.makePresetFormat("Basis Points","###,##0 bp",1e4);ke.FORMAT_MILLIONS=wn.makePresetFormat("Millions","###,##0.000 mm",1e-6);ke.FORMAT_SCIENTIFIC_NOTATION=wn.makePresetFormat("Scientific Notation","0.0000E0");ke.FORMAT_ROUND=wn.makePresetFormat("Round","###,##0");ke.FORMAT_ROUND_TWO_DECIMALS=wn.makePresetFormat("0.00","###,##0.00");ke.FORMAT_ROUND_FOUR_DECIMALS=wn.makePresetFormat("0.0000","###,##0.0000");class kC extends nt{format(e){return`${e}`}}const xC=J.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{xC.error("Invalid format arguments")}return""}};let Qe=Ni;Qe.DEFAULT_FORMAT_STRING="###,##0";Qe.FORMAT_MILLIONS=Ni.makePresetFormat("Millions","###,##0.000 mm",1e-6);Qe.FORMAT_SCIENTIFIC_NOTATION=Ni.makePresetFormat("Scientific Notation","0.0000E0");class OC 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 Hn=$t;Hn.FULL_DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSSSSS";Hn.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 AC(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 LC(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=J.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 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"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();default:return null}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]=Hn.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 mg(`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]=Hn.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 _=re;_.dataType={BOOLEAN:"boolean",CHAR:"char",DATETIME:"datetime",DECIMAL:"decimal",INT:"int",STRING:"string",UNKNOWN:"unknown"};_.sortDirection={ascending:"ASC",descending:"DESC",reverse:"REVERSE",none:null};_.REVERSE_TYPE=Object.freeze({NONE:"none",PRE_SORT:"pre-sort",POST_SORT:"post-sort"});_.NUMBER_REGEX=/^-?\d+(\.\d+)?$/;class nn{static makeColumnFormatMap(e){return e==null?new Map:e.reduce((n,s)=>{const i=_.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 kC,this.typeFormatterMap=new Map([[_.dataType.BOOLEAN,new NC],[_.dataType.CHAR,new _C],[_.dataType.DATETIME,new st(n)],[_.dataType.DECIMAL,new ke(s)],[_.dataType.INT,new Qe(i)],[_.dataType.STRING,new OC]]),this.columnFormatMap=nn.makeColumnFormatMap(e),this.truncateNumbersWithPound=o}getColumnFormatMapForType(e,n=!1){const s=_.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=_.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(_.dataType.DATETIME)?.dhTimeZone?.id}}function PC(t){if(t&&t.formatter){const{formatter:e}=t;return e}}function HC(t){return{timeZone:t?.timeZone,defaultDateTimeFormatString:t?.defaultDateTimeFormat,showTimeZone:t?.showTimeZone,showTSeparator:t?.showTSeparator}}function UC(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:PC,getDateTimeFormatterOptions:HC,isCustomColumnFormatDefined:UC};Or.register([Sf,bf,wf,Tf,vf,Ef]);const su=typeof Bl=="function"?Bl(Or):Bl.default(Or),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 VC="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",BC="#403e41",$C="#5b5a5c",GC="#c0bfbf",WC="#4878ea",zC="rgba(91, 90, 92, 0.7)",It={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:VC,gridcolor:BC,linecolor:$C,zerolinecolor:GC,activecolor:WC,rangebgcolor:zC,"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"]}),so=J.module("ChartUtils"),fs=Object.freeze(I.calendar.DayOfWeek.values()),pc="io.deephaven.time.DateTime",qC=36e5,YC=1e6;function KC(t){return t.asDate!==void 0}function XC(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 _.isDateType(s)?(o=oe.getPlotlyDateFormat(e,s,i),o=oe.addTickSpacing(o,n,!0)):_.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/YC),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(v=>v.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){so.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),v=oe.getAxisPropertyName(C);if(v!=null){const y=oe.getAxisLayoutProperty(v,w);if(n.has(y))so.debug(`${y} already added.`);else{so.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:N,holidays:P,timeZone:H}=R,A=e?.getColumnTypeFormatter(pc);let q;gc(A)&&(q=A.dhTimeZone);const B=q?(H.standardOffset-q.standardOffset)/60:0;P.length>0&&F.push(...oe.createRangeBreakValuesFromHolidays(P,H,q)),D.forEach(K=>F.push({pattern:"hour",bounds:[oe.periodToDecimal(K.close)+B,oe.periodToDecimal(K.open)+B]})),N.length<fs.length&&oe.createBoundsFromDays(N).forEach(K=>F.push({pattern:"day of week",bounds:K})),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=0,s=0){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={left:r*m+(r>0?g/2:0),bottom:a*p+(a>0?f/2:0),top:u*p-(u<o?f/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),v=g.get(C),E=C===I.plot.AxisType.Y?i:s;k(w),k(v);for(let R=0;R<w.length;R+=1){const F=w[R],D=v.indexOf(F),N=oe.getAxisLayoutProperty(S,D);c[N]==null&&(c[N]=oe.makeLayoutAxis(C,l));const P=c[N];if(P!=null){oe.updateLayoutAxis(P,F,R,u,a,d,o);const{range:H,autorange:A}=P;if(r!=null&&H!==void 0&&(A===void 0||A===!1)){const q=r(F),[B,K]=q(H);so.debug("Setting downsample range",E,B,K),F.range(E,B,K)}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=qC*(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(KC(t))return I.i18n.DateTimeFormat.format(oe.DATE_FORMAT,t,e);if(XC(t))return t.asNumber()}return t}static wrapValue(t,e,n=null){if(_.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(" "):so.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=J.module("Chart"),go=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:go.convertIcon(Eh),attr:"fill-warning"}),n||s||i||r){const l=go.downsampleButtonTitle(s,i),a=go.downsampleButtonAttr(s,i),d=s?pg:gg;o.push({name:l,icon:go.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&&Or.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=go;iu.defaultProps={isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:Hn.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}};const kt=J.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 QC({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 H=async()=>{const q=await t.getWorkerHeapInfo();if(r(q),s||l){const B=(q.totalHeapSize-q.freeMemory)/q.maximumHeapSize,K=Date.now(),{timestamps:x,usages:O}=d.current;for(;x.length!==0&&K-x[0]>i*1.5;)x.shift(),O.shift();x.push(K),O.push(B)}else d.current={timestamps:[],usages:[]}};H();const A=setInterval(H,l?n:e);return()=>{clearInterval(A)}},[l,n,t,e,i,s]);const c=(P,H)=>Math.round(P*10**H)/10**H,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),v=S-C,y=(P,H,A=!1)=>T("div",{className:Y("heap-usage-info-row",{"heading-bottom-border":A}),children:[h("div",{className:"font-weight-bold",children:P}),h("div",{children:H})]}),{timestamps:E,usages:R}=d.current,F=E[E.length-1]??0,D=g/f,N=(g-p)/f;return T(be,{children:[T("div",{className:"max-memory",children:[h("div",{className:"total-memory",style:{width:`calc(${D*100}% - ${D*2}px`}}),h("div",{className:Y("used-memory",{"heap-overflow":(g-p)/f>.95}),style:{width:`calc(${N*100}% - ${N*2}px`}}),T("div",{className:"memory-text",children:[w.toFixed(1)," GB"]})]}),h(ut,{onEntered:()=>a(!0),onExited:()=>a(!1),interactive:!0,children:T("div",{className:"heap-tooltip",children:[y("In use:",`${v.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}}})}),T("div",{className:"heap-utilisation-text",children:["% utilization over ",Math.round(i/1e3/60)," min."]})]})})]})}const qa=Object.freeze({}),ZC=new Map,ru=t=>t.user,Ya=t=>t.storage,lu=t=>Ya(t).commandHistoryStorage,au=t=>Ya(t).fileStorage,JC=t=>Ya(t).workspaceStorage,ml=t=>t.workspace,Et=t=>ml(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,ko=t=>Et(t).timeZone,mu=t=>Et(t).showTimeZone,pu=t=>Et(t).showTSeparator,gu=t=>Et(t).truncateNumbersWithPound,eS=t=>Et(t).shortcutOverrides,tS=t=>Et(t).defaultNotebookSettings??qa,pl=t=>t.activeTool,nS=t=>t.plugins??ZC,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",sS=t=>({type:wu,payload:t}),yu=t=>({type:Tu,payload:t}),iS=t=>({type:vu,payload:t}),oS=t=>({type:Cu,payload:t}),rS=t=>({type:Su,payload:t}),lS=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(lS(o))},gl=t=>e=>e(Ru({settings:t})),fl=t=>({type:fu,payload:t}),aS=t=>({type:bu,payload:t}),dS=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 cS(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 hS=Ls(fu,null),uS=Ls(bu,null),mS=Ls(Cu,null),pS=Ls(Su,null),gS=Ls(vu,null),fS=xa({commandHistoryStorage:mS,fileStorage:pS,workspaceStorage:gS}),CS=Iu(wu,null),SS=Iu(Tu,null),bS=Ls(Eu,null),wS={activeTool:hS,plugins:uS,storage:fS,user:CS,workspace:SS,serverConfigValues:bS};class TS{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 TS,Cc=J.module("redux-logger"),vS=t=>e=>n=>{Cc.debug("dispatching",n);const s=e(n);return Cc.debug("next state",t.getState()),s},ES=J.module("redux-crashReporter"),yS=t=>e=>n=>{try{return e(n)}catch(s){throw ES.error("Error executing",n," with state ",t.getState(),":",s),s}},RS=[vS,yS,wp];Object.entries(wS).map(([t,e])=>Gi.register(t,e));const IS=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__??Ep,Cl=Tp(xa(Gi.reducers),IS(vp(...RS)));Gi.setListener(t=>{Cl.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 FS(t){return t.component!==void 0}const Nu=Object.freeze({type:"default",isClosable:!0,isFocusOnShow:!0,reorderEnabled:!0,title:""}),DS=Object.freeze(Object.defineProperty({__proto__:null,defaultConfig:Fu,isGLComponentConfig:Du,isReactComponentConfig:FS,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 NS=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 Sl(t){return window.requestAnimationFrame(t)}function _S(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 MS(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 xo 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(){Nr.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(){Nr.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 Vr=["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"],kS=[!0,!1,"row","column","stack","component","close","maximise","minimise","open in new window"];function ja(t){if(Vr.length>36)throw new Error("Too many keys in config minifier map");const e={};return Qa(t,e,"_min"),e}function fa(t){if(Vr.length>36)throw new Error("Too many keys in config minifier map");const e={};return Qa(t,e,"_max"),e}function Qa(t,e,n){const s=n==="_min"?xS:OS;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,Vr);e[l]=r}Qa(o,r,n)}else{const r=s(o,kS);if(Array.isArray(e))e[Number.parseInt(i,10)]=r;else{const l=s(i,Vr);e[l]=r}}}}function xS(t,e){if(typeof t=="string"&&t.length===1)return"___"+t;var n=e.indexOf(t);return n===-1?t:n.toString(36)}function OS(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 AS=Object.freeze(Object.defineProperty({__proto__:null,EventEmitter:pn,DragListener:xo,ReactComponentHandler:ku,BubblingEvent:Ca,EventHub:xu,getHashValue:_u,getQueryStringParam:Mu,animFrame:Sl,removeFromArray:_S,getUniqueId:Ka,filterXss:MS,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 Oo=Au;Oo._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 xo(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 Oo(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 xo(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 Oo(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 Za=Hu;Za._template='<div class="lm_dropTargetIndicator"><div class="lm_inner"></div></div>';class fo{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 ti extends Error{constructor(e,n){super(),this.name="Configuration Error",this.message=e,this.node=n}}const LS=Object.freeze(Object.defineProperty({__proto__:null,ConfigurationError:ti},Symbol.toStringTag,{value:"Module"}));function Fo(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,Fo(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 ti("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,Sl(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 ti('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 Br 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}),Sl(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 Br)||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 Ao(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 PS=Object.freeze(Object.defineProperty({__proto__:null,AbstractContentItem:Tt,ContentItem:Tt,Component:Vu,Root:Sa,RowOrColumn:Br,Stack:ba,isStack:Fo,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 xo(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 Oo(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 vr=class extends pn{constructor(t,e){super(),this.element=pe(vr._template),this.tabDropdownList=null,this.tabs=[],this.activeContentItem=null,this.closeButton=null,this.tabDropdownButton=null,this.tabNextButton=pe(vr._nextButtonTemplate),this.tabPreviousButton=pe(vr._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 fo(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 fo(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 fo(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 fo(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 Ao=vr;Ao._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("");Ao._previousButtonTemplate=['<ul class="lm_controls">','<li class="lm_tabpreviousbutton"></li>',"</ul>"].join("");Ao._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 xo(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),Sl(this._nextAnimationFrame.bind(this))}_measure(e){const n=e.offset();return{left:n?.left,top:n?.top,width:e.outerWidth(),height:e.outerHeight()}}}const HS=Object.freeze(Object.defineProperty({__proto__:null,BrowserPopout:Ou,DragProxy:Oo,DragSource:Lu,DragSourceFromEvent:Pu,DropTargetIndicator:Za,Header:Ao,HeaderButton:fo,Splitter:$u,Tab:Ja,TransitionIndicator:Gu},Symbol.toStringTag,{value:"Module"})),US={config:DS,container:NS,controls:HS,errors:LS,items:PS,utils:AS};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:Br.bind(this,!0),row:Br.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 Za,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 ti("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 ti(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(!Fo(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 ti(n,e);if(e.content.length>1)throw n="Top level content can't contain more then one element.",new ti(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=>{Fo(s)?e.push(s):s.isComponent||this._findAllStackContainersRecursive(e,s)})}}ed.__lm=US;const VS="_lm_root_15d73_3",BS="_lm_row_15d73_7",$S="_lm_item_15d73_7",GS="_lm_content_15d73_11",WS="_lm_dragging_15d73_17",zS="_lm_maximised_15d73_23",qS="_lm_maximise_placeholder_15d73_30",YS="_lm_splitter_15d73_34",KS="_lm_vertical_15d73_41",XS="_lm_drag_handle_15d73_41",jS="_lm_horizontal_15d73_46",QS="_lm_header_15d73_56",ZS="_lm_dropdown_open_15d73_63",JS="_lm_controls_15d73_69",eb="_lm_tabs_15d73_89",tb="_lm_tab_15d73_89",nb="_lm_title_15d73_104",sb="_lm_close_tab_15d73_111",ib="_lm_stack_15d73_120",ob="_lm_left_15d73_120",rb="_lm_right_15d73_121",lb="_lm_dragProxy_15d73_125",ab="_lm_items_15d73_148",db="_lm_tabdropdown_list_15d73_165",cb="_lm_bottom_15d73_192",hb="_lm_drop_tab_placeholder_15d73_207",ub="_lm_tabdropdown_15d73_165",mb="_lm_dropTargetIndicator_15d73_258",pb="_lm_inner_15d73_264",gb="_lm_transition_indicator_15d73_272",fb="_lm_popin_15d73_282",Cb="_lm_bg_15d73_297",Sb="_lm_icon_15d73_300",bb="_lm_goldenlayout_15d73_304",wb="_lm_selectable_15d73_340",Tb="_lm_active_15d73_370",vb="_lm_selected_15d73_388",Eb="_lm_keyboard_active_15d73_397",yb="_lm_popout_15d73_416",Rb="_lm_maximise_15d73_23",Ib="_lm_close_15d73_111",Fb="_lm_tabnextbutton_15d73_425",Db="_lm_tabpreviousbutton_15d73_428",Nb="_lm_title_before_15d73_544",_b="_lm_focusin_15d73_568",Mb="_lm_window_blur_15d73_573",kb="_lm_tabdropdown_search_15d73_631",xb="_march_15d73_1",Ob="_app_15d73_712",Ab="_plotly_15d73_721",Sc={"tab-height":"28px","drag-border-width":"5px",lm_root:VS,lm_row:BS,lm_item:$S,lm_content:GS,lm_dragging:WS,lm_maximised:zS,lm_maximise_placeholder:qS,lm_splitter:YS,lm_vertical:KS,lm_drag_handle:XS,lm_horizontal:jS,lm_header:QS,lm_dropdown_open:ZS,lm_controls:JS,lm_tabs:eb,lm_tab:tb,lm_title:nb,lm_close_tab:sb,lm_stack:ib,lm_left:ob,lm_right:rb,lm_dragProxy:lb,lm_items:ab,lm_tabdropdown_list:db,lm_bottom:cb,lm_drop_tab_placeholder:hb,lm_tabdropdown:ub,lm_dropTargetIndicator:mb,lm_inner:pb,lm_transition_indicator:gb,lm_popin:fb,lm_bg:Cb,lm_icon:Sb,lm_goldenlayout:bb,lm_selectable:wb,lm_active:Tb,lm_selected:vb,lm_keyboard_active:Eb,lm_popout:yb,lm_maximise:Rb,lm_close:Ib,lm_tabnextbutton:Fb,lm_tabpreviousbutton:Db,lm_title_before:Nb,"editor-unsaved-indicator":"_editor-unsaved-indicator_15d73_548","is-unsaved":"_is-unsaved_15d73_556",lm_focusin:_b,lm_window_blur:Mb,lm_tabdropdown_search:kb,march:xb,app:Ob,"js-plotly-plot":"_js-plotly-plot_15d73_721",plotly:Ab},bc=Object.freeze({tabHeight:parseInt(Sc["tab-height"],10),dragBorderWidth:parseInt(Sc["drag-border-width"],10)}),Ss=J.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 ir(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&&Fo(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&&ir(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&&ir(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)&&ir(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:(ir(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 T("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 Lb(t){return typeof t.id=="string"&&t.layout instanceof ed&&t.panelManager instanceof td&&typeof t.registerComponent=="function"}function Ps(t){if(!Lb(t))throw new Error(`Expected dashboard plugin props, but instead received ${t}`)}const an=J.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 Pb=J.module("PanelErrorBoundary");class Hb 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);Pb.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(Jr,{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},Ub=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}),Vb=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:Ub,EventHub:qu,Layout:Vb}),Be=(t,e,n)=>b.exports.useEffect(function(){return t.on(e,n),()=>{t.off(e,n)}},[t,e,n]),Yu="SET_DASHBOARD_DATA",Bb=cS(Yu,{},!1),$b={dashboardData:Bb},Gb=new Map,Wb=Object.freeze({}),zb=Object.freeze([]),qb=t=>t.dashboardData,Yt=(t,e)=>qb(t)[e]??Wb,Yb=(t,e)=>Yt(t,e).closed??zb,Ku=(t,e)=>Yt(t,e).openedMap??Gb,Xu=(t,e)=>({type:Yu,id:t,payload:e}),Vn=(t,e)=>(n,s)=>n(Xu(t,{...Yt(s(),t),...e}));Object.entries($b).map(([t,e])=>Gi.register(t,e));const or=J.module("DashboardLayout"),Kb=Object.freeze({}),Xb=[],vc=()=>{},Ec=t=>t;function ju({id:t,children:e,emptyDashboard:n=h("div",{children:"Dashboard is empty."}),layout:s,layoutConfig:i=Xb,onLayoutChange:o=vc,onLayoutInitialized:r=vc,hydrate:l=sd,dehydrate:a=nd}){const d=Oa(),c=yp(x=>Yt(x,t))??Kb,[u,m]=b.exports.useState(!1),[p,g]=b.exports.useState(!1),[f,C]=b.exports.useState(),[S]=b.exports.useState(c?.closed??[]),[w,v]=b.exports.useState(!1),y=b.exports.useMemo(()=>new Map,[]),E=b.exports.useMemo(()=>new Map,[]),R=Rp(),F=b.exports.useCallback((x,O,G=l,ee=a)=>{or.debug2("registerComponent",x,O,G,ee);function ne(X,se){const ce=O,{glContainer:Q,glEventHub:he}=X;return h(ph,{store:R,children:h(Hb,{glContainer:Q,glEventHub:he,children:h(ce,{...X,ref:se})})})}const V=de.forwardRef(ne),W=s.registerComponent(x,V);return y.set(x,G),E.set(x,ee),W},[l,a,y,E,s,R]),D=b.exports.useCallback((x,O)=>(y.get(x)??Ec)(O,t),[y,t]),N=b.exports.useCallback((x,O)=>(E.get(x)??Ec)(O,t),[E,t]),P=b.exports.useMemo(()=>new td(s,D,N,new Map,S,({closed:x,openedMap:O})=>{d(Vn(t,{closed:x,openedMap:O}))}),[N,d,D,t,S,s]),H=b.exports.useCallback(()=>{if(p)return;w||(r(),v(!0));const O=s.toConfig().content,G=ie.dehydrateLayoutConfig(O,N),ee=f==null||!ie.isEqual(f,G);or.debug("handleLayoutStateChanged",ee,O,G),ee&&(m(s.root.contentItems.length===0),C(G),o(G))},[N,w,p,f,s,o,r]),A=b.exports.useCallback(x=>{const O=ie.getIdFromContainer(x);s.eventHub.emit(Ee.DRAGGING,O),g(!0)},[s.eventHub]),q=b.exports.useCallback(x=>{const O=ie.getIdFromContainer(x);s.eventHub.emit(Ee.DROPPED,O),g(!1)},[s.eventHub]),B=b.exports.useCallback(x=>{if(or.debug2("handleComponentCreated",x),x==null||x.config==null||x.config.component==null||x.element==null)return;const G=`${x.config.component.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}-component`;x.element.addClass(G)},[]);Be(s,"stateChanged",H),Be(s,"itemPickedUp",A),Be(s,"itemDropped",q),Be(s,"componentCreated",B),Be(s.eventHub,Ee.TITLE_CHANGED,H);const K=rl(i);return b.exports.useEffect(function(){if(K!==i&&i!==f){or.debug("Setting new layout content...");const O=ie.hydrateLayoutConfig(i,D);for(;s.root.contentItems.length>0;)s.root.contentItems[0].remove();for(let G=0;G<O.length;G+=1)s.root.addChild(O[G]);m(s.root.contentItems.length===0)}},[D,s,i,f,P,K]),T(be,{children:[u&&n,de.Children.map(e,x=>x!=null?de.cloneElement(x,{id:t,layout:s,panelManager:P,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,zl=()=>{},Qb=Object.freeze({});function Zb({id:t="default",children:e,emptyDashboard:n,layoutConfig:s,layoutSettings:i=Qb,onLayoutConfigChange:o=zl,onGoldenLayoutChange:r=zl,onLayoutInitialized:l=zl,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 v=new ed(w,u.current),y=()=>{v.off("initialised",y),p(!0)};return v.on("initialised",y),a!=null&&v.setFallbackComponent(a),v.init(),f(v),r(v),()=>{v.destroy()}},[i,a,r,p,f]);const C=b.exports.useMemo(()=>Ln(()=>{g!=null&&g.isInitialised&&g?.updateSize()},jb),[g]);return b.exports.useEffect(function(){return window.addEventListener("resize",C),()=>{window.removeEventListener("resize",C)}},[C]),T("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 Sn="default";class Qu extends Error{constructor(){super(...arguments),this.isAssertionFailed=!0}}function yc(t){if(t==null)throw new Qu(`Expected 'val' to be defined, but received ${t}`)}class ql extends Error{constructor(){super(...arguments),this.isPasteError=!0}}function tt(t){return t?.isEditable!==void 0}function Rc(t){if(!tt(t))throw new Qu(`Expected 'model' to be editable, but received ${t}`)}function ze(t){return t?.hasExpandableRows!==void 0}var bn=(t=>(t.DOWN="DOWN",t.UP="UP",t.LEFT="LEFT",t.RIGHT="RIGHT",t))(bn||{});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=bn;function Jb(t){return Array.isArray(t)&&t.length===2&&(t[0]===null||typeof t[0]=="number")&&(t[1]===null||typeof t[1]=="number")}function rr(t){return Jb(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 Ze(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],v=d.get(w)??0,y=c.get(w)??0,E=y===0;if(!C||!E){let R=v+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],v=d.get(w)??0,y=c.get(w)??0,E=y===0;if(v<l-y)return null;if(!C||!E){let R=v+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 v=C+S;w?v+=m:p&&(v-=m);const y=v-m,E=v+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&&!rr(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&&rr(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 rr(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;rr(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 v=[[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(...v)}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,v=o,y=r;return n!=null&&(n>d&&(S+=u),n<f-c&&(v-=m)),e!=null&&(e>l&&(w+=p),e<C-a&&(y-=g)),{x1:S,y1:w,x2:v,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 z=Ne;z.PIXELS_PER_LINE=100/3;function L(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 lr(t,e=Lo.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+=L(i,l);r=s;for(let l=0;l<e&&n-l-1>=0;l+=1)r-=L(i,n-l-1),o.set(n-l-1,r);return o}const Zu=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:v,rowCount:y,floatingTopRowCount:E,floatingBottomRowCount:R,floatingLeftColumnCount:F,floatingRightColumnCount:D,columnHeaderMaxDepth:N}=a,P=this.getFirstRow(t),H=this.getFirstColumn(t),A=this.getGridX(t),q=this.getGridY(t),B=ze(a)&&a.hasExpandableRows?this.calculateTreePaddingX(t):0,K=0,x=this.getVisibleRowHeights(t),O=this.getVisibleColumnWidths(t,H,B),G=Array.from(x.keys()),ee=Array.from(O.keys()),ne=new Map([...x,...this.getFloatingRowHeights(t)]),V=new Map([...O,...this.getFloatingColumnWidths(t)]),W=this.getVisibleColumnXs(V,ee,s),X=this.getVisibleRowYs(ne,G,i),se=G.length>0?G[G.length-1]:n,ce=ee.length>0?ee[ee.length-1]:e,Q=this.getBottomViewport(t,G,X,ne),he=this.getRightViewport(t,ee,W,V),Se=this.getFloatingTopHeight(t,ne),Re=this.getFloatingBottomHeight(t,ne),et=this.getFloatingLeftWidth(t,V),yt=this.getFloatingRightWidth(t,V),je=Array.from(V.values()),Tn=Array.from(ne.values()),Ut=je.reduce((it,yn)=>it+yn,0)-s,De=Tn.reduce((it,yn)=>it+yn,0)-i,mt=s+Ut+g,at=i+De,Rt=o-A,Vt=r-q,vn=this.getLastLeft(t,null,Rt-g),on=this.getLastLeft(t,null,Rt-g-w),ci=this.getLastTop(t,null,Vt-Re),Hs=this.getLastTop(t,null,Vt-Re-w);let rn=on,cs=Hs;vn===0&&ci===0&&(rn=0,cs=0);const hi=rn>0,Qi=hi?w:0,ui=cs>0,mi=ui?w:0,Vo=A,Bo=N*C,hs=o-Vo-mi,Us=r-Bo-Qi,kl=v===1?hs/mt:(v-rn)/v,$o=y===1?Us/at:(y-cs)/y,Zi=hi?Ze(hs*kl,S,hs-1):0,Ji=ui?Ze(Us*$o,S,Us-1):0,Go=L(V,e,0),Wo=L(ne,n,0),xl=Go>0?s/Go:0,Ol=Wo>0?i/Wo:0,Al=v===1?s/(mt-Rt):(e+xl)/rn,Vs=y===1?i/(at-Vt):(n+Ol)/cs,Ll=hi?Al*(hs-Zi):0,zo=ui?Vs*(Us-Ji):0,qo=[...Array(E).keys(),...[...Array(R).keys()].map(it=>y-it-1)],eo=new Map([...X,...this.getFloatingRowYs(t,ne,Math.floor(r-q-Qi))]),Yo=[...Array(F).keys(),...[...Array(D).keys()].map(it=>v-it-1)],us=new Map([...W,...this.getFloatingColumnXs(t,V,Math.floor(o-A-mi))]),to=[];if(u)for(let it=u.range[0];it<=u.range[1];it+=1)to.push(it),V.has(it)||V.set(it,this.getVisibleColumnWidth(it,t)),us.has(it)||us.set(it,0);const Ko=G.concat(qo),Xo=ee.concat(Yo).concat(to),no=this.getModelRows(Ko,t),Pl=this.getModelColumns(Xo,t),jo=this.getVisibleRowTreeBoxes(ne,no,t),Qo=this.getTopVisible(t,eo,ne,G),Zo=this.getLeftVisible(t,us,V,ee),Jo=cs>0?this.getBottomVisible(t,eo,ne,G,q):se,er=rn>0?this.getRightVisible(t,us,V,ee,A):ce,{fontWidths:tr,userColumnWidths:Hl,userRowHeights:Ye,calculatedRowHeights:_t,calculatedColumnWidths:En}=this;return{rowHeight:m,rowHeaderWidth:p,rowFooterWidth:g,rowCount:y,columnWidth:f,columnCount:v,columnHeaderHeight:C,floatingTopRowCount:E,floatingBottomRowCount:R,floatingLeftColumnCount:F,floatingRightColumnCount:D,gridX:A,gridY:q,firstRow:P,firstColumn:H,treePaddingX:B,treePaddingY:K,left:e,top:n,bottom:se,right:ce,topOffset:i,leftOffset:s,topVisible:Qo,leftVisible:Zo,bottomVisible:Jo,rightVisible:er,bottomViewport:Q,rightViewport:he,width:o,height:r,maxX:Ut,maxY:De,lastLeft:rn,lastTop:cs,barHeight:Us,barTop:Bo,barWidth:hs,barLeft:Vo,handleHeight:Ji,handleWidth:Zi,hasHorizontalBar:hi,hasVerticalBar:ui,verticalBarWidth:mi,horizontalBarHeight:Qi,scrollX:Ll,scrollY:zo,scrollableContentWidth:mt,scrollableContentHeight:at,scrollableViewportWidth:Rt,scrollableViewportHeight:Vt,visibleRows:G,visibleColumns:ee,visibleRowHeights:x,visibleColumnWidths:O,floatingRows:qo,floatingColumns:Yo,allRows:Ko,allColumns:Xo,allRowHeights:ne,allColumnWidths:V,floatingTopHeight:Se,floatingBottomHeight:Re,floatingLeftWidth:et,floatingRightWidth:yt,visibleRowYs:X,visibleColumnXs:W,allRowYs:eo,allColumnXs:us,visibleRowTreeBoxes:jo,modelRows:no,modelColumns:Pl,movedRows:d,movedColumns:c,fontWidths:tr,userColumnWidths:Hl,userRowHeights:Ye,calculatedRowHeights:_t,calculatedColumnWidths:En,columnHeaderMaxDepth:N}}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 Ze(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 Ze(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=L(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=L(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=L(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+=L(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+=L(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+=L(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+=L(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(L(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(L(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=L(e,u),p=L(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=L(e,u),p=L(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=L(e,o)+L(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 L(this.modelRows,t);const{movedRows:n}=e,s=z.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 L(this.modelColumns,t);const{movedColumns:s}=e,i=z.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)),lr(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),lr(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,v=Math.ceil(n+w);return z.iterateAllItems(n,v,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)*Zu.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 L(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)),lr(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)),lr(n),this.userRowHeights=n}resetRowHeight(t){const e=new Map(this.userRowHeights);e.delete(t),this.userRowHeights=e,this.calculatedRowHeights.delete(t)}};let Lo=Zu;Lo.CACHE_SIZE=1e4;Lo.MAX_COLUMN_WIDTH=.8;const ew=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 tw(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 nw(t,e){const[n,s,i]=la.hex.rgb(t);return`rgba(${n}, ${s}, ${i}, ${e})`}const Fc={colorWithAlpha:nw,darkenForDepth:tw};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=L(l,g),C=s-a-f-this.dragOffset,S=L(c,g),w=this.targetSizes.get(S),v=this.resizingItems.length>1,y=this.hiddenItems.indexOf(g);let E=L(d,S);g===u&&(E+=m);let R=C;Math.abs(C-E)<=r.headerResizeSnapThreshold?R=E:w!==void 0&&C>w&&(v&&y!==0||y>0)?R=w:C<=r.headerResizeHiddenSnapThreshold&&(R=0),p.set(S,R),C<-r.headerResizeSnapThreshold&&R===0?y>=0&&v?(this.resizingItems.pop(),this.removeTargetSize(o,g),g=this.resizingItems[this.resizingItems.length-1],this.dragOffset-=this.targetSizes.get(L(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)):v?(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=L(a,l.index),c=L(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];L(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=L(s,n);let a=i.get(l);(a==null||a===0)&&(a=L(o,l)+r),this.targetSizes.set(l,a)}removeTargetSize(e,n){const s=e[this.modelIndexesProperty],i=L(s,n);this.targetSizes.delete(i)}}class bl 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=z.getHiddenColumns,this.getNextShownItem=z.getNextShownColumn,this.getSeparator=bl.getColumnSeparator}static getColumnSeparator(e,n,s,i){if(!i.allowColumnResize)return null;const{x:o,y:r,columnHeaderDepth:l}=e,{modelColumns:a}=n,d=z.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 Qn=class{constructor(){this.getCachedTruncatedString=Jt((t,e,n,s,i)=>Qn.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=>ol.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=Qn.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=Qn.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 Qn.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:L(u,r-1)+L(m,r-1)-.5}),l>0&&this.drawSelectedRanges(t,e,{top:d-l-1,bottom:d-1,minY:L(u,d-l)+.5,maxY:L(u,d-1)+L(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:L(f,r-1)+L(C,r-1)}),l>0&&this.drawSelectedRanges(t,e,{left:p-l,right:p-1,minX:L(f,p-l)+.5,maxX:L(f,p-1)+L(C,p-1)});for(let v=0;v<c.length;v+=1){const y=c[v];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=L(c,i-1)+L(m,i-1)+.5;t.moveTo(0,w),t.lineTo(g,w)}if(o>0){const w=L(c,a-o)-.5;t.moveTo(0,w),t.lineTo(g,w)}if(r>0){const w=L(u,r-1)+L(p,r-1)+.5;t.moveTo(w,0),t.lineTo(w,f)}if(l>0){const w=L(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=L(c,i-1)+L(m,i-1)+.5;t.moveTo(0,w),t.lineTo(g,w)}if(o>0){const w=L(c,a-o)-.5;t.moveTo(0,w),t.lineTo(g,w)}if(r>0){const w=L(u,r-1)+L(p,r-1)+.5;t.moveTo(w,0),t.lineTo(w,f)}if(l>0){const w=L(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)?L(g,l+1):-10,minY:d>0&&p.has(d+1)?L(p,d+1):-10,maxX:a>0&&g.has(c-a-1)?L(g,c-a-1)+L(f,c-a-1)-.5:C+10,maxY:r>0&&p.has(u-r-1)?L(p,u-r-1)+L(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=(v,y)=>{const E=ze(a)?a.depthForRow(v):0,R=m[v%m.length],F=R[Math.min(E,R.length-1)];if(f.has(F)||f.set(F,[]),f.get(F).push(v),y!=null){const D=ze(a)?a.depthForRow(y):0;D<E?C.push(v):D>E&&S.push(y)}};for(let v=0;v<n.length;v+=1){const y=n[v],E=v>0?n[v-1]:void 0;w(y,E)}if(f.forEach((v,y)=>{t.fillStyle=y,t.beginPath();for(let E=0;E<v.length;E+=1){const R=v[E],F=L(p,R),D=L(g,R);t.rect(i,F,o,D)}t.fill()}),C.length>0){t.save();const v=this.getCachedColorWithAlpha(u,.15),y=this.getCachedColorWithAlpha(u,0),E=t.createLinearGradient(0,0,0,c);E.addColorStop(0,v),E.addColorStop(1,y),t.fillStyle=E;for(let R=0;R<C.length;R+=1){const F=C[R],D=L(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 v=this.getCachedColorWithAlpha(u,0),y=this.getCachedColorWithAlpha(u,.15),E=t.createLinearGradient(0,0,0,c);E.addColorStop(0,v),E.addColorStop(1,y),t.fillStyle=E;for(let R=0;R<S.length;R+=1){const F=S[R],D=L(p,F),N=L(g,F),P=D+N-c;t.translate(0,P),t.fillRect(i,0,o,c),t.translate(0,-P)}t.restore()}}drawMouseColumnHover(t,e){const{mouseX:n,mouseY:s,theme:i,metrics:o}=e;if(n==null||s==null)return;const r=z.getColumnAtX(n,o);if(r==null||i.columnHoverBackgroundColor==null)return;const{allColumnWidths:l,allColumnXs:a,maxY:d}=o;if(s>d)return;const c=L(a,r),u=L(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=z.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=z.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=L(l,n),c=L(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=L(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=L(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=L(c,s),C=L(d,n),S=r.backgroundColorForCell(C,f,l),w=n===a,v=ze(r)&&r.hasExpandableRows;if(S!=null){const y=L(u,n)+1,E=L(p,s)+1,R=L(m,n)-1,F=L(g,s)-1;t.fillStyle=S,t.fillRect(y,E,R,F)}w&&v&&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=L(i,n),d=L(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=L(d,n),S=L(u,s),w=L(c,n),v=L(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+v*.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=L(m,s),f=L(u,s),C=L(c,n),S=i??r.textForCell(C,f),w=r.truncationCharForCell(C,f),v=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),N=d.get(t.font)??Qn.DEFAULT_FONT_WIDTH,P=this.getCachedTruncatedString(t,S,R,N,w);P&&t.fillText(P,F,D)}v&&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=L(u,a),v=L(m,a),y=L(p,n),E=L(g,n);if(!ze(i)||!i.isRowExpandable(n))return;const R=L(f,n),F=o!=null&&r!=null&&o>=d+w&&o<=d+w+v&&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=L(d,a),C=L(c,n),S=L(u,n),w=s!==void 0?o.depthForRow(s):0,v=l>w?l-w:0;if(t.strokeStyle=g,t.lineWidth=1,l-v>0){t.beginPath();for(let y=0;y<l-v;y+=1){const E=f+y*m+m*.5+p+.5;t.moveTo(E,C),t.lineTo(E,C+S)}t.stroke()}if(v>0){t.beginPath();for(let y=l-v;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:v,columnHeaderMaxDepth:y}=o;if(d<=0)return;const{headerHiddenSeparatorSize:E,headerHiddenSeparatorHoverColor:R,headerSeparatorColor:F,headerSeparatorHoverColor:D}=i,N=d*.5,P=d*(y-1)+d*.5-N*.5,H=C>0;if(t.save(),this.drawColumnHeadersForRange(t,e,[p[0],p[p.length-1]],{minX:u+S,maxX:m-w}),H&&this.drawColumnHeadersForRange(t,e,[c[0],c[c.length-1]],{minX:u,maxX:u+S}),F){t.strokeStyle=F;const A=[...g.entries()].filter(([q,B])=>B===0).map(([q])=>q);t.beginPath(),t.fillStyle=F;for(let q=0;q<A.length;q+=1){const B=A[q],K=L(f,B),x=L(g,B),O=u+K+x+.5-E*.5;t.rect(O,P,E,N)}t.fill()}if(D){let{index:A,depth:q}=r??{};if(A==null&&n!=null&&s!=null){const K=bl.getColumnSeparator(z.getGridPointFromXY(n,s,o),o,a,i);A=K?.index,q=K?.depth}let B;if(A==null)B=!1;else{const K=v.get(A),x=v.get(A+1);K==null||x==null?B=!1:B=a.textForColumnHeader(K,q)!==a.textForColumnHeader(x,q)}if(B&&A!=null&&q!=null&&(!l||r!=null)){t.strokeStyle=D;const K=L(f,A),x=L(g,A),O=u+K+x+.5,G=p.indexOf(A),ee=G<p.length-1?p[G+1]:null,ne=ee!=null?g.get(ee):null,V=x===0,W=ne!=null&&ne===0;V?(t.strokeStyle=R,t.fillStyle=R,t.fillRect(O,P,E*.5,N)):W&&(t.fillStyle=D,t.fillRect(O-E*.5,P,E*.5,N)),t.beginPath(),t.moveTo(O,(y-q-1)*d),t.lineTo(O,(y-q)*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:v}=s,y=v-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,v);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,N=L(a,F),P=r.textForColumnHeader(N,i),H=r.colorForColumnHeader(N,i);let A=L(d,F)+c,q=A+L(p,F);if(P!=null){let B=F-1;for(;B>=0&&(q-A<y||A>w);){const G=a.get(B)??z.getModelIndex(B,g);if(G==null||r.textForColumnHeader(G,i)!==P)break;A-=m.get(G)??u.get(G)??C,B-=1}let K=F+1;for(;K<D&&(q-A<y||q<v);){const G=a.get(K)??z.getModelIndex(K,g);if(r.textForColumnHeader(G,i)!==P)break;q+=m.get(G)??u.get(G)??C,K+=1}F=K-1;const x=q-A>=y;let O=A;x&&(q<v?O=q-y:A<w&&(O=w)),this.drawColumnHeader(t,e,P,O,Math.min(q-A,y),{backgroundColor:H??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=L(l,n),u=L(a,n)+d,m=L(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)??Qn.DEFAULT_FONT_WIDTH,y=(i-d*2)/w,{backgroundColor:E=u,separatorColor:R=p}=o??{};let{textColor:F=m}=o??{};try{const V=this.getCachedColorIsDark(E),W=this.getCachedColorIsDark(F);V&&W?F=f:!V&&!W&&(F=g)}catch{}let{minX:D=0,maxX:N=S}=r??{};t.save(),t.rect(D,0,N-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 P=n;y<=0?P="":P.length>y&&(P=`${P.substring(0,y-1)}\u2026`);const H=P.length*w;let A=s+i*.5;const q=c*.5;D+=d,N-=d;const B=s+d,K=Ze(B,D,N),x=s+i-d,G=Ze(x,D,N)-K,ee=A-H*.5<D,ne=A+H*.5>N;ee?H<G?A=D+H*.5:A=x-H*.5:ne&&(H<G?A=N-H*.5:A=B+H*.5),t.textAlign="center",t.fillText(P,A,q),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,v=a*.5,y=a*.5-v*.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],N=L(m,D),P=L(u,D);if(P>0){const H=l+N+P+.5;t.moveTo(0,H),t.lineTo(a,H),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],N=L(m,D),P=L(u,D),H=l+N+P+.5-f*.5;t.rect(y,H,v,f)}t.fill()}if(w){let{index:E=null}=r??{};if(E==null&&n!=null&&s!=null&&(E=z.getRowSeparatorIndex(n,s,i,o)),E!=null){t.strokeStyle=w;const R=L(m,E),F=L(u,E),D=l+R+F+.5,N=c.indexOf(E),P=N<c.length-1?c[N+1]:null,H=P!=null?u.get(P):null,A=F===0,q=H!=null&&H===0;A?(t.strokeStyle=C,t.fillStyle=C,t.fillRect(y,D,v,f*.5)):q&&(t.fillStyle=w,t.fillRect(y,D-f*.5,v,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=L(u,R),D=L(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=L(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:v,headerBackgroundColor:y,headerColor:E,headerHiddenSeparatorSize:R,headerHiddenSeparatorHoverColor:F,headerSeparatorColor:D,headerSeparatorHoverColor:N}=r,P=m*.5,H=m*.5-P*.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 B=[];let K=!1;for(let x=0;x<f.length;x+=1){const O=f[x],G=L(S,O),ee=L(C,O);if(ee>0){const ne=a+G+ee+.5;t.moveTo(A+.5,ne),t.lineTo(A+m-.5,ne),K=!1}else K||(K=!0,B.push(O))}t.moveTo(A+.5,a),t.lineTo(A+.5,p),t.stroke(),t.beginPath(),t.fillStyle=D;for(let x=0;x<B.length;x+=1){const O=B[x],G=L(S,O),ee=L(C,O),ne=a+G+ee+.5-R*.5;t.rect(A+H,ne,P,R)}t.fill()}if(N){let{index:B=null}=l??{};if(B==null&&n!=null&&s!=null&&(B=z.getRowSeparatorIndex(n,s,i,r)),B!=null){t.strokeStyle=N;const K=L(S,B),x=L(C,B),O=a+K+x+.5,G=f.indexOf(B),ee=G<f.length-1?f[G+1]:null,ne=ee!=null?C.get(ee):null,V=x===0,W=ne!=null&&ne===0;V?(t.strokeStyle=F,t.fillStyle=F,t.fillRect(H,O,P,R*.5)):W&&(t.fillStyle=N,t.fillRect(H,O-R*.5,P,R*.5)),t.beginPath(),t.moveTo(A+.5,O),t.lineTo(A+m+.5,O),t.stroke()}}t.beginPath(),t.rect(A,a,m,p),t.clip(),t.fillStyle=E,t.textAlign="left";const q=A+v;for(let B=0;B<f.length;B+=1){const K=f[B],x=L(C,K);if(x>0){const O=L(S,K)+a,G=L(u,K),ee=O+x*.5;t.fillText(o.textForRowFooter(G),q,ee)}}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:v=a.top,right:y=a.right,bottom:E=a.bottom,minY:R=-10,maxY:F=S+10,minX:D=-10,maxX:N=C+10}=n;if(c.length===0)return;const P=tt(d)&&d.isEditable&&l==null&&o==null&&r==null&&s!=null&&i!=null&&p.has(s)&&f.has(i);if(P){const H=L(p,s),A=L(f,i),q=L(m,s),B=L(g,i);t.save(),t.beginPath(),t.rect(0,0,C,S),t.rect(H,A,q,B),t.clip("evenodd")}t.beginPath();for(let H=0;H<c.length;H+=1){const A=c[H],q=A.startColumn!==null?A.startColumn:w,B=A.startRow!==null?A.startRow:v,K=A.endColumn!==null?A.endColumn:y,x=A.endRow!==null?A.endRow:E;if(x>=v&&E>=B&&K>=w&&y>=q){const O=q>=w&&p.has(q)?Math.round(L(p,q))+.5:D,G=B>=v&&f.has(B)?Math.max(Math.round(L(f,B))+.5,.5):R,ee=K<=y&&p.has(K)?Math.round(L(p,K)+L(m,K))-.5:N,ne=x<=E&&f.has(x)?Math.round(L(f,x)+L(g,x))-.5:F;t.rect(O,G,ee-O,ne-G)}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()}P&&s!=null&&i!=null&&(t.restore(),this.drawActiveCell(t,e,s,i))}drawActiveCell(t,e,n,s,i=Qn.ACTIVE_CELL_BORDER_WIDTH){const{metrics:o,theme:r}=e,{allColumnWidths:l,allColumnXs:a,allRowHeights:d,allRowYs:c}=o,u=L(a,n),m=L(c,s),p=L(l,n),g=L(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:v}=t;t.beginPath(),t.lineWidth=i,t.strokeStyle=r.selectionOutlineColor,this.drawRoundedRect(t,f,C,S,w),t.stroke(),t.lineWidth=v}drawRoundedRect(t,e,n,s,i,o=Qn.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:v}=s,y=w.get(l[0])??z.getModelIndex(l[0],S),E=r.getColumnHeaderGroup(y,a);if(a>0&&!E)return;const[R,F]=l,D=L(u,R),P=L(u,F)+L(m,F)-D,H=n.left,{backgroundColor:A,font:q,headerFont:B,reorderOffset:K,shadowBlur:x,shadowColor:O}=o,G=(f-a-1)*C;t.save(),t.translate(d,0),t.save(),t.beginPath(),t.rect(v,0,g,p),t.clip(),t.fillStyle=A,t.fillRect(D,G,P,p),t.restore(),t.translate(0,K),t.save(),t.shadowColor=O,t.shadowBlur=x,t.fillStyle=A,t.fillRect(n.left,G+K,n.width,p),t.restore(),t.beginPath(),t.rect(n.left,G,n.width+1,p),t.clip(),t.translate(H-D,0),t.font=B;const ee=[];for(let ne=n.range[0];ne<=n.range[1];ne+=1)ee.push(ne);this.drawColumnHeaders(t,e),this.drawColumnHeadersForRange(t,e,[ee[0],ee[ee.length-1]],{minX:D,maxX:g}),t.translate(0,c),t.font=q,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=L(d,n),p=L(c,n)+1,{backgroundColor:g,font:f,headerFont:C,reorderOffset:S,shadowBlur:w,shadowColor:v}=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=v,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:v,barTop:y}=o,{scrollBarBackgroundColor:E,scrollBarHoverBackgroundColor:R,scrollBarCasingColor:F,scrollBarCornerColor:D,scrollBarColor:N,scrollBarHoverColor:P,scrollBarActiveColor:H,scrollBarSize:A,scrollBarHoverSize:q,scrollBarCasingWidth:B,scrollBarSelectionTick:K,scrollBarSelectionTickColor:x,scrollBarActiveSelectionTickColor:O,autoSelectRow:G,autoSelectColumn:ee}=a,ne=r!=null&&l!=null&&r<=d&&l<=c,V=s||C&&!n&&!i&&r!=null&&l!=null&&r>=d-q&&l>=y&&ne,W=n||f&&!s&&!i&&!V&&r!=null&&l!=null&&l>=c-q&&r>=v&&ne,X=W?q:A,se=V?q:A;if(t.translate(v,y),f&&C&&(t.fillStyle=F,t.fillRect(d-v-A,c-y-A,A,A),t.fillStyle=D,t.fillRect(d-v-A+B,c-y-A+B,A-B,A-B)),f){const ce=p,Q=c-y-X;if(t.fillStyle=F,t.fillRect(0,Q,S,X-B),t.fillStyle=W?R:E,t.fillRect(0,Q+B,S,X-B),n?t.fillStyle=H:W?t.fillStyle=P:t.fillStyle=N,t.fillRect(ce,Q+B,m,X-B),!G&&K&&x!=null&&O!=null){t.fillStyle=x;const{selectedRanges:he,cursorColumn:Se}=e,{lastLeft:Re,columnCount:et}=o,je=[...he].filter(De=>De.startColumn!=null&&De.endColumn!=null).map(De=>[De.startColumn,De.endColumn]).sort(z.compareRanges),Tn=z.mergeSortedRanges(je),Ut=De=>De<=Re?De/Re*(S-m):S-m+(De-Re)/(et-Re)*m;for(let De=0;De<Tn.length;De+=1){const mt=Tn[De],at=mt[0],Rt=mt[1];if(at!=null&&Rt!=null&&(at!==Se||Rt!==Se)){const Vt=Ut(at),vn=Math.max(1,Math.round(Ut(Rt+1)-Vt)),on=X-B;t.fillRect(Vt,Q+B+Math.round(on/3),vn,Math.round(on/3))}}if(Se!=null){const De=Ut(Se),mt=2,at=X-B;t.fillStyle=O,t.fillRect(De,Q+B,mt,at)}}}if(C){const ce=d-v-se,Q=g;if(t.fillStyle=F,t.fillRect(ce,0,se-B,w),t.fillStyle=V?R:E,t.fillRect(ce+B,0,se-B,w),s?t.fillStyle=H:V?t.fillStyle=P:t.fillStyle=N,t.fillRect(ce+B,Q,se-B,u),!ee&&K&&x!=null&&O!=null){const{selectedRanges:he,cursorRow:Se}=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 Tn=[...he].filter(De=>De.startRow!=null&&De.endRow!=null).map(De=>[De.startRow,De.endRow]).sort(z.compareRanges),Ut=z.mergeSortedRanges(Tn);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!==Se||Rt!==Se)){const Vt=yt(at),vn=se-B,on=Math.max(1,Math.round(yt(Rt+1)-Vt));t.fillRect(ce+B+Math.round(vn/3),Vt,Math.round(vn/3),on)}}if(Se!=null){const De=Math.round(yt(Se)),mt=se-B,at=2;t.fillStyle=O,t.fillRect(ce+B,De,mt,at)}}}t.translate(-v,-y)}};let ri=Qn;ri.DEFAULT_FONT_WIDTH=10;ri.DEFAULT_EDGE_RADIUS=2;ri.ACTIVE_CELL_BORDER_WIDTH=2;const Dc=100;class sw 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=z.isModifierKeyDown(s),C=s.shiftKey;f||(C?n.trimSelectedRanges():n.clearSelectedRanges());const S=n.getTheme(),{autoSelectRow:w,autoSelectColumn:v}=S;return(r!==null||!v)&&(l!==null||!w)&&(n.focus(),n.moveCursorToPosition(r,l,C,!1,C&&f)),this.startPoint=e,this.hasExtendedFloating=!1,this.dragBounds=z.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=z.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:v,floatingBottomRowCount:y,floatingLeftColumnCount:E,floatingRightColumnCount:R,columnCount:F,rowCount:D,bottom:N,right:P,topVisible:H,bottomVisible:A,leftVisible:q,rightVisible:B}=d;this.hasExtendedFloating||(s!==null&&s<v&&l>=v?(l=v,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&&!z.isFloatingRow(s,d)&&z.isFloatingRow(l,d)&&(s>l&&l<m?l=H-1:s<l&&l>N&&(l=A+1)),i!==null&&!z.isFloatingColumn(i,d)&&z.isFloatingColumn(a,d)&&(i>a&&a<c?a=q-1:i<a&&a>P&&(a=B+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,iw=1e3/60,ar=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)??z.getModelIndex(t,o),g=s.getColumnHeaderGroup(p,e),f=g!=null;let C,S,w;if(g!=null){const[v,y]=g.getVisibleRange(o);C=r.get(v)??u,S=(r.get(y)??m)+(a.get(y)??0),w=[v,y]}else{const v=r.get(t);if(v==null)return null;C=v,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 ow 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-=ar;m<0;){u-=1;const f=z.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+=ar;let f=c.get(i);for(;f!==void 0&&m>f;){u+=1,m-=f;const C=z.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"?-ar:ar),e.setState({left:u,leftOffset:m}),(n==="left"&&u===0&&r===0||n==="right"&&u===o)&&this.clearScrollInterval())},iw))}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(z.getColumnAtX(Ze(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:N=0}=bs(F[1],0,l,o)??{};this.draggingOffset=e-(N-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(z.getModelIndex(F,r));)F+=1;else for(F-=1;F>p.visibleIndex&&!o.isColumnMovable(z.getModelIndex(F,r));)F-=1;if(F!==p.visibleIndex){m||(F-=p.range[1]-p.range[0]);const N=this.moveColumn(p,F,r);n.setState({movedColumns:N,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,v=o.getColumnHeaderParentGroup(p.modelIndex,p.depth);let y,E=(v?.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?z.moveRange(e.range,n,s):z.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=Ze((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 rw 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=L(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=L(f,R)+L(g,R)*.5+p}let w=C;if(i<c){const R=i+1;w=L(f,R)+L(g,R)*.5+p}let{movedRows:v}=n.state;r<S&&i>0&&s.isRowMovable(i-1)?(v=z.moveItem(i,i-1,v),i-=1):w<r&&i<m-1&&s.isRowMovable(i+1)&&(v=z.moveItem(i,i+1,v),i+=1),n.setState({movedRows:v,draggingRow:i});const y=p+L(g,a)*.5,E=p+L(f,u)+L(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=z.getHiddenRows,this.getNextShownItem=z.getNextShownRow,this.getSeparator=rd.getRowSeparator}static getRowSeparator(e,n,s,i){if(!i.allowRowResize)return null;const{x:o,y:r}=e,l=z.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=L(u,s),S=L(m,s),w=L(g,i),v=L(p,i);if(o>=a+C&&o<=a+C+S&&r>=d+w&&r<=d+w+v)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,z.isModifierKeyDown(s)),!0}return!1}}class lw 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=Ze((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 aw 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 di{constructor(e=5e3){this.order=e}onDown(e,n){return!1}}class dw extends di{onDown(e,n){switch(e.key){case"a":if(z.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 z.isModifierKeyDown(e)?!1:this.handlePageUp(e,n);case"j":case"J":return z.isModifierKeyDown(e)?!1:this.handlePageDown(e,n);case"h":case"H":return z.isModifierKeyDown(e)?!1:(e.shiftKey||n.clearSelectedRanges(),n.moveCursorToPosition(0,n.state.cursorRow,e.shiftKey),!0);case"l":case"L":{if(z.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(z.isModifierKeyDown(e)?n.state.cursorColumn:0,z.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(z.isModifierKeyDown(e)?n.state.cursorColumn:i-1,z.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=z.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=Ze(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=Ze(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 cw extends di{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 hw extends di{onDown(e,n){if(z.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 uw(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 mw(t){const e=[];return t.forEach(n=>{const s=n.textContent??"";s.length>0&&e.push(s.split(/\t|\u00a0\u00a0 \u00a0/))}),e}function pw(t){const e=t.querySelector("table");if(e!=null)return uw(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?mw(t.childNodes):n}return null}class gw extends di{onDown(e,n){switch(e.key){case"v":if(z.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=pw(s);o!=null&&n.pasteValue(o)};return s.addEventListener("input",i),s.focus(),{preventDefault:!1,stopPropagation:!0}}break}return!1}}const fw=t=>{switch(t){case"ArrowDown":return bn.DOWN;case"ArrowUp":return bn.UP;case"ArrowLeft":return bn.LEFT;case"ArrowRight":return bn.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 v=b.exports.useCallback(H=>{o(H)},[o]),y=b.exports.useCallback(H=>{const{value:A}=H.target;w(A),g(!0),v(A)},[v,w,g]),E=b.exports.useCallback(()=>{u.current=!0,p&&v(m),g(!1),r()},[m,p,r,v]),R=b.exports.useCallback(()=>{C(!1)},[C]),F=b.exports.useCallback((H,A=!1)=>{l(S,{direction:H,fillRange:A})},[l,S]),D=b.exports.useCallback(()=>{u.current||F(null)},[u,F]),N=b.exports.useCallback(H=>{switch(H.stopPropagation(),H.key){case"Escape":H.preventDefault(),E();break;case"Enter":if(H.preventDefault(),z.isModifierKeyDown(H))F(void 0,!0);else if(H.altKey){const A=`${S}
20
20
  `;w(A),g(!0),v(A)}else F(H.shiftKey?bn.UP:bn.DOWN);break;case"Tab":H.preventDefault(),F(H.shiftKey?bn.LEFT:bn.RIGHT);break;case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":f&&(H.preventDefault(),F(fw(H.key)));break}},[E,F,f,w,g,v,S]),P=b.exports.useCallback(H=>{a(H)},[a]);return h("textarea",{ref:c,className:Y("grid-cell-input-field",e),value:S,onBlur:D,onChange:y,onKeyDown:N,onContextMenu:P,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 Cw=de.createContext({}),Xs=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 ri,this.metricCalculator=s||new Lo,this.canvas=null,this.canvasContext=null,this.animationFrame=null,this.prevMetrics=null,this.metrics=null,this.documentCursor=null,this.dragTimer=null,this.keyHandlers=[new hw(400),new gw(450),new dw(500),new cw(900)],this.mouseHandlers=[new rd(100),new bl(200),new rw(300),new ow(400),new aw(450),new ld(500),new od(600),new lw(700),new Ai(800),new sw(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:v}=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!==v&&a(v),e.draggingRow!=null&&S==null&&d(v),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:N,height:P,width:H}=this.prevMetrics;if(D!==y||R!==P){const{isStuckToBottom:A}=this.state;A&&this.scrollToBottom()}if(N!==E||F!==H){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 Xs.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 z.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=Xs.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 v=ae.makeNormalized(f,C,S,w);if(g.equals(v))return null;const y=[...o];return y[y.length-1]=v,{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=Ze(l+t,0,c-1),p=Ze(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&&!z.isFloatingRow(e,this.metrics)&&(e<o?(a=n.getTopForTopVisible(l,e),c=0):e>s&&(a=n.getTopForBottomVisible(l,e),c=0)),t!=null&&!z.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 ql("Can't paste in to read-only area.");if(i.length<=0)throw new ql("Select an area to paste to.");if(typeof t=="string"){const u=[],m=z.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 ql("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=z.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!==Xs.getCursorClassName(t)&&(this.documentCursor!=null&&document.documentElement.classList.remove(this.documentCursor),this.documentCursor=Xs.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)},Xs.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,v=this.getTheme(),y=this.canvas.clientWidth,E=this.canvas.clientHeight,R={width:y,height:E,context:w,theme:v,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:v,deltaY:y}=z.getScrollDelta(t,n.barWidth,n.barHeight,n.rowHeight,n.rowHeight);for(;m&&v!==0;){if(S+=v,v=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?(v=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):(v=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=bn.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},v=this.getModelColumn(r),y=this.getModelRow(l),E=v!=null&&y!=null?{textAlign:t.textAlignForCell(v,y)}:void 0,R=t.isValidForCell(v,y,i);return h("div",{style:w,children:h(ad,{selectionRange:s,className:Y({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 T(be,{children:[h("canvas",{className:Y("grid-canvas",Xs.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=Xs;Wi.contextType=Cw;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)=>({...ew,...t,...e}));class em extends Ip{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 Sw 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 js=class extends Sw{constructor({rowCount:t=js.DEFAULT_ROW_COUNT,columnCount:e=js.DEFAULT_COLUMN_COUNT,children:n=new Map,childRowCount:s=Math.ceil(Math.max(js.MIN_CHILD_ROW_COUNT,t*js.DEFAULT_CHILD_ROW_COUNT_FACTOR)),maxDepth:i=js.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 js({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 Po=js;Po.DEFAULT_ROW_COUNT=1e9;Po.DEFAULT_COLUMN_COUNT=100;Po.DEFAULT_CHILD_ROW_COUNT_FACTOR=.01;Po.MIN_CHILD_ROW_COUNT=10;Po.MAX_DEPTH=10;function bw(t,e){const n=vw(t);return n===void 0?void 0:`${Dw(t)} ? ${n} : ${e}`}function ww(t){return dh.Column.formatRowColor(t)}function Tw(t,e){return t.formatColor(e)}const Yl=J.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||{}),Qt=(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))(Qt||{}),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||{}),Co=(t=>(t.IS_TRUE="is-true",t.IS_FALSE="is-false",t.IS_NULL="is-null",t.IS_NOT_NULL="is-not-null",t))(Co||{}),ni=(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))(ni||{}),Nn=(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))(Nn||{});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 $r(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 Gr(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 vw(t){const e=Gr(t.style),n=$r(t.style);if(!(e===void 0||n===void 0))return`bgfg(\`${n}\`, \`${e}\`)`}function Ew(t){const{column:e,value:n,start:s,end:i}=t;return Vw(e.name,t.condition,n,s,i)}function yw(t){const{column:e,value:n}=t;return Bw(e.name,t.condition,n)}function Rw(t){const{column:e,value:n}=t;return $w(e.name,t.condition,n)}function Iw(t){const{column:e}=t;return Gw(e.name,t.condition)}function Fw(t){const{column:e,value:n}=t;return Ww(e.name,t.condition,n)}function Dw(t){const{column:e}=t;if(_.isNumberType(e.type))return Ew(t);if(_.isCharType(e.type))return Fw(t);if(_.isStringType(e.type))return yw(t);if(_.isDateType(e.type))return Rw(t);if(_.isBooleanType(e.type))return Iw(t);throw new Error("Invalid column type")}function Nw(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 _w(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 Mw(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 kw(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 xw(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(_.isNumberType(t)||_.isCharType(t))return"is-equal";if(_.isStringType(t)||_.isDateType(t))return"is-exactly";if(_.isBooleanType(t))return"is-true";throw new Error("Invalid column type")}function Ow(t){if(_.isCharType(t)||_.isStringType(t))return""}function nm(t){const{condition:e,value:n,start:s,end:i}=t;return{condition:e,value:n,start:s,end:i}}function wl(t){return{condition:tm(t),value:Ow(t),start:void 0,end:void 0}}function sm(){return{type:"no-formatting"}}function Aw(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 Lw(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 Pw(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 Hw(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 Uw(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 Vw(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 Bw(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 $w(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 Gw(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 Ww(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 zw(t,e){if(_.isNumberType(t))return Uw(e);if(_.isCharType(t))return Hw(e);if(_.isStringType(t))return Aw(e);if(_.isDateType(t))return Lw(e);if(_.isBooleanType(t))return Pw(e);throw new Error("Invalid column type")}function qw(t,e){if(e===void 0)return Yl.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){Yl.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=bw(o,d);if(u===void 0){Yl.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"?Tw(a,u):ww(u);n.push(p),r==="conditional"?i.set(a.name,[u,p]):s=[u,p]}),n}function Yw({type:t}){return _.isNumberType(t)||_.isCharType(t)||_.isStringType(t)||_.isDateType(t)||_.isBooleanType(t)}function Tl({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:Y("iris-grid-bottom-bar",n),role:"presentation",onClick:i,onKeyPress:i,children:e})})}const Kw=3e3,Xw=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=rl(t),w=b.exports.useMemo(()=>r.size===0?o:r.size<=Xw?`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)},Kw))},[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 v=l.size;let y;return t?y=h(as,{}):g&&(y=Pa),T(Tl,{className:"pending-data-bottom-bar",isShown:v>0||m||w!=null,onEntering:a,onEntered:d,onExiting:c,onExited:()=>{f(!1),u&&u()},children:[w!=null&&w!==""&&T("div",{className:"error-message",children:[h(Z,{icon:Os}),h("span",{children:`${w}`})]}),(w==null||w==="")&&h("div",{className:"status-message",children:v>0&&h("span",{children:`${v} row${v>1?"s":""} pending`})}),T("div",{className:"buttons-container",children:[!t&&!g&&h(U,{kind:"secondary",onClick:n,tooltip:s,children:"Discard"}),T(U,{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 Qw=t=>{switch(t){default:return!1}},Zw=(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 _.isNumberType(e)||_.isDateType(e)||_.isTextType(e);case Oe.SUM:case Oe.ABS_SUM:case Oe.VAR:case Oe.AVG:case Oe.STD:return _.isNumberType(e);case Oe.SKIP:return!1}},dd=(t,e)=>t.filter(n=>Zw(e,n.type)),Jw=(t,e,n,s)=>dd(t,e).map(({name:i})=>i).filter(i=>n.includes(i)?!s:s),_s={isRollupOperation:Qw,filterValidColumns:dd,getOperationColumnNames:Jw};var li=(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))(li||{});const eT=Object.freeze([[li.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS,!1],[li.LINK_CHANGE_CLEARS_ALL_FILTERS,!1]]),im={DEFAULTS:eT},tT=J.module("ColumnHeaderGroup");function Kl(t){return t instanceof kn}const om=class{constructor({name:t,children:e,color:n,depth:s,childIndexes:i,parent:o}){this.getVisibleRange=ge(r=>{const l=this.childIndexes.flat(),a=z.getVisibleIndexes(l,r),d=Math.min(...a),c=Math.max(...a);return c-d!==l.length-1&&tT.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(om.NEW_GROUP_PREFIX)}};let kn=om;kn.NEW_GROUP_PREFIX=":newGroup";const io=J.module("IrisGridUtils");function ws(t,e){return t>=0&&t<e.length}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:v=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(([N])=>N!=null&&N>=0&&N<D.length).map(([N,P])=>[D[N].name,P]),userRowHeights:[...F],customColumns:[...d],conditionalFormats:[...c],reverseType:u,rollupConfig:m,showSearchBar:p,searchValue:g,selectDistinctColumns:[...f],selectedSearchColumns:C,invertSearchColumns:w,pendingDataMap:te.dehydratePendingDataMap(D,v),frozenColumns:y,columnHeaderGroups:E?.map(N=>({name:N.name,children:N.children,color:N.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:v=!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(([N,P])=>typeof N=="string"||N instanceof String?[F.findIndex(({name:H})=>H===N),P]:[N,P]).filter(([N])=>N!=null&&N>=0&&N<F.length)),customColumns:d,conditionalFormats:c,userRowHeights:new Map(m),reverseType:p,rollupConfig:g,showSearchBar:f,searchValue:C,selectDistinctColumns:S,selectedSearchColumns:w,invertSearchColumns:v,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([...im.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=_.makeQuickFilter(d,l,s))}catch(d){io.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=_.makeAdvancedFilter(l,a,s))}catch(c){io.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 _.isDateType(n)?te.dehydrateDateTime(e):_.isLongType(n)?te.dehydrateLong(e):e}static hydrateValue(e,n){return _.isDateType(n)?te.hydrateDateTime(e):_.isLongType(n)?te.hydrateLong(e):e}static dehydrateDateTime(e){return e!=null?I.i18n.DateTimeFormat.format(Hn.FULL_DATE_FORMAT,e):null}static hydrateDateTime(e){return e!=null?I.i18n.DateTimeFormat.parse(Hn.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===_.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===_.sortDirection.descending?a=a.desc():a=a.asc(),a}return null}).filter(s=>s!=null&&s.direction!==_.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 _.makeQuickFilter(l,r,s)}catch(a){io.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=z.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=z.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=z.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=z.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]:(io.error("Unable to retrieve column",n,">=",e.length),null)}static getColumnByName(e,n){const s=e.find(({name:i})=>i===n);return s==null&&io.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=_.getFilterOperatorString(l)));let d=`${a}${o}`;l==="startsWith"&&(d=`${o}${a}`),e!=null&&r!==null&&_.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),v=e.getColumnIndexByName(S);if(w){const y=d(w);g.push(...y.childIndexes),f=Math.max(f,y.depth+1)}else if(v!=null)g.push(v),f=Math.max(f,1);else throw new Error(`Unknown child ${S} in group ${m}`)});const C=new kn({...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}}}const Kt=J.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,No(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=z.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 Zr?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 T(Tl,{animation:d,isShown:r,className:Y("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:T("div",{className:"buttons-container",children:[h("button",{type:"button",className:"btn btn-outline-secondary btn-cancel",onClick:this.handleCancelClick,children:"Cancel"}),T(U,{kind:p?"tertiary":"primary",className:Y("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 rm 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 T("div",{style:n,className:"iris-grid-input-autosized-wrapper","data-value":o,children:[h("input",{ref:r=>{this.inputField=r},className:Y("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(U,{kind:"ghost",className:Y("btn-link-icon advanced-filter-button",{"filter-set":s}),onClick:i,onContextMenu:this.handleContextMenu,children:T("div",{className:"fa-layers ",children:[h(Z,{icon:Ha,className:"filter-solid"}),h(Z,{icon:Mr,className:"filter-light"})]})})})]})}}rm.defaultProps={style:{},className:"",value:"",isAdvancedFilterSet:!1,onAdvancedFiltersTriggered:()=>{},onChange:()=>{},onDone:()=>{},onTab:()=>{},onContextMenu:()=>{},debounceMs:150};class nT extends di{constructor(e){super(),this.irisGrid=e}onDown(e){const{selectedRanges:n}=this.irisGrid.state;return e.key==="c"&&Pn.isModifierKeyDown(e)?(te.isValidSnapshotRanges(n)?this.irisGrid.copyRanges(n):this.irisGrid.copyRanges(n,!1,!1,"Invalid copy ranges"),!0):!1}}const sT={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]})},iT={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:sT,INPUT_TABLE:iT};class oT extends di{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===_.REVERSE_TYPE.NONE?this.irisGrid.reverse(_.REVERSE_TYPE.POST_SORT):this.irisGrid.reverse(_.REVERSE_TYPE.NONE),!0}return!1}}class rT extends di{constructor(e){super(),this.irisGrid=e}onDown(e){return en.TABLE.CLEAR_FILTERS.matchesEvent(e)?(this.irisGrid.clearAllFilters(),!0):!1}}class lT 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 aT 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 dT 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 lm=class extends b.exports.Component{constructor(t=lm.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=Rf.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 T("div",{className:"form-group flex-grow mb-0",children:[T("div",{className:"custom-format-title",children:[h("span",{className:"icon",children:o}),T("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 am=lm;am.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(am,{formatString:e.formatString,title:e.label,placeholder:s,onChange:o})}}}const _n=class{static getOptions(t,e){const n=new Date,i=[{group:_n.dateGroup,formatString:"yyyy-MM-dd"},{group:_n.dateGroup,formatString:"MM-dd-yyyy"},{group:_n.timeGroup,formatString:"HH:mm:ss"},{group:_n.timeGroup,formatString:"HH:mm:ss.SSS"},{group:_n.timeGroup,formatString:"HH:mm:ss.SSSSSSSSS"},{group:_n.dateTimeGroup,formatString:"yyyy-MM-dd HH:mm:ss"},{group:_n.dateTimeGroup,formatString:"yyyy-MM-dd HH:mm:ss.SSS"},{group:_n.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,_.dataType.DATETIME,"",l);return tn.makeOption(a,l,r.group,st.isSameFormat(l,e))});return[tn.makeOption("Default",null,_n.dateGroup,tn.isDefaultSelected(e)),...i]}};let vl=_n;vl.dateGroup=10;vl.timeGroup=20;vl.dateTimeGroup=30;const Mn=class{static getOptions(t,e){const n=[{format:ke.FORMAT_PERCENT,group:Mn.presetGroup},{format:ke.FORMAT_BASIS_POINTS,group:Mn.presetGroup},{format:ke.FORMAT_MILLIONS,group:Mn.presetGroup},{format:ke.FORMAT_SCIENTIFIC_NOTATION,group:Mn.presetGroup},{format:ke.FORMAT_ROUND,group:Mn.presetRoundGroup},{format:ke.FORMAT_ROUND_TWO_DECIMALS,group:Mn.presetRoundGroup},{format:ke.FORMAT_ROUND_FOUR_DECIMALS,group:Mn.presetRoundGroup}],s=tn.makeOption("Default",null,Mn.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,Mn.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 Ho=Mn;Ho.defaultGroup=10;Ho.presetGroup=20;Ho.presetRoundGroup=30;Ho.customGroup=40;const So=class{static getOptions(t,e){const n=[{format:Qe.FORMAT_MILLIONS,group:So.presetGroup},{format:Qe.FORMAT_SCIENTIFIC_NOTATION,group:So.presetGroup}],s=tn.makeOption("Default",null,So.defaultGroup,tn.isDefaultSelected(t)),i=n.map(a=>tn.makeOption(a.format.label,a.format,a.group,Qe.isSameFormat(a.format,t))),o=tn.isCustomSelected(t),r=o?t:Qe.makeCustomFormat(),l=tn.makeCustomFormatOption(r,So.customGroup,Qe.DEFAULT_FORMAT_STRING,o,a=>{if(a!=null){const d=Qe.makeCustomFormat(a);Qe.isValid(d)&&e(d)}else e(null)});return[s,...i,l]}};let El=So;El.defaultGroup=10;El.presetGroup=20;El.customGroup=30;const Mc=J.module("IrisGridContextMenuHandler"),cT=150,kc="yyyy-MM-dd HH:mm:ss.SSSSSSSSS",j=class extends ft{constructor(t){super(),this.debouncedUpdateCustomFormat=Je(t.handleFormatSelection,cT),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 _.isCharType(t)?I.FilterValue.ofString(String.fromCharCode(e)):I.FilterValue.ofNumber(e)}static getRowOptionFormatted(t,e,n=30){return`${t} "${ri.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,v=_.getSortForColumn(w,t),y=d!==_.REVERSE_TYPE.NONE,{userColumnWidths:E}=a,R=[...E.values()].some(N=>N===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:Mr,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,v)}),l.push({title:"Add Additional Sort",disabled:v&&w.length===1||y&&w.length===1||v&&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===_.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===_.REVERSE_TYPE.NONE?this.irisGrid.reverse(_.REVERSE_TYPE.POST_SORT):this.irisGrid.reverse(_.REVERSE_TYPE.NONE)}}),l.push({title:"Copy Column Name",group:j.GROUP_COPY,action:()=>{No(i.textForColumnHeader(t)??"").catch(N=>Mc.error("Unable to copy header",N))}}),_.isDateType(r.type)?l.push({title:"Date/Time Format",group:j.GROUP_FORMAT,actions:this.dateFormatActions(r)}):_.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}),v=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(_.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(_.isNumberType(m.type)||_.isCharType(m.type)){k(t);const R=_.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(_.isDateType(m.type)){const R=w.format(c),F=v.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:v,columnHeaderMaxDepth:y}=p,E=[];if(a!=null&&d!=null){const R=c.valueForCell(a,d),F=c.textForCell(a,d),D=m[a],{onContextMenu:N}=s.props;D!=null&&E.push(N({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<=v: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=vl.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(_.isDecimalType(t.type))i=Ho.getOptions(s,l=>{k(o),this.debouncedUpdateCustomFormat(o,l)});else if(_.isIntegerType(t.type))i=El.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:T("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:T("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&&!_.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:T("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:T("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:T("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 _.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:T("div",{className:"btn-context-menu menu-title",children:[h("span",{className:"icon",children:h(Z,{icon:Wn,style:{color:s??void 0}})}),h("span",{className:"title",children:"Add Additional Sort"}),h("span",{className:"shortcut",children:Pn.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 _.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 hT 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 uT 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 mT 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 pT 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=Pn.isModifierKeyDown(s);return this.irisGrid.toggleSort(i,o),!0}return!1}}class gT 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}=z.getScrollDelta(s);return tt(o)&&o.isEditable&&a>=d-1&&u>0&&i.setState({pendingRowCount:l+Math.ceil(u/c)}),!1}}const fT=3e3;function CT({children:t=null,onEntering:e,onEntered:n,onExiting:s,onExited:i}){const[o,r]=b.exports.useState(!1),l=b.exports.useRef(),a=rl(t),d=b.exports.useCallback(()=>{r(!0),l.current&&clearTimeout(l.current),l.current=setTimeout(()=>{r(!1)},fT)},[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(Tl,{className:"toast-bottom-bar",isShown:o,onEntering:e,onEntered:n,onExiting:s,onExited:i,children:t})}class ST extends Lo{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!==_.REVERSE_TYPE.NONE&&l!=null&&l.length>0&&(n+=i.reverseHeaderBarHeight),n}getUserColumnWidths(){return this.userColumnWidths}}const bT=1,dm=de.memo(({model:t,modelColumns:e,top:n,bottom:s,left:i,right:o,filter:r,formatter:l,reverseType:a=_.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:v,formatColumns:y,columnHeaderGroups:E})=>{const R=b.exports.useMemo(()=>te.getModelViewportColumns(e,i,o,u,m,p,bT),[e,i,o,u,m,p]);return b.exports.useEffect(function(){t.filter=r},[t,r]),b.exports.useEffect(function(){const D=[...d];a!==_.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(){v&&t.updateFrozenColumns(v)},[t,v]),b.exports.useEffect(function(){t.columnHeaderGroups=E},[t,E]),null});dm.displayName="IrisGridModelUpdater";const Fn=Object.freeze({SORT_UP:"sortUp",SORT_DOWN:"sortDown",CARET_DOWN:"caretDown",CARET_RIGHT:"caretRight",CELL_OVERFLOW:"cellOverflow"}),xc=10,Xl=16;class To extends ri{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(Fn.SORT_UP,fg),this.setIcon(Fn.SORT_DOWN,Cg),this.setIcon(Fn.CARET_DOWN,ts),this.setIcon(Fn.CARET_RIGHT,wh),this.setIcon(Fn.CELL_OVERFLOW,Sg)}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===_.sortDirection.ascending?this.getIcon(Fn.SORT_UP):e.direction===_.sortDirection.descending?this.getIcon(Fn.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=L(a,i),c=l.get(s);if(c===void 0)return;const u=r.valueForCell(c,d);if(_.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!==_.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!==_.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=L(d,s,0),C=L(c,s)+u,S=a.get(s);if(S==null)return;const w=_.getSortForColumn(r.sort,S);if(!w)return;const v=this.getSortIcon(w);if(!v)return;const y=r.textForColumnHeader(S);if(y===void 0)return;const E=p.get(e.font)??ri.DEFAULT_FONT_WIDTH;k(E);const R=y.length*E,F=u+C+R+g;let{maxX:D}=i;D-=g;const N=u+C+f-g-1,P=F>D?F+1:Math.min(D,N),H=w.direction===_.sortDirection.ascending?-6:-12,A=m*.5+H;e.save(),e.beginPath(),e.rect(C,0,f,m),e.clip(),e.fillStyle=l.headerSortBarColor,e.translate(P,A),e.fill(v),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 v=p[w],y=L(m,v),E=L(f,v),R=L(g,v);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 v=p[w],y=L(g,v),R=L(f,v)+d;this.drawExpandedFilterHeader(e,n,v,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 v=a.get(w),y=d.get(w);if(v==null&&y==null)return;let E=null;if(v!=null){const{text:F}=v;if(E=F,E||(E=_.getFilterText(v.filter)),E!=null){const{fontWidths:D}=r;let N=D.get(e.font);(N==null||N===0)&&(N=e.measureText("8").width,N||(N=10));const P=(o-f*2)/N;P<=0?E="":E.length>P&&(E=`${E.substring(0,P-1)}\u2026`)}}if(e.save(),To.isFilterValid(y,v)&&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,N=o-3,P=m-5;e.strokeRect(F,D,N,P)}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 v=To.isFilterValid(g,p);S!=null&&p==null&&g==null?e.fillStyle=S:C!=null&&v?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(Fn.CARET_DOWN):this.getIcon(Fn.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:v,allRowYs:y,width:E}=s;if(f<=0||g.length===0)return;const{cellHorizontalPadding:R,floatingGridRowColor:F,floatingRowBackgroundColors:D,headerColor:N,rowHoverBackgroundColor:P}=l;e.translate(d,a),e.beginPath();const H=Math.min(c,E-f-w-d);e.fillStyle=D,m>0&&e.rect(H,0,f,m),p>0&&e.rect(H,C-a-S-p,f,p),e.fill();const A=o!=null&&r!=null&&o>=d&&o<=c+f?z.getRowAtY(r,s):null;if(P!=null&&A!==null&&g.includes(A)){e.fillStyle=P;const B=y.get(A),K=v.get(A);k(B),k(K),e.fillRect(H,B,f,K)}if(e.beginPath(),F!=null&&(e.strokeStyle=F),m>0&&(e.moveTo(H+.5,.5),e.lineTo(H+.5,m-.5)),p>0){const B=C-a-S-p;e.moveTo(H-.5,B+.5),e.lineTo(H-.5,B+p-.5)}e.stroke(),e.fillStyle=N,e.textAlign="left";const q=H+R;for(let B=0;B<g.length;B+=1){const K=g[B],x=v.get(K),O=y.get(K),G=u.get(K);if(O!=null&&x!=null&&G!=null){const ee=O+x*.5;e.fillText(i.textForRowFooter(G),q,ee)}}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}=z.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}=z.getCellInfoFromXY(s,i,o);if(a==null||d==null||c==null||u==null||!_.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)??To.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}=z.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(Fn.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}=z.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 wT="12px Fira Sans, sans-serif",TT="#f0f0ee",vT="#1a171a",ue={"grid-bg":"#211f22",font:wT,white:TT,black:vT,"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"},cm=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=J.module("ColumnStatistics"),ET={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 ET[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),v=T(de.Fragment,{children:[h("div",{className:Y("column-statistic-operation",f),children:g}),h("div",{className:"column-statistic-value",children:w})]},g);l.push(v)}const c=ze(e)&&e.hasExpandableRows?"Expanded Rows":"Number of Rows",u=e.displayString(o,"long"),m=e.getColumnIndexByName(t.name);return T("div",{className:"column-statistics",children:[T("div",{className:"column-statistics-title",children:[t.name,T("span",{className:"column-statistics-type",children:["\xA0(",a,")"]}),h(ll,{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)&&T("div",{className:"column-statistics-status",children:[h(Z,{icon:e.isColumnFrozen(m)?bg:wg,className:"mr-1"}),e.isColumnFrozen(m)?"Frozen":"Not movable"]}),T("div",{className:"column-statistics-grid",children:[i==null&&T(be,{children:[h("div",{className:"column-statistic-operation",children:c}),h("div",{className:"column-statistic-value",children:u})]}),l]}),r&&h(U,{kind:"ghost",className:"px-0",onClick:this.handleGenerateStatistics,children:"Generate Stats"}),n!=null&&h("div",{className:"error-message",children:`${n}`}),i&&!s&&h(U,{kind:"ghost",className:"px-0",onClick:this.handleGenerateStatistics,icon:h(Z,{icon:Ua,className:"mr-1"}),children:"Refresh"}),s&&T("div",{className:"column-statistics-loading",children:[h(as,{className:"mr-2"}),"Calculating Stats..."]})]})}};let hm=Ta;hm.AUTO_GENERATE_LIMIT=1e5;const dr=J.module("AdvancedFilterCreatorFilterItem");class cd extends b.exports.PureComponent{constructor(e){super(e),this.getCachedIsValid=ge((o,r,l,a)=>{try{return!l||_.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(_.isNumberType(e)||_.isCharType(e))return tu(n);if(_.isTextType(e))return eu(n);if(_.isDateType(e))return nu(n);if(_.isBooleanType(e))return LC(n);throw new Error(`Unrecognized column type: ${e}`)}catch(s){return dr.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;dr.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){dr.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(){dr.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=!_.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:T("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:Y("form-control",{error:!a}),placeholder:"Enter value",value:o,onChange:this.handleValueChange})})}),h("div",{className:"form-group col-1 px-0",children:h(U,{kind:"ghost",className:"w-100 h-100 p-0 m-0",onClick:this.handleDelete,icon:sn,tooltip:"Remove Filter"})})]})})}}const Oc=J.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 T("div",{className:"select-value-list-wrapper",children:[h(Tg,{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 um=va;um.defaultProps={invertSelection:!0,selectedValues:[],onChange:()=>{}};const mm=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,mm.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;_.isCharType(s.type)?r=_.makeQuickFilter(s,e):_.isTextType(s.type)?r=_.makeQuickFilter(s,`~${e}`,n):r=_.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 T("div",{className:"advanced-filter-creator-select-value",children:[T("div",{className:l?"form-group":"",children:[h("label",{htmlFor:"advanced-filter-creator-select-value-input",children:"Select Values"}),l&&h("input",{type:"text",className:Y("form-control",{"is-invalid":t!=null}),id:"advanced-filter-creator-select-value-input",placeholder:c,value:i,onChange:this.handleSearchChange})]}),h(um,{table:o,filters:e,invertSelection:n,selectedValues:s,formatter:r,onChange:this.handleListChange}),T("div",{className:"advanced-filter-creator-select-meta-row",children:[T("div",{children:[h(U,{kind:"ghost",onClick:this.handleSelectAllClick,children:"Select All"}),h(U,{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=mm;hd.searchDebounceTime=250;hd.defaultProps={invertSelection:!0,selectedValues:[],onChange:()=>{},showSearch:!0};const oo=J.module("AdvancedFilterCreator"),Qs=class extends b.exports.PureComponent{constructor(t){super(t),this.getFilterTypes=ge(r=>_.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){oo.debug("No values table for this model, just ignore");return}this.valuesTablePromise=_.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)||(oo.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],AC(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(){oo.debug("Resetting Advanced Filter"),this.setState({filterItems:[Qs.makeFilterItem()],filterOperators:[],selectedValues:[],invertSelection:!0}),this.startUpdateTimer()}handleSortDown(t){const e=Pn.isModifierKeyDown(t);this.sortTable(_.sortDirection.descending,e)}handleSortUp(t){const e=Pn.isModifierKeyDown(t);this.sortTable(_.sortDirection.ascending,e)}handleSubmit(t){oo.debug("Submitting Advanced Filter"),this.stopUpdateTimer(),this.sendUpdate(),t.preventDefault()}handleDone(t){oo.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=_.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=_.isBooleanType(t.type),m=_.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 v=i[w],{key:y,selectedType:E,value:R}=v,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 N=o[w]===zt.and,P=T("div",{className:"form-row justify-content-end advanced-filter-creator-filter-operator",children:[h(U,{kind:"ghost",className:Y("filter-operator",{active:N}),onClick:()=>this.handleChangeFilterOperator(w,zt.and),children:"AND"}),h(U,{kind:"ghost",className:Y("filter-operator",{active:!N}),onClick:()=>this.handleChangeFilterOperator(w,zt.or),children:"OR"})]},`filterOperator${y}`);f.push(P)}}const C=this.shouldShowAddFilter(),S=T("div",{className:Y("form-row justify-content-end add-filter-item",{hidden:!C}),children:[h("span",{className:"text-muted",children:h(Z,{icon:As})}),h(U,{kind:"ghost",className:"btn-filter-item",onClick:this.handleAddAnd,disabled:!C,tooltip:"Add filter with AND",children:"AND"}),h(U,{kind:"ghost",className:"btn-filter-item",onClick:this.handleAddOr,disabled:!C,tooltip:"Add filter with OR",children:"OR"})]},"addFilterItem");return f.push(S),T("div",{className:"advanced-filter-creator",role:"presentation",children:[h("div",{tabIndex:0,onFocus:this.handleFocusTrapStart}),T("form",{onSubmit:this.handleSubmit,ref:this.focusTrapContainer,children:[T("div",{className:"title-bar",children:[h("h6",{className:"advanced-filter-title",children:"Advanced Filters"}),T("div",{className:"advanced-filter-menu-buttons",children:[h(U,{kind:"ghost",className:Y("sort-operator",{active:n===_.sortDirection.descending}),onClick:this.handleSortDown,icon:qd,tooltip:`Sort ${t.name} Descending`}),h(U,{kind:"ghost",className:Y("sort-operator",{active:n===_.sortDirection.ascending}),onClick:this.handleSortUp,icon:h(Z,{icon:qd,rotation:180}),tooltip:`Sort ${t.name} Ascending`})]})]}),h("hr",{}),T("div",{className:"advanced-filter-column-name",children:[t.name,"\xA0",T("span",{className:"column-type",children:["(",g,")"]})]}),f,c&&d==null&&T(be,{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})})]}),T("div",{className:"form-row justify-content-end",children:[h(U,{kind:"secondary",className:"mr-2",onClick:this.handleReset,children:"Reset"}),h(U,{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=J.module("Aggregations"),yT=[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 RT({isRollup:t,settings:e,onChange:n,onEdit:s}){const{aggregations:i,showOnTop:o}=e,r=b.exports.useMemo(()=>yT.filter(N=>!i.some(P=>P.operation===N)),[i]),[l,a]=b.exports.useState(r[0]),[d,c]=b.exports.useState([]),u=b.exports.useCallback(N=>{n({...e,...N})},[n,e]),m=b.exports.useCallback(N=>{u({aggregations:N})},[u]),p=b.exports.useCallback(N=>{u({showOnTop:N})},[u]),g=b.exports.useCallback(()=>{Ac.debug("handleDragStart"),qt.startDragging()},[]),f=b.exports.useCallback(({destination:N,source:P})=>{if(Ac.debug("handleDragEnd",N,P),qt.stopDragging(),N===null)return;let H=N.index;P.index<N.index&&(H+=1);const A=[...i],q=qt.reorder(A,d,A,H),B=qt.adjustDestinationIndex(H,d),K=[[B,B+q.length-1]];m(A),c(K)},[m,i,d,c]),C=b.exports.useCallback(N=>{a(N)},[a]),S=b.exports.useCallback(()=>{m([...i,{operation:l,selected:[],invert:!0}])},[i,l,m]),w=b.exports.useCallback(N=>{m(i.filter((P,H)=>H!==N))},[i,m]),v=b.exports.useCallback(N=>{c(N)},[c]),y=b.exports.useCallback(N=>{const P=i[N];_s.isRollupOperation(P.operation)||s(P)},[i,s]),E=b.exports.useCallback(N=>{p(N.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:N,itemIndex:P,isClone:H=!1,selectedCount:A})=>{const q=N.operation,B=H?`${A}`:void 0,K=H?"item-list-item-clone":void 0,x=_s.isRollupOperation(N.operation),O=!H&&!x;return T(be,{children:[T("div",{className:Y("item-list-item-content","draggable-item-list-item-content",K),children:[T("span",{className:"title",children:[q,!t&&x&&T("span",{className:"small text-warning",children:[h(Z,{icon:Eh})," Requires rollup"]})]}),Cn.renderBadge({text:B}),Cn.renderHandle()]}),!H&&T(be,{children:[h(U,{kind:"ghost",className:"btn-edit",icon:Mo,tooltip:"Edit Columns",onClick:()=>s(N),disabled:!O}),h(U,{kind:"ghost",className:"btn-delete",icon:sn,tooltip:"Delete Aggregation",onClick:()=>w(P)})]})]})},[w,s,t]),F=r.length>0,D=i.length>0;return T("div",{className:"aggregations",children:[F&&T("div",{className:"form-inline",children:[h(Nf,{onChange:C,value:l,children:r.map(N=>h(Df,{value:N,children:N},N))}),T("button",{type:"button",className:"btn btn-link btn-add",onClick:S,children:[h(Z,{icon:As}),"Add Aggregation"]})]}),F&&D&&h("hr",{}),D&&T(be,{children:[!t&&T("div",{className:"form-inline",children:[h("label",{children:"Placement:\xA0"}),T(al,{onChange:E,value:`${o}`,children:[h(is,{value:"true",children:"Top"}),h(is,{value:"false",children:"Bottom"})]})]}),h(jr,{onDragStart:g,onDragEnd:f,children:h(Cn,{className:"selected-aggregations",itemCount:i.length,items:i,renderItem:R,offset:0,onSelectionChange:v,onSelect:y,selectedRanges:d,isMultiSelect:!0})})]})]})}const IT=30;function FT({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=_.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],N=d;F>=0?D.splice(F,1):(D.push(R),D.length===p.length&&(D=[],N=!d)),n({...t,selected:D,invert:N})},[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]),v=c.length===0?d:null,y=c.length!==0||!d||l!==0;return T("div",{role:"menu",className:"aggregation-edit",children:[h("div",{className:"top-menu",children:T("div",{className:"form-inline",children:[h(mn,{checked:v,onChange:w,children:"Toggle All"}),h("div",{className:"spacer"}),h(Ht,{in:y,timeout:Xe.transitionSlowMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:h(U,{kind:"ghost",className:"btn-reset",onClick:C,children:"Reset"})}),h(U,{kind:"ghost",className:Y({active:l===1}),icon:Va,tooltip:"Sort ascending",onClick:()=>a(1)}),h(U,{kind:"ghost",className:Y({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:IT,focusSelector:"input",ref:u})})]})}function DT(t){return h("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...t,children:T("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 NT(t){return h("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...t,children:T("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 _T(t){return h("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...t,children:T("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 MT(t){return h("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...t,children:T("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 kT(t){return h("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...t,children:T("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 xT(t){return T("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 OT(t){return T("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=J.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(_T,{});case I.plot.SeriesPlotStyle.BAR:return h(DT,{});case I.plot.SeriesPlotStyle.SCATTER:return h(kT,{});case I.plot.SeriesPlotStyle.PIE:return h(MT,{});case I.plot.SeriesPlotStyle.HISTOGRAM:return h(NT,{});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:T("form",{onSubmit:this.handleSubmit,children:[T("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:T("button",{type:"button",className:Y("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",{}),T("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)=>T("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(U,{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&&T("div",{className:"form-row",children:[h("div",{className:"col-2"}),h(U,{kind:"ghost",className:"btn-add-series mt-1",onClick:this.handleAddSeries,icon:As,children:"Add Series"})]}),T("div",{className:"form-row chart-builder-link",children:[h("label",{className:"col-2 label-right",children:T("div",{className:"fa-md fa-layers",children:[h(Z,{mask:La,icon:Mi,transform:"right-5 down-5"}),h(Z,{icon:o?yh:vg,transform:"grow-2 right-8 down-6"})]})}),T(al,{onChange:this.handleLinkStateChange,value:`${o}`,children:[h(is,{value:"true",children:"Sync State"}),h(is,{value:"false",children:"Freeze State"})]})]}),T("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."})]}),T("div",{className:Y("form-row","justify-content-end","my-3"),children:[h(U,{kind:"secondary",className:"btn-reset",onClick:this.handleReset,children:"Reset"}),h(U,{kind:"primary",type:"submit",className:"btn-submit",children:"Create"})]})]})})}};let pm=pt;pm.types=[I.plot.SeriesPlotStyle.LINE,I.plot.SeriesPlotStyle.BAR,I.plot.SeriesPlotStyle.SCATTER,I.plot.SeriesPlotStyle.PIE];class gm 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 T("div",{className:Y("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"})]})}}gm.defaultProps={value:"",onContentChanged:()=>{},editorSettings:{},editorIndex:0,onTab:()=>{},invalid:!1};const Pc=Object.freeze({NAME:"name",FORMULA:"formula"}),AT=()=>{};function LT({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)=>T("div",{className:Y("draggable-container",{dragging:m.isDragging}),ref:u.innerRef,...u.draggableProps,children:[T("div",{className:"custom-column-input-container",children:[T("div",{className:"pb-3",children:[T("div",{className:"d-flex flex-row custom-column-name",children:[h("input",{className:Y("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(U,{kind:"ghost",className:"ml-1 px-2",onClick:()=>{o(t)},icon:sn,tooltip:"Delete custom column"}),h(U,{kind:"ghost",className:"btn-drag-handle",onClick:AT,...u.dragHandleProps,icon:el,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(gm,{editorSettings:{language:"deephavenDb"},editorIndex:n,value:s,onContentChanged:c,onTab:r,invalid:l})]}),h("hr",{})]})})}const Ql=[];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 Ql}get backColumns(){return Ql}get frozenColumns(){return Ql}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:T(be,{children:[T("p",{children:[h(Z,{icon:Os})," Failed to apply custom columns."]}),T("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(LT,{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 T(U,{kind:n?"success":"primary",className:Y("btn-apply",{"btn-spinner":e}),disabled:n||e||!i||!r,onClick:this.handleSaveClick,children:[e&&T("span",{children:[h(as,{}),h("span",{className:"btn-normal-content",children:"Applying"})]}),!n&&!e&&s,n&&T(be,{children:[h(Z,{icon:Pa})," Success"]})]})}render(){const{onCancel:t}=this.props,{errorMessage:e}=this.state;return T("div",{role:"presentation",className:"custom-column-builder-container",ref:n=>{this.container=n},onClick:this.resetRequestFailed,onFocus:this.resetRequestFailed,children:[h("hr",{}),h(jr,{onDragStart:qt.startDragging,onDragEnd:this.handleDragEnd,children:h(Aa,{droppableId:"droppable-custom-columns",children:(n,s)=>T("div",{ref:n.innerRef,...n.droppableProps,className:Y("droppable-container",{dragging:s.draggingFromThisWith}),children:[this.renderInputs(),n.placeholder]})})}),h("div",{className:"pt-1 px-3",children:h(U,{kind:"ghost",className:"btn-add-column",onClick:this.handleAddColumnClick,icon:As,children:"Add Another Column"})}),T("div",{className:"custom-column-builder-footer",children:[e&&h("div",{className:"error-message",children:e}),T("div",{className:"d-flex justify-content-end",children:[h(U,{kind:"secondary",className:"mr-2",onClick:t,children:"Cancel"}),this.renderSaveButton()]})]})]})}};let fm=Ei;fm.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 ro=J.module("RollupRows"),PT=150,cr="grouped-rollup-rows",hr="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)},PT),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]:_.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 Cn.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!_.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){ro.debug("handleDragStart",t),document.documentElement.classList.add("drag-pointer-events-none"),this.setState({dragSource:t.source})}handleDragEnd(t){ro.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===hr){this.setState(({groupedSelectedRanges:o,columns:r})=>{const l=[...r];return qt.reorder(l,o,[],0),{columns:l,ungroupedSelectedRanges:[],groupedSelectedRanges:[]}});return}const s=n.droppableId===cr;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){ro.debug("handleUngroupedSelect"),this.setState(({columns:e})=>({columns:gn.addGroupings(e,[this.getSortedUngroupedColumns()[t].name]),ungroupedSelectedRanges:[],groupedSelectedRanges:[]}))}handleUngroupedSelectionChange(t){ro.debug2("handleUngroupedSelectionChange",t),this.setState(({ungroupedSelectedRanges:e})=>t===e?null:{ungroupedSelectedRanges:t,groupedSelectedRanges:[]})}handleGroupedSelectionChange(t){ro.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 T(be,{children:[Cn.renderTextItem({text:o,badgeText:r,className:l}),(n===void 0||!n)&&h(U,{kind:"ghost",className:"btn btn-link btn-link-icon btn-delete-grouping float-right",onClick:()=>this.handleDeleteClicked(e),children:h(Z,{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*Cn.DEFAULT_ROW_HEIGHT;e?.droppableId===hr&&(d+=Cn.DEFAULT_ROW_HEIGHT);const c=a.length*Cn.DEFAULT_ROW_HEIGHT+10,u=Math.min(3*Cn.DEFAULT_ROW_HEIGHT,c);return h("div",{role:"menu",className:Y("rollup-rows",{"is-dragging":e!=null}),tabIndex:0,children:T(jr,{onDragEnd:this.handleDragEnd,onDragStart:this.handleDragStart,children:[T("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:Y("placeholder","text-muted",{"is-dragging-from-this":p.draggingFromThisWith,"is-dragging-over":p.isDraggingOver,"is-dropping":p.draggingOverWith}),ref:m.innerRef,...m.droppableProps,children:"Create rollup by dragging columns here, from the available columns list below."})}),t.length>0&&h(Cn,{draggingItemClassName:"rollup-rows-dragging-grouped-item",draggablePrefix:cr,droppableId:cr,itemCount:t.length,items:t,offset:0,onSelectionChange:this.handleGroupedSelectionChange,ref:this.groupedList,renderItem:this.renderGroupedItem,selectedRanges:s,style:{height:d},isMultiSelect:!0})]}),T("div",{className:"rollup-rows-available-columns",children:[h("div",{className:"section-title",children:"Available Grouping Columns"}),T("div",{className:"top-menu",children:[h(Bi,{className:"w-100",value:n,matchCount:n?i.length:void 0,placeholder:"Find column...",onChange:this.handleSearchChange}),T(U,{kind:"ghost",className:Y("btn-link btn-link-icon",{active:l===gn.SORT.ASCENDING}),onClick:this.handleSortAscending,children:[h(Z,{icon:Va}),h(ut,{children:"Sort ascending"})]}),T(U,{kind:"ghost",className:Y("btn-link btn-link-icon",{active:l===gn.SORT.DESCENDING}),onClick:this.handleSortDescending,children:[h(Z,{icon:Ba}),h(ut,{children:"Sort descending"})]})]}),h(Cn,{className:"rollup-available-grouping-columns",draggablePrefix:hr,droppableId:hr,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!==cr,isMultiSelect:!0}),T("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 HT=J.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=z.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){HT.error("CSV download failed",c),this.setState({errorMessage:T("p",{children:[h(Z,{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:T("p",{children:[h(Z,{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:T("p",{children:[h(Z,{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 T("div",{className:"table-csv-exporter",children:[h("div",{className:"section-title",children:"Download Rows"}),h("div",{className:"form-group",children:T(al,{onChange:this.handleDownloadRowOptionChanged,value:l,disabled:e,children:[T(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)`})]}),T(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:T("div",{className:"radio-input-row",role:"presentation",onClick:()=>{this.setState({downloadRowOption:Ge.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS})},children:[T("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"})]})})]})}),T("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})]}),T("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"})]}),T("div",{className:"section-footer flex-column",children:[p!=null&&h("div",{className:"error-message",children:p}),o&&T("div",{className:"download-status",children:[(o===Ge.DOWNLOAD_STATUS.DOWNLOADING||o===Ge.DOWNLOAD_STATUS.INITIATING)&&T(be,{children:[o===Ge.DOWNLOAD_STATUS.INITIATING&&h("div",{className:"text-muted",children:"Starting Download..."}),o===Ge.DOWNLOAD_STATUS.DOWNLOADING&&T("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}%`}})})]}),T(U,{kind:"primary","data-testid":"btn-csv-exporter-download",className:Y("btn-downloading",{"btn-spinner btn-cancelable":e}),onClick:this.handleDownloadClick,children:[e&&T("span",{children:[h(as,{}),h("span",{className:"btn-normal-content",children:"Downloading"}),h("span",{className:"btn-hover-content",children:"Cancel"})]}),!e&&"Download"]})]})]})}};let Zt=Ge;Zt.FILENAME_DATE_FORMAT="yyyy-MM-dd-HHmmss";Zt.DOWNLOAD_STATUS={INITIATING:"INITIATING",DOWNLOADING:"DOWNLOADING",FINISHED:"FINISHED",CANCELED:"CANCELED"};Zt.DOWNLOAD_ROW_OPTIONS={ALL_ROWS:"ALL_ROWS",SELECTED_ROWS:"SELECTED_ROWS",CUSTOMIZED_ROWS:"CUSTOMIZED_ROWS"};Zt.CUSTOMIZED_ROWS_OPTIONS={FIRST:"FIRST",LAST:"LAST"};Zt.DEFAULT_DOWNLOAD_ROWS=100;Zt.defaultProps={onDownloadStart:()=>{},isDownloading:!1,tableDownloadStatus:"",tableDownloadProgress:0,tableDownloadEstimatedTime:null,selectedRanges:[]};const Yn=J.module("TableSaver"),UT="yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS z";function VT(t){return t.added!==void 0}function BT(t){if(!VT(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(`
@@ -28,15 +28,15 @@ ${e}`):s.setValue(`${e}`);const o=s.getLineCount(),r=s.getLineLength(o)+1;this.e
28
28
  `),this.makeSnapshot(Math.min(Rs.SNAPSHOT_BUFFER_SIZE-this.snapshotsBuffer.size-this.snapshotPending,this.snapshotsTotal-this.snapshotCounter)))}updateDownloadProgress(t){if(t!=null&&this.snapshotsTotal!=null&&this.downloadStartTime!=null){const{onDownloadProgressUpdate:e}=this.props,n=Math.floor(t*100/this.snapshotsTotal),s=t>1?Math.floor((Date.now()-this.downloadStartTime)*(this.snapshotsTotal-t)/t/1e3):null;e(n,s)}}convertSnapshotIntoCsv(t){let e="";const n=t.added.iterator(),{formatter:s}=this.props,i=[];for(;n.hasNext();)i.push(n.next().value);k(this.columns);const{useUnformattedValues:o}=this;for(let r=0;r<i.length;r+=1){const l=i[r];for(let a=0;a<this.columns.length;a+=1){const{type:d,name:c}=this.columns[a];let u=null;if(o){let m=t.getData(l,this.columns[a])??"";m!==""&&_.isDateType(d)&&(m=I.i18n.DateTimeFormat.format(UT,m,I.i18n.TimeZone.getTimeZone(s.timeZone))),u=m.toString()}else{const m=this.getCachedCustomColumnFormatFlag(s,c,d);let p=null;if(!m){const g=t.getFormat(l,this.columns[a]);p=g?.formatString!=null?g:null}p?u=s.getFormattedString(t.getData(l,this.columns[a]),d,c,p):u=s.getFormattedString(t.getData(l,this.columns[a]),d,c)}e+=Rs.csvEscapeString(u),e+=a===this.columns.length-1?`
29
29
  `:","}}return e}makeSnapshot(t){if(t<=0)return;k(this.gridRangeCounter);let e=0,n=this.gridRanges[this.gridRangeCounter];for(k(this.tableSubscription),k(this.columns);e<t;){k(n),k(n.startRow),k(n.endRow),k(this.rangedSnapshotCounter),k(this.chunkRows);const s=n.startRow+this.rangedSnapshotCounter*this.chunkRows,i=Math.min(s+this.chunkRows-1,n.endRow),o=this.snapshotCounter;this.cancelableSnapshots.push(ye.makeCancelable(this.tableSubscription.snapshot(I.RangeSet.ofRange(s,i),this.columns).then(r=>(BT(r),this.handleSnapshotResolved(r,o,s,i),o)).catch(r=>{Yn.error(r)}),r=>{Yn.info(`snapshot ${r} has been canceled`)})),this.rangedSnapshotCounter+=1,this.snapshotCounter+=1,this.snapshotPending+=1,this.rangedSnapshotCounter>=this.rangedSnapshotsTotal[this.gridRangeCounter]&&(this.gridRangeCounter+=1,this.rangedSnapshotCounter=0,n=this.gridRanges[this.gridRangeCounter]),e+=1}}handlePortMessage({data:t}){const{download:e,readableStreamPulling:n}=t;if(!this.useBlobFallback){if(e!=null){const{includeColumnHeaders:s}=this;this.makeIframe(`${e}`),this.writeCsvTable(s)}n!=null&&(this.useBlobFallback||(this.streamTimeout!=null&&clearTimeout(this.streamTimeout),this.streamTimeout=setTimeout(this.handleDownloadTimeout,Rs.STREAM_TIMEOUT)))}}handleSnapshotResolved(t,e,n,s){this.snapshotHandlerTimeout=setTimeout(()=>{this.snapshotsBuffer.set(e,t),this.snapshotPending-=1,this.writeSnapshot(e,n,s),this.cancelableSnapshots[e]=null},Rs.SNAPSHOT_HANDLER_TIMEOUT)}makeIframe(t){const e=document.createElement("iframe");e.hidden=!0,e.src=`download/${t}`,e.name="iframe",document.body.appendChild(e),this.iframes.push(e)}render(){return null}};let qi=Rs;qi.DOWNLOAD_CELL_CHUNK=6e3;qi.SNAPSHOT_BUFFER_SIZE=5;qi.STREAM_TIMEOUT=8e3;qi.SNAPSHOT_HANDLER_TIMEOUT=5;qi.defaultProps={getDownloadWorker:()=>Promise.reject(new Error("Download worker not provided")),isDownloading:!1,onDownloadCompleted:()=>{},onDownloadCanceled:()=>{},onDownloadProgressUpdate:()=>{}};function $T(t){const{group:e,onDelete:n,onColorChange:s,onNameChange:i,validateName:o}=t,{isNew:r}=e,l=b.exports.useRef(e),a=b.exports.useRef(null),d=b.exports.useRef(null),[c,u]=b.exports.useState(r?"":e.name),[m,p]=b.exports.useState(r),[g,f]=b.exports.useState(!1),C=c!==e.name?o(c):"",S=r&&!g||C==="";b.exports.useEffect(function(){m&&a.current&&(a.current.focus(),a.current.select())},[m]),b.exports.useEffect(function(){return()=>{l.current.isNew&&n(l.current)}},[n]);const w=()=>{S&&(i(e,c),p(!1))},v=()=>{if(r){n(e);return}u(e.name),p(!1)},y=E=>{f(!0),E.key==="Enter"&&(E.stopPropagation(),w()),E.key===" "&&E.stopPropagation(),E.key==="Escape"&&v()};return m?T(be,{children:[T("div",{className:"editing-container",children:[h("input",{ref:a,className:Y("form-control",{"is-invalid":!S}),value:c,placeholder:"Group Name",onChange:E=>u(E.target.value),onKeyDown:y}),h(U,{kind:"ghost",icon:ss,tooltip:"Confirm",onClick:w}),h(U,{kind:"ghost",icon:Eg,tooltip:"Cancel",onClick:v})]}),!S&&h("p",{className:"mb-0 validate-label-error text-danger",children:C})]}):T("div",{className:"group-name-wrapper",children:[h("span",{className:"column-name",children:c}),h(U,{className:"p-1 mx-1",kind:"ghost",icon:Mo,tooltip:"Edit",onClick:()=>{p(!0)}}),T("span",{className:"right-buttons",children:[h(U,{kind:"ghost",icon:sn,tooltip:"Delete group",onClick:()=>n(e)}),h(U,{kind:"ghost",className:"color-swatch mr-1",icon:e.color!==void 0?T("span",{className:"fa-layers",children:[h(Z,{className:"color-swatch",icon:kr,color:Xe.white,transform:"down-1"}),h(Z,{className:"color-swatch",icon:kr,color:e.color,transform:"shrink-2 down-1"})]}):yg,tooltip:"Set color",onClick:()=>{d.current?.click(),d.current?.focus()}}),h("input",{"aria-label":"Color input",ref:d,type:"color",list:"presetColors",value:e.color??Xe["content-bg"],style:{visibility:"hidden",width:0,height:0,padding:0,border:0},onChange:E=>{e.color=E.target.value,s(e,E.target.value)}}),T("datalist",{id:"presetColors",children:[h("option",{children:Xe["content-bg"]}),h("option",{children:Xe.primary}),h("option",{children:Xe.foreground}),h("option",{children:Xe.green}),h("option",{children:Xe.yellow}),h("option",{children:Xe.orange}),h("option",{children:Xe.red}),h("option",{children:Xe.purple}),h("option",{children:Xe.blue}),h("option",{children:Xe["gray-400"]})]})]})]})}function GT(){}const WT=b.exports.forwardRef(function(e,n){const{value:s,clone:i,childCount:o,item:r,onVisibilityChange:l,onClick:a,onGroupDelete:d,onGroupColorChange:c,onGroupNameChange:u,validateGroupName:m,handleProps:p}=e,{group:g,modelIndex:f,isVisible:C}=r.data,S=b.exports.useRef(null),w=b.exports.useCallback(y=>{y.buttons===1&&(l([f].flat(),!C),S.current?.focus())},[l,f,C]),v=b.exports.useCallback(y=>{a(s,y)},[a,s]);return T("div",{ref:n,className:Y("tree-item",{isSelected:r.selected,"two-dragged":o===2,"multiple-dragged":o>2}),onClick:v,...p,children:[h(U,{ref:S,kind:"ghost",className:"px-1",onClick:GT,onMouseDown:w,onMouseEnter:w,icon:C?$a:Rh,tooltip:"Toggle visibility"}),h("span",{className:Y("column-name",g&&"column-group"),children:g&&!i?h($T,{group:g,onDelete:d,onColorChange:c,onNameChange:u,validateName:m}):s}),T("div",{children:[i&&o>1&&h("span",{className:"item-count",children:o}),h(ut,{children:"Drag to re-order"}),h(Z,{icon:el})]})]})});function zT(t){return t.parentId!==void 0}function qT(t,e){return Math.round(t/e)}function Cm(t,e,n,s,i,o){const r=t.findIndex(l=>l.name===s);if(r===-1){const l=n.get(s);if(l==null)throw new Error(`Column or header group not found: ${s}`);const a=l.childIndexes.flat();return{id:s,selected:o.has(s),children:l.children.map(d=>Cm(t,e,n,d,i,o)).sort((d,c)=>{const u=Array.isArray(d.data.visibleIndex)?d.data.visibleIndex[0]:d.data.visibleIndex,m=Array.isArray(c.data.visibleIndex)?c.data.visibleIndex[0]:c.data.visibleIndex;return u-m}),data:{modelIndex:a,visibleIndex:l.getVisibleRange(e),group:l,isVisible:a.some(d=>!i.has(d))}}}return{id:s,children:[],selected:o.has(s),data:{modelIndex:r,visibleIndex:z.getVisibleIndex(r,e),isVisible:!i.has(r)}}}function YT(t,e,n,s,i){const o=[],r=new Set(i),l=new Map(n.map(c=>[c.name,c])),a=new Set(s);let d=0;for(;d<t.length;){const c=z.getModelIndex(d,e),u=t[c].name;let m=n.find(({children:g})=>g.includes(u));for(;m!==void 0&&m.parent!==void 0;)m=l.get(m.parent);const p=Cm(t,e,l,m?m.name:u,a,r);o.push(p),Array.isArray(p.data.visibleIndex)?d+=p.data.visibleIndex[1]-p.data.visibleIndex[0]+1:d+=1}return o}function Wr(t,e,n,s,i){const o=t.findIndex(({id:S})=>S===n),r=t.findIndex(({id:S})=>S===e),l=t[r],a=Fp(t,r,o),d=a[o-1],c=a[o+1],u=qT(s,i),m=l.depth+u,p=KT({previousItem:d,nextItem:c}),g=XT({nextItem:c});let f=m;return m>=p?f=p:m<g&&(f=g),{depth:f,maxDepth:p,minDepth:g,parentId:C()};function C(){return f===0||!d?null:f===d.depth?d.parentId:f>d.depth?d.id:a.slice(0,o).reverse().find(w=>w.depth===f)?.parentId??null}}function KT({previousItem:t,nextItem:e}){return Math.max(t?.depth??0,e?.depth??0)}function XT({nextItem:t}){return t?t.depth:0}function Sm(t,e=null,n=0){return t.reduce((s,i,o)=>[...s,{...i,parentId:e,depth:n,index:o},...Sm(i.children,i.id,n+1)],[])}function dn(t){return t.every(zT)?[...t]:Sm(t)}function bm(t,e){for(let n=0;n<t.length;n+=1){const s=t[n],{id:i,children:o}=s;if(i===e)return s;if(o.length){const r=bm(o,e);if(r)return r}}}function wm(t,e=0){return t.reduce((n,{children:s})=>s.length?wm(s,n+1):n+1,e)}function jT(t,e){const n=bm(t,e);return n?wm(n.children):0}const QT=[xn.Down,xn.Right,xn.Up,xn.Left],ZT=[xn.Left,xn.Right];function JT(t,e,n){return(s,{currentCoordinates:i,context:{active:o,over:r,collisionRect:l,droppableRects:a,droppableContainers:d}})=>{if(QT.includes(s.code)){if(!o||!l)return;s.preventDefault();const{current:{items:c,offset:u}}=t;if(ZT.includes(s.code)&&r?.id!=null){const{depth:f,maxDepth:C,minDepth:S}=Wr(c,o.id,r.id,u,n);switch(s.code){case xn.Left:if(f>S)return{...i,x:i.x-n};break;case xn.Right:if(f<C)return{...i,x:i.x+n};break}return}const m=[];d.forEach(f=>{if(f?.disabled||f.id===r?.id)return;const C=a.get(f.id);if(!!C)switch(s.code){case xn.Down:l.top<C.top&&m.push(f);break;case xn.Up:l.top>C.top&&m.push(f);break}});const p=Dp({active:o,collisionRect:l,pointerCoordinates:null,droppableRects:a,droppableContainers:m});let g=Np(p,"id");if(g===r?.id&&p.length>1&&(g=p[1].id),g!=null&&r?.id!=null){const f=a.get(o.id),C=a.get(g),S=d.get(g);if(f&&C&&S){const w=c.findIndex(({id:R})=>R===g),v=c[w],y=c.findIndex(({id:R})=>R===o.id),E=c[y];if(v!=null&&E!=null){const{depth:R}=Wr(c,o.id,g,(v.depth-E.depth)*n,n),D=w>y?1:-1,N=e?(l.height-f.height)/2:0;return{x:C.left+R*n,y:C.top+D*N}}}}}}}class Tm extends _p{}Tm.activators=[{eventName:"onPointerDown",handler:({nativeEvent:t})=>!(!t.isPrimary||t.button!==0||tv(t.target))}];const ev=["button","input","textarea","select","option"];function tv(t){return!!(t?.tagName!=null&&ev.includes(t.tagName.toLowerCase()))}function vm(t){const{clone:e=!1,depth:n,disableInteraction:s=!1,ghost:i=!1,handleProps:o,value:r,dragRef:l=null,wrapperRef:a=null,renderItem:d,item:c,childCount:u}=t,m=b.exports.useMemo(()=>Array(n).fill(0).map((g,f)=>h("span",{className:"depth-line"},`depth-line-${f}`)),[n]),p=b.exports.useMemo(()=>({ref:l,clone:e,value:r,item:c,childCount:u,handleProps:o}),[l,e,r,c,u,o]);return T("li",{className:Y("item-wrapper",{clone:e,ghost:i,disableInteraction:s}),ref:a,children:[!e&&m,d(p)]},r)}vm.displayName="TreeItem";const nv=({isSorting:t,wasDragging:e})=>!(t||e);function Hc({id:t,depth:e,...n}){const{attributes:s,isDragging:i,isSorting:o,listeners:r,setDraggableNodeRef:l,setDroppableNodeRef:a,transform:d,transition:c}=Mp({id:t,animateLayoutChanges:nv}),u=aa.Translate.toString(d),m=b.exports.useMemo(()=>({transform:u,transition:c}),[u,c]),p=b.exports.useMemo(()=>({...s,...r,style:m}),[s,r,m]);return h(vm,{dragRef:l,wrapperRef:a,depth:e,ghost:i,disableInteraction:o,handleProps:p,...n})}const sv={keyframes({transform:t}){return[{opacity:1,transform:aa.Transform.toString(t.initial)},{opacity:0,transform:aa.Transform.toString({...t.final,x:t.final.x+5,y:t.final.y+5})}]},easing:"ease-out",sideEffects({active:t}){t.node.animate([{opacity:0},{opacity:1}],{duration:Vd.duration,easing:Vd.easing})}};let ur=null;function iv(t){return ur==null&&t.activeNodeRect&&t.activatorEvent instanceof PointerEvent&&(ur=Math.floor((t.activatorEvent.clientY-t.activeNodeRect.top)/t.activeNodeRect.height)*t.activeNodeRect.height),t.activeNodeRect||(ur=null),{...t.transform,y:t.transform.y+(ur??0)}}function ov({items:t,renderItem:e,indentationWidth:n=30,indicator:s=!1,activeId:i,overId:o,offsetLeft:r}){const l=kp(),a=b.exports.useRef(l);b.exports.useEffect(function(){a.current=l},[l]),b.exports.useEffect(function(){a.current.measureDroppableContainers(t.map(({id:p})=>p))},[t]);const d=i!=null&&o!=null?Wr(t,i,o,r,n):null,c=b.exports.useRef({items:t,offset:r}),u=i!=null?t.find(({id:m})=>m===i):null;return b.exports.useEffect(()=>{c.current={items:t,offset:r}},[t,r]),T(be,{children:[h("div",{className:Y("tree-container",i!=null&&"marching-ants"),children:t.map(m=>{const{id:p,depth:g}=m;return h(Hc,{id:p,value:p,depth:p===i&&d?d.depth:g,item:m,renderItem:e},p)})}),xp.exports.createPortal(h(Op,{dropAnimation:sv,modifiers:[iv],className:"visibility-ordering-list",children:i!=null&&u?h(Hc,{id:i,depth:u.depth,clone:!0,childCount:jT(t,i)+1,value:i.toString(),renderItem:e,item:u}):null}),document.body)]})}const rv={droppable:{strategy:Ap.Always}},lv={activationConstraint:{distance:5}};function av({items:t,indicator:e=!1,indentationWidth:n=30,onDragStart:s,onDragEnd:i,renderItem:o}){const[r,l]=b.exports.useState(null),[a,d]=b.exports.useState(null),[c,u]=b.exports.useState(0),m=b.exports.useMemo(()=>{const D=dn(t);return r!=null?D.filter(({id:N,selected:P})=>N===r||!P):D},[r,t]),p=r!=null&&a!=null?Wr(m,r,a,c,n):null,g=b.exports.useRef({items:m,offset:c}),f=b.exports.useMemo(()=>({coordinateGetter:JT(g,e,n)}),[n,e]),C=Lp(Bd(Tm,lv),Bd(Bp,f)),S=b.exports.useMemo(()=>m.map(({id:D})=>D),[m]);b.exports.useEffect(()=>{g.current={items:m,offset:c}},[m,c]);const w=b.exports.useCallback(({active:{id:D}})=>{l(D),d(D),s?.(D),document.body.style.setProperty("cursor","grabbing")},[s]),v=b.exports.useCallback(({delta:D})=>{u(D.x)},[]),y=b.exports.useCallback(({over:D})=>{d(D?.id??null)},[]),E=b.exports.useCallback(()=>{d(null),l(null),u(0),document.body.style.setProperty("cursor","")},[]),R=b.exports.useCallback(({active:D,over:N})=>{if(E(),p&&N){const{depth:P,parentId:H}=p,A=JSON.parse(JSON.stringify(dn(t))),q=A.findIndex(({id:x})=>x===N.id),B=A.findIndex(({id:x})=>x===D.id),K=A[B];A[B]={...K,depth:P,parentId:H},i?.(K,{...A[q],parentId:p.parentId})}},[t,i,p,E]),F=b.exports.useCallback(()=>{E()},[E]);return h(Pp,{sensors:C,collisionDetection:Hp,measuring:rv,onDragStart:w,onDragMove:v,onDragOver:y,onDragEnd:R,onDragCancel:F,children:h(Up,{items:S,strategy:Vp,children:h(ov,{items:m,renderItem:o,indicator:e,indentationWidth:n,activeId:r,overId:a,offsetLeft:c})})})}function dv(t,e,n,s,i,o,r,l){const a=i.map((w,v)=>({...w,index:v}));let d=[],c=s;const u=o[0].data.visibleIndex,m=a.findIndex(({id:w})=>w===t.id),p=a.findIndex(({id:w})=>w===e.id);let g=Array.isArray(u)?u[1]+1:u+1;c=Fs(o[0],e.parentId,c);for(let w=1;w<o.length;w+=1){const{data:{visibleIndex:v}}=o[w];d=z.moveItemOrRange(v,g,d,!0),g+=Array.isArray(v)?v[1]-v[0]+1:1,c=Fs(o[w],e.parentId,c)}const f=[Array.isArray(u)?u[0]:u,g-1],C=Array.isArray(e.data.visibleIndex)?e.data.visibleIndex[0]:e.data.visibleIndex;let S=z.getVisibleIndex(C,d);return m>p&&S>C&&(S-=1),e.children.length>0&&(Array.isArray(u)?u[0]:u)<S&&(S-=1),f[0]<S&&(S-=f[1]-f[0]),d=z.moveItemOrRange(f,Ze(S,r,l),d),{groups:c,movedColumns:n.concat(d)}}function Fs(t,e,n){if(t.parentId===e)return[...n];let s=n.map(a=>new kn(a));const i=new Map(s.map(a=>[a.name,a])),o=s.find(a=>a.name===t.parentId),r=s.find(a=>a.name===e),l=s.find(a=>a.name===t.id);if(o!=null&&(o.children=o.children.filter(a=>a!==t.id),o.children.length===0)){const a=new Set([o.name]),{parent:d=""}=o;let c=i.get(d);for(c?.removeChildren([o.name]);c&&c.children.length===0;){a.add(c.name);const u=c?.parent??"",m=i.get(u);m?.removeChildren([c.name]),c=m}s=s.filter(({name:u})=>!a.has(u))}return r?.addChildren([t.id]),l?.setParent(e??void 0),s}const cv=150,Ct=class extends b.exports.Component{constructor(t){super(t),this.debouncedSearchColumns=Je(this.searchColumns,cv),this.handleGroupColorChange=Ln((e,n)=>{const{columnHeaderGroups:s,onColumnHeaderGroupChanged:i}=this.props,o=[...s],r=new kn({...e,color:n});o.splice(o.findIndex(({name:l})=>l===e.name),1,r),i(o)},250),this.renderItem=Ie(({value:e,clone:n,item:s,ref:i,handleProps:o})=>{const{onColumnVisibilityChanged:r}=this.props,{selectedColumns:l}=this.state;let a=e;return n&&(a=this.getSelectedParentItems().map(({id:c})=>c).join(", ")),h(WT,{ref:i,value:a,clone:n,item:s,childCount:l.size,onVisibilityChange:r,onClick:this.handleItemClick,onGroupDelete:this.handleGroupDelete,onGroupColorChange:this.handleGroupColorChange,onGroupNameChange:this.handleGroupNameChange,validateGroupName:this.validateGroupName,handleProps:o})}),this.getMemoizedFirstMovableIndex=Ie((e,n,s)=>{for(let i=0;i<n.length;i+=1){const o=z.getModelIndex(i,s);if(e.isColumnMovable(o))return i}return null}),this.getMemoizedLastMovableIndex=Ie((e,n,s)=>{for(let i=n.length-1;i>=0;i-=1){const o=z.getModelIndex(i,s);if(e.isColumnMovable(o))return i}return null}),this.memoizedGetTreeItems=Ie((e,n,s,i,o)=>YT(e,n,s,i,[...o.values()])),this.makeVisibilityOrderingList=Ie((e,n)=>{const{movedColumns:s}=this.props,i=[],o=this.getFirstMovableIndex(),r=this.getLastMovableIndex(),l=n.findIndex(({data:c})=>Array.isArray(c.visibleIndex)?c.visibleIndex[0]===o:c.visibleIndex===o),a=n.findIndex(({data:c})=>Array.isArray(c.visibleIndex)?c.visibleIndex[1]===r:c.visibleIndex===r),d=n.slice(l,a+1);if(o==null||r===null){for(let c=0;c<e.length;c+=1){const u=z.getModelIndex(c,s),m=e[u];i.push(this.renderImmovableItem(m.name))}return i}for(let c=0;c<o;c+=1){const u=z.getModelIndex(c,s),m=e[u];i.push(this.renderImmovableItem(m.name))}o!==null&&o>0&&i.push(h("hr",{},"top-horizontal-divider")),i.push(h(av,{items:d,renderItem:this.renderItem,onDragStart:this.handleDragStart,onDragEnd:this.handleDragEnd},"movable-items")),r!=null&&r<e.length-1&&i.push(h("hr",{},"bottom-horizontal-divider"));for(let c=r+1;c<e.length;c+=1){const u=z.getModelIndex(c,s),m=e[u];i.push(this.renderImmovableItem(m.name))}return i}),this.renderImmovableItem=Ie(e=>h("div",{className:"visibility-ordering-list-item immovable",children:h("div",{className:"column-item",children:h("span",{className:"column-name",children:e})})},e)),this.handleSearchInputChange=this.handleSearchInputChange.bind(this),this.searchColumns=this.searchColumns.bind(this),this.handleItemClick=this.handleItemClick.bind(this),this.handleDragEnd=this.handleDragEnd.bind(this),this.handleGroupDelete=this.handleGroupDelete.bind(this),this.handleGroupNameChange=this.handleGroupNameChange.bind(this),this.handleGroupCreate=this.handleGroupCreate.bind(this),this.validateGroupName=this.validateGroupName.bind(this),this.addColumnToSelected=this.addColumnToSelected.bind(this),this.handleDragStart=this.handleDragStart.bind(this),this.state={selectedColumns:new Set,lastSelectedColumn:"",searchFilter:""},this.list=null}componentWillUnmount(){this.debouncedSearchColumns.cancel()}resetVisibilityOrdering(){const{model:t,onReset:e,onMovedColumnsChanged:n,onColumnHeaderGroupChanged:s}=this.props;this.setState({selectedColumns:new Set,lastSelectedColumn:"",searchFilter:""}),e(),s(t.initialColumnHeaderGroups),n(t.initialMovedColumns)}resetSelection(){this.setState({selectedColumns:new Set,lastSelectedColumn:""})}handleSearchInputChange(t){const e=t.target.value;if(this.setState({searchFilter:e}),!e){this.debouncedSearchColumns.cancel(),this.resetSelection();return}this.debouncedSearchColumns(e)}searchColumns(t){const e=dn(this.getTreeItems()),s=e.filter(({id:o})=>o.toLowerCase().includes(t.toLowerCase())).map(({id:o})=>o),i=e.findIndex(({id:o})=>o.toLowerCase().includes(t.toLowerCase()));this.addColumnToSelected(s,!1),s.length>0&&this.list?.querySelectorAll(".item-wrapper")[i]?.scrollIntoView({block:"center"})}moveSelectedColumns(t){const{columnHeaderGroups:e}=this.props,{selectedColumns:n}=this.state,s=dn(this.getTreeItems());let i=this.getFirstMovableIndex(),o=this.getLastMovableIndex();k(i),k(o);const r=this.getSelectedParentItems();t===Ct.MOVE_OPTIONS.UP||t===Ct.MOVE_OPTIONS.TOP||r.reverse();let a=[],d=e;for(let c=0;c<r.length;c+=1){const{id:u,parentId:m,depth:p,data:{visibleIndex:g}}=r[c];switch(t){case Ct.MOVE_OPTIONS.TOP:{a=z.moveItemOrRange(g,i,a,!0),i+=Array.isArray(g)?g[1]-g[0]+1:1,d=Fs(r[c],null,d);break}case Ct.MOVE_OPTIONS.BOTTOM:{a=z.moveItemOrRange(g,o,a,!0),o-=Array.isArray(g)?g[1]-g[0]+1:1,d=Fs(r[c],null,d);break}case Ct.MOVE_OPTIONS.UP:{const f=s.findIndex(w=>w.id===u),C=s.map((w,v)=>v<f&&!n.has(w.id)).lastIndexOf(!0),S=s[C];if(S!=null&&S.parentId!==m)if(Math.abs(S.depth-p)>1){const w=s.map((y,E)=>E<C&&y.depth===p).lastIndexOf(!0),v=s[w];d=Fs(r[c],v.id,d)}else d=Fs(r[c],S.parentId,d);else{const w=Ze(Array.isArray(g)?g[0]-1:g-1,i,o);a=z.moveItemOrRange(g,w,a,!1),i+=Array.isArray(g)?g[1]-g[0]+1:1}break}case Ct.MOVE_OPTIONS.DOWN:{const f=s.findIndex(v=>v.id===u),C=s.find((v,y)=>y>f&&!n.has(v.id));if(C?.parentId!==m){const v=s.find(y=>y.id===m);d=Fs(r[c],v?.parentId??null,d);break}else if(C?.children.length>0){d=Fs(r[c],C.id,d);break}const S=Ze(Array.isArray(g)?g[0]+1:g+1,i,o);a=z.moveItemOrRange(g,S,a,!1),o-=Array.isArray(g)?g[1]-g[0]+1:1;break}}}return{newMoves:a,groups:d}}handleMoveColumns(t){const{onMovedColumnsChanged:e,movedColumns:n,onColumnHeaderGroupChanged:s}=this.props,{newMoves:i,groups:o}=this.moveSelectedColumns(t);let r;t===Ct.MOVE_OPTIONS.TOP&&(r=()=>{this.list?.parentElement?.scroll({top:0})}),t===Ct.MOVE_OPTIONS.BOTTOM&&(r=()=>{this.list?.parentElement?.scroll({top:this.list.parentElement.scrollHeight})}),s(o),i.length>0&&e(n.concat(i),r)}getSortMoves(t,e,n){const s=[...t],i=e===Ct.SORTING_OPTIONS.ASC;s.sort((l,a)=>{const d=l.id.toUpperCase(),c=a.id.toUpperCase();return jt.sort(d,c,i)});let o=[...n],r=Math.min(...s.flatMap(l=>{const{modelIndex:a}=l.data;return Array.isArray(a)?z.getVisibleIndexes(a,o):z.getVisibleIndex(a,o)}));for(let l=0;l<s.length;l+=1){const a=s[l],{modelIndex:d}=a.data,c=Array.isArray(d)?z.getVisibleIndexes(d,o):z.getVisibleIndex(d,o);o=Array.isArray(c)?z.moveRange([Math.min(...c),Math.max(...c)],r,o,!0):z.moveItem(c,r,o),Array.isArray(c)&&(o=this.getSortMoves(a.children,e,o)),r+=Array.isArray(d)?d.length:1}return o}handleSortColumns(t){const{model:e,onMovedColumnsChanged:n}=this.props,s=this.getSortMoves(this.getTreeItems(),t,e.initialMovedColumns);n(s)}handleItemClick(t,e){if(e.stopPropagation(),e.target instanceof HTMLElement&&(e.target.tagName==="BUTTON"||e.target.tagName==="INPUT"))return;e.currentTarget.focus();const{selectedColumns:n,lastSelectedColumn:s}=this.state,i=z.isModifierKeyDown(e),o=e.shiftKey,r=n.has(t),l=[t];if(r&&i){this.removeColumnFromSelected(t);return}const a=dn(this.getTreeItems());if(r&&!o&&s===t){const d=a.find(({id:u})=>u===t);if(k(d),dn(d.children).length+1===n.size){this.resetSelection();return}}if(o){const d=a.findIndex(u=>u.id===t),c=a.findIndex(u=>u.id===s);l.push(...a.slice(Math.min(c,d),Math.max(c,d)+1).map(u=>u.id))}this.addColumnToSelected(l,i||o),this.setState({lastSelectedColumn:t})}addColumnToSelected(t,e){const{selectedColumns:n}=this.state,s=new Set(e?[...n.values()].concat(t):t);dn(this.getTreeItems()).forEach(({id:o,children:r})=>{s.has(o)&&r.forEach(l=>s.add(l.id))}),this.setState({selectedColumns:s})}removeColumnFromSelected(t){const{selectedColumns:e}=this.state,n=dn(this.getTreeItems()),s=n.find(({id:o})=>o===t);k(s);let i=n.find(({id:o})=>o===s.parentId);for(dn(s?.children).forEach(o=>e.delete(o.id));i!=null;){e.delete(i.id);const o=i.parentId;i=n.find(({id:r})=>r===o)}e.delete(t),this.setState({selectedColumns:new Set(e)})}handleDragStart(t){const{selectedColumns:e}=this.state;e.has(t)||this.addColumnToSelected([t],!1)}handleDragEnd(t,e){const{movedColumns:n,onMovedColumnsChanged:s,columnHeaderGroups:i,onColumnHeaderGroupChanged:o}=this.props,r=this.getSelectedParentItems(),l=dn(this.getTreeItems()).map((m,p)=>({...m,index:p})),a=this.getFirstMovableIndex(),d=this.getLastMovableIndex();k(a),k(d);const{groups:c,movedColumns:u}=dv(t,e,n,i,l,r,a,d);o(c),s(u)}handleGroupNameChange(t,e){const{columnHeaderGroups:n,onColumnHeaderGroupChanged:s}=this.props,i=[...n],o=t.name,r=i.findIndex(({name:c})=>c===o),l=i[r];k(l);const a=new kn(l);a.name=e,i.splice(r,1,a);const d=i.findIndex(({name:c})=>c===a.parent);if(d>=0){const c=new kn(i[d]);c.removeChildren([o]),c.addChildren([e]),i.splice(d,1,c)}s(i)}handleGroupDelete(t){const{columnHeaderGroups:e,onColumnHeaderGroupChanged:n}=this.props,s=e.filter(o=>o.name!==t.name),i=s.findIndex(o=>o.name===t.parent);if(i>=0){const o=new kn(s[i]);o.addChildren(t.children),o.removeChildren([t.name]),s.splice(i,1,o)}n(s)}handleGroupCreate(){const{movedColumns:t,onMovedColumnsChanged:e,onColumnHeaderGroupChanged:n}=this.props,{newMoves:s,groups:i}=this.moveSelectedColumns(Ct.MOVE_OPTIONS.TOP),o=i.filter(c=>!c.isNew),r=this.getSelectedParentItems(),l=r.map(c=>c.data.modelIndex).flat().filter(c=>c>=0),a=`${kn.NEW_GROUP_PREFIX}-${Date.now()}`,d=new kn({name:a,children:r.map(({id:c})=>c),depth:0,childIndexes:[...new Set(l)]});e(t.concat(s),()=>{this.list?.parentElement?.scroll({top:0})}),n(o.concat([d])),this.resetSelection()}validateGroupName(t){const{model:e,columnHeaderGroups:n}=this.props,{columns:s}=e;return Vi.isValidColumnName(t)?s.some(({name:i})=>i===t)||n.some(({name:i})=>i===t)?"Duplicate name":"":"Invalid name"}getFirstMovableIndex(){const{model:t,movedColumns:e}=this.props;return this.getMemoizedFirstMovableIndex(t,t.columns,e)}getLastMovableIndex(){const{model:t,movedColumns:e}=this.props;return this.getMemoizedLastMovableIndex(t,t.columns,e)}getTreeItems(){const{model:t,movedColumns:e,hiddenColumns:n,columnHeaderGroups:s}=this.props,{selectedColumns:i}=this.state;return this.memoizedGetTreeItems(t.columns,e,s,n,i)}getSelectedParentItems(){const{selectedColumns:t}=this.state;return dn(this.getTreeItems()).filter(({id:n,parentId:s})=>t.has(n)&&!t.has(s??""))}render(){const{model:t,hiddenColumns:e,onColumnVisibilityChanged:n}=this.props,{selectedColumns:s,searchFilter:i}=this.state,o=s.size>0,r=this.getTreeItems(),l=new Map(dn(r).map(g=>[g.id,g.data.modelIndex])),a=new Set(e),d=[...new Set(o?[...s.values()].map(g=>l.get(g)).filter(g=>g!=null).flat():r.map(g=>g.data.modelIndex).flat())],c=d.some(g=>!a.has(g)),u=c?"Hide All":"Show All",m=c?"Hide Selected":"Show Selected",p=this.makeVisibilityOrderingList(t.columns,r);return T("div",{role:"menu",className:"visibility-ordering-builder",tabIndex:0,children:[T("div",{className:"top-menu",children:[h(U,{kind:"ghost",className:"toggle-visibility-btn",onClick:()=>{n(d,!c)},icon:c?$a:Rh,tooltip:"Toggle column visibility",children:o?m:u}),h(Bi,{className:"visibility-search",value:i,matchCount:i?s.size:void 0,onChange:this.handleSearchInputChange})]}),T("div",{className:"top-menu",children:[h(U,{kind:"ghost",icon:ei,tooltip:"Reset to default",onClick:()=>{this.resetVisibilityOrdering()},children:"Reset"}),h("span",{className:"vertical-divider"}),h(U,{kind:"ghost",icon:Va,tooltip:"Sort ascending",onClick:()=>{this.handleSortColumns(Ct.SORTING_OPTIONS.ASC)}}),h(U,{kind:"ghost",icon:Ba,tooltip:"Sort descending",onClick:()=>{this.handleSortColumns(Ct.SORTING_OPTIONS.DSC)}}),h("span",{className:"vertical-divider"}),T(U,{kind:"ghost",tooltip:"Create group from selection",disabled:!o,onClick:this.handleGroupCreate,children:[T("span",{className:"fa-layers",style:{marginRight:"0.75rem"},children:[h(Z,{mask:Rg,icon:Mi,transform:"right-7 down-5 shrink-6"}),h(Z,{icon:Ig,transform:"right-8 down-6 shrink-8"})]}),"Group"]}),h("span",{className:"vertical-divider"}),h(U,{kind:"ghost",icon:Fg,tooltip:"Move selection up",onClick:()=>{this.handleMoveColumns(Ct.MOVE_OPTIONS.UP)},disabled:!o}),h(U,{kind:"ghost",icon:Dg,tooltip:"Move selection down",onClick:()=>{this.handleMoveColumns(Ct.MOVE_OPTIONS.DOWN)},disabled:!o}),h(U,{kind:"ghost",icon:Ng,tooltip:"Move selection to top",onClick:()=>{this.handleMoveColumns(Ct.MOVE_OPTIONS.TOP)},disabled:!o}),h(U,{kind:"ghost",icon:_g,tooltip:"Move selection to bottom",onClick:()=>{this.handleMoveColumns(Ct.MOVE_OPTIONS.BOTTOM)},disabled:!o})]}),h("div",{role:"menu",className:Y("visibility-ordering-list"),children:h("div",{className:"column-list",ref:g=>{this.list=g},children:p})})]})}};let pd=Ct;pd.SORTING_OPTIONS={DSC:"DSC",ASC:"ASC"};pd.MOVE_OPTIONS={TOP:"TOP",BOTTOM:"BOTTOM",UP:"UP",DOWN:"DOWN"};class mr extends b.exports.PureComponent{constructor(e){super(e),this.handleSearchValueChange=this.handleSearchValueChange.bind(this),this.toggleColumn=this.toggleColumn.bind(this),this.selectAll=this.selectAll.bind(this),this.clear=this.clear.bind(this),this.selectNumbers=this.selectNumbers.bind(this),this.searchField=de.createRef(),this.state={isConfigureColumnsShown:!1}}static createSearchFilter(e,n,s,i){const o=i?s.filter(r=>!n.includes(r.name)).map(r=>r.name):n;if(e&&o.length>0){const r=I.FilterValue.ofString(e);return o.length===s.length?I.FilterCondition.search(r):I.FilterCondition.search(r,s.filter(a=>o.includes(a.name)).map(a=>a.filter()))}}focus(){this.searchField.current?.focus()}handleSearchValueChange(e){const{onChange:n,selectedColumns:s,invertSelection:i}=this.props;n(e.target.value,s,i)}sendColumnChange(e,n){const{onChange:s,value:i}=this.props;s(i,e,n)}setInvertSelection(e){const{onChange:n,value:s}=this.props;n(s,[],e)}toggleColumn(e){const{selectedColumns:n,invertSelection:s}=this.props;if(n.includes(e))this.sendColumnChange(n.filter(i=>i!==e),s);else{const i=n.slice();i.push(e),this.sendColumnChange(i,s)}}selectAll(){this.setInvertSelection(!0)}clear(){this.setInvertSelection(!1)}selectNumbers(){const{columns:e}=this.props;this.sendColumnChange(e.filter(n=>_.isNumberType(n.type)).map(n=>n.name),!1)}render(){const{value:e,selectedColumns:n,invertSelection:s,columns:i}=this.props,{isConfigureColumnsShown:o}=this.state,r=n.length===0&&s===!0||n.length===i.length&&s===!1,l=n.length===0&&s===!1||n.length===i.length&&s===!0;let a;return r?a=T(be,{children:[h(Z,{icon:kr,mask:Vl,transform:"shrink-2 down-5 right-7"}),h(Z,{icon:Mg,className:"text-primary",transform:"shrink-4 down-5 right-7"})]}):l?a=T(be,{children:[h(Z,{icon:Mi,mask:Vl,transform:"shrink-1 down-5 right-7"}),h(Z,{icon:Yd,className:"text-danger",transform:"shrink-4 down-5 right-7"})]}):a=T(be,{children:[h(Z,{icon:kr,mask:Vl,transform:"shrink-2 down-5 right-7"}),h(Z,{icon:kg,className:"text-primary",transform:"shrink-4 down-5 right-7"})]}),T("div",{className:"cross-column-container",children:[h(Bi,{className:"cross-column-search",placeholder:"Search Data...",value:e,onChange:this.handleSearchValueChange,ref:this.searchField}),T("button",{type:"button",className:"btn btn-link btn-link-icon px-2",onClick:()=>{o?this.setState({isConfigureColumnsShown:!1}):this.setState({isConfigureColumnsShown:!0})},children:[h("div",{className:"fa-layers",children:a}),h(ut,{children:"Configure Columns"}),h(tl,{isShown:o,className:"cross-column-popper",onExited:()=>{this.setState({isConfigureColumnsShown:!1})},closeOnBlur:!0,interactive:!0,children:T("div",{className:"cross-column-popup",children:["Searched Columns",h("div",{className:"cross-column-scroll",children:i.map(d=>T(de.Fragment,{children:[h(mn,{className:"cross-column-checkbox",checked:s?!n.includes(d.name):n.includes(d.name),onChange:()=>this.toggleColumn(d.name),children:d.name}),d.type.substring(d.type.lastIndexOf(".")+1)]},d.name))}),T("div",{className:"cross-column-button-bar",children:[h("button",{type:"button",className:"btn btn-link",onClick:this.selectAll,children:"Select All"}),h("button",{type:"button",className:"btn btn-link",onClick:this.clear,children:"Clear"}),h("button",{type:"button",className:"btn btn-link",onClick:this.selectNumbers,children:"Numbers Only"})]}),l&&T("p",{className:"text-danger",children:[h(Z,{icon:Yd})," Select at least one column to search."]})]})})]})]})}}const Ts=J.module("PartitionSelectorSearch"),hv=150,Em=class extends b.exports.Component{constructor(t){super(t),this.debounceUpdateFilter=Je(()=>{this.updateFilter()},hv),this.handleFilterChange=this.handleFilterChange.bind(this),this.handleInputFocus=this.handleInputFocus.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleListKeydown=this.handleListKeydown.bind(this),this.handleSelect=this.handleSelect.bind(this),this.handleTableUpdate=this.handleTableUpdate.bind(this),this.handleTextChange=this.handleTextChange.bind(this),this.handleViewportChange=this.handleViewportChange.bind(this),this.itemList=null,this.searchInput=null,this.timer=null,this.state={offset:0,itemCount:0,items:[],text:"",isLoading:!0}}static handleError(t){t instanceof Zr||Ts.error(t)}componentDidMount(){this.startListening()}componentDidUpdate(t,e){const{isLoading:n,itemCount:s}=this.state,{onListResized:i}=this.props;(s!==e.itemCount||n!==e.isLoading)&&i()}componentWillUnmount(){this.debounceUpdateFilter.cancel(),this.stopListening()}handleKeyDown(t){if(this.itemList==null)return!1;const{items:e,itemCount:n}=this.state;switch(t.key){case"Enter":{let s=null;if(e.length>0)s=e[0].value;else{const{text:i}=this.state;s=i.trim()}if(s.length>0){const{onSelect:i}=this.props;i(s)}return t.stopPropagation(),t.preventDefault(),!0}case"ArrowDown":return n>0&&this.itemList.focusItem(1),t.stopPropagation(),t.preventDefault(),!0;default:return!1}}handleListKeydown(t){switch(t.key){case"Escape":break;default:this.focus();break}}handleFilterChange(){Ts.debug2("handleFilterChange");const{table:t}=this.props,e=t.size;this.setState({itemCount:e,isLoading:!0})}handleInputFocus(){this.itemList&&this.itemList.focusItem(0)}handleSelect(t){Ts.debug2("handleSelect",t);const{onSelect:e}=this.props,{offset:n,items:s}=this.state,i=t-n;if(i<0||s.length<=i){Ts.error("No data for item",t);return}const{value:o}=s[i];e(o)}handleTableUpdate(t){const e=t.detail,{offset:n}=e,s=[],{getFormattedString:i,table:o}=this.props,r=o.columns[0];for(let a=0;a<e.rows.length;a+=1){const c=e.rows[a].get(r),u=i(c,r.type,r.name);s.push({displayValue:u,value:c})}const l=o.size;Ts.debug2("handleTableUpdate",l,n,s.length),this.setState({itemCount:l,items:s,offset:n,isLoading:!1})}handleTextChange(t){Ts.debug2("handleTextChange");const{value:e}=t.target;this.setState({text:e}),this.debounceUpdateFilter()}handleViewportChange(t,e){Ts.debug2("handleViewportChange",t,e);const n=Math.max(1,e-t),s=Math.max(0,t-n),i=e+n,{table:o}=this.props;o.setViewport(s,i)}focus(){this.searchInput&&this.searchInput.focus()}startListening(){const{initialPageSize:t,table:e}=this.props;e.addEventListener(I.Table.EVENT_UPDATED,this.handleTableUpdate),e.addEventListener(I.Table.EVENT_FILTERCHANGED,this.handleFilterChange),e.setViewport(0,t)}stopListening(){const{table:t}=this.props;t.removeEventListener(I.Table.EVENT_UPDATED,this.handleTableUpdate),t.removeEventListener(I.Table.EVENT_FILTERCHANGED,this.handleFilterChange)}updateFilter(){const{initialPageSize:t,table:e}=this.props,{text:n}=this.state,s=n.trim(),i=[];if(s.length>0){const r=e.columns[0].filter().invoke("matches",I.FilterValue.ofString(`(?s)(?i).*\\Q${s}\\E.*`));i.push(r)}Ts.debug2("updateFilter",i),e.applyFilter(i),e.setViewport(0,t)}render(){const{isLoading:t,itemCount:e,items:n,offset:s,text:i}=this.state,o=Math.min(e,Em.MAX_VISIBLE_ITEMS)*ki.DEFAULT_ROW_HEIGHT+11;return T("div",{className:"iris-grid-partition-selector-search",children:[h("div",{className:"search-container",children:h("input",{type:"text",ref:r=>{this.searchInput=r},value:i,placeholder:"Available Partitions",onChange:this.handleTextChange,onFocus:this.handleInputFocus,onKeyDown:this.handleKeyDown,className:"form-control input-partition"})}),!t&&e>0&&h("div",{className:"iris-grid-partition-selector-search-list",onKeyDown:this.handleListKeydown,role:"presentation",style:{height:o},children:h(ki,{ref:r=>{this.itemList=r},itemCount:e,items:n,offset:s,onSelect:this.handleSelect,onViewportChange:this.handleViewportChange})}),!t&&e===0&&h("div",{className:"iris-grid-partition-selector-search-empty",children:"No results"}),t&&T("div",{className:"iris-grid-partition-selector-loading",children:[h(as,{}),"\xA0Loading..."]})]})}};let yl=Em;yl.MAX_VISIBLE_ITEMS=12;yl.defaultProps={initialPageSize:100,onSelect:()=>{},onListResized:()=>{}};yl.propTypes={getFormattedString:M.exports.func.isRequired,table:M.exports.shape({addEventListener:M.exports.func.isRequired,removeEventListener:M.exports.func.isRequired,columns:M.exports.arrayOf(M.exports.shape({name:M.exports.string.isRequired,type:M.exports.string.isRequired,filter:M.exports.func.isRequired})),size:M.exports.number.isRequired,applyFilter:M.exports.func.isRequired,setViewport:M.exports.func.isRequired}).isRequired,initialPageSize:M.exports.number,onSelect:M.exports.func,onListResized:M.exports.func};const Ci=J.module("IrisGridPartitionSelector"),uv=250;class ym extends b.exports.Component{constructor(e){super(e),this.debounceUpdate=Je(()=>{this.sendUpdate()},uv),this.handleAppendClick=this.handleAppendClick.bind(this),this.handleCloseClick=this.handleCloseClick.bind(this),this.handleIgnoreClick=this.handleIgnoreClick.bind(this),this.handlePartitionChange=this.handlePartitionChange.bind(this),this.handlePartitionSelect=this.handlePartitionSelect.bind(this),this.handlePartitionListResized=this.handlePartitionListResized.bind(this),this.handleSearchOpened=this.handleSearchOpened.bind(this),this.handleSearchClosed=this.handleSearchClosed.bind(this),this.searchMenu=null,this.selectorSearch=null;const{partition:n}=e;this.state={partition:n}}componentWillUnmount(){this.debounceUpdate.cancel()}handleAppendClick(){Ci.debug2("handleAppendClick");const{onAppend:e}=this.props,{partition:n}=this.state;e(n)}handleCloseClick(){Ci.debug2("handleCloseClick"),this.sendDone()}handleIgnoreClick(){Ci.debug2("handleIgnoreClick"),this.sendFetchAll()}handlePartitionChange(e){Ci.debug2("handlePartitionChange");const{value:n}=e.target;this.setState({partition:n}),this.debounceUpdate()}handlePartitionSelect(e){this.searchMenu&&this.searchMenu.closeMenu(),this.setState({partition:e},()=>{this.sendUpdate()})}handlePartitionListResized(){this.searchMenu&&this.searchMenu.scheduleUpdate()}handleSearchClosed(){const{table:e}=this.props;e.applyFilter([])}handleSearchOpened(){this.selectorSearch&&this.selectorSearch.focus()}sendDone(){this.debounceUpdate.flush();const{onDone:e}=this.props;e()}sendUpdate(){Ci.debug2("sendUpdate");const{onChange:e}=this.props,{partition:n}=this.state;e(n)}sendFetchAll(){Ci.debug2("sendFetchAll"),this.debounceUpdate.cancel();const{onFetchAll:e}=this.props;e()}render(){const{columnName:e,getFormattedString:n,onDone:s,table:i}=this.props,{partition:o}=this.state,r=h(yl,{getFormattedString:n,table:i,onSelect:this.handlePartitionSelect,onListResized:this.handlePartitionListResized,ref:l=>{this.selectorSearch=l}},"search");return T("div",{className:"iris-grid-partition-selector",children:[h("div",{className:"status-message",children:T("span",{children:['Filtering "',e,'" partition to']})}),T("div",{className:"input-group",children:[h("input",{type:"text",value:o,onChange:this.handlePartitionChange,className:"form-control input-partition"}),h("div",{className:"input-group-append",children:T("button",{type:"button",className:"btn btn-outline-primary",children:[h(Z,{icon:ts}),h(ut,{children:"Partitions"}),h(ns,{ref:l=>{this.searchMenu=l},actions:[{menuElement:r}],onMenuOpened:this.handleSearchOpened,onMenuClosed:this.handleSearchClosed})]})})]}),h("div",{className:"iris-grid-partition-selector-spacer"}),h("button",{type:"button",className:"btn btn-outline-primary btn-ignore",onClick:this.handleIgnoreClick,children:"Ignore & Fetch All"}),h("button",{type:"button",className:"btn btn-outline-primary btn-append",onClick:this.handleAppendClick,children:"Append Command"}),h("button",{type:"button",className:"btn btn-link btn-link-icon btn-close",onClick:s,children:h(Z,{icon:Ui})})]})}}ym.defaultProps={onAppend:()=>{},onChange:()=>{},onFetchAll:()=>{},onDone:()=>{},partition:""};const mv=J.module("SelectDistinctBuilder");class Rm extends b.exports.Component{constructor(e){super(e),this.handleAddColumnClick=this.handleAddColumnClick.bind(this),this.handleDeleteColumn=this.handleDeleteColumn.bind(this),this.handleDropdownChanged=this.handleDropdownChanged.bind(this);const{model:n,selectDistinctColumns:s}=this.props;this.state={inputs:s.length>0?[...s]:[""],columns:n.originalColumns}}componentDidUpdate(e,n){const{inputs:s}=this.state,{onChange:i}=this.props;if(n.inputs!==s){const o=s.filter(r=>r!=="");ct(n.inputs.filter(r=>r!==""),o)||i(o)}}handleAddColumnClick(){this.setState(({inputs:e})=>({inputs:[...e,""]}))}handleDeleteColumn(e){this.setState(({inputs:n})=>({inputs:n.length===1&&e===0?[""]:n.filter((s,i)=>e!==i)}))}handleDropdownChanged(e,n){mv.debug("handleDropdownChanged",e,n);const{value:s}=n.target;this.setState(({inputs:i})=>{const o=[...i];return o[e]=s,{inputs:o}})}renderInputs(){const{columns:e,inputs:n}=this.state;return n.map((s,i)=>{const o=e.filter(({name:r})=>r===s||!n.includes(r)).map(({name:r})=>h("option",{value:r,children:r},r));return T("div",{className:"form-inline px-3 pb-3",children:[T("select",{className:"form-control custom-select col",value:s,onChange:r=>this.handleDropdownChanged(i,r),children:[h("option",{value:"",children:"Select a column"}),o]}),(n.length>1||s!=="")&&h(U,{kind:"ghost",className:"ml-1 px-2",onClick:()=>{this.handleDeleteColumn(i)},icon:h(Z,{icon:sn,transform:"grow-3"}),tooltip:"Delete column"})]},i)})}render(){const{columns:e,inputs:n}=this.state,s=n.length>=e.length;return T("div",{role:"presentation",className:"select-distinct-builder-container h-100",children:[h("div",{className:"select-distinct-title",children:"Display Unique Values From"}),this.renderInputs(),h("hr",{}),h("div",{className:"pt-1 px-3",children:h(U,{kind:"ghost",className:"btn-add-column",onClick:this.handleAddColumnClick,disabled:s,icon:As,children:"Add Additional Column"})}),h("div",{className:"select-distinct-builder-footer",children:T("div",{className:"select-distinct-builder-hint",children:["Modifies a table to show unique value from a column, same as"," ",h("span",{className:"inline-code-snippet",children:'selectDistinct("Column")'}),". Filters will be reset and the resulting table will contain only the selected columns above."]})})]})}}Rm.defaultProps={selectDistinctColumns:[],onChange:()=>{}};function gd({items:t,onChange:e=()=>{}}){return h(Oh,{items:Array.from(t.entries()).map(([n,s])=>({title:gd.getAdvancedSettingsTitleForKey(n),isOn:s,onChange:i=>e(n,i)}))})}gd.getAdvancedSettingsTitleForKey=t=>{switch(t){case li.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS:return"Control filters clear existing table filters";case li.LINK_CHANGE_CLEARS_ALL_FILTERS:return"Inbound links clear existing table filters"}};const Uc=J.module("ConditionalFormattingMenu"),Zl=()=>{};function pv(t){const{column:{type:e}}=t;if(_.isNumberType(e))return t.condition===We.IS_NULL||t.condition===We.IS_NOT_NULL?"":`${t.value}`;if(_.isCharType(e))return t.condition===Lt.IS_NULL||t.condition===Lt.IS_NOT_NULL?"":`${t.value}`;if(_.isStringType(e))return t.condition===Qt.IS_NULL||t.condition===Qt.IS_NOT_NULL?"":`"${t.value}"`;if(_.isDateType(e))return t.condition===Lt.IS_NULL||t.condition===Lt.IS_NOT_NULL?"":`${t.value}`;if(_.isBooleanType(e))return"";throw new Error(`Invalid column type ${e} in getRuleValue`)}function gv(t){return _.isNumberType(t.column.type)&&t.condition===We.IS_BETWEEN?`${t.start} < ${t.column.name} < ${t.end}`:`${t.column.name} ${zw(t.column.type,t.condition)}
30
30
  ${pv(t)}`}function fv(t){const{rules:e=[],onChange:n=Zl,onCreate:s=Zl,onSelect:i=Zl}=t,o=b.exports.useCallback((d,c,u)=>{d.stopPropagation(),Uc.debug("Rule clicked",c,u),i(u)},[i]),r=b.exports.useCallback((d,c,u)=>{d.stopPropagation(),Uc.debug("Delete button clicked",c,u);const m=[...e];m.splice(u,1),n(m)},[n,e]),l=b.exports.useCallback(d=>{d.stopPropagation()},[]),a=b.exports.useCallback(d=>{if(qt.stopDragging(),d.destination==null)return;const c=d.source.index,u=d.destination.index,m=[...e],p=e[c];m.splice(c,1),m.splice(u,0,p),n(m)},[n,e]);return T("div",{className:"conditional-formatting-rules",children:[h(jr,{onDragStart:qt.startDragging,onDragEnd:a,children:h(Aa,{droppableId:"droppable-custom-columns",children:(d,c)=>T("div",{ref:d.innerRef,...d.droppableProps,className:Y("droppable-container",{dragging:c.draggingFromThisWith}),children:[e.length===0&&h("div",{className:"text-muted pl-2",children:"No formats defined"}),e.map((u,m)=>h(gh,{draggableId:`${m}-${u.type}`,index:m,disableInteractiveElementBlocking:!0,children:(p,g)=>h("div",{role:"menuitem",tabIndex:0,onClick:f=>o(f,u,m),className:Y("draggable-container",{dragging:g.isDragging}),ref:p.innerRef,...p.draggableProps,children:h("div",{className:"conditional-formatting-list-item",children:T("div",{className:"formatting-item",children:[h("div",{className:"rule-icon",children:h("span",{className:"rule-icon-bg",style:{backgroundColor:$r(u.config.style),color:Gr(u.config.style)},children:u.type===Un.ROWS?"row":"col"})}),h("div",{className:"rule-title",children:gv(u.config)}),h(U,{kind:"ghost",className:"ml-1 px-2",onClick:f=>r(f,u,m),icon:sn,tooltip:"Delete rule"}),T("button",{type:"button",className:"btn btn-link btn-link-icon px-2 btn-drag-handle",onClick:l,...p.dragHandleProps,children:[h(ut,{children:"Drag to re-order"}),h(Z,{icon:el})]})]})})})},`${m}-${u.type}`)),d.placeholder]})})}),h("hr",{}),h(U,{kind:"ghost",onClick:s,icon:As,children:"Add New Rule"})]})}const Si=J.module("ConditionEditor"),Cv=()=>{},Sv=[We.IS_EQUAL,We.IS_NOT_EQUAL,We.IS_BETWEEN,We.GREATER_THAN,We.GREATER_THAN_OR_EQUAL,We.LESS_THAN,We.LESS_THAN_OR_EQUAL,We.IS_NULL,We.IS_NOT_NULL].map(t=>h("option",{value:t,children:Nw(t)},t)),bv=[Qt.IS_EXACTLY,Qt.IS_NOT_EXACTLY,Qt.CONTAINS,Qt.DOES_NOT_CONTAIN,Qt.STARTS_WITH,Qt.ENDS_WITH,Qt.IS_NULL,Qt.IS_NOT_NULL].map(t=>h("option",{value:t,children:_w(t)},t)),wv=[Lt.IS_EXACTLY,Lt.IS_NOT_EXACTLY,Lt.IS_BEFORE,Lt.IS_BEFORE_OR_EQUAL,Lt.IS_AFTER,Lt.IS_AFTER_OR_EQUAL,Lt.IS_NULL,Lt.IS_NOT_NULL].map(t=>h("option",{value:t,children:Mw(t)},t)),Tv=[Co.IS_TRUE,Co.IS_FALSE,Co.IS_NULL,Co.IS_NOT_NULL].map(t=>h("option",{value:t,children:kw(t)},t)),vv=[ni.IS_EQUAL,ni.IS_NOT_EQUAL,ni.IS_NULL,ni.IS_NOT_NULL].map(t=>h("option",{value:t,children:xw(t)},t));function Ev(t,e,n,s){return t===We.IS_NULL||t===We.IS_NOT_NULL||t===We.IS_BETWEEN&&n!=null&&n!==""&&!Number.isNaN(Number.parseFloat(n))&&s!=null&&s!==""&&!Number.isNaN(Number.parseFloat(s))||t!==We.IS_BETWEEN&&e!==void 0&&e!==""&&!Number.isNaN(Number.parseFloat(e))}function yv(t,e,n,s,i,o,r){switch(t){case We.IS_EQUAL:case We.IS_NOT_EQUAL:case We.GREATER_THAN:case We.GREATER_THAN_OR_EQUAL:case We.LESS_THAN:case We.LESS_THAN_OR_EQUAL:return h("input",{type:"number",className:"form-control",placeholder:"Enter value",value:i??"",onChange:e});case We.IS_BETWEEN:return T("div",{className:"d-flex flex-row",children:[h("input",{type:"number",className:"form-control d-flex mr-2",placeholder:"Start value",value:o??"",onChange:n}),h("input",{type:"number",className:"form-control d-flex",placeholder:"End value",value:r??"",onChange:s})]});case We.IS_NULL:case We.IS_NOT_NULL:return null}}function Rv(t,e,n){switch(t){case Qt.IS_NULL:case Qt.IS_NOT_NULL:return null;default:return h("input",{type:"text",className:"form-control",placeholder:"Enter value",value:n??"",onChange:e})}}function Iv(t,e,n){switch(t){case Lt.IS_NULL:case Lt.IS_NOT_NULL:return null;default:return h("input",{type:"text",className:"form-control",placeholder:"Enter value",value:n??"",onChange:e})}}function Fv(){return null}function Dv(t,e,n){switch(t){case ni.IS_NULL:case ni.IS_NOT_NULL:return null;default:return h("input",{type:"text",className:"form-control",maxLength:1,placeholder:"Enter value",value:n??"",onChange:e})}}function Im(t){const{column:e,config:n,onChange:s=Cv}=t,i=e.type,[o,r]=b.exports.useState(i),[l,a]=b.exports.useState(n.condition),[d,c]=b.exports.useState(n.value),[u,m]=b.exports.useState(n.start),[p,g]=b.exports.useState(n.end);i!==o&&(a(tm(i)),c(void 0),m(void 0),g(void 0),r(i));const f=b.exports.useMemo(()=>{if(i===void 0)return[];if(_.isNumberType(i))return Sv;if(_.isCharType(i))return vv;if(_.isStringType(i))return bv;if(_.isDateType(i))return wv;if(_.isBooleanType(i))return Tv},[i]),C=b.exports.useCallback(E=>{const{value:R}=E.target;Si.debug("handleConditionChange",R),a(R)},[]),S=b.exports.useCallback(E=>{const{value:R}=E.target;Si.debug("handleValueChange",R),c(R)},[]),w=b.exports.useCallback(E=>{const{value:R}=E.target;Si.debug("handleStartValueChange",R),m(R)},[]),v=b.exports.useCallback(E=>{const{value:R}=E.target;Si.debug("handleEndValueChange",R),g(R)},[]);b.exports.useEffect(function(){let R=!0;l===void 0&&(Si.debug("Unable to create formatting rule. Condition is not selected."),R=!1),_.isNumberType(e.type)&&!Ev(l,d,u,p)&&(Si.debug("Unable to create formatting rule. Invalid value",d),R=!1),s({condition:l,value:d,start:u,end:p},R)},[s,e.type,l,d,u,p]);const y=b.exports.useMemo(()=>{if(i===void 0)return null;if(_.isNumberType(i))return yv(l,S,w,v,d,u,p);if(_.isCharType(i))return Dv(l,S,d);if(_.isStringType(i))return Rv(l,S,d);if(_.isDateType(i))return Iv(l,S,d);if(_.isBooleanType(i))return Fv()},[i,l,d,u,p,S,w,v]);return T("div",{className:"condition-editor mb-2",children:[h("select",{value:l,id:"condition-select",className:"custom-select mb-2",onChange:C,children:f}),y]})}const Nv=J.module("StyleEditor"),_v="#fcfcfa",Mv="#f0f0ee",kv="#1a171a",xv=200,Ov=()=>{};function Fm(t){const{config:e,onChange:n=Ov}=t,[s,i]=b.exports.useState(e.type),[o,r]=b.exports.useState(e.customConfig?.background??_v),[l,a]=b.exports.useState(!1),[d,c]=b.exports.useState(xv),u=b.exports.useRef(null),m=b.exports.useCallback(v=>{const{value:y}=v.target;Nv.debug("handleBackgroundChange",y),r(y)},[]),p=b.exports.useCallback(()=>{l&&a(!1)},[l]),g=b.exports.useCallback(()=>{l||C(),a(!l)},[l]),f=b.exports.useMemo(()=>[Nn.NO_FORMATTING,Nn.POSITIVE,Nn.NEGATIVE,Nn.WARN,Nn.NEUTRAL,Nn.ACCENT_1,Nn.ACCENT_2,Nn.CUSTOM],[]);function C(){u.current&&c(u.current.getBoundingClientRect().width)}b.exports.useEffect(function(){n({type:s,customConfig:{color:ol.isDark(o)?Mv:kv,background:o}})},[n,s,o]);const S=b.exports.useCallback(()=>{const v=[];for(let y=0;y<f.length;y+=1){const E=f[y],R=`option-${y}-${E}`;v.push(T(U,{kind:"inline",className:"style-option-btn",onClick:()=>{i(E),a(!1)},style:{color:Gr({type:E}),background:$r({type:E})},children:[E===s&&h(Z,{icon:ss,className:"mr-2"}),E!==s&&h("span",{className:"mr-4"}),_c(E)]},R))}return v},[f,s]),w=b.exports.useCallback(()=>h("div",{className:"style-menu-container",role:"presentation",style:{width:d},children:h("div",{className:"style-options",children:S()})}),[d,S]);return T("div",{className:"style-editor",children:[T("div",{className:"mb-2",ref:u,children:[h("label",{className:"mb-0",children:"Style"}),T(U,{kind:"inline",className:"cs-dropdown",style:{color:Gr({type:s}),background:$r({type:s})},onClick:g,children:[_c(s),h("span",{children:h(Z,{icon:xg,className:"cs-caret"})}),h(ns,{isShown:l,actions:{menuElement:w()},popperOptions:{placement:"bottom-start"},popperClassName:"style-dropdown-menu",onMenuClosed:p,menuStyle:{maxWidth:"100rem"}})]})]}),s===Nn.CUSTOM&&T("div",{className:"mb-2",children:[h("label",{className:"mb-0",children:"Background"}),h("input",{type:"color",value:o,className:"custom-select color-select",onChange:m})]})]})}const lo=J.module("ColumnFormatEditor"),Av=()=>{};function Lv(t){const{type:e,name:n}=t[0];return{column:{type:e,name:n},style:sm(),...wl(e)}}function Pv(t){const{columns:e,config:n=Lv(e),onChange:s=Av}=t,[i,o]=b.exports.useState(e.find(C=>C.name===n.column.name&&C.type===n.column.type)??e[0]),[r,l]=b.exports.useState(nm(n)),[a,d]=b.exports.useState(!1),[c,u]=b.exports.useState(n.style),m=b.exports.useCallback(C=>{const S=e.find(({name:w})=>w===C);S!==void 0?(o(S),i.type!==S.type&&(l(wl(S.type)),d(!1))):lo.error(`Column ${C} not found.`)},[e,i]),p=b.exports.useCallback((C,S)=>{lo.debug("handleConditionChange",C,S),l(C),d(S)},[]),g=b.exports.useCallback(C=>{lo.debug("handleStyleChange",C),u(C)},[]);b.exports.useEffect(function(){if(i===void 0){lo.debug("Column is not selected, skip update.");return}if(c===void 0){lo.debug("Style is not selected, skip update.");return}const{type:S,name:w}=i;s({column:{type:S,name:w},style:c,...r},a)},[s,i,c,r,a]);const f=e.map(({name:C})=>({title:C,value:C}));return T("div",{className:"conditional-rule-editor form",children:[T("div",{className:"mb-2",children:[h("label",{className:"mb-0",children:"Format Cell If"}),h(Ih,{defaultValue:i?.name,options:f,inputPlaceholder:"Select a column",spellCheck:!1,onChange:m,searchPlaceholder:"Filter columns"})]}),i!==void 0&&T(be,{children:[h(Im,{column:i,config:r,onChange:p}),h(Fm,{config:c,onChange:g})]})]})}const ao=J.module("RowFormatEditor"),Hv=()=>{};function Uv(t){const{type:e,name:n}=t[0];return{column:{type:e,name:n},style:sm(),...wl(e)}}function Vv(t){const{columns:e,config:n=Uv(e),onChange:s=Hv}=t,[i,o]=b.exports.useState(e.find(C=>C.name===n.column.name&&C.type===n.column.type)??e[0]),[r,l]=b.exports.useState(nm(n)),[a,d]=b.exports.useState(!1),[c,u]=b.exports.useState(n.style),m=b.exports.useCallback(C=>{const S=e.find(({name:w})=>w===C);S!==void 0?(o(S),i.type!==S.type&&(l(wl(S.type)),d(!1))):ao.error(`Column ${C} not found.`)},[e,i]),p=b.exports.useCallback((C,S)=>{ao.debug("handleConditionChange",C,S),l(C),d(S)},[]),g=b.exports.useCallback(C=>{ao.debug("handleStyleChange",C),u(C)},[]);b.exports.useEffect(function(){if(i===void 0){ao.debug("Column is not selected, skip update.");return}if(c===void 0){ao.debug("Style is not selected, skip update.");return}const{type:S,name:w}=i;s({column:{type:S,name:w},style:c,...r},a)},[s,i,c,r,a]);const f=e.map(({name:C})=>({title:C,value:C}));return T("div",{className:"conditional-rule-editor form",children:[T("div",{className:"mb-2",children:[h("label",{className:"mb-0",children:"Format Row If"}),h(Ih,{defaultValue:i?.name,options:f,inputPlaceholder:"Select a column",spellCheck:!1,onChange:m,searchPlaceholder:"Filter columns"})]}),i!==void 0&&T(be,{children:[h(Im,{column:i,config:r,onChange:p}),h(Fm,{config:c,onChange:g})]})]})}const Jl=J.module("ConditionalFormatEditor"),ea=()=>{};function Bv(t){switch(t){case Un.CONDITIONAL:return h(xT,{});case Un.ROWS:return h(OT,{})}}function $v(t){switch(t){case Un.CONDITIONAL:return"Conditional";case Un.ROWS:return"Rows"}}const Vc=[Un.CONDITIONAL,Un.ROWS];function Gv(t){const{columns:e,onSave:n=ea,onUpdate:s=ea,onCancel:i=ea,rule:o}=t,r=e.filter(Yw),[l,a]=b.exports.useState(o?.type??Vc[0]),[d,c]=b.exports.useState(o),[u,m]=b.exports.useState(!1),p=b.exports.useCallback(()=>{i()},[i]),g=b.exports.useCallback(()=>{if(d===void 0){Jl.error("Rule is not defined.");return}n(d)},[n,d]),f=b.exports.useCallback(S=>{Jl.debug("handleFormatterChange",S),a(S)},[]),C=b.exports.useCallback((S,w)=>{Jl.debug("handleRuleChange",S,w,l);const v={type:l,config:S};c(v),m(w),s(w?v:void 0)},[s,l]);return T("div",{className:"conditional-format-editor form",children:[T("div",{className:"mb-2",children:[h("label",{className:"mb-0",htmlFor:"formatter-select",children:"Select Formatter"}),h("div",{className:"formatter-list",children:Vc.map((S,w)=>h("div",{className:"formatter-type",children:T("button",{type:"button",className:Y("btn","btn-icon","btn-formatter-type",{active:S===l}),"data-index":w,onClick:()=>f(S),children:[Bv(S),$v(S)]})},S))})]}),l===Un.CONDITIONAL&&h(Pv,{columns:r,config:d?.config,onChange:C}),l===Un.ROWS&&h(Vv,{columns:r,config:d?.config,onChange:C}),h("hr",{}),T("div",{className:"d-flex justify-content-end my-3",children:[h(U,{kind:"secondary",onClick:p,className:"mr-2",children:"Cancel"}),h(U,{kind:"primary",onClick:g,disabled:d===void 0||!u,children:"Done"})]})]})}function Wv({text:t,isOpen:e,onClose:n}){const[s,i]=b.exports.useState(!1),[o,r]=b.exports.useState(0),[l,a]=b.exports.useState(!1),[d,c]=b.exports.useState(!1),[u,m]=b.exports.useState(!1),p=b.exports.useRef();b.exports.useEffect(function(){if(!!e){try{JSON.parse(t),m(!0)}catch{m(!1)}c(!1)}},[e,t]),b.exports.useEffect(function(){p.current&&p.current.layout()},[o]),b.exports.useEffect(function(){p.current&&p.current.updateOptions({lineNumbers:l?"on":"off"})},[l]);function g(){a(!l)}function f(){const v=p.current?.getModel();!u||!v||(d?(v.setValue(t),c(!1)):(v.setValue(JSON.stringify(JSON.parse(t),void 0,2)),c(!0)),C())}function C(){const v=p.current;!v||a((v.getModel()?.getLineCount()??0)>1)}function S(){s&&(p.current=void 0,n())}function w(v){p.current=v,r(v.getContentHeight()),v.onDidContentSizeChange(({contentHeight:y})=>r(y)),C()}return!e&&!s?null:T(nl,{isOpen:e,centered:!0,keyboard:!0,toggle:S,onOpened:()=>i(!0),onClosed:()=>{i(!1),r(0)},className:"theme-bg-dark cell-overflow-modal",size:"xl",children:[T(sl,{toggle:n,children:[h("h5",{className:"overflow-modal-title",children:"Cell Contents"}),h(ll,{kind:"inline",tooltip:"Copy cell contents",copy:p.current?.getValue()??t}),h(U,{kind:"inline",active:l,icon:Og,tooltip:"Toggle line numbers",onClick:g}),u&&h(U,{kind:"inline",icon:Ag,active:d,tooltip:"Format as JSON",onClick:f})]}),h(il,{style:{height:o},children:h(hl,{onEditorInitialized:w,settings:{value:t,readOnly:!0,wordWrap:"on",language:u?"typescript":"plaintext",folding:u,padding:{bottom:16},lineNumbers:l?"on":"off",overviewRulerLanes:0,renderLineHighlight:"none",find:{seedSearchStringFromSelection:"never"}}})})]})}function zv(t){return t.model!==void 0}const qv="###,##0";function Yv({gotoRow:t,gotoRowError:e,gotoValueError:n,onGotoRowSubmit:s,isShown:i,onEntering:o,onEntered:r,onExiting:l,onExited:a,model:d,onGotoRowNumberChanged:c,onClose:u,gotoValueSelectedColumnName:m,gotoValue:p,onGotoValueSelectedColumnNameChanged:g,onGotoValueSelectedFilterChanged:f,onGotoValueChanged:C,onGotoValueSubmit:S}){const w=b.exports.useRef(null),v=b.exports.useRef(null),[y,E]=b.exports.useState(!1);let R=[];zv(d)&&d.table!==void 0&&({columns:R}=d.table);const F="Row number",{rowCount:D}=d,N=O=>{O.key==="Enter"&&(O.stopPropagation(),O.preventDefault(),S())},P=d.getColumnIndexByName(m);k(P);const A=R[P]?.type,q=_.getNormalizedType(A),B=O=>{C(O??"")},K=()=>{y&&document.activeElement!==w.current?w.current?.select():!y&&document.activeElement!==v.current&&v.current?.select()};b.exports.useEffect(K,[y,t,p]);const x=()=>{switch(q){case _.dataType.DECIMAL:case _.dataType.INT:return h("div",{className:"goto-row-input",children:h("input",{ref:v,type:"number",className:Y("form-control",{"is-invalid":n!==""}),onKeyDown:N,placeholder:"value",onChange:O=>B(O.target.value),value:p})});case _.dataType.DATETIME:return h("div",{className:"goto-value-date-time-input",children:h(Pg,{className:Y("form-control","goto-value-date-time-input",{"is-invalid":n!==""}),onChange:B})});case _.dataType.STRING:return T(be,{children:[h("div",{className:"goto-row-input",children:T("select",{className:"custom-select",onChange:O=>{f(O.target.value)},children:[h("option",{value:$.eq,children:"Equals"},$.eq),h("option",{value:$.contains,children:"Contains"},$.contains),h("option",{value:$.eqIgnoreCase,children:"EqIgnoreCase"},$.eqIgnoreCase)]})}),h("div",{className:"goto-row-input",children:h("input",{ref:v,className:Y("form-control",{"is-invalid":n!==""}),onKeyDown:N,placeholder:"value",onChange:O=>B(O.target.value),value:p})})]});case _.dataType.BOOLEAN:return h("div",{className:"goto-row-input",children:T("select",{className:"custom-select",onChange:O=>{B(O.target.value)},value:p,children:[h("option",{value:"true",children:"true"},"true"),h("option",{value:"false",children:"false"},"false")]})});default:return h("div",{className:"goto-row-input",children:h("input",{ref:v,className:"form-control",onKeyDown:N,placeholder:"value",onChange:O=>B(O.target.value),value:p})})}};return h(Tl,{isShown:i,className:Y("goto-row"),onEntering:o,onEntered:()=>{r(),K()},onExiting:l,onExited:a,children:T(be,{children:[T("div",{className:"goto-row-row",children:[T("div",{className:Y("goto-row-wrapper",{"is-inactive":!y}),onClick:()=>E(!0),onFocus:()=>E(!0),role:"group",children:[h("div",{className:"goto-row-text",children:"Go to row"}),h("div",{className:"goto-row-input",children:h("input",{ref:w,type:"number",onKeyDown:O=>{O.key==="Enter"&&(O.stopPropagation(),O.preventDefault(),s())},className:Y("form-control",{"is-invalid":e!==""}),placeholder:F,onChange:O=>{c(O)},value:t})}),T("div",{className:"goto-row-text",children:["of ",dh.i18n.NumberFormat.format(qv,D)]}),e&&h("div",{className:"text-danger",children:e})]}),h("div",{className:"goto-row-close",children:h(U,{kind:"ghost",onClick:u,children:h(Z,{icon:Ui,style:{marginRight:"0"}})})})]}),d.isSeekRowAvailable&&h("div",{className:"goto-row-row",children:T("div",{className:Y("goto-row-wrapper",{"is-inactive":y}),onClick:()=>E(!1),onFocus:()=>E(!1),role:"group",children:[h("div",{className:"goto-row-text",children:"Go to value"}),h("div",{className:"goto-row-input",children:h("select",{className:"custom-select",onChange:O=>{const G=O.target.value;g(G)},value:m,children:R.map(O=>h("option",{value:O.name,children:O.name},O.name))})}),x(),T("div",{children:[h(U,{kind:"ghost",disabled:p==="",onClick:()=>{S(!0)},children:h(Z,{icon:Fh})}),h(U,{kind:"ghost",disabled:p==="",onClick:()=>{S(!1)},children:h(Z,{icon:Lg})})]}),n&&h("div",{className:"text-danger",children:n})]})})]})})}const fe=J.module("IrisGrid"),Kv=500,Xv=250,jv=250,Qv=250,Dm=Object.freeze({aggregations:He,showOnTop:!1}),Zv="yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS z";function Bc({advancedFilters:t,aggregationSettings:e,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a}){return t.size===0&&e.aggregations.length===0&&n.length===0&&s.size===0&&i===_.REVERSE_TYPE.NONE&&o==null&&r==null&&l.length===0&&a.length===0}const Is=class extends b.exports.Component{constructor(t){super(t),this.getAdvancedMenuOpenedHandler=Ie(x=>this.handleAdvancedMenuOpened.bind(this,x),{max:100}),this.getCachedAdvancedFilterMenuActions=Ie((x,O,G,ee,ne)=>h(ud,{model:x,column:O,onFilterChange:this.handleAdvancedFilterChange,onSortChange:this.handleAdvancedFilterSortChange,onDone:this.handleAdvancedFilterDone,options:G,sortDirection:ee,formatter:ne}),{max:50}),this.getCachedOptionItems=Ie((x,O,G,ee,ne,V,W,X,se,ce,Q,he,Se,Re,et,yt)=>{const je=[];return x&&je.push({type:xe.CHART_BUILDER,title:"Chart Builder",icon:Hg}),je.push({type:xe.VISIBILITY_ORDERING_BUILDER,title:"Hide, Group, and Order Columns",icon:$a}),G&&je.push({type:xe.CONDITIONAL_FORMATTING,title:"Conditional Formatting",icon:Mo}),O&&je.push({type:xe.CUSTOM_COLUMN_BUILDER,title:"Custom Columns",icon:Ug}),ee&&je.push({type:xe.ROLLUP_ROWS,title:"Rollup Rows",icon:Dh}),ne&&je.push({type:xe.AGGREGATIONS,title:"Aggregate Columns",icon:Vg}),V&&je.push({type:xe.SELECT_DISTINCT,title:"Select Distinct Values",icon:Bg}),W&&Se&&je.push({type:xe.TABLE_EXPORTER,title:"Download CSV",icon:$g}),yt&&je.push({type:xe.ADVANCED_SETTINGS,title:"Advanced Settings",icon:Gg}),je.push({type:xe.QUICK_FILTERS,title:"Quick Filters",subtitle:X.shortcut.getDisplayText(),icon:Mr,isOn:Q,onChange:X.action}),Re&&je.push({type:xe.SEARCH_BAR,title:"Search Bar",subtitle:se.shortcut.getDisplayText(),icon:Wg,isOn:he,onChange:se.action}),je.push({type:xe.GOTO,title:"Go to",subtitle:ce.shortcut.getDisplayText(),icon:zg,isOn:et,onChange:ce.action}),Object.freeze(je)},{max:1}),this.getCachedHiddenColumns=Ie((x,O)=>te.getHiddenColumns(new Map([...x.initialColumnWidths,...O])),{max:1}),this.getAggregationMap=Ie((x,O)=>{const G={};return O.forEach(({operation:ee,selected:ne,invert:V})=>{G[ee]=_s.getOperationColumnNames(x,ee,ne,V)}),G}),this.getOperationMap=Ie((x,O)=>{const G={};return O.filter(ee=>!_s.isRollupOperation(ee.operation)).forEach(({operation:ee,selected:ne,invert:V})=>{_s.getOperationColumnNames(x,ee,ne,V).forEach(W=>{const X=[...G[W]??[],ee];G[W]=Object.freeze(X)})}),G}),this.getOperationOrder=Ie(x=>x.map(O=>O.operation).filter(O=>!_s.isRollupOperation(O))),this.getCachedFormatColumns=Ie((x,O)=>qw(x,O)),this.getCachedModelColumns=Ie((x,O)=>x.columns),this.getCachedPreviewFormatColumns=Ie((x,O,G,ee)=>{if(fe.debug("getCachedPreviewFormatColumns",O,G,ee),G!==void 0&&ee!==void 0){const ne=[...O];return ne[ee]=G,this.getCachedFormatColumns(x,ne)}return this.getCachedFormatColumns(x,O)}),this.getModelRollupConfig=Ie((x,O,G)=>te.getModelRollupConfig(x,O,G)),this.getModelTotalsConfig=Ie((x,O,G)=>{const{aggregations:ee,showOnTop:ne}=G;if((O?.columns?.length??0)>0||(ee?.length??0)===0)return null;const V=this.getOperationMap(x,ee),W=this.getOperationOrder(ee);return{operationMap:V,operationOrder:W,showOnTop:ne}}),this.getCachedStateOverride=Ie((x,O,G,ee,ne,V,W,X,se,ce)=>({hoverSelectColumn:x,isFilterBarShown:O,isSelectingColumn:G,loadingScrimProgress:ee,quickFilters:ne,advancedFilters:V,sorts:W,reverseType:X,rollupConfig:se,isMenuShown:ce}),{max:1}),this.getCachedFilter=Ie((x,O,G,ee,ne)=>[...x??[],...ee??[],...te.getFiltersFromFilterMap(O),...te.getFiltersFromFilterMap(G),...ne!==void 0?[ne]:[]],{max:1}),this.getCachedTheme=Ie((x,O,G)=>({...cm,...x,autoSelectRow:!O,rowFooterWidth:G>0?x.rowFooterWidth:0}),{max:1}),this.getAlwaysFetchColumns=Ie((x,O,G,ee,ne,V)=>{const W=[];for(let se=0;se<ee;se+=1)W.push(O[z.getModelIndex(se,G)].name);for(let se=0;se<ne;se+=1)W.push(O[z.getModelIndex(O.length-1-se,G)].name);if(V)for(let se=V[0];se<=V[1];se+=1)W.push(O[z.getModelIndex(se,G)].name);const X=new Set([...x,...W]);return Object.freeze([...X])}),this.updateSearchFilter=Je((x,O,G,ee)=>{const ne=mr.createSearchFilter(x,O,G,ee);this.setState({searchFilter:ne})},Xv),this.handleConditionalFormatEditorUpdate=Je(x=>{this.setState({conditionalFormatPreview:x})},Qv),this.handleDownloadProgressUpdate=Ln((x,O)=>{const{tableDownloadStatus:G}=this.state;G===Zt.DOWNLOAD_STATUS.DOWNLOADING&&this.setState({tableDownloadProgress:x,tableDownloadEstimatedTime:O})},Kv),this.getOverflowButtonTooltip=Ie(x=>{if(x==null)return null;const O={position:"absolute",...x,pointerEvents:"none"};return h("div",{style:O,children:h(ut,{options:{placement:"left",modifiers:{flip:{behavior:["left","right"]}}},ref:this.handleTooltipRef,children:"View full contents"},Date.now())})}),this.getExpandCellTooltip=Ie(x=>{if(x==null)return null;const{expandTooltipDisplayValue:O}=this.state,G={position:"absolute",...x,pointerEvents:"none"};return h("div",{style:G,children:h(ut,{options:{placement:"bottom-start"},ref:this.handleTooltipRef,children:T("div",{style:{textAlign:"left"},children:["Click to ",O," row",h("br",{}),Pn.isMacPlatform()?"\u2318":"Ctrl+","Click to expand row and all children"]})},Date.now())})}),this.handleGotoValueChanged=x=>{this.setState({gotoValue:x}),this.debouncedSeekRow(x)},this.debouncedSeekRow=Je(x=>{this.seekRow(x)},jv),this.handleAdvancedFilterChange=this.handleAdvancedFilterChange.bind(this),this.handleAdvancedFilterSortChange=this.handleAdvancedFilterSortChange.bind(this),this.handleAdvancedFilterDone=this.handleAdvancedFilterDone.bind(this),this.handleAdvancedMenuOpened=this.handleAdvancedMenuOpened.bind(this),this.handleGotoRowOpened=this.handleGotoRowOpened.bind(this),this.handleGotoRowClosed=this.handleGotoRowClosed.bind(this),this.handleAdvancedMenuClosed=this.handleAdvancedMenuClosed.bind(this),this.handleAggregationChange=this.handleAggregationChange.bind(this),this.handleAggregationsChange=this.handleAggregationsChange.bind(this),this.handleAggregationEdit=this.handleAggregationEdit.bind(this),this.handleAnimationLoop=this.handleAnimationLoop.bind(this),this.handleAnimationStart=this.handleAnimationStart.bind(this),this.handleAnimationEnd=this.handleAnimationEnd.bind(this),this.handleChartChange=this.handleChartChange.bind(this),this.handleChartCreate=this.handleChartCreate.bind(this),this.handleGridError=this.handleGridError.bind(this),this.handleFilterBarChange=this.handleFilterBarChange.bind(this),this.handleFilterBarDone=this.handleFilterBarDone.bind(this),this.handleFilterBarTab=this.handleFilterBarTab.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleMenu=this.handleMenu.bind(this),this.handleMenuClose=this.handleMenuClose.bind(this),this.handleMenuSelect=this.handleMenuSelect.bind(this),this.handleMenuBack=this.handleMenuBack.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.handleSelectionChanged=this.handleSelectionChanged.bind(this),this.handleMovedColumnsChanged=this.handleMovedColumnsChanged.bind(this),this.handleHeaderGroupsChanged=this.handleHeaderGroupsChanged.bind(this),this.handleUpdate=this.handleUpdate.bind(this),this.handleTooltipRef=this.handleTooltipRef.bind(this),this.handleViewChanged=this.handleViewChanged.bind(this),this.handleFormatSelection=this.handleFormatSelection.bind(this),this.handleConditionalFormatCreate=this.handleConditionalFormatCreate.bind(this),this.handleConditionalFormatEdit=this.handleConditionalFormatEdit.bind(this),this.handleConditionalFormatsChange=this.handleConditionalFormatsChange.bind(this),this.handleConditionalFormatEditorSave=this.handleConditionalFormatEditorSave.bind(this),this.handleConditionalFormatEditorCancel=this.handleConditionalFormatEditorCancel.bind(this),this.handleUpdateCustomColumns=this.handleUpdateCustomColumns.bind(this),this.handleCustomColumnsChanged=this.handleCustomColumnsChanged.bind(this),this.handleSelectDistinctChanged=this.handleSelectDistinctChanged.bind(this),this.handlePendingDataUpdated=this.handlePendingDataUpdated.bind(this),this.handlePendingCommitClicked=this.handlePendingCommitClicked.bind(this),this.handlePendingDiscardClicked=this.handlePendingDiscardClicked.bind(this),this.handleGotoRowSelectedRowNumberSubmit=this.handleGotoRowSelectedRowNumberSubmit.bind(this),this.focusRowInGrid=this.focusRowInGrid.bind(this),this.handleDownloadTable=this.handleDownloadTable.bind(this),this.handleDownloadTableStart=this.handleDownloadTableStart.bind(this),this.handleCancelDownloadTable=this.handleCancelDownloadTable.bind(this),this.handleDownloadCanceled=this.handleDownloadCanceled.bind(this),this.handleDownloadCompleted=this.handleDownloadCompleted.bind(this),this.handlePartitionAppend=this.handlePartitionAppend.bind(this),this.handlePartitionChange=this.handlePartitionChange.bind(this),this.handlePartitionFetchAll=this.handlePartitionFetchAll.bind(this),this.handlePartitionDone=this.handlePartitionDone.bind(this),this.handleColumnVisibilityChanged=this.handleColumnVisibilityChanged.bind(this),this.handleColumnVisibilityReset=this.handleColumnVisibilityReset.bind(this),this.handleCrossColumnSearch=this.handleCrossColumnSearch.bind(this),this.handleRollupChange=this.handleRollupChange.bind(this),this.handleOverflowClose=this.handleOverflowClose.bind(this),this.getColumnBoundingRect=this.getColumnBoundingRect.bind(this),this.handleGotoRowSelectedRowNumberChanged=this.handleGotoRowSelectedRowNumberChanged.bind(this),this.handleGotoValueSelectedColumnNameChanged=this.handleGotoValueSelectedColumnNameChanged.bind(this),this.handleGotoValueSelectedFilterChanged=this.handleGotoValueSelectedFilterChanged.bind(this),this.handleGotoValueChanged=this.handleGotoValueChanged.bind(this),this.handleGotoValueSubmitted=this.handleGotoValueSubmitted.bind(this),this.grid=null,this.gridWrapper=null,this.lastLoadedConfig=null,this.pending=new ds,this.globalColumnFormats=He,this.decimalFormatOptions={},this.integerFormatOptions={},this.truncateNumbersWithPound=!1,this.renderer=new To,this.tableSaver=null,this.crossColumnRef=de.createRef(),this.isAnimating=!1,this.filterInputRef=de.createRef(),this.toggleFilterBarAction={action:()=>this.toggleFilterBar(),shortcut:en.TABLE.TOGGLE_QUICK_FILTER},this.toggleSearchBarAction={action:()=>this.toggleSearchBar(),shortcut:en.TABLE.TOGGLE_SEARCH},this.toggleGotoRowAction={action:()=>this.toggleGotoRow(),shortcut:en.TABLE.GOTO_ROW},this.discardAction={action:()=>{const{model:x}=this.props;tt(x)&&x.isEditable&&x.pendingDataMap.size>0&&this.discardPending().catch(fe.error)},shortcut:en.INPUT_TABLE.DISCARD},this.commitAction={action:()=>{const{model:x}=this.props;tt(x)&&x.isEditable&&x.pendingDataMap.size>0&&x.pendingDataErrors.size===0&&this.commitPending().catch(fe.error)},shortcut:en.INPUT_TABLE.COMMIT},this.contextActions=[this.toggleFilterBarAction,this.toggleSearchBarAction,this.toggleGotoRowAction,this.discardAction,this.commitAction];const{aggregationSettings:e,conditionalFormats:n,customColumnFormatMap:s,isFilterBarShown:i,isSelectingPartition:o,model:r,movedColumns:l,movedRows:a,partition:d,partitionColumn:c,rollupConfig:u,userColumnWidths:m,userRowHeights:p,showSearchBar:g,searchValue:f,selectedSearchColumns:C,invertSearchColumns:S,advancedFilters:w,quickFilters:v,selectDistinctColumns:y,pendingDataMap:E,canCopy:R,frozenColumns:F,columnHeaderGroups:D}=t,N=[new oT(this),new rT(this)];R&&N.push(new nT(this));const P=[new lT(this),new mT(this),new aT(this),new dT(this),new pT(this),new uT(this),new Bn(this),new hT(this),new gT(this)],H=l.length>0?l:r.initialMovedColumns,A=a.length>0?a:r.initialMovedRows,q=new ST({userColumnWidths:new Map(m),userRowHeights:new Map(p),movedColumns:H,initialColumnWidths:new Map(r?.layoutHints?.hiddenColumns?.map(x=>[r.getColumnIndexByName(x),0]))}),B=C??[],K=mr.createSearchFilter(f,B,r.columns,S);this.state={isFilterBarShown:i,isSelectingPartition:o,focusedFilterBarColumn:null,metricCalculator:q,metrics:void 0,keyHandlers:N,mouseHandlers:P,partition:d,partitionColumn:c,partitionTable:null,partitionFilters:[],quickFilters:v?new Map(v):new Map,advancedFilters:new Map(w),shownAdvancedFilter:null,hoverAdvancedFilter:null,sorts:[],reverseType:_.REVERSE_TYPE.NONE,customColumns:[],selectDistinctColumns:y,selectedRanges:[],copyOperation:null,loadingText:null,loadingScrimProgress:null,loadingSpinnerShown:!1,movedColumns:H,movedRows:A,shownColumnTooltip:null,formatter:new nn,isMenuShown:!1,customColumnFormatMap:new Map(s),conditionalFormats:n,conditionalFormatEditIndex:null,conditionalFormatPreview:void 0,hoverSelectColumn:null,isTableDownloading:!1,isReady:!1,tableDownloadStatus:"",tableDownloadProgress:0,tableDownloadEstimatedTime:0,showSearchBar:g,searchFilter:K,searchValue:f,selectedSearchColumns:B,invertSearchColumns:S,rollupConfig:u,rollupSelectedColumns:[],aggregationSettings:e,selectedAggregation:null,openOptions:[],pendingRowCount:0,pendingDataMap:E??new Map,pendingDataErrors:new Map,pendingSavePromise:null,pendingSaveError:null,toastMessage:null,frozenColumns:F,showOverflowModal:!1,overflowText:"",overflowButtonTooltipProps:null,expandCellTooltipProps:null,expandTooltipDisplayValue:"expand",isGotoShown:!1,gotoRow:"",gotoRowError:"",gotoValueError:"",gotoValueSelectedColumnName:r.columns[0].name,gotoValueSelectedFilter:$.eq,gotoValue:"",columnHeaderGroups:D??r.initialColumnHeaderGroups}}static makeQuickFilter(t,e,n){try{return _.makeQuickFilter(t,e,n)}catch(s){fe.error("Error creating quick filter",s)}return null}componentDidMount(){const{partitionColumn:t,model:e}=this.props,n=t??e.columns.find(s=>s.isPartitionColumn);e.isFilterRequired&&e.isValuesTableAvailable&&n!=null?this.loadPartitionsTable(n):this.initState(),this.startListening(e)}componentDidUpdate(t){const{inputFilters:e,isSelectingColumn:n,settings:s,model:i,customFilters:o,sorts:r}=this.props;i!==t.model&&(this.stopListening(t.model),this.startListening(i));const l=e!==t.inputFilters?e.filter(c=>!t.inputFilters.includes(c)):[];if(l.length>0){const{advancedSettings:c}=this.props,u=c.get(li.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS)??!1;u&&(this.clearGridInputField(),this.clearCrossColumSearch()),this.startLoading("Filtering...",!0),this.applyInputFilters(l,u)}n!==t.isSelectingColumn&&this.resetColumnSelection(),s!==t.settings&&this.updateFormatterSettings(s),o!==t.customFilters&&this.startLoading("Filtering...",!0),r!==t.sorts&&this.updateSorts(r);const{loadingScrimStartTime:a,loadingScrimFinishTime:d}=this;a!=null&&d!=null&&window.requestAnimationFrame(()=>{const c=Date.now(),u=c-a,m=d-a,p=Math.min(u/m,1);d<c&&(this.loadingScrimStartTime=void 0,this.loadingScrimFinishTime=void 0),this.setState(g=>g.loadingScrimProgress==null?(fe.debug2("Ignoring scrim update because loading cancelled."),null):{loadingScrimProgress:p})}),this.sendStateChange()}componentWillUnmount(){const{model:t}=this.props;this.stopListening(t),this.pending.cancel(),this.updateSearchFilter.cancel(),this.loadingTimer&&clearTimeout(this.loadingTimer),this.handleDownloadProgressUpdate.cancel(),this.animationFrame!==void 0&&cancelAnimationFrame(this.animationFrame)}getValueForCell(t,e,n=!1){const{model:s}=this.props,i=this.getModelColumn(t),o=this.getModelRow(e);if(n&&i!=null&&o!=null){const r=s.valueForCell(i,o);if(_.isDateType(s.columns[i].type)){const{formatter:l}=s;return I.i18n.DateTimeFormat.format(Zv,r,I.i18n.TimeZone.getTimeZone(l.timeZone))}return r}return n?null:i!=null&&o!=null?s.textForCell(i,o):""}getModelColumn(t){const{metrics:e}=this.state;k(e);const{modelColumns:n}=e;return n==null?null:t!=null?n.get(t):null}getModelRow(t){const{metrics:e}=this.state;k(e);const{modelRows:n}=e;return n==null?null:t!=null?n.get(t):null}getTheme(){const{model:t,theme:e}=this.props;return this.getCachedTheme(e,(tt(t)&&t.isEditable)??!1,t.floatingTopRowCount+t.floatingBottomRowCount)}getVisibleColumn(t){const{movedColumns:e}=this.state;return z.getVisibleIndex(t,e)}applyInputFilters(t,e=!1){const{model:n}=this.props,{advancedFilters:s,quickFilters:i}=this.state,o=e?new Map:new Map(s),r=e?new Map:new Map(i);let l=e&&s.size>0;t.forEach(({name:a,type:d,value:c})=>{const u=n.columns.findIndex(({name:m,type:p})=>m===a&&p===d);u>=0?(l=o.delete(u)||l,l=this.applyQuickFilter(u,c,r)||l):fe.error("Unable to find column for inputFilter",a,d,c)}),l&&this.setState({quickFilters:r,advancedFilters:o})}applyQuickFilter(t,e,n){const{model:s}=this.props,{formatter:i}=s,o=s.columns[t];if(e!=null&&`${e}`.trim().length>0){const r=n.get(t);if(r!=null){const{text:l}=r;if(l===e)return fe.debug2("Ignoring change to existing filter"),!1}return n.set(t,{text:e,filter:Is.makeQuickFilter(o,e,i.timeZone)}),!0}return n.delete(t)}setAdvancedFilterMap(t){this.setState({advancedFilters:t})}setAdvancedFilter(t,e,n){fe.debug("Setting advanced filter",t,e),this.startLoading("Filtering...",!0),this.setState(({advancedFilters:s})=>{const i=new Map(s);return e==null?i.delete(t):i.set(t,{filter:e,options:n}),{advancedFilters:i}})}setQuickFilter(t,e,n){fe.debug("Setting quick filter",t,e,n),this.startLoading("Filtering...",!0),this.setState(({quickFilters:s})=>{const i=new Map(s);return i.set(t,{filter:e,text:n}),{quickFilters:i}})}setFilterMap(t){fe.debug("setFilterMap",t);const{advancedSettings:e}=this.props;(e.get(li.LINK_CHANGE_CLEARS_ALL_FILTERS)??!1)&&this.clearAllFilters();const{model:s}=this.props;t.forEach(({columnType:i,filterList:o},r)=>{const l=s.columns.find(c=>c.name===r&&c.type===i);if(l==null)return;const a=s.getColumnIndexByName(l.name);k(a);const d=te.combineFiltersFromList(i,o);if(d.length===0)this.removeQuickFilter(a);else{const{formatter:c}=s;this.setQuickFilter(a,Is.makeQuickFilter(l,d,c.timeZone),`${d}`)}})}removeColumnFilter(t){this.startLoading("Filtering...",!0),this.setState(({advancedFilters:e,quickFilters:n})=>{const s=e?new Map(e):new Map,i=n?new Map(n):new Map;return i.delete(t),s.delete(t),{quickFilters:i,advancedFilters:s}})}removeQuickFilter(t){this.startLoading("Clearing Filter...",!0),this.setState(({quickFilters:e})=>{const n=new Map(e);return n.delete(t),{quickFilters:n}})}clearAllFilters(){fe.debug("Clearing all filters");const{advancedFilters:t,quickFilters:e,searchFilter:n}=this.state;e.size===0&&t.size===0&&n===null||(this.clearGridInputField(),this.startLoading("Clearing Filters...",!0),this.setState({quickFilters:new Map,advancedFilters:new Map,searchValue:"",searchFilter:void 0}))}clearCrossColumSearch(){fe.debug("Clearing cross-column search"),this.setState({searchValue:"",searchFilter:void 0})}clearGridInputField(){this.filterInputRef.current!=null&&this.filterInputRef.current.setValue("")}rebuildFilters(){fe.debug("Rebuilding filters");const{model:t}=this.props,{advancedFilters:e,quickFilters:n}=this.state,{columns:s,formatter:i}=t,o=new Map,r=new Map;e.forEach((l,a)=>{const{options:d}=l,c=s[a],u=_.makeAdvancedFilter(c,d,i.timeZone);o.set(a,{options:d,filter:u})}),n.forEach((l,a)=>{const{text:d}=l,c=s[a];r.set(a,{text:d,filter:Is.makeQuickFilter(c,d,i.timeZone)})}),this.startLoading("Rebuilding filters...",!0),this.setState({quickFilters:r,advancedFilters:o})}setFilters({quickFilters:t,advancedFilters:e}){this.setState({quickFilters:t,advancedFilters:e})}updateFormatterSettings(t,e=!0){const n=rs.getColumnFormats(t),s=rs.getDateTimeFormatterOptions(t),i=t?.defaultDecimalFormatOptions??{},o=t?.defaultIntegerFormatOptions??{},r=t?.truncateNumbersWithPound??!1,l=!ct(this.globalColumnFormats,n),a=!ct(this.dateTimeFormatterOptions,s),d=!ct(this.decimalFormatOptions,t?.defaultDecimalFormatOptions),c=!ct(this.integerFormatOptions,o),u=this.truncateNumbersWithPound!==r;(l||a||d||c||u)&&(this.globalColumnFormats=n,this.dateTimeFormatterOptions=s,this.decimalFormatOptions=i,this.integerFormatOptions=o,this.truncateNumbersWithPound=r,this.updateFormatter({},e),a&&e&&this.rebuildFilters())}updateFormatter(t,e=!0){const{customColumnFormatMap:n}=this.state,s={customColumnFormatMap:n,...t},i=[...this.globalColumnFormats??[],...s.customColumnFormatMap.values()],o=new nn(i,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions,this.truncateNumbersWithPound);fe.debug("updateFormatter",this.globalColumnFormats,i),this.setState({...s,formatter:o},()=>{e&&this.grid&&this.grid.forceUpdate()})}initFormatter(){const{settings:t}=this.props;this.updateFormatterSettings(t)}initState(){const{applyInputFiltersOnInit:t,inputFilters:e,sorts:n,model:s,reverseType:i,customColumns:o,searchValue:r,selectedSearchColumns:l,invertSearchColumns:a}=this.props,d=l??[],c=mr.createSearchFilter(r,d,s.columns,a);if(t){const u=e.filter(m=>m.value!=null);this.applyInputFilters(u)}this.setState({sorts:n,reverseType:i,customColumns:o,isReady:!0,searchFilter:c}),this.initFormatter()}async loadPartitionsTable(t){const{model:e}=this.props;this.setState({isSelectingPartition:!0});try{const n=await this.pending.add(e.valuesTable(t),r=>r.close()),s=n.columns[0],i=s.sort().desc();n.applySort([i]),n.setViewport(0,0,[s]);const o=await this.pending.add(n.getViewportData());if(o.rows.length>0){const l=o.rows[0].get(s);this.updatePartition(l,t),this.setState({isSelectingPartition:!0})}else fe.info("Table does not have any data, just fetching all"),this.setState({isSelectingPartition:!1}),this.handlePartitionFetchAll();this.setState({partitionTable:n,partitionColumn:t},()=>{this.initState()})}catch(n){this.handleTableLoadError(n)}}updatePartition(t,e){const s=[e.filter().eq(I.FilterValue.ofString(t))];this.setState({partition:t,partitionFilters:s})}copyCell(t,e,n=!1){const{canCopy:s}=this.props;if(s){const i=String(this.getValueForCell(t,e,n));No(i).catch(o=>fe.error("Unable to copy cell",o))}else fe.error("Attempted to copyCell for user without copy permission.")}copyRanges(t,e=!1,n=!0,s){const{model:i,canCopy:o}=this.props,{metricCalculator:r,movedColumns:l}=this.state,a=r.getUserColumnWidths();if(o){const d={ranges:ae.boundedRanges(t,i.columnCount,i.rowCount),includeHeaders:e,formatValues:n,movedColumns:l,userColumnWidths:a,error:s};this.setState({copyOperation:d})}else fe.error("Attempted copyRanges for user without copy permission.")}startLoading(t,e=!1){this.setState({loadingText:t});const n=this.getTheme();if(e&&this.grid&&(this.grid.clearSelectedRanges(),this.grid.setViewState({top:0},!0)),this.loadingScrimStartTime==null){const{minScrimTransitionTime:s,maxScrimTransitionTime:i}=n;k(s),k(i);const o=this.gridWrapper?.getBoundingClientRect().height??0,r=Math.max(s,Math.min(o/2,i));this.loadingScrimStartTime=Date.now(),this.loadingScrimFinishTime=this.loadingScrimStartTime+r,this.setState({loadingScrimProgress:0}),this.loadingTimer=setTimeout(()=>{this.setState({loadingSpinnerShown:!0})},Is.loadingSpinnerDelay)}}stopLoading(){this.loadingScrimStartTime=void 0,this.loadingScrimFinishTime=void 0,this.setState({loadingText:null,loadingScrimProgress:null,loadingSpinnerShown:!1}),this.loadingTimer!=null&&(clearTimeout(this.loadingTimer),this.loadingTimer=void 0)}rollback(){if(this.lastLoadedConfig){fe.debug("loading last loading config",this.lastLoadedConfig);const{advancedFilters:t,aggregationSettings:e,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a}=this.lastLoadedConfig;this.lastLoadedConfig=null,this.setState({advancedFilters:t,aggregationSettings:e,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a})}else fe.debug("remove all sorts, filters, and custom columns"),this.setState({advancedFilters:new Map,aggregationSettings:Dm,customColumns:[],quickFilters:new Map,reverseType:_.REVERSE_TYPE.NONE,rollupConfig:void 0,selectDistinctColumns:[],sorts:[]})}canRollback(){return this.lastLoadedConfig!=null||!Bc(this.state)}startListening(t){t.addEventListener(Ce.EVENT.UPDATED,this.handleUpdate),t.addEventListener(Ce.EVENT.REQUEST_FAILED,this.handleRequestFailed),t.addEventListener(Ce.EVENT.COLUMNS_CHANGED,this.handleCustomColumnsChanged),t.addEventListener(Ce.EVENT.PENDING_DATA_UPDATED,this.handlePendingDataUpdated)}stopListening(t){t.removeEventListener(Ce.EVENT.UPDATED,this.handleUpdate),t.removeEventListener(Ce.EVENT.REQUEST_FAILED,this.handleRequestFailed),t.removeEventListener(Ce.EVENT.COLUMNS_CHANGED,this.handleCustomColumnsChanged),t.removeEventListener(Ce.EVENT.PENDING_DATA_UPDATED,this.handlePendingDataUpdated)}focus(){this.grid?.focus()}focusFilterBar(t){const{movedColumns:e}=this.state,{model:n}=this.props,{columnCount:s}=n,i=z.getModelIndex(t,e);if(t==null||t<0||s<=t||!n.isFilterable(i)){this.setState({focusedFilterBarColumn:null});return}const{metricCalculator:o,metrics:r}=this.state;k(r);const{left:l,rightVisible:a,lastLeft:d}=r;if(t<l)this.grid?.setViewState({left:t},!0);else if(a<t){const c=this.grid?.getMetricState();k(c);const u=o.getLastLeft(c,t,o.getVisibleWidth(c));this.grid?.setViewState({left:Math.min(u,d),leftOffset:0},!0)}this.lastFocusedFilterBarColumn=t,this.setState({focusedFilterBarColumn:t,isFilterBarShown:!0})}hideColumnByVisibleIndex(t){const{metricCalculator:e,movedColumns:n}=this.state;e.setColumnWidth(z.getModelIndex(t,n),0),this.grid?.forceUpdate()}freezeColumnByColumnName(t){const{frozenColumns:e,movedColumns:n}=this.state,{model:s}=this.props;fe.debug2("freezing column",t);const i=e==null?new Set(s.frozenColumns):new Set(e);i.add(t);const o=s.getColumnIndexByName(t);k(o);const r=z.getVisibleIndex(o,n),l=z.moveItem(r,i.size-1,n);this.setState({frozenColumns:[...i],movedColumns:l})}unFreezeColumnByColumnName(t){const{frozenColumns:e,movedColumns:n}=this.state,{model:s}=this.props;fe.debug2("unfreezing column",t);const i=e==null?new Set(s.frozenColumns):new Set(e);i.delete(t);const o=s.getColumnIndexByName(t);k(o);const r=z.getVisibleIndex(o,n),l=z.moveItem(r,i.size+s.frontColumns.length,n);this.setState({frozenColumns:[...i],movedColumns:l})}handleColumnVisibilityChanged(t,e){const{metricCalculator:n,metrics:s}=this.state;k(s),e?t.forEach(i=>{const o=n.initialColumnWidths.get(i),r=L(s.calculatedColumnWidths,i);o!==r?n.setColumnWidth(i,r):n.resetColumnWidth(i)}):t.forEach(i=>{n.setColumnWidth(i,0)}),this.grid?.forceUpdate()}handleColumnVisibilityReset(){const{metricCalculator:t,metrics:e}=this.state,{model:n}=this.props;k(e);for(let s=0;s<e.columnCount;s+=1)t.resetColumnWidth(s);this.handleMovedColumnsChanged(n.initialMovedColumns),this.handleHeaderGroupsChanged(n.initialColumnHeaderGroups),this.setState({frozenColumns:n.layoutHints?.frozenColumns??[]})}handleCrossColumnSearch(t,e,n){const{model:s}=this.props;this.updateSearchFilter(t,e,s.columns,n),this.setState({searchValue:t,selectedSearchColumns:e,invertSearchColumns:n})}handleAnimationLoop(){this.grid?.updateCanvasScale(),this.grid?.updateCanvas(),this.isAnimating&&(this.animationFrame=requestAnimationFrame(this.handleAnimationLoop))}handleAnimationStart(){fe.debug2("handleAnimationStart"),this.isAnimating=!0,this.animationFrame=requestAnimationFrame(this.handleAnimationLoop)}handleAnimationEnd(){fe.debug2("handleAnimationEnd"),this.isAnimating=!1}handlePartitionAppend(t){const{onPartitionAppend:e}=this.props,{partitionColumn:n}=this.state;n!=null&&e(n,t)}handlePartitionChange(t){const{partitionColumn:e}=this.state;e!=null&&this.updatePartition(t,e)}handlePartitionFetchAll(){this.setState({partitionFilters:[],isSelectingPartition:!1})}handlePartitionDone(){this.setState({isSelectingPartition:!1})}handleTableLoadError(t){if(ye.isCanceled(t))return;fe.error(t);const{onError:e}=this.props;e(t)}showAllColumns(){const{metricCalculator:t}=this.state,n=[...t.getUserColumnWidths().entries()];for(let s=0;s<n.length;s+=1){const[i,o]=n[s];o===0&&t.resetColumnWidth(i)}this.grid?.forceUpdate()}toggleSort(t,e){fe.info("Toggling sort for column",t);const{model:n}=this.props,{sorts:s}=this.state,i=this.getModelColumn(t);k(i);const o=_.toggleSortForColumn(s,n.columns,i,e);this.updateSorts(o)}updateSorts(t){this.startLoading("Sorting..."),this.setState({sorts:t}),this.grid?.forceUpdate()}sortColumn(t,e=_.sortDirection.none,n=!1,s=!1){k(t);const{model:i}=this.props,o=_.sortColumn(i.sort,i.columns,t,e,n,s);this.startLoading("Sorting..."),this.setState({sorts:o}),this.grid?.forceUpdate()}reverse(t){this.startLoading("Reversing..."),this.setState({reverseType:t}),this.grid?.forceUpdate()}isReversible(){const{model:t}=this.props;return t.isReversible}toggleFilterBar(t=this.lastFocusedFilterBarColumn){let{isFilterBarShown:e}=this.state;if(e=!e,this.setState({isFilterBarShown:e}),e)if(t!=null)this.focusFilterBar(t);else{let n=0;const{model:s}=this.props,{columnCount:i}=s;for(let o=0;o<i;o+=1){const r=this.getModelColumn(o);if(r!=null){const l=s.columns[r];if(l!=null&&_.isTextType(l.type)){n=o;break}}}this.focusFilterBar(n)}else this.grid?.focus()}isTableSearchAvailable(){const{model:t,canToggleSearch:e}=this.props,n=t?.layoutHints?.searchDisplayMode;return n===I.SearchDisplayMode?.SEARCH_DISPLAY_HIDE?!1:n===I.SearchDisplayMode?.SEARCH_DISPLAY_SHOW?!0:e}toggleSearchBar(){const{showSearchBar:t}=this.state;if(!this.isTableSearchAvailable())return;const e=!t;this.setState({showSearchBar:e},()=>{e&&this.crossColumnRef?.current?this.crossColumnRef?.current.focus():this.grid?.focus()})}toggleGotoRow(t="",e="",n=""){const{isGotoShown:s}=this.state;if(t||e){this.setState({isGotoShown:!0,gotoRow:t,gotoValue:e,gotoValueSelectedColumnName:n,gotoRowError:"",gotoValueError:""}),this.focusRowInGrid(t);return}this.setState({isGotoShown:!s,gotoRow:"",gotoValue:"",gotoRowError:"",gotoValueError:""})}async commitPending(){const{model:t}=this.props;if(!tt(t)||!t.isEditable)throw new Error("Cannot save, table is not editable");const{pendingSavePromise:e}=this.state;if(e!=null)throw new Error("Save already in progress");const n=document?.activeElement?.classList.contains("grid-cell-input-field");if(n!=null&&n){if(document.activeElement!=null&&document.activeElement.classList.contains("error"))throw new Di("Current input is invalid");this.grid?.focus()}const s=this.pending.add(t.commitPending()).then(()=>{this.setState({pendingSaveError:null,pendingSavePromise:null})}).catch(i=>{ye.isCanceled(i)||this.setState({pendingSaveError:i,pendingSavePromise:null})});return this.setState({pendingSavePromise:s}),s}async discardPending(){const{pendingSavePromise:t}=this.state;if(t!=null)throw new Error("Cannot cancel a save in progress");this.setState({pendingSavePromise:null,pendingSaveError:null,pendingDataMap:new Map,pendingDataErrors:new Map})}selectColumn(t){const{onColumnSelected:e}=this.props;e(t)}selectData(t,e){const{model:n}=this.props,{columns:s,groupedColumns:i}=n,o={};for(let l=0;l<s.length;l+=1){const a=s[l],{name:d,type:c}=a,u=n.valueForCell(l,e),m=n.textForCell(l,e),p=this.getVisibleColumn(l),g=ze(n)&&n.isRowExpandable(e),f=i.find(C=>C.name===d)!=null;o[d]={value:u,text:m,type:c,isGrouped:f,isExpandable:g,visibleIndex:p}}const{onDataSelected:r}=this.props;r(e,o)}handleAdvancedFilterChange(t,e,n){const{model:s}=this.props,i=s.getColumnIndexByName(t.name);k(i),this.setAdvancedFilter(i,e,n)}handleAdvancedFilterSortChange(t,e,n=!1){const{model:s}=this.props,i=s.getColumnIndexByName(t.name);k(i);const o=_.getSortForColumn(s.sort,i);let r=null;(o==null||o.direction!==e)&&(e===_.sortDirection.descending?r=t.sort().desc():r=t.sort().asc());const l=_.setSortForColumn(s.sort,i,r,n);fe.info("Setting table sorts",l),this.startLoading("Sorting..."),this.setState({sorts:l}),this.grid?.forceUpdate()}handleAdvancedFilterDone(){this.grid?.focus()}handleAdvancedMenuOpened(t){this.setState({shownAdvancedFilter:t})}handleGotoRowOpened(){this.setState({isGotoShown:!0})}handleGotoRowClosed(){this.setState({isGotoShown:!1})}handleAdvancedMenuClosed(t){const{focusedFilterBarColumn:e,isFilterBarShown:n}=this.state;n&&e===t&&this.filterInputRef?.current!==null?(this.filterInputRef?.current.focus(),this.setState({shownAdvancedFilter:null})):this.setState({focusedFilterBarColumn:null,shownAdvancedFilter:null})}handleCancel(){this.rollback()}handleChartChange(){}handleChartCreate(t){const{model:e,onCreateChart:n}=this.props;n(t,e)}handleGridError(t){fe.warn("Grid Error",t),this.setState({toastMessage:h("div",{className:"error-message",children:`${t}`})})}handleFilterBarChange(t){this.startLoading("Filtering...",!0),this.setState(({focusedFilterBarColumn:e,quickFilters:n})=>{const s=new Map(n);if(e!=null){const i=this.getModelColumn(e);k(i),this.applyQuickFilter(i,t,s)}return{quickFilters:s}})}handleFilterBarDone(t=!0,e=!0){t&&this.grid?.focus(),e&&this.setState({focusedFilterBarColumn:null})}handleFilterBarTab(t){const{focusedFilterBarColumn:e}=this.state;k(e),t?this.focusFilterBar(e-1):this.focusFilterBar(e+1)}handleFormatSelection(t,e){const{model:n}=this.props,s=n.columns[t],{customColumnFormatMap:i}=this.state,o=new Map(i);if(e!=null){const r=_.getNormalizedType(s.type);k(r);const l=nn.makeColumnFormattingRule(r,s.name,e);o.set(s.name,l)}else o.delete(s.name);this.updateFormatter({customColumnFormatMap:o})}handleMenu(t){t.stopPropagation(),this.setState({isMenuShown:!0})}handleMenuClose(){this.setState({isMenuShown:!1,openOptions:[]})}handleMenuBack(){this.setState(({openOptions:t})=>{const e=[...t];return e.pop(),{openOptions:e}})}handleMenuSelect(t){this.setState(({openOptions:e})=>({openOptions:[...e,t]}))}handleRequestFailed(t){const e=t;if(fe.error("request failed:",e.detail),this.stopLoading(),this.canRollback())this.startLoading("Rolling back changes...",!0),this.rollback();else{fe.error("Table failed and unable to rollback");const{onError:n}=this.props;n(new Error(`Error displaying table: ${e.detail}`))}}handleUpdate(){this.stopLoading(),fe.debug2("Received model update");const{advancedFilters:t,aggregationSettings:e,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a}=this.state,d={advancedFilters:t,aggregationSettings:e,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:r,selectDistinctColumns:l,sorts:a};Bc(d)?this.lastLoadedConfig=null:this.lastLoadedConfig=d,this.grid?.forceUpdate()}handleViewChanged(t){const{model:e}=this.props,{selectionEndRow:n=0}=this.grid?.state??{};let s=0;if(tt(e)&&e.isEditable){k(t);const{bottomViewport:i}=t,o=e.rowCount-e.floatingBottomRowCount;n===o-1?s=e.pendingRowCount+1:n===o-2?s=e.pendingRowCount:s=Math.max(0,i-(e.rowCount-e.pendingRowCount)-e.floatingTopRowCount-e.floatingBottomRowCount-1)}this.setState({metrics:t,pendingRowCount:s})}handleSelectionChanged(t){k(t);const{onSelectionChanged:e}=this.props,{copyOperation:n}=this.state;this.setState({selectedRanges:t}),n!=null&&this.setState({copyOperation:null}),e(t)}handleMovedColumnsChanged(t,e){this.setState({movedColumns:t},e)}handleHeaderGroupsChanged(t){const{model:e}=this.props;this.setState({columnHeaderGroups:te.parseColumnHeaderGroups(e,t).groups},()=>this.grid?.forceUpdate())}handleTooltipRef(t){t?.startTimer(),this.tooltip=t}handleConditionalFormatsChange(t){fe.debug("Updated conditional formats",t),this.setState({conditionalFormats:t})}handleConditionalFormatCreate(){fe.debug("Create new conditional format");const{openOptions:t,conditionalFormats:e}=this.state;this.setState({openOptions:[...t,{type:xe.CONDITIONAL_FORMATTING_EDIT,title:"Create Formatting Rule"}],conditionalFormatEditIndex:e.length,conditionalFormatPreview:void 0})}handleConditionalFormatEdit(t){fe.debug("Edit conditional format",t);const{openOptions:e,conditionalFormats:n}=this.state;this.setState({openOptions:[...e,{type:xe.CONDITIONAL_FORMATTING_EDIT,title:"Edit Formatting Rule"}],conditionalFormatEditIndex:t,conditionalFormatPreview:{...n[t]}})}handleConditionalFormatEditorSave(t){fe.debug("Save conditional format changes",t),this.setState(e=>{if(e.conditionalFormatEditIndex===null)return fe.debug("Invalid format index"),null;const n=[...e.conditionalFormats];return n[e.conditionalFormatEditIndex]=t,{conditionalFormats:n}},()=>{this.handleMenuBack()})}handleConditionalFormatEditorCancel(){this.handleMenuBack(),this.setState({conditionalFormatEditIndex:null})}handleUpdateCustomColumns(t){fe.info("handleUpdateCustomColumns:",t);const{model:e}=this.props,{movedColumns:n,sorts:s,quickFilters:i,advancedFilters:o,selectDistinctColumns:r}=this.state,{columns:l}=e,a=e.customColumns.map(c=>`${c}`),d=te.getRemovedCustomColumnNames(a,t);if(d.length>0){const c=te.removeSortsInColumns(s,d),u=te.removeFiltersInColumns(l,i,d),m=te.removeFiltersInColumns(l,o,d),p=te.removeColumnFromMovedColumns(l,n,d),g=te.removeColumnsFromSelectDistinctColumns(r,d);c.length!==s.length&&(fe.debug("removing sorts from removed custom columns..."),this.setState({sorts:c})),(u.size!==i.size||m.size!==o.size)&&(fe.debug("removing filters from removed custom columns..."),this.setState({quickFilters:u,advancedFilters:m})),ct(n,p)||(fe.debug("change moved columns for removed custom columns",p),this.setState({movedColumns:p})),ct(r,g)||(fe.debug("change selectDistinct columns for removed custom columns",p),this.setState({selectDistinctColumns:g}))}this.setState({customColumns:t}),t.length>0&&this.startLoading("Applying custom columns...")}handleCustomColumnsChanged(){fe.debug("custom columns changed");const{isReady:t}=this.state;t?(this.stopLoading(),this.grid?.forceUpdate()):this.initState()}handlePendingCommitClicked(){return this.commitPending()}handlePendingDiscardClicked(){return this.discardPending()}handlePendingDataUpdated(){fe.debug("pending data updated");const{model:t}=this.props,{pendingDataMap:e,pendingDataErrors:n}=t;this.setState({pendingDataMap:e,pendingDataErrors:n,pendingSaveError:null}),this.grid?.forceUpdate()}handleAggregationsChange(t){fe.debug("handleAggregationsChange",t),this.startLoading(`Aggregating ${t.aggregations.map(e=>e.operation).join(", ")}...`),this.setState({aggregationSettings:t})}handleAggregationChange(t){fe.debug("handleAggregationChange",t),this.startLoading(`Aggregating ${t.operation}...`),this.setState(({aggregationSettings:e})=>({selectedAggregation:t,aggregationSettings:{...e,aggregations:e.aggregations.map(n=>n.operation===t.operation?t:n)}}))}handleAggregationEdit(t){fe.debug("handleAggregationEdit",t);const{openOptions:e}=this.state;this.setState({openOptions:[...e,{type:xe.AGGREGATION_EDIT,title:`Edit Columns to ${t.operation}`}],selectedAggregation:t})}handleRollupChange(t){fe.info("Rollup change",t),this.resetGridViewState(),this.showAllColumns(),this.clearAllFilters(),this.startLoading(`Grouping by columns ${t?.columns?.join(", ")??""}...`),this.setState({rollupConfig:t,movedColumns:[],sorts:[],reverseType:_.REVERSE_TYPE.NONE,selectDistinctColumns:[]})}handleSelectDistinctChanged(t){fe.debug("SelectDistinct change",t),this.resetGridViewState(),this.showAllColumns(),this.clearAllFilters(),this.startLoading(`Selecting distinct values in ${t.length>0?t.join(", "):""}...`),this.setState({selectDistinctColumns:t,movedColumns:[],sorts:[],reverseType:_.REVERSE_TYPE.NONE})}handleDownloadTableStart(){const{canDownloadCsv:t}=this.props;t?this.setState({isTableDownloading:!0,tableDownloadProgress:0,tableDownloadEstimatedTime:null,tableDownloadStatus:Zt.DOWNLOAD_STATUS.INITIATING}):fe.error("Attempted to handleDownloadTableStart for user without download CSV permission.")}handleDownloadTable(t,e,n,s,i,o,r){const{canDownloadCsv:l}=this.props;l?(fe.info("start table downloading",t,e,n,s,i,o,r),this.setState(()=>(this.tableSaver&&this.tableSaver.startDownload(t,e,n,s,i,o,r),{tableDownloadStatus:Zt.DOWNLOAD_STATUS.DOWNLOADING}))):fe.error("Attempted to handleDownloadTable for user without download CSV permission.")}async seekRow(t,e=!1){const{gotoValueSelectedColumnName:n,gotoValueSelectedFilter:s}=this.state,{model:i}=this.props;if(!i.isSeekRowAvailable||t==="")return;const o=i.getColumnIndexByName(n);if(o===void 0)return;const r=i.columns[o];let l;this.grid&&({selectionEndRow:l}=this.grid.state),l==null&&(l=0);const a=s===$.contains,d=s===$.eq||s===$.eqIgnoreCase;try{const c=_.getNormalizedType(r.type);let u;switch(c){case _.dataType.STRING:{u=await i.seekRow(e===!0?l-1:l+1,r,I.ValueType.STRING,t,d,a,e??!1);break}case _.dataType.DATETIME:{const{formatter:m}=i,[p]=Hn.parseDateRange(t,m.timeZone);u=await i.seekRow(e===!0?l-1:l+1,r,I.ValueType.DATETIME,p,void 0,void 0,e??!1);break}case _.dataType.DECIMAL:case _.dataType.INT:{if(!_.isBigDecimalType(r.type)&&!_.isBigIntegerType(r.type)){const m=parseInt(t,10);u=await i.seekRow(l,r,I.ValueType.NUMBER,m,void 0,void 0,e??!1)}else u=await i.seekRow(l,r,I.ValueType.STRING,t,void 0,void 0,e??!1);break}default:u=await i.seekRow(l,r,I.ValueType.STRING,t,void 0,void 0,e??!1)}this.grid?.setFocusRow(u),this.setState({gotoValueError:""})}catch{this.setState({gotoValueError:"invalid input"})}}handleCancelDownloadTable(){this.tableSaver?.cancelDownload(),this.setState({isTableDownloading:!1})}handleDownloadCompleted(){this.setState({isTableDownloading:!1,tableDownloadProgress:100,tableDownloadStatus:Zt.DOWNLOAD_STATUS.FINISHED})}handleDownloadCanceled(){this.setState({isTableDownloading:!1,tableDownloadProgress:0,tableDownloadStatus:Zt.DOWNLOAD_STATUS.CANCELED})}deleteRanges(t){const{model:e}=this.props;this.pending.add(e.delete(t)).catch(n=>{ye.isCanceled(n)||fe.error("Unable to delete ranges",t,n)})}resetColumnSelection(){if(this.grid==null)return;const{isSelectingColumn:t}=this.props;if(t){const{columnAllowedCursor:e}=this.props;this.grid.setState({cursor:e})}else this.grid.setState({cursor:null}),this.setState({hoverSelectColumn:null})}resetGridViewState(t=!0){!this.grid||(this.grid.clearSelectedRanges(),this.grid.setViewState({left:0,top:0,topOffset:0,leftOffset:0},t))}sendStateChange(){if(!this.grid)return;const{state:t}=this,{state:e}=this.grid,{onStateChange:n}=this.props;n(t,e)}handleOverflowClose(){this.setState({showOverflowModal:!1})}getColumnBoundingRect(){const{metrics:t,shownColumnTooltip:e}=this.state;k(t),k(e);const n=this.gridWrapper?.getBoundingClientRect(),s=20;k(n);const{columnHeaderHeight:i,allColumnXs:o,allColumnWidths:r,width:l,columnHeaderMaxDepth:a}=t,d=o.get(e),c=r.get(e);k(d),k(c);const u=n.left+Ze(d+c/2,s,l-s);return{top:n.top+(a-1)*i,left:n.left+Ze(d+c/2,s,l-s),bottom:n.top+a*i,right:n.left+Ze(d+c/2,s,l-s)+1,width:1,height:i,x:u,y:n.top,toJSON:()=>{throw new Error("not implemented")}}}handleGotoRowSelectedRowNumberSubmit(){const{gotoRow:t}=this.state;this.focusRowInGrid(t)}focusRowInGrid(t){const{model:e}=this.props,{rowCount:n}=e;if(this.setState({gotoRow:t}),t===""){this.setState({gotoRowError:"",gotoValueError:""});return}const s=parseInt(t,10);s>n||s<-n?this.setState({gotoRowError:"Invalid row index"}):s===0?(this.setState({gotoRowError:"",gotoValueError:""}),this.grid?.setFocusRow(0)):s<0?(this.setState({gotoRowError:"",gotoValueError:""}),this.grid?.setFocusRow(s+n)):(this.grid?.setFocusRow(s-1),this.setState({gotoRowError:"",gotoValueError:""}))}handleGotoRowSelectedRowNumberChanged(t){const e=t.target.value;this.focusRowInGrid(e)}getColumnTooltip(t,e,n){const{columnHeaderHeight:s,columnHeaderMaxDepth:i,allColumnXs:o,allColumnWidths:r,width:l}=e,a=o.get(t),d=r.get(t);if(a==null||d==null)return null;const c=Math.max(0,a);let u=d;a+d>l?u=l-a:a<0&&(u=d-Math.abs(a));const m={position:"absolute",top:(i-1)*s,left:c,width:u,height:s,pointerEvents:"none"},p={clientWidth:1,clientHeight:s,getBoundingClientRect:this.getColumnBoundingRect},g={placement:"bottom",modifiers:{flip:{behavior:["bottom","top"]}}},f=this.getModelColumn(t);if(f==null)return null;const C=n.columns[f];return C==null?null:h("div",{style:m,children:h(ut,{timeout:400,interactive:!0,options:g,ref:this.handleTooltipRef,referenceObject:p,onExited:()=>{this.setState({shownColumnTooltip:null})},children:h(hm,{model:n,column:C,onStatistics:()=>{this.tooltip?.update()}})},C.name)})}handleGotoValueSelectedColumnNameChanged(t){this.setState({gotoValueSelectedColumnName:t,gotoValueError:""})}handleGotoValueSelectedFilterChanged(t){this.setState({gotoValueSelectedFilter:t,gotoValueError:""})}handleGotoValueSubmitted(t){const{gotoValue:e}=this.state;this.seekRow(e,t)}render(){const{children:t,customFilters:e,getDownloadWorker:n,isSelectingColumn:s,isStuckToBottom:i,isStuckToRight:o,model:r,name:l,onlyFetchVisibleColumns:a,alwaysFetchColumns:d,advancedSettings:c,onAdvancedSettingsChange:u,canDownloadCsv:m,onCreateChart:p}=this.props,{metricCalculator:g,metrics:f,isFilterBarShown:C,isSelectingPartition:S,isMenuShown:w,isReady:v,copyOperation:y,focusedFilterBarColumn:E,loadingText:R,loadingScrimProgress:F,loadingSpinnerShown:D,keyHandlers:N,mouseHandlers:P,shownColumnTooltip:H,hoverAdvancedFilter:A,shownAdvancedFilter:q,hoverSelectColumn:B,quickFilters:K,advancedFilters:x,partition:O,partitionFilters:G,partitionTable:ee,partitionColumn:ne,searchFilter:V,selectDistinctColumns:W,movedColumns:X,movedRows:se,formatter:ce,conditionalFormats:Q,conditionalFormatPreview:he,conditionalFormatEditIndex:Se,sorts:Re,reverseType:et,customColumns:yt,selectedRanges:je,isTableDownloading:Tn,tableDownloadStatus:Ut,tableDownloadProgress:De,tableDownloadEstimatedTime:mt,showSearchBar:at,searchValue:Rt,selectedSearchColumns:Vt,invertSearchColumns:vn,aggregationSettings:on,selectedAggregation:ci,rollupConfig:Hs,openOptions:rn,pendingSavePromise:cs,pendingSaveError:hi,pendingRowCount:Qi,pendingDataErrors:ui,pendingDataMap:mi,toastMessage:Vo,frozenColumns:Bo,columnHeaderGroups:hs,showOverflowModal:Us,overflowText:kl,overflowButtonTooltipProps:$o,expandCellTooltipProps:Zi,isGotoShown:Ji,gotoRow:Go,gotoRowError:Wo,gotoValueError:xl,gotoValueSelectedColumnName:Ol,gotoValue:Al}=this.state;if(!v)return null;const Vs=this.getTheme(),Ll=this.getCachedFilter(e,K,x,G,V),zo=g.getUserColumnWidths(),qo=this.getCachedStateOverride(B,C,s,F,K,x,Re,et,Hs,w),eo=f?f.top:0,Yo=f?f.bottomViewport:0;let us=null,to=null;a&&(us=f?f.left:0,to=f?f.right:0);const Ko=f!=null&&f.width>0&&f.height>0,Xo=(Hs?.columns?.length??0)>0;let no=null;const Pl=f?Math.min(Math.max(Is.minDebounce,Math.round(f.rowCount/200)),Is.maxDebounce):Is.maxDebounce;if(C&&E!=null&&f!=null){const{gridX:Ye,gridY:_t,allColumnXs:En,allColumnWidths:it,width:yn}=f,ms=En.get(E),Bt=it.get(E);if(ms!=null&&Bt!=null){const Mt=Ye+ms,Gn=_t-(Vs.filterBarHeight??0),Bs=Bt+1,$s=(Vs.filterBarHeight??0)-1,nr={top:Gn,left:Mt,minWidth:Math.min(Bs,yn-Mt),height:$s};let Rn="",pi=!0;const Gs=this.getModelColumn(E);k(Gs);const gi=K.get(Gs),ps=x.get(Gs);gi!=null&&(Rn=gi.text,pi=gi.filter!=null);const fi=K.size!==0||x.size!==0;no=h(rm,{ref:this.filterInputRef,style:nr,className:Y({error:!pi,active:Rn!==""||ps!=null,"iris-grid-has-filter":fi}),isAdvancedFilterSet:ps!=null,onAdvancedFiltersTriggered:()=>{this.setState({shownAdvancedFilter:E})},onChange:this.handleFilterBarChange,onDone:this.handleFilterBarDone,onTab:this.handleFilterBarTab,onContextMenu:this.grid?.handleContextMenu,debounceMs:Pl,value:Rn},E)}}let jo=null;if(R!=null){const Ye=T("div",{className:"iris-grid-loading-status",children:[h("div",{className:Y("iris-grid-loading-status-bar",{show:D}),children:R}),T("button",{type:"button",onClick:this.handleCancel,className:Y("iris-grid-btn-cancel",{show:D}),children:[h(Z,{icon:Ui,transform:"down-1"}),"Cancel"]})]}),_t=f?f.gridY:0;jo=h("div",{className:"iris-grid-loading",style:{top:_t},children:Ye})}let Qo=null;H!=null&&f&&(Qo=this.getColumnTooltip(H,f,r),this.tooltip?.update());const Zo=[];if(f&&C){const{gridX:Ye,gridY:_t,visibleColumns:En,allColumnXs:it,allColumnWidths:yn}=f,{filterBarHeight:ms}=Vs;for(let Bt=0;Bt<En.length;Bt+=1){const Mt=En[Bt],Gn=it.get(Mt),Bs=yn.get(Mt),$s=this.getModelColumn(Mt);if($s!=null&&r.isFilterable($s)&&Gn!=null&&Bs!=null&&Bs>0){const Rn=Ye+Gn+Bs-24,pi=_t-(ms??0)+2,Gs={position:"absolute",top:pi,left:Rn},ps=x.get($s)!=null,fi=Mt===A||Mt===E||ps,Ul=h("div",{className:Y("advanced-filter-button-container",{hidden:!fi}),style:Gs,children:fi&&h(U,{kind:"ghost",className:Y("btn-link-icon advanced-filter-button",{"filter-set":ps}),onClick:()=>{this.setState({shownAdvancedFilter:Mt})},onContextMenu:Cp=>{this.grid?.handleContextMenu(Cp)},onMouseEnter:()=>{this.setState({hoverAdvancedFilter:Mt})},onMouseLeave:()=>{this.setState({hoverAdvancedFilter:null})},children:T("div",{className:"fa-layers",children:[h(Z,{icon:Ha,className:"filter-solid"}),h(Z,{icon:Mr,className:"filter-light"})]})})},Mt);Zo.push(Ul)}}}const Jo=[];if(f){const{gridX:Ye,visibleColumns:_t,allColumnXs:En,allColumnWidths:it,columnHeaderHeight:yn}=f;for(let ms=0;ms<_t.length;ms+=1){const Bt=_t[ms],Mt=En.get(Bt),Gn=it.get(Bt);if(Mt!=null&&Gn!=null&&Gn>0){const Bs=Ye+Mt,$s=Ye+Mt+Gn-20,nr=C?{position:"absolute",top:yn,left:$s,width:20,height:Vs.filterBarHeight}:{position:"absolute",top:0,left:Bs,width:Gn,height:yn},Rn=this.getModelColumn(Bt);if(Rn!=null){const pi=r.columns[Rn],Gs=x.get(Rn),{options:gi}=Gs||{},ps=_.getSortForColumn(r.sort,Rn),fi=ps?ps.direction:null,Ul=h("div",{className:"advanced-filter-menu-container",style:nr,children:h(tl,{className:"advanced-filter-menu-popper",onEntered:this.getAdvancedMenuOpenedHandler(Bt),onExited:()=>{this.handleAdvancedMenuClosed(Bt)},isShown:q===Bt,interactive:!0,closeOnBlur:!0,options:{positionFixed:!0},children:this.getCachedAdvancedFilterMenuActions(r,pi,gi,fi,ce)})},Bt);Jo.push(Ul)}}}}const er=this.getCachedOptionItems(p!==void 0&&r.isChartBuilderAvailable,r.isCustomColumnsAvailable,r.isFormatColumnsAvailable,r.isRollupAvailable,r.isTotalsAvailable,r.isSelectDistinctAvailable,r.isExportAvailable,this.toggleFilterBarAction,this.toggleSearchBarAction,this.toggleGotoRowAction,C,at,m,this.isTableSearchAvailable(),Ji,c.size>0),tr=this.getCachedHiddenColumns(g,zo),Hl=rn.map(Ye=>{switch(Ye.type){case xe.CHART_BUILDER:return h(pm,{model:r,onChange:this.handleChartChange,onSubmit:this.handleChartCreate},xe.CHART_BUILDER);case xe.VISIBILITY_ORDERING_BUILDER:return h(pd,{model:r,movedColumns:X,hiddenColumns:tr,columnHeaderGroups:hs,onColumnVisibilityChanged:this.handleColumnVisibilityChanged,onReset:this.handleColumnVisibilityReset,onMovedColumnsChanged:this.handleMovedColumnsChanged,onColumnHeaderGroupChanged:this.handleHeaderGroupsChanged},xe.VISIBILITY_ORDERING_BUILDER);case xe.CONDITIONAL_FORMATTING:return h(fv,{rules:Q,onChange:this.handleConditionalFormatsChange,onCreate:this.handleConditionalFormatCreate,onSelect:this.handleConditionalFormatEdit});case xe.CONDITIONAL_FORMATTING_EDIT:return k(r.columns),k(this.handleConditionalFormatEditorUpdate),h(Gv,{columns:r.columns,rule:he,onUpdate:this.handleConditionalFormatEditorUpdate,onSave:this.handleConditionalFormatEditorSave,onCancel:this.handleConditionalFormatEditorCancel});case xe.CUSTOM_COLUMN_BUILDER:return h(fm,{model:r,customColumns:yt,onSave:this.handleUpdateCustomColumns,onCancel:this.handleMenuBack},xe.CUSTOM_COLUMN_BUILDER);case xe.ROLLUP_ROWS:return h(md,{model:r,onChange:this.handleRollupChange,config:Hs},xe.ROLLUP_ROWS);case xe.AGGREGATIONS:return h(RT,{settings:on,isRollup:Xo,onChange:this.handleAggregationsChange,onEdit:this.handleAggregationEdit});case xe.AGGREGATION_EDIT:return ci&&h(FT,{aggregation:ci,columns:r.originalColumns,onChange:this.handleAggregationChange});case xe.TABLE_EXPORTER:return h(Zt,{model:r,name:l,userColumnWidths:zo,movedColumns:X,isDownloading:Tn,tableDownloadStatus:Ut,tableDownloadProgress:De,tableDownloadEstimatedTime:mt??void 0,onDownload:this.handleDownloadTable,onDownloadStart:this.handleDownloadTableStart,onCancel:this.handleCancelDownloadTable,selectedRanges:je},xe.TABLE_EXPORTER);case xe.SELECT_DISTINCT:return h(Rm,{model:r,selectDistinctColumns:W,onChange:this.handleSelectDistinctChanged});case xe.ADVANCED_SETTINGS:return h(gd,{items:c,onChange:u});default:throw Error(`Unexpected option type ${Ye.type}`)}});return T("div",{className:"iris-grid",role:"presentation",children:[T("div",{className:"iris-grid-column",children:[t!=null&&h("div",{className:"iris-grid-bar",children:t}),h(Ht,{in:S,timeout:Xe.transitionSlowMs,classNames:"iris-grid-bar-horizontal",onEnter:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExit:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:"iris-grid-partition-selector-wrapper iris-grid-bar iris-grid-bar-primary",children:ee&&ne&&O!=null&&h(ym,{table:ee,getFormattedString:(Ye,_t,En)=>r.displayString(Ye,_t,En),columnName:ne.name,partition:O,onChange:this.handlePartitionChange,onFetchAll:this.handlePartitionFetchAll,onAppend:this.handlePartitionAppend,onDone:this.handlePartitionDone})})}),h(Ht,{in:at,timeout:Xe.transitionSlowMs,classNames:"iris-grid-bar-horizontal",onEnter:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExit:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:"iris-grid-bar",children:h(mr,{value:Rt,selectedColumns:Vt,invertSelection:vn,onChange:this.handleCrossColumnSearch,columns:r.columns,ref:this.crossColumnRef})})}),T("div",{className:"grid-wrapper",ref:Ye=>{this.gridWrapper=Ye},children:[h(Wi,{ref:Ye=>{this.grid=Ye},isStickyBottom:!tt(r)||!r.isEditable,isStuckToBottom:i,isStuckToRight:o,metricCalculator:g,model:r,keyHandlers:N,mouseHandlers:P,movedColumns:X,movedRows:se,onError:this.handleGridError,onViewChanged:this.handleViewChanged,onSelectionChanged:this.handleSelectionChanged,onMovedColumnsChanged:this.handleMovedColumnsChanged,renderer:this.renderer,stateOverride:qo,theme:Vs}),h(Wv,{isOpen:Us,text:kl,onClose:this.handleOverflowClose}),Ko&&h(dm,{model:r,modelColumns:r.columns,top:eo,bottom:Yo,left:us,right:to,filter:Ll,formatter:ce,sorts:Re,reverseType:et,movedColumns:X,customColumns:yt,hiddenColumns:tr,alwaysFetchColumns:this.getAlwaysFetchColumns(d,r.columns,X,r.floatingLeftColumnCount,r.floatingRightColumnCount,this.grid?.state.draggingColumn?.range),formatColumns:this.getCachedPreviewFormatColumns(this.getCachedModelColumns(r,yt),Q,he,rn[rn.length-1]?.type===xe.CONDITIONAL_FORMATTING_EDIT?Se??void 0:void 0),rollupConfig:this.getModelRollupConfig(r.originalColumns,Hs,on),totalsConfig:this.getModelTotalsConfig(r.columns,Hs,on),selectDistinctColumns:W,pendingRowCount:Qi,pendingDataMap:mi,frozenColumns:Bo,columnHeaderGroups:hs}),!w&&h("div",{className:"grid-settings-button",children:h(U,{kind:"ghost","data-testid":`btn-iris-grid-settings-button-${l}`,onClick:this.handleMenu,icon:h(Z,{icon:qg,transform:"up-1"}),tooltip:"Table Options"})}),no,jo,Zo,Qo,Jo,$o&&this.getOverflowButtonTooltip($o),Zi&&this.getExpandCellTooltip(Zi)]}),h(Yv,{model:r,isShown:Ji,gotoRow:Go,gotoRowError:Wo,gotoValueError:xl,onGotoRowSubmit:this.handleGotoRowSelectedRowNumberSubmit,onGotoRowNumberChanged:this.handleGotoRowSelectedRowNumberChanged,onClose:this.handleGotoRowClosed,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:()=>{this.handleAnimationStart(),this.focus()},onExited:this.handleAnimationEnd,gotoValueSelectedColumnName:Ol,gotoValue:Al,onGotoValueSelectedColumnNameChanged:this.handleGotoValueSelectedColumnNameChanged,onGotoValueSelectedFilterChanged:this.handleGotoValueSelectedFilterChanged,onGotoValueChanged:this.handleGotoValueChanged,onGotoValueSubmit:this.handleGotoValueSubmitted}),h(jw,{error:hi,isSaving:cs!=null,saveTooltip:`Commit (${this.commitAction.shortcut.getDisplayText()})`,discardTooltip:`Discard (${this.discardAction.shortcut.getDisplayText()})`,pendingDataErrors:ui,pendingDataMap:mi,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd,onSave:this.handlePendingCommitClicked,onDiscard:this.handlePendingDiscardClicked}),h(CT,{children:Vo}),h(zi,{model:r,copyOperation:y??void 0,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd}),h(qi,{ref:Ye=>{this.tableSaver=Ye},getDownloadWorker:n,onDownloadCompleted:this.handleDownloadCompleted,onDownloadCanceled:this.handleDownloadCanceled,onDownloadProgressUpdate:this.handleDownloadProgressUpdate,isDownloading:Ut===Zt.DOWNLOAD_STATUS.DOWNLOADING,formatter:ce})]}),h(Ht,{in:w,timeout:Xe.transitionMidMs,classNames:"slide-left",onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:h("div",{className:"table-sidebar",children:T(Ff,{children:[h(Jd,{title:"Table Options",onClose:this.handleMenuClose,children:h(Oh,{onSelect:Ye=>this.handleMenuSelect(er[Ye]),items:er})}),Hl.map((Ye,_t)=>h(Jd,{title:rn[_t].title,onBack:this.handleMenuBack,onClose:this.handleMenuClose,children:Ye},rn[_t].type))]})})}),h(le,{actions:this.contextActions})]})}};let Yi=Is;Yi.minDebounce=150;Yi.maxDebounce=500;Yi.loadingSpinnerDelay=800;Yi.defaultProps={children:null,advancedFilters:Jn,advancedSettings:Jn,alwaysFetchColumns:He,conditionalFormats:He,customColumnFormatMap:Jn,isFilterBarShown:!1,applyInputFiltersOnInit:!1,movedColumns:He,movedRows:He,inputFilters:He,customFilters:He,onCreateChart:void 0,onColumnSelected:()=>{},onDataSelected:()=>{},onError:()=>{},onStateChange:()=>{},onPartitionAppend:()=>{},onAdvancedSettingsChange:()=>{},partition:null,partitionColumn:null,quickFilters:Jn,selectDistinctColumns:He,sorts:He,reverseType:_.REVERSE_TYPE.NONE,customColumns:He,aggregationSettings:Dm,rollupConfig:void 0,userColumnWidths:Jn,userRowHeights:Jn,onSelectionChanged:()=>{},isSelectingColumn:!1,isSelectingPartition:!1,isStuckToBottom:!1,isStuckToRight:!1,columnSelectionValidator:null,columnAllowedCursor:null,columnNotAllowedCursor:null,name:"table",onlyFetchVisibleColumns:!0,showSearchBar:!1,searchValue:"",selectedSearchColumns:null,invertSearchColumns:!0,onContextMenu:()=>{},pendingDataMap:Jn,getDownloadWorker:void 0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:Hn.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,truncateNumbersWithPound:!1,formatter:He,decimalFormatOptions:M.exports.shape({defaultFormatString:M.exports.string}),integerFormatOptions:M.exports.shape({defaultFormatString:M.exports.string})},canCopy:!0,canDownloadCsv:!0,frozenColumns:null,theme:cm,canToggleSearch:!0};class Jv extends Error{constructor(e,n){super(`${n} can't be empty (on pending row ${e+1})`),this.isMissingKey=!0,this.rowIndex=e,this.columnName=n}}const ot=J.module("IrisGridTableModel"),eE=150,tE=0,nE=[];function si(t){return t.table!==void 0}const Ea=class extends Ce{constructor(t,e=new nn,n=null){super(),this.pendingNewRowCount=0,this._columnHeaderGroupMap=new Map,this.columnHeaderParentMap=new Map,this._columnHeaderMaxDepth=null,this._columnHeaderGroups=[],this._movedColumns=null,this.getMemoizedInitialMovedColumns=ge(s=>{if(!s)return[];let i=[];const{groupMap:o}=te.parseColumnHeaderGroups(this,s?.columnGroups??[]),r=(m,p)=>{const g=this.getColumnIndexByName(m);if(g==null)throw new Error(`Unknown layout hint column: ${m}`);const f=z.getVisibleIndex(g,i);i=z.moveItem(f,p,i)},l=(m,p)=>{const g=o.get(m);if(g==null)throw new Error(`Unknown layout hint group: ${m}`);const f=g.getVisibleRange(i);i=z.moveRange(f,p,i)},{frontColumns:a=[],backColumns:d=[],frozenColumns:c=[]}=s;if(a.length||d.length||c.length){const m=new Set;let p=0;c.forEach(f=>{if(m.has(f))throw new Error(`Column specified in multiple layout hints: ${f}`);r(f,p),p+=1}),a.forEach(f=>{if(m.has(f))throw new Error(`Column specified in multiple layout hints: ${f}`);r(f,p),p+=1});let g=this.columnMap.size-1;d.forEach(f=>{if(m.has(f))throw new Error(`Column specified in multiple layout hints: ${f}`);r(f,g),g-=1})}if(s?.columnGroups){const m=[...o.values()];m.sort((p,g)=>p.depth-g.depth),m.forEach(p=>{const g=p.children[0],f=this.getColumnIndexByName(g);let C;if(f!=null)C=z.getVisibleIndex(f,i);else{const S=o.get(g);if(!S)throw new Error(`Unknown column ${g} in group ${p.name}`);[,C]=S.getVisibleRange(i)}for(let S=1;S<p.children.length;S+=1){const w=p.children[S],v=o.get(w),y=this.getColumnIndexByName(w);if(v){const R=v.getVisibleRange(i)[0]<C?C-v.childIndexes.length+1:C+1;l(w,R),C=R+v.childIndexes.length-1}else if(y!=null){const R=z.getVisibleIndex(y,i)<C?C:C+1;r(w,R),C=R}}})}return this._movedColumns=i,i}),this.getMemoizedInitialColumnHeaderGroups=ge(s=>te.parseColumnHeaderGroups(this,s?.columnGroups??[]).groups),this.getMemoizedColumnMap=ge(s=>{const i=new Map;return s.forEach(o=>i.set(o.name,o)),i}),this.getColumnIndicesByNameMap=ge(s=>{const i=new Map;return s.forEach(({name:o},r)=>i.set(o,r)),i}),this.setViewport=Ln((s,i,o)=>{if(i<s){ot.error("Invalid viewport",s,i);return}const{viewport:r}=this;if(r!=null&&r.top===s&&r.bottom===i&&r.columns===o){ot.debug2("Ignoring duplicate viewport",r);return}this.viewport={top:s,bottom:i,columns:o},ot.debug2("setViewport",this.viewport),this.applyViewport()},eE),this.applyViewport=Ln(()=>{if(!this.viewport)return;ot.debug2("applyViewport",this.viewport);const{top:s,bottom:i,columns:o}=this.viewport,[r,l]=this.getCachedViewportRowRange(s,i);this.applyBufferedViewport(r,l,o)},tE,{leading:!1}),this.getCachedFormattedString=Jt((s,i,o,r,l)=>s.getFormattedString(i,o,r,l),{max:1e4}),this.getCachedCustomColumnFormatFlag=Jt(rs.isCustomColumnFormatDefined,{max:1e4}),this.getCachedViewportRowRange=ge((s,i)=>{const o=i-s,r=Math.max(0,s-o*Ea.ROW_BUFFER_PAGES),l=i+o*Ea.ROW_BUFFER_PAGES;return[r,l]}),this.getCachedPendingErrors=ge((s,i,o)=>{const r=new Map;return s.forEach((l,a)=>{const{data:d}=l;for(let c=0;c<o;c+=1)d.has(c)||(r.has(a)||r.set(a,[]),r.get(a)?.push(new Jv(a,i[c].name)))}),r}),this.handleTableDisconnect=this.handleTableDisconnect.bind(this),this.handleTableReconnect=this.handleTableReconnect.bind(this),this.handleTableUpdate=this.handleTableUpdate.bind(this),this.handleTotalsUpdate=this.handleTotalsUpdate.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.handleCustomColumnsChanged=this.handleCustomColumnsChanged.bind(this),this.irisFormatter=e,this.inputTable=n,this.subscription=null,this.table=t,this.viewport=null,this.viewportData=null,this.formattedStringData=[],this.pendingStringData=[],this.isSaveInProgress=!1,this.totalsTable=null,this.totalsTablePromise=null,this.totals=null,this.totalsDataMap=null,this.pendingNewDataMap=new Map,this.pendingNewRowCount=0,this.columnHeaderGroups=te.parseColumnHeaderGroups(this,this.layoutHints?.columnGroups??[]).groups}seekRow(t,e,n,s,i,o,r){throw new Error("Method not implemented.")}export(){throw new Error("Method not implemented.")}columnStatistics(t){throw new Error("Method not implemented.")}get customColumns(){return[]}set customColumns(t){throw new Error("Method not implemented.")}get formatColumns(){return[]}set formatColumns(t){throw new Error("Method not implemented.")}updateFrozenColumns(t){throw new Error("Method not implemented.")}get rollupConfig(){throw new Error("Method not implemented.")}set rollupConfig(t){throw new Error("Method not implemented.")}get selectDistinctColumns(){throw new Error("Method not implemented.")}set selectDistinctColumns(t){throw new Error("Method not implemented.")}get columns(){return this.table.columns}close(){this.table.close(),this.totalsTable!==null&&this.totalsTable.close(),this.totalsTablePromise!==null&&this.totalsTablePromise.cancel()}startListening(){super.startListening(),this.table.addEventListener(I.Table.EVENT_DISCONNECT,this.handleTableDisconnect),this.table.addEventListener(I.Table.EVENT_RECONNECT,this.handleTableReconnect),this.table.addEventListener(I.Table.EVENT_UPDATED,this.handleTableUpdate),this.table.addEventListener(I.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed),this.table.addEventListener(I.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleCustomColumnsChanged),this.totalsTable!=null&&this.addTotalsListeners(this.totalsTable),this.applyViewport()}stopListening(){super.stopListening(),this.table.removeEventListener(I.Table.EVENT_DISCONNECT,this.handleTableDisconnect),this.table.removeEventListener(I.Table.EVENT_RECONNECT,this.handleTableReconnect),this.table.removeEventListener(I.Table.EVENT_UPDATED,this.handleTableUpdate),this.table.removeEventListener(I.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed),this.table.removeEventListener(I.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleCustomColumnsChanged),this.totalsTable!=null&&this.removeTotalsListeners(this.totalsTable),this.closeSubscription()}addTotalsListeners(t){t.addEventListener(I.Table.EVENT_UPDATED,this.handleTotalsUpdate),t.setViewport(0,0)}removeTotalsListeners(t){t.removeEventListener(I.Table.EVENT_UPDATED,this.handleTotalsUpdate)}handleTableDisconnect(){this.dispatchEvent(new Ke(Ce.EVENT.DISCONNECT))}handleTableReconnect(){this.dispatchEvent(new Ke(Ce.EVENT.RECONNECT))}handleTableUpdate(t){this.copyViewportData(t.detail),this.dispatchEvent(new Ke(Ce.EVENT.UPDATED))}handleTotalsUpdate(t){this.copyTotalsData(t.detail),this.dispatchEvent(new Ke(Ce.EVENT.UPDATED))}handleRequestFailed(t){this.dispatchEvent(new Ke(Ce.EVENT.REQUEST_FAILED,t))}handleCustomColumnsChanged(){this.dispatchEvent(new Ke(Ce.EVENT.COLUMNS_CHANGED,{detail:this.columns}))}get rowCount(){return this.table.size+this.pendingNewRowCount+(this.totals?.operationOrder?.length??0)}get pendingDataErrors(){return this.getCachedPendingErrors(this.pendingNewDataMap,this.columns,this.inputTable?.keyColumns.length??0)}get pendingDataMap(){return this.pendingNewDataMap}set pendingDataMap(t){t!==this.pendingNewDataMap&&(t.forEach((e,n)=>{if(!te.isValidIndex(n))throw new Error(`Invalid rowIndex ${n}`);const{data:s}=e;s.forEach((i,o)=>{if(!te.isValidIndex(o))throw new Error(`Invalid columnIndex ${o}`)})}),this.pendingNewDataMap=t,this.pendingNewRowCount=Math.max(this.pendingNewRowCount,this.maxPendingDataRow),this.formattedStringData=[],this.dispatchEvent(new Ke(Ce.EVENT.PENDING_DATA_UPDATED)))}get pendingRowCount(){return this.pendingNewRowCount}set pendingRowCount(t){t!==this.pendingNewRowCount&&(this.pendingNewRowCount=Math.max(0,t,this.maxPendingDataRow),this.dispatchEvent(new Ke(Ce.EVENT.UPDATED)))}get maxPendingDataRow(){return this.pendingNewDataMap.size>0?Math.max(...this.pendingNewDataMap.keys())+1:0}get columnCount(){return this.columns.length}get floatingBottomRowCount(){return this.totals!=null&&this.totals.showOnTop?0:this.totals?.operationOrder?.length??0}get floatingTopRowCount(){return this.totals!=null&&this.totals.showOnTop?this.totals?.operationOrder?.length??0:0}get isChartBuilderAvailable(){return!0}get isTotalsAvailable(){return this.table.getTotalsTable!=null}get isEditable(){return!this.isSaveInProgress&&this.inputTable!=null}cacheFormattedValue(t,e,n){this.formattedStringData[t]==null&&(this.formattedStringData[t]=[]),this.formattedStringData[t][e]=n}cachePendingValue(t,e,n){this.pendingStringData[t]==null&&(this.pendingStringData[t]=[]),this.pendingStringData[t][e]=n}clearPendingValue(t,e){const n=this.pendingStringData[t];n!=null&&delete n[e]}textValueForCell(t,e){if(this.pendingStringData[t]?.[e]!==void 0)return this.pendingStringData[t][e];if(this.formattedStringData[t]?.[e]===void 0){const n=this.valueForCell(t,e);if(n==null)return null;const s=this.totalsColumn(t,e)??this.columns[t],i=this.getCachedCustomColumnFormatFlag(this.formatter,s.name,s.type);let o;if(!i){const l=this.formatForCell(t,e);l?.formatString!=null&&(o=l)}const r=this.displayString(n,s.type,s.name,o);this.cacheFormattedValue(t,e,r)}return this.formattedStringData[t][e]}textForCell(t,e){const n=this.textValueForCell(t,e);if(n==null&&this.isKeyColumn(t)){const s=this.pendingRow(e);if(s!=null&&this.pendingDataMap.has(s))return"*"}return n??""}truncationCharForCell(t){const e=this.columns[t],{type:n}=e;if(_.isNumberType(n)&&this.formatter.truncateNumbersWithPound)return"#"}colorForCell(t,e,n){const s=this.dataForCell(t,e);if(s){const{format:i,value:o}=s;if(o==null||o==="")return k(n.nullStringColor),n.nullStringColor;if(i&&i.color)return i.color;if(this.isPendingRow(e))return k(n.pendingTextColor),n.pendingTextColor;if(o!=null){const r=this.totalsColumn(t,e)??this.columns[t];if(_.isDateType(r.type)||r.name==="Date")return k(n.dateColor),n.dateColor;if(_.isNumberType(r.type))return o>0?(k(n.positiveNumberColor),n.positiveNumberColor):o<0?(k(n.negativeNumberColor),n.negativeNumberColor):(k(n.zeroNumberColor),n.zeroNumberColor)}}else if(this.isPendingRow(e)&&this.isKeyColumn(t))return k(n.errorTextColor),n.errorTextColor;return n.textColor}backgroundColorForCell(t,e){return this.formatForCell(t,e)?.backgroundColor??null}textAlignForCell(t){const e=this.columns[t],{type:n}=e;return _.isNumberType(n)?"right":_.isDateType(n)||e.name==="Date"?"center":"left"}textForColumnHeader(t,e=0){const n=this.columnAtDepth(t,e);return Kl(n)?n.isNew?"":n.name:n?.name}colorForColumnHeader(t,e=0){const n=this.columnAtDepth(t,e);return Kl(n)?n.color??null:null}getColumnHeaderGroup(t,e){const n=this.columnAtDepth(t,e);if(Kl(n))return n}getColumnHeaderParentGroup(t,e){return this.columnHeaderParentMap.get(this.columnAtDepth(t,e)?.name??"")}columnAtDepth(t,e=0){if(e===0)return this.columns[t];const n=this.columns[t]?.name;let s=this.columnHeaderParentMap.get(n);if(!s)return;let i=s.depth;for(;i<e;){if(s=this.columnHeaderParentMap.get(s.name),!s)return;i=s.depth}if(s.depth===e)return s}textForRowFooter(t){const e=this.totalsRow(t);return e!=null&&this.totals?this.totals.operationOrder[e]:""}get initialMovedColumns(){return this.getMemoizedInitialMovedColumns(this.layoutHints??void 0)}get initialMovedRows(){return nE}get initialColumnHeaderGroups(){return this.getMemoizedInitialColumnHeaderGroups(this.layoutHints??void 0)}get columnMap(){return this.getMemoizedColumnMap(this.table.columns)}get columnHeaderMaxDepth(){return this._columnHeaderMaxDepth??1}set columnHeaderMaxDepth(t){this._columnHeaderMaxDepth=t}get columnHeaderGroupMap(){return this._columnHeaderGroupMap}get columnHeaderGroups(){return this._columnHeaderGroups}set columnHeaderGroups(t){if(t===this._columnHeaderGroups)return;const{groups:e,maxDepth:n,parentMap:s,groupMap:i}=te.parseColumnHeaderGroups(this,t??this.initialColumnHeaderGroups);this._columnHeaderGroups=e,this.columnHeaderMaxDepth=n,this.columnHeaderParentMap=s,this._columnHeaderGroupMap=i}get groupedColumns(){return[]}row(t){const e=this.totals?.operationOrder?.length??0,n=this.totals?.showOnTop??!1,s=this.totalsRow(t);if(s!=null){const l=this.totals?.operationOrder[s];return k(l),this.totalsDataMap?.get(l)??null}const i=this.pendingRow(t);if(i!=null)return this.pendingNewDataMap.get(i)??null;const o=this.viewportData?.offset??0,r=(n?t-e:t)-o;return this.viewportData?.rows?.[r]??null}totalsColumn(t,e){const n=this.totalsRow(e);if(n==null)return null;const s=this.totals?.operationOrder[n],i=this.totals?.defaultOperation??Oe.SUM,o=this.columns[t];return this.totalsTable?.columns.find(r=>r.name===`${o.name}__${s}`||(s===i||this.totals?.operationOrder.length===1)&&r.name===o.name)}totalsRow(t){const e=this.totals?.operationOrder?.length??0,s=this.totals?.showOnTop??!1?t:t-this.table.size;return s>=0&&s<e?s:null}pendingRow(t){const e=t-this.floatingTopRowCount-this.table.size;return e>=0&&e<this.pendingNewRowCount?e:null}isTotalsRow(t){return this.totalsRow(t)!=null}isPendingRow(t){return this.pendingRow(t)!=null}dataForCell(t,e){return this.row(e)?.data.get(t)}formatForCell(t,e){return this.dataForCell(t,e)?.format}valueForCell(t,e){const n=this.dataForCell(t,e);if(n)return n.value??null}copyViewportData(t){if(t==null){ot.warn("invalid data!");return}this.viewportData=this.extractViewportData(t),this.formattedStringData=[]}copyTotalsData(t){if(t==null){ot.warn("invalid data!");return}const{columns:e,rows:n}=t;if(n.length!==1){ot.error("Unexpected number of rows received for totals table, ignoring update");return}const s=new Map,i=n[0],o=this.totals?.defaultOperation??Oe.SUM,r=this.totals?.operationMap;for(let l=0;l<e.length;l+=1){const a=e[l],[d,c=r?.[d]?.[0]??o]=a.name.split("__");s.has(c)||s.set(c,{data:new Map});const{data:u}=s.get(c),m=this.columns.findIndex(p=>p.name===d);u.set(m,{value:i.get(a),format:i.getFormat(a)})}ot.debug2("copyTotalsData",s),this.totalsDataMap=s,this.formattedStringData=[]}getColumnIndexByName(t){return this.getColumnIndicesByNameMap(this.columns).get(t)}extractViewportData(t){const e={offset:t.offset,rows:[]},{columns:n}=t;for(let s=0;s<t.rows.length;s+=1){const i=t.rows[s],o=this.extractViewportRow(i,n);e.rows.push(o)}return e}extractViewportRow(t,e){const n=new Map;for(let s=0;s<e.length;s+=1){const i=e[s],o=this.getColumnIndexByName(i.name);k(o),n.set(o,{value:t.get(i),format:t.getFormat(i)})}return{data:n}}closeSubscription(){ot.debug2("closeSubscription",this.subscription),this.subscription&&(this.subscription.close(),this.subscription=null),this.setViewport.cancel(),this.applyViewport.cancel()}get filter(){return this.table.filter}set filter(t){this.closeSubscription(),this.table.applyFilter(t),this.applyViewport()}get formatter(){return this.irisFormatter}set formatter(t){this.irisFormatter=t,this.formattedStringData=[],this.dispatchEvent(new Ke(Ce.EVENT.FORMATTER_UPDATED))}displayString(t,e,n="",s){return this.getCachedFormattedString(this.formatter,t,e,n,s)}get sort(){return this.table.sort}set sort(t){this.closeSubscription(),this.table.applySort(t),this.applyViewport()}set totalsConfig(t){if(ot.debug("set totalsConfig",t),t!==this.totals){if(this.totals=t,this.formattedStringData=[],this.totalsTablePromise!=null&&this.totalsTablePromise.cancel(),this.setTotalsTable(null),t==null){this.dispatchEvent(new Ke(Ce.EVENT.UPDATED));return}this.totalsTablePromise=ye.makeCancelable(this.table.getTotalsTable(t),e=>e.close()),this.totalsTablePromise.then(e=>{this.totalsTablePromise=null,this.setTotalsTable(e)}).catch(e=>{ye.isCanceled(e)||(ot.error("Unable to set next totalsTable",e),this.totalsTablePromise=null,this.dispatchEvent(new Ke(Ce.EVENT.REQUEST_FAILED,{detail:e})))})}}setTotalsTable(t){ot.debug("setTotalsTable",t),this.totalsTable!==null&&(this.listenerCount>0&&this.removeTotalsListeners(this.totalsTable),this.totalsTable.close()),this.totalsTable=t,this.totalsDataMap=null,this.listenerCount>0&&this.totalsTable!=null&&this.addTotalsListeners(this.totalsTable)}applyBufferedViewport(t,e,n){ot.debug2("applyBufferedViewport",t,e,n),this.subscription==null?(ot.debug2("applyBufferedViewport creating new subscription"),this.subscription=this.table.setViewport(t,e,n)):(ot.debug2("applyBufferedViewport using existing subscription"),this.subscription.setViewport(t,e,n))}async snapshot(t,e=!1,n=i=>i,s=!0){if(this.subscription==null)throw new Error("No subscription available");const i=s?ae.consolidate(t):t;if(!te.isValidSnapshotRanges(i))throw new Error(`Invalid snapshot ranges ${t}`);const o=new Set,r=[],l=new Set;for(let m=0;m<i.length;m+=1){const p=i[m];k(p.endRow),k(p.startRow);for(let g=p.startRow;g<=p.endRow&&g<this.floatingTopRowCount;g+=1)o.add(g);p.endRow>=this.floatingTopRowCount&&p.startRow<=this.floatingTopRowCount+this.table.size&&r.push(new ae(p.startColumn,Math.min(Math.max(0,p.startRow-this.floatingTopRowCount)),p.endColumn,Math.min(Math.max(0,p.endRow-this.floatingTopRowCount),this.table.size-this.floatingTopRowCount)));for(let g=Math.max(p.startRow,this.floatingTopRowCount+this.table.size);g<=p.endRow&&g<this.floatingTopRowCount+this.table.size+this.floatingBottomRowCount;g+=1)l.add(g)}const a=te.columnsFromRanges(i,this.columns),d=[];e&&d.push(a.map(m=>m.name));const c=[...o].sort();for(let m=0;m<c.length;m+=1){const p=c[m],g=a.map(f=>{const C=this.getColumnIndexByName(f.name);return k(C),n(this.valueForCell(C,p),f)});e&&g.push(this.textForRowFooter(p)),d.push(g)}if(r.length>0){const m=te.rangeSetFromRanges(r),p=await this.subscription.snapshot(m,a);d.push(...p.rows.map(g=>a.map(f=>n(g.get(f),f))))}const u=[...l].sort();for(let m=0;m<u.length;m+=1){const p=u[m],g=a.map(f=>{const C=this.getColumnIndexByName(f.name);return k(C),n(this.valueForCell(C,p),f)});e&&g.push(this.textForRowFooter(p)),d.push(g)}return d}async textSnapshot(t,e=!1,n=s=>`${s}`){return ot.debug2("textSnapshot",t,e),(await this.snapshot(t,e,n,!1)).map(i=>i.join(" ")).join(`
31
- `)}async valuesTable(t){let e=null;try{return e=await this.table.copy(),e.applyFilter([]),e.applySort([]),e.selectDistinct([t])}finally{e?.close()}}isColumnMovable(t,e){if(t<0||t>=this.columnCount)return!1;if(e>0)return!0;const n=this.columns[t].name;return this.frontColumns.includes(n)||this.backColumns.includes(n)||this.frozenColumns.includes(n)||!n?!1:!this.isKeyColumn(t)}isKeyColumn(t){return t<(this.inputTable?.keyColumns.length??0)}isRowMovable(){return!1}isEditableRange(t){return!(this.inputTable==null||!ae.isBounded(t)||!(this.isPendingRow(t.startRow)&&this.isPendingRow(t.endRow)||this.inputTable.keyColumns.length!==0&&t.startColumn>=this.inputTable.keyColumns.length&&t.endColumn>=this.inputTable.keyColumns.length)||t.startRow<this.floatingTopRowCount||t.startRow>=this.floatingTopRowCount+this.table.size+this.pendingRowCount||t.endRow>=this.floatingTopRowCount+this.table.size+this.pendingRowCount)}isDeletableRange(t){return this.inputTable!=null&&t.startRow!=null&&t.endRow!=null&&t.startRow>=this.floatingTopRowCount&&t.startRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount&&t.endRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount}isEditableRanges(t){return t.every(e=>this.isEditableRange(e))}isDeletableRanges(t){return t.every(e=>this.isDeletableRange(e))}getTableAreaRange(){return new ae(null,this.floatingTopRowCount,null,this.floatingTopRowCount+this.table.size-1)}getPendingAreaRange(){return new ae(null,this.floatingTopRowCount+this.table.size,null,this.floatingTopRowCount+this.table.size+this.pendingNewRowCount-1)}async setValueForCell(t,e,n){return this.setValueForRanges([new ae(t,e,t,e)],n)}async setValueForRanges(t,e){if(!this.isEditableRanges(t))throw new Error(`Uneditable ranges ${t}`);try{const n=new Set,s=[];ae.forEachCell(t,(a,d)=>{const c=this.columns[a];if(n.add(c),s[a]===void 0){const u=_.makeValue(c.type,e,this.formatter.timeZone);s[a]=u!=null?this.displayString(u,c.type,c.name):null}this.cachePendingValue(a,d,s[a])});const i=this.getPendingAreaRange(),o=t.map(a=>ae.intersection(i,a)).filter(a=>a!=null).map(a=>(k(a),ae.offset(a,0,-(this.floatingTopRowCount+this.table.size))));if(o.length>0){const a=new Map(this.pendingNewDataMap);ae.forEachCell(o,(d,c)=>{a.has(c)||a.set(c,{data:new Map});const u=this.columns[d],m=a.get(c);k(m);const{data:p}=m,g=new Map(p),f=_.makeValue(u.type,e,this.formatter.timeZone);f!=null?g.set(d,{value:f}):g.delete(d),g.size>0?a.set(c,{...m,data:g}):a.delete(c)}),this.pendingDataMap=a}this.dispatchEvent(new Ke(Ce.EVENT.UPDATED));const r=this.getTableAreaRange(),l=t.map(a=>ae.intersection(r,a)).filter(a=>a!=null);if(l.length>0){const d=(await this.snapshot(l.map(u=>new ae(null,u?.startRow??null,null,u?.endRow??null)))).map(u=>{const m={};for(let p=0;p<this.columns.length;p+=1)m[this.columns[p].name]=u[p];return n.forEach(p=>{m[p.name]=_.makeValue(p.type,e,this.formatter.timeZone)}),m}),c=await this.inputTable?.addRows(d);ot.debug("setValueForRanges(",t,",",e,") set tableRanges",l,"result",c)}ae.forEachCell(t,(a,d)=>{const c=s[a];k(c),this.cacheFormattedValue(a,d,c)})}catch(n){ot.error("Unable to set ranges",t,e,n)}finally{ae.forEachCell(t,(n,s)=>{this.clearPendingValue(n,s)})}}async setValues(t=[]){if(ot.debug("setValues(",t,")"),!t.every(e=>this.isEditableRange(ae.makeCell(e.column??e.x,e.row??e.y))))throw new Error(`Uneditable ranges ${t}`);try{const e=new Map(this.pendingNewDataMap);t.forEach(r=>{const{text:l}=r,a=r.column??r.x,d=r.row??r.y,c=this.columns[a],u=_.makeValue(c.type,l,this.formatter.timeZone),m=u!=null?this.displayString(u,c.type,c.name):null;this.cachePendingValue(a,d,m);const p=this.pendingRow(d);if(p!=null){e.has(p)||e.set(p,{data:new Map});const g=e.get(p);k(g);const{data:f}=g,C=new Map(f);u!=null?C.set(a,{value:u}):C.delete(a),C.size>0?e.set(p,{...g,data:C}):e.delete(p)}}),this.pendingDataMap=e,this.dispatchEvent(new Ke(Ce.EVENT.UPDATED));const n=t.reduce((r,l)=>{const a=l.row??l.y;return r.has(a)||r.set(a,[]),r.get(a)?.push(l),r},new Map),s=ae.consolidate(t.map(r=>ae.makeCell(r.column??r.x,r.row??r.y))),i=this.getTableAreaRange(),o=s.map(r=>ae.intersection(i,r)).filter(r=>r!=null);if(o.length>0){const l=(await this.snapshot(o.map(d=>(k(d),new ae(null,d.startRow,null,d.endRow))))).map((d,c)=>{let u=null,m=c;for(let f=0;f<o.length;f+=1){const C=o[f];k(C);const S=ae.rowCount([C]);if(m<S){k(C.startRow),u=C.startRow+m;break}m-=S}const p={};for(let f=0;f<this.columns.length;f+=1)p[this.columns[f].name]=d[f];k(u);const g=n.get(u);return g?.forEach(f=>{const C=this.columns[f.column??f.x];p[C.name]=_.makeValue(C.type,f.text,this.formatter.timeZone)}),p});ot.info("setValues setting tableRanges",o);const a=await this.inputTable?.addRows(l);ot.info("setValues set tableRanges",o,"SUCCESS",a)}t.forEach(r=>{const{text:l}=r,a=r.column??r.x,d=r.row??r.y,c=this.columns[a],u=_.makeValue(c.type,l,this.formatter.timeZone),m=u!=null?this.displayString(u,c.type,c.name):null;this.cacheFormattedValue(a,d,m)})}finally{t.forEach(e=>{this.clearPendingValue(e.column,e.row)})}}async commitPending(){if(this.pendingNewDataMap.size<=0)throw new Error("No pending changes to commit");try{this.isSaveInProgress=!0;const t=[];this.pendingNewDataMap.forEach(n=>{const s={};n.data.forEach(({value:i},o)=>{const r=this.columns[o];s[r.name]=i}),t.push(s)});const e=await this.inputTable?.addRows(t);ot.debug("commitPending()",this.pendingNewDataMap,"result",e),this.pendingNewDataMap=new Map,this.pendingNewRowCount=Math.max(0,(this.viewport?.bottom??0)-this.table.size),this.formattedStringData=[],this.dispatchEvent(new Ke(Ce.EVENT.PENDING_DATA_UPDATED))}finally{this.isSaveInProgress=!1}}editValueForCell(t,e){return this.textValueForCell(t,e)}async delete(t){if(!this.isDeletableRanges(t))throw new Error(`Undeletable ranges ${t}`);k(this.inputTable);const{keyColumns:e}=this.inputTable;if(e.length===0)throw new Error("No key columns to allow deletion");const n=this.getPendingAreaRange(),s=t.map(c=>ae.intersection(n,c)).filter(c=>c!=null).map(c=>(k(c),ae.offset(c,0,-(this.floatingTopRowCount+this.table.size))));if(s.length>0){const c=new Map(this.pendingNewDataMap);for(let u=0;u<s.length;u+=1){const m=s[u];k(m.startRow),k(m.endRow);for(let p=m.startRow;p<=m.endRow;p+=1)c.delete(p)}this.pendingNewDataMap=c,this.formattedStringData=[],this.dispatchEvent(new Ke(Ce.EVENT.PENDING_DATA_UPDATED)),this.dispatchEvent(new Ke(Ce.EVENT.UPDATED))}const i=this.getTableAreaRange(),o=t.map(c=>ae.intersection(i,c)).filter(c=>c!=null);if(o.length<=0)return;const[r,l]=await Promise.all([this.snapshot(o.map(c=>(k(c),new ae(0,c.startRow,e.length-1,c.endRow)))),this.table.copy()]),d=r.map(c=>{const u=[];for(let m=0;m<e.length;m+=1){const p=e[m],g=c[m],f=_.makeFilterRawValue(p.type,g),C=p.filter().eq(f);u.push(C)}return u.reduce((m,p)=>m?.and(p)??p)}).reduce((c,u)=>c?.or(u)??u);l.applyFilter([d]),l.close()}isValidForCell(t,e,n){try{const s=this.columns[t];return _.makeValue(s.type,n,this.formatter.timeZone),!0}catch{return!1}}};let fd=Ea;fd.ROW_BUFFER_PAGES=1;const vs=J.module("IrisGridTableModel");class Nm extends fd{constructor(e,n=new nn,s=null){super(e,n,s),this.getMemoizedFrontColumns=ge(i=>i??[]),this.getMemoizedBackColumns=ge(i=>i??[]),this.getMemoizedFrozenColumns=ge((i,o)=>o??i??[]),this.getCachedFilterableColumnSet=ge(i=>new Set(i.map((o,r)=>r))),this.customColumnList=[],this.formatColumnList=[]}get isExportAvailable(){return this.table.freeze!=null}get isColumnStatisticsAvailable(){return this.table.getColumnStatistics!=null}get isValuesTableAvailable(){return this.table.selectDistinct!=null&&this.table.copy!=null}get isRollupAvailable(){return this.table.rollup!=null}get isSelectDistinctAvailable(){return this.table.selectDistinct!=null}get isCustomColumnsAvailable(){return this.table.applyCustomColumns!=null}get isFormatColumnsAvailable(){return this.table.applyCustomColumns!=null}get frontColumns(){return this.getMemoizedFrontColumns(this.layoutHints?.frontColumns)}get backColumns(){return this.getMemoizedBackColumns(this.layoutHints?.backColumns)}get frozenColumns(){return this.getMemoizedFrozenColumns(this.layoutHints?.frozenColumns,this.userFrozenColumns)}get layoutHints(){return this.table.layoutHints}get floatingLeftColumnCount(){return this.frozenColumns.length}get description(){return this.table.description}get customColumns(){return this.customColumnList}set customColumns(e){if(vs.debug2("set customColumns",e,this.customColumnList,e===this.customColumnList),this.customColumnList.length===0&&e.length===0){vs.debug("Ignore empty initial customColumns"),this.customColumnList=e;return}if(this.customColumnList===e){vs.debug("Ignore same customColumns");return}this.closeSubscription(),this.customColumnList=e,this.table.applyCustomColumns([...e,...this.formatColumns]),this.applyViewport()}get formatColumns(){return this.formatColumnList}set formatColumns(e){if(vs.debug2("set formatColumns",e,this.formatColumnList,e===this.formatColumnList),this.formatColumnList.length===0&&e.length===0){vs.debug("Ignore empty initial formatColumns"),this.formatColumnList=e;return}if(this.formatColumnList===e){vs.debug("Ignore same formatColumns");return}this.closeSubscription(),this.formatColumnList=e,this.table.applyCustomColumns([...this.customColumns,...e]),this.applyViewport()}updateFrozenColumns(e){this.userFrozenColumns=e,this.dispatchEvent(new Ke(Ce.EVENT.TABLE_CHANGED,{detail:this.table}))}set totalsConfig(e){if(vs.debug("set totalsConfig",e),e!==this.totals){if(this.totals=e,this.formattedStringData=[],this.totalsTablePromise!=null&&this.totalsTablePromise.cancel(),this.setTotalsTable(null),e==null){this.dispatchEvent(new Ke(Ce.EVENT.UPDATED));return}this.totalsTablePromise=ye.makeCancelable(this.table.getTotalsTable(e),n=>n.close()),this.totalsTablePromise.then(n=>{this.totalsTablePromise=null,this.setTotalsTable(n)}).catch(n=>{ye.isCanceled(n)||(vs.error("Unable to set next totalsTable",n),this.totalsTablePromise=null,this.dispatchEvent(new Ke(Ce.EVENT.REQUEST_FAILED,{detail:n})))})}}get isFilterRequired(){return this.table.isUncoalesced}isFilterable(e){return this.getCachedFilterableColumnSet(this.columns).has(e)}async export(){return this.table.freeze()}columnStatistics(e){return this.table.getColumnStatistics(e)}isColumnMovable(e){const n=this.columns[e].name;return this.frontColumns.includes(n)||this.backColumns.includes(n)||this.frozenColumns.includes(n)?!1:!this.isKeyColumn(e)}isColumnFrozen(e){return this.frozenColumns.includes(this.columns[e].name)}async delete(e){if(!this.isDeletableRanges(e))throw new Error(`Undeletable ranges ${e}`);k(this.inputTable);const{keyColumns:n}=this.inputTable;if(n.length===0)throw new Error("No key columns to allow deletion");const s=this.getPendingAreaRange(),i=e.map(u=>ae.intersection(s,u)).filter(u=>u!=null).map(u=>(k(u),ae.offset(u,0,-(this.floatingTopRowCount+this.table.size))));if(i.length>0){const u=new Map(super.pendingDataMap);for(let m=0;m<i.length;m+=1){const p=i[m];k(p.startRow),k(p.endRow);for(let g=p.startRow;g<=p.endRow;g+=1)u.delete(g)}super.pendingDataMap=u,this.formattedStringData=[],this.dispatchEvent(new Ke(Ce.EVENT.PENDING_DATA_UPDATED)),this.dispatchEvent(new Ke(Ce.EVENT.UPDATED))}const o=this.getTableAreaRange(),r=e.map(u=>ae.intersection(o,u)).filter(u=>u!=null);if(r.length<=0)return;const[l,a]=await Promise.all([this.snapshot(r.map(u=>(k(u),new ae(0,u.startRow,n.length-1,u.endRow)))),this.table.copy()]),c=l.map(u=>{const m=[];for(let p=0;p<n.length;p+=1){const g=n[p],f=u[p],C=_.makeFilterRawValue(g.type,f),S=g.filter().eq(C);m.push(S)}return m.reduce((p,g)=>p?.and(g)??g)}).reduce((u,m)=>u?.or(m)??m);a.applyFilter([c]),await this.inputTable?.deleteTable(a),a.close()}async seekRow(e,n,s,i,o,r,l){return this.table.seekRow(e,n,s,i,o,r,l)}get isSeekRowAvailable(){return this.table.seekRow!=null}}class sE extends fd{constructor(){super(...arguments),this.getCachedFilterableColumnSet=ge((e,n)=>new Set((n?.length>0?n:e).map(s=>e.findIndex(i=>s.name===i.name))))}applyBufferedViewport(e,n,s){this.table.setViewport(e,n,s)}textForCell(e,n){const s=this.columns[e],i=this.row(n);if(i!=null&&s!=null&&!i.hasChildren&&s.constituentType!=null){const o=this.valueForCell(e,n);return this.displayString(o,s.constituentType,s.name)}return super.textForCell(e,n)}extractViewportRow(e,n){const{isExpanded:s,hasChildren:i,depth:o}=e;return{...super.extractViewportRow(e,n),isExpanded:s,hasChildren:i,depth:o}}async snapshot(e,n,s){k(this.viewport),k(this.viewportData);const{columns:i}=this.viewport,o=[];n!=null&&n&&o.push(i.map(l=>l.name));const r=new ae(0,this.viewportData?.offset,i.length,this.viewportData.offset+this.viewportData.rows.length);for(let l=0;l<e.length;l+=1){const a=ae.intersection(r,e[l]);k(a),k(a.startRow),k(a.endRow);for(let d=a.startRow;d<=a.endRow;d+=1){const c=[],u=this.viewportData.rows[d-this.viewportData.offset];k(a.startColumn),k(a.endColumn);for(let m=a.startColumn;m<=a.endColumn;m+=1)k(s),c.push(s(u.data.get(m)?.value,this.columns[m]));o.push(c)}}return o}get groupedColumns(){return this.table.groupedColumns}get hasExpandableRows(){return!0}get isExpandAllAvailable(){return this.table.expandAll!==void 0}get isChartBuilderAvailable(){return!1}get isSelectDistinctAvailable(){return!1}get isReversible(){return!1}isFilterable(e){return this.getCachedFilterableColumnSet(this.columns,this.groupedColumns).has(e)}isColumnMovable(e){return e>=this.groupedColumns.length}isRowExpandable(e){return this.row(e)?.hasChildren??!1}isRowExpanded(e){return this.row(e)?.isExpanded??!1}setRowExpanded(e,n,s=!1){this.isExpandAllAvailable?this.table.setExpanded(e,n,s):this.table.setExpanded(e,n)}expandAll(){this.table.expandAll&&this.table.expandAll()}collapseAll(){this.table.collapseAll&&this.table.collapseAll()}depthForRow(e){return(this.row(e)?.depth??1)-1}}const Es=J.module("IrisGridProxyModel");function ta(t,e,n){return _.isTreeTable(t)?new sE(t,e):new Nm(t,e,n)}class iE extends Ce{constructor(e,n=new nn,s=null){super(),this.textForCell=(...o)=>this.model.textForCell(...o),this.truncationCharForCell=(...o)=>this.model.truncationCharForCell(...o),this.textAlignForCell=(...o)=>this.model.textAlignForCell(...o),this.colorForCell=(...o)=>this.model.colorForCell(...o),this.backgroundColorForCell=(...o)=>this.model.backgroundColorForCell(...o),this.textForColumnHeader=(...o)=>this.model.textForColumnHeader(...o),this.colorForColumnHeader=(...o)=>this.model.colorForColumnHeader(...o),this.textForRowHeader=(...o)=>this.model.textForRowHeader(...o),this.textForRowFooter=(...o)=>this.model.textForRowFooter(...o),this.isRowMovable=(...o)=>this.model.isRowMovable(...o),this.isColumnMovable=(...o)=>this.model.isColumnMovable(...o),this.isRowExpandable=(...o)=>ze(this.model)?this.model.isRowExpandable(...o):!1,this.isRowExpanded=(...o)=>ze(this.model)?this.model.isRowExpanded(...o):!1,this.setRowExpanded=(...o)=>{if(ze(this.model))return this.model.setRowExpanded(...o);throw Error("Function setRowExpanded does not exist on IrisGridTableModel")},this.expandAll=()=>{if(ze(this.model))return this.model.expandAll();throw Error("Function expandAll does not exist on IrisGridTableModel")},this.collapseAll=()=>{if(ze(this.model))return this.model.collapseAll();throw Error("Function collapseAll does not exist on IrisGridTableModel")},this.depthForRow=(...o)=>ze(this.model)?this.model.depthForRow(...o):0,this.getColumnHeaderGroup=(...o)=>this.model.getColumnHeaderGroup(...o),this.getColumnHeaderParentGroup=(...o)=>this.model.getColumnHeaderParentGroup(...o),this.formatForCell=(...o)=>this.model.formatForCell(...o),this.valueForCell=(...o)=>this.model.valueForCell(...o),this.displayString=(...o)=>this.model.displayString(...o),this.isEditableRange=(...o)=>tt(this.model)?this.model.isEditableRange(...o):!1,this.isFilterable=(...o)=>this.model.isFilterable(...o),this.setViewport=(o,r,l)=>this.model.setViewport(o,r,l),this.snapshot=(...o)=>this.model.snapshot(...o),this.textSnapshot=(...o)=>this.model.textSnapshot(...o),this.valuesTable=(...o)=>this.model.valuesTable(...o),this.editValueForCell=(...o)=>(tt(this.model)&&this.model.editValueForCell(...o),""),this.setValueForCell=(...o)=>tt(this.model)?this.model.setValueForCell(...o):Promise.reject(new Error("Model is not editable")),this.setValueForRanges=(...o)=>tt(this.model)?this.model.setValueForRanges(...o):Promise.reject(new Error("Model is not editable")),this.setValues=(...o)=>tt(this.model)?this.model.setValues(...o):Promise.resolve(),this.isValidForCell=(...o)=>tt(this.model)?this.model.isValidForCell(...o):!1,this.delete=(...o)=>this.model.delete(...o),this.commitPending=(...o)=>this.model.commitPending(...o),this.handleModelEvent=this.handleModelEvent.bind(this);const i=ta(e,n,s);this.originalModel=i,this.model=i,this.modelPromise=null,this.rollup=null,this.selectDistinct=[]}close(){this.originalModel.close(),this.model!==this.originalModel&&this.model.close(),this.modelPromise!=null&&this.modelPromise.cancel()}handleModelEvent(e){Es.debug2("handleModelEvent",e);const{detail:n,type:s}=e;this.dispatchEvent(new Ke(s,{detail:n}))}setModel(e){Es.debug("setModel",e);const n=this.model;n!==this.originalModel&&n.close(),this.model=e,this.listenerCount>0&&this.addListeners(e),this.dispatchEvent(new Ke(Ce.EVENT.COLUMNS_CHANGED,{detail:e.columns})),si(e)&&this.dispatchEvent(new Ke(Ce.EVENT.TABLE_CHANGED,{detail:e.table}))}setNextModel(e){Es.debug2("setNextModel"),this.modelPromise&&this.modelPromise.cancel(),this.listenerCount>0&&this.removeListeners(this.model),this.modelPromise=ye.makeCancelable(e,n=>n.close()),this.modelPromise.then(n=>{this.modelPromise=null,this.setModel(n)}).catch(n=>{if(ye.isCanceled(n)){Es.debug2("setNextModel cancelled");return}Es.error("Unable to set next model",n),this.modelPromise=null,this.dispatchEvent(new Ke(Ce.EVENT.REQUEST_FAILED,{detail:n}))})}startListening(){super.startListening(),this.addListeners(this.model)}stopListening(){super.stopListening(),this.removeListeners(this.model)}addListeners(e){const n=Object.keys(Ce.EVENT);for(let s=0;s<n.length;s+=1)e.addEventListener(n[s],this.handleModelEvent)}removeListeners(e){const n=Object.keys(Ce.EVENT);for(let s=0;s<n.length;s+=1)e.removeEventListener(n[s],this.handleModelEvent)}get rowCount(){return this.model.rowCount}get columnCount(){return this.model.columnCount}get floatingTopRowCount(){return this.model.floatingTopRowCount}get floatingBottomRowCount(){return this.model.floatingBottomRowCount}get floatingLeftColumnCount(){return this.model.floatingLeftColumnCount}get floatingRightColumnCount(){return this.model.floatingRightColumnCount}isColumnFrozen(e){return this.model.isColumnFrozen(e)}get hasExpandableRows(){return ze(this.model)?this.model.hasExpandableRows:!1}get isExpandAllAvailable(){return ze(this.model)?this.model.isExpandAllAvailable??!1:!1}get isExportAvailable(){return this.model.isExportAvailable}get isColumnStatisticsAvailable(){return this.model.isColumnStatisticsAvailable}get isValuesTableAvailable(){return this.model.isValuesTableAvailable}get isCustomColumnsAvailable(){return this.model.isCustomColumnsAvailable&&!(this.isSelectDistinctAvailable&&this.selectDistinctColumns.length>0)}get isFormatColumnsAvailable(){return this.model.isFormatColumnsAvailable}get isChartBuilderAvailable(){return this.model.isChartBuilderAvailable}get isRollupAvailable(){return(this.originalModel.isRollupAvailable||this.rollup!=null)&&this.selectDistinct.length===0}get isSelectDistinctAvailable(){return(this.originalModel.isSelectDistinctAvailable||this.selectDistinct.length>0)&&this.rollup==null}get isTotalsAvailable(){return this.model.isTotalsAvailable}get isReversible(){return this.model.isReversible}get columns(){return this.model.columns}get initialMovedColumns(){return this.model.initialMovedColumns}get initialMovedRows(){return this.model.initialMovedRows}get layoutHints(){return this.model.layoutHints}get frontColumns(){return this.model.frontColumns}get backColumns(){return this.model.backColumns}get frozenColumns(){return this.model.frozenColumns}get columnHeaderGroups(){return this.model.columnHeaderGroups}set columnHeaderGroups(e){this.model.columnHeaderGroups=e}get initialColumnHeaderGroups(){return this.model.initialColumnHeaderGroups}get columnHeaderGroupMap(){return this.model.columnHeaderGroupMap}get columnHeaderMaxDepth(){return this.model.columnHeaderMaxDepth}updateFrozenColumns(e){return this.model.updateFrozenColumns(e)}get originalColumns(){return this.originalModel.columns}get groupedColumns(){return this.model.groupedColumns}get description(){return this.model.description}get filter(){return this.model.filter}set filter(e){this.model.filter=e}get formatter(){return this.model.formatter}set formatter(e){this.model.formatter=e}get sort(){return this.model.sort}set sort(e){this.model.sort=e}get customColumns(){return this.model.customColumns}set customColumns(e){this.model.customColumns=e}get formatColumns(){return this.model.formatColumns}set formatColumns(e){this.model.formatColumns=e}get rollupConfig(){return this.rollup}set rollupConfig(e){if(Es.debug("set rollupConfig",e),!this.isRollupAvailable)throw new Error("Rollup Rows are not available");if(ct(e,this.rollup))return;this.rollup=e;let n=Promise.resolve(this.originalModel);si(this.originalModel)&&e!=null&&(n=this.originalModel.table.rollup(e).then(s=>ta(s,this.formatter))),this.setNextModel(n)}get selectDistinctColumns(){return this.selectDistinct}set selectDistinctColumns(e){if(Es.debug("set selectDistinctColumns",e),!this.isSelectDistinctAvailable)throw new Error("Select distinct is not available");if(e===this.selectDistinctColumns||e.length===0&&this.selectDistinctColumns.length===0){Es.debug("Ignore same selectDistinctColumns",e);return}this.selectDistinct=e;const n=e.map(i=>this.originalColumns.find(o=>o.name===i)).filter(i=>i!=null);let s=Promise.resolve(this.originalModel);si(this.originalModel)&&n.length>0&&(s=this.originalModel.table.selectDistinct(n).then(i=>ta(i,this.formatter))),this.setNextModel(s)}get table(){if(si(this.model))return this.model.table}get totalsConfig(){return this.model.totalsConfig}set totalsConfig(e){this.model.totalsConfig=e}get isFilterRequired(){return this.model.isFilterRequired}get isEditable(){return tt(this.model)&&this.model.isEditable}export(){if(_.isTreeTable(this.model))throw new Error("TreeTable has no 'export' property");return this.model.export()}columnStatistics(e){if(_.isTreeTable(this.model))throw new Error("TreeTable has no 'columnStatistics' function");return this.model.columnStatistics(e)}get pendingDataMap(){return this.model.pendingDataMap}set pendingDataMap(e){this.model.pendingDataMap=e}get pendingRowCount(){return this.model.pendingRowCount}set pendingRowCount(e){this.model.pendingRowCount=e}get pendingDataErrors(){return this.model.pendingDataErrors}getColumnIndexByName(e){return this.model.getColumnIndexByName(e)}async seekRow(e,n,s,i,o,r,l){return this.model.seekRow(e,n,s,i,o,r,l)}get isSeekRowAvailable(){return this.model.isSeekRowAvailable}}class Cd{static async makeModel(e,n=new nn){let s=null;return!_.isTreeTable(e)&&e.hasInputTable&&(s=await e.inputTable()),new iE(e,n,s)}}const Kn=J.module("TableViewportUpdater"),oE=150,bo=class extends b.exports.PureComponent{constructor(){super(...arguments),this.getViewportRowRange=ge((t,e,n)=>{const s=n-e,i=Math.max(0,e-s*bo.ROW_BUFFER_PAGES),o=n+s*bo.ROW_BUFFER_PAGES;return[i,o]}),this.getViewportColumns=ge((t,e,n,s)=>{if(e==null||n==null)return null;const i=n-e,o=Math.max(0,e-i*bo.COLUMN_BUFFER_PAGES),r=Math.min(n+i*bo.COLUMN_BUFFER_PAGES,t.columns.length-1),l=[];for(let a=o;a<=r;a+=1){const d=z.getModelIndex(a,s);l.push(t.columns[d])}return l}),this.updateViewport=Ln((t,e,n,s,i)=>{if(e<t){Kn.error("Invalid viewport",t,e);return}if(t===0&&e===0){Kn.debug2("Ignoring 0-0 viewport");return}const{movedColumns:o,table:r}=this.props,[l,a]=this.getViewportRowRange(r,t,e),d=i??this.getViewportColumns(r,n,s,o);if(Kn.debug2("Setting Viewport Top:",l,"Bottom:",a,"Columns:",d),this.subscription==null){Kn.debug2("updateViewport creating new subscription"),this.subscription=r.setViewport(l,a,d);const{onSubscription:c}=this.props;c(this.subscription)}else Kn.debug2("updateViewport using existing subscription"),this.subscription.setViewport(l,a,d)},oE)}componentDidMount(){const{top:t,bottom:e,left:n,right:s,table:i,filters:o,sorts:r,columns:l,customColumns:a}=this.props;i.applyFilter(o),i.applySort(r),i.applyCustomColumns(a),this.updateViewport(t,e,n,s,l)}componentDidUpdate(t){const{top:e,bottom:n,left:s,right:i,table:o,filters:r,sorts:l,customColumns:a,columns:d}=this.props,c=r!==t.filters,u=l!==t.sorts,m=a!==t.customColumns,p=o!==t.table;(c||u||m||p)&&this.closeSubscription(),(c||p)&&(Kn.debug("update table filter",r),o.applyFilter(r)),(u||p)&&(Kn.debug("update table sort",l),o.applySort(l)),(m||p)&&(Kn.debug("update table custom columns",a),o.applyCustomColumns(a)),this.updateViewport(e,n,s,i,d)}componentWillUnmount(){this.closeSubscription()}closeSubscription(){if(Kn.debug2("closeSubscription",this.subscription),this.subscription){this.subscription.close(),this.subscription=void 0;const{onSubscription:t}=this.props;t()}this.updateViewport.cancel()}render(){return null}};let Sd=bo;Sd.ROW_BUFFER_PAGES=3;Sd.COLUMN_BUFFER_PAGES=1;Sd.defaultProps={top:0,bottom:0,left:null,right:null,columns:null,onSubscription:()=>{},filters:[],sorts:[],customColumns:[],movedColumns:[]};const bi=J.module("TreeTableViewportUpdater"),rE=150,_m=class extends b.exports.PureComponent{constructor(t){super(t),this.updateViewport=Ln((e,n)=>{if(n<e){bi.error("Invalid viewport",e,n);return}if(e===0&&n===0){bi.debug2("Ignoring 0-0 viewport");return}const{table:s,updateInterval:i}=this.props,o=n-e,r=Math.max(0,e-o*3),l=n+o*3+1;if(bi.debug2("Setting Viewport Top:",r,"Bottom:",l,s),!this.listenerCleanup){const{onViewportUpdate:a}=this.props;this.listenerCleanup=s.addEventListener(I.TreeTable.EVENT_UPDATED,a)}s.setViewport(r,l,void 0,i)},rE),this.listenerCleanup=null}componentDidMount(){const{top:t,bottom:e,table:n,filters:s,sorts:i}=this.props;bi.debug("componentDidMount",this.props),n.applyFilter(s),n.applySort(i),this.updateViewport(t,e)}componentDidUpdate(t){const{top:e,bottom:n,table:s,filters:i,sorts:o}=this.props;i!==t.filters&&(bi.debug("update table filter",i),s.applyFilter(i)),o!==t.sorts&&(bi.debug("update table sort",o),s.applySort(o)),this.updateViewport(e,n)}componentWillUnmount(){this.updateViewport.cancel(),this.listenerCleanup&&this.listenerCleanup()}render(){return null}};let Mm=_m;Mm.UPDATE_INTERVAL=1e3;Mm.defaultProps={top:0,bottom:0,onViewportUpdate:()=>{},filters:[],sorts:[],updateInterval:_m.UPDATE_INTERVAL};class Li{}Li.OPEN="ChartEvent.OPEN";Li.CLOSE="ChartEvent.CLOSE";Li.COLUMN_SELECTED="ChartEvent.COLUMN_SELECTED";class gt{}gt.SESSION_OPENED="ConsoleEvent.SESSION_OPENED";gt.SESSION_CLOSED="ConsoleEvent.SESSION_CLOSED";gt.FOCUS_HISTORY="ConsoleEvent.FOCUS_HISTORY";gt.SEND_COMMAND="ConsoleEvent.SEND_COMMAND";gt.SETTINGS_CHANGED="ConsoleEvent.SETTINGS_CHANGED";class Le{}Le.TABLE_CHANGED="InputFilterEvent.TABLE_CHANGED";Le.COLUMNS_CHANGED="InputFilterEvent.COLUMNS_CHANGED";Le.FILTERS_CHANGED="InputFilterEvent.FILTERS_CHANGED";Le.CLEAR_ALL_FILTERS="InputFilterEvent.CLEAR_ALL_FILTERS";Le.COLUMN_SELECTED="InputFilterEvent.COLUMN_SELECTED";Le.OPEN_DROPDOWN="InputFilterEvent.OPEN_DROPDOWN";Le.OPEN_INPUT="InputFilterEvent.OPEN_INPUT";Le.OPEN_FILTER_SET_MANAGER="InputFilterEvent.OPEN_FILTER_SET_MANAGER";class wt{}wt.OPEN_GRID="IrisGridEvent.OPEN_GRID";wt.CLOSE_GRID="IrisGridEvent.CLOSE_GRID";wt.DATA_SELECTED="IrisGridEvent.DATA_SELECTED";wt.COLUMN_SELECTED="IrisGridEvent.COLUMN_SELECTED";wt.STATE_CHANGED="IrisGridEvent.STATE_CHANGED";wt.CREATE_CHART="IrisGridevent.CREATE_CHART";const km=Object.freeze({OPEN:"MarkdownEvent.OPEN"});class Ae{}Ae.CREATE_NOTEBOOK="NotebookEvent.createNotebook";Ae.SELECT_NOTEBOOK="NotebookEvent.selectNotebook";Ae.CLOSE_FILE="NotebookEvent.closeFile";Ae.RENAME="NotebookEvent.rename";Ae.RENAME_FILE="NotebookEvent.renameFile";Ae.REGISTER_FILE="NotebookEvent.registerFile";Ae.SEND_TO_NOTEBOOK="NotebookEvent.sendToNotebook";Ae.UNREGISTER_FILE="NotebookEvent.unregisterFile";class On{}On.focus="TabEvent.focus";On.blur="TabEvent.blur";On.openPQObject="TabEvent.openPQObject";On.openControl="TabEvent.openControl";On.reload="TabEvent.reload";On.clearAllFilters="TabEvent.clearAllFilters";class xm extends b.exports.PureComponent{constructor(e){super(e),this.handleCloseTab=this.handleCloseTab.bind(this),this.handleCloseTabsRight=this.handleCloseTabsRight.bind(this),this.handleCloseTabsAll=this.handleCloseTabsAll.bind(this)}getAllTabs(){const{glContainer:e}=this.props;return[...e?.tab?.header?.tabs??[]]}handleCloseTab(){const{glContainer:e}=this.props;e.close()}handleCloseTabsAll(){this.getAllTabs().forEach(n=>(n?.contentItem).container?.close())}handleCloseTabsRight(){const{glContainer:e}=this.props,n=this.getAllTabs();for(let s=n.length-1;s>0&&n[s].contentItem?.config?.id!==e.tab?.contentItem?.config?.id;s-=1)(n[s]?.contentItem).container?.close()}canCloseTabsRight(){const{glContainer:e}=this.props,n=this.getAllTabs();let s=!0;for(let i=n.length-1;i>0&&n[i].contentItem?.config?.id!==e.tab?.contentItem?.config?.id;i-=1)if(Boolean(n[i]?.contentItem?.config?.isClosable)){s=!1;break}return s}canCloseAny(){const e=this.getAllTabs();let n=!0;for(let s=e.length-1;s>0;s-=1)if(Boolean(e[s]?.contentItem?.config?.isClosable)){n=!1;break}return n}render(){const{additionalActions:e,glContainer:n}=this.props,s=[...e],i=n.tab?.contentItem?.config?.isClosable;return s.push({title:"Close",order:10,group:le.groups.low,action:this.handleCloseTab,disabled:i===void 0||!i}),s.push(()=>({title:"Close Tabs to Right",order:20,group:le.groups.low,action:this.handleCloseTabsRight,disabled:this.canCloseTabsRight()})),s.push(()=>({title:"Close All",order:30,group:le.groups.low,action:this.handleCloseTabsAll,disabled:this.canCloseAny()})),h(le,{actions:s})}}xm.defaultProps={additionalActions:[]};class Om extends b.exports.PureComponent{constructor(e){super(e),this.handleRenameDialogOpened=this.handleRenameDialogOpened.bind(this),this.handleRenameInputChange=this.handleRenameInputChange.bind(this),this.handleRenameCancel=this.handleRenameCancel.bind(this),this.handleRenameSubmit=this.handleRenameSubmit.bind(this),this.renameInputRef=de.createRef();const{value:n}=e;this.state={value:n,valueWasValidated:!1}}componentDidUpdate(e){const{isShown:n}=e,{isShown:s}=this.props;s&&!n&&this.resetState()}resetState(){const{value:e}=this.props;this.setState({value:e,valueWasValidated:!1})}handleRenameDialogOpened(){this.renameInputRef?.current?.focus()}handleRenameInputChange(e){this.setState({value:e.target.value})}handleRenameCancel(){const{onCancel:e}=this.props;e()}handleRenameSubmit(e){e.stopPropagation(),e.preventDefault();const{value:n}=this.state,s=n?.trim();if(s!==void 0&&s!==""){const{onSubmit:i}=this.props;i(s)}else this.setState({value:s,valueWasValidated:!0})}renderRenameDialog(){const{isShared:e,isOwner:n,itemType:s}=this.props,{value:i,valueWasValidated:o}=this.state;return T("form",{className:Y("p-3",{"was-validated":o}),onSubmit:this.handleRenameSubmit,noValidate:!0,role:"presentation",onMouseDown:r=>{r.stopPropagation()},onMouseUp:r=>{r.stopPropagation()},children:[T("div",{className:"form-group",children:[T("label",{htmlFor:`rename-dialog-${s}-input`,children:["Rename ",s]}),h("input",{type:"text",className:"form-control",id:`rename-dialog-${s}-input`,value:i??void 0,ref:this.renameInputRef,onChange:this.handleRenameInputChange,required:!0}),T("div",{className:"invalid-feedback",children:[s," name cannot be empty"]}),(e||!n)&&T("div",{className:"pt-2",children:["Renaming this ",s," will rename for all users."]})]}),T("div",{className:"text-right",children:[h(U,{kind:"secondary",className:"mr-2",onClick:this.handleRenameCancel,children:"Cancel"}),h(U,{kind:"primary",type:"submit",children:"Rename"})]})]})}render(){const{isShown:e,onCancel:n}=this.props;return h(tl,{isShown:e,onEntered:this.handleRenameDialogOpened,onExited:n,options:{placement:"bottom"},interactive:!0,closeOnBlur:!0,children:this.renderRenameDialog()})}}Om.defaultProps={isShared:!1,isOwner:!0,itemType:"Item",value:""};const lE=J.module("Panel");class $n extends b.exports.PureComponent{constructor(e){super(e),this.getAdditionActions=ge((s,i,o)=>{const r=[];return i&&r.push(this.getCloneAction()),o&&r.push(this.getRenameAction()),[...r,...s]}),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.handleCopyPanel=this.handleCopyPanel.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleHide=this.handleHide.bind(this),this.handleResize=this.handleResize.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleBeforeShow=this.handleBeforeShow.bind(this),this.handleShow=this.handleShow.bind(this),this.handleTabBlur=this.handleTabBlur.bind(this),this.handleTabFocus=this.handleTabFocus.bind(this),this.handleRenameCancel=this.handleRenameCancel.bind(this),this.handleRenameSubmit=this.handleRenameSubmit.bind(this),this.handleShowRenameDialog=this.handleShowRenameDialog.bind(this),this.handleTabClicked=this.handleTabClicked.bind(this),this.handleTab=this.handleTab.bind(this);const{glContainer:n}=this.props;this.state={title:ie.getTitleFromContainer(n),showRenameDialog:!1}}componentDidMount(){const{componentPanel:e,glContainer:n,glEventHub:s}=this.props;n.on("resize",this.handleResize),n.on("show",this.handleBeforeShow),n.on("shown",this.handleShow),n.on("hide",this.handleHide),n.on("tab",this.handleTab),n.on("tabClicked",this.handleTabClicked),s.on(gt.SESSION_CLOSED,this.handleSessionClosed),s.on(gt.SESSION_OPENED,this.handleSessionOpened),s.on(On.focus,this.handleTabFocus),s.on(On.blur,this.handleTabBlur),s.on(Le.CLEAR_ALL_FILTERS,this.handleClearAllFilters),s.emit(Ee.MOUNT,e)}componentWillUnmount(){const{componentPanel:e,glContainer:n,glEventHub:s}=this.props;n.off("resize",this.handleResize),n.off("show",this.handleBeforeShow),n.off("shown",this.handleShow),n.off("hide",this.handleHide),n.off("tab",this.handleTab),n.off("tabClicked",this.handleTabClicked),s.off(gt.SESSION_CLOSED,this.handleSessionClosed),s.off(gt.SESSION_OPENED,this.handleSessionOpened),s.off(On.focus,this.handleTabFocus),s.off(On.blur,this.handleTabBlur),s.off(Le.CLEAR_ALL_FILTERS,this.handleClearAllFilters),s.emit(Ee.UNMOUNT,e)}handleTab(e){e!=null&&this.setState({title:ie.getTitleFromTab(e)}),this.forceUpdate();const{onTab:n}=this.props;n(e)}handleTabClicked(...e){const{onTabClicked:n}=this.props;n(...e)}handleClearAllFilters(...e){const{onClearAllFilters:n}=this.props;n(...e)}handleFocus(e){const{componentPanel:n,glEventHub:s}=this.props;s.emit(Ee.FOCUS,n);const{onFocus:i}=this.props;i(e)}handleBlur(e){const{onBlur:n}=this.props;n(e)}handleHide(...e){const{onHide:n}=this.props;n(...e)}handleResize(...e){const{onResize:n}=this.props;n(...e)}handleSessionClosed(e){const{onSessionClose:n}=this.props;n(e)}handleSessionOpened(e,n){const{onSessionOpen:s}=this.props;s(e,n)}handleBeforeShow(...e){const{onBeforeShow:n}=this.props;n(...e)}handleShow(...e){const{onShow:n}=this.props;n(...e)}handleTabBlur(...e){const{onTabBlur:n}=this.props;n(...e)}handleTabFocus(...e){const{onTabFocus:n}=this.props;n(...e)}handleRenameCancel(){this.setState({showRenameDialog:!1})}handleShowRenameDialog(){this.setState({showRenameDialog:!0})}handleRenameSubmit(e){const{glContainer:n}=this.props;this.setState({showRenameDialog:!1,title:e});const s=ie.getRootFromContainer(n),i=ie.getComponentConfigFromContainer(n);k(i),ie.renameComponent(s,i,e)}handleCopyPanel(){const{glContainer:e,glEventHub:n}=this.props,s=ie.getRootFromContainer(e),i=ie.getComponentConfigFromContainer(e);if(i==null){lE.error("Could not get component config from container",e);return}const o=ie.cloneComponent(s,i);o!==null&&n.emit(Ee.CLONED,this,o)}getCloneAction(){return{title:"Copy Panel",order:10,group:le.groups.high,action:this.handleCopyPanel}}getRenameAction(){return{title:"Rename",order:10,group:le.groups.medium,action:this.handleShowRenameDialog}}render(){const{children:e,className:n,renderTabTooltip:s,glContainer:i,additionalActions:o,errorMessage:r,isLoaded:l,isLoading:a,isClonable:d,isRenamable:c}=this.props,{tab:u}=i,{showRenameDialog:m,title:p}=this.state;return T("div",{className:Y("h-100 w-100 iris-panel",n),onFocusCapture:this.handleFocus,onBlurCapture:this.handleBlur,children:[e,h(Jr,{errorMessage:r,isLoaded:l,isLoading:a}),u!=null&&Nr.createPortal(T(be,{children:[h(xm,{glContainer:i,additionalActions:this.getAdditionActions(o,d,c)}),c&&h(Om,{isShown:m,value:p,itemType:"Panel",onCancel:this.handleRenameCancel,onSubmit:this.handleRenameSubmit}),s!=null&&h(ut,{interactive:!0,options:{placement:"bottom"},popperClassName:"panel-tab-popper",children:s()})]}),u.element[0])]})}}$n.defaultProps={className:"",onTab:()=>{},onTabClicked:()=>{},onClearAllFilters:()=>{},onFocus:()=>{},onBlur:()=>{},onHide:()=>{},onResize:()=>{},onSessionClose:()=>{},onSessionOpen:()=>{},onBeforeShow:()=>{},onShow:()=>{},onTabBlur:()=>{},onTabFocus:()=>{},renderTabTooltip:null,additionalActions:[],errorMessage:null,isLoading:!1,isLoaded:!0,isClonable:!1,isRenamable:!1};function Rl(t){const{widgetType:e,widgetName:n,glContainer:s,description:i,children:o}=t,r=ie.getTitleFromContainer(s);return T("div",{className:"tab-tooltip-container",children:[T("div",{className:"row flex-nowrap align-items-start",children:[h("span",{className:"tab-tooltip-title",children:T("b",{children:[e," Name "]})}),h("span",{className:"tab-tooltip-name",children:n}),h(ll,{className:"tab-tooltip-copy",tooltip:"Copy name",copy:n})]}),n!==r&&T("div",{className:"row",children:[h("span",{className:"tab-tooltip-title",children:h("b",{children:"Display Name"})}),h("span",{className:"tab-tooltip-name",children:r})]}),i&&h("div",{className:"row",children:h("span",{className:"tab-tooltip-description",children:i})}),o]})}Rl.propTypes={glContainer:id.Container.isRequired,widgetType:M.exports.string,widgetName:M.exports.string,description:M.exports.string,children:M.exports.node};Rl.defaultProps={widgetType:"",widgetName:"",description:null,children:null};class Il extends b.exports.PureComponent{constructor(e){super(e),this.getCachedRenderTabTooltip=ge((n,s,i,o,r)=>n?()=>h(Rl,{glContainer:s,widgetType:i,widgetName:o,description:r}):null),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleCopyName=this.handleCopyName.bind(this),this.state={isClientDisconnected:!1,isPanelDisconnected:!1,isWidgetDisconnected:!1,isWaitingForReconnect:!1,isPanelInactive:!1}}handleCopyName(){const{widgetName:e}=this.props;No(e)}getErrorMessage(){const{errorMessage:e}=this.props,{isClientDisconnected:n,isPanelDisconnected:s,isWidgetDisconnected:i,isWaitingForReconnect:o}=this.state;if(e)return`${e}`;if(n&&s&&o)return`Disconnected from server.
31
+ `)}async valuesTable(t){let e=null;try{return e=await this.table.copy(),e.applyFilter([]),e.applySort([]),e.selectDistinct([t])}finally{e?.close()}}isColumnMovable(t,e){if(t<0||t>=this.columnCount)return!1;if(e>0)return!0;const n=this.columns[t].name;return this.frontColumns.includes(n)||this.backColumns.includes(n)||this.frozenColumns.includes(n)||!n?!1:!this.isKeyColumn(t)}isKeyColumn(t){return t<(this.inputTable?.keyColumns.length??0)}isRowMovable(){return!1}isEditableRange(t){return!(this.inputTable==null||!ae.isBounded(t)||!(this.isPendingRow(t.startRow)&&this.isPendingRow(t.endRow)||this.inputTable.keyColumns.length!==0&&t.startColumn>=this.inputTable.keyColumns.length&&t.endColumn>=this.inputTable.keyColumns.length)||t.startRow<this.floatingTopRowCount||t.startRow>=this.floatingTopRowCount+this.table.size+this.pendingRowCount||t.endRow>=this.floatingTopRowCount+this.table.size+this.pendingRowCount)}isDeletableRange(t){return this.inputTable!=null&&t.startRow!=null&&t.endRow!=null&&t.startRow>=this.floatingTopRowCount&&t.startRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount&&t.endRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount}isEditableRanges(t){return t.every(e=>this.isEditableRange(e))}isDeletableRanges(t){return t.every(e=>this.isDeletableRange(e))}getTableAreaRange(){return new ae(null,this.floatingTopRowCount,null,this.floatingTopRowCount+this.table.size-1)}getPendingAreaRange(){return new ae(null,this.floatingTopRowCount+this.table.size,null,this.floatingTopRowCount+this.table.size+this.pendingNewRowCount-1)}async setValueForCell(t,e,n){return this.setValueForRanges([new ae(t,e,t,e)],n)}async setValueForRanges(t,e){if(!this.isEditableRanges(t))throw new Error(`Uneditable ranges ${t}`);try{const n=new Set,s=[];ae.forEachCell(t,(a,d)=>{const c=this.columns[a];if(n.add(c),s[a]===void 0){const u=_.makeValue(c.type,e,this.formatter.timeZone);s[a]=u!=null?this.displayString(u,c.type,c.name):null}this.cachePendingValue(a,d,s[a])});const i=this.getPendingAreaRange(),o=t.map(a=>ae.intersection(i,a)).filter(a=>a!=null).map(a=>(k(a),ae.offset(a,0,-(this.floatingTopRowCount+this.table.size))));if(o.length>0){const a=new Map(this.pendingNewDataMap);ae.forEachCell(o,(d,c)=>{a.has(c)||a.set(c,{data:new Map});const u=this.columns[d],m=a.get(c);k(m);const{data:p}=m,g=new Map(p),f=_.makeValue(u.type,e,this.formatter.timeZone);f!=null?g.set(d,{value:f}):g.delete(d),g.size>0?a.set(c,{...m,data:g}):a.delete(c)}),this.pendingDataMap=a}this.dispatchEvent(new Ke(Ce.EVENT.UPDATED));const r=this.getTableAreaRange(),l=t.map(a=>ae.intersection(r,a)).filter(a=>a!=null);if(l.length>0){const d=(await this.snapshot(l.map(u=>new ae(null,u?.startRow??null,null,u?.endRow??null)))).map(u=>{const m={};for(let p=0;p<this.columns.length;p+=1)m[this.columns[p].name]=u[p];return n.forEach(p=>{m[p.name]=_.makeValue(p.type,e,this.formatter.timeZone)}),m}),c=await this.inputTable?.addRows(d);ot.debug("setValueForRanges(",t,",",e,") set tableRanges",l,"result",c)}ae.forEachCell(t,(a,d)=>{const c=s[a];k(c),this.cacheFormattedValue(a,d,c)})}catch(n){ot.error("Unable to set ranges",t,e,n)}finally{ae.forEachCell(t,(n,s)=>{this.clearPendingValue(n,s)})}}async setValues(t=[]){if(ot.debug("setValues(",t,")"),!t.every(e=>this.isEditableRange(ae.makeCell(e.column??e.x,e.row??e.y))))throw new Error(`Uneditable ranges ${t}`);try{const e=new Map(this.pendingNewDataMap);t.forEach(r=>{const{text:l}=r,a=r.column??r.x,d=r.row??r.y,c=this.columns[a],u=_.makeValue(c.type,l,this.formatter.timeZone),m=u!=null?this.displayString(u,c.type,c.name):null;this.cachePendingValue(a,d,m);const p=this.pendingRow(d);if(p!=null){e.has(p)||e.set(p,{data:new Map});const g=e.get(p);k(g);const{data:f}=g,C=new Map(f);u!=null?C.set(a,{value:u}):C.delete(a),C.size>0?e.set(p,{...g,data:C}):e.delete(p)}}),this.pendingDataMap=e,this.dispatchEvent(new Ke(Ce.EVENT.UPDATED));const n=t.reduce((r,l)=>{const a=l.row??l.y;return r.has(a)||r.set(a,[]),r.get(a)?.push(l),r},new Map),s=ae.consolidate(t.map(r=>ae.makeCell(r.column??r.x,r.row??r.y))),i=this.getTableAreaRange(),o=s.map(r=>ae.intersection(i,r)).filter(r=>r!=null);if(o.length>0){const l=(await this.snapshot(o.map(d=>(k(d),new ae(null,d.startRow,null,d.endRow))))).map((d,c)=>{let u=null,m=c;for(let f=0;f<o.length;f+=1){const C=o[f];k(C);const S=ae.rowCount([C]);if(m<S){k(C.startRow),u=C.startRow+m;break}m-=S}const p={};for(let f=0;f<this.columns.length;f+=1)p[this.columns[f].name]=d[f];k(u);const g=n.get(u);return g?.forEach(f=>{const C=this.columns[f.column??f.x];p[C.name]=_.makeValue(C.type,f.text,this.formatter.timeZone)}),p});ot.info("setValues setting tableRanges",o);const a=await this.inputTable?.addRows(l);ot.info("setValues set tableRanges",o,"SUCCESS",a)}t.forEach(r=>{const{text:l}=r,a=r.column??r.x,d=r.row??r.y,c=this.columns[a],u=_.makeValue(c.type,l,this.formatter.timeZone),m=u!=null?this.displayString(u,c.type,c.name):null;this.cacheFormattedValue(a,d,m)})}finally{t.forEach(e=>{this.clearPendingValue(e.column,e.row)})}}async commitPending(){if(this.pendingNewDataMap.size<=0)throw new Error("No pending changes to commit");try{this.isSaveInProgress=!0;const t=[];this.pendingNewDataMap.forEach(n=>{const s={};n.data.forEach(({value:i},o)=>{const r=this.columns[o];s[r.name]=i}),t.push(s)});const e=await this.inputTable?.addRows(t);ot.debug("commitPending()",this.pendingNewDataMap,"result",e),this.pendingNewDataMap=new Map,this.pendingNewRowCount=Math.max(0,(this.viewport?.bottom??0)-this.table.size),this.formattedStringData=[],this.dispatchEvent(new Ke(Ce.EVENT.PENDING_DATA_UPDATED))}finally{this.isSaveInProgress=!1}}editValueForCell(t,e){return this.textValueForCell(t,e)}async delete(t){if(!this.isDeletableRanges(t))throw new Error(`Undeletable ranges ${t}`);k(this.inputTable);const{keyColumns:e}=this.inputTable;if(e.length===0)throw new Error("No key columns to allow deletion");const n=this.getPendingAreaRange(),s=t.map(c=>ae.intersection(n,c)).filter(c=>c!=null).map(c=>(k(c),ae.offset(c,0,-(this.floatingTopRowCount+this.table.size))));if(s.length>0){const c=new Map(this.pendingNewDataMap);for(let u=0;u<s.length;u+=1){const m=s[u];k(m.startRow),k(m.endRow);for(let p=m.startRow;p<=m.endRow;p+=1)c.delete(p)}this.pendingNewDataMap=c,this.formattedStringData=[],this.dispatchEvent(new Ke(Ce.EVENT.PENDING_DATA_UPDATED)),this.dispatchEvent(new Ke(Ce.EVENT.UPDATED))}const i=this.getTableAreaRange(),o=t.map(c=>ae.intersection(i,c)).filter(c=>c!=null);if(o.length<=0)return;const[r,l]=await Promise.all([this.snapshot(o.map(c=>(k(c),new ae(0,c.startRow,e.length-1,c.endRow)))),this.table.copy()]),d=r.map(c=>{const u=[];for(let m=0;m<e.length;m+=1){const p=e[m],g=c[m],f=_.makeFilterRawValue(p.type,g),C=p.filter().eq(f);u.push(C)}return u.reduce((m,p)=>m?.and(p)??p)}).reduce((c,u)=>c?.or(u)??u);l.applyFilter([d]),l.close()}isValidForCell(t,e,n){try{const s=this.columns[t];return _.makeValue(s.type,n,this.formatter.timeZone),!0}catch{return!1}}};let fd=Ea;fd.ROW_BUFFER_PAGES=1;const vs=J.module("IrisGridTableModel");class Nm extends fd{constructor(e,n=new nn,s=null){super(e,n,s),this.getMemoizedFrontColumns=ge(i=>i??[]),this.getMemoizedBackColumns=ge(i=>i??[]),this.getMemoizedFrozenColumns=ge((i,o)=>o??i??[]),this.getCachedFilterableColumnSet=ge(i=>new Set(i.map((o,r)=>r))),this.customColumnList=[],this.formatColumnList=[]}get isExportAvailable(){return this.table.freeze!=null}get isColumnStatisticsAvailable(){return this.table.getColumnStatistics!=null}get isValuesTableAvailable(){return this.table.selectDistinct!=null&&this.table.copy!=null}get isRollupAvailable(){return this.table.rollup!=null}get isSelectDistinctAvailable(){return this.table.selectDistinct!=null}get isCustomColumnsAvailable(){return this.table.applyCustomColumns!=null}get isFormatColumnsAvailable(){return this.table.applyCustomColumns!=null}get frontColumns(){return this.getMemoizedFrontColumns(this.layoutHints?.frontColumns)}get backColumns(){return this.getMemoizedBackColumns(this.layoutHints?.backColumns)}get frozenColumns(){return this.getMemoizedFrozenColumns(this.layoutHints?.frozenColumns,this.userFrozenColumns)}get layoutHints(){return this.table.layoutHints}get floatingLeftColumnCount(){return this.frozenColumns.length}get description(){return this.table.description}get customColumns(){return this.customColumnList}set customColumns(e){if(vs.debug2("set customColumns",e,this.customColumnList,e===this.customColumnList),this.customColumnList.length===0&&e.length===0){vs.debug("Ignore empty initial customColumns"),this.customColumnList=e;return}if(this.customColumnList===e){vs.debug("Ignore same customColumns");return}this.closeSubscription(),this.customColumnList=e,this.table.applyCustomColumns([...e,...this.formatColumns]),this.applyViewport()}get formatColumns(){return this.formatColumnList}set formatColumns(e){if(vs.debug2("set formatColumns",e,this.formatColumnList,e===this.formatColumnList),this.formatColumnList.length===0&&e.length===0){vs.debug("Ignore empty initial formatColumns"),this.formatColumnList=e;return}if(this.formatColumnList===e){vs.debug("Ignore same formatColumns");return}this.closeSubscription(),this.formatColumnList=e,this.table.applyCustomColumns([...this.customColumns,...e]),this.applyViewport()}updateFrozenColumns(e){this.userFrozenColumns=e,this.dispatchEvent(new Ke(Ce.EVENT.TABLE_CHANGED,{detail:this.table}))}set totalsConfig(e){if(vs.debug("set totalsConfig",e),e!==this.totals){if(this.totals=e,this.formattedStringData=[],this.totalsTablePromise!=null&&this.totalsTablePromise.cancel(),this.setTotalsTable(null),e==null){this.dispatchEvent(new Ke(Ce.EVENT.UPDATED));return}this.totalsTablePromise=ye.makeCancelable(this.table.getTotalsTable(e),n=>n.close()),this.totalsTablePromise.then(n=>{this.totalsTablePromise=null,this.setTotalsTable(n)}).catch(n=>{ye.isCanceled(n)||(vs.error("Unable to set next totalsTable",n),this.totalsTablePromise=null,this.dispatchEvent(new Ke(Ce.EVENT.REQUEST_FAILED,{detail:n})))})}}get isFilterRequired(){return this.table.isUncoalesced}isFilterable(e){return this.getCachedFilterableColumnSet(this.columns).has(e)}async export(){return this.table.freeze()}columnStatistics(e){return this.table.getColumnStatistics(e)}isColumnMovable(e){const n=this.columns[e].name;return this.frontColumns.includes(n)||this.backColumns.includes(n)||this.frozenColumns.includes(n)?!1:!this.isKeyColumn(e)}isColumnFrozen(e){return this.frozenColumns.includes(this.columns[e].name)}async delete(e){if(!this.isDeletableRanges(e))throw new Error(`Undeletable ranges ${e}`);k(this.inputTable);const{keyColumns:n}=this.inputTable;if(n.length===0)throw new Error("No key columns to allow deletion");const s=this.getPendingAreaRange(),i=e.map(u=>ae.intersection(s,u)).filter(u=>u!=null).map(u=>(k(u),ae.offset(u,0,-(this.floatingTopRowCount+this.table.size))));if(i.length>0){const u=new Map(super.pendingDataMap);for(let m=0;m<i.length;m+=1){const p=i[m];k(p.startRow),k(p.endRow);for(let g=p.startRow;g<=p.endRow;g+=1)u.delete(g)}super.pendingDataMap=u,this.formattedStringData=[],this.dispatchEvent(new Ke(Ce.EVENT.PENDING_DATA_UPDATED)),this.dispatchEvent(new Ke(Ce.EVENT.UPDATED))}const o=this.getTableAreaRange(),r=e.map(u=>ae.intersection(o,u)).filter(u=>u!=null);if(r.length<=0)return;const[l,a]=await Promise.all([this.snapshot(r.map(u=>(k(u),new ae(0,u.startRow,n.length-1,u.endRow)))),this.table.copy()]),c=l.map(u=>{const m=[];for(let p=0;p<n.length;p+=1){const g=n[p],f=u[p],C=_.makeFilterRawValue(g.type,f),S=g.filter().eq(C);m.push(S)}return m.reduce((p,g)=>p?.and(g)??g)}).reduce((u,m)=>u?.or(m)??m);a.applyFilter([c]),await this.inputTable?.deleteTable(a),a.close()}async seekRow(e,n,s,i,o,r,l){return this.table.seekRow(e,n,s,i,o,r,l)}get isSeekRowAvailable(){return this.table.seekRow!=null}}class sE extends fd{constructor(){super(...arguments),this.getCachedFilterableColumnSet=ge((e,n)=>new Set((n?.length>0?n:e).map(s=>e.findIndex(i=>s.name===i.name))))}applyBufferedViewport(e,n,s){this.table.setViewport(e,n,s)}textForCell(e,n){const s=this.columns[e],i=this.row(n);if(i!=null&&s!=null&&!i.hasChildren&&s.constituentType!=null){const o=this.valueForCell(e,n);return this.displayString(o,s.constituentType,s.name)}return super.textForCell(e,n)}extractViewportRow(e,n){const{isExpanded:s,hasChildren:i,depth:o}=e;return{...super.extractViewportRow(e,n),isExpanded:s,hasChildren:i,depth:o}}async snapshot(e,n,s){k(this.viewport),k(this.viewportData);const{columns:i}=this.viewport,o=[];n!=null&&n&&o.push(i.map(l=>l.name));const r=new ae(0,this.viewportData?.offset,i.length,this.viewportData.offset+this.viewportData.rows.length);for(let l=0;l<e.length;l+=1){const a=ae.intersection(r,e[l]);k(a),k(a.startRow),k(a.endRow);for(let d=a.startRow;d<=a.endRow;d+=1){const c=[],u=this.viewportData.rows[d-this.viewportData.offset];k(a.startColumn),k(a.endColumn);for(let m=a.startColumn;m<=a.endColumn;m+=1)k(s),c.push(s(u.data.get(m)?.value,this.columns[m]));o.push(c)}}return o}get groupedColumns(){return this.table.groupedColumns}get hasExpandableRows(){return!0}get isExpandAllAvailable(){return this.table.expandAll!==void 0}get isChartBuilderAvailable(){return!1}get isSelectDistinctAvailable(){return!1}get isReversible(){return!1}isFilterable(e){return this.getCachedFilterableColumnSet(this.columns,this.groupedColumns).has(e)}isColumnMovable(e){return e>=this.groupedColumns.length}isRowExpandable(e){return this.row(e)?.hasChildren??!1}isRowExpanded(e){return this.row(e)?.isExpanded??!1}setRowExpanded(e,n,s=!1){this.isExpandAllAvailable?this.table.setExpanded(e,n,s):this.table.setExpanded(e,n)}expandAll(){this.table.expandAll&&this.table.expandAll()}collapseAll(){this.table.collapseAll&&this.table.collapseAll()}depthForRow(e){return(this.row(e)?.depth??1)-1}}const Es=J.module("IrisGridProxyModel");function ta(t,e,n){return _.isTreeTable(t)?new sE(t,e):new Nm(t,e,n)}class iE extends Ce{constructor(e,n=new nn,s=null){super(),this.textForCell=(...o)=>this.model.textForCell(...o),this.truncationCharForCell=(...o)=>this.model.truncationCharForCell(...o),this.textAlignForCell=(...o)=>this.model.textAlignForCell(...o),this.colorForCell=(...o)=>this.model.colorForCell(...o),this.backgroundColorForCell=(...o)=>this.model.backgroundColorForCell(...o),this.textForColumnHeader=(...o)=>this.model.textForColumnHeader(...o),this.colorForColumnHeader=(...o)=>this.model.colorForColumnHeader(...o),this.textForRowHeader=(...o)=>this.model.textForRowHeader(...o),this.textForRowFooter=(...o)=>this.model.textForRowFooter(...o),this.isRowMovable=(...o)=>this.model.isRowMovable(...o),this.isColumnMovable=(...o)=>this.model.isColumnMovable(...o),this.isRowExpandable=(...o)=>ze(this.model)?this.model.isRowExpandable(...o):!1,this.isRowExpanded=(...o)=>ze(this.model)?this.model.isRowExpanded(...o):!1,this.setRowExpanded=(...o)=>{if(ze(this.model))return this.model.setRowExpanded(...o);throw Error("Function setRowExpanded does not exist on IrisGridTableModel")},this.expandAll=()=>{if(ze(this.model))return this.model.expandAll();throw Error("Function expandAll does not exist on IrisGridTableModel")},this.collapseAll=()=>{if(ze(this.model))return this.model.collapseAll();throw Error("Function collapseAll does not exist on IrisGridTableModel")},this.depthForRow=(...o)=>ze(this.model)?this.model.depthForRow(...o):0,this.getColumnHeaderGroup=(...o)=>this.model.getColumnHeaderGroup(...o),this.getColumnHeaderParentGroup=(...o)=>this.model.getColumnHeaderParentGroup(...o),this.formatForCell=(...o)=>this.model.formatForCell(...o),this.valueForCell=(...o)=>this.model.valueForCell(...o),this.displayString=(...o)=>this.model.displayString(...o),this.isEditableRange=(...o)=>tt(this.model)?this.model.isEditableRange(...o):!1,this.isFilterable=(...o)=>this.model.isFilterable(...o),this.setViewport=(o,r,l)=>this.model.setViewport(o,r,l),this.snapshot=(...o)=>this.model.snapshot(...o),this.textSnapshot=(...o)=>this.model.textSnapshot(...o),this.valuesTable=(...o)=>this.model.valuesTable(...o),this.editValueForCell=(...o)=>tt(this.model)?this.model.editValueForCell(...o):"",this.setValueForCell=(...o)=>tt(this.model)?this.model.setValueForCell(...o):Promise.reject(new Error("Model is not editable")),this.setValueForRanges=(...o)=>tt(this.model)?this.model.setValueForRanges(...o):Promise.reject(new Error("Model is not editable")),this.setValues=(...o)=>tt(this.model)?this.model.setValues(...o):Promise.resolve(),this.isValidForCell=(...o)=>tt(this.model)?this.model.isValidForCell(...o):!1,this.delete=(...o)=>this.model.delete(...o),this.commitPending=(...o)=>this.model.commitPending(...o),this.handleModelEvent=this.handleModelEvent.bind(this);const i=ta(e,n,s);this.originalModel=i,this.model=i,this.modelPromise=null,this.rollup=null,this.selectDistinct=[]}close(){this.originalModel.close(),this.model!==this.originalModel&&this.model.close(),this.modelPromise!=null&&this.modelPromise.cancel()}handleModelEvent(e){Es.debug2("handleModelEvent",e);const{detail:n,type:s}=e;this.dispatchEvent(new Ke(s,{detail:n}))}setModel(e){Es.debug("setModel",e);const n=this.model;n!==this.originalModel&&n.close(),this.model=e,this.listenerCount>0&&this.addListeners(e),this.dispatchEvent(new Ke(Ce.EVENT.COLUMNS_CHANGED,{detail:e.columns})),si(e)&&this.dispatchEvent(new Ke(Ce.EVENT.TABLE_CHANGED,{detail:e.table}))}setNextModel(e){Es.debug2("setNextModel"),this.modelPromise&&this.modelPromise.cancel(),this.listenerCount>0&&this.removeListeners(this.model),this.modelPromise=ye.makeCancelable(e,n=>n.close()),this.modelPromise.then(n=>{this.modelPromise=null,this.setModel(n)}).catch(n=>{if(ye.isCanceled(n)){Es.debug2("setNextModel cancelled");return}Es.error("Unable to set next model",n),this.modelPromise=null,this.dispatchEvent(new Ke(Ce.EVENT.REQUEST_FAILED,{detail:n}))})}startListening(){super.startListening(),this.addListeners(this.model)}stopListening(){super.stopListening(),this.removeListeners(this.model)}addListeners(e){const n=Object.keys(Ce.EVENT);for(let s=0;s<n.length;s+=1)e.addEventListener(n[s],this.handleModelEvent)}removeListeners(e){const n=Object.keys(Ce.EVENT);for(let s=0;s<n.length;s+=1)e.removeEventListener(n[s],this.handleModelEvent)}get rowCount(){return this.model.rowCount}get columnCount(){return this.model.columnCount}get floatingTopRowCount(){return this.model.floatingTopRowCount}get floatingBottomRowCount(){return this.model.floatingBottomRowCount}get floatingLeftColumnCount(){return this.model.floatingLeftColumnCount}get floatingRightColumnCount(){return this.model.floatingRightColumnCount}isColumnFrozen(e){return this.model.isColumnFrozen(e)}get hasExpandableRows(){return ze(this.model)?this.model.hasExpandableRows:!1}get isExpandAllAvailable(){return ze(this.model)?this.model.isExpandAllAvailable??!1:!1}get isExportAvailable(){return this.model.isExportAvailable}get isColumnStatisticsAvailable(){return this.model.isColumnStatisticsAvailable}get isValuesTableAvailable(){return this.model.isValuesTableAvailable}get isCustomColumnsAvailable(){return this.model.isCustomColumnsAvailable&&!(this.isSelectDistinctAvailable&&this.selectDistinctColumns.length>0)}get isFormatColumnsAvailable(){return this.model.isFormatColumnsAvailable}get isChartBuilderAvailable(){return this.model.isChartBuilderAvailable}get isRollupAvailable(){return(this.originalModel.isRollupAvailable||this.rollup!=null)&&this.selectDistinct.length===0}get isSelectDistinctAvailable(){return(this.originalModel.isSelectDistinctAvailable||this.selectDistinct.length>0)&&this.rollup==null}get isTotalsAvailable(){return this.model.isTotalsAvailable}get isReversible(){return this.model.isReversible}get columns(){return this.model.columns}get initialMovedColumns(){return this.model.initialMovedColumns}get initialMovedRows(){return this.model.initialMovedRows}get layoutHints(){return this.model.layoutHints}get frontColumns(){return this.model.frontColumns}get backColumns(){return this.model.backColumns}get frozenColumns(){return this.model.frozenColumns}get columnHeaderGroups(){return this.model.columnHeaderGroups}set columnHeaderGroups(e){this.model.columnHeaderGroups=e}get initialColumnHeaderGroups(){return this.model.initialColumnHeaderGroups}get columnHeaderGroupMap(){return this.model.columnHeaderGroupMap}get columnHeaderMaxDepth(){return this.model.columnHeaderMaxDepth}updateFrozenColumns(e){return this.model.updateFrozenColumns(e)}get originalColumns(){return this.originalModel.columns}get groupedColumns(){return this.model.groupedColumns}get description(){return this.model.description}get filter(){return this.model.filter}set filter(e){this.model.filter=e}get formatter(){return this.model.formatter}set formatter(e){this.model.formatter=e}get sort(){return this.model.sort}set sort(e){this.model.sort=e}get customColumns(){return this.model.customColumns}set customColumns(e){this.model.customColumns=e}get formatColumns(){return this.model.formatColumns}set formatColumns(e){this.model.formatColumns=e}get rollupConfig(){return this.rollup}set rollupConfig(e){if(Es.debug("set rollupConfig",e),!this.isRollupAvailable)throw new Error("Rollup Rows are not available");if(ct(e,this.rollup))return;this.rollup=e;let n=Promise.resolve(this.originalModel);si(this.originalModel)&&e!=null&&(n=this.originalModel.table.rollup(e).then(s=>ta(s,this.formatter))),this.setNextModel(n)}get selectDistinctColumns(){return this.selectDistinct}set selectDistinctColumns(e){if(Es.debug("set selectDistinctColumns",e),!this.isSelectDistinctAvailable)throw new Error("Select distinct is not available");if(e===this.selectDistinctColumns||e.length===0&&this.selectDistinctColumns.length===0){Es.debug("Ignore same selectDistinctColumns",e);return}this.selectDistinct=e;const n=e.map(i=>this.originalColumns.find(o=>o.name===i)).filter(i=>i!=null);let s=Promise.resolve(this.originalModel);si(this.originalModel)&&n.length>0&&(s=this.originalModel.table.selectDistinct(n).then(i=>ta(i,this.formatter))),this.setNextModel(s)}get table(){if(si(this.model))return this.model.table}get totalsConfig(){return this.model.totalsConfig}set totalsConfig(e){this.model.totalsConfig=e}get isFilterRequired(){return this.model.isFilterRequired}get isEditable(){return tt(this.model)&&this.model.isEditable}export(){if(_.isTreeTable(this.model))throw new Error("TreeTable has no 'export' property");return this.model.export()}columnStatistics(e){if(_.isTreeTable(this.model))throw new Error("TreeTable has no 'columnStatistics' function");return this.model.columnStatistics(e)}get pendingDataMap(){return this.model.pendingDataMap}set pendingDataMap(e){this.model.pendingDataMap=e}get pendingRowCount(){return this.model.pendingRowCount}set pendingRowCount(e){this.model.pendingRowCount=e}get pendingDataErrors(){return this.model.pendingDataErrors}getColumnIndexByName(e){return this.model.getColumnIndexByName(e)}async seekRow(e,n,s,i,o,r,l){return this.model.seekRow(e,n,s,i,o,r,l)}get isSeekRowAvailable(){return this.model.isSeekRowAvailable}}class Cd{static async makeModel(e,n=new nn){let s=null;return!_.isTreeTable(e)&&e.hasInputTable&&(s=await e.inputTable()),new iE(e,n,s)}}const Kn=J.module("TableViewportUpdater"),oE=150,bo=class extends b.exports.PureComponent{constructor(){super(...arguments),this.getViewportRowRange=ge((t,e,n)=>{const s=n-e,i=Math.max(0,e-s*bo.ROW_BUFFER_PAGES),o=n+s*bo.ROW_BUFFER_PAGES;return[i,o]}),this.getViewportColumns=ge((t,e,n,s)=>{if(e==null||n==null)return null;const i=n-e,o=Math.max(0,e-i*bo.COLUMN_BUFFER_PAGES),r=Math.min(n+i*bo.COLUMN_BUFFER_PAGES,t.columns.length-1),l=[];for(let a=o;a<=r;a+=1){const d=z.getModelIndex(a,s);l.push(t.columns[d])}return l}),this.updateViewport=Ln((t,e,n,s,i)=>{if(e<t){Kn.error("Invalid viewport",t,e);return}if(t===0&&e===0){Kn.debug2("Ignoring 0-0 viewport");return}const{movedColumns:o,table:r}=this.props,[l,a]=this.getViewportRowRange(r,t,e),d=i??this.getViewportColumns(r,n,s,o);if(Kn.debug2("Setting Viewport Top:",l,"Bottom:",a,"Columns:",d),this.subscription==null){Kn.debug2("updateViewport creating new subscription"),this.subscription=r.setViewport(l,a,d);const{onSubscription:c}=this.props;c(this.subscription)}else Kn.debug2("updateViewport using existing subscription"),this.subscription.setViewport(l,a,d)},oE)}componentDidMount(){const{top:t,bottom:e,left:n,right:s,table:i,filters:o,sorts:r,columns:l,customColumns:a}=this.props;i.applyFilter(o),i.applySort(r),i.applyCustomColumns(a),this.updateViewport(t,e,n,s,l)}componentDidUpdate(t){const{top:e,bottom:n,left:s,right:i,table:o,filters:r,sorts:l,customColumns:a,columns:d}=this.props,c=r!==t.filters,u=l!==t.sorts,m=a!==t.customColumns,p=o!==t.table;(c||u||m||p)&&this.closeSubscription(),(c||p)&&(Kn.debug("update table filter",r),o.applyFilter(r)),(u||p)&&(Kn.debug("update table sort",l),o.applySort(l)),(m||p)&&(Kn.debug("update table custom columns",a),o.applyCustomColumns(a)),this.updateViewport(e,n,s,i,d)}componentWillUnmount(){this.closeSubscription()}closeSubscription(){if(Kn.debug2("closeSubscription",this.subscription),this.subscription){this.subscription.close(),this.subscription=void 0;const{onSubscription:t}=this.props;t()}this.updateViewport.cancel()}render(){return null}};let Sd=bo;Sd.ROW_BUFFER_PAGES=3;Sd.COLUMN_BUFFER_PAGES=1;Sd.defaultProps={top:0,bottom:0,left:null,right:null,columns:null,onSubscription:()=>{},filters:[],sorts:[],customColumns:[],movedColumns:[]};const bi=J.module("TreeTableViewportUpdater"),rE=150,_m=class extends b.exports.PureComponent{constructor(t){super(t),this.updateViewport=Ln((e,n)=>{if(n<e){bi.error("Invalid viewport",e,n);return}if(e===0&&n===0){bi.debug2("Ignoring 0-0 viewport");return}const{table:s,updateInterval:i}=this.props,o=n-e,r=Math.max(0,e-o*3),l=n+o*3+1;if(bi.debug2("Setting Viewport Top:",r,"Bottom:",l,s),!this.listenerCleanup){const{onViewportUpdate:a}=this.props;this.listenerCleanup=s.addEventListener(I.TreeTable.EVENT_UPDATED,a)}s.setViewport(r,l,void 0,i)},rE),this.listenerCleanup=null}componentDidMount(){const{top:t,bottom:e,table:n,filters:s,sorts:i}=this.props;bi.debug("componentDidMount",this.props),n.applyFilter(s),n.applySort(i),this.updateViewport(t,e)}componentDidUpdate(t){const{top:e,bottom:n,table:s,filters:i,sorts:o}=this.props;i!==t.filters&&(bi.debug("update table filter",i),s.applyFilter(i)),o!==t.sorts&&(bi.debug("update table sort",o),s.applySort(o)),this.updateViewport(e,n)}componentWillUnmount(){this.updateViewport.cancel(),this.listenerCleanup&&this.listenerCleanup()}render(){return null}};let Mm=_m;Mm.UPDATE_INTERVAL=1e3;Mm.defaultProps={top:0,bottom:0,onViewportUpdate:()=>{},filters:[],sorts:[],updateInterval:_m.UPDATE_INTERVAL};class Li{}Li.OPEN="ChartEvent.OPEN";Li.CLOSE="ChartEvent.CLOSE";Li.COLUMN_SELECTED="ChartEvent.COLUMN_SELECTED";class gt{}gt.SESSION_OPENED="ConsoleEvent.SESSION_OPENED";gt.SESSION_CLOSED="ConsoleEvent.SESSION_CLOSED";gt.FOCUS_HISTORY="ConsoleEvent.FOCUS_HISTORY";gt.SEND_COMMAND="ConsoleEvent.SEND_COMMAND";gt.SETTINGS_CHANGED="ConsoleEvent.SETTINGS_CHANGED";class Le{}Le.TABLE_CHANGED="InputFilterEvent.TABLE_CHANGED";Le.COLUMNS_CHANGED="InputFilterEvent.COLUMNS_CHANGED";Le.FILTERS_CHANGED="InputFilterEvent.FILTERS_CHANGED";Le.CLEAR_ALL_FILTERS="InputFilterEvent.CLEAR_ALL_FILTERS";Le.COLUMN_SELECTED="InputFilterEvent.COLUMN_SELECTED";Le.OPEN_DROPDOWN="InputFilterEvent.OPEN_DROPDOWN";Le.OPEN_INPUT="InputFilterEvent.OPEN_INPUT";Le.OPEN_FILTER_SET_MANAGER="InputFilterEvent.OPEN_FILTER_SET_MANAGER";class wt{}wt.OPEN_GRID="IrisGridEvent.OPEN_GRID";wt.CLOSE_GRID="IrisGridEvent.CLOSE_GRID";wt.DATA_SELECTED="IrisGridEvent.DATA_SELECTED";wt.COLUMN_SELECTED="IrisGridEvent.COLUMN_SELECTED";wt.STATE_CHANGED="IrisGridEvent.STATE_CHANGED";wt.CREATE_CHART="IrisGridevent.CREATE_CHART";const km=Object.freeze({OPEN:"MarkdownEvent.OPEN"});class Ae{}Ae.CREATE_NOTEBOOK="NotebookEvent.createNotebook";Ae.SELECT_NOTEBOOK="NotebookEvent.selectNotebook";Ae.CLOSE_FILE="NotebookEvent.closeFile";Ae.RENAME="NotebookEvent.rename";Ae.RENAME_FILE="NotebookEvent.renameFile";Ae.REGISTER_FILE="NotebookEvent.registerFile";Ae.SEND_TO_NOTEBOOK="NotebookEvent.sendToNotebook";Ae.UNREGISTER_FILE="NotebookEvent.unregisterFile";class On{}On.focus="TabEvent.focus";On.blur="TabEvent.blur";On.openPQObject="TabEvent.openPQObject";On.openControl="TabEvent.openControl";On.reload="TabEvent.reload";On.clearAllFilters="TabEvent.clearAllFilters";class xm extends b.exports.PureComponent{constructor(e){super(e),this.handleCloseTab=this.handleCloseTab.bind(this),this.handleCloseTabsRight=this.handleCloseTabsRight.bind(this),this.handleCloseTabsAll=this.handleCloseTabsAll.bind(this)}getAllTabs(){const{glContainer:e}=this.props;return[...e?.tab?.header?.tabs??[]]}handleCloseTab(){const{glContainer:e}=this.props;e.close()}handleCloseTabsAll(){this.getAllTabs().forEach(n=>(n?.contentItem).container?.close())}handleCloseTabsRight(){const{glContainer:e}=this.props,n=this.getAllTabs();for(let s=n.length-1;s>0&&n[s].contentItem?.config?.id!==e.tab?.contentItem?.config?.id;s-=1)(n[s]?.contentItem).container?.close()}canCloseTabsRight(){const{glContainer:e}=this.props,n=this.getAllTabs();let s=!0;for(let i=n.length-1;i>0&&n[i].contentItem?.config?.id!==e.tab?.contentItem?.config?.id;i-=1)if(Boolean(n[i]?.contentItem?.config?.isClosable)){s=!1;break}return s}canCloseAny(){const e=this.getAllTabs();let n=!0;for(let s=e.length-1;s>0;s-=1)if(Boolean(e[s]?.contentItem?.config?.isClosable)){n=!1;break}return n}render(){const{additionalActions:e,glContainer:n}=this.props,s=[...e],i=n.tab?.contentItem?.config?.isClosable;return s.push({title:"Close",order:10,group:le.groups.low,action:this.handleCloseTab,disabled:i===void 0||!i}),s.push(()=>({title:"Close Tabs to Right",order:20,group:le.groups.low,action:this.handleCloseTabsRight,disabled:this.canCloseTabsRight()})),s.push(()=>({title:"Close All",order:30,group:le.groups.low,action:this.handleCloseTabsAll,disabled:this.canCloseAny()})),h(le,{actions:s})}}xm.defaultProps={additionalActions:[]};class Om extends b.exports.PureComponent{constructor(e){super(e),this.handleRenameDialogOpened=this.handleRenameDialogOpened.bind(this),this.handleRenameInputChange=this.handleRenameInputChange.bind(this),this.handleRenameCancel=this.handleRenameCancel.bind(this),this.handleRenameSubmit=this.handleRenameSubmit.bind(this),this.renameInputRef=de.createRef();const{value:n}=e;this.state={value:n,valueWasValidated:!1}}componentDidUpdate(e){const{isShown:n}=e,{isShown:s}=this.props;s&&!n&&this.resetState()}resetState(){const{value:e}=this.props;this.setState({value:e,valueWasValidated:!1})}handleRenameDialogOpened(){this.renameInputRef?.current?.focus()}handleRenameInputChange(e){this.setState({value:e.target.value})}handleRenameCancel(){const{onCancel:e}=this.props;e()}handleRenameSubmit(e){e.stopPropagation(),e.preventDefault();const{value:n}=this.state,s=n?.trim();if(s!==void 0&&s!==""){const{onSubmit:i}=this.props;i(s)}else this.setState({value:s,valueWasValidated:!0})}renderRenameDialog(){const{isShared:e,isOwner:n,itemType:s}=this.props,{value:i,valueWasValidated:o}=this.state;return T("form",{className:Y("p-3",{"was-validated":o}),onSubmit:this.handleRenameSubmit,noValidate:!0,role:"presentation",onMouseDown:r=>{r.stopPropagation()},onMouseUp:r=>{r.stopPropagation()},children:[T("div",{className:"form-group",children:[T("label",{htmlFor:`rename-dialog-${s}-input`,children:["Rename ",s]}),h("input",{type:"text",className:"form-control",id:`rename-dialog-${s}-input`,value:i??void 0,ref:this.renameInputRef,onChange:this.handleRenameInputChange,required:!0}),T("div",{className:"invalid-feedback",children:[s," name cannot be empty"]}),(e||!n)&&T("div",{className:"pt-2",children:["Renaming this ",s," will rename for all users."]})]}),T("div",{className:"text-right",children:[h(U,{kind:"secondary",className:"mr-2",onClick:this.handleRenameCancel,children:"Cancel"}),h(U,{kind:"primary",type:"submit",children:"Rename"})]})]})}render(){const{isShown:e,onCancel:n}=this.props;return h(tl,{isShown:e,onEntered:this.handleRenameDialogOpened,onExited:n,options:{placement:"bottom"},interactive:!0,closeOnBlur:!0,children:this.renderRenameDialog()})}}Om.defaultProps={isShared:!1,isOwner:!0,itemType:"Item",value:""};const lE=J.module("Panel");class $n extends b.exports.PureComponent{constructor(e){super(e),this.getAdditionActions=ge((s,i,o)=>{const r=[];return i&&r.push(this.getCloneAction()),o&&r.push(this.getRenameAction()),[...r,...s]}),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.handleCopyPanel=this.handleCopyPanel.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleHide=this.handleHide.bind(this),this.handleResize=this.handleResize.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleBeforeShow=this.handleBeforeShow.bind(this),this.handleShow=this.handleShow.bind(this),this.handleTabBlur=this.handleTabBlur.bind(this),this.handleTabFocus=this.handleTabFocus.bind(this),this.handleRenameCancel=this.handleRenameCancel.bind(this),this.handleRenameSubmit=this.handleRenameSubmit.bind(this),this.handleShowRenameDialog=this.handleShowRenameDialog.bind(this),this.handleTabClicked=this.handleTabClicked.bind(this),this.handleTab=this.handleTab.bind(this);const{glContainer:n}=this.props;this.state={title:ie.getTitleFromContainer(n),showRenameDialog:!1}}componentDidMount(){const{componentPanel:e,glContainer:n,glEventHub:s}=this.props;n.on("resize",this.handleResize),n.on("show",this.handleBeforeShow),n.on("shown",this.handleShow),n.on("hide",this.handleHide),n.on("tab",this.handleTab),n.on("tabClicked",this.handleTabClicked),s.on(gt.SESSION_CLOSED,this.handleSessionClosed),s.on(gt.SESSION_OPENED,this.handleSessionOpened),s.on(On.focus,this.handleTabFocus),s.on(On.blur,this.handleTabBlur),s.on(Le.CLEAR_ALL_FILTERS,this.handleClearAllFilters),s.emit(Ee.MOUNT,e)}componentWillUnmount(){const{componentPanel:e,glContainer:n,glEventHub:s}=this.props;n.off("resize",this.handleResize),n.off("show",this.handleBeforeShow),n.off("shown",this.handleShow),n.off("hide",this.handleHide),n.off("tab",this.handleTab),n.off("tabClicked",this.handleTabClicked),s.off(gt.SESSION_CLOSED,this.handleSessionClosed),s.off(gt.SESSION_OPENED,this.handleSessionOpened),s.off(On.focus,this.handleTabFocus),s.off(On.blur,this.handleTabBlur),s.off(Le.CLEAR_ALL_FILTERS,this.handleClearAllFilters),s.emit(Ee.UNMOUNT,e)}handleTab(e){e!=null&&this.setState({title:ie.getTitleFromTab(e)}),this.forceUpdate();const{onTab:n}=this.props;n(e)}handleTabClicked(...e){const{onTabClicked:n}=this.props;n(...e)}handleClearAllFilters(...e){const{onClearAllFilters:n}=this.props;n(...e)}handleFocus(e){const{componentPanel:n,glEventHub:s}=this.props;s.emit(Ee.FOCUS,n);const{onFocus:i}=this.props;i(e)}handleBlur(e){const{onBlur:n}=this.props;n(e)}handleHide(...e){const{onHide:n}=this.props;n(...e)}handleResize(...e){const{onResize:n}=this.props;n(...e)}handleSessionClosed(e){const{onSessionClose:n}=this.props;n(e)}handleSessionOpened(e,n){const{onSessionOpen:s}=this.props;s(e,n)}handleBeforeShow(...e){const{onBeforeShow:n}=this.props;n(...e)}handleShow(...e){const{onShow:n}=this.props;n(...e)}handleTabBlur(...e){const{onTabBlur:n}=this.props;n(...e)}handleTabFocus(...e){const{onTabFocus:n}=this.props;n(...e)}handleRenameCancel(){this.setState({showRenameDialog:!1})}handleShowRenameDialog(){this.setState({showRenameDialog:!0})}handleRenameSubmit(e){const{glContainer:n}=this.props;this.setState({showRenameDialog:!1,title:e});const s=ie.getRootFromContainer(n),i=ie.getComponentConfigFromContainer(n);k(i),ie.renameComponent(s,i,e)}handleCopyPanel(){const{glContainer:e,glEventHub:n}=this.props,s=ie.getRootFromContainer(e),i=ie.getComponentConfigFromContainer(e);if(i==null){lE.error("Could not get component config from container",e);return}const o=ie.cloneComponent(s,i);o!==null&&n.emit(Ee.CLONED,this,o)}getCloneAction(){return{title:"Copy Panel",order:10,group:le.groups.high,action:this.handleCopyPanel}}getRenameAction(){return{title:"Rename",order:10,group:le.groups.medium,action:this.handleShowRenameDialog}}render(){const{children:e,className:n,renderTabTooltip:s,glContainer:i,additionalActions:o,errorMessage:r,isLoaded:l,isLoading:a,isClonable:d,isRenamable:c}=this.props,{tab:u}=i,{showRenameDialog:m,title:p}=this.state;return T("div",{className:Y("h-100 w-100 iris-panel",n),onFocusCapture:this.handleFocus,onBlurCapture:this.handleBlur,children:[e,h(Jr,{errorMessage:r,isLoaded:l,isLoading:a}),u!=null&&Nr.createPortal(T(be,{children:[h(xm,{glContainer:i,additionalActions:this.getAdditionActions(o,d,c)}),c&&h(Om,{isShown:m,value:p,itemType:"Panel",onCancel:this.handleRenameCancel,onSubmit:this.handleRenameSubmit}),s!=null&&h(ut,{interactive:!0,options:{placement:"bottom"},popperClassName:"panel-tab-popper",children:s()})]}),u.element[0])]})}}$n.defaultProps={className:"",onTab:()=>{},onTabClicked:()=>{},onClearAllFilters:()=>{},onFocus:()=>{},onBlur:()=>{},onHide:()=>{},onResize:()=>{},onSessionClose:()=>{},onSessionOpen:()=>{},onBeforeShow:()=>{},onShow:()=>{},onTabBlur:()=>{},onTabFocus:()=>{},renderTabTooltip:null,additionalActions:[],errorMessage:null,isLoading:!1,isLoaded:!0,isClonable:!1,isRenamable:!1};function Rl(t){const{widgetType:e,widgetName:n,glContainer:s,description:i,children:o}=t,r=ie.getTitleFromContainer(s);return T("div",{className:"tab-tooltip-container",children:[T("div",{className:"row flex-nowrap align-items-start",children:[h("span",{className:"tab-tooltip-title",children:T("b",{children:[e," Name "]})}),h("span",{className:"tab-tooltip-name",children:n}),h(ll,{className:"tab-tooltip-copy",tooltip:"Copy name",copy:n})]}),n!==r&&T("div",{className:"row",children:[h("span",{className:"tab-tooltip-title",children:h("b",{children:"Display Name"})}),h("span",{className:"tab-tooltip-name",children:r})]}),i&&h("div",{className:"row",children:h("span",{className:"tab-tooltip-description",children:i})}),o]})}Rl.propTypes={glContainer:id.Container.isRequired,widgetType:M.exports.string,widgetName:M.exports.string,description:M.exports.string,children:M.exports.node};Rl.defaultProps={widgetType:"",widgetName:"",description:null,children:null};class Il extends b.exports.PureComponent{constructor(e){super(e),this.getCachedRenderTabTooltip=ge((n,s,i,o,r)=>n?()=>h(Rl,{glContainer:s,widgetType:i,widgetName:o,description:r}):null),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleCopyName=this.handleCopyName.bind(this),this.state={isClientDisconnected:!1,isPanelDisconnected:!1,isWidgetDisconnected:!1,isWaitingForReconnect:!1,isPanelInactive:!1}}handleCopyName(){const{widgetName:e}=this.props;No(e)}getErrorMessage(){const{errorMessage:e}=this.props,{isClientDisconnected:n,isPanelDisconnected:s,isWidgetDisconnected:i,isWaitingForReconnect:o}=this.state;if(e)return`${e}`;if(n&&s&&o)return`Disconnected from server.
32
32
  Check your internet connection.`;if(n&&s)return"Disconnected from server.";if(s){const{widgetName:r,widgetType:l}=this.props;return`Variable "${r}" not set.
33
33
  ${l} does not exist yet.`}if(i){const{widgetName:r}=this.props;return`${r} is unavailable.`}}handleSessionClosed(...e){const{onSessionClose:n}=this.props;this.setState({isPanelDisconnected:!0,isWaitingForReconnect:!1}),n(...e)}handleSessionOpened(...e){const{onSessionOpen:n}=this.props;n(...e)}render(){const{children:e,className:n,componentPanel:s,isLoaded:i,isLoading:o,glContainer:r,glEventHub:l,isDisconnected:a,isClonable:d,isRenamable:c,showTabTooltip:u,renderTabTooltip:m,widgetType:p,widgetName:g,description:f,onClearAllFilters:C,onHide:S,onFocus:w,onBlur:v,onResize:y,onShow:E,onTabBlur:R,onTabFocus:F,onTabClicked:D}=this.props,{isPanelDisconnected:N,isWidgetDisconnected:P,isPanelInactive:H}=this.state,A=this.getErrorMessage(),q=m??this.getCachedRenderTabTooltip(u,r,p,g,f),B=[{title:`Copy ${p} Name`,group:le.groups.medium,order:20,action:this.handleCopyName}];return T($n,{className:Y(n,{disconnected:N||P||a,inactive:H}),componentPanel:s,glContainer:r,glEventHub:l,onClearAllFilters:C,onHide:S,onFocus:w,onBlur:v,onResize:y,onShow:E,onSessionClose:this.handleSessionClosed,onSessionOpen:this.handleSessionOpened,onTabBlur:R,onTabFocus:F,onTabClicked:D,renderTabTooltip:q,errorMessage:A,isLoaded:i,isLoading:o,isClonable:d,isRenamable:c,additionalActions:B,children:[e,H&&h("div",{className:"fill-parent-absolute"})]})}}Il.defaultProps={className:"",errorMessage:null,isClonable:!0,isDisconnected:!1,isLoading:!1,isLoaded:!0,isRenamable:!0,showTabTooltip:!0,widgetName:"Widget",widgetType:"Widget",renderTabTooltip:null,description:"",onFocus:()=>{},onBlur:()=>{},onHide:()=>{},onClearAllFilters:()=>{},onResize:()=>{},onSessionClose:()=>{},onSessionOpen:()=>{},onShow:()=>{},onTabBlur:()=>{},onTabFocus:()=>{},onTabClicked:()=>{}};const Wt=Object.freeze({DEFAULT:"DEFAULT",LINKER:"LINKER"}),aE="SET_SESSION_WRAPPER",dE=Ls(aE,null),cE={sessionWrapper:dE},hE=new Map,Fl=Object.freeze([]),Am=(t,e)=>Yt(t,e).columns??Fl,uE=(t,e)=>Yt(t,e).filterSets??Fl,bd=(t,e)=>Yt(t,e).filters??Fl,wd=(t,e)=>Yt(t,e).tableMap??hE,Td=(t,e)=>Yt(t,e).isolatedLinkerPanelId,Ki=(t,e)=>Yt(t,e).links??Fl,vd=(t,e)=>Yt(t,e).columnSelectionValidator,mE=(t,e)=>Yt(t,e).connection,ai=(t,e)=>Yt(t,e).sessionWrapper,pE=(t,e)=>n=>n(Vn(t,{connection:e})),gE=(t,e)=>n=>n(Vn(t,{sessionWrapper:e})),Ed=(t,e)=>n=>n(Vn(t,{links:e})),fE=(t,e)=>(n,s)=>{const i=Ki(s(),t),o=e.filter(r=>i.findIndex(l=>ct(l.start,r.start)&&ct(l.end,r.end))<0);return n(Ed(t,i.concat(o)))},CE=(t,e)=>(n,s)=>{const o=Ki(s(),t).filter(r=>!e.includes(r.id));return n(Ed(t,o))},Lm=(t,e)=>n=>n(Vn(t,{isolatedLinkerPanelId:e})),SE=(t,e)=>n=>n(Vn(t,{columnSelectionValidator:e})),bE=(t,e)=>n=>n(Vn(t,{consoleSettings:e})),wE=(t,e)=>n=>n(Vn(t,{filterSets:e}));Object.entries(cE).map(([t,e])=>Gi.register(t,e));function Pm({columnMap:t,inputFilterMap:e,linkedColumnMap:n,onAdd:s,onOpenLinker:i,waitingFilterMap:o,waitingInputMap:r}){const l=b.exports.useMemo(()=>{const p=Array.from(r.keys()),g=p.find(S=>e.get(S)!=null),f=p.find(S=>n.get(S)!=null),C=jt.join(p.map(S=>`"${S}"`));return g!=null&&g&&f!=null&&f?`Use a filter control or linked table to set a value for ${C}`:g!=null&&g?`Set a filter control value for ${C}`:`Double click a row in a linked table to set a value for ${C}`},[e,n,r]),a=b.exports.useMemo(()=>Array.from(t.values()),[t]),d=b.exports.useCallback(p=>{p.stopPropagation(),p.preventDefault(),s(Array.from(o.values()))},[s,o]),c=b.exports.useCallback(p=>{p.stopPropagation(),p.preventDefault(),i()},[i]),u=o.size>0,m=!u&&r.size>0;return h("div",{className:"chart-panel-overlay chart-filter-overlay",children:T("div",{className:Y("chart-panel-overlay-content chart-filter-overlay-content",{"chart-filter-waiting-filter":u},{"chart-filter-waiting-input":m}),children:[u&&T(be,{children:[h("div",{className:"info-message",children:"This plot requires a filter control to be added to the layout or a table link to be created on the following columns:"}),h("div",{className:"waiting-filter-list",children:a.map(p=>{const g=o.has(p.name),f=g?Os:Pa;return T("div",{className:Y("waiting-filter-item",{"is-invalid":g}),children:[h(Z,{icon:f}),p.name]},p.name)})}),T("div",{children:[h(Kd,{onClick:d,className:"btn-primary",children:"Add Input Filters"}),h(Kd,{onClick:c,className:"btn-primary",children:"Open Linker Tool"})]})]}),m&&T(be,{children:[h("div",{className:"info-message",children:"Waiting for User Input"}),h("div",{className:"",children:l})]})]})})}Pm.propTypes={columnMap:M.exports.instanceOf(Map).isRequired,inputFilterMap:M.exports.instanceOf(Map).isRequired,linkedColumnMap:M.exports.instanceOf(Map).isRequired,onAdd:M.exports.func.isRequired,onOpenLinker:M.exports.func.isRequired,waitingFilterMap:M.exports.instanceOf(Map).isRequired,waitingInputMap:M.exports.instanceOf(Map).isRequired};function Do({columns:t,onColumnSelected:e,onMouseEnter:n,onMouseLeave:s}){return h("div",{className:"chart-panel-overlay chart-column-selector-overlay",children:T("div",{className:Y("chart-panel-overlay-content"),children:[h("div",{className:"info-message",children:"This plot requires a filter control to be added to the layout or a table link to be created on the following columns:"}),h("div",{className:"waiting-column-select-list",children:t.map(i=>h(Nh,{className:Y("btn-chart-column-selector",Do.makeButtonClassName(i.name)),onClick:()=>e(i.name),onMouseEnter:()=>{n&&n(i)},onMouseLeave:s,disabled:!i.isValid,isLinked:i.isActive,children:i.name},i.name))})]})})}Do.makeButtonClassName=t=>`btn-chart-column-selector-${t}`;Do.defaultProps={onMouseEnter:()=>{},onMouseLeave:()=>{}};const Xt=J.module("ChartPanel"),TE=150;function Er(t){return t.settings!==void 0}function vE(t){return t.inputFilters!=null}function EE(t){return t.panelState!=null}class Dl extends b.exports.Component{constructor(e){super(e),this.getWaitingInputMap=ge((r,l,a)=>{if(!r)return new Map;const d=new Map(l);return a.forEach((c,u)=>{d.delete(u)}),d}),this.getWaitingFilterMap=ge((r,l,a,d,c)=>{if(!r)return new Map;const u=new Map(l);return a.forEach((m,p)=>{u.delete(p)}),c.forEach((m,p)=>{u.delete(p)}),d.forEach((m,p)=>{u.delete(p)}),u}),this.getInputFilterColumnMap=ge((r,l)=>{const a=new Map;for(let d=0;d<l.length;d+=1){const c=l[d],{name:u,type:m}=c,p=r.get(u);p!=null&&p.type===m&&a.set(u,c)}return a}),this.getLinkedColumnMap=ge((r,l)=>{const a=new Map,d=ie.getIdFromPanel(this);for(let c=0;c<l.length;c+=1){const u=l[c];let m=null;if(u.start!=null&&u.start.panelId===d&&r.has(u.start.columnName)?m=u.start.columnName:u.end&&u.end.panelId===d&&r.has(u.end.columnName)&&(m=u.end.columnName),m!=null&&r.has(m)){const p=r.get(m);k(p),a.set(m,p)}}return a}),this.getSelectorColumns=ge((r,l,a)=>Array.from(r.values()).map(d=>({name:d.name,type:d.type,isValid:a?a(this,d):!1,isActive:l.has(d.name)}))),this.handleColumnSelected=this.handleColumnSelected.bind(this),this.handleColumnMouseEnter=this.handleColumnMouseEnter.bind(this),this.handleColumnMouseLeave=this.handleColumnMouseLeave.bind(this),this.handleDisconnect=this.handleDisconnect.bind(this),this.handleReconnect=this.handleReconnect.bind(this),this.handleFilterAdd=this.handleFilterAdd.bind(this),this.handleHide=this.handleHide.bind(this),this.handleError=this.handleError.bind(this),this.handleLoadError=this.handleLoadError.bind(this),this.handleLoadSuccess=this.handleLoadSuccess.bind(this),this.handleResize=this.handleResize.bind(this),this.handleSettingsChanged=this.handleSettingsChanged.bind(this),this.handleOpenLinker=this.handleOpenLinker.bind(this),this.handleShow=this.handleShow.bind(this),this.handleSourceColumnChange=this.handleSourceColumnChange.bind(this),this.handleSourceFilterChange=this.handleSourceFilterChange.bind(this),this.handleSourceSortChange=this.handleSourceSortChange.bind(this),this.handleTabBlur=this.handleTabBlur.bind(this),this.handleTabFocus=this.handleTabFocus.bind(this),this.handleUpdate=this.handleUpdate.bind(this),this.updateModelFromSource=Je(this.updateModelFromSource.bind(this),TE),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.panelContainer=de.createRef(),this.chart=de.createRef(),this.pending=new ds;const{metadata:n,panelState:s}=e,{filterValueMap:i=[],settings:o={}}=s??{};this.state={settings:o,error:void 0,isActive:!1,isDisconnected:!1,isLoading:!1,isLoaded:!1,isLinked:n!=null&&Er(n)&&n.settings.isLinked,filterMap:new Map(i),filterValueMap:new Map(i),model:void 0,columnMap:new Map,panelState:s}}componentDidMount(){this.isHidden()||(this.setState({isActive:!0}),this.initModel())}componentDidUpdate(e,n){const{inputFilters:s,source:i}=this.props,{columnMap:o,model:r,filterMap:l,filterValueMap:a,isLinked:d,settings:c}=this.state;!r||(o!==n.columnMap&&this.pruneFilterMaps(),s!==e.inputFilters&&this.updateChangedInputFilters(s,e.inputFilters),l!==n.filterMap?this.updateFilters():a!==n.filterValueMap&&this.updatePanelState(),c!==n.settings&&fc(r)&&(r.updateSettings(c),this.updatePanelState()),d!==n.isLinked?i&&(d?(this.startListeningToSource(i),this.updateModelFromSource()):this.stopListeningToSource(i)):d&&i!==e.source&&(e.source&&this.stopListeningToSource(e.source),i&&(this.startListeningToSource(i),this.updateModelFromSource())))}componentWillUnmount(){this.pending.cancel();const{source:e}=this.props;e&&this.stopListeningToSource(e)}initModel(){this.setState({isLoading:!0,isLoaded:!1,error:void 0});const{makeModel:e}=this.props;this.pending.add(e(),n=>{n.close()}).then(this.handleLoadSuccess,this.handleLoadError)}startListeningToSource(e){Xt.debug("startListeningToSource",e),e.addEventListener(I.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleSourceColumnChange),e.addEventListener(I.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),e.addEventListener(I.Table.EVENT_SORTCHANGED,this.handleSourceSortChange)}stopListeningToSource(e){Xt.debug("stopListeningToSource",e),e.removeEventListener(I.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleSourceColumnChange),e.removeEventListener(I.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),e.removeEventListener(I.Table.EVENT_SORTCHANGED,this.handleSourceSortChange)}loadModelIfNecessary(){const{isActive:e,isLoaded:n,isLoading:s}=this.state;e&&!n&&!s&&this.initModel()}isHidden(){const{glContainer:e}=this.props,{isHidden:n}=e;return n}handleColumnSelected(e){const{glEventHub:n}=this.props,{columnMap:s}=this.state;n.emit(Li.COLUMN_SELECTED,this,s.get(e))}handleColumnMouseEnter({type:e,name:n}){const{columnSelectionValidator:s}=this.props;Xt.debug("handleColumnMouseEnter",s,e,n),s&&s(this,{type:e,name:n})}handleColumnMouseLeave(){const{columnSelectionValidator:e}=this.props;Xt.debug("handleColumnMouseLeave",e),e&&e(this,void 0)}handleDisconnect(){this.setState({error:new Error("Figure disconnected"),isDisconnected:!0})}handleFilterAdd(e){for(let n=0;n<e.length;n+=1)this.openInputFilter(e[n])}handleOpenLinker(){const{localDashboardId:e,setActiveTool:n,setDashboardIsolatedLinkerPanelId:s}=this.props;s(e,void 0),n(Wt.LINKER)}handleReconnect(){this.setState({isDisconnected:!1,error:void 0}),this.sendColumnChange(),this.updateColumnFilters()}handleLoadSuccess(e){Xt.debug("handleLoadSuccess");const{model:n}=this.state;this.setState({model:e,isLoaded:!0},()=>{const{inputFilters:s,source:i}=this.props,{filterMap:o,isLinked:r}=this.state;e!==n&&(this.sendColumnChange(),this.updateColumnFilters(),this.updateInputFilters(s,o.size>0||e.isFilterRequired()),i&&r&&(this.startListeningToSource(i),this.updateModelFromSource()))})}handleLoadError(e){ye.isCanceled(e)||(Xt.error("handleLoadError",e),this.setState({error:e,isLoading:!1}))}handleSourceColumnChange(){this.updateModelFromSource()}handleSourceFilterChange(){this.updateModelFromSource()}handleSourceSortChange(){this.updateModelFromSource()}updateModelFromSource(){const{metadata:e,source:n}=this.props,{isLinked:s,model:i}=this.state;if(!s||!i||!n){Xt.debug2("updateModelFromSource ignoring",s,i,n);return}if(this.pending.cancel(),Er(e)){const{settings:o}=e;this.pending.add(I.plot.Figure.create(_e.makeFigureSettings(o,n))).then(r=>{fc(i)&&i.setFigure(r)}).catch(this.handleLoadError)}this.updatePanelState()}updatePanelState(){const{sourcePanel:e}=this.props,{panelState:n,filterValueMap:s,settings:i}=this.state;let{tableSettings:o}=n??{};if(e&&vE(e.props)&&EE(e.state)){const{inputFilters:r}=e.props,{panelState:l}=e.state;l!=null&&(o=te.extractTableSettings(l,r))}this.setState({panelState:{settings:i,tableSettings:o,filterValueMap:Array.from(s)}})}handleError(){this.setState({isLoading:!1})}handleResize(){this.updateChart()}handleSettingsChanged(e){this.setState(({settings:n})=>{const s={...n,...e};return Xt.debug("Updated settings",s),{settings:s}})}handleHide(){this.setActive(!1)}handleShow(){this.setActive(!0)}handleTabBlur(){this.setActive(!1)}handleTabFocus(){const e=this.isHidden();this.setActive(!e)}handleUpdate(){this.setState({isLoading:!1})}handleClearAllFilters(){this.setState({filterValueMap:new Map,filterMap:new Map}),this.updatePanelState()}openInputFilter(e){const{glEventHub:n}=this.props,{name:s,type:i}=e;n.emit(Le.OPEN_INPUT,{title:`${s} Filter`,panelState:{name:s,type:i,isValueShown:!0},createNewStack:!0,focusElement:"input"})}setActive(e){this.setState({isActive:e},()=>{e&&(this.loadModelIfNecessary(),this.updateChart())})}sendColumnChange(){const{model:e}=this.state;if(!e)return;const{glEventHub:n}=this.props;n.emit(Le.COLUMNS_CHANGED,this,Array.from(e.getFilterColumnMap().values()))}getCoordinateForColumn(e){const n=Do.makeButtonClassName(e);if(!this.panelContainer.current)return null;const i=this.panelContainer.current.querySelector(`.${n}`)?.getBoundingClientRect()??null;if(i==null||i.width<=0||i.height<=0)return null;const o=i.left+i.width/2,r=i.bottom;return[o,r]}setFilterMap(e){Xt.debug("setFilterMap",e),this.setState(n=>{const{columnMap:s,filterMap:i}=n;let o=null;const r=new Map(n.filterValueMap);return e.forEach(({columnType:l,value:a},d)=>{const c=s.get(d);c==null||c.type!==l||(r.set(d,a),i.get(d)!==a&&(o===null&&(o=new Map(i)),o.set(d,a)))}),{filterValueMap:r,filterMap:o??i}})}unsetFilterValue(e){this.setState(n=>{const{inputFilters:s}=this.props,{columnMap:i}=n;let{filterMap:o,filterValueMap:r}=n;if(!r.has(e))return null;r=new Map(n.filterValueMap),r.delete(e);const l=this.getInputFilterColumnMap(i,s);if(l.has(e)){const a=o.get(e),d=l.get(e)?.value;d!=null&&a!==d&&(o=new Map(n.filterMap),d.length>0?o.set(e,d):o.delete(e))}else o=new Map(n.filterMap),o.delete(e);return{filterMap:o,filterValueMap:r}})}updateChangedInputFilters(e,n){const s=n.filter(o=>e.find(r=>r.name===o.name&&r.type===o.type)===void 0);s.length>0&&this.deleteInputFilters(s);const i=e.filter(o=>!n.includes(o));i.length>0&&this.updateInputFilters(i)}updateInputFilters(e,n=!1){this.setState(s=>{const{columnMap:i}=s,o=new Map(s.filterValueMap),r=new Map(s.filterMap),l=n?{filterMap:r,filterValueMap:o}:{};for(let a=0;a<e.length;a+=1){const{name:d,type:c,value:u}=e[a],m=i.get(d);m!=null&&m.type===c&&(u!=null&&r.get(d)!==u&&(u===""?r.delete(d):r.set(d,u),l.filterMap=r),o.has(d)&&(o.delete(d),l.filterValueMap=o))}return Xt.debug("updateInputFilters",l),l})}deleteInputFilters(e,n=!1){this.setState(s=>{const{columnMap:i,filterValueMap:o}=s,r=new Map(s.filterMap);let l=n;for(let a=0;a<e.length;a+=1){const{name:d,type:c}=e[a],u=i.get(d);if(u!=null&&u.type===c&&r.has(d)){const m=r.get(d);if(o.has(d)){const p=o.get(d);p!==m&&p!=null&&(l=!0,r.set(d,p))}else l=!0,r.delete(d)}}return Xt.debug("deleteInputFilters",l),l?{filterMap:r}:null})}updateColumnFilters(){this.setState(({model:e})=>e?{columnMap:e.getFilterColumnMap()}:null)}updateFilters(){const{columnMap:e,filterMap:n,model:s}=this.state;k(s);const i=this.getWaitingInputMap(s.isFilterRequired(),e,n);if(s.setFilter(n),n.size>0&&i.size===0){const o=s.getDefaultTitle(),r=jt.join(Array.from(n.entries()).map(([l,a])=>`${l}: ${a}`));o?s.setTitle(`${o}<br><span style="font-size: smaller">${r}</span>`):s.setTitle(r),Xt.debug2("updateFilters filters set",n),this.setState({isLoading:!0})}else Xt.debug2("updateFilters waiting on inputs",i),s.setTitle(s.getDefaultTitle()),this.setState({isLoading:!1});this.updatePanelState()}pruneFilterMaps(){this.setState(e=>{const{columnMap:n}=e,s=new Map(e.filterMap),i=new Map(e.filterValueMap),o={};return e.filterValueMap.forEach((r,l)=>{n.has(l)||(i.delete(l),o.filterValueMap=i)}),e.filterMap.forEach((r,l)=>{n.has(l)||(s.delete(l),o.filterMap=s)}),o})}updateChart(){this.chart.current&&this.chart.current.updateDimensions()}render(){const{columnSelectionValidator:e,glContainer:n,glEventHub:s,inputFilters:i,isLinkerActive:o,links:r,metadata:l,settings:a}=this.props,{columnMap:d,filterMap:c,error:u,model:m,isActive:p,isDisconnected:g,isLoaded:f,isLoading:C}=this.state;let S;Er(l)?S=l.table:S=l.figure;const w=this.getInputFilterColumnMap(d,i),v=this.getLinkedColumnMap(d,r),y=m!=null?this.getWaitingInputMap(m.isFilterRequired(),d,c):new Map,E=m!=null?this.getWaitingFilterMap(m.isFilterRequired(),d,c,v,w):new Map,R=u!=null?`Unable to open chart. ${u}`:void 0,F=y.size>0,D=d.size>0&&o;return h(Il,{className:Y("iris-chart-panel",{"input-required":F}),componentPanel:this,glContainer:n,glEventHub:s,onHide:this.handleHide,onClearAllFilters:this.handleClearAllFilters,onResize:this.handleResize,onShow:this.handleShow,onTabBlur:this.handleTabBlur,onTabFocus:this.handleTabFocus,errorMessage:R,isDisconnected:g,isLoading:C,isLoaded:f,widgetName:S,widgetType:"Chart",children:T("div",{ref:this.panelContainer,className:"chart-panel-container h-100 w-100",children:[h("div",{className:"chart-container h-100 w-100",children:f&&m&&h(iu,{isActive:p,model:m,settings:a,ref:this.chart,onDisconnect:this.handleDisconnect,onReconnect:this.handleReconnect,onUpdate:this.handleUpdate,onError:this.handleError,onSettingsChanged:this.handleSettingsChanged})}),h(Ht,{in:F&&!D&&!C,timeout:Xe.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:h(Pm,{inputFilterMap:w,linkedColumnMap:v,onAdd:this.handleFilterAdd,onOpenLinker:this.handleOpenLinker,columnMap:d,waitingFilterMap:E,waitingInputMap:y})}),h(Ht,{in:D,timeout:Xe.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:h(Do,{columns:this.getSelectorColumns(d,v,e),onColumnSelected:this.handleColumnSelected,onMouseEnter:this.handleColumnMouseEnter,onMouseLeave:this.handleColumnMouseLeave})})]})})}}Dl.defaultProps={columnSelectionValidator:null,isLinkerActive:!1,source:null,sourcePanel:null,panelState:null,settings:{}};Dl.displayName="ChartPanel";Dl.COMPONENT="ChartPanel";const yE=(t,e)=>{const{localDashboardId:n,metadata:s}=e;let i;s!=null&&(i=s.sourcePanelId);const o=wd(t,n),r=Ku(t,n),l=pl(t),a=Td(t,n),d=l===Wt.LINKER&&a===void 0;return{columnSelectionValidator:vd(t,n),isLinkerActive:d,inputFilters:bd(t,n),links:Ki(t,n),source:i!=null?o.get(i):void 0,sourcePanel:i!=null?r.get(i):void 0,settings:Et(t)}},_i=vt(yE,{setActiveTool:fl,setDashboardIsolatedLinkerPanelId:Lm},null,{forwardRef:!0})(Dl);const pr=J.module("CommandHistoryPanel"),Hm=class extends b.exports.Component{constructor(t){super(t),this.handleFocusHistory=this.handleFocusHistory.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleShow=this.handleShow.bind(this),this.handleSendToConsole=this.handleSendToConsole.bind(this),this.handleSendToNotebook=this.handleSendToNotebook.bind(this),this.container=de.createRef(),this.pending=new ds;const{session:e,sessionId:n,language:s}=t;this.state={panelState:{},session:e,sessionId:n,language:s,contextActions:[{action:this.handleFocusHistory,shortcut:Pt.COMMAND_HISTORY.FOCUS_HISTORY}]}}static handleError(t){pr.error(t)}componentDidMount(){const{glEventHub:t,session:e}=this.props;t.on(gt.FOCUS_HISTORY,this.handleFocusHistory),e!=null&&this.loadTable()}componentWillUnmount(){const{glEventHub:t}=this.props;t.off(gt.FOCUS_HISTORY,this.handleFocusHistory),this.pending.cancel()}handleFocusHistory(){this.container.current&&this.container.current.focus()}handleShow(){this.container.current?.restoreScrollPosition()}handleSessionOpened(t,{language:e,sessionId:n}){this.setState({session:t,sessionId:n,language:e},()=>{this.loadTable()})}handleSessionClosed(){this.pending.cancel(),this.setState({session:void 0,language:void 0,table:void 0})}handleSendToNotebook(t,e=!1){const{session:n,language:s}=this.state;if(pr.debug("handleSendToNotebook",n,t),!n){pr.error("Session is not connected.");return}const{glEventHub:i}=this.props;i.emit(e?Ae.CREATE_NOTEBOOK:Ae.SEND_TO_NOTEBOOK,n,s,t)}handleSendToConsole(t,e=!0,n=!1){pr.debug("handleSendToConsole",t);const{glEventHub:s}=this.props;s.emit(gt.SEND_COMMAND,t,e,n)}loadTable(){const{commandHistoryStorage:t}=this.props,{language:e,sessionId:n}=this.state;k(e),k(n),this.pending.add(t.getTable(e,n,Date.now()),s=>s.close()).then(s=>{this.setState({table:s})}).catch(Hm.handleError)}render(){const{glContainer:t,glEventHub:e,commandHistoryStorage:n}=this.props,{language:s,contextActions:i,table:o}=this.state;return T($n,{className:"command-history-pane",componentPanel:this,glContainer:t,glEventHub:e,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onShow:this.handleShow,children:[!o&&h("div",{className:"command-history-disconnected-message",children:"Waiting for console connection"}),o&&s!=null&&T(be,{children:[h(ul,{ref:this.container,language:s,sendToNotebook:this.handleSendToNotebook,sendToConsole:this.handleSendToConsole,table:o,commandHistoryStorage:n}),h(le,{actions:i})]})]})}};let yd=Hm;yd.COMPONENT="CommandHistoryPanel";yd.TITLE="Command History";const RE=(t,e)=>{const n=lu(t),s=ai(t,e.localDashboardId),{session:i,config:o}=s??{},{type:r,id:l}=o??{};return{commandHistoryStorage:n,language:r,session:i,sessionId:l}},zr=vt(RE,null,null,{forwardRef:!0})(yd);const gr=J.module("ConsolePanel"),IE=500,FE=Object.freeze({consoleSettings:{},itemIds:[]});class Rd extends b.exports.PureComponent{constructor(e){super(e),this.savePanelState=Je(()=>{const{consoleSettings:r,itemIds:l}=this.state,a={consoleSettings:r,itemIds:[...l]};gr.debug("Saving panel state",a),this.setState({panelState:a})},IE),this.handleFocusCommandHistory=this.handleFocusCommandHistory.bind(this),this.handleOpenObject=this.handleOpenObject.bind(this),this.handleCloseObject=this.handleCloseObject.bind(this),this.handleResize=this.handleResize.bind(this),this.handleSettingsChange=this.handleSettingsChange.bind(this),this.handleShow=this.handleShow.bind(this),this.handlePanelMount=this.handlePanelMount.bind(this),this.consoleRef=de.createRef();const{panelState:n}=e,s={...FE,...n||{}},{consoleSettings:i,itemIds:o}=s;this.state={consoleSettings:i,itemIds:new Map(o),objectMap:new Map,error:void 0,panelState:s}}componentDidMount(){const{glEventHub:e}=this.props;this.closeDisconnectedPanels(),e.on(Ee.MOUNT,this.handlePanelMount),this.subscribeToFieldUpdates()}componentDidUpdate(e,n){const{consoleSettings:s,itemIds:i}=this.state;(n.consoleSettings!==s||n.itemIds!==i)&&this.savePanelState()}componentWillUnmount(){const{glEventHub:e}=this.props;this.savePanelState.flush(),e.off(Ee.MOUNT,this.handlePanelMount),this.objectSubscriptionCleanup?.()}subscribeToFieldUpdates(){const{sessionWrapper:e}=this.props,{session:n}=e;this.objectSubscriptionCleanup=n.subscribeToFieldUpdates(s=>{gr.debug("Got updates",s),this.setState(({objectMap:i})=>{const{updated:o,created:r,removed:l}=s,a=[...o,...l],d=new Map(i);return a.forEach(u=>{const{title:m}=u;m!==void 0&&d.delete(m)}),[...o,...r].forEach(u=>{u.title!==void 0&&d.set(u.title,u)}),{objectMap:d}})})}setItemId(e,n){this.setState(({itemIds:s})=>{const i=new Map(s);return i.set(e,n),{itemIds:i}})}getItemId(e,n=!0){const{itemIds:s}=this.state;let i=s.get(e);return i==null&&n&&(i=$e.generate(),this.setItemId(e,i)),i}handleTabFocus(){this.consoleRef.current?.focus()}handlePanelMount(e){const{itemIds:n}=this.state,s=e?.props?.id,i=e?.props?.metadata?.sourcePanelId;s&&i&&new Set(n.values()).has(i)&&this.setItemId(s,s)}handleFocusCommandHistory(){const{glEventHub:e}=this.props;e.emit(gt.FOCUS_HISTORY)}handleResize(){this.updateDimensions()}handleShow(){this.updateDimensions()}handleOpenObject(e){const{sessionWrapper:n}=this.props,{session:s}=n;this.openWidget(e,s)}handleCloseObject(e){const{title:n}=e;if(n!==void 0){const s=this.getItemId(n,!1),{glEventHub:i}=this.props;i.emit(Ee.CLOSE,s)}}handleSettingsChange(e){const{glEventHub:n}=this.props;gr.debug("handleSettingsChange",e),this.setState({consoleSettings:e}),n.emit(gt.SETTINGS_CHANGED,e)}openWidget(e,n){const{glEventHub:s}=this.props,{title:i}=e;k(i);const o=this.getItemId(i),r={fetch:()=>n.getObject(e),panelId:o,widget:e};gr.debug("openWidget",r),s.emit(Ee.OPEN,r)}addCommand(e,n=!0,s=!1){this.consoleRef.current?.addCommand(e,n,s)}closeDisconnectedPanels(e=!1){const{consoleSettings:n,itemIds:s}=this.state,{isClosePanelsOnDisconnectEnabled:i=!0}=n;if(!i&&!e)return;const o=[...s.values()],{glEventHub:r}=this.props;o.forEach(l=>{r.emit(Ee.CLOSE,l)}),this.setState({itemIds:new Map})}updateDimensions(){this.consoleRef.current?.updateDimensions()}render(){const{commandHistoryStorage:e,glContainer:n,glEventHub:s,sessionWrapper:i,timeZone:o,unzip:r}=this.props,{consoleSettings:l,error:a,objectMap:d}=this.state,{config:c,session:u,connection:m}=i,{id:p,type:g}=c;return h($n,{componentPanel:this,glContainer:n,glEventHub:s,onResize:this.handleResize,onShow:this.handleShow,onTabFocus:this.handleTabFocus,errorMessage:a!=null?`${a}`:void 0,children:u!=null&&h(za,{ref:this.consoleRef,settings:l,session:u,focusCommandHistory:this.handleFocusCommandHistory,openObject:this.handleOpenObject,closeObject:this.handleCloseObject,commandHistoryStorage:e,onSettingsChange:this.handleSettingsChange,language:g,statusBarChildren:T(be,{children:[h("div",{children:"\xA0"}),h("div",{children:Ph.LANGUAGE_MAP.get(g)}),h("div",{children:"\xA0"}),h("div",{children:h(QC,{connection:m,defaultUpdateInterval:10*1e3,hoverUpdateInterval:3*1e3,monitorDuration:10*60*1e3})}),h("div",{children:"\xA0"})]}),scope:p,timeZone:o,objectMap:d,unzip:r})})}}Rd.COMPONENT="ConsolePanel";Rd.TITLE="Console";const DE=(t,e)=>({commandHistoryStorage:lu(t),sessionWrapper:ai(t,e.localDashboardId),timeZone:ko(t)}),Ii=vt(DE,null,null,{forwardRef:!0})(Rd);const fr=J.module("DropdownFilter"),NE=150,yr=class extends b.exports.Component{constructor(t){super(t),this.getCompatibleColumns=ge((i,o)=>i!=null?o.filter(({type:r})=>r!==void 0&&_.isCompatibleType(r,i.columnType)):[]),this.getColumnOptions=ge((i,o)=>{let r=-1;const l=[];return l.push(h("option",{value:"-1",children:"Select a column"},"placeholder")),i.forEach((a,d)=>{l.push(h("option",{value:d,children:this.getItemLabel(i,d)},`${a.name}/${a.type}`)),o!==null&&a.name===o.name&&a.type===o.type&&(r=d)}),[l,r]}),this.getSelectedOptionIndex=ge((i,o)=>i.indexOf(o)),this.getValueOptions=ge(i=>[h("option",{value:"-1",children:yr.PLACEHOLDER},"-1"),...i.map((o,r)=>h("option",{value:r,children:o??"(null)"},`${r}/${o}`))]),this.getItemLabel=Ie((i,o)=>{const{name:r,type:l}=i[o];if(o>0&&i[o-1].name===r||o<i.length-1&&i[o+1].name===r){const a=l.substring(l.lastIndexOf(".")+1);return`${r} (${a})`}return r}),this.sendUpdate=Je(()=>{const{onChange:i}=this.props,{column:o,value:r,isValueShown:l}=this.state;i({column:o,isValueShown:l,value:r??void 0})},NE),this.handleColumnChange=this.handleColumnChange.bind(this),this.handleSettingsCancel=this.handleSettingsCancel.bind(this),this.handleSettingsClick=this.handleSettingsClick.bind(this),this.handleSettingsSave=this.handleSettingsSave.bind(this),this.handleBackgroundClick=this.handleBackgroundClick.bind(this),this.handleDropdownKeyPress=this.handleDropdownKeyPress.bind(this),this.handleValueChange=this.handleValueChange.bind(this),this.dropdownRef=de.createRef();const{column:e,isValueShown:n,value:s}=t;this.state={column:e,id:$e(),selectedColumn:e,disableCancel:!n,isValueShown:n,value:s}}componentDidUpdate(t,e){const{source:n,values:s,isLoaded:i}=this.props,{column:o,value:r,isValueShown:l}=this.state;i&&(n!==t.source&&this.sourceUpdated(),s!==t.values&&r!==""&&!s.includes(r)&&this.resetValue(),l!==e.isValueShown&&l&&this.focusInput(),(o!==e.column||r!==e.value||l!==e.isValueShown)&&this.sendUpdate())}componentWillUnmount(){this.sendUpdate.flush()}handleColumnChange(t){const{value:e}=t.target;if(fr.debug2("handleColumnChange",e),e!=null&&parseInt(e,10)<0){this.setState({selectedColumn:null});return}const{columns:n,source:s}=this.props,i=this.getCompatibleColumns(s,n);this.setState({selectedColumn:i[parseInt(e,10)]})}handleDropdownKeyPress(t){t.key==="Enter"&&(t.preventDefault(),t.stopPropagation(),fr.debug2("handleDropdownKeyPress"),this.sendUpdate(),this.sendUpdate.flush())}handleValueChange(t){const{value:e}=t.target,n=parseInt(e,10);let s="";const{values:i}=this.props;n>=0&&n<i.length?s=i[n]:fr.debug2("Selected default item"),fr.debug2("handleValueChange",s),this.setState({value:s})}handleSettingsCancel(){this.setState(({column:t})=>({selectedColumn:t,isValueShown:!0}))}handleSettingsSave(){this.setState(({column:t,selectedColumn:e,value:n})=>({column:e,value:t===e?n:"",isValueShown:!0,disableCancel:!1}))}handleSettingsClick(t){t.stopPropagation(),this.showSettings()}handleBackgroundClick(t){t.target!==this.dropdownRef.current&&this.focusInput()}sourceUpdated(){this.setState({column:null,selectedColumn:null,isValueShown:!1,disableCancel:!0,value:""})}showSettings(){const{column:t}=this.state;this.setState({selectedColumn:t,isValueShown:!1})}focusInput(){this.dropdownRef.current?.focus()}resetValue(){this.setState({value:""})}clearFilter(){this.resetValue()}setFilterState({name:t,type:e,value:n,isValueShown:s}){const i=t!=null&&e!=null?{name:t,type:e}:null;this.setState(({value:o,isValueShown:r})=>({column:i,value:n??o,isValueShown:s??r}))}render(){const{columns:t,disableLinking:e,isLinkerActive:n,isLoaded:s,source:i,onColumnSelected:o,onSourceMouseEnter:r,onSourceMouseLeave:l,values:a,settingsError:d}=this.props,{column:c,disableCancel:u,id:m,isValueShown:p,selectedColumn:g,value:f}=this.state,C=i===null,S=this.getCompatibleColumns(i,t),w=i!=null,v=i?.columnName??yr.SOURCE_BUTTON_PLACEHOLDER,y=c!=null?`${c.name} Filter`:null,[E,R]=this.getColumnOptions(S,g),F=this.getValueOptions(a),D=this.getSelectedOptionIndex(a,f),N=!w||g==null,P=p&&!n,H=`source-column-btn-${m}`,A=`filter-column-select-${m}`;return T(Ga,{className:"dropdown-filter fill-parent-absolute",isFlipped:P,children:[h("div",{className:"dropdown-filter-settings-card",children:T("div",{className:"dropdown-filter-card-content",children:[T("div",{className:"dropdown-filter-settings-grid",children:[h("label",{htmlFor:H,children:"Source Column"}),h(Nh,{id:H,isLinked:w,onClick:o,onMouseEnter:r,onMouseLeave:l,className:yr.SOURCE_BUTTON_CLASS_NAME,disabled:e,children:v}),h("div",{className:"text-muted small",children:"Select a source column for the list by linking to a table."}),h("label",{htmlFor:A,children:"Filter Column"}),h("select",{id:A,value:R,className:"custom-select",onChange:this.handleColumnChange,disabled:C,children:E}),h("div",{className:"text-muted small",children:"Dropdown filter control will apply its filter to all columns matching this name in this dashboard."})]}),d&&h("div",{className:"error-message text-center",children:d}),w&&T("div",{className:"dropdown-filter-settings-buttons",children:[h(U,{kind:"secondary",type:"button",onClick:this.handleSettingsCancel,disabled:u||p||n,tooltip:n?"Cancel disabled while linker open":void 0,children:"Cancel"}),h(U,{kind:"primary",type:"button",className:"ml-2",onClick:this.handleSettingsSave,disabled:N||p||n,tooltip:n?"Save disabled while linker open":void 0,children:"Save"})]})]})}),h("div",{className:"dropdown-filter-value-card",onClick:this.handleBackgroundClick,"data-testid":"dropdown-filter-value-background",children:s&&T(be,{children:[h("div",{className:"dropdown-filter-column",children:h("div",{className:"dropdown-filter-column-title",children:y})}),T("div",{className:"dropdown-filter-card-content",children:[h("div",{className:"dropdown-filter-value-input d-flex flex-column justify-content-center",children:h("select",{className:"custom-select",value:D,ref:this.dropdownRef,onChange:this.handleValueChange,onKeyPress:this.handleDropdownKeyPress,title:"Select Value",children:F})}),d&&h("div",{className:"error-message mt-3 text-center",children:d})]}),h("div",{className:"dropdown-filter-menu",children:h(U,{kind:"ghost",className:"m-2 px-2",onClick:this.handleSettingsClick,icon:h(Z,{icon:_o,transform:"grow-4"}),tooltip:"Dropdown Filter Settings"})})]})})]})}};let Pi=yr;Pi.defaultProps={column:null,disableLinking:!1,isLinkerActive:!1,isLoaded:!1,isValueShown:!1,settingsError:null,source:null,value:"",values:[],onColumnSelected:()=>{},onSourceMouseEnter:()=>{},onSourceMouseLeave:()=>{}};Pi.PLACEHOLDER="Select a value...";Pi.SOURCE_BUTTON_CLASS_NAME="btn-dropdown-filter-selector";Pi.SOURCE_BUTTON_PLACEHOLDER="Select a column";const rt=J.module("DropdownFilterPanel"),_E=250,ME=(t,e)=>{const{localDashboardId:n}=e,s=ie.getIdFromPanel({props:e}),i=wd(t,n),o=Ki(t,n),r=pl(t),l=Td(t,n),a=r===Wt.LINKER&&(l===void 0||l===s),d=r===Wt.LINKER&&l!==void 0&&l!==s;return{columns:Am(t,n),columnSelectionValidator:vd(t,n),isLinkerActive:a,disableLinking:d,settings:Et(t),panelTableMap:i,dashboardLinks:o}},kE=vt(ME,null,null,{forwardRef:!0}),Zs=class extends b.exports.Component{constructor(t){super(t),this.getCachedValues=Ie((d,{type:c,name:u},m)=>c!==void 0&&_.isDateType(c)?d.map(p=>Zs.DATETIME_FORMATTER.format(p)):d.map(p=>p!=null&&c!=null?m.getFormattedString(p,c,u):null)),this.getCachedPanelLinks=Ie((d,c)=>{const u=ie.getIdFromPanel(c);return rt.debug("getCachedPanelLinks",d,u),d.filter(m=>m.end?.panelId===u)}),this.getCachedSource=Ie(d=>{rt.debug("getCachedSource",d);let c;if(d.length>0){const[u]=d;c=u.start,d.length>1&&rt.error("Filter has more that one link",d)}return c}),this.getCachedSourceTable=Ie((d,c)=>{if(rt.debug("getCachedSourceTable",d,c),c==null)return null;const{panelId:u}=c;return d.get(u)??null}),this.getCachedSourceColumn=Ie((d,c)=>(rt.debug("getCachedSourceColumn",d,c),d==null||c==null?null:d.columns.find(({name:u,type:m})=>u===c.columnName&&m===c.columnType)??null)),this.handleChange=Je(this.handleChange.bind(this),_E),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.handleDisconnect=this.handleDisconnect.bind(this),this.handleReconnect=this.handleReconnect.bind(this),this.handleColumnSelected=this.handleColumnSelected.bind(this),this.handleSourceFilterChange=this.handleSourceFilterChange.bind(this),this.handleSourceSortChange=this.handleSourceSortChange.bind(this),this.handleSourceSizeChange=this.handleSourceSizeChange.bind(this),this.handleSourceMouseEnter=this.handleSourceMouseEnter.bind(this),this.handleSourceMouseLeave=this.handleSourceMouseLeave.bind(this),this.handleValuesTableUpdate=this.handleValuesTableUpdate.bind(this),this.dropdownFilterRef=de.createRef(),this.panelContainer=de.createRef(),this.pending=new ds;const{panelState:e,settings:n}=t;this.columnFormats=rs.getColumnFormats(n);const{value:s="",isValueShown:i=!1,name:o,type:r,timestamp:l}=e??{},a=o!=null&&r!=null?{name:o,type:r}:void 0;this.state={column:a,formatter:new nn(this.columnFormats),valuesTable:void 0,valuesColumn:void 0,sourceSize:0,value:s,timestamp:l,values:[],isValueShown:i,wasFlipped:!1,skipUpdate:!1,panelState:e,isDisconnected:!1,isLoading:!1,isLoaded:!1,error:null}}componentDidMount(){this.updateValuesTable();const{dashboardLinks:t,panelTableMap:e}=this.props,{column:n,value:s,timestamp:i}=this.state,o=this.getSourceTable(e,t);if(o!==null&&this.startListeningToSource(o),n!=null){const{name:r,type:l}=n;this.sendUpdate(r,l,s,i)}}componentDidUpdate(t,e){const{dashboardLinks:n,panelTableMap:s,settings:i}=this.props,{valuesTable:o}=this.state,r=this.getSource(n),l=this.getSourceTable(s,n),a=this.getSource(t.dashboardLinks),d=this.getSourceTable(t.panelTableMap,t.dashboardLinks);i!==t.settings&&i!==void 0&&this.updateFormatterSettings(i),o!==e.valuesTable&&e.valuesTable!=null&&(rt.debug("Table in state modified, closing the old table."),e.valuesTable.close()),(l!==d||r!==a)&&this.updateValuesTable(),l!==d&&(d!==null&&this.stopListeningToSource(d),l!==null&&this.startListeningToSource(l))}componentWillUnmount(){const{dashboardLinks:t,panelTableMap:e}=this.props,{valuesTable:n}=this.state,s=this.getSourceTable(e,t);this.pending.cancel(),s!==null&&this.stopListeningToSource(s),this.cleanup&&this.cleanup(),n?.close()}getCoordinateForColumn(){if(this.panelContainer.current==null)return null;const e=this.panelContainer.current.querySelector(`.${Pi.SOURCE_BUTTON_CLASS_NAME}`)?.getBoundingClientRect()??null;if(e==null||e.width<=0||e.height<=0)return null;const n=e.left+e.width/2,s=e.bottom;return[n,s]}getSettingsErrorMessage(){const{sourceSize:t}=this.state;if(t>Zs.MAX_TABLE_SIZE)return`Table too large, must have fewer than ${Zs.MAX_TABLE_SIZE} options.`}getPanelErrorMessage(){const{error:t}=this.state;return t!=null?`${t}`:void 0}getSource(t){const e=this.getCachedPanelLinks(t,this);return this.getCachedSource(e)}getSourceTable(t,e){const n=this.getSource(e);return this.getCachedSourceTable(t,n)}getValuesColumn(t,e){const n=this.getSource(e);return this.getCachedSourceColumn(t,n)}startListeningToSource(t){rt.debug("startListeningToSource"),t.addEventListener(I.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),t.addEventListener(I.Table.EVENT_SORTCHANGED,this.handleSourceSortChange),t.addEventListener(I.Table.EVENT_SIZECHANGED,this.handleSourceSizeChange),t.addEventListener(I.Table.EVENT_DISCONNECT,this.handleDisconnect),t.addEventListener(I.Table.EVENT_RECONNECT,this.handleReconnect)}stopListeningToSource(t){rt.debug("stopListeningToSource"),t.removeEventListener(I.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),t.removeEventListener(I.Table.EVENT_SORTCHANGED,this.handleSourceSortChange),t.removeEventListener(I.Table.EVENT_SIZECHANGED,this.handleSourceSizeChange),t.removeEventListener(I.Table.EVENT_DISCONNECT,this.handleDisconnect),t.removeEventListener(I.Table.EVENT_RECONNECT,this.handleReconnect)}handleChange({column:t,isValueShown:e=!1,value:n}){const{name:s=void 0,type:i=void 0}=t??{};let o=!0,r=Date.now();this.setState(({panelState:l,timestamp:a,wasFlipped:d,skipUpdate:c})=>{const u=l!=null&&e!==l.isValueShown&&s===l.name&&i===l.type&&n===l.value;return o=(!c&&e&&(!u||!d))??!1,o||(r=a),{panelState:{isValueShown:e,name:s,type:i,value:n,timestamp:r??void 0},timestamp:r,wasFlipped:u,skipUpdate:!1}},()=>{o&&this.sendUpdate(s??null,i,n,r)})}handleDisconnect(){this.setState({error:new Error("Table disconnected"),isDisconnected:!0,isLoading:!1})}handleReconnect(){this.setState({isDisconnected:!1,error:null})}handleSourceFilterChange(){this.applySourceFilters()}handleSourceSortChange(){this.applySourceSorts()}handleSourceSizeChange({detail:t}){this.setState({sourceSize:t})}handleColumnSelected(){rt.debug("handleColumnSelected");const{glEventHub:t}=this.props;t.emit(Le.COLUMN_SELECTED,this,Zs.SOURCE_COLUMN)}handleClearAllFilters(){this.dropdownFilterRef?.current?.clearFilter()}setPanelState(t,e=!1){const{dashboardLinks:n}=this.props;if(this.getSource(n)==null){rt.debug("Ignore state update for unlinked filter",t);return}this.setState({skipUpdate:!e}),this.dropdownFilterRef?.current?.setFilterState(t)}sendUpdate(t,e,n,s){const{dashboardLinks:i,glEventHub:o}=this.props,r=this.getSource(i)?.panelId,l=r===null?[]:[r];rt.debug("sendUpdate",{name:t,type:e,value:n,timestamp:s,excludePanelIds:l}),o.emit(Le.FILTERS_CHANGED,this,{name:t,type:e,value:n??"=null",timestamp:s,excludePanelIds:l})}updateValuesTable(){const{dashboardLinks:t,panelTableMap:e}=this.props,n=this.getSource(t),s=this.getSourceTable(e,t);if(rt.debug("updateValuesTable",n,s),this.setState({values:[],valuesTable:void 0,error:null}),n==null){rt.debug("Filter unlinked."),this.setState({isLoading:!1,isLoaded:!0,isValueShown:!1,sourceSize:0});return}this.setState({isLoading:!0}),s!=null&&(this.setState({isLoaded:!1,sourceSize:s.size}),this.pending.add(s.copy(),i=>i.close()).then(i=>{this.updateViewportListener(i),this.setState({valuesTable:i})}).catch(i=>{ye.isCanceled(i)||(rt.error(i),this.setState({isLoading:!1,error:i}))}))}applySourceSorts(){const{dashboardLinks:t,panelTableMap:e}=this.props,{valuesTable:n}=this.state,s=this.getSourceTable(e,t);if(rt.debug("applySourceSorts",s?.sort),n==null||s==null){rt.debug("Table not initialized");return}const i=[...s.sort];n.applySort(i),this.setViewport(n)}applySourceFilters(){const{dashboardLinks:t,panelTableMap:e}=this.props,{valuesTable:n}=this.state,s=this.getSourceTable(e,t);if(rt.debug("applySourceFilters",s?.filter),n==null||s==null){rt.debug("Table not initialized");return}const i=[...s.filter];n.applyFilter(i),this.setViewport(n)}updateViewportListener(t){if(rt.debug("updateViewportListener",t?.size),this.cleanup&&this.cleanup(),t==null){this.cleanup=void 0;return}this.cleanup=t.addEventListener(I.Table.EVENT_UPDATED,this.handleValuesTableUpdate),this.setViewport(t)}setViewport(t){const{dashboardLinks:e}=this.props,n=this.getValuesColumn(t,e);if(!n){rt.error("values column is null");return}t.setViewport(0,Zs.MAX_TABLE_SIZE-1,[n])}updateFormatterSettings(t){const e=rs.getColumnFormats(t);ct(this.columnFormats,e)||(this.columnFormats=e,this.setState({formatter:new nn(e)}))}handleValuesTableUpdate({detail:t}){const{rows:e}=t,{dashboardLinks:n}=this.props,{valuesTable:s}=this.state;if(!s){rt.error("valuesTable is null");return}const i=this.getValuesColumn(s,n);if(!i){rt.error("Values column not found");return}const o=e.map(r=>r.get(i));this.setState({values:o,isLoading:!1,isLoaded:!0,valuesColumn:i})}handleSourceMouseEnter(){const{columnSelectionValidator:t}=this.props;!t||t(this,Zs.SOURCE_COLUMN)}handleSourceMouseLeave(){const{columnSelectionValidator:t}=this.props;!t||t(this,void 0)}render(){const{columns:t,dashboardLinks:e,disableLinking:n,glContainer:s,glEventHub:i,isLinkerActive:o}=this.props,{column:r,formatter:l,isDisconnected:a,isValueShown:d,value:c,values:u,valuesColumn:m,isLoading:p,isLoaded:g}=this.state,f=this.getSource(e),C=this.getSettingsErrorMessage(),S=this.getPanelErrorMessage(),w=g&&m!=null?this.getCachedValues(u,m,l):[];return h(Il,{errorMessage:S,isLoading:p,isLoaded:g,isDisconnected:a,className:"iris-dropdown-filter-panel",componentPanel:this,glContainer:s,glEventHub:i,onClearAllFilters:this.handleClearAllFilters,widgetName:"Dropdown Filter",widgetType:"DropdownFilter",children:h("div",{ref:this.panelContainer,className:"dropdown-filter-container h-100 w-100 container",children:h(Pi,{ref:this.dropdownFilterRef,column:r,columns:t,isValueShown:d,isLinkerActive:o,disableLinking:n,isLoaded:g,settingsError:C,source:f,value:c,values:w,onChange:this.handleChange,onColumnSelected:this.handleColumnSelected,onSourceMouseEnter:this.handleSourceMouseEnter,onSourceMouseLeave:this.handleSourceMouseLeave})})})}};let Xi=Zs;Xi.displayName="DropdownFilterPanel";Xi.COMPONENT="DropdownFilterPanel";Xi.MAX_TABLE_SIZE=256;Xi.DATETIME_FORMATTER=new st({showTimeZone:!1,showTSeparator:!0,defaultDateTimeFormatString:"yyyy-MM-dd HH:mm:ss.SSSSSSSSS"});Xi.SOURCE_COLUMN=Object.freeze({name:"FilterSource",type:null});const ii=kE(Xi);function An(t){return t.type==="directory"}var Um=(t=>(t.GROOVY="text/x-groovy",t.PLAIN_TEXT="text/plain",t.PYTHON="text/x-python",t.PYTHON_COMPILED="application/x-python-code",t.SCALA="text/x-scala",t.UNKNOWN="",t))(Um||{});class me{static fileExtensionToString(e=""){return e.length===0?"":`.${e}`}static getDepth(e){if(!me.hasPath(e))throw new Error(`Invalid path provided: ${e}`);return(e.match(/\//g)??[]).length-1}static getExtension(e){const n=this.getBaseName(e).split(".");return n.length>1?n.pop()??"":""}static getBaseName(e){return e.split("/").pop()??""}static getCopyFileName(e){const n=e.lastIndexOf(".");let s=null,i=null;n<0?i=e:(i=e.substring(0,n),s=e.substring(n+1));const o=i?`${i}-copy`:"Copy";return s!==null?`${o}.${s}`:o}static getMimeType(e){switch(this.getExtension(e).toLowerCase()){case"groovy":return"text/x-groovy";case"py":return"text/x-python";case"pyc":return"application/x-python-code";case"scala":return"text/x-scala";case"txt":return"text/plain";default:return""}}static getParent(e){if(!me.hasPath(e))throw new Error(`Invalid name provided: ${e}`);const n=e.split("/");for(;n.pop()==="";);if(n.length===0)throw new Error(`No parent for path provided: ${e}`);return`${n.join("/")}/`}static getPath(e){if(!me.hasPath(e))throw new Error(`Invalid filename provided: ${e}`);const n=e.split("/");return n.pop(),`${n.join("/")}/`}static hasPath(e){return e.startsWith("/")}static isPath(e){return e.startsWith("/")&&e.endsWith("/")}static makePath(e){return e.endsWith("/")?e:`${e}/`}static replaceExtension(e,n=""){const s=e.lastIndexOf("."),i=s>-1?e.substring(0,s):e,o=me.fileExtensionToString(n);return`${i}${o}`}static validateName(e){const n=[".",".."],s=/[\\/\0]/g,i=new Map([["\0","null"]]);if(!e)throw new Di("Name cannot be empty");if(n.includes(e))throw new Di(`"${e}" is a reserved name`);if(s.test(e))throw new Di(`Invalid characters in name: "${e.match(s)?.reduce((o,r)=>o.includes(r)?o:[...o,r],[]).map(o=>i.has(o)?i.get(o):o).join('", "')??""}"`)}static reducePaths(e){const n=e.filter(s=>me.isPath(s));return e.filter(s=>!n.some(i=>s!==i&&s.startsWith(i)))}static removeRoot(e,n){if(e.length===0)return n;if(!n.startsWith(e))throw new Error(`Filename ${n} does not start with expected root ${e}`);return n.substring(e.length)}static addRoot(e,n){return`${e}${n}`}}const xt=J.module("FileList"),ya=t=>An(t)?me.makePath(t.filename):me.getPath(t.filename),Id=26,xE=500,$c="item-list-scroll-pane",Ra=t=>{const{children:e,draggedItems:n,isDragInProgress:s,isDropTargetValid:i,isSelected:o,item:r,itemIndex:l,dropTargetItem:a,onDragStart:d,onDragOver:c,onDragEnd:u,onDrop:m}=t,p=n?.some(R=>R.id===r.id)??!1,g=ya(r),f=s&&a?ya(a):null,C=s&&i&&An(r)&&f===g,S=s&&i&&f===g,w=s&&!i&&f===g,v=OE(r),y=me.getDepth(r.filename),E=Array(y).fill(null).map((R,F)=>h("span",{className:"file-list-depth-line"},F));return T("div",{className:Y("d-flex w-100 align-items-center","file-list-item",{"is-dragged":p,"is-exact-drop-target":C,"is-in-drop-target":S,"is-invalid-drop-target":w,"is-selected":o}),onDragStart:R=>d(l,R),onDragOver:R=>c(l,R),onDragEnd:R=>u(l,R),onDrop:R=>m(l,R),draggable:!0,role:"presentation","aria-label":r.basename,children:[E," ",h(Z,{icon:v,className:"item-icon",fixedWidth:!0})," ",T("span",{className:"truncation-wrapper",children:[e??r.basename,h(ut,{options:{placement:"left"},children:e??r.basename})]})]})};function OE(t){if(An(t))return t.isExpanded?Yg:Kg;switch(me.getMimeType(t.basename)){case Um.PYTHON:return jg;default:return Xg}}function Gc(t,e){if(t.length===0||e==null)throw new Error("No items to move");const n=ya(e);if(t.some(({filename:s})=>me.getPath(s)===n))throw new Error("File already in the destination folder");if(t.some(s=>An(s)&&n.startsWith(me.makePath(s.filename))))throw new Error("Destination folder cannot be a child of a dragged folder");return{files:t,targetPath:n}}function AE(t){const{isMultiSelect:e=!1,table:n,onFocusChange:s=()=>{},onMove:i,onSelect:o,onSelectionChange:r=()=>{},renderItem:l=Ra,rowHeight:a=Id,overscanCount:d=ki.DEFAULT_OVERSCAN}=t,[c,u]=b.exports.useState(()=>({items:[],offset:0,itemCount:0})),[m,p]=b.exports.useState({top:0,bottom:0}),[g,f]=b.exports.useState(),[C,S]=b.exports.useState(),[w,v]=b.exports.useState(),[y,E]=b.exports.useState([]),R=b.exports.useRef(null),F=b.exports.useRef(null),D=b.exports.useCallback(Q=>{if(Q.length===0||c==null)return[];const he=[];for(let Se=0;Se<Q.length;Se+=1){const Re=Q[Se];for(let et=Re[0];et<=Re[1];et+=1)et>=c.offset&&et<c.offset+c.items.length&&he.push(c.items[et-c.offset])}return he},[c]),N=b.exports.useCallback(Q=>{const he=D([[Q,Q]]);if(he.length>0)return he[0]},[D]),P=b.exports.useCallback(()=>{const Q=Xd.count(y);if(Q===0)return null;if(Q===1){const he=y[0][0],Se=N(he);if(Se!=null)return Se.filename}return`${Q} items`},[N,y]),H=b.exports.useCallback(Q=>{if(!(!C||!g)){xt.debug("dropItems",C,"to",Q);try{const{files:he,targetPath:Se}=Gc(C,g);i?.(he,Se),Q!=null&&(E([[Q,Q]]),R.current?.focusItem(Q))}catch(he){xt.error("Unable to complete move",he)}}},[C,g,i]),A=b.exports.useCallback((Q,he)=>{const Se=c.items[Q-c.offset];Se!==void 0&&(xt.debug("handleItemClick",Se),o(Se,he),An(Se)&&n?.setExpanded(Se.filename,!Se.isExpanded))},[c,o,n]),q=b.exports.useCallback((Q,he)=>{xt.debug2("handleItemDragStart",Q,y);let Se=y;Xd.isSelected(y,Q)||(Se=[[Q,Q]],E(Se)),S(D(Se)),R.current?.resetMouseState();const Re=document.createElement("div");Re.innerHTML=`<div class="dnd-placeholder-content">${P()}</div>`,Re.className="file-list-dnd-placeholder",document.body.appendChild(Re),he.dataTransfer.setDragImage(Re,0,0),he.dataTransfer.effectAllowed="move",v(Re)},[P,D,y]),B=b.exports.useCallback((Q,he)=>{he.preventDefault(),xt.debug2("handleItemDragOver",he),f(N(Q))},[N]),K=b.exports.useCallback((Q,he)=>{xt.debug("handleItemDragEnd",Q),w?.remove(),S(void 0),f(void 0),v(void 0)},[w]),x=b.exports.useCallback((Q,he)=>{H(Q)},[H]),O=b.exports.useCallback(()=>{xt.debug2("handleItemDragExit"),f(void 0)},[]),G=b.exports.useCallback(Q=>{Q.target instanceof Element&&Q.target.classList.contains($c)&&(Q.preventDefault(),xt.debug2("handleListDragOver",Q),f({type:"directory",filename:"/",basename:"/",id:"/"}))},[]),ee=b.exports.useCallback(Q=>{Q.target instanceof Element&&Q.target.classList.contains($c)&&(xt.debug("handleListDrop"),H())},[H]),ne=b.exports.useCallback(Q=>{if(xt.debug2("handleSelectionChange",Q),Q!==y){E(Q);const he=D(Q);r(he)}},[D,r,y]),V=b.exports.useCallback(Q=>{if(xt.debug2("handleFocusChange",Q),Q!=null){const[he]=D([[Q,Q]]);s(he)}else s()},[D,s]),W=b.exports.useCallback((Q,he)=>{xt.debug("handleViewportChange",Q,he),(Q!==m.top||he!==m.bottom)&&p({top:Q,bottom:he})},[m]),X=b.exports.useMemo(()=>{if(!C||!g)return!1;try{return Gc(C,g),xt.debug("handleValidateDropTarget true"),!0}catch{return xt.debug("handleValidateDropTarget false"),!1}},[C,g]),{focusedPath:se}=t;b.exports.useEffect(()=>{se!==void 0&&(se==="/"?n.collapseAll():(n.setExpanded(se,!1),n.setExpanded(se,!0)))},[n,se]),b.exports.useEffect(function(){xt.debug("updating table viewport",m),n?.setViewport({top:Math.max(0,m.top-d),bottom:m.bottom+d})},[d,n,m]),b.exports.useEffect(function(){const he=n.onUpdate(Se=>{u({items:Se.items.map(Re=>({...Re,itemName:Re.basename})),offset:Se.offset,itemCount:n.size})});return()=>{he()}},[n]),b.exports.useEffect(function(){if(g!=null&&An(g)&&g.filename!=="/"){const he=setTimeout(()=>{g.isExpanded||n?.setExpanded(g.filename,!0)},xE);return()=>clearTimeout(he)}},[g,n]);const ce=b.exports.useCallback(Q=>l({...Q,isDragInProgress:C!=null,dropTargetItem:g,draggedItems:C,isDropTargetValid:X,onDragStart:q,onDragEnd:K,onDragOver:B,onDragExit:O,onDrop:x}),[K,O,B,q,x,C,g,X,l]);return h("div",{ref:F,className:Y("file-list",{"is-dragging":C!=null}),onDragOver:G,onDrop:ee,children:h(ki,{ref:R,items:c.items,itemCount:c.itemCount,offset:c.offset,onFocusChange:V,onSelect:A,onSelectionChange:ne,onViewportChange:W,selectedRanges:y,renderItem:ce,rowHeight:a,isMultiSelect:e,isDragSelect:!1,isDeselectOnClick:!1})})}const LE={name:"File Explorer",DELETE:qe.createAndAdd({id:"FILE_EXPLORER.DELETE",name:"Delete",shortcut:[Fe.DELETE],macShortcut:[Te.CMD,Fe.BACKSPACE]}),RENAME:qe.createAndAdd({id:"FILE_EXPLORER.RENAME",name:"Rename",shortcut:[Fe.ENTER],macShortcut:[Fe.ENTER]})},Wc={FILE_EXPLORER:LE};const zc=J.module("FileListItemEditor"),PE=()=>Promise.resolve();function HE({item:t,onCancel:e,onSubmit:n,validate:s=PE}){const i=b.exports.useRef(null),[o,r]=b.exports.useState(t.basename),[l,a]=b.exports.useState(),[d,c]=b.exports.useState(Promise.resolve()),u=b.exports.useCallback(()=>{i.current?.focus()},[i]),m=b.exports.useCallback(S=>S.stopPropagation(),[]),p=b.exports.useCallback(()=>{d.then(()=>{n(o)}).catch(S=>zc.info("Unable to validate name",S))},[n,o,d]);b.exports.useEffect(function(){const w=ye.makeCancelable(s(o));return w.then(()=>a(void 0)).catch(v=>{ye.isCanceled(v)||a(v)}),c(w),()=>w.cancel()},[s,o]),b.exports.useEffect(function(){u()},[u]);const g=b.exports.useCallback(()=>{zc.debug2("handleBlur"),p()},[p]),f=b.exports.useCallback(S=>{const{value:w}=S.target;r(w)},[]),C=b.exports.useCallback(S=>{S.stopPropagation();const{key:w}=S;switch(w){case"Enter":{p();break}case"Escape":{e();break}}},[e,p]);return T("div",{className:"file-list-item-editor",children:[h("input",{type:"text",className:Y("form-control file-list-item-editor-input",{"is-invalid":l}),value:o,ref:i,onBlur:g,onKeyDown:C,onChange:f,onClick:m,onDoubleClick:m,onMouseDown:m}),l&&h("div",{className:"invalid-feedback",children:`${l}`})]})}function Vm(t){const{isMultiSelect:e=!1,focusedPath:n,showContextMenu:s=!1,onCreateFile:i,onCreateFolder:o,onCopy:r,onDelete:l,onMove:a,onRename:d,onSelect:c,onSelectionChange:u,table:m,rowHeight:p=Id,validateRename:g=()=>Promise.resolve()}=t,[f,C]=b.exports.useState(),[S,w]=b.exports.useState([]),[v,y]=b.exports.useState(),E=b.exports.useCallback(O=>{w(O),u?.(O)},[u]),R=b.exports.useCallback(O=>{y(O)},[]),F=b.exports.useCallback(()=>{v&&r?.(v)},[v,r]),D=b.exports.useCallback(()=>{S.length>0&&l?.(S)},[l,S]),N=b.exports.useCallback(()=>{i?.()},[i]),P=b.exports.useCallback(()=>{v&&o?.(me.getPath(v.filename))},[v,o]),H=b.exports.useCallback(()=>{v&&C(v)},[v]),A=b.exports.useCallback(()=>{C(void 0)},[]),q=b.exports.useCallback(O=>{f&&(d?.(f,O),C(void 0))},[d,f]),B=b.exports.useMemo(()=>{if(f)return[];const O=[];return i&&O.push({title:"New File",description:"Create new file",action:N,group:le.groups.medium}),o&&O.push({title:"New Folder",description:"Create new folder",action:P,group:le.groups.medium}),r&&O.push({title:"Copy",description:"Copy",action:F,group:le.groups.low,disabled:v==null||An(v)}),l&&S.length>0&&O.push({title:"Delete",description:"Delete",shortcut:Wc.FILE_EXPLORER.DELETE,action:D,group:le.groups.low}),d&&O.push({title:"Rename",description:"Rename",shortcut:Wc.FILE_EXPLORER.RENAME,action:H,group:le.groups.low,disabled:v==null}),O},[F,D,N,P,H,v,r,i,o,l,d,S,f]),K=b.exports.useCallback(O=>(k(f),g(f,O)),[f,g]),x=b.exports.useCallback(O=>{const{item:G}=O;return f&&f.filename===G.filename?Ra({...O,children:h(HE,{item:G,validate:K,onSubmit:q,onCancel:A})}):Ra(O)},[A,q,f,K]);return T("div",{className:"file-list-container",children:[m!=null&&h(AE,{onMove:a,onSelect:c,onSelectionChange:E,onFocusChange:R,renderItem:x,rowHeight:p,table:m,isMultiSelect:e,focusedPath:n}),s&&h(le,{actions:B})]})}Vm.displayName="FileListContainer";class Rr extends Di{constructor(e){super("Name already exists"),this.isExistingFile=!0,this.info=e}}class Fd extends Error{constructor(){super("No file exists at the path specified"),this.isFileNotFound=!0}}const Ws=J.module("FileExplorer");function Dd(t){const{storage:e,isMultiSelect:n=!1,focusedPath:s,onDelete:i=()=>{},onRename:o=()=>{},onSelect:r,onSelectionChange:l,rowHeight:a=Id}=t,[d,c]=b.exports.useState([]),[u,m]=b.exports.useState();b.exports.useEffect(function(){let F;async function D(){Ws.debug("initTable"),F=ye.makeCancelable(e.getTable(),N=>N.close());try{m(await F)}catch(N){ye.isCanceled(N)||Ws.error("Unable to initialize table",N)}}return D(),()=>{F.cancel()}},[e]);const p=b.exports.useCallback(R=>{ye.isCanceled(R)||Ws.error(R)},[]),g=b.exports.useCallback(R=>{Ws.debug("handleDelete, pending confirmation",R),c(R)},[]),f=b.exports.useCallback(()=>{Ws.debug("handleDeleteConfirm",d),d.forEach(R=>e.deleteFile(An(R)?me.makePath(R.filename):R.filename)),i(d),c([])},[d,i,e]),C=b.exports.useCallback(()=>{Ws.debug("handleDeleteCancel"),c([])},[]),S=b.exports.useCallback((R,F)=>{me.reducePaths(R.map(N=>An(N)?me.makePath(N.filename):N.filename)).forEach(N=>{const P=me.isPath(N)?`${F}${me.getBaseName(N.substring(0,N.length-1))}/`:`${F}${me.getBaseName(N)}`;e.moveFile(N,P).then(()=>{o(N,P)}).catch(p)})},[p,o,e]),w=b.exports.useCallback((R,F)=>{let D=R.filename;const N=An(R);N&&!D.endsWith("/")&&(D=`${D}/`);let P=`${me.getParent(D)}${F}`;N&&!P.endsWith("/")&&(P=`${P}/`),Ws.debug2("handleRename",D,P),e.moveFile(D,P).catch(p),o(D,P)},[p,o,e]),v=b.exports.useCallback(async(R,F)=>{if(F===R.basename)return;me.validateName(F);const D=`${me.getPath(R.filename)}${F}`;try{const N=await e.info(D);throw new Rr(N)}catch(N){if(!(N instanceof Fd))throw N}},[e]),y=d.length>0,E=b.exports.useMemo(()=>d.length===1?`Are you sure you want to delete "${d[0].filename}"?`:"Are you sure you want to delete the selected files?",[d]);return T("div",{className:"file-explorer",children:[u&&h(Vm,{isMultiSelect:n,focusedPath:s,showContextMenu:!0,onMove:S,onDelete:g,onRename:w,onSelect:r,onSelectionChange:l,rowHeight:a,table:u,validateRename:v}),h(xr,{isOpen:y,headerText:E,bodyText:"You cannot undo this action.",onCancel:C,onConfirm:f,confirmButtonText:"Delete"})]})}Dd.displayName="FileExplorer";const zs=J.module("NewItemModal"),Ir=class extends b.exports.PureComponent{constructor(t){super(t),this.inputRef=de.createRef(),this.pending=new ds,this.pathMap=new Map,this.isInitialLoad=!0,this.handleModalSubmit=this.handleModalSubmit.bind(this),this.handleModalOpened=this.handleModalOpened.bind(this),this.handleSelect=this.handleSelect.bind(this),this.handleChange=this.handleChange.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleValidationError=this.handleValidationError.bind(this),this.handleOverwriteCancel=this.handleOverwriteCancel.bind(this),this.handleOverwriteConfirm=this.handleOverwriteConfirm.bind(this),this.handleExtensionChangeCancel=this.handleExtensionChangeCancel.bind(this),this.handleExtensionChangeConfirm=this.handleExtensionChangeConfirm.bind(this),this.handleBreadcrumbSelect=this.handleBreadcrumbSelect.bind(this);const{defaultValue:e}=t,n=me.hasPath(e)?me.getPath(e):"/";this.state={isSubmitting:!1,path:n,prevExtension:me.getExtension(e),showExtensionChangeModal:!1,showOverwriteModal:!1,value:me.getBaseName(e)}}static getValidationMessage(t){return t instanceof Rr&&t.info.type==="directory"?"Error: Cannot overwrite existing directory":`${t}`}static handleError(t){ye.isCanceled(t)||zs.error(t)}componentDidUpdate(t,e){const{isOpen:n}=this.props,{isOpen:s}=t,{value:i,path:o}=this.state;!s&&n&&(this.resetValue(),this.isInitialLoad=!0),s&&n&&(!this.isInitialLoad&&(o!==e.path||i!==e.value)&&this.updateValidationStatus(o,i),this.isInitialLoad=!1)}componentWillUnmount(){this.pending.cancel(),this.cancelableValidatePromise&&this.cancelableValidatePromise.cancel(),this.cancelableExistingItemPromise&&this.cancelableExistingItemPromise.cancel()}resetValue(){const{defaultValue:t}=this.props,e=me.hasPath(t)?me.getPath(t):"/";this.setState({path:e,value:me.getBaseName(t),validationError:void 0,prevExtension:me.getExtension(t),isSubmitting:!1})}getValidationPromise(t,e,n=!1){return this.cancelableValidatePromise&&this.cancelableValidatePromise.cancel(),this.cancelableValidatePromise=ye.makeCancelable(this.validateName(t,e,n)),this.cancelableValidatePromise}async validateName(t,e,n){me.validateName(e);const{defaultValue:s,storage:i}=this.props;if(n){const o=`${t}${e}`;if(o!==s)try{const r=await i.info(o);throw new Rr(r)}catch(r){if(!(r instanceof Fd))throw r}}return e}updateValidationStatus(t,e){this.getValidationPromise(t,e).then(()=>{this.setState({validationError:void 0})}).catch(this.handleValidationError).catch(Ir.handleError)}handleModalOpened(){this.focusRenameInput()}handleModalSubmit(){this.submitModal()}handleChange(t){const{value:e}=t.target;this.setState({value:e})}handleSelect(t){if(zs.debug("handleSelect",t),t.type==="directory")this.setState({path:me.makePath(t.filename)});else{const e=t.basename,n=me.getPath(t.filename);this.setState({value:e,path:n},()=>{this.focusRenameInput()})}}handleKeyDown(t){const{key:e}=t;switch(t.stopPropagation(),e){case"Enter":{t.preventDefault(),this.submitModal();break}case"Escape":{t.preventDefault();const{onCancel:n}=this.props;n();break}}}handleValidationError(t){if(!(t instanceof Di))throw t;zs.debug("Validation error",t),this.setState({validationError:t})}handleOverwriteCancel(){this.setState({showOverwriteModal:!1,isSubmitting:!1})}handleOverwriteConfirm(){this.setState({showOverwriteModal:!1});const{onSubmit:t}=this.props,{path:e,value:n}=this.state;zs.debug("handleOverwriteConfirm",e,n),t(`${e}${n}`,!0)}handleExtensionChangeCancel(){zs.debug("handleExtensionChangeCancel"),this.setState(({value:t,prevExtension:e})=>{const n=me.replaceExtension(t,e);return{showExtensionChangeModal:!1,value:n}}),this.submitModal(!0)}handleExtensionChangeConfirm(){zs.debug("handleExtensionChangeConfirm"),this.setState({showExtensionChangeModal:!1}),this.submitModal(!0)}focusRenameInput(){const t=this.inputRef.current;if(t){const{type:e}=this.props,{value:n}=t,s=e==="directory"?n.length:n.lastIndexOf(".");t.focus(),t.setSelectionRange(0,s>0?s:n.length)}}submitModal(t=!1){this.setState(({prevExtension:e,value:n,path:s})=>{const{notifyOnExtensionChange:i,type:o}=this.props;zs.debug("submitModal",e,n);const r=me.getExtension(n);return i&&!t&&e!==null&&e!==r?{isSubmitting:!1,showExtensionChangeModal:!0,newExtension:r}:(this.getValidationPromise(s,n,!0).then(l=>{const{onSubmit:a}=this.props;a(`${s}${n}`)}).catch(l=>{if(l instanceof Rr&&o!=="directory"&&l.info.type!=="directory"){this.setState({showOverwriteModal:!0});return}throw l}).catch(l=>{throw ye.isCanceled(l)&&this.setState({isSubmitting:!1}),l}).catch(this.handleValidationError).catch(Ir.handleError),{isSubmitting:!0,showExtensionChangeModal:!1,newExtension:void 0})})}handleBreadcrumbSelect(t){this.setState({path:t})}renderPathButtons(t){const e=t.split("/");return e.pop(),e.map((n,s)=>{let i="";for(let o=0;o<s;o+=1)i+=`${e[o]}/`;return i+=`${n}/`,T(de.Fragment,{children:[h(U,{kind:"ghost",className:"directory-breadcrumbs",onClick:()=>this.handleBreadcrumbSelect(i),"aria-label":s===0?"Home":void 0,icon:s===0?h(Z,{icon:Qg,transform:"right-1.6"}):void 0,tooltip:s===0?"Home":void 0,children:n}),"/"]},i)})}render(){const{storage:t,isOpen:e,onCancel:n,placeholder:s,title:i,type:o}=this.props,{isSubmitting:r,path:l,showExtensionChangeModal:a,showOverwriteModal:d,validationError:c,value:u,prevExtension:m,newExtension:p}=this.state,g=o==="directory",f=me.fileExtensionToString(m),C=me.fileExtensionToString(p),S=g?"Create":"Save",w=g?"New folder name":"Save file as";return T(be,{children:[T(nl,{isOpen:e,toggle:n,onOpened:this.handleModalOpened,className:"modal-dialog-centered new-file-modal theme-bg-dark",children:[h(sl,{toggle:n,children:i}),h(il,{children:h("form",{children:T("div",{className:"d-flex flex-column new-file-modal-content",children:[T("div",{className:"flex-grow-0 mb-4",children:[h("label",{htmlFor:"file-name-input",children:w}),h("input",{id:"file-name-input",type:"text",autoComplete:"off",autoCapitalize:"none",autoCorrect:"off",spellCheck:"false",className:Y("form-control",{"is-invalid":c}),value:u,placeholder:s,ref:this.inputRef,onKeyDown:this.handleKeyDown,onChange:this.handleChange}),c&&h("div",{className:"invalid-feedback",children:Ir.getValidationMessage(c)})]}),T("div",{className:"flex-grow-0",children:[h("label",{children:"Directory: /"}),this.renderPathButtons(l)]}),h("div",{className:"flex-grow-1 file-explorer-container",children:h(Dd,{onSelect:this.handleSelect,storage:t,focusedPath:l})})]})})}),T(_h,{children:[h(U,{kind:"secondary",onClick:n,children:"Cancel"}),h(U,{kind:"primary",disabled:r,onClick:this.handleModalSubmit,children:S})]})]}),h(xr,{isOpen:d,headerText:"Confirm overwrite",bodyText:"File with this name already exists, are you sure you want to overwrite it?",onCancel:this.handleOverwriteCancel,onConfirm:this.handleOverwriteConfirm,cancelButtonText:"Cancel",confirmButtonText:"Overwrite"}),h(xr,{isOpen:a,headerText:"Confirm extension change",bodyText:`Are you sure you want to change extension from "${f}" to "${C}"?`,onCancel:this.handleExtensionChangeCancel,onConfirm:this.handleExtensionChangeConfirm,cancelButtonText:`Keep "${f}"`,confirmButtonText:`Use "${C}"`})]})}};let Nl=Ir;Nl.propTypes={isOpen:M.exports.bool,title:M.exports.string.isRequired,defaultValue:M.exports.string,type:M.exports.oneOf(["file","directory"]).isRequired,onSubmit:M.exports.func,onCancel:M.exports.func,placeholder:M.exports.string,storage:M.exports.shape({}).isRequired,notifyOnExtensionChange:M.exports.bool};Nl.defaultProps={isOpen:!1,defaultValue:"/",notifyOnExtensionChange:!1,placeholder:"",onSubmit:(t,e)=>{},onCancel:()=>{}};function UE({createFile:t,createFolder:e,onSearchChange:n,defaultSearchText:s=""}){return T("div",{className:"file-explorer-toolbar",children:[T("div",{className:"file-explorer-toolbar-buttons",children:[h(U,{kind:"ghost",icon:vh,tooltip:"New notebook",onClick:t,"aria-label":"New notebook"}),h(U,{kind:"ghost",icon:Zg,tooltip:"New folder",onClick:e,"aria-label":"New folder"})]}),n&&h("div",{className:"file-explorer-toolbar-search",children:h(Jg,{value:s,onChange:n,placeholder:"Search by name"})})]})}const wi=J.module("FileExplorerPanel"),VE=(t,e)=>{const n=au(t),s=ai(t,e.localDashboardId),{session:i,config:o}=s??{},r=o?.type;return{fileStorage:n,language:r,session:i}},BE=vt(VE,null,null,{forwardRef:!0});function $E(t){const e=t;return e!=null&&typeof e.button=="number"}const Ia=class extends de.Component{static handleError(t){wi.error(t)}static isFocusEvent(t){return $E(t)?t.detail>=2:!0}constructor(t){super(t),this.handleFileSelect=this.handleFileSelect.bind(this),this.handleCreateFile=this.handleCreateFile.bind(this),this.handleCreateDirectory=this.handleCreateDirectory.bind(this),this.handleCreateDirectoryCancel=this.handleCreateDirectoryCancel.bind(this),this.handleCreateDirectorySubmit=this.handleCreateDirectorySubmit.bind(this),this.handleDelete=this.handleDelete.bind(this),this.handleRename=this.handleRename.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleShow=this.handleShow.bind(this),this.handleSelectionChange=this.handleSelectionChange.bind(this);const{session:e,language:n}=t;this.state={isShown:!1,language:n,session:e,showCreateFolder:!1,focusedFilePath:"/"}}componentDidMount(){this.isHidden()||this.setState({isShown:!0})}handleCreateFile(){const{glEventHub:t}=this.props,{session:e,language:n}=this.state,s={language:n,value:""};wi.debug("handleCreateFile",e,n,s),t.emit(Ae.CREATE_NOTEBOOK,e,n,s)}handleCreateDirectory(t){this.setState({showCreateFolder:!0})}handleCreateDirectoryCancel(){wi.debug("handleCreateDirectoryCancel"),this.setState({showCreateFolder:!1})}handleCreateDirectorySubmit(t){wi.debug("handleCreateDirectorySubmit",t),this.setState({showCreateFolder:!1});const{fileStorage:e}=this.props;e.createDirectory(t).catch(Ia.handleError)}handleDelete(t){const{glEventHub:e}=this.props;t.forEach(n=>{e.emit(Ae.CLOSE_FILE,{id:n.filename,itemName:n.filename})})}handleSelectionChange(t){let e="/";t.length===1&&(t[0].type==="directory"?e=me.makePath(t[0].filename):e=me.getPath(t[0].filename)),this.setState({focusedFilePath:e})}handleFileSelect(t,e){if(wi.debug("fileSelect",t),t.type==="directory")return;const n=Ia.isFocusEvent(e),s={id:t.filename,itemName:t.filename},{glEventHub:i}=this.props,{session:o,language:r}=this.state,l={value:null,language:r};i.emit(Ae.SELECT_NOTEBOOK,o,r,l,s,n)}handleRename(t,e){const{glEventHub:n}=this.props;wi.debug("handleRename",t,e),n.emit(Ae.RENAME_FILE,t,e)}handleSessionOpened(t,{language:e}){this.setState({session:t,language:e})}handleSessionClosed(){this.setState({session:void 0,language:void 0})}handleShow(){this.setState({isShown:!0})}isHidden(){const{glContainer:t}=this.props,{isHidden:e}=t;return e}render(){const{fileStorage:t,glContainer:e,glEventHub:n}=this.props,{isShown:s,showCreateFolder:i,focusedFilePath:o}=this.state;return T($n,{className:"file-explorer-panel",componentPanel:this,glContainer:e,glEventHub:n,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onShow:this.handleShow,children:[h(UE,{createFile:this.handleCreateFile,createFolder:this.handleCreateDirectory}),s&&h(Dd,{isMultiSelect:!0,storage:t,onDelete:this.handleDelete,onRename:this.handleRename,onSelect:this.handleFileSelect,onSelectionChange:this.handleSelectionChange}),h(Nl,{isOpen:i,type:"directory",title:"Create New Folder",storage:t,onSubmit:this.handleCreateDirectorySubmit,onCancel:this.handleCreateDirectoryCancel,defaultValue:o})]})}};let Nd=Ia;Nd.COMPONENT="FileExplorerPanel";Nd.TITLE="File Explorer";const qr=BE(Nd);const dt=J.module("FilterSetManager"),GE="Enter name...",qc="No Available Filter Sets";class Yr extends b.exports.Component{constructor(e){super(e),this.renameInputRef=de.createRef(),this.dropdownRef=de.createRef(),this.editDropdownRef=de.createRef(),this.isRenamingExistingSet=ge((n,s)=>s!==void 0&&n.some(({id:i})=>i===s.id)),this.handleSettingsCancel=this.handleSettingsCancel.bind(this),this.handleSettingsClick=this.handleSettingsClick.bind(this),this.handleSettingsSave=this.handleSettingsSave.bind(this),this.handleBackgroundClick=this.handleBackgroundClick.bind(this),this.handleEditDropdownChange=this.handleEditDropdownChange.bind(this),this.handleFilterChange=this.handleFilterChange.bind(this),this.handleFilterApply=this.handleFilterApply.bind(this),this.handleCaptureNewSet=this.handleCaptureNewSet.bind(this),this.handleNameInputChange=this.handleNameInputChange.bind(this),this.handleNameInputKeyPress=this.handleNameInputKeyPress.bind(this),this.handleRenameConfirm=this.handleRenameConfirm.bind(this),this.handleRenameCancel=this.handleRenameCancel.bind(this),this.handleRestoreFullStateChange=this.handleRestoreFullStateChange.bind(this),this.handleSetDelete=this.handleSetDelete.bind(this),this.handleSetEdit=this.handleSetEdit.bind(this),this.handleSetUpdate=this.handleSetUpdate.bind(this),this.state={editId:void 0,renameSet:void 0,nameInputValue:"",nameInputError:void 0,modifiedFilterSets:[],restoreFullState:!1}}static animateScreenFlash(){const e=document.createElement("div");e.classList.add("screen-flash-overlay"),e.addEventListener("animationend",()=>{e.remove()}),document.querySelector("body")?.appendChild(e)}componentDidMount(){const{isValueShown:e}=this.props;e?this.updateSelectedId():this.initSettingsScreen()}componentDidUpdate(e,n){const{isValueShown:s,filterSets:i}=this.props,{modifiedFilterSets:o}=this.state;if(e.isValueShown&&!s&&this.initSettingsScreen(),this.isNameInputScreen()&&!this.isNameInputScreen(n)&&this.focusRenameInput(),i!==e.filterSets)if(!s&&i.length>0&&e.filterSets.length===0&&o.length===0){const{onChange:r}=this.props;r({isValueShown:!0,selectedId:i[0].id})}else this.updateSelectedId()}initSettingsScreen(){const{filterSets:e,selectedId:n}=this.props;dt.debug("initSettingsScreen",e,n),this.setState({modifiedFilterSets:[...e],editId:n})}updateSelectedId(){const{isValueShown:e,filterSets:n,selectedId:s,onChange:i}=this.props;if(dt.debug("updateSelectedId",n,s),!!e&&!n.some(({id:o})=>o===s)){const o=n.length===0;i({isValueShown:!o,selectedId:o?void 0:n[0].id})}}handleEditDropdownChange(e){const{value:n}=e.target;this.setState({editId:n})}handleFilterChange(e){const{value:n}=e.target,{isValueShown:s,onChange:i}=this.props;this.applyFilterSet(n),i({isValueShown:s,selectedId:n})}handleFilterApply(){const{selectedId:e}=this.props;this.applyFilterSet(e)}handleSettingsCancel(){const{onChange:e,selectedId:n,filterSets:s}=this.props;this.setState({modifiedFilterSets:[]}),s.length>0&&e({isValueShown:!0,selectedId:n})}handleSettingsSave(){const{onChange:e,onUpdateSets:n}=this.props,{modifiedFilterSets:s,editId:i}=this.state;this.setState({modifiedFilterSets:[]}),dt.debug("Update sets",s,i),n(s),s.length>0&&e({isValueShown:!0,selectedId:i})}handleCaptureNewSet(){const{getFilterState:e}=this.props;Yr.animateScreenFlash();const n=$e(),s=e(),i={id:n,title:"",panels:s};dt.debug("handleSetCreate",i),this.setState({nameInputValue:"",nameInputError:void 0,renameSet:i})}handleRenameCancel(){this.setState({renameSet:void 0})}handleRestoreFullStateChange(e){this.setState({restoreFullState:e.target.value==="true"})}getNameError(e){const{renameSet:n,modifiedFilterSets:s}=this.state,i=e?.trim()??"";if(i.length===0)return dt.debug("Name cannot be empty",i),"Name cannot be empty";if(n!==void 0&&s.some(({title:o,id:r})=>o===i&&r!==n.id))return dt.debug("Set with this name already exists",i),"Set with this name already exists"}handleRenameConfirm(){const{nameInputValue:e,renameSet:n,modifiedFilterSets:s,restoreFullState:i}=this.state;if(n===void 0){dt.error("Renamed set undefined.");return}const o=this.getNameError(e);if(dt.debug("handleRenameConfirm",e,o),o!==void 0){this.setState({nameInputError:o});return}const r=e?.trim()??"",l={...n,title:r,restoreFullState:i},a=s.findIndex(({id:c})=>c===n.id),d=[...s];a>=0?(d[a]=l,dt.debug("Renamed existing set",d)):(d.push(l),dt.debug("Added new set to modified sets",d)),this.setState({editId:l.id,modifiedFilterSets:d,renameSet:void 0})}handleSetDelete(){this.setState(e=>{const{editId:n,modifiedFilterSets:s}=e,i=s.findIndex(({id:a})=>a===n);if(i<0)return dt.error("Unable to find selected filterSet index",s,n),null;const o=s.filter(({id:a})=>a!==n),r=Math.max(0,Math.min(o.length-1,i-1)),l=o.length>0?o[r].id:void 0;return dt.debug("Deleted selected set",n,s,o),dt.debug("New selection",r,l),{modifiedFilterSets:o,editId:l}})}handleSetUpdate(){const{getFilterState:e}=this.props;Yr.animateScreenFlash();const n=e();this.setState(({modifiedFilterSets:s,editId:i})=>{if(i===void 0)return dt.error("Filter for update not selected."),null;const o=[...s],r=o.findIndex(({id:l})=>l===i);return r<0?(dt.error("Selected set for update not found."),null):(o[r]={...o[r],panels:n},dt.debug("Update set",o,n),{modifiedFilterSets:o})})}handleSetEdit(){this.setState(({editId:e,modifiedFilterSets:n})=>{const s=n.find(({id:r})=>r===e);if(s===void 0)return dt.error("Could not find selected set",e,n),null;const{title:i,restoreFullState:o=!1}=s;return{nameInputValue:i,nameInputError:void 0,renameSet:s,restoreFullState:o}})}handleSettingsClick(e){e.stopPropagation();const{onChange:n,selectedId:s}=this.props;n({isValueShown:!1,selectedId:s})}handleBackgroundClick(e){dt.debug("handleBackgroundClick"),e.target!==this.dropdownRef.current&&this.focusInput()}handleNameInputChange(e){const{value:n}=e.target,s=this.getNameError(n);this.setState({nameInputValue:n,nameInputError:s})}handleNameInputKeyPress(e){const{key:n}=e;n==="Enter"&&(e.preventDefault(),this.handleRenameConfirm())}isNameInputScreen(e=this.state){const{renameSet:n}=e;return n!==void 0}applyFilterSet(e){const{onApply:n,filterSets:s}=this.props;if(e===void 0){dt.debug("No filter selected");return}const i=s.find(({id:o})=>o===e);if(i===void 0){dt.debug("Selected id not found in filterSets",e,s);return}dt.debug("Apply filterSet",i),n(i)}focusInput(){this.dropdownRef.current?.focus()}focusRenameInput(){this.renameInputRef.current?.focus()}render(){const{nameInputValue:e,nameInputError:n,editId:s,renameSet:i,modifiedFilterSets:o,restoreFullState:r}=this.state,{isValueShown:l,filterSets:a,selectedId:d}=this.props,c=this.isNameInputScreen(),u=this.isRenamingExistingSet(o,i),m=o.length===0,p=!c&&m&&a.length===0,g=!c&&!p,f=T("div",{className:"fa-layers mr-3",children:[h(Z,{icon:Mi,mask:ca,transform:"shrink-1 down-5 right-7"}),h(Z,{icon:As,className:"text-primary",transform:"shrink-6 down-5 right-7"})]}),C=T("div",{className:"fa-layers",children:[h(Z,{icon:Mi,mask:ca,transform:"shrink-1 down-5 right-7"}),h(Z,{icon:ha,transform:"shrink-1 down-5 right-7"})]});return h("div",{className:"filter-set-manager fill-parent-absolute",children:T(Ga,{className:"w-100 h-100",isFlipped:l,children:[h("div",{className:"filter-set-manager-settings-card fill-parent-absolute",children:T("div",{className:"filter-set-manager-card-content",children:[p&&T("div",{children:[h(U,{kind:"ghost",className:"btn btn-link no-underline",onClick:this.handleCaptureNewSet,icon:f,children:"Capture filter set"}),h("div",{className:"py-3 text-muted small",children:"Takes a snapshot of the currently applied filters on all panels, allowing you to restore saved filter sets later."})]}),c&&T("div",{className:"d-flex flex-column justify-content-center","data-testid":"edit-filter-set-container",children:[T("div",{className:"form-group",children:[h("label",{children:u?"Edit set":"Name captured set"}),T("div",{className:"name-input-container",children:[h("input",{type:"text",className:"input-set-name form-control",placeholder:GE,value:e,ref:this.renameInputRef,onChange:this.handleNameInputChange,onKeyPress:this.handleNameInputKeyPress,spellCheck:"false"}),h(U,{"data-testid":"rename-confirm-button",kind:"ghost",className:"btn btn-link no-underline pt-2 pb-2",onClick:this.handleRenameConfirm,tooltip:"Save","test-id":"button-save",icon:Mh}),h(U,{"data-testid":"rename-cancel-button",kind:"ghost",className:"btn btn-link no-underline pt-2 pb-2",onClick:this.handleRenameCancel,tooltip:"Cancel",icon:ef})]}),n!==void 0&&h("div",{className:"error-message",children:n})]}),h("div",{className:"form-group",children:T(al,{onChange:this.handleRestoreFullStateChange,value:`${r}`,children:[h(is,{value:"false",children:"Restore only filters"}),h(is,{value:"true",children:"Restore full table state"})]})})]}),g&&T("div",{className:"filter-set-manager-settings-grid-1",children:[T("div",{className:"form-group",children:[h("label",{children:"Edit filter sets"}),T("div",{className:"filter-select-container",children:[T("select",{"data-testid":"settings-card-filter-select",ref:this.editDropdownRef,value:s??"-1",className:"custom-select filter-value-select",onChange:this.handleEditDropdownChange,disabled:m,children:[m&&h("option",{value:"-1",disabled:!0,children:qc}),o.map(({id:S,title:w})=>h("option",{value:S,children:w},S))]}),h(U,{kind:"ghost",onClick:this.handleSetUpdate,disabled:m,icon:C,tooltip:"Update"}),h(U,{kind:"ghost",onClick:this.handleSetEdit,disabled:m,icon:Mo,tooltip:"Edit"}),h(U,{kind:"ghost",onClick:this.handleSetDelete,disabled:m,icon:sn,tooltip:"Delete"})]})]}),h("div",{children:h(U,{kind:"ghost",className:"btn btn-link no-underline",onClick:this.handleCaptureNewSet,icon:f,children:"Capture new filter set"})}),T("div",{className:"py-3 text-right",children:[h(U,{kind:"secondary",onClick:this.handleSettingsCancel,children:"Cancel"}),"\xA0",h(U,{kind:"primary",onClick:this.handleSettingsSave,children:"Save"})]})]})]})},"front"),T("div",{className:"filter-set-manager-value-card fill-parent-absolute",onClick:this.handleBackgroundClick,children:[h("div",{className:"filter-set-manager-column",children:h("div",{className:"filter-set-manager-column-title",children:"Filter sets"})}),h("div",{className:"filter-set-manager-card-content",children:h("div",{className:"filter-set-manager-value-input",children:T("div",{className:"filter-select-container",children:[T("select",{"data-testid":"value-card-filter-select",ref:this.dropdownRef,value:d,className:"custom-select filter-value-select",onChange:this.handleFilterChange,children:[a.length===0&&h("option",{value:"-1",disabled:!0,children:qc}),a.map(({id:S,title:w})=>h("option",{value:S,children:w},S))]}),h(U,{"data-testid":"filter-apply-button",kind:"ghost",onClick:this.handleFilterApply,icon:Ua,tooltip:"Apply Filter Set"})]})})}),h("div",{className:"filter-set-manager-menu",children:h(U,{kind:"ghost",className:"btn btn-link btn-link-icon m-2 px-2",onClick:this.handleSettingsClick,tooltip:"Settings",icon:h(Z,{icon:_o,transform:"grow-4"})})})]},"back")]})})}}function _d(t){const{model:e,widgetName:n,glContainer:s,description:i}=t,o=(e?.rowCount??0)-(e?.pendingRowCount??0),r=e?.displayString(o,"long");return h(Rl,{widgetType:"Table",widgetName:n,glContainer:s,description:i,children:T("div",{className:"column-statistics-grid",children:[h("span",{className:"column-statistic-operation",children:"Number of Rows"}),h("span",{className:"column-statistic-value",children:r})]})})}_d.propTypes={glContainer:id.Container.isRequired,widgetName:M.exports.string.isRequired,description:M.exports.string};_d.defaultProps={description:null};const Dn=J.module("IrisGridPanel"),WE=500,zE={IrisGrid:Yi,IrisGridTableModel:Nm,ContextMenuRoot:kh};class Hi extends b.exports.PureComponent{constructor(e){super(e),this.getGridInputFilters=ge((s,i)=>te.getInputFiltersForColumns(s,i.filter(({value:o,excludePanelIds:r})=>{const l=ie.getIdFromPanel(this);return o!=null&&(r==null||l!=null&&!r.includes(l))}))),this.getAlwaysFetchColumns=ge((s,i)=>{const o=ie.getIdFromPanel(this),r=new Set(i);for(let l=0;l<s.length;l+=1){const{start:a}=s[l];a!=null&&a.panelId===o&&r.add(a.columnName)}return[...r]}),this.getPluginContent=ge((s,i,o,r,l)=>!i||!si(i)||s==null||i.table==null?null:h("div",{className:"iris-grid-plugin",children:h(s,{ref:this.pluginRef,filter:this.handlePluginFilter,onFilter:this.handlePluginFilter,fetchColumns:this.handlePluginFetchColumns,onFetchColumns:this.handlePluginFetchColumns,table:i.table,user:o,panel:this,workspace:r,components:zE,onStateChange:this.handlePluginStateChange,pluginState:l})})),this.getDehydratedIrisGridPanelState=ge((s,i,o,r,l)=>te.dehydrateIrisGridPanelState(s,{isSelectingPartition:i,partition:o,partitionColumn:r,advancedSettings:l})),this.getDehydratedIrisGridState=ge((s,i,o,r,l,a,d,c,u,m,p,g,f,C,S,w,v,y,E,R,F)=>te.dehydrateIrisGridState(s,{advancedFilters:o,aggregationSettings:v,customColumnFormatMap:r,isFilterBarShown:l,metrics:{userColumnWidths:S,userRowHeights:w},quickFilters:a,customColumns:d,reverseType:c,rollupConfig:u,showSearchBar:m,searchValue:p,selectDistinctColumns:g,selectedSearchColumns:f,sorts:i,invertSearchColumns:C,pendingDataMap:y,frozenColumns:E,conditionalFormats:R,columnHeaderGroups:F})),this.getDehydratedGridState=ge((s,i,o,r,l)=>te.dehydrateGridState(s,{isStuckToBottom:r,isStuckToRight:l,movedColumns:i,movedRows:o})),this.getCachedPanelState=ge((s,i,o,r)=>({irisGridPanelState:s,irisGridState:i,gridState:o,pluginState:r})),this.savePanelState=Je(()=>{const{irisGridState:s,gridState:i,pluginState:o}=this;k(s);const{onPanelStateUpdate:r}=this.props,{model:l,panelState:a,isSelectingPartition:d,partition:c,partitionColumn:u,advancedSettings:m}=this.state,{advancedFilters:p,aggregationSettings:g,customColumnFormatMap:f,isFilterBarShown:C,quickFilters:S,customColumns:w,reverseType:v,rollupConfig:y,showSearchBar:E,searchValue:R,selectDistinctColumns:F,selectedSearchColumns:D,sorts:N,invertSearchColumns:P,metrics:H,pendingDataMap:A,frozenColumns:q,conditionalFormats:B,columnHeaderGroups:K}=s;k(l),k(H);const{userColumnWidths:x,userRowHeights:O}=H;k(i);const{isStuckToBottom:G,isStuckToRight:ee,movedColumns:ne,movedRows:V}=i,W=this.getCachedPanelState(this.getDehydratedIrisGridPanelState(l,d,c,u,m),this.getDehydratedIrisGridState(l,N,p,f,C,S,w,v,y,E,R,F,D,P,x,O,g,A,q,B,K),this.getDehydratedGridState(l,ne,V,G,ee),o);W!==a&&(Dn.debug("Saving panel state",this,W),this.setState({panelState:W}),r?.(W))},WE),this.handleAdvancedSettingsChange=this.handleAdvancedSettingsChange.bind(this),this.handleColumnsChanged=this.handleColumnsChanged.bind(this),this.handleTableChanged=this.handleTableChanged.bind(this),this.handleColumnSelected=this.handleColumnSelected.bind(this),this.handleDataSelected=this.handleDataSelected.bind(this),this.handleError=this.handleError.bind(this),this.handleGridStateChange=this.handleGridStateChange.bind(this),this.handlePluginStateChange=this.handlePluginStateChange.bind(this),this.handlePartitionAppend=this.handlePartitionAppend.bind(this),this.handleCreateChart=this.handleCreateChart.bind(this),this.handleResize=this.handleResize.bind(this),this.handleShow=this.handleShow.bind(this),this.handleTabClicked=this.handleTabClicked.bind(this),this.handleDisconnect=this.handleDisconnect.bind(this),this.handleReconnect=this.handleReconnect.bind(this),this.handleLoadSuccess=this.handleLoadSuccess.bind(this),this.handleLoadError=this.handleLoadError.bind(this),this.isColumnSelectionValid=this.isColumnSelectionValid.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.handlePluginFilter=this.handlePluginFilter.bind(this),this.handlePluginFetchColumns=this.handlePluginFetchColumns.bind(this),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.irisGrid=de.createRef(),this.pluginRef=de.createRef();const{panelState:n}=e;this.pluginState=null,this.state={error:null,isDisconnected:!1,isLoaded:!1,isLoading:!0,isModelReady:!1,model:void 0,advancedFilters:new Map,aggregationSettings:{aggregations:[],showOnTop:!1},advancedSettings:new Map(im.DEFAULTS),customColumns:[],customColumnFormatMap:new Map,isFilterBarShown:!1,quickFilters:new Map,sorts:[],userColumnWidths:new Map,userRowHeights:new Map,reverseType:_.REVERSE_TYPE.NONE,movedColumns:[],movedRows:[],isSelectingPartition:!1,partition:void 0,partitionColumn:void 0,rollupConfig:void 0,showSearchBar:!1,searchValue:"",selectedSearchColumns:void 0,invertSearchColumns:!0,Plugin:void 0,pluginFilters:[],pluginFetchColumns:[],modelQueue:[],pendingDataMap:new Map,frozenColumns:void 0,panelState:n,irisGridStateOverrides:{},gridStateOverrides:{},isStuckToBottom:!1,isStuckToRight:!1,conditionalFormats:[],selectDistinctColumns:[]}}componentDidMount(){this.initModel()}componentDidUpdate(e,n){const{model:s}=this.state;s!==n.model&&(n.model!=null&&(this.stopModelListening(n.model),n.model.close()),s!=null&&this.startModelListening(s))}componentWillUnmount(){this.savePanelState.cancel(),this.modelPromise!=null&&(this.modelPromise.cancel(),this.modelPromise=void 0);const{model:e}=this.state;e&&(this.stopModelListening(e),e.close())}getTableName(){const{metadata:e}=this.props;return e.table}initModel(){this.setState({isModelReady:!1,isLoading:!0,error:null});const{makeModel:e}=this.props;this.modelPromise!=null&&this.modelPromise.cancel(),this.modelPromise=ye.makeCancelable(e(),n=>n.close()),this.modelPromise.then(this.handleLoadSuccess).catch(this.handleLoadError)}handleLoadSuccess(e){const n=e,{panelState:s,irisGridStateOverrides:i}=this.state,o=[];if(s!=null){const{irisGridState:r}=s,{aggregationSettings:l,customColumns:a,selectDistinctColumns:d=[],rollupConfig:c}={...r,...i};a.length>0&&o.push(u=>{u.customColumns=a}),c!=null&&c.columns.length>0&&o.push(u=>{u.rollupConfig=te.getModelRollupConfig(u.originalColumns,c,l)}),d.length>0&&o.push(u=>{u.selectDistinctColumns=d})}this.setState({model:n,modelQueue:o}),this.initModelQueue(n,o)}initModelQueue(e,n){const s=e;if(n.length===0){this.modelInitialized(s);return}const i=n.shift();Dn.debug("initModelQueue",i),i&&i(s),this.setState({modelQueue:n})}handleAdvancedSettingsChange(e,n){Dn.debug("handleAdvancedSettingsChange",e,n),this.setState(({advancedSettings:s})=>s.get(e)===n?null:{advancedSettings:new Map(s).set(e,n)})}handlePluginFilter(e){const{model:n}=this.state;k(n);const{columns:s,formatter:i}=n,o=te.getFiltersFromInputFilters(s,e,i.timeZone);this.setState({pluginFilters:o})}handlePluginFetchColumns(e){this.setState({pluginFetchColumns:e})}handleContextMenu(e){return this.pluginRef.current?.getMenu?.(e)??[]}isColumnSelectionValid(e){const{columnSelectionValidator:n}=this.props;return n&&e?n(this,e):!1}handleGridStateChange(e,n){this.irisGridState=e,this.gridState=n,this.setState({isLoaded:!0,isLoading:!1}),this.savePanelState();const{glEventHub:s,onStateChange:i}=this.props;s.emit(wt.STATE_CHANGED,this),i?.(e,n)}handlePluginStateChange(e){const{irisGridState:n,gridState:s}=this;this.pluginState=e,n!==null&&s!==null&&this.savePanelState()}handleColumnsChanged(e){const{isModelReady:n,model:s,modelQueue:i}=this.state;n?this.sendColumnsChange(e.detail):(k(s),this.initModelQueue(s,i))}handleTableChanged(e){Dn.debug("handleTableChanged",e);const{glEventHub:n}=this.props,{detail:s}=e;n.emit(Le.TABLE_CHANGED,this,s)}handlePartitionAppend(e,n){const{glEventHub:s}=this.props,{name:i}=e,o=this.getTableName(),r=`${o} = ${o}.where("${i}=\`${n}\`")`;s.emit(gt.SEND_COMMAND,r,!1,!0)}handleCreateChart(e,n){this.savePanelState.flush(),this.setState(()=>null,()=>{const{glEventHub:s,inputFilters:i,metadata:o}=this.props,{table:r}=o,{panelState:l}=this.state,a=ie.getIdFromPanel(this);let d;l&&(d=te.extractTableSettings(l,i)),s.emit(wt.CREATE_CHART,{metadata:{settings:e,sourcePanelId:a,table:r,tableSettings:d},table:si(n)?n.table:void 0})})}handleColumnSelected(e){const{glEventHub:n}=this.props;n.emit(wt.COLUMN_SELECTED,this,e)}handleDataSelected(e,n){const{glEventHub:s}=this.props;s.emit(wt.DATA_SELECTED,this,n)}handleResize(){this.updateGrid()}handleShow(){this.updateGrid()}handleTabClicked(){this.irisGrid.current&&this.irisGrid.current.focus()}handleError(e){Dn.error(e),this.setState({error:e,isLoading:!1})}handleDisconnect(){this.setState({error:new Error("Table disconnected"),isDisconnected:!0,isLoading:!1})}handleReconnect(){this.setState({isDisconnected:!1,error:null})}handleLoadError(e){ye.isCanceled(e)||this.handleError(e)}modelInitialized(e){const{glEventHub:n,loadPlugin:s}=this.props;if(this.modelPromise=void 0,this.loadPanelState(e),this.setState({isModelReady:!0}),si(e)){const{table:i}=e,{pluginName:o}=i;if(o!==""&&s!=null&&o!=null){const r=s(o);this.setState({Plugin:r})}n.emit(Le.TABLE_CHANGED,this,i)}this.sendColumnsChange(e.columns)}handleClearAllFilters(){const e=this.irisGrid.current,{isDisconnected:n}=this.state;e!=null&&!n&&e.clearAllFilters()}sendColumnsChange(e){Dn.debug2("sendColumnsChange",e);const{glEventHub:n}=this.props;n.emit(Le.COLUMNS_CHANGED,this,e)}startModelListening(e){e.addEventListener(Ce.EVENT.DISCONNECT,this.handleDisconnect),e.addEventListener(Ce.EVENT.RECONNECT,this.handleReconnect),e.addEventListener(Ce.EVENT.COLUMNS_CHANGED,this.handleColumnsChanged),e.addEventListener(Ce.EVENT.TABLE_CHANGED,this.handleTableChanged)}stopModelListening(e){e.removeEventListener(Ce.EVENT.DISCONNECT,this.handleDisconnect),e.removeEventListener(Ce.EVENT.RECONNECT,this.handleReconnect),e.removeEventListener(Ce.EVENT.COLUMNS_CHANGED,this.handleColumnsChanged),e.removeEventListener(Ce.EVENT.TABLE_CHANGED,this.handleTableChanged)}getCoordinateForColumn(e){const{model:n}=this.state;if(!n)return null;const s=this.irisGrid.current,{gridWrapper:i}=s||{},o=i?.getBoundingClientRect()??null;if(o==null||o.width<=0||o.height<=0)return null;k(s);const{metrics:r}=s.state;k(r);const{columnHeaderHeight:l,allColumnXs:a,allColumnWidths:d,right:c,columnHeaderMaxDepth:u}=r,m=n.getColumnIndexByName(e);k(m);const p=s.getVisibleColumn(m),g=a.get(p)??0,f=d.get(p)??0,C=Math.max(o.left,Math.min(p>c?o.right:o.left+g+f*.5,o.right)),S=o.top+l*u;return[C,S]}setFilterMap(e){const n=this.irisGrid.current;n?.setFilterMap(e)}setAdvancedFilterMap(e){const n=this.irisGrid.current;n?.setAdvancedFilterMap(e)}setFilters({quickFilters:e,advancedFilters:n}){Dn.debug("setFilters",e,n);const{model:s,isDisconnected:i}=this.state,o=this.irisGrid.current;if(o==null||i){Dn.debug("Ignore setFilters, model disconnected");return}k(s);const{columns:r,formatter:l}=s,a=te.changeFilterColumnNamesToIndexes(s.columns,e).filter(([c])=>s.isFilterable(c)),d=te.changeFilterColumnNamesToIndexes(s.columns,n).filter(([c])=>s.isFilterable(c));o.clearAllFilters(),o.setFilters({quickFilters:te.hydrateQuickFilters(r,a,l.timeZone),advancedFilters:te.hydrateAdvancedFilters(r,d,l.timeZone)})}setStateOverrides(e){Dn.debug("setStateOverrides",e);const{irisGridState:n,gridState:s}=e;this.setState({irisGridStateOverrides:n,gridStateOverrides:s},()=>{this.initModel()})}unsetFilterValue(){}loadPanelState(e){const{panelState:n,irisGridStateOverrides:s,gridStateOverrides:i}=this.state;if(n!=null)try{const{gridState:o,irisGridState:r,irisGridPanelState:l}=n,a={...s},{quickFilters:d,advancedFilters:c}=a;d&&(a.quickFilters=te.changeFilterColumnNamesToIndexes(e.columns,d)),c&&(a.advancedFilters=te.changeFilterColumnNamesToIndexes(e.columns,c));const{isSelectingPartition:u,partition:m,partitionColumn:p,advancedSettings:g}=te.hydrateIrisGridPanelState(e,l),{advancedFilters:f,customColumns:C,customColumnFormatMap:S,isFilterBarShown:w,quickFilters:v,reverseType:y,rollupConfig:E,aggregationSettings:R,sorts:F,userColumnWidths:D,userRowHeights:N,showSearchBar:P,searchValue:H,selectDistinctColumns:A,selectedSearchColumns:q,invertSearchColumns:B,pendingDataMap:K,frozenColumns:x,conditionalFormats:O,columnHeaderGroups:G}=te.hydrateIrisGridState(e,{...r,...a}),{isStuckToBottom:ee,isStuckToRight:ne,movedColumns:V,movedRows:W}=te.hydrateGridState(e,{...o,...i},r.customColumns);this.setState({advancedFilters:f,advancedSettings:g,conditionalFormats:O,customColumns:C,customColumnFormatMap:S,isFilterBarShown:w,isSelectingPartition:u,movedColumns:V,movedRows:W,partition:m,partitionColumn:p,quickFilters:v,reverseType:y,rollupConfig:E,aggregationSettings:R,sorts:F,userColumnWidths:D,userRowHeights:N,showSearchBar:P,searchValue:H,selectDistinctColumns:A,selectedSearchColumns:q,invertSearchColumns:B,pendingDataMap:K,frozenColumns:x,isStuckToBottom:ee,isStuckToRight:ne,columnHeaderGroups:G})}catch(o){Dn.error("loadPanelState failed to load panelState",n,o)}}updateGrid(){const e=this.irisGrid.current?.grid??null;!e||e.handleResize()}render(){const{children:e,glContainer:n,glEventHub:s,columnSelectionValidator:i,getDownloadWorker:o,inputFilters:r,links:l,metadata:a,panelState:d,user:c,workspace:u,settings:m,theme:p}=this.props,{advancedFilters:g,aggregationSettings:f,advancedSettings:C,conditionalFormats:S,customColumns:w,customColumnFormatMap:v,error:y,isDisconnected:E,isFilterBarShown:R,isSelectingPartition:F,isStuckToBottom:D,isStuckToRight:N,isLoaded:P,isLoading:H,isModelReady:A,model:q,movedColumns:B,movedRows:K,partition:x,partitionColumn:O,quickFilters:G,reverseType:ee,rollupConfig:ne,sorts:V,userColumnWidths:W,userRowHeights:X,showSearchBar:se,searchValue:ce,selectDistinctColumns:Q,selectedSearchColumns:he,invertSearchColumns:Se,Plugin:Re,pluginFilters:et,pluginFetchColumns:yt,pendingDataMap:je,frozenColumns:Tn,columnHeaderGroups:Ut}=this.state,De=y!=null?`Unable to open table. ${y}`:void 0,{table:mt}=a,at=q?.description??void 0,Rt=d?.pluginState??null,Vt=e??this.getPluginContent(Re,q,c,u,Rt),{permissions:vn}=c,{canCopy:on,canDownloadCsv:ci}=vn;return h(Il,{errorMessage:De,isDisconnected:E,isLoading:H,isLoaded:P,className:"iris-grid-panel",glContainer:n,glEventHub:s,onClearAllFilters:this.handleClearAllFilters,onResize:this.handleResize,onShow:this.handleShow,onTabFocus:this.handleShow,onTabClicked:this.handleTabClicked,widgetName:mt,widgetType:"Table",description:at,componentPanel:this,renderTabTooltip:()=>h(_d,{model:q,widgetName:mt,glContainer:n,description:at}),children:A&&q&&h(Yi,{advancedFilters:g,aggregationSettings:f,advancedSettings:C,alwaysFetchColumns:this.getAlwaysFetchColumns(l,yt),columnAllowedCursor:"linker",columnNotAllowedCursor:"linker-not-allowed",customColumns:w,customColumnFormatMap:v,columnSelectionValidator:this.isColumnSelectionValid,conditionalFormats:S,inputFilters:this.getGridInputFilters(q.columns,r),applyInputFiltersOnInit:d==null,isFilterBarShown:R,isSelectingColumn:i!=null,isSelectingPartition:F,isStuckToBottom:D,isStuckToRight:N,movedColumns:B,movedRows:K,partition:x,partitionColumn:O,quickFilters:G,reverseType:ee,rollupConfig:ne,settings:m,sorts:V,userColumnWidths:W,userRowHeights:X,model:q,showSearchBar:se,searchValue:ce,selectedSearchColumns:he,selectDistinctColumns:Q,invertSearchColumns:Se,onColumnSelected:this.handleColumnSelected,onCreateChart:this.handleCreateChart,onDataSelected:this.handleDataSelected,onError:this.handleError,onPartitionAppend:this.handlePartitionAppend,onStateChange:this.handleGridStateChange,onContextMenu:this.handleContextMenu,onAdvancedSettingsChange:this.handleAdvancedSettingsChange,customFilters:et,pendingDataMap:je,canCopy:on,canDownloadCsv:ci,ref:this.irisGrid,getDownloadWorker:o,frozenColumns:Tn,theme:p,columnHeaderGroups:Ut,children:Vt})})}}Hi.defaultProps={onStateChange:()=>{},onPanelStateUpdate:()=>{}};Hi.displayName="IrisGridPanel";Hi.COMPONENT="IrisGridPanel";const qE=(t,{localDashboardId:e=Sn})=>({inputFilters:bd(t,e),links:Ki(t,e),columnSelectionValidator:vd(t,e),user:ru(t),workspace:ml(t),settings:Et(t)}),oi=vt(qE,null,null,{forwardRef:!0})(Hi);const Yc=J.module("InputFilter"),YE=150,Fa=class extends b.exports.Component{constructor(t){super(t),this.getItemLabel=Ie((i,o)=>{const{name:r,type:l}=i[o];if(o>0&&i[o-1].name===r||o<i.length-1&&i[o+1].name===r){const a=l.substring(l.lastIndexOf(".")+1);return`${r} (${a})`}return r}),this.sendUpdate=Je(()=>{const{onChange:i}=this.props,{column:o,value:r,isValueShown:l}=this.state;i({column:o,isValueShown:l,value:r})},YE),this.handleColumnChange=this.handleColumnChange.bind(this),this.handleInputKeyPress=this.handleInputKeyPress.bind(this),this.handleValueChange=this.handleValueChange.bind(this),this.handleSettingsCancel=this.handleSettingsCancel.bind(this),this.handleSettingsClick=this.handleSettingsClick.bind(this),this.handleSettingsSave=this.handleSettingsSave.bind(this),this.handleBackgroundClick=this.handleBackgroundClick.bind(this),this.inputRef=de.createRef();const{column:e,isValueShown:n,value:s}=t;this.state={column:e,selectedColumn:e,value:s,isValueShown:n}}componentDidUpdate(t,e){const{column:n}=this.props,{column:s,value:i,isValueShown:o}=this.state;n!==t.column&&this.setState({column:n,selectedColumn:n}),o!==void 0&&o&&o!==e.isValueShown&&this.focusInput(),(s!==e.column||i!==e.value||o!==e.isValueShown)&&this.sendUpdate()}componentWillUnmount(){this.sendUpdate.flush()}handleColumnChange(t){const{columns:e}=this.props,{value:n}=t.target,s=e[parseInt(n,10)];Yc.debug2("handleColumnChange",s),this.setState({selectedColumn:s,value:void 0})}handleInputKeyPress(t){t.key==="Enter"&&(t.preventDefault(),t.stopPropagation(),this.setState(({value:e})=>e==null?{value:""}:null,()=>{this.sendUpdate(),this.sendUpdate.flush()}))}handleValueChange(t){const{value:e}=t.target;Yc.debug2("handleValueChange",e),this.setState({value:e})}handleSettingsCancel(){const{column:t}=this.state;this.setState({selectedColumn:t,isValueShown:!0})}handleSettingsSave(){const{selectedColumn:t}=this.state;this.setState({column:t,isValueShown:!0})}handleSettingsClick(t){const{column:e}=this.state;this.setState({selectedColumn:e,isValueShown:!1}),t.stopPropagation()}handleBackgroundClick(t){t.target!==this.inputRef.current&&this.focusInput()}focusInput(){this.inputRef.current!==null&&(this.inputRef.current.select(),this.inputRef.current.focus())}clearFilter(){this.setState({value:""})}setFilterState({name:t,type:e,value:n,isValueShown:s}){const i=t!=null&&e!=null?{name:t,type:e}:void 0,o=s===void 0?{column:i,value:n}:{column:i,value:n,isValueShown:s};this.setState(o)}render(){const{columns:t}=this.props,{column:e,isValueShown:n,selectedColumn:s,value:i}=this.state,o=i==null||i.length===0?Fa.PLACEHOLDER.length:i.length;let r=null;if(e!=null){const l=t.findIndex(a=>a.name===e.name&&a.type===e.type);r=l>=0?this.getItemLabel(t,l):e.name}return T(Ga,{className:"input-filter fill-parent-absolute",isFlipped:n??!1,children:[h("div",{className:"input-filter-settings-card",children:T("div",{className:"input-filter-settings-content",children:[T("div",{className:"input-filter-settings-grid",children:[h("label",{children:"Filter Column"}),T("select",{value:t.findIndex(l=>l.name===s?.name&&l.type===s?.type),className:"custom-select",onChange:this.handleColumnChange,children:[t.map((l,a)=>h("option",{value:a,children:this.getItemLabel(t,a)},`${l.name}/${l.type}`)),t.length===0&&h("option",{value:"-1",disabled:!0,children:"No Available Columns"})]}),h("div",{className:"text-muted small",children:"Input filter control will apply its filter to all columns matching this name in this dashboard."})]}),T("div",{className:"input-filter-settings-buttons",children:[h(U,{kind:"secondary",onClick:this.handleSettingsCancel,disabled:e==null,children:"Cancel"}),h(U,{kind:"primary",className:"ml-2",onClick:this.handleSettingsSave,disabled:s==null,children:"Save"})]})]})}),T("div",{className:"input-filter-value-card",onClick:this.handleBackgroundClick,children:[h("div",{className:"input-filter-column",children:T("div",{className:"input-filter-column-title",children:[r," Filter"]})}),h("div",{className:"d-flex justify-content-center align-items-center h-100 w-100",children:h("div",{className:"input-filter-value-input d-flex flex-column justify-content-center",children:h("input",{type:"text",ref:this.inputRef,placeholder:Fa.PLACEHOLDER,value:i??"",onChange:this.handleValueChange,onKeyPress:this.handleInputKeyPress,style:{width:`${o+3}ch`},spellCheck:"false"})})}),h("div",{className:"input-filter-menu",children:h(U,{kind:"ghost",className:"m-2 px-2",onClick:this.handleSettingsClick,icon:h(Z,{icon:_o,transform:"grow-4"}),tooltip:"Input Filter Settings"})})]})]})}};let Md=Fa;Md.PLACEHOLDER="Enter value...";Md.defaultProps={column:null,isValueShown:!1,value:null};const KE=250;class _l extends b.exports.Component{constructor(e){super(e),this.handleChange=Je(this.handleChange.bind(this),KE),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.inputFilterRef=de.createRef();const{panelState:n}=e,{value:s,isValueShown:i=!1,name:o,type:r,timestamp:l}=n??{};this.state={columns:[],column:o!=null&&r!=null?{name:o,type:r}:void 0,value:s,timestamp:l,isValueShown:i,wasFlipped:!1,skipUpdate:!1,panelState:n}}componentDidMount(){this.updateColumns();const{column:e,value:n,timestamp:s}=this.state;if(e!=null){const{name:i,type:o}=e;this.sendUpdate(i,o,n,s)}}componentDidUpdate(e){const{columns:n}=this.props;n!==e.columns&&this.updateColumns()}handleChange({column:e,isValueShown:n=!1,value:s}){let i,o;e!=null&&({name:i,type:o}=e);let r=!0,l=Date.now();this.setState(({panelState:a,timestamp:d,wasFlipped:c,skipUpdate:u})=>{const m=a!=null&&n!==a.isValueShown&&i===a.name&&o===a.type&&s===a.value;return r=(!u&&n&&(!m||!c))??!1,r||(l=d),{panelState:{isValueShown:n,name:i,type:o,value:s,timestamp:l},timestamp:l,wasFlipped:m,skipUpdate:!1}},()=>{r&&this.sendUpdate(i,o,s,l)})}handleClearAllFilters(){this.inputFilterRef.current?.clearFilter()}sendUpdate(e,n,s,i){const{glEventHub:o}=this.props;o.emit(Le.FILTERS_CHANGED,this,{name:e,type:n,value:s,timestamp:i})}setPanelState(e,n=!1){this.setState({skipUpdate:!n}),this.inputFilterRef.current?.setFilterState(e)}updateColumns(){const{columns:e}=this.props;e!=null&&this.setState(n=>{const{column:s}=n;return s==null&&e.length>0?{columns:[...e],column:e[0]}:s!=null&&!e.find(({name:i,type:o})=>s.name===i&&s.type===o)?{columns:[...e,s]}:{columns:[...e]}})}render(){const{glContainer:e,glEventHub:n}=this.props,{column:s,columns:i,isValueShown:o,value:r}=this.state;return h($n,{className:"iris-input-filter-panel",componentPanel:this,glContainer:e,glEventHub:n,onClearAllFilters:this.handleClearAllFilters,isClonable:!0,isRenamable:!0,children:h(Md,{ref:this.inputFilterRef,column:s,columns:i,onChange:this.handleChange,isValueShown:o,value:r})})}}_l.defaultProps={panelState:null};_l.COMPONENT="InputFilterPanel";_l.displayName="InputFilterPanel";const XE=(t,e)=>{const{localDashboardId:n}=e;return{columns:Am(t,n)}},vo=vt(XE,null,null,{forwardRef:!0})(_l);const Ft=J.module("FilterSetManagerPanel");function jE(t){return t.setPanelState!=null}const Da=class extends b.exports.Component{static changeFilterIndexesToColumnNames(t,e){return e.map(([n,s])=>{if(n>=t.columns.length)return null;const{name:i}=t.columns[n];return{name:i,filter:s}}).filter(n=>n!=null)}constructor(t){super(t),this.handleChange=this.handleChange.bind(this),this.handleFilterApply=this.handleFilterApply.bind(this),this.handleSetsUpdate=this.handleSetsUpdate.bind(this),this.handleGetFilterState=this.handleGetFilterState.bind(this);const{panelState:e,filterSets:n}=t,{selectedId:s=n.length>0?n[0].id:void 0,isValueShown:i=!1}=e??{};this.state={selectedId:s,isValueShown:i,panelState:e}}getFilterState(){const{dashboardOpenedPanelMap:t}=this.props,e=[];return[...t.keys()].forEach(n=>{const s=t.get(n);if(s===void 0){Ft.error("Could not get panel",s);return}const i=ie.getComponentNameFromPanel(s),o=ie.getIdFromPanel(s);Ft.debug("Panel:",s,i);const{glContainer:r=null}=s.props;if(r==null){Ft.error("Could not get panel container",s);return}const l=ie.getComponentConfigFromContainer(r);if(l==null){Ft.error("Could not get component config from container",r);return}const a=ie.getPanelComponentState(l);if(a==null){Ft.debug(`Panel state is null ${o}`);return}switch(i){case ie.getComponentName(Hi):{let d;o!=null&&(d=this.getIrisGridPanelFilters(o,a)),d!=null&&e.push({panelId:o,type:i,state:d});break}case ie.getComponentName(vo):case ie.getComponentName(ii):{const{isValueShown:d,name:c,type:u,value:m}=a;e.push({panelId:o,type:i,state:{isValueShown:d,name:c,type:u,value:m}});break}}}),e}getIrisGridPanelFilters(t,e){const{panelTableMap:n}=this.props,s=n.get(t);if(s==null)return Ft.error(`Unable to get table for panel ${t}.`),null;const{irisGridState:i={advancedFilters:void 0,quickFilters:void 0},gridState:o={}}=e,{advancedFilters:r,quickFilters:l}=i;let a;r&&(a=Da.changeFilterIndexesToColumnNames(s,r));let d;return l&&(d=Da.changeFilterIndexesToColumnNames(s,l)),{irisGridState:{...i,advancedFilters:a,quickFilters:d},gridState:{...o}}}handleGetFilterState(){return this.getFilterState()}handleChange({isValueShown:t,selectedId:e}){Ft.debug("handleChange",t,e),this.setState({isValueShown:t,selectedId:e}),this.updatePanelState()}handleFilterApply(t){const{dashboardOpenedPanelMap:e}=this.props,{panels:n,restoreFullState:s=!1}=t;Ft.debug("Apply filters from filter set",t),n.forEach(({panelId:i,type:o,state:r})=>{if(i==null){Ft.debug("panel is null",i);return}if(!e.has(i)){Ft.debug("Ignore closed panel",i);return}Ft.debug("Apply panel filters",i,o,r);const l=e.get(i);switch(o){case ie.getComponentName(Hi):this.restoreIrisGridFilters(l,r,s);break;case ie.getComponentName(vo):case ie.getComponentName(ii):this.restoreInputFilterState(l,r);break}})}handleSetsUpdate(t){const{setDashboardFilterSets:e,localDashboardId:n}=this.props;Ft.debug("Saving updated sets",t),e(n,[...t])}updatePanelState(){this.setState(({selectedId:t,isValueShown:e})=>({panelState:{selectedId:t,isValueShown:e}}))}restoreIrisGridFilters(t,e,n){const{irisGridState:s={},advancedFilters:i=[],quickFilters:o=[]}=e,{advancedFilters:r=i,quickFilters:l=o}=s,{panelTableMap:a}=this.props,d=ie.getIdFromPanel(t);if(d==null){Ft.error("Panel Id is null.");return}if(a.get(d)==null){Ft.error(`Unable to get table for panel ${d}.`);return}Ft.debug("restoreIrisGridFilters",d,e,n),n?t.setStateOverrides(e):t.setFilters({quickFilters:l,advancedFilters:r})}restoreInputFilterState(t,e){const n={...e};delete n.isValueShown,Ft.debug("restoreInputFilterState",t,n),t&&jE(t)&&t.setPanelState(n)}render(){const{glContainer:t,glEventHub:e,filterSets:n}=this.props,{isValueShown:s,selectedId:i}=this.state;return h($n,{className:"filter-set-manager-panel",componentPanel:this,glContainer:t,glEventHub:e,isClonable:!0,isRenamable:!0,children:h("div",{className:"input-filter-container h-100 w-100 container",children:h(Yr,{onChange:this.handleChange,onApply:this.handleFilterApply,onUpdateSets:this.handleSetsUpdate,isValueShown:s,filterSets:n,selectedId:i,getFilterState:this.handleGetFilterState})})})}};let kd=Da;kd.defaultProps={panelState:null};kd.COMPONENT="FilterSetManagerPanel";const QE=(t,e)=>{const{localDashboardId:n}=e;return{filterSets:uE(t,n),dashboardOpenedPanelMap:Ku(t,n),dashboardInputFilters:bd(t,n),panelTableMap:wd(t,n)}},na=vt(QE,{setDashboardFilterSets:wE},null,{forwardRef:!0})(kd);const Kc=J.module("LogPanel");class Ml extends b.exports.PureComponent{constructor(e){super(e),this.handleResize=this.handleResize.bind(this),this.handleShow=this.handleShow.bind(this),this.handleHide=this.handleHide.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.isBottomVisible=!0,this.logView=null;const{session:n}=this.props;this.state={session:n}}handleResize(){this.updateDimensions()}handleShow(){this.updateDimensions(),this.logView&&(this.logView.triggerFindWidget(),this.isBottomVisible&&this.logView.scrollToBottom())}handleHide(){this.logView&&(this.isBottomVisible=this.logView.isBottomVisible())}handleSessionOpened(e){Kc.debug("Session opened",[e]),this.setState({session:e})}handleSessionClosed(e){Kc.debug("Session closed",e)}updateDimensions(){this.logView&&this.logView.updateDimensions()}render(){const{glContainer:e,glEventHub:n}=this.props,{session:s}=this.state;return T($n,{componentPanel:this,glContainer:e,glEventHub:n,onResize:this.handleResize,onHide:this.handleHide,onShow:this.handleShow,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,children:[s==null&&h("div",{className:"log-panel-disconnected-message",children:"Waiting for session connection"}),s!=null&&h($i,{session:s,ref:i=>{this.logView=i}})]})}}Ml.defaultProps={session:null};Ml.COMPONENT="LogPanel";Ml.TITLE="Log";const ZE=(t,e)=>({session:ai(t,e.localDashboardId)?.session}),Kr=vt(ZE,null,null,{forwardRef:!0})(Ml);class Bm extends b.exports.PureComponent{render(){const{isEditing:e,children:n,onDoubleClick:s}=this.props;return T("div",{className:"markdown-editor-container h-100 w-100",onDoubleClick:s,children:[h("div",{className:Y("text-muted","edit-hint",{viewing:e===void 0||!e}),children:T("span",{children:["double-click to edit ",h(Z,{icon:Mo})]})}),n]})}}Bm.defaultProps={isEditing:!1};const JE=J.module("MarkdownStartPage");class $m extends b.exports.PureComponent{constructor(e){super(e),this.handleDeleteButtonClick=this.handleDeleteButtonClick.bind(this),this.handleDeleteModalClose=this.handleDeleteModalClose.bind(this),this.state={isDeleteModalShown:!1}}handleDeleteButtonClick(e){this.setState({isDeleteModalShown:!0,toBeDeleted:e})}handleDeleteModalClose(){this.setState({isDeleteModalShown:!1,toBeDeleted:void 0})}handleDeleteMarkdown(e){if(JE.debug("delete markdown: ",e),e!==void 0){const{onDelete:n}=this.props;n(e)}this.setState({isDeleteModalShown:!1,toBeDeleted:void 0})}render(){const{closedMarkdowns:e,onOpen:n,onCreate:s}=this.props,{isDeleteModalShown:i,toBeDeleted:o}=this.state;return h("div",{className:"markdown-panel-start-page h-100 w-100",children:T("div",{className:"markdown-panel-start-page-container",children:[T("div",{className:"markdown-panel-start-list",children:[h("h3",{className:"list-title",children:"Start"}),h("div",{className:"list-item",children:h(U,{kind:"ghost",className:"title",onClick:s,children:"New Markdown Note"})})]}),T("div",{className:"markdown-panel-start-list",children:[h("h3",{className:"list-title",children:"Recently Closed from Dashboard"}),e.map(r=>T("div",{className:"list-item",children:[h(U,{kind:"ghost",className:"title",onClick:()=>n(r),children:r.title}),h("button",{className:"btn-link icon",type:"button",onClick:()=>{this.handleDeleteButtonClick(r)},children:h(Z,{icon:sn})})]},r.id)),T(nl,{isOpen:i,toggle:this.handleDeleteModalClose,className:"modal-dialog-centered markdown-delete-modal theme-bg-light",children:[h(sl,{children:"Are you sure you want to permanently delete this note?"}),h(il,{children:"You can't undo this action."}),T(_h,{children:[h(U,{kind:"secondary",onClick:this.handleDeleteModalClose,children:"Cancel"}),h(U,{kind:"danger",onClick:()=>{this.handleDeleteMarkdown(o)},children:"Delete"})]})]})]})]})})}}$m.defaultProps={closedMarkdowns:[],onOpen:()=>{},onCreate:()=>{},onDelete:()=>{}};const ey=t=>{const{children:e,className:n}=t,s=n!==void 0&&n?.startsWith("language-")?n.substring(9):"plaintext";return h("pre",{children:h("code",{children:h(cl,{language:s,children:de.Children.map(e,i=>typeof i=="string"?i.trim():i)})})})};class Gm extends b.exports.PureComponent{constructor(e){super(e),this.container=null}render(){const{isEditing:e,content:n,onEditorInitialized:s}=this.props;return h("div",{className:"markdown-editor-container",ref:i=>{this.container=i},children:e?h(hl,{settings:{language:"markdown",value:n,lineNumbers:"off"},onEditorInitialized:s}):h(fh,{components:{code:ey},children:n})})}}Gm.defaultProps={isEditing:!1,content:""};const Cr=J.module("MarkdownPanel");class xd extends b.exports.Component{constructor(e){super(e),this.getClosedMarkdowns=ge(i=>i.filter(o=>o.component==="MarkdownPanel").reverse()),this.handleContainerDoubleClick=this.handleContainerDoubleClick.bind(this),this.handleCreateMarkdown=this.handleCreateMarkdown.bind(this),this.handleDeleteMarkdown=this.handleDeleteMarkdown.bind(this),this.handleOpenMarkdown=this.handleOpenMarkdown.bind(this),this.handleEditorInitialized=this.handleEditorInitialized.bind(this),this.handleEditorBlur=this.handleEditorBlur.bind(this),this.handleEditorResize=this.handleEditorResize.bind(this);const{panelState:n}=e;let s=null;n!=null&&n.content!=null&&({content:s}=n),this.state={isStartPageShown:s==null,isEditing:!1,content:s,panelState:n},this.markdownEditor=null}setEditorPosition(e){k(this.markdownEditor);const{container:n}=this.markdownEditor;if(this.editor&&n){const s=n.getBoundingClientRect().top,i=n.scrollTop,o=n.scrollHeight,r=this.editor.getModel()?.getLineCount()??0;let l=Math.round((i+e-s)/o*r);l>r&&(l=r),this.editor.revealLine(l),this.editor.setPosition({lineNumber:l,column:1}),this.editor.focus()}}handleContainerDoubleClick(e){const{isEditing:n}=this.state,s=e.clientY;n||this.setState({isEditing:!0},()=>{this.setEditorPosition(s)})}handleEditorInitialized(e){Cr.debug("Markdown Editor Initialized..."),this.editor=e}handleCreateMarkdown(){Cr.debug("create markdown..."),this.setState({isStartPageShown:!1,content:"",isEditing:!0,panelState:{content:""}},()=>{this.editor!=null&&this.editor.focus!=null&&this.editor.focus()})}handleOpenMarkdown(e){Cr.debug("open markdown...",e);const{glContainer:n,glEventHub:s}=this.props,i=ie.getComponentConfigFromContainer(n);s.emit(Ee.REOPEN,e,i)}handleDeleteMarkdown(e){const{glEventHub:n}=this.props;n.emit(Ee.DELETE,e)}handleEditorBlur(e){Cr.debug("markdown content changed, saving...");const{isEditing:n}=this.state;if(!n||this.markdownEditor!=null&&this.markdownEditor.container!=null&&this.markdownEditor.container.contains(e.relatedTarget))return;const s=this.editor?.getValue();this.setState({content:s,isEditing:!1,panelState:{content:s}})}handleEditorResize(){const{isEditing:e}=this.state;e&&this.editor&&this.editor.layout()}render(){const{glContainer:e,glEventHub:n,closedPanels:s}=this.props,{isEditing:i,isStartPageShown:o,content:r}=this.state,l=this.getClosedMarkdowns(s);return h($n,{glContainer:e,glEventHub:n,className:"markdown-panel",componentPanel:this,onResize:this.handleEditorResize,onBlur:this.handleEditorBlur,isClonable:!0,isRenamable:!0,children:o?h($m,{closedMarkdowns:l,onCreate:this.handleCreateMarkdown,onOpen:this.handleOpenMarkdown,onDelete:this.handleDeleteMarkdown}):h(Bm,{isEditing:i,onDoubleClick:this.handleContainerDoubleClick,children:h(Gm,{ref:a=>{this.markdownEditor=a},isEditing:i,content:r??void 0,onEditorInitialized:this.handleEditorInitialized})})})}}xd.defaultProps={panelState:null};xd.COMPONENT="MarkdownPanel";const ty=(t,e)=>{const{localDashboardId:n}=e;return{closedPanels:Yb(t,n)}},co=vt(ty,null,null,{forwardRef:!0})(xd);class Wm extends b.exports.PureComponent{constructor(e){super(e),this.handleRunSelected=this.handleRunSelected.bind(this),this.renderCodeBlock=this.renderCodeBlock.bind(this),this.renderLink=this.renderLink.bind(this),this.commands=new Map,this.codeElements=new Map,this.editorScrollView=de.createRef(),this.state={hasCode:!1,hasRunCode:!1,nextStartLine:null}}componentDidMount(){this.updateHasCode()}componentDidUpdate(){this.updateHasCode()}updateHasCode(){const{hasCode:e}=this.state;this.commands.size===0&&e?this.setState({hasCode:!1}):this.commands.size>0&&!e&&this.setState({hasCode:!0})}getNextStartLine(e){const n=[...this.commands.keys()],s=n.findIndex(i=>i===e)+1;return s>=n.length?null:n[s]}handleRunSelected(e){e.preventDefault(),e.stopPropagation();const{nextStartLine:n}=this.state,s=[...this.commands.keys()],i=s.findIndex(c=>c===n||n==null);if(i<0)return;const o=s[i],r=this.commands.get(o),l=this.getNextStartLine(o),d=this.codeElements.get(o)?.current?.parentElement?.nextElementSibling;if(d!=null){const{offsetTop:c}=d,u=c;this.editorScrollView.current?.scroll({top:u,left:0})}this.runCode(r),this.setState({nextStartLine:l})}runCode(e){const{onRunCode:n}=this.props;n(e),this.setState({hasRunCode:!0})}renderCodeBlock(e){const{children:n,className:s,inline:i,node:o}=e,{hasRunCode:r,nextStartLine:l}=this.state,{children:a,position:d}=o;k(d);const{start:c}=d,{line:u}=c,m=a[0].value,p=de.createRef(),g=this.commands.size===0,f=l===u||g&&l==null&&!r,C=s!==void 0&&s.startsWith("language-")?s.substring(9):"plaintext";return i!=null&&i?h("code",{className:s,children:n}):(this.commands.set(u,m),this.codeElements.set(u,p),T("div",{className:Y("markdown-notebook-code-block",{"is-selected":f}),ref:p,onClick:()=>{this.setState({nextStartLine:u})},role:"presentation",children:[h(U,{kind:"ghost",icon:_r,className:"btn-play-block",onClick:S=>{S.stopPropagation(),S.preventDefault(),this.runCode(m),this.setState({nextStartLine:u})},tooltip:"Run code"}),h("code",{children:h(cl,{language:C,children:de.Children.map(n,S=>typeof S=="string"?S.trim():S)})})]}))}renderLink(e){const{onLinkClick:n}=this.props,{href:s,children:i,target:o}=e;return h("a",{href:s,onClick:n,target:o,children:i})}render(){const{content:e,transformImageUri:n,transformLinkUri:s}=this.props,{hasCode:i,hasRunCode:o,nextStartLine:r}=this.state;return T("div",{className:"markdown-notebook",children:[h("div",{className:"markdown-notebook-toolbar",children:h(U,{className:Y("btn-play-selected-cell",{flashing:i&&!o}),kind:"ghost",icon:_r,onClick:this.handleRunSelected,tooltip:"Run code and select next",disabled:o&&r==null||!i,children:"Run Selected Code"})}),h("div",{className:"markdown-notebook-content",ref:this.editorScrollView,children:h(fh,{components:{code:this.renderCodeBlock,a:this.renderLink},linkTarget:"_blank",remarkPlugins:[$p],transformLinkUri:s,transformImageUri:n,includeElementIndex:!0,children:e})})]})}}Wm.defaultProps={onRunCode:()=>{}};const Ue=J.module("NotebookPanel"),Xc=400,yi=class extends b.exports.Component{constructor(t){super(t),this.getSettings=ge((u,m)=>({...u,minimap:{enabled:m}})),this.getOverflowActions=ge((u,m)=>[{title:"Find",icon:tf,action:this.handleFind,group:le.groups.high,shortcut:Pt.NOTEBOOK.FIND,order:10},{title:"Show Minimap",icon:u?ss:void 0,action:this.handleMinimapChange,group:le.groups.medium,shortcut:Pt.NOTEBOOK.MINIMAP,order:20},{title:"Word Wrap",icon:m?ss:void 0,action:this.handleWordWrapChange,group:le.groups.medium,shortcut:Pt.NOTEBOOK.WORDWRAP,order:30}]),this.handleBlur=this.handleBlur.bind(this),this.handleCloseCancel=this.handleCloseCancel.bind(this),this.handleCloseDiscard=this.handleCloseDiscard.bind(this),this.handleCloseSave=this.handleCloseSave.bind(this),this.handleCopy=this.handleCopy.bind(this),this.handleEditorInitialized=this.handleEditorInitialized.bind(this),this.handleEditorWillDestroy=this.handleEditorWillDestroy.bind(this),this.handleEditorChange=this.handleEditorChange.bind(this),this.handleFind=this.handleFind.bind(this),this.handleMinimapChange=this.handleMinimapChange.bind(this),this.handleWordWrapChange=this.handleWordWrapChange.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleLinkClick=this.handleLinkClick.bind(this),this.handleLoadSuccess=this.handleLoadSuccess.bind(this),this.handleLoadError=this.handleLoadError.bind(this),this.handlePanelTabClick=this.handlePanelTabClick.bind(this),this.handleRenameFile=this.handleRenameFile.bind(this),this.handleResize=this.handleResize.bind(this),this.handleRunCommand=this.handleRunCommand.bind(this),this.handleRunAll=this.handleRunAll.bind(this),this.handleRunSelected=this.handleRunSelected.bind(this),this.handleSave=this.handleSave.bind(this),this.handleSaveAsCancel=this.handleSaveAsCancel.bind(this),this.handleSaveAsSubmit=this.handleSaveAsSubmit.bind(this),this.handleSaveError=this.handleSaveError.bind(this),this.handleSaveSuccess=this.handleSaveSuccess.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleShow=this.handleShow.bind(this),this.handleShowRename=this.handleShowRename.bind(this),this.handleTab=this.handleTab.bind(this),this.handleTabFocus=this.handleTabFocus.bind(this),this.handleTabBlur=this.handleTabBlur.bind(this),this.handleTransformLinkUri=this.handleTransformLinkUri.bind(this),this.handleOverwrite=this.handleOverwrite.bind(this),this.getDropdownOverflowActions=this.getDropdownOverflowActions.bind(this),this.pending=new ds,this.debouncedSavePanelState=Je(this.savePanelState.bind(this),Xc),this.debouncedLoad=Je(this.load.bind(this),Xc),this.notebook=null,this.tabTitleElement=null,this.tabInitOnce=!1;const{isDashboardActive:e,session:n,sessionLanguage:s,panelState:i}=t;let o={value:"",language:"",wordWrap:"off"},r=null,{isPreview:l}=t;i!=null&&({fileMetadata:r=r,isPreview:l=l,settings:o=o}=i);const a=r!=null&&me.hasPath(r.itemName),c=a===!0&&o.value!=null||!a&&o.value!=null&&o.value.length>0?1:0;this.state={error:void 0,isDashboardActive:e,isFocused:!1,isLoading:!0,isLoaded:!1,isPreview:l,savedChangeCount:0,changeCount:c,fileMetadata:r,settings:o,session:n,sessionLanguage:s,panelState:{fileMetadata:r,settings:o},showCloseModal:!1,showSaveAsModal:!1,scriptCode:"",shouldPromptClose:!0},Ue.debug("constructor",t,this.state)}static handleError(t){ye.isCanceled(t)||Ue.error(t)}static languageFromFileName(t){switch(me.getExtension(t).toLowerCase()){case"py":case"python":return"python";case"groovy":return"groovy";case"scala":return"scala";default:return null}}componentDidMount(){const{glContainer:t,glEventHub:e}=this.props,{tab:n}=t;n!=null&&this.initTab(n),this.initNotebookContent(),e.on(Ae.RENAME_FILE,this.handleRenameFile),t.on("tabClicked",this.handlePanelTabClick)}componentDidUpdate(t,e){const{isPreview:n,settings:s}=this.state,{wordWrap:i}=s,{defaultNotebookSettings:o}=this.props;n!==e.isPreview&&this.setPreviewStatus(),i!==e.settings.wordWrap&&(this.updateEditorWordWrap(),this.debouncedSavePanelState()),o.isMinimapEnabled!==t.defaultNotebookSettings.isMinimapEnabled&&this.updateEditorMinimap()}componentWillUnmount(){this.debouncedSavePanelState.flush(),this.pending.cancel();const{glContainer:t,glEventHub:e}=this.props,{fileMetadata:n,isPreview:s}=this.state;e.off(Ae.RENAME_FILE,this.handleRenameFile),t.off("tabClicked",this.handlePanelTabClick),e.emit(Ae.UNREGISTER_FILE,n,s)}initTab(t){this.tabInitOnce||(this.tabInitOnce=!0,this.initTabCloseOverride()),this.initTabClasses(t)}initTabCloseOverride(){const{glContainer:t}=this.props;t.beforeClose(e=>{if(e?.force===!0)return!0;const{changeCount:n,savedChangeCount:s,shouldPromptClose:i}=this.state;return n!==s&&i?(this.setState({showCloseModal:!0}),!1):!0})}initTabClasses(t){const e=t.element.get(0);k(e);const n=e.querySelector(".lm_title");this.tabTitleElement=n,n?.classList.add("notebook-title"),this.setPreviewStatus()}getNotebookValue(){const{changeCount:t,savedChangeCount:e,settings:n}=this.state,{value:s}=n;if(t!==e&&this.notebook){const i=this.notebook.getValue();return i??s}return s}initNotebookContent(){const{fileMetadata:t,settings:e,isPreview:n}=this.state;if(t&&t.id){Ue.debug("Init content from file"),this.registerFileMetadata(t,n),this.load();return}if(e.value!=null){Ue.debug("Use content passed in the settings prop"),this.handleLoadSuccess();return}this.handleLoadError(new Error("Missing file metadata"))}closeFileTabById(t){const{glEventHub:e}=this.props;e.emit(Ae.CLOSE_FILE,{id:t})}registerFileMetadata(t,e){const{glEventHub:n,metadata:s}=this.props,{id:i}=s;n.emit(Ae.REGISTER_FILE,i,t,e)}renameTab(t,e){const{glEventHub:n}=this.props;n.emit(Ae.RENAME,t,e)}load(){const{fileMetadata:t,settings:e}=this.state;k(t);const{id:n}=t,{fileStorage:s}=this.props;this.pending.add(s.loadFile(n)).then(i=>{Ue.debug("Loaded file",i);const{filename:o}=i,{itemName:r}=this.state;if(o!==r){const{metadata:a}=this.props,{id:d}=a;this.renameTab(d,me.getBaseName(o))}const l={...e,language:yi.languageFromFileName(o)??""};e.value==null&&(l.value=i.content),e.wordWrap===void 0&&(e.wordWrap="off"),this.setState({fileMetadata:{id:o,itemName:o},settings:l}),this.debouncedSavePanelState()}).then(this.handleLoadSuccess).catch(this.handleLoadError)}save(){const{fileMetadata:t}=this.state;if(t&&me.hasPath(t.itemName)){const e=this.getNotebookValue();return e!==void 0?(this.saveContent(t.itemName,e),!0):!1}return this.setState({showSaveAsModal:!0}),!1}saveContent(t,e){Ue.debug("saveContent",t,e),this.updateSavedChangeCount();const{fileStorage:n}=this.props;this.pending.add(n.saveFile({filename:t,content:e,basename:t})).then(this.handleSaveSuccess).catch(this.handleSaveError)}updateSavedChangeCount(){this.setState(({changeCount:t})=>({savedChangeCount:t}))}setPreviewStatus(){if(!this.tabTitleElement)return;const{isPreview:t}=this.state;Ue.debug("setPreviewStatus",this.tabTitleElement,t),t?this.tabTitleElement.classList.add("is-preview"):this.tabTitleElement.classList.remove("is-preview")}savePanelState(){this.setState(t=>{const{changeCount:e,savedChangeCount:n,fileMetadata:s,isPreview:i,settings:o}=t,r=this.getNotebookValue(),l=e!==n?r:void 0,a={...o,value:r},c={settings:{...o,value:l},fileMetadata:s,isPreview:i};return Ue.debug("Saving panel state",c),{settings:a,panelState:c}})}handleCloseDiscard(){this.setState({shouldPromptClose:!1,showCloseModal:!1});const{glContainer:t}=this.props;t.close()}handleCloseSave(){if(this.setState({shouldPromptClose:!1,showCloseModal:!1}),this.save()){const{glContainer:t}=this.props;t.close()}}handleCloseCancel(){this.setState({shouldPromptClose:!0,showCloseModal:!1})}handleOverwrite(t){const{glEventHub:e}=this.props;e.emit(Ae.CLOSE_FILE,{id:t,itemName:t},{force:!0}),this.focus()}handleCopy(){const{fileMetadata:t,settings:e}=this.state;k(t);const n=this.getNotebookValue(),{language:s}=e,{itemName:i}=t,o=me.getCopyFileName(i);Ue.debug("handleCopy",t,i,o),this.createNotebook(o,s,n)}handleEditorInitialized(t){this.editor=t}handleEditorWillDestroy(){this.editor=void 0}handleEditorChange(t){Ue.debug2("handleEditorChanged",t),this.removePreviewStatus(),this.setState(e=>{const{changeCount:n,savedChangeCount:s}=e,{isUndoing:i,isRedoing:o}=t;return i?{changeCount:n-1,savedChangeCount:s}:!o&&n<s?{changeCount:n+1,savedChangeCount:0}:{changeCount:n+1,savedChangeCount:s}}),this.debouncedSavePanelState()}handleFind(){this.notebook&&this.notebook.toggleFind()}updateEditorMinimap(){if(this.editor){const{defaultNotebookSettings:t}=this.props;this.editor.updateOptions({minimap:{enabled:t.isMinimapEnabled}})}}handleMinimapChange(){const{settings:t,defaultNotebookSettings:e,saveSettings:n}=this.props,s={...t,defaultNotebookSettings:{isMinimapEnabled:!e.isMinimapEnabled}};n(s)}updateEditorWordWrap(){if(this.editor){const{settings:t}=this.state,{wordWrap:e}=t;this.editor.updateOptions({wordWrap:e})}}handleWordWrapChange(){this.editor&&this.setState(t=>{const{settings:e}=t,n=e.wordWrap==="on"?"off":"on";return{settings:{...e,wordWrap:n}}})}handleBlur(){Ue.debug("handleBlur"),this.setState({isFocused:!1})}handleFocus(){Ue.debug("handleFocus"),this.setState({isFocused:!0})}handleLinkClick(t){const{notebooksUrl:e,session:n,sessionLanguage:s}=this.props,{href:i}=t.currentTarget;if(!i||!i.startsWith(e))return;t.stopPropagation(),t.preventDefault();const o=`/${i.substring(e.length)}`.replace(/%20/g," ");if(o==="/"){Ue.debug("Ignoring invalid notebook link",o);return}Ue.debug("Notebook link clicked, opening",o);const{glEventHub:r}=this.props,l={value:null,language:s},a={id:o,itemName:o};r.emit(Ae.SELECT_NOTEBOOK,n,s,l,a)}handleLoadSuccess(){this.setState({error:void 0,isLoaded:!0,isLoading:!1})}handleLoadError(t){let e=t;ye.isCanceled(e)||(ye.isTimedOut(e)&&(e=new Error("File not found.")),Ue.error(e),this.setState({error:e,isLoading:!1}))}handleSave(){Ue.debug("handleSave"),this.save()}handleSaveSuccess(t){const{fileStorage:e}=this.props,n={id:t.filename,itemName:t.filename},s=yi.languageFromFileName(t.filename)??"";this.setState(i=>{const{fileMetadata:o}=i,r={...i.settings,language:s};return Ue.debug("handleSaveSuccess",n,o,r),o&&me.hasPath(o.itemName)&&o.itemName!==n.itemName&&(Ue.debug("handleSaveSuccess deleting old file",o.itemName),e.deleteFile(o.itemName).catch(yi.handleError)),{fileMetadata:n,settings:r,isPreview:!1}}),this.debouncedSavePanelState(),this.registerFileMetadata(n,!1)}handleSaveError(t){ye.isCanceled(t)||(this.setState({savedChangeCount:0}),Ue.error(t))}handleSaveAsCancel(){this.setState({showSaveAsModal:!1})}handleSaveAsSubmit(t,e=!1){e&&this.handleOverwrite(t),Ue.debug("handleSaveAsSubmit",t);const{fileMetadata:n}=this.state;if(!n)return;const{itemName:s}=n,i=this.getNotebookValue()??"";if(this.setState({showSaveAsModal:!1}),me.getBaseName(s)!==me.getBaseName(t)){const{metadata:o}=this.props,{id:r}=o;this.renameTab(r,me.getBaseName(t))}this.saveContent(t,i)}handleRenameFile(t,e,n){const{fileMetadata:s,panelState:i}=this.state,{glContainer:o}=this.props;if(s?.itemName===`/${e}`&&n&&JSON.stringify(i)!==JSON.stringify(n)){o.close();return}s&&s.id===t&&(this.setState({fileMetadata:{id:e,itemName:e}}),this.debouncedSavePanelState())}handleResize(){this.notebook?.updateDimensions()}handleRunCommand(t){this.runCommand(t)}handleRunAll(){if(!this.notebook){Ue.error("Editor is not initialized.");return}this.runCommand(this.notebook.getValue()??void 0)}handleRunSelected(){if(!this.notebook){Ue.error("Editor is not initialized.");return}this.runCommand(this.notebook.getSelectedCommand())}handleSessionOpened(t,{language:e}){this.setState({session:t,sessionLanguage:e})}handleSessionClosed(){this.setState({session:void 0,sessionLanguage:void 0})}handleShow(){Ue.debug("handleShow"),this.notebook?.updateDimensions()}handleShowRename(){this.setState({showSaveAsModal:!0})}handleTab(t){Ue.debug("NotebookPanel tab event",t),this.initTab(t)}handleTabFocus(...t){Ue.debug("handleTabFocus",...t);const{glContainer:e}=this.props;this.setState({isDashboardActive:!0}),this.notebook&&!e.isHidden&&this.notebook.updateDimensions()}handleTabBlur(){Ue.debug("handleTabBlur"),this.setState({isDashboardActive:!1})}handlePanelTabClick(){Ue.debug("handlePanelTabClick"),this.focus()}handleTransformLinkUri(t){const{notebooksUrl:e}=this.props,{fileMetadata:n}=this.state;if(t.endsWith("/"))return t;if(t.startsWith("/"))return`${e}${t.substring(1)}`;let s=n?.itemName;if(s===void 0)return t;s.charAt(0)==="/"&&(s=s.substring(1));const i=new URL(s,e);return new URL(t,i).href}focus(){requestAnimationFrame(()=>{this.notebook&&this.notebook.focus()})}createNotebook(t,e,n=""){const{glEventHub:s}=this.props,{session:i,sessionLanguage:o,settings:r}=this.state,l={...r,language:e,value:n},a={id:null,itemName:t};Ue.debug("handleCreateNotebook",i,o,l,a),s.emit(Ae.CREATE_NOTEBOOK,i,o,l,a)}runCommand(t){if(t===void 0){Ue.debug("Ignoring empty command.");return}this.removePreviewStatus();const{glEventHub:e}=this.props;e.emit(gt.SEND_COMMAND,t,!1,!0)}removePreviewStatus(){this.setState(({isPreview:t})=>{if(t){const{fileMetadata:e}=this.state;return e&&this.registerFileMetadata(e,!1),{isPreview:!1}}return null})}getDropdownOverflowActions(){const{defaultNotebookSettings:t}=this.props,{settings:e}=this.state;return this.getOverflowActions(t.isMinimapEnabled,this.getSettings(e,t.isMinimapEnabled).wordWrap==="on")}render(){const{fileStorage:t,glContainer:e,glContainer:{tab:n},glEventHub:s,defaultNotebookSettings:i}=this.props,{changeCount:o,savedChangeCount:r,error:l,isDashboardActive:a,isLoaded:d,isLoading:c,isPreview:u,fileMetadata:m,session:p,sessionLanguage:g,settings:f,showCloseModal:C,showSaveAsModal:S}=this.state,w=a&&!e.isHidden&&!u,v=m?.itemName??yi.DEFAULT_NAME,y=v.endsWith(".md"),E=m?.id!=null,R=this.getSettings(f,i.isMinimapEnabled),F=p!=null,D=g===R.language,N=!d||!F||!D,P=!d,H=[{action:this.handleSave,shortcut:ls.SAVE},{action:this.handleMinimapChange,shortcut:Pt.NOTEBOOK.MINIMAP},{action:this.handleWordWrapChange,shortcut:Pt.NOTEBOOK.WORDWRAP}],A=cc.getDisabledRunTooltip(F,D,"Notebook extension","Run"),q=cc.getDisabledRunTooltip(F,D,"Notebook extension","Run Selected"),B=[{title:E?"Rename":"Save As\u2026",order:10,group:le.groups.high,action:this.handleShowRename},{title:"Copy File",action:this.handleCopy,group:le.groups.high,order:20}],K=n?.element.find(".lm_title_before").get(0);return T(be,{children:[K&&Nr.createPortal(h("span",{className:Y("editor-unsaved-indicator",{"is-unsaved":o!==r})}),K),T($n,{className:"notebook-container",componentPanel:this,glContainer:e,glEventHub:s,onTab:this.handleTab,onResize:this.handleResize,onShow:this.handleShow,onTabFocus:this.handleTabFocus,onTabBlur:this.handleTabBlur,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onFocus:this.handleFocus,onBlur:this.handleBlur,additionalActions:B,renderTabTooltip:()=>v,children:[!y&&T(be,{children:[T("div",{className:"notebook-toolbar",children:[T("span",{children:[h(U,{kind:"ghost",className:"btn-play",onClick:this.handleRunAll,disabled:N,icon:h(Z,{icon:_r,transform:"grow-4"}),tooltip:`Run ${Pt.NOTEBOOK.RUN.getDisplayText()}`,"aria-label":"Run"}),A!=null&&h(ut,{children:A})]}),T("span",{children:[h(U,{kind:"ghost",className:"btn-play",onClick:this.handleRunSelected,disabled:N,icon:h(Z,{icon:nf,transform:"grow-4"}),tooltip:`Run Selected ${Pt.NOTEBOOK.RUN_SELECTED.getDisplayText()}`,"aria-label":"Run Selected"}),q!=null&&h(ut,{children:q})]}),h(U,{kind:"ghost",className:"mr-auto",disabled:P,onClick:this.handleSave,icon:Mh,tooltip:`Save ${ls.SAVE.getDisplayText()}`,"aria-label":"Save"}),h(U,{kind:"ghost",className:"btn-overflow btn-link-icon",disabled:P,icon:Th,tooltip:"More Actions...",onClick:()=>{},children:h(ns,{actions:this.getDropdownOverflowActions,popperOptions:yi.POPPER_OPTIONS})})]}),h(jh,{isLoaded:d,isLoading:c,error:l,onChange:this.handleEditorChange,onRunCommand:this.handleRunCommand,session:p,sessionLanguage:g,onEditorInitialized:this.handleEditorInitialized,onEditorWillDestroy:this.handleEditorWillDestroy,settings:R,focusOnMount:w,ref:x=>{this.notebook=x}})]}),y&&h(Wm,{content:R.value??"",onLinkClick:this.handleLinkClick,onRunCode:this.handleRunCommand,transformImageUri:this.handleTransformLinkUri,transformLinkUri:this.handleTransformLinkUri}),h(Nl,{isOpen:S,type:"file",defaultValue:v,title:E?"Rename":"Save file as",onSubmit:this.handleSaveAsSubmit,onCancel:this.handleSaveAsCancel,notifyOnExtensionChange:!0,storage:t}),h(xr,{isOpen:C,headerText:`Do you want to save the changes you made to ${v}?`,bodyText:"Your changes will be lost if you don't save them.",onCancel:this.handleCloseCancel,onDiscard:this.handleCloseDiscard,onConfirm:this.handleCloseSave,discardButtonText:"Discard Changes",confirmButtonText:"Save"}),h(le,{actions:H})]})]})}};let Uo=yi;Uo.COMPONENT="NotebookPanel";Uo.POPPER_OPTIONS={placement:"bottom-end"};Uo.DEFAULT_NAME="Untitled";Uo.defaultProps={isDashboardActive:!0,isPreview:!1,session:null,sessionLanguage:null,defaultNotebookSettings:null};const ny=(t,e)=>{const n=au(t),s=Et(t),i=tS(t),o=ai(t,e.localDashboardId),{session:r,config:l}=o??{},{type:a}=l??{};return{fileStorage:n,settings:s,defaultNotebookSettings:i,session:r,sessionLanguage:a}},qs=vt(ny,{saveSettings:gl},null,{forwardRef:!0})(Uo);class Eo extends b.exports.Component{constructor(e){super(e),this.irisGridRef=de.createRef(),this.buttonRef=de.createRef(),this.handleReload=this.handleReload.bind(this),this.handleGridStateChange=this.handleGridStateChange.bind(this),this.handlePanelStateUpdate=this.handlePanelStateUpdate.bind(this);const{panelState:n}=e;this.state={shouldFocusGrid:!1,panelState:n}}handleReload(){this.irisGridRef.current?.initModel(),this.buttonRef.current?.blur(),this.setState({shouldFocusGrid:!0})}handleGridStateChange(){const{shouldFocusGrid:e}=this.state;e&&this.irisGridRef.current?.irisGrid?.current?.grid&&(this.irisGridRef.current.irisGrid.current.grid.focus(),this.setState({shouldFocusGrid:!1}))}handlePanelStateUpdate(e){this.setState({panelState:e})}render(){const{...e}=this.props;return h(oi,{ref:this.irisGridRef,onStateChange:this.handleGridStateChange,onPanelStateUpdate:this.handlePanelStateUpdate,...e,children:T(U,{ref:this.buttonRef,kind:"primary",className:"btn-pandas",onClick:this.handleReload,tooltip:"Click to refresh pandas dataframe, updates do not occur automatically.",children:["pandas dataframe",T("span",{children:[h(Z,{icon:Ua,transform:"shrink-1",className:"mr-1"}),"Reload"]})]})})}}Eo.defaultProps={panelState:null};Eo.COMPONENT="PandasPanel";function sy(t){Ps(t);const{id:e,layout:n,registerComponent:s,hydrate: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.FIGURE)return;const m={name:c,figure:c},p=()=>l().then(C=>Oi.makeModel(void 0,C)),g={type:"react-component",component:_i.COMPONENT,props:{localDashboardId:e,id:a,metadata:m,makeModel:p},title:c,id:a},{root:f}=n;ie.openComponent({root:f,config:g,dragEvent:r})},[e,n]);return b.exports.useEffect(function(){const l=[s(_i.COMPONENT,_i,i)];return()=>{l.forEach(a=>a())}},[i,s]),Be(n.eventHub,Ee.OPEN,o),null}function iy(t){Ps(t);const{id:e,layout:n}=t,s=b.exports.useCallback(({metadata:i,panelId:o=$e.generate(),table:r})=>{const{settings:l}=i,a=()=>Oi.makeModelFromSettings(l,r),d=_e.titleFromSettings(l),c={type:"react-component",component:_i.COMPONENT,props:{localDashboardId:e,id:o,metadata:i,makeModel:a},title:d,id:o},{root:u}=n;ie.openComponent({root:u,config:c})},[e,n]);return Be(n.eventHub,wt.CREATE_CHART,s),null}const ht=J.module("ConsolePlugin");function jc(t){return t.notebook!==void 0}function oy(t){Ps(t)}function ry(t){oy(t);const{id:e,hydrateConsole:n,layout:s,panelManager:i,registerComponent:o,notebooksUrl:r}=t,l=b.exports.useRef(0),[a,d]=b.exports.useState(new Map),[c,u]=b.exports.useState(new Map),m=Oa(),p=b.exports.useCallback(()=>i.getLastUsedPanelOfType(Ii),[i]),g=b.exports.useCallback((V,W)=>{d(X=>new Map(X.set(V,W)))},[d]),f=b.exports.useCallback(V=>{d(W=>(W.delete(V),new Map(W)))},[d]),C=b.exports.useCallback((V,W)=>{u(X=>new Map(X.set(V,W)))},[u]),S=b.exports.useCallback(V=>{u(W=>(W.delete(V),new Map(W)))},[u]),w=b.exports.useCallback((V,W=!0,X=!0)=>{if(!(V&&V.trim()))ht.info("Ignoring empty code");else{const ce=p();if(!ce||!(ce instanceof Ii.WrappedComponent)){ht.error("Console panel not found");return}ht.debug("Send command: ",V,W,X),ce.addCommand(V,W,X)}},[p]),v=b.exports.useCallback(V=>{m(bE(e,V))},[m,e]),y=b.exports.useCallback(({language:V})=>{const W=V==="python"?"py":V;let X=null;return W==null?(ht.debug("No extension for language",V),X=`Untitled-${l.current}`):X=`Untitled-${l.current}.${W}`,l.current+=1,X},[]),E=b.exports.useCallback((V,W=!0)=>{const{id:X}=V;return X!=null&&a.has(X)?a.get(X):X!=null&&c.has(X)?c.get(X):W?$e.generate():null},[a,c]),R=b.exports.useCallback((V,W)=>{ie.renameComponent(s.root,{id:V},W)},[s.root]),F=b.exports.useCallback((V,W)=>{ht.debug("Rename file panel",V,W);let X;if(a.has(V)&&(X=a.get(V),f(V),X!=null&&g(W,X)),c.has(V)&&(X=c.get(V),S(V),X!=null&&C(W,X)),X===void 0){ht.debug2(`File ${V} isn't open, no need to rename the tab`);return}R(X,me.getBaseName(W))},[a,c,R,g,C,f,S]),D=b.exports.useCallback(V=>{const W=E(V,!1);if(W==null){ht.error("Could not find panel id for file metadata",V);return}ie.activateTab(s.root,{id:W})},[E,s.root]),N=b.exports.useCallback((V,W,X)=>{if(ht.debug("registerFilePanel",V,W,X),W==null||W.id==null){ht.debug("Ignore empty file id",W);return}const{id:se}=W;if(X){C(se,V);return}if(a.has(se)){const ce=a.get(se);if(V===ce){ht.debug(`Update tab title for file ${se}`);const{itemName:Q}=W;F(se,Q)}else ht.error(`File ${se} already associated with a different tab ${ce}`);return}g(se,V),c.has(se)&&S(se)},[a,c,F,g,C,S]),P=b.exports.useCallback((V,W)=>{if(ht.debug("unregisterFileTab",V,W),V==null||V.id==null){ht.debug("Ignore empty file id",V);return}const{id:X}=V;if(W){S(X);return}f(X)},[f,S]),H=b.exports.useCallback((V,W)=>{ht.debug("closeFilePanel",V);const{id:X}=V;let se=null,ce=!1;if(a.has(X))se=a.get(X);else if(c.has(X))se=c.get(X),ce=!0;else{ht.debug(`File ${X} isn't open, ignore close event`);return}P(V,ce),ie.closeComponent(s.root,{id:se},W)},[s.root,a,c,P]),A=b.exports.useCallback(V=>{const{itemName:W}=V;return me.getBaseName(W)},[]),q=b.exports.useCallback(V=>{const{id:W}=V;return ht.debug("fileIsOpen",V,W,a),W!=null&&a.has(W)},[a]),B=b.exports.useCallback(V=>{const{id:W}=V;return ht.debug("fileIsOpenAsPreview",V,W,c),W!=null&&c.has(W)},[c]),K=b.exports.useCallback(V=>{if(V==null)return;const W=i.getOpenedPanelById(V);W&&jc(W)&&W.focus()},[i]),x=b.exports.useCallback(({id:V,settings:W,fileMetadata:X,session:se,sessionLanguage:ce,isPreview:Q=!1})=>{const he={settings:W,fileMetadata:X},Se=A(X);return{type:"react-component",component:qs.COMPONENT,isFocusOnShow:!1,props:{localDashboardId:e,metadata:{id:V},session:se,sessionLanguage:ce,panelState:he,isPreview:Q,notebooksUrl:r},title:Se,id:V}},[A,e,r]),O=b.exports.useCallback((V,W,X,se={id:null,itemName:y(X)})=>{const ce=E(se);if(q(se)&&ce!=null){ht.debug("File is already open, focus panel"),D(se),K(ce);return}const Q=ie.getStackForComponentTypes(s.root,[qs.COMPONENT]),he=x({id:ce,settings:X,fileMetadata:se,session:V,sessionLanguage:W});ht.debug("createNotebook",he,a),ie.openComponentInStack(Q,he)},[q,K,y,E,s.root,x,a,D]),G=b.exports.useCallback((V,W,X,se,ce=!1)=>{ht.debug("selectNotebook",se,ce);const Q=q(se),he=B(se);if(Q){if(D(se),ce){const je=E(se);K(je)}return}if(he&&!ce){D(se);return}const[Se]=Array.from(c.values());let Re=null,et=null;Se!=null&&(Re=Se,et=ie.getStackForConfig(s.root,{component:qs.COMPONENT,id:Re})),et==null&&(Re=E(se),et=ie.getStackForComponentTypes(s.root,[qs.COMPONENT]));const yt=x({id:Re,settings:X,fileMetadata:se,session:V,sessionLanguage:W,isPreview:!ce});ie.openComponentInStack(et,yt),ce&&K(Re)},[D,q,B,K,E,s.root,x,c]),ee=b.exports.useCallback((V,W,X={},se=!0)=>{const ce=i.getLastUsedPanelOfType(qs);ce&&jc(ce)?X!=null&&X.value!=null&&ce.notebook!=null&&ce.notebook.append(X.value):se&&O(V,W,X)},[O,i]),ne=b.exports.useCallback((V,W)=>wa.hydrate({...V,notebooksUrl:r},W),[r]);return b.exports.useEffect(function(){const W=[o(Ii.COMPONENT,Ii,n),o(zr.COMPONENT,zr),o(qr.COMPONENT,qr),o(Kr.COMPONENT,Kr),o(qs.COMPONENT,qs,ne)];return()=>{W.forEach(X=>X())}},[o,n,ne]),Be(s.eventHub,gt.SEND_COMMAND,w),Be(s.eventHub,gt.SETTINGS_CHANGED,v),Be(s.eventHub,Ae.CLOSE_FILE,H),Be(s.eventHub,Ae.CREATE_NOTEBOOK,O),Be(s.eventHub,Ae.SELECT_NOTEBOOK,G),Be(s.eventHub,Ae.RENAME,R),Be(s.eventHub,Ae.RENAME_FILE,F),Be(s.eventHub,Ae.SEND_TO_NOTEBOOK,ee),Be(s.eventHub,Ae.REGISTER_FILE,N),Be(s.eventHub,Ae.UNREGISTER_FILE,P),null}const ho=J.module("FilterPlugin");function Qc(t,e){return t.concat(e)}function ly(t){Ps(t);const{id:e,layout:n,registerComponent:s}=t,i=Oa(),[o]=b.exports.useState(()=>new Map),[r]=b.exports.useState(()=>new Map),[l]=b.exports.useState(()=>new Map),a=b.exports.useCallback(()=>{const C=Array.from(o.values()).reduce(Qc,[]).sort((v,y)=>{const E=jt.toLower(v.name),R=jt.toLower(y.name);if(E!==R)return E>R?1:-1;const F=jt.toLower(v.type),D=jt.toLower(y.type);return F!==D?F>D?1:-1:0}).reduce((v,y)=>((v.length===0||jt.toLower(v[v.length-1].name)!==jt.toLower(y.name)||jt.toLower(v[v.length-1].type)!==jt.toLower(y.type))&&v.push(y),v),[]),S=Array.from(r.values()).reduce(Qc,[]).sort((v,y)=>v.timestamp-y.timestamp),w=new Map(l);ho.debug("sendUpdate",{columns:C,filters:S,tableMap:w}),i(Vn(e,{columns:C,filters:S,tableMap:w}))},[i,e,o,r,l]),d=b.exports.useCallback((C,S)=>{ho.debug2("handleColumnsChanged",C,S),o.set(C,[].concat(S)),a()},[o,a]),c=b.exports.useCallback((C,S)=>{ho.debug2("handleFiltersChanged",C,S),r.set(C,[].concat(S)),a()},[r,a]),u=b.exports.useCallback((C,S)=>{ho.debug2("handleTableChanged",C,S),l.set(ie.getIdFromPanel(C),S),a()},[l,a]),m=b.exports.useCallback(C=>{ho.debug2("handlePanelUnmount",C),o.delete(C),r.delete(C),l.delete(ie.getIdFromPanel(C)),a()},[o,r,l,a]),p=b.exports.useCallback(({title:C="DropdownFilter",metadata:S={},panelState:w=null,id:v=$e.generate(),focusElement:y=ie.DEFAULT_FOCUS_SELECTOR,createNewStack:E=!1,dragEvent:R=null})=>{const F={type:"react-component",component:ii.COMPONENT,props:{id:v,metadata:S,panelState:w,localDashboardId:e},title:C,id:v},{root:D}=n;ie.openComponent({root:D,config:F,focusElement:y,createNewStack:E,dragEvent:R})},[n,e]),g=b.exports.useCallback(({title:C="InputFilter",metadata:S={},panelState:w=null,id:v=$e.generate(),focusElement:y=ie.DEFAULT_FOCUS_SELECTOR,createNewStack:E=!1,dragEvent:R=null})=>{const F={type:"react-component",component:vo.COMPONENT,props:{id:v,metadata:S,panelState:w,localDashboardId:e},title:C,id:v},{root:D}=n;ie.openComponent({root:D,config:F,focusElement:y,createNewStack:E,dragEvent:R})},[n,e]),f=b.exports.useCallback(({title:C="FilterSets",metadata:S={},panelState:w=null,id:v=$e.generate(),focusElement:y=ie.DEFAULT_FOCUS_SELECTOR,createNewStack:E=!1,dragEvent:R=null})=>{const F={type:"react-component",component:na.COMPONENT,props:{id:v,metadata:S,panelState:w,localDashboardId:e},title:C,id:v},{root:D}=n;ie.openComponent({root:D,config:F,focusElement:y,createNewStack:E,dragEvent:R})},[n,e]);return b.exports.useEffect(function(){const S=[s(ii.COMPONENT,ii),s(vo.COMPONENT,vo),s(na.COMPONENT,na)];return()=>{S.forEach(w=>w())}},[s]),Be(n.eventHub,Le.COLUMNS_CHANGED,d),Be(n.eventHub,Le.FILTERS_CHANGED,c),Be(n.eventHub,Le.TABLE_CHANGED,u),Be(n.eventHub,Le.OPEN_DROPDOWN,p),Be(n.eventHub,Le.OPEN_INPUT,g),Be(n.eventHub,Le.OPEN_FILTER_SET_MANAGER,f),Be(n.eventHub,Ee.UNMOUNT,m),null}const ay=[dh.VariableType.TABLE,dh.VariableType.TREETABLE,dh.VariableType.HIERARCHICALTABLE];function dy(t){Ps(t);const{getDownloadWorker:e,loadPlugin:n,id:s,layout:i,registerComponent:o,hydrate:r,theme:l}=t,a=b.exports.useCallback(({dragEvent:d,fetch:c,panelId:u=$e.generate(),widget:m})=>{const{name:p,type:g}=m;if(!ay.includes(g))return;const f={name:p,table:p,type:m.type},C=()=>c().then(v=>Cd.makeModel(v)),S={type:"react-component",component:oi.COMPONENT,props:{getDownloadWorker:e,loadPlugin:n,localDashboardId:s,id:u,metadata:f,makeModel:C,theme:l},title:p,id:u},{root:w}=i;ie.openComponent({root:w,config:S,dragEvent:d})},[e,s,i,n,l]);return b.exports.useEffect(function(){const c=[o(oi.COMPONENT,oi,r)];return()=>{c.forEach(u=>u())}},[r,o]),Be(i.eventHub,Ee.OPEN,a),null}function zm(t){return typeof t.getCoordinateForColumn=="function"}function Zc(t){const e=t;return zm(t)&&typeof e.setFilterMap=="function"&&typeof e.unsetFilterValue=="function"}function Jc(t){return t.description===void 0||!t.description?.startsWith("Preview of type: ")}const uo=J.module("LinkerUtils"),qm=class{static getLinkType(t,e,n){if(t?.panelId==null||e?.panelId==null||t.panelId===e.panelId||n!=null&&n!==t.panelId&&n!==e.panelId)return uo.debug2("Incompatible panel ids",t,e,n),"invalid";if(t.panelComponent==null||e.panelComponent==null)return uo.error("PanelComponent should not be null",t,e),"invalid";const s=qm.ALLOWED_LINKS.get(t.panelComponent)?.includes(e.panelComponent);if(s===void 0||!s)return uo.debug2("Incompatible panel components",t,e),"invalid";const{columnType:i}=t,{columnType:o}=e;if(!(o===null||_.isCompatibleType(i,o)))return uo.debug2("Incompatible type",i,o),"invalid";switch(e.panelComponent){case ie.getComponentName(_i):case ie.getComponentName(oi):return"tableLink";case ie.getComponentName(ii):return"filterSource"}return uo.debug2("Incompatible target panel component",e.panelComponent),"invalid"}static findColumn(t,{columnName:e,columnType:n}){return t.find(({name:s,type:i})=>s===e&&i===n)}static cloneLinksForPanel(t,e,n){const s=[];return t.forEach(i=>{i.start.panelId===e&&i.type!=="filterSource"?s.push({...i,id:$e.generate(),start:{...i.start,panelId:n}}):i.end?.panelId===e&&s.push({...i,id:$e.generate(),end:{...i.end,panelId:n}})}),s}};let Js=qm;Js.ALLOWED_LINKS=new Map([[ie.getComponentName(oi),[ie.getComponentName(oi),ie.getComponentName(_i),ie.getComponentName(ii)]]]);const cy=J.module("LinkerLink"),eh=.015,th=1.5,Ym=12,Km=12,nh=2,Sr=Math.sqrt((Km*.5)**2+Ym**2),sh=Math.asin(Km*.5/Ym),ih=15,ys=Math.PI*.5,Fr=class extends b.exports.Component{constructor(t){super(t),this.getOperators=ge((e,n)=>{const{onOperatorChanged:s}=this.props;let i=_.getFilterTypes(n);return _.isBooleanType(n)&&(i=[$.eq,$.notEq]),i.flatMap((o,r)=>{if(o==="eqIgnoreCase"||o==="notEqIgnoreCase")return[];let l="";return o==="startsWith"?l="a*":o==="endsWith"?l="*z":l=_.getFilterOperatorString(o),[{title:Fr.getLabelForLinkFilter(n,o),icon:h("b",{children:l}),action:()=>s(e,o),order:r}]})}),this.handleClick=this.handleClick.bind(this),this.handleMouseEnter=this.handleMouseEnter.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleDelete=this.handleDelete.bind(this),this.getDropdownActions=this.getDropdownActions.bind(this),this.state={isHovering:void 0}}static makeCirclePath(t,e,n){return`M ${t} ${e} m -${n},0 a ${n},${n} 0 1,0 ${n*2},0 a ${n},${n} 0 1,0 -${n*2},0 z`}static getLabelForLinkFilter(t,e){try{if(_.isNumberType(t)||_.isCharType(t))return tu(e);if(_.isTextType(t))return eu(e);if(_.isDateType(t))return nu(e);if(_.isBooleanType(t)){if(e===$.eq)return"is equal to";if(e===$.notEq)return"is not equal to"}throw new Error(`Unrecognized column type: ${t}`)}catch(n){return cy.warn(n),""}}handleClick(t){t.stopPropagation(),t.preventDefault();const{id:e,onClick:n,onDelete:s}=this.props;t.altKey?s(e):n(e)}handleMouseEnter(){this.setState({isHovering:!0})}handleMouseLeave(){this.setState({isHovering:!1})}handleDelete(){const{id:t,onDelete:e}=this.props;e(t)}getDropdownActions(){const{id:t,startColumnType:e}=this.props;return e!=null?this.getOperators(t,e):[]}render(){const{className:t,operator:e,isSelected:n,x1:s,y1:i,x2:o,y2:r,id:l,startColumnType:a}=this.props,{isHovering:d}=this.state,c=Math.sqrt((s-o)**2+(i-r)**2),u=Math.atan2(r-i,o-s),m=Math.sin(u),p=Math.cos(u)+2,g=window.innerWidth,f=window.innerHeight,C=0,S=0,w=Math.max(C,Math.min(s+(o-s)/2+m*(c*eh)**th,g)),v=Math.max(S,Math.min(i+(r-i)/2+p*(c*eh)**th,f)),y=`M ${s} ${i} Q ${w} ${v} ${o} ${r}`,E=`M ${C} ${S} L ${C} ${f} L ${g} ${f} L ${g} ${S} z
34
34
  ${Fr.makeCirclePath(s,i,ih)}
35
35
  ${Fr.makeCirclePath(o,r,ih)}`,R=`link-select-clip-${l}`,F=Math.atan2(r-v,o-w),D=F-sh+Math.PI,N=F+sh+Math.PI,P=o+Math.cos(F)*nh,H=r+Math.sin(F)*nh,A=P+Math.cos(D)*Sr,q=H+Math.sin(D)*Sr,B=P+Math.cos(N)*Sr,K=H+Math.sin(N)*Sr,x=`${P},${H} ${A},${q} ${B},${K}`,O=.25*s+.5*w+.25*o,G=.25*i+.5*v+.25*r,ee=w-s+(o-w),V=(v-i+(r-v))/ee;let X=20/Math.sqrt(1+V**2),se=X*V,ce=X*-1,Q=se*-1;Number.isFinite(V)?V>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)):V<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=_.getFilterOperatorString(e)),T(be,{children:[T("svg",{className:Y(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&&T(be,{children:[h(U,{kind:"primary",className:"btn-fab btn-operator",style:{top:G+(V>=0?se:Q),left:O+(V>=0?X:ce)},onClick:()=>{},icon:T("div",{className:"fa-md fa-layers",children:[h("b",{children:he}),h(Z,{icon:ts,transform:"right-8 down-9 shrink-5"})]}),tooltip:"Change comparison operator",children:h(ns,{actions:this.getDropdownActions,popperOptions:{placement:"bottom-start"}})}),h(U,{kind:"primary",className:"btn-fab btn-delete",style:{top:G+(V<0?se:Q),left:O+(V<0?X:ce)},onClick:this.handleDelete,icon:sn,tooltip:"Delete"})]})]})}};let Xm=Fr;Xm.defaultProps={className:"",isSelected:!1,onClick(){},onDelete(){}};const sa=J.module("LinkerOverlayContent");class jm 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(!zm(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=Ze(e.x,0,window.innerWidth-n.width),i=Ze(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=Ze(window.innerWidth-(e.clientX+i.width+n.x),0,window.innerWidth-i.width),r=Ze(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:v,operator:y}=g,E=w.columnType;let[R,F]=this.getPointFromLinkPoint(w),D=d?.x??R,N=d?.y??F;if(v!=null&&([D,N]=this.getPointFromLinkPoint(v)),S!=null&&S){const[H,A]=[R,F];[R,F]=[D,N],[D,N]=[H,A]}const P=Y("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:N,id:f,className:P,operator:y,startColumnType:E}}catch(f){return sa.warn("Unable to get point for link",g,f),null}}).filter(g=>g!=null);return T("div",{className:Y("linker-overlay",{"danger-delete":m==="delete"}),children:[p.map(({x1:g,y1:f,x2:C,y2:S,id:w,className:v,operator:y,startColumnType:E})=>h(Xm,{className:v,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)),T("div",{className:Y("linker-toast-dialog",{dragging:u}),ref:this.dialogRef,style:{bottom:c?.y,right:c?.x},children:[h(U,{draggable:!0,kind:"inline",className:"btn-drag-handle",icon:el,onClick:()=>{},onMouseDown:this.handleMouseDown,children:!u&&h(ut,{children:"Drag to reposition"})}),h("div",{className:"toast-body",children:i}),T("div",{className:"toast-footer",children:[h(U,{kind:"secondary",onClick:l,children:"Clear All"}),h(U,{kind:"primary",onClick:a,children:"Done"})]})]}),h(le,{actions:[{action:this.handleEscapePressed,shortcut:ls.LINKER_CLOSE,isGlobal:!0}]})]})}}jm.defaultProps={disabled:"false"};const Dt=J.module("Linker"),hy=(t,e)=>({activeTool:pl(t),isolatedLinkerPanelId:Td(t,e.localDashboardId),links:Ki(t,e.localDashboardId),timeZone:ko(t)}),uy=vt(hy,{setActiveTool:fl,setDashboardLinks:Ed,addDashboardLinks:fE,deleteDashboardLinks:CE,setDashboardIsolatedLinkerPanelId:Lm,setDashboardColumnSelectionValidator:SE});class my 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&&Js.findColumn(n,r)==null||l!=null&&l.panelId===i&&Js.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=Js.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,v=u.filter(({end:y})=>y?.panelId===w);this.deleteLinks(v);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?Zc(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?Zc(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:v}=n[a.columnName],y=`${v}`;v===null&&S&&w&&(v=void 0),p!=null&&_.isDateType(p)&&(y=new st({timeZone:o,showTimeZone:!1,showTSeparator:!0,defaultDateTimeFormatString:Hn.FULL_DATE_FORMAT}).format(v));const E={operator:c,text:y,value:v,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=Js.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?Js.getLinkType(a,r,i):Js.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(jm,{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 py=uy(my);function gy(t){Ps(t);const{id:e,layout:n,panelManager:s}=t;return h(py,{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 yo=Na;yo.DEFAULT_TITLE="Note";yo.DEFAULT_CONTENT=`# Markdown Note
36
36
 
37
- This note can be edited using **markdown** for styling.`;function fy(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===yo.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(co.COMPONENT),g=s.getClosedPanelConfigsOfType(co.COMPONENT),f=p.map(y=>y.title??""),C=l!=null&&l!==""?l:yo.getNewMarkdownTitle(f),S=g.length>0?null:yo.DEFAULT_CONTENT,w={type:"react-component",component:co.COMPONENT,props:{id:d,metadata:a,panelState:{content:S},localDashboardId:e},title:C,id:d},{root:v}=n;ie.openComponent({root:v,config:w,focusElement:c,createNewStack:u,dragEvent:m})},[e,n,s]);return b.exports.useEffect(function(){const a=[i(co.COMPONENT,co,sd,o)];return()=>{a.forEach(d=>d())}},[o,i]),Be(n.eventHub,km.OPEN,r),null}function Cy(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:Eo.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(Eo.COMPONENT,Eo,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 Sy=M.exports.shape({state:M.exports.shape({panelState:M.exports.shape({})})}),by=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}),wy=M.exports.arrayOf(Qm),Ty=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:by,Link:Qm,Links:wy,Panel:Sy,User:Ty});const vy=(t,e)=>t[e]===null?null:M.exports.bool,Ey=(t,e)=>t[e]===null?null:M.exports.string;Object.freeze({nullableBoolean:vy,nullableString:Ey});J.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=J.module("PouchStorageTable"),yy="Deephaven.";Ch.plugin(Gp);function Ry(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 Iy(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]:Ry(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=>Iy(e)),{name:{$gt:null}},{id:{$gt:null}}]}}function Fy(t,e=!1){return[{id:e?"desc":"asc"},...t?.map(n=>({[n.column]:n.direction}))??[]]}class Dy{constructor(e){this.listeners=[],this.itemListeners=new Map,this.currentSize=0,this.currentReverse=!1,this.currentFilter=null,this.currentSort=null,this.db=new Ch(`${yy}${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=Fy(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 Dy{constructor(e){super(`CommandHistoryStorage.${e}`)}setSearch(e){this.setFilters(e?[rh.makeFilterConfig([rh.makeFilterItem("name",$.contains,e)])]:[])}}const ah=J.module("PouchCommandHistoryStorage");class Ny{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 Zm="SET_LAYOUT_STORAGE",_y=t=>({type:Zm,payload:t}),Jm="/ide/assets/community-wordmark-app.d2c5c1eb.svg";const My=J.module("FormattingSectionContent");function ky(t){return t.formatString!=null}function _a(t){const e=t?.querySelector("input, select, textarea");e&&e.focus()}function ep(t,e){return t.defaultFormatString===e.defaultFormatString}function xy(t,e){return ep(t,e)}function Oy(t,e){return ep(t,e)}function tp(t){return t!==""&&Vi.isValidColumnName(t)}function Ms(t,e){if(!t||e.formatString==null||!ky(e))return!1;switch(t){case"datetime":return st.isValid(e);case"decimal":return ke.isValid(e);case"int":return Qe.isValid(e);default:return My.warn("Trying to validate format of unknown type"),!0}}function np(t){const{id:e,isNewRule:n,...s}=t;return s}function sp(t){return tp(t.columnName)&&Ms(t.columnType,t.format)}function ip(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(be,{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,_.dataType.DATETIME,"",c)},d)})})}function Ay(){return h(be,{children:Qr.TIME_ZONES.map(t=>{const{label:e,value:n}=t;return h("option",{value:n,children:e},n)})})}const Ys=J.module("FormattingSectionContent"),op=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(ip,{timestamp:f,timeZone:c,showTimeZone:u,showTSeparator:m,isGlobalOptions:p,legacyGlobalFormat:g})}),this.debouncedCommitChanges=Je(this.commitChanges.bind(this),op.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){Ys.debug("handleDefaultDateTimeFormatChange",t.target.value),this.setState({defaultDateTimeFormat:t.target.value},()=>{this.debouncedCommitChanges()})}handleDefaultDecimalFormatChange(t){Ys.debug("handleDefaultDecimalFormatChange",t.target.value),this.setState({defaultDecimalFormatOptions:{defaultFormatString:t.target.value}},()=>{this.debouncedCommitChanges()})}handleDefaultIntegerFormatChange(t){Ys.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;Ys.debug("handleResetDateTimeFormat"),this.setState({defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s},()=>{this.debouncedCommitChanges()})}handleResetTimeZone(){const{defaults:t}=this.props,{timeZone:e}=t;Ys.debug("handleResetTimeZone"),this.setState({timeZone:e},()=>{this.debouncedCommitChanges()})}handleResetDecimalFormat(){const{defaults:t}=this.props,{defaultDecimalFormatOptions:e}=t;Ys.debug("handleResetDecimalFormat"),this.setState({defaultDecimalFormatOptions:e},()=>{this.debouncedCommitChanges()})}handleResetIntegerFormat(){const{defaults:t}=this.props,{defaultIntegerFormatOptions:e}=t;Ys.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(sp).map(np)??[],{settings:d,saveSettings:c}=this.props,u={...d,formatter:a,defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s,timeZone:i,truncateNumbersWithPound:l};Ms(_.dataType.DECIMAL,ke.makeCustomFormat(o.defaultFormatString))&&(u.defaultDecimalFormatOptions=o),Ms(_.dataType.INT,Qe.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=Qe.DEFAULT_FORMAT_STRING}=s??{},c=i===t.timeZone,u=r===t.showTSeparator&&o===t.showTimeZone&&e===t.defaultDateTimeFormat,m=xy(n,t.defaultDecimalFormatOptions),p=Oy(s,t.defaultIntegerFormatOptions);return h("div",{className:"app-settings-formatting-section",ref:this.containerRef,children:T("div",{className:"container-fluid p-0",children:[h("div",{children:"Default formatting for column types"}),h("div",{className:"app-settings-menu-description mb-3",children:"Applies a formatting rule to all columns of a set type."}),T("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(Ay,{})})}),h("div",{className:"col-1 btn-col",children:h(U,{kind:"ghost",icon:ei,onClick:this.handleResetTimeZone,tooltip:"Reset Time Zone",className:Y("btn-reset","btn-reset-time-zone",{hidden:c})})})]}),T("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(U,{kind:"ghost",icon:ei,onClick:this.handleResetDateTimeFormat,tooltip:"Reset DateTime Options",className:Y("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"})})}),T("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:Y("form-control","flex-grow-1","default-decimal-format-input",{"is-invalid":!Ms(_.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(U,{kind:"ghost",icon:ei,onClick:this.handleResetDecimalFormat,tooltip:"Reset Decimal Formatting",className:Y("btn-reset","btn-reset-decimal",{hidden:m}),"data-testid":"btn-reset-decimal"})})]}),T("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:Y("form-control","flex-grow-1","default-integer-format-input",{"is-invalid":!Ms(_.dataType.INT,Qe.makeCustomFormat(d))}),"data-lpignore":!0,placeholder:Qe.DEFAULT_FORMAT_STRING,type:"text",id:"default-integer-format-input",value:d,onChange:this.handleDefaultIntegerFormatChange})}),h("div",{className:"col-1 btn-col",children:h(U,{kind:"ghost",icon:ei,onClick:this.handleResetIntegerFormat,tooltip:"Reset Integer Formatting",className:Y("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=op;Od.defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:st.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:ke.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:Qe.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:st.DEFAULT_TIME_ZONE_ID}};Od.inputDebounceTime=250;const Ly=t=>({formatter:uu(t),defaultDateTimeFormat:du(t),defaultDecimalFormatOptions:cu(t),defaultIntegerFormatOptions:hu(t),showTimeZone:mu(t),showTSeparator:pu(t),truncateNumbersWithPound:gu(t),timeZone:ko(t),settings:Et(t)}),Py=vt(Ly,{saveSettings:gl})(Od);function Hy(){const[t,e]=b.exports.useState(!1),n=()=>{e(!t)};return T(U,{kind:"ghost",onClick:n,icon:sf,children:["Legal Notices",T(nl,{isOpen:t,toggle:n,className:"theme-bg-light",children:[h(sl,{toggle:n,children:"Legal Notice"}),T(il,{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."}),T("p",{children:["\xA9 2016-",new Date().getFullYear()," Deephaven Data Labs LLC. Patent Pending."]})]})]})]})}function Ro(t){const{children:e,isExpanded:n,sectionKey:s,title:i,onToggle:o}=t;return T(be,{children:[h("div",{children:T(U,{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(Z,{transform:n?"flip-v":"",icon:ts})})]})}),h(of,{in:n,autoFocusOnShow:!0,children:e})]})}Ro.propTypes={children:M.exports.node,isExpanded:M.exports.bool.isRequired,sectionKey:M.exports.string.isRequired,title:M.exports.node.isRequired,onToggle:M.exports.func};Ro.defaultProps={children:null,onToggle:()=>{}};function Uy({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(v){if(v.stopPropagation(),v.preventDefault(),t.isEditable&&!v.repeat){const y=fn.getKeyStateFromEvent(v),E=fn.createKeyState([Fe.BACKSPACE]);fn.doKeyStatesMatch(y,E)?l(fn.NULL_KEY_STATE):l(y)}}function p(v){v.stopPropagation(),v.preventDefault(),t.matchesKeyState(r)||d(!0)}function g(){Pn.disableAllActions()}function f(){Pn.enableAllActions()}function C(){t.setKeyState(r),d(!1),s(t)}function S(){const v=t.getKeyState();l(v),d(!1)}function w(){d(!0),l(t.getDefaultKeyState())}return T(be,{children:[T("div",{className:"shortcut-item-container",children:[T("label",{className:"shortcut-item-name",children:[t.name,t.tooltip!==void 0&&h(ut,{children:t.tooltip})]}),T("div",{className:"shortcut-item-input-container",children:[h("input",{className:Y("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(U,{className:"reset-to-default-button",kind:"ghost",icon:h(Z,{icon:ei,transform:{rotate:90,flipX:!0}}),tooltip:"Reset to default",onClick:w})]})]}),a&&T("div",{className:Y("shortcut-item-message-container",{"is-invalid":c}),children:[h("div",{className:"shortcut-item-message",children:c}),T("div",{className:"shortcut-item-message-buttons",children:[fn.isValidKeyState(r)&&h(U,{kind:"ghost",onClick:C,children:"Confirm"}),h(U,{kind:"ghost",onClick:S,children:"Undo"})]})]})]})}function Vy({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),T(be,{children:[h("div",{className:"app-settings-menu-description",children:"Customize shortcuts below. Assigning shortcuts that conflict with the browser or IDE shortcuts may cause unintended behavior"}),i.map(l=>h(By,{name:l.name,shortcuts:l.shortcuts,saveShortcutOverrides:s},l.name))]})}function By({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 T("div",{className:"mt-3",children:[h("div",{className:"font-weight-bold",children:s(t)}),i.map((a,d)=>h(Uy,{shortcut:a,displayText:l[d],categoryName:t,onChange:r},a.id))]})}const $y=t=>({settings:Et(t),shortcutOverrides:eS(t)}),Gy={saveSettings:gl},Wy=vt($y,Gy)(Vy),zy="yyyy-MM-dd-HHmmss";function rp(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]=rp(o,a,n)}}}),s}function qy(){const t=Cl.getState();return JSON.stringify(rp(t),null,2)}function Yy(t){const e={uiVersion:"0.30.0",userAgent:navigator.userAgent,...t};return JSON.stringify(e,null,2)}async function Ky(t=`${I.i18n.DateTimeFormat.format(zy,new Date)}_support_logs`,e){const n=new Sh,s=n.folder(t);s.file("console.txt",rf.getFormattedHistory()),s.file("redux.json",qy()),s.file("metadata.json",Yy(e));const i=await n.generateAsync({type:"blob"}),o=document.createElement("a");o.href=URL.createObjectURL(i),o.download=`${t}.zip`,o.click()}const Xy=[{value:_.dataType.DATETIME,label:"DateTime"},{value:_.dataType.DECIMAL,label:"Decimal"},{value:_.dataType.INT,label:"Integer"}];function jy(){const t=Xy.map(e=>h("option",{value:e.value,children:e.label},`key-columnType-${e.value}`));return T(be,{children:[h("option",{disabled:!0,value:"",children:"Select Type"},"key-columnType-placeholder"),t]})}const lp=class extends b.exports.PureComponent{constructor(t){super(t),this.getCachedColumnTypeOptions=Ie(()=>h(jy,{})),this.getCachedDateTimeFormatOptions=Ie((c,u,m,p=!1,g)=>{const{timestampAtMenuOpen:f}=this.state;return h(ip,{timestamp:f,timeZone:c,showTimeZone:u,showTSeparator:m,isGlobalOptions:p,legacyGlobalFormat:g})}),this.debouncedCommitChanges=Je(this.commitChanges.bind(this),lp.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:_.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(sp).map(np)??[],{settings:d,saveSettings:c}=this.props,u={...d,formatter:a,defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s,timeZone:i,truncateNumbersWithPound:l};Ms(_.dataType.DECIMAL,ke.makeCustomFormat(o.defaultFormatString))&&(u.defaultDecimalFormatOptions=o),Ms(_.dataType.INT,Qe.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.")),tp(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 T("fieldset",{className:"container-fluid format-rule-container",children:[T("div",{className:"form-row",children:[T("div",{className:"form-group col-7 mb-2",children:[h("label",{htmlFor:n,children:"Column Name"}),h("input",{id:n,className:Y("form-control",{"is-invalid":d.hasColumnNameError}),"data-lpignore":!0,type:"text",value:e.columnName,onChange:r,onBlur:l})]}),T("div",{className:"form-group col mb-2",children:[h(U,{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:T("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(_.getNormalizedType(e)){case _.dataType.DATETIME:return this.renderDateTimeFormatRuleInput(t,n,s,i);case _.dataType.DECIMAL:return this.renderDecimalFormatRuleInput(t,n,s,i);case _.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 T("select",{className:Y("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:Y("form-control","flex-grow-1",{"is-invalid":s}),"data-lpignore":!0,id:e,placeholder:Qe.DEFAULT_FORMAT_STRING,type:"text",value:i,onChange:o=>{const r=Qe.makeFormat("",o.target.value,Qe.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(t,"format",r)}})}renderDecimalFormatRuleInput(t,e,n,s){const i=n.formatString??"";return h("input",{className:Y("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(U,{kind:"ghost",className:"mb-3",onClick:this.handleFormatRuleCreate,ref:this.addFormatRuleButtonRef,icon:As,children:"Add New Rule"});return T("div",{className:"app-settings-formatting-section",ref:this.containerRef,children:[h("div",{children:"Default formatting for matched column names"}),h("div",{className:"app-settings-menu-description mb-3",children:"Applies a formatting rule to all columns that match a specified name and type."}),h(Wp,{appear:t,enter:t,exit:t,children:n}),s]})}};let Ad=lp;Ad.defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:st.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:ke.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:Qe.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:st.DEFAULT_TIME_ZONE_ID}};Ad.inputDebounceTime=250;const Qy=t=>({formatter:uu(t),defaultDateTimeFormat:du(t),defaultDecimalFormatOptions:cu(t),defaultIntegerFormatOptions:hu(t),showTimeZone:mu(t),showTSeparator:pu(t),truncateNumbersWithPound:gu(t),timeZone:ko(t),settings:Et(t)}),Zy=vt(Qy,{saveSettings:gl})(Ad),Zn=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:Zn.FORMATTING_SECTION_KEY}}static focusFirstInputInContainer(t){const e=t?.querySelector("input, select, textarea");e&&e.focus()}componentDidMount(){Zn.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;Ky(void 0,Object.fromEntries(t))}render(){const t="0.30.0",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)=>T(be,{children:[h("div",{children:a}),h("div",{children:d})]});return T("div",{className:"app-settings-menu",children:[T("header",{className:"app-settings-menu-header",children:[h("div",{className:"flex-spacer"}),h(U,{kind:"ghost",className:"btn-close-settings-menu",onClick:this.handleClose,icon:h(Z,{icon:Ui,transform:"grow-4"}),tooltip:"Close"})]}),T("div",{className:"app-settings-menu-content",ref:this.menuContentRef,children:[h("h5",{children:"Settings"}),h("hr",{className:"my-0"}),h(Ro,{sectionKey:Zn.FORMATTING_SECTION_KEY,isExpanded:this.isSectionExpanded(Zn.FORMATTING_SECTION_KEY),title:T(be,{children:[h(Z,{icon:lf,transform:"grow-4",className:"mr-2"}),"Default Formatting & Time zone"]}),onToggle:this.handleSectionToggle,children:h(Py,{})}),h(Ro,{sectionKey:Zn.COLUMN_SPECIFIC_SECTION_KEY,isExpanded:this.isSectionExpanded(Zn.COLUMN_SPECIFIC_SECTION_KEY),title:T(be,{children:[h(Z,{icon:af,transform:"grow-4",className:"mr-2"}),"Column Specific Formatting Rules"]}),onToggle:this.handleSectionToggle,children:h(Zy,{scrollTo:this.handleScrollTo})}),h(Ro,{sectionKey:Zn.SHORTCUT_SECTION_KEY,isExpanded:this.isSectionExpanded(Zn.SHORTCUT_SECTION_KEY),title:T(be,{children:[h(Z,{icon:df,transform:"grow-2"})," ","Keyboard Shortcuts"]}),onToggle:this.handleSectionToggle,children:h(Wy,{})}),T("div",{className:"app-settings-footer",children:[T("div",{className:"app-settings-footer-section",children:[T("div",{className:"app-settings-footer-item",children:[h("div",{className:"font-weight-bold",children:"Support"}),T("div",{children:["GitHub:\xA0",h("a",{href:e,className:"custom-link",target:"_blank",rel:"noopener noreferrer",children:e})]}),h(U,{kind:"tertiary",className:"mt-2 py-2",onClick:this.handleExportSupportLogs,children:"Export Logs"})]}),T("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})]}),T("div",{className:"app-settings-footer-item",children:[h("div",{className:"font-weight-bold",children:"Version"}),T("span",{className:"d-inline-block text-muted",children:[r," ",h(Z,{icon:cf}),T(ut,{interactive:!0,children:[T("div",{className:"detailed-server-config",children:[l("Engine Version",r),l("Web UI Version",t),l("Java Version",o),l("Barrage Version",i)]}),h(ll,{tooltip:"Copy version numbers",copy:`Engine Version: ${r}
37
+ This note can be edited using **markdown** for styling.`;function fy(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===yo.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(co.COMPONENT),g=s.getClosedPanelConfigsOfType(co.COMPONENT),f=p.map(y=>y.title??""),C=l!=null&&l!==""?l:yo.getNewMarkdownTitle(f),S=g.length>0?null:yo.DEFAULT_CONTENT,w={type:"react-component",component:co.COMPONENT,props:{id:d,metadata:a,panelState:{content:S},localDashboardId:e},title:C,id:d},{root:v}=n;ie.openComponent({root:v,config:w,focusElement:c,createNewStack:u,dragEvent:m})},[e,n,s]);return b.exports.useEffect(function(){const a=[i(co.COMPONENT,co,sd,o)];return()=>{a.forEach(d=>d())}},[o,i]),Be(n.eventHub,km.OPEN,r),null}function Cy(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:Eo.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(Eo.COMPONENT,Eo,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 Sy=M.exports.shape({state:M.exports.shape({panelState:M.exports.shape({})})}),by=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}),wy=M.exports.arrayOf(Qm),Ty=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:by,Link:Qm,Links:wy,Panel:Sy,User:Ty});const vy=(t,e)=>t[e]===null?null:M.exports.bool,Ey=(t,e)=>t[e]===null?null:M.exports.string;Object.freeze({nullableBoolean:vy,nullableString:Ey});J.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=J.module("PouchStorageTable"),yy="Deephaven.";Ch.plugin(Gp);function Ry(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 Iy(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]:Ry(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=>Iy(e)),{name:{$gt:null}},{id:{$gt:null}}]}}function Fy(t,e=!1){return[{id:e?"desc":"asc"},...t?.map(n=>({[n.column]:n.direction}))??[]]}class Dy{constructor(e){this.listeners=[],this.itemListeners=new Map,this.currentSize=0,this.currentReverse=!1,this.currentFilter=null,this.currentSort=null,this.db=new Ch(`${yy}${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=Fy(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 Dy{constructor(e){super(`CommandHistoryStorage.${e}`)}setSearch(e){this.setFilters(e?[rh.makeFilterConfig([rh.makeFilterItem("name",$.contains,e)])]:[])}}const ah=J.module("PouchCommandHistoryStorage");class Ny{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 Zm="SET_LAYOUT_STORAGE",_y=t=>({type:Zm,payload:t}),Jm="/ide/assets/community-wordmark-app.d2c5c1eb.svg";const My=J.module("FormattingSectionContent");function ky(t){return t.formatString!=null}function _a(t){const e=t?.querySelector("input, select, textarea");e&&e.focus()}function ep(t,e){return t.defaultFormatString===e.defaultFormatString}function xy(t,e){return ep(t,e)}function Oy(t,e){return ep(t,e)}function tp(t){return t!==""&&Vi.isValidColumnName(t)}function Ms(t,e){if(!t||e.formatString==null||!ky(e))return!1;switch(t){case"datetime":return st.isValid(e);case"decimal":return ke.isValid(e);case"int":return Qe.isValid(e);default:return My.warn("Trying to validate format of unknown type"),!0}}function np(t){const{id:e,isNewRule:n,...s}=t;return s}function sp(t){return tp(t.columnName)&&Ms(t.columnType,t.format)}function ip(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(be,{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,_.dataType.DATETIME,"",c)},d)})})}function Ay(){return h(be,{children:Qr.TIME_ZONES.map(t=>{const{label:e,value:n}=t;return h("option",{value:n,children:e},n)})})}const Ys=J.module("FormattingSectionContent"),op=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(ip,{timestamp:f,timeZone:c,showTimeZone:u,showTSeparator:m,isGlobalOptions:p,legacyGlobalFormat:g})}),this.debouncedCommitChanges=Je(this.commitChanges.bind(this),op.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){Ys.debug("handleDefaultDateTimeFormatChange",t.target.value),this.setState({defaultDateTimeFormat:t.target.value},()=>{this.debouncedCommitChanges()})}handleDefaultDecimalFormatChange(t){Ys.debug("handleDefaultDecimalFormatChange",t.target.value),this.setState({defaultDecimalFormatOptions:{defaultFormatString:t.target.value}},()=>{this.debouncedCommitChanges()})}handleDefaultIntegerFormatChange(t){Ys.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;Ys.debug("handleResetDateTimeFormat"),this.setState({defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s},()=>{this.debouncedCommitChanges()})}handleResetTimeZone(){const{defaults:t}=this.props,{timeZone:e}=t;Ys.debug("handleResetTimeZone"),this.setState({timeZone:e},()=>{this.debouncedCommitChanges()})}handleResetDecimalFormat(){const{defaults:t}=this.props,{defaultDecimalFormatOptions:e}=t;Ys.debug("handleResetDecimalFormat"),this.setState({defaultDecimalFormatOptions:e},()=>{this.debouncedCommitChanges()})}handleResetIntegerFormat(){const{defaults:t}=this.props,{defaultIntegerFormatOptions:e}=t;Ys.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(sp).map(np)??[],{settings:d,saveSettings:c}=this.props,u={...d,formatter:a,defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s,timeZone:i,truncateNumbersWithPound:l};Ms(_.dataType.DECIMAL,ke.makeCustomFormat(o.defaultFormatString))&&(u.defaultDecimalFormatOptions=o),Ms(_.dataType.INT,Qe.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=Qe.DEFAULT_FORMAT_STRING}=s??{},c=i===t.timeZone,u=r===t.showTSeparator&&o===t.showTimeZone&&e===t.defaultDateTimeFormat,m=xy(n,t.defaultDecimalFormatOptions),p=Oy(s,t.defaultIntegerFormatOptions);return h("div",{className:"app-settings-formatting-section",ref:this.containerRef,children:T("div",{className:"container-fluid p-0",children:[h("div",{children:"Default formatting for column types"}),h("div",{className:"app-settings-menu-description mb-3",children:"Applies a formatting rule to all columns of a set type."}),T("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(Ay,{})})}),h("div",{className:"col-1 btn-col",children:h(U,{kind:"ghost",icon:ei,onClick:this.handleResetTimeZone,tooltip:"Reset Time Zone",className:Y("btn-reset","btn-reset-time-zone",{hidden:c})})})]}),T("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(U,{kind:"ghost",icon:ei,onClick:this.handleResetDateTimeFormat,tooltip:"Reset DateTime Options",className:Y("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"})})}),T("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:Y("form-control","flex-grow-1","default-decimal-format-input",{"is-invalid":!Ms(_.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(U,{kind:"ghost",icon:ei,onClick:this.handleResetDecimalFormat,tooltip:"Reset Decimal Formatting",className:Y("btn-reset","btn-reset-decimal",{hidden:m}),"data-testid":"btn-reset-decimal"})})]}),T("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:Y("form-control","flex-grow-1","default-integer-format-input",{"is-invalid":!Ms(_.dataType.INT,Qe.makeCustomFormat(d))}),"data-lpignore":!0,placeholder:Qe.DEFAULT_FORMAT_STRING,type:"text",id:"default-integer-format-input",value:d,onChange:this.handleDefaultIntegerFormatChange})}),h("div",{className:"col-1 btn-col",children:h(U,{kind:"ghost",icon:ei,onClick:this.handleResetIntegerFormat,tooltip:"Reset Integer Formatting",className:Y("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=op;Od.defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:st.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:ke.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:Qe.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:st.DEFAULT_TIME_ZONE_ID}};Od.inputDebounceTime=250;const Ly=t=>({formatter:uu(t),defaultDateTimeFormat:du(t),defaultDecimalFormatOptions:cu(t),defaultIntegerFormatOptions:hu(t),showTimeZone:mu(t),showTSeparator:pu(t),truncateNumbersWithPound:gu(t),timeZone:ko(t),settings:Et(t)}),Py=vt(Ly,{saveSettings:gl})(Od);function Hy(){const[t,e]=b.exports.useState(!1),n=()=>{e(!t)};return T(U,{kind:"ghost",onClick:n,icon:sf,children:["Legal Notices",T(nl,{isOpen:t,toggle:n,className:"theme-bg-light",children:[h(sl,{toggle:n,children:"Legal Notice"}),T(il,{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."}),T("p",{children:["\xA9 2016-",new Date().getFullYear()," Deephaven Data Labs LLC. Patent Pending."]})]})]})]})}function Ro(t){const{children:e,isExpanded:n,sectionKey:s,title:i,onToggle:o}=t;return T(be,{children:[h("div",{children:T(U,{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(Z,{transform:n?"flip-v":"",icon:ts})})]})}),h(of,{in:n,autoFocusOnShow:!0,children:e})]})}Ro.propTypes={children:M.exports.node,isExpanded:M.exports.bool.isRequired,sectionKey:M.exports.string.isRequired,title:M.exports.node.isRequired,onToggle:M.exports.func};Ro.defaultProps={children:null,onToggle:()=>{}};function Uy({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(v){if(v.stopPropagation(),v.preventDefault(),t.isEditable&&!v.repeat){const y=fn.getKeyStateFromEvent(v),E=fn.createKeyState([Fe.BACKSPACE]);fn.doKeyStatesMatch(y,E)?l(fn.NULL_KEY_STATE):l(y)}}function p(v){v.stopPropagation(),v.preventDefault(),t.matchesKeyState(r)||d(!0)}function g(){Pn.disableAllActions()}function f(){Pn.enableAllActions()}function C(){t.setKeyState(r),d(!1),s(t)}function S(){const v=t.getKeyState();l(v),d(!1)}function w(){d(!0),l(t.getDefaultKeyState())}return T(be,{children:[T("div",{className:"shortcut-item-container",children:[T("label",{className:"shortcut-item-name",children:[t.name,t.tooltip!==void 0&&h(ut,{children:t.tooltip})]}),T("div",{className:"shortcut-item-input-container",children:[h("input",{className:Y("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(U,{className:"reset-to-default-button",kind:"ghost",icon:h(Z,{icon:ei,transform:{rotate:90,flipX:!0}}),tooltip:"Reset to default",onClick:w})]})]}),a&&T("div",{className:Y("shortcut-item-message-container",{"is-invalid":c}),children:[h("div",{className:"shortcut-item-message",children:c}),T("div",{className:"shortcut-item-message-buttons",children:[fn.isValidKeyState(r)&&h(U,{kind:"ghost",onClick:C,children:"Confirm"}),h(U,{kind:"ghost",onClick:S,children:"Undo"})]})]})]})}function Vy({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),T(be,{children:[h("div",{className:"app-settings-menu-description",children:"Customize shortcuts below. Assigning shortcuts that conflict with the browser or IDE shortcuts may cause unintended behavior"}),i.map(l=>h(By,{name:l.name,shortcuts:l.shortcuts,saveShortcutOverrides:s},l.name))]})}function By({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 T("div",{className:"mt-3",children:[h("div",{className:"font-weight-bold",children:s(t)}),i.map((a,d)=>h(Uy,{shortcut:a,displayText:l[d],categoryName:t,onChange:r},a.id))]})}const $y=t=>({settings:Et(t),shortcutOverrides:eS(t)}),Gy={saveSettings:gl},Wy=vt($y,Gy)(Vy),zy="yyyy-MM-dd-HHmmss";function rp(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]=rp(o,a,n)}}}),s}function qy(){const t=Cl.getState();return JSON.stringify(rp(t),null,2)}function Yy(t){const e={uiVersion:"0.30.1",userAgent:navigator.userAgent,...t};return JSON.stringify(e,null,2)}async function Ky(t=`${I.i18n.DateTimeFormat.format(zy,new Date)}_support_logs`,e){const n=new Sh,s=n.folder(t);s.file("console.txt",rf.getFormattedHistory()),s.file("redux.json",qy()),s.file("metadata.json",Yy(e));const i=await n.generateAsync({type:"blob"}),o=document.createElement("a");o.href=URL.createObjectURL(i),o.download=`${t}.zip`,o.click()}const Xy=[{value:_.dataType.DATETIME,label:"DateTime"},{value:_.dataType.DECIMAL,label:"Decimal"},{value:_.dataType.INT,label:"Integer"}];function jy(){const t=Xy.map(e=>h("option",{value:e.value,children:e.label},`key-columnType-${e.value}`));return T(be,{children:[h("option",{disabled:!0,value:"",children:"Select Type"},"key-columnType-placeholder"),t]})}const lp=class extends b.exports.PureComponent{constructor(t){super(t),this.getCachedColumnTypeOptions=Ie(()=>h(jy,{})),this.getCachedDateTimeFormatOptions=Ie((c,u,m,p=!1,g)=>{const{timestampAtMenuOpen:f}=this.state;return h(ip,{timestamp:f,timeZone:c,showTimeZone:u,showTSeparator:m,isGlobalOptions:p,legacyGlobalFormat:g})}),this.debouncedCommitChanges=Je(this.commitChanges.bind(this),lp.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:_.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(sp).map(np)??[],{settings:d,saveSettings:c}=this.props,u={...d,formatter:a,defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s,timeZone:i,truncateNumbersWithPound:l};Ms(_.dataType.DECIMAL,ke.makeCustomFormat(o.defaultFormatString))&&(u.defaultDecimalFormatOptions=o),Ms(_.dataType.INT,Qe.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.")),tp(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 T("fieldset",{className:"container-fluid format-rule-container",children:[T("div",{className:"form-row",children:[T("div",{className:"form-group col-7 mb-2",children:[h("label",{htmlFor:n,children:"Column Name"}),h("input",{id:n,className:Y("form-control",{"is-invalid":d.hasColumnNameError}),"data-lpignore":!0,type:"text",value:e.columnName,onChange:r,onBlur:l})]}),T("div",{className:"form-group col mb-2",children:[h(U,{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:T("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(_.getNormalizedType(e)){case _.dataType.DATETIME:return this.renderDateTimeFormatRuleInput(t,n,s,i);case _.dataType.DECIMAL:return this.renderDecimalFormatRuleInput(t,n,s,i);case _.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 T("select",{className:Y("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:Y("form-control","flex-grow-1",{"is-invalid":s}),"data-lpignore":!0,id:e,placeholder:Qe.DEFAULT_FORMAT_STRING,type:"text",value:i,onChange:o=>{const r=Qe.makeFormat("",o.target.value,Qe.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(t,"format",r)}})}renderDecimalFormatRuleInput(t,e,n,s){const i=n.formatString??"";return h("input",{className:Y("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(U,{kind:"ghost",className:"mb-3",onClick:this.handleFormatRuleCreate,ref:this.addFormatRuleButtonRef,icon:As,children:"Add New Rule"});return T("div",{className:"app-settings-formatting-section",ref:this.containerRef,children:[h("div",{children:"Default formatting for matched column names"}),h("div",{className:"app-settings-menu-description mb-3",children:"Applies a formatting rule to all columns that match a specified name and type."}),h(Wp,{appear:t,enter:t,exit:t,children:n}),s]})}};let Ad=lp;Ad.defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:st.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:ke.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:Qe.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:st.DEFAULT_TIME_ZONE_ID}};Ad.inputDebounceTime=250;const Qy=t=>({formatter:uu(t),defaultDateTimeFormat:du(t),defaultDecimalFormatOptions:cu(t),defaultIntegerFormatOptions:hu(t),showTimeZone:mu(t),showTSeparator:pu(t),truncateNumbersWithPound:gu(t),timeZone:ko(t),settings:Et(t)}),Zy=vt(Qy,{saveSettings:gl})(Ad),Zn=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:Zn.FORMATTING_SECTION_KEY}}static focusFirstInputInContainer(t){const e=t?.querySelector("input, select, textarea");e&&e.focus()}componentDidMount(){Zn.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;Ky(void 0,Object.fromEntries(t))}render(){const t="0.30.1",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)=>T(be,{children:[h("div",{children:a}),h("div",{children:d})]});return T("div",{className:"app-settings-menu",children:[T("header",{className:"app-settings-menu-header",children:[h("div",{className:"flex-spacer"}),h(U,{kind:"ghost",className:"btn-close-settings-menu",onClick:this.handleClose,icon:h(Z,{icon:Ui,transform:"grow-4"}),tooltip:"Close"})]}),T("div",{className:"app-settings-menu-content",ref:this.menuContentRef,children:[h("h5",{children:"Settings"}),h("hr",{className:"my-0"}),h(Ro,{sectionKey:Zn.FORMATTING_SECTION_KEY,isExpanded:this.isSectionExpanded(Zn.FORMATTING_SECTION_KEY),title:T(be,{children:[h(Z,{icon:lf,transform:"grow-4",className:"mr-2"}),"Default Formatting & Time zone"]}),onToggle:this.handleSectionToggle,children:h(Py,{})}),h(Ro,{sectionKey:Zn.COLUMN_SPECIFIC_SECTION_KEY,isExpanded:this.isSectionExpanded(Zn.COLUMN_SPECIFIC_SECTION_KEY),title:T(be,{children:[h(Z,{icon:af,transform:"grow-4",className:"mr-2"}),"Column Specific Formatting Rules"]}),onToggle:this.handleSectionToggle,children:h(Zy,{scrollTo:this.handleScrollTo})}),h(Ro,{sectionKey:Zn.SHORTCUT_SECTION_KEY,isExpanded:this.isSectionExpanded(Zn.SHORTCUT_SECTION_KEY),title:T(be,{children:[h(Z,{icon:df,transform:"grow-2"})," ","Keyboard Shortcuts"]}),onToggle:this.handleSectionToggle,children:h(Wy,{})}),T("div",{className:"app-settings-footer",children:[T("div",{className:"app-settings-footer-section",children:[T("div",{className:"app-settings-footer-item",children:[h("div",{className:"font-weight-bold",children:"Support"}),T("div",{children:["GitHub:\xA0",h("a",{href:e,className:"custom-link",target:"_blank",rel:"noopener noreferrer",children:e})]}),h(U,{kind:"tertiary",className:"mt-2 py-2",onClick:this.handleExportSupportLogs,children:"Export Logs"})]}),T("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})]}),T("div",{className:"app-settings-footer-item",children:[h("div",{className:"font-weight-bold",children:"Version"}),T("span",{className:"d-inline-block text-muted",children:[r," ",h(Z,{icon:cf}),T(ut,{interactive:!0,children:[T("div",{className:"detailed-server-config",children:[l("Engine Version",r),l("Web UI Version",t),l("Java Version",o),l("Barrage Version",i)]}),h(ll,{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(Hy,{})})]}),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:Jm,alt:"Deephaven Data Labs",width:"230px"})})})})]})]})]})}};let ji=Zn;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]),T("button",{type:"button",className:Y("btn-context-menu",{disabled:s},{active:r&&!s},{"keyboard-active":l&&!s}),onMouseDown:f,onMouseUp:C,disabled:m,children:[h("span",{className:Y("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:hf,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:uf,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:mf,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 Jy=Ls(Zm,null),eR={layoutStorage:Jy},tR=t=>t.layoutStorage,nR=t=>t.serverConfigValues;Object.entries(eR).map(([t,e])=>Gi.register(t,e));const hh=10;function sR(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:T(U,{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]),v=b.exports.useMemo(()=>w.length===0?h("span",{children:"No bound variables found."}):null,[w]);return T("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})}),T("ul",{className:"widget-list flex-grow-1",children:[v&&h("li",{className:"widget-list-message",children:v}),!v&&w]}),h("div",{children:h("hr",{})}),T("div",{className:"widget-list-footer",children:[T(U,{kind:"ghost",onClick:e,children:[T("div",{className:"fa-md fa-layers",children:[h(Z,{mask:da,icon:jd,transform:"right-5 down-5"}),h(Z,{icon:jd,transform:"right-8 down-6"})]}),"Export Layout"]}),T(U,{kind:"ghost",onClick:n,children:[T("div",{className:"fa-md fa-layers",children:[h(Z,{mask:da,icon:ha,transform:"right-5 down-5"}),h(Z,{icon:ha,transform:"right-8 down-6"})]}),"Import Layout"]}),h(U,{kind:"ghost",icon:ei,onClick:s,tooltip:"Reset Layout"})]})]})}const iR=async(t,e,n)=>{let s,i,o,r;if(Er(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,ko(Cl.getState())),Oi.makeModelFromSettings(s,a)},oR=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 rR({onAutoFillClick:t=()=>{}}){return T("div",{className:"empty-dashboard-container",children:[T("div",{className:"hint-container",children:[h(Z,{icon:Fh})," ",h("br",{}),"Use the panel list to add objects from a query."]}),T("div",{className:"empty-dashboard",children:[h("div",{className:"add-panels-hint",children:"Drag Panels Here"}),h(U,{kind:"tertiary",onClick:t,children:"Auto fill objects"})]})]})}function lR(t){return t.version===2}function aR(t){return Array.isArray(t)}const br=J.module("UserLayoutUtils"),dR={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:Kr.COMPONENT,title:Kr.TITLE,isClosable:!1}]},{type:"stack",width:25,content:[{type:"react-component",component:zr.COMPONENT,title:zr.TITLE,isClosable:!1},{type:"react-component",component:qr.COMPONENT,title:qr.TITLE,isClosable:!1}]}]},{type:"row",content:[{type:"stack",title:"Notebooks",content:[]}]}]}],links:[],filterSets:[],version:2},cR={layoutConfig:[],links:[],filterSets:[],version:2};function ap(t){if(lR(t))return t;if(aR(t))return{layoutConfig:t,links:[],filterSets:[],version:2};throw new Error(`Unexpected layout import format: ${t}`)}async function hR(t,e=!0){try{const n=await t.getLayouts();if(n.length>0)try{const s=await t.getLayout(n[0]);return ap(s)}catch(s){br.error("Unable to load layout",n[0],":",s),br.warn("No valid layouts found, falling back to default layout")}}catch(n){br.error("Unable to fetch layout list",n),br.warn("Falling back to default layout")}return e?dR:cR}function uR(t){const{filterSets:e,layoutConfig:n,links:s}=t;return{filterSets:e,layoutConfig:n,links:s,version:2}}const Dr={exportLayout:uR,getDefaultLayout:hR,normalizeLayout:ap},wr=J.module("DownloadServiceWorkerUtils"),dp=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(),wr.info("Registering service worker on ",e,n)}).catch(n=>{wr.error("Failed to register service worker",n)})}):wr.info("Service worker is not supported."))}static async getServiceWorker(){if("serviceWorker"in navigator){const e=(await navigator.serviceWorker.getRegistrations()).find(n=>n.scope.endsWith(dp.DOWNLOAD_PATH));if(e&&e.active)return wr.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 Xr=dp;Xr.DOWNLOAD_PATH="/download/";const cp={react:de},mR=zp(cp),pR=qp({requires:mR}),gR=Yp.createRequires(cp),fR=Kp({requires:gR}),CR=J.module("PluginUtils");class Ma{static loadComponentPlugin(e){if("".split(",").includes(e)){const o=de.lazy(()=>ff(()=>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(pR,{url:s,render:({err:l,Component:a})=>{if(l!=null&&l!==""){const d=`Error loading plugin ${e} from ${s} due to ${l}`;return CR.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 fR(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=J.module("AppMainContainer");class Io 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",Io.handleWindowBeforeUnload)}componentDidUpdate(e){const{dashboardData:n}=this.props;e.dashboardData!==n&&this.handleDataChange(n)}componentWillUnmount(){this.deinitWidgets(),window.removeEventListener("beforeunload",Io.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(km.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=Dr.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}=Dr.normalizeLayout(o);s({layoutConfig:l}),n(Sn,{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 Dr.getDefaultLayout(e,n!==void 0),{updateDashboardData:r,updateWorkspaceData:l}=this.props;l({layoutConfig:i}),r(Sn,{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:Xr.getServiceWorker,loadPlugin:this.handleLoadTablePlugin,localDashboardId:n,makeModel:()=>oR(i,e.metadata,s)}}hydrateChart(e,n){const{connection:s}=this.props;return{...e,localDashboardId:n,makeModel:()=>{const{metadata:i,panelState:o}=e;return iR(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 T("div",{className:Y("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:T("div",{className:"app-main-top-nav-menus",children:[h("img",{src:Jm,alt:"Deephaven Data Labs",width:"115px",className:"ml-1"}),T("div",{children:[T(U,{kind:"ghost",className:"btn-panels-menu",icon:pf,onClick:()=>{},children:["Controls",h(Ld,{handleControlSelect:this.handleControlSelect,handleToolSelect:this.handleToolSelect,onClearFilter:this.handleClearFilter})]}),d&&T(U,{kind:"ghost",className:"btn-panels-menu btn-show-panels","data-testid":"app-main-panels-button",onClick:this.handleWidgetMenuClick,icon:gf,children:["Panels",h(tl,{isShown:u,className:"panels-menu-popper",onExited:this.handleWidgetsMenuClose,closeOnBlur:!0,interactive:!0,children:h(sR,{widgets:p,onExportLayout:this.handleExportLayoutClick,onImportLayout:this.handleImportLayoutClick,onResetLayout:this.handleResetLayoutClick,onSelect:this.handleWidgetSelect})})]}),h(U,{kind:"ghost",className:Y("btn-settings-menu",{"text-warning":s.operateAs!==s.name}),onClick:this.handleSettingsMenuShow,icon:h(Z,{icon:_o,transform:"grow-3 right-1 down-1"}),tooltip:"User Settings"})]})]})}),T(Zb,{emptyDashboard:h(rR,{onAutoFillClick:this.handleAutoFillClick}),id:Sn,layoutConfig:l,onGoldenLayoutChange:this.handleGoldenLayoutChange,onLayoutConfigChange:this.handleLayoutConfigChange,onLayoutInitialized:this.openNotebookFromURL,hydrate:this.hydrateDefault,children:[h(dy,{hydrate:this.hydrateGrid,getDownloadWorker:Xr.getServiceWorker,loadPlugin:this.handleLoadTablePlugin}),h(sy,{hydrate:this.hydrateChart}),h(iy,{}),h(ry,{hydrateConsole:Io.hydrateConsole,notebooksUrl:new URL("/notebooks/",`${window.location}`).href}),h(ly,{}),h(Cy,{hydrate:this.hydratePandas}),h(fy,{}),h(gy,{}),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 SR=t=>({activeTool:pl(t),dashboardData:Yt(t,Sn),layoutStorage:tR(t),plugins:nS(t),connection:mE(t,Sn),session:ai(t,Sn)?.session,sessionConfig:ai(t,Sn)?.config,user:ru(t),workspace:ml(t),serverConfigValues:nR(t)}),bR=vt(SR,{setActiveTool:fl,updateDashboardData:Vn,updateWorkspaceData:Ru})(Xp(Io));function wR(){return T("div",{className:"app",children:[h(bR,{}),h(kh,{})]})}const TR=J.module("LocalWorkspaceStorage"),wo=class{static async makeDefaultWorkspaceData(t,e){const{filterSets:n,links:s,layoutConfig:i}=await Dr.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:Qe.DEFAULT_FORMAT_STRING},truncateNumbersWithPound:!1,defaultNotebookSettings:{isMinimapEnabled:!1}},layoutConfig:i,closed:[{}],links:s,filterSets:n}}static async makeDefaultWorkspace(t,e){return{data:await wo.makeDefaultWorkspaceData(t,e)}}constructor(t){this.layoutStorage=t}async load(t){try{return JSON.parse(localStorage.getItem(wo.STORAGE_KEY)??"")}catch{return TR.info("Unable to load workspace data, initializing to default data"),wo.makeDefaultWorkspace(this.layoutStorage,t)}}async save(t){return localStorage.setItem(wo.STORAGE_KEY,JSON.stringify(t)),t}};let hp=wo;hp.STORAGE_KEY="deephaven.WorkspaceStorage";class vR extends Error{constructor(){super(...arguments),this.isNoConsolesError=!0}}function ER(t){return t.isNoConsolesError}const ks=J.module("SessionUtils");var up=(t=>(t.ANONYMOUS="anonymous",t.PARENT="parent",t))(up||{});function yR(){return new URL("/jsapi",`${window.location}`)}function mp(){const t=yR();return`${t.protocol}//${t.host}`}function RR(){switch(new URLSearchParams(window.location.search).get("authProvider")){case"parent":return"parent";default:return"anonymous"}}function IR(){const t=mp();return ks.info(`Starting connection to '${t}'...`),new I.IdeConnection(t)}async function FR(t){ks.info("Getting console types...");const e=await t.getConsoleTypes();if(ks.info("Available types:",e),e.length===0)throw new vR("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 DR(){const t=mp();return ks.info("createCoreClient",t),new I.CoreClient(t)}async function NR(){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 _R(t){switch(t){case"parent":return NR();case"anonymous":return{type:I.CoreClient.LOGIN_TYPE_ANONYMOUS};default:throw new Error(`Unknown auth type: ${t}`)}}class MR{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 mo=J.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){mo.debug2("doRefresh",this.root),t(this.fetchData())}refresh(){mo.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 Zr;return this.currentViewportData=n,this.sendUpdate(),n}));e.catch(n=>{ye.isCanceled(n)||mo.error("Error updating viewport",n)}),this.viewportUpdatePromise=e}refreshInternal(){try{this.refresh()}catch(t){ye.isCanceled(t)||mo.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,mo.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 pp=ka;pp.REFRESH_DEBOUNCE=50;const kR=J.module("GrpcFileStorage"),gp=class{constructor(t,e=""){this.tables=[],this.refreshTables=Ln(()=>{this.tables.forEach(n=>n.refresh())},gp.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 pp(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 kR.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 fp=gp;fp.REFRESH_THROTTLE=150;const xs=J.module("AppInit");async function xR(){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 OR(t){let e;try{e=await FR(t)}catch(n){if(!ER(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.30.0",navigator.userAgent);const F=DR(),D=RR();xs.info(`Login using auth type ${D}...`),await F.login(await _R(D));const N=await xR(),P=await(D===up.ANONYMOUS&&F.getAsIdeConnection==null?IR():F.getAsIdeConnection());P.addEventListener(I.IdeConnection.HACK_CONNECTION_FAILURE,Se=>{const{detail:Re}=Se;xs.error("Connection failure",`${JSON.stringify(Re)}`),f(`Unable to connect: ${Re.details??"Unknown Error"}`)});const H=await OR(P),A="user",q=F.getStorageService(),B=new MR(q,"/layouts"),K=new fp(q,"/notebooks"),x=new hp(B),O=new Ny,G=await x.load({isConsoleAvailable:H!==void 0}),{data:ee}=G,{settings:ne}=ee;ne.defaultDecimalFormatOptions===void 0&&(ne.defaultDecimalFormatOptions={defaultFormatString:ke.DEFAULT_FORMAT_STRING}),ne.defaultIntegerFormatOptions===void 0&&(ne.defaultIntegerFormatOptions={defaultFormatString:Qe.DEFAULT_FORMAT_STRING}),ne.truncateNumbersWithPound===void 0&&(ne.truncateNumbersWithPound=!1);const{shortcutOverrides:V={}}=ne,X=fn.isMacPlatform?V.mac??{}:V.windows??{};Object.entries(X).forEach(([Se,Re])=>{qe.get(Se)?.setKeyState(Re)});const se={filterSets:ee.filterSets,links:ee.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(O),i(Sn,se),o(K),r(B),l(Sn,P),H!==void 0&&a(Sn,H),d(N),c(he),m(x),u(G)}catch(F){xs.error(F),f(F)}},[n,s,i,o,r,l,a,d,c,u,m,p]),v=b.exports.useCallback(()=>{document.fonts!=null?document.fonts.ready.then(()=>{S(!1)}):S(!1)},[]);b.exports.useEffect(function(){w(),v()},[w,v]);const y=e==null&&g==null||C,E=!y&&g==null,R=g!=null?`${g}`:null;return T(be,{children:[E&&h(wR,{}),h(Jr,{isLoading:y,isLoaded:E,errorMessage:R}),T("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 AR=t=>({workspace:ml(t),workspaceStorage:JC(t)}),uh=vt(AR,{setActiveTool:fl,setCommandHistoryStorage:oS,setDashboardData:Xu,setFileStorage:rS,setLayoutStorage:_y,setDashboardConnection:pE,setDashboardSessionWrapper:gE,setPlugins:aS,setUser:sS,setWorkspace:yu,setWorkspaceStorage:iS,setServerConfigValues:dS})(Pd);function LR(){return h(jp,{basename:"/ide/",children:T(Qp,{children:[h($d,{exact:!0,path:"/",component:uh}),h($d,{path:"/notebook/:notebookPath+",component:uh}),h(Zp,{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 PR(){"serviceWorker"in navigator&&navigator.serviceWorker.getRegistrations().then(t=>{t.forEach(e=>{e.scope.endsWith("/download/")||e.unregister()})})}function GR(){return b.exports.useEffect(()=>{PR(),Xr.registerOnLoaded(),lt.init({getWorker:()=>new Cf}),window["__react-beautiful-dnd-disable-dev-warnings"]=!0},[]),h(ph,{store:Cl,children:h(LR,{})})}export{GR as AppRoot,GR as default};
42
- //# sourceMappingURL=AppRoot.d190ead3.js.map
41
+ Barrage Version: ${i}`,children:"Copy Versions"})]})]})]}),h("div",{className:"app-settings-footer-item",children:h(Hy,{})})]}),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:Jm,alt:"Deephaven Data Labs",width:"230px"})})})})]})]})]})}};let ji=Zn;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]),T("button",{type:"button",className:Y("btn-context-menu",{disabled:s},{active:r&&!s},{"keyboard-active":l&&!s}),onMouseDown:f,onMouseUp:C,disabled:m,children:[h("span",{className:Y("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:hf,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:uf,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:mf,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 Jy=Ls(Zm,null),eR={layoutStorage:Jy},tR=t=>t.layoutStorage,nR=t=>t.serverConfigValues;Object.entries(eR).map(([t,e])=>Gi.register(t,e));const hh=10;function sR(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:T(U,{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]),v=b.exports.useMemo(()=>w.length===0?h("span",{children:"No bound variables found."}):null,[w]);return T("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})}),T("ul",{className:"widget-list flex-grow-1",children:[v&&h("li",{className:"widget-list-message",children:v}),!v&&w]}),h("div",{children:h("hr",{})}),T("div",{className:"widget-list-footer",children:[T(U,{kind:"ghost",onClick:e,children:[T("div",{className:"fa-md fa-layers",children:[h(Z,{mask:da,icon:jd,transform:"right-5 down-5"}),h(Z,{icon:jd,transform:"right-8 down-6"})]}),"Export Layout"]}),T(U,{kind:"ghost",onClick:n,children:[T("div",{className:"fa-md fa-layers",children:[h(Z,{mask:da,icon:ha,transform:"right-5 down-5"}),h(Z,{icon:ha,transform:"right-8 down-6"})]}),"Import Layout"]}),h(U,{kind:"ghost",icon:ei,onClick:s,tooltip:"Reset Layout"})]})]})}const iR=async(t,e,n)=>{let s,i,o,r;if(Er(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,ko(Cl.getState())),Oi.makeModelFromSettings(s,a)},oR=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 rR({onAutoFillClick:t=()=>{}}){return T("div",{className:"empty-dashboard-container",children:[T("div",{className:"hint-container",children:[h(Z,{icon:Fh})," ",h("br",{}),"Use the panel list to add objects from a query."]}),T("div",{className:"empty-dashboard",children:[h("div",{className:"add-panels-hint",children:"Drag Panels Here"}),h(U,{kind:"tertiary",onClick:t,children:"Auto fill objects"})]})]})}function lR(t){return t.version===2}function aR(t){return Array.isArray(t)}const br=J.module("UserLayoutUtils"),dR={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:Kr.COMPONENT,title:Kr.TITLE,isClosable:!1}]},{type:"stack",width:25,content:[{type:"react-component",component:zr.COMPONENT,title:zr.TITLE,isClosable:!1},{type:"react-component",component:qr.COMPONENT,title:qr.TITLE,isClosable:!1}]}]},{type:"row",content:[{type:"stack",title:"Notebooks",content:[]}]}]}],links:[],filterSets:[],version:2},cR={layoutConfig:[],links:[],filterSets:[],version:2};function ap(t){if(lR(t))return t;if(aR(t))return{layoutConfig:t,links:[],filterSets:[],version:2};throw new Error(`Unexpected layout import format: ${t}`)}async function hR(t,e=!0){try{const n=await t.getLayouts();if(n.length>0)try{const s=await t.getLayout(n[0]);return ap(s)}catch(s){br.error("Unable to load layout",n[0],":",s),br.warn("No valid layouts found, falling back to default layout")}}catch(n){br.error("Unable to fetch layout list",n),br.warn("Falling back to default layout")}return e?dR:cR}function uR(t){const{filterSets:e,layoutConfig:n,links:s}=t;return{filterSets:e,layoutConfig:n,links:s,version:2}}const Dr={exportLayout:uR,getDefaultLayout:hR,normalizeLayout:ap},wr=J.module("DownloadServiceWorkerUtils"),dp=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(),wr.info("Registering service worker on ",e,n)}).catch(n=>{wr.error("Failed to register service worker",n)})}):wr.info("Service worker is not supported."))}static async getServiceWorker(){if("serviceWorker"in navigator){const e=(await navigator.serviceWorker.getRegistrations()).find(n=>n.scope.endsWith(dp.DOWNLOAD_PATH));if(e&&e.active)return wr.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 Xr=dp;Xr.DOWNLOAD_PATH="/download/";const cp={react:de},mR=zp(cp),pR=qp({requires:mR}),gR=Yp.createRequires(cp),fR=Kp({requires:gR}),CR=J.module("PluginUtils");class Ma{static loadComponentPlugin(e){if("".split(",").includes(e)){const o=de.lazy(()=>ff(()=>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(pR,{url:s,render:({err:l,Component:a})=>{if(l!=null&&l!==""){const d=`Error loading plugin ${e} from ${s} due to ${l}`;return CR.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 fR(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=J.module("AppMainContainer");class Io 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",Io.handleWindowBeforeUnload)}componentDidUpdate(e){const{dashboardData:n}=this.props;e.dashboardData!==n&&this.handleDataChange(n)}componentWillUnmount(){this.deinitWidgets(),window.removeEventListener("beforeunload",Io.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(km.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=Dr.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}=Dr.normalizeLayout(o);s({layoutConfig:l}),n(Sn,{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 Dr.getDefaultLayout(e,n!==void 0),{updateDashboardData:r,updateWorkspaceData:l}=this.props;l({layoutConfig:i}),r(Sn,{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:Xr.getServiceWorker,loadPlugin:this.handleLoadTablePlugin,localDashboardId:n,makeModel:()=>oR(i,e.metadata,s)}}hydrateChart(e,n){const{connection:s}=this.props;return{...e,localDashboardId:n,makeModel:()=>{const{metadata:i,panelState:o}=e;return iR(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 T("div",{className:Y("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:T("div",{className:"app-main-top-nav-menus",children:[h("img",{src:Jm,alt:"Deephaven Data Labs",width:"115px",className:"ml-1"}),T("div",{children:[T(U,{kind:"ghost",className:"btn-panels-menu",icon:pf,onClick:()=>{},children:["Controls",h(Ld,{handleControlSelect:this.handleControlSelect,handleToolSelect:this.handleToolSelect,onClearFilter:this.handleClearFilter})]}),d&&T(U,{kind:"ghost",className:"btn-panels-menu btn-show-panels","data-testid":"app-main-panels-button",onClick:this.handleWidgetMenuClick,icon:gf,children:["Panels",h(tl,{isShown:u,className:"panels-menu-popper",onExited:this.handleWidgetsMenuClose,closeOnBlur:!0,interactive:!0,children:h(sR,{widgets:p,onExportLayout:this.handleExportLayoutClick,onImportLayout:this.handleImportLayoutClick,onResetLayout:this.handleResetLayoutClick,onSelect:this.handleWidgetSelect})})]}),h(U,{kind:"ghost",className:Y("btn-settings-menu",{"text-warning":s.operateAs!==s.name}),onClick:this.handleSettingsMenuShow,icon:h(Z,{icon:_o,transform:"grow-3 right-1 down-1"}),tooltip:"User Settings"})]})]})}),T(Zb,{emptyDashboard:h(rR,{onAutoFillClick:this.handleAutoFillClick}),id:Sn,layoutConfig:l,onGoldenLayoutChange:this.handleGoldenLayoutChange,onLayoutConfigChange:this.handleLayoutConfigChange,onLayoutInitialized:this.openNotebookFromURL,hydrate:this.hydrateDefault,children:[h(dy,{hydrate:this.hydrateGrid,getDownloadWorker:Xr.getServiceWorker,loadPlugin:this.handleLoadTablePlugin}),h(sy,{hydrate:this.hydrateChart}),h(iy,{}),h(ry,{hydrateConsole:Io.hydrateConsole,notebooksUrl:new URL("/notebooks/",`${window.location}`).href}),h(ly,{}),h(Cy,{hydrate:this.hydratePandas}),h(fy,{}),h(gy,{}),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 SR=t=>({activeTool:pl(t),dashboardData:Yt(t,Sn),layoutStorage:tR(t),plugins:nS(t),connection:mE(t,Sn),session:ai(t,Sn)?.session,sessionConfig:ai(t,Sn)?.config,user:ru(t),workspace:ml(t),serverConfigValues:nR(t)}),bR=vt(SR,{setActiveTool:fl,updateDashboardData:Vn,updateWorkspaceData:Ru})(Xp(Io));function wR(){return T("div",{className:"app",children:[h(bR,{}),h(kh,{})]})}const TR=J.module("LocalWorkspaceStorage"),wo=class{static async makeDefaultWorkspaceData(t,e){const{filterSets:n,links:s,layoutConfig:i}=await Dr.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:Qe.DEFAULT_FORMAT_STRING},truncateNumbersWithPound:!1,defaultNotebookSettings:{isMinimapEnabled:!1}},layoutConfig:i,closed:[{}],links:s,filterSets:n}}static async makeDefaultWorkspace(t,e){return{data:await wo.makeDefaultWorkspaceData(t,e)}}constructor(t){this.layoutStorage=t}async load(t){try{return JSON.parse(localStorage.getItem(wo.STORAGE_KEY)??"")}catch{return TR.info("Unable to load workspace data, initializing to default data"),wo.makeDefaultWorkspace(this.layoutStorage,t)}}async save(t){return localStorage.setItem(wo.STORAGE_KEY,JSON.stringify(t)),t}};let hp=wo;hp.STORAGE_KEY="deephaven.WorkspaceStorage";class vR extends Error{constructor(){super(...arguments),this.isNoConsolesError=!0}}function ER(t){return t.isNoConsolesError}const ks=J.module("SessionUtils");var up=(t=>(t.ANONYMOUS="anonymous",t.PARENT="parent",t))(up||{});function yR(){return new URL("/jsapi",`${window.location}`)}function mp(){const t=yR();return`${t.protocol}//${t.host}`}function RR(){switch(new URLSearchParams(window.location.search).get("authProvider")){case"parent":return"parent";default:return"anonymous"}}function IR(){const t=mp();return ks.info(`Starting connection to '${t}'...`),new I.IdeConnection(t)}async function FR(t){ks.info("Getting console types...");const e=await t.getConsoleTypes();if(ks.info("Available types:",e),e.length===0)throw new vR("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 DR(){const t=mp();return ks.info("createCoreClient",t),new I.CoreClient(t)}async function NR(){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 _R(t){switch(t){case"parent":return NR();case"anonymous":return{type:I.CoreClient.LOGIN_TYPE_ANONYMOUS};default:throw new Error(`Unknown auth type: ${t}`)}}class MR{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 mo=J.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){mo.debug2("doRefresh",this.root),t(this.fetchData())}refresh(){mo.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 Zr;return this.currentViewportData=n,this.sendUpdate(),n}));e.catch(n=>{ye.isCanceled(n)||mo.error("Error updating viewport",n)}),this.viewportUpdatePromise=e}refreshInternal(){try{this.refresh()}catch(t){ye.isCanceled(t)||mo.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,mo.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 pp=ka;pp.REFRESH_DEBOUNCE=50;const kR=J.module("GrpcFileStorage"),gp=class{constructor(t,e=""){this.tables=[],this.refreshTables=Ln(()=>{this.tables.forEach(n=>n.refresh())},gp.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 pp(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 kR.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 fp=gp;fp.REFRESH_THROTTLE=150;const xs=J.module("AppInit");async function xR(){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 OR(t){let e;try{e=await FR(t)}catch(n){if(!ER(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.30.1",navigator.userAgent);const F=DR(),D=RR();xs.info(`Login using auth type ${D}...`),await F.login(await _R(D));const N=await xR(),P=await(D===up.ANONYMOUS&&F.getAsIdeConnection==null?IR():F.getAsIdeConnection());P.addEventListener(I.IdeConnection.HACK_CONNECTION_FAILURE,Se=>{const{detail:Re}=Se;xs.error("Connection failure",`${JSON.stringify(Re)}`),f(`Unable to connect: ${Re.details??"Unknown Error"}`)});const H=await OR(P),A="user",q=F.getStorageService(),B=new MR(q,"/layouts"),K=new fp(q,"/notebooks"),x=new hp(B),O=new Ny,G=await x.load({isConsoleAvailable:H!==void 0}),{data:ee}=G,{settings:ne}=ee;ne.defaultDecimalFormatOptions===void 0&&(ne.defaultDecimalFormatOptions={defaultFormatString:ke.DEFAULT_FORMAT_STRING}),ne.defaultIntegerFormatOptions===void 0&&(ne.defaultIntegerFormatOptions={defaultFormatString:Qe.DEFAULT_FORMAT_STRING}),ne.truncateNumbersWithPound===void 0&&(ne.truncateNumbersWithPound=!1);const{shortcutOverrides:V={}}=ne,X=fn.isMacPlatform?V.mac??{}:V.windows??{};Object.entries(X).forEach(([Se,Re])=>{qe.get(Se)?.setKeyState(Re)});const se={filterSets:ee.filterSets,links:ee.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(O),i(Sn,se),o(K),r(B),l(Sn,P),H!==void 0&&a(Sn,H),d(N),c(he),m(x),u(G)}catch(F){xs.error(F),f(F)}},[n,s,i,o,r,l,a,d,c,u,m,p]),v=b.exports.useCallback(()=>{document.fonts!=null?document.fonts.ready.then(()=>{S(!1)}):S(!1)},[]);b.exports.useEffect(function(){w(),v()},[w,v]);const y=e==null&&g==null||C,E=!y&&g==null,R=g!=null?`${g}`:null;return T(be,{children:[E&&h(wR,{}),h(Jr,{isLoading:y,isLoaded:E,errorMessage:R}),T("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 AR=t=>({workspace:ml(t),workspaceStorage:JC(t)}),uh=vt(AR,{setActiveTool:fl,setCommandHistoryStorage:oS,setDashboardData:Xu,setFileStorage:rS,setLayoutStorage:_y,setDashboardConnection:pE,setDashboardSessionWrapper:gE,setPlugins:aS,setUser:sS,setWorkspace:yu,setWorkspaceStorage:iS,setServerConfigValues:dS})(Pd);function LR(){return h(jp,{basename:"/ide/",children:T(Qp,{children:[h($d,{exact:!0,path:"/",component:uh}),h($d,{path:"/notebook/:notebookPath+",component:uh}),h(Zp,{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 PR(){"serviceWorker"in navigator&&navigator.serviceWorker.getRegistrations().then(t=>{t.forEach(e=>{e.scope.endsWith("/download/")||e.unregister()})})}function GR(){return b.exports.useEffect(()=>{PR(),Xr.registerOnLoaded(),lt.init({getWorker:()=>new Cf}),window["__react-beautiful-dnd-disable-dev-warnings"]=!0},[]),h(ph,{store:Cl,children:h(LR,{})})}export{GR as AppRoot,GR as default};
42
+ //# sourceMappingURL=AppRoot.7498c843.js.map