@deephaven/code-studio 0.35.1-beta.0 → 0.35.1-beta.2

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,43 +0,0 @@
1
- import{A as b,B as I,H as J,P as Hm,C as l,D as ft,F as $,R as Bi,G as Q,I as _e,J as ge,K as Ye,L as Vm,M as Bm,N as Rl,O as tr,Q as Um,E as xl,S as $m,T as il,U as fe,V as ol,W as Ls,X as Th,Y as it,Z as Il,_ as Wm,$ as Gm,a0 as zm,a1 as Km,a2 as me,a3 as Ac,a4 as Dl,a5 as qm,a6 as Ym,a7 as Eh,a8 as He,a9 as al,aa as nr,ab as Xm,ac as Ln,ad as Zm,ae as Qm,af as Jm,ag as eg,ah as rl,ai as tg,aj as ng,ak as sg,al as Lc,am as ig,an as Pc,ao as og,ap as ag,aq as rg,ar as lg,as as cg,at as dg,au as Ct,av as yh,aw as hg,ax as Rh,ay as ug,az as xh,aA as mg,aB as gg,aC as pg,aD as fg,aE as Cg,aF as Sg,aG as bg,aH as wg,aI as vg,aJ as Tg,aK as _c,aL as Eg}from"./vendor-44bb27a6.js";import{e as Qn,l as An,K as dn,a as jc,R as yg,b as Ds,W as Rg}from"./monaco-a26f85af.js";import{T as ze,L as Z,M as zi,a as Ki,b as Mo,v as Ih,c as yn,d as Dh,e as Pn,f as xg,g as Ig,h as ko,i as Dg,j as qi,k as Fl,l as Fg,m as ll,n as Ng,o as Fh,p as Nl,q as Nh,r as Hc,s as Mg,t as kg,u as Og,w as Ag,x as Jt,y as As,z as Mh,A as Jn,B as sr,C as Ui,D as Lg,E as Pg,F as Vc,G as Da,H as Bc,I as kh,J as _g,K as Oo,N as Oh,O as jg,P as Hg,Q as Ml,R as kl,S as Fa,U as Un,V as Vg,W as Bg,X as Ug,Y as $g,Z as Wg,_ as Ol,$ as Ps,a0 as Uc,a1 as Ao,a2 as Al,a3 as Ll,a4 as Gg,a5 as zg,a6 as Na,a7 as Kg,a8 as Pl,a9 as Ah,aa as si,ab as qg,ac as Yg,ad as Xg,ae as Zg,af as Qg,ag as Jg,ah as $c,ai as Lr,aj as ep,ak as tp,al as np,am as sp,an as ip,ao as Lh,ap as op,aq as ap,ar as rp,as as Ph,at as lp,au as cp,av as dp,aw as hp,ax as up,ay as mp,az as gp,aA as pp,aB as fp,aC as Cp,aD as Sp,aE as bp,aF as _h,aG as wp,aH as cl,aI as dl,aJ as vp,aK as Tp,aL as Ep,aM as yp,aN as Rp,aO as xp,aP as Ip,aQ as Dp,aR as Fp,aS as Np,aT as Mp,aU as Wc,aV as kp,aW as Op,aX as Ap}from"./index-b28f4328.js";import{P as Ma,b as Lp,h as Pp,p as _p,o as jp,s as Hp,t as Vp,c as Pr}from"./plotly-a0b86fc0.js";import"./helpers-042e6b4d.js";class Bp extends b.Component{static propTypes={children:I.node.isRequired,options:I.shape({}),className:I.string,timeout:I.number,onEntered:I.func,onExited:I.func,isShown:I.bool,closeOnBlur:I.bool,interactive:I.bool,referenceObject:I.shape({}),"data-testid":I.string};static defaultProps={options:{},className:"",timeout:ze.transitionMs,onEntered(){},onExited(){},isShown:!1,interactive:!1,closeOnBlur:!1,referenceObject:null,"data-testid":void 0};constructor(e){super(e),this.handleEnter=this.handleEnter.bind(this),this.handleExit=this.handleExit.bind(this),this.handleBlur=this.handleBlur.bind(this),this.element=document.createElement("div"),this.element.className="popper-container",this.container=J.createRef(),this.rAF=0;const{isShown:t}=this.props;this.state={show:t,popper:null}}componentDidUpdate(e){const{isShown:t}=this.props;e.isShown!==t&&(t?(cancelAnimationFrame(this.rAF),this.rAF=window.requestAnimationFrame(()=>{this.show()})):this.hide())}componentWillUnmount(){this.destroyPopper(!1)}element;container;rAF;getVisibleElement(e){return e==null||e.clientHeight>0||e.clientWidth>0?e:this.getVisibleElement(e.parentElement)}initPopper(){let{popper:e}=this.state;const{closeOnBlur:t,referenceObject:n}=this.props;if(e||this.container.current===null)return;let{options:s}=this.props;s={placement:"auto",modifiers:{preventOverflow:{boundariesElement:"viewport"}},...s},document.body.appendChild(this.element);let i=this.getVisibleElement(this.container.current);i==null&&(i=this.container.current),e=new Hm(n||i,this.element,s),e.scheduleUpdate(),cancelAnimationFrame(this.rAF),this.rAF=window.requestAnimationFrame(()=>{if(t&&!this.element.contains(document.activeElement)){const o=this.element.firstElementChild;o instanceof HTMLElement&&o.focus()}}),this.setState({popper:e})}destroyPopper(e=!0){cancelAnimationFrame(this.rAF);const{popper:t}=this.state;t&&(t.destroy(),document.body.contains(this.element)&&document.body.removeChild(this.element),e&&this.setState({popper:null}))}show(){this.initPopper(),this.setState({show:!0})}hide(){this.setState({show:!1})}scheduleUpdate(){const{popper:e}=this.state;e&&e.scheduleUpdate()}handleBlur(e){e.relatedTarget instanceof HTMLElement&&(this.element.contains(e.relatedTarget)||this.hide())}handleEnter(){const{onEntered:e}=this.props;e()}handleExit(){const{onExited:e}=this.props,{show:t}=this.state;t||this.destroyPopper(),e()}renderContent(){const{className:e,children:t,timeout:n,interactive:s,closeOnBlur:i}=this.props,{show:o}=this.state;return l.jsx(ft,{in:o,timeout:n,classNames:"popper-transition",onEntered:this.handleEnter,onExited:this.handleExit,children:l.jsx("div",{onClick:a=>{a.stopPropagation()},onKeyDown:a=>{a.key==="Escape"&&this.hide()},className:$("popper",{interactive:s},e),onBlur:i?this.handleBlur:void 0,tabIndex:i?-1:void 0,role:"presentation",children:l.jsxs("div",{className:"popper-content",children:[t,l.jsx("div",{className:"popper-arrow","x-arrow":""})]})})})}render(){const{popper:e}=this.state,{"data-testid":t}=this.props;return l.jsx("div",{className:"popper-parent-container",ref:this.container,style:{display:"none"},"data-testid":t,children:e&&Bi.createPortal(this.renderContent(),this.element)})}}const hi=Bp,Up=Z.module("Tooltip");class Lt extends b.Component{static defaultTimeout=500;static defaultReshowTimeout=100;static triggerReshowThreshold=300;static shownTooltipCount=0;static lastHiddenTime=Date.now();static defaultProps={interactive:!1,options:{},popperClassName:"",reshowTimeout:Lt.defaultReshowTimeout,timeout:Lt.defaultTimeout,onEntered:()=>{},onExited:()=>{},"data-testid":void 0};static handleHidden(){Lt.shownTooltipCount-=1,Lt.shownTooltipCount===0&&(Lt.lastHiddenTime=Date.now())}static handleShown(){Lt.shownTooltipCount+=1}constructor(e){super(e),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleWindowMouseMove=this.handleWindowMouseMove.bind(this),this.handleWheel=this.handleWheel.bind(this),this.handleTimeout=this.handleTimeout.bind(this),this.handleExited=this.handleExited.bind(this),this.stopShowingTooltip=this.stopShowingTooltip.bind(this),this.container=J.createRef(),this.popper=J.createRef(),this.parent=null,this.timer=null,this.state={isShown:!1}}componentDidMount(){this.startListening();const{timeout:e}=this.props;e===0&&this.show()}componentDidUpdate(e,t){const{isShown:n}=t,{isShown:s}=this.state;s!==n&&(s?Lt.handleShown():Lt.handleHidden())}componentWillUnmount(){this.stopListening(),this.stopListeningWindow(),this.stopTimer();const{isShown:e}=this.state;e&&Lt.handleHidden()}container;popper;parent;timer;startListening(){if(!this.container.current||!this.container.current.parentElement){Up.error("Tooltip doesn't have a container or a parent set!");return}this.parent=this.container.current.parentElement,this.parent.addEventListener("mousemove",this.handleMouseMove),this.parent.addEventListener("mouseleave",this.handleMouseLeave),this.parent.addEventListener("mousedown",this.stopShowingTooltip)}stopListening(){this.parent&&(this.parent.removeEventListener("mousemove",this.handleMouseMove),this.parent.removeEventListener("mouseleave",this.handleMouseLeave),this.parent.removeEventListener("mousedown",this.stopShowingTooltip))}startListeningWindow(){window.addEventListener("mousemove",this.handleWindowMouseMove,!0),window.addEventListener("contextmenu",this.stopShowingTooltip,!0),window.addEventListener("wheel",this.handleWheel)}stopListeningWindow(){window.removeEventListener("mousemove",this.handleWindowMouseMove,!0),window.removeEventListener("contextmenu",this.stopShowingTooltip,!0),window.removeEventListener("wheel",this.handleWheel)}handleMouseMove(){this.startTimer()}handleWheel(){const{isShown:e}=this.state;this.popper.current&&this.parent&&e&&!this.popper.current.element.matches(":hover")&&!this.parent.matches(":hover")&&(this.stopTimer(),this.hide())}handleMouseLeave(){const{isShown:e}=this.state;this.stopTimer();const{interactive:t}=this.props;!t&&e&&this.hide()}handleTimeout(){this.show()}handleWindowMouseMove(e){const t=e.clientX,n=e.clientY,{isShown:s}=this.state;if(!this.popper.current||!this.parent)return;const i=this.popper.current.element.getBoundingClientRect(),o=this.parent.getBoundingClientRect();t>=i.left&&t<=i.left+i.width&&n>=i.top&&n<=i.top+i.height?this.handleMouseMove():t>=o.left&&t<=o.left+o.width&&n>=o.top&&n<=o.top+o.height?this.handleMouseMove():s&&(this.stopTimer(),this.hide())}startTimer(){this.stopTimer();const{timeout:e,reshowTimeout:t}=this.props;let n=e;(Lt.shownTooltipCount>0||Date.now()-Lt.lastHiddenTime<Lt.triggerReshowThreshold)&&(n=t),this.timer=window.setTimeout(this.handleTimeout,n)}stopTimer(){this.timer!=null&&(clearTimeout(this.timer),this.timer=null)}show(){const{isShown:e}=this.state;if(this.stopTimer(),!e){this.popper.current?.show(),this.setState({isShown:!0});const{interactive:t}=this.props;t&&this.startListeningWindow()}}hide(){this.popper.current?.hide(),this.stopListeningWindow()}update(){this.popper.current?.scheduleUpdate()}handleExited(){this.setState({isShown:!1});const{onExited:e}=this.props;e()}stopShowingTooltip(){const{isShown:e}=this.state;this.stopTimer(),e&&this.hide()}render(){const{interactive:e,children:t,referenceObject:n,popperClassName:s,"data-testid":i,onEntered:o}=this.props,{isShown:a}=this.state;let{options:r}=this.props;return r={placement:"bottom",...r},l.jsx("div",{ref:this.container,style:{display:"none"},"data-testid":i,children:l.jsx(hi,{className:$(s),options:r,ref:this.popper,onEntered:o,onExited:this.handleExited,interactive:e,referenceObject:n,children:l.jsxs("div",{className:"tooltip-content",children:[" ",a&&t]})})})}}const tt=Lt;function ir(d){const{children:e,className:t,style:n,"data-testid":s}=d;return l.jsx("div",{className:$("btn-group",t),style:n,role:"group","data-testid":s,children:e})}ir.displayName="ButtonGroup";ir.propTypes={children:I.node.isRequired,className:I.string,style:I.object,"data-testid":I.string};ir.defaultProps={className:null,style:{},"data-testid":void 0};const $p=["primary","secondary","tertiary","success","danger","inline","ghost"],Wp=["group-end"];function Gp(d,e){switch(d){case"primary":return"btn-primary";case"secondary":return"btn-outline-primary";case"tertiary":return"btn-secondary";case"success":return"btn-success";case"danger":return"btn-danger";case"inline":return"btn-inline";case"ghost":return $("btn-link",{"btn-link-icon":e,"btn-link-icon-only":e})}}function zp(d){switch(d){case"group-end":return $("pl-2","pr-3")}}const or=J.forwardRef((d,e)=>{const{kind:t,variant:n,type:s,tooltip:i,icon:o,disabled:a=!1,active:r,onClick:c,onContextMenu:h,onMouseDown:u,onMouseUp:m,onMouseEnter:g,onMouseLeave:p,onKeyDown:C,className:f,style:S,children:v,tabIndex:w,"data-testid":T,"aria-label":y}=d,E=Boolean(o&&v==null),D=Gp(t,E);let F;n&&(F=zp(n));let N;o&&(N=J.isValidElement(o)?o:l.jsx(Q,{icon:o}));let _;i!==void 0&&(_=typeof i=="string"?l.jsx(tt,{children:i}):i);let P=y;y===void 0&&E&&i!=null&&typeof i=="string"&&(P=i);const U=l.jsxs("button",{"data-testid":T,ref:e,type:s,className:$("btn",D,F,{active:r},f),onClick:c,onContextMenu:h,onMouseUp:m,onMouseDown:u,onMouseEnter:g,onMouseLeave:p,onKeyDown:C,style:S,disabled:a,tabIndex:w,"aria-label":P,children:[o&&N,v,i!=null&&!a&&_]});return a?l.jsxs("span",{className:"btn-disabled-wrapper",children:[U,i!==void 0&&_]}):U});or.displayName="Button";or.propTypes={kind:I.oneOf($p).isRequired,variant:I.oneOf(Wp),type:I.oneOf(["submit","reset","button"]),tooltip(d){const{tooltip:e,icon:t,children:n}=d;return e===void 0&&t!=null&&n==null?new Error("Tooltip is required for icon only buttons"):null},icon(d){const{children:e,icon:t}=d;return t==null&&e==null?new Error("Icon is required if no children are provided"):e==null&&!J.isValidElement(t)&&(t==null||t.iconName===""||t.iconName==null)?new Error("Icon must be react element or fontawesome IconDefinition"):null},disabled:I.bool,active:I.bool,onClick(d){const{onClick:e,type:t}=d;return t==="button"&&typeof e!="function"?new Error("type button requires an onClick function"):e!==void 0&&typeof e!="function"?new Error("onClick must be a function"):null},onContextMenu:I.func,onMouseUp:I.func,onMouseDown:I.func,onMouseEnter:I.func,onMouseLeave:I.func,onKeyDown:I.func,tabIndex:I.number,children:I.node,className:I.string,style:I.object,"data-testid":I.string};or.defaultProps={type:"button",onClick:void 0,onContextMenu:void 0,onMouseUp:void 0,onMouseDown:void 0,onMouseEnter:void 0,onMouseLeave:void 0,onKeyDown:void 0,variant:void 0,tooltip:void 0,icon:void 0,disabled:!1,active:void 0,tabIndex:void 0,children:void 0,className:void 0,style:{},"data-testid":void 0};const B=or;function Kp({className:d,icon:e,isOpen:t,subtitle:n,title:s}){return l.jsx(zi,{isOpen:t,className:d,children:l.jsx(Ki,{children:l.jsxs("div",{className:"info-modal",children:[e!=null&&l.jsx("div",{className:"message-icon",children:l.jsx(Q,{icon:e})}),l.jsx("div",{className:"message-header",children:s}),n!=null&&l.jsx("div",{className:"message-content",children:n})]})})})}function _l({className:d="modal-footer",children:e,"data-testid":t}){return l.jsx("div",{className:d,"data-testid":t,children:e})}function ci(d){const{isOpen:e,headerText:t,bodyText:n,onCancel:s,onConfirm:i,onDiscard:o,onModalDisable:a,cancelButtonText:r="Cancel",confirmButtonText:c="Okay",discardButtonText:h="Discard",isConfirmDanger:u=!1,children:m,"data-testid":g}=d,p=b.useRef(null),C=b.useRef(null),f=b.useCallback(()=>{C.current!==null&&C.current.checked&&a&&a(),i()},[i,a]),S=b.useCallback(()=>{p.current?.focus()},[]);let v="";return e&&(v=typeof n=="function"?n():n),l.jsxs(zi,{isOpen:e,className:"theme-bg-light",onOpened:S,children:[l.jsx(Mo,{closeButton:!1,children:t}),l.jsx(Ki,{children:v}),l.jsxs(_l,{children:[a&&l.jsxs("div",{className:"custom-control custom-checkbox form-group mr-auto",children:[l.jsx("input",{type:"checkbox",className:"custom-control-input",id:"move-confirmation-checkbox",defaultChecked:!1,ref:C,"data-testid":g!==void 0?`${g}-checkbox-confirm`:void 0}),l.jsx("label",{className:"custom-control-label",htmlFor:"move-confirmation-checkbox",children:"Don't ask me again"})]}),o&&l.jsx(B,{kind:"secondary",className:"mr-auto","data-dismiss":"modal",onClick:o,"data-testid":g!==void 0?`${g}-btn-discard`:void 0,children:h}),s&&l.jsx(B,{kind:"secondary","data-dismiss":"modal",onClick:s,"data-testid":g!==void 0?`${g}-btn-cancel`:void 0,children:r}),l.jsxs(ir,{children:[l.jsx(B,{kind:u?"danger":"primary",onClick:f,ref:p,"data-testid":g!==void 0?`${g}-btn-confirm`:void 0,children:c}),m]})]})]})}ci.propTypes={isOpen:I.bool.isRequired,headerText:I.string.isRequired,bodyText:I.oneOfType([I.string,I.func]).isRequired,onCancel:I.func,onConfirm:I.func.isRequired,onDiscard:I.func,onModalDisable:I.func,cancelButtonText:I.string,confirmButtonText:I.string,discardButtonText:I.string,children:I.node,"data-testid":I.string};ci.defaultProps={children:void 0,cancelButtonText:"Cancel",confirmButtonText:"Okay",discardButtonText:"Discard",onCancel:void 0,onDiscard:void 0,onModalDisable:void 0,"data-testid":void 0};const ar=J.forwardRef((d,e)=>{const{children:t,className:n,disabled:s,onClick:i,style:o,id:a}=d;return l.jsx("button",{ref:e,type:"button",className:$("btn",n),onClick:i,style:o,disabled:s,id:a,children:t})});ar.displayName="Button";ar.propTypes={children:I.node,className:I.string,disabled:I.bool,onClick:I.func,style:I.shape({}),id:I.string};ar.defaultProps={children:null,className:"",disabled:!1,onClick:()=>null,style:{},id:""};const Gc=ar;function jl({className:d,isFlipped:e,children:t,"data-testid":n}){const s=r=>{if(t.length!==2)throw new Error("CardFlip requires 2 children to function");return t[r]},i=b.useRef(null),o=b.useCallback(r=>{r.target===r.currentTarget&&document.body.classList.add("card-flip--is-flipping")},[]),a=b.useCallback(r=>{r.target===r.currentTarget&&document.body.classList.remove("card-flip--is-flipping")},[]);return b.useEffect(function(){if(!i.current)throw Error("ref undefined");i.current.addEventListener("transitionstart",o);const c=i.current;return function(){if(c!=null)return c.removeEventListener("transitionstart",o)}},[o]),l.jsxs("div",{className:$(d,{"card-flip--show-front":e,"card-flip--show-back":!e}),"data-testid":n,children:[l.jsx("div",{className:"card-flip--back",children:s(0)}),l.jsx("div",{ref:i,className:"card-flip--front",onTransitionEnd:a,children:s(1)})]})}function _r(d){return d.then!==void 0}class Qs{static actionsDisabled=!1;static disableAllActions(){Qs.actionsDisabled=!0}static enableAllActions(){Qs.actionsDisabled=!1}static isContextActionEvent(e){return Array.isArray(e.contextActions)}static compareActions(e,t){return e.group!==t.group?(e.group??0)>(t.group??0)?1:-1:e.order!==t.order?(e.order??0)>(t.order??0)?1:-1:e.title!==t.title?(e.title??"")>(t.title??"")?1:-1:e!==t?e>t?1:-1:0}static sortActions(e){if(e==null||!Array.isArray(e))return[];const t=e.slice();return t.sort(Qs.compareActions),t}static isMacPlatform(){const{platform:e}=window.navigator;return e.startsWith("Mac")}static getModifierKey(){return Qs.isMacPlatform()?"metaKey":"ctrlKey"}static isModifierKeyDown(e){const t=Qs.getModifierKey();return e[t]}static getMenuItems(e,t=!0){let n=[],s=e;Array.isArray(s)||(s=[s]);for(let i=0;i<s.length;i+=1){const o=s[i];let a;typeof o=="function"?a=o():a=o,a!=null&&(a instanceof Promise?t&&n.push(a):Array.isArray(a)?n=n.concat(a):n.push(a))}return n=n.filter(i=>i.title!==void 0||i.then!=null||i.menuElement),n}static getNextMenuItem(e,t,n){let s=e;s<0&&t<0&&(s=n.length);for(let i=1;i<n.length+1;i+=1){const o=(s+t*i+n.length)%n.length,a=n[o];if(!(a instanceof Promise)&&a.disabled!==!0)return o}return e}}const Ve=Qs,zc=Z.module("GlobalContextAction");class qp extends b.Component{constructor(e){super(e),this.handleContextMenu=this.handleContextMenu.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}componentDidMount(){document.body.addEventListener("contextmenu",this.handleContextMenu),document.body.addEventListener("keydown",this.handleKeyDown)}componentWillUnmount(){document.body.removeEventListener("contextmenu",this.handleContextMenu),document.body.removeEventListener("keydown",this.handleKeyDown)}handleContextMenu(e){const t=e;t.contextActions==null&&(t.contextActions=[]);const{action:n}=this.props;n.title==null&&!n.menuElement||(t.contextActions==null&&(t.contextActions=[]),t.contextActions.push(n),zc.debug("Received context menu event at global action! Menu items are now: ",t.contextActions))}handleKeyDown(e){const{action:t}=this.props;!Ve.actionsDisabled&&t.shortcut!==void 0&&t.shortcut.matchesEvent(e)&&(zc.debug("Global hotkey matched!",e),t.action?.(e),e.preventDefault(),e.stopPropagation())}render(){return null}}const Yp=qp;class Xp extends b.Component{render(){const{actions:e,"data-testid":t}=this.props,n=[];for(let s=0;s<e.length;s+=1){const i=e[s],{shortcut:o}=i;if(i.title!=null||i.menuElement||o){const a=l.jsx(Yp,{action:i,"data-testid":t},`${i.title}.${o?.id}`);n.push(a)}}return n}}const Zp=Xp;const na=Z.module("ContextActions");class Qp extends b.Component{static groups={default:null,high:100,medium:5e3,low:1e4,global:1e5,edit:100};static triggerMenu(e,t,n,s){if(s.length===0)return;const i=new MouseEvent("contextmenu",{clientX:t,clientY:n,bubbles:!0,cancelable:!0});i.contextActions=s,e.dispatchEvent(i)}constructor(e){super(e),this.handleContextMenu=this.handleContextMenu.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.container=J.createRef(),this.state={globalActions:[],keyboardActions:[]}}static getDerivedStateFromProps(e){if(e.actions==null||!Array.isArray(e.actions))return{globalActions:[],keyboardActions:[]};const t=e.actions.filter(s=>!_r(s)&&typeof s!="function"&&s.isGlobal),n=e.actions.filter(s=>!_r(s)&&typeof s!="function"&&(s.isGlobal===void 0||!s.isGlobal)&&s.shortcut!=null);return{globalActions:t,keyboardActions:n}}componentDidMount(){this.container.current?.parentElement&&(this.container.current.parentElement.addEventListener("contextmenu",this.handleContextMenu),this.container.current.parentElement.addEventListener("keydown",this.handleKeyDown))}componentWillUnmount(){this.container.current?.parentElement&&(this.container.current.parentElement.removeEventListener("contextmenu",this.handleContextMenu),this.container.current.parentElement.removeEventListener("keydown",this.handleKeyDown))}container;handleContextMenu(e){const{ignoreClassNames:t=[]}=this.props;if(t.length>0){let s=e.target;for(;s!=null;){const{classList:i}=s,o=t.find(a=>i.contains(a));if(o!==void 0){na.debug2(`Contextmenu event ignored based on the target className "${o}"`);return}s=s.parentElement}}if(Ve.isContextActionEvent(e)||(e.contextActions=[]),!Ve.isContextActionEvent(e))return;const{actions:n}=this.props;if(n!=null){let s=n;Array.isArray(s)&&(s=s.filter(i=>_r(i)||typeof i=="function"||i.isGlobal===void 0||!i.isGlobal)),e.contextActions=e.contextActions.concat(s)}na.debug("Received context menu event! Menu items are now: ",e.contextActions)}handleKeyDown(e){const{keyboardActions:t}=this.state;for(let n=0;n<t.length;n+=1){const s=t[n];!Ve.actionsDisabled&&s.shortcut!=null&&s.shortcut.matchesEvent(e)&&(na.debug("Context hotkey matched!",e),s.action?.(e),e.stopPropagation(),e.preventDefault(),na.debug2("Matched hotkey returned false, key event not consumed"))}}render(){const{"data-testid":e}=this.props,{globalActions:t}=this.state;return l.jsx("div",{className:"context-actions-listener",ref:this.container,"data-testid":e,children:l.jsx(Zp,{actions:t})})}}const ie=Qp,Hl=J.forwardRef((d,e)=>{function t(f){const{menuItem:S,onMenuItemClick:v}=d;v(S,f)}function n(f){const{menuItem:S,onMenuItemMouseMove:v}=d;v(S,f)}function s(f){const{menuItem:S,onMenuItemContextMenu:v}=d;v(S,f)}function i(f,S,v){if(typeof f.type=="string")return f;const{closeMenu:w,menuItem:T,isKeyboardSelected:y,isMouseSelected:E,"data-testid":D}=d,F={menuItem:T,closeMenu:w,isKeyboardSelected:y,isMouseSelected:E,iconElement:S,displayShortcut:v,"data-testid":D};return J.cloneElement(f,{forwardedProps:F})}const{children:o,menuItem:a,isKeyboardSelected:r=!1,isMouseSelected:c=!1,"data-testid":h}=d,u=a.shortcut?.getDisplayText();let m=null;if(a.icon){const f=a.icon;if(J.isValidElement(f))m=f;else{let S;a.iconColor!=null&&(a.disabled===void 0||!a.disabled)&&(S={color:a.iconColor}),m=l.jsx(Q,{icon:f,style:S})}}let g=null;const p=Boolean(o);a.actions&&(g=l.jsx(Q,{icon:Ih}));let C=null;if(a.menuElement)C=l.jsx("div",{className:"custom-menu-item",onMouseMove:n,children:i(a.menuElement,m,u)});else{const f=a.disabled,S=a.iconOutline;C=l.jsx("button",{type:"button",className:$("btn-context-menu",{disabled:f},{active:(p||c)&&(f===void 0||!f)},{"keyboard-active":r&&(f===void 0||!f)}),onClick:t,onMouseMove:n,onContextMenu:s,title:a.description??"",children:l.jsxs("div",{className:"btn-context-menu-wrapper",children:[l.jsx("span",{className:$("icon",{outline:S}),children:m}),l.jsx("span",{className:"title",children:a.title}),u!==void 0&&l.jsx("span",{className:"shortcut",children:u}),g&&l.jsx("span",{className:$("submenu-indicator",{disabled:f}),children:g})]})})}return l.jsxs("div",{className:"context-menu-item",ref:e,"data-testid":h,children:[o,C]})});Hl.displayName="ContextMenuItem";Hl.defaultProps={children:null,isKeyboardSelected:!1,isMouseSelected:!1,"data-testid":void 0};const jh=Hl,Fe=Object.freeze([]),qn=new Map;class Jp extends Error{isCanceled=!0}const $i=Jp;class rr{static isDark(e){const t=document.createElement("div");t.style.display="none",t.style.color=e;const n=getComputedStyle(document.body.appendChild(t)).color,s=n.match(/\d+/g);let i=[];if(s)i=s.map(a=>parseInt(a,10));else throw new Error(`Invalid color received. Got ${n}`);return document.body.removeChild(t),rr.getBrightness(i)<125}static getBrightness(e){return Math.round((e[0]*299+e[1]*587+e[2]*114)/1e3)}}async function Yi(d){const{clipboard:e}=navigator;if(e!==void 0)try{return navigator.clipboard.writeText(d)}catch{return Kc(d)}Kc(d)}function Kc(d){const e=document.activeElement,t=document.createElement("textarea");t.value=d,document.body.appendChild(t),t.focus(),t.select();const n=document.execCommand("copy");if(document.body.removeChild(t),e instanceof HTMLElement&&e.focus(),!n)throw new Error("Unable to execute copy command")}const ef="table_",qc="column_",tf=new Set(["in","not","i","ii","k"]),nf=new Set(["abstract","continue","for","new","switch","assert","default","if","package","synchronized","boolean","do","goto","private","this","break","double","implements","protected","throw","byte","else","import","public","throws","case","enum","instanceof","return","transient","catch","extends","int","short","try","char","final","interface","static","void","class","finally","long","strictfp","volatile","const","float","native","super","while","null","true","false"]),sf=/[^a-zA-Z0-9_$+@-]/g,of=/[^A-Za-z0-9_$]/g;class un{static legalize=(e,t,n,s,i)=>{let o=e.trim().replace(/[- ]/g,"_");return s&&(tf.has(o)||nf.has(o))&&(o=t+o),o=o.replace(n,""),o||(o=t+i),Number.isNaN(Number(o.charAt(0)))||(o=t+o),o};static legalizeTableName=e=>un.legalize(e,ef,sf,!1,0);static legalizeColumnNames=e=>{const t=[];return e.forEach((n,s)=>{let i=un.legalizeColumnName(n,s);t.includes(i)&&(i=qc+s),t.push(i)}),t};static legalizeColumnName=(e,t=0)=>un.legalize(e,qc,of,!0,t);static isValidTableName=e=>un.legalizeTableName(e)===e;static isValidColumnName=e=>un.legalizeColumnName(e)===e}function af(d,e){return d?d.closest(`.${e}`):null}const rf={getClosestByClassName:af};class Ue extends CustomEvent{constructor(e,t){super(e,t)}}class lf extends Error{isTimeout=!0}const Hh=lf;class ve{static makeCancelable(e,t){let n=!1,s,i;const o=new Promise((a,r)=>{i=r,Promise.resolve(e).then(c=>{n?t&&t(c):(s=c,a(c))}).catch(c=>r(c))});return o.cancel=()=>{n=!0,i(new $i),s!=null&&t&&t(s)},o}static isCanceled(e){return e instanceof $i}static isTimedOut(e){return e instanceof Hh}static withTimeout(e,t){return new Promise((n,s)=>{setTimeout(()=>{try{n(t())}catch(i){s(i)}},e)})}}class cf{pending=[];resolved=[];add(e,t){const n=ve.makeCancelable(e,t);return this.pending.push(n),n.then(()=>{this.resolve(n)},()=>{this.resolve(n)}),n}remove(e){for(let t=0;t<this.pending.length;t+=1)if(this.pending[t]===e){this.pending.splice(t,1);return}}resolve(e){this.remove(e),this.resolved.push(e)}cancel(){const e=[...this.pending,...this.resolved];for(let t=0;t<e.length;t+=1)e[t].cancel();this.pending=[],this.resolved=[]}}const is=cf;function M(d){if(d==null)throw new Error("Value is null or undefined")}function L(d,e,t=void 0){const n=d.get(e)??t;if(n!==void 0)return n;throw new Error(`Missing value for key ${e}`)}class hn{static isValidRange(e){return e!=null&&e.length===2&&Number.isInteger(e[0])&&Number.isInteger(e[1])&&e[0]<=e[1]}static validateRange(e){if(!hn.isValidRange(e))throw new Error(`Invalid range! ${e}`)}static isSelected(e,t){for(let n=0;n<e.length;n+=1){const s=e[n],i=s[0],o=s[1];if(i<=t&&t<=o)return!0}return!1}static selectRange(e,t){let[n,s]=t;const i=[...e];for(let o=i.length-1;o>=0;o-=1){const a=i[o],r=a[0],c=a[1];if(r<=n&&s<=c)return i;n<=c&&r<=s&&(n=Math.min(n,r),s=Math.max(s,c),i.splice(o,1))}return i.push([n,s]),i}static deselectRange(e,t){const[n,s]=t,i=[...e];for(let o=i.length-1;o>=0;o-=1){const a=i[o],r=a[0],c=a[1];if(!(s<r||c<n))if(r<n&&s<c){i[o]=[r,n-1],i.splice(o+1,0,[s+1,c]);break}else n<=r&&c<=s?i.splice(o,1):r<n?i[o]=[r,n-1]:i[o]=[s+1,c]}return i}static count(e){return e.reduce((t,n)=>t+(n[1]-n[0]+1),0)}static getItemsInRanges(e,t){return t.reduce((n,s)=>{const i=[...n];for(let o=s[0];o<=s[1];o+=1)i.push(e[o]);return i},[])}}class df{static join(e,t="and"){if(e==null||e.length===0)return"";if(e.length===1)return e[0];if(e.length===2)return`${e[0]} ${t} ${e[1]}`;const n=e.slice(0,e.length-1).join(", "),s=e[e.length-1];return`${n}, ${t} ${s}`}static toLower(e,t=!0){if(e==null){if(t)return"";throw new Error("Null string passed in to TextUtils.toLower")}return e.toLowerCase()}static sort(e,t,n=!0){return e<t?n?-1:1:e>t?n?1:-1:0}}const zt=df;class Xi{static TIME_PATTERN="([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]";static TIME_ZONES=Object.freeze([{label:"Tokyo UTC+9 No DST",value:"Asia/Tokyo"},{label:"Seoul UTC+9 No DST",value:"Asia/Seoul"},{label:"Hong Kong UTC+8 No DST",value:"Asia/Hong_Kong"},{label:"Singapore UTC+8 No DST",value:"Asia/Singapore"},{label:"Kolkata UTC+5:30 No DST",value:"Asia/Kolkata"},{label:"Berlin UTC+1",value:"Europe/Berlin"},{label:"UTC UTC±0 No DST",value:"UTC"},{label:"London UTC±0",value:"Europe/London"},{label:"Sao Paulo UTC-2",value:"America/Sao_Paulo"},{label:"Newfoundland UTC-3:30",value:"America/St_Johns"},{label:"Halifax UTC-4",value:"America/Halifax"},{label:"New York UTC−5",value:"America/New_York"},{label:"Chicago UTC-6",value:"America/Chicago"},{label:"Denver UTC-7",value:"America/Denver"},{label:"Los Angeles UTC-8",value:"America/Los_Angeles"},{label:"Anchorage UTC-9",value:"America/Anchorage"},{label:"Honolulu UTC-10 No DST",value:"Pacific/Honolulu"},{label:"Zurich UTC+1",value:"Europe/Zurich"},{label:"Amsterdam UTC+1",value:"Europe/Amsterdam"},{label:"Taipei UTC+8 No DST",value:"Asia/Taipei"},{label:"Sydney UTC+10",value:"Australia/Sydney"}]);static formatElapsedTime(e){if(typeof e!="number"||!Number.isInteger(e))throw new Error(`${e} is not a number that can be expressed as a formatted time`);const t=Math.floor(e/3600),n=Math.floor(e%3600/60),s=e%60;return`${t>0?`${t}h `:""}${n>0||t>0?`${n}m `:""}${e>=60?`${s}s`.padStart(3,"0"):`${s}s`}`}static formatTime(e){if(typeof e!="number"||!Number.isInteger(e)||e<0)throw new Error(`${e} is not a number that can be expressed as a formatted time`);const t=String(Math.floor(e/(60*60))).padStart(2,"0"),n=e%(60*60),s=String(Math.floor(n/60)).padStart(2,"0"),i=n%60,o=String(Math.ceil(i)).padStart(2,"0");return`${t}:${s}:${o}`}static isTimeString(e){return new RegExp(Xi.TIME_PATTERN).test(e)}static parseTime(e){if(e==null||typeof e!="string")throw new Error(`${e} is not a valid string`);const t=e.split(":");if(t.length!==3)throw new Error(`${e} is not a time string that can be parsed`);return Number(t[0])*60*60+Number(t[1])*60+Number(t[2])}}class hf extends Error{isInvalid=!0}const Li=hf,Yc=Z.module("ContextMenu");class ka extends b.PureComponent{static defaultProps={subMenuParentWidth:0,subMenuParentHeight:0,closeMenu(){},onMenuOpened(){},onMenuClosed(){},options:{},menuStyle:{},"data-testid":void 0};static handleContextMenu(e){e.metaKey||(e.stopPropagation(),e.preventDefault())}constructor(e){super(e),this.handleBlur=this.handleBlur.bind(this),this.handleCloseSubMenu=this.handleCloseSubMenu.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleMenuItemClick=this.handleMenuItemClick.bind(this),this.handleMenuItemContextMenu=this.handleMenuItemContextMenu.bind(this),this.handleMenuItemMouseMove=this.handleMenuItemMouseMove.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleWindowResize=this.handleWindowResize.bind(this),this.container=J.createRef(),this.oldFocus=document.activeElement,this.activeSubMenuRef=J.createRef(),this.subMenuTimer=0,this.rAF=0,this.initialPosition={top:e.top,left:e.left},this.state={menuItems:[],pendingItems:[],activeSubMenu:null,hasOverflow:!1,subMenuTop:null,subMenuLeft:null,subMenuParentWidth:0,subMenuParentHeight:0,keyboardIndex:-1,mouseIndex:-1}}componentDidMount(){this.initMenu(),this.verifyPosition(),window.addEventListener("resize",this.handleWindowResize),this.rAF=window.requestAnimationFrame(()=>{this.container.current?.focus();const{onMenuOpened:e}=this.props;e(this)})}componentDidUpdate(e,t){const{actions:n}=this.props,{activeSubMenu:s}=this.state;s!==t.activeSubMenu&&(s==null?this.container.current?.focus():this.setActiveSubMenuPosition()),e.actions!==n&&(this.initMenu(),(this.container.current==null||!this.container.current.contains(document.activeElement))&&this.container.current?.focus()),this.verifyPosition()}componentWillUnmount(){this.cancelPromises(),window.removeEventListener("resize",this.handleWindowResize),cancelAnimationFrame(this.rAF)}container;oldFocus;activeSubMenuRef;subMenuTimer;rAF;initialPosition;getKeyboardIndex(){const{options:e}=this.props;if(e.separateKeyboardMouse!==void 0&&e.separateKeyboardMouse){const{keyboardIndex:t}=this.state;return t}return this.getMouseIndex()}setKeyboardIndex(e){const{options:t}=this.props;t.separateKeyboardMouse!==void 0&&t.separateKeyboardMouse?this.setState({keyboardIndex:e}):this.setMouseIndex(e)}getMouseIndex(){const{mouseIndex:e}=this.state;return e}setMouseIndex(e){this.setState({mouseIndex:e})}initMenu(){this.cancelPromises(),cancelAnimationFrame(this.rAF);const{options:e}=this.props;let t=e.initialKeyboardIndex;t===void 0&&(t=-1);const{actions:n}=this.props,s=Ve.getMenuItems(n),i=[];for(let o=s.length-1;o>=0;o-=1){const a=s[o];a instanceof Promise?this.initMenuPromise(a):i.push(a)}this.setState({mouseIndex:-1,keyboardIndex:t,activeSubMenu:null,menuItems:Ve.sortActions(i)})}initMenuPromise(e){const t=ve.makeCancelable(e);this.setState(n=>({pendingItems:n.pendingItems.concat(t)})),t.then(n=>{this.setState(s=>{const i=s.pendingItems.indexOf(t);if(i>=0){const o=s.pendingItems.slice();return o.splice(i,1),{menuItems:Ve.sortActions(s.menuItems.concat(n)),pendingItems:o}}return null})},n=>{ve.isCanceled(n)||(this.setState(s=>{const i=s.pendingItems.indexOf(t);if(i>=0){const o=s.pendingItems.slice();return o.splice(i,1),{pendingItems:o}}return null}),Yc.error(n))})}cancelPromises(){const{pendingItems:e}=this.state;e.map(t=>t.cancel())}setActiveSubMenuPosition(){if(this.activeSubMenuRef.current===null)return;const e=this.activeSubMenuRef.current.getBoundingClientRect();this.setState({subMenuTop:e.top,subMenuLeft:e.right,subMenuParentHeight:e.height,subMenuParentWidth:e.width})}verifyPosition(){const{options:e,updatePosition:t,subMenuParentWidth:n,subMenuParentHeight:s,top:i,left:o}=this.props;if(!this.container.current||e.doNotVerifyPosition!=null&&e.doNotVerifyPosition)return;let{top:a,left:r}=this.initialPosition;const{width:c,height:h}=this.container.current?.getBoundingClientRect()??{width:0,height:0},u=(this.container.current?.scrollHeight??0)>window.innerHeight;h===0||c===0||(a+h>window.innerHeight&&(a-h-s>0?a-=h-s:a=window.innerHeight-h),r+c>window.innerWidth&&(r=r-c-n),(o!==r||i!==a)&&(this.setState({hasOverflow:u}),t(a,r)))}handleWindowResize(){this.container.current&&this.closeMenu(!0)}handleBlur(e){if(!this.container.current){Yc.warn("Container is null!");return}if(!this.container.current.contains(e.relatedTarget)){let t=e.relatedTarget,n=!1;for(;t&&!n;)n=t.hasAttribute("data-dh-context-menu"),t=t.parentElement;n||this.closeMenu(!0)}}isEscapeKey(e){const{left:t}=this.props;return e==="Escape"||t<0&&e==="ArrowRight"||e==="ArrowLeft"}handleKeyDown(e){const{menuItems:t}=this.state,n=this.getKeyboardIndex();let s=n,i=!1;if(e.key==="Enter"||e.key===" "){n>=0&&n<t.length&&this.handleMenuItemClick(t[n],e);return}if(e.key==="ArrowRight"?n>=0&&n<=t.length?i=!0:s=0:this.isEscapeKey(e.key)?s=null:e.key==="ArrowUp"||e.shiftKey&&e.key==="Tab"?s=Ve.getNextMenuItem(s,-1,t):(e.key==="ArrowDown"||e.key==="Tab")&&(s=Ve.getNextMenuItem(s,1,t)),i){this.openSubMenu(n),e.preventDefault(),e.stopPropagation();return}n!==s&&(s!==null?this.setKeyboardIndex(s):(this.closeMenu(),this.oldFocus instanceof HTMLElement&&this.oldFocus.focus()),e.preventDefault(),e.stopPropagation())}openSubMenu(e){const{menuItems:t,activeSubMenu:n}=this.state,s=t[e].actions?e:null;n!==s&&this.setState({activeSubMenu:s,subMenuTop:null,subMenuLeft:null})}closeMenu(e=!1){const{closeMenu:t,onMenuClosed:n}=this.props;cancelAnimationFrame(this.rAF),this.rAF=window.requestAnimationFrame(()=>{t(e),n(this)})}closeSubMenu(){this.setState({activeSubMenu:null})}handleCloseSubMenu(e){e?this.closeMenu(!0):this.closeSubMenu()}handleMenuItemClick(e,t){t.preventDefault(),t.stopPropagation();const{menuItems:n}=this.state;e!=null&&(e.disabled===void 0||!e.disabled)&&(e.actions!=null?this.openSubMenu(n.indexOf(e)):e.action!=null&&(e.action(),this.closeMenu(!0)))}handleMenuItemContextMenu(e,t){t.metaKey||this.handleMenuItemClick(e,t)}handleMenuItemMouseMove(e){const{menuItems:t}=this.state,n=t.indexOf(e);this.setMouseIndex(n),n>=0&&n<t.length&&(e.disabled===void 0||!e.disabled)&&this.openSubMenu(n)}handleMouseLeave(){this.setMouseIndex(-1)}render(){const e=[],{top:t,left:n}=this.props,{activeSubMenu:s,hasOverflow:i,keyboardIndex:o,menuItems:a,mouseIndex:r,pendingItems:c,subMenuTop:h,subMenuLeft:u,subMenuParentWidth:m,subMenuParentHeight:g}=this.state;for(let v=0;v<a.length;v+=1){const w=a[v];v>0&&w.group!==a[v-1].group&&e.push(l.jsx("hr",{},`${v}.separator`));const T=l.jsx(jh,{ref:s===v?this.activeSubMenuRef:null,isKeyboardSelected:o===v,isMouseSelected:r===v,menuItem:w,closeMenu:this.handleCloseSubMenu,onMenuItemClick:this.handleMenuItemClick,onMenuItemMouseMove:this.handleMenuItemMouseMove,onMenuItemContextMenu:this.handleMenuItemContextMenu},v);e.push(T)}let p=null;c.length>0&&(p=l.jsx("div",{className:"loading",children:l.jsx(yn,{})}));const{menuStyle:C,"data-testid":f}=this.props,S=s!==null&&h!==null&&u!==null;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:$({"has-overflow":i},"context-menu-container"),style:{top:t,left:n,...C},ref:this.container,"data-dh-context-menu":!0,onBlur:this.handleBlur,onKeyDown:this.handleKeyDown,onMouseLeave:this.handleMouseLeave,onContextMenu:ka.handleContextMenu,role:"menuitem",tabIndex:0,"data-testid":f,children:[e,p]}),S&&s!==null&&h!==null&&u!==null&&l.jsx(ka,{actions:a[s].actions||[],closeMenu:this.handleCloseSubMenu,top:h,left:u,updatePosition:(v,w)=>{this.setState({subMenuTop:v,subMenuLeft:w})},subMenuParentWidth:m,subMenuParentHeight:g},`sub-${s}`)]})}}const uf=ka;class mf extends b.Component{constructor(e){super(e),this.handleMenuClose=this.handleMenuClose.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.container=J.createRef(),this.openMenu=J.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)}container;openMenu;handleContextMenu(e){if(!Ve.isContextActionEvent(e)||!this.container.current||e.metaKey||e.ctrlKey)return;const t=Ve.getMenuItems(e.contextActions),n=this.container.current.getBoundingClientRect(),s=e.clientY-n.top,i=e.clientX-n.left;if(t.length===0){if(e.target===this.container.current){e.preventDefault(),this.setState({actions:null},()=>{const o=document.elementFromPoint(i,s),a=new MouseEvent("contextmenu",{clientX:e.clientX,clientY:e.clientY,bubbles:!0,cancelable:!0});o?.dispatchEvent(a)});return}return}e.preventDefault(),this.setState({actions:t,top:s,left:i})}handleMenuClose(e){e===this.openMenu.current&&this.setState({actions:null})}render(){let e=null;const{"data-testid":t}=this.props,{actions:n,top:s,left:i}=this.state;return n&&(e=l.jsx(uf,{ref:this.openMenu,actions:n,onMenuClosed:this.handleMenuClose,top:s,left:i,updatePosition:(o,a)=>{this.setState({top:o,left:a})},"data-testid":t})),l.jsx("div",{className:$("context-menu-root",{active:n}),ref:this.container,children:e})}}const Vh=mf;class vs extends b.Component{static propTypes={className:I.string,in:I.bool.isRequired,children:I.node.isRequired,autoFocusOnShow:I.bool,"data-testid":I.string};static defaultProps={className:"",autoFocusOnShow:!1,"data-testid":void 0};static handleEnter(e){const t=e;t.style.height="0"}static handleEntering(e){const t=e;t.style.height=`${vs.getHeight(t)}px`}static handleExiting(e){const t=e;t.style.height="0"}static handleExit(e){const t=e;t.style.height=`${vs.getHeight(t)}px`}static getHeight(e){const t=e.scrollWidth-e.clientWidth;return e.scrollHeight-t}constructor(e){super(e),this.handleEntered=this.handleEntered.bind(this)}handleEntered(e){const t=e;t.style.height="";const{autoFocusOnShow:n}=this.props;if(n!==void 0&&n){const s=t.querySelector("input, select, textarea");s?.focus()}}render(){const{children:e,className:t,in:n,"data-testid":s}=this.props;return l.jsx(ft,{in:n,classNames:{enterActive:"collapsing",enterDone:"collapse show",exitActive:"collapsing",exitDone:"collapse"},onEnter:vs.handleEnter,onEntering:vs.handleEntering,onEntered:this.handleEntered,onExit:vs.handleExit,onExiting:vs.handleExiting,timeout:350,children:i=>l.jsx("div",{className:$({collapse:i==="exited"},t),"data-testid":s,children:e})})}}const gf=vs;function lr(d){const e=b.useRef();return b.useEffect(function(){e.current=d}),e.current}function Bh(d){const e=b.useRef(null);return b.useEffect(function(){d&&(typeof d=="function"?d(e.current):d.current=e.current)}),e}const pf=3500,ff=Z.module("useCopyToClipboard");function Cf(){const[d,e]=b.useState(!1),t=b.useRef(null),n=b.useCallback(s=>{Yi(s).then(()=>{e(!0)}).catch(i=>ff.error(`Unable to copy ${s}`,`
2
- `,i))},[]);return b.useEffect(()=>(t.current&&clearTimeout(t.current),d&&(t.current=setTimeout(()=>{e(!1)},pf)),()=>{t.current&&clearTimeout(t.current)}),[d]),[d,n]}const cr=J.forwardRef((d,e)=>{const{checked:t=!1,children:n,className:s,disabled:i,inputClassName:o,isInvalid:a,labelClassName:r,name:c,onChange:h,"data-testid":u}=d,[m]=b.useState(_e()),g=Bh(e);b.useEffect(function(){g.current&&(g.current.indeterminate=t===null)},[g,t]);const p=b.useCallback(C=>{g.current&&(g.current.indeterminate=t===null),h&&h(C)},[g,t,h]);return l.jsxs("div",{className:$("custom-control custom-checkbox",s),children:[l.jsx("input",{type:"checkbox",ref:g,checked:t??!1,className:$("custom-control-input",o,{"is-invalid":a}),disabled:i,id:m,name:c,onChange:p,"data-testid":u}),l.jsx("label",{className:$("custom-control-label",r),htmlFor:m,children:n})]})});cr.displayName="Checkbox";cr.propTypes={checked:(d,e)=>{const{[e]:t}=d;return t!==null&&typeof t!="boolean"?new Error("Checked must be a boolean or null for indeterminate"):null},children:I.node.isRequired,className:I.string,disabled:I.bool,inputClassName:I.string,isInvalid:I.bool,labelClassName:I.string,name:I.string,onChange:I.func,"data-testid":I.string};cr.defaultProps={checked:!1,className:"",disabled:!1,inputClassName:"",isInvalid:!1,labelClassName:"",name:void 0,onChange:void 0,"data-testid":void 0};const Zt=cr;class Sf extends b.PureComponent{static defaultProps={placeholder:"Search",className:"",matchCount:null,onKeyDown(){},id:"","data-testid":void 0};constructor(e){super(e),this.inputField=J.createRef()}inputField;focus(){this.inputField.current?.focus()}render(){const{value:e,placeholder:t,onBlur:n,onChange:s,className:i,disabled:o,matchCount:a,id:r,onKeyDown:c,"data-testid":h}=this.props;return l.jsxs("div",{className:$("search-group",i),children:[l.jsx("input",{type:"search",value:e,onBlur:n,onChange:s,onKeyDown:c,className:"form-control",disabled:o,placeholder:t,ref:this.inputField,id:r,"data-testid":h}),a!=null&&l.jsx("span",{className:"search-match",children:a}),l.jsx("span",{className:"search-icon",children:l.jsx(Q,{icon:Dh})})]})}}const _s=Sf;var Uh=(d=>(d.UP="UP",d.DOWN="DOWN",d))(Uh||{});class xi extends b.Component{static MENU_NAVIGATION_DIRECTION=Uh;static DROP_DOWN_MENU_HEIGHT=200;static propTypes={options:I.arrayOf(I.shape({title:I.string.isRequired,value:I.string.isRequired})).isRequired,popperOptions:I.shape({title:I.string.isRequired,value:I.string.isRequired}),onChange:I.func,inputPlaceholder:I.string,searchPlaceholder:I.string,disabled:I.bool,className:I.string,defaultValue:I.string,spellCheck:I.bool,onEnter:I.func,"data-testid":I.string};static defaultProps={onChange(){},inputPlaceholder:"",searchPlaceholder:"Search",disabled:!1,className:"",defaultValue:"",popperOptions:null,spellCheck:!0,onEnter(){},"data-testid":void 0};constructor(e){super(e),this.state={value:"",filter:"",filteredOptions:e.options,keyboardOptionIndex:-1,menuIsOpen:!1,inputWidth:100},this.toggleMenu=this.toggleMenu.bind(this),this.handleMenuKeyDown=this.handleMenuKeyDown.bind(this),this.handleMenuBlur=this.handleMenuBlur.bind(this),this.closeMenu=this.closeMenu.bind(this),this.handleInputChange=this.handleInputChange.bind(this),this.handleInputKeyDown=this.handleInputKeyDown.bind(this),this.handleInputBlur=this.handleInputBlur.bind(this),this.handleFilterChange=this.handleFilterChange.bind(this),this.handleOptionClick=this.handleOptionClick.bind(this),this.handleOptionFocus=this.handleOptionFocus.bind(this),this.handleMenuOpened=this.handleMenuOpened.bind(this),this.handleMenuExited=this.handleMenuExited.bind(this),this.popper=J.createRef(),this.cbContainer=J.createRef(),this.toggleButton=J.createRef(),this.menuContainer=J.createRef(),this.input=J.createRef(),this.searchInput=J.createRef()}componentDidUpdate(){const{menuIsOpen:e,keyboardOptionIndex:t}=this.state;e&&t>=0&&this.scrollOptionIntoView()}popper;cbContainer;toggleButton;menuContainer;input;searchInput;setInputWidth(){this.cbContainer.current&&this.setState({inputWidth:this.cbContainer.current.getBoundingClientRect().width})}getCachedFilteredOptions=ge((e,t)=>e.filter(n=>n.title.toLowerCase().indexOf(t.toLowerCase())>=0||n.value.toLowerCase().indexOf(t.toLowerCase())>=0));focus(){this.input.current?.focus()}resetValue(){this.setState({value:""})}updateInputValue(e){const{onChange:t}=this.props;this.setState({value:e}),t(e)}handleResize(){this.setInputWidth()}handleMenuKeyDown(e){const{filter:t,filteredOptions:n,keyboardOptionIndex:s}=this.state,{options:i}=this.props,o=t?n:i;switch(e.key){case"Enter":o[s]?.value!=null&&this.updateInputValue(o[s].value),this.closeMenu(),this.input.current?.focus(),e.stopPropagation(),e.preventDefault();break;case"ArrowUp":this.handleMenuNavigation(xi.MENU_NAVIGATION_DIRECTION.UP),e.stopPropagation(),e.preventDefault();break;case"ArrowDown":this.handleMenuNavigation(xi.MENU_NAVIGATION_DIRECTION.DOWN),e.stopPropagation(),e.preventDefault();break;case"Escape":t!==""?(this.setState({filter:""}),e.stopPropagation()):this.closeMenu();break;case"Tab":!e.shiftKey&&s===o.length-1&&this.closeMenu();break}}handleMenuNavigation(e){const{filter:t,filteredOptions:n,keyboardOptionIndex:s}=this.state,{options:i}=this.props,a=(t?n:i).length;let r=0;switch(e){case xi.MENU_NAVIGATION_DIRECTION.UP:r=-1;break;case xi.MENU_NAVIGATION_DIRECTION.DOWN:r=1;break}r!==0&&this.setState({keyboardOptionIndex:(s+r+a)%a})}handleInputKeyDown(e){const{onEnter:t}=this.props,{menuIsOpen:n}=this.state;e.key==="ArrowDown"||e.key==="ArrowUp"?n||this.openMenu():e.key==="Enter"&&t()}handleInputChange(e){this.updateInputValue(e.target.value)}handleOptionClick(e){const t=Number(e.currentTarget.value),{filter:n,filteredOptions:s}=this.state,{options:i}=this.props,o=n?s:i;this.updateInputValue(o[t].value),this.closeMenu(),this.input.current?.focus()}handleOptionFocus(e){this.setState({keyboardOptionIndex:Number(e.target.value)})}handleFilterChange(e){const{options:t}=this.props,n=e.target.value,s=this.getCachedFilteredOptions(t,n);this.setState({filter:n,filteredOptions:s,keyboardOptionIndex:0}),this.popper.current?.scheduleUpdate()}handleMenuBlur(e){e.relatedTarget instanceof Element&&this.popper.current!=null&&this.popper.current.element.contains(e.relatedTarget)||e.relatedTarget===this.toggleButton.current||this.closeMenu(!1)}handleInputBlur(e){const{menuIsOpen:t}=this.state;t&&e.relatedTarget instanceof Element&&this.popper.current!=null&&this.popper.current.element.contains(e.relatedTarget)||this.closeMenu(!1)}handleMenuOpened(){this.scrollOptionIntoView(),this.searchInput.current?.focus()}handleMenuExited(){const{menuIsOpen:e}=this.state;e&&(this.setState({menuIsOpen:!1}),this.popper.current?.hide()),this.setState({filter:""})}toggleMenu(e){const{menuIsOpen:t}=this.state;t?this.closeMenu():this.openMenu(),e.stopPropagation()}openMenu(){this.updateKeyboardIndex(),this.setInputWidth(),this.setState({menuIsOpen:!0}),window.requestAnimationFrame(()=>{this.popper.current?.show()})}closeMenu(e=!0){this.setState({menuIsOpen:!1}),e&&this.input.current?.focus(),this.popper.current?.hide()}updateKeyboardIndex(){const{value:e,filter:t,filteredOptions:n}=this.state,{options:s}=this.props,o=(t?n:s).findIndex(a=>a.value===e);this.setState({keyboardOptionIndex:o})}scrollOptionIntoView(){const e=this.menuContainer.current?.querySelector(".cb-option-btn.keyboard-active");e instanceof HTMLElement&&e.scrollIntoView({block:"nearest",inline:"nearest"})}renderMenuElement(){const{searchPlaceholder:e}=this.props,{filter:t,inputWidth:n}=this.state;return l.jsxs("div",{className:"cb-menu-container",ref:this.menuContainer,role:"presentation",onKeyDown:this.handleMenuKeyDown,onClick:s=>{s.stopPropagation()},style:{width:n},onBlur:this.handleMenuBlur,children:[l.jsx("div",{className:"cb-search-input-container",children:l.jsx(_s,{value:t,ref:this.searchInput,onChange:this.handleFilterChange,className:"cb-search-input",placeholder:e})}),l.jsx("div",{className:"cb-options-container",children:l.jsx("div",{className:"cb-options",children:this.renderOptions()})})]})}renderOptions(){const{options:e}=this.props,{keyboardOptionIndex:t,filter:n,filteredOptions:s}=this.state;return(n?s:e).map((o,a)=>{const r=`option-${a}-${o.value}`;return l.jsx("button",{type:"button",value:a,className:$("cb-option-btn",{"keyboard-active":t===a}),onClick:this.handleOptionClick,onFocus:this.handleOptionFocus,children:o.title},r)})}render(){const{options:e,inputPlaceholder:t,disabled:n,className:s,defaultValue:i,spellCheck:o,"data-testid":a}=this.props,{value:r}=this.state;let{popperOptions:c}=this.props;return c={placement:"bottom-end",modifiers:{preventOverflow:{enabled:!1}},...c},l.jsxs("div",{className:"input-group cb-container",ref:this.cbContainer,children:[l.jsx("input",{value:r||i,className:$("form-control",s,"cb-input"),ref:this.input,onChange:this.handleInputChange,placeholder:t||(e[0]!=null?e[0].title:void 0),disabled:n,onBlur:this.handleInputBlur,onKeyDown:this.handleInputKeyDown,spellCheck:o,"data-testid":a!==void 0?`${a}-input`:void 0}),l.jsx("div",{className:"input-group-append cb-dropdown",children:l.jsxs("button",{type:"button",className:"btn cb-btn form-control",ref:this.toggleButton,onClick:this.toggleMenu,onKeyDown:this.handleInputKeyDown,disabled:n,"data-testid":a!==void 0?`${a}-btn`:void 0,children:[l.jsx(Q,{icon:Pn}),l.jsx(hi,{ref:this.popper,options:c,className:$("combobox interactive"),onEntered:this.handleMenuOpened,onExited:this.handleMenuExited,children:this.renderMenuElement()})]})})]})}}const $h=xi;function dr({copy:d,kind:e="ghost",tooltip:t="Copy",className:n,"data-testid":s,children:i}){const[o,a]=Cf();return l.jsx(B,{kind:e,className:n,"data-testid":s,icon:o?xg:Ig,tooltip:o?"Copied":t,onClick:()=>{a(typeof d=="function"?d():d)},children:i})}function Wh(d,e,t){return d.substring(0,e)+t+d.substring(e+1)}function bf(d,e,t){return d.length<t?`${d}${e.substring(d.length,t)}`:d}function Xc(d,e){let{length:t}=d;for(let n=d.length-1;n>=0&&e[n]===d[n];n-=1)t=n;return d.substring(0,t)}const mn=Z.module("MaskedInput"),vi={FORWARD:"forward",BACKWARD:"backward",NONE:"none"},sa=" ",Gh=J.forwardRef((d,e)=>{const{className:t,example:n,getNextSegmentValue:s=(O,j,k)=>k,getPreferredReplacementString:i=Wh,onChange:o=()=>!1,onSelect:a=()=>!1,onSubmit:r,pattern:c,placeholder:h,selection:u,value:m,onFocus:g=()=>!1,onBlur:p=()=>!1,"data-testid":C}=d,f=Bh(e),S=b.useMemo(()=>Array.isArray(n)?n:[n],[n]),v=b.useMemo(()=>S[0].replace(/[a-zA-Z0-9]/g,sa),[S]);b.useEffect(function(){if(u!=null){mn.debug("setting selection...",u);const{selectionStart:j,selectionEnd:k,selectionDirection:A}=u;f.current?.setSelectionRange(j,k,A),mn.debug("selection set!")}},[u,f]);const w=b.useCallback(O=>{let j=O,k=O;const A=S.length>0?S[0]:m;for(let K=j-1;K>=0&&/[a-zA-Z0-9]/g.test(A.charAt(K));K-=1)j=K;for(let K=k;K<A.length&&/[a-zA-Z0-9]/g.test(A.charAt(K));K+=1)k=K+1;const H=j===k?vi.NONE:vi.BACKWARD;return{selectionStart:j,selectionEnd:k,selectionDirection:H}},[S,m]);function T(O,j,k=O.length){let A="";for(let H=0;H<k;H+=1)O.charAt(H)!==sa?A=A.concat(O[H]):A=A.concat(j[H]);return A=A.concat(j.substring(k)),A}function y(O,j=O.length){const k=new RegExp(`^${c}$`);if(k.test(O))return!0;for(let A=0;A<S.length;A+=1){const H=T(O,S[A],j);if(k.test(H))return!0}return!1}function E(O){const j=w(O),k=j.selectionEnd+1;return k>=m.length?j:w(k)}function D(O){const j=w(O),k=j.selectionStart-1;return k<=0?j:w(k)}function F(O,j){const k=w(O),A=m.substring(k.selectionStart,k.selectionEnd),H=s(k,j,A,m),K=m.substring(0,k.selectionStart)+H+m.substring(k.selectionEnd);y(K,k.selectionEnd)&&(o(K),a(k))}const N=b.useCallback(O=>{const{selectionStart:j=0,selectionEnd:k=0,selectionDirection:A="none"}=O.target;if(j===null||k===null||A===null){mn.error("Selection attempted on non-text input element",O.target);return}if(mn.debug2("handleSelect",j,k,A),!(u!=null&&j===u.selectionStart&&k===u.selectionEnd)){if(u!=null&&j===m.length&&k===m.length&&O.nativeEvent.type!=="mouseup"){a({...u});return}if(j===k){const H=w(j);mn.debug("Selection segment from ",j,k,"=>",H),a(H)}else a({selectionStart:j,selectionEnd:k,selectionDirection:A})}},[w,a,u,m]),_=b.useCallback(O=>{if(!f.current)return;mn.debug("handleSelectCapture",O);const j=f.current.selectionStart??0;j===m.length&&u!=null&&j!==u.selectionStart&&(O.preventDefault(),O.stopPropagation())},[f,u,m]);function P(O){if(O.preventDefault(),O.stopPropagation(),!f.current)return;const{key:j}=O,{selectionStart:k=0,selectionEnd:A=0}=f.current;if(k===null||A===null){mn.error("Selection arrow nvaigation attempted on non-text input element",O.target);return}j==="ArrowLeft"?a(D(k)):j==="ArrowRight"?a(E(A)):j==="ArrowUp"?F(k,-1):j==="ArrowDown"&&F(k,1)}function U(O){if(!f.current)return;mn.debug("handleKeyDown",O);const{key:j}=O,{selectionStart:k=0,selectionEnd:A=0}=f.current;if(k===null||A===null){mn.error("Selection key event on non-text input element",O.target);return}if(j==="Enter"){r?.(O);return}if(j.startsWith("Arrow")){P(O);return}if(j==="Delete"||j==="Backspace"){if(O.preventDefault(),O.stopPropagation(),A>=Xc(m,v).length){const K=m.substring(0,k===A?k-1:k),q=Xc(K,v);q!==m&&(o(q),a({selectionStart:q.length,selectionEnd:q.length,selectionDirection:vi.NONE}));return}if(k!==A){const K=m.substring(0,k)+m.substring(k,A).replace(/[a-zA-Z0-9]/g,sa)+m.substring(A);mn.debug("Range ",k,A,"deleted, setting value",K),o(K),a({selectionStart:k,selectionEnd:k,selectionDirection:vi.NONE})}else if(k>0)for(let K=k-1;K>=0;K-=1){const q=m.substring(0,K)+m.substring(K,k).replace(/[a-zA-Z0-9]/g,sa)+m.substring(k);if(q!==m){o(q),a({selectionStart:K,selectionEnd:K,selectionDirection:vi.NONE});return}}return}if(O.altKey||O.metaKey||O.ctrlKey||j.length>1)return;O.preventDefault(),O.stopPropagation();const H=Array.from(new Set([j,j.toUpperCase(),j.toLowerCase()]));for(let K=0;K<H.length;K+=1){const q=H[K],oe=/[a-zA-Z0-9]/g.test(q)?S[0].length-1:k;for(let W=k;W<=oe;W+=1){const G=bf(m,S[0],W+1),ne=i(G,W,q,k,A);if(y(ne,W+1)){const ae=w(W),ce=W+1;let te={selectionStart:ce,selectionEnd:ce,selectionDirection:vi.NONE};if(ce>=ae.selectionEnd){const re=E(W);re.selectionStart!==ae.selectionStart&&(te=re)}mn.debug("handleKeyDown",j,"=>",ne,te),o(ne),a(te);return}}}}return l.jsx("input",{ref:f,className:$("form-control masked-input",t),type:"text",pattern:c,placeholder:h,value:m,onChange:()=>{},onKeyDown:U,onSelect:N,onSelectCapture:_,onFocus:g,onBlur:p,"data-testid":C})});Gh.defaultProps={className:"",placeholder:void 0,onChange(){},onSelect(){},getNextSegmentValue:(d,e,t)=>t,getPreferredReplacementString:Wh,selection:void 0,onFocus(){},onBlur(){},"data-testid":void 0};const wf=Gh;let vf=class extends b.PureComponent{static defaultProps={closeMenu(){},onMenuOpened(){},onMenuClosed(){},options:{},menuStyle:{},"data-testid":void 0};constructor(e){super(e),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleMenuItemClick=this.handleMenuItemClick.bind(this),this.handleMenuItemMouseMove=this.handleMenuItemMouseMove.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleCloseMenu=this.handleCloseMenu.bind(this),this.container=J.createRef(),this.oldFocus=document.activeElement,this.rAF=0;const{options:t}=e,n=t.initialKeyboardIndex??-1;this.state={menuItems:[],keyboardIndex:n,mouseIndex:-1}}componentDidMount(){this.initMenu(),this.rAF=window.requestAnimationFrame(()=>{this.container.current?.focus();const{onMenuOpened:e}=this.props;e(this)})}componentDidUpdate(e){const{actions:t}=this.props;e.actions!==t&&this.initMenu()}componentWillUnmount(){cancelAnimationFrame(this.rAF)}container;oldFocus;rAF;getKeyboardIndex(){const{options:e}=this.props;if(e.separateKeyboardMouse!==void 0&&e.separateKeyboardMouse){const{keyboardIndex:t}=this.state;return t}return this.getMouseIndex()}setKeyboardIndex(e){const{options:t}=this.props;t.separateKeyboardMouse!==void 0&&t.separateKeyboardMouse?this.setState({keyboardIndex:e}):this.setMouseIndex(e)}getMouseIndex(){const{mouseIndex:e}=this.state;return e}setMouseIndex(e){this.setState({mouseIndex:e})}initMenu(){cancelAnimationFrame(this.rAF),this.setState({menuItems:[]});const{actions:e}=this.props,t=Ve.getMenuItems(e,!1);t.length>0&&this.setState(n=>({menuItems:Ve.sortActions(n.menuItems.concat(t))}))}handleKeyDown(e){const{menuItems:t}=this.state,n=this.getKeyboardIndex();let s=n;if(e.key==="Enter"||e.key===" "){n!=null&&n>=0&&n<t.length&&this.handleMenuItemClick(t[n],e);return}e.key==="Escape"?s=null:e.key==="ArrowUp"||e.key==="Tab"&&e.shiftKey===!0?s=Ve.getNextMenuItem(s??0,-1,t):(e.key==="ArrowDown"||e.key==="Tab"&&e.shiftKey===!1)&&(s=Ve.getNextMenuItem(s??0,1,t)),n!==s&&(s!==null?this.setKeyboardIndex(s):(this.closeMenu(),this.oldFocus instanceof HTMLElement&&this.oldFocus.focus()),e.preventDefault(),e.stopPropagation())}closeMenu(e=!1){const{closeMenu:t,onMenuClosed:n}=this.props;cancelAnimationFrame(this.rAF),this.rAF=window.requestAnimationFrame(()=>{t(e),n(this)})}handleCloseMenu(){this.closeMenu()}handleMenuItemClick(e,t){t.preventDefault(),t.stopPropagation(),e!=null&&(e.disabled===void 0||!e.disabled)&&e.action!=null&&(e.action(),this.closeMenu(!0))}handleMenuItemMouseMove(e){const{menuItems:t}=this.state,n=t.indexOf(e);this.setMouseIndex(n)}handleMouseLeave(){this.setMouseIndex(-1)}render(){const e=[],{"data-testid":t}=this.props,{keyboardIndex:n,menuItems:s,mouseIndex:i}=this.state;for(let a=0;a<s.length;a+=1){const r=s[a];a>0&&r.group!==s[a-1].group&&e.push(l.jsx("hr",{},`${a}.separator`));const c=l.jsx(jh,{isKeyboardSelected:n===a,isMouseSelected:i===a,menuItem:r,closeMenu:this.handleCloseMenu,onMenuItemClick:this.handleMenuItemClick,onMenuItemMouseMove:this.handleMenuItemMouseMove,onMenuItemContextMenu:()=>!1},a);e.push(c)}const{menuStyle:o}=this.props;return l.jsx("div",{className:"context-menu-container",style:{...o},ref:this.container,onKeyDown:this.handleKeyDown,onMouseLeave:this.handleMouseLeave,role:"menuitem",tabIndex:0,"data-testid":t,children:e})}};const Tf=vf;class Ef extends b.PureComponent{static defaultProps={isShown:null,onMenuClosed(){},onMenuOpened(){},options:{},popperOptions:{},popperClassName:"",menuStyle:{},"data-testid":void 0};constructor(e){super(e),this.handleClick=this.handleClick.bind(this),this.handleCloseMenu=this.handleCloseMenu.bind(this),this.handleExited=this.handleExited.bind(this),this.container=J.createRef(),this.parent=null,this.popper=J.createRef(),this.isOpen=!1}componentDidMount(){const{isShown:e}=this.props;e===null?this.container.current?.parentElement&&(this.parent=this.container.current.parentElement,this.parent.addEventListener("click",this.handleClick)):e&&this.openMenu()}componentDidUpdate(e){const{isShown:t}=this.props;e.isShown!==t&&(t!==null&&t?window.requestAnimationFrame(()=>{this.openMenu()}):this.closeMenu())}componentWillUnmount(){this.parent&&this.parent.removeEventListener("click",this.handleClick)}container;parent;popper;isOpen;closeMenu(){this.popper.current?.hide()}openMenu(){this.popper.current&&!this.isOpen&&(this.popper.current.show(),this.isOpen=!0)}scheduleUpdate(){this.popper.current?.scheduleUpdate()}handleClick(e){e.preventDefault(),e.stopPropagation(),this.openMenu()}handleCloseMenu(){this.closeMenu()}handleExited(){this.isOpen=!1;const{onMenuClosed:e}=this.props;e()}render(){const{actions:e,onMenuOpened:t,popperClassName:n,"data-testid":s}=this.props,{menuStyle:i}=this.props;let{options:o,popperOptions:a}=this.props;return a={placement:"bottom",...a},o={separateKeyboardMouse:!0,...o},l.jsx("div",{className:"menu-actions-listener",ref:this.container,"data-testid":s,children:l.jsx(hi,{ref:this.popper,options:a,className:$("menu-popper",n),onExited:this.handleExited,closeOnBlur:!0,interactive:!0,children:l.jsx(Tf,{actions:e,closeMenu:this.handleCloseMenu,onMenuOpened:t,options:o,menuStyle:i})})})}}const es=Ef;function Ti(d,e,t,n,s){const i=n-t+1;return`${((parseInt(e,10)-d-t)%i+i)%i+t}`.padStart(s,"0")}function yf(d,e,t){const{selectionStart:n}=d;return n===0?Ti(e,t,1900,2099,4):n===5?Ti(e,t,1,12,2):n===8?Ti(e,t,1,31,2):n===11?Ti(e,t,0,23,2):n===17||n===14?Ti(e,t,0,59,2):n===20||n===24||n===28?Ti(e,t,0,999,3):t}function hl(d){const e=d.substring(0,23),t=d.substring(23,26),n=d.substring(26);return[e,t,n].filter(s=>s!=="").join("​")}const Rf=Z.module("DateTimeInput"),xf="[12][0-9]{3}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])",If="([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]\\.[0-9]{3}​[0-9]{3}​[0-9]{3}",Df=`${xf} ${If}`,Ea="2022-01-01",zh=`${Ea} 00:00:00.000000000`,Ff="YYYY-MM-DD HH:MM:SS.SSSSSSSSS";function Zc(d){return d!=null&&d.length>=Ea.length?`${d.substring(0,Ea.length)}${d.substring(Ea.length).replace(/\u2007/g,"0")}${zh.substring(d.length)}`:d}function Qc(d){return d.replace(/\u200B/g,"")}const Nf=[hl(zh)],Vl=J.forwardRef((d,e)=>{const{className:t="",onChange:n=()=>{},defaultValue:s="",onFocus:i=()=>{},onBlur:o=()=>{},onSubmit:a,"data-testid":r}=d,[c,h]=b.useState(s.length>0?hl(s):""),[u,m]=b.useState(),g=b.useCallback(C=>{Rf.debug("handleChange",C),h(C),n(Zc(Qc(C)))},[n]),p=b.useCallback(()=>{const C=Qc(c),f=Zc(C);f!==C&&h(hl(f)),o()},[c,o]);return l.jsx("div",{className:"d-flex flex-row align-items-center",children:l.jsx(wf,{ref:e,className:$(t),example:Nf,getNextSegmentValue:yf,onChange:g,onSelect:m,onSubmit:a,pattern:Df,placeholder:Ff,selection:u,value:c,onFocus:i,onBlur:p,"data-testid":r})})});Vl.displayName="DateTimeInput";Vl.defaultProps={className:"",onChange:()=>{},defaultValue:"",onFocus:()=>{},onBlur:()=>{},"data-testid":void 0};const Mf=Vl;class kf extends b.PureComponent{static defaultProps={placeholder:"Search",className:"",matchCount:null,debounceMs:250,id:"","data-testid":void 0};constructor(e){super(e),this.searchInput=J.createRef(),this.handleChange=this.handleChange.bind(this),this.sendUpdate=Ye(this.sendUpdate.bind(this),e.debounceMs),this.state={value:e.value}}componentDidUpdate(e){const{value:t}=this.props;e.value!==t&&this.setState({value:t})}searchInput;focus(){this.searchInput.current?.focus()}handleChange(e){this.setState({value:e.target.value},this.sendUpdate)}sendUpdate(){const{onChange:e}=this.props,{value:t}=this.state;e(t)}render(){const{placeholder:e,className:t,matchCount:n,id:s,"data-testid":i}=this.props,{value:o}=this.state;return l.jsx(_s,{value:o,placeholder:e,onChange:this.handleChange,className:t,matchCount:n,ref:this.searchInput,id:s,"data-testid":i})}}const Of=kf;const Af=Z.module("ItemListItem");class Bl extends b.Component{static defaultProps={children:null,isDraggable:!1,isFocused:!1,isSelected:!1,itemIndex:0,"data-testid":void 0,onBlur(){},onClick(){},onContextMenu(){},onDragStart(){},onDrag(){},onDragOver(){},onDragEnd(){},onDrop(){},onDoubleClick(){},onFocus(){},onMouseDown(){},onMouseMove(){},onMouseUp(){},style:{}};static handleKeyDown(){return Af.log("ItemListItem.handleKeyDown false"),!1}constructor(e){super(e),this.handleBlur=this.handleBlur.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleClick=this.handleClick.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.handleDragStart=this.handleDragStart.bind(this),this.handleDrag=this.handleDrag.bind(this),this.handleDragOver=this.handleDragOver.bind(this),this.handleDragEnd=this.handleDragEnd.bind(this),this.handleDrop=this.handleDrop.bind(this),this.handleDoubleClick=this.handleDoubleClick.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this.itemRef=J.createRef()}itemRef;handleBlur(e){const{itemIndex:t,onBlur:n}=this.props;n(t,e)}handleFocus(e){const{itemIndex:t,onFocus:n}=this.props;n(t,e)}handleClick(e){const{itemIndex:t,onClick:n}=this.props;n(t,e)}handleContextMenu(e){const{itemIndex:t,onContextMenu:n}=this.props;n(t,e)}handleDragStart(e){const{itemIndex:t,onDragStart:n}=this.props;n(t,e)}handleDrag(e){const{itemIndex:t,onDrag:n}=this.props;n(t,e)}handleDragOver(e){e.preventDefault();const{itemIndex:t,onDragOver:n}=this.props;n(t,e)}handleDragEnd(e){const{itemIndex:t,onDragEnd:n}=this.props;n(t,e)}handleDrop(e){const{itemIndex:t,onDrop:n}=this.props;n(t,e)}handleDoubleClick(e){const{itemIndex:t,onDoubleClick:n}=this.props;n(t,e)}handleMouseMove(e){const{itemIndex:t,onMouseMove:n}=this.props;n(t,e)}handleMouseDown(e){const{itemIndex:t,onMouseDown:n}=this.props;n(t,e)}handleMouseUp(e){const{itemIndex:t,onMouseUp:n}=this.props;n(t,e)}render(){const{isDraggable:e,isFocused:t,isSelected:n,style:s,children:i,"data-testid":o}=this.props;return l.jsx("div",{className:$("item-list-item",{active:n},{"is-focused":t},{"is-draggable":e}),onKeyDown:Bl.handleKeyDown,onContextMenuCapture:this.handleContextMenu,onClick:this.handleClick,onDrag:this.handleDrag,onDragStart:this.handleDragStart,onDragOver:this.handleDragOver,onDragEnd:this.handleDragEnd,onDrop:this.handleDrop,onDoubleClick:this.handleDoubleClick,onMouseDown:this.handleMouseDown,onMouseMove:this.handleMouseMove,onMouseUp:this.handleMouseUp,tabIndex:-1,ref:this.itemRef,role:"listitem",style:s,onFocus:this.handleFocus,onBlur:this.handleBlur,draggable:e,"data-testid":o,children:i})}}const Lf=Bl;const Jc=Z.module("ItemList"),ed=5;class Bt extends b.PureComponent{static CACHE_SIZE=1e3;static DEFAULT_ROW_HEIGHT=20;static DEFAULT_OVERSCAN=10;static defaultProps={offset:0,items:[],rowHeight:Bt.DEFAULT_ROW_HEIGHT,isDeselectOnClick:!0,isDoubleClickSelect:!1,isDragSelect:!0,isMultiSelect:!1,isStickyBottom:!1,disableSelect:!1,onFocusChange(){},onSelect(){},onSelectionChange(){},onViewportChange(){},overscanCount:Bt.DEFAULT_OVERSCAN,renderItem:Bt.renderItem,selectedRanges:[],focusSelector:".item-list-item","data-testid":void 0};static renderItem({item:e}){return l.jsx("div",{className:"item-list-item-content",children:e!=null&&(e.displayValue??e.value??`${e}`)})}constructor(e){super(e),this.handleItemBlur=this.handleItemBlur.bind(this),this.handleItemContextMenu=this.handleItemContextMenu.bind(this),this.handleItemFocus=this.handleItemFocus.bind(this),this.handleItemDoubleClick=this.handleItemDoubleClick.bind(this),this.handleItemMouseDown=this.handleItemMouseDown.bind(this),this.handleItemMouseMove=this.handleItemMouseMove.bind(this),this.handleItemMouseUp=this.handleItemMouseUp.bind(this),this.handleItemsRendered=this.handleItemsRendered.bind(this),this.handleWindowMouseUp=this.handleWindowMouseUp.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.handleScroll=this.handleScroll.bind(this),this.handleResize=this.handleResize.bind(this),this.renderInnerElement=this.renderInnerElement.bind(this),this.list=J.createRef(),this.listContainer=J.createRef();const{isStickyBottom:t,selectedRanges:n}=e;this.state={focusIndex:null,mouseDownIndex:null,selectedRanges:n,overscanStartIndex:0,height:null,isDragging:!1,isStuckToBottom:t,scrollOffset:null,mouseX:null,mouseY:null}}componentDidUpdate(e,t){const{selectedRanges:n,itemCount:s}=this.props,{focusIndex:i,isStuckToBottom:o,scrollOffset:a,height:r,selectedRanges:c}=this.state;if(o&&!this.isListAtBottom()&&s>0&&this.scrollToBottom(),(a!==t.scrollOffset||r!==t.height)&&this.sendViewportUpdate(),n!==e.selectedRanges&&n!==c)this.setSelectedRanges(n);else if(c!==t.selectedRanges){const{onSelectionChange:h}=this.props;h(c)}if(i!==t.focusIndex){const{onFocusChange:h}=this.props;h(i)}}componentWillUnmount(){window.removeEventListener("mouseup",this.handleWindowMouseUp)}list;listContainer;getItemSelected=ge((e,t)=>hn.isSelected(t,e),{max:Bt.CACHE_SIZE});getCachedItem=ge((e,t,n,s,i,o,a,r)=>{const c=o({item:n,itemIndex:e,isFocused:s,isSelected:i,style:a});return l.jsx(Lf,{onContextMenu:this.handleItemContextMenu,onDoubleClick:this.handleItemDoubleClick,onMouseDown:this.handleItemMouseDown,onFocus:this.handleItemFocus,onBlur:this.handleItemBlur,disableSelect:r,onMouseMove:this.handleItemMouseMove,onMouseUp:this.handleItemMouseUp,isFocused:s,isSelected:i,itemIndex:e,style:a,children:c},t)},{max:Bt.CACHE_SIZE});getOuterElement=ge(e=>{const t=J.forwardRef((n,s)=>l.jsx("div",{ref:s,tabIndex:-1,onKeyDown:e,role:"presentation",...n}));return t.displayName="ItemListOuterElement",t});getInnerElement=ge(()=>{const e=J.forwardRef((t,n)=>l.jsx("div",{className:"item-list-inner-element",ref:n,...t}));return e.displayName="ItemListInnerElement",e});getItemData=ge((e,t,n)=>({items:e,selectedRanges:t,renderItem:n}));focus(){this.listContainer.current?.focus()}restoreScrollPosition(){const{scrollOffset:e}=this.state;e!=null&&this.listContainer.current?.scrollTo(0,e)}getElement(e){if(this.listContainer.current==null)return null;const{focusSelector:t}=this.props,{overscanStartIndex:n}=this.state,s=this.listContainer.current.querySelectorAll(t),i=e-n;return s[i]}focusItem(e){const{disableSelect:t}=this.props;if(t)return;this.setState({focusIndex:e});const n=this.getElement(e);n instanceof HTMLElement&&n.focus()}scrollToItem(e){const t=this.getElement(e);t?.scrollIntoView({block:"center"})}handleItemContextMenu(e,t){const{selectedRanges:n}=this.state,i=hn.isSelected(n,e)||Ve.isModifierKeyDown(t);this.toggleSelect(e,t.shiftKey,i,!1)}handleItemDoubleClick(e,t){const{isDoubleClickSelect:n,onSelect:s}=this.props;n&&this.setState(({selectedRanges:i})=>({selectedRanges:hn.selectRange(i,[e,e])}),()=>{s(e,t)})}handleItemMouseDown(e,t){const{selectedRanges:n}=this.state;if(!(t.target instanceof HTMLElement&&["button","select","input","textarea"].indexOf(t.target.tagName.toLowerCase())!==-1)){if(t.button===2&&n.length===0){this.focusItem(e),this.selectItem(e);return}t.button!=null&&t.button!==0||(this.setState({mouseDownIndex:e,mouseX:t.clientX,mouseY:t.clientY}),window.addEventListener("mouseup",this.handleWindowMouseUp))}}handleItemBlur(e,t){Jc.debug2("item blur",e,t.currentTarget,t.relatedTarget),(!t.relatedTarget||this.listContainer.current&&t.relatedTarget instanceof HTMLElement&&!this.listContainer.current.contains(t.relatedTarget))&&this.setState({focusIndex:null})}handleItemFocus(e,t){Jc.debug2("item focus",e,t.target),this.setState(n=>{const{focusIndex:s}=n;return s!==e?{focusIndex:e}:null})}handleItemMouseMove(e,t){const{isDragSelect:n,isMultiSelect:s,disableSelect:i}=this.props,{mouseDownIndex:o,selectedRanges:a,mouseX:r,mouseY:c}=this.state;if(o==null||i)return;const h=Math.abs(t.clientX-(r??0)),u=Math.abs(t.clientY-(c??0));h>ed&&u>ed&&this.setState({isDragging:!0}),(n||o===e)&&(this.focusItem(e),s?(!n&&!this.getItemSelected(e,a)&&!Ve.isModifierKeyDown(t)&&this.deselectAll(),this.selectRange([Math.min(o,e),Math.max(o,e)])):this.toggleSelect(e,t.shiftKey,Ve.isModifierKeyDown(t),!1))}handleItemMouseUp(e,t){const{isDeselectOnClick:n,isDoubleClickSelect:s,onSelect:i}=this.props,{mouseDownIndex:o,isDragging:a}=this.state;if(!(t.target instanceof HTMLElement&&["button","select","input","textarea"].indexOf(t.target.tagName.toLowerCase())!==-1)){if(o===e&&!a){const r=t.shiftKey,c=Ve.isModifierKeyDown(t);this.focusItem(e),this.toggleSelect(e,r,c,n),!s&&!r&&!c&&i(e,t)}this.resetMouseState()}}handleItemsRendered({overscanStartIndex:e}){this.setState({overscanStartIndex:e})}handleResize({height:e}){this.setState({height:e})}handleMouseLeave(){this.setState({mouseDownIndex:null})}handleWindowMouseUp(){this.resetMouseState(),window.removeEventListener("mouseup",this.handleWindowMouseUp)}handleKeyDown(e){const{isMultiSelect:t,itemCount:n,onSelect:s}=this.props,{focusIndex:i}=this.state;let o=i;if(e.key==="Enter"||e.key===" "){!t&&o!=null&&this.setState({selectedRanges:[[o,o]]},()=>{o!=null&&s(o,e)});return}if(e.key==="ArrowUp")o!=null&&o>=0?o=Math.max(0,o-1):o=n-1;else if(e.key==="ArrowDown")o!=null&&o>=0?o=Math.min(o+1,n-1):o=0;else return;if(i!==o){e.stopPropagation(),e.preventDefault(),this.focusItem(o);const{selectedRanges:a}=this.state;if(e.shiftKey&&a.length>0){const r=a[a.length-1];this.selectRange([Math.min(o,r[0]),Math.max(o,r[1])])}else this.deselectAll(),o!==null?this.selectItem(o):this.listContainer.current?.focus();this.scrollIntoView(o)}}handleScroll({scrollUpdateWasRequested:e,scrollOffset:t}){this.setState(n=>{if(e)return{scrollOffset:t};const{isStickyBottom:s}=this.props,{height:i}=n;return{isStuckToBottom:s&&this.isListAtBottom({scrollOffset:t,height:i}),scrollOffset:t}})}resetMouseState(){this.setState({mouseDownIndex:null,isDragging:!1})}scrollToBottom(){const{itemCount:e}=this.props;this.list.current&&this.list.current.scrollToItem(e)}scrollIntoView(e){this.list.current&&this.list.current.scrollToItem(e)}toggleSelect(e,t,n,s=!0){const{isMultiSelect:i}=this.props,{selectedRanges:o}=this.state;if(i&&t&&o.length>0){const a=o[o.length-1];this.selectRange([Math.min(a[0],e),Math.max(e,a[1])])}else i&&o.length===1&&o[0][0]===e&&o[0][1]===e?s&&this.deselectItem(e):i&&n?this.getItemSelected(e,o)?s&&this.deselectItem(e):this.selectItem(e):(this.deselectAll(),this.selectItem(e))}deselectAll(){const{itemCount:e}=this.props;this.deselectRange([0,e])}deselectItem(e){this.deselectRange([e,e])}deselectRange(e){hn.validateRange(e),this.setState(({selectedRanges:t})=>({selectedRanges:hn.deselectRange(t,e)}))}selectItem(e){const{disableSelect:t}=this.props;t||this.selectRange([e,e])}selectRange(e){hn.validateRange(e),this.setState(({selectedRanges:t})=>({selectedRanges:hn.selectRange(t,e)}))}setSelectedRanges(e){this.setState({selectedRanges:e})}sendViewportUpdate(){const{scrollOffset:e,height:t}=this.state;if(e!=null&&t!=null){const{onViewportChange:n,rowHeight:s}=this.props,i=Math.floor(e/s),o=i+Math.ceil(t/s);n(i,o)}}isListAtBottom({scrollOffset:e,height:t}=this.state){if(t==null||e==null)return!1;const{itemCount:n,rowHeight:s}=this.props;return e+t>=n*s}renderInnerElement({index:e,style:t}){const{items:n,offset:s,renderItem:i,disableSelect:o}=this.props,{focusIndex:a,selectedRanges:r}=this.state;if(e<s||e>=s+n.length)return null;const c=n[e-s];return this.getCachedItem(e,e,c,e===a&&!o,this.getItemSelected(e,r),i,t,o)}render(){const{items:e,itemCount:t,overscanCount:n,renderItem:s,rowHeight:i,"data-testid":o}=this.props,{selectedRanges:a,isStuckToBottom:r}=this.state;return l.jsx(Vm,{className:"item-list-auto-sizer",onResize:this.handleResize,children:({width:c,height:h})=>l.jsx(Bm,{className:"item-list-scroll-pane",height:h,width:c,initialScrollOffset:r?t*i:0,itemCount:t,itemSize:i,itemData:this.getItemData(e,a,s),onScroll:this.handleScroll,onItemsRendered:this.handleItemsRendered,ref:this.list,outerElementType:this.getOuterElement(this.handleKeyDown),outerRef:this.listContainer,innerElementType:this.getInnerElement(),overscanCount:n,"data-testid":o,children:this.renderInnerElement})})}}class Ts extends b.PureComponent{static DEFAULT_ROW_HEIGHT=30;static defaultProps={className:"",draggingItemClassName:"",offset:0,items:[],rowHeight:Ts.DEFAULT_ROW_HEIGHT,isDeselectOnClick:!0,isDoubleClickSelect:!0,isDropDisabled:!1,isDragDisabled:!1,isMultiSelect:!1,isStickyBottom:!1,disableSelect:!1,style:null,onFocusChange(){},onSelect(){},onSelectionChange(){},onViewportChange(){},renderItem:Ts.renderItem,selectedRanges:[],draggablePrefix:"draggable-item",droppableId:"droppable-item-list","data-testid":void 0};static renderHandle(){return l.jsxs("div",{children:[l.jsx(tt,{children:"Drag to re-order"}),l.jsx(Q,{icon:ko})]})}static renderBadge({text:e}){return e!=null&&e.length>0?l.jsx("span",{className:"number-badge",children:e}):null}static renderTextItem({text:e,badgeText:t="",className:n=""}){return l.jsxs("div",{className:$("item-list-item-content","draggable-item-list-item-content",n),children:[l.jsx("span",{className:"title",children:e}),Ts.renderBadge({text:t}),Ts.renderHandle()]})}static renderItem({item:e,isClone:t,selectedCount:n}){const s=e!=null?e.displayValue??e.value??`${e}`:"",i=t!==void 0&&t?`${n}`:"",o=t!==void 0&&t?"item-list-item-clone":"";return Ts.renderTextItem({text:s,badgeText:i,className:o})}static getDraggableId(e,t){return`${e}/${t}`}static getDraggableIndex(e){const t=e.split("/").pop();return parseInt(t!==void 0?t:"",10)}constructor(e){super(e),this.handleSelectionChange=this.handleSelectionChange.bind(this),this.itemList=J.createRef(),this.state={selectedCount:0}}itemList;selectItem(e){this.itemList.current?.selectItem(e)}focusItem(e){this.itemList.current?.focusItem(e)}scrollToItem(e){this.itemList.current?.scrollToItem(e)}getCachedDraggableItem=ge((e,t,n,s,i,o,a,r)=>l.jsx(Rl,{draggableId:Ts.getDraggableId(e,s),index:s,isDragDisabled:a,children:c=>l.jsx("div",{role:"menuitem",className:"draggable-item-list-item",ref:c.innerRef,tabIndex:-1,...c.draggableProps,...c.dragHandleProps,children:t({item:n,itemIndex:s,isFocused:i,isSelected:o,style:r,isClone:!1})})},s),{max:Bt.CACHE_SIZE});handleSelectionChange(e){this.setState({selectedCount:hn.count(e)});const{onSelectionChange:t}=this.props;t(e)}getCachedRenderDraggableItem=ge((e,t,n)=>({item:s,itemIndex:i,isFocused:o,isSelected:a,style:r})=>this.getCachedDraggableItem(e,n,s,i,o,a,t,r),{max:1});getCachedRenderClone=ge((e,t,n,s)=>(i,o,a)=>{const{selectedCount:r}=this.state,{draggableProps:c,dragHandleProps:h,innerRef:u}=i,{index:m}=a.source,g=t[m-n];return l.jsx("div",{className:$("draggable-item-list-dragging-item-container",e),...c,...h,ref:u,children:l.jsx("div",{className:$("draggable-item-list-dragging-item",{"two-dragged":r===2},{"multiple-dragged":r>2}),children:s({item:g,itemIndex:m,isFocused:!1,isSelected:!0,style:{},isClone:!0,selectedCount:r})})})},{max:1});render(){const{className:e,draggablePrefix:t,draggingItemClassName:n,droppableId:s,isDoubleClickSelect:i,isDragDisabled:o,isDropDisabled:a,isMultiSelect:r,isStickyBottom:c,itemCount:h,items:u,offset:m,onFocusChange:g,onSelect:p,onViewportChange:C,renderItem:f,rowHeight:S,selectedRanges:v,style:w,"data-testid":T}=this.props;return l.jsx(tr,{isDropDisabled:a,droppableId:s,mode:"virtual",renderClone:this.getCachedRenderClone(n,u,m,f),"data-testid":T,children:(y,E)=>l.jsx("div",{role:"menu",className:$("draggable-item-list",e,{"is-drop-disabled":a,"is-drag-disabled":o,"is-dragging-from-this":E.draggingFromThisWith,"is-dragging-over":E.isDraggingOver,"is-dropping":E.draggingOverWith}),style:w,ref:y.innerRef,...y.droppableProps,children:l.jsx(Bt,{focusSelector:".draggable-item-list-item",isDoubleClickSelect:i,isDragSelect:!1,isMultiSelect:r,isStickyBottom:c,itemCount:h,items:u,onFocusChange:g,onSelect:p,onSelectionChange:this.handleSelectionChange,onViewportChange:C,offset:m,ref:this.itemList,renderItem:this.getCachedRenderDraggableItem(t,o,f),rowHeight:S,selectedRanges:v})})})}}const Cn=Ts;class Oa{static reorder(e,t,n,s){const i=e===n?Oa.adjustDestinationIndex(s,t):s,o=Oa.removeItems(e,t);return n.splice(i,0,...o),o}static removeItems(e,t){const n=[],s=t.map((i,o)=>({range:i,index:o})).sort((i,o)=>o.range[0]-i.range[0]);for(let i=0;i<s.length;i+=1){const{range:o,index:a}=s[i],[r,c]=o;n[a]=e.splice(r,c-r+1)}return Um(n)}static adjustDestinationIndex(e,t){let n=e;for(let s=0;s<t.length;s+=1){const[i,o]=t[s];if(i>e)break;n-=Math.min(o,e-1)-i+1}return n}static startDragging(){document.documentElement.classList.add("drag-pointer-events-none")}static stopDragging(){document.documentElement.classList.remove("drag-pointer-events-none")}}const vn=Oa;function Kh({on:d,id:e,className:t,isInvalid:n,disabled:s=!1,onClick:i,"data-testid":o}){return l.jsx("button",{type:"button",className:$("btn","btn-switch",t,{active:d},{"is-invalid":n}),id:e,onClick:i,disabled:s,"data-testid":o,children:l.jsx("div",{className:"handle"})})}function td(d){return d.isOn!==void 0}function Pf({item:d,onSelect:e=()=>{},"data-testid":t}){const{icon:n,subtitle:s,title:i}=d,o=b.useMemo(()=>td(d)?()=>{d.onChange(!d.isOn)}:e,[d,e]);return l.jsxs("div",{className:"btn btn-navigation-menu-item","data-testid":`menu-item-${i}`,onClick:o,onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&o()},tabIndex:0,role:"menuitem",children:[n!==void 0&&l.jsx("div",{className:"icon",children:l.jsx(Q,{icon:n})}),l.jsx("div",{className:"title",children:i}),s!==void 0&&l.jsx("div",{className:"shortcut",children:s}),l.jsx("div",{className:"accessory","data-testid":t,children:td(d)?l.jsx(Kh,{on:d.isOn,onClick:a=>{a.stopPropagation(),o()}}):l.jsx(Q,{icon:Ih})})]})}function qh({items:d,onSelect:e=()=>{},"data-testid":t}){return l.jsx("div",{className:"navigation-menu-view","data-testid":t,children:l.jsx("ul",{className:"navigation-menu-list",children:d.map((n,s)=>l.jsx("li",{children:l.jsx(Pf,{item:n,onSelect:()=>{e(s)}})},n.title))})})}function nd({children:d,onBack:e,onClose:t,title:n,"data-testid":s}){return l.jsxs("div",{className:"navigation-page","data-testid":s,children:[l.jsxs("div",{className:"navigation-title-bar",children:[l.jsx("div",{className:"navigation-left-buttons",children:e!==void 0&&l.jsx(B,{kind:"ghost",className:"btn-back","data-testid":"btn-page-back",onClick:e,icon:Dg,children:"Back"})}),l.jsx("div",{className:"navigation-title",children:n}),l.jsx("div",{className:"navigation-right-buttons",children:t!==void 0&&l.jsx(B,{kind:"ghost",className:"btn-close px-2 m-1","data-testid":"btn-page-close",onClick:t,icon:qi,tooltip:"Close"})})]}),l.jsx("div",{className:"navigation-content",children:d})]})}function _f({children:d,"data-testid":e}){const t=b.useMemo(()=>J.Children.toArray(d),[d]),n=lr(t),[s,i]=b.useState(t[t.length-1]),[o,a]=b.useState(null),[r,c]=b.useState(null);b.useEffect(function(){if(n===void 0||t===n)return;const g=t[t.length-1];t.length===n.length||n.length===0||o!==null||r!==null?o!==null&&g!==o?a(g):g!==r&&g!==s&&i(g):t.length>n.length?a(g):t.length<n.length&&(i(g),c(n[n.length-1]))},[t,n,o,r,s]);const h=b.useCallback(()=>{i(o),a(null)},[o]),u=b.useCallback(()=>{c(null)},[]);return l.jsxs("div",{className:"navigation-stack",children:[l.jsx("div",{className:"main-view","data-testid":e,children:s}),l.jsx(ft,{in:r!=null,timeout:ze.transitionMidMs,classNames:"slide-right",onEntered:u,children:l.jsx(l.Fragment,{children:r!=null&&l.jsx("div",{className:"popping-view",children:r})})}),l.jsx(ft,{in:o!=null,timeout:ze.transitionMidMs,classNames:"slide-left",onEntered:h,children:l.jsx(l.Fragment,{children:o!=null&&l.jsx("div",{className:"pushing-view",children:o})})})]})}function jf({children:d,disabled:e,value:t,"data-testid":n}){return l.jsx("option",{value:t,disabled:e,"data-testid":n,children:d})}function hr(d){const{children:e,disabled:t=!1,name:n,onChange:s,value:i="","data-testid":o}=d,[a]=b.useState(n??_e());return l.jsx(l.Fragment,{children:J.Children.map(e,r=>r?J.cloneElement(r,{name:a,onChange:r.props.onChange??s,checked:i===r.props.value,disabled:r.props.disabled??t,"data-testid":o}):null)})}const Ul=J.forwardRef((d,e)=>{const{checked:t,children:n,className:s="",disabled:i=!1,inputClassName:o="",isInvalid:a=!1,labelClassName:r="",name:c,onChange:h,value:u,"data-testid":m}=d,[g]=b.useState(_e());return l.jsxs("div",{className:$("custom-control custom-radio",s),children:[l.jsx("input",{type:"radio",id:g,"data-testid":m,name:c,ref:e,className:$("custom-control-input",o,{"is-invalid":a}),checked:t,disabled:i,value:u,onChange:h}),l.jsx("label",{className:$("custom-control-label",r),htmlFor:g,children:n})]})});Ul.displayName="RadioItem";Ul.defaultProps={checked:void 0,className:"",disabled:!1,inputClassName:"",isInvalid:!1,labelClassName:"",name:void 0,onChange:void 0,"data-testid":void 0};const ts=Ul;function Hf({children:d,onBlur:e,onChange:t,className:n,defaultValue:s,name:i,value:o,disabled:a,"data-testid":r}){const c=b.useCallback(h=>{t(h.target.value)},[t]);return l.jsx("select",{className:$("custom-select",n),onBlur:e,onChange:c,defaultValue:s,value:o,name:i,disabled:a,"data-testid":r,children:d})}class Vf extends b.PureComponent{static defaultProps={disabled:!1,rowHeight:21,onBlur:()=>{},"data-testid":void 0};constructor(e){super(e),this.handleBlur=this.handleBlur.bind(this),this.handleScroll=this.handleScroll.bind(this),this.handleSelect=this.handleSelect.bind(this),this.list=J.createRef(),this.topRow=null,this.bottomRow=null}componentDidMount(){this.sendViewportUpdate()}componentDidUpdate(){this.sendViewportUpdate()}list;topRow;bottomRow;getCachedItem=ge((e,t,n,s,i,o,a)=>{const r={height:i},c=s??n;return l.jsx("li",{className:"value-list-item",style:r,tabIndex:-1,children:l.jsx(Zt,{checked:o,disabled:a,onChange:()=>this.handleSelect(e),children:c})},t)},{max:1e3});getCachedItems=ge((e,t,n,s)=>{const i=[];for(let o=0;o<e.length;o+=1){const a=e[o],{value:r,displayValue:c,isSelected:h}=a,u=n+o,m=u,g=this.getCachedItem(u,m,r,c,t,h,s);i.push(g)}return i},{max:1});handleBlur(e){if(!e.relatedTarget||this.list.current&&e.relatedTarget instanceof HTMLElement&&!this.list.current.contains(e.relatedTarget)){const{onBlur:t}=this.props;t?.(e)}}handleScroll(){this.sendViewportUpdate()}handleSelect(e){const{items:t,offset:n,onSelect:s}=this.props,i=e-n;if(i>=0&&i<t.length){const o=t[i],{value:a}=o;s(e,a)}else s(e,null)}sendViewportUpdate(){if(!this.list.current||this.list.current.clientHeight===0)return;const{onViewportChange:e,rowHeight:t}=this.props,n=this.list.current.scrollTop,s=n+this.list.current.clientHeight,i=Math.floor(n/t),o=Math.ceil(s/t);(this.topRow!==i||this.bottomRow!==o)&&(this.topRow=i,this.bottomRow=o,e(i,o))}getElement(e){return this.list.current==null?null:this.list.current.querySelectorAll(".value-list-item")[e]}scrollIntoView(e){this.getElement(e)?.scrollIntoView({block:"center"})}render(){const{className:e,disabled:t,isInvalid:n,items:s,itemCount:i,offset:o,rowHeight:a,"data-testid":r}=this.props,c=this.getCachedItems(s,a,o,t);return l.jsx("div",{className:$("select-value-list-scroll-pane h-100 w-100",{"is-invalid":n},e),onBlur:this.handleBlur,onScroll:this.handleScroll,ref:this.list,"data-testid":r,children:l.jsx("div",{className:"select-value-list",style:{height:i*a},children:l.jsx("ol",{className:"select-value-list-content",style:{position:"absolute",height:s.length*a,top:o*a,left:0},children:c})})})}}const Bf=Vf,sd=Z.module("Shortcut");var de=(d=>(d.CTRL="MODIFIER_CTRL",d.CMD="MODIFIER_CMD",d.ALT="MODIFIER_ALT",d.OPTION="MODIFIER_OPTION",d.SHIFT="MODIFIER_SHIFT",d))(de||{}),ue=(d=>(d.A="A",d.B="B",d.C="C",d.D="D",d.E="E",d.F="F",d.G="G",d.H="H",d.I="I",d.J="J",d.K="K",d.L="L",d.M="M",d.N="N",d.O="O",d.P="P",d.Q="Q",d.R="R",d.S="S",d.T="T",d.U="U",d.V="V",d.W="W",d.X="X",d.Y="Y",d.Z="Z",d.ZERO="0",d.ONE="1",d.TWO="2",d.THREE="3",d.FOUR="4",d.FIVE="5",d.SIX="6",d.SEVEN="7",d.EIGHT="8",d.NINE="9",d.BACKSPACE="Backspace",d.ESCAPE="Escape",d.ENTER="Enter",d.DELETE="Delete",d.SLASH="/",d.QUESTION_MARK="?",d.BACKSLASH="\\",d.PIPE="|",d.MINUS="-",d.UNDERSCORE="_",d.EQUALS="=",d.PLUS="+",d.BACKTICK="`",d.TILDE="~",d.COMMA=",",d.LEFT_CHEVRON="<",d.PERIOD=".",d.RIGHT_CHEVRON=">",d.SEMICOLON=";",d.COLON=":",d.SINGLE_QUOTE="'",d.DOUBLE_QUOTE='"',d.LEFT_BRACKET="[",d.RIGHT_BRACKET="]",d.LEFT_CURLY="{",d.RIGHT_CURLY="}",d.F1="F1",d.F2="F2",d.F3="F3",d.F4="F4",d.F5="F5",d.F6="F6",d.F7="F7",d.F8="F8",d.F9="F9",d.F10="F10",d.F11="F11",d.F12="F12",d))(ue||{});const Uf=new Set(["Enter","Delete","F1","F2","F3","F4","F5","F6","F7","F8","F9","F10","F11","F12"]);class Ae extends xl{id;name;tooltip;isEditable;defaultKeyState;keyState;static NULL_KEY_STATE={metaKey:!1,shiftKey:!1,altKey:!1,ctrlKey:!1,keyValue:null};static isAllowedKey(e){return Object.values(ue).includes(e)}static isValidKeyState(e){const{keyValue:t}=e;return t===null?!0:!Ae.isMacPlatform&&e.metaKey||!Ae.isAllowedKey(t)?!1:!(!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey)||Uf.has(t)}static isMacPlatform=Ve.isMacPlatform();static createKeyState(e){const t={altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1,keyValue:e[e.length-1]};return e.forEach(n=>{switch(n){case"MODIFIER_CTRL":t.ctrlKey=!0;break;case"MODIFIER_ALT":case"MODIFIER_OPTION":t.altKey=!0;break;case"MODIFIER_CMD":t.metaKey=!0;break;case"MODIFIER_SHIFT":t.shiftKey=!0;break}}),t}static getKeyStateFromEvent(e){const{key:t,keyCode:n}=e;let s="";return t==="Shift"||t==="Meta"||t==="Control"||t==="Alt"?s="":!Ae.isAllowedKey(t)&&Ae.isAllowedKey(String.fromCharCode(n))?s=String.fromCharCode(n):s=t,{keyValue:s,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey}}static getWindowsDisplayText(e){let t="";return e.ctrlKey&&(t+="Ctrl+"),e.altKey&&(t+="Alt+"),e.shiftKey&&(t+="Shift+"),e.keyValue==="Escape"?t+="Esc":e.keyValue!==null&&(t+=e.keyValue),t}static getMacDisplayText(e){let t="";switch(e.ctrlKey&&(t+="⌃"),e.altKey&&(t+="⌥"),e.shiftKey&&(t+="⇧"),e.metaKey&&(t+="⌘"),e.keyValue){case"Enter":t+="⏎";break;case"Escape":t+="⎋";break;case"Backspace":t+="⌫";break;case"Delete":t+="⌦";break;case null:break;default:t+=e.keyValue}return t}static doKeyStatesMatch(e,t){return e.keyValue?.toUpperCase()===t.keyValue?.toUpperCase()&&e.altKey===t.altKey&&e.ctrlKey===t.ctrlKey&&e.metaKey===t.metaKey&&e.shiftKey===t.shiftKey}static getDisplayText(e){return e.keyValue===null?"":Ae.isMacPlatform?Ae.getMacDisplayText(e):Ae.getWindowsDisplayText(e)}constructor({id:e,shortcut:t,macShortcut:n,isEditable:s=!0,name:i,tooltip:o}){super(),this.id=e,this.name=i,this.tooltip=o,this.isEditable=s;const r=Ae.isMacPlatform?n:t;this.defaultKeyState=Ae.createKeyState(r),this.keyState=this.defaultKeyState}getDisplayText(){return Ae.getDisplayText(this.keyState)}getKeyState(){return this.keyState}setKeyState(e){Ae.isValidKeyState(e)?(sd.debug2(`Shortcut ${this.id} updated to ${JSON.stringify(e)}`),this.keyState=e,this.dispatchEvent(new Ue("onUpdate",{detail:this}))):sd.debug2(`Shortcut ${this.id} tried to update to invalid keyState ${JSON.stringify(e)}`)}getDefaultKeyState(){return this.defaultKeyState}isDefault(){return Ae.doKeyStatesMatch(this.getDefaultKeyState(),this.getKeyState())}setToNull(){this.setKeyState(Ae.NULL_KEY_STATE)}isNull(){return Ae.doKeyStatesMatch(this.keyState,Ae.NULL_KEY_STATE)}setToDefault(){this.setKeyState(this.defaultKeyState)}matchesKeyState(e){return Ae.doKeyStatesMatch(e,this.keyState)}matchesEvent(e){return this.matchesKeyState(Ae.getKeyStateFromEvent(e))}}const id=Z.module("ShortcutRegistry");class $f extends xl{shortcutMap=new Map;shortcutsByCategory=new Map;createAndAdd(e){const t=new Ae(e);return this.add(t)}add(e){const t=this.shortcutMap.get(e.id);if(t)return id.warn(`Skipping attempt to add duplicate shortcut ID to registry: ${e.id}`),t;id.debug2(`Adding shortcut to registry: ${e.id}`),e.addEventListener("onUpdate",({detail:s})=>this.dispatchEvent(new Ue("onUpdate",{detail:s})));const n=e.id.split(".")[0];return this.shortcutMap.set(e.id,e),this.shortcutsByCategory.has(n)?this.shortcutsByCategory.get(n)?.push(e):this.shortcutsByCategory.set(n,[e]),e}get(e){return this.shortcutMap.get(e)}getConflictingShortcuts(e){return Array.from(this.shortcutMap.values()).filter(t=>!t.isNull()&&t.matchesKeyState(e))}}const Wf=Object.freeze(new $f),Ne=Wf,Gf={COPY:Ne.createAndAdd({id:"GLOBAL.COPY",name:"Copy",shortcut:[de.CTRL,ue.C],macShortcut:[de.CMD,ue.C],isEditable:!1}),PASTE:Ne.createAndAdd({id:"GLOBAL.PASTE",name:"Paste",shortcut:[de.CTRL,ue.V],macShortcut:[de.CMD,ue.V],isEditable:!1}),SAVE:Ne.createAndAdd({id:"GLOBAL.SAVE",name:"Save",shortcut:[de.CTRL,ue.S],macShortcut:[de.CMD,ue.S],isEditable:!1}),SELECT_ALL:Ne.createAndAdd({id:"GLOBAL.SELECT_ALL",name:"Select All",shortcut:[de.CTRL,ue.A],macShortcut:[de.CMD,ue.A],isEditable:!1}),LINKER:Ne.createAndAdd({id:"GLOBAL.LINKER",name:"Linker",shortcut:[de.CTRL,ue.L],macShortcut:[de.CMD,ue.L]}),LINKER_CLOSE:Ne.createAndAdd({id:"GLOBAL.LINKER_CLOSE",name:"Close Linker Overlay",shortcut:[ue.ESCAPE],macShortcut:[ue.ESCAPE],isEditable:!1})},ss=Gf;const $l=J.forwardRef((d,e)=>{const{children:t,className:n,disabled:s,id:i,isLinked:o,isLinkedSource:a,isInvalid:r,onClick:c,onMouseEnter:h,onMouseLeave:u,style:m,"data-testid":g}=d;return l.jsxs("button",{ref:e,type:"button",className:$("btn-socketed",{"btn-socketed-linked":o!==void 0&&o||a},{"btn-socketed-linked-source":a},{"is-invalid":r},n),id:i,onClick:c,onMouseEnter:h,onMouseLeave:u,style:m,disabled:s,"data-testid":g,children:[t,l.jsx(Q,{icon:Fl,className:"linked btn-socketed-icon",transform:"down-1"}),l.jsx(Q,{icon:Fg,className:"is-invalid btn-socketed-icon"})]})});$l.displayName="SocketedButton";$l.defaultProps={children:void 0,className:"",disabled:!1,id:void 0,isLinked:!1,isLinkedSource:!1,isInvalid:!1,onClick:void 0,onMouseEnter:void 0,onMouseLeave:void 0,style:void 0,"data-testid":void 0};const Yh=$l,{dh:R}=globalThis,Wl=I.shape({name:I.string.isRequired,type:I.string.isRequired,description:I.string,constituentType:I.string}),zf=I.shape({not:I.func.isRequired,and:I.func.isRequired,or:I.func.isRequired});I.shape({asc:I.func.isRequired,desc:I.func.isRequired,abs:I.func.isRequired,column:Wl.isRequired,direction:I.string.isRequired,isAbs:I.bool.isRequired});I.shape({columns:I.arrayOf(Wl).isRequired,customColumns:I.arrayOf(I.string).isRequired,filter:I.arrayOf(zf),addEventListener:I.func.isRequired,removeEventListener:I.func.isRequired,size:I.number.isRequired,sort:I.arrayOf(I.any),copy:I.func.isRequired,applyFilter:I.func.isRequired,applySort:I.func.isRequired,applyCustomColumns:I.func.isRequired,description:I.string});I.shape({columns:I.arrayOf(Wl),filter:I.arrayOf(I.any),isExpanded:I.func.isRequired,saveExpandedState:I.func.isRequired,addEventListener:I.func.isRequired,removeEventListener:I.func.isRequired,size:I.number.isRequired,sort:I.arrayOf(I.any),applyFilter:I.func.isRequired,applySort:I.func.isRequired});const jr=I.shape({name:I.string.isRequired,type:I.string.isRequired});I.shape({created:I.arrayOf(jr).isRequired,updated:I.arrayOf(jr).isRequired,removed:I.arrayOf(jr).isRequired});I.shape({groupingColumns:I.arrayOf(I.string),aggregations:I.shape({}),includeConstituents:I.bool,includeOriginalColumns:I.bool,includeDescriptions:I.bool});I.shape({addEventListener:I.func.isRequired,removeEventListener:I.func.isRequired,onLogMessage:I.func,getTable:I.func.isRequired,runCode:I.func.isRequired});function Xh({type:d}){switch(d){case R.VariableType.TABLE:case R.VariableType.TABLEMAP:case R.VariableType.TREETABLE:case R.VariableType.HIERARCHICALTABLE:return l.jsx(Q,{icon:Nl});case R.VariableType.FIGURE:return l.jsx(Q,{icon:Fh});case R.VariableType.PANDAS:return l.jsx(Q,{icon:Ng});default:return l.jsx(Q,{icon:ll})}}class Kf extends b.Component{constructor(e){super(e),this.container=null}componentDidMount(){this.colorize()}container;colorize(){const{children:e}=this.props;this.container&&e!=null&&Qn.colorizeElement(this.container,{theme:"dh-dark"})}render(){const{children:e,language:t}=this.props;return l.jsx("div",{children:l.jsx("div",{"data-lang":t,ref:n=>{this.container=n},style:{pointerEvents:"none"},children:e})})}}const ur=Kf;class qf{static get LANGUAGE_MAP(){return new Map([["python","Python"],["groovy","Groovy"],["scala","Scala"]])}}const Zh=qf;class Aa{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)?[]:$m.parse(e).filter(t=>!this.hasComment(t)).map(t=>this.hasPattern(t)?t.pattern:this.hasOp(t)?t.op:`${t}`)}static formatTimestamp(e){if(e==null||!(e instanceof Date))return null;const t=`${e.getHours()}`.padStart(2,"0"),n=`${e.getMinutes()}`.padStart(2,"0"),s=`${e.getSeconds()}`.padStart(2,"0"),i=`${e.getMilliseconds()}`.padStart(3,"0");return`${t}:${n}:${s}.${i}`}static isTableType(e){return e===R.VariableType.TABLE||e===R.VariableType.TREETABLE||e===R.VariableType.HIERARCHICALTABLE}static isWidgetType(e){return e===R.VariableType.FIGURE||e===R.VariableType.OTHERWIDGET||e===R.VariableType.PANDAS}static isOpenableType(e){return Aa.isTableType(e)||Aa.isWidgetType(e)}static isFigureType(e){return e===R.VariableType.FIGURE}static isPandas(e){return e===R.VariableType.PANDAS}}const ul=Aa;function Qh({children:d}){return l.jsxs("div",{className:"console-history-item-result",children:[l.jsx("div",{className:"console-history-gutter",children:"-"}),l.jsx("div",{className:"console-history-content",children:d})]})}Qh.propTypes={children:I.node.isRequired};class Yf extends b.Component{static defaultProps={disabled:!1};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}timer;startTime;updateElapsed(){this.setState({elapsed:Math.round((Date.now()-this.startTime)/1e3)})}render(){const{disabled:e,onCancelClick:t}=this.props,{elapsed:n}=this.state;return l.jsx("div",{className:$("console-history-result-in-progress",{disabled:e}),children:l.jsxs("span",{className:"badge",children:[l.jsx(yn,{})," Running... ",Xi.formatElapsedTime(n)," ",l.jsx(B,{className:"console-history-result-in-progress-cancel",kind:"ghost",icon:qi,tooltip:"Cancel",onClick:t,disabled:e})]})})}}const Xf=Yf;class La extends b.PureComponent{static defaultProps={message:""};static mouseDragThreshold=5;constructor(e){super(e),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}}mouseX;mouseY;isClicking;handleKeyPress(e){switch(e.key){case"Enter":case" ":this.handleToggleError(),e.stopPropagation(),e.preventDefault();break}}handleMouseDown(e){this.mouseX=e.clientX,this.mouseY=e.clientY,this.isClicking=!0}handleMouseMove(e){this.mouseX!=null&&this.mouseY!=null?(Math.abs(e.clientX-this.mouseX)>=La.mouseDragThreshold||Math.abs(e.clientY-this.mouseY)>=La.mouseDragThreshold)&&(this.isClicking=!1):this.isClicking&&(this.isClicking=!1)}handleMouseUp(e){this.isClicking&&!e.shiftKey&&!e.metaKey&&!e.altKey&&this.handleToggleError(),this.mouseX=null,this.mouseY=null,this.isClicking=!1}handleToggleError(){this.setState(e=>({isExpanded:!e.isExpanded}))}handleMouseEnter(){this.setState({isTriggerHovered:!0})}handleMouseLeave(){this.setState({isTriggerHovered:!1})}render(){const{isExpanded:e,isTriggerHovered:t}=this.state,{message:n}=this.props;M(n);const s=n.indexOf(`
3
- `),i=s>-1;let o=n;i&&(o=n.slice(0,s));const a=n.slice(s),r=t?"error-btn-link error-btn-link--active":"error-btn-link";return l.jsxs("div",{className:$("error-message",{expanded:e}),children:[i&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"error-gutter",children:l.jsx("button",{type:"button",onClick:this.handleToggleError,className:r,tabIndex:-1,children:l.jsx(Q,{icon:e?Pn:Nh,transform:"left-3"})})}),l.jsxs("div",{className:"error-content",children:[l.jsx("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}),e?a:""]})]}),!i&&l.jsx("div",{className:"error-content",children:l.jsx("div",{className:"console-error-text",children:o})})]},"error")}}const Zf=La;const od=Z.module("ConsoleHistoryItem");class Qf extends b.PureComponent{static defaultProps={disabled:!1};constructor(e){super(e),this.handleCancelClick=this.handleCancelClick.bind(this),this.handleObjectClick=this.handleObjectClick.bind(this)}handleObjectClick(e){od.debug("handleObjectClick",e);const{openObject:t}=this.props;t(e)}handleCancelClick(){const{item:e}=this.props;e!=null&&e.cancelResult&&(od.debug(`Cancelling command: ${e.command}`),e.cancelResult())}render(){const{disabled:e,item:t,language:n}=this.props,{disabledObjects:s,result:i}=t;let o=null;t.command!=null&&t.command!==""&&(o=l.jsxs("div",{className:"console-history-item-command",children:[l.jsx("div",{className:"console-history-gutter",children:">"}),l.jsx("div",{className:"console-history-content",children:l.jsx(ur,{language:n,children:t.command})})]}));const a=[];let r=!1;if(i){const{error:h,message:u,changes:m}=i;if(m){const{created:g,updated:p}=m;[...g,...p].forEach(C=>{r=!0;const{title:f}=C,S=`${f}`,v=e===void 0||e||(s??[]).indexOf(S)>=0,w=l.jsx(B,{kind:"primary",onClick:()=>this.handleObjectClick(C),className:"btn-console-object",disabled:v,icon:l.jsx(Xh,{type:C.type}),children:f},S);a.push(w)})}if(h!=null&&t.command==null){let g=`${h.message??h}`;g||(g=h);const p=l.jsx(Zf,{message:g},"result-error");a.push(p)}if(u!==void 0&&u!==""){const g=l.jsx("div",{className:"log-message",children:u},"log-message");a.push(g)}}else{r=!0;const h=l.jsx(Xf,{onCancelClick:this.handleCancelClick,disabled:e},"in_progress");a.push(h)}let c=null;return a.length>0&&(c=l.jsx(Qh,{children:a})),l.jsxs("div",{className:$("console-command-result",{"console-result-buttons":r}),children:[o,c]})}}const Jf=Qf;class Gl extends b.Component{static defaultProps={disabled:!1};static itemKey(e,t){return`${e}.${t.command}.${t.result&&t.result.message}.${t.result&&t.result.error}`}render(){const{disabled:e,items:t,language:n,openObject:s}=this.props,i=[];for(let o=0;o<t.length;o+=1){const a=t[o],r=l.jsx(Jf,{disabled:e,item:a,openObject:s,language:n},Gl.itemKey(o,a));i.push(r)}return l.jsx("div",{className:"container-fluid console-history",children:i})}}const eC=Gl,tC={name:"Console",CLEAR:Ne.createAndAdd({id:"CONSOLE.CLEAR",name:"Clear",shortcut:[de.CTRL,ue.L],macShortcut:[de.CTRL,ue.C]}),FOCUS_HISTORY:Ne.createAndAdd({id:"CONSOLE.FOCUS_HISTORY",name:"Focus History",shortcut:[de.CTRL,ue.H],macShortcut:[de.CTRL,de.OPTION,ue.H]})},nC={name:"Command History",FOCUS_HISTORY:Ne.createAndAdd({id:"COMMAND_HISTORY.FOCUS_HISTORY",name:"Focus History Search",shortcut:[de.CTRL,ue.H],macShortcut:[de.CTRL,de.OPTION,ue.H]}),SEND_TO_CONSOLE:Ne.createAndAdd({id:"COMMAND_HISTORY.SEND_TO_CONSOLE",name:"Send to Console",shortcut:[ue.ENTER],macShortcut:[ue.ENTER]}),SEND_TO_NOTEBOOK:Ne.createAndAdd({id:"COMMAND_HISTORY.SEND_TO_NOTEBOOK",name:"Send to Notebook",shortcut:[de.CTRL,ue.ENTER],macShortcut:[de.CMD,ue.ENTER]}),RUN:Ne.createAndAdd({id:"COMMAND_HISTORY.RUN",name:"Run",shortcut:[de.ALT,ue.R],macShortcut:[de.OPTION,ue.R]})},sC={name:"Notebook",RUN:Ne.createAndAdd({id:"NOTEBOOK.RUN",name:"Run",shortcut:[de.ALT,ue.R],macShortcut:[de.OPTION,ue.R]}),RUN_SELECTED:Ne.createAndAdd({id:"NOTEBOOK.RUN_SELECTED",name:"Run Selected",shortcut:[de.ALT,de.SHIFT,ue.R],macShortcut:[de.OPTION,de.SHIFT,ue.R]}),FIND:Ne.createAndAdd({id:"NOTEBOOK.FIND",name:"Find",shortcut:[de.CTRL,ue.F],macShortcut:[de.CMD,ue.F],isEditable:!1}),MINIMAP:Ne.createAndAdd({id:"NOTEBOOK.MINIMAP",name:"Show Minimap",shortcut:[de.ALT,ue.M],macShortcut:[de.OPTION,ue.M]}),WORDWRAP:Ne.createAndAdd({id:"NOTEBOOK.WORDWRAP",name:"Word Wrap",shortcut:[de.ALT,ue.Z],macShortcut:[de.OPTION,ue.Z]})},iC={CONSOLE:tC,COMMAND_HISTORY:nC,NOTEBOOK:sC},Mt=iC,gt=Object.freeze({FATAL:"FATAL",STDERR:"STDERR",ERROR:"ERROR",WARN:"WARN",STDOUT:"STDOUT",INFO:"INFO",DEBUG:"DEBUG",TRACE:"TRACE"}),oC="#2d2a2e",aC="#fcfcfa",rC="#fcd65b",lC="#b2b1b2",cC="#9edc6f",dC="#76d9e4",hC="#f95d84",uC="#aa9af4",mC="#f95d84",gC="#fcfcfa",pC="#7c7b7c",Ce={"error-foreground":"#f95d84",background:oC,foreground:aC,"line-height":"19px",string:rC,"string-delim":"#929192",delimiter:lC,predefined:cC,keyword:dC,storage:hC,number:uC,operator:mC,identifier:gC,"namespace-identifier":"#f95d84","identifier-js":"#fcd65b",comment:pC,"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","text-link-foreground":"#929192","text-link-active-foreground":"#f0f0ee","editor-link-active-foreground":"#f0f0ee"},fC="python",CC={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/}}},SC={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"]]}},bC={id:fC,conf:CC,language:SC},wC=bC,vC="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/}}},EC={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"]]}},yC={id:vC,conf:TC,language:EC},RC=yC,xC="scala",IC={wordPattern:/(unary_[@~!#%^&*()\-=+\\|:<>/?]+)|([a-zA-Z_$][\w$]*?_=)|(`[^`]+`)|([a-zA-Z_$][\w$]*)/g,comments:{lineComment:"//",blockComment:["/*","*/"]},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],folding:{markers:{start:/^\s*\/\/\s*(?:(?:#?region\b)|(?:<editor-fold\b))/,end:/^\s*\/\/\s*(?:(?:#?endregion\b)|(?:<\/editor-fold>))/}}},DC={keywords:["asInstanceOf","catch","class","classOf","def","do","else","extends","finally","for","foreach","forSome","if","import","isInstanceOf","macro","match","new","object","package","return","throw","trait","try","type","until","val","var","while","with","yield","given","enum","then"],softKeywords:["as","export","extension","end","derives","on"],constants:["true","false","null","this","super"],modifiers:["abstract","final","implicit","lazy","override","private","protected","sealed"],softModifiers:["inline","opaque","open","transparent","using"],name:/(?:[a-z_$][\w$]*|`[^`]+`)/,type:/(?:[A-Z][\w$]*)/,symbols:/[=><!~?:&|+\-*/^\\%@#]+/,digits:/\d+(_+\d+)*/,hexdigits:/[[0-9a-fA-F]+(_+[0-9a-fA-F]+)*/,escapes:/\\(?:[btnfr\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,fstring_conv:/[bBhHsScCdoxXeEfgGaAt]|[Tn](?:[HIklMSLNpzZsQ]|[BbhAaCYyjmde]|[RTrDFC])/,tokenizer:{root:[[/\braw"""/,{token:"string.quote",bracket:"@open",next:"@rawstringt"}],[/\braw"/,{token:"string.quote",bracket:"@open",next:"@rawstring"}],[/\bs"""/,{token:"string.quote",bracket:"@open",next:"@sstringt"}],[/\bs"/,{token:"string.quote",bracket:"@open",next:"@sstring"}],[/\bf""""/,{token:"string.quote",bracket:"@open",next:"@fstringt"}],[/\bf"/,{token:"string.quote",bracket:"@open",next:"@fstring"}],[/"""/,{token:"string.quote",bracket:"@open",next:"@stringt"}],[/"/,{token:"string.quote",bracket:"@open",next:"@string"}],[/(@digits)[eE]([-+]?(@digits))?[fFdD]?/,"number.float","@allowMethod"],[/(@digits)\.(@digits)([eE][-+]?(@digits))?[fFdD]?/,"number.float","@allowMethod"],[/0[xX](@hexdigits)[Ll]?/,"number.hex","@allowMethod"],[/(@digits)[fFdD]/,"number.float","@allowMethod"],[/(@digits)[lL]?/,"number","@allowMethod"],[/\b_\*/,"key"],[/\b(_)\b/,"keyword","@allowMethod"],[/\bimport\b/,"keyword","@import"],[/\b(case)([ \t]+)(class)\b/,["keyword.modifier","white","keyword"]],[/\bcase\b/,"keyword","@case"],[/\bva[lr]\b/,"keyword","@vardef"],[/\b(def)([ \t]+)((?:unary_)?@symbols|@name(?:_=)|@name)/,["keyword","white","identifier"]],[/@name(?=[ \t]*:(?!:))/,"variable"],[/(\.)(@name|@symbols)/,[{token:"operator"},{token:"@rematch",next:"@allowMethod"}]],[/([{(])(\s*)(@name(?=\s*=>))/,["@brackets","white","variable"]],[/@name/,{cases:{"@keywords":"keyword","@softKeywords":"keyword","@modifiers":"keyword.modifier","@softModifiers":"keyword.modifier","@constants":{token:"constant",next:"@allowMethod"},"@default":{token:"identifier",next:"@allowMethod"}}}],[/@type/,"type","@allowMethod"],{include:"@whitespace"},[/@[a-zA-Z_$][\w$]*(?:\.[a-zA-Z_$][\w$]*)*/,"annotation"],[/[{(]/,"@brackets"],[/[})]/,"@brackets","@allowMethod"],[/\[/,"operator.square"],[/](?!\s*(?:va[rl]|def|type)\b)/,"operator.square","@allowMethod"],[/]/,"operator.square"],[/([=-]>|<-|>:|<:|:>|<%)(?=[\s\w()[\]{},."'`])/,"keyword"],[/@symbols/,"operator"],[/[;,.]/,"delimiter"],[/'[a-zA-Z$][\w$]*(?!')/,"attribute.name"],[/'[^\\']'/,"string","@allowMethod"],[/(')(@escapes)(')/,[{token:"string"},{token:"string.escape"},{token:"string",next:"@allowMethod"}]],[/'/,"string.invalid"]],import:[[/;/,"delimiter","@pop"],[/^|$/,"","@pop"],[/[ \t]+/,"white"],[/[\n\r]+/,"white","@pop"],[/\/\*/,"comment","@comment"],[/@name|@type/,"type"],[/[(){}]/,"@brackets"],[/[[\]]/,"operator.square"],[/[.,]/,"delimiter"]],allowMethod:[[/^|$/,"","@pop"],[/[ \t]+/,"white"],[/[\n\r]+/,"white","@pop"],[/\/\*/,"comment","@comment"],[/(?==>[\s\w([{])/,"keyword","@pop"],[/(@name|@symbols)(?=[ \t]*[[({"'`]|[ \t]+(?:[+-]?\.?\d|\w))/,{cases:{"@keywords":{token:"keyword",next:"@pop"},"->|<-|>:|<:|<%":{token:"keyword",next:"@pop"},"@default":{token:"@rematch",next:"@pop"}}}],["","","@pop"]],comment:[[/[^/*]+/,"comment"],[/\/\*/,"comment","@push"],[/\*\//,"comment","@pop"],[/[/*]/,"comment"]],case:[[/\b_\*/,"key"],[/\b(_|true|false|null|this|super)\b/,"keyword","@allowMethod"],[/\bif\b|=>/,"keyword","@pop"],[/`[^`]+`/,"identifier","@allowMethod"],[/@name/,"variable","@allowMethod"],[/:::?|\||@(?![a-z_$])/,"keyword"],{include:"@root"}],vardef:[[/\b_\*/,"key"],[/\b(_|true|false|null|this|super)\b/,"keyword"],[/@name/,"variable"],[/:::?|\||@(?![a-z_$])/,"keyword"],[/=|:(?!:)/,"operator","@pop"],[/$/,"white","@pop"],{include:"@root"}],string:[[/[^\\"\n\r]+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/"/,{token:"string.quote",bracket:"@close",switchTo:"@allowMethod"}]],stringt:[[/[^\\"\n\r]+/,"string"],[/@escapes/,"string.escape"],[/\\./,"string.escape.invalid"],[/"(?=""")/,"string"],[/"""/,{token:"string.quote",bracket:"@close",switchTo:"@allowMethod"}],[/"/,"string"]],fstring:[[/@escapes/,"string.escape"],[/"/,{token:"string.quote",bracket:"@close",switchTo:"@allowMethod"}],[/\$\$/,"string"],[/(\$)([a-z_]\w*)/,["operator","identifier"]],[/\$\{/,"operator","@interp"],[/%%/,"string"],[/(%)([-#+ 0,(])(\d+|\.\d+|\d+\.\d+)(@fstring_conv)/,["metatag","keyword.modifier","number","metatag"]],[/(%)(\d+|\.\d+|\d+\.\d+)(@fstring_conv)/,["metatag","number","metatag"]],[/(%)([-#+ 0,(])(@fstring_conv)/,["metatag","keyword.modifier","metatag"]],[/(%)(@fstring_conv)/,["metatag","metatag"]],[/./,"string"]],fstringt:[[/@escapes/,"string.escape"],[/"(?=""")/,"string"],[/"""/,{token:"string.quote",bracket:"@close",switchTo:"@allowMethod"}],[/\$\$/,"string"],[/(\$)([a-z_]\w*)/,["operator","identifier"]],[/\$\{/,"operator","@interp"],[/%%/,"string"],[/(%)([-#+ 0,(])(\d+|\.\d+|\d+\.\d+)(@fstring_conv)/,["metatag","keyword.modifier","number","metatag"]],[/(%)(\d+|\.\d+|\d+\.\d+)(@fstring_conv)/,["metatag","number","metatag"]],[/(%)([-#+ 0,(])(@fstring_conv)/,["metatag","keyword.modifier","metatag"]],[/(%)(@fstring_conv)/,["metatag","metatag"]],[/./,"string"]],sstring:[[/@escapes/,"string.escape"],[/"/,{token:"string.quote",bracket:"@close",switchTo:"@allowMethod"}],[/\$\$/,"string"],[/(\$)([a-z_]\w*)/,["operator","identifier"]],[/\$\{/,"operator","@interp"],[/./,"string"]],sstringt:[[/@escapes/,"string.escape"],[/"(?=""")/,"string"],[/"""/,{token:"string.quote",bracket:"@close",switchTo:"@allowMethod"}],[/\$\$/,"string"],[/(\$)([a-z_]\w*)/,["operator","identifier"]],[/\$\{/,"operator","@interp"],[/./,"string"]],interp:[[/{/,"operator","@push"],[/}/,"operator","@pop"],{include:"@root"}],rawstring:[[/[^"]/,"string"],[/"/,{token:"string.quote",bracket:"@close",switchTo:"@allowMethod"}]],rawstringt:[[/[^"]/,"string"],[/"(?=""")/,"string"],[/"""/,{token:"string.quote",bracket:"@close",switchTo:"@allowMethod"}],[/"/,"string"]],whitespace:[[/[ \t\r\n]+/,"white"],[/\/\*/,"comment","@comment"],[/\/\/.*$/,"comment"]]}},FC={id:xC,conf:IC,language:DC},NC=FC,MC="deephavenDb",kC={comments:{lineComment:"#",blockComment:["'''","'''"]},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"',notIn:["string"]},{open:"'",close:"'",notIn:["string","comment"]}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],onEnterRules:[{beforeText:/^\s*(?:def|class|for|if|elif|else|while|try|with|finally|except|async).*?:\s*$/,action:{indentAction:1}}],folding:{offSide:!0,markers:{start:/^\s*#region\b/,end:/^\s*#endregion\b/}}},OC={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"]]}},AC={id:MC,conf:kC,language:OC},LC=AC,PC="log",_C={},jC={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"}]]}},HC={id:PC,conf:_C,language:jC},VC=HC,In=Z.module("MonacoUtils");class Nn{static init({getWorker:e}={}){In.debug("Initializing Monaco..."),e!==void 0&&Nn.registerGetWorker(e);const{registerLanguages:t,removeHashtag:n}=Nn,s=[{token:"",foreground:n(Ce.foreground)},{token:"string",foreground:n(Ce.string)},{token:"string.delim",foreground:n(Ce["string-delim"])},{token:"keyword",foreground:n(Ce.keyword)},{token:"identifier.js",foreground:n(Ce["identifier-js"])},{token:"delimiter",foreground:n(Ce.delimiter)},{token:"comment",foreground:n(Ce.comment)},{token:"number",foreground:n(Ce.number)},{token:"storage",foreground:n(Ce.storage)},{token:"identifier",foreground:n(Ce.identifier)},{token:"namespace.identifier",foreground:n(Ce["namespace-identifier"])},{token:"operator",foreground:n(Ce.operator)},{token:"predefined",foreground:n(Ce.predefined)},{token:"error.log",foreground:Ce["log-error"].substring(1)},{token:"warn.log",foreground:n(Ce["log-warn"])},{token:"info.log",foreground:n(Ce["log-info"])},{token:"stdout.log",foreground:n(Ce["log-stdout"])},{token:"trace.log",foreground:n(Ce["log-trace"])},{token:"debug.log",foreground:n(Ce["log-debug"])},{token:"date.log",foreground:n(Ce["log-date"])}],i={errorForeground:Ce["error-foreground"],"inputOption.activeBorder":Ce["input-option-active-border"],"editor.background":Ce.background,"editor.foreground":Ce.foreground,"editor.lineHighlightBackground":Ce["editor-line-highlight-bg"],"editorLineNumber.foreground":Ce["editor-line-number-foreground"],"editor.selectionBackground":Ce["editor-selection-background"],"editor.findMatchBackground":Ce["editor-find-match-background"],"editor.findMatchHighlightBackground":Ce["editor-find-match-highlight-background"],"editorSuggestWidget.background":Ce["editor-suggest-widget-background"],"editorSuggestWidget.border":Ce["editor-suggest-widget-border"],"editorSuggestWidget.foreground":Ce["editor-suggest-widget-foreground"],"editorSuggestWidget.selectedBackground":Ce["editor-suggest-widget-selected-background"],"editorSuggestWidget.highlightForeground":Ce["editor-suggest-widget-highlightForeground"],"list.hoverBackground":Ce["list-hover-background"],"dropdown.background":Ce["context-menu-background"],"dropdown.foreground":Ce["context-menu-foreground"],"menu.selectionBackground":Ce["menu-selection-background"],"list.focusBackground":Ce["menu-selection-background"],"editorWidget.background":Ce["editor-widget-background"],"inputOption.activeBackground":Ce["input-option-active-background"],"inputOption.activeForeground":Ce["input-option-active-foreground"],focusBorder:Ce["focus-border"],"input.background":Ce["input-background"],"input.foreground":Ce["input-foreground"],"input.border":Ce["input-border"],"textLink.foreground":Ce["text-link-foreground"],"textLink.activeForeground":Ce["text-link-active-foreground"],"editorLink.activeForeground":Ce["editor-link-active-foreground"]};Qn.defineTheme("dh-dark",{base:"vs-dark",inherit:!0,rules:s,colors:i}),In.debug2("monaco theme: ",Ce),Qn.setTheme("dh-dark"),t([LC,wC,RC,VC,NC]),In.debug("Monaco initialized.")}static registerGetWorker(e){window.MonacoEnvironment={...window.MonacoEnvironment,getWorker:e}}static removeHashtag(e){return e.substring(1)}static registerLanguages(e){const t=e.map(({id:n})=>n);An.getLanguages().filter(({id:n})=>t.includes(n)).forEach(n=>{const s=n;In.debug2("Overriding default language loader:",s.id)}),e.forEach(n=>{Nn.registerLanguage(n)})}static registerLanguage(e){In.debug2("Registering language: ",e.id),An.register(e),An.onLanguage(e.id,()=>{An.setLanguageConfiguration(e.id,e.conf),An.setMonarchTokensProvider(e.id,e.language)})}static setEOL(e,t=Qn.EndOfLineSequence.LF){e.getModel()?.setEOL(t)}static openDocument(e,t){const n=e.getModel();M(n);const s={textDocument:{uri:`${n.uri}`,languageId:n.getLanguageId(),version:n.getVersionId(),text:n.getValue()}};return In.debug2("didOpenDocumentParams: ",s),t.openDocument(s),e.onDidChangeModelContent(o=>{const{changes:a,versionId:r}=o,c=[];for(let h=0;h<a.length;h+=1){const u=a[h],{range:m,rangeLength:g,text:p}=u,C={range:{start:{line:m.startLineNumber-1,character:m.startColumn-1},end:{line:m.endLineNumber-1,character:m.endColumn-1}},rangeLength:g,text:p};c.push(C)}if(c.length>0){const h={textDocument:{version:r,uri:`${n.uri}`},contentChanges:c};In.debug2("didChangeDocumentParams",h),t.changeDocument(h)}})}static closeDocument(e,t){const n=e.getModel();M(n);const s={textDocument:{uri:`${n.uri}`}};t.closeDocument(s)}static registerPasteHandler(e){e.onDidPaste(t=>{const n=/“|”/g,s=/\u200b/g,i=/\u00A0/g,o=e.getModel();M(o);const a=o.getValueInRange(t.range);(n.test(a)||s.test(a)||i.test(a))&&o.applyEdits([{range:t.range,text:a.replace(n,'"').replace(s,"").replace(i," ")}])})}static isMacPlatform(){const{platform:e}=window.navigator;return e.startsWith("Mac")}static removeConflictingKeybindings(e){const t=[{windows:"ctrl+D",mac:"meta+D"},{windows:"ctrl+H"}];try{t.forEach(n=>{Nn.isMacPlatform()&&n.mac===""||!Nn.isMacPlatform()&&n.windows===""||Nn.removeKeybinding(e,Nn.isMacPlatform()?n.mac:n.windows)})}catch(n){In.error(n)}}static removeKeybinding(e,t){if(t===void 0)return;const n=e._standaloneKeybindingService._getResolver()._map.get(t);n!=null?n.forEach(s=>{In.debug2(`Removing Monaco keybinding ${t} for ${s.command}`),e._standaloneKeybindingService.addDynamicKeybinding(`-${s.command}`,null,()=>{})}):In.warn(`Did not find any keybindings to remove for ${t}`)}static getMonacoKeyCodeFromShortcut(e){const{keyState:t}=e,{keyValue:n}=t;return n===null?0:Nn.isMacPlatform()?(t.metaKey?dn.CtrlCmd:0)|(t.shiftKey?dn.Shift:0)|(t.altKey?dn.Alt:0)|(t.ctrlKey?dn.WinCtrl:0)|jc.fromString(n):(t.ctrlKey?dn.CtrlCmd:0)|(t.shiftKey?dn.Shift:0)|(t.altKey?dn.Alt:0)|(t.metaKey?dn.WinCtrl:0)|jc.fromString(n)}static provideLinks(e){const t=[];for(let n=1;n<=e.getLineCount();n+=1){const s=e.getLineContent(n);il(s).forEach(o=>{t.push({url:o.href,range:new yg(n,o.start+1,n,o.end+1)})})}return{links:t}}}const Ht=Nn,$n=Z.module("MonacoCompletionProvider");class Js extends b.PureComponent{static lspToMonacoKind(e){const t=An.CompletionItemKind;switch(e){case 1:return t.Text;case 2:return t.Method;case 3:return t.Function;case 4:return t.Constructor;case 5:return t.Field;case 6:return t.Variable;case 7:return t.Class;case 8:return t.Interface;case 9:return t.Module;case 10:return t.Property;case 11:return t.Unit;case 12:return t.Value;case 13:return t.Enum;case 14:return t.Keyword;case 15:return t.Snippet;case 16:return t.Color;case 17:return t.File;case 18:return t.Reference;case 19:return t.Folder;case 20:return t.EnumMember;case 21:return t.Constant;case 22:return t.Struct;case 23:return t.Event;case 24:return t.Operator;case 25:return t.TypeParameter;default:return t.Variable}}static lspToMonacoRange(e){const{start:t,end:n}=e;return{startLineNumber:t.line+1,startColumn:t.character+1,endLineNumber:n.line+1,endColumn:n.character+1}}static monacoToLspPosition(e){return{line:e.lineNumber-1,character:e.column-1}}constructor(e){super(e),this.handleCompletionRequest=this.handleCompletionRequest.bind(this),this.handleSignatureRequest=this.handleSignatureRequest.bind(this),this.handleHoverRequest=this.handleHoverRequest.bind(this)}componentDidMount(){const{language:e,session:t}=this.props;this.registeredCompletionProvider=An.registerCompletionItemProvider(e,{provideCompletionItems:this.handleCompletionRequest,triggerCharacters:[".",'"',"'"]}),t.getSignatureHelp&&(this.registeredSignatureProvider=An.registerSignatureHelpProvider(e,{provideSignatureHelp:this.handleSignatureRequest,signatureHelpTriggerCharacters:["(",","]})),t.getHover&&(this.registeredHoverProvider=An.registerHoverProvider(e,{provideHover:this.handleHoverRequest}))}componentWillUnmount(){this.registeredCompletionProvider?.dispose(),this.registeredSignatureProvider?.dispose(),this.registeredHoverProvider?.dispose()}registeredCompletionProvider;registeredSignatureProvider;registeredHoverProvider;handleCompletionRequest(e,t,n){const{model:s,session:i}=this.props;if(e!==s)return null;const o={textDocument:{uri:`${e.uri}`,version:e.getVersionId()},position:Js.monacoToLspPosition(t),context:n},a=i.getCompletionItems(o);return $n.debug("Requested completion items",o),a.then(c=>($n.debug("Completion items received: ",o,c),{incomplete:!0,suggestions:c.map(u=>{const{label:m,kind:g,detail:p,documentation:C,sortText:f,filterText:S,textEdit:v,insertTextFormat:w}=u;return{label:m,kind:Js.lspToMonacoKind(g),detail:p,documentation:C?.kind==="markdown"?C:C?.value,sortText:f,filterText:S,insertText:v.text,insertTextRules:w===2?4:w,range:Js.lspToMonacoRange(v.range)}})})).catch(c=>($n.error("There was an error retrieving completion items",c),{suggestions:[]}))}handleSignatureRequest(e,t,n,s){const i={value:{signatures:[],activeSignature:0,activeParameter:0},dispose:()=>{}},{model:o,session:a}=this.props;if(e!==o||!a.getSignatureHelp)return null;const r={textDocument:{uri:`${e.uri}`,version:e.getVersionId()},position:Js.monacoToLspPosition(t),context:s},c=a.getSignatureHelp(r);return $n.debug("Requested signature help",r),c.then(u=>{$n.debug("Signatures received: ",r,c);const m=u.map(p=>{const{label:C,documentation:f,parameters:S}=p;return{documentation:f?.kind==="markdown"?f:f?.value,label:C,parameters:S??[]}});if(m.length===0)return i;const g=0;return{value:{signatures:m,activeSignature:g,activeParameter:u[g].activeParameter},dispose:()=>{}}}).catch(u=>($n.error("There was an error retrieving completion items",u),i))}handleHoverRequest(e,t){const{model:n,session:s}=this.props;if(e!==n||!s.getHover)return null;const i={textDocument:{uri:`${e.uri}`,version:e.getVersionId()},position:Js.monacoToLspPosition(t)},o=s.getHover(i);return $n.debug("Requested hover",i),o.then(r=>{$n.debug("Hover received: ",i,r);const{contents:c}=r;return{contents:c?[c]:[]}}).catch(r=>($n.error("There was an error retrieving hover",r),{contents:[]}))}render(){return null}}const Jh=Js;const Hr=Z.module("ConsoleInput"),ya=parseInt(Ce["line-height"],10),eu=6,tu=6,BC=ya+eu+tu,Vr=100;class zl extends b.PureComponent{static defaultProps={maxHeight:ya*10,scope:null,disabled:!1};static INPUT_CLASS_NAME="console-input";constructor(e){super(e),this.handleWindowResize=this.handleWindowResize.bind(this),this.commandContainer=J.createRef(),this.commandHistoryIndex=null,this.timestamp=Date.now(),this.bufferIndex=0,this.history=[],this.modifiedCommands=new Map,this.state={commandEditorHeight:ya,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()}cancelListener;commandContainer;commandEditor;commandHistoryIndex;commandSuggestionContainer;loadingPromise;timestamp;bufferIndex;history;modifiedCommands;setConsoleText(e,t=!0,n=!1){e&&(Hr.debug("Command received: ",e),n||(this.commandHistoryIndex=null,this.commandEditor?.setValue(e)),t&&this.focusEnd(),this.updateDimensions(),n&&this.processCommand(e))}initCommandEditor(){const{language:e,session:t}=this.props,n={copyWithSyntaxHighlighting:!1,cursorStyle:"block",fixedOverflowWidgets:!0,folding:!1,fontFamily:"Fira Mono",glyphMargin:!1,language:e,lineHeight:ya,lineDecorationsWidth:3,lineNumbers:"off",minimap:{enabled:!1},renderLineHighlight:"none",scrollBeyondLastLine:!1,scrollbar:{arrowSize:0,horizontal:"hidden",horizontalScrollbarSize:0},padding:{top:eu,bottom:tu},tabCompletion:"on",value:"",wordWrap:"on"},s=this.commandContainer.current;M(s),this.commandEditor=Qn.create(s,n),Ht.setEOL(this.commandEditor),Ht.openDocument(this.commandEditor,t),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:a}=this,r=o?.getPosition();M(r);const{lineNumber:c}=r,h=o?.getModel();if(i.code==="ArrowUp"&&!this.isSuggestionMenuPopulated()&&c===1){a!=null?this.loadCommand(a+1):this.loadCommand(0),this.focusStart(),i.stopPropagation(),i.preventDefault();return}if(i.code==="ArrowDown"&&!this.isSuggestionMenuPopulated()&&c===h?.getLineCount()){a!=null&&a>0?this.loadCommand(a-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 u=this.commandEditor?.getValue().trim();u!==void 0&&(this.processCommand(u),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(dn.CtrlCmd|Ds.KeyF,()=>{}),Ht.removeConflictingKeybindings(this.commandEditor),Ht.registerPasteHandler(this.commandEditor),this.commandEditor.focus(),this.updateDimensions(),this.setState({model:this.commandEditor.getModel()})}destroyCommandEditor(){const{session:e}=this.props;this.commandEditor&&(Ht.closeDocument(this.commandEditor,e),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 e=this.commandEditor?.getModel();M(e);const t=e.getLineLength(1)+1,n=this.commandEditor?.getTopForPosition(1,t);M(n),this.commandEditor?.setPosition({lineNumber:1,column:t}),this.commandEditor?.setScrollTop(n),this.commandEditor?.focus()}focusEnd(){const e=this.commandEditor?.getModel();M(e);const t=e.getLineCount(),n=e.getLineLength(t)+1,s=this.commandEditor?.getTopForPosition(t,n);M(s),this.commandEditor?.setPosition({lineNumber:t,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(e){if(e!==null&&e>=this.history.length)return;const t=this.modifiedCommands.get(e),n=e===null?"":this.history[this.history.length-e-1];this.commandHistoryIndex=e,this.commandEditor?.getModel()?.setValue(t??n),e!==null&&e>this.history.length-Vr&&this.loadMoreHistory()}async loadMoreHistory(){try{if(this.loadingPromise!=null||this.bufferIndex==null)return;const{commandHistoryStorage:e,language:t,scope:n}=this.props;this.loadingPromise=ve.makeCancelable(e.getTable(t,n??"",this.timestamp),o=>o.close());const s=await this.loadingPromise;s.setReversed(!0),s.setViewport({top:this.bufferIndex,bottom:this.bufferIndex+Vr-1}),this.loadingPromise=ve.makeCancelable(s.getViewportData(),()=>s.close());const i=await this.loadingPromise;this.bufferIndex+=Vr,this.bufferIndex>=s.size&&(this.bufferIndex=null),this.history=[...i.items.filter(({name:o},a,r)=>a===0||o!==r[a-1].name).map(({name:o})=>o).reverse(),...this.history],this.loadingPromise=void 0,s.close()}catch(e){if(this.loadingPromise=void 0,ve.isCanceled(e)){Hr.debug2("Promise canceled, not loading history");return}Hr.error("Error fetching history",e)}}processCommand(e){this.commandHistoryIndex=null,this.modifiedCommands.clear(),M(e),e!==""&&(this.history.length===0||e!==this.history[this.history.length-1])&&this.history.push(e),this.updateDimensions();const{onSubmit:t}=this.props;t(e)}updateDimensions(){if(!this.commandEditor)return;const{maxHeight:e}=this.props;M(e);const t=this.commandEditor.getContentHeight(),n=Math.max(Math.min(t,e),BC),i={overviewRulerLanes:t>n?void 0:0};this.setState({commandEditorHeight:n},()=>{this.commandEditor?.updateOptions(i),this.commandEditor?.layout()})}render(){const{disabled:e,language:t,session:n}=this.props,{commandEditorHeight:s,isFocused:i,model:o}=this.state;return l.jsx("div",{className:$("console-input-wrapper",{disabled:e}),children:l.jsxs("div",{className:$("console-input-inner-wrapper",{focus:i}),children:[l.jsx("div",{className:zl.INPUT_CLASS_NAME,ref:this.commandContainer,style:{height:s}}),o&&l.jsx(Jh,{model:o,language:t,session:n})]})})}}const ad=zl;const rd="pasted values",UC=[/^audio.*/,/^font.*/,/^image.*/,/^video.*/],Br=[".csv",".tsv",".tab",".psv",".dsv",".txt"],ld=[".zip"];class ei extends b.Component{static defaultProps={allowZip:!1,dragError:null};static MULTIPLE_FILE_ERROR="Please select only one file";static FILE_TYPE_ERROR="Filetype not supported.";static isValidDropItem(e){return e!=null&&e.kind==="file"&&!UC.find(t=>t.test(e.type))}static isValidExtension(e,t=!1){return Br.some(n=>e.endsWith(n))||t&&ld.some(n=>e.endsWith(n))}static handleDragOver(e){e.preventDefault(),e.stopPropagation()}static getIcon(e){return e===rd?Hc:e.endsWith(".csv")?Mg:e.endsWith(".zip")?kg:Og}constructor(e){super(e),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=J.createRef(),this.divElem=J.createRef(),this.state={selectedFileName:""}}componentDidMount(){this.divElem.current?.addEventListener("paste",this.handlePasteEvent),this.divElem.current?.focus()}componentWillUnmount(){this.divElem.current?.removeEventListener("paste",this.handlePasteEvent)}fileElem;divElem;handleSelectFile(){this.fileElem.current&&(this.fileElem.current.value="",this.fileElem.current?.click())}handleFiles(e){e.stopPropagation(),e.preventDefault();const{files:t}=e.target;t!=null&&this.handleFile(t[0])}handleDrop(e){const{allowZip:t,clearDragError:n,dragError:s}=this.props;if(e.preventDefault(),e.stopPropagation(),s!=null){n();return}if(e.dataTransfer==null||e.dataTransfer.items==null||e.dataTransfer.items.length===0)return;const i=e.dataTransfer.items[0].getAsFile();M(i),ei.isValidExtension(i.name,t)?this.handleFile(i):this.setState({dropError:ei.FILE_TYPE_ERROR})}unstageFile(e){const{onCancel:t}=this.props;e.stopPropagation(),e.preventDefault(),t(),this.setState({selectedFileName:"",dropError:void 0})}handleFile(e){const{onFileOpened:t}=this.props;t(e),this.setState({selectedFileName:e.name,dropError:void 0})}handleMenuPaste(){const{onPaste:e,onError:t,uploadInProgress:n}=this.props;n||navigator.clipboard.readText().then(s=>{e(s),this.setState({selectedFileName:rd,dropError:void 0})}).catch(s=>t(s))}handlePasteEvent(e){e.stopPropagation(),e.preventDefault(),this.handleMenuPaste()}makeContextMenuItems(){const{uploadInProgress:e}=this.props;return[{title:"Paste",icon:Hc,action:this.handleMenuPaste,shortcut:ss.PASTE,disabled:e}]}getValidExtensions=fe(e=>e?[...Br,...ld]:[...Br]);getAcceptString=fe(e=>this.getValidExtensions(e).join(", "));getFileTypeErrorString=fe(e=>zt.join(this.getValidExtensions(e),"or"));render(){const{allowZip:e,dragError:t,uploadInProgress:n}=this.props,{selectedFileName:s,dropError:i}=this.state,o=t??i,a=this.makeContextMenuItems();return l.jsxs("div",{ref:this.divElem,className:"csv-overlay fill-parent-absolute",onDragOver:ei.handleDragOver,onDrop:this.handleDrop,tabIndex:-1,children:[l.jsx(ie,{actions:a}),l.jsx("input",{ref:this.fileElem,type:"file",id:"fileElem",accept:this.getAcceptString(e),style:{display:"none"},onChange:this.handleFiles,"data-testid":"fileElem"}),!s&&(o===void 0||o==="")&&l.jsxs("div",{className:"message-content",children:[l.jsx("div",{className:"message-icon",children:l.jsx(Q,{icon:Ag})}),l.jsx("label",{children:"Drop file (or paste values) here to import"}),l.jsx("div",{className:"message-small",children:l.jsx("label",{children:"or"})}),l.jsx(B,{kind:"primary",onClick:this.handleSelectFile,children:"Select File..."})]}),s&&(o===void 0||o==="")&&l.jsxs("div",{className:"selected-content",children:[l.jsx("div",{className:"selected-icon",children:l.jsx(Q,{icon:ei.getIcon(s)})}),l.jsxs("div",{className:"selected-text",children:[l.jsx("label",{children:"Selected File"}),l.jsxs("label",{className:"selected-name",children:[s,!n&&l.jsx(B,{kind:"ghost",className:"ml-2",onClick:this.unstageFile,icon:Jt,tooltip:"Remove"})]})]})]}),Boolean(o)&&l.jsxs("div",{className:"message-content",children:[l.jsx("div",{className:"message-icon",children:l.jsx(Q,{icon:As})}),l.jsx("label",{children:o}),o===ei.FILE_TYPE_ERROR&&l.jsx("div",{className:"message-small",children:l.jsx("label",{children:this.getFileTypeErrorString(e)})})]})]})}}const Ri=ei;class $C{static INTEGER="int";static LONG="long";static DOUBLE="double";static BOOLEAN="bool";static STRING="string";static DATE_TIME="datetime";static LOCAL_TIME="localtime"}const Le=$C,cd="unknown",WC=2147483647,GC=-2147483648,dd=/^[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]+)?$/,hd=/^([0-9]+T)?([0-9]+):([0-9]+)(:[0-9]+)?(?:\.[0-9]{1,9})?$/;class yt{static determineType(e,t,n){if(!e||e===n)return t;switch(t){case Le.STRING:return Le.STRING;case Le.INTEGER:return yt.checkInteger(e);case Le.LONG:return yt.checkLong(e);case Le.DOUBLE:return yt.checkDouble(e);case Le.BOOLEAN:return yt.checkBoolean(e);case Le.DATE_TIME:return yt.checkDateTime(e);case Le.LOCAL_TIME:return yt.checkLocalTime(e);default:return yt.getTypeFromUnknown(e)}}static isNotParsableNumber(e){return isNaN(e)||e==="Infinity"||e==="-Infinity"}static checkInteger(e){const t=e.replace(/,/g,"");return yt.isNotParsableNumber(t)?Le.STRING:yt.getNumberType(t)}static checkLong(e){const t=e.replace(/,/g,"");return yt.isNotParsableNumber(t)?Le.STRING:t.includes(".")?Le.DOUBLE:Le.LONG}static checkDouble(e){const t=e.replace(/,/g,"");return yt.isNotParsableNumber(t)?Le.STRING:Le.DOUBLE}static checkBoolean(e){const t=e.toLowerCase();return t==="true"||t==="false"?Le.BOOLEAN:Le.STRING}static checkDateTime(e){return dd.test(e)?Le.DATE_TIME:Le.STRING}static checkLocalTime(e){return hd.test(e)?Le.LOCAL_TIME:Le.STRING}static getTypeFromUnknown(e){const t=e.replace(/,/g,"");if(yt.isNotParsableNumber(t)){const n=e.toLowerCase();return n==="true"||n==="false"?Le.BOOLEAN:dd.test(e)&&e.includes(":")?Le.DATE_TIME:hd.test(e)?Le.LOCAL_TIME:Le.STRING}return yt.getNumberType(t)}static getNumberType(e){if(e.includes("."))return Le.DOUBLE;const t=e.startsWith("-")?11:10;if(e.length>t)return Le.LONG;const n=parseInt(e,10);return n>WC||n<GC?Le.LONG:Le.INTEGER}constructor(e,t,n,s,i,o,a,r,c,h){this.onFileCompleted=e,this.file=t,this.readHeaders=n,this.nullString=i,this.onProgress=o,this.onError=a,this.chunks=0,this.totalChunks=r,this.isZip=c,this.shouldTrim=h,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={...s,error:this.handleError,chunk:this.handleChunk,complete:this.handleComplete}}onFileCompleted;file;readHeaders;nullString;onProgress;onError;types;chunks;totalChunks;isZip;shouldTrim;zipProgress;config;parse(){const e=this.isZip?this.file.nodeStream("nodebuffer",this.handleNodeUpdate):this.file;ol.parse(e,this.config)}handleChunk(e,t){let{data:n}=e;if(!this.types){if(n==null||n.length===0){t.abort(),this.onError("Error parsing CSV: no data in file.");return}this.types=new Array(n[0].length).fill(cd),this.readHeaders&&(n=n.slice(1))}M(this.types);const s=[...this.types];n.forEach(a=>{if(a.length>=s.length){for(let r=0;r<s.length;r+=1)s[r]=yt.determineType(this.shouldTrim?a[r].trim():a[r],s[r],this.nullString);this.types=s}else t.abort(),this.onError(`Error parsing CSV: Insufficient data in row.
4
- Expected length ${s.length} but found ${a.length}.
5
- Row = ${a}`)}),this.chunks+=1;let i=0;this.totalChunks>0?i=Math.round(this.chunks/this.totalChunks*50):i=Math.round(this.zipProgress/2),this.onProgress(i)&&t.abort()}handleComplete(e){const{types:t,onFileCompleted:n}=this;M(t),(e==null||!e.meta.aborted)&&n(t.map(s=>s===cd?Le.STRING:s))}handleError(e){const{onError:t}=this;t(e)}handleNodeUpdate(e){this.zipProgress=e.percent}}const zC=yt,ia=Z.module("CsvParser"),KC=650;class vo{static generateHeaders=e=>{const t=[];for(let n=0;n<e;n+=1)t.push(vo.generateHeaderRecursive(n));return t};static generateHeaderRecursive(e){let t="",n=e;return e>=26&&(t=t.concat(vo.generateHeaderRecursive(Math.floor(e/26)-1)),n=e%26),t.concat(String.fromCharCode(65+n))}constructor({onFileCompleted:e,session:t,file:n,type:s,readHeaders:i=!0,onProgress:o,onError:a,timeZone:r,isZip:c}){this.onFileCompleted=e,this.session=t,this.file=n,this.isZip=c,this.type=s,this.readHeaders=i,this.timeZone=r,this.onProgress=o,this.onError=a,this.tables=[],this.chunks=0,this.totalChunks=c?0:Math.ceil(n.size/ol.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}}onFileCompleted;session;file;isZip;type;readHeaders;timeZone;onProgress;onError;tables;headers;types;chunks;totalChunks;isComplete;zipProgress;consolidatedChunks;numConsolidated;isCancelled;config;cancel(){this.isCancelled=!0}transpose(e,t){const n=t.length,s=new Array(e).fill(null).map(()=>new Array(n));for(let i=0;i<n;i+=1){const o=t[i];if(o.length<e)throw new Error(`Insufficient columns. Expected ${e} but found ${o.length}
6
- ${o}`);for(let a=0;a<e;a+=1){const r=this.type.shouldTrim?t[i][a].trim():t[i][a];s[a][i]=this.nullCheck(r)}}return s}nullCheck(e){return e===this.type.nullString?"":e}parse(){const e=n=>{const s=this.isZip?this.file.nodeStream("nodebuffer",this.handleNodeUpdate):this.file;this.types=n,ol.parse(s,this.config)};new zC(e,this.file,this.readHeaders,this.config,this.type.nullString,this.onProgress,this.onError,this.totalChunks,this.isZip,this.type.shouldTrim).parse()}handleChunk(e,t){const{readHeaders:n,onError:s,handleCreateTable:i,isZip:o,tables:a}=this;if(this.isCancelled){ia.debug2("CSV parser cancelled."),t.abort(),a.forEach(h=>h.close());return}let{data:r}=e;this.headers||(n?(this.headers=un.legalizeColumnNames(r[0]),r=r.slice(1)):this.headers=vo.generateHeaders(r[0].length));let c=[];try{if(c=this.transpose(this.headers.length,r),o)this.consolidateChunks(c,t);else{const h=this.chunks;this.chunks+=1,i(h,c,t)}}catch(h){s(h)}}consolidateChunks(e,t){if(!this.consolidatedChunks)this.consolidatedChunks=e.slice();else for(let n=0;n<e.length;n+=1)this.consolidatedChunks[n]=this.consolidatedChunks[n].concat(e[n]);this.numConsolidated+=1,(this.numConsolidated>=KC||this.isComplete)&&this.uploadConsolidatedChunks(t)}uploadConsolidatedChunks(e){const{handleCreateTable:t}=this,n=this.chunks;this.chunks+=1;const s=this.consolidatedChunks?.slice();this.consolidatedChunks=void 0,this.numConsolidated=0,M(s),t(n,s,e)}handleCreateTable(e,t,n){const{session:s,tables:i,onFileCompleted:o,totalChunks:a,types:r,onProgress:c,onError:h}=this;n&&n.pause(),M(this.headers),M(r),s.newTable(this.headers,r,t,this.timeZone).then(u=>{if(this.isCancelled){ia.debug2("CSV parser cancelled."),n&&n.abort(),i.forEach(g=>g.close());return}n&&n.resume(),i[e]=u;let m=0;a>0?m=Math.round(i.length/a*50)+50:m=Math.round(50+this.zipProgress/2),ia.debug2(`CSV parser progress ${m}`),c(m),this.isComplete&&i.length===this.chunks&&(ia.debug2("CSV parser complete."),o(i))}).catch(u=>{!this.isComplete&&n&&n.abort(),h(u)})}handleComplete(e){(e==null||e.meta.aborted==null)&&(this.isComplete=!0,this.consolidatedChunks&&this.uploadConsolidatedChunks(null))}handleError(e){const{onError:t}=this;t(e)}handleNodeUpdate(e){this.zipProgress=e.percent}}const qC=vo;class YC{static DEFAULT_TYPE="DEFAULT_CSV";static AUTO="AUTODETECT";static fromExtension(e){return e.endsWith(".csv")?"DEFAULT_CSV":e.endsWith(".tsv")||e.endsWith(".tab")?"TSV":e.endsWith(".psv")?"PIPE_SV":"AUTODETECT"}static TYPES=Object.freeze({DEFAULT_CSV:{name:"Default csv (trimmed)",delimiter:",",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},TSV:{name:"Tab seperated (tsv)",delimiter:" ",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},APACHE_COMMON_CSV:{name:"Apache Common csv",delimiter:",",newline:`\r
7
- `,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:null},EXCEL_CSV:{name:"Excel csv (strict)",delimiter:",",newline:`\r
8
- `,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!1,nullString:null},MY_SQL_CSV:{name:"MySQL csv",delimiter:" ",newline:`
9
- `,escapeChar:"\\",shouldTrim:!0,skipEmptyLines:!1,nullString:"\\N"},RFC4180_CSV:{name:"RFC4180 csv",delimiter:",",newline:`\r
10
- `,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!1,nullString:null},COLON_SV:{name:": colon sv",delimiter:":",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},SEMI_COLON_SV:{name:"; semi-colon sv",delimiter:";",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},PIPE_SV:{name:"| pipe separated (psv)",delimiter:"|",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},SPACE_SV:{name:'" " space sv',delimiter:" ",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},AUTODETECT:{name:"autodetect",delimiter:void 0,newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"}})}const So=YC;const ud=Z.module("CsvInputBar"),XC=Object.entries(So.TYPES).map(([d,e])=>l.jsx("option",{value:d,children:e.name},d));class ZC extends b.Component{static defaultProps={file:null,paste:null,unzip:null};constructor(e){super(e),this.handleUpload=this.handleUpload.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleError=this.handleError.bind(this),this.handleTableName=this.handleTableName.bind(this),this.toggleFirstRowHeaders=this.toggleFirstRowHeaders.bind(this),this.handleProgress=this.handleProgress.bind(this),this.handleCancelInProgress=this.handleCancelInProgress.bind(this),this.handleQueryTypeChange=this.handleQueryTypeChange.bind(this),this.inputRef=J.createRef(),this.state={tableName:"",tableNameSet:!1,isFirstRowHeaders:!0,showProgress:!1,progressValue:0,type:So.DEFAULT_TYPE,parser:null}}componentDidUpdate(e){const{file:t,paste:n}=this.props,{tableName:s,tableNameSet:i}=this.state;if(!i&&t!=null&&!s){const o=t.name.lastIndexOf("."),a=un.legalizeTableName(t.name.substring(0,o));this.setState({tableName:a,tableNameSet:!0}),this.inputRef.current?.focus()}else(t==null&&e.file!=null||n==null&&e.paste!=null)&&this.setState({tableName:"",tableNameSet:!1});n!=null&&n!==""&&!s&&this.inputRef.current&&this.inputRef.current.focus(),t!=null&&t!==e.file?this.setState({type:So.fromExtension(t.name)}):n!=null&&n!==""&&(e.paste===void 0||e.paste==="")&&this.setState({type:So.AUTO})}componentWillUnmount(){const{parser:e}=this.state;e&&e.cancel()}inputRef;handleCancel(){const{onClose:e}=this.props;e()}handleError(e){const{onClose:t,onError:n}=this.props;ud.error(e),n(e),t()}handleTableName(e){this.setState({tableName:e.target.value,tableNameSet:!0})}toggleFirstRowHeaders(){const{isFirstRowHeaders:e}=this.state;this.setState({isFirstRowHeaders:!e})}handleUpload(e){e.stopPropagation(),e.preventDefault();const{file:t,paste:n}=this.props;t!=null?t.name.endsWith(".zip")?this.handleZipFile(t):this.handleFile(t):n!==void 0&&n!==""&&this.handleFile(new Blob([n],{type:"text/plain"}))}handleFile(e,t=!1){ud.info(`Starting CSV parser for ${e instanceof File?e.name:"pasted values"} ${t?"":e.size} bytes`);const{session:n,timeZone:s,onInProgress:i}=this.props,{tableName:o,isFirstRowHeaders:a,type:r}=this.state,c=u=>{u.length===1?n.bindTableToVariable(u[0],o).then(()=>this.openTable()).catch(m=>this.handleError(m)):n.mergeTables(u).then(m=>{n.bindTableToVariable(m,o).then(()=>this.openTable()).catch(g=>this.handleError(g)),u.forEach(g=>g.close())}).catch(m=>this.handleError(m))},h=new qC({onFileCompleted:c,session:n,file:e,type:So.TYPES[r],readHeaders:a,onProgress:this.handleProgress,onError:this.handleError,timeZone:s,isZip:t});h.parse(),this.setState({showProgress:!0,parser:h}),i(!0)}handleZipFile(e){const{onUpdate:t,unzip:n}=this.props;if(n==null){this.handleError(new Error("No support for zip files available."));return}n(e).then(s=>{let i=!1;for(let o=0;o<s.length;o+=1){const a=s[o];if(Ri.isValidExtension(a.name)){t(`Loading ${a.name} as csv from ${e.name}`),i=!0,this.handleFile(a,!0);break}}if(!i)throw new Error(`No csv file found in ${e.name}`)}).catch(s=>this.handleError(s))}handleProgress(e){const{showProgress:t}=this.state;return t&&this.setState({progressValue:e}),!t}handleCancelInProgress(){const{onInProgress:e}=this.props,{parser:t}=this.state;t&&t.cancel(),this.setState({showProgress:!1,progressValue:0}),e(!1)}openTable(){const{onOpenTable:e,onClose:t}=this.props,{tableName:n}=this.state;e(n),t()}handleQueryTypeChange(e){this.setState({type:e.target.value})}render(){const{file:e,paste:t}=this.props,{tableName:n,isFirstRowHeaders:s,showProgress:i,progressValue:o,type:a}=this.state,r=Boolean(t)&&!n;return l.jsxs("div",{className:"csv-input-bar",children:[!i&&l.jsxs("form",{onSubmit:this.handleUpload,className:"csv-input-bar-container form-inline",children:[l.jsxs("div",{className:"form-group",children:[l.jsx("label",{htmlFor:"tableNameInput",children:"Table name"}),l.jsx("input",{ref:this.inputRef,id:"tableNameInput",type:"text",className:$("form-control",{"is-invalid":r}),value:n,onChange:this.handleTableName})]}),l.jsxs("div",{className:"form-group",children:[l.jsx("label",{htmlFor:"formatSelect",children:"File format"}),l.jsx("select",{id:"formatSelect",className:"custom-select",value:a,onChange:this.handleQueryTypeChange,children:XC})]}),l.jsx(Zt,{className:"firstRowHeaders",checked:s,onChange:this.toggleFirstRowHeaders,children:"First row is column headers"}),l.jsxs("div",{className:"csv-input-buttons form-group",children:[l.jsx(B,{kind:"secondary",onClick:this.handleCancel,children:"Cancel"}),l.jsx(B,{kind:"primary",type:"submit",disabled:!(e!==null||t!==void 0&&t!=="")||!n,children:"Upload"})]})]}),i&&l.jsxs("div",{className:"csv-progress-container",children:[l.jsx("label",{children:"Uploading Table"}),l.jsx("div",{className:"progress",children:l.jsx("div",{className:"progress-bar bg-primary",style:{width:`${o}%`},"aria-valuenow":o,"aria-valuemin":0,"aria-valuemax":100})}),l.jsxs("label",{children:[o,"%"]}),l.jsx(B,{kind:"primary",onClick:this.handleCancelInProgress,children:"Cancel"})]})]})}}const QC=ZC;const md=Z.module("ConsoleMenu");class Pa extends b.PureComponent{static makeItemActions(e,t,n,s,i){if(e.length===0)return[];const o={menuElement:l.jsx(_s,{value:t,onChange:s,className:"console-menu",ref:n})};let a=e;t&&(a=a.filter(({title:c})=>c!=null&&c.toLowerCase().indexOf(t.toLowerCase())>=0));const r=a.map(c=>({title:c.title,action:()=>{i(c)}}));return[o,...r]}constructor(e){super(e),this.handleTableFilterChange=this.handleTableFilterChange.bind(this),this.handleTableMenuClosed=this.handleTableMenuClosed.bind(this),this.handleTableMenuOpened=this.handleTableMenuOpened.bind(this),this.handleWidgetFilterChange=this.handleWidgetFilterChange.bind(this),this.handleWidgetMenuClosed=this.handleWidgetMenuClosed.bind(this),this.handleWidgetMenuOpened=this.handleWidgetMenuOpened.bind(this),this.state={tableFilterText:"",widgetFilterText:""}}tableSearchField;widgetSearchField;makeTableActions=fe((e,t,n)=>{const s=e.filter(i=>ul.isTableType(i.type));return Pa.makeItemActions(s,t,i=>{this.tableSearchField=i},this.handleTableFilterChange,n)});makeWidgetActions=fe((e,t,n)=>{const s=e.filter(i=>ul.isWidgetType(i.type));return Pa.makeItemActions(s,t,i=>{this.widgetSearchField=i},this.handleWidgetFilterChange,n)});handleTableFilterChange(e){md.debug("filtering tables..."),this.setState({tableFilterText:e.target.value})}handleTableMenuClosed(){this.setState({tableFilterText:""})}handleTableMenuOpened(){this.tableSearchField?.focus()}handleWidgetFilterChange(e){md.debug("filtering widgets..."),this.setState({widgetFilterText:e.target.value})}handleWidgetMenuClosed(){this.setState({widgetFilterText:""})}handleWidgetMenuOpened(){this.widgetSearchField?.focus()}render(){const{overflowActions:e,objects:t,openObject:n}=this.props,{tableFilterText:s,widgetFilterText:i}=this.state,o=this.makeTableActions(t,s,n),a=this.makeWidgetActions(t,i,n),r={placement:"bottom-end"},c=o.length===0,h=a.length===0;return l.jsxs("div",{className:"console-pane-menu",children:[l.jsxs(B,{kind:"ghost",className:"btn-link-icon",disabled:c,onClick:()=>{},tooltip:c?"No tables available":"Tables",children:[l.jsxs("div",{className:"fa-md fa-layers",children:[l.jsx(Q,{mask:Nl,icon:Pn,transform:"right-5 down-5"}),l.jsx(Q,{icon:Pn,transform:"right-8 down-6"})]}),l.jsx(es,{actions:o,onMenuOpened:this.handleTableMenuOpened,onMenuClosed:this.handleTableMenuClosed,options:{initialKeyboardIndex:1},popperOptions:r},"table-actions ")]}),l.jsxs(B,{kind:"ghost",className:"btn-link-icon",disabled:a.length===0,onClick:()=>{},tooltip:h?"No widgets available":"Widgets",children:[l.jsxs("div",{className:"fa-md fa-layers",children:[l.jsx(Q,{mask:Fh,icon:Pn,transform:"right-5 down-5"}),l.jsx(Q,{icon:Pn,transform:"right-8 down-6"})]}),l.jsx(es,{actions:a,onMenuOpened:this.handleWidgetMenuOpened,onMenuClosed:this.handleWidgetMenuClosed,options:{initialKeyboardIndex:1},popperOptions:r},"table-actions")]}),l.jsx(B,{kind:"ghost",className:"btn-overflow btn-link-icon",icon:Mh,tooltip:"More Actions...",onClick:()=>{},children:l.jsx(es,{actions:e,popperOptions:r})})]})}}const JC=Pa;class eS extends b.PureComponent{static defaultProps={children:null};constructor(e){super(e),this.handleCommandStarted=this.handleCommandStarted.bind(this),this.handleCommandCompleted=this.handleCommandCompleted.bind(this),this.pending=new is,this.state={isDisconnected:!1,isCommandRunning:!1}}componentDidMount(){this.startListening()}componentWillUnmount(){this.stopListening(),this.cancelPendingPromises()}pending;startListening(){const{session:e}=this.props;e.addEventListener(R.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted)}stopListening(){const{session:e}=this.props;e.removeEventListener(R.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted)}cancelPendingPromises(){this.pending.cancel()}handleCommandStarted(e){const{result:t}=e.detail;this.pending.add(t).then(()=>this.handleCommandCompleted(null)).catch(n=>this.handleCommandCompleted(n)),this.setState({isCommandRunning:!0})}handleCommandCompleted(e){e instanceof $i||this.setState({isCommandRunning:this.pending.pending.length>0})}render(){const{children:e,openObject:t,overflowActions:n,objects:s}=this.props,{isDisconnected:i,isCommandRunning:o}=this.state;let a=null,r=null;return i?(a="console-status-icon-disconnected",r="Worker is disconnected"):o?(a="console-status-icon-pending",r="Worker is busy"):(a="console-status-icon-idle",r="Worker is idle"),l.jsxs("div",{className:"console-pane-status-bar",children:[l.jsxs("div",{children:[l.jsx("div",{className:$("console-status-icon",a)}),l.jsx(tt,{children:r})]}),e,l.jsx(JC,{overflowActions:n,openObject:t,objects:s})]})}}const tS=eS,Wn=Z.module("Console"),gd={isAutoLaunchPanelsEnabled:!0,isPrintStdOutEnabled:!0,isClosePanelsOnDisconnectEnabled:!0};class Ii extends b.PureComponent{static defaultProps={statusBarChildren:null,settings:{},onSettingsChange:()=>{},scope:null,actions:[],historyChildren:null,timeZone:"America/New_York",objectMap:new Map,disabled:!1,unzip:null};static LOG_THROTTLE=500;static isErrorLevel(e){return e===gt.STDERR||e===gt.ERROR||e===gt.FATAL}static isOutputLevel(e){return e===gt.STDOUT||Ii.isErrorLevel(e)}constructor(e){super(e),this.handleCommandResult=this.handleCommandResult.bind(this),this.handleCommandStarted=this.handleCommandStarted.bind(this),this.handleCommandSubmit=this.handleCommandSubmit.bind(this),this.handleClearShortcut=this.handleClearShortcut.bind(this),this.handleFocusHistory=this.handleFocusHistory.bind(this),this.handleLogMessage=this.handleLogMessage.bind(this),this.handleOverflowActions=this.handleOverflowActions.bind(this),this.handleScrollPaneScroll=this.handleScrollPaneScroll.bind(this),this.handleToggleAutoLaunchPanels=this.handleToggleAutoLaunchPanels.bind(this),this.handleToggleClosePanelsOnDisconnect=this.handleToggleClosePanelsOnDisconnect.bind(this),this.handleTogglePrintStdout=this.handleTogglePrintStdout.bind(this),this.handleUploadCsv=this.handleUploadCsv.bind(this),this.handleHideCsv=this.handleHideCsv.bind(this),this.handleCsvFileCanceled=this.handleCsvFileCanceled.bind(this),this.handleCsvFileOpened=this.handleCsvFileOpened.bind(this),this.handleCsvPaste=this.handleCsvPaste.bind(this),this.handleDragEnter=this.handleDragEnter.bind(this),this.handleDragLeave=this.handleDragLeave.bind(this),this.handleClearDragError=this.handleClearDragError.bind(this),this.handleOpenCsvTable=this.handleOpenCsvTable.bind(this),this.handleCsvUpdate=this.handleCsvUpdate.bind(this),this.handleCsvError=this.handleCsvError.bind(this),this.handleCsvInProgress=this.handleCsvInProgress.bind(this),this.consolePane=J.createRef(),this.consoleInput=J.createRef(),this.consoleHistoryScrollPane=J.createRef(),this.pending=new is,this.queuedLogMessages=[];const{objectMap:t,settings:n}=this.props;this.state={consoleHistory:[],consoleHeight:0,isScrollDecorationShown:!1,objectHistoryMap:new Map,objectMap:new Map(t),showCsvOverlay:!1,csvFile:null,csvPaste:null,dragError:null,csvUploadInProgress:!1,...gd,...n}}componentDidMount(){this.initConsoleLogging();const{session:e}=this.props;e.addEventListener(R.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted),this.updateDimensions()}componentDidUpdate(e,t){const{props:n,state:s}=this;this.sendSettingsChange(t,s),n.objectMap!==e.objectMap&&this.updateObjectMap()}componentWillUnmount(){const{session:e}=this.props;e.removeEventListener(R.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted),this.pending.cancel(),this.processLogMessageQueue.cancel(),this.deinitConsoleLogging()}cancelListener;consolePane;consoleInput;consoleHistoryScrollPane;pending;queuedLogMessages;initConsoleLogging(){const{session:e}=this.props;this.cancelListener=e.onLogMessage(this.handleLogMessage)}deinitConsoleLogging(){this.cancelListener!=null&&(this.cancelListener(),this.cancelListener=void 0)}handleClearShortcut(e){e.preventDefault(),e.stopPropagation(),this.consoleInput.current?.clear()}handleCommandStarted(e){const{code:t,result:n}=e.detail,s=this.pending.add(n),i={command:t,disabledObjects:[],startTime:Date.now(),cancelResult:()=>{n.cancel()},wrappedResult:s},{commandHistoryStorage:o,language:a,scope:r}=this.props,c=o.addItem(a,r,t,{command:t,startTime:new Date().toJSON()});c.catch(h=>{Wn.debug("Error adding workspace item",h)}),this.setState(h=>({consoleHistory:h.consoleHistory.concat(i)}),()=>{this.scrollConsoleHistoryToBottom(!0)}),s.then(h=>{this.handleCommandResult(h,i,c)}).catch(h=>{this.handleCommandError(h,i,c)})}handleCommandResult(e,t,n){const s={...t,wrappedResult:void 0,cancelResult:void 0,result:e??t.result};this.setState(({consoleHistory:i})=>{const o=i.lastIndexOf(t);if(o<0)return Wn.error("historyItem not found in consoleHistory"),null;const a=i.concat();return a[o]=s,{consoleHistory:a}}),e&&(this.updateHistory(e,s),this.updateKnownObjects(s),this.updateWorkspaceHistoryItem({error:e.error},n),this.closeRemovedItems(e.changes),this.openUpdatedItems(e.changes))}handleCommandError(e,t,n){if(ve.isCanceled(e)){Wn.debug("Called handleCommandError on a cancelled promise result");return}this.updateWorkspaceHistoryItem({error:`${e}`},n),this.setState(s=>{const i=s.consoleHistory.concat(),o=i.lastIndexOf(t),a={...t};return a.wrappedResult=void 0,a.cancelResult=void 0,a.endTime=Date.now(),a.result={error:e},i[o]=a,{consoleHistory:i}})}handleFocusHistory(e){e.preventDefault(),e.stopPropagation();const{focusCommandHistory:t}=this.props;t()}handleLogMessage(e){const{isPrintStdOutEnabled:t}=this.state;t&&Ii.isOutputLevel(e.logLevel)&&this.queueLogMessage(e.message,e.logLevel)}queueLogMessage(e,t){const n={};Ii.isErrorLevel(t)?n.error=e:n.message=e;const s={command:void 0,result:n};this.queuedLogMessages.push(s),this.processLogMessageQueue()}processLogMessageQueue=Ls(()=>{this.scrollConsoleHistoryToBottom(),this.setState(e=>{Wn.debug2("processLogMessageQueue",this.queuedLogMessages.length," items");let{consoleHistory:t}=e;return t=t.concat(this.queuedLogMessages),this.queuedLogMessages=[],{consoleHistory:t}})},Ii.LOG_THROTTLE);openUpdatedItems(e){const{isAutoLaunchPanelsEnabled:t}=this.state;if(e==null||!t)return;const{openObject:n}=this.props;[...e.created,...e.updated].forEach(s=>n(s))}closeRemovedItems(e){if(e==null||e.removed==null||e.removed.length===0)return;const{closeObject:t}=this.props,{removed:n}=e;n.forEach(s=>t(s))}updateHistory(e,t){const n=t;e==null||e.changes==null||n==null||(n.endTime=Date.now(),this.scrollConsoleHistoryToBottom(),this.setState(s=>({consoleHistory:s.consoleHistory.concat()})))}updateKnownObjects(e){let t;if(e.result&&(t=e.result.changes),!t||(t.created==null||t.created.length===0)&&(t.updated==null||t.updated.length===0)&&(t.removed==null||t.removed.length===0)){Wn.debug2("updateKnownObjects no changes");return}this.setState(n=>{let{consoleHistory:s}=n;const i=s.lastIndexOf(e);if(i<0)return Wn.error("historyItem not found in state.consoleHistory"),null;const o=new Map(n.objectHistoryMap),a=new Map(n.objectMap),r=(c,h=!1)=>{const{title:u}=c;M(u);const m=o.get(u);if(m!=null&&m>=0){s===n.consoleHistory&&(s=s.concat());const g={...s[m],disabledObjects:[...s[m].disabledObjects??[],u]};s[m]=g}o.set(u,i),h?a.delete(u):a.set(u,c)};return t?.updated.forEach(c=>r(c)),t?.removed.forEach(c=>r(c,!0)),t?.created.forEach(c=>{const{title:h}=c;M(h),o.set(h,i),a.set(h,c)}),{objectHistoryMap:o,objectMap:a,consoleHistory:s}})}updateObjectMap(){const{objectMap:e}=this.props;this.setState({objectMap:e})}updateWorkspaceHistoryItem(e,t){const n=this.pending.add(t),s=new Date().toJSON();n.then(i=>{const o={...i,data:{...i.data,endTime:s,result:e}},{commandHistoryStorage:a,language:r}=this.props;a.updateItem(r,o).catch(c=>{Wn.warn("Error updating command history storage",c)})}).catch(i=>{Wn.debug("Error updating workspace history item",i)})}scrollConsoleHistoryToBottom(e=!1){const t=this.consoleHistoryScrollPane.current;M(t),!(!e&&t.scrollTop<t.scrollHeight-t.offsetHeight)&&window.requestAnimationFrame(()=>{t.scrollTop=t.scrollHeight})}handleScrollPaneScroll(){const e=this.consoleHistoryScrollPane.current;M(e),e.scrollTop>0&&e.scrollHeight>e.clientHeight?this.setState({isScrollDecorationShown:!0}):this.setState({isScrollDecorationShown:!1})}handleToggleAutoLaunchPanels(){this.setState(e=>({isAutoLaunchPanelsEnabled:!e.isAutoLaunchPanelsEnabled}))}handleToggleClosePanelsOnDisconnect(){this.setState(e=>({isClosePanelsOnDisconnectEnabled:!e.isClosePanelsOnDisconnectEnabled}))}handleTogglePrintStdout(){this.setState(e=>({isPrintStdOutEnabled:!e.isPrintStdOutEnabled}))}handleUploadCsv(){this.setState({showCsvOverlay:!0,dragError:null,csvUploadInProgress:!1})}handleHideCsv(){this.setState({showCsvOverlay:!1,csvFile:null,csvPaste:null,dragError:null,csvUploadInProgress:!1})}handleCsvFileCanceled(){this.setState({csvFile:null,csvPaste:null})}handleCsvFileOpened(e){this.setState({csvFile:e,csvPaste:null})}handleCsvPaste(e){this.setState({csvFile:null,csvPaste:e})}handleDragEnter(e){if(e.dataTransfer==null||e.dataTransfer.items==null||e.dataTransfer.items.length===0||e.dataTransfer.items[0].kind==="string")return;e.preventDefault(),e.stopPropagation(),this.setState({showCsvOverlay:!0});const{items:t}=e.dataTransfer;if(t.length>1){this.setState({dragError:Ri.MULTIPLE_FILE_ERROR});return}const n=t[0];Ri.isValidDropItem(n)?this.setState({dragError:null}):this.setState({dragError:Ri.FILE_TYPE_ERROR})}handleDragLeave(e){e.currentTarget==null||e.currentTarget instanceof Element&&e.relatedTarget instanceof Element&&e.currentTarget.contains(e.relatedTarget)||(e.preventDefault(),e.stopPropagation(),this.setState({showCsvOverlay:!1,dragError:null}))}handleClearDragError(){this.setState({dragError:null})}handleOpenCsvTable(e){const{openObject:t,commandHistoryStorage:n,language:s,scope:i}=this.props,{consoleHistory:o,objectMap:a}=this.state,r={name:e,title:e,type:R.VariableType.TABLE},c=a.has(e),h={startTime:Date.now(),endTime:Date.now(),disabledObjects:[],result:{changes:{created:[],updated:[],removed:[],[c?"updated":"created"]:[r]}}},u=o.concat(h);this.setState({consoleHistory:u}),this.scrollConsoleHistoryToBottom(!0),this.updateKnownObjects(h),t({name:e,title:e,type:R.VariableType.TABLE}),n.addItem(s,i,e,{command:e,startTime:new Date().toJSON(),endTime:new Date().toJSON()})}addConsoleHistoryMessage(e,t){const{consoleHistory:n}=this.state,s={command:"",startTime:Date.now(),endTime:Date.now(),result:{message:e,error:t}},i=n.concat(s);this.setState({consoleHistory:i})}handleCsvUpdate(e){this.addConsoleHistoryMessage(e)}handleCsvError(e){this.addConsoleHistoryMessage(void 0,e!=null?`${e}`:void 0)}handleCsvInProgress(e){this.setState({csvUploadInProgress:e})}handleOverflowActions(){const{isAutoLaunchPanelsEnabled:e,isClosePanelsOnDisconnectEnabled:t,isPrintStdOutEnabled:n}=this.state,{actions:s}=this.props;return[...s,{title:"Print Stdout",action:this.handleTogglePrintStdout,group:ie.groups.high,icon:n?Jn:void 0,order:10},{title:"Auto Launch Panels",action:this.handleToggleAutoLaunchPanels,group:ie.groups.high,icon:e?Jn:void 0,order:20},{title:"Close Panels on Disconnect",action:this.handleToggleClosePanelsOnDisconnect,group:ie.groups.high,icon:t?Jn:void 0,order:30},{title:"Upload Table from File",action:this.handleUploadCsv,group:ie.groups.high+10,order:40}]}handleCommandSubmit(e){if(e==="clear"||e==="cls")this.clearConsoleHistory();else if(e.length>0){const{session:t}=this.props;t.runCode(e).catch(n=>{Wn.error("There was an error initiating the command",n)})}else{const t={command:" ",result:{},startTime:Date.now(),endTime:Date.now()};this.scrollConsoleHistoryToBottom(!0),this.setState(n=>({consoleHistory:n.consoleHistory.concat(t)}))}}clearConsoleHistory(){this.pending.cancel(),this.setState(e=>{const t=new Map([...e.objectHistoryMap.keys()].map(n=>[n,-1]));return{consoleHistory:[],objectHistoryMap:t}})}getObjects=fe(e=>[...e.values()]);getContextActions=fe(e=>[...e,{action:this.handleClearShortcut,shortcut:Mt.CONSOLE.CLEAR},{action:this.handleFocusHistory,shortcut:Mt.CONSOLE.FOCUS_HISTORY}]);addCommand(e,t=!0,n=!1){this.consoleInput.current&&(this.consoleInput.current.setConsoleText(e,t,n),t&&this.scrollConsoleHistoryToBottom(!0))}focus(){this.consoleInput.current?.focus()}sendSettingsChange(e,t,n=!0){const s=Object.keys(gd),i={};let o=!1;for(let r=0;r<s.length;r+=1){const c=s[r],{[c]:h}=t,{[c]:u}=e;h!==u&&(o=!0),i[c]=h}if(n&&!o)return;const{onSettingsChange:a}=this.props;a(i)}updateDimensions(){this.consolePane.current&&this.setState({consoleHeight:this.consolePane.current.clientHeight}),this.consoleInput.current&&this.consoleInput.current.updateDimensions()}render(){const{actions:e,historyChildren:t,language:n,statusBarChildren:s,openObject:i,session:o,scope:a,commandHistoryStorage:r,timeZone:c,disabled:h,unzip:u}=this.props,{consoleHeight:m,consoleHistory:g,isScrollDecorationShown:p,objectMap:C,showCsvOverlay:f,csvFile:S,csvPaste:v,dragError:w,csvUploadInProgress:T}=this.state,y=this.getObjects(C),E=Math.round(m*.7),D=this.getContextActions(e);return l.jsxs("div",{role:"presentation",className:$("iris-console","h-100","w-100",{disabled:h}),children:[l.jsxs("div",{className:"console-pane",ref:this.consolePane,children:[l.jsx(tS,{session:o,overflowActions:this.handleOverflowActions,openObject:i,objects:y,children:s}),l.jsxs("div",{className:"console-csv-container",onDragOver:Ri.handleDragOver,onDragEnter:this.handleDragEnter,onDragLeave:this.handleDragLeave,children:[f&&l.jsx(Ri,{onCancel:this.handleCsvFileCanceled,onFileOpened:this.handleCsvFileOpened,onPaste:this.handleCsvPaste,clearDragError:this.handleClearDragError,dragError:w,onError:this.handleCsvError,uploadInProgress:T,allowZip:u!=null}),l.jsxs("div",{role:"presentation",className:$("scroll-pane no-scroll-x",{"scroll-decoration":p}),onScroll:this.handleScrollPaneScroll,ref:this.consoleHistoryScrollPane,children:[l.jsx(eC,{items:g,openObject:i,language:n,disabled:h}),t]})]}),!f&&l.jsx(ad,{ref:this.consoleInput,session:o,language:n,scope:a,onSubmit:this.handleCommandSubmit,maxHeight:E,commandHistoryStorage:r}),f&&l.jsx(QC,{session:o,onOpenTable:this.handleOpenCsvTable,onClose:this.handleHideCsv,onUpdate:this.handleCsvUpdate,onError:this.handleCsvError,file:S??void 0,paste:v??void 0,onInProgress:this.handleCsvInProgress,timeZone:c,unzip:u})]}),l.jsx(ie,{actions:D,ignoreClassNames:[ad.INPUT_CLASS_NAME]})]})}}const nS=Ii;class sS extends b.Component{static defaultProps={className:"fill-parent-absolute",onEditorInitialized:()=>{},onEditorWillDestroy:()=>{},settings:{}};constructor(e){super(e),this.handleResize=this.handleResize.bind(this),this.container=null,this.state={}}componentDidMount(){this.initEditor(),window.addEventListener("resize",this.handleResize)}componentWillUnmount(){window.removeEventListener("resize",this.handleResize),this.destroyEditor()}container;editor;setLanguage(e){if(this.editor){const t=this.editor.getModel();M(t),Qn.setModelLanguage(t,e)}}handleResize(){this.updateDimensions()}toggleFind(){this.editor&&(this.editor.focus(),this.editor.trigger("toggleFind","actions.find",void 0))}updateDimensions(){this.editor?.layout()}initEditor(){const{onEditorInitialized:e}=this.props;let{settings:t}=this.props;t={copyWithSyntaxHighlighting:!1,fixedOverflowWidgets:!0,folding:!1,fontFamily:"Fira Mono",glyphMargin:!1,language:"python",lineNumbersMinChars:3,minimap:{enabled:!1},scrollBeyondLastLine:!1,tabCompletion:"on",value:"",wordWrap:"off",links:!0,...t},M(this.container),this.editor=Qn.create(this.container,t),this.editor.addAction({id:"find",label:"Find",keybindings:[dn.CtrlCmd|Ds.KeyF],precondition:void 0,keybindingContext:void 0,contextMenuGroupId:"navigation",contextMenuOrder:1,run:()=>{this.toggleFind()}}),this.editor.layout(),Ht.removeConflictingKeybindings(this.editor),An.registerLinkProvider("plaintext",{provideLinks:Ht.provideLinks}),e(this.editor)}destroyEditor(){const{onEditorWillDestroy:e}=this.props;M(this.editor),e(this.editor),this.editor.dispose(),this.editor=void 0}render(){const{className:e}=this.props;return l.jsx("div",{className:$("editor-container",e),ref:t=>{this.container=t}})}}const Kl=sS;const on=Z.module("ScriptEditor");class iS extends b.Component{static defaultProps={error:null,isLoading:!1,isLoaded:!1,focusOnMount:!0,onChange:()=>{},onEditorInitialized:()=>{},onEditorWillDestroy:()=>{},session:null};constructor(e){super(e),this.handleEditorInitialized=this.handleEditorInitialized.bind(this),this.handleEditorWillDestroy=this.handleEditorWillDestroy.bind(this),this.handleRun=this.handleRun.bind(this),this.handleRunSelected=this.handleRunSelected.bind(this),this.updateShortcuts=this.updateShortcuts.bind(this),this.contextActionCleanups=[],this.editorComponent=J.createRef(),this.state={model:null}}componentDidMount(){Ne.addEventListener("onUpdate",this.updateShortcuts)}componentDidUpdate(e){const{sessionLanguage:t,settings:n}=this.props,s=n?.language;s!==e.settings?.language&&(on.debug("Set language",s),this.setLanguage(s));const o=t==null&&e.sessionLanguage!=null,a=s===t,r=e.settings?.language===e.sessionLanguage;(o||t!==void 0&&r&&!a)&&(on.debug("De-init completion and context actions"),this.deInitContextActions(),this.deInitCodeCompletion()),(t!=null&&e.sessionLanguage==null&&a||t!==void 0&&!r&&a)&&(on.debug("Init completion and context actions"),this.initContextActions(),this.initCodeCompletion())}componentWillUnmount(){Ne.removeEventListener("onUpdate",this.updateShortcuts)}contextActionCleanups;completionCleanup;editor;editorComponent;getValue(){return this.editor?this.editor.getValue():(on.error("Editor not initialized"),null)}getSelectedCommand(){const e=this.editor?.getSelection();M(e);const t=this.editor?.getModel();M(t);const{startLineNumber:n,endColumn:s}=e;let{endLineNumber:i}=e;s===1&&i>n&&(i-=1);const o=t?.getLineMinColumn(n),a=t?.getLineMaxColumn(i),r=e.setStartPosition(n,o).setEndPosition(i,a);return t?.getValueInRange(r)}handleEditorInitialized(e){const{focusOnMount:t,onChange:n,onEditorInitialized:s,settings:i,session:o,sessionLanguage:a}=this.props;on.debug("handleEditorInitialized",a,o,i),this.editor=e,this.setState({model:this.editor.getModel()}),Ht.setEOL(e),Ht.registerPasteHandler(e),o!=null&&i&&a===i.language&&(this.initContextActions(),this.initCodeCompletion()),e.onDidChangeModelContent(n),t!=null&&t&&e.focus(),s(this.editor)}handleEditorWillDestroy(e){on.debug("handleEditorWillDestroy");const{onEditorWillDestroy:t}=this.props;t(e),this.deInitContextActions(),this.deInitCodeCompletion(),this.setState({model:null}),this.editor=void 0}handleRun(){const{onRunCommand:e}=this.props,t=this.getValue();t!=null&&e(t)}handleRunSelected(){const{onRunCommand:e}=this.props,t=this.getSelectedCommand();e(t)}initContextActions(){if(this.contextActionCleanups.length>0){on.error("Context actions already initialized.");return}if(!this.editor)return;const e=[];e.push(this.editor.addAction({id:"run-code",label:"Run",keybindings:[Ht.getMonacoKeyCodeFromShortcut(Mt.NOTEBOOK.RUN)],contextMenuGroupId:"navigation",contextMenuOrder:1.5,run:()=>{this.handleRun()}})),e.push(this.editor.addAction({id:"run-selected-code",label:"Run Selected",keybindings:[Ht.getMonacoKeyCodeFromShortcut(Mt.NOTEBOOK.RUN_SELECTED)],contextMenuGroupId:"navigation",contextMenuOrder:1.5,run:()=>{this.handleRunSelected()}})),this.contextActionCleanups=e}deInitContextActions(){this.contextActionCleanups.length>0&&(this.contextActionCleanups.forEach(e=>e.dispose()),this.contextActionCleanups=[])}updateShortcuts(){this.deInitContextActions(),this.initContextActions()}initCodeCompletion(){if(this.completionCleanup!=null){on.error("Code completion already initialized.");return}const{session:e}=this.props;on.debug("initCodeCompletion",this.editor,e),this.editor&&e!=null&&(this.completionCleanup=Ht.openDocument(this.editor,e))}deInitCodeCompletion(){const{session:e}=this.props;on.debug("deInitCodeCompletion",this.editor,e),this.completionCleanup&&(this.completionCleanup.dispose(),this.completionCleanup=void 0,this.editor&&e!=null&&Ht.closeDocument(this.editor,e))}append(e,t=!0){M(this.editor);const n=this.editor.getModel();M(n);const s=n.getValue();s?n.setValue(`${s}
11
- ${e}`):n.setValue(`${e}`);const i=n.getLineCount(),o=n.getLineLength(i)+1;this.editor.setPosition({lineNumber:i,column:o}),t&&this.editor.focus()}updateDimensions(){on.debug("updateDimensions"),this.editor&&this.editor.layout()}focus(){on.debug("focus"),this.editor&&this.editor.focus()}toggleFind(){this.editorComponent.current&&this.editorComponent.current.toggleFind()}setLanguage(e){this.editorComponent.current&&e!==void 0&&this.editorComponent.current.setLanguage(e)}render(){const{error:e,isLoaded:t,isLoading:n,session:s,sessionLanguage:i,settings:o}=this.props,{model:a}=this.state,r=e?`Unable to open document. ${e}`:null,c=o?o.language??null:null,h=a&&s&&c===i;return l.jsxs(l.Fragment,{children:[(e||n)&&l.jsx("div",{className:"h-100 w-100 position-relative",children:l.jsx(sr,{errorMessage:r,isLoading:n,isLoaded:t})}),t&&l.jsx("div",{className:"h-100 w-100 script-editor",children:o&&l.jsxs(l.Fragment,{children:[l.jsx(Kl,{ref:this.editorComponent,settings:o,onEditorInitialized:this.handleEditorInitialized,onEditorWillDestroy:this.handleEditorWillDestroy}),h!=null&&h&&l.jsx(Jh,{model:a,language:c,session:s})]})})]})}}const oS=iS,aS={groovy:"Groovy",python:"Python",scala:"Scala"};class rS{static normalizeScriptLanguage(e){return aS[e]||null}static getDisabledRunTooltip(e,t,n,s){return e?t?null:`${n} doesn't match the session language – ${s} disabled`:`Console session not connected – ${s} disabled`}}const pd=rS;const lS=250,cS=2500;class ql extends b.Component{static defaultProps={onUpdate:()=>{}};static getTimeString(e,t){if(e==null||t===""||t===0)return null;const n=Math.round((new Date(t).valueOf()-new Date(e).valueOf())/1e3);return n<1?"<1s":Xi.formatElapsedTime(n)}constructor(e){super(e),this.handleUpdate=this.handleUpdate.bind(this),this.handleError=this.handleError.bind(this),this.handleTimeout=this.handleTimeout.bind(this),this.state={currentTime:Date.now()}}componentDidMount(){this.loadData()}componentDidUpdate(e,t){const{data:n}=this.state;this.timer==null&&!n?.result&&Boolean(n?.startTime)&&!(n==null||n.endTime===void 0)?this.startTimer():(n?.result&&!t.data?.result||Boolean(n?.endTime)&&!(t.data==null||t.data.endTime===void 0))&&this.stopTimer()}componentWillUnmount(){this.loadData.cancel(),this.cleanup!=null&&this.cleanup(),this.stopTimer()}timer;cleanup;loadData=Ye(()=>{const{commandHistoryStorage:e,item:t,language:n}=this.props,{id:s}=t;this.cleanup=e.listenItem(n,s,this.handleUpdate,this.handleError)},lS);startTimer(){this.stopTimer(),this.timer=setInterval(this.handleTimeout,1e3)}stopTimer(){this.timer&&(clearInterval(this.timer),this.timer=void 0)}updateTime(){this.setState({currentTime:Date.now()})}handleError(e){this.setState({error:`${e}`})}handleUpdate(e){const{data:t}=e??{};this.setState({data:t});const{onUpdate:n}=this.props;n?.(t)}handleTimeout(){this.updateTime()}getPreviewText=ge(e=>e.split(`
12
- `,cS).join(`
13
- `),{max:1});render(){const{item:{name:e},language:t}=this.props,{currentTime:n,data:s,error:i}=this.state,{result:o,startTime:a,endTime:r}=s??{},c=o?.error??i,h=ql.getTimeString(a,r??n),u=this.getPreviewText(e),m=Boolean(h);return l.jsxs("div",{className:"command-history-item-tooltip",children:[l.jsxs("div",{className:"scroll-container",children:[l.jsx(ur,{language:t,children:u}),u.length<e.length&&l.jsx("p",{children:"Preview Truncated..."})]}),l.jsxs("div",{className:"result-info",children:[l.jsxs("div",{className:"d-flex justify-content-between",children:[Boolean(c)&&l.jsxs("div",{className:"text-danger mr-1",children:[l.jsx(Q,{icon:As})," Executed with errors"]}),l.jsxs("div",{className:"time-wrapper",children:["Elapsed time:"," ",m?l.jsx("span",{className:"time-string",children:h}):l.jsx(yn,{})]})]}),Boolean(c)&&l.jsx("div",{className:"error-message",children:c})]})]})}}const dS=ql,hS=512;function nu(d){const{item:e,language:t,isSelected:n,commandHistoryStorage:s}=d,i=e.name.substring(0,hS),o=b.useRef(null),a=b.useCallback(()=>{o.current?.update()},[o]);return l.jsxs("div",{className:$("command-history-item",{selected:n}),children:[i,l.jsx(tt,{ref:o,interactive:!0,options:{placement:"left",modifiers:{preventOverflow:{enabled:!0,boundariesElement:"viewport",order:825}}},popperClassName:"command-history-item-popper",children:l.jsx(dS,{item:e,language:t,onUpdate:a,commandHistoryStorage:s})})]})}nu.defaultProps={isSelected:!1};class _a extends b.Component{static itemKey(e,t){return`${t.title}`}static renderContent(e){return e.selectionRequired!==void 0&&e.selectionRequired?l.jsxs("div",{className:"fa-md fa-layers",children:[l.jsx(Q,{icon:Ui,mask:e.icon,transform:"right-5 down-5 shrink-4"}),l.jsx(Q,{icon:Lg,transform:"shrink-3 right-7 down-6"})]}):l.jsx(Q,{icon:e.icon})}render(){const{actions:e,hasSelection:t}=this.props;return l.jsx("div",{className:"command-history-actions",children:e.map((n,s)=>l.jsx(B,{kind:"inline",className:$(n.className),onClick:n.action,tooltip:n.description,disabled:n.selectionRequired!==void 0&&n.selectionRequired&&!t,icon:_a.renderContent(n)},_a.itemKey(s,n)))})}}const uS=_a;const mS=150,gS=150,fd=3,Cd=Z.module("CommandHistoryViewportUpdater");function pS({table:d,columns:e,top:t=0,bottom:n=0,search:s,isReversed:i=!1,onUpdate:o}){const a=b.useMemo(()=>Ye(c=>{d.setSearch(c??"")},mS),[d]),r=b.useMemo(()=>Ls(c=>{const h=c.bottom-c.top,u=Math.max(0,c.top-h*fd),m=c.bottom+h*fd;d.setViewport({top:u,bottom:m,columns:c.columns})},gS),[d]);return b.useEffect(function(){const h=d.onUpdate(u=>{o({items:u.items??[],offset:u.offset??0})});return()=>{Cd.debug("onUpdate cleanup"),h()}},[d,o]),b.useEffect(function(){a(s)},[a,s]),b.useEffect(function(){r({top:t,bottom:n,columns:e})},[r,t,n,e,s,i]),b.useEffect(()=>()=>{Cd.debug2("Cancel throttledUpdateViewport"),r.cancel()},[r]),null}const ds=Z.module("CommandHistory");class Mn extends b.Component{static ITEM_HEIGHT=29;static MAX_SELECTION_COUNT=1e4;static menuGroups={send:ie.groups.medium+100};static getCommandsFromViewport(e,t,n){const s=[];for(let i=0;i<n.length;i+=1){const o=n[i];for(let a=o[0];a<=o[1];a+=1)if(a>=t&&a<t+e.length){const{name:r}=e[a-t];s.push(r)}}return s}static async getCommandsFromSnapshot(e,t){return[...(await e.getSnapshot(t)).values()].map(s=>s.name)}constructor(e){super(e),this.copySelectedCommands=this.copySelectedCommands.bind(this),this.createNotebook=this.createNotebook.bind(this),this.sendToConsole=this.sendToConsole.bind(this),this.renderItem=this.renderItem.bind(this),this.runInConsole=this.runInConsole.bind(this),this.sendToNotebook=this.sendToNotebook.bind(this),this.handleSelect=this.handleSelect.bind(this),this.handleSelectionChange=this.handleSelectionChange.bind(this),this.handleSearchChange=this.handleSearchChange.bind(this),this.handleViewportChange=this.handleViewportChange.bind(this),this.handleViewportUpdate=this.handleViewportUpdate.bind(this),this.itemActions=[{title:"Copy Selection",description:"Copy selected commands to clipboard",icon:Pg,shortcut:ss.COPY,action:this.copySelectedCommands,group:ie.groups.edit},{title:"Send to Console",description:"Open selected commands in the console",icon:Vc,shortcut:Mt.COMMAND_HISTORY.SEND_TO_CONSOLE,action:this.sendToConsole,group:Mn.menuGroups.send,order:10},{title:"Run in Console",description:"Run selected commands in the console",icon:Da,shortcut:Mt.COMMAND_HISTORY.RUN,action:this.runInConsole,group:Mn.menuGroups.send,order:10},{title:"Send to Active Notebook",description:"Open selected commands in a notebook",icon:Bc,shortcut:Mt.COMMAND_HISTORY.SEND_TO_NOTEBOOK,action:this.sendToNotebook,group:Mn.menuGroups.send,order:20},{title:"Send to New Notebook",description:"Open selected commands in a new notebook",icon:kh,action:this.createNotebook,group:Mn.menuGroups.send,order:30}],this.historyActions=[{title:"Send to Console",icon:Vc,selectionRequired:!0,description:"Open selected commands in the console",action:this.sendToConsole},{title:"Send to Notebook",icon:Bc,selectionRequired:!0,description:"Open selected commands in a notebook",action:this.sendToNotebook}],this.pending=new is,this.searchInputRef=J.createRef(),this.itemListRef=J.createRef();const{table:t}=e;this.state={actions:[],historyActions:this.historyActions,top:0,bottom:0,itemCount:t.size,items:[],offset:0,selectedRanges:[],searchText:""}}componentWillUnmount(){this.pending.cancel()}itemActions;historyActions;pending;searchInputRef;itemListRef;async getSelectedCommands(){const{items:e,offset:t,selectedRanges:n}=this.state,s=n.slice().sort((o,a)=>o[0]-a[0]);if(s.length===0)return[];if(s[0][0]>=t&&s[s.length-1][1]<t+e.length)return Mn.getCommandsFromViewport(e,t,s);const{table:i}=this.props;return this.pending.add(Mn.getCommandsFromSnapshot(i,s))}getSelectedCommandText(){return this.getSelectedCommands().then(e=>e.join(`
14
- `))}updateActions(){this.setState(e=>{const{selectedRanges:t}=e,n=t.reduce((s,i)=>s+i[1]-i[0]+1,0);return n>0&&n<Mn.MAX_SELECTION_COUNT?(ds.debug("Updating actions",this.itemActions),{actions:this.itemActions}):(ds.debug("Disabling actions",n),{actions:[]})})}copySelectedCommands(){this.getSelectedCommandText().then(Yi).catch(ds.error)}createNotebook(){this.getSelectedCommandText().then(e=>{const{language:t,sendToNotebook:n}=this.props;n({value:e,language:t},!0)}).catch(ds.error)}sendToNotebook(){this.getSelectedCommandText().then(e=>{const{language:t,sendToNotebook:n}=this.props;n({value:e,language:t})}).catch(ds.error)}sendToConsole(){const{sendToConsole:e}=this.props;this.getSelectedCommandText().then(e).catch(ds.error)}runInConsole(){this.getSelectedCommandText().then(e=>{const{sendToConsole:t}=this.props;t(e,!0,!0)}).catch(ds.error)}handleSelect(e){const{sendToConsole:t}=this.props,{items:n,offset:s}=this.state;if(e<s||e>=s+n.length){ds.error("Invalid index!",e);return}const{name:i}=n[e-s];t(i)}handleSelectionChange(e){this.setState({selectedRanges:e}),this.updateActions()}handleViewportChange(e,t){this.setState({top:e,bottom:t})}handleSearchChange(e){this.setState({searchText:e.target.value,selectedRanges:[]})}handleViewportUpdate({items:e,offset:t}){const{table:n}=this.props,s=n.size;this.setState({items:e,itemCount:s,offset:t})}renderItem({item:e,itemIndex:t,isSelected:n}){const{language:s,commandHistoryStorage:i}=this.props;return l.jsx(nu,{isSelected:n,item:e,language:s,commandHistoryStorage:i})}focus(){this.searchInputRef.current&&this.searchInputRef.current.focus()}restoreScrollPosition(){this.itemListRef.current?.restoreScrollPosition()}render(){const{language:e,table:t}=this.props,{actions:n,historyActions:s,searchText:i,top:o,bottom:a,items:r,itemCount:c,offset:h,selectedRanges:u}=this.state,m=Zh.LANGUAGE_MAP.get(e)??"";return l.jsxs("div",{className:"command-history",children:[l.jsxs("div",{className:"command-history-search-bar",children:[l.jsx(_s,{ref:this.searchInputRef,value:i,placeholder:`${m} Command History`,onChange:this.handleSearchChange}),l.jsx(uS,{actions:s,hasSelection:u.length>0})]}),l.jsxs("div",{className:"command-history-list",children:[l.jsx(Bt,{ref:this.itemListRef,itemCount:c,items:r,offset:h,selectedRanges:u,onSelect:this.handleSelect,onSelectionChange:this.handleSelectionChange,onViewportChange:this.handleViewportChange,renderItem:this.renderItem,rowHeight:Mn.ITEM_HEIGHT,isDoubleClickSelect:!0,isMultiSelect:!0,isStickyBottom:!0}),l.jsx(pS,{table:t,top:o,bottom:a,search:i,onUpdate:this.handleViewportUpdate}),l.jsx(ie,{actions:n})]})]})}}const fS=Mn;class CS extends b.PureComponent{constructor(e){super(e),this.handleSwitchClick=this.handleSwitchClick.bind(this)}handleSwitchClick(){const{logLevel:e,onClick:t}=this.props;t(e)}render(){const{logLevel:e,on:t}=this.props;return l.jsxs("div",{className:$("log-level-menu-item",e),children:[l.jsx(Kh,{on:t,onClick:this.handleSwitchClick}),e]})}}const SS=CS;class Rt extends b.PureComponent{static DefaultLogLevels=[gt.STDOUT,gt.ERROR,gt.FATAL,gt.STDERR,gt.WARN];static AllLogLevels=[gt.INFO,gt.STDOUT,gt.ERROR,gt.FATAL,gt.STDERR,gt.WARN,gt.DEBUG,gt.TRACE];static bufferTimeout=16;static maxLogSize=131072;static truncateSize=65536;static getLogText(e){const t=new Date(e.micros/1e3);return`${ul.formatTimestamp(t)} ${e.logLevel} ${e.message}`}constructor(e){super(e),this.handleClearClick=this.handleClearClick.bind(this),this.handleFlushTimeout=this.handleFlushTimeout.bind(this),this.handleLogMessage=this.handleLogMessage.bind(this),this.handleMenuItemClick=this.handleMenuItemClick.bind(this),this.handleResetClick=this.handleResetClick.bind(this),this.handleResize=this.handleResize.bind(this),this.handleToggleAllClick=this.handleToggleAllClick.bind(this),this.logLevelMenuItems={},this.editorContainer=null,this.bufferedMessages=[],this.messages=[],this.state={shownLogLevels:{}}}componentDidMount(){this.resetLogLevels(),this.initMonaco(),this.startListening(),window.addEventListener("resize",this.handleResize)}componentDidUpdate(e,t){this.updateDimensions();const{shownLogLevels:n}=this.state;t.shownLogLevels!==n&&this.refreshLogText();const{session:s}=this.props;e.session!==s&&(this.stopListening(),this.startListening(),this.clearLogs())}componentWillUnmount(){this.stopFlushTimer(),this.stopListening(),this.destroyMonaco(),window.removeEventListener("resize",this.handleResize)}cancelListener;editor;editorContainer;logLevelMenuItems;flushTimer;bufferedMessages;messages;getMenuActions(e){const t=[];t.push({menuElement:l.jsx("div",{className:"log-level-menu-title",children:"Display Log Levels"}),group:1,order:10});for(let n=0;n<Rt.AllLogLevels.length;n+=1){const s=Rt.AllLogLevels[n],i=e[s]!=null?e[s]:!1;t.push({title:s,group:1,order:n+100,menuElement:l.jsx(SS,{logLevel:s,on:i,onClick:this.handleMenuItemClick,ref:o=>{o!=null&&(this.logLevelMenuItems[s]=o)}})})}return t.push({group:1,order:1e3,menuElement:l.jsxs("div",{className:"log-level-menu-controls",children:[l.jsx(B,{kind:"ghost",className:"log-level-toggle-all",onClick:this.handleToggleAllClick,children:"Toggle All"}),l.jsx(B,{kind:"ghost",onClick:this.handleResetClick,children:"Reset"})]})}),t}resetLogLevels(){const e={};for(let t=0;t<Rt.AllLogLevels.length;t+=1){const n=Rt.AllLogLevels[t],s=Rt.DefaultLogLevels.some(i=>i===n);e[n]=s}this.setState({shownLogLevels:e})}startListening(){const{session:e}=this.props;this.cancelListener=e.onLogMessage(this.handleLogMessage)}stopListening(){this.cancelListener!=null&&(this.cancelListener(),this.cancelListener=void 0)}initMonaco(){M(this.editorContainer),this.editor=Qn.create(this.editorContainer,{copyWithSyntaxHighlighting:!1,fixedOverflowWidgets:!0,folding:!1,fontFamily:"Fira Mono",glyphMargin:!1,language:"log",lineDecorationsWidth:0,lineNumbers:"off",lineNumbersMinChars:0,minimap:{enabled:!1},readOnly:!0,renderLineHighlight:"none",scrollBeyondLastLine:!1,value:"",wordWrap:"on"}),this.editor.addCommand(Ds.Escape,()=>{}),this.editor.addCommand(dn.Shift|Ds.Escape,()=>{}),this.editor.addCommand(Ds.Escape,()=>{const e=this.editor?.getPosition();M(e),this.editor?.setPosition(e)},"findWidgetVisible && editorTextFocus"),this.editor.addCommand(dn.Shift|Ds.Escape,()=>{const e=this.editor?.getPosition();M(e),this.editor?.setPosition(e)},"findWidgetVisible && editorTextFocus")}destroyMonaco(){this.editor&&(this.editor.dispose(),this.editor=void 0)}triggerFindWidget(){this.editor?.focus(),this.editor?.trigger("keyboard","actions.find",void 0)}toggleAll(){const{shownLogLevels:e}=this.state;let t=!0;for(let n=0;n<Rt.AllLogLevels.length;n+=1){const s=Rt.AllLogLevels[n];if(!e[s]){t=!1;break}}if(t)this.setState({shownLogLevels:{}});else{const n={};for(let s=0;s<Rt.AllLogLevels.length;s+=1){const i=Rt.AllLogLevels[s];n[i]=!0}this.setState({shownLogLevels:n})}}toggleLogLevel(e){const{shownLogLevels:t}=this.state,n=t[e],s={};s[e]=!n,this.updateLogLevels(s)}updateLogLevels(e){let{shownLogLevels:t}=this.state;t={...t,...e},this.setState({shownLogLevels:t})}appendLogText(e){if(!this.editor)return;const t=this.editor.getModel();let n=t?.getLineCount();M(n);let s=t?.getLineLength(n);M(s);const i=this.isBottomVisible(),o=[];if(s>0&&(o.push({range:{startLineNumber:n,startColumn:s+1,endLineNumber:n,endColumn:s+1},text:`
15
- `,forceMoveMarkers:!0}),n+=1,s=0),o.push({range:{startLineNumber:n,startColumn:s,endLineNumber:n,endColumn:s},text:e,forceMoveMarkers:!0}),t?.applyEdits(o),i){const a=t?.getLineCount();M(a),this.editor.revealLine(a,1)}}refreshLogText(){if(!this.editor)return;this.truncateLogIfNecessary();const{shownLogLevels:e}=this.state,t=this.isBottomVisible();let n="";for(let s=0;s<this.messages.length;s+=1){const i=this.messages[s];if(e[i.logLevel]){const o=Rt.getLogText(i);o.length>0&&(n+=o,o.charAt(o.length-1)!==`
16
- `&&(n+=`
17
- `))}}if(n=n.trimRight(),this.editor.setValue(n),t){const s=this.editor.getModel()?.getLineCount();M(s),this.editor.revealLine(s,1)}this.stopFlushTimer(),this.bufferedMessages=[]}truncateLogIfNecessary(){this.messages.length>Rt.maxLogSize&&(this.messages=this.messages.splice(this.messages.length-Rt.truncateSize))}scrollToBottom(){if(!this.editor)return;const e=this.editor?.getModel?.()?.getLineCount();M(e),this.editor.revealLine(e,1)}isBottomVisible(){if(!this.editor)return!0;const t=this.editor.getModel()?.getLineCount();return M(t),this.isLineVisible(t)}isLineVisible(e){const t=this.editor?.getVisibleRanges();if(t==null||t.length===0)return!1;for(let n=0;n<t.length;n+=1){const s=t[n];if(s.startLineNumber<=e&&e<=s.endLineNumber)return!0}return!1}isLogItemVisible(e){const{shownLogLevels:t}=this.state;return t[e.logLevel]}flush(){let e="";for(let t=0;t<this.bufferedMessages.length;t+=1){const n=this.bufferedMessages[t],s=Rt.getLogText(n);e+=s,s.charAt(s.length-1)!==`
18
- `&&(e+=`
19
- `)}this.bufferedMessages=[],this.appendLogText(e)}queue(e){this.bufferedMessages.push(e),this.bufferedMessages.length===1&&(this.flushTimer=setTimeout(this.handleFlushTimeout,Rt.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(e){this.messages.push(e),this.editor&&this.isLogItemVisible(e)&&this.queue(e)}handleMenuItemClick(e){this.toggleLogLevel(e)}handleResetClick(){this.resetLogLevels()}handleResize(){this.updateDimensions()}handleToggleAllClick(){this.toggleAll()}render(){const e={placement:"bottom-end"},{shownLogLevels:t}=this.state,n=this.getMenuActions(t);return l.jsxs("div",{className:"log-pane h-100 w-100",children:[l.jsxs("div",{className:"log-pane-menu",children:[l.jsx(B,{kind:"ghost",className:"btn-clear-logs",onClick:this.handleClearClick,icon:_g,tooltip:"Clear log"}),l.jsx(B,{kind:"ghost",className:"btn-link-icon btn-overflow",icon:Oo,tooltip:"Log Settings",onClick:()=>{},children:l.jsx(es,{actions:n,popperClassName:"log-level-menu-popper",popperOptions:e})})]}),l.jsx("div",{className:"log-pane-editor h-100 w-100",ref:s=>{this.editorContainer=s}})]})}}const bS=Rt;class ct{static TYPE_GLOBAL="type-global";static TYPE_CONTEXT_PRESET="type-context-preset";static TYPE_CONTEXT_CUSTOM="type-context-custom";static isValid(e){return!0}static isSameFormat(e,t){throw new Error("isSameFormat not implemented")}static makeFormat(e,t,n){return{label:e,formatString:t,type:n}}format(e,t){return""}}class wS extends ct{format(e){switch(e){case 1:case!0:return"true";case 0:case!1:return"false";default:return""}}}class vS extends ct{format(e){return String.fromCharCode(e)}}const Sd=Z.module("DateTimeColumnFormatter");class je extends ct{static isValid(e){try{return R.i18n.DateTimeFormat.format(e.formatString,new Date),!0}catch{return!1}}static makeFormat(e,t,n=ct.TYPE_CONTEXT_PRESET){return{label:e,formatString:t,type:n}}static isSameFormat(e,t){return e===t||e!==null&&t!==null&&e.type===t.type&&e.formatString===t.formatString}static DEFAULT_DATETIME_FORMAT_STRING="yyyy-MM-dd HH:mm:ss.SSS";static DEFAULT_TIME_ZONE_ID="America/New_York";static makeGlobalFormatStringMap(e,t){const n=t?"'T'":" ",s=e?" 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(e,t){return[...je.makeGlobalFormatStringMap(e,t).keys()]}static makeFormatStringMap(e,t){const n=t!==void 0&&t?"'T'":" ",s=e!==void 0&&e?" z":"";return new Map([["yyyy-MM-dd",`yyyy-MM-dd${s}`],["MM-dd-yyyy",`MM-dd-yyyy${s}`],["HH:mm:ss",`HH:mm:ss${s}`],["HH:mm:ss.SSS",`HH:mm:ss.SSS${s}`],["HH:mm:ss.SSSSSSSSS",`HH:mm:ss.SSSSSSSSS${s}`],["yyyy-MM-dd HH:mm:ss",`yyyy-MM-dd${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(e,t){return[...je.makeFormatStringMap(e,t).keys()]}dhTimeZone;defaultDateTimeFormatString;showTimeZone;showTSeparator;formatStringMap;constructor({timeZone:e="",showTimeZone:t=!0,showTSeparator:n=!1,defaultDateTimeFormatString:s=je.DEFAULT_DATETIME_FORMAT_STRING}={}){super();const i=e||je.DEFAULT_TIME_ZONE_ID;try{this.dhTimeZone=R.i18n.TimeZone.getTimeZone(i)}catch{Sd.error("Unsupported time zone id",i),this.dhTimeZone=R.i18n.TimeZone.getTimeZone(je.DEFAULT_TIME_ZONE_ID)}this.defaultDateTimeFormatString=s,this.showTimeZone=t,this.showTSeparator=n,this.formatStringMap=je.makeFormatStringMap(t,n)}getEffectiveFormatString(e){return this.formatStringMap.get(e)??e}format(e,t={}){const n=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultDateTimeFormatString,s=this.getEffectiveFormatString(n);try{return R.i18n.DateTimeFormat.format(s,e,this.dhTimeZone)}catch{Sd.error("Invalid format arguments")}return""}}const TS=Z.module("DecimalColumnFormatter");class Re extends ct{static isValid(e){try{return R.i18n.NumberFormat.format(e.formatString,0),!0}catch{return!1}}static makeFormat(e,t,n=ct.TYPE_CONTEXT_PRESET,s){return{label:e,type:n,formatString:t,multiplier:s}}static makePresetFormat(e,t="",n){return Re.makeFormat(e,t,ct.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(e="",t){return Re.makeFormat("Custom Format",e,ct.TYPE_CONTEXT_CUSTOM,t)}static DEFAULT_FORMAT_STRING="###,##0.0000";static FORMAT_PERCENT=Re.makePresetFormat("Percent","##0.00%");static FORMAT_BASIS_POINTS=Re.makePresetFormat("Basis Points","###,##0 bp",1e4);static FORMAT_MILLIONS=Re.makePresetFormat("Millions","###,##0.000 mm",1e-6);static FORMAT_SCIENTIFIC_NOTATION=Re.makePresetFormat("Scientific Notation","0.0000E0");static FORMAT_ROUND=Re.makePresetFormat("Round","###,##0");static FORMAT_ROUND_TWO_DECIMALS=Re.makePresetFormat("0.00","###,##0.00");static FORMAT_ROUND_FOUR_DECIMALS=Re.makePresetFormat("0.0000","###,##0.0000");static isSameFormat(e,t){return e===t||e!=null&&t!=null&&e.type===t.type&&e.formatString===t.formatString&&e.multiplier===t.multiplier}defaultFormatString;constructor({defaultFormatString:e=Re.DEFAULT_FORMAT_STRING}={}){super(),this.defaultFormatString=e}format(e,t={}){const n=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultFormatString,s=t.multiplier!=null&&t.multiplier!==0?e*t.multiplier:e;try{return R.i18n.NumberFormat.format(n,s)}catch{TS.error("Invalid format arguments")}return""}}class ES extends ct{format(e){return`${e}`}}const yS=Z.module("IntegerColumnFormatter");class Ge extends ct{static isValid(e){try{return R.i18n.NumberFormat.format(e.formatString,0),!0}catch{return!1}}static makeFormat(e,t,n=ct.TYPE_CONTEXT_PRESET,s){return{label:e,type:n,formatString:t,multiplier:s}}static makePresetFormat(e,t="",n){return Ge.makeFormat(e,t,ct.TYPE_CONTEXT_PRESET,n)}static makeCustomFormat(e="",t){return Ge.makeFormat("Custom Format",e,ct.TYPE_CONTEXT_CUSTOM,t)}static isSameFormat(e,t){return e===t||e!=null&&t!=null&&e.type===t.type&&e.formatString===t.formatString&&e.multiplier===t.multiplier}static DEFAULT_FORMAT_STRING="###,##0";static FORMAT_MILLIONS=Ge.makePresetFormat("Millions","###,##0.000 mm",1e-6);static FORMAT_SCIENTIFIC_NOTATION=Ge.makePresetFormat("Scientific Notation","0.0000E0");defaultFormatString;constructor({defaultFormatString:e=Ge.DEFAULT_FORMAT_STRING}={}){super(),this.defaultFormatString=e}format(e,t={}){const n=t.formatString!=null&&t.formatString!==""?t.formatString:this.defaultFormatString,s=t.multiplier!=null&&t.multiplier!==0?e*t.multiplier:e;try{return R.i18n.NumberFormat.format(n,s)}catch{yS.error("Invalid format arguments")}return""}}class RS extends ct{format(e){return e}}class et{static FULL_DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSSSSS";static months=["january","february","march","april","may","june","july","august","september","october","november","december"];static makeDateWrapper(e,t,n=0,s=1,i=0,o=0,a=0,r=0){if(!e)throw new Error("No timezone provided");const c=`${t}`.padStart(4,"0"),h=`${n+1}`.padStart(2,"0"),u=`${s}`.padStart(2,"0"),m=`${i}`.padStart(2,"0"),g=`${o}`.padStart(2,"0"),p=`${a}`.padStart(2,"0"),C=`${r}`.padStart(9,"0"),f=`${c}-${h}-${u} ${m}:${g}:${p}.${C}`;return R.i18n.DateTimeFormat.parse(et.FULL_DATE_FORMAT,f,R.i18n.TimeZone.getTimeZone(e))}static getNextNanos(e){const t=parseInt(e,10),n="0".repeat(9-e.length),s=`${t+1}${n}`;return parseInt(s,10)}static getNextDate(e,t,n){let{year:s,month:i,date:o,hours:a,minutes:r,seconds:c,nanos:h}=t;if(e.nanos!=null){if(e.nanos.length===9)return null;h=et.getNextNanos(e.nanos),h>999999999&&(c+=1,h=0)}else e.seconds!=null?c+=1:e.minutes!=null?r+=1:e.hours!=null?a+=1:e.date!=null?o+=1:e.month!=null?i+=1:s+=1;const u=new Date(s,i,o,a,r,c);return et.makeDateWrapper(n,u.getFullYear(),u.getMonth(),u.getDate(),u.getHours(),u.getMinutes(),u.getSeconds(),h)}static parseMonth(e){const t=parseInt(e,10);if(!Number.isNaN(t))return t>=1&&t<=12?t-1:NaN;const n=e.trim().toLowerCase();if(n.length>=3){for(let s=0;s<et.months.length;s+=1)if(et.months[s].startsWith(n))return s}return NaN}static parseDateValues(e,t,n,s,i,o,a){const r=parseInt(e,10),c=t!=null?this.parseMonth(t):0,h=n!=null?parseInt(n,10):1,u=s!=null?parseInt(s,10):0,m=i!=null?parseInt(i,10):0,g=o!=null?parseInt(o,10):0,p=a!=null?parseInt(a.padEnd(9,"0"),10):0;return Number.isNaN(r)||Number.isNaN(c)||Number.isNaN(h)||Number.isNaN(u)||Number.isNaN(m)||Number.isNaN(g)||Number.isNaN(p)?null:{year:r,month:c,date:h,hours:u,minutes:m,seconds:g,nanos:p}}static parseDateTimeString(e){const n=/\s*(\d{4})([-./]([\da-z]+))?([-./](\d{1,2}))?([tT\s](\d{2})([:](\d{2}))?([:](\d{2}))?([.](\d{1,9}))?)?(.*)/.exec(e);if(n==null)throw new Error(`Unexpected date string: ${e}`);const[,s,,i,,o,,a,,r,,c,,h,u]=n;if(u!=null&&u.length>0)throw new Error(`Unexpected characters after date string '${e}': ${u}`);return{year:s,month:i,date:o,hours:a,minutes:r,seconds:c,nanos:h}}static parseDateRange(e,t){const n=e.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 r=new Date(Date.now()),c=et.makeDateWrapper(t,r.getFullYear(),r.getMonth(),r.getDate()),h=et.makeDateWrapper(t,r.getFullYear(),r.getMonth(),r.getDate()+1);return[c,h]}if(n==="yesterday"){const r=new Date(Date.now()),c=et.makeDateWrapper(t,r.getFullYear(),r.getMonth(),r.getDate()-1),h=et.makeDateWrapper(t,r.getFullYear(),r.getMonth(),r.getDate());return[c,h]}if(n==="now"){const r=new Date(Date.now());return[R.DateWrapper.ofJsDate(r),null]}const s=et.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=et.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=et.makeDateWrapper(t,i.year,i.month,i.date,i.hours,i.minutes,i.seconds,i.nanos),a=et.getNextDate(s,i,t);return[o,a]}static getJsDate(e){return typeof e=="number"?new Date(e):e.asDate()}}class wn{static not="not";static and="and";static or="or"}function xS(d){if(!(d==="not"||d==="and"||d==="or"))throw new Error("operator is not a valid FilterOperatorValue")}class X{static eq="eq";static eqIgnoreCase="eqIgnoreCase";static notEq="notEq";static notEqIgnoreCase="notEqIgnoreCase";static greaterThan="greaterThan";static greaterThanOrEqualTo="greaterThanOrEqualTo";static lessThan="lessThan";static lessThanOrEqualTo="lessThanOrEqualTo";static in="in";static inIgnoreCase="inIgnoreCase";static notIn="notIn";static notInIgnoreCase="notInIgnoreCase";static isTrue="isTrue";static isFalse="isFalse";static isNull="isNull";static invoke="invoke";static contains="contains";static notContains="notContains";static startsWith="startsWith";static endsWith="endsWith";static containsAny="containsAny"}function su(d){switch(d){case X.eq:return"is exactly";case X.eqIgnoreCase:return"is exactly (ignore case)";case X.notEq:return"is not exactly";case X.notEqIgnoreCase:return"is not exactly (ignore case)";case X.contains:return"contains";case X.notContains:return"does not contain";case X.startsWith:return"starts with";case X.endsWith:return"ends with";default:throw new Error(`Unrecognized text filter type ${d}`)}}function iu(d){switch(d){case X.eq:return"is equal to";case X.notEq:return"is not equal to";case X.greaterThan:return"greater than";case X.greaterThanOrEqualTo:return"greater than or equal to";case X.lessThan:return"less than";case X.lessThanOrEqualTo:return"less than or equal to";default:throw new Error(`Unrecognized number filter type ${d}`)}}function ou(d){switch(d){case X.eq:return"date is";case X.notEq:return"date is not";case X.notEqIgnoreCase:case X.greaterThan:return"date is after";case X.greaterThanOrEqualTo:return"date is after or equal";case X.lessThan:return"date is before";case X.lessThanOrEqualTo:return"date is before or equal";default:throw new Error(`Unrecognized date filter type ${d}`)}}function IS(d){switch(d){case X.isTrue:return"Is True";case X.isFalse:return"Is False";case X.isNull:return"Is Null";default:throw new Error(`Unrecognized boolean filter type ${d}`)}}const Gn=Z.module("TableUtils");class x{static dataType={BOOLEAN:"boolean",CHAR:"char",DATETIME:"datetime",DECIMAL:"decimal",INT:"int",STRING:"string",UNKNOWN:"unknown"};static sortDirection={ascending:"ASC",descending:"DESC",reverse:"REVERSE",none:null};static REVERSE_TYPE=Object.freeze({NONE:"none",PRE_SORT:"pre-sort",POST_SORT:"post-sort"});static NUMBER_REGEX=/^-?\d+(\.\d+)?$/;static getSortIndex(e,t){for(let n=0;n<e.length;n+=1)if(e[n].column?.name===t)return n;return null}static getSortForColumn(e,t){const n=x.getSortIndex(e,t);return n!=null?e[n]:null}static getFilterText(e){return e?e.toString():null}static getFilterTypes(e){return x.isBooleanType(e)?[X.isTrue,X.isFalse,X.isNull]:x.isCharType(e)||x.isNumberType(e)||x.isDateType(e)?[X.eq,X.notEq,X.greaterThan,X.greaterThanOrEqualTo,X.lessThan,X.lessThanOrEqualTo]:x.isTextType(e)?[X.eq,X.eqIgnoreCase,X.notEq,X.notEqIgnoreCase,X.contains,X.notContains,X.startsWith,X.endsWith]:[]}static getNextSort(e,t,n){if(n<0||n>=e.length)return null;const s=x.getSortForColumn(t,e[n].name);return s===null?e[n].sort().asc():s.direction===x.sortDirection.ascending?s.desc():null}static makeColumnSort(e,t,n,s){if(t<0||t>=e.length||n===x.sortDirection.none)return null;let i=e[t].sort();switch(n){case x.sortDirection.ascending:i=i.asc();break;case x.sortDirection.descending:i=i.desc();break}return s&&(i=i.abs()),i}static toggleSortForColumn(e,t,n,s=!1){if(n<0||n>=t.length)return[];const i=x.getNextSort(t,e,n);return x.setSortForColumn(e,t[n].name,i,s)}static sortColumn(e,t,n,s,i,o){if(n<0||n>=t.length)return[];const a=x.makeColumnSort(t,n,s,i);return x.setSortForColumn(e,t[n].name,a,o)}static setSortForColumn(e,t,n,s=!1){const i=x.getSortIndex(e,t);let o=[];return s&&(o=o.concat(e.filter(({direction:a})=>a!==x.sortDirection.reverse)),i!==null&&o.splice(i,1)),n!==null&&o.push(n),o}static getNormalizedType(e){switch(e){case"boolean":case"java.lang.Boolean":case x.dataType.BOOLEAN:return x.dataType.BOOLEAN;case"char":case"java.lang.Character":case x.dataType.CHAR:return x.dataType.CHAR;case"java.lang.String":case x.dataType.STRING:return x.dataType.STRING;case"io.deephaven.db.tables.utils.DBDateTime":case"io.deephaven.time.DateTime":case"com.illumon.iris.db.tables.utils.DBDateTime":case"java.time.Instant":case"java.time.ZonedDateTime":case x.dataType.DATETIME:return x.dataType.DATETIME;case"double":case"java.lang.Double":case"float":case"java.lang.Float":case"java.math.BigDecimal":case x.dataType.DECIMAL:return x.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 x.dataType.INT:return x.dataType.INT;default:return x.dataType.UNKNOWN}}static isLongType(e){switch(e){case"long":case"java.lang.Long":return!0;default:return!1}}static isDateType(e){switch(e){case"io.deephaven.db.tables.utils.DBDateTime":case"io.deephaven.time.DateTime":case"java.time.Instant":case"java.time.ZonedDateTime":case"com.illumon.iris.db.tables.utils.DBDateTime":return!0;default:return!1}}static isNumberType(e){return x.isIntegerType(e)||x.isDecimalType(e)}static isIntegerType(e){switch(e){case"int":case"java.lang.Integer":case"java.math.BigInteger":case"long":case"java.lang.Long":case"short":case"java.lang.Short":case"byte":case"java.lang.Byte":return!0;default:return!1}}static isDecimalType(e){switch(e){case"double":case"java.lang.Double":case"java.math.BigDecimal":case"float":case"java.lang.Float":return!0;default:return!1}}static isBigDecimalType(e){switch(e){case"java.math.BigDecimal":return!0;default:return!1}}static isBigIntegerType(e){switch(e){case"java.math.BigInteger":return!0;default:return!1}}static isBooleanType(e){switch(e){case"boolean":case"java.lang.Boolean":return!0;default:return!1}}static isCharType(e){switch(e){case"char":case"java.lang.Character":return!0;default:return!1}}static isStringType(e){switch(e){case"java.lang.String":return!0;default:return!1}}static isTextType(e){return this.isStringType(e)||this.isCharType(e)}static getBaseType(e){return e.split("[]")[0]}static isCompatibleType(e,t){return x.getNormalizedType(e)===x.getNormalizedType(t)}static makeQuickFilter(e,t,n){const s=t.split("||");let i=null;for(let o=0;o<s.length;o+=1){const r=s[o].split("&&");let c=null;for(let h=0;h<r.length;h+=1){const u=r[h].trim();if(u.length>0){const m=x.makeQuickFilterFromComponent(e,u,n);if(m)c?c=c.and(m):c=m;else throw new Error(`Unable to parse quick filter from text ${t}`)}}i&&c?i=i.or(c):i=c}return i}static makeQuickFilterFromComponent(e,t,n){const{type:s}=e;return x.isNumberType(s)?this.makeQuickNumberFilter(e,t):x.isBooleanType(s)?this.makeQuickBooleanFilter(e,t):n!=null&&x.isDateType(s)?this.makeQuickDateFilter(e,t,n):x.isCharType(s)?this.makeQuickCharFilter(e,t):this.makeQuickTextFilter(e,t)}static makeQuickNumberFilter(e,t){const n=e.filter();let s=null;const o=/\s*(>=|<=|=>|=<|>|<|!=|=|!)?(\s*-\s*)?(\s*\d*(?:,\d{3})*(?:\.\d*)?\s*)?(null|nan|infinity|inf|\u221E)?(.*)/i.exec(t);let a=null,r=null,c=null,h=null,u=null;if(o!==null&&o.length>3&&([,a,r,c,h,u]=o),u!=null&&u.trim().length>0)return null;if(a==null&&(a="="),h!=null){if(!(a==="="||a==="!"||a==="!="))return null;switch(h=h.trim().toLowerCase(),h){case"null":s=n.isNull();break;case"nan":s=R.FilterCondition.invoke("isNaN",n);break;case"infinity":case"inf":case"∞":r!=null?s=R.FilterCondition.invoke("isInf",n).and(n.lessThan(R.FilterValue.ofNumber(0))):s=R.FilterCondition.invoke("isInf",n).and(n.greaterThan(R.FilterValue.ofNumber(0)));break}return s!==null&&(a==="!"||a==="!=")&&(s=s.not()),s}if(c==null)return null;if(c=x.removeCommas(c),x.isLongType(e.type))try{c=R.FilterValue.ofNumber(R.LongWrapper.ofString(`${r!=null?"-":""}${c}`))}catch(m){return Gn.warn("Unable to create long filter",m),null}else{if(c=parseFloat(c),c==null||Number.isNaN(c))return null;c=R.FilterValue.ofNumber(r!=null?0-c:c)}return s=e.filter(),x.makeRangeFilterWithOperation(s,a,c)}static makeQuickTextFilter(e,t){const n=`${t}`.trim(),i=/^(!~|!=|~|=|!)?(.*)/.exec(n);let o=null,a=null;if(i!==null&&i.length>2&&([,o,a]=i,a!=null&&(a=a.trim())),a==null||a.length===0)return null;o==null&&(o="=");const r=e.filter();if(a.toLowerCase()==="null")switch(o){case"=":return r.isNull();case"!=":case"!":return r.isNull().not()}let c=null,h=null;switch(a.startsWith("*")?(c="*",a=a.substring(1)):a.endsWith("*")&&!a.endsWith("\\*")&&(h="*",a=a.substring(0,a.length-1)),a=a.replace("\\",""),o){case"~":return r.isNull().not().and(r.invoke("matches",R.FilterValue.ofString(`(?s)(?i).*\\Q${a}\\E.*`)));case"!~":return r.isNull().or(r.invoke("matches",R.FilterValue.ofString(`(?s)(?i).*\\Q${a}\\E.*`)).not());case"!=":return c==="*"?r.isNull().or(r.invoke("matches",R.FilterValue.ofString(`(?s)(?i).*\\Q${a}\\E$`)).not()):h==="*"?r.isNull().or(r.invoke("matches",R.FilterValue.ofString(`(?s)(?i)^\\Q${a}\\E.*`)).not()):r.notEqIgnoreCase(R.FilterValue.ofString(a.toLowerCase()));case"=":return c==="*"?r.isNull().not().and(r.invoke("matches",R.FilterValue.ofString(`(?s)(?i).*\\Q${a}\\E$`))):h==="*"?r.isNull().not().and(r.invoke("matches",R.FilterValue.ofString(`(?s)(?i)^\\Q${a}\\E.*`))):r.eqIgnoreCase(R.FilterValue.ofString(a.toLowerCase()))}return null}static makeQuickBooleanFilter(e,t){const s=/^(!=|=|!)?(.*)/.exec(`${t}`.trim());if(s===null)return null;const[,i,o]=s,a=i==="!"||i==="!=",r=o.trim().toLowerCase();let c=e.filter();try{const h=x.makeBooleanValue(r);return h!=null&&h?c=c.isTrue():h===null?c=c.isNull():c=c.isFalse(),a?c.not():c}catch{return null}}static makeQuickDateFilter(e,t,n){const s=t.trim(),o=/\s*(>=|<=|=>|=<|>|<|!=|!|=)?(.*)/.exec(s);if(o==null||o.length<=2)throw new Error(`Unable to parse date filter: ${t}`);let a=null,r=null;[,a,r]=o;let c=X.eq;switch(a){case"<":c=X.lessThan;break;case"<=":case"=<":c=X.lessThanOrEqualTo;break;case">":c=X.greaterThan;break;case">=":case"=>":c=X.greaterThanOrEqualTo;break;case"!=":case"!":c=X.notEq;break;case"=":case"==":default:c=X.eq;break}return x.makeQuickDateFilterWithOperation(e,r,c,n)}static makeQuickDateFilterWithOperation(e,t,n,s){const[i,o]=et.parseDateRange(t,s),a=i!=null?R.FilterValue.ofNumber(i):null,r=o!=null?R.FilterValue.ofNumber(o):null,c=e.filter();if(a==null)return n===X.notEq?c.isNull().not():c.isNull();switch(n){case X.eq:{if(r!=null){const h=c.greaterThanOrEqualTo(a),u=c.lessThan(r);return h.and(u)}return c.eq(a)}case X.lessThan:return c.lessThan(a);case X.lessThanOrEqualTo:return r!=null?c.lessThan(r):c.lessThanOrEqualTo(a);case X.greaterThan:return r!=null?c.greaterThanOrEqualTo(r):c.greaterThan(a);case X.greaterThanOrEqualTo:return c.greaterThanOrEqualTo(a);case X.notEq:{if(r!=null){const h=c.lessThan(a),u=c.greaterThanOrEqualTo(r);return h.or(u)}return c.notEq(a)}default:throw new Error(`Invalid operator: ${n}`)}}static quoteValue(e){return e.length>=2&&(e.charAt(0)==='"'&&e.charAt(e.length-1)==='"'||e.charAt(0)==="'"&&e.charAt(e.length-1)==="'")?e:`"${e}"`}static isRangeOperation(e){switch(e){case"<":case"<=":case"=<":case">":case">=":case"=>":return!0;default:return!1}}static makeQuickCharFilter(e,t){const n=`${t}`.trim(),i=/^(>=|<=|=>|=<|>|<|!=|=|!)?(null|"."|'.'|.)?(.*)/.exec(n);let o=null,a=null,r=null;if(i!==null&&i.length>3&&([,o,a,r]=i),r!=null&&r.trim().length>0||a==null||a.length===0)return null;o==null&&(o="=");const c=e.filter();if(a.toLowerCase()==="null")switch(o){case"=":return c.isNull();case"!=":case"!":return c.isNull().not();default:return null}const h=R.FilterValue.ofString(x.isRangeOperation(o)?x.quoteValue(a):a);return x.makeRangeFilterWithOperation(c,o,h)}static makeRangeFilterWithOperation(e,t,n){switch(t){case"=":return e.eq(n);case"<":return e.lessThan(n);case"<=":case"=<":return e.lessThanOrEqualTo(n);case">":return e.greaterThan(n);case">=":case"=>":return e.greaterThanOrEqualTo(n);case"!=":case"!":return e.notEq(n);default:return null}}static makeCancelableTablePromise(e){return ve.makeCancelable(e,t=>{t.close()})}static makeCancelableTableEventPromise(e,t,n=0,s=null){let i,o,a=!0;const r=new Promise((c,h)=>{o=setTimeout(()=>{i(),a=!1,h(new Hh(`Event "${t}" timed out.`))},n),i=e.addEventListener(t,u=>{if(s!=null&&!s(u)){Gn.debug2("Event triggered, but matcher returned false.");return}Gn.debug2("Event triggered, resolving."),i(),clearTimeout(o),a=!1,c(u)})});return r.cancel=()=>{if(a){Gn.debug2("Pending promise cleanup."),i(),clearTimeout(o),a=!1;return}Gn.debug2("Ignoring non-pending promise cancel.")},r}static makeAdvancedFilter(e,t,n){const{filterItems:s,filterOperators:i,invertSelection:o,selectedValues:a}=t;let r=null;for(let h=0;h<s.length;h+=1){const u=s[h],{selectedType:m,value:g}=u;if(m!=null&&m.length>0&&g!=null&&g.length>0)try{const p=x.makeAdvancedValueFilter(e,m,g,n);if(p!=null){if(h===0)r=p;else if(r!==null&&h-1<i.length){const C=i[h-1];if(C===wn.and)r=r.and(p);else if(C===wn.or)r=r.or(p);else{Gn.error("Unexpected filter operator",C,p),r=null;break}}}else Gn.debug2("Empty filter ignored for",m,g)}catch(p){Gn.error("Unable to create filter",p),r=null;break}}const c=x.makeSelectValueFilter(e,a,o);return c!=null&&(r!=null?r=r.and(c):r=c),r}static removeCommas(e){return e.replace(/[\s|,]/g,"")}static makeFilterValue(e,t){const n=x.getBaseType(e);return x.isTextType(n)?R.FilterValue.ofString(t):x.isLongType(n)?R.FilterValue.ofNumber(R.LongWrapper.ofString(x.removeCommas(t))):R.FilterValue.ofNumber(x.removeCommas(t))}static makeFilterRawValue(e,t){return x.isTextType(e)?R.FilterValue.ofString(t):x.isBooleanType(e)?R.FilterValue.ofBoolean(t):R.FilterValue.ofNumber(t)}static makeValue(e,t,n){if(t==="null")return null;if(x.isTextType(e))return t;if(x.isLongType(e))return R.LongWrapper.ofString(x.removeCommas(t));if(x.isBooleanType(e))return x.makeBooleanValue(t,!0);if(x.isDateType(e)){const[s]=et.parseDateRange(t,n);return s}return x.isNumberType(e)?x.makeNumberValue(t):(Gn.error("Unexpected column type",e),null)}static makeBooleanValue(e,t=!1){if(e===""&&t)return null;switch(e?.toLowerCase()){case"null":return null;case"0":case"f":case"fa":case"fal":case"fals":case"false":case"n":case"no":return!1;case"1":case"t":case"tr":case"tru":case"true":case"y":case"ye":case"yes":return!0;default:throw new Error(`Invalid boolean '${e}'`)}}static makeNumberValue(e){if(e==="null"||e==="")return null;const t=e.toLowerCase().trim();if(t==="∞"||t==="infinity"||t==="inf")return Number.POSITIVE_INFINITY;if(t==="-∞"||t==="-infinity"||t==="-inf")return Number.NEGATIVE_INFINITY;const n=x.removeCommas(t);if(x.NUMBER_REGEX.test(n))return parseFloat(n);throw new Error(`Invalid number '${e}'`)}static getFilterOperatorString(e){switch(e){case X.eq:return"=";case X.notEq:return"!=";case X.greaterThan:return">";case X.greaterThanOrEqualTo:return">=";case X.lessThan:return"<";case X.lessThanOrEqualTo:return"<=";case X.contains:return"~";case X.notContains:return"!~";default:throw new Error(`Unexpected filter type ${e}`)}}static makeAdvancedValueFilter(e,t,n,s){if(x.isDateType(e.type))return x.makeQuickDateFilterWithOperation(e,n,t,s);if(x.isNumberType(e.type)||x.isCharType(e.type))return x.makeQuickFilter(e,`${x.getFilterOperatorString(t)}${n}`);const i=x.makeFilterValue(e.type,n),o=e.filter();switch(t){case X.eq:return o.eq(i);case X.eqIgnoreCase:return o.eqIgnoreCase(i);case X.notEq:return o.notEq(i);case X.notEqIgnoreCase:return o.notEqIgnoreCase(i);case X.greaterThan:return o.greaterThan(i);case X.greaterThanOrEqualTo:return o.greaterThanOrEqualTo(i);case X.lessThan:return o.lessThan(i);case X.lessThanOrEqualTo:return o.lessThanOrEqualTo(i);case X.isTrue:return o.isTrue();case X.isFalse:return o.isFalse();case X.isNull:return o.isNull();case X.contains:return o.isNull().not().and(o.invoke("matches",R.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E.*`)));case X.notContains:return o.isNull().or(o.invoke("matches",R.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E.*`)).not());case X.startsWith:return o.isNull().not().and(o.invoke("matches",R.FilterValue.ofString(`(?s)(?i)^\\Q${n}\\E.*`)));case X.endsWith:return o.isNull().not().and(o.invoke("matches",R.FilterValue.ofString(`(?s)(?i).*\\Q${n}\\E$`)));case X.in:case X.inIgnoreCase:case X.notIn:case X.notInIgnoreCase:case X.invoke:default:throw new Error(`Unexpected filter operation: ${t}`)}}static makeSelectValueFilter(e,t,n){if(t.length===0){if(n)return null;let o=null;x.isTextType(e.type)?o=R.FilterValue.ofString("a"):x.isBooleanType(e.type)?o=R.FilterValue.ofBoolean(!0):x.isDateType(e.type)?o=R.FilterValue.ofNumber(R.DateWrapper.ofJsDate(new Date)):o=R.FilterValue.ofNumber(0);const a=e.filter().eq(o),r=e.filter().notEq(o);return a.and(r)}const s=[];let i=!1;for(let o=0;o<t.length;o+=1){const a=t[o];a==null?i=!0:x.isTextType(e.type)?s.push(R.FilterValue.ofString(typeof a=="number"?String.fromCharCode(a):a)):x.isBooleanType(e.type)?s.push(R.FilterValue.ofBoolean(Boolean(a))):s.push(R.FilterValue.ofNumber(a))}return i?s.length>0?n?e.filter().isNull().not().and(e.filter().notIn(s)):e.filter().isNull().or(e.filter().in(s)):n?e.filter().isNull().not():e.filter().isNull():n?e.filter().notIn(s):e.filter().in(s)}static isTreeTable(e){return e!=null&&e.expand!==void 0&&e.collapse!==void 0}static sortColumns(e,t=!0){return[...e].sort((n,s)=>{const i=n.name.toUpperCase(),o=s.name.toUpperCase();return zt.sort(i,o,t)})}}class Qt{static makeColumnFormatMap(e){return e==null?new Map:e.reduce((t,n)=>{const s=x.getNormalizedType(n.columnType);return s===null||(t.has(s)||t.set(s,new Map),t.get(s)?.set(n.columnName,n.format)),t},new Map)}static makeColumnFormattingRule(e,t,n){return{columnType:e,columnName:t,format:n}}constructor(e=[],t,n,s,i=!1){this.defaultColumnFormatter=new ES,this.typeFormatterMap=new Map([[x.dataType.BOOLEAN,new wS],[x.dataType.CHAR,new vS],[x.dataType.DATETIME,new je(t)],[x.dataType.DECIMAL,new Re(n)],[x.dataType.INT,new Ge(s)],[x.dataType.STRING,new RS]]),this.columnFormatMap=Qt.makeColumnFormatMap(e),this.truncateNumbersWithPound=i}defaultColumnFormatter;typeFormatterMap;columnFormatMap;truncateNumbersWithPound;getColumnFormatMapForType(e,t=!1){const n=x.getNormalizedType(e);if(n!==null)return t&&!this.columnFormatMap.has(n)&&this.columnFormatMap.set(n,new Map),this.columnFormatMap.get(n)}getColumnFormat(e,t){return this.getColumnFormatMapForType(e)?.get(t)??null}getColumnTypeFormatter(e){const t=x.getNormalizedType(e);let n=this.defaultColumnFormatter;return t&&(n=this.typeFormatterMap.get(t)??n),n}getFormattedString(e,t,n="",s){if(e==null)return"";const i=this.getColumnTypeFormatter(t),o=s||this.getColumnFormat(t,n);return i.format(e,o??void 0)}get timeZone(){return this.typeFormatterMap.get(x.dataType.DATETIME)?.dhTimeZone?.id}}function DS(d){if(d&&d.formatter){const{formatter:e}=d;return e}}function FS(d){return{timeZone:d?.timeZone,defaultDateTimeFormatString:d?.defaultDateTimeFormat,showTimeZone:d?.showTimeZone,showTSeparator:d?.showTSeparator}}function NS(d,e,t){const n=d.getColumnFormat(t,e);return n!=null&&(n.type===ct.TYPE_CONTEXT_PRESET||n.type===ct.TYPE_CONTEXT_CUSTOM)}const ns={getColumnFormats:DS,getDateTimeFormatterOptions:FS,isCustomColumnFormatDefined:NS};Ma.register([Lp,Pp,_p,jp,Hp,Vp]);const au=typeof Pr=="function"?Pr(Ma):Pr.default(Ma);class kn{static EVENT_UPDATED="ChartModel.EVENT_UPDATED";static EVENT_DISCONNECT="ChartModel.EVENT_DISCONNECT";static EVENT_RECONNECT="ChartModel.EVENT_RECONNECT";static EVENT_DOWNSAMPLESTARTED="ChartModel.EVENT_DOWNSAMPLESTARTED";static EVENT_DOWNSAMPLEFINISHED="ChartModel.EVENT_DOWNSAMPLEFINISHED";static EVENT_DOWNSAMPLEFAILED="ChartModel.EVENT_DOWNSAMPLEFAILED";static EVENT_DOWNSAMPLENEEDED="ChartModel.EVENT_DOWNSAMPLENEEDED";static EVENT_LOADFINISHED="ChartModel.EVENT_LOADFINISHED";constructor(){this.listeners=[],this.isDownsamplingDisabled=!1}listeners;formatter;rect;isDownsamplingDisabled;title;getData(){return[]}getDefaultTitle(){return""}getLayout(){return{}}getFilterColumnMap(){return new Map}isFilterRequired(){return!1}setFilter(e){}close(){}setFormatter(e){this.formatter=e}setDownsamplingDisabled(e){this.isDownsamplingDisabled=e}setDimensions(e){this.rect=e}setTitle(e){this.title=e}subscribe(e){this.listeners.push(e)}unsubscribe(e){this.listeners=this.listeners.filter(t=>t!==e)}fireEvent(e){for(let t=0;t<this.listeners.length;t+=1)this.listeners[t](e)}fireUpdate(e){this.fireEvent(new CustomEvent(kn.EVENT_UPDATED,{detail:e}))}fireDisconnect(){this.fireEvent(new CustomEvent(kn.EVENT_DISCONNECT))}fireReconnect(){this.fireEvent(new CustomEvent(kn.EVENT_RECONNECT))}fireDownsampleStart(e){this.fireEvent(new CustomEvent(kn.EVENT_DOWNSAMPLESTARTED,{detail:e}))}fireDownsampleFinish(e){this.fireEvent(new CustomEvent(kn.EVENT_DOWNSAMPLEFINISHED,{detail:e}))}fireDownsampleFail(e){this.fireEvent(new CustomEvent(kn.EVENT_DOWNSAMPLEFAILED,{detail:e}))}fireDownsampleNeeded(e){this.fireEvent(new CustomEvent(kn.EVENT_DOWNSAMPLENEEDED,{detail:e}))}fireLoadFinished(){this.fireEvent(new CustomEvent(kn.EVENT_LOADFINISHED))}}const Kn=kn,MS="#76d9e4 #9edc6f #fcd65b #aa9af4 #f37e3f #f95d84 #f0f0ee",kS="#403e41",OS="#5b5a5c",AS="#c0bfbf",LS="#4878ea",PS="rgba(91, 90, 92, 0.7)",wt={"paper-bgcolor":"#2d2a2e","plot-bgcolor":"#322f33","title-color":"#f0f0ee",colorway:MS,gridcolor:kS,linecolor:OS,zerolinecolor:AS,activecolor:LS,rangebgcolor:PS,"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"},jt=Object.freeze({paper_bgcolor:wt["paper-bgcolor"],plot_bgcolor:wt["plot-bgcolor"],title_color:wt["title-color"],colorway:wt.colorway,gridcolor:wt.gridcolor,linecolor:wt.linecolor,zerolinecolor:wt.zerolinecolor,activecolor:wt.activecolor,rangebgcolor:wt.rangebgcolor,area_color:wt["area-color"],trend_color:wt["trend-color"],line_color:wt["line-color"],error_band_line_color:wt["error-band-line-color"],error_band_fill_color:wt["error-band-fill-color"],ohlc_increasing:wt["ohlc-increasing"],ohlc_decreasing:wt["ohlc-decreasing"]}),ro=Z.module("ChartUtils"),hs=Object.freeze(R.calendar.DayOfWeek.values()),bd="io.deephaven.time.DateTime",_S=36e5,jS=1e6;function HS(d){return d.asDate!==void 0}function VS(d){return d.asNumber!==void 0}function wd(d){return d.dhTimeZone!==void 0}function BS(d){return d!=null&&d.range!=null&&(d.autorange===!1||d.autorange===void 0)}class se{static DEFAULT_AXIS_SIZE=.15;static MIN_AXIS_SIZE=.025;static MAX_AXIS_SIZE=.2;static AXIS_SIZE_PX=75;static LEGEND_WIDTH_PX=50;static MAX_LEGEND_SIZE=.25;static ORIENTATION=Object.freeze({HORIZONTAL:"h",VERTICAL:"v"});static DATE_FORMAT="yyyy-MM-dd HH:mm:ss.SSSSSS";static DEFAULT_MARGIN=Object.freeze({l:60,r:50,t:30,b:60,pad:0});static DEFAULT_TITLE_PADDING=Object.freeze({t:8});static SUBTITLE_LINE_HEIGHT=25;static DEFAULT_MARKER_SIZE=6;static MODE_MARKERS="markers";static MODE_LINES="lines";static getPlotlyChartType(e,t){switch(e){case R.plot.SeriesPlotStyle.SCATTER:return t?"scatter":"scattergl";case R.plot.SeriesPlotStyle.LINE:return"scatter";case R.plot.SeriesPlotStyle.BAR:case R.plot.SeriesPlotStyle.STACKED_BAR:return"bar";case R.plot.SeriesPlotStyle.PIE:return"pie";case R.plot.SeriesPlotStyle.TREEMAP:return"treemap";case R.plot.SeriesPlotStyle.HISTOGRAM:return"histogram";case R.plot.SeriesPlotStyle.OHLC:return"ohlc";default:return}}static getPlotlyChartMode(e,t,n){const s=new Set;switch(e){case R.plot.SeriesPlotStyle.SCATTER:(t??!1)&&s.add(se.MODE_LINES),(n??!0)&&s.add(se.MODE_MARKERS);break;case R.plot.SeriesPlotStyle.LINE:(t??!0)&&s.add(se.MODE_LINES),(n??!1)&&s.add(se.MODE_MARKERS);break}return s.size>0?[...s].join("+"):void 0}static getPlotlyProperty(e,t){switch(e){case R.plot.SeriesPlotStyle.PIE:switch(t){case R.plot.SourceType.X:return"labels";case R.plot.SourceType.Y:return"values"}break;case R.plot.SeriesPlotStyle.OHLC:switch(t){case R.plot.SourceType.TIME:return"x"}break;case R.plot.SeriesPlotStyle.TREEMAP:switch(t){case R.plot.SourceType.X:return"ids";case R.plot.SourceType.Y:return"values";case R.plot.SourceType.LABEL:return"labels";case R.plot.SourceType.PARENT:return"parents";case R.plot.SourceType.COLOR:return"marker.colors"}break}switch(t){case R.plot.SourceType.X:return"x";case R.plot.SourceType.Y:return"y";case R.plot.SourceType.Z:return"z";case R.plot.SourceType.X_LOW:return"xLow";case R.plot.SourceType.X_HIGH:return"xHigh";case R.plot.SourceType.Y_LOW:return"yLow";case R.plot.SourceType.Y_HIGH:return"yHigh";case R.plot.SourceType.TIME:return"time";case R.plot.SourceType.OPEN:return"open";case R.plot.SourceType.HIGH:return"high";case R.plot.SourceType.LOW:return"low";case R.plot.SourceType.CLOSE:return"close";case R.plot.SourceType.SHAPE:return"shape";case R.plot.SourceType.SIZE:return"size";case R.plot.SourceType.LABEL:return"label";case R.plot.SourceType.COLOR:return"color";case R.plot.SourceType.PARENT:return"parent";case R.plot.SourceType.HOVER_TEXT:return"hovertext";case R.plot.SourceType.TEXT:return"text";default:throw new Error(`Unrecognized source type: ${t}`)}}static getPlotlySeriesOrientation(e){const{sources:t}=e;return t.length===2&&t[0]?.axis?.type===R.plot.AxisType.Y?se.ORIENTATION.HORIZONTAL:se.ORIENTATION.VERTICAL}static getPlotlyErrorBars(e,t,n){const s=n.map((o,a)=>o-e[a]),i=t.map((o,a)=>e[a]-o);return{type:"data",symmetric:!1,array:s,arrayminus:i}}static getPlotlyDateFormat(e,t,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=e?.getColumnTypeFormatter(t);return o!=null&&wd(o)&&o.dhTimeZone!=null&&o.showTimeZone&&(i=R.i18n.DateTimeFormat.format(" z",new Date,o.dhTimeZone)),{tickformat:s,ticksuffix:i,automargin:!0}}static convertNumberPrefix(e){return e.replace(/\u00A4\u00A4/g,"USD").replace(/\u00A4/g,"$")}static getPlotlyNumberFormat(e,t,n){if(!n)return null;const i=n.split(";")[0].match(/^([^#,0.]*)([#,]*)([0,]*)(\.?)(0*)(#*)(E?0*)(%?)(.*)/);M(i);const[,o,a,r,,c,h,u,m,g]=i,p=r.replace(",","").length,f=a.indexOf(",")>=0||r.indexOf(",")>=0?",":"",S=u!=null&&u!==""?"e":"f",v=m!==""?m:S,w=c.length+h.length,y=`0${p}${f}.${w}${v}`,E=se.convertNumberPrefix(o),D=se.convertNumberPrefix(g);return{tickformat:y,tickprefix:E,ticksuffix:D,automargin:!0}}static getPlotlyAxisFormat(e,t=null){const{axis:n,columnType:s}=e,{formatPattern:i}=n;let o=null;return x.isDateType(s)?(o=se.getPlotlyDateFormat(t,s,i),o=se.addTickSpacing(o,n,!0)):x.isNumberType(s)&&(o=se.getPlotlyNumberFormat(t,s,i),o=se.addTickSpacing(o,n,!1)),n.formatType===R.plot.AxisFormatType.CATEGORY&&(o?o.type="category":o={type:"category",tickformat:void 0,ticksuffix:void 0}),o}static addTickSpacing(e,t,n){const{gapBetweenMajorTicks:s}=t;if(s>0){const i=e||{};let o=s;return n&&(o=s/jS),t.log&&(o=Math.log(o)),i.tickmode="linear",i.dtick=o,i}return e}static getSourceForAxis(e,t){for(let n=0;n<e.series.length;n+=1){const s=e.series[n];for(let i=0;i<s.sources.length;i+=1){const o=s.sources[i];if(o.axis===t)return o}}return null}static getSeriesVisibility(e,t){return t!=null&&t.hiddenSeries!=null&&t.hiddenSeries.includes(e)?"legendonly":!0}static getHiddenLabels(e){return e?.hiddenSeries?[...e.hiddenSeries]:[]}static makeSeriesData(e,t,n,s,i=se.ORIENTATION.VERTICAL){return{type:e,mode:t,name:n,orientation:i,showlegend:s??void 0}}static makeSeriesDataFromSeries(e,t,n,s=null,i=jt){const{name:o,isLinesVisible:a,isShapesVisible:r,plotStyle:c,lineColor:h,shapeColor:u,sources:m,shape:g,shapeSize:p}=e,C=m.some(T=>T.axis?.businessCalendar),f=se.getChartType(c,C),S=se.getPlotlyChartMode(c,a??void 0,r??void 0),v=se.getPlotlySeriesOrientation(e),w=se.makeSeriesData(f,S,o,s,v);return se.addSourcesToSeriesData(w,c,m,t),se.addStylingToSeriesData(w,c,i,h,u,g,p,n),w}static addSourcesToSeriesData(e,t,n,s){const i=e;for(let o=0;o<n.length;o+=1){const a=n[o],{axis:r,type:c}=a,h=se.getPlotlyProperty(t,c);Th(i,h,[]);const u=r!=null?se.getAxisPropertyName(r.type):null;if(u!=null){const m=s.get(r.type);if(m){const g=m.indexOf(r),p=g>0?`${g+1}`:"";i[`${u}axis`]=`${u}${p}`}}}}static addStylingToSeriesData(e,t,n=jt,s=null,i=null,o=null,a=null,r=null){const c=e;if(c.marker={line:{}},c.line={width:1},t===R.plot.SeriesPlotStyle.AREA?c.fill="tozeroy":t===R.plot.SeriesPlotStyle.STACKED_AREA?c.stackgroup="stack":t===R.plot.SeriesPlotStyle.STEP?c.line.shape="hv":t===R.plot.SeriesPlotStyle.HISTOGRAM?(c.width=[],c.marker.line!==void 0&&Object.assign(c.marker.line,{color:n.paper_bgcolor,width:1})):t===R.plot.SeriesPlotStyle.OHLC?(c.increasing={line:{color:n.ohlc_increasing}},c.decreasing={line:{color:n.ohlc_decreasing}}):t===R.plot.SeriesPlotStyle.PIE?(c.textinfo="label+percent",c.outsidetextfont={color:n.title_color}):t===R.plot.SeriesPlotStyle.TREEMAP&&(c.hoverinfo="text",c.textinfo="label+text",c.tiling={packing:"squarify",pad:0},c.textposition="middle center",c.outsidetextfont={color:n.title_color}),s!=null&&(t===R.plot.SeriesPlotStyle.BAR?c.marker.color=s:c.line.color=s),i!=null&&(c.marker.color=i),o!=null&&o.length>0)try{c.marker.symbol=se.getMarkerSymbol(o)}catch(h){ro.warn("Unable to handle shape",o,":",h)}a!=null&&(c.marker.size=a*se.DEFAULT_MARKER_SIZE),r!=null&&t!==R.plot.SeriesPlotStyle.PIE&&(c.visible=r)}static getMarkerSymbol(e){switch(e){case"SQUARE":return"square";case"CIRCLE":return"circle";case"DIAMOND":return"diamond";case"UP_TRIANGLE":return"triangle-up";case"DOWN_TRIANGLE":return"triangle-down";case"RIGHT_TRIANGLE":return"triangle-right";case"LEFT_TRIANGLE":return"triangle-left";case"ELLIPSE":case"HORIZONTAL_RECTANGLE":case"VERTICAL_RECTANGLE":default:throw new Error(`Unrecognized shape ${e}`)}}static getAxisFormats(e,t){const n=new Map,s={tickformat:null,ticksuffix:null},i=se.getAllAxes(e),o=se.groupArray(i,"type"),{charts:a}=e;for(let r=0;r<a.length;r+=1){const c=a[r];for(let h=0;h<c.series.length;h+=1){const u=c.series[h],{sources:m}=u,g=m.filter(p=>p.axis);for(let p=0;p<g.length;p+=1){const C=g[p],{axis:f}=C,{type:S}=f,v=o.get(S);M(v);const w=v.indexOf(f),T=se.getAxisPropertyName(S);if(T!=null){const y=se.getAxisLayoutProperty(T,w);if(n.has(y))ro.debug(`${y} already added.`);else{ro.debug(`Adding ${y} to axisFormats.`);const E=se.getPlotlyAxisFormat(C,t);if(E===null)n.set(y,s);else{n.set(y,E);const{businessCalendar:D}=f;if(D!=null){const F=[],{businessPeriods:N,businessDays:_,holidays:P,timeZone:U}=D,O=t?.getColumnTypeFormatter(bd);let j;wd(O)&&(j=O.dhTimeZone);const k=j?(U.standardOffset-j.standardOffset)/60:0;P.length>0&&F.push(...se.createRangeBreakValuesFromHolidays(P,U,j)),N.forEach(A=>F.push({pattern:"hour",bounds:[se.periodToDecimal(A.close)+k,se.periodToDecimal(A.open)+k]})),_.length<hs.length&&se.createBoundsFromDays(_).forEach(A=>F.push({pattern:"day of week",bounds:A})),E.rangebreaks=F}if(n.size===c.axes.length)return n}}}}}}return n}static getChartType(e,t){switch(e){case R.plot.SeriesPlotStyle.HISTOGRAM:return"bar";default:return se.getPlotlyChartType(e,t)}}static getAxisPropertyName(e){switch(e){case R.plot.AxisType.X:return"x";case R.plot.AxisType.Y:return"y";default:return null}}static getAxisSide(e){switch(e){case R.plot.AxisPosition.BOTTOM:return"bottom";case R.plot.AxisPosition.TOP:return"top";case R.plot.AxisPosition.LEFT:return"left";case R.plot.AxisPosition.RIGHT:return"right";default:return}}static getAllAxes(e){return e.charts.reduce((t,n)=>[...t,...n.axes],[])}static getChartForSeries(e,t){const{charts:n}=e;for(let s=0;s<n.length;s+=1){const i=n[s];for(let o=0;o<i.series.length;o+=1)if(t===i.series[o])return i}return null}static getLayoutRanges(e){const t={},n=Object.keys(e).filter(s=>s.indexOf("axis")>=0);for(let s=0;s<n.length;s+=1){const i=n[s],o=e[i];BS(o)&&(t[i]=[...o.range])}return t}static updateFigureAxes(e,t,n,s=0,i=0,o=jt){const a=e,r=se.getAllAxes(t);for(let c=0;c<t.charts.length;c+=1){const h=t.charts[c],u=n?.(h),m=se.getChartBounds(t,h,s,i);se.updateLayoutAxes(a,h.axes,r,s,i,m,u,o)}se.removeStaleAxes(a,r)}static getChartBounds(e,t,n,s){const{cols:i,rows:o}=e,{column:a,colspan:r,row:c,rowspan:h}=t,u=a+r,m=c+h,g=1/i,p=1/o,C=se.AXIS_SIZE_PX/n,f=se.AXIS_SIZE_PX/s,S={bottom:(o-m)*p+(m<o?f/2:0),top:(o-c)*p-(c>0?f/2:0),left:a*g+(a>0?C/2:0),right:u*g-(u<i?C/2:0)};return(se.groupArray(t.axes,"position").get(R.plot.AxisPosition.RIGHT)??[]).length>0&&(n>0?S.right-=(S.right-S.left)*Math.max(0,Math.min(se.LEGEND_WIDTH_PX/n,se.MAX_LEGEND_SIZE)):S.right-=(S.right-S.left)*se.DEFAULT_AXIS_SIZE),S}static updateLayoutAxes(e,t,n,s=0,i=0,o={left:0,top:0,right:1,bottom:1},a,r=jt){const c=s>0?Math.max(se.MIN_AXIS_SIZE,Math.min(se.AXIS_SIZE_PX/i,se.MAX_AXIS_SIZE)):se.DEFAULT_AXIS_SIZE,h=i>0?Math.max(se.MIN_AXIS_SIZE,Math.min(se.AXIS_SIZE_PX/s,se.MAX_AXIS_SIZE)):se.DEFAULT_AXIS_SIZE,u=e,m=se.groupArray(t,"position"),g=se.groupArray(t,"type"),p=[...g.keys()],C=se.groupArray(n,"type");for(let f=0;f<p.length;f+=1){const S=p[f],v=se.getAxisPropertyName(S);if(v!=null){const w=g.get(S),T=C.get(S),E=S===R.plot.AxisType.Y?i:s;M(w),M(T);for(let D=0;D<w.length;D+=1){const F=w[D],N=T.indexOf(F),_=se.getAxisLayoutProperty(v,N);u[_]==null&&(u[_]=se.makeLayoutAxis(S,r));const P=u[_];if(P!=null){se.updateLayoutAxis(P,F,D,m,c,h,o);const{range:U,autorange:O}=P;if(a!=null&&U!==void 0&&(O===void 0||O===!1)){const j=a(F),[k,A]=j(U);ro.debug("Setting downsample range",E,k,A),F.range(E,k,A)}else F.range(E)}}}}}static removeStaleAxes(e,t){const n=e,s=se.groupArray(t,"type"),i=[...s.keys()];for(let o=0;o<i.length;o+=1){const a=i[o],r=s.get(a);M(r);let c=r.length;const h=se.getAxisPropertyName(a);if(h!=null){let u=se.getAxisLayoutProperty(h,c);for(;n[u]!=null;)delete n[u],c+=1,u=se.getAxisLayoutProperty(h,c)}}}static getAxisLayoutProperty(e,t){const n=t>0?`${t+1}`:"";return`${e??""}axis${n}`}static updateLayoutAxis(e,t,n,s,i,o,a){const c=t.type===R.plot.AxisType.Y?o:i,h=e,u=t.label??"";if(h.title!==void 0&&typeof h.title!="string"?h.title.text=u:h.title={text:u},t.log&&(h.type="log"),h.side=se.getAxisSide(t.position),n>0){h.overlaying=se.getAxisPropertyName(t.type)??void 0;const m=s.get(t.position)??[],g=m.indexOf(t);g>0&&(h.anchor="free",t.position===R.plot.AxisPosition.RIGHT?h.position=a.right+(g-m.length+1)*c:t.position===R.plot.AxisPosition.TOP?h.position=a.top+(g-m.length+1)*c:t.position===R.plot.AxisPosition.BOTTOM?h.position=a.bottom+(m.length-g+1)*c:t.position===R.plot.AxisPosition.LEFT&&(h.position=a.left+(m.length-g+1)*c))}else if(t.type===R.plot.AxisType.X){const m=s.get(R.plot.AxisPosition.LEFT)||[],g=s.get(R.plot.AxisPosition.RIGHT)||[],p=Math.max(a.left,a.left+(m.length-1)*o),C=Math.min(a.right-(g.length-1)*o,a.right);h.domain=[p,C]}else if(t.type===R.plot.AxisType.Y){const m=s.get(R.plot.AxisPosition.BOTTOM)||[],g=s.get(R.plot.AxisPosition.TOP)||[],p=Math.max(a.bottom,a.bottom+(m.length-1)*i),C=Math.min(a.top-(g.length-1)*i,a.top);h.domain=[p,C]}}static periodToDecimal(e){const t=e.split(":");return Number(t[0])+Number(t[1])/60}static createBoundsFromDays(e){const t=e.map(o=>hs.indexOf(o)),n=hs.filter(o=>!e.includes(o)).map(o=>hs.indexOf(o)),s=new Set;n.forEach(o=>{for(let a=o+1;a<o+hs.length;a+=1){const r=a%hs.length;if(t.includes(r)){s.add(r);break}}});const i=[];return s.forEach(o=>{for(let a=o-1;a>o-hs.length;a-=1){const r=a<0?a+hs.length:a;if(t.includes(r)){const c=(r+1)%7;i.push([c,o]);break}}}),i}static createRangeBreakValuesFromHolidays(e,t,n){const s=[],i=[];return e.forEach(o=>{o.businessPeriods.length>0?i.push(...se.createPartialHoliday(o,t,n)):s.push(se.createFullHoliday(o,t,n))}),[{values:s},...i]}static createFullHoliday(e,t,n){return se.adjustDateForTimeZone(`${e.date.toString()} 00:00:00.000000`,t,n)}static createPartialHoliday(e,t,n){const s=e.date.toString(),i=["00:00"];e.businessPeriods.forEach(a=>{i.push(a.open),i.push(a.close)}),i.push("24:00");const o=[];for(let a=0;a<i.length;a+=2){const r=i[a],c=i[a+1];if(r!==c){const h=[se.adjustDateForTimeZone(`${s} ${r}:00.000000`,t,n)],u=_S*(se.periodToDecimal(c)-se.periodToDecimal(r));o.push({values:h,dvalue:u})}}return o}static adjustDateForTimeZone(e,t,n){return n&&n.standardOffset!==t.standardOffset?se.unwrapValue(se.wrapValue(e,bd,t),n):e}static groupArray(e,t){return e.reduce((n,s)=>{const i=s[t],o=n.get(i)??[];return o.push(s),n.set(i,o),n},new Map)}static unwrapValue(e,t){if(e!=null){if(HS(e))return R.i18n.DateTimeFormat.format(se.DATE_FORMAT,e,t);if(VS(e))return e.asNumber()}return e}static wrapValue(e,t,n=null){if(x.isDateType(t)&&typeof e=="string"){const s=e,i=se.DATE_FORMAT.substr(0,e.length),o=R.i18n.DateTimeFormat.parse(i,s);if(!n)return o;const a=`${i} Z`,r=R.i18n.DateTimeFormat.format("Z",o,n),c=R.i18n.DateTimeFormat.parse(a,`${s} ${r}`),h=R.i18n.DateTimeFormat.format("Z",c,n);return R.i18n.DateTimeFormat.parse(a,`${s} ${h}`)}return e}static makeLayoutAxis(e,t=jt){const n={automargin:!0,gridcolor:t.gridcolor,linecolor:t.linecolor,rangeslider:{visible:!1},showline:!0,ticklen:5,tickcolor:t.paper_bgcolor,tickfont:{color:t.zerolinecolor},title:{font:{color:t.title_color}}};return e===R.plot.AxisType.X?Object.assign(n,{showgrid:!0}):e===R.plot.AxisType.Y&&Object.assign(n,{zerolinecolor:t.zerolinecolor,zerolinewidth:2}),n}static getColorwayFromTheme(e=jt){let t=[];return e.colorway&&(Array.isArray(e.colorway)?t=e.colorway:typeof e.colorway=="string"?t=e.colorway.split(" "):ro.warn(`Unable to handle colorway property: ${e.colorway}`)),t}static makeDefaultLayout(e=jt){const t={...e,autosize:!0,colorway:se.getColorwayFromTheme(e),font:{family:"'Fira Sans', sans-serif"},title:{font:{color:e.title_color},yanchor:"top",pad:{...se.DEFAULT_TITLE_PADDING},y:1},legend:{font:{color:e.title_color}},margin:{...se.DEFAULT_MARGIN},xaxis:se.makeLayoutAxis(R.plot.AxisType.X,e),yaxis:se.makeLayoutAxis(R.plot.AxisType.Y,e)};return t.datarevision=0,t}static hydrateSettings(e){return{...e,type:e.type!=null?R.plot.SeriesPlotStyle[e.type]:void 0}}static titleFromSettings(e){const{series:t,xAxis:n,title:s=`${(t??[]).join(", ")} by ${n}`}=e;return s}static makeFigureSettings(e,t){const{series:n,xAxis:s,type:i}=e,o=se.titleFromSettings(e),a={formatType:`${R.plot.AxisFormatType.NUMBER}`,type:`${R.plot.AxisType.X}`,position:`${R.plot.AxisPosition.BOTTOM}`},r={formatType:`${R.plot.AxisFormatType.NUMBER}`,type:`${R.plot.AxisType.Y}`,position:`${R.plot.AxisPosition.LEFT}`};return{charts:[{chartType:`${R.plot.ChartType.XY}`,axes:[a,r],series:(n??[]).map(c=>({plotStyle:`${i}`,name:c,dataSources:[{type:`${R.plot.SourceType.X}`,columnName:s??"",axis:a,table:t},{type:`${R.plot.SourceType.Y}`,columnName:c,axis:r,table:t}]}))}],title:o}}}const Je=se;const us=Z.module("Chart");class Di extends b.Component{static defaultProps={isActive:!0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:et.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,formatter:[]},onDisconnect:()=>{},onReconnect:()=>{},onUpdate:()=>{},onError:()=>{},onSettingsChanged:()=>{}};static convertIcon(e){const[t,,,,n]=e.icon,s=`${n}`;return{width:t,path:s,ascent:t,descent:0,transform:"matrix(1, 0, 0, 1, 0, 0)"}}static downsampleButtonTitle(e,t){return e?"Downsampling in progress...":t?"Downsampling disabled, click to enable":"Downsampling enabled, click to disable"}static downsampleButtonAttr(e,t){return e?"animation-spin":t?void 0:"fill-active"}constructor(e){super(e),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=J.createRef(),this.plotWrapper=J.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}}componentDidMount(){this.updateDimensions(),this.updateModelDimensions(),this.initData(),this.initFormatter();const{isActive:e}=this.props;e&&this.subscribe()}componentDidUpdate(e){const{isActive:t,settings:n}=this.props;this.updateFormatterSettings(n),t!==e.isActive&&(t?this.subscribe():this.unsubscribe())}componentWillUnmount(){this.unsubscribe()}currentSeries;plot;plotWrapper;columnFormats;dateTimeFormatterOptions;decimalFormatOptions;integerFormatOptions;rect;ranges;isSubscribed;isLoadedFired;getCachedConfig=fe((e,t,n,s)=>{const i=[],o=Boolean(e);if(o&&i.push({name:`Downsampling failed: ${e}`,click:()=>{},icon:Di.convertIcon(Oh),attr:"fill-warning"}),t||n||s||o){const a=Di.downsampleButtonTitle(n,s),r=Di.downsampleButtonAttr(n,s),c=n?jg:Hg;i.push({name:a,icon:Di.convertIcon(c),click:this.handleDownsampleClick,attr:r})}return{displaylogo:!1,displayModeBar:n||o?!0:"hover",modeBarButtons:[i,["toImage"],["zoom2d","pan2d"],["zoomIn2d","zoomOut2d","autoScale2d","resetScale2d"]]}});getPlotRect(){return this.plotWrapper.current?.getBoundingClientRect()??null}initData(){const{model:e}=this.props,{layout:t}=this.state;this.setState({data:e.getData(),layout:{...t,...e.getLayout()}})}subscribe(){if(this.isSubscribed)return;const{model:e}=this.props;if(!this.rect||this.rect.width===0||this.rect.height===0){us.debug2("Delaying subscription until model dimensions are set");return}e.subscribe(this.handleModelEvent),this.isSubscribed=!0}unsubscribe(){if(!this.isSubscribed)return;const{model:e}=this.props;e.unsubscribe(this.handleModelEvent),this.isSubscribed=!1}handleAfterPlot(){this.plot.current!=null}handleDownsampleClick(){this.setState(({isDownsamplingDisabled:e})=>({downsamplingError:null,isDownsampleInProgress:!1,isDownsampleFinished:!1,isDownsamplingDisabled:!e}),()=>{const{model:e}=this.props,{isDownsamplingDisabled:t}=this.state;e.setDownsamplingDisabled(t)})}handleModelEvent(e){const{type:t,detail:n}=e;switch(us.debug2("Received data update",t,n),t){case Kn.EVENT_UPDATED:{this.currentSeries+=1,this.setState(i=>{const{layout:o,revision:a}=i;return typeof o.datarevision=="number"&&(o.datarevision+=1),{data:n,layout:o,revision:a+1}});const{onUpdate:s}=this.props;s({isLoading:!this.isLoadedFired});break}case Kn.EVENT_LOADFINISHED:{const{onUpdate:s}=this.props;this.isLoadedFired=!0,s({isLoading:!1});break}case Kn.EVENT_DISCONNECT:{const{onDisconnect:s}=this.props;s();break}case Kn.EVENT_RECONNECT:{const{onReconnect:s}=this.props;s();break}case Kn.EVENT_DOWNSAMPLESTARTED:{this.setState({isDownsampleFinished:!1,isDownsampleInProgress:!0,downsamplingError:null});break}case Kn.EVENT_DOWNSAMPLEFINISHED:{this.setState({isDownsampleFinished:!0,isDownsampleInProgress:!1,downsamplingError:null});break}case Kn.EVENT_DOWNSAMPLENEEDED:case Kn.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:us.debug("Unknown event type",t,e)}}handlePlotUpdate(e){const{layout:t}=e,n=Je.getLayoutRanges(t);!it(n,this.ranges)&&(this.ranges=n,this.updateModelDimensions(!0))}handleRelayout(e){if(us.debug("handleRelayout",e),e.hiddenlabels!=null){const{onSettingsChanged:t}=this.props,n=[...e.hiddenlabels];t({hiddenSeries:n})}this.updateModelDimensions()}handleRestyle([e,t]){if(us.debug("handleRestyle",e,t),Object.keys(e).includes("visible")){const{data:n}=this.state,{onSettingsChanged:s}=this.props;if(n!=null){const i=n.reduce((o,{name:a,visible:r})=>a!=null&&r==="legendonly"?[...o,a]:o,[]);s({hiddenSeries:i})}}}updateModelDimensions(e=!1){const t=this.getPlotRect();if(!t){us.warn("Unable to get plotting rect");return}if(!this.rect||this.rect.width!==t.width||this.rect.height!==t.height||e){this.rect=t;const{isActive:s,model:i}=this.props;i.setDimensions(t),s&&this.subscribe()}}initFormatter(){const{settings:e}=this.props;this.updateFormatterSettings(e)}updateFormatterSettings(e){const t=ns.getColumnFormats(e),n=ns.getDateTimeFormatterOptions(e),{decimalFormatOptions:s={},integerFormatOptions:i={}}=e;(!it(this.columnFormats,t)||!it(this.dateTimeFormatterOptions,n)||!it(this.decimalFormatOptions,s)||!it(this.integerFormatOptions,i))&&(this.columnFormats=ns.getColumnFormats(e),this.dateTimeFormatterOptions=n,this.decimalFormatOptions=s,this.integerFormatOptions=i,this.updateFormatter())}updateFormatter(){const e=new Qt(this.columnFormats,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions),{model:t}=this.props;t.setFormatter(e)}updateDimensions(){const e=this.getPlotRect();this.plot.current!=null&&e!=null&&e.width>0&&e.height>0&&Ma.relayout(this.plot.current.el,{autosize:!0}).catch(t=>{us.debug("Unable to resize, promise rejected",t)})}render(){const{data:e,downsamplingError:t,isDownsampleFinished:n,isDownsampleInProgress:s,isDownsamplingDisabled:i,layout:o,revision:a}=this.state,r=this.getCachedConfig(t,n,s,i),c=e!=null;return l.jsx("div",{className:"h-100 w-100 chart-wrapper",ref:this.plotWrapper,children:c&&l.jsx(au,{ref:this.plot,data:e,layout:o,revision:a,config:r,onAfterPlot:this.handleAfterPlot,onError:us.error,onRelayout:this.handleRelayout,onUpdate:this.handlePlotUpdate,onRestyle:this.handleRestyle,useResizeHandler:!0,style:{height:"100%",width:"100%"}})})}}const US=Di,Dt=Z.module("FigureChartModel");class Yl extends Kn{static ADD_SERIES_DEBOUNCE=50;constructor(e,t={},n=jt){super(),this.handleFigureUpdated=this.handleFigureUpdated.bind(this),this.handleFigureDisconnected=this.handleFigureDisconnected.bind(this),this.handleFigureReconnected=this.handleFigureReconnected.bind(this),this.handleFigureSeriesAdded=this.handleFigureSeriesAdded.bind(this),this.handleDownsampleStart=this.handleDownsampleStart.bind(this),this.handleDownsampleFinish=this.handleDownsampleFinish.bind(this),this.handleDownsampleFail=this.handleDownsampleFail.bind(this),this.handleDownsampleNeeded=this.handleDownsampleNeeded.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.figure=e,this.settings=t,this.theme=n,this.data=[];const s={data:{},layout:Je.makeDefaultLayout(n)};this.layout={grid:{rows:e.rows,columns:e.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()}figure;settings;theme;data;layout;seriesDataMap;pendingSeries;oneClicks;filterColumnMap;lastFilter;isConnected;seriesToProcess;close(){this.figure.close(),this.addPendingSeries.cancel(),this.stopListeningFigure()}getDefaultTitle(){return this.figure.charts.length>0?this.figure.charts[0].title:""}initAllSeries(){this.oneClicks=[],this.filterColumnMap.clear();const{charts:e}=this.figure,t=Je.getAllAxes(this.figure),n=[];for(let o=0;o<e.length;o+=1){const a=e[o];for(let r=0;r<a.series.length;r+=1){const c=a.series[r];n.push(c.name),this.addSeries(c,t,a.showLegend)}}const i=[...this.seriesDataMap.keys()].filter(o=>n.indexOf(o)<0);for(let o=0;o<i.length;o+=1){const a=i[o];this.seriesDataMap.delete(a)}this.seriesToProcess=new Set([...this.seriesDataMap.keys()])}addSeries(e,t,n){const s=Je.groupArray(t,"type"),i=Je.makeSeriesDataFromSeries(e,s,Je.getSeriesVisibility(e.name,this.settings),n,this.theme);if(this.seriesDataMap.set(e.name,i),this.data=[...this.seriesDataMap.values()],e.plotStyle===R.plot.SeriesPlotStyle.STACKED_BAR?this.layout.barmode="stack":e.plotStyle===R.plot.SeriesPlotStyle.PIE&&(this.layout.hiddenlabels=Je.getHiddenLabels(this.settings)),this.layout.showlegend=this.data.length>1||e.plotStyle===R.plot.SeriesPlotStyle.PIE?n??void 0:!1,e.oneClick!=null){const{oneClick:o}=e,{columns:a}=o;for(let r=0;r<a.length;r+=1)this.filterColumnMap.set(a[r].name,a[r]);this.oneClicks.push(o)}this.updateLayoutFormats()}addPendingSeries=Ye(()=>{const e=Je.getAllAxes(this.figure),{pendingSeries:t}=this;for(let n=0;n<t.length;n+=1){const s=t[n],i=this.figure.charts.find(o=>o.series.includes(s));this.addSeries(s,e,i?.showLegend??null),s.subscribe()}this.pendingSeries=[]},Yl.ADD_SERIES_DEBOUNCE);subscribe(e){super.subscribe(e),this.listeners.length===1&&(this.initAllSeries(),this.subscribeFigure())}unsubscribe(e){super.unsubscribe(e),this.listeners.length===0&&this.unsubscribeFigure()}subscribeFigure(){if(!this.isConnected){Dt.debug("Ignoring subscribe when figure in disconnected state");return}this.figure.subscribe(this.isDownsamplingDisabled?R.plot.DownsampleOptions.DISABLE:R.plot.DownsampleOptions.DEFAULT)}unsubscribeFigure(){this.figure.unsubscribe()}startListeningFigure(){this.figure.addEventListener(R.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.addEventListener(R.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.addEventListener(R.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.addEventListener(R.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.addEventListener(R.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.addEventListener(R.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.addEventListener(R.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.addEventListener(R.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.addEventListener(R.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}stopListeningFigure(){this.figure.removeEventListener(R.plot.Figure.EVENT_UPDATED,this.handleFigureUpdated),this.figure.removeEventListener(R.plot.Figure.EVENT_SERIES_ADDED,this.handleFigureSeriesAdded),this.figure.removeEventListener(R.plot.Figure.EVENT_DISCONNECT,this.handleFigureDisconnected),this.figure.removeEventListener(R.plot.Figure.EVENT_RECONNECT,this.handleFigureReconnected),this.figure.removeEventListener(R.plot.Figure.EVENT_DOWNSAMPLESTARTED,this.handleDownsampleStart),this.figure.removeEventListener(R.plot.Figure.EVENT_DOWNSAMPLEFINISHED,this.handleDownsampleFinish),this.figure.removeEventListener(R.plot.Figure.EVENT_DOWNSAMPLEFAILED,this.handleDownsampleFail),this.figure.removeEventListener(R.plot.Figure.EVENT_DOWNSAMPLENEEDED,this.handleDownsampleNeeded),this.figure.removeEventListener(R.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed)}getTimeZone=ge((e,t)=>{if(t!=null){const n=t.getColumnTypeFormatter(e);if(n!=null)return n.dhTimeZone}});getValueTranslator=ge((e,t)=>{const n=this.getTimeZone(e,t);return s=>Je.unwrapValue(s,n)});getValueParser=ge((e,t)=>{const n=this.getTimeZone(e,t);return s=>Je.wrapValue(s,e,n)});getRangeParser=ge((e,t)=>n=>{let[s,i]=n;const o=this.getValueParser(e,t);return s=o(s),i=o(i),[s,i]});getAxisRangeParser=ge((e,t)=>n=>{const s=Je.getSourceForAxis(e,n);return s?this.getRangeParser(s.columnType,t):i=>i});handleDownsampleStart(e){Dt.debug("Downsample started",e),this.fireDownsampleStart(e.detail)}handleDownsampleFinish(e){Dt.debug("Downsample finished",e),this.fireDownsampleFinish(e.detail)}handleDownsampleFail(e){Dt.error("Downsample failed",e),this.fireDownsampleFail(e.detail)}handleDownsampleNeeded(e){Dt.info("Downsample needed",e),this.fireDownsampleNeeded(e.detail)}handleFigureUpdated(e){const{detail:t}=e,{series:n}=t;Dt.debug2("handleFigureUpdated",n);for(let i=0;i<n.length;i+=1){const o=n[i];Dt.debug2("handleFigureUpdated updating series",o.name);const{sources:a}=o;for(let r=0;r<a.length;r+=1){const c=a[r],{columnType:h,type:u}=c,m=this.getValueTranslator(h,this.formatter),g=t.getArray(o,u,m);this.setDataArrayForSeries(o,u,g)}this.seriesToProcess.delete(o.name),this.seriesToProcess.size===0&&this.fireLoadFinished(),this.cleanSeries(o)}const{data:s}=this;this.fireUpdate(s)}handleRequestFailed(e){Dt.error("Request failed",e)}resubscribe(){this.listeners.length>0&&(this.unsubscribeFigure(),this.subscribeFigure())}setFormatter(e){super.setFormatter(e),this.updateLayoutFormats(),this.resubscribe()}setDownsamplingDisabled(e){super.setDownsamplingDisabled(e),this.resubscribe()}handleFigureDisconnected(e){Dt.debug("Figure disconnected",e),this.isConnected=!1,this.listeners.length>0&&this.unsubscribeFigure(),this.fireDisconnect()}handleFigureReconnected(e){Dt.debug("Figure reconnected",e),this.isConnected=!0,this.initAllSeries(),this.fireReconnect(),this.listeners.length>0&&this.subscribeFigure()}handleFigureSeriesAdded(e){const{detail:t}=e;Dt.debug("handleFigureSeriesAdded",t),this.pendingSeries.push(t),this.addPendingSeries()}setDimensions(e){super.setDimensions(e),this.updateAxisPositions()}setTitle(e){super.setTitle(e);const t=(e??"").match(/<br>/g)?.length??0,n=Je.DEFAULT_MARGIN.t+t*Je.SUBTITLE_LINE_HEIGHT;this.layout.margin?this.layout.margin.t=n:this.layout.margin={t:n},typeof this.layout.title=="string"?this.layout.title=e:(this.layout.title={...this.layout.title},this.layout.title.text=e,this.layout.title.pad={...this.layout.title.pad},this.layout.title.pad.t=Je.DEFAULT_TITLE_PADDING.t+t*Je.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 e=this.getPlotWidth(),t=this.getPlotHeight();Je.updateFigureAxes(this.layout,this.figure,n=>this.getAxisRangeParser(n,this.formatter),e,t,this.theme)}updateLayoutFormats(){if(!this.formatter)return;Je.getAxisFormats(this.figure,this.formatter).forEach((t,n)=>{Dt.debug(`Assigning ${n}`,this.layout[n],t);const s=this.layout[n];s!=null?Object.assign(s,t):Dt.debug(`Ignoring null layout.${n}`)})}setDataArrayForSeries(e,t,n){const{name:s,plotStyle:i}=e,o=this.seriesDataMap.get(s),a=Je.getPlotlyProperty(i,t);o&&Th(o,a,n)}cleanSeries(e){const{name:t,plotStyle:n}=e,s=this.seriesDataMap.get(t);if(s!=null){if(n===R.plot.SeriesPlotStyle.HISTOGRAM){const{xLow:i,xHigh:o}=s;if(i&&o&&i.length===o.length){const a=[];for(let r=0;r<i.length;r+=1)a.push(o[r]-i[r]);s.width=a}}else if(n===R.plot.SeriesPlotStyle.LINE){const{x:i,xLow:o,xHigh:a,y:r,yLow:c,yHigh:h}=s;o&&a&&o!==i&&(s.error_x=Je.getPlotlyErrorBars(i,o,a)),c&&h&&c!==r&&(s.error_y=Je.getPlotlyErrorBars(r,c,h))}else if(n===R.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(e=>e.requireAllFiltersToDisplay)!=null}setFilter(e){if(this.oneClicks.length===0){Dt.warn("Trying to set a filter, but no one click!");return}Dt.debug("setFilter",e);for(let t=0;t<this.oneClicks.length;t+=1){const n=this.oneClicks[t],{columns:s}=n;new Set([...e.keys(),...this.lastFilter.keys()]).forEach(o=>{const a=e.get(o);this.lastFilter.get(o)!==a&&s.find(r=>r.name===o)!=null&&n.setValueForColumn(o,a)})}this.lastFilter=new Map(e)}setFigure(e){this.close(),this.figure=e,this.setTitle(this.getDefaultTitle()),this.initAllSeries(),this.updateAxisPositions(),this.startListeningFigure(),this.listeners.length>0&&this.subscribeFigure()}updateSettings(e){this.settings=e}}const vd=Yl;class Xl{static async makeModelFromSettings(e,t,n=jt){const s=await Xl.makeFigureFromSettings(e,t);return new vd(s,e,n)}static async makeFigureFromSettings(e,t){const n=await t.copy();return n.applyCustomColumns(t.customColumns),n.applyFilter(t.filter),n.applySort(t.sort),R.plot.Figure.create(Je.makeFigureSettings(e,n))}static async makeModel(e,t,n=jt){return new vd(t,e,n)}}const ja=Xl;function Td(d){return d.setFigure!==void 0}const $S=Z.module("HeapUsage");function WS({connection:d,defaultUpdateInterval:e,hoverUpdateInterval:t,bgMonitoring:n=!0,monitorDuration:s}){const[i,o]=b.useState({freeMemory:0,maximumHeapSize:999,totalHeapSize:0}),[a,r]=b.useState(!1),c=b.useRef({timestamps:[],usages:[]});b.useEffect(function(){const P=async()=>{try{const O=await d.getWorkerHeapInfo();if(o(O),n||a){const j=(O.totalHeapSize-O.freeMemory)/O.maximumHeapSize,k=Date.now(),{timestamps:A,usages:H}=c.current;for(;A.length!==0&&k-A[0]>s*1.5;)A.shift(),H.shift();A.push(k),H.push(j)}else c.current={timestamps:[],usages:[]}}catch(O){$S.warn("Unable to get heap usage",O)}};P();const U=setInterval(P,a?t:e);return()=>{clearInterval(U)}},[a,t,d,e,s,n]);const h=(_,P)=>Math.round(_*10**P)/10**P,u=2,m=1024**3,{freeMemory:g,totalHeapSize:p,maximumHeapSize:C}=i,f=h(g/m,u),S=h(p/m,u),v=h(C/m,u),w=S-f,T=(_,P,U=!1)=>l.jsxs("div",{className:$("heap-usage-info-row",{"heading-bottom-border":U}),children:[l.jsx("div",{className:"font-weight-bold",children:_}),l.jsx("div",{children:P})]}),{timestamps:y,usages:E}=c.current,D=y[y.length-1]??0,F=p/C,N=(p-g)/C;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"max-memory",children:[l.jsx("div",{className:"total-memory",style:{width:`calc(${F*100}% - ${F*2}px`}}),l.jsx("div",{className:$("used-memory",{"heap-overflow":(p-g)/C>.95}),style:{width:`calc(${N*100}% - ${N*2}px`}}),l.jsxs("div",{className:"memory-text",children:[v.toFixed(1)," GB"]})]}),l.jsx(tt,{onEntered:()=>r(!0),onExited:()=>r(!1),interactive:!0,children:l.jsxs("div",{className:"heap-tooltip",children:[T("In use:",`${w.toFixed(u)} of ${v.toFixed(u)} GB`,!0),T("Free:",`${f.toFixed(u)} GB`),T("Total:",`${S.toFixed(u)} GB`),T("Max:",`${v.toFixed(u)} GB`),l.jsx("div",{className:"heap-plot",children:l.jsx(au,{data:[{x:[...y],y:[...E],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(s/6),gridcolor:jt.linecolor,range:[D-s,D],linecolor:jt.linecolor,linewidth:2,mirror:!0},yaxis:{dtick:.2,gridcolor:jt.linecolor,range:[0,1],linecolor:jt.linecolor,linewidth:2,mirror:!0}}})}),l.jsxs("div",{className:"heap-utilisation-text",children:["% utilization over ",Math.round(s/1e3/60)," min."]})]})})]})}const Zl=Object.freeze({}),GS=new Map,ru=d=>d.user,Ql=d=>d.storage,lu=d=>Ql(d).commandHistoryStorage,cu=d=>Ql(d).fileStorage,zS=d=>Ql(d).workspaceStorage,mr=d=>d.workspace,St=d=>mr(d).data.settings,du=d=>St(d).defaultDateTimeFormat,hu=d=>St(d).defaultDecimalFormatOptions??Zl,uu=d=>St(d).defaultIntegerFormatOptions??Zl,mu=d=>St(d).formatter,Lo=d=>St(d).timeZone,gu=d=>St(d).showTimeZone,pu=d=>St(d).showTSeparator,fu=d=>St(d).truncateNumbersWithPound,KS=d=>St(d).shortcutOverrides,qS=d=>St(d).defaultNotebookSettings??Zl,gr=d=>d.activeTool,YS=d=>d.plugins??GS,Cu="SET_ACTIVE_TOOL",Su="SET_COMMAND_HISTORY_STORAGE",bu="SET_FILE_STORAGE",wu="SET_PLUGINS",vu="SET_USER",Tu="SET_WORKSPACE",Eu="SET_WORKSPACE_STORAGE",yu="SET_SERVER_CONFIG_VALUES",XS=d=>({type:vu,payload:d}),Ru=d=>({type:Tu,payload:d}),ZS=d=>({type:Eu,payload:d}),QS=d=>({type:Su,payload:d}),JS=d=>({type:bu,payload:d}),eb=d=>(e,t)=>{e(Ru(d));const{storage:n}=t(),{workspaceStorage:s}=n;return s.save(d)},xu=d=>(e,t)=>{const{workspace:n}=t(),{data:s}=n,i={...n,data:{...s,...d}};return e(eb(i))},pr=d=>e=>e(xu({settings:d})),fr=d=>({type:Cu,payload:d}),tb=d=>({type:wu,payload:d}),nb=d=>({type:yu,payload:d});function Iu(d,e){return(t=e,n)=>{switch(n.type){case d:{const s=n.payload;return s==null?null:t!=null?{...t,...s}:{...s}}default:return t}}}function sb(d,e={},t=!0){return(n=e,s)=>{switch(s.type){case d:{const{id:i,payload:o}=s;return t&&it({payload:o},{payload:n[i]})?n:{...n,[i]:o}}default:return n}}}function js(d,e){return(t=e,n)=>{switch(n.type){case d:return n.payload;default:return t}}}const ib=js(Cu,null),ob=js(wu,null),ab=js(Su,null),rb=js(bu,null),lb=js(Eu,null),cb=Il({commandHistoryStorage:ab,fileStorage:rb,workspaceStorage:lb}),db=Iu(vu,null),hb=Iu(Tu,null),ub=js(yu,null),mb={activeTool:ib,plugins:ob,storage:cb,user:db,workspace:hb,serverConfigValues:ub};class gb{reducers={};listener=null;register(e,t){this.reducers={...this.reducers,[e]:t},this.listener?.(this.reducers)}setListener(e){this.listener=e}}const Zi=new gb,Ed=Z.module("redux-logger"),pb=d=>e=>t=>{Ed.debug("dispatching",t);const n=e(t);return Ed.debug("next state",d.getState()),n},fb=Z.module("redux-crashReporter"),Cb=d=>e=>t=>{try{return e(t)}catch(n){throw fb.error("Error executing",t," with state ",d.getState(),":",n),n}},Sb=[pb,Cb,Wm];Object.entries(mb).map(([d,e])=>Zi.register(d,e));const bb=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__??Km,Cr=Gm(Il(Zi.reducers),bb(zm(...Sb)));Zi.setListener(d=>{Cr.replaceReducer(Il(d))});const Du=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 Fu(d){return d.componentName!==void 0}function wb(d){return d.component!==void 0}const Nu=Object.freeze({type:"default",isClosable:!0,isFocusOnShow:!0,reorderEnabled:!0,title:""}),vb=Object.freeze(Object.defineProperty({__proto__:null,defaultConfig:Du,isGLComponentConfig:Fu,isReactComponentConfig:wb,itemDefaultConfig:Nu},Symbol.toStringTag,{value:"Module"}));class Ut{static ALL_EVENT="__all";_mSubscriptions;constructor(){this._mSubscriptions={},this._mSubscriptions[Ut.ALL_EVENT]=[]}on(e,t,n){if(typeof t!="function")throw new Error("Tried to listen to event "+e+" with non-function callback "+t);this._mSubscriptions[e]||(this._mSubscriptions[e]=[]),this._mSubscriptions[e].push({fn:t,ctx:n})}emit(e,...t){const n=this._mSubscriptions[e];if(n)for(let i=0;i<n.length;i++){const o=n[i].ctx||{};n[i].fn.apply(o,t)}t.unshift(e);const s=this._mSubscriptions[Ut.ALL_EVENT];for(let i=0;i<s.length;i++){const o=s[i].ctx||{};s[i].fn.apply(o,t)}}unbind(e,t,n){if(!this._mSubscriptions[e])throw new Error("No subscribtions to unsubscribe for event "+e);let s=!1;for(let i=0;i<this._mSubscriptions[e].length;i++)(!t||this._mSubscriptions[e][i].fn===t)&&(!n||n===this._mSubscriptions[e][i].ctx)&&(this._mSubscriptions[e].splice(i,1),s=!0);if(s===!1)throw new Error("Nothing to unbind for "+e)}off=this.unbind;trigger=this.emit}class ml extends Ut{width;height;title;parent;layoutManager;tab;_config;isHidden=!1;beforeCloseHandler;_element=me(['<div class="lm_item_container">','<div class="lm_content" tabindex="-1"></div>',"</div>"].join(""));_contentElement;constructor(e,t,n){super(),this.title=Fu(e)?e.componentName:"",this.parent=t,this.layoutManager=n,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,t){let n=this.parent,s=null;for(;n&&!n.isColumn&&!n.isRow;)if(s=n,n=n.parent,n?.isRoot)return!1;if(!n||!s)return!1;const i=n.isColumn?"height":"width",o=i==="height"?t:e,a=(this[i]??0)*(1/((s.config[i]??0)/100)),r=o/a*100,c=((s.config[i]??0)-r)/(n.contentItems.length-1);for(let h=0;h<n.contentItems.length;h++)n.contentItems[h]===s?n.contentItems[h].config[i]=r:n.contentItems[h].config[i]=(n.contentItems[h].config[i]??0)+c;return n.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(me.extend(!0,this.getState(),e))}setState(e){this._config.componentState=e,this.parent.emitBubblingEvent("stateChanged")}setTitle(e){this.parent.setTitle(e)}_$setSize(e=0,t=0){if(e!==this.width||t!==this.height){this.width=e,this.height=t;var n=this._contentElement[0],s=n.offsetWidth-n.clientWidth,i=n.offsetHeight-n.clientHeight;this._contentElement.width(this.width-s).height(this.height-i),this.emit("resize")}}}const Tb=Object.freeze(Object.defineProperty({__proto__:null,Container:ml,ItemContainer:ml},Symbol.toStringTag,{value:"Module"}));function Mu(d){var e=location.hash.match(new RegExp(d+"=([^&]*)"));return e?e[1]:null}function ku(d){if(window.location.hash)return Mu(d);if(!window.location.search)return null;var e=window.location.search.substr(1).split("&"),t={},n,s;for(s=0;s<e.length;s++)n=e[s].split("="),t[n[0]]=n[1];return t[d]||null}function Sr(d){return window.requestAnimationFrame(d)}function Eb(d,e){var t=e.indexOf(d);if(t===-1)throw new Error("Can't remove item from array. Item is not in the array");e.splice(t,1)}function Jl(){return(Math.random()*1e15).toString(36).replace(".","")}function yb(d,e){var t=d.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?t:t.replace(/>/g,"&gt;").replace(/</g,"&lt;")}function ec(d){return me.trim(d.replace(/(<([^>]+)>)/gi,""))}class Po extends Ut{_eElement;_oDocument;_eBody;_destroyAfterMouseUp;_nDelay=400;_timeout;timeout;_nDistance=10;_nX=0;_nY=0;_nOriginalX=0;_nOriginalY=0;_bDragging=!1;constructor(e,t=!1){super(),this._eElement=e,this._oDocument=me(document),this._eBody=me(document.body),this._destroyAfterMouseUp=t,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 t=this._getCoordinates(e);this._nOriginalX=t.x??0,this._nOriginalY=t.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 t=this._getCoordinates(e);this._nX=(t.x??0)-this._nOriginalX,this._nY=(t.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 Ou{_container;_reactComponent=null;_originalComponentWillUpdate=null;_initialState;_reactClass;constructor(e,t){this._reactComponent=null,this._originalComponentWillUpdate=null,this._container=e,this._initialState=t,this._reactClass=this._getReactClass(),this._container.on("open",this._render,this),this._container.on("destroy",this._destroy,this)}_render(){Bi.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 t=this._container.getState();t&&this._reactComponent.setState(t)}_destroy(){Bi.unmountComponentAtNode(this._container.getElement()[0]),this._container.off("open",this._render,this),this._container.off("destroy",this._destroy,this)}_onUpdate(e,t){this._container.setState(t),this._originalComponentWillUpdate?.call(this._reactComponent,e,t)}_getReactClass(){var e=this._container._config.component;if(!e)throw new Error("No react component name. type: react-component needs a field `component`");const t=this._container.layoutManager.getComponent(e)||this._container.layoutManager.getFallbackComponent();if(!t)throw new Error('React component "'+e+'" not found. Please register all components with GoldenLayout using `registerComponent(name, component)`');return t}_getReactComponent(){var e={glEventHub:this._container.layoutManager.eventHub,glContainer:this._container,ref:this._gotReactComponent.bind(this)},t=me.extend(e,this._container._config.props);return J.createElement(this._reactClass,t)}}const Ha=["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"],Rb=[!0,!1,"row","column","stack","component","close","maximise","minimise","open in new window"];function tc(d){if(Ha.length>36)throw new Error("Too many keys in config minifier map");const e={};return nc(d,e,"_min"),e}function gl(d){if(Ha.length>36)throw new Error("Too many keys in config minifier map");const e={};return nc(d,e,"_max"),e}function nc(d,e,t){const n=t==="_min"?xb:Ib;for(let s in d){if(!d.hasOwnProperty(s))continue;const i=Array.isArray(d)?d[Number.parseInt(s,10)]:d[s];if(typeof i=="object"&&i!=null){const o=i instanceof Array?[]:{};if(Array.isArray(e))e[Number.parseInt(s,10)]=o;else{const a=n(s,Ha);e[a]=o}nc(i,o,t)}else{const o=n(i,Rb);if(Array.isArray(e))e[Number.parseInt(s,10)]=o;else{const a=n(s,Ha);e[a]=o}}}}function xb(d,e){if(typeof d=="string"&&d.length===1)return"___"+d;var t=e.indexOf(d);return t===-1?d:t.toString(36)}function Ib(d,e){return typeof d=="string"&&d.length===1?e[parseInt(d,36)]:typeof d=="string"&&d.substr(0,3)==="___"?d[3]:d}class pl{name;origin;isPropagationStopped;constructor(e,t){this.name=e,this.origin=t,this.isPropagationStopped=!1}stopPropagation(){this.isPropagationStopped=!0}}let Au=class extends Ut{_layoutManager;_dontPropagateToParent;_childEventSource;_boundOnEventFromChild;constructor(e){super(),this._layoutManager=e,this._dontPropagateToParent=null,this._childEventSource=null,this.on(Ut.ALL_EVENT,this._onEventFromThis.bind(this)),this._boundOnEventFromChild=this._onEventFromChild.bind(this),me(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 t="gl_child_event",n=window.opener?.document.createEvent("HTMLEvents");n.initEvent(t,!0,!0),n.eventName=t,n.__glArgs=e,n.__gl=this._layoutManager,window.opener.dispatchEvent(n)}_propagateToChildren(e){for(let t=0;t<this._layoutManager.openPopouts.length;t++){const n=this._layoutManager.openPopouts[t].getGlInstance();n&&n!==this._childEventSource&&n.eventHub._$onEventFromParent(e)}}destroy(){me(window).off("gl_child_event",this._boundOnEventFromChild)}};const Db=Object.freeze(Object.defineProperty({__proto__:null,BubblingEvent:pl,DragListener:Po,EventEmitter:Ut,EventHub:Au,ReactComponentHandler:Ou,animFrame:Sr,filterXss:yb,getHashValue:Mu,getQueryStringParam:ku,getUniqueId:Jl,minifyConfig:tc,removeFromArray:Eb,stripTags:ec,unminifyConfig:gl},Symbol.toStringTag,{value:"Module"}));class Lu extends Ut{isInitialised=!1;_config;_dimensions;_parentId;_indexInParent;_layoutManager;_popoutWindow=null;_id=null;constructor(e,t,n,s,i){super(),this._config=e,this._dimensions=t,this._parentId=n,this._indexInParent=s,this._layoutManager=i,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,t=null;this._parentId&&(e=me.extend(!0,{},this.getGlInstance()?.toConfig()).content[0],t=this._layoutManager.root.getItemsById(this._parentId)[0],t||((this._layoutManager.root.contentItems.length??0)>0?t=this._layoutManager.root.contentItems[0]:t=this._layoutManager.root)),e&&(t?.addChild(e,this._indexInParent),this.close())}_createWindow(){const e=this._createUrl(),t=Math.floor(Math.random()*1e6).toString(36),n=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,t,n),!this._popoutWindow)if(this._layoutManager.config.settings.blockedPopoutsThrowError===!0){const i=new Error("Popout blocked");throw i.type="popoutBlocked",i}else return;me(this._popoutWindow).on("load",this._positionWindow.bind(this)).on("unload beforeunload",this._onClose.bind(this));let s=window.setInterval(()=>{this._popoutWindow?.__glInstance&&this._popoutWindow.__glInstance.isInitialised&&(this._onInitialised(),window.clearInterval(s))},10)}_serializeWindowOptions(e){var t=[],n;for(n in e)t.push(n+"="+e[n]);return t.join(",")}_createUrl(){var e={content:this._config};const t="gl-window-config-"+Jl();e=tc(e);try{localStorage.setItem(t,JSON.stringify(e))}catch(s){throw new Error("Error while writing to localStorage "+s.toString())}const n=document.location.href.split("?");return n.length===1?n[0]+"?gl-window="+t:document.location.href+"&gl-window="+t}_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)}}class Qi extends Ut{static _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>';_dragListener;_layoutManager;_contentItem;_originalParent;_area=null;_lastValidArea=null;_minX;_maxX;_minY;_maxY;_width;_height;_sided;element;childElementContainer;_proxyTab;constructor(e,t,n,s,i,o){super(),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=me(Qi._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:e,top:t}),this._proxyTab=this.element.find(".lm_tab"),this._proxyTab.attr("title",ec(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(),me(document.body).append(this.element),this._setDimensions(),!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 a=this._layoutManager.container.offset();this._minX=a?.left??0,this._minY=a?.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(e,t),this._layoutManager.emit("itemPickedUp",this._contentItem)}_onDrag(e,t,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(e,t){this.element.css({left:e,top:t}),this._area=this._layoutManager._$getArea(e,t),this._area!==null&&(this._lastValidArea=this._area,this._area.contentItem._$highlightDropZone(e,t,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 e=this._layoutManager.config.dimensions;let t=e.dragProxyWidth,n=e.dragProxyHeight;this.element.width(t),this.element.height(n),t-=this._sided?e.headerHeight:0,n-=this._sided?0:e.headerHeight,this.childElementContainer.width(t),this.childElementContainer.height(n),this._contentItem.element.width(t),this._contentItem.element.height(n),this._contentItem.callDownwards("_$show"),this._contentItem.callDownwards("setSize")}}class Pu{_element;_itemConfig;_layoutManager;_dragListener;constructor(e,t,n){this._element=e,this._itemConfig=t,this._layoutManager=n,this._dragListener=this._createDragListener()}_createDragListener(){return this._dragListener=new Po(this._element,!0),this._dragListener.on("dragStart",this._onDragStart,this),this._dragListener.on("dragStop",this._createDragListener,this),this._dragListener}_onDragStart(e,t){let n=this._itemConfig;typeof n=="function"&&(n=n());const s=this._layoutManager._$normalizeContentItem(me.extend(!0,{},n)),i=new Qi(e,t,this._dragListener,this._layoutManager,s,null);this._layoutManager.transitionIndicator?.transitionElements(this._element,i.element)}}class _u{_element=me(window);_itemConfig;_layoutManager;_dragListener;constructor(e,t,n){this._itemConfig=e,this._layoutManager=t,this._createDragListener(n)}_createDragListener(e){this._dragListener&&this._dragListener.destroy(),this._element&&(this._dragListener=new Po(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,t){if(!(!this._dragListener||!this._layoutManager)){var n=this._itemConfig;typeof n=="function"&&(n=n());var s=this._layoutManager._$normalizeContentItem(me.extend(!0,{},n));new Qi(e,t,this._dragListener,this._layoutManager,s,null)}}}class br{static _template='<div class="lm_dropTargetIndicator"><div class="lm_inner"></div></div>';element=me(br._template);constructor(){me(document.body).append(this.element)}destroy(){this.element.remove()}highlightArea(e){this.element.css({left:e.x1,top:e.y1,width:Math.floor(e.x2-e.x1),height:Math.floor(e.y2-e.y1)}).show()}hide(){this.element.hide()}}class bo{element;_header;_action;constructor(e,t,n,s){this._header=e,this.element=me('<li class="'+n+'" title="'+t+'"></li>'),this._header.on("destroy",this._$destroy,this),this._action=s,this.element.on("click",this._action),this._header.controlsContainer.append(this.element)}_$destroy(){this.element.off(),this.element.remove()}}class ii extends Error{node;constructor(e,t){super(),this.name="Configuration Error",this.message=e,this.node=t}}const Fb=Object.freeze(Object.defineProperty({__proto__:null,ConfigurationError:ii},Symbol.toStringTag,{value:"Module"}));function Io(d){return d.isStack}function _t(d){return d.isComponent}function ju(d){return d.isRoot}class pt extends Ut{config;type;contentItems;parent;layoutManager;element;childElementContainer;componentName;isInitialised=!1;isMaximised=!1;isRoot=!1;isRow=!1;isColumn=!1;isStack=!1;isComponent=!1;tab;_pendingEventPropagations;_throttledEvents;constructor(e,t,n,s){super(),this.element=s,this.config=this._extendItemNode(t),this.type=t.type,this.contentItems=[],this.parent=n,this.layoutManager=e,this._pendingEventPropagations={},this._throttledEvents=["stateChanged"],this.on(Ut.ALL_EVENT,this._propagateEvent,this),t.content&&this._createContentItems(t)}callDownwards(e,t=[],n=!1,s=!1){n!==!0&&s!==!0&&this[e].apply(this,t);for(let i=0;i<this.contentItems.length;i++)this.contentItems[i].callDownwards(e,t,n);n===!0&&s!==!0&&this[e].apply(this,t)}removeChild(e,t=!1){const n=this.contentItems.indexOf(e);if(n===-1)throw new Error("Can't remove child item. Unknown content item");t!==!0&&this.contentItems[n]._$destroy(),this.contentItems.splice(n,1),this.config.content?.splice(n,1),this.contentItems.length>0?this.callDownwards("setSize"):this.type!=="root"&&this.config.isClosable&&this.parent?.removeChild(this)}addChild(e,t){e=this.layoutManager._$normalizeContentItem(e,this),t===void 0&&(t=this.contentItems.length),this.contentItems.splice(t,0,e),this.config.content===void 0&&(this.config.content=[]),this.config.content.splice(t,0,e.config),e.parent=this,e.parent.isInitialised===!0&&e.isInitialised===!1&&e._$init()}replaceChild(e,t,n=!1){t=this.layoutManager._$normalizeContentItem(t);const s=this.contentItems.indexOf(e),i=e.element[0].parentNode;if(s===-1)throw new Error("Can't replace child. oldChild is not child of this");i?.replaceChild(t.element[0],e.element[0]),n===!0&&(e.parent=null,e._$destroy()),this.contentItems[s]=t,t.parent=this,Io(this)&&(this.header.tabs[s].contentItem=t),t.parent.isInitialised===!0&&t.isInitialised===!1&&t._$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 t=this.config.id.indexOf(e);this.config.id.splice(t,1)}}getItemsByFilter(e){const t=[],n=function(s){for(let i=0;i<s.contentItems.length;i++)e(s.contentItems[i])===!0&&t.push(s.contentItems[i]),n(s.contentItems[i])};return n(this),t}getItemsById(e){return this.getItemsByFilter(function(t){return t.config.id instanceof Array?t.config.id.indexOf(e)!==-1:t.config.id===e})}getItemsByType(e){return this._$getItemsByProperty("type",e)}getComponentsByName(e){const t=this._$getItemsByProperty("componentName",e),n=[];for(let s=0;s<t.length;s++)n.push(t[s].instance);return n}_$getItemsByProperty(e,t){return this.getItemsByFilter(function(n){return n[e]===t})}_$setParent(e){this.parent=e}_$highlightDropZone(e,t,n){this.layoutManager.dropTargetIndicator?.highlightArea(n)}_$onDrop(e,t){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 t=this.getItemsByType("stack");let n=null;for(let s=0;s<t.length;s++)n=t[s].getActiveContentItem(),n&&_t(n)&&n.container[e]()}_$destroy(){this.emitBubblingEvent("beforeItemDestroyed"),this.callDownwards("_$destroy",[],!0,!0),this.element.remove(),this.emitBubblingEvent("itemDestroyed")}_$getArea(e){e=e||this.element;const t=e.offset()??{left:0,top:0},n=e.width()??0,s=e.height()??0;return{x1:t.left,y1:t.top,x2:t.left+n,y2:t.top+s,surface:n*s,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 t=new pl(e,this);this.emit(e,t)}_createContentItems(e){var t;if(!(e.content instanceof Array))throw new ii("content must be an Array",e);for(let n=0;n<e.content.length;n++)t=this.layoutManager.createContentItem(e.content[n],this),this.contentItems.push(t)}_extendItemNode(e){for(let[t,n]of Object.entries(Nu)){const s=t;e[s]===void 0&&(e[s]=n)}return e}_propagateEvent(e,t){t instanceof pl&&t.isPropagationStopped===!1&&this.isInitialised===!0&&(this.isRoot===!1&&this.parent?this.parent.emit.apply(this.parent,[e,t]):this._scheduleEventPropagationToLayoutManager(e,t))}_scheduleEventPropagationToLayoutManager(e,t){this._throttledEvents.indexOf(e)===-1?this.layoutManager.emit(e,t.origin):this._pendingEventPropagations[e]!==!0&&(this._pendingEventPropagations[e]=!0,Sr(this._propagateEventToLayoutManager.bind(this,e,t)))}_propagateEventToLayoutManager(e,t){this._pendingEventPropagations[e]=!1,this.layoutManager.emit(e,t)}}class Hu extends pt{config;componentName;container;parent;instance;constructor(e,t,n){super(e,t,n,me()),this.config=t,this.parent=n;const s=e.getComponent(this.config.componentName)||e.getFallbackComponent(),i=me.extend(!0,{},this.config.componentState||{});if(s==null)throw new ii('Unknown component "'+this.config.componentName+'"');i.componentName=this.config.componentName,this.componentName=this.config.componentName,this.config.title===""&&(this.config.title=this.config.componentName),this.isComponent=!0,this.container=new ml(this.config,this,e),this.instance=new s(this.container,i),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(){pt.prototype._$init.call(this),this.container.emit("open")}_$hide(){this.container.hide(),pt.prototype._$hide.call(this)}_$show(){this.container.show(),this.container._config.isFocusOnShow&&this.container._contentElement[0].focus({preventScroll:!0}),pt.prototype._$show.call(this)}_$destroy(){this.container.emit("destroy",this),pt.prototype._$destroy.call(this)}_$getArea(){return null}}class Va extends pt{isRow;isColumn;childElementContainer;parent;_splitter=[];_splitterSize;_splitterGrabSize;_isColumn;_dimension;_splitterPosition=null;_splitterMinPosition=null;_splitterMaxPosition=null;constructor(e,t,n,s){super(t,n,s,me('<div class="lm_item lm_'+(e?"column":"row")+'"></div>')),this.parent=s,this.isRow=!e,this.isColumn=e,this.childElementContainer=this.element,this._splitterSize=t.config.dimensions.borderWidth,this._splitterGrabSize=t.config.dimensions.borderGrabWidth,this._isColumn=e,this._dimension=e?"height":"width",this._splitterPosition=null,this._splitterMinPosition=null,this._splitterMaxPosition=null}addChild(e,t,n){var s,i,o,a;if(e=this.layoutManager._$normalizeContentItem(e,this),t===void 0&&(t=this.contentItems.length),this.contentItems.length>0?(a=this._createSplitter(Math.max(0,t-1)).element,t>0?(this.contentItems[t-1].element.after(a),a.after(e.element)):(this.contentItems[0].element.before(a),a.before(e.element))):this.childElementContainer.append(e.element),pt.prototype.addChild.call(this,e,t),s=1/this.contentItems.length*100,n===!0){this.emitBubblingEvent("stateChanged");return}for(o=0;o<this.contentItems.length;o++)this.contentItems[o]===e?e.config[this._dimension]=s:(i=(this.contentItems[o].config[this._dimension]??0)*(100-s)/100,this.contentItems[o].config[this._dimension]=i);this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged")}removeChild(e,t){var n=e.config[this._dimension]??0,s=this.contentItems.indexOf(e),i=Math.max(s-1,0),o,a;if(s===-1)throw new Error("Can't remove child. ContentItem is not child of this Row or Column");for(this._splitter[i]&&(this._splitter[i]._$destroy(),this._splitter.splice(i,1)),o=0;o<this.contentItems.length;o++)this.contentItems[o]!==e&&(this.contentItems[o].config[this._dimension]=(this.contentItems[o].config[this._dimension]??0)+n/(this.contentItems.length-1));pt.prototype.removeChild.call(this,e,t),this.contentItems.length===1&&this.config.isClosable===!0?(a=this.contentItems[0],this.contentItems=[],this.parent.replaceChild(this,a,!0)):(this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged"))}replaceChild(e,t){var n=e.config[this._dimension];super.replaceChild(e,t),t.config[this._dimension]=n,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(pt.prototype._$init.call(this),e=0;e<this.contentItems.length-1;e++)this.contentItems[e].element.after(this._createSplitter(e).element)}}_setAbsoluteSizes(){var e,t=this._calculateAbsoluteSizes();for(e=0;e<this.contentItems.length;e++)t.additionalPixel-e>0&&t.itemSizes[e]++,this._isColumn?(this.contentItems[e].element.width(t.totalWidth),this.contentItems[e].element.height(t.itemSizes[e])):(this.contentItems[e].element.width(t.itemSizes[e]),this.contentItems[e].element.height(t.totalHeight))}_calculateAbsoluteSizes(){const e=(this.contentItems.length-1)*this._splitterSize;let t=this.element.width()??0,n=this.element.height()??0,s=0;const i=[];this._isColumn?n-=e:t-=e;for(let a=0;a<this.contentItems.length;a++){const r=this._isColumn?Math.floor(n*((this.contentItems[a].config.height??0)/100)):Math.floor(t*((this.contentItems[a].config.width??0)/100));s+=r,i.push(r)}const o=Math.floor((this._isColumn?n:t)-s);return{itemSizes:i,additionalPixel:o,totalWidth:t,totalHeight:n}}_calculateRelativeSizes(){let e=0;const t=[],n=this._isColumn?"height":"width";for(let s=0;s<this.contentItems.length;s++)this.contentItems[s].config[n]!==void 0?e+=this.contentItems[s].config[n]??0:t.push(this.contentItems[s]);if(Math.round(e)===100){this._respectMinItemWidth();return}if(Math.round(e)<100&&t.length>0){for(let s=0;s<t.length;s++)t[s].config[n]=(100-e)/t.length;this._respectMinItemWidth();return}if(Math.round(e)>100)for(let s=0;s<t.length;s++)t[s].config[n]=50,e+=50;for(let s=0;s<this.contentItems.length;s++)this.contentItems[s].config[n]=(this.contentItems[s].config[n]??0)/e*100;this._respectMinItemWidth()}_respectMinItemWidth(){const e=this.layoutManager.config.dimensions?this.layoutManager.config.dimensions.minItemWidth??0:0,t=[];let n=0,s=0,i=0;const o=[];let a;if(this._isColumn||!e||this.contentItems.length<=1)return;const r=this._calculateAbsoluteSizes();for(let h=0;h<this.contentItems.length;h++){this.contentItems[h];const u=r.itemSizes[h];u<e?(s+=e-u,a={width:e}):(n+=u-e,a={width:u},t.push(a)),o.push(a)}if(s===0||s>n)return;const c=s/n;i=s;for(let h=0;h<t.length;h++){a=t[h];const u=Math.round((a.width-e)*c);i-=u,a.width-=u}i!==0&&(o[o.length-1].width-=i);for(let h=0;h<this.contentItems.length;h++)this.contentItems[h].config.width=o[h].width/r.totalWidth*100}_createSplitter(e){var t;return t=new Vu(this._isColumn,this._splitterSize,this._splitterGrabSize),t.on("drag",this._onSplitterDrag.bind(this,t),this),t.on("dragStop",this._onSplitterDragStop.bind(this,t),this),t.on("dragStart",this._onSplitterDragStart.bind(this,t),this),this._splitter.splice(e,0,t),t}_getItemsForSplitter(e){const t=this._splitter.indexOf(e);if(t<0)throw new Error("Splitter not found in RowOrColumn");return{before:this.contentItems[t],after:this.contentItems[t+1]}}_getMinimumDimensions(e){for(var t=0,n=0,s=0;s<e.length;++s)t=Math.max(e[s].minWidth??0,t),n=Math.max(e[s].minHeight??0,n);return{horizontal:t,vertical:n}}_onSplitterDragStart(e){const t=this._getItemsForSplitter(e),n=this.layoutManager.config.dimensions[this._isColumn?"minItemHeight":"minItemWidth"];var s=this._getMinimumDimensions(t.before.config.content??[]),i=this._isColumn?s.vertical:s.horizontal,o=this._getMinimumDimensions(t.after.config.content??[]),a=this._isColumn?o.vertical:o.horizontal;this._splitterPosition=0,this._splitterMinPosition=-1*((t.before.element[this._dimension]()??0)-(i||n)),this._splitterMaxPosition=(t.after.element[this._dimension]()??0)-(a||n)}_onSplitterDrag(e,t,n){const s=this._isColumn?n:t;this._splitterMaxPosition==null||this._splitterMinPosition==null||s>this._splitterMinPosition&&s<this._splitterMaxPosition&&(this._splitterPosition=s,e.element.css(this._isColumn?"top":"left",s))}_onSplitterDragStop(e){const t=this._getItemsForSplitter(e),n=t.before.element[this._dimension]()??0,s=t.after.element[this._dimension]()??0,i=((this._splitterPosition??0)+n)/(n+s),o=(t.before.config[this._dimension]??0)+(t.after.config[this._dimension]??0);t.before.config[this._dimension]=i*o,t.after.config[this._dimension]=(1-i)*o,e.element.css({top:0,left:0}),Sr(this.callDownwards.bind(this,"setSize",void 0,void 0,void 0))}}class fl extends pt{childElementContainer;_containerElement;constructor(e,t,n){super(e,{...t,type:"root"},null,me('<div class="lm_goldenlayout lm_item lm_root"></div>')),this.isRoot=!0,this.type="root",this.childElementContainer=this.element,this._containerElement=n,this._containerElement.append(this.element)}addChild(e,t){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,t),this.callDownwards("setSize"),this.emitBubblingEvent("stateChanged")}setSize(e,t){e=typeof e>"u"?this._containerElement.width()??0:e,t=typeof t>"u"?this._containerElement.height()??0:t,this.element.width(e),this.element.height(t),this.contentItems[0]&&(this.contentItems[0].element.width(e),this.contentItems[0].element.height(t))}_$getArea(){const e=super._$getArea();if(e==null)throw new Error("Unable to get root area");return e}_$highlightDropZone(e,t,n){this.layoutManager.tabDropPlaceholder.remove(),super._$highlightDropZone(e,t,n)}_$onDrop(e,t){var n;if(_t(e)&&(n=this.layoutManager.createContentItem({type:"stack",header:e.config.header||{}},this),n._$init(),n.addChild(e),e=n),!this.contentItems.length)this.addChild(e);else{const{side:s}=t,i=s==="left"||s==="right"?"row":"column",o=s==="left"||s==="right"?"width":"height",a=s==="left"||s==="top",r=this.contentItems[0];if(!(r instanceof Va)||r.type!=i){const c=this.layoutManager.createContentItem({type:i},this);this.replaceChild(r,c),c.addChild(e,a?0:void 0,!0),c.addChild(r,a?void 0:0,!0),r.config[o]=50,e.config[o]=50,c.callDownwards("setSize")}else{const c=r.contentItems[a?0:r.contentItems.length-1];r.addChild(e,a?0:void 0,!0),c.config[o]=(c.config[o]??0)*.5,e.config[o]=c.config[o],r.callDownwards("setSize")}}}}class Cl extends pt{_activeContentItem=null;_header;childElementContainer=me('<div class="lm_items"></div>');header;parent;isStack=!0;_dropZones={};_dropSegment=null;_contentAreaDimensions=null;_dropIndex;_side;_sided=!1;config;constructor(e,t,n){super(e,t,n,me('<div class="lm_item lm_stack"></div>')),this.parent=n,this.config=t;const s=e.config;this._side=!1,this._header={show:s.settings?.hasHeaders&&t.hasHeaders!==!1,popout:s.settings?.showPopoutIcon?s.labels?.popout:void 0,maximise:s.settings?.showMaximiseIcon?s.labels?.maximise:void 0,close:s.settings?.showCloseIcon?s.labels?.close:void 0,minimise:s.labels?.minimise??void 0},s.header&&(this._header={...this._header,...s.header}),t.header&&(this._header={...this._header,...t.header}),t.content&&t.content[0]&&t.content[0].header&&(this._header={...this._header,...t.content[0].header}),this.header=new Pi(e,this),this.element.append(this.header.element),this.element.append(this.childElementContainer),this._setupHeaderPosition(),this._$validateClosability()}setSize(){var e,t=this._header.show?this.layoutManager.config.dimensions?.headerHeight??0:0,n=(this.element.width()??0)-(this._sided?t:0),s=(this.element.height()??0)-(this._sided?0:t);for(this.childElementContainer.width(n),this.childElementContainer.height(s),e=0;e<this.contentItems.length;e++)this.contentItems[e].element.width(n).height(s);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,t){e=this.layoutManager._$normalizeContentItem(e,this),super.addChild(e,t),this.childElementContainer.append(e.element),this.header.createTab(e,t),this.setActiveContentItem(e),this.callDownwards("setSize"),this._$validateClosability(),this.emitBubblingEvent("stateChanged")}removeChild(e,t=!1){var n=this.contentItems.indexOf(e);super.removeChild(e,t),this.header.removeTab(e),this.header.activeContentItem===e&&(this.contentItems.length>0?this.setActiveContentItem(this.contentItems[Math.max(n-1,0)]):this._activeContentItem=null),this._$validateClosability(),this.emitBubblingEvent("stateChanged")}_$validateClosability(){let e=this.header._isClosable();for(let t=0,n=this.contentItems.length;t<n&&e;t++)e=this.contentItems[t].config.isClosable??!1;this.header._$setClosable(e)}_$destroy(){pt.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 t=this._dropSegment==="top"||this._dropSegment==="bottom",n=this._dropSegment==="left"||this._dropSegment==="right",s=this._dropSegment==="top"||this._dropSegment==="left",i=t&&this.parent.isColumn||n&&this.parent.isRow,o=t?"column":"row",a=t?"height":"width";if(_t(e)){const r=this.layoutManager.createContentItem({type:"stack",header:e.config.header||{}},this);r._$init(),r.addChild(e),e=r}if(i){const r=this.parent.contentItems.indexOf(this);this.parent.addChild(e,s?r:r+1,!0),this.config[a]=(this.config[a]??0)*.5,e.config[a]=this.config[a],this.parent.callDownwards("setSize")}else{const r=this.layoutManager.createContentItem({type:o},this);this.parent.replaceChild(this,r),r.addChild(e,s?0:void 0,!0),r.addChild(this,s?void 0:0,!0),this.config[a]=50,e.config[a]=50,r.callDownwards("setSize")}}_$highlightDropZone(e,t){if(this._contentAreaDimensions)for(let[n,s]of Object.entries(this._contentAreaDimensions)){const i=s.hoverArea;if(i.x1<e&&i.x2>e&&i.y1<t&&i.y2>t){n==="header"?(this._dropSegment="header",this._highlightHeaderDropZone(e)):(this._resetHeaderDropZone(),this._highlightBodyDropZone(n));return}}}_$getArea(){if(this.element.is(":visible")===!1)return null;const e=super._$getArea(this.header.element),t=super._$getArea(this.childElementContainer);if(e==null||t==null)return null;const n=t.x2-t.x1,s=t.y2-t.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:t.x1,y1:t.y1,x2:t.x2,y2:t.y2},highlightArea:{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2}},super._$getArea(this.element)):(this._contentAreaDimensions.left={hoverArea:{x1:t.x1,y1:t.y1,x2:t.x1+n*.25,y2:t.y2},highlightArea:{x1:t.x1,y1:t.y1,x2:t.x1+n*.5,y2:t.y2}},this._contentAreaDimensions.top={hoverArea:{x1:t.x1+n*.25,y1:t.y1,x2:t.x1+n*.75,y2:t.y1+s*.5},highlightArea:{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y1+s*.5}},this._contentAreaDimensions.right={hoverArea:{x1:t.x1+n*.75,y1:t.y1,x2:t.x2,y2:t.y2},highlightArea:{x1:t.x1+n*.5,y1:t.y1,x2:t.x2,y2:t.y2}},this._contentAreaDimensions.bottom={hoverArea:{x1:t.x1+n*.25,y1:t.y1+s*.5,x2:t.x1+n*.75,y2:t.y2},highlightArea:{x1:t.x1,y1:t.y1+s*.5,x2:t.x2,y2:t.y2}},super._$getArea(this.element))}_highlightHeaderDropZone(e){const t=this.header.tabs.length;if(t===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 s=this.header.tabsContainer.get(0)?.getBoundingClientRect(),i=this.layoutManager.tabDropPlaceholder.get(0)?.getBoundingClientRect();if(!s||!i)return;e<s.left?e=s.left+1:e>s.right&&(e=s.right-1);let o,a;if(!(i.left<e&&e<i.right)){for(var r=0;r<t;r++)if(o=this.header.tabs[r].element,a=o.get(0)?.getBoundingClientRect(),a&&a.left<e&&e<a.right){this._dropIndex=r;break}o&&a&&e<a.left+a.width*.5?o.before(this.layoutManager.tabDropPlaceholder):o&&(this._dropIndex=Math.min((this._dropIndex??0)+1,t),o.after(this.layoutManager.tabDropPlaceholder))}let c=this.layoutManager.tabDropPlaceholder.offset()?.left??0;c=Math.max(c,this.header.tabsContainer.offset()?.left??0);var h=c+(this.layoutManager.tabDropPlaceholder.width()??0);h=Math.min(h,(this.header.tabsContainer.offset()?.left??0)+(this.header.tabsContainer.innerWidth()??0)),this.layoutManager.dropTargetIndicator?.highlightArea({x1:c,x2:h,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(t=>t===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 t=["right","bottom"].indexOf(this._side.toString())>=0?"before":"after";this.header.element[t](this.childElementContainer),this.callDownwards("setSize")}}_highlightBodyDropZone(e){const t=this._contentAreaDimensions?.[e]?.highlightArea;t&&this.layoutManager.dropTargetIndicator?.highlightArea(t),this._dropSegment=e}}const Nb=Object.freeze(Object.defineProperty({__proto__:null,AbstractContentItem:pt,Component:Hu,ContentItem:pt,Root:fl,RowOrColumn:Va,Stack:Cl,isComponent:_t,isRoot:ju,isStack:Io},Symbol.toStringTag,{value:"Module"}));class wr{static _template=['<li class="lm_tab">','<span class="lm_title_before"></span>','<span class="lm_title"></span>','<div class="lm_close_tab"></div>',"</li>"].join("");header;contentItem;element=me(wr._template);titleElement;closeElement;isActive=!1;_layoutManager;_dragListener;constructor(e,t){this.header=e,this.contentItem=t,this.titleElement=this.element.find(".lm_title"),this.closeElement=this.element.find(".lm_close_tab"),this.closeElement[t.config.isClosable?"show":"hide"](),this.setTitle(t.config.title),this.contentItem.on("titleChanged",this.setTitle,this),this._layoutManager=this.contentItem.layoutManager,this._layoutManager.config.settings?.reorderEnabled&&t.config.reorderEnabled&&(this._dragListener=new Po(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),_t(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(e=""){this.titleElement.html(e)}setActive(e){e!==this.isActive&&(this.isActive=e,e?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),_t(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(e,t){this.contentItem.parent?.isMaximised&&this.contentItem.parent.toggleMaximise(),this._dragListener&&new Qi(e,t,this._dragListener,this._layoutManager,this.contentItem,this.header.parent)}_onTabContentFocusIn(){_t(this.contentItem)&&!this.contentItem.container._contentElement[0].contains(document.activeElement)&&this.contentItem.container._contentElement[0].focus(),this.element.addClass("lm_focusin")}_onTabContentFocusOut(){_t(this.contentItem)&&!this.contentItem.container._contentElement[0].contains(document.activeElement)&&this.element.removeClass("lm_focusin")}_onTabClick(e){if(!e||e.button===0){var t=this.header.parent.getActiveContentItem();this.contentItem!==t&&_t(this.contentItem)?this.header.parent.setActiveContentItem(this.contentItem):_t(this.contentItem)&&!this.contentItem.container._contentElement[0].contains(document.activeElement)&&this.contentItem.container._contentElement.focus(),_t(this.contentItem)&&this.contentItem.container.emit("tabClicked",e),this.header._hideAdditionalTabsDropdown(),this.element.get(0)?.scrollIntoView({inline:"nearest"})}else e.button===1&&this.contentItem.config.isClosable&&this._onCloseClick(e)}_onCloseClick(e){e.stopPropagation(),_t(this.contentItem)?this.contentItem.container.close():this.header.parent.removeChild(this.contentItem)}_onCloseMousedown(e){e.stopPropagation()}}class Pi extends Ut{static _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("");static _previousButtonTemplate=['<ul class="lm_controls">','<li class="lm_tabpreviousbutton"></li>',"</ul>"].join("");static _nextButtonTemplate=['<li class="lm_tabnextbutton"></li>'].join("");layoutManager;element=me(Pi._template);tabsContainer;tabDropdownContainer;tabDropdownSearch;tabDropdownList=null;controlsContainer;parent;tabs=[];activeContentItem=null;closeButton=null;tabDropdownButton=null;tabNextButton=me(Pi._nextButtonTemplate);tabPreviousButton=me(Pi._previousButtonTemplate);holdTimer=null;rAF=null;CLICK_TIMEOUT=500;START_SPEED=.01;ACCELERATION=5e-4;SCROLL_LEFT="left";SCROLL_RIGHT="right";isDraggingTab=!1;isOverflowing=!1;isDropdownShown=!1;dropdownKeyIndex=0;_lastVisibleTabIndex=-1;_tabControlOffset;constructor(e,t){super(),this.layoutManager=e,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=t,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(e,t){for(let s=0;s<this.tabs.length;s++)if(this.tabs[s].contentItem===e)return;const n=new wr(this,e);if(this.tabs.length===0){this.tabs.push(n),this.tabsContainer.append(n.element);return}t===void 0&&(t=this.tabs.length),t>0?this.tabs[t-1].element.after(n.element):this.tabs[0].element.before(n.element),this.tabs.splice(t,0,n),this._updateTabSizes()}removeTab(e){for(var t=0;t<this.tabs.length;t++)if(this.tabs[t].contentItem===e){this.tabs[t]._$destroy(),this.tabs.splice(t,1);return}throw new Error("contentItem is not controlled by this header")}setActiveContentItem(e){for(var t,n=0;n<this.tabs.length;n++)t=this.tabs[n].contentItem===e,this.tabs[n].setActive(t),t===!0&&(this.activeContentItem=e,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(e){let t=this.parent._header.show;return t&&!this.parent._side&&(t="top"),e!==void 0&&this.parent._header.show!==e&&(this.parent._header.show=e,this.parent._setupHeaderPosition()),t}_attachWheelListener(){this.tabsContainer.get(0)?.addEventListener("wheel",this._handleWheelEvent,{passive:!0})}_detachWheelListener(){this.tabsContainer.get(0)?.removeEventListener("wheel",this._handleWheelEvent)}_handleWheelEvent(e){const t=e.currentTarget;if(!(t instanceof HTMLElement))return;let n=Math.abs(e.deltaY)>Math.abs(e.deltaX)?e.deltaY:e.deltaX;e.deltaMode===WheelEvent.DOM_DELTA_PAGE?n*=this.tabsContainer.innerWidth()??1:e.deltaMode===WheelEvent.DOM_DELTA_LINE&&(n*=100/3),t.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 e;for(let t=0;t<this.tabs.length;t+=1)if((this.tabs[t].element.get(0)?.offsetLeft??0)>(this.tabsContainer.get(0)?.offsetWidth??0)+(this.tabsContainer.scrollLeft()??0)){e=this.tabs[t].element.get(0);break}if(e)e.scrollIntoView({behavior:"smooth",inline:"nearest"}),this._handleScrollButtonMouseDown(this.SCROLL_RIGHT);else{const t=this.tabsContainer.get(0);t&&(t.scrollLeft=this.tabsContainer.get(0)?.scrollWidth??0)}}_handlePreviousButtonMouseDown(){for(var e,t=this.tabs.length-1;t>=0;t-=1)if((this.tabs[t].element.get(0)?.offsetLeft??0)<(this.tabsContainer.scrollLeft()??0)){e=this.tabs[t].element.get(0);break}if(e)e.scrollIntoView({behavior:"smooth",inline:"start"}),this._handleScrollButtonMouseDown(this.SCROLL_LEFT);else{const n=this.tabsContainer.get(0);n&&(n.scrollLeft=0)}}_handleScrollButtonMouseDown(e){this.holdTimer=window.setTimeout(()=>{this._handleScrollRepeat(e,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(e,t,n=0,s){const i=this.tabsContainer.get(0);if(!i)return;const o=i.getBoundingClientRect();if(e===this.SCROLL_LEFT){if(this.tabsContainer.scrollLeft(t-n),this.isDraggingTab&&this.parent._highlightHeaderDropZone(o.left-1),this.tabsContainer.scrollLeft()===0){this._checkScrollArrows();return}}else if(e===this.SCROLL_RIGHT&&(this.tabsContainer.scrollLeft(t+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(a=>{var r=s||a,c=a-r,h=this.START_SPEED*c+.5*this.ACCELERATION*(c*c);h=Math.min(h,this.tabsContainer.get(0)?.scrollWidth??1/0),this._handleScrollRepeat(e,t,h,r)})}_$setClosable(e){return this.closeButton&&this._isClosable()?(this.closeButton.element[e?"show":"hide"](),!0):!1}_$destroy(){this.emit("destroy",this);for(var e=0;e<this.tabs.length;e++)this.tabs[e]._$destroy();this._detachWheelListener(),this._handleItemDropped(),me(document).off("mouseup",this._hideAdditionalTabsDropdown),this.tabDropdownSearch.off("input",this._handleFilterInput),this.tabDropdownSearch.off("keydown",this._handleFilterKeydown),this.element.remove()}_getHeaderSetting(e){if(e in this.parent._header)return this.parent._header[e]}_createControls(){var e,t,n,s,i;if(i=this.layoutManager.config.labels.tabDropdown,this.layoutManager.config.labels.tabNextLabel,this.layoutManager.config.labels.tabPreviousLabel,this.tabDropdownButton=new bo(this,i,"lm_tabdropdown",this._showAdditionalTabsDropdown),this.tabDropdownButton.element.hide(),this.controlsContainer.prepend(this.tabNextButton),this.tabNextButton.hide(),this._getHeaderSetting("popout")&&(t=this._onPopoutClick.bind(this),n=this._getHeaderSetting("popout"),new bo(this,n,"lm_popout",t)),this._getHeaderSetting("maximise")){s=this.parent.toggleMaximise.bind(this.parent);const o=this._getHeaderSetting("maximise"),a=this._getHeaderSetting("minimise"),r=new bo(this,o,"lm_maximise",s);this.parent.on("maximised",function(){r.element.attr("title",a??"")}),this.parent.on("minimised",function(){r.element.attr("title",o??"")})}this._isClosable()&&(e=this.parent.remove.bind(this.parent),n=this._getHeaderSetting("close"),this.closeButton=new bo(this,n,"lm_close",e))}_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"),me(document).on("mousedown",this._hideAdditionalTabsDropdown),this._updateAdditionalTabsDropdown()}_handleFilterKeydown(e){if(this.dropdownKeyIndex===-1)return;if(e.key==="Escape"){this._hideAdditionalTabsDropdown();return}if(e.key==="Enter"||e.key===" "){this._hideAdditionalTabsDropdown(),this.tabs[this.dropdownKeyIndex]._onTabClick();return}function t(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}e.key==="ArrowDown"||e.key==="Tab"&&e.shiftKey===!1?(e.preventDefault(),this.tabDropdownList?.eq(this.dropdownKeyIndex).removeClass("lm_keyboard_active"),this.dropdownKeyIndex=t(this.dropdownKeyIndex,1,this.tabDropdownList),this.tabDropdownList?.eq(this.dropdownKeyIndex).addClass("lm_keyboard_active")):(e.key==="ArrowUp"||e.key==="Tab")&&(e.preventDefault(),this.tabDropdownList?.eq(this.dropdownKeyIndex).removeClass("lm_keyboard_active"),this.dropdownKeyIndex=t(this.dropdownKeyIndex,-1,this.tabDropdownList),this.tabDropdownList?.eq(this.dropdownKeyIndex).addClass("lm_keyboard_active"))}_handleFilterInput(e){if(this.tabDropdownList!=null){this.tabDropdownList.eq(this.dropdownKeyIndex).removeClass("lm_keyboard_active"),this.dropdownKeyIndex=-1;for(var t=0;t<this.tabDropdownList.length;t++)(this.tabs[t].contentItem.config.title?.toLowerCase().indexOf(e.target.value.toLowerCase())??-1)!==-1?(this.tabDropdownList.eq(t).css("display",""),this.dropdownKeyIndex===-1&&(this.dropdownKeyIndex=t)):this.tabDropdownList.eq(t).css("display","none");this.dropdownKeyIndex!==-1&&this.tabDropdownList.eq(this.dropdownKeyIndex).addClass("lm_keyboard_active")}}_hideAdditionalTabsDropdown(e){this.isDropdownShown&&(e&&this.tabDropdownContainer.get(0)?.contains(e.target)||e&&this.tabDropdownButton?.element.get(0)===e.target||(this.element.removeClass("lm_dropdown_open"),this.tabDropdownContainer.hide(),this.isDropdownShown=!1,this.tabDropdownContainer.find(".lm_tabs").remove(),me(document).off("mousedown",this._hideAdditionalTabsDropdown)))}_updateAdditionalTabsDropdown(){this.tabDropdownContainer.css("max-height","");const e=this.tabDropdownContainer[0].scrollHeight;if(e===0)return;const t=(this.tabDropdownContainer.offset()?.top??0)-(me(window).scrollTop()??0);t+e>(me(window).height()??0)&&this.tabDropdownContainer.css("max-height",(me(window).height()??0)-t-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(e){e.target===this.element[0]&&this.parent.select()}_updateTabSizes(){if(this.tabs.length===0)return;const e=this.tabsContainer.get(0);e&&(!this.isOverflowing&&e.scrollWidth>e.clientWidth?(this.tabDropdownButton?.element.show(),this.tabNextButton.show(),this.tabPreviousButton.show(),this.isOverflowing=!0):this.isOverflowing&&e.scrollWidth<=e.clientWidth&&(this.tabDropdownButton?.element.hide(),this.tabNextButton.hide(),this.tabPreviousButton.hide(),this.isOverflowing=!1),this.isOverflowing&&this._checkScrollArrows())}}class Vu{_isVertical;_size;_grabSize;_dragListener;element;constructor(e,t,n){this._isVertical=e,this._size=t,this._grabSize=n<t?t:n,this.element=this._createElement(),this._dragListener=new Po(this.element)}on(e,t,n){this._dragListener?.on(e,t,n)}_$destroy(){this._dragListener?.destroy(),this._dragListener=null,this.element.remove()}_createElement(){var e=me('<div class="lm_drag_handle"></div>'),t=me('<div class="lm_splitter"></div>');t.append(e);var n=this._grabSize-this._size,s=n/2;return this._isVertical?(e.css("top",-s),e.css("height",this._size+n),t.addClass("lm_vertical"),t.height(this._size)):(e.css("left",-s),e.css("width",this._size+n),t.addClass("lm_horizontal"),t.width(this._size)),t}}class Bu{_element=me('<div class="lm_transition_indicator"></div>');_toElement=null;_fromDimensions={};_totalAnimationDuration=200;_animationStartTime=null;constructor(){me(document.body).append(this._element)}destroy(){this._element.remove()}transitionElements(e,t){}_nextAnimationFrame(){if(!this._toElement||this._animationStartTime==null)return;const e=this._measure(this._toElement),t=(Date.now()-this._animationStartTime)/this._totalAnimationDuration,n={};if(t>=1){this._element.hide();return}e.opacity=0;const s=Object.keys(this._fromDimensions);for(let i of s)n[i]=(this._fromDimensions[i]??0)+((e[i]??0)-(this._fromDimensions[i]??0))*t;this._element.css(n),Sr(this._nextAnimationFrame.bind(this))}_measure(e){const t=e.offset();return{left:t?.left,top:t?.top,width:e.outerWidth(),height:e.outerHeight()}}}const Mb=Object.freeze(Object.defineProperty({__proto__:null,BrowserPopout:Lu,DragProxy:Qi,DragSource:Pu,DragSourceFromEvent:_u,DropTargetIndicator:br,Header:Pi,HeaderButton:bo,Splitter:Vu,Tab:wr,TransitionIndicator:Bu},Symbol.toStringTag,{value:"Module"})),kb={config:vb,container:Tb,controls:Mb,errors:Fb,items:Nb,utils:Db};class Uu extends Ut{static __lm=kb;static minifyConfig(e){return tc(e)}static unminifyConfig(e){return gl(e)}isInitialised=!1;_isFullPage=!1;_resizeTimeoutId;_components={"lm-react-component":Ou};_fallbackComponent;_itemAreas=[];_maximisedItem=null;_maximisePlaceholder=me('<div class="lm_maximise_place"></div>');_creationTimeoutPassed=!1;_subWindowsCreated=!1;_dragSources=[];_updatingColumnsResponsive=!1;_firstLoad=!0;width=null;height=null;root;openPopouts=[];selectedItem=null;isSubWindow=!1;eventHub=new Au(this);config;container;_originalContainer;dropTargetIndicator=null;transitionIndicator=null;tabDropPlaceholder=me('<div class="lm_drop_tab_placeholder"></div>');_typeToItem;constructor(e,t){super(),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=t,this.container=this._getContainer(),this.isSubWindow&&me("body").css("visibility","hidden"),this._typeToItem={column:Va.bind(this,!0),row:Va.bind(this,!1),stack:Cl,component:Hu}}registerComponent(e,t){if(typeof t!="function"&&(t==null||t.render==null||typeof t.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]=t,()=>{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 pt))throw new Error("Root must be a ContentItem");const t={settings:{...this.config.settings},dimensions:{...this.config.dimensions},labels:{...this.config.labels},content:[]},n=function(s,i){for(let o in i.config)o!=="content"&&(s[o]=i.config[o]);if(s.componentName==="lm-react-component"&&(s.type="react-component"),i.contentItems.length){s.content=[];for(let o=0;o<i.contentItems.length;o++)s.content[o]={},n(s.content[o],i.contentItems[o])}};e?n(t,{contentItems:[e]}):n(t,this.root),this._$reconcilePopoutWindows(),t.openPopouts=[];for(let s=0;s<this.openPopouts.length;s++)t.openPopouts.push(this.openPopouts[s].toConfig());return t.maximisedItemId=this._maximisedItem?"__glMaximised":void 0,t}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){me(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 br,this.transitionIndicator=new Bu,this.updateSize(),this._create(this.config),this._bindEvents(),this.isInitialised=!0,this._adjustColumnsResponsive(),this.emit("initialised")}updateSize(e,t){this.width=e??this.container.width()??0,this.height=t??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(),me(window).off("resize",this._onResize),me(window).off("unload beforeunload",this._onUnload),me(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,t){var n,s;if(typeof e.type!="string")throw new ii("Missing parameter 'type'",e);if(e.type==="react-component"&&(e.type="component",e.componentName="lm-react-component"),!this._typeToItem[e.type])throw n="Unknown type '"+e.type+"'. Valid types are "+Object.keys(this._typeToItem).join(","),new ii(n);return e.type==="component"&&!(t instanceof Cl)&&t&&!(this.isSubWindow===!0&&t instanceof fl)&&(e={type:"stack",width:e.width,height:e.height,content:[e]}),s=new this._typeToItem[e.type](this,e,t),s}createPopout(e,t,n,s){let i=[];const o=e instanceof pt,a=this;if(o){i=this.toConfig(e).content,n=Jl();let c=e.parent,h=e;for(;c?.contentItems.length===1&&!c.isRoot;)h=c,c=c.parent;c?.addId(n),(s==null||Number.isNaN(s))&&(s=c?.contentItems.indexOf(h))}else e instanceof Array?i=e:i=[e];if(!t&&o){const c=window.screenX||window.screenLeft,h=window.screenY||window.screenTop,u=e.element.offset()??{left:0,top:0};t={left:c+u.left,top:h+u.top,width:e.element.width()??0,height:e.element.height()??0}}if(!t&&!o&&(t={left:window.screenX||window.screenLeft+20,top:window.screenY||window.screenTop+20,width:500,height:309}),o&&e.remove(),!t||!n||s===void 0)return;const r=new Lu(i,t,n,s,this);return r.on("initialised",function(){a.emit("windowOpened",r)}),r.on("closed",function(){a._$reconcilePopoutWindows()}),this.openPopouts.push(r),r}createDragSource(e,t){this.config.settings.constrainDragToContainer=!1;var n=new Pu(e,t,this);return this._dragSources.push(n),n}createDragSourceFromEvent(e,t){return this.config.settings.constrainDragToContainer=!1,new _u(e,this,t)}selectItem(e,t){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&&t!==!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,t){let n=1/0,s=null;for(let i=0;i<this._itemAreas.length;i++){const o=this._itemAreas[i];e>o.x1&&e<o.x2&&t>o.y1&&t<o.y2&&n>o.surface&&(n=o.surface,s=o)}return s}_$createRootItemAreas(){const t={...this.root._$getArea()},n=[{...t,side:"left",x2:t.x1+50},{...t,side:"right",x1:t.x2-50},{...t,side:"top",y2:t.y1+50},{...t,side:"bottom",y1:t.y2-50}];n.forEach(s=>{s.surface=(s.x2-s.x1)*(s.y2-s.y1)}),this._itemAreas.push(...n)}_$calculateItemAreas(){const e=this._getAllContentItems();if(this._itemAreas=[],e.length===1){this._itemAreas.push(this.root._$getArea());return}this._$createRootItemAreas();for(let t=0;t<e.length;t++){const n=e[t];if(!Io(n))continue;const s=n._$getArea();if(s!==null)if(s instanceof Array)this._itemAreas=this._itemAreas.concat(s);else{this._itemAreas.push(s);let i={...s,...s.contentItem._contentAreaDimensions?.header.highlightArea};i.surface=(i.x2-i.x1)*(i.y2-i.y1),this._itemAreas.push(i)}}}_$normalizeContentItem(e,t){if(!e)throw new Error("No content item defined");if(typeof e=="function"&&(e=e()),e instanceof pt)return e;if(me.isPlainObject(e)&&e.type){var n=this.createContentItem(e,t);return n.callDownwards("_$init"),n}else throw new Error("Invalid contentItem")}_$reconcilePopoutWindows(){const e=[];for(let t=0;t<this.openPopouts.length;t++)this.openPopouts[t].getWindow()?.closed===!1?e.push(this.openPopouts[t]):this.emit("windowClosed",this.openPopouts[t]);this.openPopouts.length!==e.length&&(this.emit("stateChanged"),this.openPopouts=e)}_getAllContentItems(){const e=[],t=n=>{if(e.push(n),n.contentItems instanceof Array)for(let s=0;s<n.contentItems.length;s++)t(n.contentItems[s])};return t(this.root),e}_bindEvents(){this._isFullPage&&me(window).resize(this._onResize),me(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 t=ku("gl-window");t&&(this.isSubWindow=!0,e=JSON.parse(localStorage.getItem(t)||"{}"),e=gl(e),localStorage.removeItem(t)),e=me.extend(!0,{},Du,e);var n=function(s){for(var i in s){const o=s[i];i!=="props"&&typeof o=="object"&&o!=null?n(o):i==="type"&&o==="react-component"&&(s.type="component",s.componentName="lm-react-component")}};return n(e),e.settings?.hasHeaders===!1&&(e.dimensions.headerHeight=0),e}_adjustToWindowMode(){var e=me('<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=ec(this.config.content[0].title??""),me("head").append(me("body link, body style, template, .gl_keep")),this.container=me("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 t=this.config.openPopouts[e];this.createPopout(t.content,t.dimensions,t.parentId,t.indexInParent)}}_getContainer(){const e=this._originalContainer?me(this._originalContainer):me("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,me("html, body").css({height:"100%",margin:0,padding:0,overflow:"hidden"})),this.container=e}_create(e){var t;if(!(e.content instanceof Array))throw e.content===void 0?t="Missing setting 'content' on top level of configuration":t="Configuration parameter 'content' must be an array",new ii(t,e);if(e.content.length>1)throw t="Top level content can't contain more then one element.",new ii(t,e);this.root=new fl(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 t=this.config.dimensions.minItemWidth,n=e*t;if(!(this.width==null||n<=this.width)){this._updatingColumnsResponsive=!0;for(var s=Math.max(Math.floor(this.width/t),1),i=e-s,o=this.root.contentItems[0],a=this._findAllStackContainers()[0],r=0;r<i;r++){var c=o.contentItems[o.contentItems.length-1];this._addChildContentItemsToContainer(a,c)}this._updatingColumnsResponsive=!1}}}_useResponsiveLayout(){return this.config.settings&&(this.config.settings.responsiveMode=="always"||this.config.settings.responsiveMode=="onload"&&this._firstLoad)}_addChildContentItemsToContainer(e,t){t.type==="stack"?t.contentItems.forEach(function(n){e.addChild(n),t.removeChild(n,!0)}):t.contentItems.forEach(n=>{this._addChildContentItemsToContainer(e,n)})}_findAllStackContainers(){const e=[];return this._findAllStackContainersRecursive(e,this.root),e}_findAllStackContainersRecursive(e,t){t.contentItems.forEach(n=>{Io(n)?e.push(n):n.isComponent||this._findAllStackContainersRecursive(e,n)})}}const Ob="_lm_root_15d73_3",Ab="_lm_row_15d73_7",Lb="_lm_item_15d73_7",Pb="_lm_content_15d73_11",_b="_lm_dragging_15d73_17",jb="_lm_maximised_15d73_23",Hb="_lm_maximise_placeholder_15d73_30",Vb="_lm_splitter_15d73_34",Bb="_lm_vertical_15d73_41",Ub="_lm_drag_handle_15d73_41",$b="_lm_horizontal_15d73_46",Wb="_lm_header_15d73_56",Gb="_lm_dropdown_open_15d73_63",zb="_lm_controls_15d73_69",Kb="_lm_tabs_15d73_89",qb="_lm_tab_15d73_89",Yb="_lm_title_15d73_104",Xb="_lm_close_tab_15d73_111",Zb="_lm_stack_15d73_120",Qb="_lm_left_15d73_120",Jb="_lm_right_15d73_121",ew="_lm_dragProxy_15d73_125",tw="_lm_items_15d73_148",nw="_lm_tabdropdown_list_15d73_165",sw="_lm_bottom_15d73_192",iw="_lm_drop_tab_placeholder_15d73_207",ow="_lm_tabdropdown_15d73_165",aw="_lm_dropTargetIndicator_15d73_258",rw="_lm_inner_15d73_264",lw="_lm_transition_indicator_15d73_272",cw="_lm_popin_15d73_282",dw="_lm_bg_15d73_297",hw="_lm_icon_15d73_300",uw="_lm_goldenlayout_15d73_304",mw="_lm_selectable_15d73_340",gw="_lm_active_15d73_370",pw="_lm_selected_15d73_388",fw="_lm_keyboard_active_15d73_397",Cw="_lm_popout_15d73_416",Sw="_lm_maximise_15d73_23",bw="_lm_close_15d73_111",ww="_lm_tabnextbutton_15d73_425",vw="_lm_tabpreviousbutton_15d73_428",Tw="_lm_title_before_15d73_544",Ew="_lm_focusin_15d73_568",yw="_lm_window_blur_15d73_573",Rw="_lm_tabdropdown_search_15d73_631",xw="_march_15d73_1",Iw="_app_15d73_712",Dw="_plotly_15d73_721",yd={"tab-height":"28px","drag-border-width":"5px",lm_root:Ob,lm_row:Ab,lm_item:Lb,lm_content:Pb,lm_dragging:_b,lm_maximised:jb,lm_maximise_placeholder:Hb,lm_splitter:Vb,lm_vertical:Bb,lm_drag_handle:Ub,lm_horizontal:$b,lm_header:Wb,lm_dropdown_open:Gb,lm_controls:zb,lm_tabs:Kb,lm_tab:qb,lm_title:Yb,lm_close_tab:Xb,lm_stack:Zb,lm_left:Qb,lm_right:Jb,lm_dragProxy:ew,lm_items:tw,lm_tabdropdown_list:nw,lm_bottom:sw,lm_drop_tab_placeholder:iw,lm_tabdropdown:ow,lm_dropTargetIndicator:aw,lm_inner:rw,lm_transition_indicator:lw,lm_popin:cw,lm_bg:dw,lm_icon:hw,lm_goldenlayout:uw,lm_selectable:mw,lm_active:gw,lm_selected:pw,lm_keyboard_active:fw,lm_popout:Cw,lm_maximise:Sw,lm_close:bw,lm_tabnextbutton:ww,lm_tabpreviousbutton:vw,lm_title_before:Tw,"editor-unsaved-indicator":"_editor-unsaved-indicator_15d73_548","is-unsaved":"_is-unsaved_15d73_556",lm_focusin:Ew,lm_window_blur:yw,lm_tabdropdown_search:Rw,march:xw,app:Iw,"js-plotly-plot":"_js-plotly-plot_15d73_721",plotly:Dw},Rd=Object.freeze({tabHeight:parseInt(yd["tab-height"],10),dragBorderWidth:parseInt(yd["drag-border-width"],10)}),ms=Z.module("LayoutUtils");function $u(d){return d.componentName!==void 0}function Fi(d){const e=d;return($u(d)&&d.componentName==="lm-react-component"||d.type==="react-component")&&e.component!==void 0}function oa(d){return d.focus!==void 0}function xd(d){return d.type==="stack"}class Y{static DEFAULT_FOCUS_SELECTOR="input, select, textarea, button";static activateTab(e,t){const n=Y.getStackForRoot(e,t,!1);if(!n){ms.error("Could not find stack for config",t);return}const s=Y.getContentItemInStack(n,t);s&&n.setActiveContentItem(s)}static isActiveTab(e,t){const n=Y.getStackForRoot(e,t,!1);if(!n)return ms.error("Could not find stack for config",t),!1;const s=Y.getContentItemInStack(n,t);return n.getActiveContentItem()===s}static addStack(e,t=!0){const n=t?"column":"row";if(ju(e)){(e.contentItems==null||e.contentItems.length===0)&&e.addChild({type:n});const o=e.contentItems[0];if(!(t?o.isColumn:o.isRow)){e.removeChild(o,!0),e.addChild({type:n});const r=document.activeElement;e.contentItems[0].addChild(o),r&&r.focus!=null&&r.focus()}return this.addStack(e.contentItems[0],t)}if(e.contentItems.length<2)return e.addChild({type:"stack"}),e.contentItems[e.contentItems.length-1];let s=e.contentItems[e.contentItems.length-1];return(t?s.isRow:s.isColumn)||(e.addChild({type:t?"row":"column"}),e.removeChild(s,!0),e.contentItems[e.contentItems.length-1].addChild(s),s=e.contentItems[e.contentItems.length-1]),this.addStack(s,!t)}static getStackForConfig(e,t={},n=!1){if(n&&Io(e)&&e.contentItems.length===0)return e;if(e.contentItems==null)return null;for(let s=0;s<e.contentItems.length;s+=1){const i=e.contentItems[s];if(i.isComponent&&i.config!=null&&Ac(i.config,t))return e;const o=this.getStackForConfig(i,t,n);if(o)return o}return null}static getStackForRoot(e,t,n=!0,s=!0,i=!0){let o=this.getStackForConfig(e,t);return!o&&s&&(o=this.getStackForConfig(e,{component:t.component},i)),!o&&n&&(o=this.addStack(e)),o}static getStackForComponentTypes(e,t,n=!0,s=!0,i=!0){for(let o=0;o<t.length;o+=1){const a=t[o],r=o===t.length-1,c=Y.getStackForRoot(e,{component:a},n&&r,s,i);if(c)return c}return null}static getContentItemInStack(e,t){if(!e)return null;for(let n=0;n<e.contentItems.length;n+=1){const s=e.contentItems[n];if(s.isComponent&&s.config!=null&&Ac(s.config,t))return s}return null}static dehydrateLayoutConfig(e,t){if(e==null||!e.length)return[];const n=[];for(let s=0;s<e.length;s+=1){const i=e[s],{component:o,content:a}=i;if(o){const r=t(o,i);r!=null?n.push(r):ms.debug2(`dehydrateLayoutConfig: skipping unmapped component "${o}"`)}else if(a){const r={...i,content:Y.dehydrateLayoutConfig(a,t)};n.push(r)}else n.push(i)}return n}static getTabPoint(e){const{tab:t}=e;if(t==null)throw new Error(`Cannot get tab for panel container ${e}`);const n=t.element[0].getBoundingClientRect();return[n.left+n.width*.5,n.bottom-8]}static dropLayoutMinorChange(e){for(let t=0;t<e.length;t+=1){const n=e[t],{content:s}=n;s!==void 0?(xd(n)&&delete n.activeItemIndex,Y.dropLayoutMinorChange(s)):Fi(n)&&n.component==="IrisGridPanel"&&n.props.panelState!=null&&(delete n.id,n.props.panelState.irisGridState.sorts=[],n.props.panelState.irisGridState.quickFilters=[])}}static isEqual(e,t,n=!1){if(n){const s=Y.cloneLayout(e),i=Y.cloneLayout(t);return Y.dropLayoutMinorChange(s),Y.dropLayoutMinorChange(i),it(s,i)}return it(e,t)}static cloneLayout(e){return JSON.parse(JSON.stringify(e))}static hydrateLayoutConfig(e,t){if(e==null||!e.length)return[];const n=[];for(let s=0;s<e.length;s+=1){const i=e[s];if(Fi(i)){const{component:o,props:a={}}=i;n.push({...i,id:i?.id??_e(),props:t(o,a)})}else if(i.content!==void 0){const o=Y.hydrateLayoutConfig(i.content,t);xd(i)&&i.activeItemIndex!=null&&i.activeItemIndex>=o.length&&(ms.warn("Fixing bad activeItemIndex!",i.activeItemIndex,i),i.activeItemIndex=0),n.push({...i,content:o})}else n.push(i)}return n}static openComponent({root:e,config:t,replaceExisting:n=!0,replaceConfig:s=void 0,createNewStack:i=!1,focusElement:o=void 0,dragEvent:a=void 0}={}){const r=document.activeElement,c={...t};if(c.id==null&&(c.id=_e.generate()),a){e?.layoutManager.createDragSourceFromEvent(c,a);return}const h=s||{id:c.id,component:c.component};M(e);const u=i?Y.addStack(e):Y.getStackForRoot(e,h);M(u);const m=Y.getContentItemInStack(u,h);if(o!=null){const g=p=>{ms.debug("Component created, focusing element",o),u.off("componentCreated",g);const{element:C}=p.origin;requestAnimationFrame(()=>{Y.focusElement(C[0],o)})};u.on("componentCreated",g)}if(n&&m){const g=u.contentItems.indexOf(m);u.addChild(c,g+1),u.removeChild(m),u.setActiveContentItem(u.contentItems[g])}else u.addChild(c);o==null&&r&&oa(r)&&r.focus()}static openComponentInStack(e,t,n=!0){const s=document.activeElement,i={id:t.id},o=Y.getContentItemInStack(e,i);if(n&&o&&e){const a=e?.contentItems.indexOf(o);e.addChild(t,a+1),e.removeChild(o),e.setActiveContentItem(e.contentItems[a])}else e?.addChild(t);s&&oa(s)&&s.focus()}static closeComponent(e,t,n){const s=Y.getStackForRoot(e,t,!1,!1,!1);if(!s){ms.warn("Cannot find stack for component, ignoring close",t);return}const i=Y.getContentItemInStack(s,t),o=document.activeElement;i&&(_t(i)?i.container.close(n):s.removeChild(i)),o&&document.contains(o)&&oa(o)&&o.focus()}static renameComponent(e,t,n){const s=Y.getStackForRoot(e,t,!1);if(!s){ms.error("Could not find stack for config",t);return}const i=Y.getContentItemInStack(s,t);i&&i.setTitle(n)}static cloneComponent(e,t){const n=Y.getStackForRoot(e,t,!1);if(!n)return ms.error("Could not find stack for config",t),null;const{props:s={}}=t,i=Y.getPanelComponentState(t),o={type:"react-component",component:t.component,props:{...s,panelState:i},title:`${t.title} Copy`,id:_e.generate()};return Y.openComponentInStack(n,o),o}static getPanelComponentState(e){return $u(e)?e.componentState?.panelState:Fi(e)?e.props?.panelState:null}static makeDefaultLayout(){return{dimensions:{headerHeight:Rd.tabHeight,borderWidth:Rd.dragBorderWidth,borderGrabWidth:10},settings:{showPopoutIcon:!1,showCloseIcon:!1,constrainDragToContainer:!1}}}static getRootFromContainer(e){return e.layoutManager.root}static getComponentConfigFromContainer(e){return e?e.tab!=null&&e.tab.contentItem!=null?e.tab.contentItem.config:e._config:null}static getTitleFromContainer(e){return e!=null&&e.tab!=null&&e.tab.contentItem!=null?e.tab.contentItem.config.title:null}static getTitleFromTab(e){return e!=null&&e.contentItem!=null?e.contentItem.config.title:null}static getIdFromContainer(e){const t=Y.getComponentConfigFromContainer(e);return t?t.id:null}static getIdFromPanel(e){const{glContainer:t}=e.props;return Y.getIdFromContainer(t)}static getComponentNameFromPanel(e){const{glContainer:t}=e.props,n=Y.getComponentConfigFromContainer(t);return n&&Fi(n)?n.component??null:null}static getComponentName(e){const t=e.WrappedComponent?.displayName??e.displayName;if(t==null)throw new Error(`Component displayName not defined ${e}`);return t}static focusElement(e,t=Y.DEFAULT_FOCUS_SELECTOR){if(e==null)return null;const n=e.querySelector(t);return n==null?null:(oa(n)&&n.focus(),n)}static onInitialized(e){return new Promise(t=>{if(e.isInitialised){t();return}const n=()=>{e.off("initialised",n),t()};e.on("initialised",n)})}}const Wu=J.forwardRef((d,e)=>{const t=Y.getComponentNameFromPanel({props:d});return l.jsxs("div",{ref:e,className:"panel-placeholder",children:['Component "',t,'" is not registered.']})});Wu.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 Id(d){return d?.WrappedComponent!==void 0}function Fw(d){return typeof d.id=="string"&&d.layout instanceof Uu&&d.panelManager instanceof Gu&&typeof d.registerComponent=="function"}function Hs(d){if(!Fw(d))throw new Error(`Expected dashboard plugin props, but instead received ${d}`)}const an=Z.module("PanelManager");class Gu{static MAX_CLOSED_PANEL_COUNT=100;layout;hydrateComponent;dehydrateComponent;onPanelsUpdated;closed;openedMap;constructor(e,t=(a,r)=>r,n=(a,r)=>r,s=new Map,i=[],o=()=>{}){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=t,this.dehydrateComponent=n,this.onPanelsUpdated=o,this.openedMap=new Map(s),this.closed=[...i],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(t=>t.component===e)}getOpenedPanels(){return Array.from(this.openedMap.values())}getOpenedPanelConfigs(){return this.getOpenedPanels().map(e=>{const{glContainer:t}=e.props;return Y.getComponentConfigFromContainer(t)})}getOpenedPanelConfigsOfType(e){return this.getOpenedPanelConfigs().filter(t=>t!=null&&Fi(t)&&t.component===e)}getOpenedPanelById(e){return this.openedMap.get(e)}getContainerByPanelId(e){const t=Y.getStackForConfig(this.layout.root,{id:e});return(t&&Y.getContentItemInStack(t,{id:e}))??null}getLastUsedPanel(e){const t=this.getOpenedPanels();for(let n=t.length-1;n>=0;n-=1){const s=t[n];if(e==null||e(s))return s}}getLastUsedPanelOfType(e){return this.getLastUsedPanelOfTypes([e])}getLastUsedPanelOfTypes(e){return this.getLastUsedPanel(t=>e.some(n=>Id(n)&&t instanceof n.WrappedComponent||!Id(n)&&t instanceof n))}updatePanel(e){const t=Y.getIdFromPanel(e);if(t==null){an.error("updatePanel Panel did not have an ID",e);return}an.debug2(`Updating panel ID ${t} in open panels map`),this.openedMap.delete(t),this.openedMap.set(t,e)}removePanel(e){const t=Y.getIdFromPanel(e);if(t==null){an.error("removePanel Panel did not have an ID",e);return}if(!this.openedMap.has(t)){an.error(`Missing panel ID ${t} in open panels map`);return}if(this.openedMap.get(t)!==e){an.debug(`Panel argument doesn't match the open panels map entry for ${t}, removePanel ignored`);return}an.debug2(`Removing panel ID ${t} from open panels map`),this.openedMap.delete(t)}removeClosedPanelConfig(e){const t=this.closed.findIndex(n=>n===e||n.id!=null&&e.id!=null&&n.id===e.id);t>=0&&this.closed.splice(t,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,t){an.debug2("Reopen:",e,t),this.removeClosedPanelConfig(e);const{component:n}=e;let{props:s}=e;s=this.hydrateComponent(n,s);const i={...e,props:s},{root:o}=this.layout;Y.openComponent({root:o,config:i,replaceConfig:t})}handleDeleted(e){an.debug2("Deleted:",e),this.removeClosedPanelConfig(e),this.sendUpdate()}handleClosed(e,t){an.debug2("Closed: ",e),this.addClosedPanel(t),this.sendUpdate()}handleControlClose(e){const t={id:e},{root:n}=this.layout;Y.closeComponent(n,t)}addClosedPanel(e){const t=Y.getComponentConfigFromContainer(e);if(t&&Fi(t)){const n=this.dehydrateComponent(t.component,t);n!=null&&this.closed.push(n)}}sendUpdate(){const{closed:e,openedMap:t}=this;this.onPanelsUpdated({closed:[...e],openedMap:new Map(t)})}}const Nw=Z.module("PanelErrorBoundary");class Mw extends b.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){this.setState({error:e})}componentWillUnmount(){const{glContainer:e,glEventHub:t}=this.props,n=Y.getIdFromContainer(e);Nw.debug("componentWillUnmount",n),t.emit(Ee.CLOSED,n,e)}render(){const{children:e}=this.props,{error:t}=this.state;return t!=null?l.jsx("div",{className:"panel-error-boundary",children:l.jsx(sr,{errorMessage:`${t}`,isLoading:!1,isLoaded:!1})}):e}}function sc(d){const{props:e,componentState:t}=d,{metadata:n}=e;let{panelState:s=null}=e;t&&({panelState:s}=t);const i={};return n!=null&&(i.metadata=n),s!=null&&(i.panelState=s),{...d,componentState:null,props:i,type:"react-component"}}function ic(d,e=""){return{metadata:{},...d,localDashboardId:e}}const Sl={dehydrate:sc,hydrate:ic},kw=I.shape({on:I.func,off:I.func,isHidden:I.bool,tab:I.shape({header:I.shape({tabs:I.arrayOf(I.shape({contentItem:I.shape({})}))})}),title:I.string,setTitle:I.func,close:I.func}),zu=I.shape({on:I.func,off:I.func,emit:I.func}),Ow=I.shape({registerComponent:I.func,root:I.shape({addChild:I.func}),on:I.func,off:I.func,eventHub:zu}),oc=Object.freeze({Container:kw,EventHub:zu,Layout:Ow}),We=(d,e,t)=>b.useEffect(function(){return d.on(e,t),()=>{d.off(e,t)}},[d,e,t]),Ku="SET_DASHBOARD_DATA",Aw=sb(Ku,{},!1),Lw={dashboardData:Aw},Pw=new Map,_w=Object.freeze({}),jw=Object.freeze([]),Hw=d=>d.dashboardData,$t=(d,e)=>Hw(d)[e]??_w,Vw=(d,e)=>$t(d,e).closed??jw,qu=(d,e)=>$t(d,e).openedMap??Pw,Yu=(d,e)=>({type:Ku,id:d,payload:e}),Hn=(d,e)=>(t,n)=>t(Yu(d,{...$t(n(),d),...e}));Object.entries(Lw).map(([d,e])=>Zi.register(d,e));const aa=Z.module("DashboardLayout"),Bw=Object.freeze({}),Uw=[],Dd=()=>{},Fd=d=>d;function Xu({id:d,children:e,emptyDashboard:t=l.jsx("div",{children:"Dashboard is empty."}),layout:n,layoutConfig:s=Uw,onLayoutChange:i=Dd,onLayoutInitialized:o=Dd,hydrate:a=ic,dehydrate:r=sc}){const c=Dl(),h=qm(A=>$t(A,d))??Bw,[u,m]=b.useState(!1),[g,p]=b.useState(!1),[C,f]=b.useState(),[S]=b.useState(h?.closed??[]),[v,w]=b.useState(!1),T=b.useMemo(()=>new Map,[]),y=b.useMemo(()=>new Map,[]),E=Ym(),D=b.useCallback((A,H,K=a,q=r)=>{aa.debug2("registerComponent",A,H,K,q);function oe(ne,ae){const ce=H,{glContainer:te,glEventHub:re}=ne;return l.jsx(Eh,{store:E,children:l.jsx(Mw,{glContainer:te,glEventHub:re,children:l.jsx(ce,{...ne,ref:ae})})})}const W=J.forwardRef(oe),G=n.registerComponent(A,W);return T.set(A,K),y.set(A,q),G},[a,r,T,y,n,E]),F=b.useCallback((A,H)=>(T.get(A)??Fd)(H,d),[T,d]),N=b.useCallback((A,H)=>(y.get(A)??Fd)(H,d),[y,d]),_=b.useMemo(()=>new Gu(n,F,N,new Map,S,({closed:A,openedMap:H})=>{c(Hn(d,{closed:A,openedMap:H}))}),[N,c,F,d,S,n]),P=b.useCallback(()=>{if(g)return;v||(o(),w(!0));const H=n.toConfig().content,K=Y.dehydrateLayoutConfig(H,N),q=C==null||!Y.isEqual(C,K);aa.debug("handleLayoutStateChanged",q,H,K),q&&(m(n.root.contentItems.length===0),f(K),i(K))},[N,v,g,C,n,i,o]),U=b.useCallback(A=>{const H=Y.getIdFromContainer(A);n.eventHub.emit(Ee.DRAGGING,H),p(!0)},[n.eventHub]),O=b.useCallback(A=>{const H=Y.getIdFromContainer(A);n.eventHub.emit(Ee.DROPPED,H),p(!1)},[n.eventHub]),j=b.useCallback(A=>{if(aa.debug2("handleComponentCreated",A),A==null||A.config==null||A.config.component==null||A.element==null)return;const K=`${A.config.component.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}-component`;A.element.addClass(K)},[]);We(n,"stateChanged",P),We(n,"itemPickedUp",U),We(n,"itemDropped",O),We(n,"componentCreated",j),We(n.eventHub,Ee.TITLE_CHANGED,P);const k=lr(s);return b.useEffect(function(){if(k!==s&&s!==C){aa.debug("Setting new layout content...");const H=Y.hydrateLayoutConfig(s,F);for(;n.root.contentItems.length>0;)n.root.contentItems[0].remove();for(let K=0;K<H.length;K+=1)n.root.addChild(H[K]);m(n.root.contentItems.length===0)}},[F,n,s,C,_,k]),l.jsxs(l.Fragment,{children:[u&&t,J.Children.map(e,A=>A!=null?J.cloneElement(A,{id:d,layout:n,panelManager:_,registerComponent:D}):null)]})}Xu.propTypes={id:I.string.isRequired,children:I.node,data:I.shape({}),emptyDashboard:I.node,layout:oc.Layout.isRequired,layoutConfig:I.arrayOf(I.shape({})),onLayoutChange:I.func,onLayoutInitialized:I.func};const $w=100,Ur=()=>{},Ww=Object.freeze({});function Gw({id:d="default",children:e,emptyDashboard:t,layoutConfig:n,layoutSettings:s=Ww,onLayoutConfigChange:i=Ur,onGoldenLayoutChange:o=Ur,onLayoutInitialized:a=Ur,fallbackComponent:r=Wu,hydrate:c,dehydrate:h}){const u=b.useRef(null),[m,g]=b.useState(!1),[p,C]=b.useState();b.useEffect(function(){if(!u.current){C(void 0);return}const v={...Y.makeDefaultLayout()};v.settings===void 0&&(v.settings={}),Object.assign(v.settings,s),v.content=[];const w=new Uu(v,u.current),T=()=>{w.off("initialised",T),g(!0)};return w.on("initialised",T),r!=null&&w.setFallbackComponent(r),w.init(),C(w),o(w),()=>{w.destroy()}},[s,r,o,g,C]);const f=b.useMemo(()=>Ls(()=>{p!=null&&p.isInitialised&&p?.updateSize()},$w),[p]);return b.useEffect(function(){return window.addEventListener("resize",f),()=>{window.removeEventListener("resize",f)}},[f]),l.jsxs("div",{className:"dashboard-container w-100 h-100",children:[l.jsx("div",{className:"w-100 h-100",ref:u}),m&&p&&l.jsx(Xu,{emptyDashboard:t,id:d,layout:p,layoutConfig:n,onLayoutChange:i,onLayoutInitialized:a,hydrate:c,dehydrate:h,children:e})]})}const Tn="default";class Zu extends Error{isAssertionFailed=!0}function Nd(d){if(d==null)throw new Zu(`Expected 'val' to be defined, but received ${d}`)}class $r extends Error{isPasteError=!0}function Ze(d){return d?.isEditable!==void 0}function Md(d){if(!Ze(d))throw new Zu(`Expected 'model' to be editable, but received ${d}`)}function qe(d){return d?.hasExpandableRows!==void 0}var En=(d=>(d.DOWN="DOWN",d.UP="UP",d.LEFT="LEFT",d.RIGHT="RIGHT",d))(En||{});class z{startColumn;startRow;endColumn;endRow;static SELECTION_DIRECTION=En;static normalize(e,t,n,s){let i=e,o=t,a=n,r=s;return i!=null&&a!=null&&a<i&&(i=a,a=e),o!=null&&r!=null&&r<o&&(o=r,r=t),[i,o,a,r]}static makeNormalized(e,t,n,s){return new z(...z.normalize(e,t,n,s))}static makeCell(e,t){return new z(e,t,e,t)}static makeColumn(e){return new z(e,null,e,null)}static makeRow(e){return new z(null,e,null,e)}static minOrNull(e,t){return e==null||t==null?null:Math.min(e,t)}static maxOrNull(e,t){return e==null||t==null?null:Math.max(e,t)}static consolidate(e){const t=e.slice();let n=!0;for(;n;){n=!1;for(let s=0;s<t.length&&!n;s+=1){const i=t[s];for(let o=t.length-1;o>s;o-=1){const a=t[o];if(i.contains(a))t.splice(o,1);else if(a.contains(i)){n=!0,t[s]=a,t.splice(o,1);break}else if(i.startRow===a.startRow&&i.endRow===a.endRow){if(i.touches(a)){const{startRow:r,endRow:c}=i,h=z.minOrNull(i.startColumn,a.startColumn),u=z.maxOrNull(i.endColumn,a.endColumn);n=!0,t[s]=new z(h,r,u,c),t.splice(o,1);break}}else if(i.startColumn===a.startColumn&&i.endColumn===a.endColumn&&i.touches(a)){const{startColumn:r,endColumn:c}=i,h=z.minOrNull(i.startRow,a.startRow),u=z.maxOrNull(i.endRow,a.endRow);n=!0,t[s]=new z(r,h,c,u),t.splice(o,1);break}}}}return t}static isAxisRangeTouching(e,t,n,s){return e==null?t==null||n==null?!0:n<=t+1:t==null?s==null?!0:s>=e-1:n==null?s==null?!0:e<=s+1:s==null?t>=n-1:n>=e-1?n<=t+1:s>=e-1}static rangeArraysEqual(e,t){if(e===t)return!0;if(e==null||t==null||e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(!e[n].equals(t[n]))return!1;return!0}static intersection(e,t){if(e.equals(t))return e;let{startColumn:n,startRow:s,endColumn:i,endRow:o}=e;return n=n!=null&&t.startColumn!=null?Math.max(n,t.startColumn):n??t.startColumn,i=i!=null&&t.endColumn!=null?Math.min(i,t.endColumn):i??t.endColumn,s=s!=null&&t.startRow!=null?Math.max(s,t.startRow):s??t.startRow,o=o!=null&&t.endRow!=null?Math.min(o,t.endRow):o??t.endRow,n!=null&&n>(i??-1)||s!=null&&s>(o??-1)?null:new z(n,s,i,o)}static subtractFromRange(e,t){const n=[],s=z.intersection(e,t);return s==null?[e]:(s.startRow!=null&&(e.startRow==null||e.startRow<s.startRow)&&n.push(new z(e.startColumn,e.startRow,e.endColumn,s.startRow-1)),s.startColumn!=null&&(e.startColumn==null||e.startColumn<s.startColumn)&&n.push(new z(e.startColumn,s.startRow,s.startColumn-1,s.endRow)),s.endColumn!=null&&(e.endColumn==null||e.endColumn>s.endColumn)&&n.push(new z(s.endColumn+1,s.startRow,e.endColumn,s.endRow)),s.endRow!=null&&(e.endRow==null||e.endRow>s.endRow)&&n.push(new z(e.startColumn,s.endRow+1,e.endColumn,e.endRow)),n)}static subtractFromRanges(e,t){const n=[];for(let s=0;s<e.length;s+=1)n.push(...z.subtractFromRange(e[s],t));return n}static subtractRangesFromRanges(e,t){let n=[...e];for(let s=0;s<t.length;s+=1)n=z.subtractFromRanges(n,t[s]);return n}static isBounded(e){return e.startRow!=null&&e.startColumn!=null&&e.endRow!=null&&e.endColumn!=null}static boundedRange(e,t,n){return z.isBounded(e)?e:new z(e.startColumn??0,e.startRow??0,e.endColumn??t-1,e.endRow??n-1)}static boundedRanges(e,t,n){return e.map(s=>z.boundedRange(s,t,n))}static offset(e,t,n){return new z(e.startColumn!=null?e.startColumn+t:null,e.startRow!=null?e.startRow+n:null,e.endColumn!=null?e.endColumn+t:null,e.endRow!=null?e.endRow+n:null)}static nextCell(e,t=null,n=null,s=z.SELECTION_DIRECTION.DOWN){if(e.length===0)return null;let i=-1;if(t!=null&&n!=null&&(i=e.findIndex(o=>o.containsCell(t,n)),i>=0)){const a=e[i].nextCell(t,n,s);if(a!=null)return a}switch(s){case z.SELECTION_DIRECTION.DOWN:case z.SELECTION_DIRECTION.RIGHT:{const o=i<e.length-1?i+1:0;return e[o].startCell(s)}case z.SELECTION_DIRECTION.LEFT:case z.SELECTION_DIRECTION.UP:{const o=i>0?i-1:e.length-1;return e[o].startCell(s)}default:throw new Error(`Invalid direction: ${s}`)}}static cellCount(e){return e.reduce((t,n)=>t+((n.endRow??NaN)-(n.startRow??NaN)+1)*((n.endColumn??NaN)-(n.startColumn??NaN)+1),0)}static rowCount(e){return e.reduce((t,n)=>t+(n.endRow??NaN)-(n.startRow??NaN)+1,0)}static columnCount(e){return e.reduce((t,n)=>t+(n.endColumn??NaN)-(n.startColumn??NaN)+1,0)}static containsCell(e,t,n){for(let s=0;s<e.length;s+=1)if(e[s].containsCell(t,n))return!0;return!1}static forEachCell(e,t,n=z.SELECTION_DIRECTION.RIGHT){for(let s=0;s<e.length;s+=1)e[s].forEach(t,n)}constructor(e,t,n,s){this.startColumn=e,this.startRow=t,this.endColumn=n,this.endRow=s}equals(e){return this.startColumn===e.startColumn&&this.startRow===e.startRow&&this.endColumn===e.endColumn&&this.endRow===e.endRow}contains(e){return(this.startColumn==null||e.startColumn!=null&&this.startColumn<=e.startColumn)&&(this.startRow==null||e.startRow!=null&&this.startRow<=e.startRow)&&(this.endColumn==null||e.endColumn!=null&&this.endColumn>=e.endColumn)&&(this.endRow==null||e.endRow!=null&&this.endRow>=e.endRow)}containsCell(e,t){return e==null||t==null?!1:(this.startColumn==null||this.startColumn<=e)&&(this.endColumn==null||this.endColumn>=e)&&(this.startRow==null||this.startRow<=t)&&(this.endRow==null||this.endRow>=t)}touches(e){return z.isAxisRangeTouching(this.startRow,this.endRow,e.startRow,e.endRow)&&z.isAxisRangeTouching(this.startColumn,this.endColumn,e.startColumn,e.endColumn)}subtract(e){return z.subtractFromRange(this,e)}startCell(e=z.SELECTION_DIRECTION.DOWN){if(!z.isBounded(this))throw new Error("Cannot get the startCell of an unbounded range");switch(e){case z.SELECTION_DIRECTION.DOWN:case z.SELECTION_DIRECTION.RIGHT:return{column:this.startColumn,row:this.startRow};case z.SELECTION_DIRECTION.LEFT:case z.SELECTION_DIRECTION.UP:return{column:this.endColumn,row:this.endRow};default:throw new Error(`Invalid direction: ${e}`)}}nextCell(e,t,n){if(!z.isBounded(this))throw new Error("Bounded range required");if(e==null||t==null)throw new Error("Require a non-null cursor");const{startColumn:s,endColumn:i,startRow:o,endRow:a}=this;switch(n){case z.SELECTION_DIRECTION.DOWN:if(t<a)return{column:e,row:Math.max(t+1,o)};if(e<i)return{column:Math.max(e+1,s),row:o};break;case z.SELECTION_DIRECTION.UP:if(t>o)return{column:e,row:Math.min(t-1,a)};if(e>s)return{column:Math.min(e-1,i),row:a};break;case z.SELECTION_DIRECTION.RIGHT:if(e<i)return{column:Math.max(e+1,s),row:t};if(t<a)return{column:s,row:Math.max(t+1,o)};break;case z.SELECTION_DIRECTION.LEFT:if(e>s)return{column:Math.min(e-1,i),row:t};if(t>o)return{column:i,row:Math.min(t-1,a)};break;default:throw new Error(`Invalid direction: ${n}`)}return null}forEach(e,t=z.SELECTION_DIRECTION.RIGHT){let n=0,{column:s,row:i}=this.startCell(t);for(;s!=null&&i!=null;)e(s,i,n),n+=1,{column:s,row:i}=this.nextCell(s,i,t)??{}}}function zw(d){return Array.isArray(d)&&d.length===2&&(d[0]===null||typeof d[0]=="number")&&(d[1]===null||typeof d[1]=="number")}function ra(d){return zw(d)&&d[0]!=null&&d[1]!=null}function Ba(d){return d?.href!==void 0}class V{static PIXELS_PER_LINE=100/3;static getGridPointFromXY(e,t,n){const s=V.getColumnAtX(e,n),i=V.getRowAtY(t,n),o=V.getColumnHeaderDepthAtY(t,n);return{x:e,y:t,row:i,column:s,columnHeaderDepth:o}}static getCellInfoFromXY(e,t,n){const{row:s,column:i}=V.getGridPointFromXY(e,t,n),{allColumnWidths:o,allRowHeights:a,allColumnXs:r,allRowYs:c,modelColumns:h,modelRows:u}=n,m=s!==null?u.get(s):null,g=i!==null?h.get(i):null,p=i!==null?r.get(i):null,C=s!==null?c.get(s):null,f=i!==null?o.get(i):null,S=s!==null?a.get(s):null;return{row:s,column:i,modelRow:m??null,modelColumn:g??null,left:p??null,top:C??null,columnWidth:f??null,rowHeight:S??null}}static getColumnHeaderDepthAtY(e,t){const n=V.getRowAtY(e,t),{columnHeaderHeight:s,columnHeaderMaxDepth:i}=t;if(n===null&&e<=s*i)return He(i-Math.ceil(e/s),0,i-1)}static iterateFloatingStart(e,t,n){for(let s=0;s<e&&s<t;s+=1){const i=n(s);if(i!==void 0)return i}}static iterateFloatingEnd(e,t,n){for(let s=0;s<e&&t-(e-s)>=0;s+=1){const i=n(t-(e-s));if(i!==void 0)return i}}static iterateFloating(e,t,n,s){const i=V.iterateFloatingStart(e,n,s);return i!==void 0?i:V.iterateFloatingEnd(t,n,s)}static iterateAllItems(e,t,n,s,i,o){const a=Math.max(e,n),r=Math.min(t,i-s-1);let c=V.iterateFloating(n,s,i,o);if(c!==void 0)return c;for(let h=a;h<=r;h+=1)if(c=o(h),c!==void 0)return c}static isInItem(e,t,n,s){const i=t.get(e)??0,o=n.get(e)??0;return i<=s&&s<=i+o}static getItemAtOffset(e,t,n,s,i,o,a,r=!1){const c=r?void 0:V.iterateFloating(n,s,t,h=>{if(V.isInItem(h,o,a,e))return h});if(!r&&c!==void 0)return c;for(let h=0;h<i.length;h+=1){const u=i[h];if(V.isInItem(u,o,a,e))return u}return null}static getColumnAtX(e,t,n=!1){const{columnCount:s,floatingLeftColumnCount:i,floatingRightColumnCount:o,visibleColumns:a,allColumnXs:r,allColumnWidths:c,gridX:h}=t;return e<h?null:this.getItemAtOffset(e-h,s,i,o,a,r,c,n)}static getRowAtY(e,t){const{floatingTopRowCount:n,floatingBottomRowCount:s,rowCount:i,visibleRows:o,allRowYs:a,allRowHeights:r,gridY:c}=t;return e<c?null:this.getItemAtOffset(e-c,i,n,s,o,a,r)}static getNextShownItem(e,t,n,s){let i=n.findIndex(o=>o===e)||0;for(i-=1;i!=null&&i>=0;){const o=n[i],a=t.get(o);if(a!=null&&s.get(a)!==0)return o;i-=1}return null}static getNextShownColumn(e,t){const{modelColumns:n,visibleColumns:s,userColumnWidths:i}=t;return V.getNextShownItem(e,n,s,i)}static getNextShownRow(e,t){const{modelRows:n,visibleRows:s,userRowHeights:i}=t;return V.getNextShownItem(e,n,s,i)}static getColumnSeparatorIndex(e,t,n,s){const{rowHeaderWidth:i,columnHeaderHeight:o,floatingColumns:a,floatingLeftWidth:r,visibleColumns:c,allColumnXs:h,allColumnWidths:u,columnHeaderMaxDepth:m}=n,{allowColumnResize:g,headerSeparatorHandleSize:p}=s;if(m*o<t||!g||p<=0)return null;const C=e-i,f=p*.5;let S=!1;for(let v=a.length-1;v>=0;v-=1){const w=a[v],T=h.get(w)??0,y=u.get(w)??0,E=y===0;if(!S||!E){let D=T+y;E?D+=f:S&&(D-=f);const F=D-f,N=D+f;if(F<=C&&C<=N)return w;S=E}}S=!1;for(let v=c.length-1;v>=0;v-=1){const w=c[v],T=h.get(w)??0,y=u.get(w)??0,E=y===0;if(T<r-y)return null;if(!S||!E){let D=T+y;E?D+=f:S&&(D-=f);const F=D-f,N=D+f;if(F<=C&&C<=N)return w;S=E}}return null}static isItemHidden(e,t){return t.get(e)===0}static isColumnHidden(e,t){const{allColumnWidths:n}=t;return V.isItemHidden(e,n)}static isFloatingRow(e,t){if(e==null)return!1;const{floatingTopRowCount:n,floatingBottomRowCount:s,rowCount:i}=t;return e<n||e>=i-s}static isFloatingColumn(e,t){if(e==null)return!1;const{floatingLeftColumnCount:n,floatingRightColumnCount:s,columnCount:i}=t;return e<n||e>=i-s}static getHiddenItems(e,t,n){if(!V.isItemHidden(e,t))return[];const s=[e],i=n.findIndex(o=>o===e);for(let o=i-1;o>=0;o-=1){const a=n[o];if(!V.isItemHidden(a,t))break;s.push(a)}return s}static getHiddenColumns(e,t){const{visibleColumns:n,allColumnWidths:s}=t;return V.getHiddenItems(e,s,n)}static getRowSeparatorIndex(e,t,n,s){const{rowHeaderWidth:i,columnHeaderHeight:o,visibleRows:a,allRowYs:r,allRowHeights:c}=n,{allowRowResize:h,headerSeparatorHandleSize:u}=s;if(i<e||!h||u<=0)return null;const m=t-o,g=u*.5;let p=!1;for(let C=a.length-1;C>=0;C-=1){const f=a[C],S=r.get(f)??0,v=c.get(f)??0,w=v===0;if(!p||!w){let T=S+v;w?T+=g:p&&(T-=g);const y=T-g,E=T+g;if(y<=m&&m<=E)return f;p=w}}return null}static isRowHidden(e,t){const{allRowHeights:n}=t;return V.isItemHidden(e,n)}static getHiddenRows(e,t){const{visibleRows:n,allRowHeights:s}=t;return V.getHiddenItems(e,s,n)}static moveItem(e,t,n){if(e===t)return[...n];const s=[...n],i=s[s.length-1];return i!=null&&!ra(i.from)&&i.to===e?i.from===t?s.pop():s[s.length-1]={...i,to:t}:s.push({from:e,to:t}),s}static moveRange(e,t,n,s=!1){if(e[0]===e[1])return V.moveItem(e[0],t,n);let i=t;if(s&&e[0]<t&&(i-=e[1]-e[0]),e[0]===i)return[...n];const o=[...n],a=o[o.length-1];a!=null&&ra(a.from)&&a.from[1]-a.from[0]===e[1]-e[0]&&a.to===e[0]?o[o.length-1]={...a,to:i}:o.push({from:e,to:i});const r=o[o.length-1];return ra(r.from)&&r.from[0]===r.to&&o.pop(),o}static moveItemOrRange(e,t,n,s=!1){return Array.isArray(e)?V.moveRange(e,t,n,s):V.moveItem(e,t,n)}static applyItemMoves(e,t,n,s=!1){let i=[[e,t]];for(let o=s?n.length-1:0;s?o>=0:o<n.length;s?o-=1:o+=1){const{from:a,to:r}=n[o];let c=1,h;ra(a)?(c=a[1]-a[0]+1,[h]=a):h=a;const u=s?r:h,m=u+c-1,g=s?h:r,p=g-u,C=[];for(let f=0;f<i.length;f+=1){const S=i[f][0]??Number.NEGATIVE_INFINITY,v=i[f][1]??Number.POSITIVE_INFINITY;let w;const T=[[S,u-1],[u,m],[m+1,v]].map(([y,E])=>[Math.max(y,S),Math.min(E,v)]).filter(([y,E])=>y<=E).map(y=>{const[E,D]=y;return u<=E&&m>=D?(w=[E+p,D+p],w):m<E?[E-c,D-c]:y}).map(y=>{const[E,D]=y;return g>E&&g<=D?[[E,g-1],[g+c,D+c]]:y===w?[y]:g<=E?[[E+c,D+c]]:[y]}).flat();C.push(...T)}i=C.map(([f,S])=>[Number.isFinite(f)?f:null,Number.isFinite(S)?S:null])}return i}static translateRange(e,t,n,s){const i=V.applyItemMoves(e.startColumn,e.endColumn,t,s),o=V.applyItemMoves(e.startRow,e.endRow,n,s),a=[];for(let r=0;r<i.length;r+=1){const c=i[r];for(let h=0;h<o.length;h+=1){const u=o[h];a.push(new z(c[0],u[0],c[1],u[1]))}}return a}static getModelIndex(e,t){return V.applyItemMoves(e,e,t,!0)[0][0]}static getModelIndexes(e,t){return e.map(n=>V.getModelIndex(n,t))}static getModelRangeIndexes(e,t,n){return V.applyItemMoves(e,t,n,!0)}static getModelRange(e,t=Fe,n=Fe){return V.translateRange(e,t,n,!0)}static getModelRanges(e,t=Fe,n=Fe){const s=[];for(let i=0;i<e.length;i+=1)s.push(...V.getModelRange(e[i],t,n));return s}static getVisibleRangeIndexes(e,t,n){return V.applyItemMoves(e,t,n,!1)}static getVisibleRange(e,t=Fe,n=Fe){return this.translateRange(e,t,n,!1)}static getVisibleRanges(e,t=Fe,n=Fe){const s=[];for(let i=0;i<e.length;i+=1)s.push(...V.getVisibleRange(e[i],t,n));return s}static getVisibleIndex(e,t){return V.applyItemMoves(e,e,t)[0][0]}static getVisibleIndexes(e,t){return e.map(n=>V.getVisibleIndex(n,t))}static isMacPlatform(){const{platform:e}=window.navigator;return e.startsWith("Mac")}static getModifierKey(){return V.isMacPlatform()?"metaKey":"ctrlKey"}static isModifierKeyDown(e){const t=V.getModifierKey();return e[t]}static checkColumnHidden(e,t){return t.get(e)===0}static checkAllColumnsHidden(e,t){return t.size===0?!1:e.every(n=>t.get(n)===0)}static getScrollDragBounds(e,t,n){const{gridX:s,gridY:i,width:o,height:a,floatingTopRowCount:r,floatingBottomRowCount:c,floatingLeftColumnCount:h,floatingRightColumnCount:u,floatingLeftWidth:m,floatingRightWidth:g,floatingTopHeight:p,floatingBottomHeight:C,columnCount:f,rowCount:S}=e;let v=s,w=i,T=o,y=a;return n!=null&&(n>h&&(v+=m),n<f-u&&(T-=g)),t!=null&&(t>r&&(w+=p),t<S-c&&(y-=C)),{x1:v,y1:w,x2:T,y2:y}}static getScrollDelta(e,t=1024,n=768,s=20,i=20){let{deltaX:o,deltaY:a}=e;return!V.isMacPlatform()&&e.shiftKey&&e.deltaX===0&&e.deltaY!==0&&(o=e.deltaY,a=e.deltaX),e?.deltaMode===WheelEvent.DOM_DELTA_PAGE?(o*=t,a*=n):e?.deltaMode===WheelEvent.DOM_DELTA_LINE&&(V.isMacPlatform()?(o=Math.round(o*s),a=Math.round(a*i)):(o=Math.round(o*this.PIXELS_PER_LINE),a=Math.round(a*this.PIXELS_PER_LINE))),{deltaX:o,deltaY:a}}static compareRanges(e,t){return e[0]==null||e[1]==null||t[0]==null||t[1]==null?0:e[0]!==t[0]?e[0]-t[0]:e[1]-t[1]}static mergeSortedRanges(e){const t=[];for(let n=0;n<e.length;n+=1){const s=e[n],i=s[0],o=s[1];n===0?t.push([i,o]):i-1<=t[t.length-1][1]?t[t.length-1][1]=Math.max(t[t.length-1][1],o):t.push([i,o])}return t}static translateTokenBox(e,t){const{x1:n,y1:s,x2:i,y2:o}=e,{gridX:a,gridY:r,width:c,height:h,verticalBarWidth:u,horizontalBarHeight:m}=t,g=He(a+n,a,c-u),p=He(a+i,a,c-u),C=He(r+s,r,h-m),f=He(r+o,r,h-m);return{x1:g,y1:C,x2:p,y2:f,token:e.token}}}function la(d,e=_o.CACHE_SIZE,t=Math.floor(e/2)){if(d.size>e){const n=d.keys();for(;d.size>t;)d.delete(n.next().value)}}function kd(d,e,t,n,s){const i=new Map;let o=0;for(let a=0;a<d&&a<t;a+=1)i.set(a,o),o+=L(s,a);o=n;for(let a=0;a<e&&t-a-1>=0;a+=1)o-=L(s,t-a-1),i.set(t-a-1,o);return i}class _o{static CACHE_SIZE=1e4;static MAX_COLUMN_WIDTH=.8;initialRowHeights;initialColumnWidths;userColumnWidths;userRowHeights;calculatedColumnWidths;calculatedRowHeights;fontWidths;modelRows;modelColumns;movedRows;movedColumns;constructor({userColumnWidths:e=new Map,userRowHeights:t=new Map,calculatedColumnWidths:n=new Map,calculatedRowHeights:s=new Map,fontWidths:i=new Map,modelRows:o=new Map,modelColumns:a=new Map,movedRows:r=[],movedColumns:c=[],initialRowHeights:h=new Map,initialColumnWidths:u=new Map}={}){this.userColumnWidths=e,this.userRowHeights=t,this.calculatedRowHeights=s,this.calculatedColumnWidths=n,this.fontWidths=i,this.modelRows=o,this.modelColumns=a,this.movedRows=r,this.movedColumns=c,this.initialRowHeights=h,this.initialColumnWidths=u}getMetrics(e){const{left:t,top:n,leftOffset:s,topOffset:i,width:o,height:a,theme:r,model:c,movedRows:h,movedColumns:u,draggingColumn:m}=e,{rowHeight:g,rowHeaderWidth:p,rowFooterWidth:C,columnWidth:f,columnHeaderHeight:S,minScrollHandleSize:v,scrollBarSize:w}=r;h!==this.movedRows&&(this.movedRows=h,this.modelRows.clear()),u!==this.movedColumns&&(this.movedColumns=u,this.modelColumns.clear());const{columnCount:T,rowCount:y,floatingTopRowCount:E,floatingBottomRowCount:D,floatingLeftColumnCount:F,floatingRightColumnCount:N,columnHeaderMaxDepth:_}=c,P=this.getFirstRow(e),U=this.getFirstColumn(e),O=this.getGridX(e),j=this.getGridY(e),k=qe(c)&&c.hasExpandableRows?this.calculateTreePaddingX(e):0,A=0,H=this.getVisibleRowHeights(e),K=this.getVisibleColumnWidths(e,U,k),q=Array.from(H.keys()),oe=Array.from(K.keys()),W=new Map([...H,...this.getFloatingRowHeights(e)]),G=new Map([...K,...this.getFloatingColumnWidths(e)]),ne=this.getVisibleColumnXs(G,oe,s),ae=this.getVisibleRowYs(W,q,i),ce=q.length>0?q[q.length-1]:n,te=oe.length>0?oe[oe.length-1]:t,re=this.getBottomViewport(e,q,ae,W),we=this.getRightViewport(e,oe,ne,G),Ie=this.getFloatingTopHeight(e,W),xe=this.getFloatingBottomHeight(e,W),at=this.getFloatingLeftWidth(e,G),xt=this.getFloatingRightWidth(e,G),en=Array.from(G.values()),Rn=Array.from(W.values()),kt=en.reduce((Oe,sn)=>Oe+sn,0)-s,ye=Rn.reduce((Oe,sn)=>Oe+sn,0)-i,ut=s+kt+C,rt=i+ye,bt=o-O,Ot=a-j,xn=this.getLastLeft(e,null,bt-C),tn=this.getLastLeft(e,null,bt-C-w),jo=this.getLastTop(e,null,Ot-xe),Vs=this.getLastTop(e,null,Ot-xe-w);let nn=tn,as=Vs;xn===0&&jo===0&&(nn=0,as=0);const mi=nn>0,eo=mi?w:0,gi=as>0,pi=gi?w:0,Ho=O,Vo=_*S,rs=o-Ho-pi,Bs=a-Vo-eo,xr=T===1?rs/ut:(T-nn)/T,Bo=y===1?Bs/rt:(y-as)/y,to=mi?He(rs*xr,v,rs-1):0,no=gi?He(Bs*Bo,v,Bs-1):0,so=L(G,t,0),Uo=L(W,n,0),Ir=so>0?s/so:0,Dr=Uo>0?i/Uo:0,Fr=T===1?s/(ut-bt):(t+Ir)/nn,Nr=y===1?i/(rt-Ot):(n+Dr)/as,Mr=mi?Fr*(rs-to):0,Us=gi?Nr*(Bs-no):0,$o=[...Array(E).keys(),...[...Array(D).keys()].map(Oe=>y-Oe-1)],fi=new Map([...ae,...this.getFloatingRowYs(e,W,Math.floor(a-j-eo))]),Wo=[...Array(F).keys(),...[...Array(N).keys()].map(Oe=>T-Oe-1)],$s=new Map([...ne,...this.getFloatingColumnXs(e,G,Math.floor(o-O-pi))]),Go=[];if(m)for(let Oe=m.range[0];Oe<=m.range[1];Oe+=1)Go.push(Oe),G.has(Oe)||G.set(Oe,this.getVisibleColumnWidth(Oe,e)),$s.has(Oe)||$s.set(Oe,0);const io=q.concat($o),oo=oe.concat(Wo).concat(Go),zo=this.getModelRows(io,e),Ko=this.getModelColumns(oo,e),qo=this.getVisibleRowTreeBoxes(W,zo,e),kr=this.getTopVisible(e,fi,W,q),Yo=this.getLeftVisible(e,$s,G,oe),Xo=as>0?this.getBottomVisible(e,fi,W,q,j):ce,Zo=nn>0?this.getRightVisible(e,$s,G,oe,O):te,{fontWidths:Qo,userColumnWidths:Jo,userRowHeights:ea,calculatedRowHeights:Or,calculatedColumnWidths:Xe}=this;return{rowHeight:g,rowHeaderWidth:p,rowFooterWidth:C,rowCount:y,columnWidth:f,columnCount:T,columnHeaderHeight:S,floatingTopRowCount:E,floatingBottomRowCount:D,floatingLeftColumnCount:F,floatingRightColumnCount:N,gridX:O,gridY:j,firstRow:P,firstColumn:U,treePaddingX:k,treePaddingY:A,left:t,top:n,bottom:ce,right:te,topOffset:i,leftOffset:s,topVisible:kr,leftVisible:Yo,bottomVisible:Xo,rightVisible:Zo,bottomViewport:re,rightViewport:we,width:o,height:a,maxX:kt,maxY:ye,lastLeft:nn,lastTop:as,barHeight:Bs,barTop:Vo,barWidth:rs,barLeft:Ho,handleHeight:no,handleWidth:to,hasHorizontalBar:mi,hasVerticalBar:gi,verticalBarWidth:pi,horizontalBarHeight:eo,scrollX:Mr,scrollY:Us,scrollableContentWidth:ut,scrollableContentHeight:rt,scrollableViewportWidth:bt,scrollableViewportHeight:Ot,visibleRows:q,visibleColumns:oe,visibleRowHeights:H,visibleColumnWidths:K,floatingRows:$o,floatingColumns:Wo,allRows:io,allColumns:oo,allRowHeights:W,allColumnWidths:G,floatingTopHeight:Ie,floatingBottomHeight:xe,floatingLeftWidth:at,floatingRightWidth:xt,visibleRowYs:ae,visibleColumnXs:ne,allRowYs:fi,allColumnXs:$s,visibleRowTreeBoxes:qo,modelRows:zo,modelColumns:Ko,movedRows:h,movedColumns:u,fontWidths:Qo,userColumnWidths:Jo,userRowHeights:ea,calculatedRowHeights:Or,calculatedColumnWidths:Xe,columnHeaderMaxDepth:_}}getGridX(e){const{theme:t}=e,{rowHeaderWidth:n}=t;return n}getGridY(e){const{theme:t,model:n}=e,{columnHeaderHeight:s}=t,{columnHeaderMaxDepth:i}=n;return i*s}getVisibleHeight(e,t=this.getFloatingRowHeights(e)){const{height:n,theme:s}=e,{scrollBarSize:i}=s,o=this.getGridY(e),a=this.getFloatingBottomHeight(e,t),r=this.getFloatingTopHeight(e,t);return n-a-r-o-i}getVisibleWidth(e,t=this.getFloatingColumnWidths(e)){const{width:n,theme:s}=e,{scrollBarSize:i,rowFooterWidth:o}=s,a=this.getGridX(e),r=this.getFloatingRightWidth(e,t),c=this.getFloatingLeftWidth(e,t);return n-c-r-a-i-o}getFirstIndex(e,t,n){const s=e.size+1;for(let i=0;i<s;i+=1){const o=t(i,n);if(e.get(o)!==0)return i}return 0}getFirstColumn(e){return this.getFirstIndex(this.userColumnWidths,this.getModelColumn.bind(this),e)}getFirstRow(e){return this.getFirstIndex(this.userRowHeights,this.getModelRow.bind(this),e)}getLastLeft(e,t,n){const{model:s}=e,{columnCount:i,floatingRightColumnCount:o}=s;let a=Math.max(0,i-o-1);t!=null&&(a=t);let r=0;for(;a>=0;){const c=this.getVisibleColumnWidth(a,e);if(r+=c,r>=n)return He(a+1,0,t??i-1);a-=1}return 0}getLastTop(e,t,n){const{model:s}=e,{rowCount:i,floatingBottomRowCount:o}=s;let a=Math.max(0,i-o-1);t!=null&&(a=t);let r=0;for(;a>=0;){const c=this.getVisibleRowHeight(a,e);if(r+=c,r>=n)return He(a+1,0,i-1);a-=1}return 0}getTopForTopVisible(e,t){const n=this.getFloatingTopHeight(e);let s=t,i=0;for(;s>0&&i<n;)s-=1,i+=this.getVisibleRowHeight(s,e);return s}getTopForBottomVisible(e,t){const{height:n}=e,s=this.getGridY(e),i=this.getFloatingBottomHeight(e),o=n-s-i;return this.getLastTop(e,t,o)}getLeftForLeftVisible(e,t){const n=this.getFloatingLeftWidth(e);let s=t,i=0;for(;s>0&&i<n;)s-=1,i+=this.getVisibleColumnWidth(s,e);return s}getLeftForRightVisible(e,t){const{width:n}=e,s=this.getGridX(e),i=this.getFloatingRightWidth(e),o=n-s-i;return this.getLastLeft(e,t,o)}getFloatingRowHeights(e){const{model:t}=e,{floatingTopRowCount:n,floatingBottomRowCount:s,rowCount:i}=t,o=new Map;for(let a=0;a<n&&a<i;a+=1)o.set(a,this.getVisibleRowHeight(a,e));for(let a=0;a<s&&i-a-1>=0;a+=1){const r=i-a-1;o.set(r,this.getVisibleRowHeight(r,e))}return o}getVisibleRowHeights(e){const{top:t,topOffset:n,height:s,model:i}=e;let o=0,a=t;const r=new Map,{rowCount:c}=i;for(;o<s+n&&a<c;){const h=this.getVisibleRowHeight(a,e);r.set(a,h),o+=h,a+=1}return r}getFloatingColumnWidths(e,t=this.getFirstColumn(e),n=this.calculateTreePaddingX(e)){const{model:s}=e,{columnCount:i,floatingLeftColumnCount:o,floatingRightColumnCount:a}=s,r=new Map;for(let c=0;c<o&&c<i;c+=1)r.set(c,this.getVisibleColumnWidth(c,e,t,n));for(let c=0;c<a&&i-c-1>=0;c+=1){const h=i-c-1;r.set(h,this.getVisibleColumnWidth(h,e,t,n))}return r}getVisibleColumnWidths(e,t=this.getFirstColumn(e),n=this.calculateTreePaddingX(e)){const{left:s,leftOffset:i,width:o,model:a}=e;let r=0,c=s;const h=new Map,{columnCount:u}=a;for(;r<o+i&&c<u;){const m=this.getVisibleColumnWidth(c,e,t,n);h.set(c,m),r+=m,c+=1}return h}getFloatingColumnXs(e,t,n){const{model:s}=e,{columnCount:i,floatingLeftColumnCount:o,floatingRightColumnCount:a}=s;return kd(o,a,i,n,t)}getVisibleColumnXs(e,t,n){const s=new Map;let i=-n;for(let o=0;o<t.length;o+=1){const a=t[o],r=L(e,a);s.set(a,i),i+=r}return s}getFloatingRowYs(e,t,n){const{model:s}=e,{floatingTopRowCount:i,floatingBottomRowCount:o,rowCount:a}=s;return kd(i,o,a,n,t)}getVisibleRowYs(e,t,n){const s=new Map;let i=-n;for(let o=0;o<t.length;o+=1){const a=t[o],r=L(e,a);s.set(a,i),i+=r}return s}getVisibleRowTreeBoxes(e,t,n){const s=new Map,{model:i,theme:o}=n,{treeDepthIndent:a,treeHorizontalPadding:r}=o;return qe(i)&&i.hasExpandableRows&&e.forEach((c,h)=>{const u=L(t,h);if(i.isRowExpandable(u)){const m=i.depthForRow(u),g=m*a+r,p=(m+1)*a+r,C=0,f=c;s.set(h,{x1:g,y1:C,x2:p,y2:f})}}),s}getFloatingLeftWidth(e,t=this.getFloatingColumnWidths(e)){const{model:n}=e,{floatingLeftColumnCount:s}=n;let i=0;for(let o=0;o<s;o+=1)i+=L(t,o);return i}getFloatingRightWidth(e,t=this.getFloatingColumnWidths(e)){const{model:n}=e,{floatingRightColumnCount:s,columnCount:i}=n;let o=0;for(let a=0;a<s;a+=1)o+=L(t,i-a-1);return o}getFloatingTopHeight(e,t=this.getFloatingRowHeights(e)){const{model:n}=e,{floatingTopRowCount:s}=n;let i=0;for(let o=0;o<s;o+=1)i+=L(t,o);return i}getFloatingBottomHeight(e,t=this.getFloatingRowHeights(e)){const{model:n}=e,{floatingBottomRowCount:s,rowCount:i}=n;let o=0;for(let a=0;a<s;a+=1)o+=L(t,i-a-1);return o}getTopVisible(e,t,n,s){const i=this.getFloatingTopHeight(e,n);for(let o=0;o<s.length;o+=1){const a=s[o];if(L(t,a)>=i)return a}return 0}getLeftVisible(e,t,n,s){const i=this.getFloatingLeftWidth(e,n);for(let o=0;o<s.length;o+=1){const a=s[o];if(L(t,a)>=i)return a}return 0}getBottomVisible(e,t,n,s,i){const{height:o,theme:a}=e,{scrollBarSize:r}=a,c=this.getFloatingBottomHeight(e,n),h=o-i-r-c;for(let u=s.length-1;u>=0;u-=1){const m=s[u],g=L(t,m),p=L(n,m);if(g+p<=h)return m}return 0}getRightVisible(e,t,n,s,i){const{width:o,theme:a}=e,{scrollBarSize:r}=a,c=this.getFloatingRightWidth(e,n),h=o-i-r-c;for(let u=s.length-1;u>=0;u-=1){const m=s[u],g=L(t,m),p=L(n,m);if(g+p<=h)return m}return 0}getBottomViewport(e,t,n,s){const{height:i,theme:o}=e,{rowHeight:a}=o;return this.getLastIndexViewport(t,n,s,i,a)}getRightViewport(e,t,n,s){const{width:i,theme:o}=e,{columnWidth:a}=o;return this.getLastIndexViewport(t,n,s,i,a)}getLastIndexViewport(e,t,n,s,i){let o=0,a=0;return e.length>0&&(o=e[e.length-1],a=L(t,o)+L(n,o)),a<s&&(o+=Math.ceil((s-a)/i)),o}getVisibleItemSize(e,t,n){return t.get(e)??n()}getVisibleRowHeight(e,t){const n=this.getModelRow(e,t),s=this.calculateRowHeight(e,n,t);return this.getVisibleItemSize(n,this.userRowHeights,()=>{const i=this.initialRowHeights.get(n);return i!==void 0?i:s})}getVisibleColumnWidth(e,t,n=this.getFirstColumn(t),s=this.calculateTreePaddingX(t)){const i=this.getModelColumn(e,t),o=this.calculateColumnWidth(e,i,t,n,s);return this.getVisibleItemSize(i,this.userColumnWidths,()=>{const a=this.initialColumnWidths.get(i);return a!==void 0?a:o})}getModelRows(e,t){const n=new Map;for(let s=0;s<e.length;s+=1){const i=e[s],o=this.getModelRow(i,t);n.set(i,o)}return n}getModelRow(e,t){if(this.modelRows.has(e))return L(this.modelRows,e);const{movedRows:n}=t,s=V.getModelIndex(e,n);return this.modelRows.set(e,s),s}getModelColumns(e,t){const n=new Map;for(let s=0;s<e.length;s+=1){const i=e[s],o=this.getModelColumn(i,t);n.set(i,o)}return n}getModelColumn(e,t){if(this.modelColumns.has(e))return L(this.modelColumns,e);const{movedColumns:s}=t,i=V.getModelIndex(e,s);return this.modelColumns.set(e,i),i}calculateRowHeight(e,t,n){const{theme:s}=n,{autoSizeRows:i,rowHeight:o}=s;if(!i)return o;const a=this.calculatedRowHeights.get(t);return a??(this.calculatedRowHeights.set(t,Math.ceil(o)),la(this.calculatedRowHeights),o)}calculateColumnWidth(e,t,n,s=this.getFirstColumn(n),i=this.calculateTreePaddingX(n)){const{theme:o}=n,{autoSizeColumns:a,minColumnWidth:r}=o;if(!a){const{columnWidth:g}=o;return g}const c=this.calculateColumnHeaderWidth(t,n),h=this.calculateColumnDataWidth(t,n),u=this.calculatedColumnWidths.get(t);let m=Math.ceil(Math.max(c,h));return m=Math.max(r,m),u!=null&&u>m?m=u:(this.calculatedColumnWidths.set(t,m),la(this.calculatedColumnWidths)),e===s&&(m+=i),m}calculateColumnHeaderWidth(e,t){const{model:n,theme:s}=t,{headerFont:i,headerHorizontalPadding:o}=s,a=n.textForColumnHeader(e,0);if(a!==void 0&&a!==""){const r=this.getWidthForFont(i,t);return a.length*r+o*2}return o*2}calculateColumnDataWidth(e,t){const{top:n,height:s,width:i,model:o,theme:a}=t,{floatingTopRowCount:r,floatingBottomRowCount:c,rowCount:h}=o,{font:u,cellHorizontalPadding:m,rowHeight:g,rowHeaderWidth:p,rowFooterWidth:C,scrollBarSize:f}=a;let S=0;const v=this.getWidthForFont(u,t),w=s/g,T=Math.ceil(n+w);return V.iterateAllItems(n,T,r,c,h,y=>{const E=this.getModelRow(y,t),D=o.textForCell(e,E);if(D){const F=m*2;S=Math.max(S,D.length*v+F)}}),S=Math.max(Math.min(S,(i-p-f-C)*_o.MAX_COLUMN_WIDTH),m*2),S}calculateTreePaddingX(e){const{top:t,height:n,model:s,theme:i}=e,{rowHeight:o,treeDepthIndent:a}=i;if(!qe(s)||!s.hasExpandableRows)return 0;let r=0;const c=n/o,h=Math.ceil(t+c);for(let u=t;u<=h;u+=1){const m=this.getModelRow(u,e),g=s.depthForRow(m);r=Math.max(r,a*(g+1))}return r}getWidthForFont(e,t){if(this.fontWidths.has(e))return L(this.fontWidths,e);const{context:n}=t;n.font=e;const s=n.measureText("8"),{width:i}=s;return this.fontWidths.set(e,i),this.fontWidths.set(n.font,i),i}setColumnWidth(e,t){const n=new Map(this.userColumnWidths);n.set(e,Math.ceil(t)),la(n),this.userColumnWidths=n}resetColumnWidth(e){const t=new Map(this.userColumnWidths);t.delete(e),this.userColumnWidths=t}setRowHeight(e,t){const n=new Map(this.userRowHeights);n.set(e,Math.ceil(t)),la(n),this.userRowHeights=n}resetRowHeight(e){const t=new Map(this.userRowHeights);t.delete(e),this.userRowHeights=t,this.calculatedRowHeights.delete(e)}}const Kw=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",hyperlinkColor:"#4878ea",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"}),Zn=(d,e)=>{let t=!1;const n=ge(d,{...e,dispose:()=>{t||(t=!0,n.clear(),t=!1)}});return n};function qw(d,e,t=6){const n=al.hex.lab.raw(d);return n[0]=Math.max(n[0]-n[0]/t*e,0),`#${al.lab.hex(n)}`}function Yw(d,e){const[t,n,s]=al.hex.rgb(d);return`rgba(${t}, ${n}, ${s}, ${e})`}const Od={colorWithAlpha:Yw,darkenForDepth:qw};class dt{order;constructor(e=5e3){this.order=e}cursor=null;onDown(e,t,n){return!1}onMove(e,t,n){return!1}onDrag(e,t,n){return!1}onLeave(e,t,n){return!1}onClick(e,t,n){return!1}onContextMenu(e,t,n){return!1}onDoubleClick(e,t,n){return!1}onUp(e,t,n){return!1}onWheel(e,t,n){return!1}}class Qu extends dt{draggingIndex;resizingItems=[];hiddenItems=[];targetSizes=new Map;dragOffset=0;onDown(e,t){const{metrics:n}=t,{model:s}=t.props,i=t.getTheme();if(!n)throw new Error("metrics not set");const o=this.getSeparator(e,n,s,i);if(o!=null){const a=o.index;return this.dragOffset=0,this.draggingIndex=a,this.resizingItems=[a],this.hiddenItems=this.getHiddenItems(a,n).reverse(),this.targetSizes.clear(),this.addTargetSize(n,a),this.updateCursor(n,a),this.updateSeparator(t,o),!0}return!1}onMove(e,t){const{metrics:n}=t,{model:s}=t.props,i=t.getTheme();if(!n)throw new Error("metrics not set");const o=this.getSeparator(e,n,s,i);return o!=null?(this.updateCursor(n,o.index),!0):!1}onDrag(e,t){if(this.draggingIndex==null)return!1;const n=e[this.pointProperty],{metricCalculator:s,metrics:i}=t;if(!i)throw new Error("metrics not set");const o=t.getTheme(),a=i[this.visibleOffsetProperty],r=i[this.marginProperty],c=i[this.calculatedSizesProperty],h=i[this.modelIndexesProperty],u=i[this.firstIndexProperty],m=i[this.treePaddingProperty],g=new Map;let p=this.resizingItems[this.resizingItems.length-1];for(;p!=null;){const C=L(a,p),f=n-r-C-this.dragOffset,S=L(h,p),v=this.targetSizes.get(S),w=this.resizingItems.length>1,T=this.hiddenItems.indexOf(p);let y=L(c,S);p===u&&(y+=m);let E=f;Math.abs(f-y)<=o.headerResizeSnapThreshold?E=y:v!==void 0&&f>v&&(w&&T!==0||T>0)?E=v:f<=o.headerResizeHiddenSnapThreshold&&(E=0),g.set(S,E),f<-o.headerResizeSnapThreshold&&E===0?T>=0&&w?(this.resizingItems.pop(),this.removeTargetSize(i,p),p=this.resizingItems[this.resizingItems.length-1],this.dragOffset-=this.targetSizes.get(L(h,p))??0):(p=this.getNextShownItem(p,i),p!==null&&(this.resizingItems.push(p),this.addTargetSize(i,p))):v!==void 0&&f>v+o.headerResizeSnapThreshold&&E===v?T>0?(this.dragOffset+=E,p=this.hiddenItems[T-1],this.resizingItems.push(p),this.addTargetSize(i,p)):w?(this.resizingItems.pop(),this.removeTargetSize(i,p),p=this.resizingItems[this.resizingItems.length-1]):p=null:p=null}return g.forEach((C,f)=>{const S=s[this.initialSizesProperty].get(f)??c.get(f);C===S?this.resetSize(s,f):this.setSize(s,f,C)}),this.updateCursor(i,this.draggingIndex),!0}onUp(e,t){return this.draggingIndex!=null&&(this.draggingIndex=void 0,this.resizingItems=[],this.hiddenItems=[],this.targetSizes.clear(),this.updateSeparator(t,null)),!1}onDoubleClick(e,t){const{metrics:n,metricCalculator:s}=t,{model:i}=t.props,o=t.getTheme();if(!n)throw new Error("metrics not set");const a=this.getSeparator(e,n,i,o);if(a!=null){const r=n[this.modelIndexesProperty],c=L(r,a.index),h=L(n[this.calculatedSizesProperty],c),u=s[this.initialSizesProperty].get(c);return h===u?this.resetSize(s,c):this.setSize(s,c,h),t.forceUpdate(),!0}return!1}updateCursor(e,t){const n=e[this.visibleSizesProperty];L(n,t)===0?this.cursor=this.hiddenCursor:this.cursor=this.defaultCursor}addTargetSize(e,t){const n=e[this.modelIndexesProperty],s=e[this.userSizesProperty],i=e[this.calculatedSizesProperty],o=t===0?e[this.treePaddingProperty]:0,a=L(n,t);let r=s.get(a);(r==null||r===0)&&(r=L(i,a)+o),this.targetSizes.set(a,r)}removeTargetSize(e,t){const n=e[this.modelIndexesProperty],s=L(n,t);this.targetSizes.delete(s)}}class vr extends Qu{static getColumnSeparator(e,t,n,s){if(!s.allowColumnResize)return null;const{x:i,y:o,columnHeaderDepth:a}=e,{modelColumns:r}=t,c=V.getColumnSeparatorIndex(i,o,t,s);return c==null||a==null||a>0?null:r.get(c)!=null?{index:c,depth:0}:null}hiddenCursor="e-resize";defaultCursor="col-resize";pointProperty="x";userSizesProperty="userColumnWidths";visibleOffsetProperty="visibleColumnXs";visibleSizesProperty="visibleColumnWidths";marginProperty="rowHeaderWidth";calculatedSizesProperty="calculatedColumnWidths";initialSizesProperty="initialColumnWidths";modelIndexesProperty="modelColumns";firstIndexProperty="firstColumn";treePaddingProperty="treePaddingX";getHiddenItems=V.getHiddenColumns;getNextShownItem=V.getNextShownColumn;setSize(e,t,n){e.setColumnWidth(t,n)}resetSize(e,t){e.resetColumnWidth(t)}updateSeparator(e,t){e.setState({draggingColumnSeparator:t,isDragging:t!==null})}getSeparator=vr.getColumnSeparator}class Pt{static DEFAULT_FONT_WIDTH=10;static DEFAULT_EDGE_RADIUS=2;static ACTIVE_CELL_BORDER_WIDTH=2;static truncate(e,t){return t<e.length?e.substr(0,t)+"…":e}static binaryTruncateToWidth(e,t,n,s=0,i=t.length,o){if(i>=t.length&&e.measureText(t).width<=n)return t;if(o!==void 0){const h=e.measureText(o).width;return o.repeat(Math.max(1,Math.floor(n/h)))}let a=s,r=Math.min(t.length-1,i),c=t;for(;r>=a;){const h=Math.ceil((r+a)/2),u=Pt.truncate(t,h);if(e.measureText(u).width<=n){if(c=u,a===h)break;a=h}else if(h===0){c=u;break}else r=h-1}return c}static truncateToWidth(e,t,n,s=Pt.DEFAULT_FONT_WIDTH,i){if(n<=0||t.length<=0)return"";const o=Math.min(Math.max(0,Math.floor(n/s/2)-5),t.length),a=Math.min(Math.ceil(n/s*2),t.length);return Pt.binaryTruncateToWidth(e,t,n,o,a,i)}drawCanvas(e){const{context:t}=e;t.save(),this.configureContext(t,e),this.drawBackground(t,e),this.drawGrid(t,e),this.drawHeaders(t,e),this.drawFooters(t,e),this.drawDraggingColumn(t,e),this.drawDraggingRow(t,e),this.drawScrollBars(t,e),t.restore()}configureContext(e,t){const{theme:n}=t;e.font=n.font,e.textBaseline="middle",e.lineCap="butt"}drawBackground(e,t){const{theme:n,metrics:s}=t,{width:i,height:o}=s;e.fillStyle=n.backgroundColor,e.fillRect(0,0,i,o)}drawGrid(e,t){const{metrics:n,draggingRow:s,draggingColumn:i}=t,{gridX:o,gridY:a}=n;e.translate(o,a),this.drawGridBackground(e,t,s==null&&i==null),this.drawCellContents(e,t),this.drawFloatingRows(e,t),this.drawFloatingColumns(e,t),e.translate(-o,-a)}drawFloatingRows(e,t){const{draggingRow:n,draggingColumn:s,metrics:i,theme:o}=t,{floatingTopRowCount:a,floatingBottomRowCount:r,floatingRows:c,rowCount:h,visibleColumns:u,allRowYs:m,allRowHeights:g}=i;if(c.length!==0){o.floatingRowBackgroundColors&&this.drawRowStripesForRows(e,t,c,o.floatingRowBackgroundColors),n==null&&s==null&&this.drawFloatingMouseRowHover(e,t),this.drawGridLinesForItems(e,t,u,c,o.floatingGridColumnColor,o.floatingGridRowColor),this.drawCellBackgroundsForItems(e,t,u,c),this.drawFloatingBorders(e,t),a>0&&this.drawSelectedRanges(e,t,{top:0,bottom:a-1,maxY:L(m,a-1)+L(g,a-1)-.5}),r>0&&this.drawSelectedRanges(e,t,{top:h-r-1,bottom:h-1,minY:L(m,h-r)+.5,maxY:L(m,h-1)+L(g,h-1)-.5});for(let p=0;p<u.length;p+=1){const C=u[p];for(let f=0;f<c.length;f+=1){const S=c[f];this.drawCellContent(e,t,C,S)}}}}drawFloatingColumns(e,t){const{draggingRow:n,draggingColumn:s,metrics:i,theme:o}=t,{floatingLeftColumnCount:a,floatingRightColumnCount:r,floatingLeftWidth:c,floatingRightWidth:h,floatingColumns:u,gridX:m,maxX:g,columnCount:p,visibleRows:C,allColumnXs:f,allColumnWidths:S,width:v,height:w}=i;if(u.length!==0){o.floatingRowBackgroundColors&&(this.drawRowStripesForRows(e,t,C,o.floatingRowBackgroundColors,0,c),this.drawRowStripesForRows(e,t,C,o.floatingRowBackgroundColors,v-m-h,g)),n==null&&s==null&&this.drawFloatingMouseRowHover(e,t),e.save(),e.beginPath(),e.rect(0,0,c,w),e.clip(),this.drawGridLinesForItems(e,t,u,C,o.floatingGridColumnColor,o.floatingGridRowColor),e.restore(),this.drawCellBackgroundsForItems(e,t,u,C),this.drawFloatingBorders(e,t),a>0&&this.drawSelectedRanges(e,t,{left:0,maxX:L(f,a-1)+L(S,a-1)}),r>0&&this.drawSelectedRanges(e,t,{left:p-r,right:p-1,minX:L(f,p-r)+.5,maxX:L(f,p-1)+L(S,p-1)});for(let T=0;T<u.length;T+=1){const y=u[T];for(let E=0;E<C.length;E+=1){const D=C[E];this.drawCellContent(e,t,y,D)}}}}drawFloatingBorders(e,t){const{metrics:n,theme:s}=t,{floatingTopRowCount:i,floatingBottomRowCount:o,floatingLeftColumnCount:a,floatingRightColumnCount:r,rowCount:c,columnCount:h,allRowYs:u,allColumnXs:m,allRowHeights:g,allColumnWidths:p,maxX:C,maxY:f}=n,{floatingDividerOuterColor:S,floatingDividerInnerColor:v}=s;if(e.lineWidth=3,e.beginPath(),e.strokeStyle=S,i>0){const w=L(u,i-1)+L(g,i-1)+.5;e.moveTo(0,w),e.lineTo(C,w)}if(o>0){const w=L(u,c-o)-.5;e.moveTo(0,w),e.lineTo(C,w)}if(a>0){const w=L(m,a-1)+L(p,a-1)+.5;e.moveTo(w,0),e.lineTo(w,f)}if(r>0){const w=L(m,h-r)-.5;e.moveTo(w,0),e.lineTo(w,f)}if(e.stroke(),e.beginPath(),e.lineWidth=1,e.strokeStyle=v,i>0){const w=L(u,i-1)+L(g,i-1)+.5;e.moveTo(0,w),e.lineTo(C,w)}if(o>0){const w=L(u,c-o)-.5;e.moveTo(0,w),e.lineTo(C,w)}if(a>0){const w=L(m,a-1)+L(p,a-1)+.5;e.moveTo(w,0),e.lineTo(w,f)}if(r>0){const w=L(m,h-r)-.5;e.moveTo(w,0),e.lineTo(w,f)}e.stroke()}drawGridBackground(e,t,n=!1){this.drawRowStripes(e,t),n&&(this.drawMouseColumnHover(e,t),this.drawMouseRowHover(e,t)),this.drawGridLines(e,t),this.drawCellBackgrounds(e,t);const{metrics:s}=t,{bottom:i,right:o,floatingBottomRowCount:a,floatingLeftColumnCount:r,floatingRightColumnCount:c,floatingTopRowCount:h,columnCount:u,rowCount:m,allRowHeights:g,allRowYs:p,allColumnXs:C,allColumnWidths:f,width:S,height:v}=s;this.drawSelectedRanges(e,t,{bottom:Math.min(i,m-a-1),right:Math.min(o,u-c-1),minX:r>0&&C.has(r+1)?L(C,r+1):-10,minY:h>0&&p.has(h+1)?L(p,h+1):-10,maxX:c>0&&C.has(u-c-1)?L(C,u-c-1)+L(f,u-c-1)-.5:S+10,maxY:a>0&&p.has(m-a-1)?L(p,m-a-1)+L(g,m-a-1)-.5:v+10})}drawRowStripes(e,t){const{metrics:n,theme:s}=t,{visibleRows:i}=n,{rowBackgroundColors:o}=s;o&&this.drawRowStripesForRows(e,t,i,o)}drawRowStripesForRows(e,t,n,s,i=0,o=t.metrics.maxX){const{theme:a,metrics:r,model:c}=t,{maxDepth:h,shadowBlur:u,shadowColor:m}=a,g=this.getCachedBackgroundColors(s,h),{allRowYs:p,allRowHeights:C}=r,f=new Map,S=[],v=[],w=(T,y)=>{const E=qe(c)?c.depthForRow(T):0,D=g[T%g.length],F=D[Math.min(E,D.length-1)];if(f.has(F)||f.set(F,[]),f.get(F).push(T),y!=null){const N=qe(c)?c.depthForRow(y):0;N<E?S.push(T):N>E&&v.push(y)}};for(let T=0;T<n.length;T+=1){const y=n[T],E=T>0?n[T-1]:void 0;w(y,E)}if(f.forEach((T,y)=>{e.fillStyle=y,e.beginPath();for(let E=0;E<T.length;E+=1){const D=T[E],F=L(p,D),N=L(C,D);e.rect(i,F,o,N)}e.fill()}),S.length>0){e.save();const T=this.getCachedColorWithAlpha(m,.15),y=this.getCachedColorWithAlpha(m,0),E=e.createLinearGradient(0,0,0,u);E.addColorStop(0,T),E.addColorStop(1,y),e.fillStyle=E;for(let D=0;D<S.length;D+=1){const F=S[D],N=L(p,F);e.translate(0,N),e.fillRect(i,0,o,u),e.translate(0,-N)}e.restore()}if(v.length>0){e.save();const T=this.getCachedColorWithAlpha(m,0),y=this.getCachedColorWithAlpha(m,.15),E=e.createLinearGradient(0,0,0,u);E.addColorStop(0,T),E.addColorStop(1,y),e.fillStyle=E;for(let D=0;D<v.length;D+=1){const F=v[D],N=L(p,F),_=L(C,F),P=N+_-u;e.translate(0,P),e.fillRect(i,0,o,u),e.translate(0,-P)}e.restore()}}drawMouseColumnHover(e,t){const{mouseX:n,mouseY:s,theme:i,metrics:o}=t;if(n==null||s==null)return;const a=V.getColumnAtX(n,o);if(a==null||i.columnHoverBackgroundColor==null)return;const{allColumnWidths:r,allColumnXs:c,maxY:h}=o;if(s>h)return;const u=L(c,a),m=L(r,a);e.fillStyle=i.columnHoverBackgroundColor,e.fillRect(u,0,m,h)}drawMouseRowHover(e,t){const{mouseX:n,mouseY:s,theme:i,metrics:o}=t;if(n==null||s==null)return;const{maxX:a}=o;if(n>a||i.rowHoverBackgroundColor==null)return;const r=V.getRowAtY(s,o);r!=null&&this.drawMouseRowHoverForRow(e,t,r)}drawFloatingMouseRowHover(e,t){const{mouseX:n,mouseY:s,theme:i,metrics:o}=t,{maxX:a,floatingTopRowCount:r,floatingBottomRowCount:c,rowCount:h,rowFooterWidth:u}=o;if(n==null||s==null||n>a+u||i.rowHoverBackgroundColor==null)return;const m=V.getRowAtY(s,o);m!=null&&(m<r||h-c<=m)&&this.drawMouseRowHoverForRow(e,t,m)}drawMouseRowHoverForRow(e,t,n){const{metrics:s,selectedRanges:i,theme:o}=t,{allRowHeights:a,allRowYs:r,maxX:c}=s,h=L(r,n),u=L(a,n);o.rowHoverBackgroundColor!=null&&(e.fillStyle=o.rowHoverBackgroundColor);for(let m=0;m<i.length;m+=1){const{startRow:g,endRow:p}=i[m];if(g!=null&&p!=null&&g<=n&&p>=n){o.selectedRowHoverBackgroundColor!=null&&(e.fillStyle=o.selectedRowHoverBackgroundColor);break}}e.fillRect(0,h,c,u)}drawGridLines(e,t){const{metrics:n,theme:s}=t,{visibleColumns:i,visibleRows:o}=n;this.drawGridLinesForItems(e,t,i,o,s.gridColumnColor,s.gridRowColor)}drawGridLinesForItems(e,t,n,s,i,o){i==null&&o==null||(e.lineWidth=1,e.beginPath(),i!=null&&(e.strokeStyle=i,this.drawGridLinesForColumns(e,t,n)),o!=null&&(e.strokeStyle=o,this.drawGridLinesForRows(e,t,s)),e.stroke())}drawGridLinesForColumns(e,t,n){const{metrics:s}=t,{allColumnXs:i,maxY:o}=s;for(let a=0;a<n.length;a+=1){const r=n[a],c=L(i,r)+.5;e.moveTo(c,0),e.lineTo(c,o)}}drawGridLinesForRows(e,t,n){const{metrics:s}=t,{allRowYs:i,maxX:o}=s,a=o;for(let r=0;r<n.length;r+=1){const c=n[r],h=L(i,c)+.5;e.moveTo(.5,h),e.lineTo(a-.5,h)}}drawCellBackgrounds(e,t){const{metrics:n}=t,{visibleColumns:s,visibleRows:i}=n;this.drawCellBackgroundsForItems(e,t,s,i)}drawCellBackgroundsForItems(e,t,n,s){e.save();for(let i=0;i<n.length;i+=1){const o=n[i];for(let a=0;a<s.length;a+=1){const r=s[a],c=a+1<s.length?s[a+1]:void 0;this.drawCellBackground(e,t,o,r,c)}}e.restore()}drawCellBackground(e,t,n,s,i){const{metrics:o,model:a,theme:r}=t,{firstColumn:c,modelColumns:h,modelRows:u,allColumnXs:m,allColumnWidths:g,allRowYs:p,allRowHeights:C}=o,f=L(u,s),S=L(h,n),v=a.backgroundColorForCell(S,f,r),w=n===c,T=qe(a)&&a.hasExpandableRows;if(v!=null){const y=L(m,n)+1,E=L(p,s)+1,D=L(g,n)-1,F=L(C,s)-1;e.fillStyle=v,e.fillRect(y,E,D,F)}w&&T&&this.drawCellRowTreeDepthLines(e,t,s,i)}drawCellContents(e,t){const{metrics:n}=t,{visibleColumns:s}=n;for(let i=0;i<s.length;i+=1){const o=s[i];this.drawColumnCellContents(e,t,o)}}drawColumnCellContents(e,t,n){const{metrics:s}=t,{allColumnXs:i,allColumnWidths:o,visibleRows:a,height:r}=s,c=L(i,n),h=L(o,n);e.save(),e.beginPath(),e.rect(c,0,h,r),e.clip();for(let u=0;u<a.length;u+=1){const m=a[u];this.drawCellContent(e,t,n,m)}e.restore()}getTextRenderMetrics(e,t,n){const{metrics:s,model:i,theme:o}=e,{firstColumn:a,allColumnXs:r,allColumnWidths:c,allRowYs:h,allRowHeights:u,modelRows:m,modelColumns:g}=s,{cellHorizontalPadding:p,treeDepthIndent:C,treeHorizontalPadding:f}=o,S=L(m,n),v=L(g,t),w=i.textAlignForCell(v,S),T=L(r,t),y=L(h,n),E=L(c,t),D=L(u,n),F=t===a;let N=0;qe(i)&&i.hasExpandableRows&&F&&(N=C*(i.depthForRow(n)+1)+f);const _=E-N;let P=T+p;const U=y+D*.5;return w==="right"?P=T+_-p:w==="center"&&(P=T+_*.5),P+=N,{width:_-p*2,x:P,y:U}}drawCellContent(e,t,n,s,i){const{metrics:o,model:a,theme:r}=t,{firstColumn:c,fontWidths:h,modelColumns:u,modelRows:m,allRowHeights:g}=o,{textColor:p}=r,C=L(g,s),f=L(m,s),S=L(u,n),v=i??a.textForCell(S,f),w=a.truncationCharForCell(S,f),T=n===c;if(v&&C>0){const y=a.textAlignForCell(S,f)||"left";e.textAlign=y;const E=a.colorForCell(S,f,r)||p;e.fillStyle=E,e.save();const{width:D,x:F,y:N}=this.getTextRenderMetrics(t,n,s),_=h.get(e.font)??Pt.DEFAULT_FONT_WIDTH,P=this.getCachedTruncatedString(e,v,D,_,w),U=a.tokensForCell(S,f,P.length);if(P){let O=0,j=0,k=F;const{actualBoundingBoxDescent:A}=e.measureText(P);for(;j<P.length;){const H=U[O],K=j===H?.start?H:null,q=K?.end??H?.start??P.length,oe=P.substring(j,q),{width:W}=e.measureText(oe),G=oe.endsWith("…")?e.measureText(oe.substring(0,oe.length-1)).width:W;K!=null?(e.fillStyle=r.hyperlinkColor,e.fillText(oe,k,N),e.fillRect(k,N+A,G,1)):(e.fillStyle=E,e.fillText(oe,k,N)),k+=W,j=q,K!=null&&(O+=1)}}e.restore()}T&&qe(a)&&a.hasExpandableRows&&this.drawCellRowTreeMarker(e,t,s)}drawCellRowTreeMarker(e,t,n){const{metrics:s,model:i,mouseX:o,mouseY:a,theme:r}=t,{firstColumn:c,gridX:h,gridY:u,allColumnXs:m,allColumnWidths:g,allRowYs:p,allRowHeights:C,visibleRowTreeBoxes:f}=s,{treeMarkerColor:S,treeMarkerHoverColor:v}=r,w=L(m,c),T=L(g,c),y=L(p,n),E=L(C,n);if(!qe(i)||!i.isRowExpandable(n))return;const D=L(f,n),F=o!=null&&a!=null&&o>=h+w&&o<=h+w+T&&a>=u+y&&a<=u+y+E?v:S;this.drawTreeMarker(e,t,w,y,D,F,i.isRowExpanded(n))}drawTreeMarker(e,t,n,s,i,o,a){const{x1:r,y1:c,x2:h,y2:u}=i,m=a?"⊟":"⊞",g=n+(r+h)*.5+.5,p=s+(c+u)*.5+.5;e.fillStyle=o,e.textAlign="center",e.fillText(m,g,p)}drawCellRowTreeDepthLines(e,t,n,s){const{metrics:i,model:o,theme:a}=t;if(!qe(o))return;const r=o.depthForRow(n);if(r===0)return;const{firstColumn:c,allColumnXs:h,allRowYs:u,allRowHeights:m}=i,{treeDepthIndent:g,treeHorizontalPadding:p,treeLineColor:C}=a,f=L(h,c),S=L(u,n),v=L(m,n),w=s!==void 0?o.depthForRow(s):0,T=r>w?r-w:0;if(e.strokeStyle=C,e.lineWidth=1,r-T>0){e.beginPath();for(let y=0;y<r-T;y+=1){const E=f+y*g+g*.5+p+.5;e.moveTo(E,S),e.lineTo(E,S+v)}e.stroke()}if(T>0){e.beginPath();for(let y=r-T;y<r;y+=1){const E=f+y*g+g*.5+p+.5;e.moveTo(E,S),e.lineTo(E,S+Math.ceil(v/2)),e.moveTo(E-.5,S+Math.ceil(v/2)+.5),e.lineTo(E+g-.5,S+Math.ceil(v/2)+.5)}e.stroke()}}getCachedTruncatedString=Zn((e,t,n,s,i)=>Pt.truncateToWidth(e,t,n,s,i),{max:1e4});getCachedBackgroundColors=Zn((e,t)=>e.split(" ").map(n=>{const s=[];for(let i=0;i<t;i+=1)s.push(Od.darkenForDepth(n,i,t));return s}),{max:1e3});getCachedColorWithAlpha=Zn((e,t)=>Od.colorWithAlpha(e,t),{max:1e3});getCachedColorIsDark=Zn(e=>rr.isDark(e),{max:1e3});drawHeaders(e,t){const{theme:n}=t;e.font=n.headerFont,this.drawColumnHeaders(e,t),this.drawRowHeaders(e,t)}drawFooters(e,t){const{theme:n}=t;e.font=n.headerFont,this.drawRowFooters(e,t)}drawColumnHeaders(e,t){const{mouseX:n,mouseY:s,theme:i,metrics:o,draggingColumnSeparator:a,isDragging:r,model:c}=t,{columnHeaderHeight:h,floatingColumns:u,gridX:m,width:g,visibleColumns:p,allColumnWidths:C,allColumnXs:f,floatingLeftColumnCount:S,floatingLeftWidth:v,floatingRightWidth:w,modelColumns:T,columnHeaderMaxDepth:y}=o;if(h<=0)return;const{headerHiddenSeparatorSize:E,headerHiddenSeparatorHoverColor:D,headerSeparatorColor:F,headerSeparatorHoverColor:N}=i,_=h*.5,P=h*(y-1)+h*.5-_*.5,U=S>0;if(e.save(),this.drawColumnHeadersForRange(e,t,[p[0],p[p.length-1]],{minX:m+v,maxX:g-w}),U&&this.drawColumnHeadersForRange(e,t,[u[0],u[u.length-1]],{minX:m,maxX:m+v}),F){e.strokeStyle=F;const O=[...C.entries()].filter(([j,k])=>k===0).map(([j])=>j);e.beginPath(),e.fillStyle=F;for(let j=0;j<O.length;j+=1){const k=O[j],A=L(f,k),H=L(C,k),K=m+A+H+.5-E*.5;e.rect(K,P,E,_)}e.fill()}if(N){let{index:O,depth:j}=a??{};if(O==null&&n!=null&&s!=null){const A=vr.getColumnSeparator(V.getGridPointFromXY(n,s,o),o,c,i);O=A?.index,j=A?.depth}let k;if(O==null)k=!1;else{const A=T.get(O),H=T.get(O+1);A==null||H==null?k=!1:k=c.textForColumnHeader(A,j)!==c.textForColumnHeader(H,j)}if(k&&O!=null&&j!=null&&(!r||a!=null)){e.strokeStyle=N;const A=L(f,O),H=L(C,O),K=m+A+H+.5,q=p.indexOf(O),oe=q<p.length-1?p[q+1]:null,W=oe!=null?C.get(oe):null,G=H===0,ne=W!=null&&W===0;G?(e.strokeStyle=D,e.fillStyle=D,e.fillRect(K,P,E*.5,_)):ne&&(e.fillStyle=N,e.fillRect(K-E*.5,P,E*.5,_)),e.beginPath(),e.moveTo(K,(y-j-1)*h),e.lineTo(K,(y-j)*h-1),e.stroke()}}e.restore()}drawColumnHeadersForRange(e,t,n,s){const{model:i}=t,{columnHeaderMaxDepth:o}=i;if(o!==0)for(let a=0;a<=o;a+=1)this.drawColumnHeadersAtDepth(e,t,n,s,a)}drawColumnHeadersAtDepth(e,t,n,s,i){const{metrics:o,model:a,theme:r}=t,{modelColumns:c,allColumnXs:h,gridX:u,userColumnWidths:m,allColumnWidths:g,movedColumns:p}=o,{columnHeaderHeight:C,columnWidth:f}=r,{columnHeaderMaxDepth:S}=a,{minX:v,maxX:w}=s,T=w-v;if(S===0)return;const y=n[0],E=n[1];if(e.save(),e.translate(0,(S-i-1)*C),i===0){this.drawColumnHeader(e,t,"",v,w);for(let D=y;D<=E;D+=1)this.drawColumnHeaderAtIndex(e,t,D,s)}if(i>0){let D=y;for(;D<=E;){const{columnCount:F}=o,N=L(c,D),_=a.textForColumnHeader(N,i),P=a.colorForColumnHeader(N,i);let U=L(h,D)+u,O=U+L(g,D);if(_!=null){let j=D-1;for(;j>=0&&(O-U<T||U>v);){const K=c.get(j)??V.getModelIndex(j,p);if(K==null||a.textForColumnHeader(K,i)!==_)break;const q=m.get(K)??g.get(j)??f;U-=q,j-=1}let k=D+1;for(;k<F&&(O-U<T||O<w);){const K=c.get(k)??V.getModelIndex(k,p);if(a.textForColumnHeader(K,i)!==_)break;const q=m.get(K)??g.get(k)??f;O+=q,k+=1}D=k-1;const A=O-U>=T;let H=U;A&&(O<w?H=O-T:U<v&&(H=v)),this.drawColumnHeader(e,t,_,H,Math.min(O-U,T),{backgroundColor:P??void 0},s)}D+=1}}e.restore()}drawColumnHeaderAtIndex(e,t,n,s){const{metrics:i,model:o}=t,{modelColumns:a,allColumnWidths:r,allColumnXs:c,gridX:h}=i,u=L(r,n),m=L(c,n)+h,g=L(a,n),p=o.textForColumnHeader(g);p!=null&&this.drawColumnHeader(e,t,p,m,u,{backgroundColor:o.colorForColumnHeader(g)??void 0},s)}drawColumnHeader(e,t,n,s,i,o,a){if(i<=0)return;const{metrics:r,theme:c}=t,{headerHorizontalPadding:h,columnHeaderHeight:u,headerBackgroundColor:m,headerColor:g,headerSeparatorColor:p,black:C,white:f}=c,{fontWidths:S,width:v}=r,w=S.get(e.font)??Pt.DEFAULT_FONT_WIDTH,y=(i-h*2)/w,{backgroundColor:E=m,separatorColor:D=p}=o??{};let{textColor:F=g}=o??{};try{const G=this.getCachedColorIsDark(E),ne=this.getCachedColorIsDark(F);G&&ne?F=f:!G&&!ne&&(F=C)}catch{}let{minX:N=0,maxX:_=v}=a??{};e.save(),e.rect(N,0,_-N,u),e.clip(),E!=null&&(e.fillStyle=E,e.fillRect(s,0,i,u)),D!=null&&(e.strokeStyle=D,e.beginPath(),s>0&&(e.moveTo(s+.5,0),e.lineTo(s+.5,u)),e.moveTo(s+i+.5,0),e.lineTo(s+i+.5,u),e.moveTo(s,u-.5),e.lineTo(s+i,u-.5),e.stroke()),e.beginPath(),e.rect(s,0,i,u),e.clip(),e.fillStyle=F;let P=n;y<=0?P="":P.length>y&&(P=`${P.substring(0,y-1)}…`);const U=P.length*w;let O=s+i*.5;const j=u*.5;N+=h,_-=h;const k=s+h,A=He(k,N,_),H=s+i-h,q=He(H,N,_)-A,oe=O-U*.5<N,W=O+U*.5>_;oe?U<q?O=N+U*.5:O=H-U*.5:W&&(U<q?O=_-U*.5:O=k+U*.5),e.textAlign="center",e.fillText(P,O,j),e.restore()}drawRowHeaders(e,t){const{mouseX:n,mouseY:s,metrics:i,theme:o,draggingRowSeparator:a}=t,{gridY:r,rowHeaderWidth:c,height:h,visibleRows:u,allRowHeights:m,allRowYs:g}=i;if(c<=0)return;const{headerBackgroundColor:p,headerColor:C,headerHiddenSeparatorSize:f,headerHiddenSeparatorHoverColor:S,headerSeparatorColor:v,headerSeparatorHoverColor:w}=o,T=c*.5,y=c*.5-T*.5;if(e.save(),e.beginPath(),e.fillStyle=p,e.fillRect(0,0,c,h),v){e.strokeStyle=v,e.beginPath(),e.moveTo(0,r+.5),e.lineTo(c,r+.5);const E=[];let D=!1;for(let F=0;F<u.length;F+=1){const N=u[F],_=L(g,N),P=L(m,N);if(P>0){const U=r+_+P+.5;e.moveTo(0,U),e.lineTo(c,U),D=!1}else D||(D=!0,E.push(N))}e.moveTo(c-.5,0),e.lineTo(c-.5,h),e.stroke(),e.beginPath(),e.fillStyle=v;for(let F=0;F<E.length;F+=1){const N=E[F],_=L(g,N),P=L(m,N),U=r+_+P+.5-f*.5;e.rect(y,U,T,f)}e.fill()}if(w){let{index:E=null}=a??{};if(E==null&&n!=null&&s!=null&&(E=V.getRowSeparatorIndex(n,s,i,o)),E!=null){e.strokeStyle=w;const D=L(g,E),F=L(m,E),N=r+D+F+.5,_=u.indexOf(E),P=_<u.length-1?u[_+1]:null,U=P!=null?m.get(P):null,O=F===0,j=U!=null&&U===0;O?(e.strokeStyle=S,e.fillStyle=S,e.fillRect(y,N,T,f*.5)):j&&(e.fillStyle=w,e.fillRect(y,N-f*.5,T,f*.5)),e.beginPath(),e.moveTo(.5,N),e.lineTo(c+.5,N),e.stroke()}}e.beginPath(),e.rect(0,r,c,h),e.clip(),e.fillStyle=C,e.textAlign="right";for(let E=0;E<u.length;E+=1){const D=u[E],F=L(m,D),N=L(g,D)+r;this.drawRowHeader(e,t,D,N,F)}e.restore()}drawRowHeader(e,t,n,s,i){if(i<=0)return;const{metrics:o,model:a,theme:r}=t,{modelRows:c,rowHeaderWidth:h}=o,u=L(c,n),m=h-r.cellHorizontalPadding,g=s+i*.5;e.fillText(a.textForRowHeader(u),m,g)}drawRowFooters(e,t){const{mouseX:n,mouseY:s,metrics:i,model:o,theme:a,draggingRowSeparator:r}=t,{gridY:c,gridX:h,maxX:u,modelRows:m,rowFooterWidth:g,height:p,verticalBarWidth:C,visibleRows:f,allRowHeights:S,allRowYs:v,width:w}=i;if(g<=0)return;const{cellHorizontalPadding:T,headerBackgroundColor:y,headerColor:E,headerHiddenSeparatorSize:D,headerHiddenSeparatorHoverColor:F,headerSeparatorColor:N,headerSeparatorHoverColor:_}=a,P=g*.5,U=g*.5-P*.5,O=Math.min(h+u,w-g-C);if(e.save(),e.beginPath(),e.fillStyle=y,e.fillRect(O,c,g,p),N){e.strokeStyle=N,e.beginPath(),e.moveTo(O,c+.5),e.lineTo(g,c+.5);const k=[];let A=!1;for(let H=0;H<f.length;H+=1){const K=f[H],q=L(v,K),oe=L(S,K);if(oe>0){const W=c+q+oe+.5;e.moveTo(O+.5,W),e.lineTo(O+g-.5,W),A=!1}else A||(A=!0,k.push(K))}e.moveTo(O+.5,c),e.lineTo(O+.5,p),e.stroke(),e.beginPath(),e.fillStyle=N;for(let H=0;H<k.length;H+=1){const K=k[H],q=L(v,K),oe=L(S,K),W=c+q+oe+.5-D*.5;e.rect(O+U,W,P,D)}e.fill()}if(_){let{index:k=null}=r??{};if(k==null&&n!=null&&s!=null&&(k=V.getRowSeparatorIndex(n,s,i,a)),k!=null){e.strokeStyle=_;const A=L(v,k),H=L(S,k),K=c+A+H+.5,q=f.indexOf(k),oe=q<f.length-1?f[q+1]:null,W=oe!=null?S.get(oe):null,G=H===0,ne=W!=null&&W===0;G?(e.strokeStyle=F,e.fillStyle=F,e.fillRect(U,K,P,D*.5)):ne&&(e.fillStyle=_,e.fillRect(U,K-D*.5,P,D*.5)),e.beginPath(),e.moveTo(O+.5,K),e.lineTo(O+g+.5,K),e.stroke()}}e.beginPath(),e.rect(O,c,g,p),e.clip(),e.fillStyle=E,e.textAlign="left";const j=O+T;for(let k=0;k<f.length;k+=1){const A=f[k],H=L(S,A);if(H>0){const K=L(v,A)+c,q=L(m,A),oe=K+H*.5;e.fillText(o.textForRowFooter(q),j,oe)}}e.restore()}drawSelectedRanges(e,t,n={}){const{cursorColumn:s,cursorRow:i,draggingRow:o,draggingColumn:a,editingCell:r,metrics:c,model:h,selectedRanges:u,theme:m}=t,{allColumnWidths:g,allColumnXs:p,allRowHeights:C,allRowYs:f,width:S,height:v}=c,{left:w=c.left,top:T=c.top,right:y=c.right,bottom:E=c.bottom,minY:D=-10,maxY:F=v+10,minX:N=-10,maxX:_=S+10}=n;if(u.length===0)return;const P=Ze(h)&&h.isEditable&&r==null&&o==null&&a==null&&s!=null&&i!=null&&p.has(s)&&f.has(i);if(P){const U=L(p,s),O=L(f,i),j=L(g,s),k=L(C,i);e.save(),e.beginPath(),e.rect(0,0,S,v),e.rect(U,O,j,k),e.clip("evenodd")}e.beginPath();for(let U=0;U<u.length;U+=1){const O=u[U],j=O.startColumn!==null?O.startColumn:w,k=O.startRow!==null?O.startRow:T,A=O.endColumn!==null?O.endColumn:y,H=O.endRow!==null?O.endRow:E;if(H>=T&&E>=k&&A>=w&&y>=j){const K=j>=w&&p.has(j)?Math.round(L(p,j))+.5:N,q=k>=T&&f.has(k)?Math.max(Math.round(L(f,k))+.5,.5):D,oe=A<=y&&p.has(A)?Math.round(L(p,A)+L(g,A))-.5:_,W=H<=E&&f.has(H)?Math.round(L(f,H)+L(C,H))-.5:F;e.rect(K,q,oe-K,W-q)}e.fillStyle=m.selectionColor,e.fill(),e.save(),e.clip(),e.strokeStyle=m.selectionOutlineCasingColor,e.lineWidth=3,e.stroke(),e.restore(),e.strokeStyle=m.selectionOutlineColor,e.lineWidth=1,e.stroke()}P&&s!=null&&i!=null&&(e.restore(),this.drawActiveCell(e,t,s,i))}drawActiveCell(e,t,n,s,i=Pt.ACTIVE_CELL_BORDER_WIDTH){const{metrics:o,theme:a}=t,{allColumnWidths:r,allColumnXs:c,allRowHeights:h,allRowYs:u}=o,m=L(c,n),g=L(u,s),p=L(r,n),C=L(h,s);let f=m-i*.5,S=g-i*.5,v=p+i,w=C+i;f<=0&&(v+=f-1,f=1),S<=0&&(w+=S-1,S=1);const{lineWidth:T}=e;e.beginPath(),e.lineWidth=i,e.strokeStyle=a.selectionOutlineColor,this.drawRoundedRect(e,f,S,v,w),e.stroke(),e.lineWidth=T}drawRoundedRect(e,t,n,s,i,o=Pt.DEFAULT_EDGE_RADIUS){e.beginPath(),e.moveTo(t+o,n),e.lineTo(t+s-o,n),e.quadraticCurveTo(t+s,n,t+s,n+o),e.lineTo(t+s,n+i-o),e.quadraticCurveTo(t+s,n+i,t+s-o,n+i),e.lineTo(t+o,n+i),e.quadraticCurveTo(t,n+i,t,n+i-o),e.lineTo(t,n+o),e.quadraticCurveTo(t,n,t+o,n),e.closePath()}drawDraggingColumn(e,t){const{draggingColumn:n,metrics:s,mouseX:i,theme:o,model:a}=t;if(n==null||i==null)return;const{range:r,depth:c}=n,{gridX:h,gridY:u,allColumnXs:m,allColumnWidths:g,height:p,width:C,columnHeaderMaxDepth:f,columnHeaderHeight:S,movedColumns:v,modelColumns:w,floatingLeftWidth:T}=s,y=w.get(r[0])??V.getModelIndex(r[0],v),E=a.getColumnHeaderGroup(y,c);if(c>0&&!E)return;const[D,F]=r,N=L(m,D),P=L(m,F)+L(g,F)-N,U=n.left,{backgroundColor:O,font:j,headerFont:k,reorderOffset:A,shadowBlur:H,shadowColor:K}=o,q=(f-c-1)*S;e.save(),e.translate(h,0),e.save(),e.beginPath(),e.rect(T,0,C,p),e.clip(),e.fillStyle=O,e.fillRect(N,q,P,p),e.restore(),e.translate(0,A),e.save(),e.shadowColor=K,e.shadowBlur=H,e.fillStyle=O,e.fillRect(n.left,q+A,n.width,p),e.restore(),e.beginPath(),e.rect(n.left,q,n.width+1,p),e.clip(),e.translate(U-N,0),e.font=k;const oe=[];for(let W=n.range[0];W<=n.range[1];W+=1)oe.push(W);this.drawColumnHeaders(e,t),this.drawColumnHeadersForRange(e,t,[oe[0],oe[oe.length-1]],{minX:N,maxX:C}),e.translate(0,u),e.font=j,this.drawGridBackground(e,t);for(let W=D;W<=F;W+=1)this.drawColumnCellContents(e,t,W);e.restore()}drawDraggingRow(e,t){const{draggingRow:n,draggingRowOffset:s,metrics:i,mouseY:o,theme:a}=t;if(n==null||o==null)return;const{gridX:r,gridY:c,allRowYs:h,allRowHeights:u,width:m}=i,g=L(h,n),p=L(u,n)+1,{backgroundColor:C,font:f,headerFont:S,reorderOffset:v,shadowBlur:w,shadowColor:T}=a;e.save(),e.translate(0,c),e.fillStyle=C,e.fillRect(0,g,m,p),e.translate(r+v,o-g-c-(s??0)),e.save(),e.shadowColor=T,e.shadowBlur=w,e.fillStyle=C,e.fillRect(-r,g,m,p),e.restore(),e.beginPath(),e.rect(-r,g,m,p),e.clip(),e.font=f,this.drawGridBackground(e,t),this.drawCellContents(e,t),e.translate(-r,-c),e.font=S,this.drawRowHeaders(e,t),e.restore()}drawScrollBars(e,t){const{isDraggingHorizontalScrollBar:n,isDraggingVerticalScrollBar:s,isDragging:i,metrics:o,mouseX:a,mouseY:r,theme:c}=t;if(c.scrollBarSize<=0)return;const{width:h,height:u,handleHeight:m,handleWidth:g,scrollX:p,scrollY:C,hasHorizontalBar:f,hasVerticalBar:S,barWidth:v,barHeight:w,barLeft:T,barTop:y}=o,{scrollBarBackgroundColor:E,scrollBarHoverBackgroundColor:D,scrollBarCasingColor:F,scrollBarCornerColor:N,scrollBarColor:_,scrollBarHoverColor:P,scrollBarActiveColor:U,scrollBarSize:O,scrollBarHoverSize:j,scrollBarCasingWidth:k,scrollBarSelectionTick:A,scrollBarSelectionTickColor:H,scrollBarActiveSelectionTickColor:K,autoSelectRow:q,autoSelectColumn:oe}=c,W=a!=null&&r!=null&&a<=h&&r<=u,G=s||S&&!n&&!i&&a!=null&&r!=null&&a>=h-j&&r>=y&&W,ne=n||f&&!s&&!i&&!G&&a!=null&&r!=null&&r>=u-j&&a>=T&&W,ae=ne?j:O,ce=G?j:O;if(e.translate(T,y),f&&S&&(e.fillStyle=F,e.fillRect(h-T-O,u-y-O,O,O),e.fillStyle=N,e.fillRect(h-T-O+k,u-y-O+k,O-k,O-k)),f){const te=p,re=u-y-ae;if(e.fillStyle=F,e.fillRect(0,re,v,ae-k),e.fillStyle=ne?D:E,e.fillRect(0,re+k,v,ae-k),n?e.fillStyle=U:ne?e.fillStyle=P:e.fillStyle=_,e.fillRect(te,re+k,g,ae-k),!q&&A&&H!=null&&K!=null){e.fillStyle=H;const{selectedRanges:we,cursorColumn:Ie}=t,{lastLeft:xe,columnCount:at}=o,en=[...we].filter(ye=>ye.startColumn!=null&&ye.endColumn!=null).map(ye=>[ye.startColumn,ye.endColumn]).sort(V.compareRanges),Rn=V.mergeSortedRanges(en),kt=ye=>ye<=xe?ye/xe*(v-g):v-g+(ye-xe)/(at-xe)*g;for(let ye=0;ye<Rn.length;ye+=1){const ut=Rn[ye],rt=ut[0],bt=ut[1];if(rt!=null&&bt!=null&&(rt!==Ie||bt!==Ie)){const Ot=kt(rt),xn=Math.max(1,Math.round(kt(bt+1)-Ot)),tn=ae-k;e.fillRect(Ot,re+k+Math.round(tn/3),xn,Math.round(tn/3))}}if(Ie!=null){const ye=kt(Ie),ut=2,rt=ae-k;e.fillStyle=K,e.fillRect(ye,re+k,ut,rt)}}}if(S){const te=h-T-ce,re=C;if(e.fillStyle=F,e.fillRect(te,0,ce-k,w),e.fillStyle=G?D:E,e.fillRect(te+k,0,ce-k,w),s?e.fillStyle=U:G?e.fillStyle=P:e.fillStyle=_,e.fillRect(te+k,re,ce-k,m),!oe&&A&&H!=null&&K!=null){const{selectedRanges:we,cursorRow:Ie}=t,{lastTop:xe,rowCount:at}=o,xt=ye=>ye<=xe?ye/xe*(w-m):w-m+(ye-xe)/(at-xe)*m;e.fillStyle=H;const Rn=[...we].filter(ye=>ye.startRow!=null&&ye.endRow!=null).map(ye=>[ye.startRow,ye.endRow]).sort(V.compareRanges),kt=V.mergeSortedRanges(Rn);for(let ye=0;ye<kt.length;ye+=1){const ut=kt[ye],rt=ut[0],bt=ut[1];if(rt!=null&&bt!=null&&(rt!==Ie||bt!==Ie)){const Ot=xt(rt),xn=ce-k,tn=Math.max(1,Math.round(xt(bt+1)-Ot));e.fillRect(te+k+Math.round(xn/3),Ot,Math.round(xn/3),tn)}}if(Ie!=null){const ye=Math.round(xt(Ie)),ut=ce-k,rt=2;e.fillStyle=K,e.fillRect(te+k,ye,ut,rt)}}}e.translate(-T,-y)}getTokenBoxesForVisibleCell(e,t,n){const{metrics:s,context:i,model:o,theme:a}=n;if(i==null||s==null)return Fe;const{modelRows:r,modelColumns:c}=s,h=L(r,t),u=L(c,e),m=o.textForCell(u,h),{width:g,x:p,y:C}=this.getTextRenderMetrics(n,e,t),{fontWidths:f}=s;i.save(),this.configureContext(i,n);const S=f?.get(i.font)??Pt.DEFAULT_FONT_WIDTH,v=o.truncationCharForCell(u,h),w=this.getCachedTruncatedString(i,m,g,S,v),{actualBoundingBoxAscent:T,actualBoundingBoxDescent:y}=i.measureText(w),E=T+y,D=o.tokensForCell(u,h,w.length);if(D.length===0)return i.restore(),Fe;const F=this.getCachedTokenBoxesForVisibleCell(w,D,a.font,"middle",E,i).map(N=>({x1:N.x1+p,y1:N.y1+(C-T),x2:N.x2+p,y2:N.y2+(C-T),token:N.token}));return i.restore(),F}getCachedTokenBoxesForVisibleCell=Zn((e,t,n,s,i,o)=>{const r=i,c=[];let h=0,u=0;for(let m=0;m<t.length;m+=1){const g=t[m],{start:p,end:C}=g,f=C>e.length?e.substring(p):g.value;u+=o.measureText(e.substring(h,p)).width;const S=o.measureText(f).width,v=u,w=v+S,T={x1:v,y1:0,x2:w,y2:r,token:g};c.push(T),h=C,u+=S}return c},{max:1e4})}const Ad=100;class Xw extends dt{startPoint;hasExtendedFloating=!1;timer;lastTriggerTime;dragBounds;onDown(e,t,n){const{x:s,y:i,column:o,row:a}=e,{metrics:r}=t;if(!r)throw new Error("metrics not set");const{gridX:c,gridY:h,maxX:u,maxY:m}=r,g=s-c,p=i-h;if(g<0||p<0||o==null&&g>u||a==null&&p>m)return!1;const C=V.isModifierKeyDown(n),f=n.shiftKey;C||(f?t.trimSelectedRanges():t.clearSelectedRanges());const S=t.getTheme(),{autoSelectRow:v,autoSelectColumn:w}=S;return(o!==null||!w)&&(a!==null||!v)&&(t.focus(),t.moveCursorToPosition(o,a,f,!1,f&&C)),this.startPoint=e,this.hasExtendedFloating=!1,this.dragBounds=V.getScrollDragBounds(r,a,o),!0}onDrag(e,t){if(this.startPoint===void 0)return!1;this.stopTimer();const{row:n,column:s}=this.startPoint,{x:i,y:o}=e;let{row:a,column:r}=e;const{metrics:c}=t;if(!c)throw new Error("metrics not set");const{left:h,lastLeft:u,top:m,lastTop:g,columnWidth:p,rowHeight:C}=c,f=V.getScrollDragBounds(c,n,s);let S=0,v=0;if(h<u&&(i<f.x1?S=i-f.x1:i>f.x2&&(S=i-f.x2)),m<g&&(o<f.y1?v=o-f.y1:o>f.y2&&(v=o-f.y2)),S!==0||v!==0)this.startTimer(t,e,S>0?Math.ceil(S/p):Math.floor(S/p),v>0?Math.ceil(v/C):Math.floor(v/C));else if(a!=null&&r!=null){const{floatingTopRowCount:w,floatingBottomRowCount:T,floatingLeftColumnCount:y,floatingRightColumnCount:E,columnCount:D,rowCount:F,bottom:N,right:_,topVisible:P,bottomVisible:U,leftVisible:O,rightVisible:j}=c;this.hasExtendedFloating||(n!==null&&n<w&&a>=w?(a=w,this.hasExtendedFloating=!0):n!==null&&n>=F-T&&a<F-T&&(a=F-T-1,this.hasExtendedFloating=!0),s!==null&&s<y&&r>=y?(r=y,this.hasExtendedFloating=!0):s!==null&&s>=D-E&&r<D-E&&(r=D-E-1,this.hasExtendedFloating=!0)),n!==null&&!V.isFloatingRow(n,c)&&V.isFloatingRow(a,c)&&(n>a&&a<m?a=P-1:n<a&&a>N&&(a=U+1)),s!==null&&!V.isFloatingColumn(s,c)&&V.isFloatingColumn(r,c)&&(s>r&&r<h?r=O-1:s<r&&r>_&&(r=j+1)),t.moveCursorToPosition(r,a,!0,!0)}return!0}onUp(e,t){return this.startPoint!==void 0&&(this.startPoint=void 0,this.dragBounds=void 0,this.stopTimer(),t.commitSelection()),!1}moveSelection(e,t,n,s){const{row:i,column:o}=t,{metrics:a}=e;if(!a)throw new Error("metrics not set");const{selectionEndRow:r,selectionEndColumn:c}=e.state;if(r==null||c==null)throw new Error("selection not set");const{rowCount:h,columnCount:u}=a,m=n<0&&o!=null?o:0,g=n>0&&o!=null?o:u-1,p=s<0&&i!=null?i:0,C=s>0&&i!=null?i:h-1;e.moveCursorToPosition(Math.min(Math.max(m,c+n),g),Math.min(Math.max(p,r+s),C),!0),this.lastTriggerTime=Date.now()}startTimer(e,t,n,s){this.stopTimer();const i=this.lastTriggerTime!=null?Ad-Math.min(Ad,Date.now()-this.lastTriggerTime):0;this.timer=setTimeout(()=>{this.moveSelection(e,t,n,s),this.startTimer(e,t,n,s)},i)}stopTimer(){this.timer!==void 0&&(clearTimeout(this.timer),this.timer=void 0)}}const Ld=5,Zw=1e3/60,ca=10;function gs(d,e,t,n){const{modelColumns:s,movedColumns:i,allColumnXs:o,columnCount:a,allColumnWidths:r,userColumnWidths:c,calculatedColumnWidths:h,floatingLeftWidth:u,maxX:m}=t;if(e==null||d==null||d>a||d<0)return null;const g=s.get(d)??V.getModelIndex(d,i),p=n.getColumnHeaderGroup(g,e),C=p!=null;let f,S,v;if(p!=null){const[w,T]=p.getVisibleRange(i);f=o.get(w)??u,S=(o.get(T)??m)+(r.get(T)??0),v=[w,T]}else{const w=o.get(d);if(w==null)return null;f=w,S=f+(r.get(d)??c.get(g)??h.get(g)??0),v=[d,d]}return{visibleIndex:d,modelIndex:g,left:f,right:S,width:S-f,isColumnGroup:C,range:v,depth:e}}class Qw extends dt{cursor=null;draggingOffset;initialOffset;initialGridPoint;scrollingInterval;scrollingDirection;draggingColumn=null;setScrollInterval(e,t){this.scrollingInterval!=null&&t===this.scrollingDirection||(this.scrollingDirection=t,this.scrollingInterval=window.setInterval(()=>{const{metrics:n}=e;if(!n)return;const{left:s,lastLeft:i,leftOffset:o,userColumnWidths:a,calculatedColumnWidths:r,movedColumns:c,allColumnWidths:h}=n;let u=s,m=o;if(t==="left")for(m-=ca;m<0;){u-=1;const C=V.getModelIndex(s-1,c),f=a.get(C)??r.get(C);f===void 0?m=0:m+=f,u<0&&(m=0,u=0)}else{m+=ca;let C=h.get(s);for(;C!==void 0&&m>C;){u+=1,m-=C;const f=V.getModelIndex(s+1,c);C=a.get(f)??r.get(f),u>i&&(m=0,u=i)}}const{mouseX:g,mouseY:p}=e.state;n==null||g==null||p==null||(this.moveDraggingColumn(g,e,t==="left"?-ca:ca),e.setState({left:u,leftOffset:m}),(t==="left"&&u===0&&o===0||t==="right"&&u===i)&&this.clearScrollInterval())},Zw))}clearScrollInterval(){this.scrollingDirection=void 0,window.clearInterval(this.scrollingInterval),this.scrollingInterval=void 0}onLeave(){return this.clearScrollInterval(),!1}onDown(e,t){const{model:n}=t.props,{x:s,column:i,columnHeaderDepth:o}=e,{metrics:a}=t;if(!a)throw new Error("Metrics not set");const r=gs(i,o,a,n);if(i==null||r==null||o==null||o>0&&!r.isColumnGroup)return!1;const{rowHeaderWidth:c}=a;return this.initialGridPoint=e,this.draggingColumn=null,this.cursor=null,r.modelIndex!=null&&o!=null&&n.isColumnMovable(r.modelIndex,o)&&(this.draggingOffset=s-r.left-c,this.initialOffset=this.draggingOffset),!1}onDrag(e,t,n){if(this.draggingOffset===void 0||this.initialGridPoint===void 0||this.initialOffset===void 0)return!1;const{x:s,y:i}=e,{columnHeaderDepth:o}=this.initialGridPoint,{model:a}=t.props;let{draggingColumn:r}=this;const{metrics:c}=t;if(!c)throw new Error("Metrics not set");if(!r&&Math.abs(this.initialGridPoint.x-s)<Ld&&Math.abs(this.initialGridPoint.y-i)<Ld)return!1;if(r==null){const h=gs(this.initialGridPoint.column,o,c,a);if(!h||o==null||!a.isColumnMovable(h.modelIndex)||o>0&&!h.isColumnGroup||h.range[0]==null)return!1;r={range:h.range,depth:o,left:h.left,width:h.width};const u=gs(r.range[0],0,c,a),m=gs(r.range[1],0,c,a);if(!u||!m)return!1;this.draggingColumn=r,t.setState({draggingColumn:r,isDragging:!0})}return this.cursor="move",this.moveDraggingColumn(e.x,t,n.movementX),!0}moveDraggingColumn(e,t,n){if(this.draggingOffset===void 0||this.initialGridPoint===void 0||this.initialOffset===void 0||this.draggingColumn==null||n===0)return;if(this.initialOffset!==this.draggingOffset){this.draggingOffset<this.initialOffset&&this.initialOffset<this.draggingOffset+n||this.draggingOffset>this.initialOffset&&this.initialOffset>this.draggingOffset+n?this.draggingOffset=this.initialOffset:this.draggingOffset+=n,this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},t.setState({draggingColumn:this.draggingColumn});return}const{depth:s}=this.draggingColumn,{model:i}=t.props,{movedColumns:o}=t.state,{metrics:a}=t;if(!a)throw new Error("Metrics not set");const{floatingLeftWidth:r,width:c,columnHeaderMaxDepth:h,allColumnXs:u}=a,m=n<0,g=gs(this.draggingColumn.range[0],s,a,i);if(!g)return;const p=e-this.draggingOffset,C=p+g.width;this.draggingColumn={...this.draggingColumn,left:p},t.setState({draggingColumn:this.draggingColumn});const f=gs(V.getColumnAtX(He(m?p:C,r,c),a,!0),s,a,i),S=i.getColumnHeaderParentGroup(g.modelIndex,g.depth);if(!f)return;if(S!==void 0){const D=S.getVisibleRange(o);if(f.visibleIndex<D[0]){const F=this.moveColumn(g,D[0],o);this.draggingOffset=e-(u.get(D[0])??0),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},this.clearScrollInterval(),t.setState({draggingColumn:this.draggingColumn,movedColumns:F});return}if(f.visibleIndex>D[1]){const F=this.moveColumn(g,D[1]-(g.range[1]-g.range[0]),o),{right:N=0}=gs(D[1],0,a,i)??{};this.draggingOffset=e-(N-g.width),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},this.clearScrollInterval(),t.setState({draggingColumn:this.draggingColumn,movedColumns:F});return}}if(!i.isColumnMovable(f.modelIndex)){let D=f.visibleIndex;if(m)for(D+=1;D<g.visibleIndex&&!i.isColumnMovable(V.getModelIndex(D,o));)D+=1;else for(D-=1;D>g.visibleIndex&&!i.isColumnMovable(V.getModelIndex(D,o));)D-=1;if(D!==g.visibleIndex){m||(D-=g.range[1]-g.range[0]);const N=this.moveColumn(g,D,o);t.setState({movedColumns:N,draggingColumn:this.draggingColumn})}const F=gs(D,0,a,i);m?this.draggingOffset=e-(F?.left??0):this.draggingOffset=e-((F?.right??0)-g.width),this.draggingColumn={...this.draggingColumn,left:e-this.draggingOffset},t.setState({draggingColumn:this.draggingColumn});return}if(p<=r?this.setScrollInterval(t,"left"):C>c?this.setScrollInterval(t,"right"):this.clearScrollInterval(),f.visibleIndex===g.visibleIndex||m&&g.visibleIndex<f.visibleIndex||!m&&g.visibleIndex>f.visibleIndex)return;const v=f.left+f.width*.5,w=i.getColumnHeaderParentGroup(g.modelIndex,g.depth);let T,y=(w?.depth??h)-1;for(;y>=0&&T===void 0;)T=i.getColumnHeaderGroup(f.modelIndex,y),y-=1;let E;m&&p<v&&(!T||f.visibleIndex===T.getVisibleRange(o)[0])&&(E=this.moveColumn(g,f.range[0],o)),!m&&C>v&&(!T||f.visibleIndex===T.getVisibleRange(o)[1])&&(E=this.moveColumn(g,f.range[1]-(g.range[1]-g.range[0]),o)),E&&(this.draggingColumn={...this.draggingColumn,left:p},t.setState({movedColumns:E,draggingColumn:this.draggingColumn}))}moveColumn(e,t,n){const s=e.isColumnGroup?V.moveRange(e.range,t,n):V.moveItem(e.visibleIndex,t,n),i=t-e.range[0],o=[e.range[0]+i,e.range[1]+i];return this.draggingColumn&&(this.draggingColumn={...this.draggingColumn,range:o}),s}onUp(e,t){return this.cursor=null,this.clearScrollInterval(),this.draggingOffset!=null?(this.draggingOffset=void 0,t.setState({draggingColumn:null,isDragging:!1}),!0):!1}}class ac extends dt{static getLeftWithOffsetFromRawLeft(e,t){const n=e.getTheme(),{metrics:s,metricCalculator:i}=e;if(!s)throw new Error("metrics not set");if(n.scrollSnapToColumn)return{left:Math.round(t),leftOffset:0};const o=Math.floor(t),a=t-o;let r=s.allColumnWidths.get(o);if(r==null){const h=e.getMetricState();r=i.getVisibleColumnWidth(o,h)}const c=r*a;return{left:o,leftOffset:c}}dragOffset;cursor="default";isInScrollBar(e,t){const n=t.getTheme(),{scrollBarSize:s,scrollBarHoverSize:i}=n,{metrics:o}=t;if(!o)throw new Error("metrics not set");const{x:a,y:r}=e,{barLeft:c,barWidth:h,height:u,hasHorizontalBar:m}=o;return m&&s>0&&r>=u-i&&r<u&&a>c&&a<c+h}getLeftWithOffset(e,t){const{metrics:n}=t;if(!n)throw new Error("metrics not set");const{x:s}=e,{barWidth:i,handleWidth:o,lastLeft:a,barLeft:r,columnCount:c,scrollableContentWidth:h,scrollableViewportWidth:u}=n,m=s-r,g=He((m-(this.dragOffset??0))/(i-o),0,1);if(c===1)return{left:0,leftOffset:g*(h-u)};const p=g*a;return ac.getLeftWithOffsetFromRawLeft(t,p)}onDown(e,t){const{metrics:n}=t;if(!n)throw new Error("metrics not set");const{x:s}=e,{handleWidth:i,barLeft:o,scrollX:a}=n;if(!this.isInScrollBar(e,t))return!1;const r=s-o;if(r>=a&&r<=a+i)this.dragOffset=r-a,t.setState({isDraggingHorizontalScrollBar:!0});else{this.dragOffset=0;const{left:c,leftOffset:h}=this.getLeftWithOffset(e,t);t.setViewState({left:c,leftOffset:h,isDraggingHorizontalScrollBar:!0,isDragging:!0})}return!0}onDrag(e,t){if(this.dragOffset!=null){const{left:n,leftOffset:s}=this.getLeftWithOffset(e,t);return t.setViewState({left:n,leftOffset:s,isDraggingHorizontalScrollBar:!0,isDragging:!0}),!0}return!1}onMove(e,t){return this.isInScrollBar(e,t)}onUp(e,t){return this.dragOffset!==void 0&&(this.dragOffset=void 0,t.setState({isDraggingHorizontalScrollBar:!1,isDragging:!1})),this.isInScrollBar(e,t)}onClick(e,t){return this.isInScrollBar(e,t)}}class Jw extends dt{cursor="move";draggingOffset;onDown(e,t){const{model:n}=t.props,{x:s,y:i,row:o}=e,{metrics:a}=t;if(!a)throw new Error("metrics not set");const{columnHeaderHeight:r,rowHeaderWidth:c,allRowYs:h}=a;if(s<=c&&o!==null&&n.isRowMovable(o)){const u=L(h,o);this.draggingOffset=i-u-r,t.setState({draggingRowOffset:this.draggingOffset})}return!1}onDrag(e,t){if(this.draggingOffset==null)return!1;const{model:n}=t.props;let{draggingRow:s}=t.state;const{mouseX:i,mouseY:o}=t.state;if(i==null||o==null)return!1;if(s==null){const{row:E}=t.getGridPointFromXY(i,o);if(E!=null&&!n.isRowMovable(E)||(s=E,t.setState({draggingRow:s,isDragging:!0}),s==null))return!1}const{metrics:a}=t;if(!a)throw new Error("metrics not set");const{top:r,lastTop:c,bottom:h,bottomVisible:u,rowCount:m,columnHeaderHeight:g,allRowHeights:p,allRowYs:C,height:f}=a;let S=g;if(r<s){const E=s-1;S=L(C,E)+L(p,E)*.5+g}let v=f;if(s<h){const E=s+1;v=L(C,E)+L(p,E)*.5+g}let{movedRows:w}=t.state;o<S&&s>0&&n.isRowMovable(s-1)?(w=V.moveItem(s,s-1,w),s-=1):v<o&&s<m-1&&n.isRowMovable(s+1)&&(w=V.moveItem(s,s+1,w),s+=1),t.setState({movedRows:w,draggingRow:s});const T=g+L(p,r)*.5,y=g+L(C,u)+L(p,u)*.5;return o<T&&r>0?t.setState({top:r-1}):o>y&&r<c&&t.setState({top:r+1}),!0}onUp(e,t){return this.draggingOffset!==void 0?(this.draggingOffset=void 0,t.setState({draggingRowOffset:null,draggingRow:null,isDragging:!1}),!0):!1}}class rc extends Qu{static getRowSeparator(e,t,n,s){if(!s.allowRowResize)return null;const{x:i,y:o}=e,a=V.getRowSeparatorIndex(i,o,t,s);return a!=null?{index:a,depth:0}:null}hiddenCursor="s-resize";defaultCursor="row-resize";pointProperty="y";userSizesProperty="userRowHeights";visibleOffsetProperty="visibleRowYs";visibleSizesProperty="visibleRowHeights";marginProperty="columnHeaderHeight";calculatedSizesProperty="calculatedRowHeights";initialSizesProperty="initialRowHeights";modelIndexesProperty="modelRows";firstIndexProperty="firstRow";treePaddingProperty="treePaddingY";getHiddenItems=V.getHiddenRows;getNextShownItem=V.getNextShownRow;setSize(e,t,n){e.setRowHeight(t,n)}resetSize(e,t){e.resetRowHeight(t)}updateSeparator(e,t){e.setState({draggingRowSeparator:t,isDragging:t!==null})}getSeparator=rc.getRowSeparator}class Wi extends dt{static isInTreeBox(e,t){const{column:n,row:s,x:i,y:o}=e,{metrics:a}=t;if(!a)throw new Error("metrics not set");const{gridX:r,gridY:c,firstColumn:h,allColumnXs:u,allColumnWidths:m,allRowHeights:g,allRowYs:p,visibleRowTreeBoxes:C}=a;if(n===h&&s!=null&&C.get(s)!=null&&i>r&&o>c){const f=L(u,n),S=L(m,n),v=L(p,s),w=L(g,s);if(i>=r+f&&i<=r+f+S&&o>=c+v&&o<=c+v+w)return!0}return!1}onDown(e,t){return Wi.isInTreeBox(e,t)}onClick(e,t,n){if(Wi.isInTreeBox(e,t)){const{row:s}=e;if(s!==null)return t.toggleRowExpanded(s,V.isModifierKeyDown(n)),!0}return!1}}class ev extends dt{isInCorner(e,t){const n=t.getTheme(),{scrollBarSize:s}=n,{metrics:i}=t;if(!i)throw new Error("metrics not set");const{x:o,y:a}=e,{width:r,height:c,hasVerticalBar:h,hasHorizontalBar:u}=i;return s>0&&h&&u&&o>=r-s&&a>=c-s&&o<=r&&a<=c}onDown(e,t){return this.isInCorner(e,t)}onUp(e,t){return this.isInCorner(e,t)}onClick(e,t){return this.isInCorner(e,t)}}class lc extends dt{static getTopWithOffsetFromRawTop(e,t){const n=e.getTheme(),{metrics:s,metricCalculator:i}=e;if(!s)throw new Error("metrics not set");if(n.scrollSnapToRow)return{top:Math.round(t),topOffset:0};const o=Math.floor(t),a=t-o;let r=s.allRowHeights.get(o);if(r==null){const h=e.getMetricState();r=i.getVisibleRowHeight(o,h)}const c=r*a;return{top:o,topOffset:c}}dragOffset;cursor="default";isInScrollBar(e,t){const n=t.getTheme(),{scrollBarSize:s,scrollBarHoverSize:i}=n,{metrics:o}=t;if(!o)throw new Error("metrics not set");const{x:a,y:r}=e,{barTop:c,barHeight:h,width:u,hasVerticalBar:m}=o;return m&&s>0&&a>=u-i&&a<u&&r>c&&r<c+h}getTopWithOffset(e,t){const{metrics:n}=t;if(!n)throw new Error("metrics not set");const{y:s}=e,{barHeight:i,handleHeight:o,lastTop:a,barTop:r,rowCount:c,scrollableContentHeight:h,scrollableViewportHeight:u}=n,m=s-r,g=He((m-(this.dragOffset??0))/(i-o),0,1);if(c===1)return{top:0,topOffset:g*(h-u)};const p=g*a;return lc.getTopWithOffsetFromRawTop(t,p)}onDown(e,t){const{metrics:n}=t;if(!n)throw new Error("metrics not set");const{y:s}=e,{handleHeight:i,barTop:o,scrollY:a}=n;if(!this.isInScrollBar(e,t))return!1;const r=s-o;if(r>=a&&r<=a+i)this.dragOffset=r-a,t.setState({isDraggingVerticalScrollBar:!0});else{this.dragOffset=0;const{top:c,topOffset:h}=this.getTopWithOffset(e,t);t.setViewState({top:c,topOffset:h,isDraggingVerticalScrollBar:!0,isDragging:!0})}return!0}onMove(e,t){return this.isInScrollBar(e,t)}onDrag(e,t){if(this.dragOffset!=null){const{top:n,topOffset:s}=this.getTopWithOffset(e,t);return t.setViewState({top:n,topOffset:s,isDraggingVerticalScrollBar:!0,isDragging:!0}),!0}return!1}onUp(e,t){return this.dragOffset!==void 0&&(this.dragOffset=void 0,t.setState({isDraggingVerticalScrollBar:!1,isDragging:!1})),this.isInScrollBar(e,t)}onClick(e,t){return this.isInScrollBar(e,t)}}class tv extends dt{onDoubleClick({column:e,row:t},n){const{model:s}=n.props;return Ze(s)&&e!=null&&t!=null&&s.isEditableRange(z.makeCell(e,t))?(n.startEditing(e,t),!0):!1}}class cc extends dt{timeoutId;isHold=!1;isDown=!1;currentLinkBox;static HOLD_LENGTH=1e3;isHoveringLink(e,t){const{column:n,row:s,x:i,y:o}=e,{renderer:a,metrics:r}=t;if(n==null||s==null||r==null)return this.currentLinkBox=void 0,!1;if(this.currentLinkBox!=null){const{x1:u,y1:m,x2:g,y2:p}=this.currentLinkBox;if(i>=u&&i<=g&&o>=m&&o<=p)return!0}const c=t.updateRenderState(),h=a.getTokenBoxesForVisibleCell(n,s,c);for(let u=0;u<h.length;u+=1)if(Ba(h[u].token)){const m=V.translateTokenBox(h[u],r),{x1:g,x2:p,y1:C,y2:f}=m;if(i>=g&&i<=p&&o>=C&&o<=f)return this.currentLinkBox=m,!0}return this.currentLinkBox=void 0,!1}setCursor(e,t){return this.isHoveringLink(e,t)?this.cursor="pointer":this.cursor=null,!1}onMove(e,t){return this.setCursor(e,t)}onDown(e,t,n){const s=this.isHoveringLink(e,t);return V.isModifierKeyDown(n)||n.shiftKey||!s?!1:(this.isDown=!0,this.timeoutId!=null&&clearTimeout(this.timeoutId),this.isHold=!1,this.timeoutId=setTimeout(()=>{this.isHold=!0;const{column:i,row:o}=e,{model:a}=t.props;t.clearSelectedRanges(),t.focus(),t.moveCursorToPosition(i,o),Ze(a)&&i!=null&&o!=null&&a.isEditableRange(z.makeCell(i,o))&&t.startEditing(i,o)},cc.HOLD_LENGTH),!0)}onClick(e,t){return!this.isHoveringLink(e,t)||!this.isDown||this.currentLinkBox==null?(this.isDown=!1,this.isHold=!1,!1):(this.isHold||(this.timeoutId!=null&&clearTimeout(this.timeoutId),this.timeoutId=void 0,t.props.onTokenClicked(this.currentLinkBox?.token)),this.isHold=!1,this.isDown=!1,!0)}}class ui{order;constructor(e=5e3){this.order=e}onDown(e,t){return!1}}class nv extends ui{onDown(e,t){switch(e.key){case"a":if(V.isModifierKeyDown(e))return t.selectAll(),!0;break;case"ArrowUp":return this.handleArrowMove(0,-1,e,t);case"ArrowDown":return this.handleArrowMove(0,1,e,t);case"ArrowRight":return this.handleArrowMove(1,0,e,t);case"ArrowLeft":return this.handleArrowMove(-1,0,e,t);case"k":case"K":return V.isModifierKeyDown(e)?!1:this.handlePageUp(e,t);case"j":case"J":return V.isModifierKeyDown(e)?!1:this.handlePageDown(e,t);case"h":case"H":return V.isModifierKeyDown(e)?!1:(e.shiftKey||t.clearSelectedRanges(),t.moveCursorToPosition(0,t.state.cursorRow,e.shiftKey),!0);case"l":case"L":{if(V.isModifierKeyDown(e))return!1;const{model:n}=t.props,{columnCount:s}=n;return e.shiftKey||t.clearSelectedRanges(),t.moveCursorToPosition(s-1,t.state.cursorRow,e.shiftKey),!0}case"PageDown":return this.handlePageDown(e,t);case"PageUp":return this.handlePageUp(e,t);case"Home":return e.shiftKey||t.clearSelectedRanges(),t.moveCursorToPosition(V.isModifierKeyDown(e)?t.state.cursorColumn:0,V.isModifierKeyDown(e)?0:t.state.cursorRow,e.shiftKey,!0,!0),!0;case"End":{const{model:n}=t.props,{columnCount:s,rowCount:i}=n;return e.shiftKey||t.clearSelectedRanges(),t.moveCursorToPosition(V.isModifierKeyDown(e)?t.state.cursorColumn:s-1,V.isModifierKeyDown(e)?i-1:t.state.cursorRow,e.shiftKey,!0,!0),!0}case"Escape":return t.clearSelectedRanges(),{preventDefault:!1,stopPropagation:!1};case"Enter":if(t.state.selectedRanges.length>0)return t.moveCursorInDirection(e.shiftKey?z.SELECTION_DIRECTION.UP:z.SELECTION_DIRECTION.DOWN),!0;break;case"Tab":if(t.state.selectedRanges.length>0)return t.moveCursorInDirection(e.shiftKey?z.SELECTION_DIRECTION.LEFT:z.SELECTION_DIRECTION.RIGHT),!0;break}return!1}handleArrowMove(e,t,n,s){const i=n.shiftKey,o=V.isModifierKeyDown(n);i?s.trimSelectedRanges():s.clearSelectedRanges();const{cursorRow:a,cursorColumn:r,selectionEndColumn:c,selectionEndRow:h}=s.state,u=i?c:r,m=i?h:a;if(o){const{model:g}=s.props,{columnCount:p,rowCount:C}=g,f=o&&i;let S=null,v=null;e<0?(S=0,v=m):e>0?(S=p-1,v=m):t<0?(S=u,v=0):t>0&&(S=u,v=C-1),S!=null&&v!=null&&s.moveCursorToPosition(S,v,i,!0,f)}else{if(!s.metrics)throw new Error("grid.metrics are not set");const{theme:g}=s.props,{autoSelectRow:p=!1,autoSelectColumn:C=!1}=g;if(p&&e!==0){const{lastLeft:f}=s.metrics;let{left:S}=s.state;S=He(S+e,0,f),s.moveCursorToPosition(S,a,i,!1),s.setViewState({left:S})}else if(C&&t!==0){const{lastTop:f}=s.metrics;let{top:S}=s.state;S=He(S+t,0,f),s.moveCursorToPosition(S,r,i,!1),s.setViewState({top:S})}else s.moveCursor(e,t,i)}return!0}handlePageUp(e,t){const n=e.shiftKey;n?t.trimSelectedRanges():t.clearSelectedRanges();const{cursorColumn:s,selectionEndRow:i}=t.state,o=i,a=s;if(o==null)return!1;const r=t.getMetricState(),{metricCalculator:c}=t,{bottomVisible:h,topVisible:u,hasHorizontalBar:m}=c.getMetrics(r);let g=o-(h-u);g-=m?0:1,g=Math.max(g,0);const p=Math.max(g-(o-u),0);return t.moveCursorToPosition(a,g,n,!1),t.setViewState({top:p}),!0}handlePageDown(e,t){const n=e.shiftKey;n?t.trimSelectedRanges():t.clearSelectedRanges();const{selectionEndRow:s,cursorColumn:i}=t.state,o=s,a=i;if(o===null)return!1;const r=t.getMetricState(),{metricCalculator:c}=t,{bottomVisible:h,topVisible:u,hasHorizontalBar:m,rowCount:g,lastTop:p}=c.getMetrics(r),C=g-1;let f=h-u+o;f+=m?0:1,f=Math.min(f,C);const S=Math.min(p,f-(o-u));return t.moveCursorToPosition(a,f,n,!1),t.setViewState({top:S}),!0}}class sv extends ui{onDown(e,t){switch(e.key){case"Enter":case" ":return this.handleExpandKey(e,t)}return!1}handleExpandKey(e,t){const{selectedRanges:n}=t.state;if(n.length===1){const s=n[0];if(s.startRow===s.endRow&&s.startColumn===s.endColumn){if(!t.metrics)throw new Error("grid.metrics not set");const{model:i}=t.props,{startRow:o,startColumn:a}=s;if(o!=null){const r=t.getModelRow(o);if((a===0||a==null)&&qe(i)&&i.isRowExpandable(r))return t.toggleRowExpanded(o),!0}}}return!1}}class iv extends ui{onDown(e,t){if(V.isModifierKeyDown(e))return!1;const{model:n}=t.props,{cursorColumn:s,cursorRow:i}=t.state;if(s==null||i==null||!Ze(n)||!n.isEditableRange(z.makeCell(s,i)))return!1;const o=s,a=i;return o==null||a==null?!1:e.key.length===1?(t.startEditing(o,a,!0,[1,1],e.key),!0):e.key==="F2"?(t.startEditing(o,a),!0):e.key==="Backspace"?(t.startEditing(o,a,!0,void 0,""),!0):e.key==="Delete"?(t.setValueForCell(o,a,""),!0):!1}}function ov(d){const e=[],t=d.querySelectorAll("tr");for(let n=0;n<t.length;n+=1){const i=t[n].querySelectorAll("td"),o=[];for(let a=0;a<i.length;a+=1){const r=i[a];o.push(r.textContent?.trim()??"")}e.push(o)}return e}function av(d){const e=[];return d.forEach(t=>{const n=t.textContent??"";n.length>0&&e.push(n.split(/\t|\u00a0\u00a0 \u00a0/))}),e}function rv(d){const e=d.querySelector("table");if(e!=null)return ov(e);const t=d.textContent?.trim()??"";if(t.length>0){const{childNodes:n}=d,s=t.includes(" "),i=t.includes("    ");return s&&n.length!==0&&(n.length===1||n.length>1&&(n[0].textContent==null||!n[0].textContent.includes(" ")))?t.split(`
20
- `).map(o=>o.split(" ")):n.length>1||i?av(d.childNodes):t}return null}class lv extends ui{onDown(e,t){switch(e.key){case"v":if(V.isModifierKeyDown(e)){const n=document.createElement("div");document.body.appendChild(n),n.setAttribute("contenteditable","true"),n.setAttribute("style",'clip-path: "inset(50%)"; height: 1px; width: 1px; margin: -1px; overflow: hidden; padding 0; position: absolute;');const s=()=>{n.removeEventListener("input",s),n.remove(),t.focus();const i=rv(n);i!=null&&t.pasteValue(i)};return n.addEventListener("input",s),n.focus(),{preventDefault:!1,stopPropagation:!0}}break}return!1}}const cv=d=>{switch(d){case"ArrowDown":return En.DOWN;case"ArrowUp":return En.UP;case"ArrowLeft":return En.LEFT;case"ArrowRight":return En.RIGHT;default:return}};function dc({selectionRange:d=void 0,className:e="",disabled:t=!1,value:n="",isQuickEdit:s=!0,onChange:i=()=>{},onCancel:o=()=>{},onDone:a=()=>{},onContextMenu:r=()=>{},style:c={}}){const h=b.useRef(null),u=b.useRef(!1),[m]=b.useState(n),[g,p]=b.useState(!1),[C,f]=b.useState(s),[S,v]=b.useState(n);b.useEffect(function(){const{current:U}=h;U!=null&&(U.focus(),d?U.setSelectionRange(d[0],d[1]):U.setSelectionRange(U.value.length,U.value.length))},[d]);const w=b.useCallback(P=>{i(P)},[i]),T=b.useCallback(P=>{const{value:U}=P.target;v(U),p(!0),w(U)},[w,v,p]),y=b.useCallback(()=>{u.current=!0,g&&w(m),p(!1),o()},[m,g,o,w]),E=b.useCallback(()=>{f(!1)},[f]),D=b.useCallback((P,U=!1)=>{a(S,{direction:P,fillRange:U})},[a,S]),F=b.useCallback(()=>{u.current||D(null)},[u,D]),N=b.useCallback(P=>{switch(P.stopPropagation(),P.key){case"Escape":P.preventDefault(),y();break;case"Enter":if(P.preventDefault(),V.isModifierKeyDown(P))D(void 0,!0);else if(P.altKey){const U=`${S}
21
- `;v(U),p(!0),w(U)}else D(P.shiftKey?En.UP:En.DOWN);break;case"Tab":P.preventDefault(),D(P.shiftKey?En.LEFT:En.RIGHT);break;case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":C&&(P.preventDefault(),D(cv(P.key)));break}},[y,D,C,v,p,w,S]),_=b.useCallback(P=>{r(P)},[r]);return l.jsx("textarea",{ref:h,className:$("grid-cell-input-field",e),value:S,onBlur:F,onChange:T,onKeyDown:N,onContextMenu:_,onClick:E,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false",disabled:t,style:c})}dc.propTypes={selectionRange:I.arrayOf(I.number),className:I.string,disabled:I.bool,isQuickEdit:I.bool,value:I.string,onChange:I.func,onCancel:I.func,onDone:I.func,onContextMenu:I.func,style:I.shape({})};dc.defaultProps={selectionRange:null,className:"",disabled:!1,value:"",isQuickEdit:!0,onChange:()=>{},onCancel:()=>{},onDone:()=>{},onContextMenu:()=>{},style:{}};const dv=J.createContext({});class Es extends b.PureComponent{static contextType=dv;static defaultProps={canvasOptions:{alpha:!1},isStickyBottom:!1,isStickyRight:!1,isStuckToBottom:!1,isStuckToRight:!1,keyHandlers:Fe,mouseHandlers:Fe,movedColumns:Fe,movedRows:Fe,onError:()=>{},onSelectionChanged:()=>{},onMovedColumnsChanged:e=>{},onMoveColumnComplete:()=>{},onMovedRowsChanged:()=>{},onMoveRowComplete:()=>{},onViewChanged:()=>{},onTokenClicked:e=>{Ba(e)&&window.open(e.href,"_blank","noopener,noreferrer")},stateOverride:{},theme:{autoSelectColumn:!1,autoSelectRow:!1}};static pixelsPerLine=100/3;static dragTimeout=1e3;static getTheme=fe((e,t)=>({...Kw,...e,...t}));static getScale(e){const t=window.devicePixelRatio||1,n=e,s=n.webkitBackingStorePixelRatio??n.mozBackingStorePixelRatio??n.msBackingStorePixelRatio??n.oBackingStorePixelRatio??n.backingStorePixelRatio??1;return t/s}static getCursorClassName(e){return e!=null&&e!==""?`grid-cursor-${e}`:null}renderer;metricCalculator;canvas;canvasContext;animationFrame;prevMetrics;metrics;renderState;documentCursor;dragTimer;keyHandlers;mouseHandlers;constructor(e){super(e),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:t,isStuckToRight:n,metricCalculator:s,movedColumns:i,movedRows:o,renderer:a}=e;this.renderer=a||new Pt,this.metricCalculator=s||new _o,this.canvas=null,this.canvasContext=null,this.animationFrame=null,this.prevMetrics=null,this.metrics=null,this.renderState={},this.documentCursor=null,this.dragTimer=null,this.keyHandlers=[new iv(400),new lv(450),new nv(500),new sv(900)],this.mouseHandlers=[new rc(100),new vr(200),new Jw(300),new Qw(400),new tv(450),new lc(500),new ac(600),new ev(700),new Wi(800),new cc(825),new Xw(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:Fe,lastSelectedRanges:Fe,cursor:null,editingCell:null,isStuckToBottom:t,isStuckToRight:n}}componentDidMount(){this.initContext(),this.canvas?.addEventListener("wheel",this.handleWheel,{passive:!1}),window.addEventListener("resize",this.handleResize),this.updateCanvas();const{isStuckToBottom:e,isStuckToRight:t}=this.props;e&&this.scrollToBottom(),t&&this.scrollToRight()}componentDidUpdate(e,t){const{isStickyBottom:n,isStickyRight:s,movedColumns:i,movedRows:o,onMovedColumnsChanged:a,onMoveColumnComplete:r,onMovedRowsChanged:c,onMoveRowComplete:h}=this.props,{isStickyBottom:u,isStickyRight:m,movedColumns:g,movedRows:p}=e,{movedColumns:C,movedRows:f}=t,{draggingColumn:S,draggingRow:v,movedColumns:w,movedRows:T}=this.state;g!==i&&this.setState({movedColumns:i}),p!==o&&this.setState({movedRows:o}),C!==w&&a(w),t.draggingColumn!=null&&S==null&&r(w),f!==T&&c(T),t.draggingRow!=null&&v==null&&h(T),n!==u&&this.setState({isStuckToBottom:!1}),s!==m&&this.setState({isStuckToRight:!1}),this.updateMetrics(),this.requestUpdateCanvas(),this.checkStickyScroll(),this.validateSelection()&&this.checkSelectionChange(t)}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:e}=this.props;return Es.getTheme(this.context,e)}getGridPointFromEvent(e){Nd(this.canvas);const t=this.canvas.getBoundingClientRect(),n=e.clientX-t.left,s=e.clientY-t.top;return this.getGridPointFromXY(n,s)}getGridPointFromXY(e,t){if(!this.metrics)throw new Error("metrics must be set");return V.getGridPointFromXY(e,t,this.metrics)}getMetricState(e=this.state){const t=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,a=this.canvas.clientHeight,{left:r,top:c,leftOffset:h,topOffset:u,movedColumns:m,movedRows:g,isDraggingHorizontalScrollBar:p,isDraggingVerticalScrollBar:C,draggingColumn:f}=e;return{left:r,top:c,leftOffset:h,topOffset:u,width:o,height:a,context:i,theme:t,model:n,movedColumns:m,movedRows:g,isDraggingHorizontalScrollBar:p,isDraggingVerticalScrollBar:C,draggingColumn:f,...s}}getCachedKeyHandlers=fe(e=>[...e,...this.keyHandlers].sort((t,n)=>t.order-n.order));getKeyHandlers(){const{keyHandlers:e}=this.props;return this.getCachedKeyHandlers(e)}getCachedMouseHandlers=fe(e=>[...e,...this.mouseHandlers].sort((t,n)=>t.order-n.order));getMouseHandlers(){const{mouseHandlers:e}=this.props;return this.getCachedMouseHandlers(e)}getModelColumn(e){const t=this.metrics?.modelColumns?.get(e);if(t===void 0)throw new Error(`Unable to get ModelIndex for column ${e}`);return t}getModelRow(e){const t=this.metrics?.modelRows?.get(e);if(t===void 0)throw new Error(`Unable to get ModelIndex for row ${e}`);return t}toggleRowExpanded(e,t=!1){const n=this.getModelRow(e),{model:s}=this.props;qe(s)&&s.isRowExpandable(n)&&s.setRowExpanded(n,!s.isRowExpanded(n),t),this.clearSelectedRanges(),this.commitSelection(),this.moveCursorToPosition(0,e),this.commitSelection(),this.setState({isStuckToBottom:!1})}scrollToBottom(){if(!this.metrics)return;const{bottomVisible:e,rowCount:t,top:n,lastTop:s}=this.metrics;(e<t-1&&e>0||n>s)&&this.setState({top:s})}scrollToRight(){if(!this.metrics)return;const{rightVisible:e,columnCount:t,left:n,lastLeft:s}=this.metrics;(e<t-1&&e>0||n>s)&&this.setState({left:s})}setSelectedRanges(e){const{model:t}=this.props,{columnCount:n,rowCount:s}=t,{cursorRow:i,cursorColumn:o,selectedRanges:a}=this.state;if(this.setState({selectedRanges:e,lastSelectedRanges:a}),e.length>0){const r=z.boundedRange(e[0],n,s);let c=i,h=o;r.containsCell(o,i)||({row:c,column:h}=r.startCell()),this.setState({selectionStartColumn:r.startColumn,selectionStartRow:r.startRow,selectionEndColumn:r.endColumn,selectionEndRow:r.endRow,cursorColumn:h,cursorRow:c})}}initContext(){const{canvas:e}=this,{canvasOptions:t}=this.props;if(!e)throw new Error("Canvas not set");this.canvasContext=e.getContext("2d",t)}requestUpdateCanvas(){this.animationFrame==null&&(this.animationFrame=requestAnimationFrame(()=>{this.animationFrame=null,this.updateCanvas()}))}updateCanvas(){this.updateCanvasScale(),this.updateMetrics(),this.updateRenderState();const{canvasContext:e,metrics:t,renderState:n}=this;M(e),M(t),M(n),this.renderer.configureContext(e,n);const{onViewChanged:s}=this.props;s(t),this.drawCanvas(t)}updateCanvasScale(){const{canvas:e,canvasContext:t}=this;if(!e)throw new Error("canvas not set");if(!t)throw new Error("canvasContext not set");if(!e.parentElement)throw new Error("Canvas has no parent element");const n=Es.getScale(t),s=e.parentElement.getBoundingClientRect(),i=Math.floor(s.width),o=Math.floor(s.height);e.style.width=`${i}px`,e.style.height=`${o}px`,e.width=i*n,e.height=o*n,t.scale(n,n)}updateScrollBounds(){if(!this.metrics)throw new Error("metrics not set");const{left:e,top:t}=this.state,{lastLeft:n,lastTop:s}=this.metrics;e>n&&this.setState({left:n,leftOffset:0}),t>s&&this.setState({top:s,topOffset:0})}checkStickyScroll(){if(this.metrics){if(this.prevMetrics){const{rowCount:e,columnCount:t,height:n,width:s}=this.metrics,{rowCount:i,columnCount:o,height:a,width:r}=this.prevMetrics;if(i!==e||n!==a){const{isStuckToBottom:c}=this.state;c&&this.scrollToBottom()}if(o!==t||s!==r){const{isStuckToRight:c}=this.state;c&&this.scrollToRight()}}this.prevMetrics=this.metrics}}updateMetrics(e=this.state){this.prevMetrics=this.metrics;const{metricCalculator:t}=this,n=this.getMetricState(e);return this.metrics=t.getMetrics(n),this.updateScrollBounds(),this.metrics}checkSelectionChange(e){const{selectedRanges:t}=e,{selectedRanges:n}=this.state;if(n!==t){const{onSelectionChanged:s}=this.props;s(n)}}validateSelection(){const{model:e}=this.props,{selectedRanges:t}=this.state,{columnCount:n,rowCount:s}=e;for(let i=0;i<t.length;i+=1){const o=t[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:e}=this.state;this.setState({selectedRanges:[],lastSelectedRanges:e})}trimSelectedRanges(){const{selectedRanges:e}=this.state;e.length>0&&this.setState({selectedRanges:e.slice(e.length-1)})}beginSelection(e,t){this.setState({selectionStartColumn:e,selectionStartRow:t,selectionEndColumn:e,selectionEndRow:t,cursorColumn:e,cursorRow:t})}moveSelection(e,t,n=!1,s=!1){this.setState(i=>{const{selectedRanges:o,selectionStartRow:a,selectionStartColumn:r}=i,{theme:c}=this.props,{autoSelectRow:h,autoSelectColumn:u}=c;if(n&&o.length>0){const C=o[o.length-1];let f=null,S=null,v=null,w=null;s?(f=h!==void 0&&h?null:Math.min(e??0,C.startColumn??0),S=u!==void 0&&u?null:Math.min(t??0,C.startRow??0),v=h!==void 0&&h?null:Math.max(e??0,C.endColumn??0),w=u!==void 0&&u?null:Math.max(t??0,C.endRow??0)):(f=C.startColumn,S=C.startRow,(r!=null||a!=null)&&((h===void 0||!h)&&(f=r),(u===void 0||!u)&&(S=a)),v=h!==void 0&&h?null:e,w=u!==void 0&&u?null:t);const T=z.makeNormalized(f,S,v,w);if(C.equals(T))return null;const y=[...o];return y[y.length-1]=T,{selectedRanges:y,selectionEndColumn:e,selectionEndRow:t}}const m=[...o],g=h!==void 0&&h?null:e,p=u!==void 0&&u?null:t;return m.push(z.makeNormalized(g,p,g,p)),{selectedRanges:m,selectionEndColumn:e,selectionEndRow:t}})}commitSelection(){this.setState(e=>{const{theme:t}=this.props,{autoSelectRow:n}=t,{selectedRanges:s,lastSelectedRanges:i,cursorRow:o,cursorColumn:a}=e;if(s.length===1&&(n!==void 0&&n?z.rowCount(s)===1:z.cellCount(s)===1)&&z.rangeArraysEqual(s,i))return{selectedRanges:[],lastSelectedRanges:[],cursorColumn:null,cursorRow:null};let r=s.slice();if(r.length>1){const u=r[r.length-1];for(let m=0;m<r.length-1;m+=1){const g=r[m];if(g.contains(u)){const p=g.subtract(u);r.pop(),r.splice(m,1),r=r.concat(p);break}}r=z.consolidate(r)}let c=a,h=o;if(!z.containsCell(r,a,o)){const{model:u}=this.props,{columnCount:m,rowCount:g}=u,p=z.nextCell(z.boundedRanges(s,m,g));p!=null?{column:c,row:h}=p:(c=null,h=null)}return r.length===0&&(c=null,h=null),{cursorRow:h,cursorColumn:c,selectedRanges:r,lastSelectedRanges:s}})}setFocusRow(e){if(!this.metrics||!this.prevMetrics)return;const{gridY:t,height:n,lastTop:s,userRowHeights:i,rowHeight:o}=this.metrics,a=n-t,r=Math.round(a/2)+(i.get(e)??o),c=this.getMetricState(),h=this.metricCalculator.getLastTop(c,e+1,r);this.setState({top:Math.min(s,h),selectedRanges:[new z(null,e,null,e)],isStuckToBottom:!1});const{cursorColumn:u}=this.state;this.moveCursorToPosition(u,e,!1,!1)}selectAll(){const{model:e,theme:t}=this.props,{autoSelectRow:n,autoSelectColumn:s}=t,i=s!==void 0&&s?null:0,o=s!==void 0&&s?null:e.rowCount-1,a=n!==void 0&&n?null:0,r=n!==void 0&&n?null:e.columnCount-1;this.setSelectedRanges([new z(a,i,r,o)])}moveCursor(e,t,n){const{cursorRow:s,cursorColumn:i,selectionEndColumn:o,selectionEndRow:a}=this.state,r=n?o:i,c=n?a:s;if(c===null||r===null){const{left:h,top:u}=this.state;this.moveCursorToPosition(h,u,n)}else{const{model:h}=this.props,{columnCount:u,rowCount:m}=h,g=He(r+e,0,u-1),p=He(c+t,0,m-1);this.moveCursorToPosition(g,p,n)}}moveCursorInDirection(e=z.SELECTION_DIRECTION.DOWN){const{model:t}=this.props,{columnCount:n,rowCount:s}=t,{cursorRow:i,cursorColumn:o,selectedRanges:a}=this.state,r=a.length>0?a:[z.makeCell(o,i)];let c=null;if(r.length===1&&z.cellCount(r)===1){const h=new z(0,0,n-1,s-1);c=h.nextCell(o,i,e)??h.startCell(e)}else c=z.nextCell(z.boundedRanges(r,n,s),o,i,e);if(c!=null){const{column:h,row:u}=c;this.setState({cursorColumn:h,cursorRow:u}),z.containsCell(a,h,u)||this.setState({selectedRanges:[z.makeCell(h,u)],selectionStartColumn:h,selectionStartRow:u,selectionEndColumn:h,selectionEndRow:u}),this.moveViewToCell(c.column,c.row)}}moveCursorToPosition(e,t,n=!1,s=!0,i=!1){n||this.beginSelection(e,t),this.moveSelection(e,t,n,i),s&&this.moveViewToCell(e,t)}moveViewToCell(e,t){if(!this.metrics)throw new Error("metrics not set");const{metricCalculator:n}=this,{bottomVisible:s,rightVisible:i,topVisible:o,leftVisible:a}=this.metrics,r=this.getMetricState(this.state);let{top:c,left:h,topOffset:u,leftOffset:m}=this.state;t!=null&&!V.isFloatingRow(t,this.metrics)&&(t<o?(c=n.getTopForTopVisible(r,t),u=0):t>s&&(c=n.getTopForBottomVisible(r,t),u=0)),e!=null&&!V.isFloatingColumn(e,this.metrics)&&(e<a?(h=n.getLeftForLeftVisible(r,e),m=0):e>i&&(h=n.getLeftForRightVisible(r,e),m=0)),this.setViewState({top:c,left:h,topOffset:u,leftOffset:m})}setViewState(e,t=!1){if(!this.metrics)throw new Error("metrics not set");const{isStickyBottom:n,isStickyRight:s}=this.props,{top:i,left:o}=e,{lastTop:a,lastLeft:r}=this.metrics;i!=null&&this.setState({isStuckToBottom:n&&i>=a}),o!=null&&this.setState({isStuckToRight:s&&o>=r}),this.setState(e),t&&this.forceUpdate()}startEditing(e,t,n=!1,s,i){const{model:o}=this.props;if(!Ze(o))throw new Error("model is not editable");const a=this.getModelColumn(e),r=this.getModelRow(t),c={column:e,row:t,selectionRange:s,value:i!==void 0?i:o.editValueForCell(a,r),isQuickEdit:n};this.setState({editingCell:c,cursorColumn:e,cursorRow:t}),this.moveViewToCell(e,t)}isValidForCell(e,t,n){const{model:s}=this.props,i=this.getModelColumn(e),o=this.getModelRow(t);return Ze(s)&&s.isValidForCell(i,o,n)}async pasteValue(e){const{model:t}=this.props,{movedColumns:n,movedRows:s,selectedRanges:i}=this.state;try{if(Md(t),!t.isEditable||!i.every(m=>t.isEditableRange(m)))throw new $r("Can't paste in to read-only area.");if(i.length<=0)throw new $r("Select an area to paste to.");if(typeof e=="string"){const m=[],g=V.getModelRanges(i,n,s);z.forEachCell(g,(p,C)=>{m.push({column:p,row:C,text:e})}),await t.setValues(m);return}const o=e.length,a=e[0].length,{columnCount:r,rowCount:c}=t;let h=i;if(h.every(m=>z.cellCount([m])===1&&(m.startColumn??0)+a<=r&&(m.startRow??0)+o<=c)&&(h=h.map(m=>new z(m.startColumn,m.startRow,(m.startColumn??0)+a-1,(m.startRow??0)+o-1)),this.setSelectedRanges(h)),!h.every(m=>z.rowCount([m])===o&&z.columnCount([m])===a))throw new $r("Copy and paste area are not same size.");const u=[];h.forEach(m=>{for(let g=0;g<a;g+=1)for(let p=0;p<o;p+=1)u.push({column:(m.startColumn??0)+g,row:(m.startRow??0)+p,text:e[p][g]})}),await t.setValues(u)}catch(o){const{onError:a}=this.props;a(o instanceof Error?o:new Error(`${o}`))}}setValueForCell(e,t,n){const{model:s}=this.props;Md(s);const i=this.getModelColumn(e),o=this.getModelRow(t);return s.isValidForCell(i,o,n)?(s.setValueForCell(i,o,n),!0):!1}setValueForRanges(e,t){const{model:n}=this.props,{movedColumns:s,movedRows:i}=this.state,o=V.getModelRanges(e,s,i);Ze(n)&&n.setValueForRanges(o,t)}isSelected(e,t){const{selectedRanges:n}=this.state;for(let s=0;s<n.length;s+=1){const i=n[s],o=i.startRow===null||i.startRow<=e&&e<=(i.endRow??0),a=i.startColumn===null||i.startColumn<=t&&t<=(i.endColumn??0);if(o&&a)return!0}return!1}addDocumentCursor(e=null){this.documentCursor!==Es.getCursorClassName(e)&&(this.documentCursor!=null&&document.documentElement.classList.remove(this.documentCursor),this.documentCursor=Es.getCursorClassName(e),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(e){this.stopDragTimer();const t=new MouseEvent("custom",e.nativeEvent);this.dragTimer=setTimeout(()=>{this.handleMouseDrag(t)},Es.dragTimeout)}stopDragTimer(){this.dragTimer&&(clearTimeout(this.dragTimer),this.dragTimer=null)}drawCanvas(e=this.updateMetrics()){if(!this.canvas)throw new Error("canvas is not set");if(!this.canvasContext)throw new Error("context not set");const{renderer:t,canvasContext:n,renderState:s}=this;n.save(),t.drawCanvas(s),n.restore()}focus(){this.canvas?.focus()}isFocused(){return document.activeElement===this.canvas}handleClick(e){const t=this.getGridPointFromEvent(e),n=this.getMouseHandlers();for(let s=0;s<n.length;s+=1)if(n[s].onClick(t,this,e)!==!1){e.stopPropagation(),e.preventDefault();break}this.canvas?.focus()}handleContextMenu(e){const t=this.getGridPointFromEvent(e),n=this.getMouseHandlers();for(let s=0;s<n.length;s+=1)if(n[s].onContextMenu(t,this,e)!==!1){e.stopPropagation(),e.preventDefault();break}}handleKeyDown(e){const t=this.getKeyHandlers();for(let n=0;n<t.length;n+=1){const i=t[n].onDown(e,this);if(i!==!1){const o=i;(o?.stopPropagation??!0)&&e.stopPropagation(),(o?.preventDefault??!0)&&e.preventDefault();break}}}notifyMouseHandlers(e,t,n=!0,s=!1){const i=this.getGridPointFromEvent(t),o=this.getMouseHandlers();let a=null;for(let r=0;r<o.length;r+=1){const c=o[r],h=c[e]!=null&&c[e](i,this,t);if(h!==!1){c.cursor!=null&&({cursor:a}=c,s&&this.addDocumentCursor(a));const u=h;(u?.stopPropagation??!0)&&t.stopPropagation(),(u?.preventDefault??!0)&&t.preventDefault();break}}if(this.setState({cursor:a}),n){const{x:r,y:c}=i;this.setState({mouseX:r,mouseY:c})}}handleMouseDown(e){window.addEventListener("mousemove",this.handleMouseDrag,!0),window.addEventListener("mouseup",this.handleMouseUp,!0),!(e.button!=null&&e.button!==0)&&(this.notifyMouseHandlers("onDown",e),this.startDragTimer(e))}handleDoubleClick(e){this.notifyMouseHandlers("onDoubleClick",e)}handleMouseMove(e){this.notifyMouseHandlers("onMove",e)}handleMouseLeave(e){this.notifyMouseHandlers("onLeave",e,!1),this.setState({mouseX:null,mouseY:null})}handleMouseDrag(e){this.setState({isDragging:!0}),this.notifyMouseHandlers("onDrag",e,!0,!0),this.stopDragTimer()}handleMouseUp(e){window.removeEventListener("mousemove",this.handleMouseDrag,!0),window.removeEventListener("mouseup",this.handleMouseUp,!0),!(e.button!=null&&e.button!==0)&&(this.notifyMouseHandlers("onUp",e,!1),this.stopDragTimer(),this.removeDocumentCursor())}handleResize(){if(this.updateCanvas(),!this.metrics)throw new Error("metrics not set");this.forceUpdate()}handleWheel(e){if(this.notifyMouseHandlers("onWheel",e),e.defaultPrevented)return;const{metricCalculator:t,metrics:n}=this,s=this.getMetricState();if(!n)throw new Error("metrics not set");const{lastTop:i,lastLeft:o,columnCount:a,rowCount:r,scrollableContentWidth:c,scrollableViewportWidth:h,scrollableContentHeight:u,scrollableViewportHeight:m,hasHorizontalBar:g,hasVerticalBar:p}=n;let{top:C,left:f,topOffset:S,leftOffset:v}=n;const w=this.getTheme();let{deltaX:T,deltaY:y}=V.getScrollDelta(e,n.barWidth,n.barHeight,n.rowHeight,n.rowHeight);for(;g&&T!==0;){if(v+=T,T=0,a>1){if(v>0&&f>=o||v<0&&f<=0){v=0;break}}else{if(v<=0){v=0;break}const E=c-h;if(v>=E){v=E;break}}if(v>0){const E=n.allColumnWidths.get(f)??t.getVisibleColumnWidth(f,s);v>=E?(T=v-E,v=0,f+=1):w.scrollSnapToColumn&&a>1&&(v=0,f+=1)}else if(v<0){const E=n.allColumnWidths.get(f-1)??t.getVisibleColumnWidth(f-1,s);Math.abs(v)<=E&&w.scrollSnapToColumn&&a>1?(v=0,f-=1):(T=v+E,v=0,f-=1)}}for(;p&&y!==0;){if(S+=y,y=0,r>1){if(S>0&&C>=i||S<0&&C<=0){S=0;break}}else{if(S<=0){S=0;break}const E=u-m;if(S>=E){S=E;break}}if(S>0){const E=n.allRowHeights.get(C)??t.getVisibleRowHeight(C,s);S>=E?(y=S-E,S=0,C+=1):w.scrollSnapToRow&&r>1&&(S=0,C+=1)}else if(S<0){const E=n.allRowHeights.get(C-1)??t.getVisibleRowHeight(C-1,s);Math.abs(S)<=E&&w.scrollSnapToRow&&r>1?(S=0,C-=1):(y=S+E,S=0,C-=1)}}this.setViewState({top:C,left:f,leftOffset:v,topOffset:S}),e.stopPropagation(),e.preventDefault()}handleEditCellCancel(){this.setState({editingCell:null}),this.focus()}handleEditCellChange(e){this.setState(({editingCell:t})=>{try{return Nd(t),{editingCell:{...t,value:e}}}catch(n){const{onError:s}=this.props;return s(n instanceof Error?n:new Error(`${n}`)),null}})}handleEditCellCommit(e,{direction:t=En.DOWN,fillRange:n=!1}={}){const{editingCell:s,selectedRanges:i}=this.state;if(!s)throw new Error("editingCell not set");const{column:o,row:a}=s;if(!this.isValidForCell(o,a,e)){t===null&&this.setState({editingCell:null});return}n?this.setValueForRanges(i,e):this.setValueForCell(o,a,e),t!==null&&this.moveCursorInDirection(t),this.setState({editingCell:null}),this.focus()}renderInputField(){const{model:e}=this.props,{editingCell:t}=this.state,{metrics:n}=this;if(t==null||n==null||!Ze(e))return null;const{selectionRange:s,value:i,isQuickEdit:o}=t,{column:a,row:r}=t,{gridX:c,gridY:h,allColumnXs:u,allRowYs:m,allColumnWidths:g,allRowHeights:p}=n,C=u.get(a),f=m.get(r),S=g.get(a),v=p.get(r),w=C!=null&&f!=null&&S!=null&&v!=null?{position:"absolute",left:c+C,top:h+f,width:S,height:v}:{opacity:0},T=this.getModelColumn(a),y=this.getModelRow(r),E=T!=null&&y!=null?{textAlign:e.textAlignForCell(T,y)}:void 0,D=e.isValidForCell(T,y,i);return l.jsx("div",{style:w,children:l.jsx(dc,{selectionRange:s,className:$({error:!D}),onCancel:this.handleEditCellCancel,onChange:this.handleEditCellChange,onDone:this.handleEditCellCommit,isQuickEdit:o,style:E,value:i},`${a},${r}`)})}updateRenderState(){if(!this.canvas)throw new Error("canvas is not set");if(!this.canvasContext)throw new Error("context not set");const{cursorColumn:e,cursorRow:t,draggingColumn:n,draggingColumnSeparator:s,draggingRow:i,draggingRowOffset:o,draggingRowSeparator:a,editingCell:r,isDraggingHorizontalScrollBar:c,isDraggingVerticalScrollBar:h,isDragging:u,mouseX:m,mouseY:g,selectedRanges:p}=this.state,{model:C,stateOverride:f}=this.props,{metrics:S}=this,v=this.canvasContext,w=this.getTheme(),T=this.canvas.clientWidth,y=this.canvas.clientHeight;return M(S),this.renderState={width:T,height:y,context:v,theme:w,model:C,metrics:S,mouseX:m,mouseY:g,selectedRanges:p,draggingColumn:n,draggingColumnSeparator:s,draggingRow:i,draggingRowOffset:o,draggingRowSeparator:a,editingCell:r,isDraggingHorizontalScrollBar:c,isDraggingVerticalScrollBar:h,isDragging:u,cursorColumn:e,cursorRow:t,...f},this.renderState}render(){const{cursor:e}=this.state;return l.jsxs(l.Fragment,{children:[l.jsx("canvas",{className:$("grid-canvas",Es.getCursorClassName(e)),ref:t=>{this.canvas=t},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()]})}}const Wr=5e3;class hv extends xl{get floatingTopRowCount(){return 0}get floatingBottomRowCount(){return 0}get floatingLeftColumnCount(){return 0}get floatingRightColumnCount(){return 0}get columnHeaderMaxDepth(){return 1}truncationCharForCell(e,t){}textAlignForCell(e,t){return"left"}colorForCell(e,t,n){return n.textColor}backgroundColorForCell(e,t,n){return null}colorForColumnHeader(e,t=0){return null}textForRowHeader(e){return""}textForRowFooter(e){return""}isColumnMovable(e,t=0){return!0}isRowMovable(e){return!0}getColumnHeaderGroup(e,t){}getColumnHeaderParentGroup(e,t){}tokensForCell(e,t,n=Wr){const s=this.textForCell(e,t);return this.getCachedTokensInText(s,n)}getCachedTokensInText=Zn((e,t)=>{if(t>=e.length)return il(e);const n=e.slice(t-1,Wr).search(/\s/);let s=t+n;n===-1&&(s=Math.min(Wr,e.length));const i=e.substring(0,s);return il(i)})}function uv(d,e){const t=pv(d);return t===void 0?void 0:`${vv(d)} ? ${t} : ${e}`}function mv(d){return dh.Column.formatRowColor(d)}function gv(d,e){return d.formatColor(e)}const To=Z.module("ConditionalFormattingUtils");var jn=(d=>(d.CONDITIONAL="conditional",d.ROWS="rows",d))(jn||{}),Ke=(d=>(d.IS_EQUAL="is-equal",d.IS_NOT_EQUAL="is-not-equal",d.IS_BETWEEN="is-between",d.GREATER_THAN="greater-than",d.GREATER_THAN_OR_EQUAL="greater-than-or-equal",d.LESS_THAN="less-than",d.LESS_THAN_OR_EQUAL="less-than-or-equal",d.IS_NULL="is-null",d.IS_NOT_NULL="is-not-null",d))(Ke||{}),Kt=(d=>(d.IS_EXACTLY="is-exactly",d.IS_NOT_EXACTLY="is-not-exactly",d.CONTAINS="contains",d.DOES_NOT_CONTAIN="does-not-contain",d.STARTS_WITH="starts-with",d.ENDS_WITH="ends-with",d.IS_NULL="is-null",d.IS_NOT_NULL="is-not-null",d))(Kt||{}),Nt=(d=>(d.IS_EXACTLY="is-exactly",d.IS_NOT_EXACTLY="is-not-exactly",d.IS_BEFORE="is-before",d.IS_BEFORE_OR_EQUAL="is-before-or-equal",d.IS_AFTER="is-after",d.IS_AFTER_OR_EQUAL="is-after-or-equal",d.IS_NULL="is-null",d.IS_NOT_NULL="is-not-null",d))(Nt||{}),wo=(d=>(d.IS_TRUE="is-true",d.IS_FALSE="is-false",d.IS_NULL="is-null",d.IS_NOT_NULL="is-not-null",d))(wo||{}),oi=(d=>(d.IS_EQUAL="is-equal",d.IS_NOT_EQUAL="is-not-equal",d.IS_NULL="is-null",d.IS_NOT_NULL="is-not-null",d))(oi||{}),gn=(d=>(d.NO_FORMATTING="no-formatting",d.POSITIVE="positive",d.NEGATIVE="negative",d.WARN="warn",d.NEUTRAL="neutral",d.ACCENT_1="accent-1",d.ACCENT_2="accent-2",d.CUSTOM="custom",d))(gn||{});function Pd(d){switch(d){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 Ua(d){const{type:e,customConfig:t}=d;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 t?.background;default:return}}function $a(d){const{type:e,customConfig:t}=d;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 t?.color;default:return}}function pv(d){const e=$a(d.style),t=Ua(d.style);if(!(e===void 0||t===void 0))return`bgfg(\`${t}\`, \`${e}\`)`}function fv(d){const{column:e,value:t,start:n,end:s}=d;return kv(e.name,d.condition,t,n,s)}function Cv(d){const{column:e,value:t}=d;return Ov(e.name,d.condition,t)}function Sv(d){const{column:e,value:t}=d;return Av(e.name,d.condition,t)}function bv(d){const{column:e}=d;return Lv(e.name,d.condition)}function wv(d){const{column:e,value:t}=d;return Pv(e.name,d.condition,t)}function vv(d){const{column:e}=d;if(x.isNumberType(e.type))return fv(d);if(x.isCharType(e.type))return wv(d);if(x.isStringType(e.type))return Cv(d);if(x.isDateType(e.type))return Sv(d);if(x.isBooleanType(e.type))return bv(d);throw new Error("Invalid column type")}function Tv(d){switch(d){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 Ev(d){switch(d){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 yv(d){switch(d){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 Rv(d){switch(d){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 xv(d){switch(d){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 Ju(d){if(x.isNumberType(d)||x.isCharType(d))return"is-equal";if(x.isStringType(d)||x.isDateType(d))return"is-exactly";if(x.isBooleanType(d))return"is-true";throw new Error("Invalid column type")}function em(d){if(x.isCharType(d)||x.isStringType(d))return""}function tm(d){const{condition:e,value:t,start:n,end:s}=d;return{condition:e,value:t,start:n,end:s}}function Tr(d){return{condition:Ju(d),value:em(d),start:void 0,end:void 0}}function nm(){return{type:"no-formatting"}}function Iv(d){switch(d){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 Dv(d){switch(d){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 Fv(d){switch(d){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 Nv(d){switch(d){case"is-equal":return"==";case"is-not-equal":return"!=";case"is-null":return"is null";case"is-not-null":return"is not null"}}function Mv(d){switch(d){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 kv(d,e,t,n,s){switch(e){case"is-equal":return`${d} == ${t}`;case"is-not-equal":return`${d} != ${t}`;case"is-between":return`${d} > ${n} && ${d} < ${s}`;case"greater-than":return`${d} > ${t}`;case"greater-than-or-equal":return`${d} >= ${t}`;case"less-than":return`${d} < ${t}`;case"less-than-or-equal":return`${d} <= ${t}`;case"is-null":return`${d} == null`;case"is-not-null":return`${d} != null`}}function Ov(d,e,t){switch(e){case"is-exactly":return`${d} == "${t}"`;case"is-not-exactly":return`${d} != "${t}"`;case"contains":return`${d} != null && ${d}.contains("${t}")`;case"does-not-contain":return`${d} != null && !${d}.contains("${t}")`;case"starts-with":return`${d} != null && ${d}.startsWith("${t}")`;case"ends-with":return`${d} != null && ${d}.endsWith("${t}")`;case"is-null":return`${d} == null`;case"is-not-null":return`${d} != null`}}function Av(d,e,t){switch(e){case"is-exactly":return`${d} == convertDateTime("${t}")`;case"is-not-exactly":return`${d} != convertDateTime(\`${t}\`)`;case"is-before":return`${d} < convertDateTime(\`${t}\`)`;case"is-before-or-equal":return`${d} <= convertDateTime("${t}")`;case"is-after":return`${d} > convertDateTime(\`${t}\`)`;case"is-after-or-equal":return`${d} >= convertDateTime(\`${t}\`)`;case"is-null":return`${d} == null`;case"is-not-null":return`${d} != null`}}function Lv(d,e){switch(e){case"is-true":return`${d} == true`;case"is-false":return`${d} == false`;case"is-null":return`${d} == null`;case"is-not-null":return`${d} != null`}}function Pv(d,e,t){switch(e){case"is-equal":return`${d} == '${t}'`;case"is-not-equal":return`${d} != '${t}'`;case"is-null":return`isNull(${d})`;case"is-not-null":return`!isNull(${d})`}}function _v(d,e){if(x.isNumberType(d))return Mv(e);if(x.isCharType(d))return Nv(e);if(x.isStringType(d))return Iv(e);if(x.isDateType(d))return Dv(e);if(x.isBooleanType(d))return Fv(e);throw new Error("Invalid column type")}function jv(d,e){if(e===void 0)return To.debug("no rules passed."),[];const t=[];let n;const s=new Map;return e.forEach(({config:i,type:o})=>{const{column:a}=i,r=d.find(({name:p,type:C})=>p===a.name&&C===a.type);if(r===void 0){To.debug(`Column ${a.name}:${a.type} not found. Ignoring format rule.`,i);return}const[c,h]=(o==="conditional"?s.get(r.name):n)??["null",void 0],u=uv(i,c);if(u===void 0){To.debug("Ignoring format rule.",i);return}const m=h===void 0?-1:t.indexOf(h);m>-1&&t.splice(m,1);const g=o==="conditional"?gv(r,u):mv(u);t.push(g),o==="conditional"?s.set(r.name,[u,g]):n=[u,g]}),t}function Hv(d,e){switch(d){case"is-null":case"is-not-null":return!0;default:{const[t,...n]=(e??"").split(" "),s=n.join(" ");try{et.parseDateTimeString(t)}catch{return To.debug("Invalid datetime string",t),!1}try{dh.i18n.TimeZone.getTimeZone(s)}catch{return To.debug("Invalid timezone string",s),!1}return!0}}}function Vv({type:d}){return x.isNumberType(d)||x.isCharType(d)||x.isStringType(d)||x.isDateType(d)||x.isBooleanType(d)}function Er({animation:d="iris-grid-bottom-bar-slide-up",children:e,className:t,isShown:n,onClick:s,onEntering:i,onEntered:o,onExiting:a,onExited:r}){return l.jsx(ft,{in:n,timeout:ze.transitionMs,classNames:d,onEntering:i,onEntered:o,onExiting:a,onExited:r,mountOnEnter:!0,unmountOnExit:!0,children:l.jsx("div",{className:$("iris-grid-bottom-bar",t),role:"presentation",onClick:s,onKeyPress:s,children:e})})}const Bv=3e3,Uv=5;function $v({isSaving:d=!1,onSave:e,onDiscard:t,discardTooltip:n,saveTooltip:s,error:i,pendingDataErrors:o,pendingDataMap:a,onEntering:r,onEntered:c,onExiting:h,onExited:u}){const[m,g]=b.useState(!1),[p,C]=b.useState(!1),f=b.useRef(),S=lr(d),v=b.useMemo(()=>o.size===0?i:o.size<=Uv?`Key can't be empty (on pending row${o.size>1?"s":""} ${Array.from(o.keys()).join(", ").trim()})`:`Key can't be empty (on ${o.size} rows)`,[i,o]);b.useEffect(function(){S!=null&&S&&!d&&v==null&&(g(!0),C(!0),f.current=setTimeout(()=>{g(!1)},Bv))},[v,d,S]),b.useEffect(function(){f.current&&a.size>0&&(clearTimeout(f.current),g(!1),C(!1))},[a]),b.useEffect(function(){return()=>f.current?clearTimeout(f.current):void 0},[]);const w=a.size;let T;return d?T=l.jsx(yn,{}):p&&(T=Ml),l.jsxs(Er,{className:"pending-data-bottom-bar",isShown:w>0||m||v!=null,onEntering:r,onEntered:c,onExiting:h,onExited:()=>{C(!1),u&&u()},children:[v!=null&&v!==""&&l.jsxs("div",{className:"error-message",children:[l.jsx(Q,{icon:As}),l.jsx("span",{children:`${v}`})]}),(v==null||v==="")&&l.jsx("div",{className:"status-message",children:w>0&&l.jsx("span",{children:`${w} row${w>1?"s":""} pending`})}),l.jsxs("div",{className:"buttons-container",children:[!d&&!p&&l.jsx(B,{kind:"secondary",onClick:t,tooltip:n,children:"Discard"}),l.jsxs(B,{kind:p?"success":"primary",onClick:e,icon:T,disabled:d||p||v!=null,tooltip:s,children:[d&&"Committing...",!d&&p&&"Success",!d&&!p&&"Commit"]})]})]})}var sm=(d=>(d.COUNT="Count",d.MIN="Min",d.MAX="Max",d.SUM="Sum",d.ABS_SUM="AbsSum",d.VAR="Var",d.AVG="Avg",d.STD="Std",d.FIRST="First",d.LAST="Last",d.SKIP="Skip",d.COUNT_DISTINCT="CountDistinct",d.DISTINCT="Distinct",d.UNIQUE="Unique",d))(sm||{});const ke=sm,Wv=[ke.SUM,ke.ABS_SUM,ke.MIN,ke.MAX,ke.VAR,ke.AVG,ke.STD,ke.FIRST,ke.LAST,ke.COUNT_DISTINCT,ke.DISTINCT,ke.COUNT,ke.UNIQUE],Gv=d=>{switch(d){default:return!1}},zv=(d,e)=>{switch(d){case ke.COUNT:case ke.FIRST:case ke.LAST:case ke.COUNT_DISTINCT:case ke.DISTINCT:case ke.UNIQUE:return!0;case ke.MIN:case ke.MAX:return x.isNumberType(e)||x.isDateType(e)||x.isTextType(e);case ke.SUM:case ke.ABS_SUM:case ke.VAR:case ke.AVG:case ke.STD:return x.isNumberType(e);case ke.SKIP:return!1}},hc=(d,e)=>d.filter(t=>zv(e,t.type)),Kv=(d,e,t,n)=>hc(d,e).map(({name:s})=>s).filter(s=>t.includes(s)?!n:n),Fs={isRollupOperation:Gv,filterValidColumns:hc,getOperationColumnNames:Kv};var im=(d=>(d.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS="filter-control-change-clears-all-filters",d.LINK_CHANGE_CLEARS_ALL_FILTERS="link-change-clears-all-filters",d))(im||{});const Gi=im,qv=Object.freeze([[Gi.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS,!1],[Gi.LINK_CHANGE_CLEARS_ALL_FILTERS,!1]]),om={DEFAULTS:qv},Yv=Z.module("ColumnHeaderGroup");function Gr(d){return d instanceof Sn}class Sn{static NEW_GROUP_PREFIX=":newGroup";name;children;depth;parent;color;childIndexes;constructor({name:e,children:t,color:n,depth:s,childIndexes:i,parent:o}){this.name=e,this.children=t,this.color=n,this.depth=s,this.childIndexes=i,this.parent=o}getVisibleRange=fe(e=>{const t=this.childIndexes.flat(),n=V.getVisibleIndexes(t,e),s=Math.min(...n),i=Math.max(...n);return i-s!==t.length-1&&Yv.warn(`Column header group ${this.name} is not contiguous`),[s,i]});setParent(e){this.parent=e}addChildren(e){const t=new Set(this.children.concat(e));this.children=[...t]}removeChildren(e){const t=new Set(this.children);e.forEach(n=>t.delete(n)),this.children=[...t]}get isNew(){return this.name.startsWith(Sn.NEW_GROUP_PREFIX)}}const lo=Z.module("IrisGridUtils");function ps(d,e){return d>=0&&d<e.length}function Xv(d){return d.asDate!=null}class Te{static dehydrateGridState(e,t){const{isStuckToBottom:n,isStuckToRight:s,movedColumns:i,movedRows:o}=t,{columns:a}=e;return{isStuckToBottom:n,isStuckToRight:s,movedColumns:[...i].filter(({to:r,from:c})=>ps(r,a)&&(typeof c=="number"&&ps(c,a)||Array.isArray(c)&&ps(c[0],a)&&ps(c[1],a))).map(({to:r,from:c})=>({to:a[r].name,from:Array.isArray(c)?[a[c[0]].name,a[c[1]].name]:a[c].name})),movedRows:[...o]}}static hydrateGridState(e,t,n=[]){const{isStuckToBottom:s,isStuckToRight:i,movedColumns:o,movedRows:a}=t,{columns:r}=e,c=Te.parseCustomColumnNames(n),h=r.map(({name:u})=>u).concat(c);return{isStuckToBottom:s,isStuckToRight:i,movedColumns:[...o].map(({to:u,from:m})=>{const g=p=>typeof p=="string"?h.findIndex(C=>C===p):p;return{to:g(u),from:Array.isArray(m)?[g(m[0]),g(m[1])]:g(m)}}).filter(({to:u,from:m})=>ps(u,h)&&(typeof m=="number"&&ps(m,h)||Array.isArray(m)&&ps(m[0],h)&&ps(m[1],h))),movedRows:[...a]}}static dehydrateIrisGridState(e,t){const{aggregationSettings:n={aggregations:Fe,showOnTop:!1},advancedFilters:s,customColumnFormatMap:i,isFilterBarShown:o,metrics:a,quickFilters:r,customColumns:c,conditionalFormats:h=Fe,reverseType:u,rollupConfig:m=void 0,showSearchBar:g,searchValue:p,selectDistinctColumns:C=Fe,selectedSearchColumns:f,sorts:S,invertSearchColumns:v,pendingDataMap:w=qn,frozenColumns:T,columnHeaderGroups:y}=t;M(a);const{userColumnWidths:E,userRowHeights:D}=a,{columns:F}=e;return{advancedFilters:Te.dehydrateAdvancedFilters(F,s),aggregationSettings:n,customColumnFormatMap:[...i],isFilterBarShown:o,quickFilters:Te.dehydrateQuickFilters(r),sorts:Te.dehydrateSort(S),userColumnWidths:[...E].filter(([N])=>N!=null&&N>=0&&N<F.length).map(([N,_])=>[F[N].name,_]),userRowHeights:[...D],customColumns:[...c],conditionalFormats:[...h],reverseType:u,rollupConfig:m,showSearchBar:g,searchValue:p,selectDistinctColumns:[...C],selectedSearchColumns:f,invertSearchColumns:v,pendingDataMap:Te.dehydratePendingDataMap(F,w),frozenColumns:T,columnHeaderGroups:y?.map(N=>({name:N.name,children:N.children,color:N.color}))}}static hydrateIrisGridState(e,t){const{advancedFilters:n,aggregationSettings:s={aggregations:[],showOnTop:!1},customColumnFormatMap:i,isFilterBarShown:o,quickFilters:a,sorts:r,customColumns:c,conditionalFormats:h,userColumnWidths:u,userRowHeights:m,reverseType:g,rollupConfig:p=void 0,showSearchBar:C,searchValue:f,selectDistinctColumns:S,selectedSearchColumns:v,invertSearchColumns:w=!0,pendingDataMap:T=[],frozenColumns:y,columnHeaderGroups:E}=t,{columns:D,formatter:F}=e;return{advancedFilters:Te.hydrateAdvancedFilters(D,n,F.timeZone),aggregationSettings:s,customColumnFormatMap:new Map(i),isFilterBarShown:o,quickFilters:Te.hydrateQuickFilters(D,a,F.timeZone),sorts:Te.hydrateSort(D,r),userColumnWidths:new Map(u.map(([N,_])=>typeof N=="string"||N instanceof String?[D.findIndex(({name:P})=>P===N),_]:[N,_]).filter(([N])=>N!=null&&N>=0&&N<D.length)),customColumns:c,conditionalFormats:h,userRowHeights:new Map(m),reverseType:g,rollupConfig:p,showSearchBar:C,searchValue:f,selectDistinctColumns:S,selectedSearchColumns:v,invertSearchColumns:w,pendingDataMap:Te.hydratePendingDataMap(D,T),frozenColumns:y,columnHeaderGroups:Te.parseColumnHeaderGroups(e,E??e.layoutHints?.columnGroups??[]).groups}}static dehydrateIrisGridPanelState(e,t){const{isSelectingPartition:n,partition:s,partitionColumn:i,advancedSettings:o}=t;return{isSelectingPartition:n,partition:s,partitionColumn:i?.name,advancedSettings:[...o]}}static hydrateIrisGridPanelState(e,t){const{isSelectingPartition:n,partition:s,partitionColumn:i,advancedSettings:o}=t,{columns:a}=e;return{isSelectingPartition:n,partition:s,partitionColumn:i!=null?Te.getColumnByName(a,i):void 0,advancedSettings:new Map([...om.DEFAULTS,...o])}}static dehydrateQuickFilters(e){return[...e].map(([t,n])=>{const{text:s}=n;return[t,{text:s}]})}static hydrateQuickFilters(e,t,n){const s=t.map(([i,o])=>{const{text:a}=o;let r=null;try{const c=Te.getColumn(e,i);c!=null&&(r=x.makeQuickFilter(c,a,n))}catch(c){lo.error("hydrateQuickFilters error with",a,c)}return[i,{text:a,filter:r}]});return new Map(s)}static dehydrateAdvancedFilters(e,t){return[...t].map(([n,s])=>{const i=Te.getColumn(e,n);M(i);const o=Te.dehydrateAdvancedFilterOptions(i,s.options);return[n,{options:o}]})}static hydrateAdvancedFilters(e,t,n){const s=t.map(([i,o])=>{const a=Te.getColumn(e,i);M(a);const r=Te.hydrateAdvancedFilterOptions(a,o.options);let c=null;try{Te.getColumn(e,i)!=null&&(c=x.makeAdvancedFilter(a,r,n))}catch(h){lo.error("hydrateAdvancedFilters error with",r,h)}return[i,{options:r,filter:c}]});return new Map(s)}static dehydrateAdvancedFilterOptions(e,t){const{selectedValues:n,...s}=t;return{selectedValues:n?.map(i=>Te.dehydrateValue(i,e?.type)),...s}}static hydrateAdvancedFilterOptions(e,t){const{selectedValues:n,...s}=t;return{selectedValues:n?.map(i=>Te.hydrateValue(i,e?.type)),...s}}static dehydratePendingDataMap(e,t){return[...t].map(([n,{data:s}])=>[n,{data:[...s].map(([i,o])=>[e[i].name,Te.dehydrateValue(o,e[i].type)])}])}static hydratePendingDataMap(e,t){const n=new Map,s=i=>(n.has(i)||n.set(i,e.findIndex(({name:o})=>o===i)),n.get(i));return new Map(t.map(([i,{data:o}])=>[i,{data:new Map(o.map(([a,r])=>{const c=s(a);return M(c),[s(a)??null,Te.hydrateValue(r,e[c].type)]}))}]))}static dehydrateValue(e,t){return x.isDateType(t)?Te.dehydrateDateTime(e):x.isLongType(t)?Te.dehydrateLong(e):e}static hydrateValue(e,t){return x.isDateType(t)?Te.hydrateDateTime(e):x.isLongType(t)?Te.hydrateLong(e):e}static dehydrateDateTime(e){return e!=null?R.i18n.DateTimeFormat.format(et.FULL_DATE_FORMAT,e):null}static hydrateDateTime(e){return e!=null?R.i18n.DateTimeFormat.parse(et.FULL_DATE_FORMAT,e):null}static dehydrateLong(e){return e!=null?`${e}`:null}static hydrateLong(e){return e!=null?R.LongWrapper.ofString(e):null}static dehydrateSort(e){return e.map(t=>{const{column:n,isAbs:s,direction:i}=t;return{column:n.name,isAbs:s,direction:i}})}static hydrateSort(e,t){return t.map(n=>{const{column:s,isAbs:i,direction:o}=n;if(o===x.sortDirection.reverse)return R.Table.reverse();const a=typeof s=="string"?Te.getColumnByName(e,s):Te.getColumn(e,s);if(a!=null){let r=a.sort();return i&&(r=r.abs()),o===x.sortDirection.descending?r=r.desc():r=r.asc(),r}return null}).filter(n=>n!=null&&n.direction!==x.sortDirection.reverse)}static extractTableSettings(e,t=[]){const{irisGridPanelState:n,irisGridState:s}=e,{partitionColumn:i,partition:o}=n,{advancedFilters:a,quickFilters:r,sorts:c}=s;return{advancedFilters:a,inputFilters:t,partition:o,partitionColumn:i,quickFilters:r,sorts:c}}static applyTableSettings(e,t,n){const{columns:s}=e;let i=[];t.quickFilters&&(i=Te.getFiltersFromFilterMap(Te.hydrateQuickFilters(s,t.quickFilters,n)));let o=[];t.advancedFilters&&(o=Te.getFiltersFromFilterMap(Te.hydrateAdvancedFilters(s,t.advancedFilters,n)));const a=Te.getFiltersFromInputFilters(s,t.inputFilters,n);let r=[];t.sorts&&(r=Te.hydrateSort(s,t.sorts));let c=[...i,...o];const{partition:h,partitionColumn:u}=t;if(h!=null&&u!=null){const m=Te.getColumnByName(s,u);m&&(c=[m.filter().eq(R.FilterValue.ofString(h)),...c])}c=[...a,...c],e.applyFilter(c),e.applySort(r)}static getInputFiltersForColumns(e,t=[]){return t.filter(({name:n,type:s})=>e.find(({name:i,type:o})=>i===n&&o===s))}static getFiltersFromInputFilters(e,t=[],n){return t.map(({name:s,type:i,value:o})=>{const a=e.find(({name:r,type:c})=>r===s&&c===i);if(a)try{return x.makeQuickFilter(a,o,n)}catch(r){lo.debug("Unable to create input filter",r)}return null}).filter(s=>s!=null)}static getFiltersFromFilterMap(e){const t=[],n=Array.from(e.keys());for(let s=0;s<n.length;s+=1){const i=n[s],o=e.get(i);o?.filter!=null&&t.push(o.filter)}return t}static getHiddenColumns(e){return[...e.entries()].filter(([,t])=>t===0).map(([t])=>t)}static parseCustomColumnNames(e){return e.map(t=>t.split("=")[0])}static getRemovedCustomColumnNames(e,t){const n=Te.parseCustomColumnNames(e),s=Te.parseCustomColumnNames(t);return n.filter(i=>!s.includes(i))}static removeSortsInColumns(e,t){return e.filter(n=>!t.includes(n.column.name))}static removeFiltersInColumns(e,t,n){const s=e.map(({name:o})=>o),i=new Map(t);return n.forEach(o=>i.delete(s.indexOf(o))),i}static removeColumnFromMovedColumns(e,t,n){const s=e.map(({name:o})=>o);let i=[...t];for(let o=0;o<n.length;o+=1){const a=n[o];let r=s.findIndex(h=>h===a);const c=[];for(let h=0;h<i.length;h+=1){const u=i[h],m={...u};let[g,p]=Array.isArray(u.from)?u.from:[u.from,u.from];r<=u.to&&(m.to-=1),r<g&&(g-=1),r<=p&&(p-=1),g<=p&&g!==m.to&&(g===p?c.push({...m,from:g}):c.push({...m,from:[g,p]})),r=V.applyItemMoves(r,r,[u])[0][0]}i=c,s.splice(s.findIndex(h=>h===a),1)}return i}static removeColumnsFromSelectDistinctColumns(e,t){return e.filter(n=>!t.includes(n))}static getVisibleColumnsInRange(e,t,n,s,i){const o=[];for(let a=t;a<=n;a+=1){const r=V.getModelIndex(a,s);r>=0&&r<e.length&&!i.includes(r)&&o.push(e[r])}return o}static getPrevVisibleColumns(e,t,n,s,i){const o=[];let a=t;for(;a>=0&&o.length<n;){const r=V.getModelIndex(a,s);r>=0&&r<e.length&&!i.includes(r)&&o.unshift(e[r]),a-=1}return o}static getNextVisibleColumns(e,t,n,s,i){const o=[];let a=t;for(;a<e.length&&o.length<n;){const r=V.getModelIndex(a,s);r>=0&&r<e.length&&!i.includes(r)&&o.push(e[r]),a+=1}return o}static getColumnsToFetch(e,t,n){const s=[...t];return n.forEach(i=>{const o=e.find(({name:a})=>a===i);o!=null&&!t.includes(o)&&s.push(o)}),s}static getModelViewportColumns(e,t,n,s,i=[],o=[],a=0){if(t==null||n==null)return null;const r=Te.getVisibleColumnsInRange(e,t,n,s,i),c=r.length*a,h=Te.getPrevVisibleColumns(e,t-1,c,s,i),u=Te.getNextVisibleColumns(e,n+1,c,s,i),m=[...h,...r,...u];return Te.getColumnsToFetch(e,m,o)}static rangeSetFromRanges(e){const t=e.slice().sort((n,s)=>(M(n.startRow),M(s.startRow),n.startRow-s.startRow)).map(n=>{const{startRow:s,endRow:i}=n;return M(s),M(i),R.RangeSet.ofRange(s,i)});return R.RangeSet.ofRanges(t)}static isValidSnapshotRanges(e){if(e==null||e.length===0)return!1;const t=new Map;for(let i=0;i<e.length;i+=1){const o=e[i],a=`${o.startRow}:${o.endRow}`,r=`${o.startColumn}:${o.endColumn}`;t.has(a)||t.set(a,[]),t.get(a).push(r)}const n=[...t.keys()],s=t.get(n[0]).sort().join(",");for(let i=1;i<n.length;i+=1)if(t.get(n[i]).sort().join(",")!==s)return!1;return!0}static isValidIndex(e){return!Number.isInteger(e)||typeof e!="number"?!1:e>=0}static columnsFromRanges(e,t){if(e==null||e.length===0)return[];if(e[0].startColumn===null&&e[0].endColumn===null)return[...t];const n=new Set;for(let s=0;s<e.length;s+=1){const i=e[s];M(i.startColumn),M(i.endColumn);for(let o=i.startColumn??0;o<=(i.endColumn??t.length-1);o+=1)n.add(o)}return[...n].map(s=>t[s])}static snapshotDataToMatrix(e){const{columns:t,rows:n}=e,s=[];for(let i=0;i<n.length;i+=1){const o=n[i],a=[];for(let r=0;r<t.length;r+=1){const c=t[r],h=o.get(c);a.push(h)}s.push(a)}return s}static getModelRollupConfig(e,t,n){if((t?.columns?.length??0)===0)return null;const{columns:s=[],showConstituents:i=!0,showNonAggregatedColumns:o=!0,includeDescriptions:a=!0}=t??{},{aggregations:r=[]}=n??{},c=r.map(({operation:u,selected:m,invert:g})=>Fs.isRollupOperation(u)?[]:Fs.getOperationColumnNames(e,u,m,g)),h={};for(let u=0;u<r.length;u+=1)h[r[u].operation]=c[u];if(o){const u=new Set(e.map(m=>m.name).filter(m=>!s.includes(m)));if(c.forEach(m=>{m.forEach(g=>u.delete(g))}),u.size>0){const m=h[ke.FIRST]??[];h[ke.FIRST]=[...m,...u]}}return{groupingColumns:s,includeConstituents:i,includeDescriptions:a,aggregations:h}}static getPendingErrors(e){e.forEach((t,n)=>{if(!Te.isValidIndex(n))throw new Error(`Invalid rowIndex ${n}`);const{data:s}=t;s.forEach((i,o)=>{if(!Te.isValidIndex(o))throw new Error(`Invalid columnIndex ${o}`)})})}static getColumn(e,t){return t<e.length?e[t]:(lo.error("Unable to retrieve column",t,">=",e.length),null)}static getColumnByName(e,t){const n=e.find(({name:s})=>s===t);return n==null&&lo.error("Unable to retrieve column by name",t,e.map(({name:s})=>s)),n}static changeFilterColumnNamesToIndexes(e,t){return t.map(({name:n,filter:s})=>{const i=e.findIndex(o=>o.name===n);return i<0?null:[i,s]}).filter(n=>n!=null)}static combineFiltersFromList(e,t){t.sort((s,i)=>s.operator==="eq"&&i.operator!=="eq"?1:s.operator!=="eq"&&i.operator==="eq"?-1:s.startColumnIndex-i.startColumnIndex);let n="";for(let s=0;s<t.length;s+=1){const{text:i,value:o,operator:a}=t[s];if(o!==void 0){let r="";a!==void 0&&(o==null&&a==="eq"?r="=":a!=="eq"&&(a==="startsWith"||a==="endsWith"?r="*":r=x.getFilterOperatorString(a)));let c=`${r}${i}`;a==="startsWith"&&(c=`${i}${r}`),e!=null&&o!==null&&x.isCharType(e)&&(c=`${r}${String.fromCharCode(parseInt(i,10))}`),s!==0&&(n+=a==="eq"?" || ":" && "),n+=c}}return n}static parseColumnHeaderGroups(e,t){let n=1;const s=new Map,i=new Map,o=t?.filter(({children:u})=>u.length>0);if(o.length===0)return{groups:[],maxDepth:n,parentMap:s,groupMap:i};const a=new Map(o.map(u=>[u.name,u])),r=new Set,c=u=>{const{name:m}=u;if(e.getColumnIndexByName(m)!=null)throw new Error(`Column header group has same name as column: ${m}`);const g=i.get(m);if(g)return g;const p=[];let C=1;u.children.forEach(S=>{if(r.has(S))throw new Error(`Column group child ${S} specified in multiple groups`);r.add(S);const v=a.get(S),w=e.getColumnIndexByName(S);if(v){const T=c(v);p.push(...T.childIndexes),C=Math.max(C,T.depth+1)}else if(w!=null)p.push(w),C=Math.max(C,1);else throw new Error(`Unknown child ${S} in group ${m}`)});const f=new Sn({...u,depth:C,childIndexes:p.flat()});return i.set(m,f),u.children.forEach(S=>s.set(S,f)),n=Math.max(n,f.depth+1),f},h=new Set;return o.forEach(u=>{const{name:m}=u;if(h.has(m))throw new Error(`Duplicate column group name: ${m}`);h.add(m),c(u)}),i.forEach(u=>{u.setParent(s.get(u.name)?.name)}),{groups:[...i.values()],maxDepth:n,groupMap:i,parentMap:s}}static convertValueToText(e,t){if(t!=null&&x.isCharType(t)&&e!=null&&typeof e=="number")return String.fromCharCode(e);if(x.isDateType(t)&&Xv(e)){const n=new Date(e.asDate()),s=n.getTimezoneOffset();return new Date(n.getTime()-s*60*1e3).toISOString().replace("T"," ").substring(0,23)}return e==null?"":`${e}`}}const be=Te;const Wt=Z.module("IrisGridCopyHandler");class Me extends b.Component{static NO_PROMPT_THRESHOLD=1e4;static HIDE_TIMEOUT=3e3;static COPY_STATES={IDLE:"IDLE",CONFIRMATION_REQUIRED:"CONFIRMATION_REQUIRED",FETCH_IN_PROGRESS:"FETCH_IN_PROGRESS",FETCH_ERROR:"FETCH_ERROR",CLICK_REQUIRED:"CLICK_REQUIRED",DONE:"DONE"};static BUTTON_STATES={COPY:"COPY",FETCH_IN_PROGRESS:"FETCH_IN_PROGRESS",CLICK_TO_COPY:"CLICK_TO_COPY",RETRY:"RETRY"};static defaultProps={copyOperation:null,onEntering:()=>{},onEntered:()=>{},onExiting:()=>{},onExited:()=>{}};static getStatusMessageText(e,t){switch(e){case Me.COPY_STATES.CONFIRMATION_REQUIRED:return`Are you sure you want to copy ${t.toLocaleString()} rows to your clipboard?`;case Me.COPY_STATES.CLICK_REQUIRED:return`Fetched ${t.toLocaleString()} rows!`;case Me.COPY_STATES.FETCH_ERROR:return"Unable to copy data.";case Me.COPY_STATES.FETCH_IN_PROGRESS:return`Fetching ${t.toLocaleString()} rows for clipboard...`;case Me.COPY_STATES.DONE:return"Copied to Clipboard!";default:return""}}static getCopyButtonText(e){switch(e){case Me.BUTTON_STATES.FETCH_IN_PROGRESS:return"Fetching";case Me.BUTTON_STATES.CLICK_TO_COPY:return"Click to Copy";case Me.BUTTON_STATES.RETRY:return"Retry";default:return"Copy"}}constructor(e){super(e),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:Me.COPY_STATES.IDLE,buttonState:Me.BUTTON_STATES.COPY,isShown:!1,rowCount:0}}componentDidMount(){const{copyOperation:e}=this.props;e!=null&&this.startCopy()}componentDidUpdate(e){const{copyOperation:t}=this.props;e.copyOperation!==t&&this.startCopy()}componentWillUnmount(){this.stopCopy()}textData;hideTimer;fetchPromise;startCopy(){Wt.debug2("startCopy"),this.stopCopy();const{copyOperation:e}=this.props;if(e==null){Wt.debug2("No copy operation set, cancelling out"),this.setState({isShown:!1});return}const{ranges:t,error:n}=e;if(n!=null){Wt.debug("Showing copy error",n),this.setState({isShown:!0,copyState:Me.COPY_STATES.DONE,error:n}),this.startHideTimer();return}const s=z.rowCount(t);this.setState({rowCount:s,isShown:!0,error:void 0}),s>Me.NO_PROMPT_THRESHOLD?this.setState({buttonState:Me.BUTTON_STATES.COPY,copyState:Me.COPY_STATES.CONFIRMATION_REQUIRED}):this.startFetch()}stopCopy(){this.textData=void 0,this.stopFetch(),this.stopHideTimer()}handleBackgroundClick(){Wt.debug2("handleBackgroundClick");const{copyState:e}=this.state;e===Me.COPY_STATES.DONE&&this.setState({isShown:!1})}handleCancelClick(){Wt.debug2("handleCancelClick"),this.stopFetch(),this.setState({isShown:!1})}handleCopyClick(){Wt.debug2("handleCopyClick"),this.textData!=null?this.copyText(this.textData):this.startFetch()}handleHideTimeout(){Wt.debug2("handleHideTimeout"),this.stopHideTimer(),this.setState({isShown:!1})}copyText(e){Wt.debug2("copyText",e),this.textData=e,Yi(e).then(()=>{this.setState({copyState:Me.COPY_STATES.DONE}),this.startHideTimer()},t=>{Wt.error("copyText error",t),this.setState({buttonState:Me.BUTTON_STATES.CLICK_TO_COPY,copyState:Me.COPY_STATES.CLICK_REQUIRED})})}startFetch(){this.stopFetch(),this.setState({buttonState:Me.BUTTON_STATES.FETCH_IN_PROGRESS,copyState:Me.COPY_STATES.FETCH_IN_PROGRESS});const{model:e,copyOperation:t}=this.props,{ranges:n,includeHeaders:s,userColumnWidths:i,movedColumns:o,formatValues:a}=t;Wt.debug("startFetch",n);const r=be.getHiddenColumns(i);let c=V.getModelRanges(n,o);if(r.length>0){const u=r.map(z.makeColumn);c=z.subtractRangesFromRanges(c,u)}const h=a!=null&&a?(u,m)=>e.displayString(u,m.type,m.name):u=>`${u}`;this.fetchPromise=ve.makeCancelable(e.textSnapshot(c,s,h)),this.fetchPromise.then(u=>{this.fetchPromise=void 0,this.copyText(u)}).catch(u=>{u instanceof $i?Wt.debug("User cancelled copy."):(Wt.error("Error fetching contents",u),this.fetchPromise=void 0,this.setState({buttonState:Me.BUTTON_STATES.RETRY,copyState:Me.COPY_STATES.FETCH_ERROR}))})}stopFetch(){this.fetchPromise&&(Wt.debug2("stopFetch"),this.fetchPromise.cancel(),this.fetchPromise=void 0)}startHideTimer(){this.stopHideTimer(),this.hideTimer=setTimeout(this.handleHideTimeout,Me.HIDE_TIMEOUT)}stopHideTimer(){this.hideTimer!=null&&(clearTimeout(this.hideTimer),this.hideTimer=void 0)}render(){const{onEntering:e,onEntered:t,onExiting:n,onExited:s}=this.props,{buttonState:i,copyState:o,isShown:a,rowCount:r,error:c}=this.state,h=o===Me.COPY_STATES.DONE?"fade":"copy-slide-up",u=Me.getCopyButtonText(i),m=c??Me.getStatusMessageText(o,r),g=o!==Me.COPY_STATES.DONE,p=i===Me.BUTTON_STATES.FETCH_IN_PROGRESS,C=o===Me.COPY_STATES.DONE;return l.jsxs(Er,{animation:h,isShown:a,className:$("iris-grid-copy-handler",{"copy-done":C}),onClick:this.handleBackgroundClick,onEntering:e,onEntered:t,onExiting:n,onExited:s,children:[l.jsx("div",{className:"status-message",children:l.jsx("span",{children:m})}),l.jsx(ft,{in:g,timeout:ze.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:l.jsxs("div",{className:"buttons-container",children:[l.jsx("button",{type:"button",className:"btn btn-outline-secondary btn-cancel",onClick:this.handleCancelClick,children:"Cancel"}),l.jsxs(B,{kind:p?"tertiary":"primary",className:$("btn-copy",{"btn-spinner":p}),onClick:this.handleCopyClick,disabled:p,children:[p&&l.jsx(yn,{}),u]})]})})]})}}const Zv=Me;class Qv extends b.PureComponent{static defaultProps={style:{},className:"",value:"",isAdvancedFilterSet:!1,onAdvancedFiltersTriggered:()=>{},onChange:()=>{},onDone:()=>{},onTab:()=>{},onContextMenu:()=>{},debounceMs:150};constructor(e){super(e);const{debounceMs:t}=e;this.debouncedSendUpdate=Ye(this.sendUpdate.bind(this),t),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:n}=e;this.initialValue=n,this.state={isChanged:!1,value:n}}componentDidMount(){this.inputField?.focus()}componentDidUpdate(e){const{debounceMs:t}=this.props;e.debounceMs!==t&&(this.debouncedSendUpdate.flush(),this.debouncedSendUpdate=Ye(this.sendUpdate.bind(this),t))}componentWillUnmount(){this.debouncedSendUpdate.cancel()}inputField;initialValue;debouncedSendUpdate;setValue(e){this.initialValue=e,this.setState({value:e})}focus(){this.inputField?.focus()}handleChange(e){const{value:t}=e.target;this.setState({value:t,isChanged:!0}),this.debouncedSendUpdate(t)}handleCancel(){this.debouncedSendUpdate.cancel();const{initialValue:e}=this,{isChanged:t}=this.state;t&&this.sendUpdate(e);const{onDone:n}=this.props;n()}handleCommit(e=!0,t=!0){this.debouncedSendUpdate.flush();const{onDone:n}=this.props;n(e,t)}handleFocus(){this.inputField?.select()}handleBlur(e){const{relatedTarget:t}=e;t!=null&&t.classList.contains("context-menu-container")?this.handleCommit(!1,!0):t!=null&&t.classList.contains("advanced-filter-button")?this.handleCommit(!1,!1):this.handleCommit(!0,!0)}handleTab(e=!1){this.debouncedSendUpdate.flush();const{onTab:t}=this.props;t(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:t}=this.props;t(e)}sendUpdate(e){const{onChange:t}=this.props;t(e)}render(){const{className:e,style:t,isAdvancedFilterSet:n,onAdvancedFiltersTriggered:s}=this.props,{value:i}=this.state;return l.jsxs("div",{style:t,className:"iris-grid-input-autosized-wrapper","data-value":i,children:[l.jsx("input",{ref:o=>{this.inputField=o},className:$("iris-grid-input-field",e),type:"text",value:i,onBlur:this.handleBlur,onFocus:this.handleFocus,onChange:this.handleChange,onKeyDown:this.handleKeyDown,onContextMenu:this.handleContextMenu,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false"}),l.jsx("div",{className:"advanced-filter-button-container",children:l.jsx(B,{kind:"ghost",className:$("btn-link-icon advanced-filter-button",{"filter-set":n}),onClick:s,onContextMenu:this.handleContextMenu,children:l.jsxs("div",{className:"fa-layers ",children:[l.jsx(Q,{icon:kl,className:"filter-solid"}),l.jsx(Q,{icon:Fa,className:"filter-light"})]})})})]})}}const Jv=Qv;class eT extends ui{irisGrid;constructor(e){super(),this.irisGrid=e}onDown(e){const{selectedRanges:t}=this.irisGrid.state;return e.key==="c"&&Ve.isModifierKeyDown(e)?(be.isValidSnapshotRanges(t)?this.irisGrid.copyRanges(t):this.irisGrid.copyRanges(t,!1,!1,"Invalid copy ranges"),!0):!1}}const tT=eT,nT={TOGGLE_QUICK_FILTER:Ne.createAndAdd({id:"TABLE.TOGGLE_QUICK_FILTER",name:"Toggle Quick Filter",shortcut:[de.CTRL,ue.F],macShortcut:[de.CMD,ue.F]}),CLEAR_ALL_FILTERS:Ne.createAndAdd({id:"TABLE.CLEAR_ALL_FILTERS",name:"Clear All Table Filters",shortcut:[de.CTRL,ue.E],macShortcut:[de.CMD,ue.E]}),CLEAR_FILTERS:Ne.createAndAdd({id:"TABLE.CLEAR_FILTERS",name:"Clear Active Table Filters",shortcut:[de.CTRL,de.SHIFT,ue.E],macShortcut:[de.CMD,de.SHIFT,ue.E]}),REVERSE:Ne.createAndAdd({id:"TABLE.REVERSE",name:"Reverse",shortcut:[de.CTRL,ue.I],macShortcut:[de.CMD,ue.I]}),TOGGLE_SEARCH:Ne.createAndAdd({id:"TABLE.TOGGLE_SEARCH",name:"Toggle Search",shortcut:[de.CTRL,de.SHIFT,ue.F],macShortcut:[de.CMD,de.SHIFT,ue.F]}),GOTO_ROW:Ne.createAndAdd({id:"TABLE.GOTO_ROW",name:"Go to Row",shortcut:[de.CTRL,ue.G],macShortcut:[de.CMD,ue.G]})},sT={COMMIT:Ne.createAndAdd({id:"INPUT_TABLE.COMMIT",name:"Commit",shortcut:[de.CTRL,ue.S],macShortcut:[de.CMD,ue.S]}),DISCARD:Ne.createAndAdd({id:"INPUT_TABLE.DISCARD",name:"Discard",shortcut:[de.CTRL,de.ALT,ue.S],macShortcut:[de.CMD,de.OPTION,ue.S]})},iT={TABLE:nT,INPUT_TABLE:sT},qt=iT;class oT extends ui{irisGrid;constructor(e){super(),this.irisGrid=e}onDown(e){if(qt.TABLE.REVERSE.matchesEvent(e)){if(!this.irisGrid.isReversible())return!1;const{reverseType:t}=this.irisGrid.state;return t===x.REVERSE_TYPE.NONE?this.irisGrid.reverse(x.REVERSE_TYPE.POST_SORT):this.irisGrid.reverse(x.REVERSE_TYPE.NONE),!0}return!1}}const aT=oT;class rT extends ui{irisGrid;constructor(e){super(),this.irisGrid=e}onDown(e){return qt.TABLE.CLEAR_FILTERS.matchesEvent(e)?(this.irisGrid.clearAllFilters(),!0):!1}}const lT=rT;class cT extends dt{irisGrid;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:t,column:n,row:s}){if(n==null||s==null)return null;const{renderer:i,grid:o,state:a,props:r}=this.irisGrid;if(!o)return null;const{metrics:c}=a,{model:h}=r,{canvasContext:u}=o,m=o.getTheme(),g={context:u,mouseX:e,mouseY:t,metrics:c,model:h,theme:m},{left:p,top:C,width:f,height:S}=i.getCellOverflowButtonPosition(g);return p==null||f==null||C==null||S==null?null:{left:p,top:C,width:f,height:S}}isHoveringOverflowButton(e){const{x:t,y:n}=e,{left:s,top:i,width:o,height:a}=this.getButtonPosition(e)??{};if(s==null||o==null||i==null||a==null)return!1;const{renderer:r,grid:c,state:h,props:u}=this.irisGrid;if(!c)return!1;const{metrics:m}=h,{model:g}=u,{canvasContext:p}=c,C=c.getTheme(),f={context:p,mouseX:t,mouseY:n,metrics:m,model:g,theme:C};return r.shouldRenderOverflowButton(f)&&t>=s&&t<=s+o&&n>=i&&n<=i+a}onMove(e){if(this.isHoveringOverflowButton(e)){const{overflowButtonTooltipProps:t}=this.irisGrid.state,n=this.getButtonPosition(e);it(t,n)||this.irisGrid.setState({overflowButtonTooltipProps:n})}else this.destroyColumnTooltip();return this.setCursor(e)}onWheel(e){return this.destroyColumnTooltip(),this.onMove(e)}onDown(e){this.destroyColumnTooltip();const{column:t,row:n}=e;return this.isHoveringOverflowButton(e)&&this.irisGrid.setState({showOverflowModal:!0,overflowText:this.irisGrid.getValueForCell(t,n)}),!1}onContextMenu(){return this.destroyColumnTooltip(),!1}onLeave(){return this.destroyColumnTooltip(),!1}}const dT=cT;class hT extends dt{constructor(e){super(),this.irisGrid=e,this.cursor=null}irisGrid;isActive(){const{isSelectingColumn:e}=this.irisGrid.props;return e}isValidColumn(e){if(e==null)return!1;const{columnSelectionValidator:t}=this.irisGrid.props;return t!=null?t(e):!0}updateColumnSelectionStatus(){const{columnSelectionValidator:e}=this.irisGrid.props;e?.(null)}getTableColumn(e){if(e==null)return null;const{model:t}=this.irisGrid.props,n=this.irisGrid.getModelColumn(e);return n==null?null:t.columns[n]}onMove(e){if(!this.isActive())return!1;const{columnAllowedCursor:t,columnNotAllowedCursor:n}=this.irisGrid.props,{column:s}=e,i=this.getTableColumn(s);return this.isValidColumn(i)?(this.cursor=t,this.irisGrid.setState({hoverSelectColumn:s})):(this.cursor=n,this.irisGrid.setState({hoverSelectColumn:null})),!0}onWheel(e){if(!this.isActive())return!1;const{columnAllowedCursor:t,columnNotAllowedCursor:n}=this.irisGrid.props,{column:s}=e,i=this.getTableColumn(s);return this.isValidColumn(i)?(this.cursor=t,this.irisGrid.setState({hoverSelectColumn:s})):(this.cursor=n,this.irisGrid.setState({hoverSelectColumn:null})),{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:t}=e,n=this.getTableColumn(t);return n!=null&&this.isValidColumn(n)&&this.irisGrid.selectColumn(n),!0}}const uT=hT;class mT extends dt{constructor(e){super(),this.irisGrid=e}irisGrid;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,t,n){const{relatedTarget:s}=n instanceof MouseEvent?n:n.nativeEvent,{tooltip:i}=this.irisGrid;if(!i)return!1;const o=i.popper.current;return o&&s instanceof Element&&o.element.contains(s)||this.hideColumnTooltip(),!1}onMove(e){const{column:t,row:n,columnHeaderDepth:s}=e,{shownColumnTooltip:i}=this.irisGrid.state;let o=null;return t!==null&&n===null&&s===0&&(o=t),o!==i&&this.irisGrid.setState({shownColumnTooltip:o}),!1}}const gT=mT;class uc extends b.Component{static defaultProps={formatString:"",forwardedProps:{menuItem:{},closeMenu(e){},iconElement:null},placeholder:"",title:"",onChange(e){}};constructor(e=uc.defaultProps){super(e),this.handleInputChange=this.handleInputChange.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.inputRef=J.createRef()}inputRef;handleInputChange(){const{onChange:e}=this.props;this.inputRef.current&&e(this.inputRef.current.value)}closeContextMenu(){const{forwardedProps:e}=this.props,{closeMenu:t}=e;t(!0)}revertToDefault(){const{onChange:e}=this.props;e(null)}returnFocusToContextMenu(){const e=rf.getClosestByClassName(this.inputRef.current,"context-menu-container");e instanceof HTMLElement&&e.focus()}handleKeyDown(e){switch(e.key){case"Enter":e.stopPropagation(),this.closeContextMenu();break;case"Escape":e.stopPropagation(),this.revertToDefault(),this.closeContextMenu();break;case"ArrowRight":case"ArrowLeft":e.stopPropagation();break;case"ArrowUp":case"ArrowDown":this.returnFocusToContextMenu();break;default:e.stopPropagation()}}render(){const{formatString:e,forwardedProps:t,placeholder:n,title:s}=this.props,{menuItem:{description:i},iconElement:o}=t;return l.jsxs("div",{className:"form-group flex-grow mb-0",children:[l.jsxs("div",{className:"custom-format-title",children:[l.jsx("span",{className:"icon",children:o}),l.jsxs("label",{className:"title mb-0",htmlFor:"custom-format-input",children:[s,i!=null&&l.jsx(tt,{children:i})]})]}),l.jsx("div",{className:"pl-2 pr-2 pb-2",children:l.jsx("input",{id:"custom-format-input",className:"form-control text-right mb-0",type:"text",defaultValue:e,ref:this.inputRef,placeholder:n,onKeyDown:this.handleKeyDown,onChange:this.handleInputChange,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:"false"})})]})}}const pT=uc;class fT{static isDefaultSelected(e){return!e||![ct.TYPE_CONTEXT_CUSTOM,ct.TYPE_CONTEXT_PRESET].includes(e.type)}static isCustomSelected(e){return e!=null&&e.type===ct.TYPE_CONTEXT_CUSTOM}static makeOption(e,t,n,s){return{title:e,description:e,group:n,format:t,isSelected:s}}static makeCustomFormatOption(e,t,n,s,i){return{title:e.label,description:e.label,format:e,group:t,isSelected:s,menuElement:l.jsx(pT,{formatString:e.formatString,title:e.label,placeholder:n,onChange:i})}}}const Yt=fT;class pn{static dateGroup=10;static timeGroup=20;static dateTimeGroup=30;static getOptions(e,t){const n=new Date,i=[{group:pn.dateGroup,formatString:"yyyy-MM-dd"},{group:pn.dateGroup,formatString:"MM-dd-yyyy"},{group:pn.timeGroup,formatString:"HH:mm:ss"},{group:pn.timeGroup,formatString:"HH:mm:ss.SSS"},{group:pn.timeGroup,formatString:"HH:mm:ss.SSSSSSSSS"},{group:pn.dateTimeGroup,formatString:"yyyy-MM-dd HH:mm:ss"},{group:pn.dateTimeGroup,formatString:"yyyy-MM-dd HH:mm:ss.SSS"},{group:pn.dateTimeGroup,formatString:"yyyy-MM-dd HH:mm:ss.SSSSSSSSS"}].map(a=>{const r=je.makeFormat("",a.formatString,je.TYPE_CONTEXT_PRESET),c=e.getFormattedString(n,x.dataType.DATETIME,"",r);return Yt.makeOption(c,r,a.group,je.isSameFormat(r,t))});return[Yt.makeOption("Default",null,pn.dateGroup,Yt.isDefaultSelected(t)),...i]}}const CT=pn;class fn{static defaultGroup=10;static presetGroup=20;static presetRoundGroup=30;static customGroup=40;static getOptions(e,t){const n=[{format:Re.FORMAT_PERCENT,group:fn.presetGroup},{format:Re.FORMAT_BASIS_POINTS,group:fn.presetGroup},{format:Re.FORMAT_MILLIONS,group:fn.presetGroup},{format:Re.FORMAT_SCIENTIFIC_NOTATION,group:fn.presetGroup},{format:Re.FORMAT_ROUND,group:fn.presetRoundGroup},{format:Re.FORMAT_ROUND_TWO_DECIMALS,group:fn.presetRoundGroup},{format:Re.FORMAT_ROUND_FOUR_DECIMALS,group:fn.presetRoundGroup}],s=Yt.makeOption("Default",null,fn.defaultGroup,Yt.isDefaultSelected(e)),i=n.map(c=>Yt.makeOption(c.format.label,c.format,c.group,Re.isSameFormat(c.format,e))),o=Yt.isCustomSelected(e),a=o?e:Re.makeCustomFormat(),r=Yt.makeCustomFormatOption(a,fn.customGroup,Re.DEFAULT_FORMAT_STRING,o,c=>{if(c!=null){const h=Re.makeCustomFormat(c);Re.isValid(h)&&t(h)}else t(null)});return[s,...i,r]}}const ST=fn;class Ni{static defaultGroup=10;static presetGroup=20;static customGroup=30;static getOptions(e,t){const n=[{format:Ge.FORMAT_MILLIONS,group:Ni.presetGroup},{format:Ge.FORMAT_SCIENTIFIC_NOTATION,group:Ni.presetGroup}],s=Yt.makeOption("Default",null,Ni.defaultGroup,Yt.isDefaultSelected(e)),i=n.map(c=>Yt.makeOption(c.format.label,c.format,c.group,Ge.isSameFormat(c.format,e))),o=Yt.isCustomSelected(e),a=o?e:Ge.makeCustomFormat(),r=Yt.makeCustomFormatOption(a,Ni.customGroup,Ge.DEFAULT_FORMAT_STRING,o,c=>{if(c!=null){const h=Ge.makeCustomFormat(c);Ge.isValid(h)&&t(h)}else t(null)});return[s,...i,r]}}const bT=Ni;const _d=Z.module("IrisGridContextMenuHandler"),wT=150,jd="yyyy-MM-dd HH:mm:ss.SSSSSSSSS";class ee extends dt{static GROUP_EDIT=ie.groups.high+10;static GROUP_HIDE_COLUMNS=ie.groups.high+25;static GROUP_FILTER=ie.groups.high+50;static GROUP_EXPAND_COLLAPSE=ie.groups.high+55;static GROUP_GOTO=ie.groups.high+60;static GROUP_SORT=ie.groups.high+75;static GROUP_COPY=ie.groups.high+100;static GROUP_FORMAT=ie.groups.high+150;static COLUMN_SORT_DIRECTION={ascending:"ASC",descending:"DESC",none:null};static getQuickFilterCondition(e,t,n){return e&&n==="&&"?e.and(t):e&&n==="||"?e.or(t):t}static getQuickFilterText(e,t,n){return n&&e!=null?`${e} ${n} ${t}`:t}static getOperatorAsText(e){return e==="&&"?"And":"Or"}static getNumberValueEqualsFilter(e,t){const n=e.filter();if(t===Number.POSITIVE_INFINITY)return R.FilterCondition.invoke("isInf",n).and(n.greaterThan(R.FilterValue.ofNumber(0)));if(t===Number.NEGATIVE_INFINITY)return R.FilterCondition.invoke("isInf",n).and(n.lessThan(R.FilterValue.ofNumber(0)));if(Number.isNaN(t))return R.FilterCondition.invoke("isNaN",n);const s=ee.getFilterValueForNumberOrChar(e.type,t);return n.eq(s)}static getFilterValueForNumberOrChar(e,t){return x.isCharType(e)?R.FilterValue.ofString(String.fromCharCode(t)):R.FilterValue.ofNumber(t)}static getRowOptionFormatted(e,t,n=30){return`${e} "${Pt.truncate(t,n-e.length-3)}"`}irisGrid;debouncedUpdateCustomFormat;constructor(e){super(),this.debouncedUpdateCustomFormat=Ye(e.handleFormatSelection,wT),this.irisGrid=e}componentWillUnmount(){this.debouncedUpdateCustomFormat.flush()}getHeaderActions(e,t){const{irisGrid:n}=this,{column:s}=t;M(s);const{model:i}=n.props,{columns:o}=i,a=o[e],r=[],{metrics:c,reverseType:h,quickFilters:u,advancedFilters:m,searchFilter:g}=n.state,p=n.getTheme();M(c);const{filterIconColor:C,filterBarActiveColor:f,contextMenuSortIconColor:S,contextMenuReverseIconColor:v}=p,w=i.sort,T=x.getSortForColumn(w,a.name),y=h!==x.REVERSE_TYPE.NONE,{userColumnWidths:E}=c,D=[...E.values()].some(_=>_===0),F=i.getColumnHeaderParentGroup(e,0)===void 0,N=i.isColumnFrozen(e);return r.push({title:"Hide Column",group:ee.GROUP_HIDE_COLUMNS,action:()=>{this.irisGrid.hideColumnByVisibleIndex(s)}}),r.push({title:N?"Unfreeze Column":"Freeze Column",group:ee.GROUP_HIDE_COLUMNS,disabled:!F,action:()=>{N?this.irisGrid.unFreezeColumnByColumnName(a.name):this.irisGrid.freezeColumnByColumnName(a.name)},order:10}),r.push({title:"Show All Columns",group:ee.GROUP_HIDE_COLUMNS,action:()=>{this.irisGrid.showAllColumns()},disabled:!D}),r.push({title:"Quick Filters",icon:Un,iconColor:f,shortcut:qt.TABLE.TOGGLE_QUICK_FILTER,group:ee.GROUP_FILTER,order:10,action:()=>{this.irisGrid.toggleFilterBar(s)}}),r.push({title:"Advanced Filters",icon:m.get(e)?kl:Fa,iconColor:C,group:ee.GROUP_FILTER,order:20,action:()=>{this.irisGrid.handleAdvancedMenuOpened(s)}}),r.push({title:"Clear Table Filters",group:ee.GROUP_FILTER,order:40,shortcut:qt.TABLE.CLEAR_FILTERS,action:()=>{this.irisGrid.clearAllFilters()},disabled:!(u.size>0||m.size>0||g!=null)}),r.push({title:"Sort by",icon:Un,iconColor:S,group:ee.GROUP_SORT,order:10,actions:this.sortByActions(a,e,T)}),r.push({title:"Add Additional Sort",disabled:T&&w.length===1||y&&w.length===1||T&&y&&w.length===2||w.length===0,group:ee.GROUP_SORT,order:20,actions:this.additionalSortActions(a,e)}),r.push({title:"Clear Table Sorting",disabled:w.length===0||y&&w.length===1,group:ee.GROUP_SORT,action:()=>{this.irisGrid.sortColumn(s,ee.COLUMN_SORT_DIRECTION.none)},order:30}),r.push({title:h===x.REVERSE_TYPE.NONE?"Reverse Table":"Clear Reverse Table",icon:Un,iconColor:v,group:ee.GROUP_SORT,order:40,disabled:!i.isReversible,shortcut:qt.TABLE.REVERSE,action:()=>{h===x.REVERSE_TYPE.NONE?this.irisGrid.reverse(x.REVERSE_TYPE.POST_SORT):this.irisGrid.reverse(x.REVERSE_TYPE.NONE)}}),r.push({title:"Copy Column Name",group:ee.GROUP_COPY,action:()=>{Yi(i.textForColumnHeader(e)??"").catch(_=>_d.error("Unable to copy header",_))}}),x.isDateType(a.type)?r.push({title:"Date/Time Format",group:ee.GROUP_FORMAT,actions:this.dateFormatActions(a)}):x.isNumberType(a.type)&&r.push({title:"Number Format",group:ee.GROUP_FORMAT,actions:this.numberFormatActions(a)??void 0}),r}getCellActions(e,t,n){M(e);const{irisGrid:s}=this,{column:i,row:o}=n,{model:a,canCopy:r}=s.props,{columns:c}=a,h=s.getModelRow(o);M(h);const u=a.valueForCell(e,h),m=a.textForCell(e,h),g=c[e],p=[],{quickFilters:C}=s.state,f=s.getTheme(),{filterIconColor:S}=f,{settings:v}=s.props,w=new je({timeZone:v?.timeZone,showTimeZone:!1,showTSeparator:!0,defaultDateTimeFormatString:jd}),T=new je({timeZone:v?.timeZone,showTimeZone:v?.showTimeZone,showTSeparator:v?.showTSeparator,defaultDateTimeFormatString:jd});if(g==null||o==null)return p;if(a.isFilterable(e)){const E={title:"Filter by Value",icon:Un,iconColor:S,group:ee.GROUP_FILTER,order:10,actions:[]};if(u==null)C.get(e)&&E.actions.push({title:"And",actions:this.nullFilterActions(g,C.get(e),"&&"),order:2,group:ie.groups.high}),E.actions.push(...this.nullFilterActions(g));else if(x.isBooleanType(g.type))C.get(e)&&E.actions.push({title:"Or",actions:this.booleanFilterActions(g,m,C.get(e),"||"),order:2,group:ie.groups.high}),E.actions.push(...this.booleanFilterActions(g,m));else if(x.isNumberType(g.type)||x.isCharType(g.type)){M(e);const D=x.isCharType(g.type)?String.fromCharCode(u):`${u}`;C.get(e)&&E.actions.push({title:"And",actions:this.numberFilterActions(g,D,u,C.get(e),"&&"),order:2,group:ie.groups.high}),E.actions.push(...this.numberFilterActions(g,D,u,C.get(e)))}else if(x.isDateType(g.type)){const D=w.format(u),F=T.format(u);C.get(e)&&E.actions.push({title:"And",actions:this.dateFilterActions(g,D,F,u,C.get(e),"&&"),order:2,group:ie.groups.high}),E.actions.push(...this.dateFilterActions(g,D,F,u,C.get(e)))}else C.get(e)&&E.actions.push({title:"And",actions:this.stringFilterActions(g,m,u,C.get(e),"&&"),order:2,group:ie.groups.high}),E.actions.push(...this.stringFilterActions(g,m,u));E.actions!=null&&E.actions.length>0&&p.push(E)}if(qe(a)&&a.isRowExpandable(h)){const E=a.groupedColumns.length>0?a.depthForRow(h)-1:0,F=a.valueForCell(E,h)==null?"null":a.textForCell(E,h);p.push({title:ee.getRowOptionFormatted(a.isRowExpanded(h)?"Collapse":"Expand",F),group:ee.GROUP_EXPAND_COLLAPSE,order:10,action:()=>{a.setRowExpanded(h,!a.isRowExpanded(h))}}),a.isExpandAllAvailable===!0&&p.push({title:ee.getRowOptionFormatted("Expand All in",F),group:ee.GROUP_EXPAND_COLLAPSE,order:20,action:()=>{a.setRowExpanded(h,!0,!0)}})}qe(a)&&a.hasExpandableRows&&a.isExpandAllAvailable===!0&&(p.push({title:"Expand Entire Table",group:ee.GROUP_EXPAND_COLLAPSE,order:30,action:()=>{a.expandAll()}}),p.push({title:"Collapse Entire Table",group:ee.GROUP_EXPAND_COLLAPSE,order:40,action:()=>{a.collapseAll()}}));const y={title:"Go to",iconColor:S,shortcut:qt.TABLE.GOTO_ROW,group:ee.GROUP_GOTO,order:10,action:()=>this.irisGrid.toggleGotoRow(`${o+1}`,`${u}`,g.name)};return p.push(y),r&&(p.push({title:"Copy Cell",group:ee.GROUP_COPY,order:10,action:()=>{s.copyCell(i,o)}}),p.push({title:"Copy Cell Unformatted",group:ee.GROUP_COPY,order:20,action:()=>{s.copyCell(i,o,!0)}})),p}onContextMenu(e,t,n){const{irisGrid:s}=this,{y:i,column:o,row:a,columnHeaderDepth:r}=e,c=s.getModelColumn(o),h=s.getModelRow(a),{model:u,canCopy:m}=s.props,{columns:g}=u,{metrics:p,isFilterBarShown:C,quickFilters:f,advancedFilters:S,selectedRanges:v}=s.state;M(p);const{columnHeaderHeight:w,gridY:T,columnHeaderMaxDepth:y}=p,E=[];if(c!=null&&h!=null){const D=u.valueForCell(c,h),F=u.textForCell(c,h),N=g[c],{onContextMenu:_}=s.props;N!=null&&E.push(_({model:u,value:D,valueText:F,column:N,rowIndex:a,columnIndex:o,modelRow:h,modelColumn:c}))}return c!=null&&u.isFilterable(c)&&E.push({title:"Clear Column Filter",group:ee.GROUP_FILTER,order:30,action:()=>{this.irisGrid.removeColumnFilter(c)},disabled:!(f.has(c)||S.has(c))}),(C?i<=T:i<=w*y&&r===0)?c!=null&&E.push(...this.getHeaderActions(c,e)):(c!=null&&h!=null&&E.push(...this.getCellActions(c,t,e)),m&&v.length>0&&(E.push({title:"Copy Selection",shortcut:ss.COPY,group:ee.GROUP_COPY,order:30,action:()=>{s.copyRanges(v)}}),E.push({title:"Copy Selection w/ Headers",group:ee.GROUP_COPY,order:40,action:()=>{s.copyRanges(v,!0)}})),Ze(u)&&u.isEditable&&v.length>0&&E.push({title:"Delete Selected Rows",group:ee.GROUP_EDIT,order:50,action:()=>{this.irisGrid.deleteRanges(v)}})),E.length===0?!1:(M(s.gridWrapper),ie.triggerMenu(s.gridWrapper,n.clientX,n.clientY,E),!0)}dateFormatActions(e){const{model:t}=this.irisGrid.props,{formatter:n}=t,s=n.getColumnFormat(e.type,e.name),i=CT.getOptions(n,s),o=[];for(let a=0;a<i.length;a+=1){const{description:r,format:c,group:h,isSelected:u,title:m}=i[a];o.push({title:m,description:r,icon:u?Jn:void 0,group:h,order:a,action:()=>{const g=t.getColumnIndexByName(e.name);M(g),this.irisGrid.handleFormatSelection(g,c)}})}return o}numberFormatActions(e){const{model:t}=this.irisGrid.props,{formatter:n}=t,s=n.getColumnFormat(e.type,e.name);let i;const o=t.getColumnIndexByName(e.name);if(x.isDecimalType(e.type))i=ST.getOptions(s,r=>{M(o),this.debouncedUpdateCustomFormat(o,r)});else if(x.isIntegerType(e.type))i=bT.getOptions(s,r=>{M(o),this.debouncedUpdateCustomFormat(o,r)});else return _d.error("Invalid column type in numberFormatActions"),null;const a=[];for(let r=0;r<i.length;r+=1){const{format:c,isSelected:h}=i[r];a.push({...i[r],icon:h?Jn:void 0,order:r,action:()=>{o===void 0&&c&&c.type===ct.TYPE_CONTEXT_CUSTOM||(M(o),this.irisGrid.handleFormatSelection(o,c))}})}return a}stringFilterActions(e,t,n,s,i){const o=R.FilterValue.ofString(n);let a=s;a||(a={filter:null,text:null});const{filter:r,text:c}=a,h=[],{model:u}=this.irisGrid.props,m=u.getColumnIndexByName(e.name);return M(m),h.push({menuElement:l.jsxs("div",{className:"iris-grid-filter-menu-item-value",children:[i?ee.getOperatorAsText(i):""," ",'"',t,'"']}),order:1,group:ie.groups.high}),h.push({title:"text is exactly",description:`Show only rows where ${e.name} is ${n} (case sensitive)`,action:()=>{this.irisGrid.setQuickFilter(m,ee.getQuickFilterCondition(r,e.filter().eq(o),i),ee.getQuickFilterText(c,`=${t}`,i))},order:10,group:ie.groups.low}),h.push({title:"text is not exactly",description:`Show only rows where ${e.name} is not ${t} (case sensitive)`,action:()=>{this.irisGrid.setQuickFilter(m,ee.getQuickFilterCondition(r,e.filter().notEq(o),i),ee.getQuickFilterText(c,`!=${t}`,i))},order:20,group:ie.groups.low}),h.push({title:"text contains",description:`Show only rows where ${e.name} contains ${t}`,action:()=>{this.irisGrid.setQuickFilter(m,ee.getQuickFilterCondition(r,e.filter().contains(o),i),ee.getQuickFilterText(c,`~${t}`,i))},order:30,group:ie.groups.low}),h.push({title:"text does not contain",description:`Show only rows where ${e.name} does not contain ${n}`,action:()=>{this.irisGrid.setQuickFilter(m,ee.getQuickFilterCondition(r,e.filter().contains(o).not(),i),ee.getQuickFilterText(c,`!~${t}`,i))},order:40,group:ie.groups.low}),h.push({title:"text starts with",description:`Show only rows where ${e.name} starts with ${t}`,action:()=>{this.irisGrid.setQuickFilter(m,ee.getQuickFilterCondition(r,e.filter().invoke("startsWith",o),i),ee.getQuickFilterText(c,`${t}*`,i))},order:50,group:ie.groups.low}),h.push({title:"text ends with",description:`Show only rows where ${e.name} ends with ${t}`,action:()=>{this.irisGrid.setQuickFilter(m,ee.getQuickFilterCondition(r,e.filter().invoke("endsWith",o),i),ee.getQuickFilterText(c,`*${t}`,i))},order:60,group:ie.groups.low}),h}numberFilterActions(e,t,n,s,i){const o=ee.getFilterValueForNumberOrChar(e.type,n);let a=null,r=null;s&&(a=s.filter,r=s.text);const c=[],h=n!==Number.POSITIVE_INFINITY&&n!==Number.NEGATIVE_INFINITY&&!Number.isNaN(n),{model:u}=this.irisGrid.props,m=u.getColumnIndexByName(e.name);return M(m),c.push({menuElement:l.jsxs("div",{className:"iris-grid-filter-menu-item-value",children:[i?ee.getOperatorAsText(i):""," ",'"',t,'"']}),order:1,group:ie.groups.high}),c.push({title:"is equal to",description:`Show only rows where ${e.name} is ${t}`,action:()=>{const g=ee.getNumberValueEqualsFilter(e,n);this.irisGrid.setQuickFilter(m,ee.getQuickFilterCondition(a,g,i),ee.getQuickFilterText(r,`=${t}`,i))},order:10,group:ie.groups.low}),c.push({title:"is not equal to",description:`Show only rows where ${e.name} is not ${t}`,action:()=>{const g=ee.getNumberValueEqualsFilter(e,n).not();this.irisGrid.setQuickFilter(m,ee.getQuickFilterCondition(a,g,i),ee.getQuickFilterText(r,`!=${t}`,i))},order:20,group:ie.groups.low}),h&&!x.isCharType(e.type)&&(c.push({title:"greater than",description:`Show only rows where ${e.name} is greater than ${t}`,action:()=>{this.irisGrid.setQuickFilter(m,ee.getQuickFilterCondition(a,e.filter().greaterThan(o),i),ee.getQuickFilterText(r,`>${t}`,i))},order:30,group:ie.groups.low}),c.push({title:"greater than or equal to",description:`Show only rows where ${e.name} is greater than or equal to ${t}`,action:()=>{this.irisGrid.setQuickFilter(m,ee.getQuickFilterCondition(a,e.filter().greaterThanOrEqualTo(o),i),ee.getQuickFilterText(r,`>=${t}`,i))},order:40,group:ie.groups.low}),c.push({title:"less than",description:`Show only rows where ${e.name} is less than ${t}`,action:()=>{this.irisGrid.setQuickFilter(m,ee.getQuickFilterCondition(a,e.filter().lessThan(o),i),ee.getQuickFilterText(r,`<${t}`,i))},order:50,group:ie.groups.low}),c.push({title:"less than or equal to",description:`Show only rows where ${e.name} is less than or equal to ${t}`,action:()=>{this.irisGrid.setQuickFilter(m,ee.getQuickFilterCondition(a,e.filter().lessThanOrEqualTo(o),i),ee.getQuickFilterText(r,`<=${t}`,i))},order:60,group:ie.groups.low})),c}booleanFilterActions(e,t,n,s){const i=[],{model:o}=this.irisGrid.props,{filter:a,text:r}=n||{},c=o.getColumnIndexByName(e.name);return M(c),i.push({menuElement:l.jsxs("div",{className:"iris-grid-filter-menu-item-value",children:[s?ee.getOperatorAsText(s):""," ",'"',t??"null",'"']}),order:1,group:ie.groups.high}),i.push({title:"true",description:`Show only rows where ${e.name} is true`,action:()=>{this.irisGrid.setQuickFilter(c,ee.getQuickFilterCondition(a,e.filter().isTrue(),s),ee.getQuickFilterText(r,"true",s))},order:10,group:ie.groups.low}),i.push({title:"false",description:`Show only rows where ${e.name} is false`,action:()=>{this.irisGrid.setQuickFilter(c,ee.getQuickFilterCondition(a,e.filter().isFalse(),s),ee.getQuickFilterText(r,"false",s))},order:20,group:ie.groups.low}),i.push({title:"is null",description:`Show only rows where ${e.name} is null`,action:()=>{this.irisGrid.setQuickFilter(c,ee.getQuickFilterCondition(a,e.filter().isNull(),s),ee.getQuickFilterText(r,"null",s))},order:30,group:ie.groups.low}),i.push({title:"is not null",description:`Show only rows where ${e.name} is not null`,action:()=>{this.irisGrid.setQuickFilter(c,ee.getQuickFilterCondition(a,e.filter().isNull().not(),s),ee.getQuickFilterText(r,"!null",s))},order:40,group:ie.groups.low}),i}dateFilterActions(e,t,n,s,i,o){const a=R.FilterValue.ofNumber(s);let r=null,c=null;i&&(r=i.filter,c=i.text);const{model:h}=this.irisGrid.props,u=h.getColumnIndexByName(e.name);M(u);const m=[];return m.push({menuElement:l.jsxs("div",{className:"iris-grid-filter-menu-item-value",children:[o?ee.getOperatorAsText(o):""," ",'"',n,'"']}),order:1,group:ie.groups.high}),m.push({title:"date is",description:`Show only rows where ${e.name} is ${n}`,action:()=>{this.irisGrid.setQuickFilter(u,ee.getQuickFilterCondition(r,e.filter().eq(a),o),ee.getQuickFilterText(c,`=${t}`,o))},order:10,group:ie.groups.low}),m.push({title:"date is not",description:`Show only rows where ${e.name} is not ${n}`,action:()=>{this.irisGrid.setQuickFilter(u,ee.getQuickFilterCondition(r,e.filter().notEq(a),o),ee.getQuickFilterText(c,`!=${t}`,o))},order:20,group:ie.groups.low}),m.push({title:"date is before",description:`Show only rows where ${e.name} is before ${n}`,action:()=>{this.irisGrid.setQuickFilter(u,ee.getQuickFilterCondition(r,e.filter().lessThan(a),o),ee.getQuickFilterText(c,`<${t}`,o))},order:30,group:ie.groups.low}),m.push({title:"date is before or equal",description:`Show only rows where ${e.name} is before or equal to ${n}`,action:()=>{this.irisGrid.setQuickFilter(u,ee.getQuickFilterCondition(r,e.filter().lessThanOrEqualTo(a),o),ee.getQuickFilterText(c,`<=${t}`,o))},order:40,group:ie.groups.low}),m.push({title:"date is after",description:`Show only rows where ${e.name} is greater than ${n}`,action:()=>{this.irisGrid.setQuickFilter(u,ee.getQuickFilterCondition(r,e.filter().greaterThan(a),o),ee.getQuickFilterText(c,`>${t}`,o))},order:50,group:ie.groups.low}),m.push({title:"date is after or equal",description:`Show only rows where ${e.name} is after or equal to ${n}`,action:()=>{this.irisGrid.setQuickFilter(u,ee.getQuickFilterCondition(r,e.filter().greaterThanOrEqualTo(a),o),ee.getQuickFilterText(c,`>=${t}`,o))},order:60,group:ie.groups.low}),m}nullFilterActions(e,t,n){let s=null,i=null;t&&(s=t.filter,i=t.text);const o=[],{model:a}=this.irisGrid.props,r=a.getColumnIndexByName(e.name);return M(r),o.push({menuElement:l.jsxs("div",{className:"iris-grid-filter-menu-item-value",children:[n?ee.getOperatorAsText(n):""," ",'"null"']}),order:1,group:ie.groups.high}),o.push({title:"is null",description:`Show only rows where ${e.name} is null`,action:()=>{this.irisGrid.setQuickFilter(r,ee.getQuickFilterCondition(s,e.filter().isNull(),n),ee.getQuickFilterText(i,"null",n))},order:10,group:ie.groups.low}),o.push({title:"is not null",description:`Show only rows where ${e.name} is not null`,action:()=>{this.irisGrid.setQuickFilter(r,ee.getQuickFilterCondition(s,e.filter().isNull().not(),n),ee.getQuickFilterText(i,"!null",n))},order:20,group:ie.groups.low}),o}sortByActions(e,t,n){const s=this.irisGrid.getTheme(),{contextMenuSortIconColor:i}=s,o=[{title:`${e.name} Ascending`,order:10,action:()=>{this.irisGrid.sortColumn(t,ee.COLUMN_SORT_DIRECTION.ascending)},icon:this.checkColumnSort(n,ee.COLUMN_SORT_DIRECTION.ascending)?Un:void 0,iconColor:i},{title:`${e.name} Descending`,order:20,action:()=>{this.irisGrid.sortColumn(t,ee.COLUMN_SORT_DIRECTION.descending)},icon:this.checkColumnSort(n,ee.COLUMN_SORT_DIRECTION.descending)?Un:void 0,iconColor:i},{title:"Remove Sort",order:50,action:()=>{this.irisGrid.sortColumn(t,ee.COLUMN_SORT_DIRECTION.none,!1,!0)},disabled:!n}];return x.isNumberType(e.type)&&(o.push({title:`ABS(${e.name}) Ascending`,order:30,action:()=>{this.irisGrid.sortColumn(t,ee.COLUMN_SORT_DIRECTION.ascending,!0)},icon:this.checkColumnSort(n,ee.COLUMN_SORT_DIRECTION.ascending,!0)?Un:void 0,iconColor:i}),o.push({title:`ABS(${e.name}) Descending`,order:40,action:()=>{this.irisGrid.sortColumn(t,ee.COLUMN_SORT_DIRECTION.descending,!0)},icon:this.checkColumnSort(n,ee.COLUMN_SORT_DIRECTION.descending,!0)?Un:void 0,iconColor:i})),o}additionalSortActions(e,t){const n=this.irisGrid.getTheme(),{contextMenuSortIconColor:s}=n,i=[{title:"Add Sort By",menuElement:l.jsxs("div",{className:"btn-context-menu menu-title",children:[l.jsx("span",{className:"icon",children:l.jsx(Q,{icon:Un,style:{color:s??void 0}})}),l.jsx("span",{className:"title",children:"Add Additional Sort"}),l.jsx("span",{className:"shortcut",children:Ve.isMacPlatform()?"⌘Click":"Ctrl+Click"})]}),order:1},{title:`${e.name} Ascending`,order:10,action:()=>{this.irisGrid.sortColumn(t,ee.COLUMN_SORT_DIRECTION.ascending,!1,!0)}},{title:`${e.name} Descending`,order:20,action:()=>{this.irisGrid.sortColumn(t,ee.COLUMN_SORT_DIRECTION.descending,!1,!0)}}];return x.isNumberType(e.type)&&(i.push({title:`ABS(${e.name}) Ascending`,order:30,action:()=>{this.irisGrid.sortColumn(t,ee.COLUMN_SORT_DIRECTION.ascending,!0,!0)}}),i.push({title:`ABS(${e.name}) Descending`,order:40,action:()=>{this.irisGrid.sortColumn(t,ee.COLUMN_SORT_DIRECTION.descending,!0,!0)}})),i}checkColumnSort(e,t=null,n=!1){return e?e.direction===t&&e.isAbs===n:!1}}const vT=ee;class TT extends dt{constructor(e){super(),this.irisGrid=e}irisGrid;onDoubleClick(e){const{column:t,row:n}=e;return n==null||t==null?!1:(this.irisGrid.selectData(t,n),!0)}}const ET=TT;class yT extends dt{constructor(e){super(),this.irisGrid=e}irisGrid;onDown(e){const{y:t,column:n,row:s}=e;if(n!==null&&s===null){const{isFilterBarShown:i,metrics:o}=this.irisGrid.state;if(!o)throw new Error("Metrics not set");const{columnHeaderMaxDepth:a}=o,r=this.irisGrid.getTheme();if(i&&r.columnHeaderHeight!=null&&r.filterBarHeight!=null&&t>r.columnHeaderHeight*a&&t<=r.columnHeaderHeight*a+r.filterBarHeight)return this.irisGrid.focusFilterBar(n),!0}return!1}onMove(e){const{y:t,column:n}=e,{isFilterBarShown:s,hoverAdvancedFilter:i,metrics:o}=this.irisGrid.state;if(!o)throw new Error("Metrics not set");const{columnHeaderMaxDepth:a}=o,r=this.irisGrid.getTheme();let c=null;return s&&r.columnHeaderHeight!=null&&r.filterBarHeight!=null&&n!==null&&t>=r.columnHeaderHeight*a&&t<=r.columnHeaderHeight*a+r.filterBarHeight&&(c=n),c!==i&&this.irisGrid.setState({hoverAdvancedFilter:c}),!1}onLeave(e){const{column:t}=e,{hoverAdvancedFilter:n}=this.irisGrid.state;return n!==null&&t!==n&&this.irisGrid.setState({hoverAdvancedFilter:null}),!1}}const RT=yT;class xT extends dt{irisGrid;constructor(e){super(750),this.irisGrid=e}destroyTooltip(){this.irisGrid.setState({expandCellTooltipProps:null})}setCursor(e,t){return Wi.isInTreeBox(e,t)?(this.cursor="pointer",{stopPropagation:!1,preventDefault:!1}):(this.cursor=null,!1)}getButtonPosition({x:e,y:t,column:n,row:s}){if(n==null||s==null)return null;const{renderer:i,grid:o,state:a,props:r}=this.irisGrid;if(!o)return null;const{metrics:c}=a,{model:h}=r,{canvasContext:u}=o,m=o.getTheme(),g={context:u,mouseX:e,mouseY:t,metrics:c,model:h,theme:m},p=qe(h)?h.depthForRow(s):null,{left:C,top:f,width:S,height:v}=i.getExpandButtonPosition(g,p);return C==null||S==null||f==null||v==null?null:{left:C,top:f,width:S,height:v}}onMove(e,t){if(Wi.isInTreeBox(e,t)){const{expandCellTooltipProps:n}=this.irisGrid.state,{model:s}=this.irisGrid.props,i=this.getButtonPosition(e),{row:o}=e;M(o);const a=qe(s)&&s.isRowExpanded(o);it(n,i)||this.irisGrid.setState({expandCellTooltipProps:i,expandTooltipDisplayValue:a?"collapse":"expand"})}else this.destroyTooltip();return this.setCursor(e,t)}onDown(){return this.destroyTooltip(),!1}onContextMenu(){return this.destroyTooltip(),!1}onWheel(){return this.destroyTooltip(),!1}onLeave(){return this.destroyTooltip(),!1}}const IT=xT;class DT extends dt{constructor(e){super(),this.column=null,this.irisGrid=e}irisGrid;column;getColumnFromGridPoint(e){const{column:t,row:n,columnHeaderDepth:s}=e;return t!==null&&n===null&&s===0?t:null}onDown(e){return this.column=this.getColumnFromGridPoint(e),!1}onClick(e,t,n){const s=this.getColumnFromGridPoint(e);if(s!=null&&s===this.column){const i=Ve.isModifierKeyDown(n);return this.irisGrid.toggleSort(s,i),!0}return!1}}const FT=DT;class NT extends dt{constructor(e){super(),this.irisGrid=e}onWheel(e,t,n){const{irisGrid:s}=this,{model:i}=s.props,{metrics:o,pendingRowCount:a}=s.state;M(o);const{bottom:r,rowCount:c,rowHeight:h}=o,{deltaY:u}=V.getScrollDelta(n);return Ze(i)&&i.isEditable&&r>=c-1&&u>0&&s.setState({pendingRowCount:a+Math.ceil(u/h)}),!1}}const MT=NT;class kT extends dt{irisGrid;currentLinkBox;constructor(e){super(),this.irisGrid=e}destroyTooltip(){this.irisGrid.setState({linkHoverTooltipProps:null})}isHoveringLink(e,t){const{column:n,row:s,x:i,y:o}=e,{renderer:a,metrics:r}=t;if(n==null||s==null||r==null)return this.currentLinkBox=void 0,!1;if(this.currentLinkBox!=null){const{x1:u,y1:m,x2:g,y2:p}=this.currentLinkBox;if(i>=u&&i<=g&&o>=m&&o<=p)return!0}const c=t.updateRenderState(),h=a.getTokenBoxesForVisibleCell(n,s,c);for(let u=0;u<h.length;u+=1)if(Ba(h[u].token)){const m=V.translateTokenBox(h[u],r),{x1:g,x2:p,y1:C,y2:f}=m;if(i>=g&&i<=p&&o>=C&&o<=f)return this.currentLinkBox=m,!0}return this.currentLinkBox=void 0,!1}setCursor(e,t){return this.isHoveringLink(e,t)?(this.cursor="pointer",{stopPropagation:!1,preventDefault:!1}):(this.cursor=null,!1)}onMove(e,t){if(this.isHoveringLink(e,t)&&this.currentLinkBox!=null&&Ba(this.currentLinkBox.token)){const{linkHoverTooltipProps:s}=this.irisGrid.state;if(this.currentLinkBox==null)return!1;const{x1:i,y1:o,x2:a,y2:r}=this.currentLinkBox,{href:c}=this.currentLinkBox.token,h=a-i,u=r-o,m={left:i,top:o+1,width:h,height:u};it(s,m)||this.irisGrid.setState({linkHoverTooltipProps:m,linkHoverDisplayValue:c})}else this.destroyTooltip();return this.setCursor(e,t)}onDown(){return this.destroyTooltip(),!1}onContextMenu(){return this.destroyTooltip(),!1}onWheel(){return this.destroyTooltip(),!1}onLeave(){return this.destroyTooltip(),!1}}const OT=kT,AT=3e3;function LT({children:d=null,onEntering:e,onEntered:t,onExiting:n,onExited:s}){const[i,o]=b.useState(!1),a=b.useRef(),r=lr(d),c=b.useCallback(()=>{o(!0),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{o(!1)},AT)},[o,a]);return b.useEffect(()=>{r!==d&&d!=null&&c()},[d,r,o,c]),b.useEffect(()=>()=>a.current?clearTimeout(a.current):void 0,[]),l.jsx(Er,{className:"toast-bottom-bar",isShown:i,onEntering:e,onEntered:t,onExiting:n,onExited:s,children:d})}class PT extends _o{getGridY(e){let t=super.getGridY(e);const{isFilterBarShown:n,theme:s,advancedFilters:i,quickFilters:o,sorts:a,reverseType:r}=e;return n?t+=s.filterBarHeight:(o!=null&&o.size>0||i!=null&&i.size>0)&&(t+=s.filterBarCollapsedHeight),r!==x.REVERSE_TYPE.NONE&&a!=null&&a.length>0&&(t+=s.reverseHeaderBarHeight),t}getUserColumnWidths(){return this.userColumnWidths}}const _T=PT,jT=1,am=J.memo(({model:d,modelColumns:e,top:t,bottom:n,left:s,right:i,filter:o,formatter:a,reverseType:r=x.REVERSE_TYPE.NONE,sorts:c,customColumns:h,movedColumns:u,hiddenColumns:m,alwaysFetchColumns:g,rollupConfig:p=null,totalsConfig:C=null,selectDistinctColumns:f=Fe,pendingRowCount:S=0,pendingDataMap:v=qn,frozenColumns:w,formatColumns:T,columnHeaderGroups:y})=>{const E=b.useMemo(()=>be.getModelViewportColumns(e,s,i,u,m,g,jT),[e,s,i,u,m,g]);return b.useEffect(function(){d.filter=o},[d,o]),b.useEffect(function(){const F=[...c];r!==x.REVERSE_TYPE.NONE&&F.push(R.Table.reverse()),d.sort=F},[d,c,r]),b.useEffect(function(){d.formatter=a},[d,a]),b.useEffect(function(){d.isCustomColumnsAvailable&&(d.customColumns=h)},[d,h]),b.useEffect(function(){d.isFormatColumnsAvailable&&(d.formatColumns=T)},[d,T]),b.useEffect(function(){d.setViewport(t,n,E)},[d,t,n,E]),b.useEffect(function(){d.isRollupAvailable&&(d.rollupConfig=p)},[d,d.isRollupAvailable,p]),b.useEffect(function(){d.isSelectDistinctAvailable&&(d.selectDistinctColumns=f)},[d,f]),b.useEffect(function(){d.isTotalsAvailable&&(d.totalsConfig=C)},[d,d.isTotalsAvailable,C]),b.useEffect(function(){d.pendingRowCount=S},[d,S]),b.useEffect(function(){d.pendingDataMap=v},[d,v]),b.useEffect(function(){w&&d.updateFrozenColumns(w)},[d,w]),b.useEffect(function(){d.columnHeaderGroups=y},[d,y]),null});am.displayName="IrisGridModelUpdater";const HT=am,Dn=Object.freeze({SORT_UP:"sortUp",SORT_DOWN:"sortDown",CARET_DOWN:"caretDown",CARET_RIGHT:"caretRight",CELL_OVERFLOW:"cellOverflow"}),Hd=10,zr=16;class Eo extends Pt{static isFilterValid(e,t){const n=e==null||e.filter!=null,s=t==null||t.filter!=null;return n&&s}constructor(){super(),this.icons={},this.initIcons()}icons;initIcons(){this.setIcon(Dn.SORT_UP,Vg),this.setIcon(Dn.SORT_DOWN,Bg),this.setIcon(Dn.CARET_DOWN,Pn),this.setIcon(Dn.CARET_RIGHT,Nh),this.setIcon(Dn.CELL_OVERFLOW,Ug)}setIcon(e,t){const n=Array.isArray(t.icon[4])?t.icon[4][0]:t.icon[4],s=new Path2D(n),i=new Path2D,o={a:zr/t.icon[0],d:zr/t.icon[1]};i.addPath(s,o),this.icons[e]=i}getIcon(e){return this.icons[e]}getSortIcon(e){return e?e.direction===x.sortDirection.ascending?this.getIcon(Dn.SORT_UP):e.direction===x.sortDirection.descending?this.getIcon(Dn.SORT_DOWN):null:null}drawCanvas(e){super.drawCanvas(e),this.drawScrim(e)}drawGrid(e,t){super.drawGrid(e,t),this.drawCellOverflowButton(t)}drawGridLines(e,t){super.drawGridLines(e,t),this.drawGroupedColumnLine(e,t),this.drawPendingRowLine(e,t)}drawCellContent(e,t,n,s){const{metrics:i,model:o}=t,{modelColumns:a,modelRows:r}=i,c=L(r,s),h=a.get(n);if(h===void 0)return;const u=o.valueForCell(h,c);if(x.isTextType(o.columns[h]?.type)&&(u===null||u==="")){const m=e.font;e.font=`italic ${m}`;const g=u===null?"null":"empty";super.drawCellContent(e,t,n,s,g),e.font=m;return}super.drawCellContent(e,t,n,s)}drawGroupedColumnLine(e,t){const{metrics:n,model:s,theme:i}=t,{groupedColumns:o}=s,{maxY:a,allColumnWidths:r,allColumnXs:c}=n;if(o.length===0||i.groupedColumnDividerColor==null)return;const h=o.length-1,u=c.get(h),m=r.get(h);if(u==null||m==null)return;const g=u+m+.5;e.strokeStyle=i.groupedColumnDividerColor,e.lineWidth=1,e.beginPath(),e.moveTo(g,0),e.lineTo(g,a),e.stroke()}drawPendingRowLine(e,t){const{metrics:n,model:s,theme:i}=t,{allRowYs:o,maxX:a}=n,{pendingRowCount:r}=s;if(r<=0)return;const c=s.rowCount-s.pendingRowCount-s.floatingBottomRowCount;let h=o.get(c);h!=null&&(h-=.5,e.save(),e.setLineDash([4,2]),e.strokeStyle=i.pendingTextColor,e.lineWidth=1,e.beginPath(),e.moveTo(0,h),e.lineTo(a,h),e.stroke(),e.restore())}drawMouseColumnHover(e,t){const{theme:n,metrics:s,hoverSelectColumn:i}=t;if(i==null||n.linkerColumnHoverBackgroundColor==null)return;const{allColumnWidths:o,allColumnXs:a,maxY:r}=s,c=L(a,i),h=L(o,i);e.fillStyle=n.linkerColumnHoverBackgroundColor,e.fillRect(c,0,h,r)}drawMouseRowHover(e,t){const{isSelectingColumn:n}=t;n||super.drawMouseRowHover(e,t)}drawScrim(e){const{context:t,loadingScrimProgress:n,metrics:s,theme:i}=e;if(n==null)return;const{width:o,height:a,gridY:r}=s,{scrimBlurSize:c,scrimColor:h}=i;t.save(),t.globalCompositeOperation="color",t.filter=`blur(${c}px)`,h!=null&&(t.fillStyle=h),t.beginPath(),t.rect(0,r,o,a-r),t.clip(),t.fillRect(-c,-c+r,c*2+o,(c*2+(a-r))*n),t.globalCompositeOperation="overlay",t.filter=`blur(${c}px) opacity(15%)`,t.fillRect(-c,-c+r,c*2+o,(c*2+(a-r))*n),t.restore()}drawColumnHeaders(e,t){super.drawColumnHeaders(e,t);const{theme:n,metrics:s,model:i,reverseType:o}=t,{columnHeaderHeight:a}=s;if(this.drawFilterHeaders(e,t),a<=0)return;const{sort:r}=i;if(r.length===1){const c=o!==x.REVERSE_TYPE.NONE;let h;c?h=n.headerReverseBarColor:h=n.headerSortBarColor,this.drawHeaderBar(e,t,h,c?n.reverseHeaderBarHeight:n.sortHeaderBarHeight)}else r.length>1&&(o!==x.REVERSE_TYPE.NONE&&this.drawHeaderBar(e,t,n.headerReverseBarColor,n.reverseHeaderBarHeight,!1),this.drawHeaderBar(e,t,n.headerSortBarColor,n.sortHeaderBarHeight))}drawHeaderBar(e,t,n,s,i=!0){const{theme:o,metrics:a,model:r}=t,{columnHeaderHeight:c,width:h}=a;let u=0;i||(u=s),e.fillStyle=o.headerBarCasingColor,e.fillRect(0,r.columnHeaderMaxDepth*c-s-2+u,h,s+2),e.fillStyle=n,e.fillRect(0,r.columnHeaderMaxDepth*c-s-1+u,h,s)}drawColumnHeadersAtDepth(e,t,n,s,i){const{metrics:o,model:a,isMenuShown:r}=t,{columnHeaderMaxDepth:c}=a,{width:h}=o,u={...s,maxX:i===c-1&&s.maxX===h?h-(r?0:30):s.maxX};super.drawColumnHeadersAtDepth(e,t,n,u,i)}drawColumnHeaderAtIndex(e,t,n,s){super.drawColumnHeaderAtIndex(e,t,n,s);const{metrics:i,model:o,theme:a}=t,{modelColumns:r,allColumnWidths:c,allColumnXs:h,gridX:u,columnHeaderHeight:m,fontWidths:g}=i,{headerHorizontalPadding:p}=a,C=L(c,n,0),f=L(h,n)+u,S=r.get(n);if(S==null)return;const v=o.columns[S]?.name;if(v==null)return;const w=x.getSortForColumn(o.sort,v);if(!w)return;const T=this.getSortIcon(w);if(!T)return;const y=o.textForColumnHeader(S);if(y===void 0)return;const E=g.get(e.font)??Pt.DEFAULT_FONT_WIDTH;M(E);const D=y.length*E,F=u+f+D+p;let{maxX:N}=s;N-=p;const _=u+f+C-p-1,P=F>N?F+1:Math.min(N,_),U=w.direction===x.sortDirection.ascending?-6:-12,O=m*.5+U;e.save(),e.beginPath(),e.rect(f,0,C,m),e.clip(),e.fillStyle=a.headerSortBarColor,e.translate(P,O),e.fill(T),e.restore()}drawFilterHeaders(e,t){const{isFilterBarShown:n,quickFilters:s,advancedFilters:i}=t;n?this.drawExpandedFilterHeaders(e,t):(s!=null&&s.size>0||i!=null&&i.size>0)&&this.drawCollapsedFilterHeaders(e,t)}drawExpandedFilterHeaders(e,t){const{metrics:n,model:s,theme:i,quickFilters:o,advancedFilters:a}=t,{filterBarHeight:r}=i;if(r<=0)return;const{gridX:c,gridY:h,maxX:u,modelColumns:m,visibleColumns:g,allColumnWidths:p,allColumnXs:C}=n,f=h-r;e.save(),e.font=i.font,e.textAlign="left",o!=null&&o.size>0||a!=null&&a.size>0?e.fillStyle=i.filterBarExpandedActiveBackgroundColor:e.fillStyle=i.filterBarExpandedBackgroundColor,e.fillRect(c,f,u,r-1),e.fillStyle=i.headerBarCasingColor,e.fillRect(c,f+r-1,u,1);const S=f;e.strokeStyle=i.filterBarSeparatorColor,e.beginPath();for(let v=0;v<g.length;v+=1){const w=g[v],T=L(m,w),y=L(C,w),E=L(p,w);if(s.isFilterable(T)&&E>0){const D=c+(y??0);e.rect(D+.5,S+.5,E,r-2)}}e.stroke();for(let v=0;v<g.length;v+=1){const w=g[v],T=L(p,w),E=L(C,w)+c;this.drawExpandedFilterHeader(e,t,w,E,T)}e.restore()}drawExpandedFilterHeader(e,t,n,s,i){if(i<=0)return;const{metrics:o,theme:a,quickFilters:r,advancedFilters:c}=t,{modelColumns:h,gridY:u}=o,{filterBarHeight:m,filterBarExpandedActiveCellBackgroundColor:g,filterBarErrorColor:p,filterBarHorizontalPadding:C,headerColor:f}=a,S=u-m,v=h.get(n);if(v===void 0)return;const w=r.get(v),T=c.get(v);if(w==null&&T==null)return;let y=null;if(w!=null){const{text:D}=w;if(y=D,y||(y=x.getFilterText(w.filter)),y!=null){const{fontWidths:F}=o;let N=F.get(e.font);(N==null||N===0)&&(N=e.measureText("8").width,N||(N=10));const _=(i-C*2)/N;_<=0?y="":y.length>_&&(y=`${y.substring(0,_-1)}…`)}}if(e.save(),Eo.isFilterValid(T,w)&&g!=null)e.fillStyle=g,e.fillRect(s+1,S+1,i-1,m-3);else if(p!=null){e.fillStyle=p,e.lineWidth=2,e.strokeStyle=p;const D=s+2,F=S+2,N=i-3,_=m-5;e.strokeRect(D,F,N,_)}if(y!=null&&y!==""){const D=s+C,F=S+m*.5+1;e.fillStyle=f,e.fillText(y,D,F)}e.restore()}drawCollapsedFilterHeaders(e,t){const{metrics:n,theme:s}=t,{headerSeparatorColor:i,filterBarCollapsedHeight:o}=s;if(o<=0)return;const{gridX:a,gridY:r,maxX:c,visibleColumns:h,allColumnWidths:u,allColumnXs:m}=n,g=r-o;e.save(),e.fillStyle=i,e.fillRect(a,g,c,o);for(let p=0;p<h.length;p+=1){const C=h[p],f=u.get(C),S=m.get(C);if(S!=null&&f!=null){const v=S+a;this.drawCollapsedFilterHeader(e,t,C,v,f)}}e.restore()}drawCollapsedFilterHeader(e,t,n,s,i){if(i<=0)return;const{metrics:o,theme:a,quickFilters:r,advancedFilters:c}=t,{modelColumns:h,gridY:u}=o,m=h.get(n);if(m===void 0)return;const g=r.get(m),p=c.get(m),{filterBarCollapsedHeight:C,filterBarActiveColor:f,filterBarActiveBackgroundColor:S,filterBarErrorColor:v}=a;e.save();const w=Eo.isFilterValid(p,g);S!=null&&g==null&&p==null?e.fillStyle=S:f!=null&&w?e.fillStyle=f:v!=null&&(e.fillStyle=v);const T=s+1,y=u-C,E=i-1,D=C-1;e.fillRect(T,y,E,D),e.restore()}drawTreeMarker(e,t,n,s,i,o,a){e.save();const{x1:r,y1:c}=i,h=a?this.getIcon(Dn.CARET_DOWN):this.getIcon(Dn.CARET_RIGHT),u=n+r-2,m=s+c+2.5;e.fillStyle=o,e.textAlign="center",e.translate(u,m),e.fill(h),e.restore()}drawRowFooters(e,t){const{metrics:n,model:s,mouseX:i,mouseY:o,theme:a}=t,{gridY:r,gridX:c,maxX:h,modelRows:u,floatingTopHeight:m,floatingBottomHeight:g,floatingRows:p,rowFooterWidth:C,height:f,horizontalBarHeight:S,verticalBarWidth:v,allRowHeights:w,allRowYs:T,width:y}=n;if(C<=0||p.length===0)return;const{cellHorizontalPadding:E,floatingGridRowColor:D,floatingRowBackgroundColors:F,headerColor:N,rowHoverBackgroundColor:_}=a;e.translate(c,r),e.beginPath();const P=Math.min(h,y-C-v-c);e.fillStyle=F,m>0&&e.rect(P,0,C,m),g>0&&e.rect(P,f-r-S-g,C,g),e.fill();const U=i!=null&&o!=null&&i>=c&&i<=h+C?V.getRowAtY(o,n):null;if(_!=null&&U!==null&&p.includes(U)){e.fillStyle=_;const j=T.get(U),k=w.get(U);M(j),M(k),e.fillRect(P,j,C,k)}if(e.beginPath(),D!=null&&(e.strokeStyle=D),m>0&&(e.moveTo(P+.5,.5),e.lineTo(P+.5,m-.5)),g>0){const j=f-r-S-g;e.moveTo(P-.5,j+.5),e.lineTo(P-.5,j+g-.5)}e.stroke(),e.fillStyle=N,e.textAlign="left";const O=P+E;for(let j=0;j<p.length;j+=1){const k=p[j],A=w.get(k),H=T.get(k),K=u.get(k);if(H!=null&&A!=null&&K!=null){const q=H+A*.5;e.fillText(s.textForRowFooter(K),O,q)}}e.translate(-c,-r)}getTextRenderMetrics(e,t,n){const s=super.getTextRenderMetrics(e,t,n),{mouseX:i,mouseY:o,metrics:a}=e;if(i==null||o==null)return s;const{column:r,row:c}=V.getGridPointFromXY(i,o,a);if(t===r&&n===c){const{left:h}=this.getCellOverflowButtonPosition(e);this.shouldRenderOverflowButton(e)&&h!=null&&(s.width=h-a.gridX-s.x)}return s}shouldRenderOverflowButton(e){const{context:t,mouseX:n,mouseY:s,metrics:i,model:o,theme:a}=e;if(n==null||s==null)return!1;const{row:r,column:c,modelRow:h,modelColumn:u}=V.getCellInfoFromXY(n,s,i);if(r==null||c==null||h==null||u==null||!x.isStringType(o.columns[u].type))return!1;const m=o.textForCell(u,h)??"",{width:g}=super.getTextRenderMetrics(e,c,r),p=i.fontWidths.get(a.font)??Eo.DEFAULT_FONT_WIDTH;t.save(),t.font=a.font;const C=this.getCachedTruncatedString(t,m,g,p,o.truncationCharForCell(u,h));return t.restore(),m!==""&&C!==m}getCellOverflowButtonPosition({mouseX:e,mouseY:t,metrics:n,theme:s}){const i={left:null,top:null,width:null,height:null};if(e==null||t==null||n==null)return i;const{rowHeight:o,columnWidth:a,left:r,top:c}=V.getCellInfoFromXY(e,t,n);if(r==null||a==null||c==null)return i;const{width:h,verticalBarWidth:u}=n,{cellHorizontalPadding:m}=s,g=zr+2*m,p=o,f=Math.min(n.gridX+r+a,h-u)-g,S=n.gridY+c;return{left:f,top:S,width:g,height:p}}drawCellOverflowButton(e){const{context:t,mouseX:n,mouseY:s,theme:i}=e;if(n==null||s==null||!this.shouldRenderOverflowButton(e))return;const{left:o,top:a,width:r,height:c}=this.getCellOverflowButtonPosition(e),{cellHorizontalPadding:h,overflowButtonColor:u,overflowButtonHoverColor:m}=i;t.save(),m!=null&&o!=null&&r!=null&&a!=null&&c!=null&&n>=o&&n<=o+r&&s>=a&&s<=a+c?t.fillStyle=m:u!=null&&(t.fillStyle=u);const g=this.getIcon(Dn.CELL_OVERFLOW);o!=null&&a!=null&&t.translate(o+h,a+2),t.fill(g),t.restore()}getExpandButtonPosition({mouseX:e,mouseY:t,metrics:n,theme:s},i){const o={left:null,top:null,width:null,height:null};if(e==null||t==null||i==null||!n)return o;const{rowHeight:a,left:r,top:c}=V.getCellInfoFromXY(e,t,n);M(r),M(a),M(c);const{cellHorizontalPadding:h}=s,u=Hd+2*h,m=Math.max(r+Hd*i,n.gridX),g=n.gridY+c;return{left:m,top:g,width:u,height:a}}}const VT=Eo,BT="12px Fira Sans, sans-serif",UT="#f0f0ee",$T="#1a171a",le={"grid-bg":"#211f22",font:BT,white:UT,black:$T,"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","hyperlink-color":"#4878ea","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"},WT=Object.freeze({backgroundColor:le["grid-bg"],white:le.white,black:le.black,font:le.font,headerBackgroundColor:le["header-bg"],headerColor:le["header-color"],headerSeparatorColor:le["header-separator-color"],headerSeparatorHoverColor:le["header-separator-hover-color"],headerHiddenSeparatorHoverColor:le["header-hidden-separator-hover-color"],headerSortBarColor:le["header-sort-bar-color"],headerReverseBarColor:le["header-reverse-bar-color"],headerBarCasingColor:le["header-bar-casing-color"],headerFont:le["header-font"],rowBackgroundColors:le["row-background-colors"],rowHoverBackgroundColor:le["row-hover-bg"],selectionColor:le["selection-color"],selectionOutlineColor:le["selection-outline-color"],selectionOutlineCasingColor:le["selection-outline-casing-color"],selectedRowHoverBackgroundColor:le["selected-row-hover-bg"],scrollBarBackgroundColor:le["scroll-bar-bg"],scrollBarHoverBackgroundColor:le["scroll-bar-hover-bg"],scrollBarCasingColor:le["scroll-bar-casing-color"],scrollBarCornerColor:le["scroll-bar-corner-color"],scrollBarColor:le["scroll-bar-color"],scrollBarHoverColor:le["scroll-bar-hover-color"],scrollBarActiveColor:le["scroll-bar-active-color"],scrollBarSelectionTickColor:le["selected-row-hover-bg"],scrollBarActiveSelectionTickColor:le["scroll-bar-active-selection-tick-color"],textColor:le["text-color"],hyperlinkColor:le["hyperlink-color"],positiveNumberColor:le["positive-number-color"],negativeNumberColor:le["negative-number-color"],zeroNumberColor:le["zero-number-color"],dateColor:le["date-color"],pendingTextColor:le["pending-text-color"],errorTextColor:le["error-text-color"],nullStringColor:le["null-string-color"],filterBarActiveBackgroundColor:le["filter-bar-active-bg"],filterBarExpandedBackgroundColor:le["filter-bar-expanded-bg"],filterBarExpandedActiveBackgroundColor:le["filter-bar-expanded-active-bg"],filterBarExpandedActiveCellBackgroundColor:le["filter-bar-expanded-active-cell-bg"],filterBarSeparatorColor:le["filter-bar-separator-color"],filterBarActiveColor:le["filter-bar-active-color"],filterBarErrorColor:le["filter-bar-error-color"],filterIconColor:le["filter-icon-color"],scrimColor:le["scrim-color"],contextMenuSortIconColor:le["context-menu-sort-icon-color"],contextMenuReverseIconColor:le["context-menu-reverse-icon-color"],allowRowResize:!1,autoSelectRow:!0,gridColumnColor:null,gridRowColor:null,groupedColumnDividerColor:le["grouped-column-divider-color"],columnHoverBackgroundColor:null,headerHorizontalPadding:12,scrollBarSize:13,scrollBarHoverSize:16,minScrollHandleSize:24,rowHeight:parseInt(le["row-height"],10)||19,columnWidth:100,rowHeaderWidth:0,rowFooterWidth:60,columnHeaderHeight:parseInt(le["header-height"],10)||30,filterBarHeight:30,filterBarCollapsedHeight:5,sortHeaderBarHeight:2,reverseHeaderBarHeight:4,filterBarHorizontalPadding:4,scrimBlurSize:25,minScrimTransitionTime:150,maxScrimTransitionTime:350,scrollSnapToRow:!0,linkerColumnHoverBackgroundColor:le["linker-column-hover-bg"],treeLineColor:le["tree-line-color"],treeMarkerColor:le["tree-marker-color"],treeMarkerHoverColor:le["tree-marker-hover-color"],floatingGridColumnColor:null,floatingGridRowColor:le["floating-grid-row-color"],floatingRowBackgroundColors:le["floating-row-background-colors"],floatingDividerInnerColor:le["floating-divider-inner-color"],floatingDividerOuterColor:le["floating-divider-outer-color"],overflowButtonColor:le["overflow-button-color"],overflowButtonHoverColor:le["overflow-button-hover-color"]}),Vd=WT;const Kr=Z.module("ColumnStatistics"),GT={SIZE:"Number of Rows"};class Wa extends b.Component{static AUTO_GENERATE_LIMIT=1e5;static getStatsLabel(e){return GT[e]??e.split(" ").map(t=>t[0].toUpperCase()+t.substr(1).toLowerCase()).join(" ")}constructor(e){super(e),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}}componentDidMount(){this.maybeGenerateStatistics()}componentWillUnmount(){this.cancelablePromise&&this.cancelablePromise.cancel()}cancelablePromise;maybeGenerateStatistics(){const{model:e}=this.props,t=e.rowCount-e.pendingRowCount;this.setState({numRows:t}),e.isColumnStatisticsAvailable?t<Wa.AUTO_GENERATE_LIMIT&&this.handleGenerateStatistics():this.setState({loading:!1})}handleGenerateStatistics(){this.setState({loading:!0});const{column:e,model:t}=this.props;this.cancelablePromise=ve.makeCancelable(t.columnStatistics(e)),this.cancelablePromise.then(this.handleStatistics).catch(this.handleError)}handleStatistics(e){Kr.debug("Received statistics",e);const{model:t,onStatistics:n}=this.props,s=[];e.statisticsMap.forEach((i,o)=>{s.push({operation:Wa.getStatsLabel(o),value:i,type:e.getType(o)})}),e.uniqueValues.forEach((i,o)=>{s.push({operation:o,className:"column-statistics-unique-value",value:i,type:"long"})}),this.setState({loading:!1,statistics:s,numRows:t.rowCount-t.pendingRowCount}),n()}handleError(e){if(e!=null&&ve.isCanceled(e)){Kr.debug("Called handleError on a cancelled promise result");return}Kr.error("Error generating statistics",e),this.setState({error:e,loading:!1,statistics:null})}render(){const{column:e,model:t}=this.props,{error:n,loading:s,statistics:i,numRows:o}=this.state,a=!s&&n==null&&i==null&&t.isColumnStatisticsAvailable,r=[],c=e.type.substring(e.type.lastIndexOf(".")+1),h=e.description===null?null:e.description;if(i!=null)for(let p=0;p<i.length;p+=1){const{operation:C,className:f,value:S,type:v}=i[p],w=v?t.displayString(S,v):t.displayString(S,e.type,e.name),T=l.jsxs(J.Fragment,{children:[l.jsx("div",{className:$("column-statistic-operation",f),children:C}),l.jsx("div",{className:"column-statistic-value",children:w})]},C);r.push(T)}const u=qe(t)&&t.hasExpandableRows?"Expanded Rows":"Number of Rows",m=t.displayString(o,"long"),g=t.getColumnIndexByName(e.name);return l.jsxs("div",{className:"column-statistics",children:[l.jsxs("div",{className:"column-statistics-title",children:[e.name,l.jsxs("span",{className:"column-statistics-type",children:[" (",c,")"]}),l.jsx(dr,{className:"column-statistics-copy",tooltip:"Copy column name",copy:e.name})]}),h!=null&&l.jsx("div",{className:"column-statistics-description",children:h}),g!=null&&!t.isColumnMovable(g)&&l.jsxs("div",{className:"column-statistics-status",children:[l.jsx(Q,{icon:t.isColumnFrozen(g)?$g:Wg,className:"mr-1"}),t.isColumnFrozen(g)?"Frozen":"Not movable"]}),l.jsxs("div",{className:"column-statistics-grid",children:[i==null&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"column-statistic-operation",children:u}),l.jsx("div",{className:"column-statistic-value",children:m})]}),r]}),a&&l.jsx(B,{kind:"ghost",className:"px-0",onClick:this.handleGenerateStatistics,children:"Generate Stats"}),n!=null&&l.jsx("div",{className:"error-message",children:`${n}`}),i&&!s&&l.jsx(B,{kind:"ghost",className:"px-0",onClick:this.handleGenerateStatistics,icon:l.jsx(Q,{icon:Ol,className:"mr-1"}),children:"Refresh"}),s&&l.jsxs("div",{className:"column-statistics-loading",children:[l.jsx(yn,{className:"mr-2"}),"Calculating Stats..."]})]})}}const zT=Wa;const da=Z.module("AdvancedFilterCreatorFilterItem");class mc extends b.PureComponent{static getLabelForFilter(e,t){try{if(x.isNumberType(e)||x.isCharType(e))return iu(t);if(x.isTextType(e))return su(t);if(x.isDateType(e))return ou(t);if(x.isBooleanType(e))return IS(t);throw new Error(`Unrecognized column type: ${e}`)}catch(n){return da.warn(n),""}}constructor(e){super(e),this.handleDelete=this.handleDelete.bind(this),this.handleTypeChange=this.handleTypeChange.bind(this),this.handleValueChange=this.handleValueChange.bind(this),this.typeDropdown=null;const{value:t="",filterTypes:n,selectedType:s=n[0]}=e;this.state={selectedType:s,value:t}}componentDidMount(){this.typeDropdown?.focus()}componentDidUpdate(e){const{value:t,selectedType:n}=this.props;n!==void 0&&e.selectedType!==n&&this.setState({selectedType:n}),t!==void 0&&e.value!==t&&this.setState({value:t})}typeDropdown;handleTypeChange(e){const t=e.target.value;da.debug2("typeChange",t),this.setState({selectedType:t});const{onChange:n}=this.props,{value:s}=this.state;s!=null&&s.length>0&&n(t,s)}handleValueChange(e){da.debug2("valueChange");const{value:t}=e.target;this.setState({value:t});const{onChange:n}=this.props,{selectedType:s}=this.state;s!=null&&n(s,t)}handleDelete(){da.debug("delete");const{onDelete:e}=this.props;e()}getCachedIsValid=fe((e,t,n,s)=>{try{return!n||x.makeAdvancedValueFilter(e,t,n,s)!=null}catch{return!1}});render(){const{column:e,filterTypes:t,formatter:n}=this.props,{selectedType:s,value:i}=this.state,o=!x.isBooleanType(e.type),a=[],r=this.getCachedIsValid(e,s,i,n.timeZone);for(let c=0;c<t.length;c+=1){const h=t[c],u=mc.getLabelForFilter(e.type,h),m=l.jsx("option",{value:h,children:u},h);a.push(m)}return l.jsx("div",{className:"advanced-filter-creator-filter-item",children:l.jsxs("div",{className:"form-row",children:[l.jsx("div",{className:"form-group col",children:l.jsx("select",{className:"form-control custom-select",value:s,onChange:this.handleTypeChange,ref:c=>{this.typeDropdown=c},children:a})}),o&&l.jsx("div",{className:"form-group col",children:l.jsx("div",{className:"input-group",children:l.jsx("input",{type:"text",className:$("form-control",{error:!r}),placeholder:"Enter value",value:i,onChange:this.handleValueChange})})}),l.jsx("div",{className:"form-group col-1 px-0",children:l.jsx(B,{kind:"ghost",className:"w-100 h-100 p-0 m-0",onClick:this.handleDelete,icon:Jt,tooltip:"Remove Filter"})})]})})}}const KT=mc,Bd=Z.module("AdvancedFilterCreatorSelectValueList");class Ga extends b.PureComponent{static defaultProps={invertSelection:!0,selectedValues:[],onChange:()=>{}};static indexOf(e,t){for(let n=0;n<t.length;n+=1){const s=t[n];if(s===e||s!=null&&s.valueOf!=null&&e!=null&&e.valueOf!=null&&s.valueOf()===e.valueOf())return n}return-1}constructor(e){super(e),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:t}=this.props;this.state={itemCount:0,items:[],offset:0,selectedValues:t,isLoading:!0}}componentDidMount(){const{table:e}=this.props;e&&this.startListening(e)}componentDidUpdate(e){const{filters:t,invertSelection:n,selectedValues:s,table:i}=this.props;e.table!==i&&(e.table&&this.stopListening(e.table),i&&this.startListening(i),this.resetViewport()),e.invertSelection!==n&&this.setState({selectedValues:[]},this.handleSelectionUpdate),e.selectedValues!==s&&this.setState({selectedValues:s},this.handleSelectionUpdate),e.filters!==t&&(i?.applyFilter(t),this.resetViewport())}componentWillUnmount(){const{table:e}=this.props;e&&this.stopListening(e)}list;handleSelect(e,t){const{invertSelection:n}=this.props;let{selectedValues:s}=this.state;s=[...s];const i=Ga.indexOf(t,s);i>=0?s.splice(i,1):s.push(t);let o=i<0;n&&(o=!o);const{offset:a}=this.state;let{items:r}=this.state;r=[...r];const c=e-a;c>=0&&c<r.length&&(r[c].isSelected=o),this.setState({items:r,selectedValues:s});const{onChange:h}=this.props;h(s,n)}handleViewportChange(e,t){this.updateViewport(e,t)}handleSelectionUpdate(){this.updateItemSelection()}handleTableUpdate(e){const{table:t,formatter:n}=this.props;if(!t)return;const s=e.detail,{offset:i}=s,o=[],a=t.columns[0];for(let c=0;c<s.rows.length;c+=1){const u=s.rows[c].get(a),m=n.getFormattedString(u,a.type,a.name),g=this.isValueSelected(u);o.push({displayValue:m,value:u,isSelected:g})}Bd.debug2("Received table update:",i,o.length);const r=t.size;this.setState({itemCount:r,items:o,offset:i,isLoading:!1})}isValueSelected(e){const{invertSelection:t}=this.props,{selectedValues:n}=this.state,s=Ga.indexOf(e,n);return t?s<0:s>=0}startListening(e){e.addEventListener(R.Table.EVENT_UPDATED,this.handleTableUpdate)}stopListening(e){e.removeEventListener(R.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:e}=this.state;e=[...e];for(let t=0;t<e.length;t+=1){const n=e[t],{value:s}=n;n.isSelected=this.isValueSelected(s)}this.setState({items:e})}updateViewport(e,t,n=!1){const{table:s}=this.props;if(s==null)return;n&&this.setState({isLoading:!0});const i=t-e+1,o=Math.max(0,e-i*3),a=Math.max(o,t+i*3);Bd.debug2("Setting viewport",o,",",a),s.setViewport(o,a)}render(){const{offset:e,isLoading:t,items:n,itemCount:s}=this.state;return l.jsxs("div",{className:"select-value-list-wrapper",children:[l.jsx(Bf,{itemCount:s,items:n,offset:e,onSelect:this.handleSelect,onViewportChange:this.handleViewportChange,ref:i=>{this.list=i}}),l.jsx(ft,{in:t,timeout:250,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:l.jsx("div",{className:"loading-list",children:l.jsx(yn,{className:"loading-spinner-large"})})})]})}}const qT=Ga;class gc extends b.PureComponent{static searchDebounceTime=250;static defaultProps={invertSelection:!0,selectedValues:[],onChange:()=>{},showSearch:!0};constructor(e){super(e),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:t,selectedValues:n}=e;this.state={filters:[],invertSelection:t,selectedValues:n,searchText:""}}componentDidMount(){this.initSearchTable()}componentDidUpdate(e,t){const{invertSelection:n,selectedValues:s,table:i}=this.props;e.table!==i&&this.initSearchTable(),e.invertSelection!==n&&this.setState({invertSelection:n}),e.selectedValues!==s&&this.setState({selectedValues:s});const{table:o,searchText:a}=this.state;o!==t.table&&(t.table!=null&&t.table.close(),o!=null&&this.startUpdateFilterTimer()),a!==t.searchText&&this.startUpdateFilterTimer()}componentWillUnmount(){const{table:e}=this.state;e?.close(),this.searchTablePromise=void 0,this.stopUpdateFilterTimer()}searchTablePromise;updateFilterTimer;getColumnName(){const{table:e}=this.props;return e!=null?e.columns[0].name:""}getDisplayedValuesCount(){const{invertSelection:e,selectedValues:t,table:n}=this.state;return n==null?null:e?n.totalSize-t.length:t.length}getDisplayedValueText(){const e=this.getDisplayedValuesCount(),{table:t}=this.state,{formatter:n}=this.props;if(e!=null&&t!=null){const s=n.getFormattedString(e,"long"),i=n.getFormattedString(t.totalSize,"long");let o="";return e<1e6&&(o="Displaying "),`${o}${s} of ${i}`}return null}initSearchTable(){const{table:e}=this.props;if(e==null)return;const t=e.copy();this.searchTablePromise=t,this.searchTablePromise.then(n=>{this.searchTablePromise===t?(this.setState({table:n}),this.searchTablePromise=void 0):n.close()})}handleListChange(e,t){this.setState({selectedValues:e,invertSelection:t});const{onChange:n}=this.props;n(e,t)}handleSearchChange(e){const t=e.target.value;this.setState({searchText:t})}handleSelectAllClick(){this.resetSelection(!0)}handleClearAllClick(){this.resetSelection(!1)}handleUpdateFilterTimeout(){this.updateFilterTimer=void 0,this.updateTableFilter()}resetSelection(e){const t=[];this.setState({invertSelection:e,selectedValues:t});const{onChange:n}=this.props;n(t,e)}startUpdateFilterTimer(){this.stopUpdateFilterTimer(),this.updateFilterTimer=setTimeout(this.handleUpdateFilterTimeout,gc.searchDebounceTime)}stopUpdateFilterTimer(){this.updateFilterTimer!=null&&(clearTimeout(this.updateFilterTimer),this.updateFilterTimer=void 0)}updateTableFilter(){const{table:e,searchText:t}=this.state,{timeZone:n}=this.props,s=e?.columns[0],i=[];if(s==null)return;let o;if(t.length>0){let a=null;x.isCharType(s.type)?a=x.makeQuickFilter(s,t):x.isTextType(s.type)?a=x.makeQuickFilter(s,`~${t}`,n):a=x.makeQuickFilter(s,`>=${t}`,n),a!=null?i.push(a):o="Invalid search text"}this.setState({filters:i,error:o})}render(){const{error:e,filters:t,invertSelection:n,selectedValues:s,searchText:i,table:o}=this.state,{formatter:a,showSearch:r}=this.props,c=this.getColumnName(),h=this.getDisplayedValueText(),u=c?`Find ${c}...`:"";return l.jsxs("div",{className:"advanced-filter-creator-select-value",children:[l.jsxs("div",{className:r?"form-group":"",children:[l.jsx("label",{htmlFor:"advanced-filter-creator-select-value-input",children:"Select Values"}),r&&l.jsx("input",{type:"text",className:$("form-control",{"is-invalid":e!=null}),id:"advanced-filter-creator-select-value-input",placeholder:u,value:i,onChange:this.handleSearchChange})]}),l.jsx(qT,{table:o,filters:t,invertSelection:n,selectedValues:s,formatter:a,onChange:this.handleListChange}),l.jsxs("div",{className:"advanced-filter-creator-select-meta-row",children:[l.jsxs("div",{children:[l.jsx(B,{kind:"ghost",onClick:this.handleSelectAllClick,children:"Select All"}),l.jsx(B,{kind:"ghost",onClick:this.handleClearAllClick,children:"Clear"})]}),l.jsx(ft,{in:h!=null,timeout:250,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:l.jsx("div",{className:"row-count-info",children:h})})]})]})}}const YT=gc;const co=Z.module("AdvancedFilterCreator");class ys extends b.PureComponent{static debounceFilterUpdate=250;static defaultProps={options:{filterItems:null,filterOperators:null,invertSelection:!0,selectedValues:[]},sortDirection:null};static makeFilterItem(){return{key:_e()}}constructor(e){super(e),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=J.createRef();const{options:t}=e;let{filterOperators:n,invertSelection:s,selectedValues:i}=t;const o=t.filterItems?.map(({selectedType:a,value:r})=>({selectedType:a,value:r,key:_e()}))??[];o.length===0&&o.push(ys.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}}componentDidMount(){this.initValuesTable()}componentWillUnmount(){this.debounceTimeout!=null&&(clearTimeout(this.debounceTimeout),this.sendUpdate()),this.valuesTablePromise!=null&&this.valuesTablePromise.cancel()}focusTrapContainer;debounceTimeout;valuesTablePromise;getFilterChangeHandler(e){return this.handleFilterChange.bind(this,e)}getFilterDeleteHandler(e){return this.handleFilterDelete.bind(this,e)}getFilterTypes=fe(e=>x.getFilterTypes(e));initValuesTable(){const{model:e,column:t}=this.props;if(!e.isValuesTableAvailable){co.debug("No values table for this model, just ignore");return}this.valuesTablePromise=x.makeCancelableTablePromise(e.valuesTable(t)),this.valuesTablePromise.then(n=>{const s=n.columns[0].sort().asc();n.applySort([s]),this.setState({valuesTable:n})}).catch(n=>{ve.isCanceled(n)||(co.error("Unable to open values table",n),this.setState({valuesTableError:n}))})}handleFocusTrapEnd(){(this.focusTrapContainer?.current?.querySelector("button,select,input,textarea")).focus()}handleFocusTrapStart(){const e=this.focusTrapContainer?.current?.querySelectorAll("button,select,input,textarea");e&&e.length>0&&e[e.length-1].focus()}handleAddAnd(){let{filterItems:e,filterOperators:t}=this.state;e=e.concat(ys.makeFilterItem()),t=t.concat(wn.and),this.setState({filterItems:e,filterOperators:t})}handleAddOr(){let{filterItems:e,filterOperators:t}=this.state;e=e.concat(ys.makeFilterItem()),t=t.concat(wn.or),this.setState({filterItems:e,filterOperators:t})}handleChangeFilterOperator(e,t){let{filterOperators:n}=this.state;n=[...n],xS(t),n[e]=t,this.setState({filterOperators:n}),this.startUpdateTimer()}handleFilterChange(e,t,n){let{filterItems:s}=this.state;s=[...s];const{key:i}=s[e];s[e]={key:i,selectedType:t,value:n},this.setState({filterItems:s}),this.startUpdateTimer()}handleFilterDelete(e){let{filterItems:t,filterOperators:n}=this.state;t=[...t],n=[...n],e<t.length&&t.splice(e,1),e<n.length?n.splice(e,1):e===n.length&&n.splice(n.length-1,1),t.length===0&&t.push(ys.makeFilterItem()),this.setState({filterItems:t,filterOperators:n}),this.startUpdateTimer()}handleSelectValueChange(e,t){this.setState({selectedValues:e,invertSelection:t}),this.startUpdateTimer()}handleReset(){co.debug("Resetting Advanced Filter"),this.setState({filterItems:[ys.makeFilterItem()],filterOperators:[],selectedValues:[],invertSelection:!0}),this.startUpdateTimer()}handleSortDown(e){const t=Ve.isModifierKeyDown(e);this.sortTable(x.sortDirection.descending,t)}handleSortUp(e){const t=Ve.isModifierKeyDown(e);this.sortTable(x.sortDirection.ascending,t)}handleSubmit(e){co.debug("Submitting Advanced Filter"),this.stopUpdateTimer(),this.sendUpdate(),e.preventDefault()}handleDone(e){co.debug("Submitting and Closing Advanced Filter"),this.stopUpdateTimer(),this.sendUpdate();const{onDone:t}=this.props;t(),e.preventDefault()}handleUpdateTimeout(){this.debounceTimeout=void 0,this.sendUpdate()}shouldShowAddFilter(){const{filterItems:e}=this.state;if(e.length===0)return!1;const t=e[e.length-1],{selectedType:n,value:s}=t;return n!=null&&n.length>0&&s!=null&&s.length>0}sortTable(e,t=!1){const{column:n,onSortChange:s}=this.props;s(n,e,t)}startUpdateTimer(){this.stopUpdateTimer(),this.debounceTimeout=setTimeout(this.handleUpdateTimeout,ys.debounceFilterUpdate)}stopUpdateTimer(){this.debounceTimeout!==void 0&&(clearTimeout(this.debounceTimeout),this.debounceTimeout=void 0)}sendUpdate(){const{filterItems:e,filterOperators:t,invertSelection:n,selectedValues:s}=this.state,{column:i,onFilterChange:o,model:a}=this.props,{formatter:r}=a,c=e.filter(({selectedType:g,value:p})=>g!=null&&p!=null&&p!==""),h=t.filter((g,p)=>g!=null&&e[p].selectedType!=null&&e[p].value!=null&&e[p].value!=="").slice(0,c.length-1),u={filterItems:c,filterOperators:h,invertSelection:n,selectedValues:s},m=x.makeAdvancedFilter(i,u,r.timeZone);o(i,m,u)}render(){const{column:e,model:t,sortDirection:n,formatter:s}=this.props,{filterItems:i,filterOperators:o,invertSelection:a,selectedValues:r,valuesTable:c,valuesTableError:h}=this.state,{isValuesTableAvailable:u}=t,m=x.isBooleanType(e.type),g=x.isDateType(e.type),p=this.getFilterTypes(e.type),C=e.type.substring(e.type.lastIndexOf(".")+1),f=[];if(!m&&p.length)for(let w=0;w<i.length;w+=1){const T=i[w],{key:y,selectedType:E,value:D}=T,F=l.jsx(KT,{column:e,filterTypes:p,onChange:this.getFilterChangeHandler(w),onDelete:this.getFilterDeleteHandler(w),selectedType:E,value:D,formatter:s},y);if(f.push(F),w<o.length){const _=o[w]===wn.and,P=l.jsxs("div",{className:"form-row justify-content-end advanced-filter-creator-filter-operator",children:[l.jsx(B,{kind:"ghost",className:$("filter-operator",{active:_}),onClick:()=>this.handleChangeFilterOperator(w,wn.and),children:"AND"}),l.jsx(B,{kind:"ghost",className:$("filter-operator",{active:!_}),onClick:()=>this.handleChangeFilterOperator(w,wn.or),children:"OR"})]},`filterOperator${y}`);f.push(P)}}const S=this.shouldShowAddFilter(),v=l.jsxs("div",{className:$("form-row justify-content-end add-filter-item",{hidden:!S}),children:[l.jsx("span",{className:"text-muted",children:l.jsx(Q,{icon:Ps})}),l.jsx(B,{kind:"ghost",className:"btn-filter-item",onClick:this.handleAddAnd,disabled:!S,tooltip:"Add filter with AND",children:"AND"}),l.jsx(B,{kind:"ghost",className:"btn-filter-item",onClick:this.handleAddOr,disabled:!S,tooltip:"Add filter with OR",children:"OR"})]},"addFilterItem");return f.push(v),l.jsxs("div",{className:"advanced-filter-creator",role:"presentation",children:[l.jsx("div",{tabIndex:0,onFocus:this.handleFocusTrapStart}),l.jsxs("form",{onSubmit:this.handleSubmit,ref:this.focusTrapContainer,children:[l.jsxs("div",{className:"title-bar",children:[l.jsx("h6",{className:"advanced-filter-title",children:"Advanced Filters"}),l.jsxs("div",{className:"advanced-filter-menu-buttons",children:[l.jsx(B,{kind:"ghost",className:$("sort-operator",{active:n===x.sortDirection.descending}),onClick:this.handleSortDown,icon:Uc,tooltip:`Sort ${e.name} Descending`}),l.jsx(B,{kind:"ghost",className:$("sort-operator",{active:n===x.sortDirection.ascending}),onClick:this.handleSortUp,icon:l.jsx(Q,{icon:Uc,rotation:180}),tooltip:`Sort ${e.name} Ascending`})]})]}),l.jsx("hr",{}),l.jsxs("div",{className:"advanced-filter-column-name",children:[e.name," ",l.jsxs("span",{className:"column-type",children:["(",C,")"]})]}),f,u&&h==null&&l.jsxs(l.Fragment,{children:[!m&&l.jsx("hr",{}),l.jsx("div",{className:"form-group",children:l.jsx(YT,{table:c,onChange:this.handleSelectValueChange,invertSelection:a,selectedValues:r,formatter:s,showSearch:!g,timeZone:s.timeZone})})]}),l.jsxs("div",{className:"form-row justify-content-end",children:[l.jsx(B,{kind:"secondary",className:"mr-2",onClick:this.handleReset,children:"Reset"}),l.jsx(B,{kind:"primary",onClick:this.handleDone,children:"Done"})]})]}),l.jsx("div",{tabIndex:0,onFocus:this.handleFocusTrapEnd})]})}}const XT=ys;const Ud=Z.module("Aggregations");function ZT({isRollup:d,settings:e,onChange:t,onEdit:n}){const{aggregations:s,showOnTop:i}=e,o=b.useMemo(()=>Wv.filter(N=>!s.some(_=>_.operation===N)),[s]),[a,r]=b.useState(o[0]),[c,h]=b.useState([]),u=b.useCallback(N=>{t({...e,...N})},[t,e]),m=b.useCallback(N=>{u({aggregations:N})},[u]),g=b.useCallback(N=>{u({showOnTop:N})},[u]),p=b.useCallback(()=>{Ud.debug("handleDragStart"),vn.startDragging()},[]),C=b.useCallback(({destination:N,source:_})=>{if(Ud.debug("handleDragEnd",N,_),vn.stopDragging(),N===null)return;let P=N.index;_.index<N.index&&(P+=1);const U=[...s],O=vn.reorder(U,c,U,P),j=vn.adjustDestinationIndex(P,c),k=[[j,j+O.length-1]];m(U),h(k)},[m,s,c,h]),f=b.useCallback(N=>{r(N)},[r]),S=b.useCallback(()=>{m([...s,{operation:a,selected:[],invert:!0}])},[s,a,m]),v=b.useCallback(N=>{m(s.filter((_,P)=>P!==N))},[s,m]),w=b.useCallback(N=>{h(N)},[h]),T=b.useCallback(N=>{const _=s[N];Fs.isRollupOperation(_.operation)||n(_)},[s,n]),y=b.useCallback(N=>{g(N.target.value==="true")},[g]);b.useEffect(function(){o.length>0&&!o.includes(a)&&r(o[0])},[o,a]);const E=b.useCallback(({item:N,itemIndex:_,isClone:P=!1,selectedCount:U})=>{const O=N.operation,j=P?`${U}`:void 0,k=P?"item-list-item-clone":void 0,A=Fs.isRollupOperation(N.operation),H=!P&&!A;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:$("item-list-item-content","draggable-item-list-item-content",k),children:[l.jsxs("span",{className:"title",children:[O,!d&&A&&l.jsxs("span",{className:"small text-warning",children:[l.jsx(Q,{icon:Oh})," Requires rollup"]})]}),Cn.renderBadge({text:j}),Cn.renderHandle()]}),!P&&l.jsxs(l.Fragment,{children:[l.jsx(B,{kind:"ghost",className:"btn-edit",icon:Ao,tooltip:"Edit Columns",onClick:()=>n(N),disabled:!H}),l.jsx(B,{kind:"ghost",className:"btn-delete",icon:Jt,tooltip:"Delete Aggregation",onClick:()=>v(_)})]})]})},[v,n,d]),D=o.length>0,F=s.length>0;return l.jsxs("div",{className:"aggregations",children:[D&&l.jsxs("div",{className:"form-inline",children:[l.jsx(Hf,{onChange:f,value:a,children:o.map(N=>l.jsx(jf,{value:N,children:N},N))}),l.jsxs("button",{type:"button",className:"btn btn-link btn-add",onClick:S,children:[l.jsx(Q,{icon:Ps}),"Add Aggregation"]})]}),D&&F&&l.jsx("hr",{}),F&&l.jsxs(l.Fragment,{children:[!d&&l.jsxs("div",{className:"form-inline",children:[l.jsx("label",{children:"Placement: "}),l.jsxs(hr,{onChange:y,value:`${i}`,children:[l.jsx(ts,{value:"true",children:"Top"}),l.jsx(ts,{value:"false",children:"Bottom"})]})]}),l.jsx(nr,{onDragStart:p,onDragEnd:C,children:l.jsx(Cn,{className:"selected-aggregations",itemCount:s.length,items:s,renderItem:E,offset:0,onSelectionChange:w,onSelect:T,selectedRanges:c,isMultiSelect:!0})})]})]})}const QT=30;function JT({aggregation:d,columns:e,onChange:t}){const[n,s]=b.useState(-1),[i,o]=b.useState(-1),[a,r]=b.useState(0),{invert:c,selected:h}=d,u=b.useRef(null),m=b.useCallback(y=>h.includes(y)?!c:c,[c,h]),g=b.useMemo(()=>{let y=hc(e,d.operation);return a!==0&&(y=x.sortColumns(y,a===1)),y},[e,d.operation,a]),p=b.useMemo(()=>n>=0?g.slice(n,i+1).map(y=>({value:y.name,displayValue:y.name,isSelected:m(y.name)})):[],[g,m,i,n]),C=b.useCallback(y=>{const{name:E}=g[y],D=h.indexOf(E);let F=[...h],N=c;D>=0?F.splice(D,1):(F.push(E),F.length===g.length&&(F=[],N=!c)),t({...d,selected:F,invert:N})},[d,c,g,h,t]),f=b.useCallback(()=>{r(0),t({...d,selected:[],invert:!0})},[d,t]),S=b.useCallback((y,E)=>{s(y),o(E)},[s,o]),v=b.useCallback(()=>{h.length===0?t({...d,invert:!c}):t({...d,selected:[],invert:!0})},[d,c,t,h]),w=h.length===0?c:null,T=h.length!==0||!c||a!==0;return l.jsxs("div",{role:"menu",className:"aggregation-edit",children:[l.jsx("div",{className:"top-menu",children:l.jsxs("div",{className:"form-inline",children:[l.jsx(Zt,{checked:w,onChange:v,children:"Toggle All"}),l.jsx("div",{className:"spacer"}),l.jsx(ft,{in:T,timeout:ze.transitionSlowMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:l.jsx(B,{kind:"ghost",className:"btn-reset",onClick:f,children:"Reset"})}),l.jsx(B,{kind:"ghost",className:$({active:a===1}),icon:Al,tooltip:"Sort ascending",onClick:()=>r(1)}),l.jsx(B,{kind:"ghost",className:$({active:a===2}),icon:Ll,tooltip:"Sort descending",onClick:()=>r(2)})]})}),l.jsx("div",{className:"aggregation-edit-item-list",children:l.jsx(Bt,{itemCount:g.length,items:p,offset:n,renderItem:({item:y})=>l.jsx(Zt,{checked:m(y.value),children:y.displayValue}),onSelect:C,onViewportChange:S,rowHeight:QT,focusSelector:"input",ref:u})})]})}function eE(d){return l.jsx("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...d,children:l.jsxs("g",{fill:"none",fillRule:"evenodd",children:[l.jsx("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),l.jsx("path",{fill:"#7DA4FF",d:"M8 26h4v15H8zM15 17h4v24h-4zM22 21h4v20h-4zM29 17h4v24h-4zM36 11h4v30h-4z"})]})})}function tE(d){return l.jsx("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...d,children:l.jsxs("g",{fill:"none",fillRule:"evenodd",children:[l.jsx("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),l.jsx("path",{fill:"#7DA4FF",d:"M7 34h4v8H7zM12 31h4v11h-4zM17 27h4v15h-4zM22 22h4v20h-4zM27 27h4v15h-4zM32 29h4v13h-4zM37 31h4v11h-4z"})]})})}function nE(d){return l.jsx("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...d,children:l.jsxs("g",{fill:"none",fillRule:"evenodd",children:[l.jsx("path",{fill:"#C1C0C0",d:"M4 4h1v40H4zM44 43v1H5v-1z"}),l.jsx("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"}),l.jsx("path",{stroke:"#BECDEF",d:"M8.244 37.926L17 33.496l5 .87 10.637-10.35 10.615-1.381"})]})})}function sE(d){return l.jsx("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...d,children:l.jsxs("g",{fill:"none",fillRule:"evenodd",children:[l.jsx("path",{d:"M24 10c7.732 0 14 6.268 14 14s-6.268 14-14 14-14-6.268-14-14h14V10z",fill:"#80A6FF"}),l.jsx("path",{d:"M10 24c0-7.732 6.268-14 14-14v14H10z",fill:"#C1C0C0"})]})})}function iE(d){return l.jsx("svg",{width:48,height:48,xmlns:"http://www.w3.org/2000/svg",...d,children:l.jsxs("g",{fill:"none",fillRule:"evenodd",children:[l.jsx("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),l.jsx("path",{fill:"#939293",d:"M44 34v1H4v-1zM44 25v1H4v-1zM44 16v1H4v-1z"}),l.jsx("circle",{fill:"#7DA4FF",cx:9.5,cy:37.5,r:1.5}),l.jsx("circle",{fill:"#7DA4FF",cx:16.5,cy:30.5,r:1.5}),l.jsx("circle",{fill:"#7DA4FF",cx:22.5,cy:36.5,r:1.5}),l.jsx("circle",{fill:"#7DA4FF",cx:28.5,cy:30.5,r:1.5}),l.jsx("circle",{fill:"#7DA4FF",cx:15.5,cy:38.5,r:1.5}),l.jsx("circle",{fill:"#7DA4FF",cx:23.5,cy:25.5,r:1.5}),l.jsx("circle",{fill:"#7DA4FF",cx:19.5,cy:19.5,r:1.5}),l.jsx("circle",{fill:"#7DA4FF",cx:29.5,cy:19.5,r:1.5}),l.jsx("circle",{fill:"#7DA4FF",cx:32.5,cy:26.5,r:1.5}),l.jsx("circle",{fill:"#7DA4FF",cx:36.5,cy:13.5,r:1.5})]})})}function oE(d){return l.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",...d,children:[l.jsx("rect",{width:"48",height:"48",fill:"none"}),l.jsx("rect",{x:"26",y:"10",width:"15",height:"4",fill:"#9FDE70"}),l.jsx("rect",{x:"26",y:"22",width:"15",height:"4",fill:"#9FDE70"}),l.jsx("rect",{x:"26",y:"28",width:"15",height:"4",fill:"#FFD95C"}),l.jsx("rect",{x:"26",y:"34",width:"15",height:"4",fill:"#9FDE70"})]})}function aE(d){return l.jsxs("svg",{width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg",...d,children:[l.jsx("rect",{width:"48",height:"48",fill:"none"}),l.jsx("rect",{x:"4",y:"16",width:"40",height:"4",fill:"#FFD95C"}),l.jsx("rect",{x:"4",y:"10",width:"40",height:"4",fill:"#78DCE8"}),l.jsx("rect",{x:"4",y:"34",width:"40",height:"4",fill:"#78DCE8"})]})}const $d=Z.module("ChartBuilder");class ht extends b.PureComponent{static types=[R.plot.SeriesPlotStyle.LINE,R.plot.SeriesPlotStyle.BAR,R.plot.SeriesPlotStyle.SCATTER,R.plot.SeriesPlotStyle.PIE];static getTypeName(e){switch(e){case R.plot.SeriesPlotStyle.LINE:return"Line";case R.plot.SeriesPlotStyle.BAR:return"Bar";case R.plot.SeriesPlotStyle.SCATTER:return"Scatter";case R.plot.SeriesPlotStyle.PIE:return"Pie";case R.plot.SeriesPlotStyle.HISTOGRAM:return"Histogram";default:return e}}static getTypeIcon(e){switch(e){case R.plot.SeriesPlotStyle.LINE:return l.jsx(nE,{});case R.plot.SeriesPlotStyle.BAR:return l.jsx(eE,{});case R.plot.SeriesPlotStyle.SCATTER:return l.jsx(iE,{});case R.plot.SeriesPlotStyle.PIE:return l.jsx(sE,{});case R.plot.SeriesPlotStyle.HISTOGRAM:return l.jsx(tE,{});default:return null}}static getMaxSeriesCount(e){switch(e){case R.plot.SeriesPlotStyle.PIE:return 1;case R.plot.SeriesPlotStyle.HISTOGRAM:return 0;default:return 100}}static getXAxisLabel(e){switch(e){case R.plot.SeriesPlotStyle.PIE:return"Labels";case R.plot.SeriesPlotStyle.HISTOGRAM:return"Data";default:return"X-Axis"}}static getSeriesLabel(e){switch(e){case R.plot.SeriesPlotStyle.PIE:return"Values";default:return"Series"}}static makeSeriesItem(e){return{id:_e.generate(),value:e}}static makeDefaultSeriesItems(e,t){if(ht.getMaxSeriesCount(e)===0||t==null||t.length===0)return[];const s=t.length>1?t[1].name:t[0].name;return[ht.makeSeriesItem(s)]}static getDefaultXAxis(e,t){return t!=null&&t.length>0?t[0].name:null}constructor(e){super(e),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:t}=e,{columns:n}=t,s=ht.types[0],i=ht.getDefaultXAxis(s,n),o=ht.makeDefaultSeriesItems(s,n);this.state={type:s,seriesItems:o,xAxis:i,isLinked:!0}}handleAddSeries(){this.setState(e=>{const{seriesItems:t}=e,n=[...t],{model:s}=this.props,{columns:i}=s;return n.push({id:_e.generate(),value:i[0].name}),{seriesItems:n}},this.sendChange)}handleLinkStateChange(e){this.setState({isLinked:e.target.value==="true"},this.sendChange)}handleReset(){const{model:e}=this.props,{columns:t}=e,n=ht.types[0],s=ht.getDefaultXAxis(n,t),i=ht.makeDefaultSeriesItems(n,t),o=!0;this.setState({type:n,seriesItems:i,xAxis:s,isLinked:o},this.sendChange)}handleSeriesChange(e){const{value:t}=e.target,n=e.target.getAttribute("data-index"),s=parseInt(n,10);this.setState(i=>{let{seriesItems:o}=i;return o=[...o],o[s].value=t,{seriesItems:o}},this.sendChange)}handleSeriesDeleteClick(e){const n=e.target.getAttribute("data-index"),s=parseInt(n,10);this.setState(i=>{const{seriesItems:o}=i,a=[...o];return a.splice(s,1),{seriesItems:a}},this.sendChange)}handleSubmit(e){e.preventDefault();const{onSubmit:t}=this.props,{type:n,seriesItems:s,xAxis:i,isLinked:o}=this.state,a=s.map(r=>r.value);t({type:`${n}`,series:a,xAxis:i,isLinked:o})}handleTypeClick(e){const n=e.target.getAttribute("data-index"),s=parseInt(n,10),i=ht.types[s];$d.debug2("handleTypeSelect",i),this.setState(o=>{const a=ht.getMaxSeriesCount(i);let{seriesItems:r}=o;if(r=r.slice(0,a),r.length===0&&a>0){const{model:c}=this.props,{columns:h}=c;r=ht.makeDefaultSeriesItems(i,h)}return{type:i,seriesItems:r}},this.sendChange)}handleXAxisChange(e){const t=e.target.value;$d.debug2("x-axis change",t),this.setState({xAxis:t},this.sendChange)}sendChange(){const{onChange:e}=this.props,{isLinked:t,type:n,seriesItems:s,xAxis:i}=this.state,o=s.map(a=>a.value);e({type:n,series:o,xAxis:i,isLinked:t})}render(){const{model:e}=this.props,{columns:t}=e,{seriesItems:n,type:s,xAxis:i,isLinked:o}=this.state,a=ht.getMaxSeriesCount(s),r=ht.getXAxisLabel(s),c=ht.getSeriesLabel(s),h=n.length>0,u=n.length<a;return l.jsx("div",{className:"chart-builder",children:l.jsxs("form",{onSubmit:this.handleSubmit,children:[l.jsxs("div",{className:"form-row",children:[l.jsx("label",{children:"Select Chart Type"}),l.jsx("div",{className:"form-row",children:ht.types.map((m,g)=>{const p=m;return l.jsx("div",{className:"col col-chart-type",children:l.jsxs("button",{type:"button",className:$("btn","btn-icon","btn-chart-type",{active:m===s}),"data-index":g,onClick:this.handleTypeClick,children:[ht.getTypeIcon(m),ht.getTypeName(m)]})},p)})})]}),l.jsx("hr",{}),l.jsxs("div",{className:"form-row form-inline",children:[l.jsx("label",{className:"col-2 label-left",children:r}),l.jsx("select",{className:"form-control custom-select select-x-axis col",value:i,onChange:this.handleXAxisChange,children:t.map(m=>l.jsx("option",{value:m.name,children:m.name},m.name))})]}),h&&l.jsx("hr",{}),n.map((m,g)=>l.jsxs("div",{className:"form-row form-inline form-series-item","data-testid":`form-series-item-${g}`,children:[l.jsx("label",{className:"col-2 label-left",children:g===0?c:""}),l.jsx("select",{className:"form-control custom-select select-series col",value:m.value,onChange:this.handleSeriesChange,"data-testid":`select-series-item-${g}`,"data-index":g,children:t.map(p=>l.jsx("option",{value:p.name,"data-index":g,children:p.name},p.name))}),n.length>1&&l.jsx(B,{kind:"ghost",className:"btn-delete-series ml-2 px-2","data-index":g,"data-testid":`delete-series-${g}`,onClick:this.handleSeriesDeleteClick,icon:Jt,tooltip:"Delete"})]},m.id)),u&&l.jsxs("div",{className:"form-row",children:[l.jsx("div",{className:"col-2"}),l.jsx(B,{kind:"ghost",className:"btn-add-series mt-1",onClick:this.handleAddSeries,icon:Ps,children:"Add Series"})]}),l.jsxs("div",{className:"form-row chart-builder-link",children:[l.jsx("label",{className:"col-2 label-right",children:l.jsxs("div",{className:"fa-md fa-layers",children:[l.jsx(Q,{mask:Nl,icon:Ui,transform:"right-5 down-5"}),l.jsx(Q,{icon:o?Fl:Gg,transform:"grow-2 right-8 down-6"})]})}),l.jsxs(hr,{onChange:this.handleLinkStateChange,value:`${o}`,children:[l.jsx(ts,{value:"true",children:"Sync State"}),l.jsx(ts,{value:"false",children:"Freeze State"})]})]}),l.jsxs("div",{className:"form-row",children:[l.jsx("div",{className:"col-2 label-right"}),l.jsx("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."})]}),l.jsxs("div",{className:$("form-row","justify-content-end","my-3"),children:[l.jsx(B,{kind:"secondary",className:"btn-reset",onClick:this.handleReset,children:"Reset"}),l.jsx(B,{kind:"primary",type:"submit",className:"btn-submit",children:"Create"})]})]})})}}const rE=ht;class lE extends b.Component{static defaultProps={value:"",onContentChanged:()=>{},editorSettings:{},editorIndex:0,onTab:()=>{},invalid:!1};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()}editorContainer;editor;initEditor(){const{value:e,editorSettings:t}=this.props,n={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,...t};if(!this.editorContainer)throw new Error("editorContainer is null");this.editor=Qn.create(this.editorContainer,n),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,t=this.editor?.getModel()?.getValue();t!==void 0&&this.setState({isEditorEmpty:t.length===0}),e(t)}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:t,editorIndex:n}=this.props;e.code==="Tab"&&(e.stopPropagation(),e.preventDefault(),t(n,e.shiftKey))}render(){const{value:e,invalid:t}=this.props,{isEditorFocused:n,isEditorEmpty:s}=this.state;return l.jsxs("div",{className:$("input-editor-wrapper",{focused:n,invalid:t}),role:"presentation",onClick:this.handleContainerClick,children:[l.jsx("div",{className:"editor-container",ref:i=>{this.editorContainer=i}}),s&&!e&&l.jsx("div",{className:"editor-placeholder text-muted",children:"Column Formula"})]})}}const Wd=Object.freeze({NAME:"name",FORMULA:"formula"}),cE=()=>{};function dE({eventKey:d,name:e,inputIndex:t,formula:n,onChange:s,onDeleteColumn:i,onTabInEditor:o,invalid:a,isDuplicate:r}){const c=e===""||un.isValidColumnName(e),h=b.useCallback(u=>{u!==void 0&&(u.replace(/(\r\n|\n|\r)/gm,""),s(d,Wd.FORMULA,u))},[s,d]);return l.jsx(Rl,{draggableId:d,index:t,disableInteractiveElementBlocking:!0,children:(u,m)=>l.jsxs("div",{className:$("draggable-container",{dragging:m.isDragging}),ref:u.innerRef,...u.draggableProps,children:[l.jsxs("div",{className:"custom-column-input-container",children:[l.jsxs("div",{className:"pb-3",children:[l.jsxs("div",{className:"d-flex flex-row custom-column-name",children:[l.jsx("input",{className:$("form-control custom-column-input",{"is-invalid":a||!c||r}),placeholder:"Column Name",value:e,onChange:g=>{s(d,Wd.NAME,g.target.value)}}),l.jsx(B,{kind:"ghost",className:"ml-1 px-2",onClick:()=>{i(d)},icon:Jt,tooltip:"Delete custom column"}),l.jsx(B,{kind:"ghost",className:"btn-drag-handle",onClick:cE,...u.dragHandleProps,icon:ko,tooltip:"Drag column to re-order"})]}),(!c||r)&&l.jsx("p",{className:"validate-label-error text-danger mb-0 mt-2 pl-1",children:c?"Duplicate name":"Invalid name"})]}),l.jsx(lE,{editorSettings:{language:"deephavenDb"},editorIndex:t,value:n,onContentChanged:h,onTab:o,invalid:a})]}),l.jsx("hr",{})]})})}const qr=[];class hE extends hv{static 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"});constructor(){super(),this.listenerCount=0}listenerCount;addEventListener(e,t,n){super.addEventListener(e,t,n),this.listenerCount+=1,this.listenerCount===1&&this.startListening()}removeEventListener(e,t,n){super.removeEventListener(e,t,n),this.listenerCount-=1,this.listenerCount===0&&this.stopListening()}startListening(){}stopListening(){}get originalColumns(){return this.columns}get layoutHints(){return null}get frontColumns(){return qr}get backColumns(){return qr}get frozenColumns(){return qr}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}}const Se=hE;class ti extends b.Component{static SUCCESS_SHOW_DURATION=750;static makeCustomColumnInputEventKey(){return _e.generate()}static createCustomColumnInput(){return{eventKey:_e.generate(),name:"",formula:""}}constructor(e){super(e),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}componentDidMount(){const{customColumns:e}=this.props;this.parseCustomColumns(e),this.startListening()}componentWillUnmount(){this.stopListening(),this.successButtonTimer&&clearTimeout(this.successButtonTimer)}container;successButtonTimer;getInput=fe((e,t)=>e.find(n=>n.eventKey===t));getInputIndex=fe((e,t)=>e.findIndex(n=>n.eventKey===t));resetErrorMessage(){this.setState({errorMessage:null})}startListening(){const{model:e}=this.props;e.addEventListener(Se.EVENT.COLUMNS_CHANGED,this.handleCustomColumnUpdated),e.addEventListener(Se.EVENT.UPDATED,this.handleCustomColumnUpdated),e.addEventListener(Se.EVENT.REQUEST_FAILED,this.handleRequestFailed)}stopListening(){const{model:e}=this.props;e.removeEventListener(Se.EVENT.COLUMNS_CHANGED,this.handleCustomColumnUpdated),e.removeEventListener(Se.EVENT.UPDATED,this.handleCustomColumnUpdated),e.removeEventListener(Se.EVENT.REQUEST_FAILED,this.handleRequestFailed)}parseCustomColumns(e){if(e.length>0){const t=e.map(n=>{const s=n.split(/=(.+)/,2);return{eventKey:ti.makeCustomColumnInputEventKey(),name:s[0],formula:s[1]}});this.setState({inputs:t})}else this.setState({inputs:[ti.createCustomColumnInput()]})}handleAddColumnClick(){const{inputs:e}=this.state,t=[...e];t.push(ti.createCustomColumnInput()),this.setState({inputs:t})}handleDeleteColumn(e){const{inputs:t}=this.state,n=this.getInputIndex(t,e),s=[...t];s.splice(n,1),s.length===0&&s.push(ti.createCustomColumnInput()),this.setState({inputs:s})}handleInputChange(e,t,n){const{inputs:s}=this.state,i=this.getInputIndex(s,e),a={...this.getInput(s,e)};a[t]=n;const r=[...s];r.splice(i,1,a),this.setState({inputs:r})}handleCustomColumnUpdated(){const{isCustomColumnApplying:e}=this.state;e&&this.setState({isCustomColumnApplying:!1,isSuccessShowing:!0},()=>{this.successButtonTimer=setTimeout(()=>this.setState({isSuccessShowing:!1}),ti.SUCCESS_SHOW_DURATION)})}handleRequestFailed(e){const t=e,{isCustomColumnApplying:n}=this.state;n&&this.setState({isCustomColumnApplying:!1,errorMessage:l.jsxs(l.Fragment,{children:[l.jsxs("p",{children:[l.jsx(Q,{icon:As})," Failed to apply custom columns."]}),l.jsxs("div",{className:"error-box",children:[t.detail.errorMessage,l.jsx("br",{}),"Table configuration:"," ",JSON.stringify(t.detail.configuration)]})]}),hasRequestFailed:!0})}handleDragEnd(e){if(vn.stopDragging(),!e.destination)return;const{inputs:t}=this.state,n=e.source.index,s=e.destination.index,i=[...t],o=t[n];i.splice(n,1),i.splice(s,0,o),this.setState({inputs:i})}handleEditorTabNavigation(e,t){const{inputs:n}=this.state;if(t){(this.container?.querySelectorAll(".btn-drag-handle")[e]).focus();return}if(e===n.length-1)this.container?.querySelector(".btn-add-column")?.focus();else{const s=e+1;(this.container?.querySelectorAll(".custom-column-input")[s]).focus()}}handleSaveClick(){const{onSave:e,customColumns:t}=this.props,{inputs:n,isCustomColumnApplying:s}=this.state;if(s)return;const i=[];n.forEach(o=>{const{name:a,formula:r}=o;a&&r&&i.push(`${a}=${r}`)}),this.resetErrorMessage(),this.setState({isCustomColumnApplying:i.length>0||t.length>0}),e(i)}resetRequestFailed(){this.setState(({hasRequestFailed:e})=>e?{hasRequestFailed:!1}:null)}renderInputs(){const{inputs:e,hasRequestFailed:t}=this.state,n=new Map;return e.forEach(({name:s})=>n.set(s,(n.get(s)??0)+1)),e.map((s,i)=>{const{eventKey:o,name:a,formula:r}=s,c=(n.get(a)??0)>1;return l.jsx(dE,{inputIndex:i,eventKey:o,name:a,formula:r,onChange:this.handleInputChange,onDeleteColumn:this.handleDeleteColumn,onTabInEditor:this.handleEditorTabNavigation,invalid:t,isDuplicate:c},o)})}renderSaveButton(){const{inputs:e,isCustomColumnApplying:t,isSuccessShowing:n}=this.state,s=e.length>1?"Save Columns":"Save Column",i=e.every(({name:r})=>r===""||un.isValidColumnName(r)),o=e.filter(({name:r})=>r!=="").map(({name:r})=>r),a=new Set(o).size===o.length;return l.jsxs(B,{kind:n?"success":"primary",className:$("btn-apply",{"btn-spinner":t}),disabled:n||t||!i||!a,onClick:this.handleSaveClick,children:[t&&l.jsxs("span",{children:[l.jsx(yn,{}),l.jsx("span",{className:"btn-normal-content",children:"Applying"})]}),!n&&!t&&s,n&&l.jsxs(l.Fragment,{children:[l.jsx(Q,{icon:Ml})," Success"]})]})}render(){const{onCancel:e}=this.props,{errorMessage:t}=this.state;return l.jsxs("div",{role:"presentation",className:"custom-column-builder-container",ref:n=>{this.container=n},onClick:this.resetRequestFailed,onFocus:this.resetRequestFailed,children:[l.jsx("hr",{}),l.jsx(nr,{onDragStart:vn.startDragging,onDragEnd:this.handleDragEnd,children:l.jsx(tr,{droppableId:"droppable-custom-columns",children:(n,s)=>l.jsxs("div",{ref:n.innerRef,...n.droppableProps,className:$("droppable-container",{dragging:s.draggingFromThisWith}),children:[this.renderInputs(),n.placeholder]})})}),l.jsx("div",{className:"pt-1 px-3",children:l.jsx(B,{kind:"ghost",className:"btn-add-column",onClick:this.handleAddColumnClick,icon:Ps,children:"Add Another Column"})}),l.jsxs("div",{className:"custom-column-builder-footer",children:[t&&l.jsx("div",{className:"error-message",children:t}),l.jsxs("div",{className:"d-flex justify-content-end",children:[l.jsx(B,{kind:"secondary",className:"mr-2",onClick:e,children:"Cancel"}),this.renderSaveButton()]})]})]})}}const uE=ti;var rm=(d=>(d.ADVANCED_SETTINGS="ADVANCED_SETTINGS",d.AGGREGATIONS="AGGREGATIONS",d.AGGREGATION_EDIT="AGGREGATIONS_EDIT",d.CHART_BUILDER="CHART_BUILDER",d.CUSTOM_COLUMN_BUILDER="CUSTOM_COLUMN_BUILDER",d.QUICK_FILTERS="QUICK_FILTERS",d.ROLLUP_ROWS="ROLLUP_ROWS",d.SEARCH_BAR="SEARCH_BAR",d.SELECT_DISTINCT="SELECT_DISTINCT",d.TABLE_EXPORTER="TABLE_EXPORTER",d.VISIBILITY_ORDERING_BUILDER="VISIBILITY_ORDERING_BUILDER",d.CONDITIONAL_FORMATTING="CONDITIONAL_FORMATTING",d.CONDITIONAL_FORMATTING_EDIT="CONDITIONAL_FORMATTING_EDIT",d.GOTO="GOTO",d))(rm||{});const De=rm;const ho=Z.module("RollupRows"),mE=150,ha="grouped-rollup-rows",ua="ungrouped-rollup-rows";class ln extends b.Component{static SORT=Object.freeze({ASCENDING:"ASC",DESCENDING:"DESC"});static defaultProps={config:null,onChange:()=>{}};static renderColumn({item:e,isClone:t,selectedCount:n}){const s=e?.name,i=t!==void 0&&t?`${n}`:void 0,o=t!==void 0&&t?"item-list-item-clone":"";return Cn.renderTextItem({text:s,badgeText:i,className:o})}static addGroupings(e,t,n=e.length){if(t==null||t.length===0)return e;let s=n;const i=e.filter((o,a)=>t.includes(o)?(a<s&&(s-=1),!1):!0);return i.splice(s,0,...t),i}static isGroupable(e){return!x.isDecimalType(e.type)}constructor(e){super(e),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=J.createRef(),this.groupedList=J.createRef();const{config:t}=e,{columns:n=[],showConstituents:s=!0,showNonAggregatedColumns:i=!0}=t??{};this.state={ungroupedSelectedRanges:[],columns:n,groupedSelectedRanges:[],searchFilter:"",showConstituents:s,showNonAggregatedColumns:i,dragSource:null,sort:null}}componentDidUpdate(e,t){const{config:n}=this.props,{columns:s,showConstituents:i,showNonAggregatedColumns:o}=this.state;n!==e.config?this.updateFromConfig():(s!==t.columns||i!==t.showConstituents||o!==t.showNonAggregatedColumns)&&(n==null||s!==n.columns||i!==n.showConstituents||o!==n.showNonAggregatedColumns)&&this.sendChange()}componentWillUnmount(){this.search.cancel()}ungroupedList;groupedList;handleSearchChange(e){const t=e.target.value;if(this.setState({searchFilter:t}),!t){this.search.cancel(),this.resetSelection();return}this.search(t)}handleSortAscending(){this.setState(({sort:e})=>({sort:e===ln.SORT.ASCENDING?null:ln.SORT.ASCENDING}))}handleSortDescending(){this.setState(({sort:e})=>({sort:e===ln.SORT.DESCENDING?null:ln.SORT.DESCENDING}))}resetSelection(){this.setState({ungroupedSelectedRanges:[],groupedSelectedRanges:[]})}search=Ye(e=>{const t=this.getSortedUngroupedColumns(),n=[];let s=null;for(let i=0;i<t.length;i+=1)t[i].name.toLowerCase().includes(e.toLowerCase())&&(s==null&&(s=i),n.push([i,i]));M(s),this.setState({ungroupedSelectedRanges:n}),n.length>0&&this.ungroupedList.current&&this.ungroupedList.current.scrollToItem(s)},mE);handleDragStart(e){ho.debug("handleDragStart",e),document.documentElement.classList.add("drag-pointer-events-none"),this.setState({dragSource:e.source})}handleDragEnd(e){ho.debug("handleDragEnd",e),document.documentElement.classList.remove("drag-pointer-events-none"),this.setState({dragSource:null});const{destination:t,source:n}=e;if(t==null||n==null)return;if(t.droppableId===ua){this.setState(({groupedSelectedRanges:o,columns:a})=>{const r=[...a];return vn.reorder(r,o,[],0),{columns:r,ungroupedSelectedRanges:[],groupedSelectedRanges:[]}});return}const s=n.droppableId===ha;let i=t.index;s&&n.index<t.index&&(i+=1),this.setState(({columns:o,ungroupedSelectedRanges:a,groupedSelectedRanges:r})=>{const c=[...o],h=s?c:this.getSortedUngroupedColumns().map(C=>C.name),u=s?r:a,m=vn.reorder(h,u,c,i),g=s?vn.adjustDestinationIndex(i,r):i,p=[[g,g+m.length-1]];return{columns:c,ungroupedSelectedRanges:[],groupedSelectedRanges:p}}),this.resetSelection()}handleUngroupedSelect(e){ho.debug("handleUngroupedSelect"),this.setState(({columns:t})=>({columns:ln.addGroupings(t,[this.getSortedUngroupedColumns()[e].name]),ungroupedSelectedRanges:[],groupedSelectedRanges:[]}))}handleUngroupedSelectionChange(e){ho.debug2("handleUngroupedSelectionChange",e),this.setState(({ungroupedSelectedRanges:t})=>e===t?null:{ungroupedSelectedRanges:e,groupedSelectedRanges:[]})}handleGroupedSelectionChange(e){ho.debug2("handleGroupedSelectedRanges",e),this.setState(({groupedSelectedRanges:t})=>e===t?null:{groupedSelectedRanges:e,ungroupedSelectedRanges:[]})}handleDeleteClicked(e){this.setState(({columns:t})=>{const n=t.slice();return n.splice(e,1),{columns:n}})}handleShowConstituentsChange(){this.setState(({showConstituents:e})=>({showConstituents:!e}))}handleShowNonAggregatedColumnsChange(){this.setState(({showNonAggregatedColumns:e})=>({showNonAggregatedColumns:!e}))}updateFromConfig(){const{config:e}=this.props,{columns:t=[],showConstituents:n=!0,showNonAggregatedColumns:s=!0}=e??{};this.setState({columns:t,showConstituents:n,showNonAggregatedColumns:s})}sendChange(){const{onChange:e}=this.props,{columns:t,showConstituents:n,showNonAggregatedColumns:s}=this.state;e({columns:t,showConstituents:n,showNonAggregatedColumns:s})}getCachedUngroupedColumns=ge((e,t)=>e.filter(n=>ln.isGroupable(n)&&t.find(s=>s===n.name)==null));getCachedSortedColumns=ge((e,t)=>t==null?[...e]:x.sortColumns(e,t===ln.SORT.ASCENDING));getUngroupedColumns(){const{model:e}=this.props,{columns:t}=this.state,{originalColumns:n}=e;return this.getCachedUngroupedColumns(n,t)}getSortedUngroupedColumns(){const{sort:e}=this.state,t=this.getUngroupedColumns();return this.getCachedSortedColumns(t,e)}renderGroupedItem({item:e,itemIndex:t,isClone:n,selectedCount:s}){const o=`${n!==void 0&&n?"":"  ".repeat(t)}${e}`,a=n!==void 0&&n?`${s}`:void 0,r=n!==void 0&&n?"item-list-item-clone":"";return l.jsxs(l.Fragment,{children:[Cn.renderTextItem({text:o,badgeText:a,className:r}),(n===void 0||!n)&&l.jsx(B,{kind:"ghost",className:"btn btn-link btn-link-icon btn-delete-grouping float-right",onClick:()=>this.handleDeleteClicked(t),children:l.jsx(Q,{icon:Jt})})]})}render(){const{columns:e,dragSource:t,searchFilter:n,groupedSelectedRanges:s,ungroupedSelectedRanges:i,showConstituents:o,showNonAggregatedColumns:a,sort:r}=this.state,c=this.getSortedUngroupedColumns();let h=e.length*Cn.DEFAULT_ROW_HEIGHT;t?.droppableId===ua&&(h+=Cn.DEFAULT_ROW_HEIGHT);const u=c.length*Cn.DEFAULT_ROW_HEIGHT+10,m=Math.min(3*Cn.DEFAULT_ROW_HEIGHT,u);return l.jsx("div",{role:"menu",className:$("rollup-rows",{"is-dragging":t!=null}),tabIndex:0,children:l.jsxs(nr,{onDragEnd:this.handleDragEnd,onDragStart:this.handleDragStart,children:[l.jsxs("div",{className:"rollup-rows-group-by",children:[l.jsx("div",{className:"section-title",children:"Group By"}),e.length===0&&l.jsx(tr,{droppableId:"placeholder",children:(g,p)=>l.jsx("div",{className:$("placeholder","text-muted",{"is-dragging-from-this":p.draggingFromThisWith,"is-dragging-over":p.isDraggingOver,"is-dropping":p.draggingOverWith}),ref:g.innerRef,...g.droppableProps,children:"To create a rollup, drag columns from the list below and drop them into this area."})}),e.length>0&&l.jsx(Cn,{draggingItemClassName:"rollup-rows-dragging-grouped-item",draggablePrefix:ha,droppableId:ha,itemCount:e.length,items:e,offset:0,onSelectionChange:this.handleGroupedSelectionChange,ref:this.groupedList,renderItem:this.renderGroupedItem,selectedRanges:s,style:{height:h},isMultiSelect:!0})]}),l.jsxs("div",{className:"rollup-rows-available-columns",children:[l.jsx("div",{className:"section-title",children:"Available Grouping Columns"}),l.jsxs("div",{className:"top-menu",children:[l.jsx(_s,{className:"w-100",value:n,matchCount:n?i.length:void 0,placeholder:"Find column...",onChange:this.handleSearchChange}),l.jsxs(B,{kind:"ghost",className:$("btn-link btn-link-icon",{active:r===ln.SORT.ASCENDING}),onClick:this.handleSortAscending,children:[l.jsx(Q,{icon:Al}),l.jsx(tt,{children:"Sort ascending"})]}),l.jsxs(B,{kind:"ghost",className:$("btn-link btn-link-icon",{active:r===ln.SORT.DESCENDING}),onClick:this.handleSortDescending,children:[l.jsx(Q,{icon:Ll}),l.jsx(tt,{children:"Sort descending"})]})]}),l.jsx(Cn,{className:"rollup-available-grouping-columns",draggablePrefix:ua,droppableId:ua,itemCount:c.length,items:c,renderItem:ln.renderColumn,offset:0,onSelect:this.handleUngroupedSelect,onSelectionChange:this.handleUngroupedSelectionChange,ref:this.ungroupedList,selectedRanges:i,style:{maxHeight:u,minHeight:m},isDropDisabled:t?.droppableId!==ha,isMultiSelect:!0}),l.jsxs("div",{className:"bottom-menu",children:[l.jsx("div",{className:"label",children:"Show:"}),l.jsx(Zt,{checked:o,onChange:this.handleShowConstituentsChange,children:"Constituents"}),l.jsx(Zt,{checked:a,onChange:this.handleShowNonAggregatedColumnsChange,children:"Non-Aggregated Columns"})]})]})]})})}}const gE=ln;const pE=Z.module("TableCsvExporter");class Be extends b.Component{static FILENAME_DATE_FORMAT="yyyy-MM-dd-HHmmss";static DOWNLOAD_STATUS={INITIATING:"INITIATING",DOWNLOADING:"DOWNLOADING",FINISHED:"FINISHED",CANCELED:"CANCELED"};static DOWNLOAD_ROW_OPTIONS={ALL_ROWS:"ALL_ROWS",SELECTED_ROWS:"SELECTED_ROWS",CUSTOMIZED_ROWS:"CUSTOMIZED_ROWS"};static CUSTOMIZED_ROWS_OPTIONS={FIRST:"FIRST",LAST:"LAST"};static DEFAULT_DOWNLOAD_ROWS=100;static defaultProps={onDownloadStart:()=>{},isDownloading:!1,tableDownloadStatus:"",tableDownloadProgress:0,tableDownloadEstimatedTime:null,selectedRanges:[]};static getDateString(){return R.i18n.DateTimeFormat.format(Be.FILENAME_DATE_FORMAT,new Date)}constructor(e){super(e),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:t}=e;this.state={fileName:`${t}-${Be.getDateString()}.csv`,downloadRowOption:Be.DOWNLOAD_ROW_OPTIONS.ALL_ROWS,customizedDownloadRowOption:Be.CUSTOMIZED_ROWS_OPTIONS.FIRST,customizedDownloadRows:Be.DEFAULT_DOWNLOAD_ROWS,includeColumnHeaders:!0,includeHiddenColumns:!1,useUnformattedValues:!1,errorMessage:null,id:_e.generate()}}getSnapshotRanges(){const{model:e,selectedRanges:t}=this.props,{downloadRowOption:n,customizedDownloadRowOption:s,customizedDownloadRows:i}=this.state,{rowCount:o,columnCount:a}=e;let r=[];switch(n){case Be.DOWNLOAD_ROW_OPTIONS.ALL_ROWS:r.push(new z(0,0,a-1,o-1));break;case Be.DOWNLOAD_ROW_OPTIONS.SELECTED_ROWS:r=t.map(c=>({...c,startColumn:0,endColumn:a-1})).sort((c,h)=>c.startRow!=null&&h.startRow!=null?c.startRow-h.startRow:0);break;case Be.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS:switch(s){case Be.CUSTOMIZED_ROWS_OPTIONS.FIRST:r.push(new z(0,0,a-1,Math.min(i-1,o-1)));break;case Be.CUSTOMIZED_ROWS_OPTIONS.LAST:r.push(new z(0,Math.max(0,o-i),a-1,o-1));break}break}return r}getModelRanges(e){const{userColumnWidths:t,movedColumns:n}=this.props,{includeHiddenColumns:s}=this.state,i=be.getHiddenColumns(t);let o=V.getModelRanges(e,n);if(!s&&i.length>0){const a=i.map(z.makeColumn);o=z.subtractRangesFromRanges(o,a)}return o}resetDownloadState(){this.setState({errorMessage:null})}async handleDownloadClick(){const{model:e,isDownloading:t,onDownloadStart:n,onDownload:s,onCancel:i}=this.props,{fileName:o,includeColumnHeaders:a,useUnformattedValues:r}=this.state;if(t){i();return}this.resetDownloadState();const c=this.getSnapshotRanges(),h=this.getModelRanges(c);if(this.validateOptionInput()){n();try{const u=await e.export(),m=u.setViewport(0,0);await m.getViewportData(),s(o,u,m,c,h,a,r)}catch(u){pE.error("CSV download failed",u),this.setState({errorMessage:l.jsxs("p",{children:[l.jsx(Q,{icon:As})," ",`${u}`]})}),i()}}}handleDownloadRowOptionChanged(e){this.setState({downloadRowOption:e.target.value})}handleCustomizedDownloadRowOptionChanged(e){this.setState({customizedDownloadRowOption:e.target.value})}handleCustomizedDownloadRowsChanged(e){this.setState({customizedDownloadRows:parseInt(e.target.value,10)})}handleIncludeColumnHeadersChanged(){this.setState(({includeColumnHeaders:e})=>({includeColumnHeaders:!e}))}handleIncludeHiddenColumnsChanged(){this.setState(({includeHiddenColumns:e})=>({includeHiddenColumns:!e}))}handleUseUnformattedValuesChanged(){this.setState(({useUnformattedValues:e})=>({useUnformattedValues:!e}))}validateOptionInput(){const{selectedRanges:e}=this.props,{downloadRowOption:t,customizedDownloadRows:n}=this.state;return t===Be.DOWNLOAD_ROW_OPTIONS.SELECTED_ROWS&&e.length===0?(this.setState({errorMessage:l.jsxs("p",{children:[l.jsx(Q,{icon:As})," No rows selected. Please select some rows in the table."]})}),!1):t===Be.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS&&n<=0?(this.setState({errorMessage:l.jsxs("p",{children:[l.jsx(Q,{icon:As})," Number of rows to output must be greater than 0"]})}),!1):!0}render(){const{model:e,isDownloading:t,tableDownloadProgress:n,tableDownloadEstimatedTime:s,selectedRanges:i,tableDownloadStatus:o}=this.props,{fileName:a,downloadRowOption:r,customizedDownloadRowOption:c,customizedDownloadRows:h,includeColumnHeaders:u,includeHiddenColumns:m,useUnformattedValues:g,errorMessage:p,id:C}=this.state,{rowCount:f}=e;return l.jsxs("div",{className:"table-csv-exporter",children:[l.jsx("div",{className:"section-title",children:"Download Rows"}),l.jsx("div",{className:"form-group",children:l.jsxs(hr,{onChange:this.handleDownloadRowOptionChanged,value:r,disabled:t,children:[l.jsxs(ts,{value:Be.DOWNLOAD_ROW_OPTIONS.ALL_ROWS,"data-testid":"radio-csv-exporter-download-all",children:["All Rows",l.jsx("span",{className:"text-muted ml-2",children:`(${f.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")} rows)`})]}),l.jsxs(ts,{value:Be.DOWNLOAD_ROW_OPTIONS.SELECTED_ROWS,"data-testid":"radio-csv-exporter-only-selected",children:["Only Selected Rows",l.jsx("span",{className:"text-muted ml-2",children:i.length>0?`(${z.rowCount(i).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")} rows)`:null})]}),l.jsx(ts,{value:Be.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS,"data-testid":"radio-csv-exporter-customized-rows",children:l.jsxs("div",{className:"radio-input-row",role:"presentation",onClick:()=>{this.setState({downloadRowOption:Be.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS})},children:[l.jsxs("select",{value:c,"data-testid":"select-csv-exporter-customized-rows",className:"custom-select",disabled:t,onChange:this.handleCustomizedDownloadRowOptionChanged,children:[l.jsx("option",{value:"FIRST",children:"First"}),l.jsx("option",{value:"LAST",children:"Last"})]}),l.jsx("input",{type:"number",className:"form-control",id:`customizedRows-${C}`,"data-testid":"input-csv-exporter-customized-rows",name:`customizedRows-${C}`,placeholder:"100",value:h,disabled:t,onChange:this.handleCustomizedDownloadRowsChanged}),l.jsx("div",{children:"Rows"})]})})]})}),l.jsxs("div",{className:"form-group",children:[l.jsx("label",{htmlFor:`customizedRows-${C}`,children:"File Name"}),l.jsx("input",{type:"text",className:"form-control",id:`filename-${C}`,"data-testid":"input-csv-exporter-file-name",name:`filename-${C}`,value:a,onChange:S=>{this.setState({fileName:S.target.value})},disabled:t})]}),l.jsxs("div",{className:"checkbox-options",children:[l.jsx(Zt,{checked:u,onChange:this.handleIncludeColumnHeadersChanged,children:"Include column headers"}),l.jsx(Zt,{checked:m,onChange:this.handleIncludeHiddenColumnsChanged,children:"Include hidden columns"}),l.jsx(Zt,{checked:g,onChange:this.handleUseUnformattedValuesChanged,children:"Use unformatted values"})]}),l.jsxs("div",{className:"section-footer flex-column",children:[p!=null&&l.jsx("div",{className:"error-message",children:p}),o&&l.jsxs("div",{className:"download-status",children:[(o===Be.DOWNLOAD_STATUS.DOWNLOADING||o===Be.DOWNLOAD_STATUS.INITIATING)&&l.jsxs(l.Fragment,{children:[o===Be.DOWNLOAD_STATUS.INITIATING&&l.jsx("div",{className:"text-muted",children:"Starting Download..."}),o===Be.DOWNLOAD_STATUS.DOWNLOADING&&l.jsxs("div",{className:"text-muted d-flex justify-content-between",children:[l.jsx("span",{children:s||s===0?`Estimated time: ${Xi.formatElapsedTime(s)}`:null}),l.jsx("span",{children:`${n}%`})]})]}),o===Be.DOWNLOAD_STATUS.FINISHED&&l.jsx("div",{className:"text-muted text-right",children:"Download Completed"}),o===Be.DOWNLOAD_STATUS.CANCELED&&l.jsx("div",{className:"text-muted",children:"Download Canceled"}),(o===Be.DOWNLOAD_STATUS.DOWNLOADING||o===Be.DOWNLOAD_STATUS.INITIATING)&&l.jsx("div",{className:"progress",children:l.jsx("div",{className:"progress-bar progress-bar-striped progress-bar-animated",style:{width:`${n}%`}})}),o===Be.DOWNLOAD_STATUS.FINISHED&&l.jsx("div",{className:"progress",children:l.jsx("div",{className:"progress-bar bg-success",style:{width:`${n}%`}})})]}),l.jsxs(B,{kind:"primary","data-testid":"btn-csv-exporter-download",className:$("btn-downloading",{"btn-spinner btn-cancelable":t}),onClick:this.handleDownloadClick,children:[t&&l.jsxs("span",{children:[l.jsx(yn,{}),l.jsx("span",{className:"btn-normal-content",children:"Downloading"}),l.jsx("span",{className:"btn-hover-content",children:"Cancel"})]}),!t&&"Download"]})]})]})}}const Ks=Be,zn=Z.module("TableSaver"),fE="yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS z";function CE(d){return d.added!==void 0}function SE(d){if(!CE(d))throw new Error("event is not UpdateEventData")}class Yn extends b.PureComponent{static DOWNLOAD_CELL_CHUNK=6e3;static SNAPSHOT_BUFFER_SIZE=5;static STREAM_TIMEOUT=8e3;static SNAPSHOT_HANDLER_TIMEOUT=5;static defaultProps={getDownloadWorker:()=>Promise.reject(new Error("Download worker not provided")),isDownloading:!1,onDownloadCompleted:()=>{},onDownloadCanceled:()=>{},onDownloadProgressUpdate:()=>{}};static csvEscapeString(e){return`"${e.replace(/"/g,'""')}"`}constructor(e){super(e),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.iframes=[],this.useBlobFallback=!1}componentDidMount(){const{getDownloadWorker:e}=this.props;e().then(t=>{zn.info("found active service worker"),this.sw=t,this.sw.postMessage("ping")}).catch(t=>{zn.warn("Download csv is not optimized.",t),this.useBlobFallback=!0})}componentWillUnmount(){this.iframes.length>0&&this.iframes.forEach(e=>{e.remove()}),this.streamTimeout&&clearTimeout(this.streamTimeout),this.snapshotHandlerTimeout&&clearTimeout(this.snapshotHandlerTimeout)}sw;port;fileWriter;table;tableSubscription;columns;fileName;includeColumnHeaders;useUnformattedValues;chunkRows;gridRanges;gridRangeCounter;rangedSnapshotsTotal;rangedSnapshotCounter;snapshotsTotal;snapshotCounter;snapshotsBuffer;currentSnapshotIndex;snapshotPending;cancelableSnapshots;streamTimeout;snapshotHandlerTimeout;downloadStartTime;iframes;useBlobFallback;getCachedCustomColumnFormatFlag=Zn(ns.isCustomColumnFormatDefined,{max:1e4});createWriterStream(e){const t=this.useBlobFallback,n=[];let s=null;t&&(s=TextEncoder.prototype.encode.bind(new TextEncoder));const{fileName:i}=this,o={};return t?(o.write=a=>{M(s),a.header!==void 0&&n.push(s(a.header)),a.rows!==void 0&&n.push(s(a.rows))},o.close=()=>{M(i);const a=new Blob(n,{type:"application/octet-stream; charset=utf-8"}),r=document.createElement("a");r.href=URL.createObjectURL(a),r.download=i,r.click()},o.abort=()=>{e.postMessage({cancel:!0}),e.close()}):(o.write=a=>{e.postMessage(a)},o.close=()=>{e.postMessage({end:!0}),e.close()},o.abort=()=>{e.postMessage({cancel:!0}),e.close()}),new WritableStream(o)}startDownload(e,t,n,s,i,o,a){const{isDownloading:r}=this.props;if(r)return;this.downloadStartTime=Date.now(),zn.info(`start downloading ${e}`),this.table=t,this.columns=be.columnsFromRanges(i,t.columns),this.tableSubscription=n,this.gridRanges=s,this.includeColumnHeaders=o,this.useUnformattedValues=a;const c=encodeURIComponent(e.replace(/\//g,":")).replace(/['()]/g,escape).replace(/\*/g,"%2A"),h=new MessageChannel;if(this.port=h.port1,this.fileName=e,this.fileWriter=this.createWriterStream(this.port).getWriter(),this.useBlobFallback){this.writeCsvTable(o);return}this.sw&&this.sw.postMessage({encodedFileName:c},[h.port2]),this.port.onmessage=this.handlePortMessage}finishDownload(){this.table&&this.table.close(),this.tableSubscription&&this.tableSubscription.close(),this.fileWriter&&this.fileWriter.close();const{onDownloadCompleted:e}=this.props;e(),this.resetTableSaver(),this.downloadStartTime!==void 0&&zn.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(t=>{t&&(t.catch(()=>null),t.cancel())});const{onDownloadCanceled:e}=this.props;e(),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(){zn.info("download canceled"),this.cancelDownload()}writeTableHeader(){let e="";if(this.columns)for(let t=0;t<this.columns.length;t+=1)e+=this.columns[t].name,e+=t===this.columns.length-1?`
22
- `:",";this.fileWriter?.write({header:e}).then(()=>null)}startWriteTableBody(){this.columns&&this.gridRanges!=null&&(this.chunkRows=Math.floor(Yn.DOWNLOAD_CELL_CHUNK/this.columns.length),this.rangedSnapshotsTotal=this.gridRanges.map(e=>(M(e.endRow),M(e.startRow),M(this.chunkRows),Math.ceil((e.endRow-e.startRow+1)/this.chunkRows))),this.snapshotsTotal=this.rangedSnapshotsTotal.reduce((e,t)=>e+t),zn.info("start writing table, total snapshots: ",this.snapshotsTotal),this.makeSnapshot(Math.min(Yn.SNAPSHOT_BUFFER_SIZE,this.snapshotsTotal)))}writeCsvTable(e){e&&this.writeTableHeader(),this.startWriteTableBody()}writeSnapshot(e,t,n){if(this.currentSnapshotIndex===e&&this.fileWriter){for(;this.snapshotsBuffer.has(this.currentSnapshotIndex);){const s=this.snapshotsBuffer.get(this.currentSnapshotIndex);M(s),this.fileWriter.write({rows:this.convertSnapshotIntoCsv(s)}),this.snapshotsBuffer.delete(this.currentSnapshotIndex),this.currentSnapshotIndex+=1,this.updateDownloadProgress(e)}if(this.snapshotsTotal&&this.currentSnapshotIndex>=this.snapshotsTotal){this.finishDownload();return}}this.snapshotCounter&&this.snapshotsTotal&&this.snapshotCounter<this.snapshotsTotal&&(zn.debug2(`
23
- current range index: ${this.gridRangeCounter},
24
- snapshotIndexCounter: ${this.snapshotCounter},
25
- currentRangedSnapshotIndex : ${this.rangedSnapshotCounter},
26
- snapshotpending: ${this.snapshotPending},
27
- buffered ${this.snapshotsBuffer.size}
28
- making ${Math.min(Yn.SNAPSHOT_BUFFER_SIZE-this.snapshotsBuffer.size-this.snapshotPending,this.snapshotsTotal-this.snapshotCounter)} more snapshots
29
- `),this.makeSnapshot(Math.min(Yn.SNAPSHOT_BUFFER_SIZE-this.snapshotsBuffer.size-this.snapshotPending,this.snapshotsTotal-this.snapshotCounter)))}updateDownloadProgress(e){if(e!=null&&this.snapshotsTotal!=null&&this.downloadStartTime!=null){const{onDownloadProgressUpdate:t}=this.props,n=Math.floor(e*100/this.snapshotsTotal),s=e>1?Math.floor((Date.now()-this.downloadStartTime)*(this.snapshotsTotal-e)/e/1e3):null;t(n,s)}}convertSnapshotIntoCsv(e){let t="";const n=e.added.iterator(),{formatter:s}=this.props,i=[];for(;n.hasNext();)i.push(n.next().value);M(this.columns);const{useUnformattedValues:o}=this;for(let a=0;a<i.length;a+=1){const r=i[a];for(let c=0;c<this.columns.length;c+=1){const{type:h,name:u}=this.columns[c];let m=null;if(o){let g=e.getData(r,this.columns[c])??"";g!==""&&x.isDateType(h)&&(g=R.i18n.DateTimeFormat.format(fE,g,R.i18n.TimeZone.getTimeZone(s.timeZone))),m=g.toString()}else{const g=this.getCachedCustomColumnFormatFlag(s,u,h);let p=null;if(!g){const C=e.getFormat(r,this.columns[c]);p=C?.formatString!=null?C:null}p?m=s.getFormattedString(e.getData(r,this.columns[c]),h,u,p):m=s.getFormattedString(e.getData(r,this.columns[c]),h,u)}t+=Yn.csvEscapeString(m),t+=c===this.columns.length-1?`
30
- `:","}}return t}makeSnapshot(e){if(e<=0)return;M(this.gridRangeCounter);let t=0,n=this.gridRanges[this.gridRangeCounter];for(M(this.tableSubscription),M(this.columns);t<e;){M(n),M(n.startRow),M(n.endRow),M(this.rangedSnapshotCounter),M(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(ve.makeCancelable(this.tableSubscription.snapshot(R.RangeSet.ofRange(s,i),this.columns).then(a=>(SE(a),this.handleSnapshotResolved(a,o,s,i),o)).catch(a=>{zn.error(a)}),a=>{zn.info(`snapshot ${a} 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]),t+=1}}handlePortMessage({data:e}){const{download:t,readableStreamPulling:n}=e;if(!this.useBlobFallback){if(t!=null){const{includeColumnHeaders:s}=this;this.makeIframe(`${t}`),this.writeCsvTable(s)}n!=null&&(this.useBlobFallback||(this.streamTimeout!=null&&clearTimeout(this.streamTimeout),this.streamTimeout=setTimeout(this.handleDownloadTimeout,Yn.STREAM_TIMEOUT)))}}handleSnapshotResolved(e,t,n,s){this.snapshotHandlerTimeout=setTimeout(()=>{this.snapshotsBuffer.set(t,e),this.snapshotPending-=1,this.writeSnapshot(t,n,s),this.cancelableSnapshots[t]=null},Yn.SNAPSHOT_HANDLER_TIMEOUT)}makeIframe(e){const t=document.createElement("iframe");t.hidden=!0,t.src=`download/${e}`,t.name="iframe",document.body.appendChild(t),this.iframes.push(t)}render(){return null}}function bE(d){const{group:e,onDelete:t,onColorChange:n,onNameChange:s,validateName:i}=d,{isNew:o}=e,a=b.useRef(e),r=b.useRef(null),c=b.useRef(null),[h,u]=b.useState(!1),[m,g]=b.useState(o?"":e.name),[p,C]=b.useState(o),[f,S]=b.useState(!1),v=m!==e.name?i(m):"",w=o&&!f||v==="",T=b.useCallback(()=>{u(!1)},[]);b.useEffect(function(){p&&r.current&&(r.current.focus(),r.current.select())},[p]),b.useEffect(function(){return()=>{a.current.isNew&&t(a.current)}},[t]),b.useEffect(function(){return h&&(c.current?.click(),c.current?.focus(),window.addEventListener("click",T,!0)),()=>window.removeEventListener("click",T,!0)},[h,T]);const y=()=>{w&&(s(e,m),C(!1))},E=()=>{if(o){t(e);return}g(e.name),C(!1)},D=F=>{S(!0),F.key==="Enter"&&(F.stopPropagation(),y()),F.key===" "&&F.stopPropagation(),F.key==="Escape"&&E()};return p?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"editing-container",children:[l.jsx("input",{ref:r,className:$("form-control",{"is-invalid":!w}),value:m,placeholder:"Group Name",onChange:F=>g(F.target.value),onKeyDown:D,onBlur:()=>S(!0)}),l.jsx(B,{kind:"ghost",icon:Jn,tooltip:"Confirm",onClick:y}),l.jsx(B,{kind:"ghost",icon:zg,tooltip:"Cancel",onClick:E})]}),!w&&l.jsx("p",{className:"mb-0 validate-label-error text-danger",children:v})]}):l.jsxs("div",{className:"group-name-wrapper",children:[l.jsx("span",{className:"column-name",children:m}),l.jsx(B,{className:"p-1 mx-1",kind:"ghost",icon:Ao,tooltip:"Edit",onClick:()=>{C(!0)}}),l.jsxs("span",{className:"right-buttons",children:[l.jsx(B,{kind:"ghost",icon:Jt,tooltip:"Delete group",onClick:()=>t(e)}),l.jsx(B,{kind:"ghost",className:"color-swatch mr-1",icon:e.color!==void 0?l.jsxs("span",{className:"fa-layers",children:[l.jsx(Q,{className:"color-swatch",icon:Na,color:ze.white,transform:"down-1"}),l.jsx(Q,{className:"color-swatch",icon:Na,color:e.color,transform:"shrink-2 down-1"})]}):Kg,tooltip:"Set color",onClick:()=>u(F=>!F)}),h&&l.jsxs(l.Fragment,{children:[l.jsx("input",{"aria-label":"Color input",ref:c,type:"color",list:"presetColors",value:e.color??ze["content-bg"],style:{visibility:"hidden",width:0,height:0,padding:0,border:0},onChange:F=>{e.color=F.target.value,n(e,F.target.value)}}),l.jsxs("datalist",{id:"presetColors",children:[l.jsx("option",{children:ze["content-bg"]}),l.jsx("option",{children:ze.primary}),l.jsx("option",{children:ze.foreground}),l.jsx("option",{children:ze.green}),l.jsx("option",{children:ze.yellow}),l.jsx("option",{children:ze.orange}),l.jsx("option",{children:ze.red}),l.jsx("option",{children:ze.purple}),l.jsx("option",{children:ze.blue}),l.jsx("option",{children:ze["gray-400"]})]})]})]})]})}function wE(){}const vE=b.forwardRef(function(e,t){const{value:n,clone:s,childCount:i,item:o,onVisibilityChange:a,onClick:r,onGroupDelete:c,onGroupColorChange:h,onGroupNameChange:u,validateGroupName:m,handleProps:g}=e,{group:p,modelIndex:C,isVisible:f}=o.data,S=b.useRef(null),v=b.useCallback(T=>{T.buttons===1&&(a([C].flat(),!f),S.current?.focus())},[a,C,f]),w=b.useCallback(T=>{r(n,T)},[r,n]);return l.jsxs("div",{ref:t,className:$("tree-item",{isSelected:o.selected,"two-dragged":i===2,"multiple-dragged":i>2}),onClick:w,...g,children:[l.jsx(B,{ref:S,kind:"ghost",className:"px-1",onClick:wE,onMouseDown:v,onMouseEnter:v,icon:f?Pl:Ah,tooltip:"Toggle visibility"}),l.jsx("span",{className:$("column-name",p&&"column-group"),children:p&&!s?l.jsx(bE,{group:p,onDelete:c,onColorChange:h,onNameChange:u,validateName:m}):n}),l.jsxs("div",{children:[s&&i>1&&l.jsx("span",{className:"item-count",children:i}),l.jsx(tt,{children:"Drag to re-order"}),l.jsx(Q,{icon:ko})]})]})}),TE=vE;function EE(d){return d.parentId!==void 0}function yE(d,e){return Math.round(d/e)}function lm(d,e,t,n,s,i){const o=d.findIndex(a=>a.name===n);if(o===-1){const a=t.get(n);if(a==null)throw new Error(`Column or header group not found: ${n}`);const r=a.childIndexes.flat();return{id:n,selected:i.has(n),children:a.children.map(c=>lm(d,e,t,c,s,i)).sort((c,h)=>{const u=Array.isArray(c.data.visibleIndex)?c.data.visibleIndex[0]:c.data.visibleIndex,m=Array.isArray(h.data.visibleIndex)?h.data.visibleIndex[0]:h.data.visibleIndex;return u-m}),data:{modelIndex:r,visibleIndex:a.getVisibleRange(e),group:a,isVisible:r.some(c=>!s.has(c))}}}return{id:n,children:[],selected:i.has(n),data:{modelIndex:o,visibleIndex:V.getVisibleIndex(o,e),isVisible:!s.has(o)}}}function RE(d,e,t,n,s){const i=[],o=new Set(s),a=new Map(t.map(h=>[h.name,h])),r=new Set(n);let c=0;for(;c<d.length;){const h=V.getModelIndex(c,e),u=d[h].name;let m=t.find(({children:p})=>p.includes(u));for(;m!==void 0&&m.parent!==void 0;)m=a.get(m.parent);const g=lm(d,e,a,m?m.name:u,r,o);i.push(g),Array.isArray(g.data.visibleIndex)?c+=g.data.visibleIndex[1]-g.data.visibleIndex[0]+1:c+=1}return i}function za(d,e,t,n,s){const i=d.findIndex(({id:S})=>S===t),o=d.findIndex(({id:S})=>S===e),a=d[o],r=Xm(d,o,i),c=r[i-1],h=r[i+1],u=yE(n,s),m=a.depth+u,g=xE({previousItem:c,nextItem:h}),p=IE({nextItem:h});let C=m;return m>=g?C=g:m<p&&(C=p),{depth:C,maxDepth:g,minDepth:p,parentId:f()};function f(){return C===0||!c?null:C===c.depth?c.parentId:C>c.depth?c.id:r.slice(0,i).reverse().find(v=>v.depth===C)?.parentId??null}}function xE({previousItem:d,nextItem:e}){return Math.max(d?.depth??0,e?.depth??0)}function IE({nextItem:d}){return d?d.depth:0}function cm(d,e=null,t=0){return d.reduce((n,s,i)=>[...n,{...s,parentId:e,depth:t,index:i},...cm(s.children,s.id,t+1)],[])}function cn(d){return d.every(EE)?[...d]:cm(d)}function dm(d,e){for(let t=0;t<d.length;t+=1){const n=d[t],{id:s,children:i}=n;if(s===e)return n;if(i.length){const o=dm(i,e);if(o)return o}}}function hm(d,e=0){return d.reduce((t,{children:n})=>n.length?hm(n,t+1):t+1,e)}function DE(d,e){const t=dm(d,e);return t?hm(t.children):0}const FE=[Ln.Down,Ln.Right,Ln.Up,Ln.Left],NE=[Ln.Left,Ln.Right];function ME(d,e,t){return(n,{currentCoordinates:s,context:{active:i,over:o,collisionRect:a,droppableRects:r,droppableContainers:c}})=>{if(FE.includes(n.code)){if(!i||!a)return;n.preventDefault();const{current:{items:h,offset:u}}=d;if(NE.includes(n.code)&&o?.id!=null){const{depth:C,maxDepth:f,minDepth:S}=za(h,i.id,o.id,u,t);switch(n.code){case Ln.Left:if(C>S)return{...s,x:s.x-t};break;case Ln.Right:if(C<f)return{...s,x:s.x+t};break}return}const m=[];c.forEach(C=>{if(C?.disabled||C.id===o?.id)return;const f=r.get(C.id);if(f)switch(n.code){case Ln.Down:a.top<f.top&&m.push(C);break;case Ln.Up:a.top>f.top&&m.push(C);break}});const g=Zm({active:i,collisionRect:a,pointerCoordinates:null,droppableRects:r,droppableContainers:m});let p=Qm(g,"id");if(p===o?.id&&g.length>1&&(p=g[1].id),p!=null&&o?.id!=null){const C=r.get(i.id),f=r.get(p),S=c.get(p);if(C&&f&&S){const v=h.findIndex(({id:E})=>E===p),w=h[v],T=h.findIndex(({id:E})=>E===i.id),y=h[T];if(w!=null&&y!=null){const{depth:E}=za(h,i.id,p,(w.depth-y.depth)*t,t),F=v>T?1:-1,N=e?(a.height-C.height)/2:0;return{x:f.left+E*t,y:f.top+F*N}}}}}}}class kE extends Jm{static activators=[{eventName:"onPointerDown",handler:({nativeEvent:e})=>!(!e.isPrimary||e.button!==0||AE(e.target))}]}const OE=["button","input","textarea","select","option"];function AE(d){return!!(d?.tagName!=null&&OE.includes(d.tagName.toLowerCase()))}function um(d){const{clone:e=!1,depth:t,disableInteraction:n=!1,ghost:s=!1,handleProps:i,value:o,dragRef:a=null,wrapperRef:r=null,renderItem:c,item:h,childCount:u}=d,m=b.useMemo(()=>Array(t).fill(0).map((p,C)=>l.jsx("span",{className:"depth-line"},`depth-line-${C}`)),[t]),g=b.useMemo(()=>({ref:a,clone:e,value:o,item:h,childCount:u,handleProps:i}),[a,e,o,h,u,i]);return l.jsxs("li",{className:$("item-wrapper",{clone:e,ghost:s,disableInteraction:n}),ref:r,children:[!e&&m,c(g)]},o)}um.displayName="TreeItem";const LE=({isSorting:d,wasDragging:e})=>!(d||e);function Gd({id:d,depth:e,...t}){const{attributes:n,isDragging:s,isSorting:i,listeners:o,setDraggableNodeRef:a,setDroppableNodeRef:r,transform:c,transition:h}=eg({id:d,animateLayoutChanges:LE}),u=rl.Translate.toString(c),m=b.useMemo(()=>({transform:u,transition:h}),[u,h]),g=b.useMemo(()=>({...n,...o,style:m}),[n,o,m]);return l.jsx(um,{dragRef:a,wrapperRef:r,depth:e,ghost:s,disableInteraction:i,handleProps:g,...t})}const PE={keyframes({transform:d}){return[{opacity:1,transform:rl.Transform.toString(d.initial)},{opacity:0,transform:rl.Transform.toString({...d.final,x:d.final.x+5,y:d.final.y+5})}]},easing:"ease-out",sideEffects({active:d}){d.node.animate([{opacity:0},{opacity:1}],{duration:Lc.duration,easing:Lc.easing})}};let ma=null;function _E(d){return ma==null&&d.activeNodeRect&&d.activatorEvent instanceof PointerEvent&&(ma=Math.floor((d.activatorEvent.clientY-d.activeNodeRect.top)/d.activeNodeRect.height)*d.activeNodeRect.height),d.activeNodeRect||(ma=null),{...d.transform,y:d.transform.y+(ma??0)}}function jE({items:d,renderItem:e,indentationWidth:t=30,indicator:n=!1,activeId:s,overId:i,offsetLeft:o}){const a=tg(),r=b.useRef(a);b.useEffect(function(){r.current=a},[a]),b.useEffect(function(){r.current.measureDroppableContainers(d.map(({id:g})=>g))},[d]);const c=s!=null&&i!=null?za(d,s,i,o,t):null,h=b.useRef({items:d,offset:o}),u=s!=null?d.find(({id:m})=>m===s):null;return b.useEffect(()=>{h.current={items:d,offset:o}},[d,o]),l.jsxs(l.Fragment,{children:[l.jsx("div",{className:$("tree-container",s!=null&&"marching-ants"),children:d.map(m=>{const{id:g,depth:p}=m;return l.jsx(Gd,{id:g,value:g,depth:g===s&&c?c.depth:p,item:m,renderItem:e},g)})}),ng.createPortal(l.jsx(sg,{dropAnimation:PE,modifiers:[_E],className:"visibility-ordering-list",children:s!=null&&u?l.jsx(Gd,{id:s,depth:u.depth,clone:!0,childCount:DE(d,s)+1,value:s.toString(),renderItem:e,item:u}):null}),document.body)]})}const HE={droppable:{strategy:cg.Always}},VE={activationConstraint:{distance:5}};function BE({items:d,indicator:e=!1,indentationWidth:t=30,onDragStart:n,onDragEnd:s,renderItem:i}){const[o,a]=b.useState(null),[r,c]=b.useState(null),[h,u]=b.useState(0),m=b.useMemo(()=>{const F=cn(d);return o!=null?F.filter(({id:N,selected:_})=>N===o||!_):F},[o,d]),g=o!=null&&r!=null?za(m,o,r,h,t):null,p=b.useRef({items:m,offset:h}),C=b.useMemo(()=>({coordinateGetter:ME(p,e,t)}),[t,e]),f=ig(Pc(kE,VE),Pc(dg,C)),S=b.useMemo(()=>m.map(({id:F})=>F),[m]);b.useEffect(()=>{p.current={items:m,offset:h}},[m,h]);const v=b.useCallback(({active:{id:F}})=>{a(F),c(F),n?.(F),document.body.style.setProperty("cursor","grabbing")},[n]),w=b.useCallback(({delta:F})=>{u(F.x)},[]),T=b.useCallback(({over:F})=>{c(F?.id??null)},[]),y=b.useCallback(()=>{c(null),a(null),u(0),document.body.style.setProperty("cursor","")},[]),E=b.useCallback(({active:F,over:N})=>{if(y(),g&&N){const{depth:_,parentId:P}=g,U=JSON.parse(JSON.stringify(cn(d))),O=U.findIndex(({id:A})=>A===N.id),j=U.findIndex(({id:A})=>A===F.id),k=U[j];U[j]={...k,depth:_,parentId:P},s?.(k,{...U[O],parentId:g.parentId})}},[d,s,g,y]),D=b.useCallback(()=>{y()},[y]);return l.jsx(og,{sensors:f,collisionDetection:ag,measuring:HE,onDragStart:v,onDragMove:w,onDragOver:T,onDragEnd:E,onDragCancel:D,children:l.jsx(rg,{items:S,strategy:lg,children:l.jsx(jE,{items:m,renderItem:i,indicator:e,indentationWidth:t,activeId:o,overId:r,offsetLeft:h})})})}function UE(d,e,t,n,s,i,o,a){const r=s.map((v,w)=>({...v,index:w}));let c=[],h=n;const u=i[0].data.visibleIndex,m=r.findIndex(({id:v})=>v===d.id),g=r.findIndex(({id:v})=>v===e.id);let p=Array.isArray(u)?u[1]+1:u+1;h=Rs(i[0],e.parentId,h);for(let v=1;v<i.length;v+=1){const{data:{visibleIndex:w}}=i[v];c=V.moveItemOrRange(w,p,c,!0),p+=Array.isArray(w)?w[1]-w[0]+1:1,h=Rs(i[v],e.parentId,h)}const C=[Array.isArray(u)?u[0]:u,p-1],f=Array.isArray(e.data.visibleIndex)?e.data.visibleIndex[0]:e.data.visibleIndex;let S=V.getVisibleIndex(f,c);return m>g&&S>f&&(S-=1),e.children.length>0&&(Array.isArray(u)?u[0]:u)<S&&(S-=1),C[0]<S&&(S-=C[1]-C[0]),c=V.moveItemOrRange(C,He(S,o,a),c),{groups:h,movedColumns:t.concat(c)}}function Rs(d,e,t){if(d.parentId===e)return[...t];let n=t.map(r=>new Sn(r));const s=new Map(n.map(r=>[r.name,r])),i=n.find(r=>r.name===d.parentId),o=n.find(r=>r.name===e),a=n.find(r=>r.name===d.id);if(i!=null&&(i.children=i.children.filter(r=>r!==d.id),i.children.length===0)){const r=new Set([i.name]),{parent:c=""}=i;let h=s.get(c);for(h?.removeChildren([i.name]);h&&h.children.length===0;){r.add(h.name);const u=h?.parent??"",m=s.get(u);m?.removeChildren([h.name]),h=m}n=n.filter(({name:u})=>!r.has(u))}return o?.addChildren([d.id]),a?.setParent(e??void 0),n}const $E=150;class mt extends b.Component{static SORTING_OPTIONS={DSC:"DSC",ASC:"ASC"};static MOVE_OPTIONS={TOP:"TOP",BOTTOM:"BOTTOM",UP:"UP",DOWN:"DOWN"};constructor(e){super(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()}list;debouncedSearchColumns=Ye(this.searchColumns,$E);resetVisibilityOrdering(){const{model:e,onReset:t,onMovedColumnsChanged:n,onColumnHeaderGroupChanged:s}=this.props;this.setState({selectedColumns:new Set,lastSelectedColumn:"",searchFilter:""}),t(),s(e.initialColumnHeaderGroups),n(e.initialMovedColumns)}resetSelection(){this.setState({selectedColumns:new Set,lastSelectedColumn:""})}handleSearchInputChange(e){const t=e.target.value;if(this.setState({searchFilter:t}),!t){this.debouncedSearchColumns.cancel(),this.resetSelection();return}this.debouncedSearchColumns(t)}searchColumns(e){const t=cn(this.getTreeItems()),s=t.filter(({id:o,data:a})=>!(a.group?.isNew??!1)&&o.toLowerCase().includes(e.toLowerCase())).map(({id:o})=>o),i=t.findIndex(({id:o})=>o.toLowerCase().includes(e.toLowerCase()));this.addColumnToSelected(s,!1),s.length>0&&this.list?.querySelectorAll(".item-wrapper")[i]?.scrollIntoView({block:"center"})}moveSelectedColumns(e){const{columnHeaderGroups:t}=this.props,{selectedColumns:n}=this.state,s=cn(this.getTreeItems());let i=this.getFirstMovableIndex(),o=this.getLastMovableIndex();M(i),M(o);const a=this.getSelectedParentItems();e===mt.MOVE_OPTIONS.UP||e===mt.MOVE_OPTIONS.TOP||a.reverse();let c=[],h=t;for(let u=0;u<a.length;u+=1){const{id:m,parentId:g,depth:p,data:{visibleIndex:C}}=a[u];switch(e){case mt.MOVE_OPTIONS.TOP:{c=V.moveItemOrRange(C,i,c,!0);const f=Array.isArray(C)?C[1]-C[0]+1:1;i+=f,h=Rs(a[u],null,h);break}case mt.MOVE_OPTIONS.BOTTOM:{c=V.moveItemOrRange(C,o,c,!0);const f=Array.isArray(C)?C[1]-C[0]+1:1;o-=f,h=Rs(a[u],null,h);break}case mt.MOVE_OPTIONS.UP:{const f=s.findIndex(w=>w.id===m),S=s.map((w,T)=>T<f&&!n.has(w.id)).lastIndexOf(!0),v=s[S];if(v!=null&&v.parentId!==g)if(Math.abs(v.depth-p)>1){const w=s.map((y,E)=>E<S&&y.depth===p).lastIndexOf(!0),T=s[w];h=Rs(a[u],T.id,h)}else h=Rs(a[u],v.parentId,h);else{const w=He(Array.isArray(C)?C[0]-1:C-1,i,o);c=V.moveItemOrRange(C,w,c,!1);const T=Array.isArray(C)?C[1]-C[0]+1:1;i+=T}break}case mt.MOVE_OPTIONS.DOWN:{const f=s.findIndex(T=>T.id===m),S=s.find((T,y)=>y>f&&!n.has(T.id));if(S?.parentId!==g){const T=s.find(y=>y.id===g);h=Rs(a[u],T?.parentId??null,h);break}else if(S?.children.length>0){h=Rs(a[u],S.id,h);break}const v=He(Array.isArray(C)?C[0]+1:C+1,i,o);c=V.moveItemOrRange(C,v,c,!1);const w=Array.isArray(C)?C[1]-C[0]+1:1;o-=w;break}}}return{newMoves:c,groups:h}}handleMoveColumns(e){const{onMovedColumnsChanged:t,movedColumns:n,onColumnHeaderGroupChanged:s}=this.props,{newMoves:i,groups:o}=this.moveSelectedColumns(e);let a;e===mt.MOVE_OPTIONS.TOP&&(a=()=>{this.list?.parentElement?.scroll({top:0})}),e===mt.MOVE_OPTIONS.BOTTOM&&(a=()=>{this.list?.parentElement?.scroll({top:this.list.parentElement.scrollHeight})}),s(o),i.length>0&&t(n.concat(i),a)}getSortMoves(e,t,n){const s=[...e],i=t===mt.SORTING_OPTIONS.ASC;s.sort((r,c)=>{const h=r.id.toUpperCase(),u=c.id.toUpperCase();return zt.sort(h,u,i)});let o=[...n],a=Math.min(...s.flatMap(r=>{const{modelIndex:c}=r.data;return Array.isArray(c)?V.getVisibleIndexes(c,o):V.getVisibleIndex(c,o)}));for(let r=0;r<s.length;r+=1){const c=s[r],{modelIndex:h}=c.data,u=Array.isArray(h)?V.getVisibleIndexes(h,o):V.getVisibleIndex(h,o);o=Array.isArray(u)?V.moveRange([Math.min(...u),Math.max(...u)],a,o,!0):V.moveItem(u,a,o),Array.isArray(u)&&(o=this.getSortMoves(c.children,t,o)),a+=Array.isArray(h)?h.length:1}return o}handleSortColumns(e){const{model:t,onMovedColumnsChanged:n}=this.props,s=this.getSortMoves(this.getTreeItems(),e,t.initialMovedColumns);n(s)}handleItemClick(e,t){if(t.stopPropagation(),t.target instanceof HTMLElement&&(t.target.tagName==="BUTTON"||t.target.tagName==="INPUT"))return;t.currentTarget.focus();const{selectedColumns:n,lastSelectedColumn:s}=this.state,i=V.isModifierKeyDown(t),o=t.shiftKey,a=n.has(e),r=[e];if(a&&i){this.removeColumnFromSelected(e);return}const c=cn(this.getTreeItems());if(a&&!o&&s===e){const h=c.find(({id:m})=>m===e);if(M(h),cn(h.children).length+1===n.size){this.resetSelection();return}}if(o){const h=c.findIndex(m=>m.id===e),u=c.findIndex(m=>m.id===s);r.push(...c.slice(Math.min(u,h),Math.max(u,h)+1).map(m=>m.id))}this.addColumnToSelected(r,i||o),this.setState({lastSelectedColumn:e})}addColumnToSelected(e,t){const{selectedColumns:n}=this.state,s=new Set(t?[...n.values()].concat(e):e);cn(this.getTreeItems()).forEach(({id:o,children:a})=>{s.has(o)&&a.forEach(r=>s.add(r.id))}),this.setState({selectedColumns:s})}removeColumnFromSelected(e){const{selectedColumns:t}=this.state,n=cn(this.getTreeItems()),s=n.find(({id:o})=>o===e);M(s);let i=n.find(({id:o})=>o===s.parentId);for(cn(s?.children).forEach(o=>t.delete(o.id));i!=null;){t.delete(i.id);const o=i.parentId;i=n.find(({id:a})=>a===o)}t.delete(e),this.setState({selectedColumns:new Set(t)})}handleDragStart(e){const{selectedColumns:t}=this.state;t.has(e)||this.addColumnToSelected([e],!1)}handleDragEnd(e,t){const{movedColumns:n,onMovedColumnsChanged:s,columnHeaderGroups:i,onColumnHeaderGroupChanged:o}=this.props,a=this.getSelectedParentItems(),r=cn(this.getTreeItems()).map((g,p)=>({...g,index:p})),c=this.getFirstMovableIndex(),h=this.getLastMovableIndex();M(c),M(h);const{groups:u,movedColumns:m}=UE(e,t,n,i,r,a,c,h);o(u),s(m)}handleGroupNameChange(e,t){const{columnHeaderGroups:n,onColumnHeaderGroupChanged:s}=this.props,i=[...n],o=e.name,a=i.findIndex(({name:u})=>u===o),r=i[a];M(r);const c=new Sn(r);c.name=t,i.splice(a,1,c);const h=i.findIndex(({name:u})=>u===c.parent);if(h>=0){const u=new Sn(i[h]);u.removeChildren([o]),u.addChildren([t]),i.splice(h,1,u)}s(i)}handleGroupColorChange=Ls((e,t)=>{const{columnHeaderGroups:n,onColumnHeaderGroupChanged:s}=this.props,i=[...n],o=new Sn({...e,color:t});i.splice(i.findIndex(({name:a})=>a===e.name),1,o),s(i)},250);handleGroupDelete(e){const{columnHeaderGroups:t,onColumnHeaderGroupChanged:n}=this.props,s=t.filter(o=>o.name!==e.name),i=s.findIndex(o=>o.name===e.parent);if(i>=0){const o=new Sn(s[i]);o.addChildren(e.children),o.removeChildren([e.name]),s.splice(i,1,o)}n(s)}handleGroupCreate(){const{movedColumns:e,onMovedColumnsChanged:t,onColumnHeaderGroupChanged:n}=this.props,{newMoves:s,groups:i}=this.moveSelectedColumns(mt.MOVE_OPTIONS.TOP),o=i.filter(u=>!u.isNew),a=this.getSelectedParentItems(),r=a.map(u=>u.data.modelIndex).flat().filter(u=>u>=0),c=`${Sn.NEW_GROUP_PREFIX}-${Date.now()}`,h=new Sn({name:c,children:a.map(({id:u})=>u),depth:0,childIndexes:[...new Set(r)]});t(e.concat(s),()=>{this.list?.parentElement?.scroll({top:0})}),n(o.concat([h])),this.resetSelection()}validateGroupName(e){const{model:t,columnHeaderGroups:n}=this.props,{columns:s}=t;return un.isValidColumnName(e)?s.some(({name:i})=>i===e)||n.some(({name:i})=>i===e)?"Duplicate name":"":"Invalid name"}renderItem=ge(({value:e,clone:t,item:n,ref:s,handleProps:i})=>{const{onColumnVisibilityChanged:o}=this.props,{selectedColumns:a}=this.state;let r=e;return t&&(r=this.getSelectedParentItems().map(({id:h})=>h).join(", ")),l.jsx(TE,{ref:s,value:r,clone:t,item:n,childCount:a.size,onVisibilityChange:o,onClick:this.handleItemClick,onGroupDelete:this.handleGroupDelete,onGroupColorChange:this.handleGroupColorChange,onGroupNameChange:this.handleGroupNameChange,validateGroupName:this.validateGroupName,handleProps:i})});getMemoizedFirstMovableIndex=ge((e,t,n)=>{for(let s=0;s<t.length;s+=1){const i=V.getModelIndex(s,n);if(e.isColumnMovable(i))return s}return null});getFirstMovableIndex(){const{model:e,movedColumns:t}=this.props;return this.getMemoizedFirstMovableIndex(e,e.columns,t)}getMemoizedLastMovableIndex=ge((e,t,n)=>{for(let s=t.length-1;s>=0;s-=1){const i=V.getModelIndex(s,n);if(e.isColumnMovable(i))return s}return null});getLastMovableIndex(){const{model:e,movedColumns:t}=this.props;return this.getMemoizedLastMovableIndex(e,e.columns,t)}memoizedGetTreeItems=ge((e,t,n,s,i)=>RE(e,t,n,s,[...i.values()]));getTreeItems(){const{model:e,movedColumns:t,hiddenColumns:n,columnHeaderGroups:s}=this.props,{selectedColumns:i}=this.state;return this.memoizedGetTreeItems(e.columns,t,s,n,i)}getSelectedParentItems(){const{selectedColumns:e}=this.state;return cn(this.getTreeItems()).filter(({id:n,parentId:s})=>e.has(n)&&!e.has(s??""))}makeVisibilityOrderingList=ge((e,t)=>{const{movedColumns:n}=this.props,s=[],i=this.getFirstMovableIndex(),o=this.getLastMovableIndex(),a=t.findIndex(({data:h})=>Array.isArray(h.visibleIndex)?h.visibleIndex[0]===i:h.visibleIndex===i),r=t.findIndex(({data:h})=>Array.isArray(h.visibleIndex)?h.visibleIndex[1]===o:h.visibleIndex===o),c=t.slice(a,r+1);if(i==null||o===null){for(let h=0;h<e.length;h+=1){const u=V.getModelIndex(h,n),m=e[u];s.push(this.renderImmovableItem(m.name))}return s}for(let h=0;h<i;h+=1){const u=V.getModelIndex(h,n),m=e[u];s.push(this.renderImmovableItem(m.name))}i!==null&&i>0&&s.push(l.jsx("hr",{},"top-horizontal-divider")),s.push(l.jsx(BE,{items:c,renderItem:this.renderItem,onDragStart:this.handleDragStart,onDragEnd:this.handleDragEnd},"movable-items")),o!=null&&o<e.length-1&&s.push(l.jsx("hr",{},"bottom-horizontal-divider"));for(let h=o+1;h<e.length;h+=1){const u=V.getModelIndex(h,n),m=e[u];s.push(this.renderImmovableItem(m.name))}return s});renderImmovableItem=ge(e=>l.jsx("div",{className:"visibility-ordering-list-item immovable",children:l.jsx("div",{className:"column-item",children:l.jsx("span",{className:"column-name",children:e})})},e));render(){const{model:e,hiddenColumns:t,onColumnVisibilityChanged:n}=this.props,{selectedColumns:s,searchFilter:i}=this.state,o=s.size>0,a=this.getTreeItems(),r=new Map(cn(a).map(C=>[C.id,C.data.modelIndex])),c=new Set(t),h=[...new Set(o?[...s.values()].map(C=>r.get(C)).filter(C=>C!=null).flat():a.map(C=>C.data.modelIndex).flat())],u=h.some(C=>!c.has(C)),m=u?"Hide All":"Show All",g=u?"Hide Selected":"Show Selected",p=this.makeVisibilityOrderingList(e.columns,a);return l.jsxs("div",{role:"menu",className:"visibility-ordering-builder",tabIndex:0,children:[l.jsxs("div",{className:"top-menu",children:[l.jsx(B,{kind:"ghost",className:"toggle-visibility-btn",onClick:()=>{n(h,!u)},icon:u?Pl:Ah,tooltip:"Toggle column visibility",children:o?g:m}),l.jsx(_s,{className:"visibility-search",value:i,matchCount:i?s.size:void 0,onChange:this.handleSearchInputChange})]}),l.jsxs("div",{className:"top-menu",children:[l.jsx(B,{kind:"ghost",icon:si,tooltip:"Reset to default",onClick:()=>{this.resetVisibilityOrdering()},children:"Reset"}),l.jsx("span",{className:"vertical-divider"}),l.jsx(B,{kind:"ghost",icon:Al,tooltip:"Sort ascending",onClick:()=>{this.handleSortColumns(mt.SORTING_OPTIONS.ASC)}}),l.jsx(B,{kind:"ghost",icon:Ll,tooltip:"Sort descending",onClick:()=>{this.handleSortColumns(mt.SORTING_OPTIONS.DSC)}}),l.jsx("span",{className:"vertical-divider"}),l.jsxs(B,{kind:"ghost",tooltip:"Create group from selection",disabled:!o,onClick:this.handleGroupCreate,children:[l.jsxs("span",{className:"fa-layers",style:{marginRight:"0.75rem"},children:[l.jsx(Q,{mask:qg,icon:Ui,transform:"right-7 down-5 shrink-6"}),l.jsx(Q,{icon:Yg,transform:"right-8 down-6 shrink-8"})]}),"Group"]}),l.jsx("span",{className:"vertical-divider"}),l.jsx(B,{kind:"ghost",icon:Xg,tooltip:"Move selection up",onClick:()=>{this.handleMoveColumns(mt.MOVE_OPTIONS.UP)},disabled:!o}),l.jsx(B,{kind:"ghost",icon:Zg,tooltip:"Move selection down",onClick:()=>{this.handleMoveColumns(mt.MOVE_OPTIONS.DOWN)},disabled:!o}),l.jsx(B,{kind:"ghost",icon:Qg,tooltip:"Move selection to top",onClick:()=>{this.handleMoveColumns(mt.MOVE_OPTIONS.TOP)},disabled:!o}),l.jsx(B,{kind:"ghost",icon:Jg,tooltip:"Move selection to bottom",onClick:()=>{this.handleMoveColumns(mt.MOVE_OPTIONS.BOTTOM)},disabled:!o})]}),l.jsx("div",{role:"menu",className:$("visibility-ordering-list"),children:l.jsx("div",{className:"column-list",ref:C=>{this.list=C},children:p})})]})}}const WE=mt;class GE extends b.PureComponent{static createSearchFilter(e,t,n,s){const i=s?n.filter(o=>!t.includes(o.name)).map(o=>o.name):t;if(e&&i.length>0){const o=R.FilterValue.ofString(e);return i.length===n.length?R.FilterCondition.search(o):R.FilterCondition.search(o,n.filter(r=>i.includes(r.name)).map(r=>r.filter()))}}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=J.createRef(),this.state={isConfigureColumnsShown:!1}}searchField;focus(){this.searchField.current?.focus()}handleSearchValueChange(e){const{onChange:t,selectedColumns:n,invertSelection:s}=this.props;t(e.target.value,n,s)}sendColumnChange(e,t){const{onChange:n,value:s}=this.props;n(s,e,t)}setInvertSelection(e){const{onChange:t,value:n}=this.props;t(n,[],e)}toggleColumn(e){const{selectedColumns:t,invertSelection:n}=this.props;if(t.includes(e))this.sendColumnChange(t.filter(s=>s!==e),n);else{const s=t.slice();s.push(e),this.sendColumnChange(s,n)}}selectAll(){this.setInvertSelection(!0)}clear(){this.setInvertSelection(!1)}selectNumbers(){const{columns:e}=this.props;this.sendColumnChange(e.filter(t=>x.isNumberType(t.type)).map(t=>t.name),!1)}render(){const{value:e,selectedColumns:t,invertSelection:n,columns:s}=this.props,{isConfigureColumnsShown:i}=this.state,o=t.length===0&&n===!0||t.length===s.length&&n===!1,a=t.length===0&&n===!1||t.length===s.length&&n===!0;let r;return o?r=l.jsxs(l.Fragment,{children:[l.jsx(Q,{icon:Na,mask:Lr,transform:"shrink-2 down-5 right-7"}),l.jsx(Q,{icon:ep,className:"text-primary",transform:"shrink-4 down-5 right-7"})]}):a?r=l.jsxs(l.Fragment,{children:[l.jsx(Q,{icon:Ui,mask:Lr,transform:"shrink-1 down-5 right-7"}),l.jsx(Q,{icon:$c,className:"text-danger",transform:"shrink-4 down-5 right-7"})]}):r=l.jsxs(l.Fragment,{children:[l.jsx(Q,{icon:Na,mask:Lr,transform:"shrink-2 down-5 right-7"}),l.jsx(Q,{icon:tp,className:"text-primary",transform:"shrink-4 down-5 right-7"})]}),l.jsxs("div",{className:"cross-column-container",children:[l.jsx(_s,{className:"cross-column-search",placeholder:"Search Data...",value:e,onChange:this.handleSearchValueChange,ref:this.searchField}),l.jsxs("button",{type:"button",className:"btn btn-link btn-link-icon px-2",onClick:()=>{i?this.setState({isConfigureColumnsShown:!1}):this.setState({isConfigureColumnsShown:!0})},children:[l.jsx("div",{className:"fa-layers",children:r}),l.jsx(tt,{children:"Configure Columns"}),l.jsx(hi,{isShown:i,className:"cross-column-popper",onExited:()=>{this.setState({isConfigureColumnsShown:!1})},closeOnBlur:!0,interactive:!0,children:l.jsxs("div",{className:"cross-column-popup",children:["Searched Columns",l.jsx("div",{className:"cross-column-scroll",children:s.map(c=>l.jsxs(J.Fragment,{children:[l.jsx(Zt,{className:"cross-column-checkbox",checked:n?!t.includes(c.name):t.includes(c.name),onChange:()=>this.toggleColumn(c.name),children:c.name}),c.type.substring(c.type.lastIndexOf(".")+1)]},c.name))}),l.jsxs("div",{className:"cross-column-button-bar",children:[l.jsx("button",{type:"button",className:"btn btn-link",onClick:this.selectAll,children:"Select All"}),l.jsx("button",{type:"button",className:"btn btn-link",onClick:this.clear,children:"Clear"}),l.jsx("button",{type:"button",className:"btn btn-link",onClick:this.selectNumbers,children:"Numbers Only"})]}),a&&l.jsxs("p",{className:"text-danger",children:[l.jsx(Q,{icon:$c})," Select at least one column to search."]})]})})]})]})}}const ga=GE;const fs=Z.module("PartitionSelectorSearch"),zE=150;class pc extends b.Component{static MAX_VISIBLE_ITEMS=12;static defaultProps={initialPageSize:100,onSelect:()=>{},onListResized:()=>{}};static propTypes={getFormattedString:I.func.isRequired,table:I.shape({addEventListener:I.func.isRequired,removeEventListener:I.func.isRequired,columns:I.arrayOf(I.shape({name:I.string.isRequired,type:I.string.isRequired,filter:I.func.isRequired})),size:I.number.isRequired,applyFilter:I.func.isRequired,setViewport:I.func.isRequired}).isRequired,initialPageSize:I.number,onSelect:I.func,onListResized:I.func};static handleError(e){e instanceof $i||fs.error(e)}constructor(e){super(e),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}}componentDidMount(){this.startListening()}componentDidUpdate(e,t){const{isLoading:n,itemCount:s}=this.state,{onListResized:i}=this.props;(s!==t.itemCount||n!==t.isLoading)&&i()}componentWillUnmount(){this.debounceUpdateFilter.cancel(),this.stopListening()}itemList;searchInput;timer;handleKeyDown(e){if(this.itemList==null)return!1;const{items:t,itemCount:n}=this.state;switch(e.key){case"Enter":{let s=null;if(t.length>0)s=t[0].value;else{const{text:i}=this.state;s=i.trim()}if(s.length>0){const{onSelect:i}=this.props;i(s)}return e.stopPropagation(),e.preventDefault(),!0}case"ArrowDown":return n>0&&this.itemList.focusItem(1),e.stopPropagation(),e.preventDefault(),!0;default:return!1}}handleListKeydown(e){switch(e.key){case"Escape":break;default:this.focus();break}}handleFilterChange(){fs.debug2("handleFilterChange");const{table:e}=this.props,t=e.size;this.setState({itemCount:t,isLoading:!0})}handleInputFocus(){this.itemList&&this.itemList.focusItem(0)}handleSelect(e){fs.debug2("handleSelect",e);const{onSelect:t}=this.props,{offset:n,items:s}=this.state,i=e-n;if(i<0||s.length<=i){fs.error("No data for item",e);return}const{value:o}=s[i];t(o)}handleTableUpdate(e){const t=e.detail,{offset:n}=t,s=[],{getFormattedString:i,table:o}=this.props,a=o.columns[0];for(let c=0;c<t.rows.length;c+=1){const u=t.rows[c].get(a),m=i(u,a.type,a.name);s.push({displayValue:m,value:u})}const r=o.size;fs.debug2("handleTableUpdate",r,n,s.length),this.setState({itemCount:r,items:s,offset:n,isLoading:!1})}handleTextChange(e){fs.debug2("handleTextChange");const{value:t}=e.target;this.setState({text:t}),this.debounceUpdateFilter()}handleViewportChange(e,t){fs.debug2("handleViewportChange",e,t);const n=Math.max(1,t-e),s=Math.max(0,e-n),i=t+n,{table:o}=this.props;o.setViewport(s,i)}debounceUpdateFilter=Ye(()=>{this.updateFilter()},zE);focus(){this.searchInput&&this.searchInput.focus()}startListening(){const{initialPageSize:e,table:t}=this.props;t.addEventListener(R.Table.EVENT_UPDATED,this.handleTableUpdate),t.addEventListener(R.Table.EVENT_FILTERCHANGED,this.handleFilterChange),t.setViewport(0,e)}stopListening(){const{table:e}=this.props;e.removeEventListener(R.Table.EVENT_UPDATED,this.handleTableUpdate),e.removeEventListener(R.Table.EVENT_FILTERCHANGED,this.handleFilterChange)}updateFilter(){const{initialPageSize:e,table:t}=this.props,{text:n}=this.state,s=n.trim(),i=[];if(s.length>0){const a=t.columns[0].filter().invoke("matches",R.FilterValue.ofString(`(?s)(?i).*\\Q${s}\\E.*`));i.push(a)}fs.debug2("updateFilter",i),t.applyFilter(i),t.setViewport(0,e)}render(){const{isLoading:e,itemCount:t,items:n,offset:s,text:i}=this.state,o=Math.min(t,pc.MAX_VISIBLE_ITEMS)*Bt.DEFAULT_ROW_HEIGHT+11;return l.jsxs("div",{className:"iris-grid-partition-selector-search",children:[l.jsx("div",{className:"search-container",children:l.jsx("input",{type:"text",ref:a=>{this.searchInput=a},value:i,placeholder:"Available Partitions",onChange:this.handleTextChange,onFocus:this.handleInputFocus,onKeyDown:this.handleKeyDown,className:"form-control input-partition"})}),!e&&t>0&&l.jsx("div",{className:"iris-grid-partition-selector-search-list",onKeyDown:this.handleListKeydown,role:"presentation",style:{height:o},children:l.jsx(Bt,{ref:a=>{this.itemList=a},itemCount:t,items:n,offset:s,onSelect:this.handleSelect,onViewportChange:this.handleViewportChange})}),!e&&t===0&&l.jsx("div",{className:"iris-grid-partition-selector-search-empty",children:"No results"}),e&&l.jsxs("div",{className:"iris-grid-partition-selector-loading",children:[l.jsx(yn,{})," Loading..."]})]})}}const KE=pc;const Ei=Z.module("IrisGridPartitionSelector"),qE=250;class YE extends b.Component{static defaultProps={onAppend:()=>{},onChange:()=>{},onFetchAll:()=>{},onDone:()=>{},partition:""};constructor(e){super(e),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:t}=e;this.state={partition:t}}componentWillUnmount(){this.debounceUpdate.cancel()}searchMenu;selectorSearch;handleAppendClick(){Ei.debug2("handleAppendClick");const{onAppend:e}=this.props,{partition:t}=this.state;e(t)}handleCloseClick(){Ei.debug2("handleCloseClick"),this.sendDone()}handleIgnoreClick(){Ei.debug2("handleIgnoreClick"),this.sendFetchAll()}handlePartitionChange(e){Ei.debug2("handlePartitionChange");const{value:t}=e.target;this.setState({partition:t}),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()}debounceUpdate=Ye(()=>{this.sendUpdate()},qE);sendDone(){this.debounceUpdate.flush();const{onDone:e}=this.props;e()}sendUpdate(){Ei.debug2("sendUpdate");const{onChange:e}=this.props,{partition:t}=this.state;e(t)}sendFetchAll(){Ei.debug2("sendFetchAll"),this.debounceUpdate.cancel();const{onFetchAll:e}=this.props;e()}render(){const{columnName:e,getFormattedString:t,onDone:n,table:s}=this.props,{partition:i}=this.state,o=l.jsx(KE,{getFormattedString:t,table:s,onSelect:this.handlePartitionSelect,onListResized:this.handlePartitionListResized,ref:a=>{this.selectorSearch=a}},"search");return l.jsxs("div",{className:"iris-grid-partition-selector",children:[l.jsx("div",{className:"status-message",children:l.jsxs("span",{children:['Filtering "',e,'" partition to']})}),l.jsxs("div",{className:"input-group",children:[l.jsx("input",{type:"text",value:i,onChange:this.handlePartitionChange,className:"form-control input-partition"}),l.jsx("div",{className:"input-group-append",children:l.jsxs("button",{type:"button",className:"btn btn-outline-primary",children:[l.jsx(Q,{icon:Pn}),l.jsx(tt,{children:"Partitions"}),l.jsx(es,{ref:a=>{this.searchMenu=a},actions:[{menuElement:o}],onMenuOpened:this.handleSearchOpened,onMenuClosed:this.handleSearchClosed})]})})]}),l.jsx("div",{className:"iris-grid-partition-selector-spacer"}),l.jsx("button",{type:"button",className:"btn btn-outline-primary btn-ignore",onClick:this.handleIgnoreClick,children:"Ignore & Fetch All"}),l.jsx("button",{type:"button",className:"btn btn-outline-primary btn-append",onClick:this.handleAppendClick,children:"Append Command"}),l.jsx("button",{type:"button",className:"btn btn-link btn-link-icon btn-close",onClick:n,children:l.jsx(Q,{icon:qi})})]})}}const XE=YE;const ZE=Z.module("SelectDistinctBuilder");class QE extends b.Component{static defaultProps={selectDistinctColumns:[],onChange:()=>{}};constructor(e){super(e),this.handleAddColumnClick=this.handleAddColumnClick.bind(this),this.handleDeleteColumn=this.handleDeleteColumn.bind(this),this.handleDropdownChanged=this.handleDropdownChanged.bind(this);const{model:t,selectDistinctColumns:n}=this.props;this.state={inputs:n.length>0?[...n]:[""],columns:t.originalColumns}}componentDidUpdate(e,t){const{inputs:n}=this.state,{onChange:s}=this.props;if(t.inputs!==n){const i=n.filter(o=>o!=="");it(t.inputs.filter(o=>o!==""),i)||s(i)}}handleAddColumnClick(){this.setState(({inputs:e})=>({inputs:[...e,""]}))}handleDeleteColumn(e){this.setState(({inputs:t})=>({inputs:t.length===1&&e===0?[""]:t.filter((n,s)=>e!==s)}))}handleDropdownChanged(e,t){ZE.debug("handleDropdownChanged",e,t);const{value:n}=t.target;this.setState(({inputs:s})=>{const i=[...s];return i[e]=n,{inputs:i}})}renderInputs(){const{columns:e,inputs:t}=this.state;return t.map((n,s)=>{const i=e.filter(({name:o})=>o===n||!t.includes(o)).map(({name:o})=>l.jsx("option",{value:o,children:o},o));return l.jsxs("div",{className:"form-inline px-3 pb-3",children:[l.jsxs("select",{className:"form-control custom-select col",value:n,onChange:o=>this.handleDropdownChanged(s,o),children:[l.jsx("option",{value:"",children:"Select a column"}),i]}),(t.length>1||n!=="")&&l.jsx(B,{kind:"ghost",className:"ml-1 px-2",onClick:()=>{this.handleDeleteColumn(s)},icon:l.jsx(Q,{icon:Jt,transform:"grow-3"}),tooltip:"Delete column"})]},s)})}render(){const{columns:e,inputs:t}=this.state,n=t.length>=e.length;return l.jsxs("div",{role:"presentation",className:"select-distinct-builder-container h-100",children:[l.jsx("div",{className:"select-distinct-title",children:"Display Unique Values From"}),this.renderInputs(),l.jsx("hr",{}),l.jsx("div",{className:"pt-1 px-3",children:l.jsx(B,{kind:"ghost",className:"btn-add-column",onClick:this.handleAddColumnClick,disabled:n,icon:Ps,children:"Add Additional Column"})}),l.jsx("div",{className:"select-distinct-builder-footer",children:l.jsx("div",{className:"select-distinct-builder-hint",children:"Display only unique values from the selected table columns. Note that this will reset any filters and display only the selected columns."})})]})}}const JE=QE;function fc({items:d,onChange:e=()=>{}}){return l.jsx(qh,{items:Array.from(d.entries()).map(([t,n])=>({title:fc.getAdvancedSettingsTitleForKey(t),isOn:n,onChange:s=>e(t,s)}))})}fc.getAdvancedSettingsTitleForKey=d=>{switch(d){case Gi.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS:return"Clear current table filters before applying new filters from a control";case Gi.LINK_CHANGE_CLEARS_ALL_FILTERS:return"Clear current table filters before applying new filters from an incoming link filter"}};const zd=Z.module("ConditionalFormattingMenu"),Yr=()=>{};function ey(d){const{column:{type:e}}=d;if(x.isNumberType(e))return d.condition===Ke.IS_NULL||d.condition===Ke.IS_NOT_NULL?"":`${d.value}`;if(x.isCharType(e))return d.condition===Nt.IS_NULL||d.condition===Nt.IS_NOT_NULL?"":`${d.value}`;if(x.isStringType(e))return d.condition===Kt.IS_NULL||d.condition===Kt.IS_NOT_NULL?"":`"${d.value}"`;if(x.isDateType(e))return d.condition===Nt.IS_NULL||d.condition===Nt.IS_NOT_NULL?"":`${d.value}`;if(x.isBooleanType(e))return"";throw new Error(`Invalid column type ${e} in getRuleValue`)}function ty(d){return x.isNumberType(d.column.type)&&d.condition===Ke.IS_BETWEEN?`${d.start} < ${d.column.name} < ${d.end}`:`${d.column.name} ${_v(d.column.type,d.condition)}
31
- ${ey(d)}`}function ny(d){const{rules:e=[],onChange:t=Yr,onCreate:n=Yr,onSelect:s=Yr}=d,i=b.useCallback((c,h,u)=>{c.stopPropagation(),zd.debug("Rule clicked",h,u),s(u)},[s]),o=b.useCallback((c,h,u)=>{c.stopPropagation(),zd.debug("Delete button clicked",h,u);const m=[...e];m.splice(u,1),t(m)},[t,e]),a=b.useCallback(c=>{c.stopPropagation()},[]),r=b.useCallback(c=>{if(vn.stopDragging(),c.destination==null)return;const h=c.source.index,u=c.destination.index,m=[...e],g=e[h];m.splice(h,1),m.splice(u,0,g),t(m)},[t,e]);return l.jsxs("div",{className:"conditional-formatting-rules",children:[l.jsx(nr,{onDragStart:vn.startDragging,onDragEnd:r,children:l.jsx(tr,{droppableId:"droppable-custom-columns",children:(c,h)=>l.jsxs("div",{ref:c.innerRef,...c.droppableProps,className:$("droppable-container",{dragging:h.draggingFromThisWith}),children:[e.length===0&&l.jsx("div",{className:"text-muted pl-2",children:"No formats defined"}),e.map((u,m)=>l.jsx(Rl,{draggableId:`${m}-${u.type}`,index:m,disableInteractiveElementBlocking:!0,children:(g,p)=>l.jsx("div",{role:"menuitem",tabIndex:0,onClick:C=>i(C,u,m),className:$("draggable-container",{dragging:p.isDragging}),ref:g.innerRef,...g.draggableProps,children:l.jsx("div",{className:"conditional-formatting-list-item",children:l.jsxs("div",{className:"formatting-item",children:[l.jsx("div",{className:"rule-icon",children:l.jsx("span",{className:"rule-icon-bg",style:{backgroundColor:Ua(u.config.style),color:$a(u.config.style)},children:u.type===jn.ROWS?"row":"col"})}),l.jsx("div",{className:"rule-title",children:ty(u.config)}),l.jsx(B,{kind:"ghost",className:"ml-1 px-2",onClick:C=>o(C,u,m),icon:Jt,tooltip:"Delete rule"}),l.jsxs("button",{type:"button",className:"btn btn-link btn-link-icon px-2 btn-drag-handle",onClick:a,...g.dragHandleProps,children:[l.jsx(tt,{children:"Drag to re-order"}),l.jsx(Q,{icon:ko})]})]})})})},`${m}-${u.type}`)),c.placeholder]})})}),l.jsx("hr",{}),l.jsx(B,{kind:"ghost",onClick:n,icon:Ps,children:"Add New Rule"})]})}const qs=Z.module("ConditionEditor"),sy=()=>{},iy=[Ke.IS_EQUAL,Ke.IS_NOT_EQUAL,Ke.IS_BETWEEN,Ke.GREATER_THAN,Ke.GREATER_THAN_OR_EQUAL,Ke.LESS_THAN,Ke.LESS_THAN_OR_EQUAL,Ke.IS_NULL,Ke.IS_NOT_NULL].map(d=>l.jsx("option",{value:d,children:Tv(d)},d)),oy=[Kt.IS_EXACTLY,Kt.IS_NOT_EXACTLY,Kt.CONTAINS,Kt.DOES_NOT_CONTAIN,Kt.STARTS_WITH,Kt.ENDS_WITH,Kt.IS_NULL,Kt.IS_NOT_NULL].map(d=>l.jsx("option",{value:d,children:Ev(d)},d)),ay=[Nt.IS_EXACTLY,Nt.IS_NOT_EXACTLY,Nt.IS_BEFORE,Nt.IS_BEFORE_OR_EQUAL,Nt.IS_AFTER,Nt.IS_AFTER_OR_EQUAL,Nt.IS_NULL,Nt.IS_NOT_NULL].map(d=>l.jsx("option",{value:d,children:yv(d)},d)),ry=[wo.IS_TRUE,wo.IS_FALSE,wo.IS_NULL,wo.IS_NOT_NULL].map(d=>l.jsx("option",{value:d,children:Rv(d)},d)),ly=[oi.IS_EQUAL,oi.IS_NOT_EQUAL,oi.IS_NULL,oi.IS_NOT_NULL].map(d=>l.jsx("option",{value:d,children:xv(d)},d));function cy(d,e,t,n){return d===Ke.IS_NULL||d===Ke.IS_NOT_NULL||d===Ke.IS_BETWEEN&&t!=null&&t!==""&&!Number.isNaN(Number.parseFloat(t))&&n!=null&&n!==""&&!Number.isNaN(Number.parseFloat(n))||d!==Ke.IS_BETWEEN&&e!==void 0&&e!==""&&!Number.isNaN(Number.parseFloat(e))}function dy(d,e,t,n,s,i,o){switch(d){case Ke.IS_EQUAL:case Ke.IS_NOT_EQUAL:case Ke.GREATER_THAN:case Ke.GREATER_THAN_OR_EQUAL:case Ke.LESS_THAN:case Ke.LESS_THAN_OR_EQUAL:return l.jsx("input",{type:"number",className:"form-control",placeholder:"Enter value",value:s??"",onChange:e});case Ke.IS_BETWEEN:return l.jsxs("div",{className:"d-flex flex-row",children:[l.jsx("input",{type:"number",className:"form-control d-flex mr-2",placeholder:"Start value",value:i??"",onChange:t}),l.jsx("input",{type:"number",className:"form-control d-flex",placeholder:"End value",value:o??"",onChange:n})]});case Ke.IS_NULL:case Ke.IS_NOT_NULL:return null}}function hy(d,e,t){switch(d){case Kt.IS_NULL:case Kt.IS_NOT_NULL:return null;default:return l.jsx("input",{type:"text",className:"form-control",placeholder:"Enter value",value:t??"",onChange:e})}}function uy(d,e,t){switch(d){case Nt.IS_NULL:case Nt.IS_NOT_NULL:return null;default:return l.jsx("input",{type:"text",className:"form-control",placeholder:"Enter value",value:t??"",onChange:e})}}function my(){return null}function gy(d,e,t){switch(d){case oi.IS_NULL:case oi.IS_NOT_NULL:return null;default:return l.jsx("input",{type:"text",className:"form-control",maxLength:1,placeholder:"Enter value",value:t??"",onChange:e})}}function mm(d){const{column:e,config:t,onChange:n=sy}=d,s=e.type,[i,o]=b.useState(s),[a,r]=b.useState(t.condition),[c,h]=b.useState(t.value),[u,m]=b.useState(t.start),[g,p]=b.useState(t.end);s!==i&&(r(Ju(s)),h(em(s)),m(void 0),p(void 0),o(s));const C=b.useMemo(()=>{if(s===void 0)return[];if(x.isNumberType(s))return iy;if(x.isCharType(s))return ly;if(x.isStringType(s))return oy;if(x.isDateType(s))return ay;if(x.isBooleanType(s))return ry},[s]),f=b.useCallback(y=>{const{value:E}=y.target;qs.debug("handleConditionChange",E),r(E)},[]),S=b.useCallback(y=>{const{value:E}=y.target;qs.debug("handleValueChange",E),h(E)},[]),v=b.useCallback(y=>{const{value:E}=y.target;qs.debug("handleStartValueChange",E),m(E)},[]),w=b.useCallback(y=>{const{value:E}=y.target;qs.debug("handleEndValueChange",E),p(E)},[]);b.useEffect(function(){let E=!0;a===void 0?(qs.debug("Unable to create formatting rule. Condition is not selected."),E=!1):x.isNumberType(e.type)&&!cy(a,c,u,g)?(qs.debug("Unable to create formatting rule. Invalid value",c),E=!1):x.isDateType(e.type)&&!Hv(a,c)&&(qs.debug("Unable to create formatting rule. Invalid date condition",c),E=!1),n({condition:a,value:c,start:u,end:g},E)},[n,e.type,a,c,u,g]);const T=b.useMemo(()=>{if(s===void 0)return null;if(x.isNumberType(s))return dy(a,S,v,w,c,u,g);if(x.isCharType(s))return gy(a,S,c);if(x.isStringType(s))return hy(a,S,c);if(x.isDateType(s))return uy(a,S,c);if(x.isBooleanType(s))return my()},[s,a,c,u,g,S,v,w]);return l.jsxs("div",{className:"condition-editor mb-2",children:[l.jsx("select",{value:a,id:"condition-select",className:"custom-select mb-2",onChange:f,children:C}),T]})}const py=Z.module("StyleEditor"),fy="#fcfcfa",Cy="#f0f0ee",Sy="#1a171a",by=200,wy=()=>{};function gm(d){const{config:e,onChange:t=wy}=d,[n,s]=b.useState(e.type),[i,o]=b.useState(e.customConfig?.background??fy),[a,r]=b.useState(!1),[c,h]=b.useState(by),u=b.useRef(null),m=b.useCallback(w=>{const{value:T}=w.target;py.debug("handleBackgroundChange",T),o(T)},[]),g=b.useCallback(()=>{a&&r(!1)},[a]),p=b.useCallback(()=>{a||f(),r(!a)},[a]),C=b.useMemo(()=>[gn.NO_FORMATTING,gn.POSITIVE,gn.NEGATIVE,gn.WARN,gn.NEUTRAL,gn.ACCENT_1,gn.ACCENT_2,gn.CUSTOM],[]);function f(){u.current&&h(u.current.getBoundingClientRect().width)}b.useEffect(function(){t({type:n,customConfig:{color:rr.isDark(i)?Cy:Sy,background:i}})},[t,n,i]);const S=b.useCallback(()=>{const w=[];for(let T=0;T<C.length;T+=1){const y=C[T],E=`option-${T}-${y}`;w.push(l.jsxs(B,{kind:"inline",className:"style-option-btn",onClick:()=>{s(y),r(!1)},style:{color:$a({type:y}),background:Ua({type:y})},children:[y===n&&l.jsx(Q,{icon:Jn,className:"mr-2"}),y!==n&&l.jsx("span",{className:"mr-4"}),Pd(y)]},E))}return w},[C,n]),v=b.useCallback(()=>l.jsx("div",{className:"style-menu-container",role:"presentation",style:{width:c},children:l.jsx("div",{className:"style-options",children:S()})}),[c,S]);return l.jsxs("div",{className:"style-editor",children:[l.jsxs("div",{className:"mb-2",ref:u,children:[l.jsx("label",{className:"mb-0",children:"Style"}),l.jsxs(B,{kind:"inline",className:"cs-dropdown",style:{color:$a({type:n}),background:Ua({type:n})},onClick:p,children:[Pd(n),l.jsx("span",{children:l.jsx(Q,{icon:np,className:"cs-caret"})}),l.jsx(es,{isShown:a,actions:{menuElement:v()},popperOptions:{placement:"bottom-start"},popperClassName:"style-dropdown-menu",onMenuClosed:g,menuStyle:{maxWidth:"100rem"}})]})]}),n===gn.CUSTOM&&l.jsxs("div",{className:"mb-2",children:[l.jsx("label",{className:"mb-0",children:"Background"}),l.jsx("input",{type:"color",value:i,className:"custom-select color-select",onChange:m})]})]})}const uo=Z.module("ColumnFormatEditor"),vy=()=>{};function Ty(d){const{type:e,name:t}=d[0];return{column:{type:e,name:t},style:nm(),...Tr(e)}}function Ey(d){const{columns:e,config:t=Ty(e),onChange:n=vy}=d,[s,i]=b.useState(e.find(f=>f.name===t.column.name&&f.type===t.column.type)??e[0]),[o,a]=b.useState(tm(t)),[r,c]=b.useState(!1),[h,u]=b.useState(t.style),m=b.useCallback(f=>{const S=e.find(({name:v})=>v===f);S!==void 0?(i(S),s.type!==S.type&&(a(Tr(S.type)),c(!1))):uo.error(`Column ${f} not found.`)},[e,s]),g=b.useCallback((f,S)=>{uo.debug("handleConditionChange",f,S),a(f),c(S)},[]),p=b.useCallback(f=>{uo.debug("handleStyleChange",f),u(f)},[]);b.useEffect(function(){let S=r;s===void 0&&(uo.debug("Column is not selected, invalidating update."),S=!1),(h===void 0||h.type===gn.NO_FORMATTING)&&(uo.debug("Style is not selected, invalidating update."),S=!1);const{type:v,name:w}=s;n({column:{type:v,name:w},style:h,...o},S)},[n,s,h,o,r]);const C=e.map(({name:f})=>({title:f,value:f}));return l.jsxs("div",{className:"conditional-rule-editor form",children:[l.jsxs("div",{className:"mb-2",children:[l.jsx("label",{className:"mb-0",children:"Format Cell If"}),l.jsx($h,{defaultValue:s?.name,options:C,inputPlaceholder:"Select a column",spellCheck:!1,onChange:m,searchPlaceholder:"Filter columns"})]}),s!==void 0&&l.jsxs(l.Fragment,{children:[l.jsx(mm,{column:s,config:o,onChange:g}),l.jsx(gm,{config:h,onChange:p})]})]})}const mo=Z.module("RowFormatEditor"),yy=()=>{};function Ry(d){const{type:e,name:t}=d[0];return{column:{type:e,name:t},style:nm(),...Tr(e)}}function xy(d){const{columns:e,config:t=Ry(e),onChange:n=yy}=d,[s,i]=b.useState(e.find(f=>f.name===t.column.name&&f.type===t.column.type)??e[0]),[o,a]=b.useState(tm(t)),[r,c]=b.useState(!1),[h,u]=b.useState(t.style),m=b.useCallback(f=>{const S=e.find(({name:v})=>v===f);S!==void 0?(i(S),s.type!==S.type&&(a(Tr(S.type)),c(!1))):mo.error(`Column ${f} not found.`)},[e,s]),g=b.useCallback((f,S)=>{mo.debug("handleConditionChange",f,S),a(f),c(S)},[]),p=b.useCallback(f=>{mo.debug("handleStyleChange",f),u(f)},[]);b.useEffect(function(){if(s===void 0){mo.debug("Column is not selected, skip update.");return}if(h===void 0){mo.debug("Style is not selected, skip update.");return}const{type:S,name:v}=s;n({column:{type:S,name:v},style:h,...o},r)},[n,s,h,o,r]);const C=e.map(({name:f})=>({title:f,value:f}));return l.jsxs("div",{className:"conditional-rule-editor form",children:[l.jsxs("div",{className:"mb-2",children:[l.jsx("label",{className:"mb-0",children:"Format Row If"}),l.jsx($h,{defaultValue:s?.name,options:C,inputPlaceholder:"Select a column",spellCheck:!1,onChange:m,searchPlaceholder:"Filter columns"})]}),s!==void 0&&l.jsxs(l.Fragment,{children:[l.jsx(mm,{column:s,config:o,onChange:g}),l.jsx(gm,{config:h,onChange:p})]})]})}const Xr=Z.module("ConditionalFormatEditor"),Zr=()=>{};function Iy(d){switch(d){case jn.CONDITIONAL:return l.jsx(oE,{});case jn.ROWS:return l.jsx(aE,{})}}function Dy(d){switch(d){case jn.CONDITIONAL:return"Conditional";case jn.ROWS:return"Rows"}}const Kd=[jn.CONDITIONAL,jn.ROWS];function Fy(d){const{columns:e,onSave:t=Zr,onUpdate:n=Zr,onCancel:s=Zr,rule:i}=d,o=e.filter(Vv),[a,r]=b.useState(i?.type??Kd[0]),[c,h]=b.useState(i),[u,m]=b.useState(!1),g=b.useCallback(()=>{s()},[s]),p=b.useCallback(()=>{if(c===void 0){Xr.error("Rule is not defined.");return}t(c)},[t,c]),C=b.useCallback(S=>{Xr.debug("handleFormatterChange",S),r(S)},[]),f=b.useCallback((S,v)=>{Xr.debug("handleRuleChange",S,v,a);const w={type:a,config:S};h(w),m(v),n(v?w:void 0)},[n,a]);return l.jsxs("div",{className:"conditional-format-editor form",children:[l.jsxs("div",{className:"mb-2",children:[l.jsx("label",{className:"mb-0",htmlFor:"formatter-select",children:"Select Formatter"}),l.jsx("div",{className:"formatter-list",children:Kd.map((S,v)=>l.jsx("div",{className:"formatter-type",children:l.jsxs("button",{type:"button",className:$("btn","btn-icon","btn-formatter-type",{active:S===a}),"data-index":v,onClick:()=>C(S),children:[Iy(S),Dy(S)]})},S))})]}),a===jn.CONDITIONAL&&l.jsx(Ey,{columns:o,config:c?.config,onChange:f}),a===jn.ROWS&&l.jsx(xy,{columns:o,config:c?.config,onChange:f}),l.jsx("hr",{}),l.jsxs("div",{className:"d-flex justify-content-end my-3",children:[l.jsx(B,{kind:"secondary",onClick:g,className:"mr-2",children:"Cancel"}),l.jsx(B,{kind:"primary",onClick:p,disabled:c===void 0||!u,children:"Done"})]})]})}function Ny({text:d,isOpen:e,onClose:t}){const[n,s]=b.useState(!1),[i,o]=b.useState(0),[a,r]=b.useState(!1),[c,h]=b.useState(!1),[u,m]=b.useState(!1),g=b.useRef();b.useEffect(function(){if(e){try{JSON.parse(d),m(!0)}catch{m(!1)}h(!1)}},[e,d]),b.useEffect(function(){g.current&&g.current.layout()},[i]),b.useEffect(function(){g.current&&g.current.updateOptions({lineNumbers:a?"on":"off"})},[a]);function p(){r(!a)}function C(){const w=g.current?.getModel();!u||!w||(c?(w.setValue(d),h(!1)):(w.setValue(JSON.stringify(JSON.parse(d),void 0,2)),h(!0)),f())}function f(){const w=g.current;w&&r((w.getModel()?.getLineCount()??0)>1)}function S(){n&&(g.current=void 0,t())}function v(w){g.current=w,o(w.getContentHeight()),w.onDidContentSizeChange(({contentHeight:T})=>o(T)),f()}return!e&&!n?null:l.jsxs(zi,{isOpen:e,centered:!0,keyboard:!0,toggle:S,onOpened:()=>s(!0),onClosed:()=>{s(!1),o(0)},className:"theme-bg-dark cell-overflow-modal",size:"xl",children:[l.jsxs(Mo,{toggle:t,children:[l.jsx("h5",{className:"overflow-modal-title",children:"Cell Contents"}),l.jsx(dr,{kind:"inline",tooltip:"Copy cell contents",copy:g.current?.getValue()??d}),l.jsx(B,{kind:"inline",active:a,icon:sp,tooltip:"Toggle line numbers",onClick:p}),u&&l.jsx(B,{kind:"inline",icon:ip,active:c,tooltip:"Format as JSON",onClick:C})]}),l.jsx(Ki,{style:{height:i},children:l.jsx(Kl,{onEditorInitialized:v,settings:{value:d,readOnly:!0,wordWrap:"on",language:u?"typescript":"plaintext",folding:u,padding:{bottom:16},lineNumbers:a?"on":"off",overviewRulerLanes:0,renderLineHighlight:"none",find:{seedSearchStringFromSelection:"never"}}})})]})}function My(d){return d.model!==void 0}const ky="###,##0";function Oy({gotoRow:d,gotoRowError:e,gotoValueError:t,onGotoRowSubmit:n,isShown:s,onEntering:i,onEntered:o,onExiting:a,onExited:r,model:c,onGotoRowNumberChanged:h,onClose:u,gotoValueSelectedColumnName:m,gotoValue:g,gotoValueFilter:p,onGotoValueSelectedColumnNameChanged:C,onGotoValueSelectedFilterChanged:f,onGotoValueChanged:S,onGotoValueSubmit:v}){const w=b.useRef(null),T=b.useRef(null),[y,E]=b.useState(!1);let D=[];My(c)&&c.table!==void 0&&({columns:D}=c.table);const F="Row number",{rowCount:N}=c,_=q=>{q.key==="Enter"?(q.stopPropagation(),q.preventDefault(),v()):(q.key==="Backspace"||q.key==="Delete")&&(g===`${Number.POSITIVE_INFINITY}`||g===`${Number.NEGATIVE_INFINITY}`)&&A("")},P=q=>{q.key==="Enter"&&(q.stopPropagation(),q.preventDefault(),v(q.shiftKey))},U=c.getColumnIndexByName(m),j=D[U??0]?.type,k=x.getNormalizedType(j),A=q=>{S(q??"")},H=()=>{y&&document.activeElement!==w.current?w.current?.select():!y&&document.activeElement!==T.current&&T.current?.select()};b.useEffect(H,[y,d,g]);const K=()=>{switch(k){case x.dataType.DECIMAL:case x.dataType.INT:return l.jsx("div",{className:"goto-row-input",children:l.jsx("input",{ref:T,className:$("form-control",{"is-invalid":t!==""}),onKeyDown:_,placeholder:"value",onChange:q=>{const oe=q.target.value.toLowerCase();/^-?[0-9]*\.?[0-9]*$/.test(q.target.value)?A(q.target.value):oe==="-i"||oe==="-infinity"?A(`${Number.NEGATIVE_INFINITY}`):(oe==="i"||oe==="infinity")&&A(`${Number.POSITIVE_INFINITY}`)},value:g})});case x.dataType.DATETIME:return l.jsx("div",{className:"goto-value-date-time-input",children:l.jsx(Mf,{ref:T,className:$("form-control","goto-value-date-time-input",{"is-invalid":t!==""}),defaultValue:g,onChange:A,onSubmit:P})});case x.dataType.STRING:return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"goto-row-input",children:l.jsxs("select",{className:"custom-select",onChange:q=>{f(q.target.value)},value:p,children:[l.jsx("option",{value:X.eq,children:"Equals"},X.eq),l.jsx("option",{value:X.contains,children:"Contains"},X.contains),l.jsx("option",{value:X.eqIgnoreCase,children:"EqIgnoreCase"},X.eqIgnoreCase)]})}),l.jsx("div",{className:"goto-row-input",children:l.jsx("input",{ref:T,className:$("form-control",{"is-invalid":t!==""}),onKeyDown:P,placeholder:"value",onChange:q=>A(q.target.value),value:g})})]});case x.dataType.BOOLEAN:return l.jsx("div",{className:"goto-row-input",children:l.jsxs("select",{className:"custom-select",onChange:q=>{A(q.target.value)},value:g,children:[l.jsx("option",{"aria-label":"null value",value:""},"null"),l.jsx("option",{value:"true",children:"true"},"true"),l.jsx("option",{value:"false",children:"false"},"false")]})});default:return l.jsx("div",{className:"goto-row-input",children:l.jsx("input",{ref:T,className:"form-control",onKeyDown:P,placeholder:"value",onChange:q=>A(q.target.value),value:g})})}};return l.jsx(Er,{isShown:s,className:$("goto-row"),onEntering:i,onEntered:()=>{o(),H()},onExiting:a,onExited:r,children:l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"goto-row-row",children:[l.jsxs("div",{className:$("goto-row-wrapper",{"is-inactive":!y}),onClick:()=>E(!0),onFocus:()=>E(!0),role:"group",children:[l.jsx("div",{className:"goto-row-text",children:"Go to row"}),l.jsx("div",{className:"goto-row-input",children:l.jsx("input",{ref:w,type:"number",onKeyDown:q=>{q.key==="Enter"&&(q.stopPropagation(),q.preventDefault(),n())},className:$("form-control",{"is-invalid":e!==""}),placeholder:F,onChange:q=>{h(q)},value:d})}),l.jsxs("div",{className:"goto-row-text",children:["of ",dh.i18n.NumberFormat.format(ky,N)]}),e&&l.jsx("div",{className:"text-danger",children:e})]}),l.jsx("div",{className:"goto-row-close",children:l.jsx(B,{kind:"ghost",onClick:u,children:l.jsx(Q,{icon:qi,style:{marginRight:"0"}})})})]}),c.isSeekRowAvailable&&l.jsx("div",{className:"goto-row-row",children:l.jsxs("div",{className:$("goto-row-wrapper",{"is-inactive":y}),onClick:()=>E(!1),onFocus:()=>E(!1),role:"group",children:[l.jsx("div",{className:"goto-row-text",children:"Go to value"}),l.jsx("div",{className:"goto-row-input",children:l.jsx("select",{className:"custom-select",onChange:q=>{const oe=q.target.value;C(oe)},value:m,children:D.map(q=>l.jsx("option",{value:q.name,children:q.name},q.name))})}),K(),l.jsxs("div",{children:[l.jsx(B,{kind:"ghost",disabled:g==="",onClick:()=>{v(!0)},children:l.jsx(Q,{icon:Lh})}),l.jsx(B,{kind:"ghost",disabled:g==="",onClick:()=>{v(!1)},children:l.jsx(Q,{icon:op})})]}),t&&l.jsx("div",{className:"text-danger",children:t})]})})]})})}const pe=Z.module("IrisGrid"),Ay=500,Ly=250,Py=250,_y=250,qd=Object.freeze({aggregations:Fe,showOnTop:!1}),jy="yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS z";function Yd({advancedFilters:d,aggregationSettings:e,customColumns:t,quickFilters:n,reverseType:s,rollupConfig:i,searchFilter:o,selectDistinctColumns:a,sorts:r}){return d.size===0&&e.aggregations.length===0&&t.length===0&&n.size===0&&s===x.REVERSE_TYPE.NONE&&i==null&&o==null&&a.length===0&&r.length===0}class Xn extends b.Component{static minDebounce=150;static maxDebounce=500;static loadingSpinnerDelay=800;static defaultProps={children:null,advancedFilters:qn,advancedSettings:qn,alwaysFetchColumns:Fe,conditionalFormats:Fe,customColumnFormatMap:qn,isFilterBarShown:!1,applyInputFiltersOnInit:!1,movedColumns:Fe,movedRows:Fe,inputFilters:Fe,customFilters:Fe,onCreateChart:void 0,onColumnSelected:()=>{},onDataSelected:()=>{},onError:()=>{},onStateChange:()=>{},onPartitionAppend:()=>{},onAdvancedSettingsChange:()=>{},partition:null,partitionColumn:null,quickFilters:qn,selectDistinctColumns:Fe,sorts:Fe,reverseType:x.REVERSE_TYPE.NONE,customColumns:Fe,aggregationSettings:qd,rollupConfig:void 0,userColumnWidths:qn,userRowHeights:qn,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:qn,getDownloadWorker:void 0,settings:{timeZone:"America/New_York",defaultDateTimeFormat:et.FULL_DATE_FORMAT,showTimeZone:!1,showTSeparator:!0,truncateNumbersWithPound:!1,formatter:Fe,decimalFormatOptions:I.shape({defaultFormatString:I.string}),integerFormatOptions:I.shape({defaultFormatString:I.string})},canCopy:!0,canDownloadCsv:!0,frozenColumns:null,theme:Vd,canToggleSearch:!0};static makeQuickFilter(e,t,n){try{return x.makeQuickFilter(e,t,n)}catch(s){pe.error("Error creating quick filter",s)}return null}constructor(e){super(e),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 is,this.globalColumnFormats=Fe,this.decimalFormatOptions={},this.integerFormatOptions={},this.truncateNumbersWithPound=!1,this.renderer=new VT,this.tableSaver=null,this.crossColumnRef=J.createRef(),this.isAnimating=!1,this.filterInputRef=J.createRef(),this.toggleFilterBarAction={action:()=>this.toggleFilterBar(),shortcut:qt.TABLE.TOGGLE_QUICK_FILTER},this.toggleSearchBarAction={action:()=>this.toggleSearchBar(),shortcut:qt.TABLE.TOGGLE_SEARCH},this.toggleGotoRowAction={action:()=>this.toggleGotoRow(),shortcut:qt.TABLE.GOTO_ROW},this.discardAction={action:()=>{const{model:H}=this.props;Ze(H)&&H.isEditable&&H.pendingDataMap.size>0&&this.discardPending().catch(pe.error)},shortcut:qt.INPUT_TABLE.DISCARD},this.commitAction={action:()=>{const{model:H}=this.props;Ze(H)&&H.isEditable&&H.pendingDataMap.size>0&&H.pendingDataErrors.size===0&&this.commitPending().catch(pe.error)},shortcut:qt.INPUT_TABLE.COMMIT},this.contextActions=[this.toggleFilterBarAction,this.toggleSearchBarAction,this.toggleGotoRowAction,this.discardAction,this.commitAction];const{aggregationSettings:t,conditionalFormats:n,customColumnFormatMap:s,isFilterBarShown:i,isSelectingPartition:o,model:a,movedColumns:r,movedRows:c,partition:h,partitionColumn:u,rollupConfig:m,userColumnWidths:g,userRowHeights:p,showSearchBar:C,searchValue:f,selectedSearchColumns:S,invertSearchColumns:v,advancedFilters:w,quickFilters:T,selectDistinctColumns:y,pendingDataMap:E,canCopy:D,frozenColumns:F,columnHeaderGroups:N}=e,_=[new aT(this),new lT(this)];D&&_.push(new tT(this));const P=[new dT(this),new IT(this),new OT(this),new uT(this),new gT(this),new FT(this),new RT(this),new vT(this),new ET(this),new MT(this)],U=r.length>0?r:a.initialMovedColumns,O=c.length>0?c:a.initialMovedRows,j=new _T({userColumnWidths:new Map(g),userRowHeights:new Map(p),movedColumns:U,initialColumnWidths:new Map(a?.layoutHints?.hiddenColumns?.map(H=>[a.getColumnIndexByName(H),0]))}),k=S??[],A=ga.createSearchFilter(f,k,a.columns,v);this.state={isFilterBarShown:i,isSelectingPartition:o,focusedFilterBarColumn:null,metricCalculator:j,metrics:void 0,keyHandlers:_,mouseHandlers:P,partition:h,partitionColumn:u,partitionTable:null,partitionFilters:[],quickFilters:T?new Map(T):new Map,advancedFilters:new Map(w),shownAdvancedFilter:null,hoverAdvancedFilter:null,sorts:[],reverseType:x.REVERSE_TYPE.NONE,customColumns:[],selectDistinctColumns:y,selectedRanges:[],copyOperation:null,loadingText:null,loadingScrimProgress:null,loadingSpinnerShown:!1,movedColumns:U,movedRows:O,shownColumnTooltip:null,formatter:new Qt,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:C,searchFilter:A,searchValue:f,selectedSearchColumns:k,invertSearchColumns:v,rollupConfig:m,rollupSelectedColumns:[],aggregationSettings:t,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",linkHoverTooltipProps:null,linkHoverDisplayValue:"",isGotoShown:!1,gotoRow:"",gotoRowError:"",gotoValueError:"",gotoValueSelectedColumnName:a.columns[0]?.name??"",gotoValueSelectedFilter:X.eq,gotoValue:"",columnHeaderGroups:N??a.initialColumnHeaderGroups}}componentDidMount(){const{partitionColumn:e,model:t}=this.props,n=e??t.columns.find(s=>s.isPartitionColumn);t.isFilterRequired&&t.isValuesTableAvailable&&n!=null?this.loadPartitionsTable(n):this.initState(),this.startListening(t)}componentDidUpdate(e){const{inputFilters:t,isSelectingColumn:n,settings:s,model:i,customFilters:o,sorts:a}=this.props;i!==e.model&&(this.stopListening(e.model),this.startListening(i));const r=t!==e.inputFilters?t.filter(u=>!e.inputFilters.includes(u)):[];if(r.length>0){const{advancedSettings:u}=this.props,m=u.get(Gi.FILTER_CONTROL_CHANGE_CLEARS_ALL_FILTERS)??!1;m&&(this.clearGridInputField(),this.clearCrossColumSearch()),this.startLoading("Filtering...",!0),this.applyInputFilters(r,m)}n!==e.isSelectingColumn&&this.resetColumnSelection(),s!==e.settings&&this.updateFormatterSettings(s),o!==e.customFilters&&this.startLoading("Filtering...",!0),a!==e.sorts&&this.updateSorts(a);const{loadingScrimStartTime:c,loadingScrimFinishTime:h}=this;c!=null&&h!=null&&window.requestAnimationFrame(()=>{const u=Date.now(),m=u-c,g=h-c,p=Math.min(m/g,1);h<u&&(this.loadingScrimStartTime=void 0,this.loadingScrimFinishTime=void 0),this.setState(C=>C.loadingScrimProgress==null?(pe.debug2("Ignoring scrim update because loading cancelled."),null):{loadingScrimProgress:p})}),this.sendStateChange()}componentWillUnmount(){const{model:e}=this.props;this.stopListening(e),this.pending.cancel(),this.updateSearchFilter.cancel(),this.loadingTimer&&clearTimeout(this.loadingTimer),this.handleDownloadProgressUpdate.cancel(),this.animationFrame!==void 0&&cancelAnimationFrame(this.animationFrame)}grid;gridWrapper;lastFocusedFilterBarColumn;lastLoadedConfig;tooltip;pending;globalColumnFormats;dateTimeFormatterOptions;decimalFormatOptions;integerFormatOptions;truncateNumbersWithPound;loadingScrimStartTime;loadingScrimFinishTime;animationFrame;loadingTimer;renderer;tableSaver;crossColumnRef;isAnimating;filterInputRef;toggleFilterBarAction;toggleSearchBarAction;toggleGotoRowAction;discardAction;commitAction;contextActions;getAdvancedMenuOpenedHandler=ge(e=>this.handleAdvancedMenuOpened.bind(this,e),{max:100});getCachedAdvancedFilterMenuActions=ge((e,t,n,s,i)=>l.jsx(XT,{model:e,column:t,onFilterChange:this.handleAdvancedFilterChange,onSortChange:this.handleAdvancedFilterSortChange,onDone:this.handleAdvancedFilterDone,options:n,sortDirection:s,formatter:i}),{max:50});getCachedOptionItems=ge((e,t,n,s,i,o,a,r,c,h,u,m,g,p,C,f)=>{const S=[];return e&&S.push({type:De.CHART_BUILDER,title:"Chart Builder",icon:ap}),S.push({type:De.VISIBILITY_ORDERING_BUILDER,title:"Organize Columns",icon:Pl}),n&&S.push({type:De.CONDITIONAL_FORMATTING,title:"Conditional Formatting",icon:Ao}),t&&S.push({type:De.CUSTOM_COLUMN_BUILDER,title:"Custom Columns",icon:rp}),s&&S.push({type:De.ROLLUP_ROWS,title:"Rollup Rows",icon:Ph}),i&&S.push({type:De.AGGREGATIONS,title:"Aggregate Columns",icon:lp}),o&&S.push({type:De.SELECT_DISTINCT,title:"Select Distinct Values",icon:cp}),a&&g&&S.push({type:De.TABLE_EXPORTER,title:"Download CSV",icon:dp}),f&&S.push({type:De.ADVANCED_SETTINGS,title:"Advanced Settings",icon:hp}),S.push({type:De.QUICK_FILTERS,title:"Quick Filters",subtitle:r.shortcut.getDisplayText(),icon:Fa,isOn:u,onChange:r.action}),p&&S.push({type:De.SEARCH_BAR,title:"Search Bar",subtitle:c.shortcut.getDisplayText(),icon:Dh,isOn:m,onChange:c.action}),S.push({type:De.GOTO,title:"Go to",subtitle:h.shortcut.getDisplayText(),icon:up,isOn:C,onChange:h.action}),Object.freeze(S)},{max:1});getCachedHiddenColumns=ge((e,t)=>be.getHiddenColumns(new Map([...e.initialColumnWidths,...t])),{max:1});getAggregationMap=ge((e,t)=>{const n={};return t.forEach(({operation:s,selected:i,invert:o})=>{n[s]=Fs.getOperationColumnNames(e,s,i,o)}),n});getOperationMap=ge((e,t)=>{const n={};return t.filter(s=>!Fs.isRollupOperation(s.operation)).forEach(({operation:s,selected:i,invert:o})=>{Fs.getOperationColumnNames(e,s,i,o).forEach(a=>{const r=[...n[a]??[],s];n[a]=Object.freeze(r)})}),n});getOperationOrder=ge(e=>e.map(t=>t.operation).filter(t=>!Fs.isRollupOperation(t)));getCachedFormatColumns=ge((e,t)=>jv(e,t));getCachedPreviewFormatColumns=ge((e,t,n,s)=>{if(pe.debug("getCachedPreviewFormatColumns",t,n,s),n!==void 0&&s!==void 0){const i=[...t];return i[s]=n,this.getCachedFormatColumns(e,i)}return this.getCachedFormatColumns(e,t)});getModelRollupConfig=ge((e,t,n)=>be.getModelRollupConfig(e,t,n));getModelTotalsConfig=ge((e,t,n)=>{const{aggregations:s,showOnTop:i}=n;if((t?.columns?.length??0)>0||(s?.length??0)===0)return null;const o=this.getOperationMap(e,s),a=this.getOperationOrder(s);return{operationMap:o,operationOrder:a,showOnTop:i}});getCachedStateOverride=ge((e,t,n,s,i,o,a,r,c,h)=>({hoverSelectColumn:e,isFilterBarShown:t,isSelectingColumn:n,loadingScrimProgress:s,quickFilters:i,advancedFilters:o,sorts:a,reverseType:r,rollupConfig:c,isMenuShown:h}),{max:1});getCachedFilter=ge((e,t,n,s,i)=>[...e??[],...s??[],...be.getFiltersFromFilterMap(t),...be.getFiltersFromFilterMap(n),...i!==void 0?[i]:[]],{max:1});getCachedTheme=ge((e,t,n)=>({...Vd,...e,autoSelectRow:!t,rowFooterWidth:n>0?e.rowFooterWidth:0}),{max:1});getValueForCell(e,t,n=!1){const{model:s}=this.props,i=this.getModelColumn(e),o=this.getModelRow(t);if(n&&i!=null&&o!=null){const a=s.valueForCell(i,o);if(x.isDateType(s.columns[i].type)){const{formatter:r}=s;return R.i18n.DateTimeFormat.format(jy,a,R.i18n.TimeZone.getTimeZone(r.timeZone))}return a}return n?null:i!=null&&o!=null?s.textForCell(i,o):""}getModelColumn(e){const{metrics:t}=this.state;M(t);const{modelColumns:n}=t;return n==null?null:e!=null?n.get(e):null}getModelRow(e){const{metrics:t}=this.state;M(t);const{modelRows:n}=t;return n==null?null:e!=null?n.get(e):null}getTheme(){const{model:e,theme:t}=this.props;return this.getCachedTheme(t,(Ze(e)&&e.isEditable)??!1,e.floatingTopRowCount+e.floatingBottomRowCount)}getVisibleColumn(e){const{movedColumns:t}=this.state;return V.getVisibleIndex(e,t)}applyInputFilters(e,t=!1){const{model:n}=this.props,{advancedFilters:s,quickFilters:i}=this.state,o=t?new Map:new Map(s),a=t?new Map:new Map(i);let r=t&&s.size>0;e.forEach(({name:c,type:h,value:u})=>{const m=n.columns.findIndex(({name:g,type:p})=>g===c&&p===h);m>=0?(r=o.delete(m)||r,r=this.applyQuickFilter(m,u,a)||r):pe.error("Unable to find column for inputFilter",c,h,u)}),r&&this.setState({quickFilters:a,advancedFilters:o})}applyQuickFilter(e,t,n){const{model:s}=this.props,{formatter:i}=s,o=s.columns[e];if(t!=null&&`${t}`.trim().length>0){const a=n.get(e);if(a!=null){const{text:r}=a;if(r===t)return pe.debug2("Ignoring change to existing filter"),!1}return n.set(e,{text:t,filter:Xn.makeQuickFilter(o,t,i.timeZone)}),!0}return n.delete(e)}setAdvancedFilterMap(e){this.setState({advancedFilters:e})}setAdvancedFilter(e,t,n){pe.debug("Setting advanced filter",e,t),this.startLoading("Filtering...",!0),this.setState(({advancedFilters:s})=>{const i=new Map(s);return t==null?i.delete(e):i.set(e,{filter:t,options:n}),{advancedFilters:i}})}setQuickFilter(e,t,n){pe.debug("Setting quick filter",e,t,n),this.startLoading("Filtering...",!0),this.setState(({quickFilters:s})=>{const i=new Map(s);return i.set(e,{filter:t,text:n}),{quickFilters:i}})}setFilterMap(e){pe.debug("setFilterMap",e);const{advancedSettings:t}=this.props;(t.get(Gi.LINK_CHANGE_CLEARS_ALL_FILTERS)??!1)&&this.clearAllFilters();const{model:s}=this.props;e.forEach(({columnType:i,filterList:o},a)=>{const r=s.columns.find(u=>u.name===a&&u.type===i);if(r==null)return;const c=s.getColumnIndexByName(r.name);M(c);const h=be.combineFiltersFromList(i,o);if(h.length===0)this.removeQuickFilter(c);else{const{formatter:u}=s;this.setQuickFilter(c,Xn.makeQuickFilter(r,h,u.timeZone),`${h}`)}})}removeColumnFilter(e){this.startLoading("Filtering...",!0),this.setState(({advancedFilters:t,quickFilters:n})=>{const s=t?new Map(t):new Map,i=n?new Map(n):new Map;return i.delete(e),s.delete(e),{quickFilters:i,advancedFilters:s}})}removeQuickFilter(e){this.startLoading("Clearing Filter...",!0),this.setState(({quickFilters:t})=>{const n=new Map(t);return n.delete(e),{quickFilters:n}})}clearAllFilters(){pe.debug("Clearing all filters");const{advancedFilters:e,quickFilters:t,searchFilter:n}=this.state;t.size===0&&e.size===0&&n===null||(this.clearGridInputField(),this.startLoading("Clearing Filters...",!0),this.setState({quickFilters:new Map,advancedFilters:new Map,searchValue:"",searchFilter:void 0}))}clearCrossColumSearch(){pe.debug("Clearing cross-column search"),this.setState({searchValue:"",searchFilter:void 0})}clearGridInputField(){this.filterInputRef.current!=null&&this.filterInputRef.current.setValue("")}rebuildFilters(){pe.debug("Rebuilding filters");const{model:e}=this.props,{advancedFilters:t,quickFilters:n}=this.state,{columns:s,formatter:i}=e,o=new Map,a=new Map;t.forEach((r,c)=>{const{options:h}=r,u=s[c],m=x.makeAdvancedFilter(u,h,i.timeZone);o.set(c,{options:h,filter:m})}),n.forEach((r,c)=>{const{text:h}=r,u=s[c];a.set(c,{text:h,filter:Xn.makeQuickFilter(u,h,i.timeZone)})}),this.startLoading("Rebuilding filters...",!0),this.setState({quickFilters:a,advancedFilters:o})}setFilters({quickFilters:e,advancedFilters:t}){this.setState({quickFilters:e,advancedFilters:t})}updateFormatterSettings(e,t=!0){const n=ns.getColumnFormats(e),s=ns.getDateTimeFormatterOptions(e),i=e?.defaultDecimalFormatOptions??{},o=e?.defaultIntegerFormatOptions??{},a=e?.truncateNumbersWithPound??!1,r=!it(this.globalColumnFormats,n),c=!it(this.dateTimeFormatterOptions,s),h=!it(this.decimalFormatOptions,e?.defaultDecimalFormatOptions),u=!it(this.integerFormatOptions,o),m=this.truncateNumbersWithPound!==a;(r||c||h||u||m)&&(this.globalColumnFormats=n,this.dateTimeFormatterOptions=s,this.decimalFormatOptions=i,this.integerFormatOptions=o,this.truncateNumbersWithPound=a,this.updateFormatter({},t),c&&t&&this.rebuildFilters())}getAlwaysFetchColumns=ge((e,t,n,s,i,o)=>{const a=[];for(let c=0;c<s;c+=1)a.push(t[V.getModelIndex(c,n)].name);for(let c=0;c<i;c+=1)a.push(t[V.getModelIndex(t.length-1-c,n)].name);if(o)for(let c=o[0];c<=o[1];c+=1)a.push(t[V.getModelIndex(c,n)].name);const r=new Set([...e,...a]);return Object.freeze([...r])});updateFormatter(e,t=!0){const{customColumnFormatMap:n}=this.state,s={customColumnFormatMap:n,...e},i=[...this.globalColumnFormats??[],...s.customColumnFormatMap.values()],o=new Qt(i,this.dateTimeFormatterOptions,this.decimalFormatOptions,this.integerFormatOptions,this.truncateNumbersWithPound);pe.debug("updateFormatter",this.globalColumnFormats,i),this.setState({...s,formatter:o},()=>{t&&this.grid&&this.grid.forceUpdate()})}initFormatter(){const{settings:e}=this.props;this.updateFormatterSettings(e)}initState(){const{applyInputFiltersOnInit:e,inputFilters:t,sorts:n,model:s,reverseType:i,customColumns:o,searchValue:a,selectedSearchColumns:r,invertSearchColumns:c}=this.props,h=r??[],u=ga.createSearchFilter(a,h,s.columns,c);if(e){const m=t.filter(g=>g.value!=null);this.applyInputFilters(m)}this.setState({sorts:n,reverseType:i,customColumns:o,isReady:!0,searchFilter:u}),this.initFormatter()}async loadPartitionsTable(e){const{model:t}=this.props;this.setState({isSelectingPartition:!0});try{const n=await this.pending.add(t.valuesTable(e),a=>a.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 r=o.rows[0].get(s);this.updatePartition(r,e),this.setState({isSelectingPartition:!0})}else pe.info("Table does not have any data, just fetching all"),this.setState({isSelectingPartition:!1}),this.handlePartitionFetchAll();this.setState({partitionTable:n,partitionColumn:e},()=>{this.initState()})}catch(n){this.handleTableLoadError(n)}}updatePartition(e,t){const s=[t.filter().eq(R.FilterValue.ofString(e))];this.setState({partition:e,partitionFilters:s})}copyCell(e,t,n=!1){const{canCopy:s}=this.props;if(s){const i=String(this.getValueForCell(e,t,n));Yi(i).catch(o=>pe.error("Unable to copy cell",o))}else pe.error("Attempted to copyCell for user without copy permission.")}copyRanges(e,t=!1,n=!0,s){const{model:i,canCopy:o}=this.props,{metricCalculator:a,movedColumns:r}=this.state,c=a.getUserColumnWidths();if(o){const h={ranges:z.boundedRanges(e,i.columnCount,i.rowCount),includeHeaders:t,formatValues:n,movedColumns:r,userColumnWidths:c,error:s};this.setState({copyOperation:h})}else pe.error("Attempted copyRanges for user without copy permission.")}startLoading(e,t=!1){this.setState({loadingText:e});const n=this.getTheme();if(t&&this.grid&&(this.grid.clearSelectedRanges(),this.grid.setViewState({top:0},!0)),this.loadingScrimStartTime==null){const{minScrimTransitionTime:s,maxScrimTransitionTime:i}=n;M(s),M(i);const o=this.gridWrapper?.getBoundingClientRect().height??0,a=Math.max(s,Math.min(o/2,i));this.loadingScrimStartTime=Date.now(),this.loadingScrimFinishTime=this.loadingScrimStartTime+a,this.setState({loadingScrimProgress:0}),this.loadingTimer=setTimeout(()=>{this.setState({loadingSpinnerShown:!0})},Xn.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){pe.debug("loading last loading config",this.lastLoadedConfig);const{advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:a,selectDistinctColumns:r,sorts:c}=this.lastLoadedConfig;this.lastLoadedConfig=null,this.setState({advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:a,selectDistinctColumns:r,sorts:c})}else pe.debug("remove all sorts, filters, and custom columns"),this.setState({advancedFilters:new Map,aggregationSettings:qd,customColumns:[],quickFilters:new Map,reverseType:x.REVERSE_TYPE.NONE,rollupConfig:void 0,selectDistinctColumns:[],sorts:[]})}canRollback(){return this.lastLoadedConfig!=null||!Yd(this.state)}startListening(e){e.addEventListener(Se.EVENT.UPDATED,this.handleUpdate),e.addEventListener(Se.EVENT.REQUEST_FAILED,this.handleRequestFailed),e.addEventListener(Se.EVENT.COLUMNS_CHANGED,this.handleCustomColumnsChanged),e.addEventListener(Se.EVENT.PENDING_DATA_UPDATED,this.handlePendingDataUpdated)}stopListening(e){e.removeEventListener(Se.EVENT.UPDATED,this.handleUpdate),e.removeEventListener(Se.EVENT.REQUEST_FAILED,this.handleRequestFailed),e.removeEventListener(Se.EVENT.COLUMNS_CHANGED,this.handleCustomColumnsChanged),e.removeEventListener(Se.EVENT.PENDING_DATA_UPDATED,this.handlePendingDataUpdated)}focus(){this.grid?.focus()}focusFilterBar(e){const{movedColumns:t}=this.state,{model:n}=this.props,{columnCount:s}=n,i=V.getModelIndex(e,t);if(e==null||e<0||s<=e||!n.isFilterable(i)){this.setState({focusedFilterBarColumn:null});return}const{metricCalculator:o,metrics:a}=this.state;M(a);const{left:r,rightVisible:c,lastLeft:h}=a;if(e<r)this.grid?.setViewState({left:e},!0);else if(c<e){const u=this.grid?.getMetricState();M(u);const m=o.getLastLeft(u,e,o.getVisibleWidth(u));this.grid?.setViewState({left:Math.min(m,h),leftOffset:0},!0)}this.lastFocusedFilterBarColumn=e,this.setState({focusedFilterBarColumn:e,isFilterBarShown:!0})}hideColumnByVisibleIndex(e){const{metricCalculator:t,movedColumns:n}=this.state;t.setColumnWidth(V.getModelIndex(e,n),0),this.grid?.forceUpdate()}freezeColumnByColumnName(e){const{frozenColumns:t,movedColumns:n}=this.state,{model:s}=this.props;pe.debug2("freezing column",e);const i=t==null?new Set(s.frozenColumns):new Set(t);i.add(e);const o=s.getColumnIndexByName(e);M(o);const a=V.getVisibleIndex(o,n),r=V.moveItem(a,i.size-1,n);this.setState({frozenColumns:[...i],movedColumns:r})}unFreezeColumnByColumnName(e){const{frozenColumns:t,movedColumns:n}=this.state,{model:s}=this.props;pe.debug2("unfreezing column",e);const i=t==null?new Set(s.frozenColumns):new Set(t);i.delete(e);const o=s.getColumnIndexByName(e);M(o);const a=V.getVisibleIndex(o,n),r=V.moveItem(a,i.size+s.frontColumns.length,n);this.setState({frozenColumns:[...i],movedColumns:r})}handleColumnVisibilityChanged(e,t){const{metricCalculator:n,metrics:s}=this.state;M(s),t?e.forEach(i=>{const o=n.initialColumnWidths.get(i),a=L(s.calculatedColumnWidths,i);o!==a?n.setColumnWidth(i,a):n.resetColumnWidth(i)}):e.forEach(i=>{n.setColumnWidth(i,0)}),this.grid?.forceUpdate()}handleColumnVisibilityReset(){const{metricCalculator:e,metrics:t}=this.state,{model:n}=this.props;M(t);for(let s=0;s<t.columnCount;s+=1)e.resetColumnWidth(s);this.handleMovedColumnsChanged(n.initialMovedColumns),this.handleHeaderGroupsChanged(n.initialColumnHeaderGroups),this.setState({frozenColumns:n.layoutHints?.frozenColumns??[]})}handleCrossColumnSearch(e,t,n){const{model:s}=this.props;this.updateSearchFilter(e,t,s.columns,n),this.setState({searchValue:e,selectedSearchColumns:t,invertSearchColumns:n})}updateSearchFilter=Ye((e,t,n,s)=>{const i=ga.createSearchFilter(e,t,n,s);this.setState({searchFilter:i})},Ly);handleAnimationLoop(){this.grid?.updateCanvas(),this.isAnimating&&(this.animationFrame=requestAnimationFrame(this.handleAnimationLoop))}handleAnimationStart(){pe.debug2("handleAnimationStart"),this.isAnimating=!0,this.animationFrame=requestAnimationFrame(this.handleAnimationLoop)}handleAnimationEnd(){pe.debug2("handleAnimationEnd"),this.isAnimating=!1}handlePartitionAppend(e){const{onPartitionAppend:t}=this.props,{partitionColumn:n}=this.state;n!=null&&t(n,e)}handlePartitionChange(e){const{partitionColumn:t}=this.state;t!=null&&this.updatePartition(e,t)}handlePartitionFetchAll(){this.setState({partitionFilters:[],isSelectingPartition:!1})}handlePartitionDone(){this.setState({isSelectingPartition:!1})}handleTableLoadError(e){if(ve.isCanceled(e))return;pe.error(e);const{onError:t}=this.props;t(e)}showAllColumns(){const{metricCalculator:e}=this.state,n=[...e.getUserColumnWidths().entries()];for(let s=0;s<n.length;s+=1){const[i,o]=n[s];o===0&&e.resetColumnWidth(i)}this.grid?.forceUpdate()}toggleSort(e,t){pe.info("Toggling sort for column",e);const{model:n}=this.props,{sorts:s}=this.state,i=this.getModelColumn(e);M(i);const o=x.toggleSortForColumn(s,n.columns,i,t);this.updateSorts(o)}updateSorts(e){this.startLoading("Sorting..."),this.setState({sorts:e}),this.grid?.forceUpdate()}sortColumn(e,t=x.sortDirection.none,n=!1,s=!1){M(e);const{model:i}=this.props,o=x.sortColumn(i.sort,i.columns,e,t,n,s);this.startLoading("Sorting..."),this.setState({sorts:o}),this.grid?.forceUpdate()}reverse(e){this.startLoading("Reversing..."),this.setState({reverseType:e}),this.grid?.forceUpdate()}isReversible(){const{model:e}=this.props;return e.isReversible}toggleFilterBar(e=this.lastFocusedFilterBarColumn){let{isFilterBarShown:t}=this.state;if(t=!t,this.setState({isFilterBarShown:t}),t)if(e!=null)this.focusFilterBar(e);else{let n=0;const{model:s}=this.props,{columnCount:i}=s;for(let o=0;o<i;o+=1){const a=this.getModelColumn(o);if(a!=null){const r=s.columns[a];if(r!=null&&x.isTextType(r.type)){n=o;break}}}this.focusFilterBar(n)}else this.grid?.focus()}isTableSearchAvailable(){const{model:e,canToggleSearch:t}=this.props,n=e?.layoutHints?.searchDisplayMode;return n===R.SearchDisplayMode?.SEARCH_DISPLAY_HIDE?!1:n===R.SearchDisplayMode?.SEARCH_DISPLAY_SHOW?!0:t}toggleSearchBar(){const{showSearchBar:e}=this.state;if(!this.isTableSearchAvailable())return;const t=!e;this.setState({showSearchBar:t},()=>{t&&this.crossColumnRef?.current?this.crossColumnRef?.current.focus():this.grid?.focus()})}toggleGotoRow(e="",t="",n=""){const{isGotoShown:s}=this.state;if(e||t){this.setState({isGotoShown:!0,gotoRow:e,gotoValue:t,gotoValueSelectedColumnName:n,gotoRowError:"",gotoValueError:""}),this.focusRowInGrid(e);return}const i=this.grid?.state.cursorRow,o=this.grid?.state.cursorColumn;if(i==null||o==null){this.setState({isGotoShown:!s,gotoRow:"",gotoValue:"",gotoRowError:"",gotoValueError:""});return}const{model:a}=this.props,{name:r,type:c}=a.columns[o],h=a.valueForCell(o,i),u=be.convertValueToText(h,c);this.setState({isGotoShown:!s,gotoRow:`${i}`,gotoValue:u,gotoValueSelectedColumnName:r,gotoRowError:"",gotoValueError:""})}async commitPending(){const{model:e}=this.props;if(!Ze(e)||!e.isEditable)throw new Error("Cannot save, table is not editable");const{pendingSavePromise:t}=this.state;if(t!=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 Li("Current input is invalid");this.grid?.focus()}const s=this.pending.add(e.commitPending()).then(()=>{this.setState({pendingSaveError:null,pendingSavePromise:null})}).catch(i=>{ve.isCanceled(i)||this.setState({pendingSaveError:i,pendingSavePromise:null})});return this.setState({pendingSavePromise:s}),s}async discardPending(){const{pendingSavePromise:e}=this.state;if(e!=null)throw new Error("Cannot cancel a save in progress");this.setState({pendingSavePromise:null,pendingSaveError:null,pendingDataMap:new Map,pendingDataErrors:new Map})}selectColumn(e){const{onColumnSelected:t}=this.props;t(e)}selectData(e,t){const{model:n}=this.props,{columns:s,groupedColumns:i}=n,o={};for(let r=0;r<s.length;r+=1){const c=s[r],{name:h,type:u}=c,m=n.valueForCell(r,t),g=n.textForCell(r,t),p=this.getVisibleColumn(r),C=qe(n)&&n.isRowExpandable(t),f=i.find(S=>S.name===h)!=null;o[h]={value:m,text:g,type:u,isGrouped:f,isExpandable:C,visibleIndex:p}}const{onDataSelected:a}=this.props;a(t,o)}handleAdvancedFilterChange(e,t,n){const{model:s}=this.props,i=s.getColumnIndexByName(e.name);M(i),this.setAdvancedFilter(i,t,n)}handleAdvancedFilterSortChange(e,t,n=!1){const{model:s}=this.props,i=s.getColumnIndexByName(e.name);M(i);const o=s.columns[i].name,a=x.getSortForColumn(s.sort,o);let r=null;(a==null||a.direction!==t)&&(t===x.sortDirection.descending?r=e.sort().desc():r=e.sort().asc());const c=x.setSortForColumn(s.sort,o,r,n);pe.info("Setting table sorts",c),this.startLoading("Sorting..."),this.setState({sorts:c}),this.grid?.forceUpdate()}handleAdvancedFilterDone(){this.grid?.focus()}handleAdvancedMenuOpened(e){this.setState({shownAdvancedFilter:e})}handleGotoRowOpened(){this.setState({isGotoShown:!0})}handleGotoRowClosed(){this.setState({isGotoShown:!1})}handleAdvancedMenuClosed(e){const{focusedFilterBarColumn:t,isFilterBarShown:n}=this.state;n&&t===e&&this.filterInputRef?.current!==null?(this.filterInputRef?.current.focus(),this.setState({shownAdvancedFilter:null})):this.setState({focusedFilterBarColumn:null,shownAdvancedFilter:null})}handleCancel(){this.rollback()}handleChartChange(){}handleChartCreate(e){const{model:t,onCreateChart:n}=this.props;n(e,t)}handleGridError(e){pe.warn("Grid Error",e),this.setState({toastMessage:l.jsx("div",{className:"error-message",children:`${e}`})})}handleFilterBarChange(e){this.startLoading("Filtering...",!0),this.setState(({focusedFilterBarColumn:t,quickFilters:n})=>{const s=new Map(n);if(t!=null){const i=this.getModelColumn(t);M(i),this.applyQuickFilter(i,e,s)}return{quickFilters:s}})}handleFilterBarDone(e=!0,t=!0){e&&this.grid?.focus(),t&&this.setState({focusedFilterBarColumn:null})}handleFilterBarTab(e){const{focusedFilterBarColumn:t}=this.state;M(t),e?this.focusFilterBar(t-1):this.focusFilterBar(t+1)}handleFormatSelection(e,t){const{model:n}=this.props,s=n.columns[e],{customColumnFormatMap:i}=this.state,o=new Map(i);if(t!=null){const a=x.getNormalizedType(s.type);M(a);const r=Qt.makeColumnFormattingRule(a,s.name,t);o.set(s.name,r)}else o.delete(s.name);this.updateFormatter({customColumnFormatMap:o})}handleMenu(e){e.stopPropagation(),this.setState({isMenuShown:!0})}handleMenuClose(){this.setState({isMenuShown:!1,openOptions:[]})}handleMenuBack(){this.setState(({openOptions:e})=>{const t=[...e];return t.pop(),{openOptions:t}})}handleMenuSelect(e){this.setState(({openOptions:t})=>({openOptions:[...t,e]}))}handleRequestFailed(e){const t=e;if(pe.error("request failed:",t.detail),this.stopLoading(),this.canRollback())this.startLoading("Rolling back changes...",!0),this.rollback();else{pe.error("Table failed and unable to rollback");const{onError:n}=this.props;n(new Error(`Error displaying table: ${t.detail}`))}}handleUpdate(){this.stopLoading(),pe.debug2("Received model update");const{advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:a,selectDistinctColumns:r,sorts:c}=this.state,h={advancedFilters:e,aggregationSettings:t,customColumns:n,quickFilters:s,reverseType:i,rollupConfig:o,searchFilter:a,selectDistinctColumns:r,sorts:c};Yd(h)?this.lastLoadedConfig=null:this.lastLoadedConfig=h,this.grid?.forceUpdate()}handleViewChanged(e){const{model:t}=this.props,{selectionEndRow:n=0}=this.grid?.state??{};let s=0;if(Ze(t)&&t.isEditable){M(e);const{bottomViewport:i}=e,o=t.rowCount-t.floatingBottomRowCount;n===o-1?s=t.pendingRowCount+1:n===o-2?s=t.pendingRowCount:s=Math.max(0,i-(t.rowCount-t.pendingRowCount)-t.floatingTopRowCount-t.floatingBottomRowCount-1)}this.setState({metrics:e,pendingRowCount:s})}handleSelectionChanged(e){M(e);const{onSelectionChanged:t}=this.props,{copyOperation:n}=this.state;this.setState({selectedRanges:e}),n!=null&&this.setState({copyOperation:null}),t(e)}handleMovedColumnsChanged(e,t){this.setState({movedColumns:e},t)}handleHeaderGroupsChanged(e){const{model:t}=this.props;this.setState({columnHeaderGroups:be.parseColumnHeaderGroups(t,e).groups},()=>this.grid?.forceUpdate())}handleTooltipRef(e){e?.startTimer(),this.tooltip=e}handleConditionalFormatsChange(e){pe.debug("Updated conditional formats",e),this.setState({conditionalFormats:e})}handleConditionalFormatCreate(){pe.debug("Create new conditional format");const{openOptions:e,conditionalFormats:t}=this.state;this.setState({openOptions:[...e,{type:De.CONDITIONAL_FORMATTING_EDIT,title:"Create Formatting Rule"}],conditionalFormatEditIndex:t.length,conditionalFormatPreview:void 0})}handleConditionalFormatEdit(e){pe.debug("Edit conditional format",e);const{openOptions:t,conditionalFormats:n}=this.state;this.setState({openOptions:[...t,{type:De.CONDITIONAL_FORMATTING_EDIT,title:"Edit Formatting Rule"}],conditionalFormatEditIndex:e,conditionalFormatPreview:{...n[e]}})}handleConditionalFormatEditorUpdate=Ye(e=>{this.setState({conditionalFormatPreview:e})},_y);handleConditionalFormatEditorSave(e){pe.debug("Save conditional format changes",e),this.setState(t=>{if(t.conditionalFormatEditIndex===null)return pe.debug("Invalid format index"),null;const n=[...t.conditionalFormats];return n[t.conditionalFormatEditIndex]=e,{conditionalFormats:n}},()=>{this.handleMenuBack()})}handleConditionalFormatEditorCancel(){this.handleMenuBack(),this.setState({conditionalFormatEditIndex:null})}handleUpdateCustomColumns(e){pe.info("handleUpdateCustomColumns:",e);const{model:t}=this.props,{movedColumns:n,sorts:s,quickFilters:i,advancedFilters:o,selectDistinctColumns:a}=this.state,{columns:r}=t,c=t.customColumns.map(u=>`${u}`),h=be.getRemovedCustomColumnNames(c,e);if(h.length>0){const u=be.removeSortsInColumns(s,h),m=be.removeFiltersInColumns(r,i,h),g=be.removeFiltersInColumns(r,o,h),p=be.removeColumnFromMovedColumns(r,n,h),C=be.removeColumnsFromSelectDistinctColumns(a,h);u.length!==s.length&&(pe.debug("removing sorts from removed custom columns..."),this.setState({sorts:u})),(m.size!==i.size||g.size!==o.size)&&(pe.debug("removing filters from removed custom columns..."),this.setState({quickFilters:m,advancedFilters:g})),it(n,p)||(pe.debug("change moved columns for removed custom columns",p),this.setState({movedColumns:p})),it(a,C)||(pe.debug("change selectDistinct columns for removed custom columns",p),this.setState({selectDistinctColumns:C}))}this.setState({customColumns:e}),e.length>0&&this.startLoading("Applying custom columns...")}handleCustomColumnsChanged(){pe.debug("custom columns changed");const{isReady:e}=this.state;e?(this.stopLoading(),this.grid?.forceUpdate()):this.initState()}handlePendingCommitClicked(){return this.commitPending()}handlePendingDiscardClicked(){return this.discardPending()}handlePendingDataUpdated(){pe.debug("pending data updated");const{model:e}=this.props,{pendingDataMap:t,pendingDataErrors:n}=e;this.setState({pendingDataMap:t,pendingDataErrors:n,pendingSaveError:null}),this.grid?.forceUpdate()}handleAggregationsChange(e){pe.debug("handleAggregationsChange",e),this.startLoading(`Aggregating ${e.aggregations.map(t=>t.operation).join(", ")}...`),this.setState({aggregationSettings:e})}handleAggregationChange(e){pe.debug("handleAggregationChange",e),this.startLoading(`Aggregating ${e.operation}...`),this.setState(({aggregationSettings:t})=>({selectedAggregation:e,aggregationSettings:{...t,aggregations:t.aggregations.map(n=>n.operation===e.operation?e:n)}}))}handleAggregationEdit(e){pe.debug("handleAggregationEdit",e);const{openOptions:t}=this.state;this.setState({openOptions:[...t,{type:De.AGGREGATION_EDIT,title:`Edit Columns to ${e.operation}`}],selectedAggregation:e})}handleRollupChange(e){pe.info("Rollup change",e),this.resetGridViewState(),this.showAllColumns(),this.clearAllFilters(),this.startLoading(`Grouping by columns ${e?.columns?.join(", ")??""}...`),this.setState({rollupConfig:e,movedColumns:[],sorts:[],reverseType:x.REVERSE_TYPE.NONE,selectDistinctColumns:[]})}handleSelectDistinctChanged(e){pe.debug("SelectDistinct change",e),this.resetGridViewState(),this.showAllColumns(),this.clearAllFilters(),this.startLoading(`Selecting distinct values in ${e.length>0?e.join(", "):""}...`),this.setState({selectDistinctColumns:e,movedColumns:[],sorts:[],reverseType:x.REVERSE_TYPE.NONE})}handleDownloadTableStart(){const{canDownloadCsv:e}=this.props;e?this.setState({isTableDownloading:!0,tableDownloadProgress:0,tableDownloadEstimatedTime:null,tableDownloadStatus:Ks.DOWNLOAD_STATUS.INITIATING}):pe.error("Attempted to handleDownloadTableStart for user without download CSV permission.")}handleDownloadTable(e,t,n,s,i,o,a){const{canDownloadCsv:r}=this.props;r?(pe.info("start table downloading",e,t,n,s,i,o,a),this.setState(()=>(this.tableSaver&&this.tableSaver.startDownload(e,t,n,s,i,o,a),{tableDownloadStatus:Ks.DOWNLOAD_STATUS.DOWNLOADING}))):pe.error("Attempted to handleDownloadTable for user without download CSV permission.")}async seekRow(e,t=!1){const{gotoValueSelectedColumnName:n,gotoValueSelectedFilter:s}=this.state,{model:i}=this.props;if(!i.isSeekRowAvailable||e==="")return;const o=be.getColumnByName(i.columns,n);if(o===void 0)return;let a=this.grid?.state.cursorRow;a==null&&(a=0);const r=s===X.contains,c=s===X.eq||s===X.eqIgnoreCase;try{const{formatter:h}=i,u=x.getNormalizedType(o.type);let m;switch(u){case x.dataType.CHAR:case x.dataType.STRING:{m=await i.seekRow(a,o,R.ValueType.STRING,e,c,r,t??!1);break}case x.dataType.DATETIME:{const[g]=et.parseDateRange(e,h.timeZone);m=await i.seekRow(a,o,R.ValueType.DATETIME,g,void 0,void 0,t??!1);break}case x.dataType.DECIMAL:case x.dataType.INT:{if(!x.isBigDecimalType(o.type)&&!x.isBigIntegerType(o.type)){let g=parseInt(e,10);e==="-Infinity"?g=Number.NEGATIVE_INFINITY:e==="Infinity"&&(g=Number.POSITIVE_INFINITY),m=await i.seekRow(a,o,R.ValueType.NUMBER,g,void 0,void 0,t??!1)}else m=await i.seekRow(a,o,R.ValueType.STRING,e,void 0,void 0,t??!1);break}default:m=await i.seekRow(a,o,R.ValueType.STRING,x.makeValue(o.type,e,h.timeZone),void 0,void 0,t??!1)}this.grid?.setFocusRow(m),this.setState({gotoValueError:""})}catch{this.setState({gotoValueError:"invalid input"})}}handleCancelDownloadTable(){this.tableSaver?.cancelDownload(),this.setState({isTableDownloading:!1})}handleDownloadProgressUpdate=Ls((e,t)=>{const{tableDownloadStatus:n}=this.state;n===Ks.DOWNLOAD_STATUS.DOWNLOADING&&this.setState({tableDownloadProgress:e,tableDownloadEstimatedTime:t})},Ay);handleDownloadCompleted(){this.setState({isTableDownloading:!1,tableDownloadProgress:100,tableDownloadStatus:Ks.DOWNLOAD_STATUS.FINISHED})}handleDownloadCanceled(){this.setState({isTableDownloading:!1,tableDownloadProgress:0,tableDownloadStatus:Ks.DOWNLOAD_STATUS.CANCELED})}deleteRanges(e){const{model:t}=this.props;this.pending.add(t.delete(e)).catch(n=>{ve.isCanceled(n)||pe.error("Unable to delete ranges",e,n)})}resetColumnSelection(){if(this.grid==null)return;const{isSelectingColumn:e}=this.props;if(e){const{columnAllowedCursor:t}=this.props;this.grid.setState({cursor:t})}else this.grid.setState({cursor:null}),this.setState({hoverSelectColumn:null})}resetGridViewState(e=!0){this.grid&&(this.grid.clearSelectedRanges(),this.grid.setViewState({left:0,top:0,topOffset:0,leftOffset:0},e))}sendStateChange(){if(!this.grid)return;const{state:e}=this,{state:t}=this.grid,{onStateChange:n}=this.props;n(e,t)}handleOverflowClose(){this.setState({showOverflowModal:!1})}getColumnBoundingRect(){const{metrics:e,shownColumnTooltip:t}=this.state;M(e),M(t);const n=this.gridWrapper?.getBoundingClientRect(),s=20;M(n);const{columnHeaderHeight:i,allColumnXs:o,allColumnWidths:a,width:r,columnHeaderMaxDepth:c}=e,h=o.get(t),u=a.get(t);M(h),M(u);const m=n.left+He(h+u/2,s,r-s);return{top:n.top+(c-1)*i,left:n.left+He(h+u/2,s,r-s),bottom:n.top+c*i,right:n.left+He(h+u/2,s,r-s)+1,width:1,height:i,x:m,y:n.top,toJSON:()=>{throw new Error("not implemented")}}}getOverflowButtonTooltip=ge(e=>{if(e==null)return null;const t={position:"absolute",...e,pointerEvents:"none"},n={placement:"left",modifiers:{flip:{behavior:["left","right"]}}};return l.jsx("div",{style:t,children:l.jsx(tt,{options:n,ref:this.handleTooltipRef,children:"View full contents"},Date.now())})});getExpandCellTooltip=ge(e=>{if(e==null)return null;const{expandTooltipDisplayValue:t}=this.state,n={position:"absolute",...e,pointerEvents:"none"},s={placement:"bottom-start"};return l.jsx("div",{style:n,children:l.jsx(tt,{options:s,ref:this.handleTooltipRef,children:l.jsxs("div",{style:{textAlign:"left"},children:["Click to ",t," row",l.jsx("br",{}),Ve.isMacPlatform()?"⌘":"Ctrl+","Click to expand row and all children"]})},Date.now())})});getLinkHoverTooltip=ge(e=>{if(e==null)return null;const{linkHoverDisplayValue:t}=this.state,n={position:"absolute",...e,pointerEvents:"none"},s={placement:"bottom"};return l.jsx("div",{style:n,children:l.jsx(tt,{options:s,ref:this.handleTooltipRef,children:l.jsxs("div",{className:"link-hover-tooltip",children:[t," - Click once to follow.",l.jsx("br",{}),"Click and hold to select this cell."]})})})});handleGotoRowSelectedRowNumberSubmit(){const{gotoRow:e}=this.state;this.focusRowInGrid(e)}focusRowInGrid(e){const{model:t}=this.props,{rowCount:n}=t;if(this.setState({gotoRow:e}),e===""){this.setState({gotoRowError:"",gotoValueError:""});return}const s=parseInt(e,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(e){const t=e.target.value;this.focusRowInGrid(t)}getColumnTooltip(e,t,n){const{columnHeaderHeight:s,columnHeaderMaxDepth:i,allColumnXs:o,allColumnWidths:a,width:r}=t,c=o.get(e),h=a.get(e);if(c==null||h==null)return null;const u=Math.max(0,c);let m=h;c+h>r?m=r-c:c<0&&(m=h-Math.abs(c));const g={position:"absolute",top:(i-1)*s,left:u,width:m,height:s,pointerEvents:"none"},p={clientWidth:1,clientHeight:s,getBoundingClientRect:this.getColumnBoundingRect},C={placement:"bottom",modifiers:{flip:{behavior:["bottom","top"]}}},f=this.getModelColumn(e);if(f==null)return null;const S=n.columns[f];return S==null?null:l.jsx("div",{style:g,children:l.jsx(tt,{timeout:400,interactive:!0,options:C,ref:this.handleTooltipRef,referenceObject:p,onExited:()=>{this.setState({shownColumnTooltip:null})},children:l.jsx(zT,{model:n,column:S,onStatistics:()=>{this.tooltip?.update()}})},S.name)})}handleGotoValueSelectedColumnNameChanged(e){const{model:t}=this.props,n=this.grid?.state.cursorRow;if(n!=null){const s=t.getColumnIndexByName(e),i=be.getColumnByName(t.columns,e);if(s==null||i==null)return;const o=t.valueForCell(s,n),a=be.convertValueToText(o,i.type);this.setState({gotoValueSelectedColumnName:e,gotoValue:a,gotoValueError:""})}this.setState({gotoValueSelectedColumnName:e,gotoValueError:""})}handleGotoValueSelectedFilterChanged(e){this.setState({gotoValueSelectedFilter:e,gotoValueError:""})}handleGotoValueChanged=e=>{this.setState({gotoValue:e}),this.debouncedSeekRow(e)};debouncedSeekRow=Ye(e=>{this.seekRow(e)},Py);handleGotoValueSubmitted(e){const{gotoValue:t}=this.state;this.seekRow(t,e)}render(){const{children:e,customFilters:t,getDownloadWorker:n,isSelectingColumn:s,isStuckToBottom:i,isStuckToRight:o,model:a,name:r,onlyFetchVisibleColumns:c,alwaysFetchColumns:h,advancedSettings:u,onAdvancedSettingsChange:m,canDownloadCsv:g,onCreateChart:p}=this.props,{metricCalculator:C,metrics:f,isFilterBarShown:S,isSelectingPartition:v,isMenuShown:w,isReady:T,copyOperation:y,focusedFilterBarColumn:E,loadingText:D,loadingScrimProgress:F,loadingSpinnerShown:N,keyHandlers:_,mouseHandlers:P,shownColumnTooltip:U,hoverAdvancedFilter:O,shownAdvancedFilter:j,hoverSelectColumn:k,quickFilters:A,advancedFilters:H,partition:K,partitionFilters:q,partitionTable:oe,partitionColumn:W,searchFilter:G,selectDistinctColumns:ne,movedColumns:ae,movedRows:ce,formatter:te,conditionalFormats:re,conditionalFormatPreview:we,conditionalFormatEditIndex:Ie,sorts:xe,reverseType:at,customColumns:xt,selectedRanges:en,isTableDownloading:Rn,tableDownloadStatus:kt,tableDownloadProgress:ye,tableDownloadEstimatedTime:ut,showSearchBar:rt,searchValue:bt,selectedSearchColumns:Ot,invertSearchColumns:xn,aggregationSettings:tn,selectedAggregation:jo,rollupConfig:Vs,openOptions:nn,pendingSavePromise:as,pendingSaveError:mi,pendingRowCount:eo,pendingDataErrors:gi,pendingDataMap:pi,toastMessage:Ho,frozenColumns:Vo,columnHeaderGroups:rs,showOverflowModal:Bs,overflowText:xr,overflowButtonTooltipProps:Bo,expandCellTooltipProps:to,linkHoverTooltipProps:no,isGotoShown:so,gotoRow:Uo,gotoRowError:Ir,gotoValueError:Dr,gotoValueSelectedColumnName:Fr,gotoValue:Nr,gotoValueSelectedFilter:Mr}=this.state;if(!T)return null;const Us=this.getTheme(),$o=this.getCachedFilter(t,A,H,q,G),fi=C.getUserColumnWidths(),Wo=this.getCachedStateOverride(k,S,s,F,A,H,xe,at,Vs,w),$s=f?f.top:0,Go=f?f.bottomViewport:0;let io=null,oo=null;c&&(io=f?f.left:0,oo=f?f.right:0);const zo=f!=null&&f.width>0&&f.height>0,Ko=(Vs?.columns?.length??0)>0;let qo=null;const kr=f?Math.min(Math.max(Xn.minDebounce,Math.round(f.rowCount/200)),Xn.maxDebounce):Xn.maxDebounce;if(S&&E!=null&&f!=null){const{gridX:Xe,gridY:Oe,allColumnXs:sn,allColumnWidths:ao,width:Ci}=f,ls=sn.get(E),At=ao.get(E);if(ls!=null&&At!=null){const It=Xe+ls,Vn=Oe-(Us.filterBarHeight??0),Ws=At+1,Gs=(Us.filterBarHeight??0)-1,ta={top:Vn,left:It,minWidth:Math.min(Ws,Ci-It),height:Gs};let Bn="",Si=!0;const zs=this.getModelColumn(E);M(zs);const bi=A.get(zs),cs=H.get(zs);bi!=null&&(Bn=bi.text,Si=bi.filter!=null);const wi=A.size!==0||H.size!==0;qo=l.jsx(Jv,{ref:this.filterInputRef,style:ta,className:$({error:!Si,active:Bn!==""||cs!=null,"iris-grid-has-filter":wi}),isAdvancedFilterSet:cs!=null,onAdvancedFiltersTriggered:()=>{this.setState({shownAdvancedFilter:E})},onChange:this.handleFilterBarChange,onDone:this.handleFilterBarDone,onTab:this.handleFilterBarTab,onContextMenu:this.grid?.handleContextMenu,debounceMs:kr,value:Bn},E)}}let Yo=null;if(D!=null){const Xe=l.jsxs("div",{className:"iris-grid-loading-status",children:[l.jsx("div",{className:$("iris-grid-loading-status-bar",{show:N}),children:D}),l.jsxs("button",{type:"button",onClick:this.handleCancel,className:$("iris-grid-btn-cancel",{show:N}),children:[l.jsx(Q,{icon:qi,transform:"down-1"}),"Cancel"]})]}),Oe=f?f.gridY:0;Yo=l.jsx("div",{className:"iris-grid-loading",style:{top:Oe},children:Xe})}let Xo=null;U!=null&&f&&(Xo=this.getColumnTooltip(U,f,a),this.tooltip?.update());const Zo=[];if(f&&S){const{gridX:Xe,gridY:Oe,visibleColumns:sn,allColumnXs:ao,allColumnWidths:Ci}=f,{filterBarHeight:ls}=Us;for(let At=0;At<sn.length;At+=1){const It=sn[At],Vn=ao.get(It),Ws=Ci.get(It),Gs=this.getModelColumn(It);if(Gs!=null&&a.isFilterable(Gs)&&Vn!=null&&Ws!=null&&Ws>0){const Bn=Xe+Vn+Ws-24,zs={position:"absolute",top:Oe-(ls??0)+2,left:Bn},cs=H.get(Gs)!=null,wi=It===O||It===E||cs,Ar=l.jsx("div",{className:$("advanced-filter-button-container",{hidden:!wi}),style:zs,children:wi&&l.jsx(B,{kind:"ghost",className:$("btn-link-icon advanced-filter-button",{"filter-set":cs}),onClick:()=>{this.setState({shownAdvancedFilter:It})},onContextMenu:jm=>{this.grid?.handleContextMenu(jm)},onMouseEnter:()=>{this.setState({hoverAdvancedFilter:It})},onMouseLeave:()=>{this.setState({hoverAdvancedFilter:null})},children:l.jsxs("div",{className:"fa-layers",children:[l.jsx(Q,{icon:kl,className:"filter-solid"}),l.jsx(Q,{icon:Fa,className:"filter-light"})]})})},It);Zo.push(Ar)}}}const Qo=[];if(f){const{gridX:Xe,visibleColumns:Oe,allColumnXs:sn,allColumnWidths:ao,columnHeaderHeight:Ci}=f;for(let ls=0;ls<Oe.length;ls+=1){const At=Oe[ls],It=sn.get(At),Vn=ao.get(At);if(It!=null&&Vn!=null&&Vn>0){const Ws=Xe+It,Gs=Xe+It+Vn-20,ta=S?{position:"absolute",top:Ci,left:Gs,width:20,height:Us.filterBarHeight}:{position:"absolute",top:0,left:Ws,width:Vn,height:Ci},Bn=this.getModelColumn(At);if(Bn!=null){const Si=a.columns[Bn],zs=H.get(Bn),{options:bi}=zs||{},cs=x.getSortForColumn(a.sort,Si.name),wi=cs?cs.direction:null,Ar=l.jsx("div",{className:"advanced-filter-menu-container",style:ta,children:l.jsx(hi,{className:"advanced-filter-menu-popper",onEntered:this.getAdvancedMenuOpenedHandler(At),onExited:()=>{this.handleAdvancedMenuClosed(At)},isShown:j===At,interactive:!0,closeOnBlur:!0,options:{positionFixed:!0},children:this.getCachedAdvancedFilterMenuActions(a,Si,bi,wi,te)})},At);Qo.push(Ar)}}}}const Jo=this.getCachedOptionItems(p!==void 0&&a.isChartBuilderAvailable,a.isCustomColumnsAvailable,a.isFormatColumnsAvailable,a.isRollupAvailable,a.isTotalsAvailable||Ko,a.isSelectDistinctAvailable,a.isExportAvailable,this.toggleFilterBarAction,this.toggleSearchBarAction,this.toggleGotoRowAction,S,rt,g,this.isTableSearchAvailable(),so,u.size>0),ea=this.getCachedHiddenColumns(C,fi),Or=nn.map(Xe=>{switch(Xe.type){case De.CHART_BUILDER:return l.jsx(rE,{model:a,onChange:this.handleChartChange,onSubmit:this.handleChartCreate},De.CHART_BUILDER);case De.VISIBILITY_ORDERING_BUILDER:return l.jsx(WE,{model:a,movedColumns:ae,hiddenColumns:ea,columnHeaderGroups:rs,onColumnVisibilityChanged:this.handleColumnVisibilityChanged,onReset:this.handleColumnVisibilityReset,onMovedColumnsChanged:this.handleMovedColumnsChanged,onColumnHeaderGroupChanged:this.handleHeaderGroupsChanged},De.VISIBILITY_ORDERING_BUILDER);case De.CONDITIONAL_FORMATTING:return l.jsx(ny,{rules:re,onChange:this.handleConditionalFormatsChange,onCreate:this.handleConditionalFormatCreate,onSelect:this.handleConditionalFormatEdit});case De.CONDITIONAL_FORMATTING_EDIT:return M(a.columns),M(this.handleConditionalFormatEditorUpdate),l.jsx(Fy,{columns:a.columns,rule:we,onUpdate:this.handleConditionalFormatEditorUpdate,onSave:this.handleConditionalFormatEditorSave,onCancel:this.handleConditionalFormatEditorCancel});case De.CUSTOM_COLUMN_BUILDER:return l.jsx(uE,{model:a,customColumns:xt,onSave:this.handleUpdateCustomColumns,onCancel:this.handleMenuBack},De.CUSTOM_COLUMN_BUILDER);case De.ROLLUP_ROWS:return l.jsx(gE,{model:a,onChange:this.handleRollupChange,config:Vs},De.ROLLUP_ROWS);case De.AGGREGATIONS:return l.jsx(ZT,{settings:tn,isRollup:Ko,onChange:this.handleAggregationsChange,onEdit:this.handleAggregationEdit});case De.AGGREGATION_EDIT:return jo&&l.jsx(JT,{aggregation:jo,columns:a.originalColumns,onChange:this.handleAggregationChange});case De.TABLE_EXPORTER:return l.jsx(Ks,{model:a,name:r,userColumnWidths:fi,movedColumns:ae,isDownloading:Rn,tableDownloadStatus:kt,tableDownloadProgress:ye,tableDownloadEstimatedTime:ut??void 0,onDownload:this.handleDownloadTable,onDownloadStart:this.handleDownloadTableStart,onCancel:this.handleCancelDownloadTable,selectedRanges:en},De.TABLE_EXPORTER);case De.SELECT_DISTINCT:return l.jsx(JE,{model:a,selectDistinctColumns:ne,onChange:this.handleSelectDistinctChanged});case De.ADVANCED_SETTINGS:return l.jsx(fc,{items:u,onChange:m});default:throw Error(`Unexpected option type ${Xe.type}`)}});return l.jsxs("div",{className:"iris-grid",role:"presentation",children:[l.jsxs("div",{className:"iris-grid-column",children:[e!=null&&l.jsx("div",{className:"iris-grid-bar",children:e}),l.jsx(ft,{in:v,timeout:ze.transitionSlowMs,classNames:"iris-grid-bar-horizontal",onEnter:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExit:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:l.jsx("div",{className:"iris-grid-partition-selector-wrapper iris-grid-bar iris-grid-bar-primary",children:oe&&W&&K!=null&&l.jsx(XE,{table:oe,getFormattedString:(Xe,Oe,sn)=>a.displayString(Xe,Oe,sn),columnName:W.name,partition:K,onChange:this.handlePartitionChange,onFetchAll:this.handlePartitionFetchAll,onAppend:this.handlePartitionAppend,onDone:this.handlePartitionDone})})}),l.jsx(ft,{in:rt,timeout:ze.transitionSlowMs,classNames:"iris-grid-bar-horizontal",onEnter:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExit:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:l.jsx("div",{className:"iris-grid-bar",children:l.jsx(ga,{value:bt,selectedColumns:Ot,invertSelection:xn,onChange:this.handleCrossColumnSearch,columns:a.columns,ref:this.crossColumnRef})})}),l.jsxs("div",{className:"grid-wrapper",ref:Xe=>{this.gridWrapper=Xe},children:[l.jsx(Es,{ref:Xe=>{this.grid=Xe},isStickyBottom:!Ze(a)||!a.isEditable,isStuckToBottom:i,isStuckToRight:o,metricCalculator:C,model:a,keyHandlers:_,mouseHandlers:P,movedColumns:ae,movedRows:ce,onError:this.handleGridError,onViewChanged:this.handleViewChanged,onSelectionChanged:this.handleSelectionChanged,onMovedColumnsChanged:this.handleMovedColumnsChanged,renderer:this.renderer,stateOverride:Wo,theme:Us}),l.jsx(Ny,{isOpen:Bs,text:xr,onClose:this.handleOverflowClose}),zo&&l.jsx(HT,{model:a,modelColumns:a.columns,top:$s,bottom:Go,left:io,right:oo,filter:$o,formatter:te,sorts:xe,reverseType:at,movedColumns:ae,customColumns:xt,hiddenColumns:ea,alwaysFetchColumns:this.getAlwaysFetchColumns(h,a.columns,ae,a.floatingLeftColumnCount,a.floatingRightColumnCount,this.grid?.state.draggingColumn?.range),formatColumns:this.getCachedPreviewFormatColumns(a.columns,re,we,nn[nn.length-1]?.type===De.CONDITIONAL_FORMATTING_EDIT?Ie??void 0:void 0),rollupConfig:this.getModelRollupConfig(a.originalColumns,Vs,tn),totalsConfig:this.getModelTotalsConfig(a.columns,Vs,tn),selectDistinctColumns:ne,pendingRowCount:eo,pendingDataMap:pi,frozenColumns:Vo,columnHeaderGroups:rs}),!w&&l.jsx("div",{className:"grid-settings-button",children:l.jsx(B,{kind:"ghost","data-testid":`btn-iris-grid-settings-button-${r}`,onClick:this.handleMenu,icon:l.jsx(Q,{icon:mp,transform:"up-1"}),tooltip:"Table Options"})}),qo,Yo,Zo,Xo,Qo,Bo&&this.getOverflowButtonTooltip(Bo),to&&this.getExpandCellTooltip(to),no&&this.getLinkHoverTooltip(no)]}),l.jsx(Oy,{model:a,isShown:so,gotoRow:Uo,gotoRowError:Ir,gotoValueError:Dr,onGotoRowSubmit:this.handleGotoRowSelectedRowNumberSubmit,onGotoRowNumberChanged:this.handleGotoRowSelectedRowNumberChanged,onClose:this.handleGotoRowClosed,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:()=>{this.handleAnimationStart(),this.focus()},onExited:this.handleAnimationEnd,gotoValueSelectedColumnName:Fr,gotoValue:Nr,gotoValueFilter:Mr,onGotoValueSelectedColumnNameChanged:this.handleGotoValueSelectedColumnNameChanged,onGotoValueSelectedFilterChanged:this.handleGotoValueSelectedFilterChanged,onGotoValueChanged:this.handleGotoValueChanged,onGotoValueSubmit:this.handleGotoValueSubmitted}),l.jsx($v,{error:mi,isSaving:as!=null,saveTooltip:`Commit (${this.commitAction.shortcut.getDisplayText()})`,discardTooltip:`Discard (${this.discardAction.shortcut.getDisplayText()})`,pendingDataErrors:gi,pendingDataMap:pi,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd,onSave:this.handlePendingCommitClicked,onDiscard:this.handlePendingDiscardClicked}),l.jsx(LT,{children:Ho}),l.jsx(Zv,{model:a,copyOperation:y??void 0,onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd}),l.jsx(Yn,{ref:Xe=>{this.tableSaver=Xe},getDownloadWorker:n,onDownloadCompleted:this.handleDownloadCompleted,onDownloadCanceled:this.handleDownloadCanceled,onDownloadProgressUpdate:this.handleDownloadProgressUpdate,isDownloading:kt===Ks.DOWNLOAD_STATUS.DOWNLOADING,formatter:te})]}),l.jsx(ft,{in:w,timeout:ze.transitionMidMs,classNames:"slide-left",onEntering:this.handleAnimationStart,onEntered:this.handleAnimationEnd,onExiting:this.handleAnimationStart,onExited:this.handleAnimationEnd,mountOnEnter:!0,unmountOnExit:!0,children:l.jsx("div",{className:"table-sidebar",children:l.jsxs(_f,{children:[l.jsx(nd,{title:"Table Options",onClose:this.handleMenuClose,children:l.jsx(qh,{onSelect:Xe=>this.handleMenuSelect(Jo[Xe]),items:Jo})}),Or.map((Xe,Oe)=>l.jsx(nd,{title:nn[Oe].title,onBack:this.handleMenuBack,onClose:this.handleMenuClose,children:Xe},nn[Oe].type))]})})}),l.jsx(ie,{actions:this.contextActions})]})}}const pm=Xn;class Hy extends Error{isMissingKey=!0;rowIndex;columnName;constructor(e,t){super(`${t} can't be empty (on pending row ${e+1})`),this.rowIndex=e,this.columnName=t}}const Vy=Hy,nt=Z.module("IrisGridTableModel"),By=150,Uy=0,$y=[];function ai(d){return d.table!==void 0}class Do extends Se{static ROW_BUFFER_PAGES=1;seekRow(e,t,n,s,i,o,a){throw new Error("Method not implemented.")}export(){throw new Error("Method not implemented.")}columnStatistics(e){throw new Error("Method not implemented.")}get customColumns(){return[]}set customColumns(e){throw new Error("Method not implemented.")}get formatColumns(){return[]}set formatColumns(e){throw new Error("Method not implemented.")}updateFrozenColumns(e){throw new Error("Method not implemented.")}get rollupConfig(){throw new Error("Method not implemented.")}set rollupConfig(e){throw new Error("Method not implemented.")}get selectDistinctColumns(){throw new Error("Method not implemented.")}set selectDistinctColumns(e){throw new Error("Method not implemented.")}get columns(){return this.table.columns}irisFormatter;inputTable;subscription;table;viewport;viewportData;formattedStringData;pendingStringData;isSaveInProgress;totalsTable;totalsTablePromise;totals;totalsDataMap;pendingNewDataMap;pendingNewRowCount=0;_columnHeaderGroupMap=new Map;columnHeaderParentMap=new Map;_columnHeaderMaxDepth=null;_columnHeaderGroups=[];_movedColumns=null;constructor(e,t=new Qt,n=null){super(),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=t,this.inputTable=n,this.subscription=null,this.table=e,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=be.parseColumnHeaderGroups(this,this.layoutHints?.columnGroups??[]).groups}close(){this.table.close(),this.totalsTable!==null&&this.totalsTable.close(),this.totalsTablePromise!==null&&this.totalsTablePromise.cancel()}startListening(){super.startListening(),this.table.addEventListener(R.Table.EVENT_DISCONNECT,this.handleTableDisconnect),this.table.addEventListener(R.Table.EVENT_RECONNECT,this.handleTableReconnect),this.table.addEventListener(R.Table.EVENT_UPDATED,this.handleTableUpdate),this.table.addEventListener(R.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed),this.table.addEventListener(R.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleCustomColumnsChanged),this.totalsTable!=null&&this.addTotalsListeners(this.totalsTable),this.applyViewport()}stopListening(){super.stopListening(),this.table.removeEventListener(R.Table.EVENT_DISCONNECT,this.handleTableDisconnect),this.table.removeEventListener(R.Table.EVENT_RECONNECT,this.handleTableReconnect),this.table.removeEventListener(R.Table.EVENT_UPDATED,this.handleTableUpdate),this.table.removeEventListener(R.Client.EVENT_REQUEST_FAILED,this.handleRequestFailed),this.table.removeEventListener(R.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleCustomColumnsChanged),this.totalsTable!=null&&this.removeTotalsListeners(this.totalsTable),this.closeSubscription()}addTotalsListeners(e){e.addEventListener(R.Table.EVENT_UPDATED,this.handleTotalsUpdate),e.setViewport(0,0)}removeTotalsListeners(e){e.removeEventListener(R.Table.EVENT_UPDATED,this.handleTotalsUpdate)}handleTableDisconnect(){this.dispatchEvent(new Ue(Se.EVENT.DISCONNECT))}handleTableReconnect(){this.dispatchEvent(new Ue(Se.EVENT.RECONNECT))}handleTableUpdate(e){this.copyViewportData(e.detail),this.dispatchEvent(new Ue(Se.EVENT.UPDATED))}handleTotalsUpdate(e){this.copyTotalsData(e.detail),this.dispatchEvent(new Ue(Se.EVENT.UPDATED))}handleRequestFailed(e){this.dispatchEvent(new Ue(Se.EVENT.REQUEST_FAILED,e))}handleCustomColumnsChanged(){this.dispatchEvent(new Ue(Se.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(e){e!==this.pendingNewDataMap&&(e.forEach((t,n)=>{if(!be.isValidIndex(n))throw new Error(`Invalid rowIndex ${n}`);const{data:s}=t;s.forEach((i,o)=>{if(!be.isValidIndex(o))throw new Error(`Invalid columnIndex ${o}`)})}),this.pendingNewDataMap=e,this.pendingNewRowCount=Math.max(this.pendingNewRowCount,this.maxPendingDataRow),this.formattedStringData=[],this.dispatchEvent(new Ue(Se.EVENT.PENDING_DATA_UPDATED)))}get pendingRowCount(){return this.pendingNewRowCount}set pendingRowCount(e){e!==this.pendingNewRowCount&&(this.pendingNewRowCount=Math.max(0,e,this.maxPendingDataRow),this.dispatchEvent(new Ue(Se.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(e,t,n){this.formattedStringData[e]==null&&(this.formattedStringData[e]=[]),this.formattedStringData[e][t]=n}cachePendingValue(e,t,n){this.pendingStringData[e]==null&&(this.pendingStringData[e]=[]),this.pendingStringData[e][t]=n}clearPendingValue(e,t){const n=this.pendingStringData[e];n!=null&&delete n[t]}textValueForCell(e,t){if(this.pendingStringData[e]?.[t]!==void 0)return this.pendingStringData[e][t];if(this.formattedStringData[e]?.[t]===void 0){const n=this.valueForCell(e,t);if(n==null)return null;const s=this.totalsColumn(e,t)??this.columns[e],i=this.getCachedCustomColumnFormatFlag(this.formatter,s.name,s.type);let o;if(!i){const r=this.formatForCell(e,t);r?.formatString!=null&&(o=r)}const a=this.displayString(n,s.type,s.name,o);this.cacheFormattedValue(e,t,a)}return this.formattedStringData[e][t]}textForCell(e,t){const n=this.textValueForCell(e,t);if(n==null&&this.isKeyColumn(e)){const s=this.pendingRow(t);if(s!=null&&this.pendingDataMap.has(s))return"*"}return n??""}truncationCharForCell(e){const t=this.columns[e],{type:n}=t;if(x.isNumberType(n)&&this.formatter.truncateNumbersWithPound)return"#"}colorForCell(e,t,n){const s=this.dataForCell(e,t);if(s){const{format:i,value:o}=s;if(o==null||o==="")return M(n.nullStringColor),n.nullStringColor;if(i&&i.color)return i.color;if(this.isPendingRow(t))return M(n.pendingTextColor),n.pendingTextColor;if(o!=null){const a=this.totalsColumn(e,t)??this.columns[e];if(x.isDateType(a.type)||a.name==="Date")return M(n.dateColor),n.dateColor;if(x.isNumberType(a.type))return o>0?(M(n.positiveNumberColor),n.positiveNumberColor):o<0?(M(n.negativeNumberColor),n.negativeNumberColor):(M(n.zeroNumberColor),n.zeroNumberColor)}}else if(this.isPendingRow(t)&&this.isKeyColumn(e))return M(n.errorTextColor),n.errorTextColor;return n.textColor}backgroundColorForCell(e,t){return this.formatForCell(e,t)?.backgroundColor??null}textAlignForCell(e){const t=this.columns[e],{type:n}=t;return x.isNumberType(n)?"right":x.isDateType(n)||t.name==="Date"?"center":"left"}textForColumnHeader(e,t=0){const n=this.columnAtDepth(e,t);return Gr(n)?n.isNew?"":n.name:n?.name}colorForColumnHeader(e,t=0){const n=this.columnAtDepth(e,t);return Gr(n)?n.color??null:null}getColumnHeaderGroup(e,t){const n=this.columnAtDepth(e,t);if(Gr(n))return n}getColumnHeaderParentGroup(e,t){return this.columnHeaderParentMap.get(this.columnAtDepth(e,t)?.name??"")}columnAtDepth(e,t=0){if(t===0)return this.columns[e];const n=this.columns[e]?.name;let s=this.columnHeaderParentMap.get(n);if(!s)return;let i=s.depth;for(;i<t;){if(s=this.columnHeaderParentMap.get(s.name),!s)return;i=s.depth}if(s.depth===t)return s}textForRowFooter(e){const t=this.totalsRow(e);return t!=null&&this.totals?this.totals.operationOrder[t]:""}getMemoizedInitialMovedColumns=fe(e=>{if(!e)return[];let t=[];const{groupMap:n}=be.parseColumnHeaderGroups(this,e?.columnGroups??[]),s=(h,u)=>{const m=this.getColumnIndexByName(h);if(m==null)throw new Error(`Unknown layout hint column: ${h}`);const g=V.getVisibleIndex(m,t);t=V.moveItem(g,u,t)},i=(h,u)=>{const m=n.get(h);if(m==null)throw new Error(`Unknown layout hint group: ${h}`);const g=m.getVisibleRange(t);t=V.moveRange(g,u,t)},{frontColumns:o=[],backColumns:a=[],frozenColumns:r=[]}=e;if(o.length||a.length||r.length){const h=new Set;let u=0;r.forEach(g=>{if(h.has(g))throw new Error(`Column specified in multiple layout hints: ${g}`);s(g,u),u+=1}),o.forEach(g=>{if(h.has(g))throw new Error(`Column specified in multiple layout hints: ${g}`);s(g,u),u+=1});let m=this.columnMap.size-1;a.forEach(g=>{if(h.has(g))throw new Error(`Column specified in multiple layout hints: ${g}`);s(g,m),m-=1})}if(e?.columnGroups){const h=[...n.values()];h.sort((u,m)=>u.depth-m.depth),h.forEach(u=>{const m=u.children[0],g=this.getColumnIndexByName(m);let p;if(g!=null)p=V.getVisibleIndex(g,t);else{const C=n.get(m);if(!C)throw new Error(`Unknown column ${m} in group ${u.name}`);[,p]=C.getVisibleRange(t)}for(let C=1;C<u.children.length;C+=1){const f=u.children[C],S=n.get(f),v=this.getColumnIndexByName(f);if(S){const T=S.getVisibleRange(t)[0]<p?p-S.childIndexes.length+1:p+1;i(f,T),p=T+S.childIndexes.length-1}else if(v!=null){const T=V.getVisibleIndex(v,t)<p?p:p+1;s(f,T),p=T}}})}return this._movedColumns=t,t});get initialMovedColumns(){return this.getMemoizedInitialMovedColumns(this.layoutHints??void 0)}get initialMovedRows(){return $y}getMemoizedInitialColumnHeaderGroups=fe(e=>be.parseColumnHeaderGroups(this,e?.columnGroups??[]).groups);get initialColumnHeaderGroups(){return this.getMemoizedInitialColumnHeaderGroups(this.layoutHints??void 0)}getMemoizedColumnMap=fe(e=>{const t=new Map;return e.forEach(n=>t.set(n.name,n)),t});get columnMap(){return this.getMemoizedColumnMap(this.table.columns)}get columnHeaderMaxDepth(){return this._columnHeaderMaxDepth??1}set columnHeaderMaxDepth(e){this._columnHeaderMaxDepth=e}get columnHeaderGroupMap(){return this._columnHeaderGroupMap}get columnHeaderGroups(){return this._columnHeaderGroups}set columnHeaderGroups(e){if(e===this._columnHeaderGroups)return;const{groups:t,maxDepth:n,parentMap:s,groupMap:i}=be.parseColumnHeaderGroups(this,e??this.initialColumnHeaderGroups);this._columnHeaderGroups=t,this.columnHeaderMaxDepth=n,this.columnHeaderParentMap=s,this._columnHeaderGroupMap=i}get groupedColumns(){return[]}row(e){const t=this.totals?.operationOrder?.length??0,n=this.totals?.showOnTop??!1,s=this.totalsRow(e);if(s!=null){const r=this.totals?.operationOrder[s];return M(r),this.totalsDataMap?.get(r)??null}const i=this.pendingRow(e);if(i!=null)return this.pendingNewDataMap.get(i)??null;const o=this.viewportData?.offset??0,a=(n?e-t:e)-o;return this.viewportData?.rows?.[a]??null}totalsColumn(e,t){const n=this.totalsRow(t);if(n==null)return null;const s=this.totals?.operationOrder[n],i=this.totals?.defaultOperation??ke.SUM,o=this.columns[e];return this.totalsTable?.columns.find(a=>a.name===`${o.name}__${s}`||(s===i||this.totals?.operationOrder.length===1)&&a.name===o.name)}totalsRow(e){const t=this.totals?.operationOrder?.length??0,s=this.totals?.showOnTop??!1?e:e-this.table.size;return s>=0&&s<t?s:null}pendingRow(e){const t=e-this.floatingTopRowCount-this.table.size;return t>=0&&t<this.pendingNewRowCount?t:null}isTotalsRow(e){return this.totalsRow(e)!=null}isPendingRow(e){return this.pendingRow(e)!=null}dataForCell(e,t){return this.row(t)?.data.get(e)}formatForCell(e,t){return this.dataForCell(e,t)?.format}valueForCell(e,t){const n=this.dataForCell(e,t);if(n)return n.value??null}copyViewportData(e){if(e==null){nt.warn("invalid data!");return}this.viewportData=this.extractViewportData(e),this.formattedStringData=[]}copyTotalsData(e){if(e==null){nt.warn("invalid data!");return}const{columns:t,rows:n}=e;if(n.length!==1){nt.error("Unexpected number of rows received for totals table, ignoring update");return}const s=new Map,i=n[0],o=this.totals?.defaultOperation??ke.SUM,a=this.totals?.operationMap;for(let r=0;r<t.length;r+=1){const c=t[r],[h,u=a?.[h]?.[0]??o]=c.name.split("__");s.has(u)||s.set(u,{data:new Map});const{data:m}=s.get(u),g=this.columns.findIndex(p=>p.name===h);m.set(g,{value:i.get(c),format:i.getFormat(c)})}nt.debug2("copyTotalsData",s),this.totalsDataMap=s,this.formattedStringData=[]}getColumnIndexByName(e){return this.getColumnIndicesByNameMap(this.columns).get(e)}getColumnIndicesByNameMap=fe(e=>{const t=new Map;return e.forEach(({name:n},s)=>t.set(n,s)),t});extractViewportData(e){const t={offset:e.offset,rows:[]},{columns:n}=e;for(let s=0;s<e.rows.length;s+=1){const i=e.rows[s],o=this.extractViewportRow(i,n);t.rows.push(o)}return t}extractViewportRow(e,t){const n=new Map;for(let s=0;s<t.length;s+=1){const i=t[s],o=this.getColumnIndexByName(i.name);M(o),n.set(o,{value:e.get(i),format:e.getFormat(i)})}return{data:n}}closeSubscription(){nt.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(e){this.closeSubscription(),this.table.applyFilter(e),this.applyViewport()}get formatter(){return this.irisFormatter}set formatter(e){this.irisFormatter=e,this.formattedStringData=[],this.dispatchEvent(new Ue(Se.EVENT.FORMATTER_UPDATED))}displayString(e,t,n="",s){return this.getCachedFormattedString(this.formatter,e,t,n,s)}get sort(){return this.table.sort}set sort(e){this.closeSubscription(),this.table.applySort(e),this.applyViewport()}set totalsConfig(e){if(nt.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 Ue(Se.EVENT.UPDATED));return}this.totalsTablePromise=ve.makeCancelable(this.table.getTotalsTable(e),t=>t.close()),this.totalsTablePromise.then(t=>{this.totalsTablePromise=null,this.setTotalsTable(t)}).catch(t=>{ve.isCanceled(t)||(nt.error("Unable to set next totalsTable",t),this.totalsTablePromise=null,this.dispatchEvent(new Ue(Se.EVENT.REQUEST_FAILED,{detail:t})))})}}setTotalsTable(e){nt.debug("setTotalsTable",e),this.totalsTable!==null&&(this.listenerCount>0&&this.removeTotalsListeners(this.totalsTable),this.totalsTable.close()),this.totalsTable=e,this.totalsDataMap=null,this.listenerCount>0&&this.totalsTable!=null&&this.addTotalsListeners(this.totalsTable)}setViewport=Ls((e,t,n)=>{if(t<e){nt.error("Invalid viewport",e,t);return}const{viewport:s}=this;if(s!=null&&s.top===e&&s.bottom===t&&s.columns===n){nt.debug2("Ignoring duplicate viewport",s);return}this.viewport={top:e,bottom:t,columns:n},nt.debug2("setViewport",this.viewport),this.applyViewport()},By);applyViewport=Ls(()=>{if(!this.viewport)return;nt.debug2("applyViewport",this.viewport);const{top:e,bottom:t,columns:n}=this.viewport,[s,i]=this.getCachedViewportRowRange(e,t);this.applyBufferedViewport(s,i,n)},Uy,{leading:!1});applyBufferedViewport(e,t,n){nt.debug2("applyBufferedViewport",e,t,n),this.subscription==null?(nt.debug2("applyBufferedViewport creating new subscription"),this.subscription=this.table.setViewport(e,t,n)):(nt.debug2("applyBufferedViewport using existing subscription"),this.subscription.setViewport(e,t,n))}async snapshot(e,t=!1,n=i=>i,s=!0){if(this.subscription==null)throw new Error("No subscription available");const i=s?z.consolidate(e):e;if(!be.isValidSnapshotRanges(i))throw new Error(`Invalid snapshot ranges ${e}`);const o=new Set,a=[],r=new Set;for(let g=0;g<i.length;g+=1){const p=i[g];M(p.endRow),M(p.startRow);for(let C=p.startRow;C<=p.endRow&&C<this.floatingTopRowCount;C+=1)o.add(C);p.endRow>=this.floatingTopRowCount&&p.startRow<=this.floatingTopRowCount+this.table.size&&a.push(new z(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 C=Math.max(p.startRow,this.floatingTopRowCount+this.table.size);C<=p.endRow&&C<this.floatingTopRowCount+this.table.size+this.floatingBottomRowCount;C+=1)r.add(C)}const c=be.columnsFromRanges(i,this.columns),h=[];t&&h.push(c.map(g=>g.name));const u=[...o].sort();for(let g=0;g<u.length;g+=1){const p=u[g],C=c.map(f=>{const S=this.getColumnIndexByName(f.name);return M(S),n(this.valueForCell(S,p),f)});t&&C.push(this.textForRowFooter(p)),h.push(C)}if(a.length>0){const g=be.rangeSetFromRanges(a),p=await this.subscription.snapshot(g,c);h.push(...p.rows.map(C=>c.map(f=>n(C.get(f),f))))}const m=[...r].sort();for(let g=0;g<m.length;g+=1){const p=m[g],C=c.map(f=>{const S=this.getColumnIndexByName(f.name);return M(S),n(this.valueForCell(S,p),f)});t&&C.push(this.textForRowFooter(p)),h.push(C)}return h}async textSnapshot(e,t=!1,n=s=>`${s}`){return nt.debug2("textSnapshot",e,t),(await this.snapshot(e,t,n,!1)).map(i=>i.join(" ")).join(`
32
- `)}async valuesTable(e){let t=null;try{return t=await this.table.copy(),t.applyFilter([]),t.applySort([]),t.selectDistinct([e])}finally{t?.close()}}getCachedFormattedString=Zn((e,t,n,s,i)=>e.getFormattedString(t,n,s,i),{max:1e4});getCachedCustomColumnFormatFlag=Zn(ns.isCustomColumnFormatDefined,{max:1e4});getCachedViewportRowRange=fe((e,t)=>{const n=t-e,s=Math.max(0,e-n*Do.ROW_BUFFER_PAGES),i=t+n*Do.ROW_BUFFER_PAGES;return[s,i]});getCachedPendingErrors=fe((e,t,n)=>{const s=new Map;return e.forEach((i,o)=>{const{data:a}=i;for(let r=0;r<n;r+=1)a.has(r)||(s.has(o)||s.set(o,[]),s.get(o)?.push(new Vy(o,t[r].name)))}),s});isColumnMovable(e,t){if(e<0||e>=this.columnCount)return!1;if(t>0)return!0;const n=this.columns[e].name;return this.frontColumns.includes(n)||this.backColumns.includes(n)||this.frozenColumns.includes(n)||!n?!1:!this.isKeyColumn(e)}isKeyColumn(e){return e<(this.inputTable?.keyColumns.length??0)}isRowMovable(){return!1}isEditableRange(e){return!(this.inputTable==null||!z.isBounded(e)||!(this.isPendingRow(e.startRow)&&this.isPendingRow(e.endRow)||this.inputTable.keyColumns.length!==0&&e.startColumn>=this.inputTable.keyColumns.length&&e.endColumn>=this.inputTable.keyColumns.length)||e.startRow<this.floatingTopRowCount||e.startRow>=this.floatingTopRowCount+this.table.size+this.pendingRowCount||e.endRow>=this.floatingTopRowCount+this.table.size+this.pendingRowCount)}isDeletableRange(e){return this.inputTable!=null&&e.startRow!=null&&e.endRow!=null&&e.startRow>=this.floatingTopRowCount&&e.startRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount&&e.endRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount}isEditableRanges(e){return e.every(t=>this.isEditableRange(t))}isDeletableRanges(e){return e.every(t=>this.isDeletableRange(t))}getTableAreaRange(){return new z(null,this.floatingTopRowCount,null,this.floatingTopRowCount+this.table.size-1)}getPendingAreaRange(){return new z(null,this.floatingTopRowCount+this.table.size,null,this.floatingTopRowCount+this.table.size+this.pendingNewRowCount-1)}async setValueForCell(e,t,n){return this.setValueForRanges([new z(e,t,e,t)],n)}async setValueForRanges(e,t){if(!this.isEditableRanges(e))throw new Error(`Uneditable ranges ${e}`);try{const n=new Set,s=[];z.forEachCell(e,(c,h)=>{const u=this.columns[c];if(n.add(u),s[c]===void 0){const m=x.makeValue(u.type,t,this.formatter.timeZone);s[c]=m!=null?this.displayString(m,u.type,u.name):null}this.cachePendingValue(c,h,s[c])});const i=this.getPendingAreaRange(),o=e.map(c=>z.intersection(i,c)).filter(c=>c!=null).map(c=>(M(c),z.offset(c,0,-(this.floatingTopRowCount+this.table.size))));if(o.length>0){const c=new Map(this.pendingNewDataMap);z.forEachCell(o,(h,u)=>{c.has(u)||c.set(u,{data:new Map});const m=this.columns[h],g=c.get(u);M(g);const{data:p}=g,C=new Map(p),f=x.makeValue(m.type,t,this.formatter.timeZone);f!=null?C.set(h,{value:f}):C.delete(h),C.size>0?c.set(u,{...g,data:C}):c.delete(u)}),this.pendingDataMap=c}this.dispatchEvent(new Ue(Se.EVENT.UPDATED));const a=this.getTableAreaRange(),r=e.map(c=>z.intersection(a,c)).filter(c=>c!=null);if(r.length>0){const h=(await this.snapshot(r.map(m=>new z(null,m?.startRow??null,null,m?.endRow??null)))).map(m=>{const g={};for(let p=0;p<this.columns.length;p+=1)g[this.columns[p].name]=m[p];return n.forEach(p=>{g[p.name]=x.makeValue(p.type,t,this.formatter.timeZone)}),g}),u=await this.inputTable?.addRows(h);nt.debug("setValueForRanges(",e,",",t,") set tableRanges",r,"result",u)}z.forEachCell(e,(c,h)=>{const u=s[c];M(u),this.cacheFormattedValue(c,h,u)})}catch(n){nt.error("Unable to set ranges",e,t,n)}finally{z.forEachCell(e,(n,s)=>{this.clearPendingValue(n,s)})}}async setValues(e=[]){if(nt.debug("setValues(",e,")"),!e.every(t=>this.isEditableRange(z.makeCell(t.column??t.x,t.row??t.y))))throw new Error(`Uneditable ranges ${e}`);try{const t=new Map(this.pendingNewDataMap);e.forEach(a=>{const{text:r}=a,c=a.column??a.x,h=a.row??a.y,u=this.columns[c],m=x.makeValue(u.type,r,this.formatter.timeZone),g=m!=null?this.displayString(m,u.type,u.name):null;this.cachePendingValue(c,h,g);const p=this.pendingRow(h);if(p!=null){t.has(p)||t.set(p,{data:new Map});const C=t.get(p);M(C);const{data:f}=C,S=new Map(f);m!=null?S.set(c,{value:m}):S.delete(c),S.size>0?t.set(p,{...C,data:S}):t.delete(p)}}),this.pendingDataMap=t,this.dispatchEvent(new Ue(Se.EVENT.UPDATED));const n=e.reduce((a,r)=>{const c=r.row??r.y;return a.has(c)||a.set(c,[]),a.get(c)?.push(r),a},new Map),s=z.consolidate(e.map(a=>z.makeCell(a.column??a.x,a.row??a.y))),i=this.getTableAreaRange(),o=s.map(a=>z.intersection(i,a)).filter(a=>a!=null);if(o.length>0){const r=(await this.snapshot(o.map(h=>(M(h),new z(null,h.startRow,null,h.endRow))))).map((h,u)=>{let m=null,g=u;for(let f=0;f<o.length;f+=1){const S=o[f];M(S);const v=z.rowCount([S]);if(g<v){M(S.startRow),m=S.startRow+g;break}g-=v}const p={};for(let f=0;f<this.columns.length;f+=1)p[this.columns[f].name]=h[f];M(m);const C=n.get(m);return C?.forEach(f=>{const S=this.columns[f.column??f.x];p[S.name]=x.makeValue(S.type,f.text,this.formatter.timeZone)}),p});nt.info("setValues setting tableRanges",o);const c=await this.inputTable?.addRows(r);nt.info("setValues set tableRanges",o,"SUCCESS",c)}e.forEach(a=>{const{text:r}=a,c=a.column??a.x,h=a.row??a.y,u=this.columns[c],m=x.makeValue(u.type,r,this.formatter.timeZone),g=m!=null?this.displayString(m,u.type,u.name):null;this.cacheFormattedValue(c,h,g)})}finally{e.forEach(t=>{this.clearPendingValue(t.column,t.row)})}}async commitPending(){if(this.pendingNewDataMap.size<=0)throw new Error("No pending changes to commit");try{this.isSaveInProgress=!0;const e=[];this.pendingNewDataMap.forEach(n=>{const s={};n.data.forEach(({value:i},o)=>{const a=this.columns[o];s[a.name]=i}),e.push(s)});const t=await this.inputTable?.addRows(e);nt.debug("commitPending()",this.pendingNewDataMap,"result",t),this.pendingNewDataMap=new Map,this.pendingNewRowCount=Math.max(0,(this.viewport?.bottom??0)-this.table.size),this.formattedStringData=[],this.dispatchEvent(new Ue(Se.EVENT.PENDING_DATA_UPDATED))}finally{this.isSaveInProgress=!1}}editValueForCell(e,t){return this.textValueForCell(e,t)}async delete(e){if(!this.isDeletableRanges(e))throw new Error(`Undeletable ranges ${e}`);M(this.inputTable);const{keyColumns:t}=this.inputTable;if(t.length===0)throw new Error("No key columns to allow deletion");const n=this.getPendingAreaRange(),s=e.map(u=>z.intersection(n,u)).filter(u=>u!=null).map(u=>(M(u),z.offset(u,0,-(this.floatingTopRowCount+this.table.size))));if(s.length>0){const u=new Map(this.pendingNewDataMap);for(let m=0;m<s.length;m+=1){const g=s[m];M(g.startRow),M(g.endRow);for(let p=g.startRow;p<=g.endRow;p+=1)u.delete(p)}this.pendingNewDataMap=u,this.formattedStringData=[],this.dispatchEvent(new Ue(Se.EVENT.PENDING_DATA_UPDATED)),this.dispatchEvent(new Ue(Se.EVENT.UPDATED))}const i=this.getTableAreaRange(),o=e.map(u=>z.intersection(i,u)).filter(u=>u!=null);if(o.length<=0)return;const[a,r]=await Promise.all([this.snapshot(o.map(u=>(M(u),new z(0,u.startRow,t.length-1,u.endRow)))),this.table.copy()]),h=a.map(u=>{const m=[];for(let g=0;g<t.length;g+=1){const p=t[g],C=u[g],f=x.makeFilterRawValue(p.type,C),S=p.filter().eq(f);m.push(S)}return m.reduce((g,p)=>g?.and(p)??p)}).reduce((u,m)=>u?.or(m)??m);r.applyFilter([h]),r.close()}isValidForCell(e,t,n){try{const s=this.columns[e];return x.makeValue(s.type,n,this.formatter.timeZone),!0}catch{return!1}}}const Cs=Z.module("IrisGridTableModel");class Wy extends Do{userFrozenColumns;customColumnList;formatColumnList;constructor(e,t=new Qt,n=null){super(e,t,n),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}getMemoizedFrontColumns=fe(e=>e??[]);get frontColumns(){return this.getMemoizedFrontColumns(this.layoutHints?.frontColumns)}getMemoizedBackColumns=fe(e=>e??[]);get backColumns(){return this.getMemoizedBackColumns(this.layoutHints?.backColumns)}getMemoizedFrozenColumns=fe((e,t)=>t??e??[]);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(Cs.debug2("set customColumns",e,this.customColumnList,e===this.customColumnList),this.customColumnList.length===0&&e.length===0){Cs.debug("Ignore empty initial customColumns"),this.customColumnList=e;return}if(this.customColumnList===e){Cs.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(Cs.debug2("set formatColumns",e,this.formatColumnList,e===this.formatColumnList),this.formatColumnList.length===0&&e.length===0){Cs.debug("Ignore empty initial formatColumns"),this.formatColumnList=e;return}if(this.formatColumnList===e){Cs.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 Ue(Se.EVENT.TABLE_CHANGED,{detail:this.table}))}set totalsConfig(e){if(Cs.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 Ue(Se.EVENT.UPDATED));return}this.totalsTablePromise=ve.makeCancelable(this.table.getTotalsTable(e),t=>t.close()),this.totalsTablePromise.then(t=>{this.totalsTablePromise=null,this.setTotalsTable(t)}).catch(t=>{ve.isCanceled(t)||(Cs.error("Unable to set next totalsTable",t),this.totalsTablePromise=null,this.dispatchEvent(new Ue(Se.EVENT.REQUEST_FAILED,{detail:t})))})}}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)}getCachedFilterableColumnSet=fe(e=>new Set(e.map((t,n)=>n)));isColumnMovable(e){const t=this.columns[e].name;return this.frontColumns.includes(t)||this.backColumns.includes(t)||this.frozenColumns.includes(t)?!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}`);M(this.inputTable);const{keyColumns:t}=this.inputTable;if(t.length===0)throw new Error("No key columns to allow deletion");const n=this.getPendingAreaRange(),s=e.map(u=>z.intersection(n,u)).filter(u=>u!=null).map(u=>(M(u),z.offset(u,0,-(this.floatingTopRowCount+this.table.size))));if(s.length>0){const u=new Map(super.pendingDataMap);for(let m=0;m<s.length;m+=1){const g=s[m];M(g.startRow),M(g.endRow);for(let p=g.startRow;p<=g.endRow;p+=1)u.delete(p)}super.pendingDataMap=u,this.formattedStringData=[],this.dispatchEvent(new Ue(Se.EVENT.PENDING_DATA_UPDATED)),this.dispatchEvent(new Ue(Se.EVENT.UPDATED))}const i=this.getTableAreaRange(),o=e.map(u=>z.intersection(i,u)).filter(u=>u!=null);if(o.length<=0)return;const[a,r]=await Promise.all([this.snapshot(o.map(u=>(M(u),new z(0,u.startRow,t.length-1,u.endRow)))),this.table.copy()]),h=a.map(u=>{const m=[];for(let g=0;g<t.length;g+=1){const p=t[g],C=u[g],f=x.makeFilterRawValue(p.type,C),S=p.filter().eq(f);m.push(S)}return m.reduce((g,p)=>g?.and(p)??p)}).reduce((u,m)=>u?.or(m)??m);r.applyFilter([h]),await this.inputTable?.deleteTable(r),r.close()}async seekRow(e,t,n,s,i,o,a){return this.table.seekRow(e,t,n,s,i,o,a)}get isSeekRowAvailable(){return this.table.seekRow!=null}}const fm=Wy;class Gy extends Do{applyBufferedViewport(e,t,n){this.table.setViewport(e,t,n)}textForCell(e,t){const n=this.columns[e],s=this.row(t);if(s!=null&&n!=null&&!s.hasChildren&&n.constituentType!=null){const i=this.valueForCell(e,t);return this.displayString(i,n.constituentType,n.name)}return super.textForCell(e,t)}extractViewportRow(e,t){const{isExpanded:n,hasChildren:s,depth:i}=e;return{...super.extractViewportRow(e,t),isExpanded:n,hasChildren:s,depth:i}}async snapshot(e,t,n){M(this.viewport),M(this.viewportData);const{columns:s}=this.viewport,i=[];t!=null&&t&&i.push(s.map(a=>a.name));const o=new z(0,this.viewportData?.offset,s.length,this.viewportData.offset+this.viewportData.rows.length);for(let a=0;a<e.length;a+=1){const r=z.intersection(o,e[a]);M(r),M(r.startRow),M(r.endRow);for(let c=r.startRow;c<=r.endRow;c+=1){const h=[],u=this.viewportData.rows[c-this.viewportData.offset];M(r.startColumn),M(r.endColumn);for(let m=r.startColumn;m<=r.endColumn;m+=1)M(n),h.push(n(u.data.get(m)?.value,this.columns[m]));i.push(h)}}return i}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,t,n=!1){this.isExpandAllAvailable?this.table.setExpanded(e,t,n):this.table.setExpanded(e,t)}expandAll(){this.table.expandAll&&this.table.expandAll()}collapseAll(){this.table.collapseAll&&this.table.collapseAll()}depthForRow(e){return(this.row(e)?.depth??1)-1}getCachedFilterableColumnSet=fe((e,t)=>new Set((t?.length>0?t:e).map(n=>e.findIndex(s=>n.name===s.name))))}const zy=Gy,Ss=Z.module("IrisGridProxyModel");function Qr(d,e,t){return x.isTreeTable(d)?new zy(d,e):new fm(d,e,t)}class Ky extends Se{originalModel;model;modelPromise;rollup;selectDistinct;constructor(e,t=new Qt,n=null){super(),this.handleModelEvent=this.handleModelEvent.bind(this);const s=Qr(e,t,n);this.originalModel=s,this.model=s,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){Ss.debug2("handleModelEvent",e);const{detail:t,type:n}=e;this.dispatchEvent(new Ue(n,{detail:t}))}setModel(e){Ss.debug("setModel",e);const t=this.model;t!==this.originalModel&&t.close(),this.model=e,this.listenerCount>0&&this.addListeners(e),this.dispatchEvent(new Ue(Se.EVENT.COLUMNS_CHANGED,{detail:e.columns})),ai(e)&&this.dispatchEvent(new Ue(Se.EVENT.TABLE_CHANGED,{detail:e.table}))}setNextModel(e){Ss.debug2("setNextModel"),this.modelPromise&&this.modelPromise.cancel(),this.listenerCount>0&&this.removeListeners(this.model),this.modelPromise=ve.makeCancelable(e,t=>t.close()),this.modelPromise.then(t=>{this.modelPromise=null,this.setModel(t)}).catch(t=>{if(ve.isCanceled(t)){Ss.debug2("setNextModel cancelled");return}Ss.error("Unable to set next model",t),this.modelPromise=null,this.dispatchEvent(new Ue(Se.EVENT.REQUEST_FAILED,{detail:t}))})}startListening(){super.startListening(),this.addListeners(this.model)}stopListening(){super.stopListening(),this.removeListeners(this.model)}addListeners(e){const t=Object.keys(Se.EVENT);for(let n=0;n<t.length;n+=1)e.addEventListener(t[n],this.handleModelEvent)}removeListeners(e){const t=Object.keys(Se.EVENT);for(let n=0;n<t.length;n+=1)e.removeEventListener(t[n],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}textForCell=(...e)=>this.model.textForCell(...e);truncationCharForCell=(...e)=>this.model.truncationCharForCell(...e);textAlignForCell=(...e)=>this.model.textAlignForCell(...e);colorForCell=(...e)=>this.model.colorForCell(...e);backgroundColorForCell=(...e)=>this.model.backgroundColorForCell(...e);textForColumnHeader=(...e)=>this.model.textForColumnHeader(...e);colorForColumnHeader=(...e)=>this.model.colorForColumnHeader(...e);textForRowHeader=(...e)=>this.model.textForRowHeader(...e);textForRowFooter=(...e)=>this.model.textForRowFooter(...e);isRowMovable=(...e)=>this.model.isRowMovable(...e);isColumnMovable=(...e)=>this.model.isColumnMovable(...e);isColumnFrozen(e){return this.model.isColumnFrozen(e)}get hasExpandableRows(){return qe(this.model)?this.model.hasExpandableRows:!1}get isExpandAllAvailable(){return qe(this.model)?this.model.isExpandAllAvailable??!1:!1}isRowExpandable=(...e)=>qe(this.model)?this.model.isRowExpandable(...e):!1;isRowExpanded=(...e)=>qe(this.model)?this.model.isRowExpanded(...e):!1;setRowExpanded=(...e)=>{if(qe(this.model))return this.model.setRowExpanded(...e);throw Error("Function setRowExpanded does not exist on IrisGridTableModel")};expandAll=()=>{if(qe(this.model))return this.model.expandAll();throw Error("Function expandAll does not exist on IrisGridTableModel")};collapseAll=()=>{if(qe(this.model))return this.model.collapseAll();throw Error("Function collapseAll does not exist on IrisGridTableModel")};depthForRow=(...e)=>qe(this.model)?this.model.depthForRow(...e):0;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}getColumnHeaderGroup=(...e)=>this.model.getColumnHeaderGroup(...e);get columnHeaderGroups(){return this.model.columnHeaderGroups}set columnHeaderGroups(e){this.model.columnHeaderGroups=e}get initialColumnHeaderGroups(){return this.model.initialColumnHeaderGroups}getColumnHeaderParentGroup=(...e)=>this.model.getColumnHeaderParentGroup(...e);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}formatForCell=(...e)=>this.model.formatForCell(...e);valueForCell=(...e)=>this.model.valueForCell(...e);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}displayString=(...e)=>this.model.displayString(...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(Ss.debug("set rollupConfig",e),!this.isRollupAvailable)throw new Error("Rollup Rows are not available");if(it(e,this.rollup))return;this.rollup=e;let t=Promise.resolve(this.originalModel);ai(this.originalModel)&&e!=null&&(t=this.originalModel.table.rollup(e).then(n=>Qr(n,this.formatter))),this.setNextModel(t)}get selectDistinctColumns(){return this.selectDistinct}set selectDistinctColumns(e){if(Ss.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){Ss.debug("Ignore same selectDistinctColumns",e);return}this.selectDistinct=e;const t=e.map(s=>this.originalColumns.find(i=>i.name===s)).filter(s=>s!=null);let n=Promise.resolve(this.originalModel);ai(this.originalModel)&&t.length>0&&(n=this.originalModel.table.selectDistinct(t).then(s=>Qr(s,this.formatter))),this.setNextModel(n)}get table(){if(ai(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 Ze(this.model)&&this.model.isEditable}isEditableRange=(...e)=>Ze(this.model)?this.model.isEditableRange(...e):!1;isFilterable=(...e)=>this.model.isFilterable(...e);setViewport=(e,t,n)=>this.model.setViewport(e,t,n);snapshot=(...e)=>this.model.snapshot(...e);textSnapshot=(...e)=>this.model.textSnapshot(...e);export(){if(x.isTreeTable(this.model))throw new Error("TreeTable has no 'export' property");return this.model.export()}valuesTable=(...e)=>this.model.valuesTable(...e);columnStatistics(e){if(x.isTreeTable(this.model))throw new Error("TreeTable has no 'columnStatistics' function");return this.model.columnStatistics(e)}editValueForCell=(...e)=>Ze(this.model)?this.model.editValueForCell(...e):"";setValueForCell=(...e)=>Ze(this.model)?this.model.setValueForCell(...e):Promise.reject(new Error("Model is not editable"));setValueForRanges=(...e)=>Ze(this.model)?this.model.setValueForRanges(...e):Promise.reject(new Error("Model is not editable"));setValues=(...e)=>Ze(this.model)?this.model.setValues(...e):Promise.resolve();isValidForCell=(...e)=>Ze(this.model)?this.model.isValidForCell(...e):!1;delete=(...e)=>this.model.delete(...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}commitPending=(...e)=>this.model.commitPending(...e);getColumnIndexByName(e){return this.model.getColumnIndexByName(e)}async seekRow(e,t,n,s,i,o,a){return this.model.seekRow(e,t,n,s,i,o,a)}get isSeekRowAvailable(){return this.model.isSeekRowAvailable}}const qy=Ky;class Yy{static async makeModel(e,t=new Qt){let n=null;return!x.isTreeTable(e)&&e.hasInputTable&&(n=await e.inputTable()),new qy(e,t,n)}}const Cc=Yy;class bl{static OPEN="ChartEvent.OPEN";static CLOSE="ChartEvent.CLOSE";static COLUMN_SELECTED="ChartEvent.COLUMN_SELECTED"}class Xt{static SESSION_OPENED="ConsoleEvent.SESSION_OPENED";static SESSION_CLOSED="ConsoleEvent.SESSION_CLOSED";static FOCUS_HISTORY="ConsoleEvent.FOCUS_HISTORY";static SEND_COMMAND="ConsoleEvent.SEND_COMMAND";static SETTINGS_CHANGED="ConsoleEvent.SETTINGS_CHANGED"}class Qe{static TABLE_CHANGED="InputFilterEvent.TABLE_CHANGED";static COLUMNS_CHANGED="InputFilterEvent.COLUMNS_CHANGED";static FILTERS_CHANGED="InputFilterEvent.FILTERS_CHANGED";static CLEAR_ALL_FILTERS="InputFilterEvent.CLEAR_ALL_FILTERS";static COLUMN_SELECTED="InputFilterEvent.COLUMN_SELECTED";static OPEN_DROPDOWN="InputFilterEvent.OPEN_DROPDOWN";static OPEN_INPUT="InputFilterEvent.OPEN_INPUT";static OPEN_FILTER_SET_MANAGER="InputFilterEvent.OPEN_FILTER_SET_MANAGER"}class bn{static OPEN_GRID="IrisGridEvent.OPEN_GRID";static CLOSE_GRID="IrisGridEvent.CLOSE_GRID";static DATA_SELECTED="IrisGridEvent.DATA_SELECTED";static COLUMN_SELECTED="IrisGridEvent.COLUMN_SELECTED";static STATE_CHANGED="IrisGridEvent.STATE_CHANGED";static CREATE_CHART="IrisGridevent.CREATE_CHART"}const Cm=Object.freeze({OPEN:"MarkdownEvent.OPEN"});class $e{static CREATE_NOTEBOOK="NotebookEvent.createNotebook";static SELECT_NOTEBOOK="NotebookEvent.selectNotebook";static CLOSE_FILE="NotebookEvent.closeFile";static RENAME="NotebookEvent.rename";static RENAME_FILE="NotebookEvent.renameFile";static REGISTER_FILE="NotebookEvent.registerFile";static SEND_TO_NOTEBOOK="NotebookEvent.sendToNotebook";static UNREGISTER_FILE="NotebookEvent.unregisterFile";static PROMOTE_FROM_PREVIEW="NotebookEvent.promoteFromPreview"}class pa{static focus="TabEvent.focus";static blur="TabEvent.blur";static openPQObject="TabEvent.openPQObject";static openControl="TabEvent.openControl";static reload="TabEvent.reload";static clearAllFilters="TabEvent.clearAllFilters"}class Xy extends b.PureComponent{static defaultProps={additionalActions:[]};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(t=>(t?.contentItem).container?.close())}handleCloseTabsRight(){const{glContainer:e}=this.props,t=this.getAllTabs();for(let n=t.length-1;n>0&&t[n].contentItem?.config?.id!==e.tab?.contentItem?.config?.id;n-=1)(t[n]?.contentItem).container?.close()}canCloseTabsRight(){const{glContainer:e}=this.props,t=this.getAllTabs();let n=!0;for(let s=t.length-1;s>0&&t[s].contentItem?.config?.id!==e.tab?.contentItem?.config?.id;s-=1)if(Boolean(t[s]?.contentItem?.config?.isClosable)){n=!1;break}return n}canCloseAny(){const e=this.getAllTabs();let t=!0;for(let n=e.length-1;n>0;n-=1)if(Boolean(e[n]?.contentItem?.config?.isClosable)){t=!1;break}return t}render(){const{additionalActions:e,glContainer:t}=this.props,n=[...e],s=t.tab?.contentItem?.config?.isClosable;return n.push({title:"Close",order:10,group:ie.groups.low,action:this.handleCloseTab,disabled:s===void 0||!s}),n.push(()=>({title:"Close Tabs to Right",order:20,group:ie.groups.low,action:this.handleCloseTabsRight,disabled:this.canCloseTabsRight()})),n.push(()=>({title:"Close All",order:30,group:ie.groups.low,action:this.handleCloseTabsAll,disabled:this.canCloseAny()})),l.jsx(ie,{actions:n})}}class Zy extends b.PureComponent{static defaultProps={isShared:!1,isOwner:!0,itemType:"Item",value:""};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=J.createRef();const{value:t}=e;this.state={value:t,valueWasValidated:!1}}componentDidUpdate(e){const{isShown:t}=e,{isShown:n}=this.props;n&&!t&&this.resetState()}renameInputRef;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:t}=this.state,n=t?.trim();if(n!==void 0&&n!==""){const{onSubmit:s}=this.props;s(n)}else this.setState({value:n,valueWasValidated:!0})}renderRenameDialog(){const{isShared:e,isOwner:t,itemType:n}=this.props,{value:s,valueWasValidated:i}=this.state;return l.jsxs("form",{className:$("p-3",{"was-validated":i}),onSubmit:this.handleRenameSubmit,noValidate:!0,role:"presentation",onMouseDown:o=>{o.stopPropagation()},onMouseUp:o=>{o.stopPropagation()},children:[l.jsxs("div",{className:"form-group",children:[l.jsxs("label",{htmlFor:`rename-dialog-${n}-input`,children:["Rename ",n]}),l.jsx("input",{type:"text",className:"form-control",id:`rename-dialog-${n}-input`,value:s??void 0,ref:this.renameInputRef,onChange:this.handleRenameInputChange,required:!0}),l.jsxs("div",{className:"invalid-feedback",children:[n," name cannot be empty"]}),(e||!t)&&l.jsxs("div",{className:"pt-2",children:["Renaming this ",n," will rename for all users."]})]}),l.jsxs("div",{className:"text-right",children:[l.jsx(B,{kind:"secondary",className:"mr-2",onClick:this.handleRenameCancel,children:"Cancel"}),l.jsx(B,{kind:"primary",type:"submit",children:"Rename"})]})]})}render(){const{isShown:e,onCancel:t}=this.props;return l.jsx(hi,{isShown:e,onEntered:this.handleRenameDialogOpened,onExited:t,options:{placement:"bottom"},interactive:!0,closeOnBlur:!0,children:this.renderRenameDialog()})}}const Qy=Z.module("Panel");class os extends b.PureComponent{static 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};constructor(e){super(e),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:t}=this.props;this.state={title:Y.getTitleFromContainer(t),showRenameDialog:!1}}componentDidMount(){const{componentPanel:e,glContainer:t,glEventHub:n}=this.props;t.on("resize",this.handleResize),t.on("show",this.handleBeforeShow),t.on("shown",this.handleShow),t.on("hide",this.handleHide),t.on("tab",this.handleTab),t.on("tabClicked",this.handleTabClicked),n.on(Xt.SESSION_CLOSED,this.handleSessionClosed),n.on(Xt.SESSION_OPENED,this.handleSessionOpened),n.on(pa.focus,this.handleTabFocus),n.on(pa.blur,this.handleTabBlur),n.on(Qe.CLEAR_ALL_FILTERS,this.handleClearAllFilters),n.emit(Ee.MOUNT,e)}componentWillUnmount(){const{componentPanel:e,glContainer:t,glEventHub:n}=this.props;t.off("resize",this.handleResize),t.off("show",this.handleBeforeShow),t.off("shown",this.handleShow),t.off("hide",this.handleHide),t.off("tab",this.handleTab),t.off("tabClicked",this.handleTabClicked),n.off(Xt.SESSION_CLOSED,this.handleSessionClosed),n.off(Xt.SESSION_OPENED,this.handleSessionOpened),n.off(pa.focus,this.handleTabFocus),n.off(pa.blur,this.handleTabBlur),n.off(Qe.CLEAR_ALL_FILTERS,this.handleClearAllFilters),n.emit(Ee.UNMOUNT,e)}handleTab(e){e!=null&&this.setState({title:Y.getTitleFromTab(e)}),this.forceUpdate();const{onTab:t}=this.props;t(e)}handleTabClicked(e){const{onTabClicked:t}=this.props;t(e)}handleClearAllFilters(...e){const{onClearAllFilters:t}=this.props;t(...e)}handleFocus(e){const{componentPanel:t,glEventHub:n}=this.props;n.emit(Ee.FOCUS,t);const{onFocus:s}=this.props;s(e)}handleBlur(e){const{onBlur:t}=this.props;t(e)}handleHide(...e){const{onHide:t}=this.props;t(...e)}handleResize(...e){const{onResize:t}=this.props;t(...e)}handleSessionClosed(e){const{onSessionClose:t}=this.props;t(e)}handleSessionOpened(e,t){const{onSessionOpen:n}=this.props;n(e,t)}handleBeforeShow(...e){const{onBeforeShow:t}=this.props;t(...e)}handleShow(...e){const{onShow:t}=this.props;t(...e)}handleTabBlur(...e){const{onTabBlur:t}=this.props;t(...e)}handleTabFocus(...e){const{onTabFocus:t}=this.props;t(...e)}handleRenameCancel(){this.setState({showRenameDialog:!1})}handleShowRenameDialog(){this.setState({showRenameDialog:!0})}handleRenameSubmit(e){const{glContainer:t}=this.props;this.setState({showRenameDialog:!1,title:e});const n=Y.getRootFromContainer(t),s=Y.getComponentConfigFromContainer(t);M(s),Y.renameComponent(n,s,e)}handleCopyPanel(){const{glContainer:e,glEventHub:t}=this.props,n=Y.getRootFromContainer(e),s=Y.getComponentConfigFromContainer(e);if(s==null){Qy.error("Could not get component config from container",e);return}const i=Y.cloneComponent(n,s);i!==null&&t.emit(Ee.CLONED,this,i)}getCloneAction(){return{title:"Copy Panel",order:10,group:ie.groups.high,action:this.handleCopyPanel}}getRenameAction(){return{title:"Rename",order:10,group:ie.groups.medium,action:this.handleShowRenameDialog}}getAdditionActions=fe((e,t,n)=>{const s=[];return t&&s.push(this.getCloneAction()),n&&s.push(this.getRenameAction()),[...s,...e]});render(){const{children:e,className:t,renderTabTooltip:n,glContainer:s,additionalActions:i,errorMessage:o,isLoaded:a,isLoading:r,isClonable:c,isRenamable:h}=this.props,{tab:u}=s,{showRenameDialog:m,title:g}=this.state;return l.jsxs("div",{className:$("h-100 w-100 iris-panel",t),onFocusCapture:this.handleFocus,onBlurCapture:this.handleBlur,children:[e,l.jsx(sr,{errorMessage:o,isLoaded:a,isLoading:r}),u!=null&&Bi.createPortal(l.jsxs(l.Fragment,{children:[l.jsx(Xy,{glContainer:s,additionalActions:this.getAdditionActions(i,c,h)}),h&&l.jsx(Zy,{isShown:m,value:g,itemType:"Panel",onCancel:this.handleRenameCancel,onSubmit:this.handleRenameSubmit}),n!=null&&l.jsx(tt,{interactive:!0,options:{placement:"bottom"},popperClassName:"panel-tab-popper",children:n()})]}),u.element[0])]})}}function yr(d){const{widgetType:e,widgetName:t,glContainer:n,description:s,children:i}=d,o=Y.getTitleFromContainer(n);return l.jsxs("div",{className:"tab-tooltip-container",children:[l.jsxs("div",{className:"row flex-nowrap align-items-start",children:[l.jsx("span",{className:"tab-tooltip-title",children:l.jsxs("b",{children:[e," Name "]})}),l.jsx("span",{className:"tab-tooltip-name",children:t}),l.jsx(dr,{className:"tab-tooltip-copy",tooltip:"Copy name",copy:t})]}),t!==o&&l.jsxs("div",{className:"row",children:[l.jsx("span",{className:"tab-tooltip-title",children:l.jsx("b",{children:"Display Name"})}),l.jsx("span",{className:"tab-tooltip-name",children:o})]}),s&&l.jsx("div",{className:"row",children:l.jsx("span",{className:"tab-tooltip-description",children:s})}),i]})}yr.propTypes={glContainer:oc.Container.isRequired,widgetType:I.string,widgetName:I.string,description:I.string,children:I.node};yr.defaultProps={widgetType:"",widgetName:"",description:null,children:null};class Sc extends b.PureComponent{static 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:()=>{}};constructor(e){super(e),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;Yi(e)}getErrorMessage(){const{errorMessage:e}=this.props,{isClientDisconnected:t,isPanelDisconnected:n,isWidgetDisconnected:s,isWaitingForReconnect:i}=this.state;if(e)return`${e}`;if(t&&n&&i)return`Disconnected from server.
33
- Check your internet connection.`;if(t&&n)return"Disconnected from server.";if(n){const{widgetName:o,widgetType:a}=this.props;return`Variable "${o}" not set.
34
- ${a} does not exist yet.`}if(s){const{widgetName:o}=this.props;return`${o} is unavailable.`}}getCachedRenderTabTooltip=fe((e,t,n,s,i)=>e?()=>l.jsx(yr,{glContainer:t,widgetType:n,widgetName:s,description:i}):null);handleSessionClosed(...e){const{onSessionClose:t}=this.props;this.setState({isPanelDisconnected:!0,isWaitingForReconnect:!1}),t(...e)}handleSessionOpened(...e){const{onSessionOpen:t}=this.props;t(...e)}render(){const{children:e,className:t,componentPanel:n,isLoaded:s,isLoading:i,glContainer:o,glEventHub:a,isDisconnected:r,isClonable:c,isRenamable:h,showTabTooltip:u,renderTabTooltip:m,widgetType:g,widgetName:p,description:C,onClearAllFilters:f,onHide:S,onFocus:v,onBlur:w,onResize:T,onShow:y,onTabBlur:E,onTabFocus:D,onTabClicked:F}=this.props,{isPanelDisconnected:N,isWidgetDisconnected:_,isPanelInactive:P}=this.state,U=this.getErrorMessage(),O=m??this.getCachedRenderTabTooltip(u,o,g,p,C),j=[{title:`Copy ${g} Name`,group:ie.groups.medium,order:20,action:this.handleCopyName}];return l.jsxs(os,{className:$(t,{disconnected:N||_||r,inactive:P}),componentPanel:n,glContainer:o,glEventHub:a,onClearAllFilters:f,onHide:S,onFocus:v,onBlur:w,onResize:T,onShow:y,onSessionClose:this.handleSessionClosed,onSessionOpen:this.handleSessionOpened,onTabBlur:E,onTabFocus:D,onTabClicked:F,renderTabTooltip:O,errorMessage:U,isLoaded:s,isLoading:i,isClonable:c,isRenamable:h,additionalActions:j,children:[e,P&&l.jsx("div",{className:"fill-parent-absolute"})]})}}const Vt=Object.freeze({DEFAULT:"DEFAULT",LINKER:"LINKER"}),Jy="SET_SESSION_WRAPPER",eR=js(Jy,null),tR={sessionWrapper:eR},nR=new Map,Rr=Object.freeze([]),Sm=(d,e)=>$t(d,e).columns??Rr,sR=(d,e)=>$t(d,e).filterSets??Rr,bc=(d,e)=>$t(d,e).filters??Rr,wc=(d,e)=>$t(d,e).tableMap??nR,vc=(d,e)=>$t(d,e).isolatedLinkerPanelId,Ji=(d,e)=>$t(d,e).links??Rr,Tc=(d,e)=>$t(d,e).columnSelectionValidator,iR=(d,e)=>$t(d,e).connection,di=(d,e)=>$t(d,e).sessionWrapper,oR=(d,e)=>t=>t(Hn(d,{connection:e})),aR=(d,e)=>t=>t(Hn(d,{sessionWrapper:e})),Ec=(d,e)=>t=>t(Hn(d,{links:e})),rR=(d,e)=>(t,n)=>{const s=Ji(n(),d),i=e.filter(o=>s.findIndex(a=>it(a.start,o.start)&&it(a.end,o.end))<0);return t(Ec(d,s.concat(i)))},lR=(d,e)=>(t,n)=>{const i=Ji(n(),d).filter(o=>!e.includes(o.id));return t(Ec(d,i))},bm=(d,e)=>t=>t(Hn(d,{isolatedLinkerPanelId:e})),cR=(d,e)=>t=>t(Hn(d,{columnSelectionValidator:e})),dR=(d,e)=>t=>t(Hn(d,{consoleSettings:e})),hR=(d,e)=>t=>t(Hn(d,{filterSets:e}));Object.entries(tR).map(([d,e])=>Zi.register(d,e));function wm({columnMap:d,inputFilterMap:e,linkedColumnMap:t,onAdd:n,onOpenLinker:s,waitingFilterMap:i,waitingInputMap:o}){const a=b.useMemo(()=>{const g=Array.from(o.keys()),p=g.find(S=>e.get(S)!=null),C=g.find(S=>t.get(S)!=null),f=zt.join(g.map(S=>`"${S}"`));return p!=null&&p&&C!=null&&C?`Use a filter control or linked table to set a value for ${f}`:p!=null&&p?`Set a filter control value for ${f}`:`Double click a row in a linked table to set a value for ${f}`},[e,t,o]),r=b.useMemo(()=>Array.from(d.values()),[d]),c=b.useCallback(g=>{g.stopPropagation(),g.preventDefault(),n(Array.from(i.values()))},[n,i]),h=b.useCallback(g=>{g.stopPropagation(),g.preventDefault(),s()},[s]),u=i.size>0,m=!u&&o.size>0;return l.jsx("div",{className:"chart-panel-overlay chart-filter-overlay",children:l.jsxs("div",{className:$("chart-panel-overlay-content chart-filter-overlay-content",{"chart-filter-waiting-filter":u},{"chart-filter-waiting-input":m}),children:[u&&l.jsxs(l.Fragment,{children:[l.jsx("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:"}),l.jsx("div",{className:"waiting-filter-list",children:r.map(g=>{const p=i.has(g.name),C=p?As:Ml;return l.jsxs("div",{className:$("waiting-filter-item",{"is-invalid":p}),children:[l.jsx(Q,{icon:C}),g.name]},g.name)})}),l.jsxs("div",{children:[l.jsx(Gc,{onClick:c,className:"btn-primary",children:"Add Input Filters"}),l.jsx(Gc,{onClick:h,className:"btn-primary",children:"Open Linker Tool"})]})]}),m&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"info-message",children:"Waiting for User Input"}),l.jsx("div",{className:"",children:a})]})]})})}wm.propTypes={columnMap:I.instanceOf(Map).isRequired,inputFilterMap:I.instanceOf(Map).isRequired,linkedColumnMap:I.instanceOf(Map).isRequired,onAdd:I.func.isRequired,onOpenLinker:I.func.isRequired,waitingFilterMap:I.instanceOf(Map).isRequired,waitingInputMap:I.instanceOf(Map).isRequired};function Fo({columns:d,onColumnSelected:e,onMouseEnter:t,onMouseLeave:n}){return l.jsx("div",{className:"chart-panel-overlay chart-column-selector-overlay",children:l.jsxs("div",{className:$("chart-panel-overlay-content"),children:[l.jsx("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:"}),l.jsx("div",{className:"waiting-column-select-list",children:d.map(s=>l.jsx(Yh,{className:$("btn-chart-column-selector",Fo.makeButtonClassName(s.name)),onClick:()=>e(s.name),onMouseEnter:()=>{t&&t(s)},onMouseLeave:n,disabled:!s.isValid,isLinked:s.isActive,children:s.name},s.name))})]})})}Fo.makeButtonClassName=d=>`btn-chart-column-selector-${d}`;Fo.defaultProps={onMouseEnter:()=>{},onMouseLeave:()=>{}};function Ra(d){return d.settings!==void 0}const Gt=Z.module("ChartPanel"),uR=150;function mR(d){return d.inputFilters!=null}function gR(d){return d.panelState!=null}class pR extends b.Component{static defaultProps={columnSelectionValidator:null,isLinkerActive:!1,source:null,sourcePanel:null,panelState:null,settings:{}};static displayName="ChartPanel";static COMPONENT="ChartPanel";constructor(e){super(e),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=Ye(this.updateModelFromSource.bind(this),uR),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.panelContainer=J.createRef(),this.chart=J.createRef(),this.pending=new is;const{metadata:t,panelState:n}=e,{filterValueMap:s=[],settings:i={}}=n??{};this.state={settings:i,error:void 0,isActive:!1,isDisconnected:!1,isLoading:!1,isLoaded:!1,isLinked:t!=null&&Ra(t)&&t.settings.isLinked,filterMap:new Map(s),filterValueMap:new Map(s),model:void 0,columnMap:new Map,panelState:n}}componentDidMount(){this.isHidden()||(this.setState({isActive:!0}),this.initModel())}componentDidUpdate(e,t){const{inputFilters:n,source:s}=this.props,{columnMap:i,model:o,filterMap:a,filterValueMap:r,isLinked:c,settings:h}=this.state;o&&(i!==t.columnMap&&this.pruneFilterMaps(),n!==e.inputFilters&&this.updateChangedInputFilters(n,e.inputFilters),a!==t.filterMap?this.updateFilters():r!==t.filterValueMap&&this.updatePanelState(),h!==t.settings&&Td(o)&&(o.updateSettings(h),this.updatePanelState()),c!==t.isLinked?s&&(c?(this.startListeningToSource(s),this.updateModelFromSource()):this.stopListeningToSource(s)):c&&s!==e.source&&(e.source&&this.stopListeningToSource(e.source),s&&(this.startListeningToSource(s),this.updateModelFromSource())))}componentWillUnmount(){this.pending.cancel();const{source:e}=this.props;e&&this.stopListeningToSource(e)}panelContainer;chart;pending;initModel(){this.setState({isLoading:!0,isLoaded:!1,error:void 0});const{makeModel:e}=this.props;this.pending.add(e(),t=>{t.close()}).then(this.handleLoadSuccess,this.handleLoadError)}getWaitingInputMap=fe((e,t,n)=>{if(!e)return new Map;const s=new Map(t);return n.forEach((i,o)=>{s.delete(o)}),s});getWaitingFilterMap=fe((e,t,n,s,i)=>{if(!e)return new Map;const o=new Map(t);return n.forEach((a,r)=>{o.delete(r)}),i.forEach((a,r)=>{o.delete(r)}),s.forEach((a,r)=>{o.delete(r)}),o});getInputFilterColumnMap=fe((e,t)=>{const n=new Map;for(let s=0;s<t.length;s+=1){const i=t[s],{name:o,type:a}=i,r=e.get(o);r!=null&&r.type===a&&n.set(o,i)}return n});getLinkedColumnMap=fe((e,t)=>{const n=new Map,s=Y.getIdFromPanel(this);for(let i=0;i<t.length;i+=1){const o=t[i];let a=null;if(o.start!=null&&o.start.panelId===s&&e.has(o.start.columnName)?a=o.start.columnName:o.end&&o.end.panelId===s&&e.has(o.end.columnName)&&(a=o.end.columnName),a!=null&&e.has(a)){const r=e.get(a);M(r),n.set(a,r)}}return n});getSelectorColumns=fe((e,t,n)=>Array.from(e.values()).map(s=>({name:s.name,type:s.type,isValid:n?n(this,s):!1,isActive:t.has(s.name)})));startListeningToSource(e){Gt.debug("startListeningToSource",e),e.addEventListener(R.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleSourceColumnChange),e.addEventListener(R.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),e.addEventListener(R.Table.EVENT_SORTCHANGED,this.handleSourceSortChange)}stopListeningToSource(e){Gt.debug("stopListeningToSource",e),e.removeEventListener(R.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleSourceColumnChange),e.removeEventListener(R.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),e.removeEventListener(R.Table.EVENT_SORTCHANGED,this.handleSourceSortChange)}loadModelIfNecessary(){const{isActive:e,isLoaded:t,isLoading:n}=this.state;e&&!t&&!n&&this.initModel()}isHidden(){const{glContainer:e}=this.props,{isHidden:t}=e;return t}handleColumnSelected(e){const{glEventHub:t}=this.props,{columnMap:n}=this.state;t.emit(bl.COLUMN_SELECTED,this,n.get(e))}handleColumnMouseEnter({type:e,name:t}){const{columnSelectionValidator:n}=this.props;Gt.debug("handleColumnMouseEnter",n,e,t),n&&n(this,{type:e,name:t})}handleColumnMouseLeave(){const{columnSelectionValidator:e}=this.props;Gt.debug("handleColumnMouseLeave",e),e&&e(this,void 0)}handleDisconnect(){this.setState({error:new Error("Figure disconnected"),isDisconnected:!0})}handleFilterAdd(e){for(let t=0;t<e.length;t+=1)this.openInputFilter(e[t])}handleOpenLinker(){const{localDashboardId:e,setActiveTool:t,setDashboardIsolatedLinkerPanelId:n}=this.props;n(e,void 0),t(Vt.LINKER)}handleReconnect(){this.setState({isDisconnected:!1,error:void 0}),this.sendColumnChange(),this.updateColumnFilters()}handleLoadSuccess(e){Gt.debug("handleLoadSuccess");const{model:t}=this.state;this.setState({model:e,isLoaded:!0},()=>{const{inputFilters:n,source:s}=this.props,{filterMap:i,isLinked:o}=this.state;e!==t&&(this.sendColumnChange(),this.updateColumnFilters(),this.updateInputFilters(n,i.size>0||e.isFilterRequired()),s&&o&&(this.startListeningToSource(s),this.updateModelFromSource()))})}handleLoadError(e){ve.isCanceled(e)||(Gt.error("handleLoadError",e),this.setState({error:e,isLoading:!1}))}handleSourceColumnChange(){this.updateModelFromSource()}handleSourceFilterChange(){this.updateModelFromSource()}handleSourceSortChange(){this.updateModelFromSource()}updateModelFromSource(){const{metadata:e,source:t}=this.props,{isLinked:n,model:s}=this.state;if(!n||!s||!t){Gt.debug2("updateModelFromSource ignoring",n,s,t);return}if(this.pending.cancel(),Ra(e)){const{settings:i}=e;this.pending.add(R.plot.Figure.create(Je.makeFigureSettings(i,t))).then(o=>{Td(s)&&s.setFigure(o)}).catch(this.handleLoadError)}this.updatePanelState()}updatePanelState(){const{sourcePanel:e}=this.props,{panelState:t,filterValueMap:n,settings:s}=this.state;let{tableSettings:i}=t??{};if(e&&mR(e.props)&&gR(e.state)){const{inputFilters:o}=e.props,{panelState:a}=e.state;a!=null&&(i=be.extractTableSettings(a,o))}this.setState({panelState:{settings:s,tableSettings:i,filterValueMap:Array.from(n)}})}handleError(){this.setState({isLoading:!1})}handleResize(){this.updateChart()}handleSettingsChanged(e){this.setState(({settings:t})=>{const n={...t,...e};return Gt.debug("Updated settings",n),{settings:n}})}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:t}=this.props,{name:n,type:s}=e;t.emit(Qe.OPEN_INPUT,{title:`${n} Filter`,panelState:{name:n,type:s,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:t}=this.props;t.emit(Qe.COLUMNS_CHANGED,this,Array.from(e.getFilterColumnMap().values()))}getCoordinateForColumn(e){const t=Fo.makeButtonClassName(e);if(!this.panelContainer.current)return null;const s=this.panelContainer.current.querySelector(`.${t}`)?.getBoundingClientRect()??null;if(s==null||s.width<=0||s.height<=0)return null;const i=s.left+s.width/2,o=s.bottom;return[i,o]}setFilterMap(e){Gt.debug("setFilterMap",e),this.setState(t=>{const{columnMap:n,filterMap:s}=t;let i=null;const o=new Map(t.filterValueMap);return e.forEach(({columnType:a,value:r},c)=>{const h=n.get(c);h==null||h.type!==a||(o.set(c,r),s.get(c)!==r&&(i===null&&(i=new Map(s)),i.set(c,r)))}),{filterValueMap:o,filterMap:i??s}})}unsetFilterValue(e){this.setState(t=>{const{inputFilters:n}=this.props,{columnMap:s}=t;let{filterMap:i,filterValueMap:o}=t;if(!o.has(e))return null;o=new Map(t.filterValueMap),o.delete(e);const a=this.getInputFilterColumnMap(s,n);if(a.has(e)){const r=i.get(e),c=a.get(e)?.value;c!=null&&r!==c&&(i=new Map(t.filterMap),c.length>0?i.set(e,c):i.delete(e))}else i=new Map(t.filterMap),i.delete(e);return{filterMap:i,filterValueMap:o}})}updateChangedInputFilters(e,t){const n=t.filter(i=>e.find(o=>o.name===i.name&&o.type===i.type)===void 0);n.length>0&&this.deleteInputFilters(n);const s=e.filter(i=>!t.includes(i));s.length>0&&this.updateInputFilters(s)}updateInputFilters(e,t=!1){this.setState(n=>{const{columnMap:s}=n,i=new Map(n.filterValueMap),o=new Map(n.filterMap),a=t?{filterMap:o,filterValueMap:i}:{};for(let r=0;r<e.length;r+=1){const{name:c,type:h,value:u}=e[r],m=s.get(c);m!=null&&m.type===h&&(u!=null&&o.get(c)!==u&&(u===""?o.delete(c):o.set(c,u),a.filterMap=o),i.has(c)&&(i.delete(c),a.filterValueMap=i))}return Gt.debug("updateInputFilters",a),a})}deleteInputFilters(e,t=!1){this.setState(n=>{const{columnMap:s,filterValueMap:i}=n,o=new Map(n.filterMap);let a=t;for(let r=0;r<e.length;r+=1){const{name:c,type:h}=e[r],u=s.get(c);if(u!=null&&u.type===h&&o.has(c)){const m=o.get(c);if(i.has(c)){const g=i.get(c);g!==m&&g!=null&&(a=!0,o.set(c,g))}else a=!0,o.delete(c)}}return Gt.debug("deleteInputFilters",a),a?{filterMap:o}:null})}updateColumnFilters(){this.setState(({model:e})=>e?{columnMap:e.getFilterColumnMap()}:null)}updateFilters(){const{columnMap:e,filterMap:t,model:n}=this.state;M(n);const s=this.getWaitingInputMap(n.isFilterRequired(),e,t);if(n.setFilter(t),t.size>0&&s.size===0){const i=n.getDefaultTitle(),o=zt.join(Array.from(t.entries()).map(([a,r])=>`${a}: ${r}`));i?n.setTitle(`${i}<br><span style="font-size: smaller">${o}</span>`):n.setTitle(o),Gt.debug2("updateFilters filters set",t),this.setState({isLoading:!0})}else Gt.debug2("updateFilters waiting on inputs",s),n.setTitle(n.getDefaultTitle()),this.setState({isLoading:!1});this.updatePanelState()}pruneFilterMaps(){this.setState(e=>{const{columnMap:t}=e,n=new Map(e.filterMap),s=new Map(e.filterValueMap),i={};return e.filterValueMap.forEach((o,a)=>{t.has(a)||(s.delete(a),i.filterValueMap=s)}),e.filterMap.forEach((o,a)=>{t.has(a)||(n.delete(a),i.filterMap=n)}),i})}updateChart(){this.chart.current&&this.chart.current.updateDimensions()}render(){const{columnSelectionValidator:e,glContainer:t,glEventHub:n,inputFilters:s,isLinkerActive:i,links:o,metadata:a,settings:r}=this.props,{columnMap:c,filterMap:h,error:u,model:m,isActive:g,isDisconnected:p,isLoaded:C,isLoading:f}=this.state;let S;Ra(a)?S=a.table:S=a.figure;const v=this.getInputFilterColumnMap(c,s),w=this.getLinkedColumnMap(c,o),T=m!=null?this.getWaitingInputMap(m.isFilterRequired(),c,h):new Map,y=m!=null?this.getWaitingFilterMap(m.isFilterRequired(),c,h,w,v):new Map,E=u!=null?`Unable to open chart. ${u}`:void 0,D=T.size>0,F=c.size>0&&i;return l.jsx(Sc,{className:$("iris-chart-panel",{"input-required":D}),componentPanel:this,glContainer:t,glEventHub:n,onHide:this.handleHide,onClearAllFilters:this.handleClearAllFilters,onResize:this.handleResize,onShow:this.handleShow,onTabBlur:this.handleTabBlur,onTabFocus:this.handleTabFocus,errorMessage:E,isDisconnected:p,isLoading:f,isLoaded:C,widgetName:S,widgetType:"Chart",children:l.jsxs("div",{ref:this.panelContainer,className:"chart-panel-container h-100 w-100",children:[l.jsx("div",{className:"chart-container h-100 w-100",children:C&&m&&l.jsx(US,{isActive:g,model:m,settings:r,ref:this.chart,onDisconnect:this.handleDisconnect,onReconnect:this.handleReconnect,onUpdate:this.handleUpdate,onError:this.handleError,onSettingsChanged:this.handleSettingsChanged})}),l.jsx(ft,{in:D&&!F&&!f,timeout:ze.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:l.jsx(wm,{inputFilterMap:v,linkedColumnMap:w,onAdd:this.handleFilterAdd,onOpenLinker:this.handleOpenLinker,columnMap:c,waitingFilterMap:y,waitingInputMap:T})}),l.jsx(ft,{in:F,timeout:ze.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:l.jsx(Fo,{columns:this.getSelectorColumns(c,w,e),onColumnSelected:this.handleColumnSelected,onMouseEnter:this.handleColumnMouseEnter,onMouseLeave:this.handleColumnMouseLeave})})]})})}}const fR=(d,e)=>{const{localDashboardId:t,metadata:n}=e;let s;n!=null&&(s=n.sourcePanelId);const i=wc(d,t),o=qu(d,t),a=gr(d),r=vc(d,t),c=a===Vt.LINKER&&r===void 0;return{columnSelectionValidator:Tc(d,t),isLinkerActive:c,inputFilters:bc(d,t),links:Ji(d,t),source:s!=null?i.get(s):void 0,sourcePanel:s!=null?o.get(s):void 0,settings:St(d)}},_i=Ct(fR,{setActiveTool:fr,setDashboardIsolatedLinkerPanelId:bm},null,{forwardRef:!0})(pR);const fa=Z.module("CommandHistoryPanel");class yc extends b.Component{static COMPONENT="CommandHistoryPanel";static TITLE="Command History";static handleError(e){fa.error(e)}constructor(e){super(e),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=J.createRef(),this.pending=new is;const{session:t,sessionId:n,language:s}=e;this.state={panelState:{},session:t,sessionId:n,language:s,contextActions:[{action:this.handleFocusHistory,shortcut:Mt.COMMAND_HISTORY.FOCUS_HISTORY}]}}componentDidMount(){const{glEventHub:e,session:t}=this.props;e.on(Xt.FOCUS_HISTORY,this.handleFocusHistory),t!=null&&this.loadTable()}componentWillUnmount(){const{glEventHub:e}=this.props;e.off(Xt.FOCUS_HISTORY,this.handleFocusHistory),this.pending.cancel()}container;pending;handleFocusHistory(){this.container.current&&this.container.current.focus()}handleShow(){this.container.current?.restoreScrollPosition()}handleSessionOpened(e,{language:t,sessionId:n}){this.setState({session:e,sessionId:n,language:t},()=>{this.loadTable()})}handleSessionClosed(){this.pending.cancel(),this.setState({session:void 0,language:void 0,table:void 0})}handleSendToNotebook(e,t=!1){const{session:n,language:s}=this.state;if(fa.debug("handleSendToNotebook",n,e),!n){fa.error("Session is not connected.");return}const{glEventHub:i}=this.props;i.emit(t?$e.CREATE_NOTEBOOK:$e.SEND_TO_NOTEBOOK,n,s,e)}handleSendToConsole(e,t=!0,n=!1){fa.debug("handleSendToConsole",e);const{glEventHub:s}=this.props;s.emit(Xt.SEND_COMMAND,e,t,n)}loadTable(){const{commandHistoryStorage:e}=this.props,{language:t,sessionId:n}=this.state;M(t),M(n),this.pending.add(e.getTable(t,n,Date.now()),s=>s.close()).then(s=>{this.setState({table:s})}).catch(yc.handleError)}render(){const{glContainer:e,glEventHub:t,commandHistoryStorage:n}=this.props,{language:s,contextActions:i,table:o}=this.state;return l.jsxs(os,{className:"command-history-pane",componentPanel:this,glContainer:e,glEventHub:t,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onShow:this.handleShow,children:[!o&&l.jsx("div",{className:"command-history-disconnected-message",children:"Waiting for console connection"}),o&&s!=null&&l.jsxs(l.Fragment,{children:[l.jsx(fS,{ref:this.container,language:s,sendToNotebook:this.handleSendToNotebook,sendToConsole:this.handleSendToConsole,table:o,commandHistoryStorage:n}),l.jsx(ie,{actions:i})]})]})}}const CR=(d,e)=>{const t=lu(d),n=di(d,e.localDashboardId),{session:s,config:i}=n??{},{type:o,id:a}=i??{};return{commandHistoryStorage:t,language:o,session:s,sessionId:a}},Ka=Ct(CR,null,null,{forwardRef:!0})(yc);const Ca=Z.module("ConsolePanel"),SR=500,bR=Object.freeze({consoleSettings:{},itemIds:[]});class wR extends b.PureComponent{static COMPONENT="ConsolePanel";static TITLE="Console";constructor(e){super(e),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=J.createRef();const{panelState:t}=e,n={...bR,...t||{}},{consoleSettings:s,itemIds:i}=n;this.state={consoleSettings:s,itemIds:new Map(i),objectMap:new Map,error:void 0,panelState:n}}componentDidMount(){const{glEventHub:e}=this.props;this.closeDisconnectedPanels(),e.on(Ee.MOUNT,this.handlePanelMount),this.subscribeToFieldUpdates()}componentDidUpdate(e,t){const{consoleSettings:n,itemIds:s}=this.state;(t.consoleSettings!==n||t.itemIds!==s)&&this.savePanelState()}componentWillUnmount(){const{glEventHub:e}=this.props;this.savePanelState.flush(),e.off(Ee.MOUNT,this.handlePanelMount),this.objectSubscriptionCleanup?.()}consoleRef;objectSubscriptionCleanup;subscribeToFieldUpdates(){const{sessionWrapper:e}=this.props,{session:t}=e;this.objectSubscriptionCleanup=t.subscribeToFieldUpdates(n=>{Ca.debug("Got updates",n),this.setState(({objectMap:s})=>{const{updated:i,created:o,removed:a}=n,r=[...i,...a],c=new Map(s);return r.forEach(u=>{const{title:m}=u;m!==void 0&&c.delete(m)}),[...i,...o].forEach(u=>{u.title!==void 0&&c.set(u.title,u)}),{objectMap:c}})})}setItemId(e,t){this.setState(({itemIds:n})=>{const s=new Map(n);return s.set(e,t),{itemIds:s}})}getItemId(e,t=!0){const{itemIds:n}=this.state;let s=n.get(e);return s==null&&t&&(s=_e.generate(),this.setItemId(e,s)),s}handleTabFocus(){this.consoleRef.current?.focus()}handlePanelMount(e){const{itemIds:t}=this.state,n=e?.props?.id,s=e?.props?.metadata?.sourcePanelId;n&&s&&new Set(t.values()).has(s)&&this.setItemId(n,n)}handleFocusCommandHistory(){const{glEventHub:e}=this.props;e.emit(Xt.FOCUS_HISTORY)}handleResize(){this.updateDimensions()}handleShow(){this.updateDimensions()}handleOpenObject(e){const{sessionWrapper:t}=this.props,{session:n}=t;this.openWidget(e,n)}handleCloseObject(e){const{title:t}=e;if(t!==void 0){const n=this.getItemId(t,!1),{glEventHub:s}=this.props;s.emit(Ee.CLOSE,n)}}handleSettingsChange(e){const{glEventHub:t}=this.props;Ca.debug("handleSettingsChange",e),this.setState({consoleSettings:e}),t.emit(Xt.SETTINGS_CHANGED,e)}openWidget(e,t){const{glEventHub:n}=this.props,{title:s}=e;M(s);const i=this.getItemId(s),o={fetch:()=>t.getObject(e),panelId:i,widget:e};Ca.debug("openWidget",o),n.emit(Ee.OPEN,o)}addCommand(e,t=!0,n=!1){this.consoleRef.current?.addCommand(e,t,n)}closeDisconnectedPanels(e=!1){const{consoleSettings:t,itemIds:n}=this.state,{isClosePanelsOnDisconnectEnabled:s=!0}=t;if(!s&&!e)return;const i=[...n.values()],{glEventHub:o}=this.props;i.forEach(a=>{o.emit(Ee.CLOSE,a)}),this.setState({itemIds:new Map})}savePanelState=Ye(()=>{const{consoleSettings:e,itemIds:t}=this.state,n={consoleSettings:e,itemIds:[...t]};Ca.debug("Saving panel state",n),this.setState({panelState:n})},SR);updateDimensions(){this.consoleRef.current?.updateDimensions()}render(){const{commandHistoryStorage:e,glContainer:t,glEventHub:n,sessionWrapper:s,timeZone:i,unzip:o}=this.props,{consoleSettings:a,error:r,objectMap:c}=this.state,{config:h,session:u,connection:m}=s,{id:g,type:p}=h;return l.jsx(os,{className:"iris-panel-console",componentPanel:this,glContainer:t,glEventHub:n,onResize:this.handleResize,onShow:this.handleShow,onTabFocus:this.handleTabFocus,errorMessage:r!=null?`${r}`:void 0,children:u!=null&&l.jsx(nS,{ref:this.consoleRef,settings:a,session:u,focusCommandHistory:this.handleFocusCommandHistory,openObject:this.handleOpenObject,closeObject:this.handleCloseObject,commandHistoryStorage:e,onSettingsChange:this.handleSettingsChange,language:p,statusBarChildren:l.jsxs(l.Fragment,{children:[l.jsx("div",{children:" "}),l.jsx("div",{children:Zh.LANGUAGE_MAP.get(p)}),l.jsx("div",{children:" "}),l.jsx("div",{children:l.jsx(WS,{connection:m,defaultUpdateInterval:10*1e3,hoverUpdateInterval:3*1e3,monitorDuration:10*60*1e3})}),l.jsx("div",{children:" "})]}),scope:g,timeZone:i,objectMap:c,unzip:o})})}}const vR=(d,e)=>({commandHistoryStorage:lu(d),sessionWrapper:di(d,e.localDashboardId),timeZone:Lo(d)}),Mi=Ct(vR,null,null,{forwardRef:!0})(wR);const Sa=Z.module("DropdownFilter"),TR=150;class ji extends b.Component{static defaultProps={column:null,disableLinking:!1,isLinkerActive:!1,isLoaded:!1,isValueShown:!1,settingsError:null,source:null,value:"",values:[],onColumnSelected:()=>{},onSourceMouseEnter:()=>{},onSourceMouseLeave:()=>{}};static PLACEHOLDER="Select a value...";static SOURCE_BUTTON_CLASS_NAME="btn-dropdown-filter-selector";static SOURCE_BUTTON_PLACEHOLDER="Select a column";constructor(e){super(e),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=J.createRef();const{column:t,isValueShown:n,value:s}=e;this.state={column:t,id:_e(),selectedColumn:t,disableCancel:!n,isValueShown:n,value:s}}componentDidUpdate(e,t){const{source:n,values:s,isLoaded:i}=this.props,{column:o,value:a,isValueShown:r}=this.state;i&&(n!==e.source&&this.sourceUpdated(),s!==e.values&&a!==""&&!s.includes(a)&&this.resetValue(),r!==t.isValueShown&&r&&this.focusInput(),(o!==t.column||a!==t.value||r!==t.isValueShown)&&this.sendUpdate())}componentWillUnmount(){this.sendUpdate.flush()}dropdownRef;getCompatibleColumns=fe((e,t)=>e!=null?t.filter(({type:n})=>n!==void 0&&x.isCompatibleType(n,e.columnType)):[]);getColumnOptions=fe((e,t)=>{let n=-1;const s=[];return s.push(l.jsx("option",{value:"-1",children:"Select a column"},"placeholder")),e.forEach((i,o)=>{s.push(l.jsx("option",{value:o,children:this.getItemLabel(e,o)},`${i.name}/${i.type}`)),t!==null&&i.name===t.name&&i.type===t.type&&(n=o)}),[s,n]});getSelectedOptionIndex=fe((e,t)=>e.indexOf(t));getValueOptions=fe(e=>[l.jsx("option",{value:"-1",children:ji.PLACEHOLDER},"-1"),...e.map((t,n)=>l.jsx("option",{value:n,children:t??"(null)"},`${n}/${t}`))]);getItemLabel=ge((e,t)=>{const{name:n,type:s}=e[t];if(t>0&&e[t-1].name===n||t<e.length-1&&e[t+1].name===n){const i=s.substring(s.lastIndexOf(".")+1);return`${n} (${i})`}return n});handleColumnChange(e){const{value:t}=e.target;if(Sa.debug2("handleColumnChange",t),t!=null&&parseInt(t,10)<0){this.setState({selectedColumn:null});return}const{columns:n,source:s}=this.props,i=this.getCompatibleColumns(s,n);this.setState({selectedColumn:i[parseInt(t,10)]})}handleDropdownKeyPress(e){e.key==="Enter"&&(e.preventDefault(),e.stopPropagation(),Sa.debug2("handleDropdownKeyPress"),this.sendUpdate(),this.sendUpdate.flush())}handleValueChange(e){const{value:t}=e.target,n=parseInt(t,10);let s="";const{values:i}=this.props;n>=0&&n<i.length?s=i[n]:Sa.debug2("Selected default item"),Sa.debug2("handleValueChange",s),this.setState({value:s})}handleSettingsCancel(){this.setState(({column:e})=>({selectedColumn:e,isValueShown:!0}))}handleSettingsSave(){this.setState(({column:e,selectedColumn:t,value:n})=>({column:t,value:e===t?n:"",isValueShown:!0,disableCancel:!1}))}handleSettingsClick(e){e.stopPropagation(),this.showSettings()}handleBackgroundClick(e){e.target!==this.dropdownRef.current&&this.focusInput()}sourceUpdated(){this.setState({column:null,selectedColumn:null,isValueShown:!1,disableCancel:!0,value:""})}showSettings(){const{column:e}=this.state;this.setState({selectedColumn:e,isValueShown:!1})}focusInput(){this.dropdownRef.current?.focus()}resetValue(){this.setState({value:""})}clearFilter(){this.resetValue()}setFilterState({name:e,type:t,value:n,isValueShown:s}){const i=e!=null&&t!=null?{name:e,type:t}:null;this.setState(({value:o,isValueShown:a})=>({column:i,value:n??o,isValueShown:s??a}))}sendUpdate=Ye(()=>{const{onChange:e}=this.props,{column:t,value:n,isValueShown:s}=this.state;e({column:t,isValueShown:s,value:n??void 0})},TR);render(){const{columns:e,disableLinking:t,isLinkerActive:n,isLoaded:s,source:i,onColumnSelected:o,onSourceMouseEnter:a,onSourceMouseLeave:r,values:c,settingsError:h}=this.props,{column:u,disableCancel:m,id:g,isValueShown:p,selectedColumn:C,value:f}=this.state,S=i===null,v=this.getCompatibleColumns(i,e),w=i!=null,T=i?.columnName??ji.SOURCE_BUTTON_PLACEHOLDER,y=u!=null?`${u.name} Filter`:null,[E,D]=this.getColumnOptions(v,C),F=this.getValueOptions(c),N=this.getSelectedOptionIndex(c,f),_=!w||C==null,P=p&&!n,U=`source-column-btn-${g}`,O=`filter-column-select-${g}`;return l.jsxs(jl,{className:"dropdown-filter fill-parent-absolute",isFlipped:P,children:[l.jsx("div",{className:"dropdown-filter-settings-card",children:l.jsxs("div",{className:"dropdown-filter-card-content",children:[l.jsxs("div",{className:"dropdown-filter-settings-grid",children:[l.jsx("label",{htmlFor:U,children:"Source Column"}),l.jsx(Yh,{id:U,isLinked:w,onClick:o,onMouseEnter:a,onMouseLeave:r,className:ji.SOURCE_BUTTON_CLASS_NAME,disabled:t,children:T}),l.jsx("div",{className:"text-muted small",children:"Select a source column for the list by linking to a table."}),l.jsx("label",{htmlFor:O,children:"Filter Column"}),l.jsx("select",{id:O,value:D,className:"custom-select",onChange:this.handleColumnChange,disabled:S,children:E}),l.jsx("div",{className:"text-muted small",children:"Dropdown filter control will apply its filter to all columns matching this name in this dashboard."})]}),h&&l.jsx("div",{className:"error-message text-center",children:h}),w&&l.jsxs("div",{className:"dropdown-filter-settings-buttons",children:[l.jsx(B,{kind:"secondary",type:"button",onClick:this.handleSettingsCancel,disabled:m||p||n,tooltip:n?"Cancel disabled while linker open":void 0,children:"Cancel"}),l.jsx(B,{kind:"primary",type:"button",className:"ml-2",onClick:this.handleSettingsSave,disabled:_||p||n,tooltip:n?"Save disabled while linker open":void 0,children:"Save"})]})]})}),l.jsx("div",{className:"dropdown-filter-value-card",onClick:this.handleBackgroundClick,"data-testid":"dropdown-filter-value-background",children:s&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"dropdown-filter-column",children:l.jsx("div",{className:"dropdown-filter-column-title",children:y})}),l.jsxs("div",{className:"dropdown-filter-card-content",children:[l.jsx("div",{className:"dropdown-filter-value-input d-flex flex-column justify-content-center",children:l.jsx("select",{className:"custom-select",value:N,ref:this.dropdownRef,onChange:this.handleValueChange,onKeyPress:this.handleDropdownKeyPress,title:"Select Value",children:F})}),h&&l.jsx("div",{className:"error-message mt-3 text-center",children:h})]}),l.jsx("div",{className:"dropdown-filter-menu",children:l.jsx(B,{kind:"ghost",className:"m-2 px-2",onClick:this.handleSettingsClick,icon:l.jsx(Q,{icon:Oo,transform:"grow-4"}),tooltip:"Dropdown Filter Settings"})})]})})]})}}const st=Z.module("DropdownFilterPanel"),ER=250,yR=(d,e)=>{const{localDashboardId:t}=e,n=Y.getIdFromPanel({props:e}),s=wc(d,t),i=Ji(d,t),o=gr(d),a=vc(d,t),r=o===Vt.LINKER&&(a===void 0||a===n),c=o===Vt.LINKER&&a!==void 0&&a!==n;return{columns:Sm(d,t),columnSelectionValidator:Tc(d,t),isLinkerActive:r,disableLinking:c,settings:St(d),panelTableMap:s,dashboardLinks:i}},RR=Ct(yR,null,null,{forwardRef:!0});class xs extends b.Component{static displayName="DropdownFilterPanel";static COMPONENT="DropdownFilterPanel";static MAX_TABLE_SIZE=256;static DATETIME_FORMATTER=new je({showTimeZone:!1,showTSeparator:!0,defaultDateTimeFormatString:"yyyy-MM-dd HH:mm:ss.SSSSSSSSS"});static SOURCE_COLUMN=Object.freeze({name:"FilterSource",type:null});constructor(e){super(e),this.handleChange=Ye(this.handleChange.bind(this),ER),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=J.createRef(),this.panelContainer=J.createRef(),this.pending=new is;const{panelState:t,settings:n}=e;this.columnFormats=ns.getColumnFormats(n);const{value:s="",isValueShown:i=!1,name:o,type:a,timestamp:r}=t??{},c=o!=null&&a!=null?{name:o,type:a}:void 0;this.state={column:c,formatter:new Qt(this.columnFormats),valuesTable:void 0,valuesColumn:void 0,sourceSize:0,value:s,timestamp:r,values:[],isValueShown:i,wasFlipped:!1,skipUpdate:!1,panelState:t,isDisconnected:!1,isLoading:!1,isLoaded:!1,error:null}}componentDidMount(){this.updateValuesTable();const{dashboardLinks:e,panelTableMap:t}=this.props,{column:n,value:s,timestamp:i}=this.state,o=this.getSourceTable(t,e);if(o!==null&&this.startListeningToSource(o),n!=null){const{name:a,type:r}=n;this.sendUpdate(a,r,s,i)}}componentDidUpdate(e,t){const{dashboardLinks:n,panelTableMap:s,settings:i}=this.props,{valuesTable:o}=this.state,a=this.getSource(n),r=this.getSourceTable(s,n),c=this.getSource(e.dashboardLinks),h=this.getSourceTable(e.panelTableMap,e.dashboardLinks);i!==e.settings&&i!==void 0&&this.updateFormatterSettings(i),o!==t.valuesTable&&t.valuesTable!=null&&(st.debug("Table in state modified, closing the old table."),t.valuesTable.close()),(r!==h||a!==c)&&this.updateValuesTable(),r!==h&&(h!==null&&this.stopListeningToSource(h),r!==null&&this.startListeningToSource(r))}componentWillUnmount(){const{dashboardLinks:e,panelTableMap:t}=this.props,{valuesTable:n}=this.state,s=this.getSourceTable(t,e);this.pending.cancel(),s!==null&&this.stopListeningToSource(s),this.cleanup&&this.cleanup(),n?.close()}dropdownFilterRef;panelContainer;pending;cleanup;columnFormats;getCachedValues=ge((e,{type:t,name:n},s)=>t!==void 0&&x.isDateType(t)?e.map(i=>xs.DATETIME_FORMATTER.format(i)):e.map(i=>i!=null&&t!=null?s.getFormattedString(i,t,n):null));getCoordinateForColumn(){if(this.panelContainer.current==null)return null;const t=this.panelContainer.current.querySelector(`.${ji.SOURCE_BUTTON_CLASS_NAME}`)?.getBoundingClientRect()??null;if(t==null||t.width<=0||t.height<=0)return null;const n=t.left+t.width/2,s=t.bottom;return[n,s]}getSettingsErrorMessage(){const{sourceSize:e}=this.state;if(e>xs.MAX_TABLE_SIZE)return`Table too large, must have fewer than ${xs.MAX_TABLE_SIZE} options.`}getPanelErrorMessage(){const{error:e}=this.state;return e!=null?`${e}`:void 0}getCachedPanelLinks=ge((e,t)=>{const n=Y.getIdFromPanel(t);return st.debug("getCachedPanelLinks",e,n),e.filter(s=>s.end?.panelId===n)});getCachedSource=ge(e=>{st.debug("getCachedSource",e);let t;if(e.length>0){const[n]=e;t=n.start,e.length>1&&st.error("Filter has more that one link",e)}return t});getCachedSourceTable=ge((e,t)=>{if(st.debug("getCachedSourceTable",e,t),t==null)return null;const{panelId:n}=t;return e.get(n)??null});getCachedSourceColumn=ge((e,t)=>(st.debug("getCachedSourceColumn",e,t),e==null||t==null?null:e.columns.find(({name:n,type:s})=>n===t.columnName&&s===t.columnType)??null));getSource(e){const t=this.getCachedPanelLinks(e,this);return this.getCachedSource(t)}getSourceTable(e,t){const n=this.getSource(t);return this.getCachedSourceTable(e,n)}getValuesColumn(e,t){const n=this.getSource(t);return this.getCachedSourceColumn(e,n)}startListeningToSource(e){st.debug("startListeningToSource"),e.addEventListener(R.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),e.addEventListener(R.Table.EVENT_SORTCHANGED,this.handleSourceSortChange),e.addEventListener(R.Table.EVENT_SIZECHANGED,this.handleSourceSizeChange),e.addEventListener(R.Table.EVENT_DISCONNECT,this.handleDisconnect),e.addEventListener(R.Table.EVENT_RECONNECT,this.handleReconnect)}stopListeningToSource(e){st.debug("stopListeningToSource"),e.removeEventListener(R.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),e.removeEventListener(R.Table.EVENT_SORTCHANGED,this.handleSourceSortChange),e.removeEventListener(R.Table.EVENT_SIZECHANGED,this.handleSourceSizeChange),e.removeEventListener(R.Table.EVENT_DISCONNECT,this.handleDisconnect),e.removeEventListener(R.Table.EVENT_RECONNECT,this.handleReconnect)}handleChange({column:e,isValueShown:t=!1,value:n}){const{name:s=void 0,type:i=void 0}=e??{};let o=!0,a=Date.now();this.setState(({panelState:r,timestamp:c,wasFlipped:h,skipUpdate:u})=>{const m=r!=null&&t!==r.isValueShown&&s===r.name&&i===r.type&&n===r.value;return o=(!u&&t&&(!m||!h))??!1,o||(a=c),{panelState:{isValueShown:t,name:s,type:i,value:n,timestamp:a??void 0},timestamp:a,wasFlipped:m,skipUpdate:!1}},()=>{o&&this.sendUpdate(s??null,i,n,a)})}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:e}){this.setState({sourceSize:e})}handleColumnSelected(){st.debug("handleColumnSelected");const{glEventHub:e}=this.props;e.emit(Qe.COLUMN_SELECTED,this,xs.SOURCE_COLUMN)}handleClearAllFilters(){this.dropdownFilterRef?.current?.clearFilter()}setPanelState(e,t=!1){const{dashboardLinks:n}=this.props;if(this.getSource(n)==null){st.debug("Ignore state update for unlinked filter",e);return}this.setState({skipUpdate:!t}),this.dropdownFilterRef?.current?.setFilterState(e)}sendUpdate(e,t,n,s){const{dashboardLinks:i,glEventHub:o}=this.props,a=this.getSource(i)?.panelId,r=a===null?[]:[a];st.debug("sendUpdate",{name:e,type:t,value:n,timestamp:s,excludePanelIds:r}),o.emit(Qe.FILTERS_CHANGED,this,{name:e,type:t,value:n??"=null",timestamp:s,excludePanelIds:r})}updateValuesTable(){const{dashboardLinks:e,panelTableMap:t}=this.props,n=this.getSource(e),s=this.getSourceTable(t,e);if(st.debug("updateValuesTable",n,s),this.setState({values:[],valuesTable:void 0,error:null}),n==null){st.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=>{ve.isCanceled(i)||(st.error(i),this.setState({isLoading:!1,error:i}))}))}applySourceSorts(){const{dashboardLinks:e,panelTableMap:t}=this.props,{valuesTable:n}=this.state,s=this.getSourceTable(t,e);if(st.debug("applySourceSorts",s?.sort),n==null||s==null){st.debug("Table not initialized");return}const i=[...s.sort];n.applySort(i),this.setViewport(n)}applySourceFilters(){const{dashboardLinks:e,panelTableMap:t}=this.props,{valuesTable:n}=this.state,s=this.getSourceTable(t,e);if(st.debug("applySourceFilters",s?.filter),n==null||s==null){st.debug("Table not initialized");return}const i=[...s.filter];n.applyFilter(i),this.setViewport(n)}updateViewportListener(e){if(st.debug("updateViewportListener",e?.size),this.cleanup&&this.cleanup(),e==null){this.cleanup=void 0;return}this.cleanup=e.addEventListener(R.Table.EVENT_UPDATED,this.handleValuesTableUpdate),this.setViewport(e)}setViewport(e){const{dashboardLinks:t}=this.props,n=this.getValuesColumn(e,t);if(!n){st.error("values column is null");return}e.setViewport(0,xs.MAX_TABLE_SIZE-1,[n])}updateFormatterSettings(e){const t=ns.getColumnFormats(e);it(this.columnFormats,t)||(this.columnFormats=t,this.setState({formatter:new Qt(t)}))}handleValuesTableUpdate({detail:e}){const{rows:t}=e,{dashboardLinks:n}=this.props,{valuesTable:s}=this.state;if(!s){st.error("valuesTable is null");return}const i=this.getValuesColumn(s,n);if(!i){st.error("Values column not found");return}const o=t.map(a=>a.get(i));this.setState({values:o,isLoading:!1,isLoaded:!0,valuesColumn:i})}handleSourceMouseEnter(){const{columnSelectionValidator:e}=this.props;e&&e(this,xs.SOURCE_COLUMN)}handleSourceMouseLeave(){const{columnSelectionValidator:e}=this.props;e&&e(this,void 0)}render(){const{columns:e,dashboardLinks:t,disableLinking:n,glContainer:s,glEventHub:i,isLinkerActive:o}=this.props,{column:a,formatter:r,isDisconnected:c,isValueShown:h,value:u,values:m,valuesColumn:g,isLoading:p,isLoaded:C}=this.state,f=this.getSource(t),S=this.getSettingsErrorMessage(),v=this.getPanelErrorMessage(),w=C&&g!=null?this.getCachedValues(m,g,r):[];return l.jsx(Sc,{errorMessage:v,isLoading:p,isLoaded:C,isDisconnected:c,className:"iris-dropdown-filter-panel",componentPanel:this,glContainer:s,glEventHub:i,onClearAllFilters:this.handleClearAllFilters,widgetName:"Dropdown Filter",widgetType:"DropdownFilter",children:l.jsx("div",{ref:this.panelContainer,className:"dropdown-filter-container h-100 w-100 container",children:l.jsx(ji,{ref:this.dropdownFilterRef,column:a,columns:e,isValueShown:h,isLinkerActive:o,disableLinking:n,isLoaded:C,settingsError:S,source:f,value:u,values:w,onChange:this.handleChange,onColumnSelected:this.handleColumnSelected,onSourceMouseEnter:this.handleSourceMouseEnter,onSourceMouseLeave:this.handleSourceMouseLeave})})})}}const ri=RR(xs);function _n(d){return d.type==="directory"}var vm=(d=>(d.GROOVY="text/x-groovy",d.PLAIN_TEXT="text/plain",d.PYTHON="text/x-python",d.PYTHON_COMPILED="application/x-python-code",d.SCALA="text/x-scala",d.UNKNOWN="",d))(vm||{});class he{static fileExtensionToString(e=""){return e.length===0?"":`.${e}`}static getDepth(e){if(!he.hasPath(e))throw new Error(`Invalid path provided: ${e}`);return(e.match(/\//g)??[]).length-1}static getExtension(e){const t=this.getBaseName(e).split(".");return t.length>1?t.pop()??"":""}static getBaseName(e){return e.split("/").pop()??""}static getCopyFileName(e){const t=e.lastIndexOf(".");let n=null,s=null;t<0?s=e:(s=e.substring(0,t),n=e.substring(t+1));const i=s?`${s}-copy`:"Copy";return n!==null?`${i}.${n}`:i}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(!he.hasPath(e))throw new Error(`Invalid name provided: ${e}`);const t=e.split("/");for(;t.pop()==="";);if(t.length===0)throw new Error(`No parent for path provided: ${e}`);return`${t.join("/")}/`}static getPath(e){if(!he.hasPath(e))throw new Error(`Invalid filename provided: ${e}`);const t=e.split("/");return t.pop(),`${t.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,t=""){const n=e.lastIndexOf("."),s=n>-1?e.substring(0,n):e,i=he.fileExtensionToString(t);return`${s}${i}`}static validateName(e){const t=[".",".."],n=/[\\/\0]/g,s=new Map([["\0","null"]]);if(!e)throw new Li("Name cannot be empty");if(t.includes(e))throw new Li(`"${e}" is a reserved name`);if(n.test(e))throw new Li(`Invalid characters in name: "${e.match(n)?.reduce((i,o)=>i.includes(o)?i:[...i,o],[]).map(i=>s.has(i)?s.get(i):i).join('", "')??""}"`)}static reducePaths(e){const t=e.filter(n=>he.isPath(n));return e.filter(n=>!t.some(s=>n!==s&&n.startsWith(s)))}static removeRoot(e,t){if(e.length===0)return t;if(!t.startsWith(e))throw new Error(`Filename ${t} does not start with expected root ${e}`);return t.substring(e.length)}static addRoot(e,t){return`${e}${t}`}}const Rc=26;function wl(d){return _n(d)?he.makePath(d.filename):he.getPath(d.filename)}function Xd(d,e){if(d.length===0||e==null)throw new Error("No items to move");const t=wl(e);if(d.some(({filename:n})=>he.getPath(n)===t))throw new Error("File already in the destination folder");if(d.some(n=>_n(n)&&t.startsWith(he.makePath(n.filename))))throw new Error("Destination folder cannot be a child of a dragged folder");return{files:d,targetPath:t}}function xR(d){if(_n(d))return d.isExpanded?gp:pp;switch(he.getMimeType(d.basename)){case vm.PYTHON:return Cp;default:return fp}}function vl(d){const{children:e,draggedItems:t,isDragInProgress:n,isDropTargetValid:s,isSelected:i,item:o,itemIndex:a,dropTargetItem:r,onDragStart:c,onDragOver:h,onDragEnd:u,onDrop:m}=d,g=t?.some(E=>E.id===o.id)??!1,p=wl(o),C=n&&r?wl(r):null,f=n&&s&&_n(o)&&C===p,S=n&&s&&C===p,v=n&&!s&&C===p,w=xR(o),T=he.getDepth(o.filename),y=Array(T).fill(null).map((E,D)=>l.jsx("span",{className:"file-list-depth-line"},D));return l.jsxs("div",{className:$("d-flex w-100 align-items-center","file-list-item",{"is-dragged":g,"is-exact-drop-target":f,"is-in-drop-target":S,"is-invalid-drop-target":v,"is-selected":i}),onDragStart:E=>c(a,E),onDragOver:E=>h(a,E),onDragEnd:E=>u(a,E),onDrop:E=>m(a,E),draggable:!0,role:"presentation","aria-label":o.basename,children:[y," ",l.jsx(Q,{icon:w,className:"item-icon",fixedWidth:!0})," ",l.jsxs("span",{className:"truncation-wrapper",children:[e??o.basename,l.jsx(tt,{options:{placement:"left"},children:e??o.basename})]})]})}const Ft=Z.module("FileList"),IR=500,Zd="item-list-scroll-pane";function DR(d){const{isMultiSelect:e=!1,table:t,onFocusChange:n=()=>{},onMove:s,onSelect:i,onSelectionChange:o=()=>{},renderItem:a=vl,rowHeight:r=Rc,overscanCount:c=Bt.DEFAULT_OVERSCAN}=d,[h,u]=b.useState(()=>({items:[],offset:0,itemCount:0})),[m,g]=b.useState({top:0,bottom:0}),[p,C]=b.useState(),[f,S]=b.useState(),[v,w]=b.useState(),[T,y]=b.useState([]),E=b.useRef(null),D=b.useRef(null),F=b.useCallback(te=>{if(te.length===0||h==null)return[];const re=[];for(let we=0;we<te.length;we+=1){const Ie=te[we];for(let xe=Ie[0];xe<=Ie[1];xe+=1)xe>=h.offset&&xe<h.offset+h.items.length&&re.push(h.items[xe-h.offset])}return re},[h]),N=b.useCallback(te=>{const re=F([[te,te]]);if(re.length>0)return re[0]},[F]),_=b.useCallback(()=>{const te=hn.count(T);if(te===0)return null;if(te===1){const re=T[0][0],we=N(re);if(we!=null)return we.filename}return`${te} items`},[N,T]),P=b.useCallback(te=>{if(!(!f||!p)){Ft.debug("dropItems",f,"to",te);try{const{files:re,targetPath:we}=Xd(f,p);s?.(re,we),te!=null&&(y([[te,te]]),E.current?.focusItem(te))}catch(re){Ft.error("Unable to complete move",re)}}},[f,p,s]),U=b.useCallback((te,re)=>{const we=h.items[te-h.offset];we!==void 0&&(Ft.debug("handleItemClick",we),i(we,re),_n(we)&&t?.setExpanded(we.filename,!we.isExpanded))},[h,i,t]),O=b.useCallback((te,re)=>{Ft.debug2("handleItemDragStart",te,T);let we=T;hn.isSelected(T,te)||(we=[[te,te]],y(we)),S(F(we)),E.current?.resetMouseState();const Ie=document.createElement("div");Ie.innerHTML=`<div class="dnd-placeholder-content">${_()}</div>`,Ie.className="file-list-dnd-placeholder",document.body.appendChild(Ie),re.dataTransfer.setDragImage(Ie,0,0),re.dataTransfer.effectAllowed="move",w(Ie)},[_,F,T]),j=b.useCallback((te,re)=>{re.preventDefault(),Ft.debug2("handleItemDragOver",re),C(N(te))},[N]),k=b.useCallback((te,re)=>{Ft.debug("handleItemDragEnd",te),v?.remove(),S(void 0),C(void 0),w(void 0)},[v]),A=b.useCallback((te,re)=>{P(te)},[P]),H=b.useCallback(()=>{Ft.debug2("handleItemDragExit"),C(void 0)},[]),K=b.useCallback(te=>{te.target instanceof Element&&te.target.classList.contains(Zd)&&(te.preventDefault(),Ft.debug2("handleListDragOver",te),C({type:"directory",filename:"/",basename:"/",id:"/"}))},[]),q=b.useCallback(te=>{te.target instanceof Element&&te.target.classList.contains(Zd)&&(Ft.debug("handleListDrop"),P())},[P]),oe=b.useCallback(te=>{if(Ft.debug2("handleSelectionChange",te),te!==T){y(te);const re=F(te);o(re)}},[F,o,T]),W=b.useCallback(te=>{if(Ft.debug2("handleFocusChange",te),te!=null){const[re]=F([[te,te]]);n(re)}else n()},[F,n]),G=b.useCallback((te,re)=>{Ft.debug("handleViewportChange",te,re),(te!==m.top||re!==m.bottom)&&g({top:te,bottom:re})},[m]),ne=b.useMemo(()=>{if(!f||!p)return!1;try{return Xd(f,p),Ft.debug("handleValidateDropTarget true"),!0}catch{return Ft.debug("handleValidateDropTarget false"),!1}},[f,p]),{focusedPath:ae}=d;b.useEffect(()=>{ae!==void 0&&(ae==="/"?t.collapseAll():(t.setExpanded(ae,!1),t.setExpanded(ae,!0)))},[t,ae]),b.useEffect(function(){Ft.debug("updating table viewport",m),t?.setViewport({top:Math.max(0,m.top-c),bottom:m.bottom+c})},[c,t,m]),b.useEffect(function(){const re=t.onUpdate(we=>{u({items:we.items.map(Ie=>({...Ie,itemName:Ie.basename})),offset:we.offset,itemCount:t.size})});return()=>{re()}},[t]),b.useEffect(function(){if(p!=null&&_n(p)&&p.filename!=="/"){const re=setTimeout(()=>{p.isExpanded||t?.setExpanded(p.filename,!0)},IR);return()=>clearTimeout(re)}},[p,t]);const ce=b.useCallback(te=>a({...te,isDragInProgress:f!=null,dropTargetItem:p,draggedItems:f,isDropTargetValid:ne,onDragStart:O,onDragEnd:k,onDragOver:j,onDragExit:H,onDrop:A}),[k,H,j,O,A,f,p,ne,a]);return l.jsx("div",{ref:D,className:$("file-list",{"is-dragging":f!=null}),onDragOver:K,onDrop:q,children:l.jsx(Bt,{ref:E,items:h.items,itemCount:h.itemCount,offset:h.offset,onFocusChange:W,onSelect:U,onSelectionChange:oe,onViewportChange:G,selectedRanges:T,renderItem:ce,rowHeight:r,isMultiSelect:e,isDragSelect:!1,isDeselectOnClick:!1})})}const FR={name:"File Explorer",DELETE:Ne.createAndAdd({id:"FILE_EXPLORER.DELETE",name:"Delete",shortcut:[ue.DELETE],macShortcut:[de.CMD,ue.BACKSPACE]}),RENAME:Ne.createAndAdd({id:"FILE_EXPLORER.RENAME",name:"Rename",shortcut:[ue.ENTER],macShortcut:[ue.ENTER]})},Qd={FILE_EXPLORER:FR};const Jd=Z.module("FileListItemEditor"),NR=()=>Promise.resolve();function MR({item:d,onCancel:e,onSubmit:t,validate:n=NR}){const s=b.useRef(null),[i,o]=b.useState(d.basename),[a,r]=b.useState(),[c,h]=b.useState(Promise.resolve()),u=b.useCallback(()=>{s.current?.focus()},[s]),m=b.useCallback(S=>S.stopPropagation(),[]),g=b.useCallback(()=>{c.then(()=>{t(i)}).catch(S=>Jd.info("Unable to validate name",S))},[t,i,c]);b.useEffect(function(){const v=ve.makeCancelable(n(i));return v.then(()=>r(void 0)).catch(w=>{ve.isCanceled(w)||r(w)}),h(v),()=>v.cancel()},[n,i]),b.useEffect(function(){u()},[u]);const p=b.useCallback(()=>{Jd.debug2("handleBlur"),g()},[g]),C=b.useCallback(S=>{const{value:v}=S.target;o(v)},[]),f=b.useCallback(S=>{S.stopPropagation();const{key:v}=S;switch(v){case"Enter":{g();break}case"Escape":{e();break}}},[e,g]);return l.jsxs("div",{className:"file-list-item-editor",children:[l.jsx("input",{type:"text",className:$("form-control file-list-item-editor-input",{"is-invalid":a}),value:i,ref:s,onBlur:p,onKeyDown:f,onChange:C,onClick:m,onDoubleClick:m,onMouseDown:m}),a&&l.jsx("div",{className:"invalid-feedback",children:`${a}`})]})}function Tm(d){const{isMultiSelect:e=!1,focusedPath:t,showContextMenu:n=!1,onCreateFile:s,onCreateFolder:i,onCopy:o,onDelete:a,onMove:r,onRename:c,onSelect:h,onSelectionChange:u,table:m,rowHeight:g=Rc,validateRename:p=()=>Promise.resolve()}=d,[C,f]=b.useState(),[S,v]=b.useState([]),[w,T]=b.useState(),y=b.useCallback(H=>{v(H),u?.(H)},[u]),E=b.useCallback(H=>{T(H)},[]),D=b.useCallback(()=>{w&&o?.(w)},[w,o]),F=b.useCallback(()=>{S.length>0&&a?.(S)},[a,S]),N=b.useCallback(()=>{s?.()},[s]),_=b.useCallback(()=>{w&&i?.(he.getPath(w.filename))},[w,i]),P=b.useCallback(()=>{w&&f(w)},[w]),U=b.useCallback(()=>{f(void 0)},[]),O=b.useCallback(H=>{C&&(c?.(C,H),f(void 0))},[c,C]),j=b.useMemo(()=>{if(C)return[];const H=[];return s&&H.push({title:"New File",description:"Create new file",action:N,group:ie.groups.medium}),i&&H.push({title:"New Folder",description:"Create new folder",action:_,group:ie.groups.medium}),o&&H.push({title:"Copy",description:"Copy",action:D,group:ie.groups.low,disabled:w==null||_n(w)}),a&&S.length>0&&H.push({title:"Delete",description:"Delete",shortcut:Qd.FILE_EXPLORER.DELETE,action:F,group:ie.groups.low}),c&&H.push({title:"Rename",description:"Rename",shortcut:Qd.FILE_EXPLORER.RENAME,action:P,group:ie.groups.low,disabled:w==null}),H},[D,F,N,_,P,w,o,s,i,a,c,S,C]),k=b.useCallback(H=>(M(C),p(C,H)),[C,p]),A=b.useCallback(H=>{const{item:K}=H;return C&&C.filename===K.filename?l.jsx(vl,{...H,children:l.jsx(MR,{item:K,validate:k,onSubmit:O,onCancel:U})}):l.jsx(vl,{...H})},[U,O,C,k]);return l.jsxs("div",{className:"file-list-container",children:[m!=null&&l.jsx(DR,{onMove:r,onSelect:h,onSelectionChange:y,onFocusChange:E,renderItem:A,rowHeight:g,table:m,isMultiSelect:e,focusedPath:t}),n&&l.jsx(ie,{actions:j})]})}Tm.displayName="FileListContainer";class xa extends Li{isExistingFile=!0;info;constructor(e){super("Name already exists"),this.info=e}}class xc extends Error{constructor(){super("No file exists at the path specified")}isFileNotFound=!0}const Ys=Z.module("FileExplorer");function Ic(d){const{storage:e,isMultiSelect:t=!1,focusedPath:n,onDelete:s=()=>{},onRename:i=()=>{},onSelect:o,onSelectionChange:a,rowHeight:r=Rc}=d,[c,h]=b.useState([]),[u,m]=b.useState();b.useEffect(function(){let D;async function F(){Ys.debug("initTable"),D=ve.makeCancelable(e.getTable(),N=>N.close());try{m(await D)}catch(N){ve.isCanceled(N)||Ys.error("Unable to initialize table",N)}}return F(),()=>{D.cancel()}},[e]);const g=b.useCallback(E=>{ve.isCanceled(E)||Ys.error(E)},[]),p=b.useCallback(E=>{Ys.debug("handleDelete, pending confirmation",E),h(E)},[]),C=b.useCallback(()=>{Ys.debug("handleDeleteConfirm",c),c.forEach(E=>e.deleteFile(_n(E)?he.makePath(E.filename):E.filename)),s(c),h([])},[c,s,e]),f=b.useCallback(()=>{Ys.debug("handleDeleteCancel"),h([])},[]),S=b.useCallback((E,D)=>{he.reducePaths(E.map(N=>_n(N)?he.makePath(N.filename):N.filename)).forEach(N=>{const _=he.isPath(N)?`${D}${he.getBaseName(N.substring(0,N.length-1))}/`:`${D}${he.getBaseName(N)}`;e.moveFile(N,_).then(()=>{i(N,_)}).catch(g)})},[g,i,e]),v=b.useCallback((E,D)=>{let F=E.filename;const N=_n(E);N&&!F.endsWith("/")&&(F=`${F}/`);let _=`${he.getParent(F)}${D}`;N&&!_.endsWith("/")&&(_=`${_}/`),Ys.debug2("handleRename",F,_),e.moveFile(F,_).catch(g),i(F,_)},[g,i,e]),w=b.useCallback(async(E,D)=>{if(D===E.basename)return;he.validateName(D);const F=`${he.getPath(E.filename)}${D}`;try{const N=await e.info(F);throw new xa(N)}catch(N){if(!(N instanceof xc))throw N}},[e]),T=c.length>0,y=b.useMemo(()=>c.length===1?`Are you sure you want to delete "${c[0].filename}"?`:"Are you sure you want to delete the selected files?",[c]);return l.jsxs("div",{className:"file-explorer",children:[u&&l.jsx(Tm,{isMultiSelect:t,focusedPath:n,showContextMenu:!0,onMove:S,onDelete:p,onRename:v,onSelect:o,onSelectionChange:a,rowHeight:r,table:u,validateRename:w}),l.jsx(ci,{isOpen:T,headerText:y,bodyText:"You cannot undo this action.",onCancel:f,onConfirm:C,confirmButtonText:"Delete"})]})}Ic.displayName="FileExplorer";const Xs=Z.module("NewItemModal");class Hi extends b.PureComponent{static propTypes={isOpen:I.bool,title:I.string.isRequired,defaultValue:I.string,type:I.oneOf(["file","directory"]).isRequired,onSubmit:I.func,onCancel:I.func,placeholder:I.string,storage:I.shape({}).isRequired,notifyOnExtensionChange:I.bool};static defaultProps={isOpen:!1,defaultValue:"/",notifyOnExtensionChange:!1,placeholder:"",onSubmit:(e,t)=>{},onCancel:()=>{}};static getValidationMessage(e){return e instanceof xa&&e.info.type==="directory"?"Error: Cannot overwrite existing directory":`${e}`}static handleError(e){ve.isCanceled(e)||Xs.error(e)}constructor(e){super(e),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:t}=e,n=he.hasPath(t)?he.getPath(t):"/";this.state={isSubmitting:!1,path:n,prevExtension:he.getExtension(t),showExtensionChangeModal:!1,showOverwriteModal:!1,value:he.getBaseName(t)}}componentDidUpdate(e,t){const{isOpen:n}=this.props,{isOpen:s}=e,{value:i,path:o}=this.state;!s&&n&&(this.resetValue(),this.isInitialLoad=!0),s&&n&&(!this.isInitialLoad&&(o!==t.path||i!==t.value)&&this.updateValidationStatus(o,i),this.isInitialLoad=!1)}componentWillUnmount(){this.pending.cancel(),this.cancelableValidatePromise&&this.cancelableValidatePromise.cancel(),this.cancelableExistingItemPromise&&this.cancelableExistingItemPromise.cancel()}inputRef=J.createRef();cancelableValidatePromise;cancelableExistingItemPromise;pending=new is;pathMap=new Map;isInitialLoad=!0;resetValue(){const{defaultValue:e}=this.props,t=he.hasPath(e)?he.getPath(e):"/";this.setState({path:t,value:he.getBaseName(e),validationError:void 0,prevExtension:he.getExtension(e),isSubmitting:!1})}getValidationPromise(e,t,n=!1){return this.cancelableValidatePromise&&this.cancelableValidatePromise.cancel(),this.cancelableValidatePromise=ve.makeCancelable(this.validateName(e,t,n)),this.cancelableValidatePromise}async validateName(e,t,n){he.validateName(t);const{defaultValue:s,storage:i}=this.props;if(n){const o=`${e}${t}`;if(o!==s)try{const a=await i.info(o);throw new xa(a)}catch(a){if(!(a instanceof xc))throw a}}return t}updateValidationStatus(e,t){this.getValidationPromise(e,t).then(()=>{this.setState({validationError:void 0})}).catch(this.handleValidationError).catch(Hi.handleError)}handleModalOpened(){this.focusRenameInput()}handleModalSubmit(){this.submitModal()}handleChange(e){const{value:t}=e.target;this.setState({value:t})}handleSelect(e){if(Xs.debug("handleSelect",e),e.type==="directory")this.setState({path:he.makePath(e.filename)});else{const t=e.basename,n=he.getPath(e.filename);this.setState({value:t,path:n},()=>{this.focusRenameInput()})}}handleKeyDown(e){const{key:t}=e;switch(e.stopPropagation(),t){case"Enter":{e.preventDefault(),this.submitModal();break}case"Escape":{e.preventDefault();const{onCancel:n}=this.props;n();break}}}handleValidationError(e){if(!(e instanceof Li))throw e;Xs.debug("Validation error",e),this.setState({validationError:e})}handleOverwriteCancel(){this.setState({showOverwriteModal:!1,isSubmitting:!1})}handleOverwriteConfirm(){this.setState({showOverwriteModal:!1});const{onSubmit:e}=this.props,{path:t,value:n}=this.state;Xs.debug("handleOverwriteConfirm",t,n),e(`${t}${n}`,!0)}handleExtensionChangeCancel(){Xs.debug("handleExtensionChangeCancel"),this.setState(({value:e,prevExtension:t})=>({showExtensionChangeModal:!1,value:he.replaceExtension(e,t)})),this.submitModal(!0)}handleExtensionChangeConfirm(){Xs.debug("handleExtensionChangeConfirm"),this.setState({showExtensionChangeModal:!1}),this.submitModal(!0)}focusRenameInput(){const e=this.inputRef.current;if(e){const{type:t}=this.props,{value:n}=e,s=t==="directory"?n.length:n.lastIndexOf(".");e.focus(),e.setSelectionRange(0,s>0?s:n.length)}}submitModal(e=!1){this.setState(({prevExtension:t,value:n,path:s})=>{const{notifyOnExtensionChange:i,type:o}=this.props;Xs.debug("submitModal",t,n);const a=he.getExtension(n);return i&&!e&&t!==null&&t!==a?{isSubmitting:!1,showExtensionChangeModal:!0,newExtension:a}:(this.getValidationPromise(s,n,!0).then(r=>{const{onSubmit:c}=this.props;c(`${s}${n}`)}).catch(r=>{if(r instanceof xa&&o!=="directory"&&r.info.type!=="directory"){this.setState({showOverwriteModal:!0});return}throw r}).catch(r=>{throw ve.isCanceled(r)&&this.setState({isSubmitting:!1}),r}).catch(this.handleValidationError).catch(Hi.handleError),{isSubmitting:!0,showExtensionChangeModal:!1,newExtension:void 0})})}handleBreadcrumbSelect(e){this.setState({path:e})}renderPathButtons(e){const t=e.split("/");return t.pop(),t.map((n,s)=>{let i="";for(let o=0;o<s;o+=1)i+=`${t[o]}/`;return i+=`${n}/`,l.jsxs(J.Fragment,{children:[l.jsx(B,{kind:"ghost",className:"directory-breadcrumbs",onClick:()=>this.handleBreadcrumbSelect(i),"aria-label":s===0?"Home":void 0,icon:s===0?l.jsx(Q,{icon:Sp,transform:"right-1.6"}):void 0,tooltip:s===0?"Home":void 0,children:n}),"/"]},i)})}render(){const{storage:e,isOpen:t,onCancel:n,placeholder:s,title:i,type:o}=this.props,{isSubmitting:a,path:r,showExtensionChangeModal:c,showOverwriteModal:h,validationError:u,value:m,prevExtension:g,newExtension:p}=this.state,C=o==="directory",f=he.fileExtensionToString(g),S=he.fileExtensionToString(p),v=C?"Create":"Save",w=C?"New folder name":"Save file as";return l.jsxs(l.Fragment,{children:[l.jsxs(zi,{isOpen:t,toggle:n,onOpened:this.handleModalOpened,className:"modal-dialog-centered new-file-modal theme-bg-dark",children:[l.jsx(Mo,{toggle:n,children:i}),l.jsx(Ki,{children:l.jsx("form",{children:l.jsxs("div",{className:"d-flex flex-column new-file-modal-content",children:[l.jsxs("div",{className:"flex-grow-0 mb-4",children:[l.jsx("label",{htmlFor:"file-name-input",children:w}),l.jsx("input",{id:"file-name-input",type:"text",autoComplete:"off",autoCapitalize:"none",autoCorrect:"off",spellCheck:"false",className:$("form-control",{"is-invalid":u}),value:m,placeholder:s,ref:this.inputRef,onKeyDown:this.handleKeyDown,onChange:this.handleChange}),u&&l.jsx("div",{className:"invalid-feedback",children:Hi.getValidationMessage(u)})]}),l.jsxs("div",{className:"flex-grow-0",children:[l.jsx("label",{children:"Directory: /"}),this.renderPathButtons(r)]}),l.jsx("div",{className:"flex-grow-1 file-explorer-container",children:l.jsx(Ic,{onSelect:this.handleSelect,storage:e,focusedPath:r})})]})})}),l.jsxs(_l,{children:[l.jsx(B,{kind:"secondary",onClick:n,children:"Cancel"}),l.jsx(B,{kind:"primary",disabled:a,onClick:this.handleModalSubmit,children:v})]})]}),l.jsx(ci,{isOpen:h,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"}),l.jsx(ci,{isOpen:c,headerText:"Confirm extension change",bodyText:`Are you sure you want to change extension from "${f}" to "${S}"?`,onCancel:this.handleExtensionChangeCancel,onConfirm:this.handleExtensionChangeConfirm,cancelButtonText:`Keep "${f}"`,confirmButtonText:`Use "${S}"`})]})}}function kR({createFile:d,createFolder:e,onSearchChange:t,defaultSearchText:n=""}){return l.jsxs("div",{className:"file-explorer-toolbar",children:[l.jsxs("div",{className:"file-explorer-toolbar-buttons",children:[l.jsx(B,{kind:"ghost",icon:kh,tooltip:"New notebook",onClick:d,"aria-label":"New notebook"}),l.jsx(B,{kind:"ghost",icon:bp,tooltip:"New folder",onClick:e,"aria-label":"New folder"})]}),t&&l.jsx("div",{className:"file-explorer-toolbar-search",children:l.jsx(Of,{value:n,onChange:t,placeholder:"Search by name"})})]})}const yi=Z.module("FileExplorerPanel"),OR=(d,e)=>{const t=cu(d),n=di(d,e.localDashboardId),{session:s,config:i}=n??{},o=i?.type;return{fileStorage:t,language:o,session:s}},AR=Ct(OR,null,null,{forwardRef:!0});function LR(d){const e=d;return e!=null&&typeof e.button=="number"}class qa extends J.Component{static COMPONENT="FileExplorerPanel";static TITLE="File Explorer";static handleError(e){yi.error(e)}static isFocusEvent(e){return LR(e)?e.detail>=2:!0}constructor(e){super(e),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:t,language:n}=e;this.state={isShown:!1,language:n,session:t,showCreateFolder:!1,focusedFilePath:"/"}}componentDidMount(){this.isHidden()||this.setState({isShown:!0})}handleCreateFile(){const{glEventHub:e}=this.props,{session:t,language:n}=this.state,s={language:n,value:""};yi.debug("handleCreateFile",t,n,s),e.emit($e.CREATE_NOTEBOOK,t,n,s)}handleCreateDirectory(e){this.setState({showCreateFolder:!0})}handleCreateDirectoryCancel(){yi.debug("handleCreateDirectoryCancel"),this.setState({showCreateFolder:!1})}handleCreateDirectorySubmit(e){yi.debug("handleCreateDirectorySubmit",e),this.setState({showCreateFolder:!1});const{fileStorage:t}=this.props;t.createDirectory(e).catch(qa.handleError)}handleDelete(e){const{glEventHub:t}=this.props;e.forEach(n=>{t.emit($e.CLOSE_FILE,{id:n.filename,itemName:n.filename})})}handleSelectionChange(e){let t="/";e.length===1&&(e[0].type==="directory"?t=he.makePath(e[0].filename):t=he.getPath(e[0].filename)),this.setState({focusedFilePath:t})}handleFileSelect(e,t){if(yi.debug("fileSelect",e),e.type==="directory")return;const n=qa.isFocusEvent(t),s={id:e.filename,itemName:e.filename},{glEventHub:i}=this.props,{session:o,language:a}=this.state,r={value:null,language:a};i.emit($e.SELECT_NOTEBOOK,o,a,r,s,n)}handleRename(e,t){const{glEventHub:n}=this.props;yi.debug("handleRename",e,t),n.emit($e.RENAME_FILE,e,t)}handleSessionOpened(e,{language:t}){this.setState({session:e,language:t})}handleSessionClosed(){this.setState({session:void 0,language:void 0})}handleShow(){this.setState({isShown:!0})}isHidden(){const{glContainer:e}=this.props,{isHidden:t}=e;return t}render(){const{fileStorage:e,glContainer:t,glEventHub:n}=this.props,{isShown:s,showCreateFolder:i,focusedFilePath:o}=this.state;return l.jsxs(os,{className:"file-explorer-panel",componentPanel:this,glContainer:t,glEventHub:n,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onShow:this.handleShow,children:[l.jsx(kR,{createFile:this.handleCreateFile,createFolder:this.handleCreateDirectory}),s&&l.jsx(Ic,{isMultiSelect:!0,storage:e,onDelete:this.handleDelete,onRename:this.handleRename,onSelect:this.handleFileSelect,onSelectionChange:this.handleSelectionChange}),l.jsx(Hi,{isOpen:i,type:"directory",title:"Create New Folder",storage:e,onSubmit:this.handleCreateDirectorySubmit,onCancel:this.handleCreateDirectoryCancel,defaultValue:o})]})}}const Ya=AR(qa);const ot=Z.module("FilterSetManager"),PR="Enter name...",eh="No Available Filter Sets";class Xa extends b.Component{static animateScreenFlash(){const e=document.createElement("div");e.classList.add("screen-flash-overlay"),e.addEventListener("animationend",()=>{e.remove()}),document.querySelector("body")?.appendChild(e)}constructor(e){super(e),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}}componentDidMount(){const{isValueShown:e}=this.props;e?this.updateSelectedId():this.initSettingsScreen()}componentDidUpdate(e,t){const{isValueShown:n,filterSets:s}=this.props,{modifiedFilterSets:i}=this.state;if(e.isValueShown&&!n&&this.initSettingsScreen(),this.isNameInputScreen()&&!this.isNameInputScreen(t)&&this.focusRenameInput(),s!==e.filterSets)if(!n&&s.length>0&&e.filterSets.length===0&&i.length===0){const{onChange:o}=this.props;o({isValueShown:!0,selectedId:s[0].id})}else this.updateSelectedId()}renameInputRef=J.createRef();dropdownRef=J.createRef();editDropdownRef=J.createRef();initSettingsScreen(){const{filterSets:e,selectedId:t}=this.props;ot.debug("initSettingsScreen",e,t),this.setState({modifiedFilterSets:[...e],editId:t})}updateSelectedId(){const{isValueShown:e,filterSets:t,selectedId:n,onChange:s}=this.props;if(ot.debug("updateSelectedId",t,n),!!e&&!t.some(({id:i})=>i===n)){const i=t.length===0;s({isValueShown:!i,selectedId:i?void 0:t[0].id})}}handleEditDropdownChange(e){const{value:t}=e.target;this.setState({editId:t})}handleFilterChange(e){const{value:t}=e.target,{isValueShown:n,onChange:s}=this.props;this.applyFilterSet(t),s({isValueShown:n,selectedId:t})}handleFilterApply(){const{selectedId:e}=this.props;this.applyFilterSet(e)}handleSettingsCancel(){const{onChange:e,selectedId:t,filterSets:n}=this.props;this.setState({modifiedFilterSets:[]}),n.length>0&&e({isValueShown:!0,selectedId:t})}handleSettingsSave(){const{onChange:e,onUpdateSets:t}=this.props,{modifiedFilterSets:n,editId:s}=this.state;this.setState({modifiedFilterSets:[]}),ot.debug("Update sets",n,s),t(n),n.length>0&&e({isValueShown:!0,selectedId:s})}handleCaptureNewSet(){const{getFilterState:e}=this.props;Xa.animateScreenFlash();const t=_e(),n=e(),s={id:t,title:"",panels:n};ot.debug("handleSetCreate",s),this.setState({nameInputValue:"",nameInputError:void 0,renameSet:s})}handleRenameCancel(){this.setState({renameSet:void 0})}handleRestoreFullStateChange(e){this.setState({restoreFullState:e.target.value==="true"})}getNameError(e){const{renameSet:t,modifiedFilterSets:n}=this.state,s=e?.trim()??"";if(s.length===0)return ot.debug("Name cannot be empty",s),"Name cannot be empty";if(t!==void 0&&n.some(({title:i,id:o})=>i===s&&o!==t.id))return ot.debug("Set with this name already exists",s),"Set with this name already exists"}handleRenameConfirm(){const{nameInputValue:e,renameSet:t,modifiedFilterSets:n,restoreFullState:s}=this.state;if(t===void 0){ot.error("Renamed set undefined.");return}const i=this.getNameError(e);if(ot.debug("handleRenameConfirm",e,i),i!==void 0){this.setState({nameInputError:i});return}const o=e?.trim()??"",a={...t,title:o,restoreFullState:s},r=n.findIndex(({id:h})=>h===t.id),c=[...n];r>=0?(c[r]=a,ot.debug("Renamed existing set",c)):(c.push(a),ot.debug("Added new set to modified sets",c)),this.setState({editId:a.id,modifiedFilterSets:c,renameSet:void 0})}handleSetDelete(){this.setState(e=>{const{editId:t,modifiedFilterSets:n}=e,s=n.findIndex(({id:r})=>r===t);if(s<0)return ot.error("Unable to find selected filterSet index",n,t),null;const i=n.filter(({id:r})=>r!==t),o=Math.max(0,Math.min(i.length-1,s-1)),a=i.length>0?i[o].id:void 0;return ot.debug("Deleted selected set",t,n,i),ot.debug("New selection",o,a),{modifiedFilterSets:i,editId:a}})}handleSetUpdate(){const{getFilterState:e}=this.props;Xa.animateScreenFlash();const t=e();this.setState(({modifiedFilterSets:n,editId:s})=>{if(s===void 0)return ot.error("Filter for update not selected."),null;const i=[...n],o=i.findIndex(({id:a})=>a===s);return o<0?(ot.error("Selected set for update not found."),null):(i[o]={...i[o],panels:t},ot.debug("Update set",i,t),{modifiedFilterSets:i})})}handleSetEdit(){this.setState(({editId:e,modifiedFilterSets:t})=>{const n=t.find(({id:o})=>o===e);if(n===void 0)return ot.error("Could not find selected set",e,t),null;const{title:s,restoreFullState:i=!1}=n;return{nameInputValue:s,nameInputError:void 0,renameSet:n,restoreFullState:i}})}handleSettingsClick(e){e.stopPropagation();const{onChange:t,selectedId:n}=this.props;t({isValueShown:!1,selectedId:n})}handleBackgroundClick(e){ot.debug("handleBackgroundClick"),e.target!==this.dropdownRef.current&&this.focusInput()}handleNameInputChange(e){const{value:t}=e.target,n=this.getNameError(t);this.setState({nameInputValue:t,nameInputError:n})}handleNameInputKeyPress(e){const{key:t}=e;t==="Enter"&&(e.preventDefault(),this.handleRenameConfirm())}isNameInputScreen(e=this.state){const{renameSet:t}=e;return t!==void 0}isRenamingExistingSet=fe((e,t)=>t!==void 0&&e.some(({id:n})=>n===t.id));applyFilterSet(e){const{onApply:t,filterSets:n}=this.props;if(e===void 0){ot.debug("No filter selected");return}const s=n.find(({id:i})=>i===e);if(s===void 0){ot.debug("Selected id not found in filterSets",e,n);return}ot.debug("Apply filterSet",s),t(s)}focusInput(){this.dropdownRef.current?.focus()}focusRenameInput(){this.renameInputRef.current?.focus()}render(){const{nameInputValue:e,nameInputError:t,editId:n,renameSet:s,modifiedFilterSets:i,restoreFullState:o}=this.state,{isValueShown:a,filterSets:r,selectedId:c}=this.props,h=this.isNameInputScreen(),u=this.isRenamingExistingSet(i,s),m=i.length===0,g=!h&&m&&r.length===0,p=!h&&!g,C=l.jsxs("div",{className:"fa-layers mr-3",children:[l.jsx(Q,{icon:Ui,mask:cl,transform:"shrink-1 down-5 right-7"}),l.jsx(Q,{icon:Ps,className:"text-primary",transform:"shrink-6 down-5 right-7"})]}),f=l.jsxs("div",{className:"fa-layers",children:[l.jsx(Q,{icon:Ui,mask:cl,transform:"shrink-1 down-5 right-7"}),l.jsx(Q,{icon:dl,transform:"shrink-1 down-5 right-7"})]});return l.jsx("div",{className:"filter-set-manager fill-parent-absolute",children:l.jsxs(jl,{className:"w-100 h-100",isFlipped:a,children:[l.jsx("div",{className:"filter-set-manager-settings-card fill-parent-absolute",children:l.jsxs("div",{className:"filter-set-manager-card-content",children:[g&&l.jsxs("div",{children:[l.jsx(B,{kind:"ghost",className:"btn btn-link no-underline",onClick:this.handleCaptureNewSet,icon:C,children:"Capture filter set"}),l.jsx("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."})]}),h&&l.jsxs("div",{className:"d-flex flex-column justify-content-center","data-testid":"edit-filter-set-container",children:[l.jsxs("div",{className:"form-group",children:[l.jsx("label",{children:u?"Edit set":"Name captured set"}),l.jsxs("div",{className:"name-input-container",children:[l.jsx("input",{type:"text",className:"input-set-name form-control",placeholder:PR,value:e,ref:this.renameInputRef,onChange:this.handleNameInputChange,onKeyPress:this.handleNameInputKeyPress,spellCheck:"false"}),l.jsx(B,{"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:_h}),l.jsx(B,{"data-testid":"rename-cancel-button",kind:"ghost",className:"btn btn-link no-underline pt-2 pb-2",onClick:this.handleRenameCancel,tooltip:"Cancel",icon:wp})]}),t!==void 0&&l.jsx("div",{className:"error-message",children:t})]}),l.jsx("div",{className:"form-group",children:l.jsxs(hr,{onChange:this.handleRestoreFullStateChange,value:`${o}`,children:[l.jsx(ts,{value:"false",children:"Restore only filters"}),l.jsx(ts,{value:"true",children:"Restore full table state"})]})})]}),p&&l.jsxs("div",{className:"filter-set-manager-settings-grid-1",children:[l.jsxs("div",{className:"form-group",children:[l.jsx("label",{children:"Edit filter sets"}),l.jsxs("div",{className:"filter-select-container",children:[l.jsxs("select",{"data-testid":"settings-card-filter-select",ref:this.editDropdownRef,value:n??"-1",className:"custom-select filter-value-select",onChange:this.handleEditDropdownChange,disabled:m,children:[m&&l.jsx("option",{value:"-1",disabled:!0,children:eh}),i.map(({id:S,title:v})=>l.jsx("option",{value:S,children:v},S))]}),l.jsx(B,{kind:"ghost",onClick:this.handleSetUpdate,disabled:m,icon:f,tooltip:"Update"}),l.jsx(B,{kind:"ghost",onClick:this.handleSetEdit,disabled:m,icon:Ao,tooltip:"Edit"}),l.jsx(B,{kind:"ghost",onClick:this.handleSetDelete,disabled:m,icon:Jt,tooltip:"Delete"})]})]}),l.jsx("div",{children:l.jsx(B,{kind:"ghost",className:"btn btn-link no-underline",onClick:this.handleCaptureNewSet,icon:C,children:"Capture new filter set"})}),l.jsxs("div",{className:"py-3 text-right",children:[l.jsx(B,{kind:"secondary",onClick:this.handleSettingsCancel,children:"Cancel"})," ",l.jsx(B,{kind:"primary",onClick:this.handleSettingsSave,children:"Save"})]})]})]})},"front"),l.jsxs("div",{className:"filter-set-manager-value-card fill-parent-absolute",onClick:this.handleBackgroundClick,children:[l.jsx("div",{className:"filter-set-manager-column",children:l.jsx("div",{className:"filter-set-manager-column-title",children:"Filter sets"})}),l.jsx("div",{className:"filter-set-manager-card-content",children:l.jsx("div",{className:"filter-set-manager-value-input",children:l.jsxs("div",{className:"filter-select-container",children:[l.jsxs("select",{"data-testid":"value-card-filter-select",ref:this.dropdownRef,value:c,className:"custom-select filter-value-select",onChange:this.handleFilterChange,children:[r.length===0&&l.jsx("option",{value:"-1",disabled:!0,children:eh}),r.map(({id:S,title:v})=>l.jsx("option",{value:S,children:v},S))]}),l.jsx(B,{"data-testid":"filter-apply-button",kind:"ghost",onClick:this.handleFilterApply,icon:Ol,tooltip:"Apply Filter Set"})]})})}),l.jsx("div",{className:"filter-set-manager-menu",children:l.jsx(B,{kind:"ghost",className:"btn btn-link btn-link-icon m-2 px-2",onClick:this.handleSettingsClick,tooltip:"Settings",icon:l.jsx(Q,{icon:Oo,transform:"grow-4"})})})]},"back")]})})}}function Dc(d){const{model:e,widgetName:t,glContainer:n,description:s}=d,i=(e?.rowCount??0)-(e?.pendingRowCount??0),o=e?.displayString(i,"long");return l.jsx(yr,{widgetType:"Table",widgetName:t,glContainer:n,description:s,children:l.jsxs("div",{className:"column-statistics-grid",children:[l.jsx("span",{className:"column-statistic-operation",children:"Number of Rows"}),l.jsx("span",{className:"column-statistic-value",children:o})]})})}Dc.propTypes={glContainer:oc.Container.isRequired,widgetName:I.string.isRequired,description:I.string};Dc.defaultProps={description:null};const Fn=Z.module("IrisGridPanel"),_R=500,jR={IrisGrid:pm,IrisGridTableModel:fm,ContextMenuRoot:Vh};class Tl extends b.PureComponent{static defaultProps={onStateChange:()=>{},onPanelStateUpdate:()=>{}};static displayName="IrisGridPanel";static COMPONENT="IrisGridPanel";constructor(e){super(e),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=J.createRef(),this.pluginRef=J.createRef();const{panelState:t}=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(om.DEFAULTS),customColumns:[],customColumnFormatMap:new Map,isFilterBarShown:!1,quickFilters:new Map,sorts:[],userColumnWidths:new Map,userRowHeights:new Map,reverseType:x.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:t,irisGridStateOverrides:{},gridStateOverrides:{},isStuckToBottom:!1,isStuckToRight:!1,conditionalFormats:[],selectDistinctColumns:[]}}componentDidMount(){this.initModel()}componentDidUpdate(e,t){const{model:n}=this.state;n!==t.model&&(t.model!=null&&(this.stopModelListening(t.model),t.model.close()),n!=null&&this.startModelListening(n))}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())}irisGrid;pluginRef;modelPromise;irisGridState;gridState;pluginState;getTableName(){const{metadata:e}=this.props;return e.table}getGridInputFilters=fe((e,t)=>be.getInputFiltersForColumns(e,t.filter(({value:n,excludePanelIds:s})=>{const i=Y.getIdFromPanel(this);return n!=null&&(s==null||i!=null&&!s.includes(i))})));getAlwaysFetchColumns=fe((e,t)=>{const n=Y.getIdFromPanel(this),s=new Set(t);for(let i=0;i<e.length;i+=1){const{start:o}=e[i];o!=null&&o.panelId===n&&s.add(o.columnName)}return[...s]});getPluginContent=fe((e,t,n,s,i)=>!t||!ai(t)||e==null||t.table==null?null:l.jsx("div",{className:"iris-grid-plugin",children:l.jsx(e,{ref:this.pluginRef,filter:this.handlePluginFilter,onFilter:this.handlePluginFilter,fetchColumns:this.handlePluginFetchColumns,onFetchColumns:this.handlePluginFetchColumns,table:t.table,user:n,panel:this,workspace:s,components:jR,onStateChange:this.handlePluginStateChange,pluginState:i})}));getDehydratedIrisGridPanelState=fe((e,t,n,s,i)=>be.dehydrateIrisGridPanelState(e,{isSelectingPartition:t,partition:n,partitionColumn:s,advancedSettings:i}));getDehydratedIrisGridState=fe((e,t,n,s,i,o,a,r,c,h,u,m,g,p,C,f,S,v,w,T,y)=>be.dehydrateIrisGridState(e,{advancedFilters:n,aggregationSettings:S,customColumnFormatMap:s,isFilterBarShown:i,metrics:{userColumnWidths:C,userRowHeights:f},quickFilters:o,customColumns:a,reverseType:r,rollupConfig:c,showSearchBar:h,searchValue:u,selectDistinctColumns:m,selectedSearchColumns:g,sorts:t,invertSearchColumns:p,pendingDataMap:v,frozenColumns:w,conditionalFormats:T,columnHeaderGroups:y}));getDehydratedGridState=fe((e,t,n,s,i)=>be.dehydrateGridState(e,{isStuckToBottom:s,isStuckToRight:i,movedColumns:t,movedRows:n}));getCachedPanelState=fe((e,t,n,s)=>({irisGridPanelState:e,irisGridState:t,gridState:n,pluginState:s}));initModel(){this.setState({isModelReady:!1,isLoading:!0,error:null});const{makeModel:e}=this.props;this.modelPromise!=null&&this.modelPromise.cancel(),this.modelPromise=ve.makeCancelable(e(),t=>t.close()),this.modelPromise.then(this.handleLoadSuccess).catch(this.handleLoadError)}handleLoadSuccess(e){const t=e,{panelState:n,irisGridStateOverrides:s}=this.state,i=[];if(n!=null){const{irisGridState:o}=n,{aggregationSettings:a,customColumns:r,selectDistinctColumns:c=[],rollupConfig:h}={...o,...s};r.length>0&&i.push(u=>{u.customColumns=r}),h!=null&&h.columns.length>0&&i.push(u=>{u.rollupConfig=be.getModelRollupConfig(u.originalColumns,h,a)}),c.length>0&&i.push(u=>{u.selectDistinctColumns=c})}this.setState({model:t,modelQueue:i}),this.initModelQueue(t,i)}initModelQueue(e,t){const n=e;if(t.length===0){this.modelInitialized(n);return}const s=t.shift();Fn.debug("initModelQueue",s),s&&s(n),this.setState({modelQueue:t})}handleAdvancedSettingsChange(e,t){Fn.debug("handleAdvancedSettingsChange",e,t),this.setState(({advancedSettings:n})=>n.get(e)===t?null:{advancedSettings:new Map(n).set(e,t)})}handlePluginFilter(e){const{model:t}=this.state;M(t);const{columns:n,formatter:s}=t,i=be.getFiltersFromInputFilters(n,e,s.timeZone);this.setState({pluginFilters:i})}handlePluginFetchColumns(e){this.setState({pluginFetchColumns:e})}handleContextMenu(e){return this.pluginRef.current?.getMenu?.(e)??[]}isColumnSelectionValid(e){const{columnSelectionValidator:t}=this.props;return t&&e?t(this,e):!1}handleGridStateChange(e,t){this.irisGridState=e,this.gridState=t,this.setState({isLoaded:!0,isLoading:!1}),this.savePanelState();const{glEventHub:n,onStateChange:s}=this.props;n.emit(bn.STATE_CHANGED,this),s?.(e,t)}handlePluginStateChange(e){const{irisGridState:t,gridState:n}=this;this.pluginState=e,t!==null&&n!==null&&this.savePanelState()}handleColumnsChanged(e){const{isModelReady:t,model:n,modelQueue:s}=this.state;t?this.sendColumnsChange(e.detail):(M(n),this.initModelQueue(n,s))}handleTableChanged(e){Fn.debug("handleTableChanged",e);const{glEventHub:t}=this.props,{detail:n}=e;t.emit(Qe.TABLE_CHANGED,this,n)}handlePartitionAppend(e,t){const{glEventHub:n}=this.props,{name:s}=e,i=this.getTableName(),o=`${i} = ${i}.where("${s}=\`${t}\`")`;n.emit(Xt.SEND_COMMAND,o,!1,!0)}handleCreateChart(e,t){this.savePanelState.flush(),this.setState(()=>null,()=>{const{glEventHub:n,inputFilters:s,metadata:i}=this.props,{table:o}=i,{panelState:a}=this.state,r=Y.getIdFromPanel(this);let c;a&&(c=be.extractTableSettings(a,s)),n.emit(bn.CREATE_CHART,{metadata:{settings:e,sourcePanelId:r,table:o,tableSettings:c},table:ai(t)?t.table:void 0})})}handleColumnSelected(e){const{glEventHub:t}=this.props;t.emit(bn.COLUMN_SELECTED,this,e)}handleDataSelected(e,t){const{glEventHub:n}=this.props;n.emit(bn.DATA_SELECTED,this,t)}handleResize(){this.updateGrid()}handleShow(){this.updateGrid()}handleTabClicked(){this.irisGrid.current&&this.irisGrid.current.focus()}handleError(e){Fn.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){ve.isCanceled(e)||this.handleError(e)}modelInitialized(e){const{glEventHub:t,loadPlugin:n}=this.props;if(this.modelPromise=void 0,this.loadPanelState(e),this.setState({isModelReady:!0}),ai(e)){const{table:s}=e,{pluginName:i}=s;if(i!==""&&n!=null&&i!=null){const o=n(i);this.setState({Plugin:o})}t.emit(Qe.TABLE_CHANGED,this,s)}this.sendColumnsChange(e.columns)}handleClearAllFilters(){const e=this.irisGrid.current,{isDisconnected:t}=this.state;e!=null&&!t&&e.clearAllFilters()}sendColumnsChange(e){Fn.debug2("sendColumnsChange",e);const{glEventHub:t}=this.props;t.emit(Qe.COLUMNS_CHANGED,this,e)}startModelListening(e){e.addEventListener(Se.EVENT.DISCONNECT,this.handleDisconnect),e.addEventListener(Se.EVENT.RECONNECT,this.handleReconnect),e.addEventListener(Se.EVENT.COLUMNS_CHANGED,this.handleColumnsChanged),e.addEventListener(Se.EVENT.TABLE_CHANGED,this.handleTableChanged)}stopModelListening(e){e.removeEventListener(Se.EVENT.DISCONNECT,this.handleDisconnect),e.removeEventListener(Se.EVENT.RECONNECT,this.handleReconnect),e.removeEventListener(Se.EVENT.COLUMNS_CHANGED,this.handleColumnsChanged),e.removeEventListener(Se.EVENT.TABLE_CHANGED,this.handleTableChanged)}getCoordinateForColumn(e){const{model:t}=this.state;if(!t)return null;const n=this.irisGrid.current,{gridWrapper:s}=n||{},i=s?.getBoundingClientRect()??null;if(i==null||i.width<=0||i.height<=0)return null;M(n);const{metrics:o}=n.state;M(o);const{columnHeaderHeight:a,allColumnXs:r,allColumnWidths:c,right:h,columnHeaderMaxDepth:u}=o,m=t.getColumnIndexByName(e);M(m);const g=n.getVisibleColumn(m),p=r.get(g)??0,C=c.get(g)??0,f=Math.max(i.left,Math.min(g>h?i.right:i.left+p+C*.5,i.right)),S=i.top+a*u;return[f,S]}setFilterMap(e){const t=this.irisGrid.current;t?.setFilterMap(e)}setAdvancedFilterMap(e){const t=this.irisGrid.current;t?.setAdvancedFilterMap(e)}setFilters({quickFilters:e,advancedFilters:t}){Fn.debug("setFilters",e,t);const{model:n,isDisconnected:s}=this.state,i=this.irisGrid.current;if(i==null||s){Fn.debug("Ignore setFilters, model disconnected");return}M(n);const{columns:o,formatter:a}=n,r=be.changeFilterColumnNamesToIndexes(n.columns,e).filter(([h])=>n.isFilterable(h)),c=be.changeFilterColumnNamesToIndexes(n.columns,t).filter(([h])=>n.isFilterable(h));i.clearAllFilters(),i.setFilters({quickFilters:be.hydrateQuickFilters(o,r,a.timeZone),advancedFilters:be.hydrateAdvancedFilters(o,c,a.timeZone)})}setStateOverrides(e){Fn.debug("setStateOverrides",e);const{irisGridState:t,gridState:n}=e;this.setState({irisGridStateOverrides:t,gridStateOverrides:n},()=>{this.initModel()})}unsetFilterValue(){}loadPanelState(e){const{panelState:t,irisGridStateOverrides:n,gridStateOverrides:s}=this.state;if(t!=null)try{const{gridState:i,irisGridState:o,irisGridPanelState:a}=t,r={...n},{quickFilters:c,advancedFilters:h}=r;c&&(r.quickFilters=be.changeFilterColumnNamesToIndexes(e.columns,c)),h&&(r.advancedFilters=be.changeFilterColumnNamesToIndexes(e.columns,h));const{isSelectingPartition:u,partition:m,partitionColumn:g,advancedSettings:p}=be.hydrateIrisGridPanelState(e,a),{advancedFilters:C,customColumns:f,customColumnFormatMap:S,isFilterBarShown:v,quickFilters:w,reverseType:T,rollupConfig:y,aggregationSettings:E,sorts:D,userColumnWidths:F,userRowHeights:N,showSearchBar:_,searchValue:P,selectDistinctColumns:U,selectedSearchColumns:O,invertSearchColumns:j,pendingDataMap:k,frozenColumns:A,conditionalFormats:H,columnHeaderGroups:K}=be.hydrateIrisGridState(e,{...o,...r}),{isStuckToBottom:q,isStuckToRight:oe,movedColumns:W,movedRows:G}=be.hydrateGridState(e,{...i,...s},o.customColumns);this.setState({advancedFilters:C,advancedSettings:p,conditionalFormats:H,customColumns:f,customColumnFormatMap:S,isFilterBarShown:v,isSelectingPartition:u,movedColumns:W,movedRows:G,partition:m,partitionColumn:g,quickFilters:w,reverseType:T,rollupConfig:y,aggregationSettings:E,sorts:D,userColumnWidths:F,userRowHeights:N,showSearchBar:_,searchValue:P,selectDistinctColumns:U,selectedSearchColumns:O,invertSearchColumns:j,pendingDataMap:k,frozenColumns:A,isStuckToBottom:q,isStuckToRight:oe,columnHeaderGroups:K})}catch(i){Fn.error("loadPanelState failed to load panelState",t,i)}}savePanelState=Ye(()=>{const{irisGridState:e,gridState:t,pluginState:n}=this;M(e);const{onPanelStateUpdate:s}=this.props,{model:i,panelState:o,isSelectingPartition:a,partition:r,partitionColumn:c,advancedSettings:h}=this.state,{advancedFilters:u,aggregationSettings:m,customColumnFormatMap:g,isFilterBarShown:p,quickFilters:C,customColumns:f,reverseType:S,rollupConfig:v,showSearchBar:w,searchValue:T,selectDistinctColumns:y,selectedSearchColumns:E,sorts:D,invertSearchColumns:F,metrics:N,pendingDataMap:_,frozenColumns:P,conditionalFormats:U,columnHeaderGroups:O}=e;M(i),M(N);const{userColumnWidths:j,userRowHeights:k}=N;M(t);const{isStuckToBottom:A,isStuckToRight:H,movedColumns:K,movedRows:q}=t,oe=this.getCachedPanelState(this.getDehydratedIrisGridPanelState(i,a,r,c,h),this.getDehydratedIrisGridState(i,D,u,g,p,C,f,S,v,w,T,y,E,F,j,k,m,_,P,U,O),this.getDehydratedGridState(i,K,q,A,H),n);oe!==o&&(Fn.debug("Saving panel state",this,oe),this.setState({panelState:oe}),s?.(oe))},_R);updateGrid(){const e=this.irisGrid.current?.grid??null;e&&e.handleResize()}render(){const{children:e,glContainer:t,glEventHub:n,columnSelectionValidator:s,getDownloadWorker:i,inputFilters:o,links:a,metadata:r,panelState:c,user:h,workspace:u,settings:m,theme:g}=this.props,{advancedFilters:p,aggregationSettings:C,advancedSettings:f,conditionalFormats:S,customColumns:v,customColumnFormatMap:w,error:T,isDisconnected:y,isFilterBarShown:E,isSelectingPartition:D,isStuckToBottom:F,isStuckToRight:N,isLoaded:_,isLoading:P,isModelReady:U,model:O,movedColumns:j,movedRows:k,partition:A,partitionColumn:H,quickFilters:K,reverseType:q,rollupConfig:oe,sorts:W,userColumnWidths:G,userRowHeights:ne,showSearchBar:ae,searchValue:ce,selectDistinctColumns:te,selectedSearchColumns:re,invertSearchColumns:we,Plugin:Ie,pluginFilters:xe,pluginFetchColumns:at,pendingDataMap:xt,frozenColumns:en,columnHeaderGroups:Rn}=this.state,kt=T!=null?`Unable to open table. ${T}`:void 0,{table:ye}=r,ut=O?.description??void 0,rt=c?.pluginState??null,bt=e??this.getPluginContent(Ie,O,h,u,rt),{permissions:Ot}=h,{canCopy:xn,canDownloadCsv:tn}=Ot;return l.jsx(Sc,{errorMessage:kt,isDisconnected:y,isLoading:P,isLoaded:_,className:"iris-grid-panel",glContainer:t,glEventHub:n,onClearAllFilters:this.handleClearAllFilters,onResize:this.handleResize,onShow:this.handleShow,onTabFocus:this.handleShow,onTabClicked:this.handleTabClicked,widgetName:ye,widgetType:"Table",description:ut,componentPanel:this,renderTabTooltip:()=>l.jsx(Dc,{model:O,widgetName:ye,glContainer:t,description:ut}),children:U&&O&&l.jsx(pm,{advancedFilters:p,aggregationSettings:C,advancedSettings:f,alwaysFetchColumns:this.getAlwaysFetchColumns(a,at),columnAllowedCursor:"linker",columnNotAllowedCursor:"linker-not-allowed",customColumns:v,customColumnFormatMap:w,columnSelectionValidator:this.isColumnSelectionValid,conditionalFormats:S,inputFilters:this.getGridInputFilters(O.columns,o),applyInputFiltersOnInit:c==null,isFilterBarShown:E,isSelectingColumn:s!=null,isSelectingPartition:D,isStuckToBottom:F,isStuckToRight:N,movedColumns:j,movedRows:k,partition:A,partitionColumn:H,quickFilters:K,reverseType:q,rollupConfig:oe,settings:m,sorts:W,userColumnWidths:G,userRowHeights:ne,model:O,showSearchBar:ae,searchValue:ce,selectedSearchColumns:re,selectDistinctColumns:te,invertSearchColumns:we,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:xe,pendingDataMap:xt,canCopy:xn,canDownloadCsv:tn,ref:this.irisGrid,getDownloadWorker:i,frozenColumns:en,theme:g,columnHeaderGroups:Rn,children:bt})})}}const HR=(d,{localDashboardId:e=Tn})=>({inputFilters:bc(d,e),links:Ji(d,e),columnSelectionValidator:Tc(d,e),user:ru(d),workspace:mr(d),settings:St(d)}),li=Ct(HR,null,null,{forwardRef:!0})(Tl);const th=Z.module("InputFilter"),VR=150;class Za extends b.Component{static PLACEHOLDER="Enter value...";static defaultProps={column:null,isValueShown:!1,value:null};constructor(e){super(e),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=J.createRef();const{column:t,isValueShown:n,value:s}=e;this.state={column:t,selectedColumn:t,value:s,isValueShown:n}}componentDidUpdate(e,t){const{column:n}=this.props,{column:s,value:i,isValueShown:o}=this.state;n!==e.column&&this.setState({column:n,selectedColumn:n}),o!==void 0&&o&&o!==t.isValueShown&&this.focusInput(),(s!==t.column||i!==t.value||o!==t.isValueShown)&&this.sendUpdate()}componentWillUnmount(){this.sendUpdate.flush()}inputRef;getItemLabel=ge((e,t)=>{const{name:n,type:s}=e[t];if(t>0&&e[t-1].name===n||t<e.length-1&&e[t+1].name===n){const i=s.substring(s.lastIndexOf(".")+1);return`${n} (${i})`}return n});handleColumnChange(e){const{columns:t}=this.props,{value:n}=e.target,s=t[parseInt(n,10)];th.debug2("handleColumnChange",s),this.setState({selectedColumn:s,value:void 0})}handleInputKeyPress(e){e.key==="Enter"&&(e.preventDefault(),e.stopPropagation(),this.setState(({value:t})=>t==null?{value:""}:null,()=>{this.sendUpdate(),this.sendUpdate.flush()}))}handleValueChange(e){const{value:t}=e.target;th.debug2("handleValueChange",t),this.setState({value:t})}handleSettingsCancel(){const{column:e}=this.state;this.setState({selectedColumn:e,isValueShown:!0})}handleSettingsSave(){const{selectedColumn:e}=this.state;this.setState({column:e,isValueShown:!0})}handleSettingsClick(e){const{column:t}=this.state;this.setState({selectedColumn:t,isValueShown:!1}),e.stopPropagation()}handleBackgroundClick(e){e.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:e,type:t,value:n,isValueShown:s}){const i=e!=null&&t!=null?{name:e,type:t}:void 0,o=s===void 0?{column:i,value:n}:{column:i,value:n,isValueShown:s};this.setState(o)}sendUpdate=Ye(()=>{const{onChange:e}=this.props,{column:t,value:n,isValueShown:s}=this.state;e({column:t,isValueShown:s,value:n})},VR);render(){const{columns:e}=this.props,{column:t,isValueShown:n,selectedColumn:s,value:i}=this.state,o=i==null||i.length===0?Za.PLACEHOLDER.length:i.length;let a=null;if(t!=null){const r=e.findIndex(c=>c.name===t.name&&c.type===t.type);a=r>=0?this.getItemLabel(e,r):t.name}return l.jsxs(jl,{className:"input-filter fill-parent-absolute",isFlipped:n??!1,children:[l.jsx("div",{className:"input-filter-settings-card",children:l.jsxs("div",{className:"input-filter-settings-content",children:[l.jsxs("div",{className:"input-filter-settings-grid",children:[l.jsx("label",{children:"Filter Column"}),l.jsxs("select",{value:e.findIndex(r=>r.name===s?.name&&r.type===s?.type),className:"custom-select",onChange:this.handleColumnChange,children:[e.map((r,c)=>l.jsx("option",{value:c,children:this.getItemLabel(e,c)},`${r.name}/${r.type}`)),e.length===0&&l.jsx("option",{value:"-1",disabled:!0,children:"No Available Columns"})]}),l.jsx("div",{className:"text-muted small",children:"Input filter control will apply its filter to all columns matching this name in this dashboard."})]}),l.jsxs("div",{className:"input-filter-settings-buttons",children:[l.jsx(B,{kind:"secondary",onClick:this.handleSettingsCancel,disabled:t==null,children:"Cancel"}),l.jsx(B,{kind:"primary",className:"ml-2",onClick:this.handleSettingsSave,disabled:s==null,children:"Save"})]})]})}),l.jsxs("div",{className:"input-filter-value-card",onClick:this.handleBackgroundClick,children:[l.jsx("div",{className:"input-filter-column",children:l.jsxs("div",{className:"input-filter-column-title",children:[a," Filter"]})}),l.jsx("div",{className:"d-flex justify-content-center align-items-center h-100 w-100",children:l.jsx("div",{className:"input-filter-value-input d-flex flex-column justify-content-center",children:l.jsx("input",{type:"text",ref:this.inputRef,placeholder:Za.PLACEHOLDER,value:i??"",onChange:this.handleValueChange,onKeyPress:this.handleInputKeyPress,style:{width:`${o+3}ch`},spellCheck:"false"})})}),l.jsx("div",{className:"input-filter-menu",children:l.jsx(B,{kind:"ghost",className:"m-2 px-2",onClick:this.handleSettingsClick,icon:l.jsx(Q,{icon:Oo,transform:"grow-4"}),tooltip:"Input Filter Settings"})})]})]})}}const BR=250;class UR extends b.Component{static defaultProps={panelState:null};static COMPONENT="InputFilterPanel";static displayName="InputFilterPanel";constructor(e){super(e),this.handleChange=Ye(this.handleChange.bind(this),BR),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.inputFilterRef=J.createRef();const{panelState:t}=e,{value:n,isValueShown:s=!1,name:i,type:o,timestamp:a}=t??{};this.state={columns:[],column:i!=null&&o!=null?{name:i,type:o}:void 0,value:n,timestamp:a,isValueShown:s,wasFlipped:!1,skipUpdate:!1,panelState:t}}componentDidMount(){this.updateColumns();const{column:e,value:t,timestamp:n}=this.state;if(e!=null){const{name:s,type:i}=e;this.sendUpdate(s,i,t,n)}}componentDidUpdate(e){const{columns:t}=this.props;t!==e.columns&&this.updateColumns()}inputFilterRef;handleChange({column:e,isValueShown:t=!1,value:n}){let s,i;e!=null&&({name:s,type:i}=e);let o=!0,a=Date.now();this.setState(({panelState:r,timestamp:c,wasFlipped:h,skipUpdate:u})=>{const m=r!=null&&t!==r.isValueShown&&s===r.name&&i===r.type&&n===r.value;return o=(!u&&t&&(!m||!h))??!1,o||(a=c),{panelState:{isValueShown:t,name:s,type:i,value:n,timestamp:a},timestamp:a,wasFlipped:m,skipUpdate:!1}},()=>{o&&this.sendUpdate(s,i,n,a)})}handleClearAllFilters(){this.inputFilterRef.current?.clearFilter()}sendUpdate(e,t,n,s){const{glEventHub:i}=this.props;i.emit(Qe.FILTERS_CHANGED,this,{name:e,type:t,value:n,timestamp:s})}setPanelState(e,t=!1){this.setState({skipUpdate:!t}),this.inputFilterRef.current?.setFilterState(e)}updateColumns(){const{columns:e}=this.props;e!=null&&this.setState(t=>{const{column:n}=t;return n==null&&e.length>0?{columns:[...e],column:e[0]}:n!=null&&!e.find(({name:s,type:i})=>n.name===s&&n.type===i)?{columns:[...e,n]}:{columns:[...e]}})}render(){const{glContainer:e,glEventHub:t}=this.props,{column:n,columns:s,isValueShown:i,value:o}=this.state;return l.jsx(os,{className:"iris-input-filter-panel",componentPanel:this,glContainer:e,glEventHub:t,onClearAllFilters:this.handleClearAllFilters,isClonable:!0,isRenamable:!0,children:l.jsx(Za,{ref:this.inputFilterRef,column:n,columns:s,onChange:this.handleChange,isValueShown:i,value:o})})}}const $R=(d,e)=>{const{localDashboardId:t}=e;return{columns:Sm(d,t)}},yo=Ct($R,null,null,{forwardRef:!0})(UR);const vt=Z.module("FilterSetManagerPanel");function WR(d){return d.setPanelState!=null}class Qa extends b.Component{static defaultProps={panelState:null};static COMPONENT="FilterSetManagerPanel";static changeFilterIndexesToColumnNames(e,t){return t.map(([n,s])=>{if(n>=e.columns.length)return null;const{name:i}=e.columns[n];return{name:i,filter:s}}).filter(n=>n!=null)}constructor(e){super(e),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:t,filterSets:n}=e,{selectedId:s=n.length>0?n[0].id:void 0,isValueShown:i=!1}=t??{};this.state={selectedId:s,isValueShown:i,panelState:t}}getFilterState(){const{dashboardOpenedPanelMap:e}=this.props,t=[];return[...e.keys()].forEach(n=>{const s=e.get(n);if(s===void 0){vt.error("Could not get panel",s);return}const i=Y.getComponentNameFromPanel(s),o=Y.getIdFromPanel(s);vt.debug("Panel:",s,i);const{glContainer:a=null}=s.props;if(a==null){vt.error("Could not get panel container",s);return}const r=Y.getComponentConfigFromContainer(a);if(r==null){vt.error("Could not get component config from container",a);return}const c=Y.getPanelComponentState(r);if(c==null){vt.debug(`Panel state is null ${o}`);return}switch(i){case Y.getComponentName(Tl):{let h;o!=null&&(h=this.getIrisGridPanelFilters(o,c)),h!=null&&t.push({panelId:o,type:i,state:h});break}case Y.getComponentName(yo):case Y.getComponentName(ri):{const{isValueShown:h,name:u,type:m,value:g}=c;t.push({panelId:o,type:i,state:{isValueShown:h,name:u,type:m,value:g}});break}}}),t}getIrisGridPanelFilters(e,t){const{panelTableMap:n}=this.props,s=n.get(e);if(s==null)return vt.error(`Unable to get table for panel ${e}.`),null;const{irisGridState:i={advancedFilters:void 0,quickFilters:void 0},gridState:o={}}=t,{advancedFilters:a,quickFilters:r}=i;let c;a&&(c=Qa.changeFilterIndexesToColumnNames(s,a));let h;return r&&(h=Qa.changeFilterIndexesToColumnNames(s,r)),{irisGridState:{...i,advancedFilters:c,quickFilters:h},gridState:{...o}}}handleGetFilterState(){return this.getFilterState()}handleChange({isValueShown:e,selectedId:t}){vt.debug("handleChange",e,t),this.setState({isValueShown:e,selectedId:t}),this.updatePanelState()}handleFilterApply(e){const{dashboardOpenedPanelMap:t}=this.props,{panels:n,restoreFullState:s=!1}=e;vt.debug("Apply filters from filter set",e),n.forEach(({panelId:i,type:o,state:a})=>{if(i==null){vt.debug("panel is null",i);return}if(!t.has(i)){vt.debug("Ignore closed panel",i);return}vt.debug("Apply panel filters",i,o,a);const r=t.get(i);switch(o){case Y.getComponentName(Tl):this.restoreIrisGridFilters(r,a,s);break;case Y.getComponentName(yo):case Y.getComponentName(ri):this.restoreInputFilterState(r,a);break}})}handleSetsUpdate(e){const{setDashboardFilterSets:t,localDashboardId:n}=this.props;vt.debug("Saving updated sets",e),t(n,[...e])}updatePanelState(){this.setState(({selectedId:e,isValueShown:t})=>({panelState:{selectedId:e,isValueShown:t}}))}restoreIrisGridFilters(e,t,n){const{irisGridState:s={},advancedFilters:i=[],quickFilters:o=[]}=t,{advancedFilters:a=i,quickFilters:r=o}=s,{panelTableMap:c}=this.props,h=Y.getIdFromPanel(e);if(h==null){vt.error("Panel Id is null.");return}if(c.get(h)==null){vt.error(`Unable to get table for panel ${h}.`);return}vt.debug("restoreIrisGridFilters",h,t,n),n?e.setStateOverrides(t):e.setFilters({quickFilters:r,advancedFilters:a})}restoreInputFilterState(e,t){const n={...t};delete n.isValueShown,vt.debug("restoreInputFilterState",e,n),e&&WR(e)&&e.setPanelState(n)}render(){const{glContainer:e,glEventHub:t,filterSets:n}=this.props,{isValueShown:s,selectedId:i}=this.state;return l.jsx(os,{className:"filter-set-manager-panel",componentPanel:this,glContainer:e,glEventHub:t,isClonable:!0,isRenamable:!0,children:l.jsx("div",{className:"input-filter-container h-100 w-100 container",children:l.jsx(Xa,{onChange:this.handleChange,onApply:this.handleFilterApply,onUpdateSets:this.handleSetsUpdate,isValueShown:s,filterSets:n,selectedId:i,getFilterState:this.handleGetFilterState})})})}}const GR=(d,e)=>{const{localDashboardId:t}=e;return{filterSets:sR(d,t),dashboardOpenedPanelMap:qu(d,t),dashboardInputFilters:bc(d,t),panelTableMap:wc(d,t)}},Jr=Ct(GR,{setDashboardFilterSets:hR},null,{forwardRef:!0})(Qa);const nh=Z.module("LogPanel");class zR extends b.PureComponent{static defaultProps={session:null};static COMPONENT="LogPanel";static TITLE="Log";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:t}=this.props;this.state={session:t}}isBottomVisible;logView;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){nh.debug("Session opened",[e]),this.setState({session:e})}handleSessionClosed(e){nh.debug("Session closed",e)}updateDimensions(){this.logView&&this.logView.updateDimensions()}render(){const{glContainer:e,glEventHub:t}=this.props,{session:n}=this.state;return l.jsxs(os,{componentPanel:this,glContainer:e,glEventHub:t,onResize:this.handleResize,onHide:this.handleHide,onShow:this.handleShow,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,children:[n==null&&l.jsx("div",{className:"log-panel-disconnected-message",children:"Waiting for session connection"}),n!=null&&l.jsx(bS,{session:n,ref:s=>{this.logView=s}})]})}}const KR=(d,e)=>({session:di(d,e.localDashboardId)?.session}),Ja=Ct(KR,null,null,{forwardRef:!0})(zR);class qR extends b.PureComponent{static defaultProps={isEditing:!1};render(){const{isEditing:e,children:t,onDoubleClick:n}=this.props;return l.jsxs("div",{className:"markdown-editor-container h-100 w-100",onDoubleClick:n,children:[l.jsx("div",{className:$("text-muted","edit-hint",{viewing:e===void 0||!e}),children:l.jsxs("span",{children:["double-click to edit ",l.jsx(Q,{icon:Ao})]})}),t]})}}const YR=Z.module("MarkdownStartPage");class XR extends b.PureComponent{static defaultProps={closedMarkdowns:[],onOpen:()=>{},onCreate:()=>{},onDelete:()=>{}};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(YR.debug("delete markdown: ",e),e!==void 0){const{onDelete:t}=this.props;t(e)}this.setState({isDeleteModalShown:!1,toBeDeleted:void 0})}render(){const{closedMarkdowns:e,onOpen:t,onCreate:n}=this.props,{isDeleteModalShown:s,toBeDeleted:i}=this.state;return l.jsx("div",{className:"markdown-panel-start-page h-100 w-100",children:l.jsxs("div",{className:"markdown-panel-start-page-container",children:[l.jsxs("div",{className:"markdown-panel-start-list",children:[l.jsx("h3",{className:"list-title",children:"Start"}),l.jsx("div",{className:"list-item",children:l.jsx(B,{kind:"ghost",className:"title",onClick:n,children:"New Markdown Note"})})]}),l.jsxs("div",{className:"markdown-panel-start-list",children:[l.jsx("h3",{className:"list-title",children:"Recently Closed from Dashboard"}),e.map(o=>l.jsxs("div",{className:"list-item",children:[l.jsx(B,{kind:"ghost",className:"title",onClick:()=>t(o),children:o.title}),l.jsx("button",{className:"btn-link icon",type:"button",onClick:()=>{this.handleDeleteButtonClick(o)},children:l.jsx(Q,{icon:Jt})})]},o.id)),l.jsxs(zi,{isOpen:s,toggle:this.handleDeleteModalClose,className:"modal-dialog-centered markdown-delete-modal theme-bg-light",children:[l.jsx(Mo,{children:"Are you sure you want to permanently delete this note?"}),l.jsx(Ki,{children:"You can't undo this action."}),l.jsxs(_l,{children:[l.jsx(B,{kind:"secondary",onClick:this.handleDeleteModalClose,children:"Cancel"}),l.jsx(B,{kind:"danger",onClick:()=>{this.handleDeleteMarkdown(i)},children:"Delete"})]})]})]})]})})}}const ZR=d=>{const{children:e,className:t}=d,n=t!==void 0&&t?.startsWith("language-")?t.substring(9):"plaintext";return l.jsx("pre",{children:l.jsx("code",{children:l.jsx(ur,{language:n,children:J.Children.map(e,s=>typeof s=="string"?s.trim():s)})})})};class QR extends b.PureComponent{static defaultProps={isEditing:!1,content:""};constructor(e){super(e),this.container=null}container;render(){const{isEditing:e,content:t,onEditorInitialized:n}=this.props;return l.jsx("div",{className:"markdown-editor-container",ref:s=>{this.container=s},children:e?l.jsx(Kl,{settings:{language:"markdown",value:t,lineNumbers:"off"},onEditorInitialized:n}):l.jsx(yh,{components:{code:ZR},children:t})})}}const ba=Z.module("MarkdownPanel");class JR extends b.Component{static defaultProps={panelState:null};static COMPONENT="MarkdownPanel";constructor(e){super(e),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:t}=e;let n=null;t!=null&&t.content!=null&&({content:n}=t),this.state={isStartPageShown:n==null,isEditing:!1,content:n,panelState:t},this.markdownEditor=null}markdownEditor;editor;setEditorPosition(e){M(this.markdownEditor);const{container:t}=this.markdownEditor;if(this.editor&&t){const n=t.getBoundingClientRect().top,s=t.scrollTop,i=t.scrollHeight,o=this.editor.getModel()?.getLineCount()??0;let a=Math.round((s+e-n)/i*o);a>o&&(a=o),this.editor.revealLine(a),this.editor.setPosition({lineNumber:a,column:1}),this.editor.focus()}}getClosedMarkdowns=fe(e=>e.filter(t=>t.component==="MarkdownPanel").reverse());handleContainerDoubleClick(e){const{isEditing:t}=this.state,n=e.clientY;t||this.setState({isEditing:!0},()=>{this.setEditorPosition(n)})}handleEditorInitialized(e){ba.debug("Markdown Editor Initialized..."),this.editor=e}handleCreateMarkdown(){ba.debug("create markdown..."),this.setState({isStartPageShown:!1,content:"",isEditing:!0,panelState:{content:""}},()=>{this.editor!=null&&this.editor.focus!=null&&this.editor.focus()})}handleOpenMarkdown(e){ba.debug("open markdown...",e);const{glContainer:t,glEventHub:n}=this.props,s=Y.getComponentConfigFromContainer(t);n.emit(Ee.REOPEN,e,s)}handleDeleteMarkdown(e){const{glEventHub:t}=this.props;t.emit(Ee.DELETE,e)}handleEditorBlur(e){ba.debug("markdown content changed, saving...");const{isEditing:t}=this.state;if(!t||this.markdownEditor!=null&&this.markdownEditor.container!=null&&this.markdownEditor.container.contains(e.relatedTarget))return;const n=this.editor?.getValue();this.setState({content:n,isEditing:!1,panelState:{content:n}})}handleEditorResize(){const{isEditing:e}=this.state;e&&this.editor&&this.editor.layout()}render(){const{glContainer:e,glEventHub:t,closedPanels:n}=this.props,{isEditing:s,isStartPageShown:i,content:o}=this.state,a=this.getClosedMarkdowns(n);return l.jsx(os,{glContainer:e,glEventHub:t,className:"markdown-panel",componentPanel:this,onResize:this.handleEditorResize,onBlur:this.handleEditorBlur,isClonable:!0,isRenamable:!0,children:i?l.jsx(XR,{closedMarkdowns:a,onCreate:this.handleCreateMarkdown,onOpen:this.handleOpenMarkdown,onDelete:this.handleDeleteMarkdown}):l.jsx(qR,{isEditing:s,onDoubleClick:this.handleContainerDoubleClick,children:l.jsx(QR,{ref:r=>{this.markdownEditor=r},isEditing:s,content:o??void 0,onEditorInitialized:this.handleEditorInitialized})})})}}const ex=(d,e)=>{const{localDashboardId:t}=e;return{closedPanels:Vw(d,t)}},go=Ct(ex,null,null,{forwardRef:!0})(JR);class tx extends b.PureComponent{static defaultProps={onRunCode:()=>{}};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=J.createRef(),this.state={hasCode:!1,hasRunCode:!1,nextStartLine:null}}componentDidMount(){this.updateHasCode()}componentDidUpdate(){this.updateHasCode()}commands;codeElements;editorScrollView;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 t=[...this.commands.keys()],n=t.findIndex(s=>s===e)+1;return n>=t.length?null:t[n]}handleRunSelected(e){e.preventDefault(),e.stopPropagation();const{nextStartLine:t}=this.state,n=[...this.commands.keys()],s=n.findIndex(h=>h===t||t==null);if(s<0)return;const i=n[s],o=this.commands.get(i),a=this.getNextStartLine(i),c=this.codeElements.get(i)?.current?.parentElement?.nextElementSibling;if(c!=null){const{offsetTop:h}=c,u=h;this.editorScrollView.current?.scroll({top:u,left:0})}this.runCode(o),this.setState({nextStartLine:a})}runCode(e){const{onRunCode:t}=this.props;t(e),this.setState({hasRunCode:!0})}renderCodeBlock(e){const{children:t,className:n,inline:s,node:i}=e,{hasRunCode:o,nextStartLine:a}=this.state,{children:r,position:c}=i;M(c);const{start:h}=c,{line:u}=h,m=r[0].value,g=J.createRef(),p=this.commands.size===0,C=a===u||p&&a==null&&!o,f=n!==void 0&&n.startsWith("language-")?n.substring(9):"plaintext";return s!=null&&s?l.jsx("code",{className:n,children:t}):(this.commands.set(u,m),this.codeElements.set(u,g),l.jsxs("div",{className:$("markdown-notebook-code-block",{"is-selected":C}),ref:g,onClick:()=>{this.setState({nextStartLine:u})},role:"presentation",children:[l.jsx(B,{kind:"ghost",icon:Da,className:"btn-play-block",onClick:S=>{S.stopPropagation(),S.preventDefault(),this.runCode(m),this.setState({nextStartLine:u})},tooltip:"Run code"}),l.jsx("code",{children:l.jsx(ur,{language:f,children:J.Children.map(t,S=>typeof S=="string"?S.trim():S)})})]}))}renderLink(e){const{onLinkClick:t}=this.props,{href:n,children:s,target:i}=e;return l.jsx("a",{href:n,onClick:t,target:i,children:s})}render(){const{content:e,transformImageUri:t,transformLinkUri:n}=this.props,{hasCode:s,hasRunCode:i,nextStartLine:o}=this.state;return l.jsxs("div",{className:"markdown-notebook",children:[l.jsx("div",{className:"markdown-notebook-toolbar",children:l.jsx(B,{className:$("btn-play-selected-cell",{flashing:s&&!i}),kind:"ghost",icon:Da,onClick:this.handleRunSelected,tooltip:"Run code and select next",disabled:i&&o==null||!s,children:"Run Selected Code"})}),l.jsx("div",{className:"markdown-notebook-content",ref:this.editorScrollView,children:l.jsx(yh,{components:{code:this.renderCodeBlock,a:this.renderLink},linkTarget:"_blank",remarkPlugins:[hg],transformLinkUri:n,transformImageUri:t,includeElementIndex:!0,children:e})})]})}}const Pe=Z.module("NotebookPanel"),sh=400;class ni extends b.Component{static COMPONENT="NotebookPanel";static POPPER_OPTIONS={placement:"bottom-end"};static DEFAULT_NAME="Untitled";static handleError(e){ve.isCanceled(e)||Pe.error(e)}static defaultProps={isDashboardActive:!0,isPreview:!1,session:null,sessionLanguage:null,defaultNotebookSettings:null};static languageFromFileName(e){switch(he.getExtension(e).toLowerCase()){case"py":case"python":return"python";case"groovy":return"groovy";case"scala":return"scala";default:return null}}constructor(e){super(e),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.handleTabClick=this.handleTabClick.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.handlePreviewPromotion=this.handlePreviewPromotion.bind(this),this.getDropdownOverflowActions=this.getDropdownOverflowActions.bind(this),this.pending=new is,this.debouncedSavePanelState=Ye(this.savePanelState.bind(this),sh),this.debouncedLoad=Ye(this.load.bind(this),sh),this.notebook=null,this.tabTitleElement=null,this.tabInitOnce=!1;const{isDashboardActive:t,session:n,sessionLanguage:s,panelState:i}=e;let o={value:"",language:"",wordWrap:"off"},a=null,{isPreview:r}=e;i!=null&&({fileMetadata:a=a,isPreview:r=r,settings:o=o}=i);const c=a!=null&&he.hasPath(a.itemName),u=c===!0&&o.value!=null||!c&&o.value!=null&&o.value.length>0?1:0;this.state={error:void 0,isDashboardActive:t,isFocused:!1,isLoading:!0,isLoaded:!1,isPreview:r,savedChangeCount:0,changeCount:u,fileMetadata:a,settings:o,session:n,sessionLanguage:s,panelState:{fileMetadata:a,settings:o},showCloseModal:!1,showSaveAsModal:!1,scriptCode:""},Pe.debug("constructor",e,this.state)}componentDidMount(){const{glContainer:e,glEventHub:t}=this.props,{tab:n}=e;n!=null&&this.initTab(n),this.initNotebookContent(),t.on($e.RENAME_FILE,this.handleRenameFile),e.on($e.PROMOTE_FROM_PREVIEW,this.handlePreviewPromotion)}componentDidUpdate(e,t){const{isPreview:n,settings:s}=this.state,{wordWrap:i}=s,{defaultNotebookSettings:o}=this.props;n!==t.isPreview&&this.setPreviewStatus(),i!==t.settings.wordWrap&&(this.updateEditorWordWrap(),this.debouncedSavePanelState()),o.isMinimapEnabled!==e.defaultNotebookSettings.isMinimapEnabled&&this.updateEditorMinimap()}componentWillUnmount(){this.debouncedSavePanelState.flush(),this.pending.cancel();const{glEventHub:e,glContainer:t}=this.props,{fileMetadata:n,isPreview:s}=this.state;e.off($e.RENAME_FILE,this.handleRenameFile),t.off($e.PROMOTE_FROM_PREVIEW,this.handlePreviewPromotion),e.emit($e.UNREGISTER_FILE,n,s)}pending;debouncedSavePanelState;debouncedLoad;notebook;tabTitleElement;tabInitOnce;editor;initTab(e){this.tabInitOnce||(this.tabInitOnce=!0,this.initTabCloseOverride()),this.initTabClasses(e)}initTabCloseOverride(){const{glContainer:e}=this.props;e.beforeClose(t=>{if(t?.force===!0)return!0;const{changeCount:n,savedChangeCount:s}=this.state;return n!==s?(this.setState({showCloseModal:!0}),!1):!0})}initTabClasses(e){const t=e.element.get(0);M(t);const n=t.querySelector(".lm_title");this.tabTitleElement=n,n?.classList.add("notebook-title"),this.setPreviewStatus()}getNotebookValue(){const{changeCount:e,savedChangeCount:t,settings:n}=this.state,{value:s}=n;if(e!==t&&this.notebook){const i=this.notebook.getValue();return i??s}return s}initNotebookContent(){const{fileMetadata:e,settings:t,isPreview:n}=this.state;if(e&&e.id){Pe.debug("Init content from file"),this.registerFileMetadata(e,n),this.load();return}if(t.value!=null){Pe.debug("Use content passed in the settings prop"),this.handleLoadSuccess();return}this.handleLoadError(new Error("Missing file metadata"))}closeFileTabById(e){const{glEventHub:t}=this.props;t.emit($e.CLOSE_FILE,{id:e})}registerFileMetadata(e,t){const{glEventHub:n,metadata:s}=this.props,{id:i}=s;n.emit($e.REGISTER_FILE,i,e,t)}renameTab(e,t){const{glEventHub:n}=this.props;n.emit($e.RENAME,e,t)}load(){const{fileMetadata:e,settings:t}=this.state;M(e);const{id:n}=e,{fileStorage:s}=this.props;this.pending.add(s.loadFile(n)).then(i=>{Pe.debug("Loaded file",i);const{filename:o}=i,{itemName:a}=this.state;if(o!==a){const{metadata:c}=this.props,{id:h}=c;this.renameTab(h,he.getBaseName(o))}const r={...t,language:ni.languageFromFileName(o)??""};t.value==null&&(r.value=i.content),t.wordWrap===void 0&&(t.wordWrap="off"),this.setState({fileMetadata:{id:o,itemName:o},settings:r}),this.debouncedSavePanelState()}).then(this.handleLoadSuccess).catch(this.handleLoadError)}save(){const{fileMetadata:e}=this.state;if(e&&he.hasPath(e.itemName)){const t=this.getNotebookValue();return t!==void 0?(this.saveContent(e.itemName,t),!0):!1}return this.setState({showSaveAsModal:!0}),!1}saveContent(e,t){Pe.debug("saveContent",e,t),this.updateSavedChangeCount();const{fileStorage:n}=this.props;this.pending.add(n.saveFile({filename:e,content:t,basename:e})).then(this.handleSaveSuccess).catch(this.handleSaveError)}updateSavedChangeCount(){this.setState(({changeCount:e})=>({savedChangeCount:e}))}setPreviewStatus(){if(!this.tabTitleElement)return;const{isPreview:e}=this.state;Pe.debug("setPreviewStatus",this.tabTitleElement,e),e?this.tabTitleElement.classList.add("is-preview"):this.tabTitleElement.classList.remove("is-preview")}handlePreviewPromotion(){this.removePreviewStatus()}getSettings=fe((e,t)=>({...e,minimap:{enabled:t}}));getOverflowActions=fe((e,t)=>[{title:"Find",icon:Tp,action:this.handleFind,group:ie.groups.high,shortcut:Mt.NOTEBOOK.FIND,order:10},{title:"Show Minimap",icon:e?Jn:void 0,action:this.handleMinimapChange,group:ie.groups.medium,shortcut:Mt.NOTEBOOK.MINIMAP,order:20},{title:"Word Wrap",icon:t?Jn:void 0,action:this.handleWordWrapChange,group:ie.groups.medium,shortcut:Mt.NOTEBOOK.WORDWRAP,order:30}]);savePanelState(){this.setState(e=>{const{changeCount:t,savedChangeCount:n,fileMetadata:s,isPreview:i,settings:o}=e,a=this.getNotebookValue(),r=t!==n?a:void 0,c={...o,value:a},u={settings:{...o,value:r},fileMetadata:s,isPreview:i};return Pe.debug("Saving panel state",u),{settings:c,panelState:u}})}handleCloseDiscard(){this.setState({showCloseModal:!1});const{glContainer:e}=this.props;e.close({force:!0})}handleCloseSave(){if(this.setState({showCloseModal:!1}),this.save()){const{glContainer:e}=this.props;e.close({force:!0})}}handleCloseCancel(){this.setState({showCloseModal:!1})}handleOverwrite(e){const{glEventHub:t}=this.props;t.emit($e.CLOSE_FILE,{id:e,itemName:e},{force:!0}),this.focus()}handleCopy(){const{fileMetadata:e,settings:t}=this.state;M(e);const n=this.getNotebookValue(),{language:s}=t,{itemName:i}=e,o=he.getCopyFileName(i);Pe.debug("handleCopy",e,i,o),this.createNotebook(o,s,n)}handleEditorInitialized(e){this.editor=e}handleEditorWillDestroy(){this.editor=void 0}handleEditorChange(e){Pe.debug2("handleEditorChanged",e),this.removePreviewStatus(),this.setState(t=>{const{changeCount:n,savedChangeCount:s}=t,{isUndoing:i,isRedoing:o}=e;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:e}=this.props;this.editor.updateOptions({minimap:{enabled:e.isMinimapEnabled}})}}handleMinimapChange(){const{settings:e,defaultNotebookSettings:t,saveSettings:n}=this.props,s={...e,defaultNotebookSettings:{isMinimapEnabled:!t.isMinimapEnabled}};n(s)}updateEditorWordWrap(){if(this.editor){const{settings:e}=this.state,{wordWrap:t}=e;this.editor.updateOptions({wordWrap:t})}}handleWordWrapChange(){this.editor&&this.setState(e=>{const{settings:t}=e,n=t.wordWrap==="on"?"off":"on";return{settings:{...t,wordWrap:n}}})}handleBlur(){Pe.debug("handleBlur"),this.setState({isFocused:!1})}handleFocus(){Pe.debug("handleFocus"),this.setState({isFocused:!0})}handleLinkClick(e){const{notebooksUrl:t,session:n,sessionLanguage:s}=this.props,{href:i}=e.currentTarget;if(!i||!i.startsWith(t))return;e.stopPropagation(),e.preventDefault();const o=`/${i.substring(t.length)}`.replace(/%20/g," ");if(o==="/"){Pe.debug("Ignoring invalid notebook link",o);return}Pe.debug("Notebook link clicked, opening",o);const{glEventHub:a}=this.props,r={value:null,language:s},c={id:o,itemName:o};a.emit($e.SELECT_NOTEBOOK,n,s,r,c)}handleLoadSuccess(){this.setState({error:void 0,isLoaded:!0,isLoading:!1})}handleLoadError(e){let t=e;ve.isCanceled(t)||(ve.isTimedOut(t)&&(t=new Error("File not found.")),Pe.error(t),this.setState({error:t,isLoading:!1}))}handleSave(){Pe.debug("handleSave"),this.save()}handleSaveSuccess(e){const{fileStorage:t}=this.props,n={id:e.filename,itemName:e.filename},s=ni.languageFromFileName(e.filename)??"";this.setState(i=>{const{fileMetadata:o}=i,a={...i.settings,language:s};return Pe.debug("handleSaveSuccess",n,o,a),o&&he.hasPath(o.itemName)&&o.itemName!==n.itemName&&(Pe.debug("handleSaveSuccess deleting old file",o.itemName),t.deleteFile(o.itemName).catch(ni.handleError)),{fileMetadata:n,settings:a,isPreview:!1}}),this.debouncedSavePanelState(),this.registerFileMetadata(n,!1)}handleSaveError(e){ve.isCanceled(e)||(this.setState({savedChangeCount:0}),Pe.error(e))}handleSaveAsCancel(){this.setState({showSaveAsModal:!1})}handleSaveAsSubmit(e,t=!1){t&&this.handleOverwrite(e),Pe.debug("handleSaveAsSubmit",e);const{fileMetadata:n}=this.state;if(!n)return;const{itemName:s}=n,i=this.getNotebookValue()??"";if(this.setState({showSaveAsModal:!1}),he.getBaseName(s)!==he.getBaseName(e)){const{metadata:o}=this.props,{id:a}=o;this.renameTab(a,he.getBaseName(e))}this.saveContent(e,i)}handleRenameFile(e,t,n){const{fileMetadata:s,panelState:i}=this.state,{glContainer:o}=this.props;if(s?.itemName===`/${t}`&&n&&JSON.stringify(i)!==JSON.stringify(n)){o.close();return}s&&s.id===e&&(this.setState({fileMetadata:{id:t,itemName:t}}),this.debouncedSavePanelState())}handleResize(){this.notebook?.updateDimensions()}handleRunCommand(e){this.runCommand(e)}handleRunAll(){if(!this.notebook){Pe.error("Editor is not initialized.");return}this.runCommand(this.notebook.getValue()??void 0)}handleRunSelected(){if(!this.notebook){Pe.error("Editor is not initialized.");return}this.runCommand(this.notebook.getSelectedCommand())}handleSessionOpened(e,{language:t}){this.setState({session:e,sessionLanguage:t})}handleSessionClosed(){this.setState({session:void 0,sessionLanguage:void 0})}handleShow(){Pe.debug("handleShow"),this.notebook?.updateDimensions()}handleShowRename(){this.setState({showSaveAsModal:!0})}handleTab(e){Pe.debug("NotebookPanel tab event",e),this.initTab(e)}handleTabFocus(...e){Pe.debug("handleTabFocus",...e);const{glContainer:t}=this.props;this.setState({isDashboardActive:!0}),this.notebook&&!t.isHidden&&this.notebook.updateDimensions()}handleTabBlur(){Pe.debug("handleTabBlur"),this.setState({isDashboardActive:!1})}handleTabClick(e){Pe.debug("handle NotebookPanel tab click"),this.focus(),e.detail===2&&this.removePreviewStatus()}handleTransformLinkUri(e){const{notebooksUrl:t}=this.props,{fileMetadata:n}=this.state;if(e.endsWith("/"))return e;if(e.startsWith("/"))return`${t}${e.substring(1)}`;let s=n?.itemName;if(s===void 0)return e;s.charAt(0)==="/"&&(s=s.substring(1));const i=new URL(s,t);return new URL(e,i).href}focus(){requestAnimationFrame(()=>{this.notebook&&this.notebook.focus()})}createNotebook(e,t,n=""){const{glEventHub:s}=this.props,{session:i,sessionLanguage:o,settings:a}=this.state,r={...a,language:t,value:n},c={id:null,itemName:e};Pe.debug("handleCreateNotebook",i,o,r,c),s.emit($e.CREATE_NOTEBOOK,i,o,r,c)}runCommand(e){if(e===void 0||e===""){Pe.debug("Ignoring empty command.");return}this.removePreviewStatus();const{glEventHub:t}=this.props;t.emit(Xt.SEND_COMMAND,e,!1,!0)}removePreviewStatus(){this.setState(({isPreview:e})=>{if(e){const{fileMetadata:t}=this.state;return t&&this.registerFileMetadata(t,!1),{isPreview:!1}}return null})}getDropdownOverflowActions(){const{defaultNotebookSettings:e}=this.props,{settings:t}=this.state;return this.getOverflowActions(e.isMinimapEnabled,this.getSettings(t,e.isMinimapEnabled).wordWrap==="on")}render(){const{fileStorage:e,glContainer:t,glContainer:{tab:n},glEventHub:s,defaultNotebookSettings:i}=this.props,{changeCount:o,savedChangeCount:a,error:r,isDashboardActive:c,isLoaded:h,isLoading:u,isPreview:m,fileMetadata:g,session:p,sessionLanguage:C,settings:f,showCloseModal:S,showSaveAsModal:v}=this.state,w=c&&!t.isHidden&&!m,T=g?.itemName??ni.DEFAULT_NAME,y=T.endsWith(".md"),E=g?.id!=null,D=this.getSettings(f,i.isMinimapEnabled),F=p!=null,N=C===D.language,_=!h||!F||!N,P=!h,U=[{action:this.handleSave,shortcut:ss.SAVE},{action:this.handleMinimapChange,shortcut:Mt.NOTEBOOK.MINIMAP},{action:this.handleWordWrapChange,shortcut:Mt.NOTEBOOK.WORDWRAP}],O=pd.getDisabledRunTooltip(F,N,"Notebook extension","Run"),j=pd.getDisabledRunTooltip(F,N,"Notebook extension","Run Selected"),k=[{title:E?"Rename":"Save As…",order:10,group:ie.groups.high,action:this.handleShowRename},{title:"Copy File",action:this.handleCopy,group:ie.groups.high,order:20}],A=n?.element.find(".lm_title_before").get(0);return l.jsxs(l.Fragment,{children:[A&&Bi.createPortal(l.jsx("span",{className:$("editor-unsaved-indicator",{"is-unsaved":o!==a})}),A),l.jsxs(os,{className:"notebook-container",componentPanel:this,glContainer:t,glEventHub:s,onTab:this.handleTab,onResize:this.handleResize,onShow:this.handleShow,onTabClicked:this.handleTabClick,onTabFocus:this.handleTabFocus,onTabBlur:this.handleTabBlur,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onFocus:this.handleFocus,onBlur:this.handleBlur,additionalActions:k,renderTabTooltip:()=>T,children:[!y&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"notebook-toolbar",children:[l.jsxs("span",{children:[l.jsx(B,{kind:"ghost",className:"btn-play",onClick:this.handleRunAll,disabled:_,icon:l.jsx(Q,{icon:Da,transform:"grow-4"}),tooltip:`Run ${Mt.NOTEBOOK.RUN.getDisplayText()}`,"aria-label":"Run"}),O!=null&&l.jsx(tt,{children:O})]}),l.jsxs("span",{children:[l.jsx(B,{kind:"ghost",className:"btn-play",onClick:this.handleRunSelected,disabled:_,icon:l.jsx(Q,{icon:vp,transform:"grow-4"}),tooltip:`Run Selected ${Mt.NOTEBOOK.RUN_SELECTED.getDisplayText()}`,"aria-label":"Run Selected"}),j!=null&&l.jsx(tt,{children:j})]}),l.jsx(B,{kind:"ghost",className:"mr-auto",disabled:P,onClick:this.handleSave,icon:_h,tooltip:`Save ${ss.SAVE.getDisplayText()}`,"aria-label":"Save"}),l.jsx(B,{kind:"ghost",className:"btn-overflow btn-link-icon",disabled:P,icon:Mh,tooltip:"More Actions...",onClick:()=>{},children:l.jsx(es,{actions:this.getDropdownOverflowActions,popperOptions:ni.POPPER_OPTIONS})})]}),l.jsx(oS,{isLoaded:h,isLoading:u,error:r,onChange:this.handleEditorChange,onRunCommand:this.handleRunCommand,session:p,sessionLanguage:C,onEditorInitialized:this.handleEditorInitialized,onEditorWillDestroy:this.handleEditorWillDestroy,settings:D,focusOnMount:w,ref:H=>{this.notebook=H}})]}),y&&l.jsx(tx,{content:D.value??"",onLinkClick:this.handleLinkClick,onRunCode:this.handleRunCommand,transformImageUri:this.handleTransformLinkUri,transformLinkUri:this.handleTransformLinkUri}),l.jsx(Hi,{isOpen:v,type:"file",defaultValue:T,title:E?"Rename":"Save file as",onSubmit:this.handleSaveAsSubmit,onCancel:this.handleSaveAsCancel,notifyOnExtensionChange:!0,storage:e}),l.jsx(ci,{isOpen:S,headerText:`Do you want to save the changes you made to ${T}?`,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"}),l.jsx(ie,{actions:U})]})]})}}const nx=(d,e)=>{const t=cu(d),n=St(d),s=qS(d),i=di(d,e.localDashboardId),{session:o,config:a}=i??{},{type:r}=a??{};return{fileStorage:t,settings:n,defaultNotebookSettings:s,session:o,sessionLanguage:r}},bs=Ct(nx,{saveSettings:pr},null,{forwardRef:!0})(ni);class el extends b.Component{static defaultProps={panelState:null};static COMPONENT="PandasPanel";constructor(e){super(e),this.irisGridRef=J.createRef(),this.buttonRef=J.createRef(),this.handleReload=this.handleReload.bind(this),this.handleGridStateChange=this.handleGridStateChange.bind(this),this.handlePanelStateUpdate=this.handlePanelStateUpdate.bind(this);const{panelState:t}=e;this.state={shouldFocusGrid:!1,panelState:t}}buttonRef;irisGridRef;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 l.jsx(li,{ref:this.irisGridRef,onStateChange:this.handleGridStateChange,onPanelStateUpdate:this.handlePanelStateUpdate,...e,children:l.jsxs(B,{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",l.jsxs("span",{children:[l.jsx(Q,{icon:Ol,transform:"shrink-1",className:"mr-1"}),"Reload"]})]})})}}function sx(d){Hs(d);const{id:e,layout:t,registerComponent:n,hydrate:s}=d,i=b.useCallback(({dragEvent:o,fetch:a,panelId:r=_e.generate(),widget:c})=>{const{name:h,type:u}=c;if(u!==dh.VariableType.FIGURE)return;const m={name:h,figure:h},g=()=>a().then(f=>ja.makeModel(void 0,f)),p={type:"react-component",component:_i.COMPONENT,props:{localDashboardId:e,id:r,metadata:m,makeModel:g},title:h,id:r},{root:C}=t;Y.openComponent({root:C,config:p,dragEvent:o})},[e,t]);return b.useEffect(function(){const a=[n(_i.COMPONENT,_i,s)];return()=>{a.forEach(r=>r())}},[s,n]),We(t.eventHub,Ee.OPEN,i),null}function ix(d){Hs(d);const{id:e,layout:t}=d,n=b.useCallback(({metadata:s,panelId:i=_e.generate(),table:o})=>{const{settings:a}=s,r=()=>ja.makeModelFromSettings(a,o),c=Je.titleFromSettings(a),h={type:"react-component",component:_i.COMPONENT,props:{localDashboardId:e,id:i,metadata:s,makeModel:r},title:c,id:i},{root:u}=t;Y.openComponent({root:u,config:h})},[e,t]);return We(t.eventHub,bn.CREATE_CHART,n),null}const lt=Z.module("ConsolePlugin");function ih(d){return d.notebook!==void 0}function ox(d){Hs(d)}function ax(d){ox(d);const{id:e,hydrateConsole:t,layout:n,panelManager:s,registerComponent:i,notebooksUrl:o}=d,a=b.useRef(0),[r,c]=b.useState(new Map),[h,u]=b.useState(new Map),m=Dl(),g=b.useCallback(()=>s.getLastUsedPanelOfType(Mi),[s]),p=b.useCallback((W,G)=>{c(ne=>new Map(ne.set(W,G)))},[c]),C=b.useCallback(W=>{c(G=>(G.delete(W),new Map(G)))},[c]),f=b.useCallback((W,G)=>{u(ne=>new Map(ne.set(W,G)))},[u]),S=b.useCallback(W=>{u(G=>(G.delete(W),new Map(G)))},[u]),v=b.useCallback((W,G=!0,ne=!0)=>{if(!(W&&W.trim()))lt.info("Ignoring empty code");else{const ce=g();if(!ce||!(ce instanceof Mi.WrappedComponent)){lt.error("Console panel not found");return}lt.debug("Send command: ",W,G,ne),ce.addCommand(W,G,ne)}},[g]),w=b.useCallback(W=>{m(dR(e,W))},[m,e]),T=b.useCallback(({language:W})=>{const G=W==="python"?"py":W;let ne=null;return G==null?(lt.debug("No extension for language",W),ne=`Untitled-${a.current}`):ne=`Untitled-${a.current}.${G}`,a.current+=1,ne},[]),y=b.useCallback((W,G=!0)=>{const{id:ne}=W;if(ne!=null&&r.has(ne))return r.get(ne);if(ne!=null&&h.has(ne))return h.get(ne);if(G)return _e.generate()},[r,h]),E=b.useCallback((W,G)=>{Y.renameComponent(n.root,{id:W},G)},[n.root]),D=b.useCallback((W,G)=>{lt.debug("Rename file panel",W,G);let ne;if(r.has(W)&&(ne=r.get(W),C(W),ne!=null&&p(G,ne)),h.has(W)&&(ne=h.get(W),S(W),ne!=null&&f(G,ne)),ne===void 0){lt.debug2(`File ${W} isn't open, no need to rename the tab`);return}E(ne,he.getBaseName(G))},[r,h,E,p,f,C,S]),F=b.useCallback(W=>{const G=y(W,!1);if(G==null){lt.error("Could not find panel id for file metadata",W);return}Y.activateTab(n.root,{id:G})},[y,n.root]),N=b.useCallback((W,G,ne)=>{if(lt.debug("registerFilePanel",W,G,ne),G==null||G.id==null){lt.debug("Ignore empty file id",G);return}const{id:ae}=G;if(ne){f(ae,W);return}if(r.has(ae)){const ce=r.get(ae);if(W===ce){lt.debug(`Update tab title for file ${ae}`);const{itemName:te}=G;D(ae,te)}else lt.error(`File ${ae} already associated with a different tab ${ce}`);return}p(ae,W),h.has(ae)&&S(ae)},[r,h,D,p,f,S]),_=b.useCallback((W,G)=>{if(lt.debug("unregisterFileTab",W,G),W==null||W.id==null){lt.debug("Ignore empty file id",W);return}const{id:ne}=W;if(G){S(ne);return}C(ne)},[C,S]),P=b.useCallback((W,G)=>{lt.debug("closeFilePanel",W);const{id:ne}=W;let ae=null,ce=!1;if(r.has(ne))ae=r.get(ne);else if(h.has(ne))ae=h.get(ne),ce=!0;else{lt.debug(`File ${ne} isn't open, ignore close event`);return}_(W,ce),Y.closeComponent(n.root,{id:ae},G)},[n.root,r,h,_]),U=b.useCallback(W=>{const{itemName:G}=W;return he.getBaseName(G)},[]),O=b.useCallback(W=>{const{id:G}=W;return lt.debug("fileIsOpen",W,G,r),G!=null&&r.has(G)},[r]),j=b.useCallback(W=>{const{id:G}=W;return lt.debug("fileIsOpenAsPreview",W,G,h),G!=null&&h.has(G)},[h]),k=b.useCallback(W=>{if(W==null)return;const G=s.getOpenedPanelById(W);G&&ih(G)&&G.focus()},[s]),A=b.useCallback(({id:W,settings:G,fileMetadata:ne,session:ae,sessionLanguage:ce,isPreview:te=!1})=>{const re={settings:G,fileMetadata:ne},we=U(ne);return{type:"react-component",component:bs.COMPONENT,isFocusOnShow:!1,props:{localDashboardId:e,metadata:{id:W},session:ae,sessionLanguage:ce,panelState:re,isPreview:te,notebooksUrl:o},title:we,id:W}},[U,e,o]),H=b.useCallback((W,G,ne,ae={id:null,itemName:T(ne)})=>{const ce=y(ae);if(O(ae)&&ce!=null){lt.debug("File is already open, focus panel"),F(ae),k(ce);return}const te=Y.getStackForComponentTypes(n.root,[bs.COMPONENT]),re=A({id:ce,settings:ne,fileMetadata:ae,session:W,sessionLanguage:G});lt.debug("createNotebook",re,r),Y.openComponentInStack(te,re)},[O,k,T,y,n.root,A,r,F]),K=b.useCallback((W,G,ne,ae,ce=!1)=>{lt.debug("selectNotebook",ae,ce);const te=O(ae),re=j(ae),[we]=[...h.values()],Ie=!ce,xe=Ie&&we?we:y(ae);if(xe==null||xe==="")throw new Error("Unable to retrieve or create panelId for metadata",ae);if(te||re)F(ae);else{const at=Y.getStackForComponentTypes(n.root,[bs.COMPONENT]),xt=A({id:xe,settings:ne,fileMetadata:ae,session:W,sessionLanguage:G,isPreview:Ie});Y.openComponentInStack(at,xt)}if(re&&ce){const at=ae.id,xt=Y.getStackForConfig(n.root,{component:bs.COMPONENT,id:xe}),en=Y.getContentItemInStack(xt,{component:bs.COMPONENT,id:xe});en&&_t(en)&&(en.container.emit($e.PROMOTE_FROM_PREVIEW),S(at),p(at,xe))}ce&&k(xe)},[F,O,j,k,y,n.root,A,h,S,p]),q=b.useCallback((W,G,ne={},ae=!0)=>{const ce=s.getLastUsedPanelOfType(bs);ce&&ih(ce)?ne!=null&&ne.value!=null&&ce.notebook!=null&&ce.notebook.append(ne.value):ae&&H(W,G,ne)},[H,s]),oe=b.useCallback((W,G)=>Sl.hydrate({...W,notebooksUrl:o},G),[o]);return b.useEffect(function(){const G=[i(Mi.COMPONENT,Mi,t),i(Ka.COMPONENT,Ka),i(Ya.COMPONENT,Ya),i(Ja.COMPONENT,Ja),i(bs.COMPONENT,bs,oe)];return()=>{G.forEach(ne=>ne())}},[i,t,oe]),We(n.eventHub,Xt.SEND_COMMAND,v),We(n.eventHub,Xt.SETTINGS_CHANGED,w),We(n.eventHub,$e.CLOSE_FILE,P),We(n.eventHub,$e.CREATE_NOTEBOOK,H),We(n.eventHub,$e.SELECT_NOTEBOOK,K),We(n.eventHub,$e.RENAME,E),We(n.eventHub,$e.RENAME_FILE,D),We(n.eventHub,$e.SEND_TO_NOTEBOOK,q),We(n.eventHub,$e.REGISTER_FILE,N),We(n.eventHub,$e.UNREGISTER_FILE,_),null}const po=Z.module("FilterPlugin");function oh(d,e){return d.concat(e)}function rx(d){Hs(d);const{id:e,layout:t,registerComponent:n}=d,s=Dl(),[i]=b.useState(()=>new Map),[o]=b.useState(()=>new Map),[a]=b.useState(()=>new Map),r=b.useCallback(()=>{const f=Array.from(i.values()).reduce(oh,[]).sort((w,T)=>{const y=zt.toLower(w.name),E=zt.toLower(T.name);if(y!==E)return y>E?1:-1;const D=zt.toLower(w.type),F=zt.toLower(T.type);return D!==F?D>F?1:-1:0}).reduce((w,T)=>((w.length===0||zt.toLower(w[w.length-1].name)!==zt.toLower(T.name)||zt.toLower(w[w.length-1].type)!==zt.toLower(T.type))&&w.push(T),w),[]),S=Array.from(o.values()).reduce(oh,[]).sort((w,T)=>w.timestamp-T.timestamp),v=new Map(a);po.debug("sendUpdate",{columns:f,filters:S,tableMap:v}),s(Hn(e,{columns:f,filters:S,tableMap:v}))},[s,e,i,o,a]),c=b.useCallback((f,S)=>{po.debug2("handleColumnsChanged",f,S),i.set(f,[].concat(S)),r()},[i,r]),h=b.useCallback((f,S)=>{po.debug2("handleFiltersChanged",f,S),o.set(f,[].concat(S)),r()},[o,r]),u=b.useCallback((f,S)=>{po.debug2("handleTableChanged",f,S),a.set(Y.getIdFromPanel(f),S),r()},[a,r]),m=b.useCallback(f=>{po.debug2("handlePanelUnmount",f),i.delete(f),o.delete(f),a.delete(Y.getIdFromPanel(f)),r()},[i,o,a,r]),g=b.useCallback(({title:f="DropdownFilter",metadata:S={},panelState:v=null,id:w=_e.generate(),focusElement:T=Y.DEFAULT_FOCUS_SELECTOR,createNewStack:y=!1,dragEvent:E=null})=>{const D={type:"react-component",component:ri.COMPONENT,props:{id:w,metadata:S,panelState:v,localDashboardId:e},title:f,id:w},{root:F}=t;Y.openComponent({root:F,config:D,focusElement:T,createNewStack:y,dragEvent:E})},[t,e]),p=b.useCallback(({title:f="InputFilter",metadata:S={},panelState:v=null,id:w=_e.generate(),focusElement:T=Y.DEFAULT_FOCUS_SELECTOR,createNewStack:y=!1,dragEvent:E=null})=>{const D={type:"react-component",component:yo.COMPONENT,props:{id:w,metadata:S,panelState:v,localDashboardId:e},title:f,id:w},{root:F}=t;Y.openComponent({root:F,config:D,focusElement:T,createNewStack:y,dragEvent:E})},[t,e]),C=b.useCallback(({title:f="FilterSets",metadata:S={},panelState:v=null,id:w=_e.generate(),focusElement:T=Y.DEFAULT_FOCUS_SELECTOR,createNewStack:y=!1,dragEvent:E=null})=>{const D={type:"react-component",component:Jr.COMPONENT,props:{id:w,metadata:S,panelState:v,localDashboardId:e},title:f,id:w},{root:F}=t;Y.openComponent({root:F,config:D,focusElement:T,createNewStack:y,dragEvent:E})},[t,e]);return b.useEffect(function(){const S=[n(ri.COMPONENT,ri),n(yo.COMPONENT,yo),n(Jr.COMPONENT,Jr)];return()=>{S.forEach(v=>v())}},[n]),We(t.eventHub,Qe.COLUMNS_CHANGED,c),We(t.eventHub,Qe.FILTERS_CHANGED,h),We(t.eventHub,Qe.TABLE_CHANGED,u),We(t.eventHub,Qe.OPEN_DROPDOWN,g),We(t.eventHub,Qe.OPEN_INPUT,p),We(t.eventHub,Qe.OPEN_FILTER_SET_MANAGER,C),We(t.eventHub,Ee.UNMOUNT,m),null}const lx=[dh.VariableType.TABLE,dh.VariableType.TREETABLE,dh.VariableType.HIERARCHICALTABLE];function cx(d){Hs(d);const{getDownloadWorker:e,loadPlugin:t,id:n,layout:s,registerComponent:i,hydrate:o,theme:a}=d,r=b.useCallback(({dragEvent:c,fetch:h,panelId:u=_e.generate(),widget:m})=>{const{name:g,type:p}=m;if(!lx.includes(p))return;const C={name:g,table:g,type:m.type},f=()=>h().then(w=>Cc.makeModel(w)),S={type:"react-component",component:li.COMPONENT,props:{getDownloadWorker:e,loadPlugin:t,localDashboardId:n,id:u,metadata:C,makeModel:f,theme:a},title:g,id:u},{root:v}=s;Y.openComponent({root:v,config:S,dragEvent:c})},[e,n,s,t,a]);return b.useEffect(function(){const h=[i(li.COMPONENT,li,o)];return()=>{h.forEach(u=>u())}},[o,i]),We(s.eventHub,Ee.OPEN,r),null}function Em(d){return typeof d.getCoordinateForColumn=="function"}function ah(d){const e=d;return Em(d)&&typeof e.setFilterMap=="function"&&typeof e.unsetFilterValue=="function"}function rh(d){return d.description===void 0||!d.description?.startsWith("Preview of type: ")}const fo=Z.module("LinkerUtils");class Is{static ALLOWED_LINKS=new Map([[Y.getComponentName(li),[Y.getComponentName(li),Y.getComponentName(_i),Y.getComponentName(ri)]]]);static getLinkType(e,t,n){if(e?.panelId==null||t?.panelId==null||e.panelId===t.panelId||n!=null&&n!==e.panelId&&n!==t.panelId)return fo.debug2("Incompatible panel ids",e,t,n),"invalid";if(e.panelComponent==null||t.panelComponent==null)return fo.error("PanelComponent should not be null",e,t),"invalid";const s=Is.ALLOWED_LINKS.get(e.panelComponent)?.includes(t.panelComponent);if(s===void 0||!s)return fo.debug2("Incompatible panel components",e,t),"invalid";const{columnType:i}=e,{columnType:o}=t;if(!(o===null||x.isCompatibleType(i,o)))return fo.debug2("Incompatible type",i,o),"invalid";switch(t.panelComponent){case Y.getComponentName(_i):case Y.getComponentName(li):return"tableLink";case Y.getComponentName(ri):return"filterSource"}return fo.debug2("Incompatible target panel component",t.panelComponent),"invalid"}static findColumn(e,{columnName:t,columnType:n}){return e.find(({name:s,type:i})=>s===t&&i===n)}static cloneLinksForPanel(e,t,n){const s=[];return e.forEach(i=>{i.start.panelId===t&&i.type!=="filterSource"?s.push({...i,id:_e.generate(),start:{...i.start,panelId:n}}):i.end?.panelId===t&&s.push({...i,id:_e.generate(),end:{...i.end,panelId:n}})}),s}}const dx=Z.module("LinkerLink"),lh=.015,ch=1.5,ym=12,Rm=12,hh=2,wa=Math.sqrt((Rm*.5)**2+ym**2),uh=Math.asin(Rm*.5/ym),mh=15,ws=Math.PI*.5;class Ro extends b.Component{static defaultProps={className:"",isSelected:!1,onClick(){},onDelete(){}};static makeCirclePath(e,t,n){return`M ${e} ${t} m -${n},0 a ${n},${n} 0 1,0 ${n*2},0 a ${n},${n} 0 1,0 -${n*2},0 z`}static getLabelForLinkFilter(e,t){try{if(x.isNumberType(e)||x.isCharType(e))return iu(t);if(x.isTextType(e))return su(t);if(x.isDateType(e))return ou(t);if(x.isBooleanType(e)){if(t===X.eq)return"is equal to";if(t===X.notEq)return"is not equal to"}throw new Error(`Unrecognized column type: ${e}`)}catch(n){return dx.warn(n),""}}constructor(e){super(e),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}}getOperators=fe((e,t)=>{const{onOperatorChanged:n}=this.props;let s=x.getFilterTypes(t);return x.isBooleanType(t)&&(s=[X.eq,X.notEq]),s.flatMap((i,o)=>{if(i==="eqIgnoreCase"||i==="notEqIgnoreCase")return[];let a="";return i==="startsWith"?a="a*":i==="endsWith"?a="*z":a=x.getFilterOperatorString(i),[{title:Ro.getLabelForLinkFilter(t,i),icon:l.jsx("b",{children:a}),action:()=>n(e,i),order:o}]})});handleClick(e){e.stopPropagation(),e.preventDefault();const{id:t,onClick:n,onDelete:s}=this.props;e.altKey?s(t):n(t)}handleMouseEnter(){this.setState({isHovering:!0})}handleMouseLeave(){this.setState({isHovering:!1})}handleDelete(){const{id:e,onDelete:t}=this.props;t(e)}getDropdownActions(){const{id:e,startColumnType:t}=this.props;return t!=null?this.getOperators(e,t):[]}render(){const{className:e,operator:t,isSelected:n,x1:s,y1:i,x2:o,y2:a,id:r,startColumnType:c}=this.props,{isHovering:h}=this.state,u=Math.sqrt((s-o)**2+(i-a)**2),m=Math.atan2(a-i,o-s),g=Math.sin(m),p=Math.cos(m)+2,C=window.innerWidth,f=window.innerHeight,S=0,v=0,w=Math.max(S,Math.min(s+(o-s)/2+g*(u*lh)**ch,C)),T=Math.max(v,Math.min(i+(a-i)/2+p*(u*lh)**ch,f)),y=`M ${s} ${i} Q ${w} ${T} ${o} ${a}`,E=`M ${S} ${v} L ${S} ${f} L ${C} ${f} L ${C} ${v} z
35
- ${Ro.makeCirclePath(s,i,mh)}
36
- ${Ro.makeCirclePath(o,a,mh)}`,D=`link-select-clip-${r}`,F=Math.atan2(a-T,o-w),N=F-uh+Math.PI,_=F+uh+Math.PI,P=o+Math.cos(F)*hh,U=a+Math.sin(F)*hh,O=P+Math.cos(N)*wa,j=U+Math.sin(N)*wa,k=P+Math.cos(_)*wa,A=U+Math.sin(_)*wa,H=`${P},${U} ${O},${j} ${k},${A}`,K=.25*s+.5*w+.25*o,q=.25*i+.5*T+.25*a,oe=w-s+(o-w),G=(T-i+(a-T))/oe;let ae=20/Math.sqrt(1+G**2),ce=ae*G,te=ae*-1,re=ce*-1;Number.isFinite(G)?G>0?(ae*=-1,ce*=-1,te*=-1,re*=-1,te-=50-10*(Math.abs(m)%ws),re+=10*(Math.abs(m)%ws),ae-=50-10*(Math.abs(m)%ws),ce+=10*(Math.abs(m)%ws)):G<0?(te+=10*(Math.abs(m)%ws),re+=10*(Math.abs(m)%ws),ae+=10*(Math.abs(m)%ws),ce+=10*(Math.abs(m)%ws)):(te=15,re=10,ae=-25,ce=10):(te=10,re=5,ae=10,ce=-35);let we="";return t!==void 0&&(t==="startsWith"?we="a*":t==="endsWith"?we="*z":we=x.getFilterOperatorString(t)),l.jsxs(l.Fragment,{children:[l.jsxs("svg",{className:$(e,{hovering:h}),children:[l.jsx("clipPath",{id:D,children:l.jsx("path",{d:E,clipRule:"evenodd"})}),l.jsx("path",{className:"link-select",d:y,onClick:this.handleClick,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,clipPath:`url(#${D})`}),l.jsx("path",{className:"link-background",d:y}),l.jsx("path",{className:"link-foreground",d:y}),l.jsx("circle",{className:"link-dot",cx:s,cy:i,r:"5"}),l.jsx("polygon",{className:"link-triangle",points:H})]}),c!=null&&n&&l.jsxs(l.Fragment,{children:[l.jsx(B,{kind:"primary",className:"btn-fab btn-operator",style:{top:q+(G>=0?ce:re),left:K+(G>=0?ae:te)},onClick:()=>{},icon:l.jsxs("div",{className:"fa-md fa-layers",children:[l.jsx("b",{children:we}),l.jsx(Q,{icon:Pn,transform:"right-8 down-9 shrink-5"})]}),tooltip:"Change comparison operator",children:l.jsx(es,{actions:this.getDropdownActions,popperOptions:{placement:"bottom-start"}})}),l.jsx(B,{kind:"primary",className:"btn-fab btn-delete",style:{top:q+(G<0?ce:re),left:K+(G<0?ae:te)},onClick:this.handleDelete,icon:Jt,tooltip:"Delete"})]})]})}}const tl=Z.module("LinkerOverlayContent");class hx extends b.Component{static defaultProps={disabled:"false"};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=J.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,t){tl.error("componentDidCatch",e,t)}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)}dialogRef;getPointFromLinkPoint(e){const{panelManager:t}=this.props,{panelId:n,columnName:s}=e,i=t.getOpenedPanelById(n);if(i!=null){if(!Em(i))throw new Error(`Panel does not have getCoordinateForColumn method: ${n}`);try{const a=i.getCoordinateForColumn(s);if(a!=null)return a}catch{tl.error("Could not get coordinate for column",s,i)}}const o=t.getContainerByPanelId(n);if(o==null)throw new Error(`Unable to find panel container for id: ${n}`);return Y.getTabPoint(o)}handleOperatorChanged(e,t){const{links:n,onLinksUpdated:s}=this.props,i=n.map(o=>o.id===e?{...o,operator:t}:o);s(i)}handleBlur(){this.setState({mode:"select"})}handleResize(){const{dialog:e}=this.state;if(e&&this.dialogRef.current){const t=this.dialogRef.current.getBoundingClientRect(),n=He(e.x,0,window.innerWidth-t.width),s=He(e.y,0,window.innerHeight-t.height);this.setState({dialog:{x:n,y:s}})}}handleMouseMove(e){const{offset:t,isDragging:n}=this.state;if(this.setState({mouse:{x:e.clientX,y:e.clientY}}),n&&this.dialogRef.current){const s=this.dialogRef.current.getBoundingClientRect(),i=He(window.innerWidth-(e.clientX+s.width+t.x),0,window.innerWidth-s.width),o=He(window.innerHeight-(e.clientY+s.height+t.y),0,window.innerHeight-s.height);this.setState({dialog:{x:i,y:o}})}}handleMouseDown(e){const t={x:0,y:0};if(this.dialogRef.current){const n=this.dialogRef.current.getBoundingClientRect();t.x=n.right-(n.width+e.clientX),t.y=n.bottom-(n.height+e.clientY)}this.setState({isDragging:!0,offset:t})}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:t,onLinkDeleted:n}=this.props;e.preventDefault(),t.forEach(s=>n(s))}}handleKeyUp(e){e.key==="Alt"&&(e.preventDefault(),this.setState({mode:"select"}))}handleEscapePressed(){const{onCancel:e}=this.props;e()}render(){const{disabled:e,links:t,selectedIds:n,messageText:s,onLinkSelected:i,onLinkDeleted:o,onAllLinksDeleted:a,onDone:r}=this.props,{mouse:c,dialog:h,isDragging:u,mode:m}=this.state,g=t.map(p=>{try{const{id:C,type:f,isReversed:S,start:v,end:w,operator:T}=p,y=v.columnType;let[E,D]=this.getPointFromLinkPoint(v),F=c?.x??E,N=c?.y??D;if(w!=null&&([F,N]=this.getPointFromLinkPoint(w)),S!=null&&S){const[P,U]=[E,D];[E,D]=[F,N],[F,N]=[P,U]}const _=$("linker-link",{disabled:e},{"link-filter-source":f==="filterSource"},{"link-invalid":f==="invalid"},{interactive:p.end==null},{"link-is-selected":n.has(C)},{"danger-delete":m==="delete"});return{x1:E,y1:D,x2:F,y2:N,id:C,className:_,operator:T,startColumnType:y}}catch(C){return tl.warn("Unable to get point for link",p,C),null}}).filter(p=>p!=null);return l.jsxs("div",{className:$("linker-overlay",{"danger-delete":m==="delete"}),children:[g.map(({x1:p,y1:C,x2:f,y2:S,id:v,className:w,operator:T,startColumnType:y})=>l.jsx(Ro,{className:w,id:v,x1:p,y1:C,x2:f,y2:S,onClick:i,onDelete:o,isSelected:n.has(v),operator:T,startColumnType:y,onOperatorChanged:this.handleOperatorChanged},v)),l.jsxs("div",{className:$("linker-toast-dialog",{dragging:u}),ref:this.dialogRef,style:{bottom:h?.y,right:h?.x},children:[l.jsx(B,{draggable:!0,kind:"inline",className:"btn-drag-handle",icon:ko,onClick:()=>{},onMouseDown:this.handleMouseDown,children:!u&&l.jsx(tt,{children:"Drag to reposition"})}),l.jsx("div",{className:"toast-body",children:s}),l.jsxs("div",{className:"toast-footer",children:[l.jsx(B,{kind:"secondary",onClick:a,children:"Clear All"}),l.jsx(B,{kind:"primary",onClick:r,children:"Done"})]})]}),l.jsx(ie,{actions:[{action:this.handleEscapePressed,shortcut:ss.LINKER_CLOSE,isGlobal:!0}]})]})}}const Tt=Z.module("Linker"),ux=(d,e)=>({activeTool:gr(d),isolatedLinkerPanelId:vc(d,e.localDashboardId),links:Ji(d,e.localDashboardId),timeZone:Lo(d)}),mx=Ct(ux,{setActiveTool:fr,setDashboardLinks:Ec,addDashboardLinks:rR,deleteDashboardLinks:lR,setDashboardIsolatedLinkerPanelId:bm,setDashboardColumnSelectionValidator:cR});class gx extends b.Component{constructor(e){super(e),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:t,layout:n}=this.props;n!==e.layout&&(this.stopListening(e.layout),this.startListening(n)),t!==e.activeTool&&(this.updateSelectionValidators(),t===Vt.DEFAULT&&this.reset())}componentDidCatch(e,t){Tt.error("componentDidCatch",e,t)}componentWillUnmount(){const{layout:e}=this.props;this.stopListening(e)}startListening(e){e.on("stateChanged",this.handleLayoutStateChanged);const{eventHub:t}=e;t.on(bn.COLUMN_SELECTED,this.handleGridColumnSelect),t.on(bn.DATA_SELECTED,this.handleUpdateValues),t.on(bn.STATE_CHANGED,this.handleStateChange),t.on(bl.COLUMN_SELECTED,this.handleChartColumnSelect),t.on(Ee.CLONED,this.handlePanelCloned),t.on(Qe.COLUMN_SELECTED,this.handleFilterColumnSelect),t.on(Qe.COLUMNS_CHANGED,this.handleColumnsChanged),t.on(Ee.CLOSE,this.handlePanelClosed),t.on(Ee.CLOSED,this.handlePanelClosed),t.on(Ee.DRAGGING,this.handlePanelDragging),t.on(Ee.DROPPED,this.handlePanelDropped)}stopListening(e){e.off("stateChanged",this.handleLayoutStateChanged);const{eventHub:t}=e;t.off(bn.COLUMN_SELECTED,this.handleGridColumnSelect),t.off(bn.DATA_SELECTED,this.handleUpdateValues),t.off(bn.STATE_CHANGED,this.handleStateChange),t.off(bl.COLUMN_SELECTED,this.handleChartColumnSelect),t.off(Ee.CLONED,this.handlePanelCloned),t.off(Qe.COLUMN_SELECTED,this.handleFilterColumnSelect),t.off(Qe.COLUMNS_CHANGED,this.handleColumnsChanged),t.off(Ee.CLOSE,this.handlePanelClosed),t.off(Ee.CLOSED,this.handlePanelClosed),t.off(Ee.DRAGGING,this.handlePanelDragging),t.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:t}=this.props;t(Vt.DEFAULT)}this.setState({linkInProgress:void 0})}handleDone(){const{setActiveTool:e}=this.props;e(Vt.DEFAULT)}handleChartColumnSelect(e,t){this.columnSelected(e,t,!0)}handleFilterColumnSelect(e,t){Tt.debug("handleFilterColumnSelect",this.isOverlayShown());const{links:n,localDashboardId:s,setActiveTool:i,setDashboardIsolatedLinkerPanelId:o}=this.props,a=Y.getIdFromPanel(e),r=n.filter(c=>c.start?.panelId===a||c.end?.panelId===a);if(!this.isOverlayShown()&&a!=null){i(Vt.LINKER),o(s,a),r.length===0&&this.columnSelected(e,t,!0,a);return}this.columnSelected(e,t,!0)}handleColumnsChanged(e,t){Tt.debug("handleColumnsChanged",e,t);const{links:n}=this.props,s=Y.getIdFromPanel(e);if(s==null){Tt.error("Invalid panelId",e);return}const i=n.filter(({start:o,end:a})=>o.panelId===s&&Is.findColumn(t,o)==null||a!=null&&a.panelId===s&&Is.findColumn(t,a)==null);this.deleteLinks(i)}handleGridColumnSelect(e,t){if(!rh(t)){Tt.debug2("Column is not filterable");return}this.columnSelected(e,t)}columnSelected(e,t,n=!1,s){if(s===void 0&&!this.isOverlayShown())return;const{isolatedLinkerPanelId:i}=this.props,{linkInProgress:o}=this.state,a=Y.getIdFromPanel(e);if(a==null)return;const r=Y.getComponentNameFromPanel(e),{name:c,type:h}=t;if(o==null||o.start==null){const u={id:_e.generate(),start:{panelId:a,panelComponent:r,columnName:c,columnType:h},type:"invalid",isReversed:n};Tt.debug("starting link",u),this.setState({linkInProgress:u})}else{const{links:u}=this.props,{start:m,id:g,isReversed:p}=o,C={panelId:a,panelComponent:r,columnName:c,columnType:h},f=Is.getLinkType(p!==void 0&&p?C:m,p!==void 0&&p?m:C,s??i);switch(f){case"invalid":Tt.debug("Ignore invalid link connection",o,C);return;case"filterSource":{const v=p!==void 0&&p?m.panelId:C.panelId,w=u.filter(({end:T})=>T?.panelId===v);this.deleteLinks(w);break}}const S={start:p!==void 0&&p?C:m,end:p!==void 0&&p?m:C,id:g,type:f,operator:X.eq};Tt.info("creating link",S),this.setState({linkInProgress:void 0,selectedIds:new Set([g])},()=>{this.addLinks([S])})}}unsetFilterValueForLink(e){const{panelManager:t}=this.props;if(e.end){const{end:n}=e,{panelId:s,columnName:i,columnType:o}=n,a=t.getOpenedPanelById(s);a?ah(a)?a.unsetFilterValue(i,o):Tt.debug("endPanel.unsetFilterValue not implemented",a):Tt.debug("endPanel no longer exists, ignoring unsetFilterValue",s)}}setPanelFilterMap(e,t){Tt.debug("Set filter data for panel:",e,t);const{panelManager:n}=this.props,s=n.getOpenedPanelById(e);s?ah(s)?s.setFilterMap(t):Tt.debug("panel.setFilterMap not implemented",e,s):Tt.debug("panel no longer exists, ignoring setFilterMap",e)}addLinks(e){const{addDashboardLinks:t,localDashboardId:n}=this.props;t(n,e)}deleteLinks(e,t=!1){const{localDashboardId:n}=this.props;if(e.forEach(s=>this.unsetFilterValueForLink(s)),t){const{setDashboardLinks:s}=this.props;s(n,[])}else if(e.length>0){const{deleteDashboardLinks:s}=this.props;s(n,e.map(({id:i})=>i))}}handleAllLinksDeleted(){const{links:e,isolatedLinkerPanelId:t}=this.props;if(t===void 0)this.deleteLinks(e,!0);else{const n=e.filter(s=>s?.start?.panelId===t||s?.end?.panelId===t);this.deleteLinks(n)}this.reset()}handleLinkDeleted(e){const{links:t}=this.props,n=t.find(s=>s.id===e);n?this.deleteLinks([n]):Tt.error("Unable to find link to delete",e)}handleUpdateValues(e,t){const n=Y.getIdFromPanel(e),{links:s,timeZone:i}=this.props,o=new Map;for(let a=0;a<s.length;a+=1){const{start:r,end:c,operator:h}=s[a];if(r.panelId===n&&c!=null){const{panelId:u,columnName:m,columnType:g}=c,p=o.has(u)?o.get(u):new Map,C=p.has(m)===!0?p.get(m).filterList:[],{visibleIndex:f,isExpandable:S,isGrouped:v}=t[r.columnName];let{value:w}=t[r.columnName],T=`${w}`;w===null&&S&&v&&(w=void 0),g!=null&&x.isDateType(g)&&(T=new je({timeZone:i,showTimeZone:!1,showTSeparator:!0,defaultDateTimeFormatString:et.FULL_DATE_FORMAT}).format(w));const y={operator:h,text:T,value:w,startColumnIndex:f};C.push(y),p.set(m,{columnType:g,filterList:C}),o.set(u,p)}}o.forEach((a,r)=>{this.setPanelFilterMap(r,a)})}handlePanelCloned(e,t){const{links:n}=this.props,s=Y.getIdFromPanel(e),i=t.id;if(s!=null){const o=Is.cloneLinksForPanel(n,s,i);this.addLinks(o)}}handlePanelDragging(e){const{links:t}=this.props;for(let n=0;n<t.length;n+=1){const s=t[n],{start:i,end:o}=s;if(i.panelId===e||o?.panelId===e){this.setState({isDraggingPanel:!0});return}}}handlePanelDropped(){this.setState({isDraggingPanel:!1})}handlePanelClosed(e){Tt.debug(`Panel ${e} closed, deleting links.`),this.deleteLinksForPanelId(e)}handleLinkSelected(e){this.setState({selectedIds:new Set([e])})}handleLinksUpdated(e){const{localDashboardId:t,setDashboardLinks:n}=this.props;n(t,e)}handleLayoutStateChanged(){this.forceUpdate()}handleStateChange(){this.forceUpdate()}handleExited(){const{localDashboardId:e,setDashboardIsolatedLinkerPanelId:t}=this.props;t(e,void 0)}deleteLinksForPanelId(e){const{links:t}=this.props;for(let n=0;n<t.length;n+=1){const s=t[n],{start:i,end:o,id:a}=s;(i.panelId===e||o?.panelId===e)&&this.handleLinkDeleted(a)}}getCachedLinks=fe((e,t,n)=>{const s=[...e];return t!=null&&t.start!=null&&s.push(t),n!==void 0?s.filter(i=>i?.start?.panelId===n||i?.end?.panelId===n||i?.end==null):s});isOverlayShown(){const{activeTool:e}=this.props;return e===Vt.LINKER}updateSelectionValidators(){const{activeTool:e,setDashboardColumnSelectionValidator:t,localDashboardId:n}=this.props;switch(e){case Vt.LINKER:t(n,this.isColumnSelectionValid);break;default:t(n,void 0);break}}updateLinkInProgressType(e,t="invalid"){this.setState({linkInProgress:{...e,type:t}})}isColumnSelectionValid(e,t){const{linkInProgress:n}=this.state,{isolatedLinkerPanelId:s}=this.props;if(t==null)return n?.start!=null&&this.updateLinkInProgressType(n),!1;if(!rh(t))return Tt.debug2("Column is not filterable",t.description),n?.start!=null&&this.updateLinkInProgressType(n,"invalid"),!1;if(n?.start==null)return!0;const{isReversed:i,start:o}=n,a=Y.getIdFromPanel(e);if(a==null)return!1;const r={panelId:a,panelComponent:Y.getComponentNameFromPanel(e),columnName:t.name,columnType:t.type},c=i!==void 0&&i?Is.getLinkType(r,o,s):Is.getLinkType(o,r,s);return this.updateLinkInProgressType(n,c),c!=="invalid"}render(){const{links:e,isolatedLinkerPanelId:t,panelManager:n}=this.props,{linkInProgress:s,selectedIds:i,isDraggingPanel:o}=this.state,a=this.isOverlayShown(),r=s!=null&&s.start!=null,c=t===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 o?null:l.jsx(ft,{in:a,timeout:ze.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,onExited:this.handleExited,children:l.jsx(hx,{disabled:r,panelManager:n,links:this.getCachedLinks(e,s,t),selectedIds:i,messageText:c,onLinkSelected:this.handleLinkSelected,onLinkDeleted:this.handleLinkDeleted,onAllLinksDeleted:this.handleAllLinksDeleted,onLinksUpdated:this.handleLinksUpdated,onDone:this.handleDone,onCancel:this.handleCancel})})}}const px=mx(gx);function fx(d){Hs(d);const{id:e,layout:t,panelManager:n}=d;return l.jsx(px,{layout:t,localDashboardId:e,panelManager:n})}class Vi{static DEFAULT_TITLE="Note";static DEFAULT_CONTENT=`# Markdown Note
37
-
38
- This note can be edited using **markdown** for styling.`;static getNewMarkdownTitle(e){let t=`${Vi.DEFAULT_TITLE}`,n=0;for(;e.indexOf(t)>=0;)n+=1,t=`${Vi.DEFAULT_TITLE}-${n}`;return t}}function Cx(d){Hs(d);const{id:e,layout:t,panelManager:n,registerComponent:s}=d,i=b.useCallback(a=>{const{title:r,componentState:c,props:h}=a;let{panelState:u=null}=h;return c!=null&&({panelState:u=null}=c),r==null||u==null||u.content==null||u.content.length===0||u.content===Vi.DEFAULT_CONTENT?null:sc(a)},[]),o=b.useCallback(({title:a="",metadata:r={},id:c=_e.generate(),focusElement:h=Y.DEFAULT_FOCUS_SELECTOR,createNewStack:u=!1,dragEvent:m=null}={})=>{const g=n.getOpenedPanelConfigsOfType(go.COMPONENT),p=n.getClosedPanelConfigsOfType(go.COMPONENT),C=g.map(T=>T.title??""),f=a!=null&&a!==""?a:Vi.getNewMarkdownTitle(C),S=p.length>0?null:Vi.DEFAULT_CONTENT,v={type:"react-component",component:go.COMPONENT,props:{id:c,metadata:r,panelState:{content:S},localDashboardId:e},title:f,id:c},{root:w}=t;Y.openComponent({root:w,config:v,focusElement:h,createNewStack:u,dragEvent:m})},[e,t,n]);return b.useEffect(function(){const r=[s(go.COMPONENT,go,ic,i)];return()=>{r.forEach(c=>c())}},[i,s]),We(t.eventHub,Cm.OPEN,o),null}function Sx(d){Hs(d);const{hydrate:e,id:t,layout:n,registerComponent:s}=d,i=b.useCallback(({dragEvent:o,fetch:a,panelId:r=_e.generate(),widget:c})=>{const{name:h,type:u}=c;if(u!==dh.VariableType.PANDAS)return;const m={name:h,table:h},g=()=>a().then(f=>Cc.makeModel(f)),p={type:"react-component",component:el.COMPONENT,props:{localDashboardId:t,id:r,metadata:m,makeModel:g},title:h,id:r},{root:C}=n;Y.openComponent({root:C,config:p,dragEvent:o})},[t,n]);return b.useEffect(function(){const a=[s(el.COMPONENT,el,e)];return()=>{a.forEach(r=>r())}},[e,s]),We(n.eventHub,Ee.OPEN,i),null}class Ns{static DROPDOWN_FILTER="ControlType.DROPDOWN_FILTER";static INPUT_FILTER="ControlType.INPUT_FILTER";static MARKDOWN="ControlType.MARKDOWN";static FILTER_SET_MANAGER="ControlType.FILTER_SET_MANAGER"}I.shape({state:I.shape({panelState:I.shape({})})});I.shape({panelId:I.string.isRequired,columnName:I.string.isRequired,columnType:I.string.isRequired});const gh=I.shape({panelId:I.string.isRequired,columnName:I.string.isRequired}),bx=I.shape({start:gh,end:gh,id:I.string,isReversed:I.bool});I.arrayOf(bx);I.shape({name:I.string.isRequired,operateAs:I.string.isRequired,groups:I.arrayOf(I.string).isRequired,permissions:I.shape({isSuperUser:I.bool.isRequired,isQueryViewOnly:I.bool.isRequired,isNonInteractive:I.bool.isRequired,canUsePanels:I.bool.isRequired,canCreateDashboard:I.bool.isRequired,canCreateCodeStudio:I.bool.isRequired,canCreateQueryMonitor:I.bool.isRequired,canCopy:I.bool.isRequired,canDownloadCsv:I.bool.isRequired}).isRequired});Z.module("StorageTableViewportUpdater");class ph{static makeSortConfig(e,t){return{column:e,direction:t}}static makeFilterConfig(e){const t=[],n=[];return e.forEach((s,i)=>{t.push(s),i>0&&n.push(wn.and)}),{filterItems:t,filterOperators:n}}static combineFilterConfigs(e,t,n=wn.and){return{filterItems:[...e.filterItems,...t.filterItems],filterOperators:[...e.filterOperators,n,...t.filterOperators]}}static makeFilterItem(e,t,n){return{columnName:e,type:t,value:n}}}function wx(d,e,t){if(d.length>e){const n=d.length-t;return{toKeep:d.slice(n),toPrune:d.slice(0,n)}}return{toKeep:d,toPrune:[]}}const nl=Z.module("PouchStorageTable"),vx="Deephaven.";Rh.plugin(ug);function Tx(d,e){switch(d){case X.in:case X.contains:return{$regex:new RegExp(`${e}`)};case X.inIgnoreCase:return{$regex:new RegExp(`${e}`,"i")};case X.eq:return{$eq:e};case X.notEq:return{$neq:e};case X.greaterThan:return{$gt:e};case X.greaterThanOrEqualTo:return{$gte:e};case X.lessThan:return{$lt:e};case X.lessThanOrEqualTo:return{$lte:e};case X.startsWith:return{$regex:new RegExp(`^(?${e}).*`)};default:throw new Error(`Unsupported type: ${d}`)}}function Ex(d){const{filterItems:e,filterOperators:t}=d;let n=null;for(let s=0;s<e.length;s+=1){const i=e[s],{columnName:o,type:a,value:r}=i,c={[o]:Tx(a,r)};if(s===0)n=c;else if(n!==null&&s-1<t.length){const h=t[s-1];if(h===wn.and)n={$and:[n,c]};else if(h===wn.or)n={$or:[n,c]};else throw new Error(`Unexpected filter operator ${h}, ${c}`)}}if(n==null)throw new Error(`Invalid filter config ${d}`);return n}function sl(d=[]){return{$and:[...d.map(e=>Ex(e)),{name:{$gt:null}},{id:{$gt:null}}]}}function yx(d,e=!1){return[{id:e?"desc":"asc"},...d?.map(t=>({[t.column]:t.direction}))??[]]}class Rx{db;changes;listeners=[];itemListeners=new Map;currentSize=0;currentViewport;currentReverse=!1;currentFilter=null;currentSort=null;infoUpdatePromise;viewportUpdatePromise;currentViewportData;constructor(e,t){this.db=new Rh(`${vx}${e}`,t),this.db._remote=!1,this.listenForChanges(),this.db.createIndex({index:{fields:["id","name"]}}),this.refreshInfo()}listenForChanges(){this.changes=this.db.changes({live:!0,since:"now",include_docs:!0}).on("change",this.dbUpdate.bind(this))}onUpdate(e){return this.listeners=[...this.listeners,e],()=>{this.listeners=this.listeners.filter(t=>t!==e)}}onItemUpdate(e,t){return this.itemListeners.has(e)||this.itemListeners.set(e,[]),this.itemListeners.set(e,[...this.itemListeners.get(e),t]),this.refreshItem(e),()=>{this.itemListeners.set(e,this.itemListeners.get(e).filter(n=>n!==t))}}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 t={...e,_id:e.id};return await this.db.put(t),t}sendUpdate(){const{listeners:e}=this,t=this.currentViewportData??{items:[],offset:0};for(let n=0;n<e.length;n+=1)e[n](t)}sendItemUpdate(e){const t=this.itemListeners.get(e.id);if(t!==void 0)for(let n=0;n<t.length;n+=1)t[n](e)}dbUpdate(e){nl.debug("Update received",e),this.refreshInfo(),e.doc!==void 0&&this.sendItemUpdate(e.doc),this.refreshData()}async fetchInfo(e){return this.db.find({selector:e,fields:[]})}async refreshInfo(){try{this.infoUpdatePromise?.cancel(),this.infoUpdatePromise=ve.makeCancelable(this.fetchInfo(sl(this.currentFilter??[])));const e=await this.infoUpdatePromise;this.currentSize=e.docs.length,this.sendUpdate()}catch(e){if(!ve.isCanceled(e))throw nl.error("Unable to refreshInfo",e),e}}async fetchViewportData(e,t,n){return this.db.find({selector:t,skip:e.top,limit:e.bottom-e.top+1,sort:n,fields:["id","name"]}).then(s=>({items:s.docs,offset:e.top}))}async refreshData(){if(this.currentViewport)try{const e=sl(this.currentFilter??[]),t=yx(this.currentSort,this.currentReverse);this.viewportUpdatePromise?.cancel(),this.viewportUpdatePromise=ve.makeCancelable(this.fetchViewportData(this.currentViewport,e,t));const n=await this.viewportUpdatePromise;return this.currentViewportData=n,this.sendUpdate(),n}catch(e){if(!ve.isCanceled(e))throw nl.error("Unable to refreshData",e),e}}async refreshItem(e){const n=(await this.db.find({selector:{id:e},limit:1})).docs[0];return n!==void 0&&this.sendItemUpdate(n),n}async getSnapshot(e){const t=new Map,n=[{id:this.currentReverse?"desc":"asc"}];return await Promise.all(e.map(async([s,i])=>{const o=i-s+1;return this.db.find({selector:sl(this.currentFilter??[]),skip:s,limit:o,sort:n,fields:["id","name"]}).then(a=>{for(let r=0;r<o;r+=1){const c=s+r;t.set(c,a.docs[r])}})})),t}}const xx=2500,Ix=2e3,rn=Z.module("PouchCommandHistoryTable");class fh extends Rx{constructor(e,t){super(`CommandHistoryStorage.${e}`,{auto_compaction:!0,revs_limit:1}),this.cache=t,this.cache.tableRegistry.has(this.cacheKey)||this.cache.tableRegistry.set(this.cacheKey,new Set),rn.debug("Adding table to registry",this.cacheKey),this.cache.tableRegistry.get(this.cacheKey)?.add(this)}searchText;get cacheKey(){return this.db.name}setSearch(e){rn.debug("Setting search filters",e),this.searchText=e.trim().toLowerCase(),this.setFilters(e?[ph.makeFilterConfig([ph.makeFilterItem("name",X.contains,e)])]:[])}dbUpdate(e){rn.debug("Clearing cache and refreshing data",e),this.cache.response.delete(this.cacheKey),super.dbUpdate(e)}async fetchData(e){return ve.withTimeout(0,async()=>{this.cache.response.has(this.cacheKey)?rn.debug("Fetching from cache",this.searchText,this.viewport):(rn.debug("Fetching from PouchDB",this.searchText,this.viewport),this.cache.response.set(this.cacheKey,this.db.allDocs({include_docs:!0}).then(n=>{const s=n.rows.map(a=>a.doc).filter(({name:a})=>a);rn.debug(`Fetched ${s.length} command history items`);const{toKeep:i,toPrune:o}=wx(s,xx,Ix);return o.length&&this.pruneItems(o),{docs:i}})));const t=this.cache.response.get(this.cacheKey);return this.searchText==null||this.searchText===""?t:{...t,docs:(await t).docs.filter(({name:n})=>n.toLowerCase().includes(this.searchText))}})}async fetchInfo(e){return this.fetchData(e)}async fetchViewportData(e,t,n){const s=await this.fetchData(t);return rn.debug("Fetching viewport data",e.top,e.bottom+1,n,s),{items:(typeof n[0]=="object"&&n[0].id==="desc"?s.docs.slice(0).reverse():s.docs).slice(e.top,e.bottom+1),offset:e.top}}async pruneItems(e){if(this.cache.isPruning.get(this.cacheKey)===!0){rn.debug("Pruning already in progress. Skipping.");return}try{rn.debug(`Pruning ${e.length} command history items`);const t=this.cache.pauseChangeListeners(this.cacheKey);this.cache.isPruning.set(this.cacheKey,!0),await this.db.bulkDocs(e.map(n=>({...n,_deleted:!0}))),this.cache.isPruning.set(this.cacheKey,!1),t(),rn.debug("Finished pruning command history items")}catch(t){rn.error("An error occurred while pruning db",t)}}close(){rn.debug("Closing table",this,this.cache.tableRegistry.get(this.cacheKey)?.size),this.cache.tableRegistry.get(this.cacheKey)?.delete(this),this.changes?.cancel(),super.close()}}const Ch=Z.module("PouchCommandHistoryCache");class Dx{constructor(){this.isPruning=new Map,this.response=new Map,this.tableRegistry=new Map}isPruning;response;tableRegistry;pauseChangeListeners(e){const t=[];return this.tableRegistry.get(e)?.forEach(n=>{n.changes&&(Ch.debug(`Pausing event listeners on '${e}' table`,n),n.changes.cancel(),t.push(n))}),()=>{t.forEach(n=>{(this.tableRegistry.get(e)?.has(n)??!1)&&(Ch.debug(`Resuming event listeners on '${e}' table`,n),n.listenForChanges())})}}}const Sh=Z.module("PouchCommandHistoryStorage");class Fx{cache=new Dx;updateTableMap=new Map;getUpdateTable(e){return this.updateTableMap.has(e)||this.updateTableMap.set(e,new fh(e,this.cache)),this.updateTableMap.get(e)}async getTable(e){return new fh(e,this.cache)}async addItem(e,t,n,s){return this.updateItem(e,{id:`${new Date().getTime()}`,name:n,data:s})}async updateItem(e,t){const n=this.getUpdateTable(e),i={...await n.refreshItem(t.id)??{},...t};return Sh.debug("Updating item",i),await n.put(i),Sh.debug("Update saved"),t}listenItem(e,t,n){return this.getUpdateTable(e).onItemUpdate(t,n)}}const xm="SET_LAYOUT_STORAGE",Nx=d=>({type:xm,payload:d}),Im="/ide/assets/community-wordmark-app-d2c5c1eb.svg";const Mx=Z.module("FormattingSectionContent");function kx(d){return d.formatString!=null}function El(d){const e=d?.querySelector("input, select, textarea");e&&e.focus()}function Dm(d,e){return d.defaultFormatString===e.defaultFormatString}function Ox(d,e){return Dm(d,e)}function Ax(d,e){return Dm(d,e)}function Fm(d){return d!==""&&un.isValidColumnName(d)}function Ms(d,e){if(!d||e.formatString==null||!kx(e))return!1;switch(d){case"datetime":return je.isValid(e);case"decimal":return Re.isValid(e);case"int":return Ge.isValid(e);default:return Mx.warn("Trying to validate format of unknown type"),!0}}function Nm(d){const{id:e,isNewRule:t,...n}=d;return n}function Mm(d){return Fm(d.columnName)&&Ms(d.columnType,d.format)}function km(d){const{timestamp:e,timeZone:t,showTimeZone:n,showTSeparator:s,isGlobalOptions:i,legacyGlobalFormat:o}=d,a=new Qt([],{timeZone:t,showTimeZone:n,showTSeparator:s}),r=i?je.getGlobalFormats(n,s):je.getFormats(n,s);return o!=null&&!r.includes(o)&&r.unshift(o),l.jsx(l.Fragment,{children:r.map(c=>{const h=je.makeFormat("",c,je.TYPE_GLOBAL);return l.jsx("option",{value:c,"data-testid":"time-format",children:a.getFormattedString(e,x.dataType.DATETIME,"",h)},c)})})}function Lx(){return l.jsx(l.Fragment,{children:Xi.TIME_ZONES.map(d=>{const{label:e,value:t}=d;return l.jsx("option",{value:t,children:e},t)})})}const Zs=Z.module("FormattingSectionContent");class Fc extends b.PureComponent{static defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:je.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:Re.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:Ge.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:je.DEFAULT_TIME_ZONE_ID}};static inputDebounceTime=250;constructor(e){super(e),this.debouncedCommitChanges=Ye(this.commitChanges.bind(this),Fc.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:t,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,showTimeZone:o,showTSeparator:a,timeZone:r,truncateNumbersWithPound:c}=e,h=t.map((u,m)=>({...u,id:m}));this.containerRef=J.createRef(),this.state={formatSettings:h,showTimeZone:o,showTSeparator:a,timeZone:r,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,truncateNumbersWithPound:c,timestampAtMenuOpen:new Date}}componentDidMount(){El(this.containerRef.current)}componentWillUnmount(){this.debouncedCommitChanges.flush()}debouncedCommitChanges;containerRef;getCachedDateTimeFormatOptions=ge((e,t,n,s=!1,i)=>{const{timestampAtMenuOpen:o}=this.state;return l.jsx(km,{timestamp:o,timeZone:e,showTimeZone:t,showTSeparator:n,isGlobalOptions:s,legacyGlobalFormat:i})});handleDefaultDateTimeFormatChange(e){Zs.debug("handleDefaultDateTimeFormatChange",e.target.value),this.setState({defaultDateTimeFormat:e.target.value},()=>{this.debouncedCommitChanges()})}handleDefaultDecimalFormatChange(e){Zs.debug("handleDefaultDecimalFormatChange",e.target.value),this.setState({defaultDecimalFormatOptions:{defaultFormatString:e.target.value}},()=>{this.debouncedCommitChanges()})}handleDefaultIntegerFormatChange(e){Zs.debug("handleDefaultIntegerFormatChange",e.target.value),this.setState({defaultIntegerFormatOptions:{defaultFormatString:e.target.value}},()=>{this.debouncedCommitChanges()})}handleShowTimeZoneChange(){this.setState(e=>({showTimeZone:!e.showTimeZone}),()=>{this.debouncedCommitChanges()})}handleShowTSeparatorChange(){this.setState(e=>({showTSeparator:!e.showTSeparator}),()=>{this.debouncedCommitChanges()})}handleTimeZoneChange(e){this.setState({timeZone:e.target.value},()=>{this.debouncedCommitChanges()})}handleResetDateTimeFormat(){const{defaults:e}=this.props,{defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:s}=e;Zs.debug("handleResetDateTimeFormat"),this.setState({defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:s},()=>{this.debouncedCommitChanges()})}handleResetTimeZone(){const{defaults:e}=this.props,{timeZone:t}=e;Zs.debug("handleResetTimeZone"),this.setState({timeZone:t},()=>{this.debouncedCommitChanges()})}handleResetDecimalFormat(){const{defaults:e}=this.props,{defaultDecimalFormatOptions:t}=e;Zs.debug("handleResetDecimalFormat"),this.setState({defaultDecimalFormatOptions:t},()=>{this.debouncedCommitChanges()})}handleResetIntegerFormat(){const{defaults:e}=this.props,{defaultIntegerFormatOptions:t}=e;Zs.debug("handleResetIntegerFormat"),this.setState({defaultIntegerFormatOptions:t},()=>{this.debouncedCommitChanges()})}handleTruncateNumbersWithPoundChange(){this.setState(e=>({truncateNumbersWithPound:!e.truncateNumbersWithPound}),()=>{this.debouncedCommitChanges()})}commitChanges(){const{formatSettings:e,defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:s,timeZone:i,defaultDecimalFormatOptions:o,defaultIntegerFormatOptions:a,truncateNumbersWithPound:r}=this.state,c=e.filter(Mm).map(Nm)??[],{settings:h,saveSettings:u}=this.props,m={...h,formatter:c,defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:s,timeZone:i,truncateNumbersWithPound:r};Ms(x.dataType.DECIMAL,Re.makeCustomFormat(o.defaultFormatString))&&(m.defaultDecimalFormatOptions=o),Ms(x.dataType.INT,Ge.makeCustomFormat(a.defaultFormatString))&&(m.defaultIntegerFormatOptions=a),u(m)}render(){const{defaults:e}=this.props,{defaultDateTimeFormat:t,defaultDecimalFormatOptions:n,defaultIntegerFormatOptions:s,timeZone:i,showTimeZone:o,showTSeparator:a,truncateNumbersWithPound:r}=this.state,{defaultFormatString:c=Re.DEFAULT_FORMAT_STRING}=n??{},{defaultFormatString:h=Ge.DEFAULT_FORMAT_STRING}=s??{},u=i===e.timeZone,m=a===e.showTSeparator&&o===e.showTimeZone&&t===e.defaultDateTimeFormat,g=Ox(n,e.defaultDecimalFormatOptions),p=Ax(s,e.defaultIntegerFormatOptions);return l.jsx("div",{className:"app-settings-formatting-section",ref:this.containerRef,children:l.jsxs("div",{className:"container-fluid p-0",children:[l.jsx("div",{className:"app-settings-menu-description mb-3",children:"Choose the default formatting rule to apply to all table columns based on their type."}),l.jsxs("div",{className:"form-row mb-2",children:[l.jsx("label",{className:"col-form-label col-3",htmlFor:"select-reset-timezone",children:"Time zone"}),l.jsx("div",{className:"col pr-0",children:l.jsx("select",{className:"custom-select",value:i,onChange:this.handleTimeZoneChange,id:"select-reset-timezone",children:l.jsx(Lx,{})})}),l.jsx("div",{className:"col-1 btn-col",children:l.jsx(B,{kind:"ghost",icon:si,onClick:this.handleResetTimeZone,tooltip:"Reset Time Zone",className:$("btn-reset","btn-reset-time-zone",{hidden:u})})})]}),l.jsxs("div",{className:"form-row mb-2",children:[l.jsx("label",{className:"col-form-label col-3",htmlFor:"select-default-time-format",children:"DateTime"}),l.jsx("div",{className:"col pr-0",children:l.jsx("select",{className:"custom-select",value:t,onChange:this.handleDefaultDateTimeFormatChange,id:"select-default-time-format",children:this.getCachedDateTimeFormatOptions(i,o,a,!0,t)})}),l.jsx("div",{className:"col-1 btn-col",children:l.jsx(B,{kind:"ghost",icon:si,onClick:this.handleResetDateTimeFormat,tooltip:"Reset DateTime Options",className:$("btn-reset","btn-reset-date-time",{hidden:m})})})]}),l.jsx("div",{className:"form-row",children:l.jsx("div",{className:"offset-3 col-9",children:l.jsx(Zt,{checked:o??null,onChange:this.handleShowTimeZoneChange,children:"Show time zone in dates"})})}),l.jsx("div",{className:"form-row mb-3",children:l.jsx("div",{className:"offset-3 col-9",children:l.jsx(Zt,{checked:a??null,onChange:this.handleShowTSeparatorChange,children:"Show 'T' separator"})})}),l.jsxs("div",{className:"form-row mb-2",children:[l.jsx("label",{className:"col-form-label col-3",htmlFor:"default-decimal-format-input",children:"Decimal"}),l.jsx("div",{className:"col pr-0",children:l.jsx("input",{className:$("form-control","flex-grow-1","default-decimal-format-input",{"is-invalid":!Ms(x.dataType.DECIMAL,Re.makeCustomFormat(c))}),"data-lpignore":!0,placeholder:Re.DEFAULT_FORMAT_STRING,type:"text",id:"default-decimal-format-input",value:c,onChange:this.handleDefaultDecimalFormatChange})}),l.jsx("div",{className:"col-1 btn-col",children:l.jsx(B,{kind:"ghost",icon:si,onClick:this.handleResetDecimalFormat,tooltip:"Reset Decimal Formatting",className:$("btn-reset","btn-reset-decimal",{hidden:g}),"data-testid":"btn-reset-decimal"})})]}),l.jsxs("div",{className:"form-row mb-2",children:[l.jsx("label",{className:"col-form-label col-3",htmlFor:"default-integer-format-input",children:"Integer"}),l.jsx("div",{className:"col pr-0",children:l.jsx("input",{className:$("form-control","flex-grow-1","default-integer-format-input",{"is-invalid":!Ms(x.dataType.INT,Ge.makeCustomFormat(h))}),"data-lpignore":!0,placeholder:Ge.DEFAULT_FORMAT_STRING,type:"text",id:"default-integer-format-input",value:h,onChange:this.handleDefaultIntegerFormatChange})}),l.jsx("div",{className:"col-1 btn-col",children:l.jsx(B,{kind:"ghost",icon:si,onClick:this.handleResetIntegerFormat,tooltip:"Reset Integer Formatting",className:$("btn-reset","btn-reset-integer",{hidden:p}),"data-testid":"btn-reset-integer"})})]}),l.jsx("div",{className:"form-row mb-3",children:l.jsx("div",{className:"offset-3 col-9",children:l.jsx(Zt,{checked:r??null,onChange:this.handleTruncateNumbersWithPoundChange,children:"Truncate numbers with #"})})})]})})}}const Px=d=>({formatter:mu(d),defaultDateTimeFormat:du(d),defaultDecimalFormatOptions:hu(d),defaultIntegerFormatOptions:uu(d),showTimeZone:gu(d),showTSeparator:pu(d),truncateNumbersWithPound:fu(d),timeZone:Lo(d),settings:St(d)}),_x=Ct(Px,{saveSettings:pr})(Fc);function jx(){const[d,e]=b.useState(!1),t=()=>{e(!d)};return l.jsxs(B,{kind:"ghost",onClick:t,icon:Ep,children:["Legal Notices",l.jsxs(zi,{isOpen:d,toggle:t,className:"theme-bg-light",children:[l.jsx(Mo,{toggle:t,children:"Legal Notice"}),l.jsxs(Ki,{children:[l.jsx("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."}),l.jsxs("p",{children:["© 2016-",new Date().getFullYear()," Deephaven Data Labs LLC. Patent Pending."]})]})]})]})}function xo(d){const{children:e,isExpanded:t,sectionKey:n,title:s,onToggle:i}=d;return l.jsxs(l.Fragment,{children:[l.jsx("div",{children:l.jsxs(B,{kind:"ghost",className:"btn-collapse-trigger",onClick:()=>i(n),children:[l.jsx("div",{className:"flex-grow-1",children:s}),l.jsx("div",{className:"flex-shrink-0",children:l.jsx(Q,{transform:t?"flip-v":"",icon:Pn})})]})}),l.jsx(gf,{in:t,autoFocusOnShow:!0,children:e})]})}xo.propTypes={children:I.node,isExpanded:I.bool.isRequired,sectionKey:I.string.isRequired,title:I.node.isRequired,onToggle:I.func};xo.defaultProps={children:null,onToggle:()=>{}};function Hx({shortcut:d,displayText:e,categoryName:t,onChange:n}){const[s,i]=b.useState(e),[o,a]=b.useState(d.getKeyState()),[r,c]=b.useState(!1),[h,u]=b.useState("");b.useEffect(function(){i(e),a(d.getKeyState())},[e,d]),b.useEffect(function(){i(Ae.getDisplayText(o)),d.matchesKeyState(o)&&c(!1)},[o,d]),b.useEffect(function(){if(r){if(!Ae.isValidKeyState(o)){Ae.isAllowedKey(o.keyValue)?u("Must contain a modifier key"):u("Must contain an allowed action key");return}const T=Ne.getConflictingShortcuts(o).filter(y=>y.id.startsWith(t)&&y!==d).map(y=>y.name);if(T.length){u(`Conflicts with ${T.join(", ")}`);return}u("")}else u("")},[r,o,t,d]);function m(w){if(w.stopPropagation(),w.preventDefault(),d.isEditable&&!w.repeat){const T=Ae.getKeyStateFromEvent(w),y=Ae.createKeyState([ue.BACKSPACE]);Ae.doKeyStatesMatch(T,y)?a(Ae.NULL_KEY_STATE):a(T)}}function g(w){w.stopPropagation(),w.preventDefault(),d.matchesKeyState(o)||c(!0)}function p(){Ve.disableAllActions()}function C(){Ve.enableAllActions()}function f(){d.setKeyState(o),c(!1),n(d)}function S(){const w=d.getKeyState();a(w),c(!1)}function v(){c(!0),a(d.getDefaultKeyState())}return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"shortcut-item-container",children:[l.jsxs("label",{className:"shortcut-item-name",children:[d.name,d.tooltip!==void 0&&l.jsx(tt,{children:d.tooltip})]}),l.jsxs("div",{className:"shortcut-item-input-container",children:[l.jsx("input",{className:$("form-control",{"is-invalid":h}),onKeyDown:m,onKeyUp:g,onFocus:p,onBlur:C,disabled:!d.isEditable,value:s,readOnly:!0}),!Ae.doKeyStatesMatch(o,d.getDefaultKeyState())&&!h&&l.jsx(B,{className:"reset-to-default-button",kind:"ghost",icon:l.jsx(Q,{icon:si,transform:{rotate:90,flipX:!0}}),tooltip:"Reset to default",onClick:v})]})]}),r&&l.jsxs("div",{className:$("shortcut-item-message-container",{"is-invalid":h}),children:[l.jsx("div",{className:"shortcut-item-message",children:h}),l.jsxs("div",{className:"shortcut-item-message-buttons",children:[Ae.isValidKeyState(o)&&l.jsx(B,{kind:"ghost",onClick:f,children:"Confirm"}),l.jsx(B,{kind:"ghost",onClick:S,children:"Undo"})]})]})]})}function Vx({shortcutOverrides:d={},settings:e,saveSettings:t}){const n=b.useCallback(a=>{const r=Ae.isMacPlatform,c={mac:{...d.mac},windows:{...d.windows}},h=r?c.mac:c.windows;a.forEach(u=>{u.isDefault()?delete h[u.id]:h[u.id]=u.getKeyState()}),t({...e,shortcutOverrides:c})},[e,t,d]);let s=Array.from(Ne.shortcutsByCategory.entries()).map(([a,r])=>({name:a,shortcuts:r}));const i=s.findIndex(a=>a.name.toUpperCase()==="GLOBAL"),o=s.splice(i,1);return s=s.concat(o),l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"app-settings-menu-description",children:"Customize shortcuts below. To prevent unexpected results, avoid conflicting shortcuts with the browser or IDE editor."}),s.map(a=>l.jsx(Bx,{name:a.name,shortcuts:a.shortcuts,saveShortcutOverrides:n},a.name))]})}function Bx({name:d,shortcuts:e,saveShortcutOverrides:t}){function n(r){return r.split("_").map(c=>`${c[0].toUpperCase()}${c.slice(1).toLowerCase()}`).join(" ")}const[s,i]=b.useState(e);function o(r){const c=s.filter(u=>u!==r&&!u.isNull()&&u.matchesKeyState(r.getKeyState()));c.forEach(u=>u.setToNull());const h=[r,...c];t(h),i(u=>[...u])}const a=b.useMemo(()=>s.map(r=>r.getDisplayText()),[s]);return l.jsxs("div",{className:"mt-3",children:[l.jsx("div",{className:"font-weight-bold",children:n(d)}),s.map((r,c)=>l.jsx(Hx,{shortcut:r,displayText:a[c],categoryName:d,onChange:o},r.id))]})}const Ux=d=>({settings:St(d),shortcutOverrides:KS(d)}),$x={saveSettings:pr},Wx=Ct(Ux,$x)(Vx),Gx="yyyy-MM-dd-HHmmss";function Om(d,e="root",t=new Map([[d,""]])){const n={};return Object.entries(d).forEach(([s,i])=>{try{JSON.stringify(i),n[s]=i}catch{const a=i;if(typeof i=="bigint")n[s]=i.toString();else if(t.has(a))n[s]=`Circular ref to ${t.get(a)}`;else{const r=`${e}.${s}`;t.set(a,r),n[s]=Om(i,r,t)}}}),n}function zx(){const d=Cr.getState();return JSON.stringify(Om(d),null,2)}function Kx(d){const e={uiVersion:"0.35.0",userAgent:navigator.userAgent,...d};return JSON.stringify(e,null,2)}async function qx(d=`${R.i18n.DateTimeFormat.format(Gx,new Date)}_support_logs`,e){const t=new xh,n=t.folder(d);n.file("console.txt",yp.getFormattedHistory()),n.file("redux.json",zx()),n.file("metadata.json",Kx(e));const s=await t.generateAsync({type:"blob"}),i=document.createElement("a");i.href=URL.createObjectURL(s),i.download=`${d}.zip`,i.click()}const Yx=[{value:x.dataType.DATETIME,label:"DateTime"},{value:x.dataType.DECIMAL,label:"Decimal"},{value:x.dataType.INT,label:"Integer"}];function Xx(){const d=Yx.map(e=>l.jsx("option",{value:e.value,children:e.label},`key-columnType-${e.value}`));return l.jsxs(l.Fragment,{children:[l.jsx("option",{disabled:!0,value:"",children:"Select Type"},"key-columnType-placeholder"),d]})}class Nc extends b.PureComponent{static defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:je.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:Re.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:Ge.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:je.DEFAULT_TIME_ZONE_ID}};static inputDebounceTime=250;constructor(e){super(e),this.debouncedCommitChanges=Ye(this.commitChanges.bind(this),Nc.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:t,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,showTimeZone:o,showTSeparator:a,timeZone:r,truncateNumbersWithPound:c}=e,h=t.map((u,m)=>({...u,id:m}));this.containerRef=J.createRef(),this.addFormatRuleButtonRef=J.createRef(),this.lastFormatRuleIndex=h.length,this.state={formatSettings:h,formatRulesChanged:!1,showTimeZone:o,showTSeparator:a,timeZone:r,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,truncateNumbersWithPound:c,timestampAtMenuOpen:new Date}}componentDidMount(){El(this.containerRef.current)}componentWillUnmount(){this.debouncedCommitChanges.flush()}debouncedCommitChanges;containerRef;addFormatRuleButtonRef;lastFormatRuleIndex;isDuplicateRule(e){const{formatSettings:t}=this.state;return t.some(n=>n.id!==e.id&&n.columnName===e.columnName&&n.columnType===e.columnType)??!1}getAutoIncrementFormatRuleIndex(){const{lastFormatRuleIndex:e}=this;return this.lastFormatRuleIndex+=1,e}getCachedColumnTypeOptions=ge(()=>l.jsx(Xx,{}));getCachedDateTimeFormatOptions=ge((e,t,n,s=!1,i)=>{const{timestampAtMenuOpen:o}=this.state;return l.jsx(km,{timestamp:o,timeZone:e,showTimeZone:t,showTSeparator:n,isGlobalOptions:s,legacyGlobalFormat:i})});handleFormatRuleChange(e,t,n){this.setState(s=>{const{formatSettings:i}=s;M(i);const o=[...i];let a={};t==="columnType"&&(a={format:""});const r={...o[e],...a,[t]:n};return o[e]=r,{formatSettings:o}},()=>{this.debouncedCommitChanges()})}handleFormatRuleCreate(){this.setState(e=>{const{formatSettings:t}=e,n={columnType:x.dataType.DATETIME,columnName:"",format:{},id:this.getAutoIncrementFormatRuleIndex(),isNewRule:!0};return{formatSettings:[...t,n],formatRulesChanged:!0}})}handleFormatRuleDelete(e){this.setState(t=>{const{formatSettings:n}=t;return{formatSettings:n.filter((i,o)=>o!==e),formatRulesChanged:!0}},()=>{this.debouncedCommitChanges()})}handleFormatRuleEntered(e){this.scrollToFormatBlockBottom(),El(e)}commitChanges(){const{formatSettings:e,defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:s,timeZone:i,defaultDecimalFormatOptions:o,defaultIntegerFormatOptions:a,truncateNumbersWithPound:r}=this.state,c=e.filter(Mm).map(Nm)??[],{settings:h,saveSettings:u}=this.props,m={...h,formatter:c,defaultDateTimeFormat:t,showTimeZone:n,showTSeparator:s,timeZone:i,truncateNumbersWithPound:r};Ms(x.dataType.DECIMAL,Re.makeCustomFormat(o.defaultFormatString))&&(m.defaultDecimalFormatOptions=o),Ms(x.dataType.INT,Ge.makeCustomFormat(a.defaultFormatString))&&(m.defaultIntegerFormatOptions=a),u(m)}scrollToFormatBlockBottom(){const{scrollTo:e}=this.props;e(0,(this.addFormatRuleButtonRef.current?.offsetHeight??0)+(this.addFormatRuleButtonRef.current?.offsetTop??0))}getRuleError(e){const t={hasColumnNameError:!1,hasFormatError:!1,message:""},n=[];return e.isNewRule!==void 0&&e.isNewRule||(this.isDuplicateRule(e)&&(t.hasColumnNameError=!0,n.push("Duplicate column name/type combo.")),Fm(e.columnName)||(t.hasColumnNameError=!0,n.push("Column names must start with a letter or underscore and contain only alphanumeric characters or underscores.")),e.format.formatString!==void 0&&e.format.formatString.length===0?(t.hasFormatError=!0,n.push("Empty formatting rule.")):Ms(e.columnType,e.format)||(t.hasFormatError=!0,n.push("Invalid formatting rule.")),t.message=n.join(`
39
- `)),t}renderFormatRule(e,t){const n=`input-${e}-columnName`,s=`input-${e}-columnType`,i=`input-${e}-format`,o=this.getCachedColumnTypeOptions(),a=u=>this.handleFormatRuleChange(e,"columnName",u.target.value),r=()=>this.handleFormatRuleChange(e,"isNewRule",!1),c=u=>this.handleFormatRuleChange(e,"columnType",u.target.value),h=this.getRuleError(t);return l.jsxs("fieldset",{className:"container-fluid format-rule-container",children:[l.jsxs("div",{className:"form-row",children:[l.jsxs("div",{className:"form-group col-7 mb-2",children:[l.jsx("label",{htmlFor:n,children:"Column Name"}),l.jsx("input",{id:n,className:$("form-control",{"is-invalid":h.hasColumnNameError}),"data-lpignore":!0,type:"text",value:t.columnName,onChange:a,onBlur:r})]}),l.jsxs("div",{className:"form-group col mb-2",children:[l.jsx(B,{kind:"ghost",className:"btn-delete-format-rule float-right",tabIndex:-1,onClick:()=>this.handleFormatRuleDelete(e),icon:Jt,tooltip:"Delete","aria-label":"Delete Format Rule"}),l.jsx("label",{htmlFor:s,children:"Column Type"}),l.jsx("select",{id:s,className:"custom-select",value:t.columnType,onChange:c,children:o})]})]}),l.jsx("div",{className:"form-row",children:l.jsxs("div",{className:"form-group col-12 d-flex mb-2",children:[l.jsx("label",{className:"flex-shrink-0 col-form-label mr-3",htmlFor:i,children:"Formatting Rule"}),this.renderFormatRuleInput(e,t.columnType,i,t.format,h.hasFormatError)]})}),l.jsx("div",{className:"form-row",children:l.jsx("div",{className:"form-group col-12 d-flex mb-2",children:h.message&&l.jsx("p",{className:"text-danger",children:h.message})})})]},e)}renderFormatRuleInput(e,t,n,s,i){switch(x.getNormalizedType(t)){case x.dataType.DATETIME:return this.renderDateTimeFormatRuleInput(e,n,s,i);case x.dataType.DECIMAL:return this.renderDecimalFormatRuleInput(e,n,s,i);case x.dataType.INT:return this.renderIntegerFormatRuleInput(e,n,s,i);default:throw new Error(`Unrecognized column type: ${t}`)}}renderDateTimeFormatRuleInput(e,t,n,s){const{showTimeZone:i,showTSeparator:o,timeZone:a}=this.state,r=n.formatString??"";return l.jsxs("select",{className:$("custom-select",{"is-invalid":s}),value:r,id:t,onChange:c=>{const h=je.makeFormat("",c.target.value,je.TYPE_GLOBAL);this.handleFormatRuleChange(e,"format",h)},children:[l.jsx("option",{value:"",disabled:!0,children:"Select format"},"default"),this.getCachedDateTimeFormatOptions(a,i,o)]})}renderIntegerFormatRuleInput(e,t,n,s){const i=n.formatString??"";return l.jsx("input",{className:$("form-control","flex-grow-1",{"is-invalid":s}),"data-lpignore":!0,id:t,placeholder:Ge.DEFAULT_FORMAT_STRING,type:"text",value:i,onChange:o=>{const a=Ge.makeFormat("",o.target.value,Ge.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(e,"format",a)}})}renderDecimalFormatRuleInput(e,t,n,s){const i=n.formatString??"";return l.jsx("input",{className:$("form-control","flex-grow-1",{"is-invalid":s}),"data-lpignore":!0,id:t,placeholder:Re.DEFAULT_FORMAT_STRING,type:"text",value:i,onChange:o=>{const a=Re.makeFormat("",o.target.value,Re.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(e,"format",a)}})}render(){const{formatRulesChanged:e,formatSettings:t}=this.state,n=t.map((i,o)=>l.jsx(ft,{classNames:"fade",timeout:ze.transitionMs,onEnter:this.handleFormatRuleEntered,children:this.renderFormatRule(o,i)},i.id)),s=l.jsx(B,{kind:"ghost",className:"mb-3",onClick:this.handleFormatRuleCreate,ref:this.addFormatRuleButtonRef,icon:Ps,children:"Add New Rule"});return l.jsxs("div",{className:"app-settings-formatting-section",ref:this.containerRef,children:[l.jsx("div",{className:"app-settings-menu-description mb-3",children:"Customize the formatting of table columns by applying rules based on matching both a column name and column type."}),l.jsx(mg,{appear:e,enter:e,exit:e,children:n}),s]})}}const Zx=d=>({formatter:mu(d),defaultDateTimeFormat:du(d),defaultDecimalFormatOptions:hu(d),defaultIntegerFormatOptions:uu(d),showTimeZone:gu(d),showTSeparator:pu(d),truncateNumbersWithPound:fu(d),timeZone:Lo(d),settings:St(d)}),Qx=Ct(Zx,{saveSettings:pr})(Nc);class On extends b.Component{static defaultProps={onDone:()=>{}};static FORMATTING_SECTION_KEY="SettingsMenu.formatting";static COLUMN_SPECIFIC_SECTION_KEY="SettingsMenu.columnFormatting";static APPLICATION_SECTION_KEY="ApplicationMenu.settings";static SHORTCUT_SECTION_KEY="SettingsMenu.shortcuts";static focusFirstInputInContainer(e){const t=e?.querySelector("input, select, textarea");t&&t.focus()}constructor(e){super(e),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=J.createRef(),this.state={expandedSectionKey:On.FORMATTING_SECTION_KEY}}componentDidMount(){On.focusFirstInputInContainer(this.menuContentRef.current)}menuContentRef;isSectionExpanded(e){const{expandedSectionKey:t}=this.state;return t===e}handleScrollTo(e,t){this.menuContentRef.current?.scrollTo(e,t)}handleSectionToggle(e){this.setState(t=>({expandedSectionKey:t.expandedSectionKey===e?void 0:e}))}handleClose(){const{onDone:e}=this.props;e()}handleExportSupportLogs(){const{serverConfigValues:e}=this.props;qx(void 0,Object.fromEntries(e))}render(){const e="0.35.0",t="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"),a=s.get("deephaven.version"),r=(c,h)=>l.jsxs(l.Fragment,{children:[l.jsx("div",{children:c}),l.jsx("div",{children:h})]});return l.jsxs("div",{className:"app-settings-menu",children:[l.jsxs("header",{className:"app-settings-menu-header",children:[l.jsx("div",{className:"flex-spacer"}),l.jsx(B,{kind:"ghost",className:"btn-close-settings-menu",onClick:this.handleClose,icon:l.jsx(Q,{icon:qi,transform:"grow-4"}),tooltip:"Close"})]}),l.jsxs("div",{className:"app-settings-menu-content",ref:this.menuContentRef,children:[l.jsx("h5",{children:"Settings"}),l.jsx("hr",{className:"my-0"}),l.jsx(xo,{sectionKey:On.FORMATTING_SECTION_KEY,isExpanded:this.isSectionExpanded(On.FORMATTING_SECTION_KEY),title:l.jsxs(l.Fragment,{children:[l.jsx(Q,{icon:Rp,transform:"grow-4",className:"mr-2"}),"Default Format & Time zone"]}),onToggle:this.handleSectionToggle,children:l.jsx(_x,{})}),l.jsx(xo,{sectionKey:On.COLUMN_SPECIFIC_SECTION_KEY,isExpanded:this.isSectionExpanded(On.COLUMN_SPECIFIC_SECTION_KEY),title:l.jsxs(l.Fragment,{children:[l.jsx(Q,{icon:xp,transform:"grow-4",className:"mr-2"}),"Format by Column Name & Type"]}),onToggle:this.handleSectionToggle,children:l.jsx(Qx,{scrollTo:this.handleScrollTo})}),l.jsx(xo,{sectionKey:On.SHORTCUT_SECTION_KEY,isExpanded:this.isSectionExpanded(On.SHORTCUT_SECTION_KEY),title:l.jsxs(l.Fragment,{children:[l.jsx(Q,{icon:Ip,transform:"grow-2"})," ","Keyboard Shortcuts"]}),onToggle:this.handleSectionToggle,children:l.jsx(Wx,{})}),l.jsxs("div",{className:"app-settings-footer",children:[l.jsxs("div",{className:"app-settings-footer-section",children:[l.jsxs("div",{className:"app-settings-footer-item",children:[l.jsx("div",{className:"font-weight-bold",children:"Support"}),l.jsxs("div",{children:["GitHub: ",l.jsx("a",{href:t,className:"custom-link",target:"_blank",rel:"noopener noreferrer",children:t})]}),l.jsx(B,{kind:"tertiary",className:"mt-2 py-2",onClick:this.handleExportSupportLogs,children:"Export Logs"})]}),l.jsxs("div",{className:"app-settings-footer-item",children:[l.jsx("div",{className:"font-weight-bold",children:"Documentation"}),l.jsx("a",{target:"_blank",rel:"noreferrer noopener",href:n,className:"custom-link",children:n})]}),l.jsxs("div",{className:"app-settings-footer-item",children:[l.jsx("div",{className:"font-weight-bold",children:"Version"}),l.jsxs("span",{className:"d-inline-block text-muted",children:[a," ",l.jsx(Q,{icon:Dp}),l.jsxs(tt,{interactive:!0,children:[l.jsxs("div",{className:"detailed-server-config",children:[r("Engine Version",a),r("Web UI Version",e),r("Java Version",o),r("Barrage Version",i)]}),l.jsx(dr,{tooltip:"Copy version numbers",copy:`Engine Version: ${a}
40
- Web UI Version: ${e}
41
- Java Version: ${o}
42
- Barrage Version: ${i}`,children:"Copy Versions"})]})]})]}),l.jsx("div",{className:"app-settings-footer-item",children:l.jsx(jx,{})})]}),l.jsx("div",{className:"app-settings-footer-section",children:l.jsx("div",{className:"logo",children:l.jsx("a",{target:"_blank",rel:"noreferrer noopener",href:"https://deephaven.io",className:"d-inline-block custom-link p-1",children:l.jsx("img",{src:Im,alt:"Deephaven Data Labs",width:"230px"})})})})]})]})]})}}const bh=10;function ki(d){const{forwardedProps:{menuItem:{action:e,title:t,disabled:n},iconElement:s,displayShortcut:i,isMouseSelected:o,isKeyboardSelected:a,closeMenu:r}}=d,c=b.useRef(),h=b.useRef(),u=b.useRef(null),[m,g]=b.useState(!1),p=b.useCallback(S=>{c.current!=null&&h.current!=null&&u.current&&(Math.abs(c.current-S.clientX)>=bh||Math.abs(h.current-S.clientY)>=bh)&&(g(!0),window.removeEventListener("mousemove",p),r(),e(S),u.current=null)},[e,r]);function C(S){c.current=S.clientX,h.current=S.clientY,u.current=S.target,window.addEventListener("mousemove",p)}function f(S){u.current===S.target&&(g(!0),r(),e(),window.removeEventListener("mousemove",p)),u.current=null}return b.useEffect(function(){return function(){return window.removeEventListener("mousemove",p)}},[p]),l.jsxs("button",{type:"button",className:$("btn-context-menu",{disabled:n},{active:o&&!n},{"keyboard-active":a&&!n}),onMouseDown:C,onMouseUp:f,disabled:m,children:[l.jsx("span",{className:$("icon"),children:s}),l.jsx("span",{className:"title",children:t}),l.jsx("span",{className:"shortcut",children:i})]})}function Mc(d){const{handleControlSelect:e,handleToolSelect:t,onClearFilter:n}=d,s=b.useMemo(()=>[{title:"Input Filter",icon:Fp,menuElement:l.jsx(ki,{}),action:i=>{e(Ns.INPUT_FILTER,i)},order:10},{title:"Dropdown Filter",icon:Ph,menuElement:l.jsx(ki,{}),action:i=>{e(Ns.DROPDOWN_FILTER,i)},order:15},{title:"Markdown Widget",icon:Np,menuElement:l.jsx(ki,{}),action:i=>{e(Ns.MARKDOWN,i)},order:20},{title:"Filter Sets",icon:cl,menuElement:l.jsx(ki,{}),action:i=>{e(Ns.FILTER_SET_MANAGER,i)},order:25},{disabled:!0,menuElement:l.jsx("div",{className:"context-menu-group-header",children:"Tools"}),order:30},{title:"Linker",icon:Fl,action:()=>{t(Vt.LINKER)},order:40,shortcut:ss.LINKER},{disabled:!0,menuElement:l.jsx("div",{className:"context-menu-group-header",children:"Actions"}),order:50},{title:"Clear All Filters",icon:Mp,action:()=>{n()},order:60,shortcut:qt.TABLE.CLEAR_ALL_FILTERS}],[e,t,n]);return l.jsx(es,{popperClassName:"controls-menu-popper",actions:s})}Mc.propTypes={handleControlSelect:I.func,handleToolSelect:I.func,onClearFilter:I.func};Mc.defaultProps={handleControlSelect:()=>{},handleToolSelect:()=>{},onClearFilter:()=>{}};ki.propTypes={forwardedProps:I.shape({iconElement:I.node,displayShortcut:I.string,isMouseSelected:I.bool.isRequired,isKeyboardSelected:I.bool.isRequired,closeMenu:I.func.isRequired,menuItem:I.shape({action:I.func,title:I.string,disabled:I.bool}).isRequired})};ki.defaultProps={forwardedProps:null};const Jx=js(xm,null),eI={layoutStorage:Jx},tI=d=>d.layoutStorage,nI=d=>d.serverConfigValues;Object.entries(eI).map(([d,e])=>Zi.register(d,e));const wh=10;function sI(d){const{onExportLayout:e,onImportLayout:t,onResetLayout:n,onSelect:s,widgets:i=[]}=d,[o,a]=b.useState(!1),[r,c]=b.useState(""),h=b.useRef(null),u=b.useRef(),m=b.useCallback((T,y)=>{T!=null&&s(T,y)},[s]),g=b.useCallback(T=>{c(T.target.value)},[]),p=b.useCallback(T=>{u.current!=null&&(Math.abs(u.current.x-T.clientX)>=wh||Math.abs(u.current.y-T.clientY)>=wh)&&(a(!0),window.removeEventListener("mousemove",p),m(u.current.widget,T),u.current=void 0)},[u,m]),C=b.useCallback((T,y)=>{u.current={x:T.clientX,y:T.clientY,widget:y},window.addEventListener("mousemove",p)},[p]),f=b.useCallback((T,y)=>{window.removeEventListener("mousemove",p),u.current?.widget===y&&(a(!0),m(y)),u.current=void 0},[p,u,m]),S=b.useMemo(()=>i.filter(T=>r?T.name?.toLowerCase().includes(r.toLowerCase()):!0),[r,i]).sort((T,y)=>T.name?.localeCompare(y.name??"")??0),v=b.useMemo(()=>S.map(T=>l.jsx("li",{children:l.jsxs(B,{kind:"ghost","data-testid":`panel-list-item-${T.name??""}-button`,onMouseDown:y=>{C(y,T)},onMouseUp:y=>{f(y,T)},onKeyDown:y=>{(y.key==="Enter"||y.key===" ")&&m(T)},disabled:o,onClick:()=>{},children:[l.jsx(Xh,{type:T.type})," ",T.name??""]})},T.name)),[S,o,C,f,m]),w=b.useMemo(()=>v.length===0?l.jsx("span",{children:"No bound variables found."}):null,[v]);return l.jsxs("div",{className:"widget-list-container d-flex flex-column",children:[l.jsx("div",{className:"widget-list-header",children:l.jsx(_s,{value:r,placeholder:"Find Table, Plot or Widget",onChange:g,ref:h})}),l.jsxs("ul",{className:"widget-list flex-grow-1",children:[w&&l.jsx("li",{className:"widget-list-message",children:w}),!w&&v]}),l.jsx("div",{children:l.jsx("hr",{})}),l.jsxs("div",{className:"widget-list-footer",children:[l.jsxs(B,{kind:"ghost",onClick:e,children:[l.jsxs("div",{className:"fa-md fa-layers",children:[l.jsx(Q,{mask:ll,icon:Wc,transform:"right-5 down-5"}),l.jsx(Q,{icon:Wc,transform:"right-8 down-6"})]}),"Export Layout"]}),l.jsxs(B,{kind:"ghost",onClick:t,children:[l.jsxs("div",{className:"fa-md fa-layers",children:[l.jsx(Q,{mask:ll,icon:dl,transform:"right-5 down-5"}),l.jsx(Q,{icon:dl,transform:"right-8 down-6"})]}),"Import Layout"]}),l.jsx(B,{kind:"ghost",icon:si,onClick:n,tooltip:"Reset Layout"})]})]})}const iI=async(d,e,t)=>{let n,s,i,o;if(Ra(e)?(n=e.settings,s=e.table,i=void 0,o=e.tableSettings):(n={},s="",i=e.figure,o={}),t!==void 0&&(t.tableSettings!=null&&(o=t.tableSettings),t.table!=null&&(s=t.table),t.figure!=null&&(i=t.figure),t.settings!=null&&(n={...n,...t.settings})),i!==void 0){const c={title:i,name:i,type:R.VariableType.FIGURE},h=await d.getObject(c);return ja.makeModel(n,h)}const a={title:i,name:s,type:R.VariableType.TABLE},r=await d.getObject(a);return be.applyTableSettings(r,o,Lo(Cr.getState())),ja.makeModelFromSettings(n,r)},oI=async(d,e,t=R.VariableType.TABLE)=>{const{table:n}=e,s={title:n,name:n,type:t},i=await d.getObject(s);return Cc.makeModel(i)};function aI({onAutoFillClick:d=()=>{}}){return l.jsxs("div",{className:"empty-dashboard-container",children:[l.jsxs("div",{className:"hint-container",children:[l.jsx(Q,{icon:Lh})," ",l.jsx("br",{}),"Use the panel list to add objects from a query."]}),l.jsxs("div",{className:"empty-dashboard",children:[l.jsx("div",{className:"add-panels-hint",children:"Drag Panels Here"}),l.jsx(B,{kind:"tertiary",onClick:d,children:"Auto fill objects"})]})]})}function rI(d){return d.version===2}function lI(d){return Array.isArray(d)}const va=Z.module("UserLayoutUtils"),cI={layoutConfig:[{type:"column",content:[{type:"row",height:40,content:[{type:"stack",content:[{type:"react-component",component:Mi.COMPONENT,title:Mi.TITLE,isClosable:!1},{type:"react-component",component:Ja.COMPONENT,title:Ja.TITLE,isClosable:!1}]},{type:"stack",width:25,content:[{type:"react-component",component:Ka.COMPONENT,title:Ka.TITLE,isClosable:!1},{type:"react-component",component:Ya.COMPONENT,title:Ya.TITLE,isClosable:!1}]}]},{type:"row",content:[{type:"stack",title:"Notebooks",content:[]}]}]}],links:[],filterSets:[],version:2},dI={layoutConfig:[],links:[],filterSets:[],version:2};function Am(d){if(rI(d))return d;if(lI(d))return{layoutConfig:d,links:[],filterSets:[],version:2};throw new Error(`Unexpected layout import format: ${d}`)}async function hI(d,e=!0){try{const t=await d.getLayouts();if(t.length>0)try{const n=await d.getLayout(t[0]);return Am(n)}catch(n){va.error("Unable to load layout",t[0],":",n),va.warn("No valid layouts found, falling back to default layout")}}catch(t){va.error("Unable to fetch layout list",t),va.warn("Falling back to default layout")}return e?cI:dI}function uI(d){const{filterSets:e,layoutConfig:t,links:n}=d;return{filterSets:e,layoutConfig:t,links:n,version:2}}const Ia={exportLayout:uI,getDefaultLayout:hI,normalizeLayout:Am},Ta=Z.module("DownloadServiceWorkerUtils");class No{static DOWNLOAD_PATH="/download/";static registerOnLoaded(){new URL("/ide/",window.location.href).origin===window.location.origin&&("serviceWorker"in navigator?window.addEventListener("load",()=>{const t=new URL("/ide/download/serviceWorker.js",window.location.href);navigator.serviceWorker.register(t).then(n=>{n.update(),Ta.info("Registering service worker on ",t,n)}).catch(n=>{Ta.error("Failed to register service worker",n)})}):Ta.info("Service worker is not supported."))}static async getServiceWorker(){if("serviceWorker"in navigator){const t=(await navigator.serviceWorker.getRegistrations()).find(n=>n.scope.endsWith(No.DOWNLOAD_PATH));if(t&&t.active)return Ta.info("Download service worker is active."),t.active;throw new Error("Can not find download service worker.")}throw new Error("Download service worker is not available.")}static unregisterSW(){}}const Lm={react:J,"react-dom":Bi,redux:gg,"react-redux":pg},mI=fg(Lm),gI=Cg({requires:mI}),pI=Sg.createRequires(Lm),fI=bg({requires:pI}),CI=Z.module("PluginUtils");class yl{static loadComponentPlugin(e){const t=new URL("/ide/plugins/",`${window.location}`),n=new URL(`${e}.js`,t),s=J.forwardRef((i,o)=>l.jsx(gI,{url:n,render:({err:a,Component:r})=>{if(a!=null&&a!==""){const c=`Error loading plugin ${e} from ${n} due to ${a}`;return CI.error(c),l.jsx("div",{className:"error-message",children:`${c}`})}return l.jsx(r,{ref:o,...i})}}));return s.pluginName=e,s.displayName="Plugin",s}static async loadModulePlugin(e){return await fI(e)}static async loadJson(e){return new Promise((t,n)=>{const s=new XMLHttpRequest;s.addEventListener("load",()=>{try{const i=JSON.parse(s.responseText);t(i)}catch(i){n(i)}}),s.addEventListener("error",i=>{n(i)}),s.open("GET",e),s.send()})}}const Et=Z.module("AppMainContainer");class Oi extends b.Component{static handleWindowBeforeUnload(e){e.preventDefault(),e.returnValue=""}static hydrateConsole(e,t){return Sl.hydrate({...e,unzip:n=>xh.loadAsync(n).then(s=>Object.values(s.files))},t)}static handleRefresh(){Et.info("Refreshing application"),window.location.reload()}constructor(e){super(e),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.handleDisconnect=this.handleDisconnect.bind(this),this.handleReconnect=this.handleReconnect.bind(this),this.handleReconnectAuthFailed=this.handleReconnectAuthFailed.bind(this),this.importElement=J.createRef(),this.state={contextActions:[{action:()=>{this.handleToolSelect(Vt.LINKER)},shortcut:ss.LINKER,isGlobal:!0},{action:()=>{this.sendClearFilter()},shortcut:qt.TABLE.CLEAR_ALL_FILTERS,isGlobal:!0},{action:()=>{Et.debug("Consume unhandled save shortcut")},shortcut:ss.SAVE,isGlobal:!0}],isAuthFailed:!1,isDisconnected:!1,isPanelsMenuShown:!1,isSettingsMenuShown:!1,widgets:[]}}componentDidMount(){this.initWidgets(),this.startListeningForDisconnect(),window.addEventListener("beforeunload",Oi.handleWindowBeforeUnload)}componentDidUpdate(e){const{dashboardData:t}=this.props;e.dashboardData!==t&&this.handleDataChange(t)}componentWillUnmount(){this.deinitWidgets(),this.stopListeningForDisconnect(),window.removeEventListener("beforeunload",Oi.handleWindowBeforeUnload)}goldenLayout;importElement;widgetListenerRemover;initWidgets(){const{connection:e}=this.props;if(e.subscribeToFieldUpdates==null){Et.warn("subscribeToFieldUpdates not supported, not initializing widgets");return}this.widgetListenerRemover=e.subscribeToFieldUpdates(t=>{Et.debug("Got updates",t),this.setState(({widgets:n})=>{const{updated:s,created:i,removed:o}=t,a=[...s,...o],r=n.filter(h=>!a.some(u=>u.name===h.name));return[...s,...i].forEach(h=>{h.name!=null&&h.name!==""&&r.push(h)}),{widgets:r}})})}deinitWidgets(){this.widgetListenerRemover?.()}openNotebookFromURL(){const{match:e}=this.props,{notebookPath:t}=e.params;if(t){const{session:n,sessionConfig:s}=this.props;if(n==null||s==null){Et.error("No session available to open notebook URL",t);return}const i={id:`/${t}`,itemName:`/${t}`},o=s.type,a={value:null,language:o};this.emitLayoutEvent($e.SELECT_NOTEBOOK,n,o,a,i,!0)}}sendClearFilter(){this.emitLayoutEvent(Qe.CLEAR_ALL_FILTERS)}emitLayoutEvent(e,...t){this.goldenLayout?.eventHub.emit(e,...t)}handleError(e){ve.isCanceled(e)||Et.error(e)}handleSettingsMenuHide(){this.setState({isSettingsMenuShown:!1})}handleSettingsMenuShow(){this.setState({isSettingsMenuShown:!0})}handleControlSelect(e,t=null){switch(Et.debug("handleControlSelect",e),e){case Ns.DROPDOWN_FILTER:this.emitLayoutEvent(Qe.OPEN_DROPDOWN,{title:"DropdownFilter",type:e,createNewStack:!0,dragEvent:t});break;case Ns.INPUT_FILTER:this.emitLayoutEvent(Qe.OPEN_INPUT,{title:"InputFilter",type:e,createNewStack:!0,dragEvent:t});break;case Ns.MARKDOWN:this.emitLayoutEvent(Cm.OPEN,{title:"Markdown",type:e,dragEvent:t});break;case Ns.FILTER_SET_MANAGER:this.emitLayoutEvent(Qe.OPEN_FILTER_SET_MANAGER,{title:"FilterSets",type:e,dragEvent:t});break;default:throw new Error(`Unrecognized control type ${e}`)}}handleToolSelect(e){Et.debug("handleToolSelect",e);const{activeTool:t,setActiveTool:n}=this.props;n(t===e?Vt.DEFAULT:e)}handleClearFilter(){this.sendClearFilter()}handleDataChange(e){const{updateWorkspaceData:t}=this.props,{closed:n,filterSets:s,links:i}=e;t({closed:n,filterSets:s,links:i})}handleGoldenLayoutChange(e){this.goldenLayout=e}handleLayoutConfigChange(e){const{updateWorkspaceData:t}=this.props;t({layoutConfig:e})}handleWidgetMenuClick(){this.setState(({isPanelsMenuShown:e})=>({isPanelsMenuShown:!e}))}handleWidgetSelect(e,t){this.setState({isPanelsMenuShown:!1}),Et.debug("handleWidgetSelect",e,t),this.openWidget(e,t)}handleWidgetsMenuClose(){this.setState({isPanelsMenuShown:!1})}handleAutoFillClick(){const{widgets:e}=this.state;Et.debug("handleAutoFillClick",e);const t=e.sort((n,s)=>n.title!=null&&s.title!=null?n.title.localeCompare(s.title):0);for(let n=0;n<t.length;n+=1)this.openWidget(t[n])}handleExportLayoutClick(){Et.info("handleExportLayoutClick"),this.setState({isPanelsMenuShown:!1});try{const{workspace:e}=this.props,{data:t}=e,n=Ia.exportLayout(t);Et.info("handleExportLayoutClick exportedConfig",n);const s=new Blob([JSON.stringify(n)],{type:"application/json"}),i=R.i18n.DateTimeFormat.format("yyyy-MM-dd-HHmmss",new Date),o=document.createElement("a");o.href=URL.createObjectURL(s),o.download=`deephaven-app-layout-${i}.json`,o.click()}catch(e){Et.error("Unable to export layout",e)}}handleImportLayoutClick(){Et.info("handleImportLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.importElement.current!=null&&(this.importElement.current.value="",this.importElement.current.click())}handleResetLayoutClick(){Et.info("handleResetLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.resetLayout()}handleImportLayoutFiles(e){e.stopPropagation(),e.preventDefault(),e.target.files!=null&&this.importLayoutFile(e.target.files?.[0])}handleDisconnect(){this.setState({isDisconnected:!0})}handleReconnect(){this.setState({isDisconnected:!1})}handleReconnectAuthFailed(){this.setState({isAuthFailed:!0})}async importLayoutFile(e){try{const{updateDashboardData:t,updateWorkspaceData:n}=this.props,s=await e.text(),i=JSON.parse(s),{filterSets:o,layoutConfig:a,links:r}=Ia.normalizeLayout(i);n({layoutConfig:a}),t(Tn,{filterSets:o,links:r})}catch(t){Et.error("Unable to import layout",t)}}async resetLayout(){const{layoutStorage:e,session:t}=this.props,{filterSets:n,layoutConfig:s,links:i}=await Ia.getDefaultLayout(e,t!==void 0),{updateDashboardData:o,updateWorkspaceData:a}=this.props;a({layoutConfig:s}),o(Tn,{filterSets:n,links:i})}handlePaste(e){if(e.target instanceof HTMLElement&&e.target.closest(".monaco-editor"))return;const{clipboardData:t}=e,n=t.getData("Text"),s=/“|”/g;s.test(n)&&(e.preventDefault(),e.stopPropagation(),document.execCommand("insertText",!1,n.replace(s,'"')))}handleLoadTablePlugin(e){const{plugins:t}=this.props,n=t.get(e);return n!=null&&n.TablePlugin!=null?n.TablePlugin:yl.loadComponentPlugin(e)}startListeningForDisconnect(){const{connection:e}=this.props;e.addEventListener(R.IdeConnection.EVENT_DISCONNECT,this.handleDisconnect),e.addEventListener(R.IdeConnection.EVENT_RECONNECT,this.handleReconnect),e.addEventListener(R.CoreClient.EVENT_RECONNECT_AUTH_FAILED,this.handleReconnectAuthFailed)}stopListeningForDisconnect(){const{connection:e}=this.props;e.removeEventListener(R.IdeConnection.EVENT_DISCONNECT,this.handleDisconnect),e.removeEventListener(R.IdeConnection.EVENT_RECONNECT,this.handleReconnect),e.removeEventListener(R.CoreClient.EVENT_RECONNECT_AUTH_FAILED,this.handleReconnectAuthFailed)}hydrateDefault(e,t){const{connection:n}=this.props,{metadata:s}=e;if(s?.type!=null&&(s?.id!=null||s?.name!=null)){const i=s.id!=null?{type:s.type,id:s.id}:{type:s.type,name:s.name,title:s.name};return{fetch:()=>n.getObject(i),localDashboardId:t,...e}}return Sl.hydrate(e,t)}hydrateGrid(e,t){return this.hydrateTable(e,t,e.metadata.type??R.VariableType.TABLE)}hydratePandas(e,t){return this.hydrateTable(e,t,R.VariableType.PANDAS)}hydrateTable(e,t,n=R.VariableType.TABLE){const{connection:s}=this.props;return{...e,getDownloadWorker:No.getServiceWorker,loadPlugin:this.handleLoadTablePlugin,localDashboardId:t,makeModel:()=>oI(s,e.metadata,n)}}hydrateChart(e,t){const{connection:n}=this.props;return{...e,localDashboardId:t,makeModel:()=>{const{metadata:s,panelState:i}=e;return iI(n,s,i)}}}openWidget(e,t){const{connection:n}=this.props;this.emitLayoutEvent(Ee.OPEN,{dragEvent:t,fetch:()=>n.getObject(e),widget:e})}getDashboardPlugins=fe(e=>[...e.entries()].filter(([,t])=>t.DashboardPlugin!=null).map(([t,{DashboardPlugin:n}])=>l.jsx(n,{},t)));render(){const{activeTool:e,plugins:t,user:n,workspace:s,serverConfigValues:i}=this.props,{data:o}=s,{layoutConfig:a}=o,{permissions:r}=n,{canUsePanels:c}=r,{contextActions:h,isAuthFailed:u,isDisconnected:m,isPanelsMenuShown:g,isSettingsMenuShown:p,widgets:C}=this.state,f=this.getDashboardPlugins(t);return l.jsxs("div",{className:$("app-main-tabs","w-100","h-100","d-flex","flex-column",e?`active-tool-${e.toLowerCase()}`:""),onPaste:this.handlePaste,tabIndex:-1,children:[l.jsx("nav",{className:"nav-container",children:l.jsxs("div",{className:"app-main-top-nav-menus",children:[l.jsx("img",{src:Im,alt:"Deephaven Data Labs",width:"115px",className:"ml-1"}),l.jsxs("div",{children:[l.jsxs(B,{kind:"ghost",className:"btn-panels-menu",icon:kp,onClick:()=>{},children:["Controls",l.jsx(Mc,{handleControlSelect:this.handleControlSelect,handleToolSelect:this.handleToolSelect,onClearFilter:this.handleClearFilter})]}),c&&l.jsxs(B,{kind:"ghost",className:"btn-panels-menu btn-show-panels","data-testid":"app-main-panels-button",onClick:this.handleWidgetMenuClick,icon:Op,children:["Panels",l.jsx(hi,{isShown:g,className:"panels-menu-popper",onExited:this.handleWidgetsMenuClose,closeOnBlur:!0,interactive:!0,children:l.jsx(sI,{widgets:C,onExportLayout:this.handleExportLayoutClick,onImportLayout:this.handleImportLayoutClick,onResetLayout:this.handleResetLayoutClick,onSelect:this.handleWidgetSelect})})]}),l.jsx(B,{kind:"ghost",className:$("btn-settings-menu",{"text-warning":n.operateAs!==n.name}),onClick:this.handleSettingsMenuShow,icon:l.jsx(Q,{icon:Oo,transform:"grow-3 right-1 down-1"}),tooltip:"User Settings"})]})]})}),l.jsxs(Gw,{emptyDashboard:l.jsx(aI,{onAutoFillClick:this.handleAutoFillClick}),id:Tn,layoutConfig:a,onGoldenLayoutChange:this.handleGoldenLayoutChange,onLayoutConfigChange:this.handleLayoutConfigChange,onLayoutInitialized:this.openNotebookFromURL,hydrate:this.hydrateDefault,children:[l.jsx(cx,{hydrate:this.hydrateGrid,getDownloadWorker:No.getServiceWorker,loadPlugin:this.handleLoadTablePlugin}),l.jsx(sx,{hydrate:this.hydrateChart}),l.jsx(ix,{}),l.jsx(ax,{hydrateConsole:Oi.hydrateConsole,notebooksUrl:new URL("/notebooks/",`${window.location}`).href}),l.jsx(rx,{}),l.jsx(Sx,{hydrate:this.hydratePandas}),l.jsx(Cx,{}),l.jsx(fx,{}),f]}),l.jsx(ft,{in:p,timeout:ze.transitionMidMs,classNames:"slide-left",mountOnEnter:!0,unmountOnExit:!0,children:l.jsx(On,{serverConfigValues:i,onDone:this.handleSettingsMenuHide})}),l.jsx(ie,{actions:h}),l.jsx("input",{ref:this.importElement,type:"file",accept:".json",style:{display:"none"},onChange:this.handleImportLayoutFiles}),l.jsx(Kp,{isOpen:m&&!u,icon:Ap,title:l.jsxs(l.Fragment,{children:[l.jsx(yn,{})," Attempting to reconnect..."]}),subtitle:"Please check your network connection."}),l.jsx(ci,{confirmButtonText:"Refresh",onConfirm:Oi.handleRefresh,isOpen:u,headerText:"Authentication failed",bodyText:"Credentials are invalid. Please refresh your browser to try and reconnect."})]})}}const SI=d=>({activeTool:gr(d),dashboardData:$t(d,Tn),layoutStorage:tI(d),plugins:YS(d),connection:iR(d,Tn),session:di(d,Tn)?.session,sessionConfig:di(d,Tn)?.config,user:ru(d),workspace:mr(d),serverConfigValues:nI(d)}),bI=Ct(SI,{setActiveTool:fr,updateDashboardData:Hn,updateWorkspaceData:xu})(wg(Oi));function wI(){return l.jsxs("div",{className:"app",children:[l.jsx(bI,{}),l.jsx(Vh,{})]})}const vI=Z.module("LocalWorkspaceStorage");class Ai{static STORAGE_KEY="deephaven.WorkspaceStorage";static async makeDefaultWorkspaceData(e,t){const{filterSets:n,links:s,layoutConfig:i}=await Ia.getDefaultLayout(e,t?.isConsoleAvailable);return{settings:{defaultDateTimeFormat:je.DEFAULT_DATETIME_FORMAT_STRING,formatter:[],timeZone:je.DEFAULT_TIME_ZONE_ID,showTimeZone:!1,showTSeparator:!0,disableMoveConfirmation:!1,defaultDecimalFormatOptions:{defaultFormatString:Re.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:Ge.DEFAULT_FORMAT_STRING},truncateNumbersWithPound:!1,defaultNotebookSettings:{isMinimapEnabled:!1}},layoutConfig:i,closed:[{}],links:s,filterSets:n}}static async makeDefaultWorkspace(e,t){return{data:await Ai.makeDefaultWorkspaceData(e,t)}}layoutStorage;constructor(e){this.layoutStorage=e}async load(e){try{return JSON.parse(localStorage.getItem(Ai.STORAGE_KEY)??"")}catch{return vI.info("Unable to load workspace data, initializing to default data"),Ai.makeDefaultWorkspace(this.layoutStorage,e)}}async save(e){return localStorage.setItem(Ai.STORAGE_KEY,JSON.stringify(e)),e}}class TI extends Error{isNoConsolesError=!0}function EI(d){return d.isNoConsolesError}const ks=Z.module("SessionUtils");var Pm=(d=>(d.ANONYMOUS="anonymous",d.PARENT="parent",d))(Pm||{});function yI(){return new URL("/jsapi",`${window.location}`)}function _m(){const d=yI();return`${d.protocol}//${d.host}`}function RI(){switch(new URLSearchParams(window.location.search).get("authProvider")){case"parent":return"parent";default:return"anonymous"}}function xI(){const d=_m();return ks.info(`Starting connection to '${d}'...`),new R.IdeConnection(d)}async function II(d){ks.info("Getting console types...");const e=await d.getConsoleTypes();if(ks.info("Available types:",e),e.length===0)throw new TI("No console types available");const t=e[0];ks.info("Starting session with type",t);const n=await d.startSession(t),s={type:t,id:_e.generate()};return ks.info("Console session established",s),{session:n,config:s,connection:d}}function DI(){const d=_m();return ks.info("createCoreClient",d),new R.CoreClient(d)}async function FI(){if(window.opener==null)throw new Error("window.opener is null, unable to send auth request.");return new Promise(d=>{const e=t=>{const{data:n}=t;if(ks.debug("Received message",n),n?.message!=="loginOptions"){ks.debug("Ignore received message",n);return}window.removeEventListener("message",e),d(n.payload)};window.addEventListener("message",e),window.opener.postMessage("requestLoginOptionsFromParent","*")})}async function NI(d){switch(d){case"parent":return FI();case"anonymous":return{type:R.CoreClient.LOGIN_TYPE_ANONYMOUS};default:throw new Error(`Unknown auth type: ${d}`)}}class MI{storageService;root;constructor(e,t=""){this.storageService=e,this.root=t}async getLayouts(){return(await this.storageService.listItems(this.root,"*.json")).map(t=>t.basename)}async getLayout(e){const n=await(await this.storageService.loadFile(`${this.root}/${e}`)).text();return JSON.parse(n)}}const Co=Z.module("GrpcFileStorageTable");class er{static REFRESH_DEBOUNCE=50;storageService;baseRoot;root;currentSize=0;currentViewport;listeners=[];viewportUpdatePromise;currentViewportData;childTables=new Map;constructor(e,t="",n=t){this.storageService=e,this.baseRoot=t,this.root=n,n===t&&(this.doRefresh=Ye(this.doRefresh.bind(this),er.REFRESH_DEBOUNCE))}removeBaseRoot(e){return he.removeRoot(this.baseRoot,e)}getViewportData(){return this.viewportUpdatePromise||this.refreshInternal(),this.viewportUpdatePromise??Promise.resolve({items:[],offset:0})}getSnapshot(e){throw new Error("Method not implemented.")}get size(){return this.currentSize}setExpanded(e,t){const n=e.split("/");let s=n.shift();if((s===void 0||s==="")&&(s=n.shift()),s===void 0||s==="")throw new Error(`Invalid path: ${e}`);const i=n.join("/");if(t){if(!this.childTables.has(s)){const o=new er(this.storageService,this.baseRoot,`${this.root}/${s}`);this.childTables.set(s,o)}i&&this.childTables.get(s)?.setExpanded(i,t)}else this.childTables.has(s)&&(i?this.childTables.get(s)?.setExpanded(i,t):this.childTables.delete(s));this.currentViewport&&this.refreshInternal()}collapseAll(){this.childTables.clear(),this.currentViewport&&this.refreshInternal()}setSearch(e){throw new Error("Method not implemented.")}setViewport(e){this.currentViewport=e,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(e){return this.listeners=[...this.listeners,e],()=>{this.listeners=this.listeners.filter(t=>t!==e)}}doRefresh(e){Co.debug2("doRefresh",this.root),e(this.fetchData())}refresh(){Co.debug2("refresh",this.root),this.viewportUpdatePromise?.cancel();const e=new Promise(n=>{this.doRefresh(n)}),t=ve.makeCancelable(e.then(n=>{if(this.viewportUpdatePromise!==t)throw new $i;return this.currentViewportData=n,this.sendUpdate(),n}));t.catch(n=>{ve.isCanceled(n)||Co.error("Error updating viewport",n)}),this.viewportUpdatePromise=t}refreshInternal(){try{this.refresh()}catch(e){ve.isCanceled(e)||Co.error("Unable to refresh data",e)}}async fetchData(){const{currentViewport:e}=this;if(!e)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:a}=i;if(a===this.removeBaseRoot(`${this.root}/${o}`)&&i.type==="directory"){const r=this.childTables.get(o);if(r!=null){r.setViewport({top:0,bottom:e.bottom-s});const c=await r.getViewportData();n.splice(s+1,0,...c.items)}}}return this.currentSize=n.length,Co.debug2(this.root,"items",n,e),n=n.slice(e.top,e.bottom),{items:n,offset:e.top}}sendUpdate(){const{listeners:e}=this,t=this.currentViewportData??{items:[],offset:0};for(let n=0;n<e.length;n+=1)e[n](t)}}const kI=Z.module("GrpcFileStorage");class kc{static REFRESH_THROTTLE=150;storageService;tables=[];root;constructor(e,t=""){this.storageService=e,this.root=t}removeRoot(e){return he.removeRoot(this.root,e)}addRoot(e){return he.addRoot(this.root,e)}async createDirectory(e){return await this.storageService.createDirectory(this.addRoot(e)),this.refreshTables(),{type:"directory",id:e,filename:e,basename:he.getBaseName(e)}}async getTable(){const e=new er(this.storageService,this.root);return this.tables.push(e),e}async saveFile(e){const t=dh.storage.FileContents.text(e.content);return await this.storageService.saveFile(this.addRoot(e.filename),t,!0),this.refreshTables(),e}async loadFile(e){const n=await(await this.storageService.loadFile(this.addRoot(e))).text();return{filename:e,basename:he.getBaseName(e),content:n}}async deleteFile(e){await this.storageService.deleteItem(this.addRoot(e)),this.refreshTables()}async moveFile(e,t){await this.storageService.moveItem(this.addRoot(e),this.addRoot(t)),this.refreshTables()}async info(e){const t=await this.storageService.listItems(this.addRoot(he.getPath(e)),he.getBaseName(e));if(t.length===0)throw new xc;if(t.length>1)throw kI.error("More than one matching file found, should never happen.",t),new Error("More than one matching file found");const n=t[0];return{filename:this.removeRoot(n.filename),basename:n.basename,id:this.removeRoot(n.filename),type:n.type}}refreshTables=Ls(()=>{this.tables.forEach(e=>e.refresh())},kc.REFRESH_THROTTLE)}const Os=Z.module("AppInit");async function OI(){Os.debug("Loading plugins...");try{const d=await yl.loadJson("/js-plugins/manifest.json");Os.debug("Plugin manifest loaded:",d);const e=[];for(let s=0;s<d.plugins.length;s+=1){const{name:i,main:o}=d.plugins[s],a=`/js-plugins/${i}/${o}`;e.push(yl.loadModulePlugin(a))}const t=await Promise.all(e),n=new Map;for(let s=0;s<t.length;s+=1){const{name:i}=d.plugins[s];n.set(i,t[s])}return Os.info("Plugins loaded:",n),n}catch(d){return Os.error("Unable to load plugins:",d),new Map}}async function AI(d){let e;try{e=await II(d)}catch(t){if(!EI(t))throw t}return e}function Oc(d){const{workspace:e,setActiveTool:t,setCommandHistoryStorage:n,setDashboardData:s,setFileStorage:i,setLayoutStorage:o,setDashboardConnection:a,setDashboardSessionWrapper:r,setPlugins:c,setUser:h,setWorkspace:u,setWorkspaceStorage:m,setServerConfigValues:g}=d,[p,C]=b.useState(),[f,S]=b.useState(),[v,w]=b.useState(!0),T=b.useCallback(async()=>{try{Os.info("Initializing Web UI","0.35.0",navigator.userAgent);const N=DI(),_=RI();Os.info(`Login using auth type ${_}...`),await N.login(await NI(_));const P=await OI(),U=await(_===Pm.ANONYMOUS&&N.getAsIdeConnection==null?xI():N.getAsIdeConnection());U.addEventListener(R.IdeConnection.EVENT_SHUTDOWN,xe=>{const{detail:at}=xe;Os.info("Shutdown",`${JSON.stringify(at)}`),C(`Server shutdown: ${at??"Unknown reason"}`),S(null)});const O=await AI(U),j="user",k=N.getStorageService(),A=new MI(k,"/layouts"),H=new kc(k,"/notebooks"),K=new Ai(A),q=new Fx,oe=await K.load({isConsoleAvailable:O!==void 0}),{data:W}=oe,{settings:G}=W;G.defaultDecimalFormatOptions===void 0&&(G.defaultDecimalFormatOptions={defaultFormatString:Re.DEFAULT_FORMAT_STRING}),G.defaultIntegerFormatOptions===void 0&&(G.defaultIntegerFormatOptions={defaultFormatString:Ge.DEFAULT_FORMAT_STRING}),G.truncateNumbersWithPound===void 0&&(G.truncateNumbersWithPound=!1);const{shortcutOverrides:ne={}}=G,ce=Ae.isMacPlatform?ne.mac??{}:ne.windows??{};Object.entries(ce).forEach(([xe,at])=>{Ne.get(xe)?.setKeyState(at)});const te={filterSets:W.filterSets,links:W.links},re=await N.getServerConfigValues(),we=new Map(re),Ie={name:j,operateAs:j,groups:[],permissions:{isACLEditor:!1,isSuperUser:!1,isQueryViewOnly:!1,isNonInteractive:!1,canUsePanels:!0,canCreateDashboard:!0,canCreateCodeStudio:!0,canCreateQueryMonitor:!0,canCopy:we.get("internal.webClient.appInit.canCopy")!=="false",canDownloadCsv:we.get("internal.webClient.appInit.canDownloadCsv")!=="false"}};t(Vt.DEFAULT),g(we),n(q),s(Tn,te),i(H),o(A),a(Tn,U),O!==void 0&&r(Tn,O),c(P),h(Ie),m(K),u(oe)}catch(N){Os.error(N),C(N)}},[t,n,s,i,o,a,r,c,h,u,m,g]),y=b.useCallback(()=>{document.fonts!=null?document.fonts.ready.then(()=>{w(!1)}):w(!1)},[]);b.useEffect(function(){T(),y()},[T,y]);const E=e==null&&p==null||v,D=!E&&p==null,F=p!=null||f!=null?`${p??f}`:null;return l.jsxs(l.Fragment,{children:[D&&l.jsx(wI,{}),l.jsx(sr,{isLoading:E,isLoaded:D,errorMessage:F}),l.jsxs("div",{id:"preload-fonts",style:{visibility:"hidden",position:"absolute",top:-1e4},children:[l.jsx("p",{className:"fira-sans-regular",children:"preload"}),l.jsx("p",{className:"fira-sans-semibold",children:"preload"}),l.jsx("p",{className:"fira-mono",children:"preload"})]})]})}Oc.propTypes={workspace:I.shape({}),workspaceStorage:I.shape({close:I.func}),setActiveTool:I.func.isRequired,setCommandHistoryStorage:I.func.isRequired,setDashboardData:I.func.isRequired,setFileStorage:I.func.isRequired,setLayoutStorage:I.func.isRequired,setDashboardConnection:I.func.isRequired,setDashboardSessionWrapper:I.func.isRequired,setPlugins:I.func.isRequired,setUser:I.func.isRequired,setWorkspace:I.func.isRequired,setWorkspaceStorage:I.func.isRequired};Oc.defaultProps={workspace:null,workspaceStorage:null};const LI=d=>({workspace:mr(d),workspaceStorage:zS(d)}),vh=Ct(LI,{setActiveTool:fr,setCommandHistoryStorage:QS,setDashboardData:Yu,setFileStorage:JS,setLayoutStorage:Nx,setDashboardConnection:oR,setDashboardSessionWrapper:aR,setPlugins:tb,setUser:XS,setWorkspace:Ru,setWorkspaceStorage:ZS,setServerConfigValues:nb})(Oc);function PI(){return l.jsx(vg,{basename:"/ide/",children:l.jsxs(Tg,{children:[l.jsx(_c,{exact:!0,path:"/",component:vh}),l.jsx(_c,{path:"/notebook/:notebookPath+",component:vh}),l.jsx(Eg,{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 _I(){"serviceWorker"in navigator&&navigator.serviceWorker.getRegistrations().then(d=>{d.forEach(e=>{e.scope.endsWith("/download/")||e.unregister()})})}function GI(){return _I(),No.registerOnLoaded(),Ht.init({getWorker:()=>new Rg}),window["__react-beautiful-dnd-disable-dev-warnings"]=!0,l.jsx(Eh,{store:Cr,children:l.jsx(PI,{})})}export{GI as AppRoot,GI as default};
43
- //# sourceMappingURL=AppRoot-45c47459.js.map